Skip to content

feat(ledger): add immutable action history core - #511

Merged
vincentkoc merged 56 commits into
mainfrom
feat/action-ledger-core-v2
Jul 12, 2026
Merged

vincentkoc merged 56 commits into
mainfrom
feat/action-ledger-core-v2

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Jul 12, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add immutable, create-only JSONL action shards with deterministic replay and conflict detection
  • restrict identity inputs to strict canonical JSON with safe integers only; large identifiers must be strings
  • require explicit outcome-independent idempotency identities for mutations
  • bind repository and SHA into replay-stable producer identities and shard paths
  • preserve source timestamps while deterministically sorting causal children after parents
  • keep CrabFleet projection failures durable without logging response bodies

Correctness Hardening

  • reject email-shaped private values including single-label internal domains, Slack xox* tokens, and AWS AKIA/ASIA access keys with runtime/schema parity
  • keep every imported shard part invisible to canonical readers until its reservation and completion marker validate
  • reclaim stale locks by atomically claiming the observed inode, preserving a raced successor lock
  • treat Linux zombie owners as dead, strengthen macOS PID incarnation identity, and bypass PID-only caches for stale-lock decisions
  • coordinate projection admission with the producer lock so finalization cannot drain before a persisted projection is registered
  • restrict durable data paths to portable segments under the intended data namespaces, with runtime/schema parity
  • reject impossible calendar timestamps and year 0000 consistently in runtime and schema validation
  • serialize producer seal checks, partition markers, spool writes, and finalization with per-producer exclusive locks
  • publish primary shards before a root-scoped projection drain, then seal projection-failure producers in a second pass
  • validate direct CrabFleet events before admission and bound queued rejection when active cleanup never settles
  • isolate workflow projection drains by canonical spool root while retaining the global four-request admission bound
  • serialize destination imports from global causal validation through payload verification and completion
  • reserve exact shard sets before payload publication and publish completion only after reread verification
  • use fair root-scoped projection admission so one root cannot starve another
  • cap existing and raced shard reads at 2 MiB and partition-marker reads at 64 bytes
  • bound spool repository fanout, entries, producers, events, and aggregate bytes before retaining and sorting
  • require direct shards to be non-empty, unique, acyclic, canonically ordered, and within the 1024-event limit

Design

  • local writers spool one immutable event file per transition
  • workflow finalization batches events into digest-addressed shards per full producer identity
  • shard paths are ledger/v1/events/YYYY/MM/DD/<producer-repo>/<producer>/<run-attempt-job-digest>.jsonl
  • shard partitions derive only from immutable workflow metadata or an explicit stable date
  • source timestamps remain evidence; causal topology resolves ordering conflicts
  • mutable comments, dashboards, sessions, command ledgers, and evidence graphs remain projections

Exact-Head Validation

Head: 255499c68fc69deeffca6b5fbba2cf177b9b7287

Local runtime: Node v26.5.0, pnpm 11.10.0

  • pnpm run build && node --test test/action-ledger.test.ts test/action-ledger-runtime.test.ts
    • 133 tests: 131 passed, 0 failed, 2 Linux-only skips
    • covers privacy parity, interrupted multi-part import visibility, atomic successor-safe lock reclamation, macOS PID incarnation identity, projection/finalization admission, and the hosted contention regression
  • AWS Crabbox cbx_6ec6c62426e7, run run_1d1ea2c65a59, Node v24.18.0
    • Linux PID-reuse cache bypass: passed
    • Linux zombie-owner reclamation: passed
    • exclusive lock contention/create rollback/disappearance race: passed
    • 3/3 passed; disposable lease auto-stopped
  • pnpm run check
    • exit 0
    • unit tests: 1061 passed, 0 failed, 2 Linux-only skips
    • repair tests: 884/884
    • changed coverage tests: 884/884
    • changed coverage: 100.00% lines, 86.90% branches, 100.00% functions
    • full coverage tests: 1945 passed, 0 failed, 2 Linux-only skips
    • full coverage: 74.26% lines, 73.49% branches, 84.41% functions
    • formatting passed for 358 files
  • git diff --check: passed
  • privacy scrub: no personal paths, private IPs, internal hostnames, or non-public addresses in the branch diff
  • hosted exact-SHA checks: 6 successful, 0 failing, 0 pending; one duplicate activity notification was skipped

Hardening Commits

  • 08c3a120b5 fix(ledger): reject service credentials and internal emails
  • d1ddbe1b5c fix(ledger): hide incomplete shard imports
  • b22e12cdd1 fix(ledger): reclaim stale locks atomically
  • f397cbbfb0 fix(ledger): register projections before finalization
  • 255499c68f fix(ledger): validate import marker field types

Follow-ups

  • instrument review/apply and sweep publication
  • instrument command, repair, notification, and operational workflows
  • bind review and closure evidence to Gitcrawl snapshots and Cloudflare archive queries
  • add deterministic projection rebuilds and retention compaction

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 12, 2026
@clawsweeper

clawsweeper Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 12, 2026, 9:45 AM ET / 13:45 UTC.

Summary
The PR adds an immutable action-ledger v1 core with canonical event identities, create-only JSONL spooling and shards, hardened filesystem operations, deterministic replay and import, optional CrabFleet projection, a strict JSON Schema, design documentation, and adversarial tests.

Reproducibility: not applicable. This PR introduces a new durable subsystem rather than reporting broken current-main behavior; confidence comes from exact-head source, schema, documentation, and adversarial validation evidence.

Review metrics: 4 noteworthy metrics.

  • New durable surface: 7 files, 10,288 lines added. The branch introduces a large persistence and security-sensitive subsystem rather than a localized feature.
  • Focused test surface: 2 files, 4,839 lines added. Nearly half the patch exercises replay, privacy, import, projection, and adversarial filesystem behavior.
  • Production integration: 0 existing production files changed. The core is isolated; feat(ledger): instrument review and apply actions #512 owns the first workflow integration.
  • Review history: 17 completed cycles, 0 prior findings. Repeated exact-head review has not identified a discrete actionable patch defect.

Root-cause cluster
Relationship: canonical
Canonical: #511
Summary: This PR is the canonical action-ledger core; the open stacked PR consumes it, while the merged proof-gate PR is adjacent security architecture rather than a replacement.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦀 challenger crab
Proof: 🌊 off-meta tidepool
Patch quality: 🦀 challenger crab
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] Once stacked writers begin publishing, the v1 event schema, canonical identities, conflict semantics, shard layout, import bindings, and privacy rejection rules become compatibility constraints requiring explicit migration for later changes.
  • [P1] CrabFleet projection creates an outbound data and operational boundary; maintainers must intentionally own what is eligible for projection, how failures queue and time out, and how retained immutable records remain privacy-bounded.
  • [P1] The documented dual-write migration preserves legacy projections, but upgrade safety depends on parity and operational validation in feat(ledger): instrument review and apply actions #512 and later lane integrations.

Maintainer options:

  1. Accept the complete v1 boundary (recommended)
    Merge after a central runtime owner explicitly approves the schema, identities, shard/import format, privacy rules, retention direction, and outbound projection contract.
  2. Revise before writers land
    Request focused core changes now so stacked instrumentation does not create durable data under a contract maintainers intend to alter.
  3. Pause the ledger stack
    Defer or close the proposal if the project is not ready to own immutable history and its operational storage commitments.

Next step before merge

  • [P2] The remaining action is explicit central-runtime owner acceptance of the permanent compatibility, privacy, retention, and operational contract; no narrow automated repair is supported.

Maintainer decision needed

  • Question: Should ClawSweeper adopt this action-ledger v1 schema, identity model, privacy boundary, shard/import format, and CrabFleet projection contract as the permanent foundation for future workflow instrumentation?
  • Rationale: The patch can be technically correct while still committing the project to durable product, compatibility, privacy, retention, and operational semantics that automated review cannot authorize.
  • Likely owner: steipete — Peter Steinberger is the strongest available final-decision candidate because he merged the adjacent proof architecture and directly connected it to this PR.
  • Options:
    • Approve v1 and merge core (recommended): Accept the complete durable contract, merge this isolated core, and review feat(ledger): instrument review and apply actions #512 separately for safe dual-write integration.
    • Request contract revisions: Keep the stack paused and specify the schema, privacy, retention, import, or projection guarantees that must change before writers adopt it.
    • Defer immutable history: Pause or close the stack if the operational storage and long-term compatibility commitments are not currently sponsored.

Security
Cleared: The exact-head pass found no concrete security or supply-chain defect; the remaining security-boundary concern is intentional owner acceptance of the durable privacy and projection contract.

Review details

Best possible solution:

Approve the isolated v1 core as an explicit durable-data contract, then land writer integrations incrementally with dual-write parity, legacy behavior preserved, and real workflow evidence before treating the ledger as authoritative.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR introduces a new durable subsystem rather than reporting broken current-main behavior; confidence comes from exact-head source, schema, documentation, and adversarial validation evidence.

Is this the best way to solve the issue?

Yes, conditionally: separating the reusable core from staged dual-write instrumentation is a controlled and maintainable rollout, but the permanent compatibility and privacy contract requires explicit owner approval.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3817dde287cb.

Label changes

Label justifications:

  • P2: This is a substantial architectural improvement with limited immediate runtime impact because existing production writers are not yet changed.
  • merge-risk: 🚨 compatibility: Once used, the v1 schema, identities, conflict semantics, shard paths, and import bindings constrain future writers, readers, and migrations.
  • merge-risk: 🚨 security-boundary: The subsystem durably stores privacy-filtered automation evidence, performs hardened filesystem mutations, and can transmit structured events to CrabFleet.
  • rating: 🦀 challenger crab: Overall readiness is 🦀 challenger crab; proof is 🌊 off-meta tidepool and patch quality is 🦀 challenger crab.
  • feature: ✨ showcase: ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. A privacy-bounded immutable action history directly advances auditability, recovery, and deterministic projection rebuilding across ClawSweeper automation lanes.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The contributor is a repository member, so the external-contributor real-behavior proof gate does not apply; the supplied exact-head checks and adversarial validation remain useful supporting evidence.
Evidence reviewed

What I checked:

  • Current-main gap: Current main contains no action-ledger source, schema, or documentation; all seven ledger files are new on the PR head. (src/action-ledger.ts:1, 6fa4b8608833)
  • Durable contract: The design makes immutable events authoritative and specifies first-writer conflict behavior, stable identities and shard limits, trusted-root imports, privacy exclusions, projection behavior, and dual-write migration. (docs/action-ledger.md:3, 6fa4b8608833)
  • Vision alignment: The repository VISION.md prioritizes reliable durable audit state that is reproducible, source-linked, and safe from secret or private-data exposure. (VISION.md:25, 3817dde287cb)
  • Exact-head continuity: The current head matches the latest completed ClawSweeper review; 17 completed cycles reported no actionable finding. (6fa4b8608833)
  • Isolated rollout: The branch adds seven files without modifying an existing production path; the dependent instrumentation work is separately tracked by feat(ledger): instrument review and apply actions #512. (6fa4b8608833)
  • Ownership provenance: Blame and log history connect the existing stable JSON, structural-cache, central runtime, and CrabFleet action-session surfaces to Vincent Koc; Peter Steinberger merged adjacent proof-gate work and is the likely final acceptance owner. (src/stable-json.ts:1, 3817dde287cb)

Likely related people:

  • vincentkoc: Git history ties Vincent Koc to the existing stable serialization, structural-cache, central runtime, and CrabFleet action-session code, the adjacent staged proof-gate work, and the entire proposed ledger series. (role: feature owner and recent security-automation contributor; confidence: high; commits: ce054cf0, 588c64d4d2f0, 6fa4b8608833; files: src/stable-json.ts, src/review-structural-cache.ts, src/repair/action-session.ts)
  • steipete: Peter Steinberger merged the adjacent proof-gate architecture and cross-referenced it from this PR, making him the strongest available candidate to approve the permanent runtime contract. (role: merger and likely final product owner; confidence: medium; commits: 588c64d4d2f0; files: src/repair)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (17 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-12T11:45:32.997Z sha 4a0958c :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T12:06:20.897Z sha bd7b4ac :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T12:14:56.605Z sha 4bde1c3 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T12:33:23.000Z sha 74d1125 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T12:52:46.417Z sha 365f2b4 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T13:02:48.367Z sha 6c0d201 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T13:09:30.050Z sha ff4ea59 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T13:40:15.644Z sha 6fa4b86 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 12, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. proof: sufficient Contributor real behavior proof is sufficient. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. proof: sufficient Contributor real behavior proof is sufficient. labels Jul 12, 2026
@vincentkoc
vincentkoc force-pushed the feat/action-ledger-core-v2 branch from 6c0d201 to ff4ea59 Compare July 12, 2026 13:04
@vincentkoc
vincentkoc force-pushed the feat/action-ledger-core-v2 branch from ff4ea59 to 6fa4b86 Compare July 12, 2026 13:36
@clawsweeper clawsweeper Bot added rating: 🦀 challenger crab Exceptional PR readiness: strong proof, clean patch, and convincing validation. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jul 12, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review July 12, 2026 16:20
@vincentkoc
vincentkoc merged commit 7cc5527 into main Jul 12, 2026
9 checks passed
@vincentkoc
vincentkoc deleted the feat/action-ledger-core-v2 branch July 12, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. rating: 🦀 challenger crab Exceptional PR readiness: strong proof, clean patch, and convincing validation. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant