Repository navigation
test(brain-orb): close coverage gaps — owner gate, idempotency, hooks, flags, route wiring (ent#61) - #1428
Conversation
…hardening, flags, route wiring (abilityai/trinity-enterprise#61) /update-tests review of the Phase 1-4b surface. 26 new tests, all passing (103 total across the three files against the live backend). tests/unit/test_brain_orb.py (+18, file total 95): - POST /scope owner-gate 403 — the one mutating route missing the proof its Phase-4 siblings had (incomplete-fix-chain class) - PUT /postprocess 413 body cap (review F4) - idempotency semantics: key folds the action verb; claim released on agent 502/504; success completes with the parsed snapshot; missing key = fail-open (Invariant #18) - audit-sink failure never masks a completed write (review F5, action+refresh) - agent-server _run_hook hardening: output cap → 502, non-executable hook → 404, scope/search 413 body caps - postprocess (#73): invalid JSON 400, 8000-char prompt truncation, legacy .md fallback, corrupt-JSON degrades to defaults - voice mint: _build_system_instruction clause selection + 2000-char prompt cap; new-session window < token expiry tests/test_settings.py (+3 SMOKE): feature-flags requires auth; brain_orb_* keys present + boolean; write⇒available compound-gate invariant (#61 kill-switch layering) — first coverage of any brain-orb feature-flag key. tests/test_brain_orb_api.py (new, 5 SMOKE): live-backend route-wiring proof (#1069 escape class) — the unit suite mounts the router on a synthetic app, so only these prove main.py registration + the real AuthorizedAgentByName / OwnedAgentByName chain. Test-runner catalog updated in the trinity-dev submodule (rides separately). Co-Authored-By: Claude Fable 5 <[email protected]>
Review — Brain Orb coverage gaps (automated review, Claude)Coverage targets exactly the right risk areas for the #1389 surface: the Notes, not blockers:
LGTM as an additive test-only PR, contingent on #1389. |
Summary
/update-testsreview of the Brain Orb Phase 1–4b surface (stacked on #1389, the open brain-orb chain PR — the tests importrouters/agent_brain_orb.py, which doesn't exist ondevyet). 26 new tests; 103 total across the three files, all passing against the live backend.tests/unit/test_brain_orb.py(+18, file total 95)POST /scopeowner-gate 403 — the oneOwnedAgentByNameroute missing the non-owner proof its Phase-4 siblings had (the incomplete-fix-chain escape class from the 2026-06-27 bug-escape analysis)PUT /postprocess413 body cap (review F4)/actionand/refresh_run_hookhardening: stdout over_MAX_HOOK_OUT→ 502; hook present-but-not-executable → 404;scope/tool64 KiB body caps.mdfallback, corrupt-JSON degrades to defaults (never 500)_build_system_instructionclause selection + 2000-char prompt cap; new-session window < token expirytests/test_settings.py(+3, SMOKE)First coverage of any brain-orb feature-flag key:
brain_orb_available/brain_orb_voice_available/brain_orb_write_availablepresent + boolean; write ⇒ available compound-gate invariant (kill-switch layering, holds under any env); endpoint requires auth.tests/test_brain_orb_api.py(new, 5, SMOKE)Live-backend route-wiring proof (#1069 escape class): the unit suite mounts the router on a synthetic app with overridden dependencies, so only these prove
main.pyregistration (unauthenticated → 401, not routing 404) and the realAuthorizedAgentByName/OwnedAgentByNamechain (authenticated 404s carry a real dependency/handler detail, never FastAPI's bare "Not Found"). Needs no agent and no flags.Test plan
pytest unit/test_brain_orb.py -v→ 95 passed (no backend needed)pytest test_brain_orb_api.py test_settings.py::TestFeatureFlagsBrainOrb -v→ 8 passed (live backend)tests/utilsviasys.modules['utils']for integration files collected in the same session (pre-existing collision, documented in the test-runner catalog)Test-runner catalog (
.claude/agents/test-runner.md) updated in the trinity-dev submodule — rides separately with the next submodule sync.🤖 Generated with Claude Code