diff --git a/crates/fno-agent/src/backlog/lint_registry.rs b/crates/fno-agent/src/backlog/lint_registry.rs index 4e4e0884e8..4ceb70b88d 100644 --- a/crates/fno-agent/src/backlog/lint_registry.rs +++ b/crates/fno-agent/src/backlog/lint_registry.rs @@ -422,7 +422,21 @@ fn live_field_coverage( projected_dead: Vec::new(), }; } - let persisted_names: Vec = declared_row_names(); + let persisted_names: Vec = match declared_row_names() { + Ok(names) => names, + Err(reason) => { + return LiveReport { + status: "unmeasured".into(), + detail: format!("registry unreadable: {reason}"), + anchors: Value::Object(anchors), + contract_errors: contract.1.clone(), + persisted_total: total, + persisted_dead: Vec::new(), + projected_total: total, + projected_dead: Vec::new(), + }; + } + }; let projected_keys: Vec = projected_row_keys(schema); let persisted_dead: Vec = persisted_names .into_iter() @@ -453,20 +467,35 @@ fn live_field_coverage( /// The persisted field names, from the RegistryEntry serde shape: read one /// live row's keys and fall back to the schema's stored block. The Python /// leg read its dataclass `fields()`; the row keys are the same surface. -fn declared_row_names() -> Vec { - let mut names: Vec = Vec::new(); +/// The read goes through the registry door: once the table imports the +/// registry, the path is a fence directory and a plain file read fails on it. +fn declared_row_names() -> std::io::Result> { + let invalid = |detail: String| std::io::Error::new(std::io::ErrorKind::InvalidData, detail); let home = AgentsHome::from_env(); - let text = std::fs::read_to_string(home.registry_json()).unwrap_or_default(); - if let Ok(Value::Array(rows)) = serde_json::from_str::(&text) { - if let Some(first) = rows.first() { - if let Value::Object(map) = first { - for key in map.keys() { - names.push(key.clone()); - } - } + let path = home.registry_json(); + let text = crate::runtime::registry_read::registry_text(&path)?; + let value: Value = + serde_json::from_str(&text).map_err(|e| invalid(format!("{}: {e}", path.display())))?; + // The door returns the document object with its rows under `agents`; a + // legacy file may still be a bare row array. + let rows = match value { + Value::Array(rows) => rows, + Value::Object(mut document) => match document.remove("agents") { + Some(Value::Array(rows)) => rows, + _ => return Err(invalid(format!("{}: no agents row array", path.display()))), + }, + _ => { + return Err(invalid(format!( + "{}: registry is not a row array", + path.display() + ))) } + }; + let mut names: Vec = Vec::new(); + if let Some(Value::Object(map)) = rows.first() { + names.extend(map.keys().cloned()); } - names + Ok(names) } /// The projected keys: the schema's required + derived + rust_only + diff --git a/docs/state-root-inventory.md b/docs/state-root-inventory.md index f1fcf5ebcb..4daeb8d918 100644 --- a/docs/state-root-inventory.md +++ b/docs/state-root-inventory.md @@ -50,6 +50,7 @@ One file per install. These belong at the root. | `claims/dispatch%3A*.lock`, `.recovery.d/` | `claims/core.py` for provider handoff | transaction lease for one attempt; released at terminal return, recovery mutex removed by the claim primitive; contains holder/process metadata only | | `state/claim-aux/.lock.queue.d/`, `state/claim-aux/.lock.priority.d/`, `state/claim-aux/.lock.full.d/` | `crates/fno-agent/src/runtime/claim_queue.rs` owns the ticket format; waiters live in `crates/fno-agent/src/gate/test_run.rs` and `scripts/ci/preflight.sh` | one ticket dir per live waiter on one admission door, named `NNNNNN/holder`; removed by its own waiter on every exit path and reaped by the next scan when its recorded pid is gone. The three dirs are the lanes: `priority` (a live `test:priority` claim names the checkout), `queue` (arrival order), `full` (whole-suite runs, suite door only) | | `state/claim-aux/build-waiters/` | `crates/fno-agent/src/gate/test_run.rs` `CargoWait` | one marker per waiting checkout, removed when the wait ends and by the reader when its pid is gone; read by the stop hook to allow a stop during a held build | +| `agents/registry.json` (a directory: the fence) | `crates/fno/src/registry_read.rs` (`table_owns`, `registry_text`) and `crates/fno-agent/src/runtime/registry_store.rs` (the import writes `registry_meta` `imported=1`, then retires the file). The rows live in graph.db. `agents/registry.json/migration.json` records the import. | permanent: the fence holds the path so a stale pre-import file cannot revive removed rows. Readers go through `registry_text`; a plain file read on this path fails. Never delete the directory to clear a stray. | | `agents/squads.json` | no writer in this build: a historical store location beside the live agent files (`registry.json` there IS authoritative, which is what makes the dead file read as real). `fno mux doctor` names it and its live replacement. | dead: nothing reads it, so it can only mislead; delete on sight (`fno mux doctor` prints the `rm`) | | `agents/reap-receipts/-.json` | `crates/fno-agent/src/runtime/receipt.rs` (`write_reap_receipt`; the four writer doors are `gc_sweep.rs`, `roster_reap.rs`, the `update_registry` choke point in `receipt.rs`, and the Python choke point in `cli/src/fno/agents/registry.py`; `FNO_AGENT_HOME` overrides) | retained `config.agents.reap_receipts.retain_days` days (default 7); past the window the sweep strips the EXPENDABLE detail (ledger copy, per-effect rows, log path) and keeps the identity core (who, native locator, resume argv) forever, because deleting it would strand the only recovery record for a resumable session. Receipts carry a schema version, the writer build, and per-effect outcomes; `fno agent registry reap --verify --since 24h --json` audits them against the current build. A receipt whose `reaped_at` cannot be read is kept and named in the sweep summary, never deleted on a failed read | | `agents/retired-leads/.json` | `crates/fno-agent/src/runtime/retired_lead.rs` (written by a confirmed stop of a role holder, `fno agent hq done` and a succession; read by the lead wake, the team-revival sweep, scheduler wakes and `crates/fno/src/sessions/restore_gate.rs`) | until `fno agent resume` or a new role grant for that session | diff --git a/scripts/diagnostics/lead-checkin-wall-probe.sh b/scripts/diagnostics/lead-checkin-wall-probe.sh index 8c411414a1..8857a46cba 100755 --- a/scripts/diagnostics/lead-checkin-wall-probe.sh +++ b/scripts/diagnostics/lead-checkin-wall-probe.sh @@ -68,9 +68,15 @@ if [ ! -d "$SANDBOX/agents" ]; then exit 2 fi cp -c "$GRAPH" "$SANDBOX/graph.db" || { echo "probe: graph clone failed" >&2; exit 2; } -for need in registry.json team_names.json; do - [ -e "$SANDBOX/agents/$need" ] || { echo "probe: sandbox input missing: agents/$need" >&2; exit 2; } -done +# registry.json is a fence directory once the graph table owns it. Accept it +# only beside the cloned graph.db that holds the rows; a bare directory is +# an empty registry, so the probe refuses it by name. +if [ -d "$SANDBOX/agents/registry.json" ]; then + [ -f "$SANDBOX/graph.db" ] || { echo "probe: registry is a fence directory but graph.db did not clone" >&2; exit 2; } +elif [ ! -f "$SANDBOX/agents/registry.json" ]; then + echo "probe: sandbox input missing: agents/registry.json" >&2; exit 2 +fi +[ -e "$SANDBOX/agents/team_names.json" ] || { echo "probe: sandbox input missing: agents/team_names.json" >&2; exit 2; } T0=$(date +%s) FNO_AGENT_HOME="$SANDBOX/agents" "$BIN" lead-checkin --user-command \