Skip to content

feat(state-machines,cli): land Nov-4 index, Phase 3B new-owner hardening, and serve MCP survivor fix - #903

Open
sambitcreate wants to merge 1 commit into
mainfrom
feat/sm-phase0-3b-cli
Open

sambitcreate wants to merge 1 commit into
mainfrom
feat/sm-phase0-3b-cli

Conversation

@sambitcreate

Copy link
Copy Markdown
Owner

Summary

  • Import Nov-4 baseline inventory/risk-ranking TSVs (82c5b3849) into docs/audits/, add canonical docs/state-machines/README.md index, commit docs/plans/explicit-state-machines-refresh-plan-2026-11-23.md, and register in docs/plans/README.md
  • Add docs/state-machines/new-desktop-owners-2026-11.md worksheets and harden race/teardown edges across gemini-live/app-control/provider.ts (close-during-enabled()), hooks/hook-dispatcher.ts (identity-guarded BoundedMap.deleteIf), aiden-mcp-server.test.ts, bot-plans/lifecycle.test.ts, and bot-messages/lifecycle.test.ts
  • Fix aiden serve stop orphaned-grandchild MCP survivor gap in packages/cli/src/serve-lifecycle.ts (selectDaemonMcpGroups + lease-token binding) with unit + real-process tests in packages/cli/tests/serve-lifetime.test.mjs and docs/state-machines/serve-daemon.md updates

Verification

  • 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/cli build & tests (369 passed, 1 skipped)

…worksheets/fixes, and CLI serve-stop MCP survivor fix

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
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