Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@

`AGENTS.md` and `docs/engineering-invariants.md` together are the single source of truth for repository invariants. When `CLAUDE.md`, `contributing.md`, `TESTING.md`, or any skill conflicts with this file, **this file wins**; that skill or doc is out of date and must be reconciled.

## Repository-history cache reuse

- Before creating or rebuilding any repository-derived cache or index, agents must first search the current worktree and known sibling/source repository locations for an existing compatible artifact.
- Before initializing, rebuilding, or performing a full sync of a ZaxbyGraph issue/PR database, search the current worktree and known sibling/source repository locations for an existing cache first.
- Validate any discovered cache against the requested repository and inspect its sync metadata before reuse. When it is compatible, reuse it in place if writable or copy it into the current worktree and run only an incremental sync.
- Build a new cache from scratch only when no compatible, usable cache exists. Record that discovery result before starting the rebuild so agents do not repeat avoidable GitHub API work or consume rate limits unnecessarily.

## Prime directive

Preserve the runtime contracts that keep the plugin **loadable, portable, bounded, recoverable, and safe** across Windows, macOS, Linux, GUI, TUI, Bun, and Node-hosted plugin contexts.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# PR feedback-loop production wiring (issue #2745)

## What changed

- Wired loop settlement and canonical reactivation behind the existing triple
opt-in: `pr_monitor.enabled`, `pr_monitor.auto_pr_feedback`, and
`pr_feedback_loop.enabled`.
- The pre-existing two-flag subscriber path still activates `PR_FEEDBACK`
before oversight; this change connects the #2745 settlement and canonical
reactivation gates after that initial activation.
- Added authenticated, per-root current-head lookup and isolated read-only
critic oversight. Authorization, cancellation, and oversight-evidence
failures now fail closed before an action can run.
- Made prompt/advisory delivery per-root, ordered after acceptance, deduplicated,
and truthful about what was delivered. Flag-disabled configurations retain
their prior behavior, and the loop does not publish PR comments automatically.

## Why

The feedback-loop stages existed but were not connected to the production
runtime: the default head evaluator returned no head and the production
dispatch/delivery seams were inert. This wiring makes the opt-in path usable
without weakening the existing safety gates or allowing cross-root delivery.

## Migration

No migration is required. Enable all three PR feedback-loop flags to opt in to
the new settlement/reactivation path; leaving any flag disabled preserves the
previous behavior.

## Known caveats

The loop remains fail closed when the authenticated GitHub lookup, read-only
critic, durable claim, cancellation check, evidence write, or configured
prompt/advisory channel is unavailable. No automatic PR publication is added.
Live exact-owner reservations prevent duplicate actions; a dead owner can be
recovered only before the side-effect start marker is durable. Once that marker
exists, uncertainty fails closed and pauses for human inspection rather than
replaying the action.
4 changes: 2 additions & 2 deletions scripts/retention-registry.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,8 @@ export const RETENTION_REGISTRY: readonly RetentionRow[] = [
pathGrammar: '.swarm/pr-feedback-events/{session-stem}.json (+ .lock)',
canonicalRoot: 'project-swarm',
writerModules: ['src/background/pr-feedback-event-queue.ts'],
writerCitations: ['src/background/pr-feedback-event-queue.ts:281 writeQueueRecord — atomic temp+fsync+Windows-retry rename (enqueue/claim)'],
readerCitations: ['src/background/pr-feedback-event-queue.ts:480 readPrFeedbackMonitorQueueFromDisk — bounded ≤512 KiB with identity verification, async'],
writerCitations: ['src/background/pr-feedback-event-queue.ts:376 writeQueueRecord — atomic temp+fsync+Windows-retry rename (enqueue/claim)'],
readerCitations: ['src/background/pr-feedback-event-queue.ts:575 readPrFeedbackMonitorQueueFromDisk — bounded ≤512 KiB with identity verification, async'],
schemaVersion: 'schemaVersion 1 (:35)',
stateClass: 'operational',
privacyClass: 'metadata',
Expand Down
11 changes: 11 additions & 0 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ export {
type PrEventSubscriberOptions,
registerPrEventSubscribers,
} from './pr-event-subscribers';
export {
dispatchPrFeedbackOversight,
evaluatePrFeedbackCurrentHead,
getPrFeedbackLoopRuntime,
type PrFeedbackLoopOversightInput,
type PrFeedbackLoopOversightOutcome,
type PrFeedbackLoopRuntime,
type PrFeedbackLoopRuntimeOptions,
type PrFeedbackLoopRuntimeRegistration,
registerPrFeedbackLoopRuntime,
} from './pr-feedback-loop-runtime';
// PR Monitor Worker for background PR status polling (lazy-started)
export {
PrMonitorWorker,
Expand Down
Loading