Skip to content

feat: add verifyReceiptChain for audit chain validation [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] - #9

Open
waterWang wants to merge 2 commits into
FeeeeelixWong:mainfrom
waterWang:pr/2-verify-receipt-chain
Open

feat: add verifyReceiptChain for audit chain validation [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]#9
waterWang wants to merge 2 commits into
FeeeeelixWong:mainfrom
waterWang:pr/2-verify-receipt-chain

Conversation

@waterWang

Copy link
Copy Markdown

Closes #2

Summary

Add a deterministic verifier for exported IntentProof receipt chains. The verifier detects whether receipt content or hash links were modified after creation.

Implementation (src/domain/receipt.ts)

Export verifyReceiptChain(receipts) returning { valid, errors }:

  • First receipt must have previousHash: null
  • Every receipt hash is recomputed from its fields and compared against the stored hash
  • Every later receipt must link to the preceding receipt via previousHash
  • Empty-chain returns { valid: true, errors: [] }

Test coverage (src/domain/receipt.test.ts)

  • Valid chain of 3 receipts passes verification
  • First receipt with non-null previousHash fails verification
  • Broken hash linkage fails verification
  • Tampered content fails verification
  • Empty chain returns valid
  • Single-receipt chain returns valid

Verification

  • npm test — 24 tests passed (3 files)
  • npm run lint — 0 warnings, 0 errors
  • npm run build — built successfully
  • No wallet, network, or dependency changes introduced

wangye added 2 commits July 26, 2026 14:11
Cover NaN, zero, negative amounts; per-action cap boundaries;
daily cap boundaries; intent note length; and whitespace handling.

Closes FeeeeelixWong#3
@FeeeeelixWong

Copy link
Copy Markdown
Owner

Review findings:

  • createReceipt includes transactionSignature in the hashed payload when it is present, while verifyReceiptChain explicitly removes transactionSignature before recomputing the hash.
  • As a result, a valid submitted receipt containing a transaction signature is reported as invalid. This was reproduced with a focused test: the verifier returned valid: false for an untouched receipt created by createReceipt with status: submitted and a transaction signature.
  • A transaction signature added to a receipt that was originally created without one is ignored by verification, so that modification can remain undetected.
  • The acceptance criteria require coverage for changes to action, decision, timestamp, status, and transaction signature. Those specific tamper cases are not covered by this PR.
  • The PR also includes unrelated policy-boundary test changes and has the same head commit as PRs test: add policy boundary condition tests for evaluateAction [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] #7 and test: add policy boundary condition tests for evaluateAction [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] #8 (b506729).
  • GitHub reports no CI checks for this head branch.

The current implementation does not satisfy the valid-chain, transaction-signature integrity, test-coverage, or focused-change acceptance criteria.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent task: Verify exported receipt chains

2 participants