Skip to content

Harden Trinity ops alert recovery - #886

Closed
erichroepke wants to merge 1 commit into
Abilityai:mainfrom
erichroepke:codex/trinity-ops-stabilization
Closed

erichroepke wants to merge 1 commit into
Abilityai:mainfrom
erichroepke:codex/trinity-ops-stabilization

Conversation

@erichroepke

Copy link
Copy Markdown

Summary

  • add stale .git/index.lock detection/recovery to agent auto-sync
  • classify task execution timeouts and persist termination attempt/success metadata
  • mark verified recovered sync_failing and health alerts as recovered with structured evidence
  • teach the dashboard store/WebSocket/resolved card path to handle recovered operator-queue items
  • add an operator runbook for sync/network incidents and Backblaze backup-health triage

Linear

  • ERI-285
  • ERI-286
  • ERI-288
  • ERI-289
  • ERI-284 and ERI-287 received runtime triage updates but remain open for monitored re-enable/mount verification

Verification

  • PYTHONDONTWRITEBYTECODE=1 pytest -p no:cacheprovider tests/unit/test_sync_health_service.py tests/unit/test_monitoring_alerts_recovery.py -q -> 11 passed
  • PYTHONDONTWRITEBYTECODE=1 pytest -p no:cacheprovider tests/unit/test_agent_server_auto_sync.py tests/unit/test_task_execution_timeout_hardening.py -q -> 17 passed
  • PYTHONDONTWRITEBYTECODE=1 python3 -m py_compile ... for touched backend/test files
  • git diff --check
  • touched-file secret-pattern scan found only placeholders/code/test syntax

Note

npm run build in src/frontend could not run because vite is not installed in this checkout (sh: vite: command not found). I did not install dependencies because of the active disk-pressure context.

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

Nice hardening work — the recovery-with-evidence model and the index.lock recovery path are both well-designed, tests are solid, and the runbook follows the public-repo placeholder convention. Two blockers and a doc nit before merge:

  • Retarget base branch from main to dev. Per the Trinity SDLC, feature work lands on dev first; main only receives release-cut merges. Same flag I raised on #879 — would be great to make dev the default for future PRs from this branch family.
  • Add a GitHub issue link. The Linear IDs (ERI-285/286/288/289) aren't visible here. Either reference existing issues with Closes #N / Refs #N, or open GitHub issues for the four hardening items.
  • Update docs/memory/architecture.md:
    • Add operator_queue_recovered to the WebSocket Events (Operator Queue) list
    • Add recovered to the operator_queue.status enum in the schema block
    • One-line mention of GIT_INDEX_LOCK_STALE_SECONDS (default 900s) in the agent-server section
  • Verify CI. mergeStateStatus is UNSTABLE — worth confirming what's failing. Also, npm run build wasn't run locally and the frontend-e2e workflow is ui-label-gated; please add the ui label so the Vue changes get exercised.

Re-approve immediately once base branch and issue link are fixed.

@vybe vybe closed this Jun 3, 2026
trinity-ability pushed a commit that referenced this pull request Nov 5, 2026
…lling for it (ent#1102)

Checkpoint B of ent#1102: the dispatch, hooked into the one terminal
fan-out every CAS-won writer already calls.

An async `chat_with_agent` hands back a receipt, not an answer, and before
this there was no way to learn the answer had arrived — so agents polled.
The retrospective behind ruling D4 priced that: $246 of polling, 13
re-dispatches and 10 operator nudges for runs that had already finished. One
push replaces all of it.

`_terminal_side_effects` is the hook, as a fourth guarded sibling. It covers
all 16 terminal writers without any of them changing, and it is deliberately
NOT nested inside `emit_task_terminal_event`, which returns early when no
event subscription matches — the common case — so anything inside it would
almost never run. Nor is it armed by the MCP client at receipt time: the
terminal knows the run ended; the client does not.

The wake spends a billed turn on an agent that did not schedule it, so the
stand-downs are the design, not the edge cases. No `source_agent_name` (a
human's run has nobody to tell); a self-task or a fan-out leg (the #2524
join is the batch's own reaction); any of the four reserved platform
triggers — `caller_wake` first, which is the recursion break, so no wake
chain can sustain itself, and which also closes Premise P10: an event-
loopback row is refused before its vouched `source_agent_name` is read, so
the vouching path has no reach here. Then the policy, then the caller's own
`agent.task.*` subscription (the emit is already dispatching that turn — one
ending, one turn, AC 6), then a stopped container, which is audited rather
than dispatched at because nothing auto-starts an agent.

Two bounds that make default-ON affordable. The idempotency key is
`caller_wake:{caller}:{15s bucket}` and NOT the callee's execution id: a
cleanup sweep can terminate hundreds of stale rows in one cycle, and keying
per callee would bill a turn for each — so the frame says plainly that other
runs may have ended in the same window and names `list_recent_executions`,
rather than telling a half-truth. And `chain_depth = callee + 1`, so the
wake is governed by the same `inter_agent_max_chain_depth` as the call chain
it answers (#2806/#2973) instead of being an unbounded side channel around
it. Premise P9 is now verified, not assumed: `dispatch_and_await_terminal`
forwards `**execute_kwargs` to `execute_task`, which threads `chain_depth`.

The frame carries ids, enums and the sanitized-then-capped summary through
the #1578 chokepoint, `request_text=""` and no `source_user_email` — the
platform wrote this prompt, not a person (ent#751/#886/#715). It also names
any asks the run parked and never got answered (new indexed read
`list_pending_ask_ids_for_execution`, ids only): a run can reach a normal
terminal with asks still pending, and a caller told only "ended
successfully" would read that as finished work.

Tests: `tests/unit/test_ent1102_caller_wake.py` — 26 tests through the real
`maybe_wake_caller`. Mutation battery, each reverted from a scratch copy and
restored byte-identical: deleting the hook call reddens
`TestWiring::test_each_sibling_is_guarded_separately`; dropping the reserved-
trigger break reddens the P10 loopback test; dropping the replay return
reddens `test_a_replayed_claim_produces_no_second_wake`; dropping
`chain_depth` reddens `test_a_missing_chain_depth_starts_the_count`; keying
the window on the callee reddens `test_one_wake_per_caller_per_bucket`.
Regression over the touched seams (#1578/#2523/#2524/#3520/ent#329/ent#611/
#2806/#2973): 509 passed, 1 skipped.

Refs: abilityai/trinity-enterprise#1102

Co-Authored-By: Claude Opus 5 <[email protected]>
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.

2 participants