Skip to content

One shared subagent tracker for Claude, Codex and Grok chat rows - #27228

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/subagent-tracker-unify
Oct 11, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/subagent-tracker-unify

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When an agent in native chat starts helper agents ("subagents"), the chat shows a row listing them: their names, whether each is still working or how it ended, and how long it ran. Claude, Codex and Grok each had their own copy of the code that keeps that row up to date, and the three copies had drifted apart. The same situation could look different depending on which agent you used, and each copy had its own bugs. This PR replaces the three copies with one shared tracker that follows one set of rules for every agent.

What Changed

The problem. Three separate subagent rosters existed (Claude, Codex, and the one for Grok and other ACP agents). They disagreed on:

  • what happens when a subagent is given more work later;
  • how duplicate names are numbered;
  • whether a "lost contact" state can later be corrected;
  • what happens to the rows after the app or agent restarts;
  • how a refused journal write is retried.

Several of those disagreements were user-visible bugs:

  • A Codex helper given follow-up work in a later turn was listed in two rows. The chat draws one expandable section per helper, anchored at the first row that names it, so the second row showed the helper with nothing to open.
  • After Codex restarted, its "outside any turn" row was rewritten from all of its helpers down to the newest one.
  • A Codex helper whose thread closed early stayed "unverifiable" even when its turn later reported how it really ended.
  • Codex and Grok numbered duplicate names by counting. A generated "Audit 2" could collide with a helper the agent itself named "Audit 2".

What you see now (the same for Claude, Codex and Grok):

  • Each subagent has one entry. If the agent gives it more work later, that entry reopens where it already is: its clock restarts and it shows as working again. Claude already behaved this way; Codex now does too, so a helper no longer shows up in a second row without its section. (Unchanged from before for every agent: a subagent resumed after its row has dropped out of the last 32 settled rows gets a new entry.)
  • A turn's end settles the foreground subagent runs it started, even when the subagent is listed in an earlier turn's row.
  • After a restart, rows continue where they left off. Codex now keeps the earlier helpers in a row instead of rewriting it, as Claude already did. The row for work outside any turn is never dropped from memory, so it is never rewritten from empty either.
  • "Unverifiable" means contact was lost, not that the subagent ended, so a later real outcome still replaces it. This now holds for Codex too.
  • Duplicate names never collide. Ordinals skip any name already in the row, including one the agent chose itself ("Audit", "Audit 2", "Audit 2 2").
  • Grok's subagent rows now record when contact was lost at session end, as Claude's and Codex's already did.
  • Smaller fixes: a reported token count of 0 is shown instead of dropped; a subagent resumed more than 16 times keeps working normally instead of being marked unverifiable; an unnamed subagent ("subagent") takes the name a later report gives it.

Nothing else about the rows changes. Saved rows from before this change read back exactly as they did, and Claude's rows are written byte-for-byte the same as before outside the cases listed above.

The mechanism. src/main/native-chat/subagent-tracker/ holds one SubagentTracker that owns every decision about the rows:

  • which turn's row lists a subagent, and its name;
  • how its state may change, and how a new run reopens it;
  • what a turn's end or the session's end means for it;
  • how long settled history is kept;
  • how the row is written, including deduplication and handing a refused write back to the caller;
  • how rows from an earlier run of the agent are continued.

Every lookup is read from the rows themselves, so no second index can drift from them. Each agent's own code now only reads its provider's events and reports what it saw in one shared shape:

  • Claude: claude-subagent-roster.ts
  • Codex: codex-subagent-roster.ts
  • Grok and other ACP agents: acp-subagent-timeline.ts

What stays per agent, on purpose:

  • Row identities and group ids. They are saved in users' journals and must never change.
  • Claude's id aliases and provisional rows.
  • Codex's per-thread turn tracking.
  • Grok's reply rows.
  • Only Claude reports subagents that end with the turn. Its CLI ends foreground subagents with the turn; Codex and Grok subagents outlive it.
  • ACP agents still settle their live subagents at session end inside the session-end journal write. That write now carries the end time. Writing separate rows ahead of it could hold up the session-end write when the journal is backed up.

Why

The goal was one set of rules, owned in one place, with each agent only translating its own events. The common pattern is a shared subagent record that every provider adapter emits, plus a shared store that owns lifecycle and settlement. I compared each mechanism to that pattern.

Where common designs differ, I followed what Orca's renderer already draws. That applies to where a resumed subagent appears: one design keeps it under the place that spawned it, the other lists each call separately. Orca draws one section per subagent, so one entry per subagent is the rule that keeps the row and its section in agreement.

I considered a byte-identical move first and changing the rules later, but rejected it. It would have meant temporary per-agent switches that the second PR deletes. Instead, the first commit records golden tests of every row each roster wrote on the unchanged code. The diff to those snapshots in this PR is exactly the list of row changes above, and nothing else.

Differences from the common pattern, labelled:

  • Intended: row identities stay per agent because they are persisted forever.
  • Intended: ACP session-end settlement stays inside the shared session-end journal write, read from the journal. That is the safer place for it under journal backpressure.
  • Intended: settled history is still bounded (32 settled rows per session). Live subagents are never released by count.
  • Temporary: the running-tasks strip and per-subagent Stop still come from each agent's own tracker, and a row still lists at most 64 subagents. Because the row for work outside any turn is now kept for the whole chat, including across restarts, that limit applies to it across the chat's whole life: a 65th subagent started outside any turn gets no row (and, for Grok, no running-tasks entry or Stop). Before this PR that row only had room again because it was wrongly rewritten from empty. Subagents started outside a turn are rare. Follow-up PR: project every agent's subagent feed and Stop from this tracker, so neither depends on the row limit.

Linked Issue

N/A (internal refactor; follow-up to #26798).

Visual Proof

Hidden test builds of Orca with scripted stand-in agents (no real Claude or Codex), before = main, after = this PR. Every screenshot was checked by hand.

1. Codex: a follow-up to an earlier helper. Before, the follow-up turn got its own "Ran 1 subagent" row, which has no section to open (the helper's section stays on the first row). After, the helper is listed once, in the row that started it, and that entry reopens.

Before After
Codex follow-up before: helper listed in a second row Codex follow-up after: helper listed once in the first row

2. The same after quitting and reopening Orca. The helper started before the restart and followed up after it still appears once. ("Survivor" was still running when the app quit, so after reopening it shows "status unavailable" on both builds.)

Before After
Codex after restart before: follow-up in a second row Codex after restart after: helper listed once

3. Codex: the helper's thread closes early, then its turn reports that it finished. Before, it stayed "status unavailable". After, it shows "completed".

Before After
Codex lost contact before: stays status unavailable Codex lost contact after: completed

4. Claude and Grok resuming a helper: unchanged (listed once, as before).

Claude (after) Grok (after)
Claude resume: helper listed once Grok resume: helper listed once

Testing

  • Golden row-write tests per agent, recorded on the unchanged code in the first commit (*-characterization.test.ts); the snapshot diff is the list of changes above.
  • New tracker rule tests (subagent-tracker.test.ts) and a Codex restart test (codex-subagent-roster-restart.test.ts); existing Claude, Codex and ACP subagent, journal-translation and timeline suites pass (154 files, 1533 tests locally).
  • orca-ci-checks passes (lint, code quality, localization, typecheck).
  • Live QA on hidden test builds, before and after, for Claude, Codex and Grok (scripted stand-in agents; real config files hashed before and after, unchanged):
    • one subagent; two with the same name (one fails); a background subagent outliving its turn; parent Stop; per-subagent Stop from the running-tasks strip; resuming an earlier subagent; Codex losing contact then reporting a result;
    • a long chat of 34+ turns, each with a subagent, past the 32 kept rows, then a late event for an early subagent: no new or duplicated row;
    • quit and reopen with a subagent still running, then resume an earlier one: rows read back unchanged and the resumed one appears once.
    • Every difference from main was one of the intended changes above. One thing behaves the same on both builds and is outside this PR: Stop ends the Claude process, so a Claude background subagent shows "status unavailable" afterwards.

Notes

  • SSH and remote hosts: the tracker runs where the agent runs, as the old rosters did. No wire format changes. session.ended gains an optional in-process field only.
  • Windows and Linux: no platform-specific code.
  • Mobile: it draws each row on its own and reads the same row format.
  • Performance: each report scans at most the live rows plus 32 settled ones, the same order of cost as before.

… subagent rows

Claude, Codex and ACP (Grok) each kept their own subagent roster with drifted
rules. They now only report what they observe; one tracker decides grouping,
runs, names, state, sweeps, retention, row writes and restart inheritance.
The golden row-write tests from the previous commit show each rule change.
…amped in its session-end write

Review round 1: a resumed child keeps its one entry and reopens it where it is
listed (the chat draws one section per child, anchored at the first row naming
it), every lookup is read from the rows, the no-turn row is never released,
and ACP's session end stamps its live children inside the session-end write
instead of writing rows ahead of it.
… the turn that started it

Review round 2: the row no turn owns is recognised from its id (a stored flag
was lost when an earlier run's row was first reached through one of its
children), and a turn's end settles the foreground runs it started wherever
their child is listed.
…when a lookup loads it

A read-only lookup could load an earlier run's settled row that retention never saw, so it was never
released and a fresh settled row was released in its place.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review summary

The problem. Claude, Codex and Grok each had their own code for the "subagent" rows in native chat (the row listing helper agents, their state and run time). The three copies had drifted. Codex listed a helper given follow-up work in a second row with nothing to open, rewrote its "outside any turn" row after a restart, and left a helper whose thread closed early as "status unavailable" even after it reported finishing.

What changes for the user. All three agents now follow the same rules from one shared tracker: one entry per subagent (a resumed one reopens where it is), rows that continue after a restart, "status unavailable" that a real result can still correct, and duplicate names that never collide. Claude and Grok look the same as before in normal use. Codex gets the three fixes above. The full list is in the PR body.

How it was reviewed.

  • Characterization tests recorded every row each agent wrote on the unchanged code (first commit). The snapshot diff in this PR is exactly the intended list of changes.
  • Three rounds of independent reviews, a fresh reviewer each round. Round 1: the core, Claude, and Codex/Grok. Round 2: the whole diff, plus the Grok readers. Round 3: the round-2 fixes only.
  • A final release-readiness pass. Its severities are the reviewer's own, not validated by the multi-model panel that normally checks them.

Fixed during review.

  • Late reports could overwrite the current run, and aged-out runs could come back. Fixed by redesigning to one entry per subagent, with every lookup read from the rows.
  • Grok's end-of-session rows could hold up the session-end write when the journal was backed up. They are now stamped inside that write instead.
  • An inherited "outside any turn" row lost its never-release flag. That flag is now derived instead of stored.
  • A turn's end now settles the foreground runs that turn started.
  • A read-only lookup could load an earlier session's row that was never released (readiness P2). It now counts toward settled history.

Deferred (all already present on main, low impact).

  • Grok's "outside any turn" row can still be rewritten after a reload.
  • A subagent resumed after its row has dropped out of the 32 kept rows gets a second entry. It already did on main.
  • The Grok end-of-session stamp can land on a stale child left over from an earlier lost session.
  • Temporary, follow-up PR: a row still lists at most 64 subagents, and the running-tasks strip and Stop still come from each agent's own tracker.

Verified.

  • 154 test files (1533 tests) pass locally, plus orca-ci-checks (24/24).

  • CI is green on 8f741124a0b.

  • Live before/after QA on hidden test builds with scripted Claude, Codex and Grok stand-ins. Every screenshot was checked by hand, and the real config files were hashed before and after (unchanged). Scenarios:

    • one subagent; two with the same name;
    • a background subagent;
    • parent Stop and per-subagent Stop;
    • resuming a helper;
    • Codex losing contact;
    • 34+ turns past the 32 kept rows, then a late event;
    • quit and reopen, then resume a helper.

    Every difference from main was an intended change.

Not verified.

  • Real Claude, Codex or Grok CLIs (stand-ins only).
  • SSH remotes.
  • Windows and Linux.
  • The phone app (no mobile-facing change).
  • More than 64 subagents outside a turn.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 10, 2026 15:31
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

The pull request adds a shared subagent tracker for state, retention, journal inheritance, and row writes. Claude, Codex, and ACP timeline tracking now use the shared tracker. The changes also update provider tests for child reopening, late events, and persistence behavior. Session-end timestamps now flow into journal settlement, where working agents marked unverifiable receive a settlement timestamp when the host observed the end.


Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 8f741

After a rewind in a live session, an old subagent row that had aged out of history can reappear and be updated by a late event. This edge case affects displayed history rather than core chat function, so the change is mergeable with a small follow-up fix.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 37 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: a shared tracker for Claude, Codex, and Grok subagent rows.
Description check Passed The description is complete and directly matches the template. It explains the user impact, implementation, rationale, linked follow-up issue, visual proof, testing, platform considerations, deferred …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 89251955-a6d8-4868-a1a0-98c183fe2130
📥 Commits

Reviewing files that changed from the base of the PR and between 9d43038 and 8f74112.

⛔ Files ignored due to path filters (3)
  • src/main/acp/__snapshots__/acp-subagent-timeline-characterization.test.ts.snap is excluded by !**/*.snap
  • src/main/claude/__snapshots__/claude-subagent-roster-characterization.test.ts.snap is excluded by !**/*.snap
  • src/main/codex/__snapshots__/codex-subagent-roster-characterization.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (41)
  • src/main/acp/acp-structured-host-subagent-stop.test.ts
  • src/main/acp/acp-structured-session.ts
  • src/main/acp/acp-subagent-timeline-characterization.test.ts
  • src/main/acp/acp-subagent-timeline.test.ts
  • src/main/acp/acp-subagent-timeline.ts
  • src/main/claude/claude-subagent-group-row.ts
  • src/main/claude/claude-subagent-journaled-roster.test.ts
  • src/main/claude/claude-subagent-journaled-roster.ts
  • src/main/claude/claude-subagent-resume-after-restart.test.ts
  • src/main/claude/claude-subagent-roster-characterization.test.ts
  • src/main/claude/claude-subagent-roster-groups.test.ts
  • src/main/claude/claude-subagent-roster-groups.ts
  • src/main/claude/claude-subagent-roster-retention.test.ts
  • src/main/claude/claude-subagent-roster-state.ts
  • src/main/claude/claude-subagent-roster.test.ts
  • src/main/claude/claude-subagent-roster.ts
  • src/main/codex/codex-child-work-evidence.test.ts
  • src/main/codex/codex-default-mode-subagents.test.ts
  • src/main/codex/codex-structured-journal-limits.ts
  • src/main/codex/codex-subagent-execution-projection.test.ts
  • src/main/codex/codex-subagent-executions.ts
  • src/main/codex/codex-subagent-roster-characterization.test.ts
  • src/main/codex/codex-subagent-roster-restart.test.ts
  • src/main/codex/codex-subagent-roster-state.ts
  • src/main/codex/codex-subagent-roster.ts
  • src/main/native-chat/agent-session-journal/journal-subagent-group-body-fallback.test.ts
  • src/main/native-chat/agent-session-journal/journal-subagent-liveness.ts
  • src/main/native-chat/agent-session-timeline/provider-timeline-event.ts
  • src/main/native-chat/agent-session-timeline/provider-timeline-settlement.ts
  • src/main/native-chat/agent-session-timeline/provider-timeline-turn-decisions.ts
  • src/main/native-chat/subagent-roster-retention.test.ts
  • src/main/native-chat/subagent-roster-retention.ts
  • src/main/native-chat/subagent-row-sink-recorder-test-support.ts
  • src/main/native-chat/subagent-tracker/journaled-subagent-groups.ts
  • src/main/native-chat/subagent-tracker/subagent-row-sink-port.ts
  • src/main/native-chat/subagent-tracker/subagent-row-writes.ts
  • src/main/native-chat/subagent-tracker/subagent-tracker-entries.ts
  • src/main/native-chat/subagent-tracker/subagent-tracker-groups.ts
  • src/main/native-chat/subagent-tracker/subagent-tracker-types.ts
  • src/main/native-chat/subagent-tracker/subagent-tracker.test.ts
  • src/main/native-chat/subagent-tracker/subagent-tracker.ts
💤 Files with no reviewable changes (4)
  • src/main/claude/claude-subagent-roster-groups.test.ts
  • src/main/claude/claude-subagent-roster-state.ts
  • src/main/claude/claude-subagent-roster-groups.ts
  • src/main/claude/claude-subagent-group-row.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment on lines +57 to +80
claimGroup = (groupId: string): JournaledGroup | null => {
const reading = this.current()
const row = reading?.rowsByGroup.get(groupId) ?? null
reading?.rowsByGroup.delete(groupId)
return row
}

/** The extension's reading of the bound journal; null before bind. */
extra(): Extra | null {
return this.current()?.extra ?? null
}

private current(): Reading<Extra> | null {
const journal = this.bound()
if (!journal) {
return null
}
if (!this.reading || journal !== this.journal || journal.epoch !== this.epoch) {
this.journal = journal
this.epoch = journal.epoch
this.reading = this.read(journal)
}
return this.reading
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Find where the journal epoch is assigned or advanced.
rg -nP --type=ts -C3 '\bepoch\s*(=|:)' src/main/native-chat/agent-session-journal | head -80
rg -nP --type=ts -C3 'journalLinkage\s*[:(=]' src/main/native-chat | head -40

Repository: stablyai/orca

Length of output: 9794


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- changed file at head ---'
nl -ba src/main/native-chat/subagent-tracker/journaled-subagent-groups.ts

printf '%s\n' '--- PR diff for changed file and tracker callers ---'
git diff --no-ext-diff --unified=80 dab3f6efeb6fc0ddcb6e21b3b6dcfb76659639f2 8f741124a0b3c1bf9b6cb357201493e2db54e7d3 -- \
  src/main/native-chat/subagent-tracker \
  src/main/native-chat/agent-session-journal \
  src/main/native-chat/agent-session-wire | sed -n '1,1200p'

printf '%s\n' '--- tracker references ---'
rg -n -F --glob '*.ts' -- 'claimGroup(' src/main/native-chat
rg -n -F --glob '*.ts' -- 'locate(' src/main/native-chat/subagent-tracker src/main/native-chat | head -120

printf '%s\n' '--- journal epoch lifecycle definitions and references ---'
rg -n -F --glob '*.ts' -- 'publishNewEpoch' src/main/native-chat
rg -n -F --glob '*.ts' -- 'journalEpoch' src/main/native-chat | head -160
rg -n -F --glob '*.ts' -- 'publishJournalSessionEpoch' src/main/native-chat

printf '%s\n' '--- journal binding and write/read APIs ---'
rg -n -F --glob '*.ts' -- 'StructuredAgentSessionLinkageJournal' src/main/native-chat | head -160
rg -n -F --glob '*.ts' -- 'appendLifecycleBatch' src/main/native-chat | head -160
rg -n -F --glob '*.ts' -- 'readJournalRowsAfter' src/main/native-chat

Repository: stablyai/orca

Length of output: 42385


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- epoch controller, rollover, replacement ---'
nl -ba src/main/native-chat/agent-session-journal/journal-epoch-controller.ts
nl -ba src/main/native-chat/agent-session-journal/journal-epoch-rollover.ts
nl -ba src/main/native-chat/agent-session-journal/journal-epoch-replacement.ts

printf '%s\n' '--- journal open/store epoch and binding ---'
nl -ba src/main/native-chat/agent-session-journal/journal-open.ts | sed -n '1,230p'
nl -ba src/main/native-chat/agent-session-journal/journal-store.ts | sed -n '280,390p'
nl -ba src/main/native-chat/agent-session-wire/structured-agent-session-event-sink.ts | sed -n '50,330p'

printf '%s\n' '--- tracker implementation and row sink ---'
nl -ba src/main/native-chat/subagent-tracker/subagent-tracker-groups.ts
nl -ba src/main/native-chat/subagent-tracker/subagent-tracker.ts
nl -ba src/main/native-chat/subagent-tracker/subagent-row-sink-port.ts

printf '%s\n' '--- construction and use of JournaledSubagentGroups ---'
rg -n -F --glob '*.ts' -- 'new JournaledSubagentGroups' src/main
rg -n -F --glob '*.ts' -- 'JournaledSubagentGroups<' src/main
rg -n -F --glob '*.ts' -- 'writeSubagentRows' src/main/native-chat

Repository: stablyai/orca

Length of output: 42696


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- Claude journaled roster ---'
nl -ba src/main/claude/claude-subagent-journaled-roster.ts

printf '%s\n' '--- Codex roster ---'
nl -ba src/main/codex/codex-subagent-roster.ts

printf '%s\n' '--- tracker groups complete ---'
nl -ba src/main/native-chat/subagent-tracker/subagent-tracker-groups.ts

printf '%s\n' '--- journal state/adoption and epoch mutation ---'
rg -n -F --glob '*.ts' -- 'adopt:' src/main/native-chat/agent-session-journal src/main/native-chat/agent-session-wire
rg -n -F --glob '*.ts' -- 'onPublished' src/main/native-chat/agent-session-journal src/main/native-chat/agent-session-wire
rg -n -F --glob '*.ts' -- 'this.epoch' src/main/native-chat/agent-session-journal src/main/native-chat/agent-session-wire
rg -n -F --glob '*.ts' -- 'journal.epoch' src/main/native-chat/agent-session-journal src/main/native-chat/agent-session-wire

printf '%s\n' '--- epoch/reread tests and tracker tests ---'
rg -n -F --glob '*.test.ts' -- 'epoch' src/main/native-chat/subagent-tracker src/main/native-chat/agent-session-wire src/main/native-chat/agent-session-journal | head -160
rg -n -F --glob '*.test.ts' -- 'JournaledSubagentGroups' src/main
rg -n -F --glob '*.test.ts' -- 'claimGroup' src/main

Repository: stablyai/orca

Length of output: 42031


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- epoch controller call sites ---'
rg -n -F --glob '*.ts' -- '.epochController' src/main
rg -n -F --glob '*.ts' -- '.roll(' src/main/native-chat src/main | head -120
rg -n -F --glob '*.ts' -- '.replace(' src/main/native-chat src/main | head -120
rg -n -F --glob '*.ts' -- 'epochController' src/main/native-chat src/main | head -160

printf '%s\n' '--- journal adoption and mutable journal state ---'
rg -n -F --glob '*.ts' -- 'onPublished' src/main/native-chat/agent-session-wire src/main/native-chat/agent-session-journal
rg -n -F --glob '*.ts' -- 'adopt(loaded' src/main/native-chat
rg -n -F --glob '*.ts' -- 'adopt:' src/main/native-chat
rg -n -F --glob '*.ts' -- 'this.state =' src/main/native-chat/agent-session-journal
rg -n -F --glob '*.ts' -- 'this.epoch =' src/main/native-chat/agent-session-journal

printf '%s\n' '--- rewind/replacement lifecycle ---'
rg -n -F --glob '*.ts' -- 'replaceJournalEpoch' src/main
rg -n -F --glob '*.ts' -- 'journal.epoch' src/main/native-chat/agent-session-wire | head -120
rg -n -F --glob '*.ts' -- 'new CodexSubagentRoster' src/main
rg -n -F --glob '*.ts' -- 'new ClaudeJournaledRoster' src/main

Repository: stablyai/orca

Length of output: 25683


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- journal store replacement methods and adoption ---'
nl -ba src/main/native-chat/agent-session-journal/journal-store.ts | sed -n '90,155p;365,410p'
nl -ba src/main/native-chat/agent-session-journal/journal-store-collaborators.ts | sed -n '1,145p'

printf '%s\n' '--- rewind callers and journal replacement invocation ---'
rg -n -F --glob '*.ts' -- 'rewind(' src/main/native-chat | head -120
rg -n -F --glob '*.ts' -- '.replace(reason' src/main
rg -n -F --glob '*.ts' -- 'journal.replace' src/main
rg -n -F --glob '*.ts' -- 'replaceEpoch' src/main/native-chat

printf '%s\n' '--- provider translation-writer construction and disposal ---'
nl -ba src/main/codex/codex-structured-journal-translation-writers.ts
nl -ba src/main/claude/claude-structured-journal-translation.ts | sed -n '1,150p'
rg -n -F --glob '*.ts' -- 'dispose()' src/main/codex src/main/claude | head -120
rg -n -F --glob '*.ts' -- 'codexSubagentRoster' src/main/codex src/main/native-chat | head -120

Repository: stablyai/orca

Length of output: 41960


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- generic rewind recovery ---'
nl -ba src/main/native-chat/agent-session-wire/structured-rewind-recovery.ts | sed -n '130,195p'

printf '%s\n' '--- Codex rewind lifecycle ---'
nl -ba src/main/codex/codex-structured-rewind.ts | sed -n '110,165p'

printf '%s\n' '--- Claude rewind/session teardown references ---'
rg -n -F --glob '*.ts' -- 'journal.context.rewind' src/main/claude src/main/native-chat
rg -n -F --glob '*.ts' -- 'translator.dispose()' src/main/claude src/main/native-chat | head -80
rg -n -F --glob '*.ts' -- 'createClaudeJournalTranslator' src/main
rg -n -F --glob '*.ts' -- 'replaceEpochItems' src/main/native-chat/agent-session-wire src/main/claude src/main/codex

Repository: stablyai/orca

Length of output: 30675


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- complete Codex rewind entry ---'
nl -ba src/main/codex/codex-structured-rewind.ts | sed -n '1,180p'

printf '%s\n' '--- Codex session close and translator ownership ---'
nl -ba src/main/codex/codex-structured-session-close.ts | sed -n '1,100p'
nl -ba src/main/codex/codex-structured-session-acquire.ts | sed -n '230,285p'

printf '%s\n' '--- Claude session journal control ---'
nl -ba src/main/claude/claude-structured-session-journal-control.ts
rg -n -F --glob '*.ts' -- 'rewind' src/main/claude src/main/native-chat/agent-session-wire | head -160

Repository: stablyai/orca

Length of output: 42720


Preserve claimed group identities across journal rereads.

A live, idle Codex session can replace the journal epoch while its roster remains alive. current() then rebuilds rowsByGroup, including groups previously claimed and evicted. A late report can inherit that group again, and a later report without a run can rewrite the row.

Suggested fix
   private reading: Reading<Extra> | null = null
+  /** Groups handed to the tracker; a re-read must not hand them over again. */
+  private readonly claimed = new Set<string>()
 ...
   claimGroup = (groupId: string): JournaledGroup | null => {
+    if (this.claimed.has(groupId)) {
+      return null
+    }
     const reading = this.current()
     const row = reading?.rowsByGroup.get(groupId) ?? null
-    reading?.rowsByGroup.delete(groupId)
+    if (reading) {
+      this.claimed.add(groupId)
+      reading.rowsByGroup.delete(groupId)
+    }
     return row
   }

@brennanb2025
brennanb2025 merged commit 5b228ea into main Oct 11, 2026
54 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/subagent-tracker-unify branch October 11, 2026 20:15
brennanb2025 added a commit that referenced this pull request Oct 12, 2026
Conflict: journal-subagent-liveness.ts. Main (#27228) added `lostAt`, the
time a live host saw the session end; this branch added `lost`, which
narrows settlement to the entries the ended generation ran. Both now pass
as one options object, and each caller names what it supplies.

Merge-caused fixes:
- roster-provenance test: the Claude group row helpers moved with the
  shared subagent tracker (#27228).
- journal partition receipts (#27559): regenerated with the previous
  partitioner on this branch's row shape (each item row states its owner
  generation), which moves three chunk boundaries.
- line caps after main's additions: main's hasLoadedProviders (#26473)
  lives on the conversations map and the host delegates to it; one wire
  type and two navigation requests written on one line.
brennanb2025 added a commit that referenced this pull request Oct 15, 2026
)

* test(native-chat): pin each agent's subagent row writes before unifying the rosters

* refactor(native-chat): one shared subagent tracker owns every agent's subagent rows

Claude, Codex and ACP (Grok) each kept their own subagent roster with drifted
rules. They now only report what they observe; one tracker decides grouping,
runs, names, state, sweeps, retention, row writes and restart inheritance.
The golden row-write tests from the previous commit show each rule change.

* fix(native-chat): one entry per subagent, derived lookups, ACP end stamped in its session-end write

Review round 1: a resumed child keeps its one entry and reopens it where it is
listed (the chat draws one section per child, anchored at the first row naming
it), every lookup is read from the rows, the no-turn row is never released,
and ACP's session end stamps its live children inside the session-end write
instead of writing rows ahead of it.

* fix(native-chat): derive the no-turn group, end a foreground run with the turn that started it

Review round 2: the row no turn owns is recognised from its id (a stored flag
was lost when an earlier run's row was first reached through one of its
children), and a turn's end settles the foreground runs it started wherever
their child is listed.

* fix(native-chat): count an inherited subagent row as settled history when a lookup loads it

A read-only lookup could load an earlier run's settled row that retention never saw, so it was never
released and a fresh settled row was released in its place.

(cherry picked from commit 5b228ea)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant