Skip to content

refactor(runtime): route CLI sessions through SDK - #1604

Merged
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/cli-session-runtime-boundary
Jul 18, 2026
Merged

refactor(runtime): route CLI sessions through SDK#1604
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/cli-session-runtime-boundary

Conversation

@limityan

Copy link
Copy Markdown
Collaborator

Summary

  • Route the CLI primary session client through the assembled Agent Runtime SDK for session lifecycle, transcript, local fork, usage generation, dialog submission/cancellation, and exact turn settlement.
  • Add scheduler-owned settlement tracking so exec --output-format stream-json does not publish a successful terminal event before Core settlement and patch output complete.
  • Move the stable session-usage DTO contract into bitfun-core-types, while retaining compatibility re-exports for existing Core consumers.

Product and architecture boundaries

  • Preserve the TUI /usage seven-field metadata schema, local-command turn persistence, markdown projection, and Peer Host/Core compatibility path.
  • Keep Core as the runtime owner/provider; the CLI consumes SDK ports and does not construct a second scheduler, persistence owner, or event owner.
  • Support local session fork only. Requests carrying remote identity fail with typed NotAvailable; this PR does not add Remote fork behavior.
  • ACP, Desktop, Server/Remote, HarmonyOS, and extension execution capabilities are not expanded by this change.

Reliability changes

  • Recover/recreate a session only for structured session NotFound; validation failures such as unknown agents remain InvalidRequest.
  • Reject duplicate active/recent turn IDs, use UUID-based remote default turn IDs, and fail closed when exact settlement evidence is unavailable.
  • Classify only actual settlement timeouts as SettlementTimedOut; other runtime failures remain SystemError.
  • Failed submissions are not recorded as settled, while queued, active, cancelled, and dropped accepted turns retain exact settlement lifecycle coverage.

Validation

  • cargo +nightly fmt --all -- --check
  • node scripts/check-core-boundaries.mjs
  • cargo +nightly check --workspace
  • cargo +nightly test -p bitfun-core --lib — 1182 passed, 0 failed, 1 ignored
  • cargo +nightly test -p bitfun-cli — 224 unit tests plus ACP, exec protocol, plugin, product assembly, and PTY integration suites passed
  • git diff --check

Existing upstream deprecation and CLI daemon dead-code warnings remain unchanged.

@limityan
limityan merged commit 8deec29 into GCWing:main Jul 18, 2026
5 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