Repository navigation
fix(brain-orb): post-voice processing as observable execution + write→select hardening (trinity-enterprise#102, #103) - #1494
Conversation
…→select loop hardening (trinity-enterprise#102, #103) #102 — the post-session run was a DETACHED claude -p forked by the agent's action hook: invisible to the platform (no execution row/cost/failure surface — a billing error silently became the "processed" note) and reaped by the agent-server's 30s cgroup orphan sweep (#817). The platform now owns the trigger: the action route strips capture_transcript's `process` flag before the hook call and services/brain_orb_postprocess dispatches the agent's configured prompt (#73, still agent-owned — Invariant #8) via execute_task(triggered_by="voice") — sweep-safe, visible under Executions, failures land as FAILED rows. process_transcript dispatches the same way and never reaches the hook. Every outcome is surfaced in the orb (saved / started / skipped+reason / failed / agent offline), and voice.js always relays the session end so "no dialogue" is distinguishable from a broken pipeline. #103 — "add a note, then show it" over voice failed invisibly: real exporters title inbox nodes by file stem, so the auto-select/navigate searching the H1 title missed (normTitle kept hyphens); postAction swallowed FastAPI `detail` errors (a stopped agent read as a silent no-op); navigate_to_note awaited a minutes-long reindex inside the voice tile's 8s tool timeout. Fixes: pending auto-select tracks title AND path stem, normTitle folds hyphens; refreshGraph joins an in-flight run and queues one follow-up instead of dropping; a refresh that doesn't surface the note polls /data briefly (async/net-zero exporters) instead of declaring "up to date"; navigate waits a bounded ~6s then answers honestly and auto-selects on completion; capture success/failure and broker errors (503 "Agent is not running") toast loudly. Validated live on localhost against both hook generations (real cornelius-e2e hooks + template hooks): dispatch → execution row → agent → terminal status with precise diagnostics; idempotent replay returns the same execution with no double dispatch; the previously-failing stem-titled auto-select now lands. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Review — the code looks solid; the one red check is not yours. CI: the failing
|
…or below the state card (#2538, #2539) (#2546) * fix(brain-orb): latch wheel routing per gesture so momentum never zooms (#2538) The single window-level `wheel` listener in public/brain-orb/orb.js decided zoom-vs-scroll PER EVENT via panelCanScroll(), with no gesture memory. On a macOS trackpad one flick keeps emitting `wheel` at frame cadence long after the fingers lift, so the inertia tail that arrived after a panel reached its edge was routed to camTargetDist and the camera zoomed out. - Gesture latch: a run of wheel events with inter-event gaps <= 150 ms (WHEEL_GAP_MS — the top of the issue's 120-150 ms range) is one gesture. Its first vertical event decides the route from the scroll container under the pointer; every later event keeps it. Panel-latched events that can scroll nothing are swallowed (preventDefault), never zoomed. A fresh gesture (gap > 150 ms) over an already-edged panel still zooms, so the deliberate "scroll to the end, then keep going to zoom out" chaining is preserved. - Clock is e.timeStamp (input time) with a performance.now() fallback. Chromium coalesces events queued behind a stalled frame into one, so a stall > 150 ms still ends the gesture — bounded to one re-decided step. - deltaY === 0 (pure-horizontal) events never start a latch; they refresh the clock and otherwise behave exactly as before. deltaX handling stays deferred, as the issue itself defers it. - Allowlist gone: panelCanScroll() walks the target's ancestors up to <body> and asks computed style, so the CSS is the single source of truth. #scopePanel (overflow-y:auto all along) scrolls under the wheel at last. - The ctrlKey pinch branch and the Safari gesture* listeners are untouched. - index.html: orb.js is un-hashed under prod nginx's 1y-immutable cache, so the <script> tag now carries ?v=2026-09-06 (comment says: bump BOTH). Proof: e2e/brain-orb-wheel-latch.spec.js (@smoke; standalone /brain-orb/index.html FALLBACK graph — no agent, no auth; skips without WebGL, fails loudly on a boot error). Red before the fix at A2+A3 (camTargetDist 330 -> 473.9 across a 25-event tail), A4 ([true,false]) and A5 (#scopePanel wheel zoomed, defaultPrevented true); 9 passed after. A1 scrolls #inspContent into the inspector's visible box and asserts the aim point before firing its one trusted wheel, so a mis-aim can never read as a routing failure. Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(brain-orb): floor the inspector below the state card (#2539) #stateBox (top:26px, 174px tall) and #inspector (top:50%; translateY(-50%); max-height:82vh) are both right-anchored .panels at z-index 10 with nothing reserving vertical space, so a tall inspector rose into the state card and, being later in DOM order, painted over "STATE / Idle" — measured overlap 128 / 119 / 103 px at 1280×800 / 1440×900 / 1920×1080 (132 px on the real 1280×756 iframe viewport). CSS only — exactly two values on #inspector change: - transform: translateY(max(-50%, calc(224px - 50vh))) keeps the centring while the box is short and floors its TOP edge at 224px (26 + 174 card + 24 gap) once it is tall — continuous, no jump. The 174px premise holds for every STATES desc and the boot-time "reflecting last run" string (<=3 lines at 26ch); spec B1 asserts it rather than trusting it. - max-height: min(82vh, calc(100vh - 224px - 26px)) keeps the BOTTOM edge 26px inside the viewport. No fallback pairs: the sheet already relies on min() unguarded. No JS: makeDraggable/restorePanels set inline right:auto + transform:none, so a dragged or restored inspector keeps its user-chosen spot (spec B3). Cost, stated so nobody raises the cap later: on the real iframe a full-height inspector shrinks from 82vh to 100vh-250px (~549 -> 420 px at a 1280×800 window). Out of scope, follow-ups: the #controls legend under a full-height inspector, #scopePanel's own gutter collision, and — surfaced by spec B1 — the top-centred #dock covering the state value at <=760px. index.html: styles.css now carries the shared ?v=2026-09-06 token (the orb.js tag got it in the previous commit; bump BOTH on every edit). Proof: e2e/brain-orb-inspector-layout.spec.js (@smoke; standalone FALLBACK page, no agent/auth). Red against the previous styles.css at all five viewports — "inspector.top 72|81|97|68|81 vs stateBox.bottom 199.86, Expected >= 215.86" — 8 passed after. The shared helper gains a `paragraphText` option so B2's short note sits inside the centring band (h <= 100vh - 448) instead of on its edge. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(brain-orb): state the ?v= cache-bust convention in the feature flow (#2538, #2539) The "Known limitations" bullet said the orb was frozen (verbatim) and that a future orb update "needs a cache-bust" — both false once #2538/#2539 edit orb.js and styles.css and index.html carries the shared ?v=2026-09-06 token. Rewrite that one bullet to state the convention (bump BOTH tokens on every edit) and its residual (/brain-orb/index.html itself is heuristically cached by prod nginx — the \.html$ no-store rule is a paired follow-up), and list the two Playwright HUD specs + helper in the file map. Nothing else in the flow changes. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(brain-orb): name the symmetric latch at the zoom branch so nobody re-decides per event (#2538) The block comment above panelCanScroll() states the gesture rule ("every later event of the gesture keeps that route"), but the line a future reader would actually edit — the zoom branch that runs while `can` is true for a zoom-latched gesture — only said "zoom-latched". That is exactly where an `if(wheelMode==='zoom' && can) return;` "improvement" would land and quietly turn a zoom flick into an inspector scroll (the reported bug's mirror image). Say it at that line: the latch is symmetric by design, the first event decides, and spec A4 pins it. Comment only — no behaviour change; spec A re-run green (9 passed). Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(brain-orb): the ?v= bullet — first orb edits since v0.8.0, not since vendoring (#2538, #2539) "the first edits to the orb since it was vendored" is false: `git log --all -- src/frontend/public/brain-orb/orb.js` shows the Phase 2–4 PRs (#1395, #1407, #1494 and their hardening follow-ups) editing orb.js in-repo after #1389 vendored it. What IS true, and what the cache-bust convention hinges on, is that #2538/#2539 are the first orb edits to reach `dev` since the v0.8.0 release merge (the only commit touching these files on origin/dev). Say that instead. Co-Authored-By: Claude Fable 5.1 <[email protected]> --------- Co-authored-by: Eugene Vyborov <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
Summary
Fixes the two Brain Orb voice bugs from live testing (both P2, epic trinity-enterprise#57):
claude -pforked by the agent hook: invisible to the platform (a billing error silently became the "processed" note's content) and reaped by the agent-server's 30s cgroup orphan sweep (bug: Runaway subprocess after task failure makes agent-server unresponsive, triggering persistent CB cascade #817). The platform now owns the trigger: the action route stripscapture_transcript'sprocessflag before the hook call and the newservices/brain_orb_postprocess.pydispatches the agent's configured prompt (perf: Backend CPU saturation at 45% with ~30 agents due to WebSocket churn and polling storms #73 — config stays agent-owned, Invariant security: implement safe tar extraction with symlink/hardlink validation #8) viaexecute_task(triggered_by="voice")— sweep-safe, visible under Executions, cost-tracked, failures land as FAILED rows with the diagnostic.process_transcriptdispatches the same way and never reaches the hook. Every outcome is surfaced in the orb (saved / started / skipped+reason / failed / agent offline), and voice.js always relays the session end so "no dialogue" is distinguishable from a broken pipeline.normTitlekept hyphens);postActionswallowed FastAPIdetailerrors (a stopped agent read as a silent no-op);navigate_to_noteawaited a minutes-long reindex inside the voice tile's 8s tool timeout. Fixed: pending auto-select tracks title and path stem + hyphen folding;refreshGraphjoins in-flight runs and queues one follow-up; a refresh that doesn't surface the note briefly polls/data(async/net-zero exporters); navigate waits a bounded ~6s then answers honestly and auto-selects on completion; creation/failure and broker errors toast loudly.Root-cause analyses documented on the issues: 102, 103.
Changes
src/backend/services/brain_orb_postprocess.py(new) — config read (fail-closed) + framed-message dispatch throughexecute_task, execution row pre-created (scheduler pattern), fail-soft (a dispatch problem never loses a saved transcript)src/backend/routers/agent_brain_orb.py—processstrip + dispatch merge into thecapture_transcriptsnapshot (idempotency-complete after merge so replays carry the execution id);process_transcriptintercepted → dispatch; shared_require_running_agentgate; audit gainspostprocess_dispatched/postprocess_execution_idsrc/frontend/public/brain-orb/orb.js— outcome toasts for the whole transcript chain;postAction/refreshGrapherror surfacing (detail→ toast); multi-key pending focus +normTitlehyphen folding; in-flight join + queued refresh; bounded/datapoll; bounded navigate waitsrc/frontend/public/brain-orb/voice/voice.js— always relay session end (guarded on a session having started)src/frontend/src/components/BrainPanel.vue— copy: runs appear under Executionsdocker/base-image/agent_server/routers/brain_orb.py— contract docstring (no behavior change)architecture.mdBrain Orb section,feature-flows/brain-orb.mdPhase 4b + refresh-loop sectionstests/unit/test_brain_orb_postprocess.py(10 tests)Test Plan
pytest tests/unit/test_brain_orb.py tests/unit/test_brain_orb_postprocess.py tests/unit/test_85_brain_orb_settings.py— 134 passedcornelius-e2ehooks + template hooks):capture_transcript {process:true}→ transcript saved + execution row (triggered_by=voice) → reaches agent → terminal status with precise diagnostic (previously swallowed: "You've hit your weekly limit…" now on the FAILED row)X-Idempotent-Replay: true, same execution id, one transcript file, no double dispatchRefs abilityai/trinity-enterprise#102, abilityai/trinity-enterprise#103 (private-tracker issues — closed manually at release; cross-repo keywords don't auto-close)
🤖 Generated with Claude Code