Skip to content

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

Merged
chtnnh merged 2 commits into
mainfrom
fix/ci-verify-tree-canonical-hash
Aug 13, 2026
Merged

fix(cli): tree-canonical range hash for CI verify#9
chtnnh merged 2 commits 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 core hash and verify semantics used by gates and CI; incorrect hashing would break enforcement, but coverage includes gate-drift, verify, git-env lock tests, and CI-shaped smoke.

Overview
Range and index hashing now derive from lock-safe indexTreeOid and a tree-canonical range formula (fromOid^{tree} → current index tree) instead of cumulative commit diffs plus staged patches. The same gated tree keeps the same hash after know-code commit, so CI can validate Know-Code-Verified from public git alone—local commit-drift is no longer the happy path for multi-commit batches.

CI and tooling: GitHub workflows and know-code init --workflow check out github.event.pull_request.head.sha (merge commits lack trailers). The monorepo know-code job writes requireTrailer: true, adds npm run smoke:verify (scripts/smoke-verify-ci.sh strips gitignored seals then runs verify), and documents the contract in website/docs/verify.md with updates to CI/how-it-works/workflows. The CLI also exposes a kc bin alias.

Reviewed by Cursor Bugbot for commit a5102df. 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
Use indexTreeOid so pre-commit index.lock cannot fall back to the empty tree, and keep MDX docs free of {ident} interpolations.

Know-Code-Verified: f975b2b8543cc2ca664347ec3c1ebb87d6a8fd64f267adf1ab19514f80ab1c83
@chtnnh
chtnnh merged commit d6b6414 into main Aug 13, 2026
3 checks passed
@chtnnh
chtnnh deleted the fix/ci-verify-tree-canonical-hash branch August 14, 2026 10:33
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