Repository navigation
Record a coding run's file operations and its plan (LAB-134) - #1332
Conversation
Dispatch a Claude Code run into a workstream — a child session dedicated to that one job — and mirror its top-level messages as items in that workstream's stream, so the originating request returns immediately and nobody has to open the harness transcript to find out what a run did. Production change is one option in one package. `claudeCodeAgent` and `createClaudeCodeAgentCapability` take `sessionState: false`, which suppresses three things together: the `sessionStateSchema` declaration, the session reads and writes that go with it, and the SDK `resume`. The third is the one that hides — suppressing the schema alone leaves provider resolution intact, so a custom `sessionProvider` returning a saved id for an empty key would silently resume a prior conversation while every schema-shaped assertion stayed green. The test for it asserts on the options handed to the SDK. Both halves are needed. A capability contributes its schema through a channel the task board's block walk cannot see, so a capability still declaring it would put the key back through the one door the refusal cannot check — and it would appear to work. Default is `true`; an unset caller is unaffected in every respect (BP-030), including that a mid-stream throw still throws. Settlement — how a finished, failed or lost run is recorded — is deliberately NOT here. It was revised seven times across seven different surfaces and none of them touched the mirror, so it moved to FIX-1182. This takes the board's default: no retry allowance, so `shouldRetryOnFail` is false and no agent ever re-runs over its own commits (the one genuine harm in this area). The cost is stated rather than hidden, in the spec and in the goal check: a LOST run is written off rather than staying recoverable. Verification: - goal check `goals/harness-workstream/mirrors-a-coding-run-as-workstream-items/` — a real Claude Code run dispatched into a real workstream through the real board, read back over the real HTTP routes on store-sqlite. Two consecutive PASSes. It names its adapter deliberately: the in-memory store ignores `include_items` by documented contract, so a readback assertion there proves nothing about the route. The check asserts 0 items WITHOUT the flag, so the flag is load-bearing rather than decorative. - 6 CI behaviours: 4 in `packages/claude-code/test/sdk/agent.spec.ts`, 1 in its capability spec, and board acceptance in `packages/integration-tests`. Acceptance lives there rather than in the vendor package (which would take an orchestration dev dep for one test) or only in the goal (which needs a real model and the optional SDK peer, so it does not run in CI). - `pnpm typecheck` across all 61 projects. Two manifest fixes the build needed, neither optional: - `goals/` had no dependency on `@flow-state-dev/claude-code`; there is no way to dispatch a coding run from a goal without it. - `packages/claude-code`'s optional peer is `"*"`, and the lockfile had pinned it to 0.1.77 while `goals` resolved 0.3.234 — two copies in one workspace, with which one you got depending on the importing file's location. The old copy's bundled CLI exits 1, surfacing as a bare "process exited with code 1" that reads like a broken dispatch. A root `pnpm.overrides` entry gives the workspace one copy. The published peer range is untouched.
The goal check read `seq` off each stored item. That field does not exist — persisted items carry `itemIndex` (`packages/contracts/src/items/types.ts`, and `store-sqlite`'s request store orders on it; `sequence_number` is an SSE event field, not a stored one). So the numeric filter produced an empty array, `every` was vacuously true, the `length > 0` guard meant no failure could ever be pushed, and the evidence line still claimed "in non-decreasing sequence". The check could not see what it claimed to measure, and it failed GREEN. On the epic's own proof, that is the worst possible placement for it. Both halves fixed, because the field name alone was only half the defect: - Read `itemIndex`, verified by logging one item's keys off a live readback rather than trusting the field name — which is the mistake this finding is about. - **A missing or non-numeric field is now a FAILURE, not a skip.** Guarding the assertion on "did we read any numbers" is what made reading none satisfy it. - Checked per request, since the index is within one request's stream. - The evidence string names the field and the span it actually read. Verified by breaking it on purpose: pointed at `seq` again, the goal now FAILS with "could not read the item ordering on request 1: 20 of 20 items carry no numeric `seq`" — the same conditions that used to print PASS. The hole this left, which is the reason it matters: the two orderings were meant to be independent readings and only the coarse tool-before-message one was ever live, so a regression scrambling intermediate items would have sailed through. Also from the review round: - `getJson` swallowed transport errors into `undefined`, so a dead host read as "no workstream yet" — the same shape of defect, an error wearing the costume of a normal negative result. It now throws on unreachable, non-2xx, and unparseable. - Trimmed the `sessionState` rationale to ONE canonical home (the option's own JSDoc); everywhere else is a one-liner plus a pointer. Two notes survive verbatim because they are the non-obvious parts: that the session provider must not be resolved AT ALL, and that the board's walk cannot see a capability-contributed schema. - `sessionState: options.sessionState` instead of a conditional spread, and dropped the exported `CreateClaudeCodeAgentCapabilityOptions` (an empty extension of `ClaudeCodeAgentOptions`). Noted in the changeset. The two earlier verdict rows in goal.md are DELETED, not relabelled. They cited the PR's base commit rather than the implementing one, and — the reason a relabel would not have been enough — they both attested "non-decreasing sequence", the one claim the blind check never made. Fresh rows follow, from runs against the corrected check.
Three rows, all at 0a2dfcf — the commit that carries the corrected check, not the PR's base. Two real PASSes plus the deliberate break that proves the assertion can fire: pointed at `seq` it FAILS naming the missing evidence, which is the condition under which the previous version printed PASS.
…not (LAB-133)
Both verified against the call sites before editing, not taken on the
reviewer's citation.
**"no session id is stored" was wrong.** `sessionState: false` governs session
state and automatic resume — it does not touch the run's result. The handle the
block returns still carries the SDK `sessionId` it observed (`agent.ts`, the
handle is built and returned outside the `if (sessionState)` guard), and as a
task-board worker that handle IS the worker's output, which `recordSuccess`
writes onto the task via `collection.complete(taskId, output, …)`. So the id is
persisted, just somewhere else. A reader assessing data retention or planning a
manual resume got the opposite answer.
**The refusal guarantee was unqualified and is not universal.** The board's walk
reads `config.sessionStateSchema` on the worker and its composed children only.
A capability contributes its schema through a channel that leaves no mark on the
consuming block, so a worker carrying session state that way is accepted —
`detached.ts` states this in as many words ("Composition is walkable;
capabilities are not"). The page now scopes the claim to authored and composed
schemas and names the exception, with the one-liner for passing the option to
the capability.
The second one is the same fact that makes the capability half of the opt-out
load-bearing rather than redundant, so the docs were promising a check that
does not run on the one path where the option is easiest to forget.
Correction only — no other prose touched.
It carried the same unqualified refusal claim ("declares session state at
all") and omitted that the returned handle still carries the session id. Both
already verified against the call sites for the docs-site fix; corrected here
so the two surfaces do not disagree.
… (LAB-134) `recordWork: true` records what a run DID, alongside the items that already record what it said. Off by default; on, the agent declares three session-scoped resource collections and writes into them as the run goes: - `observed-file-ops` — one entry per path its file-writing/editing tools touched, with a three-valued `outcome` (`pending` / `applied` / `failed`). Paths, never contents. - `observed-plan` — one entry per item on the run's own to-do list, kept off the task board so seeing an agent's plan stays separate from acting on it. - `observed-gaps` — one entry per mutation the recorder understood and could not record. Without it a skip is indistinguishable afterwards from a mutation that never happened. The vendor's tool names live in exactly one place: the translation layer gains a table and the call/result correlation, and emits framework-vocabulary events. The recorder consumes only those, so it contains no tool names and is unit-testable with scripted messages. Measured, on `claude` 2.1.234 — the binary the pinned SDK spawns — rather than read off type declarations. The to-do surface is `TaskCreate`/`TaskUpdate`; the `TodoWrite` the vendor's own `.d.ts` still declares is not offered at all. A created item's id arrives on a typed `tool_use_result.task.id`, with prose recovery kept as the fallback. To-do ids are not positional across runs. Scope limits, stated rather than implied. The file record covers tool-driven operations only: a run that edits through the shell makes no file-tool call, so nothing is recorded and that file does not appear. And watching the work never breaks the work — every failure degrades to a gap row and a note, never a throw. Also extends the harness-workstream goal check to read both records back over the real route, scoped per run with `topicPrefix` and paged with `nextCursor`, across two real runs in one reused workstream. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_05ac51bc-0f56-47ad-8f80-11f3475e7a82) |
…-134) The verdict rows named the base commit rather than the state they ran on — the exact error the two deleted rows above them were deleted for. The three LAB-134 rows ran on pre-commit working trees that differ from each other in ways that matter to what each measured (the plan tools' presence in `allowedTools`, and the turn budget), so each says which state it ran on instead of borrowing a hash. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
There was a problem hiding this comment.
Simplify review — LAB-134 work recording
Verdict: The core architecture is the right one. I would not replace it with item-stream projection, file watchers, or a single catch-all journal. The translate → framework-vocabulary events → vendor-free recorder → lazy session collections split matches how this package already works and keeps the vendor mapping in one place.
What makes this PR feel large (+2.7k LOC) is mostly tests and goal harness, not a wrong decomposition. The production surface is ~800 lines across four focused modules (work-collections, work-recorder, translate extensions, agent wiring). That is proportional to the constraints: per-run namespacing on reused workstreams, lazy collections, pending/applied/failed outcomes, gap rows that must survive the run, and plan tools that are TaskCreate/TaskUpdate rather than TodoWrite.
What I think is well chosen
- Observation in
translate.ts, persistence inwork-recorder.ts— Recorder has no tool names; tests can feed scriptedTranslatedEvents. This is the main simplification win vs folding recording intoemit.tsor the agent loop. tool_use_resultas primary, prose as fallback — Addresses the spec POC gap. Structuredtask.id/filePathis the right primary path.recordWorkopt-in with capability mirroring — Correct given tools blocks do not bubble resource declarations.- Three collections, not one — File index, plan index, and gaps have different shapes and query patterns. Merging them would not simplify reads.
- Goal harness extension — End-to-end proof (second run into same workstream,
topicPrefix, zero prefix bulk-loads, PASS/FAIL/INCONCLUSIVE plan arm) is not redundant with unit tests; it grades properties only an integration path can see.
Simplification opportunities (none blocking)
| Area | Severity | Note |
|---|---|---|
| Doc typos: "two collections" | Minor | recordWork docs and openWorkRecorder header say two collections but list/declare three (observed-gaps). Easy fix; avoids reader confusion. |
| Prose id recovery | Minor–moderate | recoverItemIdFromProse + regex may be dead weight if measured SDK always ships tool_use_result.task.id. If the POC/probe confirmed structured output on every TaskCreate in your target SDK version, dropping the prose path removes ~30 lines and a fragile regex. If not confirmed, keep it — but worth a one-line comment citing the measured version. |
| Flush timer machinery | Moderate (debatable) | armTimer / setTimeout / unref / serialized writing chain is the most intricate part of work-recorder. The tradeoff (durability on kill vs write amplification) is real. A simpler alternative worth considering: flush on turn boundaries — e.g. call recorder.flush() alongside closeStreamingItems when message.type === "assistant" (once per turn, no timer). That removes timer lifecycle while still surviving kills between turns. I am not certain it is better than 1s coalescing during long tool-heavy turns; it is a fork to weigh, not a mandate. |
| Comment density | Minor | File headers and inline essays encode real invariants (gap rows vs status dedupe, lazy vs list/count, TodoWrite vs TaskCreate). Valuable, but ~40% of several files is prose. Moving the longest invariant blocks to docs/architecture/ or trimming to "why not X" one-liners would shrink the diff without losing the design record. |
UpsertableCollection seam |
Minor (keep) | Looks like over-abstraction until you see the fake collection tests and the deliberate omission of list/count. Worth keeping. |
| Third-party packages | N/A | No obvious library replaces FSD lazy resource upserts + per-run keying. debounce/p-queue would only shave the timer, not the model. |
Approaches I would not take
- Post-hoc item projection — Items are the wrong contract for keyed file/plan state; you would re-parse tool_output prose and lose the structured
tool_use_resultpath you just built. - Filesystem watchers (
chokidar, etc.) — Out of scope by design (tool-driven record, not disk truth). - Inlining the recorder into
agent.ts— Would couple persistence buffering to the SDK loop and make the translate/recorder unit split harder to test. - Files-only v1 — Plan half is already optional at the goal (INCONCLUSIVE when harness doesn't plan); the implementation cost is mostly shared translate state.
Performance (not a merge blocker)
drain()still does sequential per-keyupsertper flush window — expected without a batch store API.canonicalFilePathKeyuses syncresolvePathon each file op — cheap relative to collection I/O.- Hot loop does
recorder?.observe(event)thenawait emitTranslatedEvent(...)per event — recording is sync buffer-only; the await is emit. Fine unless profiling shows otherwise.
Summary
This is not an approach that went too far in the wrong direction. It went deep on the right seams. The actionable simplifications are mostly trim: fix the two/three collection docs, consider dropping prose id recovery if structurally guaranteed, and optionally replace the flush timer with turn-boundary flush if you want less concurrent machinery.
I am not requesting changes for merge — these are refinement suggestions. Happy to see this land and iterate on comment trim / flush strategy in a follow-up if you prefer.
Sent by Cursor Automation: Review For Best Approach
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f066e7c2f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
second-look: PR #1332Verdict: Appropriately scoped — no candidate survives the calibration gate; this is unusually restrained for its size.
No line item below +/-50 net or without an articulable, present consumer. Full pass notes below. Five lenses, applied
Non-finding, routed elsewhere
Considered & deemed justified
Posted by an automated second-look pass (retrospective approach/restraint review). Read-only — no code changes made. Generated by Claude Code |
There was a problem hiding this comment.
Grok simplify review (2nd pass) — LAB-134 work recording
This is the Grok version of the parallel simplify review (the other automation already posted under a different run). Same charter: look for approach overshoot and cleaner alternatives; approve if the taken approach is best.
Verdict
Approve. The approach is the right one for the approved direction. I would not replace it with item-stream projection, a filesystem watcher, a merged journal collection, or folding the recorder into emit.ts / agent.ts.
Continuity from the Grok review of the spec (#1329):
| Spec concern | This implementation |
|---|---|
Drop transitions[] |
Done — previousStatus only |
| Plan goal hardness | Done — PASS / FAIL / INCONCLUSIVE with non-zero exit |
Soft prefer tool_* over new kinds |
Not adopted — deliberately; see below |
| Architecture (session collections, opt-in, vendor in claude-code) | Intact |
What felt large (+2.7k) is mostly tests + goal harness. Production surface is roughly four focused modules. That matches the real constraints (reuse workstream + per-run keys, lazy collections, pending/settle, never-throw gaps, measured TaskCreate/TaskUpdate not TodoWrite).
Where I agree with the other pass
- Translate → framework-vocabulary → vendor-free recorder is the main structural win.
- Three collections beat one heterogeneous journal for gaps.
- Coalesced flush is justified for kill-mid-run durability; I would not drop pending-at-call.
- Dual
workRecorderResourceson block + capability mirrors thesessionStateSchemaseam and is required, not duplication for its own sake. - No useful 3P package here (debounce/path libs would not shrink the model).
- Directory placement under
packages/claude-code/src/sdk/is clean.
I will not re-litigate their inline notes (two/three wording, prose-id trim, turn-boundary flush fork) — those stand.
Where this pass differs / adds
1. New TranslatedEvent kinds — justified, not free (uncertain how hard to push)
file_op_observed / plan_item_observed / work_gap_observed ride the translate → agent loop → emit switch, then no-op in emit. The soft #1329 preference was "listen to existing tool_call/tool_result." After reading the structured tool_use_result attribution guard and create-id recovery, I think keeping vendor mapping in translate and emitting observation kinds is cleaner than putting tool names in the recorder or enriching tool_result enough to drive it. So I am not requesting a redesign.
If you ever want a smaller union without moving vendor knowledge: return { events, observations } from translate so observations never enter TranslatedEvent / the exhaustive emit switch. That is a tidy follow-up, not a merge blocker. I am unsure it is worth doing now vs accepting three no-op arms.
2. Comment / essay weight is the real overshoot
Same invariants (gaps vs blindness, tools don't bubble resources, never break the run, lazy vs list/count) are restated across work-collections, work-recorder, capability, and the long recordWork option. The option already claims to be the canonical explanation — the other sites can point there in one line. This is taste/maintainability, not correctness. Trim in a follow-up is enough.
3. Three open maps → one pending union (small concrete trim)
openFileOps / openPlanCreates / openPlanUpdates are three callId-keyed maps with parallel get/delete ladders. A single Map<string, FilePending | PlanCreatePending | PlanUpdatePending> would shrink state surface without changing behavior. Optional cleanup — not blocking.
4. Product ask — ship the plan half unproven end-to-end
Agree with the PR recommendation: ship it. File half is proved on real runs; plan half is off by default; INCONCLUSIVE already refuses to fake a pass; the first customer who sees plan tools fire is the first E2E proof. I would only hold if a customer promise specifically depends on reading an agent's plan back — which the PR already names.
Approaches I would not take
- Recorder consuming raw
tool_*today (leaks vendor names or forcestool_resultto carry structured Output). - Files-only v1 (plan cost is mostly shared translate state; goal already grades it thin).
- Shared monorepo "buffered upsert" helper (no other consumer; speculative abstraction).
- Status notes as the durable gap record (dedupe / latest-wins — correctly rejected).
Disposition
APPROVE. Best approach for the approved spec; residual notes are trim and optional follow-ups, not a different design. The other pass's doc/prose/flush notes are worth taking when convenient.
Sent by Cursor Automation: Grok Review For Best Approach
… (LAB-134) Review rounds 1 and 2 on #1332. All three defects are the same family — the record saying something other than what the run did. **The reporting path could fail the run.** `onSkipped` was called unguarded from inside the serialized flush chain, so a throwing hook rejected `flush()`/`stop()` and turned a successful coding run into a bookkeeping failure — precisely the outcome this module exists to make impossible, hiding in the one place nobody defends because it is the thing that reports failures. Every call now routes through one guarded helper, so a future third call site cannot forget. **A phantom unresolved mutation.** The attempt was keyed at call time and the settlement keyed under the harness's resolved path, so a single write left a permanent `pending` row beside an `applied` one whenever the two differed. The key is fixed at call time by the recording cadence, so settling elsewhere can only ever split one operation in two: settlement now uses the call-time path. The harness's path still rides along and is compared AFTER canonicalization — in the recorder, where `notes.txt` and `/work/notes.txt` are known to be one key — and a real divergence becomes a gap row rather than a silent mis-keying. **A successful re-wording was dropped.** `TaskUpdateInput.subject` is declared on the pinned SDK and changes an item's wording, but only `taskId`/`status` were kept — so `observed-plan` held the create-time title forever while claiming to be the run's current plan. The new wording is now retained and applied on a confirmed update only, the same rule the status already followed. Also: the option's doc said two collections where three are declared, the comment beside the prose id fallback now scopes what was and was not measured (one probe run, `claude` 2.1.234), and the comment claiming pathless calls are "skipped silently" said the opposite of the code — an invitation to simplify away the gap emission that makes the next issue's assertion buildable. Kept the coalescing flush: a turn-boundary flush survives a kill between turns but not within one, and a long tool-heavy turn is exactly the coding-run shape. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
|
Rounds 1 and 2 folded in 1. The reporting path could fail the run ( 2. The phantom unresolved mutation ( On making it consistent with the canonicalization rule — that's what moved the comparison. The harness's path still rides along on the event as 3. The dropped Also fixed: the two-vs-three collection count (three sites, including the Kept the coalescing timer, and added the reason to the comment so the next reviewer doesn't re-propose it: a turn-boundary flush survives a kill between turns but not within one, and a long tool-heavy turn is exactly the coding-run shape. Guards proved able to fail, same discipline as round 1 — 7/7 caught, each mutation restoring the exact defect under review: Suites: claude-code Nothing merges. Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df6cfdbedc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Review round 3 on #1332. Two real defects at the edges of the durability machinery, and one reported defect that does not reproduce. **The namespace was the request, not the run.** Rows were keyed by `ctx.request.identity.id`, but a generator holding this agent as a tool can call it several times inside one request — the framework's own tool executor disambiguates each call by `stepNumber:toolCallId` precisely because that happens. Every such call is a separate coding run, so a request-wide namespace merged them: same paths overwritten, to-do ids merged (the harness numbers those per agent session, so two runs both having a task `5` is ordinary), and gap ordinals — which restart at 1 per recorder — clobbering each other outright. Keys are now `<requestId>/<invocation>`, where the invocation is the framework's `blockPath`: unique per call and stable across a replay, which a minted id would not be. Two segments rather than replacing the request id, so `topicPrefix=<collection>/<requestId>/` still selects everything one request did while the invocation narrows to a single run — a row that could not be correlated back to its request would have been a worse record, not a better one. Docs, README, changeset and the goal check all updated to the new shape. **An interrupted plan create vanished.** The plan side was missing the survive-an-interrupt property the file side already had. A file mutation records a `pending` row when its call is seen; a plan create cannot, because the item has no id until the harness answers — so an abort left the title in memory and nothing anywhere, making an interrupted plan attempt indistinguishable from a run that never planned. Unsettled creates now drain to gap rows at stream end, on the success path as well as the throw path (`error_max_turns` ends a stream mid-exchange). Open file ops and open plan updates deliberately drain nothing: both already recorded an attempt. **The reported shutdown race does not reproduce.** The claim was that a gap raised by a write failing after `stop()`'s flush is stranded behind a fresh timer. It is not: a flush drains gaps LAST, in the same chained body as the file and plan writes, so a failure in either lands in that same flush's gap batch, and nothing can add to `pendingGaps` after its snapshot except a later flush that snapshots again. Verified by reconstructing the scenario against the unmodified `stop()` — the gap was persisted. The proposed drain-to-quiescence loop is reverted as machinery for a case that cannot happen; the ordering invariant it would have papered over now has the test instead, and `stop()` says out loud that it depends on it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
|
Round 3 in 2 — the namespace was the request, not the run. Confirmed, and it changes the key.A generator holding this agent as a tool can call it repeatedly in one request. The evidence is So the merge was real, and the sharpest instance is the one you'd expect least: gap ordinals restart at 1 per recorder, so invocation 2's New key: Deviation from your instruction, deliberately. You said a per-invocation identity rather than the request id. I kept the request id as the leading segment and appended the invocation, because replacing it outright makes a row impossible to correlate back to the request that caused it. For LAB-135 this means 1 — the interrupted
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f2f63d372
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…t (LAB-134) Review round 4 on #1332. Both defects are in this goal's own graders, and both are the shape the epic is about — a check that is green when the thing it verifies is absent. **Per-run attribution was blind to the collision it proves.** The check computed which runs own each held-out filename and then only counted them, never comparing against the run that actually wrote the file. If both runs' rows landed in one namespace, every filename still had exactly one owner and the overlap check saw nothing, because the other namespace was empty. That is precisely the merge per-run keying exists to prevent: had that keying been wrong, this goal would have called it right. The expected owner is now established by WHEN each request appeared — the request present after the first dispatch, and the one new after the second — and each file must belong to its own run and to no other. **A missing previousStatus counted as a move.** `previousStatus !== status` is satisfied by the schema default of `null`, so a recorder that kept only a final status graded as having preserved the transitions it discarded. It must now be a string as well as different. **The graders sanity-check themselves before the runs start.** Neither defect could have been caught by mutating and re-running: the plan grader is unreachable while the plan arm stays INCONCLUSIVE, and the file grader's broken world is not reachable through the current recorder. So both graders are now extracted, handed their broken world at goal start, and the goal stops immediately if either accepts it. That self-check earned itself during this change: the first mutation of the attribution grader slipped through, which exposed that the assertion's two halves masked each other — "some run owns it" and "no other run owns it" together reject the merged world, so weakening the first half changed nothing under this caller. The self-check gained the world that isolates them, and all three mutations then failed as they should. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
|
Round 4 in 1 — attribution was blind to the collision it provesConfirmed: Your framing of it is the part worth keeping: this is the check that proves round 3's per-run keying, and it was blind to exactly the merge round 3 fixed. Expected ownership now comes from when each request appeared — present after the first dispatch, new after the second — rather than from listing order, which is the route's business and not something this goal should assume. 2 — a missing
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee55636c76
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ile kind (LAB-134) Review round 5 on #1332. **Recorder shutdown is now a `finally`, not a step on each path.** It used to be written out twice — once on the success path, once on the throw path — which made it one more statement that anything running before it could skip. Three review findings have now been exactly that, each a different upstream step preventing the same shutdown: a throwing report hook, an unanswered plan create, and `finalizeOpenItems` rejecting while persisting an incomplete item. Guarding a third path would have left a fourth. One `finally` around the whole run retires the class: it runs on success, on an SDK throw, on an abort, and on a throw from anything between the loop and the return, and it cannot drift out of sync with a sibling copy because there isn't one. Its body is wrapped, because a throw THERE would replace the run's real outcome with a bookkeeping error — the one place where "watching the work must never break the work" would be violated by the code enforcing it. **A `Write` that overwrites is recorded as an edit.** The tool name is only a guess at the kind, and the call-time guess was being reused at settlement — so overwriting an existing file recorded `lastKind: created` while the harness's own output said `type: "update"`. The settled kind now comes from that output when it is there. `Edit` reports no `type` at all, so the call-time kind stays the fallback rather than the exception, and a FAILED attempt keeps the kind it attempted: nothing was created or updated, so a completion kind read off the output would contradict the `failed` outcome beside it. **Changeset trimmed to what a release-note reader needs.** It carried problem narrative, schema detail, keying mechanics and capability rationale — none of which survives the outsider rule once it becomes published release notes. What changed, the two limits that would surprise someone, and a link to the guide. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
|
Round 5 in 1 — recorder shutdown is now structuralConfirmed: You were right that this had stopped being a per-path bug. Shutdown was written out twice — once on the success path, once on the throw path — which is what made it one more statement that anything running before it could skip. All three findings were that same shape with a different upstream step: the throwing report hook, the unanswered plan create, and now finalization rejecting. Guarding this path would have left a fourth. So it's one 2 — an overwriting
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 952bb091f5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Round 7 in 1 — a mismatched
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75dc69519f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…s a batch (LAB-134) Review round 8 on #1332. Two findings share a root — the record is keyed by SUBJECT (a path, a task id) while mutations are per CALL — and one is a precision failure in round 6's own rule. **Identity collapsed at the key.** Two calls in flight on one path shared a buffer entry, so the first result to arrive settled the row the second was still using: if that second call was then interrupted, the row read `applied` and its unresolved mutation disappeared from the readback entirely. Observation events now carry the call they belong to, and the recorder tracks which calls are still open per row — a row leaves `pending` only when nothing is outstanding on it. That is the can't-tell rule again: while a mutation on this subject is unresolved, "unresolved" is the honest outcome. **Delivery is now structural, like shutdown.** Translation consumes a message and clears its correlation maps for every call in it, so the events are then the only record of what those calls did. Delivering them one at a time, interleaved with the emission `await`, made every event after the first conditional on item persistence succeeding — one rejection and a settled `TaskCreate` vanished from `observed-plan` AND `observed-gaps`, because the end-of-run drain finds no open create either. The whole batch now reaches the recorder before anything is awaited; `observe` is synchronous and never throws, so the window is closed rather than guarded. **`updatedFields` establishes THAT a field changed, not WHAT to.** Recording the requested value as confirmed is round 6's rule one notch too far. It is only wrong when the executed input can differ from the call we saw, which happens for exactly one reason: an `onToolApproval` seam becoming the SDK's `canUseTool` and returning an `updatedInput`. So translation now knows whether that seam is installed. Without it the call-time value is confirmed by construction; with it, a field the harness says changed without reporting a value is left unrecorded and the gap says the row is out of date. Also folds in a BP-006 fix in the goal, found by LAB-135's implementer: two runtime identifiers carried a planning label. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
|
Round 8 in 1 and 3 — identity collapsed at the keyYour framing was the fix: the record is keyed by subject, the events are per call. Observations now carry the call they belong to, and the recorder tracks which calls are still open per row — a row leaves And you were right that this extends round 5. Delivery is now structural the same way shutdown is: the whole translated batch reaches the recorder before anything is awaited. 2 —
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 877e25c8ff
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ch record a gap covers (LAB-134) Review round 9 on #1332, plus one surface found while checking my own. **A path the harness never named is no longer confirmed.** With an approval seam installed the executed `file_path` can differ from the call, and the row is keyed by the call. A result that names a path is compared and gaps on divergence — but one that names none was settled anyway, marking the original path `applied` while the file actually written was omitted entirely, with no gap pointing at either. That is the worst version of this defect: not a wrong row but a SILENT one. The attempt now stays `pending` and the gap carries the raw path. Only fires when an approval seam exists, because without one the call-time value is what executed. **A held settlement no longer carries its own kind.** Two calls overlapping on one path — a Write and an Edit — settle one at a time. The outcome correctly stays `pending` for the unfinished call, but the finished call's `created` overwrote the kind, leaving a row whose outcome referred to one call and whose kind referred to another. The field is now omitted while the settlement is held, so the upsert keeps the in-flight call's kind. **Gap rows say which record they stand in for.** A closed `kind` of `file` / `plan` / `run`, requested by LAB-135, which needs to tell a plan gap from an unkeyable-file gap. Pathless gaps carry no `rawPath` to infer it from, so the alternative was matching words in `reason` — grading by substring, which is the failure this record exists to make unnecessary. **Retry attempts get their own namespace.** VERIFIED before building: the `executeBlock` retry loop increments an attempt counter and rebuilds the instance id from `(request, path, attempt)` while leaving the PATH untouched, and exposes `ctx.attempt` for exactly this. So a retried run re-enters at the same path, opens a second recorder, and restarts its gap ordinals at 1. The namespace used two thirds of the framework's own invocation identity; it now uses all three. **And one found by checking a surface I had flagged myself:** deriving a plan item's previous status assumes the statuses this recorder saw arrived in the order they happened, which concurrent updates do not guarantee. The first attempt at this — suppressing derivation while calls overlap — was caught INCOMPLETE by its own test: the last call to settle reads a value an out-of-order sibling wrote, so the row still asserted a move backwards. Once the ordering is unknowable it stays unknowable, and only the harness's own `from` can speak to a transition afterwards. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
|
Round 9 in 1 — a path the harness never named was confirmed silentlyConfirmed, and your framing of the severity was right: this is the worst version, because no gap was emitted. The attempt now stays 2 — held settlement carrying its own kindConfirmed. The field is now omitted while the settlement is held, so the upsert keeps the in-flight call's kind rather than the finished one's. 3 —
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b01b39a88
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Round 10's two findings were both instances of a class round 9 already named, so this is the sweep that class implies rather than two point fixes. Every fix from rounds 5-9 was re-read against three axes — ordering (does it hold when the events arrive the other way round?), polarity (does it hold for a failure as well as a success?), presence (does it hold when a field, or the other subject, is absent?) — and checked for whether a test reaches the other side. Three instances, two reported and one found by the sweep: - Ordering. `settleAgainstOpenCalls` returned an outcome without saying which call it describes, so the caller guessed the matching kind — and guessed wrong in both directions across two rounds. It now returns the pair, and the guess has nowhere to live. Reported case: Edit opens second and settles first, leaving the row's `edited` beside a `pending` that means the Write. - Polarity. The wrong-subject guard for plan updates sat below the refusal branch, so a refusal naming a different item recorded `failed` on ours. Which item a result is about is now settled before what it says happened. - Polarity, found by the sweep. The same guard for file ops tested `!isError`, so an errored result naming no path under an approval seam settled the call-time path as `failed` — a claim about a subject we cannot identify, no safer for being negative. - Presence, found by the sweep. Files and plan items key as `<runId>/<segment>` into two different collections but shared one in-flight bookkeeping map, so a plan item id matching a root-level path could hold that file's row unsettled. Reachable only through that collision; the map has no reason to be shared. Four mutations, one per instance, 4/4 caught. The measurement worth recording is what happened before the tests were written: all 181 existing tests passed with all four fixes applied, so none of the four worlds was reachable by the suite — including two that sat directly beside a test which looked like coverage, where the covering test used the arrangement that happens to be right. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_71e63232-8a5b-4223-9c4d-4a8875f73760) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 281bed40d1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const status = | ||
| movedTo ?? | ||
| (applied?.has("status") === false || changedButUnreadable("status") | ||
| ? null | ||
| : update.status); |
There was a problem hiding this comment.
Do not confirm plan fields when approval output is absent
When onToolApproval is installed and a successful TaskUpdate omits the optional tool_use_result, approval may have revised the status or target task, but movedTo and applied are both null and this fallback records the original requested status as applied. For example, an approval that changes completed to blocked leaves observed-plan claiming completed; an absent result also bypasses the reported-ID mismatch guard. Unlike the previously reported explicit-mismatch cases, the fresh path here is a singleton result with no structured confirmation at all, so call-time fields should remain uncertain.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real, in family, and filed as LAB-137 rather than fixed here. Leaving this thread open and unresolved, because it is not addressed.
Both halves check out. The file path already treats "seam installed, no structured result" as unattributable — the plan path does not, so a TaskUpdate with no tool_use_result records the requested status as applied, and the reported-ID guard never runs because there is no reported id to compare against. Same seam, same absence, opposite treatment: it is the presence axis, on the surface where the axis was found.
Not folding it is deliberate. This is the thirteenth instance of one family across six rounds and the arrival rate is flat, so the remaining work is to make the wrong shape unwritable rather than to correct one more site. LAB-137 carries the family, the axes, and this as an example.
Generated by Claude Code
| confirmedStatus.set(event.itemId, event.status); | ||
| merged.status = event.status; |
There was a problem hiding this comment.
Avoid choosing current status by result arrival order
When concurrent TaskUpdate calls on one item settle in a different order from execution, every settlement overwrites the row's current status even though orderingUnknowable only suppresses derivation of previousStatus. For actual transitions pending → in_progress → completed whose results are delivered completed then in_progress, the final row incorrectly reports in_progress; either reconstruct the order from authoritative transitions or leave the current state uncertain once ordering is unknowable.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real, in family, and filed as LAB-137 rather than fixed here. Leaving this thread open and unresolved, because it is not addressed.
You are right, and it is the third instance of one thing I named myself: a fix aimed at the right defect can still be aimed at the wrong extent of it. orderingUnknowable was applied to the derivation of previousStatus and not to the write of the current status, which has exactly the same dependence on arrival order.
Not folding it is deliberate. Rounds 5 through 10 each produced two to four fresh instances of this family and the rate is not decaying — enumerating cells of (field × settlement path × ordering × presence of a structured result) one review pass at a time does not terminate. LAB-137 is for making the shape unwritable instead: a value that came from a call-time input should not be expressible as a confirmed field. This instance is recorded there as an example.
Generated by Claude Code
| const create = state.openPlanCreates.get(callId); | ||
| if (create !== undefined) { | ||
| state.openPlanCreates.delete(callId); | ||
| if (isError) return true; // a create that failed created nothing to record |
There was a problem hiding this comment.
Preserve failed TaskCreate attempts as gaps
When a recognized TaskCreate returns a tool error, this branch deletes its correlation entry and emits neither a plan row nor a durable gap, so readback is indistinguishable from a run that never attempted to plan. Fresh evidence beyond the earlier interrupted-create finding is that the result has arrived here and removal prevents the final unsettled-create drain from recovering it; emit a plan gap because the failed create has no item ID under which to record an outcome.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real, in family, and filed as LAB-137 rather than fixed here. Leaving this thread open and unresolved, because it is not addressed.
Confirmed by reading: the branch deletes the correlation entry before returning, so the end-of-stream drain cannot recover it either — and a create the harness tried and failed becomes indistinguishable from a run that never planned. That ambiguity is the one thing observed-gaps exists to remove, so this is the gap collection failing at its own job rather than a missing nicety.
Not folding it is deliberate: rounds 5-10 each produced two to four fresh instances of this family with no sign of the rate decaying, so the remaining work is structural rather than another call site. Recorded on LAB-137 as an example of the family.
Generated by Claude Code
Round 10 — the sweep, and the stopBoth findings on Three instances, plus the structural change that makes one of them unreachable rather than fixed. 1. Ordering — reported. 2. Polarity — reported. The wrong-subject guard for plan updates sat below the refusal branch, so a refusal naming a different item recorded 3. Polarity — found by the sweep. The same guard for file ops tested 4. Presence — found by the sweep. Files and plan items both key as What the mutation pass actually showedFour mutations, one per instance, 4/4 caught. The result worth reporting is the one before the tests were written: all 181 existing tests passed with all four fixes applied. The suite could not see any of the four worlds. Two of them sat directly beside a test that looked like coverage — the overlapping-calls test covers the arrangement where the first-opened call settles first, which is the arrangement the broken code happens to get right. That is the sharper form of the round-4 lesson. Knowing the rule doesn't make you see the instance; a test about the rule doesn't make you cover the instance either, when the fixture picked the easy side of the axis by accident.
Stopping here as agreed — no round 11 regardless of what a further sweep would turn up. Typecheck & Test green on the prior head; 181 → 186 tests. Review threads I handled are resolved, with a reply on each deliberate decline. This does not merge. Generated by Claude Code |
The claim was "all 181 existing tests passed with all four fixes applied". 181 is the after-count; the measured before-count is 176. The suite went 176 -> 181 when the round's five new tests landed. Left visible in the verdict log rather than quietly amended: getting a scoped-to-what-was-measured number wrong, in the round about claims outrunning their evidence, is the more useful thing to have written down. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
Stopping, with three findings open — and one correction to the comment aboveCorrection first. The round-10 comment says the sweep's key measurement was "all 181 existing tests passed with all four fixes applied", and quotes 181 → 186. 176 is the before-count; 181 is the after. The suite went 176 → 181 with that round's five new tests. The finding is unchanged and if anything cleaner — 176 tests, none of which could see any of the four worlds — but the number was wrong, in the round about claims outrunning their evidence. Corrected in the PR description and left visible in the verdict log rather than quietly amended ( Three new P2s arrived on
Each is answered on its own thread and left unresolved, because they are not addressed and marking them resolved would be the same unearned claim these ten rounds went into eliminating. Why stopping is the right call rather than fatigueAt round 9 I argued the review had converged, on the grounds that each round needed fewer new concepts than the last and the grain had bottomed out at per-call. That was right about concepts and wrong about instances. In-family findings per round from 5 on: 1, 2, 3, 3, 4, 2, and now 3. Flat. Two rounds also swept instead of folding, and both found more than had been reported — round 6 went 2 → 8, round 10 went 2 → 4. The family is a record field asserted without confirmation, and its instance space is roughly (field × settlement path × arrival ordering × presence of a structured result). A reviewer enumerating cells of that grid one pass at a time will not run out before we do. Only making the wrong shape unwritable ends it — a value that came from a call-time input should not be expressible as a confirmed field, with the compiler refusing it rather than a reviewer catching it on the twelfth pass. That move has already worked twice in this codebase: the three-part run namespace in this very feature (merged runs stopped recurring the moment the key became the framework's own invocation identity), and LAB-135's pooling fix next door. Filed as LAB-137, under LAB-68 and related to LAB-134. It carries the family stated once, the arrival-rate evidence, the three axes any candidate fix must be checked on both sides of — ordering, outcome polarity, presence — and the three open findings as examples of the family rather than as the work item. Linked from the description so a reader at the gate sees the known remainder rather than discovering it. State at handoff
#1332 does not merge. Generated by Claude Code |
Each observed file-op row said what last happened to a path and how it settled, so a file touched nine times read the same as one touched once. `appliedCount` is the missing number. Applied operations only, and the first reason is decisive rather than a preference: an operation is recorded TWICE, once when its call is seen and once when its result arrives, so a count of everything recorded would read as double the work done. The second reason is what makes it worth exposing — `outcome` beside it describes only the last settlement, so a count that folded attempts in with confirmations would leave nothing saying how many of a path's touches actually landed. Counted from the event's own outcome, never the row's folded one: a call that applied while a sibling call is still open on the path is correctly held at `pending` for the ROW, but the operation landed, and counting off the row would drop precisely the concurrent writes worth counting. The running total is held in memory beside `confirmedStatus`, for the same reason — this recorder is the only writer of the run's rows, and the buffered entry is cleared on every flush. Null on a row written before the field existed (BP-030), which is not the same as `0`: zero means the run touched the path and nothing applied. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_b15c2351-c0f1-4906-8dea-453ef3aff765) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e6cc9b4df9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| workstream = rows[0]; | ||
| if (workstream !== undefined && workstream.status !== "active") break; | ||
| rows = (body?.workstreams ?? []) as WorkstreamRow[]; | ||
| if (rows.length > 0 && rows.every((r) => r.status !== "active")) break; |
There was a problem hiding this comment.
Wait for the newly dispatched request before accepting inactivity
On the second dispatchAndWait call, the board reuses a workstream whose previous request is already terminal. In the default in-process path, detached acceptance can precede persistence of the new request record, so this condition can immediately observe only that prior terminal status and exit before the second coding run or its resource rows exist. The per-run attribution check then reads incomplete state and fails nondeterministically, rather than verifying the second run; wait for the request count or newest request ID to change before waiting for that request to become terminal.
Useful? React with 👍 / 👎.
| // differ for an ordinary reason, and the create result declares `subject` | ||
| // as a required field — so the row would be stale the moment it was | ||
| // written. Falls back to the request when the result omits it. | ||
| const title = readNestedString(structured, "task", "subject") ?? create.title; |
There was a problem hiding this comment.
Keep an unconfirmed TaskCreate title uncertain
When onToolApproval is installed, approval can revise the TaskCreate subject; if the successful result omits tool_use_result but its prose still supplies the new task ID, this fallback records the assistant's pre-approval subject as an applied title with no gap. Fresh evidence beyond the earlier TaskCreate-subject finding is this absent-structured-output/prose-ID path, where no confirmed subject exists to prefer. When inputsMayBeRevised is true, omit the fallback title or emit a gap instead of presenting it as confirmed.
Useful? React with 👍 / 👎.
Coordinator — two findings on
|
…g it (LAB-133)
The option was named after the framework primitive it suppresses:
`sessionState` shadowed `sessionStateSchema`, which appears six times in the
same file. `detached` is the vocabulary the option's own JSDoc already used, it
is an adjective so it reads correctly as a boolean, and it states the unusual
mode positively instead of as a double negative.
Polarity inverts at every read site, and the option stays three-state:
sessionState !== false (the default) -> !detached
sessionState === false ("detached") -> detached === true
omitted -> unchanged: an in-session agent
`sessionStateSchema` is untouched — not shadowing it is the point.
Tests pin all three states (`true`, `false`, omitted) against both observable
consequences — whether the schema is declared, and whether the SDK is handed a
`resume` — at the block's read sites and again at the capability's own. Verified
by mutation: flipping the declaration polarity reds 5 tests, the three runtime
read sites 7, the block default 3 (incl. the omitted case), and the
capability's declaration 3.
Applied identically on fix/LAB-133, fix/LAB-134 and fix/LAB-135 so the rename
does not add a second conflict on top of the `translate.ts` divergence.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_96457d5f-8caf-4070-9074-a740d80d8694) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 16a88abac4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| includePartialMessages = true, | ||
| onToolApproval, | ||
| sessionState = true, | ||
| detached = false, |
There was a problem hiding this comment.
Reject legacy sessionState before defaulting to stateful mode
When a caller passes the former sessionState: false through an indirect or spread options object, TypeScript can accept it when the object also contains recognized fields, but this destructuring silently ignores the removed key and defaults to detached: false. The same configuration that previously disabled session state can therefore resume/persist conversations or make task-board composition fail; BP-030 requires removed public config keys to throw an error naming the replacement, so detect sessionState before applying this default.
Useful? React with 👍 / 👎.
|
|
||
| | Accessor | One entry per | | ||
| |----------|---------------| | ||
| | `observed-file-ops` | path the run's file-writing/editing tools touched — `lastKind`, `outcome` (`pending`/`applied`/`failed`), `lastTouchedAt`. Paths, never contents | |
There was a problem hiding this comment.
Document appliedCount in the public readback contract
The exported file-operation schema and client projection now include appliedCount, with a meaningful legacy distinction between null and 0, but this exhaustive-looking field list omits it and the user-doc response example does too. Consumers following the package API documentation therefore cannot discover or correctly interpret the new field; add it and its null/zero semantics to both documentation surfaces.
AGENTS.md reference: AGENTS.md:L199-L205
Useful? React with 👍 / 👎.
…nState` (LAB-133) The option is introduced by this branch stack, not renamed on a released one. On `origin/main` every `sessionState` occurrence in `packages/claude-code` is `sessionStateSchema` — the framework primitive — and `sessionStateSchema` is declared unconditionally there (`agent.ts:153`, `capability.ts:34`); no `sessionState?: boolean` option exists. So the option and its final `detached` name land in the same release, and a fragment telling users to migrate off `sessionState` would document a breaking change to an API nobody ever had. `claude-code-agent-detached.md` already describes the option as it ships and names the issue; that is the whole story. (The bare-string grep that suggested otherwise matched `sessionStateSchema` — the shadowing this rename exists to remove.) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
…-134) `appliedCount` is public: it is in the exported file-operation schema and in `client.expose`, so it reaches callers over the resource route. The README's field list for `observed-file-ops` reads as exhaustive and omitted it, and the docs-site response example omitted it too. Both now name it, and both state the distinction a field list cannot carry: the count is confirmations, not attempts (each operation is recorded twice, once when the call is seen and once when it settles), and `0` and `null` are different answers — `0` is "touched, nothing applied", `null` is a row written before the field existed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
`fix/LAB-133` was rebased/force-pushed before PR #1327 merged, so `main` carries LAB-133's commits under new SHAs while this branch still carries the originals. Same changes, two unrelated lineages — which is why the merge base fell back to `f56c6b216` (PR #1307) and 9 files conflicted across 32 hunks. Resolution: every conflicted file's main-side contributors are LAB-133 commits that have a paired equivalent in this branch's lineage. Seven of the eight pairs are patch-id identical; the eighth (the `sessionState` -> `detached` rename) differs only because it was applied over LAB-134's larger agent.ts, and its `detached` usage set is identical to main's. So main contributes no content this branch lacks, and each hunk kept LAB-134's side — which is main's LAB-133 content plus LAB-134's own work (work recorder, translation, `appliedCount`). The rename's polarity is unchanged: `detached: true` == the old `sessionState: false`. The only diff-vs-main touching a `detached` line is a two-space indentation shift from LAB-134's try/finally wrapper. Verified: 187/187 claude-code tests pass; `turbo run typecheck --force` 61/61 with 0 cached; diff vs main is LAB-134's work only. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVcrTezeLMBQRVHRg2QX2f
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_d9e9dd38-07f1-4535-be7b-90ec627533b2) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa8ade3e30
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // namespace: paths overwritten, and gap ordinals (which restart at 1 per | ||
| // recorder) clobbering the earlier attempt's outright. | ||
| const attempt = identity?.attempt ?? (ctx as { attempt?: number }).attempt ?? 0; | ||
| return `${ctx.request.identity.id}/${step}#${attempt}`; |
There was a problem hiding this comment.
Encode request IDs before building resource paths
When a client uses the supported pre-generated requestId with a path-like value containing a .. segment (for example, release/../42), this raw namespace is later passed to normalizeResourcePath, which rejects every file and plan key. The resulting gap rows reuse the same invalid namespace and are rejected as well, so the run succeeds while all three observation collections remain empty. Encode the opaque request ID as one safe segment before composing the resource namespace.
Useful? React with 👍 / 👎.


The problem
When we hand a coding job to an agent we can now watch it talk. We cannot see what it did.
The two things that best describe a coding run — which files it changed, and what it decided
its job was — are thrown away as they happen, surviving only inside the harness's own
transcript, which nothing but a person can read.
So answering "did this run touch something it shouldn't have?" or "did it quietly decide to do
four things when we asked for one?" means opening a transcript and reading it. That works while
one person watches one run. It stops the moment anything else has to act on the answer.
Why now. Every layer above this one — grading a run, filing what came back, deciding what
happens next — reads state this layer produces. Built in the other order they read nothing.
What this does
recordWork: truerecords what a run did as ordinary state, alongside the items that alreadyrecord what it said. Off by default; on, the agent declares three session-scoped resource
collections and writes into them as the run goes.
observed-file-opsobserved-planobserved-gapskindsaying which of the other two it stands in forThe third one is the load-bearing one, and it is why the other two can be trusted: without it a
skip is indistinguishable afterwards from a mutation that never happened.
Everything reads back over the resource route that already ships; each row's payload is on
clientData. Entries are keyedrunId/segment, so a workstream reused across runsand a request that runs the agent more than once both answer per run.
Two limits are deliberate, and stated rather than implied. The file record covers
tool-driven operations only — a run that edits through the shell makes no file-tool call, so
nothing is recorded and that file does not appear. And watching the work never breaks the work:
every recording failure degrades to a gap row, never to a failed run.
One rule governs the whole translation layer, and it is worth knowing before reading any of
it: the record reflects what the harness confirms happened, not what the agent asked for. A
call and its result are two different claims, and they diverge for ordinary reasons.
What's asked of you
This implements the approved spec, so the approach and its §6 Decisions are not yours to
re-decide. Two things came out of building it.
1. Ship the to-do half proven only at the component level, or hold it until a real run plans?
The file half is proved end to end on real runs. The to-do half is not: across eight consecutive
real runs the agent never once used the harness's to-do tools — it wrote its to-do list into its
closing message as prose instead. The goal check reports INCONCLUSIVE rather than green, by
design.
produces, but only in component tests. Holding means an unknown wait: the behaviour is the
model's choice, and both configuration causes I control are ruled out by measurement.
unproved half is off by default and cannot affect anyone who doesn't opt in, and the check is
already wired to go green the moment a run does plan — so the proof arrives on its own.
an agent's plan, this is not proven enough to promise.
the first run that plans, which the gap collection exists to explain.
A second implementation reached the same answer independently. LAB-135 built its own reader
against these records and returned nine consecutive UNMEASURED plan verdicts — a different
reader, a different route, the same finding. That is the reason to trust it; neither of us set
out to produce it. The substance is in FIX-1185 rather than re-argued here.
2. Accept a known remainder, or keep going?
This PR stops with three review findings open and unfixed. They are real, they are answered
on their threads, and they are filed as LAB-137 rather than folded in. That is unusual
enough to be a decision rather than an oversight, so the reasoning is below.
feature nobody has opted into. Continuing means paying review rounds indefinitely against a
defect class that shows no sign of running out.
"a row says something slightly wrong" — never a broken run, never an empty record.
to-do record specifically, one of the three (a
TaskUpdaterecording a requested status asconfirmed) is the one that would bite.
are cheap to pick up individually if the structural fix is deferred.
Why the review stopped where it did
Every finding from round 5 onward was one defect: the record asserting something the harness
did not confirm. It surfaced at three altitudes — the wrong source (the agent's request
rather than the harness's report), the wrong subject (a result describing a different file
or item), and the wrong identity (a result describing a different call) — plus one axis
cutting across all three: the wrong extent, a fix aimed at the right defect but covering
less of it than the defect covers.
At round 9 I argued this had converged, because each round needed fewer new concepts than the
last and the grain had bottomed out at per-call. That was right about concepts and wrong about
instances, and the second does not follow from the first. In-family findings per round from 5
onward: 1, 2, 3, 3, 4, 2 — and 3 more after round 10. Flat, not decaying. Two rounds also ran
deliberate sweeps instead of folding what was reported, and both found further instances the
review had not: round 6 went from 2 reported to 8, round 10 from 2 to 4. So the counts understate
it.
The class looks unbounded by construction. The instance space is roughly (field × settlement
path × arrival ordering × presence of a structured result), and enumerating its cells one review
pass at a time does not terminate. Only making the wrong shape unwritable terminates it, and that
is a different change from this one — which is what LAB-137 is for.
The sharpest single measurement, from round 10: the existing suite passed with all four of
that round's fixes applied. 176 tests, all green, none of which could see any of the four worlds
being fixed — and two of the four sat directly beside a test that looked like coverage, where the
covering test happened to use the arrangement that is right. A test about a rule does not cover
an instance of it. (The suite is 181 with that round's new tests. An earlier revision of this
description and that round's commit message quoted 181 as the before-count; it is the after-count,
corrected here and in the verdict log.)
What is deliberately not fixed and not on LAB-137, because it is unmeasured rather than
unhandled: a sub-agent may number its own to-do items independently, in which case two items
could share an id. Nothing has been observed doing this, and changing a key on speculation —
right after a consumer built against it — is the mistake this record exists to prevent.
Parts worth reviewing closely
translate.ts— the rule, and its two stated exceptions. Both exceptions are KEYS: arow's key is fixed when the call is seen, so re-keying at settlement would write a second row
beside a phantom
pendingrather than update the first. A result naming a different subjectbecomes a gap and settles nothing — on a refusal as well as on a success, which is where round
10 found it reachable only one way.
work-recorder.ts— the outstanding-call tracking. The record is keyed by subject, themutations are per call, and two calls can be open on one path at once. A row leaves
pendingonly when nothing is outstanding on it, and the outcome now travels together with the metadata
of the call it describes rather than the caller inferring which one that is.
finallyaround the run, and batch-first delivery to the recorder. Both arestructural rather than guarded: shutdown and delivery each stopped being one more statement
something upstream could skip. Three separate findings were that shape before the first, and
one more before the second.
observed-gaps' closedkind. A reader has to tell a plan gap from an unkeyable-file gapstructurally; pathless gaps carry no path to infer it from, and matching words in
reasonwould be grading by substring.
before any dispatch. Two of this goal's assertions were found passing exactly the world they
were written to catch, and neither could have been caught by mutating and re-running.
Links
Spec: Linear (durable copy) and spec PR #1329 (closed unmerged; keeps its review history) —
spec/LAB-134.mdis deliberately not in this diff (BP-037). Issue: LAB-134. Known remainder:LAB-137 (under LAB-68). Targets
fix/LAB-133(#1327), notmain. Nothing in this epicmerges until sign-off.
How to review this — altitude, what's in scope, what's deliberately unsettled
How to review this. This implements an approved spec — the approach and the numbered
Decisions in its §6 are already signed off by a human, so please review the code against
that direction, not the direction itself. The spec lives on the issue's Linear document
(the durable copy) and on the closed spec PR (#1329), which keeps its review history.
Don't expect
spec/LAB-134.mdto be in this diff — the spec PR closes unmerged atapproval and the spec never lands on
main(BP-037).Most valuable here: correctness on the second path (the legacy shape, the null
boundary, the concurrent case, the cancel path), anything deriving an auth or routing
decision from caller-controllable input, and a behaviour the tests assert around
rather than on.
Already settled upstream: the approach and every §6 Decision (human-approved — if
one is wrong, say so as a spec finding and it gets folded back; don't re-argue it inline),
and the conventions in
docs/contributing/best-practices.md.One thing that is NOT open here: further instances of the confirm-only-what-the-harness-
confirmed family. They are real and welcome, but they belong on LAB-137, not on this PR — see
"Why the review stopped where it did" for why folding them one at a time does not converge.
Engineering calls — decided here, not on the product owner's surface
against a root. Relativising emits
..for anything outside the working directory, which thekey normalizer rejects and the recorder swallows — every such write would silently never land.
request/path#attempt. The framework's own invocation identity is(request, path, attempt); using fewer parts merges runs a generator makes by calling theagent repeatedly, or that a retry re-enters at the same path. This is also the one place in
the feature where the structural move was already made, and the defect it closed stopped
recurring — which is the precedent LAB-137 argues from.
observed-gapsis one row per gap, keyed by run and ordinal — never by the failing value.The commonest skip is a value that cannot become a key.
emit.statusdedupes on the messagestring and renders into a latest-wins slot; reading a gap back out of prose is substring
grading.
upsertonly.list/counttrigger a full-prefixload on a lazy collection; the test fake throws on both so the constraint holds at run time.
runId/segmentintodifferent collections, so they stay apart only by accident of what a segment usually looks
like; the in-flight tracking is scoped by subject so a colliding id cannot hold the other's
row unsettled.
Write/Edit. Those are the two a real run has beenobserved using; a tool we do not list records nothing, which is the designed outcome.
allowedToolsis a permission allowlist, not an availability filter. Measured: a run usedBash, which was not in the list.Everything else — verification, and what was measured rather than read
Measured on the real path, not read off type declarations
The spec's POC was re-run against
claude2.1.234 (the binary the pinned SDK spawns) to settlethe one claim §12 left open. CONFIRMED — the plan tools carry a structured
tool_use_result(
{"task":{"id":"5",…}}on creates;{"success":true,…,"statusChange":{"from":…,"to":…}}onupdates). Scoped to one probe run, 2/2 creates and 4/4 updates.
Two things beyond what the spec anticipated:
TaskUpdatereports both ends of the transition,which is now the authoritative source for an item's previous status; and
Edit's structuredoutput carries no
type, so the create/update distinction comes from the tool name there andfrom the output for
Write.The goal check, run for real
Four executions — eight real coding runs. The file half is green end to end: file rows in
per-run namespaces in one reused workstream,
created/applied, each naming its ownheld-out file and no other's; zero full-prefix loads of the recorded collections during the
runs; the board ledger holding exactly one row per dispatch, so the runs' own to-dos did not
become queued work. A run also reached for
Bash, and the record honestly does not mention it —the shell scope limit exercised rather than asserted.
The plan arm reports INCONCLUSIVE on every run, names why, and lists the tools the runs did use,
so a stale detector cannot masquerade as a harness that declined to plan.
Every guard broken on purpose and watched go red
Across ten review rounds, each fix was mutated back into the defect it repaired and observed
failing before it counted — 65 mutations, all caught. Several rounds began with a mutation that
stayed green, which was the more useful result each time: it exposed a test asserting a
neighbouring world rather than the real one (fixtures whose requested and reported values were
identical, so a preference between them was invisible), and once showed a reported defect did
not reproduce at all, so the proposed fix was reverted and the invariant it would have papered
over got the test instead.
Not covered
assertions are covered by the grader self-check against synthetic worlds, and the recorder and
translation for the plan half are covered at component level against real measured shapes.
lastKind: "edited"is covered at component level only — forcing a real run to reach forEditrather than a secondWriteis not something a job can guarantee.Note
Medium Risk
Opt-in session-scoped resource writes on the Claude Code agent path, with careful keying and never-fail recording. Default-off, but the translation/recorder logic is large and can mis-attribute work if a remaining confirm-vs-request edge is hit.
Overview
recordWork: true(off by default) records what a coding run did, not only what it said. The agent (and capability) declare three lazy, client-readable collections:observed-file-ops,observed-plan, andobserved-gaps.Rows are keyed per run as
<requestId>/<invocation>#<attempt>so reused workstreams and repeated tool invocations do not merge. File rows store path, last kind,pending/applied/failed, andappliedCount(confirmed landings only;nullvs0is distinct). Plan rows stay off the task board. Recording never fails the run: unkeyable or unconfirmable mutations become gap rows.Translation prefers harness-confirmed results over the agent's request; path/id keys stay call-time so settlement cannot leave a phantom
pendingrow. Recorder shutdown and event delivery are structural (finally, batch-first observe). The harness-workstream goal now dispatches two real runs and reads collections over HTTP; the plan arm is INCONCLUSIVE when the SDK never calls plan tools.Reviewed by Cursor Bugbot for commit aa8ade3. Configure here.