Skip to content

refactor(planning): simplify cfdns, detached and liveserve helpers - #15025

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14675

Summary

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

Simplified the three listed planning/shared files without changing what they do. detached.py gains private helpers for the repeated pid check, the ps/powershell subprocess call, the Windows process-handle open/close and the stop wait loop. cfdns.py gets one token-scrubbing refusal in request, a RECORD_FIELDS constant and a pattern-check helper. liveserve.py names its plain-text content type once and builds the file name once in _copy_one. The approach was a choice of means: repeated code within each file is folded into one helper in that file, every message string stays byte-identical, and nothing moves between files, since the issue leaves that to the restructuring pass.

Not verified

  • The planning Python test suites (plugins/planning/shared/tests/test_cfdns.py, test_tunnel.py, test_server_live.py, test_share.py and others that use detached) were not executed: this lane can run no interpreter, so they are left to the PR's CI
  • The Windows-only branches of detached.py (the _handle context manager in describe, started and _running) could not be exercised on this Linux runner; they are checked by reading only and are left to CI's Windows platform tests
  • ci-status green is a PR check, left to the PR's CI
  • tidy skipped passes 4 (docs-hygiene writing rules) and 5 (ai-slop fix) for the changelog fragment, because the issue fixes its body word for word; passes 1 to 3 ran over the code lines
  • Lint and type checks for Python (ruff and the like) and typos were not run here: check-affected skipped typos (not installed) and runs no Python linter in this lane; left to the PR's CI

Fix

  • plugins/planning/shared/cfdns.py: request builds its three token-scrubbed Refused errors through one local refused(); the record field tuple is RECORD_FIELDS; the four id/UUID checks go through matching(), with the tunnel-id message kept once as TUNNEL_ID
  • plugins/planning/shared/detached.py: added private _pid_ok (the pid guard used 4 times), _output (the subprocess.run plus except used 5 times), _handle (the Windows OpenProcess/CloseHandle pattern used 3 times) and _gone_within (the two stop wait loops)
  • plugins/planning/shared/liveserve.py: a TEXT constant for the 4 uses of text/plain; charset=utf-8, and one local name for the 3 uses of '/'.join(rel) in _copy_one
  • .changes/planning/work-resolve-issue-issue-14675-42778836717-1-59a52862.md: new patch fragment, ### Changed: Internal simplification, no behavior change.

Verification

The runner ran each check from the base copy against 5a1c4ce:

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

The run reports:

  • check-changelog-fragments: all 4 fragments under .changes/ 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 4 changed files (run before and after tidy)
  • fresh-context subagent review of the whole diff against HEAD: no behavior change found. It traced the error messages, exception order, empty/failed subprocess output, Windows handle close semantics, the stop() call sequence and the mocked module attributes in the tests. Two nits, both kept as is:…
  • tidy-diff over the 37 changed hunks: no further simplification, comment deletion or residue fix found
  • diff size: 3 code files plus 1 fragment, about 75 added and 85 removed lines, all in plugins/planning, within the issue's 400-line / 15-file cap
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42778836717

Left out: the items under Not verified.

Related

#14675

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

Security review: PR #15025 (head 5a1c4ce)

No security issues found.

I read every hunk of all 4 changed files: the changelog fragment, plugins/planning/shared/cfdns.py, detached.py and liveserve.py. None of them matches a trusted-path glob. The pull request touches no trust control, workflow, plugin manifest or standing instruction.

I checked whether each refactor keeps the security behavior of the code it replaces:

  • cfdns.py, token scrubbing. The local refused() builds the same f"{method} {path}: {message}" string and still applies .replace(token, "[token]"). All three error paths still go through it: the HTTPError path, the OSError/ValueError path (exc is formatted into the f-string exactly as before) and the success: false path. from None is kept, so the original exception chain, which could carry the request headers, is still cut. No error path can now leak the token where it did not before.
  • cfdns.py, input validation. matching() keeps the same fullmatch(value or "") checks on the zone, account and tunnel ids. These ids are interpolated into API paths, so path injection stays blocked. The RECORD_FIELDS constant does not change the output.
  • detached.py, pid guard. _pid_ok is the same check as before (an int, not a bool, above 1). All four former call sites use it, so the init and idle processes are still never signalled.
  • detached.py, subprocess calls. _output passes a fixed argument list with no shell, as before, and keeps the same timeouts (5 s, and 30 s for command_line) and the same env override for started. _running still treats a failed ps as "still running", so stop fails closed the same way.
  • detached.py, Windows handles. _handle still closes a non-null handle and returns early on a null one.
  • detached.py, stop. It runs the same SIGTERM, wait, SIGKILL (POSIX only), wait sequence and makes the same final _running check.
  • liveserve.py. TEXT and the precomputed name change only string constants. The symlink, hard-link, O_NOFOLLOW and resolve checks in _copy_one are unchanged, and so are the response headers.

The PR context has no embedded directives aimed at this lane. The closing issue's body was left out by the wrapper because the issue author is not on the allow list.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read every hunk of the 4 changed files. None of the changed files is on a trusted path. This is the first review of this PR (prior findings: 0 earlier heads, blocking only: no).

Behavior check (done by reading only; I ran nothing):

  • plugins/planning/shared/cfdns.py
    • The local refused() builds the same f"{method} {path}: {message}" string as before. The token is still scrubbed after formatting. refused(exc) gives the same result as the old {exc}.
    • matching() keeps the same check order and the same messages, byte for byte.
    • RECORD_FIELDS and TUNNEL_ID hold exactly the literals they replace.
  • plugins/planning/shared/detached.py
    • _output returns None on OSError/SubprocessError. Each call site sends that None to the same result as the old early return:
      • describe, exe_name, command_line and started still end up returning None (basename(""), [] and "" all fall through to or None).
      • _running still returns True when ps fails.
      • Timeouts stay the same: 5 s by default, 30 s in command_line, and the LC_ALL/TZ environment for lstart.
    • _handle closes the handle only when it is truthy. That matches the old code, which returned early on a falsy handle without calling CloseHandle.
    • _pid_ok is the same guard used in all 4 places.
    • stop/_gone_within keep the same order: SIGTERM, poll, then SIGKILL on POSIX only, poll again, then a final not _running(pid). The calls to time.monotonic, _running and sleep happen in the same order.
    • The new private names clash with nothing else in the module.
  • plugins/planning/shared/liveserve.py: TEXT and the local name hold exactly the values they replace.

Against #14675's acceptance criteria:

  • Only the 3 listed files and one changelog fragment are edited.
  • The fragment says bump: patch with ### Changed / "Internal simplification, no behavior change.", which matches the required body.
  • The size is well under 400 lines.
  • No exported name is renamed or removed. The new module-level constants and matching are additions.
  • "ci-status is green" is left to CI. The author says the test suites and the Windows branches were not run (author's claim, unverified). The existing planning tests under plugins/planning/shared/tests/ cover these paths.

Path rules: .claude/rules/ruff-pin.md (**/*.py) matches the Python files, but nothing in this change touches what it governs.

No manifest changes, no hold classes, and 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 5a1c4ce64268bcf724191a4dc23dbce0d4bde337, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 5a1c4ce

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-15025-5a1c4ce64268bcf724191a4dc23dbce0d4bde337, 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 2ab663c Nov 10, 2026
75 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14675-42778836717-1 branch November 10, 2026 09:00
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 shared planning plugin code (1 of 2)

0 participants