v0.3.0
0.3.0
Security — comprehensive exploit hardening (E01–E28)
Major release closing agent TOCTOU and hook-bypass classes discovered after 0.2.1.
Kernel
- Unstaged tracked edits close the gate — index-only hashing no longer leaves the gate open while working-tree edits await
git add/-a gatedTreeOidmandatory — legacygate.jsonwithout it never opens for shipping; re-runknow-code passafter upgrade- Shipping requires index tree ===
gatedTreeOid— blocks partial commits and post-pass tree drift before push - Push requires
HEAD^{tree}===gatedTreeOid— amend/--no-editwith a stale trailer cannot ship a new tree - Cleanliness via
git diff --quiet— never porcelain throughgit().trim()(which corruptedM filestatus lines) know-code commit/amendreject pathspecs — except gated slices:know-code commit -m "…" -- <files>is allowed only while the index tree still equalsgatedTreeOid(see Sliced batches below)
Sliced batches & DevEx
- Sliced batch commits — quiz once, then land a staged batch as multiple
know-code commit -m "…" -- <files>slices; the gate stays open under commit drift while the index tree matchesgatedTreeOidand no unstaged tracked edits exist pass/askpreflight — refuse to run over unstaged tracked edits (quizzing work that isn't in the hash)know-code hash --explain— shows which staged files feed the hash and which unstaged/untracked files are excludedstatusstaleness detail — stale artifacts showartifact hash vs current hashplus the likely cause instead of a bare "stale"doctorlocal-cli check — warns when bareknow-codeon PATH is a stale global instead of the local monorepo build- Actionable gate messages — "Gate seal invalid" split into real causes (unstaged edits, staged tree differs, HEAD moved after seal)
kcbin alias — everyknow-codecommand is also available askc(kc status,kc commit -m "…"); no popular CLI ships akcbinary, and user shell aliases (e.g.alias kc=kubectl) shadow it harmlessly
Hook-safe partial commits (three git-interaction bugs)
GIT_INDEX_FILEstripped from kernel git subprocesses — duringgit commit -- <paths>git exports a temp slice-only index to hooks; the pre-commit check now always hashes the real index (also kills an env-spoofing vector)write-treelock fallback — git holds.git/index.lockmid-commit;materializedTreeOidretries against a temp copy of the index instead of silently returning the empty treeCOMMIT_EDITMSGpre-written byknow-code commit— git only writes it after the pre-commit hook, so the grounded pending-trailer check could never pass on the first commit afterpass- Pre-push accepts the seal-hash trailer — after
range seal --rewrite, HEAD trailers carry the seal hash;check --pushnow accepts it at exactlysealedHeadOidwith a grounded seal — and only in push mode: the seal never authorizes a new pending commit through pre-commit - Fresh
passconsumes superseded range seals — a seal/binding from a previous batch permanently blocked any later non-range commit from shipping (with attest on, nothing else ever cleared it); a successful human pass now removes seal artifacts pinned to a non-HEAD commit or to a tip already reachable fromorigin/<baseBranch>(push happened, seal consumed) — only a just-sealed unpushed tip at HEAD stays rewrite-open
CI & release
know-codeverify workflow is PR-only — on a push to the base branch there is no merge-base ahead of HEAD, so grounded verification is impossible by construction;init --workflowgenerates PR-only triggers- Docs deploy on release tags only — the site always matches a published CLI version
Agent hooks (check-shell.sh + gate-cmd.ts)
Deny in agent context (humans stage/commit outside the agent; agents use know-code commit / amend):
| Denied | Reason |
|---|---|
git commit --amend |
Stale trailer / tree rewrite |
git commit -a/--all/-u/--update |
Auto-stage TOCTOU |
git commit with pathspecs / -C / --reuse-message / --fixup / --squash |
Stale trailer or silent stage |
git add |
Stage unreviewed work |
git add && git commit |
Compound TOCTOU |
git push --no-verify / hooksPath on push |
Skip pre-push |
git merge / cherry-pick / revert / rebase |
Implicit commits |
git stash apply/pop/branch |
Reintroduce unreviewed trees |
git reset --hard |
Rewrite working tree |
Artifacts & config
enforcePipelinedefaults totrue— teaching + quiz pipeline required before pass- Unsigned
sealed-head-binding.jsonignored whenrequireAttest: false(cannot bind HEAD alone) doctor --strict— fails when git hooks outdated/missing or agent hooks absent; warns onrequireAttest: falseand legacy gatesshiprunsdoctor --strictfirst
Tests
- Table-driven exploit matrix (
exploit-matrix.test.ts) covering E01–E28 helpers + kernel cases - Sliced-commit e2e through real hooks — pathspec commits with git's temp index and held
index.lockagainst an installed pre-commit hook - Adversarial suite — forged trailers, agent-minted tokens, stale seals, post-seal drift
Breaking changes
- Re-run
know-code passonce ifgate.jsonlacksgatedTreeOid - Agents cannot use raw
git add/git merge/ etc. — use know-code workflow enforcePipeline: trueby default- Prefer
know-code doctor --strictin CI / before ship - Verify workflow triggers on
pull_requestonly — removepush: branchesfrom existing.github/workflows/know-code.yml(grounded verification has no merge-base on pushes to the base branch)