Skip to content

feat(agent-status): step 1 — stamp observation provenance and ordering at every status ingress (STA-4293) - #14706

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/agent-status-provenance-sta4293
Aug 18, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/agent-status-provenance-sta4293

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​710 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​699
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​436 $\color{#cf222e}{\Huge{\mathbf{−}}}$​35 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​401

ELI5

Every agent status row in Orca is a claim like "this pane is working". Today the row cannot say who made that claim — a real provider hook, an OSC 9999 payload, or a guess from the terminal title — nor whose clock stamped it, nor what order it came in. This PR adds that label. Nothing reads the label yet. It exists so the next PR can move one consumer at a time onto it and actually be able to tell those cases apart.

What Changed

Adds an optional observation facet to agent status rows and stamps it at every ingress.

observation?: {
  origin: 'hook' | 'osc' | 'title' | 'process' | 'launch' | 'orchestration'
  authorityId: string   // which component sequenced this observation
  incarnation: number   // bumps when the pane/PTY is rebound
  revision: number      // monotonic per pane, per authority
  observedAt: number    // the AUTHORITY's clock, not the reader's
  boundary?: true       // this observation is a user-initiated new turn
  kind?: 'transition' | 'snapshot' | 'identity-only'
}

New: src/shared/agent-status-observation.ts (the type, the ordering + decay contracts, and a small per-authority sequencer) and src/renderer/src/lib/renderer-agent-status-observations.ts (the renderer's sequencer instance).

Stamped at:

Ingress Origin Where
Provider hook over loopback HTTP, and over the SSH relay (ingestRemote) hook main/agent-hooks/server.ts — applyNormalizedStatus is the single choke point every main-side ingress funnels through
OSC 9999 parsed by main (ingestTerminalStatus) osc same
OSC 9999 parsed by the renderer for remote-runtime panes osc pty-connection.ts, background-agent-status-consumer.ts, automation-session-observer.ts
Orca-launched agent seeds launch pty-connection.ts, launch-agent-background-session.ts
Command Code output/prompt seeds process pty-connection.ts, parked-terminal-command-status.ts, command-code-prompt-status-seed.ts
Title-derived sidebar rows title worktree-title-derived-agent-rows.ts

Two facets both reviewers insisted on:

  • boundary is stamped from the hook listener's own per-provider isNewTurnEvent (now exported), not from a new list of event-name literals. Today the retired-pane gate at server.ts matches two raw literals (UserPromptSubmit / SessionStart), which is why providers whose boundary event is named before_agent_start, BeforeAgent, agent.start, or beforeSubmitPrompt never un-retire a pane — the defect fix(agent-hooks): reopen a retired pane on any provider's turn boundary (#12686) #14626 fixed one instance of. Reusing the existing classifier means the target architecture cannot re-create that bug at consumers. A test mutation that swaps isNewTurnEvent for the two literals fails exactly those four providers.
  • kind: 'identity-only' for providerSessionOnly events. Those carry a state field but are resume-identity refreshes, not turn transitions — fix(stats): count agent sessions from hook transitions, not OSC titles (STA-2445) #14657 had to special-case them by hand.

The decay rule is written down at the type (agent-status-observation.ts). Both reviewers flagged it and neither original review caught it: staleness must be computed against the same authority clock that stamped observedAt, or replicas must decay on local receipt time. isExplicitAgentStatusFresh computes rendererNow − entry.updatedAt, and for a mirrored remote entry updatedAt is the host's clock. Declaring observedAt display-only does not fix that — the skew is in the subtraction, not the tiebreak. This PR does not fix it. It records the contract so the PR that moves the first consumer has something to be correct against.

Why

Two independent architecture reviews of this subsystem converged on the same root cause and the same first step. AgentStatusEntry has no provenance field, so it cannot say whether a row came from a hook, from OSC 9999, or from a terminal-title guess. Hook rows carry main's watermark-forced monotonic clock; byte-derived rows get the renderer's Date.now(). Both are arbitrated by a single strict < on updatedAt. Two clocks, one comparison, no tag — and every recurring bug class in this area traces back to it.

The joint recommendation was to introduce observation metadata first, as optional fields beside the existing scalar state, consumed by nobody, so the later work (one resolver, one consumer at a time, then deletions) has a foundation and each step can be checked in isolation.

This changes no behavior, is consumed by nothing, and exists so the NEXT PR can move one consumer at a time.

Deliberate non-scope, all later PRs: no consumer changes, no merge-point consolidation, no deletions, no change to what the host publishes to paired clients, no fix for the title-derived row whose fabricated entry.state contradicts its own row state (the origin: 'title' tag is precisely what makes that detectable).

Wire and compatibility

Per docs/reference/remote-wire-compatibility.md:

  • Optional field on existing JSON only. No new stream opcode. Old readers are untouched.
  • observation is not on AgentStatusPayload and is not copied by normalizeAgentStatusObject — a hook or OSC writer cannot declare its own provenance; only the ingress that accepted the event can stamp it.
  • Nothing changes about what the host publishes. pickParsedAgentStatusPayload and the session-tab mirror both pick fields explicitly, so observation never reaches a paired client. Changing that is a later, capability-negotiated PR.
  • Never persisted. It is excluded from PersistedAgentHookEventPayload, so last-status.json is byte-identical to today and a rehydrated row carries no ordering claim from a dead authority. (The persist path dedupes on exact JSON, so persisting it would also have meant a disk write per event.)
  • authorityId is regenerated per process instance. Revision counters live in memory, so a restarted authority must not be comparable with what it emitted before; a differing authorityId means incomparable, not "older", and consumers fall back to today's timestamp rule.
  • SSH / remote: the relay path (ingestRemote) is stamped by the local main that receives it, which is the same authority that already sequences those rows. Folder workspaces and git worktrees are identical here — the facet is pane-scoped, not worktree-scoped.

Linked Issue

STA-4293 — "Centralize and improve our agent status reporting code - right now it is pretty scattered, and flimsy". This is step 1 of N.

Fixes #

Visual Proof

N/A — there is no UI or behavior change. That is the claim this PR has to defend, and it is defended by tests rather than screenshots: agent-status-observation-neutrality.test.ts asserts that a stamped row and an unstamped row produce byte-identical output from sidebar rows, the card dot, smart-attention and the freshness gate, and that the store's agentStatusEpoch / sortEpoch tick identically (an extra epoch tick would be an extra render across every aggregate consumer — a behavior change with no visible diff).

Testing

Automated (all new suites green; the central one is a negative):

  • src/renderer/src/store/slices/agent-status-observation-neutrality.test.ts — the safety argument. For each of working | blocked | waiting | done: identical entries apart from the observation key, identical epochs, and identical output from isExplicitAgentStatusFresh, buildWorktreeAgentRows, getAgentDotState and resolveAttention, evaluated both fresh and past the staleness horizon. Plus: an entry with no observation resolves exactly as today (old hosts, persisted rehydration, title-derived and subagent rows all lack it), and an unstamped write never inherits the previous row's observation.
  • src/shared/agent-status-observation.test.ts — revision strictly increases per pane and across interleaved panes; incarnation bumps on rebind and never decreases after forget or cap eviction; revision survives eviction of 2,000 panes.
  • src/main/agent-hooks/server-observation-provenance.test.ts — origin per ingress (hook for HTTP/relay, osc for ingestTerminalStatus), snapshot for relay replay, identity-only for providerSessionOnly, boundary across five providers, revision monotonic, incarnation bumped when a retired pane restarts, and nothing written to last-status.json.
  • src/renderer/src/lib/renderer-agent-status-observation-ingress.test.ts — title rows tagged title under a fixed projection authority and deterministic in now (a counter there would churn a new revision per render and break memoization); renderer-parsed OSC tagged osc under a renderer: authority.
  • Existing suites updated where they asserted exact setAgentStatus payloads — those assertions now also pin the expected origin, which is extra ingress coverage rather than a loosened check.

Mutation-tested (each of these makes a specific test fail, so none of them is vacuous):

  • replacing isNewTurnEvent with the two gate literals → the four non-literal providers fail;
  • persisting observation → the last-status.json test fails;
  • inheriting existing.observation, or making observation sort-relevant in the store → the neutrality suite fails.

Suites run locally on macOS: src/main/agent-hooks/ (628), src/renderer/src/store/slices/ + src/renderer/src/components/sidebar/ (4,757), pty-connection.test.ts (579), plus the runtime/session-sync and launch suites — all green. tsc --noEmit clean for both the node and web projects. oxlint, the native and type-aware code-quality configs, lint-react-doctor-changed, and check:max-lines-ratchet all clean on the changed files.

Not tested on Linux/Windows/SSH hardware. There is no platform-dependent code in this change — no paths, no shortcuts, no shell invocation — and the SSH relay path is covered by the ingestRemote unit tests.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Review

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Security — the facet is stamped by the ingress, never read from a reported payload, so an OSC 9999 writer or a hook post cannot forge its own provenance. normalizeAgentStatusObject builds a fresh object from an explicit field list, which drops any observation a caller tries to send.
  • Cross-platform — no platform-dependent code.
  • Remote SSH — relay events are stamped by the receiving main, which is the authority that already sequences them. No wire change beyond an optional field.
  • Mobile / paired clients — nothing published to them changes; the session-tab mirror picks fields explicitly and does not carry observation.
  • Backwards compatibility — optional everywhere, absent from persistence, absent from old hosts; every consumer path is tested against an unstamped row.
  • Performance — one small object per accepted status event, plus one bounded (1,024-entry) per-pane map per authority. Title rows use a deterministic stamp rather than a counter specifically so re-derivation per render does not churn.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Author

  • X / Twitter: @BrennanKB5

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 65a22db2-8fe2-42b6-bb46-429cdae47fb5

📥 Commits

Reviewing files that changed from the base of the PR and between 60805f5 and a418c07.

📒 Files selected for processing (25)
  • src/main/agent-hooks/server-observation-provenance.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/index.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-command-status.test.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-command-status.ts
  • src/renderer/src/components/terminal-pane/pty-connection-hidden-output-restore.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-startup-command-delivery.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-task-complete-dispatch.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/lib/automation-session-observer.ts
  • src/renderer/src/lib/background-agent-status-consumer.ts
  • src/renderer/src/lib/command-code-prompt-status-seed.ts
  • src/renderer/src/lib/launch-agent-background-session.test.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.test.ts
  • src/renderer/src/lib/renderer-agent-status-observation-ingress.test.ts
  • src/renderer/src/lib/renderer-agent-status-observations.ts
  • src/renderer/src/store/slices/agent-status-observation-neutrality.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/agent-status-observation.test.ts
  • src/shared/agent-status-observation.ts
  • src/shared/agent-status-types.ts
🚧 Files skipped from review as they are similar to previous changes (25)
  • src/renderer/src/components/terminal-pane/pty-connection-startup-command-delivery.test.ts
  • src/main/index.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-command-status.test.ts
  • src/renderer/src/lib/launch-agent-background-session.test.ts
  • src/renderer/src/lib/renderer-agent-status-observations.ts
  • src/main/agent-hooks/server-observation-provenance.test.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.test.ts
  • src/renderer/src/lib/renderer-agent-status-observation-ingress.test.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-command-status.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/lib/automation-session-observer.ts
  • src/renderer/src/lib/background-agent-status-consumer.ts
  • src/shared/agent-hook-listener.ts
  • src/renderer/src/store/slices/agent-status-observation-neutrality.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-task-complete-dispatch.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-hidden-output-restore.test.ts
  • src/shared/agent-status-types.ts
  • src/shared/agent-status-observation.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/shared/agent-status-observation.test.ts
  • src/main/agent-hooks/server.ts
  • src/renderer/src/lib/command-code-prompt-status-seed.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

Adds agent-status observation provenance with origin, authority, incarnation, revision, timestamp, boundary, and kind metadata. Main-process ingress points stamp observations and forward them through IPC, while persistence excludes runtime metadata. Renderer status producers stamp launch, process, OSC, and title-derived observations. Pane lifecycle operations retire and rebind observation state. Tests cover sequencing, provenance, boundaries, persistence, renderer ingress, and observation-neutral store behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the feature, its scope, and the main change: stamping agent-status observation provenance and ordering.
Description check ✅ Passed The description is mostly complete and covers the change, rationale, testing, compatibility, review considerations, visual proof, and checklist.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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

🧹 Nitpick comments (1)
src/renderer/src/store/slices/agent-status.ts (1)

1483-1625: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add test coverage for forget/rebind on pane authority changes.

retireAgentPaneAuthority calls rendererAgentStatusObservations.forget for each retired alias. transferAgentPaneAuthority calls forget on the old key and rebind on the new key. No test in the reviewed files exercises this wiring.

Add a test that retires or transfers a pane, then observes the pane again through the sequencer, and checks that the resulting incarnation reflects the forget/rebind call.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 880a9ff5-8bb1-4ef6-a110-053f990c186e

📥 Commits

Reviewing files that changed from the base of the PR and between aaa877d and a5d9b2d.

📒 Files selected for processing (23)
  • src/main/agent-hooks/server-observation-provenance.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/index.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-command-status.test.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-command-status.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/lib/automation-session-observer.ts
  • src/renderer/src/lib/background-agent-status-consumer.ts
  • src/renderer/src/lib/command-code-prompt-status-seed.ts
  • src/renderer/src/lib/launch-agent-background-session.test.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.test.ts
  • src/renderer/src/lib/renderer-agent-status-observation-ingress.test.ts
  • src/renderer/src/lib/renderer-agent-status-observations.ts
  • src/renderer/src/store/slices/agent-status-observation-neutrality.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/agent-status-observation.test.ts
  • src/shared/agent-status-observation.ts
  • src/shared/agent-status-types.ts

Comment thread src/main/agent-hooks/server.ts Resolved
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/agent-status-provenance-sta4293 branch 2 times, most recently from b47792f to 1ee9033 Compare August 17, 2026 05:37
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agent-status-provenance-sta4293 branch from 1ee9033 to a418c07 Compare August 17, 2026 18:32
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status

State: MERGEABLE / CLEAN against main. CI green — 44 successful checks, 1 skipped, 0 failing. 25 files, +1144/-46 (15 prod / 10 test).

What this is, and what it deliberately is not. Step 1 of the STA-4293 agent-status architecture work. It adds an optional observation facet (origin, authorityId, incarnation, revision, observedAt, boundary?, kind?) and stamps it at every status ingress — provider hooks over loopback HTTP and over the SSH relay, main-parsed and renderer-parsed OSC 9999, Orca-launched agent seeds, Command Code output/prompt seeds, and title-derived sidebar rows.

Nothing reads it. There is no UI change, no behaviour change, and no consumer. Two independent architecture reviews converged on the same root cause — AgentStatusEntry has no provenance field, so hook rows carrying main's watermark-forced monotonic clock and byte-derived rows carrying the renderer's Date.now() are arbitrated by a single strict < on updatedAt, two clocks with one comparison and no tag — and on the same first step: land the metadata beside the existing scalar state, consumed by nobody, so each later consumer migration can be checked in isolation.

Validation — what was and was not done.

The load-bearing test is a negative: agent-status-observation-neutrality.test.ts asserts that for each of working | blocked | waiting | done, entries identical apart from the observation key produce byte-identical output from isExplicitAgentStatusFresh, buildWorktreeAgentRows, getAgentDotState and resolveAttention — evaluated both fresh and past the staleness horizon — and that the store's agentStatusEpoch / sortEpoch tick identically. That second half matters: an extra epoch tick would be an extra render across every aggregate consumer, a behaviour change with no visible diff. It also covers entries with no observation at all (old hosts, persisted rehydration, title-derived and subagent rows), and that an unstamped write never inherits the previous row's observation.

Mutation-tested, so none of it is vacuous: replacing isNewTurnEvent with the two gate literals fails exactly the four non-literal providers; persisting observation fails the last-status.json test; inheriting existing.observation or making it sort-relevant fails the neutrality suite.

Suites run locally on macOS: src/main/agent-hooks/ (628), store slices + sidebar (4,757), pty-connection.test.ts (579), plus runtime/session-sync and launch suites — all green. tsc --noEmit clean for both node and web projects. oxlint, both code-quality configs, React Doctor, and the max-lines ratchet clean.

Not done: no Linux, Windows, or SSH hardware. There is no platform-dependent code — no paths, shortcuts, or shell invocation — and the relay path is covered by ingestRemote unit tests only. No manual app-level verification beyond the automated neutrality argument; given that "no behaviour change" is the whole claim, the tests are the appropriate evidence, but they are the only evidence.

Rebase state — verified independently for this comment. The branch sits directly on top of #15082 (fix(agent-status): preserve restored child provenance, merged 2026-08-17), which is also provenance work in the same files — both touch src/main/agent-hooks/server.ts. I confirmed the branch is 1 ahead / 0 behind of #15082's merge commit, and that the observation stamp survives #15082's row handling: the stamp is applied last, at the enriched construction ({ ...this.attachStatusTiming(...), observation: this.stampObservation(...) }), and #15082's own row manipulation uses rest and object spreads (const { claudeLeadBoundaryChildOnly: _boundary, ...withoutBoundary } = previous, { ...next, … }) rather than a field-by-field rebuild, so an unknown observation key is carried through rather than dropped. This is source analysis of the merged result, not a runtime observation.

Known limits a reviewer should read before merging

  • The decay bug is documented, not fixed. isExplicitAgentStatusFresh computes rendererNow − entry.updatedAt, and for a mirrored remote entry updatedAt is the host's clock. Both reviewers flagged this and neither original review caught it. Declaring observedAt display-only does not fix it — the skew is in the subtraction, not the tiebreak. This PR writes the contract down at the type (agent-status-observation.ts) so the PR that moves the first consumer has something to be correct against. Anyone merging this should not expect cross-machine staleness to improve.
  • The title-derived row whose fabricated entry.state contradicts its own row state is not fixed either. The origin: 'title' tag is precisely what makes it detectable; that is the extent of it here.
  • Explicitly out of scope and deferred to later PRs: consumer changes, merge-point consolidation, deletions, and any change to what the host publishes to paired clients.

Wire / persistence. Optional field on existing JSON, no new stream opcode. observation is not on AgentStatusPayload and is not copied by normalizeAgentStatusObject, so a hook post or OSC 9999 writer cannot forge its own provenance — only the ingress that accepted the event can stamp it. Nothing published to paired clients changes: pickParsedAgentStatusPayload and the session-tab mirror pick fields explicitly, so observation never reaches a client. It is never persisted — excluded from PersistedAgentHookEventPayload, so last-status.json is byte-identical to today and a rehydrated row carries no ordering claim from a dead authority. authorityId is regenerated per process instance, and a differing authorityId means incomparable, not "older", with consumers falling back to today's timestamp rule.

Supersedes: nothing.

…ess (STA-4293)

Add an optional `observation` facet to agent status rows recording the origin
(hook | osc | title | process | launch | orchestration), the authority that
sequenced it, a per-pane incarnation, a monotonic revision, and the authority's
own clock. Stamp it at every ingress; no consumer reads it.

Boundary is stamped from the hook listener's existing per-provider
`isNewTurnEvent`, not a second list of event-name literals. Identity-only
(`providerSessionOnly`) rows are tagged `kind: 'identity-only'` so future
consumers do not each rediscover that they are not turn transitions.

The staleness-decay contract is documented at the type: staleness must be
computed against the same authority clock that stamped `observedAt`, or
replicas must decay on local receipt time. Not fixed here.

Behavior-neutral: optional field on existing JSON, never persisted, never
published to paired clients, and never inherited across writes.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agent-status-provenance-sta4293 branch from a418c07 to 3d04cf4 Compare August 18, 2026 00:10
@brennanb2025
brennanb2025 merged commit 26bdfc0 into main Aug 18, 2026
48 checks passed
brennanb2025 added a commit that referenced this pull request Aug 18, 2026
…as spawned into (STA-2069) (#14615)"

This reverts commit 15efc87.

The premise does not reproduce, the fix does not reach the failure that does,
and the correction it installs can misattribute status on a path that worked
before.

1. PREMISE FALSE. #14615 asserts Claude Code >= 2.1.206 hosts TUI sessions as
   workers under a shared daemon. On 2.1.233 `claude daemon status` reports
   "not running" while 69 interactive sessions are live, and all 68 running
   clients are direct children of their own pane's shell. Measured across the
   fleet: 68 distinct pane keys, ZERO collisions. The 19 keys with no live pane
   also have a dead ORCA_TERMINAL_HANDLE (pane closed, process outlived it).
   Terminals live under a *different* pane key: 0. Foreground attribution was
   never broken, so the correction has nothing to correct.

2. DOES NOT FIX THE REAL BUG. The failure #9236 describes is real but scoped to
   BACKGROUNDED sessions: a `--bg` / `/background` worker inherits the
   dispatching pane's whole ORCA_* set, and the hook script self-heals its
   endpoint while taking paneKey straight from ambient env, so the POST lands
   under the wrong pane. #14615 mints a binding only for launches Orca
   constructs, so a typed `claude --bg` produces none. That needs a `kind: "bg"`
   guard at ingest instead; #9236 is reopened for it.

3. INTRODUCES A MISATTRIBUTION. Bindings are created at two spawn sites and
   removed only on PTY death. A pane whose user exits Claude keeps its PTY, so
   the binding survives; resuming that session in another pane does not rebind
   (`--resume` is a session selector, so the pin declines), and
   resolveBoundPaneOverride then rewrites paneKey and tabId onto the ORIGINAL
   pane despite a correct posted key. That is the reported symptom, on a path
   that previously worked.

Kept #14706's observations.rebind() in the conflicting hunk — it postdates
#14615 and is not part of this revert; only #14615's comments were dropped and
the surviving rationale reworded to alias resolution, which is what actually
makes paneKey differ from envelope.paneKey now.
brennanb2025 added a commit that referenced this pull request Aug 18, 2026
…as spawned into (STA-2069) (#14615)" (#15295)

Reverts #14615. Its premise does not reproduce, it does not reach the failure that does, and the correction it installs can misattribute status on a path that worked before.

1. PREMISE FALSE. #14615 asserts Claude Code >= 2.1.206 hosts TUI sessions under a shared daemon. On 2.1.233 `claude daemon status` reports "not running" with 69 live interactive sessions, and every client is a direct child of its own pane's shell. Measured across the fleet: 68 distinct pane keys, zero collisions. Foreground attribution was never broken.

2. DOES NOT FIX THE REAL BUG. The failure in #9236 is real but scoped to BACKGROUNDED sessions, whose workers inherit the dispatching pane's whole ORCA_* set. #14615 mints a binding only for launches Orca constructs, so a typed `claude --bg` produces none. Fixed properly in #15304.

3. INTRODUCES A MISATTRIBUTION. Bindings are removed only on PTY death, and a user who exits Claude keeps the pane's PTY. Resuming that session in another pane does not rebind (`--resume` is a session selector, so the pin declines), and resolveBoundPaneOverride then rewrites paneKey and tabId onto the ORIGINAL pane despite a correct posted key. Demonstrated with a failing test against main; causation isolated to resolveBoundPaneOverride.

Kept #14706's observations.rebind() in the conflicting hunk — it postdates #14615 and is not part of this revert.
brennanb2025 added a commit that referenced this pull request Aug 19, 2026
…rn event

The un-retirement gate matched two raw event-name literals, UserPromptSubmit and
SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for
the rest a reused pane stayed rowless forever: the user starts a new turn and no
row ever appears in the sidebar or dashboard.

Measured, not estimated — 10 providers fail the new test on main: gemini
(BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor
(beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok
(user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call).

The gate was also wrong in the other direction: opencode has no turn boundary at
all, yet a literal SessionStart revived its pane. Both directions are covered.

The correct per-provider classifier, isNewTurnEvent, was already imported into
this file and already used 160 lines below — #14706 added that call specifically
so consumers would stop re-deriving boundaries from literals, and left this one.

Keeps the literal check when the remote envelope omits source: that field is
optional, an older relay does not send it, and requiring it would have left every
source-less remote pane retired forever.
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…ess (STA-4293) (stablyai#14706)

Add an optional `observation` facet to agent status rows recording the origin
(hook | osc | title | process | launch | orchestration), the authority that
sequenced it, a per-pane incarnation, a monotonic revision, and the authority's
own clock. Stamp it at every ingress; no consumer reads it.

Boundary is stamped from the hook listener's existing per-provider
`isNewTurnEvent`, not a second list of event-name literals. Identity-only
(`providerSessionOnly`) rows are tagged `kind: 'identity-only'` so future
consumers do not each rediscover that they are not turn transitions.

The staleness-decay contract is documented at the type: staleness must be
computed against the same authority clock that stamped `observedAt`, or
replicas must decay on local receipt time. Not fixed here.

Behavior-neutral: optional field on existing JSON, never persisted, never
published to paired clients, and never inherited across writes.
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…as spawned into (STA-2069) (stablyai#14615)" (stablyai#15295)

Reverts stablyai#14615. Its premise does not reproduce, it does not reach the failure that does, and the correction it installs can misattribute status on a path that worked before.

1. PREMISE FALSE. stablyai#14615 asserts Claude Code >= 2.1.206 hosts TUI sessions under a shared daemon. On 2.1.233 `claude daemon status` reports "not running" with 69 live interactive sessions, and every client is a direct child of its own pane's shell. Measured across the fleet: 68 distinct pane keys, zero collisions. Foreground attribution was never broken.

2. DOES NOT FIX THE REAL BUG. The failure in stablyai#9236 is real but scoped to BACKGROUNDED sessions, whose workers inherit the dispatching pane's whole ORCA_* set. stablyai#14615 mints a binding only for launches Orca constructs, so a typed `claude --bg` produces none. Fixed properly in stablyai#15304.

3. INTRODUCES A MISATTRIBUTION. Bindings are removed only on PTY death, and a user who exits Claude keeps the pane's PTY. Resuming that session in another pane does not rebind (`--resume` is a session selector, so the pin declines), and resolveBoundPaneOverride then rewrites paneKey and tabId onto the ORIGINAL pane despite a correct posted key. Demonstrated with a failing test against main; causation isolated to resolveBoundPaneOverride.

Kept stablyai#14706's observations.rebind() in the conflicting hunk — it postdates stablyai#14615 and is not part of this revert.
brennanb2025 added a commit that referenced this pull request Aug 23, 2026
…rn event (#15344)

* fix(agent-hooks): revive a retired pane on each provider's own new-turn event

The un-retirement gate matched two raw event-name literals, UserPromptSubmit and
SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for
the rest a reused pane stayed rowless forever: the user starts a new turn and no
row ever appears in the sidebar or dashboard.

Measured, not estimated — 10 providers fail the new test on main: gemini
(BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor
(beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok
(user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call).

The gate was also wrong in the other direction: opencode has no turn boundary at
all, yet a literal SessionStart revived its pane. Both directions are covered.

The correct per-provider classifier, isNewTurnEvent, was already imported into
this file and already used 160 lines below — #14706 added that call specifically
so consumers would stop re-deriving boundaries from literals, and left this one.

Keeps the literal check when the remote envelope omits source: that field is
optional, an older relay does not send it, and requiring it would have left every
source-less remote pane retired forever.

* fix(agent-hooks): tell an absent source apart from an unrecognized one

Review of the first commit found that `isAgentHookSource(envelope.source) ?
envelope.source : undefined` collapses two different wire conditions into one:
an older relay that omits `source`, and a NEWER host relaying a provider this
build does not know. They need opposite answers.

Case two is the normal upgrade order — hosts and clients update independently —
and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of
the 18 providers we already ship are named something else. So the legacy-literal
fallback stranded that provider's panes permanently: the exact defect this branch
fixes, silently reintroduced for traffic our own wire doctrine calls normal.

Pass the raw wire value so the gate can distinguish them, and fail OPEN on an
unrecognized provider. The costs are asymmetric: a stranded pane is invisible,
permanent, and has no user-facing recovery, while a spurious revive produces a
row that decays after AGENT_STATUS_STALE_AFTER_MS.

Also from review:
- Cover the source-less branches, which had no coverage at all — including a test
  pinning what the legacy shim CANNOT do, so nobody later widens the literal list
  to "fix" it.
- Use the source as agentType rather than always 'claude'; 15 of 16 rows were
  describing a state that cannot occur.
- Reword the opencode comment: no plugin in that family emits these literals, so
  this closes a hole rather than removing behavior.

Checked and not changed: the local HTTP path 404s an unresolvable source, so the
fallback is unreachable there and masks nothing.

* test(agent-hooks): stop pinning opencode's fence behavior on a synthetic event

The negative case asserted that an opencode pane stays retired after a literal
SessionStart. That rests on a false premise: origin/main's opencode plugin never
emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the
shared family source is what mimo-code uses too. So the assertion pinned an event
no plugin sends, and it would have become actively wrong the moment a pending
change gives opencode a real SessionStart, silently re-breaking the rowless
reused-pane case that change exists to fix.

Assert against mimo-code and command-code instead. Both genuinely have no
boundary event in any planned state, so the case tests what it claims to.

* fix(agent-hooks): reject malformed relay sources at retired fence

Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn.
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 25, 2026
…rn event (stablyai#15344)

* fix(agent-hooks): revive a retired pane on each provider's own new-turn event

The un-retirement gate matched two raw event-name literals, UserPromptSubmit and
SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for
the rest a reused pane stayed rowless forever: the user starts a new turn and no
row ever appears in the sidebar or dashboard.

Measured, not estimated — 10 providers fail the new test on main: gemini
(BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor
(beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok
(user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call).

The gate was also wrong in the other direction: opencode has no turn boundary at
all, yet a literal SessionStart revived its pane. Both directions are covered.

The correct per-provider classifier, isNewTurnEvent, was already imported into
this file and already used 160 lines below — stablyai#14706 added that call specifically
so consumers would stop re-deriving boundaries from literals, and left this one.

Keeps the literal check when the remote envelope omits source: that field is
optional, an older relay does not send it, and requiring it would have left every
source-less remote pane retired forever.

* fix(agent-hooks): tell an absent source apart from an unrecognized one

Review of the first commit found that `isAgentHookSource(envelope.source) ?
envelope.source : undefined` collapses two different wire conditions into one:
an older relay that omits `source`, and a NEWER host relaying a provider this
build does not know. They need opposite answers.

Case two is the normal upgrade order — hosts and clients update independently —
and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of
the 18 providers we already ship are named something else. So the legacy-literal
fallback stranded that provider's panes permanently: the exact defect this branch
fixes, silently reintroduced for traffic our own wire doctrine calls normal.

Pass the raw wire value so the gate can distinguish them, and fail OPEN on an
unrecognized provider. The costs are asymmetric: a stranded pane is invisible,
permanent, and has no user-facing recovery, while a spurious revive produces a
row that decays after AGENT_STATUS_STALE_AFTER_MS.

Also from review:
- Cover the source-less branches, which had no coverage at all — including a test
  pinning what the legacy shim CANNOT do, so nobody later widens the literal list
  to "fix" it.
- Use the source as agentType rather than always 'claude'; 15 of 16 rows were
  describing a state that cannot occur.
- Reword the opencode comment: no plugin in that family emits these literals, so
  this closes a hole rather than removing behavior.

Checked and not changed: the local HTTP path 404s an unresolvable source, so the
fallback is unreachable there and masks nothing.

* test(agent-hooks): stop pinning opencode's fence behavior on a synthetic event

The negative case asserted that an opencode pane stays retired after a literal
SessionStart. That rests on a false premise: origin/main's opencode plugin never
emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the
shared family source is what mimo-code uses too. So the assertion pinned an event
no plugin sends, and it would have become actively wrong the moment a pending
change gives opencode a real SessionStart, silently re-breaking the rowless
reused-pane case that change exists to fix.

Assert against mimo-code and command-code instead. Both genuinely have no
boundary event in any planned state, so the case tests what it claims to.

* fix(agent-hooks): reject malformed relay sources at retired fence

Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn.

(cherry picked from commit d1127b9)
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…ess (STA-4293) (stablyai#14706)

Add an optional `observation` facet to agent status rows recording the origin
(hook | osc | title | process | launch | orchestration), the authority that
sequenced it, a per-pane incarnation, a monotonic revision, and the authority's
own clock. Stamp it at every ingress; no consumer reads it.

Boundary is stamped from the hook listener's existing per-provider
`isNewTurnEvent`, not a second list of event-name literals. Identity-only
(`providerSessionOnly`) rows are tagged `kind: 'identity-only'` so future
consumers do not each rediscover that they are not turn transitions.

The staleness-decay contract is documented at the type: staleness must be
computed against the same authority clock that stamped `observedAt`, or
replicas must decay on local receipt time. Not fixed here.

Behavior-neutral: optional field on existing JSON, never persisted, never
published to paired clients, and never inherited across writes.
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…as spawned into (STA-2069) (stablyai#14615)" (stablyai#15295)

Reverts stablyai#14615. Its premise does not reproduce, it does not reach the failure that does, and the correction it installs can misattribute status on a path that worked before.

1. PREMISE FALSE. stablyai#14615 asserts Claude Code >= 2.1.206 hosts TUI sessions under a shared daemon. On 2.1.233 `claude daemon status` reports "not running" with 69 live interactive sessions, and every client is a direct child of its own pane's shell. Measured across the fleet: 68 distinct pane keys, zero collisions. Foreground attribution was never broken.

2. DOES NOT FIX THE REAL BUG. The failure in stablyai#9236 is real but scoped to BACKGROUNDED sessions, whose workers inherit the dispatching pane's whole ORCA_* set. stablyai#14615 mints a binding only for launches Orca constructs, so a typed `claude --bg` produces none. Fixed properly in stablyai#15304.

3. INTRODUCES A MISATTRIBUTION. Bindings are removed only on PTY death, and a user who exits Claude keeps the pane's PTY. Resuming that session in another pane does not rebind (`--resume` is a session selector, so the pin declines), and resolveBoundPaneOverride then rewrites paneKey and tabId onto the ORIGINAL pane despite a correct posted key. Demonstrated with a failing test against main; causation isolated to resolveBoundPaneOverride.

Kept stablyai#14706's observations.rebind() in the conflicting hunk — it postdates stablyai#14615 and is not part of this revert.
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…rn event (stablyai#15344)

* fix(agent-hooks): revive a retired pane on each provider's own new-turn event

The un-retirement gate matched two raw event-name literals, UserPromptSubmit and
SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for
the rest a reused pane stayed rowless forever: the user starts a new turn and no
row ever appears in the sidebar or dashboard.

Measured, not estimated — 10 providers fail the new test on main: gemini
(BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor
(beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok
(user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call).

The gate was also wrong in the other direction: opencode has no turn boundary at
all, yet a literal SessionStart revived its pane. Both directions are covered.

The correct per-provider classifier, isNewTurnEvent, was already imported into
this file and already used 160 lines below — stablyai#14706 added that call specifically
so consumers would stop re-deriving boundaries from literals, and left this one.

Keeps the literal check when the remote envelope omits source: that field is
optional, an older relay does not send it, and requiring it would have left every
source-less remote pane retired forever.

* fix(agent-hooks): tell an absent source apart from an unrecognized one

Review of the first commit found that `isAgentHookSource(envelope.source) ?
envelope.source : undefined` collapses two different wire conditions into one:
an older relay that omits `source`, and a NEWER host relaying a provider this
build does not know. They need opposite answers.

Case two is the normal upgrade order — hosts and clients update independently —
and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of
the 18 providers we already ship are named something else. So the legacy-literal
fallback stranded that provider's panes permanently: the exact defect this branch
fixes, silently reintroduced for traffic our own wire doctrine calls normal.

Pass the raw wire value so the gate can distinguish them, and fail OPEN on an
unrecognized provider. The costs are asymmetric: a stranded pane is invisible,
permanent, and has no user-facing recovery, while a spurious revive produces a
row that decays after AGENT_STATUS_STALE_AFTER_MS.

Also from review:
- Cover the source-less branches, which had no coverage at all — including a test
  pinning what the legacy shim CANNOT do, so nobody later widens the literal list
  to "fix" it.
- Use the source as agentType rather than always 'claude'; 15 of 16 rows were
  describing a state that cannot occur.
- Reword the opencode comment: no plugin in that family emits these literals, so
  this closes a hole rather than removing behavior.

Checked and not changed: the local HTTP path 404s an unresolvable source, so the
fallback is unreachable there and masks nothing.

* test(agent-hooks): stop pinning opencode's fence behavior on a synthetic event

The negative case asserted that an opencode pane stays retired after a literal
SessionStart. That rests on a false premise: origin/main's opencode plugin never
emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the
shared family source is what mimo-code uses too. So the assertion pinned an event
no plugin sends, and it would have become actively wrong the moment a pending
change gives opencode a real SessionStart, silently re-breaking the rowless
reused-pane case that change exists to fix.

Assert against mimo-code and command-code instead. Both genuinely have no
boundary event in any planned state, so the case tests what it claims to.

* fix(agent-hooks): reject malformed relay sources at retired fence

Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ess (STA-4293) (stablyai#14706)

Add an optional `observation` facet to agent status rows recording the origin
(hook | osc | title | process | launch | orchestration), the authority that
sequenced it, a per-pane incarnation, a monotonic revision, and the authority's
own clock. Stamp it at every ingress; no consumer reads it.

Boundary is stamped from the hook listener's existing per-provider
`isNewTurnEvent`, not a second list of event-name literals. Identity-only
(`providerSessionOnly`) rows are tagged `kind: 'identity-only'` so future
consumers do not each rediscover that they are not turn transitions.

The staleness-decay contract is documented at the type: staleness must be
computed against the same authority clock that stamped `observedAt`, or
replicas must decay on local receipt time. Not fixed here.

Behavior-neutral: optional field on existing JSON, never persisted, never
published to paired clients, and never inherited across writes.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…as spawned into (STA-2069) (stablyai#14615)" (stablyai#15295)

Reverts stablyai#14615. Its premise does not reproduce, it does not reach the failure that does, and the correction it installs can misattribute status on a path that worked before.

1. PREMISE FALSE. stablyai#14615 asserts Claude Code >= 2.1.206 hosts TUI sessions under a shared daemon. On 2.1.233 `claude daemon status` reports "not running" with 69 live interactive sessions, and every client is a direct child of its own pane's shell. Measured across the fleet: 68 distinct pane keys, zero collisions. Foreground attribution was never broken.

2. DOES NOT FIX THE REAL BUG. The failure in stablyai#9236 is real but scoped to BACKGROUNDED sessions, whose workers inherit the dispatching pane's whole ORCA_* set. stablyai#14615 mints a binding only for launches Orca constructs, so a typed `claude --bg` produces none. Fixed properly in stablyai#15304.

3. INTRODUCES A MISATTRIBUTION. Bindings are removed only on PTY death, and a user who exits Claude keeps the pane's PTY. Resuming that session in another pane does not rebind (`--resume` is a session selector, so the pin declines), and resolveBoundPaneOverride then rewrites paneKey and tabId onto the ORIGINAL pane despite a correct posted key. Demonstrated with a failing test against main; causation isolated to resolveBoundPaneOverride.

Kept stablyai#14706's observations.rebind() in the conflicting hunk — it postdates stablyai#14615 and is not part of this revert.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…rn event (stablyai#15344)

* fix(agent-hooks): revive a retired pane on each provider's own new-turn event

The un-retirement gate matched two raw event-name literals, UserPromptSubmit and
SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for
the rest a reused pane stayed rowless forever: the user starts a new turn and no
row ever appears in the sidebar or dashboard.

Measured, not estimated — 10 providers fail the new test on main: gemini
(BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor
(beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok
(user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call).

The gate was also wrong in the other direction: opencode has no turn boundary at
all, yet a literal SessionStart revived its pane. Both directions are covered.

The correct per-provider classifier, isNewTurnEvent, was already imported into
this file and already used 160 lines below — stablyai#14706 added that call specifically
so consumers would stop re-deriving boundaries from literals, and left this one.

Keeps the literal check when the remote envelope omits source: that field is
optional, an older relay does not send it, and requiring it would have left every
source-less remote pane retired forever.

* fix(agent-hooks): tell an absent source apart from an unrecognized one

Review of the first commit found that `isAgentHookSource(envelope.source) ?
envelope.source : undefined` collapses two different wire conditions into one:
an older relay that omits `source`, and a NEWER host relaying a provider this
build does not know. They need opposite answers.

Case two is the normal upgrade order — hosts and clients update independently —
and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of
the 18 providers we already ship are named something else. So the legacy-literal
fallback stranded that provider's panes permanently: the exact defect this branch
fixes, silently reintroduced for traffic our own wire doctrine calls normal.

Pass the raw wire value so the gate can distinguish them, and fail OPEN on an
unrecognized provider. The costs are asymmetric: a stranded pane is invisible,
permanent, and has no user-facing recovery, while a spurious revive produces a
row that decays after AGENT_STATUS_STALE_AFTER_MS.

Also from review:
- Cover the source-less branches, which had no coverage at all — including a test
  pinning what the legacy shim CANNOT do, so nobody later widens the literal list
  to "fix" it.
- Use the source as agentType rather than always 'claude'; 15 of 16 rows were
  describing a state that cannot occur.
- Reword the opencode comment: no plugin in that family emits these literals, so
  this closes a hole rather than removing behavior.

Checked and not changed: the local HTTP path 404s an unresolvable source, so the
fallback is unreachable there and masks nothing.

* test(agent-hooks): stop pinning opencode's fence behavior on a synthetic event

The negative case asserted that an opencode pane stays retired after a literal
SessionStart. That rests on a false premise: origin/main's opencode plugin never
emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the
shared family source is what mimo-code uses too. So the assertion pinned an event
no plugin sends, and it would have become actively wrong the moment a pending
change gives opencode a real SessionStart, silently re-breaking the rowless
reused-pane case that change exists to fix.

Assert against mimo-code and command-code instead. Both genuinely have no
boundary event in any planned state, so the case tests what it claims to.

* fix(agent-hooks): reject malformed relay sources at retired fence

Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn.
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