Skip to content

refactor(validation): remove unreachable missing expected hash handling - #236

Merged
jackchuma merged 1 commit into
mainfrom
refactor/drop-unreachable-expected-hash-handling
Nov 7, 2026
Merged

jackchuma merged 1 commit into
mainfrom
refactor/drop-unreachable-expected-hash-handling

Conversation

@jackchuma

@jackchuma jackchuma commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

What changed? Why?

expected.domainAndMessageHashes was typed optional, but it can never be absent: TaskConfigSchema requires expectedDomainAndMessageHashes (src/lib/config-schemas.ts:79), both hashes must match /^0x[a-fA-F0-9]{64}$/, and getExpectedData copies it from the parsed config. This makes it required and deletes the branches that handled its absence.

 ValidationData.expected.domainAndMessageHashes   optional -> required
 SigningDataComparison.actual                     optional -> required
 ValidationResults
-  canSign check + "Signing Not Available" warning
-  proceed button gated on canSign
 page.tsx HardwareSigning props
-  ?. and || '' fallbacks
 buildSigningComparisons
-  if (!expectedHashes || !actualHashes) return [];
+  if (!actualHashes) return [];
 hasBlockingErrors (signing)
-  !signing.actual ||
 evaluateValidationEntry 'signing'
-  'missing' status and NOT_FOUND_TEXT fallback

buildSigningComparisons is the only producer of SigningDataComparison: it returns [] when actual hashes are missing and otherwise always sets actual, so the !actual checks downstream were dead. actual.domainAndMessageHashes stays optional because it really is absent when task-origin validation fails and simulation is skipped; hasBlockingErrors still blocks in that case through the task-origin check.

Notes to reviewers

  • Start at src/lib/validation-results-utils.ts. src/lib/validation-service.ts changes only a return type annotation.
  • Interfaces changed (TypeScript types only, no runtime or JSON change):
    • ValidationData['expected']['domainAndMessageHashes'] now required. Its only producer is validateUpgrade, which always sets it from the schema-validated config; /api/validate returns that value unchanged.
    • SigningDataComparison.actual now required. Only buildSigningComparisons creates it and it always sets actual.
    • Removed: the "Signing Not Available" UI block and the signing 'missing' match status. Neither could render for any config that passes schema validation.
  • Reversibility: git revert undoes it.
  • Blast radius: this repository's validation UI only.

How has it been tested?

Added three tests in src/lib/__tests__/validation-results-utils.test.ts that pin the remaining signing outcomes (no test covered the signing path before): matching hashes give status match and do not block; differing hashes give mismatch and block; absent actual hashes give no signing items. Each was written against the old code first and confirmed it can fail (mutated value: expected 0x1901…, received 0x1902…; expected "mismatch", received "match"; expected [], received one signing item).

npx tsc --noEmit                      # pass
npx eslint <changed files>            # pass
npx prettier --check <changed files>  # pass
npm test -- validation-results-utils.test.ts validation-service.test.ts   # 56 passed

Why this cleanup

  • Production: +13 / −29 (net −16) across 6 files. Tests: +32 / −0 (three new tests on the signing path; no existing assertion changed).
  • Interfaces changed: ValidationData.expected.domainAndMessageHashes and SigningDataComparison.actual became required; the "Signing Not Available" block and the signing 'missing' status were removed. Nothing could reach them: the schema requires the hashes and buildSigningComparisons always sets actual.
  • A reader no longer has to reconcile optional expected hashes with a config that requires them, or reason about a signing comparison whose actual data could be missing.
  • Keep gate judge: the deleted guards and UI states are unreachable; remaining error handling, EIP-712 encoding, and logging are unchanged, and no commit history shows future-work intent.

J-Engine-Session: je:315b6759-775b-47a5-918a-b9e2804992fb
@cb-heimdall

cb-heimdall commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Heimdall Review Status

Requirement Status More Info
Reviews ✅ 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
1 if authored by an app that is not allowlisted and lacks verified human attribution 0
Sum 1

@jackchuma
jackchuma marked this pull request as ready for review November 7, 2026 00:09
@jackchuma
jackchuma requested a review from 0xth4nh November 7, 2026 00:09

@0xth4nh 0xth4nh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to Thanh's Toshi

@jackchuma
jackchuma merged commit 7f5af72 into main Nov 7, 2026
6 checks passed
@jackchuma
jackchuma deleted the refactor/drop-unreachable-expected-hash-handling branch November 7, 2026 17:56
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.

3 participants