Repository navigation
fix(trust): add durable retry isolation for terminal analysis - #88
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoAdd durable, fenced retries for trust terminal analysis
AI Description
Diagram
High-Level Assessment
Files changed (30)
|
Code Review by Qodo
1.
|
|
|
@greptile review |
PR #88 final exact-head handoff — 2026-10-03PR: #88 — OPEN, unmerged; owner merges manually. Initial base: f9144a2. Durable contractterminal_event_retries is keyed by consumer/game/sequence. It stores failure count, finite retry deadline and paired nullable UUID lease token/expiry, with known-consumer, count, time and event-FK constraints. Successful receipts remain authoritative. No payload/error persistence, dead letter or backfill. Each consumer independently claims one eligible item in a short transaction using SKIP LOCKED plus a conditional upsert and a fresh receipt predicate. Ownership uses a random token and a five-minute lease. Renewal runs every minute with a ten-second renewal timeout; lease loss aborts analysis. Claiming, renewal and crashes do not increment failures. Failure n schedules min(21,600,000 ms, 120,000 ms × 2^min(n−1,8)); count saturates at 2,147,483,647, retry continues indefinitely at the six-hour cap. Success atomically writes the receipt and deletes owned retry state; stale failure, renewal and acknowledgement are fenced out. Expired crashed work can be reclaimed after restart. Both report repositories validate consumer/game scope and check the current unexpired token and absence of receipt under event/retry locks, then recheck ownership/expiry and cancellation before commit. Delayed stale writes, expiry during writing and cancellation roll back. Analysis runs outside database locks; fenced report SQL uses five-second transaction-local limits. Forward scans retain a 1,000-item window; reverse scans retain 100 and restart after exhaustion. Poison items are skipped until due while healthy later work progresses; reverse rediscovery prevents older due work starving behind sustained new endings. Malformed and contradictory endings use durable decode-failure retry without receipts. Helm trust-worker uses Recreate for upgrade separation. Apply migration 0048 before upgraded workers start; separately deployed legacy workers must be drained. Recreate does not guarantee absence of manually created/deleted-pod overlap; upgraded-worker leases protect such overlap. Logs retain coarse phase and closed-whitelist diagnostic codes without arbitrary exception/payload text. Verification
Final external gatesAll applicable mandatory checks PASS at final HEAD, including Node 22/24, PostgreSQL, real engines, gateway, Helm, Playwright/Lighthouse and pin parity. Production image build is path-gated and SKIPPED, not applicable. Qodo exact-head footer identifies 18f0104; Bugs 0, Rules 0. The PR-88-filtered portal lists only three historical resolved findings and no open actionable or requirement-gap finding (no separate gap counter exposed). Greptile exact-head review identifies 18f0104, confidence 5/5, all prior findings resolved and no outstanding/new blocking or nonblocking actionable findings. CodeRabbit skipped review for repository eligibility; supplementary only. All six review threads resolved; unresolved 0. Fresh fetch proves local HEAD = remote branch HEAD = PR HEAD = 18f0104. Local/remote divergence 0 0; current-main behind/ahead 0 3; worktree clean. Final gate/comment/thread JSON and restoration evidence are in this ignored evidence directory. Task-owned validation/PostgreSQL/Redis containers, anonymous volumes and network removed; filtered inventories are empty. Shared Docker daemon was left running. Deliberate limitsNo moderation/sanction/policy change, engine-limit change, public API/export/PGN change, new flags, telemetry subsystem or dead letter queue. Existing permanently stalled database I/O can delay graceful shutdown; abort does not physically cancel all general database requests. Process termination leaves a finite recoverable lease. Merge remains owner-only. Canonical Vault project destination is ambiguous, so execution write-back is Daily-only. |
Persistent corrupt endings previously retried on every trust-worker scan, and overlapping workers could repeat expensive analysis. This change gives each terminal item durable scheduling and fenced ownership per consumer while preserving successful receipts and forward/reverse discovery of unrelated work.
Migration 0048 adds retry state keyed by consumer/game/sequence, with known-consumer, count, finite-time and paired-lease constraints. Short PostgreSQL transactions claim one eligible item, record one failure per owned attempt, and atomically write receipts with retry cleanup. Five-minute leases renew every minute; renewal loss aborts analysis. Failure n waits min(21,600,000 ms, 120,000 ms × 2^min(n−1, 8)), capped at six hours indefinitely. Claims and crashes do not count as failures. Decode corruption uses this same recoverable path; complete ending validation follows the game authority.
Both trust report-writing paths carry the actual lease and cancellation signal. Their short transaction validates consumer/game scope, locks event then retry state, checks the unexpired token and receipt predicate, and rechecks before commit. Delayed stale writes, expiry during writing and cancellation roll back. Report transactions have five-second lock, statement and idle limits; no analysis runs under these locks. Existing unleased repository callers and domain interfaces retain their contract.
Helm uses Recreate for first-upgrade legacy/new separation. Apply migration 0048 before upgraded workers start and drain separately deployed legacy workers. Leases still protect accidental overlap of upgraded workers. No new flags, moderation policy, sanctions, engine search limits, public API or telemetry subsystem. Logs expose only coarse phase and closed-whitelist diagnostic codes, never arbitrary payload/exception text. A permanently stalled existing database operation can still delay graceful shutdown; process termination leaves a finite recoverable lease. ADR-0155 and append-only M15 Increment 85 document these limits.
Validation on the combined main tree:
Main advanced during implementation and was merged normally to 2dd6d4d, preserving Increment 84. Strict exact-head Codex self-review is the task-authorized fallback because Claude and Gemini are genuinely quota-unavailable. Final exact-head CI, Qodo, Greptile and unresolved-thread evidence follows their fresh runs. The owner performs the merge manually.