Skip to content

refactor(discovery): simplify source-applicability primary count and research-sweep request filtering - #14540

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14445-42595474731-1
Nov 9, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14445-42595474731-1

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14445

Summary

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

I ran /simplify's four checks on the four listed discovery files and kept only the edits a read of the code shows change no output, exit code, message or order. check-source-applicability.py now counts primary sources once with sum(...) instead of building a role list and calling count() twice. research-sweep.js now normalizes each requested URL once before filtering instead of three times, and the skeptic tally filters votes directly instead of mapping through panel and filtering again. turns-to-complete.py and setup-apply.mjs are unchanged. setup-apply.mjs is a 23-line call into a shared library and has nothing to simplify. The one turns-to-complete.py edit was reverted after review (see not_done).

Not verified

  • Running the discovery test suites directly (research-sweep.test.mjs, check-source-applicability.test.sh, turns-to-complete.test.sh): this lane only allows the named wrappers, so no node or python runs here. I could not confirm whether check-affected's 13 passing checks include them. Left to the…
  • Tidy (code-tidying:tidy-diff) ran passes 1 to 4 in full, but pass 5 (ai-slop) got only a rubric read: detect.sh and digest-guard.sh are not wrappers this lane may run. The rubric found nothing on the fragment's one line. Pass 3 left one proposal: the 'v !== undefined' guard in research-sweep.js…
  • Reverted simplification: turns-to-complete.py's root-readability probe list(os.scandir(root)) reads every entry only to test access. os.scandir(root).close() would avoid that, but it no longer catches a read error that shows up only while listing, which would turn exit 2 into a silent exit 0, so it…
  • ci-status green is checked on the PR, not in this run.
  • The working tree holds untracked dotfiles this run did not create (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc). Left untouched and not part of this change.

Fix

  • plugins/discovery/scripts/check-source-applicability.py: R5's primary-source count is computed once with sum(role == 'primary') and reused in the violation message, so the throwaway roles list and second count() call are gone.
  • plugins/discovery/workflows/research-sweep.js: judged() maps each request to {url: pageOf(url.trim()), sections: idsOf(...)} once, then filters on rawable and allowed and caps it. This replaces three pageOf(q.url.trim()) calls per request and keeps the same items in the same order. The tally…
  • .changes/discovery/work-resolve-issue-issue-14445-42595474731-1-b6b49f88.md: new discovery patch fragment, '### Changed' with 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 5bfd3f4:

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

The run reports:

  • check-changelog-fragments: all 4 fragments under .changes/ valid (run before and after tidy)
  • check-changed-skills: no changed skills under plugins/*/skills/, nothing to gate (run before and after tidy)
  • check-affected: 13 passed, 6 skipped (shellcheck: no changed shell; typos: not installed; three validate-plugins checks that run code from the checked tree; changed-skills: no skill file), run again after the final edit
  • fresh-context review subagent over the whole diff: check-source-applicability.py and judged() equivalent; turns-to-complete.py os.scandir(root).close() differs from list(os.scandir(root)) when a directory opens but listing it fails (EIO, ESTALE), so that edit was reverted; tally edit differs only…
  • plugins/discovery/tests/research-sweep.test.mjs read: its banned-call check (Date.now(, Math.random(, new Date()) still holds; no test asserts on the edited lines
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42595474731

Left out: the items under Not verified.

Related

#14445

Merge-Risk: max=MEDIUM demote=false head=5bfd3f426e1a09226568986b38401e0be7583e42 rubric=8.1.4 rater=claude-opus-5-5 checker=claude-opus-5-5

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

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed 5bfd3f426e1a09226568986b38401e0be7583e42: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #14540, no findings

I read every hunk of all 3 changed files. Each of the two edits behaves exactly as the code it replaces.

  • plugins/discovery/scripts/check-source-applicability.py: sum(s.get("role") == "primary" for s in claim["sources"]) gives the same integer as roles.count("primary"), and the violation message prints the same value. The edit adds no new way for the code to raise.
  • plugins/discovery/workflows/research-sweep.js judged(): the map that was moved maps one item to one item. rawable and allowed still get the same pageOf(q.url.trim()) value, once per request. The REQUEST_CAP slice still runs after those filters and before the slices.has filter, so the output keeps the same items in the same order. idsOf now also runs on requests that are filtered out afterwards, but it is pure and cannot throw (research-sweep.js#L258), so nothing visible changes. The existing tests already send requests through this path: a URL with a fragment and an http: URL that must be dropped (research-sweep.test.mjs#L335-L337).
  • Tally: votes comes from inWaves over thunks built from panel, one result per thunk (research-sweep.js#L147-L153). So votes[i] and panel[i] line up, and votes.filter((v, i) => panel[i].c === c && v !== undefined) selects the same votes in the same order as before.

Closing issue #14445 acceptance criteria

  • Behavior unchanged: met. I checked this by reading the code; I did not run anything.
  • Only listed files plus a fragment edited: met (2 listed files and 1 fragment).
  • Within 400 lines and 15 files: met.
  • Discovery fragment with bump: patch, ### Changed and "Internal simplification, no behavior change.": met.
  • ci-status green: not checkable from this lane. The PR says it was not checked in the run, so it is unverified.

The test-suite runs mentioned in the PR body (check-affected 13 passed, fragment and skill checks) are the author's claims and I did not verify them. I found no embedded directives in the PR context. No manifest files changed. No paved-path or .claude/rules criteria applied.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 5bfd3f426e1a09226568986b38401e0be7583e42: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14540

I found no security issues in this change.

I read the whole diff for all 3 changed files. None of them is on a trusted path, and the change doesn't touch any trust control, merge hold, plugin manifest or standing instruction.

  • plugins/discovery/workflows/research-sweep.js, judged(): this is the only change that touches a security boundary: the SSRF guard on reader-requested URLs (rawable, which checks isPublicUrl, an https-only scheme and no quote or backslash characters, plus allowed). I checked that the reorder keeps that guard intact:
    • The checks now run on pageOf(q.url.trim()), which is the same value later handed to fetchOne. Before this change, the check and the fetch also used the same normalized value. So the URL that is checked is still the URL that is fetched.
    • .slice(0, REQUEST_CAP) still runs after the filter, so the cap behaves the same.
    • idsOf, now called on items before the filter, can't throw: it only does array and integer checks (research-sweep.js#L258).
    • The tally rewrite gives the same result as before (it keeps the votes at indexes whose panel entry matches and drops undefined).
  • plugins/discovery/scripts/check-source-applicability.py: the primary-source count now uses sum(...) and gives the same result as before. It isn't a security surface.
  • .changes/discovery/…md: a changelog fragment only.

There was no embedded text in the PR description or the closing-issue context that told the lane to pass the PR, skip a check, drop a finding or post elsewhere. The issue body was left out by the wrapper because its author isn't on the allowed list.

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 5bfd3f4

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-14540-5bfd3f426e1a09226568986b38401e0be7583e42, expires on 2026-12-09.

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

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit e4dfac1 Nov 9, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14445-42595474731-1 branch November 9, 2026 11:05
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 6, survived 1, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 86%; mutation score 86%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/discovery/scripts/check-source-applicability.py 3 0 0 0 0 0
plugins/discovery/workflows/research-sweep.js 3 1 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/discovery/workflows/research-sweep.js:353 SBR productive input-gap

The run's summary has the full report.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit e4dfac1be6d0423d54d423adedba24edffa2420c; 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.

Simplify the scripts, setup and workflows discovery plugin code

0 participants