Repository navigation
Harden agent-provider recovery and eliminate validation flakes - #1752
Conversation
|
🚨 SLOP COP 🚨 · I am SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, and end-to-end behavior. |
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain English summary
This PR makes agent sessions recover more reliably after daemon restarts. It keeps a stable Pi session identity across BB thread changes.
It filters duplicate completion events. It also changes slow or unreliable tests.
Findings
-
P1 — The database uses the wrong lifecycle boundary. The runtime grammar lets
item/startedreopen an item identifier. The database only resets afterturn/started. It can drop a valid second completion within one turn. Thread-scoped background items have no reset boundary. -
P1 — The database lookup can block the server event loop. Each completed item runs a synchronous turn-start query. SQLite can scan many unrelated rows for an old turn. A one-million-row benchmark took 15.8 seconds for 100 oldest-turn lookups.
-
P1 — The Codex bridge retains full completion payloads. The fingerprint set keeps every unique item JSON string until session close. A reproduction retained 125.4 MiB for 2,000 outputs of 64 KiB.
-
P2 — The web-search retry has an insufficient outer limit. Two 60-second waits can run in sequence. Vitest stops the complete test after 90 seconds.
Architecture
The Pi identity split belongs in the provider bridge. The protocol increase to version 132 correctly forces old daemons to update.
The bridge, runtime grammar, and database now apply separate duplicate rules. These rules use different lifecycle models.
Use the runtime item lifecycle as the shared contract. Keep the bridge filter bounded and treat it as an optimization.
Load database lifecycle keys once per batch. This change removes repeated hot-path queries and centralizes the rule.
Security and performance
I found no separate authorization, path traversal, or command-execution flaw. The unbounded Codex set creates a denial-of-service risk.
The repeated SQLite scan can stall the server during a large recovery batch.
Validation
All current GitHub checks pass.
I also ran these exact-head checks:
- The fake recovery suite passed 8 tests across 7 files.
- The database event suite passed 79 tests.
- The Pi bridge suite passed 24 tests.
- The Codex calibration suite passed 2 tests.
- The host-daemon contract suite passed 38 tests.
- The source app and Settings route loaded in Chromium without console errors.
git diff --checkpassed.
The tests do not cover item reuse within one turn. They do not cover large histories or long Codex sessions.
I would fix the four inline findings before merge. I posted this as a comment review only.
Summary
This PR captures the fixes found during a full lint, build, test, integration-test, and manual QA run, with extra coverage focused on agent providers and recovery behavior.
item/startedlifecycle resetsBugs and fixes
providerThreadIdseparately from the live bb routing ID; verify reopen, identity reporting, and discard against the original fileitem/started; cover same-turn and background ID reuseactive -> errordisconnect transition could fail the runbook before recovery was attemptedValidation
qa/manual-runbook.mdpass, including agent-provider, dynamic ACP, permission, and daemon-recovery scenarios