Repository navigation
refactor(ledger): deduplicate shard packing and runtime helpers - #1414
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 5:23 AM ET / 09:23 UTC. ClawSweeper reviewWhat this changesThe PR consolidates duplicate action-ledger shard packing, hashing, recovery, projection, and file-write helpers while removing redundant tests and dead helper paths. Merge readiness✅ Ready for maintainer review Keep open for normal maintainer review. The introduced refactor is narrow, preserves the ledger’s canonical validation paths, and has detailed after-change durable-output evidence; no actionable regression was found. Priority: P3 Review scores
Verification
How this fits togetherThe action ledger records review and apply activity as durable local event files. Recovery and import code consume those files to resume workflows safely and optionally project outcomes to CrabFleet. flowchart LR
Workflow[Workflow action] --> Ledger[Action ledger writer]
Ledger --> Spool[Durable event files]
Spool --> Recovery[Recovery and finalization]
Spool --> Import[Shard import validation]
Ledger --> Projection[CrabFleet projection]
Recovery --> Outcome[Workflow outcome]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Land the canonical helper consolidation while retaining the existing deterministic shard, durable-file, privacy, and recovery regression coverage. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a behavior-preserving refactor, and the relevant assessment is whether the after-change ledger exercise preserves durable behavior. Is this the best way to solve the issue? Yes: consolidating exact duplicate helpers into the existing canonical implementations reduces drift without changing the durable format or workflow contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 41caa32f64b5. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Landing: CI green on exact head b6c5483, ClawSweeper review reports real behavior verified (after-change local run with byte-identical durable output and publication order across 1,061 captured files) and no findings. Maintainer review confirmed the removed confidential-identifier check in attribute normalization is already enforced inside |
What Problem This Solves
The action-ledger writer and importer separately implemented identical shard packing. Runtime recovery and projection failure recording also repeated existing comparisons and field conversions, while the exclusive file writer carried an unused cleanup mode and identity result.
Why This Change Was Made
Use one shard-packing implementation, the existing SHA-256 helper, and the existing producer/subject conversions. Share repeated recovery predicates and phase comparisons; remove forwarding wrappers, unreachable bookkeeping, a duplicate confidential-identifier check, and one exactly duplicated replay-conflict test. The stronger replay-conflict test remains.
The file writer still leaves cleanup to its existing publication/lock owners. Serialization, filenames, lock records and protocols, timeouts, redaction patterns, and write ordering are unchanged. The runtime test file is unchanged, including the load-tolerant lock-wait assertions and release handshake from #1412.
User Impact
Behavior-neutral; no runtime contract, config, or workflow change.
Evidence
For this behavior-neutral refactor, the behavior proof is the full
pnpm run checkrun plus the targeted suites, supplemented by a pre/post comparison through the real local ledger writer, recovery, finalization, and importer.pr-behavior-proof contract
pnpm run build:all;node scripts/run-node-tests.mjs all -- --test-name-pattern='ledger|shard|projection|producer|lock';pnpm run check. Before and after the source edits:node /tmp/deslop-ledger-bytes.mjs, followed bycmp /tmp/deslop-ledger-before.json /tmp/deslop-ledger-after.json.45e96337e5d85fb4cda0234fb2efd04054722a4e5e5ed50e62c13a6e7d5868a4./tmp/deslop-ledger-bytes.mjs,/tmp/deslop-ledger-before.json,/tmp/deslop-ledger-after.json,/tmp/deslop-ledger-targeted.log, and/tmp/deslop-ledger-check.log; summaries below.action-ledger.test.ts: “durable shards batch sorted events once per producer job”; “durable shard writers split deterministically within importer event and byte limits”; “a shard identity cannot be reused for a different event set”; “shard paths use the stable run partition instead of event ordering”phaseSeqaction-ledger.test.ts: “durable shards preserve causal order ahead of source timestamps”;action-ledger-runtime.test.ts: “timeout recovery terminalizes the latest open mutation before its item summary”action-ledger-runtime.test.ts: “concurrent flushes converge on one immutable shard”; “destination import transactions prevent concurrent opposing parent edges”action-ledger-runtime.test.ts: “producer locks reclaim fresh dead owners and never evict a live holder by age”; “macOS producer/import locks retain live V1 owners and recover dead V1 owners”; “producer/import locks reclaim current-version PID reuse and reject unknown versions”; “producer and import writers serialize the platform's lock identity version”action-ledger.test.ts: “spool and shard writes reject symlinked parent directories”;action-ledger-runtime.test.ts: “partition markers and import destinations reject symlinked parents”action-ledger.test.ts: “identity hashing rejects values outside the canonical JSON domain”; “durable privacy guards reject raw text, local paths, secrets, and invalid digests”;action-ledger-runtime.test.ts: “workflow event scopes reject confidential identifiers before persistence or projection”clawsweeper-action-ledger.test.ts: “apply receipts start per item and persist mutation observation before finalization”OpenClaw Bay not affected: no dashboard changes.
Validation summaries:
Independent Codex autoreview:
scoped-cleanat P0/P1, with no accepted/actionable findings, usingautoreview --mode local --base origin/main --max-priority P1. Full output: local/tmp/autoreview-deslop-ledger.md.Validated source committed as
b6c548305without further source changes after proof or review.