Skip to content

refactor(multi-agent): simplify hook, resolver, route, setup and drift-audit code - #15027

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14661-42778848773-1
Nov 10, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14661

Summary

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

Simplified six of the nine listed multi-agent files with no change to outputs, exit codes, printed text, flags or exported names. The cuts are a shared VAL/SRC lookup in resolve-roles.sh, one workload-override lookup instead of two, optional chaining in the fetch gate, one plugin-root path in list-pointers.sh, one temp file instead of two duplicates in setup.sh, and skeptic labels built once in drift-audit.js. check-hook-registration.sh, workflow-availability.sh and list-targets.sh were reviewed and left as they are: nothing in them simplified without changing behavior or adding churn. A fresh-context review found two edge-case behavior changes in the first draft (list-pointers.sh path resolution through a symlinked skill dir, and the workload-name check merge in resolve-roles.sh), and both were reverted to the original semantics.

Not verified

  • The multi-agent test suites (tests/drift-audit.test.mjs, hooks/drift-checker-fetch-gate.test.mjs, skills/audit-defaults/scripts/list-scripts.test.sh and the resolver tests) were not run directly: this lane runs only its named wrappers. They are left to the PR's CI.
  • shellcheck and the node syntax check on the changed files were not run directly beyond what check-affected selected; left to the PR's CI.
  • ci-status green is a PR CI check; left to the PR's CI.
  • Tidy passes 4 and 5 (docs-hygiene and ai-slop) skipped: the only markdown is the changelog fragment, whose wording the issue fixes exactly.
  • Untracked runner dotfiles in the checkout root (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) are not part of this change and were left out of the tidy measurement.

Fix

  • plugins/multi-agent/hooks/drift-checker-fetch-gate.mjs: optional chaining in place of && guards, agent check inlined, deny message built with a template literal (same string).
  • plugins/multi-agent/scripts/resolve-roles.sh: val and src share one kv_get lookup; role_json reads each workload override once instead of twice.
  • plugins/multi-agent/skills/audit-defaults/scripts/list-pointers.sh: one PLUGIN_DIR (resolved the same way as the old SCRIPT_DIR plus ../../..) instead of three repeated ../../.. paths and a RESOLVER variable.
  • plugins/multi-agent/skills/route/scripts/route.sh: bare-argument counting folded into one ((++bare == 2)) branch.
  • plugins/multi-agent/skills/setup/scripts/setup.sh: dropped the duplicate $tmp/body copy of $tmp/new; legacy_md's symlink refusal folded into the condition that already tests it.
  • plugins/multi-agent/workflows/drift-audit.js: each skeptic panel entry carries its label (it was rebuilt in three places); repoUnit names its read label once; the alias list is hoisted out of validProposed; dedup and the upheld-majority branch restructured without changing their order of outcomes.
  • .changes/multi-agent/work-resolve-issue-issue-14661-42778848773-1-09e4747b.md: patch fragment, ### Changed, 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 6c43d58:

  • 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 after the final edit).
  • check-changed-skills: 3 skills checked, 0 failed; the warnings on description length and setup's missing 'Use when:' were already there and are unrelated to this diff (run after the final edit).
  • check-affected: 13 passed, 6 skipped over 7 changed files (run after the final edit).
  • Fresh-context review subagent over the whole diff: found 2 edge-case behavior differences (list-pointers.sh symlinked-path resolution; resolve-roles.sh w reset changing a role named 'workloads'). Both were fixed by restoring the original semantics, and nothing else differs on the inputs it checked.
  • Grep of plugins/multi-agent tests for source-text assertions: drift-audit.test.mjs reads the source only for banned calls, agent names and 'isolation', none of which changed.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42778848773

Left out: the items under Not verified.

Related

#14661

Merge-Risk: max=MEDIUM demote=false head=6c43d5856f946f87e321d706fcd09fecd0113f09 rubric=8.3.3 rater=claude-opus-5-5 checker=claude-opus-5-5

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

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 6c43d5856f946f87e321d706fcd09fecd0113f09: read 7 of 7 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15027 (multi-agent refactor)

No security issues found. I read every hunk of all 7 changed files. None of them matches a trusted path, none is a plugin manifest, and no standing instruction is removed or weakened.

What I checked

  • plugins/multi-agent/hooks/drift-checker-fetch-gate.mjs (the PreToolUse guard that limits drift-checker to WebFetch on first-party docs hosts): payload?.agent_type and payload.tool_input?.url work the same as the old && guards. A null or undefined payload still fails the agent regex and returns null, as it did before. The checks for tool name, URL parsing, userinfo, query string and the FETCH_HOSTS allowlist are unchanged. The template-literal deny message builds the same string. The fetch allowlist is no wider.
  • plugins/multi-agent/skills/setup/scripts/setup.sh:
    • Moving refuse_symlink "$legacy_md" into the if condition keeps the symlink refusal. refuse_symlink calls die, which runs exit 2 (setup.sh#L42-L44, L150-L154). Because it exits rather than returning, a symlinked legacy file still stops the script and never falls through to the elif.
    • The single $tmp/new file lives inside the same mktemp -d directory, which is still removed by the EXIT trap. Nothing writes to it between creation and the copy over the target.
  • plugins/multi-agent/scripts/resolve-roles.sh: kv_get is called only with the literals VAL and SRC, so the indirect variable name cannot be controlled from outside. The workload-override lookup assigns the same values as before.
  • plugins/multi-agent/workflows/drift-audit.js: validProposed checks the same grammar as before. Hoisting ALIASES is safe because MODELS is defined earlier, at line 200. Dedup, labels and the majority branching keep their outcomes, so model text still cannot slip extra lines into the diff or switch off the fan-out guard.
  • route.sh and list-pointers.sh: these only refactor argument counting (bare starts at 0, line 11) and paths (the same ../../.. plugin root). No new place reads input.

Embedded text: none in the PR context.

Spend: none.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 6c43d5856f946f87e321d706fcd09fecd0113f09: read 7 of 7 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15027, a simplification refactor of multi-agent code

I read all 7 changed files, every hunk. No findings. None of the changed files is on the trusted-path list.

I checked each rewrite for behaviour changes, reading the unchanged code that each edit calls:

  • drift-checker-fetch-gate.mjs
    • payload?.agent_type || '' and payload.tool_input?.url || '' give the same strings as the old && guards. That includes falsy non-null inputs: 0, '' and false all end up as '' either way.
    • The template literal builds exactly the same deny message.
  • resolve-roles.sh
    • In kv_get, "$1_$(kv_name …)" expands to ${1}_…, because a positional parameter takes only one digit. So val and src still read VAL_* and SRC_*.
    • The [[ -z "$v" ]] || … form assigns the same values as the old if blocks, and it returns status 0 when the override is empty.
  • list-pointers.sh
    • Nothing in the file still uses SCRIPT_DIR or RESOLVER, so set -u cannot trip on them.
    • PLUGIN_DIR builds the same …/../../.. path. If the cd fails, the fallback path (/../../..) is also the same as before.
  • route.sh
    • bare=0 is set at line 11, so ((++bare == 2)) matches the old increment-then-compare.
    • The check sits inside an if, so its exit status 1 cannot end the script.
  • setup.sh
    • refuse_symlink either calls die (exit 2) or returns 0. So moving it into the if condition keeps the same outcomes: a symlink still exits 2, and a regular file goes on to the awk check.
    • Nothing reads $tmp/body any more. $tmp/new is not changed between the write at line 241 and the frontier_guard grep at line 254.
  • drift-audit.js
    • MODELS is a top-level const (line 200) defined before ALIASES (line 583) and is never mutated, so hoisting ALIASES is safe.
    • No code reads panel[].n any more: the votes loop at line 702 reads only p.b. The skeptic labels are the same strings as before.
    • The dedup branch and the upheld-majority branch give the same outcomes in the same order.

Closing issue #14661, acceptance criteria:

  • Behaviour unchanged: I found no difference, from reading the code.
  • Only listed files plus a fragment: met.
  • Under 400 lines and 15 files: met.
  • Fragment (bump: patch, ### Changed, "Internal simplification, no behavior change."): met.
  • ci-status green: I can't see CI from this lane.

The author's verification (check-changelog-fragments, check-changed-skills, check-affected) is the author's claim; I didn't run it. I ran no tests or linters myself.

No plugin manifest changed. There are no prior findings and no settled threads. I found no embedded instructions in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 6c43d58

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-15027-6c43d5856f946f87e321d706fcd09fecd0113f09, expires on 2026-12-10.

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 10, 2026
Merged via the queue into main with commit 9cf6116 Nov 10, 2026
65 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14661-42778848773-1 branch November 10, 2026 09:04
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 hooks, scripts, assess and 4 more multi-agent plugin code

0 participants