Repository navigation
fix(audit): keep recording after a rejected metadata event - #176608
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs changes before merge. What this changesThis PR isolates rejected audit metadata records and combines overflow cutoff selection with retention deletion. Example: Record run "before", submit metadata containing a function, then record run "after".
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this maintainer-authored PR open: it repairs a current audit-writer defect, and no definite production regression was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherTrusted lifecycle producers submit metadata to a bounded process-owned FIFO, which dispatches persistence and retention operations through the shared-state worker. flowchart LR
A[Lifecycle producers] --> B[Audit writer]
B --> C[Structured clone boundary]
C --> D[Bounded FIFO]
D --> E[Shared state worker]
E --> F[Audit store and retention]
F --> G[Audit queries]
Technical reviewBest possible solution: Keep per-record rejection in the existing FIFO owner and preserve retention semantics through the existing transactional store. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the writer-boundary sequence: an uncloneable record sets unavailable, then all later submissions return false; this review executed no target code. Is this the best way to solve the issue? Removing the latch fixes the owning failure without adding recovery policy; the retention rewrite preserves the existing cutoff and removes one SQL round trip. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c576536264da. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -27, Tests +97, Docs +1. Total +71 across 7 files. Added test files: 2. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 18, 2026, 7:34 PM ET / 23:34 UTC. |
…#176608) Keep audit recording available after rejected metadata. Fold overflow cutoff selection into the bounded delete, and repair retention count drift once when no rows are deleted. Preserve retention bounds, FIFO settlement, eager PostgreSQL writer locking, and unknown-outcome no-replay behavior.
What Problem This Solves
The audit writer permanently rejects later metadata after one record cannot be cloned, and overflow pruning uses a separate cutoff read before deleting old records.
User Impact
A rejected metadata record no longer disables later audit recording. Retention bounds, FIFO ordering, duplicate-source behavior, and shutdown settlement stay unchanged. No migration or configuration change is required.
Why This Change Was Made
Put the retention cutoff in a scalar subquery of the existing bounded DELETE. Keep the existing transaction and eager PostgreSQL lock before its authoritative work. Remove the obsolete unavailable latch, duplicate progress classification, redundant readiness state, contention-counter wrapper, and retry lower clamp. Native Promise settlement and the existing retry owner already supply those guarantees.
When the cached retention count drifts above the durable count, a zero-row overflow delete refreshes the real count and expiry once. Later inserts then use the repaired owner state without repeating DELETE/MIN queries. A successful overflow deletion still refreshes the retained expiry boundary.
The removed
isOutboundMessageProgressInputguard inrecordAuditEventInDatabasehad no runtime caller besidessrc/audit/audit-event-writer.worker.ts:80–88. That worker classifies progress at line 85 and routes it torecordOutboundMessageProgressInDatabaseat line 86; only terminal audit events reachrecordAuditEventInDatabaseat line 88. Repository reference search confirms no second runtime caller.The cold-open contention boundary, drain reentry guard, execution binding, identity projection, and unknown-outcome no-replay behavior remain. Audit metadata is still best effort: the rejected record is reported and dropped; later valid records continue. The two ordinary per-turn audit requests remain separate because their producers straddle model execution.
Production: +22/-43 lines (net -21). Tests: +205/-32 (net +173), including one shared SQLite/PostgreSQL fixture. Documentation: +1. Test routing: +1.
Evidence
Formatting, type-aware oxlint on all six changed TypeScript files, and
git diff --checkpass. Two isolated Codex P0–P2 review rounds completed. The first was scoped-clean; the correction review found reused source IDs in the new count-drift fixture. Each event now has a distinct ID, so the regression reaches retention recovery rather than audit deduplication. Preparation-only interruptions did not produce additional model rounds. The prior-head run 39178651043 passed all selected jobs except PostgreSQL shard 1 and its aggregate: both new PG cases failed before assertions withMissing PostgreSQL state admission. This head adds the retention test to the database-hosted test registry, correcting that routing. The coordinator approved this exact registry addition. Final-head ordinary CI 39182445508 passes the changed-owner tests, type checks, lint, source contracts, and Madge. All three PostgreSQL shards pass in the exact-head supplemental run 39182457718, including the corrected retention-test routing. Its unrelated remaining jobs were cancelled after required evidence was collected. The mock-export ratchet failure atsrc/cli/program/root-help.test.ts:33matches current main 39182492985/job/117838287257.Head
d7b064463f4c92bb2512ac726637b5efb5fbfc9fintegrates maine7db41f0c8e9ab25b4a4104474054e5201c8d22e. All seven previously reviewed source/test/doc blobs remain byte-identical to PG-approved812fbe05cbbe91703fe4f99991b6f1be275ae015; the only additional change is the registry entry. Registry formatting/type-aware lint and native commit hooks pass. Shared-semaphore frozen installs completed successfully; tsrs0.16.0-ts7.1.0-dev.20260929is installed, and all type checks use repository lanes. Default pinned Bun is retained for local tests.The count-drift regression requires one recovery insert, one zero-row delete, and one count/expiry refresh, then exactly one INSERT for each subsequent event. Each PostgreSQL regression has its own database lifecycle. The shared retention regression exercises overflow with sequence gaps, the exact retained window, duplicate replay, and the next sequence. It expects four audit-table statements instead of five for a cold overflow insert. A real queue regression checks valid-before, rejected-uncloneable, valid-after, shutdown drain, and persisted FIFO order. All three baseline regressions fail at the intended assertions: overflow uses five audit-table statements instead of four; an uncloneable event disables later records; count drift causes six statements for the next two inserts instead of two. All three candidate regressions pass under the default pinned Bun runtime. Final Knip 39182457718/job/117838199069 has zero new findings: only FaceTime test exports
commandResult,mutedResult, andoutgoingCall (ft), identical to scheduled main 39176649118/job/117820741086.Estimated, unmeasured workload impact: one fewer SQL statement per retention overflow; no change to ordinary warm-turn SQL, worker requests, or MAIN work. No latency claim. Combined workload counts are deferred to the coordinated SQLite/PostgreSQL census. Exact-head PostgreSQL review approved
d7b064463f4c92bb2512ac726637b5efb5fbfc9f.