Skip to content

refactor(ui): retire the Agent Detail voice overlay — Talk is a door into the Workspace call (#2559) - #2606

Merged
vybe merged 17 commits into
devfrom
AndriiPasternak31/issue-2559
Sep 9, 2026
Merged

vybe merged 17 commits into
devfrom
AndriiPasternak31/issue-2559

Conversation

@AndriiPasternak31

@AndriiPasternak31 AndriiPasternak31 commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2559

Merge-order prerequisites are on dev; human sign-off is done

Step 7 of 7 (LAST) of the Workspace sequence. Nothing follows.

Merge order — satisfied. trinity#2582 + ent#548 landed as #2608 (merged into dev 2026-09-08); this branch is merged up onto a dev that contains it. ent#535 was unclaimed and released to the pool, so it is no longer a prerequisite.

Human sign-off — done. A real spoken call was placed against this branch on a keyed stack on 2026-09-08 (Talk → Workspace in the same tab, audible replies, a follow-up, end-call, transcript surviving a refresh, and a pasted ?voice=1 starting nothing). Sign-off comment. The two automated @interactive Playwright cases remain unrun — they need a keyed stack and a microphone.

Precondition: ent#534 must be deployed and exercised — this PR removes the only fallback voice front door.

No submodule pointer bump. The .claude gitlink matches dev's (584a70d). The two test-catalog doc commits that had bumped it now ride trinity-dev#22.

What this does

ent#534 put the real-time call inside the Workspace conversation. What was left on Agent Detail was a second front door with a second transcript home (chat_messages.source='voice'), its own context injection and its own per-agent /voice/status probe — the parallel-surface confusion #2484 removed, quietly reintroduced.

This retires that surface and replaces it with a door:

  • ChatPanel loses the VoiceOverlay mount, the useVoiceSession wiring, the availability fetch, and the overlay's Escape claim.
  • ChatInput loses the composer mic and its voiceAvailable/voiceActive props and voice emit.
  • AgentHeader gains Talk beside Workspace → router.push('/workspace?agent=<name>&voice=1'), same tab, so the navigation is same-document and the AudioContext stays resumable.
  • Ungated on purpose. The door's gate and the destination's gate are the same two booleans, so a gate buys nothing and costs a cold-load pop-in plus a sticky-false hide on a failed flags fetch. The Workspace reports availability in words instead — ent#438's ruling, applied consistently. The now-dead voiceAvailable prop is deleted, not given an artificial consumer.
  • ?voice=1 is an armed one-shot: armVoiceAutoStart() sets a module-scoped flag before the push, and voiceAutoStart() requires armed + landed + platform principal — so a pasted, bookmarked or mailed link (always a fresh document) never starts a billed call. navigator.userActivation was considered and rejected: it is an audio-playback heuristic, not a provenance check, and Portal.vue skips bootstrap() while signed out, so a pasted link survives unconsumed until exactly the sign-in click that would satisfy it.
  • The strip is one site, every exit — bootstrap()'s finally, keyed on the key's presence.

Nothing on the backend was deleted

/voice/start, /voice/stop and /voice/status all stay — now caller-less from the first-party frontend, test-pinned, with retirement left as a follow-up. _save_transcript stays. Historic Agent Detail voice rows keep their badge (source: msg.source || 'text' is preserved and pinned). Proof: pytest test_voice_auth + test_1076_voice_model_config + test_voice_tools + test_ent534_workspace_voice + test_ent279_scrub_parity → 131 passed.

Grep proof — consumers before → after (src/frontend/src)

### useVoiceSession
BEFORE (c04750e73):                          AFTER (HEAD):
  ChatPanel.vue:183  import …                  PortalConversation.vue:663  import …
  ChatPanel.vue:208  const voice = …           PortalConversation.vue:2026 const voice = …
  PortalConversation.vue:663  import …         composables/useVoiceSession.js:40  export function …
  PortalConversation.vue:2024 const voice = …
  composables/useVoiceSession.js:34  export function …

### VoiceOverlay
BEFORE (c04750e73):                          AFTER (HEAD):
  ChatPanel.vue:147  <VoiceOverlay             PortalConversation.vue:244  <VoiceOverlay :voice="voice" @end="endVoiceCall" />
  ChatPanel.vue:180  import VoiceOverlay       PortalConversation.vue:662  import VoiceOverlay
  PortalConversation.vue:244  <VoiceOverlay
  PortalConversation.vue:662  import VoiceOverlay

### voice/status   (the retired per-agent probe)
BEFORE:  ChatPanel.vue:215                     AFTER:  (none)

### voice/start
BEFORE:  useVoiceSession.js:80                 AFTER:  stores/clientPortal.js:1048   ← Workspace only
         stores/clientPortal.js:1048

### voiceAvailable / voice_available
BEFORE (c04750e73):                          AFTER (HEAD):
  AgentHeader.vue:657   prop                    stores/sessions.js:52,129,155   (store flag — writes only)
  ChatPanel.vue:161,209,218,220                 views/AgentBrainOrb.vue:113     (reads brainOrbVoiceAvailable — a different field)
  ChatInput.vue:168,286
  stores/sessions.js:52,122,148
  AgentBrainOrb.vue:113
  AgentDetail.vue:112

After: VoiceOverlay + useVoiceSession have exactly one consumer — PortalConversation.vue. /voice/status has zero. stores/sessions.js::voiceAvailable now has zero readers in src/ (bundled into the caller-less-routes follow-up).

Verification

Check Result
npm run test:unit 102 files / 2276 passed
Playwright @smoke for this spec, no fixture agent (the CI condition) 6 passed
Playwright — the entire @smoke suite, live stack on this branch 76 passed / 9 skipped / 0 failed
pytest backend voice suites (nothing deleted) 131 passed
/verify-local --skip-agent --skip-unit PASS — build+import-smoke, boot+health, integration 70 passed
Raw-color + loading-gate ratchets no growth (semantic_tokens 3969→3975)
CI e2e job on this PR 77 passed / 7 skipped — and the dev baseline run also skips 7, so the 5 new @smoke cases added zero skips. Had they stayed fixture-gated, CI would report 12 skipped. That is the proof the tier actually runs in CI, not just in a local simulation of it

/verify-local proves nothing about this change and is not offered as evidence for it — it is structurally blind to src/frontend/: it never serves Vue and never runs Playwright. It was run for completeness. Its unit stage showed 7 failures, all the documented pre-existing set (test_736_a2a_outbound_edges ×5 + test_ent399_ipv6_origin ×2 — an IPv4-mapped-::ffff: rendering difference in the py3.12 verify venv), with zero overlap with this branch.

The e2e tier was inert, and that was found by running it

playwright --list had reported all 7 cases present. Against a live stack the @smoke tier turned out never to execute in CI, for three stacked reasons — all measured, none inferred:

  1. A file-level #2199 existence probe skipped all five cases, because frontend-e2e.yml pins the e2e baseline at zero user agents on purpose. Playwright prints that as skipped inside a green run.
  2. CI bootstraps the admin from ADMIN_PASSWORD and flips setup_completed by docker exec — that user has no email, and client_portal/portal_auth.py:147 403s a platform principal without one. The roster is empty and the door lands on "You don't have access".
  3. Even with the roster stubbed, no call: startVoiceCall opens a thread before the first word (PortalConversation.vue:2087-2093) and its failure branch returns without reaching voice.startWith.

The @smoke tier is now hermetic on a synthetic agent (the workspace-code-blocks.spec.js pattern), and the probe moved inside @interactive — the rule workspace-absorbs-session.spec.js:30-32 already states in prose. Falsified by mutation: dropping armVoiceAutoStart(), dropping the conversationRef.value?.startVoiceCall?.() hand-off, and removing startVoiceCall from defineExpose each turn it red. The third is the rebase break the spec exists to catch — it could not have caught it while it skipped.

Docs

Requirements (runtimes.md VOICE-004/003/001/006/008/010, public-access.md §48.3, core-agent.md §5.14) · architecture (frontend.md, workspace.md, observability.md, api-endpoints.md) · feature flows (voice-chat.md, workspace-voice-conversation.md, agent-canvas.md, chat-turn-cancellation.md + index row) · user docs · CSO diff audit · two learnings.md entries.

Before merge

🤖 Generated with Claude Code

AndriiPasternak31 and others added 14 commits September 7, 2026 22:49
…2559)

Requirements first, per Rule of Engagement #1.

VOICE-004 is rewritten: the orb has one consumer (the Workspace conversation);
Agent Detail offers a door, not a surface — an ungated `Talk` button in
`AgentHeader` that navigates to `/workspace?agent=<name>&voice=1`. Ungated
because the door's gate and the destination's gate are the same two booleans
(`VOICE_ENABLED` and a provider key), so gating the door buys nothing and costs
a cold-load pop-in; the Workspace already says in words why a call cannot start.

VOICE-003 keeps its write path but records that it has no first-party caller
after this change, and that historic `chat_messages` rows keep their badge.
VOICE-001/VOICE-006 gain a scoping clause naming the OSS start route against the
Workspace's own. VOICE-008 is marked retired (#2484). VOICE-010 gains the
`?voice=1` entry contract — an intent armed IN THE APP, never by the URL alone.

public-access.md §48.3 gains FR-1b (the same contract, from the destination's
side) and FR-7 stops calling the orb "the Agent Detail overlay".
core-agent.md's Escape ownership list drops the overlay from Agent Detail.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
…#2559)

frontend.md (the map row that owns `src/frontend/src/**`) gains the paragraph:
VoiceOverlay + useVoiceSession are mounted only by PortalConversation; Agent
Detail's affordance is an ungated Talk button pushing `?voice=1`; and the
one-shot rule — armed in the app, stripped once in `bootstrap()`'s finally —
lives as a pure function in portalVoiceMode.js, with the reason a browser
activation heuristic cannot replace it.

workspace.md stops calling the orb "the Agent Detail orb". observability.md's
ent#438 knock-on re-points at the caller that actually passes `workspace_mode`
now (`client_portal/voice.py::start_workspace_voice`), which is what keeps the
Canvas tab drawing for calls started through the door. api-endpoints.md records
that `/voice/start|stop|status` have no first-party frontend caller after this
change, that they are kept and test-pinned, and which voice routes both start
paths still share.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
…#2559)

voice-chat.md loses two architecture diagrams that described surfaces which no
longer exist — the Agent Detail chat-tab overlay (retired here) and the
standalone `/agents/:name/workspace` page (retired by #2484 and still documented
three releases later) — replaced by one "Front doors" section. The User Flow is
rewritten around the door and the Workspace's own Call control, the ending
section says where the transcript actually lands, and the feature-flag section
explains why the door is UNGATED: `voice_available`, the roster's
`realtime_voice` and the retired `/voice/status` probe are three spellings of
the same two booleans, so a gate on the door buys nothing and costs a cold-load
pop-in plus a sticky-false hide.

workspace-voice-conversation.md gains the `?voice=1` entry contract beside the
entry control. agent-canvas.md re-points the `workspace_mode` caller at the
Workspace call, which is what keeps the Canvas tab drawing for calls started
through the door. chat-turn-cancellation.md shrinks ChatPanel's overlay list.
feature-flows.md gets the index row and the dated changelog entry.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
…is gone (#2559)

Every user-facing instruction told people to click a microphone beside the chat
input, which after this change is not there. `advanced/voice-chat.md` leads with
the two ways in (Talk on the agent's page, the Voice control in the Workspace),
says plainly that the agent's Chat tab is text only and that older voice
transcripts stay where they are, and explains why Talk is never hidden — hiding
it would make a working feature vanish whenever the flag has not loaded or its
fetch failed, indistinguishable from "this instance has no voice". The API table
marks `/voice/start|stop|status` as retained for API clients but no longer
called by Trinity's own UI.

The two FAQ answers are re-pointed, "Why don't I see the microphone button"
becomes "I clicked Talk and the call didn't start", and "What is Workspace
Mode?" becomes "What happened to Workspace Mode?" — the page it described was
retired by #2484 and the answer still promised it. faq/README.md's index rows
follow both renames. sharing-and-access/workspace.md inverts its stale
"not to be confused with" note: the Workspace is where voice lives now.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
ChatPanel loses the `VoiceOverlay` mount, the `useVoiceSession` wiring, the
per-agent `GET /voice/status` probe and its two call sites, the overlay's claim
on Escape, and the unmount `voice.stop()`. ChatInput loses the composer mic
button, its `voiceAvailable`/`voiceActive` props and the `voice` emit —
`PublicChat.vue`, the other ChatInput consumer, passes none of them.

`source: msg.source || 'text'` stays in `loadSession`, and `ChatBubble.vue` is
deliberately untouched: historic voice rows in these chats keep rendering with
their badge. Only the ability to create new ones here goes.

`useVoiceSession` loses `start()` — it hardcoded the OSS route and ChatPanel was
its only caller — AND its entry in the returned object. That second half is the
whole edit: `start, startWith, stop, …` is shorthand, so deleting the function
alone would throw `ReferenceError: start is not defined` at setup in EVERY
`useVoiceSession(...)` call, including `PortalConversation.vue` — the Workspace
conversation this change hands off to. It would have shipped green: src/frontend
has no lint script and no eslint config, Rollup does not error on an unresolved
shorthand, and no vitest spec imports the module (they read it as text). Pinned
in the guard spec that follows.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
…2559)

`AgentHeader` gains a Talk button beside Workspace: `armVoiceAutoStart()` then
`router.push('/workspace?agent=<name>&voice=1')`. Same tab on purpose — the
navigation is same-document, which is what carries the module-scoped one-shot to
the Workspace (a new tab is a fresh document, where it is false by construction)
and what keeps the AudioContext resumable from the click that started the call.

Ungated, with the reason in the template: the flag this page could gate on is
the same boolean the Workspace itself checks, so a gate buys nothing and costs a
cold-load pop-in plus a sticky-false hide on a failed flags fetch. The knock-on
is a deletion, not an invention — `AgentHeader`'s `voiceAvailable` prop has been
dead since ent#438, so it goes rather than being handed an artificial consumer,
and `AgentDetail` stops passing it.

`portalVoiceMode.js` gains the rule as pure functions: `VOICE_QUERY_KEY`,
`voiceQueryRequested`, the armed flag (`armVoiceAutoStart` / `disarmVoiceAutoStart`
/ `voiceAutoStartArmed`) and `voiceAutoStart`, which requires armed AND landed
AND a platform principal. `navigator.userActivation` is deliberately not used:
it is an audio-playback heuristic, not a provenance check, and `Portal.vue`
skips `bootstrap()` while signed out — so a pasted link survives unconsumed
until exactly the sign-in click that would satisfy it. sessionStorage was
rejected for surviving a reload; the module `let` dies with the document, which
is the semantics wanted, for free. `voice` joins `STAGE_QUERY_KEYS` so a
sign-out never carries the key into the next session.

`sessions.js::voiceAvailable` now has no reader in src/; kept with a comment
naming the follow-up, since the backend key still derives `workspace_available`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
…ry exit (#2559)

`Portal.vue` consumes the Talk door's intent. `resolveAgentQuery()` only RECORDS
it — at the top, before its own trailing `router.replace`, which is async and
rewrites `route.query` when it lands. `bootstrap()` owns everything else:

  - `pendingVoiceStart = false` at the top. The function is try/finally with no
    `catch`, so a throw runs the finally, propagates, and skips the consume — a
    stale `true` would make the NEXT bootstrap (continueAsOperator, onVerify)
    start a billed call nobody asked for, with the URL already stripped so
    nothing on screen explains it. Latent today, since fetchRoster and
    refreshThreads carry `.catch` — but `decorate()` and `seedAgentRecency()` do
    not.
  - the query key is read BEFORE the first await, and stripped ONCE in the
    `finally`, keyed on the key's PRESENCE rather than its value. Three
    per-branch strip sites would have missed the `/workspace/c/:sid` early
    return, the no-`?agent=` fall-through and a throw; keying on the value would
    leave `?voice=0` resident, which now also matters because `voice` is a
    `STAGE_QUERY_KEYS` member and a residual key makes `shouldEscapeStage`
    navigate spuriously.
  - the hand-off runs after the try/finally, one `nextTick` after the ref is
    assigned in the same patch as `bootstrapResolved`.

`PortalConversation` exposes `startVoiceCall` alongside `focusComposer`, and
`Portal.vue`'s `ref="conversationRef"` is that `defineExpose`'s first consumer —
nothing used `focusComposer`, so neither token is dead code now. Its header
comment stops calling the orb "Agent Detail's".

`npm run build` passes.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
New `agentDetailTalkDoor.spec.js` — the removal side, as source guards (vitest
runs environment:'node' with no mount harness). What must stay gone (the orb
mount, the session, the `/voice/status` probe, the mic and its props/emit), what
must NOT have gone with it (`source: msg.source || 'text'` and ChatBubble's
badge, so historic voice rows still render; PortalConversation's own mount of
the orb), and the door's properties: a stable test id, no `v-if`, no
`target="_blank"` — scoped to the Talk block, since the Git remote link in the
same header legitimately carries one — and no `voiceAvailable` prop.

The load-bearing case is `start,` absent from the composable's return object.
Nothing else in the suite catches that: it throws only at component setup, and
no spec imports the module.

`portalVoiceMode.spec.js` gains the rule tests — strict `'1'` parsing including
the repeated-key array, and `voiceAutoStart` refusing an otherwise perfect
request that was not armed, which is the regression test for the signed-out
pasted-link path — plus source pins for the hand-off: arm-before-push, record
without stripping, reset before the try, key read before the first await, one
strip in the finally, and no `navigator.userActivation` in any code path. Its
"the call is the Agent Detail orb" describe block is renamed; the claim is false
now even though its assertions still hold.

Two traps, both found by the tests failing on arrival rather than passing
vacuously:

  - The shared `stripComments` helper destroys `ChatInput.vue` — it contains
    `accept="image/*"`, whose `/*` opens a block comment that swallows 74% of
    the file including the `defineEmits` line. Masked, with the reason; and
    every stripped source in the new spec is now checked against a sentinel, so
    a future stripping change fails loudly instead of turning the absence
    assertions vacuous.
  - My first falsification harness shifted its args and re-read `$3`/`$4`, so
    all five mutations silently no-oped and every pin "passed". Redone: 12 of 12
    mutations now fail the right test, including reinstating `start,`.

`test_ent438_agent_canvas.py` is re-pointed rather than deleted — the property
(some live caller passes `workspace_mode`) is unchanged, only the caller moved
to `client_portal/voice.py::start_workspace_voice`. Its ChatPanel arm is
inverted, not dropped, so the retired front door cannot quietly return.

Evidence: `npm run test:unit` 102 files / 2276 tests passed;
pytest test_ent438_agent_canvas + test_voice_auth + test_1076_voice_model_config
+ test_voice_tools + test_ent534_workspace_voice + test_ent279_scrub_parity
= 54 + 131 passed (the "nothing on the backend was deleted" proof).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
…ne (#2559)

`.github/workflows/frontend-e2e.yml` runs `npm run test:e2e:smoke`
(`--grep @smoke`), so an `@interactive` case runs once on a laptop and never
again — and a source-grep spec cannot catch a sibling PR breaking `defineExpose`
on rebase. Five `@smoke` cases therefore carry the wiring: the click navigates,
the start request is ISSUED, the URL loses `voice=`, `/voice/status` is never
asked, Talk renders with the platform flag patched off (the ungated ruling), a
pasted `?voice=1` starts nothing, `?voice=0` and `/workspace/c/:sid?voice=1`
both leave a clean URL, and the composer has no mic.

Two traps closed by construction:

  - The roster is patched to `realtime_voice.available: true`. Without it the
    local stack (empty GEMINI_API_KEY) reports unavailable and `startVoiceCall`
    bails BEFORE `voice.startWith`, so "no start POST" would pass for a reason
    unrelated to the rule under test — a false green. The `@interactive` case
    additionally asserts the surfaced text is neither REASON_DISABLED nor
    REASON_NO_KEY.
  - The hand-off is `conversationRef.value?.startVoiceCall?.()`, which silently
    consumes the intent when the ref is null. So the test asserts the call was
    MADE, never merely that nothing threw.

Fixture handling follows the #2199 contract rather than convenience: default
`testfix`, the shared authenticated `agentExists` probe, definitive-404 skips
only. Defaulting to `trinity-system` is the exact anti-pattern that helper's
docstring names. The spec's header states the further need the probe does not
cover — the agent must be on the operator's Workspace roster.

`route.fetch()` has no precedent in this suite and the spec says so rather than
claiming one; `route.fulfill()` with a hand-built body is the house pattern.

`playwright --list` confirms 5 `@smoke` + 2 `@interactive`, and that `--grep
@smoke` selects exactly the five. README fixture table updated.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
…hat tab (#2559)

/sync-feature-flows sweep over every flow doc touching the changed surfaces.
Seven candidates beyond the five already updated; five needed nothing and two did:

`authenticated-chat-tab.md` owns the Chat tab, which just lost voice entirely,
and said nothing about it either way. It now states the tab is text only, names
the door, and records that historic voice rows keep their badge. Its ChatInput
inventory gains the current emit list — and a note that the line counts and
control lists in that section predate several changes, since correcting only the
line my PR touched would imply the rest is current.

`session-tab.md` listed the voice mic as deferred pending "a backend extension
to the turn endpoint — voice writes to the wrong DB tables today". #2559 settles
that rather than leaving it pending: there is one front door, no chat surface
has a composer mic, and the answer is the Talk door.

Checked and deliberately not changed: `brain-orb.md` (its `voiceAvailable` is
`brain_orb_voice_available` on a different surface, untouched);
`workspace-agent-page.md` (its `shouldEscapeStage` prose is about route SHAPE and
never enumerates `STAGE_QUERY_KEYS`, so adding `voice` does not falsify it);
`public-agent-links.md` and `web-chat-file-upload.md` (PublicChat passed no voice
props); `playbook-autocomplete.md` (its abridged `<ChatInput>` snippet omitted
the voice props already, and my change makes its `:disabled="loading"` line
accurate again).

Index is 526 lines — over the skill's 400-line guidance, but it was 525 before
this PR: one index row and one changelog row. Condensing it is not this PR's job.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
`resolveAgentQuery()` ends with `router.replace('/workspace/c/<sid>')` — a bare
path, so it drops the WHOLE query, `voice` included. `bootstrap()`'s `finally`
then started a SECOND replace in the same tick, because vue-router updates
`route` asynchronously and the strip could not see the first one in flight.
Two navigations in one tick do not compose: vue-router cancels the earlier one
(NAVIGATION_CANCELLED), so the strip won and the Talk door landed on
`/workspace?agent=X` instead of the thread URL — the code comment claiming the
two "compose rather than race" was exactly backwards.

Recorded with a flag rather than detected, since `route` cannot answer the
question in the same tick: `resolveAgentQuery()` sets `landingReplaced` where it
replaces, and the `finally` strips only when nothing already did. Every exit
still leaves a clean URL — the deep-link early return, the no-`?agent=`
fall-through, `?voice=0` and a throw all keep the one strip site.

Measured against a real `createRouter`, before → after:
  door, agent has a thread   /workspace?agent=acme  → /workspace/c/sid-123
  door, no thread yet        /workspace?agent=acme  → /workspace?agent=acme
  ?voice=0 + thread          /workspace?agent=acme  → /workspace/c/sid-9
  deep link /c/:sid          /workspace/c/sid-7     → /workspace/c/sid-7

The guard spec pins the new shape and is red without the fix (negative control
run: 1 failed / 56 passed, then 57 passed restored).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
…2559)

No findings at the gate. The one new security-relevant surface is `?voice=1`,
a URL that would open a microphone and mint a billed realtime session; the
in-app armed one-shot that guards it was traced end to end, and the module-
instance assumption it rests on was verified against a real `npm run build`
(AgentDetail and Portal are separate lazy chunks — a duplicated module would
give each its own flag and break the door in prod while working in dev).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
The tier was inert. A file-level #2199 existence probe skipped all five cases,
and frontend-e2e.yml pins the e2e baseline at zero user agents on purpose, so
the fixture it waited for is one CI will never have. Playwright reports that as
`5 skipped` inside a green run, so nothing said the coverage did not exist —
including the spec's own claim to be "the only thing that would catch a sibling
PR breaking defineExpose on rebase".

Behind it sat a second blocker: CI bootstraps the admin from ADMIN_PASSWORD and
flips setup_completed directly, so that user has no email, and portal_auth.py
403s a platform principal without one. GET /my-agents cannot answer, the roster
is empty, and the door lands on "You don't have access" rather than the call.

So the @smoke tier is now hermetic on a synthetic `e2e-talk-door`, following
workspace-code-blocks.spec.js: a fulfilled roster, the shell's reads, and — the
one that actually hid the failure — the thread-creating POST, because
startVoiceCall opens a thread before the first word and its failure branch
returns without ever reaching voice.startWith. The probe moves inside the
@Interactive describe, which is the rule workspace-absorbs-session.spec.js:30-32
already states. @Interactive keeps the real agent, patches only realtime_voice
on the live roster, and no longer stubs the start: stubbing it would make "the
orb came up" true with no call behind it.

Verified against a live stack on this branch, under the CI condition (no fixture
agent): 6 passed, and the whole @smoke suite is 76 passed / 0 failed. Falsified
by mutation — dropping armVoiceAutoStart(), dropping the
conversationRef.value?.startVoiceCall?.() hand-off, and removing startVoiceCall
from defineExpose each turn it red.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wz4MR9mmFHHUPM6DRkiCyH
@AndriiPasternak31
AndriiPasternak31 marked this pull request as ready for review September 8, 2026 09:44
AndriiPasternak31 and others added 2 commits September 8, 2026 10:47
#2579 (PR #2600) landed step 1 of the Workspace sequence and conflicted in two
places.

`PortalConversation.vue::defineExpose` — dev refactored `focusComposer` from an
inline arrow into a named function and gave it a real consumer
(`nextTick(focusComposer)` on a new chat). Resolved to `{ focusComposer,
startVoiceCall }`, keeping dev's named reference and this branch's Talk-door
export. The comment claiming nothing used `focusComposer` was true when written
and is not any more, so it is corrected rather than carried forward.

`tests/unit/workspaceNewChat.spec.js` — #2579's pin asserted the exact
one-token `defineExpose({ focusComposer })`, which any sibling PR exposing a
second thing would fail. Relaxed to membership, which is what the case's own
comment says it cares about; falsified by dropping `focusComposer`, which still
turns it red.

`learnings.md` — an append-only ledger, both sides' entries kept.

Frontend unit suite after the merge: 102 files / 2315 passed.

Co-Authored-By: Claude Opus 5 <[email protected]>
ent#547 / #2580 (PR #2604) landed the compact Workspace header. The only
conflict was `learnings.md`, an append-only ledger — all five entries kept,
dev's three first. `PortalConversation.vue` auto-merged clean this time.

Frontend unit suite after the merge: 104 files / 2339 passed.

Co-Authored-By: Claude Opus 5 <[email protected]>
@AndriiPasternak31
AndriiPasternak31 requested review from dolho and vybe and removed request for vybe September 8, 2026 13:22
@AndriiPasternak31 AndriiPasternak31 self-assigned this Sep 8, 2026
@AndriiPasternak31

Copy link
Copy Markdown
Contributor Author

User-confirmed manual voice checks — 2026-09-08

Tested on the isolated PR stack at head ae4105fe07a3f59859c73f950a2af2767245e88b with a configured Gemini key. The user confirmed:

  • Agent Detail → Talk opened the Workspace call in the same tab with the correct agent.
  • A real spoken conversation worked, including audible responses and a follow-up.
  • Ending the call stopped it; the transcript remained in Workspace after refresh.
  • Pasting the ?voice=1 URL in a new tab did not start a call; the parameter disappeared.

The user's spoken/manual verification gate is satisfied. The two automated @interactive Playwright cases have not been run in this sign-off session, so this comment does not claim that the entire pre-merge checklist is complete. Existing merge-order and other pre-merge requirements remain as listed in the PR description.

The local sign-off stack is being torn down at the user's request.

@vybe

vybe commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

merge-train: ejected — .claude gitlink is unpushed. The PR bumps .claude to ea6dd815, which does not exist on trinity-dev (gh api repos/abilityai/trinity-dev/commits/ea6dd815 → 422). Merging would break submodule update for every core-team clone while public CI stays green. Push the trinity-dev commits or reset the gitlink to dev's pointer. Also: the body declares a merge-order dependency on #2608, which is on this train — so this one rides the next train, off a dev that already contains #2608. The learnings.md conflict is mechanical.

Resolves two conflicts:

- .claude gitlink: reset to dev's pointer (584a70d). The branch had bumped
  it to ea6dd815, which does not exist on trinity-dev — merging would have
  broken `git submodule update` for every core-team clone while public CI
  stayed green (merge-train ejection, PR #2606). The two test-catalog doc
  commits are pushed to trinity-dev separately; this PR carries no
  submodule pointer bump, per the "never stage the submodule pointers"
  convention now in the sprint/commit skills.
- docs/memory/learnings.md: mechanical — both sides appended entries at the
  tail. Union kept, no entry from either side dropped.
@AndriiPasternak31

Copy link
Copy Markdown
Contributor Author

Both fixed at 068677120.

1. The .claude gitlink. Reset to dev's pointer, 584a70d. This PR now carries no submodule bump at all — checked against the pushed PR file list, not just the local tree, since diff.ignoresubmodules all makes a bump invisible to both git status and git diff:

$ gh pr view 2606 --json files --jq '.files[].path' | grep -E '^\.claude|enterprise$'
(no output)   # 40 files, none of them a gitlink

The two commits it had been pointing at were doc-only (agents/test-runner.md — the #2559 test-catalog entries). Rather than push them behind this PR, they are rebased onto trinity-dev/main @ 10c3d4c and opened on their own: Abilityai/trinity-dev#22. That also matches the convention that landed in ec4eeb3 / 584a70d itself — a feature PR does not stage the pointers, and a deliberate bump is its own change (#2631). Heads-up: trinity-dev#17 edits the same file in different sections, so whichever of the two lands second takes a mechanical conflict.

2. Merge order. #2608 merged at 16:28Z, so the dependency is now behind us rather than beside us; origin/dev (105be062f) is merged into this branch. mergeable is back to MERGEABLE.

The learnings.md conflict was mechanical as you said — both sides appended at the tail. Union kept, and proved rather than eyeballed: the set of ^## 20 headings in the result equals the union of the two sides, with nothing lost from either and nothing invented.

Re-verified on the merge commit, since the merge pulled in #2601 and #2608, which both touch PortalConversation.vue:

Check Result
CI on this PR 23 pass / 1 pytest seed still running / 3 skipping — including e2e green, the job that exercises this PR's surface
npm run test:unit 107 files / 2424 passed
npm run build ✓ — the merge is structurally sound, not just test-green
Backend voice suites (nothing deleted) 131 passed — test_voice_auth + test_1076_voice_model_config + test_voice_tools + test_ent534_workspace_voice + test_ent279_scrub_parity
Raw-color ratchet no per-file growth, measured HEAD vs origin/dev — the committed baseline is from 2026-07-31 and three of these files have grown on dev since, so a baseline comparison would have reported a false regression

The PR body is updated: sign-off and merge-order boxes checked with links, the stale ent#535 prerequisite dropped (it was released to the pool), and the submodule checklist item replaced by a statement of the pointer. Still open before merge, unchanged: the two @interactive Playwright cases are unrun, ent#534 needs to be deployed and exercised, and #710 wants its pointer comment.

Ready for the next train.

@AndriiPasternak31

Copy link
Copy Markdown
Contributor Author

Follow-up on the one check that was still running when I posted above: it went red, then green on re-run — worth a line so the failure in this run's history isn't read as a real one.

pytest (head, seed 99999) was killed by the 45-minute job cap, not by a test:

X pytest (head, seed 99999) in 45m18s
  X Run unit suite
ANNOTATIONS
  X The job has exceeded the maximum execution time of 45m0s
  X No files were found with the provided path: junit-head-99999.xml

No JUnit XML, so there was no failing test to name. Re-run with no code change: pass in 9m47s (job 102208567221). Its five siblings had already passed in 8–12m, base, seed 99999 among them at 11m11s — same seed, same ordering, on dev. A 45m wall against a 9m47s replay of the identical commit is runner contention.

Also worth stating because seed 99999 has a history here of order-dependent failures no other seed reproduces: this PR touches zero src/backend/ files. The only Python file in the diff is tests/unit/test_ent438_agent_canvas.py, which read_text()s two source files and greps them — it has no path to 45 minutes.

CI on 068677120 is now 25 pass / 3 skipping / 0 fail.

@vybe vybe added the ui PR touches the frontend UI — triggers Playwright e2e tests label Sep 9, 2026

@vybe vybe 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.

merge-train: batch validated on train/20260909-0822 (#2639) — full suite green on the combined batch.

@vybe
vybe merged commit 7eaace3 into dev Sep 9, 2026
40 of 41 checks passed
vybe pushed a commit that referenced this pull request Sep 15, 2026
… the agent's index.lock (#2742) (#2797)

* docs(git-sync): requirements, architecture and flow for lock-free sync-health polling (#2742)

Trinity Rule #1 — the requirements/architecture delta lands before the code.

What the docs now say:

- requirements/github.md §11.9 gains "Lock-free status read" and "Stuck-lock
  report, never a runtime delete", and the stale-lock hygiene bullet records
  that the boot reap now speaks. §11.8's SyncHealthService bullet names the
  leader lease AND its honest side effect (time-to-sync_failing ~90s → ~180s).
- architecture/agent-lifecycle.md is the single home: why the status read took
  index.lock ~2x/min in every workspace, what replaced it, and why the runtime
  delete was cut on measurement rather than hardened.
- architecture/agent-runtime.md gets a one-line pointer (no second home).
- architecture/background-services.md's Sync Health row states the lease, its
  fail direction and the reason (a feed that raises sync_failing must not go
  dark when Redis does) — per that file's header rule.
- feature-flows/git-sync-health.md: §1a announced boot reap + the observe-only
  runtime report with the three measurements that decide it; a new §2a for the
  agent status handler with the two distinct bounds (35s caller / 90s
  computation) and the ~130s child-budget arithmetic that replaces the doc's
  wrong "~30s worst case"; Files Touched, Testing, Operator Controls; and a
  Known Limitations rewrite that retires the "still blocks the event loop"
  bullet and replaces it with the residuals this change does NOT close.

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(sync-health): leader lease across uvicorn workers, fail-open (#2742)

main.py starts SyncHealthService in EVERY uvicorn worker and prod runs
`--workers 2`, with no lease — unlike opqueue:leader (#1632), monitoring:leader
(#1464), skills:sync:leader and canary:leader. So every git-enabled agent was
asked for /api/git/status twice a minute, and each ask runs a 30s credentialed
`git fetch origin` inside the container.

`synchealth:leader` in the #1464 shape: SET NX EX, own-lease-only refresh,
release from stop(), acquire + transition logs at the top of _poll_cycle with an
early return for non-leaders.

Two deliberate divergences from the copied shape:

- Release is a single compare-and-delete EVAL, not GET-then-DEL. The non-atomic
  form lets a worker whose lease lapsed between the two calls delete a sibling's
  FRESH grant — two pollers for a whole cycle. EVAL is outside the -@dangerous
  categories denied to the backend/scheduler ACL users.
- Fail direction is OPEN and stated in the docstring: Redis down means every
  worker polls, i.e. today's behaviour. Failing closed would darken the only
  feed that ever raises sync_failing, exactly when infra is already degraded.

The lease has an honest side effect and it is named, not buried.
db.upsert_sync_state INCREMENTS consecutive_failures per failed upsert, so it is
NOT idempotent: two unleased workers reached sync_failing in ~90s, one leader
takes ~180s. Asserted in TestLeaderLeaseAlertTiming — including the load-bearing
fact itself (the same payload polled twice increments twice), so the test cannot
pass against an idempotent upsert and prove nothing.

Also here (same file, same subject): SYNC_HEALTH_POLL_INTERVAL_SECONDS, read at
CALL time in the _maintenance_timeout_seconds shape, parse-guarded and
positive-clamped, with the default DELIBERATELY unchanged at 60s — the AC is
written as "the 60s poll" and the sampler evidence was taken there. poll_interval
becomes a property so the module-level singleton (built at import) still honours
the env; `is not None` rather than truthiness so the tests' poll_interval=0 keeps
meaning "one cycle then exit".

The `service` fixture now stubs get_breaker_redis -> None: with a local Redis it
would otherwise leave a real 30s lease behind and the NEXT test's fresh service
would lose the election and silently poll nothing.

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(agent-server): status read is lock-free and sweep-registered (#2742)

`git status --porcelain` takes .git/index.lock on EVERY invocation to refresh
the index — whether or not a rewrite follows — for a window that scales with
index size (0.6ms at one file, 12.8-15.4ms at 20k; 334-473ms measured in a real
container). The backend polls /api/git/status every 60s for every git-enabled
agent, so the platform was taking that lock ~2x/min in every workspace, outside
_REPO_LOCK, racing the agent's own `git add`.

`git --no-optional-locks status --porcelain` on exactly that one call site.
Scoped deliberately: the auto-sync cycle's status (under the repo lock, right
after `git add -A`, proceeding to commit) and the sync/pull bodies keep the plain
form — they are lock-serialized and they WANT the refreshed stat cache. Flag
form rather than GIT_OPTIONAL_LOCKS=0 because run_registered has no env= kwarg,
the env form would silently change the mutating sites too, and only the argv is
assertable in a test. Verified across a clean index, a stat-dirty index,
core.untrackedCache, --untracked-files=all, an fsmonitor hook and a repo with no
.git/index: zero lock sightings and zero rewrites in every case.

The flag closes only the index-lock half, so every status child now routes
through run_registered (#1595's seam): a sweep tick straddling the 30s
`git fetch` still SIGKILLs it, and a killed fetch orphans FETCH_HEAD.lock /
packed-refs.lock — which NO reaper covers, not even startup.sh's (its find is
scoped to refs/ and logs/). run_registered accepts neither capture_output nor
text, so both kwargs are DELETED at all ten sites; a name-only substitution
would be a TypeError ten times over.

Three of those ten are the shared helpers _compute_ahead_behind,
_get_pull_branch and _persist_last_remote_sha, which are also reached from
_conflict_response (the 409 arm of every locked endpoint), sync_to_github and
pull_from_github. So the conversion sweep-registers three children on the
MUTATING paths too. That is desirable — those are the children a repack-length
operation exposes longest — but it is stated and pinned by a test rather than
left for a reviewer to find.

Also here, because the diff was already moving these lines:

- remote_url is now unconditionally redact_url_userinfo'd. The old shape
  special-cased @github.com and returned everything else VERBATIM, so any
  non-github.com remote (GHES, GitLab, a host-rewritten origin) put a live
  `https://oauth2:<PAT>@host/...` in the response body — proxied unmodified by
  git_service.get_git_status to the UI and the MCP tool. ent#615 owns the
  broader class; this is the one line of it in this diff.
- _read_sync_state_file gates on st_size (64 KiB) BEFORE reading. That file is
  fully agent-authored and merged wholesale, and the backend reads every agent
  concurrently once a minute, so an unbounded read_text() OOMs both sides.
- The comment beside _REPO_LOCK now says what it does NOT exclude: the agent's
  own git and the backend's docker exec sites. Misreading that is what produced
  a plan to treat a successful non-blocking acquire as evidence of quiescence.

_compute_git_status is extracted verbatim as one blocking callable (the handler
calls it directly for now) so the next commit can put the coalescing in front of
it without also moving the body.

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(agent-server): coalesce /api/git/status on the event loop (#2742)

Three callers converge on this one route — the backend's 60s sync-health poll,
the UI git panel's own 60s poll while open, and the MCP get_git_status tool —
and each computation runs a 30s `git fetch origin` against one repo. The issue
observed two overlapping fetches 0.9s apart. A guard on the poller alone would
not have satisfied AC2.

Now the first caller starts the computation and every other caller awaits the
SAME future. The slot is keyed on the resolved home path, check-and-set is
atomic because there is no `await` between the test and the assignment, and the
agent server is single-process (agent_server/main.py calls uvicorn.run(app, ...)
with no workers=) — the BACKEND is not, which is what the Redis lease is for.

Coalescing happens ON THE LOOP, and only the computation takes a thread. This
is the load-bearing shape choice, not a style preference: asyncio.to_thread uses
the loop's DEFAULT executor — min(32, cpu+4) = 6 threads on a 2-vCPU agent — and
services/headless_executor.py records that ctx.terminate, auto-sync and
pipe-close deliberately stay on that same pool. Parking followers there is the
#2433 starvation class, where a burst of status callers stalls EXECUTION
TERMINATION. Five callers must cost exactly one to_thread, and a test asserts it
so the rejected shape cannot come back.

Two bounds, deliberately distinct numbers for distinct things:

- _STATUS_FOLLOWER_WAIT_SECONDS = 35 is a CALLER bound, at or just past the
  point every real client has already given up (poller 10s, git_service 30s);
  a longer wait can only produce work nobody awaits. Timeout is a 504.
- _STATUS_LEADER_DEADLINE_SECONDS = 90 is a COMPUTATION bound. The child
  timeouts sum to ~130s nominal before run_registered's post-killpg drain, and
  a slow leader costs no follower threads but DOES hold the slot, so every
  caller in that window 504s. The docstring carries the arithmetic; the flow
  doc's old "~30s worst case" (which is where a 60s follower bound came from)
  is corrected in the docs commit.

asyncio.shield is load-bearing: a follower that times out or disconnects must
not cancel the computation everyone else is waiting on. And the future is
ALWAYS resolved — to_thread -> run_in_executor -> _WorkItem.run catches
BaseException and calls set_exception — so there is no hand-rolled
set_result/set_exception pair and no "leader vanished" fallback. The comment
says not to add one.

`computed_at` admits what coalescing costs: a follower arriving at t=29s of a
30s leader run is served a 29-second-old snapshot, visible as "1 ahead" right
after a successful push. Stamping the age is cheaper and more honest than
claiming coalescing changes nothing. TTL caching was rejected — serving late
followers a fresh run reintroduces the overlapping fetch AC2 forbids.

No 409 on status by design: it is a read, and _with_repo_lock on it would make
every poll a contended write and flap the agent `unreachable`.

D5: test_1920's walk now covers docker/base-image/agent_server/ as well as
src/backend — Invariant #5, "a guard that walks only one of the two trees is
not a guard" (ent#314). Proven by planting an nx=True in an agent-server module
and watching it fail. That tree gets no allowlist row on purpose: it issues no
nx=True set and cannot (agents are not on the platform network, so Redis is
unreachable from one), and #2742's coalescing is a different class entirely.
Its one-home property is asserted directly instead, beside a meta-assertion
that fails loudly if the agent-server root ever moves out from under the walk.

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(agent-server): announce the startup lock reap and report a stuck lock (#2742)

AC3 has two halves and only one of them was missing. The RECOVERY already
existed and is provably safe: startup.sh reaps index.lock at container start,
where "no git process is running" is definitional because the PID namespace is
empty. What was missing was the OBSERVABLE half — the block was `rm -f`, silent
whether or not it removed anything, so the one moment the platform reliably
heals a wedge produced no evidence that it had.

startup.sh now tests-then-removes, echoes a line naming each lock it cleared
(Vector captures it), and drops ~/.trinity/lock-recovery.json. It also reaps
index.lock under .git/modules/* and .git/worktrees/*, which NOTHING covered
before — its find is scoped to refs/ and logs/ — so a submodule or
linked-worktree wedge used to survive every restart. Proven by extracting the
shipped block and running it against fixtures: /verify-local's agent stage boots
local:test-echo, so startup.sh never executes there and trusting the stage would
prove nothing.

_record_lock_recovery folds that marker into sync_state.last_lock_recovery on
the next status read, then deletes it so the episode is reported once rather
than every minute forever. It goes through a dedicated metrics-only writer:
_write_sync_state_file unconditionally stamps last_sync_at = now, which would
mark a never-synced agent as freshly synced and turn its dashboard dot green.

_index_lock_stuck REPORTS a currently-present lock and never unlinks it. The
runtime delete was cut on measurement, not on taste:

- st_size == 0 is the signature of a LIVE writer, not an abandoned one — git
  creates the lock with O_EXCL before walking the worktree and writes the new
  index into it only at the very end. Measured 100% of a healthy `git add -A`'s
  life: 3.9s on 450MB, 29s at 60k files, 155s under a clean filter.
- st_mtime is stamped at create and never advances, so age measures the
  IN-FLIGHT OPERATION. At t=+130s a healthy add reads size=0 age=130s — both
  naive gates satisfied.
- A wrong unlink is permanent and strictly worse than the wedge: git renames by
  PATH, so a second git's in-flight file gets promoted onto .git/index, the
  corrupting process exits rc=0 with empty stderr, and the 0-byte index is
  cleared by nothing — not the boot reap, not _reap_stale_git_litter, not
  `git reset`.
- _REPO_LOCK would not have helped: it excludes this server's own auto-sync
  cycle and nothing else, not the agent's own `git add`, which is the premise
  of this issue.

So detection is two-point inode stability — the same (st_ino, st_mtime_ns,
st_size) unchanged across >=3 status reads spanning >=15 min — on
time.monotonic(), which a forward NTP step or a live migration cannot move.
The tunable is the sighting COUNT, not a wall-clock age.

Three properties that are each a defect if dropped:

- It resolves the REAL gitdir. `.git` is a FILE for a linked worktree and for a
  submodule, both creatable by the agent in one command, and assuming a
  directory makes the observer look where the lock provably is not. Candidates
  cover <gitdir>/index.lock, modules/*/index.lock and worktrees/*/index.lock.
  A symlinked .git is skipped outright.
- It takes NO repo lock. An lstat needs no mutual exclusion, and holding
  _REPO_LOCK across the observation would make a status poll a brand-new source
  of 409 agent_busy on an operator's POST /api/git/sync.
- It is wrapped end to end in its own except OSError. It runs inside
  _compute_git_status's try, whose tail is HTTPException(500), and
  _fetch_git_status treats any non-200 as None and writes nothing — so one
  EACCES would silently stop the agent's sync-health row advancing and
  sync_failing would never fire either. An observability path must never be
  able to darken the feed it feeds.

The sighting ledger is in memory, deliberately NOT in sync-state (a deviation
from the plan, on safety grounds): a per-tick read-modify-write into the
agent-authored document would race the auto-sync writer and could drop
consecutive_failures or last_sync_status — the observability path corrupting
the feed. It needs no durability either, since the only thing that clears a
genuinely wedged lock is the container restart that also clears the ledger.

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(sync-health): log self-healed index.lock recoveries once (#2742)

The backend half of AC3, plus the AC4 concurrency proofs.

_coerce_lock_recovery / _coerce_lock_stuck rebuild both new fields from values
the backend has checked, and never pass the agent's dict through. That is not
belt-and-braces: sync-state.json is agent-authored, the agent server merges it
wholesale (merged.update(data)), so last_lock_recovery is fully agent-controlled
even on an agent where nothing ever reaped anything — and
git_service.get_git_status proxies response.json() UNMODIFIED to the UI and the
MCP tool.

Three guards, each for a named failure:

- isinstance(value, str) before parsing: parse_iso_timestamp raises
  AttributeError, not ValueError, on a non-str.
- except (ValueError, TypeError) around the parse AND the window comparison: a
  valid-but-naive ISO parses cleanly and then raises TypeError on aware > naive,
  and that raise lands in _sync_agent AFTER the upsert where
  gather(return_exceptions=True) swallows it — so the symptom is a lost alert
  with no traceback. The same guard with the same comment already exists in the
  file this record comes from.
- An explicit UTC offset is REQUIRED. startup.sh always stamps Z, so a naive
  value did not come from us, and the house posture over agent-authored JSON is
  to reject rather than guess.

The window is [now - 1h, now + 60s], with the hour deliberately a floor rather
than 2x the poll interval: startup.sh stamps `at` at container boot and the
agent server folds it in on its FIRST status read, and a cold boot can put
several minutes between those two. The clamp's job is to reject nonsense — the
far-future `at` that would otherwise be "newer" forever — and the DEDUP is what
stops a real record repeating.

Dedup is against the last OBSERVED value. The rejected alternative ("at newer
than the prior row's last_check_at") is not a dedup at all: last_check_at is
re-stamped to now on EVERY upsert, so 9999-01-01 would be newer on every tick,
per agent, for the life of the process — a WARNING asserting a platform action
that never happened. Both halves are tested, so neither can pass by rejecting
everything.

index_lock_stuck is edge-triggered and re-arms after the lock clears. No
operator-queue item and no DB column: the report is a diagnosis, not a decision.
The agent-supplied `path` is dropped at the boundary — it is composed from a
.git the agent can point anywhere and adds nothing to a fleet-level WARNING.

AC4 ships in three phases, strongest first:

- The GATE is deterministic AND genuinely concurrent: a real
  `git status --porcelain` child is SIGSTOP-frozen the instant it takes
  .git/index.lock, and the agent's own `git add` — a second real process — then
  fails rc!=0 with index.lock in stderr. 10/10 locally. SIGSTOP is the only way
  to hold that window open: git runs hooks and filters OUTSIDE the index lock
  (an fsmonitor hook sleeping 1s stretches status to 1279ms while the lock
  window stays 0.8ms). SIGCONT is in a `finally` — --timeout-method=signal
  raises inside the test and a leaked frozen child would hold the lock for the
  rest of the session. Its twin proves the flagged argv cannot be caught at all.
- The lock-sighting sampler (AC1, earlier commit) is the property.
- The threaded witness through the real get_git_status() route is
  self-validating and non-gating: its control arm must reproduce an index.lock
  failure IN THIS RUN or the test skips. Measured through this route the duty
  cycle is ~0.7% (about 95% of each iteration is git fetch), so the margin is
  roughly one failure per run — it skips ~2 runs in 5 here, which is exactly the
  point: it can never pass without having demonstrated it can fail.

Writer rounds write time.time_ns() and failures are classified by
"index.lock" in stderr, never by return code: `git commit` exits 1 with EMPTY
stderr when a round writes content identical to the previous one, which under
check=True is indistinguishable from a lock failure.

Co-Authored-By: Claude Opus 5 <[email protected]>

* docs(git-sync): sync the adjacent flows and bound the leader (#2742)

Tail steps: /update-tests and /sync-feature-flows.

Two gaps the plan's test matrix listed and the implementation had not yet
covered, both now closed:

- test_leader_deadline_releases_the_slot — a wedged leader must release the
  in-flight slot rather than monopolise the read. It holds no follower threads
  on this design, but it does hold the slot, so every caller in that window
  504s.
- An AST guard pinning _STATUS_LEADER_DEADLINE_SECONDS to the status body's
  REAL child-timeout budget. They are both 90s today (10 rev-parse + 10 status
  + 10 log + 30 fetch + 10 merge-base + 10 log + 10 remote get-url). Adding a
  child, or widening one, now fails here instead of showing up as an
  unexplained 504 in production — and the flow doc's arithmetic is guarded with
  it. Plus the ordering invariant between the two bounds (caller < computation).

Flow-doc sync — one home per feature, so the two adjacent docs get pointers,
not copies:

- github-sync.md documents GET /api/git/status's own contract, so its endpoint
  row, its _persist_last_remote_sha row (whose child is now sweep-registered on
  the LOCKED sync path too), its stale "line 249-250" call-site reference, and
  its revision history all needed the #2742 delta.
- mcp-git-tools.md: the MCP tool proxies the agent payload verbatim, so it
  gains computed_at / lock_recovery / index_lock_stuck with no signature change
  — and its callers now coalesce with the poller and the UI panel rather than
  stacking a third overlapping git fetch.
- feature-flows.md's Git Sync Health category row and git-sync-health.md's
  index_lock_stuck field list corrected to match what the code actually emits.

The test-runner catalog entry lives in the private .claude submodule and is
committed THERE, on its own branch, deliberately WITHOUT bumping this repo's
gitlink — `git add -A` stages that gitlink silently under
`diff.ignoresubmodules=all`, which is what ejected #2606 from a merge train.

Co-Authored-By: Claude Opus 5 <[email protected]>

* test(git-sync): drop the ghp_-shaped placeholder from the redaction test (#2742)

Public repo. The fixture token was never real and is too short to match
GitHub's own secret-scanning format, but a `ghp_` prefix is exactly what the
repo's pre-commit checklist tells a reviewer to grep for, and the test's point
is that URL userinfo is stripped — not that it is a GitHub PAT specifically.

Co-Authored-By: Claude Opus 5 <[email protected]>

* docs(learnings): record the to_thread-deletes-the-accidental-exclusion pitfall (#2742)

Moving the status handler off the event loop removed a mutual exclusion that
sync_to_github/pull_from_github were providing by never awaiting. _REPO_LOCK
was added for the cycle, so it does not cover a newly threaded path.

Co-Authored-By: Claude Opus 5 <[email protected]>

* docs(git-sync): replace the 29x flag-cost figure with fleet measurements (#2742)

Re-measured inside a real agent container on the ext4 workspace volume. The
penalty tracks content bytes re-hashed, not index size: ~1x on 42491 files of
~1 MB, ~390x on 1500 files of 294 MB. The single 29x figure was taken outside
the fleet and sat between the two regimes, describing neither.

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(sync-health): wire the poll-cadence knob into both compose files (#2742)

`SYNC_HEALTH_POLL_INTERVAL_SECONDS` was read by `sync_health_service` at call
time — a property rather than an import-time copy, specifically so an operator
override is honoured — and then reached no container: it was absent from
`docker-compose.yml`, `docker-compose.prod.yml` and `.env.example` alike. The
knob shipped inert. Proven by rendering rather than grepping: before, the var
does not appear in `docker compose config`'s backend environment at all.

This is the #1056 packaging class (`VOIP_*`), which
`test_ent237_skill_source_env_packaging.py` records as having already recurred
seven times. Prod compose launches standalone — no base-compose merge and no
`env_file:` on the backend service — so the explicit `environment:` list is the
only route in, and wiring dev alone would not have carried over.

The `${VAR:-60}` pass-through form is the correct one here: a cadence has no
"disable" sentinel, so unset and empty must both land on the unchanged 60 s
default. `TestPollIntervalReachesTheContainer` asserts the FORM, not mere
presence, and pins the compose default against `DEFAULT_POLL_INTERVAL` rather
than a literal so the two cannot drift into a container that polls at a
different rate from a laptop. Verified to have teeth by deleting the prod
wiring and watching it go red.

Found by /validate-pr §4.9 on this branch.

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(sync-health): the cadence knob must reach the hosted compose too (#2742)

`b6757ba66` wired `SYNC_HEALTH_POLL_INTERVAL_SECONDS` into `docker-compose.yml`,
`docker-compose.prod.yml` and `.env.example` — and missed
`docker-compose.hosted.yml`, the pull-only twin every marketplace and managed-host
channel actually runs. `test_2280_hosted_compose_parity` caught it in CI:
deterministic, all three head seeds, clean in all three base seeds.

That is the bug reproducing inside its own repair. The commit being fixed exists
because a knob never reached the container; it then failed to reach the container
that ships to marketplace installs. The hosted file's own header names the class
and lists its five prior victims (#1039, #1056, #1707, #1871, #2381) — this is
the sixth, and the first to be caught by the guard rather than by an operator.

The line is byte-identical to prod's, since #2280 compares the backend
`environment` list wholesale. No hosted-specific assertion is added here: that
guard is strictly stronger than anything this file could restate, and two guards
over one fact drift apart. The reasoning is recorded in the test's docstring so
the next reader does not "helpfully" add the redundant one.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: sim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui PR touches the frontend UI — triggers Playwright e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants