Skip to content

fix(claim): match claimed paths by segment prefix, not substring (#31) - #39

Open
AryanSingh2029 wants to merge 1 commit into
MaxonT:mainfrom
AryanSingh2029:fix/claim-overlap-path-prefix-31
Open

AryanSingh2029 wants to merge 1 commit into
MaxonT:mainfrom
AryanSingh2029:fix/claim-overlap-path-prefix-31

Conversation

@AryanSingh2029

Copy link
Copy Markdown

Fixes #31.

The bug

_overlaps compared claimed paths with a substring test:

any(x.rstrip("/") + "/" in y or y.rstrip("/") + "/" in x for x in fa for y in fb)

"docs/" in "mydocs/x.md" is True for a substring but the two paths are in different directories, so aisync claim raised a false overlap (exit 3) for cases like docs vs mydocs/x.md and src vs lib/src/a.py — telling an agent to stop and coordinate with someone working somewhere else.

The fix

Compare path prefixes by whole segment. A claim x covers y when y equals x or y lies beneath it (y starts with x.rstrip("/") + "/"), checked in both directions. A small _covers(parent, child) helper carries the rule; the exact-match fast path (bool(fa & fb)) is unchanged.

This is confined to the substring-vs-prefix bug. Path normalisation (./src/a.py vs src/a.py, #32) is a separate issue and left untouched.

Verification

  • The two false-alarm cases from the report no longer overlap; real overlaps still do: a directory covering a child in either direction (docs ↔ docs/guide.md, src/ ↔ src/app.py), an identical file, a trailing-slash spelling (docs/ vs docs), and whole-repo claims (the empty-set branch) are all preserved. Substring traps such as lib vs library/x no longer match.
  • Added test_overlap_matches_path_prefix_not_substring in tests/test_collab.py covering the false alarms and the real-overlap cases.

…onT#31)

_overlaps compared claimed paths with a substring test, so a directory whose name merely contains another claim's name (docs vs mydocs/x.md, src vs lib/src/a.py) raised a false overlap and told an agent to stop and coordinate with someone working elsewhere. Compare path prefixes by whole segment instead: a claim x covers y when y equals x or starts with x.rstrip('/') + '/', checked both directions, via a small _covers helper. Scope is the substring-vs-prefix bug only; path normalisation (MaxonT#32) is left untouched.

This branch has not been deployed

No deployments
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.

claim: 'docs' is reported as overlapping 'mydocs/x.md' (substring match, not path prefix)

1 participant