Skip to content

SEP Phase 4 (engine): commands, session actions, hot reload#29

Merged
brentrager merged 1 commit into
mainfrom
th-045f70-phase4
Jul 3, 2026
Merged

SEP Phase 4 (engine): commands, session actions, hot reload#29
brentrager merged 1 commit into
mainfrom
th-045f70-phase4

Conversation

@brentrager

Copy link
Copy Markdown
Contributor

Problem

Phase 4 of the Smooth Extension Protocol needs the engine to support extension-registered slash commands, session-mutating actions, and hot reload — with the two-tier context guard that prevents an extension from mutating the session outside a command handler or across a reload.

Solution

Additive to ExtensionHost / HostDelegate / protocol (zero behavior change with no host attached):

  • Command dispatch: run_command (command/execute, COMMAND-tier context) + complete_command (command/complete, best-effort autocomplete); commands()/shortcuts() surface registrations for a frontend palette.
  • Session actions: HostDelegate::session_send_message / session_send_user_message (deliver_as steer/follow_up/next_turn) / session_append_entry, each gated by validate_command_context (command tier + current epoch → else -32003 ContextViolation, fired before the delegate). Headless defaults report -32004 CapabilityDisabled.
  • Hot reload: reload(name) fires session_shutdown{reason:reload}, bumps the shared epoch (invalidating stale tokens), respawns (generation guard drops late replies), re-inits, fires session_start{reason:reload}. Declared-events clamp re-applied on reload (no cross-restart escalation).
  • New protocol types (CommandExecute*, CommandComplete*, Completion, ShortcutRegistration, DeliverAs, Session*Params), InitializeParams.flags, Registrations.shortcuts. sep-echo-peer registers a command + shortcut and answers command/execute + command/complete.

Verification

cargo test green (45 unit incl. exhaustive validate_command_context cases + a HostInbound session-routing test; new sep_command_reload integration test covers dispatch, autocomplete, and reload-epoch-fence). fmt clean; the 2 clippy warnings are pre-existing in checkpoint.rs.

🤖 Generated with Claude Code

ExtensionHost gains command dispatch (command/execute + command/complete),
the session-action delegate seam (send_message/send_user_message/append_entry)
guarded by the command-tier + epoch context check (-32003 ContextViolation),
and hot reload (session_shutdown → epoch fence → respawn → re-init →
session_start). New protocol types for commands/shortcuts/flags/session +
sep-echo-peer command support. Additive: no host attached = unchanged loop.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9df7916

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@smooai/smooth-operator-core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brentrager brentrager merged commit 26b4489 into main Jul 3, 2026
3 checks passed
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