Align query authority contract and spawn-time ownership
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -38,9 +38,14 @@ depend on.
|
||||
5. Snapshots and live bytes have ordering metadata. A view restore must not
|
||||
duplicate bytes already included in the snapshot or drop bytes that arrived
|
||||
after it.
|
||||
6. Terminal query authority stays with the visible renderer when needed. The
|
||||
headless model tracks state but must not answer DA, DSR, OSC 11, or other
|
||||
shell/TUI queries that would inject replies into the PTY.
|
||||
6. Terminal query authority is singular and structural: the party that
|
||||
writes a chunk into a live terminal answers its queries. Visible renderer
|
||||
and remote views keep xterm authority. Chunks dropped by the
|
||||
hidden-delivery gate are answered exactly once by the main model
|
||||
responder, from runtime-emulator state plus renderer-pushed view
|
||||
attributes. Replayed, seeded, or snapshot bytes are answered by no one.
|
||||
The daemon emulator never answers. (Amended by Phase 5 — see
|
||||
[`terminal-query-authority.md`](./terminal-query-authority.md).)
|
||||
7. The transcript contract stays separate from screen restore. `orca terminal
|
||||
read` must preserve bounded previews, cursor pagination, partial-line rules,
|
||||
truncation flags, and total counts even if view snapshots change shape.
|
||||
@@ -116,7 +121,11 @@ Before moving more runtime behavior behind the model/view boundary, add or
|
||||
extend tests that prove:
|
||||
|
||||
- headless snapshots rehydrate rich alternate-screen TUI state;
|
||||
- headless tracking does not answer DA, DSR, OSC 11, or theme-sensitive queries;
|
||||
- the daemon emulator never answers DA, DSR, OSC 11, or theme-sensitive
|
||||
queries (the `session.test.ts` pins are permanent);
|
||||
- the main runtime responder answers queries only from live chunks the
|
||||
hidden-delivery gate dropped — never delivered, replayed, seeded, or
|
||||
remote-subscribed chunks;
|
||||
- hidden renderer overflow restores from model state without duplicate live
|
||||
output;
|
||||
- sleep/wake and worktree revisit restore from model-correct state;
|
||||
@@ -135,6 +144,7 @@ Current coverage is spread across:
|
||||
- `src/main/runtime/rpc/terminal-subscribe-buffer.test.ts`
|
||||
- `src/main/runtime/rpc/terminal-multiplex.test.ts`
|
||||
- `src/main/runtime/orca-runtime.test.ts`
|
||||
- `src/main/runtime/terminal-query-responder.test.ts`
|
||||
- `src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.ts`
|
||||
- `tests/e2e/terminal-hidden-tui-visual-restore.spec.ts`
|
||||
- `tests/e2e/terminal-sleep-wake-restore.spec.ts`
|
||||
|
||||
@@ -150,8 +150,13 @@ actually pushed. Snapshot parity: add `kittyKeyboardFlags` to `TerminalModes`
|
||||
for emulator re-seed parity only. `rehydrateSequences` must **not** push kitty
|
||||
flags into a renderer xterm — `POST_REPLAY_REATTACH_RESET`'s deliberate kitty
|
||||
reset (stale CSI-u Ctrl+C hazard, `terminal-replay-cursor-state.test.ts`)
|
||||
stays authoritative. A re-seeded emulator that lost flags answers `?0u`;
|
||||
protocol-conformant programs re-push.
|
||||
stays authoritative. Slice 3 wires the re-seed consumer: the daemon
|
||||
warm-reattach snapshot threads `modes.kittyKeyboardFlags` through the spawn
|
||||
result into `seedHeadlessTerminal`, which applies them to the fresh runtime
|
||||
emulator via its own `CSI = flags ; 1 u` parse (outside any forwarding
|
||||
window), so hidden `CSI ? u` reports the flags the hidden app actually
|
||||
pushed. Paths without a snapshot (cold restore spawns a fresh shell) answer
|
||||
`?0u`; protocol-conformant programs re-push.
|
||||
|
||||
### ConPTY DA1 variant
|
||||
|
||||
@@ -163,8 +168,8 @@ emulator parser (the main-side twin of
|
||||
the forwarding predicate. The override is installed at emulator creation and
|
||||
retrofitted when the spawn mark lands (daemon stream data can create the
|
||||
emulator before the awaited spawn response marks the PTY). ConPTY blocking on
|
||||
a missing DA1 is a spawn-time hazard; see the races section for the
|
||||
hidden-at-spawn loss window that remains until Phase 6.
|
||||
a missing DA1 is a spawn-time hazard; the hidden-at-spawn loss window is
|
||||
closed by the slice-3 `initiallyHidden` spawn flag (races section).
|
||||
|
||||
## Suppression: when main never replies
|
||||
|
||||
@@ -206,12 +211,17 @@ That is acceptable for state queries (DSR/CPR/DECRPM — TUIs re-probe or
|
||||
tolerate silence, as they did for every hidden pane before this phase). The
|
||||
one blocking-on-no-reply sequence, ConPTY DA1, only fires at spawn. A visible
|
||||
pane or an active codex startup window answers it from the renderer xterm.
|
||||
But a PTY spawned hidden **without** the startup window has no answerer until
|
||||
the renderer's hidden mark lands in main (one IPC hop after spawn): a DA1
|
||||
arriving in that pre-mark window is lost. That loss window is the pre-Phase-4
|
||||
hidden status quo and persists until Phase 6 marks hidden panes at spawn
|
||||
(spawn-record flag, below) — spawn-time ownership is not deterministic before
|
||||
then.
|
||||
A PTY spawned hidden **without** the startup window previously had no
|
||||
answerer until the renderer's hidden mark landed in main (one IPC hop after
|
||||
spawn). Slice 3 closes that window with the `initiallyHidden` spawn-record
|
||||
flag: the renderer declares hidden-at-spawn on `pty:spawn` (never while the
|
||||
codex startup window would run, and never for remote-runtime transports),
|
||||
and main marks the PTY hidden before the first byte — pre-spawn for
|
||||
daemon-host sessions whose id is minted up front, immediately after
|
||||
`provider.spawn` resolves otherwise — so the gate and responder own queries
|
||||
from byte one. The pane's first visibility sync then re-marks or unmarks
|
||||
through the existing Phase-4 machinery (unmark emits the restore marker for
|
||||
any spawn-window drops).
|
||||
|
||||
## Invariants
|
||||
|
||||
@@ -283,16 +293,26 @@ otherwise untouched in this phase.
|
||||
|
||||
## What Phase 6 (delete skip grammar + startup window) requires from this design
|
||||
|
||||
- **Mark-before-first-byte**: panes spawned without a visible view must be
|
||||
hidden-marked at spawn (spawn-record flag, not a renderer round trip) so
|
||||
startup queries — including ConPTY's blocking DA1 and codex startup probes —
|
||||
are main-owned from byte zero once the 10s window is gone.
|
||||
- **Attributes before spawn**: the renderer must push view attributes at app
|
||||
start, before any hidden spawn, or spawn-time view-attribute queries fall
|
||||
into the silent-until-push rule.
|
||||
- **Daemon shell-ready write gating** queues responder replies until the
|
||||
ready marker; spawn-time replies on Windows daemon PTYs need explicit
|
||||
validation before the window is removed.
|
||||
Accepted and shipped in slice 3 (except where noted):
|
||||
|
||||
- **Mark-before-first-byte** (shipped): panes spawned without a visible view
|
||||
are hidden-marked at spawn via the `initiallyHidden` flag on `pty:spawn`
|
||||
(spawn-record flag, not a renderer round trip) so startup queries —
|
||||
including ConPTY's blocking DA1 — are main-owned from byte zero. Codex
|
||||
startup probes stay renderer-answered while the 10s window exists: the
|
||||
renderer never sets the flag for codex startups; once Phase 6 deletes the
|
||||
window, dropping that exclusion makes codex spawns main-owned too.
|
||||
- **Attributes before spawn** (shipped): the renderer pushes composed view
|
||||
attributes once at app start (right after settings load, before terminal
|
||||
reconnect/spawn), so spawn-time view-attribute queries no longer fall into
|
||||
the silent-until-push rule. Per-pane appearance applies keep re-publishing
|
||||
through the same deduped publisher.
|
||||
- **Daemon shell-ready write gating** (verified): responder replies through
|
||||
`ptyController.write` → daemon `Session.write` are QUEUED pre-ready, never
|
||||
dropped, and the queue flushes at the shell-ready marker or the 15s
|
||||
`SHELL_READY_TIMEOUT_MS` bound (`session.ts`). Spawn-time replies on
|
||||
Windows daemon PTYs still need explicit e2e validation before the codex
|
||||
window is removed.
|
||||
- With the skip grammar deleted, every chunk is either written to a live
|
||||
xterm or dropped — the delivered-but-skipped no-reply gap disappears and
|
||||
the only remaining loss window is the mark IPC race.
|
||||
|
||||
@@ -34,7 +34,7 @@ Remote-runtime PTYs (`remote:`) never transit local main; the renderer
|
||||
| OSC 133;D command-finished exit code | main | main | renderer |
|
||||
| GitHub PR-link scan | main | main | renderer |
|
||||
| Command Code output scrape | main (shipped: per-PTY detector beside the tracker → `command-code-working`/`command-code-done` facts; the renderer pane keeps the done settle timer — it must consult the live status row) | main (shipped) | renderer |
|
||||
| DECSET 2031 color-scheme reply | renderer view/watcher — query authority stays with the view (contract invariant 6) | same | renderer |
|
||||
| DECSET 2031 color-scheme reply | renderer view/watcher — the 2031 fact reply path is untouched by Phase 5; general query authority is now per-chunk structural ownership, see [`terminal-query-authority.md`](./terminal-query-authority.md) (contract invariant 6 as amended) | same | renderer |
|
||||
| DECSET 2004 paste readiness (`agent-paste-draft.ts`) | renderer — input pacing, not a model side effect | renderer | renderer |
|
||||
|
||||
## Main-Side Tracker
|
||||
|
||||
Reference in New Issue
Block a user