Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 54 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions architecture/client-transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ with `finish_non_exhaustive()`.
| `download_artifact(&artifact)` | GET | `/v1/artifacts/{artifact.artifact_id}` | — | `BoxBytesStream` |
| `create_workspace(&workspace_id, &handle, &manifest)` | POST | `/v1/workspaces` | `{schema_version, workspace_id, handle, manifest}` | `WorkspaceReady` |
| `create_workspace_derived(&workspace_id, &handle, &base_manifest_digest, &patch)` | POST | `/v1/workspaces/derive` | `{schema_version, workspace_id, handle, patch}` | `WorkspaceReady` |
| `telemetry()` | GET | `/v1/node/telemetry` | — | `NodeTelemetry` |
| `telemetry_for(&node_id)` | GET | `/v1/node/telemetry` | — | `NodeTelemetry` (node id must match) |

Prose notes on the non-obvious ones:

Expand All @@ -198,6 +200,14 @@ Prose notes on the non-obvious ones:
`eggwork-artifact-id` and `eggwork-artifact-digest` to equal the requested record's. A missing,
unparseable, or mismatched header is `InvalidResponse` and the body is not handed back. These are
the anti-mixup checks that make a content-addressed transfer trustworthy across a stream.
- **`telemetry` is the optional host-observation read.** It is a `GET` on the node's own cache; the
node never contacts its provider because of a remote read. The response is validated on arrival:
the body must be within 64 KiB, the `schema_version` must be the known one, the `state` and
`observation` must agree, and every measurement must satisfy the domain's range rules. A `404` — a
node that predates the contract — is `ClientError::TelemetryUnsupported`, which is distinct from the
`403` an unauthorized principal receives and from the `state: "unavailable"` a failing provider
produces. `telemetry_for` additionally refuses a response naming a different node, so a
fixed-target caller cannot be handed a measurement taken somewhere else.
- **`create_workspace_derived` performs a local consistency check first:** if
`patch.base_manifest_digest != *base_manifest_digest` it returns `InvalidResponse` without
sending anything. The base digest travels only inside the patch, so this is a caller-argument
Expand Down Expand Up @@ -385,6 +395,7 @@ makes a foreign base look *missing* (`409 base_manifest_missing`) rather than *f
| `InvalidResponse` | `node response was malformed` | Response did not match the expected contract (see below). | Caller's judgement; usually a hard stop for that response. | Nothing beyond the variant. |
| `ProtocolIncompatible` | `node protocol is incompatible` | `ensure_protocol_compatible`: the node's `[min, max]` does not contain `1.0`. | No — retrying the same node cannot help. | Nothing; the node's actual range is not carried. |
| `UnsupportedCapability` | `node does not support a required protocol capability` | Node does not advertise `exec.argv.v1`. | No. | Nothing; the advertised feature list is not carried. |
| `TelemetryUnsupported` | `node does not implement the node telemetry contract` | `GET /v1/node/telemetry` answered 404: the node predates the contract. | No. | Nothing. |

`InvalidResponse` is produced in every one of these situations: `serde_json::from_slice` failure on
a response body; `serde_json::to_vec` failure on a request body; a missing, unparseable, or
Expand All @@ -395,6 +406,13 @@ blob upload; an NDJSON partial line exceeding `eggwork_core::MAX_EVENT_BYTES`; a
and an `ExecutionEvent` that fails `validate()`. Note the last-but-one category is **local**: the
`create_workspace_derived` base-digest mismatch is detected before any request is sent.

The telemetry read adds its own refusals: a body over 64 KiB, a `schema_version` the client does not
know (`ProtocolIncompatible`, not `InvalidResponse` — the node speaks a different version of this
contract), a `state` that contradicts the presence of an observation, a measurement outside the
domain's range, a `node_id` that is not the one the caller asked for, and a source the client does not
know. A `404` is `TelemetryUnsupported`, not `InvalidResponse`: it means the node has no such route,
not that the route answered badly.

**Redaction.** `impl fmt::Debug for ClientError` is hand-written: `Transport` prints
`ClientError::Transport([REDACTED])`, and `Api` prints `status` and `code` but renders `message` as
`"[REDACTED]"`. The `#[error("node returned HTTP {status}: {code}")]` display string omits
Expand Down
88 changes: 88 additions & 0 deletions architecture/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,91 @@ The core data model is protocol-neutral. Later control-plane work will define ve
See the [control-plane roadmap](../plans/subsystems/control-plane-protocol-roadmap.md) and [ADR-0002](../plans/adrs/ADR-0002-eggstack-transport-and-mtls.md).

Component deep dives: [server-node.md](server-node.md) (node side of the wire contract) and [client-transport.md](client-transport.md) (client side). Overview: [overview.md](overview.md).

## The node telemetry wire contract (schema version 1)

`GET /v1/node/telemetry` returns a `NodeTelemetry` document. This is the **frozen**
contract for the optional host-telemetry projection, and the reference for the
downstream CodeGG worker-telemetry consumer.

```json
{
"schema_version": 1,
"node_id": "worker-01",
"source": "gregg",
"state": "ready",
"age_ms": 231,
"last_error": null,
"observation": {
"observed_at_unix_ms": 1729460000123,
"sample_interval_ms": 1000,
"cpu": { "value": { "logical_cores": 8, "usage_pct": 12.5, "iowait_pct": 1.5 } },
"memory": { "value": { "available_bytes": 4000000, "total_bytes": 8000000, "used_bytes": 4000000 } },
"load": { "value": { "one": 0.5, "five": 0.25, "fifteen": 0.125 } },
"swap": "unsupported",
"disk": { "value": { "available_bytes": 900, "total_bytes": 1000, "volume_count": 1 } },
"disk_io": { "value": { "read_bytes_per_sec": 11, "write_bytes_per_sec": 22 } },
"network": { "value": { "rx_bytes_per_sec": 33, "tx_bytes_per_sec": 44 } }
}
}
```

### Fields

| Field | Type | Meaning |
| --- | --- | --- |
| `schema_version` | `1` | The contract version. A reader refuses any other value rather than guessing. Additive changes stay within version 1. |
| `node_id` | string | The node that produced the observation. |
| `source` | `"gregg"` | The kind of provider the measurement came from. The set is closed; an unknown source is refused. |
| `state` | enum | What the *provider* is doing. See below. |
| `age_ms` | number or null | How long ago, in milliseconds, the node received the observation, measured on the node's monotonic clock. `null` when there is no observation. |
| `last_error` | enum or null | The bounded category of the most recent provider failure. `null` when the last interaction succeeded or none has failed. |
| `observation` | object or null | The most recent measurement the node holds. `null` when it holds none. |

### Provider states

`state` describes the provider, never the host. A node with no provider is
`disabled`, which is not a host with zero usage.

| `state` | `observation` | Meaning |
| --- | --- | --- |
| `disabled` | absent | No provider is configured. The node claims no host measurements. |
| `warming` | absent | The provider is alive but has not produced a sample yet. |
| `ready` | present | A sample is present and within its freshness bound. |
| `stale` | present | A sample is present but older than the freshness bound. |
| `unavailable` | present or absent | The provider could not be reached. |
| `invalid` | present or absent | The provider answered with something unusable. |

A sample is **current only when the state is `ready`**. A reader that needs a
fresh measurement must check the state, not merely the presence of an
observation. `unavailable` and `invalid` may still carry the last sample the
node took; `age_ms` says how old it is.

### Measurement groups

Each measurement group is one of:

| Form | Meaning |
| --- | --- |
| `{ "value": { ... } }` | A validated measurement. |
| `"unsupported"` | The host platform cannot produce this measurement. |
| `"unknown"` | The measurement is supported, but this sample carried no value. |

A missing measurement is **never zero**. A reader can tell "this host has no
swap" apart from "this host has swap and it is currently unused".

The groups are `cpu` (logical cores, busy percentage, optional I/O-wait
percentage), `memory` (available/total/used bytes), `load` (one/five/fifteen
minute load averages), `swap` (used/total bytes), `disk` (aggregate capacity
across the volumes the provider reported, with no mount path), `disk_io`
(aggregate read/write throughput), and `network` (aggregate receive/transmit
throughput).

### What the contract deliberately does not carry

No provider address, no mount path, no device or interface identity, no
hostname, no per-execution measurement, and no raw provider JSON. The node's
own `NodeStatus` and `NodeCapabilities` are unchanged: they answer "is this
node accepting work", and this document answers "what did this host look
like". The two are never merged, and nothing in this contract qualifies an
execution.
Loading
Loading