{ "$id": "https://raw.githubusercontent.com/ilbertt/nibrunner/main/crates/protocol/schema/reported.schema.json", "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "HostReportedState", "description": "What one host is running, as the daemon last wrote it to `reported.json` in its\n`paths.state_dir`.", "type": "object", "properties": { "acceptedDigest": { "description": "The document this host is converging on, as `sha256sum` reads the file it came from.\nAbsent until one has been taken up. A control plane checks it against the write it made\nto learn that this host is on that document rather than on the one before it — which is\nwhat `instances` alone cannot say about a document that changed nothing about an app.", "anyOf": [ { "$ref": "#/$defs/Sha256Digest" }, { "type": "null" } ] }, "acceptedRevision": { "description": "The `revision` that document named, if it named one — the control plane's own word for\nwhat this host is converging on, beside the digest that is this host's.", "anyOf": [ { "$ref": "#/$defs/Revision" }, { "type": "null" } ] }, "allocatable": { "description": "What is left once every booted app is taken off.", "$ref": "#/$defs/HostCapacity" }, "capacity": { "description": "What the machine has.", "$ref": "#/$defs/HostCapacity" }, "checkpoints": { "type": "array", "items": { "$ref": "#/$defs/ReportedCheckpoint" } }, "cron": { "type": [ "array", "null" ], "items": { "$ref": "#/$defs/CronListing" } }, "exports": { "type": "array", "items": { "$ref": "#/$defs/ReportedExport" } }, "hostId": { "$ref": "#/$defs/HostId" }, "instances": { "type": "array", "items": { "$ref": "#/$defs/ReportedInstance" } }, "message": { "description": "Set when the last document this host was handed was refused — malformed, or not the\ndocument this host reads — and cleared when a readable one is taken up. A control plane\nthat only reads this file learns from it that its last write did not land, and why.", "anyOf": [ { "$ref": "#/$defs/StateMessage" }, { "type": "null" } ], "default": null }, "reportedAt": { "$ref": "#/$defs/Timestamp" }, "state": { "$ref": "#/$defs/HostState" }, "versions": { "$ref": "#/$defs/HostVersions" }, "volumes": { "type": "array", "items": { "$ref": "#/$defs/ReportedVolume" } } }, "required": [ "hostId", "reportedAt", "state", "capacity", "allocatable", "versions", "cron", "volumes", "instances", "checkpoints", "exports" ], "$defs": { "AppId": { "description": "an identifier", "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,62}$" }, "CheckpointId": { "description": "an identifier", "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,62}$" }, "CheckpointState": { "type": "string", "enum": [ "pending", "ready", "deleted", "failed" ] }, "ComputeUsage": { "type": "object", "properties": { "cpuShare": { "type": [ "number", "null" ], "format": "double" }, "measuredAt": { "$ref": "#/$defs/Timestamp" }, "memoryTotalBytes": { "type": "integer", "format": "uint64", "minimum": 0 }, "memoryUsedBytes": { "type": "integer", "format": "uint64", "minimum": 0 } }, "required": [ "memoryTotalBytes", "memoryUsedBytes", "measuredAt" ] }, "CronCommand": { "type": "string", "maxLength": 32768 }, "CronListing": { "type": "object", "properties": { "appId": { "$ref": "#/$defs/AppId" }, "deploymentId": { "$ref": "#/$defs/DeploymentId" }, "enabled": { "type": "boolean" }, "jobs": { "type": "array", "items": { "$ref": "#/$defs/RegisteredCronJob" } }, "timeZone": { "type": "string" } }, "required": [ "appId", "deploymentId", "enabled", "timeZone", "jobs" ] }, "CronSchedule": { "type": "string" }, "DeploymentId": { "description": "an identifier", "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,62}$" }, "ExportId": { "description": "an identifier", "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,62}$" }, "ExportState": { "type": "string", "enum": [ "pending", "preparing", "ready", "failed", "expired" ] }, "FilesystemUsage": { "type": "object", "properties": { "measuredAt": { "$ref": "#/$defs/Timestamp" }, "totalBytes": { "type": "integer", "format": "uint64", "minimum": 0 }, "usedBytes": { "type": "integer", "format": "uint64", "minimum": 0 } }, "required": [ "totalBytes", "usedBytes", "measuredAt" ] }, "HostCapacity": { "type": "object", "properties": { "cacheBytes": { "type": "integer", "format": "uint64", "minimum": 0 }, "memoryMib": { "type": "integer", "format": "uint64", "minimum": 0 }, "vcpuCount": { "type": "integer", "format": "uint32", "minimum": 0 } }, "required": [ "vcpuCount", "memoryMib", "cacheBytes" ] }, "HostId": { "description": "an identifier", "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,62}$" }, "HostPort": { "type": "integer", "maximum": 65535, "minimum": 1 }, "HostState": { "type": "string", "enum": [ "registering", "ready", "draining", "unreachable" ] }, "HostVersions": { "type": "object", "properties": { "agent": { "type": "string" }, "firecracker": { "type": "string" }, "guestImage": { "type": "string" }, "zerofs": { "type": "string" } }, "required": [ "agent", "guestImage", "zerofs", "firecracker" ] }, "InstanceState": { "type": "string", "enum": [ "pending", "starting", "running", "unhealthy", "stopping", "stopped", "idle", "failed" ] }, "Ipv4Address": { "description": "an IPv4 address", "type": "string", "pattern": "^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])$" }, "ObjectKey": { "description": "between 1 and 1024 characters", "type": "string", "maxLength": 1024, "minLength": 1 }, "RegisteredCronJob": { "type": "object", "properties": { "command": { "$ref": "#/$defs/CronCommand" }, "environment": { "anyOf": [ { "$ref": "#/$defs/TenantEnvironment" }, { "type": "null" } ] }, "jobId": { "type": "string" }, "nextRunAt": { "anyOf": [ { "$ref": "#/$defs/Timestamp" }, { "type": "null" } ] }, "schedule": { "$ref": "#/$defs/CronSchedule" } }, "required": [ "jobId", "schedule", "command", "nextRunAt" ] }, "ReportedCheckpoint": { "type": "object", "properties": { "checkpointId": { "$ref": "#/$defs/CheckpointId" }, "message": { "anyOf": [ { "$ref": "#/$defs/StateMessage" }, { "type": "null" } ] }, "readyAt": { "anyOf": [ { "$ref": "#/$defs/Timestamp" }, { "type": "null" } ] }, "reference": { "anyOf": [ { "$ref": "#/$defs/StateMessage" }, { "type": "null" } ] }, "state": { "$ref": "#/$defs/CheckpointState" }, "volumeId": { "$ref": "#/$defs/VolumeId" } }, "required": [ "checkpointId", "volumeId", "state" ] }, "ReportedExport": { "type": "object", "properties": { "checkpointId": { "anyOf": [ { "$ref": "#/$defs/CheckpointId" }, { "type": "null" } ] }, "exportId": { "$ref": "#/$defs/ExportId" }, "message": { "anyOf": [ { "$ref": "#/$defs/StateMessage" }, { "type": "null" } ] }, "readyAt": { "anyOf": [ { "$ref": "#/$defs/Timestamp" }, { "type": "null" } ] }, "sizeBytes": { "type": [ "integer", "null" ], "format": "uint64", "minimum": 0 }, "state": { "$ref": "#/$defs/ExportState" } }, "required": [ "exportId", "state" ] }, "ReportedInstance": { "type": "object", "properties": { "appId": { "$ref": "#/$defs/AppId" }, "compute": { "anyOf": [ { "$ref": "#/$defs/ComputeUsage" }, { "type": "null" } ] }, "convergedAt": { "description": "When the instance first became what the document asks of it, for the `deploymentId` and\n`desiredState` it now carries. Absent while it is still on its way there, and for a\ndeployment this host was not there to see arrive.", "anyOf": [ { "$ref": "#/$defs/Timestamp" }, { "type": "null" } ] }, "deploymentId": { "$ref": "#/$defs/DeploymentId" }, "guestIpv4": { "anyOf": [ { "$ref": "#/$defs/Ipv4Address" }, { "type": "null" } ] }, "hostPort": { "anyOf": [ { "$ref": "#/$defs/HostPort" }, { "type": "null" } ] }, "lastExitCode": { "type": [ "integer", "null" ], "format": "int32" }, "lastRestart": { "description": "The last of those restarts. Absent until there has been one.", "anyOf": [ { "$ref": "#/$defs/ReportedRestart" }, { "type": "null" } ] }, "layerDigests": { "description": "The layers the running microVM was booted from, bottom first. Empty until one has been.", "type": "array", "items": { "$ref": "#/$defs/Sha256Digest" } }, "message": { "anyOf": [ { "$ref": "#/$defs/StateMessage" }, { "type": "null" } ] }, "restartCount": { "description": "Times the supervisor inside the guest has restarted the tenant since this host last booted\nthe app afresh. A restore from a snapshot keeps the count; a cold boot starts it over.", "type": "integer", "format": "uint32", "minimum": 0 }, "startedAt": { "anyOf": [ { "$ref": "#/$defs/Timestamp" }, { "type": "null" } ] }, "state": { "$ref": "#/$defs/InstanceState" } }, "required": [ "appId", "deploymentId", "state", "compute", "restartCount" ] }, "ReportedRestart": { "description": "A tenant restart as the host heard of it: what the guest said, and when it said it.", "type": "object", "properties": { "at": { "$ref": "#/$defs/Timestamp" }, "attempt": { "description": "1 for the first restart since the tenant last stayed up long enough to earn its budget\nback, up to `budget`.", "type": "integer", "format": "uint32", "minimum": 0 }, "backoffMs": { "type": "integer", "format": "uint64", "minimum": 0 }, "budget": { "type": "integer", "format": "uint32", "minimum": 0 }, "exit": { "$ref": "#/$defs/TenantExit" }, "reason": { "$ref": "#/$defs/StateMessage" } }, "required": [ "at", "attempt", "budget", "exit", "reason", "backoffMs" ] }, "ReportedVolume": { "type": "object", "properties": { "appId": { "$ref": "#/$defs/AppId" }, "devicePath": { "type": [ "string", "null" ] }, "message": { "anyOf": [ { "$ref": "#/$defs/StateMessage" }, { "type": "null" } ] }, "sizeBytes": { "type": "integer", "format": "uint64", "minimum": 0 }, "state": { "$ref": "#/$defs/VolumeState" }, "storagePrefix": { "anyOf": [ { "$ref": "#/$defs/ObjectKey" }, { "type": "null" } ] }, "usage": { "anyOf": [ { "$ref": "#/$defs/FilesystemUsage" }, { "type": "null" } ] }, "volumeId": { "$ref": "#/$defs/VolumeId" } }, "required": [ "volumeId", "appId", "state", "sizeBytes", "usage" ] }, "Revision": { "description": "between 1 and 128 printable characters, without spaces", "type": "string", "pattern": "^[\\x21-\\x7e]{1,128}$" }, "Sha256Digest": { "description": "a lowercase hex sha-256", "type": "string", "pattern": "^[0-9a-f]{64}$" }, "StateMessage": { "type": "string", "maxLength": 512 }, "TenantEnvironment": { "type": "object", "additionalProperties": { "$ref": "#/$defs/TenantValue" }, "propertyNames": { "not": { "const": "__proto__" }, "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" } }, "TenantExit": { "description": "How a tenant process ended: the code it exited with, or the signal that killed it.", "oneOf": [ { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" } }, "additionalProperties": false, "required": [ "code" ] }, { "type": "object", "properties": { "signal": { "type": "integer", "format": "int32" } }, "additionalProperties": false, "required": [ "signal" ] } ] }, "TenantValue": { "description": "Only complete `${NAME}` references are filled in for NAME in NIBRUN_HOSTNAME, NIBRUN_HTTP_PORT. Bare names, incomplete references and other dollar signs remain literal; complete references to unknown `NIBRUN_` names are refused.", "type": "string", "maxLength": 32768 }, "Timestamp": { "description": "an ISO 8601 instant with an offset", "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2})$" }, "VolumeId": { "description": "an identifier", "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,62}$" }, "VolumeState": { "type": "string", "enum": [ "pending", "ready", "detached", "deleted", "failed" ] } } }