Skip to content

fix: Simplify the hop_chain.py session-flow plugin code (part 2 of 2) - #15303

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14741

Summary

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

Simplified the second half of plugins/session-flow/scripts/harness/hop_chain.py (functions that start at or after line 1079 of the 2157-line file) without changing behavior: 74 lines added, 149 removed. The dry-run fake runner repeated the same record-and-tool_use scaffolding many times; a module-level _tool_use builder and local step/write_block/skill_block helpers replace it. Two other duplicates were folded into helpers: cleanup verification (_cleanup_problem) and work-dir creation (make_work_dir). cmd_dry_run's two pass/fail loops are now one, and cleanup uses contextlib.suppress. Design choices: all helpers sit in the part-2 range, nothing moved between files, and every output string, record order and CLI flag is unchanged.

Not verified

  • plugins/session-flow/scripts/harness/hop_chain.test.sh (runs hop_chain.py --dry-run and --budget) and the session-flow pytest suite were not executed: this lane runs no interpreter. Left to the PR's CI.
  • ruff lint/format was not run directly on hop_chain.py: no interpreter or linter runs in this lane. check-affected passed, and CI's lint covers the rest.
  • tidy passes 4-5 (docs-hygiene and ai-slop) were skipped for the changelog fragment because the issue fixes its body text verbatim; tidy is recorded as skipped for that reason.
  • 'ci-status is green' is a PR check, left to the PR's CI.

Fix

  • plugins/session-flow/scripts/harness/hop_chain.py: in range 2 only. Added the _tool_use builder and local step/write_block/skill_block helpers in make_fake_runner. Added make_work_dir, shared by cmd_budget and main, and _cleanup_problem, shared by _run_case and check_main_level_orchestration.…
  • .changes/session-flow/work-resolve-issue-issue-14741-42976888758-1-38f81695.md: new patch fragment, body '### Changed' plus '- Internal simplification, no behavior change.'

Verification

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

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

The run reports:

  • check-changelog-fragments: all 20 fragments valid (run before and after tidy)
  • check-changed-skills: no changed skills, nothing to gate (run before and after tidy)
  • check-affected: 13 passed, 6 skipped, the rest CI-only, over 2 changed files (run before and after tidy)
  • fresh-context review subagent over the whole diff: no correctness findings. It confirmed record order and shape in the fake runner, lambda default-arg binding in cmd_dry_run, that every imported module-level name is still defined, and Python 3.10 compatibility. I checked its one open point (literal…
  • code-tidying:tidy-diff over the 22 changed hunks: no edits needed (simplify, comment and residue passes found nothing)
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42976888758

Left out: the items under Not verified.

Related

#14741

Merge-Risk: unrated reason=pending

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

Copy link
Copy Markdown
Contributor

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

Security review: no security issues found

I read every hunk of both changed files:

  • plugins/session-flow/scripts/harness/hop_chain.py: a behavior-preserving refactor of the dry-run and budget test harness. It adds four helpers: _tool_use, make_work_dir, _cleanup_problem, and step/write_block/skill_block inside the fake runner. It also merges cmd_dry_run's two pass/fail loops into one and replaces a try/except OSError: pass with contextlib.suppress(OSError).
    • Temp dirs: make_work_dir still uses tempfile.mkdtemp with the same prefixes, and it honours --work-dir exactly as before.
    • Cleanup: _cleanup_problem runs the same checks as the inline code it replaces. Cleanup still deletes only the harness's own session ids, and the decoy checks still run.
    • The only change in behavior: check_main_level_orchestration now skips empty session ids, as _run_case already did. It does nothing to what the harness deletes or trusts.
    • No new input reaches a shell, path, or network sink. Credentials, tokens and the child env allowlist are untouched; check_child_env is still run.
  • .changes/session-flow/...38f81695.md: a new patch changelog fragment, prose only.

Other checks:

  • No file in the diff matches a trusted path.
  • The diff touches no trust control, merge hold, plugin manifest, or standing instruction.
  • No embedded instructions in the PR context.
  • This is the first review of this pull request (blocking only: no), and there were no prior findings.
  • Nothing here spends credits or can cause a charge.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read both changed files in full: plugins/session-flow/scripts/harness/hop_chain.py and the new changelog fragment. I also read the unchanged code the changed lines call (transcript_paths, _record, cmd_budget, check_child_env, the imports).

How I checked "behavior unchanged" (refactor equivalence):

  • dict.fromkeys(CHECKS, "FAIL") gives the same result as the comprehension it replaces. Each row gets its own new dict, as before.
  • contextlib.suppress(OSError) works the same as the old try/except OSError: pass. contextlib is already imported at line 32.
  • make_work_dir keeps both callers' prefixes as they were (hop-chain-budget- and hop-chain-), and still calls mkdir(parents=True, exist_ok=True).
  • In make_fake_runner, step / _tool_use / write_block / skill_block produce the same records in the same order as before. The Write block comes before the Skill block in the same-record case. Each _record call gets a new list (list(blocks)), and the ids, names and inputs match the removed literals.
  • _cleanup_problem returns the same messages, and its checks run in the same order. In check_main_level_orchestration it adds an if session_id guard that the old loop lacked. With an empty id, the old glob was projects/*/.jsonl, which looks for a file named exactly .jsonl that nothing creates, so the guard doesn't change the result. return not problem, problem returns (True, "") on success, as before.
  • cmd_dry_run: the lambda c=case: default argument binds each case, and each check still runs and prints inside the loop. That keeps the PASS/FAIL output order, the failure count and how exceptions propagate. total still counts len(DRY_RUN_CASES) + 3.

Closing issue #14741 acceptance criteria:

  • Behavior unchanged: met, per the checks above. hop_chain.test.sh runs --dry-run and --budget, which go through every refactored path, so it would fail if this broke. Neither I nor the author ran it; the PR leaves it to CI.
  • Only the listed file plus a fragment: met.
  • Within 400 lines: met (about 74 added, 149 removed, plus a 7-line fragment).
  • Fragment: met (bump: patch, ### Changed, "Internal simplification, no behavior change.").
  • Only functions starting in range 2 changed: met. Range 2 starts at line 1079, and the first hunk is at line 1142. The new helpers sit inside that range.
  • ci-status green: a PR check, not something this review can judge.

No path-scoped rule, plugin manifest or trusted path is touched. I found no embedded instructions in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

pr-merge's gate refuses its verifier verdict (verify:missing)

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@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 4817e0c Nov 11, 2026
78 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14741-42976888758-1 branch November 11, 2026 08:29
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 2, survived 5, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 29%; mutation score 29%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/session-flow/scripts/harness/hop_chain.py 2 5 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/session-flow/scripts/harness/hop_chain.py:1145 other productive no-assertion
plugins/session-flow/scripts/harness/hop_chain.py:1490 other equivalent none
plugins/session-flow/scripts/harness/hop_chain.py:1791 LCR equivalent none
plugins/session-flow/scripts/harness/hop_chain.py:1925 other productive input-gap
plugins/session-flow/scripts/harness/hop_chain.py:1932 other productive no-assertion

The run's summary has the full report.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 4817e0c5ac1191441358a7a4461ca34feb9a33d1; 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 hop_chain.py session-flow plugin code (part 2 of 2)

0 participants