Skip to content

fix(planning): tell an in-flight request it was merged into the owner - #10585

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-10446-40623283087-1
Oct 28, 2026
Merged

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

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #10446

Summary

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

The ui_merge.js flake was a real server race, not a test timing problem. The server checks a guest's secret (resolve) and runs the route's action under two separate holds of the lock. When the owner's merge lands between them, the action found the person gone and answered 401 unknown-session instead of merged-into-owner. core.js then forgot the secret and joined again as "Admin 2" (send(), core.js:915), which matches the failure: no notice, a guest secret still held, 1 join, and Admin 2 back in the owner's list. Session now remembers the pids a merge into the owner removed, and _person answers merged-into-owner for them. ui_merge.js also waits for the notice after the reload before it checks for no join or name dialog, where it used to wait a fixed time.

Not verified

  • The issue's '20 consecutive local runs of ui.test.sh', the new test_session.py test and ui_merge.js were not run: this lane allows no interpreter (python, node) and no Playwright. Left to the PR's CI test-bash and Python lanes.
  • Build, test and lint of the touched files (verify) were not run, for the same reason. check-affected ran the lints it could run here; the rest are CI only.
  • Follow-up not filed (no tracker access in this lane): a guest merged into another guest has the same race. A request resolved to src just before the merge gets 401 unknown-session, and core.js drops a secret that still works (it now maps to dst), then joins again as a new person. Fixing it needs a n
  • Known limitation, left alone: if merge_people's commit fails and the transaction rolls back, the pid stays in _merged_pids (as hashes already stay in _merged_into_owner). This does no harm while the person exists. A later eviction of that person would answer merged-into-owner instead of unknown-sess
  • Tidy: I ran the ai-slop pass as a manual catalog read of README.md:297 and the fragment. The lane allows neither detect.sh nor the fix flow's sha256sum digest guard, so no findings file was written. The simplify, comment and write-for-humans passes ran in full (one wording edit in the fragment).
  • No changelog fragment helper run: new-changelog-fragment refuses a detached HEAD, so I wrote the fragment by hand. check-changelog-fragments validates it.
  • This run made no commits: no commit tool was provided, and the lane instructions say to leave the change in the working tree for the runner's patch.

Fix

  • plugins/planning/shared/session.py: new _merged_error() helper. New Session._merged_pids (in memory only), filled by merge_people when dst is the owner. _person() raises 401 merged-into-owner for such a pid instead of unknown-session. resolve() uses the shared helper.
  • plugins/planning/shared/tests/test_session.py: new TestOwnerMerge test. A pid resolved before a merge into the owner gets 401 merged-into-owner from heartbeat, snapshot and a chat write.
  • plugins/planning/shared/tests/ui_merge.js: after the reload, waits (until, 10 s) for the merged-into-owner banner and then two polls before it checks for no join or name dialog. Before, it waited a fixed 2.5 s and read the banner once.
  • plugins/planning/shared/README.md: the /api/person/merge row says that a request already in flight also gets 401 merged-into-owner.
  • .changes/planning/fix-10446-merge-race-3b9e1c47.md: patch changelog fragment for planning.

Verification

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

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • Read the code: session.py resolve() releases the lock before the route action runs, and _person() (session.py:1565) raised unknown-session for a pid that merge_people had popped. heartbeat (session.py:1886), snapshot, presence_view and _writer all call _person. core.js send() answers a non-merged 40
  • check-changelog-fragments: all 4 fragments valid (run before and after tidy and review).
  • check-affected: 12 passed, 6 skipped, 0 failed over 5 changed files (run before and after tidy and review).
  • Fresh-context subagent review of the whole diff: no correctness bug. It confirmed that every guest route (heartbeat, /api/state snapshot and presenceOnly, writes, uploads, asset cookie) now answers merged-into-owner, and that the 304 path cannot match a tag from before the merge. Two findings were a
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/40623283087

Left out: the items under Not verified.

Related

#10446

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

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

No security issues found in this change. The review was read-only. I did not run anything.

Scope. The PR changes plugins/planning/shared/session.py, a test, a README row and a changelog fragment. It does not touch the trusted paths, any plugin.json or marketplace.json, or any instruction surface, so no manifest lines apply.

What I checked.

  • _person() now answers 401 merged-into-owner instead of unknown-session when the pid is in the new in-memory _merged_pids set. This only changes which 401 an already-removed person gets.
  • _merged_pids is filled only when dst == HOST (session.py:2377-2378). Pids come from server-side generation (secrets.token_*). A pid is only looked up after resolve() has mapped a valid secret to it, so a client cannot choose a pid to probe the set.
  • The path grants no access. A request that reaches _person() with a missing person still raises, as before. Only the error code and message differ.
  • The 401 code and message were already visible to a holder of a dropped secret through resolve(). The in-flight request now gets the same answer, so nothing new leaks.
  • The set is never persisted and grows by at most one pid per merge into the owner. That merge is an owner-only action, so an untrusted caller cannot grow it.

Not a finding. The PR notes that a rolled-back merge leaves the pid in _merged_pids. If that person is later evicted, they would see merged-into-owner instead of unknown-session. That is only the wrong message, with no security impact.

critical-findings: 0

Spend. None. The change adds no cost.

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read the full diff (5 files) and the PR context, and checked the changed code against its surroundings in plugins/planning/shared. I ran nothing, because this lane has no shell. Any test result below is the author's claim, not something I confirmed.

The fix addresses the race the PR describes.

  • resolve() and the route action take self._lock separately.
  • A merge into the owner between them used to pop the person, so _person() answered unknown-session.
  • merge_people now records the removed pid in _merged_pids when dst == HOST.
  • _person() answers 401 merged-into-owner for that pid. All the guest paths I traced go through _person(): heartbeat, snapshot, _writer and check.
  • The pid is added under the same transaction that removes the person.
  • _merged_error() replaces the duplicated literal in resolve(), so the secret path and the pid path give the same message.
  • pid in self._merged_pids cannot raise TypeError for an unhashable pid. The pids that reach _person come from resolve() or the asset cookie, so they are strings.
  • The set is in memory only, like _merged_into_owner. The README row says "remembered until the server restarts", which still holds.

The tests match the fix.

  • test_a_request_resolved_just_before_a_merge_into_the_owner_is_told_so_too reproduces the race at the session level. It calls resolve(), merges, then acts with the stale pid.
  • It uses ctx.exception.http and .code, which exist on DomainError.
  • In ui_merge.js, the reload check now waits on the banner with until(...) instead of a fixed 2.5 s sleep.
  • The remaining waitForTimeout calls only guard negative assertions (no join, no name dialog), so a fixed wait is acceptable there.

Closing issue #10446

  • "Find the race": met. The server-side race is identified and fixed.
  • "The test waits on the event it asserts, not on elapsed time": met for the reload check. The first notice check already used until.
  • "ui.test.sh passes 20 consecutive local runs": not shown. The PR says it was not run, so I treat it as unverified, not met. The CI test-bash and Python lanes are the only evidence of the fix.

Not flagged, because the author already disclosed it

  • A guest merged into another guest has the same race, and no follow-up issue was filed.
  • If the merge_people transaction rolls back, the pid stays in _merged_pids. This is harmless while the person still exists.

No plugin.json or marketplace.json change, so no manifest lines apply. The changelog fragment is bump: patch for a bug fix, which fits.

No trusted-path files changed. There is no cost or critical-security concern. The change spends no paid resources.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head a60f103b2d73289619ee829ba11ee1c6cf605c99. The lanes clear this reason on their own; the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head a60f103b2d73289619ee829ba11ee1c6cf605c99.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit 4806b4e Oct 28, 2026
52 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-10446-40623283087-1 branch October 28, 2026 03:45
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

  • Range: f2b0a86..4806b4e
  • Merged pull request: #10585
  • Outcome: no result. The run's summary says why.

The run's summary has the full report.

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.

fix(planning): stop ui_merge.js from failing main on a merge-notice race

0 participants