Skip to content

feat(assess): predict file-collision between PROCEED issues from body content #556

Closed

Description

@admarble

Summary

/assess Step 5 ("Conflict Detection") only inspects active worktrees — it can't predict collisions between two unstarted issues that will both modify the same file. As a result, batch /assess recommends parallel sequant run commands that race on shared files at merge time.

This issue adds a predicted-collision heuristic that reads issue bodies before output formatting and warns when 2+ PROCEED issues are likely to touch the same file.

Motivation — concrete recent example

/assess 532 543 551 552 (today). Issues #551 and #552 both:

  • Modify qa/SKILL.md (added new sections, distinct concerns but same file)
  • Require 3-dir sync across .claude/skills/, templates/skills/, skills/
  • Have explicit ACs naming the file paths

The skill's current output didn't auto-detect this — I caught it manually by reading both issue bodies and added an Order: warning + suggested sequential execution. Without that manual catch, the recommended commands would have started parallel worktrees that collide on identical line ranges.

The signal is grep-able from issue body content: both issues mention qa/SKILL.md and 3-dir sync. A simple cross-issue grep would have surfaced it.

Acceptance Criteria

  • AC-1: Path extraction from issue bodies. During Step 1 (Context Gathering), for each PROCEED candidate, extract file paths mentioned in the issue body. Heuristics:
    • Backtick-quoted paths matching *.md, *.ts, *.tsx, *.json, *.sh
    • Paths under .claude/, templates/, skills/, src/, bin/, docs/
    • "3-dir sync" / "across all three skill directories" → flag the named file as touching all three skill roots
  • AC-2: Cross-issue overlap detection. After path extraction, compute pairwise intersection. Any pair sharing ≥1 file → flag as predicted collision.
  • AC-3: Output annotation. Predicted collisions emit an Order: line referencing the specific shared file, plus a ⚠ per affected issue:
    Order: 551 → 552 (both modify qa/SKILL.md — sequential execution avoids 3-dir-sync merge conflicts)
    
    ⚠ #551  Modifies qa/SKILL.md (overlaps #552); land sequentially
    ⚠ #552  Modifies qa/SKILL.md (overlaps #551); land sequentially
    
  • AC-4: Suggest --chain when 3+ issues collide on the same file. Add a Chain: suggestion alongside default commands (suggest-only, never auto-applied — same rule as existing chain detection).
  • AC-5: False-positive guards. Don't flag overlap when:
    • The shared file is CHANGELOG.md (every PROCEED issue touches it; would flag on every batch)
    • The shared file is package.json lockfile (low-conflict, alphabetically merged in practice)
    • One issue's body uses the path only in a <!-- comment --> or quoted code block that's clearly not the file-of-modification
      Document the guard list in references/predicted-collision-detection.md so it's tunable without skill edits.
  • AC-6: Tests. In src/lib/__tests__/assess-skill.test.ts (or new assess-collision-detect.test.ts):
  • AC-7: SKILL.md documents the new detection step under Step 5 ("Conflict Detection") — extend the existing section rather than adding a new step. 3-dir sync.
  • AC-8: CHANGELOG entry under [Unreleased] / ### Added.

Non-Goals

  • Not auto-running issues sequentially. The skill still suggests; the user decides. Same precedent as existing Chain: detection.
  • Not parsing the full diff of each issue (premature — issue bodies contain the signal in 90%+ of cases).
  • Not detecting collisions in already-running worktrees. That's Step 5's existing scope.

Risks / Open Questions

Complexity

medium — heuristic detection logic + 2 reference files + tests + 3-dir sync. Skill-prompt heavy.

Self-assessed workflow

spec → exec → qa with -q (multi-file: skill changes + reference doc + tests + CHANGELOG)

Related

Activity

  1. added
    enhancement
    on Apr 26, 2026
  2. admarble commented on May 3, 2026

    @admarble
    ContributorAuthor

    → PROCEED — Predicted file-collision detection in /assess, 8 ACs

    Workflow: spec → exec → qa with -q

    npx sequant run 556 -q                # after #559 lands
    

    ⚠ Sequential after #559 — both modify assess/SKILL.md across 3 skill dirs (and possibly src/lib/__tests__/assess-skill.test.ts). #554 prerequisite (Order: file-collision rule) already shipped via #557.

  3. admarble commented on May 4, 2026

    @admarble
    ContributorAuthor

    /spec Plan

    AC Checklist (verbatim from issue)

    • AC-1: Path extraction from issue bodies (backtick-quoted, with skill-root expansion for 3-dir sync mentions) — Verify: unit test
    • AC-2: Cross-issue pairwise overlap → flag predicted collision — Verify: unit test
    • AC-3: Output annotation (Order: line + ⚠ per affected issue) — Verify: unit test
    • AC-4: Suggest --chain when 3+ issues collide on the same file (suggest-only) — Verify: unit test
    • AC-5: False-positive guards (CHANGELOG.md, lockfiles, code-block-only mentions); guard list documented in references/predicted-collision-detection.md — Verify: unit test + reference doc review
    • AC-6: Tests in src/lib/__tests__/assess-collision-detect.test.ts using verbatim feat(qa): require detection-pattern verification for skill regex/grep/awk changes #551 / feat(spec,qa): detect behavior-rule implementations across skill+runtime touchpoints #552 issue bodies as fixtures — Verify: vitest
    • AC-7: Step 5 of assess/SKILL.md extended (not new step), 3-dir mirrored — Verify: existing 3-dir-sync test
    • AC-8: CHANGELOG entry under [Unreleased] / ### Added

    Implementation Plan

    Phase 1 — Core detection module

    • New src/lib/assess-collision-detect.ts:
      • extractPathsFromIssueBody(body) — strips fenced code blocks + <!-- HTML comments --> first, then runs path regex over the remainder; expands 3-dir sync mentions to all three skill roots
      • detectFileCollisions(issuePaths) — pairwise intersect → { issues, file }[]
      • EXCLUDED_PATHS (CHANGELOG.md, package-lock.json, yarn.lock, pnpm-lock.yaml)
      • formatCollisionAnnotations(results) → { orderLines, warnings, chainSuggestion? }

    Phase 2 — Skill prose (3-dir sync)

    • Extend Step 5 of assess/SKILL.md (per AC-7) with a "Predicted file-collision" sub-section that names the new fns and points at the reference doc.
    • Create references/predicted-collision-detection.md (also 3-dir-mirrored) covering path regex, excluded-path list, proximity-weighting note.

    Phase 3 — Tests + CHANGELOG

    Design Review

    1. Where does this logic belong? New module src/lib/assess-collision-detect.ts — parallel to src/lib/assess-comment-parser.ts from feat(assess): detect prior assess markers — supersession note + re-assessment churn warning #555. Skill prose stays declarative; testable heuristic lives in TS.
    2. Simplest correct approach? Pure functions, no I/O. Strip fenced code blocks + HTML comments before regex (one-pass guard). Skip proximity weighting — not an AC, defer until evidence demands it.
    3. Existing pattern? Direct continuation of feat(assess): detect prior assess markers — supersession note + re-assessment churn warning #555's assess-comment-parser.ts (pure fns + SKILL.md links by name + vitest with fixture-driven cases).
    4. Senior reviewer pushback? "Why not diff parsing?" → out of scope per Non-Goals. "Why regex over markdown parser?" → AC-5's guards are state-machine simple. Documented in reference doc.

    Open Questions

    1. Multi-file collision between same pair, recommended: show lowest-named file with (+N more) suffix. Caps line width.
    2. Step 5 placement, recommended: extend existing prose (AC-7 explicit).

    Conflict Risk

    In-flight worktree feature/551-… modifies qa/SKILL.md; this issue modifies assess/SKILL.md. No file overlap.

    Recommended Workflow

    spec → exec → qa with -q (multi-file 3-dir sync × 2 + new TS module + tests).

  4. admarble commented on May 4, 2026

    @admarble
    ContributorAuthor

    /qa Review

    Verdict: READY_FOR_MERGE

    AC Coverage (8/8 MET)

    AC Status Evidence
    AC-1 Path extraction MET PATH_REGEX covers 5 extensions × 6 tracked roots; SKILL_FILE_REGEX + 3-dir-sync trigger; code-blocks + HTML comments stripped before matching
    AC-2 Cross-issue overlap MET detectFileCollisions builds file→issue map, emits one CollisionResult per shared file (≥2 issues)
    AC-3 Order: + ⚠ annotations MET formatCollisionAnnotations emits both. Output uses fully-qualified path (.claude/skills/qa/SKILL.md) — consistent with #554's bare-filename-as-reason rule for file-collision Order: lines
    AC-4 Chain: when 3+ collide MET Conditional on issues.length >= 3; suggest-only string (no auto-apply)
    AC-5 False-positive guards MET CHANGELOG.md, package-lock.json, yarn.lock, pnpm-lock.yaml excluded; fenced code blocks + HTML comments stripped; full guard list in references/predicted-collision-detection.md
    AC-6 Tests with verbatim #551/#552 MET 13 tests; 4 use verbatim issue bodies (positive overlap on qa/SKILL.md), 5 use synthetic fixtures for false-positive guards (code-block-only, HTML-comment-only, CHANGELOG-only, glob-pattern, bare filename); 3-issue Chain: case covered
    AC-7 SKILL.md extension under Step 5 MET Existing Step 5 extended (not new step); 3-dir-mirrored (existing assess-skill.test.ts 3-dir-sync test passes byte-identical)
    AC-8 CHANGELOG entry MET Under [Unreleased] / ### Added

    Quality Gates

    • Build: npx tsc clean
    • Tests: 2761/2761 pass on full suite (89/89 in assess-related files)
    • 3-dir sync: assess-skill.test.ts 3-dir-sync test confirms byte-identical content across .claude/skills/, templates/skills/, skills/
    • CLI-flag-accuracy test: new npx sequant run A B C --chain --qa-gate -q example uses only valid flags

    Adversarial Re-read

    1. Slash-command derivation false-positive risk — /qa discussed casually (not modifying) under 3-dir-sync language → flags qa/SKILL.md. Documented in the reference doc as known tradeoff. The warning is non-blocking and easy to dismiss.
    2. PATH_REGEX greedy backup-extension — .claude/skills/foo/SKILL.md.bak would partially-match …/SKILL.md. Issue bodies don't carry .bak files; non-issue.
    3. No e2e integration test — SKILL.md prose names the new functions, but no test verifies the LLM-driven /assess actually invokes them and renders the result. Same pattern as assess-comment-parser.ts from feat(assess): detect prior assess markers — supersession note + re-assessment churn warning #555 — the LLM-driven harness is verified by the human review of dashboard output.

    Risk Assessment

    PR-bound

    Diff: 9 files, +913 / -0 (3 SKILL.md mirrors + 3 reference-doc mirrors + 1 module + 1 test + CHANGELOG).

  5. admarble commented on May 4, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #556
    PR: #577
    Status: READY_FOR_MERGE

    Summary

    • AC: 8/8 met
    • Tests: 2761/2761 pass (13 new)
    • Build: clean
    • 3-dir sync: verified

    Iterations

    • Spec: 1
    • Exec: 1 (one tsc fix for */ inside JSDoc comment)
    • QA: 1

    Risk Assessment

    • Likely failure mode: Slash-command derivation over-flags two issues mentioning /qa casually under 3-dir-sync language. Cost: spurious sequencing warning. No production impact.
    • Not tested: Real /assess end-to-end on a live batch — requires post-merge verification.

    Ready for human review and merge.

  6. added a commit that references this issue on May 4, 2026
  7. admarble commented on May 4, 2026

    @admarble
    ContributorAuthor

    Adversarial follow-up — gap fix pushed

    User asked "any gaps?" after the structured QA pass. Adversarial re-read against AC-3's literal expected output surfaced 3 real gaps that the structured pipeline missed:

    Gap 1 — Triple-noise on 3-dir-sync mirror collisions

    The prior implementation expanded qa/SKILL.md to all three mirrors at extraction time, so detectFileCollisions emitted three Order: lines and six ⚠ warnings for one logical conflict:

    Order: 551 → 552 (.claude/skills/qa/SKILL.md)
    Order: 551 → 552 (templates/skills/qa/SKILL.md)
    Order: 551 → 552 (skills/qa/SKILL.md)
    ⚠ #551  Modifies .claude/skills/qa/SKILL.md (overlaps #552); land sequentially
    ⚠ #551  Modifies templates/skills/qa/SKILL.md (overlaps #552); land sequentially
    ⚠ #551  Modifies skills/qa/SKILL.md (overlaps #552); land sequentially
    ... (3 more for #552)
    

    vs. the issue's expected:

    Order: 551 → 552 (qa/SKILL.md)
    ⚠ #551  Modifies qa/SKILL.md (overlaps #552); land sequentially
    ⚠ #552  Modifies qa/SKILL.md (overlaps #551); land sequentially
    

    Fix: normalize skill-mirror prefixes (.claude/skills/, templates/skills/, skills/) to canonical bare form (qa/SKILL.md) at extraction. Mirrored references deduplicate naturally; one collision per logical conflict.

    Gap 2 — AC-6 fixture using wrong path

    AC-6 literally says: "One issue mentions qa/SKILL.md, the other only mentions it inside a code-block → no overlap." My test used src/lib/foo.ts instead, weakening the AC-6 link. Added a new test using #552 verbatim plus a synthetic code-block-only fixture.

    Gap 3 — AC-1 says "during Step 1", prose was Step-5-only

    AC-1 specifies extraction "during Step 1 (Context Gathering)". Added a cross-reference in Step 1 prose pointing at Step 5's detector.

    Verification

    Commit: 8591f6b

  8. added a commit that references this issue on May 4, 2026
  9. added a commit that references this issue on Jul 16, 2026
  10. added a commit that references this issue on Sep 9, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions