refactor(tui): adopt command shapes in session lifecycle slice (FEAT-023) - #5902
Conversation
…ECYCLE bit, and envelope slot - One contract-owned lifecycle facet with exact-minimum synchronous delegates for the nine session lifecycle commands (D2); basic CommandSessionContext unchanged - SESSION_LIFECYCLE = bit 13 (next non-conflicting bit after PLUGIN, D3) plus one independently optional envelope slot with duplicate-rejection builder - Portable values: SessionSyncPayload, SessionBranchOutcome, SessionForkReceipt, SessionSaveReceipt, SessionNewReceipt, SessionArchiveReceipt, TreeBodyProjection - 4 new contract tests: capability identity, object safety + full outcome transport, error/empty-state transport, envelope slot semantics Generated with Claude Code Signed-off-by: Paulo Aboim Pinto <paulo.aboim.pinto@gmail.com>
- Adapter implements CommandSessionLifecycleContext over App via the shared CommandHost (D4): branch hint/branch-to, tree projections, save, active and explicit fork, fresh session, load validation, picker open, archive/restore, prune - each preserving baseline check/mutation order and exact host-error text - Bundle wired: thirteen slots, SESSION_LIFECYCLE exposure branch, test parts, all-capability projection - 8 adapter tests (Tasks 3.2/3.4): transition blocking before I/O, save/fork history preservation, explicit-fork spawn depth, busy-work atomicity, draft blockers, load shape validation without state application, picker/archive/ prune with active-session protection, tree projections for all states - TUI lib suite green 11682/11682 (4-thread bounded, CI RUST_MIN_STACK) Generated with Claude Code Signed-off-by: Paulo Aboim Pinto <paulo.aboim.pinto@gmail.com>
- Pure registrations (D3): /compact and /purge declare NONE and compose their receipts/actions without any host context bundle (Tasks 4.1-4.2) - Contextual registrations: /branch, /fork, /load, /new, /save, /sessions, /tree declare SESSION_LIFECYCLE only and own parsing, branch order, exact messages, guidance appends, and action mapping from portable receipts (Tasks 4.3-4.6) - Missing lifecycle authority returns exactly the safe capability-unavailable error; no .expect(), no partial fallback - sync_session_action maps the portable payload into the temporary SyncSession action (D6); from_command_mode made crate-visible - 11 new composition/parity tests (2 pure + 9 lifecycle_portable); full TUI lib suite green 11693/11693 (4-thread bounded, CI RUST_MIN_STACK); locale parity PASS Generated with Claude Code Signed-off-by: Paulo Aboim Pinto <paulo.aboim.pinto@gmail.com>
…ispatch seam - groups/session/mod.rs now registers /branch /compact /fork /load /new /purge /save /sessions /tree via ContextualCommand::from_contract (Tasks 6.1) - Pure (/compact, /purge) and lifecycle-only declarations exact; out-of-scope control/export/structcopy entries remain legacy for FEAT-024/025/026 - Legacy lifecycle bodies removed from the nine leaves and session.rs (single authoritative portable path); feat015 legacy allowlist extended - Public-seam tests prove exact capability declarations, pure dispatch, adapter reachability, and unchanged usage/error strings (Task 6.2) - Migration fixtures + live gate PASS (frontier [config, core, debug, session] unchanged), boundary + CI-wiring + locale gates PASS (Tasks 6.3/6.4) - Full TUI lib suite green 11666/11666 (4-thread bounded, CI RUST_MIN_STACK) Generated with Claude Code Signed-off-by: Paulo Aboim Pinto <paulo.aboim.pinto@gmail.com>
- Replace late-initialized locals with direct reads after scoped bundle drops - Workspace clippy --all-targets --all-features -D warnings: exit 0 Signed-off-by: Paulo Aboim Pinto <paulo.aboim.pinto@gmail.com>
Signed-off-by: Paulo Aboim Pinto <paulo.aboim.pinto@gmail.com>
Signed-off-by: Paulo Aboim Pinto <paulo.aboim.pinto@gmail.com>
Hmbown
left a comment
There was a problem hiding this comment.
Kind: approve-with-nits. Verified against main (a58ef2d52): CommandCapabilities is u16 with bits 0–12 taken (command-contract/src/handler.rs:20-46), so SESSION_LIFECYCLE = bit 13 is the next free bit and the widening preserves every existing identity — exactly as the PR body states. Scope is law-respecting by construction: command-contract/** + tui/src/commands/** only, no turn_loop.rs, no prompts/text.rs, and lifecycle handlers map into the existing SyncSession action rather than inventing a new authority. Full matrix green, 7/7 commits signed. Nit: the u16→u32 widening is premature while only one new bit is consumed — prefer deferring until bits actually run out, or isolate it in its own commit. The 29 regression + 11 acceptance tests through public dispatch are the right coverage shape.
Keep CommandCapabilities backed by u16 while SESSION_LIFECYCLE uses the available bit 13. The representation can be widened separately when the existing bits are exhausted. Signed-off-by: Paulo Aboim Pinto <paulo.aboim.pinto@gmail.com>
|
Addressed the capability-storage nit in Verified with Paulo Aboim Pinto |
Summary
FEAT-023 converts the TUI session lifecycle slice to portable command shapes while keeping the production files in
codewhale-tui:/branch/compact/fork/load/new/purge/save/sessions/treeBaseline: current
origin/mainata58ef2d52. The branch is eight signed commits ahead with no merge commits.This PR:
CommandSessionLifecycleContextfacet and portable lifecycle DTOs;SESSION_LIFECYCLEwith exact restricted-envelope projection;CommandCapabilitiesstorage atu16while allocating the next free identity (SESSION_LIFECYCLE, bit 13);/compactand/purgepure withCommandCapabilities::NONEand no host context bundle;SESSION_LIFECYCLEfor the seven host-dependent handlers;App, session manager, journal, picker, persistence, configuration, Work-state, and reset behavior insideSessionLifecycleAdapter;sessionmigration frontier for FEAT-024 through FEAT-026;groups/sessiondirectory;Tracking: EPIC-006 / FEAT-023 in umbrella #5316.
Dependency boundary
Portable lifecycle handlers do not access concrete
App,SessionManager, session journals, picker views, configuration, history cells, host callbacks, or service locators. Missing lifecycle authority fails closed with:The remaining staged dependencies are explicit:
CommandResult,AppAction, synchronization mapping, and mode conversion;No new crate dependency and no physical production-file move occur here.
codewhale-command-contractremains independent ofcodewhale-tui.Behavior and scope
spawn_depthis mandatory rather than silently defaulted.Testing
cargo fmt --all -- --checkcodewhale-command-contractandcodewhale-tuiwith--all-targets --all-features --locked -D warningslong-running-tests— 11 passed[config, core, debug, session]git diff --checkThe full TUI run used
RUST_MIN_STACK=8388608,--test-threads=1, and removed the harnessTMUXmarker so terminal-policy tests observed their intended fixtures.Checklist
CommandSessionLifecycleContextreplaces direct host access for exactly nine lifecycle handlersSigned-off-bytrailersNo-Issue: FEAT-023 is tracked in umbrella issue #5316, which remains open for the remaining EPIC-006 work.
Paulo Aboim Pinto