Skip to content

fix(loop): dual-mode supervisor notes + derive run index on read (drop the append) - #474

Merged
huichen merged 1 commit into
mainfrom
fix/supervisor-notes-and-derived-run-index
Sep 3, 2026
Merged

huichen merged 1 commit into
mainfrom
fix/supervisor-notes-and-derived-run-index

Conversation

@huichen

@huichen huichen commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

fix(loop): dual-mode supervisor notes + derive run index on read (drop the append)

Two changes driven by the multi-worker 16x16 solve:

  1. Supervisor notes are now durable (dual-mode notify). Previously the
    completion/failure/infra-stop reports were prompt-only pushes that wake an
    IDLE supervisor session; an active orchestrator (one that is polling
    status while watching workers) never drains them, so they queue up and
    arrive only after it goes idle. notify_supervisor now writes a
    SupervisorNote ledger event FIRST (durable, replayable, surfaced in the
    supervisor events projection and describe_event) and THEN pushes to the
    supervisor session. Lost/delayed pushes no longer lose the notification —
    the note is readable by polling even when the push is dropped or the
    supervisor is busy. No supervisor registered still ledgers the note (a
    later supervisor register reads it back); only the push is skipped.

  2. The run index is no longer persisted (append removed). The old
    write_run appended runs/index.jsonl with a lockless
    OpenOptions::append per process, so N concurrent workers writing a run at
    once could interleave rows and drift the read model (the observed
    "run_index drifted — rebuilt" self-heal noise). The index is now a pure
    projection: writers only write the per-run JSON/MD files (each a unique,
    uncontended file), and readers derive the index rows via the new
    run_index::load_run_index (scans the run dir incl. archive). run-history,
    compaction, and retention all read through load_run_index; runs index --rebuild / store verify --repair remain as on-demand human inspection.
    The run-path run_index_self_heal seam is now a no-op.

…p the append)

Two changes driven by the multi-worker 16x16 solve:

1. Supervisor notes are now durable (dual-mode notify). Previously the
   completion/failure/infra-stop reports were prompt-only pushes that wake an
   IDLE supervisor session; an active orchestrator (one that is polling
   `status` while watching workers) never drains them, so they queue up and
   arrive only after it goes idle. `notify_supervisor` now writes a
   `SupervisorNote` ledger event FIRST (durable, replayable, surfaced in the
   `supervisor events` projection and `describe_event`) and THEN pushes to the
   supervisor session. Lost/delayed pushes no longer lose the notification —
   the note is readable by polling even when the push is dropped or the
   supervisor is busy. No supervisor registered still ledgers the note (a
   later `supervisor register` reads it back); only the push is skipped.

2. The run index is no longer persisted (append removed). The old
   `write_run` appended `runs/index.jsonl` with a lockless
   `OpenOptions::append` per process, so N concurrent workers writing a run at
   once could interleave rows and drift the read model (the observed
   "run_index drifted — rebuilt" self-heal noise). The index is now a pure
   projection: writers only write the per-run JSON/MD files (each a unique,
   uncontended file), and readers derive the index rows via the new
   `run_index::load_run_index` (scans the run dir incl. archive). run-history,
   compaction, and retention all read through `load_run_index`; `runs index
   --rebuild` / `store verify --repair` remain as on-demand human inspection.
   The run-path `run_index_self_heal` seam is now a no-op.
@huichen
huichen enabled auto-merge (squash) September 3, 2026 03:43
@huichen
huichen merged commit 2239326 into main Sep 3, 2026
12 checks passed
@huichen
huichen deleted the fix/supervisor-notes-and-derived-run-index branch September 3, 2026 03:47
huichen added a commit that referenced this pull request Sep 3, 2026
Two follow-ups to the detached-run and turn-provenance fixes:

1. Detached-run liveness check. `spawn` succeeding only means the child was
   created, not that it re-dispatched correctly. A mis-dispatched re-exec
   (e.g. the child drops a group layer and lands on an unrelated command)
   exits instantly with a usage error while the parent printed a fake pid and
   returned success. Give the child a short grace window, then bail with a
   pointer to the detached log when it has already exited.

2. Doc sync. The goal-level monotonic turn counter landed in #474 but the
   `DecisionSummary::turn` field and `record_turn_decision` docs still
   described the old run-local counter. Update both to the goal-level
   semantics.
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