Skip to content

test(planning): check pending live port leaks by JSON value, not substring - #9245

Merged
kyle-sexton merged 2 commits into
mainfrom
fix/shared-port-substring-flake
Oct 22, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
fix/shared-port-substring-flake

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: fixes main red at 20f70f2 (run 39868709973)

Summary

TestLiveRoutes::test_a_pending_entry_url_reaches_the_owner_and_never_a_guest_or_leader failed main in run 39868709973. It ran assertNotIn("5173", json.dumps(state)) over the guest's state, and the substring matched the host's joinedAt timestamp 1792710102.8151734. The guest's lives was [], so nothing leaked. Session._lives_view (plugins/planning/shared/session.py:4049-4067) gives non-owners only {id, label, status: {kind}}, plus url once the entry runs.

Fix

  • A new port_leaks(doc, port) test helper walks the parsed state and returns the JSON path of every string value or key that contains the port's digits, and every integer equal to the port. Floats such as timestamps never count.
  • The guest and leader check now asserts port_leaks(...) == []. The owner snapshot is checked as the matching positive case: it must leak at exactly $.lives[0].target.port and $.lives[0].url.
  • TestPortLeaks shows that a timestamp holding the port's digits trips a raw substring search but not the helper. It also shows the helper catching a URL, a host:port string, an integer port field, a string port field, and a key.
  • No server code changed.

Verification

  • Ran the changed tests 5 times: 3 passed each run. Ran the whole of plugins/planning/shared/tests/test_server.py 3 times on Python 3.14 with .github/requirements-ci.txt: 270 passed each time.
  • Sabotage check: making _lives_view hand guests target for every entry fails the new assertion (['$.lives[0].target.port'] != []).
  • scripts/run-ruff.sh check passes. The pre-push check-affected hook passed.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits October 22, 2026 19:16
…tring

The guest/leader leak check searched json.dumps(state) for "5173", which
matched the host's joinedAt timestamp (1792710102.8151734) and failed main
at 20f70f2. port_leaks walks the parsed state and flags only string
values, keys, or integers that carry the port; the owner snapshot pairs it
as the positive case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 22, 2026 23:41
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T23:44:39.855391Z — Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kyle-sexton
kyle-sexton enabled auto-merge October 22, 2026 23:42
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 876ef66d90baf0f870ed9804f2540d7020dee38b: 0 finding(s), 0 as inline comments.

Security review: PR #9245 at 876ef66

Result: no security findings.

The PR changes only a test file (plugins/planning/shared/tests/test_server.py) and a changelog fragment. It touches no production code, no plugin manifest (plugin.json or marketplace.json), no standing instruction (CLAUDE.md, AGENTS.md, rules, skill or agent bodies, hooks) and no workflow. The manifest checks and the instruction-surface check have nothing to examine, so I reported no manifest <field> lines and did not need the instruction exception register.

What the change does. It replaces a raw substring search for the port in the guest and leader /api/state JSON with port_leaks. That helper walks the parsed JSON and flags an integer equal to the port, or a key or string containing its digits. It ignores floats such as timestamps, which fixes a flake where a timestamp happened to contain the digits "5173".

Does the test still catch a leak? I checked whether the new check is weaker in a way that could hide a real leak of a pending live port to a guest or leader.

  • The check still covers every way the port can be exposed: URLs, host:port strings, integer and string fields, and keys.
  • It would miss only a port serialized as a float, such as 5173.0. The server does not emit ports that way, and the new TestPortLeaks cases and the added owner-side assertion (["$.lives[0].target.port", "$.lives[0].url"]) pin the real shape.
  • The owner-side assertion also makes the helper fail loudly if the owner state stops exposing the port, so the guest and leader checks cannot pass vacuously.

I found no exploitable path, no secret or credential handling, and no injection surface.

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 876ef66d90baf0f870ed9804f2540d7020dee38b: 0 finding(s), 0 as inline comments.

No findings on 876ef66.

I read the full diff (the new port_leaks helper, TestPortLeaks, the changed live-route test and the changelog fragment). I did not run the tests myself. The PR's claimed test runs and sabotage check are author-claimed and unverified by me.

  • Helper: port_leaks (plugins/planning/shared/tests/test_server.py:22-30) walks the parsed JSON. It flags keys and strings that contain the port's digits, and integers equal to the port. It excludes floats, so 1792710102.8151734 no longer trips it. It also excludes bools, so True == 1 can't trigger it for port 1.
  • Owner assertion: the exact list ["$.lives[0].target.port", "$.lives[0].url"] is deterministic. In Session._lives_view, {**deepcopy(e), **local(e)} puts target first and appends url.
  • Residual flake risk: I judged it negligible. Strings in the state, such as pids from ids.token(9), could in principle hold "5173". The odds are roughly 5e-7 per string, far below the timestamp collision that caused the red main.
  • Closing issue: the PR states "No related issue", so there are no acceptance criteria to check.
  • Manifest and rules: no plugin manifest changed, and no path-scoped rule under .claude/rules/ is hit by the changed files. The changelog fragment uses bump: patch, which fits a test-only fix.
  • Security: no security-relevant change.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit dabfb58 Oct 22, 2026
57 checks passed
@kyle-sexton
kyle-sexton deleted the fix/shared-port-substring-flake branch October 22, 2026 23:50
github-merge-queue Bot pushed a commit that referenced this pull request Oct 23, 2026
… the lane can commit (#9268)

No related issue: fix-docs report failure on #9245, run 39874313435

## Summary

In [run
39874313435](https://github.com/melodic-software/claude-code-plugins/actions/runs/39874313435),
job "fix-docs / report" on PR #9245 failed. The run job gated no head
SHA, so its `can-commit` output was empty. The report job's `signed`
step gated on `can-commit != 'false'`, which an empty value passes. It
ran `check-signed-commits` with an empty `since-sha`, warned "could not
verify the lane's commits (the PR's head never matched its branch)",
then failed the job when the label escalation got a 403 on `POST
.../issues/9245/labels`.

## Fix

In `.github/workflows/pr-run-activity-read.yml`, the `signed` step now
runs only when `needs.run.outputs.can-commit == 'true'` and
`steps.head.outputs.sha != ''`; the PR number and not-forged conditions
are kept.

No read-runner caller has `can-commit` true. The read workflow fails red
on any effect but `read` (`effect-not-read`), the read effect grants
`contents: read`, and `resolve-config.mjs:260` sets `can-commit` to
`String(grant.contents !== "read")`, so it is `false` whenever config
resolves and empty otherwise. The `fix-ci`, `fix-docs` and
`resolve-issue` activities all forbid `mutate-branch`. The step is kept,
not deleted, so a future read-runner activity with a write grant stays
covered.

`pr-run-activity-write.yml` has the same `!= 'false'` shape but gates on
`pr-number != ''`, and its activities can commit, so it is a different
context and is unchanged.

## Verification

- New test in `.github/actions/resolve-config/callers.test.mjs`
evaluates the step's `if` for `can-commit` `true`, `false` and empty, an
empty head SHA, an empty PR number and a forged head. It fails on the
old gate (`can-commit ''`) and passes on the new one.
- `callers.test.mjs`: 102 pass. `check-signed-commits` tests: 33 pass.
`actionlint` on the workflow: clean.
- `scripts/check-affected.sh --tests`: 9 passed, 5 skipped (no markdown,
shell, plugin, Python or skill changes).
- No changelog fragment: no plugin or convention file changed.

## Related

- Failing run:
https://github.com/melodic-software/claude-code-plugins/actions/runs/39874313435
- PR #9245

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant