rpi-cli 0.32.0

Terminal coding-agent CLI (the `rpi` binary) built on the rpi-* library crates
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
//! Read-only TUI discovery contracts; synthetic native facts and Faux only.
use super::*;
use crate::native_durable as native;
use rpi_agent::{agent_tool::AgentTool, AgentMessage};
use rpi_ai::{
    providers::faux::{faux_assistant_message, FauxProvider, FauxScript},
    types::{Content, StopReason, UserMessage},
};
use rpi_harness::{
    agent_harness::{AgentLane, HarnessRunOutcome},
    durable::DurableRunSummary,
    session::{
        jsonl::{JsonlSessionStorage, JsonlV4Header},
        types::*,
        DefaultIdGenerator, Session, SystemClock,
    },
    types::AgentHarnessOptions,
};
use rpi_tools::OsExecutionEnv;
use serde_json::{json, Value};
use std::{
    future::Future,
    sync::{atomic::Ordering, Arc, OnceLock},
    time::Duration,
};
use tokio_util::sync::CancellationToken;

// Reuse the actual storage probe, including its captured-index-scan hook.
mod probe {
    include!(concat!(
        env!("CARGO_MANIFEST_DIR"),
        "/../rpi-harness/tests/support/durable_control_probe.rs"
    ));
}
use probe::Probe;

async fn bounded<T>(future: impl Future<Output = T>) -> T {
    tokio::time::timeout(Duration::from_secs(15), future)
        .await
        .expect("bounded native runs test operation")
}
async fn memory() -> AgentHarness {
    bounded(AgentHarness::create(AgentHarnessOptions::default()))
        .await
        .unwrap()
}
async fn probed(p: Arc<Probe>) -> AgentHarness {
    bounded(AgentHarness::create(AgentHarnessOptions {
        session: Session::new(p, None),
        allow_existing_session: true,
        ..Default::default()
    }))
    .await
    .unwrap()
}
async fn view(h: &AgentHarness) -> Result<String, String> {
    bounded(native::interactive_command(h, " runs ")).await
}
fn base(id: &str) -> RecordBase {
    RecordBase {
        id: id.into(),
        seq: 0,
        lane: "main".into(),
        timestamp: 0,
    }
}
async fn append(h: &AgentHarness, id: &str, message: AgentMessage) {
    h.session()
        .append_entry(
            ProvisionedEntry {
                id: id.into(),
                kind: ProvisionedKind::Message {
                    message,
                    terminate: None,
                },
            },
            "main",
        )
        .await
        .unwrap();
}
async fn start(h: &AgentHarness, id: &str, anchored: bool) {
    h.session()
        .append_record(LaneRecord::OperationStarted(OperationStartedRecord {
            base: base(id),
            source_leaf_id: h.session().view("main").get_leaf_id().await.unwrap(),
            intent: OperationIntent::Run {
                original_prompt: vec![],
                initial_messages: vec![],
                system_prompt_override: None,
                resume_data: None,
            },
        }))
        .await
        .unwrap();
    if anchored {
        append(
            h,
            &format!("{id}-prompt"),
            AgentMessage::User(UserMessage::new("private prompt payload", 0)),
        )
        .await;
    }
}
async fn finish(h: &AgentHarness, id: &str, identity: bool) {
    h.session()
        .append_record(LaneRecord::OperationFinished(OperationFinishedRecord {
            base: base(&format!("{id}-finish")),
            run_id: id.into(),
            outcome: OperationOutcome::Completed,
            error: None,
            result: if identity {
                Some(RunResultIdentity {
                    leaf_id: h
                        .session()
                        .view("main")
                        .get_leaf_id()
                        .await
                        .unwrap()
                        .unwrap(),
                    final_entry_id: None,
                    assistant_entry_id: None,
                })
            } else {
                None
            },
        }))
        .await
        .unwrap();
}
async fn facts(h: &AgentHarness) -> Value {
    serde_json::to_value(
        h.session()
            .storage()
            .find_records(&RecordQuery::default())
            .await
            .unwrap(),
    )
    .unwrap()
}
async fn receipts(h: &AgentHarness) -> Value {
    serde_json::to_value(
        h.session()
            .storage()
            .find_entries(&EntryQuery {
                custom_type: Some("rpi.durable.control.v1".into()),
                ..Default::default()
            })
            .await
            .unwrap(),
    )
    .unwrap()
}
fn typed_index() -> DurableExecutionIndexSnapshot {
    serde_json::from_value(json!({
        "scope": {"sessionId":"synthetic-session", "lane":"main", "bindingToken":"synthetic-binding",
            "leafId":"captured-leaf", "historyRevision":12, "entryId":null, "controlRevision":0},
        "runs":[], "unavailableRuns":9,
        "control":{"forgottenRunIds":["hidden-id"], "recoveryRequest":{
            "runId":"intent-id", "startedSeq":1, "observedHistoryRevision":12,
            "unknownInvocationIds":["unknown-1"]}}
    })).unwrap()
}
fn row(id: String, seq: u64) -> DurableRunSummary {
    serde_json::from_value(json!({"id":id, "startedSeq":seq, "finishedRecordId":null,
        "finishedSeq":null, "status":"open"}))
    .unwrap()
}
fn mandatory(text: &str, verified: usize, unavailable: usize) {
    for needle in [
        "read-only",
        "Session",
        "Captured leaf",
        "history revision",
        "control revision",
        &format!("Verified runs: {verified} | unavailable candidates: {unavailable}"),
        "NOT an interrupted count",
        "not latest-run selection",
        "Choose an explicit runId",
        r#"/durable {"action":"status","runId":"<native-run-id>"}"#,
        "Open != Interrupted",
        "run completed != workflow completed",
        "No IDs truncated; no pagination",
        "Manual queue, not workers",
        "not permission to execute",
        "No automatic recovery or replay",
    ] {
        assert!(text.contains(needle), "missing {needle}: {text}");
    }
    assert!(text.len() <= MAX_TEXT_BYTES);
    assert!(text.chars().all(|c| !c.is_control() || c == '\n'));
}

#[tokio::test]
async fn branch_proof_counts_sibling_and_unanchored_without_exposing_payloads_or_writing() {
    let h = memory().await;
    append(
        &h,
        "shared-source",
        AgentMessage::User(UserMessage::new("private shared payload", 0)),
    )
    .await;
    start(&h, "sibling-run", true).await;
    finish(&h, "sibling-run", true).await;
    h.session()
        .move_lane("main", Some("shared-source"))
        .await
        .unwrap();
    start(&h, "unanchored-run", false).await;
    finish(&h, "unanchored-run", false).await;
    start(&h, "selected-open", true).await;
    let mut assistant = faux_assistant_message("private assistant result", StopReason::ToolUse);
    assistant.content.push(Content::tool_call(
        "provider-call",
        "write",
        json!({"private":"arguments"}),
    ));
    append(
        &h,
        "selected-assistant",
        AgentMessage::Assistant(Box::new(assistant)),
    )
    .await;
    h.session()
        .append_record(LaneRecord::ToolStarted(ToolStartedRecord {
            base: base("selected-invocation"),
            run_id: "selected-open".into(),
            assistant_entry_id: "selected-assistant".into(),
            tool_index: 0,
            tool_call_id: "provider-call".into(),
            tool_name: "write".into(),
            effective_args: json!({"private":"effective arguments"}),
            result_entry_id: "reserved-private-result".into(),
            replay: ToolReplay::Never,
        }))
        .await
        .unwrap();
    let s = service(&h).unwrap();
    let before = s.snapshot().await.unwrap();
    let native = facts(&h).await;
    let controls = receipts(&h).await;
    let index = s.execution_index().await.unwrap();
    assert_eq!(index.unavailable_runs, 2);
    assert_eq!(index.runs.len(), 1);
    assert_eq!(index.runs[0].id, "selected-open");
    let text = view(&h).await.unwrap();
    mandatory(&text, 1, 2);
    assert!(text.contains("Run \"selected-open\" | status \"open\""));
    assert!(!text.contains("status \"interrupted\""));
    for hidden in [
        "sibling-run",
        "unanchored-run",
        "private",
        "provider-call",
        "selected-invocation",
        "effectiveArgs",
    ] {
        assert!(!text.contains(hidden), "leaked {hidden}");
    }
    assert_eq!(s.snapshot().await.unwrap(), before);
    assert_eq!(facts(&h).await, native);
    assert_eq!(receipts(&h).await, controls);
    h.close().await.unwrap();
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn jsonl_faux_completed_read_and_forget_preserve_bytes_revision_and_native_result() {
    let tmp = tempfile::tempdir().unwrap();
    let provider = FauxProvider::new(FauxScript::new().with_text("private faux answer"));
    let h = bounded(AgentHarness::create(AgentHarnessOptions {
        model: provider.default_model().clone(),
        models: vec![provider.clone()],
        session: Session::new(
            Arc::new(
                JsonlSessionStorage::create(
                    Arc::new(OsExecutionEnv::with_cwd(tmp.path().into())),
                    "runs.jsonl",
                    JsonlV4Header::new("synthetic-runs".into(), 1, "/".into(), None, None, None),
                    Arc::new(SystemClock),
                    Arc::new(DefaultIdGenerator::new()),
                )
                .await
                .unwrap(),
            ),
            None,
        ),
        ..Default::default()
    }))
    .await
    .unwrap();
    let returned = bounded(h.prompt_text("private faux prompt", vec![]))
        .await
        .unwrap();
    let audit = h.get_result(&returned.run_id).await.unwrap().unwrap();
    let s = service(&h).unwrap();
    let native = facts(&h).await;
    for forgotten in [false, true] {
        if forgotten {
            let request = json!({"action":"forget_run", "runId":returned.run_id, "requestId":"runs-forget-001"});
            let ack = native::interactive_command(&h, &request.to_string())
                .await
                .unwrap();
            assert!(ack.contains("Mutation committed ACK"));
        }
        h.session().storage().drain().await;
        let path = tmp.path().join("runs.jsonl");
        let bytes = std::fs::read(&path).unwrap();
        let revision = h.session().storage().history_revision().await.unwrap();
        let before = s.snapshot().await.unwrap();
        let controls = receipts(&h).await;
        let text = view(&h).await.unwrap();
        mandatory(&text, usize::from(!forgotten), 0);
        if forgotten {
            assert!(!text.contains(&format!("Run {} |", quoted(&returned.run_id))));
            assert!(text.contains("Forgotten business projections: 1"));
        } else {
            assert!(text.contains(&format!(
                "Run {} | status \"completed\"",
                quoted(&returned.run_id)
            )));
        }
        assert!(!text.contains("private faux"));
        assert_eq!(s.snapshot().await.unwrap(), before);
        assert_eq!(facts(&h).await, native);
        assert_eq!(receipts(&h).await, controls);
        assert_eq!(controls.as_array().unwrap().len(), usize::from(forgotten));
        assert_eq!(
            h.session().storage().history_revision().await.unwrap(),
            revision
        );
        assert_eq!(std::fs::read(&path).unwrap(), bytes);
        let after = h.get_result(&returned.run_id).await.unwrap().unwrap();
        match (&audit.outcome, &after.outcome) {
            (
                HarnessRunOutcome::Completed {
                    leaf_id: a,
                    final_entry_id: b,
                    final_message: c,
                },
                HarnessRunOutcome::Completed {
                    leaf_id: x,
                    final_entry_id: y,
                    final_message: z,
                },
            ) => {
                assert_eq!((a, b, c), (x, y, z));
            }
            other => panic!("native completed result changed: {other:?}"),
        }
        assert_eq!(std::fs::read(&path).unwrap(), bytes);
    }
    assert_eq!(provider.state().call_count.load(Ordering::SeqCst), 1);
    h.close().await.unwrap();
}

#[test]
fn typed_formatter_omits_only_whole_prefix_rows_and_keeps_escaped_complete_ids() {
    let mut index = typed_index();
    index.scope.session_id = "session-界\u{1b}\u{7f}\u{85}\u{9b}".into();
    index.scope.leaf_id = Some("leaf-\"\\\n\u{1b}\u{85}".into());
    index.runs = (0..64)
        .map(|i| {
            row(
                format!(
                    "{i}-{}-\"\\\n\u{0}\u{1b}\u{7f}\u{85}\u{9b}",
                    "界".repeat(110)
                ),
                64 - i,
            )
        })
        .collect();
    let text = render(&index).unwrap();
    mandatory(&text, 64, 9);
    assert!(text.contains(&format!("Session {}", quoted(&index.scope.session_id))));
    assert!(text.contains(&format!("Captured leaf {}", quoted(&index.scope.leaf_id))));
    for needle in [
        "Forgotten business projections: 1",
        "Recovery INTENT ONLY",
        "explicit run \"intent-id\"",
        "unknown invocations 1",
        "audit/get_result not erased",
    ] {
        assert!(text.contains(needle), "missing {needle}");
    }
    let rows: Vec<_> = text
        .lines()
        .filter(|line| line.starts_with("Run "))
        .collect();
    assert!(!rows.is_empty() && rows.len() < 64);
    for (line, summary) in rows.iter().zip(&index.runs) {
        assert_eq!(
            *line,
            format!(
                "Run {} | status {} | started {} | finished {} | finish record {}",
                quoted(&summary.id),
                quoted(&summary.status),
                summary.started_seq,
                quoted(&summary.finished_seq),
                quoted(&summary.finished_record_id)
            )
        );
    }
    for summary in &index.runs[rows.len()..] {
        assert!(!text.contains(&quoted(&summary.id)));
    }
    assert!(text.contains(&display_summary(rows.len(), 64)));
    assert!(text.contains("\\u001b\\u007f\\u0085\\u009b"));
    // Count equality is explicit in the rendered footer, not inferred from truncation.
    assert!(text.contains(&format!("omitted {} whole rows", 64 - rows.len())));
}

#[test]
fn no_row_fits_is_not_empty_and_oversize_mandatory_scope_fails_atomically() {
    let mut index = typed_index();
    index.runs.push(row("界".repeat(MAX_TEXT_BYTES), 1));
    let text = render(&index).unwrap();
    mandatory(&text, 1, 9);
    assert!(text.contains(&display_summary(0, 1)));
    assert!(!text.contains("No proven, non-forgotten run rows"));
    assert!(!text.contains("Run \""));
    index.runs.clear();
    let empty = render(&index).unwrap();
    mandatory(&empty, 0, 9);
    assert!(empty.contains("No proven, non-forgotten run rows"));
    for leaf in [false, true] {
        let mut huge = typed_index();
        if leaf {
            huge.scope.leaf_id = Some("界".repeat(MAX_TEXT_BYTES));
        } else {
            huge.scope.session_id = "界".repeat(MAX_TEXT_BYTES);
        }
        let error = render(&huge).unwrap_err();
        assert!(error.contains("required scope/safety summary exceeds 16 KiB"));
        assert!(error.contains("read-only; no empty run history inferred"));
        assert!(!error.contains('界'));
    }
}

#[tokio::test]
async fn exact_tui_admission_keeps_flat_actions_separate_from_explicit_page_rpc() {
    let p = Probe::new(AgentHarnessOptions::default().session.storage());
    let h = probed(p.clone()).await;
    let s = service(&h).unwrap();
    let before = s.snapshot().await.unwrap();
    let controls = receipts(&h).await;
    let native = facts(&h).await;
    let binding = Arc::new(OnceLock::new());
    assert!(binding.set(h.downgrade()).is_ok());
    let tool = native::NativeDurableTool::new(binding);
    let schema = serde_json::to_value(tool.schema()).unwrap();
    assert!(!schema["parameters"]["properties"]["action"]["enum"]
        .as_array()
        .unwrap()
        .contains(&json!("runs")));
    for args in ["runs extra", "runs\nextra", r#"{"action":"runs"}"#] {
        assert!(
            native::interactive_command(&h, args).await.is_err(),
            "{args}"
        );
    }
    assert_eq!(
        native::command(&h, r#"{"action":"runs"}"#)
            .await
            .unwrap_err()
            .code,
        "invalid_request"
    );
    let error = tool
        .execute(
            "synthetic-provider-call",
            json!({"action":"runs"}),
            CancellationToken::new(),
            Arc::new(|_| {}),
        )
        .await
        .unwrap_err();
    assert!(error.to_string().contains("invalid_request"));
    for request in [
        json!({"type":"runs", "version":1}),
        json!({"type":"get_durable_state", "version":1, "action":"runs"}),
        json!({"type":"durable_mutate", "version":1, "requestId":"runs-invalid", "expected":before.scope, "action":{"action":"runs"}}),
    ] {
        assert_eq!(
            native::rpc(&h, &request, true).await.unwrap_err().code,
            "invalid_request"
        );
    }
    let json_status = native::command(&h, r#"{"action":"status"}"#).await.unwrap();
    assert_eq!(json_status["state"], serde_json::to_value(&before).unwrap());
    for enabled in [false, true] {
        assert_eq!(
            native::capabilities(enabled)["commands"],
            json!([
                "get_durable_state",
                "durable_mutate",
                "get_durable_request",
                "get_durable_runs"
            ])
        );
        assert_eq!(
            native::capabilities(enabled)["executionPages"],
            json!({
                "version":1, "command":"get_durable_runs", "cursor":"scope_bound_exclusive",
                "maxRecords":64, "automatic":false
            })
        );
    }
    assert!(!schema["parameters"]["properties"]["action"]["enum"]
        .as_array()
        .unwrap()
        .contains(&json!("get_durable_runs")));
    assert_eq!(
        native::rpc(&h, &json!({"type":"get_durable_runs","version":1}), true)
            .await
            .unwrap(),
        json!({"version":1,"page":s.execution_page(None).await.unwrap()})
    );
    let help = native::interactive_command(&h, "help").await.unwrap();
    assert!(help.contains("/durable runs"));
    assert!(help.contains("runs is TUI-only, not a JSON/tool/RPC action"));
    assert!(!help
        .split("Flat JSON actions:")
        .nth(1)
        .unwrap()
        .split("Every mutation")
        .next()
        .unwrap()
        .contains("runs"));
    assert_eq!(s.snapshot().await.unwrap(), before);
    assert_eq!(receipts(&h).await, controls);
    assert_eq!(facts(&h).await, native);
    assert_eq!(p.attempts.load(Ordering::SeqCst), 0);
    h.close().await.unwrap();
    p.fail_reads.store(true, Ordering::SeqCst);
    p.fail_revision.store(true, Ordering::SeqCst);
    let oversize = format!("{}runs", " ".repeat(MAX_REQUEST_BYTES));
    let error = native::interactive_command(&h, &oversize)
        .await
        .unwrap_err();
    assert!(error.contains("limit_exceeded"));
    assert!(error.contains("64 KiB"));
    assert!(!error.contains("\"closed\"") && !error.contains("read_failure"));
    assert!(native::interactive_command(&h, "help").await.is_ok());
}

#[tokio::test]
async fn actual_read_failure_bad_control_closed_and_65_start_cap_never_become_empty() {
    let p = Probe::new(AgentHarnessOptions::default().session.storage());
    let h = probed(p.clone()).await;
    append(
        &h,
        "read-anchor",
        AgentMessage::User(UserMessage::new("private anchor", 0)),
    )
    .await;
    let native = facts(&h).await;
    let revision = p.inner.history_revision().await.unwrap();
    for revision_failure in [false, true] {
        p.fail_reads.store(!revision_failure, Ordering::SeqCst);
        p.fail_revision.store(revision_failure, Ordering::SeqCst);
        let error = view(&h).await.unwrap_err();
        assert!(error.contains("read_failure"), "{error}");
        assert!(error.contains("No empty state inferred"));
    }
    p.fail_reads.store(false, Ordering::SeqCst);
    p.fail_revision.store(false, Ordering::SeqCst);
    assert_eq!(facts(&h).await, native);
    assert_eq!(p.inner.history_revision().await.unwrap(), revision);
    h.session()
        .storage()
        .append_entry(
            ProvisionedEntry {
                id: "bad-control".into(),
                kind: ProvisionedKind::Custom {
                    custom_type: "rpi.durable.control.v1".into(),
                    data: Some(json!({"invalid":"control"})),
                },
            },
            "main",
        )
        .await
        .unwrap();
    let revision = p.inner.history_revision().await.unwrap();
    let error = view(&h).await.unwrap_err();
    assert!(error.contains("No empty state inferred"));
    assert!(!error.contains("Verified runs:"));
    assert_eq!(p.inner.history_revision().await.unwrap(), revision);
    assert_eq!(p.attempts.load(Ordering::SeqCst), 0);
    h.close().await.unwrap();
    let error = view(&h).await.unwrap_err();
    assert!(error.contains("closed"), "{error}");
    assert!(error.contains("No empty state inferred"));

    let h = memory().await;
    for i in 0..65 {
        let id = format!("budget-{i}");
        start(&h, &id, false).await;
        finish(&h, &id, false).await;
    }
    let revision = h.session().storage().history_revision().await.unwrap();
    let native = facts(&h).await;
    let error = view(&h).await.unwrap_err();
    assert!(error.contains("limit_exceeded"), "{error}");
    assert!(error.contains("No empty state inferred"));
    assert_eq!(
        h.session().storage().history_revision().await.unwrap(),
        revision
    );
    assert_eq!(facts(&h).await, native);
    assert!(receipts(&h).await.as_array().unwrap().is_empty());
    h.close().await.unwrap();
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn cancelled_actual_captured_index_scan_releases_gate_without_late_writes() {
    let p = Probe::new(AgentHarnessOptions::default().session.storage());
    let h = Arc::new(probed(p.clone()).await);
    start(&h, "cancel-open", true).await;
    let s = service(&h).unwrap();
    let before = s.snapshot().await.unwrap();
    let native = facts(&h).await;
    let controls = receipts(&h).await;
    let revision = p.inner.history_revision().await.unwrap();
    p.pause_index_scans.store(true, Ordering::SeqCst);
    let reader = tokio::spawn({
        let h = h.clone();
        async move { native::interactive_command(&h, "runs").await }
    });
    bounded(p.index_scan_captured.notified()).await;
    reader.abort();
    assert!(bounded(reader).await.unwrap_err().is_cancelled());
    p.release_index_scan.notify_one();
    let fresh = view(&h).await.unwrap();
    mandatory(&fresh, 1, 0);
    assert!(fresh.contains("Run \"cancel-open\" | status \"open\""));
    assert_eq!(s.snapshot().await.unwrap(), before);
    assert_eq!(p.inner.history_revision().await.unwrap(), revision);
    assert_eq!(facts(&h).await, native);
    assert_eq!(receipts(&h).await, controls);
    assert_eq!(p.attempts.load(Ordering::SeqCst), 0);
    assert_eq!(p.commits.load(Ordering::SeqCst), 0);
    h.close().await.unwrap();
}