test(issuer): source-scan purity guards for receiptCandidate + policyReview#346
Open
ctol3r wants to merge 1 commit into
Open
test(issuer): source-scan purity guards for receiptCandidate + policyReview#346ctol3r wants to merge 1 commit into
ctol3r wants to merge 1 commit into
Conversation
…licyReview
The promotion-governance audit (2026-05-12) flagged that the two most
doctrine-critical pure transforms in the issuer/PSV chain —
receiptCandidate.ts and policyReview.ts — only had behavioral coverage.
A silent fetch / audit-row write could slip in without breaking any
existing assertion.
Extends the existing source-scan pattern (issuer-backend-persistence-
decision.test.ts:235, issuer-persistence-adapter.test.ts:326) to both
helpers: assert the source text contains none of fetch( / axios /
XMLHttpRequest / navigator.sendBeacon / prisma. / recordAudit /
recordAuditEvent / dynamic import('@/' / require(, and that the modules
do not statically import any backend (apps/api, @vitalcv/psv,
prisma_client, psvReceipts.repo).
No production code changes. 67 tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
apps/web/lib/issuer-verification/receiptCandidate.tsandpolicyReview.ts.fetch()or audit-row write could be added without breaking any existing assertion.Why this matters
receiptCandidate.tsandpolicyReview.tsare the modules that materialize the literaldecisionGrade: false/proofTier: 'receipt_candidate'/proofTier: 'psv_receipt_candidate'invariants of the issuer/PSV chain. Their CLAUDE.md contract explicitly states they are pure transforms — no fetches, no DB writes, no audit-event writes. Until now that was a comment, not a checked invariant.What changed
Each helper now has two new tests that
readFileSyncthe source and assert:fetch(,axios,XMLHttpRequest,navigator.sendBeacon,prisma.,recordAudit,recordAuditEvent, dynamicimport('@/,require(.apps/api,@vitalcv/psv, anyprisma_clientpath, orpsvReceipts.repo.Pattern copied from:
apps/web/__tests__/issuer-backend-persistence-decision.test.ts:235–271apps/web/__tests__/issuer-persistence-adapter.test.ts:325–363Test plan
pnpm --filter @vitalcv/web exec vitest run __tests__/issuer-policy-review.test.ts __tests__/issuer-verification.test.ts— 67 tests pass (4 new)codex execverifier output in transcript)🤖 Generated with Claude Code