Skip to content

Agent status C5/C10: show launched agents before the first status update - #21054

Closed
brennanb2025 wants to merge 28 commits into
mainfrom
brennanb2025/agent-status-c10-launch-membership
Closed

brennanb2025 wants to merge 28 commits into
mainfrom
brennanb2025/agent-status-c10-launch-membership

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 39 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2638 $\color{#cf222e}{\Huge{\mathbf{−}}}$​52 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2586
Prod 167 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4664 $\color{#cf222e}{\Huge{\mathbf{−}}}$​749 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3915

This draft makes an Orca-launched terminal agent visible to agent-status readers as soon as the execution host has successfully created or adopted it, without pretending that the agent is already working, ready, or idle. It also ties later status reports to that specific execution so a delayed report or reused pane is less likely to update the wrong agent.

Before / After

Before: the status store usually learned that a terminal agent existed only after a provider hook or terminal status event arrived. A quiet newly launched CLI could therefore be missing from the sidebar, and restart recovery had no trustworthy launch record to reconnect to the live terminal owner.

After: the host assigns run and execution identity inside the existing create-or-adopt transaction, waits for the final terminal binding, and then publishes neutral launch membership into the existing status store. The row remains visible before the first provider event without counting as active work, a completed turn, unread activity, or a reason to keep the machine awake. Later provider events keep that membership only when their execution binding or verified process ancestry matches; complete host inventories can restore or retire membership after restart, while incomplete or unreachable inventories do not claim that a process exited.

The behavior is implemented and covered by focused tests and reader projections. It has not received completed independent review or final visual Electron QA, so the visible result is intended and tested at the data/projection level but is not yet accepted as release-ready across every launch path.

Issues

No issue is being auto-closed by this draft.

Implemented toward the direct membership report, but kept open pending independent review and end-to-end QA:

  • STA-956 / #6643: ordinary fresh, committed launches now receive host-published membership before the first user message. Later commits corrected the earlier review finding that renderer-backed fresh launches could bypass this path; that correction still needs fresh independent re-review and UI validation.

Partially addressed foundations, not complete fixes:

  • STA-5329: complete owner inventories can reconnect or retire launch membership after restart, but descendant turn/outcome recovery is separate C1/C2 work.
  • STA-3499: create/adopt now shares one atomic terminal owner decision, but this PR does not prove or change the exact AI Vault Resume/Jump flow end to end.
  • STA-4766 / #15325: stable execution membership and stricter emitter binding are groundwork for pruning phantom async rows, but the async-agent roster case is not reproduced or fixed here.
  • The included C5 identity foundation has the same issue outcome documented in #21058: STA-4977 / #15639 is partially addressed internally, while the requested public plugin event still lacks the identifier.

Still open because they require a different mechanism:

  • Provider delivery and platform integration: STA-4265 / #14434, STA-5679 / #16728, and STA-2221 / #9622. A launch row does not repair missing Cursor/OpenCode events.
  • Remote completed-row retention: STA-2418 / #10130. This remains host-replication and reader-cutover work.
  • tmux discovery: STA-1490 / #7797. This PR can verify a directly visible POSIX process and its hook ancestry, but it cannot see through the tmux/screen pane boundary yet.
  • Launch, transport, and input-route failures: STA-3813 / #13539, STA-2939 / #11401, and STA-7285 / #20159. Publishing membership neither launches a missing agent nor repairs an unusable transport.
  • Separate product/lifecycle packages: STA-2018 / #9138, STA-4146 / #14308, and STA-6257. These concern old daemon cleanup, chat ordering, and unread synchronization respectively.

Why this approach

The execution host already has one transaction that decides whether an agent execution was newly created, adopted, replaced, or failed. Publishing membership from the successful result of that transaction means the status row uses the final terminal identity and the same decision that prevented duplicate execution. Desktop and headless startup now call the same publication and recovery functions.

Alternatives considered:

  • Waiting for a provider status event is the original failure: a quiet or broken integration may never send one.
  • Seeding a row from renderer launch state or a provisional pane would add another writer and can name the wrong terminal after adoption or final binding.
  • Adding a new starting status would change the wire vocabulary for independently updated clients. This branch instead adds an optional membership fact and keeps the older neutral done + session-boundary projection for compatibility; readers use the membership fact for presence without treating it as completion.
  • Inferring survival from elapsed time, a terminal title, or a shell process would turn weak evidence into a lifecycle verdict. Recovery removes absence only from a complete inventory owned by the execution host, and manual POSIX discovery requires both an exact process incarnation and matching hook-emitter ancestry.

Concrete mechanism comparison supports the narrow ownership choice: the inspected implementations keep create/adopt decisions in one host-owned lifecycle and fence stale session events, but they do not establish Orca's cross-host status publication or provider-hook attribution. Direct SSH/WSL parity, replica convergence, and every reader's final cutover therefore remain explicit work rather than claimed precedent.

Scope, overlap, and remaining work

  • This branch includes and reworks the C5 foundation from #21058. Do not merge both PRs independently. Their bases and consolidation remain coordinator decisions; this PR's base was not changed.
  • The merge with current main preserves its one legacy-status write boundary and structured-session store, then applies launch membership and execution binding before status publication.
  • Verified manual discovery currently covers a directly visible POSIX process only. WSL guest joins, Windows relay ancestry, tmux/screen pane roots, and detached automation membership are incomplete.
  • Subject-keyed reader cutover, host replica negotiation, child/turn recovery, readiness and prompt receipt, integration delivery, and exact-attachment execution observation remain dependent work in C7, C1/C2, C3/C4, and C6.
  • Bookkeeping failures are reported but do not block terminal creation, adoption, dismissal, or other user actions.

Draft / not merge-ready. These PRs were opened before final review and QA at the user's request. The earlier combined-branch reviewer was interrupted. Conflict resolution and passing focused checks do not replace independent architectural review, platform fixtures, or hidden/background Electron QA of the final head.

Checks on 74a8760d4e

  • Integrated origin/main at 36cdb34097a7075718abe41c29d559101841166a; resolved conflicts in hook-server listeners/state/retry/status update and headless startup, preserving both current-main store rules and this branch's execution-bound launch membership.
  • Focused execution-binding, terminal/structured ingest, launch-membership, process-discovery, inventory-reconciliation, and legacy-boundary tests: 11 files, 96 tests passed.
  • ORCA_BACKGROUND_LAUNCH=1 pnpm tc:node and ORCA_BACKGROUND_LAUNCH=1 pnpm tc:web: passed.
  • Direct lint of all TypeScript/JavaScript changed from the integration baseline: passed. Format checks passed, including the shared desktop/headless membership extraction.
  • pnpm run check:code-quality:changed: passed with zero new findings across all gates (698 files in its repository comparison range).
  • git diff --check and conflict-marker checks: passed.

Remaining validation gap: no completed independent review or final Electron/mobile UI QA exists for this exact head. Native, daemon, WSL, Windows relay, direct SSH, tmux/screen, detached automation, mixed-version peers, owner-promotion races, restart/replay, and visible sidebar behavior still need final end-to-end coverage before this draft can be marked ready.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review and validation handoff — 2026-09-16

Draft / not merge-ready. Published at the user's request before review/QA completion. Published head: 24b0339fd785f496f2064ac3481574821276e906.

What has been done

Implementation completed at e30e6b7, validated code/test tip 5b2325e, report-only final head 24b0339. Author reports node/web typechecks, 159 emitter/discovery tests (3 skipped), 26 inventory integration tests, diff checks and zero new changed-code quality findings passing. Prior review informed the corrections. The fresh independent reviewer only began preliminary reading before a provider disconnect; it did NOT finish.

These are recorded worker/reviewer results from the stated revisions, not a fresh coordinator rerun, CI result, or blanket approval of today's PR head. Recovery/review workers used GPT-5.6 Sol xhigh; provider interruptions prevented some follow-up stages from finishing.

What still needs to be done

Complete independent correctness/contract and environment/adversarial review, then fresh exact-head Electron QA. WSL guest joins, Windows relay ancestry, tmux/screen pane roots, detached automation membership, subject-keyed reader cutover and replica negotiation remain incomplete and are NOT accepted scope exclusions. This branch incorporates/reworks C5; reconcile that overlap and C1/C2/C6/C7 dependencies before merging.

Before marking ready: address proven findings, reconcile current main and cross-batch overlap, complete independent review of the final diff, rerun relevant tests/typechecks/quality, and perform fresh manual Electron QA against that exact head. Use background/hidden CDP validation; unavailable auth/platform scenarios remain explicitly unverified. No successful final-head review or QA should be inferred from old report filenames or task completion labels.

Earlier C5 foundation: #21058. This branch incorporates/reworks that work; reconcile rather than merge both independently.

Related batch PRs

C1: #21053 · C10: #21054 · C2: #21056 · C3: #21055 · C4: #21057 · C5: #21058 · C6: #21059 · C7: #21060

The remaining full-batch work stays open; opening this draft does not mark those requirements complete.

…2025/agent-status-c10-launch-membership

# Conflicts:
#	src/main/agent-hooks/server/server-listeners.ts
#	src/main/agent-hooks/server/server-state.ts
#	src/main/agent-hooks/server/server-status-retries.ts
#	src/main/agent-hooks/server/server-status-update.ts
#	src/main/orcad/orcad-entry.ts
@brennanb2025 brennanb2025 changed the title Agent status C5/C10: execution identity and committed launch membership Agent status C5/C10: show launched agents before the first status update Sep 16, 2026
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Conflict-resolution update for head 74a8760d4ea115e4943835689a03946de6c6c4dd against origin/main baseline 36cdb34097a7075718abe41c29d559101841166a.

Resolved conflicts in server-listeners.ts, server-state.ts, server-status-retries.ts, server-status-update.ts, and orcad-entry.ts. The resolution keeps current main's single structured/legacy status-store rules and centralized notifications, while retaining this branch's execution binding, committed-launch membership, verified local process discovery, and emitter-process checks. Retry now respects main's refused/suppressed result, and desktop/headless startup share one membership publication/reconciliation implementation.

Rerun on the integrated tree:

  • 11 focused test files / 96 tests passed (binding, terminal and structured ingest, launch membership, process discovery, inventory reconciliation, and legacy boundary)
  • pnpm tc:node and pnpm tc:web passed with ORCA_BACKGROUND_LAUNCH=1
  • direct lint and format checks passed
  • pnpm run check:code-quality:changed passed with zero new findings across all gates
  • git diff --check and conflict-marker checks passed

Still draft / not merge-ready: the fresh-launch correction and this conflict resolution need completed independent review. Final hidden/background Electron QA was not run, and WSL guest joins, Windows relay ancestry, tmux/screen boundaries, detached automation membership, mixed-version replica cutover, and related C1/C2/C3/C4/C6/C7 work remain open. This branch overlaps #21058; do not merge both independently.

Resolve resume-sleeping-agent-session.ts: keep main's hoisted identity guard,
tabId local and live-PTY ownership arm; the scoped arm now uses this branch's
isAgentStatusTurnComplete so a launch-membership boundary row keeps claiming its
provider session instead of reading as a finished turn.
These four root-level result/review notes are process artifacts pinned to
stale SHAs, not product documentation; they are kept locally as untracked
evidence instead of shipping in the PR.
…rated row

sanitizeHydratedEntry rejected an entire persisted status row when runId,
executionId or launchMembership failed to parse. These are optional additive
facets and the return statement already omits them when absent, so the guards
only converted a version skew into data loss: a build that persists a shape
this parser predates would erase a live agent's whole row on downgrade, which
is the disappearance this membership work exists to fix.

The new hydrate test fails without this change (the pane's row is dropped
entirely); providerAlias beside them already behaved this way.
…ntroduced

main's #20912 let the changed-code gate see the focused import plugins, which
surfaced eight import(no-duplicates) findings across seven of this branch's
files. Same bindings, one specifier each.
…bundle on Node 18

Two bundle ratchets were failing on this branch.

The relay bundle forbids the ES2023 array-copy methods, so the new ancestry
walk uses an indexed reverse like the other modules that reach it.

The daemon bundle must not pull node-pty into its require graph before the
entry parses argv. This branch wired the execution-binding resolver from the
main-process PTY owner registry as a module-level side effect of the hook-server
adapter, and reached the same registry again for manual-discovery admission, so
importing the adapter initialized the local PTY provider. Both now come from
whichever composition root owns a registry: the resolver moves to desktop
startup through the setter that already existed, and discovery admission becomes
an injected dependency. The daemon never populated that main-process registry,
so this drops an accidental coupling rather than behavior.
…cord

Resolving the merge with main, this branch's turn-complete predicate replaced
main's plain done check in the worktree-scoped arm of the resume claim. That was
the wrong half to keep. A launch-membership row carries no provider session, and
the equality guard above the arm returns false whenever either side is
undefined, so a membership row can never reach it; the substitution had no
effect on membership at all.

What it did reach were the rows that do carry a provider session and a session
boundary -- SessionStart, Grok and remote compact completion, all of which
predate this branch. Claiming there runs clearSleepingAgentSession, so a pending
auto-resume was deleted rather than deferred, with nothing left to retry from.

main's live-PTY ownership arm is untouched.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review-and-fix pass on 6ce2e34e3e2163345b563f00841f80bed06e04e2

This branch had drifted 51 commits behind main and was conflicting. It is now merged and
MERGEABLE. It stays a draft: independent review found two problems that I do not think should
be fixed by patching, so this is a status report, not a readiness claim.

What was done

Re-baselined onto origin/main at 779667c1e7 first, so the design was judged against what is
actually on main rather than a stale base. Exactly one conflict, in
src/renderer/src/lib/resume-sleeping-agent-session.ts. Then four independent reviewers read the
merged head: a check of whether recent main work already solves this, an architecture challenger
asked to argue for replacing the mechanism, a correctness reviewer, and a platform/wire reviewer.

Fixed in this pass

  1. A hydrated status row was discarded whole when one optional field would not parse.
    sanitizeHydratedEntry rejected the entire persisted row if runId, executionId or
    launchMembership failed to parse, even though the row's identity and routing were fine. The
    realistic trigger is a version skew, not corruption: a newer build writes a shape an older parser
    rejects, and on downgrade that pane's whole row is dropped at hydration — the agent disappears
    after restart, which is the bug this PR exists to fix. The guards were also redundant, because
    the return statement already omits fields it cannot read, and the neighbouring providerAlias
    already behaved that way. Added a regression test; it fails without the change.
  2. Eight duplicate-import findings. Not pre-existing sloppiness on this branch's part alone —
    main's fix(quality-gate): let the changed-code gate see the focused import plugins #20912 let the changed-code gate see the focused import plugins, which is why they only
    appeared now.
  3. Two bundle ratchets were red in CI. The new ancestry walk used an ES2023 array-copy method
    that the Node 18 relay bundle does not have. Separately, the branch pulled node-pty into the
    daemon bundle's require graph before argv parsing, by wiring the execution-binding resolver from
    the main-process PTY owner registry as a module-level side effect of the hook-server adapter, and
    by reaching the same registry for manual-discovery admission. Both now come from whichever
    composition root actually owns a registry; the daemon never populated that one, so this removes
    an accidental coupling rather than behaviour.
  4. Corrected part of my own merge resolution. I had kept this branch's turn-complete predicate
    in the worktree-scoped arm of the resume claim. That was the wrong half to keep: a launch row
    carries no provider session, so it can never reach that arm, and the substitution's only real
    effect was on session-boundary rows that predate this branch — where claiming deletes a pending
    auto-resume instead of deferring it.
  5. Stopped shipping four working-note markdown files that were committed at the repo root.

Still open — why this is not ready

Two confirmed problems, both in the retirement and mixed-version halves rather than in
publication:

  • A single inventory pass can delete a live agent's row. One refresh fires reconciliation twice.
    The second call reports itself complete while carrying only the main process's own owner registry,
    which is empty after a restart because daemon-advertised owners are imported on spawn. So the
    first call re-admits a daemon-hosted agent and the second deletes the whole row — not just the
    membership field. Adjacent code already refuses to treat listing-absence as authoritative unless
    the provider says it owns the listing; this path has no equivalent guard.
  • Requiring the new binding field on an owner makes a preserved older daemon fatal. Every owner
    binding minted by a shipped release now fails validation, the listing read throws for the whole
    batch, and the router aggregates adapters with no per-adapter catch. An older daemon is preserved
    exactly when it still owns live sessions, so the entire terminal inventory — including the healthy
    new daemon's — is lost on every poll, and it does not recover on its own. SSH is not exposed here,
    because relay installs are version-namespaced.

Also confirmed and unfixed: a replacement execution on the same pane never publishes its new
membership; a hydrated row can never gain membership because hydration drops the terminal handle,
so the upgrade path stays broken; readers branch on the compatibility projection rather than the
membership fact, which reclassifies three unrelated pre-existing producers; and mobile receives the
new field with nothing to read it, while the mobile CI path filter matches none of the changed
files.

The architecture challenge is worth recording as a negative result: the case for rebuilding this
on the newer launch contract, or on the durable operation ledger, was examined and does not hold.
The ledger rows cannot name a terminal surface, and the newer launch path has no callers yet and
re-enters the same commit point on desktop. Publishing from the create-or-adopt commit is the more
general seam. The publication design survived; the retirement design did not.

Checks

Passing at this head: node/web/cli typechecks; the changed-code quality gate with zero findings
across all seven categories over 206 files; 56 focused test files / 610 tests; and the two bundle
tests that were red in CI on the previous head.

Not run: Electron UI validation, screenshots, mobile emulator, a real SSH host, and a real
Windows/WSL host. That is deliberate — those were gated on the review being clean, and it is not.
An independent readiness checklist was started and did not finish, so no readiness result should be
inferred from this comment.

No issue is auto-closed by this pass, and nothing here changes the issue outcomes already listed in
the description.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing this draft from the September 14 agent-status plan. That plan was re-examined against current main and replaced.

This branch conflicts with main, and its central work duplicated contracts that had already merged (the canonical status store and the child-work contract landed on 15–16 September). The replacement work is being done as smaller root-cause PRs, each planned, challenged and reviewed first.

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