Skip to content

feat(supervisor-run): read Runtime's settle record and add a report command - #740

Merged
drewstone merged 1 commit into
mainfrom
feat/runtime-settle-record
Sep 7, 2026
Merged

feat(supervisor-run): read Runtime's settle record and add a report command#740
drewstone merged 1 commit into
mainfrom
feat/runtime-settle-record

Conversation

@drewstone

Copy link
Copy Markdown
Contributor

Change

The supervisor-run reader now takes a run's status from Runtime's own terminal record, and the CLI can print one run's report.

  • readTerminalRecord (new src/supervisor-run/terminal-record.ts) is the one derivation the analyzer and the rollout minter share.
    result.json is the SupervisedResult that supervise() returned; its kind is the status (supStatusSource: 'runtime-result') and its reason is supReason.
    failure.json ({ runId, pursuitId, at, error: { name, message } }) without a result reports status failed with the recorded error (runtime-failure), not unavailable.
    A failure.json beside a settled result is an earlier attempt's throw and is reported with earlierAttempt: true; the settled result stays the status.
    The control-plane-era state.json status and result.json sup_status remain readable as the named legacy sources legacy-state and legacy-result.
  • The stale state.status ?? result.sup_status expression in analyze.ts is replaced by the shared derivation; rollout-nodes.ts mints sup_status, is_completed, and error from the same record.
  • The Runtime reader no longer copies the result status onto its begin-stamp state document and no longer reads trajectory.json, which Runtime never wrote.
    It passes result.json and failure.json through as bytes (SupervisorRunSources.failure), refuses a result whose tree.root is not the journal root, and refuses a failure record with no error object.
  • isRuntimeSupervisorRunDir recognizes any file only Runtime's durable layer writes (spawn-journal.jsonl, observer.jsonl, failure.json), so a run that threw before its first spawn is read as a Runtime run.
    The absent-journal report carries the run id the record names.
  • agent-eval supervisor-run report <runDir> [--format headline|markdown|json] prints renderSupervisorRunHeadline, the markdown report, or the JSON report.
    Exit 1 when the directory cannot be read, 2 on a usage error.
  • Version 0.175.0 across package.json and the Python client; pnpm analyst:pin re-pinned the dependency-lock digest that covers package.json.

Refs #711: the observer projection is not consumed here; this reads the terminal records the projection does not carry.
Runtime side: tangle-network/agent-runtime branch feat/durable-settle-record (issue tangle-network/agent-runtime#1109), whose settle-record.ts writes the two records this reader consumes.

Evidence

Fixtures are copies of the real discovery-lab recursive smoke r1 directory (2026-09-06).
tests/fixtures/supervisor-run/runtime-run-r1-no-winner/ holds byte-identical observer.jsonl (14 records) and spawn-journal.jsonl (28 lines), a synthetic result.json in Runtime's canonical byte form for that journal (no-winner, all-children-down, 4 nodes), and a synthetic failure.json for the first attempt's throw (the observer's record 2, 05:58:29.604Z).
runtime-run-r1-failed/ is that directory as it stood after the first attempt: the first two observer records and the failure record, no journal.
A test asserts every observer copy is digest-chained with sequences 1..n.

pnpm typecheck            # clean
pnpm lint                 # Checked 751 files, 0 errors
pnpm vitest run src/supervisor-run
                          # 13 files, 173/173 passed (34 new: terminal-record 9, r1 fixtures 11, report command 8, reader 2, fixture updates)
pnpm test                 # see the final line in the PR checks; locally 395 files passed, 2 skipped
pnpm typecheck:examples && pnpm typecheck:scripts && pnpm run check:model-ids   # pass
pnpm build && pnpm verify:package
                          # every gate valid (analyst digests, skill, model ids, canonical json, collation, publint, attw, exports, finding contract, evidence index)
node dist/cli.js supervisor-run report tests/fixtures/supervisor-run/runtime-run-r1-no-winner
  RUN-REPORT meta-operator-recursion-smoke-r1 [?]
    status=no-winner source=runtime-result reason=all-children-down failure=TypeError: supervise budget.deadlineMs must be a non-negative finite number [runtime-failure at 2026-09-06T05:58:29.604Z, earlier attempt]
node dist/cli.js supervisor-run report tests/fixtures/supervisor-run/runtime-run-r1-failed
  RUN-REPORT meta-operator-recursion-smoke-r1 [?]
    status=failed source=runtime-failure reason=null failure=TypeError: supervise budget.deadlineMs must be a non-negative finite number [runtime-failure at 2026-09-06T05:58:29.604Z]
node dist/cli.js supervisor-run report /nonexistent   # exit 1

Limits

  • result.json in the fixture is synthetic: r1's real result was never persisted (the defect the Runtime branch fixes), so the SupervisedResult was reconstructed from the journal's settled events and totals.
  • A directory with a failure record and no journal mints no rollout row: a row is keyed on the journal's root spawn id, and the minter reports journal-unavailable instead of inventing one.
  • docs/public-api.md (the consumer census) is generated on demand with a repository sweep and was not regenerated; the new exports (readTerminalRecord, runSupervisorRunCommand, and the constants) will show as none until the next sweep.
  • Issue supervisor-run: read agent-runtime's observer projection instead of re-deriving spend and placement #711's structural ask (consume Runtime's observer projection) stays open; nothing here re-derives the projection.

🤖 Generated with Claude Code

…ommand

The supervisor-run reader takes a run's status from Runtime's own terminal
record. result.json is the SupervisedResult that supervise() returned and its
kind is the status; failure.json without a result reports status failed with
the recorded error instead of unavailable. The loops state.json status and
result.json sup_status stay readable as named legacy sources. readTerminalRecord
is the one derivation the analyzer and the rollout minter share, which replaces
the stale state.status ?? result.sup_status expression in analyze.ts.

A directory holding observer.jsonl or failure.json is a Runtime run directory
before its spawn journal exists, so a run that threw before its first spawn is
read as a Runtime run and the report names the run id the record carries.

agent-eval supervisor-run report <runDir> [--format headline|markdown|json]
prints the headline, markdown, or JSON report; exit 1 on a read error.

Fixtures copy the real discovery-lab recursive smoke r1 observer and spawn
journals and add a synthetic result.json in Runtime's canonical byte form plus
a synthetic failure.json for the first attempt's throw.

Version 0.175.0 across the npm package and the Python client.

Refs #711
@drewstone
drewstone merged commit 502596f into main Sep 7, 2026
2 checks passed
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