Menu

#143 Wire the CB.3 loop-anomaly detector into the CB.2 CostObserver seam

open
nobody
2026-08-17
2026-07-22
Anonymous
No

Originally created by: fu351

The token-burn / runaway-agent story has three legs: the turn gate, the action gate, and cost observability. Two of the three are built; this issue is now just the wiring between them.

Already shipped

  • The CostObserver seam (CB.2) — [#102]. src/doberman/storage/cost.py: CostObserver, notify_cost_observers, COST_OBSERVER_GROUP.
  • The loop-anomaly detector (CB.3) — [#164]. detect_loop_anomaly counts repeated action fingerprints in a session and raises-only to AUTH past a threshold.

What's left: wire them together

  • Dispatch detect_loop_anomaly through the CostObserver seam (notify_cost_observers / on_cost), so a runaway loop surfaces to a subscribed observer instead of sitting unused.
  • A test that crosses that path — today tests/unit/test_cost_observer.py and tests/unit/test_cost_loop_anomaly.py never meet.
  • Strictly off the decision path; raise-only; no new verdict authority.

Where to start: src/doberman/storage/cost.py, then the two test files above.


Building this? A few project invariants any change must respect:

  • Fail closed — on any error or uncertainty, deny/BLOCK; never a silent pass.
  • Raise-only — a guardrail may auto-tighten, never silently loosen; weakening goes through the human-approved, possession-factor-gated path.
  • Never expose secrets — no raw secret, full file, or unredacted prompt in a log/store; fingerprints + reason codes only.
  • Ships with tests and green CI; keep the policy core decoupled from the proxy adapter (import-linter enforced).

New here? See CONTRIBUTING.md (github.com), and come chat in the Discord — happy to help you scope any of this.

Related

Tickets: #102
Tickets: #164
Tickets: #445

Discussion

  • Anonymous

    Anonymous - 2026-08-15

    Originally posted by: fu351

    Half of this shipped: the loop-anomaly detector over the cost ledger landed in [#164] (thanks @harshitagrawal2O). Re-scoping this issue to the remaining half, the CB.2 CostObserver plugin seam plus wiring the shipped detector into it so it runs off the decision path. The level stays as-is; the seam design is the hard part and always was.

     

    Related

    Tickets: #164

  • Anonymous

    Anonymous - 2026-08-17

    Originally posted by: fu351

    Correcting the scope — both legs this issue describes are already built. The CostObserver seam (CB.2) shipped in [#102] (src/doberman/storage/cost.py: CostObserver, notify_cost_observers, COST_OBSERVER_GROUP), and detect_loop_anomaly (CB.3) shipped in [#164]. My earlier re-scope comment calling CB.2 "remaining" was wrong — sorry about that.

    The one real gap is the wiring: detect_loop_anomaly isn't dispatched through notify_cost_observers/on_cost today, and no test crosses that path. I've retitled to just that wiring and dropped it from level-9 to level-4.

     

    Related

    Tickets: #102
    Tickets: #164


Log in to post a comment.