@zhuxixi/pi-agent-board 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/README.md +15 -8
- package/docs/SECTION_FOLDING.md +53 -0
- package/docs/superpowers/plans/2026-10-23-issue-222-attach-ready.md +290 -0
- package/docs/superpowers/plans/2026-10-28-issue-257-legacy-pty-runner-endpoint-cleanup.md +256 -0
- package/docs/superpowers/plans/2026-11-03-cwd-favorites-full-pool.md +266 -0
- package/docs/superpowers/plans/2026-11-03-issue-266-alt-h-detach.md +467 -0
- package/docs/superpowers/plans/2026-11-04-issue-270-scenario-stdout-flush.md +584 -0
- package/docs/superpowers/plans/2026-11-05-issue-278-ctrl-g-external-editor.md +381 -0
- package/docs/superpowers/plans/2026-11-06-issue-280-frame-witness-delivery.md +430 -0
- package/docs/superpowers/plans/2026-11-07-issue-284-attach-recovery.md +115 -0
- package/docs/superpowers/plans/2026-11-07-issue-284-u1-u2-trial-guide.md +39 -0
- package/docs/superpowers/plans/2026-11-08-host-restart-model-override.md +894 -0
- package/docs/superpowers/plans/2026-11-08-issue-288-cap-floor.md +51 -0
- package/docs/superpowers/plans/2026-11-09-dashboard-fold-flake.md +166 -0
- package/docs/superpowers/plans/2026-11-09-issue-273-harness-console-log-exit.md +369 -0
- package/docs/superpowers/plans/2026-11-10-issue-258-board-selection-settle.md +760 -0
- package/docs/superpowers/plans/2026-11-13-issue-294-snapshot-resize-intent.md +590 -0
- package/docs/superpowers/plans/2026-11-16-greeting-title-poll.md +838 -0
- package/docs/superpowers/plans/2026-11-22-issue-297-compaction-mirror.md +797 -0
- package/docs/superpowers/plans/2026-11-23-issue-254-cursor-keep-position.md +663 -0
- package/docs/superpowers/plans/2026-11-23-issue-95-legacy-quarantine.md +320 -0
- package/docs/superpowers/specs/2026-10-23-issue-222-attach-ready-design.md +204 -0
- package/docs/superpowers/specs/2026-10-28-issue-257-legacy-pty-runner-endpoint-cleanup-design.md +197 -0
- package/docs/superpowers/specs/2026-11-03-cwd-favorites-full-pool-design.md +106 -0
- package/docs/superpowers/specs/2026-11-03-issue-266-alt-h-detach-design.md +185 -0
- package/docs/superpowers/specs/2026-11-04-issue-270-scenario-stdout-flush-design.md +176 -0
- package/docs/superpowers/specs/2026-11-05-issue-278-ctrl-g-external-editor-design.md +185 -0
- package/docs/superpowers/specs/2026-11-07-issue-284-attach-recovery-design.md +166 -0
- package/docs/superpowers/specs/2026-11-08-host-restart-model-override-design.md +115 -0
- package/docs/superpowers/specs/2026-11-08-issue-288-cap-floor-design.md +86 -0
- package/docs/superpowers/specs/2026-11-09-dashboard-fold-flake-design.md +109 -0
- package/docs/superpowers/specs/2026-11-09-issue-273-harness-console-log-exit-design.md +182 -0
- package/docs/superpowers/specs/2026-11-10-issue-258-board-selection-settle-design.md +109 -0
- package/docs/superpowers/specs/2026-11-13-issue-294-snapshot-resize-intent-design.md +141 -0
- package/docs/superpowers/specs/2026-11-16-greeting-title-poll-design.md +174 -0
- package/docs/superpowers/specs/2026-11-22-issue-297-compaction-mirror-design.md +158 -0
- package/docs/superpowers/specs/2026-11-22-issue-95-legacy-quarantine-design.md +209 -0
- package/docs/superpowers/specs/2026-11-23-issue-254-cursor-keep-position-design.md +201 -0
- package/package.json +1 -1
- package/runner/pty-runner.mjs +526 -63
- package/runner/title-runner.mjs +33 -24
- package/src/commands/agent-board.ts +5 -1
- package/src/core/attach-detach.mjs +27 -0
- package/src/core/attach-frame-proof.mjs +897 -0
- package/src/core/attach-frame-reporter.mjs +738 -0
- package/src/core/attach-frame-stream.mjs +266 -0
- package/src/core/attach-pr-label.mjs +12 -0
- package/src/core/attach-recovery.mjs +239 -0
- package/src/core/attach-screen-owner.mjs +55 -0
- package/src/core/attach-view-proof.mjs +709 -0
- package/src/core/auto-state.mjs +6 -1
- package/src/core/cwd-stats.mjs +3 -1
- package/src/core/dashboard-prefs.mjs +31 -0
- package/src/core/derive.mjs +8 -1
- package/src/core/events.mjs +127 -1
- package/src/core/foreground-projection-cache.mjs +1 -0
- package/src/core/frame-witness-update.mjs +35 -0
- package/src/core/fullscreen-selection.mjs +60 -0
- package/src/core/host-protocol.mjs +13 -2
- package/src/core/hosted-frame-witness.mjs +60 -0
- package/src/core/paths.mjs +10 -3
- package/src/core/pty-attach-render.mjs +239 -0
- package/src/core/pty-kitty-images.mjs +237 -0
- package/src/core/rows.mjs +43 -7
- package/src/core/session-entries.mjs +82 -0
- package/src/core/session-launch-prefs.mjs +45 -0
- package/src/core/session-view.mjs +3 -63
- package/src/core/store.mjs +1 -0
- package/src/core/terminal-attach-client.mjs +199 -20
- package/src/core/terminal-attach-protocol.mjs +221 -7
- package/src/core/terminal-model.mjs +24 -3
- package/src/core/terminal-snapshot.mjs +10 -0
- package/src/core/title-flow.mjs +66 -0
- package/src/core/title.mjs +101 -0
- package/src/core/types.mjs +17 -0
- package/src/index.ts +85 -0
- package/src/runtime/service.mjs +87 -18
- package/src/ui/dashboard.ts +198 -44
- package/src/ui/pty-attach.ts +1462 -117
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Spec: #258 — board (dashboard) keeps the fullscreen selection highlight after copy-on-release
|
|
2
|
+
|
|
3
|
+
Status: DRAFT (awaiting spec-cross-review; gate=auto per authorization.md — after convergence, proceed straight to step 5 without pausing)
|
|
4
|
+
Issue: https://github.com/zhuxixi/pi-agent-board/issues/258
|
|
5
|
+
Repo baseline: `origin/main` @ `5d0c982` (local main `608a22a`; `608a22a..5d0c982` touches only dashboard-fold test files and docs — all src/ citations below were verified on `608a22a` and are unaffected). pi-tui / pi-coding-agent 1.5.1 installed runtime verified.
|
|
6
|
+
|
|
7
|
+
Drafted: zai-coding-cn/glm-5.3 (selected) · zai-coding-cn/glm-5.3 (physical) @ 2026-11-10T08:52:00+08:00
|
|
8
|
+
Revised: zai-coding-cn/glm-5.3 (selected) · zai-coding-cn/glm-5.3 (physical) @ 2026-11-10T09:02:00+08:00 — R1-G1 (shouldSettle lifecycle gate), R1-G2 (U1/U2 deployment preconditions), R1-G3 (A4 non-empty precondition + no-silent-downgrade), R1-D1 (production overlay:true), R1-D2 (A4 wrapper attribution), R1-D3 (D6 acceptance owner)
|
|
9
|
+
Revised: zai-coding-cn/glm-5.3 (selected) · zai-coding-cn/glm-5.3 (physical) @ 2026-11-10T09:38:00+08:00 — R2-D1 (board `disposed` gate + A3 unmount-race case), R2-D2 (A4 explicit command + launch flags)
|
|
10
|
+
|
|
11
|
+
## Problem (root cause, verified against source)
|
|
12
|
+
|
|
13
|
+
In fullscreen (pi ≥1.0), drag-selecting text inside the board copies on release (pi-tui copy-on-select) but the inverse-video highlight stays lit until the next mouse press.
|
|
14
|
+
|
|
15
|
+
`TuiAltScreen` owns the gesture: each decoded mouse event is dispatched to overlays/layout components first (`component.handleMouse?.(event)`), and only when nothing consumed it does pi run its own selection logic — the release path does `copySelectionToClipboard()` + `requestRender()` and does **not** reset selection state. `DashboardComponent` (`src/ui/dashboard.ts:137`) implements `handleInput` only; there is no `handleMouse` anywhere in the file, so no code ever observes the gesture ending and nothing settles it. The attach view fixed the same symptom in #172 (PR #251, `3d72b68`) by observing in its own `handleMouse`; the board has no equivalent observation point yet.
|
|
16
|
+
|
|
17
|
+
Production mount: `ctx.ui.custom<DashboardResult>(..., { overlay: true, overlayOptions: { anchor: "top-left", width: "100%", maxHeight: "100%", margin: 0 } })` (`src/commands/agent-board.ts:94-131`) — with `overlay: true`, pi's interactive mode mounts the board via `showOverlay`, so mouse events reach `DashboardComponent.handleMouse` through `TuiAltScreen`'s overlay hit-test dispatch — the same dispatch path the #172 attach fix rides. (Corrected per review R1-D1; the editor-container mounting described in JFox KB applies to `ctx.ui.custom` **without** `overlay: true`, not to this component.)
|
|
18
|
+
|
|
19
|
+
## Goal / non-goals
|
|
20
|
+
|
|
21
|
+
**Goal**: in fullscreen, once pi's copy-on-select has completed for a selection gesture that ends inside the board, drop pi's selection so the highlight disappears immediately — without changing what reaches the clipboard, without consuming any mouse event, and without breaking pi's multi-click chain (double-click word / triple-click line).
|
|
22
|
+
|
|
23
|
+
**Shared-core requirement** (from the issue's fix direction): extract the settle logic so the attach and board paths cannot drift. The attach path is refactored onto the same core with behavior preserved (its existing tests stay green, unmodified).
|
|
24
|
+
|
|
25
|
+
**Non-goals**:
|
|
26
|
+
|
|
27
|
+
- X11 PRIMARY mirroring for the board (the mirror hook stays attach-only behind `AGENT_BOARD_ATTACH_NATIVE_PASTE`; the board has no middle-click paste consumer — can be added later without touching the shared core).
|
|
28
|
+
- #250 — the legacy/regular-mode attach `shouldCopy` gap; a different code path, untouched.
|
|
29
|
+
- Selections that end outside the board's overlay box (pi transcript, other pi UI): outside the component's event window — same limitation class as #172/#174; would need an upstream event.
|
|
30
|
+
- The board's row-cursor highlight (`theme.bg("selectedBg")`): unrelated, by design stays visible.
|
|
31
|
+
- Any upstream change to pi/pi-tui; private-method access stays feature-detected with graceful degradation.
|
|
32
|
+
|
|
33
|
+
## Decisions
|
|
34
|
+
|
|
35
|
+
**D1 — shared settle core in `src/core/fullscreen-selection.mjs`.**
|
|
36
|
+
New core module exporting a `FullscreenSelectionSettler` with injected seams (repo convention: pure/testable core, thin I/O shell):
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
constructor({
|
|
40
|
+
host: FullscreenSelectionHost, // { getActiveSelectionText?, getCopyOnSelect?, clearTextSelection? } — feature-detected
|
|
41
|
+
mirror?: (text: string) => void, // attach passes its xclip write (already self-gated on its env knob); board omits
|
|
42
|
+
repaint?: () => void, // attach: scheduleRender(); board: tui.requestRender()
|
|
43
|
+
schedule?: (cb: () => void) => void, // defaults to process.nextTick; injectable for unit tests
|
|
44
|
+
shouldSettle?: () => boolean, // runtime lifecycle gate — checked inside the deferred callback BEFORE any host read/mirror/clear (R1-G1); attach passes () => !this.closed, board omits
|
|
45
|
+
})
|
|
46
|
+
observeMouse(event): void
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`observeMouse` semantics (exactly the semantics attach ships today):
|
|
50
|
+
1. `press` + `left` → bump the internal gesture serial.
|
|
51
|
+
2. `isFullscreenSelectionEnd(event)` (existing pure predicate, `src/core/pty-scroll.mjs:279` — release/click of left) → capture serial, `schedule(() => { if (serial unchanged) settle(); })`.
|
|
52
|
+
3. `settle()` order: `shouldSettle && !shouldSettle()` → return (runtime lifecycle gate, R1-G1; attach keeps its existing `!this.closed` semantics) → read `host.getActiveSelectionText?.()` → empty/absent: return → `mirror?.(text)` → `host.getCopyOnSelect?.() === false`: return (user keeps the selection for Ctrl+X) → `typeof host.clearTextSelection !== "function"`: return (older/newer runtime degrades) → `clearTextSelection()` → `repaint?.()`.
|
|
53
|
+
|
|
54
|
+
Read-before-clear is load-bearing (the #172 harness fixture invalidates text on clear to pin the order). `pty-attach.ts` refactors: delete its inline serial/defer/settle code — including the `if (this.closed) return;` first line of `settleFullscreenSelection` (`src/ui/pty-attach.ts:2433`), which moves into the `shouldSettle` option — and instantiate one settler with its existing host cast, mirror, `scheduleRender`, and `() => !this.closed`. No behavior change (R1-G1). Its `FullscreenSelectionHost` interface moves to (or is re-exported from) the core module so both components share one definition.
|
|
55
|
+
|
|
56
|
+
**D2 — gesture serial lives inside the settler.**
|
|
57
|
+
pi-tui decodes a stdin batch and dispatches events synchronously, so a release and the next press can share one tick; a settle queued on the release must not consume the next gesture's selection (this exact bug was caught in #172's local review). Bumping on left press and comparing the captured serial at run time is preserved as-is — now in one place instead of two.
|
|
58
|
+
|
|
59
|
+
**D3 — clear via `clearTextSelection()`, never `resetTextSelection()`.**
|
|
60
|
+
`resetTextSelection()` also clears `lastClick`, which `getClickCount` needs within `DOUBLE_CLICK_INTERVAL_MS = 500` — clearing it per release would break double-click word / triple-click line selection. `clearTextSelection()` drops only the visual selection state. It is `private` in pi-tui typings but a plain prototype method at runtime (verified present in the installed 1.5.1 `tui-alt-screen.js`); access stays feature-detected.
|
|
61
|
+
|
|
62
|
+
**D4 — no PRIMARY mirror for the board.**
|
|
63
|
+
The board's scope is the stale highlight only. The settler's `mirror` hook keeps attach's #174 behavior intact; the board simply does not pass one.
|
|
64
|
+
|
|
65
|
+
**D5 — dashboard wiring.**
|
|
66
|
+
- `handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined` on `DashboardComponent`: calls `this.selectionSettler.observeMouse(event)`, then **always returns `undefined`** (observe only — pi keeps every gesture, its copy and its link handling). No mode gating: the settle is about pi-level selection state and applies in every board mode.
|
|
67
|
+
- The settler is constructed in the constructor body (after the `tui` parameter property is assigned), with `repaint: () => this.tui.requestRender()` and `shouldSettle: () => !this.disposed` — non-forced repaint; content is unchanged, only pi's selection overlay goes away. (`requestRender` is already the board's seam; `dashboard.ts:1287` uses the forced variant only for full-clear cases.)
|
|
68
|
+
- The board gates on its own lifecycle too (R2-D1): a private `disposed` flag set at the top of `dispose()` (`src/ui/dashboard.ts:1266`), checked via `shouldSettle`. `done()` synchronously hides and disposes the overlay, but a settle queued before that still holds the global `TuiAltScreen` host and — if the host already carries a newer non-empty selection — the stale callback would read and clear it; the gesture serial cannot guard this (it only grows on presses the dead board still observes).
|
|
69
|
+
|
|
70
|
+
**D6 — the board's embedded `CustomEditor` rows are covered by the same observer.**
|
|
71
|
+
Mouse dispatch is hit-test-based within the board's box regardless of which sub-element sits under the cursor; if pi's editor consumes an event, the gesture never starts and there is nothing to settle. No special-casing.
|
|
72
|
+
|
|
73
|
+
## Testability split design (design constraint for the plan)
|
|
74
|
+
|
|
75
|
+
| Unit | Shape | How tested | Test boundary |
|
|
76
|
+
| --- | --- | --- | --- |
|
|
77
|
+
| `FullscreenSelectionSettler` (new, `src/core/fullscreen-selection.mjs`) | all I/O injected (host object, mirror/repaint/schedule callbacks, `shouldSettle` gate); no timers, no filesystem, no spawn | unit — fake host + manual `schedule` queue flushed by the test; no wall-clock waits | everything up to and including the `clearTextSelection()` call and the repaint trigger; gesture-serial semantics; the `shouldSettle` lifecycle gate |
|
|
78
|
+
| `DashboardComponent.handleMouse` wiring | thin shell: forward to settler, return `undefined` | component harness — child process, fake fullscreen TUI (the #172 `pty-attach-selection-mirror-scenario.ts` pattern), real `DashboardComponent` from `../src/ui/dashboard.ts`, drives `handleMouse` directly | board-side wiring only: the right events reach the settler, the return value never consumes |
|
|
79
|
+
| Real dispatch chain (TuiAltScreen → overlay → `handleMouse` → pi finalize → deferred settle) | real renderers | real-renderer harness — the `dashboard-tui-modes.ts` pattern: real `TuiAltScreen` + headless xterm + captured input callback, inject SGR mouse sequences | end-to-end within the process: synthetic SGR in, selection state cleared out |
|
|
80
|
+
| Attach behavior preservation | refactor only | existing `pty-attach-selection-mirror` tests, unmodified | regression fence for the extraction |
|
|
81
|
+
|
|
82
|
+
## Acceptance matrix
|
|
83
|
+
|
|
84
|
+
| ID | 功能点 | 验收方式 | 具体验证 | 通过标准 |
|
|
85
|
+
|----|--------|----------|----------|----------|
|
|
86
|
+
| A1 | settler 核心语义 | 自动化验证(unit) | `node --test test/fullscreen-selection.test.mjs` | 全绿:空文本不清也不镜像;`copyOnSelect=false` 不清(mirror 照跑);`clearTextSelection` 缺席不抛、不清;正常路径 clear+repaint 各一次;read-before-clear 顺序(clear 后文本失效的 fixture);同 tick release→新 press 时收尾被手势序号丢弃;`click` 事件同样触发 settle;`shouldSettle` 返回 false 时 host 读取/mirror/clear/repaint 均为零 |
|
|
87
|
+
| A2 | attach 重构行为保持(含关闭门禁)| 自动化验证(unit/component) | `node --test test/pty-attach-selection-mirror.test.mjs`(既有断言零改动;**追加**用例:release 入队 → 组件 close → flush tick → mirror 写入与 clear 调用均为 0) | 原断言全绿 + 新增关闭门禁用例全绿 |
|
|
88
|
+
| A3 | board 组件接线 | 自动化验证(integration,子进程组件 harness) | `node --test test/dashboard-selection-settle.test.mjs` | 全绿:release→flush tick→`clearTextSelection` 被调、`requestRender` 被调;press/release 同 tick 抑制;wheel/右键不触发;返回值恒 `undefined`;带嵌入 CustomEditor 的模式(filter/launch)下同一手势同样 settle 且返回恒 `undefined`(D6 归属,R1-D3);release 入队 → `dispose()` → host 换上新选区 → flush 后 host 读取/mirror/clear/repaint 均为零(卸载竞态,R2-D1) |
|
|
89
|
+
| A4 | 真派发链路(overlay 路径,与生产一致)| 自动化验证(integration,real renderer + headless xterm) | `node --test test/dashboard-tui-modes.test.mjs`(**新增 wrapper**,内部沿用 `test/dashboard-fold.test.mjs:27` 的启动方式:`node --experimental-transform-types test-support/dashboard-tui-modes.ts`,R2-D2;原 fold wrapper 不改动,R1-D2) | 渲染已知文本 → SGR press/drag → **先断言非空选区存在**(`getActiveSelectionText()` 非空或反色单元,R1-G3)→ release → flush nextTick → 同一选区被清且 repaint 发生;降级规则:合成 SGR 驱动不了 headless 选区时,fallback 必须仍经真实 `TuiAltScreen` 派发缝断言 finalize→deferred settle→clear 顺序与终态,否则 A4 记**未满足**(不得降级通过,U1 门保留) |
|
|
90
|
+
| A5 | 全量回归门 | 自动化验证(build) | `npm run verify` | exit 0(typecheck、perf、tests、coverage、pack:dry) |
|
|
91
|
+
| U1 | board 拖选复制后高亮即清 | 用户实测 | 按「部署前置」更新真实加载 checkout 并重启 pi 后:fullscreen 打开 board,拖选会话名/日志行后松开 | 内容已复制(CLIPBOARD 粘贴验证:Ctrl/Cmd+V;不依赖 board 未实现的 PRIMARY 中键粘贴),反色高亮立即消失,无需下一次点击 |
|
|
92
|
+
| U2 | 双击/三击不受影响 | 用户实测 | 在 U1 的同一已更新实例上:500ms 内双击单词、三击某行 | 选词/选行照常发生并复制,高亮随后清除 |
|
|
93
|
+
|
|
94
|
+
**U1/U2 部署前置(可执行时机,R1-G2)**:pi 通过 `git:github.com/zhuxixi/pi-agent-board` 从独立 checkout `~/.pi/agent/git/github.com/zhuxixi/pi-agent-board` 加载本扩展(`~/.pi/agent/settings.json` extensions 块),当前工作副本不是加载路径。PR 合并后:`git -C ~/.pi/agent/git/github.com/zhuxixi/pi-agent-board restore package-lock.json`(或 stash——该 checkout 2026-11-10 存在 package-lock.json 本地脏改动,在案)→ `git -C … pull --ff-only` → 完全退出并以 fullscreen 模式重启 pi → `/agent-board`。
|
|
95
|
+
|
|
96
|
+
若某项无法自动化:A1–A5 均有既有同类先例(#172 的 mirror 场景、dashboard-tui-modes 的真渲染 harness),无预期障碍;A4 的降级边界已写入矩阵(fallback 仍须走真实派发缝断言时序与终态;只证明"handleMouse 被派发到"不够,A4 记未满足、U1 门保留),不允许静默降级为只跑 A3。
|
|
97
|
+
|
|
98
|
+
## Boundaries / risks
|
|
99
|
+
|
|
100
|
+
- Observation covers the overlay's hit-test box (≈ the screen). Selections released outside it keep pi's behaviour — no seam exists.
|
|
101
|
+
- Production and the A4 harness mount the board identically as a fullscreen overlay (`overlay: true`, `src/commands/agent-board.ts:127-131`; harness `test-support/dashboard-tui-modes.ts:61-63`) — A4 exercises the production dispatch path directly (R1-D1 correction; no separate "layout path" exists for this component).
|
|
102
|
+
- A settle queued before unmount is stopped by the `disposed` gate (R2-D1); without it the stale callback would still hold the global `TuiAltScreen` host and could clear a newer UI's selection.
|
|
103
|
+
- No wall-clock-sensitive waits are introduced (one nextTick deferral, same as attach) — nothing new for the #95 realtime-budget ledger.
|
|
104
|
+
|
|
105
|
+
## Supersedence / relations
|
|
106
|
+
|
|
107
|
+
- Mirrors #172 (attach, merged `3d72b68`) onto the board; shares its core going forward.
|
|
108
|
+
- #250 (legacy/regular attach) remains separate.
|
|
109
|
+
- #174's deferred-selection hook contract is preserved unchanged on the attach path.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Spec: #294 — snapshot-carried target F must satisfy the resize intent
|
|
2
|
+
|
|
3
|
+
Status: DRAFT (rev 4, post round-3 cross-review; no authorization.md → gate=stepwise: after convergence, PAUSE for user design confirmation before step 5)
|
|
4
|
+
Issue: https://github.com/zhuxixi/pi-agent-board/issues/294
|
|
5
|
+
Repo baseline: local main `3815dea` at drafting; `750b854` (post-#293 merge) at round-1 review — the delta touches only dashboard selection code, not the attach paths cited here. Implementation re-pins `origin/main` before the worktree and records the SHA. Pi 1.5.1 runtime.
|
|
6
|
+
Research artifacts: `~/.github-issue-driven/zhuxixi/pi-agent-board/issue-294/research/` (repro programs + outputs + research-summary.md).
|
|
7
|
+
|
|
8
|
+
Drafted: zai-coding-cn/glm-5.3 (selected) · zai-coding-cn/glm-5.3 (physical) @ 2026-11-12T08:57:00+08:00
|
|
9
|
+
Revised: zai-coding-cn/glm-5.3 (selected) · zai-coding-cn/glm-5.3 (physical) @ 2026-11-12T09:20:00+08:00 — R1-G1 (ordinary-F0-in-capture shape: intent evidence + gate bypass), R1-G2 (U1 diagnostics criterion rewritten to real event shapes), R1-D1 (repro seq fix + new repro variants), R1-D2 (dropped the false subset claim), R1-D3 (A4 scope + real-Pi skip semantics)
|
|
10
|
+
Revised: zai-coding-cn/glm-5.3 (selected) · zai-coding-cn/glm-5.3 (physical) @ 2026-11-12T09:52:00+08:00 — R2-G1 (sticky intent evidence; `invalidateViewProof` stops clearing it; real S0→F0 frame sequences in A2c/repro), R2-G2 (bypass head restricted to ordinary 0/0 + wrong-nonzero negatives), R2-D1 (live aggregation wording = actual lifecycle), R2-D2 (stale-evidence negative moved to A1b unit level), R2-D3 (harness protocolError readout + observable assertions)
|
|
11
|
+
Revised: zai-coding-cn/glm-5.3 (selected) · zai-coding-cn/glm-5.3 (physical) @ 2026-11-12T10:18:00+08:00 — R3-G1 (live match reuses the same pure predicate: full validation incl. target dims; live wrong-dims mixed negative added to A3), R3-D1 (harness coverageHead readout summary + protocolError via handleAttachEvent wrapper; A2c head assertions)
|
|
12
|
+
|
|
13
|
+
## Problem (root cause, verified against source)
|
|
14
|
+
|
|
15
|
+
A differing-size attach can stay on the loading surface past the 2500 ms cap even when the client already holds a complete committed view at the target geometry, `covered` proof, and a matching target-geometry F **inside `snapshotReady.viewProofRecords`**. Root cause chain, verified on `3815dea` (line numbers from that SHA):
|
|
16
|
+
|
|
17
|
+
1. A differing resize arms the intent: `noteGeometryIntent` (`src/ui/pty-attach.ts:2523-2553`) sets `resizeIntentRequired = true`, `resizeIntentId = geometryRevision`, `resizeIntentSatisfied = false`.
|
|
18
|
+
2. While the attach client is `collecting`, `view_proof` records are buffered into `partial.viewProofRecords` instead of emitted live (`src/core/terminal-attach-client.mjs:708-713`); the runner interleaves queued S/F/A records into the snapshot stream around catch-up chunks (`src/core/terminal-attach-protocol.mjs:163-208`, `flushCaptureViewProofRecords`) — so a target F **does** reach the client inside the snapshot.
|
|
19
|
+
3. `snapshotReady` stores those records but unconditionally resets `this.resizeIntentSatisfied = false` (`src/ui/pty-attach.ts:2918`) — it never derives satisfaction from the validated snapshot-carried records.
|
|
20
|
+
4. Only the later live-record path updates the flag (`src/ui/pty-attach.ts:2987-2990`) — and `invalidateViewProof` (`:1520-1525`) clears it again on every transient coverage invalidation: a live **S** record (the mandatory start of every real ordinary frame, `noteViewProofRecord(S)` → `invalidateViewProof("candidate-open")`, `:1553`), aborts, trailing-unsafe output, replay gaps. So even a live-delivered target F's satisfaction does not survive the next frame's S marker (R2-G1).
|
|
21
|
+
5. The reporter consumes the intent after writing its first matching F and later frames fall back to `intentId=0` (`src/core/attach-frame-reporter.mjs` `#emitF`, `consumeIntentOnce()` → `setIntent(null)`; ordinary post-intent metadata is `intentId: decision.intentId ?? 0, geometryRevision: decision.geometryRevision ?? 0` via `metadataFor`, `src/core/attach-frame-proof.mjs:643-656`).
|
|
22
|
+
6. The runner's snapshot coverage head is the *newest* completed proof at or before the snapshot seq (`findNewestProofAtOrBefore`, `src/core/attach-view-proof.mjs:470-476`; `coverageFor` `:599-648`) — a capture window containing the target F **and** a later ordinary frame yields `covered` coverage whose head is the ordinary F0 (`intentId=0, geometryRevision=0`). The full chain then waits `geometry-revision`/`resize-intent` on the head's metadata (`requiredGeometryRevision` mismatch fires first, `src/core/pty-attach-render.mjs:252-257`), and the degraded chain refuses any armed intent. After the cap only the reason prefix changes.
|
|
23
|
+
|
|
24
|
+
Deterministic component reproductions (virtual clock, real `PtyAttachComponent` + real client messages, no production changes; all three STUCK on main, outputs in `research/`):
|
|
25
|
+
|
|
26
|
+
- `repro-bug.json` — resnapshot carrying `records=[F(intentId=1, geometryRevision=1, 100x30)]` + `covered/exact-proof` head = that F + committed 100x30 view → waits `resize-intent` → cap expires; legal `output seq=3` + live F0 afterwards does not rescue (coverage becomes `covered/safe-trailing` head F0, still locked).
|
|
27
|
+
- `repro-f0-head.json` — records `[F1, F0]` at the same seq (protocol-legal double proof per chunk; the harness's single-frame snapshot model requires `nextSeq = beginSeq + 1` and no flush, per `finishCollecting`, `terminal-attach-client.mjs:556-596`), end coverage head = F0 → same lock (the capture-window shape, step 6).
|
|
28
|
+
- `repro-live-f0-after.json` — resnapshot with F1 in records, then the **real ordinary frame sequence** `output seq=3` → live `S0` → live `F0` → coverage `covered/safe-trailing` head F0, satisfaction cleared by the S0 (step 4) → same lock.
|
|
29
|
+
|
|
30
|
+
Control (live-delivered target F, no subsequent frame before evaluation) settles at once: `readyReason=complete, settledAt=0` (`repro-control.json`).
|
|
31
|
+
|
|
32
|
+
Archaeology: the unconditional reset was introduced by `936f46e` (PR #265), before the #284 recovery-budget redesign that added the live-only derivation; PR #285 discussion and issues #284/#288 contain no decision that snapshot-carried records must not satisfy the intent — an oversight, not a safeguard.
|
|
33
|
+
|
|
34
|
+
## Fix design
|
|
35
|
+
|
|
36
|
+
Three coordinated changes: (1) derive intent satisfaction — and a separately carried **intent-proof seq** — from validated snapshot records; (2) make that evidence **sticky** (immune to transient coverage invalidations, cleared only by a superseding intent or baseline recompute); (3) let the untouched full-view gate accept an *ordinary* later coverage head when the intent evidence is fresh enough. No runner or protocol changes; the reporter is untouched; the degraded chain is untouched.
|
|
37
|
+
|
|
38
|
+
### 1. Pure predicate (new): `resizeIntentEvidenceFromRecords(intent, records)`
|
|
39
|
+
|
|
40
|
+
Location: `src/core/pty-attach-render.mjs` (the attach presentation-policy module that already hosts `decideAttachPresentation` and imports `validateFrameMetadata`). Serves **both** evidence sources: the `snapshotReady` recompute (whole records array) and the live-record branch (single-record array) — one matcher, no divergent semantics.
|
|
41
|
+
|
|
42
|
+
Returns `{ satisfied: boolean, proofSeq: number | null }`:
|
|
43
|
+
|
|
44
|
+
- `intent.required !== true` → `{ satisfied: true, proofSeq: null }` (vacuous, mirroring the live path's `!this.resizeIntentRequired || …`; no evidence needed).
|
|
45
|
+
- Otherwise scan `records` (only when it is an array) and keep the **highest-seq** element satisfying ALL of:
|
|
46
|
+
- non-null object with `marker === "F"`;
|
|
47
|
+
- `Number.isInteger(seq) && seq >= 1`;
|
|
48
|
+
- `validateFrameMetadata(metadata).ok === true` (strict 10-field whitelist, `protocol === 1`);
|
|
49
|
+
- `metadata.value.geometryRevision === intent.geometryRevision`;
|
|
50
|
+
- `metadata.value.intentId === intent.intentId` (component `intentId ≥ 1` by construction, so intent-0 records can never match);
|
|
51
|
+
- `metadata.value.cols === intent.cols && metadata.value.rows === intent.rows` (target-dimension match).
|
|
52
|
+
- Any element failing any condition is simply not evidence; empty/absent/malformed records yield `{ satisfied: false, proofSeq: null }` (fail-closed). Highest-seq choice maximizes freshness against the coverage `throughSeq` used below.
|
|
53
|
+
|
|
54
|
+
The predicate re-validates metadata even though the client already sanitized the records: pure testability without the sanitizer, defense in depth, and no reliance on the caller's slice/cap behavior. Ring-cap drops (`viewProofRecordsDropped`) need no special case: a dropped target F is simply absent.
|
|
55
|
+
|
|
56
|
+
### 2. Component state: sticky `resizeIntentSatisfied` + `resizeIntentProofSeq`
|
|
57
|
+
|
|
58
|
+
The pair represents one validated fact — "the armed intent's target frame was proven at seq k" — and its lifecycle is explicit:
|
|
59
|
+
|
|
60
|
+
| Event | `resizeIntentSatisfied` / `resizeIntentProofSeq` |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| `noteGeometryIntent` (differing resize; `:2523-2553`) | cleared to `false` / `null` (a superseding intent invalidates the old fact) |
|
|
63
|
+
| `snapshotReady` (`:2918`) | **recomputed** from the accepted baseline's `records` via the predicate (supersedes any prior value — an empty/record-less baseline yields `false`/`null`, fail-closed) |
|
|
64
|
+
| live `viewProofRecord` F (`:2987-2990`) | **re-evaluated through the same pure predicate** with the single record — matching means full validation (marker F, integer seq ≥ 1, `validateFrameMetadata`, `geometryRevision`, `intentId`, **and target cols/rows**; single-source matching semantics, no revision/intent-only shortcut). Match → set `true` / that record's `seq` (upgrade); no match → untouched |
|
|
65
|
+
| live non-matching F, live S, live A | **untouched** |
|
|
66
|
+
| `invalidateViewProof` (`:1520-1525`) | **no longer touches the pair** — its `this.resizeIntentSatisfied = false` line is removed (production behavior change; S/A/trailing-unsafe/replay-gap/`generation-change`/`new-empty-baseline` invalidations are transient coverage facts, not intent facts). Safety: none of those paths can publish anyway — publishing requires `covered` coverage re-established in the current baseline, whose `snapshotReady` recompute or live match re-derives the evidence; `frameState`/`sync-open`/identity gates are untouched |
|
|
67
|
+
| capability loss / reporter-replaced | untouched (coverage goes UNKNOWN; the full chain cannot publish without `covered` coverage) |
|
|
68
|
+
|
|
69
|
+
Snapshot-carried records never pass through `noteViewProofRecord` (they are stored, not processed), so an S inside `records` is inert by construction — the S0 hazard exists only on the live path, which the table above handles.
|
|
70
|
+
|
|
71
|
+
Wiring changes in `src/ui/pty-attach.ts`: the `snapshotReady` reset line becomes the predicate call (sited exactly at the old reset, **after** the `records-without-coverage` resync guard, whose semantics are unchanged); the live-record branch calls the predicate with `[record]` and sets both fields only on a match (no reassignment on a non-match — a wrong-size live F is not evidence, exactly like a wrong-size snapshot record); `noteGeometryIntent` clears both; `invalidateViewProof` drops its reset line; the publication-facts assembly (≈ `:1680-1684`) passes `resizeIntentProofSeq` alongside `resizeIntentSatisfied`.
|
|
72
|
+
|
|
73
|
+
### 3. Full-view gate bypass: intent evidence vs an **ordinary** coverage head (R2-G2)
|
|
74
|
+
|
|
75
|
+
In `fullViewDecision` (`src/core/pty-attach-render.mjs`), the checks that compare the **coverage head's metadata** against the armed intent —
|
|
76
|
+
|
|
77
|
+
- `metadata.value.geometryRevision !== state.requiredGeometryRevision → wait("geometry-revision")`, and
|
|
78
|
+
- (under `resizeIntentRequired`) `metadata.value.intentId !== state.intentId || intentId === 0 → wait("resize-intent")`
|
|
79
|
+
|
|
80
|
+
— gain one shared alternative, evaluated only when **all** of the following hold (anything else fails closed to the existing waits):
|
|
81
|
+
|
|
82
|
+
1. `state.resizeIntentRequired === true && state.resizeIntentSatisfied === true`;
|
|
83
|
+
2. `Number.isInteger(state.resizeIntentProofSeq)`;
|
|
84
|
+
3. `state.resizeIntentProofSeq <= coverage.throughSeq` (the intent proof is inside the covered window — freshness);
|
|
85
|
+
4. the coverage head is an **ordinary** frame: structurally valid F with `metadata.value.intentId === 0 && metadata.value.geometryRevision === 0` — the exact metadata shape every post-intent ordinary frame carries (`metadataFor` defaults). A head with **wrong non-zero** revision/intent (e.g. from another intent generation) is NOT ordinary and keeps waiting under the existing checks;
|
|
86
|
+
5. the head's frame geometry matches the target: `metadata.value.cols === state.targetCols && metadata.value.rows === state.targetRows` (redundant with the chain's earlier `proof-geometry-mismatch` check, restated so the bypass is self-contained).
|
|
87
|
+
|
|
88
|
+
Semantics: the armed intent was provably completed by the validated target F (evidence ≤ head); an ordinary later frame at the same target size can only depict the same-or-fresher target-geometry view, and its 0/0 metadata is exactly the post-consumption shape. The wrong-size, stale (`proofSeq > throughSeq`), wrong-non-zero-revision/intent, missing-evidence cases all keep waiting with the existing reasons (gate order: `proof-geometry-mismatch` → `geometry-revision` → `resize-intent`).
|
|
89
|
+
|
|
90
|
+
Untouched: `degradedViewDecision` (an armed intent still blocks the degraded chain — existing #284 semantics; the full path with evidence covers this issue's shapes), the resync guard, the reporter's intent consumption, the runner protocol, and `noteGeometryIntent`'s arming.
|
|
91
|
+
|
|
92
|
+
This design covers all three lock shapes above, including the live `S0 → F0` frame sequence after the snapshot (A2c) — the S0 no longer erases the snapshot-derived evidence, and the F0 head is ordinary at target dims.
|
|
93
|
+
|
|
94
|
+
## Testability split design
|
|
95
|
+
|
|
96
|
+
| Unit | Kind | Boundary |
|
|
97
|
+
| --- | --- | --- |
|
|
98
|
+
| `resizeIntentEvidenceFromRecords` | pure function, `src/core/pty-attach-render.mjs` | Unit-tested directly (`test/pty-attach-render.test.mjs`) with literal intents/records — no component, no client, no clock. |
|
|
99
|
+
| `fullViewDecision` bypass | pure decision chain, same module | Unit-tested via decision states (`test/pty-attach-render-decision.test.mjs`) — no component. |
|
|
100
|
+
| Component lifecycle + wiring | small changes in `PtyAttachComponent` | Driven through the existing real-path harness `test-support/attach-recovery-scenario.ts` (real `onSocketData` protocol lines, real client state machine, virtual clock) in `test/attach-recovery-component.test.mjs`. The harness gains one observability field (see below). |
|
|
101
|
+
| Runner / protocol | untouched | Existing suites keep pinning them; `npm run verify` runs the full set (real-Pi suite enumerated but skipped unless `PI23B1_REAL_PI=1` — see A4). |
|
|
102
|
+
|
|
103
|
+
Harness changes (R2-D3 + R3-D1): `test-support/attach-recovery-scenario.ts` collects attach-client `protocolError` events (via a wrapper on the component's `handleAttachEvent` channel — the same channel the component itself uses, `installSpy`-style; the client exposes no public `on()` seam to rely on) and exposes `protocolErrorCount` + codes in the step readout; the readout additionally gains a bounded `coverageHead` summary (`latestViewProof.proof` → `{ seq, frameId, intentId, geometryRevision, cols, rows }` or `null`), so "the coverage head became that F0" is assertable directly. Both listed in the test impact inventory.
|
|
104
|
+
|
|
105
|
+
## Acceptance matrix
|
|
106
|
+
|
|
107
|
+
| ID | 功能点 | 验收方式 | 具体验证 | 通过标准 |
|
|
108
|
+
|----|--------|----------|----------|----------|
|
|
109
|
+
| A1a | 纯谓词判定语义 | 自动化验证(unit) | `node --test test/pty-attach-render.test.mjs` 新增用例:satisfied+proofSeq=最大匹配 seq(匹配 F / required=false / 混合记录含匹配 F);false+null(仅 S/A、revision 错、intentId 错(0 或异值)、cols/rows 错、metadata 非法(多余字段/protocol≠1/非整数)、seq 非法、空数组、非数组、null 元素) | 全部断言通过 |
|
|
110
|
+
| A1b | full 链 bypass 语义 | 自动化验证(unit) | `node --test test/pty-attach-render-decision.test.mjs` 新增 decision-state 用例:放行(satisfied+proofSeq≤throughSeq+头 0/0 目标尺寸);不放行(无 evidence/未 satisfied → 原 reason;proofSeq>throughSeq → 原头检查 reason;头尺寸错 → proof-geometry-mismatch;**头 wrong-non-zero revision → geometry-revision**;**头 wrong-non-zero intent → resize-intent**——后两条前置有效 F1 证据,钉 R2-G2);头即目标 F(intent metadata 匹配)走原路径 | 全部断言通过 |
|
|
111
|
+
| A2a | 快照携带目标 F、coverage 头即目标 F | 自动化验证(integration,component + 真实 client 消息 + 虚拟时钟) | `node --test test/attach-recovery-component.test.mjs`(= repro-bug 前半形状):resnapshot 携带匹配 F 记录 + covered/exact-proof(目标 F) + committed 100x30 complete | resnapshot 步后 `attaching=false`、`readyReason=complete`、`settledAt=0`;`advance 2500` 后仍 settled |
|
|
112
|
+
| A2b | 快照窗口含目标 F + 普通 F0,coverage 头=F0 | 同上 | records=[F1, F0](同 seq 双 proof,= repro-f0-head),end coverage=covered 头 F0 | 同 A2a 通过标准(settle complete) |
|
|
113
|
+
| A2c | 快照后真实普通帧序列 `output → live S0 → live F0` 覆盖 coverage | 同上 | = repro-live-f0-after:resnapshot(F1 in records) → `output seq=3` → live `S0(seq=3)` → live `F0(seq=3)`;readout 断言 `protocolErrorCount===0` 且 `viewProofRecordCount` 递增;S0 后 `latestViewProof=unknown/candidate-open`,F0 后 `coverageHead={seq:3, intentId:0, geometryRevision:0, cols:100, rows:30}`(R2-D3/R3-D1) | settle complete;protocolErrorCount=0 |
|
|
114
|
+
| A3 | 负面语义不放松(集成层) | 同上 | ①records 携带 wrong-dims F / wrong-revision F / wrong-intent F(其余同 A2a)→ 仍锁;②无 evidence 时 live S0→F0 序列 → 仍锁(现行为);③二次 differing resize 后旧 evidence 失效(noteGeometryIntent 清除)→ 等待新 target F;④**live 混合序列(R3-G1)**:空 records resnapshot → live wrong-dims F1(revision/intent 匹配、cols 错,T8 已证可经真实 client 形成 covered proof)→ output → S0 → 目标尺寸 ordinary F0 → 不发布;⑤随后 live 匹配 F 仍可救活(正对照) | 各自在 250ms 与 2500ms 处仍 `attaching=true`、`notReadyReason` 按门序(resize-intent / geometry-revision / proof-geometry-mismatch → `deadline-expired:*`);正对照 settle complete |
|
|
115
|
+
| A4 | 全量回归门 | 自动化验证(build) | `npm run verify` = typecheck + perf gate + tests + coverage + pack:dry(package.json `verify` 脚本) | exit 0。real-Pi 套件(`test/attach-frame-witness.real.test.mjs`)默认 `test.skip`,不计为证据;如需真实拓扑证据另跑 `PI23B1_REAL_PI=1 node --test test/attach-frame-witness.real.test.mjs` 并记录。已知例外:共享 runner 上 `attach-entry-22` 200ms 墙钟断言慢性 flaky(#95 在案)——本地 verify 必须过;CI 失败仅允许重跑对拍,不得削弱断言 |
|
|
116
|
+
| U1 | 真实 differing-size attach 不再卡死 | 用户实测 | 部署前置(合并后):`git -C ~/.pi/agent/git/github.com/zhuxixi/pi-agent-board restore package-lock.json`(该 checkout 有在案 package-lock 脏改动)→ `git -C … pull --ff-only` → 完全退出并重启 pi → 对一个有输出的后台会话,以与创建时不同的终端尺寸 attach,必要时制造 capture 窗口内连续输出(如让会话正在流式输出时 attach)。回填时记录所检查的 view、budgetDeadline 与部署 SHA(R2-P1) | 内容在 2500ms 内(通常即时)展示。诊断判据(读 `~/.pi/agent/agent-board/views/<view>/diagnostics.jsonl`,按同一 attach 的 budgetDeadline 关联事件):① 该 attach 存在 `attach_settle_ready` 且 `details.readyReason="complete"`;② 该 attach 无 `attach_wait_expired` `details.phase="cap"` 事件(注意:cap 事件的 `notReadyReason` 恒为 `deadline-expired:waiting-for-complete-frame`,在发送前固定(`pty-attach.ts` `handleAttachHardTimeout`),`resize-intent` 只出现在 `phase="budget"` 事件——**不得**用 cap+resize-intent 筛选,那匹配不到任何事件);③ `phase="budget"` 且 proof facts 为 covered 的等待必须有同 attach 的后续 settle,否则记失败;④ 同尺寸 re-attach 即时(既有 workaround 路径不回归) |
|
|
117
|
+
|
|
118
|
+
A1a/A1b/A2/A3 均有直接先例(`pty-attach-render.test.mjs` / `pty-attach-render-decision.test.mjs` 的既有纯用例、T8 geometry-gate 场景),无预期障碍;U1 依赖合并后的部署前置,PR 期间以 A1–A4 为门,U1 在合并后执行并回填结果。
|
|
119
|
+
|
|
120
|
+
## Non-goals / out of scope
|
|
121
|
+
|
|
122
|
+
- **No gate weakening for bad proofs**: wrong-size / wrong-revision / wrong-intent evidence, stale evidence (`proofSeq > throughSeq`), wrong-**non-zero**-revision/intent coverage heads even when valid evidence exists, empty baselines, unfinished frames keep waiting exactly as today (A1b/A3 pin these). The bypass admits exactly one new fact: validated intent evidence *inside the covered window* plus an **ordinary (0/0)** coverage head at target dims.
|
|
123
|
+
- No changes to the degraded chain (armed intent still blocks it), the reporter's intent consumption, the resync guard, the runner protocol, or `noteGeometryIntent`'s arming.
|
|
124
|
+
- The sticky-evidence lifecycle deliberately does NOT cover: evidence surviving across `epochReset` semantics beyond what the current baseline recompute provides (an epoch reset nulls the committed view and the next accepted snapshot recomputes the evidence — no extra handling).
|
|
125
|
+
- Main-branch CI flakiness (#95, `attach-entry-22` wall-clock budget on shared runners) is tracked separately and explicitly not addressed here.
|
|
126
|
+
|
|
127
|
+
## Risks / guarantees
|
|
128
|
+
|
|
129
|
+
- **Guarantee (single-source matcher)**: both evidence sources — snapshot records and live records — go through the **same pure predicate** with identical per-record validation (marker, seq, strict metadata whitelist, revision, intent, target dims); no revision/intent-only shortcut exists anywhere. **Aggregation semantics (actual, R2-D1)**: snapshot derivation is per-baseline existential (highest-seq match, recomputed at each accepted `snapshotReady`); live derivation is set-on-match / untouched-otherwise; both share the sticky lifecycle table above. No subset/equivalence relation between paths is claimed — publication safety rests on the untouched coverage/identity/seq/frameState gates plus the bypass's own conditions (evidence freshness `proofSeq ≤ throughSeq`, ordinary 0/0 head, target dims). No missing, stale, wrong-size, wrong-non-zero-revision or wrong-intent proof can publish (A3④ pins the live wrong-size mixed sequence).
|
|
130
|
+
- Behavior change surface: `invalidateViewProof` no longer clears `resizeIntentSatisfied` (sticky evidence). This is intentional and pinned by A2c (S0 must not erase snapshot-derived evidence) and A3② (without evidence, S0/F0 still waits as today). The existing suites that pin `invalidateViewProof`'s coverage effects are untouched.
|
|
131
|
+
- This area has a revert history (#263): the production diff stays minimal — one pure predicate, gate-bypass logic in the pure decision module, four small component touches (reset line, live-record branch, `invalidateViewProof` reset removal, facts assembly), one harness observability field, tests.
|
|
132
|
+
- Coverage thresholds (`npm run verify`) apply unchanged.
|
|
133
|
+
|
|
134
|
+
## Test impact inventory
|
|
135
|
+
|
|
136
|
+
- `src/core/pty-attach-render.mjs` — add `resizeIntentEvidenceFromRecords`; extend `fullViewDecision` with the shared intent-evidence alternative (ordinary-head restricted).
|
|
137
|
+
- `src/ui/pty-attach.ts` — replace the `snapshotReady` reset line with the predicate call; the live-record branch calls the predicate with `[record]`; clear both in `noteGeometryIntent`; remove the reset line from `invalidateViewProof`; pass the field in the facts assembly.
|
|
138
|
+
- `test-support/attach-recovery-scenario.ts` — collect attach-client `protocolError` events (handleAttachEvent wrapper) into the readout (`protocolErrorCount`); add the bounded `coverageHead` summary to the readout.
|
|
139
|
+
- `test/pty-attach-render.test.mjs` — A1a.
|
|
140
|
+
- `test/pty-attach-render-decision.test.mjs` — A1b (incl. wrong-non-zero head negatives).
|
|
141
|
+
- `test/attach-recovery-component.test.mjs` — A2a/A2b/A2c/A3.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Spec: #295 — greeting first message must not freeze the session title
|
|
2
|
+
|
|
3
|
+
Status: DRAFT (rev 4, post round-3 cross-review; 1 gap + 3 details accepted, 5 passes) — gate=design-only per `../authorization.md`: after convergence, PAUSE once for user design confirmation, then push/PR/CR-fix loop runs automatically until the merge decision.
|
|
4
|
+
Issue: https://github.com/zhuxixi/pi-agent-board/issues/295
|
|
5
|
+
Repo baseline: local main `750b854` (post-#293 merge). Pi 1.5.1 runtime. Implementation re-pins `origin/main` in the worktree and records the SHA.
|
|
6
|
+
Plan provenance: @SummerZuo's fix plan (issue comment) — endorsed by the maintainer; this spec turns it into a verifiable design.
|
|
7
|
+
Research artifacts: `~/.github-issue-driven/zhuxixi/pi-agent-board/issue-295/research/` (research-summary.md).
|
|
8
|
+
|
|
9
|
+
Drafted: zai-coding-cn/glm-5.3 (selected) · zai-coding-cn/glm-5.3 (physical) @ 2026-11-13T08:45:00+08:00
|
|
10
|
+
Revised: zai-coding-cn/glm-5.3 (selected) · zai-coding-cn/glm-5.3 (physical) @ 2026-11-13T09:05:00+08:00 — R1-G1 (greedy longest-match tokenizer so multi-word/multi-char greetings actually match; A1 explicit phrase cases), R1-G2 (unified `commitMeta` dep), R1-G3 (`resolveTitleSettings` pure resolver owning both env vars + precedence; flow is env-free; `enabled:false` exits before polling), R1-G4 (A4 failure branches: empty/null/fallback outputs, readMeta null, rename during pending one-shot, rejection propagation), R1-G5 (U1 deployment preconditions: loaded checkout, pull, SHA record, full restart, provider auth), R1-G6 (last-line extraction preserved in `generateOnce`; multiline cases in A4), R1-D1 (honest shell coverage + hermetic runner smoke test A6 with new fixture), R1-D2 (U1③ reordered to actually reach the guard)
|
|
11
|
+
Revised: zai-coding-cn/glm-5.3 (selected) · zai-coding-cn/glm-5.3 (physical) @ 2026-11-13T09:25:00+08:00 — R2-G1 (consume rule rewritten as whole-string greedy consumption without per-unit trailing boundary, so `你好呀`/`嗨嗨` match and the duplicate rule is subsumed; A1 gains no-separator negatives `helloX`/`你好请修复`), R2-D1 (U1 precondition now runs a one-shot with the explicit resolved title model/thinking instead of relying on VERIFY.md §2's default-model check)
|
|
12
|
+
Revised: zai-coding-cn/glm-5.3 (selected) · zai-coding-cn/glm-5.3 (physical) @ 2026-11-13T09:50:00+08:00 — R3-G1 (greeting-first grammar: the first consumed unit must be a GREETINGS entry; PARTICLES may only follow; A1 adds bare-particle and particle-first negatives), R3-D1 (U1① timing anchored to the substantive message send, ~30s window), R3-D2 (A6 spawns the fixture via `piCommand: process.execPath` + `piArgsPrefix: [fixture]` per the repo's hermetic pattern), R3-D3 (one-shot health judgment aligned with VERIFY.md: exit 0 + assistant `message_end` + `agent_end` + no auth errors)
|
|
13
|
+
|
|
14
|
+
## Problem (root cause, verified on `750b854`)
|
|
15
|
+
|
|
16
|
+
A session whose first user message is a bare greeting (`hello` / `hi` / `你好`) keeps a useless title ("Simple greeting") forever:
|
|
17
|
+
|
|
18
|
+
1. `queueGeneratedTitle(meta, prompt)` has a single call site — the dispatch path (`src/runtime/service.mjs:2083`); replies never re-trigger it.
|
|
19
|
+
2. `runner/title-runner.mjs` generates the title **once**, from that first prompt, via a one-shot model call.
|
|
20
|
+
3. The write-back guard `if (meta.name !== config.fallbackName) return;` (`runner/title-runner.mjs:40`) — intended as "manual rename wins" — then holds forever, because the generated title made `meta.name` differ from the fallback.
|
|
21
|
+
|
|
22
|
+
Feasibility notes from research (see research-summary.md): the referenced `feat/board-ux-title` retry machinery (`shouldRetryTitle` / `TITLE_RETRY_BACKOFF_MS`) does **not exist** on origin or in any commit; the design is therefore fully self-contained inside the runner. `contentText` is currently private in `src/core/session-view.mjs` and must be lifted. Nothing reaps a longer-lived title-runner (detached spawn, warm-host sweeper only targets PTY hosts and skips `AGENT_BOARD_NO_SWEEP=1` children).
|
|
23
|
+
|
|
24
|
+
## Design
|
|
25
|
+
|
|
26
|
+
### 1. `src/core/title.mjs` — greeting classifier (pure)
|
|
27
|
+
|
|
28
|
+
`isGreetingPrompt(text)` classifies a message as a greeting iff the **entire** message is greeting material.
|
|
29
|
+
|
|
30
|
+
Normalization: `String(text ?? "")` → trim → lowercase → collapse whitespace runs to a single space → strip leading/trailing characters from `PUNCT = "!!??。.,,、~~…;;::"`.
|
|
31
|
+
|
|
32
|
+
Matching is a **whole-string greedy longest-match consume** over the normalized string (multi-word English phrases and multi-character Chinese phrases are first-class vocabulary units; adjacent units need no separator, which is what makes `你好呀` and `嗨嗨` match):
|
|
33
|
+
|
|
34
|
+
- Vocabulary: `GREETINGS = { hello, hi, hey, hiya, yo, sup, howdy, greetings, morning, good morning, good afternoon, good evening, good day, 你好, 您好, 嗨, 哈喽, 哈啰, 在吗, 在么, 早上好, 上午好, 早安, 下午好, 晚上好, 晚安 }` and `PARTICLES = { there, 呀, 啊, 哦 }` (covers `hi there`, `你好呀`).
|
|
35
|
+
- Consume rule (**greeting-first**): starting at position 0, repeatedly (a) skip any run of separators (a space or any `PUNCT` char), then (b) consume the **longest** vocabulary unit matching at the current position — **no trailing-boundary requirement on individual units**. **The first consumed unit must belong to `GREETINGS`; units consumed after the first may be `GREETINGS` or `PARTICLES`.** There is no separate repetition rule: adjacent duplicates (``hello hello``, ``嗨嗨``) are naturally consumed because each unit is itself in the vocabulary.
|
|
36
|
+
- The message is a greeting iff the consume reaches the end of the string with **at least one `GREETINGS` unit consumed**. A stuck position — next characters match no vocabulary unit (``hello, please fix X`` stalls at ``please``; bare ``good`` stalls immediately since ``good`` alone is not in the vocabulary; no-separator real tasks like ``helloX`` / ``你好请修复`` stall at ``X`` / ``请修复``) → `false`; a string that never consumes a `GREETINGS` unit (bare ``there``, bare ``呀``, or particle-first ``there hello``) → `false`. Empty string → `false`.
|
|
37
|
+
- The vocabulary is intentionally small and fixed (denylist-style classifier, not NLP); extending it is a one-line change plus tests.
|
|
38
|
+
|
|
39
|
+
### 2. `src/core/title.mjs` — env settings resolver (pure, new)
|
|
40
|
+
|
|
41
|
+
`resolveTitleSettings(env, configModel)` returns `{ enabled: boolean, model: string, thinking: string }`, owning **both** legacy and current env vars with today's exact precedence (currently inlined in `runner/title-runner.mjs:26-29`):
|
|
42
|
+
|
|
43
|
+
- `configured = env.AGENT_BOARD_TITLE_MODEL ?? env.AGENT_VIEW_TITLE_MODEL`
|
|
44
|
+
- `enabled = configured !== "off"` (off wins even when `configModel` is set — preserves today's early return)
|
|
45
|
+
- `model = configModel ?? configured ?? DEFAULT_TITLE_MODEL`
|
|
46
|
+
- `thinking = env.AGENT_BOARD_TITLE_THINKING_LEVEL ?? env.AGENT_VIEW_TITLE_THINKING_LEVEL ?? DEFAULT_TITLE_THINKING_LEVEL`
|
|
47
|
+
|
|
48
|
+
The flow module never reads `process.env`; the shell calls this resolver once and either exits (`enabled === false`, before any polling starts) or wires `runOneShot` with the resolved model/thinking.
|
|
49
|
+
|
|
50
|
+
### 3. `src/core/session-entries.mjs` — lift `contentText`
|
|
51
|
+
|
|
52
|
+
Move `contentText(content)` verbatim from `src/core/session-view.mjs` into `src/core/session-entries.mjs` (both are structure/projection primitives; session-entries is the documented "single source" module and has no `node:fs` import). `session-view.mjs` imports it from there — no duplicate, no behavior change.
|
|
53
|
+
|
|
54
|
+
### 4. `src/core/title.mjs` — substantive-prompt projection (pure)
|
|
55
|
+
|
|
56
|
+
`firstSubstantiveUserPrompt(sessionJsonlText)`:
|
|
57
|
+
|
|
58
|
+
- `parseSessionEntries` → `activeBranchEntries` (both from `src/core/session-entries.mjs`);
|
|
59
|
+
- iterate branch entries in order, keep `type === "message"` with `message.role === "user"`, project text via `contentText(message.content)` (only text blocks — tool-result user entries project to empty and are skipped);
|
|
60
|
+
- skip empty projections and entries where `isGreetingPrompt(text)` is true (the first entry **is** the greeting prompt that triggered polling);
|
|
61
|
+
- return the first remaining text; if none, `null`.
|
|
62
|
+
|
|
63
|
+
### 5. `src/core/title-flow.mjs` — orchestration with injected I/O (new module)
|
|
64
|
+
|
|
65
|
+
Exported: `runTitleFlow(config, deps)` plus constants `TITLE_POLL_INTERVAL_MS = 15_000`, `TITLE_POLL_BUDGET_MS = 300_000`.
|
|
66
|
+
|
|
67
|
+
`deps` (all injected; the runner shell wires real implementations):
|
|
68
|
+
`{ now(): number, sleep(ms): Promise<void>, readMeta(root, viewId): object|null, commitMeta(meta): void, readSessionText(config): string|null, runOneShot(prompt): Promise<string|null> }`
|
|
69
|
+
|
|
70
|
+
`TitleConfig` (`src/core/types.mjs` JSDoc) gains optional `pollIntervalMs` / `pollBudgetMs`; when absent the constants above apply. The service never sets them — they exist so hermetic tests can shrink the poll window without touching production timing.
|
|
71
|
+
|
|
72
|
+
Flow (single source for both paths):
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
runTitleFlow(config, deps):
|
|
76
|
+
if !isGreetingPrompt(config.prompt):
|
|
77
|
+
return generateOnce(config, deps, config.prompt) // today's behavior, unchanged
|
|
78
|
+
deadline = deps.now() + (config.pollBudgetMs ?? TITLE_POLL_BUDGET_MS)
|
|
79
|
+
interval = config.pollIntervalMs ?? TITLE_POLL_INTERVAL_MS
|
|
80
|
+
loop while deps.now() < deadline:
|
|
81
|
+
await deps.sleep(interval) // sleep-first: t=15s, 30s, …
|
|
82
|
+
text = deps.readSessionText(config) // readMeta → meta.sessionFile → read if exists, else null
|
|
83
|
+
prompt = text ? firstSubstantiveUserPrompt(text) : null
|
|
84
|
+
if prompt: return generateOnce(config, deps, prompt)
|
|
85
|
+
return // budget exhausted → quiet exit, row keeps fallback slug
|
|
86
|
+
|
|
87
|
+
generateOnce(config, deps, prompt):
|
|
88
|
+
out = await deps.runOneShot(prompt) // rejection propagates to the caller (shell catches — best effort)
|
|
89
|
+
last = out?.trim().split("\n").slice(-1)[0]?.trim() ?? "" // LAST LINE ONLY — today's shell semantics, now owned by the flow
|
|
90
|
+
title = normalizeGeneratedTitle(last, config.fallbackName)
|
|
91
|
+
if !title || title === config.fallbackName: return
|
|
92
|
+
meta = deps.readMeta(config.root, config.viewId)
|
|
93
|
+
if !meta: return
|
|
94
|
+
if meta.name !== config.fallbackName: return // manual rename wins — re-checked at write time
|
|
95
|
+
meta.name = title
|
|
96
|
+
deps.commitMeta(meta)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`readMeta` is re-read **inside** `generateOnce` right before the guard, so a manual rename at any point — during polling **or** while the one-shot model call is pending — still wins (this also keeps the runner safe against other `meta.name` writers such as the user-side `agent-board-name-sync` bridge). `runOneShot` rejections are **not** caught inside the flow: they propagate to the shell's existing `.catch(() => {})` best-effort handler. (Today's real `runOneShot` never rejects — it resolves `""` on spawn error and on timeout — but injected test doubles may.)
|
|
100
|
+
|
|
101
|
+
### 6. `runner/title-runner.mjs` — thin shell
|
|
102
|
+
|
|
103
|
+
- Keep argv/config-file handling, `runOneShot` (spawn + JSON event scan + timeout), and the top-level best-effort catch.
|
|
104
|
+
- `main()`: read config → `const settings = resolveTitleSettings(process.env, config.model)` → `if (!settings.enabled) return` (before any polling) → wire real deps and `await runTitleFlow(config, deps)`:
|
|
105
|
+
- `now: Date.now`, `sleep: ms => new Promise(r => setTimeout(r, ms))`
|
|
106
|
+
- `readMeta` from `src/core/store.mjs`
|
|
107
|
+
- `commitMeta: meta => writeMeta(config.root, meta)` (`writeMeta` from `src/core/store.mjs`)
|
|
108
|
+
- `readSessionText: () => { const m = readMeta(config.root, config.viewId); if (!m?.sessionFile) return null; return existsSync(m.sessionFile) ? readFileSync(m.sessionFile, "utf8") : null; }`
|
|
109
|
+
- `runOneShot: prompt => runOneShot(config.piCommand, [...config.piArgsPrefix, "--mode", "json", "-p", "--no-session", "--model", settings.model, ...(settings.thinking && settings.thinking !== "off" ? ["--thinking", settings.thinking] : []), titlePrompt(prompt)], 15000)`
|
|
110
|
+
- `src/runtime/service.mjs` is **not touched** (single call site, same config shape, same fallback name).
|
|
111
|
+
|
|
112
|
+
### Decision table
|
|
113
|
+
|
|
114
|
+
| Situation | Behavior |
|
|
115
|
+
|---|---|
|
|
116
|
+
| First prompt is substantive | Identical to today: generate once at dispatch, guarded write |
|
|
117
|
+
| First prompt is a greeting, later substantive user message within budget | Title generated from that first substantive message; guarded write |
|
|
118
|
+
| First prompt is a greeting, manual rename before the write (polling **or** one-shot pending) | Manual name kept (guard re-checks `meta.name` at write time) |
|
|
119
|
+
| First prompt is a greeting, no substantive message within budget | Runner exits quietly; row keeps fallback slug (today's failure mode, no worse) |
|
|
120
|
+
| Title settings resolve to off (`AGENT_BOARD_TITLE_MODEL` or legacy `AGENT_VIEW_TITLE_MODEL` = `off`) | Shell exits before flow and before polling; no generation |
|
|
121
|
+
| Session file never appears (child failed to start) | Poll misses every tick (readSessionText → null); quiet exit at budget |
|
|
122
|
+
| Model call returns empty / null / fallback-equal output | No commit (normalize + equality guard) |
|
|
123
|
+
| `readMeta` returns null at write time | No commit, quiet return |
|
|
124
|
+
| `runOneShot` rejects | Propagates to shell's `.catch(() => {})`; no commit |
|
|
125
|
+
|
|
126
|
+
### Non-goals
|
|
127
|
+
|
|
128
|
+
- No retry/backoff machinery (the referenced `feat/board-ux-title` branch does not exist); no changes to `service.mjs` scheduling; no regeneration for rows that already carry a generated or manual title.
|
|
129
|
+
- No NLP greeting detection beyond the fixed vocabulary; no change to the title model, prompt, `normalizeGeneratedTitle`, or the last-line extraction semantics.
|
|
130
|
+
- No new env knobs (both legacy and current title env vars keep today's names and precedence).
|
|
131
|
+
|
|
132
|
+
## Acceptance matrix
|
|
133
|
+
|
|
134
|
+
| ID | 功能点 | 验收方式 | 具体验证 | 通过标准 |
|
|
135
|
+
|----|--------|----------|----------|----------|
|
|
136
|
+
| A1 | `isGreetingPrompt` classification | 自动化验证(unit) | `node --test test/title.test.mjs` | 正例:`hello/hi/hey/hiya/yo/sup/howdy/greetings/morning`、**`good morning/good afternoon/good evening/good day`**、zh 全词表(`你好/您好/嗨/哈喽/哈啰/在吗/在么/早上好/上午好/早安/下午好/晚上好/晚安`)、大小写、首尾标点、重复(`hello hello`、`嗨嗨`)、语气词后缀(`hi there`、`你好呀`)→ `true`;反例:问候前缀实任务(`hello, please fix X`)、**无分隔符前缀任务(`helloX`、`你好请修复`)**、**裸语气词(`there`、`呀`)、语气词在前(`there hello`)**、裸 `good`、空串、非问候 → `false` |
|
|
137
|
+
| A2 | `firstSubstantiveUserPrompt` projection | 自动化验证(unit) | `node --test test/title.test.mjs` | fixture JSONL(问候首条、tool-result 用户条目、assistant 条目、非活动分支):返回活动分支第一条实质用户消息文本;全问候/空文件/无用户消息 → `null` |
|
|
138
|
+
| A3 | `contentText` lift regression | 自动化验证(unit) | `npm test`(既有 session-view/session-entries 测试不变更地通过) | 行为零变化 |
|
|
139
|
+
| A4 | greeting poll flow + guard + failure branches | 自动化验证(unit,注入 I/O + 假时钟) | `node --test test/title-flow.test.mjs` | ①问候→轮询命中→以实质消息调 `runOneShot`、守卫后 `commitMeta` 提交;②轮询期间手动改名→不提交;③预算耗尽→不调 `runOneShot`、不提交、安静返回;④非问候→立即生成、不轮询;⑤`runOneShot` 返回 null/空串/等于 fallback 的输出→不提交;⑥写前 `readMeta` 返回 null→不提交;⑦deferred `runOneShot` 挂起期间改名→恢复后仍不提交;⑧`runOneShot` reject→异常传播出 flow、不提交(由 shell catch 承接);⑨多行模型输出(两条路径各一例)→只用最后一行生成标题 |
|
|
140
|
+
| A5 | `resolveTitleSettings` env resolution | 自动化验证(unit) | `node --test test/title.test.mjs` | `AGENT_BOARD_TITLE_MODEL=off` → `enabled:false`;legacy `AGENT_VIEW_TITLE_MODEL=off` → `enabled:false`;两变量并存时 board 优先;`configModel` 覆盖 env model 但不覆盖 off;thinking 同名变量与默认值链路正确 |
|
|
141
|
+
| A6 | runner shell hermetic smoke | 自动化验证(integration) | `node --test test/title-runner-smoke.test.mjs`(新 fixture `test-support/fake-title-pi.mjs`:输出一行 `message_end` JSON 后退出;**按仓内 hermetic 模式配置 `piCommand: process.execPath`、`piArgsPrefix: [<fixture 绝对路径>]`**——不直接 spawn `.mjs`,Windows 亦可移植) | ①非问候:真实 spawn `node runner/title-runner.mjs <config>`,temp root meta → 进程退出、`meta.name` 更新为 fixture 标题;②问候:config 带 `pollIntervalMs: 50`、session 文件预置问候+实质消息 → 退出、`meta.name` 更新为实质消息标题;③`off`(board 与 legacy 各一)→ 退出且 `meta.name` 不变、无模型调用 |
|
|
142
|
+
| A7 | static/build | 自动化验证(static + build) | `npm run typecheck`;PR 前 `npm run verify`(worktree 内,node_modules 软链主 checkout) | typecheck 0 错误;verify 全绿且 coverage 阈值(lines 85 / funcs 80 / branches 70)达标 |
|
|
143
|
+
| A8 | full-suite regression | 自动化验证(integration) | `npm test` | 全绿 |
|
|
144
|
+
| U1 | real dispatch on deployed code | 用户实测(部署前置见下) | ①新会话首条发 `hello`,再发一条实任务消息,**从实任务消息发送时刻起约 30 秒内**(下一次轮询 tick ≤15s + 一次 one-shot ≤15s + 余量)标题更新为实任务标题;②对照:首条即实任务的会话标题照旧即时生成;③`hello` → 手动改名 → 发实任务 → 等待 ≥ 轮询间隔 + 一次 one-shot 窗口 → 手动名保持;④`hello` 后 5 分钟内不发实任务 → 行名保持 slug | ①–④ 全部符合观察预期 |
|
|
145
|
+
|
|
146
|
+
**U1 部署前置(必须先完成,否则在旧代码上验收)**:运行中的 Pi 通过扩展加载路径的 `import.meta.url` 解析 `TITLE_RUNNER_SCRIPT`(`src/index.ts:21`)——①对 Pi **当前实际加载**的 checkout(本机为 `~/.pi/agent/git/github.com/zhuxixi/pi-agent-board`,以 `pi` 会话内实际加载路径为准)执行 `git pull --ff-only` 并记录部署 SHA(PR 合并后);②完全退出并重启 Pi(dashboard/board 会话全部重开);③**title-model 专项检查**(VERIFY.md §2 的 one-shot 只验证默认模型,验不了 title-runner 实际使用的模型):用与本次部署相同的 title settings 显式跑一次 one-shot——`pi --mode json -p --no-session --model <resolved-title-model> [--thinking <resolved-thinking>] 'Reply with: ok'`(`<resolved-title-model>` 按 `resolveTitleSettings` 的优先级解析,未配置时为 `openai-codex/gpt-5.5`;thinking 为 off 时省略该参数);**健康判定与 VERIFY.md §2 对齐:进程退出码 0、出现 assistant 的 `message_end`、随后 `agent_end`、无认证错误**(可进一步确认回复包含 `ok`);④再执行①–④ 实测并回填结果。
|
|
147
|
+
|
|
148
|
+
**U1 rationale**: the poll window and one-shot model call involve a real detached runner + real title model on the user's machine; deterministic coverage of the same logic is achieved by A4/A6 with injected deps and hermetic fixtures, so U1 verifies deployment reality (spawn path, session-file timing, env resolution in a real process) rather than logic. **可执行时机**:PR 合并部署后(或明确将 `pi install` 指向被测 worktree 后),随时可执行。
|
|
149
|
+
|
|
150
|
+
## Testability split (design constraint for implementation)
|
|
151
|
+
|
|
152
|
+
| Unit | Purity | Test boundary |
|
|
153
|
+
|------|--------|---------------|
|
|
154
|
+
| `isGreetingPrompt` (`src/core/title.mjs`) | pure | direct unit table tests (A1) |
|
|
155
|
+
| `resolveTitleSettings` (`src/core/title.mjs`) | pure (env passed as argument) | unit tests with plain objects (A5); nothing reads `process.env` outside the shell |
|
|
156
|
+
| `firstSubstantiveUserPrompt` (`src/core/title.mjs`) | pure (imports session-entries) | fixture-JSONL unit tests (A2) |
|
|
157
|
+
| `contentText` (`src/core/session-entries.mjs`, moved) | pure | exercised via A2 + existing session-view tests (A3) |
|
|
158
|
+
| `runTitleFlow` + constants (`src/core/title-flow.mjs`) | orchestration, **all** I/O injected (`now/sleep/readMeta/commitMeta/readSessionText/runOneShot`) | fake-clock unit tests drive ticks without real timers or spawns (A4); **no re-coupling allowed** — the shell must not regain decision logic, the flow must not read env |
|
|
159
|
+
| `runner/title-runner.mjs` shell | I/O only | hermetic spawn smoke via `test-support/fake-title-pi.mjs` + `pollIntervalMs` shrink (A6); real-pi behavior by U1 |
|
|
160
|
+
|
|
161
|
+
Implementation must keep these boundaries: the classifier, resolver, and projection stay pure; the flow module owns sequencing and guards with every effect injected; the shell only wires real deps.
|
|
162
|
+
|
|
163
|
+
## Deployment / execution path
|
|
164
|
+
|
|
165
|
+
- Runner spawn path unchanged: `launchTitle` (`src/core/launch.mjs:97-105`) writes the title config and spawns the detached node script; poll mode only extends the runner's lifetime to ≤ ~5 min 15 s. Nothing in the repo reaps title-runners (sweeper targets warm PTY hosts only, `src/core/warm-host-sweeper.mjs:147-148`).
|
|
166
|
+
- Worktree (step 5, model B): branch `issue-295-greeting-title-poll` (≤64 chars, no prefixes); `npm run verify` in the worktree requires `node_modules` symlinked to the main checkout (known ENOENT otherwise — see research notes).
|
|
167
|
+
- U1 executes only after the deployed checkout (the one Pi actually loads) is updated and Pi is fully restarted — see the U1 preconditions block.
|
|
168
|
+
|
|
169
|
+
## Alternatives considered (from the issue plan + research)
|
|
170
|
+
|
|
171
|
+
- **Skip generation for greetings, keep the slug forever**: trivial but leaves a useless name — rejected (does not satisfy the issue).
|
|
172
|
+
- **Re-queue title generation from the `reply()` path in `service.mjs`**: misses messages typed directly inside an attached session; the session JSONL observes every user message — rejected.
|
|
173
|
+
- **Revive a retry/backout machinery**: the referenced branch does not exist; would grow scope beyond the runner — rejected for this issue.
|
|
174
|
+
- **Let the flow read `process.env` directly**: rejected in round 1 (R1-G3) — breaks the fake-clock unit boundary and duplicates the legacy-alias precedence that already lives in the shell.
|