Skip to content

test(code-metrics): isolate dispatch.test.sh from the developer's home configuration - #16374

Merged
melodic-automation-lanes[bot] merged 4 commits into
mainfrom
work-resolve-issue/issue-16365-43731868848-1
Nov 15, 2026
Merged

melodic-automation-lanes[bot] merged 4 commits into
mainfrom
work-resolve-issue/issue-16365-43731868848-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #16365

Summary

Opened by the work-resolve-issue lane. The run's own summary:

dispatch.test.sh now creates an empty temporary directory at suite start, exports CODE_METRICS_HOME to it, and removes it in the existing EXIT trap. Every dispatch invocation that set no CODE_METRICS_HOME of its own (30 of 52) therefore resolves config against that empty home instead of ~/.claude. A developer's ~/.claude/code-metrics.yaml or ~/.claude/ecosystems/<lane>.yaml can no longer change lanes, thresholds or scope in the cases. Cases that already set a per-command CODE_METRICS_HOME keep it, since a per-command assignment overrides the export. No case tests the default home on purpose, so none is exempted. Design choice: one suite-wide export rather than 30 per-command prefixes. It covers every invocation, including ones added later, and matches the pattern audit-suppressions.test.sh:39 already uses. Basis: entry-common.sh:97-99 is the only place that passes a home to resolve-config.py, and dispatch.sh calls it only when no --config is given. The test's direct resolve-config.py calls pass layer files positionally, which skips home discovery. Adds a bump: none changelog fragment for code-metrics.

Not verified

  • Running dispatch.test.sh itself, and the done-when check that the suite passes with a ~/.claude/ecosystems/<bundled lane>.yaml present: this lane's Bash runs only named wrappers, so neither ran here. Left to the PR's CI and a local run. By reading the code, the export routes every dispatch…
  • Adjacent exposure outside this issue's scope, found by the review: the skill suites audit-size.test.sh, audit-complexity.test.sh, audit-duplication.test.sh, audit-coverage.test.sh (and possibly audit-type-debt.test.sh:224) drive the dispatcher without CODE_METRICS_HOME. Cases in dispatch.test.sh…
  • tidy pass 5 (ai-slop fix) on the changelog fragment: detect.sh is not a wrapper this lane may run, so only the rubric was read (no findings, no edit). Tidy passes 1-4 found nothing to change.
  • verify step (build and tests): no build applies to a shell test file, and the test suite could not run in this lane (see above)

Fix

  • plugins/code-metrics/scripts/dispatch.test.sh: export CODE_METRICS_HOME to a mktemp -d directory before the first case, with a comment saying why, and add that directory to the EXIT trap's cleanup
  • plugins/code-metrics/scripts/dispatch.test.sh: also export HOME to a test-owned directory. It holds a user-global python ecosystem file whose glob matches no fixture, so any dispatch call that falls back to HOME moves cm_sample.py out of the python lane and fails a case. It also keeps persist-report.sh out of the real ~/.claude/plugins/data. A new case 0 runs with CODE_METRICS_HOME empty and asserts the guard works. Both directories are removed by the EXIT trap (review feedback)
  • .changes/code-metrics/work-resolve-issue-issue-16365-43731868848-1-b8a86c1b.md: new bump: none fragment describing the test-only change

Verification

The runner ran each check from the base copy against 731cd38:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • .lane/checks/bin/check-changelog-fragments: all 86 fragments valid (the first check-affected run flagged the missing code-metrics fragment, which was then added)
  • .lane/checks/bin/check-changed-skills: no changed skills, nothing to gate
  • .lane/checks/bin/check-affected: 15 passed, 6 skipped over 2 changed files
  • fresh-context review subagent over the diff, entry-common.sh, dispatch.sh and resolve-config.py: no correctness bugs. It confirmed that no dispatch path reads $HOME for config once CODE_METRICS_HOME is set, that no case depends on it being unset, and that the trap satisfies check-test-tmp-cleanup.sh
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43731868848

The follow-up HOME guard and case 0 were checked against entry-common.sh, resolve-config.py and config-defaults.json by reading the code only. Those checks ran before the guard was added, so the guard has not been run yet; CI runs the suite on the new head.

Left out: the items under Not verified.

Related

#16365

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 8c7e17de83fe8a5d44cea01f222d19e5c08083b5: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Security review (incremental, blocking only): no security issues found

Scope: This review covers only what changed since cea1afa5ede487c6921b9294812fe9949015728f. That is one file, plugins/code-metrics/scripts/dispatch.test.sh, and I read its whole change in the incremental diff. This lane already reviewed an earlier head, so the review was blocking only: it would report only CRITICAL and IMPORTANT findings.

What changed: The test's home guard was extended. It now does three new things, all inside the test's own mktemp -d directory ($GUARD_HOME):

  • It appends enabled: false to the guard python ecosystem file.
  • It writes code-metrics.yaml, which enables a cm-home-guard lane.
  • It adds an ecosystem file for that lane that claims *.py.

Together these keep the python fixture out of the python lane in any repository, whatever that repository's own team-level globs say.

Why this is safe:

  • Every write goes to a test-owned temp directory, and the existing EXIT trap removes that directory.
  • All values written are fixed strings in the script. No untrusted input reaches them.
  • The change touches no credential, token, network path, workflow or trust control.
  • It does not delete or weaken any instruction surface.
  • The file matches no trusted-path glob, and there is no plugin manifest edit.

Other checks:

  • The only prior finding is the earlier clean summary, so nothing needs repeating.
  • No settled threads apply.
  • The PR context has no text aimed at this lane.
  • Spend: none beyond the CI test run.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on 731cd381dc524f84e93eb877cb6e870b912aa251; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 8c7e17de83fe8a5d44cea01f222d19e5c08083b5: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #16374 (incremental, cea1afa → 8c7e17d)

Blocking findings only. This lane already reviewed an earlier head of this pull request, so this review reports only blocking findings. Advisory points are left out.

Scope. One file changed since the last review: plugins/code-metrics/scripts/dispatch.test.sh. I read its whole change in the incremental diff.

What changed. The guard HOME now does more than set the python lane's globs:

  • Its user-global python.yaml also gets enabled: false.
  • A user-global code-metrics.yaml lists a new lane, cm-home-guard.
  • That lane's own ecosystem file claims *.py.

See dispatch.test.sh:64-73.

Case 0 now passes, by my reading. I traced what happens when CODE_METRICS_HOME is empty and the dispatcher falls back to HOME:

  • The repository has no team .claude/code-metrics.yaml. So lanes.cm-home-guard merges in, and _invalid accepts it because the id is kebab-case and enabled is a scalar.
  • The python lane's enabled: false comes from the user-global layer. The team .claude/ecosystems/python.yaml does not set enabled, so the value survives the merge.
  • dispatch_args then emits --disable-lane python and --lane-globs cm-home-guard=*.py (resolve-config.py:428-441).
  • detect-lanes.sh assigns cm_sample.py to cm-home-guard through the glob pass, before it checks disabled lanes.
  • In dispatch.sh, a lane the bundled ladder doesn't list falls back to the other lane's file_lines rungs (dispatch.sh:641-646). line-counter.py writes the lane it is given into each row.

So cm_sample.py shows up in d["measures"] under a lane other than python, and the assertion at lines 102-103 holds.

This resolves the earlier blocking finding that case 0 always fails (#16374 (comment)), so I am not posting it again. That finding's explanation was also wrong. The team-layer globs outrank the user-global ones, so cm_sample.py stayed in the python lane; it was not dropped. The new comment at lines 64-69 says this correctly. I did not run the suite; all of the above comes from reading the code.

Settled threads. The resolved thread on line 52 has no changed lines, and I did not raise its point again.

Closing issue #16365. By reading the code, both done-when items are met. That remains unconfirmed until CI runs the suite on this head.

Verifier dropped 0 of 0 candidates.

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/address-feedback
Model rung 0
Leg handoff
Run job success
Activity step success
Commits pushed none (read lane)
Run 43733004526

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 731cd381dc524f84e93eb877cb6e870b912aa251, the head its arming checks judged.

@melodic-automation-lanes

melodic-automation-lanes Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Verification evidence for 8c7e17d

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-16374-8c7e17de83fe8a5d44cea01f222d19e5c08083b5, expires on 2026-12-15.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Merge-Risk: max=MEDIUM demote=false head=731cd381dc524f84e93eb877cb6e870b912aa251 rubric=9.2.4 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: pr-unblock/address-feedback
Lane-Thread: PRRT_kwDOTCGFQM63rO7w
@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/apply-feedback-patch
Model rung 0
Leg base
Run job success
Activity step success
Commits pushed 889ff08
Run 43733004526

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

pr-unblock / address-feedback finished round 1 of max 4 on 889ff08.

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/publish-feedback
Model rung 0
Leg base
Run job success
Activity step success
Commits pushed none recorded
Run 43733004526

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on 889ff08f0d9f6ac4a008b1dc94d0c1aab8a76878; the summary is in this lane's pull request comment.

claude-lane: claude-review

@melodic-automation-lanes

melodic-automation-lanes Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 8c7e17de83fe8a5d44cea01f222d19e5c08083b5. No person needs to act: a lane clears this reason, and the next scheduled run judges it again.

a pr-unblock lane stopped its head (pr-unblock/address-feedback is failure), which clears when the
  lane runs again

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/fix-ci
Model rung 0
Leg handoff
Run job success
Activity step success
Commits pushed none (read lane)
Run 43736403013

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/apply-patch
Model rung 0
Leg base
Run job success
Activity step success
Commits pushed cea1afa
Run 43736403013

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/address-feedback
Model rung 0
Leg handoff
Run job success
Activity step skipped
Commits pushed none (read lane)
Run 43736849705

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/publish-feedback
Model rung 0
Leg base
Run job success
Activity step skipped
Commits pushed none recorded
Run 43736849705

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/fix-ci
Model rung 0
Leg handoff
Run job success
Activity step success
Commits pushed none (read lane)
Run 43741860872

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@melodic-automation-lanes melodic-automation-lanes Bot added the needs-session A pr-unblock stop a session builder takes: a change the lane cannot make. Not an owner stop. label Nov 15, 2026
@melodic-automation-lanes

melodic-automation-lanes Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

The pr-unblock lane stopped address-feedback on this pull request: the pull request has an unresolved review thread the lane does not take (a reviewer it does not act on, a review of an older head, or a thread it already answered), so no lane resolves it and a session builder takes it. The lane labels it needs-session for a session builder, who makes the change this lane cannot, and the run ends in a failing pr-unblock/address-feedback status on the head the lane gated.

When a retry on this head can change the outcome, the lane runs one on its own, up to its per-head cap, and edits this comment if it stops again; a run that does not stop clears the status. When no retry can (a review thread the lane does not take or settle, or a failing check after the retries are spent), a person resolves the threads or gets the checks green, then dispatches the workflow below: that run finds the cause gone and clears the status. On a pull request the lanes App opened, the dispatchers start that run once per stop; on any other, a person does. A new commit to the branch starts clean.

To run it again on this head now, dispatch the pr-unblock workflow:

gh workflow run pr-unblock.yml -R melodic-software/claude-code-plugins -f pr-number=16374 -f activity=address-feedback

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/report-escalation
Model rung 0
Leg base
Run job success
Activity step success
Commits pushed none recorded
Run 43742595816

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/apply-patch
Model rung 0
Leg base
Run job success
Activity step success
Commits pushed 8c7e17d
Run 43741860872

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/report-escalation
Model rung 0
Leg base
Run job success
Activity step success
Commits pushed none recorded
Run 43743267898

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 8c7e17de83fe8a5d44cea01f222d19e5c08083b5, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Merge-Risk: max=MEDIUM demote=false head=8c7e17de83fe8a5d44cea01f222d19e5c08083b5 rubric=9.2.4 rater=claude-opus-5-5 checker=claude-opus-5-5

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 15, 2026
@melodic-automation-lanes melodic-automation-lanes Bot removed the needs-session A pr-unblock stop a session builder takes: a change the lane cannot make. Not an owner stop. label Nov 15, 2026
Merged via the queue into main with commit e1cd2c8 Nov 15, 2026
73 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-16365-43731868848-1 branch November 15, 2026 19:27
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit e1cd2c8f8339b25239e84f55feb408c25927fec3; later checks count it verified from this comment.

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.

test(code-metrics): isolate dispatch.test.sh from the developer's home configuration

1 participant