Skip to content

refactor(planning): simplify session.py part 3 of 4 without behavior change - #15256

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14679

Summary

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

Simplified the functions that start in range 3 of 4 of plugins/planning/shared/session.py (lines 3427-5139 of the 6851-line file as measured at the start of this part). Logic that was repeated has moved into small private helpers, each used by two or more callers: _next_seq (decision-log sequence numbers), _ask_from and _posted (the "Claude" ask that chat messages and Discussion comments file, and their route answer), _chat_message (active-author chat lookup with 404), _toggle_reaction (the emoji add or remove and its caps on chat messages and comments), _is_live_url (live-prototype URL check), _request_in (the 409 wrong-status check on requests), _drop_result and _result_request (result removal and the lookup of the request behind a result). Separately, _run no longer returns an unused value, and my_requests became a comprehension. Every error code, message, field, return value and state change, and their order, is unchanged; no public method was renamed or removed. The changed lines amount to 98 added and 89 removed.

Not verified

  • The planning plugin's Python test suites (plugins/planning/shared/tests) were not run: this lane cannot start an interpreter. The PR's CI runs them.
  • tidy: passes 1-3 (simplify, comments, residue) ran over the code lines and changed nothing. Pass 4 (write-for-humans) was skipped and pass 5 (ai-slop) was done by reading only, because the fragment's one line is wording the issue requires word for word and this lane cannot run the ai-slop detect.sh…
  • Line-length lint: the repository root sets no line-length rule, and the new long lines are no longer than many existing lines in the file.
  • The working tree has untracked files this run did not create (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc), probably sandbox or runner files. They should stay out of the patch.

Fix

  • plugins/planning/shared/session.py: only the functions starting in range 3 of 4 were changed: _decided, _undo_take_back, chat, react_chat, propose_from_chat, live_started, live_moved, comment, react_comment, act_on_request, _move_request, _run, _act_on_result, _share_result, my_requests,…
  • .changes/planning/work-resolve-issue-issue-14679-42955823408-1-a8502c68.md: new planning patch fragment, made with new-changelog-fragment planning patch, whose body is ### Changed and "Internal simplification, no behavior change."

Verification

The runner ran each check from the base copy against 3da62e8:

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

The run reports:

  • check-changelog-fragments: all 15 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 (shellcheck had no changed shell; typos is not installed; 3 validate-plugins checks only run code from the checked tree; changed-skills had no skill file), the rest are CI-only (run before and after tidy)
  • fresh-context review subagent, given only the diff: checked each hunk against the current code and its callers and found no behavior difference and no lint issue. That covers evaluation order (seq is computed before log.pop in _undo_take_back), the old max() with no default (an empty log cannot…
  • range check: every changed function starts between lines 3427 and 5139 of the original file, and every new helper sits in that range
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42955823408

Left out: the items under Not verified.

Related

#14679

Merge-Risk: max=MEDIUM demote=false head=3da62e82ddd620f4212187fcc6807aa08862e40b 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-security-review reviewed 3da62e82ddd620f4212187fcc6807aa08862e40b: 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: the planning changelog fragment, which is prose only, and plugins/planning/shared/session.py. Neither file matches a trusted path. No plugin manifest, workflow, action or instruction surface is touched, and nothing in the diff deletes or softens a guardrail.

I checked the session.py refactor against the code around it for any change to who can do what:

  • Authorization calls are unchanged. Every check the routes made before still runs, in the same order: _writer, _moderator, _throttle, _write_as, and _request(..., runner=..., owner_pid=pid). _request_in reproduces the old 409 wrong-status status lists exactly, and act_on_request keeps the same per-action map.
  • _ask_from behaves the same. It reads post["text"] and post.get("attachments", ()). The message and comment dicts store the same tokenized text and attachment value (attachments only when non-empty), so _new_request receives the same input (session.py:3841, session.py:4398-4411). It still absorbs only slow-down and too-many-pending and re-raises any other DomainError. The request throttle and pending cap in _new_request are untouched.
  • _chat_message reads the same state. It reads self.state["chat"]. _tx yields self.state (session.py:1492-1500), so this is the same list the old st["chat"] named, and the active-author filter and 404 are kept.
  • _toggle_reaction keeps both caps. MAX_CHAT_EMOJI and MAX_MY_CHAT_EMOJI are enforced as before, with the same messages and the cleanup of an empty reactions map.
  • _is_live_url keeps the URL check. It still requires a str, the MAX_LIVE_URL length limit, and a full LIVE_URL match. Wrapping the result in bool() changes nothing.
  • Dropping _run's return value is safe. No caller used it (session.py:4415, 4437, 4454).
  • my_requests is unchanged in what it exposes. The new comprehension filters the same rows and applies the same _plain_all name masking as the loop did.

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

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15256 (session.py simplification, part 3 of 4)

No findings. I read both changed files in full (plugins/planning/shared/session.py and the new changelog fragment). I checked every hunk against the head file and the code it calls.

Checked for behavior equivalence (by reading the code; I ran no tests, and the "Not verified" items in the PR body are the author's claims, also unverified):

  • _next_seq: _decided gives the same result as before. In _undo_take_back, the old max() had no default, but the log can't be empty there because mine was found in it. seq is still worked out before log.pop(mine), so the order is unchanged.
  • _ask_from / _posted:
    • post["text"] is the tokenized text in both chat and comment.
    • post.get("attachments", ()) matches the old att whenever att is truthy. When it's falsy, _new_request treats () the same way, since it only adds attachments if att.
    • msg= is still passed for chat only. Refusal handling (slow-down and too-many-pending are swallowed, anything else is re-raised) and the route answer are the same.
  • _chat_message: self.state["chat"] is the same object _tx() yields as st. In propose_from_chat, removing as st is safe because the body no longer uses st.
  • _toggle_reaction:
    • The refusal text for each noun ("message" or "comment") reads exactly as before.
    • The n count after an add uses msg["reactions"], which is still there because the add path leaves it non-empty.
    • The notification still fires only on an add, and an empty reactions map is still removed.
  • _is_live_url: bool(fullmatch) keeps the same truth value.
  • _request_in: the 409 wrong-status message and status field are unchanged in act_on_request, claim_my_request, submit_my_result and fail_my_request.
  • _drop_result: in _move_request, results is self.state["results"], so dropping the empty key and then calling setdefault behaves as before.
  • _result_request: same lookup as before.
  • _run: none of its callers (lines 4415, 4437, 4454) read its return value.
  • The my_requests comprehension keeps the same order and output.

Closing issue #14679, acceptance criteria:

  • Behavior unchanged: met as far as reading the code shows. The existing tests in plugins/planning/shared/tests/test_server.py and test_session.py cover chat asks, reactions, proposals and result moves.
  • The diff edits only session.py and a changelog fragment: met.
  • Within 400 changed lines: met (about 98 added, 89 removed).
  • Fragment: met. It is bump: patch, with ### Changed and "Internal simplification, no behavior change."
  • Only functions starting in range 3 of 4 changed: met. Every changed function and new helper sits between _decided and fail_my_request.
  • ci-status green: CI decides this, and this lane can't see it.

Path-scoped rules: .claude/rules/ruff-pin.md matches **/*.py, but it only covers how to run lint, so it gives nothing to check in this diff. No other rule matches the changed files.

Prior findings: none. This is the first review of this PR, so it is not limited to blocking findings.

No trusted paths, plugin manifests or cost-relevant changes are touched.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 3da62e8

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-15256-3da62e82ddd620f4212187fcc6807aa08862e40b, 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
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 11, 2026
@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 3bf77ad Nov 11, 2026
75 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14679-42955823408-1 branch November 11, 2026 05:27
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 3bf77adcc9edc35d0a5b835e24e55c0e4b019139; 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 session.py planning plugin code (part 3 of 4)

0 participants