Skip to content

feat: activate accepted plans in routed sessions - #65

Closed
jefft72 wants to merge 3 commits into
stack/native-plan-02-sessionfrom
stack/native-plan-03-runtime
Closed

jefft72 wants to merge 3 commits into
stack/native-plan-02-sessionfrom
stack/native-plan-03-runtime

Conversation

@jefft72

@jefft72 jefft72 commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refactors session and harness replacement into a prepared, reserved, and committed runtime transition that keeps the current session intact until its successor is ready.
Routes accepted plan continuations into the appropriate task-scoped runtime before implementation begins, while ordinary planning turns remain in their current session without automatic profile switching.

Reasoning

Runtime replacement spans asynchronous routing, candidate creation, extension shutdown, host invalidation, activation, and UI rebinding.
Tearing down the current runtime before those prerequisites succeed can strand the user with a dead session, while allowing overlapping prompts or replacements can deliver input to the wrong transcript.

Accepted plans add a stricter ordering requirement because the implementation continuation must be delivered exactly once under the selected implementation harness.
Session identity, leaf position, collaboration state, and disposal status therefore need to be revalidated at each asynchronous boundary before ownership changes.

Changes

  • Adds exclusive runtime-operation ownership that serializes session switches, new sessions, forks, imports, harness activation, accepted-plan routing, and disposal.
  • Settles and reserves the outgoing AgentSession, prepares the successor before shutdown, and releases the reservation without replacing the live runtime when candidate creation fails.
  • Commits replacement as a one-way transition through shutdown hooks, host invalidation, disposal, activation, and rebinding, while adopting the prepared runtime and recording diagnostics if a post-shutdown stage fails.
  • Keeps disposed outgoing session references leased so stale callers cannot mutate a SessionManager that has been adopted by the successor runtime.
  • Adds target-validation callbacks and expected-session and expected-leaf checks so switch, new-session, fork, and routed activation can reject stale or incompatible state before mutating the current session.
  • Creates independent in-memory branch managers for forks and makes profile metadata changes reversible when a candidate runtime is rejected or persistence fails.
  • Defers related-session metadata updates until commit and preserves the outgoing session when those precommit writes fail.
  • Bypasses automatic profile and task-boundary routing for normal plan-mode prompts, including races where plan mode becomes active while routing, confirmation, switch hooks, or runtime creation are pending.
  • Rejects automatic harness resume when the target transcript is in plan mode, has an unresolved plan, or holds an accepted continuation.
  • Routes an accepted continuation under exclusive ownership, activates an initial harness when automatic routing requires one, reuses existing or pinned runtime scope when appropriate, and waits for the operation before disposal completes.

Testing

  • Final rebased stack: npm run check passed.
  • Final rebased stack: focused Vitest validation across 28 affected files passed all 451 tests.
  • This intermediate branch was not checked independently after reconstruction.

@jefft72 jefft72 added enhancement New feature or request coding-agent labels Aug 16, 2026
@jefft72 jefft72 self-assigned this Aug 16, 2026
@jefft72 jefft72 added enhancement New feature or request coding-agent labels Aug 16, 2026
@Issacboy123
Issacboy123 force-pushed the stack/native-plan-03-runtime branch from aa78294 to 530d68d Compare August 16, 2026 03:14
Serialize runtime replacement and disposal so outgoing sessions remain valid until their successors are ready.
Prepare forked and restored runtimes without mutating the live session before replacement succeeds.
Activate routed harness sessions atomically and hand accepted plan continuations to the selected runtime.
@jefft72

jefft72 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

Closing to rebuild on a clean base.

This stack does not build. Two separate defects are present, and the first masks the second:

  1. A stray closing brace committed in feat: enforce native plan collaboration policy #64 stops packages/coding-agent/src/core/agent-session.ts from parsing at all.
  2. From feat: activate accepted plans in routed sessions #65 onward the stack imports five modules that exist only on the task profile stack: evolved.ts, harness-descriptors.ts, profile-router.ts, profiles.ts, and runtime-telemetry.ts.

Replacement stacks:

  • plan/* for native plan mode standing alone on main
  • plan-harness/* for the plan and profile integration

The branch behind this PR is retained unchanged as a backup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coding-agent enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant