Repository navigation
feat(agent-status): route structured sessions through canonical ownership - #20718
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Read the full 56-file diff end-to-end and exercised the touched suites locally (full src/main/agent-hooks subtree plus the shared store/child-work, native-chat wire, runtime, ipc, and relay files — all green). This slice moves native-chat (structured) sessions off the legacy adapter onto the canonical store while deliberately leaving PTY/OSC/relay evidence on the isolated adapter.
- Canonical structured ingress —
ingestStructuredStatus(summary, subject)now takes the exact host-scopedstructured-sessionsubject, validates it against the summary (kind/sessionId/workspaceId/finiteupdatedAt), refuses an address already held by legacy evidence, and writes throughapplyMutation({ reopenStructuredParent: true, parent }). Legacy readers are projected from the committed row viastructuredStatusLegacyEvent, withreceivedAtkept monotonic andstateStartedAtpreserved across same-state updates. - Mixed enumeration order —
combinedStatusEntries()merges legacy rows and canonical parents-with-status under one shared listing-order counter, so legacy and canonical rows cannot reorder each other through updates, drops, re-admission, or pane relocation. - Owner-address retention —
StructuredAgentSessionStatusOwnershipkeeps the exact subject so teardownforgets it even after the session record and live session are deleted, forgets the previous scope before publishing a trusted relocation, and keeps the address when a downstream observer throws. The record-deleted-first teardown path no longer needs a pane-key lookup. - Legacy fencing — admission refuses
structuredHostrows and canonically owned pane keys in both directions;applyNormalizedStatusreturnsundefinedon refusal and its callers (lifecycle/retries/inference) were made null-safe. - Child-work lifetime fencing — new binding keys distinguish one alias across several proven lifetimes,
resumetombstones retired fences beyond the bounded history, settled children are immutable, and freshness treatsidle/doneas terminal rather than decaying them. - Store hardening — an exact cumulative 16 MiB byte-budget pre-check (
agent-status-store-byte-budget.ts) is now the final step ofvalidateAgentStatusStoreState, andreopenStructuredParentis parsed only for astructured-sessionparent, clearing exactly that parent tombstone. - Credential tightening —
structuredWorkerPaneKeyBelongsToSessionnow rejects the publicstructuredAgentSessionPaneKey, whose hash-derived leaf otherwise satisfies the terminal-UUID shape check.
I also verified the byte-budget accounting against serializeAgentStatusStoreSnapshot (base empty-array object + one comma per extra record + per-record bytes is byte-exact, and those records are deeply frozen so the WeakMap cache cannot go stale), and that this only converts a deferred serialize-time throw into an atomic mutation-time rejection. Benchmarked getSnapshot() at ~0.02 ms for a realistic canonical store, so the new per-notification enumeration is not a hot-path cost in this slice.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Incremental delta since the prior pullfrog review (c93a9e09f4 → 60c3f3c8d3), three files:
- Re-admit after teardown —
StructuredAgentSessionStatusFeed.publishno longer early-returns when an unchanged projection is seen while the ownership no longer holds the session's address. It now re-publishes throughsink(summary, session.params.location)whenownership.matchesLocation(...)is false, restoring the canonical parent and its legacy projection after an earlierforgetremoved them. - Scope comparison — new
StructuredAgentSessionStatusOwnership.matchesLocationcompares all four execution-scope fields (executionHostId,wslDistro,workspaceId,workspaceKind) against the retained subject, so both a forgotten address and a moved address trigger the re-publish path. - Coverage —
structured-agent-session-status-reentry.test.tspins re-admission afterforgetand moving an unchanged projection to a new host scope (asserting the old subject is forgotten exactly once and the new one published).
This addresses the teardown/re-admit ordering hazard directly and reads correctly: the subject is stored in publish before the sink call, so a throwing sink cannot cause a re-publish loop, and a forget that throws retains the subject for a later retry. The new test fails without the fix (parents would stay empty after re-adding the session). Local run of the re-entry, feed, and ownership suites is green.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
d94b0d1 to
c1ac898
Compare
60c3f3c to
53cfb0c
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Reviewed changes
This increment is a rebase of the structured-routing series onto the updated pr2a-2 base (c93a9e09f4/60c3f3c8d3 → 030f435b98/53cfb0c2db). Every file is byte-identical to its previously reviewed version except structured-worker-identity.ts; the canonical ingress, listing, ownership, legacy fencing, child-work lifetime, store hardening, and the re-admit-after-teardown fix are otherwise unchanged code the prior reviews already read.
- Rebased the two-commit series onto base
c1ac898c58, leaving the previously reviewed behavior intact acrossserver-ingest-structured.ts,server-listeners.ts,server-status-update.ts, the ownership/feed wire, and the shared child-work/store files. - Re-applied the
structuredAgentSessionPaneKeycredential guard during conflict resolution intopersistedStructuredWorkerPaneKeyIsValid, where the updated base already carries the identical predicate, producing a duplicate&&term (flagged inline).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
c1ac898 to
f144127
Compare
53cfb0c to
5e07107
Compare
…ip and fence child lifetimes Restacked onto the canonical store and child-work contract. Completing that restack drops the `reopenStructuredParent` mutation flag this change had carried, along with its contract field, its codec branch, and its single call site in structured ingest, which passed a hardcoded `true`. The flag was a narrow escape hatch from the absolute `tombstones.has(...)` rule that governed parent upserts in this branch's original base. The canonical store replaces that rule with a revision envelope, because a bounded store compacts tombstones away and a presence-based guard silently stops fencing once one is evicted. With the envelope deciding the outcome, the escape hatch has nothing left to escape from, so removing it changes no production behaviour. `agent-status-store-reopen.test.ts` is rewritten against the envelope: the reopen case now pins that an unflagged republication succeeds while replay from before the reopen stays fenced even after the parent tombstone is compacted away, and the second case pins where the guard genuinely bites — a republication inside the removing mutation itself, for every subject kind.
…dings - agent-status-store-byte-budget.ts: type the byte-budget helper's record parameter as the union of what its call sites actually pass (the snapshot header plus each store entity record) instead of the broad `object`. - server-structured-canonical-status.test.ts: replace `Reflect.apply` with a typed, explicitly-bound call that models a caller at an untyped boundary omitting the trusted owner subject.
0e13d31 to
93e0273
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — one minor cleanup suggestion inline.
Reviewed changes
This increment restacks the structured-routing series onto the now-merged canonical-store contract (0e13d31087 → 93e0273f8a); the three commits are the same logical changes as the prior review, re-based, with one semantic change.
- Dropped the
reopenStructuredParentescape hatch — the mutation field, its codec branch, and the hardcodedtrueat the structured-ingest call site are gone. The store's revision envelope (upsertParentrejects whentombstone.revision >= revision) already decides parent reopen, andagent-status-store-reopen.test.tswas rewritten to pin the successful reopen and the same-mutation fence for every subject kind. - Adapted to the new base APIs —
getAliasesForChild, binding-key tombstones/queries, the newagentStatusStoreFitsByteBudget, and the extractedresume/stopadmission helpers;agent-status-child-work-stop.tsandagent-status-store-run-index.tsare now taken from the base instead of being carried by the PR. - Carried forward unchanged — the re-admit-after-teardown
matchesLocationfix and the anti-slop lint cleanup.structured-agent-session-status-feed.ts,structured-agent-session-status-ownership.ts,server-listeners.ts, andstructured-worker-identity.tsare byte-identical to the prior reviewed state.
I traced the flag removal myself and it is behavior-preserving: agent-status-store-mutation.ts:145 fences on the tombstone revision, every structured publish allocates snapshot.revision + 1, and no production mutation pairs removeParent with a same-mutation parent. The focused suites (24 tests across reopen/bounds/byte-budget/lifetime/canonical-status/reentry) are green on this head.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
📝 WalkthroughWalkthroughThe pull request adds subject-aware canonical storage for structured agent status. It updates feed ownership, runtime wiring, listener replay, legacy admission, and lifecycle reset behavior. It adds child-work binding codecs, resume handling, alias queries, lifetime fencing, and byte-budget validation. It also updates child freshness projection and related tests. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to Structured status can be missing, retained after teardown, or removed while another valid session remains. These lifecycle and state-lookup risks should be resolved before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the scope, rationale, migration boundary, and deferred work. However, it omits several required template sections, including a Linked Issue entry using "Fixes #", Visual Proof or an explicit N/A reason, Testing details and checkboxes, AI Disclosure, Review, Notes, and the Checklist. Resolution Complete the required template sections. Add the linked issue, provide visual proof or state N/A with a reason, document testing and platforms, complete AI Disclosure when applicable, add Review and Notes content, and mark the relevant Checklist items. Full details: Docstring CoverageExplanation Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 44 functions across 51 files. (4 skipped: 1 unsupported, 3 over the file limit.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Warning Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🟠 Major · Update getAlias for binding-keyed storage.
src/shared/agent-status-store.ts:93-94
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftUpdate
getAliasfor binding-keyed storage.
state.aliasesnow uses binding keys, butgetAliasstill computes an alias key. These encodings have different prefixes, so this method returnsnullfor every stored alias.Replace this API with a set-valued lookup, or scan for the requested alias identity and define how ambiguity is reported.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 753ee200-13a6-4204-a8a7-cb6dd8277e96
📒 Files selected for processing (56)
docs/reference/agent-status-canonical-boundary.mddocs/reference/agent-status-store.mdsrc/main/agent-hooks/first-work-branch-rename.test.tssrc/main/agent-hooks/server-ingest-structured-status.test.tssrc/main/agent-hooks/server-structured-canonical-status.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/server/server-ingest-structured.tssrc/main/agent-hooks/server/server-lifecycle.tssrc/main/agent-hooks/server/server-listeners.tssrc/main/agent-hooks/server/server-state.tssrc/main/agent-hooks/server/server-status-inference.tssrc/main/agent-hooks/server/server-status-retries.tssrc/main/agent-hooks/server/server-status-update.tssrc/main/agent-hooks/server/server-structured-status-row.tssrc/main/native-chat/agent-session-wire/structured-agent-session-forget-status.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed-test-session.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-ownership.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-ownership.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-reentry.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-subscribers.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-surface-lifetime.test.tssrc/main/orcad/orcad-entry.tssrc/main/runtime/orca-runtime-tests/worktree-ps-structured-host.spec.tssrc/main/runtime/rpc/methods/structured-agent-session-rpc.test-fixture.tssrc/main/runtime/runtime-worktree-agent-rows-structured.test.tssrc/main/runtime/runtime-worktree-structured-agent-rows-liveness.test.tssrc/main/runtime/structured-worker-identity.test.tssrc/main/runtime/structured-worker-identity.tssrc/main/startup/main-process-runtime-service.tssrc/relay/agent-status-store-relay-context.test.tssrc/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.test.tsxsrc/renderer/src/components/sidebar/useWorktreeAgentRows.test.tssrc/renderer/src/components/sidebar/worktree-subagent-child-rows.test.tssrc/renderer/src/components/sidebar/worktree-subagent-child-rows.tssrc/shared/agent-hook-listener/listener-state.tssrc/shared/agent-status-child-work-admission-core.tssrc/shared/agent-status-child-work-admission-operations.tssrc/shared/agent-status-child-work-admission.tssrc/shared/agent-status-child-work-binding.tssrc/shared/agent-status-child-work-freshness.tssrc/shared/agent-status-child-work-lifetime.test.tssrc/shared/agent-status-child-work-projection.test.tssrc/shared/agent-status-child-work-resume.tssrc/shared/agent-status-legacy-adapter.test.tssrc/shared/agent-status-legacy-adapter.tssrc/shared/agent-status-store-byte-budget.test.tssrc/shared/agent-status-store-byte-budget.tssrc/shared/agent-status-store-child-queries.tssrc/shared/agent-status-store-codec.tssrc/shared/agent-status-store-mutation.tssrc/shared/agent-status-store-persistence.tssrc/shared/agent-status-store-reopen.test.tssrc/shared/agent-status-store-state.tssrc/shared/agent-status-store.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| this.subjects.set(summary.sessionId, subject) | ||
| sink.publish(summary, subject) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,110p' src/main/native-chat/agent-session-wire/structured-agent-session-status-ownership.ts
sed -n '130,290p' src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.ts
rg -n "matchesLocation|published|publish.*catch|sink\\(" src/main/native-chat/agent-session-wire/structured-agent-session-status-*.tsRepository: stablyai/orca
Length of output: 12604
🏁 Script executed:
rg -n -C 8 "StructuredAgentSessionStatusSink|dropStructuredStatus|structured status|structured-session|status.*publish" src/main src/sharedRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
rg -n -C 12 "new StructuredAgentSessionStatusFeed|StructuredAgentSessionStatusSink|dropStructuredStatus|structuredAgentSessionStatus" src/main src/sharedRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
rg -n -C 20 "ingestStructuredStatus|dropStructuredStatus" src/main/agent-hooks src/mainRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
sed -n '17,125p' src/main/agent-hooks/server/server-ingest-structured.tsRepository: stablyai/orca
Length of output: 4587
Keep failed status publications eligible for retry.
StructuredAgentSessionStatusFeed.sink() catches errors from AgentHookServer.ingestStructuredStatus(). That method commits the canonical row through canonicalStatusStore.applyMutation(). If it throws before the commit, the feed has already stored the summary and ownership has already stored the subject. The next unchanged publication sees matchesLocation(...) === true, and no pending or error state forces another publish. The canonical row can remain absent until another path causes a new sink call.
Track pending publication in StructuredAgentSessionStatusOwnership. Make matchesLocation() return false while publication is pending, and clear the pending state only after sink.publish() succeeds.
| if (!subject) { | ||
| return | ||
| } | ||
| this.sink()?.forget(subject) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n "new StructuredAgentSessionStatusFeed|StructuredAgentSessionClientDelivery|forgetStatus|closeSession|\\.close\\(|dropStructuredStatus|ownerEpoch|owner.*generation" src/main
sed -n '1,120p' src/main/native-chat/agent-session-wire/structured-agent-session-status-ownership.tsRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
set -eu
printf '%s\n' '--- ownership ---'
sed -n '1,140p' src/main/native-chat/agent-session-wire/structured-agent-session-status-ownership.ts
printf '%s\n' '--- feed ---'
sed -n '1,230p' src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.ts
printf '%s\n' '--- client delivery ---'
sed -n '1,130p' src/main/native-chat/agent-session-wire/structured-agent-session-client-delivery.ts
printf '%s\n' '--- host lifetime ---'
sed -n '1,180p' src/main/native-chat/agent-session-wire/structured-agent-session-host-lifetime.ts
printf '%s\n' '--- host construction/use ---'
sed -n '1,230p' src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
printf '%s\n' '--- feed construction sites ---'
rg -n -C 5 'StructuredAgentSessionStatusFeed|new StructuredAgentSessionStatusFeed|StructuredAgentSessionStatusOwnership|new StructuredAgentSessionStatusOwnership' src/main/native-chat src/main/orcad src/main/runtime
printf '%s\n' '--- sink wiring and implementation ---'
rg -n -C 8 'dropStructuredStatus|publish:.*structured|forget:.*structured|StructuredAgentSessionStatusSink|structured status' src/main/orcad src/main/native-chat src/main/agent-hooks src/main/runtimeRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
set -eu
printf '%s\n' '--- remaining feed publish/close section ---'
sed -n '190,380p' src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.ts
printf '%s\n' '--- host teardown ---'
sed -n '1,240p' src/main/native-chat/agent-session-wire/structured-agent-session-host-teardown.ts
printf '%s\n' '--- host construction sites ---'
rg -n -C 8 'new StructuredAgentSessionHost|StructuredAgentSessionHost\\(' src/main --glob '*.ts' --glob '!*.test.ts'
printf '%s\n' '--- status sink wiring ---'
rg -n -C 10 'dropStructuredStatus|ingestStructuredStatus|StructuredAgentSessionStatusSink|statusSink' src/main/orcad src/main/agent-hooks src/main/native-chat --glob '*.ts' --glob '!*.test.ts'
printf '%s\n' '--- canonical store implementation ---'
rg -n -C 10 'dropStructuredStatus|ingestStructuredStatus|structuredStatus|StructuredStatus' src/main/agent-hooks/server src/shared --glob '*.ts' --glob '!*.test.ts'
printf '%s\n' '--- host lifetime call sites ---'
rg -n -C 8 'forgetStatus\\(|clientDelivery\\.closeSession|statusFeed\\.close|evictHeldStructuredAgentSession' src/main/native-chat --glob '*.ts' --glob '!*.test.ts'Repository: stablyai/orca
Length of output: 9626
🏁 Script executed:
set -eu
printf '%s\n' '--- non-test host construction sites ---'
rg -n -F -C 8 'new StructuredAgentSessionHost' src/main --glob '*.ts' --glob '!*.test.ts'
printf '%s\n' '--- status sink wiring ---'
rg -n -F -C 10 'dropStructuredStatus' src/main/orcad src/main/agent-hooks src/main/native-chat --glob '*.ts' --glob '!*.test.ts'
rg -n -F -C 10 'ingestStructuredStatus' src/main/agent-hooks src/main/orcad src/main/native-chat --glob '*.ts' --glob '!*.test.ts'
printf '%s\n' '--- canonical status implementation ---'
fd -i 'agent-hook-server' src/main
rg -n -F -C 12 'structuredStatus' src/main/agent-hooks src/main/orcad --glob '*.ts' --glob '!*.test.ts'
printf '%s\n' '--- relevant host lifecycle callers ---'
rg -n -F -C 8 'tearDownStructuredAgentSessionHost' src/main/native-chat --glob '*.ts' --glob '!*.test.ts'
rg -n -F -C 8 'StructuredAgentSessionHost' src/main/native-chat --glob '*.ts' --glob '!*.test.ts' | head -240Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
set -eu
printf '%s\n' '--- canonical store bindings ---'
rg -n -F -C 12 'canonicalStatusStore' src/main/agent-hooks src/main/shared src/shared --glob '*.ts' --glob '!*.test.ts'
printf '%s\n' '--- applyMutation definitions ---'
rg -n -F -C 18 'applyMutation' src/main/agent-hooks src/shared --glob '*.ts' --glob '!*.test.ts'
printf '%s\n' '--- runtime factory and lifecycle ---'
rg -n -F -C 12 'createStructuredAgentSessionRuntime' src/main --glob '*.ts' --glob '!*.test.ts'
rg -n -F -C 12 'installStructuredAgentSessionRuntime' src/main --glob '*.ts' --glob '!*.test.ts'
rg -n -F -C 12 'flushAllStreamedEvents' src/main/runtime src/main/native-chat --glob '*.ts' --glob '!*.test.ts'
printf '%s\n' '--- runtime construction references ---'
rg -n -F -C 8 'structuredAgentSessionRuntime' src/main --glob '*.ts' --glob '!*.test.ts' | head -240Repository: stablyai/orca
Length of output: 18892
🏁 Script executed:
set -eu
printf '%s\n' '--- agent status store ---'
sed -n '1,240p' src/shared/agent-status-store.ts
printf '%s\n' '--- runtime module outline and construction ---'
rg -n '^(export )?(async )?(function|class|const) |new StructuredAgentSessionHost|host =|close|shutdown|dispose' src/main/runtime/structured-agent-session-runtime.ts
sed -n '240,390p' src/main/runtime/structured-agent-session-runtime.ts
printf '%s\n' '--- runtime callers and singleton bindings ---'
rg -n -F -C 10 'structured-agent-session-runtime' src/main --glob '*.ts' --glob '!*.test.ts'
rg -n -F -C 10 'createStructuredAgentSessionRuntime' src/main --glob '*.ts' --glob '!*.test.ts'Repository: stablyai/orca
Length of output: 21572
🏁 Script executed:
set -eu
printf '%s\n' '--- runtime ensure/stop/teardown ---'
sed -n '100,235p' src/main/runtime/structured-agent-session-runtime.ts
printf '%s\n' '--- mutation removal branch ---'
rg -n -F -C 18 'removeParent' src/shared/agent-status-store-mutation.tsRepository: stablyai/orca
Length of output: 9981
🏁 Script executed:
set -eu
printf '%s\n' '--- runtime install completion and restore calls ---'
sed -n '1,115p' src/main/runtime/structured-agent-session-runtime.ts
sed -n '300,430p' src/main/runtime/structured-agent-session-runtime.ts
printf '%s\n' '--- record store open/close contract ---'
rg -n -F -C 12 'static async open' src/main/native-chat/agent-session-record-store.ts src/main --glob '*record-store*.ts'
rg -n -F -C 10 'class AgentSessionRecordStore' src/main/native-chat src/main --glob '*.ts' | head -100
printf '%s\n' '--- lease release and attach publication boundary ---'
rg -n -F -C 14 'releaseStoredStructuredAgentSessionOwner' src/main/native-chat/agent-session-wire --glob '*.ts'
rg -n -F -C 12 'publishStatus' src/main/native-chat/agent-session-wire/structured-agent-session-attach-orchestration.ts src/main/native-chat/agent-session-wire/structured-agent-session-attach.ts --glob '*.ts'Repository: stablyai/orca
Length of output: 12044
🏁 Script executed:
set -eu
printf '%s\n' '--- record store load and transaction initialization ---'
rg -n -F -C 14 'loadProtectedAgentSessionStore' src/main/runtime --glob '*.ts'
rg -n -F -C 14 'fromLoadedStore' src/main/runtime/agent-session-store-transaction-queue.ts
printf '%s\n' '--- concrete ensure caller ---'
sed -n '1,90p' src/main/runtime/orca-runtime-get-worktree-ps.ts
printf '%s\n' '--- attach publication path ---'
rg -n -F -C 18 'publishStatus(sessionId' src/main/native-chat/agent-session-wire --glob '*.ts'Repository: stablyai/orca
Length of output: 12342
Fence status cleanup to the current owner.
stopStructuredAgentSessionRuntime() clears the installation slot before awaiting the old runtime teardown, so ensureStructuredAgentSessionHost() can create a new feed while the old feed still retains its subject. The new feed can publish the same persisted session and subject before the old feed calls forget(). dropStructuredStatus() then removes the current row for that exact subject without checking an owner generation or expected revision. The old feed can therefore delete the newer row.
Pass an owner generation or publication token through publish and forget, and remove the canonical row only when that token still owns it.
| this.sink()?.forget(subject) | ||
| this.subjects.delete(sessionId) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Retain the subject when the sink is unavailable.
If this.sink() returns undefined, Line 64 performs no cleanup. Line 65 still deletes the retained subject. A later retry cannot identify the canonical row, so teardown can leave stale status permanently.
Resolve the sink first. Delete the subject only after sink.forget(subject) completes.
Proposed fix
forget(sessionId: string): void {
const subject = this.subjects.get(sessionId)
if (!subject) {
return
}
- this.sink()?.forget(subject)
+ const sink = this.sink()
+ if (!sink) {
+ return
+ }
+ sink.forget(subject)
this.subjects.delete(sessionId)
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| this.sink()?.forget(subject) | |
| this.subjects.delete(sessionId) | |
| const sink = this.sink() | |
| if (!sink) { | |
| return | |
| } | |
| sink.forget(subject) | |
| this.subjects.delete(sessionId) |
| const alias = deserializeAgentChildWorkBindingKey(tombstone.key) | ||
| if (alias && keys.has(serializeAgentChildWorkAliasKey(alias))) { | ||
| matches.push(deepFreezeAgentStatusStoreValue({ ...alias, revision: tombstone.revision })) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
rg -n "compactTombstones|tombstones|resolveChildAliases|resolveAgentStatusChildBindings|deleted children|retired" src/shared/agent-status-store* src/shared/agent-status-child-work*
sed -n '1,220p' src/shared/agent-status-store-child-queries.ts
sed -n '1,240p' src/shared/agent-status-child-work-lifetime.test.tsRepository: stablyai/orca
Length of output: 15798
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- mutation compaction and mutation paths ---'
sed -n '1,310p' src/shared/agent-status-store-mutation.ts
printf '%s\n' '--- admission core ---'
sed -n '1,240p' src/shared/agent-status-child-work-admission-core.ts
printf '%s\n' '--- store state invariants and snapshot restore ---'
sed -n '110,285p' src/shared/agent-status-store-state.ts
printf '%s\n' '--- tombstone-limit and reopen tests ---'
sed -n '220,320p' src/shared/agent-status-store.test.ts
sed -n '1,100p' src/shared/agent-status-store-reopen.test.tsRepository: stablyai/orca
Length of output: 27675
🏁 Script executed:
set -eu
sed -n '1,310p' src/shared/agent-status-store-mutation.ts
sed -n '1,240p' src/shared/agent-status-child-work-admission-core.ts
sed -n '110,285p' src/shared/agent-status-store-state.ts
sed -n '220,320p' src/shared/agent-status-store.test.ts
sed -n '1,100p' src/shared/agent-status-store-reopen.test.tsRepository: stablyai/orca
Length of output: 27512
🏁 Script executed:
set -eu
rg -n "resolveAgentChildWorkAliasRecords|resolveChildAliases|mintChildWorkId|created: true|buildAgentChildWorkAliases|announce\\(" src/shared/agent-status-child-work-admission.ts src/shared/agent-status-child-work-admission-*.ts
sed -n '1,320p' src/shared/agent-status-child-work-admission.tsRepository: stablyai/orca
Length of output: 6967
🏁 Script executed:
set -eu
sed -n '1,125p' src/shared/agent-status-child-work-admission-operations.tsRepository: stablyai/orca
Length of output: 4468
Keep deleted lifetime fences after tombstone compaction.
removeChild creates both child and alias tombstones. compactTombstones can remove both when the tombstone limit overflows. After snapshot restore, resolveAgentStatusChildBindings then finds no binding. announceAgentChildWork treats the empty result as a new child and can mint a replacement for the delayed observation.
Keep a compact durable fence for retired bindings, and add a regression test that deletes a child, forces tombstone compaction, restarts the store, and replays the old observation.
| item.revision > state.revision || | ||
| (item.entity === 'parent' && !deserializeAgentStatusSubject(item.key)) || | ||
| (item.entity === 'alias' && !deserializeAgentChildWorkAliasKey(item.key)) || | ||
| (item.entity === 'alias' && !deserializeAgentChildWorkBindingKey(item.key)) || |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
rg -n "AGENT_STATUS_STORE_SNAPSHOT_VERSION|snapshotVersion|schemaVersion|agent-status.*snapshot|last-status|applySnapshot|stateFromSnapshot|alias tombstone|serializeAgentChildWorkAliasKey" src docs
sed -n '1,260p' src/shared/agent-status-store-state.ts
sed -n '1,180p' src/shared/agent-status-store-persistence.tsRepository: stablyai/orca
Length of output: 50372
🏁 Script executed:
set -u
printf '%s\n' '--- focused files ---'
wc -l src/shared/agent-status-store-state.ts src/shared/agent-status-store-persistence.ts src/shared/agent-status-store-contract.ts 2>/dev/null || true
sed -n '1,280p' src/shared/agent-status-store-state.ts
printf '%s\n' '--- persistence ---'
sed -n '1,240p' src/shared/agent-status-store-persistence.ts
printf '%s\n' '--- contract ---'
sed -n '1,180p' src/shared/agent-status-store-contract.ts
printf '%s\n' '--- relevant repository references ---'
rg -n --glob '!src/cli/bundled-skill-guides.ts' --glob '!**/*.map' \
'AGENT_STATUS_STORE_SNAPSHOT_VERSION|agentStatusStoreStateFromSnapshot|serializeAgentChildWorkAliasKey|deserializeAgentChildWorkBindingKey|serializeAgentChildWorkBindingKey|tombstone' \
src/shared docs README.md package.json 2>/dev/null | head -n 300
printf '%s\n' '--- focused diff ---'
git diff -- src/shared/agent-status-store-state.ts src/shared/agent-status-store-persistence.ts src/shared/agent-status-store-contract.ts src/shared | head -n 500Repository: stablyai/orca
Length of output: 34864
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/architecture /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions
Length of output: 47429
🏁 Script executed:
set -u
printf '%s\n' '--- alias and binding encodings ---'
sed -n '1,240p' src/shared/agent-status-child-work-alias.ts
sed -n '1,120p' src/shared/agent-status-child-work-binding.ts
printf '%s\n' '--- snapshot codec ---'
sed -n '1,330p' src/shared/agent-status-store-codec.ts
printf '%s\n' '--- store snapshot and replica callers ---'
sed -n '1,220p' src/shared/agent-status-store.ts
printf '%s\n' '--- mutation tombstone handling ---'
sed -n '1,280p' src/shared/agent-status-store-mutation.ts
printf '%s\n' '--- focused tests and compatibility references ---'
rg -n -C 5 --glob 'src/shared/agent-status-store*.test.ts' --glob 'src/shared/agent-status-child-work*.test.ts' \
'snapshot|tombstone|alias|legacy|version|replica|restore|reopen' src/shared
printf '%s\n' '--- recent revision and parent comparison ---'
git log -1 --oneline --decorate
parent="$(git rev-parse HEAD^ 2>/dev/null || true)"
printf 'parent=%s\n' "$parent"
if [ -n "$parent" ]; then
git show "$parent:src/shared/agent-status-store-state.ts" 2>/dev/null | sed -n '1,280p'
printf '%s\n' '--- parent binding file ---'
git show "$parent:src/shared/agent-status-child-work-binding.ts" 2>/dev/null | sed -n '1,120p'
printf '%s\n' '--- parent mutation alias paths ---'
git show "$parent:src/shared/agent-status-store-mutation.ts" 2>/dev/null | sed -n '100,270p'
fiRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
set -u
log=/tmp/coderabbit-shell-logs/shell-output-fShZYV
printf '%s\n' '--- omitted history section from prior result ---'
rg -n -A 180 -B 5 -- '--- recent revision and parent comparison ---|^parent=' "$log" | head -n 400
printf '%s\n' '--- concise history ---'
git log -4 --oneline --decorate -- src/shared/agent-status-child-work-binding.ts src/shared/agent-status-store-state.ts src/shared/agent-status-store-mutation.ts src/shared/agent-status-store-contract.ts
printf '%s\n' '--- current and parent binding signatures ---'
parent="$(git rev-parse HEAD^ 2>/dev/null || true)"
printf 'parent=%s\n' "$parent"
if [ -n "$parent" ]; then
printf '%s\n' 'parent binding:'
git show "$parent:src/shared/agent-status-child-work-binding.ts" 2>/dev/null | sed -n '1,100p'
printf '%s\n' 'parent state tombstone/alias lines:'
git show "$parent:src/shared/agent-status-store-state.ts" 2>/dev/null | rg -n -C 4 \
'serializeAgentChildWork|deserializeAgentChildWork|item.entity|tombstone|SNAPSHOT_VERSION' | head -n 180
printf '%s\n' 'parent mutation alias/tombstone lines:'
git show "$parent:src/shared/agent-status-store-mutation.ts" 2>/dev/null | rg -n -C 4 \
'serializeAgentChildWork|deserializeAgentChildWork|removeAlias|tombstone' | head -n 180
printf '%s\n' 'parent contract version:'
git show "$parent:src/shared/agent-status-store-contract.ts" 2>/dev/null | rg -n -C 3 \
'SNAPSHOT_VERSION|Tombstone|Snapshot'
fiRepository: stablyai/orca
Length of output: 21913
🏁 Script executed:
set -u
printf '%s\n' '--- introducing commit metadata ---'
git show --stat --oneline 8ef5feb112
printf '%s\n' '--- introducing commit relevant diff ---'
git diff 8ef5feb112^ 8ef5feb112 -- \
src/shared/agent-status-child-work-binding.ts \
src/shared/agent-status-store-state.ts \
src/shared/agent-status-store-mutation.ts \
src/shared/agent-status-store-contract.ts \
src/shared/agent-status-store-codec.ts \
src/shared/agent-status-store.ts | head -n 500
printf '%s\n' '--- pre-transition state and mutation ---'
git show 8ef5feb112^:src/shared/agent-status-store-state.ts 2>/dev/null | rg -n -C 8 \
'serializeAgentChildWork|deserializeAgentChildWork|item.entity|tombstone|SNAPSHOT_VERSION' | head -n 240
git show 8ef5feb112^:src/shared/agent-status-store-mutation.ts 2>/dev/null | rg -n -C 8 \
'serializeAgentChildWork|deserializeAgentChildWork|removeAlias|tombstone' | head -n 240
printf '%s\n' '--- pre-transition contract and codec version ---'
git show 8ef5feb112^:src/shared/agent-status-store-contract.ts 2>/dev/null | rg -n -C 4 \
'SNAPSHOT_VERSION|Tombstone|Snapshot'
git show 8ef5feb112^:src/shared/agent-status-store-codec.ts 2>/dev/null | rg -n -C 5 \
'SNAPSHOT_VERSION|tombstone'
printf '%s\n' '--- initial store commit aliases/tombstones ---'
git show 0325f1a22e:src/shared/agent-status-store-mutation.ts 2>/dev/null | rg -n -C 5 \
'serializeAgentChildWork|deserializeAgentChildWork|removeAlias|tombstone' | head -n 180Repository: stablyai/orca
Length of output: 36992
🏁 Script executed:
set -u
printf '%s\n' '--- store documentation ---'
for f in docs/reference/agent-status-store.md docs/reference/agent-status-canonical-boundary.md; do
if [ -f "$f" ]; then
printf '%s\n' "--- $f ---"
rg -n -C 5 'snapshot|persist|replica|version|tombstone|compatib|migration' "$f" | head -n 240
fi
done
printf '%s\n' '--- persistence and transport call sites ---'
rg -n -C 5 --glob '!src/cli/bundled-skill-guides.ts' \
'serializeAgentStatusStoreSnapshot|deserializeAgentStatusStoreSnapshot|applySnapshot|applyTransportEnvelope|type: .snapshot.|snapshot:' \
src/main src/relay src/shared docs | head -n 360
printf '%s\n' '--- reopen and transport tests ---'
sed -n '1,140p' src/shared/agent-status-store-reopen.test.ts
sed -n '1,180p' src/shared/agent-status-transport-envelope.ts
rg -n -C 4 'applySnapshot|snapshot|replica|transport' src/shared/agent-status-store*.test.ts src/shared/agent-status-transport-envelope*.ts | head -n 300Repository: stablyai/orca
Length of output: 50369
Preserve version-1 snapshot compatibility. The binding-key transition kept AGENT_STATUS_STORE_SNAPSHOT_VERSION at 1, although the previous implementation wrote alias-only keys into alias tombstones. Current agentStatusStoreStateFromSnapshot accepts the snapshot version, then validateAgentStatusStoreState rejects those tombstones because it only parses binding keys. A persisted snapshot or replica snapshot can therefore fail restoration.
If version 1 remains supported, add a compatibility reader for the legacy tombstone shape before current validation. Otherwise, bump the snapshot version and reject the old format explicitly.
docs/reference/ holds implementation detail, not rollout progress. The canonical-boundary notes move to the effort's working directory; the agent-status-store status section keeps the boundary statement and loses the now-dangling link.
There was a problem hiding this comment.
🟡 Minor · Align getAlias with the binding index.
src/shared/agent-status-store.ts:93-94
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAlign
getAliaswith the binding index.AgentStatusStore.getAliasacceptsAgentChildWorkAliasIdentity, which omits the child-work ID and fence, butupsertAliasesstores records underserializeAgentChildWorkBindingKey. The lookup therefore misses every active alias record and returnsnull. Since one alias can name several bindings, makegetAliasbinding-specific or replace it with the existingresolveChildAliasesAPI.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: f6096f4a-fb5c-483e-bf4a-c111d068a473
📒 Files selected for processing (1)
docs/reference/agent-status-store.md
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/reference/agent-status-store.md
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
…truction The hook server's canonical store was built in an instance-member initializer, so constructing AgentHookServer — which happens at import time for the module singleton — demanded a live randomUUID. Any importer that stubs node:crypto threw 'Invalid agent status store epoch' before a single test ran. The store is now created on first canonical access and reset by dropping it, so construction owes nothing to a crypto implementation and the epoch still rotates per authority incarnation.
There was a problem hiding this comment.
ℹ️ No new issues introduced by this delta.
Reviewed changes
Incremental delta since the prior pullfrog review (69f14ab7ac → 65b9885ccf), one file, one commit:
- Lazy canonical epoch —
AgentHookServerState.canonicalStatusStoreis now a lazy getter overprivate canonicalStatusStoreInstance, so constructing theAgentHookServermodule singleton no longer callsrandomUUID()and owes nothing to a livenode:cryptoimplementation. Any importer that stubsnode:cryptopreviously threwInvalid agent status store epochat import time. - Reset by dropping —
resetCanonicalStatus()now nulls the stored instance instead of eagerly building a replacement, so the epoch still rotates per authority incarnation on the next canonical access.
I verified the fix is behavior-preserving: createAgentStatusStore is the only production store seeded from randomUUID() (every other call site passes a literal epoch), no production call site captures a store reference across resetCanonicalStatus(), and the motivating suite — ssh-relay-session-reconnect-incarnation.test.ts, which mocks randomUUID to return undefined while transitively importing the singleton via ssh-relay-session.ts — now passes (15/15), with pnpm tc:node clean. This review is non-approving only because two earlier Pullfrog inline threads remain open and are untouched by this commit.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
… pane guard Two leftovers from the canonical-store routing change: agent-status-store-snapshot-budget.ts lost its only caller when the store state switched to agentStatusStoreFitsByteBudget. Nothing in the repo imports it now, so the module goes with the caller it existed for. The replacement is not a straight copy: it only memoises a record's measured size once the record is frozen, so a still-mutable record can no longer return a stale byte count. persistedStructuredWorkerPaneKeyIsValid repeated its public-pane-key rejection verbatim three lines below the first one. The tests covering that rejection pass on the first occurrence alone, so the second decided nothing and only obscured which predicate was load-bearing.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Incremental delta since the prior pullfrog review (65b9885ccf → 0f5db831a0), one commit that only removes code:
- Removed a duplicated credential guard —
persistedStructuredWorkerPaneKeyIsValidno longer evaluatespaneKey !== structuredAgentSessionPaneKey(...)twice, andparsed.tabId/isTerminalLeafIdare unchanged, so the rejection of the public status pane key is preserved. With the duplicate gone,structured-worker-identity.tsis byte-identical to its base version and drops out of the PR diff. - Deleted the orphaned snapshot budget —
agent-status-store-snapshot-budget.ts, unreferenced since this PR movedvalidateAgentStatusStoreStateontoagentStatusStoreFitsByteBudget, is removed, leaving a single byte-budget implementation.
Both changes retire the two prior Pullfrog inline threads (now resolved); no behavioral surface is introduced. Focused suites green (structured-worker-identity 17 tests, agent-status-store-byte-budget 2 tests) and pnpm tc:node clean.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…owned Three defects found reviewing the structured routing path. combinedStatusEntries defaulted a missing listing order to 0, but the counter it compares against starts at 1, so any unordered row sorted above every ordered one. Unknown order now sorts last. The owner map recorded a session as owned before the sink ran. A publish that threw therefore left matchesLocation reporting an owned location for a row that was never written, and the unchanged-projection path — the only thing that would re-offer it — stopped. The address still has to survive a throw so teardown can forget a row that did land, so the two facts are now separate: the address is recorded up front, and only a publish that returned marks the row as landed. The reopen test claimed the revision envelope rather than the tombstone fences a stale replay. It cannot tell: transport consecutiveness, the parent-revision validator and the tombstone guard each refuse that replay alone, and ablating any two leaves the test green. It now asserts the outcome and says so.
# Conflicts: # src/shared/agent-status-store-snapshot-budget.ts
Merge-gate review — verified at
|
| Gate | Result |
|---|---|
pnpm tc |
only main's pre-existing TS6196; no other error |
pnpm run audit:anti-slop |
exit 0 |
pnpm run check:code-quality:changed |
0 new findings across 53 files |
npx oxfmt --check (6 touched files) |
clean, re-run after commit |
src/shared/agent-status |
245 passed, 1 expected fail |
src/main/agent-hooks/ |
88 files, 918 passed, 9 skipped |
| ssh agent-hooks integration | 10/10 |
| native-chat + ssh + identity | 616 passed |
Merged origin/main rather than rebasing; merge commit verified to have two parents.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Incremental delta since the prior pullfrog review (0f5db831a0 → 6185d0623b), two commits:
- A failed structured publish no longer latches as owned —
StructuredAgentSessionStatusOwnershipnow tracks a separatelandedset beside the retained address: the address is still recorded before the sink runs so teardown canforgeta row that did land, but only a publish that returned marks it landed, somatchesLocationno longer suppresses the feed's unchanged-projection re-offer after a throw. The added test fails against the prior code (matchesLocationreturnedtrueafter the throwing publish). - An unordered listing row now sorts last —
combinedStatusEntries()defaulted a missing listing order to0, but the shared counter starts at1, so such a row sorted above every ordered one; the legacy and canonical defaults now share aNumber.MAX_SAFE_INTEGERsentinel. - Reopen test asserts outcomes only —
agent-status-store-reopen.test.tsno longer claims the revision envelope (rather than the tombstone) fences a stale replay; it verifies the spent replay is refused and a resequenced one is accepted, with a comment recording that transport consecutiveness, the parent-revision validator, and the tombstone guard each refuse it independently. - Merged
origin/main— the base-side merge diff touches no PR file, so no conflict resolution was carried; the sync brought unrelated native-chat changes (structured-agent-session-host-handoff.ts,journal-store.ts,structured-agent-session-turns.ts) with no overlap.
Both prior Pullfrog inline threads are resolved and untouched by this delta. Focused suites (structured-agent-session-status-ownership 5, agent-status-store-reopen 2, server-structured-canonical-status 8) are green and pnpm tc:node is clean.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/shared/agent-status-legacy-adapter.test.ts (1)
36-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExercise the canonical-pane-key rejection branch.
canonicalPaneKeysis empty here. This input can be rejected only because it hasstructuredHost. Add a separate case that inserts'structured-pane'intocanonicalPaneKeysand admits a non-structured payload. The current assertion cannot detect a regression inisCanonicalPaneKey.Based on learnings: a negative result alone does not show that the intended conditional branch ran.
Source: Learnings
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: e2339122-00f6-4165-9206-153b6dc81274
📒 Files selected for processing (55)
docs/reference/agent-status-store.mdsrc/main/agent-hooks/first-work-branch-rename.test.tssrc/main/agent-hooks/server-ingest-structured-status.test.tssrc/main/agent-hooks/server-structured-canonical-status.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/server/server-ingest-structured.tssrc/main/agent-hooks/server/server-lifecycle.tssrc/main/agent-hooks/server/server-listeners.tssrc/main/agent-hooks/server/server-state.tssrc/main/agent-hooks/server/server-status-inference.tssrc/main/agent-hooks/server/server-status-retries.tssrc/main/agent-hooks/server/server-status-update.tssrc/main/agent-hooks/server/server-structured-status-row.tssrc/main/native-chat/agent-session-wire/structured-agent-session-forget-status.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed-test-session.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-ownership.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-ownership.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-reentry.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-subscribers.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-surface-lifetime.test.tssrc/main/orcad/orcad-entry.tssrc/main/runtime/orca-runtime-tests/worktree-ps-structured-host.spec.tssrc/main/runtime/rpc/methods/structured-agent-session-rpc.test-fixture.tssrc/main/runtime/runtime-worktree-agent-rows-structured.test.tssrc/main/runtime/runtime-worktree-structured-agent-rows-liveness.test.tssrc/main/runtime/structured-worker-identity.test.tssrc/main/startup/main-process-runtime-service.tssrc/relay/agent-status-store-relay-context.test.tssrc/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.test.tsxsrc/renderer/src/components/sidebar/useWorktreeAgentRows.test.tssrc/renderer/src/components/sidebar/worktree-subagent-child-rows.test.tssrc/renderer/src/components/sidebar/worktree-subagent-child-rows.tssrc/shared/agent-hook-listener/listener-state.tssrc/shared/agent-status-child-work-admission-core.tssrc/shared/agent-status-child-work-admission-operations.tssrc/shared/agent-status-child-work-admission.tssrc/shared/agent-status-child-work-binding.tssrc/shared/agent-status-child-work-freshness.tssrc/shared/agent-status-child-work-lifetime.test.tssrc/shared/agent-status-child-work-projection.test.tssrc/shared/agent-status-child-work-resume.tssrc/shared/agent-status-legacy-adapter.test.tssrc/shared/agent-status-legacy-adapter.tssrc/shared/agent-status-store-byte-budget.test.tssrc/shared/agent-status-store-byte-budget.tssrc/shared/agent-status-store-child-queries.tssrc/shared/agent-status-store-codec.tssrc/shared/agent-status-store-mutation.tssrc/shared/agent-status-store-persistence.tssrc/shared/agent-status-store-reopen.test.tssrc/shared/agent-status-store-snapshot-budget.tssrc/shared/agent-status-store-state.tssrc/shared/agent-status-store.ts
💤 Files with no reviewable changes (1)
- src/shared/agent-status-store-snapshot-budget.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- docs/reference/agent-status-store.md
- src/shared/agent-status-child-work-admission.ts
- src/main/native-chat/agent-session-wire/structured-agent-session-subscribers.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| this.commitStatusRowMutation(structuredStatusLegacyEvent(previous.status), undefined) | ||
| this.notifyStatusChangeListeners() | ||
| this.emitStatusDropped(previous.status.paneKey) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Do not publish a pane deletion while another canonical subject remains.
Different execution scopes can produce the same paneKey for an identical session ID. After this method removes one subject, canonicalSubjectsByPane can still contain another subject for that pane.
The current code still publishes before → undefined and calls emitStatusDropped. Consumers can remove pane or child state even though getStatusSnapshotForPane still returns a surviving canonical row.
If subjects remain, publish the selected surviving row instead. Call emitStatusDropped only when the pane has no remaining subjects.
| parentEvidenceFresh: args.parentIsFresh, | ||
| transportObservation: args.parentEntry.subagentObservation ?? 'live' | ||
| }) | ||
| const state = freshness === 'done' ? 'idle' : freshness === 'monitoring' ? 'working' : freshness |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Preserve the done state.
When resolveAgentChildWorkFreshness returns done, this conversion changes the dashboard row to idle. A completed child then appears idle instead of completed.
Only convert monitoring to working. Add a done case to worktree-subagent-child-rows.test.ts.
Proposed fix
- const state = freshness === 'done' ? 'idle' : freshness === 'monitoring' ? 'working' : freshness
+ const state = freshness === 'monitoring' ? 'working' : freshness📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const state = freshness === 'done' ? 'idle' : freshness === 'monitoring' ? 'working' : freshness | |
| const state = freshness === 'monitoring' ? 'working' : freshness |
| } else if (sourceOrder !== undefined) { | ||
| listingOrderByPaneKey.set(movedKey, sourceOrder) | ||
| } else { | ||
| listingOrderByPaneKey.set(movedKey, nextListingOrder()) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Validate the generated moved-entry order.
move stores nextListingOrder() without the validation used by admit. If the configured callback returns a negative, unsafe, or non-integer value, listingOrder exposes invalid state instead of throwing.
Proposed fix
} else {
- listingOrderByPaneKey.set(movedKey, nextListingOrder())
+ const order = nextListingOrder()
+ if (!Number.isSafeInteger(order) || order < 0) {
+ throw new RangeError(
+ 'Legacy agent-status listing order must be a non-negative safe integer'
+ )
+ }
+ listingOrderByPaneKey.set(movedKey, order)
}| } | ||
| state.aliases.set( | ||
| serializeAgentChildWorkAliasKey(record), | ||
| serializeAgentChildWorkBindingKey(record), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Align getAlias with the binding-key map.
This change stores aliases under serializeAgentChildWorkBindingKey(record). getAlias in src/shared/agent-status-store.ts Line 94 still looks up serializeAgentChildWorkAliasKey(identity). Valid stored aliases therefore return null through the existing API.
Move callers to resolveChildAliases, or change the getAlias contract and lookup to use the binding-key identity.
…ship (stablyai#20718) * feat(agent-status): route structured status through canonical ownership and fence child lifetimes Restacked onto the canonical store and child-work contract. Completing that restack drops the `reopenStructuredParent` mutation flag this change had carried, along with its contract field, its codec branch, and its single call site in structured ingest, which passed a hardcoded `true`. The flag was a narrow escape hatch from the absolute `tombstones.has(...)` rule that governed parent upserts in this branch's original base. The canonical store replaces that rule with a revision envelope, because a bounded store compacts tombstones away and a presence-based guard silently stops fencing once one is evicted. With the envelope deciding the outcome, the escape hatch has nothing left to escape from, so removing it changes no production behaviour. `agent-status-store-reopen.test.ts` is rewritten against the envelope: the reopen case now pins that an unflagged republication succeeds while replay from before the reopen stays fenced even after the parent tombstone is compacted away, and the second case pins where the guard genuinely bites — a republication inside the removing mutation itself, for every subject kind. * fix(agent-status): re-admit unchanged structured owners after teardown * fix(agent-status): clear anti-slop object-param and Reflect.apply findings - agent-status-store-byte-budget.ts: type the byte-budget helper's record parameter as the union of what its call sites actually pass (the snapshot header plus each store entity record) instead of the broad `object`. - server-structured-canonical-status.test.ts: replace `Reflect.apply` with a typed, explicitly-bound call that models a caller at an untyped boundary omitting the trusted owner subject. * docs(agent-status): drop the 2A progress doc from docs/reference docs/reference/ holds implementation detail, not rollout progress. The canonical-boundary notes move to the effort's working directory; the agent-status-store status section keeps the boundary statement and loses the now-dangling link. * fix(agent-status): mint the canonical epoch on first use, not at construction The hook server's canonical store was built in an instance-member initializer, so constructing AgentHookServer — which happens at import time for the module singleton — demanded a live randomUUID. Any importer that stubs node:crypto threw 'Invalid agent status store epoch' before a single test ran. The store is now created on first canonical access and reset by dropping it, so construction owes nothing to a crypto implementation and the epoch still rotates per authority incarnation. * fix(agent-status): drop the orphaned snapshot budget and a duplicated pane guard Two leftovers from the canonical-store routing change: agent-status-store-snapshot-budget.ts lost its only caller when the store state switched to agentStatusStoreFitsByteBudget. Nothing in the repo imports it now, so the module goes with the caller it existed for. The replacement is not a straight copy: it only memoises a record's measured size once the record is frozen, so a still-mutable record can no longer return a stale byte count. persistedStructuredWorkerPaneKeyIsValid repeated its public-pane-key rejection verbatim three lines below the first one. The tests covering that rejection pass on the first occurrence alone, so the second decided nothing and only obscured which predicate was load-bearing. * fix(agent-status): stop a failed structured publish from latching as owned Three defects found reviewing the structured routing path. combinedStatusEntries defaulted a missing listing order to 0, but the counter it compares against starts at 1, so any unordered row sorted above every ordered one. Unknown order now sorts last. The owner map recorded a session as owned before the sink ran. A publish that threw therefore left matchesLocation reporting an owned location for a row that was never written, and the unchanged-projection path — the only thing that would re-offer it — stopped. The address still has to survive a throw so teardown can forget a row that did land, so the two facts are now separate: the address is recorded up front, and only a publish that returned marks the row as landed. The reopen test claimed the revision envelope rather than the tombstone fences a stale replay. It cannot tell: transport consecutiveness, the parent-revision validator and the tombstone guard each refuse that replay alone, and ablating any two leaves the test green. It now asserts the outcome and says so.

ELI5
Makes it live for native chat. Structured (native-chat) sessions now publish, revoke and forget
through the canonical store, and their child rows get fenced lifetimes. CLI/PTY agents keep their
producer and their row order, but the mechanism behind that order does change: legacy and
canonical rows are now merged into one list sorted by a shared counter both draw from, where the
legacy side previously relied on map insertion order alone. A regression there would surface through
shared-bounded-status-cache,relay-status-cache, ormain-pane-alias-transfer— look at thoserather than taking "untouched" on trust.
Why only native chat
The original plan for this stage said "key everything by scoped subject." Implementation proved that
impossible and stopped rather than fudging it: the hook payload carries no execution host, WSL distro
or workspace kind anywhere, the structured sink carries only a workspace id, and relay ownership is
pane-keyed — while the subject type requires all four scope fields. Satisfying it literally would have
meant fabricating scope for PTY and relay evidence.
So the line moved to where trusted scope actually exists today: structured sessions already carry
their full owner location, so they migrate for real now; PTY/relay evidence waits for the PR that
binds it properly. All three reviewing seats signed that amended boundary.
The part that keeps this honest
The legacy adapter is temporary, and "temporary" needs a forcing function rather than an intention.
The required-suite ratchet over the legacy allowlist landed with #20717 — required-suite
specifically, because an e2e-only guard gates nothing in this repo — and it governs this PR rather
than being carried by it. The allowlist must be empty before the next stage can complete, and its
removal is proven by ablation rather than by disuse.
What this PR adds to that boundary is the admission guard itself: a payload carrying
structuredHostcan no longer enter the legacy adapter at all, so the canonical store is the only path a structured
session has.
What a reviewer should check first
The structured publish/revoke/forget path, and specifically exact-subject
forget— including therecord-deleted-first teardown case. Ownership transfer and teardown ordering is where this kind of
change goes wrong quietly.
Second: the renderer bridge production file is deliberately untouched. It is currently the only
source of native-chat child rows, and deleting it before a host-side producer exists would silently
kill them. That deletion belongs to a later PR, paired with its replacement.
Scope
Third of three, originally stacked on #20717 (now merged); this targets
main. It also updatesdocs/reference/agent-status-store.mdto record the amended 2A boundary and drops the stale 2Aprogress doc. What is still owed after this lands:
producers from the legacy manifest.
turn/completion clocks.
exist,
StructuredAgentSessionStatusBridgeand the main structured-row publication filters have tostay.
not grant those clients canonical identity or action authority.