Skip to content

refactor(session-flow): simplify resume_eval.py - #15156

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14745

Summary

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

Simplified plugins/session-flow/scripts/harness/resume_eval.py without changing its outputs, written files, exit codes, flags or exported names. The changes: moved repeated local imports (shutil, subprocess, a redundant pathlib.Path) to the module top; added a shared _result_event helper (used three times) and a _lead_prompt helper (used three times, in write_stage and read_stage); merged write_stage's two duplicated hop endings (effects write, _write_hop, token sum, note) into one; made a new scripted-hop session reuse append_turns over an empty transcript (the same bytes as the old direct write); made model_usage_total table-driven; inserted _claude's extra flags in one slice assignment; and computed check_matches pools only for the requested kind. Design choice: I kept every function in this file, because moving code between files is out of scope per the issue.

Not verified

  • pytest suites test_resume_eval.py and test_resume_cases.py (via resume_eval.test.sh) were not run: this lane allows no interpreter or test runner, so they are left to the PR's CI
  • Python lint (ruff or similar) on resume_eval.py was not run: no linter wrapper is available in this lane, so it is left to the PR's CI
  • One intended difference shows only on malformed input: check_matches now evaluates only the selected pool, so malformed events can no longer raise AttributeError from an unrelated pool. Well-formed inputs behave the same.
  • tidy pass 5: the ai-slop deterministic detector (detect.sh) did not run, because this lane's Bash runs only the named wrappers. The rubric read was done by hand. The fragment is untracked, so no findings file applies.
  • ci-status green is checked by the PR's CI, not this run

Fix

  • plugins/session-flow/scripts/harness/resume_eval.py: hoisted local imports, added the _result_event and _lead_prompt helpers, merged the duplicated hop tail in write_stage, made model_usage_total table-driven, simplified flag insertion in _claude and the writer_tokens build in _write_hop, made the…
  • .changes/session-flow/work-resolve-issue-issue-14745-42883439803-1-03109022.md: new patch fragment, ### Changed / - Internal simplification, no behavior change.

Verification

The runner ran each check from the base copy against 8e40b55:

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

The run reports:

  • check-changelog-fragments: all 6 fragments valid (run before and after tidy and the review fixes)
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 13 passed, 6 skipped over 2 changed files (final tree)
  • fresh-context review subagent over the whole diff: found no behavior change on any non-error path, no undefined names and no syntax errors. It flagged two error-path differences: an empty transcript left behind when the lead lookup raises, and an earlier read of hop['hop'] on live hops. I fixed…
  • tidy-diff: pass 1 (simplify) no further edits; pass 2 (comments) no comment in the listed lines; pass 3 (generated-code residue) none found; pass 4 (write-for-humans on the fragment) no change, since its line is required word for word; pass 5 (ai-slop rubric read of the fragment) no tells
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42883439803

Left out: the items under Not verified.

Related

#14745

Merge-Risk: max=MEDIUM demote=false head=8e40b55fac571fed2f78f747da0b71790875600c rubric=8.3.5 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 8e40b55fac571fed2f78f747da0b71790875600c: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15156 (refactor(session-flow): simplify resume_eval.py)

No security issues found.

critical-findings: 0

I read every hunk of both changed files:

  • .changes/session-flow/work-resolve-issue-issue-14745-42883439803-1-03109022.md is a new changelog fragment with prose only.
  • plugins/session-flow/scripts/harness/resume_eval.py is the local eval harness. The change is a refactor with no new trust boundary. What I checked:
    • Imports: the function-local shutil, subprocess and pathlib.Path imports moved to module top level (Path is imported at line 25). main now uses the module-level HERE (line 27, Path(__file__).resolve().parent), which has the same value as the removed local here. The default --evals-dir and --repo-root paths do not change.
    • Cleanup path in run_once: the rmtree target cache = home / ".cache" / "claude-cli-nodejs" / run["keydir"].name uses home, which line 1366 already defines with the same expression the old code inlined (Path(run["env"].get("HOME", str(Path.home())))). The deletion target is unchanged.
    • _claude flag insertion: cmd[-1:-1] = [...] puts --fork-session and extra in the same positions and order as the old insert(-1, …) loop. No input reaches the command that did not reach it before.
    • Scripted-hop transcript write: write_stage now creates an empty <session>.jsonl and calls append_turns, where it used to write render_history output directly. It writes in the same run["keydir"] with a session name from uuid4, so no path comes from case input.
    • Pure refactors: check_matches now builds only the selected pool (lazy callables), and the _result_event, _lead_prompt and table-driven model_usage_total helpers are refactors. None of them touches credentials, network, or command construction.

No trusted-path globs match, no plugin manifest changed, and no standing instruction was deleted or narrowed. The PR context has no embedded directives aimed at this lane.

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: refactor(session-flow): simplify resume_eval.py (#15156)

No findings. I read both changed files in full. I checked each change against the code at head and found no behavior change on any path that well-formed input takes.

What I checked in plugins/session-flow/scripts/harness/resume_eval.py:

  • Hoisted imports (shutil, subprocess, local Path): Path is already imported at module level (L25). HERE (L27) is the same value as the removed here in main.
  • _result_event: model_usage_total now uses (_result_event(events) or {}), which matches the old next(..., {}) default.
  • _claude flag insertion: cmd[-1:-1] = [fork?, *extra] keeps the same order as the old repeated insert(-1, ...) calls. Each insert went in just before the last element, so the order was already preserved.
  • check_matches pools: each pool is now evaluated only when its kind is selected. Results are the same for valid kinds. The PR body already notes the one difference, on malformed events only.
  • write_stage merge:
    • A new scripted-hop session now goes through append_turns over an empty file. With no prior uuid, parent=None, and render_history's default is None (L381). The {repo} replacement and the "\n".join(...) + "\n" write are the same as before, so the bytes match.
    • The shared tail (effects write, _write_hop, token sum, note) is identical for both branches.
    • The live branch's logic is unchanged.
  • _lead_prompt: in read_stage the old code read delivery.get("lead") from the same case["reader"]["delivery"][arm_base(arm)] dict (L1050). The output is the same.
  • _write_hop writer_tokens: inlining it produces the same values on the compact path. The removed tokens/out_path initializers were only used on that path, or not at all.
  • run_once cache path: it now reuses home (L1366), which is the same expression the old code repeated.

Against closing issue #14745's acceptance criteria:

  • Behavior unchanged: met, as above. A behavior-preserving refactor is covered by the existing test_resume_eval.py / test_resume_cases.py suites. The author says those suites weren't run in the authoring lane and are left to CI; I didn't verify that.
  • Only listed files plus a fragment: met.
  • Within 400 lines and 15 files: met.
  • Fragment: met. .changes/session-flow/...md has bump: patch, ### Changed and the required line word for word.
  • ci-status green: CI checks this; this lane can't confirm it.

No plugin manifest changed, and no path-scoped rule or paved-path item applied. Both changed files are outside the trusted-path globs. The PR context has no embedded instructions.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 8e40b55

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-15156-8e40b55fac571fed2f78f747da0b71790875600c, 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 86b8a9f Nov 10, 2026
64 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14745-42883439803-1 branch November 10, 2026 20:05
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 86b8a9ffd12eb10433bac7383775b2b6f3e43d9d; 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 resume_eval.py session-flow plugin code

0 participants