Skip to content

Commit c0af163

Browse files
authored
fix(live-proof): avoid replaying one-shot terminal proofs (#1259)
* fix(live-proof): plan one-shot terminal commands without replay Clarify that terminal entry executes before typed steps so one-shot proofs are planned once. Preserve intentional repeated commands and prove non-overwrite, nonzero-exit, and timeout safety through real tmux. * fix(live-proof): constrain proof plan generation
1 parent ff813ac commit c0af163

12 files changed

Lines changed: 1266 additions & 37 deletions

‎docs/live-proof.md‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,20 @@ assertion remains a completed, non-gating schema-v1 step, is explicitly labeled
144144
paths never enter published terminal output. Each entry or `run` action executes
145145
as a separately supervised Bash process in the same checkout, so plans should
146146
share state through files or one command rather than shell-local mutations.
147-
The terminal `entry` executes automatically before typed steps and must not be
148-
repeated as the first `run`; exact leading duplicates are normalized away before
149-
execution.
147+
The terminal `entry` executes automatically before all typed steps. Every `run`
148+
executes independently, including a first `run` identical to `entry` or a later
149+
repeated command; the parser and driver do not deduplicate commands. Intentional
150+
reruns after state changes remain valid and execute in order.
151+
152+
Plan one-shot proofs, including commands that refuse an existing output directory,
153+
in one of two ways: put the proof command in `entry` followed by stable
154+
`expect_output` steps, or put safe setup in `entry` followed by exactly one `run`
155+
of the proof command and its expectations. Do not replay a proof just to capture
156+
its output or produce media. For a useful recording transition, choose setup plus
157+
one run so the expected output appears after the action; otherwise use
158+
`static_text` and verify once. Preserve non-overwrite guards rather than deleting
159+
the original output to accommodate an accidental replay.
160+
150161
Nonzero exits, signals, command timeouts, and missing markers for still-running
151162
commands remain failures.
152163
All untrusted fields are bounded and neutralized against Markdown fences, HTML,
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# Terminal proof planning
2+
3+
Status: fresh constrained generation and local proof at runtime head
4+
`ca48d41487affa905cb775da8a985d1b128b18c3`, with the generator and documentation
5+
fix still uncommitted. Exact final-head replay remains pending. This record does
6+
not authorize a commit, publication, or live mutation.
7+
8+
## Claim and provenance
9+
10+
The planner should describe a one-shot terminal proof once, while the parser and
11+
driver preserve every intentional command and all existing failure gates. Entry
12+
runs automatically before steps; a run step is another execution, never a
13+
restatement of entry.
14+
15+
[The successful entry and failed replay on PR 1240](https://github.com/openclaw/clawsweeper/pull/1240#issuecomment-5403433718)
16+
exposed a plan that ran a non-overwriting proof twice. The
17+
[PR 1254 producer artifact](https://github.com/openclaw/clawsweeper/actions/runs/33033345816)
18+
also repeated entry as its first run: that run failed waiting for entry, even
19+
though the captured output later contained exit zero and successful validation.
20+
Those are distinct failure observations. The producer and this base have identical
21+
terminal drivers. Independent real-tmux probes confirmed that a previous-command
22+
timeout remains failed even if entry finishes successfully during final capture:
23+
the requested next command never ran. That probe deliberately injected capture
24+
latency to establish the ordering, not to claim the producer experienced it. The
25+
original artifact lacks status-sample timestamps, so no distinct driver status bug
26+
is established. Driver supervision, deadlines, and failure latching are unchanged.
27+
28+
[PR 1256](https://github.com/openclaw/clawsweeper/pull/1256), present in the base,
29+
silently removed an exact leading duplicate. This change removes only that
30+
normalization, restores command-preservation tests, and clarifies the production
31+
prompt and schema descriptions. Its cold-build/final-output verification changes
32+
remain intact. The public schema's properties, types, required fields, enums,
33+
and bounds are unchanged.
34+
35+
Release-note context, retained here following the release-owned changelog
36+
disposition in PR 1256: terminal proof planning now explicitly separates automatic
37+
entry execution from subsequent commands, avoids accidental one-shot replays for
38+
media, and preserves intentional repeated commands.
39+
40+
## Reproduce
41+
42+
Use Node 24 or newer, the repository pnpm, real tmux, and an authenticated Codex
43+
CLI with the built-in ChatGPT-backed provider. The generation helper currently
44+
attests macOS Seatbelt and CLI `0.150.0-alpha.13`; other platforms or versions
45+
must be re-attested, not allowed to fall back to full access. Do not put private
46+
model identifiers or raw agent transcripts in proof records. Run from this
47+
checkout after building:
48+
49+
```bash
50+
pnpm run build
51+
mkdir -p .artifacts/terminal-proof-planning
52+
node scripts/e2e/terminal-proof-planning.mjs prepare .artifacts/terminal-proof-planning/fast fast
53+
```
54+
55+
`prepare` uses the production review-prompt assembly and full decision schema.
56+
The only extra input is a synthetic, fully supplied local fixture review request;
57+
it supplies commands and expected output, not a hand-written plan. It writes the
58+
exact prompt/schema inputs and their hashes. Generate the decision with real
59+
Codex inference, without executing any commands from the prompt:
60+
61+
```bash
62+
proof_bundle="$PWD/.artifacts/terminal-proof-planning/fast"
63+
node scripts/e2e/terminal-proof-generate.mjs "$proof_bundle"
64+
node scripts/e2e/terminal-proof-planning.mjs run "$proof_bundle" fast
65+
```
66+
67+
An optional second helper argument selects the host-approved model for this
68+
invocation only; it is never written into the sanitized receipt. User routing
69+
configuration is intentionally ignored. Authentication uses the existing login;
70+
no credentials are copied or extracted.
71+
72+
Generation is a distinct constrained workflow. The helper supplies the entire
73+
production prompt and schema as data to `codex exec --ignore-user-config
74+
--ignore-rules --ephemeral --strict-config`, with approval `never` and the named
75+
`terminal-proof` permission profile. That profile allows minimal OS reads and
76+
reads of an empty workspace, no writable paths, and no child network access.
77+
The CLI adds read access to its bundled shell and executable shim; the helper
78+
also verifies those effective runtime roots from the session-start trace.
79+
Shell execution, image reads, web search, MCP, plugins, skills, hooks, and nested
80+
agents are disabled; no executable fixture is placed in the workspace. Ancestor
81+
project configuration is refused and project instructions are disabled. Only
82+
the CLI's own inference/authentication transport may contact the configured
83+
service. A temporary cwd or a textual instruction alone is not this boundary.
84+
85+
Before inference, a trusted sandbox probe must fail to read a harmless sentinel
86+
outside the workspace and fail to create a file inside it. After inference, the
87+
helper checks actual startup settings and the model-facing request's tool
88+
inventory, requires zero tool calls, and only then copies the generated decision
89+
into the bundle. This CLI has no blanket no-tools flag: its remaining
90+
`apply_patch` tool is restricted by the same read/write sandbox. Model metadata
91+
can require Code Mode despite feature flags, so the helper fingerprints the
92+
inspected `exec`/`wait` wrappers: their V8 environment has no Node, filesystem,
93+
or network primitives and exposes only sandboxed `apply_patch`. An optional
94+
user-message tool has no filesystem or network authority. Unexpected tools,
95+
changed wrapper definitions, missing trace evidence, or failed checks stop the
96+
helper. Do not replay a decision until its attestation passes.
97+
98+
Repeat with a fresh directory and `delayed` instead of `fast` in both script
99+
invocations. The delayed command emits a startup line, then takes 34 seconds,
100+
longer than entry startup polling. No driver timeout is extended. Existing
101+
directories are refused; use new names for subsequent captures.
102+
Inspect temporary Codex diagnostics locally if generation fails; do not copy
103+
them into the proof bundle or public artifacts. The helper retains only the
104+
structured decision and sanitized `generation.json` in the bundle. Local raw
105+
traces are diagnostic evidence, never publication artifacts.
106+
107+
The replay script parses the full model decision through the production parser,
108+
requires the generated plan to survive unchanged, checks its command allowlist,
109+
and executes it through the production terminal driver on a dedicated real tmux
110+
server. It requires all five assertions to be observed, not merely schema-v1
111+
successful-exit fallback. Files and invocation traces prove single execution and
112+
byte preservation on a refused replay. Hand-written negative controls are clearly
113+
marked separately from model-generated proof: an exact leading duplicate must
114+
execute and fail, identical later commands must observe a changed state, exit 7
115+
must fail, and a silent 40-second command must hit the real 30-second timeout.
116+
117+
`inputs.json`, `decision.json`, `generation.json`,
118+
per-scenario `live-verification.json`, and `receipt.json` remain under ignored
119+
`.artifacts/terminal-proof-planning/`. Compact receipts beside this note record
120+
actual results, provenance, and hashes; no raw transcripts are included. The
121+
source-hash guard rejects replay after any recorded implementation input changes.
122+
The receipt distinguishes the runtime head, original base, source hashes, and
123+
generator hash. It does not claim proof of a later commit.
124+
125+
## Observed results
126+
127+
Both fresh constrained Codex generations passed on local macOS with Node `v24.19.0` and
128+
tmux `3.7c`. The fast plan put the command only in entry and chose static text.
129+
The delayed plan chose setup entry, one run, and expectations, with no explicit
130+
wait; existing expectation polling observed the delayed completion.
131+
Both observed all five success assertions and invoked the proof exactly once.
132+
Both refused a replay with exit 17 and preserved the original result bytes. In
133+
each run, the exact leading duplicate executed and failed, the intentional later
134+
repeat observed changed file state, exit 7 failed, and the silent command hit the
135+
existing 30-second timeout. `receipt.json` records normalized plans, outcomes,
136+
generation provenance, source hashes, and hashes of the full ignored receipts.
137+
138+
Each generation trace shows one actual inference request and zero tool calls,
139+
approval `never`, the active `terminal-proof` profile, restricted filesystem
140+
reads, no writable paths, and restricted network access. The harmless outside
141+
sentinel read and workspace write were both denied. The generated workspace
142+
remained empty. No model-directed fixture execution occurred during generation.
143+
144+
The latest receipt comes from two fresh inference calls using the final helper
145+
unchanged, followed by real-tmux execution. Both calls passed the built-in
146+
permission and tool-inventory checks directly; neither decision was edited,
147+
reused from an earlier generation, or retrospectively re-attested. Diagnostic
148+
attempts during helper development remain local and are not the published proof.
149+
150+
This receipt supersedes the full-access generation receipt preserved at
151+
[the previous head](https://github.com/openclaw/clawsweeper/blob/ca48d41487affa905cb775da8a985d1b128b18c3/docs/proof/terminal-proof-planning/receipt.json).
152+
The earlier four runtime demonstrations are historical observations, not evidence
153+
of isolated generation. None of their decisions was reused here. These two new
154+
observations are not a guarantee of all future planner output.
155+
156+
Focused validation passed all 138 tests:
157+
158+
```bash
159+
node --test test/decision-parser.test.ts test/review-prompt-policy.test.ts \
160+
test/review-prompt-context.test.ts test/live-proof.test.ts
161+
```
162+
163+
Build, helper syntax/lint/format, documentation checks, and `git diff --check`
164+
passed. The full repository suite was not rerun for this narrow correction:
165+
the earlier run's 49 diagnosed host-fixture failures (Git pruning, offline pnpm,
166+
and timing) remain outside this patch. No full-suite success is claimed; CI must
167+
run again after the parent-reviewed commit.
168+
169+
## Limits
170+
171+
This is a controlled terminal fixture, not Worker/apply functional correctness,
172+
live GitHub behavior, or evidence that every future model plan is correct. The
173+
driver runs with recording disabled even if the planner chooses a media payoff;
174+
setup/action/expectation execution can be verified, but video recording and
175+
publication are not claimed. No accounts, target services, live apply/close,
176+
workflow changes, or external artifact uploads are used by the fixture.
177+
178+
OpenClaw Bay is unaffected: the schema shape, verification lifecycle, publication
179+
contract, and observer-only ownership are unchanged. The PR 1254 artifact does not
180+
prove when the supervised entry exited; later target JSON saying exit zero is not
181+
authority to erase a timeout or pass an unexecuted run.

0 commit comments

Comments
 (0)