fix(background): wire pr-feedback-loop production seams (#2745) - #2765
zaxbysauce wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It wires an autonomous PR-feedback action path through plugin init, cross-process durable claims, per-root registration races, and security-sensitive injection sanitization—critical, high-risk surfaces that warrant final human review.
Pull request overview
This PR wires the previously-inert PR feedback settling loop (shipped fail-closed in #2744) into the production runtime, behind the existing triple opt-in (pr_monitor.enabled + pr_monitor.auto_pr_feedback + pr_feedback_loop.enabled). It introduces a new composition-boundary module that binds the OpenCode client, agent inventory, and authenticated GitHub head polling to a canonical project root at init, and exposes bounded, fail-closed adapters (evaluateCurrentHead, dispatchOversight) that the loop's default seams already delegate to. It also hardens delivery ownership (per-root registration for wake/advisory delivery), truthful accepted-delivery gating for loop notification, and durable-claim identity (workflow-instance + owner PID).
Changes:
- New
src/background/pr-feedback-loop-runtime.ts: per-root registration with lexical-then-canonical resolution, synchronous side-effect-free registration, async promotion viapostResolutionTasks, read-only prefixed-critic oversight dispatch, and exact-APPROVEDgating. pr-event-delivery.tsrefactored from a single global registration to per-canonical-root owners (bounded, owner-token-guarded) with a trusted mode-signal channel that neutralizes body injection;index.tswires registration/promotion/cleanup and passesdirectorythroughnoteSessionIdle/deliverPrActivity.pr-feedback-event-queue.tsaddsclaimedOwnerPidpairing, dead-owner reclaim, and an exact-owner claim-release API; subscriber only settles the loop after the configured delivery channel accepts.
File summaries
| File | Description |
|---|---|
src/background/pr-feedback-loop-runtime.ts |
New production boundary: root-owned runtime, oversight dispatch, fail-closed adapters |
src/background/pr-event-delivery.ts |
Per-root delivery ownership + trusted mode-signal handling |
src/background/pr-event-subscribers.ts |
Accepted-delivery gating before loop notify; mode signal in delivered message |
src/background/pr-feedback-event-queue.ts |
Owner-PID claim identity, dead-claim reclaim, exact-owner release |
src/background/index.ts |
Barrel exports for the new runtime |
src/index.ts |
Triple-opt-in init registration, post-resolution promotion, cleanup wiring |
src/observability/catalog.ts |
Producer line citations shifted +2 (verified accurate) |
scripts/retention-registry.data.ts |
Writer/reader citation lines updated (verified accurate) |
docs/releases/pending/...md |
Pending release fragment |
AGENTS.md |
Adds repository cache-reuse governance section |
tests/** (9 files) |
Extensive runtime/ownership/safety/capacity/admission + integration coverage |
The core logic (fail-closed defaults, canonical-root promotion race handling, oversight verdict exactness, durable claim identity, injection neutralization) is carefully implemented and well-covered by tests. My one comment is an optional consistency nit on a mode-signal sanitizer regex that diverges from its two sibling build/validate sites.
Review details
- Files reviewed: 24/24 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| payload.prUrl | ||
| ? (() => { | ||
| const safePrUrl = String(payload.prUrl).replace(/["\]]/g, ''); | ||
| const safePrUrl = String(payload.prUrl).replace(/["<>\r\n\]]/g, ''); |
🤖 Multi-Stage PR ReviewPipeline: MiniMax-M2.7-highspeed (orientation) (context pack) → MiniMax-M2.7-highspeed (explorer) (explore → candidates) → MiniMax-M2.7-highspeed (fallback arbiter) (challenge + blind-spot) Phase 0 — Reconstruct IntentFrom issue #2745 and the PR description:
Phase 1 — Summarise Actual BehaviourThe PR introduces Phase 2 — Compare Intended vs Actual
The stealth change (singleton → per-root) is documented. ✅ Phase 3 — Review for Actual DefectsCorrectness — logic, async, null/edgeNone found. All code paths reviewed for:
Security / Trust BoundariesNone found. Oversight prompt ( Agent Role BoundariesNone found. Oversight uses Shipped-vs-ClaimedNone found. All claimed behaviors verified in code. Test QualityNone found. Tests for capacity exhaustion use real settlement paths, not injected mocks for the capacity gate itself. Tests for dead-owner recovery mock Phase 4 — False-Positive Control on Confirmed FindingThe confirmed finding states: "installHappySeams does not mock isProcessAlive, so dead-owner lock recovery tests that rely on it may hit the real OS process table." Claim re-examined: The fixture (
None of the failing tests depend on Verdict: REFUTED — tests that need this control mock it inline; no controlled-behavior gap exists. Phase 5 — Blind-Spot PassNo blind-spot findings. The following were checked and found correct:
🔍 PR Intent
🚨 Confirmed FindingsNone — the confirmed finding was REFUTED; no additional defects introduced by this PR. 🔬 Unverified but Plausible RisksNone — all structural risks are mitigated by runtime guards (schema validation, owner-token guards, try/catch fail-closed wrappers, capacity 🧪 Test / Coverage GapsNone — all changed/added behaviors have focused test coverage. The init wiring integration test ( 📋 Shipped-vs-Claimed GapsNone. 📝 Merge Recommendation[APPROVE] The PR correctly wires the production seams behind the documented triple opt-in, adds per-root ownership, exact PID claims, cancellation barriers, and strict oversight matching. All obligations are met. The confirmed finding was correctly refuted: tests needing
🔁 Validation provenance
🔒 Reviewed by a multi-stage local-first funnel (architect context pack → explorer candidates → critic challenge/author) for high recall with low false-positive noise. Findings are advisory — verify before acting. |
Swarm PR Review — #2765 "fix(background): wire pr-feedback-loop production seams (#2745)"Scope: merge-base
|
Closes #2745
Summary
pr_monitor.enabled,pr_monitor.auto_pr_feedback, andpr_feedback_loop.enabled.AGENTS.md.Invariant audit
bun run build,node scripts/repro-704.mjs, and Node ESM import passed.check:bare-spawn,check:shell-audit, andcheck:bash-portabilitypassed.bun:test, bounded files, deterministic temp-path helpers, and isolated dependency seams;check:mock-cleanupandcheck:test-file-cappassed.check:pending-fragmentpassed;AGENTS.mdnow requires cache/index discovery and compatibility validation before rebuilds.Test plan
bun run typecheckbun run lint:cibun run check:invariantsbun run check:mock-cleanupbun run check:cross-contaminationbun run check:test-clockbun run check:runtime-src-refsbun run check:eventsbun run check:retentionbun run check:registry-citationsbun run check:core-eventsbun run check:shell-auditbun run check:trajectory-storebun run check:test-file-capbun run check:pending-fragmentbun run check:gate-portabilitybun run check:bare-spawnbun run check:test-tmpdirbun run check:bash-portabilitybun run check:error-channel-discardbun run check:path-identitybun run check:token-formulabun run package:smokenode scripts/repro-704.mjsnode --input-type=module -e "await import('./dist/index.js'); console.log('dist import OK')"Known caveat: the issue-tracer checkpoint is bound to the clean committed HEAD only after publication; all code and validation gates passed before this PR was opened.