Skip to content

refactor(planning): simplify shared server.py - #15028

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14676

Summary

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

Simplified plugins/planning/shared/server.py with no behavior change. A QuickTunnelStarter.forget helper replaces five inline copies of the drop-and-end sequence in watch(). A GuestHandler.content_length helper replaces two identical Content-Length parses. An App.public_hosts helper replaces three copies of the tunnel-host set. client_fields now skips a missing field once instead of checking for None twice. Means chosen on evidence from the file: each helper has only callers in server.py and nothing else defines those names (checked with Grep over the plugin and its tests). The port-gone branch keeps its original order (pop, end, log, then live_ended), so the log output stays the same even when a state write fails.

Not verified

  • Python test suites (plugins/planning/shared/tests/test_server.py, test_server_live.py and the rest) were not run: this lane runs no interpreter or test runner. Left to the PR's CI.
  • ci-status green is a PR check, left to the PR's CI.
  • Tidy's ai-slop pass ran its rubric over the changelog fragment by reading it, but not its deterministic detector (detect.sh), since the lane's Bash runs only the named wrappers. The fragment's text is fixed by the issue.
  • The changes are left uncommitted in the working tree, as the lane's instructions say, so no commit was made with a commit tool.

Fix

  • plugins/planning/shared/server.py: added QuickTunnelStarter.forget, GuestHandler.content_length and App.public_hosts and used them in place of the duplicated inline code; collapsed the double None check in client_fields
  • .changes/planning/work-resolve-issue-issue-14676-42778884065-1-b21214b0.md: patch fragment, ### Changed, "Internal simplification, no behavior change."

Verification

The runner ran each check from the base copy against 085c9a5:

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

The run reports:

  • check-changelog-fragments: all 4 fragments valid (run before and after the review fix)
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 13 passed, 6 skipped over 2 changed files (run before and after the review fix)
  • fresh-context review subagent over the whole diff: found one difference (in the port-gone branch of QuickTunnelStarter.watch, a raising live_ended would have dropped the info log line written before it); fixed by keeping live_ended after the log there; no other findings
  • Grep over plugins/planning: no other definition of or reliance on forget, content_length or public_hosts; tests use the real App and QuickTunnelStarter
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42778884065

Left out: the items under Not verified.

Related

#14676

Merge-Risk: max=HIGH demote=true head=085c9a50c9cb7d60f4e38ce0027476beeec60b6f rubric=8.3.3 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 085c9a50c9cb7d60f4e38ce0027476beeec60b6f: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15028 (refactor(planning): simplify shared server.py)

No security issues found.

I read every hunk in both changed files. Neither file matches a trusted-path glob, and neither touches a trust control, a workflow, a plugin manifest or an instruction surface.

plugins/planning/shared/server.py. I compared each refactor with the code it replaces. Behavior on the security-relevant paths is the same as before.

  • App.public_hosts() builds the same set as the three inline copies it replaces: {h for h in (self.tunnel_host, self.retired_host) if h}. Two places depend on it, and their results are unchanged:
    • host_ok, the Host/Origin gate in front of every guest request. Its re-check after sync_tunnel still recomputes the set, because it calls the method again.
    • The Secure attribute on the asset cookie in asset_cookie.
  • GuestHandler.content_length() parses the header exactly as before and still returns -1 when the header is missing or not an integer. Both callers still reject a negative length and still enforce BODY_CAPS / session.CHUNK_SIZE. The guard rejecting Transfer-Encoding on chunk uploads is untouched.
  • client_fields: skipping None first, then checking the type, then the length, rejects and accepts exactly the same inputs as before. _visible sanitizing and the CLIENT_KINDS check are unchanged.
  • QuickTunnelStarter.forget(): each of the five call sites does the same steps as the code it replaces:
    • The two branches that originally skipped live_ended now pass record=False.
    • The port-gone branch, where the owner's server stopped listening, still ends the entry, so the public address is never carried over to whatever binds the port next.
    • The pop still happens under _live_lock.

Changelog fragment. Prose only, no security surface.

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

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read every hunk of both changed files. I checked each refactor in plugins/planning/shared/server.py against the code it replaces, reading the file at head:

  • QuickTunnelStarter.forget (L408-L415): the order is the same as before: pop under _live_lock, then end, then live_ended/changed when record is set. I checked all five call sites in watch():
    • The two branches that called live_ended right away now use the default record=True.
    • The "stopped while it restarted" branch never called live_ended, and now passes record=False.
    • The port-gone branch passes record=False and keeps its own log.info and then live_ended, so the log line still comes before the session write.
    • The gone path inside the restart except still calls self.end directly, the same as before.
  • GuestHandler.content_length: the parse and the -1 fallback are identical at both call sites (the JSON body and the upload piece).
  • App.public_hosts: returns the same set comprehension that was used in asset_cookie and twice in host_ok. host_ok still reads the host set again after sync_tunnel.
  • client_fields: the early continue on None gives the same result as the two v is not None guards it replaces.
  • Name clashes: none. A Grep over plugins/planning finds no other definition of forget, public_hosts or content_length on these classes. session.py has _forget, which is a different class.

Closing issue #14676 acceptance criteria

  • Behavior unchanged: met, by my reading of the code. The existing suites under plugins/planning/shared/tests/ cover these paths, but I did not run them.
  • Diff edits only the listed file plus a fragment: met.
  • Within 400 lines and 15 files: met.
  • Fragment from new-changelog-fragment.sh planning patch with ### Changed and the exact line: met (bump: patch, correct body).
  • ci-status green: I can't check this from here. The author says it is left to the PR's CI, and that is unverified.

The test and check results in the PR body come from the author's lane run. I did not confirm them.

No paved-path, path-scoped-rule or plugin-manifest items apply: the diff changes no .claude-plugin manifest. No embedded instructions in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 085c9a5

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-15028-085c9a50c9cb7d60f4e38ce0027476beeec60b6f, 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 130a6cf Nov 10, 2026
75 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14676-42778884065-1 branch November 10, 2026 09:04
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 server.py planning plugin code

0 participants