Skip to content

refactor(harness-ops): simplify control-claude-code driver and broker without behavior change - #15243

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14556-42941705389-1
Nov 11, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14556

Summary

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

Removed duplicated logic in the control-claude-code driver and broker with no behavior change. In driver.mjs, the npm audit, load probe and signature mark now run through one verifyInstall helper (used for both the repair-line and the fresh install), and a verified() check replaces two copies of the same condition. The holder's close steps are one closeTerminal helper, and runPrint's two child handlers share one settle cleanup. One WHOLE regex replaces three copies of /^[1-9]\d*$/. launch reuses the env from its first buildLaunch call instead of building it a second time, and its wait loop uses the module's sleep. In broker.mjs, the two identical 'driver did not start' paths share one notStarted handler. cli/account.mjs is unchanged: merging its two catch blocks would turn a flag-parse error's exit 2 into exit 1.

Not verified

  • node --test for driver.test.mjs and broker.test.mjs was not run: this lane allows no interpreter. Left to the PR's CI
  • tidy passes 4 and 5 (docs-hygiene and ai-slop) were skipped for the changelog fragment, whose body text the issue's acceptance criteria fix verbatim. Code passes 1 to 3 ran with no edits
  • review-venue.txt was absent, so the review ran as a local fresh-context subagent instead of the CI code-review lane
  • build and lint of the touched .mjs files were not run separately (no interpreter here); check-affected covered what it selects

Fix

  • plugins/harness-ops/skills/control-claude-code/driver/driver.mjs: extracted verifyInstall and verified() in ensureInstalled, closeTerminal in serve (the exit helper inlined into closeAndExit), settle in runPrint, and the WHOLE regex used in three places; launch reuses one buildLaunch env and uses…
  • plugins/harness-ops/skills/control-claude-code/driver/broker.mjs: one notStarted handler replaces the duplicated spawn-failure message in the catch and the child 'error' handler
  • .changes/harness-ops/work-resolve-issue-issue-14556-42941705389-1-58023e35.md: new patch fragment, '### Changed' with 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against be1647d:

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

The run reports:

  • check-changelog-fragments: all 10 fragments valid (run before and after tidy)
  • check-changed-skills: control-claude-code PASS, 0 errors, 3 warnings that were already there (skill name contains 'claude', no 'Use when:' in the description, a #N citation in SKILL.md), none from this change
  • check-affected: 12 passed, 7 skipped over 3 changed files
  • fresh-context subagent review of the full diff, given the code and not this run's conclusion: found no behavior difference; it checked process.env is not mutated between the two former buildLaunch calls, the order of side effects in verifyInstall, closeTerminal and settle, that sleep is defined…
  • grep of the .test. files under plugins/harness-ops: driver.test.mjs and broker.test.mjs import only exported names and run the files as processes; nothing reads their source text, and no export changed
  • tidy-diff over all 22 changed hunks: no edits; no class-A comment and no generated-code residue in the changed lines
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42941705389

Left out: the items under Not verified.

Related

#14556

Merge-Risk: max=MEDIUM demote=false head=be1647d210edf89a2185a615b06ac605931a4106 rubric=8.4.1 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-review reviewed be1647d210edf89a2185a615b06ac605931a4106: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15243 (complete, 3 of 3 files read)

No findings. Every hunk is a pure refactor, and each one does exactly what the original code did. I checked this by reading the code at head. I did not run any tests, because this lane has no interpreter.

What I checked

  • broker.mjs, notStarted: It sends the same stderr text and calls finish(1). The catch branch now returns undefined where it used to return finish(1)'s value. That return value comes from inside the conn.on('data') callback, and nothing reads it, so behavior is the same.
  • driver.mjs, verifyInstall and verified(): The audit, load probe and SIGNED write run in the same order, against the same directory and with the same repair line, in both the repair path and the fresh-install path. On the fresh-install path, a Broken thrown inside try still reaches the same catch, which removes partial and rechecks for a concurrent install. verified() evaluates the condition each time it is called, not once, so its recheck in the catch behaves as before.
  • serve, closeTerminal and the inlined exit: exit had no other callers; my search found only the two removed uses. ctx and terminal are both defined before closeTerminal, and ctx.recording is still read when the function is called, not when it is defined. The stop verb and closeAndExit run the same close, then free, then exit steps.
  • launch, reusing one buildLaunch env: buildLaunch copies env ({ ...env }). The only code that changes process.env is in serve (driver.mjs L920, L927), which runs in the holder process, not in launch. Nothing between the first buildLaunch call and spawn (reserve, request, ensureInstalled, endpoint) writes to process.env, and config is built once. So the env passed to spawn is the same as before.
  • sleep: It is a module-level const (driver.mjs L775) and does the same thing as the inline Promise it replaces.
  • WHOLE: It is a module-level regex with no g flag, so reusing it across .test() calls carries no lastIndex state between calls. It matches the three literals it replaces.
  • runPrint, settle: It clears both timers and calls closeOut() in the same order before fail and done. deadline and killTimer are both in scope where it is defined.
  • doctor font line: The printed text is unchanged.

Closing issue #14556, acceptance criteria

  • Behavior unchanged: met, as checked above. No exported names, flags or messages changed.
  • Only listed files plus fragments edited: met. The diff changes broker.mjs, driver.mjs and one fragment; cli/account.mjs is untouched, and the PR body explains why.
  • Under 400 lines and 15 files: met.
  • ci-status green: CI decides this; this lane cannot check it.
  • Fragment bump: patch with body ### Changed / "Internal simplification, no behavior change.": met.

No plugin manifest changed. The PR context contains no embedded instructions directed at this lane.

@github-actions

Copy link
Copy Markdown
Contributor

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

Security review: PR #15243 (complete, all 3 changed files read)

I found no security issues.

This is a pure refactor of the control-claude-code driver and launch broker in the harness-ops plugin. None of the 3 changed files matches a trusted-path glob, and no plugin manifest, userConfig key, workflow, trust control or merge hold is touched. I checked the parts that could matter for security:

  • Install verification (driver.mjs verifyInstall). The new helper runs the same steps as the two inline copies it replaces, in the same order. It runs npm audit signatures, then the load probe, and writes the SIGNED marker last. Both callers still throw Broken before the marker is written. On the fresh-install path the helper runs before renameSync(partial, target), as before. verified() is the same hasEngine && existsSync(SIGNED) condition at both call sites. Signature verification is not weakened.
  • Credential env reuse (driver.mjs launch). launch now spawns the holder with the env from its first buildLaunch call instead of calling it a second time. buildLaunch at driver.mjs#L155-L172 returns a fresh copy ({ ...env, ... }) with the credential scrub already applied. Nothing between the two former calls (reserve, request, ensureInstalled, endpoint) assigns to process.env. The only process.env mutations, at L920 and L927, are in serve, which runs in the holder process. So the scrubbed credential set the holder gets is unchanged.
  • Broker (broker.mjs notStarted). It sends the same stderr message and the same finish(1) for both the synchronous spawn failure and the child error event. childEnv(process.env, key) and the spawn arguments are unchanged.
  • Other changes. closeTerminal, settle and sleep (defined at L775) are behavior-equivalent cleanups. WHOLE is the same regex (/^[1-9]\d*$/) and is still applied to --ttl and --timeout.
  • Changelog fragment. Text only; nothing runs from it.

The PR context file contains no embedded instructions directed at this lane.

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for be1647d

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-15243-be1647d210edf89a2185a615b06ac605931a4106, expires on 2026-12-11.

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 11, 2026
Merged via the queue into main with commit 71e9844 Nov 11, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14556-42941705389-1 branch November 11, 2026 03:11
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 71e9844d03c36090d8cdbccffc7bc1557596d6d4; 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 control-claude-code harness-ops plugin code

0 participants