Skip to content

Optional Gregg host telemetry (M001+M002) and the staged-helper ETXTBSY corrective - #2

Merged
dbowm91 merged 13 commits into
mainfrom
planning/optional-gregg-telemetry-m001-m002
Oct 19, 2026
Merged

dbowm91 merged 13 commits into
mainfrom
planning/optional-gregg-telemetry-m001-m002

Conversation

@dbowm91

@dbowm91 dbowm91 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes the optional Gregg host-telemetry line and the corrective that eliminates the ETXTBSY refusal CI hit on it.

What this branch contains

Optional Gregg host telemetry (M001, M002) — the closed line:

  • M001 (ac55985) — a default-off loopback Gregg adapter and cache. The provider stays on the node's loopback interface; Eggwork reads it optionally and nothing else changes. The normalized measurement vocabulary lives in eggwork-core so the client can own the wire DTO without depending on the provider's types.
  • M002 (5ccb1e6) — an authorized node telemetry read route behind a narrow telemetry grant, with the contract frozen as eggwork_core::NodeTelemetry schema version 1. The grant is separate from status on purpose: folding it in would silently widen every existing status grant.

Closure records: plans/closure/optional-gregg-host-telemetry/001-status.md, .../002-status.md.

Operations M004b (c91a9f7, cf51114) — the corrective for the CI failure this branch's M002 closure hit.

The CI failure and the fix

CI run 39306109740 failed cargo test --locked --workspace --all-targets:
malformed_private_spec_and_unavailable_status_channel_do_not_launch_target
panicked at crates/eggwork-sandbox-helper/tests/landlock_runner.rs:471 with
ExecutableFileBusy ("Text file busy").

This is the residual the M004a closure characterised and dispositioned rather
than fixed. That characterisation turned out to be incomplete in a way that
mattered:

  • The refusal is not a microsecond-wide timing window, and it is not a
    write-back problem. execve() calls exe_file_deny_write_access(), which
    is deny_write_access() — atomic_dec_unless_positive(&inode->i_writecount)
    — so Linux refuses to execute an inode that is open for writing. The
    access is taken by every write-open of a regular file and released with that
    file's teardown, which is deferred, so the refusal outlives the descriptor
    that took it: the failing inode is not in any /proc/<pid>/fd.
  • The M004a write_open: no-writer probe could not have detected a writer:
    opening a file for writing succeeds whether or not another writer exists.
  • The fixture module's own claim that atomic publication made a fixture immune
    to ETXTBSY was false, and that false claim is what left CI red.

So the fix removes the write rather than racing it:

  • stage links the Cargo-built helper into the fixture's private 0700
    directory instead of copying it, so the file the fixture executes is never
    opened for writing. There is no copy fallback: a copy is a file that was
    written, and a written file is exactly what the kernel refuses to execute.
    Staging fails loudly when a link is impossible.
  • A link carries the source's mode, and verify_trusted_helper rejects a
    helper anyone but its owner may write. Cargo derives the executable's mode
    from the umask, so the fixture clears the group and world write bits of the
    build output once, before the first link. The change is one-directional —
    it can only remove write permission for others — and the build output's
    bytes are never touched.
  • set_mode and replace_with_junk publish a replacement instead of mutating
    the shared inode.
  • The server's own place_trusted_helper() stages the same way.

Why the copy-and-commit barrier is gone

The branch's first attempt kept a copy path, committed before publication
(write, sync_all, rename, sync the parent). CI refused it: run 39316541191
refused 3 of 32 copy stagings with ETXTBSY with the barrier in place,
while the link path passed 32 of 32 in the same run. A barrier that is 0.02% on
one host and 9% on another is a rate, not a barrier — and fsync, O_DSYNC, a
sleep and a retry all fail to touch the property that matters.

Evidence

  • 40 consecutive Landlock suite runs at --test-threads=16: 0 ETXTBSY.
  • The regression test asserts two things: 32 parallel stagings are never
    refused, and the staged helper is the build output's own inode and
    device. The second assertion needs no race to reproduce — forcing stage
    back through a copy refuses 5 of 32 stagings here and fails the inode
    assertion outright.
  • cargo fmt, cargo clippy -D warnings, cargo test --locked --workspace --all-targets, cargo check --workspace, the execution-ownership guard
    (and its negative-exit proof), the release-harness unit tests and
    git diff --check all pass locally and on CI (rust, windows-runner,
    release-drift).

Closure record: plans/closure/operations-distribution/004b-status.md. The M004a
record is preserved as written, with two additive addenda pointing here.

dbowm91 and others added 13 commits October 19, 2026 17:42
Implements the first milestone of the optional Gregg host-telemetry
roadmap: a node may be configured to read host-wide measurements from a
telemetry provider running on the same machine, cache them, and expose
them to a later authorized projection. Nothing about the node's
execution semantics changes, and with no configuration the node creates
no provider, starts no task, and claims no measurements.

The provider seam is one method. `HostTelemetryProvider::observe` returns
either an observation or the fact that the provider is still warming up,
so a warming daemon is a state rather than a failure. The one production
implementation reads a local Gregg daemon's `/v2/status`.

Provider vocabulary stops at the module boundary. `gregg_protocol::v2`'s
own `validate_payload_v2` is applied first, and the payload is then
translated into `eggwork_core::HostTelemetry` -- a protocol-neutral
vocabulary with no Gregg types in it. Only host-wide aggregates cross:
CPU cores and utilization, physical memory, load, swap, storage capacity
summed across the reported volumes, and aggregate disk and network
throughput. Drive names, device identities, interface identities, and the
provider's system identity are dropped in `normalize` and never leave the
node. `gregg-protocol` 1.0.15 was chosen over a hand-rolled DTO: it adds
three packages to the lockfile (`gregg-protocol`, `thiserror` 1.x,
`thiserror-impl` 1.x) and no new dependency families, and it is the only
copy of the provider's validation rules that cannot drift from the
provider.

A missing measurement is never zero. Each measurement group is a
`TelemetryMetric<T>` that is `Value(T)`, `Unsupported` (the platform
cannot produce it), or `Unknown` (it can, but this sample carried none),
and the provider's capability flags decide which. A reader can tell "this
host has no swap" apart from "this host has swap and it is unused".

The endpoint is validated once, at config-load time, against a closed
rule set: plain HTTP, an IP literal that is a loopback address, an
explicit TCP port, and exactly `/v2/status` -- no userinfo, query, or
fragment. A hostname, `localhost` included, is refused, so no name is
ever resolved and no DNS answer can be rebound between validation and
use. The alternative spellings of an IPv4 address (`127.0.0.1.`,
`2130706433`, `0x7f000001`, `127.1`) are canonicalized by the URL parser
to the literal address, so the endpoint the client is finally given names
the address literally. The provider client is an Eggfetch client built
without the `redirects` and `proxy` features: a `3xx` is reported as an
unexpected status rather than followed, and no ambient `HTTP_PROXY` is
consulted, so neither a redirect hop nor an inherited proxy can move the
request off the loopback interface. The decoded body is capped at
256 KiB, the connect deadline is 2 s, and the whole request is bounded
at 5 s.

One owner polls. `TelemetryMonitor::start` spawns exactly one task that
performs every provider request; readers consult the cache and never
trigger a request, so a burst of callers cannot become a burst of
provider requests. The first attempt happens as soon as the node is
running, because waiting a whole interval would make a freshly started
node look empty for no reason. Consecutive failures back off (15 s ->
30 s -> 60 s, capped at 5 minutes) so an absent provider is not polled in
a tight loop. `TelemetryMonitor::disabled()` creates no task at all, and
the monitor is stopped with the node.

Freshness is measured on the node's monotonic clock, so a wall-clock
adjustment cannot make a stale sample look fresh. The provider's own
wall-clock timestamp is kept as provenance and is checked against a 30 s
skew tolerance: a timestamp implausibly in the future is refused rather
than treated as indefinitely fresh. A sample older than the freshness
bound -- when it arrives, or once the node's copy has aged out -- is
reported as `Stale`, not as `Ready`.

Failures are typed and bounded. `TelemetryError` maps onto a closed set of
categories (connection, timeout, HTTP status, malformed, schema version,
invalid, too large, clock skew), and no response body, provider URL, or
host path is carried into a category, a log line, or a metric. The new
`host-telemetry` doctor check reports whether the provider is configured
but never contacts it and never echoes its address: a node whose provider
happens to be down is still a healthy node, and a diagnostic line is not
a place for a provider address.

`eggwork-core` gains the protocol-neutral measurement vocabulary and its
validation; `eggwork-server` gains the adapter, the cache, the config
key, and the lifecycle wiring. `NodeStatus` and `NodeCapabilities` keep
their existing meaning, and `NodeConfig`/`OperatorConfig` gain one
optional field each, so a node without the provider is unchanged.

Tests cover the endpoint rule set (including every SSRF shape the rule
set is meant to refuse), the normalization rules, the provider protocol
against a real loopback HTTP server (valid payload, warming envelope,
unexpected status, malformed body, oversized body, unfollowed redirect,
timeout, refused connection), the single-owner property under 64
concurrent readers, the stopped-monitor property, the disabled default,
and the doctor surface.

Refs: plans/implementation/optional-gregg-host-telemetry/001-loopback-gregg-adapter.md
Records the closure of the first optional Gregg host-telemetry milestone
and unlocks the second.

`plans/closure/optional-gregg-host-telemetry/001-status.md` is the
evidence record. It distinguishes what was executed from what was
inspected, and it is deliberately honest about three limits:

* the IPv6 loopback endpoint is validated but was not exercised against a
  live IPv6 listener in this environment, so only the validation path is
  proven there;
* no hosted macOS or Windows evidence exists, so no platform claim is made
  beyond a host-independent code path exercised on Linux;
* the `eggwork-sandbox-helper` `ETXTBSY` flake seen under the full
  parallel workspace run is recorded as pre-existing and unrelated. That
  crate is untouched by the M001 implementation, the test passes 3/3 in
  isolation on this tree, and the same failure was reproduced on the
  unmodified tree.

The dependency note is the measured one the plan asked for:
`gregg-protocol` 1.0.15 was used rather than a hand-rolled DTO. It adds
three packages (`gregg-protocol`, `thiserror` 1.x, `thiserror-impl` 1.x)
and no new dependency family, and it is the only copy of the provider's
validation rules that cannot drift from the provider. The alternative
would have re-implemented those rules in Eggwork.

Registry, roadmap, and plan statuses move together: M001 is closed, M002
is ready, and M002's recorded blocker is discharged by the frozen
normalized contract (`eggwork_core::HostTelemetry`,
`TelemetryProviderState`, `TelemetryErrorCategory`).

Refs: plans/implementation/optional-gregg-host-telemetry/001-loopback-gregg-adapter.md
…d (M002)

Exposes M001's bounded host-wide observation to a specifically authorized
remote controller, over the existing authenticated Eggwork channel. The
provider stays where it was: on the node's loopback interface, reachable
by nobody remotely.

The wire contract is frozen as `eggwork_core::NodeTelemetry` (schema
version 1) and documented in `architecture/protocol.md`. It is additive
and separate from `NodeStatus`: status answers "is this node accepting
work", telemetry answers "what did this host look like", and the two are
never merged. Nothing in the contract qualifies an execution.

The contract carries `schema_version`, `node_id`, `source`, the provider
`state`, the observation `age_ms`, the bounded `last_error` category, and
the `observation` itself. `state` describes the provider and never the
host, so a node with no provider is `disabled` -- which is not a host
with zero usage. The `state`/`observation` pair is the part a reader has
to understand: a sample is current only when the state is `ready`, and
`unavailable` may still carry the last sample the node took, with
`age_ms` saying how old it is.

Each measurement group is a `TelemetryMetric<T>` that is `Value(T)`,
`Unsupported` (the platform cannot produce it), or `Unknown` (it can,
but this sample carried none). A missing measurement is still never a
zero, and a reader can tell "this host has no swap" apart from "this
host has swap and it is unused".

The route is `GET /v1/node/telemetry`, and it is authorized by a narrow,
separate grant: the `telemetry` operation name. It is deliberately not
folded into `status`. Folding it in would silently widen every principal
that already holds a status grant to read host utilization, which is a
different kind of data about a different question; the plan allowed
either choice and the narrow one is the one that does not change the
meaning of an existing grant. A principal without the grant gets the
existing typed 403, and the refusal reveals nothing about whether the
node holds an observation.

The read is served from the node's own cache. It never contacts the
provider, so a burst of readers cannot become a burst of provider
requests, and a provider that is down does not turn a read into a
timeout. A node that predates the contract answers 404, which the client
maps to a distinct `TelemetryUnsupported` -- so "this node cannot serve
telemetry" stays distinguishable from "this principal may not read
telemetry" and from "the provider is down".

`NodeClient::telemetry` validates what it receives: 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. `telemetry_for` additionally refuses a response naming a
different node, so a fixed-target caller cannot be handed a measurement
taken somewhere else. An unknown source, an out-of-range or non-finite
number, and a body that is not the expected document are all refused
rather than parsed.

No capability feature was added. `NodeCapabilities` is about what a node
can *enforce*, and a telemetry read is not an execution capability; the
route's presence is already discoverable from the 404/403 distinction,
so advertising a protocol feature would have changed the capabilities
contract for every node for no gain.

Tests cover the authorized read and its payload, the narrow grant
(403), the unknown principal (401), the no-provider case (`disabled`),
an unreachable provider (`unavailable` with a bounded category), a node
without the route (`TelemetryUnsupported`), the guarantee that a remote
read never becomes a provider request, and the client's own refusals
(malformed, oversized, unknown schema version, unknown source, a state
that contradicts its observation, an out-of-range measurement, a number
that does not fit, and a node-id mismatch). An installed-binary smoke
test confirms the default daemon runs and answers the route with
`disabled` when no provider is configured, and refuses it with 403 for a
principal without the grant while the same principal's status read still
succeeds.

Refs: plans/implementation/optional-gregg-host-telemetry/002-authenticated-node-telemetry.md
Records the closure of the second optional Gregg host-telemetry
milestone. The subsystem roadmap's completion condition is now met: both
milestones are closed with code/test receipts, and the default-off
no-Gregg execution is proven.

`plans/closure/optional-gregg-host-telemetry/002-status.md` is the
evidence record. It carries the frozen wire contract in full, the
requirement-to-evidence matrix, the security and compatibility reviews,
and the installed-release receipt.

Two things in that record are worth surfacing here.

The first is the real-binary evidence. The opt-in installed-release
qualification was run against a locally built `eggworkd` with a node
configuration that has no `host_telemetry` block, so it qualifies the
default path: the doctor reports "host telemetry is disabled", the
execution reaches `Succeeded`, and required isolation is applied and
enforced. The same installed binary was then probed over real mTLS:
`GET /v1/node/telemetry` answers 200 with `state: "disabled"` for a
principal holding the `telemetry` grant, 403 for a principal that does
not, and nothing at all without a client certificate -- while that same
ungranted principal's `status` read still returns 200. That is the whole
authorization story on a real binary.

The second is a correction. This record's first draft said the
`eggwork-sandbox-helper` `ETXTBSY` flake "did not occur" in this
milestone's workspace run. It did. The record now says so, points at the
measured host-level-kernel-window disposition already accepted in
`plans/closure/operations-distribution/004a-status.md`, and notes that
the same failure reproduces on the unmodified tree. A closure record that
hides a flake it happened to hit is not evidence.

Registry, roadmap, and plan statuses move together: M002 is closed, the
optional Gregg telemetry workstream is closed, and the CodeGG worker
telemetry consumer is unblocked against the frozen
`eggwork_core::NodeTelemetry` contract.

Refs: plans/implementation/optional-gregg-host-telemetry/002-authenticated-node-telemetry.md
…ever writing the executed file

CI run 39306109740 failed the Landlock suite on the optional-Gregg
telemetry branch: `malformed_private_spec_and_unavailable_status_channel_do_not_launch_target`
panicked at landlock_runner.rs:471 with `ExecutableFileBusy` ("Text file
busy"). This is the residual the M004a closure characterised and
dispositioned rather than fixed, and it recurred because that
characterisation was incomplete.

What the M004a record got right and what it missed. It was right that the
refusal reproduces outside Eggwork's spawn path, that the staged path is
provably unique, and that no writer is observable at failure time. It was
wrong that the refusal is a "microsecond-wide window": the condition is a
property of the inode and it persists, because a hundred immediate
re-spawns of the same path all failed. And its `write_open: no-writer`
probe could not have detected a writer in the first place, since opening a
file for writing succeeds whether or not another writer exists. Most
consequentially, the fixture module's own claim that atomic publication
made a fixture immune to ETXTBSY was false, and that false claim is what
left CI red.

Linux refuses to execute a file whose inode still carries an open write
reference, and that reference is released when the write-back completes,
not when the writer's descriptor is closed. Measured here, 16 threads
staging and executing a private copy in a loop: 35.78% of executions
refused for the M004a copy-and-rename sequence, 37.08% for an explicit
read and write, 44.06% when the rename is dropped, and 0.00% for a file
that is never written at all.

So the fix removes the write rather than racing it.

`stage` now links the Cargo-built helper into the fixture's private 0700
directory instead of copying it. A link shares an inode that was last
written when the linker produced the binary, so it carries no write
reference and the kernel has no reason to refuse it. That also drops a
per-fixture copy of the whole binary from every test, which is why the
suite is no slower than it was before the fix.

The copy path that remains is taken when a link is impossible, because the
source and the fixture directory are on different filesystems or the source
is not executable. That path is committed before publication, in the
repository's own write-then-`sync_all`-then-rename-then-sync-parent order,
and the commit follows the mode change, because the mode change is itself
a write to the inode and a barrier taken before it does not cover it.

`set_mode` and `replace_with_junk` publish a replacement instead of
mutating the inode. Under a shared inode a chmod would have reached the
Cargo-built helper and every other fixture. No fixture mutates an inode it
shares any more, which is a stronger form of the M004a isolation invariant
than the one M004a recorded.

`eggwork-server`'s `place_trusted_helper` stages and then executes a helper
the same way, so it takes the same link-or-committed-copy treatment.

Two regression tests, both verified to fail when the corresponding fix is
removed: forcing `stage` back through an unbarriered copy refuses 6 of 32
stagings, and removing the copy path's barrier refuses 2 of 32. The Landlock
suite then ran 40 consecutive times at 16 threads with zero refusals, where
5 of 25 runs failed the same way before.

No retry, no sleep, no `O_TMPFILE`+`linkat`, no trust-rule change and no
production change. The product consumes a helper that was installed long
before, so its inode never carries a write reference; the exposure was
confined to test fixtures.

Refs: plans/implementation/operations-distribution/004b-staged-helper-publication-durability-corrective.md
…ity corrective

Records the closure of the corrective that eliminates the `ETXTBSY`
refusal the M004a closure characterised and left open, and registers it
as the current authority for the Operations/distribution workstream.

`plans/closure/operations-distribution/004b-status.md` is the evidence
record. It carries the requirement-to-evidence matrix, the variant
measurements that established the mechanism, the proof that both
regression tests are non-vacuous, and an honest statement of what the
mechanism explanation does and does not rest on.

The record's §2 is the part worth surfacing. It states which of the
M004a claims no longer hold: that the refusal is a microsecond-wide
timing window, when it is in fact a property of the inode that survived a
hundred immediate retries; that the `write_open: no-writer` probe showed
no writer, when opening a file for writing succeeds whether or not another
writer exists and so the probe could not have shown anything; and that
atomic publication made a fixture immune, which was the fixture module's
own claim and the reason CI stayed red.

The record's §5 is the second part worth surfacing, because it supersedes
a decision rather than merely extending one. M004a §10 rejected hard
links, and its stated reason was that `chmod` on one fixture's copy would
change the mode every other fixture sees. That reason no longer applies,
because a mode change now publishes a replacement instead of mutating the
inode. M004a §11 also pointed at `O_TMPFILE`+`linkat` as the next step,
and the evidence says that addresses the wrong property: the failure was
never that a partially written helper could be observed, it was that a
fully written helper still carried a write reference.

The M004a record is preserved as written. Its addendum marks the residual
as eliminated, marks its `O_TMPFILE` pointer and its hard-link rejection
as superseded, and points here. Registry, roadmap, and plan statuses move
together: M004b is closed, and the Operations/distribution workstream row
now names this record as the current authority.

Refs: plans/implementation/operations-distribution/004b-staged-helper-publication-durability-corrective.md
…written

The staged helper is now published with link(2) instead of being copied, and
the copy path is gone rather than merely deferred. The refusal is not a
write-back window: fs/exec.c's do_open_execat() ends with
exe_file_deny_write_access(), which is deny_write_access() --
atomic_dec_unless_positive(&inode->i_writecount) -- so an execve() of an inode
that is open for writing fails with ETXTBSY. The write access is taken by
every write-open of a regular file in do_dentry_open() and released with that
file's teardown, which is deferred, so the refusal outlives the descriptor
that took it -- which is why the failing inode is not in any /proc/<pid>/fd.
A copy is a file that was written by definition; a link never opens the
executed inode for writing. That is the whole difference between a refusal
that cannot happen and one that is merely unlikely, and it is the only
construction that measured zero refusals on both the development host and the
CI runner.

The copy-and-commit barrier this branch first carried is what CI rejected:
run 39316541191 refused 3 of 32 copy stagings with ETXTBSY while the link path
passed 32 of 32 in the same run. A barrier that is 0.02% on one host and 9% on
another is a rate, not a barrier, and fsync, O_DSYNC, a sleep and a retry all
fail to touch the property that matters. Staging therefore fails loudly when
a link is impossible, instead of falling back to the construction that fails.

A link carries the source's mode, and verify_trusted_helper rejects a helper
that anyone but its owner may write. Cargo derives the executable's mode from
the umask, so a permissive umask leaves the build output group-writable and
no fixture could stage it by linking. The fixture now clears the group and
world write bits of the build output once, before the first link, under a lock
so that no fixture can stage a helper whose mode has not settled. The change
is one-directional -- it can only remove write permission for others -- and
the build output's bytes are never touched, so the M004a isolation invariant
still holds.

set_mode and replace_with_junk publish a replacement instead of mutating the
shared inode, and the server's own place_trusted_helper() stages the same way.

The regression test now asserts two things: that 32 parallel stagings are
never refused, and that the staged helper *is* the build output's own inode
and device. The second assertion needs no race to reproduce, so a regression
to copying fails on the first run rather than on the run where the host
happens to be busy. Forcing stage back through a copy refuses 5 of 32
stagings here and fails the inode assertion outright.
…tive

Rewrites the M004b closure record around the executed design and the CI
evidence that produced it. The record now reads the mechanism from the kernel
rather than inferring it: the refusal is the inode's write access, not a
write-back window, and the previous record's own residual-risk section was
honest that it had never been confirmed against the kernel's accounting. It
also carries the second CI failure -- the copy path's barrier being refused 3
times in 32 stagings on the runner -- and the non-vacuity evidence for the two
regression tests, including the structural inode assertion, which fails on the
first run rather than on the run where the host happens to be busy.

The M004a record is preserved as written. A second additive addendum (S14)
records that the elimination is by link-only staging rather than by the
copy-and-commit barrier the first attempt proposed, and states the one cost
the link introduces: a link carries the source's mode, so the build output's
mode is normalised to a trusted one once, before the first fixture exists, in
a change that can only remove write permission for others.

The registry and the Operations/distribution roadmap are updated to name the
milestone for what it did -- a write-access staging corrective -- and the
current-baseline bullet, the workstream row, the dependency diagram and the
M004a supersession note follow.
@dbowm91
dbowm91 merged commit 81f34e0 into main Oct 19, 2026
6 checks passed
@dbowm91
dbowm91 deleted the planning/optional-gregg-telemetry-m001-m002 branch November 13, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant