Skip to content

fix(test-selection): path-qualified reverse lookup in affected-tests.sh #5656

Closed

Description

@kyle-sexton

Closes nothing yet; this is a slice of the parked umbrella #3716 (acceptance criterion 5). The owner approved filing it on 2026-10-01; #3716 itself stays parked and is not unparked by this issue.

Problem

scripts/affected-tests.sh rules R3/R4 (reverse lookup) match a changed file to suites by bare basename. A same-named reference file under a different skill gets pulled in. Example from #3716: changing plugins/code-tidying/skills/dissolve-comments/reference/safety.md selected three unrelated suites under plugins/source-control/skills/babysit-prs/scripts/tests/ (test_babysit_merge.py, test_babysit_merge_review_settle.py, test_skill_contract.py), which reference the babysit-prs safety.md.

Fix

Make the R3/R4 reverse lookup path-qualified: at minimum skill plus filename (<skill>/<file>), or the repository-relative path, so a reference to one skill's file no longer selects suites for another skill's same-named file.

Acceptance criteria

  • Changing plugins/code-tidying/skills/dissolve-comments/reference/safety.md does not select any babysit-prs suite.
  • A regression test covers that case.
  • Selection is otherwise behavior-preserving: every suite selected before for a genuine dependency is still selected. Existing suites pass unchanged.
  • R5 copy fan-out is kept as is. affected-tests.sh (the comment near line 234 on origin/main) states that a same-basename match in another directory has to stay a basename rule because R5's fan-out is copies sharing a basename across directories (for example lib/hook-utils.sh). Path-qualifying R3/R4 must not drop suites R5 reaches.
  • Selection time does not regress noticeably (the existing batching of basenames into one grep pass is a known performance constraint, see the comments around lines 248-253).

Verification

Run scripts/affected-tests.sh --explain over a diff touching the code-tidying safety.md, before and after, and compare the selected sets. Run the affected-tests suite.

Related

Activity

  1. added
    agent-ready
    on Oct 1, 2026
  2. added
    needs-triage
    on Oct 1, 2026
  3. kyle-sexton commented on Oct 1, 2026

    @kyle-sexton
    MemberAuthor

    #5718 (merge commit 7bd7d2c) meets all five acceptance criteria on origin/main. I checked this by running scripts/affected-tests.sh on a git-archive snapshot of origin/main (HEAD 0e14fdb) and comparing it with a snapshot of the parent commit 329ea77.

    • AC1: --explain on plugins/code-tidying/skills/dissolve-comments/reference/safety.md now selects no suite (reported as no-suite, exit 0), so no babysit-prs suite is selected. The parent commit selected the babysit-prs suites plus clause-coverage suites. The babysit-prs safety.md selection is unchanged.
    • AC2: the ownership-probe regression cases are in scripts/affected-tests.test.sh (lines 1374-1426). They use a fixture, ownership-probe.md, and cover the same-named-file-in-another-skill case. The suite gives PASS=102 FAIL=0.
    • AC3: the open question from fix(test-selection): scope R3/R4 reverse lookup to skill ownership #5718 is answered, and no owner call is needed. No course-digest suite names any of the four files plugins/knowledge/skills/course-digest/extraction/{register-hook,resolve-hook,run,setup-deps}.mjs. A grep finds them only in SKILL.md, context/workflow.md and the files themselves. Their old selections came only from same-named video-digest files (including unrelated pixel-art suites), so they were not genuine dependencies. They now report UNMAPPED (exit 1), which scripts/affected-tests-no-suite.txt describes as the intended result for a code file with no test. Across every changed-file seed fix(test-selection): scope R3/R4 reverse lookup to skill ownership #5718 swept (2863 seeds), the new selection gained 0 suites and lost 2175 (seed, suite) pairs. Of the 156 lost pairs where the suite mentions the seed's own basename, every one is a skill citing its own same-named file or a path through another skill.
    • AC4: I derived the copy set for every sync source with --print-fanout. No lost suite names a copy by basename. The R5 copy fan-out is unchanged.
    • AC5: interleaved runs of 3, medians before and after: lib/hook-utils.sh 875 ms to 911 ms, audit-instructions finding-ids.sh 326 ms to 418 ms, dissolve safety.md 224 ms to 129 ms, babysit-prs safety.md 212 ms to 246 ms. All are sub-second, and the 22-path aggregate fix(test-selection): scope R3/R4 reverse lookup to skill ownership #5718 measured was within noise. The cost is one extra BFS level of about 4 ms.

    No open PR or duplicate issue covers this.

    Separate follow-up, not part of this issue: those four course-digest .mjs files have no test, so a PR that touches them will fail affected-tests selection until a suite covers them or a no-suite entry names a lane. ci.yml lines 2458-2477 already run the course-digest run-tests.sh test.

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

    agent-readyneeds-triage

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions