Repository navigation
wip init stops reading a failed git status as clean, refuses a template path whose ancestor is a symlink or not a directory, refuses one staged at a mode it never wrote, and names a skip-worktree path HEAD carries and the disk does not - #101
brettheap merged 11 commits into
Conversation
…s empty output as a clean checkout (#49) `wip init`'s step 6a is the gate that refuses an ADOPTED checkout carrying anything this command did not write, and it is asked BEFORE step 7 writes a byte for exactly that reason. It asked the question as unrelated="$(git -C "$checkout" "${status_args[@]}" 2>/dev/null | sed … || :)" The `2>/dev/null` threw away git's own diagnostic and the `|| :` turned any non-zero exit of the pipeline — under this file's `set -o pipefail`, `git status`'s own: a corrupt index, an unreadable `.git`, a submodule error — into a plain empty string. An empty change list is precisely what "nothing unrelated, proceed" looks like, so a checkout this command could not even PUT the question to was read as clean and step 7 seeded into it, past the one gate that exists to refuse first. The run is `wip_quietly`'s now, so the failure carries git's own words under the refusal the way the clone and the seed commit already do, and the change list is read from the file that wrapper writes rather than from a capture a failure can empty: `[ -s "$WIP_LAST_OUT" ]` decides, never a variable. `wip_quietly` keeps its stdout in `$WORKDIR/cmd-out` instead of `/dev/null` for that — nothing ever prints it, so stdout is still dropped from the report — which is what lets a command whose OUTPUT is the answer run through the one wrapper rather than carrying a second copy of its stderr capture. The `--untracked-files=all` and `:(exclude)<template path>` shape is unchanged. The regression test `test_a_git_status_this_command_cannot_run_is_refused_not_read_as_clean` corrupts `.git/index` in an adopted checkout that is missing one template file — `rev-parse` still answers, so the run reaches step 6a — and asserts exit 2, git's own `fatal:` line about the index under `What it said:`, and that the missing template file was still not written. (The sentence itself is not pinned: which one a corrupt index draws depends on how it is corrupt and on the git version.) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…r anything else that is not a directory, before `mkdir -p` and `cp` write through it (#62) `path_kind` asks what is at `$rel` itself; nothing asked what is at `handoffs`, `lanes`, `lanes/log` or `workspaces`. An adopted checkout can carry a TRACKED symlink at one of those — a person whose `handoffs` is a link into another tree of their own, committed — and step 6a reads that worktree as clean, because it IS what HEAD says. Every test step 7 then makes answers as though nothing were at `handoffs/README.md` at all: `[ -e ]` and `[ -L ]` are false where the link's target holds no such file, and git has no notion of a path inside a tracked symlink, so `:$rel`, `HEAD:$rel` and `ls-files -u` are false too. The MISSING branch was reached, its `mkdir -p` created nothing (the link resolves to a directory that is already there) and its `cp` wrote this run's template bytes THROUGH the link — outside the checkout, where the link led. Only the `git add` two steps later noticed, with `fatal: … is beyond a symbolic link`, after the bytes had landed somewhere this command was never pointed at. So every component of `$rel` between `$checkout` and the leaf is walked first, left to right, and a symlink at any of them is a refusal naming the component and the path it points to, with nothing written. The walk answers an ancestor that is not a directory at all in the same breath, because the same MISSING branch meets it one line earlier: a regular file committed at `handoffs` fails that `mkdir -p`, and a failing `mkdir` under this file's `set -e` exits 1 — the code this toolset spends on "findings were printed" — from a run that meant to refuse with 2 and never said why. The regression test `test_an_ancestor_of_a_template_path_that_is_not_a_directory_is_refused` commits each shape at `handoffs` in an adopted checkout and asserts exit 2, the component and its target in the refusal, nothing staged, no commit, no push — and, for the link, that the directory it points at is still empty. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…e blob, and a template path staged at any mode but 100644 is refused (#63) Step 7's owed-candidate branch trusted the index the moment its blob matched the fetched template, and `cat-file -p` prints a blob's BYTES and never its mode. So a path a person had staged with `git add --chmod=+x`, byte-identical to the template and executable, read as "the index carries the template": step 8's `git add` then restaged that path from the WORKTREE at the worktree's own mode and committed it, replacing their `100755` with `100644` without a word. `git ls-files -s -- "$rel"`'s first field is asked for now, and it must be `100644` — the only mode any file in `templates/workspace-root` carries, and the only mode this command has ever written, having never chmod'ed anything. THE ARM IS A REFUSAL, not "leave it and count it as the person's", because that is the contract of the branch it sits in: every other "this is not an earlier run's own leftover" answer there is a `die` — a symlink, a FIFO, a staged addition with no worktree file, an unresolved conflict, bytes that are not the template's — and the one arm that succeeds means "this IS my own leftover, carry it into the seed commit". Leaving it would be worse than either: the path is neither seeded nor owed, so step 8 commits and pushes without it and step 9 writes the pointer file over a main that is missing a template file, which is the state no later run digs out of. A mode this command could not READ is refused the same way, because an unreadable answer is never a matching one. It is asked BEFORE the fetch, with the branch's other local questions: the answer does not depend on the template's bytes, and a machine with no network deserves the refusal that names the real reason. The regression test `test_a_template_path_staged_at_another_mode_is_refused_not_restaged` stages the template's own substituted bytes at `handoffs/README.md` with `--chmod=+x` (which moves the index and leaves the worktree file at 0644, so only the mode differs) and asserts exit 2, the mode and the path in the refusal, and that the person's staged `100755` is still there afterwards. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… named in the summary rather than silently passed (#69) `skip-worktree` — which is also what `git sparse-checkout` sets — tells git not to compare the worktree at that path at all: HEAD carries it, the stage-0 entry carries it, `git status` is clean, and the file is physically absent. That answered step 7's outer presence test exactly as a person's own deliberate `git rm` does, so the run `continue`d past it, counted it as neither `seeded` nor `owed`, printed "the workspace already carries every template file" and wrote the pointer file — while a template path this command seeds, and the lane tooling reads, was not on disk at all. THE ARM IS TO NAME IT, and to write nothing. The principle the branch is built on still stands — a template path HEAD already carries is the person's, and this command has never modified a committed file — so seeding over it is out, and a refusal would stop a run whose only problem is one line a person needs to read. What it stops being is INVISIBLE: `git ls-files -v -- "$rel"` is asked where the worktree file is absent, and a tag of `S` (or the lowercase `s` that means the same entry is also assume-unchanged) puts one line in the summary saying HEAD carries it, the index marks it skip-worktree, and it is not on disk, with the `git update-index --no-skip-worktree` that brings it back. `h` — assume- unchanged alone — is deliberately not claimed as this case: that bit is a person telling git to stop stat-ing a path they own and keep, not a checkout that never materialized one. (The issue's body says a LOWERCASE letter marks skip-worktree. `ls-files -v` prints `S`; lowercase is what it uses for assume-unchanged, whatever the letter, so both spellings of a skip-worktree entry are matched and `h` is not.) The regression test `test_a_skip_worktree_template_path_is_named_and_never_seeded` sets the bit on `lanes/LANES.md`, deletes the file, asserts that `git status` really is silent about it, and then asserts the line, exit 0, nothing written at the path, nothing staged, no commit and no push for it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 1 day and 20 hours by commenting @sourcery-ai review. Upgrade to get a review now.
Reviewer's GuideHardens File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🟡 Changes recommended
A moderate macOS portability issue and a critical mode-validation gap remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Hardens wip init against failed status checks, unsafe template ancestors, staged mode mismatches, and missing skip-worktree files.
Changes:
- Adds safety checks and diagnostics in
openRepoTools. - Adds regression coverage in
tests/test_wip_init_command.py. - Remaining findings: macOS-incompatible
sedargument ordering and incomplete worktree mode validation.
File summaries
| File | Summary |
|---|---|
tests/test_wip_init_command.py |
Adds regression tests for the four hardening cases. |
openRepoTools |
Implements validation and reporting changes; requires fixes for the noted findings. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…late path in share one fixture instead of a copy each (SonarCloud's new-code duplication gate on #101) `adopted_checkout_without` is the ten lines four of them had written out separately: the adopted checkout, the template's own substituted bytes read BEFORE the path is removed (they are what an earlier run's leftover looks like), the `git rm` + commit + push that takes it out of HEAD — step 7 asks `HEAD:$rel` first, so a path HEAD still carries never reaches that branch at all — and the HEAD every refusal is then checked against. Two of those copies predate this branch and the third arrived with #63's regression test, which is what took SonarCloud's `new_duplicated_lines_density` to 4.0% against a 3% gate: one ten-line block, three times. #49's test takes the same fixture for the one thing it needs from it — a template file that is genuinely missing — and ignores the bytes. A copy per test is also how two of them come to differ in a way nobody meant, which is the same argument this repository makes about two copies of one rule in the code itself. No test's behaviour changes: the commit message the fixture writes now names the path it removed rather than spelling `handoffs/README.md` in prose, and nothing asserts on it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…able template path is refused rather than staged into the seed as 100755 (Copilot round 1 on #101) #63's fix asks what the INDEX carries at an owed candidate, and step 8 stages from the WORKTREE — so the half that decides what actually lands in the seed commit was still unasked. An owed candidate whose file carries the execute bit is recorded as `100755` and pushed to the workspace repository's `main`, and it reaches that point two ways the stage-0 question never sees: an UNTRACKED template path whose bytes match the template and whose file somebody chmod'ed, and a path staged `100644` whose worktree file got the bit afterwards. Step 6a cannot catch either, because it excludes the template's own paths by name. This command copies the template's bytes from a 0644 file — `cp` from the pinned checkout, or a shell redirect, then `sed` into `$file.subst` and a `mv` — and has never chmod'ed anything it wrote. So an executable file at a template path is not an earlier run's leftover whatever its bytes say; it is somebody's own, and this branch's answer to that is the refusal the staged mode already gets. ASKED ONLY WHERE GIT WOULD RECORD IT. On a filesystem that reports every file executable, `git clone` sets `core.fileMode=false` and git stages `100644` regardless; refusing there would refuse every re-run on that mount over a bit that means nothing, so the config that decides it is read and only an explicit `false` stands the refusal down (unset is true). `test_an_executable_template_path_is_refused_not_seeded_at_100755` covers both shapes: without this commit each exits 0, seeds, commits and pushes; with it each is exit 2 naming the path, with the person's own 0755 and their staged 100644 untouched. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…re says which half was missing (SonarCloud python:S9073 on #101) `assert "fatal:" in stderr and "index" in stderr` is one assertion carrying two claims, and the two say different things: the first is that git's own sentence reached the person at all, the second that the sentence is about the index it could not read. Failed together they name neither, which is the whole of what S9073 is about — and this suite's own convention is a message per claim. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ad as a BOOLEAN, because git spells false four ways `git config --get core.fileMode` hands back whatever is written in the file, and git's own boolean is `false`, `no`, `off` or `0` — so a checkout carrying `fileMode = 0`, which is what some tools write, answered `0`, which is not the string `false`, and the refusal stood where git would in fact have staged `100644`. `--bool` is git's own normalisation of exactly that set, and it is older than every git this toolset runs under. Unset still answers 1 and nothing, which is still not `false`, so the refusal still stands there: an answer this command could not get is never permission to publish a mode. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
A critical issue and additional unresolved findings remain.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (3)
openRepoTools:2135
- This
elseis the false arm of the outer presence test at lines 1927–1930, so it runs only when neither the worktree, index, HEAD, nor a conflict entry exists. A skip-worktree path still has a HEAD entry and a stage-0 index entry, so it takes thethenarm,if ! HEADis false, and continues without evaluatingls-files -v; the new regression therefore cannot report the missing file. Move this probe into the outerthenpath when HEAD carries the path but the worktree is absent, while leaving the outerelseto reach normal missing-file seeding.
else
# ---- A PATH HEAD CARRIES THAT IS NOT ON DISK BECAUSE THE INDEX
# SAYS SO IS NAMED, NOT SEEDED AND NOT SILENTLY PASSED (#69).
#
# `skip-worktree` — which is also what `git sparse-checkout`
openRepoTools:2197
- The only recovery command printed for this finding is incomplete: the output ends with
git update-index --no-skip-worktree --and putsthat pathon a separate prose line, without naming the checkout or the actual template path. A user cannot copy it to restore the reported entry, especially whenwip initwas run outside the checkout. Print a complete command such asgit -C "$checkout" update-index --no-skip-worktree -- "$rel"(or clearly mark both values as placeholders).
say " (a sparse checkout leaves a tracked path there and off the disk; nothing"
say " was written or committed at it. \`git update-index --no-skip-worktree --\`"
say " that path, or \`git sparse-checkout\`, is what brings it back.)"
openRepoTools:2197
- The recovery command printed here only clears the index bit;
git update-index --no-skip-worktree -- <path>does not recreate a missing worktree file. After following this message, the path is still absent and step 6a will report it as a deletion, so the documented remedy cannot get the checkout back to a runnable state. Include a checkout/restore step (or an explicit sparse-checkout reapply) after clearing the bit.
say " was written or committed at it. \`git update-index --no-skip-worktree --\`"
say " that path, or \`git sparse-checkout\`, is what brings it back.)"
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
…— a submodule, or a clone somebody left there — is refused before the `cp` writes inside it (Copilot round 2 on #101) The ancestor walk added for #62 asks whether each component is a symlink and whether it is a directory, and a tracked SUBMODULE passes both: `-L` is false and `-d` is true, because a gitlink at `handoffs` is a whole repository on disk. Nothing else catches it either — a clean submodule reports nothing to step 6a, and a gitlink carries no `handoffs/README.md`, so `[ -e ]`, `[ -L ]`, `:$rel`, `HEAD:$rel` and `ls-files -u` are all false. The MISSING branch then wrote this run's template bytes INSIDE somebody's nested repository, and the `git add` two steps later answered fatal: Pathspec 'handoffs/README.md' is in submodule 'handoffs' with the bytes already there, in a repository this command has no business in and does not clean up. Measured on a real submodule, both before and after. THE INDEX IS WHAT MAKES IT A SUBMODULE, so that is what is asked: `ls-files -s` answers `160000` at that exact path whether or not the submodule is checked out, and a `deinit`ed one — an EMPTY directory with no `.git` in it at all — fails the same `git add` for the same reason. The `.git` test beside it catches the other shape, a nested repository nobody tracked, which an ignore rule can hide from step 6a as well. `$4` is `ls-files -s`'s path column and every component walked here comes from `$WIP_TEMPLATE_FILES`, nine fixed ASCII paths, so it is never a quoted or split field. `test_a_submodule_at_a_template_paths_ancestor_is_refused[checked-out| deinitialized]` builds a real submodule with `protocol.file.allow=always` (git has refused a local-path submodule without it since 2.38), asserts `git status` really is silent about it, and then asserts exit 2 naming the component, with nothing written inside the nested repository, nothing staged, no commit and no push. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved correctness and reporting issues remain in openRepoTools, including staged-entry detection, executable-mode detection, recovery guidance, and the clone-failure write guarantee.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (3)
Previously missed (1) — in code that hasn't changed since the last review.
openRepoTools:2232
- The recovery command printed here is incomplete:
git update-index --no-skip-worktree --has no path operand, so copying the command fails and the path is only mentioned outside the backticks. Include$relin the command and give the sparse-checkout alternative as an actionable pattern change.
openRepoTools:2087
[ -x ]tests whether the effective user can execute the file, not whether the mode bit Git records is executable. An adopted/shared checkout can have the owner execute bit set while the current user lacks execute access, so this condition passes even thoughgit addrecords mode100755and publishes a mode this command never wrote. Inspect the file's mode bit directly, using a portable approach for the supported platforms, rather than an access check.
if [ -x "$checkout/$rel" ] &&
[ "$(git -C "$checkout" config --bool --get core.fileMode 2>/dev/null || :)" != "false" ]
then
openRepoTools:1841
- This refusal is also used immediately after a fresh
gh repo clone(step 6 runs before this gate), so the clone has already written files into$checkoutwhengit statusfails. Saying that nothing was written is false in that path; limit the guarantee to step 7's template writes so the refusal reports the checkout state accurately.
it could not put that question to. NOTHING was written into that checkout on this run
and nothing was staged.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
…n entry whose blob git has lost is a refusal rather than an empty index (Copilot round 3 on #101) `git cat-file -e ":$rel"` answers false in TWO states, because it resolves the name through the index and then looks the OBJECT up: there is no stage-0 entry, or there is one whose blob the object store has lost. The staged-mode guard gated on it and the comparison below took its "no entry" arm on the same question, so the second state was spent as though it were the first — the mode was never checked, a worktree that reads back as the template was accepted as this command's own leftover, and step 8's `git add` replaced what the person had staged with this run's copy. Measured on a repository with the blob removed: the staged sha changes and the `add` reports nothing. `git ls-files -s` reads the index and never the object store, so presence is its answer now, at the exact path and at stage 0. Three states, three answers: a read that FAILS is a refusal and never an empty index (#49's own lesson, one question over); an entry whose blob cannot be read is a refusal of its own, because an entry this command cannot READ is not one it may stage over; and no entry at all is the arm the comparison already had. `test_a_staged_entry_whose_blob_is_gone_is_refused_not_read_as_no_entry` stages somebody's own edit, makes the worktree read back as the template, deletes the object behind the index entry, and asserts exit 2 with the person's staged sha still in `ls-files -s` afterwards. Without this commit the run exits 0 and replaces it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
The skip-worktree remediation command is malformed and omits the affected path.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
openRepoTools:2266
- The skip-worktree remediation renders an unusable command: it has a closing backtick without an opening one, and
--is not followed by the affected path. A user copyinggit update-index --no-skip-worktree --gets Git's empty-pathspec error; include$relin the command and balance the quoting.
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
…cestors-modes-sparse-and-status-failure
|
There was a problem hiding this comment.
🔵 Needs a closer look
Two moderate correctness issues and one documentation nit remain in openRepoTools.
Review details
Suppressed comments (3)
openRepoTools:2345
- The recovery command in this summary is printed without a path operand:
git update-index --no-skip-worktree --exits with a usage error. Include the affected$relin the command (and keep the sparse-checkout alternative as prose) so the only remediation shown for this case is runnable.
say " was written or committed at it. \`git update-index --no-skip-worktree --\`"
say " that path, or \`git sparse-checkout\`, is what brings it back.)"
openRepoTools:2215
- This new
ls-files -sguard is reached only after the outer presence test at line 2042. If a stage-0 entry's blob is missing and the worktree file is also absent,cat-file -e :$relin that outer test fails, so execution skips this block and reaches the MISSING branch, which recreates the file and letsgit addreplace the person's index entry instead of refusing. Make the outer presence check use index metadata (and handle a failed read) so every stage-0 entry reaches this validation.
if staged_entry="$(git -C "$checkout" ls-files -s -- "$rel" 2>/dev/null)"; then
staged_mode="$(printf '%s\n' "$staged_entry" |
awk -v p="$rel" '$3 == "0" && $4 == p { print $1; exit }')"
openRepoTools:2165
[ -x "$checkout/$rel" ]tests whether the current user can execute the file, not the owner-execute bit Git uses when deciding whether a regular file is mode100755. For example, a readable file owned by another account with mode0744makes this test false for the current user, whilegit addstill records100755, so step 8 can publish a mode this command did not write; group-executable files cause the opposite false refusal. Inspect the permission bits with a portable mode check instead (the existingmode_ishelper usesfindfor this repository's GNU/BSD portability).
if [ -x "$checkout/$rel" ] &&
[ "$(git -C "$checkout" config --bool --get core.fileMode 2>/dev/null || :)" != "false" ]
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
…e textual conflict in README.md, resolved as a union `main` moved from f9e63f4 to 957a26f — #102 (every `chmod` `--install` performs fails through `die`, and a second writer of either hook refuses whether or not our own entry is beside it) and #101 (`wip init` stops reading a failed `git status` as clean, refuses a template path whose ancestor is a symlink or not a directory, refuses one staged at a mode it never wrote, and names a skip-worktree path HEAD carries and the disk does not). Neither touches `lanes-edit.sh`, so the guard and Amendment 16 sections merge untouched. ONE TEXTUAL CONFLICT, IN README.md, AND IT IS A UNION. Both sides edited the same sentence in the settings-merge paragraph: this branch's Amendment 16 raised twelve files to THIRTEEN (`lane-rename` joins `INSTALLABLES`), and #102 appended the new paragraph on a second writer refusing whether or not our own entry sits beside it. Kept: "thirteen" (this branch's count — `openRepoTools` itself already says thirteen throughout, unconflicted, since that count comes from `INSTALLABLES` and not from this paragraph) followed by #102's whole "A SECOND WRITER REFUSES..." paragraph, in main's order. `openRepoTools`, `tests/test_install_skill_and_hook.py`, `tests/test_openrepotools_command.py` and `tests/test_wip_init_command.py` merged with no conflict. `bash tests/test_lane_helpers.sh` run to completion after this merge; see the finishing-writer report for the count. Lane: openrepotools-3 (openRepoTools-3) Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EaHzfTLW4u9ukpWuw8Dt6r
… beside the supervised restart `main` moved twice under this branch: every `chmod` `--install` performs now fails through `die` and a second writer of either hook refuses whether or not our own entry is beside it (#102), and `wip init` stops reading a failed `git status` as clean, refuses a template path whose ancestor is a symlink or not a directory, refuses one staged at a mode it never wrote, and names a skip-worktree path HEAD carries and the disk does not (#101). Both touch `openRepoTools`, `README.md` and three pytest files; this branch touches none of them. The merge is a union with no overlapping hunk, which is what `git merge` reports and what the file list proves: the shell suite's `ort_text` assertions read `openRepoTools` from the tree and are unchanged on either side. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01EaHzfTLW4u9ukpWuw8Dt6r
…ide Amendment 18's binding reads — no file in either half is touched by the other Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01EaHzfTLW4u9ukpWuw8Dt6r
Bring #97 onto a current base before the seam rework Brett Heap ruled on 2026-10-04 ("managed ledger owns enrolled lanes; #97 owns legacy — rework both"). Main moved 14 commits past 957a26f, to daed209: #81 lane-rename, #83 Amendment 18, #93 Amendment 19, #61 claim --force takeover, #146, #119, #101-#103, #129, #131, #133, #135, #136, #139 and #134. Four files conflicted, and in every one both intents survive: - lanes-edit.sh, the function sections: both sides appended after migrate_state_cells. Main's Amendment 19(c)/(d) sweep and archive stay directly under it, because its header says "the shape `migrate-state-cells` has one screen up"; #97's lifecycle and inventory section follows them. - lanes-edit.sh, the unknown-subcommand refusal: the union of both lists, 56 names, the same set as the dispatcher's 56 arms. - lanes-edit.sh, the exit-code table, and the manual's copy of it: #97's 7 row ("another act got there first", in three verbs) is kept, and exit 9 now has two meanings, one per verb. #61 spent 9 on `claim --force`'s abandoned takeover and #97 spent it on `lane-state`'s unreadable snapshot, and each PR took it as unused. Neither verb can return the other's 9, so the table names both and nothing is renumbered in a merge. The manual's 9 row said "(`claim` only)", which the merge would have made false; its 7 row now names #97's two fenced writers too, as the code table already did. The next commit moves #97's 9 to 10. - lane-handoff, the late-record restart line: #129's `$lane_profile_word` (lclaude) with #97's lifecycle line under it. - docs/README-lanes.md: Amendment 19's section, then #97's #91 section, so the amendment sections stay in number order. - tests/test_lane_helpers.sh: main's Amendment 19 and Amendment 18 sections run first, in main's order (A18's restores its fixtures), and #97's self-contained #91 section follows them, before the workstation-seam section, as it did on #97's branch. lane-start auto-merged around #134's rewrite. #97's section 4a still prints the reconciliation after Amendment 18's binding gate and before section 5 and the STARTED/RESUMED write in 5b. AGENTS.md, README.md, tests/test_repo_hygiene.py and skills/ are byte-identical to main, so the 316- and 486-line caps already match the merged counts. Locally, tests/run.sh -k 'lane_helpers_suite or repo_hygiene or lane_start_claude_current or guard_launch_mode or install_skill_and_hook': 274 passed, 600 deselected, in 1560 s. Lane: openRepoTools-3 Co-Authored-By: Claude Opus 5.5 <[email protected]>



Four hardening gaps in
openRepoTools wip init's step 6a and step 7, each with a regression test that fails before the change and passes after it. Nothing in step 8's push is touched (#64 is a design question the lane owner has put to Brett Heap), and step 6a keeps its--untracked-files=all/:(exclude)<template path>shape.#49 — a
git statusthis command could not run was read as a clean checkoutStep 6a is the gate that refuses an ADOPTED checkout carrying anything this command did not write, asked BEFORE step 7 writes a byte for exactly that reason. It asked the question as
git … status … 2>/dev/null | sed … || :: the redirect threw away git's own diagnostic, and the|| :turned any non-zero exit of the pipeline — under this file'sset -o pipefail,git status's own: a corrupt index, an unreadable.git, a submodule error — into a plain empty string, which is exactly what a clean checkout produces. So a checkout this command could not even PUT the question to passed the gate and step 7 seeded into it.The run goes through
wip_quietlynow, so the refusal carries git's own words underWhat it said:the way the clone and the seed commit already do, and the change list is read from the file that wrapper writes —[ -s "$WIP_LAST_OUT" ]decides, never a capture a failure can empty.wip_quietlykeeps its stdout in$WORKDIR/cmd-outinstead of/dev/nullfor that; nothing ever prints it, so stdout is still dropped from the report, and a command whose OUTPUT is the answer runs through the one wrapper rather than carrying a second copy of its stderr capture.#62 — the leaf was asked about and its ancestors were not
path_kindasks what is at$relitself; nothing asked what is athandoffs,lanes,lanes/logorworkspaces. An adopted checkout can carry a TRACKED symlink at one of those, and step 6a reads that worktree as clean because it IS what HEAD says. Every test step 7 makes then answers as though nothing were athandoffs/README.mdat all —[ -e ]and[ -L ]are false where the link's target holds no such file, and git has no notion of a path inside a tracked symlink, so:$rel,HEAD:$relandls-files -uare false too. The MISSING branch was reached, itsmkdir -pcreated nothing (the link resolves to a directory that is already there) and itscpwrote this run's template bytes THROUGH the link, outside the checkout. Only thegit addtwo steps later noticed —fatal: … is beyond a symbolic link— after the bytes had landed.Every component between
$checkoutand the leaf is now walked left to right before any branch acts, and a symlink at one of them is a refusal naming the component and the path it points to, with nothing written. The same walk answers an ancestor that is not a directory at all, because the same MISSING branch meets it one line earlier: a regular file committed athandoffsfails thatmkdir -p, and a failingmkdirunder this file'sset -eexits 1 — the code this toolset spends on "findings were printed" — from a run that meant to refuse with 2 and never said why. One walk, one comment, both refusals tested. (unusable_dir_kindis not this question and so is not reused: it climbs UP to the nearest ancestor that exists and asks whether a file can be created there, so a symlink to a directory that is really there answers it-d/-w/-x— usable — and it never looks at the components below. This walk goes DOWN the exact relative path and asks what each component IS.)#63 — the index check compared the blob and never the staged mode
cat-file -pprints a blob's BYTES and never its mode, so a path a person had staged withgit add --chmod=+x, byte-identical to the template and executable, read as "the index carries the template". Step 8'sgit addthen restaged it from the WORKTREE at the worktree's own mode and committed: their100755replaced by100644without a word.git ls-files -s -- "$rel"'s first field is asked for now and must be100644— the only mode any file intemplates/workspace-rootcarries and the only mode this command has ever written.The arm chosen is REFUSE, naming the mode and the path, because that is the contract of the branch it sits in: every other "this is not an earlier run's own leftover" answer there is a
die— a symlink, a FIFO, a staged addition with no worktree file, an unresolved conflict, bytes that are not the template's — and the one arm that succeeds means "this IS my own leftover, carry it into the seed commit". Leaving it and counting it as the person's would be worse than either: the path would be neitherseedednorowed, so step 8 would commit and push without it and step 9 would write the pointer file over amainmissing a template file — the state step 8's own comment says no later run digs out of. A mode this command could not READ is refused the same way, since an unreadable answer is never a matching one. The check is asked BEFORE the fetch, with the branch's other local questions, so a machine with no network gets the refusal that names the real reason.#69 — a skip-worktree entry could not be told from a real tracked file
skip-worktree— which is also whatgit sparse-checkoutsets — tells git not to compare the worktree at that path at all: HEAD carries it, the stage-0 entry carries it,git statusis clean, and the file is physically absent. That answered step 7's outer presence test exactly as a person's own deliberategit rmdoes, so the runcontinued past it, counted it as neitherseedednorowed, printed "the workspace already carries every template file" and wrote the pointer file — while a template path this command seeds, and the lane tooling reads, was not on disk.The arm chosen is to NAME it and write nothing. The principle the branch is built on still stands — a template path HEAD already carries is the person's, and this command has never modified a committed file — so seeding over it is out; and a refusal would stop a run whose only problem is one line a person needs to read. What it stops being is INVISIBLE:
git ls-files -v -- "$rel"is asked where the worktree file is absent, and one line in the summary says HEAD carries it, the index marks it skip-worktree, and it is not on disk, with thegit update-index --no-skip-worktreethat brings it back. Exit stays 0 and the run finishes.Two notes on the tag letter, since the issue body has it the other way round:
ls-files -vprintsSfor skip-worktree, and lowercase is what it uses for assume-unchanged (sosis skip-worktree and assume-unchanged, and both are matched).h— assume-unchanged alone — is deliberately not claimed as this case: that bit is a person telling git to stop stat-ing a path they own and keep on disk, not a checkout that never materialized one, and calling it "skip-worktree" in the summary would be false.Round 2 — Copilot
handoffspasses both questions the new walk asked (-Lfalse,-dtrue of a whole repository on disk); a clean submodule reports nothing to step 6a; and a gitlink carries nohandoffs/README.md, so every presence test in step 7 is false. The MISSING branch wrote this run's template bytes INSIDE that nested repository and thegit addtwo steps later answeredfatal: Pathspec 'handoffs/README.md' is in submodule 'handoffs'— with the bytes already there. The walk now asks the INDEX at that exact component (ls-files -s's path column, refused on160000), because the index is what makes it a submodule and adeinited one is an empty directory with no.gitin it at all — and it asks.gitbeside that, for a nested repository nobody tracked. Regression:test_a_submodule_at_a_template_paths_ancestor_is_refused[checked-out|deinitialized].Round 3 — Copilot
cat-file -e ":$rel"conflates "no index entry" with "entry whose blob is lost" (thread) — taken, and measured first: with the staged blob removed,cat-file -eanswers false whilels-files -sstill carries the entry, andgit addthen replaces the person's staged sha silently. Presence isgit ls-files -s's answer now (the index, never the object store, at the exact path and stage 0); a read that FAILS is a refusal rather than an empty index, an entry whose blob cannot be read gets its own refusal, and the comparison's "no entry" arm is spelled[ -z "$staged_mode" ]so a failed object lookup can no longer reach it. Regression:test_a_staged_entry_whose_blob_is_gone_is_refused_not_read_as_no_entry.Filed rather than fixed here
wip initstep 7 writes with an unguardedmkdir -p/cp, so an unwritable template directory is exit 1 with no refusal #105 — step 7's MISSING branch writes with an unguardedmkdir -p/cp, so a template directory this user cannot write (chmod 555 handoffs) exits 1 throughset -ewith noREFUSED:line at all, on a command whose codes are 0 and 2. Both lines predate this branch, andunusable_dir_kindis the question this repository already has for it.How it was tested
tests/run.sh -k "wip_init_command or repo_hygiene"on Linux, twice: once with the four fixes reverted, where the five new cases fail and nothing else does, and once with them in place, where the whole of both modules passes. The four new tests aretest_a_git_status_this_command_cannot_run_is_refused_not_read_as_clean— corrupts.git/indexin an adopted checkout that is missing one template file (rev-parsestill answers, so the run reaches step 6a) and asserts exit 2 and git's ownfatal:line about the index underWhat it said:(the exact sentence is not pinned — which one a corrupt index draws depends on how it is corrupt and on the git version; this run's wasfatal: .git/index: index file smaller than expected), and that the missing template file was still not written.test_an_ancestor_of_a_template_path_that_is_not_a_directory_is_refused[symlink|regular-file]— commits each shape athandoffsand asserts exit 2, the component and its target in the refusal, nothing staged, no commit, no push, and — for the link — that the directory it points at is still empty.test_a_template_path_staged_at_another_mode_is_refused_not_restaged— stages the template's own substituted bytes athandoffs/README.mdwith--chmod=+x(which moves the index and leaves the worktree file at 0644, so only the mode differs) and asserts the person's staged100755is still there after the refusal.test_a_skip_worktree_template_path_is_named_and_never_seeded— sets the bit onlanes/LANES.md, deletes the file, assertsgit statusreally is silent about it, then asserts the summary line, exit 0, nothing written, nothing staged, no commit and no push for it.Everything new parses under macOS bash 3.2 — no
${x,,},mapfile,declare -Aorlocal -n; the ancestor walk is acase/whileover${rest%%/*}and${rest#*/}, the onecasewhose word is a command substitution was hoisted onto its own line, and the newsedspells--before its operand. CI runs the whole suite on all four jobs.Round 1 — Copilot, and SonarCloud's gate
wip init's owed-candidate index check compares blob content but never the staged mode #63's fix asks what the INDEX carries at an owed candidate, and step 8 stages from the WORKTREE, so a candidate carrying the execute bit is recorded as100755in the seed commit and pushed. Two routes reach that point which the stage-0 question never sees: an UNTRACKED template path whose bytes match the template and whose file somebody chmod'ed, and a path staged100644whose worktree file got the bit afterwards — step 6a catches neither, because it excludes the template's own paths by name. This command copies the template's bytes from a 0644 file and has never chmod'ed anything it wrote, so an executable file there is somebody's own and gets the same refusal a staged100755gets. Regression:test_an_executable_template_path_is_refused_not_seeded_at_100755[untracked|staged-then-chmod]. The refusal readscore.fileMode(as a boolean, because git spells false four ways) and stands down only for an explicitfalse: on a filesystem that reports every file executable git stages100644regardless, and refusing there would refuse every re-run on that mount over a bit that means nothing.sed -e 'script' -- "$file"on BSDsed(thread) — declined, with the cited file as the evidence._end_of_options_after_an_operand's own docstring names this shape as the REMEDY rather than the defect — "sed -n -e 'script' "$file"has no operand before the file list at all, which is why that is the shape this repository uses" — the checker itself does not flag the line (-eis in_OPTIONS_WITH_ARGUMENTS, so its argument is not an operand and--is reached withseen_operandfalse), andlanes-edit.sh:1387already ships the identical shape (grep -n -e … -e … -- "$file") through the macOS job. BSD'sgetopt(3)consumes--; what it does not do is permute, which is why a bare script operand before--breaks there and an-escript does not.wip init's owed-candidate index check compares blob content but never the staged mode #63's test.adopted_checkout_withoutis that block once, with four callers.python:S9073— the step 6a test's one composite assertion split into the two separate claims it was making.Closes #49
Closes #62
Closes #63
Closes #69
Lane: openRepoTools-1
🤖 Generated with Claude Code
Summary by Sourcery
Harden wip init against ambiguous repository state and unsafe template paths before it writes, stages, commits, or reports completion.
Bug Fixes:
Enhancements:
CI:
Tests: