Skip to content

wip init step 7 writes with an unguarded mkdir -p/cp, so an unwritable template directory is exit 1 with no refusal #105

Open

Description

@brettheap

wip init step 7's MISSING branch writes with an unguarded mkdir -p and cp, so a template directory this user cannot write is exit 1 and no refusal at all:

		mkdir -p -- "$checkout/$(dirname -- "$rel")"      # openRepoTools:2215
		cp -- "$dest" "$checkout/$rel"                    # openRepoTools:2216

Every other failure in wip_init is a die — exit 2, a REFUSED: line, and what to do about it. These two are not guarded at all, so under this file's set -euo pipefail the shell's own status stands: 1, which this toolset spends on "findings were printed" (status:3076-3078, and step 9's own comment says so in as many words about its pointer-file redirect). A person gets cp: cannot create regular file …: Permission denied on stderr and an exit code that means something else entirely; an automated caller — setup.sh runs wip init on every host — reads 1 as a report rather than a refusal.

Measured, under the same shell options this file sets:

$ mkdir -p handoffs && chmod 555 handoffs
$ bash -c 'set -euo pipefail; mkdir -p -- handoffs; echo "mkdir returned $?"; cp -- src handoffs/README.md; echo NEVER REACHED'
mkdir returned 0
cp: cannot create regular file 'handoffs/README.md': Permission denied
(exit 1)

mkdir -p returns 0 because the directory is already there — a chmod 555 on handoffs, or on lanes, is the whole precondition — and the cp is the call that fails.

Why this is filed rather than fixed in #101

It predates that branch entirely: both lines are unchanged since the commit that added the seed, and #101's own diff is the four gaps of #49, #62, #63 and #69 plus the two Copilot rounds on them (the durable word: take what a round introduces, file what predates it). #101 does close the two reachable ancestor shapes that end at these lines — a symlinked or non-directory component, and a submodule — but each of those is a die; permission is the one that still falls through to the shell.

What's open

Ask the question this repository already has a function for, before the write: unusable_dir_kind answers -d, -w and -x of the nearest existing ancestor and is what plan_install_targets and plan_skill_targets both use, for exactly this reason ("a directory at 0600 accepts no new file at all"). A die naming the directory and the bit it lacks would put this on the same footing as every other refusal in the command — and the cp itself is still worth guarding, since a write can fail for reasons no planner can see (ENOSPC, EROFS, an immutable bit).

Lane: openRepoTools-1

Activity

  1. brettheap commented on Oct 6, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoTools-1, session df82f553-7803-49c4-8ddf-3f9acdcb8ee0@Eagle, 2026-10-06T20:40:30Z, for #105

    Logged in lanes/log/openRepoTools-1.md at e5f324f3106b50df5d2dcc2319c34e40281f3291.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoTools#105:
       none
    2. `gh pr list --repo opensoft/openRepoTools --state all --search "#105"`, kept where the row or its body names `#105`:
    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	fix/wip-init-step7-ancestors-modes-sparse-and-status-failure	MERGED
    3. `git ls-remote --heads [email protected]:opensoft/openRepoTools` branches naming `105` as a whole token:
       none
    
  2. brettheap commented on Oct 6, 2026

    @brettheap
    ContributorAuthor

    Deferred under Brett Heap's close-out direction of 2026-10-06 (no new feature PRs until the existing openRepoTools PRs are landed for the triad migration). Lane openRepoTools-1 claimed this, a writer read the ground and designed the fix, and stopped before writing code; the claim is released and the design below is the handover.

    Design. Add a PLANNING pass before step 7's loop: first move the #62/#101 ancestor walk (symlink, non-directory, submodule) into it so its refusals keep their words (test_an_ancestor_of_a_template_path_that_is_not_a_directory_is_refused asserts "sits under it", and unusable_dir_kind would otherwise answer "not a directory" first); then, for each ABSENT template path, ask unusable_dir_kind "$checkout/$(dirname -- "$rel")" and die (exit 2) naming the directory and the reason, saying NOTHING was written. Put the MISSING-branch presence test (-e/-L, cat-file -e :rel, cat-file -e HEAD:rel, ls-files -u) in one helper such as wip_template_absent. Then guard the MISSING branch's mkdir -p and cp with || die naming the path.

    Tests. NOT_ROOT case (idiom at tests/test_install_skill_and_hook.py:651): adopted_checkout_without(rel="handoffs/README.md"), chmod 0o555 handoffs, assert exit 2, REFUSED, the path named, nothing written or staged, HEAD and remote unchanged, no pointer file; restore the mode in finally. Late-failure case: a fake cp on PATH that fails only when the destination is inside the checkout — wip_fetch_template_file also runs cp from upstream/openRepoShape, so the fake must pass every other call through.

    Branch prepared (no commits): fix/wip-init-step7-guarded-writes-and-step8-refusal-words off main 2080f3d, local only; whoever resumes runs git merge origin/main first. Shared with #140.

  3. brettheap commented on Oct 6, 2026

    @brettheap
    ContributorAuthor

    RELEASED — lane openRepoTools-1, session df82f553-7803-49c4-8ddf-3f9acdcb8ee0@Eagle, 2026-10-06T20:46:51Z, for #105 — deferred under Brett Heap's close-out direction of 2026-10-06; design posted on the issue; no code; no PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions