Skip to content

fix(runtime): streamline recovery and preserve literal TUI input - #1120

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
XuPeng-SH:perf/durable-turn-boundaries
Oct 23, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
XuPeng-SH:perf/durable-turn-boundaries

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Capability assessment: Unchanged: existing CLI/Server capabilities, runtime profiles and access boundaries remain accurate; this corrects local input/recovery and removes unnecessary canonical recovery preparation.

Summary

  • Add // for literal slash conversation through the shared submission parser, preserving semantic text through guidance, rejection, Ctrl+R and recovery.
  • Preserve incompatible command/shell drafts and returned conversation as editable unsent drafts. Navigation retains edited history and its suspended original, including buffered and large pasted content.
  • Dispatch accepted client FIFO input through one typed wake. Recheck owner/Session attachment and input gates before consuming one entry; retain physical paste protection independently.
  • Classify empty canonical recovery in one snapshot and reject zero-spill pre-turn summarization before model/Offering preparation.

Related issue

Closes #624.

Related: #1100, #1119, #980, #915 remain open. General single-task semantic continuity, the 3× target, remote MatrixOne acceptance and real CLI latency acceptance remain unmet.

Change type

  • Bug fix
  • Refactor or performance improvement
  • Test
  • Documentation

User and compatibility impact

//tmp/project inspect this sends /tmp/project inspect this; //stop stays conversation. Ctrl+R preserves this intent when editing and resending. Unknown/ambiguous single-slash commands retain diagnostics with escape guidance.

Returned conversation stays recoverable alongside an existing command or shell draft. “Unsent drafts” exposes retained content after the current draft is sent or cleared. Pasted command and shell drafts retain their own submission boundaries, including their exact trailing whitespace and CRLF. Each recovered editable draft requires a fresh gesture. Navigation preserves distinct edited history and the original suspended draft; unchanged recalled messages remain in history.

Ctrl+Q queues conversation for an ordinary safe next-turn handoff. A pasted queued message can start promptly after settlement without a synthetic Enter being mistaken for a trailing pasted newline. Real terminal Enter retains its existing paste protection. After an accepted or cancelled paste, a protected Enter on the empty composer is consumed without creating a phantom draft. Intentional whitespace and explicit newlines still count as user drafts. Local drafts/queues remain process-local, with no new restart durability, configuration or schema change.

Architecture and complexity delta

  • Canonical owners: shared TUI submission parser; ChatComposer editing/history/paste state; existing client next-turn FIFO and handoff gates; inference canonical recovery; Server pre-turn compaction eligibility.
  • The FIFO retains its head until a typed wake validates owner/Session/attachment and modal, login, catalog, background-read and draft gates. One pending-wake flag controls scheduling only. Event-local provenance grants the FIFO admission exemption. Cancellation/session changes retain the head in existing recovery custody.
  • Removed synthetic Enter replay, its special first-Work-message composer staging, premature wake arming and the redundant continuation transport event. Existing continuation targets, custody identities and semantic dispatch remain authoritative. No second runtime scheduler or message ledger.
  • ChatComposer expands at most two recoverable buffers before clearing history/paste state. Unchanged history recall is omitted; exact equal expanded visible/suspended drafts are retained once. BottomPane reuses its manual unsent deque and canonical popup replacement.
  • Recovery classifies expanded raw input through ChatComposer, borrowing when no paste expansion is needed. The first fragment keeps its composer encoding/placeholders; only appended conversation fragments are decoded. This prevents hidden shell/command prefixes from absorbing returned conversation, avoids repeated slash decoding and preserves payload whitespace. Expanded reads do not consume history, suspended drafts or blobs.
  • TextArea consumes guarded empty-buffer Enter without mutation; active paste and nonempty/whitespace drafts retain newline behavior. The same helper protects popup and approval routing. No FIFO whitespace exemption or paste provenance flag.
  • Shared cheap shell syntax and the existing paste detector remain the owners of their rules. No new classifier, timer, automatic authority for manual drafts or storage projection.
  • Recovery classification reuses existing retirement, expired-owner recovery and fenced reconstruction. Nonempty recovery retains its locked boundaries; snapshot checkouts are released before acquiring those owners.

Verification

Merge base: c048e2435150af663c632dc4098b636868b36635.

  • Native Rust 1.97: cargo test --locked -p astra-cli --lib tui:: -- --test-threads=2: 2,021 passed, one existing ignore.
  • Actual Rust TSan: 2,021 passed, one existing ignore, no race report, exit 0. Nightly 2026-10-12, instrumented std via -Zbuild-std, -Zsanitizer=thread, explicit Linux target and external compiler-rt; TSAN_OPTIONS=halt_on_error=1:symbolize=0. Normal UT is separate from race evidence.
  • Incremental SCA: cargo clippy --locked -p astra-cli --all-targets -- -D warnings passed. Unchanged runtime/services all-target SCA and fourteen directly affected shell-policy/literal/attachment native+TSan consumers are reused with matching source/dependency fingerprints. Formatting and diff whitespace checks pass.
  • Public-interface QA: real key/paste/Enter/Ctrl+Q; actual /skill and /stats dispatch using the existing PTY fixture/TerminalGuard; InfoView → slash → clear → retained content; Ctrl+R repeated resend and terminal cleanup.
  • Cross-boundary controls cover pasted queue consumption without synthetic keys; repeated scheduling/exactly one pending wake; stale Session/epoch, modal, login/active turn, catalog/read, cancellation, occupied composer/pending paste; physical submission FIFO ordering; control-like raw input, duplicate accepted entries and bound continuation purpose. History controls cover unchanged/edited recall, distinct/equal/empty originals, large paste payloads and pending bytes before Up. Additional cases cover multiline pasted shell/command isolation through both Enter and Ctrl+Q, escaped slash prefixes hidden/split across placeholders, multiple paste blobs, exact CRLF/trailing whitespace, non-destructive history reads, repeated empty tail Enter without Ctrl+C cleanup, approval safety and genuine whitespace/Shift+Enter FIFO gates.
  • Database/runtime source is unchanged by the CLI follow-up. Their native/resource/race evidence and original-head online CI are reused where matching; older database integration binaries are not claimed to match the current fixture. No new database or latency experiment was run for this CLI correction.
  • Solution/design and final overall review: actual gpt-6.1-sol with xhigh reasoning. The complete PR delta was accepted with no unresolved material blockers; both follow-up findings are closed.
  • New-head CI is pending and is not claimed passed.

Historical service resource/performance scope

30 balanced A/B and B/A pairs, all 60 successful, local unoptimized fixed_default control. SQL-window totals include background work; recovery counts are identified separately from the owning SQL sequence.

Metric Base Candidate
Empty recovery SQL/protocol events 10 1
Empty recovery transactions 1 0
Full turn P80 0.689 s 0.702 s
Full turn P90 0.973 s 0.771 s
Recovery interval P90 7.519 ms 2.932 ms

Five native recovery resource controls used six fresh fixtures per revision: fresh/reused empty recovery 10→1 events, three-round recovery 12→10, absorbed three-round retirement 16→14, active primary blocker 3→3. Outcomes, mutation counts and retained WAL bytes matched (three rows/3,725 bytes for the retained chain; zero for the other cases).

These are service API controls. P80 was slightly worse. Recovery intervals exclude initial pool acquisition; neither those intervals nor SQL counts establish general whole-turn or real CLI latency improvements. No 3× or remote-database acceptance claim is made. These measurements were not rerun for CLI corrections.

Final checklist

  • Tests cover owning behavior, public dispatch and unhappy paths.
  • Public/design documentation reflects the contract and process-local limits.
  • Diff checked for credentials, private inputs and generated artifacts.
  • Conventional Commit title.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Deep review — 需要修改(1 个 P2)

审查提交:09012a877ec9b112d4316af4ed2b10f310b08a27;未使用 subagent。本轮为源码与既有验证证据审查,未修改实现、未新增或重跑测试。

确认的问题:literal slash 在“编辑上一条消息”的用户路径上丢失输入类型。详见行内 P2。

设计与增量

  • 实现:统一 submission parser、复用既有 FIFO/custody/continuation 与 canonical recovery owner 的方向合理。非空恢复保留原 retirement/reconciliation/fenced reconstruction;snapshot checkout 在调用这些 owner 前释放。未发现其他阻断性的重复状态机、存储路径或准入边界回归。零 spill 提前返回是范围清楚的准备开销优化。
  • 测试:按键、paste、Enter/Ctrl+Q、非空草稿合并、鉴权拒绝,以及单连接池恢复/retirement/删除 fence 覆盖有实际价值;但没有覆盖 semantic transcript → Ctrl+R → composer → 再提交,现有 helper/队列测试不能证明这条路径正确。
  • 文档:描述了显式 // escape,且没有把 #1100 单轮任务连续性或 3×/远端数据库/真实 CLI 性能验收标成完成。上述 issues 仍需保持开放。
  • 性能与数据库:既有证据支持空恢复 SQL/protocol events 10→1、事务 1→0,所测资源场景 mutation/WAL bytes 不增加;不等于数据库 CPU 或整体 latency 的普遍改善。30 对测量中整轮 P80 为 0.689→0.702 秒,不能声称整体加速。

审查开始前,GitHub review threads/reviews/comments 均为空,没有既有 GitHub comment 可核销。此前本地 review 的片段合并问题已修正,但本轮发现的 Ctrl+R 遗漏仍需修复。

CI:lint/check 已成功;MOI lane 在拉取 matrixone-init 镜像时遇到 HTTP 500,测试步骤未执行,多项测试被取消;live harness 尚在运行。该失败未提供本 PR 实现失败的证据,也不能视为完整 CI 已通过。

当前账号是 PR 作者,GitHub 不允许对自己的 PR 提交 REQUEST_CHANGES;此 COMMENT review 的审查结论仍为:修复该 P2 后再合并。

Comment thread crates/astra-cli/src/tui/event_loop.rs
@XuPeng-SH
XuPeng-SH force-pushed the perf/durable-turn-boundaries branch from 09012a8 to 8250f8a Compare October 23, 2026 03:10
@XuPeng-SH
XuPeng-SH merged commit 8cbabcc into matrixorigin:main Oct 23, 2026
39 of 40 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.

TUI treats any /-prefixed input as a slash command: absolute paths produce 'Unknown command' with no escape mechanism

1 participant