Skip to content

fix(llmapp): order streamed text via sealed control segments#91

Merged
sqlrush merged 3 commits into
mainfrom
spec-1.21.1-stream-ordering-fix
Jun 3, 2026
Merged

fix(llmapp): order streamed text via sealed control segments#91
sqlrush merged 3 commits into
mainfrom
spec-1.21.1-stream-ordering-fix

Conversation

@sqlrush

@sqlrush sqlrush commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

Implements spec-1.21.1 stream ordering fix.

  • routes authoritative assistant text through sealed ctrl FIFO segments
  • keeps TokenStream as preview-only with PreviewTick + Model.previewNodes
  • makes View read-only over committed scrollback + preview nodes
  • removes old per-turn markAssistantBullet path and terminal-chunk mapToRender path
  • syncs hook-local spec registry ordinal 50

Verification

  • make gate
  • go test ./internal/app/cli/llmapp
  • go test ./internal/app/cli/...
  • go test -race -count=10 ./internal/app/cli/llmapp -run TestModel_LoopAppendsToolBlocks

sqlrush added 2 commits June 3, 2026 17:01
Route authoritative assistant text through the ctrl FIFO alongside tool events.

Keep TokenStream as preview-only and make View read-only over previewNodes.

Spec: spec-1.21.1-stream-ordering-fix.md
@sqlrush

sqlrush commented Jun 3, 2026

Copy link
Copy Markdown
Owner Author

spec-1.21.1 implementation update — CI green

Implemented the R2.1 sealed-control architecture and fixed the transient CI security drift.

Implementation status

  • Authoritative assistant text now travels through the same streamControlMsg FIFO as tool/result/finish events via SealedText.
  • TokenStream is preview-only; View renders cached previewNodes and no longer drains or mutates scrollback.
  • Tool-before/after assistant text now commits as separate assistant message nodes, restoring the post-tool behavior without touching FROZEN spec-1.6.
  • Removed the old terminal mapToRender drain path and the assistantBulletPending / markAssistantBullet mechanism.

Verification

  • Local: make gate PASS.
  • Local targeted: go test -race -count=10 ./internal/app/cli/llmapp -run TestModel_LoopAppendsToolBlocks PASS.
  • PR CI: all required checks PASS on head e7fb459.
  • Security drift: GO-2026-5037 / GO-2026-5039 added to the existing stdlib allowlist window; local make vuln-check PASS and CI security PASS.

Codex local review note

No new blocking finding from the implementation diff. Permanent transcript ordering is controlled by ctrl FIFO. Preview remains best-effort/transient by design and is cleared when sealed text commits, so producer run-ahead cannot pollute scrollback.

三路 post-impl review absorb(code-reviewer APPROVE + go-reviewer
APPROVE-WITH-FIXES + codex REQUEST-CHANGES 2H)。codex H-1(regression,
按用户 verdict 标准 = HIGH):cancel-mid-segment 丢 partial assistant 文本 +
[已取消] marker —— Loop emit-error break 不发 EventFinish,partial 在
previewNodes(PreviewTick 缓存),streamDoneMsg 原 drain-discard 丢弃。修:
streamDoneMsg final-flush 从 previewNodes(+ Close 残留)恢复 partial 进
永久 scrollback(markFirstAssistant 带 ⏺)+ finishHandled flag 缺 finish 时
补 [已取消](恢复 pre-1.21.1 final-drain-preserves-text)。codex H-2:统一
isCancelledFinish predicate(FinishCancelled OR FinishError+context.Canceled)
给 marker render + snapshot adoption,防 err-cancel 覆盖 lastSnapshot。
go-reviewer MED-1:segBuf strings.Builder(O(n²)→O(n))。+ 回归测
CancelMidSegmentRecoversPartial / NormalFinishNoSpuriousCancel / H-2 snapshot。
gate 全绿 + -race -count=10。

Spec: spec-1.21.1-stream-ordering-fix.md
@sqlrush sqlrush merged commit 02a03c3 into main Jun 3, 2026
12 checks passed
@sqlrush sqlrush deleted the spec-1.21.1-stream-ordering-fix branch June 3, 2026 12:18
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