Repository navigation
Conversation
|
I found one source-level gap that looks worth fixing before this closes the corrupted-row recovery issue. The new The same edge exists for direct I did not run the PR branch locally; this is from reading the current diff plus |
|
Codex review: needs maintainer review before merge. Reviewed July 5, 2026, 8:44 AM ET / 12:44 UTC. Summary PR surface: Source +117, Tests +305. Total +422 across 3 files. Reproducibility: yes. Source inspection shows current main and v2026.6.11 both call bare JSON.parse while materializing persisted channel ingress rows, and the PR body includes a negative-control terminal run showing SyntaxError failures against the old code. Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the queue-layer guard after maintainer review accepts the corrupt-row tombstone semantics and exact-head required checks remain green; no broader plugin API change is needed. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main and v2026.6.11 both call bare JSON.parse while materializing persisted channel ingress rows, and the PR body includes a negative-control terminal run showing SyntaxError failures against the old code. Is this the best way to solve the issue? Yes. The shared ingress queue materialization, duplicate, claim, and stale-recovery layer is the narrow owner boundary; plugin-specific guards would miss other users of the same queue. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 601b80c5f4c1. Label changesLabel justifications:
Evidence reviewedPR surface: Source +117, Tests +305. Total +422 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (9 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
11ed39d to
1c7bac6
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
1c7bac6 to
4c37844
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
4c37844 to
ca292d0
Compare
|
@clawsweeper re-review Rebased onto latest main, conflicts resolved. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
7d8e39b to
ca292d0
Compare
ca292d0 to
eba795a
Compare
…tale recovery Two P1 gaps: enqueue() threw on duplicate when the existing row had corrupt payload_json, and recoverStaleClaims() silently skipped corrupt claimed rows, leaving them invisible to recovery. Both paths now tombstone the unrecoverable row as failed with reason "corrupt_payload" and return a proper result. Co-Authored-By: Claude Opus 4.7 <[email protected]>
Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
@clawsweeper re-review Fixed the two P1 gaps from last review:
All 25 tests pass (23 original + 2 new), lint clean. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Maintainer review: malformed JSON should not crash every queue read, but this head changes delivery ownership and ordering without a proven corruption producer, so I am not landing it.
The safe repair needs a concrete producer/repro, one explicit quarantine transition that conditionally matches the exact observed row/claim, and lane-preserving behavior. Please prove Telegram and WhatsApp redelivery/claim recovery live, including a dropped ACK and concurrent renewal negative control, before changing this shared queue contract. I am keeping this open; no branch changes or landing from this review. |
|
Landed the current-main replacement in #105259 as commit The final fix preserves the original corruption report and contributor credit while adding durable Kysely compare-and-set tombstones, bounded claim reconciliation, stable keyset listing, active-claim protection, and owner-aware Telegram stale recovery. The replacement was necessary because the original branch's parse-and-skip path could still starve later work and could not safely recover corrupt claimed rows. Thank you @Pick-cat for finding the durable queue failure and iterating on the original repair. For future PRs, keeping Allow edits by maintainers enabled lets us preserve the original PR branch when larger current-main fixups are needed. |
What Problem This Solves
Fixes an issue where a single corrupted
payload_json,metadata_json, orcompleted_metadata_jsonrow in the SQLite channel ingress queue crashes the entire queue operation. TheparseJson()helper callsJSON.parse(value)without a try-catch. A corrupt row throws an uncaughtSyntaxErrorthat propagates throughbaseRecord()(called bylistPending,listClaims,claimNext,enqueue) andcompletedRecord()(called byenqueueduplicate detection). One bad row inlistPending()orlistClaims()kills all entries in that listing. This affects every channel that uses the durable ingress queue for inbound message processing.Additionally,
claimNextandclaimwould UPDATE a pending row toclaimedstatus before validating the payload could be decoded — so a corrupt payload could become an invisible claimed row, hidden fromlistPending/listClaims/recoverStaleClaims, permanently blocking queue recovery.Why This Change Was Made
Tagged parse result:
parseJson()now returns{ ok: true, value } | { ok: false }instead of the ambiguousunknown | null.JSON.parse("null")is valid and returnsnull, which the old sentinel conflated with parse failure. The tagged result cleanly separates "valid JSON value" from "corrupt input".Guard
parseJsonat the chokepoint:baseRecord()returnsnullwhenpayload_jsonis corrupt (unrecoverable). Corruptmetadata_json/completed_metadata_jsonis non-fatal — the record is kept with metadata omitted. All callers (listPending,listClaims,enqueue,claimNext,claim) handle null/omitted results.Validate before claiming:
claimNextcallsbaseRecord()insiderows.find()to skip corrupt rows before they are selected, andclaimpre-reads the pending row and validatesbaseRecord()before issuing the UPDATE. No corrupt row can ever be promoted toclaimedstatus.Tombstone corrupt rows on duplicate enqueue: When
enqueue()finds a duplicate event whose existing row has a corruptpayload_json, it now tombstones the corrupt row asfailedwith reason"corrupt_payload"instead of throwing. The caller receives{ kind: "failed", duplicate: true }.Recover corrupt claimed rows during stale recovery:
recoverStaleClaims()now scans raw claimed rows directly (bypassinglistClaims()which filters out corrupt rows). Corrupt claimed rows are tombstoned asfailedinstead of being left permanently invisible to recovery.User Impact
No user-visible impact under normal operation. When a channel ingress queue row is somehow corrupted:
listPending/listClaimsskip the bad entry instead of crashingclaimNext/claimskip corrupt rows and claim the next valid oneenqueueduplicate detection tombstones corrupt rows and returns a proper resultrecoverStaleClaimstombstones corrupt claimed rows so they don't block the queuenullpayload is correctly preserved (not treated as corrupt)Real behavior proof
createChannelIngressQueueagainst a real on-disk SQLite database.93572a00b0.New tests cover: pending row with corrupt
payload_json→ skipped, corruptmetadata_json→ metadata omitted, corrupt claimed row → skipped inlistClaims, corruptcompleted_metadata_json→ duplicate detection works,claimNextskips corrupt pending → claims next valid,claimrejects corrupt pending, valid JSON null → preserved, duplicate enqueue of corrupt row → tombstoned as failed, stale recovery of corrupt claimed row → tombstoned as failed.Restoring the fix returns to 25/25 green. The negative control is load-bearing: same tests, same corrupt rows, same disk boundary.
Evidence
Existing tests — no regressions:
Additional validation:
Lint:
oxlintclean on both changed files.Rebased onto latest
origin/main, fixed thecheck-test-typesfailure from typed empty mock call tuple access in gateway cron tests, and reran local autoreview with no accepted/actionable findings.AI-assisted.