Skip to content

fix(cli): tree-canonical range hash for CI verify - #9

Open
chtnnh wants to merge 1 commit into
mainfrom
fix/ci-verify-tree-canonical-hash
Open

fix(cli): tree-canonical range hash for CI verify#9
chtnnh wants to merge 1 commit into
mainfrom
fix/ci-verify-tree-canonical-hash

Conversation

@chtnnh

@chtnnh chtnnh commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Make range hashing tree-canonical (fromOid^{tree}write-tree) so pass-time trailers match CI after know-code commit without trusting gitignored seals.
  • Pin know-code CI/init workflow to the PR tip (head.sha), write requireTrailer: true, and add npm run smoke:verify (CI-shaped e2e).
  • Document the verify contract in website/docs/verify.md; tighten ci.md / how-it-works.md.

Closes #8

Test plan

  • npm test
  • npm run smoke
  • npm run smoke:verify
  • Confirm GitHub know-code check is green on this PR (tip trailer = merge-base..HEAD)

Make pass-time trailers match merge-base..HEAD after commit, pin PR tip checkout, and document the verify contract with a CI-shaped smoke.

Know-Code-Verified: 75e9159d5acf07be52dcd1e647fd611694690b3bc833db8c67fe110ac778e58b
@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes the range diff hash formula and gate drift semantics, which can break PRs or local gates that relied on the old patch+staged hash; CI workflow checkout behavior also changes for all PR verify runs.

Overview
Range hashing is now tree-canonical (fromOid^{tree}write-tree), so the pass-time Know-Code-Verified trailer still matches know-code verify after know-code commit without gitignored seals or commit-drift candidates. Local gate tests expect no commit drift when the gated tree is unchanged across staged → committed and pathspec slice commits.

CI and onboarding check out the PR tip (github.event.pull_request.head.sha), ensure requireTrailer: true in the monorepo workflow, and add npm run smoke:verify (scripts/smoke-verify-ci.sh) — full quiz flow, strip local artifacts, assert verify passes. init --workflow and the composite action description document the PR-tip checkout requirement.

Docs: new Verification design page (verify.md) plus updates to ci.md and how-it-works.md for grounded CI checks and tree-stable range hashes.

Reviewed by Cursor Bugbot for commit 9e1f785. Bugbot is set up for automated code reviews on this repo. Configure here.

@chtnnh chtnnh self-assigned this Aug 13, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9e1f785. Configure here.

Comment thread packages/cli/src/hash.ts
EMPTY_TREE;
const indexTree =
git(["write-tree"], repoRoot, { allowFail: true }) || EMPTY_TREE;
const diff = git(["diff", fromTree, indexTree], repoRoot, {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Range hash skips lock-safe write-tree

Medium Severity

computeRangeDiffContext now depends on write-tree for the tree-canonical tip, but calls raw git write-tree with an EMPTY_TREE fallback instead of indexTreeOid. Under pre-commit index.lock, that failure yields a wrong range hash (empty-tree material) rather than the real index tree the rest of the gate path already resolves lock-safely.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9e1f785. Configure here.

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.

CI verify fails for receipt-mode range trailers (passHash ≠ merge-base..HEAD)

1 participant