Skip to content

refactor(session-flow): simplify save_point.py validate, emit and fill helpers (part 2 of 3) - #15351

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14732

Summary

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

Simplified the functions that start in range 2 of 3 of plugins/session-flow/scripts/save_point.py (lines 1333-2665 of the 3997-line file on main), with no behavior change. cmd_fill now parses the bytes it already read instead of reading the file a second time through parse_doc. cmd_emit reads the file size only when a FAIL verdict needs it, since an UNVALIDATED verdict is always under the Read cap. _print_verdict is a flat if/elif chain. _next_id tests the predecessor's shape once. The one-call _amendment_units wrapper is inlined into its only caller, _entry_units. _apply_retire computes the hop-file name once, outside its loop. Choice basis: each edit was checked against the callers and helpers it relies on, and a fresh-context review found every hunk identical for every input.

Not verified

  • The session-flow Python test suite (plugins/session-flow/scripts/tests/test_save_point.py) and a Python lint were not run, because this lane's Bash runs only the named wrappers. Both are left to the PR's CI.
  • ai-slop detect.sh was not run on the changelog fragment because the lane's Bash allows only the named wrappers. Only the rubric read ran on that file.
  • ci-status green is an acceptance item the PR's CI settles.
  • The working tree shows untracked runner-environment files (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc). This run did not create them, and they are not part of this change.

Fix

  • plugins/session-flow/scripts/save_point.py: in range-2 functions only. _next_id tests the predecessor's shape once. The _amendment_units wrapper is inlined into _entry_units. _print_verdict's label is an if/elif chain. cmd_emit skips the size read unless a FAIL verdict needs it. _apply_retire…
  • .changes/session-flow/work-resolve-issue-issue-14732-43011748134-1-076c2b97.md: new patch fragment, made with new-changelog-fragment session-flow patch, whose body is '### Changed' and '- Internal simplification, no behavior change.'

Verification

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

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

The run reports:

  • check-changelog-fragments: all 11 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 (run before and after tidy)
  • Range check: every changed function (_next_id, _entry_units, _print_verdict, cmd_emit, _apply_retire, cmd_fill) and the removed _amendment_units start between lines 1333 and 2665 of the 3997-line file, which is range 2 of 3
  • Repo-wide grep: _amendment_units has no other reference, and the only test reference to a changed-region function (sp._size_finding) keeps its signature
  • Fresh-context review subagent over the whole diff: every hunk is behavior-identical. It confirmed _size_finding's ordering guarantees UNVALIDATED implies size <= READ_CAP_BYTES, so cmd_emit's message choice is unchanged, and that _text_lines(bytes.decode('utf-8')) equals parse_doc's read_text…
  • tidy-diff over 11 hunk rows: no edits. Pass 1 (simplify) and pass 3 (residue) found nothing more. Pass 2 kept the new cmd_emit comment because it states an invariant the code cannot show. Pass 4 (write-for-humans) and pass 5 (ai-slop rubric read) found nothing in the mandated fragment text
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43011748134

Left out: the items under Not verified.

Related

#14732

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

Security review: PR #15351 (head ab5a276)

I found no security issues. I read every hunk of both changed files.

  • plugins/session-flow/scripts/save_point.py: a local refactor of a CLI helper script.

    • _next_id now tests the predecessor's shape once.
    • The _amendment_units wrapper is inlined into _entry_units.
    • _print_verdict's label logic is a flat if/elif chain.
    • cmd_emit reads the file size only when the verdict is not UNVALIDATED.
    • _apply_retire computes the file name once, before its loop.
    • cmd_fill builds its read-only guard doc from bytes it has already decoded. Before, it re-read the file through parse_doc.

    No change touches subprocess calls, shell strings, path building, network I/O, credentials or a trust boundary. cmd_fill still checks type: handoff and the file's shape on the same content before it writes anything. The bytes it checks are now the same bytes it writes back, which removes a second read rather than adding a gap.

  • .changes/session-flow/...md: a new changelog fragment that is text only.

Neither file matches a trusted-path glob. The change touches no trust control, plugin manifest, workflow or standing instruction.

The PR context contains no embedded instructions aimed at the lane.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read the full diff for both changed files: plugins/session-flow/scripts/save_point.py and the new changelog fragment. I then checked each hunk against the unchanged code it calls. This was a whole review, not a blocking-only one, since no earlier head of this PR had been reviewed.

Behavior equivalence, hunk by hunk (from reading the code; I did not run tests or lint):

  • _next_id: floor and ids get the same values for both shapes. ids is still a new list, so ids += changes nothing outside the function.
  • _amendment_units inlined into _entry_units: nothing else in plugins/ references it, and the body is unchanged.
  • _print_verdict: the new if/elif chain gives the same label for every combination of code and findings.unvalidated / findings.items. UNVALIDATED can only be reached when code == 0, as before.
  • cmd_emit: _size_finding returns UNVALIDATED only after its size > READ_CAP_BYTES branch has returned FAIL (save_point.py#L1673). So an UNVALIDATED verdict always means the file is under the Read cap, and choosing the message by level gives the same text as the old over_read test. _cap_state is still read for every FAIL verdict, and _size_finding has already read the size before that, so the read is just as able to fail as before.
  • _apply_retire: rel is not reassigned inside the loop, so computing name once before the loop is equivalent. When listings is empty it now does one extra rsplit on a string, which cannot fail.
  • cmd_fill: parse_doc is _doc_from_lines(path, _text_lines(path.read_text(encoding="utf-8"))) (L607-L608). _universal turns \r\n and a lone \r into \n, the same as read_text's universal-newline mode (L467-L473). Neither path strips a BOM. The only exceptions the old try caught came from the second read, which no longer happens. The updated docstring matches the new code.

Closing issue #14732 acceptance criteria:

  • Behavior unchanged: met, per the reading above. The existing session-flow tests are what would catch a regression; the PR says it did not run them and leaves them to CI (author-claimed, unverified).
  • Diff edits only the listed file and a fragment: met.
  • Within 400 lines and 15 files: met (about 50 changed lines, 1 hand-edited file).
  • Fragment body is ### Changed plus "Internal simplification, no behavior change.", with bump: patch: met.
  • Only functions starting in range 2 of 3 changed: the changed functions start around lines 1435–2335 at head, which is consistent with the stated 1333–2665 base range.
  • ci-status green: depends on the PR's CI, which this lane cannot see.

Rules checked: .claude/rules/ruff-pin.md matches **/*.py, but the diff does not touch anything it covers. The PR changes no plugin manifest, so there are no manifest lines.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for ab5a276

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-15351-ab5a276622fe50fa8767361894ab6923f415fcbc, 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 2e7479e Nov 11, 2026
65 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14732-43011748134-1 branch November 11, 2026 12:54
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

0 participants