Verify passes in a checkout that holds other worktrees
Why. The Maintainer's sessions put git worktrees under .claude/worktrees/ in the main checkout, each a whole copy of the repo with a .git file. tools/check_context.py and tools/check_repo.py walked the whole tree, so make verify in that checkout read every nested copy's AGENTS.md, CLAUDE.md and tests as this repo's own. Verify passed only in a worktree or a fresh clone.
What.
tools/walk.pylists this working tree's files and top-level folders, and copies the tree. It skips any directory below the root that holds a.gitentry, file or directory. At the root it skips the tree's own.gitand thecorpus/thatmake_corpus.pywrites;.gitignorenow anchors that to/corpus/.__pycache__is skipped at any depth. A skipped name drops a directory, never a file of that name. A link is listed and never followed. A link to nothing is reported bycheck_repoin a sentence. It needs no git, so it also works in an export that has no.git.check_context,check_repoandcheck_puritywalk through it.check_puritywalkskernel/from the repo root, sokernel/corpus/is checked like any other code.clone()intests/test_tools.pyand the copy intools/mutants.pycopy through it, links as links, so all of them skip the same things. Only the tree-copy code inmutants.pychanged; the list of mutants did not.tools/AGENTS.mdgains the rule: the tree is walked or copied only bywalk.py.
Safe for CI. Skipping a directory that holds .git cannot hide committed content from the required check. Git refuses to check out a path named .git, so no commit can plant one, and in CI every such directory is one a person made locally.
Tests, written first.
test_another_working_tree_inside_this_one_is_not_readplants nested worktrees full of faults in a clone, with.gitfiles and a.gitdirectory, and runs every check that reads the tree. Before the change it failed for purity, repo and context.test_only_the_corpus_at_the_root_is_skipped_and_only_a_directoryplantskernel/corpus/x.pywithimport time,sim/corpus/test_hidden.py, a credential-shaped token undersim/corpus/, and acorpusfile, and asserts each is caught.test_a_copy_of_the_repo_leaves_out_another_working_treeandtest_a_link_is_not_followed_and_a_link_to_nothing_is_reportedhold the walk and the copy to the same rules.test_only_the_walk_walks_the_treereads the syntax of every file undertools/,tests/andsim/, and fails if anything butwalk.pywalks or copies a tree.test_a_walk_written_another_way_is_still_a_walkfeeds itPath.walk(),os.fwalk,os.walk (,from os import walk, an aliasedcopytree,glob(..., recursive=True)andglob("x/**/*.py").
Verified. make verify and python3 -m tools.mutants pass (26 of 26 killed, after rebasing onto main). make verify also passes in a clone that holds a real git worktree under .claude/worktrees/.
Not here. A committed link in kernel/ that points at a directory outside it, such as kernel/ext -> ../docs/x, hides that code from check_purity. That was already true before this change, and it is its own story: "A link in kernel/ cannot hide code from the purity check".
Order. "Session hooks that check: the fast checks after an edit, verify before a stop, the Maintainer's identity" should merge after this. Without it, a session in the main checkout is sent back at every stop.
Closes #64
š¤ Generated with Claude Code