Repository navigation
Description
Motivation
know-code verify is PR-only today because, after a checkout of the new main tip, origin/main is HEAD (aheadCount === 0). The range candidate is skipped (on base tip) and a range trailer cannot match. That is an implementation gap, not a GitHub limitation.
GitHub already gives the previous tip as github.event.before (all-zeros only for a new branch). Local tests of squash / rebase / merge landings already show verify can pass when the merge-base is that parent, not HEAD.
PR checks are not enough:
- Direct push to a protected branch (admin bypass, missing “require a pull request”, ruleset gaps) never runs
pull_requestverify. - Local pre-push is same-UID and skippable (
git pushwith hooks disabled,core.hooksPath). - Several GitHub landings can arrive in one
git push(stacked squashes, a merge commit plus its PR commits, rebase-and-merge replay). A single combinedbefore..HEADpatch is not equal to any per-range trailer, so “hash the whole push” is the wrong check.
This branch (test/verify-merge-from-main) already adds GitHub-shaped PR verify tests and merge-method docs. The walker is the missing CI half: prove each landed run still carries a grounded Know-Code-Verified trailer after it hits the base branch.
Design
know-code verify --from <oid>(push job passesgithub.event.before).- Walk
from..HEADoldest-first (rev-list --reverse --topo-order). - Split into runs that share the same
Know-Code-Verifiedhash. - Merge commits with no trailer attach to the current run (incoming PR side).
- Linear (single-parent) commits with no trailer fail closed.
- Each run: hash parent-of-first tree → run-tip tree via a historical tree-pair (not live
write-tree). Trailer must match that hash. - Single-commit runs also accept the index hash (empty-tree → that commit’s tree) so hotfixes still verify.
--fromnot an ancestor of HEAD → fail closed (force-push / missing object).from == HEAD→ nothing to walk, exit 0.- All-zero
before→ skip (new branch); CLI and workflow both treat this as success with a log line. - PR path unchanged: no
--from; still checkouthead.sha; still HEAD trailer thenmerge-base..HEADscan.
Push + PR both running on a GitHub merge is intentional defense in depth.
Receipt-mode ranges (trailer only on the tip) still pass PR verify. The push walker is stricter: every non-merge in before..HEAD needs a trailer. GitHub squash (one landing commit, often a hoisted trailer) and rewrite ranges pass. A merge-commit landing of a tip-only receipt PR fails on push unless those commits were rewritten — document that.
Acceptance criteria
-
know-code verify --from <oid>walksfrom..HEADand verifies each trailer run against a historical tree-pair hash (parent-of-first tree → run-tip tree), notwrite-tree. - Merge commits without a trailer attach to the current run; a merge with no current run fails closed.
- A linear commit without a trailer fails closed.
- A single-commit run accepts either the range tree-pair or the empty-tree (index) hash.
- Two or more stacked ranges/squashes in one push each verify independently (combined
before..HEADpatch must not be required to match any one trailer). -
--fromthat is not an ancestor of HEAD (force-push / unknown object) fails closed with a clear error. -
from == HEADexits 0 (empty walk). - All-zero
--from/github.event.beforeis skipped (exit 0), not a hard fail. - Dirty index does not change
--fromresults (historical trees only). - PR verify path is unchanged (no
--from; stillhead.sha; Update branch /pull/N/mergerange scan still pass). -
.github/workflows/know-code.ymltriggers onpushtomainand runsknow-code verify --fromwithgithub.event.before; PR job still useshead.sha. -
know-code init --workflowtemplate, compositeaction/, and action README match (newfrominput; not PR-only). - Docs no longer claim verify cannot run on push / that
on base tipis the end of the story; they describe--from+ the walker, and the receipt-vs-rewrite push caveat. - Tests cover the AC above (local git only — no live GitHub).
commands-coreno longer asserts the consumer workflow is PR-only.
Out of scope
- Restamping PR ci: bump Actions off Node 20 runtime (#6) #7 (old hash algorithm) — wait until this lands on main.
- Changing quiz/hash formulas for local
pass/know-code commit. - Phase 2 human-signature-in-CI (threat model). This only closes the “verify never sees the landing commit” hole.
Activity
chtnnh commentedon Aug 14, 2026
Implementation is on
test/verify-merge-from-main(CLI--fromwalker, push workflow, actionfrominput, docs). Link the PR withFixes #10.