Skip to content

The inventory tests' norm takes the sandbox root out before the tree-id and pid rules, so a TMPDIR with a c<digits>- segment no longer fails two tests (opensoft/openRepoTools#334) - #24

Merged
brettheap merged 1 commit into
mainfrom
fix/334-norm-root-first
Nov 10, 2026
Merged

brettheap merged 1 commit into
mainfrom
fix/334-norm-root-first

Conversation

@brettheap

@brettheap brettheap commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openRepoTools-3
Claim: opensoft/openRepoTools#334 (comment)

Draft: needs an independent review before it lands (opensoft/openRepoTools#334 says so).

The defect

Inventory.norm in tests/test_lanes_index.py applied TREE_ID to the whole answer before it took out the sandbox root (on code main 86d635b, lines 1783-1785). A root whose own path holds a segment TREE_ID matches, such as rv-c302-309-work, was cut up first (rv-<TREE>), so no root was left to take out. Two tests that compare one sandbox's answer with another's then fail for no reason but the folder the suite ran from: test_offline_no_read_the_inventory_acts_are_byte_identical_against_an_unreachable_index and test_a_poisoned_worktrees_table_changes_no_inventory_acts_answer. The pid rule also ran before the root was taken out, so a root with the live session's pid as a segment had the same fault. CI is unaffected, because its path has no c<digits>- segment.

The fix

norm now takes the root out first (as resolved, then as given), then applies TREE_ID, then the pid rule, then normal(text) (no longer handed the root, which is already out). New test test_norm_takes_the_sandbox_root_out_before_any_rule_that_could_cut_it_up writes one answer under four roots (plain; a rv-c302-309-work segment; a link whose target holds that segment; the pid as a segment) and requires the same text from each. Test-only: tests/test_lanes_index.py, +72/-3, one commit.

Port source

This ports commit 77ff7bfc6db9f705a98f13285cf63cb235422148 (77ff7bf, branch fix/334-norm-replaces-root-first in the monorepo opensoft/openRepoTools, never PR'd) onto code main 86d635b778c9943a8d6a8b3d785080800cc48e4a. It was applied with git cherry-pick -n and applied cleanly, with no hand edits: the diff is the same hunks.

Verification

Narrow run on this branch (head 06102a4), under TMPDIR=/tmp XDG_STATE_HOME=/tmp/l3-334, as timeout 3600 bash tests/run.sh -k 'test_lanes_index':

102 passed, 4167 deselected in 601.11s (0:10:01)

That run's TMPDIR has no c<digits>- segment, so it shows the change breaks nothing and that the new test passes; it does not by itself show the fix. I did not rerun run.sh under a TMPDIR holding such a segment. The old-versus-new difference is the probe below, which runs a COPY of Inventory.norm extracted by ast from 86d635b's file and from this branch's file, over one answer written under a plain root and under a root rv-c123-work/root. $SB stands for the sandbox directory.

== OLD norm (code main 86d635b)
-- under the plain root $SB/probe-roots/plain/root
ROOT	<ROOT>/lane-state/repoA-1
TREE	<TREE>	ok	<ROOT>/repos/repoA/.claude/worktrees/w-run	branch feat/run head <HEX> observed <UTC>
HOLDER	live	<PID>	orphan
-- under the root with a c123- segment $SB/probe-roots/rv-c123-work/root
ROOT	/workspace/projects/.lane-worktrees/openRepoTools-3/wk-334-<HEX>/probe-roots/rv-<TREE>/root/lane-state/repoA-1
TREE	<TREE>	ok	/workspace/projects/.lane-worktrees/openRepoTools-3/wk-334-<HEX>/probe-roots/rv-<TREE>/root/repos/repoA/.claude/worktrees/w-run	branch feat/run head <HEX> observed <UTC>
HOLDER	live	<PID>	orphan
-- SAME TEXT FROM BOTH ROOTS: False

== NEW norm (branch HEAD)
-- under the plain root $SB/probe-roots/plain/root
ROOT	<ROOT>/lane-state/repoA-1
TREE	<TREE>	ok	<ROOT>/repos/repoA/.claude/worktrees/w-run	branch feat/run head <HEX> observed <UTC>
HOLDER	live	<PID>	orphan
-- under the root with a c123- segment $SB/probe-roots/rv-c123-work/root
ROOT	<ROOT>/lane-state/repoA-1
TREE	<TREE>	ok	<ROOT>/repos/repoA/.claude/worktrees/w-run	branch feat/run head <HEX> observed <UTC>
HOLDER	live	<PID>	orphan
-- SAME TEXT FROM BOTH ROOTS: True

Under the c123- root the old norm leaves the root in the text (rv-<TREE>, and its wk-334-<HEX> folder name cut by the hex rule) and the two answers differ. The new norm returns the same text from both roots.

🤖 Generated with Claude Code

Summary by Sourcery

Fix inventory normalization so equivalent answers remain identical regardless of the sandbox root path.

Bug Fixes:

  • Ensure inventory answer normalization removes the sandbox root before applying tree-ID and process-ID substitutions, preventing root path segments from being altered and causing false test failures.

Tests:

  • Add coverage for sandbox roots containing tree-ID segments, symlink-resolved tree-ID segments, and process-ID segments.

…e-id and pid rules, so a TMPDIR with a `c<digits>-` segment no longer fails two tests (opensoft/openRepoTools#334)

Test-only: `Inventory.norm` in `tests/test_lanes_index.py` is the one function changed, plus one new parametrized test. No product code and no golden file changes.

## What was wrong

`norm` applied `TREE_ID` to the whole answer before it took out the sandbox root. A root whose own path holds a segment `TREE_ID` matches, such as `rv-c302-309-work` (a review folder), was cut up first (`rv-<TREE>`), so no root was left to take out, and the two tests that compare one sandbox's answer with another's failed for no reason but the folder the suite ran from: `test_offline_no_read_the_inventory_acts_are_byte_identical_against_an_unreachable_index` and `test_a_poisoned_worktrees_table_changes_no_inventory_acts_answer`. The pid rule also ran before the root was taken out, so a root with the live session's pid as a segment had the same fault.

## What changed

`norm` takes the root out first, as resolved and then as given, and only then applies `TREE_ID` and the pid rule; `normal` follows as before and is no longer handed the root, which is already out.

`test_norm_takes_the_sandbox_root_out_before_any_rule_that_could_cut_it_up` writes one answer under four roots (a plain one; one holding `rv-c302-309-work`; a link whose target holds it, so the segment is in the resolved path alone; one with the pid as a segment) and requires the same text from each.

## Port

This ports commit `77ff7bf` (`77ff7bfc6db9f705a98f13285cf63cb235422148`, branch `fix/334-norm-replaces-root-first` in the monorepo opensoft/openRepoTools) onto the code leg's `main` at `86d635b`. The diff applies unchanged: `tests/test_lanes_index.py`, +72/-3.

## To reproduce opensoft/openRepoTools#334

Run the inventory tests from a TMPDIR whose path holds a `c<digits>-` segment, for example `mkdir -p /tmp/rv-c302-309-work` and then `TMPDIR=/tmp/rv-c302-309-work bash tests/run.sh -k test_lanes_index`: the two tests named above fail on `main`'s `norm` (called directly, as `77ff7bf` recorded) and pass with this change. The new parametrized test also fails on `main`'s `norm` for the three roots that hold a rule's match, and passes for all four with this change.

Lane: openRepoTools-3

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Tests

Change Inventory.norm to remove the sandbox root before tree-ID and PID normalization, and add parametrized coverage for roots that contain those patterns, including a symlink-resolved path.

  • tests/test_lanes_index.py L1782-1789, L1803-1868

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap marked this pull request as ready for review November 10, 2026 12:33
@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026

Copy link
Copy Markdown

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 4 days and 5 hours by commenting @sourcery-ai review. Upgrade to get a review now.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant