← Back to Pull requests

feat(audit): submit canonical commitments through the durable Anchorer (#52) #267

Re-review Required
CierCier merged 22 files (2994 lines) on Nov 29, 2026 05:13 UTC
View on GitHub
CierCier CierCier commented on Nov 29, 2026 05:12 UTC
Author

<!-- claude-projects-attribution: {"github_login":"CierCier"} -->
_Requested by cier · project thread_

Closes #52 (CHAIN03).

What this does

Adds packages/audit.DurableAnchorer, which submits a stored manifest's CT09 public commitment to the registry as anchor(1, id, C) (C from CHAIN07, domain from an enabled CHAIN01 descriptor).

  • One logical request per commitment. Migration 017 adds immutable audit_anchor_requests (random anchor-req: retry ID, unique per adapter and commitment ID, must reference a stored manifest with the same digest), audit_anchor_transactions (one signed tx per request, random evm-tx: reference, unique writer nonce) and append-only audit_anchor_attempts.

  • Persist before broadcast. The signed EIP-1559 bytes, hash, nonce and reserved fee are committed before eth_sendRawTransaction. A restart or Resume rebroadcasts the same bytes and never signs again.

  • Checks before signing. Chain ID, registry runtime-code hash, current writer authorization, the registry's entry for the ID (already_anchored / digest_conflict), per-transaction fee ceiling and rolling 24h reservation budget. A per-adapter Postgres advisory lock serializes nonce and fee allocation across controller processes.

  • Signer stays separate. The writer key lives in an external service reached over eth_signTransaction (Clef/Web3Signer/Anvil shape). The returned envelope is RLP-decoded and every field must equal the approved call (zero value, no access list), or it is refused as signer_mismatch.

  • Console API. POST /console/api/audit-manifests/{id}/anchor (fresh admin) and GET (admin). Responses carry only opaque IDs, evidence class and outcomes. anchor_state is unverified or pending, never finalized. Retryable refusals return 503, non-retryable ones 409.

  • Controller wiring. --chain-descriptor-file plus DEVICE_AUDIT_CHAIN_RPC_URL / DEVICE_AUDIT_CHAIN_SIGNER_URL (environment variables, so URLs with credentials stay out of argv, logs and the descriptor). The controller resumes stored work at startup and every 5 minutes.

  • The unimplemented legacy Anchorer.Commit/Verify interface (with its Finalized receipt flag) is replaced by Submit/Resume.
  • Evidence

    All run locally on 29 Nov in the cloud container: PostgreSQL 16, Foundry/Anvil v1.7.1, solc 0.8.39.

  • go test -race -tags=chain_integration ./contracts/integration: new TestDurableAnchorerSubmitsThroughRPCAndSigner plus the 3 existing tests pass. It uses the production JSON-RPC client and RPC signer: fee-ceiling refusal before signing (nonce stays 0), lost broadcast, restart rebroadcasting identical bytes with a signer that refuses every call, mined Anchored(1,id,C) event and state, duplicate request spending no nonce, ID already on-chain, revoked writer. Local: 71,941 gas, reserved worst case 9.0e13 wei (< 0.0001 ETH ceiling), 213-byte envelope.

  • PostgreSQL store tests: fee refusal then restart; six concurrent adapters over one DB sign exactly one tx; nonces 7,8 from the ledger; unknown/altered/cross-registry commitments refused; rows immutable and free of manifest nonce, device ID, evidence ID and manifest digest; routes enforce fresh admin and never expose signed bytes or tx hash.

  • make check (fmt, vet, race tests with TEST_DATABASE_URL, model-check, fake-check), make cross-build, make contract-check (367 golden vectors, 81 wire cases) pass.
  • Details: docs/validation/chain-anchorer-52.md. Decision entry and requirements row updated.

    Caveats / not tested

  • No Base Mainnet/Sepolia RPC, live fee quote, real OP Stack getL1FeeUpperBound oracle (required on 8453/84532, absent on Anvil so 0 there), funded writer or production signing service/custody. Anvil's unlocked account stood in for the signer.

  • The adapter cannot recover the signing address without secp256k1. Writer authorization at inclusion stays a receipt check (#126/#127).

  • Receipt tracking after broadcast (pending/finalized/reverted, reorg, nonce reconciliation, replacement txs, releasing fee reservations) is #126. Until then reservations are never released, so the rolling budget errs toward refusing.

  • No queue saturation bound or stuck-request alerting yet.

  • The CI chain integration job (if any) needs Foundry and solc 0.8.39. I did not add new CI wiring.

  • A stray remote branch claude/52-durable-anchorer (same commit) was pushed by mistake and the proxy refused to delete it. It can be deleted safely.
  • ---
    _Generated by Claude Code_

    Diff: 2994 lines (+2960 / -34) across 22 files Reviewer: jR4dh3y Review duration: 1m
    Review confidence threshold not met — re-review recommended
    Residual risk 0.68 = Change Risk (0.87) × (1 − Review Confidence (0.21)). Flagged for follow-up review before production rollout.
    Model 1 · Change Risk (XGBoost)
    Score: 0.87 · 2994 lines diff across 22 files
    0.87
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.30 · 1 substantive comment(s)
    0.30
    Model 3 · Review Timing & Attention
    Session adequacy: 1% · Reviewer familiarity: 50%
    20%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Shallow Review Depth shallow_review_depth
    0.247
    Rapid Merge rapid_merge
    0.100
    Mass File Touch mass_file_touch
    0.080
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    4 items
    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 29, 2026 05:12 UTC
    Reviewer

    Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

    coderabbitai[bot] coderabbitai[bot] commented on Nov 29, 2026 05:12 UTC
    Bot

    <!-- coderabbit-ai-generated:v1 -->

    <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
    <!-- review_stack_entry_start -->

    <a href="https://app.coderabbit.ai/change-stack/i-got-this-faa/device-audit/pull/267?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a>

    <!-- review_stack_entry_end -->
    <!-- This is an auto-generated comment: failure by coderabbit.ai -->

    [!CAUTION]

    ## Review failed

    > <!-- failure_reason_start -->

    The pull request is closed.

    <!-- failure_reason_end -->

    <!-- end of auto-generated comment: failure by coderabbit.ai -->

    <!-- autopilot:start -->

  • <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

  • <!-- autopilot:end -->
    <!-- tips_start -->

    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.

    <details>
    <summary><strong>Share</strong></summary>
    <dl>
    <dd>
    <br>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </dd>
    </dl>
    </details>

    <!-- tips_end -->

    jR4dh3y jR4dh3y approved these changes on Nov 29, 2026 05:13 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    CierCier CierCier
    Labels
    risk: high confidence: 20.9% needs-re-review
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 86.5% (HIGH) · Higher = larger blast radius
    86.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 20.9% · Lower = rushed or shallow review
    20.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 68.4% · Re-review required
    68.4%