Skip to content

scripts/carry.py's worktree-registration check can never match on Windows #1117

Closed

Description

@ptr727

Summary

scripts/carry.py's worktree-registration check compares git's forward-slash path against Python's native path string. On Windows those never match, so carry.py check and carry.py apply always fail with target is not a registered git worktree even when the target is a correctly registered worktree. The tool is unusable on a Windows host.

Found while running RESYNC.md section 3 item 3 against ptr727/Financial-Modeling, which needed the .github/skills verbatim-tree carried.

Where

scripts/carry.py:346-348:

worktree_rows = git(target, "worktree", "list", "--porcelain").splitlines()
if sum(row == f"worktree {target.resolve()}" for row in worktree_rows) != 1:
    raise CarryError("target is not a registered git worktree")

git worktree list --porcelain emits POSIX-style separators on Windows, while pathlib.WindowsPath.__str__ emits backslashes. The equality can never hold.

Evidence

Host: Windows 11, git 2.55.0, Python 3.13.15 (scripts/host_gate.py --repo <target> reports [ok] host-tools 0 issue(s)).

Observed, from the target worktree:

$ git worktree list --porcelain | head -6
worktree C:/Users/piete/repos/Financial-Modeling
HEAD 52dfe4b06341ba0d44da3949a430c875aad019ba
branch refs/heads/develop

worktree C:/Users/piete/repos/worktrees/Financial-Modeling-hub-carried-files
HEAD 52dfe4b06341ba0d44da3949a430c875aad019ba

$ python -c "import pathlib; print('worktree', pathlib.Path('.').resolve())"
worktree C:\Users\piete\repos\worktrees\Financial-Modeling-hub-carried-files

And the resulting failure, run from a clean hub worktree at f3b4cc9:

$ python scripts/carry.py check Financial-Modeling --target /c/Users/piete/repos/worktrees/Financial-Modeling-hub-carried-files
ERROR: target is not a registered git worktree

The target was a genuine registered worktree on its own feature branch, as the git worktree list output above shows.

Expected and actual

  • Expected: the check passes for a registered worktree on every supported host, and carry.py check/apply proceed to compare the manifest-owned trees.
  • Actual: on Windows it raises target is not a registered git worktree unconditionally, so the manifest-driven tree carry cannot run at all and the tree has to be mirrored by hand.

Suggested fix

Compare resolved paths rather than strings, for example parsing each worktree row into a pathlib.Path and comparing Path(row).resolve() == target.resolve(), or normalizing with as_posix() on both sides. scripts/carry.py:334 (if top != target.resolve()) compares Path objects and is not affected, which is why only this one site fails.

Workaround used

Mirrored .github/skills by hand from the hub checkout and verified byte-identical with diff -rq. That loses the prune authority the tree declaration is supposed to supply, so an extra downstream path would not have been reported.

Context

  • Hub: f3b4cc9 (2.0.526), read at main.
  • Downstream: ptr727/Financial-Modeling, audit run 2026-08-30T14:37:34Z | hub f3b4cc9.
  • Downstream PR that hit it: ptr727/Financial-Modeling#204.

Activity

  1. added
    script
    on Sep 5, 2026
  2. ptr727 commented on Sep 9, 2026

    @ptr727
    OwnerAuthor

    Still reproducing, unchanged, at hub 8195c43 (2.0.587), 190-odd commits after this was filed.

    Hit again driving RESYNC.md against ptr727/Financial-Modeling, this time on both halves of section 3: check-sections/apply-sections for the AGENTS.md and GOVERNANCE.md verbatim regions, and check/apply for the .github/skills tree. All four subcommands fail identically at verify_target, before any manifest work starts.

    Audit run stamp: audit run 2026-09-09T20:19:39Z | hub 8195c43.

    Host is unchanged from the report above except for the git version: Windows 11, git 2.55.0, Python 3.13.15, scripts/host_gate.py --repo <target> reports [ok] host-tools 0 issue(s) over 8 declared tool(s).

    The comparison at scripts/carry.py:352-354 is still:

    worktree_rows = git(target, "worktree", "list", "--porcelain").splitlines()
    if sum(row == f"worktree {target.resolve()}" for row in worktree_rows) != 1:
        raise CarryError("target is not a registered git worktree")

    Confirmed on this host that the two sides differ only in separator:

    $ git worktree list --porcelain | head -1
    worktree C:/Users/piete/repos/Financial-Modeling
    $ python -c "import pathlib; print(repr(str(pathlib.Path(r'C:\Users\piete\repos\worktrees\hub-resync-sections').resolve())))"
    'C:\Users\piete\repos\worktrees\hub-resync-sections'
    

    Worth noting what the workaround costs, since it bears on priority. carry.py is not a convenience here: its post-apply assertion, that the preamble, the heading sequence, and every non-declared region came through byte-identical, is the mechanical layer that carried-instruction-file-guard leans on to make a downstream re-vendor safe. A resync that routes around this bug by hand-copying regions loses exactly that assertion, on the file class where the AGENTS.md-overwrite incident happened. This resync kept the assertion by wrapping the one git worktree list --porcelain call in a shim rather than by hand-copying, but that is not something the procedure should need.

    Suggested fix, comparing resolved paths rather than strings:

    registered = {
        pathlib.Path(row[len("worktree ") :]).resolve()
        for row in git(target, "worktree", "list", "--porcelain").splitlines()
        if row.startswith("worktree ")
    }
    if target.resolve() not in registered:
        raise CarryError("target is not a registered git worktree")

    That also drops the != 1 count, which was only ever guarding against a duplicate row git does not emit.

  3. ptr727 commented on Sep 21, 2026

    @ptr727
    OwnerAuthor

    ptr727/Financial-Modeling is waiting on this. Recorded there as ptr727/Financial-Modeling#416, which states what that repository cannot do in its own terms and carries the blocked label, per GOVERNANCE.md "Durable Knowledge and Self-Improvement". Filed from the hub resync that merged as ptr727/Financial-Modeling#413, measured at audit run 2026-09-21T00:48:09Z | hub 90161ce.

  4. ptr727 commented on Sep 27, 2026

    @ptr727
    OwnerAuthor

    Still reproducing, unchanged, at hub f431a02 (scripts/carry.py last changed at 09a82e6). The comparison is now at scripts/carry.py:363-365.

    Hit again driving RESYNC.md against ptr727/Vantage-Config on Windows 11 (git 2.55.0, Python 3.13.15, host_gate.py --repo clean). check-sections fails with target is not a registered git worktree against a correctly registered worktree at C:/Users/piete/repos/worktrees/Vantage-Config-resync-instructions. The workaround was the one this issue already implies: carry by hand from git ls-files in the hub checkout, then byte-compare each declared ## region after CRLF normalization. That also meant the tool's post-apply assertion (preamble and non-declared regions byte-identical) was not available, so the manual comparison had to stand in for it. The resulting convergence PRs are ptr727/Vantage-Config#16 (sections) and ptr727/Vantage-Config#18 (.github/skills tree).

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

    script

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions