Repository navigation
feat(state-machines,cli): land Nov-4 index, Phase 3B new-owner hardening, and serve MCP survivor fix - #903
feat(state-machines,cli): land Nov-4 index, Phase 3B new-owner hardening, and serve MCP survivor fix#903sambitcreate wants to merge 1 commit into
Conversation
…worksheets/fixes, and CLI serve-stop MCP survivor fix
There was a problem hiding this comment.
Important
The forced-stop selector can SIGKILL an unrelated same-user process group after a stale PGID is reused; this ownership gap should be closed before merge.
Reviewed changes Reviewed the complete initial change set at 5333aa1b8, including the imported audit inventory, canonical state-machine documentation, desktop owner hardening, and CLI survivor cleanup.
- Audit and plan inventory — Imports the Nov-4 TSV baselines and adds the canonical worksheet index and remediation plan.
- Desktop lifecycle coverage — Adds behavioral tests for MCP tool-runner authorization, Bot plan and message teardown, and related retained-owner contracts.
- Live app control — Rechecks provider closure around awaited enablement and guards late look and idle-state publication.
- Hook idempotency — Makes stale dispatch cleanup identity-aware so it cannot remove a newer cached outcome.
- CLI forced stop — Extends MCP group discovery to wrapper-orphaned grandchildren, adds lease-token metadata, and exercises the path with pure and real-process tests.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
| const liveMembers = members.filter((member) => !member.zombie); | ||
| if (liveMembers.length === 0) continue; | ||
| if (daemonUid !== undefined && liveMembers.some((member) => member.uid !== daemonUid)) continue; | ||
| owned.add(group); |
There was a problem hiding this comment.
Same-UID membership is not an ownership proof after the original process group has emptied. liveGroups removal is polled and this file publishes updates best-effort, so a stale PGID can be reused by an unrelated same-user wrapper that exits; this branch then accepts its leaderless child and stopDaemon() sends the unrelated group SIGKILL.
Technical details
# Leaderless group selection can kill unrelated processes
## Affected sites
- `packages/cli/src/serve-lifecycle.ts:131-134` — accepts a leaderless group using only live-member UID equality.
- `main/services/mcp-stdio-transport.ts:186-194` — removes a dead group on a later poll, leaving an interval in which the recorded PGID can be stale.
- `packages/cli/src/serve-lifecycle.ts:508` — signals every selected group with `SIGKILL`.
## Required outcome
- Select an orphaned leaderless group only from ownership evidence bound to that process-group incarnation; stale or reused leaderless groups must fail closed.
- Cover a stale record followed by same-UID leaderless PGID reuse, rather than only a currently owned leaderless orphan.
## Suggested approach
- Preserve an observable supervisor/leader identity or persist and validate process-incarnation evidence captured before ancestry is lost; UID alone cannot distinguish these snapshots.|
|
||
| --- | ||
|
|
||
| ## 4. Remaining Open Execution Slices (Phases 4A–4C) |
There was a problem hiding this comment.
The status line and phase table say 4A–4C are implemented, but this heading and the future-tense checklist call them remaining work. Please convert this section to an implementation record or restore those phases to the open status so the canonical plan has one answer.

Summary
82c5b3849) intodocs/audits/, add canonicaldocs/state-machines/README.mdindex, commitdocs/plans/explicit-state-machines-refresh-plan-2026-11-23.md, and register indocs/plans/README.mddocs/state-machines/new-desktop-owners-2026-11.mdworksheets and harden race/teardown edges acrossgemini-live/app-control/provider.ts(close-during-enabled()),hooks/hook-dispatcher.ts(identity-guardedBoundedMap.deleteIf),aiden-mcp-server.test.ts,bot-plans/lifecycle.test.ts, andbot-messages/lifecycle.test.tsaiden serve stoporphaned-grandchild MCP survivor gap inpackages/cli/src/serve-lifecycle.ts(selectDaemonMcpGroups+ lease-token binding) with unit + real-process tests inpackages/cli/tests/serve-lifetime.test.mjsanddocs/state-machines/serve-daemon.mdupdatesVerification
npm run type-check(0 errors),test:bot-plans(147/147),test:bot-messaging(101/101),test:hooks(185/185),test:gemini-live(577/577),test:aiden-remote(1,484 passed, 5 skipped),aiden-mcp-server.test.ts(19/19),packages/clibuild & tests (369 passed, 1 skipped)