diff --git a/Cargo.lock b/Cargo.lock index a3c872891..0f5148ebc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1685,11 +1685,21 @@ dependencies = [ "tracing", ] +[[package]] +name = "pa-test-macros" +version = "0.10.0" +dependencies = [ + "quote", + "syn 2.0.119", +] + [[package]] name = "pa-test-scratch" version = "0.10.0" dependencies = [ "libc", + "pa-test-macros", + "serde_json", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d08c4cf19..db4bcc3e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ members = [ "crates/pa-tui", "crates/pa-cli", "crates/pa-test-scratch", + "crates/pa-test-macros", ] # Crossterm 0.28.1's kitty support check holds the process-wide event reader diff --git a/crates/pa-test-macros/Cargo.toml b/crates/pa-test-macros/Cargo.toml new file mode 100644 index 000000000..f03a3b027 --- /dev/null +++ b/crates/pa-test-macros/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "pa-test-macros" +version.workspace = true +edition.workspace = true +license.workspace = true +publish = false +description = "Test-only timing attribute for pa-test-scratch." + +[lib] +proc-macro = true + +[dependencies] +quote = "1" +syn = { version = "2", features = ["full"] } diff --git a/crates/pa-test-macros/README.md b/crates/pa-test-macros/README.md new file mode 100644 index 000000000..f20f4b6f1 --- /dev/null +++ b/crates/pa-test-macros/README.md @@ -0,0 +1,11 @@ +# pa-test-macros + +Test-only attribute expansion owned by the timing instrumentation. No runtime, +fixture, or production behavior belongs here. Dependencies are `syn` and `quote`; +the generated code calls `pa-test-scratch` without a dependency back to it. + +Public API: `#[pa_test_scratch::pa_test]` must precede a normal `#[test]`, but +follow `#[tokio::test]`. Tokio forwards it to its synchronous wrapper, so timing +includes runtime setup and teardown instead of only the async body. It preserves +the function and attributes, inserting `_pa_test_timing` as the first local. +See `pa-test-scratch` for the recorder API. diff --git a/crates/pa-test-macros/src/lib.rs b/crates/pa-test-macros/src/lib.rs new file mode 100644 index 000000000..6d5ed485e --- /dev/null +++ b/crates/pa-test-macros/src/lib.rs @@ -0,0 +1,30 @@ +use proc_macro::TokenStream; +use quote::quote; +use syn::{parse_macro_input, ItemFn}; + +#[proc_macro_attribute] +pub fn pa_test(args: TokenStream, input: TokenStream) -> TokenStream { + if !args.is_empty() { + return syn::Error::new( + proc_macro::Span::call_site().into(), + "pa_test takes no arguments", + ) + .to_compile_error() + .into(); + } + let mut function = parse_macro_input!(input as ItemFn); + let name = &function.sig.ident; + let guard = syn::parse_quote! { + let _pa_test_timing = ::pa_test_scratch::TestTiming::start( + concat!(module_path!(), "::", stringify!(#name)) + ); + }; + let first_statement = function + .block + .stmts + .iter() + .position(|statement| !matches!(statement, syn::Stmt::Item(_))) + .unwrap_or(function.block.stmts.len()); + function.block.stmts.insert(first_statement, guard); + quote!(#function).into() +} diff --git a/crates/pa-test-scratch/Cargo.toml b/crates/pa-test-scratch/Cargo.toml index 6351804e9..618d4f815 100644 --- a/crates/pa-test-scratch/Cargo.toml +++ b/crates/pa-test-scratch/Cargo.toml @@ -8,3 +8,5 @@ description = "Test-only: a private TMPDIR per test binary, removed when the bin [dependencies] libc = "0.2" +serde_json.workspace = true +pa-test-macros = { path = "../pa-test-macros" } diff --git a/crates/pa-test-scratch/README.md b/crates/pa-test-scratch/README.md new file mode 100644 index 000000000..85812696c --- /dev/null +++ b/crates/pa-test-scratch/README.md @@ -0,0 +1,45 @@ +# pa-test-scratch + +Test-only scratch ownership and timing. This crate must remain a dev-dependency; +production behavior, fixture changes, and test scheduling are out of scope. +Dependencies are `libc`, `serde_json`, and the leaf proc-macro crate `pa-test-macros`. + +Linking owns the existing per-binary scratch directory lifecycle. + +## Timing API + +Place `#[pa_test_scratch::pa_test]` immediately before a normal `#[test]`. +For async tests, place it immediately after `#[tokio::test]`. Tokio forwards the +attribute to its generated synchronous test wrapper, so the timing guard covers +runtime setup, the async body, and runtime teardown. Putting the timing attribute +before Tokio would time only the async body. + +The macro retains the function attributes and introduces `_pa_test_timing` as +the wrapper's first executable statement and first local, so it drops after +runtime and fixture locals. Leading item declarations stay in place; they do not +execute before the guard. + +- `TestTiming::start(full_name)` starts a test manually. +- `_pa_test_timing.span("fixture")` returns an owned `TimingSpan`. +- `_pa_test_timing.recorder()` returns a cloneable `TimingRecorder`. +- `TimingRecorder::span(name)` starts an owned span from helpers or spawned tasks. + +The recorder and spans can cross await points and threads. +`timing::span(name)` is a convenience for helpers running on the original test +thread, resolved through a thread-ID registry. It does not find test context +after task migration; use explicit recorders there. Finish all spawned work and +drop its spans before the test returns; the test guard writes its collected spans on drop. + +Timing is enabled by default. `PA_TEST_TIMING=0` disables timing and file output +for overhead comparisons. `PA_TEST_TIMING_DIR` selects the destination; otherwise +it is the workspace `target/test-timings` directory. Each process appends to +`-.jsonl`, with writes serialized within that process. + +Each JSON line has `kind: "test"`, `test` (libtest name without the crate prefix), +`binary`, `pid`, `start_unix_ns`, `end_unix_ns`, `elapsed_ns`, `panicking`, +`outcome` (`"panic"` or `"returned"`), and `spans`. Each span has `name`, the same +timestamps, elapsed duration, and panic flag. Durations use a monotonic clock; timestamps use the Unix clock. The panic +flag is unwind state, not the harness outcome (`should_panic` can pass). + +Write failures panic during normal completion. During unwinding they are reported +to stderr without a second panic; the runner must reject the missing record. diff --git a/crates/pa-test-scratch/src/lib.rs b/crates/pa-test-scratch/src/lib.rs index ee0168af9..964f216af 100644 --- a/crates/pa-test-scratch/src/lib.rs +++ b/crates/pa-test-scratch/src/lib.rs @@ -27,6 +27,13 @@ fn record_cleanup_failure() { CLEANUP_FAILED.store(true, std::sync::atomic::Ordering::Relaxed); } +extern crate self as pa_test_scratch; + +pub mod timing; + +pub use pa_test_macros::pa_test; +pub use timing::{TestTiming, TimingRecorder, TimingSpan}; + #[cfg(unix)] mod hook { use std::path::{Path, PathBuf}; diff --git a/crates/pa-test-scratch/src/timing.rs b/crates/pa-test-scratch/src/timing.rs new file mode 100644 index 000000000..ad0dcf920 --- /dev/null +++ b/crates/pa-test-scratch/src/timing.rs @@ -0,0 +1,261 @@ +use std::collections::HashMap; +use std::fs::{File, OpenOptions}; +use std::io::{self, Write}; +use std::path::PathBuf; +use std::sync::{Arc, Mutex, OnceLock, Weak}; +use std::thread::{self, ThreadId}; +use std::time::{Instant, SystemTime, UNIX_EPOCH}; + +use serde_json::{json, Value}; + +type Spans = Mutex>; + +static RECORDERS: OnceLock>>> = OnceLock::new(); +static OUTPUT: OnceLock, String>> = OnceLock::new(); + +pub struct TestTiming { + state: Option, +} + +struct TestState { + name: String, + started: Instant, + start_unix_ns: u128, + thread: ThreadId, + recorder: TimingRecorder, +} + +#[derive(Clone, Default)] +pub struct TimingRecorder { + spans: Option>, +} + +pub struct TimingSpan { + state: Option, +} + +struct SpanState { + name: String, + started: Instant, + start_unix_ns: u128, + spans: Arc, +} + +impl TestTiming { + #[must_use] + pub fn start(full_name: &str) -> Self { + if std::env::var_os("PA_TEST_TIMING").is_some_and(|value| value == "0") { + return Self { state: None }; + } + let started = Instant::now(); + let start_unix_ns = unix_ns(); + let thread = thread::current(); + let normalized = full_name + .split_once("::") + .map_or(full_name, |(_, name)| name); + let name = thread.name().unwrap_or(normalized).to_owned(); + let spans = Arc::new(Mutex::new(Vec::new())); + RECORDERS + .get_or_init(Mutex::default) + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner) + .insert(thread.id(), Arc::downgrade(&spans)); + Self { + state: Some(TestState { + name, + started, + start_unix_ns, + thread: thread.id(), + recorder: TimingRecorder { spans: Some(spans) }, + }), + } + } + + #[must_use] + pub fn recorder(&self) -> TimingRecorder { + self.state + .as_ref() + .map_or_else(TimingRecorder::default, |state| state.recorder.clone()) + } + + #[must_use] + pub fn span(&self, name: &str) -> TimingSpan { + self.recorder().span(name) + } +} + +impl TimingRecorder { + #[must_use] + pub fn span(&self, name: &str) -> TimingSpan { + TimingSpan { + state: self.spans.as_ref().map(|spans| SpanState { + name: name.to_owned(), + started: Instant::now(), + start_unix_ns: unix_ns(), + spans: Arc::clone(spans), + }), + } + } +} + +#[must_use] +pub fn span(name: &str) -> TimingSpan { + let spans = RECORDERS.get().and_then(|recorders| { + recorders + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner) + .get(&thread::current().id()) + .and_then(Weak::upgrade) + }); + TimingRecorder { spans }.span(name) +} + +impl Drop for TimingSpan { + fn drop(&mut self) { + if let Some(state) = self.state.take() { + let elapsed_ns = state.started.elapsed().as_nanos(); + let end_unix_ns = unix_ns(); + state + .spans + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner) + .push(json!({ + "name": state.name, + "start_unix_ns": state.start_unix_ns, + "end_unix_ns": end_unix_ns, + "elapsed_ns": elapsed_ns, + "panicking": thread::panicking(), + })); + } + } +} + +impl Drop for TestTiming { + fn drop(&mut self) { + if let Some(state) = self.state.take() { + let elapsed_ns = state.started.elapsed().as_nanos(); + let end_unix_ns = unix_ns(); + let panicking = thread::panicking(); + RECORDERS + .get_or_init(Mutex::default) + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner) + .remove(&state.thread); + let spans = state + .recorder + .spans + .as_ref() + .expect("enabled timing has a recorder") + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner); + let record = json!({ + "kind": "test", + "test": state.name, + "binary": binary_name(), + "pid": std::process::id(), + "start_unix_ns": state.start_unix_ns, + "end_unix_ns": end_unix_ns, + "elapsed_ns": elapsed_ns, + "panicking": panicking, + "outcome": if panicking { "panic" } else { "returned" }, + "spans": &*spans, + }); + if let Err(error) = write_record(&record) { + if panicking { + let _ = writeln!(io::stderr().lock(), "test timing write failed: {error}"); + } else { + panic!("test timing write failed: {error}"); + } + } + } + } +} + +fn unix_ns() -> u128 { + SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_nanos() +} + +fn binary_name() -> String { + std::env::current_exe() + .expect("test executable path") + .file_name() + .expect("test executable file name") + .to_string_lossy() + .into_owned() +} + +fn write_record(record: &Value) -> Result<(), String> { + let output = OUTPUT.get_or_init(|| { + let directory = std::env::var_os("PA_TEST_TIMING_DIR").map_or_else( + || PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../target/test-timings"), + PathBuf::from, + ); + std::fs::create_dir_all(&directory).map_err(|error| error.to_string())?; + let binary = binary_name(); + let pid = std::process::id(); + OpenOptions::new() + .create(true) + .append(true) + .open(directory.join(format!("{binary}-{pid}.jsonl"))) + .map(Mutex::new) + .map_err(|error| error.to_string()) + }); + let output = output.as_ref().map_err(Clone::clone)?; + let mut file = output + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner); + serde_json::to_writer(&mut *file, record).map_err(|error| error.to_string())?; + file.write_all(b"\n").map_err(|error| error.to_string()) +} + +#[cfg(test)] +mod tests { + use super::{TimingRecorder, TimingSpan}; + use std::sync::{Arc, Mutex}; + + struct TeardownSpan(TimingRecorder); + + impl Drop for TeardownSpan { + fn drop(&mut self) { + let _span = self.0.span("teardown"); + } + } + + #[crate::pa_test] + #[test] + fn spans_include_local_teardown_before_the_enclosing_scope_ends() { + let spans = Arc::new(Mutex::new(Vec::new())); + let recorder = TimingRecorder { + spans: Some(Arc::clone(&spans)), + }; + { + let _scope = recorder.span("scope"); + let _local = TeardownSpan(recorder); + } + let recorded = spans.lock().expect("span lock"); + let names: Vec<_> = recorded.iter().map(|span| span["name"].as_str()).collect(); + assert_eq!(names, vec![Some("teardown"), Some("scope")]); + assert!(recorded.iter().all(|span| span["panicking"] == false)); + } + + #[crate::pa_test] + #[test] + fn spans_capture_unwinding_without_requiring_a_test_thread_context() { + let spans = Arc::new(Mutex::new(Vec::new())); + let recorder = TimingRecorder { + spans: Some(Arc::clone(&spans)), + }; + let result = std::panic::catch_unwind(|| { + let _span: TimingSpan = recorder.span("unwind"); + panic!("span unwind"); + }); + assert!(result.is_err()); + let recorded = spans.lock().expect("span lock"); + assert_eq!(recorded.len(), 1); + assert_eq!(recorded[0]["name"], "unwind"); + assert!(recorded[0]["panicking"].as_bool().expect("panic flag")); + } +} diff --git a/crates/pa-test-scratch/tests/timing.rs b/crates/pa-test-scratch/tests/timing.rs new file mode 100644 index 000000000..cab3d6640 --- /dev/null +++ b/crates/pa-test-scratch/tests/timing.rs @@ -0,0 +1,22 @@ +use pa_test_scratch::timing; + +#[pa_test_scratch::pa_test] +#[test] +fn timing_keeps_owned_spans_when_work_moves_threads() { + let recorder = _pa_test_timing.recorder(); + let span = recorder.span("across_threads"); + std::thread::spawn(move || { + let _span = span; + let _nested = recorder.span("worker"); + }) + .join() + .expect("timed worker returns normally"); +} + +#[pa_test_scratch::pa_test] +#[test] +#[should_panic(expected = "timed test panic")] +fn timing_retains_should_panic_behavior() { + let _span = timing::span("unwind"); + panic!("timed test panic"); +} -- knotmirror 0.0.1 From 28abe7698a9836d0d554f88a2357caf906857045 Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Sat, 21 Nov 2026 12:09:37 +0000 Subject: [PATCH 2/9] test(timing): add local runner and sidecar aggregation --- scripts/instrument_test_timings.py | 105 ++++ scripts/test_instrument_test_timings.py | 35 ++ scripts/test_test_timings.py | 204 ++++++++ scripts/test_timings.py | 611 ++++++++++++++++++++++++ 4 files changed, 955 insertions(+) create mode 100644 scripts/instrument_test_timings.py create mode 100644 scripts/test_instrument_test_timings.py create mode 100644 scripts/test_test_timings.py create mode 100644 scripts/test_timings.py diff --git a/scripts/instrument_test_timings.py b/scripts/instrument_test_timings.py new file mode 100644 index 000000000..e0afa4849 --- /dev/null +++ b/scripts/instrument_test_timings.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 +import argparse +from pathlib import Path +import re + + +TEST_ATTRIBUTE = re.compile(r"(?m)^([ \t]*)#\[(?:test|tokio::test(?:\([^]]*\))?)\]") +TIMING_ATTRIBUTE = "#[pa_test_scratch::pa_test]" + + +def code_mask(source): + masked = list(source) + index = 0 + while index < len(source): + start = index + if source.startswith("//", index): + end = source.find("\n", index) + index = len(source) if end < 0 else end + elif source.startswith("/*", index): + depth = 1 + index += 2 + while index < len(source) and depth: + if source.startswith("/*", index): + depth += 1 + index += 2 + elif source.startswith("*/", index): + depth -= 1 + index += 2 + else: + index += 1 + elif source[index] in "rb" and (raw := re.match(r'(?:br|r)(#*)"', source[index:])): + close = '"' + raw[1] + end = source.find(close, index + raw.end()) + if end < 0: + raise ValueError("unterminated Rust raw string") + index = end + len(close) + elif source[index] == '"': + index += 1 + while index < len(source): + if source[index] == "\\": + index += 2 + elif source[index] == '"': + index += 1 + break + else: + index += 1 + elif source[index] == "'" and (char := re.match(r"'(?:[^'\\\n]|\\(?:[^u]|u\{[^}]*\}))'", source[index:])): + index += char.end() + else: + index += 1 + continue + for offset in range(start, index): + if masked[offset] != "\n": + masked[offset] = " " + return "".join(masked) + + +def instrument(source): + insertions = [] + for match in TEST_ATTRIBUTE.finditer(code_mask(source)): + if "tokio::test" in match[0]: + following = source[match.end():].lstrip().splitlines() + if following and following[0].strip() == TIMING_ATTRIBUTE: + continue + insertions.append((match.end(), "\n" + match[1] + TIMING_ATTRIBUTE)) + else: + previous = source[:match.start()].rstrip().splitlines() + if previous and previous[-1].strip() == TIMING_ATTRIBUTE: + continue + insertions.append((match.start(), match[1] + TIMING_ATTRIBUTE + "\n")) + for offset, text in reversed(insertions): + source = source[:offset] + text + source[offset:] + return source, len(insertions) + + +def inventory(repo): + integration = list((repo / "crates").glob("*/tests/**/*.rs")) + units = [path for crate in ("pa-core", "pa-daemon") + for path in (repo / "crates" / crate / "src").rglob("*.rs")] + return sorted(set(integration + units)) + + +def main(): + parser = argparse.ArgumentParser(description="Add timing attributes to integration tests and pa-core/pa-daemon unit tests.") + parser.add_argument("--write", action="store_true") + args = parser.parse_args() + repo = Path(__file__).resolve().parents[1] + missing = 0 + files = 0 + for path in inventory(repo): + source = path.read_text() + updated, count = instrument(source) + if count: + print(f"{path.relative_to(repo)}: {count}") + files += 1 + missing += count + if args.write: + path.write_text(updated) + print(f"{missing} uninstrumented scoped test attributes in {files} files") + if missing and not args.write: + raise SystemExit(1) + + +if __name__ == "__main__": + main() diff --git a/scripts/test_instrument_test_timings.py b/scripts/test_instrument_test_timings.py new file mode 100644 index 000000000..42aaeb6c9 --- /dev/null +++ b/scripts/test_instrument_test_timings.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +import unittest + +from instrument_test_timings import instrument + + +class InstrumentTests(unittest.TestCase): + def test_keeps_attributes_and_test_bodies(self): + source = '''#[cfg(unix)] +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +#[should_panic] +async fn sample() { panic!("expected"); } +''' + expected = source.replace("#[should_panic]", "#[pa_test_scratch::pa_test]\n#[should_panic]") + self.assertEqual(instrument(source), (expected, 1)) + self.assertEqual(instrument(expected), (expected, 0)) + + def test_ignores_strings_and_nested_comments(self): + source = '''let sample = r###" +#[test] +fn quoted() {} +"###; +/* outer /* inner */ +#[test] +fn commented() {} +*/ +#[test] +fn actual() { let text = "\\\"escaped"; } +''' + expected = source.replace("#[test]\nfn actual", "#[pa_test_scratch::pa_test]\n#[test]\nfn actual") + self.assertEqual(instrument(source), (expected, 1)) + + +if __name__ == "__main__": + unittest.main() diff --git a/scripts/test_test_timings.py b/scripts/test_test_timings.py new file mode 100644 index 000000000..fa7453517 --- /dev/null +++ b/scripts/test_test_timings.py @@ -0,0 +1,204 @@ +#!/usr/bin/env python3 +import copy +from concurrent.futures import ThreadPoolExecutor +import json +import os +from pathlib import Path +import signal +import subprocess +import sys +import tempfile +import unittest + +from test_timings import Children, load_timing_run, reconcile, span_totals, statuses + + +def target(required=True): + return {"inventory": ["module::normal", "module::panic", "module::ignored"], + "ignored": ["module::ignored"], "timing_required": required, + "statuses": [("module::normal", "ok"), ("module::panic", "ok"), + ("module::ignored", "ignored")]} + + +def record(name, panic=False): + return {"kind": "test", "test": name, "binary": "fixture", "pid": 123, + "start_unix_ns": 100, "end_unix_ns": 200, "elapsed_ns": 100, + "panicking": panic, "outcome": "panic" if panic else "returned", "spans": []} + + +class ChildOwnership(unittest.TestCase): + def setUp(self): + private = tempfile.TemporaryDirectory(prefix="pa-timing-test-") + self.addCleanup(private.cleanup) + self.cwd = Path(private.name) + home = self.cwd / "home" + temporary = self.cwd / "tmp" + home.mkdir() + temporary.mkdir() + self.env = {"HOME": str(home), "TMPDIR": str(temporary), + "TMP": str(temporary), "TEMP": str(temporary)} + + def test_main_thread_child_inherits_unblocked_interrupt_and_term(self): + children = Children() + child = children.spawn( + [sys.executable, "-I", "-c", "import json, signal; print(json.dumps([int(s) for s in signal.pthread_sigmask(signal.SIG_BLOCK, [])]))"], + cwd=self.cwd, env=self.env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + try: + children.resume_signals() + stdout, stderr = child.communicate() + finally: + child.wait() + children.complete(child) + self.assertEqual((child.returncode, stderr), (0, "")) + self.assertFalse({signal.SIGINT, signal.SIGTERM} & set(json.loads(stdout))) + self.assertFalse(children.active) + + def test_cancel_signals_only_tracked_group_and_owner_reaps(self): + children = Children() + child = children.spawn( + [sys.executable, "-I", "-c", "import signal; print('ready', flush=True); signal.pause()"], + cwd=self.cwd, env=self.env, stdout=subprocess.PIPE, text=True) + + def reap(): + try: + _, status, usage = os.wait4(child.pid, 0) + child.returncode = os.waitstatus_to_exitcode(status) + return child.returncode, usage + finally: + children.complete(child) + + try: + with ThreadPoolExecutor(max_workers=1) as workers: + future = workers.submit(reap) + try: + children.resume_signals() + self.assertEqual(child.stdout.readline(), "ready\n") + self.assertEqual(os.getpgid(child.pid), child.pid) + finally: + children.cancel() + code, usage = future.result() + self.assertEqual(code, -signal.SIGTERM) + self.assertGreaterEqual(usage.ru_utime, 0) + self.assertFalse(children.active) + with self.assertRaises(RuntimeError): + children.spawn([sys.executable, "-I", "-c", "pass"], cwd=self.cwd, env=self.env) + finally: + child.stdout.close() + + +class TimingReports(unittest.TestCase): + def test_harness_status_keeps_expected_panic_success_separate_from_guard(self): + fixture = target() + fixture["statuses"] = statuses( + "running 3 tests\n" + "test module::normal ... ok\n" + "test module::panic - should panic ... ok\n" + "test module::ignored ... ignored, fixture\n" + "failures:\n" + "test bogus::captured_stdout ... FAILED\n" + "test result: ok. 2 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.01s\n", + fixture["inventory"], fixture["ignored"]) + records = [record("module::normal"), record("module::panic", panic=True)] + self.assertEqual(reconcile(fixture, records, disabled=False), []) + self.assertEqual(dict(fixture["statuses"])[records[1]["test"]], "ok") + self.assertEqual(records[1]["outcome"], "panic") + + def test_nested_failed_child_does_not_override_passing_parent_summary(self): + fixture = target() + log = ( + "running 3 tests\n" + "running 1 test\n" + "test module::normal ... FAILED\n" + "failures:\n\n module::normal\n\n" + "test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2 filtered out; finished in 0.01s\n" + "test module::normal ... ok\n" + "test module::normal ... ok\n" + "test module::panic - should panic ... ok\n" + "test module::ignored ... ignored\n" + "test result: ok. 2 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.02s\n") + self.assertEqual(dict(statuses(log, fixture["inventory"], fixture["ignored"])), + dict(fixture["statuses"])) + + def test_failed_parent_uses_only_final_failure_name_list(self): + fixture = target() + log = ( + "running 3 tests\n" + "failures:\n\n---- module::panic stdout ----\n" + "failures:\n\n module::panic\n\n" + "test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2 filtered out; finished in 0.01s\n" + "failures:\n\n module::normal\n\n" + "test result: FAILED. 1 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.02s\n") + self.assertEqual(dict(statuses(log, fixture["inventory"], fixture["ignored"])), + {"module::normal": "FAILED", "module::panic": "ok", "module::ignored": "ignored"}) + + def test_missing_filtered_or_mismatched_summary_cannot_claim_completion(self): + fixture = target() + for log in ( + "test module::normal ... ok\n", + "test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out; finished in 0.01s\n", + "test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.01s\n", + "failures:\n\n module::panic\n\n module::normal\n\n" + "test result: FAILED. 1 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.01s\n"): + with self.subTest(log=log), self.assertRaises(ValueError): + statuses(log, fixture["inventory"], fixture["ignored"]) + + def test_integrations_require_one_record_per_completed_test(self): + records = [record("module::normal"), record("module::panic", panic=True)] + self.assertEqual(reconcile(target(), records, disabled=False), []) + for invalid in (records[:1], records + records[:1], records + [record("unexpected")]): + with self.subTest(records=invalid): + self.assertTrue(reconcile(target(), invalid, disabled=False)) + + def test_units_report_uncovered_but_strict_mode_rejects(self): + fixture = target(required=False) + self.assertEqual(reconcile(fixture, [], disabled=False), []) + self.assertEqual(fixture["uncovered_tests"], ["module::normal", "module::panic"]) + strict = copy.deepcopy(fixture) + strict["timing_required"] = True + self.assertTrue(reconcile(strict, [], disabled=False)) + + def test_raw_sidecars_group_by_binary_and_pid_without_inventing_status(self): + first = record("module::normal") + second = record("module::panic", panic=True) + second["pid"] = 456 + with tempfile.TemporaryDirectory() as state: + directory = Path(state) + (directory / "fixture-123.jsonl").write_text(json.dumps(first) + "\n") + (directory / "fixture-456.jsonl").write_text(json.dumps(second) + "\n") + manifest = load_timing_run(directory) + self.assertTrue(manifest["coverage_unverified"]) + self.assertEqual({row["pid"] for row in manifest["targets"]}, {123, 456}) + self.assertEqual([row["statuses"] for row in manifest["targets"]], [[], []]) + self.assertEqual(sum(len(row["records"]) for row in manifest["targets"]), 2) + self.assertTrue(all(row["coverage_unverified"] for row in manifest["targets"])) + + def test_completion_is_independent_of_passing_and_detects_early_abort(self): + fixture = target(required=False) + fixture["statuses"][0] = ("module::normal", "FAILED") + reconcile(fixture, [], disabled=False) + self.assertTrue(fixture["whole_test_set_completed"]) + self.assertFalse(fixture["aborted_early"]) + self.assertEqual(fixture["failed_phases"], {"module::normal": ["unknown"]}) + fixture["statuses"].pop(1) + reconcile(fixture, [], disabled=False) + self.assertFalse(fixture["whole_test_set_completed"]) + self.assertTrue(fixture["aborted_early"]) + self.assertEqual((fixture["completed_count"], fixture["expected_nonignored_count"]), (1, 2)) + + def test_nested_and_overlapping_spans_do_not_double_count(self): + timing = record("module::normal") + timing["spans"] = [ + {"name": "outer", "start_unix_ns": 110, "end_unix_ns": 180, "elapsed_ns": 70}, + {"name": "inner", "start_unix_ns": 120, "end_unix_ns": 140, "elapsed_ns": 20}, + {"name": "inner", "start_unix_ns": 130, "end_unix_ns": 150, "elapsed_ns": 20}, + {"name": "outer", "start_unix_ns": 185, "end_unix_ns": 190, "elapsed_ns": 5}, + ] + totals, unattributed = span_totals(timing) + self.assertEqual((totals, unattributed), ({"inner": 30, "outer": 75}, 25)) + self.assertEqual(reconcile({"inventory": ["module::normal"], "ignored": [], + "statuses": [("module::normal", "ok")], "timing_required": True}, + [timing], disabled=False), []) + + +if __name__ == "__main__": + unittest.main() diff --git a/scripts/test_timings.py b/scripts/test_timings.py new file mode 100644 index 000000000..4ee1b4eb0 --- /dev/null +++ b/scripts/test_timings.py @@ -0,0 +1,611 @@ +#!/usr/bin/env python3 +"""Developer-only whole-binary timing runs. Doctests run last, timing uncovered. + +Requires a Unix host with os.wait4 (the supported developer host is Linux). +Use a qualified, synced kernel and private CARGO_HOME/CARGO_TARGET_DIR, as for +check_workspace_tests.py. This runner never filters, retries, or changes native +libtest concurrency. run.json retains commands, isolated environments and logs. +""" +import argparse +from collections import Counter +from concurrent.futures import ThreadPoolExecutor, as_completed +import json +import os +from pathlib import Path +import re +import shutil +import signal +import subprocess +import tempfile +import time +from threading import Event, RLock, current_thread, main_thread + +from check_workspace_tests import CLEANUP_SECONDS, EXCLUSIVE, target_environment, target_groups + + +class Children: + def __init__(self): + self.lock = RLock() + self.active = {} + self.cancelled = False + self.launching_main = False + self.pending_signal = None + + def spawn(self, command, **kwargs): + if current_thread() is main_thread(): + self.launching_main = True + try: + with self.lock: + if self.cancelled: + raise RuntimeError("run cancelled before child launch") + child = subprocess.Popen(command, start_new_session=True, **kwargs) + self.active[child.pid] = Event() + return child + except BaseException: + self.resume_signals() + raise + + def resume_signals(self): + if current_thread() is main_thread(): + self.launching_main = False + pending, self.pending_signal = self.pending_signal, None + if pending is not None: + signal.raise_signal(pending) + + def complete(self, child): + with self.lock: + event = self.active.pop(child.pid) + event.set() + + def cancel(self): + previous = None + if current_thread() is main_thread(): + previous = signal.pthread_sigmask(signal.SIG_BLOCK, {signal.SIGINT, signal.SIGTERM}) + try: + with self.lock: + if self.cancelled: + return + self.cancelled = True + children = list(self.active.items()) + for pid, _ in children: + try: + os.killpg(pid, signal.SIGTERM) + except ProcessLookupError: + pass + deadline = time.monotonic() + CLEANUP_SECONDS + for _, done in children: + done.wait(max(0, deadline - time.monotonic())) + for pid, _ in children: + try: + os.killpg(pid, signal.SIGKILL) + except ProcessLookupError: + pass + finally: + if previous is not None: + signal.pthread_sigmask(signal.SIG_SETMASK, previous) + + +def snapshot(): + return {"unix_ns": time.time_ns(), "load_average": os.getloadavg(), + "cpu_count": os.cpu_count()} + + +def save(path, value): + path.write_text(json.dumps(value, indent=2) + "\n") + + +def release_state(state, record, cancelled): + record["state_retained"] = cancelled + if cancelled: + return + try: + shutil.rmtree(state) + except OSError as error: + record["cleanup_error"] = f"{type(error).__name__}: {error}" + record["state_retained"] = True + + +def environment(repo, state, ambient): + env = target_environment(repo, state, ambient) + env.pop("RUST_TEST_THREADS", None) + if "RUST_TEST_THREADS" in ambient: + env["RUST_TEST_THREADS"] = ambient["RUST_TEST_THREADS"] + env["PA_CORE_KERNEL_PYTHON"] = ambient["PA_CORE_KERNEL_PYTHON"] + return env + + +def checked(command, cwd, env, log, commands, children): + commands.append({"command": command, "cwd": str(cwd), "environment": env}) + child = children.spawn(command, cwd=cwd, env=env, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True) + try: + try: + children.resume_signals() + stdout, stderr = child.communicate() + except BaseException: + children.cancel() + stdout, stderr = child.communicate() + log.write_text(stdout + stderr) + raise + log.write_text(stdout + stderr) + finally: + children.complete(child) + if child.returncode: + raise RuntimeError(f"command failed ({child.returncode}); see {log}") + return stdout + + +def inventory(binary, cwd, env, directory, commands, children): + inventories = [] + for ignored in (False, True): + command = [binary, "--list", "--format", "terse"] + if ignored: + command.append("--ignored") + output = checked(command, cwd, env, + directory / ("ignored.log" if ignored else "inventory.log"), commands, children) + names = [line[:-6] for line in output.splitlines() if line.endswith(": test")] + if len(names) != len(set(names)): + raise ValueError(f"duplicate inventory entries for {binary}") + inventories.append(set(names)) + all_names, ignored = inventories + if not ignored <= all_names: + raise ValueError(f"ignored inventory not a subset for {binary}") + return sorted(all_names), sorted(ignored) + + +def statuses(log, inventory, ignored): + pattern = re.compile( + r"^test result: (ok|FAILED)\. (\d+) passed; (\d+) failed; (\d+) ignored; " + r"(\d+) measured; (\d+) filtered out; finished in [^\n]*$", re.MULTILINE) + summaries = list(pattern.finditer(log)) + if not summaries: + raise ValueError("parent harness final summary missing; completion unknown") + summary = summaries[-1] + outcome = summary[1] + passed, failed, ignored_count, measured, filtered = map(int, summary.groups()[1:]) + expected = set(inventory) - set(ignored) + if (passed + failed != len(expected) or ignored_count != len(ignored) + or measured or filtered or (outcome == "ok") != (failed == 0)): + raise ValueError("parent harness final summary does not match unfiltered inventory") + failed_names = [] + if failed: + preceding = log[:summary.start()].rstrip() + marker = preceding.rfind("\nfailures:\n") + block = preceding[marker + 1:] if marker >= 0 else preceding + lines = block.splitlines() + if not lines or lines[0] != "failures:" or any( + line and not line[0].isspace() for line in lines[1:]): + raise ValueError("parent harness final failure-name list missing") + failed_names = [line.strip() for line in lines[1:] if line.strip()] + if (len(failed_names) != failed or len(set(failed_names)) != failed + or not set(failed_names) <= expected): + raise ValueError("parent harness final failure-name list disagrees with summary/inventory") + return [(name, "ignored" if name in ignored else "FAILED" if name in failed_names else "ok") + for name in sorted(inventory)] + + +def read_records(directory, binary, pid): + path = directory / f"{Path(binary).name}-{pid}.jsonl" + records = [] + if path.exists(): + for line in path.read_text().splitlines(): + record = json.loads(line) + if record.get("pid") != pid: + raise ValueError(f"foreign pid in {path}") + records.append(record) + return records + + +def reconcile(target, records, disabled): + errors = [] + expected = set(target["inventory"]) - set(target["ignored"]) + completed = target["statuses"] + all_counts = Counter(name for name, _ in completed) + if set(all_counts) - set(target["inventory"]): + errors.append("unexpected harness status names") + if any(count != 1 for count in all_counts.values()): + errors.append("duplicate harness status names") + counts = Counter(name for name, status in completed if status != "ignored") + target["expected_nonignored_count"] = len(expected) + target["completed_count"] = sum(counts.values()) + target["whole_test_set_completed"] = counts == Counter({name: 1 for name in expected}) + target["aborted_early"] = not target["whole_test_set_completed"] + target["failed_phases"] = {name: ["unknown"] for name, status in completed if status == "FAILED"} + if set(counts) != expected: + errors.append(f"completion mismatch: missing={sorted(expected - counts.keys())}, " + f"unexpected={sorted(counts.keys() - expected)}") + if any(count != 1 for count in counts.values()): + errors.append("duplicate harness completions") + recorded = Counter(record.get("test") for record in records) + uncovered = sorted(expected - recorded.keys()) + target["uncovered_tests"] = uncovered + required = target["timing_required"] + if not disabled and ((required and uncovered) or recorded.keys() - expected): + errors.append(f"record mismatch: missing={sorted(expected - recorded.keys())}, " + f"unexpected={sorted(recorded.keys() - expected, key=str)}") + if disabled and records: + errors.append("timing disabled but records were emitted") + if any(count != 1 for count in recorded.values()): + errors.append("duplicate timing records") + for record in records: + start, end = record["start_unix_ns"], record["end_unix_ns"] + if (record.get("kind") != "test" or end < start + or record["elapsed_ns"] < 0 + or not isinstance(record.get("binary"), str) + or record.get("outcome") not in ("panic", "returned") + or record.get("panicking") != (record.get("outcome") == "panic")): + errors.append(f"invalid record: {record.get('test')}") + failed_spans = [span["name"] for span in record["spans"] if span.get("panicking") is True] + if record.get("test") in target["failed_phases"] and failed_spans: + target["failed_phases"][record["test"]] = failed_spans + for span in record["spans"]: + if (not isinstance(span["name"], str) + or not start <= span["start_unix_ns"] <= span["end_unix_ns"] <= end + or span["elapsed_ns"] < 0): + errors.append(f"invalid span: {record.get('test')}") + return errors + + +def execute(target, repo, ambient, run_dir, disabled, children): + directory = run_dir / target["id"] + directory.mkdir() + private = Path(tempfile.mkdtemp(prefix="pa-t-", dir="/tmp")) + target.update(state_root=str(private), commands=[], load_before=snapshot(), + exit_code=None, expected_nonignored_count=None, completed_count=0, + whole_test_set_completed=False, aborted_early=True, failed_phases={}, errors=[]) + try: + env = environment(repo, private, ambient) + timing_dir = directory / "records" + timing_dir.mkdir() + env["PA_TEST_TIMING"] = "0" if disabled else "1" + env["PA_TEST_TIMING_DIR"] = str(timing_dir) + deps = str(Path(target["binary"]).parent) + loader = "DYLD_FALLBACK_LIBRARY_PATH" if os.uname().sysname == "Darwin" else "LD_LIBRARY_PATH" + env[loader] = os.pathsep.join(filter(None, [deps, env.get(loader)])) + cwd = Path(target["cwd"]) + target["environment"] = env + target["inventory"], target["ignored"] = inventory( + target["binary"], cwd, env, directory, target["commands"], children) + target["expected_nonignored_count"] = len(set(target["inventory"]) - set(target["ignored"])) + command = [target["binary"]] + target["commands"].append({"command": command, "cwd": str(cwd), "environment": env}) + with (directory / "harness.log").open("w") as output: + started = time.monotonic_ns() + target["start_unix_ns"] = time.time_ns() + target["start_monotonic_ns"] = started + child = children.spawn(command, cwd=cwd, env=env, stdout=output, + stderr=subprocess.STDOUT) + target["pid"] = child.pid + try: + children.resume_signals() + _, status, usage = os.wait4(child.pid, 0) + except BaseException: + try: + os.killpg(child.pid, signal.SIGKILL) + except ProcessLookupError: + pass + _, status, usage = os.wait4(child.pid, 0) + child.returncode = os.waitstatus_to_exitcode(status) + raise + finally: + children.complete(child) + child.returncode = os.waitstatus_to_exitcode(status) + target.update(exit_code=child.returncode, elapsed_ns=time.monotonic_ns() - started, + end_unix_ns=time.time_ns(), cpu_user_seconds=usage.ru_utime, + cpu_system_seconds=usage.ru_stime) + try: + target["statuses"] = statuses((directory / "harness.log").read_text(), + target["inventory"], target["ignored"]) + target["harness_status_source"] = "final unfiltered libtest summary and final failure-name list" + except ValueError as error: + target["statuses"] = [] + target["errors"].append(str(error)) + target["records"] = read_records(timing_dir, target["binary"], child.pid) + target["errors"].extend(reconcile(target, target["records"], disabled)) + if child.returncode: + target["errors"].append(f"binary exited {child.returncode}") + except Exception as error: + target.setdefault("errors", []).append(f"{type(error).__name__}: {error}") + finally: + target["load_after"] = snapshot() + target["cancelled"] = children.cancelled + release_state(private, target, children.cancelled) + save(directory / "target.json", target) + return target + + +def execute_doctests(repo, ambient, run_dir, selection, children): + target = {"id": "doctests", "kinds": ["doctest"], "records": [], "statuses": [], + "errors": [], "load_before": snapshot(), "timing_uncovered": True, + "exit_code": None, "expected_nonignored_count": None, "completed_count": None, + "whole_test_set_completed": None, "aborted_early": None, + "completion_basis": "native Cargo doctest aggregate; inventory not collected"} + directory = run_dir / "doctests" + directory.mkdir() + private = Path(tempfile.mkdtemp(prefix="pa-t-", dir="/tmp")) + try: + env = environment(repo, private, ambient) + env.pop("PA_TEST_TIMING_DIR", None) + env["PA_TEST_TIMING"] = "0" + command = ["cargo", "test", "--locked", "--offline", *selection, "--doc"] + target.update(command=command, cwd=str(repo), environment=env, state_root=str(private)) + with (directory / "harness.log").open("w") as output: + started = time.monotonic_ns() + target["start_unix_ns"] = time.time_ns() + target["start_monotonic_ns"] = started + child = children.spawn(command, cwd=repo, env=env, stdout=output, + stderr=subprocess.STDOUT) + target["pid"] = child.pid + try: + children.resume_signals() + _, status, usage = os.wait4(child.pid, 0) + except BaseException: + try: + os.killpg(child.pid, signal.SIGKILL) + except ProcessLookupError: + pass + _, status, usage = os.wait4(child.pid, 0) + child.returncode = os.waitstatus_to_exitcode(status) + raise + finally: + children.complete(child) + child.returncode = os.waitstatus_to_exitcode(status) + target.update(exit_code=child.returncode, elapsed_ns=time.monotonic_ns() - started, + end_unix_ns=time.time_ns(), cpu_user_seconds=usage.ru_utime, + cpu_system_seconds=usage.ru_stime) + if child.returncode: + target["errors"].append(f"doctests exited {child.returncode}") + except Exception as error: + target["errors"].append(f"{type(error).__name__}: {error}") + finally: + target["load_after"] = snapshot() + target["cancelled"] = children.cancelled + release_state(private, target, children.cancelled) + save(directory / "target.json", target) + return target + + +def union_ns(intervals): + total = 0 + end = None + for start, stop in sorted(intervals): + total += max(0, stop - max(start, end if end is not None else start)) + end = max(stop, end if end is not None else stop) + return total + + +def span_totals(record): + spans = record["spans"] + names = sorted({span["name"] for span in spans}) + totals = {name: union_ns([(span["start_unix_ns"], span["end_unix_ns"]) + for span in spans if span["name"] == name]) for name in names} + covered = union_ns([(span["start_unix_ns"], span["end_unix_ns"]) for span in spans]) + return totals, max(0, record["elapsed_ns"] - covered) + + +def load_timing_run(directory): + manifest_path = directory / "run.json" + if manifest_path.exists(): + return json.loads(manifest_path.read_text()) + groups = {} + for path in sorted(directory.glob("*.jsonl")): + for line_number, line in enumerate(path.read_text().splitlines(), 1): + record = json.loads(line) + if record.get("kind") != "test": + raise ValueError(f"{path}:{line_number}: expected a test timing record") + key = (record["binary"], record["pid"]) + target = groups.setdefault(key, {"id": f"{key[0]}-{key[1]}", "binary": key[0], + "pid": key[1], "records": [], "statuses": [], + "coverage_unverified": True, "errors": []}) + target["records"].append(record) + if not groups: + raise ValueError(f"no run.json or timing sidecars in {directory}") + return {"targets": list(groups.values()), "coverage_unverified": True} + + +def table(directory): + manifest = load_timing_run(directory) + unverified = manifest.get("coverage_unverified", False) + if manifest.get("cleanup_error"): + print(f"BUILD STATE RETAINED: {manifest.get('build_state_root')}: {manifest['cleanup_error']}") + if unverified: + print("COVERAGE UNVERIFIED: raw sidecars have no runner inventory or harness status.") + print("TARGET WALL(s) USER(s) SYS(s) EXIT INVENTORY_COMPLETED RESULT") + for target in manifest["targets"]: + if unverified: + print(f"{target['id']} records={len(target['records'])} " + "wall/CPU/exit=unknown INVENTORY=UNVERIFIED") + continue + print(f"{target['id']} {target.get('elapsed_ns', 0) / 1e9:.3f} " + f"{target.get('cpu_user_seconds', 0):.3f} " + f"{target.get('cpu_system_seconds', 0):.3f} " + f"{target.get('exit_code')} " + f"{target.get('completed_count')}/{target.get('expected_nonignored_count')} " + f"(whole={target.get('whole_test_set_completed')}, aborted={target.get('aborted_early')}) " + f"{'FAIL' if target.get('errors') else 'ok'}") + if target.get("cleanup_error"): + print(f" STATE RETAINED: {target.get('state_root')}: {target['cleanup_error']}") + for name, phases in target.get("failed_phases", {}).items(): + print(f" FAILED PHASE: {name}: {', '.join(phases)}") + if target.get("timing_uncovered"): + print(" UNCOVERED TIMING: doctest aggregate (executed natively; inventory completion unknown)") + if target.get("uncovered_tests"): + print(f" UNCOVERED TIMING: crate={target.get('package', 'unknown')} " + f"{len(target['uncovered_tests'])} tests " + f"({', '.join(target.get('kinds', []))}); names in run.json") + for error in target.get("errors", []): + print(f" {error}") + if unverified: + print("TOTAL wall/CPU unknown (raw records are not a measured run).") + else: + print(f"TOTAL wall_with_build={manifest['elapsed_ns'] / 1e9:.3f}s " + f"execution={manifest.get('execution_elapsed_ns', 0) / 1e9:.3f}s " + f"user={manifest['cpu_user_seconds']:.3f}s sys={manifest['cpu_system_seconds']:.3f}s") + rows = [(target, record) for target in manifest["targets"] for record in target.get("records", [])] + print("\nTEST WALL(s) HARNESS GUARD SPANS(s) UNATTRIBUTED(s)") + for target, record in sorted(rows, key=lambda row: row[1]["elapsed_ns"], reverse=True): + totals, unattributed = span_totals(record) + outcome = dict(target["statuses"]).get(record["test"], "unknown" if unverified else "missing") + details = ", ".join(f"{name}={total / 1e9:.6f}" for name, total in totals.items()) + print(f"{target['id']}::{record['test']} {record['elapsed_ns'] / 1e9:.6f} " + f"{outcome} {record['outcome']} {details or '-'} {unattributed / 1e9:.6f}") + uncovered_crates = sorted({target["package"] for target in manifest["targets"] + if target.get("uncovered_tests") and target.get("package")}) + if unverified: + print("\nCOVERAGE UNVERIFIED: missing tests, ignored tests and fixture subprocess provenance unknown.") + else: + print("\nUNCOVERED UNIT CRATES: " + (", ".join(uncovered_crates) or "none")) + print("UNCOVERED TIMING: doctests; uninstrumented lib/bin unit tests. Ignored tests are not run.") + return int(any(target.get("errors") for target in manifest["targets"])) + + +def run(args): + repo = Path(__file__).resolve().parents[1] + audit = None + if args.audit: + from instrument_test_timings import instrument, inventory as source_inventory + missing = {} + for path in source_inventory(repo): + _, count = instrument(path.read_text()) + if count: + missing[str(path.relative_to(repo))] = count + audit = {"scope": "integration tests plus pa-core/pa-daemon src unit tests", "missing": missing} + if missing: + raise ValueError(f"source audit: {sum(missing.values())} uninstrumented scoped tests: {missing}") + ambient = dict(os.environ) + required = ("CARGO_HOME", "CARGO_TARGET_DIR", "PRIME_AGENT_KERNEL_PYTHON", + "PA_E2E_KERNEL_PYTHON", "PA_CORE_KERNEL_PYTHON") + for key in required: + if not ambient.get(key) or not Path(ambient[key]).is_absolute(): + raise ValueError(f"set {key} to an absolute isolated/qualified path first") + if len({ambient[key] for key in ("PRIME_AGENT_KERNEL_PYTHON", "PA_E2E_KERNEL_PYTHON", + "PA_CORE_KERNEL_PYTHON")}) != 1: + raise ValueError("all three kernel Python overrides must name the same synced interpreter") + directory = args.output.resolve() if args.output else Path(tempfile.mkdtemp(prefix="pa-timings-")) + if args.output: + directory.mkdir(parents=True, exist_ok=False) + manifest = {"schema_version": 1, "slots": args.slots, "timing_disabled": args.disable_timing, + "load_before": snapshot(), "commands": [], "targets": [], + "source_audit": audit, + "uncovered": ["doctests", "ignored tests", "uninstrumented lib/bin unit tests"]} + started = time.monotonic_ns() + private = Path(tempfile.mkdtemp(prefix="pa-t-", dir="/tmp")) + children = Children() + previous_handlers = {sig: signal.getsignal(sig) for sig in (signal.SIGINT, signal.SIGTERM)} + + def interrupt(signum, frame): + if children.launching_main: + children.pending_signal = signum + return + for sig in previous_handlers: + signal.signal(sig, signal.SIG_IGN) + children.cancel() + raise KeyboardInterrupt(f"timing run interrupted by signal {signum}") + + for sig in previous_handlers: + signal.signal(sig, interrupt) + try: + env = environment(repo, private, ambient) + selection = ["-p", args.package] if args.package else ["--workspace"] + selectors = [item for name in (args.target or []) for item in ("--test", name)] + command = ["cargo", "test", "--locked", "--offline", *selection, *selectors, + "--no-run", "--message-format=json"] + output = checked(command, repo, env, directory / "build.log", manifest["commands"], children) + metadata = json.loads(checked(["cargo", "metadata", "--locked", "--offline", "--no-deps", + "--format-version", "1"], repo, env, + directory / "metadata.log", manifest["commands"], children)) + scheduling_metadata = json.loads(json.dumps(metadata)) + for package in scheduling_metadata["packages"]: + for target in package["targets"]: + if target["kind"] == ["proc-macro"]: + target["kind"] = ["lib"] + target_groups(scheduling_metadata) + packages = {package["id"]: package for package in metadata["packages"]} + seen = set() + for line in output.splitlines(): + artifact = json.loads(line) + if (artifact.get("reason") != "compiler-artifact" + or not artifact.get("profile", {}).get("test") or not artifact.get("executable")): + continue + target = artifact["target"] + if not set(target["kind"]) & {"lib", "bin", "test", "proc-macro"}: + raise ValueError(f"unsupported default harness: {target['kind']}") + binary = artifact["executable"] + if binary in seen: + continue + seen.add(binary) + if args.target and target["name"] not in args.target: + continue + package = packages[artifact["package_id"]] + manifest["targets"].append({"id": f"{len(seen):03d}-{package['name']}-{target['name']}", + "name": target["name"], "binary": binary, + "package": package["name"], "kinds": target["kind"], + "timing_required": (args.require_all_timing or "test" in target["kind"] + or package["name"] in {"pa-core", "pa-daemon"}), + "cwd": str(Path(package["manifest_path"]).parent)}) + if not manifest["targets"]: + raise ValueError("no matching default test binaries") + ordinary = [target for target in manifest["targets"] if target["name"] not in EXCLUSIVE] + exclusive = [target for target in manifest["targets"] if target["name"] in EXCLUSIVE] + for targets, slots in ((ordinary, args.slots), (exclusive, 1)): + with ThreadPoolExecutor(max_workers=slots) as workers: + try: + futures = [workers.submit(execute, target, repo, ambient, directory, + args.disable_timing, children) for target in targets] + for future in as_completed(futures): + target = future.result() + print(f"{target['id']}: {'FAIL' if target['errors'] else 'ok'}", flush=True) + except BaseException: + children.cancel() + raise + if not args.target: + manifest["targets"].append(execute_doctests(repo, ambient, directory, selection, children)) + else: + manifest["uncovered"].append("doctests not run for --target selection") + completed = [target for target in manifest["targets"] if "end_unix_ns" in target] + manifest["execution_elapsed_ns"] = ( + max(target["start_monotonic_ns"] + target["elapsed_ns"] for target in completed) + - min(target["start_monotonic_ns"] for target in completed)) if completed else 0 + except BaseException: + children.cancel() + manifest["cancelled"] = True + raise + finally: + for sig, handler in previous_handlers.items(): + signal.signal(sig, handler) + release_state(private, manifest, children.cancelled) + manifest["build_state_root"] = str(private) + manifest.update(elapsed_ns=time.monotonic_ns() - started, load_after=snapshot()) + for field in ("cpu_user_seconds", "cpu_system_seconds"): + manifest[field] = sum(target.get(field, 0) for target in manifest["targets"]) + save(directory / "run.json", manifest) + print(f"Timing run: {directory}", flush=True) + return table(directory) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + commands = parser.add_subparsers(dest="command", required=True) + runner = commands.add_parser("run") + runner.add_argument("--slots", type=int, choices=(1, 8, 16), required=True) + runner.add_argument("--package") + runner.add_argument("--audit", action="store_true", + help="audit integration and pa-core/pa-daemon source instrumentation") + runner.add_argument("--require-all-timing", action="store_true", + help="require lib/bin/proc-macro unit coverage too; doctest timing remains uncovered") + runner.add_argument("--target", action="append", help="integration target name; repeat to select whole binaries") + runner.add_argument("--output", type=Path) + runner.add_argument("--disable-timing", action="store_true", help="measure harness overhead without guard records") + viewer = commands.add_parser("table") + viewer.add_argument("run_dir", type=Path, help="runner run directory or raw JSONL sidecar directory") + args = parser.parse_args() + try: + return run(args) if args.command == "run" else table(args.run_dir) + except KeyboardInterrupt as error: + parser.exit(130, f"{error}\n") + except (OSError, ValueError, RuntimeError) as error: + parser.exit(1, f"{error}\n") + + +if __name__ == "__main__": + raise SystemExit(main()) -- knotmirror 0.0.1 From 780b4358547d50cdc579d27b006399209c9b007a Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Sat, 21 Nov 2026 12:09:37 +0000 Subject: [PATCH 3/9] test(timing): instrument integration test inventory and phases --- crates/pa-agent/tests/agent_loop_scripted.rs | 14 ++++++ crates/pa-agent/tests/tool_error_status.rs | 6 +++ crates/pa-ai/tests/codex_extra_ca.rs | 1 + crates/pa-cli/tests/acp_config_option_e2e.rs | 1 + crates/pa-cli/tests/acp_mode_e2e.rs | 47 +++++++++++++++++++ .../tests/acp_mode_e2e/shutdown_tests.rs | 3 ++ crates/pa-cli/tests/agents_view_anchor_e2e.rs | 3 ++ crates/pa-cli/tests/agents_view_flash_e2e.rs | 2 + .../tests/agents_view_refusal_panel_e2e.rs | 1 + crates/pa-cli/tests/agents_view_reply_e2e.rs | 2 + crates/pa-cli/tests/agents_view_search_e2e.rs | 2 + .../pa-cli/tests/agents_view_subagents_e2e.rs | 2 + .../tests/chat_agents_chat_roundtrip_e2e.rs | 2 + .../tests/chat_open_first_frame_pty_e2e.rs | 2 + .../tests/clipboard_auth_commands_e2e.rs | 10 ++++ crates/pa-cli/tests/continue_guard_e2e.rs | 2 + crates/pa-cli/tests/cursor_visibility_e2e.rs | 3 ++ crates/pa-cli/tests/daemon_commands_e2e.rs | 6 +++ crates/pa-cli/tests/daemon_discovery_e2e.rs | 8 ++++ crates/pa-cli/tests/differential_cli.rs | 8 ++++ .../pa-cli/tests/dock_scope_exit_focus_e2e.rs | 4 ++ .../tests/editor_handoff_paint_pty_e2e.rs | 2 + crates/pa-cli/tests/exit_backfill_pty_e2e.rs | 3 ++ .../pa-cli/tests/export_live_differential.rs | 2 + crates/pa-cli/tests/export_share_e2e.rs | 4 ++ .../pa-cli/tests/input_live_open_pty_e2e.rs | 3 ++ crates/pa-cli/tests/installer_platform_map.rs | 19 ++++++++ crates/pa-cli/tests/installer_update_e2e.rs | 9 ++++ crates/pa-cli/tests/interactive_daemon_e2e.rs | 39 +++++++++++++++ crates/pa-cli/tests/interactive_fork_e2e.rs | 2 + crates/pa-cli/tests/kitty_early_typing_e2e.rs | 3 ++ .../tests/kitty_exit_routes_e2e/main.rs | 2 + .../pa-cli/tests/kitty_release_handoff_e2e.rs | 2 + crates/pa-cli/tests/kitty_verdict_time_e2e.rs | 8 ++++ crates/pa-cli/tests/lock_compat_e2e.rs | 5 ++ crates/pa-cli/tests/login_panel_pty_e2e.rs | 6 +++ crates/pa-cli/tests/mcp_view_e2e.rs | 2 + .../mermaid_titled_empty_subgraph_e2e.rs | 1 + crates/pa-cli/tests/nix_managed_update.rs | 1 + crates/pa-cli/tests/package_e2e.rs | 3 ++ crates/pa-cli/tests/package_resources_e2e.rs | 1 + crates/pa-cli/tests/packaged_layout_e2e.rs | 7 +++ crates/pa-cli/tests/plugin_headless/daemon.rs | 1 + crates/pa-cli/tests/plugin_headless_e2e.rs | 10 ++++ .../tests/print_inline_subagents_e2e.rs | 8 ++++ crates/pa-cli/tests/print_runtime_e2e.rs | 25 ++++++++++ crates/pa-cli/tests/refresh_models_e2e.rs | 9 ++++ crates/pa-cli/tests/release_workflow.rs | 11 +++++ crates/pa-cli/tests/rpc_mode_e2e.rs | 25 ++++++++++ crates/pa-cli/tests/settings_mcp_save.rs | 2 + .../pa-cli/tests/slow_drain_exit_guard_e2e.rs | 3 ++ crates/pa-cli/tests/subagent_panel_nav_e2e.rs | 3 ++ .../tests/subagent_panel_nested_count_e2e.rs | 1 + crates/pa-cli/tests/suspend_signal_e2e.rs | 3 ++ .../terminal_state_differential_e2e/ledger.rs | 11 +++++ .../terminal_state_differential_e2e/main.rs | 18 +++++++ .../pa-cli/tests/termios_process_exit_e2e.rs | 6 +++ crates/pa-cli/tests/tool_error_status.rs | 2 + .../pa-cli/tests/view_switch_latency_e2e.rs | 1 + .../tests/windows_runtime_triage_e2e.rs | 3 ++ .../tests/windows_runtime_triage_workflow.rs | 6 +++ crates/pa-core/tests/abort_kernel_cell.rs | 1 + crates/pa-core/tests/auth_refresh_compat.rs | 20 ++++++++ crates/pa-core/tests/compaction_transport.rs | 4 ++ crates/pa-core/tests/git_context.rs | 13 +++++ .../pa-core/tests/kernel_capture_freshness.rs | 10 ++++ .../pa-core/tests/kernel_host_cancellation.rs | 1 + crates/pa-core/tests/kernel_lifecycle.rs | 9 ++++ crates/pa-core/tests/kernel_mcp_settle.rs | 3 ++ crates/pa-core/tests/kernel_prewarm.rs | 2 + .../tests/kernel_protocol_frame_caps.rs | 3 ++ .../tests/kernel_python_skills_unavailable.rs | 2 + crates/pa-core/tests/kernel_restore_guards.rs | 6 +++ crates/pa-core/tests/kernel_result_clip.rs | 1 + .../pa-core/tests/kernel_snapshot_resume.rs | 2 + crates/pa-core/tests/kernel_startup_join.rs | 5 ++ crates/pa-core/tests/kernel_startup_memo.rs | 10 ++++ crates/pa-core/tests/kernel_stop_revive.rs | 4 ++ crates/pa-core/tests/kernel_system_exit.rs | 2 + crates/pa-core/tests/kernel_teardown.rs | 4 ++ crates/pa-core/tests/live_catalog_chain.rs | 8 ++++ crates/pa-core/tests/lock_compat.rs | 5 ++ crates/pa-core/tests/lua_hook_yield.rs | 1 + .../pa-core/tests/offline_catalog_startup.rs | 3 ++ crates/pa-core/tests/prompt_guards.rs | 5 ++ .../pa-core/tests/release_channel_manifest.rs | 7 +++ .../pa-core/tests/session_nested_metadata.rs | 4 ++ crates/pa-core/tests/turn_boundary_kernel.rs | 1 + crates/pa-daemon/tests/abort_kernel_e2e.rs | 1 + crates/pa-daemon/tests/agent_family_e2e.rs | 3 ++ .../pa-daemon/tests/agents_view_roster_e2e.rs | 3 ++ .../tests/close_listener_cleanup_e2e.rs | 5 ++ crates/pa-daemon/tests/command_breadth.rs | 3 ++ .../pa-daemon/tests/command_dispatch_e2e.rs | 1 + .../pa-daemon/tests/compaction_abort_e2e.rs | 2 + .../tests/compaction_completion_stall_e2e.rs | 1 + .../tests/compaction_mega_trace_e2e.rs | 1 + .../pa-daemon/tests/compaction_outcome_e2e.rs | 1 + .../tests/compaction_summary_stream_e2e.rs | 1 + crates/pa-daemon/tests/context_latency_e2e.rs | 10 ++++ crates/pa-daemon/tests/create_join_e2e.rs | 1 + crates/pa-daemon/tests/create_reuse_e2e.rs | 4 ++ .../pa-daemon/tests/daemon_boot_reap_e2e.rs | 2 + crates/pa-daemon/tests/direct_attach_e2e.rs | 2 + crates/pa-daemon/tests/fd_lifecycle_e2e.rs | 5 ++ crates/pa-daemon/tests/fork_isolation_e2e.rs | 2 + .../pa-daemon/tests/goal_branch_reload_e2e.rs | 2 + crates/pa-daemon/tests/goal_recovery_e2e.rs | 2 + crates/pa-daemon/tests/herdr_pane_e2e.rs | 2 + crates/pa-daemon/tests/hold_refusal_e2e.rs | 1 + .../pa-daemon/tests/idle_passivation_e2e.rs | 3 ++ .../pa-daemon/tests/import_compaction_e2e.rs | 1 + crates/pa-daemon/tests/kernel_dispose_e2e.rs | 3 ++ crates/pa-daemon/tests/launch_env_e2e.rs | 4 ++ .../pa-daemon/tests/mcp_product_path_e2e.rs | 2 + crates/pa-daemon/tests/model_catalog_e2e.rs | 1 + .../pa-daemon/tests/model_facts_switch_e2e.rs | 1 + crates/pa-daemon/tests/orphan_journal_e2e.rs | 2 + crates/pa-daemon/tests/peer_messaging_e2e.rs | 3 ++ .../tests/protocol_breadth_b10_b11.rs | 7 +++ .../pa-daemon/tests/protocol_breadth_b6_b9.rs | 8 ++++ .../pa-daemon/tests/provider_failover_e2e.rs | 4 ++ .../pa-daemon/tests/provider_failure_e2e.rs | 8 ++++ crates/pa-daemon/tests/queue_delivery_e2e.rs | 3 ++ crates/pa-daemon/tests/readoption_wake_e2e.rs | 3 ++ .../tests/recovery_control_plane_e2e.rs | 1 + .../tests/registration_refusal_heal_e2e.rs | 3 ++ .../pa-daemon/tests/replacement_kernel_e2e.rs | 5 ++ .../tests/rlm_child_usage_attribution_e2e.rs | 2 + crates/pa-daemon/tests/rlm_children_e2e.rs | 4 ++ .../tests/rlm_children_parent_death_e2e.rs | 3 ++ .../tests/rlm_children_replacement_e2e.rs | 4 ++ .../tests/rlm_quiescence_barrier_e2e.rs | 2 + crates/pa-daemon/tests/rlm_roster_walk_e2e.rs | 2 + .../tests/rlm_spawn_replacement_e2e.rs | 1 + .../tests/saved_catalog_stream_e2e.rs | 2 + .../pa-daemon/tests/saved_session_wake_e2e.rs | 1 + crates/pa-daemon/tests/session_archive_e2e.rs | 2 + crates/pa-daemon/tests/session_rebind_e2e.rs | 1 + .../tests/session_stop_lifecycle_e2e.rs | 1 + crates/pa-daemon/tests/session_tree_e2e.rs | 2 + .../tests/socket_identity_guard_e2e.rs | 4 ++ .../tests/stale_lease_release_e2e.rs | 3 ++ .../tests/startup_no_auto_resume_e2e.rs | 2 + .../tests/steer_boundary_batch_e2e.rs | 1 + crates/pa-daemon/tests/stop_escalation_e2e.rs | 2 + .../pa-daemon/tests/supervisor_e2e/attach.rs | 1 + .../tests/supervisor_e2e/compaction.rs | 1 + .../pa-daemon/tests/supervisor_e2e/create.rs | 6 +++ .../tests/supervisor_e2e/event_order.rs | 1 + .../tests/supervisor_e2e/lifecycle.rs | 1 + .../tests/supervisor_e2e/read_goldens.rs | 1 + .../tests/supervisor_e2e/shutdown.rs | 2 + .../tests/supervisor_e2e/side_questions.rs | 1 + .../tests/supervisor_e2e/tool_results.rs | 1 + .../supervisor_restart_e2e/boot_cleanup.rs | 1 + .../supervisor_restart_e2e/plain_boot.rs | 1 + .../tests/supervisor_restart_e2e/restart.rs | 1 + .../tests/supervisor_restart_e2e/revival.rs | 4 ++ .../supervisor_restart_e2e/update_boot.rs | 1 + .../tests/support/session_fixture.rs | 1 + crates/pa-daemon/tests/thinking_level_e2e.rs | 4 ++ .../tests/thinking_level_roster_e2e.rs | 2 + .../pa-daemon/tests/worker_orphan_exit_e2e.rs | 5 ++ crates/pa-daemon/tests/worker_stderr_e2e.rs | 2 + .../pa-models/tests/custom_ca_extra_certs.rs | 1 + .../pa-models/tests/custom_ca_native_once.rs | 1 + .../pa-models/tests/custom_ca_native_roots.rs | 1 + crates/pa-models/tests/fetch_layer.rs | 7 +++ crates/pa-models/tests/parity.rs | 4 ++ crates/pa-models/tests/refresh_compat.rs | 13 +++++ .../tests/agents_view_catalog_settle_carry.rs | 4 ++ .../tests/agents_view_click_headless.rs | 11 +++++ .../agents_view_heartbeat_badge_headless.rs | 1 + .../tests/agents_view_hover_headless.rs | 11 +++++ .../tests/agents_view_incident_notice_e2e.rs | 3 ++ .../agents_view_saved_catalog_failure.rs | 2 + .../tests/agents_view_wait_render_barrier.rs | 2 + .../anthropic_warning_lifecycle_headless.rs | 5 ++ crates/pa-tui/tests/bash_bang_headless.rs | 8 ++++ .../tests/chat_detail_persist_headless.rs | 2 + .../tests/chat_open_first_frame_headless.rs | 3 ++ .../pa-tui/tests/daemon_rejection_headless.rs | 9 ++++ .../daemon_shutdown_reconnect_headless.rs | 1 + .../daemon_shutdown_turn_end_headless.rs | 1 + crates/pa-tui/tests/dock_arrows_headless.rs | 8 ++++ crates/pa-tui/tests/dock_click_headless.rs | 8 ++++ .../tests/dock_panel_exit_focus_headless.rs | 7 +++ crates/pa-tui/tests/drag_select_perf.rs | 2 + .../tests/editor_keybinds_parity_headless.rs | 4 ++ .../tests/effort_tray_label_headless.rs | 3 ++ .../tests/esc_repeat_ladder_headless.rs | 2 + crates/pa-tui/tests/info_panel_headless.rs | 1 + crates/pa-tui/tests/loader_anchor_headless.rs | 1 + .../tests/loader_quiet_turn_headless.rs | 1 + .../tests/model_picker_provider_headless.rs | 1 + .../pa-tui/tests/mouse_click_open_headless.rs | 3 ++ crates/pa-tui/tests/mouse_scroll_headless.rs | 4 ++ .../pa-tui/tests/mouse_selection_headless.rs | 5 ++ .../pa-tui/tests/nightly_command_headless.rs | 3 ++ .../pa-tui/tests/plugins_command_headless.rs | 9 ++++ .../tests/prompt_history_nav_headless.rs | 3 ++ .../tests/quiet_tick_busy_stream_headless.rs | 2 + .../pa-tui/tests/refresh_command_headless.rs | 4 ++ crates/pa-tui/tests/replay_images.rs | 2 + crates/pa-tui/tests/replay_tables.rs | 2 + crates/pa-tui/tests/service_tier_headless.rs | 1 + crates/pa-tui/tests/settings_menu_headless.rs | 15 ++++++ crates/pa-tui/tests/skills_menu_headless.rs | 6 +++ .../pa-tui/tests/slash_menu_panel_headless.rs | 1 + crates/pa-tui/tests/speed_footer_headless.rs | 2 + ...ash_restore_before_typed_ahead_headless.rs | 1 + crates/pa-tui/tests/touch_click_headless.rs | 6 +++ .../pa-tui/tests/tray_prompt_down_headless.rs | 4 ++ crates/pa-tui/tests/tui_rss_stability.rs | 1 + .../pa-tui/tests/wake_inventory_headless.rs | 2 + .../tests/windowed_backfill_headless.rs | 10 ++++ .../pa-tui/tests/working_messages_headless.rs | 1 + .../pa-types/tests/daemon_wire_roundtrip.rs | 2 + .../pa-types/tests/session_jsonl_roundtrip.rs | 2 + .../pa-types/tests/update_flow_artifacts.rs | 7 +++ 221 files changed, 956 insertions(+) diff --git a/crates/pa-agent/tests/agent_loop_scripted.rs b/crates/pa-agent/tests/agent_loop_scripted.rs index 93d83c752..d922f4dd2 100644 --- a/crates/pa-agent/tests/agent_loop_scripted.rs +++ b/crates/pa-agent/tests/agent_loop_scripted.rs @@ -219,6 +219,7 @@ async fn scripted_agent_with( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn normal_turn_streams_and_completes() { let (agent, provider, events) = scripted_agent(vec![]).await; provider.push_text_turn("hello world"); @@ -263,6 +264,7 @@ async fn normal_turn_streams_and_completes() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tool_call_turn_dispatches_and_feeds_result_back() { let echo = EchoTool::new("echo"); let (agent, provider, _events) = scripted_agent(vec![echo.clone()]).await; @@ -301,6 +303,7 @@ async fn tool_call_turn_dispatches_and_feeds_result_back() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn parallel_tool_calls_execute_concurrently_and_emit_in_order() { // Both calls target the same slow tool: overlap shows up as its // concurrent-execution high-water mark. @@ -330,6 +333,7 @@ async fn parallel_tool_calls_execute_concurrently_and_emit_in_order() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn sequential_tool_calls_run_one_at_a_time() { let tool = EchoTool::with_options("echo_seq", 60, false); let (agent, provider, _events) = @@ -354,6 +358,7 @@ async fn sequential_tool_calls_run_one_at_a_time() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tool_error_produces_error_tool_result_and_loop_continues() { let failing = EchoTool::with_options("bad_tool", 0, true); let (agent, provider, _events) = scripted_agent(vec![failing.clone()]).await; @@ -379,6 +384,7 @@ async fn tool_error_produces_error_tool_result_and_loop_continues() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn unknown_tool_name_yields_error_tool_result() { let echo = EchoTool::new("echo"); let (agent, provider, _events) = scripted_agent(vec![echo.clone()]).await; @@ -399,6 +405,7 @@ async fn unknown_tool_name_yields_error_tool_result() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn provider_stream_failure_mid_turn_ends_run_and_retry_continues() { let (agent, provider, _events) = scripted_agent(vec![]).await; provider.push_stream_failure_turn("partial answer", "connection reset by peer"); @@ -472,6 +479,7 @@ async fn provider_stream_failure_mid_turn_ends_run_and_retry_continues() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn user_abort_mid_stream_finalizes_aborted_assistant_message() { let (agent, provider, _events) = scripted_agent(vec![]).await; // The provider streams partial text and then stalls; only an abort ends it. @@ -505,6 +513,7 @@ async fn user_abort_mid_stream_finalizes_aborted_assistant_message() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn abort_during_tool_execution_produces_aborted_tool_result() { let slow = EchoTool::with_options("slow_tool", 60_000, false); let (agent, provider, _events) = scripted_agent(vec![slow.clone()]).await; @@ -535,6 +544,7 @@ async fn abort_during_tool_execution_produces_aborted_tool_result() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn max_iterations_stops_after_configured_turn_count() { let echo = EchoTool::new("echo"); let (_agent, provider, _events) = scripted_agent(vec![echo.clone()]).await; @@ -586,6 +596,7 @@ async fn max_iterations_stops_after_configured_turn_count() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn steering_message_injects_before_next_turn() { // Slow enough that the mid-run steer (50ms in) lands while turn 1 is // still executing its tool call. @@ -633,6 +644,7 @@ async fn steering_message_injects_before_next_turn() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn terminate_tool_result_stops_the_run() { let (agent, provider, _events) = scripted_agent(vec![Arc::new(TerminatingTool)]).await; provider.push_tool_call_turn(None, vec![("call-1", "stop_tool", serde_json::json!({}))]); @@ -647,6 +659,7 @@ async fn terminate_tool_result_stops_the_run() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn prompt_while_processing_is_rejected_with_ts_message() { let (agent, provider, _events) = scripted_agent(vec![]).await; provider.push_stalled_turn("streaming"); @@ -667,6 +680,7 @@ async fn prompt_while_processing_is_rejected_with_ts_message() { first.await.unwrap().unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn scripted_event_shapes_round_trip_through_the_event_enum() { // Terminal events must expose their message and deltas must not. diff --git a/crates/pa-agent/tests/tool_error_status.rs b/crates/pa-agent/tests/tool_error_status.rs index e929475c7..87f3931bc 100644 --- a/crates/pa-agent/tests/tool_error_status.rs +++ b/crates/pa-agent/tests/tool_error_status.rs @@ -12,6 +12,7 @@ use pa_agent::types::{ }; use serde_json::{json, Value}; +#[pa_test_scratch::pa_test] #[test] fn execution_status_is_internal_and_old_payloads_decode_as_success() { let mut result = AgentToolResult::text("reported failure"); @@ -206,6 +207,7 @@ async fn verify_status_case(case: StatusCase) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_reported_error_continues_with_its_payload() { verify_status_case(StatusCase { input_is_error: true, @@ -216,6 +218,7 @@ async fn a_reported_error_continues_with_its_payload() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn success_does_not_infer_error_from_details() { verify_status_case(StatusCase { input_is_error: false, @@ -226,6 +229,7 @@ async fn success_does_not_infer_error_from_details() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn after_tool_call_can_clear_a_reported_error() { verify_status_case(StatusCase { input_is_error: true, @@ -236,6 +240,7 @@ async fn after_tool_call_can_clear_a_reported_error() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn after_tool_call_can_mark_a_success_as_error() { verify_status_case(StatusCase { input_is_error: false, @@ -246,6 +251,7 @@ async fn after_tool_call_can_mark_a_success_as_error() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_reported_error_preserves_explicit_batch_termination() { verify_status_case(StatusCase { input_is_error: true, diff --git a/crates/pa-ai/tests/codex_extra_ca.rs b/crates/pa-ai/tests/codex_extra_ca.rs index b0250b405..679016f09 100644 --- a/crates/pa-ai/tests/codex_extra_ca.rs +++ b/crates/pa-ai/tests/codex_extra_ca.rs @@ -29,6 +29,7 @@ impl Drop for FixtureEnvironment { } #[tokio::test] +#[pa_test_scratch::pa_test] // Keep the fixture, first-use precondition and public-path assertions in one // test so no other test/client can initialize the process-default TLS provider. // tungstenite dictates the upgrade callback's Response-sized error type. diff --git a/crates/pa-cli/tests/acp_config_option_e2e.rs b/crates/pa-cli/tests/acp_config_option_e2e.rs index cf6d5727c..ea0bd2c0c 100644 --- a/crates/pa-cli/tests/acp_config_option_e2e.rs +++ b/crates/pa-cli/tests/acp_config_option_e2e.rs @@ -181,6 +181,7 @@ fn faux_models_fixture() -> serde_json::Value { /// through `set_thinking_level`, invalid values refused, and a real /// model switch observable (the plain model drops the effort picker, the /// map model accepts `xhigh`, and the turn after a switch settles). +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_config_option_pickers() { let home = tempfile::TempDir::new().unwrap(); diff --git a/crates/pa-cli/tests/acp_mode_e2e.rs b/crates/pa-cli/tests/acp_mode_e2e.rs index 43aeda2ae..50b5fea6c 100644 --- a/crates/pa-cli/tests/acp_mode_e2e.rs +++ b/crates/pa-cli/tests/acp_mode_e2e.rs @@ -91,6 +91,7 @@ impl AcpChild { /// the drop shuts the supervisor down. The socket sits on the struct /// for tests that speak raw daemon commands alongside the ACP frames. fn spawn(args: &[&str], script: &serde_json::Value) -> AcpChild { + let _timing_span = pa_test_scratch::timing::span("setup.process_and_fixture"); let home = tempfile::TempDir::new().unwrap(); let socket = home.path().join("daemon.sock"); std::fs::write(home.path().join("worker-script.json"), script.to_string()).unwrap(); @@ -111,6 +112,7 @@ impl AcpChild { child_script: &serde_json::Value, kernel_python: &std::path::Path, ) -> AcpChild { + let _timing_span = pa_test_scratch::timing::span("setup.process_and_fixture"); let home = tempfile::TempDir::new().unwrap(); let socket = home.path().join("daemon.sock"); let child_script_path = home.path().join("child-script.json"); @@ -151,6 +153,7 @@ impl AcpChild { /// Read frames until the request `id` answers; returns the answer with the notifications seen /// before it, in order. fn wait_response(&mut self, id: u64, timeout: Duration) -> (Value, Vec) { + let _timing_span = pa_test_scratch::timing::span("run.response_wait"); let deadline = Instant::now() + timeout; let mut notifications = Vec::new(); loop { @@ -186,6 +189,7 @@ impl AcpChild { timeout: Duration, mut frame_matches: impl FnMut(&Value) -> bool, ) -> Value { + let _timing_span = pa_test_scratch::timing::span("run.frame_wait"); let deadline = Instant::now() + timeout; loop { let timeout_left = deadline.saturating_duration_since(Instant::now()); @@ -270,6 +274,7 @@ fn worker_descriptor(home: &std::path::Path) -> Value { impl Drop for AcpChild { fn drop(&mut self) { + let _timing_span = pa_test_scratch::timing::span("teardown.process"); if std::thread::panicking() { if let Some(home) = self.home.take() { let path = home.keep(); @@ -316,6 +321,7 @@ fn assert_end_turn(response: &Value) { /// The TS initialize response shape (capture `ts-happy_path.jsonl`), with the /// version and sessionId-class fields normalized as volatile. +#[pa_test_scratch::pa_test] #[test] fn acp_initialize_matches_the_ts_golden() { let script = json!({ "responses": ["unused"] }); @@ -343,6 +349,7 @@ fn acp_initialize_matches_the_ts_golden() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_second_initialize_is_served() { let script = json!({ "responses": ["unused"] }); @@ -354,6 +361,7 @@ fn acp_second_initialize_is_served() { assert_eq!(response["result"]["protocolVersion"], 1); } +#[pa_test_scratch::pa_test] #[test] fn acp_prompt_stream_completion_envelope_and_stop_reason_match_ts() { let script = json!({ "engine": "faux", "responses": ["ACP-OK"] }); @@ -438,6 +446,7 @@ fn acp_prompt_stream_completion_envelope_and_stop_reason_match_ts() { assert_eq!(close_response["result"], json!({})); } +#[pa_test_scratch::pa_test] #[test] fn acp_prompt_chunk_carries_the_assistant_message_id() { let script = json!({ "engine": "faux", "responses": ["ACP-OK"] }); @@ -474,6 +483,7 @@ fn acp_prompt_chunk_carries_the_assistant_message_id() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_cwd_mismatch_is_reported_not_adopted() { let script = json!({ "responses": ["unused"] }); @@ -491,6 +501,7 @@ fn acp_cwd_mismatch_is_reported_not_adopted() { .is_some_and(|actual| actual.starts_with(std::path::MAIN_SEPARATOR))); } +#[pa_test_scratch::pa_test] #[test] fn acp_error_shapes_match_the_ts_goldens() { let script = json!({ "responses": ["unused"] }); @@ -549,6 +560,7 @@ fn acp_error_shapes_match_the_ts_goldens() { assert_eq!(response["result"], json!({})); } +#[pa_test_scratch::pa_test] #[test] fn acp_initialize_with_string_protocol_version_is_invalid_params() { let script = json!({ "responses": ["unused"] }); @@ -566,6 +578,7 @@ fn acp_initialize_with_string_protocol_version_is_invalid_params() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_image_block_without_mime_type_is_invalid_params() { let script = json!({ "responses": ["unused"] }); @@ -592,6 +605,7 @@ fn acp_image_block_without_mime_type_is_invalid_params() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_cancel_without_an_active_turn_is_a_noop() { let script = json!({ "responses": ["unused"] }); @@ -612,6 +626,7 @@ fn acp_cancel_without_an_active_turn_is_a_noop() { assert_eq!(close_response["result"], json!({})); } +#[pa_test_scratch::pa_test] #[test] fn acp_mcp_admission_accepts_valid_servers_and_close_releases() { let script = json!({ "responses": ["unused"] }); @@ -635,6 +650,7 @@ fn acp_mcp_admission_accepts_valid_servers_and_close_releases() { assert_eq!(close_response["result"], json!({})); } +#[pa_test_scratch::pa_test] #[test] fn acp_mcp_admission_rejects_a_second_session_only_when_open() { let script = json!({ "responses": ["unused"] }); @@ -681,6 +697,7 @@ fn acp_mcp_admission_rejects_a_second_session_only_when_open() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_mcp_admission_rejects_invalid_params_with_the_ts_reasons() { let script = json!({ "responses": ["unused"] }); @@ -733,6 +750,7 @@ fn acp_mcp_admission_rejects_invalid_params_with_the_ts_reasons() { } } +#[pa_test_scratch::pa_test] #[test] fn acp_mcp_schema_invalid_entries_are_dropped_like_the_sdk() { // The SDK zod filter (`vecSkipError(zMcpServer)`) silently drops entries @@ -757,6 +775,7 @@ fn acp_mcp_schema_invalid_entries_are_dropped_like_the_sdk() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_mcp_long_names_fail_at_tool_derivation_with_internal_error() { let script = json!({ "responses": ["unused"] }); @@ -778,6 +797,7 @@ fn acp_mcp_long_names_fail_at_tool_derivation_with_internal_error() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_close_clears_the_connection_mcp_servers() { let script = json!({ "engine": "faux", "responses": ["unused"] }); @@ -819,6 +839,7 @@ fn acp_daemon_attached_close_clears_the_connection_mcp_servers() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_eof_teardown_clears_the_connection_mcp_servers() { let script = json!({ "engine": "faux", "responses": ["unused"] }); @@ -855,6 +876,7 @@ fn acp_daemon_attached_eof_teardown_clears_the_connection_mcp_servers() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_mode_daemon_unreachable_exits_1_without_fallback() { let home = tempfile::TempDir::new().unwrap(); @@ -893,6 +915,7 @@ fn acp_mode_daemon_unreachable_exits_1_without_fallback() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_cancels_mid_turn() { // A scripted worker with a slow turn: the cancel lands while the @@ -927,6 +950,7 @@ fn acp_daemon_attached_cancels_mid_turn() { drop(client); } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_overlapping_prompt_is_refused() { // A second prompt while the first runs is refused; the running turn @@ -992,6 +1016,7 @@ fn acp_daemon_attached_overlapping_prompt_is_refused() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_close_mid_turn_answers_cancelled() { let mut client = AcpChild::spawn( @@ -1103,6 +1128,7 @@ fn wait_live_session(socket: &std::path::Path) -> Value { } } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_default_session_persists_and_resumes() { // Without --no-session the daemon session is saved and resident: it @@ -1191,6 +1217,7 @@ fn acp_daemon_attached_default_session_persists_and_resumes() { assert!(saved.contains("Name a river.") && saved.contains("Name a mountain.")); } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_resident_eof_mid_turn_cancels_the_prompt() { let answer = "a paced answer that streams slowly enough to close mid-turn"; @@ -1238,6 +1265,7 @@ fn acp_daemon_attached_resident_eof_mid_turn_cancels_the_prompt() { /// EOF while `session/new` is still running: the reader awaits the /// handler before it reads further, so the teardown at EOF releases the /// session it installs and the process exits. +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_eof_during_session_new_exits() { let mut client = AcpChild::spawn( @@ -1256,6 +1284,7 @@ fn acp_daemon_attached_eof_during_session_new_exits() { assert!(client.child.wait().expect("the ACP child exits").success()); } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_close_keeps_the_worker_and_new_rebinds_it() { let mut client = AcpChild::spawn( @@ -1303,6 +1332,7 @@ fn acp_daemon_attached_close_keeps_the_worker_and_new_rebinds_it() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_prompt_during_cancel_is_refused() { // A prompt behind a cancel is refused while the stop runs, and the @@ -1369,6 +1399,7 @@ fn acp_daemon_attached_prompt_during_cancel_is_refused() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_failed_turn_publishes_only_the_error_boundary() { // A failed turn (here: the empty-prompt rejection) publishes one @@ -1425,6 +1456,7 @@ fn acp_daemon_attached_failed_turn_publishes_only_the_error_boundary() { } #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_supervisor_loss_fails_the_prompt() { // The supervisor dies while a prompt is in flight: the pending @@ -1485,6 +1517,7 @@ fn acp_daemon_attached_supervisor_loss_fails_the_prompt() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_image_only_prompt_reaches_the_session() { let mut client = AcpChild::spawn( @@ -1627,6 +1660,7 @@ fn request_sandboxed_daemon_shutdown(socket: &std::path::Path) { } } +#[pa_test_scratch::pa_test] #[test] fn acp_compact_command_publishes_the_compaction_meta_and_end_turn() { // The faux session is short, so `/compact` skips (TS @@ -1675,6 +1709,7 @@ fn acp_compact_command_publishes_the_compaction_meta_and_end_turn() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_goal_command_publishes_goal_meta_and_runs_the_continuation() { // `/goal` start schedules its continuation as the turn's model segment: @@ -1737,6 +1772,7 @@ fn acp_goal_command_publishes_goal_meta_and_runs_the_continuation() { ); } +#[pa_test_scratch::pa_test] #[test] fn acp_truncated_final_response_maps_to_max_tokens_stop_reason() { // Issue #3363: a turn whose final assistant message stopped at the @@ -1799,6 +1835,7 @@ fn daemon_request(socket: &std::path::Path, id: &str, command: &Value) -> Value .unwrap_or_else(|| panic!("the daemon closed without answering {id}")) } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_forwards_cli_session_options() { // Outside the agent dir: only --skill loads it. @@ -1896,6 +1933,7 @@ fn compaction_metas(updates: &[Value]) -> Vec { /// A settled turn crossing the reserve headroom compacts at the boundary and publishes the /// `compaction` meta (a single-turn skip publishes the empty payload). +#[pa_test_scratch::pa_test] #[test] fn acp_threshold_auto_compaction_publishes_the_compaction_meta() { let script = json!({ @@ -1967,6 +2005,7 @@ fn acp_threshold_auto_compaction_publishes_the_compaction_meta() { /// leaves, so a client that prompts again the instant it reads the /// response is admitted. Twenty back-to-back prompts keep every /// settle-to-next-admission window covered. +#[pa_test_scratch::pa_test] #[test] fn acp_settled_prompt_immediately_admits_the_next_prompt() { let script = json!({ @@ -2005,6 +2044,7 @@ fn acp_settled_prompt_immediately_admits_the_next_prompt() { /// error runs one compact-and-retry at the boundary and the retried turn /// settles the prompt with `end_turn` instead of the error (TS /// `_checkCompaction` Case 1, binary level). +#[pa_test_scratch::pa_test] #[test] fn acp_overflow_recovery_compacts_and_retries_the_turn() { let script = json!({ @@ -2152,6 +2192,7 @@ fn spawn_lane( /// update reports the live outstanding-subagent count, the terminal update /// reports zero, and the settled child's terminal-notice turn ("notice /// seen") drains inside the barrier, between the two. +#[pa_test_scratch::pa_test] #[test] fn acp_prompt_settles_after_rlm_quiescence() { let Some(kernel_python) = kernel_python() else { @@ -2211,6 +2252,7 @@ fn acp_prompt_settles_after_rlm_quiescence() { /// answers cancelled once the stop sequence cancelled the held child, and /// the roster reports the child cancelled. Close goes through the same /// stop sequence, so it is not retested here. +#[pa_test_scratch::pa_test] #[test] fn acp_cancel_during_settle_cancels_the_subagents() { let Some(kernel_python) = kernel_python() else { @@ -2257,6 +2299,7 @@ fn acp_cancel_during_settle_cancels_the_subagents() { /// subagents (TS aborts the controller and exits): the process is gone /// while the resident session's held child still runs — EOF does not /// cancel a resident session's children. +#[pa_test_scratch::pa_test] #[test] fn acp_eof_during_settle_exits_and_leaves_resident_subagents() { let Some(kernel_python) = kernel_python() else { @@ -2296,6 +2339,7 @@ fn acp_eof_during_settle_exits_and_leaves_resident_subagents() { /// `heartbeats_changed` to every client; the ACP link publishes the /// change at origin turn 0 (connection-scoped like TS, never the active /// prompt turn). +#[pa_test_scratch::pa_test] #[test] fn acp_heartbeat_change_publishes_turn_zero_meta() { let mut client = AcpChild::spawn( @@ -2326,6 +2370,7 @@ fn acp_heartbeat_change_publishes_turn_zero_meta() { /// A bash run another client started on the bound session (the daemon's /// `execute_bash`) surfaces as one synthetic tool call keyed by run id: /// the started run, the streamed chunk, and the settled status. +#[pa_test_scratch::pa_test] #[test] fn acp_user_bash_maps_to_a_synthetic_tool_call() { let mut client = AcpChild::spawn( @@ -2377,6 +2422,7 @@ fn acp_user_bash_maps_to_a_synthetic_tool_call() { } #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_close_stop_failure_fences_the_session() { let mut client = AcpChild::spawn( @@ -2448,6 +2494,7 @@ fn acp_daemon_attached_close_stop_failure_fences_the_session() { drop(client); } +#[pa_test_scratch::pa_test] #[test] fn acp_daemon_attached_close_holds_the_input_pause_until_the_next_session_new() { let mut client = AcpChild::spawn( diff --git a/crates/pa-cli/tests/acp_mode_e2e/shutdown_tests.rs b/crates/pa-cli/tests/acp_mode_e2e/shutdown_tests.rs index ea7487daa..4066fb085 100644 --- a/crates/pa-cli/tests/acp_mode_e2e/shutdown_tests.rs +++ b/crates/pa-cli/tests/acp_mode_e2e/shutdown_tests.rs @@ -45,6 +45,7 @@ fn withhold_shutdown_acknowledgement(socket: &Path, pid: u32) -> std::thread::Jo }) } +#[pa_test_scratch::pa_test] #[test] fn missing_acknowledgement_passes_after_stubborn_child_is_confirmed_absent() { let root = tempfile::tempdir().expect("shutdown fixture root"); @@ -64,6 +65,7 @@ fn missing_acknowledgement_passes_after_stubborn_child_is_confirmed_absent() { ); } +#[pa_test_scratch::pa_test] #[test] fn missing_hello_cleanup_fixture() { let Some(root) = std::env::var_os("PA_TEST_MISSING_HELLO_ROOT") else { @@ -96,6 +98,7 @@ fn missing_hello_cleanup_fixture() { server.join().expect("missing hello fixture server"); } +#[pa_test_scratch::pa_test] #[test] fn missing_hello_confirms_owned_tree_absence_and_names_handshake_failure() { let root = tempfile::tempdir().expect("missing hello fixture root"); diff --git a/crates/pa-cli/tests/agents_view_anchor_e2e.rs b/crates/pa-cli/tests/agents_view_anchor_e2e.rs index e3d84f463..319ac2760 100644 --- a/crates/pa-cli/tests/agents_view_anchor_e2e.rs +++ b/crates/pa-cli/tests/agents_view_anchor_e2e.rs @@ -164,6 +164,7 @@ fn write_fixture(dir: &Path, id: &str, name: &str, turns: &[(&str, &str)]) -> Pa /// Enter opens the anchor's file, not the first-listed session's. #[tokio::test] +#[pa_test_scratch::pa_test] async fn entry_anchor_selects_the_left_session() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -237,6 +238,7 @@ async fn entry_anchor_selects_the_left_session() { /// The `--continue` launch's view contract (P6 continue-recent safety): preselect the /// newest saved session; Enter opens the candidate — the user confirms. #[tokio::test] +#[pa_test_scratch::pa_test] async fn continue_recent_view_preselects_the_candidate_and_renders_the_notice() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -326,6 +328,7 @@ async fn continue_recent_view_preselects_the_candidate_and_renders_the_notice() /// Through the real daemon (`rename_saved_session` wire path, which a unit test cannot /// exercise): the row renames in place, the file gains the name. #[tokio::test] +#[pa_test_scratch::pa_test] async fn rename_saved_session_renames_the_row_and_the_file() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-cli/tests/agents_view_flash_e2e.rs b/crates/pa-cli/tests/agents_view_flash_e2e.rs index b4fbc99e2..1eed1de79 100644 --- a/crates/pa-cli/tests/agents_view_flash_e2e.rs +++ b/crates/pa-cli/tests/agents_view_flash_e2e.rs @@ -354,6 +354,7 @@ fn view_options(socket: &Path, session_dir: &Path) -> AgentsViewOptions { const DEAD_CHILDREN: usize = 300; #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_first_agents_view_render_is_clean_behind_hundreds_of_dead_subagents() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -566,6 +567,7 @@ async fn the_first_agents_view_render_is_clean_behind_hundreds_of_dead_subagents /// A stopped session's row STAYS visible (TS `flipWorkerRosterEntriesInactive`; the Rust /// stop used to delete it — the operator's rows-disappear report). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_stopped_session_stays_visible_in_the_view() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-cli/tests/agents_view_refusal_panel_e2e.rs b/crates/pa-cli/tests/agents_view_refusal_panel_e2e.rs index 5ad5e7529..c0623cb47 100644 --- a/crates/pa-cli/tests/agents_view_refusal_panel_e2e.rs +++ b/crates/pa-cli/tests/agents_view_refusal_panel_e2e.rs @@ -142,6 +142,7 @@ fn frame_text(frames: &[String]) -> String { /// A foreign process has no known daemon resume endpoint. Its execution-lock /// refusal names the actual holder and offers kill/retry, dismissed by any key. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_refused_open_renders_the_foreign_holder_takeover_notice_panel() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-cli/tests/agents_view_reply_e2e.rs b/crates/pa-cli/tests/agents_view_reply_e2e.rs index e1f461381..360df1dc9 100644 --- a/crates/pa-cli/tests/agents_view_reply_e2e.rs +++ b/crates/pa-cli/tests/agents_view_reply_e2e.rs @@ -230,6 +230,7 @@ fn view_options(socket: &Path, session_dir: &Path, config: serde_json::Value) -> } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reply_to_live_session_delivers_the_prompt() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -387,6 +388,7 @@ async fn reply_to_live_session_delivers_the_prompt() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reply_to_saved_session_resumes_and_sends() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-cli/tests/agents_view_search_e2e.rs b/crates/pa-cli/tests/agents_view_search_e2e.rs index ed310c94a..42ebdfc12 100644 --- a/crates/pa-cli/tests/agents_view_search_e2e.rs +++ b/crates/pa-cli/tests/agents_view_search_e2e.rs @@ -198,6 +198,7 @@ fn dump_frames(label: &str, frames: &[String]) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn search_matches_names_ids_and_cwd_never_transcripts() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -357,6 +358,7 @@ async fn search_matches_names_ids_and_cwd_never_transcripts() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn ranked_hits_sort_by_relevance_then_recency() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-cli/tests/agents_view_subagents_e2e.rs b/crates/pa-cli/tests/agents_view_subagents_e2e.rs index 1c0ea023a..635a6c21b 100644 --- a/crates/pa-cli/tests/agents_view_subagents_e2e.rs +++ b/crates/pa-cli/tests/agents_view_subagents_e2e.rs @@ -230,6 +230,7 @@ fn view_options( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn panel_expand_drill_in_and_back_re_expands_the_tree() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -466,6 +467,7 @@ async fn panel_expand_drill_in_and_back_re_expands_the_tree() { /// A `keybindings.json` fixture rebinding the open action (`app.agents.open` right /// -> ctrl+g) — the hint renders the OVERRIDE key; it opens, the default key does not. #[tokio::test] +#[pa_test_scratch::pa_test] async fn agents_view_fires_user_keybindings_from_settings() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-cli/tests/chat_agents_chat_roundtrip_e2e.rs b/crates/pa-cli/tests/chat_agents_chat_roundtrip_e2e.rs index 9b3c3267d..aefadeccc 100644 --- a/crates/pa-cli/tests/chat_agents_chat_roundtrip_e2e.rs +++ b/crates/pa-cli/tests/chat_agents_chat_roundtrip_e2e.rs @@ -215,6 +215,7 @@ fn chat_options(socket: PathBuf, cwd: PathBuf) -> InteractiveOptions { /// The real round trip over one daemon: chat (agents-back) -> view -> the re-entry adopts /// the held handoff and renders the same rows. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_roundtrip_reentry_renders_the_same_transcript() { let _handoff_guard = HANDOFF_E2E_LOCK.lock().await; let dir = tempfile::TempDir::new().expect("temp dir"); @@ -362,6 +363,7 @@ async fn the_roundtrip_reentry_renders_the_same_transcript() { /// under the worker's final sequence (the settle update after /// `agent_end`). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_post_turn_sojourn_reentry_still_serves_the_held_packs() { let _handoff_guard = HANDOFF_E2E_LOCK.lock().await; let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-cli/tests/chat_open_first_frame_pty_e2e.rs b/crates/pa-cli/tests/chat_open_first_frame_pty_e2e.rs index 92a471ef6..752774e1b 100644 --- a/crates/pa-cli/tests/chat_open_first_frame_pty_e2e.rs +++ b/crates/pa-cli/tests/chat_open_first_frame_pty_e2e.rs @@ -44,6 +44,7 @@ const DOCK_DATA_DELAY_MS: u64 = 300; /// The child half: runs the real interactive loop against the parent's mock supervisor; a /// plain `cargo test` run passes trivially. +#[pa_test_scratch::pa_test] #[test] fn chat_open_first_frame_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -61,6 +62,7 @@ fn chat_open_first_frame_child_mode() { /// shared sandbox CPUs. static HARNESS_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); +#[pa_test_scratch::pa_test] #[test] fn chat_open_first_frame_pins_the_first_paint() { if !session_runner() { diff --git a/crates/pa-cli/tests/clipboard_auth_commands_e2e.rs b/crates/pa-cli/tests/clipboard_auth_commands_e2e.rs index 49d7524d5..1036a64e4 100644 --- a/crates/pa-cli/tests/clipboard_auth_commands_e2e.rs +++ b/crates/pa-cli/tests/clipboard_auth_commands_e2e.rs @@ -66,6 +66,7 @@ fn process_stat_alive(stat: &str) -> bool { !rest.trim_start().starts_with('Z') } +#[pa_test_scratch::pa_test] #[test] fn process_stat_parser_distinguishes_zombies_from_live_workers() { assert!(!process_stat_alive("123 (test worker) Z 1 2 3")); @@ -483,6 +484,7 @@ fn enter() -> pa_tui::interactive::HeadlessStep { // /copy #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_copy_emits_the_ts_osc52_sequence() { use base64::Engine; // No clipboard tools in the verifier: the copy chain falls to OSC 52 (the TS fallback). @@ -562,6 +564,7 @@ async fn tui_copy_emits_the_ts_osc52_sequence() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_copy_toast_coalesces_consecutive_copies_and_auto_dismisses() { use base64::Engine; for var in [ @@ -685,6 +688,7 @@ fn key(code: crossterm::event::KeyCode) -> pa_tui::interactive::HeadlessStep { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_prime_login_renders_the_inline_team_picker() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -801,6 +805,7 @@ async fn tui_prime_login_renders_the_inline_team_picker() { /// Esc on the team picker cancels the SELECTION (TS `onCancel`): the login still completes. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_prime_login_escape_keeps_the_default_team_status() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -873,6 +878,7 @@ async fn tui_prime_login_escape_keeps_the_default_team_status() { // /import #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_import_replaces_the_session_from_a_fixture() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -1062,6 +1068,7 @@ async fn tui_import_replaces_the_session_from_a_fixture() { // /login + /logout #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_login_and_logout_run_the_provider_flows() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -1186,6 +1193,7 @@ async fn tui_login_and_logout_run_the_provider_flows() { /// streams (the update replaces only the binary; the daemon keeps running); /// the outcome lands as a note row; a second in-flight run is refused. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_update_runs_out_of_band_during_a_turn() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -1264,6 +1272,7 @@ async fn tui_update_runs_out_of_band_during_a_turn() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_update_failure_lands_the_error_row() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -1336,6 +1345,7 @@ async fn tui_update_failure_lands_the_error_row() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_logout_with_no_stored_credentials_reports_the_ts_status() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-cli/tests/continue_guard_e2e.rs b/crates/pa-cli/tests/continue_guard_e2e.rs index 72e63b466..e9a374878 100644 --- a/crates/pa-cli/tests/continue_guard_e2e.rs +++ b/crates/pa-cli/tests/continue_guard_e2e.rs @@ -151,6 +151,7 @@ fn run_print(args: &[&str], env: &[(String, String)]) -> (String, String, i32) { /// `-c` refuses an active session with the exact TS error; a fresh daemon /// still continues the most recent session. +#[pa_test_scratch::pa_test] #[test] fn print_continue_refuses_an_active_daemon_session() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -274,6 +275,7 @@ fn print_continue_refuses_an_active_daemon_session() { /// A session file held by a live process outside the daemon roster refuses /// `--resume`. This test process holds the execution lock; the print process /// must discover that ownership before opening the session file. +#[pa_test_scratch::pa_test] #[test] fn print_resume_refuses_a_foreign_lease_holder() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-cli/tests/cursor_visibility_e2e.rs b/crates/pa-cli/tests/cursor_visibility_e2e.rs index 6a290a732..c5a232aae 100644 --- a/crates/pa-cli/tests/cursor_visibility_e2e.rs +++ b/crates/pa-cli/tests/cursor_visibility_e2e.rs @@ -47,6 +47,7 @@ const CHILD_SOCKET_ENV: &str = "PA_CURSOR_CHILD_SOCKET"; /// The child half of the e2e: runs the real interactive loop against the mock /// supervisor (a plain `cargo test` run passes trivially). +#[pa_test_scratch::pa_test] #[test] fn cursor_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -79,6 +80,7 @@ fn sigtstp_session_runner() -> bool { true } +#[pa_test_scratch::pa_test] #[test] fn cursor_stays_hidden_and_positioned_across_mount_picker_and_suspend() { if !sigtstp_session_runner() { @@ -217,6 +219,7 @@ fn cursor_stays_hidden_and_positioned_across_mount_picker_and_suspend() { harness.finish(); } +#[pa_test_scratch::pa_test] #[test] fn shell_markers_are_reserved_for_the_exit_transcript() { let _lock = HARNESS_LOCK diff --git a/crates/pa-cli/tests/daemon_commands_e2e.rs b/crates/pa-cli/tests/daemon_commands_e2e.rs index accab1f65..e1b64d697 100644 --- a/crates/pa-cli/tests/daemon_commands_e2e.rs +++ b/crates/pa-cli/tests/daemon_commands_e2e.rs @@ -352,6 +352,7 @@ fn is_clock(token: &str) -> bool { .all(|part| !part.is_empty() && part.chars().all(|c| c.is_ascii_digit())) } +#[pa_test_scratch::pa_test] #[test] fn hex_display_id_normalizes_as_a_timestamp_even_when_it_reads_as_an_age() { // The display id is the last 12 hex chars of a random uuid, so one @@ -573,6 +574,7 @@ impl CliPair { // Rust end-to-end: pa-daemon + prime-agent +#[pa_test_scratch::pa_test] #[test] fn rust_daemon_cli_commands_end_to_end() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -827,6 +829,7 @@ fn session_file_stem(row: &Value) -> String { .to_string() } +#[pa_test_scratch::pa_test] #[test] fn sessions_delete_is_all_or_nothing_and_reports_the_freed_bytes() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -1048,6 +1051,7 @@ fn sessions_delete_is_all_or_nothing_and_reports_the_freed_bytes() { assert_eq!(stop.status.code(), Some(0), "{}", stderr(&stop)); } +#[pa_test_scratch::pa_test] #[test] fn cli_connect_error_matches_ts_golden() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -1103,6 +1107,7 @@ fn cli_connect_error_matches_ts_golden() { /// The schedule commands' usage errors fire in the router's validation, before /// any daemon request (`--daemon-socket` before the command rotates into the /// operands; the TS CLI rejects the same shape). +#[pa_test_scratch::pa_test] #[test] fn schedule_usage_errors_and_valid_invocations() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -1312,6 +1317,7 @@ fn assert_ts_fixture_turns(wire: &mut Wire, name: &str, expected: usize) { // TS differential: each CLI uses its own product-default TS counterpart server +#[pa_test_scratch::pa_test] #[test] fn ts_daemon_differential_cli_output() { let Some(ts) = ts_binary() else { diff --git a/crates/pa-cli/tests/daemon_discovery_e2e.rs b/crates/pa-cli/tests/daemon_discovery_e2e.rs index 914cd4386..2ed37559d 100644 --- a/crates/pa-cli/tests/daemon_discovery_e2e.rs +++ b/crates/pa-cli/tests/daemon_discovery_e2e.rs @@ -128,6 +128,7 @@ fn run_cli(root: &Path, args: &[&str]) -> Output { /// process's ambient one, which on a dev box points at the real agent dir — /// and afterwards the whole client process is gone, not just its runtime: /// the terminal-close scenario. Only the supervisor it spawned may remain. +#[pa_test_scratch::pa_test] #[test] fn interactive_launcher_detaches_supervisor_from_client_session() { use std::io::{BufRead as _, BufReader}; @@ -198,6 +199,7 @@ fn interactive_launcher_detaches_supervisor_from_client_session() { /// run the real launcher (`ensure_daemon_running_with`, the interactive /// mode's pre-TUI path) against the fixture socket and exit, leaving only /// the detached supervisor behind. +#[pa_test_scratch::pa_test] #[test] fn launcher_client_child_mode() { let Some(socket) = std::env::var_os(LAUNCHER_CLIENT_SOCKET_ENV) else { @@ -319,6 +321,7 @@ fn reported_socket_paths(report: &Value) -> Vec { .collect() } +#[pa_test_scratch::pa_test] #[test] fn doctor_lists_and_then_reaps_an_idle_root_owned_daemon() { let fixture = tempfile::tempdir().expect("fixture"); @@ -382,6 +385,7 @@ fn doctor_lists_and_then_reaps_an_idle_root_owned_daemon() { wait_until_stopped(&socket, &mut daemon); } +#[pa_test_scratch::pa_test] #[test] fn shutdown_without_force_requires_confirmation_and_harms_nothing() { let fixture = tempfile::tempdir().expect("fixture"); @@ -433,6 +437,7 @@ fn shutdown_without_force_requires_confirmation_and_harms_nothing() { assert!(daemon.child.try_wait().expect("wait").is_none()); } +#[pa_test_scratch::pa_test] #[test] fn discovery_and_shutdown_from_another_root_leave_a_foreign_daemon_alive() { // Fixture A holds a live supervisor; fixture B is a completely different @@ -726,6 +731,7 @@ fn tracked_worker_pid(agent_dir: &Path, supervisor_socket: &Path) -> u32 { /// live workers of their own. A shutdown must stop only the daemons its /// root owns — the pinned socket, never the pinned directory — and never /// another daemon's workers. +#[pa_test_scratch::pa_test] #[test] fn force_shutdown_from_an_env_pinned_root_stops_only_that_daemon_tree() { let shared_tmp = tempfile::tempdir().expect("shared tmpdir"); @@ -921,6 +927,7 @@ fn fixture_process_scalars(pid: u32) -> (u32, Option, Option, Option< /// An agent-dir override can contain the shared worker directory while its /// own supervisor is pinned elsewhere. Such a root must still exclude other /// supervisors' workers from both discovery and the force residual sweep. +#[pa_test_scratch::pa_test] #[test] fn a_pinned_root_with_an_overlapping_agent_dir_never_stops_foreign_workers() { let shared_tmp = tempfile::tempdir().expect("shared worker tmpdir"); @@ -1020,6 +1027,7 @@ fn a_pinned_root_with_an_overlapping_agent_dir_never_stops_foreign_workers() { /// child, so `prime-agent --mode daemon --daemon-socket B` launched from /// inside a worker must come up as B's supervisor — never as a second /// worker of the live supervisor the inherited env points at. +#[pa_test_scratch::pa_test] #[test] fn a_daemon_launched_with_an_inherited_worker_env_comes_up_as_a_supervisor() { let fixture = tempfile::tempdir().expect("fixture"); diff --git a/crates/pa-cli/tests/differential_cli.rs b/crates/pa-cli/tests/differential_cli.rs index 362f9d43a..8dc64a3e4 100644 --- a/crates/pa-cli/tests/differential_cli.rs +++ b/crates/pa-cli/tests/differential_cli.rs @@ -354,6 +354,7 @@ fn isolate_child(command: &mut Command, sandbox: &Path) { } fn run(binary: &Path, args: &[&str], sandbox: &Path) -> InvocationOutput { + let _timing_span = pa_test_scratch::timing::span("run.child_process"); let mut command = Command::new("timeout"); command.arg("20").arg(binary).args(args); isolate_child(&mut command, sandbox); @@ -368,6 +369,7 @@ fn run(binary: &Path, args: &[&str], sandbox: &Path) -> InvocationOutput { /// Normalize version numbers so the TS product version (0.9.x) and the Rust /// workspace version can be compared structurally. fn normalize(text: &str, sandbox_roots: &[&Path]) -> String { + let _timing_span = pa_test_scratch::timing::span("run.normalization"); let mut text = text.to_string(); // Sandbox paths leak into cwd-related error messages; normalize them so // the per-binary sandbox roots compare equal. @@ -449,6 +451,7 @@ fn normalize_versions(text: &str) -> String { } fn sandbox(prefix: &str) -> PathBuf { + let _timing_span = pa_test_scratch::timing::span("setup.fixture"); let base = std::env::temp_dir().join(format!( "pa-cli-differential-{prefix}-{}", std::process::id() @@ -591,6 +594,7 @@ fn declared_late_console_case(case: &[&str]) -> bool { // These declared divergences are also native contracts when no TS reference is // installed. None disables only the TS expectation, never the native assertion. +#[pa_test_scratch::pa_test] #[test] fn native_cli_contract_fixtures() { let rust = PathBuf::from(env!("CARGO_BIN_EXE_prime-agent")); @@ -631,6 +635,7 @@ fn native_cli_contract_fixtures() { } } +#[pa_test_scratch::pa_test] #[test] fn differential_corpus_matches_ts_binary() { let Some(ts) = ts_binary() else { @@ -692,6 +697,7 @@ fn run_with_env( sandbox: &Path, envs: &[(&str, &str)], ) -> InvocationOutput { + let _timing_span = pa_test_scratch::timing::span("run.child_process"); let mut command = Command::new("timeout"); command.arg("20").arg(binary).args(args); isolate_child(&mut command, sandbox); @@ -706,6 +712,7 @@ fn run_with_env( } } +#[pa_test_scratch::pa_test] #[test] fn differential_env_flag_cases_match_ts_binary() { let Some(ts) = ts_binary() else { @@ -777,6 +784,7 @@ fn exported_css_vars(html: &str) -> Vec { /// Differential parity for `session export`: the same fixture exported by /// both binaries prints the same success line and produces files carrying /// the same session data, theme CSS variables, and template scaffolding. +#[pa_test_scratch::pa_test] #[test] fn differential_session_export_matches_ts_binary() { let Some(ts) = ts_binary() else { diff --git a/crates/pa-cli/tests/dock_scope_exit_focus_e2e.rs b/crates/pa-cli/tests/dock_scope_exit_focus_e2e.rs index de67660a4..79b8fa3de 100644 --- a/crates/pa-cli/tests/dock_scope_exit_focus_e2e.rs +++ b/crates/pa-cli/tests/dock_scope_exit_focus_e2e.rs @@ -411,11 +411,13 @@ async fn scope_exit_keeps_the_subagents_item(exit_key: &'static str) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn scoped_view_escape_returns_to_the_subagents_dock_item() { scope_exit_keeps_the_subagents_item("escape").await; } #[tokio::test] +#[pa_test_scratch::pa_test] async fn scoped_view_left_returns_to_the_subagents_dock_item() { scope_exit_keeps_the_subagents_item("left").await; } @@ -483,6 +485,7 @@ fn assert_scoped_frame(frame: &str) { /// top-level agents view. Its dock entry opens the session's own scoped /// view, empty, and the new action starts a child bound to the session. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_session_without_subagents_opens_its_empty_scoped_view() { let dir = tempfile::TempDir::new().expect("temp dir"); let session_dir = pa_daemon::paths::sessions_dir(&dir.path().join("agent")) @@ -525,6 +528,7 @@ async fn a_session_without_subagents_opens_its_empty_scoped_view() { /// A child bound to the session while its empty scoped view is open pops in /// without reopening the view. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_child_created_under_the_open_empty_scope_appears_live() { let dir = tempfile::TempDir::new().expect("temp dir"); let session_dir = pa_daemon::paths::sessions_dir(&dir.path().join("agent")) diff --git a/crates/pa-cli/tests/editor_handoff_paint_pty_e2e.rs b/crates/pa-cli/tests/editor_handoff_paint_pty_e2e.rs index 51b0e3411..0fa317332 100644 --- a/crates/pa-cli/tests/editor_handoff_paint_pty_e2e.rs +++ b/crates/pa-cli/tests/editor_handoff_paint_pty_e2e.rs @@ -250,6 +250,7 @@ fn graceful_shutdown(socket: &Path) { /// The child half: runs the real interactive loop against the real supervisor; a /// plain `cargo test` run passes trivially. +#[pa_test_scratch::pa_test] #[test] fn editor_handoff_paint_child_mode() { let (Ok(socket), Ok(session), Ok(editor)) = ( @@ -313,6 +314,7 @@ static HARNESS_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); /// The regression: a mid-stream external-editor handoff must not stop the /// transcript from painting the settled reply, and a follow-up plain submit /// must still paint. +#[pa_test_scratch::pa_test] #[test] fn editor_handoff_keeps_painting_the_streaming_transcript() { if !session_runner() { diff --git a/crates/pa-cli/tests/exit_backfill_pty_e2e.rs b/crates/pa-cli/tests/exit_backfill_pty_e2e.rs index 9cce5915a..916b5c9dd 100644 --- a/crates/pa-cli/tests/exit_backfill_pty_e2e.rs +++ b/crates/pa-cli/tests/exit_backfill_pty_e2e.rs @@ -56,6 +56,7 @@ const LAST_ROW: &[u8] = b"tail row 8"; /// The child half: runs the real interactive loop against the parent's /// mock supervisor; a plain `cargo test` run passes trivially. +#[pa_test_scratch::pa_test] #[test] fn exit_backfill_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -86,11 +87,13 @@ fn exit_backfill_child_mode() { /// The pty harnesses serialize: concurrent byte-level waits flake on the shared test CPUs. static HARNESS_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); +#[pa_test_scratch::pa_test] #[test] fn exit_does_not_wait_for_a_pending_backfill_page() { leave_with_pending_backfill(b"/exit\r"); } +#[pa_test_scratch::pa_test] #[test] fn resume_does_not_wait_for_a_pending_backfill_page() { leave_with_pending_backfill(b"/resume s2\r"); diff --git a/crates/pa-cli/tests/export_live_differential.rs b/crates/pa-cli/tests/export_live_differential.rs index 1ded0e75f..d698cd7f6 100644 --- a/crates/pa-cli/tests/export_live_differential.rs +++ b/crates/pa-cli/tests/export_live_differential.rs @@ -100,6 +100,7 @@ fn process_stat_alive(stat: &str) -> bool { !rest.trim_start().starts_with('Z') } +#[pa_test_scratch::pa_test] #[test] fn process_stat_parser_distinguishes_zombies_from_live_workers() { assert!(!process_stat_alive("123 (test worker) Z 1 2 3")); @@ -440,6 +441,7 @@ fn live_export(binary: &Path, base: &Path, ts_side: bool) -> Value { data } +#[pa_test_scratch::pa_test] #[test] fn differential_live_export_matches_ts_binary() { let Some(ts) = ts_binary() else { diff --git a/crates/pa-cli/tests/export_share_e2e.rs b/crates/pa-cli/tests/export_share_e2e.rs index 47aa28678..e2a731f89 100644 --- a/crates/pa-cli/tests/export_share_e2e.rs +++ b/crates/pa-cli/tests/export_share_e2e.rs @@ -67,6 +67,7 @@ fn process_stat_alive(stat: &str) -> bool { !rest.trim_start().starts_with('Z') } +#[pa_test_scratch::pa_test] #[test] fn process_stat_parser_distinguishes_zombies_from_live_workers() { assert!(!process_stat_alive("123 (test worker) Z 1 2 3")); @@ -209,6 +210,7 @@ fn make_executable(path: &Path) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn export_refuses_unavailable_tools_while_session_log_is_locked() { use std::io::Write as _; use std::os::unix::ffi::OsStrExt as _; @@ -369,6 +371,7 @@ end}}} } #[tokio::test] +#[pa_test_scratch::pa_test] async fn cached_build_failure_keeps_the_leaf_diagnostic_in_display_reads() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -484,6 +487,7 @@ async fn cached_build_failure_keeps_the_leaf_diagnostic_in_display_reads() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_export_and_share_surface() { use base64::Engine as _; let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-cli/tests/input_live_open_pty_e2e.rs b/crates/pa-cli/tests/input_live_open_pty_e2e.rs index 1c221376f..0a7679d18 100644 --- a/crates/pa-cli/tests/input_live_open_pty_e2e.rs +++ b/crates/pa-cli/tests/input_live_open_pty_e2e.rs @@ -68,6 +68,7 @@ const PTY_COLS: usize = 80; /// mode against the parent's mock supervisor. A plain `cargo test` run /// (no `CHILD_SOCKET_ENV`) passes trivially — only the parent test drives /// the real path. +#[pa_test_scratch::pa_test] #[test] fn input_live_open_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -93,6 +94,7 @@ static HARNESS_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); /// A keystroke echoes into the rendered surface while the session open is /// still in flight (the attach is stalled for `OPEN_STALL_MS`), and the /// typed-ahead text plus the queued Enter submit once the open lands. +#[pa_test_scratch::pa_test] #[test] fn typing_echoes_while_the_session_open_is_stalled() { let _lock = match HARNESS_LOCK.lock() { @@ -152,6 +154,7 @@ fn typing_echoes_while_the_session_open_is_stalled() { /// Drive terminal bytes through the real reader, bindings, editor, and wire. /// Negotiation matters: sending CSI-u alone does not prove the app enabled it. +#[pa_test_scratch::pa_test] #[test] fn terminal_enter_bindings_preserve_newlines_and_follow_ups() { let _lock = HARNESS_LOCK diff --git a/crates/pa-cli/tests/installer_platform_map.rs b/crates/pa-cli/tests/installer_platform_map.rs index 859cfd544..44e1f21dd 100644 --- a/crates/pa-cli/tests/installer_platform_map.rs +++ b/crates/pa-cli/tests/installer_platform_map.rs @@ -77,6 +77,7 @@ fn map_row(output: &Output) -> String { /// The five published platforms resolve to their channel rows; the Windows /// uname family (Git Bash, MSYS2, Cygwin) lands on the MSVC build with the /// `.exe` binary name. +#[pa_test_scratch::pa_test] #[test] fn the_uname_map_resolves_the_published_platforms() { let cases = [ @@ -130,6 +131,7 @@ fn the_uname_map_resolves_the_published_platforms() { /// An unsupported machine gets the honest refusal: the full matrix — the /// MSVC build named — plus the Windows entry points, so the die tells the /// user exactly what ships. +#[pa_test_scratch::pa_test] #[test] fn the_uname_map_refuses_unsupported_machines_with_the_matrix() { for (os, arch) in [ @@ -159,6 +161,7 @@ fn the_uname_map_refuses_unsupported_machines_with_the_matrix() { /// `NATIVE_PLATFORMS` spelling the manifest reader keeps), the ARM64 /// refusal, and the two render lines the release pipeline's publish step /// stamps (the sed + grep contract in release.yml's promote job). +#[pa_test_scratch::pa_test] #[test] fn install_ps1_carries_the_windows_contract() { let text = std::fs::read_to_string(repo_root().join("install.ps1")).expect("read install.ps1"); @@ -210,6 +213,7 @@ fn install_ps1_carries_the_windows_contract() { /// (the file name plus the size, install-rust.sh's discipline), and /// restores the caller's values after: the quiet zone is the download, /// never the session. +#[pa_test_scratch::pa_test] #[test] fn install_ps1_pins_the_download_preferences_around_the_downloads() { let text = std::fs::read_to_string(repo_root().join("install.ps1")).expect("read install.ps1"); @@ -284,6 +288,7 @@ fn install_ps1_pins_the_download_preferences_around_the_downloads() { /// string the installer EMITS - Write-Host, Write-Warning, and Fail's /// thrown message - must be plain ASCII. The script's comments and the /// launcher files it writes are out of scope: neither lands on the console. +#[pa_test_scratch::pa_test] #[test] fn install_ps1_emits_only_ascii_output() { let text = std::fs::read_to_string(repo_root().join("install.ps1")).expect("read install.ps1"); @@ -317,6 +322,7 @@ fn install_ps1_emits_only_ascii_output() { /// bootstrap that cannot fix a missing DLL. With the static-runtime build /// the class should not occur at all; if it does, the message must say /// what actually happened. +#[pa_test_scratch::pa_test] #[test] fn install_ps1_names_the_dll_not_found_failure_honestly() { let text = std::fs::read_to_string(repo_root().join("install.ps1")).expect("read install.ps1"); @@ -363,6 +369,7 @@ fn install_ps1_names_the_dll_not_found_failure_honestly() { /// in the same console immediately, and the printed hint says a NEW /// terminal gets it automatically instead of telling the user to go edit /// the registry by hand. +#[pa_test_scratch::pa_test] #[test] fn install_ps1_adds_bin_to_the_user_path_and_the_session_path() { let text = std::fs::read_to_string(repo_root().join("install.ps1")).expect("read install.ps1"); @@ -480,6 +487,7 @@ fn install_ps1_adds_bin_to_the_user_path_and_the_session_path() { /// operator-set dir wins, the Windows C:\ spelling normalizes through /// cygpath exactly like `PRIME_AGENT_RUST_PREFIX`, and the knob is /// documented in the header's Configuration block. +#[pa_test_scratch::pa_test] #[test] fn install_rust_sh_honors_the_uv_bin_dir_knob() { let text = @@ -595,6 +603,7 @@ fn install_rust_sh_honors_the_uv_bin_dir_knob() { /// file's name, the landed bytes, the percent) with three attempts - the /// .NET transfer records stay silent the whole time (the download-block /// pins test covers the silencing). +#[pa_test_scratch::pa_test] #[test] fn install_ps1_runs_a_step_ledger_and_its_own_download_progress() { let text = std::fs::read_to_string(repo_root().join("install.ps1")).expect("read install.ps1"); @@ -681,6 +690,7 @@ fn install_ps1_runs_a_step_ledger_and_its_own_download_progress() { /// (install-rust.sh's pre-warm PATH fix), and a failure degrades to the /// honest note plus the exact manual command (the sh installer's /// note/todo shape). +#[pa_test_scratch::pa_test] #[test] fn install_ps1_installs_uv_like_the_linux_installer() { let text = std::fs::read_to_string(repo_root().join("install.ps1")).expect("read install.ps1"); @@ -773,6 +783,7 @@ fn install_ps1_installs_uv_like_the_linux_installer() { /// drive-based or UNC path - a rooted-only check accepts drive-relative /// spellings like C:uv-bin that resolve against the CURRENT directory in /// later shells. +#[pa_test_scratch::pa_test] #[test] fn install_ps1_validates_the_uv_knob_before_any_side_effect() { let text = std::fs::read_to_string(repo_root().join("install.ps1")).expect("read install.ps1"); @@ -813,6 +824,7 @@ fn install_ps1_validates_the_uv_knob_before_any_side_effect() { /// `crt-static` flag, rejects any vcruntime import in the built PE (the /// stock-box 0xC0000135 regression guard), gates on the uv install the /// ps1 route promises, and restores the User PATH it dirtied. +#[pa_test_scratch::pa_test] #[test] fn windows_install_e2e_builds_the_shipped_link_mode() { let harness = std::fs::read_to_string( @@ -848,6 +860,7 @@ fn windows_install_e2e_builds_the_shipped_link_mode() { /// drops only the entries under its own scratch dir, and writes back with /// the kind preserved - a Path the test created from nothing is deleted /// again; a Path untouched by the test is not rewritten at all. +#[pa_test_scratch::pa_test] #[test] fn windows_e2e_harnesses_strip_only_their_own_path_entries() { for harness_name in [ @@ -901,6 +914,7 @@ fn windows_e2e_harnesses_strip_only_their_own_path_entries() { /// within the stall window throws and takes the retry path, while a /// slow-but-flowing body never trips it (a read returns as soon as data /// arrives, the window restarts per chunk). +#[pa_test_scratch::pa_test] #[test] fn install_ps1_download_survives_a_stalled_body() { let text = std::fs::read_to_string(repo_root().join("install.ps1")).expect("read install.ps1"); @@ -949,6 +963,7 @@ fn install_ps1_download_survives_a_stalled_body() { /// while a working PATH uv is never shadowed (a stale target file cannot /// displace it) and a uv at the canonical `~/.local/bin` needs no prepend /// (`ensure_uv` finds it by itself). +#[pa_test_scratch::pa_test] #[test] fn install_ps1_does_not_shadow_a_working_uv() { let text = std::fs::read_to_string(repo_root().join("install.ps1")).expect("read install.ps1"); @@ -985,6 +1000,7 @@ fn install_ps1_does_not_shadow_a_working_uv() { /// same handoff the block runs `UV_INSTALL_DIR` through, with the caller's /// value saved and restored) and the child reads the variable - no /// PowerShell parsing of the path happens at any version. +#[pa_test_scratch::pa_test] #[test] fn install_ps1_passes_the_uv_installer_path_as_process_data() { let text = std::fs::read_to_string(repo_root().join("install.ps1")).expect("read install.ps1"); @@ -1038,6 +1054,7 @@ fn install_ps1_passes_the_uv_installer_path_as_process_data() { /// saved and restored. The cleanup has no uv work left to do, and the /// user's ~/.local/bin is referenced only by the read-only pre-state /// check. +#[pa_test_scratch::pa_test] #[test] fn windows_e2e_harnesses_isolate_the_uv_install() { for harness_name in [ @@ -1083,6 +1100,7 @@ fn windows_e2e_harnesses_isolate_the_uv_install() { /// being wrong. The harness records the pre-state first, and the gate /// throws only for a box that had no uv in either place install.ps1 /// looks. +#[pa_test_scratch::pa_test] #[test] fn windows_install_e2e_gates_the_uv_install_on_a_fresh_runner() { let harness = std::fs::read_to_string( @@ -1136,6 +1154,7 @@ fn windows_install_e2e_gates_the_uv_install_on_a_fresh_runner() { /// and clears them again in cleanup, so the e2e touches the real profile /// only through the User PATH registry value and the uv binaries (both /// snapshotted and restored). +#[pa_test_scratch::pa_test] #[test] fn windows_e2e_harnesses_keep_the_kernel_prewarm_writes_in_scratch() { for harness_name in [ diff --git a/crates/pa-cli/tests/installer_update_e2e.rs b/crates/pa-cli/tests/installer_update_e2e.rs index 7bade05bc..019d0b27d 100644 --- a/crates/pa-cli/tests/installer_update_e2e.rs +++ b/crates/pa-cli/tests/installer_update_e2e.rs @@ -157,6 +157,7 @@ fn prime_agent(args: &[&str], sandbox: &Sandbox) -> Command { command } +#[pa_test_scratch::pa_test] #[test] fn update_runs_the_downloaded_installer_and_preserves_the_session_store() { let sandbox = Sandbox::new(); @@ -193,6 +194,7 @@ fn update_runs_the_downloaded_installer_and_preserves_the_session_store() { /// A nightly install's `prime-agent update` fetches `install-beta.sh` from /// the download base (no installer override): the domain only forwards /// the stable `install.sh`, so nightly updates go to the bucket directly. +#[pa_test_scratch::pa_test] #[test] fn a_nightly_update_fetches_install_beta_from_the_download_base() { let sandbox = Sandbox::new(); @@ -228,6 +230,7 @@ fn a_nightly_update_fetches_install_beta_from_the_download_base() { } /// A failing installer reports the error and keeps the previous install. +#[pa_test_scratch::pa_test] #[test] fn a_failing_installer_keeps_the_previous_install() { let sandbox = Sandbox::new(); @@ -371,6 +374,7 @@ fn live_version(sandbox: &Sandbox) -> String { /// kept, `--rollback` swaps the kept payload back (keeping the one it /// replaces), so a second `--rollback` undoes the first; the session store /// is untouched throughout. +#[pa_test_scratch::pa_test] #[test] fn update_archive_and_rollback_swap_installer_payloads() { let sandbox = Sandbox::new(); @@ -431,6 +435,7 @@ fn update_archive_and_rollback_swap_installer_payloads() { /// payload (the Windows update handoff runs this exact scan before it /// hands the real run off, so its exit code is honest for the /// deterministic refusals). +#[pa_test_scratch::pa_test] #[test] fn rollback_check_answers_synchronously_without_touching_the_payload() { let sandbox = Sandbox::new(); @@ -500,6 +505,7 @@ fn rollback_check_answers_synchronously_without_touching_the_payload() { /// `--version` is the ground truth for the marker the install records /// (and the rollback later reports), so a name/payload mismatch would /// publish a lie. +#[pa_test_scratch::pa_test] #[test] fn update_archive_refuses_a_misnamed_payload_version() { let sandbox = Sandbox::new(); @@ -552,6 +558,7 @@ fn update_archive_refuses_a_misnamed_payload_version() { /// payload at the un-suffixed `prime-agent.old` and never writes the /// generations record, so the CLI's rollback must fall back to that /// slot — a ps1-updated machine's only automated rollback path. +#[pa_test_scratch::pa_test] #[test] fn update_rollback_reads_the_unsuffixed_installer_slot() { let sandbox = Sandbox::new(); @@ -602,6 +609,7 @@ fn update_rollback_reads_the_unsuffixed_installer_slot() { /// A fresh installer install has nothing to roll back: the run fails with /// the reason and the live payload stays. +#[pa_test_scratch::pa_test] #[test] fn update_rollback_without_a_kept_version_changes_nothing() { let sandbox = Sandbox::new(); @@ -653,6 +661,7 @@ fn update_rollback_without_a_kept_version_changes_nothing() { /// Windows update handoff runs this exact validation before it hands /// the real run off, so its exit code is honest for the deterministic /// refusals). +#[pa_test_scratch::pa_test] #[test] fn archive_check_answers_synchronously_without_publishing() { let sandbox = Sandbox::new(); diff --git a/crates/pa-cli/tests/interactive_daemon_e2e.rs b/crates/pa-cli/tests/interactive_daemon_e2e.rs index 69cfd4be5..d1a607fc8 100644 --- a/crates/pa-cli/tests/interactive_daemon_e2e.rs +++ b/crates/pa-cli/tests/interactive_daemon_e2e.rs @@ -391,6 +391,7 @@ async fn create_session_via_daemon( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_attaches_prompts_streams_lists_and_switches() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -724,6 +725,7 @@ impl pa_tui::provider_auth::ProviderAuthCommands for FullFlowProviderAuth { /// The full first-run flow with no usable model (TS `runOnboardingFlow`'s /// not-ready branch): every answer, both credentials, and the flag persist. #[tokio::test] +#[pa_test_scratch::pa_test] async fn fresh_home_runs_the_full_sign_in_flow_to_completion() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -857,6 +859,7 @@ async fn fresh_home_runs_the_full_sign_in_flow_to_completion() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_failed_completion_write_surfaces_a_warning_and_never_kills_the_run() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -913,6 +916,7 @@ async fn a_failed_completion_write_surfaces_a_warning_and_never_kills_the_run() } #[tokio::test] +#[pa_test_scratch::pa_test] async fn ensure_daemon_running_spawns_supervisor_and_tui_attaches() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -1000,6 +1004,7 @@ async fn ensure_daemon_running_spawns_supervisor_and_tui_attaches() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_dispatches_slash_commands_menu_and_suggestions() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -1179,6 +1184,7 @@ async fn tui_dispatches_slash_commands_menu_and_suggestions() { /// and Enter applies it (durable `model_change` row); `/effort` without /// reasoning reports the TS unsupported note (an `off`-only list is no thinking). #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_model_picker_applies_and_effort_reports() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -1331,6 +1337,7 @@ async fn tui_model_picker_applies_and_effort_reports() { /// The `thinkingLevelMap` (not the `reasoning` flag) is the capability signal: /// `/effort` applies its declared level. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_effort_applies_on_a_map_addressable_model_without_the_reasoning_flag() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -1453,6 +1460,7 @@ async fn tui_effort_applies_on_a_map_addressable_model_without_the_reasoning_fla /// The skip (TS `CompactionSkippedError`) reaches the transcript through the /// `compaction_end` event. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_compact_on_a_short_session_warns_nothing_to_compact() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -1552,6 +1560,7 @@ async fn tui_compact_on_a_short_session_warns_nothing_to_compact() { /// The loader row is a soft capture: a loaded box can batch the delayMs-paced /// window past the paint loop. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_compact_shows_the_loader_then_the_summary_and_rebuilds() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -1729,6 +1738,7 @@ async fn tui_compact_shows_the_loader_then_the_summary_and_rebuilds() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_session_tree_navigates_forks_and_clones() { use crossterm::event::{KeyCode, KeyModifiers}; @@ -1890,6 +1900,7 @@ async fn tui_session_tree_navigates_forks_and_clones() { /// Two ~12k-token unpaced turns must render at the producer's rate, not a frame-rate ceiling. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_big_streamed_turns_render_at_the_producer_rate() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -2010,6 +2021,7 @@ async fn tui_big_streamed_turns_render_at_the_producer_rate() { /// A settings fixture rebinding `app.tools.expand` to `ctrl+alt+x` drives the surface. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_renders_and_fires_user_keybindings_from_settings() { use crossterm::event::{KeyCode, KeyModifiers}; @@ -2159,6 +2171,7 @@ async fn tui_renders_and_fires_user_keybindings_from_settings() { /// The visible follow-up queue (TS `queuedMessagesContainer`): prompts /// submitted while a turn runs park as dim preview rows with the browse hint. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_prompts_queued_behind_a_turn_render_the_queue_strip() { use crossterm::event::{KeyCode, KeyModifiers}; let dir = tempfile::TempDir::new().expect("temp dir"); @@ -2265,6 +2278,7 @@ async fn tui_prompts_queued_behind_a_turn_render_the_queue_strip() { /// model resolves from the full catalog and fails at run-start auth /// validation with the TS login-guidance message — never "Model not found". #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_flagged_model_turn_reports_the_ts_preflight_error_without_credentials() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -2362,6 +2376,7 @@ async fn tui_flagged_model_turn_reports_the_ts_preflight_error_without_credentia /// The dogfood acceptance: a `/model` pick must move the footer label immediately /// and leave the next turn on the switched model. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_model_pick_refreshes_the_label_and_the_next_turn_resolves() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -2481,6 +2496,7 @@ async fn tui_model_pick_refreshes_the_label_and_the_next_turn_resolves() { /// `--models` scope end to end: the cycle keys walk the session's scope /// order, not the catalog's (mock-2 must never appear). #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_scoped_models_cycle_through_the_session_scope() { use crossterm::event::{KeyCode, KeyModifiers}; @@ -2603,6 +2619,7 @@ fn base_options( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_renames_session_through_slash_command() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -2682,6 +2699,7 @@ async fn tui_renames_session_through_slash_command() { // the new session through the `/name` path, the verbatim suffix submits as the // initial prompt, and a parse error keeps the draft without creating a session. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_new_command_honors_name_and_prompt() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -2824,6 +2842,7 @@ async fn tui_new_command_honors_name_and_prompt() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_side_question_pane_flow() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -2948,6 +2967,7 @@ async fn tui_side_question_pane_flow() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_settings_menu_cycles_rows() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -3013,6 +3033,7 @@ async fn tui_settings_menu_cycles_rows() { /// The operator's Esc-ordering pin (2026-09-25): Esc closes the cwd /// completion menu without interrupting the streaming turn. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_esc_closes_the_completion_menu_without_interrupting_the_turn() { use crossterm::event::KeyCode; @@ -3092,6 +3113,7 @@ async fn tui_esc_closes_the_completion_menu_without_interrupting_the_turn() { /// Prompt-stash verifier: a draft in the editor belongs to the session it was typed in. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_prompt_stash_round_trips_across_in_place_switch() { use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; @@ -3216,6 +3238,7 @@ async fn tui_prompt_stash_round_trips_across_in_place_switch() { /// Prompt-stash verifier, the agents-view handoff arm: the (user-rebound) /// `app.session.resume` key stashes the draft; reopening the chat restores it. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_prompt_stash_survives_the_agents_view_handoff() { use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; @@ -3374,6 +3397,7 @@ async fn tui_prompt_stash_survives_the_agents_view_handoff() { /// Prompt-stash verifier, the pasted-image arm: the stashed draft round-trips its image bytes. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_prompt_stash_restores_a_pasted_image_with_the_draft() { use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; @@ -3506,6 +3530,7 @@ async fn tui_prompt_stash_restores_a_pasted_image_with_the_draft() { /// TS `handlePromptStash` — `app.prompt.stash` on its DEFAULT key (ctrl+s): /// stash with a draft, restore with an empty editor. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_ctrl_s_stashes_and_restores_the_prompt_draft() { use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; @@ -3666,6 +3691,7 @@ async fn tui_ctrl_s_stashes_and_restores_the_prompt_draft() { /// restores the held draft into the emptied editor (TS /// `promptStashToRestore`). #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_ctrl_s_stash_keeps_a_held_draft_and_reports_the_empty_editor() { use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; @@ -3801,6 +3827,7 @@ async fn tui_ctrl_s_stash_keeps_a_held_draft_and_reports_the_empty_editor() { /// `app.prompt.stash` is remappable: a user binding replaces the default outright. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_ctrl_s_stash_is_remappable_via_keybindings_json() { use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; @@ -3942,6 +3969,7 @@ async fn tui_ctrl_s_stash_is_remappable_via_keybindings_json() { /// draft and shows the parked text, so the stash must stash the user's draft, /// and the disarmed browse keeps the next Enter from deleting the parked message. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_ctrl_s_during_queue_browse_stashes_the_draft_and_keeps_the_parked_message() { use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; @@ -4115,6 +4143,7 @@ async fn tui_ctrl_s_during_queue_browse_stashes_the_draft_and_keeps_the_parked_m /// Declared chat-editor keybindings dispatch: ctrl+l opens the picker, and /// the no-default actions fire from a user keybindings.json. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_dispatches_declared_editor_keybindings() { use crossterm::event::{KeyCode, KeyModifiers}; @@ -4257,6 +4286,7 @@ async fn create_idle_session_with_settled_turn( /// IDLE settled session must paint the transcript from the attach snapshot /// alone; the run's only step is a settle window. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_attach_to_idle_session_renders_without_input() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -4387,6 +4417,7 @@ fn subscription_options( /// and the daemon's marker (the supervisor routes the new /// `mark_anthropic_warning_shown` frame to the worker). #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_anthropic_warning_warns_once_then_a_fresh_process_reattaches_silently() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -4518,6 +4549,7 @@ async fn tui_anthropic_warning_warns_once_then_a_fresh_process_reattaches_silent /// ever reaches the run; the renamed tray label only appears when the /// event's render scheduling works. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_idle_session_event_repaints_without_input() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -4582,6 +4614,7 @@ async fn tui_idle_session_event_repaints_without_input() { /// `prime-agent` run must open a FRESH session even when a newer saved session /// exists for the cwd — resuming it blindly would resurrect whatever it holds. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_bare_launch_opens_a_fresh_session_when_a_newer_saved_one_exists_for_the_cwd() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -4664,6 +4697,7 @@ async fn tui_bare_launch_opens_a_fresh_session_when_a_newer_saved_one_exists_for /// submissions (the second while the first's round trip is in flight) reach /// the daemon in order; the ordered channel pins it. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_two_back_to_back_submits_reach_the_daemon_in_order() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -4762,6 +4796,7 @@ async fn tui_two_back_to_back_submits_reach_the_daemon_in_order() { /// the outcome stays SILENT on the newly mounted session, while the daemon /// still ran the turn for the switched-away session (TS's staleness guard). #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_submit_outlived_by_switch_stays_silent_on_the_new_session() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -4892,6 +4927,7 @@ async fn tui_submit_outlived_by_switch_stays_silent_on_the_new_session() { /// closed `ui_rx` is select-ready forever, so the loop must park the closed /// arm (the exit gate waits on the turn's events) — an unparked arm hot-spins. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_headless_done_with_a_turn_settling_parks_the_closed_input_channel() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -4972,6 +5008,7 @@ async fn tui_headless_done_with_a_turn_settling_parks_the_closed_input_channel() /// killing the worker (and removing its file, so no rebind can resurrect it) /// settles the round trip as a refusal — the turn never ran. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_refused_submit_restores_the_draft_after_the_round_trip() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -5090,6 +5127,7 @@ async fn tui_refused_submit_restores_the_draft_after_the_round_trip() { /// for the worker's `isStreaming` state (an external admission condition), /// so I/O stalls cannot move a fixed submit/kill clock across the edge. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_accepted_then_killed_turn_renders_closed_error() { let dir = tempfile::TempDir::new().expect("temp dir"); let session_dir = dir.path().join("agent/sessions"); @@ -5227,6 +5265,7 @@ async fn tui_accepted_then_killed_turn_renders_closed_error() { /// Both terminal close reasons remain visible after a later, replaceable turn status. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_close_reason_rows_survive_late_turn_status() { for (reason, explanation) in [ ("shutdown", "The Prime Agent daemon shut down while this window was attached. The session transcript remains saved; restart Prime Agent and reopen it from Agents View."), diff --git a/crates/pa-cli/tests/interactive_fork_e2e.rs b/crates/pa-cli/tests/interactive_fork_e2e.rs index 0988d442f..defb99611 100644 --- a/crates/pa-cli/tests/interactive_fork_e2e.rs +++ b/crates/pa-cli/tests/interactive_fork_e2e.rs @@ -38,6 +38,7 @@ const CHILD_ENV: &str = "PA_INTERACTIVE_FORK_CHILD"; /// The interactive client half: the same entry point the shipped binary /// calls, over the pty the parent opened — the real fork startup. The exit /// code lands in the outcome file for the parent to assert. +#[pa_test_scratch::pa_test] #[test] fn interactive_fork_child_mode() { let Ok(config) = std::env::var(CHILD_ENV) else { @@ -361,6 +362,7 @@ fn find_subsequence(haystack: &[u8], needle: &[u8]) -> Option { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn interactive_fork_launch_copies_and_the_daemon_opens_the_fork() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-cli/tests/kitty_early_typing_e2e.rs b/crates/pa-cli/tests/kitty_early_typing_e2e.rs index 8a9165fed..d56f4a042 100644 --- a/crates/pa-cli/tests/kitty_early_typing_e2e.rs +++ b/crates/pa-cli/tests/kitty_early_typing_e2e.rs @@ -51,6 +51,7 @@ const CHILD_SOCKET_ENV: &str = "PA_EARLY_TYPING_CHILD_SOCKET"; /// The child half of the e2e: runs the real chat surface against the harness's /// mock supervisor (a plain `cargo test` run passes trivially). +#[pa_test_scratch::pa_test] #[test] fn early_typing_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -72,6 +73,7 @@ fn early_typing_child_mode() { /// The pty harnesses serialize: concurrent process-group signals and raw ptys flake on shared CPUs. static HARNESS_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); +#[pa_test_scratch::pa_test] #[test] fn early_typing_inside_the_probe_window_renders_before_the_settle() { let _lock = match HARNESS_LOCK.lock() { @@ -110,6 +112,7 @@ fn early_typing_inside_the_probe_window_renders_before_the_settle() { harness.finish(); } +#[pa_test_scratch::pa_test] #[test] fn a_kitty_terminal_upgrades_and_a_da1_terminal_settles_without_flags() { let _lock = match HARNESS_LOCK.lock() { diff --git a/crates/pa-cli/tests/kitty_exit_routes_e2e/main.rs b/crates/pa-cli/tests/kitty_exit_routes_e2e/main.rs index 0adc0b8da..4e83602da 100644 --- a/crates/pa-cli/tests/kitty_exit_routes_e2e/main.rs +++ b/crates/pa-cli/tests/kitty_exit_routes_e2e/main.rs @@ -115,6 +115,7 @@ impl Route { /// The child half: re-executed with the route env, it runs the REAL surface /// like the CLI composition (a plain `cargo test` run passes trivially). +#[pa_test_scratch::pa_test] #[test] fn kitty_exit_child_mode() { let (Ok(route), Ok(socket)) = ( @@ -126,6 +127,7 @@ fn kitty_exit_child_mode() { child_run(&route, PathBuf::from(socket)); } +#[pa_test_scratch::pa_test] #[test] fn every_exit_route_restores_the_kitty_mode() { let _lock = match HARNESS_LOCK.lock() { diff --git a/crates/pa-cli/tests/kitty_release_handoff_e2e.rs b/crates/pa-cli/tests/kitty_release_handoff_e2e.rs index ca461960e..ca63a9e60 100644 --- a/crates/pa-cli/tests/kitty_release_handoff_e2e.rs +++ b/crates/pa-cli/tests/kitty_release_handoff_e2e.rs @@ -55,6 +55,7 @@ const CHILD_SOCKET_ENV: &str = "PA_KITTY_CHILD_SOCKET"; /// The child half of the e2e: runs the real chat surface against the mock /// supervisor, then hands off like the CLI composition (a plain `cargo test` passes). +#[pa_test_scratch::pa_test] #[test] fn kitty_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -108,6 +109,7 @@ fn kitty_child_mode() { /// The pty harnesses serialize: concurrent process-group signals and raw ptys flake on shared CPUs. static HARNESS_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); +#[pa_test_scratch::pa_test] #[test] fn releases_around_the_handoff_never_become_visible() { let _lock = match HARNESS_LOCK.lock() { diff --git a/crates/pa-cli/tests/kitty_verdict_time_e2e.rs b/crates/pa-cli/tests/kitty_verdict_time_e2e.rs index f10a06ac7..db1d9792c 100644 --- a/crates/pa-cli/tests/kitty_verdict_time_e2e.rs +++ b/crates/pa-cli/tests/kitty_verdict_time_e2e.rs @@ -63,6 +63,7 @@ const SWEEP_ENV: &str = "PA_KITTY_VERDICT_SWEEP"; /// The child half of the e2e: runs the real chat surface in terminal mode against /// the mock supervisor (a plain `cargo test` run passes trivially). +#[pa_test_scratch::pa_test] #[test] fn verdict_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -84,6 +85,7 @@ fn verdict_child_mode() { /// The pty harnesses serialize: concurrent process-group signals and raw ptys flake on shared CPUs. static HARNESS_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); +#[pa_test_scratch::pa_test] #[test] fn a_da1_terminal_concludes_before_the_ms60_late_kitty_reply() { let _lock = match HARNESS_LOCK.lock() { @@ -127,6 +129,7 @@ fn a_da1_terminal_concludes_before_the_ms60_late_kitty_reply() { harness.finish(); } +#[pa_test_scratch::pa_test] #[test] fn a_da1_terminal_concludes_before_the_ms100_late_kitty_reply() { let _lock = match HARNESS_LOCK.lock() { @@ -154,6 +157,7 @@ fn a_da1_terminal_concludes_before_the_ms100_late_kitty_reply() { harness.finish(); } +#[pa_test_scratch::pa_test] #[test] fn the_same_ms100_reply_on_a_silent_pty_still_upgrades() { let _lock = match HARNESS_LOCK.lock() { @@ -175,6 +179,7 @@ fn the_same_ms100_reply_on_a_silent_pty_still_upgrades() { harness.finish(); } +#[pa_test_scratch::pa_test] #[test] fn the_kitty_control_upgrades_at_the_answer() { let _lock = match HARNESS_LOCK.lock() { @@ -194,6 +199,7 @@ fn the_kitty_control_upgrades_at_the_answer() { harness.finish(); } +#[pa_test_scratch::pa_test] #[test] fn a_raced_suspend_on_a_da1_terminal_does_not_wait_for_the_deadline() { let _lock = match HARNESS_LOCK.lock() { @@ -225,6 +231,7 @@ fn a_raced_suspend_on_a_da1_terminal_does_not_wait_for_the_deadline() { harness.finish(); } +#[pa_test_scratch::pa_test] #[test] fn a_raced_suspend_on_a_silent_pty_keeps_the_deadline() { let _lock = match HARNESS_LOCK.lock() { @@ -261,6 +268,7 @@ fn a_raced_suspend_on_a_silent_pty_keeps_the_deadline() { /// The characterization sweep (VM-only, opt-in): CI never sets the env, so it /// returns trivially there; each cell prints one `SWEEP_ROW` json line. +#[pa_test_scratch::pa_test] #[test] fn verdict_time_characterization_sweep() { if std::env::var(SWEEP_ENV).is_err() { diff --git a/crates/pa-cli/tests/lock_compat_e2e.rs b/crates/pa-cli/tests/lock_compat_e2e.rs index bd3b12783..ac0ba2c94 100644 --- a/crates/pa-cli/tests/lock_compat_e2e.rs +++ b/crates/pa-cli/tests/lock_compat_e2e.rs @@ -128,6 +128,7 @@ fn assert_settings_has_server(sandbox: &Path, name: &str) { ); } +#[pa_test_scratch::pa_test] #[test] fn ts_binary_fails_on_stale_lock_file_artifact() { // The regression that wedged a real TS install: a pre-compat Rust flock @@ -165,6 +166,7 @@ fn ts_binary_fails_on_stale_lock_file_artifact() { ); } +#[pa_test_scratch::pa_test] #[test] fn ts_binary_reclaims_stale_lock_directory_artifact() { // A crashed TS (or Rust) holder leaves an empty lock directory. The TS @@ -195,6 +197,7 @@ fn ts_binary_reclaims_stale_lock_directory_artifact() { ); } +#[pa_test_scratch::pa_test] #[test] fn ts_binary_sees_a_rust_held_lock_as_contention() { // A Rust-held lock must be indistinguishable from a TS-held lock: an @@ -249,6 +252,7 @@ fn ts_binary_sees_a_rust_held_lock_as_contention() { assert_settings_has_server(&sandbox, "http-three"); } +#[pa_test_scratch::pa_test] #[test] fn rust_binary_reclaims_stale_lock_directory_artifact() { let rust = PathBuf::from(env!("CARGO_BIN_EXE_prime-agent")); @@ -274,6 +278,7 @@ fn rust_binary_reclaims_stale_lock_directory_artifact() { ); } +#[pa_test_scratch::pa_test] #[test] fn rust_binary_heals_stale_lock_file_artifact() { // Pre-compat Rust builds left flock FILEs at the lock path. The Rust diff --git a/crates/pa-cli/tests/login_panel_pty_e2e.rs b/crates/pa-cli/tests/login_panel_pty_e2e.rs index 415312571..54bc4116e 100644 --- a/crates/pa-cli/tests/login_panel_pty_e2e.rs +++ b/crates/pa-cli/tests/login_panel_pty_e2e.rs @@ -45,6 +45,7 @@ const CHILD_SOCKET_ENV: &str = "PA_LOGIN_PANEL_CHILD_SOCKET"; /// The child half: the real interactive loop against the parent's mock /// supervisor, with the scripted provider-auth hook. +#[pa_test_scratch::pa_test] #[test] fn login_panel_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -60,6 +61,7 @@ fn login_panel_child_mode() { /// The `/mcp`-view child half: the same loop with a scripted client-auth /// hook and a roster carrying the `linear` service. +#[pa_test_scratch::pa_test] #[test] fn login_panel_mcp_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -75,6 +77,7 @@ fn login_panel_mcp_child_mode() { /// The model-picker sign-in child: the real loop with an unsigned /// provider's model in the catalog and a scripted API-key login. +#[pa_test_scratch::pa_test] #[test] fn model_sign_in_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -346,6 +349,7 @@ const MOUSE_DISABLE: &str = "\x1b[?1006l\x1b[?1002l"; /// The terminal-sequence e2e: `/login` drives the inline auth panel, and /// the byte stream shows no terminal takeover (the old flow's alt-screen /// leave + clear + raw stdin prompt never happen). +#[pa_test_scratch::pa_test] #[test] fn prime_login_renders_the_team_picker_without_a_terminal_takeover() { let mut harness = LoginPanelHarness::start(); @@ -401,6 +405,7 @@ fn prime_login_renders_the_team_picker_without_a_terminal_takeover() { /// The `/mcp`-view login e2e: Enter on the connection row runs the login /// flow, and the byte stream shows the panel rendering INLINE. +#[pa_test_scratch::pa_test] #[test] fn mcp_view_enter_login_renders_inline_without_a_terminal_takeover() { let mut harness = LoginPanelHarness::start_mcp(); @@ -441,6 +446,7 @@ fn mcp_view_enter_login_renders_inline_without_a_terminal_takeover() { /// The model-picker sign-in e2e (the operator's bug report): the unsigned /// provider's row stays visible ("require sign in"), selecting it routes the /// sign-in flow, and a successful sign-in applies the model automatically. +#[pa_test_scratch::pa_test] #[test] fn model_picker_routes_the_sign_in_flow_and_applies_after_login() { let mut harness = LoginPanelHarness::start_model_sign_in(); diff --git a/crates/pa-cli/tests/mcp_view_e2e.rs b/crates/pa-cli/tests/mcp_view_e2e.rs index b92e573f9..645be85fa 100644 --- a/crates/pa-cli/tests/mcp_view_e2e.rs +++ b/crates/pa-cli/tests/mcp_view_e2e.rs @@ -385,6 +385,7 @@ async fn assert_roster_answers_fast(socket: &Path, dir: &Path) { /// The TUI surface: the headless client opens `/mcp`, the inline view /// renders the roster, Esc closes it, and Enter dispatches the login. #[tokio::test] +#[pa_test_scratch::pa_test] async fn mcp_view_lists_the_configured_mock_connection() { let dir = tempfile::TempDir::new().expect("temp dir"); std::fs::create_dir_all(dir.path().join("agent").join("sessions")).expect("session dir"); @@ -463,6 +464,7 @@ async fn mcp_view_lists_the_configured_mock_connection() { /// the session-build window, so `/mcp` froze mid-turn. The TS picker builds /// rows from local state, so the mid-turn open is instant. #[tokio::test] +#[pa_test_scratch::pa_test] async fn get_mcp_connections_answers_instantly_mid_turn() { let dir = tempfile::TempDir::new().expect("temp dir"); std::fs::create_dir_all(dir.path().join("agent").join("sessions")).expect("session dir"); diff --git a/crates/pa-cli/tests/mermaid_titled_empty_subgraph_e2e.rs b/crates/pa-cli/tests/mermaid_titled_empty_subgraph_e2e.rs index 59687360f..10e7cb89d 100644 --- a/crates/pa-cli/tests/mermaid_titled_empty_subgraph_e2e.rs +++ b/crates/pa-cli/tests/mermaid_titled_empty_subgraph_e2e.rs @@ -333,6 +333,7 @@ fn headless_options( /// the attach paint; the fixed one paints the surviving clusters, omits the /// empty one titled `on the workers`, and keeps taking turns. #[tokio::test] +#[pa_test_scratch::pa_test] async fn attach_survives_a_titled_empty_subgraph_diagram() { let dir = tempfile::TempDir::new().expect("temp dir"); std::fs::create_dir_all(dir.path().join("agent").join("sessions")).expect("session dir"); diff --git a/crates/pa-cli/tests/nix_managed_update.rs b/crates/pa-cli/tests/nix_managed_update.rs index 482eb524b..9f7143e15 100644 --- a/crates/pa-cli/tests/nix_managed_update.rs +++ b/crates/pa-cli/tests/nix_managed_update.rs @@ -20,6 +20,7 @@ impl Drop for RestoreOwner { // This integration test executable has one test: its process-local ownership // marker cannot race another test. Subprocesses receive an environment allowlist. #[tokio::test] +#[pa_test_scratch::pa_test] async fn nix_ownership_blocks_cli_and_both_direct_installer_boundaries() { let dir = tempfile::tempdir().unwrap(); let root = dir.path(); diff --git a/crates/pa-cli/tests/package_e2e.rs b/crates/pa-cli/tests/package_e2e.rs index 79abae687..98f9e3ae3 100644 --- a/crates/pa-cli/tests/package_e2e.rs +++ b/crates/pa-cli/tests/package_e2e.rs @@ -144,6 +144,7 @@ fn write_executable(path: &Path, content: &str) { std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755)).unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn generated_shell_shims_use_a_direct_interpreter() { let _fixture_guard = EXECUTABLE_FIXTURE_LOCK.lock().unwrap(); @@ -420,6 +421,7 @@ fn normalize_hashes(text: &str) -> String { /// Git fetch ranges (`..`) must survive version normalization. /// Regression: the old normalizer trimmed a `..` to `.` whenever the old /// hash ended in a digit, making the drives differ for ~29% of runs. +#[pa_test_scratch::pa_test] #[test] fn normalize_keeps_git_fetch_ranges_for_all_hash_shapes() { let fetch_ranges = [ @@ -523,6 +525,7 @@ fn drive(binary: &Path, base: &Path, fixtures: &Fixtures) -> (String, Sandbox) { (transcript, sandbox) } +#[pa_test_scratch::pa_test] #[test] fn package_manager_corpus_matches_ts_binary() { let _fixture_guard = EXECUTABLE_FIXTURE_LOCK.lock().unwrap(); diff --git a/crates/pa-cli/tests/package_resources_e2e.rs b/crates/pa-cli/tests/package_resources_e2e.rs index 8700523fa..842732d7d 100644 --- a/crates/pa-cli/tests/package_resources_e2e.rs +++ b/crates/pa-cli/tests/package_resources_e2e.rs @@ -92,6 +92,7 @@ fn assistant_text(stdout: &str) -> String { .expect("assistant message in output") } +#[pa_test_scratch::pa_test] #[test] fn package_provided_skill_appears_in_created_session_skill_list() { let script = serde_json::json!({ "responses": [{"systemPrompt": true}] }); diff --git a/crates/pa-cli/tests/packaged_layout_e2e.rs b/crates/pa-cli/tests/packaged_layout_e2e.rs index a555caeae..8922941cf 100644 --- a/crates/pa-cli/tests/packaged_layout_e2e.rs +++ b/crates/pa-cli/tests/packaged_layout_e2e.rs @@ -247,6 +247,7 @@ fn run_json_turn( /// A packaged session boots the kernel with the exe-adjacent layout: the /// ipython cell runs through the staged binary and the skills resolve from /// the staged `skills/` directory. +#[pa_test_scratch::pa_test] #[test] fn packaged_session_boots_kernel_without_pi_package_dir() { let _guard = serial_lock(); @@ -303,6 +304,7 @@ fn packaged_session_boots_kernel_without_pi_package_dir() { /// The staged manifest reports the pinned version (TS `--version` reads the /// packaged package.json at runtime). +#[pa_test_scratch::pa_test] #[test] fn packaged_binary_reports_manifest_version() { let _guard = serial_lock(); @@ -329,6 +331,7 @@ fn packaged_binary_reports_manifest_version() { } /// A missing sidecar (broken install) surfaces the actionable failure, not a raw uv/pip error. +#[pa_test_scratch::pa_test] #[test] fn missing_sidecar_reports_actionable_bootstrap_error() { let _guard = serial_lock(); @@ -361,6 +364,7 @@ fn missing_sidecar_reports_actionable_bootstrap_error() { } /// A `PRIME_AGENT_KERNEL_PYTHON` that lacks the runtime reports the TS override error. +#[pa_test_scratch::pa_test] #[test] fn invalid_kernel_python_override_reports_ts_error() { let _guard = serial_lock(); @@ -444,6 +448,7 @@ fn hostile_child_assertions(staged: &Path) { /// kernel-env recipe leaks it into the test env and flips the /// missing-sidecar test. This test re-execs this binary with a hostile env /// and asserts hermetic behavior in the child. +#[pa_test_scratch::pa_test] #[test] fn packaged_layout_stays_hermetic_under_hostile_host_env() { if let Some(stage) = std::env::var_os(HOSTILE_CHILD_STAGE) { @@ -568,6 +573,7 @@ fn split_paired_fixture(python: &str, version: &str, target: &str, alias: &str) /// The packaging dry-run produces the release artifact (staged layout, /// tarball, manifest, integrity sums) with no dev caches. +#[pa_test_scratch::pa_test] #[test] fn packaging_dry_run_produces_artifact() { let _guard = serial_lock(); @@ -960,6 +966,7 @@ fn sha256(data: &[u8]) -> [u8; 32] { /// Heavy (network + uv): the packaged sidecar bootstraps a fresh kernel /// venv and boots a session: `cargo test -p pa-cli --test packaged_layout_e2e -- --ignored` +#[pa_test_scratch::pa_test] #[test] #[ignore = "network + uv bootstrap (~minutes); the lane verifier runs it explicitly"] fn bootstrap_kernel_venv_from_packaged_sidecar() { diff --git a/crates/pa-cli/tests/plugin_headless/daemon.rs b/crates/pa-cli/tests/plugin_headless/daemon.rs index cbbefa513..103308ea8 100644 --- a/crates/pa-cli/tests/plugin_headless/daemon.rs +++ b/crates/pa-cli/tests/plugin_headless/daemon.rs @@ -111,6 +111,7 @@ fn catalog(wire: &mut Wire, session: &str) -> Vec { // Keep the production lifecycle trace linear so the generation and history assertions stay ordered. #[allow(clippy::too_many_lines)] +#[pa_test_scratch::pa_test] #[test] fn real_supervisor_worker_discovers_invokes_reloads_and_retires_lua_commands() { let fixture = Fixture::new(); diff --git a/crates/pa-cli/tests/plugin_headless_e2e.rs b/crates/pa-cli/tests/plugin_headless_e2e.rs index 4a80a54b7..38f6166dc 100644 --- a/crates/pa-cli/tests/plugin_headless_e2e.rs +++ b/crates/pa-cli/tests/plugin_headless_e2e.rs @@ -211,6 +211,7 @@ fn success(output: &Output) { ); } +#[pa_test_scratch::pa_test] #[test] fn configured_lua_command_crosses_cli_and_persists_only_command_rows() { let fixture = Fixture::new(); @@ -244,6 +245,7 @@ fn configured_lua_command_crosses_cli_and_persists_only_command_rows() { assert!(!entries.iter().any(|row| row["type"] == "message")); } +#[pa_test_scratch::pa_test] #[test] fn lua_command_json_uses_shared_executor_frames_without_a_model_turn() { let fixture = Fixture::new(); @@ -278,6 +280,7 @@ fn lua_command_json_uses_shared_executor_frames_without_a_model_turn() { assert_eq!(value["args"], "json args"); } +#[pa_test_scratch::pa_test] #[test] fn unavailable_slash_input_never_becomes_a_model_prompt() { for prompt in [ @@ -305,6 +308,7 @@ fn unavailable_slash_input_never_becomes_a_model_prompt() { } } +#[pa_test_scratch::pa_test] #[test] fn disabled_command_is_unavailable_and_saved_data_survives() { let fixture = Fixture::new(); @@ -320,6 +324,7 @@ fn disabled_command_is_unavailable_and_saved_data_survives() { assert_eq!(std::fs::read_to_string(saved).unwrap(), "retained"); } +#[pa_test_scratch::pa_test] #[test] fn lua_failures_and_unsupported_streams_reject_the_prompt_wait() { for (prompt, error) in [ @@ -344,6 +349,7 @@ fn lua_failures_and_unsupported_streams_reject_the_prompt_wait() { } } +#[pa_test_scratch::pa_test] #[test] fn reload_has_visible_output_but_no_turn_or_management_history_rows() { for args in [ @@ -361,6 +367,7 @@ fn reload_has_visible_output_but_no_turn_or_management_history_rows() { } } +#[pa_test_scratch::pa_test] #[test] fn prompt_inspection_lists_active_contributions_without_persistence_or_kernel() { let fixture = Fixture::new(); @@ -400,6 +407,7 @@ fn prompt_inspection_lists_active_contributions_without_persistence_or_kernel() ); } +#[pa_test_scratch::pa_test] #[test] fn actual_model_prompt_includes_the_active_plugin_inventory() { let fixture = Fixture::new(); @@ -412,6 +420,7 @@ fn actual_model_prompt_includes_the_active_plugin_inventory() { assert!(stdout(&output).contains("/plugin_echo")); } +#[pa_test_scratch::pa_test] #[test] fn templates_and_skills_still_expand_before_command_routing() { let fixture = Fixture::new(); @@ -443,6 +452,7 @@ fn templates_and_skills_still_expand_before_command_routing() { assert_eq!(stdout(&output), "skill used\n"); } +#[pa_test_scratch::pa_test] #[test] fn prompt_inspection_keeps_model_rules_and_append_layers_consistent() { let fixture = Fixture::new(); diff --git a/crates/pa-cli/tests/print_inline_subagents_e2e.rs b/crates/pa-cli/tests/print_inline_subagents_e2e.rs index 35e68373e..cf0c9dda5 100644 --- a/crates/pa-cli/tests/print_inline_subagents_e2e.rs +++ b/crates/pa-cli/tests/print_inline_subagents_e2e.rs @@ -226,6 +226,7 @@ fn combined_parent_script() -> serde_json::Value { /// both reply from their kernels; the print run waits for the replies, /// answers with the combined text, and disposes the child kernels (the /// final namespace snapshots land in the children's artifact dirs). +#[pa_test_scratch::pa_test] #[test] fn print_inline_subagents_wait_for_replies_and_combine_them() { let lane = lane(); @@ -378,6 +379,7 @@ fn print_inline_subagents_wait_for_replies_and_combine_them() { /// The depth gate: with `RLM_MAX_DEPTH=1`, a depth-1 child's own spawn /// fails with the shared depth-limit error in its tool result, and the /// print run still completes. +#[pa_test_scratch::pa_test] #[test] fn print_inline_subagents_enforce_the_depth_limit() { let lane = lane(); @@ -457,6 +459,7 @@ fn print_inline_subagents_enforce_the_depth_limit() { /// The quiescence predicate reads the child's live session state (the /// queued follow-up row), so the run cannot exit while the row sits in /// the settled child's steering lane. +#[pa_test_scratch::pa_test] #[test] fn print_inline_subagents_wait_for_a_retasked_child() { let lane = lane(); @@ -536,6 +539,7 @@ fn print_inline_subagents_wait_for_a_retasked_child() { /// with no stale error from the failed run. The child's error response is /// delayed past the parent's spawn turn, so its failure row drains through /// the quiescence drive, not the spawn turn's steering poll. +#[pa_test_scratch::pa_test] #[test] fn print_inline_subagents_report_a_failed_child_then_a_clean_retry() { let lane = lane(); @@ -670,6 +674,7 @@ fn goal_context_positions(entries: &[serde_json::Value]) -> Vec { /// child's reply row, and its turn completes the goal, so the printed /// answer is the post-reply turn. No backoff sleeps: the continuation /// turn produces output and calls `goal.complete()`. +#[pa_test_scratch::pa_test] #[test] fn print_inline_goal_continuation_waits_for_the_child_reply() { let lane = lane(); @@ -752,6 +757,7 @@ fn print_inline_goal_continuation_waits_for_the_child_reply() { /// and the reply turn; the real run uses spawn + half the reply turn /// (thousands of tokens of margin, so the crossing lands mid-reply-turn /// and nowhere else). +#[pa_test_scratch::pa_test] #[test] fn print_inline_budget_steer_from_a_drained_reply_runs_after_it() { let warm_lane = lane(); @@ -881,6 +887,7 @@ fn print_inline_budget_steer_from_a_drained_reply_runs_after_it() { ); } +#[pa_test_scratch::pa_test] #[test] fn print_inline_rename_rejects_sibling_collisions_and_preserves_routing() { let lane = lane(); @@ -950,6 +957,7 @@ print("SELF RENAME REJECTED") ); } +#[pa_test_scratch::pa_test] #[test] fn print_inline_delete_cancels_an_executing_child_and_removes_it() { let lane = lane(); diff --git a/crates/pa-cli/tests/print_runtime_e2e.rs b/crates/pa-cli/tests/print_runtime_e2e.rs index 638acbeb8..ffc3a21d6 100644 --- a/crates/pa-cli/tests/print_runtime_e2e.rs +++ b/crates/pa-cli/tests/print_runtime_e2e.rs @@ -36,6 +36,7 @@ fn run(args: &[&str], script: &serde_json::Value) -> (String, String, i32) { ) } +#[pa_test_scratch::pa_test] #[test] fn print_mode_text_output_matches_the_scripted_response() { let script = serde_json::json!({ "responses": ["first answer"] }); @@ -45,6 +46,7 @@ fn print_mode_text_output_matches_the_scripted_response() { assert!(stderr.is_empty()); } +#[pa_test_scratch::pa_test] #[test] fn print_mode_multi_prompt_consumes_responses_in_order() { let script = serde_json::json!({ "responses": ["first answer", "second answer"] }); @@ -53,6 +55,7 @@ fn print_mode_multi_prompt_consumes_responses_in_order() { assert_eq!(stdout, "second answer\n"); } +#[pa_test_scratch::pa_test] #[test] fn print_mode_json_streams_ts_shaped_events() { let script = serde_json::json!({ "responses": ["json answer"] }); @@ -90,6 +93,7 @@ fn print_mode_json_streams_ts_shaped_events() { assert_eq!(*types.last().unwrap(), "agent_end"); } +#[pa_test_scratch::pa_test] #[test] fn print_mode_reports_provider_errors_as_exit_one() { // No responses queued: the faux provider returns an error stop reason. @@ -156,6 +160,7 @@ fn read_entries(path: &std::path::Path) -> Vec { /// The goal cap's text-mode end state: the capped run exits 1 with the reason, and a later /// resume of the capped session answers normally — the persisted cap never swallows a run. +#[pa_test_scratch::pa_test] #[test] fn print_mode_goal_cap_reports_the_reason_and_exits_one() { let home = isolated_home(); @@ -204,6 +209,7 @@ fn leased_session_files(home: &std::path::Path) -> Vec { leased } +#[pa_test_scratch::pa_test] #[test] fn print_mode_persists_a_session_file_by_default() { let home = isolated_home(); @@ -239,6 +245,7 @@ fn print_mode_persists_a_session_file_by_default() { assert_eq!(entries[0]["cwd"], home.path().display().to_string()); } +#[pa_test_scratch::pa_test] #[test] fn print_mode_no_session_writes_nothing() { let home = isolated_home(); @@ -251,6 +258,7 @@ fn print_mode_no_session_writes_nothing() { /// A regular file at the lease root forces EEXIST before any persistent admission. /// Exercise all initial in-process modes with a real, test-owned HTTP provider. +#[pa_test_scratch::pa_test] #[test] fn fresh_lease_failure_rejects_print_json_and_rpc_before_model_http_or_journal_append() { use std::io::{Read, Write}; @@ -361,6 +369,7 @@ fn fresh_lease_failure_rejects_print_json_and_rpc_before_model_http_or_journal_a } } +#[pa_test_scratch::pa_test] #[test] fn fresh_lease_failure_does_not_block_no_session_mode() { let home = isolated_home(); @@ -379,6 +388,7 @@ fn fresh_lease_failure_does_not_block_no_session_mode() { assert_eq!(std::fs::read(blocker).unwrap(), b"not a directory"); } +#[pa_test_scratch::pa_test] #[test] fn print_mode_resume_appends_to_the_same_session_file() { let home = isolated_home(); @@ -418,6 +428,7 @@ fn print_mode_resume_appends_to_the_same_session_file() { assert!(texts.contains(&"second")); } +#[pa_test_scratch::pa_test] #[test] fn print_mode_continue_recent_reuses_the_latest_session() { let home = isolated_home(); @@ -439,6 +450,7 @@ fn print_mode_continue_recent_reuses_the_latest_session() { /// A finished print run releases the session file's runtime lease: the run /// exits and no owner record survives under `session-leases`. +#[pa_test_scratch::pa_test] #[test] fn print_mode_releases_the_session_lease_when_the_run_ends() { let home = isolated_home(); @@ -454,6 +466,7 @@ fn print_mode_releases_the_session_lease_when_the_run_ends() { ); } +#[pa_test_scratch::pa_test] #[test] fn print_mode_resume_unknown_selector_fails_with_browse_hint() { let home = isolated_home(); @@ -473,6 +486,7 @@ fn print_mode_resume_unknown_selector_fails_with_browse_hint() { } /// `--thinking max` on a reasoning faux model must persist the clamped effective level. +#[pa_test_scratch::pa_test] #[test] fn print_mode_thinking_max_persists_the_clamped_high_level() { let home = isolated_home(); @@ -494,6 +508,7 @@ fn print_mode_thinking_max_persists_the_clamped_high_level() { } /// The clamp also applies on the way down: a non-reasoning model maps any requested level to off. +#[pa_test_scratch::pa_test] #[test] fn print_mode_thinking_clamps_to_off_for_non_reasoning_models() { let home = isolated_home(); @@ -549,6 +564,7 @@ const OVERFLOW_RECOVERY_FAILED: &str = "Context overflow recovery failed after o /// The full compact-and-retry cycle (verified against the TS binary): an /// overflow drops the failed turn, compacts once, re-issues, and the second /// overflow ends the run, exit 1. +#[pa_test_scratch::pa_test] #[test] fn print_mode_overflow_compacts_retries_once_then_reports() { let home = isolated_home(); @@ -602,6 +618,7 @@ fn print_mode_overflow_compacts_retries_once_then_reports() { } /// The retry on the compacted context recovers the turn (exit 0). +#[pa_test_scratch::pa_test] #[test] fn print_mode_overflow_retry_recovers_the_turn() { let home = isolated_home(); @@ -637,6 +654,7 @@ fn print_mode_overflow_retry_recovers_the_turn() { /// A skipped recovery (nothing compactable) surfaces the warning row and /// exits 0 — the TS text-mode contract. +#[pa_test_scratch::pa_test] #[test] fn print_mode_overflow_skip_surfaces_the_warning_row() { let home = isolated_home(); @@ -664,6 +682,7 @@ fn print_mode_overflow_skip_surfaces_the_warning_row() { /// against the TS binary): the `compaction_start`/`compaction_end` pair with /// `willRetry: true`, the retried turn without a new user message, /// and the reported failure surface. +#[pa_test_scratch::pa_test] #[test] fn print_mode_overflow_json_streams_the_compaction_events() { let home = isolated_home(); @@ -762,6 +781,7 @@ fn print_mode_overflow_json_streams_the_compaction_events() { /// The stale-overflow recovery across runs (the `--continue` shape, /// verified against the TS binary): the resumed run's pre-turn arm compacts /// the stale overflow before the admitted prompt. +#[pa_test_scratch::pa_test] #[test] fn print_mode_stale_overflow_recovers_before_the_next_prompt_after_a_resume() { let home = isolated_home(); @@ -808,6 +828,7 @@ fn print_mode_stale_overflow_recovers_before_the_next_prompt_after_a_resume() { /// The streaming deltas (TS `message_update`): the wire carries the slim /// deltas (`partial` never rides the wire). +#[pa_test_scratch::pa_test] #[test] fn print_mode_json_streams_the_message_update_deltas() { let home = isolated_home(); @@ -862,6 +883,7 @@ fn print_mode_json_streams_the_message_update_deltas() { /// The threshold compaction arm (TS `_checkCompaction` Case 3): a settled /// turn crossing the reserve headroom streams the `compaction_start`/ /// `compaction_end` pair with the `threshold` reason. +#[pa_test_scratch::pa_test] #[test] fn print_mode_json_streams_the_threshold_compaction_pair() { let home = isolated_home(); @@ -967,6 +989,7 @@ fn run_in_home_cwd( /// TS `createSessionManager`'s fork arm: `--fork ` copies the /// source session into a NEW file (TS `SessionManager.forkFrom`), the run /// continues the copy, and the fork header parents at the source. +#[pa_test_scratch::pa_test] #[test] fn print_mode_fork_copies_the_session_into_a_new_file() { let home = isolated_home(); @@ -1021,6 +1044,7 @@ fn print_mode_fork_copies_the_session_into_a_new_file() { /// `--fork` is the cross-project path: another project's session forks /// into the CURRENT cwd (the TS GLOBAL arm); `--resume` refuses it. +#[pa_test_scratch::pa_test] #[test] fn print_mode_fork_imports_a_global_session_into_this_cwd() { let home = isolated_home(); @@ -1091,6 +1115,7 @@ fn print_mode_fork_imports_a_global_session_into_this_cwd() { /// TS `forkFrom`'s failure contract: an empty source file errors with the /// TS message, and `--fork` still refuses its conflicting flags. +#[pa_test_scratch::pa_test] #[test] fn print_mode_fork_rejects_empty_sources_and_conflicting_flags() { let home = isolated_home(); diff --git a/crates/pa-cli/tests/refresh_models_e2e.rs b/crates/pa-cli/tests/refresh_models_e2e.rs index f2f68aeb3..ba9afb93c 100644 --- a/crates/pa-cli/tests/refresh_models_e2e.rs +++ b/crates/pa-cli/tests/refresh_models_e2e.rs @@ -48,6 +48,7 @@ fn text(output: &Output) -> String { ) } +#[pa_test_scratch::pa_test] #[test] fn refresh_offline_without_a_daemon_does_not_create_a_socket_or_session() { let dir = tempfile::TempDir::new().unwrap(); @@ -67,6 +68,7 @@ fn refresh_offline_without_a_daemon_does_not_create_a_socket_or_session() { assert!(!dir.path().join("agent/sessions").exists()); } +#[pa_test_scratch::pa_test] #[test] fn explicit_offline_refresh_never_contacts_a_resident_daemon() { let dir = tempfile::TempDir::new().unwrap(); @@ -90,6 +92,7 @@ fn explicit_offline_refresh_never_contacts_a_resident_daemon() { ); } +#[pa_test_scratch::pa_test] #[test] fn refresh_rejects_session_prompt_and_command_options_before_any_launch() { let dir = tempfile::TempDir::new().unwrap(); @@ -147,6 +150,7 @@ fn mock_refresh(revision: u64, capability: bool, response: Value) -> (Output, Ve (output, requests) } +#[pa_test_scratch::pa_test] #[test] fn compatible_resident_daemon_refreshes_once_and_prints_sanitized_fields() { let (output, requests) = mock_refresh( @@ -168,6 +172,7 @@ fn compatible_resident_daemon_refreshes_once_and_prints_sanitized_fields() { assert_eq!(requests[0]["type"], "refresh_all_models"); } +#[pa_test_scratch::pa_test] #[test] fn old_or_unadvertised_daemons_fall_back_without_sending_a_refresh() { for (revision, capability) in [(31, true), (32, false)] { @@ -178,6 +183,7 @@ fn old_or_unadvertised_daemons_fall_back_without_sending_a_refresh() { } } +#[pa_test_scratch::pa_test] #[test] fn remote_failure_does_not_fall_back_or_expose_daemon_error_text() { let (output, requests) = mock_refresh( @@ -193,6 +199,7 @@ fn remote_failure_does_not_fall_back_or_expose_daemon_error_text() { assert_eq!(requests.len(), 1); } +#[pa_test_scratch::pa_test] #[test] fn zero_resident_workers_uses_the_standalone_registry() { let (output, requests) = mock_refresh( @@ -209,6 +216,7 @@ fn zero_resident_workers_uses_the_standalone_registry() { assert_eq!(requests.len(), 1); } +#[pa_test_scratch::pa_test] #[test] fn stale_network_and_worker_failures_exit_nonzero_but_offline_stale_does_not() { for (status, reason, failed, exit) in [ @@ -231,6 +239,7 @@ fn stale_network_and_worker_failures_exit_nonzero_but_offline_stale_does_not() { } #[cfg(target_os = "linux")] +#[pa_test_scratch::pa_test] #[test] fn a_saturated_resident_backlog_cannot_hold_the_one_shot_open() { use std::os::fd::AsRawFd; diff --git a/crates/pa-cli/tests/release_workflow.rs b/crates/pa-cli/tests/release_workflow.rs index 03b916599..d82727fb1 100644 --- a/crates/pa-cli/tests/release_workflow.rs +++ b/crates/pa-cli/tests/release_workflow.rs @@ -430,6 +430,7 @@ fn run_promote_gates(cwd: &Path, steps: &[Step]) -> (String, serde_json::Value) /// Native release jobs must exercise the current channel installer as well /// as the retained TypeScript updater before their artifacts reach promotion. +#[pa_test_scratch::pa_test] #[test] fn native_release_jobs_gate_fresh_and_legacy_installation() { let text = fs::read_to_string(repo_root().join(".github/upstream-workflows/release.yml")) @@ -465,6 +466,7 @@ fn native_release_jobs_gate_fresh_and_legacy_installation() { /// its own runner (never inside build-gnu's linux container), the livecheck /// names the `.exe` binary, promote needs the job, and the channel /// completeness gate refuses a manifest that dropped a platform row. +#[pa_test_scratch::pa_test] #[test] fn windows_build_job_contract() { let text = fs::read_to_string(repo_root().join(".github/upstream-workflows/release.yml")) @@ -550,6 +552,7 @@ fn windows_build_job_contract() { /// The operator hit exactly that on a real box (2026-10-06), so the /// crt-static pin is the build step's own env: only the SHIPPED binary is /// static, and never through Cargo.toml, whose dev builds stay dynamic. +#[pa_test_scratch::pa_test] #[test] fn the_windows_build_links_the_static_vc_runtime() { let text = fs::read_to_string(repo_root().join(".github/upstream-workflows/release.yml")) @@ -611,6 +614,7 @@ fn the_windows_build_links_the_static_vc_runtime() { /// The structural gate: one count-independent download-all step, pinned to /// `incoming`, followed by the normalize step before the per-artifact gates. +#[pa_test_scratch::pa_test] #[test] fn promote_download_layout_contract() { let steps = promote_steps(); @@ -680,6 +684,7 @@ fn promote_download_layout_contract() { /// The promote gate accepts a usable historical installer layout and rejects /// an archive missing a required asset before any release is published. +#[pa_test_scratch::pa_test] #[test] fn historical_native_updater_gate_requires_the_compatibility_assets() { let Some(_python3) = python3_binary((3, 9)) else { @@ -712,6 +717,7 @@ fn historical_native_updater_gate_requires_the_compatibility_assets() { /// A one-target release: the single artifact lands flat in `incoming/` and /// the gates must still verify its hashes and attach a manifest. +#[pa_test_scratch::pa_test] #[test] fn single_artifact_release_finds_the_downloaded_manifest() { let Some(_python3) = python3_binary((3, 12)) else { @@ -758,6 +764,7 @@ fn single_artifact_release_finds_the_downloaded_manifest() { /// carry all five binaries (the Windows row included), and every /// platform's payload unpacks under its target triple with the staged /// binary name (`prime-agent.exe` on the MSVC target). +#[pa_test_scratch::pa_test] #[test] fn five_target_release_finds_all_downloaded_manifests() { let Some(_python3) = python3_binary((3, 12)) else { @@ -806,6 +813,7 @@ fn five_target_release_finds_all_downloaded_manifests() { } /// A release whose artifacts never arrived must fail loudly at the normalize gate. +#[pa_test_scratch::pa_test] #[test] fn zero_artifacts_fail_loudly_instead_of_verifying_nothing() { let Some(_python3) = python3_binary((3, 0)) else { @@ -831,6 +839,7 @@ fn zero_artifacts_fail_loudly_instead_of_verifying_nothing() { /// Production installer updates require a stable release on both platforms; /// beta releases publish only the explicitly selected beta installer pair. +#[pa_test_scratch::pa_test] #[test] fn production_installers_are_published_only_by_stable_releases() { let text = fs::read_to_string(repo_root().join(".github/upstream-workflows/release.yml")) @@ -890,6 +899,7 @@ fn production_installers_are_published_only_by_stable_releases() { /// first Rust stable cut re-publishes latest.json; this pins the /// emission's half of that contract — when that cut lands, the stable /// manifest carries the Windows row under `binaries_v2`. +#[pa_test_scratch::pa_test] #[test] fn the_channel_manifest_carries_the_windows_row_on_both_channels() { let Some(_python3) = python3_binary((3, 12)) else { @@ -1041,6 +1051,7 @@ fn the_channel_manifest_carries_the_windows_row_on_both_channels() { /// the completeness gate refuses the release and names the missing /// platform — a Windows install stranded on the old channel version is /// worse than a failed cut. +#[pa_test_scratch::pa_test] #[test] fn the_channel_manifest_refuses_a_release_missing_the_windows_row() { let Some(_python3) = python3_binary((3, 12)) else { diff --git a/crates/pa-cli/tests/rpc_mode_e2e.rs b/crates/pa-cli/tests/rpc_mode_e2e.rs index 680638395..fc085660f 100644 --- a/crates/pa-cli/tests/rpc_mode_e2e.rs +++ b/crates/pa-cli/tests/rpc_mode_e2e.rs @@ -204,6 +204,7 @@ fn turn_script(steps: &Value) -> Value { json!({ "responses": steps }) } +#[pa_test_scratch::pa_test] #[test] fn rpc_get_state_answers_the_fresh_session() { let mut client = RpcChild::spawn( @@ -234,6 +235,7 @@ fn rpc_get_state_answers_the_fresh_session() { } /// The prompt response precedes the turn's stream events (TS `promptResponsePending` buffering). +#[pa_test_scratch::pa_test] #[test] fn rpc_prompt_streams_events_after_the_response() { let mut client = RpcChild::spawn( @@ -271,6 +273,7 @@ fn rpc_prompt_streams_events_after_the_response() { client.drain_stderr(); } +#[pa_test_scratch::pa_test] #[test] fn rpc_parse_and_unknown_command_errors() { let mut client = RpcChild::spawn( @@ -315,6 +318,7 @@ fn rpc_parse_and_unknown_command_errors() { /// Steer and follow-up queue behind a running turn; abort parks them; the next /// prompt's run folds the steer and delivers the follow-up (TS `runLoop`). +#[pa_test_scratch::pa_test] #[test] fn rpc_steer_and_follow_up_queue_then_abort() { let script = json!({ @@ -404,6 +408,7 @@ fn rpc_steer_and_follow_up_queue_then_abort() { client.drain_stderr(); } +#[pa_test_scratch::pa_test] #[test] fn rpc_thinking_level_set_and_cycle() { let script = json!({ "responses": ["unused"], "reasoning": true }); @@ -443,6 +448,7 @@ fn rpc_thinking_level_set_and_cycle() { client.drain_stderr(); } +#[pa_test_scratch::pa_test] #[test] fn rpc_compact_answers_the_ts_skip_error() { let mut client = RpcChild::spawn( @@ -473,6 +479,7 @@ fn rpc_compact_answers_the_ts_skip_error() { client.drain_stderr(); } +#[pa_test_scratch::pa_test] #[test] fn rpc_daemon_mode_families_answer_the_ts_inprocess_semantics() { let mut client = RpcChild::spawn( @@ -509,6 +516,7 @@ fn rpc_daemon_mode_families_answer_the_ts_inprocess_semantics() { client.drain_stderr(); } +#[pa_test_scratch::pa_test] #[test] fn rpc_set_session_name_round_trip() { let mut client = RpcChild::spawn( @@ -534,6 +542,7 @@ fn rpc_set_session_name_round_trip() { } /// `fork` branches at the entry's parent leaf and moves the connection onto the fork's file. +#[pa_test_scratch::pa_test] #[test] fn rpc_fork_messages_and_fork_swap() { let script = turn_script(&json!(["one", "two"])); @@ -573,6 +582,7 @@ fn rpc_fork_messages_and_fork_swap() { client.drain_stderr(); } +#[pa_test_scratch::pa_test] #[test] fn rpc_new_session_swaps_the_engine() { let script = turn_script(&json!(["one", "unused"])); @@ -592,6 +602,7 @@ fn rpc_new_session_swaps_the_engine() { client.drain_stderr(); } +#[pa_test_scratch::pa_test] #[test] fn rpc_get_available_models_lists_the_catalog() { let mut client = RpcChild::spawn_seeded( @@ -623,6 +634,7 @@ fn rpc_get_available_models_lists_the_catalog() { client.drain_stderr(); } +#[pa_test_scratch::pa_test] #[test] fn rpc_eof_settles_and_exits_zero() { let script = json!({ @@ -647,6 +659,7 @@ fn rpc_eof_settles_and_exits_zero() { client.spawn_stderr = None; } +#[pa_test_scratch::pa_test] #[test] fn rpc_get_session_stats_answers_the_ts_shape() { let script = turn_script(&json!(["one"])); @@ -670,6 +683,7 @@ fn rpc_get_session_stats_answers_the_ts_shape() { } /// Regression test: `--mode rpc` must never print the missing-subsystem stub. +#[pa_test_scratch::pa_test] #[test] fn rpc_mode_never_prints_the_missing_subsystem_stub() { let mut client = RpcChild::spawn( @@ -689,6 +703,7 @@ fn rpc_mode_never_prints_the_missing_subsystem_stub() { } /// A fresh persisted session leases its file before the engine can write it. +#[pa_test_scratch::pa_test] #[test] fn rpc_fresh_sessions_lease_their_files() { let mut client = RpcChild::spawn(&["--mode", "rpc"], &turn_script(&json!(["one"]))); @@ -724,6 +739,7 @@ fn rpc_fresh_sessions_lease_their_files() { } /// The `--fork` copy leases its materialized file before the engine writes it. +#[pa_test_scratch::pa_test] #[test] fn rpc_fork_leases_the_materialized_file() { let mut source = RpcChild::spawn(&["--mode", "rpc"], &turn_script(&json!(["one"]))); @@ -778,6 +794,7 @@ fn rpc_fork_leases_the_materialized_file() { } /// A FAILED whole-session replacement never strands the queued work: the post-turn fold drains it. +#[pa_test_scratch::pa_test] #[test] fn rpc_failed_replacement_restarts_the_queue_pump() { let script = json!({ "responses": [ @@ -870,6 +887,7 @@ fn rpc_failed_replacement_restarts_the_queue_pump() { } /// The 143 exit must not queue behind the replacement's settle. +#[pa_test_scratch::pa_test] #[test] fn rpc_sigterm_during_replacement_exits_promptly() { let script = json!({ "responses": [ { "text": "slow", "delayMs": 30_000 } ] }); @@ -1087,6 +1105,7 @@ fn write_corpus_fixture(path: &std::path::Path, size_mib: usize) { } } +#[pa_test_scratch::pa_test] #[test] fn corpus_fixture_has_a_null_root_and_preserves_every_nonroot_parent() { let dir = tempfile::tempdir().unwrap(); @@ -1257,11 +1276,13 @@ impl Drop for TimedRpcChild { /// The `compaction_start` frame must reach the client BEFORE the pipeline runs: /// the pre-summarizer CPU span runs without a yield, so without the flush the /// frame strands (TS writes stdout synchronously at the emit: the flush is parity). +#[pa_test_scratch::pa_test] #[test] fn rpc_compact_flushes_the_start_frame_before_the_pipeline() { case_rpc_compact_flushes_the_start_frame_before_the_pipeline(10); } +#[pa_test_scratch::pa_test] #[test] fn rpc_compact_flushes_the_start_frame_before_the_pipeline_32m() { case_rpc_compact_flushes_the_start_frame_before_the_pipeline(32); @@ -1338,11 +1359,13 @@ fn case_rpc_compact_flushes_the_start_frame_before_the_pipeline(size_mib: usize) /// The flush is bounded against a stalled reader: with the pipe full the writer /// blocks mid-write and the compaction must still complete. +#[pa_test_scratch::pa_test] #[test] fn rpc_compact_flush_is_bounded_against_a_stalled_reader() { case_rpc_compact_flush_is_bounded_against_a_stalled_reader(10); } +#[pa_test_scratch::pa_test] #[test] fn rpc_compact_flush_is_bounded_against_a_stalled_reader_32m() { case_rpc_compact_flush_is_bounded_against_a_stalled_reader(32); @@ -1401,11 +1424,13 @@ fn case_rpc_compact_flush_is_bounded_against_a_stalled_reader(size_mib: usize) { /// The prompt-admitted `/compact`'s frames ride the prompt-response buffer (TS /// `promptResponsePending`) and publish AFTER the response. +#[pa_test_scratch::pa_test] #[test] fn rpc_prompt_admitted_compact_frames_flush_after_the_response() { case_rpc_prompt_admitted_compact_frames_flush_after_the_response(10); } +#[pa_test_scratch::pa_test] #[test] fn rpc_prompt_admitted_compact_frames_flush_after_the_response_32m() { case_rpc_prompt_admitted_compact_frames_flush_after_the_response(32); diff --git a/crates/pa-cli/tests/settings_mcp_save.rs b/crates/pa-cli/tests/settings_mcp_save.rs index 1977f4afc..a1199e8e1 100644 --- a/crates/pa-cli/tests/settings_mcp_save.rs +++ b/crates/pa-cli/tests/settings_mcp_save.rs @@ -4,6 +4,7 @@ use pa_test_scratch::Command; use pa_core::settings::SettingsManager; use serde_json::{json, Value}; +#[pa_test_scratch::pa_test] #[test] fn first_mcp_server_can_be_added_after_chat_detail_save_or_legacy_null() { for legacy_null in [false, true] { @@ -40,6 +41,7 @@ fn first_mcp_server_can_be_added_after_chat_detail_save_or_legacy_null() { } } +#[pa_test_scratch::pa_test] #[test] fn mcp_registration_preserves_invalid_documents_and_non_null_maps() { for content in ["{bad", "[]", r#"{"mcpServers":[],"theme":"light"}"#] { diff --git a/crates/pa-cli/tests/slow_drain_exit_guard_e2e.rs b/crates/pa-cli/tests/slow_drain_exit_guard_e2e.rs index ca9692685..2e22d5f3b 100644 --- a/crates/pa-cli/tests/slow_drain_exit_guard_e2e.rs +++ b/crates/pa-cli/tests/slow_drain_exit_guard_e2e.rs @@ -58,6 +58,7 @@ const LAST_ROW: &[u8] = b"row 1599"; /// The dock's exit-hint row, rendered after every transcript row. const EXIT_HINT_ROW: &[u8] = b"Press Ctrl+C again to exit"; +#[pa_test_scratch::pa_test] #[test] fn slow_drain_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -85,6 +86,7 @@ fn slow_drain_child_mode() { /// The pty harnesses serialize: concurrent byte-level waits flake on the shared test CPUs. static HARNESS_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); +#[pa_test_scratch::pa_test] #[test] fn a_slow_drain_flushes_the_whole_transcript_without_forcing_the_exit() { let _lock = match HARNESS_LOCK.lock() { @@ -155,6 +157,7 @@ fn a_slow_drain_flushes_the_whole_transcript_without_forcing_the_exit() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_stalled_drain_still_fires_the_force_quit() { let _lock = match HARNESS_LOCK.lock() { diff --git a/crates/pa-cli/tests/subagent_panel_nav_e2e.rs b/crates/pa-cli/tests/subagent_panel_nav_e2e.rs index bc10f5068..78d7381d5 100644 --- a/crates/pa-cli/tests/subagent_panel_nav_e2e.rs +++ b/crates/pa-cli/tests/subagent_panel_nav_e2e.rs @@ -262,6 +262,7 @@ fn session_options( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn down_arrow_focuses_the_dock_and_enter_opens_the_scoped_agents_view() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -447,6 +448,7 @@ async fn down_arrow_focuses_the_dock_and_enter_opens_the_scoped_agents_view() { /// The attached parent's top bar bills the ledger-seeded passive child's /// spend: the parent's own $1.00 plus the child's $0.30. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_title_bills_a_passive_subagents_spend() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -532,6 +534,7 @@ async fn the_title_bills_a_passive_subagents_spend() { /// the top bar; the agents-view row reads the same row through the same /// `compute_rollups`, so it bills the same number. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_title_bills_a_deleted_subagents_spend() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-cli/tests/subagent_panel_nested_count_e2e.rs b/crates/pa-cli/tests/subagent_panel_nested_count_e2e.rs index bdd3e9ea9..21c02b7f4 100644 --- a/crates/pa-cli/tests/subagent_panel_nested_count_e2e.rs +++ b/crates/pa-cli/tests/subagent_panel_nested_count_e2e.rs @@ -265,6 +265,7 @@ fn entry_parent_keys(entry: &Value) -> Vec { /// every count surface reports the whole subtree: the summary-box walk /// counts two descendants from the root (one from the child). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_two_level_spawn_counts_the_whole_tree() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-cli/tests/suspend_signal_e2e.rs b/crates/pa-cli/tests/suspend_signal_e2e.rs index 5b4f7ca7f..692616a9a 100644 --- a/crates/pa-cli/tests/suspend_signal_e2e.rs +++ b/crates/pa-cli/tests/suspend_signal_e2e.rs @@ -65,6 +65,7 @@ fn wire_log_dump() -> String { } /// The child half: the real interactive loop against the parent's mock supervisor. +#[pa_test_scratch::pa_test] #[test] fn suspend_child_mode() { let Ok(socket) = std::env::var(CHILD_SOCKET_ENV) else { @@ -111,6 +112,7 @@ fn lead_fresh_session() -> bool { }) } +#[pa_test_scratch::pa_test] #[test] fn ctrl_z_releases_tracking_stops_and_sigcont_re_applies() { if !lead_fresh_session() { @@ -178,6 +180,7 @@ fn ctrl_z_releases_tracking_stops_and_sigcont_re_applies() { /// Real-tty e2e for `app.editor.external` (TS `openExternalEditor`): ctrl+g hands the /// terminal to `$VISUAL`; the resumed surface strips one trailing newline. +#[pa_test_scratch::pa_test] #[test] fn ctrl_g_hands_the_terminal_to_the_external_editor() { use std::os::unix::fs::PermissionsExt; diff --git a/crates/pa-cli/tests/terminal_state_differential_e2e/ledger.rs b/crates/pa-cli/tests/terminal_state_differential_e2e/ledger.rs index 075a6427b..1959d1d5a 100644 --- a/crates/pa-cli/tests/terminal_state_differential_e2e/ledger.rs +++ b/crates/pa-cli/tests/terminal_state_differential_e2e/ledger.rs @@ -502,6 +502,7 @@ fn findings_of(stream: &[u8]) -> Vec { ledger.leaks() } +#[pa_test_scratch::pa_test] #[test] fn the_ledger_passes_the_balanced_restore() { // The exact write set of a whole mount/exit session: every mode armed @@ -520,6 +521,7 @@ fn the_ledger_passes_the_balanced_restore() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_ledger_catches_a_leaked_mouse_mode() { let stream = b"\x1b[?1002h\x1b[?1003h\x1b[?1006h"; @@ -530,6 +532,7 @@ fn the_ledger_catches_a_leaked_mouse_mode() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_ledger_catches_an_unknown_leaked_mode() { // A mode the product never writes: the net must catch it anyway. @@ -540,6 +543,7 @@ fn the_ledger_catches_an_unknown_leaked_mode() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_ledger_catches_a_default_on_mode_left_off() { // Cursor visibility's default is ON: hide and never show again = deviating. @@ -554,6 +558,7 @@ fn the_ledger_catches_a_default_on_mode_left_off() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_ledger_catches_a_kitty_re_arm_after_the_pop() { // A push after the final pop: the re-arm leak shape. @@ -565,6 +570,7 @@ fn the_ledger_catches_a_kitty_re_arm_after_the_pop() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_ledger_catches_a_dangling_sgr() { // A styled write with no reset: the shell paints in the color. @@ -575,6 +581,7 @@ fn the_ledger_catches_a_dangling_sgr() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_ledger_catches_a_dangling_hyperlink() { let findings = findings_of(b"\x1b]8;;https://example.com\x1b\\link"); @@ -584,6 +591,7 @@ fn the_ledger_catches_a_dangling_hyperlink() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_ledger_catches_forbidden_writes() { let findings = findings_of(b"\x1b=\x1b[2 q\x1b]0;title\x07"); @@ -601,6 +609,7 @@ fn the_ledger_catches_forbidden_writes() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_ledger_catches_an_absolute_kitty_set_left_on() { let findings = findings_of(b"\x1b[=5u"); @@ -613,6 +622,7 @@ fn the_ledger_catches_an_absolute_kitty_set_left_on() { /// The extended-color forms are one attribute, not a code walk: `38;5;N` /// arms no phantom blink (5) or bold (1), and a zero channel inside /// `38;2;R;G;B` is a color component, never a reset. +#[pa_test_scratch::pa_test] #[test] fn the_ledger_reads_extended_color_forms_as_one_attribute() { // The balanced pair: the extended color sets fg, the 39 clears it. @@ -630,6 +640,7 @@ fn the_ledger_reads_extended_color_forms_as_one_attribute() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_ledger_catches_modify_other_keys_left_armed() { let findings = findings_of(b"\x1b[>4;2m"); diff --git a/crates/pa-cli/tests/terminal_state_differential_e2e/main.rs b/crates/pa-cli/tests/terminal_state_differential_e2e/main.rs index 56f26472f..6791df7fb 100644 --- a/crates/pa-cli/tests/terminal_state_differential_e2e/main.rs +++ b/crates/pa-cli/tests/terminal_state_differential_e2e/main.rs @@ -72,6 +72,7 @@ const CHILD_TERM: &str = "xterm-256color"; /// then the agents view when the exit came through agents-back /// (`return_to_agents_view`). A roster-link failure returns quietly: the /// error path's restore still ran. +#[pa_test_scratch::pa_test] #[test] fn diff_chat_child_mode() { let Some(socket) = std::env::var(CHILD_SOCKET_ENV).ok() else { @@ -104,6 +105,7 @@ fn diff_chat_child_mode() { /// The agents-view child: a fresh roster-surface run. A roster-link failure /// returns quietly (the error-route restore still ran). +#[pa_test_scratch::pa_test] #[test] fn diff_view_child_mode() { let Some(socket) = std::env::var(CHILD_SOCKET_ENV).ok() else { @@ -129,6 +131,7 @@ fn diff_view_child_mode() { /// The picker child: the config-selector surface over a fixed row set; the /// flags arm the error and exit variants. +#[pa_test_scratch::pa_test] #[test] fn diff_selector_child_mode() { if std::env::var(CHILD_MODE_ENV).ok().as_deref() != Some("selector") { @@ -170,6 +173,7 @@ fn diff_selector_child_mode() { /// The replay child: the replay surface over a harness-written fixture; the /// `panic` flag runs the panic driver (a real unwind). +#[pa_test_scratch::pa_test] #[test] fn diff_replay_child_mode() { let Some(fixture) = std::env::var(CHILD_FIXTURE_ENV).ok() else { @@ -223,6 +227,7 @@ fn write_replay_fixture() -> String { } /// Route: the parity exit through the `/exit` slash command. +#[pa_test_scratch::pa_test] #[test] fn parity_exit_through_slash_command_restores_every_mode() { let _lock = harness_lock(); @@ -247,6 +252,7 @@ fn parity_exit_through_slash_command_restores_every_mode() { harness.assert_terminal_state_restored("the parity exit (/exit)"); } +#[pa_test_scratch::pa_test] #[test] fn parity_exit_through_the_ctrl_c_pair_restores_every_mode() { let _lock = harness_lock(); @@ -272,6 +278,7 @@ fn parity_exit_through_the_ctrl_c_pair_restores_every_mode() { /// Route: the detach handoff to the agents view — the pane hands to a second /// surface of the same process (alt screen and raw mode stay by design), and /// the VIEW's exit then releases everything. +#[pa_test_scratch::pa_test] #[test] fn the_detach_handoff_then_the_view_exit_restores_every_mode() { let _lock = harness_lock(); @@ -305,6 +312,7 @@ fn the_detach_handoff_then_the_view_exit_restores_every_mode() { /// Route: the force-quit watchdog from a wedged loop: the mock stalls the /// `/list` request, the loop wedges, the Ctrl+C pair arms the watchdog, and /// its own byte order must hand the terminal back whole. +#[pa_test_scratch::pa_test] #[test] fn the_force_quit_watchdog_restores_every_mode() { let _lock = harness_lock(); @@ -330,6 +338,7 @@ fn the_force_quit_watchdog_restores_every_mode() { harness.assert_terminal_state_restored("the force-quit watchdog"); } +#[pa_test_scratch::pa_test] #[test] fn the_agents_view_fresh_exit_restores_every_mode() { let _lock = harness_lock(); @@ -358,6 +367,7 @@ fn the_agents_view_fresh_exit_restores_every_mode() { /// roster link fails while the pane is in TUI state, so the surface's own /// release must hand the terminal back before the error escapes (TS /// `returnToAgentsView`'s `finally`). +#[pa_test_scratch::pa_test] #[test] fn the_agents_view_roster_failure_behind_a_handoff_restores_every_mode() { let _lock = harness_lock(); @@ -380,6 +390,7 @@ fn the_agents_view_roster_failure_behind_a_handoff_restores_every_mode() { harness.assert_terminal_state_restored("the agents view's roster failure behind a handoff"); } +#[pa_test_scratch::pa_test] #[test] fn the_config_selector_esc_close_restores_every_mode() { let _lock = harness_lock(); @@ -400,6 +411,7 @@ fn the_config_selector_esc_close_restores_every_mode() { harness.assert_terminal_state_restored("the config selector's Esc close"); } +#[pa_test_scratch::pa_test] #[test] fn the_config_selector_remapped_exit_action_restores_every_mode() { let _lock = harness_lock(); @@ -426,6 +438,7 @@ fn the_config_selector_remapped_exit_action_restores_every_mode() { harness.assert_terminal_state_restored("the config selector's remapped exit action"); } +#[pa_test_scratch::pa_test] #[test] fn the_config_selector_toggle_error_restores_every_mode() { let _lock = harness_lock(); @@ -448,6 +461,7 @@ fn the_config_selector_toggle_error_restores_every_mode() { harness.assert_terminal_state_restored("the config selector's toggle error"); } +#[pa_test_scratch::pa_test] #[test] fn the_replay_surface_clean_exit_restores_every_mode() { let _lock = harness_lock(); @@ -473,6 +487,7 @@ fn the_replay_surface_clean_exit_restores_every_mode() { /// Route: the panic unwind: the panic driver panics mid-loop after the first /// paint; the unwind crosses the guard, the exit restore runs, and the /// process dies with the terminal whole. +#[pa_test_scratch::pa_test] #[test] fn the_panic_unwind_restores_every_mode() { let _lock = harness_lock(); @@ -503,6 +518,7 @@ fn the_panic_unwind_restores_every_mode() { /// Route: the pre-mount daemon refusal: the run errors BEFORE any /// terminal state is armed, so the error path must restore NOTHING. +#[pa_test_scratch::pa_test] #[test] fn the_pre_mount_daemon_refusal_arms_nothing() { let _lock = harness_lock(); @@ -624,6 +640,7 @@ fn wait_for_stopped(pid: u32, what: &str) { /// Route: the suspend cycle (ctrl+z). The shell gets the terminal /// MID-PROCESS, so the differential asserts twice: at the stop point and /// at the resumed session's final exit. +#[pa_test_scratch::pa_test] #[test] fn the_suspend_cycle_hands_a_whole_terminal_to_the_shell_and_back() { if !sigtstp_session_runner() || !sigtstp_stops_processes() { @@ -689,6 +706,7 @@ fn the_suspend_cycle_hands_a_whole_terminal_to_the_shell_and_back() { /// Route: the late kitty answer: the probe's query goes unanswered /// through the mount, and the answer bytes land INSIDE the exit window. /// Whatever path takes the answer, the stream must carry NO kitty flags push after the exit began. +#[pa_test_scratch::pa_test] #[test] fn the_late_kitty_answer_inside_the_exit_window_is_stood_down() { let _lock = harness_lock(); diff --git a/crates/pa-cli/tests/termios_process_exit_e2e.rs b/crates/pa-cli/tests/termios_process_exit_e2e.rs index 51018c233..77a21c647 100644 --- a/crates/pa-cli/tests/termios_process_exit_e2e.rs +++ b/crates/pa-cli/tests/termios_process_exit_e2e.rs @@ -66,6 +66,7 @@ const PREMOUNT_MARKER: &[u8] = b"termios-premount-gate\r\n"; /// The chat child: the real interactive surface against the mock /// supervisor (a plain run passes trivially). +#[pa_test_scratch::pa_test] #[test] fn diff_chat_child_mode() { let Some(socket) = std::env::var(CHILD_SOCKET_ENV).ok() else { @@ -98,6 +99,7 @@ fn diff_chat_child_mode() { } /// The view child: the agents-view roster surface, closed by the caller. +#[pa_test_scratch::pa_test] #[test] fn diff_view_child_mode() { let Some(socket) = std::env::var(CHILD_SOCKET_ENV).ok() else { @@ -197,6 +199,7 @@ fn assert_the_handback_is_whole(harness: &mut DifferentialHarness, context: &str /// Route: the full chat session -> `/exit`: the mid-session Ctrl+S lands /// in a raw window (IXON off), and the exit must flow anyway. +#[pa_test_scratch::pa_test] #[test] fn a_full_session_with_a_mid_session_ctrl_s_exits_whole() { let _lock = harness::harness_lock(); @@ -231,6 +234,7 @@ fn a_full_session_with_a_mid_session_ctrl_s_exits_whole() { /// Route: the launch on a Ctrl+S-STOPPED tty: the gate holds the child in /// the cooked window while the harness arms the stop, and the mount must /// lift it (`cfmakeraw`'s IXON clearing). +#[pa_test_scratch::pa_test] #[test] fn a_launch_on_a_ctrl_s_stopped_tty_flows_and_exits_whole() { let _lock = harness::harness_lock(); @@ -287,6 +291,7 @@ fn a_launch_on_a_ctrl_s_stopped_tty_flows_and_exits_whole() { } /// Route: the agents-view exit (breadth over the second surface). +#[pa_test_scratch::pa_test] #[test] fn the_agents_view_exit_exits_whole() { let _lock = harness::harness_lock(); @@ -494,6 +499,7 @@ fn wait_for_exit(child: &mut Child, what: &str) { /// window — the exact state the flow-control fix targets: Ctrl+Z stops the /// group, a Ctrl+S stops the tty (IXON restored), the `fg` resume must /// restart output, and the exit hands back a FLOWING tty. +#[pa_test_scratch::pa_test] #[test] fn a_suspend_cycle_with_a_ctrl_s_in_the_stopped_window_never_stops_the_shell() { if !stop_capable_runner() { diff --git a/crates/pa-cli/tests/tool_error_status.rs b/crates/pa-cli/tests/tool_error_status.rs index bd6303b34..be052781b 100644 --- a/crates/pa-cli/tests/tool_error_status.rs +++ b/crates/pa-cli/tests/tool_error_status.rs @@ -321,11 +321,13 @@ async fn assert_persisted_status(is_error: bool) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn error_flag_survives_rich_result_to_provider_sdk_events_and_disk() { assert_persisted_status(/*is_error*/ true).await; } #[tokio::test] +#[pa_test_scratch::pa_test] async fn success_flag_ignores_error_strings_in_details_through_all_boundaries() { assert_persisted_status(/*is_error*/ false).await; } diff --git a/crates/pa-cli/tests/view_switch_latency_e2e.rs b/crates/pa-cli/tests/view_switch_latency_e2e.rs index e1df1a379..4683cee7b 100644 --- a/crates/pa-cli/tests/view_switch_latency_e2e.rs +++ b/crates/pa-cli/tests/view_switch_latency_e2e.rs @@ -271,6 +271,7 @@ fn chat_options( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn agents_view_round_trip_reattaches_under_the_ceiling() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-cli/tests/windows_runtime_triage_e2e.rs b/crates/pa-cli/tests/windows_runtime_triage_e2e.rs index e51fd7531..120c4fbf4 100644 --- a/crates/pa-cli/tests/windows_runtime_triage_e2e.rs +++ b/crates/pa-cli/tests/windows_runtime_triage_e2e.rs @@ -379,6 +379,7 @@ fn the_session_file(session_dir: &Path) -> (PathBuf, String) { /// path - no live worker holds the history); a fresh daemon boots against /// the same store; the reopened session must render the OLD messages. #[tokio::test] +#[pa_test_scratch::pa_test] async fn tui_reopen_renders_the_old_history() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -487,6 +488,7 @@ async fn tui_reopen_renders_the_old_history() { /// view nests it under the parent instead of merging everything into one /// session row. #[tokio::test] +#[pa_test_scratch::pa_test] async fn subagent_session_stays_a_distinct_store_entry() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -646,6 +648,7 @@ async fn subagent_session_stays_a_distinct_store_entry() { /// Scenario (3): preserve non-ASCII user/assistant text in headless frames. /// This renderer regression does not exercise console, font or `ConPTY` I/O. #[tokio::test] +#[pa_test_scratch::pa_test] async fn agent_message_rows_dump_their_glyphs() { let dir = tempfile::TempDir::new().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-cli/tests/windows_runtime_triage_workflow.rs b/crates/pa-cli/tests/windows_runtime_triage_workflow.rs index 1c3c558fa..816ca1544 100644 --- a/crates/pa-cli/tests/windows_runtime_triage_workflow.rs +++ b/crates/pa-cli/tests/windows_runtime_triage_workflow.rs @@ -94,6 +94,7 @@ const SCENARIO_TESTS: [&str; 3] = [ "agent_message_rows_dump_their_glyphs", ]; +#[pa_test_scratch::pa_test] #[test] fn the_battery_source_defines_the_three_scenarios() { let battery = @@ -111,6 +112,7 @@ fn the_battery_source_defines_the_three_scenarios() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_pr_wave_runs_on_windows_touched_paths() { let (_, triggers) = workflow_yaml(); @@ -148,6 +150,7 @@ fn the_pr_wave_runs_on_windows_touched_paths() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_nightly_wave_runs_on_main() { let (_, triggers) = workflow_yaml(); @@ -161,6 +164,7 @@ fn the_nightly_wave_runs_on_main() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_dispatch_loop_stays_available() { let (_, triggers) = workflow_yaml(); @@ -170,6 +174,7 @@ fn the_dispatch_loop_stays_available() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_tui_battery_job_boots_the_binary_and_dumps_the_panes() { let (workflow, _) = workflow_yaml(); @@ -292,6 +297,7 @@ fn the_tui_battery_job_boots_the_binary_and_dumps_the_panes() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_deep_battery_stays_off_the_pr_wave() { let (workflow, _) = workflow_yaml(); diff --git a/crates/pa-core/tests/abort_kernel_cell.rs b/crates/pa-core/tests/abort_kernel_cell.rs index ebf540add..287785e59 100644 --- a/crates/pa-core/tests/abort_kernel_cell.rs +++ b/crates/pa-core/tests/abort_kernel_cell.rs @@ -114,6 +114,7 @@ fn scripted_model() -> pa_agent::types::Model { /// The abort budget is generous for CI but far below the cell's 120s /// sleep: a wedge waits the sleep out (or forever). #[tokio::test] +#[pa_test_scratch::pa_test] async fn abort_during_a_kernel_cell_settles_the_turn_immediately() { let Some(kernel_python) = kernel_python() else { return; diff --git a/crates/pa-core/tests/auth_refresh_compat.rs b/crates/pa-core/tests/auth_refresh_compat.rs index 5d71acf90..d2d1bb525 100644 --- a/crates/pa-core/tests/auth_refresh_compat.rs +++ b/crates/pa-core/tests/auth_refresh_compat.rs @@ -202,48 +202,57 @@ fn run(mode: &str) { finish(&mut child); } +#[pa_test_scratch::pa_test] #[test] fn native_processes_spend_refresh_once_and_both_receive_fresh_credentials() { run("race"); } +#[pa_test_scratch::pa_test] #[test] fn cooperative_remove_cannot_resurrect_after_held_refresh() { run("remove"); } +#[pa_test_scratch::pa_test] #[test] fn cooperative_replacement_wins_after_held_refresh() { run("replace"); } +#[pa_test_scratch::pa_test] #[test] fn external_removal_during_fetch_is_not_resurrected() { run("external-remove"); } +#[pa_test_scratch::pa_test] #[test] fn external_replacement_during_fetch_is_not_overwritten() { run("external-replace"); } +#[pa_test_scratch::pa_test] #[test] fn manager_refresh_and_team_rebind_preserve_touched_and_unrelated_metadata() { run("metadata"); } +#[pa_test_scratch::pa_test] #[test] #[ignore = "requires explicit PA_TS_PACKAGE_DIR and pinned PA_TEST_NODE; no ambient lookup"] fn typescript_async_lock_is_not_stolen_after_ten_seconds() { run("ts-lock"); } +#[pa_test_scratch::pa_test] #[test] #[ignore = "requires explicit PA_TS_PACKAGE_DIR and pinned PA_TEST_NODE; no ambient lookup"] fn typescript_first_refresh_interoperates_with_rust_process() { run("ts-first"); } +#[pa_test_scratch::pa_test] #[test] #[ignore = "requires explicit PA_TS_PACKAGE_DIR and pinned PA_TEST_NODE; no ambient lookup"] fn rust_first_refresh_interoperates_with_typescript_process() { @@ -616,27 +625,32 @@ fn ts_lock(root: &Path, mode: &str) { ); } +#[pa_test_scratch::pa_test] #[test] #[cfg(unix)] fn symlink_alias_writes_preserve_alias_and_update_real_target() { run("symlink"); } +#[pa_test_scratch::pa_test] #[test] fn callback_error_releases_real_backend_lock() { run("callback-error"); } +#[pa_test_scratch::pa_test] #[test] fn callback_panic_releases_real_backend_lock() { run("callback-panic"); } +#[pa_test_scratch::pa_test] #[test] fn drop_does_not_remove_another_owners_replacement_lock() { run("lock-replacement"); } +#[pa_test_scratch::pa_test] #[test] #[cfg(unix)] #[ignore = "requires explicit PA_TS_PACKAGE_DIR and pinned PA_TEST_NODE; no ambient lookup"] @@ -669,6 +683,7 @@ fn rust_heartbeat(root: &Path) { ); } +#[pa_test_scratch::pa_test] #[test] #[ignore = "requires explicit PA_TS_PACKAGE_DIR and pinned PA_TEST_NODE; no ambient lookup"] fn rust_refresh_heartbeat_prevents_typescript_sync_lock_steal() { @@ -735,16 +750,19 @@ fn nested_team_metadata(root: &Path) { ); } +#[pa_test_scratch::pa_test] #[test] fn sameprocess_regular_writer_refuses_within_one_second_of_held_refresh() { run("sameprocess-timeout"); } +#[pa_test_scratch::pa_test] #[test] fn same_key_preserve_team_keeps_nested_unknown_team_metadata() { run("nested-team-metadata"); } +#[pa_test_scratch::pa_test] #[test] fn coexistence_guard_never_spends_refresh_and_observes_fresh_peer_credentials() { run("coexistence-guard"); @@ -816,6 +834,7 @@ fn coexistence_guard(root: &Path) { ); } +#[pa_test_scratch::pa_test] #[test] fn coexistence_guard_builtin_provider_dispatch_has_zero_transport_io() { run("coexistence-builtin"); @@ -879,6 +898,7 @@ fn coexistence_builtin() { ); } +#[pa_test_scratch::pa_test] #[test] fn auth_refresh_compat_child() { let Ok(mode) = std::env::var("PA_AUTH_COMPAT_MODE") else { diff --git a/crates/pa-core/tests/compaction_transport.rs b/crates/pa-core/tests/compaction_transport.rs index 5b5ec4cc6..116b2ac48 100644 --- a/crates/pa-core/tests/compaction_transport.rs +++ b/crates/pa-core/tests/compaction_transport.rs @@ -94,6 +94,7 @@ async fn mock_summary( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn summary_respects_mandatory_thinking() { let (model, request, server) = mock_summary(Reply::Complete).await; let summary = complete_summary_call( @@ -114,6 +115,7 @@ async fn summary_respects_mandatory_thinking() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn dropped_summary_closes_hung_transport() { for reply in [Reply::HangBeforeHeaders, Reply::HangAfterDelta] { let (model, request, server) = mock_summary(reply).await; @@ -158,6 +160,7 @@ async fn dropped_summary_closes_hung_transport() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn summary_preserves_unspecified_reasoning_when_off_is_supported() { for map in [ json!({"off":"none","low":"low"}), @@ -186,6 +189,7 @@ async fn summary_preserves_unspecified_reasoning_when_off_is_supported() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn branch_summary_respects_mandatory_thinking() { let (model, request, server) = mock_summary(Reply::Complete).await; let entries = [FileEntry::Message { diff --git a/crates/pa-core/tests/git_context.rs b/crates/pa-core/tests/git_context.rs index 9fdac209e..0e5b4b681 100644 --- a/crates/pa-core/tests/git_context.rs +++ b/crates/pa-core/tests/git_context.rs @@ -53,6 +53,7 @@ fn user(text: &str) -> AgentMessage { }) } +#[pa_test_scratch::pa_test] #[test] fn reads_branch_commit_and_normalized_repo_url() { let repo = tempfile::tempdir().unwrap(); @@ -79,6 +80,7 @@ fn reads_branch_commit_and_normalized_repo_url() { ); } +#[pa_test_scratch::pa_test] #[test] fn detached_head_reports_commit_without_branch() { let repo = tempfile::tempdir().unwrap(); @@ -91,6 +93,7 @@ fn detached_head_reports_commit_without_branch() { assert_eq!(context.branch, None); } +#[pa_test_scratch::pa_test] #[test] fn omits_repo_url_without_origin() { let repo = tempfile::tempdir().unwrap(); @@ -102,6 +105,7 @@ fn omits_repo_url_without_origin() { assert_eq!(context.commit.as_deref(), Some(sha.as_str())); } +#[pa_test_scratch::pa_test] #[test] fn keeps_ssh_remote_url_verbatim_when_unnormalizable() { let repo = tempfile::tempdir().unwrap(); @@ -119,12 +123,14 @@ fn keeps_ssh_remote_url_verbatim_when_unnormalizable() { ); } +#[pa_test_scratch::pa_test] #[test] fn returns_none_outside_a_git_repo() { let dir = tempfile::tempdir().unwrap(); assert_eq!(capture_git_context(dir.path()), None); } +#[pa_test_scratch::pa_test] #[test] fn fresh_repo_without_commits_still_reports_branch() { let repo = tempfile::tempdir().unwrap(); @@ -135,6 +141,7 @@ fn fresh_repo_without_commits_still_reports_branch() { assert_eq!(context.commit, None); } +#[pa_test_scratch::pa_test] #[test] fn dirty_tree_does_not_change_capture() { let repo = tempfile::tempdir().unwrap(); @@ -167,6 +174,7 @@ fn dirty_tree_does_not_change_capture() { /// parses into the same Rust git context, wire shape included. The line below is the verbatim first /// line of `~/.prime/sessions/.jsonl` produced by `prime-agent -p --session-dir ... "say hi"` /// in that repo (the header is written before any model call). +#[pa_test_scratch::pa_test] #[test] fn ts_binary_session_header_round_trips() { let ts_header = concat!( @@ -202,6 +210,7 @@ fn ts_binary_session_header_round_trips() { // Session git-state lifecycle +#[pa_test_scratch::pa_test] #[test] fn session_header_captures_git_context() { let repo = tempfile::tempdir().unwrap(); @@ -233,6 +242,7 @@ fn session_header_captures_git_context() { ); } +#[pa_test_scratch::pa_test] #[test] fn no_git_state_entry_when_nothing_changed() { let repo = tempfile::tempdir().unwrap(); @@ -254,6 +264,7 @@ fn no_git_state_entry_when_nothing_changed() { .any(|entry| matches!(entry, FileEntry::GitState { .. }))); } +#[pa_test_scratch::pa_test] #[test] fn records_git_state_when_commit_changes() { let repo = tempfile::tempdir().unwrap(); @@ -289,6 +300,7 @@ fn records_git_state_when_commit_changes() { ); } +#[pa_test_scratch::pa_test] #[test] fn re_records_git_state_on_branch_without_it_on_active_path() { let repo = tempfile::tempdir().unwrap(); @@ -314,6 +326,7 @@ fn re_records_git_state_on_branch_without_it_on_active_path() { .is_some()); } +#[pa_test_scratch::pa_test] #[test] fn git_state_entries_stay_out_of_llm_context() { let repo = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/tests/kernel_capture_freshness.rs b/crates/pa-core/tests/kernel_capture_freshness.rs index 1c5f942f7..74b1c6a29 100644 --- a/crates/pa-core/tests/kernel_capture_freshness.rs +++ b/crates/pa-core/tests/kernel_capture_freshness.rs @@ -79,6 +79,7 @@ fn file_bytes(path: &Path) -> Vec { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn fresh_capture_skips_until_a_settled_cell_changes_the_namespace() { let dir = tempfile::TempDir::new().expect("temp dir"); let manifest_path = manifest_path_in(dir.path()); @@ -156,6 +157,7 @@ async fn fresh_capture_skips_until_a_settled_cell_changes_the_namespace() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_over_cap_value_is_skipped_from_the_write_and_survives_in_the_namespace() { let dir = tempfile::TempDir::new().expect("temp dir"); let manifest_path = manifest_path_in(dir.path()); @@ -231,6 +233,7 @@ async fn an_over_cap_value_is_skipped_from_the_write_and_survives_in_the_namespa } #[tokio::test] +#[pa_test_scratch::pa_test] async fn dispose_flush_skips_when_fresh_and_still_restores() { let dir = tempfile::TempDir::new().expect("temp dir"); let manifest_path = manifest_path_in(dir.path()); @@ -287,6 +290,7 @@ async fn dispose_flush_skips_when_fresh_and_still_restores() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn dispose_flush_dumps_after_a_settled_cell() { let dir = tempfile::TempDir::new().expect("temp dir"); let manifest_path = manifest_path_in(dir.path()); @@ -341,6 +345,7 @@ async fn dispose_flush_dumps_after_a_settled_cell() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_externally_replaced_manifest_defeats_the_fresh_skip() { let dir = tempfile::TempDir::new().expect("temp dir"); let manifest_path = manifest_path_in(dir.path()); @@ -370,6 +375,7 @@ async fn an_externally_replaced_manifest_defeats_the_fresh_skip() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_internal_state_request_does_not_defeat_the_fresh_skip() { let dir = tempfile::TempDir::new().expect("temp dir"); let manifest_path = manifest_path_in(dir.path()); @@ -408,6 +414,7 @@ async fn an_internal_state_request_does_not_defeat_the_fresh_skip() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_internal_execute_that_writes_a_user_variable_defeats_the_memo() { let dir = tempfile::TempDir::new().expect("temp dir"); let manifest_path = manifest_path_in(dir.path()); @@ -485,6 +492,7 @@ async fn an_internal_execute_that_writes_a_user_variable_defeats_the_memo() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_restore_settle_clears_the_memo() { let dir = tempfile::TempDir::new().expect("temp dir"); let manifest_path = manifest_path_in(dir.path()); @@ -526,6 +534,7 @@ async fn a_restore_settle_clears_the_memo() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_externally_replaced_payload_defeats_the_fresh_skip() { let dir = tempfile::TempDir::new().expect("temp dir"); let payload_path = snapshot_path_in(dir.path()); @@ -560,6 +569,7 @@ async fn an_externally_replaced_payload_defeats_the_fresh_skip() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn concurrent_settles_keep_the_boundary_invariant() { let dir = tempfile::TempDir::new().expect("temp dir"); let Some(options) = test_options(Some(dir.path())) else { diff --git a/crates/pa-core/tests/kernel_host_cancellation.rs b/crates/pa-core/tests/kernel_host_cancellation.rs index 5dd753562..f54b144b4 100644 --- a/crates/pa-core/tests/kernel_host_cancellation.rs +++ b/crates/pa-core/tests/kernel_host_cancellation.rs @@ -64,6 +64,7 @@ async fn bounded(future: impl std::future::Future) -> T { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn per_call_cancellation_drops_native_plugin_work_without_retiring_generation() { let Some(python) = std::env::var_os("PA_CORE_KERNEL_PYTHON") else { eprintln!( diff --git a/crates/pa-core/tests/kernel_lifecycle.rs b/crates/pa-core/tests/kernel_lifecycle.rs index 0c724e4c2..aea32b0ed 100644 --- a/crates/pa-core/tests/kernel_lifecycle.rs +++ b/crates/pa-core/tests/kernel_lifecycle.rs @@ -116,6 +116,7 @@ async fn execute( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn kernel_state_persists_across_cells_and_turns() { let Some(options) = test_options(None) else { return; @@ -164,6 +165,7 @@ async fn kernel_state_persists_across_cells_and_turns() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn background_thread_output_is_separated_from_cell_output() { let Some(options) = test_options(None) else { return; @@ -195,6 +197,7 @@ async fn background_thread_output_is_separated_from_cell_output() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn rlm_bootstrap_injects_the_kernel_surface() { let Some(base) = test_options(None) else { return; @@ -228,6 +231,7 @@ async fn rlm_bootstrap_injects_the_kernel_surface() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn host_requests_round_trip_to_registered_handlers() { let mut handlers = HostRequestHandlers::new(); handlers.register( @@ -290,6 +294,7 @@ async fn host_requests_round_trip_to_registered_handlers() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn kill9_then_restart_revives_snapshot_and_reports_unserializable() { let dir = tempfile::tempdir().expect("tempdir"); let Some(options) = test_options(Some(dir.path())) else { @@ -376,6 +381,7 @@ async fn kill9_then_restart_revives_snapshot_and_reports_unserializable() { /// continuation waits for their settlement: its completion settles the /// track exactly once; a graceful teardown over the settled track fires nothing. #[tokio::test] +#[pa_test_scratch::pa_test] async fn background_bash_settlement_fires_the_callback_once() { let Some(mut options) = test_options(None) else { return; @@ -425,6 +431,7 @@ async fn background_bash_settlement_fires_the_callback_once() { /// once: the handles die with the kernel, so owed continuations waiting /// on them must hear it before it is lost — once, not once per handle. #[tokio::test] +#[pa_test_scratch::pa_test] async fn kernel_teardown_with_live_handles_settles_the_callback_once() { let Some(mut options) = test_options(None) else { return; @@ -454,6 +461,7 @@ async fn kernel_teardown_with_live_handles_settles_the_callback_once() { /// execute result — including calls routed through a helper function, /// which a static scan of the cell source cannot see. #[tokio::test] +#[pa_test_scratch::pa_test] async fn cell_result_summarizes_the_bash_commands_it_ran() { let Some(options) = test_options(None) else { return; @@ -483,6 +491,7 @@ async fn cell_result_summarizes_the_bash_commands_it_ran() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn graceful_shutdown_flushes_the_final_snapshot() { let dir = tempfile::tempdir().expect("tempdir"); let Some(options) = test_options(Some(dir.path())) else { diff --git a/crates/pa-core/tests/kernel_mcp_settle.rs b/crates/pa-core/tests/kernel_mcp_settle.rs index 9507e7d3f..29f93140f 100644 --- a/crates/pa-core/tests/kernel_mcp_settle.rs +++ b/crates/pa-core/tests/kernel_mcp_settle.rs @@ -135,6 +135,7 @@ async fn wait_for_kernel_boot( /// the eager boot is still in flight waits for THAT boot and succeeds: the /// join memo serves one boot, never a second build, and the cell runs. #[tokio::test] +#[pa_test_scratch::pa_test] // The std Mutex guard for LIVE_KERNEL_LOCK rides the awaits on purpose // (the lock's own doc above): the kernel-python env is process-global, so // the tests serialize their whole kernel lifetimes, not just their setup. @@ -273,6 +274,7 @@ server.run() /// open and succeeds instead of erroring (the registry's per-server lock /// joins both callers onto one open). #[tokio::test] +#[pa_test_scratch::pa_test] // LIVE_KERNEL_LOCK held across the awaits on purpose (the lock's own doc // above): the kernel-python env is process-global, so the tests serialize // their whole kernel lifetimes. @@ -396,6 +398,7 @@ async fn generic_mcp_servers_settle_in_the_background_and_first_use_joins_the_op /// Red on a runtime without the lane (the cell queues behind the /// listing); green with it. #[tokio::test] +#[pa_test_scratch::pa_test] // LIVE_KERNEL_LOCK held across the awaits on purpose (the lock's own doc // above): the kernel-python env is process-global, so the tests serialize // their whole kernel lifetimes. diff --git a/crates/pa-core/tests/kernel_prewarm.rs b/crates/pa-core/tests/kernel_prewarm.rs index 024d2e6e9..3213b21d4 100644 --- a/crates/pa-core/tests/kernel_prewarm.rs +++ b/crates/pa-core/tests/kernel_prewarm.rs @@ -126,6 +126,7 @@ async fn wait_for_kernel_boot(engine: &pa_core::session_engine::engine::SessionE /// durable entries — with the empty-namespace arm, because the model never /// ran a cell. #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::await_holding_lock)] async fn prewarmed_kernel_lands_compaction_notice_without_tool_use() { let Some(_kernel_python) = kernel_python() else { @@ -277,6 +278,7 @@ async fn prewarmed_kernel_lands_compaction_notice_without_tool_use() { /// first-call start even when the runtime factory passes /// `prewarmIpythonKernel: true` — no boot. #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::await_holding_lock)] async fn subagent_sessions_stay_lazy_despite_the_prewarm_flag() { let Some(_kernel_python) = kernel_python() else { diff --git a/crates/pa-core/tests/kernel_protocol_frame_caps.rs b/crates/pa-core/tests/kernel_protocol_frame_caps.rs index 7c88beb0a..68700e23c 100644 --- a/crates/pa-core/tests/kernel_protocol_frame_caps.rs +++ b/crates/pa-core/tests/kernel_protocol_frame_caps.rs @@ -66,6 +66,7 @@ fn manager(python: std::path::PathBuf) -> ReplKernelManager { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn oversized_unterminated_protocol_line_poisons_and_repairs() { let fixture = fake_runtime_path(); let manager = manager(fixture.to_path_buf()); @@ -95,6 +96,7 @@ async fn oversized_unterminated_protocol_line_poisons_and_repairs() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn normal_protocol_lines_still_stream_through_the_bounded_reader() { // Multiple frames in one 64 Ki chunk plus a trailing partial line must // all dispatch: the chunked reader only poisons past the ceiling. @@ -130,6 +132,7 @@ async fn normal_protocol_lines_still_stream_through_the_bounded_reader() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn multi_mib_blank_protocol_line_is_read_in_linear_time() { // A 31 MiB blank line arrives in pipe reads of at most 64 KiB; rescanning // the buffered prefix per read would scan >= 8 GB. Blank lines skip diff --git a/crates/pa-core/tests/kernel_python_skills_unavailable.rs b/crates/pa-core/tests/kernel_python_skills_unavailable.rs index e49d7c09a..555e65376 100644 --- a/crates/pa-core/tests/kernel_python_skills_unavailable.rs +++ b/crates/pa-core/tests/kernel_python_skills_unavailable.rs @@ -72,6 +72,7 @@ fn skill(name: &str) -> KernelPythonSkill { /// One boot with an explicit kernel python reports the broken import (and only it): the marker line /// carries `json`'s healthy import nowhere, so the report stays honest about what actually failed. #[tokio::test] +#[pa_test_scratch::pa_test] async fn broken_skill_import_reports_and_healthy_skills_stay_silent() { let Some(python) = kernel_python() else { return; @@ -114,6 +115,7 @@ async fn broken_skill_import_reports_and_healthy_skills_stay_silent() { /// The notice rides the next admitted turn as model context: the /// durable row keeps the multi-skill content and `details.skills`. #[tokio::test] +#[pa_test_scratch::pa_test] // The faux lock is held across the turn's awaits (see `FAUX_LOCK`). #[allow(clippy::await_holding_lock)] async fn notice_rides_the_next_turn_as_model_context() { diff --git a/crates/pa-core/tests/kernel_restore_guards.rs b/crates/pa-core/tests/kernel_restore_guards.rs index e23739ebf..35db0f958 100644 --- a/crates/pa-core/tests/kernel_restore_guards.rs +++ b/crates/pa-core/tests/kernel_restore_guards.rs @@ -98,6 +98,7 @@ async fn wait_out_debounce(ms: u64) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn restored_functions_run_against_live_namespace_globals() { let dir = tempfile::TempDir::new().expect("temp dir"); let Some(writer_options) = test_options(Some(dir.path()), None) else { @@ -160,6 +161,7 @@ async fn restored_functions_run_against_live_namespace_globals() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn post_restore_auto_snapshot_skips_until_a_real_cell_changes_the_namespace() { let dir = tempfile::TempDir::new().expect("temp dir"); let snapshot_path = snapshot_path_in(dir.path()); @@ -243,6 +245,7 @@ async fn post_restore_auto_snapshot_skips_until_a_real_cell_changes_the_namespac } #[tokio::test] +#[pa_test_scratch::pa_test] async fn failed_restore_keeps_the_on_disk_payload_through_the_debounced_snapshot() { let dir = tempfile::TempDir::new().expect("temp dir"); let snapshot_path = snapshot_path_in(dir.path()); @@ -315,6 +318,7 @@ fn v2_record(name: &str, blob: &[u8]) -> Vec { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn partial_restore_keeps_the_fuller_on_disk_payload_through_the_dispose_flush() { let dir = tempfile::TempDir::new().expect("temp dir"); let snapshot_path = snapshot_path_in(dir.path()); @@ -366,6 +370,7 @@ async fn partial_restore_keeps_the_fuller_on_disk_payload_through_the_dispose_fl } #[tokio::test] +#[pa_test_scratch::pa_test] async fn failed_restore_keeps_the_on_disk_payload_through_the_dispose_flush() { let dir = tempfile::TempDir::new().expect("temp dir"); let snapshot_path = snapshot_path_in(dir.path()); @@ -406,6 +411,7 @@ async fn failed_restore_keeps_the_on_disk_payload_through_the_dispose_flush() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn zero_debounce_after_a_failed_restore_still_cannot_clobber_the_payload() { let dir = tempfile::TempDir::new().expect("temp dir"); let snapshot_path = snapshot_path_in(dir.path()); diff --git a/crates/pa-core/tests/kernel_result_clip.rs b/crates/pa-core/tests/kernel_result_clip.rs index 7ca1c07ff..c8ba89f71 100644 --- a/crates/pa-core/tests/kernel_result_clip.rs +++ b/crates/pa-core/tests/kernel_result_clip.rs @@ -34,6 +34,7 @@ for line in sys.stdin: "#; #[tokio::test] +#[pa_test_scratch::pa_test] async fn result_clipping_counts_characters_and_preserves_follow_up_cells() { let dir = tempfile::TempDir::new().expect("temp dir"); let python = dir.path().join("fake-kernel"); diff --git a/crates/pa-core/tests/kernel_snapshot_resume.rs b/crates/pa-core/tests/kernel_snapshot_resume.rs index 6c19b16c3..54eb58c44 100644 --- a/crates/pa-core/tests/kernel_snapshot_resume.rs +++ b/crates/pa-core/tests/kernel_snapshot_resume.rs @@ -219,6 +219,7 @@ impl Fixture { /// The full lifecycle: a session defines kernel state and ends, a resumed session prewarms with the /// config flag OFF, and its FIRST ipython call sees the old namespace. #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::await_holding_lock)] async fn session_end_then_resume_prewarms_and_revives_the_namespace() { let Some(_kernel_python) = kernel_python() else { @@ -373,6 +374,7 @@ async fn session_end_then_resume_prewarms_and_revives_the_namespace() { /// The prewarm arm does not over-fire: a FRESH session (no snapshot) with /// the config flag off stays lazy — no boot. #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::await_holding_lock)] async fn fresh_session_without_snapshot_stays_lazy_without_the_flag() { let Some(_kernel_python) = kernel_python() else { diff --git a/crates/pa-core/tests/kernel_startup_join.rs b/crates/pa-core/tests/kernel_startup_join.rs index 50c026e5a..82823b02f 100644 --- a/crates/pa-core/tests/kernel_startup_join.rs +++ b/crates/pa-core/tests/kernel_startup_join.rs @@ -51,6 +51,7 @@ fn starts(count: &std::path::Path) -> u64 { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn first_touch_joins_prewarm_and_preserves_true_failure() { let (_dir, provisioner, count) = failing_kernel(); provisioner.prewarm(); @@ -71,6 +72,7 @@ async fn first_touch_joins_prewarm_and_preserves_true_failure() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn aborted_waiter_leaves_boot_for_other_callers() { let (_dir, provisioner, count) = failing_kernel(); provisioner.prewarm(); @@ -95,6 +97,7 @@ async fn aborted_waiter_leaves_boot_for_other_callers() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn stop_during_boot_joins_startup() { let (_dir, provisioner, count) = failing_kernel(); provisioner.prewarm(); @@ -105,6 +108,7 @@ async fn stop_during_boot_joins_startup() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn panicking_progress_callback_does_not_poison_next_startup() { let (_dir, provisioner, count) = failing_kernel(); let progress: pa_core::kernel::bootstrap::KernelBootstrapProgressHandler = @@ -130,6 +134,7 @@ async fn panicking_progress_callback_does_not_poison_next_startup() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn dispose_during_boot_waits_and_releases_it() { let (_dir, provisioner, count) = failing_kernel(); provisioner.prewarm(); diff --git a/crates/pa-core/tests/kernel_startup_memo.rs b/crates/pa-core/tests/kernel_startup_memo.rs index d4ca66007..a4cffefc2 100644 --- a/crates/pa-core/tests/kernel_startup_memo.rs +++ b/crates/pa-core/tests/kernel_startup_memo.rs @@ -110,6 +110,7 @@ fn starts(count: &std::path::Path) -> u64 { /// leave that newer memo alone: the late joiner below must land on the /// newer boot, and exactly two interpreters may spawn. #[tokio::test] +#[pa_test_scratch::pa_test] async fn stale_publisher_cannot_clear_a_newer_startup_memo() { let Some(python) = kernel_python() else { return; @@ -191,6 +192,7 @@ async fn stale_publisher_cannot_clear_a_newer_startup_memo() { /// doomed boot's own settle kills its kernel instead of parking it, and /// the next `ensure()` boots fresh. #[tokio::test] +#[pa_test_scratch::pa_test] async fn kill_during_boot_leaves_no_resident_kernel() { let Some(python) = kernel_python() else { return; @@ -263,6 +265,7 @@ async fn kill_during_boot_leaves_no_resident_kernel() { /// published between separate check and publish scopes could park a live /// kernel into a provisioner that had already reported itself torn down. #[tokio::test] +#[pa_test_scratch::pa_test] async fn dispose_during_boot_settles_it_without_parking() { let Some(python) = kernel_python() else { return; @@ -343,6 +346,7 @@ async fn dispose_during_boot_settles_it_without_parking() { /// fresh generation, and `kill()` mid-re-armed-boot still leaves no /// resident kernel - the doomed re-armed boot is killed by its own settle. #[tokio::test] +#[pa_test_scratch::pa_test] async fn kill_during_the_re_armed_boot_leaves_no_resident_kernel() { let Some(python) = kernel_python() else { return; @@ -431,6 +435,7 @@ async fn kill_during_the_re_armed_boot_leaves_no_resident_kernel() { /// newer boot replays that boot's last stage to its fresh progress /// handler; after the doomed settle the replay must still fire. #[tokio::test] +#[pa_test_scratch::pa_test] async fn doomed_settle_keeps_the_newer_boot_listener_state() { let Some(python) = kernel_python() else { return; @@ -630,6 +635,7 @@ fn flaky_first_kernel( /// settle only kills its kernel - the absolute spawn count pins that the /// killed generation never consumed its retry after the backoff. #[tokio::test] +#[pa_test_scratch::pa_test] async fn kill_during_the_retry_backoff_pins_the_spawn_count() { let Some(python) = kernel_python() else { return; @@ -701,6 +707,7 @@ async fn kill_during_the_retry_backoff_pins_the_spawn_count() { /// boot's report still must (the same bootstrap's broken import, the /// same callback, exactly one report). #[tokio::test] +#[pa_test_scratch::pa_test] async fn doomed_boot_does_not_report_unavailable_skills() { let Some(python) = kernel_python() else { return; @@ -804,6 +811,7 @@ async fn doomed_boot_does_not_report_unavailable_skills() { /// resurrect a generation `kill()` doomed. The sentinel snapshot stays /// byte-identical. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_killed_then_disposed_boot_never_flushes_the_snapshot() { let Some(python) = kernel_python() else { return; @@ -873,6 +881,7 @@ async fn a_killed_then_disposed_boot_never_flushes_the_snapshot() { /// completion - it cannot return while the doomed boot's interpreter is /// still held. #[tokio::test] +#[pa_test_scratch::pa_test] async fn dispose_after_a_kill_waits_the_doomed_boot() { let Some(python) = kernel_python() else { return; @@ -933,6 +942,7 @@ async fn dispose_after_a_kill_waits_the_doomed_boot() { /// dispose signal. The observable is the spawn count: only the first /// boot's interpreter ever spawns. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_kill_while_the_boot_waits_the_stop_gate_spawns_no_interpreter() { let Some(python) = kernel_python() else { return; diff --git a/crates/pa-core/tests/kernel_stop_revive.rs b/crates/pa-core/tests/kernel_stop_revive.rs index 08d468dea..88f48ba33 100644 --- a/crates/pa-core/tests/kernel_stop_revive.rs +++ b/crates/pa-core/tests/kernel_stop_revive.rs @@ -57,6 +57,7 @@ fn kernel_python() -> Option { /// and releases the kernel, and the revived namespace still serves the variables the flush carried /// — while `dispose` was never called. #[tokio::test] +#[pa_test_scratch::pa_test] async fn stop_kernel_flushes_the_snapshot_and_the_next_ensure_revives_it() { let Some(python) = kernel_python() else { return; @@ -106,6 +107,7 @@ async fn stop_kernel_flushes_the_snapshot_and_the_next_ensure_revives_it() { /// An idle stop is a no-op (no kernel, no snapshot churn) and a second /// stop supersedes the first (TS `pendingStop` last-writer-wins). #[tokio::test] +#[pa_test_scratch::pa_test] async fn stop_kernel_without_a_kernel_is_a_no_op_and_stays_revivable() { let Some(python) = kernel_python() else { return; @@ -140,6 +142,7 @@ async fn stop_kernel_without_a_kernel_is_a_no_op_and_stays_revivable() { /// draining host work in `stop_kernel()`. The held request gives an exact /// ordering barrier rather than relying on timing of the snapshot flush. #[tokio::test] +#[pa_test_scratch::pa_test] async fn revival_waits_for_in_flight_stop_before_booting() { let Some(python) = kernel_python() else { return; @@ -273,6 +276,7 @@ async fn revival_waits_for_in_flight_stop_before_booting() { /// against the first bounded await. The absolute spawn count stays pinned /// at two: nothing in the chain may arm a third interpreter. #[tokio::test] +#[pa_test_scratch::pa_test] async fn superseding_stop_after_kill_cannot_deadlock_the_revival_gate() { let Some(python) = kernel_python() else { return; diff --git a/crates/pa-core/tests/kernel_system_exit.rs b/crates/pa-core/tests/kernel_system_exit.rs index ff67c667a..35cd094dd 100644 --- a/crates/pa-core/tests/kernel_system_exit.rs +++ b/crates/pa-core/tests/kernel_system_exit.rs @@ -101,6 +101,7 @@ fn busy_kernel_path() -> tempfile::TempPath { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_system_exit_cell_fails_that_cell_and_the_kernel_keeps_serving() { let Some(python) = kernel_python() else { return; @@ -142,6 +143,7 @@ async fn a_system_exit_cell_fails_that_cell_and_the_kernel_keeps_serving() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_unsettled_cell_leaves_the_busy_refusal_typed() { let fixture = busy_kernel_path(); let manager = ReplKernelManager::new(options(fixture.to_path_buf(), "busy-kernel")); diff --git a/crates/pa-core/tests/kernel_teardown.rs b/crates/pa-core/tests/kernel_teardown.rs index dfed1b71c..16ec59ba9 100644 --- a/crates/pa-core/tests/kernel_teardown.rs +++ b/crates/pa-core/tests/kernel_teardown.rs @@ -171,6 +171,7 @@ fn test_options() -> Option { } #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::await_holding_lock)] async fn manager_drop_kills_the_kernel_process() { let _guard = test_lock(); @@ -184,6 +185,7 @@ async fn manager_drop_kills_the_kernel_process() { } #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::await_holding_lock)] async fn provisioner_drop_kills_the_kernel_process() { let _guard = test_lock(); @@ -209,6 +211,7 @@ async fn provisioner_drop_kills_the_kernel_process() { /// the prewarm flag boots a kernel in the background; found via the /// process table, so the test exercises the public session surface. #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::await_holding_lock)] async fn session_engine_drop_kills_the_prewarmed_kernel_process() { let _guard = test_lock(); @@ -285,6 +288,7 @@ async fn session_engine_drop_kills_the_prewarmed_kernel_process() { /// The explicit dispose seam: a host that keeps the engine object but ends the session (the daemon /// worker's shape) must be able to take the kernel down without dropping the engine. #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::await_holding_lock)] async fn engine_dispose_kernel_kills_the_prewarmed_kernel_process() { let _guard = test_lock(); diff --git a/crates/pa-core/tests/live_catalog_chain.rs b/crates/pa-core/tests/live_catalog_chain.rs index c4c0c097d..a723ef912 100644 --- a/crates/pa-core/tests/live_catalog_chain.rs +++ b/crates/pa-core/tests/live_catalog_chain.rs @@ -222,6 +222,7 @@ fn pi_payload(repriced_id: &str, repriced_input: f64) -> String { /// The credentialed fetches carry the Bearer + team headers (the /// $0-pricing bug: production fetched without them). #[tokio::test] +#[pa_test_scratch::pa_test] async fn refresh_lands_live_pricing_private_models_and_layer_a_entries() { let agent_dir = tempfile::tempdir().unwrap(); let bundled_dir = tempfile::tempdir().unwrap(); @@ -305,6 +306,7 @@ async fn refresh_lands_live_pricing_private_models_and_layer_a_entries() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_refresh_warms_the_process_shared_catalog() { let agent_dir = tempfile::tempdir().unwrap(); let bundled_dir = tempfile::tempdir().unwrap(); @@ -341,6 +343,7 @@ async fn startup_refresh_warms_the_process_shared_catalog() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn without_credentials_the_compiled_fallback_serves_unchanged() { let agent_dir = tempfile::tempdir().unwrap(); let bundled_dir = tempfile::tempdir().unwrap(); @@ -375,6 +378,7 @@ async fn without_credentials_the_compiled_fallback_serves_unchanged() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn layer_a_fetch_adds_entries_the_compiled_fallback_lacks() { let agent_dir = tempfile::tempdir().unwrap(); let bundled_dir = tempfile::tempdir().unwrap(); @@ -405,6 +409,7 @@ async fn layer_a_fetch_adds_entries_the_compiled_fallback_lacks() { /// the full catalog but is gated out of the picker (the production openai-codex picker gap was /// missing auth, not missing wiring). #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_picker_available_list_shows_a_fetched_entry_once_its_provider_auth_is_configured() { async fn refreshed_registry_with_openai_auth( openai_auth_configured: bool, @@ -469,6 +474,7 @@ async fn the_picker_available_list_shows_a_fetched_entry_once_its_provider_auth_ /// `findSessionModelWithReadinessWait`: the session boot gives the daemon restart's fetch a bounded /// window before the lookup is allowed to fail). #[tokio::test] +#[pa_test_scratch::pa_test] async fn session_model_restore_waits_out_a_slow_catalog_fetch() { let agent_dir = tempfile::tempdir().unwrap(); let bundled_dir = tempfile::tempdir().unwrap(); @@ -501,6 +507,7 @@ async fn session_model_restore_waits_out_a_slow_catalog_fetch() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn session_model_restore_is_bounded_when_the_fetch_never_lands() { let agent_dir = tempfile::tempdir().unwrap(); let bundled_dir = tempfile::tempdir().unwrap(); @@ -527,6 +534,7 @@ async fn session_model_restore_is_bounded_when_the_fetch_never_lands() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn session_model_restore_fast_path_never_fetches() { let agent_dir = tempfile::tempdir().unwrap(); let bundled_dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/tests/lock_compat.rs b/crates/pa-core/tests/lock_compat.rs index 51af38e77..7f79530a0 100644 --- a/crates/pa-core/tests/lock_compat.rs +++ b/crates/pa-core/tests/lock_compat.rs @@ -69,6 +69,7 @@ impl Drop for Flock { } } +#[pa_test_scratch::pa_test] #[test] fn settings_write_leaves_no_lock_artifact() { let dir = tempfile::tempdir().unwrap(); @@ -87,6 +88,7 @@ fn settings_write_leaves_no_lock_artifact() { ); } +#[pa_test_scratch::pa_test] #[test] fn settings_write_reclaims_a_crashed_holders_lock_directory() { let dir = tempfile::tempdir().unwrap(); @@ -106,6 +108,7 @@ fn settings_write_reclaims_a_crashed_holders_lock_directory() { assert!(!lock.exists(), "the write released its own lock"); } +#[pa_test_scratch::pa_test] #[test] fn settings_write_reports_contention_on_a_live_lock_directory() { let dir = tempfile::tempdir().unwrap(); @@ -196,6 +199,7 @@ const SOURCE_AUTH: &str = r#"{ } "#; +#[pa_test_scratch::pa_test] #[test] fn auth_write_rejects_a_stale_legacy_file_without_mutation() { let dir = tempfile::tempdir().unwrap(); @@ -208,6 +212,7 @@ fn auth_write_rejects_a_stale_legacy_file_without_mutation() { assert_legacy_refused(&auth, &lock, &expected); } +#[pa_test_scratch::pa_test] #[test] fn auth_write_rejects_a_held_and_released_legacy_flock_without_mutation() { // Even a released flock cannot prove that no legacy writer already has diff --git a/crates/pa-core/tests/lua_hook_yield.rs b/crates/pa-core/tests/lua_hook_yield.rs index 84dad3098..742b23bba 100644 --- a/crates/pa-core/tests/lua_hook_yield.rs +++ b/crates/pa-core/tests/lua_hook_yield.rs @@ -86,6 +86,7 @@ async fn trial(round: usize) { } } #[tokio::test(flavor = "multi_thread", worker_threads = 4)] +#[pa_test_scratch::pa_test] async fn concurrent_hook_yields_preserve_suspended_lua_frame_locals() { tokio::time::timeout(std::time::Duration::from_secs(45), async { for batch in 0..1250 { diff --git a/crates/pa-core/tests/offline_catalog_startup.rs b/crates/pa-core/tests/offline_catalog_startup.rs index c45ad863f..ee6e4c21a 100644 --- a/crates/pa-core/tests/offline_catalog_startup.rs +++ b/crates/pa-core/tests/offline_catalog_startup.rs @@ -141,6 +141,7 @@ fn prime_payload() -> serde_json::Value { // Keep the isolated child actions together so the env-cleared entry point is explicit. #[allow(clippy::too_many_lines)] +#[pa_test_scratch::pa_test] #[test] fn startup_child() { let Ok(action) = std::env::var(CHILD) else { @@ -468,11 +469,13 @@ async fn fenced_children(actions: &[&str]) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn production_default_catalog_makes_zero_offline_requests() { fenced_children(&["models"]).await; } #[tokio::test] +#[pa_test_scratch::pa_test] async fn online_loopback_and_rejecting_proxy_are_live() { fenced_children(&["online", "fence"]).await; } diff --git a/crates/pa-core/tests/prompt_guards.rs b/crates/pa-core/tests/prompt_guards.rs index bf48623ac..428573b3c 100644 --- a/crates/pa-core/tests/prompt_guards.rs +++ b/crates/pa-core/tests/prompt_guards.rs @@ -58,6 +58,7 @@ const DYNAMIC_ONLY_MARKERS: &[&str] = &[ "You are a child agent spawned by", ]; +#[pa_test_scratch::pa_test] #[test] fn static_layers_contain_no_dynamic_content() { for (name, text) in [ @@ -76,6 +77,7 @@ fn static_layers_contain_no_dynamic_content() { } } +#[pa_test_scratch::pa_test] #[test] fn cached_prefix_is_stable_across_sessions() { let mut options = BuildSystemPromptOptions { @@ -446,6 +448,7 @@ fn documented_surface_tokens() -> BTreeSet { documented } +#[pa_test_scratch::pa_test] #[test] fn core_layer_documents_the_real_tool_surface() { let documented = documented_surface_tokens(); @@ -508,6 +511,7 @@ const TS_PACKAGED_SKILL_SET: &[&str] = &[ /// The loadable skill set is exactly the historical TS set. /// The generic `mcp` skill stays markdown-only, and the retired per-service pair stays gone. +#[pa_test_scratch::pa_test] #[test] fn bundled_skills_match_the_ts_packaged_set() { let skills = sorted_bundled_skills(); @@ -539,6 +543,7 @@ fn bundled_skills_match_the_ts_packaged_set() { /// The generic mcp skill loads through the normal markdown discovery and renders in the /// `` inventory exactly like any other markdown skill: the `[skill name /// location]`-style XML the TS `formatSkillsForPrompt` emits, without a `python_import` line. +#[pa_test_scratch::pa_test] #[test] fn generic_mcp_skill_renders_in_the_prompt_inventory() { let mut options = BuildSystemPromptOptions { diff --git a/crates/pa-core/tests/release_channel_manifest.rs b/crates/pa-core/tests/release_channel_manifest.rs index 70ba2ea3d..aa435ba77 100644 --- a/crates/pa-core/tests/release_channel_manifest.rs +++ b/crates/pa-core/tests/release_channel_manifest.rs @@ -189,6 +189,7 @@ fn channel_step_run(workflow: &Workflow) -> &str { .expect("the channel-manifest step runs a script") } +#[pa_test_scratch::pa_test] #[test] fn the_workflow_wires_the_channel_manifest_producer() { let (text, workflow) = load_workflow(); @@ -282,6 +283,7 @@ fn the_workflow_wires_the_channel_manifest_producer() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_rolling_nightly_refresh_is_a_serialized_job() { let (_, workflow) = load_workflow(); @@ -373,6 +375,7 @@ fn the_rolling_nightly_refresh_is_a_serialized_job() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_producer_emits_a_stable_manifest_the_reader_accepts() { let (_, workflow) = load_workflow(); @@ -420,6 +423,7 @@ fn the_producer_emits_a_stable_manifest_the_reader_accepts() { assert_reader_artifacts_are_truthful(&release, &out); } +#[pa_test_scratch::pa_test] #[test] fn the_producer_emits_a_nightly_manifest_the_reader_accepts() { let (_, workflow) = load_workflow(); @@ -447,6 +451,7 @@ fn the_producer_emits_a_nightly_manifest_the_reader_accepts() { assert_reader_artifacts_are_truthful(&release, &out); } +#[pa_test_scratch::pa_test] #[test] fn the_producer_refuses_rows_the_reader_rejects() { let (_, workflow) = load_workflow(); @@ -476,6 +481,7 @@ fn the_producer_refuses_rows_the_reader_rejects() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_producer_refuses_a_manifest_missing_a_platform_row() { let (_, workflow) = load_workflow(); @@ -542,6 +548,7 @@ fn assert_reader_artifacts_are_truthful(release: &LatestRelease, out: &Path) { } } +#[pa_test_scratch::pa_test] #[test] fn assembled_archives_carry_the_platform_alias_the_reader_demands() { let (_, workflow) = load_workflow(); diff --git a/crates/pa-core/tests/session_nested_metadata.rs b/crates/pa-core/tests/session_nested_metadata.rs index d408b7cad..16481d066 100644 --- a/crates/pa-core/tests/session_nested_metadata.rs +++ b/crates/pa-core/tests/session_nested_metadata.rs @@ -83,16 +83,19 @@ fn persistent_roundtrip(fixture: &str) { assert_eq!(std::fs::read(original).unwrap(), original_bytes); } +#[pa_test_scratch::pa_test] #[test] fn persistent_open_append_reopen_preserves_nested_metadata() { persistent_roundtrip(FIXTURE); } +#[pa_test_scratch::pa_test] #[test] fn persistent_open_preserves_all_audited_nested_metadata() { persistent_roundtrip(include_str!("fixtures/session_nested_metadata_all.jsonl")); } +#[pa_test_scratch::pa_test] #[test] fn empty_unknown_maps_keep_existing_wire_bytes() { for line in include_str!("fixtures/session_nested_empty_extras.jsonl").lines() { @@ -102,6 +105,7 @@ fn empty_unknown_maps_keep_existing_wire_bytes() { } } +#[pa_test_scratch::pa_test] #[test] fn git_identity_ignores_preserved_metadata_but_records_known_changes() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/tests/turn_boundary_kernel.rs b/crates/pa-core/tests/turn_boundary_kernel.rs index 6a8d28610..bb56c5ccf 100644 --- a/crates/pa-core/tests/turn_boundary_kernel.rs +++ b/crates/pa-core/tests/turn_boundary_kernel.rs @@ -115,6 +115,7 @@ fn registry_model() -> pa_types::ai::Model { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn turn_boundary_host_requests_round_trip_through_a_real_kernel() { let Some(kernel_python) = kernel_python() else { return; diff --git a/crates/pa-daemon/tests/abort_kernel_e2e.rs b/crates/pa-daemon/tests/abort_kernel_e2e.rs index 4bd713a6d..ee225a8b4 100644 --- a/crates/pa-daemon/tests/abort_kernel_e2e.rs +++ b/crates/pa-daemon/tests/abort_kernel_e2e.rs @@ -221,6 +221,7 @@ impl Client { } /// The turn unwinds within the budget and the cell dies (its finish marker never appears). +#[pa_test_scratch::pa_test] #[test] fn abort_during_a_kernel_cell_settles_the_daemon_turn_immediately() { let Some(_) = kernel_python() else { diff --git a/crates/pa-daemon/tests/agent_family_e2e.rs b/crates/pa-daemon/tests/agent_family_e2e.rs index 7e32f19cb..0240dc225 100644 --- a/crates/pa-daemon/tests/agent_family_e2e.rs +++ b/crates/pa-daemon/tests/agent_family_e2e.rs @@ -421,6 +421,7 @@ async fn send_agent_message( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn parent_child_agent_message_round_trip_end_to_end() { let Some(kernel_python) = kernel_python() else { return; @@ -682,6 +683,7 @@ fn cell_turn(code: &str) -> Value { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn family_edges_never_cross_families_end_to_end() { let Some(kernel_python) = kernel_python() else { return; @@ -1227,6 +1229,7 @@ async fn family_edges_never_cross_families_end_to_end() { /// the new name, and the parent-side selectors stop matching the old /// name (`rlm.collect` by the old name fails, the new name hits). #[tokio::test] +#[pa_test_scratch::pa_test] async fn parent_renames_a_child_end_to_end() { let Some(kernel_python) = kernel_python() else { return; diff --git a/crates/pa-daemon/tests/agents_view_roster_e2e.rs b/crates/pa-daemon/tests/agents_view_roster_e2e.rs index a0177ba2e..c3f88ec3a 100644 --- a/crates/pa-daemon/tests/agents_view_roster_e2e.rs +++ b/crates/pa-daemon/tests/agents_view_roster_e2e.rs @@ -167,6 +167,7 @@ impl Client { } } +#[pa_test_scratch::pa_test] #[test] fn roster_subscribe_snapshot_and_live_update_pushes() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -318,6 +319,7 @@ fn roster_subscribe_snapshot_and_live_update_pushes() { ); } +#[pa_test_scratch::pa_test] #[test] fn worker_roster_delta_requires_authentication() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -342,6 +344,7 @@ fn worker_roster_delta_requires_authentication() { /// Family-depth roster rows: a supervisor-backed RLM child joins the roster keyed /// `parentSessionPath#childId` (TS `rosterAgentIdForSummary`). #[tokio::test] +#[pa_test_scratch::pa_test] async fn rlm_children_key_the_roster_by_parent_path_and_child_id() { use pa_core::session_engine::rlm_host::{RlmSpawnRequest, RlmSubagentHost}; use pa_daemon::rlm_children::{ParentIdentity, SupervisorChildSessions}; diff --git a/crates/pa-daemon/tests/close_listener_cleanup_e2e.rs b/crates/pa-daemon/tests/close_listener_cleanup_e2e.rs index 7d68e4fab..02e98fe5c 100644 --- a/crates/pa-daemon/tests/close_listener_cleanup_e2e.rs +++ b/crates/pa-daemon/tests/close_listener_cleanup_e2e.rs @@ -356,6 +356,7 @@ fn read_exact_timeout(stream: &mut UnixStream, buffer: &mut [u8], deadline: Inst /// inside the worker's bind->capture window poisons the captured /// identity, the worker's real exit path runs, and the successor's LIVE /// socket at the path must survive it. +#[pa_test_scratch::pa_test] #[test] fn a_poisoned_workers_shutdown_exit_spares_the_successors_live_socket() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -388,6 +389,7 @@ fn a_poisoned_workers_shutdown_exit_spares_the_successors_live_socket() { /// at the path inside the supervisor's bind->capture window poisons the /// captured identity, the real drain exit runs, and the successor's LIVE /// socket at the path must survive it. +#[pa_test_scratch::pa_test] #[test] fn a_poisoned_supervisors_drain_spares_the_successors_live_socket() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -427,6 +429,7 @@ fn a_poisoned_supervisors_drain_spares_the_successors_live_socket() { /// so the refusal exit unlinks its own dead file on Linux and /// conservatively preserves it everywhere else. #[cfg(target_os = "linux")] +#[pa_test_scratch::pa_test] #[test] fn a_refused_registrations_exit_removes_the_workers_own_dead_socket() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -456,6 +459,7 @@ fn a_refused_registrations_exit_removes_the_workers_own_dead_socket() { /// exit must leave the file alone rather than guess - the next bind's /// stale-socket prepare is what clears it. #[cfg(not(target_os = "linux"))] +#[pa_test_scratch::pa_test] #[test] fn a_refused_registrations_exit_preserves_its_dead_file_off_linux() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -483,6 +487,7 @@ fn a_refused_registrations_exit_preserves_its_dead_file_off_linux() { /// unlink even though the poisoned identity gate would match. This pins /// the refusal exit to the same successor-protection contract the /// routed-shutdown exit carries. +#[pa_test_scratch::pa_test] #[test] fn a_refused_registrations_exit_spares_the_poisoning_successor() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/command_breadth.rs b/crates/pa-daemon/tests/command_breadth.rs index 628c72951..ba38d8c4b 100644 --- a/crates/pa-daemon/tests/command_breadth.rs +++ b/crates/pa-daemon/tests/command_breadth.rs @@ -518,6 +518,7 @@ const WIRE_FIXTURES: &[(&str, &str)] = &[ ]; /// The accept list is the TS list, in TS order, then the Rust-native supervisor/worker frames. +#[pa_test_scratch::pa_test] #[test] fn known_command_types_match_the_ts_list() { // Keep the ordered TS baseline intact. These declared public extensions @@ -562,6 +563,7 @@ fn known_command_types_match_the_ts_list() { } } +#[pa_test_scratch::pa_test] #[test] fn every_command_type_parses_and_routes() { for (type_name, wire) in WIRE_FIXTURES { @@ -590,6 +592,7 @@ fn every_command_type_parses_and_routes() { } /// Unknown types keep the TS wire error, not a parse accident. +#[pa_test_scratch::pa_test] #[test] fn unknown_type_keeps_the_ts_error_string() { let line = r#"{"type":"command","id":"c1","protocol":{"name":"prime-agent.daemon","version":7},"command":{"type":"not_a_command"}}"#; diff --git a/crates/pa-daemon/tests/command_dispatch_e2e.rs b/crates/pa-daemon/tests/command_dispatch_e2e.rs index c984b3517..2ede1eb75 100644 --- a/crates/pa-daemon/tests/command_dispatch_e2e.rs +++ b/crates/pa-daemon/tests/command_dispatch_e2e.rs @@ -372,6 +372,7 @@ fn print_table(phase: &str, measurements: &[Measurement]) { } } +#[pa_test_scratch::pa_test] #[test] fn client_commands_answer_fast_while_a_turn_streams() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/compaction_abort_e2e.rs b/crates/pa-daemon/tests/compaction_abort_e2e.rs index d09aa68ea..cc815de8d 100644 --- a/crates/pa-daemon/tests/compaction_abort_e2e.rs +++ b/crates/pa-daemon/tests/compaction_abort_e2e.rs @@ -489,6 +489,7 @@ impl Client { } } +#[pa_test_scratch::pa_test] #[test] fn abort_compaction_mid_threshold_run_records_the_cancelled_outcome() { let dir = tempfile::tempdir().expect("temp dir"); @@ -800,6 +801,7 @@ fn signal(pid: u32, signal: &str) { assert!(status.success(), "kill {signal} {pid} failed"); } +#[pa_test_scratch::pa_test] #[test] fn wedged_worker_abort_acks_immediately_and_declares_terminal() { let dir = tempfile::tempdir().expect("temp dir"); diff --git a/crates/pa-daemon/tests/compaction_completion_stall_e2e.rs b/crates/pa-daemon/tests/compaction_completion_stall_e2e.rs index 31b5ee600..21152b53c 100644 --- a/crates/pa-daemon/tests/compaction_completion_stall_e2e.rs +++ b/crates/pa-daemon/tests/compaction_completion_stall_e2e.rs @@ -530,6 +530,7 @@ fn seed_mega_session(client: &mut TimedClient, session_id: &str, mock: &StallMoc ); } +#[pa_test_scratch::pa_test] #[test] #[ignore = "seeds ~12MB; asserts the interrupted-compaction contract"] fn interrupted_threshold_compaction_settles_consistent() { diff --git a/crates/pa-daemon/tests/compaction_mega_trace_e2e.rs b/crates/pa-daemon/tests/compaction_mega_trace_e2e.rs index 98cc3e588..a26c4e991 100644 --- a/crates/pa-daemon/tests/compaction_mega_trace_e2e.rs +++ b/crates/pa-daemon/tests/compaction_mega_trace_e2e.rs @@ -332,6 +332,7 @@ fn read_trace(path: &Path) -> Vec<(String, u128, Value)> { // Measurement harness, not a correctness test: seeds a ~50MB session and // prints the phase table; run explicitly with --ignored. +#[pa_test_scratch::pa_test] #[test] #[ignore = "measurement harness: seeds ~50MB and prints the phase table"] fn mega_session_threshold_compaction_phase_measurement() { diff --git a/crates/pa-daemon/tests/compaction_outcome_e2e.rs b/crates/pa-daemon/tests/compaction_outcome_e2e.rs index ac4cd1c30..4f41ec6c1 100644 --- a/crates/pa-daemon/tests/compaction_outcome_e2e.rs +++ b/crates/pa-daemon/tests/compaction_outcome_e2e.rs @@ -368,6 +368,7 @@ impl Client { } } +#[pa_test_scratch::pa_test] #[test] fn forced_failed_auto_compaction_records_the_durable_outcome_row() { let dir = tempfile::tempdir().expect("temp dir"); diff --git a/crates/pa-daemon/tests/compaction_summary_stream_e2e.rs b/crates/pa-daemon/tests/compaction_summary_stream_e2e.rs index 5e909e3d4..db16bfb15 100644 --- a/crates/pa-daemon/tests/compaction_summary_stream_e2e.rs +++ b/crates/pa-daemon/tests/compaction_summary_stream_e2e.rs @@ -374,6 +374,7 @@ impl Client { } } +#[pa_test_scratch::pa_test] #[test] fn threshold_compaction_streams_summary_deltas_to_attached_clients() { let dir = tempfile::tempdir().expect("temp dir"); diff --git a/crates/pa-daemon/tests/context_latency_e2e.rs b/crates/pa-daemon/tests/context_latency_e2e.rs index fda3d3a7d..c5f78ef5a 100644 --- a/crates/pa-daemon/tests/context_latency_e2e.rs +++ b/crates/pa-daemon/tests/context_latency_e2e.rs @@ -52,6 +52,7 @@ struct Daemon { impl Drop for Daemon { fn drop(&mut self) { + let _timing_span = pa_test_scratch::timing::span("teardown.process"); let _ = self.child.kill(); let _ = self.child.wait(); } @@ -60,6 +61,7 @@ impl Drop for Daemon { // The timeout panic path cannot wait on the child; the test process exits and reaps it. #[allow(clippy::zombie_processes)] fn spawn_daemon(socket: &std::path::Path, agent_dir: &std::path::Path) -> Daemon { + let _timing_span = pa_test_scratch::timing::span("setup.process_and_ready"); let binary = env!("CARGO_BIN_EXE_pa-daemon"); let child = Command::new(binary) .arg("supervisor") @@ -91,6 +93,7 @@ struct Client { impl Client { fn connect(socket: &std::path::Path) -> (Self, serde_json::Value) { + let _timing_span = pa_test_scratch::timing::span("setup.connect_wait"); let deadline = Instant::now() + Duration::from_secs(5); loop { if let Ok(stream) = UnixStream::connect(socket) { @@ -137,6 +140,7 @@ impl Client { /// One command round trip with its elapsed wall time; non-response frames are skipped. fn read_response(&mut self, id: &str) -> (Duration, serde_json::Value) { + let _timing_span = pa_test_scratch::timing::span("run.response_wait"); let deadline = Instant::now() + Duration::from_secs(60); loop { assert!(Instant::now() < deadline, "no response for {id} arrived"); @@ -169,6 +173,7 @@ fn scripted_turn(client: &mut Client, session_id: &str, text: &str, id: &str) { /// walk pays a real parse cost per child. fn seed_child_session(dir: &std::path::Path, child_id: &str) { const CHILD_HEADER_ROWS: u64 = 1; + let fixture_generation = pa_test_scratch::timing::span("setup.fixture_generation"); std::fs::create_dir_all(dir).expect("child dir"); let file = dir.join(format!("{child_id}.jsonl")); let filler = "x".repeat(SEEDED_ASSISTANT_CONTENT_KB * 1024); @@ -204,12 +209,14 @@ fn seed_child_session(dir: &std::path::Path, child_id: &str) { content.push('\n'); parent_id = Some(entry_id); } + drop(fixture_generation); assert_eq!( write_session_rows(&file, &content), SEEDED_MESSAGES_PER_CHILD as u64 + CHILD_HEADER_ROWS ); } +#[pa_test_scratch::pa_test] #[test] fn get_context_tree_answers_from_memory_on_a_grown_store() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -294,6 +301,7 @@ fn get_context_tree_answers_from_memory_on_a_grown_store() { // Every read must answer under the ceiling, cold or warm: the root is in-memory // and the children come from the cache (a cold cache serves the live rows alone). + let _cache_wait = pa_test_scratch::timing::span("run.cache_wait"); let mut saw_seeded_children = false; let deadline = Instant::now() + CACHE_FILL_DEADLINE; let mut reads = 0; @@ -348,6 +356,7 @@ fn get_context_tree_answers_from_memory_on_a_grown_store() { mod session_fixture; fn write_session_rows(path: &std::path::Path, content: &str) -> u64 { + let _timing_span = pa_test_scratch::timing::span("setup.fixture_log_write"); let mut fixture = session_fixture::BulkSessionFixture::new(path); for line in content.lines().filter(|line| !line.is_empty()) { let row: serde_json::Value = serde_json::from_str(line).expect("fixture row"); @@ -356,6 +365,7 @@ fn write_session_rows(path: &std::path::Path, content: &str) -> u64 { fixture.finish() } +#[pa_test_scratch::pa_test] #[test] #[ignore = "expensive old durable path; run explicitly for fixture byte equivalence"] fn static_child_fixtures_match_the_durable_writer() { diff --git a/crates/pa-daemon/tests/create_join_e2e.rs b/crates/pa-daemon/tests/create_join_e2e.rs index 0f528aac6..fa7a92226 100644 --- a/crates/pa-daemon/tests/create_join_e2e.rs +++ b/crates/pa-daemon/tests/create_join_e2e.rs @@ -247,6 +247,7 @@ fn write_padded_session_file(dir: &Path) -> PathBuf { path } +#[pa_test_scratch::pa_test] #[test] fn concurrent_creates_join_the_first_create() { let dir = diff --git a/crates/pa-daemon/tests/create_reuse_e2e.rs b/crates/pa-daemon/tests/create_reuse_e2e.rs index 78411d156..f07db18bf 100644 --- a/crates/pa-daemon/tests/create_reuse_e2e.rs +++ b/crates/pa-daemon/tests/create_reuse_e2e.rs @@ -228,6 +228,7 @@ fn create_session(client: &mut Client, request_id: &str, config: &Value) -> (Str /// Kevin's reproducer, green: opening a saved session whose worker is already live /// answers the LIVE binding — never `Session is already active`. +#[pa_test_scratch::pa_test] #[test] fn create_over_a_live_worker_answers_the_live_binding() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -319,6 +320,7 @@ fn create_over_a_live_worker_answers_the_live_binding() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_lease_owner_names_the_live_worker_not_a_stale_inherited_id() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -350,6 +352,7 @@ fn the_lease_owner_names_the_live_worker_not_a_stale_inherited_id() { /// A stale binding (the file's previous worker is dead) keeps the launch path: the open /// succeeds, mints the successor, and the #2575 supersede re-attaches the old pane. +#[pa_test_scratch::pa_test] #[test] fn create_over_a_dead_workers_file_launches_and_rebinds() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -418,6 +421,7 @@ fn create_over_a_dead_workers_file_launches_and_rebinds() { assert_eq!(binding["sessionFile"].as_str(), Some(session_file.as_str())); } +#[pa_test_scratch::pa_test] #[test] fn concurrent_creates_for_one_file_share_a_single_launch() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/daemon_boot_reap_e2e.rs b/crates/pa-daemon/tests/daemon_boot_reap_e2e.rs index 69755779b..15c1e22c3 100644 --- a/crates/pa-daemon/tests/daemon_boot_reap_e2e.rs +++ b/crates/pa-daemon/tests/daemon_boot_reap_e2e.rs @@ -266,6 +266,7 @@ fn orphan_the_worker(daemon: &mut Daemon, agent_dir: &Path, socket: &Path, sessi /// The operator's exact report, end to end: kill -9 the daemon plus the descriptor loss, /// boot a new daemon on the SAME socket, open the session — the boot reaps the leftover. +#[pa_test_scratch::pa_test] #[test] fn boot_reap_clears_the_leftover_and_the_session_reopens() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -382,6 +383,7 @@ fn boot_reap_clears_the_leftover_and_the_session_reopens() { } } +#[pa_test_scratch::pa_test] #[test] fn boot_reap_never_touches_a_different_socket_daemon() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/direct_attach_e2e.rs b/crates/pa-daemon/tests/direct_attach_e2e.rs index b7d1203fe..4e6af30d5 100644 --- a/crates/pa-daemon/tests/direct_attach_e2e.rs +++ b/crates/pa-daemon/tests/direct_attach_e2e.rs @@ -288,6 +288,7 @@ fn peer_auth(worker: &mut WorkerClient, ticket: &Value) -> Value { ) } +#[pa_test_scratch::pa_test] #[test] fn direct_attach_ticket_streams_across_supervisor_kill9() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -542,6 +543,7 @@ fn direct_attach_ticket_streams_across_supervisor_kill9() { } } +#[pa_test_scratch::pa_test] #[test] fn unused_ticket_expires() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/fd_lifecycle_e2e.rs b/crates/pa-daemon/tests/fd_lifecycle_e2e.rs index f561def37..3cd6d13c8 100644 --- a/crates/pa-daemon/tests/fd_lifecycle_e2e.rs +++ b/crates/pa-daemon/tests/fd_lifecycle_e2e.rs @@ -223,6 +223,7 @@ const CYCLES: usize = 20; /// fds that may legitimately sit open on top of the steady state. const FD_SLACK: usize = 6; +#[pa_test_scratch::pa_test] #[test] fn supervisor_fd_count_stable_across_session_cycles() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -345,6 +346,7 @@ fn supervisor_fd_count_stable_across_session_cycles() { ); } +#[pa_test_scratch::pa_test] #[test] fn worker_fd_count_stable_across_prompts() { const PROMPTS: usize = 30; @@ -519,6 +521,7 @@ fn worker_socket_path(agent_dir: &Path, socket: &Path, worker_id: &str) -> PathB PathBuf::from(value["socketPath"].as_str().expect("socket path")) } +#[pa_test_scratch::pa_test] #[test] fn worker_fd_table_stable_across_client_connection_churn() { const PROBES: usize = 15; @@ -628,6 +631,7 @@ fn worker_fd_table_stable_across_client_connection_churn() { /// The supervisor's restart loop must not leak worker processes when the create replay /// keeps failing (a corrupt session store): each failed relaunch kills the worker it /// spawned (the "failure 4/5 restart loop" shape from the EMFILE report). +#[pa_test_scratch::pa_test] #[test] fn supervisor_restart_loop_leaves_no_orphan_workers() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -719,6 +723,7 @@ fn supervisor_restart_loop_leaves_no_orphan_workers() { /// A supervisor started under a low soft fd limit raises it to the hard /// limit before it binds its socket (macOS starts every process at 256). #[cfg(target_os = "linux")] +#[pa_test_scratch::pa_test] #[test] fn supervisor_raises_a_low_soft_fd_limit_to_the_hard_limit() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/fork_isolation_e2e.rs b/crates/pa-daemon/tests/fork_isolation_e2e.rs index 4499ca3e3..cc77d3e3e 100644 --- a/crates/pa-daemon/tests/fork_isolation_e2e.rs +++ b/crates/pa-daemon/tests/fork_isolation_e2e.rs @@ -215,6 +215,7 @@ fn session_dir_text(session_dir: &std::path::Path) -> String { .join("\n") } +#[pa_test_scratch::pa_test] #[test] fn the_fork_is_a_fully_detached_session() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -559,6 +560,7 @@ fn wait_socket_accepts(socket: &std::path::Path) { /// FINDING 3's restart pin: a failed identity persist, then a restart — the boot serves /// the NEW identity (reconciles from live worker state before routing). +#[pa_test_scratch::pa_test] #[test] fn a_restart_after_a_failed_identity_persist_serves_the_moved_session() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/goal_branch_reload_e2e.rs b/crates/pa-daemon/tests/goal_branch_reload_e2e.rs index 834134972..345fe5da9 100644 --- a/crates/pa-daemon/tests/goal_branch_reload_e2e.rs +++ b/crates/pa-daemon/tests/goal_branch_reload_e2e.rs @@ -380,6 +380,7 @@ fn message_text(content: &Value) -> Option { } } +#[pa_test_scratch::pa_test] #[test] fn navigate_tree_moves_follow_the_branchs_goal_state() { let mut harness = setup("goal-branch-reload"); @@ -451,6 +452,7 @@ fn navigate_tree_moves_follow_the_branchs_goal_state() { /// The clear's reply reflects the action it took (the operator's 2026-09-25 bug report): /// clearing a held record answers "Goal cleared.", never the post-state read's text. +#[pa_test_scratch::pa_test] #[test] fn goal_clear_answers_the_action_it_took() { let mut harness = setup("goal-clear-reply"); diff --git a/crates/pa-daemon/tests/goal_recovery_e2e.rs b/crates/pa-daemon/tests/goal_recovery_e2e.rs index 86352100f..6be81b74a 100644 --- a/crates/pa-daemon/tests/goal_recovery_e2e.rs +++ b/crates/pa-daemon/tests/goal_recovery_e2e.rs @@ -369,6 +369,7 @@ impl Harness { } } +#[pa_test_scratch::pa_test] #[test] fn killed_mid_goal_worker_rehydrates_the_goal_with_counts() { let mut harness = setup("goal-recovery"); @@ -611,6 +612,7 @@ fn killed_mid_goal_worker_rehydrates_the_goal_with_counts() { /// `red-goal-recovery-faux-exhaustion-20260926-1`: the goal-continuation loop's unbounded /// churn can empty a finite script queue mid-flow; the last scripted reply's `message_end` /// is the witness. +#[pa_test_scratch::pa_test] #[test] fn repeat_last_script_stays_answerable_once_the_goal_churn_empties_it() { let mut harness = setup("goal-recovery-exhaustion"); diff --git a/crates/pa-daemon/tests/herdr_pane_e2e.rs b/crates/pa-daemon/tests/herdr_pane_e2e.rs index e0d8fc186..887b71815 100644 --- a/crates/pa-daemon/tests/herdr_pane_e2e.rs +++ b/crates/pa-daemon/tests/herdr_pane_e2e.rs @@ -266,6 +266,7 @@ fn pane_env(herdr_socket: &Path, pane_id: &str) -> Value { /// the pane its create payload carried — idle with the session file /// reference at the create, working at the turn start, idle at the /// settle, and the release as the kill's last write, with silence after. +#[pa_test_scratch::pa_test] #[test] fn the_session_reports_its_payload_pane_across_the_lifecycle() { let Some(kernel_python) = kernel_python() else { @@ -397,6 +398,7 @@ fn the_session_reports_its_payload_pane_across_the_lifecycle() { /// hostile ambient env never produces a boot-context report — until the /// pane that opens it attaches its identity, which the session ADOPTS /// (adopt-if-absent), reports for, and releases at its stop. +#[pa_test_scratch::pa_test] #[test] fn an_envless_session_stays_silent_until_its_attach_adopts_the_pane() { let Some(kernel_python) = kernel_python() else { diff --git a/crates/pa-daemon/tests/hold_refusal_e2e.rs b/crates/pa-daemon/tests/hold_refusal_e2e.rs index 5ccde242e..093c84523 100644 --- a/crates/pa-daemon/tests/hold_refusal_e2e.rs +++ b/crates/pa-daemon/tests/hold_refusal_e2e.rs @@ -187,6 +187,7 @@ fn create_session(client: &mut Client, request_id: &str, config: &Value) -> (Str /// A create over a file another daemon's live worker holds answers the /// session-hold refusal with the typed wire info. +#[pa_test_scratch::pa_test] #[test] fn a_foreign_lease_holder_rejects_the_create_with_the_hold_refusal() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/idle_passivation_e2e.rs b/crates/pa-daemon/tests/idle_passivation_e2e.rs index fbc78b60d..183523036 100644 --- a/crates/pa-daemon/tests/idle_passivation_e2e.rs +++ b/crates/pa-daemon/tests/idle_passivation_e2e.rs @@ -206,6 +206,7 @@ fn write_faux_script(dir: &Path, name: &str, responses: &Value) -> PathBuf { /// `agent_message.send` WAKES a fresh worker over the child's session /// file and delivers. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_settled_child_passivates_stays_listable_and_revives_by_agent_message() { let Some(kernel_python) = kernel_python() else { return; @@ -523,6 +524,7 @@ fn root_worker_ids(agent_dir: &Path) -> Vec { /// wake retry `prompt_child` carries: the retry's wake launches a fresh /// worker over the child's session file and the rename lands there. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_parent_rename_after_a_revival_and_second_passivation_reaches_the_child() { let Some(kernel_python) = kernel_python() else { return; @@ -767,6 +769,7 @@ async fn a_parent_rename_after_a_revival_and_second_passivation_reaches_the_chil /// by its durable session id: the attach wakes a fresh worker over the /// saved file and the snapshot carries the pre-passivation transcript. #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_idle_root_passivates_and_resumes_by_its_durable_id_with_its_transcript() { let Some(kernel_python) = kernel_python() else { return; diff --git a/crates/pa-daemon/tests/import_compaction_e2e.rs b/crates/pa-daemon/tests/import_compaction_e2e.rs index ff1d09be9..ea51c2347 100644 --- a/crates/pa-daemon/tests/import_compaction_e2e.rs +++ b/crates/pa-daemon/tests/import_compaction_e2e.rs @@ -313,6 +313,7 @@ fn session_rows(harness: &Harness, type_: &str) -> Vec { .collect() } +#[pa_test_scratch::pa_test] #[test] fn imported_session_compacts() { let mut harness = setup("import-compact"); diff --git a/crates/pa-daemon/tests/kernel_dispose_e2e.rs b/crates/pa-daemon/tests/kernel_dispose_e2e.rs index efbbf51ab..8c0d10b46 100644 --- a/crates/pa-daemon/tests/kernel_dispose_e2e.rs +++ b/crates/pa-daemon/tests/kernel_dispose_e2e.rs @@ -318,6 +318,7 @@ fn await_receipt(dir: &Path) { } } +#[pa_test_scratch::pa_test] #[test] fn kill_disposes_the_session_kernel() { let Some(kernel_python) = kernel_python() else { @@ -356,6 +357,7 @@ fn kill_disposes_the_session_kernel() { /// Daemon `shutdown` routes a `shutdown` to every worker: each disposes its kernel /// before its own process exit (no destructors run on `std::process::exit`). +#[pa_test_scratch::pa_test] #[test] fn shutdown_disposes_session_kernels_before_the_worker_exits() { let Some(kernel_python) = kernel_python() else { @@ -384,6 +386,7 @@ fn shutdown_disposes_session_kernels_before_the_worker_exits() { await_kernels_gone(&baseline, Duration::from_secs(90)); } +#[pa_test_scratch::pa_test] #[test] fn orphan_exit_disposes_the_kernel_before_the_worker_exits() { let Some(kernel_python) = kernel_python() else { diff --git a/crates/pa-daemon/tests/launch_env_e2e.rs b/crates/pa-daemon/tests/launch_env_e2e.rs index 57d756445..0d6ae8aa2 100644 --- a/crates/pa-daemon/tests/launch_env_e2e.rs +++ b/crates/pa-daemon/tests/launch_env_e2e.rs @@ -328,6 +328,7 @@ fn session_header_depth(session_file: &Path) -> u64 { /// workers stamp depth-0 root headers, and the durable descriptor for /// A carries no trace of the client env. #[cfg(target_os = "linux")] // /proc//environ +#[pa_test_scratch::pa_test] #[test] fn the_client_launch_env_reaches_only_its_own_worker() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -413,6 +414,7 @@ fn the_client_launch_env_reaches_only_its_own_worker() { /// The kernel under the worker runs in the client's env too (the audit /// #1 repro: `bash()`/kernel subprocesses see the terminal's PATH, not /// the daemon's). One scripted cell writes its `os.environ` to a receipt. +#[pa_test_scratch::pa_test] #[test] fn the_kernel_runs_in_the_client_launch_env() { let Some(kernel_python) = kernel_python() else { @@ -494,6 +496,7 @@ fn the_kernel_runs_in_the_client_launch_env() { /// along. #[cfg(target_os = "linux")] // /proc//environ #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_rlm_spawn_child_inherits_the_parent_worker_env() { use pa_core::session_engine::rlm_host::{RlmSpawnRequest, RlmSubagentHost}; use pa_daemon::rlm_children::{ParentIdentity, SupervisorChildSessions}; @@ -586,6 +589,7 @@ async fn an_rlm_spawn_child_inherits_the_parent_worker_env() { /// The update-restart roster's `launch_env` rows respawn workers with the /// supervisor's INTERNAL identity only: the client env a session was /// created with never lands in the durable roster. +#[pa_test_scratch::pa_test] #[test] fn the_update_roster_never_carries_the_client_env() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/mcp_product_path_e2e.rs b/crates/pa-daemon/tests/mcp_product_path_e2e.rs index 1bcfc479f..ae2400562 100644 --- a/crates/pa-daemon/tests/mcp_product_path_e2e.rs +++ b/crates/pa-daemon/tests/mcp_product_path_e2e.rs @@ -228,6 +228,7 @@ fn tool_result_texts(session_messages: &[Value]) -> Vec { .collect() } +#[pa_test_scratch::pa_test] #[test] fn settings_declared_stdio_server_round_trips_through_the_kernel_mcp_client() { let Some(kernel_python) = kernel_python() else { @@ -365,6 +366,7 @@ fn settings_declared_stdio_server_round_trips_through_the_kernel_mcp_client() { ); } +#[pa_test_scratch::pa_test] #[test] fn begin_login_host_request_is_live_in_the_worker() { let Some(kernel_python) = kernel_python() else { diff --git a/crates/pa-daemon/tests/model_catalog_e2e.rs b/crates/pa-daemon/tests/model_catalog_e2e.rs index 8ea8c446a..da1484b06 100644 --- a/crates/pa-daemon/tests/model_catalog_e2e.rs +++ b/crates/pa-daemon/tests/model_catalog_e2e.rs @@ -148,6 +148,7 @@ fn write_models_json(agent_dir: &Path, base_url: &str) { .expect("write models.json"); } +#[pa_test_scratch::pa_test] #[test] fn offline_daemon_serves_the_bundled_catalog_fallback() { let dir = std::env::temp_dir().join(format!( diff --git a/crates/pa-daemon/tests/model_facts_switch_e2e.rs b/crates/pa-daemon/tests/model_facts_switch_e2e.rs index 28231c217..c562f857d 100644 --- a/crates/pa-daemon/tests/model_facts_switch_e2e.rs +++ b/crates/pa-daemon/tests/model_facts_switch_e2e.rs @@ -279,6 +279,7 @@ fn read_receipt(client: &mut Client, session_id: &str, receipt: &Path, read_id: /// A `set_model` switch must rebind the kernel's model facts: the second /// turn's cell answers the switched-to model's `model.info` and context /// window, not the session-creation model's. +#[pa_test_scratch::pa_test] #[test] fn set_model_rebinds_the_kernel_model_facts() { let Some(kernel_python) = kernel_python() else { diff --git a/crates/pa-daemon/tests/orphan_journal_e2e.rs b/crates/pa-daemon/tests/orphan_journal_e2e.rs index b08a4a87b..5f019bebe 100644 --- a/crates/pa-daemon/tests/orphan_journal_e2e.rs +++ b/crates/pa-daemon/tests/orphan_journal_e2e.rs @@ -563,6 +563,7 @@ fn session_with_orphan( /// T1: a kernel killed without its shutdown hook must not leak the /// `bash()` groups it journaled — the worker's teardown reaps them. +#[pa_test_scratch::pa_test] #[test] fn a_killed_kernel_reaps_its_journaled_bash_groups() { static NEXT: AtomicUsize = AtomicUsize::new(0); @@ -590,6 +591,7 @@ fn a_killed_kernel_reaps_its_journaled_bash_groups() { /// T2: the stopped worker cannot run its own teardown reap when the /// kernel and worker die — only the supervisor can, from the journal the /// dead worker's kernel wrote. +#[pa_test_scratch::pa_test] #[test] fn a_dead_worker_reaps_its_journaled_bash_groups_from_the_supervisor() { static NEXT: AtomicUsize = AtomicUsize::new(0); diff --git a/crates/pa-daemon/tests/peer_messaging_e2e.rs b/crates/pa-daemon/tests/peer_messaging_e2e.rs index 60bc4e749..3e1e0068b 100644 --- a/crates/pa-daemon/tests/peer_messaging_e2e.rs +++ b/crates/pa-daemon/tests/peer_messaging_e2e.rs @@ -349,6 +349,7 @@ fn setup_messaging() -> Option { }) } +#[pa_test_scratch::pa_test] #[test] fn worker_to_worker_kernel_send_delivers_over_the_peer_transport() { let Some(messaging) = setup_messaging() else { @@ -432,6 +433,7 @@ fn worker_to_worker_kernel_send_delivers_over_the_peer_transport() { ); } +#[pa_test_scratch::pa_test] #[test] fn attached_client_to_client_send_completes_without_route_starvation() { let Some(messaging) = setup_messaging() else { @@ -517,6 +519,7 @@ fn attached_client_to_client_send_completes_without_route_starvation() { ); } +#[pa_test_scratch::pa_test] #[test] fn supervisor_death_mid_conversation_still_delivers_after_re_registration() { let Some(mut messaging) = setup_messaging() else { diff --git a/crates/pa-daemon/tests/protocol_breadth_b10_b11.rs b/crates/pa-daemon/tests/protocol_breadth_b10_b11.rs index 025c4137b..f186b7a2d 100644 --- a/crates/pa-daemon/tests/protocol_breadth_b10_b11.rs +++ b/crates/pa-daemon/tests/protocol_breadth_b10_b11.rs @@ -262,6 +262,7 @@ fn scripted_session( /// Wave b10: the scheduling catalog rides the supervisor route and answers /// the TS wire shapes against a live scripted session. +#[pa_test_scratch::pa_test] #[test] fn wave_b10_scheduling_wire_shapes() { let _serial = serial_lock(); @@ -410,6 +411,7 @@ fn wave_b10_scheduling_wire_shapes() { /// Wave b10: a scheduled once job actually fires into the session and the run bookkeeping /// lands in the catalog. +#[pa_test_scratch::pa_test] #[test] fn wave_b10_scheduled_prompt_fires() { let _serial = serial_lock(); @@ -468,6 +470,7 @@ fn wave_b10_scheduled_prompt_fires() { } /// Wave b10 selector-less catalog shapes on a fresh supervisor: the empty objects and refusals. +#[pa_test_scratch::pa_test] #[test] fn wave_b10_fresh_supervisor_catalog() { let _serial = serial_lock(); @@ -521,6 +524,7 @@ fn wave_b10_fresh_supervisor_catalog() { /// Wave b11: the saved-session catalog and peer-roster wire shapes — the fresh-supervisor /// error paths, the offline rename/delete, and the live rename. +#[pa_test_scratch::pa_test] #[test] fn wave_b11_saved_sessions_wire_shapes() { let _serial = serial_lock(); @@ -669,6 +673,7 @@ fn wave_b11_saved_sessions_wire_shapes() { /// The heartbeat-catalog snapshot fallback (TS `worker.heartbeatSnapshot`): a worker too /// busy to answer a fresh `heartbeats_list` serves its last-good rows; a worker whose snapshot /// went stale fails the response instead (TS `failed`). +#[pa_test_scratch::pa_test] #[test] fn wave_b10_heartbeat_snapshot_fallback() { let _serial = serial_lock(); @@ -725,6 +730,7 @@ fn wave_b10_heartbeat_snapshot_fallback() { /// TS #2487, the single-worker catalog: the served slice is the worker's own, so the merged /// responses are byte-identical to the fresh-forward ones. +#[pa_test_scratch::pa_test] #[test] fn wave_b10_single_worker_slice_is_byte_identical() { let _serial = serial_lock(); @@ -785,6 +791,7 @@ fn wave_b10_single_worker_slice_is_byte_identical() { /// TS #2487: the supervisor serves each worker's own catalog slice without reforwarding; /// a worker-side mutation bumps that worker's generation, so the next list consults it /// again (a frozen worker with no fresh slice fails the response, TS `failed`). +#[pa_test_scratch::pa_test] #[test] fn wave_b10_catalog_slices_served_without_reforwarding() { let _serial = serial_lock(); diff --git a/crates/pa-daemon/tests/protocol_breadth_b6_b9.rs b/crates/pa-daemon/tests/protocol_breadth_b6_b9.rs index 3e6175923..2a7cb1af7 100644 --- a/crates/pa-daemon/tests/protocol_breadth_b6_b9.rs +++ b/crates/pa-daemon/tests/protocol_breadth_b6_b9.rs @@ -262,6 +262,7 @@ fn scripted_session( (daemon, client, session_id, socket) } +#[pa_test_scratch::pa_test] #[test] fn wave_b6_rlm_surface_wire_shapes() { let _serial = serial_lock(); @@ -298,6 +299,7 @@ fn wave_b6_rlm_surface_wire_shapes() { ); } +#[pa_test_scratch::pa_test] #[test] fn wave_b7_agent_messages_wire_shapes() { let _serial = serial_lock(); @@ -380,6 +382,7 @@ fn wave_b7_agent_messages_wire_shapes() { } } +#[pa_test_scratch::pa_test] #[test] fn wave_b8_session_input_pause_wire_shapes() { let _serial = serial_lock(); @@ -443,6 +446,7 @@ fn wave_b8_session_input_pause_wire_shapes() { assert_eq!(response["data"], Value::Null); } +#[pa_test_scratch::pa_test] #[test] fn wave_b8_held_pause_gates_queued_input() { let _serial = serial_lock(); @@ -545,6 +549,7 @@ fn wave_b8_held_pause_gates_queued_input() { assert_eq!(response["data"]["steering"], json!([]), "{response}"); } +#[pa_test_scratch::pa_test] #[test] fn disconnect_mid_write_releases_the_held_input_pause() { let _serial = serial_lock(); @@ -655,6 +660,7 @@ fn disconnect_mid_write_releases_the_held_input_pause() { ); } +#[pa_test_scratch::pa_test] #[test] fn wave_b9_session_navigation_wire_shapes() { let _serial = serial_lock(); @@ -754,6 +760,7 @@ fn cancel_owned_admission( } } +#[pa_test_scratch::pa_test] #[test] fn wave_b9_prompt_admission_wire_shapes() { let _serial = serial_lock(); @@ -871,6 +878,7 @@ fn wave_b9_prompt_admission_wire_shapes() { assert_eq!(response["data"], json!({ "status": "unknown" })); } +#[pa_test_scratch::pa_test] #[test] fn wave_b9_owned_session_lifecycle_wire_shapes() { let _serial = serial_lock(); diff --git a/crates/pa-daemon/tests/provider_failover_e2e.rs b/crates/pa-daemon/tests/provider_failover_e2e.rs index 3fe72d945..4b288eb96 100644 --- a/crates/pa-daemon/tests/provider_failover_e2e.rs +++ b/crates/pa-daemon/tests/provider_failover_e2e.rs @@ -499,6 +499,7 @@ fn retry_end(events: &[Value]) -> &Value { .expect("auto_retry_end") } +#[pa_test_scratch::pa_test] #[test] fn provider_failure_fails_over_to_the_next_provider_and_recovers() { let primary = FailingMock::start(usize::MAX, ReplyMode::Text("never reached")); @@ -587,6 +588,7 @@ fn provider_failure_fails_over_to_the_next_provider_and_recovers() { ); } +#[pa_test_scratch::pa_test] #[test] fn every_provider_failing_surfaces_the_final_error() { let primary = FailingMock::start(usize::MAX, ReplyMode::Text("never reached")); @@ -651,6 +653,7 @@ fn every_provider_failing_surfaces_the_final_error() { assert_eq!(turn_end.get("error"), None, "turn_end: {turn_end}"); } +#[pa_test_scratch::pa_test] #[test] fn threshold_yield_keeps_the_backup_until_the_tool_run_finishes() { let primary = FailingMock::start(usize::MAX, ReplyMode::Text("never")); @@ -764,6 +767,7 @@ fn read_receipt(client: &mut Client, session_id: &str, receipt: &Path, read_id: /// primary facts while the in-episode provider requests stay on the backup. // Long by design: one failover flow asserted end to end. #[allow(clippy::too_many_lines)] +#[pa_test_scratch::pa_test] #[test] fn failover_switch_and_restore_rebind_the_kernel_model_facts() { let Some(kernel_python) = kernel_python() else { diff --git a/crates/pa-daemon/tests/provider_failure_e2e.rs b/crates/pa-daemon/tests/provider_failure_e2e.rs index 977989ce9..b208088dc 100644 --- a/crates/pa-daemon/tests/provider_failure_e2e.rs +++ b/crates/pa-daemon/tests/provider_failure_e2e.rs @@ -710,6 +710,7 @@ fn event_types(events: &[Value]) -> Vec { .collect() } +#[pa_test_scratch::pa_test] #[test] fn provider_failure_is_retried_then_surfaced_to_attached_clients() { let (_dir, mock, _supervisor, mut client, session_id) = setup("failing", 5, "never reached"); @@ -857,6 +858,7 @@ fn provider_failure_is_retried_then_surfaced_to_attached_clients() { /// The 429-storm simulation (operator ruling 2026-09-23): a rate-limiting provider gets /// bounded exponential backoff; Retry-After wins over the tiny base delay, and the episode /// leaves exactly ONE durable outcome row. +#[pa_test_scratch::pa_test] #[test] fn storm_429_caps_requests_honors_retry_after_and_leaves_one_outcome_row() { let (_dir, mock, _supervisor, mut client, session_id) = setup_with_rejection( @@ -965,6 +967,7 @@ fn storm_429_caps_requests_honors_retry_after_and_leaves_one_outcome_row() { /// THE 402 REGRESSION: a wallet-drain 402 must classify by STATUS (the `payment_required` /// kind, first attempt, no ladder) and still emit the disclosure row. +#[pa_test_scratch::pa_test] #[test] fn payment_402_settles_once_with_the_disclosure() { let (_dir, mock, _supervisor, mut client, session_id) = @@ -1013,6 +1016,7 @@ fn payment_402_settles_once_with_the_disclosure() { /// THE GOAL-SIDE 402 REGRESSION: a goal whose continuation turn dies on the wallet-drain /// 402 refuses the NEXT continuation and finishes the goal. The disclosure row still /// fires (BUG 1). +#[pa_test_scratch::pa_test] #[test] fn goal_continuation_refuses_after_the_402_corpse() { let (dir, mock, _supervisor, mut client, session_id) = setup_with_rejection( @@ -1210,6 +1214,7 @@ fn read_exact_soft( Some(()) } +#[pa_test_scratch::pa_test] #[test] fn provider_failure_surfaces_on_the_direct_transport_path() { let (_dir, mock, _supervisor, mut client, session_id) = setup("direct", 5, "never reached"); @@ -1312,6 +1317,7 @@ fn provider_failure_surfaces_on_the_direct_transport_path() { assert_eq!(mock.count(), 3, "requests: initial + 2 retries"); } +#[pa_test_scratch::pa_test] #[test] fn provider_failure_recovered_by_retry_settles_the_turn() { let (_dir, mock, _supervisor, mut client, session_id) = setup("healing", 2, "recovered reply"); @@ -1421,6 +1427,7 @@ fn provider_failure_recovered_by_retry_settles_the_turn() { ); } +#[pa_test_scratch::pa_test] #[test] fn socket_presence_is_not_readiness_until_listen_succeeds() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -1463,6 +1470,7 @@ fn socket_presence_is_not_readiness_until_listen_succeeds() { drop(stream); } +#[pa_test_scratch::pa_test] #[test] fn readiness_reports_child_exit_instead_of_waiting_on_a_stale_socket() { use std::os::unix::process::ExitStatusExt; diff --git a/crates/pa-daemon/tests/queue_delivery_e2e.rs b/crates/pa-daemon/tests/queue_delivery_e2e.rs index 9db7a5d22..356ca40c0 100644 --- a/crates/pa-daemon/tests/queue_delivery_e2e.rs +++ b/crates/pa-daemon/tests/queue_delivery_e2e.rs @@ -535,6 +535,7 @@ fn action_updates_with(events: &[Value], steering: &[&str], follow_ups: &[&str]) .collect() } +#[pa_test_scratch::pa_test] #[test] fn queue_pickup_projection_reaches_clients_before_the_delivered_turn_starts() { let (_dir, mock, _supervisor, mut client, session_id) = setup("queue-pickup"); @@ -641,6 +642,7 @@ fn queue_pickup_projection_reaches_clients_before_the_delivered_turn_starts() { ); } +#[pa_test_scratch::pa_test] #[test] fn multi_item_queue_delivers_every_item_in_lane_order() { let (_dir, mock, _supervisor, mut client, session_id) = setup("queue-multi"); @@ -725,6 +727,7 @@ fn multi_item_queue_delivers_every_item_in_lane_order() { /// TS #2063 (RES-1306): a queue-visible delivery's active action rides the turn through /// its client-rendered phases; the settle's projection carries no active action. +#[pa_test_scratch::pa_test] #[test] fn queue_delivery_projects_the_active_action_phases_around_the_turn() { let (_dir, mock, _supervisor, mut client, session_id) = setup("active-action-phases"); diff --git a/crates/pa-daemon/tests/readoption_wake_e2e.rs b/crates/pa-daemon/tests/readoption_wake_e2e.rs index 67b15049d..dfe116ac3 100644 --- a/crates/pa-daemon/tests/readoption_wake_e2e.rs +++ b/crates/pa-daemon/tests/readoption_wake_e2e.rs @@ -374,6 +374,7 @@ fn create_session(client: &mut Client, id: &str, dir: &Path, agent_dir: &Path) - (active_id, session_id) } +#[pa_test_scratch::pa_test] #[test] fn a_detached_bash_completion_wakes_the_idle_session_across_a_supervisor_restart() { static NEXT: AtomicUsize = AtomicUsize::new(0); @@ -476,6 +477,7 @@ fn a_detached_bash_completion_wakes_the_idle_session_across_a_supervisor_restart ); } +#[pa_test_scratch::pa_test] #[test] fn a_heartbeat_keeps_firing_across_a_supervisor_restart() { let root = tempfile::TempDir::new().expect("temp dir"); @@ -594,6 +596,7 @@ fn a_heartbeat_keeps_firing_across_a_supervisor_restart() { /// Boot-time wake vs the storm gates (the ~200-agent boot crash class): the ADOPTED-ALIVE /// worker fires, the KILLED sibling never resurrects (#2592/#2642 gates hold). +#[pa_test_scratch::pa_test] #[test] fn a_boot_fires_the_adopted_worker_due_job_and_never_resurrects_the_killed_sibling() { let root = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/recovery_control_plane_e2e.rs b/crates/pa-daemon/tests/recovery_control_plane_e2e.rs index 4241c10f5..93b77373c 100644 --- a/crates/pa-daemon/tests/recovery_control_plane_e2e.rs +++ b/crates/pa-daemon/tests/recovery_control_plane_e2e.rs @@ -223,6 +223,7 @@ impl Client { /// race the control plane. const SESSIONS: usize = 12; +#[pa_test_scratch::pa_test] #[test] fn control_plane_stays_responsive_while_a_large_adoption_pass_recovers() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/registration_refusal_heal_e2e.rs b/crates/pa-daemon/tests/registration_refusal_heal_e2e.rs index 58d9a7074..1e8e19dd1 100644 --- a/crates/pa-daemon/tests/registration_refusal_heal_e2e.rs +++ b/crates/pa-daemon/tests/registration_refusal_heal_e2e.rs @@ -263,6 +263,7 @@ fn run_one_turn(client: &mut Client, id: &str, request_id: &str) { assert_eq!(done["success"], true, "scripted turn failed: {done}"); } +#[pa_test_scratch::pa_test] #[test] fn a_refused_registration_retires_the_worker() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -349,6 +350,7 @@ fn a_refused_registration_retires_the_worker() { } /// The box incident, end to end. +#[pa_test_scratch::pa_test] #[test] fn a_descriptorless_leftover_dies_and_its_session_resumes() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -435,6 +437,7 @@ fn a_descriptorless_leftover_dies_and_its_session_resumes() { drop(daemon2); } +#[pa_test_scratch::pa_test] #[test] fn an_owned_stop_kills_a_worker_that_missed_the_shutdown() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/replacement_kernel_e2e.rs b/crates/pa-daemon/tests/replacement_kernel_e2e.rs index 3d1faa856..36242cff1 100644 --- a/crates/pa-daemon/tests/replacement_kernel_e2e.rs +++ b/crates/pa-daemon/tests/replacement_kernel_e2e.rs @@ -404,6 +404,7 @@ fn first_user_entry_id(client: &mut Client, session_id: &str, id: &str) -> Strin } /// `new_session` (TS `teardownForReplacement`): the old kernel dies, the fresh kernel is COLD. +#[pa_test_scratch::pa_test] #[test] fn new_session_disposes_the_kernel_and_starts_cold() { let Some(kernel_python) = kernel_python() else { @@ -445,6 +446,7 @@ fn new_session_disposes_the_kernel_and_starts_cold() { /// `switch_session` (TS `teardownForReplacement`): a prepared target replaces the runtime /// (cold); a MISSING target fails at the prepare, leaving the live kernel untouched. +#[pa_test_scratch::pa_test] #[test] fn switch_session_disposes_the_kernel_and_a_failed_target_keeps_it() { let Some(kernel_python) = kernel_python() else { @@ -527,6 +529,7 @@ fn switch_session_disposes_the_kernel_and_a_failed_target_keeps_it() { } /// `fork` (TS `teardownForReplacement`): a whole-runtime replacement; the fork's kernel boots cold. +#[pa_test_scratch::pa_test] #[test] fn fork_disposes_the_kernel_and_starts_cold() { let Some(kernel_python) = kernel_python() else { @@ -578,6 +581,7 @@ fn fork_disposes_the_kernel_and_starts_cold() { /// The switch cwd rebind (TS `createRuntime({ cwd: sessionManager.getCwd() })`): the /// post-switch kernel's `os.getcwd()` is the switched-to session's working directory. +#[pa_test_scratch::pa_test] #[test] fn switch_session_rebinds_the_kernel_cwd_onto_the_target_session() { let Some(kernel_python) = kernel_python() else { @@ -681,6 +685,7 @@ fn switch_session_rebinds_the_kernel_cwd_onto_the_target_session() { /// `navigate_tree` (TS `AgentSession.navigateTree`): a tree move is NOT a runtime replacement; /// the namespace stays WARM (the marker set before the move survives it). +#[pa_test_scratch::pa_test] #[test] fn navigate_tree_keeps_the_kernel_warm() { let Some(kernel_python) = kernel_python() else { diff --git a/crates/pa-daemon/tests/rlm_child_usage_attribution_e2e.rs b/crates/pa-daemon/tests/rlm_child_usage_attribution_e2e.rs index 7b91fb22b..9d4c59827 100644 --- a/crates/pa-daemon/tests/rlm_child_usage_attribution_e2e.rs +++ b/crates/pa-daemon/tests/rlm_child_usage_attribution_e2e.rs @@ -462,6 +462,7 @@ fn settled_child_usage(child_file: &Path) -> Value { /// `child_usage_attributed` row in the TS shape, targeting the durable assistant row /// that issued the spawn; a fresh reopen of the parent file folds the aggregate (the /// resume semantics). +#[pa_test_scratch::pa_test] #[test] fn child_usage_attributed_row_reaches_the_parent_transcript() { let _guard = test_lock(); @@ -608,6 +609,7 @@ impl Drop for GitGate { /// A real child sends a parent message before settling its usage. Both owner /// deliveries must leave the parent's canonical source usable for the next turn. +#[pa_test_scratch::pa_test] #[test] fn child_message_then_usage_preserves_parent_read_and_next_prompt() { let _guard = test_lock(); diff --git a/crates/pa-daemon/tests/rlm_children_e2e.rs b/crates/pa-daemon/tests/rlm_children_e2e.rs index 65a3a4eca..1f69d1b0a 100644 --- a/crates/pa-daemon/tests/rlm_children_e2e.rs +++ b/crates/pa-daemon/tests/rlm_children_e2e.rs @@ -243,6 +243,7 @@ fn spawn_request(name: &str, prompt: &str) -> RlmSpawnRequest { /// Spawn a child through the supervisor, observe it in both rosters, collect its answer, /// then delete it (both rosters drop it). #[tokio::test] +#[pa_test_scratch::pa_test] async fn rlm_children_spawn_roster_collect_delete_end_to_end() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("daemon.sock"); @@ -501,6 +502,7 @@ async fn rlm_children_spawn_roster_collect_delete_end_to_end() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn rlm_create_session_spawns_a_prompted_depth_zero_session() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("daemon.sock"); @@ -574,6 +576,7 @@ async fn rlm_create_session_spawns_a_prompted_depth_zero_session() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn rlm_recursion_bound_is_enforced() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("daemon.sock"); @@ -611,6 +614,7 @@ async fn rlm_recursion_bound_is_enforced() { /// reservation for the whole fresh-launch admission; once the winner is gone, the name /// admits again. #[tokio::test] +#[pa_test_scratch::pa_test] async fn parallel_same_name_subagent_creates_admit_exactly_one() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("daemon.sock"); diff --git a/crates/pa-daemon/tests/rlm_children_parent_death_e2e.rs b/crates/pa-daemon/tests/rlm_children_parent_death_e2e.rs index f8e330096..ff65b0b91 100644 --- a/crates/pa-daemon/tests/rlm_children_parent_death_e2e.rs +++ b/crates/pa-daemon/tests/rlm_children_parent_death_e2e.rs @@ -390,6 +390,7 @@ fn sigkill(pid: u32) { /// as a settled row from the surviving spawn edge, and the child stays /// visible as a passive ledger row (the close is a plain stop - the /// spawn edge survives, no delete record). +#[pa_test_scratch::pa_test] #[test] fn sigkill_closes_the_spawned_child_and_passivates_the_row() { let Some(kernel_python) = kernel_python() else { @@ -530,6 +531,7 @@ fn sigkill_closes_the_spawned_child_and_passivates_the_row() { /// `rlm.create_session` depth-0 roots are NOT parent-linked (TS `createRlmRootSession` /// carries no `parentActiveSessionId`, so `getChildActiveSessionStates` never matches /// them): a created root survives the parent's hard death. +#[pa_test_scratch::pa_test] #[test] fn sigkill_keeps_a_created_root_session_running() { let Some(kernel_python) = kernel_python() else { @@ -642,6 +644,7 @@ fn semantic_ledger(path: &Path) -> Vec { /// `recordChildReturned`; the spawn runs mid-turn through the product /// `rlm.spawn` surface, and both engines are real over the faux /// provider). +#[pa_test_scratch::pa_test] #[test] fn a_spawned_child_ledger_names_its_spawning_request_and_the_parent_records_the_return() { let Some(kernel_python) = kernel_python() else { diff --git a/crates/pa-daemon/tests/rlm_children_replacement_e2e.rs b/crates/pa-daemon/tests/rlm_children_replacement_e2e.rs index 8c9b3f0b5..74235ce6d 100644 --- a/crates/pa-daemon/tests/rlm_children_replacement_e2e.rs +++ b/crates/pa-daemon/tests/rlm_children_replacement_e2e.rs @@ -363,6 +363,7 @@ fn create_parent( created["data"].clone() } +#[pa_test_scratch::pa_test] #[test] fn new_session_closes_the_spawned_child_and_empties_the_roster() { let Some(kernel_python) = kernel_python() else { @@ -493,6 +494,7 @@ fn new_session_closes_the_spawned_child_and_empties_the_roster() { /// `rlm.create_session` root sessions are NOT parent-linked, so /// `closeChildSessions` never matches them. +#[pa_test_scratch::pa_test] #[test] fn new_session_keeps_a_created_root_session_running() { let Some(kernel_python) = kernel_python() else { @@ -574,11 +576,13 @@ fn new_session_keeps_a_created_root_session_running() { /// A daemon restart must not lose the parent's RLM children: the /// reattached parent lists its child again and messaging it wakes the child. +#[pa_test_scratch::pa_test] #[test] fn a_daemon_restart_relists_and_wakes_the_parents_child() { restart_relists_child(0, "completed"); } +#[pa_test_scratch::pa_test] #[test] fn a_daemon_restart_marks_a_still_running_child_as_failed() { restart_relists_child(30_000, "running"); diff --git a/crates/pa-daemon/tests/rlm_quiescence_barrier_e2e.rs b/crates/pa-daemon/tests/rlm_quiescence_barrier_e2e.rs index 9a1b63bbc..1f6f81be3 100644 --- a/crates/pa-daemon/tests/rlm_quiescence_barrier_e2e.rs +++ b/crates/pa-daemon/tests/rlm_quiescence_barrier_e2e.rs @@ -349,6 +349,7 @@ fn spawn_held_child_lane(kernel_python: &Path) -> HeldChildLane { /// The barrier must answer only after the held child turn settles and the /// terminal notice it queues drains; a child with running subagents is not /// idle until its whole subtree settled. +#[pa_test_scratch::pa_test] #[test] fn wait_for_idle_waits_for_rlm_quiescence() { let Some(kernel_python) = kernel_python() else { @@ -384,6 +385,7 @@ fn wait_for_idle_waits_for_rlm_quiescence() { /// barrier sent once the roster says `done` must still hold for the /// terminal notice's parent turn; a status-reading barrier answers /// inside the settle window. +#[pa_test_scratch::pa_test] #[test] fn wait_for_idle_holds_through_the_settle_window() { let Some(kernel_python) = kernel_python() else { diff --git a/crates/pa-daemon/tests/rlm_roster_walk_e2e.rs b/crates/pa-daemon/tests/rlm_roster_walk_e2e.rs index 4dac3bcf5..aac6d8e09 100644 --- a/crates/pa-daemon/tests/rlm_roster_walk_e2e.rs +++ b/crates/pa-daemon/tests/rlm_roster_walk_e2e.rs @@ -247,6 +247,7 @@ fn write_synthetic_family(agent_dir: &Path, children: usize) -> (PathBuf, usize) (root_path, live) } +#[pa_test_scratch::pa_test] #[test] fn list_all_returns_the_full_synthetic_thousand_child_roster() { const CHILDREN: usize = 1_000; @@ -298,6 +299,7 @@ fn list_all_returns_the_full_synthetic_thousand_child_roster() { /// stop (no tombstone) the child survives as a seeded passive row, in the /// existing subscriber's push and in a fresh subscriber's snapshot. #[tokio::test] +#[pa_test_scratch::pa_test] async fn subscribe_after_spawn_then_shutdown_seeds_the_passive_child() { use pa_core::session_engine::rlm_host::{RlmSpawnRequest, RlmSubagentHost}; use pa_daemon::rlm_children::{ParentIdentity, SupervisorChildSessions}; diff --git a/crates/pa-daemon/tests/rlm_spawn_replacement_e2e.rs b/crates/pa-daemon/tests/rlm_spawn_replacement_e2e.rs index a7fe25264..fe307eac6 100644 --- a/crates/pa-daemon/tests/rlm_spawn_replacement_e2e.rs +++ b/crates/pa-daemon/tests/rlm_spawn_replacement_e2e.rs @@ -275,6 +275,7 @@ fn worker_pid(agent_dir: &Path, socket: &Path, worker_id: &str) -> u32 { // `SupervisorChildSessions`) must progress while the test thread blocks in // its synchronous JSONL/file polls. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] +#[pa_test_scratch::pa_test] async fn concurrent_spawns_prompt_exactly_once_across_a_worker_replacement() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("daemon.sock"); diff --git a/crates/pa-daemon/tests/saved_catalog_stream_e2e.rs b/crates/pa-daemon/tests/saved_catalog_stream_e2e.rs index b84c59330..6b8b68235 100644 --- a/crates/pa-daemon/tests/saved_catalog_stream_e2e.rs +++ b/crates/pa-daemon/tests/saved_catalog_stream_e2e.rs @@ -189,6 +189,7 @@ fn write_fixture( /// The FIRST `session_list_item` frame must arrive well before the final /// response (the grown file's fold is the scan's tail); the ratio catches /// the batched form without a wall-clock budget (self-calibrating). +#[pa_test_scratch::pa_test] #[test] fn the_saved_catalog_streams_per_file_during_the_scan() { // The scan's head: small newest-first rows, stamped in increasing @@ -312,6 +313,7 @@ fn the_saved_catalog_streams_per_file_during_the_scan() { ); } +#[pa_test_scratch::pa_test] #[test] #[ignore = "expensive old durable path; run explicitly for fixture byte equivalence"] fn static_catalog_fixtures_match_the_durable_writer() { diff --git a/crates/pa-daemon/tests/saved_session_wake_e2e.rs b/crates/pa-daemon/tests/saved_session_wake_e2e.rs index bcea7cb96..8bde35850 100644 --- a/crates/pa-daemon/tests/saved_session_wake_e2e.rs +++ b/crates/pa-daemon/tests/saved_session_wake_e2e.rs @@ -241,6 +241,7 @@ fn messages(client: &mut Client, id: &str, active_session_id: &str) -> String { serde_json::to_string(&response["data"]).expect("messages json") } +#[pa_test_scratch::pa_test] #[test] fn send_to_a_saved_session_wakes_it_and_runs_the_turn() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/session_archive_e2e.rs b/crates/pa-daemon/tests/session_archive_e2e.rs index 6819a0667..63e2bd932 100644 --- a/crates/pa-daemon/tests/session_archive_e2e.rs +++ b/crates/pa-daemon/tests/session_archive_e2e.rs @@ -291,6 +291,7 @@ fn log_mentions(agent_dir: &Path, needle: &str) -> bool { .any(|path| std::fs::read_to_string(&path).is_ok_and(|content| content.contains(needle))) } +#[pa_test_scratch::pa_test] #[test] fn boot_sweep_archives_aged_sessions_and_the_catalog_excludes_them() { let dir = tempfile::tempdir().expect("temp dir"); @@ -349,6 +350,7 @@ fn boot_sweep_archives_aged_sessions_and_the_catalog_excludes_them() { }); } +#[pa_test_scratch::pa_test] #[test] fn an_archived_session_resumes_through_the_wake() { let dir = tempfile::tempdir().expect("temp dir"); diff --git a/crates/pa-daemon/tests/session_rebind_e2e.rs b/crates/pa-daemon/tests/session_rebind_e2e.rs index 7a2405b96..8232c4b1d 100644 --- a/crates/pa-daemon/tests/session_rebind_e2e.rs +++ b/crates/pa-daemon/tests/session_rebind_e2e.rs @@ -198,6 +198,7 @@ impl Client { } } +#[pa_test_scratch::pa_test] #[test] fn stale_active_id_rebinds_after_worker_replacement() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/session_stop_lifecycle_e2e.rs b/crates/pa-daemon/tests/session_stop_lifecycle_e2e.rs index 1c84d69c4..6a62e159e 100644 --- a/crates/pa-daemon/tests/session_stop_lifecycle_e2e.rs +++ b/crates/pa-daemon/tests/session_stop_lifecycle_e2e.rs @@ -272,6 +272,7 @@ impl Session { } } +#[pa_test_scratch::pa_test] #[test] fn kill_cancels_goal_and_heartbeat_and_no_wake_revives_the_session() { let root = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/session_tree_e2e.rs b/crates/pa-daemon/tests/session_tree_e2e.rs index ae1a12ae9..8398ee056 100644 --- a/crates/pa-daemon/tests/session_tree_e2e.rs +++ b/crates/pa-daemon/tests/session_tree_e2e.rs @@ -167,6 +167,7 @@ fn scripted_turn(client: &mut Client, session_id: &str, message: &str, id: &str) assert_eq!(response["success"], true, "prompt {id} failed: {response}"); } +#[pa_test_scratch::pa_test] #[test] fn session_tree_commands_over_the_supervisor_wire() { fn entry_id(node: &serde_json::Value) -> &str { @@ -506,6 +507,7 @@ fn read_exact_timeout(stream: &mut UnixStream, buffer: &mut [u8], deadline: Inst } } +#[pa_test_scratch::pa_test] #[test] fn session_tree_commands_over_the_direct_worker_link() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/socket_identity_guard_e2e.rs b/crates/pa-daemon/tests/socket_identity_guard_e2e.rs index 1678acb0e..ff69647da 100644 --- a/crates/pa-daemon/tests/socket_identity_guard_e2e.rs +++ b/crates/pa-daemon/tests/socket_identity_guard_e2e.rs @@ -298,6 +298,7 @@ fn read_exact_timeout(stream: &mut UnixStream, buffer: &mut [u8], deadline: Inst /// process's late orphan exit must leave the replacement's live socket /// alone - a stale-socket unlink there bounces every route to the /// replacement until the next relaunch cycle. +#[pa_test_scratch::pa_test] #[test] fn orphan_exit_never_unlinks_a_replacement_bound_on_the_worker_path() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -323,6 +324,7 @@ fn orphan_exit_never_unlinks_a_replacement_bound_on_the_worker_path() { /// must remove it so a respawn does not wait out the stale-socket path. /// The still-ours directions of the other two call sites are pinned by the /// in-tree controls named in the module doc. +#[pa_test_scratch::pa_test] #[test] fn routed_shutdown_removes_the_workers_own_socket_file() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -343,6 +345,7 @@ fn routed_shutdown_removes_the_workers_own_socket_file() { /// (`worker.rs` `exit_after_close`): the same survivor class as the /// orphan exit - a file replaced at the path after the bind is never /// unlinked by the old owner's exit. +#[pa_test_scratch::pa_test] #[test] fn routed_shutdown_never_unlinks_a_replacement_bound_on_the_worker_path() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -372,6 +375,7 @@ fn routed_shutdown_never_unlinks_a_replacement_bound_on_the_worker_path() { /// nameless listener. The original's graceful drain must not unlink the /// successor's live socket - every new connect would fail ENOENT while /// the socket looks alive. +#[pa_test_scratch::pa_test] #[test] fn a_drained_supervisor_never_unlinks_a_replaced_socket_file() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/stale_lease_release_e2e.rs b/crates/pa-daemon/tests/stale_lease_release_e2e.rs index 5b569854f..de84e92e1 100644 --- a/crates/pa-daemon/tests/stale_lease_release_e2e.rs +++ b/crates/pa-daemon/tests/stale_lease_release_e2e.rs @@ -352,6 +352,7 @@ fn crash_daemon_and_worker(daemon: &mut Daemon, worker_pid: u32) { } } +#[pa_test_scratch::pa_test] #[test] fn the_revived_worker_stays_supervised_and_the_session_reopens() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -410,6 +411,7 @@ fn the_revived_worker_stays_supervised_and_the_session_reopens() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_worker_that_fails_to_death_releases_the_session_hold() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -446,6 +448,7 @@ fn a_worker_that_fails_to_death_releases_the_session_hold() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_give_up_sweep_reaps_a_live_leftover_of_the_abandoned_id() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/startup_no_auto_resume_e2e.rs b/crates/pa-daemon/tests/startup_no_auto_resume_e2e.rs index 16407ab4a..4cbcfe44d 100644 --- a/crates/pa-daemon/tests/startup_no_auto_resume_e2e.rs +++ b/crates/pa-daemon/tests/startup_no_auto_resume_e2e.rs @@ -399,6 +399,7 @@ fn write_models_json(agent_dir: &Path, url: &Path) { /// The positive half: once the USER resumes the session, its schedule /// arms and the due heartbeat fires through the live worker's scheduler. +#[pa_test_scratch::pa_test] #[test] fn a_due_scheduled_job_never_boots_its_session_at_daemon_start() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -514,6 +515,7 @@ fn a_due_scheduled_job_never_boots_its_session_at_daemon_start() { } /// The archived-state file (a session TS stopped on purpose) stays down and out of the catalog. +#[pa_test_scratch::pa_test] #[test] fn a_stale_ts_era_heartbeat_stays_dormant_across_daemon_restarts() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/steer_boundary_batch_e2e.rs b/crates/pa-daemon/tests/steer_boundary_batch_e2e.rs index 628ec5228..dc75c903f 100644 --- a/crates/pa-daemon/tests/steer_boundary_batch_e2e.rs +++ b/crates/pa-daemon/tests/steer_boundary_batch_e2e.rs @@ -243,6 +243,7 @@ impl Client { } } +#[pa_test_scratch::pa_test] #[test] fn multi_steer_parked_mid_run_co_delivers_as_one_batched_turn() { let Some(_kernel) = kernel_python() else { diff --git a/crates/pa-daemon/tests/stop_escalation_e2e.rs b/crates/pa-daemon/tests/stop_escalation_e2e.rs index 4d18ed746..4c7fa1300 100644 --- a/crates/pa-daemon/tests/stop_escalation_e2e.rs +++ b/crates/pa-daemon/tests/stop_escalation_e2e.rs @@ -281,6 +281,7 @@ fn holder_report(pid: u32) -> String { format!("pid {pid} state {state} cmdline {cmdline:?} owner {owner:?}") } +#[pa_test_scratch::pa_test] #[test] fn a_hung_worker_is_killed_within_the_escalation_window_and_its_lease_frees() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -394,6 +395,7 @@ fn a_hung_worker_is_killed_within_the_escalation_window_and_its_lease_frees() { drop(daemon); } +#[pa_test_scratch::pa_test] #[test] fn a_well_behaved_worker_keeps_the_clean_stop() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/supervisor_e2e/attach.rs b/crates/pa-daemon/tests/supervisor_e2e/attach.rs index 64e47b839..0706a6da9 100644 --- a/crates/pa-daemon/tests/supervisor_e2e/attach.rs +++ b/crates/pa-daemon/tests/supervisor_e2e/attach.rs @@ -6,6 +6,7 @@ use super::*; /// Chunked snapshot streaming on the attach path (live TS goldens in /// `tests/goldens/chunked-attach-live-ts.json`): begin/chunk/end records /// whose reassembly equals the full snapshot legacy clients receive. +#[pa_test_scratch::pa_test] #[test] fn chunked_snapshot_attach_streams_begin_chunk_end() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/supervisor_e2e/compaction.rs b/crates/pa-daemon/tests/supervisor_e2e/compaction.rs index 764fefcb1..9c380d293 100644 --- a/crates/pa-daemon/tests/supervisor_e2e/compaction.rs +++ b/crates/pa-daemon/tests/supervisor_e2e/compaction.rs @@ -5,6 +5,7 @@ use super::*; // Response and event shapes captured read-only from the live TS daemon // (`tests/goldens/compaction-live-ts.json`). +#[pa_test_scratch::pa_test] #[test] fn compaction_commands_scripted_session() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/supervisor_e2e/create.rs b/crates/pa-daemon/tests/supervisor_e2e/create.rs index ea38ec8a5..aad46a079 100644 --- a/crates/pa-daemon/tests/supervisor_e2e/create.rs +++ b/crates/pa-daemon/tests/supervisor_e2e/create.rs @@ -19,6 +19,7 @@ fn write_saved_header(path: &std::path::Path, header: &serde_json::Value) { /// Explicit `--provider`/`--model` flags are authoritative for the worker's /// model resolution — no process-wide fallback may answer instead. +#[pa_test_scratch::pa_test] #[test] fn create_config_model_flags_reach_the_worker_engine() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -83,6 +84,7 @@ fn create_config_model_flags_reach_the_worker_engine() { ); } +#[pa_test_scratch::pa_test] #[test] fn create_path_duplicate_name_fails_with_current_ts_string() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -165,6 +167,7 @@ fn create_path_duplicate_name_fails_with_current_ts_string() { /// newest saved session for the cwd (any session on a shared dir, including /// one whose context and scheduled jobs resurrect); the daemon refuses the /// blind-resume form, and a create without the field still succeeds. +#[pa_test_scratch::pa_test] #[test] fn create_with_continue_recent_is_refused() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -238,6 +241,7 @@ fn create_with_continue_recent_is_refused() { /// A cold reopen must discover project resources in the saved directory, even /// when the caller (Agents View inline Reply) sends no cwd. An explicit fallback /// or override must still win. +#[pa_test_scratch::pa_test] #[test] fn cold_reopen_uses_saved_cwd_unless_explicitly_overridden() { let dir = tempfile::tempdir().expect("temp dir"); @@ -352,6 +356,7 @@ fn cold_reopen_uses_saved_cwd_unless_explicitly_overridden() { assert_eq!(client.read_response("shutdown")["success"], true); } +#[pa_test_scratch::pa_test] #[test] fn missing_saved_cwd_requires_an_explicit_fallback() { let dir = tempfile::tempdir().unwrap(); @@ -399,6 +404,7 @@ fn missing_saved_cwd_requires_an_explicit_fallback() { } /// Uses a real Python kernel; only provider responses are scripted. +#[pa_test_scratch::pa_test] #[test] #[ignore = "requires PRIME_AGENT_KERNEL_PYTHON with the kernel runtime installed"] fn cold_reopen_python_kernel_uses_saved_cwd_and_explicit_override() { diff --git a/crates/pa-daemon/tests/supervisor_e2e/event_order.rs b/crates/pa-daemon/tests/supervisor_e2e/event_order.rs index 39e5ad63d..1dada5b15 100644 --- a/crates/pa-daemon/tests/supervisor_e2e/event_order.rs +++ b/crates/pa-daemon/tests/supervisor_e2e/event_order.rs @@ -25,6 +25,7 @@ const SOCKET_SLACK: usize = 1 << 20; /// a wire offset past [`SOCKET_SLACK`] was still queued in the supervisor /// when `wait_for_idle` answered; the test asserts a minimum count of /// those, so a turn too small to build a queue fails loudly. +#[pa_test_scratch::pa_test] #[test] fn slow_client_reads_turn_events_before_the_reply() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/supervisor_e2e/lifecycle.rs b/crates/pa-daemon/tests/supervisor_e2e/lifecycle.rs index 957f65fc2..622a1efc1 100644 --- a/crates/pa-daemon/tests/supervisor_e2e/lifecycle.rs +++ b/crates/pa-daemon/tests/supervisor_e2e/lifecycle.rs @@ -6,6 +6,7 @@ use std::path::Path; use super::*; +#[pa_test_scratch::pa_test] #[test] fn supervisor_end_to_end_scripted_session_lifecycle() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/supervisor_e2e/read_goldens.rs b/crates/pa-daemon/tests/supervisor_e2e/read_goldens.rs index 0b9b5e928..97aff7f88 100644 --- a/crates/pa-daemon/tests/supervisor_e2e/read_goldens.rs +++ b/crates/pa-daemon/tests/supervisor_e2e/read_goldens.rs @@ -7,6 +7,7 @@ use super::*; // Differential goldens from the live TS daemon (protocol 7, schema 28: // read-only `get_session_header` / `get_session_stats` on a live session). +#[pa_test_scratch::pa_test] #[test] fn session_stats_and_header_match_live_daemon_goldens() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/supervisor_e2e/shutdown.rs b/crates/pa-daemon/tests/supervisor_e2e/shutdown.rs index ee9b8913a..fdaf961dc 100644 --- a/crates/pa-daemon/tests/supervisor_e2e/shutdown.rs +++ b/crates/pa-daemon/tests/supervisor_e2e/shutdown.rs @@ -59,6 +59,7 @@ fn wait_child_exit(child: &mut Child, timeout: Duration) -> Option (Daemon, PathBuf, String (daemon, log_path, boot_before) } +#[pa_test_scratch::pa_test] #[test] fn plain_boot_parks_stale_busy_evidence() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -170,6 +171,7 @@ fn plain_boot_parks_stale_busy_evidence() { /// Even FRESH busy evidence must not revive a session whose durable state /// is the stop lifecycle's `archived` belt (#2592). +#[pa_test_scratch::pa_test] #[test] fn plain_boot_never_revives_a_stopped_session() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -216,6 +218,7 @@ fn plain_boot_never_revives_a_stopped_session() { /// The give-up verdict is durable: a descriptor the supervisor already /// gave up on never relaunches at a later boot. +#[pa_test_scratch::pa_test] #[test] fn plain_boot_never_revives_a_given_up_worker() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -257,6 +260,7 @@ fn plain_boot_never_revives_a_given_up_worker() { /// The no-false-negative half of #2584's contract: fresh busy evidence, /// an active session, no give-up, no lease holder — still relaunches. +#[pa_test_scratch::pa_test] #[test] fn plain_boot_still_revives_fresh_busy_evidence() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/supervisor_restart_e2e/update_boot.rs b/crates/pa-daemon/tests/supervisor_restart_e2e/update_boot.rs index cdc2b9d69..8315d479e 100644 --- a/crates/pa-daemon/tests/supervisor_restart_e2e/update_boot.rs +++ b/crates/pa-daemon/tests/supervisor_restart_e2e/update_boot.rs @@ -4,6 +4,7 @@ use super::*; /// An update boot relaunches the dead workers its roster keeps, plus any /// with durable busy evidence; an unkept idle descriptor must never revive /// (the parked session may have a newer worker from a client reopen). +#[pa_test_scratch::pa_test] #[test] fn update_boot_revives_only_roster_kept_workers() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/support/session_fixture.rs b/crates/pa-daemon/tests/support/session_fixture.rs index cf52925b1..6e12734d0 100644 --- a/crates/pa-daemon/tests/support/session_fixture.rs +++ b/crates/pa-daemon/tests/support/session_fixture.rs @@ -64,6 +64,7 @@ pub fn assert_durable_equivalent(path: &Path) { eprintln!("byte-identical fixture {id}: {} bytes", durable.len()); } +#[pa_test_scratch::pa_test] #[test] fn bulk_serialization_matches_durable_rows() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/tests/thinking_level_e2e.rs b/crates/pa-daemon/tests/thinking_level_e2e.rs index 0d9c9226c..73ced368b 100644 --- a/crates/pa-daemon/tests/thinking_level_e2e.rs +++ b/crates/pa-daemon/tests/thinking_level_e2e.rs @@ -435,6 +435,7 @@ impl Harness { } } +#[pa_test_scratch::pa_test] #[test] fn interactive_thinking_max_clamps_to_effective_high_end_to_end() { let mut harness = setup("thinking-max", Some("max")); @@ -470,6 +471,7 @@ fn interactive_thinking_max_clamps_to_effective_high_end_to_end() { } } +#[pa_test_scratch::pa_test] #[test] fn interactive_sessions_without_a_flag_default_to_medium() { let mut harness = setup("thinking-default", None); @@ -485,6 +487,7 @@ fn interactive_sessions_without_a_flag_default_to_medium() { } } +#[pa_test_scratch::pa_test] #[test] fn invalid_thinking_level_fails_the_create() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -544,6 +547,7 @@ fn invalid_thinking_level_fails_the_create() { /// After their workers stop, the durable-row-backed surfaces (`list --all` /// saved rows and the ledger-seeded roster rows) keep rendering /// "model:level". +#[pa_test_scratch::pa_test] #[test] fn session_summaries_carry_the_thinking_level_for_both_session_kinds() { let mut harness = setup("summary-levels", None); diff --git a/crates/pa-daemon/tests/thinking_level_roster_e2e.rs b/crates/pa-daemon/tests/thinking_level_roster_e2e.rs index e25da98c8..3d353ffcc 100644 --- a/crates/pa-daemon/tests/thinking_level_roster_e2e.rs +++ b/crates/pa-daemon/tests/thinking_level_roster_e2e.rs @@ -342,6 +342,7 @@ impl Harness { } /// A model switch that clamps the level flushes the roster too. +#[pa_test_scratch::pa_test] #[test] fn thinking_level_changes_reach_the_roster_push() { let mut harness = setup("thinking-roster"); @@ -516,6 +517,7 @@ fn thinking_level_changes_reach_the_roster_push() { ); } +#[pa_test_scratch::pa_test] #[test] fn unchanged_thinking_level_answers_without_a_roster_push() { let mut harness = setup("thinking-roster-quiet"); diff --git a/crates/pa-daemon/tests/worker_orphan_exit_e2e.rs b/crates/pa-daemon/tests/worker_orphan_exit_e2e.rs index 365d73c96..241646916 100644 --- a/crates/pa-daemon/tests/worker_orphan_exit_e2e.rs +++ b/crates/pa-daemon/tests/worker_orphan_exit_e2e.rs @@ -107,6 +107,7 @@ fn wait_exit(child: &mut Child, budget: Duration) -> bool { } } +#[pa_test_scratch::pa_test] #[test] fn orphaned_worker_exits_when_the_supervisor_socket_never_answers() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -126,6 +127,7 @@ fn orphaned_worker_exits_when_the_supervisor_socket_never_answers() { ); } +#[pa_test_scratch::pa_test] #[test] fn worker_with_a_reachable_supervisor_survives_the_lost_window() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -239,6 +241,7 @@ fn read_exact_timeout( } } +#[pa_test_scratch::pa_test] #[test] fn the_orphan_exit_preserves_the_session_and_releases_execution_ownership() { let dir = tempfile::tempdir().expect("temp dir"); @@ -293,6 +296,7 @@ fn the_orphan_exit_preserves_the_session_and_releases_execution_ownership() { /// not a readiness signal: an idle orphan exits at the second availability /// check after the client's close (checks every 5s, a 4s window), so a worker /// that ignored the run would exit while the 20s command still runs. +#[pa_test_scratch::pa_test] #[test] fn an_orphaned_worker_waits_for_a_running_user_bash() { let dir = tempfile::tempdir().expect("temp dir"); @@ -345,6 +349,7 @@ fn an_orphaned_worker_waits_for_a_running_user_bash() { /// writes the sidecars while it holds them: a session whose turn settled /// leaves a current info sidecar (`generation.len == offset == file len`), /// so the next daemon boot folds zero bytes instead of the transcript. +#[pa_test_scratch::pa_test] #[test] fn the_orphan_exit_writes_a_current_info_sidecar() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/tests/worker_stderr_e2e.rs b/crates/pa-daemon/tests/worker_stderr_e2e.rs index 1022d5f4a..09055485f 100644 --- a/crates/pa-daemon/tests/worker_stderr_e2e.rs +++ b/crates/pa-daemon/tests/worker_stderr_e2e.rs @@ -175,6 +175,7 @@ fn worker_stderr_logs(agent_dir: &Path) -> Vec { .collect() } +#[pa_test_scratch::pa_test] #[test] fn worker_stderr_lands_in_the_per_worker_log_and_prunes_retention() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -231,6 +232,7 @@ fn worker_stderr_lands_in_the_per_worker_log_and_prunes_retention() { ); } +#[pa_test_scratch::pa_test] #[test] fn never_ready_worker_failure_carries_the_captured_stderr_tail() { // The injected `TMPDIR` below must stay short enough that the worker's socket probe still diff --git a/crates/pa-models/tests/custom_ca_extra_certs.rs b/crates/pa-models/tests/custom_ca_extra_certs.rs index 1ae374f17..0615e7be9 100644 --- a/crates/pa-models/tests/custom_ca_extra_certs.rs +++ b/crates/pa-models/tests/custom_ca_extra_certs.rs @@ -2,6 +2,7 @@ use pa_test_scratch as _; // a private TMPDIR for this test binary, deleted on e mod common; #[tokio::test] +#[pa_test_scratch::pa_test] async fn node_extra_ca_certs_adds_the_custom_ca() { common::fetch_trusting_test_ca("NODE_EXTRA_CA_CERTS").await; } diff --git a/crates/pa-models/tests/custom_ca_native_once.rs b/crates/pa-models/tests/custom_ca_native_once.rs index 48ebcafd3..435e75cab 100644 --- a/crates/pa-models/tests/custom_ca_native_once.rs +++ b/crates/pa-models/tests/custom_ca_native_once.rs @@ -6,6 +6,7 @@ use pa_test_scratch as _; // a private TMPDIR for this test binary, deleted on e mod common; #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_native_trust_store_is_read_once_per_process() { let mut server = common::tls_catalog_server(2).await; let ca_env = common::ca_bundle_env("SSL_CERT_FILE", &server.ca_pem); diff --git a/crates/pa-models/tests/custom_ca_native_roots.rs b/crates/pa-models/tests/custom_ca_native_roots.rs index 226598a86..57ab33eaa 100644 --- a/crates/pa-models/tests/custom_ca_native_roots.rs +++ b/crates/pa-models/tests/custom_ca_native_roots.rs @@ -6,6 +6,7 @@ use pa_test_scratch as _; // a private TMPDIR for this test binary, deleted on e mod common; #[tokio::test] +#[pa_test_scratch::pa_test] async fn ssl_cert_file_backs_the_unix_native_catalog_loader() { common::fetch_trusting_test_ca("SSL_CERT_FILE").await; } diff --git a/crates/pa-models/tests/fetch_layer.rs b/crates/pa-models/tests/fetch_layer.rs index 483adabda..c3e0e9d63 100644 --- a/crates/pa-models/tests/fetch_layer.rs +++ b/crates/pa-models/tests/fetch_layer.rs @@ -10,6 +10,7 @@ use pa_models::fetch::{CatalogFetcher, FetchOutcome}; use std::time::Duration; #[tokio::test] +#[pa_test_scratch::pa_test] async fn serves_200_bodies_with_etags_and_sends_catalog_headers() { let server = common::MockServer::start(vec![ok_json( "{\"schemaVersion\":1,\"models\":[]}", @@ -46,6 +47,7 @@ async fn serves_200_bodies_with_etags_and_sends_catalog_headers() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn redirects_are_refused() { let server = common::MockServer::start(vec![redirect()]).await; let fetcher = CatalogFetcher::new(); @@ -57,6 +59,7 @@ async fn redirects_are_refused() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn non_success_statuses_surface_with_their_code() { let server = common::MockServer::start(vec![status(404, "Not Found")]).await; let fetcher = CatalogFetcher::new(); @@ -74,6 +77,7 @@ async fn non_success_statuses_surface_with_their_code() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn content_length_over_the_cap_fails_before_reading() { let server = common::MockServer::start(vec![common::oversized_header()]).await; let fetcher = CatalogFetcher::new(); @@ -81,6 +85,7 @@ async fn content_length_over_the_cap_fails_before_reading() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn streamed_bodies_past_the_cap_fail_mid_read() { let server = common::MockServer::start(vec![common::oversized_stream()]).await; let fetcher = CatalogFetcher::with_limits(Duration::from_secs(5), 64 * 1024); @@ -92,6 +97,7 @@ async fn streamed_bodies_past_the_cap_fail_mid_read() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn hard_timeout_aborts_unresponsive_servers() { // A server that accepts but never answers: the 5s timeout would make the // test slow, so bound the same policy with a short explicit limit. @@ -116,6 +122,7 @@ async fn hard_timeout_aborts_unresponsive_servers() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn connection_failures_are_transport_errors() { // Bind then close: nothing listens on this port anymore. let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); diff --git a/crates/pa-models/tests/parity.rs b/crates/pa-models/tests/parity.rs index c959f963b..f80369768 100644 --- a/crates/pa-models/tests/parity.rs +++ b/crates/pa-models/tests/parity.rs @@ -15,6 +15,7 @@ fn fixture() -> Value { serde_json::from_str(FIXTURE).expect("fixture parses") } +#[pa_test_scratch::pa_test] #[test] fn parses_the_real_payload_with_zero_failures() { let parsed = @@ -27,6 +28,7 @@ fn parses_the_real_payload_with_zero_failures() { assert!(parsed.models.iter().all(|model| model.headers.is_none())); } +#[pa_test_scratch::pa_test] #[test] fn every_real_entry_survives_transport_pinning() { let pinned = parse_provider_model_catalog(&fixture(), &PinnedTemplates::from_compiled()) @@ -43,6 +45,7 @@ fn every_real_entry_survives_transport_pinning() { assert!(headers > 0, "template headers are applied at parse time"); } +#[pa_test_scratch::pa_test] #[test] fn passes_the_packer_gates() { // The build lane's gate: >= 42 distinct (provider, api, baseUrl) tuples. @@ -68,6 +71,7 @@ fn passes_the_packer_gates() { ); } +#[pa_test_scratch::pa_test] #[test] fn skip_invalid_keeps_the_real_payload_whole() { let parsed = parse_model_catalog(&fixture(), InvalidEntries::SkipInvalid).expect("skip mode"); diff --git a/crates/pa-models/tests/refresh_compat.rs b/crates/pa-models/tests/refresh_compat.rs index 3b79b13d0..3df0a782a 100644 --- a/crates/pa-models/tests/refresh_compat.rs +++ b/crates/pa-models/tests/refresh_compat.rs @@ -89,6 +89,7 @@ fn catalog_json(ids: &[&str]) -> String { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn fresh_fetch_writes_a_validated_0600_snapshot_and_serves_it() { let dir = tempfile::tempdir().unwrap(); let body = catalog_json(&["model-a"]); @@ -135,6 +136,7 @@ async fn fresh_fetch_writes_a_validated_0600_snapshot_and_serves_it() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn unsupported_future_version_keeps_last_good_silently() { let dir = tempfile::tempdir().unwrap(); let good = catalog_json(&["model-a"]); @@ -186,6 +188,7 @@ async fn unsupported_future_version_keeps_last_good_silently() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn malformed_model_entry_skips_and_the_refresh_succeeds() { let dir = tempfile::tempdir().unwrap(); let compiled = pa_models::transports::compiled_models(); @@ -220,6 +223,7 @@ async fn malformed_model_entry_skips_and_the_refresh_succeeds() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn network_failure_and_oversize_keep_state_unchanged() { let dir = tempfile::tempdir().unwrap(); let server = common::MockServer::start(vec![ @@ -281,6 +285,7 @@ async fn network_failure_and_oversize_keep_state_unchanged() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn hourly_gating_skips_recent_attempts_and_force_overrides() { let dir = tempfile::tempdir().unwrap(); let server = @@ -318,6 +323,7 @@ async fn hourly_gating_skips_recent_attempts_and_force_overrides() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn concurrent_refreshes_coalesce_into_one_fetch() { let dir = tempfile::tempdir().unwrap(); let server = @@ -348,6 +354,7 @@ async fn concurrent_refreshes_coalesce_into_one_fetch() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn not_modified_keeps_snapshot_and_updates_fetched_at() { let dir = tempfile::tempdir().unwrap(); let server = common::MockServer::start(vec![ @@ -385,6 +392,7 @@ async fn not_modified_keeps_snapshot_and_updates_fetched_at() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn prime_inference_cache_is_scope_keyed_and_isolated() { let dir = tempfile::tempdir().unwrap(); let compiled = pa_models::transports::prime_inference_offline_entries(); @@ -481,6 +489,7 @@ async fn prime_inference_cache_is_scope_keyed_and_isolated() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn unauthorized_prime_inference_clears_only_that_scope() { let dir = tempfile::tempdir().unwrap(); let compiled = pa_models::transports::prime_inference_offline_entries(); @@ -547,6 +556,7 @@ async fn unauthorized_prime_inference_clears_only_that_scope() { .is_empty()); } +#[pa_test_scratch::pa_test] #[test] fn prime_inference_parse_and_coverage_gate_use_public_fns() { // Sanity for the closure the PrimeInferenceCatalog installs: an empty @@ -559,6 +569,7 @@ fn prime_inference_parse_and_coverage_gate_use_public_fns() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn mid_session_refresh_never_retargets() { let dir = tempfile::tempdir().unwrap(); let server = common::MockServer::start(vec![ @@ -599,6 +610,7 @@ async fn mid_session_refresh_never_retargets() { /// Fire-and-forget safety: a caller that drops its `refresh` mid-fetch /// must not poison the coalescing gate. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_dropped_refresh_resolves_the_gate_and_the_next_refresh_starts_fresh() { let dir = tempfile::tempdir().unwrap(); let server = common::MockServer::start_scripted(vec![ @@ -670,6 +682,7 @@ async fn a_dropped_refresh_resolves_the_gate_and_the_next_refresh_starts_fresh() /// caches without waiting an hour) and the tick's fetch arms the hourly /// gate, so an immediate second attempt stays inside the window. #[tokio::test] +#[pa_test_scratch::pa_test] async fn facade_refreshes_authorized_layers_and_gates_recent_attempts() { let dir = tempfile::tempdir().unwrap(); let compiled = pa_models::transports::prime_inference_offline_entries(); diff --git a/crates/pa-tui/tests/agents_view_catalog_settle_carry.rs b/crates/pa-tui/tests/agents_view_catalog_settle_carry.rs index 35d764008..0faf3006f 100644 --- a/crates/pa-tui/tests/agents_view_catalog_settle_carry.rs +++ b/crates/pa-tui/tests/agents_view_catalog_settle_carry.rs @@ -275,6 +275,7 @@ fn view_options(socket: &std::path::Path, anchor: Option<&str>) -> AgentsViewOpt /// wait (TS `resolveMissingSelectionAnchor`'s finally arm): the Enter after the load opens the /// default row instead of re-arming "Still loading sessions" behind a catalog that already settled. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_successful_load_settles_the_anchor_wait_when_the_row_is_missing() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("agents-view.sock"); @@ -336,6 +337,7 @@ async fn a_successful_load_settles_the_anchor_wait_when_the_row_is_missing() { /// The flow's carried catalog (TS `persistentState.savedSessions`): the flow's NEXT view run /// paints the Inactive rows on its FIRST frame with no second fetch. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_carried_catalog_paints_the_first_frame_and_skips_the_refetch() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("agents-view.sock"); @@ -411,6 +413,7 @@ async fn the_carried_catalog_paints_the_first_frame_and_skips_the_refetch() { /// A carried catalog settles the entry anchor AT OPEN (TS `start()`'s `armSavedSearchFetch` + /// `resolveMissingSelectionAnchor`): the next view run arms no fetch. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_carried_catalog_settles_the_entry_anchor_at_open() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("agents-view.sock"); @@ -480,6 +483,7 @@ async fn a_carried_catalog_settles_the_entry_anchor_at_open() { /// A late `session_list_item` frame delivered after the terminal response never clobbers /// the settled catalog: the response is the authoritative array, so a late frame cannot upsert. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_late_stream_frame_never_clobbers_the_settled_catalog() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("agents-view.sock"); diff --git a/crates/pa-tui/tests/agents_view_click_headless.rs b/crates/pa-tui/tests/agents_view_click_headless.rs index 9ad2ed44b..a960357da 100644 --- a/crates/pa-tui/tests/agents_view_click_headless.rs +++ b/crates/pa-tui/tests/agents_view_click_headless.rs @@ -206,7 +206,10 @@ fn view_options(socket: &std::path::Path) -> AgentsViewOptions { /// Run one headless plan and return the outcome. Holds the run lock: the click dispatch gates on /// the process-global tracking state. async fn run_plan(steps: Vec) -> pa_tui::agents_view::AgentsViewOutcome { + let lock_wait = pa_test_scratch::timing::span("setup.lock_wait"); let _guard = RUN_LOCK.lock().await; + drop(lock_wait); + let fixture = pa_test_scratch::timing::span("setup.fixture"); let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("agents-view.sock"); let mock = MockSupervisor::bind(&socket); @@ -223,12 +226,16 @@ async fn run_plan(steps: Vec) -> pa_tui::agents_view::AgentsViewOutc width: 120, height: 36, }; + drop(fixture); + let run_wait = pa_test_scratch::timing::span("run.wait_and_render"); let run = run_agents_view( view_options(&socket), AgentsViewUiMode::Headless(plan), None, ) .await; + drop(run_wait); + let _teardown = pa_test_scratch::timing::span("teardown.server_join"); connected_rx .recv_timeout(Duration::from_millis(2500)) .expect("mock accepted the view connection") @@ -263,6 +270,7 @@ fn locate_row(frames: &[String], needle: &str) -> Option { /// A plain click on a session row opens it: the press/release pair on the second row's line selects /// and opens that row (the default Enter would have opened the FIRST row). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_click_on_a_session_row_opens_it() { let outcome = run_plan(vec![AgentsStep::WaitSettle { timeout_ms: 2500 }]).await; let row = locate_row(&outcome.frames, "second one").expect("the second roster row renders"); @@ -281,6 +289,7 @@ async fn a_click_on_a_session_row_opens_it() { /// A dragged release never opens the row under it (the press-drag release is a select gesture, not /// a click). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_dragged_release_never_opens_the_row() { let outcome = run_plan(vec![AgentsStep::WaitSettle { timeout_ms: 2500 }]).await; let row = locate_row(&outcome.frames, "second one").expect("the second roster row renders"); @@ -303,11 +312,13 @@ async fn a_dragged_release_never_opens_the_row() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn settle_reports_the_unfinished_catalog_instead_of_releasing_the_plan() { assert_unfinished_catalog_fails_settle(vec![AgentsStep::WaitSettle { timeout_ms: 0 }]).await; } #[tokio::test] +#[pa_test_scratch::pa_test] async fn settle_after_a_satisfied_render_still_waits_for_the_catalog() { assert_unfinished_catalog_fails_settle(vec![ AgentsStep::WaitRender { diff --git a/crates/pa-tui/tests/agents_view_heartbeat_badge_headless.rs b/crates/pa-tui/tests/agents_view_heartbeat_badge_headless.rs index 4d9bd87af..18b3fe612 100644 --- a/crates/pa-tui/tests/agents_view_heartbeat_badge_headless.rs +++ b/crates/pa-tui/tests/agents_view_heartbeat_badge_headless.rs @@ -251,6 +251,7 @@ fn view_options(socket: &std::path::Path) -> AgentsViewOptions { /// row renders the dock's `◷ N` vocabulary between its status icon and /// its title. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_row_renders_its_heartbeat_count_after_a_heartbeats_changed() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("agents-view.sock"); diff --git a/crates/pa-tui/tests/agents_view_hover_headless.rs b/crates/pa-tui/tests/agents_view_hover_headless.rs index a44ac0d4c..7dbd68360 100644 --- a/crates/pa-tui/tests/agents_view_hover_headless.rs +++ b/crates/pa-tui/tests/agents_view_hover_headless.rs @@ -233,7 +233,10 @@ fn view_options(socket: &std::path::Path) -> AgentsViewOptions { /// Run one headless plan and return the outcome. Holds the run lock: the click dispatch gates on /// the process-global tracking state. async fn run_plan(steps: Vec) -> pa_tui::agents_view::AgentsViewOutcome { + let lock_wait = pa_test_scratch::timing::span("setup.lock_wait"); let _guard = RUN_LOCK.lock().await; + drop(lock_wait); + let fixture = pa_test_scratch::timing::span("setup.fixture"); let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("agents-view.sock"); let mock = MockSupervisor::bind(&socket); @@ -250,12 +253,16 @@ async fn run_plan(steps: Vec) -> pa_tui::agents_view::AgentsViewOutc width: 120, height: 36, }; + drop(fixture); + let run_wait = pa_test_scratch::timing::span("run.wait_and_render"); let run = run_agents_view( view_options(&socket), AgentsViewUiMode::Headless(plan), None, ) .await; + drop(run_wait); + let _teardown = pa_test_scratch::timing::span("teardown.server_join"); connected_rx .recv_timeout(Duration::from_millis(2500)) .expect("mock accepted the view connection") @@ -310,6 +317,7 @@ fn motion(col: usize, row: usize) -> String { /// A plain click on the INACTIVE saved row opens it: the resume selection — every row is clickable, /// the archived ones included. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_click_on_an_inactive_row_opens_it() { let frames = settled_frames("archived run").await; let row = locate_row(&frames, "archived run").expect("the inactive row renders"); @@ -334,6 +342,7 @@ async fn a_click_on_an_inactive_row_opens_it() { /// A plain click on the merged `N subagents (M running)` row EXPANDS the dropdown — the toggle, not /// an open: the frame renders the child rows and the run keeps running with no selection. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_click_on_the_merged_summary_expands_the_dropdown() { let frames = settled_frames("subagents (").await; let row = locate_row(&frames, "subagents (").expect("the merged line renders"); @@ -364,6 +373,7 @@ async fn a_click_on_the_merged_summary_expands_the_dropdown() { /// A plain click on the expanded CHILD row opens the subagent — the Enter action on the drilled-in /// row. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_click_on_the_expanded_child_opens_the_subagent() { let frames = settled_frames("subagents (").await; let summary = locate_row(&frames, "subagents (").expect("the merged line renders"); @@ -411,6 +421,7 @@ async fn a_click_on_the_expanded_child_opens_the_subagent() { /// The `?1003` hover motions ride the rows without disturbing the click grammar: motions across the /// merged line, the child rows, and the headings, then a plain click — the subagent still opens. #[tokio::test] +#[pa_test_scratch::pa_test] async fn hover_motions_never_disturb_the_agents_view_click() { let frames = settled_frames("subagents (").await; let summary = locate_row(&frames, "subagents (").expect("the merged line renders"); diff --git a/crates/pa-tui/tests/agents_view_incident_notice_e2e.rs b/crates/pa-tui/tests/agents_view_incident_notice_e2e.rs index 0ccd53659..76f00c512 100644 --- a/crates/pa-tui/tests/agents_view_incident_notice_e2e.rs +++ b/crates/pa-tui/tests/agents_view_incident_notice_e2e.rs @@ -249,6 +249,7 @@ fn view_options(socket: &std::path::Path) -> AgentsViewOptions { /// The collapsed worker-crash notice line renders from the log tail, with the pointer to the /// incident CLI (TS "renders the collapsed worker-crash notice line from the log tail"). #[tokio::test] +#[pa_test_scratch::pa_test] async fn renders_the_collapsed_worker_crash_notice_line() { let _env = env_lock().await; let dir = tempfile::TempDir::new().expect("temp dir"); @@ -311,6 +312,7 @@ async fn renders_the_collapsed_worker_crash_notice_line() { /// Esc dismisses the notice with the status confirmation, and a dismissal survives a later poll /// (TS "dismisses with Esc and never resurrects across later polls"). #[tokio::test] +#[pa_test_scratch::pa_test] async fn dismisses_with_esc_and_the_dismissal_survives_reentry() { let _env = env_lock().await; let dir = tempfile::TempDir::new().expect("temp dir"); @@ -395,6 +397,7 @@ async fn dismisses_with_esc_and_the_dismissal_survives_reentry() { /// An armed delete confirmation wins the Esc: it cancels and the notice stays (TS "cancels an /// armed delete confirmation with Esc instead of dismissing the notice"). #[tokio::test] +#[pa_test_scratch::pa_test] async fn esc_cancels_an_armed_delete_confirmation_and_keeps_the_notice() { let _env = env_lock().await; let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-tui/tests/agents_view_saved_catalog_failure.rs b/crates/pa-tui/tests/agents_view_saved_catalog_failure.rs index 2313c0231..6a5f6ae46 100644 --- a/crates/pa-tui/tests/agents_view_saved_catalog_failure.rs +++ b/crates/pa-tui/tests/agents_view_saved_catalog_failure.rs @@ -207,6 +207,7 @@ fn view_options(socket: &std::path::Path) -> AgentsViewOptions { /// The terminal saved-catalog failure settles the entry anchor's wait: the status line keeps the /// honest error, and an Enter after the failure opens the default row (never the loading hint). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_terminal_saved_catalog_failure_settles_the_anchor_wait() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("agents-view.sock"); @@ -276,6 +277,7 @@ async fn a_terminal_saved_catalog_failure_settles_the_anchor_wait() { /// The failed fetch re-arms on the next query change (TS `rearmSavedSearchFetch`): a typed query /// after the failure sends a SECOND saved-catalog request. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_failed_fetch_rearms_on_the_next_query_change() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("agents-view.sock"); diff --git a/crates/pa-tui/tests/agents_view_wait_render_barrier.rs b/crates/pa-tui/tests/agents_view_wait_render_barrier.rs index b598a2913..f5cdcf044 100644 --- a/crates/pa-tui/tests/agents_view_wait_render_barrier.rs +++ b/crates/pa-tui/tests/agents_view_wait_render_barrier.rs @@ -259,6 +259,7 @@ fn view_options(socket: &std::path::Path) -> AgentsViewOptions { /// daemon-driven row: the mock's 2s catalog answer lands long after the barrier armed. The retired /// 300ms budget-settle reds here deterministically: `Done` fires before the answer lands. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_render_barrier_holds_until_the_catalog_row_renders() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("agents-view.sock"); @@ -313,6 +314,7 @@ async fn the_render_barrier_holds_until_the_catalog_row_renders() { /// The barrier's deadline pops the hold and the plan proceeds honestly: the needle the mock /// never renders ends the wait at its own bound, the status line reports the unsatisfied wait. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_barrier_deadline_pops_the_hold_and_the_plan_proceeds() { let dir = tempfile::TempDir::new().expect("temp dir"); let socket = dir.path().join("agents-view.sock"); diff --git a/crates/pa-tui/tests/anthropic_warning_lifecycle_headless.rs b/crates/pa-tui/tests/anthropic_warning_lifecycle_headless.rs index 95c8ed90c..3ad2509fe 100644 --- a/crates/pa-tui/tests/anthropic_warning_lifecycle_headless.rs +++ b/crates/pa-tui/tests/anthropic_warning_lifecycle_headless.rs @@ -518,6 +518,7 @@ fn warning_settings() -> Arc { /// The genuinely-new session (the daemon reports the gate closed): the /// startup detection arm draws the warning once and marks the gate with /// the daemon — exactly one mark leaves the client. +#[pa_test_scratch::pa_test] #[test] fn a_new_session_warns_once_and_marks_the_gate() { let (frames, commands) = run_plan( @@ -546,6 +547,7 @@ fn a_new_session_warns_once_and_marks_the_gate() { /// The reattach/resume read (a fresh TUI instance over a session whose /// gate the daemon reports OPEN): no warning renders, and the client never /// re-marks. This is the every-open re-warn the directive fixes. +#[pa_test_scratch::pa_test] #[test] fn a_marked_session_reattach_never_rewarns() { let (frames, commands) = run_plan( @@ -572,6 +574,7 @@ fn a_marked_session_reattach_never_rewarns() { /// The settings toggle stays FIRST: with `warnings.anthropicExtraUsage` /// off, a genuinely new session on a subscription credential never warns /// and never marks (the daemon-side gate is never asked). +#[pa_test_scratch::pa_test] #[test] fn the_settings_toggle_off_never_warns() { let settings = Arc::new(StubSettings { @@ -600,6 +603,7 @@ fn the_settings_toggle_off_never_warns() { /// draws the product warning — the login-completed arm is not gated by /// the lifecycle marker, each landing is its own event — and it marks the /// gate too. +#[pa_test_scratch::pa_test] #[test] fn a_fresh_login_rewarns_on_a_marked_session() { let (frames, commands) = run_plan( @@ -643,6 +647,7 @@ fn a_fresh_login_rewarns_on_a_marked_session() { /// `anthropicWarningShown` field (the pre-fix build) keeps the warning /// working — the gate fails OPEN, so an unreadable lifecycle state shows /// the warning rather than suppressing it. +#[pa_test_scratch::pa_test] #[test] fn a_daemon_without_the_gate_field_fails_open_and_warns() { let (frames, commands) = run_plan( diff --git a/crates/pa-tui/tests/bash_bang_headless.rs b/crates/pa-tui/tests/bash_bang_headless.rs index c31f13ea1..d4fc8df55 100644 --- a/crates/pa-tui/tests/bash_bang_headless.rs +++ b/crates/pa-tui/tests/bash_bang_headless.rs @@ -614,6 +614,7 @@ fn run_plan_with( } } +#[pa_test_scratch::pa_test] #[test] fn bang_runs_the_command_and_mounts_the_bash_card() { let steps = vec![ @@ -665,6 +666,7 @@ fn bang_runs_the_command_and_mounts_the_bash_card() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_running_guard_blocks_and_a_bare_bang_is_inert() { let steps = vec![ @@ -692,6 +694,7 @@ fn the_running_guard_blocks_and_a_bare_bang_is_inert() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_side_conversation_bash_run_mounts_in_the_pane_and_seeds_follow_ups() { let steps = vec![ @@ -748,6 +751,7 @@ fn a_side_conversation_bash_run_mounts_in_the_pane_and_seeds_follow_ups() { } /// `bash_output` carries no run identity on the wire, so routing follows the active run (TS /// `activeBashComponent`): a settled pane row never receives a later run's output. +#[pa_test_scratch::pa_test] #[test] fn a_main_run_after_a_settled_pane_run_owns_its_output() { let steps = vec![ @@ -800,6 +804,7 @@ fn a_main_run_after_a_settled_pane_run_owns_its_output() { /// TS `pendingMessagesContainer`: the run mounts above the execution indicator and flushes /// into the transcript when the turn ends (TS `flushPendingBashComponents`). +#[pa_test_scratch::pa_test] #[test] fn a_bang_during_a_streaming_turn_holds_then_flushes() { let steps = vec![ @@ -880,6 +885,7 @@ fn a_bang_during_a_streaming_turn_holds_then_flushes() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_long_truncated_run_previews_the_tail_and_names_the_spill_file() { let steps = vec![ @@ -922,6 +928,7 @@ fn a_long_truncated_run_previews_the_tail_and_names_the_spill_file() { } /// TS `setComplete`: cancelled outranks the exit code. +#[pa_test_scratch::pa_test] #[test] fn a_cancelled_run_marks_the_card_cancelled() { let steps = vec![ @@ -948,6 +955,7 @@ fn a_cancelled_run_marks_the_card_cancelled() { /// §10: the link dies before `bash_end`; the resync's `bashFinished` edge settles the held card /// with an unknown exit (TS `renderResyncedSession` — no fake `(cancelled)` marker). +#[pa_test_scratch::pa_test] #[test] fn an_update_restart_settles_the_held_bang_card_on_reattach() { let steps = vec![ diff --git a/crates/pa-tui/tests/chat_detail_persist_headless.rs b/crates/pa-tui/tests/chat_detail_persist_headless.rs index 1ad94d25a..abe931b7a 100644 --- a/crates/pa-tui/tests/chat_detail_persist_headless.rs +++ b/crates/pa-tui/tests/chat_detail_persist_headless.rs @@ -398,6 +398,7 @@ fn wait_label(label: &str) -> HeadlessStep { /// TS #2709's regression shape: pick a level with Ctrl+O in one chat; the pick is saved as the /// `chatDetail` setting, and a later run — a fresh process re-reading the store — opens at the /// saved level. The later run attaches to a DIFFERENT session id: the setting is global. +#[pa_test_scratch::pa_test] #[test] fn ctrl_o_pick_persists_and_a_later_chat_reopens_at_it() { // Run one: an unset store, so the chat starts at the `overview` startup level (the collapse @@ -461,6 +462,7 @@ fn ctrl_o_pick_persists_and_a_later_chat_reopens_at_it() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_cycle_saves_the_overview_wrap_too() { let settings = Arc::new(StubSettings { diff --git a/crates/pa-tui/tests/chat_open_first_frame_headless.rs b/crates/pa-tui/tests/chat_open_first_frame_headless.rs index 7d5616cdc..891fa3d07 100644 --- a/crates/pa-tui/tests/chat_open_first_frame_headless.rs +++ b/crates/pa-tui/tests/chat_open_first_frame_headless.rs @@ -292,6 +292,7 @@ fn is_divider_row(line: &str, width: usize) -> bool { /// The dock's counts are first-frame state: every captured frame carries both rows with the final /// count, so the delayed dock data never repaints the row in late. +#[pa_test_scratch::pa_test] #[test] fn the_activity_dock_is_in_every_frame_from_the_first() { let frames = run_open(&OpeningTranscript::Empty); @@ -317,6 +318,7 @@ fn the_activity_dock_is_in_every_frame_from_the_first() { /// A chat that opens directly into content paints its first frame from the snapshot: the /// transcript, the pinned title row, and the dock all ride that same frame, and the brand splash /// (the new chat's header) never renders — no splash flash above the title, no one-row shift. +#[pa_test_scratch::pa_test] #[test] fn a_direct_open_into_content_never_renders_the_splash() { let frames = run_open(&OpeningTranscript::Content); @@ -339,6 +341,7 @@ fn a_direct_open_into_content_never_renders_the_splash() { /// The counter-pin: an empty chat keeps its brand splash — TS `BrandSplashHeader` is the new chat's /// header, and the suppression is scoped to opens into content. +#[pa_test_scratch::pa_test] #[test] fn an_empty_open_keeps_the_brand_splash() { let frames = run_open(&OpeningTranscript::Empty); diff --git a/crates/pa-tui/tests/daemon_rejection_headless.rs b/crates/pa-tui/tests/daemon_rejection_headless.rs index 19a13af87..f7ac84474 100644 --- a/crates/pa-tui/tests/daemon_rejection_headless.rs +++ b/crates/pa-tui/tests/daemon_rejection_headless.rs @@ -600,6 +600,7 @@ fn run_plan( } /// An empty follow-up submission is TS `handleFollowUp`'s silent no-op. +#[pa_test_scratch::pa_test] #[test] fn empty_follow_up_is_a_silent_noop_and_the_client_stays_alive() { let steps = vec![ @@ -632,6 +633,7 @@ fn empty_follow_up_is_a_silent_noop_and_the_client_stays_alive() { ); } +#[pa_test_scratch::pa_test] #[test] fn rejected_mid_turn_submission_renders_the_error_row_and_keeps_running() { let steps = vec![ @@ -670,6 +672,7 @@ fn rejected_mid_turn_submission_renders_the_error_row_and_keeps_running() { /// Handled, not fatal (operator directive: the user never loses their TUI to a daemon hiccup); /// the loss is surfaced twice, and the close-after-send draft stays consumed so the natural /// resubmit never runs the prompt twice. +#[pa_test_scratch::pa_test] #[test] fn dead_connection_on_prompt_keeps_the_draft_consumed_and_arms_the_reconnect() { let steps = vec![ @@ -714,6 +717,7 @@ fn dead_connection_on_prompt_keeps_the_draft_consumed_and_arms_the_reconnect() { /// TS `onSubmit` passes its captured `streamingBehavior` to the fallthrough prompt, so alt+enter /// on unknown slash text parks on the follow-up lane, not the steering lane. /// A queued prompt remains consumed even if a session-binding event wins the outcome race. +#[pa_test_scratch::pa_test] #[test] fn close_after_rebind_keeps_the_outlived_prompt_consumed() { let steps = vec![ @@ -742,6 +746,7 @@ fn close_after_rebind_keeps_the_outlived_prompt_consumed() { assert!(!last.contains("hello"), "the draft stays consumed: {last}"); } +#[pa_test_scratch::pa_test] #[test] fn prompt_template_follow_up_keeps_the_follow_up_lane() { let steps = vec![ @@ -780,6 +785,7 @@ fn prompt_template_follow_up_keeps_the_follow_up_lane() { /// A refused saved-session create ("Session is already active in ", another instance /// holding the file; Kevin's second reproducer) must not exit the client. +#[pa_test_scratch::pa_test] #[test] fn refused_saved_session_create_falls_back_to_the_agents_view() { let run = run_plan_with(vec![HeadlessStep::WaitMs(100)], |supervisor| { @@ -807,6 +813,7 @@ fn refused_saved_session_create_falls_back_to_the_agents_view() { } /// The TS-identical first line plus the holder guidance, never the bare lease text. +#[pa_test_scratch::pa_test] #[test] fn refused_saved_session_create_names_the_holder_and_next_steps() { let run = run_plan_with_selection( @@ -861,6 +868,7 @@ fn refused_saved_session_create_names_the_holder_and_next_steps() { } /// TS #2391: a create rejected in the preparing-restart window is retried, never a bare failure. +#[pa_test_scratch::pa_test] #[test] fn an_agents_view_open_waits_through_the_update_restart_window() { let run = run_agents_view_plan_with_selection( @@ -902,6 +910,7 @@ fn an_agents_view_open_waits_through_the_update_restart_window() { } /// TS #2391: the permanent refusal surfaces itself — no third attempt through the window. +#[pa_test_scratch::pa_test] #[test] fn a_permanent_create_failure_after_the_window_surfaces_unmasked() { let run = run_agents_view_plan_with_selection( diff --git a/crates/pa-tui/tests/daemon_shutdown_reconnect_headless.rs b/crates/pa-tui/tests/daemon_shutdown_reconnect_headless.rs index 6900245d2..955cbbb70 100644 --- a/crates/pa-tui/tests/daemon_shutdown_reconnect_headless.rs +++ b/crates/pa-tui/tests/daemon_shutdown_reconnect_headless.rs @@ -361,6 +361,7 @@ fn options_with_session(socket: PathBuf, session: SessionSelection) -> Interacti /// The operator's daemon restart recovers an attached window (TS #2458): the announced non-update /// closing arms the bounded shutdown recovery, the pane stays mounted while it waits, and the /// restarted daemon's reattach lands. +#[pa_test_scratch::pa_test] #[test] fn an_announced_shutdown_reconnects_when_the_daemon_comes_back() { // The ambient TMUX variable adds a startup notice; scrub it so runs are the same inside tmux diff --git a/crates/pa-tui/tests/daemon_shutdown_turn_end_headless.rs b/crates/pa-tui/tests/daemon_shutdown_turn_end_headless.rs index 4dfa0f6f3..baa4e21af 100644 --- a/crates/pa-tui/tests/daemon_shutdown_turn_end_headless.rs +++ b/crates/pa-tui/tests/daemon_shutdown_turn_end_headless.rs @@ -380,6 +380,7 @@ fn options_with_session(socket: PathBuf, session: SessionSelection) -> Interacti /// A turn settling as the daemon dies must not stall the recovery (the post-turn refresh on the /// dead socket): the announced shutdown arms the bounded recovery and the restarted daemon's /// reattach lands on the first fixed poll. +#[pa_test_scratch::pa_test] #[test] fn a_turn_settling_with_the_shutdown_does_not_stall_the_recovery() { // The ambient TMUX variable adds a startup notice; scrub it so runs are the same inside tmux diff --git a/crates/pa-tui/tests/dock_arrows_headless.rs b/crates/pa-tui/tests/dock_arrows_headless.rs index 453e653d0..eea956581 100644 --- a/crates/pa-tui/tests/dock_arrows_headless.rs +++ b/crates/pa-tui/tests/dock_arrows_headless.rs @@ -381,6 +381,7 @@ fn run_plan_with_roster( /// The arrows still visit each empty section in order, each opening its own view (panel-exit /// ruling 2026-09-26); Left from the subagents section opens the scoped agents view (2026-09-28). +#[pa_test_scratch::pa_test] #[test] fn dock_arrows_visit_each_empty_section_in_order_both_directions() { let steps = vec![ @@ -463,6 +464,7 @@ fn dock_arrows_visit_each_empty_section_in_order_both_directions() { } /// Filling a section never moves another (panel-exit ruling 2026-09-26 keeps the dock focused). +#[pa_test_scratch::pa_test] #[test] fn dock_arrows_visit_the_same_sections_when_one_has_rows() { let steps = vec![ @@ -529,6 +531,7 @@ fn dock_arrows_visit_the_same_sections_when_one_has_rows() { /// Left from the subagents selection opens the agents view (the operator's 2026-09-28 ask): the TS /// dock has no left/right handling at all, so this is the documented Rust divergence; the editor's /// `agents back` is the same rule on the adjacent surface. +#[pa_test_scratch::pa_test] #[test] fn left_from_the_subagents_selection_opens_the_agents_view() { let steps = vec![ @@ -556,6 +559,7 @@ fn left_from_the_subagents_selection_opens_the_agents_view() { /// The all-zero dock (the operator's 2026-09-28 directive): the dock row still renders zero /// counts, and Enter on the Subagents group opens the scoped agents view's empty roster. +#[pa_test_scratch::pa_test] #[test] fn an_all_zero_dock_renders_and_opens_the_empty_scoped_agents_view() { let steps = vec![ @@ -654,6 +658,7 @@ fn goal_event_push(seconds: u64) -> Value { /// The dock's event-driven update contract, pinned ahead of the run loop's per-wake recompute /// removal: a `roster_update` push alone repaints the running count and the title's family cost. +#[pa_test_scratch::pa_test] #[test] fn a_roster_push_alone_remounts_the_dock_count_and_the_title_cost() { let steps = vec![ @@ -680,6 +685,7 @@ fn a_roster_push_alone_remounts_the_dock_count_and_the_title_cost() { } /// A `goal_update` event alone mounts the dock's goal row. +#[pa_test_scratch::pa_test] #[test] fn b_a_goal_update_alone_mounts_the_dock_goal_row() { let steps = vec![HeadlessStep::WaitRender { @@ -698,6 +704,7 @@ fn b_a_goal_update_alone_mounts_the_dock_goal_row() { /// A child's settle — the roster push flipping it running to idle — drops the dock's running count /// on its own event. +#[pa_test_scratch::pa_test] #[test] fn c_a_child_settle_alone_drops_the_dock_running_count() { let steps = vec![HeadlessStep::WaitRender { @@ -721,6 +728,7 @@ fn c_a_child_settle_alone_drops_the_dock_running_count() { /// The attach fold: the `roster_subscribe` snapshot's running counts mount in the open's FIRST /// frame, and a session switch's fresh snapshot re-mounts them in the switch's first rebuilt /// frame — the counts follow the newly attached session. +#[pa_test_scratch::pa_test] #[test] fn d_the_attach_mounts_the_snapshot_counts_in_its_first_frame_and_a_switch_follows() { let steps = vec![ diff --git a/crates/pa-tui/tests/dock_click_headless.rs b/crates/pa-tui/tests/dock_click_headless.rs index 8d30d059c..a3b1e7afb 100644 --- a/crates/pa-tui/tests/dock_click_headless.rs +++ b/crates/pa-tui/tests/dock_click_headless.rs @@ -390,6 +390,7 @@ fn visible_col(line: &str, needle: &str) -> Option { } /// The focused Enter's dispatch, arrived at by the mouse. +#[pa_test_scratch::pa_test] #[test] fn a_click_on_the_heartbeats_group_opens_the_heartbeats_view() { let frames = settled_frames("1 heartbeat"); @@ -418,6 +419,7 @@ fn a_click_on_the_heartbeats_group_opens_the_heartbeats_view() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_click_on_the_shells_group_opens_the_bash_view() { let frames = settled_frames("1 shell"); @@ -443,6 +445,7 @@ fn a_click_on_the_shells_group_opens_the_bash_view() { } /// The handoff carries this session's scope. +#[pa_test_scratch::pa_test] #[test] fn a_click_on_the_subagents_group_hands_off_to_the_scoped_agents_view() { let frames = settled_frames("1 heartbeat"); @@ -468,6 +471,7 @@ fn a_click_on_the_subagents_group_hands_off_to_the_scoped_agents_view() { } /// The left arrow's agents-back handoff — the GLOBAL agents view, no scope. +#[pa_test_scratch::pa_test] #[test] fn a_click_on_the_manage_hint_hands_off_to_the_agents_view() { let frames = settled_frames("1 heartbeat"); @@ -492,6 +496,7 @@ fn a_click_on_the_manage_hint_hands_off_to_the_agents_view() { } /// The dock's Enter route for the goal row. +#[pa_test_scratch::pa_test] #[test] fn a_click_on_the_goal_group_opens_the_goal_panel() { let frames = settled_frames("Pursuing goal"); @@ -518,6 +523,7 @@ fn a_click_on_the_goal_group_opens_the_goal_panel() { /// The hint's click keeps the key's gate: with a draft the left arrow is the caret motion, not /// the agents-back handoff (Macroscope: the unconditional dispatch stashed a draft). +#[pa_test_scratch::pa_test] #[test] fn a_click_on_the_manage_hint_with_a_draft_opens_nothing() { let frames = settled_frames("manage"); @@ -552,6 +558,7 @@ fn a_click_on_the_manage_hint_with_a_draft_opens_nothing() { } /// The gap between segments is inert — the cells the click surface never recorded. +#[pa_test_scratch::pa_test] #[test] fn a_click_on_the_separator_between_groups_opens_nothing() { let frames = settled_frames("1 heartbeat"); @@ -588,6 +595,7 @@ fn a_click_on_the_separator_between_groups_opens_nothing() { ); } +#[pa_test_scratch::pa_test] #[test] fn hover_motions_across_the_dock_never_disturb_the_click() { let frames = settled_frames("1 heartbeat"); diff --git a/crates/pa-tui/tests/dock_panel_exit_focus_headless.rs b/crates/pa-tui/tests/dock_panel_exit_focus_headless.rs index f2b5a062f..25f5d11c9 100644 --- a/crates/pa-tui/tests/dock_panel_exit_focus_headless.rs +++ b/crates/pa-tui/tests/dock_panel_exit_focus_headless.rs @@ -382,6 +382,7 @@ fn goal_exit_plan(exit: KeyCode) -> Vec { /// ESC from the Heartbeats panel lands back on the dock's Heartbeates item: the second Enter /// re-opens the same panel (an empty-draft Enter submits nothing). +#[pa_test_scratch::pa_test] #[test] fn heartbeats_panel_esc_returns_to_the_dock_item() { let outcome = run_plan(heartbeats_exit_plan(KeyCode::Esc)); @@ -399,6 +400,7 @@ fn heartbeats_panel_esc_returns_to_the_dock_item() { /// The `/heartbeats` COMMAND path (not the dock's Enter) leaves the dock's Heartbeates item /// selected too: with the selection parked on the goal row, submitting `/heartbeats` and leaving /// with ESC lands on the Heartbeates item. +#[pa_test_scratch::pa_test] #[test] fn heartbeats_command_path_esc_returns_to_the_dock_item() { let outcome = run_plan(vec![ @@ -434,6 +436,7 @@ fn heartbeats_command_path_esc_returns_to_the_dock_item() { ); } +#[pa_test_scratch::pa_test] #[test] fn heartbeats_panel_left_returns_to_the_dock_item() { let outcome = run_plan(heartbeats_exit_plan(KeyCode::Left)); @@ -448,6 +451,7 @@ fn heartbeats_panel_left_returns_to_the_dock_item() { ); } +#[pa_test_scratch::pa_test] #[test] fn shells_panel_esc_returns_to_the_dock_item() { let outcome = run_plan(shells_exit_plan(KeyCode::Esc)); @@ -462,6 +466,7 @@ fn shells_panel_esc_returns_to_the_dock_item() { ); } +#[pa_test_scratch::pa_test] #[test] fn shells_panel_left_returns_to_the_dock_item() { let outcome = run_plan(shells_exit_plan(KeyCode::Left)); @@ -476,6 +481,7 @@ fn shells_panel_left_returns_to_the_dock_item() { ); } +#[pa_test_scratch::pa_test] #[test] fn goal_panel_esc_returns_to_the_dock_item() { let outcome = run_plan(goal_exit_plan(KeyCode::Esc)); @@ -490,6 +496,7 @@ fn goal_panel_esc_returns_to_the_dock_item() { ); } +#[pa_test_scratch::pa_test] #[test] fn goal_panel_left_returns_to_the_dock_item() { let outcome = run_plan(goal_exit_plan(KeyCode::Left)); diff --git a/crates/pa-tui/tests/drag_select_perf.rs b/crates/pa-tui/tests/drag_select_perf.rs index e3f990ada..8a0baff61 100644 --- a/crates/pa-tui/tests/drag_select_perf.rs +++ b/crates/pa-tui/tests/drag_select_perf.rs @@ -280,6 +280,7 @@ fn timed_drag(messages: usize) -> (Vec, Vec, Duration, usize) { (frames, copies, elapsed, last_render - first_render) } +#[pa_test_scratch::pa_test] #[test] fn timing_checkpoints_preserve_rendered_frames_and_copies() { let expected = run_plan(40, drag_burst(None)); @@ -360,6 +361,7 @@ fn drag_cost(messages: usize) -> (Duration, Vec, String) { (best, intervals, extracted) } +#[pa_test_scratch::pa_test] #[test] fn drag_select_frame_cost_is_independent_of_session_size() { let small = 40usize; diff --git a/crates/pa-tui/tests/editor_keybinds_parity_headless.rs b/crates/pa-tui/tests/editor_keybinds_parity_headless.rs index 30c4e3262..253fac0ca 100644 --- a/crates/pa-tui/tests/editor_keybinds_parity_headless.rs +++ b/crates/pa-tui/tests/editor_keybinds_parity_headless.rs @@ -239,6 +239,7 @@ fn ctrl_home() -> HeadlessStep { key(KeyCode::Home, KeyModifiers::CONTROL) } +#[pa_test_scratch::pa_test] #[test] fn paste_undo_redo_round_trip() { let frames = run_plan(vec![ @@ -282,6 +283,7 @@ fn paste_undo_redo_round_trip() { ); } +#[pa_test_scratch::pa_test] #[test] fn select_all_replaces_and_undo_restores() { let frames = run_plan(vec![ @@ -307,6 +309,7 @@ fn select_all_replaces_and_undo_restores() { ); } +#[pa_test_scratch::pa_test] #[test] fn shift_selection_backspace_deletes_the_selection() { let frames = run_plan(vec![ @@ -325,6 +328,7 @@ fn shift_selection_backspace_deletes_the_selection() { ); } +#[pa_test_scratch::pa_test] #[test] fn ctrl_home_jumps_to_the_start() { let frames = run_plan(vec![ diff --git a/crates/pa-tui/tests/effort_tray_label_headless.rs b/crates/pa-tui/tests/effort_tray_label_headless.rs index c95292e7f..7b6ed0ef4 100644 --- a/crates/pa-tui/tests/effort_tray_label_headless.rs +++ b/crates/pa-tui/tests/effort_tray_label_headless.rs @@ -326,6 +326,7 @@ fn run_plan(session: MockSession, steps: Vec) -> Vec { /// `/effort` moves the tray's `model:effort` label live: the attach state seeds /// `glm-5.3:medium`, and the switch's level lands as `glm-5.3:high`. +#[pa_test_scratch::pa_test] #[test] fn effort_command_moves_the_tray_model_label() { let steps = vec![ @@ -359,6 +360,7 @@ fn effort_command_moves_the_tray_model_label() { /// A successful `/effort` switch whose state re-read fails still moves the label: the requested /// level renders (TS `applyThinkingLevel` patches the connection state), never the stale suffix. +#[pa_test_scratch::pa_test] #[test] fn effort_switch_with_failed_state_read_never_keeps_the_stale_suffix() { let mut session = reasoning_session(); @@ -388,6 +390,7 @@ fn effort_switch_with_failed_state_read_never_keeps_the_stale_suffix() { } /// The state's level is "off", but the tray never carries a suffix. +#[pa_test_scratch::pa_test] #[test] fn tray_label_stays_bare_without_reasoning() { let steps = vec![HeadlessStep::WaitRender { diff --git a/crates/pa-tui/tests/esc_repeat_ladder_headless.rs b/crates/pa-tui/tests/esc_repeat_ladder_headless.rs index 00879817f..6e6ca0dfc 100644 --- a/crates/pa-tui/tests/esc_repeat_ladder_headless.rs +++ b/crates/pa-tui/tests/esc_repeat_ladder_headless.rs @@ -428,6 +428,7 @@ const TREE_PANE: &str = "Session Tree"; /// Sixty Escape presses at the empty editor: the repeat's tree action fires exactly once and the /// ladder terminates instead of cycling the selector every second press. +#[pa_test_scratch::pa_test] #[test] fn repeated_escape_converges_to_the_inert_empty_state() { let mut steps = vec![HeadlessStep::WaitMs(300)]; @@ -459,6 +460,7 @@ fn repeated_escape_converges_to_the_inert_empty_state() { /// A non-Escape key re-arms the gesture: after the converged inert tail, one arrow press starts a /// fresh input chain and the next double-Esc opens the selector again. +#[pa_test_scratch::pa_test] #[test] fn a_non_escape_key_re_arms_the_double_escape_gesture() { let mut steps = vec![HeadlessStep::WaitMs(300)]; diff --git a/crates/pa-tui/tests/info_panel_headless.rs b/crates/pa-tui/tests/info_panel_headless.rs index 44dd83314..0e3fe803b 100644 --- a/crates/pa-tui/tests/info_panel_headless.rs +++ b/crates/pa-tui/tests/info_panel_headless.rs @@ -277,6 +277,7 @@ const PANEL_HINT: &str = "Esc close"; /// Every flooding command opens the read-only info panel inline, ESC closes it, and the transcript /// gains nothing; `?` types into the editor instead of mounting the removed guide. +#[pa_test_scratch::pa_test] #[test] fn info_commands_open_inline_panels_that_esc_closes_without_transcript_rows() { let steps = vec![ diff --git a/crates/pa-tui/tests/loader_anchor_headless.rs b/crates/pa-tui/tests/loader_anchor_headless.rs index 55148c655..221a6b75b 100644 --- a/crates/pa-tui/tests/loader_anchor_headless.rs +++ b/crates/pa-tui/tests/loader_anchor_headless.rs @@ -289,6 +289,7 @@ fn loader_elapsed_secs(prompt_age_ms: u64) -> u64 { /// The operator's contract (2026-09-28): the waiting/executing timer counts since the LAST HUMAN /// PROMPT and NEVER resets on a view transition; a NEWER prompt re-anchors the clock onto itself. +#[pa_test_scratch::pa_test] #[test] fn the_loader_anchor_survives_the_agents_view_round_trip() { // The turn's prompt landed 25s ago. First attach (the turn running): the loader already counts diff --git a/crates/pa-tui/tests/loader_quiet_turn_headless.rs b/crates/pa-tui/tests/loader_quiet_turn_headless.rs index 382a9482f..ab06dbefb 100644 --- a/crates/pa-tui/tests/loader_quiet_turn_headless.rs +++ b/crates/pa-tui/tests/loader_quiet_turn_headless.rs @@ -223,6 +223,7 @@ fn options(socket: PathBuf) -> InteractiveOptions { /// How long the mock's turn stays silent before `turn_end`. const QUIET_TURN_MS: u64 = 3500; +#[pa_test_scratch::pa_test] #[test] fn a_quiet_turn_keeps_the_loader_animating() { // The ambient TMUX variable adds a startup notice to the diff --git a/crates/pa-tui/tests/model_picker_provider_headless.rs b/crates/pa-tui/tests/model_picker_provider_headless.rs index e00df1173..10e418584 100644 --- a/crates/pa-tui/tests/model_picker_provider_headless.rs +++ b/crates/pa-tui/tests/model_picker_provider_headless.rs @@ -303,6 +303,7 @@ fn run_plan(steps: Vec) -> Vec { /// The operator's duplicate-id repro: the session runs `prime-inference/z-ai/glm-5.3`, the catalog /// lists the same id under openrouter FIRST — the prime-inference row carries `current`. +#[pa_test_scratch::pa_test] #[test] fn the_picker_marks_the_sessions_own_provider_current() { let frames = run_plan(vec![ diff --git a/crates/pa-tui/tests/mouse_click_open_headless.rs b/crates/pa-tui/tests/mouse_click_open_headless.rs index 161d10a05..d80f98ad2 100644 --- a/crates/pa-tui/tests/mouse_click_open_headless.rs +++ b/crates/pa-tui/tests/mouse_click_open_headless.rs @@ -309,6 +309,7 @@ fn plain_position() -> (usize, usize) { /// A press-release without a drag over the link label opens its OSC 8 target (TS /// `fullscreenPressedHyperlink`'s release branch). +#[pa_test_scratch::pa_test] #[test] fn click_on_a_transcript_link_opens_it() { let (row, col) = link_position(); @@ -328,6 +329,7 @@ fn click_on_a_transcript_link_opens_it() { } /// The release with a selection copies and never opens (TS: the hasSelection branch wins). +#[pa_test_scratch::pa_test] #[test] fn drag_over_a_link_selects_it_instead_of_opening() { let (row, col) = link_position(); @@ -347,6 +349,7 @@ fn drag_over_a_link_selects_it_instead_of_opening() { } /// Only cells inside a link's OSC 8 range resolve a URL. +#[pa_test_scratch::pa_test] #[test] fn click_on_plain_text_opens_nothing() { let (row, col) = plain_position(); diff --git a/crates/pa-tui/tests/mouse_scroll_headless.rs b/crates/pa-tui/tests/mouse_scroll_headless.rs index 70b5a875d..b677e110f 100644 --- a/crates/pa-tui/tests/mouse_scroll_headless.rs +++ b/crates/pa-tui/tests/mouse_scroll_headless.rs @@ -286,6 +286,7 @@ fn run_plan(steps: Vec, fullscreen_mouse: bool) -> Vec { /// Wheel turns scroll the transcript: up pauses tail-following and drops the newest message /// from the window; wheel-down scrolls back, and reaching the bottom resumes following. +#[pa_test_scratch::pa_test] #[test] fn wheel_turns_scroll_the_transcript() { let mut steps = vec![HeadlessStep::Mouse(WHEEL_UP.to_string()); 18]; @@ -322,6 +323,7 @@ fn wheel_turns_scroll_the_transcript() { /// The TS overlay-focus gate: the wheel is consumed while the picker owns /// the frame. +#[pa_test_scratch::pa_test] #[test] fn wheel_is_ignored_while_a_picker_owns_the_frame() { let steps = vec![ @@ -353,6 +355,7 @@ fn wheel_is_ignored_while_a_picker_owns_the_frame() { ); } +#[pa_test_scratch::pa_test] #[test] fn wheel_reports_are_consumed_when_tracking_is_disabled() { let steps = vec![ @@ -374,6 +377,7 @@ fn wheel_reports_are_consumed_when_tracking_is_disabled() { } /// Dispatch decoded terminal reports through `SessionUi` and compare the actual painted rows. +#[pa_test_scratch::pa_test] #[test] fn each_wheel_report_moves_exactly_one_rendered_row() { let frames = run_plan( diff --git a/crates/pa-tui/tests/mouse_selection_headless.rs b/crates/pa-tui/tests/mouse_selection_headless.rs index 11f16d9bc..e1651bdb5 100644 --- a/crates/pa-tui/tests/mouse_selection_headless.rs +++ b/crates/pa-tui/tests/mouse_selection_headless.rs @@ -317,6 +317,7 @@ fn top_layout() -> (usize, usize, usize, usize, usize, usize) { (row0, col0, answer_row, answer_col, ctx_row, ctx_col) } +#[pa_test_scratch::pa_test] #[test] fn press_drag_release_copies_the_spanned_transcript_text() { let (row0, col0, ..) = top_layout(); @@ -338,6 +339,7 @@ fn press_drag_release_copies_the_spanned_transcript_text() { /// A drag spanning rows copies each row's slice — the anchor's row from the anchor column, the /// spacer rows as empty lines, the head's row up to the head column (TS `extractSelectionText`). +#[pa_test_scratch::pa_test] #[test] fn multi_row_drag_copies_each_line() { let (row0, col0, answer_row, answer_col, ..) = top_layout(); @@ -364,6 +366,7 @@ fn multi_row_drag_copies_each_line() { } /// TS: the anchor and head coincide, so the release takes the clear branch. +#[pa_test_scratch::pa_test] #[test] fn click_without_drag_copies_nothing() { let (row0, col0, ..) = top_layout(); @@ -379,6 +382,7 @@ fn click_without_drag_copies_nothing() { /// A press on the dock starts a frame selection over the row's visible span (TS /// `beginFrameSelection`). +#[pa_test_scratch::pa_test] #[test] fn dock_press_drag_copies_the_frame_region() { let (_, _, _, _, ctx_row, ctx_col) = top_layout(); @@ -400,6 +404,7 @@ fn dock_press_drag_copies_the_frame_region() { assert_eq!(copies, vec!["Collap".to_string()], "the dock span copied"); } +#[pa_test_scratch::pa_test] #[test] fn selection_reports_are_consumed_when_tracking_is_disabled() { let (row0, col0, ..) = top_layout(); diff --git a/crates/pa-tui/tests/nightly_command_headless.rs b/crates/pa-tui/tests/nightly_command_headless.rs index cf0c91bc5..8bee32c89 100644 --- a/crates/pa-tui/tests/nightly_command_headless.rs +++ b/crates/pa-tui/tests/nightly_command_headless.rs @@ -385,6 +385,7 @@ fn run_plan(steps: Vec) -> Vec { /// `/nightly status` reports the inferred channel (the harness has no settings seam, so no /// preferred channel is set) and the running version; a bad argument gets the TS usage error. +#[pa_test_scratch::pa_test] #[test] fn nightly_status_and_usage_error_render_the_ts_wording() { let steps = vec![ @@ -408,6 +409,7 @@ fn nightly_status_and_usage_error_render_the_ts_wording() { /// `/nightly on` (or bare) saves the nightly channel that `/update` and /// `prime-agent update` follow. +#[pa_test_scratch::pa_test] #[test] fn nightly_on_saves_the_nightly_channel() { let steps = vec![ @@ -428,6 +430,7 @@ fn nightly_on_saves_the_nightly_channel() { ); } +#[pa_test_scratch::pa_test] #[test] fn nightly_off_renders_the_stable_pin_note() { let steps = vec![ diff --git a/crates/pa-tui/tests/plugins_command_headless.rs b/crates/pa-tui/tests/plugins_command_headless.rs index 4ee115c52..ebb88257f 100644 --- a/crates/pa-tui/tests/plugins_command_headless.rs +++ b/crates/pa-tui/tests/plugins_command_headless.rs @@ -411,6 +411,7 @@ fn wait(needle: &str) -> HeadlessStep { } } +#[pa_test_scratch::pa_test] #[test] fn plugins_manages_native_lua_while_mcp_keeps_connections() { let (frames, requests) = run_plan( @@ -441,6 +442,7 @@ fn plugins_manages_native_lua_while_mcp_keeps_connections() { ); } +#[pa_test_scratch::pa_test] #[test] fn unknown_and_streaming_plugin_commands_never_become_model_prompts() { let (frames, requests) = run_plan( @@ -466,6 +468,7 @@ fn unknown_and_streaming_plugin_commands_never_become_model_prompts() { ); } +#[pa_test_scratch::pa_test] #[test] fn old_worker_explicitly_rejects_native_commands_without_sending() { let (frames, requests) = run_plan( @@ -489,6 +492,7 @@ fn old_worker_explicitly_rejects_native_commands_without_sending() { ); } +#[pa_test_scratch::pa_test] #[test] fn reload_dispatches_to_the_worker_and_refreshes_discovery() { let (frames, requests) = run_plan( @@ -521,6 +525,7 @@ fn reload_dispatches_to_the_worker_and_refreshes_discovery() { ); } +#[pa_test_scratch::pa_test] #[test] fn plugin_completion_dispatches_with_its_generation_target() { let enter = || { @@ -556,6 +561,7 @@ fn plugin_completion_dispatches_with_its_generation_target() { ); } +#[pa_test_scratch::pa_test] #[test] fn delayed_previous_session_catalog_cannot_replace_the_rebound_worker_catalog() { let (frames, requests) = run_plan( @@ -585,6 +591,7 @@ fn delayed_previous_session_catalog_cannot_replace_the_rebound_worker_catalog() ); } +#[pa_test_scratch::pa_test] #[test] fn early_template_input_waits_for_discovery_and_keeps_template_admission() { let (_, requests) = run_plan( @@ -614,6 +621,7 @@ fn early_template_input_waits_for_discovery_and_keeps_template_admission() { ); } +#[pa_test_scratch::pa_test] #[test] fn failed_catalog_does_not_fall_back_to_a_paid_prompt() { let (_, requests) = run_plan( @@ -631,6 +639,7 @@ fn failed_catalog_does_not_fall_back_to_a_paid_prompt() { ); } +#[pa_test_scratch::pa_test] #[test] fn failed_management_reconcile_refreshes_commands_after_applied_disable() { for management in ["/reload", "/plugins disable fixture"] { diff --git a/crates/pa-tui/tests/prompt_history_nav_headless.rs b/crates/pa-tui/tests/prompt_history_nav_headless.rs index 8aca672c4..8dca16c66 100644 --- a/crates/pa-tui/tests/prompt_history_nav_headless.rs +++ b/crates/pa-tui/tests/prompt_history_nav_headless.rs @@ -340,6 +340,7 @@ fn wait_gone(needle: &str) -> HeadlessStep { } } +#[pa_test_scratch::pa_test] #[test] fn up_walks_backward_down_forward_and_the_draft_returns() { let mut steps = Vec::new(); @@ -368,6 +369,7 @@ fn up_walks_backward_down_forward_and_the_draft_returns() { /// operator's 2026-10-01 consistency ruling — here one heartbeat and no /// subagents), and the recall stays one press away: the Up after that /// Down returns the focus to the prompt, and the next Up recalls. +#[pa_test_scratch::pa_test] #[test] fn the_drafts_down_enters_the_dock_and_up_returns_before_the_recall() { let mut steps = Vec::new(); @@ -401,6 +403,7 @@ fn the_drafts_down_enters_the_dock_and_up_returns_before_the_recall() { /// Coexistence: the right arrow walks to the heartbeats group (the 2026-09-26 dock-arrows /// directive), and Escape closes the panel onto the dock's own item (the 2026-09-26 panel-exit /// ruling): the history recall works right after the round trip. +#[pa_test_scratch::pa_test] #[test] fn alt_a_arrows_and_enter_still_open_the_dock_group_view_and_recall_survives_it() { let mut steps = Vec::new(); diff --git a/crates/pa-tui/tests/quiet_tick_busy_stream_headless.rs b/crates/pa-tui/tests/quiet_tick_busy_stream_headless.rs index 8cfec3f09..eecb9dbf3 100644 --- a/crates/pa-tui/tests/quiet_tick_busy_stream_headless.rs +++ b/crates/pa-tui/tests/quiet_tick_busy_stream_headless.rs @@ -202,6 +202,7 @@ fn run_plan(steps: Vec) -> Vec { /// A parked autocomplete request materializes while the reply streams: the second barrier /// releases only on the dropdown's selected row, and its budget is shorter than the stream, /// so a tick that waits for the stream to pause times the barrier out instead. +#[pa_test_scratch::pa_test] #[test] fn the_quiet_tick_materializes_autocomplete_while_a_reply_streams() { let frames = run_plan(vec![ @@ -225,6 +226,7 @@ fn the_quiet_tick_materializes_autocomplete_while_a_reply_streams() { /// A keystroke restarts the window: a typed command plus its Enter in one burst submits as /// typed, instead of a mid-burst dropdown's Enter completing the command into its args. +#[pa_test_scratch::pa_test] #[test] fn a_typed_command_burst_submits_as_typed() { let mut steps = vec![ diff --git a/crates/pa-tui/tests/refresh_command_headless.rs b/crates/pa-tui/tests/refresh_command_headless.rs index 0045dd658..c2c0793cc 100644 --- a/crates/pa-tui/tests/refresh_command_headless.rs +++ b/crates/pa-tui/tests/refresh_command_headless.rs @@ -244,6 +244,7 @@ fn wait(needle: &str) -> HeadlessStep { } } +#[pa_test_scratch::pa_test] #[test] fn refresh_reports_fixed_fields_without_changing_the_selected_model() { let (frames, commands) = run_plan( @@ -274,6 +275,7 @@ fn refresh_reports_fixed_fields_without_changing_the_selected_model() { .any(|command| command["type"] == "set_model")); } +#[pa_test_scratch::pa_test] #[test] fn old_or_unadvertised_daemons_are_not_sent_refresh_commands() { for (revision, supported) in [(31, true), (32, false)] { @@ -296,6 +298,7 @@ fn old_or_unadvertised_daemons_are_not_sent_refresh_commands() { } } +#[pa_test_scratch::pa_test] #[test] fn busy_refresh_is_rejected_without_a_request() { let (_, commands) = run_plan( @@ -314,6 +317,7 @@ fn busy_refresh_is_rejected_without_a_request() { .any(|command| command["type"] == "refresh_models")); } +#[pa_test_scratch::pa_test] #[test] fn a_hanging_refresh_does_not_block_input_or_paint() { let (tx, rx) = std::sync::mpsc::channel(); diff --git a/crates/pa-tui/tests/replay_images.rs b/crates/pa-tui/tests/replay_images.rs index 8a93867c9..5d24d545a 100644 --- a/crates/pa-tui/tests/replay_images.rs +++ b/crates/pa-tui/tests/replay_images.rs @@ -61,6 +61,7 @@ fn session_with_image(png: &str, with_text_prompt: bool) -> String { ) } +#[pa_test_scratch::pa_test] #[test] fn replayed_image_blocks_render_placeholder_rows() { let png = tiny_png_base64(); @@ -78,6 +79,7 @@ fn replayed_image_blocks_render_placeholder_rows() { ); } +#[pa_test_scratch::pa_test] #[test] fn replayed_images_hidden_setting_swaps_the_placeholder_form() { let png = tiny_png_base64(); diff --git a/crates/pa-tui/tests/replay_tables.rs b/crates/pa-tui/tests/replay_tables.rs index 92faa2eb3..242dd270b 100644 --- a/crates/pa-tui/tests/replay_tables.rs +++ b/crates/pa-tui/tests/replay_tables.rs @@ -49,6 +49,7 @@ fn frame_text(session: &str, width: u16, height: u16) -> Vec { rows } +#[pa_test_scratch::pa_test] #[test] fn replayed_table_renders_boxed_aligned_rows() { let rows = frame_text(TABLE_SESSION, 100, 30); @@ -82,6 +83,7 @@ fn replayed_table_renders_boxed_aligned_rows() { assert!(flat.contains("example.com/log)"), "link row 2: {flat}"); } +#[pa_test_scratch::pa_test] #[test] fn replayed_table_narrow_terminal_falls_back_to_raw() { let rows = frame_text(TABLE_SESSION, 12, 60); diff --git a/crates/pa-tui/tests/service_tier_headless.rs b/crates/pa-tui/tests/service_tier_headless.rs index c3466e79d..150b849f0 100644 --- a/crates/pa-tui/tests/service_tier_headless.rs +++ b/crates/pa-tui/tests/service_tier_headless.rs @@ -300,6 +300,7 @@ fn run_plan(steps: Vec) -> Vec { outcome.frames } +#[pa_test_scratch::pa_test] #[test] fn tier_command_shows_applies_and_rejects() { // The leading settle (the sibling harnesses' pattern): the attach must land its model + diff --git a/crates/pa-tui/tests/settings_menu_headless.rs b/crates/pa-tui/tests/settings_menu_headless.rs index 516b58cbb..97958b018 100644 --- a/crates/pa-tui/tests/settings_menu_headless.rs +++ b/crates/pa-tui/tests/settings_menu_headless.rs @@ -517,6 +517,7 @@ fn open_settings() -> Vec { /// The spacing pass: a blank row above and below the tab strip, four spaces between the tabs, /// the separator rule below the description, the hint carrying the description's padding. +#[pa_test_scratch::pa_test] #[test] fn the_settings_page_renders_the_spacing_and_the_new_keys() { let (frames, _) = run_plan(open_settings()); @@ -572,6 +573,7 @@ fn the_settings_page_renders_the_spacing_and_the_new_keys() { /// Right flips the Quiet startup toggle, left flips it back, Enter keeps its cycle; the /// multi-option Idle eviction row walks its list the same way. +#[pa_test_scratch::pa_test] #[test] fn the_arrows_cycle_values_and_the_writes_persist() { let mut steps = open_settings(); @@ -618,6 +620,7 @@ fn the_arrows_cycle_values_and_the_writes_persist() { ); } +#[pa_test_scratch::pa_test] #[test] fn tab_and_the_number_keys_move_the_tabs_not_the_arrows() { let mut steps = open_settings(); @@ -653,6 +656,7 @@ fn tab_and_the_number_keys_move_the_tabs_not_the_arrows() { /// The two regression pins: the full-width rule stays over the submenu, and the setting's rows /// keep the list rows' two-space padding — the hint too. +#[pa_test_scratch::pa_test] #[test] fn opening_into_a_setting_keeps_the_bar_and_the_padding() { let mut steps = open_settings(); @@ -689,6 +693,7 @@ fn opening_into_a_setting_keeps_the_bar_and_the_padding() { } /// A toggle for an unsupported mode is worse than none. +#[pa_test_scratch::pa_test] #[test] fn the_fullscreen_setting_and_command_are_retired() { let mut steps = open_settings(); @@ -728,6 +733,7 @@ fn the_fullscreen_setting_and_command_are_retired() { /// The search field keeps its edit keys after a no-match query: the /// garbage backspaces away, the rows return, and Space still cycles /// the selected row (TS `SettingsList.handleInput`). +#[pa_test_scratch::pa_test] #[test] fn a_no_match_query_backspaces_away_and_space_still_cycles() { let mut steps = open_settings(); @@ -759,6 +765,7 @@ fn a_no_match_query_backspaces_away_and_space_still_cycles() { ); } +#[pa_test_scratch::pa_test] #[test] fn threshold_percentage_cycles_through_the_persistence_seam() { let mut steps = open_settings(); @@ -780,6 +787,7 @@ fn threshold_percentage_cycles_through_the_persistence_seam() { /// The real `SessionUi` must supply discovered themes to the menu, then /// validate and persist the chosen filename through its settings seam. +#[pa_test_scratch::pa_test] #[test] fn a_discovered_custom_theme_is_rendered_previewed_and_persisted() { let mut theme: Value = serde_json::from_str(pa_tui::theme::PRIME_JSON).unwrap(); @@ -826,6 +834,7 @@ fn a_discovered_custom_theme_is_rendered_previewed_and_persisted() { assert_eq!(settings.log(), vec!["theme=terminal-native"]); } +#[pa_test_scratch::pa_test] #[test] fn an_invalid_discovered_theme_shows_a_diagnostic_and_is_not_persisted() { let mut steps = open_settings(); @@ -862,6 +871,7 @@ fn an_invalid_discovered_theme_shows_a_diagnostic_and_is_not_persisted() { assert!(settings.log().is_empty(), "a rejected theme is never saved"); } +#[pa_test_scratch::pa_test] #[test] fn bad_startup_themes_keep_a_visible_diagnostic_after_the_initial_paint() { for initial_theme in ["missing-theme", "broken"] { @@ -898,6 +908,7 @@ fn bad_startup_themes_keep_a_visible_diagnostic_after_the_initial_paint() { } } +#[pa_test_scratch::pa_test] #[test] fn valid_startup_themes_are_silent_and_do_not_rewrite_preferences() { let custom: Value = serde_json::from_str(pa_tui::theme::PRIME_JSON).unwrap(); @@ -919,6 +930,7 @@ fn valid_startup_themes_are_silent_and_do_not_rewrite_preferences() { /// timestamp arrives. Its timeout releases a synchronous-loader mutant too, /// so a failure never leaves the runtime waiting on a blocked file reader. #[cfg(target_os = "linux")] +#[pa_test_scratch::pa_test] #[test] fn a_stalled_startup_theme_does_not_hold_first_paint_or_typing() { let (paint_tx, paint_rx) = std::sync::mpsc::channel(); @@ -971,6 +983,7 @@ fn a_stalled_startup_theme_does_not_hold_first_paint_or_typing() { } #[cfg(target_os = "linux")] +#[pa_test_scratch::pa_test] #[test] fn a_late_startup_theme_failure_cannot_replace_an_intentional_theme_setting() { let (chosen_tx, chosen_rx) = std::sync::mpsc::channel(); @@ -1052,6 +1065,7 @@ fn a_late_startup_theme_failure_cannot_replace_an_intentional_theme_setting() { /// Run the real public headless entry in its own process. A held theme /// read must not keep Tokio runtime teardown (and therefore the CLI) alive. #[cfg(target_os = "linux")] +#[pa_test_scratch::pa_test] #[test] fn quitting_while_a_startup_theme_read_is_held_does_not_hold_process_exit() { let _lock = RUN_LOCK @@ -1100,6 +1114,7 @@ fn quitting_while_a_startup_theme_read_is_held_does_not_hold_process_exit() { }); } #[cfg(target_os = "linux")] +#[pa_test_scratch::pa_test] #[test] #[ignore = "subprocess helper for the bounded whole-process quit verifier"] fn held_startup_theme_quit_child() { diff --git a/crates/pa-tui/tests/skills_menu_headless.rs b/crates/pa-tui/tests/skills_menu_headless.rs index 0597b42a6..a50c19e3d 100644 --- a/crates/pa-tui/tests/skills_menu_headless.rs +++ b/crates/pa-tui/tests/skills_menu_headless.rs @@ -501,6 +501,7 @@ fn run_plan_with_prompts(steps: Vec) -> (Vec, Vec) (outcome.frames, prompts) } +#[pa_test_scratch::pa_test] #[test] fn skill_commands_surface_in_the_slash_menu() { let steps = vec![ @@ -527,6 +528,7 @@ fn skill_commands_surface_in_the_slash_menu() { /// The TS default (`enableSkillCommands: true`) applies with no settings /// seam at all. +#[pa_test_scratch::pa_test] #[test] fn skills_surface_without_a_settings_seam() { std::env::remove_var("TMUX"); @@ -562,6 +564,7 @@ fn skills_surface_without_a_settings_seam() { ); } +#[pa_test_scratch::pa_test] #[test] fn disabled_skill_commands_stay_out_of_the_menu() { use pa_tui::client_settings::ClientSettings; @@ -612,6 +615,7 @@ fn enter() -> crossterm::event::KeyEvent { /// A bare `/skill:` submission never reaches the daemon: the guard restores the draft and /// the notice names the fix. +#[pa_test_scratch::pa_test] #[test] fn a_bare_skill_submit_shows_the_notice_and_never_sends() { let (frames, prompts) = run_plan_with_prompts(vec![ @@ -644,6 +648,7 @@ fn a_bare_skill_submit_shows_the_notice_and_never_sends() { /// The restored draft keeps the argument position: the trailing space survives, so typed keystrokes /// become args instead of gluing onto the command name. +#[pa_test_scratch::pa_test] #[test] fn the_bare_skill_guard_restores_into_the_argument_position() { let (frames, prompts) = run_plan_with_prompts(vec![ @@ -670,6 +675,7 @@ fn the_bare_skill_guard_restores_into_the_argument_position() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_completed_skill_with_args_sends_the_command_and_request() { let (frames, prompts) = run_plan_with_prompts(vec![ diff --git a/crates/pa-tui/tests/slash_menu_panel_headless.rs b/crates/pa-tui/tests/slash_menu_panel_headless.rs index c42791215..0920ba8f2 100644 --- a/crates/pa-tui/tests/slash_menu_panel_headless.rs +++ b/crates/pa-tui/tests/slash_menu_panel_headless.rs @@ -251,6 +251,7 @@ fn run_plan(steps: Vec) -> Vec { outcome.frames } +#[pa_test_scratch::pa_test] #[test] fn slash_menu_opens_with_the_top_border_rule() { let steps = vec![ diff --git a/crates/pa-tui/tests/speed_footer_headless.rs b/crates/pa-tui/tests/speed_footer_headless.rs index 67c05648b..17144553d 100644 --- a/crates/pa-tui/tests/speed_footer_headless.rs +++ b/crates/pa-tui/tests/speed_footer_headless.rs @@ -305,6 +305,7 @@ fn run_plan(steps: Vec) -> Vec { /// `/speed` toggles the footer readout over completed responses: the status note carries the TS /// wording, and the first completed response renders the dim `tok/s` row (the dock's last row). +#[pa_test_scratch::pa_test] #[test] fn speed_command_toggles_the_footer_readout() { let steps = vec![ @@ -354,6 +355,7 @@ fn speed_command_toggles_the_footer_readout() { ); } +#[pa_test_scratch::pa_test] #[test] fn speed_command_rejects_bad_args() { let steps = vec![ diff --git a/crates/pa-tui/tests/stash_restore_before_typed_ahead_headless.rs b/crates/pa-tui/tests/stash_restore_before_typed_ahead_headless.rs index af472d702..7f9709ca4 100644 --- a/crates/pa-tui/tests/stash_restore_before_typed_ahead_headless.rs +++ b/crates/pa-tui/tests/stash_restore_before_typed_ahead_headless.rs @@ -247,6 +247,7 @@ fn options( /// Red on the pre-wave head: the opening loop evaluated `app.exit` /// against the pre-restore empty editor and exited the run during the /// stalled attach (no restore, no draft, empty frames). +#[pa_test_scratch::pa_test] #[test] fn the_reopen_restores_the_stash_before_the_queued_exit_key_evaluates() { std::env::remove_var("TMUX"); diff --git a/crates/pa-tui/tests/touch_click_headless.rs b/crates/pa-tui/tests/touch_click_headless.rs index 3cf6fef4f..1ca765771 100644 --- a/crates/pa-tui/tests/touch_click_headless.rs +++ b/crates/pa-tui/tests/touch_click_headless.rs @@ -423,6 +423,7 @@ fn locate(frames: &[String], needle: &str) -> Option<(usize, usize, usize)> { /// A click on a tool card expands the card's own output (operator directive 2026-09-26); the /// chat opens at the collapsed overview level (operator directive 2026-09-28). +#[pa_test_scratch::pa_test] #[test] fn a_click_on_a_card_expands_it() { let frames = run_plan( @@ -468,6 +469,7 @@ fn a_click_on_a_card_expands_it() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_second_click_on_a_card_collapses_back() { let frames = run_plan( @@ -534,6 +536,7 @@ fn a_second_click_on_a_card_collapses_back() { } /// One click toggles exactly the clicked component (TS per-component `expanded`). +#[pa_test_scratch::pa_test] #[test] fn a_click_toggles_only_the_clicked_component() { let frames = run_plan( @@ -617,6 +620,7 @@ fn a_click_toggles_only_the_clicked_component() { } /// Buttonless motion reports flow through the same decode-and-dispatch path. +#[pa_test_scratch::pa_test] #[test] fn hover_motion_reports_do_not_disturb_the_click_grammar() { let frames = run_plan( @@ -664,6 +668,7 @@ fn hover_motion_reports_do_not_disturb_the_click_grammar() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_click_in_the_prompt_bar_places_the_caret() { let typed = "hello world"; @@ -709,6 +714,7 @@ fn a_click_in_the_prompt_bar_places_the_caret() { } /// The clicked row carries the `›` marker, exactly like the arrows. +#[pa_test_scratch::pa_test] #[test] fn a_click_selects_a_model_picker_row() { let catalog = vec![model("mock-1", "Mock One"), model("mock-2", "Mock Two")]; diff --git a/crates/pa-tui/tests/tray_prompt_down_headless.rs b/crates/pa-tui/tests/tray_prompt_down_headless.rs index 4e6ed2cc2..cb37f5a5f 100644 --- a/crates/pa-tui/tests/tray_prompt_down_headless.rs +++ b/crates/pa-tui/tests/tray_prompt_down_headless.rs @@ -302,6 +302,7 @@ const ALL_ZERO_DOCK: &str = /// Bug 1: with zero subagents (every count zero), the prompt's Down /// enters the dock on its subagents group, and Enter opens the scoped /// agents view — whose empty roster is the view's own empty state. +#[pa_test_scratch::pa_test] #[test] fn prompt_down_enters_the_all_zero_dock_and_enter_opens_subagents() { let steps = vec![ @@ -324,6 +325,7 @@ fn prompt_down_enters_the_all_zero_dock_and_enter_opens_subagents() { /// Every empty group stays reachable from the prompt's Down: Right walks /// to the empty heartbeats and shells groups, and Enter opens each view's /// empty state. +#[pa_test_scratch::pa_test] #[test] fn prompt_down_reaches_every_empty_group() { let steps = vec![ @@ -362,6 +364,7 @@ fn prompt_down_reaches_every_empty_group() { /// Bug 2: with a shell running and zero subagents, the prompt's Down /// enters the dock and two Right presses reach the shells group, whose /// Enter opens the bash view listing the running shell. +#[pa_test_scratch::pa_test] #[test] fn prompt_down_reaches_the_shells_group_with_zero_subagents() { let steps = vec![ @@ -392,6 +395,7 @@ fn prompt_down_reaches_the_shells_group_with_zero_subagents() { /// follows reaches the empty prompt, never the dock's heartbeats group /// (whose view would render its empty state), and the typed text after it /// lands in the prompt — the barrier proves the Enter was handled. +#[pa_test_scratch::pa_test] #[test] fn up_and_esc_return_from_the_dock_to_the_prompt() { for back in [up(), escape()] { diff --git a/crates/pa-tui/tests/tui_rss_stability.rs b/crates/pa-tui/tests/tui_rss_stability.rs index f09f86fe9..03ae1acbb 100644 --- a/crates/pa-tui/tests/tui_rss_stability.rs +++ b/crates/pa-tui/tests/tui_rss_stability.rs @@ -305,6 +305,7 @@ fn stream_turn(writer: &mut UnixStream) { /// A long scripted session must not grow the TUI's resident memory without bound: the transcript /// grows with the session (as designed), but no per-frame or per-event class may accumulate. +#[pa_test_scratch::pa_test] #[test] fn interactive_session_rss_plateaus_over_long_stream() { const TURNS: usize = 40; diff --git a/crates/pa-tui/tests/wake_inventory_headless.rs b/crates/pa-tui/tests/wake_inventory_headless.rs index 91318cf5b..43d4fee91 100644 --- a/crates/pa-tui/tests/wake_inventory_headless.rs +++ b/crates/pa-tui/tests/wake_inventory_headless.rs @@ -179,6 +179,7 @@ fn options(socket: PathBuf) -> InteractiveOptions { /// The first frame paints without any input after the open: the open's rebuild leaves the surface /// dirty, so the only wake is the dirty frame's own deadline on the frame arm. +#[pa_test_scratch::pa_test] #[test] fn the_first_frame_paints_on_a_fully_quiet_link() { let outcome = run_boot_plan(vec![]); @@ -191,6 +192,7 @@ fn the_first_frame_paints_on_a_fully_quiet_link() { /// A `WaitRender` barrier whose needle never arrives pops on its deadline: the barrier's /// re-check runs at the loop top, so the deadline's wake is the only thing that observes it. +#[pa_test_scratch::pa_test] #[test] fn a_wait_render_barrier_times_out_on_a_quiet_surface() { let outcome = run_boot_plan(vec![HeadlessStep::WaitRender { diff --git a/crates/pa-tui/tests/windowed_backfill_headless.rs b/crates/pa-tui/tests/windowed_backfill_headless.rs index 2f8d63a3e..13bddfa33 100644 --- a/crates/pa-tui/tests/windowed_backfill_headless.rs +++ b/crates/pa-tui/tests/windowed_backfill_headless.rs @@ -450,6 +450,7 @@ fn collapsed_markers(frame: &str) -> Vec { }) } +#[pa_test_scratch::pa_test] #[test] fn a_windowed_open_backfills_history_above_the_tail() { let (frames, requests) = run_attached( @@ -496,6 +497,7 @@ fn a_windowed_open_backfills_history_above_the_tail() { ); } +#[pa_test_scratch::pa_test] #[test] fn an_unverified_history_leaf_echo_keeps_the_attached_tail_and_reports_incomplete_history() { // An older worker omits the echo; a wrong echo belongs to another branch. @@ -546,6 +548,7 @@ fn an_unverified_history_leaf_echo_keeps_the_attached_tail_and_reports_incomplet } } +#[pa_test_scratch::pa_test] #[test] fn a_full_snapshot_attach_never_backfills() { let (frames, requests) = run_attached( @@ -574,6 +577,7 @@ fn a_full_snapshot_attach_never_backfills() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_rejected_backfill_retries_then_reports_incomplete_history() { let (frames, requests) = run_attached_with_failures( @@ -591,6 +595,7 @@ fn a_rejected_backfill_retries_then_reports_incomplete_history() { assert_eq!(requests[0], requests[1]); } +#[pa_test_scratch::pa_test] #[test] fn an_exit_with_backfill_in_flight_releases_the_daemon_connection() { let (frames, requests) = run_attached_holding_backfill( @@ -620,6 +625,7 @@ fn an_exit_with_backfill_in_flight_releases_the_daemon_connection() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_reload_rebuild_during_an_in_flight_backfill_keeps_rows_unique_and_ordered() { let (frames, requests) = run_attached_holding_backfill( @@ -676,6 +682,7 @@ fn a_reload_rebuild_during_an_in_flight_backfill_keeps_rows_unique_and_ordered() ); } +#[pa_test_scratch::pa_test] #[test] fn a_changed_or_unverifiable_prefix_is_rejected_before_the_compaction_event() { for state in [ @@ -718,6 +725,7 @@ fn a_changed_or_unverifiable_prefix_is_rejected_before_the_compaction_event() { } } +#[pa_test_scratch::pa_test] #[test] fn a_failed_rebuild_reports_cancelled_incomplete_history() { let (frames, requests) = run_attached_holding_backfill( @@ -881,6 +889,7 @@ fn run_display_peer( outcome } +#[pa_test_scratch::pa_test] #[test] fn issue_19_saved_display_history_replays_every_message_once_and_keeps_redraws_incremental() { let outcome = run_display_peer( @@ -924,6 +933,7 @@ fn issue_19_saved_display_history_replays_every_message_once_and_keeps_redraws_i ); } +#[pa_test_scratch::pa_test] #[test] fn issue_19_same_session_branch_failure_shows_selected_context_then_retries_full_native_history() { let outcome = run_display_peer( diff --git a/crates/pa-tui/tests/working_messages_headless.rs b/crates/pa-tui/tests/working_messages_headless.rs index 132dfc854..eb10ceeb4 100644 --- a/crates/pa-tui/tests/working_messages_headless.rs +++ b/crates/pa-tui/tests/working_messages_headless.rs @@ -389,6 +389,7 @@ fn run_case(resource: Option<&str>, expected: &str, final_event: Value) -> Vec usize { lines } +#[pa_test_scratch::pa_test] #[test] fn committed_fixture_roundtrips() { let mut lines = 0usize; @@ -68,6 +69,7 @@ fn committed_fixture_roundtrips() { /// Live sessions are opt-in: real user data whose presence varies per machine. Set /// `PA_TYPES_LIVE_SESSIONS=1` (optionally `PA_TYPES_SESSIONS_DIR`) to sweep them. +#[pa_test_scratch::pa_test] #[test] fn live_captured_sessions_roundtrip_losslessly() { if std::env::var_os("PA_TYPES_LIVE_SESSIONS").as_deref() != Some(std::ffi::OsStr::new("1")) { diff --git a/crates/pa-types/tests/update_flow_artifacts.rs b/crates/pa-types/tests/update_flow_artifacts.rs index 5b44b4e0b..998fb558f 100644 --- a/crates/pa-types/tests/update_flow_artifacts.rs +++ b/crates/pa-types/tests/update_flow_artifacts.rs @@ -91,6 +91,7 @@ const SPEC_ROSTER: &str = r#"{ ] }"#; +#[pa_test_scratch::pa_test] #[test] fn spec_roster_example_roundtrips_losslessly() { rt::(SPEC_ROSTER); @@ -112,6 +113,7 @@ fn spec_roster_example_roundtrips_losslessly() { ); } +#[pa_test_scratch::pa_test] #[test] fn full_artifact_set_roundtrips() { rt::( @@ -125,6 +127,7 @@ fn full_artifact_set_roundtrips() { ); } +#[pa_test_scratch::pa_test] #[test] fn prepared_artifact_paths_lay_out_under_the_socket_dir() { let agent_dir = Path::new("/ad"); @@ -151,6 +154,7 @@ fn prepared_artifact_paths_lay_out_under_the_socket_dir() { /// Every watchdog outcome (spec §9) must name a transition the coordinator /// table (spec §4) allows from the state it guards. +#[pa_test_scratch::pa_test] #[test] fn watchdog_outcomes_are_legal_transitions() { let legal = [ @@ -175,6 +179,7 @@ fn watchdog_outcomes_are_legal_transitions() { /// The marker timestamp written with the budgeted window must expire /// exactly when the watchdog says so (spec §5, §7, §9). +#[pa_test_scratch::pa_test] #[test] fn prepared_expiry_window_and_marker_verdict_agree() { let budget = UpdateTimeoutBudget::default(); @@ -203,6 +208,7 @@ fn prepared_expiry_window_and_marker_verdict_agree() { /// The status file keeps the TS schema shape: the version constant and the counts field names match /// the TS writer's, so differential tests compare artifacts directly. +#[pa_test_scratch::pa_test] #[test] fn status_schema_is_ts_shaped() { assert_eq!(UPDATE_STATUS_FORMAT_VERSION, 1); @@ -238,6 +244,7 @@ fn status_schema_is_ts_shaped() { assert!(encoded.get("state").is_some()); } +#[pa_test_scratch::pa_test] #[test] fn roster_binary_and_heartbeat_wire_names() { let binary: UpdateRosterBinary = serde_json::from_value(serde_json::json!({ -- knotmirror 0.0.1 From 92b74aa5a01de8902ae7b4add22b0e0a6df01ff3 Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Sat, 21 Nov 2026 12:09:37 +0000 Subject: [PATCH 4/9] test(timing): instrument pa-core unit tests --- crates/pa-core/src/auth/manager/tests.rs | 19 +++++++++ crates/pa-core/src/auth/prime_inference.rs | 7 ++++ .../pa-core/src/auth/prime_inference_login.rs | 7 ++++ crates/pa-core/src/auth/provider_oauth.rs | 7 ++++ crates/pa-core/src/auth/refresh_policy.rs | 1 + .../pa-core/src/auth/resolve_config_value.rs | 2 + crates/pa-core/src/auth/storage.rs | 10 +++++ crates/pa-core/src/auth/types.rs | 1 + crates/pa-core/src/cron/mod.rs | 6 +++ crates/pa-core/src/cron/scheduler.rs | 10 +++++ crates/pa-core/src/cron/store/heartbeat.rs | 2 + crates/pa-core/src/cron/store/jobs.rs | 6 +++ .../pa-core/src/cron/store/rlm_heartbeat.rs | 1 + .../src/cron/store/session_artifacts.rs | 1 + crates/pa-core/src/cron/store/state.rs | 2 + .../pa-core/src/export_html/ansi_to_html.rs | 7 ++++ crates/pa-core/src/export_html/mod.rs | 5 +++ crates/pa-core/src/export_html/theme.rs | 8 ++++ crates/pa-core/src/export_html/tool_render.rs | 4 ++ crates/pa-core/src/goals.rs | 8 ++++ .../pa-core/src/kernel/bootstrap/dir_lock.rs | 7 ++++ .../pa-core/src/kernel/bootstrap/disk_memo.rs | 5 +++ crates/pa-core/src/kernel/bootstrap/mod.rs | 2 + .../src/kernel/bootstrap/runtime_code.rs | 5 +++ .../src/kernel/bootstrap/venv/layout/tests.rs | 1 + .../kernel/bootstrap/venv/recovery/tests.rs | 13 +++++++ .../kernel/bootstrap/venv/runtime_source.rs | 4 ++ .../src/kernel/bootstrap/venv/tests.rs | 21 ++++++++++ .../src/kernel/bootstrap/venv/version.rs | 3 ++ crates/pa-core/src/kernel/cancellation.rs | 2 + crates/pa-core/src/kernel/live_kernels.rs | 2 + crates/pa-core/src/kernel/manager/events.rs | 4 ++ .../src/kernel/manager/host_requests.rs | 4 ++ crates/pa-core/src/kernel/manager/mod.rs | 2 + crates/pa-core/src/kernel/manager/requests.rs | 5 +++ crates/pa-core/src/kernel/manager/startup.rs | 4 ++ crates/pa-core/src/kernel/orphan_journal.rs | 3 ++ crates/pa-core/src/kernel/protocol.rs | 14 +++++++ crates/pa-core/src/kernel/provisioner.rs | 21 ++++++++++ crates/pa-core/src/kernel/rlm_runtime.rs | 5 +++ crates/pa-core/src/kernel/state_snapshot.rs | 1 + crates/pa-core/src/mcp/login.rs | 11 ++++++ crates/pa-core/src/mcp/mod.rs | 8 ++++ crates/pa-core/src/mcp/oauth.rs | 19 +++++++++ .../pa-core/src/mcp/oauth/lifecycle_tests.rs | 5 +++ crates/pa-core/src/mcp/oauth_callback.rs | 19 +++++++++ crates/pa-core/src/mcp/oauth_discovery.rs | 8 ++++ crates/pa-core/src/mcp/oauth_http.rs | 1 + crates/pa-core/src/models/allowlist.rs | 3 ++ crates/pa-core/src/models/custom.rs | 10 +++++ .../pa-core/src/models/image_model_routing.rs | 8 ++++ .../pa-core/src/models/ollama_cloud_config.rs | 8 ++++ crates/pa-core/src/models/prime_inference.rs | 3 ++ .../models/registry/catalog_refresh_tests.rs | 15 +++++++ .../models/registry/provider_facts_tests.rs | 4 ++ crates/pa-core/src/models/registry/tests.rs | 14 +++++++ crates/pa-core/src/models/resolver.rs | 14 +++++++ crates/pa-core/src/models/session_restore.rs | 2 + crates/pa-core/src/packages/manager.rs | 7 ++++ crates/pa-core/src/packages/npm.rs | 4 ++ crates/pa-core/src/packages/process.rs | 2 + crates/pa-core/src/packages/resolve/tests.rs | 39 +++++++++++++++++++ .../pa-core/src/packages/resource_config.rs | 7 ++++ crates/pa-core/src/packages/source.rs | 13 +++++++ crates/pa-core/src/packages/tests.rs | 7 ++++ crates/pa-core/src/platform/browser.rs | 2 + crates/pa-core/src/platform/lock_dir.rs | 8 ++++ crates/pa-core/src/platform/perms.rs | 1 + crates/pa-core/src/platform/process.rs | 3 ++ crates/pa-core/src/platform/rename.rs | 10 +++++ crates/pa-core/src/platform/shell.rs | 5 +++ crates/pa-core/src/plugins/manifest/tests.rs | 11 ++++++ crates/pa-core/src/plugins/tests.rs | 20 ++++++++++ crates/pa-core/src/prompts/model_prompts.rs | 10 +++++ crates/pa-core/src/prompts/system_prompt.rs | 5 +++ crates/pa-core/src/resources/mod.rs | 5 +++ crates/pa-core/src/session/artifacts.rs | 4 ++ crates/pa-core/src/session/discovery.rs | 7 ++++ crates/pa-core/src/session/history.rs | 35 +++++++++++++++++ .../src/session/manager/persist_tests.rs | 2 + crates/pa-core/src/session/manager/tests.rs | 26 +++++++++++++ crates/pa-core/src/session/manager_ext.rs | 3 ++ crates/pa-core/src/session/mod.rs | 3 ++ crates/pa-core/src/session/read.rs | 1 + crates/pa-core/src/session/storage.rs | 3 ++ crates/pa-core/src/session/tree.rs | 1 + crates/pa-core/src/session/window_tests.rs | 32 +++++++++++++++ .../session_engine/agent_messaging/tests.rs | 10 +++++ .../src/session_engine/auto_retry/tests.rs | 17 ++++++++ .../src/session_engine/auxiliary_model.rs | 9 +++++ .../session_engine/branch_summarization.rs | 9 +++++ .../compact_session/tests/auxiliary_model.rs | 2 + .../compact_session/tests/cut_math.rs | 4 ++ .../tests/execute_compaction.rs | 6 +++ .../tests/prepare_compaction.rs | 5 +++ .../tests/second_compaction.rs | 3 ++ .../compact_session/tests/skip_guards.rs | 4 ++ .../compact_session/tests/split_turn.rs | 5 +++ .../pa-core/src/session_engine/compaction.rs | 16 ++++++++ .../src/session_engine/compaction_exec.rs | 10 +++++ .../compaction_outcome_tests.rs | 4 ++ .../compaction_threshold_tests.rs | 5 +++ .../compaction_unblocked_tests.rs | 5 +++ .../src/session_engine/compaction_utils.rs | 9 +++++ .../src/session_engine/context_strategy.rs | 6 +++ .../context_strategy/defaults_tests.rs | 5 +++ .../session_engine/context_strategy/input.rs | 5 +++ .../context_strategy/startup.rs | 2 + .../context_strategy/startup_tests.rs | 17 ++++++++ .../session_engine/context_strategy/tests.rs | 33 ++++++++++++++++ .../engine/append_system_tests.rs | 7 ++++ .../src/session_engine/engine/tests.rs | 8 ++++ .../src/session_engine/goal_driver/tests.rs | 31 +++++++++++++++ crates/pa-core/src/session_engine/headless.rs | 5 +++ .../src/session_engine/history_host.rs | 13 +++++++ .../src/session_engine/host_requests.rs | 2 + .../session_engine/inference_capabilities.rs | 11 ++++++ .../session_engine/inference_router/tests.rs | 10 +++++ .../src/session_engine/ipython_state.rs | 6 +++ crates/pa-core/src/session_engine/messages.rs | 8 ++++ .../src/session_engine/ollama_cloud.rs | 6 +++ .../session_engine/optchat/engine_tests.rs | 12 ++++++ .../session_engine/optchat/service_tests.rs | 4 ++ .../src/session_engine/optchat/tests.rs | 9 +++++ .../src/session_engine/plugin_context.rs | 2 + .../src/session_engine/plugin_stages_tests.rs | 7 ++++ crates/pa-core/src/session_engine/plugins.rs | 8 ++++ .../src/session_engine/plugins/tests.rs | 7 ++++ .../src/session_engine/provider_adapter.rs | 8 ++++ .../src/session_engine/provider_failover.rs | 9 +++++ .../src/session_engine/provider_park.rs | 11 ++++++ .../src/session_engine/provider_retry.rs | 17 ++++++++ .../request_timing/payload/tests.rs | 12 ++++++ .../session_engine/request_timing/tests.rs | 14 +++++++ crates/pa-core/src/session_engine/rlm_host.rs | 9 +++++ .../pa-core/src/session_engine/rlm_notices.rs | 4 ++ .../pa-core/src/session_engine/rlm_usage.rs | 7 ++++ crates/pa-core/src/session_engine/runtime.rs | 4 ++ .../src/session_engine/runtime_wiring.rs | 2 + .../session_engine/semantic_edges/ledger.rs | 1 + .../session_engine/semantic_edges/tests.rs | 6 +++ .../src/session_engine/session_commands.rs | 5 +++ .../src/session_engine/session_events.rs | 2 + .../src/session_engine/side_question.rs | 9 +++++ .../skills_unavailable_notice.rs | 1 + .../src/session_engine/slash_commands.rs | 1 + .../src/session_engine/slash_session_tests.rs | 1 + .../session_engine/state_restore_notice.rs | 3 ++ crates/pa-core/src/session_engine/tests.rs | 16 ++++++++ .../pa-core/src/session_engine/tool_bridge.rs | 3 ++ .../tool_bridge/error_status_tests.rs | 2 + .../src/session_engine/turn_activity.rs | 3 ++ .../src/session_engine/turn_boundary/tests.rs | 9 +++++ crates/pa-core/src/session_log/crc.rs | 1 + crates/pa-core/src/session_log/follower.rs | 2 + crates/pa-core/src/session_log/line.rs | 7 ++++ crates/pa-core/src/session_log/tests.rs | 36 +++++++++++++++++ crates/pa-core/src/settings/load.rs | 6 +++ crates/pa-core/src/settings/manager.rs | 11 ++++++ crates/pa-core/src/settings/merge.rs | 6 +++ .../pa-core/src/settings/persistence_tests.rs | 15 +++++++ crates/pa-core/src/settings/storage.rs | 9 +++++ crates/pa-core/src/skills/frontmatter.rs | 6 +++ crates/pa-core/src/skills/loader.rs | 3 ++ crates/pa-core/src/skills/mod.rs | 8 ++++ crates/pa-core/src/skills/prompt_templates.rs | 5 +++ crates/pa-core/src/slash_command_args.rs | 1 + .../pa-core/src/tools/file_mutation_queue.rs | 3 ++ crates/pa-core/src/tools/golden_replay.rs | 6 +++ crates/pa-core/src/tools/ipython.rs | 1 + crates/pa-core/src/tools/path_utils.rs | 6 +++ crates/pa-core/src/tools/render_utils.rs | 1 + crates/pa-core/src/tools/shell_utils.rs | 3 ++ crates/pa-core/src/tools/truncate.rs | 5 +++ crates/pa-core/src/update/download.rs | 8 ++++ crates/pa-core/src/update/homebrew.rs | 3 ++ crates/pa-core/src/update/install.rs | 7 ++++ crates/pa-core/src/update/installer.rs | 14 +++++++ crates/pa-core/src/update/managed.rs | 1 + crates/pa-core/src/update/release.rs | 6 +++ crates/pa-core/src/update/version.rs | 5 +++ 181 files changed, 1361 insertions(+) diff --git a/crates/pa-core/src/auth/manager/tests.rs b/crates/pa-core/src/auth/manager/tests.rs index f2bd3691f..4d2efa237 100644 --- a/crates/pa-core/src/auth/manager/tests.rs +++ b/crates/pa-core/src/auth/manager/tests.rs @@ -41,6 +41,7 @@ fn storage_with_env(data: &serde_json::Value, env: ScriptedEnv) -> AuthStorage { AuthStorage::in_memory_with_env(&data, Arc::new(NoOAuth), Arc::new(env)) } +#[pa_test_scratch::pa_test] #[test] fn local_status_does_not_resolve_deferred_credentials() { struct ForbiddenOAuth; @@ -112,6 +113,7 @@ fn local_status_does_not_resolve_deferred_credentials() { ); } +#[pa_test_scratch::pa_test] #[test] fn local_api_key_preserves_precedence_and_stale_sources() { let mut auth = storage_with_env( @@ -156,6 +158,7 @@ fn local_api_key_preserves_precedence_and_stale_sources() { ); } +#[pa_test_scratch::pa_test] #[test] fn local_api_key_never_executes_commands_oauth_or_fallback() { struct ForbiddenOAuth; @@ -205,6 +208,7 @@ fn local_api_key_never_executes_commands_oauth_or_fallback() { assert_eq!(auth.get_api_key_local("openai-codex"), None); } +#[pa_test_scratch::pa_test] #[test] fn local_codex_key_respects_existing_stale_source_tokens() { let oauth = Arc::new(CountingOAuth { @@ -224,6 +228,7 @@ fn local_codex_key_respects_existing_stale_source_tokens() { assert_eq!(auth.get_api_key_local("openai-codex"), None); } +#[pa_test_scratch::pa_test] #[test] fn runtime_override_wins() { // Non-prime provider: runtime beats stored; stored outranks env, @@ -241,6 +246,7 @@ fn runtime_override_wins() { assert_eq!(auth.get_api_key("anthropic").as_deref(), Some("stored-key")); } +#[pa_test_scratch::pa_test] #[test] fn stale_marking_skips_source_and_clears() { let mut auth = storage_with(&serde_json::json!({ @@ -257,6 +263,7 @@ fn stale_marking_skips_source_and_clears() { ); } +#[pa_test_scratch::pa_test] #[test] fn candidate_memos_supersede_exactly_when_material_changes() { // The memo is keyed by the hashed material: a changed env value re-resolves to @@ -312,6 +319,7 @@ fn candidate_memos_supersede_exactly_when_material_changes() { ); } +#[pa_test_scratch::pa_test] #[test] fn set_and_remove_credentials() { let mut auth = storage_with(&serde_json::json!({})); @@ -339,6 +347,7 @@ fn set_and_remove_credentials() { assert_eq!(auth.get_api_key("anthropic"), None); } +#[pa_test_scratch::pa_test] #[test] fn command_keys_resolve() { let mut auth = storage_with(&serde_json::json!({ @@ -347,6 +356,7 @@ fn command_keys_resolve() { assert_eq!(auth.get_api_key("anthropic").as_deref(), Some("cmd-key")); } +#[pa_test_scratch::pa_test] #[test] fn env_key_priority_for_prime_inference() { let mut auth = storage_with_env( @@ -364,6 +374,7 @@ fn env_key_priority_for_prime_inference() { ); } +#[pa_test_scratch::pa_test] #[test] fn fallback_resolver_last_resort() { let mut auth = storage_with(&serde_json::json!({})); @@ -373,6 +384,7 @@ fn fallback_resolver_last_resort() { assert_eq!(auth.get_api_key("custom").as_deref(), Some("fb-key")); } +#[pa_test_scratch::pa_test] #[test] fn provider_headers_team_selection() { let auth = storage_with(&serde_json::json!({ @@ -469,6 +481,7 @@ fn team(id: &str, name: &str) -> PrimeTeamCredential { } } +#[pa_test_scratch::pa_test] #[test] fn prime_inference_key_writes_follow_the_ts_assignment_rules() { let mut auth = storage_with(&serde_json::json!({})); @@ -526,6 +539,7 @@ fn prime_inference_key_writes_follow_the_ts_assignment_rules() { assert_eq!(credential.get("primeTeam"), Some(&serde_json::Value::Null)); } +#[pa_test_scratch::pa_test] #[test] fn prime_inference_team_selection_rebinds_only_the_stored_key() { let mut auth = storage_with(&serde_json::json!({})); @@ -581,6 +595,7 @@ impl AuthStorageBackend for WriteFailingBackend { } } +#[pa_test_scratch::pa_test] #[test] fn a_failed_prime_inference_key_write_keeps_the_stale_marking() { // TS: `setPrimeInferenceApiKey` throws before `clearStaleAuthSource`, @@ -607,6 +622,7 @@ fn a_failed_prime_inference_key_write_keeps_the_stale_marking() { assert_eq!(auth.get_api_key(PRIME_INFERENCE_PROVIDER_ID), None); } +#[pa_test_scratch::pa_test] #[test] fn prime_inference_team_selection_reads_follow_the_ts_tri_state() { let auth = storage_with(&serde_json::json!({})); @@ -766,6 +782,7 @@ fn storage_over_backend_with( ) } +#[pa_test_scratch::pa_test] #[test] fn an_unexpired_oauth_credential_serves_without_a_fetch() { let oauth = Arc::new(CountingOAuth { @@ -785,6 +802,7 @@ fn an_unexpired_oauth_credential_serves_without_a_fetch() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_token_fetch_holds_the_document_lock_through_commit() { struct HeldOAuth { @@ -868,6 +886,7 @@ fn the_token_fetch_holds_the_document_lock_through_commit() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_second_refresh_joins_the_first_flight_instead_of_fetching_again() { // Two resolutions race: the document lock serializes them, and the diff --git a/crates/pa-core/src/auth/prime_inference.rs b/crates/pa-core/src/auth/prime_inference.rs index 6d9a86a39..0524f2f25 100644 --- a/crates/pa-core/src/auth/prime_inference.rs +++ b/crates/pa-core/src/auth/prime_inference.rs @@ -501,6 +501,7 @@ mod tests { )) } + #[pa_test_scratch::pa_test] #[test] fn the_config_resolution_matches_ts_normalization() { assert_eq!( @@ -527,6 +528,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_access_check_sends_the_ts_request_and_reads_the_scope() { let http = scripted(vec![( "https://api.example/api/v1/user/whoami", @@ -544,6 +546,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_access_check_reports_each_denial_with_the_ts_message() { let http = scripted(vec![( "https://api.example/api/v1/user/whoami", @@ -595,6 +598,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_team_list_paginates_the_ts_way() { let page = (0..100) .map(|index| { @@ -635,6 +639,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_team_list_errors_with_the_ts_messages() { let http = scripted(vec![( "https://api.example/api/v1/user/teams?offset=0&limit=100", @@ -659,6 +664,7 @@ mod tests { /// The production transport's wire shape: the request head the real /// client sends. #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_reqwest_transport_sends_the_ts_request() { let listener = TcpListener::bind("127.0.0.1:0").await.expect("bind"); let port = listener.local_addr().unwrap().port(); @@ -706,6 +712,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn the_prime_cli_config_reuse_only_accepts_production() { let dir = tempfile::tempdir().expect("temp dir"); diff --git a/crates/pa-core/src/auth/prime_inference_login.rs b/crates/pa-core/src/auth/prime_inference_login.rs index 70bb5c0cc..2e4357605 100644 --- a/crates/pa-core/src/auth/prime_inference_login.rs +++ b/crates/pa-core/src/auth/prime_inference_login.rs @@ -478,6 +478,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_prime_cli_candidate_short_circuits_with_its_team() { let dir = tempfile::tempdir().expect("temp dir"); let config_path = dir.path().join("config.json"); @@ -527,6 +528,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_prime_cli_candidate_without_a_team_is_the_personal_account() { let dir = tempfile::tempdir().expect("temp dir"); let config_path = dir.path().join("config.json"); @@ -548,6 +550,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_denied_cli_key_runs_the_browser_challenge() { let dir = tempfile::tempdir().expect("temp dir"); let config_path = dir.path().join("config.json"); @@ -613,6 +616,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_browser_challenge_url_carries_only_the_code() { let http = ScriptedHttp::new(vec![whoami_ok(true)]); let progress = Mutex::new(Vec::::new()); @@ -649,6 +653,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_non_production_config_never_reads_the_prime_cli() { let dir = tempfile::tempdir().expect("temp dir"); // The cli config carries a working key, but the base URL is @@ -691,6 +696,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_browser_key_without_inference_access_reports_the_ts_error() { let http = ScriptedHttp::new(vec![whoami_ok(false)]); let callbacks = PrimeInferenceLoginCallbacks { @@ -714,6 +720,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_expired_challenge_reports_the_ts_error() { // The dynamic generate stays off so the queue owns every answer. let http = ScriptedHttp::without_dynamic(vec![ diff --git a/crates/pa-core/src/auth/provider_oauth.rs b/crates/pa-core/src/auth/provider_oauth.rs index 2efa1604f..7bb1ad8bb 100644 --- a/crates/pa-core/src/auth/provider_oauth.rs +++ b/crates/pa-core/src/auth/provider_oauth.rs @@ -381,6 +381,7 @@ mod tests { crate::auth::AuthStorage::in_memory_without_env(&data, integrations()) } + #[pa_test_scratch::pa_test] #[test] fn an_expired_codex_credential_refreshes_and_resolves() { let mut auth = @@ -406,6 +407,7 @@ mod tests { assert_eq!(account_id.as_deref(), Some("acct-2")); } + #[pa_test_scratch::pa_test] #[test] fn an_expired_anthropic_credential_refreshes_and_resolves() { let mut auth = storage_with_credential( @@ -427,6 +429,7 @@ mod tests { assert!(expires > 1, "the fresh expiry landed"); } + #[pa_test_scratch::pa_test] #[test] fn an_expired_copilot_credential_refreshes_through_the_enterprise_domain() { let mut auth = storage_with_credential( @@ -457,6 +460,7 @@ mod tests { assert!(expires > 1, "the fresh expiry landed"); } + #[pa_test_scratch::pa_test] #[test] fn an_expired_xai_credential_refreshes_and_resolves() { let mut auth = @@ -476,6 +480,7 @@ mod tests { assert!(expires > 1, "the fresh expiry landed"); } + #[pa_test_scratch::pa_test] #[test] fn a_failed_refresh_keeps_the_stored_credential() { // Nothing scripted: the refresh fails, the stored credential stays. @@ -499,6 +504,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn non_subscription_providers_do_not_refresh() { let mut auth = storage_with_credential("other-oauth", &expired_credential("other-oauth")); @@ -506,6 +512,7 @@ mod tests { assert!(auth.get_all().credential("other-oauth").is_some()); } + #[pa_test_scratch::pa_test] #[test] fn an_unexpired_credential_serves_without_a_refresh() { let unexpired = AuthCredential::Oauth { diff --git a/crates/pa-core/src/auth/refresh_policy.rs b/crates/pa-core/src/auth/refresh_policy.rs index 1851c03bc..7bbddc320 100644 --- a/crates/pa-core/src/auth/refresh_policy.rs +++ b/crates/pa-core/src/auth/refresh_policy.rs @@ -23,6 +23,7 @@ pub(super) fn disabled() -> bool { mod tests { use super::is_disabled; + #[pa_test_scratch::pa_test] #[test] fn explicit_truthy_values_disable_refresh_only() { for (value, expected) in [ diff --git a/crates/pa-core/src/auth/resolve_config_value.rs b/crates/pa-core/src/auth/resolve_config_value.rs index 10e932354..a65c4bc33 100644 --- a/crates/pa-core/src/auth/resolve_config_value.rs +++ b/crates/pa-core/src/auth/resolve_config_value.rs @@ -116,12 +116,14 @@ fn hidden_spawn(_command: &str) -> Result> { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn env_or_literal_semantics() { let key = "PA_TEST_DEFINITELY_UNSET_VAR"; assert_eq!(resolve_env_or_literal(key), Some(key.to_string())); } + #[pa_test_scratch::pa_test] #[test] fn command_resolution_and_cache() { let value = resolve_config_value("!echo resolved-value"); diff --git a/crates/pa-core/src/auth/storage.rs b/crates/pa-core/src/auth/storage.rs index 06717e637..c98a4327f 100644 --- a/crates/pa-core/src/auth/storage.rs +++ b/crates/pa-core/src/auth/storage.rs @@ -292,6 +292,7 @@ mod tests { use super::*; #[cfg(not(unix))] + #[pa_test_scratch::pa_test] #[test] fn ordinary_file_auth_survives_unsupported_rotating_refresh() { let dir = tempfile::tempdir().unwrap(); @@ -313,6 +314,7 @@ mod tests { assert_eq!(backend.read().unwrap().as_deref(), Some("{}")); } + #[pa_test_scratch::pa_test] #[test] fn file_backend_round_trip_and_modes() { let dir = tempfile::tempdir().unwrap(); @@ -338,6 +340,7 @@ mod tests { /// The auth save goes through the real `with_lock` writer and takes exactly one fsync branch /// landing the exact document bytes. + #[pa_test_scratch::pa_test] #[test] fn auth_write_takes_exactly_one_fsync() { let dir = tempfile::tempdir().unwrap(); @@ -358,6 +361,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn parse_rejects_non_object() { assert!(parse_storage_data(Some("[1,2]")).is_err()); @@ -367,6 +371,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn read_creates_the_document_like_with_lock() { let dir = tempfile::tempdir().unwrap(); @@ -375,6 +380,7 @@ mod tests { assert!(dir.path().join("auth.json").is_file()); } + #[pa_test_scratch::pa_test] #[test] fn read_hits_do_not_run_the_lock_protocol() { let dir = tempfile::tempdir().unwrap(); @@ -391,6 +397,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn read_sees_external_atomic_writes() { let dir = tempfile::tempdir().unwrap(); @@ -407,6 +414,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn read_sees_external_in_place_writes() { let dir = tempfile::tempdir().unwrap(); @@ -421,6 +429,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn read_hits_serve_the_validated_copy_under_a_foreign_holder() { let dir = tempfile::tempdir().unwrap(); @@ -434,6 +443,7 @@ mod tests { fs::remove_dir(crate::platform::lock_dir::LockDir::path_for(&path)).unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn read_sees_this_process_with_lock_writes() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/auth/types.rs b/crates/pa-core/src/auth/types.rs index f8af852d2..a33debd6b 100644 --- a/crates/pa-core/src/auth/types.rs +++ b/crates/pa-core/src/auth/types.rs @@ -237,6 +237,7 @@ pub struct AuthSourceToken { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn credential_wire_shapes() { let api_key: AuthCredential = diff --git a/crates/pa-core/src/cron/mod.rs b/crates/pa-core/src/cron/mod.rs index 6a51e157a..b83a8db18 100644 --- a/crates/pa-core/src/cron/mod.rs +++ b/crates/pa-core/src/cron/mod.rs @@ -875,6 +875,7 @@ mod tests { const BASE: u64 = 1_700_000_000_000; // 2023-11-14T22:13:20Z + #[pa_test_scratch::pa_test] #[test] fn parse_one_shot_and_interval_schedules() { let (schedule, next) = parse_agent_cron_schedule("in 10m", BASE).unwrap(); @@ -899,6 +900,7 @@ mod tests { assert_eq!(schedule.expression, "in 10m"); } + #[pa_test_scratch::pa_test] #[test] fn cron_expressions_evaluate() { // @hourly fires at the next whole hour. @@ -922,6 +924,7 @@ mod tests { assert!(parse_agent_cron_schedule("a * * * *", BASE).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn next_run_rollover() { let (_, next) = parse_agent_cron_schedule("@daily", BASE).unwrap(); @@ -951,6 +954,7 @@ mod tests { assert_eq!(next_run_at_for_schedule(&once, BASE).unwrap(), None); } + #[pa_test_scratch::pa_test] #[test] fn heartbeat_command_parsing() { use ParsedHeartbeatCommand::*; @@ -1034,6 +1038,7 @@ mod tests { assert!(parse_heartbeat_command("/heartbeat --every 10m").is_err()); } + #[pa_test_scratch::pa_test] #[test] fn heartbeat_deferral_rules() { let job = |source: &str, mode: Option| AgentCronJob { @@ -1101,6 +1106,7 @@ mod tests { )); } + #[pa_test_scratch::pa_test] #[test] fn due_jobs_and_formatting() { let mut job = AgentCronJob { diff --git a/crates/pa-core/src/cron/scheduler.rs b/crates/pa-core/src/cron/scheduler.rs index acd6cb7a5..6a6688f13 100644 --- a/crates/pa-core/src/cron/scheduler.rs +++ b/crates/pa-core/src/cron/scheduler.rs @@ -372,6 +372,7 @@ mod tests { /// Dogfood P0 regression: a heartbeat created after the bind-time arm /// never fires unless the mutation's wake re-arms. #[tokio::test] + #[pa_test_scratch::pa_test] async fn wake_rearms_a_timer_for_a_job_created_after_start() { let dir = tempfile::TempDir::new().unwrap(); let store = Arc::new(AgentCronJobStore::new(dir.path().join("jobs.json"))); @@ -403,6 +404,7 @@ mod tests { /// The frozen-heartbeat incident: a panicking dispatch must not wedge /// the run-pass flag at `true` (later passes silently no-op forever). #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_panicking_dispatch_does_not_wedge_the_run_pass() { struct PanickingHooks { runs: Arc, @@ -472,6 +474,7 @@ mod tests { /// The live incident: a wake landing while a fire pass is in-flight must /// not strand the claimed dispatch. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_mutation_wake_during_an_in_flight_pass_does_not_wedge_the_flag() { struct BlockingHooks { runs: Arc, @@ -532,6 +535,7 @@ mod tests { /// The store emptying mid-life must leave a parked timer a later /// wake re-arms (the mid-life death behind a re-adopted worker). #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_timer_parks_on_an_empty_store_and_re_arms_on_wake() { let dir = tempfile::TempDir::new().unwrap(); let store = Arc::new(AgentCronJobStore::new(dir.path().join("jobs.json"))); @@ -570,6 +574,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn claims_and_runs_due_jobs() { let dir = tempfile::TempDir::new().unwrap(); let store = Arc::new(AgentCronJobStore::new(dir.path().join("jobs.json"))); @@ -595,6 +600,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn skip_outcomes_are_recorded() { let dir = tempfile::TempDir::new().unwrap(); let store = Arc::new(AgentCronJobStore::new(dir.path().join("jobs.json"))); @@ -618,6 +624,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn lane_serializes_same_session_dispatches() { let dir = tempfile::TempDir::new().unwrap(); let store = Arc::new(AgentCronJobStore::new(dir.path().join("jobs.json"))); @@ -638,6 +645,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn schedule_kind_from_create_is_interval() { let dir = tempfile::TempDir::new().unwrap(); let store = AgentCronJobStore::new(dir.path().join("jobs.json")); @@ -646,6 +654,7 @@ mod tests { assert_eq!(job.schedule.kind, ScheduleKind::Interval); } + #[pa_test_scratch::pa_test] #[test] fn failure_backoff_doubles_then_caps() { assert_eq!(failure_backoff_ms(1), 120_000); @@ -659,6 +668,7 @@ mod tests { /// Dogfood incident: a dead route re-fired an every-2m heartbeat /// ~120 times. #[tokio::test] + #[pa_test_scratch::pa_test] async fn consecutive_failures_back_off_the_next_run() { let dir = tempfile::TempDir::new().unwrap(); let store = Arc::new(AgentCronJobStore::new(dir.path().join("jobs.json"))); diff --git a/crates/pa-core/src/cron/store/heartbeat.rs b/crates/pa-core/src/cron/store/heartbeat.rs index 7c962cb2f..83d16c31e 100644 --- a/crates/pa-core/src/cron/store/heartbeat.rs +++ b/crates/pa-core/src/cron/store/heartbeat.rs @@ -294,6 +294,7 @@ mod tests { use super::*; use crate::cron::store::input; + #[pa_test_scratch::pa_test] #[test] fn pause_does_not_ack_when_state_lock_is_held() { let dir = tempfile::tempdir().unwrap(); @@ -313,6 +314,7 @@ mod tests { assert_eq!(store.get_heartbeat("live-1"), Some(heartbeat)); } + #[pa_test_scratch::pa_test] #[test] fn heartbeat_lifecycle() { let dir = tempfile::TempDir::new().unwrap(); diff --git a/crates/pa-core/src/cron/store/jobs.rs b/crates/pa-core/src/cron/store/jobs.rs index 829d04a78..1439a8368 100644 --- a/crates/pa-core/src/cron/store/jobs.rs +++ b/crates/pa-core/src/cron/store/jobs.rs @@ -461,6 +461,7 @@ mod tests { use super::*; use crate::cron::store::input; + #[pa_test_scratch::pa_test] #[test] fn create_list_and_cancel() { let dir = tempfile::TempDir::new().unwrap(); @@ -481,6 +482,7 @@ mod tests { assert!(store.create(&input(" ", "every 10m", now)).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn cancel_does_not_ack_when_state_lock_is_held() { let dir = tempfile::tempdir().unwrap(); @@ -498,6 +500,7 @@ mod tests { assert_eq!(store.list(), vec![job]); } + #[pa_test_scratch::pa_test] #[test] fn claim_dispatch_and_result_recording() { let dir = tempfile::TempDir::new().unwrap(); @@ -538,6 +541,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn run_and_skip_results_roll_schedules() { let dir = tempfile::TempDir::new().unwrap(); @@ -577,6 +581,7 @@ mod tests { assert!(store.list().iter().any(|job| job.last_skipped_at.is_some())); } + #[pa_test_scratch::pa_test] #[test] fn claim_due_skips_while_the_state_lock_is_held() { let dir = tempfile::tempdir().unwrap(); @@ -599,6 +604,7 @@ mod tests { assert_eq!(dispatches[0].job.id, job.id); } + #[pa_test_scratch::pa_test] #[test] fn defer_next_run_pushes_only_later() { let dir = tempfile::TempDir::new().unwrap(); diff --git a/crates/pa-core/src/cron/store/rlm_heartbeat.rs b/crates/pa-core/src/cron/store/rlm_heartbeat.rs index 912475f12..ec5d57e65 100644 --- a/crates/pa-core/src/cron/store/rlm_heartbeat.rs +++ b/crates/pa-core/src/cron/store/rlm_heartbeat.rs @@ -258,6 +258,7 @@ mod tests { use super::*; use crate::cron::store::input; + #[pa_test_scratch::pa_test] #[test] fn rlm_heartbeat_management() { let dir = tempfile::TempDir::new().unwrap(); diff --git a/crates/pa-core/src/cron/store/session_artifacts.rs b/crates/pa-core/src/cron/store/session_artifacts.rs index 8ce5e1273..d64ed1d07 100644 --- a/crates/pa-core/src/cron/store/session_artifacts.rs +++ b/crates/pa-core/src/cron/store/session_artifacts.rs @@ -170,6 +170,7 @@ mod tests { use super::*; use crate::cron::store::{input, CancelJobsFilter, SessionBinding}; + #[pa_test_scratch::pa_test] #[test] fn session_artifact_partitioning() { let dir = tempfile::TempDir::new().unwrap(); diff --git a/crates/pa-core/src/cron/store/state.rs b/crates/pa-core/src/cron/store/state.rs index 30e85e71b..a5dd17bf2 100644 --- a/crates/pa-core/src/cron/store/state.rs +++ b/crates/pa-core/src/cron/store/state.rs @@ -360,6 +360,7 @@ pub(crate) fn write_jobs_state(path: &Path, state: &CronJobsState) -> anyhow::Re mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn jobs_state_write_propagates_physical_failure() { let dir = tempfile::tempdir().unwrap(); @@ -370,6 +371,7 @@ mod tests { /// The cron state write opts in (the TS test pins `{ fsync: true, mode: 0o600 }`) /// `to_string_pretty(state) + "\n"` bytes. + #[pa_test_scratch::pa_test] #[test] fn jobs_state_write_keeps_exactly_one_fsync() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/export_html/ansi_to_html.rs b/crates/pa-core/src/export_html/ansi_to_html.rs index dc1457c79..d34dfda3d 100644 --- a/crates/pa-core/src/export_html/ansi_to_html.rs +++ b/crates/pa-core/src/export_html/ansi_to_html.rs @@ -232,12 +232,14 @@ pub fn ansi_lines_to_html(lines: &[String]) -> String { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn plain_text() { assert_eq!(ansi_to_html("hello"), "hello"); assert_eq!(ansi_to_html("a < b & c"), "a < b & c"); } + #[pa_test_scratch::pa_test] #[test] fn color_spans() { assert_eq!( @@ -250,6 +252,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn text_styles() { assert_eq!( @@ -263,6 +266,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn extended_colors() { assert_eq!( @@ -280,6 +284,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn resets() { assert_eq!( @@ -289,6 +294,7 @@ mod tests { assert_eq!(ansi_to_html("\x1b[mplain"), "plain"); } + #[pa_test_scratch::pa_test] #[test] fn unclosed_span() { assert_eq!( @@ -297,6 +303,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn lines() { let lines = vec!["\x1b[1mx\x1b[0m".to_string(), String::new()]; diff --git a/crates/pa-core/src/export_html/mod.rs b/crates/pa-core/src/export_html/mod.rs index df60a08f5..d6f7aa714 100644 --- a/crates/pa-core/src/export_html/mod.rs +++ b/crates/pa-core/src/export_html/mod.rs @@ -216,6 +216,7 @@ mod tests { /// The embedded base64 session data decodes to the exact /// header/entries/leaf shape. + #[pa_test_scratch::pa_test] #[test] fn export_from_file_shape() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -254,6 +255,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn default_output_name() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -270,6 +272,7 @@ mod tests { } /// A missing input file is the TS error, verbatim. + #[pa_test_scratch::pa_test] #[test] fn missing_input_file() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -283,6 +286,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn tools_section_wire_shape() { use pa_agent::types::{AgentTool, AgentToolResult}; @@ -332,6 +336,7 @@ mod tests { } /// Serializes with the template's wire keys (camelCase). + #[pa_test_scratch::pa_test] #[test] fn export_data_wire_keys() { let data = SessionExportData { diff --git a/crates/pa-core/src/export_html/theme.rs b/crates/pa-core/src/export_html/theme.rs index e36a91d9d..fd752888d 100644 --- a/crates/pa-core/src/export_html/theme.rs +++ b/crates/pa-core/src/export_html/theme.rs @@ -348,6 +348,7 @@ mod tests { use super::*; /// The bundled prime theme resolves like the TS exporter. + #[pa_test_scratch::pa_test] #[test] fn prime_theme_resolves_like_the_ts_exporter() { let theme = resolve_export_theme(Some("prime"), Path::new("/nonexistent-agent-dir")) @@ -359,6 +360,7 @@ mod tests { assert_eq!(theme.info_bg, "#151518"); } + #[pa_test_scratch::pa_test] #[test] fn ansi256_colors() { assert_eq!(ansi256_to_hex(196), "#ff0000"); @@ -374,6 +376,7 @@ mod tests { /// A custom theme under `/themes/.json` loads (variables resolved, the /// `export` override honored); an unknown name errors. + #[pa_test_scratch::pa_test] #[test] fn custom_theme_discovery_and_not_found() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -398,6 +401,7 @@ mod tests { assert_eq!(error.to_string(), "Theme not found: missing"); } + #[pa_test_scratch::pa_test] #[test] fn default_theme_detection() { assert!(!detect_light_terminal_background(Some("15;0"))); @@ -407,6 +411,7 @@ mod tests { assert!(!detect_light_terminal_background(Some("bogus"))); } + #[pa_test_scratch::pa_test] #[test] fn derived_export_colors() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -432,6 +437,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn light_theme_derivation() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -449,12 +455,14 @@ mod tests { assert!(theme.theme_vars.contains("--text: #000000;")); } + #[pa_test_scratch::pa_test] #[test] fn adjust_brightness_clamps() { assert_eq!(adjust_brightness((255, 0, 10), 1.2), "rgb(255, 0, 12)"); assert_eq!(adjust_brightness((10, 10, 10), 0.5), "rgb(5, 5, 5)"); } + #[pa_test_scratch::pa_test] #[test] fn var_reference_errors() { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-core/src/export_html/tool_render.rs b/crates/pa-core/src/export_html/tool_render.rs index 6ee7dc0b8..b373de0d8 100644 --- a/crates/pa-core/src/export_html/tool_render.rs +++ b/crates/pa-core/src/export_html/tool_render.rs @@ -259,6 +259,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn renders_custom_call_and_result() { let entries = vec![ @@ -280,6 +281,7 @@ mod tests { .is_some_and(|html| html.contains("more detail"))); } + #[pa_test_scratch::pa_test] #[test] fn template_tools_and_empty_map_omit_the_section() { let entries = vec![ @@ -297,6 +299,7 @@ mod tests { /// A tool result without a call still renders its sections (the /// entry has no `callHtml`). + #[pa_test_scratch::pa_test] #[test] fn result_without_call() { let entries = vec![tool_result("tc9", "custom_tool")]; @@ -305,6 +308,7 @@ mod tests { assert!(rendered["tc9"]["resultHtmlExpanded"].is_string()); } + #[pa_test_scratch::pa_test] #[test] fn blank_lines_trim() { let lines = vec![ diff --git a/crates/pa-core/src/goals.rs b/crates/pa-core/src/goals.rs index a82838448..c40d67334 100644 --- a/crates/pa-core/src/goals.rs +++ b/crates/pa-core/src/goals.rs @@ -447,6 +447,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn normalize_derives_active_from_status() { let mut goal = active_goal(); @@ -457,6 +458,7 @@ mod tests { assert_eq!(normalized.status, GoalStatus::Paused); } + #[pa_test_scratch::pa_test] #[test] fn objective_and_budget_validation() { assert_eq!(validate_goal_objective(" padded ").unwrap(), "padded"); @@ -471,6 +473,7 @@ mod tests { assert!(validate_goal_budget(Some(0)).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn usage_delta_clamps_negatives() { assert_eq!(goal_token_delta_for_usage(10, 20), 30); @@ -478,6 +481,7 @@ mod tests { assert_eq!(goal_token_delta_for_usage(-5, -20), 0); } + #[pa_test_scratch::pa_test] #[test] fn persisted_state_guard() { let goal = active_goal(); @@ -493,6 +497,7 @@ mod tests { }))); } + #[pa_test_scratch::pa_test] #[test] fn host_response_shapes() { let goal = active_goal(); @@ -515,6 +520,7 @@ mod tests { assert_eq!(empty.remaining_tokens, None); } + #[pa_test_scratch::pa_test] #[test] fn goal_context_messages_match_prompts() { let goal = active_goal(); @@ -562,6 +568,7 @@ mod tests { assert!(create_goal_context_message(&bare, GoalContextKind::Continuation, &[]).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn usage_formatting() { let goal = active_goal(); @@ -641,6 +648,7 @@ mod tests { /// The restore-resurrection scan: the newest active goal row with a /// terminal failure settled after it. + #[pa_test_scratch::pa_test] #[test] fn stale_active_goal_failure_scan() { let active = goal_state_entry(&active_goal()); diff --git a/crates/pa-core/src/kernel/bootstrap/dir_lock.rs b/crates/pa-core/src/kernel/bootstrap/dir_lock.rs index 919c8637a..b108ab468 100644 --- a/crates/pa-core/src/kernel/bootstrap/dir_lock.rs +++ b/crates/pa-core/src/kernel/bootstrap/dir_lock.rs @@ -92,6 +92,7 @@ mod tests { #[cfg(unix)] #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn reaped_parent_pid_times_out_without_reclaiming_the_lock() { use std::os::unix::fs::MetadataExt; @@ -136,6 +137,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn old_unknown_owner_files_time_out_without_mutating_the_lock() { for owner in [ b"".as_slice(), @@ -173,6 +175,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn old_legacy_directory_without_pid_times_out_without_moving_the_lock() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel-venv"); @@ -197,6 +200,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn live_pid_file_has_a_bounded_wait_without_removing_the_owner() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel-venv"); @@ -221,6 +225,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn legacy_directory_has_a_bounded_wait_without_removing_the_owner() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel-venv"); @@ -240,6 +245,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn an_owner_releasing_before_the_deadline_allows_acquisition() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel-venv"); @@ -258,6 +264,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn cancelling_a_waiter_preserves_the_owner_and_cleans_candidates() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel-venv"); diff --git a/crates/pa-core/src/kernel/bootstrap/disk_memo.rs b/crates/pa-core/src/kernel/bootstrap/disk_memo.rs index 8b3998941..29d224241 100644 --- a/crates/pa-core/src/kernel/bootstrap/disk_memo.rs +++ b/crates/pa-core/src/kernel/bootstrap/disk_memo.rs @@ -137,6 +137,7 @@ mod tests { read_keys(path) } + #[pa_test_scratch::pa_test] #[test] fn write_then_hit_and_dedupe() { let dir = tempfile::tempdir().unwrap(); @@ -151,6 +152,7 @@ mod tests { assert!(std::fs::symlink_metadata(&path).is_ok_and(|m| m.is_file())); } + #[pa_test_scratch::pa_test] #[test] fn cap_then_clear_matches_the_in_process_rule() { let dir = tempfile::tempdir().unwrap(); @@ -167,6 +169,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn stale_and_forged_entries_never_hit() { let dir = tempfile::tempdir().unwrap(); @@ -207,6 +210,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn invalidate_serves_no_hits_with_the_fallback() { let dir = tempfile::tempdir().unwrap(); @@ -227,6 +231,7 @@ mod tests { std::fs::remove_dir(&path).unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn missing_dir_is_fail_open_on_write() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/kernel/bootstrap/mod.rs b/crates/pa-core/src/kernel/bootstrap/mod.rs index cfc07cbb8..5f8d689ac 100644 --- a/crates/pa-core/src/kernel/bootstrap/mod.rs +++ b/crates/pa-core/src/kernel/bootstrap/mod.rs @@ -331,6 +331,7 @@ mod tests { use super::*; #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn cancelled_caller_does_not_unlock_a_running_bootstrap() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel-venv"); @@ -363,6 +364,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn lock_timeout_prevents_venv_rebuild() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel-venv"); diff --git a/crates/pa-core/src/kernel/bootstrap/runtime_code.rs b/crates/pa-core/src/kernel/bootstrap/runtime_code.rs index ddffa23c1..24c7f55d9 100644 --- a/crates/pa-core/src/kernel/bootstrap/runtime_code.rs +++ b/crates/pa-core/src/kernel/bootstrap/runtime_code.rs @@ -205,6 +205,7 @@ mod tests { use super::*; use std::path::PathBuf; + #[pa_test_scratch::pa_test] #[test] fn bootstrap_code_without_skills_binds_rlm() { let code = build_rlm_bootstrap_code(&[]); @@ -214,6 +215,7 @@ mod tests { assert!(!code.contains("_PrimeAgentUnavailableSkill")); } + #[pa_test_scratch::pa_test] #[test] fn bootstrap_recovery_advice_preserves_typescript_runtime() { let code = build_rlm_bootstrap_code(&[]); @@ -225,6 +227,7 @@ mod tests { assert!(!code.contains("Remove ~/.prime/agent/kernel-venv ")); } + #[pa_test_scratch::pa_test] #[test] fn bootstrap_code_imports_skills() { let skills = vec![KernelPythonSkill { @@ -240,6 +243,7 @@ mod tests { /// The TS #2381 parser table: marker+JSON, noise-prefixed marker, no marker, non-JSON payload /// all land where the host-side report decides notice vs silence. + #[pa_test_scratch::pa_test] #[test] fn parse_unavailable_python_skills_table() { let cases: Vec<(String, Option)> = vec![ @@ -266,6 +270,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn parse_unavailable_python_skills_drops_non_string_and_empty_values() { // Non-string values and empty messages drop (TS keeps only diff --git a/crates/pa-core/src/kernel/bootstrap/venv/layout/tests.rs b/crates/pa-core/src/kernel/bootstrap/venv/layout/tests.rs index 7281fdb38..69eb2986e 100644 --- a/crates/pa-core/src/kernel/bootstrap/venv/layout/tests.rs +++ b/crates/pa-core/src/kernel/bootstrap/venv/layout/tests.rs @@ -2,6 +2,7 @@ use super::*; +#[pa_test_scratch::pa_test] #[test] fn rust_kernel_namespaces_preserve_legacy_fixtures_and_private_overrides() { const CASE_ENV: &str = "PA_RUNTIME_NAMESPACING_CASE"; diff --git a/crates/pa-core/src/kernel/bootstrap/venv/recovery/tests.rs b/crates/pa-core/src/kernel/bootstrap/venv/recovery/tests.rs index 1db1bceb3..a82862623 100644 --- a/crates/pa-core/src/kernel/bootstrap/venv/recovery/tests.rs +++ b/crates/pa-core/src/kernel/bootstrap/venv/recovery/tests.rs @@ -46,6 +46,7 @@ fn environment(path: &Path, identity: &str) { std::fs::write(path.join("user-package"), "keep me").unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn archive_copy_and_rollback_preserve_original_bytes_and_symlinks() { let dir = tempfile::tempdir().unwrap(); @@ -91,6 +92,7 @@ fn archive_copy_and_rollback_preserve_original_bytes_and_symlinks() { assert!(!intent_path(&venv).exists()); } +#[pa_test_scratch::pa_test] #[test] fn interrupted_intent_before_rename_leaves_active_environment_unchanged() { let dir = tempfile::tempdir().unwrap(); @@ -116,6 +118,7 @@ fn interrupted_intent_before_rename_leaves_active_environment_unchanged() { assert!(!intent_path(&venv).exists()); } +#[pa_test_scratch::pa_test] #[test] fn interrupted_archive_before_copy_restores_predecessor() { let dir = tempfile::tempdir().unwrap(); @@ -131,6 +134,7 @@ fn interrupted_archive_before_copy_restores_predecessor() { assert!(!intent_path(&venv).exists()); } +#[pa_test_scratch::pa_test] #[test] fn unsafe_intent_and_symlink_backup_root_never_move_active_environment() { let dir = tempfile::tempdir().unwrap(); @@ -166,6 +170,7 @@ fn unsafe_intent_and_symlink_backup_root_never_move_active_environment() { } #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn successful_upgrade_intent_and_offline_source_rollback_reuse_archives() { let dir = tempfile::tempdir().unwrap(); @@ -204,6 +209,7 @@ fn uv_fixture(root: &Path, sync_body: &str) -> PathBuf { #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn failed_locked_upgrade_rolls_back_user_packages_and_marker() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel"); @@ -236,6 +242,7 @@ async fn failed_locked_upgrade_rolls_back_user_packages_and_marker() { #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn successful_locked_upgrade_preserves_extra_packages_and_archive() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel"); @@ -268,6 +275,7 @@ async fn successful_locked_upgrade_preserves_extra_packages_and_archive() { } #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn refused_archive_keeps_active_environment() { let root = tempfile::tempdir().unwrap(); @@ -298,6 +306,7 @@ impl Drop for KillGroup { // This is process dispatch, not an environment-gated optional test. #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn killed_upgrade_refuses_reacquisition_requires_offline_recovery() { use std::os::unix::process::CommandExt; use tokio::io::AsyncBufReadExt; @@ -393,6 +402,7 @@ async fn killed_upgrade_refuses_reacquisition_requires_offline_recovery() { #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn failed_post_sync_readiness_restores_the_working_predecessor() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel"); @@ -441,6 +451,7 @@ fn checkpoint_skills(root: &Path) -> Vec { #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn killed_skill_sync_refuses_reacquisition_requires_offline_recovery() { use std::os::unix::process::CommandExt; use tokio::io::AsyncBufReadExt; @@ -569,6 +580,7 @@ async fn killed_skill_sync_refuses_reacquisition_requires_offline_recovery() { #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn committed_replacement_finalizes_intent_even_with_a_legacy_corrupt_predecessor() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel"); @@ -604,6 +616,7 @@ async fn committed_replacement_finalizes_intent_even_with_a_legacy_corrupt_prede #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn fresh_kernel_syncs_locked_group_without_seed_or_inexact() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel"); diff --git a/crates/pa-core/src/kernel/bootstrap/venv/runtime_source.rs b/crates/pa-core/src/kernel/bootstrap/venv/runtime_source.rs index 058c3ae01..049f648cc 100644 --- a/crates/pa-core/src/kernel/bootstrap/venv/runtime_source.rs +++ b/crates/pa-core/src/kernel/bootstrap/venv/runtime_source.rs @@ -116,6 +116,7 @@ mod tests { Ok(()) } + #[pa_test_scratch::pa_test] #[test] fn lockfile_changes_invalidate_identity_and_missing_lock_fails() -> anyhow::Result<()> { let temp = tempfile::tempdir()?; @@ -129,6 +130,7 @@ mod tests { Ok(()) } + #[pa_test_scratch::pa_test] #[test] fn missing_or_incomplete_runtime_sources_are_not_resolved() -> anyhow::Result<()> { let temp = tempfile::tempdir()?; @@ -159,6 +161,7 @@ mod tests { Ok(()) } + #[pa_test_scratch::pa_test] #[test] fn packaged_dist_and_checkout_sources_resolve_to_absolute_paths() -> anyhow::Result<()> { let temp = tempfile::tempdir()?; @@ -183,6 +186,7 @@ mod tests { Ok(()) } + #[pa_test_scratch::pa_test] #[test] fn relative_package_paths_are_never_returned_as_requirements() -> anyhow::Result<()> { const CHILD_ROOT: &str = "PA_TEST_RELATIVE_RUNTIME_SOURCE_ROOT"; diff --git a/crates/pa-core/src/kernel/bootstrap/venv/tests.rs b/crates/pa-core/src/kernel/bootstrap/venv/tests.rs index e04d1c40a..6f100c2d4 100644 --- a/crates/pa-core/src/kernel/bootstrap/venv/tests.rs +++ b/crates/pa-core/src/kernel/bootstrap/venv/tests.rs @@ -1,6 +1,7 @@ //! The venv module's unit battery: Windows executable candidates, the //! skill-manifest parsing, the version-file round trip, the two-layer //! probe memo oracles, and the skill-sync batching. +#[pa_test_scratch::pa_test] #[test] fn windows_executable_candidates_default_order() { assert_eq!( @@ -15,6 +16,7 @@ fn windows_executable_candidates_default_order() { ); } +#[pa_test_scratch::pa_test] #[test] fn windows_executable_candidates_follows_pathext_order() { assert_eq!( @@ -23,6 +25,7 @@ fn windows_executable_candidates_follows_pathext_order() { ); } +#[pa_test_scratch::pa_test] #[test] fn windows_executable_candidates_skips_suffix_and_duplicates() { assert_eq!( @@ -43,6 +46,7 @@ fn windows_executable_candidates_skips_suffix_and_duplicates() { use super::*; +#[pa_test_scratch::pa_test] #[test] fn dependency_names_parse() { let dir = tempfile::tempdir().unwrap(); @@ -96,6 +100,7 @@ fn collect_memo_files(root: &Path, found: &mut Vec) { } } +#[pa_test_scratch::pa_test] #[test] fn version_file_round_trips() { let dir = tempfile::tempdir().unwrap(); @@ -110,6 +115,7 @@ fn version_file_round_trips() { )); } +#[pa_test_scratch::pa_test] #[test] fn probe_memo_key_distinguishes_every_input_and_drops_on_invalidate() { let _memo_state = MEMO_STATE_LOCK @@ -152,6 +158,7 @@ fn probe_memo_key_distinguishes_every_input_and_drops_on_invalidate() { /// The out-of-band-detection trio: the memo must hit on an unchanged venv, miss when the installed /// `rlm` tree or the interpreter changes, and miss after invalidation. #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn probe_memo_misses_on_out_of_band_venv_mutation() { let _memo_state = MEMO_STATE_LOCK @@ -259,6 +266,7 @@ fn probe_memo_misses_on_out_of_band_venv_mutation() { /// The cross-process layer, pinned: a fresh process (empty in-process map) /// hits the on-disk memo under the same identity key and runs ZERO probes. #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn disk_memo_hits_across_a_fresh_process_with_zero_probes() { let _memo_state = MEMO_STATE_LOCK @@ -318,6 +326,7 @@ fn disk_memo_hits_across_a_fresh_process_with_zero_probes() { /// Damage across processes: process A memoizes, the venv is damaged /// out of band, and a FRESH process must miss both layers and re-probe. #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn disk_memo_damage_across_processes_misses_and_reprobes() { let _memo_state = MEMO_STATE_LOCK @@ -406,6 +415,7 @@ fn disk_memo_damage_across_processes_misses_and_reprobes() { /// The masked class, pinned against the DISK layer: fingerprint-invisible damage is masked by a /// cross-process hit until the first failed kernel start drops BOTH layers and. #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn disk_memo_masked_class_hits_across_processes_until_invalidation() { let _memo_state = MEMO_STATE_LOCK @@ -478,6 +488,7 @@ fn disk_memo_masked_class_hits_across_processes_until_invalidation() { /// key-valid entry. That is BENIGN — the entry's key matches the current environment — and the next /// failed start re-invalidates. #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn disk_memo_late_write_after_invalidate_is_benign() { let _memo_state = MEMO_STATE_LOCK @@ -544,6 +555,7 @@ static PRIME_AGENT_ENV_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_ /// the DIRECT probe and never reads or writes any memo file. #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn custom_override_never_touches_the_disk_memo() { let _guard = PRIME_AGENT_ENV_LOCK.lock().await; let dir = tempfile::tempdir().unwrap(); @@ -592,6 +604,7 @@ async fn custom_override_never_touches_the_disk_memo() { /// The Windows venv layout (`/Lib/site-packages/rlm`, no python-version layer) is a /// fingerprint input: mutations under it change the memo key. +#[pa_test_scratch::pa_test] #[test] fn windows_layout_venv_rlm_is_witnessed() { let dir = tempfile::tempdir().unwrap(); @@ -620,6 +633,7 @@ fn windows_layout_venv_rlm_is_witnessed() { /// Live (ignored by default; run with `--ignored` on a machine with a kernel venv under `HOME`): /// the memo behavior against a REAL interpreter and a REAL `rlm` import. #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] #[ignore = "live: needs a real kernel venv under HOME (bench VMs)"] fn live_probe_memo_reprobes_when_installed_rlm_is_removed() { @@ -778,6 +792,7 @@ fn live_probe_memo_reprobes_when_installed_rlm_is_removed() { /// Live-gated closure freeze (run with `--ignored` on a machine with a real kernel venv): the /// runtime-ready probe's import closure must stay stdlib-or- rlm-relative at MODULE level. Pins the /// shipped artifact. +#[pa_test_scratch::pa_test] #[test] #[ignore = "live: needs a real kernel venv under HOME (bench VMs)"] fn live_probe_closure_is_stdlib_or_rlm_relative() { @@ -887,6 +902,7 @@ print(json.dumps({"closure": sorted(closure), "violations": violations})) ); } +#[pa_test_scratch::pa_test] #[test] fn extra_recorded_skills_do_not_force_reinstall() { // A session's set ([edit]) must be served by a venv that also carries @@ -932,6 +948,7 @@ fn uv_invocations(dir: &Path) -> Vec { #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn skill_sync_installs_only_missing_skills() { // A fake uv records its args: every missing skill must land in ONE // invocation, and already-installed skills must stay out of it. @@ -1002,6 +1019,7 @@ async fn skill_sync_installs_only_missing_skills() { #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn skill_sync_checkpoints_successes_and_excludes_failed_skills() { // A batch covering several skills fails; the fallback retries each missing skill alone. let dir = tempfile::tempdir().unwrap(); @@ -1064,6 +1082,7 @@ async fn skill_sync_checkpoints_successes_and_excludes_failed_skills() { assert_eq!(recorded, vec!["edit"], "only the healthy skill is recorded"); } +#[pa_test_scratch::pa_test] #[test] fn inline_dependencies_and_cycles_resolve_to_local_skills() { let root = tempfile::tempdir().unwrap(); @@ -1096,6 +1115,7 @@ fn inline_dependencies_and_cycles_resolve_to_local_skills() { #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn changed_recorded_skills_each_install_and_checkpoint_without_dropping_later_records() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel"); @@ -1150,6 +1170,7 @@ async fn changed_recorded_skills_each_install_and_checkpoint_without_dropping_la #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn failed_local_dependency_is_still_offered_as_trusted_source_to_its_dependent() { let root = tempfile::tempdir().unwrap(); let venv = root.path().join("kernel"); diff --git a/crates/pa-core/src/kernel/bootstrap/venv/version.rs b/crates/pa-core/src/kernel/bootstrap/venv/version.rs index 21b174d37..2c86ff636 100644 --- a/crates/pa-core/src/kernel/bootstrap/venv/version.rs +++ b/crates/pa-core/src/kernel/bootstrap/venv/version.rs @@ -151,6 +151,7 @@ pub(super) fn read_bootstrap_version_raw(venv: &Path) -> (Option= 250ms) shows up in the elapsed time. @@ -1729,6 +1744,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn startup_retry_cancelled_by_dispose() { let options = IpythonKernelProvisionerOptions { python: Some(PathBuf::from("/nonexistent/kernel-python-for-test")), @@ -1751,6 +1767,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn clone_shares_kernel_state() { let provisioner = IpythonKernelProvisioner::new("/tmp", IpythonKernelProvisionerOptions::default()); @@ -1760,6 +1777,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn prewarm_swallows_failure_and_keeps_lazy_fallback() { let options = IpythonKernelProvisionerOptions { python: Some(PathBuf::from("/nonexistent/kernel-python-for-test")), @@ -1788,6 +1806,7 @@ mod tests { /// request or the failed boot's shutdown behind a full pipe. #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn nonreading_kernel_fails_bootstrap_without_parking_shutdown() { use std::os::unix::fs::PermissionsExt; @@ -1832,6 +1851,7 @@ mod tests { /// failure. #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn silent_bootstrap_fails_bounded_and_leaves_no_kernel() { use std::os::unix::fs::PermissionsExt; @@ -1902,6 +1922,7 @@ for line in sys.stdin: ); } + #[pa_test_scratch::pa_test] #[test] fn real_kernel_bootstrap_keeps_default_budget_in_test_builds() { let options = IpythonKernelProvisionerOptions::default(); diff --git a/crates/pa-core/src/kernel/rlm_runtime.rs b/crates/pa-core/src/kernel/rlm_runtime.rs index 3e39cde3d..3a171910a 100644 --- a/crates/pa-core/src/kernel/rlm_runtime.rs +++ b/crates/pa-core/src/kernel/rlm_runtime.rs @@ -370,6 +370,7 @@ pub fn kwargs_from_payload(payload: &Value) -> serde_json::Map { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn normalizes_session_name() { assert_eq!( @@ -385,6 +386,7 @@ mod tests { assert!(normalize_requested_rlm_subagent_session_name(Some(&long), "rlm.spawn").is_err()); } + #[pa_test_scratch::pa_test] #[test] fn normalizes_thinking_and_model() { assert_eq!( @@ -401,6 +403,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn default_session_name_shape() { let name = @@ -410,6 +413,7 @@ mod tests { assert!(name.chars().count() <= 64); } + #[pa_test_scratch::pa_test] #[test] fn model_matches_ranked_and_capped() { let models = vec![ @@ -434,6 +438,7 @@ mod tests { assert_eq!(matches.len(), 1, "empty query lists up to the limit"); } + #[pa_test_scratch::pa_test] #[test] fn short_form_resolution_and_error_text() { let models = vec![ diff --git a/crates/pa-core/src/kernel/state_snapshot.rs b/crates/pa-core/src/kernel/state_snapshot.rs index 0652605af..c517458ea 100644 --- a/crates/pa-core/src/kernel/state_snapshot.rs +++ b/crates/pa-core/src/kernel/state_snapshot.rs @@ -57,6 +57,7 @@ pub fn manifest_path_in(artifact_dir: impl AsRef) -> PathBuf { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn paths_match_ts_layout() { assert_eq!( diff --git a/crates/pa-core/src/mcp/login.rs b/crates/pa-core/src/mcp/login.rs index 8bc915f61..720123572 100644 --- a/crates/pa-core/src/mcp/login.rs +++ b/crates/pa-core/src/mcp/login.rs @@ -387,6 +387,7 @@ mod tests { ]) } + #[pa_test_scratch::pa_test] #[test] fn oauth_config_threads_client_id_and_callback_port() { for endpoint in ["https://fixture.example/mcp", "https://mcp.slack.com/mcp"] { @@ -411,6 +412,7 @@ mod tests { /// Slack has no DCR; drive its public desktop client through the real manager and auth store. #[tokio::test] + #[pa_test_scratch::pa_test] async fn slack_login_persists_refreshes_and_can_login_again() { struct SlackHttp { responses: ScriptedHttp, @@ -529,6 +531,7 @@ mod tests { assert!(enabled.contains(&"slack".to_string())); } + #[pa_test_scratch::pa_test] #[test] fn registered_oauth_client_follows_endpoint_instead_of_connection_name() { let agent = tempfile::tempdir().unwrap(); @@ -556,6 +559,7 @@ mod tests { /// `begin_login` -> persisted endpoint-bound credentials -> `is_authed` /// -> the server unlocks in the prompt gating. #[tokio::test] + #[pa_test_scratch::pa_test] async fn begin_login_persists_creds_and_unlocks_gating() { let agent = tempfile::tempdir().unwrap(); let http = Arc::new(fixture_http()); @@ -630,6 +634,7 @@ mod tests { /// The builtin linear integration: `begin_login` removes its skill /// override; notion stays disabled. #[tokio::test] + #[pa_test_scratch::pa_test] async fn begin_login_unlocks_builtin_skill_gating() { let agent = tempfile::tempdir().unwrap(); let http = Arc::new(ScriptedHttp::new(vec![ @@ -698,6 +703,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cancelled_or_expired_login_waiting_for_storage_is_not_saved() { struct StorageUi { paste: PasteUi, @@ -791,6 +797,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cancellation_after_token_response_prevents_persistence() { struct CancelOnToken { scripted: ScriptedHttp, @@ -867,6 +874,7 @@ mod tests { /// Unknown servers and non-OAuth servers error with the TS wording; /// the handler surfaces it to the kernel. #[tokio::test] + #[pa_test_scratch::pa_test] async fn begin_login_rejects_unknown_servers() { let agent = tempfile::tempdir().unwrap(); let http = Arc::new(ReqwestOAuthHttp::new()) as Arc; @@ -895,6 +903,7 @@ mod tests { /// Expired credentials refresh through the `AuthStorage` seam: the stored endpoint answers a /// `refresh_token` grant. #[tokio::test] + #[pa_test_scratch::pa_test] async fn mcp_oauth_refreshes_expired_credentials() { let agent = tempfile::tempdir().unwrap(); let http = Arc::new(fixture_http()); @@ -932,6 +941,7 @@ mod tests { /// A credential written by another process is visible to the worker's `mcp.refresh`:. #[tokio::test] + #[pa_test_scratch::pa_test] async fn refresh_sees_credentials_written_by_another_process() { let agent = tempfile::tempdir().unwrap(); let http = Arc::new(fixture_http()); @@ -976,6 +986,7 @@ mod tests { /// mcp.refresh refuses ACP-admitted servers with the TS wording. #[tokio::test] + #[pa_test_scratch::pa_test] async fn mcp_refresh_rejects_acp_servers() { let agent = tempfile::tempdir().unwrap(); let http = Arc::new(ReqwestOAuthHttp::new()) as Arc; diff --git a/crates/pa-core/src/mcp/mod.rs b/crates/pa-core/src/mcp/mod.rs index 091b66e11..ea953897b 100644 --- a/crates/pa-core/src/mcp/mod.rs +++ b/crates/pa-core/src/mcp/mod.rs @@ -810,6 +810,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn connection_roster_covers_builtins_and_user_servers() { let mut user_servers = HashMap::new(); @@ -835,6 +836,7 @@ mod tests { assert_eq!(linear.transport, "http"); } + #[pa_test_scratch::pa_test] #[test] fn builtin_catalog_and_skill_overrides() { let manager = manager_with(None); @@ -857,6 +859,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn stdio_and_env_token_servers_are_enabled() { let mut user_servers = HashMap::new(); @@ -871,6 +874,7 @@ mod tests { assert!(!generic.contains(&"search".to_string())); } + #[pa_test_scratch::pa_test] #[test] fn user_servers_cannot_reserve_builtin_names() { let mut user_servers = HashMap::new(); @@ -891,6 +895,7 @@ mod tests { .contains(&"linear".to_string())); } + #[pa_test_scratch::pa_test] #[test] fn generic_name_pattern() { assert!(is_generic_server_name("a")); @@ -901,6 +906,7 @@ mod tests { assert!(!is_generic_server_name(&"x".repeat(65))); } + #[pa_test_scratch::pa_test] #[test] fn acp_server_ownership() { let manager = manager_with(None); @@ -925,6 +931,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn config_host_handler_returns_user_stdio_server_config() { let mut user_servers = HashMap::new(); user_servers.insert( @@ -957,6 +964,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn config_host_handler_resolves_user_and_acp_servers() { let manager = std::sync::Arc::new(std::sync::Mutex::new(manager_with(None))); let mut handlers = HostRequestHandlers::default(); diff --git a/crates/pa-core/src/mcp/oauth.rs b/crates/pa-core/src/mcp/oauth.rs index a48d1f47e..639a9018a 100644 --- a/crates/pa-core/src/mcp/oauth.rs +++ b/crates/pa-core/src/mcp/oauth.rs @@ -768,6 +768,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn dropping_a_login_with_a_pending_paste_releases_the_registered_port() { struct PendingUi(Mutex); impl McpLoginUi for PendingUi { @@ -823,6 +824,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn settled_browser_code_wins_over_paste_cancel_and_validation_errors() { struct GraceUi { auth_url: Mutex, @@ -916,6 +918,7 @@ mod tests { /// The full Plane-style login through a manual paste: PRM, issuer /// metadata, DCR, and the token endpoint. #[tokio::test] + #[pa_test_scratch::pa_test] async fn discovers_protected_resource_metadata_and_external_issuer() { let http = ScriptedHttp::new(vec![ (RESOURCE, 401, None, ""), @@ -1020,6 +1023,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn origin_level_metadata_without_protected_resource() { let origin_prm = "https://srv.test/.well-known/oauth-protected-resource/mcp"; let http = ScriptedHttp::new(vec![ @@ -1079,6 +1083,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn www_authenticate_pointer_preferred() { let pointer = "https://metadata.example/resources/plane"; let http = ScriptedHttp::new(vec![ @@ -1142,6 +1147,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn protected_resource_mismatch_fails() { let http = ScriptedHttp::new(vec![ (RESOURCE, 401, None, ""), @@ -1166,6 +1172,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn prm_selected_issuer_must_match_exactly() { let http = ScriptedHttp::new(vec![ (RESOURCE, 401, None, ""), @@ -1204,6 +1211,7 @@ mod tests { /// Pathful OIDC metadata when RFC 8414 serves a non-metadata document. #[tokio::test] + #[pa_test_scratch::pa_test] async fn pathful_oidc_fallback() { let issuer = "https://login.example/tenant"; let oidc_meta = "https://login.example/tenant/.well-known/openid-configuration"; @@ -1260,6 +1268,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn dynamic_registration_unavailable_fails_clearly() { let meta = serde_json::json!({ "issuer": "https://srv.test/tenant", @@ -1280,6 +1289,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn redirected_token_post_rejected() { let credentials = AuthCredential::Oauth { access: "a".to_string(), @@ -1311,6 +1321,7 @@ mod tests { /// Refresh keeps the stored bindings, the resource indicator, and the /// prior refresh token when the server omits a new one. #[tokio::test] + #[pa_test_scratch::pa_test] async fn refresh_validates_bindings() { let credentials = AuthCredential::Oauth { access: "access-1".to_string(), @@ -1438,6 +1449,7 @@ mod tests { /// A discovery-mode change (origin-only credentials against a /// resource-bound server) requires a fresh login. #[tokio::test] + #[pa_test_scratch::pa_test] async fn discovery_mode_change_requires_relogin() { let credentials = AuthCredential::Oauth { access: "origin-access".to_string(), @@ -1483,6 +1495,7 @@ mod tests { /// A genuine paste validation error surfaces; a cancelled paste keeps the browser path alive, /// then reports a missing code. #[tokio::test] + #[pa_test_scratch::pa_test] async fn manual_paste_state_mismatch_surfaces() { let http = ScriptedHttp::new(vec![ (ORIGIN_URL, 404, None, ""), @@ -1511,6 +1524,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn zero_callback_port_fails_before_any_oauth_request() { for client_id in [None, Some("fixture-client".to_string())] { let http = ScriptedHttp::new(vec![]); @@ -1525,6 +1539,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn pre_registered_client_skips_registration_and_pins_the_redirect() { let (reservation, ownership) = super::super::oauth_callback::test_listener::reserve_listener(); @@ -1594,6 +1609,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn dynamic_registration_advertises_the_pinned_redirect() { let (reservation, ownership) = super::super::oauth_callback::test_listener::reserve_listener(); @@ -1654,6 +1670,7 @@ mod tests { /// string-equal, match — the declared resource is the stored and sent /// audience. #[tokio::test] + #[pa_test_scratch::pa_test] async fn root_endpoint_trailing_slash_resource_audience() { const ROOT: &str = "https://root.example"; const ROOT_PRM: &str = "https://root.example/.well-known/oauth-protected-resource"; @@ -1742,6 +1759,7 @@ mod tests { /// The Notion/Slack shape (TS parity): an origin-level declared /// resource serves a pathful endpoint as an "origin" audience. #[tokio::test] + #[pa_test_scratch::pa_test] async fn origin_level_resource_audience_serves_pathful_endpoint() { const NOTION_PRM: &str = "https://srv.test/.well-known/oauth-protected-resource/mcp"; let http = ScriptedHttp::new(vec![ @@ -1812,6 +1830,7 @@ mod tests { /// Origin-mode credentials refresh against the origin-level binding; /// an audience-mode drift against current discovery requires re-login. #[tokio::test] + #[pa_test_scratch::pa_test] async fn refresh_validates_audience_modes() { const NOTION_PRM: &str = "https://srv.test/.well-known/oauth-protected-resource/mcp"; const DECLARED: &str = "https://srv.test"; diff --git a/crates/pa-core/src/mcp/oauth/lifecycle_tests.rs b/crates/pa-core/src/mcp/oauth/lifecycle_tests.rs index 282bb8f57..912d3e919 100644 --- a/crates/pa-core/src/mcp/oauth/lifecycle_tests.rs +++ b/crates/pa-core/src/mcp/oauth/lifecycle_tests.rs @@ -58,6 +58,7 @@ impl OAuthHttp for HangingHttp { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn explicit_cancel_drops_discovery_registration_and_token_exchange() { for hang_url in [ORIGIN_URL, ORIGIN_REGISTER, ORIGIN_TOKEN] { let http = HangingHttp { @@ -104,6 +105,7 @@ async fn explicit_cancel_drops_discovery_registration_and_token_exchange() { } #[tokio::test(start_paused = true)] +#[pa_test_scratch::pa_test] async fn whole_flow_deadline_includes_pending_discovery() { let http = HangingHttp { scripted: ScriptedHttp::new(vec![]), @@ -125,6 +127,7 @@ async fn whole_flow_deadline_includes_pending_discovery() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn pre_cancelled_login_issues_no_requests() { let http = ScriptedHttp::new(vec![]); let ui = CancelUi { @@ -140,6 +143,7 @@ async fn pre_cancelled_login_issues_no_requests() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn whole_flow_deadline_interrupts_token_exchange() { let http = HangingHttp { scripted: ScriptedHttp::new(vec![ @@ -183,6 +187,7 @@ async fn whole_flow_deadline_interrupts_token_exchange() { } #[tokio::test(start_paused = true)] +#[pa_test_scratch::pa_test] async fn whole_flow_deadline_closes_pending_callback_listener() { struct PendingUi(Mutex); impl McpLoginUi for PendingUi { diff --git a/crates/pa-core/src/mcp/oauth_callback.rs b/crates/pa-core/src/mcp/oauth_callback.rs index f11551015..1047d93c1 100644 --- a/crates/pa-core/src/mcp/oauth_callback.rs +++ b/crates/pa-core/src/mcp/oauth_callback.rs @@ -661,6 +661,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cancel_closes_idle_accepted_sockets_and_joins_all_requests() { let server = ephemeral_server().await; let mut events = server.sockets.lock().unwrap().progress.subscribe(); @@ -680,6 +681,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn drop_closes_idle_accepted_sockets_without_a_runtime_turn() { let server = ephemeral_server().await; let port = server.port; @@ -701,6 +703,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn idle_connections_are_bounded_and_releasing_one_resumes_acceptance() { let server = ephemeral_server().await; let mut events = server.sockets.lock().unwrap().progress.subscribe(); @@ -735,6 +738,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn fragmented_headers_do_not_settle_before_the_terminator() { let server = ephemeral_server().await; let mut events = server.sockets.lock().unwrap().progress.subscribe(); @@ -761,6 +765,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn upgrades_close_without_settling_even_with_valid_query_parameters() { let server = ephemeral_server().await; for upgrade in [ @@ -781,6 +786,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn oversized_request_head_is_rejected_without_settling() { let server = ephemeral_server().await; let mut stream = TcpStream::connect(("127.0.0.1", server.port)) @@ -798,6 +804,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn incomplete_head_has_one_total_deadline_not_a_per_read_deadline() { let server = ephemeral_server().await; let mut events = server.sockets.lock().unwrap().progress.subscribe(); @@ -831,6 +838,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn settlement_is_persistent_and_wakes_all_registered_waiters() { let server = ephemeral_server().await; let mut first = Box::pin(server.wait_for_code()); @@ -860,6 +868,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn settled_browser_code_survives_ready_input_after_listener_exit() { // An accept loop can exit while a previously accepted request is still completing. // Complete listener cleanup first so input cancellation will not yield on a join. @@ -886,6 +895,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn dropping_a_registered_callback_releases_the_port_without_yielding() { let (reservation, ownership) = test_listener::reserve_listener(); let port = reservation.port(); @@ -900,6 +910,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn registered_port_is_exact_and_released_after_cancel() { let blocker = std::net::TcpListener::bind(("127.0.0.1", 0)).unwrap(); let port = blocker.local_addr().unwrap().port(); @@ -939,6 +950,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn falls_back_to_the_next_free_port() { let blocker = std::net::TcpListener::bind(("127.0.0.1", 0)).unwrap(); let blocked_port = blocker.local_addr().unwrap().port(); @@ -952,6 +964,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn all_candidates_bound_fails_clearly() { let blockers: Vec<_> = (0..2) .map(|_| std::net::TcpListener::bind(("127.0.0.1", 0)).unwrap()) @@ -968,6 +981,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn callback_flow_settles_code_and_state() { let server = ephemeral_server().await; let response = reqwest::Client::new() @@ -989,6 +1003,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn error_callback_settles_none() { let server = ephemeral_server().await; let response = reqwest::Client::new() @@ -1004,6 +1019,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn unknown_route_is_404_without_settling() { let server = ephemeral_server().await; let response = reqwest::Client::new() @@ -1017,6 +1033,7 @@ mod tests { assert!(server.wait_for_code().await.is_none()); } + #[pa_test_scratch::pa_test] #[test] fn query_and_percent_decoding() { for (encoded, decoded) in [ @@ -1037,6 +1054,7 @@ mod tests { assert_eq!(query_param("code", "state"), None); } #[tokio::test] + #[pa_test_scratch::pa_test] async fn zero_callback_port_is_rejected_before_binding_or_registration() { assert!(redirect_uris(Some(0)) .unwrap_err() @@ -1047,6 +1065,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn pinned_port_is_owned_until_drop() { let (reservation, ownership) = test_listener::reserve_listener(); let port = reservation.port(); diff --git a/crates/pa-core/src/mcp/oauth_discovery.rs b/crates/pa-core/src/mcp/oauth_discovery.rs index cbe61d3c3..17c2064a4 100644 --- a/crates/pa-core/src/mcp/oauth_discovery.rs +++ b/crates/pa-core/src/mcp/oauth_discovery.rs @@ -586,6 +586,7 @@ pub(crate) fn parse_redirect_input(input: &str, expected_state: &str) -> Result< mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn https_url_validation() { assert!(validated_https_url("https://mcp.example/mcp", ENDPOINT_LABEL).is_ok()); @@ -609,6 +610,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn canonical_resource_forms() { assert_eq!( @@ -634,6 +636,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn authorization_server_metadata_urls_cover_both_locations() { let issuer = Url::parse("https://login.example/tenant").unwrap(); @@ -646,6 +649,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn metadata_validation_messages() { let issuer = "https://login.example/tenant"; @@ -710,6 +714,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn protected_resource_metadata_audience_policy() { let endpoint = Url::parse("https://mcp.example/mcp").unwrap(); @@ -787,6 +792,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn www_authenticate_resource_metadata_pointer() { assert_eq!( @@ -799,6 +805,7 @@ mod tests { assert_eq!(header_resource_metadata(Some("Basic realm=\"x\"")), None); } + #[pa_test_scratch::pa_test] #[test] fn redirect_input_parsing() { assert_eq!( @@ -825,6 +832,7 @@ mod tests { assert_eq!(error, "Missing authorization code"); } + #[pa_test_scratch::pa_test] #[test] fn pkce_shapes() { let (verifier, challenge) = generate_pkce(); diff --git a/crates/pa-core/src/mcp/oauth_http.rs b/crates/pa-core/src/mcp/oauth_http.rs index 6fb970479..7b0941679 100644 --- a/crates/pa-core/src/mcp/oauth_http.rs +++ b/crates/pa-core/src/mcp/oauth_http.rs @@ -153,6 +153,7 @@ fn method_label(method: OAuthHttpMethod) -> &'static str { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn response_header_lookup_is_case_insensitive() { let response = OAuthHttpResponse { diff --git a/crates/pa-core/src/models/allowlist.rs b/crates/pa-core/src/models/allowlist.rs index 1712e8516..a3548f2ac 100644 --- a/crates/pa-core/src/models/allowlist.rs +++ b/crates/pa-core/src/models/allowlist.rs @@ -65,6 +65,7 @@ mod tests { const SELECTOR: &str = "prime-inference/internal/glm-5.3-fast"; + #[pa_test_scratch::pa_test] #[test] fn exact_and_bare_id_patterns_match_case_insensitively() { assert!(model_allowed( @@ -88,6 +89,7 @@ mod tests { )); } + #[pa_test_scratch::pa_test] #[test] fn glob_patterns_match_the_full_selector_or_bare_id() { let allow = |pattern: &str| vec![pattern.to_string()]; @@ -109,6 +111,7 @@ mod tests { assert!(!model_allowed(SELECTOR, &allow("["))); } + #[pa_test_scratch::pa_test] #[test] fn the_refusal_error_carries_the_selector() { let refusal = ModelAllowlistRefusal { diff --git a/crates/pa-core/src/models/custom.rs b/crates/pa-core/src/models/custom.rs index 30deafd71..5f1aa6bec 100644 --- a/crates/pa-core/src/models/custom.rs +++ b/crates/pa-core/src/models/custom.rs @@ -576,6 +576,7 @@ pub fn load_custom_models( #[cfg(test)] mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn discovery_urls_keep_credentials_out_of_the_authority_and_fragment() { for url in [ @@ -596,6 +597,7 @@ mod tests { assert!(validate_config(&config, &|_| false).is_ok()); } + #[pa_test_scratch::pa_test] #[test] fn discovery_defaults_reject_invented_modalities_and_incomplete_pricing() { let defaults = serde_json::json!({"contextWindow":32000,"maxTokens":4000,"reasoning":false,"input":["text"], @@ -619,6 +621,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn strips_comments_and_trailing_commas() { let input = r#"{ @@ -632,6 +635,7 @@ mod tests { assert!(parsed["providers"]["ollama"]["baseUrl"].is_string()); } + #[pa_test_scratch::pa_test] #[test] fn validates_custom_provider_requirements() { let config = parse_models_config( @@ -643,6 +647,7 @@ mod tests { assert!(validate_config(&config, &|p| p == "custom").is_ok()); } + #[pa_test_scratch::pa_test] #[test] fn parses_custom_models_with_defaults() { let result = load_custom_models( @@ -662,6 +667,7 @@ mod tests { assert_eq!(result.models[0].context_window, 128_000); } + #[pa_test_scratch::pa_test] #[test] fn parses_a_custom_model_definition_thinking_level_map() { let result = load_custom_models( @@ -693,6 +699,7 @@ mod tests { /// TS `755-configured-max-tokens.test.ts`: a models.json `maxTokens` /// is explicit — the configured value reaches the provider unchanged /// instead of being clamped to the 32000 default ceiling. + #[pa_test_scratch::pa_test] #[test] fn a_models_json_max_tokens_is_explicit() { let result = load_custom_models( @@ -714,6 +721,7 @@ mod tests { /// A custom model that omits `maxTokens` defaults to 16384 and stays /// catalog-like (capped): the flag marks a CONFIGURED value only. + #[pa_test_scratch::pa_test] #[test] fn a_custom_model_without_max_tokens_stays_unmarked() { let result = load_custom_models( @@ -736,6 +744,7 @@ mod tests { /// configuration too — the flag flips true so the value bypasses the /// ceiling (a per-model override of a built-in model is the #755 /// shape with no custom provider involved). + #[pa_test_scratch::pa_test] #[test] fn a_per_model_override_marks_max_tokens_explicit() { let base: Model = serde_json::from_value(serde_json::json!({ @@ -759,6 +768,7 @@ mod tests { assert!(!untouched.max_tokens_explicit); } + #[pa_test_scratch::pa_test] #[test] fn model_overrides_merge() { let base = serde_json::from_value(serde_json::json!({ diff --git a/crates/pa-core/src/models/image_model_routing.rs b/crates/pa-core/src/models/image_model_routing.rs index 995d07c7d..95e92b01f 100644 --- a/crates/pa-core/src/models/image_model_routing.rs +++ b/crates/pa-core/src/models/image_model_routing.rs @@ -151,6 +151,7 @@ mod tests { // The TS table (test/image-model-override.test.ts): routes image turns // to imageModel; a vision session model serves image turns natively; // blocked images stay on the session model; refusals name the setting. + #[pa_test_scratch::pa_test] #[test] fn routes_image_turns_to_image_model() { let session = model("claude-opus-4-7-text-only", false); @@ -164,6 +165,7 @@ mod tests { assert_eq!(resolved.service_tier, Some(ServiceTier::Default)); } + #[pa_test_scratch::pa_test] #[test] fn vision_session_model_serves_image_turns() { let session = model("claude-opus-4-7", true); @@ -172,6 +174,7 @@ mod tests { assert_eq!(resolve_image_model_override(&inputs).unwrap(), None); } + #[pa_test_scratch::pa_test] #[test] fn blocked_images_stay_on_the_session_model() { let session = model("claude-opus-4-7-text-only", false); @@ -180,6 +183,7 @@ mod tests { assert_eq!(resolve_image_model_override(&inputs).unwrap(), None); } + #[pa_test_scratch::pa_test] #[test] fn refuses_without_image_model() { let session = model("claude-opus-4-7-text-only", false); @@ -190,6 +194,7 @@ mod tests { assert!(error.contains("Set imageModel in settings.json"), "{error}"); } + #[pa_test_scratch::pa_test] #[test] fn refuses_unusable_reference() { let session = model("claude-opus-4-7-text-only", false); @@ -199,6 +204,7 @@ mod tests { assert!(error.contains("could not be resolved"), "{error}"); } + #[pa_test_scratch::pa_test] #[test] fn refuses_text_only_image_model() { let session = model("claude-opus-4-7-text-only", false); @@ -214,6 +220,7 @@ mod tests { assert!(error.contains("could not be resolved"), "{error}"); } + #[pa_test_scratch::pa_test] #[test] fn refuses_unauthenticated_image_model() { let session = model("claude-opus-4-7-text-only", false); @@ -225,6 +232,7 @@ mod tests { assert!(error.contains("could not be resolved"), "{error}"); } + #[pa_test_scratch::pa_test] #[test] fn priority_tier_kept_on_fast_mode_models() { let session = model("claude-opus-4-7-text-only", false); diff --git a/crates/pa-core/src/models/ollama_cloud_config.rs b/crates/pa-core/src/models/ollama_cloud_config.rs index 3b9bff467..3f968d9fe 100644 --- a/crates/pa-core/src/models/ollama_cloud_config.rs +++ b/crates/pa-core/src/models/ollama_cloud_config.rs @@ -338,6 +338,7 @@ mod tests { .unwrap() } + #[pa_test_scratch::pa_test] #[test] fn merges_each_scope_per_key_and_only_overlays_the_outgoing_body() { let fixture = Fixture::new(); @@ -390,6 +391,7 @@ mod tests { assert_eq!(config.configure_model(&other_provider), other_provider); } + #[pa_test_scratch::pa_test] #[test] fn drops_unknown_fields_and_invalid_values_before_merging() { let fixture = Fixture::new(); @@ -454,6 +456,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn accepts_all_finite_sampler_keys_without_imposing_numeric_ranges() { let fixture = Fixture::new(); @@ -480,6 +483,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn rejects_overflow_numbers_but_keeps_valid_siblings_and_empty_stop() { let fixture = Fixture::new(); @@ -498,6 +502,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn caps_use_js_safe_integer_semantics_including_decimal_rounding() { let fixture = Fixture::new(); @@ -523,6 +528,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn invalid_or_missing_files_fall_back_independently() { let fixture = Fixture::new(); @@ -547,6 +553,7 @@ mod tests { assert_eq!(fixture.load().overlay_request(body.clone(), "x"), body); } + #[pa_test_scratch::pa_test] #[test] fn numeric_normalization_preserves_strings_and_rejects_malformed_numbers() { let fixture = Fixture::new(); @@ -578,6 +585,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn independent_loads_and_reload_do_not_retain_removed_caps() { let fixture = Fixture::new(); diff --git a/crates/pa-core/src/models/prime_inference.rs b/crates/pa-core/src/models/prime_inference.rs index 1539476c5..04b70c2dc 100644 --- a/crates/pa-core/src/models/prime_inference.rs +++ b/crates/pa-core/src/models/prime_inference.rs @@ -57,6 +57,7 @@ pub fn private_prime_inference_models() -> Vec { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn private_id_predicate() { assert!(is_private_prime_inference_model_id("internal/glm-5.2-fast")); @@ -80,6 +81,7 @@ mod tests { /// Differential: the provider base URL must equal the TS reference's /// `PRIME_INFERENCE_BASE_URL` - the URL the installed TS binary actually /// calls. Golden is read from the TS source, no network. + #[pa_test_scratch::pa_test] #[test] fn base_url_matches_ts_reference() { let Some(root) = ts_reference_root() else { @@ -102,6 +104,7 @@ mod tests { assert_eq!(PRIME_INFERENCE_BASE_URL, expected); } + #[pa_test_scratch::pa_test] #[test] fn generated_catalog_base_urls_match_const() { let models = pa_ai::models_generated::get_models("prime-inference"); diff --git a/crates/pa-core/src/models/registry/catalog_refresh_tests.rs b/crates/pa-core/src/models/registry/catalog_refresh_tests.rs index e0eaf0fcd..32d230936 100644 --- a/crates/pa-core/src/models/registry/catalog_refresh_tests.rs +++ b/crates/pa-core/src/models/registry/catalog_refresh_tests.rs @@ -151,6 +151,7 @@ fn selected(source: &str) -> Vec { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn source_filtered_refresh_uses_models_json_key_then_local_apply_needs_no_fetch() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("models.json"); @@ -214,6 +215,7 @@ async fn source_filtered_refresh_uses_models_json_key_then_local_apply_needs_no_ } #[tokio::test] +#[pa_test_scratch::pa_test] async fn ollama_forwards_custom_authorization_only_on_the_configured_origin() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("models.json"); @@ -265,6 +267,7 @@ async fn ollama_forwards_custom_authorization_only_on_the_configured_origin() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn ollama_cross_origin_override_never_sends_custom_authorization() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("models.json"); @@ -314,6 +317,7 @@ impl OAuthIntegration for OAuthProbe { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn local_apply_never_runs_command_keys_or_oauth_including_prime_credentials() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("models.json"); @@ -378,6 +382,7 @@ async fn local_apply_never_runs_command_keys_or_oauth_including_prime_credential } #[tokio::test] +#[pa_test_scratch::pa_test] async fn local_apply_does_not_replace_deferred_auth_with_models_json_fallback() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("models.json"); @@ -429,6 +434,7 @@ fn prime_auth() -> AuthStorage { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn private_prime_401_revokes_the_scoped_snapshot_for_fresh_registries() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("models.json"); @@ -488,6 +494,7 @@ async fn private_prime_401_revokes_the_scoped_snapshot_for_fresh_registries() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn timed_out_restore_keeps_late_publication_and_zero_budget_cached_fast_path() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("models.json"); @@ -599,6 +606,7 @@ async fn timed_out_restore_keeps_late_publication_and_zero_budget_cached_fast_pa } #[tokio::test] +#[pa_test_scratch::pa_test] async fn codex_refresh_adds_provider_models_and_local_apply_updates_the_picker_registry() { use base64::Engine as _; @@ -690,6 +698,7 @@ async fn codex_refresh_adds_provider_models_and_local_apply_updates_the_picker_r } #[tokio::test] +#[pa_test_scratch::pa_test] async fn explicit_discovery_auth_replaces_inference_auth_case_insensitively() { for discovery in [ json!({"format":"openai","apiKey":"catalog-key"}), @@ -724,6 +733,7 @@ async fn explicit_discovery_auth_replaces_inference_auth_case_insensitively() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn id_only_builtin_lists_do_not_admit_untrusted_chat_capabilities() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("models.json"); @@ -757,6 +767,7 @@ async fn id_only_builtin_lists_do_not_admit_untrusted_chat_capabilities() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn custom_discovery_admits_new_ids_only_with_explicit_complete_defaults() { for allow_new in [false, true] { let dir = tempfile::tempdir().unwrap(); @@ -795,6 +806,7 @@ async fn custom_discovery_admits_new_ids_only_with_explicit_complete_defaults() } } +#[pa_test_scratch::pa_test] #[test] fn inherited_team_environment_change_supersedes_publication() { struct EnvCleanup(String); @@ -824,6 +836,7 @@ fn inherited_team_environment_change_supersedes_publication() { ); } +#[pa_test_scratch::pa_test] #[test] fn picker_availability_never_executes_stored_commands_or_oauth_adapters() { let dir = tempfile::tempdir().unwrap(); @@ -865,6 +878,7 @@ fn picker_availability_never_executes_stored_commands_or_oauth_adapters() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn protocol_headers_do_not_authorize_unconfigured_provider_discovery() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("models.json"); @@ -921,6 +935,7 @@ fn write_fact_plugin(agent_dir: &Path, base: &str, context: u64) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_defaults_change_keeps_the_last_good_discovery_cache() { let dir = tempfile::tempdir().unwrap(); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-core/src/models/registry/provider_facts_tests.rs b/crates/pa-core/src/models/registry/provider_facts_tests.rs index a27861732..a698e91d6 100644 --- a/crates/pa-core/src/models/registry/provider_facts_tests.rs +++ b/crates/pa-core/src/models/registry/provider_facts_tests.rs @@ -32,6 +32,7 @@ return {providers = { }} "#; +#[pa_test_scratch::pa_test] #[test] fn a_plugin_fact_exposes_its_provider_and_models_without_a_session() { let dir = agent_dir(LOCAL_FACT); @@ -59,6 +60,7 @@ fn a_plugin_fact_exposes_its_provider_and_models_without_a_session() { assert_eq!(status.source, None); } +#[pa_test_scratch::pa_test] #[test] fn a_keyless_provider_resolves_set_model_and_sends_no_authorization() { let dir = agent_dir(LOCAL_FACT); @@ -102,6 +104,7 @@ fn remote_model(id: &str, context: u64, max_tokens: u64) -> Model { .unwrap() } +#[pa_test_scratch::pa_test] #[test] fn fact_limits_clamp_endpoint_metadata_and_mark_the_ceiling_explicit() { let dir = agent_dir(LOCAL_FACT); @@ -128,6 +131,7 @@ fn fact_limits_clamp_endpoint_metadata_and_mark_the_ceiling_explicit() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_fact_named_after_a_builtin_provider_is_rejected() { let dir = agent_dir( diff --git a/crates/pa-core/src/models/registry/tests.rs b/crates/pa-core/src/models/registry/tests.rs index 7d50ea674..529d5f489 100644 --- a/crates/pa-core/src/models/registry/tests.rs +++ b/crates/pa-core/src/models/registry/tests.rs @@ -27,6 +27,7 @@ fn model(id: &str, provider: &str) -> Model { .unwrap() } +#[pa_test_scratch::pa_test] #[test] fn in_memory_loads_built_in_catalog() { let registry = ModelRegistry::in_memory(auth_with(&serde_json::json!({}))); @@ -42,6 +43,7 @@ fn in_memory_loads_built_in_catalog() { /// unmarked when no override configures `maxTokens` — the default 32000 /// ceiling keeps applying to them (901 of the catalog's models declare /// more than 32000 and their request size must not change). +#[pa_test_scratch::pa_test] #[test] fn built_in_catalog_models_stay_unmarked() { let registry = ModelRegistry::in_memory(auth_with(&serde_json::json!({}))); @@ -52,6 +54,7 @@ fn built_in_catalog_models_stay_unmarked() { .all(|model| !model.max_tokens_explicit)); } +#[pa_test_scratch::pa_test] #[test] fn available_filters_by_configured_auth() { let auth = auth_with(&serde_json::json!({ @@ -71,6 +74,7 @@ fn available_filters_by_configured_auth() { })); } +#[pa_test_scratch::pa_test] #[test] fn rlm_searchable_models_gate_one_stale_provider_across_its_models() { // The per-provider status memo must answer every model of a provider @@ -96,6 +100,7 @@ fn rlm_searchable_models_gate_one_stale_provider_across_its_models() { .all(|model| model.provider != "zz-no-provider")); } +#[pa_test_scratch::pa_test] #[test] fn models_json_custom_models_and_auth_header() { let dir = tempfile::tempdir().unwrap(); @@ -129,6 +134,7 @@ fn models_json_custom_models_and_auth_header() { ); } +#[pa_test_scratch::pa_test] #[test] fn models_json_error_keeps_built_ins() { let dir = tempfile::tempdir().unwrap(); @@ -139,6 +145,7 @@ fn models_json_error_keeps_built_ins() { assert!(!registry.get_all().is_empty()); } +#[pa_test_scratch::pa_test] #[test] fn header_precedence_model_over_provider() { let mut registry = ModelRegistry::in_memory(auth_with(&serde_json::json!({ @@ -184,6 +191,7 @@ async fn serve_catalog_once(payload: serde_json::Value) -> (String, tokio::task: } #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::too_many_lines)] async fn live_scope_keyed_cache_merges_over_the_compiled_prime_inference_models() { let dir = tempfile::tempdir().unwrap(); @@ -305,6 +313,7 @@ async fn live_scope_keyed_cache_merges_over_the_compiled_prime_inference_models( .any(|model| model.id == "anthropic/live-only-model")); } +#[pa_test_scratch::pa_test] #[test] fn invalid_models_config_keeps_the_bundled_catalog() { let dir = tempfile::tempdir().unwrap(); @@ -318,6 +327,7 @@ fn invalid_models_config_keeps_the_bundled_catalog() { assert!(registry.get_error().is_some()); } +#[pa_test_scratch::pa_test] #[test] fn explicit_private_ids_are_authorized() { let registry = ModelRegistry::in_memory(auth_with(&serde_json::json!({}))); @@ -325,6 +335,7 @@ fn explicit_private_ids_are_authorized() { assert!(!registry.is_authorized_private_model(&private_model)); } +#[pa_test_scratch::pa_test] #[test] fn a_stored_copilot_credential_rewrites_its_models_base_url() { // TS `githubCopilotOAuthProvider.modifyModels`: the token's @@ -361,6 +372,7 @@ fn a_stored_copilot_credential_rewrites_its_models_base_url() { assert_eq!(grok.base_url, "https://copilot-api.company.ghe.com"); } +#[pa_test_scratch::pa_test] #[test] fn a_stored_xai_subscription_switches_its_models_onto_responses() { let auth = auth_without_env(&serde_json::json!({ @@ -410,6 +422,7 @@ fn a_stored_xai_subscription_switches_its_models_onto_responses() { /// A model that already declares addressable levels keeps them under the /// subscription — a blanket replacement collapsed a thinking-capable route /// onto the all-null default arm (the `/effort` false refusal). +#[pa_test_scratch::pa_test] #[test] fn a_subscription_model_keeps_its_own_thinking_level_map() { let mut grok = model("grok-build-0.1", "xai"); @@ -428,6 +441,7 @@ fn a_subscription_model_keeps_its_own_thinking_level_map() { ); } +#[pa_test_scratch::pa_test] #[test] fn without_a_stored_xai_subscription_the_models_stay_on_completions() { let registry = ModelRegistry::in_memory(auth_without_env(&serde_json::json!({}))); diff --git a/crates/pa-core/src/models/resolver.rs b/crates/pa-core/src/models/resolver.rs index 14f704633..9036a077e 100644 --- a/crates/pa-core/src/models/resolver.rs +++ b/crates/pa-core/src/models/resolver.rs @@ -654,6 +654,7 @@ mod tests { ] } + #[pa_test_scratch::pa_test] #[test] fn failover_candidates_order_by_catalog_after_current() { let mut catalog = catalog(); @@ -688,6 +689,7 @@ mod tests { assert!(candidates.iter().all(|model| model.provider != "zai")); } + #[pa_test_scratch::pa_test] #[test] fn exact_and_fuzzy_matching() { let catalog = catalog(); @@ -702,6 +704,7 @@ mod tests { assert_eq!(fuzzy.map(|m| m.id.as_str()), Some("claude-sonnet-4-5")); } + #[pa_test_scratch::pa_test] #[test] fn scoped_colon_tags_do_not_collapse_to_exact_prefixes() { let mut models = catalog(); @@ -739,6 +742,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn scoped_patterns_and_thinking_levels() { let catalog = catalog(); @@ -750,6 +754,7 @@ mod tests { assert_eq!(scoped[1].thinking_level, Some(ThinkingLevel::High)); } + #[pa_test_scratch::pa_test] #[test] fn cli_provider_model_resolution() { let catalog = catalog(); @@ -778,6 +783,7 @@ mod tests { assert!(missing.warning.unwrap().contains("Using custom model id")); } + #[pa_test_scratch::pa_test] #[test] fn openrouter_slash_ids_resolve_without_provider_inference() { let catalog = catalog(); @@ -789,6 +795,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn fallback_model_prefers_private_template_for_private_ids() { let mut catalog = catalog(); @@ -807,6 +814,7 @@ mod tests { /// TS regression (#2459): Prime Inference rejects `enable_thinking` /// with a 400, so a fallback model — public or private — must never /// inherit the zai thinking format from its template. + #[pa_test_scratch::pa_test] #[test] fn fallback_models_never_inherit_the_zai_thinking_format() { use pa_ai::types::ModelExt; @@ -832,6 +840,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn initial_model_prefers_cli_flags() { let catalog = catalog(); @@ -850,6 +859,7 @@ mod tests { assert_eq!(model.id, "claude-sonnet-4-5"); } + #[pa_test_scratch::pa_test] #[test] fn initial_model_saved_default_wins_over_featured_default() { let catalog = catalog(); @@ -868,6 +878,7 @@ mod tests { assert_eq!(model.id, "claude-sonnet-4-5"); } + #[pa_test_scratch::pa_test] #[test] fn initial_model_rebuilds_missing_saved_id_on_template() { let catalog = catalog(); @@ -886,6 +897,7 @@ mod tests { assert_eq!(model.id, "claude-future-model"); } + #[pa_test_scratch::pa_test] #[test] fn initial_model_falls_back_to_featured_then_first_available() { let catalog = catalog(); @@ -921,6 +933,7 @@ mod tests { assert_eq!(find_initial_model(&empty), None); } + #[pa_test_scratch::pa_test] #[test] fn initial_model_scope_prefers_saved_default_in_scope() { let catalog = catalog(); @@ -949,6 +962,7 @@ mod tests { assert_eq!(model.provider, "prime-inference"); assert_eq!(model.id, "z-ai/glm-5.3"); } + #[pa_test_scratch::pa_test] #[test] fn ollama_cloud_default_matches_pinned_fallback() { assert_eq!(default_model_per_provider("ollama-cloud"), Some("glm-5.3")); diff --git a/crates/pa-core/src/models/session_restore.rs b/crates/pa-core/src/models/session_restore.rs index 7179f0cb3..8431ca141 100644 --- a/crates/pa-core/src/models/session_restore.rs +++ b/crates/pa-core/src/models/session_restore.rs @@ -57,6 +57,7 @@ mod tests { use super::*; #[tokio::test] + #[pa_test_scratch::pa_test] async fn environment_only_auth_restores_a_known_model_without_waiting() { struct Environment; impl crate::auth::manager::EnvCredentialSource for Environment { @@ -101,6 +102,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn restore_requires_a_registered_model_with_configured_auth() { let auth = crate::auth::AuthStorage::in_memory_without_env( &crate::auth::AuthStorageData::default(), diff --git a/crates/pa-core/src/packages/manager.rs b/crates/pa-core/src/packages/manager.rs index e9806a4f8..0666b0bf0 100644 --- a/crates/pa-core/src/packages/manager.rs +++ b/crates/pa-core/src/packages/manager.rs @@ -658,6 +658,7 @@ mod tests { pkg } + #[pa_test_scratch::pa_test] #[test] fn install_and_remove_local_round_trip() { let (dir, mut manager) = setup(); @@ -702,6 +703,7 @@ mod tests { .unwrap()); } + #[pa_test_scratch::pa_test] #[test] fn installing_missing_local_path_fails() { let (dir, mut manager) = setup(); @@ -718,6 +720,7 @@ mod tests { assert!(manager.list_configured_packages().is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn duplicate_installs_are_settings_noops() { let (dir, mut manager) = setup(); @@ -732,6 +735,7 @@ mod tests { assert_eq!(settings["packages"].as_array().unwrap().len(), 1); } + #[pa_test_scratch::pa_test] #[test] fn project_scope_persists_against_project_settings_base() { let (dir, mut manager) = setup(); @@ -761,6 +765,7 @@ mod tests { assert_eq!(configured[0].scope, UserOrProject::Project); } + #[pa_test_scratch::pa_test] #[test] fn equivalent_local_path_forms_remove_by_identity() { let (dir, mut manager) = setup(); @@ -773,6 +778,7 @@ mod tests { .unwrap()); } + #[pa_test_scratch::pa_test] #[test] fn filtered_entries_list_and_remove_by_source() { let (dir, mut manager) = setup(); @@ -798,6 +804,7 @@ mod tests { assert!(manager.list_configured_packages().is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn progress_events_report_start_and_error() { let (_dir, mut manager) = setup(); diff --git a/crates/pa-core/src/packages/npm.rs b/crates/pa-core/src/packages/npm.rs index d6400e2ac..1c25210cb 100644 --- a/crates/pa-core/src/packages/npm.rs +++ b/crates/pa-core/src/packages/npm.rs @@ -159,6 +159,7 @@ pub fn ensure_gitignore(dir: &Path) -> Result<()> { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn npm_command_defaults_and_configuration() { assert_eq!(npm_command(None), ("npm".to_string(), Vec::::new())); @@ -172,6 +173,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn git_dependency_args_follow_npm_command_configuration() { assert_eq!( @@ -184,6 +186,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn install_paths_per_scope() { let cwd = Path::new("/work"); @@ -207,6 +210,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn reads_installed_version() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/packages/process.rs b/crates/pa-core/src/packages/process.rs index 05bf3524f..cb66c58f8 100644 --- a/crates/pa-core/src/packages/process.rs +++ b/crates/pa-core/src/packages/process.rs @@ -123,6 +123,7 @@ fn signal_name(status: std::process::ExitStatus) -> String { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn capture_trims_stdout_and_reports_failures() { let out = run_command_capture("echo", &["-n", " hi "], None, None, &[]).unwrap(); @@ -135,6 +136,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn capture_times_out() { let error = diff --git a/crates/pa-core/src/packages/resolve/tests.rs b/crates/pa-core/src/packages/resolve/tests.rs index 4fe4c5869..07ac03cf8 100644 --- a/crates/pa-core/src/packages/resolve/tests.rs +++ b/crates/pa-core/src/packages/resolve/tests.rs @@ -126,6 +126,7 @@ fn has_path(resources: &[ResolvedResource], suffix: &str) -> bool { .any(|r| r.path.to_string_lossy().ends_with(suffix)) } +#[pa_test_scratch::pa_test] #[test] fn resolve_without_configured_sources_returns_only_auto_resources() { let mut fixture = Fixture::new(); @@ -137,6 +138,7 @@ fn resolve_without_configured_sources_returns_only_auto_resources() { })); } +#[pa_test_scratch::pa_test] #[test] fn resolve_skill_paths_from_settings() { let mut fixture = Fixture::new(); @@ -154,6 +156,7 @@ fn resolve_skill_paths_from_settings() { .any(|r| r.path == skill_file && r.enabled)); } +#[pa_test_scratch::pa_test] #[test] fn auto_discovers_root_markdown_skills() { let mut fixture = Fixture::new(); @@ -170,6 +173,7 @@ fn auto_discovers_root_markdown_skills() { .any(|r| r.path == skill_file && r.enabled)); } +#[pa_test_scratch::pa_test] #[test] fn resolves_project_paths_relative_to_project_config_dir() { let mut fixture = Fixture::new(); @@ -185,6 +189,7 @@ fn resolves_project_paths_relative_to_project_config_dir() { .any(|r| r.path == prompt_path && r.enabled)); } +#[pa_test_scratch::pa_test] #[test] fn auto_discovers_user_prompts_with_overrides() { let mut fixture = Fixture::new(); @@ -199,6 +204,7 @@ fn auto_discovers_user_prompts_with_overrides() { .any(|r| r.path == prompt_path && !r.enabled)); } +#[pa_test_scratch::pa_test] #[test] fn auto_discovers_project_prompts_with_overrides() { let mut fixture = Fixture::new(); @@ -217,6 +223,7 @@ fn auto_discovers_project_prompts_with_overrides() { /// Unix symlink layout; Windows needs `symlink_dir` and a privileged /// developer mode to create links, so the case runs on Unix only. #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn resolves_symlinked_user_and_project_resources_once() { use std::os::unix::fs::symlink; @@ -256,6 +263,7 @@ fn resolves_symlinked_user_and_project_resources_once() { } } +#[pa_test_scratch::pa_test] #[test] fn agents_skills_scan_stops_at_git_repo_root() { let fixture = Fixture::new(); @@ -290,6 +298,7 @@ fn agents_skills_scan_stops_at_git_repo_root() { assert!(!result.skills.iter().any(|r| r.path == above_repo)); } +#[pa_test_scratch::pa_test] #[test] fn agents_skills_scan_goes_to_fs_root_without_a_repo() { let fixture = Fixture::new(); @@ -320,6 +329,7 @@ fn agents_skills_scan_goes_to_fs_root_without_a_repo() { .any(|r| r.path == middle_skill && r.enabled)); } +#[pa_test_scratch::pa_test] #[test] fn agents_skills_ignores_root_markdown_files() { let mut fixture = Fixture::new(); @@ -336,6 +346,7 @@ fn agents_skills_ignores_root_markdown_files() { assert!(result.skills.iter().any(|r| r.path == nested && r.enabled)); } +#[pa_test_scratch::pa_test] #[test] fn home_agents_skills_stays_user_scoped_when_cwd_is_under_home() { let _guard = ENV_MUTEX.lock().unwrap(); @@ -375,6 +386,7 @@ fn home_agents_skills_stays_user_scoped_when_cwd_is_under_home() { /// Unix symlink layout (see `resolves_symlinked_user_and_project_resources_once`). #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn user_skill_entries_dedupe_when_agent_skills_symlinks_agents_skills() { use std::os::unix::fs::symlink; @@ -402,6 +414,7 @@ fn user_skill_entries_dedupe_when_agent_skills_symlinks_agents_skills() { } } +#[pa_test_scratch::pa_test] #[test] fn skill_directories_respect_gitignore() { let mut fixture = Fixture::new(); @@ -418,6 +431,7 @@ fn skill_directories_respect_gitignore() { assert!(!result.skills.iter().any(|r| r.path == bad && r.enabled)); } +#[pa_test_scratch::pa_test] #[test] fn parent_gitignore_does_not_apply_to_auto_discovery() { let mut fixture = Fixture::new(); @@ -433,6 +447,7 @@ fn parent_gitignore_does_not_apply_to_auto_discovery() { .any(|r| r.path == skill_path && r.enabled)); } +#[pa_test_scratch::pa_test] #[test] fn top_level_filters_themes_with_glob_patterns() { let mut fixture = Fixture::new(); @@ -448,6 +463,7 @@ fn top_level_filters_themes_with_glob_patterns() { assert!(is_disabled(&result.themes, "funky.json")); } +#[pa_test_scratch::pa_test] #[test] fn top_level_filters_prompts_with_exclusion_pattern() { let mut fixture = Fixture::new(); @@ -461,6 +477,7 @@ fn top_level_filters_prompts_with_exclusion_pattern() { assert!(is_disabled(&result.prompts, "explain.md")); } +#[pa_test_scratch::pa_test] #[test] fn top_level_filters_skills_with_exclusion_pattern() { let mut fixture = Fixture::new(); @@ -480,6 +497,7 @@ fn top_level_filters_skills_with_exclusion_pattern() { .any(|r| r.path.to_string_lossy().contains("bad-skill") && !r.enabled)); } +#[pa_test_scratch::pa_test] #[test] fn manifest_supports_glob_patterns_for_skills() { let mut fixture = Fixture::new(); @@ -503,6 +521,7 @@ fn manifest_supports_glob_patterns_for_skills() { .any(|r| r.path.to_string_lossy().contains("bad-skill"))); } +#[pa_test_scratch::pa_test] #[test] fn manifest_expands_positive_glob_entries_before_collecting_skills() { let mut fixture = Fixture::new(); @@ -538,6 +557,7 @@ fn manifest_expands_positive_glob_entries_before_collecting_skills() { && r.enabled)); } +#[pa_test_scratch::pa_test] #[test] fn user_filters_layer_on_top_of_manifest_filters() { let mut fixture = Fixture::new(); @@ -562,6 +582,7 @@ fn user_filters_layer_on_top_of_manifest_filters() { assert!(!has_path(&result.prompts, "baz.md")); } +#[pa_test_scratch::pa_test] #[test] fn package_filters_filter_themes() { let mut fixture = Fixture::new(); @@ -580,6 +601,7 @@ fn package_filters_filter_themes() { assert!(is_disabled(&result.themes, "ugly.json")); } +#[pa_test_scratch::pa_test] #[test] fn package_filters_combine_include_and_exclude_patterns() { let mut fixture = Fixture::new(); @@ -600,6 +622,7 @@ fn package_filters_combine_include_and_exclude_patterns() { assert!(is_disabled(&result.prompts, "gamma.md")); } +#[pa_test_scratch::pa_test] #[test] fn package_filters_work_with_direct_paths() { let mut fixture = Fixture::new(); @@ -618,6 +641,7 @@ fn package_filters_work_with_direct_paths() { assert!(is_disabled(&result.prompts, "two.md")); } +#[pa_test_scratch::pa_test] #[test] fn force_include_overrides_exclude_in_package_filters() { let mut fixture = Fixture::new(); @@ -638,6 +662,7 @@ fn force_include_overrides_exclude_in_package_filters() { assert!(is_disabled(&result.prompts, "gamma.md")); } +#[pa_test_scratch::pa_test] #[test] fn force_include_multiple_resources() { let mut fixture = Fixture::new(); @@ -667,6 +692,7 @@ fn force_include_multiple_resources() { .any(|r| r.path.to_string_lossy().contains("skill-c") && r.enabled)); } +#[pa_test_scratch::pa_test] #[test] fn force_include_after_specific_exclusion() { let mut fixture = Fixture::new(); @@ -683,6 +709,7 @@ fn force_include_after_specific_exclusion() { assert!(is_enabled(&result.prompts, "b.md")); } +#[pa_test_scratch::pa_test] #[test] fn force_include_in_manifest_patterns() { let mut fixture = Fixture::new(); @@ -702,6 +729,7 @@ fn force_include_in_manifest_patterns() { assert!(is_enabled(&result.prompts, "three.md")); } +#[pa_test_scratch::pa_test] #[test] fn force_include_themes() { let mut fixture = Fixture::new(); @@ -720,6 +748,7 @@ fn force_include_themes() { assert!(is_enabled(&result.themes, "special.json")); } +#[pa_test_scratch::pa_test] #[test] fn force_include_prompts() { let mut fixture = Fixture::new(); @@ -738,6 +767,7 @@ fn force_include_prompts() { assert!(is_enabled(&result.prompts, "debug.md")); } +#[pa_test_scratch::pa_test] #[test] fn force_exclude_top_level_resources() { let mut fixture = Fixture::new(); @@ -754,6 +784,7 @@ fn force_exclude_top_level_resources() { assert!(is_enabled(&result.themes, "beta.json")); } +#[pa_test_scratch::pa_test] #[test] fn force_exclude_in_package_filters() { let mut fixture = Fixture::new(); @@ -772,6 +803,7 @@ fn force_exclude_in_package_filters() { assert!(is_enabled(&result.prompts, "beta.md")); } +#[pa_test_scratch::pa_test] #[test] fn same_local_package_in_both_scopes_resolves_once_with_project_scope() { let mut fixture = Fixture::new(); @@ -798,6 +830,7 @@ fn same_local_package_in_both_scopes_resolves_once_with_project_scope() { assert_eq!(shared[0].metadata.scope, SourceScope::Project); } +#[pa_test_scratch::pa_test] #[test] fn different_packages_in_both_scopes_both_resolve() { let mut fixture = Fixture::new(); @@ -827,6 +860,7 @@ fn different_packages_in_both_scopes_both_resolve() { .any(|r| r.path.to_string_lossy().contains("pkg2"))); } +#[pa_test_scratch::pa_test] #[test] fn offline_mode_skips_installing_missing_sources() { const CHILD: &str = "PA_PACKAGES_OFFLINE_FIXTURE_CHILD"; @@ -874,6 +908,7 @@ fn offline_mode_skips_installing_missing_sources() { .any(|r| r.metadata.origin == ResourceOrigin::Package)); } +#[pa_test_scratch::pa_test] #[test] fn on_missing_error_fails_resolution() { let _guard = ENV_MUTEX.lock().unwrap(); @@ -890,6 +925,7 @@ fn on_missing_error_fails_resolution() { assert_eq!(error.to_string(), "Missing source: npm:missing-package"); } +#[pa_test_scratch::pa_test] #[test] fn on_missing_skip_leaves_the_source_out() { let _guard = ENV_MUTEX.lock().unwrap(); @@ -908,6 +944,7 @@ fn on_missing_skip_leaves_the_source_out() { .all(|r| r.metadata.origin != ResourceOrigin::Package)); } +#[pa_test_scratch::pa_test] #[test] fn bundled_skills_collect_with_websearch_excluded_until_enabled() { let fixture = Fixture::new(); @@ -955,6 +992,7 @@ fn bundled_skills_collect_with_websearch_excluded_until_enabled() { assert!(!websearch.enabled, "websearch excluded until enabled"); } +#[pa_test_scratch::pa_test] #[test] fn empty_bundled_skills_dir_warns() { let fixture = Fixture::new(); @@ -977,6 +1015,7 @@ fn empty_bundled_skills_dir_warns() { })); } +#[pa_test_scratch::pa_test] #[test] fn disabled_builtin_skills_are_not_collected() { let fixture = Fixture::new(); diff --git a/crates/pa-core/src/packages/resource_config.rs b/crates/pa-core/src/packages/resource_config.rs index 2f4975394..02997011a 100644 --- a/crates/pa-core/src/packages/resource_config.rs +++ b/crates/pa-core/src/packages/resource_config.rs @@ -445,6 +445,7 @@ mod tests { paths } + #[pa_test_scratch::pa_test] #[test] fn groups_follow_ts_ordering_and_labels() { let paths = resolved(vec![ @@ -522,6 +523,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn prompt_display_names_show_the_file_name() { let item = resource( @@ -568,6 +570,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn toggling_a_user_skill_writes_the_disable_then_enable_pattern() { let (root, mut settings) = settings_fixture(); @@ -588,6 +591,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn toggling_a_bundled_skill_keys_off_the_bundled_dir() { let (root, mut settings) = settings_fixture(); @@ -601,6 +605,7 @@ mod tests { assert_eq!(written, "-websearch/SKILL.md"); } + #[pa_test_scratch::pa_test] #[test] fn toggling_a_project_resource_writes_the_project_scope() { let (root, mut settings) = settings_fixture(); @@ -621,6 +626,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn toggling_a_package_resource_writes_a_filter_entry() { let (root, mut settings) = settings_fixture(); @@ -652,6 +658,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn relative_paths_match_ts_semantics() { assert_eq!( diff --git a/crates/pa-core/src/packages/source.rs b/crates/pa-core/src/packages/source.rs index ddedbdc4f..6007d2d34 100644 --- a/crates/pa-core/src/packages/source.rs +++ b/crates/pa-core/src/packages/source.rs @@ -428,6 +428,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn parses_documented_source_forms() { assert_eq!(kind("npm:@scope/pkg@1.2.3"), "npm"); @@ -441,6 +442,7 @@ mod tests { assert_eq!(kind("../relative/path"), "local"); } + #[pa_test_scratch::pa_test] #[test] fn never_parses_dot_relative_paths_as_git() { let ParsedSource::Local(local) = parse_source("./packages/agent-timers") else { @@ -453,6 +455,7 @@ mod tests { assert_eq!(local.path, "../packages/agent-timers"); } + #[pa_test_scratch::pa_test] #[test] fn parses_https_github_urls() { let ParsedSource::Git(git) = parse_source("https://github.com/user/repo") else { @@ -464,6 +467,7 @@ mod tests { assert!(!git.pinned); } + #[pa_test_scratch::pa_test] #[test] fn parses_https_urls_with_git_prefix() { let ParsedSource::Git(git) = parse_source("git:https://github.com/user/repo") else { @@ -473,6 +477,7 @@ mod tests { assert_eq!(git.path, "user/repo"); } + #[pa_test_scratch::pa_test] #[test] fn parses_https_urls_with_ref() { let ParsedSource::Git(git) = parse_source("https://github.com/user/repo@v1.2.3") else { @@ -489,6 +494,7 @@ mod tests { assert_eq!(git.r#ref.as_deref(), Some("feature/branch")); } + #[pa_test_scratch::pa_test] #[test] fn parses_host_path_shorthand_only_with_git_prefix() { let ParsedSource::Git(git) = parse_source("git:github.com/user/repo") else { @@ -501,6 +507,7 @@ mod tests { assert_eq!(kind("github.com/user/repo"), "local"); } + #[pa_test_scratch::pa_test] #[test] fn parses_https_urls_with_git_suffix() { let ParsedSource::Git(git) = parse_source("https://github.com/user/repo.git") else { @@ -509,6 +516,7 @@ mod tests { assert_eq!(git.path, "user/repo"); } + #[pa_test_scratch::pa_test] #[test] fn parses_other_hosted_domains() { for url in [ @@ -523,6 +531,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn keeps_scp_clone_urls_for_scp_like_sources() { let ParsedSource::Git(git) = parse_source("git:git@github.com:user/repo") else { @@ -533,6 +542,7 @@ mod tests { assert_eq!(git.path, "user/repo"); } + #[pa_test_scratch::pa_test] #[test] fn parses_ssh_protocol_urls() { let ParsedSource::Git(git) = parse_source("git:ssh://git@github.com/user/repo") else { @@ -543,6 +553,7 @@ mod tests { assert_eq!(git.path, "user/repo"); } + #[pa_test_scratch::pa_test] #[test] fn treats_protocol_git_urls_with_git_prefix_as_local() { // The `git:` prefix is stripped before parsing, so `git://host/path` @@ -550,6 +561,7 @@ mod tests { assert_eq!(kind("git://localhost/fixtures/repo.git"), "local"); } + #[pa_test_scratch::pa_test] #[test] fn parses_npm_specs() { let (name, version) = parse_npm_spec("@scope/pkg@1.2.3"); @@ -563,6 +575,7 @@ mod tests { assert_eq!(version, None); } + #[pa_test_scratch::pa_test] #[test] fn resolves_paths_lexically() { let base = Path::new("/work/project"); diff --git a/crates/pa-core/src/packages/tests.rs b/crates/pa-core/src/packages/tests.rs index cbf21147b..fc3c3bca0 100644 --- a/crates/pa-core/src/packages/tests.rs +++ b/crates/pa-core/src/packages/tests.rs @@ -157,6 +157,7 @@ impl Sandbox { } } +#[pa_test_scratch::pa_test] #[test] fn npm_install_list_remove_flow() { let _guard = super::test_support::ENV_MUTEX.lock().unwrap(); @@ -187,6 +188,7 @@ fn npm_install_list_remove_flow() { assert!(log.contains("npm uninstall -g fake-pkg\n"), "{log}"); } +#[pa_test_scratch::pa_test] #[test] fn npm_update_skips_matching_versions() { let _guard = super::test_support::ENV_MUTEX.lock().unwrap(); @@ -204,6 +206,7 @@ fn npm_update_skips_matching_versions() { assert!(!log.contains("npm install -g fake-pkg@latest"), "{log}"); } +#[pa_test_scratch::pa_test] #[test] fn npm_update_reinstalls_moved_versions() { let _guard = super::test_support::ENV_MUTEX.lock().unwrap(); @@ -226,6 +229,7 @@ fn npm_update_reinstalls_moved_versions() { ); } +#[pa_test_scratch::pa_test] #[test] fn update_unknown_source_is_an_error_with_suggestion() { let _guard = super::test_support::ENV_MUTEX.lock().unwrap(); @@ -241,6 +245,7 @@ fn update_unknown_source_is_an_error_with_suggestion() { ); } +#[pa_test_scratch::pa_test] #[test] fn git_clone_update_remove_flow() { let _guard = super::test_support::ENV_MUTEX.lock().unwrap(); @@ -302,6 +307,7 @@ fn git_clone_update_remove_flow() { assert!(sandbox.agent_dir.join("git").join(".gitignore").exists()); } +#[pa_test_scratch::pa_test] #[test] fn git_ref_checkout_installs_the_pinned_revision() { let _guard = super::test_support::ENV_MUTEX.lock().unwrap(); @@ -344,6 +350,7 @@ fn git_ref_checkout_installs_the_pinned_revision() { /// Homebrew formula's `bin` link): the shipped payload sits beside the /// real file, and a plain path stays untouched. #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn exe_dir_of_resolves_a_launcher_symlink() { let root = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/platform/browser.rs b/crates/pa-core/src/platform/browser.rs index 7d9e89a9d..fd42a2591 100644 --- a/crates/pa-core/src/platform/browser.rs +++ b/crates/pa-core/src/platform/browser.rs @@ -45,6 +45,7 @@ pub fn open_in_browser(url: &str) { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn opener_selection() { let (program, args) = opener("https://example.com/login"); @@ -54,6 +55,7 @@ mod tests { } #[cfg(windows)] + #[pa_test_scratch::pa_test] #[test] fn browser_launch_uses_system32_program_and_dll_entrypoint_arguments() { let url = "https://example.com/login?state=a%20b&code=c"; diff --git a/crates/pa-core/src/platform/lock_dir.rs b/crates/pa-core/src/platform/lock_dir.rs index 972272a1c..d6069d43a 100644 --- a/crates/pa-core/src/platform/lock_dir.rs +++ b/crates/pa-core/src/platform/lock_dir.rs @@ -529,6 +529,7 @@ mod tests { LockDir::path_for(file) } + #[pa_test_scratch::pa_test] #[test] fn lock_is_an_empty_directory_and_cleans_up() { let dir = tempfile::tempdir().unwrap(); @@ -544,6 +545,7 @@ mod tests { assert!(!lock_of(&file).exists(), "release removes the directory"); } + #[pa_test_scratch::pa_test] #[test] fn mtime_matches_the_proper_lockfile_probe_shape() { let dir = tempfile::tempdir().unwrap(); @@ -567,6 +569,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn second_acquire_reports_contention() { let dir = tempfile::tempdir().unwrap(); @@ -577,6 +580,7 @@ mod tests { assert_eq!(error.kind(), std::io::ErrorKind::WouldBlock); } + #[pa_test_scratch::pa_test] #[test] fn stale_lock_is_taken_over() { let dir = tempfile::tempdir().unwrap(); @@ -594,6 +598,7 @@ mod tests { } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn live_owned_lock_cannot_be_stolen_after_stale_age() { let dir = tempfile::tempdir().unwrap(); @@ -608,6 +613,7 @@ mod tests { } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn dead_owned_lock_is_reclaimed_and_old_guard_cannot_remove_successor() { let dir = tempfile::tempdir().unwrap(); @@ -629,6 +635,7 @@ mod tests { } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn unparseable_owned_lock_is_reclaimed_by_age() { let dir = tempfile::tempdir().unwrap(); @@ -642,6 +649,7 @@ mod tests { next.ensure_owned().unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn legacy_lock_file_is_removed_not_choked_on() { // A pre-compat Rust build left flock FILES at the lock path (the TS diff --git a/crates/pa-core/src/platform/perms.rs b/crates/pa-core/src/platform/perms.rs index f4e34c16c..38f2d4a8b 100644 --- a/crates/pa-core/src/platform/perms.rs +++ b/crates/pa-core/src/platform/perms.rs @@ -205,6 +205,7 @@ pub fn create_dir_all_private(path: &Path) -> std::io::Result<()> { mod windows_tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn restriction_is_a_no_op_and_probes_match_open_semantics() { let dir = std::env::temp_dir().join(format!("pa-perms-{}", std::process::id())); diff --git a/crates/pa-core/src/platform/process.rs b/crates/pa-core/src/platform/process.rs index f9d7e3241..a892a6106 100644 --- a/crates/pa-core/src/platform/process.rs +++ b/crates/pa-core/src/platform/process.rs @@ -566,6 +566,7 @@ mod win32 { mod windows_tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn pid_exists_for_self_but_not_zero() { assert!(pid_exists(std::process::id())); @@ -573,6 +574,7 @@ mod windows_tests { assert!(!pid_exists(u32::MAX)); } + #[pa_test_scratch::pa_test] #[test] fn out_of_range_pids_never_prove_kills() { assert!(!kill_pid(-1, Signal::Kill)); @@ -590,6 +592,7 @@ mod exit_wait_tests { use super::*; #[tokio::test] + #[pa_test_scratch::pa_test] async fn wait_for_exit_resolves_at_once_for_a_reaped_pid() { let mut child = std::process::Command::new("sleep") .arg("600") diff --git a/crates/pa-core/src/platform/rename.rs b/crates/pa-core/src/platform/rename.rs index 9d5da3e4b..7680951c3 100644 --- a/crates/pa-core/src/platform/rename.rs +++ b/crates/pa-core/src/platform/rename.rs @@ -87,6 +87,7 @@ pub fn rename_onto(from: &Path, to: &Path) -> io::Result<()> { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn win32_retries_busy_failures_with_linear_backoff_until_cap() { for failure in [RenameFailure::AccessDenied, RenameFailure::Busy] { @@ -110,6 +111,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn unix_and_fatal_failures_never_retry() { for failure in [ @@ -130,6 +132,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn rename_onto_replaces_destination() { let dir = tempfile::tempdir().unwrap(); @@ -142,6 +145,7 @@ mod tests { assert!(!from.exists()); } + #[pa_test_scratch::pa_test] #[test] fn rename_onto_missing_source_surfaces_the_error() { let dir = tempfile::tempdir().unwrap(); @@ -151,6 +155,7 @@ mod tests { assert_eq!(error.kind(), std::io::ErrorKind::NotFound); } + #[pa_test_scratch::pa_test] #[test] fn classification_marks_only_the_win32_busy_family_transient() { use io::ErrorKind; @@ -181,6 +186,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] #[cfg(unix)] fn unix_surfaces_real_permission_failures() { @@ -253,6 +259,7 @@ mod durable_tests { dir } + #[pa_test_scratch::pa_test] #[test] fn durable_rename_replaces_the_destination_and_keeps_its_bytes() { let dir = scratch("replace"); @@ -269,6 +276,7 @@ mod durable_tests { fs::remove_dir_all(&dir).ok(); } + #[pa_test_scratch::pa_test] #[test] fn durable_rename_creates_a_new_name_without_a_prior_destination() { let dir = scratch("create"); @@ -283,11 +291,13 @@ mod durable_tests { /// A bare relative name syncs the current directory: that IS its containing /// directory, so the proof is real rather than silently skipped. This matches /// the append path's normalisation, so the two durability helpers agree. + #[pa_test_scratch::pa_test] #[test] fn bare_relative_name_syncs_the_current_directory() { sync_parent_directory(Path::new("bare-name.jsonl")).expect("current directory sync"); } + #[pa_test_scratch::pa_test] #[test] fn a_missing_parent_directory_surfaces_the_open_error() { let dir = scratch("missing-parent"); diff --git a/crates/pa-core/src/platform/shell.rs b/crates/pa-core/src/platform/shell.rs index 258ebc211..7c8b0dbc1 100644 --- a/crates/pa-core/src/platform/shell.rs +++ b/crates/pa-core/src/platform/shell.rs @@ -254,6 +254,7 @@ pub fn resolve_kernel_bash_shell(custom: Option<&str>) -> anyhow::Result); impl HostCapabilities for Observe { @@ -640,6 +650,7 @@ async fn stream_backpressure_then_ordered_delivery_crosses_the_same_host_interfa } #[tokio::test] +#[pa_test_scratch::pa_test] async fn buffered_terminal_result_is_fenced_after_observable_producer_completion() { use std::{ future::Future, @@ -691,6 +702,7 @@ async fn buffered_terminal_result_is_fenced_after_observable_producer_completion } #[tokio::test] +#[pa_test_scratch::pa_test] async fn already_buffered_update_is_fenced_on_disable_and_cancellation() { for action in ["disable", "cancel"] { let (started_tx, mut started) = mpsc::unbounded_channel(); @@ -731,6 +743,7 @@ async fn already_buffered_update_is_fenced_on_disable_and_cancellation() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn typed_context_callbacks_require_unary_and_existing_plugin_name_grammar() { let host = host(); let context = @@ -763,6 +776,7 @@ async fn typed_context_callbacks_require_unary_and_existing_plugin_name_grammar( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn provider_declarations_stream_and_reject_duplicate_ids_atomically() { let host = host(); let provider = "return {providers={{name='custom-provider',run=function(input,ctx) ctx.emit(input); return {done=true} end}}}"; @@ -805,6 +819,7 @@ async fn provider_declarations_stream_and_reject_duplicate_ids_atomically() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn candidate_policy_validation_preserves_previous_generation_and_live_state() { let host = host(); let original = host.reconcile(vec![source("counter", COUNTER)]).unwrap(); @@ -841,6 +856,7 @@ async fn candidate_policy_validation_preserves_previous_generation_and_live_stat } #[tokio::test] +#[pa_test_scratch::pa_test] async fn capability_requests_bind_each_callback_to_a_distinct_invocation() { struct Capture(mpsc::UnboundedSender); impl HostCapabilities for Capture { @@ -883,6 +899,7 @@ async fn capability_requests_bind_each_callback_to_a_distinct_invocation() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn context_data_declarations_are_explicit_and_do_not_rewrite_invocation_values() { let host = host(); let source = source( @@ -955,6 +972,7 @@ async fn context_data_declarations_are_explicit_and_do_not_rewrite_invocation_va } #[tokio::test] +#[pa_test_scratch::pa_test] async fn runaway_declaration_hits_the_initialization_deadline() { let host = host(); assert!(matches!( @@ -965,6 +983,7 @@ async fn runaway_declaration_hits_the_initialization_deadline() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reload_cannot_publish_a_result_from_the_retired_generation() { struct Reload { host: std::sync::Mutex>, @@ -1031,6 +1050,7 @@ async fn reload_cannot_publish_a_result_from_the_retired_generation() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn invalid_context_data_modes_or_kinds_leave_the_previous_activation_intact() { let host = host(); let original = host.reconcile(vec![source("counter", COUNTER)]).unwrap(); diff --git a/crates/pa-core/src/prompts/model_prompts.rs b/crates/pa-core/src/prompts/model_prompts.rs index bda6f7952..15bc48bff 100644 --- a/crates/pa-core/src/prompts/model_prompts.rs +++ b/crates/pa-core/src/prompts/model_prompts.rs @@ -288,6 +288,7 @@ mod tests { dir } + #[pa_test_scratch::pa_test] #[test] fn documented_selector_examples_match() { let cases = [ @@ -346,6 +347,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn every_matching_rule_applies_and_shared_files_dedupe_first() { let dir = user_layer( @@ -371,6 +373,7 @@ files = ["a.md"] assert_eq!(resolution.extras.as_deref(), Some("A\n\nB\n\nC")); } + #[pa_test_scratch::pa_test] #[test] fn user_files_override_shipped_and_user_rules_run_last() { let dir = user_layer( @@ -403,6 +406,7 @@ files = ["shared.md", "user-only.md"] assert_eq!(resolution.extras.as_deref(), Some("SHIPPED")); } + #[pa_test_scratch::pa_test] #[test] fn layer_problems_disable_extras_and_name_the_source() { let empty = tempfile::tempdir().unwrap(); @@ -465,6 +469,7 @@ files = ["shared.md", "user-only.md"] .any(|error| error.contains(USER_MODEL_PROMPTS_TOML))); } + #[pa_test_scratch::pa_test] #[test] fn the_shipped_map_is_valid() { let empty = tempfile::tempdir().unwrap(); @@ -472,6 +477,7 @@ files = ["shared.md", "user-only.md"] assert!(resolution.errors.is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn shipped_glm_bash_rule_applies_to_glm_models_only() { let empty = tempfile::tempdir().unwrap(); @@ -489,6 +495,7 @@ files = ["shared.md", "user-only.md"] assert_eq!(other, ModelPromptResolution::default()); } + #[pa_test_scratch::pa_test] #[test] fn file_entries_outside_the_agent_dir_are_rejected() { let root = tempfile::tempdir().unwrap(); @@ -529,6 +536,7 @@ files = ["shared.md", "user-only.md"] assert!(failures.is_empty(), "{failures:#?}"); } + #[pa_test_scratch::pa_test] #[test] fn normalized_names_resolve_shipped_files() { let dir = user_layer("[[rule]]\nmatch = [\"*\"]\nfiles = [\"./a.md\", \"a.md\"]\n"); @@ -543,6 +551,7 @@ files = ["shared.md", "user-only.md"] } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn symlink_targets_must_stay_inside_agent_directory() { use std::os::unix::fs::symlink; @@ -581,6 +590,7 @@ files = ["shared.md", "user-only.md"] } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn fifos_are_rejected_without_opening_them() { // Keep a writer available so a regression fails assertions instead of hanging the suite. diff --git a/crates/pa-core/src/prompts/system_prompt.rs b/crates/pa-core/src/prompts/system_prompt.rs index 1e83e140e..2b01564a1 100644 --- a/crates/pa-core/src/prompts/system_prompt.rs +++ b/crates/pa-core/src/prompts/system_prompt.rs @@ -420,6 +420,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn default_prompt_is_layered_with_static_prefix_first() { let breakdown = system_prompt_breakdown(&base_options()); @@ -454,6 +455,7 @@ mod tests { assert!(tail.contains("Pre-installed Python packages: requests, httpx,")); } + #[pa_test_scratch::pa_test] #[test] fn dynamic_tail_isolates_the_cached_prefix() { let mut other = base_options(); @@ -476,6 +478,7 @@ mod tests { .contains("You are a child agent spawned by the lead.")); } + #[pa_test_scratch::pa_test] #[test] fn custom_prompt_replaces_layers_keeps_tail() { let mut options = base_options(); @@ -493,6 +496,7 @@ mod tests { assert!(!prompt.contains("Tier-2 guidance.")); } + #[pa_test_scratch::pa_test] #[test] fn mcp_servers_are_a_tail_segment() { let mut options = base_options(); @@ -510,6 +514,7 @@ mod tests { .contains("Enabled generic MCP servers: `t`.")); } + #[pa_test_scratch::pa_test] #[test] fn model_prompt_extras_form_the_last_static_segment() { let mut options = base_options(); diff --git a/crates/pa-core/src/resources/mod.rs b/crates/pa-core/src/resources/mod.rs index 5bc84b3c4..84c20bf34 100644 --- a/crates/pa-core/src/resources/mod.rs +++ b/crates/pa-core/src/resources/mod.rs @@ -311,6 +311,7 @@ mod tests { use super::*; use std::fs; + #[pa_test_scratch::pa_test] #[test] fn context_files_global_then_ancestors_root_first() { let tmp = tempfile::tempdir().unwrap(); @@ -326,6 +327,7 @@ mod tests { assert_eq!(contents, vec!["global", "level-a", "deep"]); } + #[pa_test_scratch::pa_test] #[test] fn system_prompt_discovery_prefers_project() { let tmp = tempfile::tempdir().unwrap(); @@ -351,6 +353,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn resources_load_end_to_end() { let tmp = tempfile::tempdir().unwrap(); @@ -392,6 +395,7 @@ mod tests { assert!(resources.append_system_prompt.is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn package_provided_skills_and_prompts_load_into_a_session() { let tmp = tempfile::tempdir().unwrap(); @@ -438,6 +442,7 @@ mod tests { assert_eq!(prompt.source_info.source, "../fixture-pkg"); } + #[pa_test_scratch::pa_test] #[test] fn project_auto_skills_win_name_collisions_over_user_auto() { let tmp = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/session/artifacts.rs b/crates/pa-core/src/session/artifacts.rs index 08fc3a2f4..a838e3abd 100644 --- a/crates/pa-core/src/session/artifacts.rs +++ b/crates/pa-core/src/session/artifacts.rs @@ -101,6 +101,7 @@ fn subtree_bytes(dir: &Path) -> u64 { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn top_level_session_partitions_beside_the_session_tree() { let dir = Path::new("/agent/sessions"); @@ -114,6 +115,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn child_partitions_use_the_agents_artifacts_tree_not_a_nested_one() { let child_dir = Path::new("/agent/session-artifacts/parent/sub-1"); @@ -127,6 +129,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn nested_roots_are_reported_with_the_bytes_below_them() { let agent = tempfile::tempdir().expect("agent dir"); @@ -149,6 +152,7 @@ mod tests { assert_eq!(roots[1].bytes, 4, "the deep root counts only its own files"); } + #[pa_test_scratch::pa_test] #[test] fn an_unrelated_ancestor_name_is_not_an_artifacts_tree() { let dir = Path::new("/srv/session-artifacts-archive/agent/sessions"); diff --git a/crates/pa-core/src/session/discovery.rs b/crates/pa-core/src/session/discovery.rs index 62bfa9761..31c821b79 100644 --- a/crates/pa-core/src/session/discovery.rs +++ b/crates/pa-core/src/session/discovery.rs @@ -354,6 +354,7 @@ mod tests { tempfile::tempdir().unwrap() } + #[pa_test_scratch::pa_test] #[test] fn path_like_selectors_pass_through() { assert!(looks_like_session_path("./a.jsonl")); @@ -367,6 +368,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn exact_local_match_resolves_by_normalized_id() { let dir = temp_dir(); @@ -376,6 +378,7 @@ mod tests { assert_eq!(resolved, ResolvedSession::Local(path)); } + #[pa_test_scratch::pa_test] #[test] fn global_match_reports_the_session_cwd() { let dir = temp_dir(); @@ -390,6 +393,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn ambiguous_matches_error_with_ids() { let dir = temp_dir(); @@ -417,6 +421,7 @@ mod tests { assert!(message.contains("aaaa0002")); } + #[pa_test_scratch::pa_test] #[test] fn not_found_offers_a_close_suggestion() { let dir = temp_dir(); @@ -440,6 +445,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn most_recent_session_for_cwd_prefers_newest_mtime() { let dir = temp_dir(); @@ -459,6 +465,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn most_recent_ignores_other_cwds() { let dir = temp_dir(); diff --git a/crates/pa-core/src/session/history.rs b/crates/pa-core/src/session/history.rs index fbc973577..7e8de8c33 100644 --- a/crates/pa-core/src/session/history.rs +++ b/crates/pa-core/src/session/history.rs @@ -964,6 +964,7 @@ mod tests { messages.iter().map(message_text).collect() } + #[pa_test_scratch::pa_test] #[test] fn get_last_region_and_id_address_the_same_view() { let (entries, ids) = chain(50); @@ -984,6 +985,7 @@ mod tests { assert_eq!(by_id.id.as_deref(), Some("u7")); } + #[pa_test_scratch::pa_test] #[test] fn drop_removes_the_region_from_the_request_and_keeps_the_record() { let (entries, ids) = chain(20); @@ -1001,6 +1003,7 @@ mod tests { assert!(texts(&walk.messages()).contains(&"m8".to_string())); } + #[pa_test_scratch::pa_test] #[test] fn inserted_notes_are_visible_but_never_sent() { let (entries, _) = chain(3); @@ -1023,6 +1026,7 @@ mod tests { assert_eq!(texts(&walk.messages()), before); } + #[pa_test_scratch::pa_test] #[test] fn two_changes_resolve_against_the_pre_edit_view() { let (entries, _) = chain(10); @@ -1046,6 +1050,7 @@ mod tests { assert_eq!(walk.entries[1].text, "m4"); } + #[pa_test_scratch::pa_test] #[test] fn dropped_tool_result_cannot_strand_its_call() { let content = @@ -1082,6 +1087,7 @@ mod tests { assert_eq!(walk.entries.len(), 4); } + #[pa_test_scratch::pa_test] #[test] fn replacing_an_assistant_tool_call_is_rejected() { let content = @@ -1106,6 +1112,7 @@ mod tests { assert!(error.contains("tool calls"), "{error}"); } + #[pa_test_scratch::pa_test] #[test] fn unknown_op_and_unused_keys_are_parse_errors() { let unknown = serde_json::json!({"op": "explode", "at": 1}); @@ -1127,6 +1134,7 @@ mod tests { .contains("needs 'text'")); } + #[pa_test_scratch::pa_test] #[test] fn an_unknown_op_row_degrades_and_round_trips_verbatim() { let line = r#"{"type":"context_edit","id":"e1","parentId":null,"timestamp":"t","by":"agent","changes":[{"op":"explode","at":1}]}"#; @@ -1139,6 +1147,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_session_without_edits_sends_as_before() { let lines = [ @@ -1169,6 +1178,7 @@ mod tests { .to_string() } + #[pa_test_scratch::pa_test] #[test] fn compaction_then_edit_substitutes_on_the_same_walk() { let lines = [ @@ -1197,6 +1207,7 @@ mod tests { assert!(!sent.contains(&"STATE".to_string())); } + #[pa_test_scratch::pa_test] #[test] fn edit_then_compaction_composes_in_the_other_order() { let lines = [ @@ -1216,6 +1227,7 @@ mod tests { assert_eq!(sent[2], "after"); } + #[pa_test_scratch::pa_test] #[test] fn auto_compaction_fires_only_above_the_threshold() { use crate::session_engine::compaction::{ @@ -1248,6 +1260,7 @@ mod tests { assert!(estimate_context_tokens(&trimmed).tokens < estimate_context_tokens(&full).tokens); } + #[pa_test_scratch::pa_test] #[test] fn selectors_off_the_path_name_the_rule_and_the_target() { let (entries, _) = chain(3); @@ -1331,6 +1344,7 @@ mod tests { .to_string() } + #[pa_test_scratch::pa_test] #[test] fn edit_then_a_portable_compaction_retires_the_usage_and_the_drift() { let big = "x".repeat(200_000); @@ -1387,6 +1401,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_native_compaction_retires_the_usage_behind_it() { let big = "x".repeat(200_000); @@ -1435,6 +1450,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn an_edit_after_a_compaction_does_not_revive_the_retired_usage() { let lines = [ @@ -1465,6 +1481,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn replacing_the_compaction_row_retires_the_usage_it_carried() { let big = "x".repeat(40_000); @@ -1498,6 +1515,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_usage_reported_after_a_compaction_is_honoured_and_clears_the_correction() { let lines = [ @@ -1555,6 +1573,7 @@ mod tests { assert_ne!(fresh, chars); } + #[pa_test_scratch::pa_test] #[test] fn dropping_the_compaction_row_clears_its_archive() { let lines = [ @@ -1582,6 +1601,7 @@ mod tests { .any(|entry| entry.source.is_some() && entry.role == ContextRole::User)); } + #[pa_test_scratch::pa_test] #[test] fn a_native_archive_is_an_addressable_view_entry() { let lines = [ @@ -1608,6 +1628,7 @@ mod tests { assert_eq!(walk.messages().len(), 2, "a view-only entry is never sent"); } + #[pa_test_scratch::pa_test] #[test] fn an_untouched_archive_survives_the_walk() { let lines = [ @@ -1622,6 +1643,7 @@ mod tests { assert!(walk.archive.is_some()); } + #[pa_test_scratch::pa_test] #[test] fn dropping_a_row_before_the_usage_anchor_moves_the_estimate() { let big = "x".repeat(40_000); @@ -1648,6 +1670,7 @@ mod tests { assert_eq!(after, before - 10_000, "{before} -> {after}"); } + #[pa_test_scratch::pa_test] #[test] fn an_edit_that_removes_the_usage_anchor_falls_back_to_the_char_count() { let big = "x".repeat(40_000); @@ -1672,6 +1695,7 @@ mod tests { assert!(estimate > 10_000, "{estimate}"); } + #[pa_test_scratch::pa_test] #[test] fn deleting_below_the_threshold_stops_compaction_from_firing() { let big = "x".repeat(400_000); @@ -1709,6 +1733,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn drop_and_replace_naming_one_entry_is_rejected() { let (entries, _ids) = chain(4); @@ -1729,6 +1754,7 @@ mod tests { assert_eq!(walk.entries.len(), 4, "a rejected edit mutates nothing"); } + #[pa_test_scratch::pa_test] #[test] fn replacing_a_row_before_the_usage_anchor_counts_the_replacement() { let lines = [ @@ -1769,6 +1795,7 @@ mod tests { assert!(after > 49_000, "{after}"); } + #[pa_test_scratch::pa_test] #[test] fn a_view_without_an_anchor_compacts_on_its_own_char_count() { let big = "x".repeat(500_000); @@ -1818,6 +1845,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn dropping_the_compaction_row_leaves_no_anchor_for_the_prefix() { let lines = [ @@ -1846,6 +1874,7 @@ mod tests { assert!(estimate < 100, "{estimate}"); } + #[pa_test_scratch::pa_test] #[test] fn replace_then_drop_naming_one_entry_is_rejected_too() { let (entries, _ids) = chain(4); @@ -1867,6 +1896,7 @@ mod tests { assert_eq!(walk.entries[1].text, "m1"); } + #[pa_test_scratch::pa_test] #[test] fn a_fresh_usage_anchor_resets_the_edit_correction() { let big = "x".repeat(200_000); @@ -1936,6 +1966,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_note_before_the_anchor_does_not_move_the_estimate() { let big = "x".repeat(200_000); @@ -1980,6 +2011,7 @@ mod tests { assert!((90_000..91_000).contains(&estimate), "{estimate}"); } + #[pa_test_scratch::pa_test] #[test] fn a_range_end_an_earlier_edit_dropped_uses_the_off_path_rule() { let (entries, _ids) = chain(5); @@ -2001,6 +2033,7 @@ mod tests { assert!(error.contains("u1"), "{error}"); } + #[pa_test_scratch::pa_test] #[test] fn an_insert_anchored_to_a_dropped_row_still_resolves() { let (entries, _ids) = chain(6); @@ -2035,6 +2068,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn an_edit_that_no_longer_resolves_is_counted_rather_than_silently_skipped() { let lines = [ @@ -2061,6 +2095,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn an_inserted_note_can_be_dropped_by_position_and_survives_compaction() { let lines = [ diff --git a/crates/pa-core/src/session/manager/persist_tests.rs b/crates/pa-core/src/session/manager/persist_tests.rs index 5f8d34b9c..1e71708cd 100644 --- a/crates/pa-core/src/session/manager/persist_tests.rs +++ b/crates/pa-core/src/session/manager/persist_tests.rs @@ -64,6 +64,7 @@ fn disk() -> Arc { }) } +#[pa_test_scratch::pa_test] #[test] fn an_observed_pending_row_requires_a_new_barrier_before_publication() { let dir = tempfile::tempdir().unwrap(); @@ -108,6 +109,7 @@ fn an_observed_pending_row_requires_a_new_barrier_before_publication() { ); } +#[pa_test_scratch::pa_test] #[test] fn initial_unknown_retains_its_exact_row_and_recovery_until_the_barrier_returns() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/session/manager/tests.rs b/crates/pa-core/src/session/manager/tests.rs index ac96fd5d5..827870528 100644 --- a/crates/pa-core/src/session/manager/tests.rs +++ b/crates/pa-core/src/session/manager/tests.rs @@ -21,6 +21,7 @@ fn canonical_in_memory_header_fixture() -> SessionHeader { .unwrap() } +#[pa_test_scratch::pa_test] #[test] fn in_memory_from_header_preserves_authoritative_header_without_io() { let tmp = tempfile::tempdir().unwrap(); @@ -80,6 +81,7 @@ fn in_memory_from_header_preserves_authoritative_header_without_io() { assert_eq!(std::fs::read_dir(tmp.path()).unwrap().count(), 1); } +#[pa_test_scratch::pa_test] #[test] fn in_memory_from_header_accepts_a_header_only_session() { let tmp = tempfile::tempdir().unwrap(); @@ -93,6 +95,7 @@ fn in_memory_from_header_accepts_a_header_only_session() { assert_eq!(std::fs::read_dir(tmp.path()).unwrap().count(), 0); } +#[pa_test_scratch::pa_test] #[test] fn in_memory_from_header_rejects_an_empty_id_without_io() { let tmp = tempfile::tempdir().unwrap(); @@ -105,6 +108,7 @@ fn in_memory_from_header_rejects_an_empty_id_without_io() { assert_eq!(std::fs::read_dir(tmp.path()).unwrap().count(), 0); } +#[pa_test_scratch::pa_test] #[test] fn in_memory_from_header_keeps_metadata_after_verified_window_adoption() { let tmp = tempfile::tempdir().unwrap(); @@ -151,6 +155,7 @@ fn in_memory_from_header_keeps_metadata_after_verified_window_adoption() { assert_eq!(std::fs::read(&path).unwrap(), bytes.as_bytes()); } +#[pa_test_scratch::pa_test] #[test] fn generated_entry_ids_are_unique_and_link_to_previous_entry() { let mut manager = SessionManager::in_memory(Path::new("/tmp")); @@ -171,6 +176,7 @@ fn generated_entry_ids_are_unique_and_link_to_previous_entry() { /// The durable compaction line is the full TS `CompactionEntry` record: /// `fromHook: false` is present (never a missing key), and the details /// and usage ride along. +#[pa_test_scratch::pa_test] #[test] fn append_compaction_serializes_the_full_ts_record() { let tmp = tempfile::tempdir().unwrap(); @@ -212,6 +218,7 @@ fn append_compaction_serializes_the_full_ts_record() { assert!(line.contains("\"usage\":")); } +#[pa_test_scratch::pa_test] #[test] fn persist_appends_before_first_assistant() { let tmp = tempfile::tempdir().unwrap(); @@ -250,6 +257,7 @@ fn persist_appends_before_first_assistant() { let _ = first; } +#[pa_test_scratch::pa_test] #[test] fn open_rejects_torn_tail_without_modifying_source() { let tmp = tempfile::tempdir().unwrap(); @@ -279,6 +287,7 @@ fn open_rejects_torn_tail_without_modifying_source() { assert_eq!(std::fs::read_to_string(&file).unwrap(), content.trim_end()); } +#[pa_test_scratch::pa_test] #[test] fn flush_now_durability_without_assistant() { let tmp = tempfile::tempdir().unwrap(); @@ -289,6 +298,7 @@ fn flush_now_durability_without_assistant() { assert_eq!(manager.get_session_name().as_deref(), Some("my session")); } +#[pa_test_scratch::pa_test] #[test] fn iso_format_round_trips() { let stamp = format_iso(1_704_067_200_012); @@ -296,6 +306,7 @@ fn iso_format_round_trips() { assert_eq!(super::super::timestamp_to_millis(&stamp), 1_704_067_200_012); } +#[pa_test_scratch::pa_test] #[test] fn fork_from_copies_the_branch_under_a_fresh_header() { let tmp = tempfile::tempdir().unwrap(); @@ -406,6 +417,7 @@ fn fork_from_copies_the_branch_under_a_fresh_header() { assert!(after.lines().count() > before.lines().count()); } +#[pa_test_scratch::pa_test] #[test] fn fork_from_never_rewrites_the_source() { let tmp = tempfile::tempdir().unwrap(); @@ -419,6 +431,7 @@ fn fork_from_never_rewrites_the_source() { assert_eq!(std::fs::read_to_string(&file).unwrap(), content); } +#[pa_test_scratch::pa_test] #[test] fn fork_from_terminates_on_cyclic_git_state_parents() { let tmp = tempfile::tempdir().unwrap(); @@ -455,6 +468,7 @@ fn fork_from_terminates_on_cyclic_git_state_parents() { /// The loader returns no entries for a missing file, an empty file, AND a /// file without a valid leading header (the no-header error stays as /// TS-faithful defense-in-depth). +#[pa_test_scratch::pa_test] #[test] fn fork_from_rejects_empty_and_headerless_sources() { let tmp = tempfile::tempdir().unwrap(); @@ -474,6 +488,7 @@ fn fork_from_rejects_empty_and_headerless_sources() { assert!(!target.exists()); } +#[pa_test_scratch::pa_test] #[test] fn fork_from_rejects_a_non_regular_source() { let tmp = tempfile::tempdir().unwrap(); @@ -491,6 +506,7 @@ fn fork_from_rejects_a_non_regular_source() { ); } +#[pa_test_scratch::pa_test] #[test] fn open_treats_a_path_shaped_header_id_as_corrupted() { let tmp = tempfile::tempdir().unwrap(); @@ -506,6 +522,7 @@ fn open_treats_a_path_shaped_header_id_as_corrupted() { /// Replay validation must stay on the retained index: the full-history query /// panics after window adoption. Replaying a registered row once does not /// suppress a later legitimate submission of the same text. +#[pa_test_scratch::pa_test] #[test] fn replay_admitted_user_rows_stays_windowed_and_reuses_only_registered_ids() { let dir = tempfile::tempdir().unwrap(); @@ -567,6 +584,7 @@ fn replay_admitted_user_rows_stays_windowed_and_reuses_only_registered_ids() { ); } +#[pa_test_scratch::pa_test] #[test] fn host_writer_receives_exact_entry_before_publication() { use std::sync::{Arc, Mutex}; @@ -598,6 +616,7 @@ fn host_writer_receives_exact_entry_before_publication() { assert_eq!(*rows.lock().unwrap(), vec![entry.clone()]); } +#[pa_test_scratch::pa_test] #[test] fn host_writer_failure_does_not_publish_an_entry() { struct Writer; @@ -620,6 +639,7 @@ fn host_writer_failure_does_not_publish_an_entry() { assert_eq!(manager.retained_entries(), before); } +#[pa_test_scratch::pa_test] #[test] fn host_writer_does_not_repeat_accepted_user_rows() { use std::sync::{Arc, Mutex}; @@ -652,6 +672,7 @@ fn host_writer_does_not_repeat_accepted_user_rows() { assert!(rows.lock().unwrap().is_empty()); } +#[pa_test_scratch::pa_test] #[test] fn host_sink_returns_the_committed_identity_and_parent() { struct Writer; @@ -684,6 +705,7 @@ fn host_sink_returns_the_committed_identity_and_parent() { assert_eq!(stored.timestamp(), "2001-02-03T04:05:06.789Z"); } +#[pa_test_scratch::pa_test] #[test] fn admitted_custom_identity_is_consumed_once_without_content_deduplication() { let tmp = tempfile::tempdir().unwrap(); @@ -726,6 +748,7 @@ fn write_log_fixture(path: &Path, content: impl AsRef<[u8]>) -> std::io::Result< Ok(()) } +#[pa_test_scratch::pa_test] #[test] fn external_commits_enter_context_before_inference_and_parent_selection() { let dir = tempfile::tempdir().unwrap(); @@ -754,6 +777,7 @@ fn external_commits_enter_context_before_inference_and_parent_selection() { ); } +#[pa_test_scratch::pa_test] #[test] fn unsupported_and_torn_prefixes_never_repair_or_recreate_existing_files() { let dir = tempfile::tempdir().unwrap(); @@ -769,6 +793,7 @@ fn unsupported_and_torn_prefixes_never_repair_or_recreate_existing_files() { } } +#[pa_test_scratch::pa_test] #[test] fn mirrored_sink_tail_is_visible_before_model_and_next_append() { use std::sync::{Arc, Mutex}; @@ -848,6 +873,7 @@ fn mirrored_sink_tail_is_visible_before_model_and_next_append() { ); } +#[pa_test_scratch::pa_test] #[test] fn lazy_new_session_never_adopts_a_precreated_target() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/session/manager_ext.rs b/crates/pa-core/src/session/manager_ext.rs index bb2e63606..672ecf712 100644 --- a/crates/pa-core/src/session/manager_ext.rs +++ b/crates/pa-core/src/session/manager_ext.rs @@ -332,6 +332,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn branch_and_summary() { let tmp = tempfile::tempdir().unwrap(); @@ -349,6 +350,7 @@ mod tests { assert!(manager.get_entry_by_id(&b).is_some()); } + #[pa_test_scratch::pa_test] #[test] fn user_content_detection() { let tmp = tempfile::tempdir().unwrap(); @@ -361,6 +363,7 @@ mod tests { assert!(manager.has_user_content()); } + #[pa_test_scratch::pa_test] #[test] fn labels_on_active_branch() { let tmp = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/session/mod.rs b/crates/pa-core/src/session/mod.rs index 4c6980f2b..e7245b7dc 100644 --- a/crates/pa-core/src/session/mod.rs +++ b/crates/pa-core/src/session/mod.rs @@ -376,6 +376,7 @@ mod context_tests { .to_string() } + #[pa_test_scratch::pa_test] #[test] fn context_walks_parent_chain() { let content = format!( @@ -403,6 +404,7 @@ mod context_tests { )); } + #[pa_test_scratch::pa_test] #[test] fn compaction_rebuilds_summary_first() { let content = String::from( @@ -439,6 +441,7 @@ mod context_tests { } } + #[pa_test_scratch::pa_test] #[test] fn child_usage_attribution_folds_into_assistant() { let content = format!( diff --git a/crates/pa-core/src/session/read.rs b/crates/pa-core/src/session/read.rs index cf0749ef3..15c047245 100644 --- a/crates/pa-core/src/session/read.rs +++ b/crates/pa-core/src/session/read.rs @@ -47,6 +47,7 @@ pub fn read_entries_from(mut reader: impl BufRead) -> io::Result> mod tests { use super::*; use crate::session_log::{Outcome, SessionLog}; + #[pa_test_scratch::pa_test] #[test] fn reads_plain_rows_and_rejects_corruption_without_repairing_source() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/session/storage.rs b/crates/pa-core/src/session/storage.rs index ca7653474..f2a45dd9b 100644 --- a/crates/pa-core/src/session/storage.rs +++ b/crates/pa-core/src/session/storage.rs @@ -138,6 +138,7 @@ mod tests { const ID: &str = "01a1fb6b-cd31-7694-a622-8cbd0fa54d8d"; + #[pa_test_scratch::pa_test] #[test] fn sizes_split_the_artifact_directory_from_its_kernel_snapshot() { let root = tempfile::tempdir().unwrap(); @@ -172,6 +173,7 @@ mod tests { assert_eq!(sizes.total(), 195); } + #[pa_test_scratch::pa_test] #[test] fn a_child_log_resolves_to_the_agents_artifacts_tree() { let root = tempfile::tempdir().unwrap(); @@ -190,6 +192,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn absent_storage_measures_zero() { let root = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/session/tree.rs b/crates/pa-core/src/session/tree.rs index de7a6f030..f3008eced 100644 --- a/crates/pa-core/src/session/tree.rs +++ b/crates/pa-core/src/session/tree.rs @@ -95,6 +95,7 @@ mod tests { use super::super::parse_session_entries; use super::*; + #[pa_test_scratch::pa_test] #[test] fn tree_paths_and_labels() { let content = r#" diff --git a/crates/pa-core/src/session/window_tests.rs b/crates/pa-core/src/session/window_tests.rs index d31c1e09e..e8bab097b 100644 --- a/crates/pa-core/src/session/window_tests.rs +++ b/crates/pa-core/src/session/window_tests.rs @@ -20,6 +20,7 @@ fn fixture() -> String { } /// The stats carry the cumulative aggregate, not the raw row. +#[pa_test_scratch::pa_test] #[test] fn older_path_stats_fold_child_usage_attributions() { let dir = tempfile::tempdir().unwrap(); @@ -72,6 +73,7 @@ fn older_path_stats_fold_child_usage_attributions() { } /// Newest-first, the FIRST aggregate seen per target is the last one written. +#[pa_test_scratch::pa_test] #[test] fn older_path_stats_keep_a_targets_last_aggregate() { let dir = tempfile::tempdir().unwrap(); @@ -110,6 +112,7 @@ fn older_path_stats_keep_a_targets_last_aggregate() { } /// The capture gate accepts objects only, like the session-store fold. +#[pa_test_scratch::pa_test] #[test] fn older_path_stats_skip_malformed_aggregates() { let dir = tempfile::tempdir().unwrap(); @@ -143,6 +146,7 @@ fn older_path_stats_skip_malformed_aggregates() { /// A post-compaction switch inside the retained window must not re-label the boundary's early /// summarizer spend. +#[pa_test_scratch::pa_test] #[test] fn boundary_model_is_the_prefixs_newest_model_change_not_the_leafs() { let dir = tempfile::tempdir().unwrap(); @@ -177,6 +181,7 @@ fn boundary_model_is_the_prefixs_newest_model_change_not_the_leafs() { ); } +#[pa_test_scratch::pa_test] #[test] fn warm_cache_reads_only_header_and_suffix_and_append_stays_warm() { let dir = tempfile::tempdir().unwrap(); @@ -211,6 +216,7 @@ fn warm_cache_reads_only_header_and_suffix_and_append_stays_warm() { ); } +#[pa_test_scratch::pa_test] #[test] fn blank_rows_and_uncompacted_context_are_warm() { let dir = tempfile::tempdir().unwrap(); @@ -225,6 +231,7 @@ fn blank_rows_and_uncompacted_context_are_warm() { } } +#[pa_test_scratch::pa_test] #[test] fn valid_goal_and_physical_metadata_survive_invalid_newer_branch_goal() { let dir = tempfile::tempdir().unwrap(); @@ -254,6 +261,7 @@ fn valid_goal_and_physical_metadata_survive_invalid_newer_branch_goal() { /// paying a full-file parse — and the cached sidecar serves it warm. The /// matcher is honest about the payload: a row with `data.shown` false is /// not a marker. +#[pa_test_scratch::pa_test] #[test] fn anthropic_warning_marker_hydrates_from_before_the_boundary() { let dir = tempfile::tempdir().unwrap(); @@ -292,6 +300,7 @@ fn anthropic_warning_marker_hydrates_from_before_the_boundary() { /// A `custom` row with the marker's type but `data.shown` false is not the /// marker: the gate's payload check keeps a future un-show payload (or a /// foreign row borrowing the type) from suppressing the warning. +#[pa_test_scratch::pa_test] #[test] fn an_unshown_marker_row_never_hydrates_the_gate() { let dir = tempfile::tempdir().unwrap(); @@ -311,6 +320,7 @@ fn an_unshown_marker_row_never_hydrates_the_gate() { assert!(!store.anthropic_warning_shown()); } +#[pa_test_scratch::pa_test] #[test] fn unleased_append_invalidates_without_certification() { let dir = tempfile::tempdir().unwrap(); @@ -329,6 +339,7 @@ fn unleased_append_invalidates_without_certification() { assert_eq!(reopened.leaf_id(), "info"); } +#[pa_test_scratch::pa_test] #[test] fn cached_accounting_preserves_subtotal_bits() { let stats = WindowStats { @@ -340,6 +351,7 @@ fn cached_accounting_preserves_subtotal_bits() { assert_eq!(restored.cost.to_bits(), stats.cost.to_bits()); } +#[pa_test_scratch::pa_test] #[test] fn explicit_null_tier_append_stays_warm() { let dir = tempfile::tempdir().unwrap(); @@ -368,6 +380,7 @@ fn explicit_null_tier_append_stays_warm() { assert_eq!(window.context().service_tier, None); } +#[pa_test_scratch::pa_test] #[test] fn stale_corrupt_and_replaced_cache_rebuild() { let dir = tempfile::tempdir().unwrap(); @@ -403,6 +416,7 @@ fn stale_corrupt_and_replaced_cache_rebuild() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn context_and_hydration_match_full_reader() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("session.jsonl"); @@ -434,6 +448,7 @@ async fn context_and_hydration_match_full_reader() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn metadata_and_concurrent_disk_append_survive_hydration() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("metadata.jsonl"); @@ -459,6 +474,7 @@ async fn metadata_and_concurrent_disk_append_survive_hydration() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn manager_opens_window_and_appends_without_hydration() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("manager.jsonl"); @@ -487,6 +503,7 @@ async fn manager_opens_window_and_appends_without_hydration() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn failed_window_append_returns_error_without_id_or_listener() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("manager.jsonl"); @@ -508,6 +525,7 @@ async fn failed_window_append_returns_error_without_id_or_listener() { assert!(!path.exists()); } +#[pa_test_scratch::pa_test] #[test] fn sparse_settings_and_sibling_changes_match_full_context() { let dir = tempfile::tempdir().unwrap(); @@ -541,6 +559,7 @@ fn sparse_settings_and_sibling_changes_match_full_context() { ); } +#[pa_test_scratch::pa_test] #[test] fn unterminated_session_is_not_admitted_as_a_window() { let dir = tempfile::tempdir().unwrap(); @@ -549,6 +568,7 @@ fn unterminated_session_is_not_admitted_as_a_window() { assert!(WindowedSessionStore::open(&path).unwrap().is_none()); } +#[pa_test_scratch::pa_test] #[test] fn reverse_reader_preserves_long_lines_and_unterminated_tail() { let dir = tempfile::tempdir().unwrap(); @@ -570,6 +590,7 @@ fn reverse_reader_preserves_long_lines_and_unterminated_tail() { assert_eq!(lines, vec!["last".to_owned(), long, "first".to_owned()]); } +#[pa_test_scratch::pa_test] #[test] fn no_retained_boundary_matches_cold_context_and_keeps_only_the_physical_suffix() { let dir = tempfile::tempdir().unwrap(); @@ -613,6 +634,7 @@ fn no_retained_boundary_matches_cold_context_and_keeps_only_the_physical_suffix( } } +#[pa_test_scratch::pa_test] #[test] fn windowed_context_is_byte_identical_to_the_cold_parse() { // The resumed worker's first model request is built from this context: @@ -654,6 +676,7 @@ fn windowed_context_is_byte_identical_to_the_cold_parse() { } } +#[pa_test_scratch::pa_test] #[test] fn sequential_appends_keep_reopens_amortized() { // N leased appends stay O(append): every reopen stays a cache hit whose @@ -691,6 +714,7 @@ fn sequential_appends_keep_reopens_amortized() { } /// The detach changes WHO holds the retained rows, never WHAT is served. +#[pa_test_scratch::pa_test] #[test] fn adopted_context_matches_unadopted_window_byte_for_byte() { let dir = tempfile::tempdir().unwrap(); @@ -744,6 +768,7 @@ fn adopted_context_matches_unadopted_window_byte_for_byte() { /// The detached window keeps its snapshot/settings/metadata surfaces; its /// transcript context moves to the owning manager — `context()` on a /// detached window is a programming error, caught loudly. +#[pa_test_scratch::pa_test] #[test] #[should_panic(expected = "detached window's transcript context")] fn detached_window_serves_lookups_but_not_its_own_context() { @@ -772,6 +797,7 @@ fn detached_window_serves_lookups_but_not_its_own_context() { /// Post-adoption live appends — including an attribution whose target is /// a RETAINED assistant — must match what a cold reopen serves. #[tokio::test] +#[pa_test_scratch::pa_test] async fn adopted_manager_live_appends_match_full_reopen() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("adopt-append.jsonl"); @@ -883,6 +909,7 @@ fn full_history_fixture() -> String { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn full_history_snapshot_serves_retained_rows_without_the_file() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("full.jsonl"); @@ -924,6 +951,7 @@ async fn full_history_snapshot_serves_retained_rows_without_the_file() { /// Without the sole-writer lease another writer may have appended out of band. #[tokio::test] +#[pa_test_scratch::pa_test] async fn full_history_snapshot_without_lease_keeps_the_historical_read() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("unleased-full.jsonl"); @@ -943,6 +971,7 @@ async fn full_history_snapshot_without_lease_keeps_the_historical_read() { /// A compaction boundary discards a prefix by design; the fast path never claims coverage. #[tokio::test] +#[pa_test_scratch::pa_test] async fn boundary_window_snapshot_keeps_the_historical_read() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("boundary.jsonl"); @@ -981,6 +1010,7 @@ async fn boundary_window_snapshot_keeps_the_historical_read() { /// appended row: both would be lost to the index. The append boundary /// guard writes one newline first, so the appended row parses on its own /// line and the torn row alone stays skipped. +#[pa_test_scratch::pa_test] #[test] fn append_refuses_a_torn_source_without_repairing_it() { let dir = tempfile::tempdir().unwrap(); @@ -1054,6 +1084,7 @@ fn write_enveloped(path: &Path, body: &str, seq_of: impl Fn(usize) -> u64) { /// a line's absolute position. What it can check is that neighbouring envelope /// lines agree: a line that declares a seq which is not one less than the line /// below it is refused. +#[pa_test_scratch::pa_test] #[test] fn a_wrong_seq_envelope_is_refused_by_the_backwards_walk() { let dir = tempfile::tempdir().unwrap(); @@ -1087,6 +1118,7 @@ fn a_wrong_seq_envelope_is_refused_by_the_backwards_walk() { /// A file holding both shapes is what an append by this binary to a legacy file /// produces, and both shapes carry their position the same way, so it reads. +#[pa_test_scratch::pa_test] #[test] fn a_file_holding_both_shapes_reads_backwards() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/session_engine/agent_messaging/tests.rs b/crates/pa-core/src/session_engine/agent_messaging/tests.rs index 1cf0ea7b5..8d556eecd 100644 --- a/crates/pa-core/src/session_engine/agent_messaging/tests.rs +++ b/crates/pa-core/src/session_engine/agent_messaging/tests.rs @@ -4,6 +4,7 @@ use super::*; /// TS #2493: an observation row carries the typed family status and /// its live activity (a separate axis), and a member with no live /// session omits the activity field entirely. +#[pa_test_scratch::pa_test] #[test] fn observe_rows_carry_the_typed_status_and_activity() { let mut row = AgentObserveSummary { @@ -41,6 +42,7 @@ fn observe_rows_carry_the_typed_status_and_activity() { ); } +#[pa_test_scratch::pa_test] #[test] fn message_ids_and_validation() { let id = create_agent_session_message_id(); @@ -60,6 +62,7 @@ fn message_ids_and_validation() { assert!(normalize_agent_session_message(&at_limit).is_ok()); } +#[pa_test_scratch::pa_test] #[test] fn target_and_capacity_guards() { assert_eq!( @@ -82,6 +85,7 @@ fn target_and_capacity_guards() { ); } +#[pa_test_scratch::pa_test] #[test] fn message_prompts_and_id_parsing() { let payload = AgentMessagePromptPayload { @@ -110,6 +114,7 @@ fn message_prompts_and_id_parsing() { assert!(!is_agent_session_message_prompt("plain text")); } +#[pa_test_scratch::pa_test] #[test] fn the_custom_row_carries_the_ts_agent_message_shape() { let prompt = "[agent-message from child:lane]\n\nfinished the research"; @@ -163,6 +168,7 @@ fn the_custom_row_carries_the_ts_agent_message_shape() { assert_eq!(plain["details"]["from"], Value::Null); } +#[pa_test_scratch::pa_test] #[test] fn observe_limits_clamp() { assert_eq!(normalize_observe_limit(None).unwrap(), 8); @@ -175,6 +181,7 @@ fn observe_limits_clamp() { assert!(normalize_observe_max_chars(Some(2_001)).is_err()); } +#[pa_test_scratch::pa_test] #[test] fn observe_previews_truncate() { let user = pa_types::session::AgentMessage::User(pa_types::ai::UserMessage { @@ -270,6 +277,7 @@ fn send_request(send: &crate::kernel::shared::HostHandlerFn, data: Value) -> any } #[tokio::test] +#[pa_test_scratch::pa_test] async fn message_host_handler_round_trip() { let mut handlers = HostRequestHandlers::default(); register_agent_message_host_handlers( @@ -385,6 +393,7 @@ async fn message_host_handler_round_trip() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn broadcast_without_family_is_empty_and_failures_settle() { struct NoFamilyController; impl AgentMessageController for NoFamilyController { @@ -445,6 +454,7 @@ async fn broadcast_without_family_is_empty_and_failures_settle() { /// broadcast: both shapes carry the target, the delivery status, and the /// queued reason (issue #33). A caller can decide from either receipt. #[tokio::test] +#[pa_test_scratch::pa_test] async fn broadcast_and_direct_report_the_same_admission_receipt() { struct HeldTargetController; impl AgentMessageController for HeldTargetController { diff --git a/crates/pa-core/src/session_engine/auto_retry/tests.rs b/crates/pa-core/src/session_engine/auto_retry/tests.rs index 8a1ee2235..98d4157df 100644 --- a/crates/pa-core/src/session_engine/auto_retry/tests.rs +++ b/crates/pa-core/src/session_engine/auto_retry/tests.rs @@ -74,6 +74,7 @@ fn fast_policy() -> ProviderRetryPolicy { /// parks the session when the park seam reports a park: the give-up /// status becomes the parked sentence (TS #2375). #[tokio::test] +#[pa_test_scratch::pa_test] async fn quota_reset_beyond_cap_parks_through_the_seam() { let events = Arc::new(Mutex::new(Vec::new())); let parked_calls = Arc::new(std::sync::atomic::AtomicUsize::new(0)); @@ -138,6 +139,7 @@ async fn quota_reset_beyond_cap_parks_through_the_seam() { /// A park seam that declines keeps the give-up: the surfaced status /// stays the plain exceeds-cap sentence. #[tokio::test] +#[pa_test_scratch::pa_test] async fn quota_reset_beyond_cap_keeps_the_give_up_when_the_seam_declines() { let events = Arc::new(Mutex::new(Vec::new())); let events_for_emit = Arc::clone(&events); @@ -179,6 +181,7 @@ async fn quota_reset_beyond_cap_keeps_the_give_up_when_the_seam_declines() { /// server-requested wait on a non-quota failure keeps the give-up /// even when a park is armed (TS parks only from the usage path). #[tokio::test] +#[pa_test_scratch::pa_test] async fn non_quota_exceeds_cap_never_consults_the_park_seam() { let events = Arc::new(Mutex::new(Vec::new())); let events_for_emit = Arc::clone(&events); @@ -215,6 +218,7 @@ async fn non_quota_exceeds_cap_never_consults_the_park_seam() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn transient_failure_is_retried_until_success_with_events() { let attempts = Arc::new(std::sync::atomic::AtomicUsize::new(0)); let events = Arc::new(Mutex::new(Vec::new())); @@ -294,6 +298,7 @@ async fn transient_failure_is_retried_until_success_with_events() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn exhausted_retries_surface_the_final_error() { let attempts = Arc::new(std::sync::atomic::AtomicUsize::new(0)); let events = Arc::new(Mutex::new(Vec::new())); @@ -375,6 +380,7 @@ fn stream_drop_message() -> AssistantMessage { /// (the retryable `stream_drop` class) is retried — the re-issued turn /// completes on the retry, never settling as the silent empty turn. #[tokio::test] +#[pa_test_scratch::pa_test] async fn stream_drop_retries_until_the_turn_completes() { let attempts = Arc::new(std::sync::atomic::AtomicUsize::new(0)); let events = Arc::new(Mutex::new(Vec::new())); @@ -436,6 +442,7 @@ async fn stream_drop_retries_until_the_turn_completes() { /// failure row names the `stream_drop` class — never a silent empty /// turn. #[tokio::test] +#[pa_test_scratch::pa_test] async fn stream_drop_exhausts_retries_surfacing_the_class() { let attempts = Arc::new(std::sync::atomic::AtomicUsize::new(0)); let events = Arc::new(Mutex::new(Vec::new())); @@ -488,6 +495,7 @@ async fn stream_drop_exhausts_retries_surfacing_the_class() { /// `auto_retry_end` (attempt 0) — the disclosure row must fire for /// every provider failure, not only retry episodes. #[tokio::test] +#[pa_test_scratch::pa_test] async fn permanent_failures_never_retry_but_disclose() { let attempts = Arc::new(std::sync::atomic::AtomicUsize::new(0)); let events = Arc::new(Mutex::new(Vec::new())); @@ -537,6 +545,7 @@ async fn permanent_failures_never_retry_but_disclose() { /// failure-scoped disclosure still fires, so the turn never settles /// as a silent empty message. #[tokio::test] +#[pa_test_scratch::pa_test] async fn payment_failures_settle_once_with_the_disclosure() { let attempts = Arc::new(std::sync::atomic::AtomicUsize::new(0)); let events = Arc::new(Mutex::new(Vec::new())); @@ -581,6 +590,7 @@ async fn payment_failures_settle_once_with_the_disclosure() { /// rejection) is a deterministic rejection — one attempt, no retry /// loop — with the failure-scoped disclosure (attempt 0). #[tokio::test] +#[pa_test_scratch::pa_test] async fn safety_failures_are_permanent_never_retry_but_disclose() { let attempts = Arc::new(std::sync::atomic::AtomicUsize::new(0)); let events = Arc::new(Mutex::new(Vec::new())); @@ -630,6 +640,7 @@ async fn safety_failures_are_permanent_never_retry_but_disclose() { /// `_isRetryableError`'s overflow guard): the turn surfaces the error /// immediately so the compact-and-retry recovery owns it. #[tokio::test] +#[pa_test_scratch::pa_test] async fn context_overflow_never_enters_the_retry_loop() { let attempts = Arc::new(std::sync::atomic::AtomicUsize::new(0)); let events = Arc::new(Mutex::new(Vec::new())); @@ -667,6 +678,7 @@ async fn context_overflow_never_enters_the_retry_loop() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn cancelled_wait_aborts_with_retry_cancelled() { let events = Arc::new(Mutex::new(Vec::new())); let events_for_emit = Arc::clone(&events); @@ -706,6 +718,7 @@ async fn cancelled_wait_aborts_with_retry_cancelled() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn aborted_signal_racing_failure_stops_aborted() { let controller = pa_agent::abort::AbortController::new(); controller.abort(); @@ -724,6 +737,7 @@ async fn aborted_signal_racing_failure_stops_aborted() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn server_retry_after_over_cap_ends_the_loop() { let attempts = Arc::new(std::sync::atomic::AtomicUsize::new(0)); let events = Arc::new(Mutex::new(Vec::new())); @@ -773,6 +787,7 @@ async fn server_retry_after_over_cap_ends_the_loop() { /// A disabled retry policy never retries, but a provider failure /// still settles with the failure-scoped disclosure (attempt 0). #[tokio::test] +#[pa_test_scratch::pa_test] async fn disabled_policy_never_retries_but_discloses() { let policy = ProviderRetryPolicy { enabled: false, @@ -818,6 +833,7 @@ async fn disabled_policy_never_retries_but_discloses() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn attempt_errors_propagate() { let error = run_turn_with_auto_retry( &fast_policy(), @@ -838,6 +854,7 @@ async fn attempt_errors_propagate() { /// one attempt with the failure-scoped disclosure (attempt 0), like /// the other non-retryable provider failures. #[tokio::test] +#[pa_test_scratch::pa_test] async fn unsupported_tool_failures_surface_with_the_disclosure() { let attempts = Arc::new(std::sync::atomic::AtomicUsize::new(0)); let events = Arc::new(Mutex::new(Vec::new())); diff --git a/crates/pa-core/src/session_engine/auxiliary_model.rs b/crates/pa-core/src/session_engine/auxiliary_model.rs index 0eeb1a469..3d7ccb4e5 100644 --- a/crates/pa-core/src/session_engine/auxiliary_model.rs +++ b/crates/pa-core/src/session_engine/auxiliary_model.rs @@ -215,6 +215,7 @@ mod tests { /// The session fallback resolves its MERGED headers through the same /// registry the session's own requests use. + #[pa_test_scratch::pa_test] #[test] fn the_session_fallback_keeps_the_merged_headers() { let (dir, context) = context_with_settings(&serde_json::json!({})); @@ -242,6 +243,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn an_explicit_selector_is_distinct_from_the_top_level_auxiliary_setting() { let (_dir, context) = context_with_settings(&serde_json::json!({ @@ -286,6 +288,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn unavailable_explicit_models_return_sanitized_errors_instead_of_falling_back() { let (_dir, context) = context_with_settings(&serde_json::json!({ @@ -310,6 +313,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn unset_selector_keeps_the_session_model() { let (_dir, context) = context_with_settings(&serde_json::json!({})); @@ -325,6 +329,7 @@ mod tests { assert_eq!(routed.api_key.as_deref(), Some("session-key")); } + #[pa_test_scratch::pa_test] #[test] fn selector_equal_to_the_session_model_keeps_the_session_model() { let (_dir, context) = @@ -341,6 +346,7 @@ mod tests { assert_eq!(routed.api_key.as_deref(), Some("session-key")); } + #[pa_test_scratch::pa_test] #[test] fn configured_selector_routes_to_the_auxiliary_model() { let (_dir, context) = @@ -358,6 +364,7 @@ mod tests { assert_eq!(routed.headers, None); } + #[pa_test_scratch::pa_test] #[test] fn unknown_selector_falls_back_to_the_session_model() { let (_dir, context) = @@ -374,6 +381,7 @@ mod tests { assert_eq!(routed.api_key.as_deref(), Some("session-key")); } + #[pa_test_scratch::pa_test] #[test] fn too_small_window_falls_back_to_the_session_model() { let (_dir, context) = @@ -397,6 +405,7 @@ mod tests { assert_eq!(routed.model.id, "aux-model"); } + #[pa_test_scratch::pa_test] #[test] fn selector_outside_the_allowlist_falls_back() { let (_dir, context) = context_with_settings(&serde_json::json!({ diff --git a/crates/pa-core/src/session_engine/branch_summarization.rs b/crates/pa-core/src/session_engine/branch_summarization.rs index 1a2ddc42c..3d4a6c9e5 100644 --- a/crates/pa-core/src/session_engine/branch_summarization.rs +++ b/crates/pa-core/src/session_engine/branch_summarization.rs @@ -494,6 +494,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn collects_old_branch_to_common_ancestor() { // root -> u1 -> a1 -> u2 (old leaf) @@ -511,6 +512,7 @@ mod tests { assert_eq!(result.entries[1].id(), Some("u2")); } + #[pa_test_scratch::pa_test] #[test] fn preparation_respects_budget_and_keeps_boundaries() { let mut entries = Vec::new(); @@ -531,6 +533,7 @@ mod tests { assert_eq!(unlimited.messages.len(), 10); } + #[pa_test_scratch::pa_test] #[test] fn request_and_finalize() { let entries = vec![entry("e0", None, user("explore the widget"))]; @@ -552,6 +555,7 @@ mod tests { assert!(branch_summary_presentation("s").contains("[branch-summary]")); } + #[pa_test_scratch::pa_test] #[test] fn compaction_entries_become_summary_messages() { let compaction = FileEntry::Compaction { @@ -583,6 +587,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn generates_summary_through_the_faux_provider() { // One faux provider per test (a process-global registry); the // guard is released before the awaited model call. @@ -625,6 +630,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn empty_branch_summarizes_to_a_note() { let model: pa_types::ai::Model = serde_json::from_value(serde_json::json!({ "id": "m", "name": "m", "api": "openai-completions", "provider": "test", @@ -654,6 +660,7 @@ mod tests { /// A selector equal to the session model keeps it, and a selector /// that resolves to no model falls back the same way. #[tokio::test] + #[pa_test_scratch::pa_test] async fn branch_summary_auxiliary_selector_falls_back_to_the_session_model() { static FAUX_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); for selector in ["faux/faux-1", "testaux/missing-model"] { @@ -719,6 +726,7 @@ mod tests { /// The window estimate mirrors `generate_branch_summary`'s slicing /// and prompt exactly. + #[pa_test_scratch::pa_test] #[test] fn branch_summary_options_carry_the_owning_session_id() { let options = branch_summary_stream_options(None, None, Some("session-1")); @@ -728,6 +736,7 @@ mod tests { .is_none()); } + #[pa_test_scratch::pa_test] #[test] fn branch_window_estimate_shapes() { // An entry too large for the slice budget: no wire request, but diff --git a/crates/pa-core/src/session_engine/compact_session/tests/auxiliary_model.rs b/crates/pa-core/src/session_engine/compact_session/tests/auxiliary_model.rs index a5559ddb5..16914b002 100644 --- a/crates/pa-core/src/session_engine/compact_session/tests/auxiliary_model.rs +++ b/crates/pa-core/src/session_engine/compact_session/tests/auxiliary_model.rs @@ -25,6 +25,7 @@ fn aux_context( /// A selector equal to the session model keeps the session model (the /// faux factory records the model). #[tokio::test] +#[pa_test_scratch::pa_test] async fn compaction_auxiliary_selector_equal_to_the_session_model_runs_on_the_session_model() { let registration = faux_registration(); let model = registration.get_model(); @@ -75,6 +76,7 @@ async fn compaction_auxiliary_selector_equal_to_the_session_model_runs_on_the_se /// A selector that resolves to no model (unusable) falls back to the /// session model with a warning: the compaction still runs. #[tokio::test] +#[pa_test_scratch::pa_test] async fn compaction_auxiliary_selector_unusable_falls_back_to_the_session_model() { let registration = faux_registration(); let model = registration.get_model(); diff --git a/crates/pa-core/src/session_engine/compact_session/tests/cut_math.rs b/crates/pa-core/src/session_engine/compact_session/tests/cut_math.rs index 7c31d3b7e..3ca84a0fc 100644 --- a/crates/pa-core/src/session_engine/compact_session/tests/cut_math.rs +++ b/crates/pa-core/src/session_engine/compact_session/tests/cut_math.rs @@ -4,6 +4,7 @@ use super::*; use pa_types::session::EntryBase; +#[pa_test_scratch::pa_test] #[test] fn cut_and_tokens_computed_from_entries() { let tmp = tempfile::tempdir().unwrap(); @@ -13,6 +14,7 @@ fn cut_and_tokens_computed_from_entries() { assert_eq!(tokens, 120); } +#[pa_test_scratch::pa_test] #[test] fn message_extraction_skips_compaction_and_tool_results() { let mut compaction = FileEntry::Compaction { @@ -57,6 +59,7 @@ fn message_extraction_skips_compaction_and_tool_results() { /// A usage-less error turn never anchors `tokensBefore`: the estimate uses /// the last settled usage plus a chars/4 estimate of what trails it. +#[pa_test_scratch::pa_test] #[test] fn tokens_before_anchors_on_last_valid_usage_plus_trailing() { let reply = |usage: pa_types::ai::Usage, error: bool| { @@ -130,6 +133,7 @@ fn tokens_before_anchors_on_last_valid_usage_plus_trailing() { /// A split turn estimates BOTH the history request and the turn-prefix /// request; the no-history split arm estimates only the prefix call. +#[pa_test_scratch::pa_test] #[test] fn summary_window_estimate_covers_both_split_requests() { let history = vec![user_message("some history to summarize")]; diff --git a/crates/pa-core/src/session_engine/compact_session/tests/execute_compaction.rs b/crates/pa-core/src/session_engine/compact_session/tests/execute_compaction.rs index 7c371d424..896592c7a 100644 --- a/crates/pa-core/src/session_engine/compact_session/tests/execute_compaction.rs +++ b/crates/pa-core/src/session_engine/compact_session/tests/execute_compaction.rs @@ -6,6 +6,7 @@ use super::*; use serde_json::Map; #[tokio::test] +#[pa_test_scratch::pa_test] async fn execute_compaction_persists_and_rebuilds() { let registration = faux_registration(); let model = registration.get_model(); @@ -61,6 +62,7 @@ async fn execute_compaction_persists_and_rebuilds() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn rebuilt_live_context_prevents_repeat_auto_compaction_until_new_usage() { let registration = faux_registration(); registration.set_responses(vec![ @@ -177,6 +179,7 @@ async fn rebuilt_live_context_prevents_repeat_auto_compaction_until_new_usage() /// The sink receives every summarizer text delta in order; the final result /// still comes from the terminal assistant message. #[tokio::test] +#[pa_test_scratch::pa_test] async fn execute_compaction_streams_summary_deltas_to_the_sink() { let registration = faux_registration(); let model = registration.get_model(); @@ -225,6 +228,7 @@ async fn execute_compaction_streams_summary_deltas_to_the_sink() { /// streams live, the turn-prefix call never streams raw chunks, and the /// accumulated stream converges to the committed summary. #[tokio::test] +#[pa_test_scratch::pa_test] async fn split_turn_compaction_streams_in_final_order_and_converges() { let registration = faux_registration(); let model = registration.get_model(); @@ -351,6 +355,7 @@ async fn split_turn_compaction_streams_in_final_order_and_converges() { /// An error-stop summarizer response fails the compaction, never an /// empty-summary success. #[tokio::test] +#[pa_test_scratch::pa_test] async fn execute_compaction_fails_on_an_error_summarizer_response() { let registration = faux_registration(); let model = registration.get_model(); @@ -400,6 +405,7 @@ async fn execute_compaction_fails_on_an_error_summarizer_response() { /// The durable row carries the full record — `fromHook: false`, the usage, /// and the file-operation details — not just the summary boundary. #[tokio::test] +#[pa_test_scratch::pa_test] async fn durable_compaction_row_carries_the_ts_record() { let registration = faux_registration(); let model = registration.get_model(); diff --git a/crates/pa-core/src/session_engine/compact_session/tests/prepare_compaction.rs b/crates/pa-core/src/session_engine/compact_session/tests/prepare_compaction.rs index 4bf443514..00145bd35 100644 --- a/crates/pa-core/src/session_engine/compact_session/tests/prepare_compaction.rs +++ b/crates/pa-core/src/session_engine/compact_session/tests/prepare_compaction.rs @@ -7,6 +7,7 @@ use pa_types::session::EntryBase; /// The split arm of the skip guard: a mid-turn cut with no history still has /// the turn prefix to summarize, so the compaction prepares. +#[pa_test_scratch::pa_test] #[test] fn prepare_compaction_split_arm_counts_the_turn_prefix_as_content() { let tmp = tempfile::tempdir().unwrap(); @@ -128,6 +129,7 @@ fn raw_assistant_text_entry(id: &str, text: &str) -> FileEntry { /// The recency anchor pins to the newest kept-tail assistant text: a direction /// flip fails (an older assistant sits in the same kept tail), thinking-only /// assistants skip, long text tail-truncates, and a text-less tail carries none. +#[pa_test_scratch::pa_test] #[test] fn prepare_compaction_anchors_on_the_newest_kept_tail_assistant_text() { // 400-char texts (100 tokens at the chars/4 heuristic) keep the cuts @@ -221,6 +223,7 @@ fn prepare_compaction_anchors_on_the_newest_kept_tail_assistant_text() { /// File-list blocks never reach the update prompt: the stored summary's blocks /// strip, and a file-blocks-only summary leaves no update anchor. +#[pa_test_scratch::pa_test] #[test] fn prepare_compaction_strips_file_blocks_from_the_previous_summary() { let entries = vec![ @@ -254,6 +257,7 @@ fn prepare_compaction_strips_file_blocks_from_the_previous_summary() { /// The iterative update mode activates from a prior compaction: the prior /// summary becomes `previousSummary` and its first kept entry the boundary. +#[pa_test_scratch::pa_test] #[test] fn prepare_compaction_update_mode_anchors_on_the_prior_compaction() { let entries = vec![ @@ -285,6 +289,7 @@ fn prepare_compaction_update_mode_anchors_on_the_prior_compaction() { /// The boundary fallback (the entry after the compaction when the retained /// entry is gone) and the guard (a prior summary alone is enough to run). +#[pa_test_scratch::pa_test] #[test] fn prepare_compaction_boundary_fallback_and_prior_summary_guard() { let entries = vec![ diff --git a/crates/pa-core/src/session_engine/compact_session/tests/second_compaction.rs b/crates/pa-core/src/session_engine/compact_session/tests/second_compaction.rs index b2e8b986e..b4182f936 100644 --- a/crates/pa-core/src/session_engine/compact_session/tests/second_compaction.rs +++ b/crates/pa-core/src/session_engine/compact_session/tests/second_compaction.rs @@ -7,6 +7,7 @@ use super::*; /// A session compacted twice: the second request carries the update prompt /// with the prior summary and summarizes only the conversation since. #[tokio::test] +#[pa_test_scratch::pa_test] async fn second_compaction_updates_the_prior_summary_over_new_history() { let registration = faux_registration(); let model = registration.get_model(); @@ -143,6 +144,7 @@ async fn second_compaction_updates_the_prior_summary_over_new_history() { /// the file lists: the update request carries a STRIPPED `` /// plus the newest retained assistant text in a `` block. #[tokio::test] +#[pa_test_scratch::pa_test] async fn second_compaction_request_carries_the_anchor_and_strips_file_blocks() { let registration = faux_registration(); let model = registration.get_model(); @@ -316,6 +318,7 @@ async fn second_compaction_request_carries_the_anchor_and_strips_file_blocks() { /// A split-turn cut after a prior compaction: the history call runs in /// update mode, while the turn-prefix call stays a plain prefix summary. #[tokio::test] +#[pa_test_scratch::pa_test] async fn second_compaction_split_turn_history_updates_prefix_does_not() { let registration = faux_registration(); let model = registration.get_model(); diff --git a/crates/pa-core/src/session_engine/compact_session/tests/skip_guards.rs b/crates/pa-core/src/session_engine/compact_session/tests/skip_guards.rs index 1da1f1bb2..f4c2c4aa0 100644 --- a/crates/pa-core/src/session_engine/compact_session/tests/skip_guards.rs +++ b/crates/pa-core/src/session_engine/compact_session/tests/skip_guards.rs @@ -6,6 +6,7 @@ use super::*; /// An already-aborted signal cancels the run before any summarizer /// request: the abort marker error surfaces and nothing commits. #[tokio::test] +#[pa_test_scratch::pa_test] async fn execute_compaction_with_pre_aborted_signal_never_runs_the_summarizer() { let registration = faux_registration(); let model = registration.get_model(); @@ -45,6 +46,7 @@ async fn execute_compaction_with_pre_aborted_signal_never_runs_the_summarizer() /// A signal that aborts while the summarizer is in flight cancels the run /// before it commits: the resolved summary never lands as an entry. #[tokio::test] +#[pa_test_scratch::pa_test] async fn execute_compaction_with_late_abort_cancels_before_the_commit() { let registration = faux_registration(); let model = registration.get_model(); @@ -101,6 +103,7 @@ async fn execute_compaction_with_late_abort_cancels_before_the_commit() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn execute_compaction_skips_short_sessions() { let registration = faux_registration(); let model = registration.get_model(); @@ -135,6 +138,7 @@ async fn execute_compaction_skips_short_sessions() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn execute_compaction_skips_when_already_compacted() { let registration = faux_registration(); let model = registration.get_model(); diff --git a/crates/pa-core/src/session_engine/compact_session/tests/split_turn.rs b/crates/pa-core/src/session_engine/compact_session/tests/split_turn.rs index 229e0d8c1..3fbf219b2 100644 --- a/crates/pa-core/src/session_engine/compact_session/tests/split_turn.rs +++ b/crates/pa-core/src/session_engine/compact_session/tests/split_turn.rs @@ -16,6 +16,7 @@ use crate::session_engine::semantic_edges::{ /// turn context behind the TS split marker, with both calls' usage /// summed onto the durable row (TS `compact`'s split arm). #[tokio::test] +#[pa_test_scratch::pa_test] async fn split_turn_compaction_runs_two_summarizer_calls_and_merges_the_turn_context() { let registration = faux_registration(); let model = registration.get_model(); @@ -196,6 +197,7 @@ async fn split_turn_compaction_runs_two_summarizer_calls_and_merges_the_turn_con /// duplicate user message — compacts with a whole-turn cut; the double-represented /// shape lands mid-turn. #[tokio::test] +#[pa_test_scratch::pa_test] async fn injected_custom_turn_cuts_whole_turns_the_double_row_splits() { let registration = faux_registration(); let model = registration.get_model(); @@ -367,6 +369,7 @@ async fn injected_custom_turn_cuts_whole_turns_the_double_row_splits() { /// A split turn with no history makes only the turn-prefix wire call and /// stands in the literal "No prior history." for the history half. #[tokio::test] +#[pa_test_scratch::pa_test] async fn split_turn_without_history_makes_only_the_prefix_call() { let registration = faux_registration(); let model = registration.get_model(); @@ -536,6 +539,7 @@ fn begun_compaction_id(events: &[LedgerEvent]) -> String { /// `summaryCall` + `compactionRecorded`: the ledger lands before the /// compaction entry). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_split_turn_compaction_commits_both_summary_slices_before_its_entry() { let registration = faux_registration(); let model = registration.get_model(); @@ -690,6 +694,7 @@ async fn a_split_turn_compaction_commits_both_summary_slices_before_its_entry() /// records `cancelled` (TS's catch: the abort settles the compaction, and /// no summary request stays committed for the next turn to attach to). #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_aborted_compaction_fails_its_slices_and_records_cancelled() { let registration = faux_registration(); let model = registration.get_model(); diff --git a/crates/pa-core/src/session_engine/compaction.rs b/crates/pa-core/src/session_engine/compaction.rs index 36f698148..314ed97d2 100644 --- a/crates/pa-core/src/session_engine/compaction.rs +++ b/crates/pa-core/src/session_engine/compaction.rs @@ -709,6 +709,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn estimate_context_tokens_anchors_on_the_last_valid_usage() { let messages = vec![ @@ -725,6 +726,7 @@ mod tests { assert_eq!(estimate.tokens, 2); } + #[pa_test_scratch::pa_test] #[test] fn threshold_crosses_the_reserve_headroom() { // 126_010 tokens on a 128k window with a 127_500 reserve leaves @@ -757,6 +759,7 @@ mod tests { assert!(!threshold_compaction_due(&messages, 0, 0, &settings)); } + #[pa_test_scratch::pa_test] #[test] fn threshold_fires_before_a_combined_limit_overflow() { // The live 400 shape: 1_017_457 input tokens under the old trigger @@ -792,6 +795,7 @@ mod tests { )); } + #[pa_test_scratch::pa_test] #[test] fn threshold_percentage_ceiling_guards_large_windows() { // Past 95% of a large window the percentage ceiling fires before @@ -801,6 +805,7 @@ mod tests { assert!(!should_compact(996_000, 1_048_576, 32_000, &settings)); } + #[pa_test_scratch::pa_test] #[test] fn threshold_combined_ceiling_guards_small_windows() { // A 128k window with a 32k output budget: pure 95% (124_518) would under-reserve @@ -811,6 +816,7 @@ mod tests { assert!(!should_compact(81_000, 131_072, 32_768, &settings)); } + #[pa_test_scratch::pa_test] #[test] fn threshold_headroom_floor_covers_estimate_error() { // A tiny reserve still keeps the 4_096 estimate-error floor: @@ -836,6 +842,7 @@ mod tests { )); } + #[pa_test_scratch::pa_test] #[test] fn stale_pre_compaction_usage_never_retriggers() { let settings = CompactionSettings { @@ -858,6 +865,7 @@ mod tests { assert!(threshold_compaction_due(&messages, 128_000, 0, &settings)); } + #[pa_test_scratch::pa_test] #[test] fn token_estimation() { let user = AgentMessage::User(pa_types::ai::UserMessage { @@ -878,6 +886,7 @@ mod tests { assert_eq!(calculate_context_tokens(&usage), 100); } + #[pa_test_scratch::pa_test] #[test] fn should_compact_threshold() { let settings = CompactionSettings::default(); @@ -891,6 +900,7 @@ mod tests { assert!(!should_compact(1, 0, 0, &settings)); } + #[pa_test_scratch::pa_test] #[test] fn cut_points_never_tool_results() { let entries = vec![ @@ -920,6 +930,7 @@ mod tests { assert_eq!(points, vec![0, 1]); } + #[pa_test_scratch::pa_test] #[test] fn cut_point_keeps_recent_tokens() { let entries = vec![ @@ -948,6 +959,7 @@ mod tests { assert_eq!(keep_small.turn_start_index, Some(2)); } + #[pa_test_scratch::pa_test] #[test] fn summarization_prompt_shapes() { let initial = build_summarization_prompt(None, None); @@ -960,6 +972,7 @@ mod tests { assert!(custom.contains("focus on tests")); } + #[pa_test_scratch::pa_test] #[test] fn last_assistant_usage_skips_aborted() { let entries = vec![ @@ -1004,6 +1017,7 @@ mod tests { .unwrap() } + #[pa_test_scratch::pa_test] #[test] fn metadata_cut_before_user_preserves_exact_first_kept_without_split() { let entries = vec![ @@ -1037,6 +1051,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn metadata_cut_before_assistant_preserves_real_split() { let entries = vec![ @@ -1053,6 +1068,7 @@ mod tests { assert_eq!(cut.turn_start_index, Some(2)); } + #[pa_test_scratch::pa_test] #[test] fn metadata_cut_stops_at_each_meaningful_boundary_before_later_user() { let mut boundaries = vec![ diff --git a/crates/pa-core/src/session_engine/compaction_exec.rs b/crates/pa-core/src/session_engine/compaction_exec.rs index c1370c2b4..4c1bb9eac 100644 --- a/crates/pa-core/src/session_engine/compaction_exec.rs +++ b/crates/pa-core/src/session_engine/compaction_exec.rs @@ -484,6 +484,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn add_assistant_usage_saturates_token_totals() { let mut total = pa_types::ai::Usage { @@ -502,6 +503,7 @@ mod tests { assert_eq!(total.output, 1); } + #[pa_test_scratch::pa_test] #[test] fn compaction_entry_records_the_ts_wire_fields() { let usage = pa_types::ai::Usage { @@ -543,6 +545,7 @@ mod tests { /// The history request carries the recency anchor after the previous /// summary; a missing anchor adds no block. + #[pa_test_scratch::pa_test] #[test] fn summarization_request_carries_the_recent_state_anchor() { let request = build_summarization_request( @@ -578,6 +581,7 @@ mod tests { /// The serialized `details` block byte-matches the TS literal order /// (`readFiles` first): struct field order is the wire byte order. + #[pa_test_scratch::pa_test] #[test] fn details_serialize_in_the_ts_key_order() { let details = CompactionDetails { @@ -591,6 +595,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn compact_summarizes_prefix_and_returns_result() { let messages = vec![user("one"), user("two"), user("three")]; let entries: Vec = messages @@ -660,6 +665,7 @@ mod tests { /// The turn-prefix request never carries the checkpoint prompt, a /// previous summary, or the kernel note. + #[pa_test_scratch::pa_test] #[test] fn turn_prefix_request_shape() { let messages = vec![user("big turn"), user("more of the turn")]; @@ -678,6 +684,7 @@ mod tests { assert!(!text.contains("the Python kernel keeps running")); } + #[pa_test_scratch::pa_test] #[test] fn split_summary_marker_format() { assert_eq!( @@ -689,6 +696,7 @@ mod tests { /// A call without usage contributes nothing; no calls means no /// recorded usage. + #[pa_test_scratch::pa_test] #[test] fn usage_summing_over_slices() { let usage = |input: u64, output: u64, cost: f64| pa_types::ai::Usage { @@ -729,6 +737,7 @@ mod tests { assert_eq!(summed_usage(&[slice("a", None)]), None); } + #[pa_test_scratch::pa_test] #[test] fn summary_options_carry_the_owning_session_id() { let options = summary_stream_options(None, None, 512, Some("session-1")); @@ -739,6 +748,7 @@ mod tests { .is_none()); } + #[pa_test_scratch::pa_test] #[test] fn summarization_request_shape() { let messages = vec![user("hello"), user("world")]; diff --git a/crates/pa-core/src/session_engine/compaction_outcome_tests.rs b/crates/pa-core/src/session_engine/compaction_outcome_tests.rs index 27d49a273..93cb0cf00 100644 --- a/crates/pa-core/src/session_engine/compaction_outcome_tests.rs +++ b/crates/pa-core/src/session_engine/compaction_outcome_tests.rs @@ -51,6 +51,7 @@ fn seeded_assistant() -> SessionAgentMessage { }) } +#[pa_test_scratch::pa_test] #[test] fn outcome_row_shape_matches_ts() { let row = create_compaction_outcome_message( @@ -77,6 +78,7 @@ fn outcome_row_shape_matches_ts() { /// The row lands in the entry chain and on the live loop context, a rebuild /// keeps it, and the LLM conversion drops it — the model never sees the disclosure. #[tokio::test] +#[pa_test_scratch::pa_test] async fn record_appends_row_to_entries_and_live_context_but_not_llm_input() { let tmp = tempfile::tempdir().unwrap(); let session = scripted_session_over(SessionManager::in_memory(tmp.path())).await; @@ -135,6 +137,7 @@ async fn record_appends_row_to_entries_and_live_context_but_not_llm_input() { /// A failed disclosure append cannot publish a row absent from durable history. #[tokio::test] +#[pa_test_scratch::pa_test] async fn record_refuses_a_failed_disk_write_without_publishing() { let tmp = tempfile::tempdir().unwrap(); let sessions = tmp.path().join("sessions"); @@ -159,6 +162,7 @@ async fn record_refuses_a_failed_disk_write_without_publishing() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn message_end_persist_failure_refuses_publication() { let tmp = tempfile::tempdir().unwrap(); let sessions = tmp.path().join("sessions"); diff --git a/crates/pa-core/src/session_engine/compaction_threshold_tests.rs b/crates/pa-core/src/session_engine/compaction_threshold_tests.rs index 6a82503c6..dc74f1cd6 100644 --- a/crates/pa-core/src/session_engine/compaction_threshold_tests.rs +++ b/crates/pa-core/src/session_engine/compaction_threshold_tests.rs @@ -1,5 +1,6 @@ use super::*; +#[pa_test_scratch::pa_test] #[test] fn default_percentage_preserves_the_current_threshold_and_strict_boundary() { let settings = CompactionSettings::default(); @@ -18,6 +19,7 @@ fn default_percentage_preserves_the_current_threshold_and_strict_boundary() { } } +#[pa_test_scratch::pa_test] #[test] fn custom_percentages_obey_both_ceilings_as_model_limits_change() { for (percent, expected_by_model) in [ @@ -44,6 +46,7 @@ fn custom_percentages_obey_both_ceilings_as_model_limits_change() { } } +#[pa_test_scratch::pa_test] #[test] fn invalid_runtime_percentages_fall_back_without_losing_headroom() { for percent in [ @@ -71,6 +74,7 @@ fn invalid_runtime_percentages_fall_back_without_losing_headroom() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn saved_percentage_applies_to_existing_sessions_without_changing_manual_budgets() { let dir = tempfile::tempdir().unwrap(); let agent_dir = dir.path().join("agent"); @@ -114,6 +118,7 @@ async fn saved_percentage_applies_to_existing_sessions_without_changing_manual_b )); } +#[pa_test_scratch::pa_test] #[test] fn low_percentages_leave_room_for_retained_history_and_both_summaries() { for percent in [1.0, 5.0, 10.0] { diff --git a/crates/pa-core/src/session_engine/compaction_unblocked_tests.rs b/crates/pa-core/src/session_engine/compaction_unblocked_tests.rs index 9c43fbc6a..333c03c40 100644 --- a/crates/pa-core/src/session_engine/compaction_unblocked_tests.rs +++ b/crates/pa-core/src/session_engine/compaction_unblocked_tests.rs @@ -140,6 +140,7 @@ fn spawn_compact( /// to `retained_entries()` reads (what `register_spawn` walks), and the /// committed context survives a file reopen. #[tokio::test(flavor = "multi_thread", worker_threads = 4)] +#[pa_test_scratch::pa_test] async fn mid_summarize_writes_are_durable_now_and_ride_the_retained_tail() { let (engine, tmp) = held_engine(true, 3).await; let session_file = engine @@ -206,6 +207,7 @@ async fn mid_summarize_writes_are_durable_now_and_ride_the_retained_tail() { /// A branch move mid-window is a structural conflict: the compaction /// retries from PREPARE and commits against the moved-to tree. #[tokio::test(flavor = "multi_thread", worker_threads = 4)] +#[pa_test_scratch::pa_test] async fn a_branch_move_mid_summarize_conflicts_and_commits_against_the_new_tree() { let (engine, _tmp) = held_engine(false, 6).await; let mut summarizer = held_summarizer(1, vec![follow_up("## Goal\nretry summary")]); @@ -254,6 +256,7 @@ async fn a_branch_move_mid_summarize_conflicts_and_commits_against_the_new_tree( /// Overlapping compactions serialize: the second waits for the /// in-flight run instead of summarizing the same prefix again. #[tokio::test(flavor = "multi_thread", worker_threads = 4)] +#[pa_test_scratch::pa_test] async fn a_second_compaction_waits_for_the_in_flight_one() { let (engine, _tmp) = held_engine(false, 3).await; // The follow-up response would let a racing second summarizer finish. @@ -289,6 +292,7 @@ async fn a_second_compaction_waits_for_the_in_flight_one() { /// A branch rebuild during every attempt: the compaction fails with the /// retry-cap error after three summarizer calls, never committing. #[tokio::test(flavor = "multi_thread", worker_threads = 4)] +#[pa_test_scratch::pa_test] async fn repeated_branch_conflicts_fail_the_compaction_after_three_attempts() { let (engine, _tmp) = held_engine(false, 6).await; let mut summarizer = held_summarizer(3, Vec::new()); @@ -334,6 +338,7 @@ async fn repeated_branch_conflicts_fail_the_compaction_after_three_attempts() { /// Public branch replacement waits for the pending transaction, rather than /// publishing a live view assembled against an unfinished compaction window. #[tokio::test(flavor = "multi_thread", worker_threads = 4)] +#[pa_test_scratch::pa_test] async fn public_branch_replacement_waits_for_the_compaction_transaction() { let (engine, _tmp) = held_engine(false, 6).await; let entries = engine.entries().await; diff --git a/crates/pa-core/src/session_engine/compaction_utils.rs b/crates/pa-core/src/session_engine/compaction_utils.rs index 1964614c8..4d1dc5596 100644 --- a/crates/pa-core/src/session_engine/compaction_utils.rs +++ b/crates/pa-core/src/session_engine/compaction_utils.rs @@ -349,6 +349,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn file_ops_from_edit_tool_call() { let mut ops = FileOperations::default(); @@ -361,6 +362,7 @@ mod tests { assert!(format_file_operations(&read, &modified).contains("")); } + #[pa_test_scratch::pa_test] #[test] fn file_ops_from_kernel_diffs() { let mut ops = FileOperations::default(); @@ -382,6 +384,7 @@ mod tests { assert!(read.iter().all(|path| !modified.contains(path))); } + #[pa_test_scratch::pa_test] #[test] fn serialization_format() { let messages = vec![user("do the thing"), assistant_with_tool_call()]; @@ -445,6 +448,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn tool_result_labels_carry_the_tool_name_and_error_marker() { assert_eq!( @@ -467,6 +471,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn repeated_same_tool_calls_pair_by_index() { let messages = vec![ @@ -483,6 +488,7 @@ mod tests { assert_eq!(serialize_conversation(&messages), expected); } + #[pa_test_scratch::pa_test] #[test] fn orphan_tool_result_falls_back_to_the_name_only_label() { let messages = vec![ @@ -497,6 +503,7 @@ mod tests { assert_eq!(serialize_conversation(&messages), expected); } + #[pa_test_scratch::pa_test] #[test] fn file_lists_cap_combined_chars_dropping_read_only_first() { // 37-char entries: each contributes 38 chars, so the cap keeps @@ -539,6 +546,7 @@ mod tests { assert!(modified_files.is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn strip_file_list_blocks_removes_read_and_modified_blocks() { assert_eq!( @@ -581,6 +589,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn tool_result_truncated() { let long = "x".repeat(10_000); diff --git a/crates/pa-core/src/session_engine/context_strategy.rs b/crates/pa-core/src/session_engine/context_strategy.rs index 0bb6de869..f3056ecc4 100644 --- a/crates/pa-core/src/session_engine/context_strategy.rs +++ b/crates/pa-core/src/session_engine/context_strategy.rs @@ -1016,6 +1016,7 @@ mod proposed_summary_tests { serde_json::from_value(json!({"role":"compactionSummary","summary":"identical summary","tokensBefore":42,"timestamp":timestamp,"futureSummaryMetadata":{"nested":[1,2,3]}})).unwrap() } + #[pa_test_scratch::pa_test] #[test] fn identical_older_summary_is_unchanged_after_reordered_json_proposal_binding() { let old = summary(17); @@ -1034,6 +1035,7 @@ mod proposed_summary_tests { .contains("__pa_proposed_summary_")); } + #[pa_test_scratch::pa_test] #[test] fn same_key_with_unrelated_token_is_preserved() { let mut view = vec![summary(18), summary(17)]; @@ -1048,6 +1050,7 @@ mod proposed_summary_tests { assert_eq!(view[1], old); } + #[pa_test_scratch::pa_test] #[test] fn moving_provenance_to_another_role_is_rejected_before_write() { let mut view = vec![summary(18)]; @@ -1063,6 +1066,7 @@ mod proposed_summary_tests { assert!(proposal.resolve(&mut view).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn duplicate_provenance_is_rejected_before_write() { let mut view = vec![summary(18)]; @@ -1071,6 +1075,7 @@ mod proposed_summary_tests { assert!(proposal.resolve(&mut view).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn missing_provenance_never_falls_back_to_identical_body() { let mut view = vec![summary(18), summary(18)]; @@ -1079,6 +1084,7 @@ mod proposed_summary_tests { assert!(proposal.resolve(&mut view).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn native_archive_does_not_claim_a_retained_summary() { let old = summary(17); diff --git a/crates/pa-core/src/session_engine/context_strategy/defaults_tests.rs b/crates/pa-core/src/session_engine/context_strategy/defaults_tests.rs index 7a5609993..abe6b242d 100644 --- a/crates/pa-core/src/session_engine/context_strategy/defaults_tests.rs +++ b/crates/pa-core/src/session_engine/context_strategy/defaults_tests.rs @@ -18,6 +18,7 @@ async fn configure(f: &Fixture, model: &pa_types::ai::Model, plugins: Value) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn server_rejections_and_uncertain_outcomes_never_replay_or_mutate_history() { for (status, body) in [ (401, r#"{"error":{"code":"invalid_api_key"}}"#), @@ -53,6 +54,7 @@ async fn server_rejections_and_uncertain_outcomes_never_replay_or_mutate_history } #[tokio::test] +#[pa_test_scratch::pa_test] async fn explicit_chain_and_disabled_compactors_override_builtin_defaults() { for plugins in [ json!({"default_context":{"config":{"compactors":["standard_compaction/standard"]}}}), @@ -90,6 +92,7 @@ async fn explicit_chain_and_disabled_compactors_override_builtin_defaults() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn default_server_cancellation_and_retirement_close_pending_request_without_fallback() { use tokio::io::{AsyncReadExt, AsyncWriteExt}; for retire in [false, true] { @@ -185,6 +188,7 @@ async fn default_server_cancellation_and_retirement_close_pending_request_withou } #[tokio::test] +#[pa_test_scratch::pa_test] async fn explicit_server_route_mismatch_is_terminal_and_null_disables_probe() { for disable in [false, true] { let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap(); @@ -239,6 +243,7 @@ async fn explicit_server_route_mismatch_is_terminal_and_null_disables_probe() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn default_server_inherits_resolved_auth_headers_without_compaction_settings() { let (base, mut requests, server) = json_server(r#"{"error":{"code":"unsupported_operation"}}"#, 404).await; diff --git a/crates/pa-core/src/session_engine/context_strategy/input.rs b/crates/pa-core/src/session_engine/context_strategy/input.rs index b62f5d6d1..ce68254fe 100644 --- a/crates/pa-core/src/session_engine/context_strategy/input.rs +++ b/crates/pa-core/src/session_engine/context_strategy/input.rs @@ -265,6 +265,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn refs_clone_original_native_body_without_any_json_normalization() { let owner = target(ContextDataMode::RefsV1); @@ -277,6 +278,7 @@ mod tests { assert!(serde_json::to_string(&descriptor).unwrap().len() < 1024); } + #[pa_test_scratch::pa_test] #[test] fn refs_reject_every_forged_scope_and_cross_call_or_typed_slot() { let owner = target(ContextDataMode::RefsV1); @@ -315,6 +317,7 @@ mod tests { .is_err()); } + #[pa_test_scratch::pa_test] #[test] fn refs_allow_only_bounded_ordered_nonoverlapping_spans() { let owner = target(ContextDataMode::RefsV1); @@ -347,6 +350,7 @@ mod tests { .contains("span resource")); } + #[pa_test_scratch::pa_test] #[test] fn json_callbacks_keep_full_bodies_and_all_modes_reject_oversized_controls() { let owner = target(ContextDataMode::Json); @@ -373,6 +377,7 @@ mod tests { .is_none()); } + #[pa_test_scratch::pa_test] #[test] fn archive_headers_keep_large_ciphertext_rest_and_coverage_native() { let owner = target(ContextDataMode::RefsV1); diff --git a/crates/pa-core/src/session_engine/context_strategy/startup.rs b/crates/pa-core/src/session_engine/context_strategy/startup.rs index 56debb103..af161e52d 100644 --- a/crates/pa-core/src/session_engine/context_strategy/startup.rs +++ b/crates/pa-core/src/session_engine/context_strategy/startup.rs @@ -140,6 +140,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn startup_mixed_inputs_require_exact_order_and_preserve_prefix() { let mut manager = SessionManager::in_memory(std::path::Path::new("/project")); @@ -186,6 +187,7 @@ mod tests { .is_err()); } + #[pa_test_scratch::pa_test] #[test] fn startup_empty_accepts_bootstrap_but_not_unproven_body_or_archive() { let mut manager = SessionManager::in_memory(std::path::Path::new("/project")); diff --git a/crates/pa-core/src/session_engine/context_strategy/startup_tests.rs b/crates/pa-core/src/session_engine/context_strategy/startup_tests.rs index 7bf9f0eba..6de0b11cb 100644 --- a/crates/pa-core/src/session_engine/context_strategy/startup_tests.rs +++ b/crates/pa-core/src/session_engine/context_strategy/startup_tests.rs @@ -252,6 +252,7 @@ async fn replay_and_prompt(f: &StartupFixture, engine: &SessionEngine, admitted: } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_leaf_uses_stored_strategy_and_prefix_then_replays_exact_admitted_user_once() { let f = StartupFixture::new(OBSERVING, "policy/b"); let mut manager = f.manager(); @@ -301,6 +302,7 @@ async fn startup_leaf_uses_stored_strategy_and_prefix_then_replays_exact_admitte } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_empty_has_no_user_or_leaf_then_replays_first_admitted_user_once() { let f = StartupFixture::new(OBSERVING, "policy/a"); let mut manager = f.manager(); @@ -332,6 +334,7 @@ async fn startup_empty_has_no_user_or_leaf_then_replays_first_admitted_user_once } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_current_default_keeps_the_full_existing_branch() { let f = StartupFixture::new(OBSERVING, "policy/a"); let mut manager = f.manager(); @@ -358,6 +361,7 @@ async fn startup_current_default_keeps_the_full_existing_branch() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_rejects_empty_missing_and_nonancestor_leaf_before_callback() { for kind in ["empty", "missing", "nonancestor"] { let f = StartupFixture::new(FORBIDDEN, "policy/a"); @@ -377,6 +381,7 @@ async fn startup_rejects_empty_missing_and_nonancestor_leaf_before_callback() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_leaf_requires_explicit_exact_suffix_admission_ids_before_callback() { for wrong_id in [false, true] { let f = StartupFixture::new(FORBIDDEN, "policy/a"); @@ -390,6 +395,7 @@ async fn startup_leaf_requires_explicit_exact_suffix_admission_ids_before_callba } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_empty_rejects_unadmitted_old_history_before_callback() { let f = StartupFixture::new(FORBIDDEN, "policy/a"); let mut manager = f.manager(); @@ -400,6 +406,7 @@ async fn startup_empty_rejects_unadmitted_old_history_before_callback() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_disabled_stored_strategy_fails_closed_instead_of_using_global_default() { let f = StartupFixture::new(FORBIDDEN, "default_context/rolling"); let mut manager = f.manager(); @@ -416,6 +423,7 @@ async fn startup_disabled_stored_strategy_fails_closed_instead_of_using_global_d } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_current_rejects_admission_ids_before_callback() { let f = StartupFixture::new(FORBIDDEN, "policy/a"); let mut manager = f.manager(); @@ -425,6 +433,7 @@ async fn startup_current_rejects_admission_ids_before_callback() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_empty_accepts_bootstrap_metadata_and_uses_stored_strategy() { let f = StartupFixture::new(OBSERVING, "policy/b"); let mut manager = f.manager(); @@ -497,6 +506,7 @@ async fn assert_rejected_view_unchanged( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_rebuild_at_keeps_full_rows_and_prefix_and_rejects_invalid_proof_atomically() { let f = StartupFixture::new(OBSERVING, "policy/b"); let mut manager = f.manager(); @@ -548,6 +558,7 @@ async fn startup_rebuild_at_keeps_full_rows_and_prefix_and_rejects_invalid_proof } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_window_restore_at_keeps_full_rows_and_prefix_and_rejects_foreign_or_invalid_views() { use crate::session::window::WindowedSessionStore; @@ -684,6 +695,7 @@ fn assert_receipt_a(receipts: &SelectionReceipts) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_selection_ack_failure_precedes_strategy_callbacks_for_fresh_and_saved_choices() { for saved in [false, true] { let f = StartupFixture::new(FORBIDDEN, if saved { "policy/b" } else { "policy/a" }); @@ -713,6 +725,7 @@ async fn startup_selection_ack_failure_precedes_strategy_callbacks_for_fresh_and } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_selection_ack_success_is_recorded_before_first_strategy_callback() { for saved in [false, true] { let f = StartupFixture::new(FORBIDDEN, if saved { "policy/b" } else { "policy/a" }); @@ -742,6 +755,7 @@ async fn startup_selection_ack_success_is_recorded_before_first_strategy_callbac } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_selection_ack_uses_pinned_a_without_inventing_mirror_selection_rows() { for saved in [false, true] { let f = StartupFixture::new(OBSERVING, if saved { "policy/b" } else { "policy/a" }); @@ -788,6 +802,7 @@ async fn startup_selection_ack_uses_pinned_a_without_inventing_mirror_selection_ } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_without_selection_ack_keeps_default_sdk_choice_append() { let f = StartupFixture::new(OBSERVING, "policy/a"); let mut manager = f.manager(); @@ -856,6 +871,7 @@ async fn startup_native_export( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_native_optchat_sources_only_prefix_then_includes_admitted_user_once_at_model() { let f = StartupFixture::new("return {}", "optchat/tree"); std::fs::create_dir_all(f.cwd.join(".prime/agent")).unwrap(); @@ -1009,6 +1025,7 @@ async fn startup_native_optchat_sources_only_prefix_then_includes_admitted_user_ } #[tokio::test] +#[pa_test_scratch::pa_test] async fn startup_invalid_boundary_does_not_invoke_external_selection_ack() { let f = StartupFixture::new(FORBIDDEN, "policy/a"); let mut manager = f.manager(); diff --git a/crates/pa-core/src/session_engine/context_strategy/tests.rs b/crates/pa-core/src/session_engine/context_strategy/tests.rs index 667981705..132759713 100644 --- a/crates/pa-core/src/session_engine/context_strategy/tests.rs +++ b/crates/pa-core/src/session_engine/context_strategy/tests.rs @@ -103,6 +103,7 @@ end}}} "; #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_engine_orders_failures_and_commits_once_then_restores() { let f = Fixture::new(ORDERED, "policy/view", true).await; let before = f.engine.session.entries().await; @@ -154,6 +155,7 @@ async fn public_engine_orders_failures_and_commits_once_then_restores() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn ineligible_decline_does_no_work_and_all_failures_preserve_exact_state() { let decline=ORDERED.replace("{status='failure',reason='local failure'}","{status='decline'}").replace("{status='failure',reason='render failure'}","{status='decline'}").replace("{status='success',summary='accepted third',first_kept_entry_id=input.entries[#input.entries].id}","{status='decline'}"); let f = Fixture::new(&decline, "policy/view", true).await; @@ -217,6 +219,7 @@ async fn ready(f: &Fixture) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn cancellation_and_retirement_are_terminal_not_fallback() { for retire in [false, true] { let f = Fixture::new(HELD, "policy/view", true).await; @@ -252,6 +255,7 @@ async fn cancellation_and_retirement_are_terminal_not_fallback() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn selected_strategy_changes_startup_branch_and_actual_model_view_not_history() { let source = r"return {context_strategies={{name='last',run=function(input) if input.stage=='restore' then return {accepted=true} end @@ -292,6 +296,7 @@ async fn selected_strategy_changes_startup_branch_and_actual_model_view_not_hist } #[tokio::test] +#[pa_test_scratch::pa_test] async fn standard_native_adapter_is_actual_third_fallback_and_default_skip_parity() { let source = ORDERED.replace("'policy/third'", "'standard_compaction/standard'"); let f = Fixture::new(&source, "policy/view", false).await; @@ -397,6 +402,7 @@ async fn gated_compact( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn descendant_append_is_retained_but_branch_departure_reprepares_without_fallback() { let f = Fixture::new(GATED, "policy/view", true).await; let (gate, task) = gated_compact(&f).await; @@ -447,6 +453,7 @@ async fn descendant_append_is_retained_but_branch_departure_reprepares_without_f } #[tokio::test] +#[pa_test_scratch::pa_test] async fn intervening_compaction_reprepares_instead_of_falling_through() { let f = Fixture::new(GATED, "policy/view", true).await; let (gate, task) = gated_compact(&f).await; @@ -487,6 +494,7 @@ async fn intervening_compaction_reprepares_instead_of_falling_through() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn failed_durable_append_never_publishes_candidate() { let f = Fixture::new(ORDERED, "policy/view", true).await; let before = f.state().await; @@ -573,6 +581,7 @@ async fn json_server( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn native_archive_restores_raw_prefix_and_appends_only_uncovered_continuation() { let envelope = r#"{"id":"response_1","created_at":1,"object":"response.compaction","output":[{"type":"message","id":"kept","role":"user","content":[{"type":"input_text","text":"kept native"}]},{"type":"compaction","id":"cmp","encrypted_content":"opaque-\u0061","future":1.2300}],"usage":{"input_tokens":20,"output_tokens":7,"total_tokens":27}}"#; let envelope = envelope.replace("opaque-", &format!("opaque-{}", "x".repeat(24_000))); @@ -783,6 +792,7 @@ async fn native_archive_restores_raw_prefix_and_appends_only_uncovered_continuat } #[tokio::test] +#[pa_test_scratch::pa_test] async fn invalid_archive_restore_does_not_adopt_branch_or_publish_view() { let f = Fixture::new(ORDERED, "policy/view", true).await; f.compact(None).await.unwrap(); @@ -807,6 +817,7 @@ async fn invalid_archive_restore_does_not_adopt_branch_or_publish_view() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn selected_strategy_is_durable_before_compaction_and_not_reselected_from_global_settings() { let source = ORDERED.replace( "if input.stage=='assemble' then return {messages=input.messages} end", @@ -866,6 +877,7 @@ async fn selected_strategy_is_durable_before_compaction_and_not_reselected_from_ } #[tokio::test] +#[pa_test_scratch::pa_test] async fn strategy_rejection_or_assembly_failure_before_commit_preserves_exact_state() { for source in [ ORDERED.replace("return {accepted=input.archive.version==1}","return {accepted=false}"), @@ -921,6 +933,7 @@ async fn reopened(f: &Fixture) -> SessionEngine { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn explicit_selection_is_durable_and_restores_the_exact_selected_view() { let f = Fixture::new(SWITCHABLE, "policy/view", true).await; let before = f.engine.session.entries().await; @@ -963,6 +976,7 @@ async fn explicit_selection_is_durable_and_restores_the_exact_selected_view() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn selection_validation_and_durable_append_failures_leave_old_choice_and_view_intact() { let f = Fixture::new(SWITCHABLE, "policy/view", true).await; let before = f.state().await; @@ -1019,6 +1033,7 @@ fn policy_enabled(f: &Fixture, enabled: bool) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn explicit_disable_removes_contributions_and_refuses_model_work_until_explicit_selection() { let f = Fixture::new(SWITCHABLE, "policy/view", true).await; let before = f.state().await; @@ -1122,6 +1137,7 @@ async fn gated_selection(f: &Fixture) -> (Arc, tokio::task::JoinHandle1 do table.remove(m,1) end;return {messages=m} end @@ -1472,6 +1493,7 @@ async fn switching_strategy_uses_canonical_source_not_a_foreign_archive_or_hidde } #[tokio::test] +#[pa_test_scratch::pa_test] async fn invalid_settings_preserve_last_valid_sources_but_removing_a_source_retires_it() { let f = Fixture::new(SWITCHABLE, "policy/view", true).await; let path = f.agent.join("settings.json"); @@ -1536,6 +1558,7 @@ async fn invalid_settings_preserve_last_valid_sources_but_removing_a_source_reti } #[tokio::test] +#[pa_test_scratch::pa_test] async fn direct_agent_run_admitted_during_preparation_fences_selection_publication() { let f = Fixture::new(SWITCHABLE, "policy/view", true).await; let (gate, selection) = gated_selection(&f).await; @@ -1576,6 +1599,7 @@ async fn direct_agent_run_admitted_during_preparation_fences_selection_publicati } #[tokio::test] +#[pa_test_scratch::pa_test] async fn mixed_reload_retires_disabled_a_and_keeps_the_last_valid_enabled_b_generation() { let f = Fixture::new(SWITCHABLE, "policy/view", true).await; let path = f.agent.join("settings.json"); @@ -1643,6 +1667,7 @@ const REFERENCE_VIEW: &str = r"return {context_strategies={{name='view',context_ end}}}"; #[tokio::test] +#[pa_test_scratch::pa_test] async fn reference_strategy_selects_explicit_spans_but_keeps_original_canonical_rows() { let source=REFERENCE_VIEW.replace("return {messages=input.messages}", "if input.messages.count>1 then input.messages.spans={{first=2,count=input.messages.count-1}} end; return {messages=input.messages}"); @@ -1669,6 +1694,7 @@ async fn reference_strategy_selects_explicit_spans_but_keeps_original_canonical_ } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reference_replay_is_rejected_before_actual_provider_or_selection_publication() { let source = REFERENCE_VIEW .replace( @@ -1720,6 +1746,7 @@ async fn reference_replay_is_rejected_before_actual_provider_or_selection_public } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reference_compactors_cancel_or_retire_without_fallback_or_commit() { let source = HELD .replace("name='hold',run", "name='hold',context_data='refs_v1',run") @@ -1767,6 +1794,7 @@ async fn reference_compactors_cancel_or_retire_without_fallback_or_commit() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn large_legacy_callback_fails_explicitly_and_builtin_name_override_keeps_body_contract() { let f = Fixture::new(REFERENCE_VIEW, "policy/view", false).await; let source = r"return {context_strategies={{name='rolling',run=function(input) @@ -1806,6 +1834,7 @@ async fn large_legacy_callback_fails_explicitly_and_builtin_name_override_keeps_ } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reference_model_echo_matches_prior_tool_image_signature_conversion_and_exact_controls() { let source=REFERENCE_VIEW.replace("return {messages=input.messages}", "if input.phase=='model' then assert(input.instructions=='EXACT PROMPT' and input.tools[1].name=='actual_tool' and input.output_tokens==77) end; return {messages=input.messages}"); @@ -1859,6 +1888,7 @@ async fn reference_model_echo_matches_prior_tool_image_signature_conversion_and_ } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reference_default_restore_keeps_a_large_unknown_archive_body_out_of_lua() { let f = Fixture::new(REFERENCE_VIEW, "policy/view", false).await; let plugins = f.engine.session.plugins.as_ref().unwrap(); @@ -1899,6 +1929,7 @@ async fn reference_default_restore_keeps_a_large_unknown_archive_body_out_of_lua } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reference_selected_disable_fails_closed_until_explicit_recovery() { let f = Fixture::new(REFERENCE_VIEW, "policy/view", true).await; let before = f.state().await; @@ -1943,6 +1974,7 @@ async fn reference_selected_disable_fails_closed_until_explicit_recovery() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn oversized_legacy_compactor_remains_a_failed_stage_not_a_chain_bypass() { let source = r"local called=0; return {exports={{name='calls',run=function()return called end}}, compactors={{name='body',run=function(input)called=called+1; assert(input.messages[1].content=='old first'); return {status='failure',reason='body callback ran'} end}}, @@ -2001,6 +2033,7 @@ async fn oversized_legacy_compactor_remains_a_failed_stage_not_a_chain_bypass() } #[tokio::test] +#[pa_test_scratch::pa_test] async fn before_model_refreshes_foreign_committed_rows_without_appending() { struct Tail(std::sync::Mutex>); impl crate::session::manager::SessionEntryWriter for Tail { diff --git a/crates/pa-core/src/session_engine/engine/append_system_tests.rs b/crates/pa-core/src/session_engine/engine/append_system_tests.rs index dee3f1ead..4bcdcbfb6 100644 --- a/crates/pa-core/src/session_engine/engine/append_system_tests.rs +++ b/crates/pa-core/src/session_engine/engine/append_system_tests.rs @@ -100,6 +100,7 @@ async fn assert_prompt_case(case: PromptCase) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn append_system_global_reaches_provider() { assert_prompt_case(PromptCase { custom_system: true, @@ -112,6 +113,7 @@ async fn append_system_global_reaches_provider() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn append_system_project_overrides_global() { assert_prompt_case(PromptCase { custom_system: true, @@ -124,6 +126,7 @@ async fn append_system_project_overrides_global() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn append_system_explicit_overrides_files() { assert_prompt_case(PromptCase { custom_system: true, @@ -136,6 +139,7 @@ async fn append_system_explicit_overrides_files() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn append_system_explicit_file_is_resolved() { let tmp = tempfile::tempdir().unwrap(); let path = tmp.path().join("override.md"); @@ -151,6 +155,7 @@ async fn append_system_explicit_file_is_resolved() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn append_system_empty_project_suppresses_global() { assert_prompt_case(PromptCase { custom_system: true, @@ -163,6 +168,7 @@ async fn append_system_empty_project_suppresses_global() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn append_system_empty_explicit_suppresses_files() { assert_prompt_case(PromptCase { custom_system: true, @@ -175,6 +181,7 @@ async fn append_system_empty_explicit_suppresses_files() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn append_system_preserves_default_system_layers() { assert_prompt_case(PromptCase { custom_system: false, diff --git a/crates/pa-core/src/session_engine/engine/tests.rs b/crates/pa-core/src/session_engine/engine/tests.rs index 9f38c2091..b2b8696ad 100644 --- a/crates/pa-core/src/session_engine/engine/tests.rs +++ b/crates/pa-core/src/session_engine/engine/tests.rs @@ -31,6 +31,7 @@ fn echo_definition() -> ToolDefinition { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn engine_runs_tool_loop_and_persists() { let model = pa_agent::types::Model { id: "m".into(), @@ -144,6 +145,7 @@ async fn engine_runs_tool_loop_and_persists() { /// A spawned child's prompt stamps its recursion depth: `create_session` /// at depth N reads "depth: N (not root)", never the root identity. #[tokio::test] +#[pa_test_scratch::pa_test] async fn spawned_child_prompt_stamps_its_depth() { let model = pa_agent::types::Model { id: "m".into(), @@ -215,6 +217,7 @@ async fn spawned_child_prompt_stamps_its_depth() { /// server stays gated, an endpoint-bound credential unlocks it in the NEXT /// session, and one bound to another endpoint does not. #[tokio::test] +#[pa_test_scratch::pa_test] async fn oauth_creds_unlock_generic_mcp_gating_in_new_sessions() { fn model() -> pa_agent::types::Model { pa_agent::types::Model { @@ -345,6 +348,7 @@ async fn oauth_creds_unlock_generic_mcp_gating_in_new_sessions() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn create_session_registers_goal_and_heartbeat_handlers() { let dir = tempfile::TempDir::new().unwrap(); let registration = @@ -400,6 +404,7 @@ async fn create_session_registers_goal_and_heartbeat_handlers() { /// `conversation_log_path`, still auto-appends the missing /// thinking-level and service-tier rows (#3350's gate regression). #[tokio::test] +#[pa_test_scratch::pa_test] async fn create_session_appends_missing_resume_settings_rows() { let model = pa_agent::types::Model { id: "m".into(), @@ -492,6 +497,7 @@ async fn create_session_appends_missing_resume_settings_rows() { /// `history.index` reports the figure the engine actually sends: the same /// assembled view, measured with the drift the engine publishes. #[tokio::test] +#[pa_test_scratch::pa_test] async fn history_index_matches_the_request_the_engine_sends() { let model = pa_agent::types::Model { id: "m".into(), @@ -581,6 +587,7 @@ async fn history_index_matches_the_request_the_engine_sends() { /// The engine's live view is the send path, not a build-time snapshot: an edit /// appended to the session changes both, and the compact figure follows. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_live_view_tracks_the_session_and_the_send_path() { let model = pa_agent::types::Model { id: "m".into(), @@ -757,6 +764,7 @@ impl pa_agent::types::AgentTool for EngineEditTool { /// An edit inside a real run: request two must lack the dropped turn, and /// `history.index` must report the usage the provider returned after it. #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_edit_lands_in_the_second_request_and_index_reports_the_post_edit_usage() { let model = pa_agent::types::Model { id: "m".into(), diff --git a/crates/pa-core/src/session_engine/goal_driver/tests.rs b/crates/pa-core/src/session_engine/goal_driver/tests.rs index 8a007b286..fea038538 100644 --- a/crates/pa-core/src/session_engine/goal_driver/tests.rs +++ b/crates/pa-core/src/session_engine/goal_driver/tests.rs @@ -150,6 +150,7 @@ fn usage(input: u64, output: u64) -> pa_types::ai::Usage { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn compacted_goal_restore_and_mutation_do_not_hydrate_history() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("goal.jsonl"); @@ -192,6 +193,7 @@ async fn compacted_goal_restore_and_mutation_do_not_hydrate_history() { assert!(std::fs::read(&path).unwrap().starts_with(&original)); } +#[pa_test_scratch::pa_test] #[test] fn start_resume_pause_lifecycle() { let (_session_dir, mut session) = persisted_session(); @@ -232,6 +234,7 @@ fn start_resume_pause_lifecycle() { assert_eq!(driver.state().objective, None); } +#[pa_test_scratch::pa_test] #[test] fn usage_accounting_and_budget_limit() { let (_session_dir, mut session) = persisted_session(); @@ -272,6 +275,7 @@ fn usage_accounting_and_budget_limit() { assert_eq!(driver.state().status, GoalStatus::BudgetLimited); } +#[pa_test_scratch::pa_test] #[test] fn terminal_messages_fail_or_keep_the_goal() { use pa_types::ai::StopReason; @@ -296,6 +300,7 @@ fn terminal_messages_fail_or_keep_the_goal() { assert_eq!(driver.state().status, GoalStatus::Error); } +#[pa_test_scratch::pa_test] #[test] fn continuations_increment() { let (_session_dir, mut session) = persisted_session(); @@ -332,6 +337,7 @@ fn continuations_increment() { assert_eq!(reloaded.state().continuations_used, 1); } +#[pa_test_scratch::pa_test] #[test] fn the_mint_refuses_and_finishes_on_an_errored_turn() { let (_session_dir, mut session) = persisted_session(); @@ -361,6 +367,7 @@ fn the_mint_refuses_and_finishes_on_an_errored_turn() { } /// A rate-limited corpse never triggers the hard finish; it counts toward the no-output backoff. +#[pa_test_scratch::pa_test] #[test] fn a_rate_limited_turn_keeps_the_goal_alive() { let (_session_dir, mut session) = persisted_session(); @@ -396,6 +403,7 @@ fn a_rate_limited_turn_keeps_the_goal_alive() { assert_eq!(driver.state().continuations_used, 1); } +#[pa_test_scratch::pa_test] #[test] fn no_output_turns_count_to_the_cap_and_backoff() { let (_session_dir, mut session) = persisted_session(); @@ -466,6 +474,7 @@ fn no_output_turns_count_to_the_cap_and_backoff() { } /// Only a turn the goal's own lifetime produced (timestamp after `created_at`) can judge it. +#[pa_test_scratch::pa_test] #[test] fn a_stale_pre_goal_corpse_never_finishes_the_new_goal() { let (_session_dir, mut session) = persisted_session(); @@ -494,6 +503,7 @@ fn a_stale_pre_goal_corpse_never_finishes_the_new_goal() { assert_eq!(driver.state().no_progress_streak, Some(0)); } +#[pa_test_scratch::pa_test] #[test] fn a_replacement_goal_starts_with_a_fresh_streak() { let (_session_dir, mut session) = persisted_session(); @@ -534,6 +544,7 @@ fn a_replacement_goal_starts_with_a_fresh_streak() { ); } +#[pa_test_scratch::pa_test] #[test] fn rate_limit_and_empty_text_corpses_and_the_examined_gate() { let (_session_dir, mut session) = persisted_session(); @@ -593,6 +604,7 @@ fn rate_limit_and_empty_text_corpses_and_the_examined_gate() { /// The examined-turn dedup keys on the millisecond timestamp (the operator's /// ruling) — NOT a total order across settle paths: the kill is UNCONDITIONAL. +#[pa_test_scratch::pa_test] #[test] fn a_terminal_error_sharing_the_millisecond_still_refuses() { let (_session_dir, mut session) = persisted_session(); @@ -655,6 +667,7 @@ fn a_terminal_error_sharing_the_millisecond_still_refuses() { /// A same-ms pre-goal row never judges the new goal — the gate requires a /// STRICTLY later turn — and a parked refusal clears an earlier strike's window. +#[pa_test_scratch::pa_test] #[test] fn a_same_ms_pre_goal_corpse_never_judges_the_new_goal() { let (_session_dir, mut session) = persisted_session(); @@ -691,6 +704,7 @@ fn a_same_ms_pre_goal_corpse_never_judges_the_new_goal() { assert_eq!(driver.state().status, GoalStatus::Error); } +#[pa_test_scratch::pa_test] #[test] fn a_parked_refusal_clears_an_earlier_strikes_window() { let (_session_dir, mut session) = persisted_session(); @@ -730,6 +744,7 @@ fn a_parked_refusal_clears_an_earlier_strikes_window() { /// deadline passed during the settled run: the take still yields the /// overdue deadline once — the sleep saturates to zero — and consuming /// it admits exactly one wake per strike. +#[pa_test_scratch::pa_test] #[test] fn the_print_wake_take_yields_an_overdue_window_once() { let (_session_dir, mut session) = persisted_session(); @@ -754,6 +769,7 @@ fn the_print_wake_take_yields_an_overdue_window_once() { assert_eq!(driver.take_backoff_wake_at(), None); } +#[pa_test_scratch::pa_test] #[test] fn the_rate_limit_refusal_sticks_across_reconsults() { let (_session_dir, mut session) = persisted_session(); @@ -788,6 +804,7 @@ fn the_rate_limit_refusal_sticks_across_reconsults() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_restored_goal_at_the_cap_finishes_at_the_first_consult() { let (_session_dir, mut session) = persisted_session(); @@ -818,6 +835,7 @@ fn a_restored_goal_at_the_cap_finishes_at_the_first_consult() { ); } +#[pa_test_scratch::pa_test] #[test] fn load_persisted_adopts_the_stale_active_failure() { let (_session_dir, mut session) = persisted_session(); @@ -879,6 +897,7 @@ fn load_persisted_adopts_the_stale_active_failure() { ); } +#[pa_test_scratch::pa_test] #[test] fn owed_continuation_defers_and_delivers_once() { let (_session_dir, mut session) = persisted_session(); @@ -920,6 +939,7 @@ fn owed_continuation_defers_and_delivers_once() { assert!(!driver.owes_continuation()); } +#[pa_test_scratch::pa_test] #[test] fn rollback_continuation_mint_restores_the_count() { let (_session_dir, mut session) = persisted_session(); @@ -945,6 +965,7 @@ fn rollback_continuation_mint_restores_the_count() { assert_eq!(driver.state().continuations_used, 1); } +#[pa_test_scratch::pa_test] #[test] fn resume_resolves_the_existing_goal() { let (_session_dir, mut session) = persisted_session(); @@ -972,6 +993,7 @@ fn resume_resolves_the_existing_goal() { ); } +#[pa_test_scratch::pa_test] #[test] fn restore_persisted_adopts_the_state_without_rewriting_it() { let state = GoalState { @@ -1024,6 +1046,7 @@ fn restore_persisted_adopts_the_state_without_rewriting_it() { assert_eq!(driver.state().continuations_used, 3); } +#[pa_test_scratch::pa_test] #[test] fn branch_seedable_rules() { let (_session_dir, mut session) = persisted_session(); @@ -1053,6 +1076,7 @@ fn append_goal_row(session: &mut SessionManager, state: &GoalState) { .unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn same_timeline_reload_never_regresses_the_same_goal() { let (_session_dir, mut session) = persisted_session(); @@ -1095,6 +1119,7 @@ fn same_timeline_reload_never_regresses_the_same_goal() { assert_eq!(driver.state().tokens_used, 1); } +#[pa_test_scratch::pa_test] #[test] fn same_timeline_reload_keeps_a_fired_budget_gate() { let (_session_dir, mut session) = persisted_session(); @@ -1131,6 +1156,7 @@ fn same_timeline_reload_keeps_a_fired_budget_gate() { /// A different goal adopts faithfully even under the same-timeline /// rule (the clamp is same-goal only). +#[pa_test_scratch::pa_test] #[test] fn same_timeline_reload_adopts_a_different_goal_faithfully() { let (_session_dir, mut session) = persisted_session(); @@ -1186,6 +1212,7 @@ fn same_timeline_reload_adopts_a_different_goal_faithfully() { assert_eq!(driver.state().time_used_seconds, 9); } +#[pa_test_scratch::pa_test] #[test] fn reload_skips_invalid_rows() { let (_session_dir, mut session) = persisted_session(); @@ -1226,6 +1253,7 @@ fn reload_skips_invalid_rows() { /// The operator's exact case (2026-09-28): a goal created ~2 hours /// ago reads ~2 hours, and no accounting write compounds it. +#[pa_test_scratch::pa_test] #[test] fn creation_based_timer_reads_the_goals_age() { let (_session_dir, mut session) = persisted_session(); @@ -1274,6 +1302,7 @@ fn creation_based_timer_reads_the_goals_age() { /// The paused goal displays the same creation-based age (the /// operator's ruling). +#[pa_test_scratch::pa_test] #[test] fn paused_goal_reads_its_age() { let (_session_dir, mut session) = persisted_session(); @@ -1300,6 +1329,7 @@ fn paused_goal_reads_its_age() { ); } +#[pa_test_scratch::pa_test] #[test] fn rows_without_created_at_backfill_from_updated_at() { let (_session_dir, mut session) = persisted_session(); @@ -1341,6 +1371,7 @@ fn rows_without_created_at_backfill_from_updated_at() { assert_eq!(GoalDriver::load_persisted(&fresh).state().created_at, None); } +#[pa_test_scratch::pa_test] #[test] fn pending_continuation_never_re_arms() { let (_session_dir, mut session) = persisted_session(); diff --git a/crates/pa-core/src/session_engine/headless.rs b/crates/pa-core/src/session_engine/headless.rs index 89bcb700e..5d08c4d37 100644 --- a/crates/pa-core/src/session_engine/headless.rs +++ b/crates/pa-core/src/session_engine/headless.rs @@ -213,6 +213,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn selects_final_assistant_message() { let messages = vec![ @@ -232,6 +233,7 @@ mod tests { assert_eq!(exit_code, 0); } + #[pa_test_scratch::pa_test] #[test] fn failed_assistant_runs_exit_nonzero() { let mut error = text_assistant("partial", StopReason::Error); @@ -260,6 +262,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn skips_internal_suffix_and_collects_compactions() { let messages = vec![ @@ -285,6 +288,7 @@ mod tests { assert_eq!(result.compaction_outcomes[1].outcome, "failed"); } + #[pa_test_scratch::pa_test] #[test] fn slash_command_results_are_primary() { let messages = vec![ @@ -312,6 +316,7 @@ mod tests { assert_eq!(severity, None); } + #[pa_test_scratch::pa_test] #[test] fn non_suffix_messages_stop_the_walk() { // A compaction summary (not a custom message) ends the suffix walk. diff --git a/crates/pa-core/src/session_engine/history_host.rs b/crates/pa-core/src/session_engine/history_host.rs index 9a2cc2674..79816be3b 100644 --- a/crates/pa-core/src/session_engine/history_host.rs +++ b/crates/pa-core/src/session_engine/history_host.rs @@ -578,6 +578,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn index_totals_match_the_request_built_at_send() { let (_dir, session) = session_with(40); let (requests, handlers, _session, _tmp) = registered(session); @@ -598,6 +599,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn get_reports_the_remainder_of_an_over_limit_region() { let (_dir, session) = session_with(50); let (_requests, handlers, _session, _tmp) = registered(session); @@ -623,6 +625,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn rejected_edit_names_the_target_and_leaves_the_file_unchanged() { let (_dir, session) = session_with(6); let file = session.get_session_file().unwrap().to_owned(); @@ -652,6 +655,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn edit_writes_one_row_and_the_next_request_drops_the_region() { let (_dir, session) = session_with(10); let file = session.get_session_file().unwrap().to_owned(); @@ -758,6 +762,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_edit_reaches_the_next_request_of_the_same_run() { let (_dir, session) = session_with(6); let (requests, handlers, session, _tmp) = registered(session); @@ -823,6 +828,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn get_by_id_and_by_slice_return_the_same_entry() { let (_dir, session) = session_with(8); let (_requests, handlers, session, _tmp) = registered(session); @@ -856,6 +862,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_bounded_path_reports_its_remainder_and_previews() { let (_dir, session) = session_with(4); let (requests, handlers, _session, _tmp) = registered(session); @@ -879,6 +886,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_inserted_note_carries_no_id_and_addresses_by_position() { let (_dir, session) = session_with(3); let (_requests, handlers, _session, _tmp) = registered(session); @@ -912,6 +920,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_refresh_sends_a_message_that_arrived_while_the_view_was_assembled() { let (_dir, session) = session_with(4); let (requests, _handlers, session, _tmp) = registered(session); @@ -991,6 +1000,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_inserted_user_row_is_sent_once_and_its_drop_sticks() { let (_dir, session) = session_with(3); let (requests, handlers, session, _tmp) = registered(session); @@ -1039,6 +1049,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn compact_status_reports_the_figure_history_index_reports_after_an_edit() { let (_dir, session) = session_with(12); let (requests, mut handlers, _session, _tmp) = registered(session); @@ -1063,6 +1074,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_failed_assembly_keeps_the_refresh_pending() { let (_dir, session) = session_with(2); let (requests, _handlers, _session, _tmp) = registered(session); @@ -1089,6 +1101,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_refresh_hook_does_not_keep_its_agent_alive() { let (_dir, session) = session_with(1); let requests = Arc::new(TurnBoundaryRequests::new()); diff --git a/crates/pa-core/src/session_engine/host_requests.rs b/crates/pa-core/src/session_engine/host_requests.rs index df3da522e..9c0b9e45e 100644 --- a/crates/pa-core/src/session_engine/host_requests.rs +++ b/crates/pa-core/src/session_engine/host_requests.rs @@ -367,6 +367,7 @@ mod tests { AgentCronJobStore::new(dir.path().join("jobs.json")) } + #[pa_test_scratch::pa_test] #[test] fn goal_host_requests() { let (_session_dir, mut session) = persisted_session(); @@ -435,6 +436,7 @@ mod tests { assert!(error.to_string().contains("unknown goal request type")); } + #[pa_test_scratch::pa_test] #[test] fn rlm_heartbeat_host_requests() { let store = heartbeat_store(); diff --git a/crates/pa-core/src/session_engine/inference_capabilities.rs b/crates/pa-core/src/session_engine/inference_capabilities.rs index 8d150943c..35f1ec19f 100644 --- a/crates/pa-core/src/session_engine/inference_capabilities.rs +++ b/crates/pa-core/src/session_engine/inference_capabilities.rs @@ -831,6 +831,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn sse_frames_hand_lua_parsed_json_instead_of_wire_text() { let backend = InferenceCapabilities::new("session".into()); let value = json!({"delta":"wire ✓","nested":[1,true,null]}); @@ -875,6 +876,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn explicit_native_open_streams_real_faux_provider() { let registration = pa_ai::faux::register_faux_provider(pa_ai::faux::RegisterFauxProviderOptions { @@ -924,6 +926,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn raw_delegate_allows_current_instructions_but_not_portable_messages_or_model_changes() { use pa_ai::compaction::{ CompactionLimits, CompactionRoute, ResponsesCompactor, ResponsesWindow, @@ -995,6 +998,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn typed_delegate_is_single_use_and_pull_based() { let backend = InferenceCapabilities::new("session".into()); let pulls = Arc::new(AtomicUsize::new(0)); @@ -1062,6 +1066,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn dropping_a_read_future_cancels_its_open_transport() { let backend = InferenceCapabilities::new("session".into()); let pulls = Arc::new(AtomicUsize::new(0)); @@ -1094,6 +1099,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn close_interrupts_an_active_reader_and_session_drop_closes_idle_streams() { let backend = InferenceCapabilities::new("session".into()); let closed = CancellationToken::new(); @@ -1152,6 +1158,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn invocation_cancellation_closes_idle_inference() { let backend = InferenceCapabilities::new("session".into()); let closed = CancellationToken::new(); @@ -1208,6 +1215,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn explicit_http_json_and_sse_cross_host_capabilities() { let backend = InferenceCapabilities::new("session".into()); for (format, content_type, body, expected) in [ @@ -1263,6 +1271,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn oversized_sse_frame_errors_and_revokes_handle() { let backend = InferenceCapabilities::new("session".into()); let mut body = b"data: ".to_vec(); @@ -1296,6 +1305,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn bounded_native_explicit_and_delegated_result_only_drain_more_than_sixteen_events() { let registration = pa_ai::faux::register_faux_provider(pa_ai::faux::RegisterFauxProviderOptions { @@ -1398,6 +1408,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn bounded_native_result_only_drains_a_real_http_stream_larger_than_both_queues() { let mut body = String::new(); for _ in 0..96 { diff --git a/crates/pa-core/src/session_engine/inference_router/tests.rs b/crates/pa-core/src/session_engine/inference_router/tests.rs index c701be287..9eed86762 100644 --- a/crates/pa-core/src/session_engine/inference_router/tests.rs +++ b/crates/pa-core/src/session_engine/inference_router/tests.rs @@ -114,6 +114,7 @@ fn text(message: &AssistantMessage) -> String { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn engine_main_and_auxiliary_routes_are_session_scoped_and_stream_real_deltas() { let a = Fixture::new(PROVIDER, "alpha").await; let b = Fixture::new(PROVIDER, "beta").await; @@ -182,6 +183,7 @@ async fn engine_main_and_auxiliary_routes_are_session_scoped_and_stream_real_del } #[tokio::test] +#[pa_test_scratch::pa_test] async fn invalid_reload_preserves_route_and_disable_fences_queued_terminal_without_fallback() { let f = Fixture::new(PROVIDER, "kept").await; let mut stream = f.stream("before").await; @@ -208,6 +210,7 @@ async fn invalid_reload_preserves_route_and_disable_fences_queued_terminal_witho } #[tokio::test] +#[pa_test_scratch::pa_test] async fn malformed_stream_and_cancelled_caller_are_terminal_diagnostics() { let f=Fixture::new("return {providers={{name='custom',mode='streaming',run=function(i,c) c.emit({bogus=true}); return {} end}}}","bad").await; let mut stream = f.stream("malformed").await; @@ -241,6 +244,7 @@ async fn malformed_stream_and_cancelled_caller_are_terminal_diagnostics() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn lua_can_wrap_native_request_and_transform_response_without_recursion() { const WRAPPER: &str = r" return {providers={{name='custom',mode='streaming',run=function(input,ctx) @@ -276,6 +280,7 @@ end}}} } #[tokio::test] +#[pa_test_scratch::pa_test] async fn normalized_tool_events_and_terminal_tool_result_survive_the_route() { let source=PROVIDER.replace("message.content={{type='text',text=text}}", "message.content={{type='toolCall',id='call_1',name='lookup',arguments={query='kept'}}}") .replace("ctx.emit({type='text_delta',contentIndex=0,delta=text,partial=message})", @@ -336,6 +341,7 @@ async fn emitted(engine: &super::super::engine::SessionEngine) -> u64 { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn slow_consumer_applies_bounded_lua_backpressure_and_drop_stops_publication() { let source=PROVIDER.replace("return {providers", "local emitted=0; return {exports={{name='emitted',run=function() return emitted end}},providers") .replace("ctx.emit({type='text_delta',contentIndex=0,delta=text,partial=message})", @@ -399,6 +405,7 @@ async fn http_service(body: String) -> (String, tokio::task::JoinHandle) } #[tokio::test] +#[pa_test_scratch::pa_test] async fn custom_http_sse_and_native_gateway_are_real_engine_provider_routes() { let message = pa_ai::faux::faux_assistant_text_message( "custom network", @@ -471,6 +478,7 @@ end}}}}}} } #[tokio::test] +#[pa_test_scratch::pa_test] async fn dropping_engine_provider_stream_closes_held_http_socket() { use tokio::io::{AsyncReadExt, AsyncWriteExt}; let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); @@ -522,6 +530,7 @@ end}}}}}} } #[tokio::test] +#[pa_test_scratch::pa_test] async fn dedicated_auxiliary_retains_full_requested_model_and_explicit_options() { let f = Fixture::new(PROVIDER, "unused").await; f.disable().await; @@ -585,6 +594,7 @@ async fn dedicated_auxiliary_retains_full_requested_model_and_explicit_options() } #[tokio::test] +#[pa_test_scratch::pa_test] async fn typed_native_input_survives_lua_delegate_and_actual_responses_transport() { use pa_ai::compaction::{ CompactionLimits, CompactionRoute, ResponsesCompactor, ResponsesWindow, diff --git a/crates/pa-core/src/session_engine/ipython_state.rs b/crates/pa-core/src/session_engine/ipython_state.rs index 964e55f01..d073bed89 100644 --- a/crates/pa-core/src/session_engine/ipython_state.rs +++ b/crates/pa-core/src/session_engine/ipython_state.rs @@ -256,6 +256,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn notice_content_matches_the_ts_text() { assert_eq!( @@ -276,6 +277,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn notice_row_is_display_false_without_details() { let row = notice_message(notice_content(Some(&["v".to_string()]))); @@ -294,6 +296,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn capture_guards_match_ts() { let idle = ScriptedProbe::idle(); assert_eq!(capture_notice_content(&idle).await, None); @@ -404,6 +407,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn compaction_with_a_running_kernel_appends_the_notice_after_the_entry() { let registration = faux_registration(vec![pa_ai::faux::FauxResponseStep::Message( pa_ai::faux::faux_assistant_text_message( @@ -457,6 +461,7 @@ mod tests { /// the compaction row, so back-to-back `/compact` RUNS again; a /// session without a kernel keeps the "Already compacted" skip. #[tokio::test] + #[pa_test_scratch::pa_test] async fn back_to_back_compact_runs_again_with_a_running_kernel() { let seen: std::sync::Arc>> = std::sync::Arc::default(); let registration = faux_registration(vec![ @@ -501,6 +506,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn back_to_back_compact_without_a_kernel_still_skips() { let registration = faux_registration(vec![pa_ai::faux::FauxResponseStep::Message( pa_ai::faux::faux_assistant_text_message( diff --git a/crates/pa-core/src/session_engine/messages.rs b/crates/pa-core/src/session_engine/messages.rs index cc4755cef..9f5a275e5 100644 --- a/crates/pa-core/src/session_engine/messages.rs +++ b/crates/pa-core/src/session_engine/messages.rs @@ -420,6 +420,7 @@ mod tests { /// SANCTIONED DIVERGENCE, operator ruling 2026-09-23: one durable /// line per episode, never model context. + #[pa_test_scratch::pa_test] #[test] fn provider_retry_outcome_row_is_the_one_line_and_never_context() { let recovered = @@ -454,6 +455,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn model_prompt_error_row_is_never_context() { let message = crate::prompts::model_prompts::model_prompt_error_message(&[ @@ -462,6 +464,7 @@ mod tests { assert!(convert_to_llm(&[AgentMessage::Custom(message)]).is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn bash_output_fences_and_status() { let rendered = bash_output_to_text( @@ -482,6 +485,7 @@ mod tests { assert!(fenced.contains("````\na ``` b\n````")); } + #[pa_test_scratch::pa_test] #[test] fn conversion_wraps_summaries_and_drops_bookkeeping() { let messages = vec![ @@ -545,6 +549,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn loop_conversion_applies_session_rules_to_custom_rows() { let note_row: pa_agent::types::AgentMessage = serde_json::from_value(serde_json::json!({ @@ -585,6 +590,7 @@ mod tests { assert_eq!(text.text, "a note"); } + #[pa_test_scratch::pa_test] #[test] fn heartbeat_prompt_message_matches_the_ts_shape() { let job = AgentCronJob { @@ -654,6 +660,7 @@ mod tests { assert_eq!(details["lastRunAt"], "2026-09-22T00:10:00.000Z"); } + #[pa_test_scratch::pa_test] #[test] fn async_bash_completion_message_matches_the_ts_shape() { let message = @@ -680,6 +687,7 @@ mod tests { assert_eq!(details["exitCode"], 2); } + #[pa_test_scratch::pa_test] #[test] fn bash_execution_becomes_user_text() { let bash = AgentMessage::BashExecution(pa_types::session::BashExecutionMessage { diff --git a/crates/pa-core/src/session_engine/ollama_cloud.rs b/crates/pa-core/src/session_engine/ollama_cloud.rs index bce208e76..6c8fb80e9 100644 --- a/crates/pa-core/src/session_engine/ollama_cloud.rs +++ b/crates/pa-core/src/session_engine/ollama_cloud.rs @@ -193,6 +193,7 @@ mod tests { .unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn cap_changes_and_removal_restore_the_exact_gateway_baseline() { let dir = tempfile::tempdir().unwrap(); @@ -234,6 +235,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn native_overlay_precedes_user_hook_and_uses_actual_request_model() { use pa_agent::stream::{LlmContext, StreamRequestOptions}; let dir = tempfile::tempdir().unwrap(); @@ -288,6 +290,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn user_hook_none_keeps_overlay_and_non_ollama_requests_stay_unchanged() { use pa_agent::stream::{LlmContext, StreamRequestOptions}; let dir = tempfile::tempdir().unwrap(); @@ -325,6 +328,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn explicit_caps_reload_and_removal_reach_the_real_provider_body() { use pa_agent::stream::{LlmContext, StreamRequestOptions}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -434,6 +438,7 @@ mod tests { assert_eq!(original.max_tokens, 32000); } + #[pa_test_scratch::pa_test] #[test] fn full_model_projection_keeps_gateway_and_existing_agent_wire_spelling() { let full = model(); @@ -447,6 +452,7 @@ mod tests { assert!(serde_json::from_value::(wire).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn fresh_registry_baseline_wins_when_equal_to_an_old_cap() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/session_engine/optchat/engine_tests.rs b/crates/pa-core/src/session_engine/optchat/engine_tests.rs index 8ff546cc4..09fa1d408 100644 --- a/crates/pa-core/src/session_engine/optchat/engine_tests.rs +++ b/crates/pa-core/src/session_engine/optchat/engine_tests.rs @@ -174,6 +174,7 @@ async fn export( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_engine_tree_covers_history_scoped_auxiliary_recall_append_and_main_call() { let f = Fixture::new(96).await; let calls = f.calls().await; @@ -283,6 +284,7 @@ async fn public_engine_tree_covers_history_scoped_auxiliary_recall_append_and_ma } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_engine_failed_summary_keeps_previous_view_and_journal() { let f = Fixture::new(32).await; let previous = f.export("optchat", "status", json!({})).await.unwrap(); @@ -325,6 +327,7 @@ async fn public_engine_failed_summary_keeps_previous_view_and_journal() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_engine_resume_window_uses_full_source_and_fresh_session_never_imports_tree() { let f = Fixture::new(64).await; { @@ -420,6 +423,7 @@ async fn public_engine_resume_window_uses_full_source_and_fresh_session_never_im } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_model_switch_rechecks_bound_without_source_loss() { let f = Fixture::new(64).await; f.native.push_text_turn("large model answer"); @@ -459,6 +463,7 @@ async fn public_model_switch_rechecks_bound_without_source_loss() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_oversized_mandatory_instructions_fail_before_main_inference() { let f = Fixture::new(32).await; let previous = f.engine.session.agent().state().await.messages; @@ -514,6 +519,7 @@ impl crate::plugins::HostCapabilities for Arc { } } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_engine_cancelled_or_retired_auxiliary_work_cannot_publish() { for retire in [false, true] { let f = Fixture::new(32).await; @@ -598,6 +604,7 @@ async fn public_engine_cancelled_or_retired_auxiliary_work_cannot_publish() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_branch_navigation_builds_candidate_tree_not_previous_sibling() { let f = Fixture::new(32).await; let foreign = f @@ -665,6 +672,7 @@ async fn public_branch_navigation_builds_candidate_tree_not_previous_sibling() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_explicit_selection_disable_and_resume_never_fall_back() { let f = Fixture::new(48).await; f.engine @@ -759,6 +767,7 @@ async fn public_explicit_selection_disable_and_resume_never_fall_back() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_failed_tree_selection_preserves_rolling_authority_and_history() { let f = Fixture::new(32).await; f.engine @@ -863,6 +872,7 @@ async fn read_http_request(socket: &mut tokio::net::TcpStream) -> Value { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_text_tree_two_round_native_http_preserves_current_executed_tool_outcome() { use tokio::io::AsyncWriteExt; let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); @@ -977,6 +987,7 @@ async fn public_text_tree_two_round_native_http_preserves_current_executed_tool_ } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_tiny_typed_image_fails_before_any_inference_and_requires_explicit_strategy_change() { let f = Fixture::new(32).await; @@ -1214,6 +1225,7 @@ async fn actual_responses_archive_fixture( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_native_archives_and_typed_signatures_fail_before_projection_inference() { enum Source { Archive(pa_types::session::ContextRepresentation), diff --git a/crates/pa-core/src/session_engine/optchat/service_tests.rs b/crates/pa-core/src/session_engine/optchat/service_tests.rs index 10895c992..8c691208c 100644 --- a/crates/pa-core/src/session_engine/optchat/service_tests.rs +++ b/crates/pa-core/src/session_engine/optchat/service_tests.rs @@ -68,6 +68,7 @@ impl Fixture { } } #[tokio::test] +#[pa_test_scratch::pa_test] async fn native_public_capability_roundtrip_durable_cache_and_exact_source() { let f = Fixture::new(); let before = { @@ -141,6 +142,7 @@ async fn native_public_capability_roundtrip_durable_cache_and_exact_source() { ); } #[tokio::test] +#[pa_test_scratch::pa_test] async fn cancellation_branch_departure_and_persistence_failure_preserve_active_view() { for mode in ["cancel", "branch", "persist"] { let f = Fixture::new(); @@ -191,6 +193,7 @@ async fn cancellation_branch_departure_and_persistence_failure_preserve_active_v } #[tokio::test] +#[pa_test_scratch::pa_test] async fn whole_call_budget_charges_exact_instructions_tools_and_output_before_layout() { let f = Fixture::new(); let mut input = json!({"budget_bytes":4096,"summary_bytes":128,"phase":"model", @@ -259,6 +262,7 @@ impl HostCapabilities for PlanRouter { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn actual_native_plan_reply_stays_within_lua_quota_without_shrinking_history() { use crate::plugins::{ContributionKind, InvocationEvent, InvocationOutcome}; let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/session_engine/optchat/tests.rs b/crates/pa-core/src/session_engine/optchat/tests.rs index 4685158fe..b73c14296 100644 --- a/crates/pa-core/src/session_engine/optchat/tests.rs +++ b/crates/pa-core/src/session_engine/optchat/tests.rs @@ -29,6 +29,7 @@ fn summarize(tree: &mut Tree) -> usize { count } +#[pa_test_scratch::pa_test] #[test] fn complete_bounded_view_balanced_merges_and_exact_recall() { let original = history(128); @@ -52,6 +53,7 @@ fn complete_bounded_view_balanced_merges_and_exact_recall() { assert_eq!(summarize(&mut t), 0); } +#[pa_test_scratch::pa_test] #[test] fn descendants_reuse_nodes_and_siblings_cannot_recall_each_other() { let original = history(64); @@ -82,6 +84,7 @@ fn descendants_reuse_nodes_and_siblings_cannot_recall_each_other() { assert!(sibling.recall(&foreign_id, 0, 256).is_err()); } +#[pa_test_scratch::pa_test] #[test] fn source_hash_child_hash_summary_and_budget_are_validated() { let original = history(8); @@ -120,6 +123,7 @@ fn source_hash_child_hash_summary_and_budget_are_validated() { assert!(Tree::new("session", history(8), Some("e7".into()), cache, 128).is_err()); } +#[pa_test_scratch::pa_test] #[test] fn canonical_tool_custom_date_search_and_fresh_session_isolation() { let mut source = history(3); @@ -153,6 +157,7 @@ fn canonical_tool_custom_date_search_and_fresh_session_isolation() { .is_err()); } +#[pa_test_scratch::pa_test] #[test] fn missing_source_and_cycles_fail_instead_of_partial_coverage() { let mut missing = history(3); @@ -172,6 +177,7 @@ fn missing_source_and_cycles_fail_instead_of_partial_coverage() { assert!(t.view(10).is_err()); } +#[pa_test_scratch::pa_test] #[test] fn typed_multimodal_projection_rejects_without_disabling_exact_recall() { let image = json!({"type":"image","data":"AA==","mimeType":"image/png"}); @@ -253,6 +259,7 @@ pub(super) fn signed_source_messages() -> Vec<(pa_types::session::AgentMessage, cases } +#[pa_test_scratch::pa_test] #[test] fn typed_opaque_signatures_and_route_ids_reject_projection_but_preserve_exact_index() { for (message, marker) in signed_source_messages() { @@ -281,6 +288,7 @@ fn typed_opaque_signatures_and_route_ids_reject_projection_but_preserve_exact_in assert!(tree(vec![original], Cache::default()).view(4096).is_ok()); } +#[pa_test_scratch::pa_test] #[test] fn serialized_plan_bound_counts_metadata_and_defers_an_ordered_prefix() { use super::tree::{MAX_MERGE_INPUT_BYTES, MAX_PLAN_REPLY_BYTES}; @@ -331,6 +339,7 @@ fn serialized_plan_bound_counts_metadata_and_defers_an_ordered_prefix() { .contains("serialized single merge")); } +#[pa_test_scratch::pa_test] #[test] fn oversized_single_plan_input_fails_explicitly_before_any_reply() { let source=(0..2).map(|index|serde_json::from_value(json!({"type":"message","id":format!("large-{index}"),"parentId":if index==0 {None}else{Some("large-0")},"timestamp":"2026-10-20T10:00:00Z","message":{"role":"user","content":"x".repeat(300*1024),"timestamp":0}})).unwrap()).collect::>(); diff --git a/crates/pa-core/src/session_engine/plugin_context.rs b/crates/pa-core/src/session_engine/plugin_context.rs index fc90a26cc..a6cbb9eeb 100644 --- a/crates/pa-core/src/session_engine/plugin_context.rs +++ b/crates/pa-core/src/session_engine/plugin_context.rs @@ -150,6 +150,7 @@ mod tests { use pa_agent::stream::{event_stream, LlmContext, ModelStream, StreamRequestOptions}; use std::sync::Mutex; + #[pa_test_scratch::pa_test] #[test] fn recent_context_signal_is_bounded_text_only_newest_first() { let mut context = pa_agent::stream::LlmContext { @@ -192,6 +193,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_failing_plugin_contribution_never_fails_the_model_call() { let dir = tempfile::tempdir().unwrap(); let cwd = dir.path().join("project"); diff --git a/crates/pa-core/src/session_engine/plugin_stages_tests.rs b/crates/pa-core/src/session_engine/plugin_stages_tests.rs index 99d139c84..3641eb851 100644 --- a/crates/pa-core/src/session_engine/plugin_stages_tests.rs +++ b/crates/pa-core/src/session_engine/plugin_stages_tests.rs @@ -281,6 +281,7 @@ async fn export(host: &PluginHost, name: &str) -> Value { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tool_call_block_denies_with_reason_and_skips_execution() { let hooks = ToolStageHooks::new(host(&[("alpha", BLOCK)]), "hook-test".into()); let run = run_probe(Some(hooks), "original result").await; @@ -294,6 +295,7 @@ async fn tool_call_block_denies_with_reason_and_skips_execution() { } #[tokio::test(flavor = "multi_thread")] +#[pa_test_scratch::pa_test] async fn tool_call_timeout_blocks_and_produces_an_error_result() { let hooks = ToolStageHooks::new(host(&[("alpha", TIMEOUT)]), "hook-test".into()); let run = run_probe(Some(hooks), "original result").await; @@ -308,6 +310,7 @@ async fn tool_call_timeout_blocks_and_produces_an_error_result() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tool_result_rewrite_persists_on_the_existing_tool_result_row() { let hooks = ToolStageHooks::new(host(&[("alpha", REWRITE)]), "hook-test".into()); let run = run_probe(Some(hooks), "original result").await; @@ -331,6 +334,7 @@ async fn tool_result_rewrite_persists_on_the_existing_tool_result_row() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tool_result_failure_keeps_the_original_result() { let hooks = ToolStageHooks::new(host(&[("alpha", FAILURE)]), "hook-test".into()); let run = run_probe(Some(hooks), "original result").await; @@ -345,6 +349,7 @@ async fn tool_result_failure_keeps_the_original_result() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn no_plugins_keeps_byte_identical_messages() { let plain = run_probe(None, "original result").await; let empty = run_probe( @@ -364,6 +369,7 @@ async fn no_plugins_keeps_byte_identical_messages() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn tool_result_hooks_run_in_alphabetical_plugin_order() { let hooks = ToolStageHooks::new( host(&[("zeta", ZETA_APPEND), ("alpha", ALPHA_APPEND)]), @@ -383,6 +389,7 @@ async fn tool_result_hooks_run_in_alphabetical_plugin_order() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn compaction_observer_fires_once_for_ran_and_skipped() { let host = host(&[("alpha", COMPACTION_OBSERVER)]); let skipped = CompactOutcome::Skipped("session too short"); diff --git a/crates/pa-core/src/session_engine/plugins.rs b/crates/pa-core/src/session_engine/plugins.rs index 7784c273a..3bda16719 100644 --- a/crates/pa-core/src/session_engine/plugins.rs +++ b/crates/pa-core/src/session_engine/plugins.rs @@ -907,6 +907,7 @@ mod context_selection_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn capability_namespaces_route_independently() { struct Capture { name: &'static str, @@ -1023,6 +1024,7 @@ mod context_selection_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn compiled_default_and_full_chain_are_real_lua_contributions() { let f = Fixture::new(); f.manager.reload().await.unwrap(); @@ -1080,6 +1082,7 @@ mod context_selection_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn archive_restore_validates_schema_without_requiring_creator_generation() { let f = Fixture::new(); let strategy = f.manager.context_selection().unwrap(); @@ -1112,6 +1115,7 @@ mod context_selection_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn invalid_enabled_replacement_preserves_host_but_explicit_disable_retires_it() { let f = Fixture::new(); let old = f.manager.context_selection().unwrap(); @@ -1164,6 +1168,7 @@ mod context_selection_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn invalid_builtin_chain_preserves_host_revision_and_selection() { let f = Fixture::new(); let original = f.manager.host.snapshot(); @@ -1194,6 +1199,7 @@ mod context_selection_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn custom_strategy_and_compactors_use_same_typed_invocation_and_retirement() { let f = Fixture::new(); let source = r"return { @@ -1246,6 +1252,7 @@ mod context_selection_tests { .is_err()); } #[tokio::test] + #[pa_test_scratch::pa_test] async fn context_registration_rejects_away_then_back_even_same_generation() { let f = Fixture::new(); std::fs::write(f.manager.agent_dir.join("away.lua"), "return {context_strategies={{name='other',run=function(input) return {messages=input.messages} end}}}").unwrap(); @@ -1280,6 +1287,7 @@ mod context_selection_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn context_commit_admission_does_not_publish_after_compactor_retirement() { let f = Fixture::new(); let strategy = f.manager.context_selection().unwrap(); diff --git a/crates/pa-core/src/session_engine/plugins/tests.rs b/crates/pa-core/src/session_engine/plugins/tests.rs index 9ffc3121a..905de824a 100644 --- a/crates/pa-core/src/session_engine/plugins/tests.rs +++ b/crates/pa-core/src/session_engine/plugins/tests.rs @@ -226,6 +226,7 @@ async fn command( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn configured_plugins_cross_engine_kernel_and_slash_surfaces() { let f = Fixture::new(ALPHA).await; let engine = &f.engine; @@ -319,6 +320,7 @@ async fn configured_plugins_cross_engine_kernel_and_slash_surfaces() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reload_is_atomic_config_sensitive_and_history_neutral() { let f = Fixture::new(ALPHA).await; let engine = &f.engine; @@ -411,6 +413,7 @@ async fn reload_is_atomic_config_sensitive_and_history_neutral() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn disable_cancels_active_kernel_work_and_fences_saved_command() { let f = Fixture::new(ALPHA).await; let engine = &f.engine; @@ -478,6 +481,7 @@ async fn disable_cancels_active_kernel_work_and_fences_saved_command() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn malformed_activation_does_not_kill_normal_startup_and_sessions_are_private() { let bad = Fixture::new("not valid Lua !").await; assert!(bad.engine.plugin_diagnostic().is_some()); @@ -509,6 +513,7 @@ async fn malformed_activation_does_not_kill_normal_startup_and_sessions_are_priv } #[tokio::test] +#[pa_test_scratch::pa_test] async fn namespace_incompatible_replacement_preserves_native_inventory() { let f = Fixture::new(ALPHA).await; let engine = &f.engine; @@ -557,6 +562,7 @@ async fn namespace_incompatible_replacement_preserves_native_inventory() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn active_inventory_is_a_live_model_prompt_tail_not_canonical_history() { let f = Fixture::new(ALPHA).await; let engine = &f.engine; @@ -592,6 +598,7 @@ async fn active_inventory_is_a_live_model_prompt_tail_not_canonical_history() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn actual_kernel_preimports_refreshes_and_fences_plugin_callables() { tokio::time::timeout(std::time::Duration::from_secs(45), async { use crate::kernel::shared::{ExecuteOptions, ExecuteStatus}; diff --git a/crates/pa-core/src/session_engine/provider_adapter.rs b/crates/pa-core/src/session_engine/provider_adapter.rs index e8c2ee139..0187bf2d4 100644 --- a/crates/pa-core/src/session_engine/provider_adapter.rs +++ b/crates/pa-core/src/session_engine/provider_adapter.rs @@ -544,6 +544,7 @@ mod tests { use super::*; #[tokio::test] + #[pa_test_scratch::pa_test] async fn delivered_terminal_survives_close_and_abort() { for reason in [ pa_types::ai::StopReason::Stop, @@ -605,6 +606,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn configured_transport_reaches_the_provider_options() { let registration = pa_ai::faux::register_faux_provider(pa_ai::faux::RegisterFauxProviderOptions { @@ -645,6 +647,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn live_target_service_tier_reaches_provider_and_reset() { let registration = pa_ai::faux::register_faux_provider(pa_ai::faux::RegisterFauxProviderOptions { @@ -695,6 +698,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn auxiliary_model_is_not_replaced_by_the_main_switchable_target() { let registration = pa_ai::faux::register_faux_provider(pa_ai::faux::RegisterFauxProviderOptions { @@ -755,6 +759,7 @@ mod tests { registration.unregister(); } + #[pa_test_scratch::pa_test] #[test] fn prompt_text_message_round_trips() { let message = pa_agent::types::AgentMessage::Standard(pa_agent::types::Message::User( @@ -786,6 +791,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn routed_model_modalities_survive_the_agent_boundary() { let mut routed = pa_agent::types::Model::unknown(); @@ -814,6 +820,7 @@ mod tests { /// Regression guard: provider signatures must survive the round-trip. pa-agent has no /// catch-all field, so a key-casing mismatch silently dropped them — a Rust-written /// session lost the signature TS-written ones carry. + #[pa_test_scratch::pa_test] #[test] fn provider_signatures_round_trip_both_directions() { let thinking = pa_types::ai::ThinkingContent { @@ -857,6 +864,7 @@ mod tests { /// A delayed faux response holds the request mid-wait; `ModelStream::close` cancels the fetch /// NOW, so the stream settles on the aborted message instead of waiting out the hold. #[tokio::test] + #[pa_test_scratch::pa_test] async fn closing_the_stream_cancels_a_held_fetch_immediately() { let registration = pa_ai::faux::register_faux_provider(pa_ai::faux::RegisterFauxProviderOptions { diff --git a/crates/pa-core/src/session_engine/provider_failover.rs b/crates/pa-core/src/session_engine/provider_failover.rs index eac2b584f..1cd7c71a8 100644 --- a/crates/pa-core/src/session_engine/provider_failover.rs +++ b/crates/pa-core/src/session_engine/provider_failover.rs @@ -522,6 +522,7 @@ mod tests { harness } + #[pa_test_scratch::pa_test] #[test] fn backoff_schedule_starts_at_base_doubles_and_caps() { let failover = ProviderFailoverPolicy { @@ -552,6 +553,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn provider_failure_switches_to_the_next_provider_then_succeeds() { let candidates = vec![model("backup-a"), model("backup-b")]; // Two failures exhaust the primary's budget (max_retries 2). @@ -633,6 +635,7 @@ mod tests { /// Operator ruling 2026-09-23: the chain gives up at /// [`MAX_TOTAL_PROVIDER_RETRIES`] retries. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_long_candidate_chain_gives_up_at_the_episode_cap() { // Six backup candidates: without the cap the walk would consume // (1 + candidates) * (1 + budget) attempts (the ~30 the operator ruled out). @@ -672,6 +675,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn all_providers_failing_surfaces_the_final_error() { let candidates = vec![model("backup-a"), model("backup-b")]; let script: Vec = (0..9) @@ -716,6 +720,7 @@ mod tests { /// The 402 diagnosis: no provider failure settles silently. #[tokio::test] + #[pa_test_scratch::pa_test] async fn permanent_failures_never_walk_the_chain_but_disclose() { let candidates = vec![model("backup-a")]; let script = vec![error_message( @@ -740,6 +745,7 @@ mod tests { /// The router's tool-use 404 is permanent even though a plain 404 is /// transient (the dogfood incident): every provider rejects tools identically. #[tokio::test] + #[pa_test_scratch::pa_test] async fn unsupported_tool_failures_never_walk_the_chain_but_disclose() { let candidates = vec![model("backup-a")]; let script = vec![error_message( @@ -765,6 +771,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn disabled_failover_or_no_candidates_is_the_plain_quick_loop() { let candidates = vec![model("backup-a")]; // Disabled: the quick policy drives (3 retries at 2000ms base). @@ -818,6 +825,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn success_without_retries_emits_no_events() { let candidates = vec![model("backup-a")]; let harness = drive(&fast_failover(), &candidates, vec![ok_message("done")]).await; @@ -829,6 +837,7 @@ mod tests { /// The compact-and-retry recovery owns it (TS `_isRetryableError`). #[tokio::test] + #[pa_test_scratch::pa_test] async fn context_overflow_never_walks_the_provider_chain() { let candidates = vec![model("backup-a"), model("backup-b")]; let mut overflow = error_message(None, None, "prompt is too long"); diff --git a/crates/pa-core/src/session_engine/provider_park.rs b/crates/pa-core/src/session_engine/provider_park.rs index 97f96d63e..a5a89fa95 100644 --- a/crates/pa-core/src/session_engine/provider_park.rs +++ b/crates/pa-core/src/session_engine/provider_park.rs @@ -238,6 +238,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn parks_at_the_reported_reset_plus_grace() { let decision = provider_park_decision(0, Some(3_600_000), &policy()); @@ -249,6 +250,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn caps_a_distant_reset_at_max_pause_ms() { let decision = provider_park_decision(0, Some(30 * 86_400_000), &policy()); @@ -260,6 +262,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn clamps_a_configured_bound_above_one_week() { let mut configured = policy(); @@ -273,6 +276,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn disabled_keeps_the_immediate_abort() { let mut disabled = policy(); @@ -285,6 +289,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn spent_park_budget_aborts() { assert_eq!( @@ -295,6 +300,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn no_reported_reset_never_parks() { assert_eq!( @@ -334,6 +340,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn quota_classification_reads_the_rate_limit_kind() { assert!(is_quota_block_failure("a_message( @@ -356,6 +363,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn parked_status_names_the_wake_time() { let message = quota_parked_final_error( @@ -369,6 +377,7 @@ mod tests { assert!(message.starts_with("Provider requested a 4363s wait")); } + #[pa_test_scratch::pa_test] #[test] fn branch_scan_takes_the_newest_park() { let entries = vec![ @@ -399,6 +408,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn branch_scan_stops_at_a_newer_resume() { let entries = vec![ @@ -419,6 +429,7 @@ mod tests { assert_eq!(scan_quota_park_entries(&entries), BranchParkScan::Resumed); } + #[pa_test_scratch::pa_test] #[test] fn branch_scan_ignores_unrelated_entries_and_bad_data() { let entries = vec![ diff --git a/crates/pa-core/src/session_engine/provider_retry.rs b/crates/pa-core/src/session_engine/provider_retry.rs index b39964103..a6e22735d 100644 --- a/crates/pa-core/src/session_engine/provider_retry.rs +++ b/crates/pa-core/src/session_engine/provider_retry.rs @@ -335,6 +335,7 @@ mod tests { /// SANCTIONED DIVERGENCE, operator ruling 2026-09-23: ±20% around /// the computed backoff. + #[pa_test_scratch::pa_test] #[test] fn jitter_stays_inside_the_band_and_mid_is_identity() { assert_eq!(jittered_delay_ms(1000, 0.5), 1000); @@ -352,6 +353,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn retry_delay_exponentially_backs_off() { let policy = ProviderRetryPolicy { @@ -379,6 +381,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn retry_delay_caps_server_requests() { let policy = ProviderRetryPolicy { @@ -406,6 +409,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn permanent_kinds_never_retry() { assert!(is_permanent_provider_failure_kind( @@ -472,6 +476,7 @@ mod tests { /// fires and the completion settles on the retry's healthy stream /// (the fleet's death shape, replayed). #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_dropped_sse_stream_retries_and_completes_on_the_retry() { use crate::session_engine::provider_adapter::{json_round_trip, real_stream_fn}; use pa_agent::stream::{LlmContext, StreamRequestOptions}; @@ -553,6 +558,7 @@ mod tests { /// `stream_drop` class through the same retry ladder: a dropped stream /// retries and the completion settles on the retry. #[tokio::test] + #[pa_test_scratch::pa_test] async fn stream_drop_failures_retry_in_the_one_shot_arms() { let policy = ProviderRetryPolicy { enabled: true, @@ -590,6 +596,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn transient_failure_is_retried_until_success() { let policy = ProviderRetryPolicy { enabled: true, @@ -644,6 +651,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn retries_exhaust_after_max_retries() { let policy = ProviderRetryPolicy { enabled: true, @@ -669,6 +677,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn disabled_policy_never_retries() { let policy = ProviderRetryPolicy { enabled: false, @@ -694,6 +703,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn permanent_failure_returns_without_waiting() { let policy = ProviderRetryPolicy { enabled: true, @@ -732,6 +742,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn aborted_signal_racing_failure_stops_aborted() { let policy = ProviderRetryPolicy { enabled: true, @@ -754,6 +765,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn aborted_wait_stops_aborted() { let policy = ProviderRetryPolicy { enabled: true, @@ -779,6 +791,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn lifecycle_and_faux_failures_are_never_retried() { let policy = ProviderRetryPolicy { enabled: true, @@ -829,6 +842,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn attempt_errors_propagate() { let policy = ProviderRetryPolicy { enabled: true, @@ -848,6 +862,7 @@ mod tests { assert_eq!(error.to_string(), "attempt failed"); } + #[pa_test_scratch::pa_test] #[test] fn stream_failure_fields_read_from_diagnostics() { let message = error_message(Some("server_error"), Some(500), Some(120)); @@ -863,6 +878,7 @@ mod tests { /// Provider-controllable text alone never steers the retry policy; /// the rejection is permanent only together with the 404 status. + #[pa_test_scratch::pa_test] #[test] fn unsupported_tool_rejections_are_terminal() { let mut unsupported = error_message(Some("invalid_request"), Some(404), None); @@ -887,6 +903,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn unsupported_tool_failures_never_retry() { let policy = ProviderRetryPolicy { enabled: true, diff --git a/crates/pa-core/src/session_engine/request_timing/payload/tests.rs b/crates/pa-core/src/session_engine/request_timing/payload/tests.rs index 8eb684057..a5030efae 100644 --- a/crates/pa-core/src/session_engine/request_timing/payload/tests.rs +++ b/crates/pa-core/src/session_engine/request_timing/payload/tests.rs @@ -137,6 +137,7 @@ fn fill_until_saturated(capture: &RequestPayloadCapture, marker_prefix: &str) -> fills } +#[pa_test_scratch::pa_test] #[test] fn the_capture_writes_the_exact_body_and_envelope() { let _writer_lock = super::WRITER_TEST_LOCK.blocking_lock(); @@ -182,6 +183,7 @@ fn the_capture_writes_the_exact_body_and_envelope() { } #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn the_capture_writes_owner_only_modes_even_into_an_existing_dir() { use std::os::unix::fs::PermissionsExt; @@ -211,6 +213,7 @@ fn the_capture_writes_owner_only_modes_even_into_an_existing_dir() { } #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn symlinked_components_end_the_capture_before_any_write() { let _writer_lock = super::WRITER_TEST_LOCK.blocking_lock(); @@ -252,6 +255,7 @@ fn symlinked_components_end_the_capture_before_any_write() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_failed_write_takes_its_temp_file_with_it() { let _writer_lock = super::WRITER_TEST_LOCK.blocking_lock(); @@ -290,6 +294,7 @@ fn a_failed_write_takes_its_temp_file_with_it() { ); } +#[pa_test_scratch::pa_test] #[test] fn an_over_budget_body_drops_without_cloning() { let _writer_lock = super::WRITER_TEST_LOCK.blocking_lock(); @@ -346,6 +351,7 @@ fn an_over_budget_body_drops_without_cloning() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_ring_keeps_the_newest_bodies() { let _writer_lock = super::WRITER_TEST_LOCK.blocking_lock(); @@ -380,6 +386,7 @@ fn the_ring_keeps_the_newest_bodies() { assert_eq!(bodies, [2, 3], "the oldest body left first: {bodies:?}"); } +#[pa_test_scratch::pa_test] #[test] fn two_wirings_sharing_one_dir_each_keep_their_capture() { let _writer_lock = super::WRITER_TEST_LOCK.blocking_lock(); @@ -404,6 +411,7 @@ fn two_wirings_sharing_one_dir_each_keep_their_capture() { assert_eq!(wirings, ["a", "b"], "both captures survived intact"); } +#[pa_test_scratch::pa_test] #[test] fn two_sessions_captures_own_their_directories() { let _writer_lock = super::WRITER_TEST_LOCK.blocking_lock(); @@ -445,6 +453,7 @@ fn two_sessions_captures_own_their_directories() { } } +#[pa_test_scratch::pa_test] #[test] fn an_unwritable_target_disables_the_capture_silently() { let _writer_lock = super::WRITER_TEST_LOCK.blocking_lock(); @@ -464,6 +473,7 @@ fn an_unwritable_target_disables_the_capture_silently() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_record_hands_off_without_waiting_for_the_write() { let _writer_lock = super::WRITER_TEST_LOCK.blocking_lock(); @@ -497,6 +507,7 @@ fn a_record_hands_off_without_waiting_for_the_write() { /// The slot reserve precedes the clone; the self-calibrating bound compares the probe's /// handoff against the same body's measured clone cost. +#[pa_test_scratch::pa_test] #[test] fn a_saturated_queue_drops_without_cloning() { let _writer_lock = super::WRITER_TEST_LOCK.blocking_lock(); @@ -561,6 +572,7 @@ fn a_saturated_queue_drops_without_cloning() { ); } +#[pa_test_scratch::pa_test] #[test] fn concurrent_producers_drop_at_the_reserve_when_the_queue_is_full() { let _writer_lock = super::WRITER_TEST_LOCK.blocking_lock(); diff --git a/crates/pa-core/src/session_engine/request_timing/tests.rs b/crates/pa-core/src/session_engine/request_timing/tests.rs index 146f9f5b6..645e9235e 100644 --- a/crates/pa-core/src/session_engine/request_timing/tests.rs +++ b/crates/pa-core/src/session_engine/request_timing/tests.rs @@ -227,11 +227,13 @@ fn timing_on(log_path: &Path) -> Arc { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn emits_the_full_timeline_first_byte_from_the_response_hook() { emits_the_full_timeline(true).await; } #[tokio::test] +#[pa_test_scratch::pa_test] async fn emits_the_full_timeline_first_byte_from_the_start_event() { emits_the_full_timeline(false).await; } @@ -314,6 +316,7 @@ async fn emits_the_full_timeline(with_response_hook: bool) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn measures_the_payload_once_and_never_when_disabled() { let dir = tempfile::tempdir().unwrap(); let log_path = dir.path().join("agent.jsonl"); @@ -438,6 +441,7 @@ async fn measures_the_payload_once_and_never_when_disabled() { /// The identity-matched slot leaves the parent's entry in place; the /// side question correlates on a fresh sequence. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_cloned_stream_seam_never_steals_the_parent_correlation() { let dir = tempfile::tempdir().unwrap(); let log_path = dir.path().join("agent.jsonl"); @@ -538,6 +542,7 @@ async fn a_cloned_stream_seam_never_steals_the_parent_correlation() { /// protocol encodes failures as terminal events and cannot throw /// mid-iteration. #[tokio::test] +#[pa_test_scratch::pa_test] async fn reports_stream_fn_failures_as_failed() { let dir = tempfile::tempdir().unwrap(); let log_path = dir.path().join("agent.jsonl"); @@ -568,6 +573,7 @@ async fn reports_stream_fn_failures_as_failed() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reports_terminal_error_events() { for (stop_reason, outcome, reason_text) in [ (StopReason::Error, "failed", "error"), @@ -628,6 +634,7 @@ async fn reports_terminal_error_events() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reports_early_termination_as_aborted() { let dir = tempfile::tempdir().unwrap(); let log_path = dir.path().join("agent.jsonl"); @@ -652,6 +659,7 @@ async fn reports_early_termination_as_aborted() { assert_eq!(summary.get("outcome"), Some(&json!("aborted"))); } +#[pa_test_scratch::pa_test] #[test] fn truthy_env_flag_follows_the_offline_convention() { for on in ["1", "true", "yes", "TRUE", "Yes"] { @@ -671,6 +679,7 @@ fn truthy_env_flag_follows_the_offline_convention() { /// Serialized on the env lock: the process env is global. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_env_override_enables_request_timing() { let _guard = REQUEST_TIMING_ENV_LOCK.lock().await; let previous = std::env::var(REQUEST_TIMING_ENV).ok(); @@ -685,6 +694,7 @@ async fn the_env_override_enables_request_timing() { } } +#[pa_test_scratch::pa_test] #[test] fn the_settings_flag_round_trips_and_defaults_off() { let settings: crate::settings::Settings = @@ -705,6 +715,7 @@ fn the_settings_flag_round_trips_and_defaults_off() { /// absent (the TS omission shape); the engine wires the instrumented /// seams from the `requestTiming` settings key. #[tokio::test] +#[pa_test_scratch::pa_test] async fn engine_sessions_emit_the_timeline_only_when_the_flag_is_on() { use crate::session_engine::engine::{create_session, SessionEngineConfig}; use crate::session_engine::provider_adapter::{json_round_trip, real_stream_fn}; @@ -866,6 +877,7 @@ fn payload_calling_provider() -> StreamFn { /// captured body. #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_payload_capture_writes_the_exact_outbound_body() { let _writer_lock = super::payload::WRITER_TEST_LOCK.lock().await; let dir = tempfile::tempdir().unwrap(); @@ -917,6 +929,7 @@ async fn the_payload_capture_writes_the_exact_outbound_body() { #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_payload_capture_writes_nothing_when_the_flag_is_off() { let dir = tempfile::tempdir().unwrap(); let log_path = dir.path().join("agent.jsonl"); @@ -945,6 +958,7 @@ async fn the_payload_capture_writes_nothing_when_the_flag_is_off() { /// The daemon workers' session build is this same `create_session`. #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn engine_sessions_capture_the_outbound_payload_when_the_flag_is_on() { use crate::session_engine::engine::{create_session, SessionEngineConfig}; diff --git a/crates/pa-core/src/session_engine/rlm_host.rs b/crates/pa-core/src/session_engine/rlm_host.rs index 5ad7d4159..ca4f5d3fd 100644 --- a/crates/pa-core/src/session_engine/rlm_host.rs +++ b/crates/pa-core/src/session_engine/rlm_host.rs @@ -1095,6 +1095,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn find_models_round_trip_through_the_registry() { let dir = tempfile::TempDir::new().unwrap(); let wiring = wired(dir.path(), None); @@ -1176,6 +1177,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn progress_note_throttles_and_stores() { let dir = tempfile::TempDir::new().unwrap(); let wiring = wired(dir.path(), None); @@ -1230,6 +1232,7 @@ mod tests { /// The accepted note announces with its message and wall-clock /// timestamp; a throttled note announces nothing. #[tokio::test] + #[pa_test_scratch::pa_test] async fn accepted_note_announces_throttled_note_stays_silent() { let dir = tempfile::TempDir::new().unwrap(); let session = persisted_session(dir.path()); @@ -1279,6 +1282,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn spawn_round_trip_through_the_registry() { let dir = tempfile::TempDir::new().unwrap(); let host = RecordingHost::new(); @@ -1369,6 +1373,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn create_session_round_trip_through_the_registry() { let dir = tempfile::TempDir::new().unwrap(); let host = RecordingHost::new(); @@ -1450,6 +1455,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn roster_collect_and_delete_round_trip() { let dir = tempfile::TempDir::new().unwrap(); let host = RecordingHost::new(); @@ -1544,6 +1550,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn rename_round_trip_and_validation() { let dir = tempfile::TempDir::new().unwrap(); let host = RecordingHost::new(); @@ -1618,6 +1625,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn no_host_rename_appends_locally_and_rejects_child_targets() { let dir = tempfile::TempDir::new().unwrap(); let wiring = wired(dir.path(), None); @@ -1646,6 +1654,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn no_host_session_reports_empty_roster_and_selector_misses() { let dir = tempfile::TempDir::new().unwrap(); let wiring = wired(dir.path(), None); diff --git a/crates/pa-core/src/session_engine/rlm_notices.rs b/crates/pa-core/src/session_engine/rlm_notices.rs index 13244a242..3725fbdea 100644 --- a/crates/pa-core/src/session_engine/rlm_notices.rs +++ b/crates/pa-core/src/session_engine/rlm_notices.rs @@ -119,6 +119,7 @@ pub fn create_rlm_child_failure_message( mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn no_reply_notice_matches_the_ts_shape() { let notice = RlmChildTerminalNotice::CompletedWithoutReply { @@ -143,6 +144,7 @@ mod tests { assert_eq!(details["lastAssistantTextPreview"], "done with the task"); } + #[pa_test_scratch::pa_test] #[test] fn cancelled_notice_without_reason_has_no_body() { let notice = RlmChildTerminalNotice::Cancelled { @@ -160,6 +162,7 @@ mod tests { assert_eq!(details["reason"], serde_json::Value::Null); } + #[pa_test_scratch::pa_test] #[test] fn cancelled_notice_carries_the_reason_body() { let notice = RlmChildTerminalNotice::Cancelled { @@ -177,6 +180,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn failure_notice_matches_the_ts_shape() { let message = create_rlm_child_failure_message("sub-9", "lane", "boom", 4_000); diff --git a/crates/pa-core/src/session_engine/rlm_usage.rs b/crates/pa-core/src/session_engine/rlm_usage.rs index de051c766..4fcd17b5c 100644 --- a/crates/pa-core/src/session_engine/rlm_usage.rs +++ b/crates/pa-core/src/session_engine/rlm_usage.rs @@ -558,6 +558,7 @@ mod tests { /// and totalTokens FROZEN at the parent's 23,032; the raw parent's /// cache/output split is synthetic. #[tokio::test] + #[pa_test_scratch::pa_test] async fn captured_ts_fixture_attributes_with_frozen_total_tokens() { let raw_parent = usage_block(2_690, 1_577, 19_917, 0, 23_032, 0.0); let child = usage_block(50_208, 2_929, 0, 0, 53_137, 0.008_995_7); @@ -610,6 +611,7 @@ mod tests { /// the retired registrations and bases, so a post-swap report continues /// the chain instead of dropping. #[tokio::test] + #[pa_test_scratch::pa_test] async fn rebuild_adoption_continues_the_aggregate_chain() { let raw_parent = usage_block(1_000, 0, 0, 0, 4_096, 0.0); let (_tmp, manager) = manager_with_assistant(raw_parent); @@ -772,6 +774,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn multiple_children_and_origins_share_the_cumulative_base() { let raw_parent = usage_block(1_000, 100, 0, 0, 1_100, 0.01); let (_tmp, manager) = manager_with_assistant(raw_parent); @@ -824,6 +827,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn unregistered_child_report_attributes_nothing() { let (_tmp, manager) = manager_with_assistant(usage_block(1, 1, 0, 0, 2, 0.0)); let producer = producer(manager.clone()); @@ -875,6 +879,7 @@ mod tests { /// A failed append returns false and writes no row; the retry persists /// the batch once, folding from the unchanged base (no double fold). #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_failed_append_leaves_the_base_for_the_retry() { let raw_parent = usage_block(1_000, 0, 0, 0, 4_096, 0.0); let (_tmp, manager) = manager_with_assistant(raw_parent); @@ -956,6 +961,7 @@ mod tests { /// Acknowledged origins must not be folded again when a later origin fails. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_partially_persisted_report_is_counted_once_on_retry() { let (_tmp, manager) = manager_with_assistant(usage_block(1_000, 0, 0, 0, 4_096, 0.0)); let producer = @@ -1004,6 +1010,7 @@ mod tests { /// An error after a complete real append cannot safely mean nothing persisted. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_persisted_report_with_lost_acknowledgment_is_not_appended_twice() { let (_tmp, manager) = manager_with_assistant(usage_block(1_000, 0, 0, 0, 4_096, 0.0)); let producer = diff --git a/crates/pa-core/src/session_engine/runtime.rs b/crates/pa-core/src/session_engine/runtime.rs index d5d5e7c0a..455b53715 100644 --- a/crates/pa-core/src/session_engine/runtime.rs +++ b/crates/pa-core/src/session_engine/runtime.rs @@ -206,6 +206,7 @@ mod tests { /// The purge seam fires only for `goal.complete`, never on the way in. #[tokio::test] + #[pa_test_scratch::pa_test] async fn goal_complete_purge_runs_only_after_goal_complete() { let (_session_dir, session) = persisted_session(); let session = Arc::new(Mutex::new(session)); @@ -249,6 +250,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn goal_handlers_round_trip_through_the_registry() { let (_session_dir, session) = persisted_session(); let session = Arc::new(Mutex::new(session)); @@ -304,6 +306,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn heartbeat_handlers_round_trip_through_the_registry() { let (_session_dir, session) = persisted_session(); let session = Arc::new(Mutex::new(session)); @@ -348,6 +351,7 @@ mod tests { /// Catalog reads announce nothing. #[tokio::test] + #[pa_test_scratch::pa_test] async fn rlm_heartbeat_mutations_invoke_the_cron_mutation_hook() { let (_session_dir, session) = persisted_session(); let session = Arc::new(Mutex::new(session)); diff --git a/crates/pa-core/src/session_engine/runtime_wiring.rs b/crates/pa-core/src/session_engine/runtime_wiring.rs index a75393fa8..9c849c5e1 100644 --- a/crates/pa-core/src/session_engine/runtime_wiring.rs +++ b/crates/pa-core/src/session_engine/runtime_wiring.rs @@ -429,6 +429,7 @@ mod tests { use super::{kernel_exec_error, KernelExecError}; use crate::kernel::shared::KernelBusyAfterInterruptError; + #[pa_test_scratch::pa_test] #[test] fn busy_after_interrupt_survives_the_adapter() { let error = kernel_exec_error(anyhow::Error::new(KernelBusyAfterInterruptError)); @@ -439,6 +440,7 @@ mod tests { assert!(matches!(error, KernelExecError::BusyAfterInterrupt(_))); } + #[pa_test_scratch::pa_test] #[test] fn other_kernel_errors_stay_other() { let error = kernel_exec_error(anyhow::anyhow!("kernel exploded")); diff --git a/crates/pa-core/src/session_engine/semantic_edges/ledger.rs b/crates/pa-core/src/session_engine/semantic_edges/ledger.rs index d6b70f0e8..5cff40847 100644 --- a/crates/pa-core/src/session_engine/semantic_edges/ledger.rs +++ b/crates/pa-core/src/session_engine/semantic_edges/ledger.rs @@ -153,6 +153,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn short_append_fails_without_a_second_write() { let mut writer = ShortWriter { writes: 0 }; diff --git a/crates/pa-core/src/session_engine/semantic_edges/tests.rs b/crates/pa-core/src/session_engine/semantic_edges/tests.rs index d27fe35af..b45ae1cdc 100644 --- a/crates/pa-core/src/session_engine/semantic_edges/tests.rs +++ b/crates/pa-core/src/session_engine/semantic_edges/tests.rs @@ -63,6 +63,7 @@ fn request_started_slice( } } +#[pa_test_scratch::pa_test] #[test] fn a_turn_lifecycle_is_ledgered_and_reopening_replays_without_reregistering() { let (identity, _dir) = identity("session-a"); @@ -98,6 +99,7 @@ fn a_turn_lifecycle_is_ledgered_and_reopening_replays_without_reregistering() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_parked_retry_reuses_its_id_only_for_an_identical_body_in_the_same_epoch() { let (identity, _dir) = identity("session-b"); @@ -155,6 +157,7 @@ fn a_parked_retry_reuses_its_id_only_for_an_identical_body_in_the_same_epoch() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn split_summary_slices_commit_in_resolve_order() { let (identity, _dir) = identity("session-g"); let recorder = Arc::new(SemanticEdgeRecorder::open(identity.clone())); @@ -227,6 +230,7 @@ async fn split_summary_slices_commit_in_resolve_order() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_ledger_failure_drops_the_spawn_anchor() { let (identity, _dir) = identity("session-e"); @@ -248,6 +252,7 @@ fn a_ledger_failure_drops_the_spawn_anchor() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_torn_final_line_is_ignored_on_replay_and_truncated_before_the_next_append() { let (identity, _dir) = identity("session-c"); @@ -358,6 +363,7 @@ async fn wrapped_call( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn turn_requests_carry_both_headers_and_settle_by_stop_reason() { let (identity, _dir) = identity("session-d"); let recorder = Arc::new(SemanticEdgeRecorder::open(identity.clone())); diff --git a/crates/pa-core/src/session_engine/session_commands.rs b/crates/pa-core/src/session_engine/session_commands.rs index 56a6b8644..b9de197f3 100644 --- a/crates/pa-core/src/session_engine/session_commands.rs +++ b/crates/pa-core/src/session_engine/session_commands.rs @@ -440,6 +440,7 @@ mod tests { message.content.text() } + #[pa_test_scratch::pa_test] #[test] fn echo_row_shape_matches_ts() { let echo = session_command_echo_row(&command("compact", "focus on tests")); @@ -457,6 +458,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn result_row_shape_matches_ts() { let result = slash_command_result( @@ -484,6 +486,7 @@ mod tests { assert_eq!(failed.details.unwrap()["error"], serde_json::json!("boom")); } + #[pa_test_scratch::pa_test] #[test] fn goal_status_text_matches_ts() { let mut state = empty_goal_state(); @@ -508,6 +511,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn plugin_executor_needs_no_provider_inputs_and_reload_is_history_free() { let dir = tempfile::tempdir().unwrap(); let cwd = dir.path().join("project"); @@ -586,6 +590,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn goal_state_slugs() { let state = GoalState { diff --git a/crates/pa-core/src/session_engine/session_events.rs b/crates/pa-core/src/session_engine/session_events.rs index 82fc84ca9..8a31a0923 100644 --- a/crates/pa-core/src/session_engine/session_events.rs +++ b/crates/pa-core/src/session_engine/session_events.rs @@ -220,6 +220,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn message_update_event_json_wraps_the_partial_and_delta() { let message = partial(vec![AssistantContent::Text(TextContent { @@ -245,6 +246,7 @@ mod tests { serde_json::json!({"type": "text_delta", "contentIndex": 0, "delta": "first reply"}) ); } + #[pa_test_scratch::pa_test] #[test] fn assistant_message_event_wire_shapes_match_ts() { let message = partial(Vec::new()); diff --git a/crates/pa-core/src/session_engine/side_question.rs b/crates/pa-core/src/session_engine/side_question.rs index 53e3cb864..32258e351 100644 --- a/crates/pa-core/src/session_engine/side_question.rs +++ b/crates/pa-core/src/session_engine/side_question.rs @@ -583,6 +583,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn answers_from_the_cloned_conversation() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_text_turn("the side answer"); @@ -614,6 +615,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn side_question_reuses_the_parent_session_id() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_text_turn("the side answer"); @@ -651,6 +653,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn previous_turns_replay_after_the_clone() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_text_turn("follow-up answer"); @@ -684,6 +687,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn provider_failures_are_retried() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_stream_failure_turn("partial stream", "provider stream broke"); @@ -697,6 +701,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn exhausted_retries_fail_the_run() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_stream_failure_turn("", "provider stream broke"); @@ -716,6 +721,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn abort_mid_run_cancels_with_partial_answer() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_stalled_turn("partial answer"); @@ -737,6 +743,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cancelled_sink_aborts_the_run() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_stalled_turn("streaming text"); @@ -751,6 +758,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn tool_calls_are_blocked_and_turn_capped() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_tool_call_turn(None, vec![("call-1", "echo", serde_json::json!({}))]); @@ -776,6 +784,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn missing_model_fails_the_run() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_text_turn("never reached"); diff --git a/crates/pa-core/src/session_engine/skills_unavailable_notice.rs b/crates/pa-core/src/session_engine/skills_unavailable_notice.rs index ab15a5914..c4846fa9f 100644 --- a/crates/pa-core/src/session_engine/skills_unavailable_notice.rs +++ b/crates/pa-core/src/session_engine/skills_unavailable_notice.rs @@ -63,6 +63,7 @@ mod tests { ] } + #[pa_test_scratch::pa_test] #[test] fn notice_names_each_failed_skill_and_its_error() { let message = notice_message(&errors()); diff --git a/crates/pa-core/src/session_engine/slash_commands.rs b/crates/pa-core/src/session_engine/slash_commands.rs index 2ef365290..a17b9ac1a 100644 --- a/crates/pa-core/src/session_engine/slash_commands.rs +++ b/crates/pa-core/src/session_engine/slash_commands.rs @@ -41,6 +41,7 @@ pub fn parse_session_command( mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn session_command_extraction() { let registry = SlashCommandRegistry::builtin(); diff --git a/crates/pa-core/src/session_engine/slash_session_tests.rs b/crates/pa-core/src/session_engine/slash_session_tests.rs index 67efea114..448fdca8c 100644 --- a/crates/pa-core/src/session_engine/slash_session_tests.rs +++ b/crates/pa-core/src/session_engine/slash_session_tests.rs @@ -13,6 +13,7 @@ fn test_model() -> pa_agent::types::Model { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn session_commands_never_reach_the_model() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_text_turn("unused"); diff --git a/crates/pa-core/src/session_engine/state_restore_notice.rs b/crates/pa-core/src/session_engine/state_restore_notice.rs index cac454414..46c34c47e 100644 --- a/crates/pa-core/src/session_engine/state_restore_notice.rs +++ b/crates/pa-core/src/session_engine/state_restore_notice.rs @@ -84,6 +84,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn revived_notice_lists_names() { let message = notice_message(&restore(vec!["data", "helper"], vec![])); @@ -102,6 +103,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn empty_restore_notifies_fresh_kernel() { let message = notice_message(&restore(vec![], vec![])); @@ -118,6 +120,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn failed_names_get_the_recreate_line() { let message = notice_message(&restore(vec!["data"], vec![("sock", "cannot pickle")])); diff --git a/crates/pa-core/src/session_engine/tests.rs b/crates/pa-core/src/session_engine/tests.rs index 1ca621e5d..66d03cf40 100644 --- a/crates/pa-core/src/session_engine/tests.rs +++ b/crates/pa-core/src/session_engine/tests.rs @@ -32,6 +32,7 @@ async fn scripted_session() -> AgentSession { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn prompt_persists_user_and_assistant() { let session = scripted_session().await; session @@ -61,6 +62,7 @@ async fn prompt_persists_user_and_assistant() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_skill_command_prompt_expands_into_the_skill_block() { // TS `_expandSkillCommand`: a `/skill: [args]` submission // persists as the `` block plus the argument text; the @@ -112,6 +114,7 @@ async fn a_skill_command_prompt_expands_into_the_skill_block() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_unknown_skill_command_passes_through() { let session = scripted_session().await; session @@ -178,6 +181,7 @@ fn user_text(message: &pa_agent::types::Message) -> String { /// turn (the custom row, appended once), never a duplicate user /// message. #[tokio::test] +#[pa_test_scratch::pa_test] async fn prompt_injected_message_persists_one_custom_row() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_text_turn("notice acknowledged"); @@ -250,6 +254,7 @@ async fn prompt_injected_message_persists_one_custom_row() { /// The comparison covers the whole request - system prompt, tools, and /// every message row - with only the per-run timestamps normalized. #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_agent_message_custom_row_matches_the_plain_prompt_context() { let prompt = "[agent-message from child:research-lane]\n\nthe research is done"; @@ -311,6 +316,7 @@ fn normalized_context(context: &pa_agent::stream::LlmContext) -> serde_json::Val } #[tokio::test] +#[pa_test_scratch::pa_test] async fn prompt_persists_tool_results() { struct EchoTool; impl pa_agent::types::AgentTool for EchoTool { @@ -431,6 +437,7 @@ async fn prompt_persists_tool_results() { /// Persisted `ipython`/`python` calls dispatch through `ToolDefinitionBridge` /// to the registered Python tool. #[tokio::test] +#[pa_test_scratch::pa_test] async fn python_tool_aliases_dispatch_to_python_repl() { let calls = Arc::new(std::sync::atomic::AtomicUsize::new(0)); let definition = crate::tools::tool_definition::ToolDefinition { @@ -513,6 +520,7 @@ async fn python_tool_aliases_dispatch_to_python_repl() { /// A `toolResult` entry captured from a live TS session (read-only, from /// the installed product's own session store) parses into the Rust /// session types and re-serializes to the identical wire shape. +#[pa_test_scratch::pa_test] #[test] fn ts_toolresult_entry_round_trips() { let golden: serde_json::Value = serde_json::from_str(include_str!( @@ -550,6 +558,7 @@ fn ts_toolresult_entry_round_trips() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn template_expansion_applies() { let provider = Arc::new(ScriptedProvider::new(test_model())); provider.push_text_turn("ok"); @@ -605,6 +614,7 @@ async fn template_expansion_applies() { /// branch switch between turns is recorded by the next run, and an unchanged /// context at `agent_end` adds nothing. #[tokio::test] +#[pa_test_scratch::pa_test] async fn run_boundaries_record_git_state() { fn git(cwd: &std::path::Path, args: &[&str]) { let output = std::process::Command::new("git") @@ -699,6 +709,7 @@ async fn run_boundaries_record_git_state() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn durable_event_failure_refuses_local_message_publication() { struct RefusingWriter; impl crate::session::manager::SessionEntryWriter for RefusingWriter { @@ -724,6 +735,7 @@ async fn durable_event_failure_refuses_local_message_publication() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn custom_event_replays_exact_admitted_row_without_another_append() { let mut manager = SessionManager::in_memory(std::path::Path::new("/tmp")); let row = pa_types::session::CustomMessage { @@ -753,6 +765,7 @@ async fn custom_event_replays_exact_admitted_row_without_another_append() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn admitted_user_event_uses_stored_message_not_transient_timestamp() { let mut manager = SessionManager::in_memory(std::path::Path::new("/tmp")); let original: SessionAgentMessage = serde_json::from_value(serde_json::json!({ @@ -779,6 +792,7 @@ async fn admitted_user_event_uses_stored_message_not_transient_timestamp() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn admitted_custom_event_uses_stored_timestamp_details_and_extra_fields() { let mut manager = SessionManager::in_memory(std::path::Path::new("/tmp")); let id = manager @@ -822,6 +836,7 @@ async fn admitted_custom_event_uses_stored_timestamp_details_and_extra_fields() } #[tokio::test] +#[pa_test_scratch::pa_test] async fn context_custom_prefix_cannot_consume_the_admitted_custom_input() { let mut manager = SessionManager::in_memory(std::path::Path::new("/tmp")); let id = manager @@ -891,6 +906,7 @@ async fn context_custom_prefix_cannot_consume_the_admitted_custom_input() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn engine_supplies_session_id_to_the_model_stream() { let dir = tempfile::tempdir().unwrap(); let cwd = dir.path().join("project"); diff --git a/crates/pa-core/src/session_engine/tool_bridge.rs b/crates/pa-core/src/session_engine/tool_bridge.rs index cb90846f9..e80ce32b0 100644 --- a/crates/pa-core/src/session_engine/tool_bridge.rs +++ b/crates/pa-core/src/session_engine/tool_bridge.rs @@ -177,6 +177,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn bridges_definition_into_the_loop_contract() { let tool = bridge_tool(echo_definition(false)); assert_eq!(tool.name(), "echo"); @@ -205,6 +206,7 @@ mod tests { /// The interactive loader's kernel-boot note and live cell output /// ride this channel. #[tokio::test] + #[pa_test_scratch::pa_test] async fn streamed_updates_reach_the_loop_callback() { use std::sync::Mutex; let definition = ToolDefinition { @@ -253,6 +255,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn errors_surface_as_err_like_a_throw() { let tool = bridge_tool(echo_definition(true)); let error = tool diff --git a/crates/pa-core/src/session_engine/tool_bridge/error_status_tests.rs b/crates/pa-core/src/session_engine/tool_bridge/error_status_tests.rs index 28d15082a..8cef7c956 100644 --- a/crates/pa-core/src/session_engine/tool_bridge/error_status_tests.rs +++ b/crates/pa-core/src/session_engine/tool_bridge/error_status_tests.rs @@ -298,11 +298,13 @@ async fn assert_persisted_status(is_error: bool) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn error_flag_survives_rich_result_to_provider_sdk_events_and_disk() { assert_persisted_status(/*is_error*/ true).await; } #[tokio::test] +#[pa_test_scratch::pa_test] async fn success_flag_ignores_error_strings_in_details_through_all_boundaries() { assert_persisted_status(/*is_error*/ false).await; } diff --git a/crates/pa-core/src/session_engine/turn_activity.rs b/crates/pa-core/src/session_engine/turn_activity.rs index 1c3067a51..435a6a738 100644 --- a/crates/pa-core/src/session_engine/turn_activity.rs +++ b/crates/pa-core/src/session_engine/turn_activity.rs @@ -194,6 +194,7 @@ impl TurnActivitySignal { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn guards_nest_and_clear_only_at_the_outer_drop() { let signal = TurnActivitySignal::new(); @@ -207,6 +208,7 @@ mod tests { assert!(!signal.activity().busy()); } + #[pa_test_scratch::pa_test] #[test] fn compaction_and_retry_are_distinct_busy_classes() { let signal = TurnActivitySignal::new(); @@ -233,6 +235,7 @@ mod tests { assert!(!signal.activity().busy()); } + #[pa_test_scratch::pa_test] #[test] fn a_host_probe_overrides_the_engine_state() { let signal = TurnActivitySignal::new(); diff --git a/crates/pa-core/src/session_engine/turn_boundary/tests.rs b/crates/pa-core/src/session_engine/turn_boundary/tests.rs index e54c3cbd8..aa35d1cbc 100644 --- a/crates/pa-core/src/session_engine/turn_boundary/tests.rs +++ b/crates/pa-core/src/session_engine/turn_boundary/tests.rs @@ -137,6 +137,7 @@ fn handler( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn model_info_reports_the_bound_model() { let requests = Arc::new(TurnBoundaryRequests::new()); let handlers = registered(&requests); @@ -181,6 +182,7 @@ async fn model_info_reports_the_bound_model() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn compact_run_validates_and_reports_no_active_turn() { let requests = Arc::new(TurnBoundaryRequests::new()); let handlers = registered(&requests); @@ -234,6 +236,7 @@ async fn compact_run_validates_and_reports_no_active_turn() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn compact_run_prepare_skips_report_the_ts_reasons() { for ((_session_dir, case), expected) in [ // A branch ending in a compaction has nothing new to summarize. @@ -279,6 +282,7 @@ async fn compact_run_prepare_skips_report_the_ts_reasons() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn compact_run_schedules_inside_a_tool_call_and_status_sees_it() { let requests = Arc::new(TurnBoundaryRequests::new()); let handlers = registered(&requests); @@ -340,6 +344,7 @@ async fn compact_run_schedules_inside_a_tool_call_and_status_sees_it() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn clear_pending_drops_scheduled_requests() { let requests = Arc::new(TurnBoundaryRequests::new()); registered(&requests); @@ -381,6 +386,7 @@ async fn clear_pending_drops_scheduled_requests() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn compact_run_merges_instructions_into_a_pending_request() { let requests = Arc::new(TurnBoundaryRequests::new()); registered(&requests); @@ -427,6 +433,7 @@ async fn compact_run_merges_instructions_into_a_pending_request() { ); } +#[pa_test_scratch::pa_test] #[test] fn context_usage_anchors_on_the_last_valid_assistant_usage() { let dir = tempfile::TempDir::new().unwrap(); @@ -462,6 +469,7 @@ fn context_usage_anchors_on_the_last_valid_assistant_usage() { assert!((percent - (usage.tokens.unwrap() as f64 / 100_000.0 * 100.0)).abs() < 1e-9); } +#[pa_test_scratch::pa_test] #[test] fn context_usage_after_a_compaction_falls_back_to_the_view_estimate() { let (_session_dir, mut session) = session_with_history(false); @@ -486,6 +494,7 @@ fn context_usage_after_a_compaction_falls_back_to_the_view_estimate() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_failing_live_view_falls_back_to_the_edit_aware_walk() { let requests = Arc::new(TurnBoundaryRequests::new()); let handlers = registered(&requests); diff --git a/crates/pa-core/src/session_log/crc.rs b/crates/pa-core/src/session_log/crc.rs index 8f6c03568..adf85ecfe 100644 --- a/crates/pa-core/src/session_log/crc.rs +++ b/crates/pa-core/src/session_log/crc.rs @@ -43,6 +43,7 @@ pub(crate) fn crc32_parts(parts: &[&[u8]]) -> u32 { mod tests { use super::crc32_parts; + #[pa_test_scratch::pa_test] #[test] fn matches_the_published_check_value_over_the_parts() { // The CRC-32 check value every implementation agrees on, reached both diff --git a/crates/pa-core/src/session_log/follower.rs b/crates/pa-core/src/session_log/follower.rs index e4627c9ad..09b80b3be 100644 --- a/crates/pa-core/src/session_log/follower.rs +++ b/crates/pa-core/src/session_log/follower.rs @@ -148,6 +148,7 @@ mod tests { Instant::now() + Duration::from_secs(10) } + #[pa_test_scratch::pa_test] #[test] fn independent_cursors_extend_without_replaying_the_prefix() { let dir = tempfile::tempdir().unwrap(); @@ -183,6 +184,7 @@ mod tests { assert!(log.read_tail(&mut cursor, deadline()).unwrap().is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn repair_and_regrowth_cannot_reuse_a_followers_boundary() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/session_log/line.rs b/crates/pa-core/src/session_log/line.rs index 7b8382499..1faa3ea25 100644 --- a/crates/pa-core/src/session_log/line.rs +++ b/crates/pa-core/src/session_log/line.rs @@ -294,6 +294,7 @@ mod tests { ) } + #[pa_test_scratch::pa_test] #[test] fn a_bare_line_is_its_own_row() { assert_eq!( @@ -303,6 +304,7 @@ mod tests { assert_eq!(shape(br#"{"type":"message"}"#), Some(Format::Bare)); } + #[pa_test_scratch::pa_test] #[test] fn an_envelope_yields_the_row_it_wraps() { let body = r#"{"type":"message","id":"b"}"#; @@ -315,6 +317,7 @@ mod tests { assert!(parse(line.replace("id", "ie").as_bytes(), 1).is_none()); } + #[pa_test_scratch::pa_test] #[test] fn a_partial_envelope_is_damage_and_never_a_row() { let body = r#"{"type":"message","id":"c"}"#; @@ -336,6 +339,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn a_non_object_or_a_trailing_byte_is_not_a_row() { assert!(parse(br#"{"type":"message"} {"x":1}"#, 0).is_none()); @@ -343,6 +347,7 @@ mod tests { assert!(parse(b"", 0).is_none()); } + #[pa_test_scratch::pa_test] #[test] fn both_shapes_round_trip_through_their_encoder() { let body = r#"{"type":"message","content":"line\nbreak"}"#; @@ -354,6 +359,7 @@ mod tests { assert_eq!(parse(wrapped.as_bytes(), 6).unwrap().1, body); assert!(parse(wrapped.as_bytes(), 7).is_none()); } + #[pa_test_scratch::pa_test] #[test] fn a_null_envelope_member_still_marks_the_line_as_an_envelope() { // `Option` fields cannot tell an absent member from a null one, so the @@ -373,6 +379,7 @@ mod tests { assert!(!super::reserved_name(br#"{"type":"message","id":"a"}"#)); } + #[pa_test_scratch::pa_test] #[test] fn a_backwards_walk_checks_that_neighbouring_envelopes_agree() { use super::BackwardsSequence; diff --git a/crates/pa-core/src/session_log/tests.rs b/crates/pa-core/src/session_log/tests.rs index b7272be51..179ec4a30 100644 --- a/crates/pa-core/src/session_log/tests.rs +++ b/crates/pa-core/src/session_log/tests.rs @@ -136,6 +136,7 @@ impl Disk for TestDisk { } } +#[pa_test_scratch::pa_test] #[test] fn append_and_read_round_trip() { let temp = tempfile::tempdir().unwrap(); @@ -158,6 +159,7 @@ fn append_and_read_round_trip() { assert_eq!(tail[0].seq, 2); } +#[pa_test_scratch::pa_test] #[test] fn a_killed_writer_leaves_a_torn_tail_that_repair_truncates() { let temp = tempfile::tempdir().unwrap(); @@ -204,6 +206,7 @@ fn a_killed_writer_leaves_a_torn_tail_that_repair_truncates() { assert_eq!(log.read_since(0).unwrap().len(), 3); } +#[pa_test_scratch::pa_test] #[test] fn reading_stops_at_a_torn_tail_without_repairing() { let temp = tempfile::tempdir().unwrap(); @@ -224,6 +227,7 @@ fn reading_stops_at_a_torn_tail_without_repairing() { ); } +#[pa_test_scratch::pa_test] #[test] fn an_interrupted_write_is_provably_not_written() { let temp = tempfile::tempdir().unwrap(); @@ -264,6 +268,7 @@ fn an_interrupted_write_is_provably_not_written() { assert_eq!(committed_seq(&log.append(&row(1), deadline())), Some(1)); } +#[pa_test_scratch::pa_test] #[test] fn a_second_writer_is_refused_at_the_deadline() { let temp = tempfile::tempdir().unwrap(); @@ -290,6 +295,7 @@ fn a_second_writer_is_refused_at_the_deadline() { assert_eq!(committed_seq(&log.append(&row(1), deadline())), Some(1)); } +#[pa_test_scratch::pa_test] #[test] fn two_writers_never_share_a_seq() { let temp = tempfile::tempdir().unwrap(); @@ -312,6 +318,7 @@ fn two_writers_never_share_a_seq() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_crash_before_the_directory_sync_leaves_no_partial_row() { let temp = tempfile::tempdir().unwrap(); @@ -335,6 +342,7 @@ fn a_crash_before_the_directory_sync_leaves_no_partial_row() { assert_eq!(log.read_since(0).unwrap().len(), 1); } +#[pa_test_scratch::pa_test] #[test] fn a_failed_fsync_is_undecided_and_recover_never_lies() { for bytes_survive in [true, false] { @@ -401,6 +409,7 @@ fn a_failed_fsync_is_undecided_and_recover_never_lies() { } } +#[pa_test_scratch::pa_test] #[test] fn a_duplicate_retry_is_idempotent() { let temp = tempfile::tempdir().unwrap(); @@ -442,6 +451,7 @@ fn a_duplicate_retry_is_idempotent() { assert_eq!(log.read_since(0).unwrap().len(), 1); } +#[pa_test_scratch::pa_test] #[test] fn a_flipped_byte_stops_the_read_and_is_reported_by_repair() { let temp = tempfile::tempdir().unwrap(); @@ -480,6 +490,7 @@ fn a_flipped_byte_stops_the_read_and_is_reported_by_repair() { assert!(report.truncated_bytes > 0, "repair reports the damage"); } +#[pa_test_scratch::pa_test] #[test] fn a_byte_flip_inside_a_string_is_the_damage_a_bare_line_cannot_show() { // The envelope's checksum caught this; a bare line does not. Stated as a @@ -510,6 +521,7 @@ fn a_byte_flip_inside_a_string_is_the_damage_a_bare_line_cannot_show() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_legacy_envelope_log_loads_and_its_seq_must_match_its_position() { let temp = tempfile::tempdir().unwrap(); @@ -572,6 +584,7 @@ fn a_legacy_envelope_log_loads_and_its_seq_must_match_its_position() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_new_file_is_bare_and_its_lines_are_the_rows() { let temp = tempfile::tempdir().unwrap(); @@ -587,6 +600,7 @@ fn a_new_file_is_bare_and_its_lines_are_the_rows() { assert_eq!(text, expected); } +#[pa_test_scratch::pa_test] #[test] fn a_partial_envelope_appended_by_a_foreign_writer_is_corrupt_not_a_row() { // A line that names any part of the envelope is judged as an envelope. A @@ -621,6 +635,7 @@ fn a_partial_envelope_appended_by_a_foreign_writer_is_corrupt_not_a_row() { } } +#[pa_test_scratch::pa_test] #[test] fn a_wrong_seq_envelope_is_rejected_wherever_it_is_read() { let temp = tempfile::tempdir().unwrap(); @@ -650,6 +665,7 @@ fn a_wrong_seq_envelope_is_rejected_wherever_it_is_read() { assert_eq!(std::fs::read(&path).unwrap(), envelope.as_bytes()); } +#[pa_test_scratch::pa_test] #[test] fn every_append_writes_the_row_itself() { let temp = tempfile::tempdir().unwrap(); @@ -680,6 +696,7 @@ fn every_append_writes_the_row_itself() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_foreign_line_does_not_change_what_the_next_append_writes() { // Another writer may append either shape after this handle opened: an old @@ -717,6 +734,7 @@ fn a_foreign_line_does_not_change_what_the_next_append_writes() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_row_may_not_carry_a_reserved_name() { // The reader judges a line that names seq/ts/crc/row as an envelope, so a @@ -745,6 +763,7 @@ fn a_row_may_not_carry_a_reserved_name() { assert_eq!(committed_seq(&log.append(&row(2), deadline())), Some(2)); } +#[pa_test_scratch::pa_test] #[test] fn a_file_holding_both_shapes_reads() { // A row followed by an envelope is what an append by this binary to a legacy @@ -775,6 +794,7 @@ fn a_file_holding_both_shapes_reads() { assert_eq!(log.read_since(0).unwrap().len(), 3); } +#[pa_test_scratch::pa_test] #[test] fn a_corrupt_first_envelope_line_is_left_for_an_operator() { // With nothing before the damage there is no anchor: a repair would empty @@ -804,6 +824,7 @@ fn a_corrupt_first_envelope_line_is_left_for_an_operator() { assert_eq!(std::fs::read(&path).unwrap(), bytes); } +#[pa_test_scratch::pa_test] #[test] fn a_creator_crash_before_the_directory_sync_is_repaired_by_the_next_open() { let temp = tempfile::tempdir().unwrap(); @@ -839,6 +860,7 @@ fn a_creator_crash_before_the_directory_sync_is_repaired_by_the_next_open() { assert_eq!(committed_seq(&log.append(&row(1), deadline())), Some(1)); } +#[pa_test_scratch::pa_test] #[test] fn the_busy_holder_record_round_trips() { let temp = tempfile::tempdir().unwrap(); @@ -903,6 +925,7 @@ fn the_busy_holder_record_round_trips() { assert_eq!(committed_seq(&log.append(&row(3), deadline())), Some(3)); } +#[pa_test_scratch::pa_test] #[test] fn an_oversized_row_is_refused_before_it_is_written() { let temp = tempfile::tempdir().unwrap(); @@ -936,6 +959,7 @@ fn an_oversized_row_is_refused_before_it_is_written() { assert_eq!(committed_seq(&log.append(&row(2), deadline())), Some(2)); } +#[pa_test_scratch::pa_test] #[test] fn an_append_behind_a_corrupt_tail_is_refused_with_its_own_reason() { let temp = tempfile::tempdir().unwrap(); @@ -978,6 +1002,7 @@ fn an_append_behind_a_corrupt_tail_is_refused_with_its_own_reason() { )); } +#[pa_test_scratch::pa_test] #[test] fn a_damaged_bare_file_is_never_truncated_by_open_or_repair() { // Nineteen logs on the live disk are bare and carry a complete line that is @@ -1018,6 +1043,7 @@ fn a_damaged_bare_file_is_never_truncated_by_open_or_repair() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_torn_tail_on_a_bare_file_is_still_repaired() { // A torn tail is a write that never became a row: dropping it loses nothing, @@ -1042,6 +1068,7 @@ fn a_torn_tail_on_a_bare_file_is_still_repaired() { assert_eq!(committed_seq(&log.append(&row(2), deadline())), Some(2)); } +#[pa_test_scratch::pa_test] #[test] fn seq_keeps_increasing_across_handles() { let temp = tempfile::tempdir().unwrap(); @@ -1055,6 +1082,7 @@ fn seq_keeps_increasing_across_handles() { assert_eq!(second.read_since(1).unwrap().len(), 2); } +#[pa_test_scratch::pa_test] #[test] fn refresh_reads_only_the_new_tail_and_advances_the_cursor() { let temp = tempfile::tempdir().unwrap(); @@ -1101,6 +1129,7 @@ fn refresh_reads_only_the_new_tail_and_advances_the_cursor() { ); } +#[pa_test_scratch::pa_test] #[test] fn refresh_reports_damage_the_way_an_append_does() { let temp = tempfile::tempdir().unwrap(); @@ -1158,6 +1187,7 @@ fn refresh_reports_damage_the_way_an_append_does() { )); } +#[pa_test_scratch::pa_test] #[test] fn a_hundred_thousand_rows_stay_usable() { let temp = tempfile::tempdir().unwrap(); @@ -1191,6 +1221,7 @@ fn a_hundred_thousand_rows_stay_usable() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_row_that_is_not_an_object_is_refused() { let temp = tempfile::tempdir().unwrap(); @@ -1205,6 +1236,7 @@ fn a_row_that_is_not_an_object_is_refused() { assert!(log.read_since(0).unwrap().is_empty()); } +#[pa_test_scratch::pa_test] #[test] fn a_session_id_must_be_one_path_component() { let temp = tempfile::tempdir().unwrap(); @@ -1215,6 +1247,7 @@ fn a_session_id_must_be_one_path_component() { } #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn an_unopenable_session_is_reported() { use std::os::unix::fs::PermissionsExt; @@ -1257,6 +1290,7 @@ fn an_unopenable_session_is_reported() { .unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn a_pinned_retry_reestablishes_the_failed_durability_barrier() { let dir = tempfile::tempdir().unwrap(); @@ -1294,6 +1328,7 @@ fn a_pinned_retry_reestablishes_the_failed_durability_barrier() { assert_eq!(log.read_since(0).unwrap().len(), 1); } +#[pa_test_scratch::pa_test] #[test] fn a_first_append_never_adopts_a_rivals_bytes() { let dir = tempfile::tempdir().unwrap(); @@ -1324,6 +1359,7 @@ fn a_first_append_never_adopts_a_rivals_bytes() { assert_eq!(std::fs::read(log_path(dir.path())).unwrap(), torn); } +#[pa_test_scratch::pa_test] #[test] fn recover_does_not_truncate_a_bare_files_complete_bad_line() { // `recover` resolves this process's own undecided append. A complete line diff --git a/crates/pa-core/src/settings/load.rs b/crates/pa-core/src/settings/load.rs index 8009079e6..9076316f7 100644 --- a/crates/pa-core/src/settings/load.rs +++ b/crates/pa-core/src/settings/load.rs @@ -116,6 +116,7 @@ pub fn from_value_lenient(value: &Value) -> Settings { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn wrong_typed_fields_load_as_none() { let value: Value = serde_json::json!({ @@ -137,6 +138,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn typed_plugins_load_and_null_is_unset() { let settings = from_value_lenient(&serde_json::json!({ @@ -154,6 +156,7 @@ mod tests { assert_eq!(settings.plugins, None); } + #[pa_test_scratch::pa_test] #[test] fn malformed_plugin_map_stays_visible_as_raw_data() { let raw = serde_json::json!({"alpha": {"enabled": true, "unknown": 1}}); @@ -162,6 +165,7 @@ mod tests { assert_eq!(settings.extra.get("plugins"), Some(&raw)); } + #[pa_test_scratch::pa_test] #[test] fn clean_document_strict_parses() { let value: Value = serde_json::json!({ "theme": "prime", "rlmMaxDepth": 4 }); @@ -170,6 +174,7 @@ mod tests { assert_eq!(settings.rlm_max_depth, Some(4)); } + #[pa_test_scratch::pa_test] #[test] fn removed_extensions_key_loads_gracefully() { let value: Value = serde_json::json!({ @@ -187,6 +192,7 @@ mod tests { /// A wrong-typed `requestTiming` behaves as unset (the known-field /// registry entry), never a surviving raw value. + #[pa_test_scratch::pa_test] #[test] fn wrong_typed_request_timing_loads_as_none() { let value: Value = serde_json::json!({ "requestTiming": "yes" }); diff --git a/crates/pa-core/src/settings/manager.rs b/crates/pa-core/src/settings/manager.rs index 74f8041cc..ce8112f10 100644 --- a/crates/pa-core/src/settings/manager.rs +++ b/crates/pa-core/src/settings/manager.rs @@ -984,6 +984,7 @@ mod tests { use super::*; use crate::settings::types::MarkdownSettings; + #[pa_test_scratch::pa_test] #[test] fn in_memory_loads_merges_and_saves() { let mut manager = SettingsManager::in_memory(&Settings::default()); @@ -1000,6 +1001,7 @@ mod tests { assert_eq!(manager.get_default_model(), Some("z-ai/glm-5.3")); } + #[pa_test_scratch::pa_test] #[test] fn reopen_keeps_the_runtime_overrides_in_the_merged_settings() { let mut manager = SettingsManager::in_memory(&Settings::default()); @@ -1013,6 +1015,7 @@ mod tests { assert_eq!(manager.reopen().get_code_block_indent(), " "); } + #[pa_test_scratch::pa_test] #[test] fn code_block_indent_reads_markdown_settings_with_ts_default() { let manager = SettingsManager::in_memory(&Settings::default()); @@ -1029,6 +1032,7 @@ mod tests { assert_eq!(manager.get_code_block_indent(), " "); } + #[pa_test_scratch::pa_test] #[test] fn chat_detail_persists_the_chosen_level_with_the_startup_fallback() { let mut manager = SettingsManager::in_memory(&Settings::default()); @@ -1055,6 +1059,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn steering_mode_defaults_to_all_follow_ups_stay_one_at_a_time() { let mut manager = SettingsManager::in_memory(&Settings::default()); @@ -1070,6 +1075,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn migrations_apply_on_load() { let storage: Arc = @@ -1083,6 +1089,7 @@ mod tests { assert_eq!(manager.get_steering_mode(), QueueModeSetting::All); } + #[pa_test_scratch::pa_test] #[test] fn wrong_typed_fields_never_fail_load() { let storage: Arc = @@ -1097,6 +1104,7 @@ mod tests { assert_eq!(manager.get_theme(), Some("prime")); } + #[pa_test_scratch::pa_test] #[test] fn idle_eviction_semantics() { let mut manager = SettingsManager::in_memory(&Settings::default()); @@ -1115,6 +1123,7 @@ mod tests { assert_eq!(manager.get_idle_eviction(), IdleEviction::Minutes(45)); } + #[pa_test_scratch::pa_test] #[test] fn compaction_toggle_defaults_on_and_persists() { let mut manager = SettingsManager::in_memory(&Settings::default()); @@ -1125,6 +1134,7 @@ mod tests { assert!(!manager.get_compaction_enabled()); } + #[pa_test_scratch::pa_test] #[test] fn session_archive_policy_semantics() { let mut manager = SettingsManager::in_memory(&Settings::default()); @@ -1152,6 +1162,7 @@ mod tests { assert_eq!(manager.get_session_archive_policy().max_sessions, Some(50)); } + #[pa_test_scratch::pa_test] #[test] fn image_model_reads_trimmed_or_unset() { let manager = SettingsManager::in_memory(&Settings { diff --git a/crates/pa-core/src/settings/merge.rs b/crates/pa-core/src/settings/merge.rs index 9a801110d..ae2fbd72a 100644 --- a/crates/pa-core/src/settings/merge.rs +++ b/crates/pa-core/src/settings/merge.rs @@ -135,6 +135,7 @@ mod tests { use crate::settings::TransportSetting; use serde_json::json; + #[pa_test_scratch::pa_test] #[test] fn project_plugins_are_dropped_but_other_project_fields_merge() { let global: Settings = serde_json::from_value(json!({ @@ -164,6 +165,7 @@ mod tests { assert!(!plugins.contains_key("beta")); } + #[pa_test_scratch::pa_test] #[test] fn malformed_plugin_raw_survives_merge_without_losing_other_fields() { let mut global = Settings { @@ -180,6 +182,7 @@ mod tests { assert_eq!(merged.plugins, None); } + #[pa_test_scratch::pa_test] #[test] fn project_scope_cannot_inject_a_malformed_plugin_map() { let global: Settings = serde_json::from_value(json!({ @@ -196,6 +199,7 @@ mod tests { assert!(merged.extra.get("plugins").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn settings_without_plugins_merge_to_no_entries() { assert_eq!( @@ -213,6 +217,7 @@ mod tests { assert_eq!(merge_scopes(&Settings::default(), &global).plugins, None); } + #[pa_test_scratch::pa_test] #[test] fn merge_prefers_overrides_and_merges_nested() { let base: Settings = serde_json::from_value(json!({ @@ -232,6 +237,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn migration_rewrites_legacy_shapes() { let mut doc = json!({ diff --git a/crates/pa-core/src/settings/persistence_tests.rs b/crates/pa-core/src/settings/persistence_tests.rs index f3186debd..f20e929de 100644 --- a/crates/pa-core/src/settings/persistence_tests.rs +++ b/crates/pa-core/src/settings/persistence_tests.rs @@ -17,6 +17,7 @@ fn document(storage: &dyn SettingsStorage) -> Value { serde_json::from_str(&storage.read(SettingsScope::Global).unwrap().unwrap()).unwrap() } +#[pa_test_scratch::pa_test] #[test] fn model_switch_preserves_a_document_that_failed_to_load() { for content in ["{\"theme\":\"light\",}", "\u{feff}{\"theme\":\"light\"}"] { @@ -36,6 +37,7 @@ fn model_switch_preserves_a_document_that_failed_to_load() { } } +#[pa_test_scratch::pa_test] #[test] fn chat_detail_save_changes_only_the_requested_setting() { let (storage, mut manager) = fixture(r#"{"theme":"light","pluginSetting":{"keep":true}}"#); @@ -48,6 +50,7 @@ fn chat_detail_save_changes_only_the_requested_setting() { ); } +#[pa_test_scratch::pa_test] #[test] fn stale_managers_preserve_other_writers_and_explicit_same_value_choices() { let (storage, mut first) = @@ -65,6 +68,7 @@ fn stale_managers_preserve_other_writers_and_explicit_same_value_choices() { ); } +#[pa_test_scratch::pa_test] #[test] fn saves_preserve_a_document_corrupted_after_load() { let (storage, mut manager) = fixture(r#"{"theme":"light"}"#); @@ -92,6 +96,7 @@ fn saves_preserve_a_document_corrupted_after_load() { ); } +#[pa_test_scratch::pa_test] #[test] fn resource_save_preserves_a_document_corrupted_after_load() { let (storage, mut manager) = fixture("{}"); @@ -109,6 +114,7 @@ fn resource_save_preserves_a_document_corrupted_after_load() { .any(|error| error.message.contains("not saved"))); } +#[pa_test_scratch::pa_test] #[test] fn clearing_a_setting_removes_only_that_key() { let (storage, mut manager) = fixture(r#"{"enabledModels":["old"],"theme":"light"}"#); @@ -116,6 +122,7 @@ fn clearing_a_setting_removes_only_that_key() { assert_eq!(document(storage.as_ref()), json!({"theme":"light"})); } +#[pa_test_scratch::pa_test] #[test] fn resource_save_survives_an_unrelated_later_save() { let (storage, mut manager) = fixture("{}"); @@ -129,6 +136,7 @@ fn resource_save_survives_an_unrelated_later_save() { ); } +#[pa_test_scratch::pa_test] #[test] fn compaction_percentage_preserves_siblings_and_survives_reload() { let (storage, mut manager) = @@ -147,6 +155,7 @@ fn compaction_percentage_preserves_siblings_and_survives_reload() { } } +#[pa_test_scratch::pa_test] #[test] fn invalid_compaction_percentage_never_mutates_or_saves() { let (storage, mut manager) = fixture(r#"{"compaction":{"thresholdPercent":80.0}}"#); @@ -167,6 +176,7 @@ fn invalid_compaction_percentage_never_mutates_or_saves() { } } +#[pa_test_scratch::pa_test] #[test] fn invalid_loaded_percentage_keeps_other_compaction_settings() { for invalid in [ @@ -197,6 +207,7 @@ fn invalid_loaded_percentage_keeps_other_compaction_settings() { } } +#[pa_test_scratch::pa_test] #[test] fn project_percentage_overrides_global_and_stale_writes_preserve_external_settings() { let (storage, mut first) = fixture(r#"{"compaction":{"thresholdPercent":80.0}}"#); @@ -219,6 +230,7 @@ fn project_percentage_overrides_global_and_stale_writes_preserve_external_settin assert_eq!(first.get_compaction_threshold_percent(), 60.5); } +#[pa_test_scratch::pa_test] #[test] fn aliased_settings_scopes_have_one_global_authority() { for alias in [ @@ -339,6 +351,7 @@ fn aliased_settings_scopes_have_one_global_authority() { } } +#[pa_test_scratch::pa_test] #[test] #[cfg(unix)] fn global_settings_file_symlink_survives_atomic_save() { @@ -363,6 +376,7 @@ fn global_settings_file_symlink_survives_atomic_save() { assert_eq!(manager.reopen().get_theme(), Some("new")); } +#[pa_test_scratch::pa_test] #[test] fn tree_filter_falls_back_to_default_but_keeps_explicit_preferences() { let mut manager = SettingsManager::in_memory(&super::Settings::default()); @@ -375,6 +389,7 @@ fn tree_filter_falls_back_to_default_but_keeps_explicit_preferences() { assert_eq!(manager.reopen().get_tree_filter_mode(), "default"); } +#[pa_test_scratch::pa_test] #[test] fn in_memory_scopes_remain_independent_by_default() { let (storage, mut manager) = fixture(r#"{"packages":["global"],"skills":["global-skill"]}"#); diff --git a/crates/pa-core/src/settings/storage.rs b/crates/pa-core/src/settings/storage.rs index b1eb25748..25a0e45bc 100644 --- a/crates/pa-core/src/settings/storage.rs +++ b/crates/pa-core/src/settings/storage.rs @@ -382,6 +382,7 @@ impl SettingsStorage for InMemorySettingsStorage { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] #[cfg(unix)] fn file_alias_uses_the_physical_targets_lock() { @@ -398,6 +399,7 @@ mod tests { .is_err()); } + #[pa_test_scratch::pa_test] #[test] fn in_memory_round_trip() { let storage = InMemorySettingsStorage::default(); @@ -415,6 +417,7 @@ mod tests { .unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn file_storage_read_modify_write() { let dir = tempfile::tempdir().unwrap(); @@ -433,6 +436,7 @@ mod tests { assert_eq!(crate::platform::perms::file_mode(&path), Some(0o600)); } + #[pa_test_scratch::pa_test] #[test] fn atomic_write_default_skips_fsync_and_opt_in_takes_exactly_one() { let dir = tempfile::tempdir().unwrap(); @@ -463,6 +467,7 @@ mod tests { assert_eq!(names, ["state.json".to_string()]); } + #[pa_test_scratch::pa_test] #[test] fn settings_write_takes_exactly_one_fsync() { let dir = tempfile::tempdir().unwrap(); @@ -481,6 +486,7 @@ mod tests { assert_eq!(fs::read_to_string(&path).unwrap(), document); } + #[pa_test_scratch::pa_test] #[test] fn read_arm_serves_content_and_survives_writes() { let dir = tempfile::tempdir().unwrap(); @@ -517,6 +523,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn read_arm_error_matches_with_lock_read() { let dir = tempfile::tempdir().unwrap(); @@ -526,6 +533,7 @@ mod tests { assert!(storage.read(SettingsScope::Global).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn read_arm_default_is_with_lock_read() { let storage = InMemorySettingsStorage::default(); @@ -544,6 +552,7 @@ mod tests { /// A relative agent dir (a relative `PRIME_AGENT_CODING_AGENT_DIR`) locks and /// loads: the lock probe's `utimensat` resolves relative lock paths against `AT_FDCWD`. + #[pa_test_scratch::pa_test] #[test] #[cfg(unix)] fn relative_agent_dir_locks_and_loads() { diff --git a/crates/pa-core/src/skills/frontmatter.rs b/crates/pa-core/src/skills/frontmatter.rs index 29af854b3..bc68db530 100644 --- a/crates/pa-core/src/skills/frontmatter.rs +++ b/crates/pa-core/src/skills/frontmatter.rs @@ -61,6 +61,7 @@ pub fn strip_frontmatter(content: &str) -> String { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn parses_simple_frontmatter() { let (frontmatter, body) = @@ -70,6 +71,7 @@ mod tests { assert_eq!(body, "Use it well."); } + #[pa_test_scratch::pa_test] #[test] fn no_frontmatter_returns_body() { let (frontmatter, body) = parse_frontmatter("Just text"); @@ -77,6 +79,7 @@ mod tests { assert_eq!(body, "Just text"); } + #[pa_test_scratch::pa_test] #[test] fn unterminated_frontmatter_returns_body() { let (frontmatter, body) = parse_frontmatter("---\nname: x\nno end"); @@ -84,6 +87,7 @@ mod tests { assert_eq!(body, "---\nname: x\nno end"); } + #[pa_test_scratch::pa_test] #[test] fn an_empty_frontmatter_block_is_no_frontmatter() { // TS `!yamlString`: the close follows the open, so the whole @@ -95,6 +99,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn an_empty_first_line_between_delimiters_is_no_frontmatter() { // `---x\n---\nbody`: TS slice(4, 4) = "" -> falsy -> no frontmatter. @@ -103,6 +108,7 @@ mod tests { assert_eq!(body, "---x\n---\nbody"); } + #[pa_test_scratch::pa_test] #[test] fn crlf_and_bom_normalized() { let (frontmatter, _) = parse_frontmatter("\u{feff}---\r\nname: x\r\n---\r\nbody"); diff --git a/crates/pa-core/src/skills/loader.rs b/crates/pa-core/src/skills/loader.rs index 08e25b428..a0e86a4ca 100644 --- a/crates/pa-core/src/skills/loader.rs +++ b/crates/pa-core/src/skills/loader.rs @@ -247,6 +247,7 @@ mod tests { .unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn loads_user_and_project_skills_with_collision() { let tmp = tempfile::tempdir().unwrap(); @@ -279,6 +280,7 @@ mod tests { .any(|d| matches!(d, ResourceDiagnostic::Collision { .. }))); } + #[pa_test_scratch::pa_test] #[test] fn skills_list_in_load_order_ts_map_semantics() { // TS `Map` insertion order: user dir first, then project, then the @@ -313,6 +315,7 @@ mod tests { assert_eq!(names, vec!["zeta", "alpha", "gamma"]); } + #[pa_test_scratch::pa_test] #[test] fn explicit_paths_and_missing_paths() { let tmp = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/skills/mod.rs b/crates/pa-core/src/skills/mod.rs index d222c03cf..8f027232d 100644 --- a/crates/pa-core/src/skills/mod.rs +++ b/crates/pa-core/src/skills/mod.rs @@ -291,6 +291,7 @@ pub fn expand_skill_command<'a>(text: &str, skills: &'a [Skill]) -> (String, Opt mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn name_validation_rules() { assert!(validate_name("web-search", "web-search").is_empty()); @@ -300,6 +301,7 @@ mod tests { assert!(!validate_name("web", "other").is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn description_validation_rules() { assert_eq!(validate_description(""), vec!["description is required"]); @@ -332,6 +334,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn expands_a_known_skill_command_with_and_without_args() { let dir = tempfile::tempdir().expect("tempdir"); @@ -363,6 +366,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn an_empty_frontmatter_block_is_a_warned_skip_not_a_panic() { // TS no-frontmatter semantics: the whole document is the body, the @@ -379,6 +383,7 @@ mod tests { )); } + #[pa_test_scratch::pa_test] #[test] fn an_empty_frontmatter_name_falls_back_to_the_parent_directory() { // TS `frontmatter.name || parentDirName`. @@ -401,6 +406,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn non_skill_and_unknown_inputs_pass_through() { let dir = tempfile::tempdir().expect("tempdir"); @@ -417,6 +423,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn an_unreadable_skill_file_passes_through() { let dir = tempfile::tempdir().expect("tempdir"); @@ -429,6 +436,7 @@ mod tests { assert!(used.is_none()); } + #[pa_test_scratch::pa_test] #[test] fn prompt_formatting_excludes_hidden() { let skill = |name: &str, disable: bool| Skill { diff --git a/crates/pa-core/src/skills/prompt_templates.rs b/crates/pa-core/src/skills/prompt_templates.rs index b76b26b22..2c64ec71a 100644 --- a/crates/pa-core/src/skills/prompt_templates.rs +++ b/crates/pa-core/src/skills/prompt_templates.rs @@ -332,6 +332,7 @@ pub fn expand_prompt_template(text: &str, templates: &[PromptTemplate]) -> Strin mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn command_args_quoting() { assert_eq!( @@ -341,6 +342,7 @@ mod tests { assert_eq!(parse_command_args(" "), Vec::::new()); } + #[pa_test_scratch::pa_test] #[test] fn substitutes_positional_and_slices() { let args = vec!["one".to_string(), "two".to_string(), "three".to_string()]; @@ -356,6 +358,7 @@ mod tests { assert_eq!(substitute_args("cost is $10", &args), "cost is "); } + #[pa_test_scratch::pa_test] #[test] fn slash_command_parsing() { assert_eq!( @@ -369,6 +372,7 @@ mod tests { assert_eq!(parse_slash_command("no slash"), None); } + #[pa_test_scratch::pa_test] #[test] fn template_expansion() { let template = PromptTemplate { @@ -390,6 +394,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn loads_templates_from_dirs() { let tmp = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/slash_command_args.rs b/crates/pa-core/src/slash_command_args.rs index 09c290688..cd7b2e3fe 100644 --- a/crates/pa-core/src/slash_command_args.rs +++ b/crates/pa-core/src/slash_command_args.rs @@ -94,6 +94,7 @@ fn parse_goal_budget_value(value: &str) -> Result { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn goal_command_kinds() { assert_eq!(parse_goal_command("").unwrap(), GoalCommand::Status); diff --git a/crates/pa-core/src/tools/file_mutation_queue.rs b/crates/pa-core/src/tools/file_mutation_queue.rs index 29c75a56b..b4f5c2d16 100644 --- a/crates/pa-core/src/tools/file_mutation_queue.rs +++ b/crates/pa-core/src/tools/file_mutation_queue.rs @@ -60,6 +60,7 @@ mod tests { use std::time::Duration; #[tokio::test] + #[pa_test_scratch::pa_test] async fn serializes_same_file() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("f.txt"); @@ -88,6 +89,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn parallel_across_files() { let dir = tempfile::tempdir().unwrap(); let a = dir.path().join("a.txt"); @@ -112,6 +114,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn registry_cleans_up() { let dir = tempfile::tempdir().unwrap(); let p = dir.path().join("x.txt").to_str().unwrap().to_string(); diff --git a/crates/pa-core/src/tools/golden_replay.rs b/crates/pa-core/src/tools/golden_replay.rs index 78adc474d..f4a16d0c0 100644 --- a/crates/pa-core/src/tools/golden_replay.rs +++ b/crates/pa-core/src/tools/golden_replay.rs @@ -118,6 +118,7 @@ fn assert_json_eq(actual: &serde_json::Value, expected: &serde_json::Value, what } #[tokio::test] +#[pa_test_scratch::pa_test] async fn golden_edit_group_matches_ts() { let corpus = corpus("edit"); let mut checked = 0; @@ -184,6 +185,7 @@ async fn golden_edit_group_matches_ts() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn golden_bash_group_matches_ts() { let corpus = corpus("bash"); let cases = corpus["cases"].as_array().expect("cases array").clone(); @@ -308,6 +310,7 @@ async fn golden_bash_group_matches_ts() { assert_eq!(checked, corpus["caseCount"].as_u64().expect("caseCount")); } +#[pa_test_scratch::pa_test] #[test] fn golden_truncate_group_matches_ts() { let corpus = corpus("truncate"); @@ -489,6 +492,7 @@ fn mock_execution(entry: &serde_json::Value) -> MockOutcome { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn golden_ipython_group_matches_ts() { let corpus = corpus("ipython"); let mut checked = 0; @@ -573,6 +577,7 @@ async fn golden_ipython_group_matches_ts() { assert_eq!(checked, corpus["caseCount"].as_u64().expect("caseCount")); } +#[pa_test_scratch::pa_test] #[test] fn golden_schema_group_matches_ts() { let corpus = corpus("schema"); @@ -621,6 +626,7 @@ fn golden_schema_group_matches_ts() { // Small direct checks of guard parsing (subsumed by the bash golden group). +#[pa_test_scratch::pa_test] #[test] fn destructive_git_discard_detection_examples() { assert!(crate::tools::bash_guard::is_destructive_git_discard_command("git reset --hard")); diff --git a/crates/pa-core/src/tools/ipython.rs b/crates/pa-core/src/tools/ipython.rs index 727a89645..6d8750ab2 100644 --- a/crates/pa-core/src/tools/ipython.rs +++ b/crates/pa-core/src/tools/ipython.rs @@ -536,6 +536,7 @@ pub fn create_ipython_tool_definition(_cwd: &str, options: IpythonToolOptions) - mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn sent_agent_message_json_matches_ts_wire_shape() { let sent = crate::kernel::shared::KernelSentAgentMessage { diff --git a/crates/pa-core/src/tools/path_utils.rs b/crates/pa-core/src/tools/path_utils.rs index 9a9d3d8dd..682679058 100644 --- a/crates/pa-core/src/tools/path_utils.rs +++ b/crates/pa-core/src/tools/path_utils.rs @@ -500,6 +500,7 @@ pub fn resolve_read_path(file_path: &str, cwd: &str) -> String { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn expand_tilde() { assert_eq!(expand_path_platform("~", Some("/home/u")), "/home/u"); @@ -515,6 +516,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn strips_at_prefix() { assert_eq!(expand_path_platform("@~/f", Some("/h")), "/h/f"); @@ -522,6 +524,7 @@ mod tests { /// POSIX dispatcher semantics; the win32 sibling lives below (the dispatcher is /// platform-picked, so a POSIX expectation is a not-windows test). + #[pa_test_scratch::pa_test] #[test] #[cfg(not(windows))] fn resolve_relative() { @@ -530,6 +533,7 @@ mod tests { assert_eq!(resolve_to_cwd("/abs/x", "/cwd"), "/abs/x"); } + #[pa_test_scratch::pa_test] #[test] #[cfg(not(windows))] fn node_resolve_matches_node_semantics() { @@ -545,6 +549,7 @@ mod tests { /// match exactly (the edit tool resolves user paths through this on Windows). /// Deterministic rows only - the device-relative fallback reads the process cwd /// when the `=` convention is unset, which a parallel test cannot pin. + #[pa_test_scratch::pa_test] #[test] fn win32_resolve_matches_node_outputs() { let cases = [ @@ -604,6 +609,7 @@ mod tests { /// Node's drive-specific cwd convention: a device-relative tail resolves against /// that drive's cwd, or the DRIVE ROOT when it sits on a different drive. + #[pa_test_scratch::pa_test] #[test] fn win32_resolve_honors_the_drive_cwd_convention() { assert_eq!( diff --git a/crates/pa-core/src/tools/render_utils.rs b/crates/pa-core/src/tools/render_utils.rs index f29742759..b1c9bf17f 100644 --- a/crates/pa-core/src/tools/render_utils.rs +++ b/crates/pa-core/src/tools/render_utils.rs @@ -149,6 +149,7 @@ fn webp_dimensions(b: &[u8]) -> Option { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn png_dimensions_parsed() { // Minimal PNG header with IHDR 2x3. diff --git a/crates/pa-core/src/tools/shell_utils.rs b/crates/pa-core/src/tools/shell_utils.rs index a0cb2a234..5c0f39830 100644 --- a/crates/pa-core/src/tools/shell_utils.rs +++ b/crates/pa-core/src/tools/shell_utils.rs @@ -109,6 +109,7 @@ pub fn kill_process_tree(pid: i32) -> bool { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn shell_config_prefers_bin_bash_with_portable_fallback() { let cfg = get_shell_config(None).unwrap(); @@ -125,6 +126,7 @@ mod tests { assert_eq!(output.stdout, b"shell-ready"); } + #[pa_test_scratch::pa_test] #[test] fn shell_env_disables_prompts() { let env = get_shell_env(); @@ -133,6 +135,7 @@ mod tests { assert!(env.get("PATH").unwrap().contains("/bin")); } + #[pa_test_scratch::pa_test] #[test] fn sanitize_removes_control_chars() { assert_eq!(sanitize_binary_output("a\u{0}b\u{7}c"), "abc"); diff --git a/crates/pa-core/src/tools/truncate.rs b/crates/pa-core/src/tools/truncate.rs index 42dedf558..73e1d1d54 100644 --- a/crates/pa-core/src/tools/truncate.rs +++ b/crates/pa-core/src/tools/truncate.rs @@ -155,6 +155,7 @@ fn truncate_string_to_bytes_from_end(s: &str, max_bytes: usize) -> String { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn format_size_matches_ts() { assert_eq!(format_size(512), "512B"); @@ -165,6 +166,7 @@ mod tests { assert_eq!(format_size(2 * 1024 * 1024 + 512 * 1024), "2.5MB"); } + #[pa_test_scratch::pa_test] #[test] fn tail_keeps_last_lines() { let r = truncate_tail("1\n2\n3\n4\n5", TruncationOptions::with_limits(2, 100)); @@ -172,6 +174,7 @@ mod tests { assert_eq!(r.truncated_by, Some(TruncatedBy::Lines)); } + #[pa_test_scratch::pa_test] #[test] fn tail_byte_limit_no_partial() { // 20 lines of 10 bytes + newline each = 220 bytes total. @@ -187,6 +190,7 @@ mod tests { assert!(r.content.ends_with(&content[content.len() - 21..])); } + #[pa_test_scratch::pa_test] #[test] fn tail_partial_line_rescue() { let long = "x".repeat(100); @@ -197,6 +201,7 @@ mod tests { assert_eq!(r.content.len(), 50); } + #[pa_test_scratch::pa_test] #[test] fn multi_byte_boundary_from_end() { // "héllo" - é is 2 bytes. diff --git a/crates/pa-core/src/update/download.rs b/crates/pa-core/src/update/download.rs index 9921e4d0f..44ef97f80 100644 --- a/crates/pa-core/src/update/download.rs +++ b/crates/pa-core/src/update/download.rs @@ -586,6 +586,7 @@ mod tests { (archive, sha256_hex(&bytes)) } + #[pa_test_scratch::pa_test] #[test] fn stages_and_revalidates_a_release() { let dir = tempfile::tempdir().unwrap(); @@ -624,6 +625,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn never_reuses_a_damaged_release() { let dir = tempfile::tempdir().unwrap(); @@ -661,6 +663,7 @@ mod tests { #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn stages_a_local_payload_directory() { let dir = tempfile::tempdir().unwrap(); let payload = fixture_payload(dir.path(), "payload", "9.9.9"); @@ -709,6 +712,7 @@ mod tests { #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_permission_change_stages_a_new_release() { use std::os::unix::fs::PermissionsExt; let dir = tempfile::tempdir().unwrap(); @@ -753,6 +757,7 @@ mod tests { #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn stages_a_local_archive_and_probes_the_binary() { let dir = tempfile::tempdir().unwrap(); let (archive, _archive_file_sha) = @@ -779,6 +784,7 @@ mod tests { #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn refuses_a_local_payload_without_a_release_version() { let dir = tempfile::tempdir().unwrap(); let payload = fixture_payload(dir.path(), "payload", "not a version"); @@ -789,6 +795,7 @@ mod tests { .is_err()); } + #[pa_test_scratch::pa_test] #[test] fn tree_digests_are_deterministic_and_content_sensitive() { let dir = tempfile::tempdir().unwrap(); @@ -848,6 +855,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn downloads_verify_the_archive_digest_and_refuse_a_mismatch() { let payload: Vec = b"release archive bytes".to_vec(); let sha = sha256_hex(&payload); diff --git a/crates/pa-core/src/update/homebrew.rs b/crates/pa-core/src/update/homebrew.rs index af7d9dc90..0f7a91537 100644 --- a/crates/pa-core/src/update/homebrew.rs +++ b/crates/pa-core/src/update/homebrew.rs @@ -59,6 +59,7 @@ pub fn upgrade_instruction(kind: HomebrewKind) -> String { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn detects_formula_and_cask_layouts() { let root = tempfile::tempdir().unwrap(); @@ -75,6 +76,7 @@ mod tests { } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn resolves_brew_bin_symlinks_into_the_formula_keg() { let root = tempfile::tempdir().unwrap(); @@ -89,6 +91,7 @@ mod tests { assert_eq!(managed_kind(&launcher), Some(HomebrewKind::Formula)); } + #[pa_test_scratch::pa_test] #[test] fn ignores_other_kegs_and_non_homebrew_installs() { let root = tempfile::tempdir().unwrap(); diff --git a/crates/pa-core/src/update/install.rs b/crates/pa-core/src/update/install.rs index d33abd5e8..97bcc3b60 100644 --- a/crates/pa-core/src/update/install.rs +++ b/crates/pa-core/src/update/install.rs @@ -380,6 +380,7 @@ mod tests { .unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn reads_and_validates_a_managed_installation() { let dir = tempfile::tempdir().unwrap(); @@ -395,6 +396,7 @@ mod tests { assert_eq!(installation.target.platform, "linux-x64"); } + #[pa_test_scratch::pa_test] #[test] fn rejects_a_damaged_release() { let dir = tempfile::tempdir().unwrap(); @@ -406,6 +408,7 @@ mod tests { assert!(read_installation(root, CURRENT_LAUNCHER).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn activation_state_wins_over_the_bare_previous_link() { let dir = tempfile::tempdir().unwrap(); @@ -425,6 +428,7 @@ mod tests { assert_eq!(rollback.version(), "0.1.0"); } + #[pa_test_scratch::pa_test] #[test] fn rollback_without_state_uses_the_previous_link() { let dir = tempfile::tempdir().unwrap(); @@ -435,6 +439,7 @@ mod tests { assert_eq!(rollback.version(), "0.1.0"); } + #[pa_test_scratch::pa_test] #[test] fn anchors_the_running_release_directory() { let dir = tempfile::tempdir().unwrap(); @@ -454,6 +459,7 @@ mod tests { assert!(running_release(&stray).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn install_sources_must_be_http() { assert!(install_source_is_valid("https://example.com")); @@ -462,6 +468,7 @@ mod tests { assert!(!install_source_is_valid("example.com")); } + #[pa_test_scratch::pa_test] #[test] fn parses_release_link_shapes_only() { assert!(parse_release_link(Path::new( diff --git a/crates/pa-core/src/update/installer.rs b/crates/pa-core/src/update/installer.rs index a67f1625e..7cb2da127 100644 --- a/crates/pa-core/src/update/installer.rs +++ b/crates/pa-core/src/update/installer.rs @@ -797,6 +797,7 @@ mod tests { /// supported platform pair (the same set install-rust.sh's uname case /// resolves): the Windows pair ships the MSVC target, and the refusal /// covers every other pair with the full matrix in the message. + #[pa_test_scratch::pa_test] #[test] fn target_for_covers_the_published_matrix() { assert_eq!(target_for("macos", "aarch64"), Some("aarch64-apple-darwin")); @@ -828,6 +829,7 @@ mod tests { /// followed $`PSDefaultParameterValues`) keeps the installer-ownership /// gate working instead of sending a ps1-updated machine down the /// managed path. + #[pa_test_scratch::pa_test] #[test] fn installed_channel_reads_the_ps1_encoded_marker() { let dir = tempfile::TempDir::new().unwrap(); @@ -897,6 +899,7 @@ mod tests { /// stay on beta (the marker the installer writes at publish carries /// the channel), a stable or pre-marker install rides the script's /// own default, and a foreign marker is never treated as a channel. + #[pa_test_scratch::pa_test] #[test] fn installed_channel_reads_the_publish_marker() { let dir = tempfile::TempDir::new().unwrap(); @@ -931,6 +934,7 @@ mod tests { /// Only the payload binary of a marked installer tree is /// installer-owned; the marker's version line is the installed /// version. + #[pa_test_scratch::pa_test] #[test] fn installer_prefix_of_needs_the_payload_path_and_the_marker() { let dir = tempfile::TempDir::new().unwrap(); @@ -958,6 +962,7 @@ mod tests { /// running image, so the local operations always wait for the /// installer — even a fully staged, marker-bearing payload prefix /// stays closed (the platform alone decides). + #[pa_test_scratch::pa_test] #[test] #[cfg(not(windows))] fn caller_owns_payload_stays_false_for_a_staged_prefix_on_unix() { @@ -981,6 +986,7 @@ mod tests { /// payload dir, so even a fully staged prefix stays closed on /// Windows — the true arm needs a real self-installed run (the e2e /// covers the wait path). + #[pa_test_scratch::pa_test] #[test] #[cfg(windows)] fn caller_owns_payload_needs_the_running_image_on_windows() { @@ -1109,6 +1115,7 @@ echo "installed: 9.9.8-continuous.fedcba9876543210" /// domain's install endpoint, nightly (beta) fetches `install-beta.sh` /// from the download base (the domain forwards only `install.sh`), and /// the override pins both. + #[pa_test_scratch::pa_test] #[test] fn the_installer_url_follows_the_channel() { // The knobs are SAVED and RESTORED around the probe: the env is @@ -1153,6 +1160,7 @@ echo "installed: 9.9.8-continuous.fedcba9876543210" } } + #[pa_test_scratch::pa_test] #[test] fn the_target_matrix_covers_the_published_builds() { assert_eq!(target_for("macos", "aarch64"), Some("aarch64-apple-darwin")); @@ -1180,6 +1188,7 @@ echo "installed: 9.9.8-continuous.fedcba9876543210" ); } + #[pa_test_scratch::pa_test] #[test] fn running_commit_reads_the_continuous_stamp() { assert_eq!( @@ -1205,6 +1214,7 @@ echo "installed: 9.9.8-continuous.fedcba9876543210" /// The requested channel (an explicit flag or the saved setting) wins /// over the install marker; without one the marker's channel rides. #[tokio::test] + #[pa_test_scratch::pa_test] #[cfg(unix)] async fn the_requested_channel_wins_over_the_install_marker() { let (root, _preserve, prefix) = sandbox(); @@ -1235,6 +1245,7 @@ echo "installed: 9.9.8-continuous.fedcba9876543210" } #[tokio::test] + #[pa_test_scratch::pa_test] #[cfg(unix)] async fn the_funnel_runs_the_downloaded_installer_and_preserves_the_session_store() { let (root, preserve, prefix) = sandbox(); @@ -1260,6 +1271,7 @@ echo "installed: 9.9.8-continuous.fedcba9876543210" } #[tokio::test] + #[pa_test_scratch::pa_test] #[cfg(unix)] async fn the_probe_still_reads_a_pre_takeover_launchers_version() { let (root, _preserve, prefix) = sandbox(); @@ -1280,6 +1292,7 @@ echo "installed: 9.9.8-continuous.fedcba9876543210" } #[tokio::test] + #[pa_test_scratch::pa_test] #[cfg(unix)] async fn a_failed_installer_keeps_the_previous_install_and_reports_the_error() { let (root, preserve, prefix) = sandbox(); @@ -1310,6 +1323,7 @@ echo "installed: 9.9.8-continuous.fedcba9876543210" } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_unfetchable_script_fails_without_installing() { let (_root, _preserve, prefix) = sandbox(); let failure = run_installer_from( diff --git a/crates/pa-core/src/update/managed.rs b/crates/pa-core/src/update/managed.rs index 98356d5d6..34fd58df0 100644 --- a/crates/pa-core/src/update/managed.rs +++ b/crates/pa-core/src/update/managed.rs @@ -25,6 +25,7 @@ fn refusal(owner: Option<&str>, executable: Option<&Path>) -> Option<&'static st mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn nix_owner_and_store_payloads_refuse_self_update_without_prefix_collisions() { assert_eq!( diff --git a/crates/pa-core/src/update/release.rs b/crates/pa-core/src/update/release.rs index 3f02089a0..f5bf9938b 100644 --- a/crates/pa-core/src/update/release.rs +++ b/crates/pa-core/src/update/release.rs @@ -173,6 +173,7 @@ pub fn sha256_hex(bytes: &[u8]) -> String { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn validates_artifact_rows_like_ts() { let release = LatestRelease { @@ -195,6 +196,7 @@ mod tests { assert!(artifact_for_platform(&unknown).is_err()); } + #[pa_test_scratch::pa_test] #[test] fn parse_channel_manifest_accepts_the_producer_shape() { // The shape release.yml's promote job emits: a v1 `binaries` list plus the @@ -221,6 +223,7 @@ mod tests { .any(|artifact| artifact.platform == "linux-arm64")); } + #[pa_test_scratch::pa_test] #[test] fn parse_channel_manifest_keeps_the_reader_guards() { // A row the reader cannot verify empties the artifacts (TS parity). @@ -242,6 +245,7 @@ mod tests { assert!(version_only.artifacts.is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn user_agent_keeps_the_ts_shape() { let agent = update_user_agent("1.2.3"); @@ -288,6 +292,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn latest_release_fetches_the_channel_manifest_over_http() { let manifest = serde_json::json!({ "version": "1.2.3", @@ -323,6 +328,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_endpoint_error_is_no_release_never_a_planning_failure() { let (base_url, _) = fake_release_endpoint("500 Internal Server Error", String::new()).await; let release = latest_release("1.2.2", None, &base_url, std::time::Duration::from_secs(5)) diff --git a/crates/pa-core/src/update/version.rs b/crates/pa-core/src/update/version.rs index 8e8a6e126..9ef258c47 100644 --- a/crates/pa-core/src/update/version.rs +++ b/crates/pa-core/src/update/version.rs @@ -282,6 +282,7 @@ mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn parses_and_compares_semver() { assert_eq!(parse_package_version("1.2.3").map(|v| v.major), Some(1)); @@ -309,6 +310,7 @@ mod tests { assert_eq!(compare_package_versions("x", "1.2.3"), None); } + #[pa_test_scratch::pa_test] #[test] fn newer_and_downgrade_rules_match_ts() { assert!(is_newer_package_version("1.3.0", "v1.2.3")); @@ -318,6 +320,7 @@ mod tests { assert!(!is_base_version_downgrade("junk", "1.2.3")); } + #[pa_test_scratch::pa_test] #[test] fn opaque_build_tag_shuffles_are_never_candidates() { assert!(same_base_opaque_build_tag( @@ -360,6 +363,7 @@ mod tests { assert!(!same_base_opaque_build_tag("junk", "0.10.0-rust-64f66e3d")); } + #[pa_test_scratch::pa_test] #[test] fn prerelease_tags_are_detected() { assert!(has_prerelease_tag("0.10.0-rust-64f66e3d")); @@ -368,6 +372,7 @@ mod tests { assert!(!has_prerelease_tag("junk")); } + #[pa_test_scratch::pa_test] #[test] fn channel_and_candidate_rules_match_ts() { assert_eq!( -- knotmirror 0.0.1 From 6c1429da96ec4d7849b32f6e39c65c7bcfa09aa5 Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Sat, 21 Nov 2026 12:09:37 +0000 Subject: [PATCH 5/9] test(timing): instrument pa-daemon unit tests --- crates/pa-daemon/src/acp/config_options.rs | 7 ++++ crates/pa-daemon/src/acp/daemon.rs | 5 +++ crates/pa-daemon/src/acp/jsonrpc.rs | 2 + crates/pa-daemon/src/acp/mcp.rs | 8 ++++ crates/pa-daemon/src/acp/meta.rs | 3 ++ crates/pa-daemon/src/acp/types.rs | 6 +++ crates/pa-daemon/src/acp/wire_events.rs | 10 +++++ crates/pa-daemon/src/agent_engine/config.rs | 1 + .../agent_engine/context_selection_tests.rs | 8 ++++ crates/pa-daemon/src/agent_engine/goalcore.rs | 2 + crates/pa-daemon/src/agent_engine/model.rs | 6 +++ .../pa-daemon/src/agent_engine/tests/abort.rs | 6 +++ .../src/agent_engine/tests/compaction.rs | 15 ++++++++ .../src/agent_engine/tests/context_usage.rs | 1 + .../src/agent_engine/tests/failover_facts.rs | 1 + .../pa-daemon/src/agent_engine/tests/goal.rs | 14 +++++++ .../agent_engine/tests/model_resolution.rs | 24 ++++++++++++ .../src/agent_engine/tests/quota_park.rs | 8 ++++ .../src/agent_engine/tests/reload.rs | 12 ++++++ .../src/agent_engine/tests/rlm_children.rs | 3 ++ .../src/agent_engine/tests/saved_context.rs | 6 +++ .../src/agent_engine/tests/session.rs | 10 +++++ .../src/agent_engine/tests/streaming.rs | 12 ++++++ crates/pa-daemon/src/agent_message_ingest.rs | 2 + .../src/agent_messaging/controller_tests.rs | 16 ++++++++ crates/pa-daemon/src/agent_roster.rs | 10 +++++ crates/pa-daemon/src/async_safe_runtime.rs | 1 + crates/pa-daemon/src/backpressure.rs | 4 ++ crates/pa-daemon/src/bash_notices.rs | 1 + crates/pa-daemon/src/boot_reap.rs | 11 ++++++ crates/pa-daemon/src/child_status_notices.rs | 3 ++ crates/pa-daemon/src/compaction.rs | 3 ++ .../pa-daemon/src/compaction_supervision.rs | 18 +++++++++ crates/pa-daemon/src/context_tree_cache.rs | 7 ++++ crates/pa-daemon/src/context_tree_children.rs | 7 ++++ crates/pa-daemon/src/create_reuse.rs | 8 ++++ crates/pa-daemon/src/descriptor.rs | 6 +++ crates/pa-daemon/src/engine/tests.rs | 3 ++ crates/pa-daemon/src/goal_continuation.rs | 2 + crates/pa-daemon/src/goal_state_persist.rs | 5 +++ crates/pa-daemon/src/herdr.rs | 20 ++++++++++ crates/pa-daemon/src/hold_refusal.rs | 7 ++++ crates/pa-daemon/src/image_route.rs | 4 ++ crates/pa-daemon/src/journal.rs | 16 ++++++++ crates/pa-daemon/src/lease.rs | 6 +++ crates/pa-daemon/src/mcp_login.rs | 4 ++ crates/pa-daemon/src/messaging.rs | 7 ++++ crates/pa-daemon/src/model_allowlist.rs | 6 +++ crates/pa-daemon/src/model_catalog.rs | 6 +++ crates/pa-daemon/src/model_refresh_worker.rs | 3 ++ crates/pa-daemon/src/model_switch.rs | 7 ++++ crates/pa-daemon/src/overflow_compaction.rs | 8 ++++ crates/pa-daemon/src/ownership.rs | 1 + crates/pa-daemon/src/paths.rs | 1 + crates/pa-daemon/src/peer.rs | 8 ++++ crates/pa-daemon/src/peer_tickets.rs | 3 ++ crates/pa-daemon/src/platform/paths.rs | 7 ++++ crates/pa-daemon/src/plugin_commands.rs | 6 +++ crates/pa-daemon/src/prompt_admission.rs | 4 ++ crates/pa-daemon/src/protocol.rs | 9 +++++ crates/pa-daemon/src/queue_commands.rs | 7 ++++ crates/pa-daemon/src/recovery_pacing.rs | 2 + crates/pa-daemon/src/registration.rs | 5 +++ crates/pa-daemon/src/registry.rs | 11 ++++++ crates/pa-daemon/src/revival_gate.rs | 11 ++++++ crates/pa-daemon/src/rlm_child_model.rs | 8 ++++ crates/pa-daemon/src/rlm_child_usage.rs | 2 + crates/pa-daemon/src/rlm_children/host.rs | 1 + .../pa-daemon/src/rlm_children/lifecycle.rs | 1 + .../spawn_name_reservation_tests.rs | 7 ++++ .../src/rlm_children/usage_emit_tests.rs | 17 +++++++++ .../pa-daemon/src/rlm_children/watch_tests.rs | 26 +++++++++++++ crates/pa-daemon/src/rlm_ledger/tests.rs | 31 +++++++++++++++ crates/pa-daemon/src/rlm_roster.rs | 4 ++ crates/pa-daemon/src/rlm_surface.rs | 4 ++ crates/pa-daemon/src/roster_activity.rs | 5 +++ crates/pa-daemon/src/rpc/protocol.rs | 4 ++ .../pa-daemon/src/saved_session_commands.rs | 4 ++ crates/pa-daemon/src/scheduled_jobs/tests.rs | 4 ++ crates/pa-daemon/src/scheduling_catalog.rs | 3 ++ crates/pa-daemon/src/session_archive.rs | 9 +++++ crates/pa-daemon/src/session_bindings.rs | 12 ++++++ crates/pa-daemon/src/session_catalog.rs | 7 ++++ crates/pa-daemon/src/session_commands.rs | 2 + crates/pa-daemon/src/session_custom.rs | 9 +++++ crates/pa-daemon/src/session_export.rs | 5 +++ crates/pa-daemon/src/session_input_pause.rs | 5 +++ crates/pa-daemon/src/session_navigation.rs | 9 +++++ crates/pa-daemon/src/session_scan.rs | 10 +++++ crates/pa-daemon/src/session_stats/tests.rs | 8 ++++ .../src/session_store/context_selection.rs | 10 +++++ .../src/session_store/display_tests.rs | 2 + crates/pa-daemon/src/session_store/info.rs | 2 + .../src/session_store/log_reader_tests.rs | 10 +++++ crates/pa-daemon/src/session_store/tests.rs | 38 +++++++++++++++++++ .../pa-daemon/src/session_store_info_tests.rs | 24 ++++++++++++ .../src/session_store_stream_tests.rs | 4 ++ .../src/session_store_window_tests.rs | 7 ++++ crates/pa-daemon/src/session_transport.rs | 19 ++++++++++ crates/pa-daemon/src/session_tree.rs | 13 +++++++ crates/pa-daemon/src/session_usage.rs | 12 ++++++ crates/pa-daemon/src/setting_switches.rs | 15 ++++++++ crates/pa-daemon/src/side_question.rs | 4 ++ crates/pa-daemon/src/snapshot_stream.rs | 11 ++++++ crates/pa-daemon/src/socket.rs | 17 +++++++++ .../src/state_getters/state_getters_tests.rs | 13 +++++++ crates/pa-daemon/src/state_getters/usage.rs | 4 ++ crates/pa-daemon/src/stop_cleanup.rs | 6 +++ crates/pa-daemon/src/streaming.rs | 5 +++ .../pa-daemon/src/supervisor/accept_loop.rs | 7 ++++ crates/pa-daemon/src/supervisor/adoption.rs | 5 +++ crates/pa-daemon/src/supervisor/clients.rs | 5 +++ .../src/supervisor/dead_child_delete_tests.rs | 3 ++ .../src/supervisor/handshake_tests.rs | 14 +++++++ .../src/supervisor/launch_admission_tests.rs | 7 ++++ .../pa-daemon/src/supervisor/launch_budget.rs | 1 + .../src/supervisor/model_refresh/tests.rs | 10 +++++ .../src/supervisor/plugin_command_tests.rs | 1 + .../pa-daemon/src/supervisor/root_identity.rs | 6 +++ crates/pa-daemon/src/supervisor/routing.rs | 2 + crates/pa-daemon/src/supervisor/sessions.rs | 2 + .../src/supervisor/signals_shutdown.rs | 3 ++ .../src/supervisor/spawn_record_tests.rs | 4 ++ .../pa-daemon/src/supervisor/subscribers.rs | 6 +++ .../pa-daemon/src/supervisor/supervision.rs | 9 +++++ crates/pa-daemon/src/supervisor/tests.rs | 32 ++++++++++++++++ .../src/supervisor/update_restart.rs | 1 + .../src/supervisor/worker_lifecycle.rs | 3 ++ crates/pa-daemon/src/supervisor_link.rs | 3 ++ crates/pa-daemon/src/supervisor_lost.rs | 1 + .../pa-daemon/src/supervisor_parent_death.rs | 2 + .../src/supervisor_roster/delta_push.rs | 4 ++ .../src/supervisor_roster/passivation.rs | 12 ++++++ .../pa-daemon/src/supervisor_roster_seed.rs | 9 +++++ crates/pa-daemon/src/ts_era.rs | 1 + crates/pa-daemon/src/types.rs | 2 + crates/pa-daemon/src/update_prepare.rs | 12 ++++++ crates/pa-daemon/src/update_restore.rs | 21 ++++++++++ crates/pa-daemon/src/update_roster.rs | 2 + crates/pa-daemon/src/update_stop.rs | 3 ++ crates/pa-daemon/src/user_bash.rs | 16 ++++++++ crates/pa-daemon/src/util.rs | 2 + .../src/worker/agent_message_tests.rs | 16 ++++++++ crates/pa-daemon/src/worker/commands.rs | 1 + .../src/worker/compaction_admission_tests.rs | 2 + .../pa-daemon/src/worker/context_selection.rs | 2 + .../src/worker/prompt_image_tests.rs | 3 ++ .../src/worker/recovery_verdict_tests.rs | 6 +++ .../src/worker/replacement_gate_tests.rs | 9 +++++ .../src/worker/tests/abort_boundary_tests.rs | 12 ++++++ .../worker/tests/connection_state_tests.rs | 2 + .../pa-daemon/src/worker/tests/goal_tests.rs | 7 ++++ .../src/worker/tests/kill_broadcast_tests.rs | 5 +++ .../pa-daemon/src/worker/tests/queue_tests.rs | 8 ++++ .../src/worker/tests/shutdown_usage_tests.rs | 3 ++ .../src/worker/tests/sidecar_exit_tests.rs | 2 + .../src/worker/tests/summary_tests.rs | 8 ++++ .../src/worker/tests/warning_marker_tests.rs | 1 + .../src/worker/tests/windowed_attach_tests.rs | 11 ++++++ .../pa-daemon/src/worker/turn_stream_tests.rs | 5 +++ .../turn_stream_tests/abort_idle_race.rs | 1 + .../src/worker/turn_stream_tests/broadcast.rs | 5 +++ .../src/worker/turn_stream_tests/burst.rs | 4 ++ .../worker/turn_stream_tests/early_abort.rs | 3 ++ .../src/worker/turn_stream_tests/feed.rs | 2 + .../worker/turn_stream_tests/interleave.rs | 15 ++++++++ .../src/worker/turn_stream_tests/park.rs | 5 +++ .../src/worker/turn_stream_tests/queue.rs | 15 ++++++++ .../turn_stream_tests/queue/withdrawal.rs | 1 + .../src/worker/update_snapshot_tests.rs | 12 ++++++ .../src/worker_resume_settings_tests.rs | 2 + crates/pa-daemon/src/worker_stderr.rs | 8 ++++ 172 files changed, 1246 insertions(+) diff --git a/crates/pa-daemon/src/acp/config_options.rs b/crates/pa-daemon/src/acp/config_options.rs index 6f0ddcda0..c606ab396 100644 --- a/crates/pa-daemon/src/acp/config_options.rs +++ b/crates/pa-daemon/src/acp/config_options.rs @@ -225,17 +225,20 @@ mod tests { names.iter().map(std::string::ToString::to_string).collect() } + #[pa_test_scratch::pa_test] #[test] fn model_value_is_the_serialized_pair() { // JSON.stringify shape, byte-identical: `["provider","model"]`. assert_eq!(model_value("faux", "faux-1"), r#"["faux","faux-1"]"#); } + #[pa_test_scratch::pa_test] #[test] fn no_model_yields_no_options() { assert!(session_config_options(None, "medium", &levels(&["off"]), &[]).is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn the_effort_picker_follows_the_map_driven_capability() { let flagged_false = @@ -259,6 +262,7 @@ mod tests { assert_eq!(none.len(), 1, "no levels, no picker: {none:?}"); } + #[pa_test_scratch::pa_test] #[test] fn model_option_lists_discovered_and_current_models() { let current = PickerModel::from_model(&model("faux", "faux-1", "Faux Model", true)); @@ -309,6 +313,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn duplicate_values_collapse_and_the_current_model_wins_its_slot() { let current = PickerModel::from_model(&model("faux", "shared", "Live Name", false)); @@ -322,6 +327,7 @@ mod tests { assert_eq!(options.len(), 1); } + #[pa_test_scratch::pa_test] #[test] fn connection_state_metadata_parses() { let parsed = PickerModel::from_connection_state(&json!({ @@ -333,6 +339,7 @@ mod tests { assert!(PickerModel::from_connection_state(&json!({ "id": "x" })).is_none()); } + #[pa_test_scratch::pa_test] #[test] fn response_value_carries_config_options() { let current = PickerModel::from_model(&model("faux", "faux-1", "Faux Model", false)); diff --git a/crates/pa-daemon/src/acp/daemon.rs b/crates/pa-daemon/src/acp/daemon.rs index b8b389011..d0865ea01 100644 --- a/crates/pa-daemon/src/acp/daemon.rs +++ b/crates/pa-daemon/src/acp/daemon.rs @@ -1936,6 +1936,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn eof_waits_for_a_reserved_close_before_taking_the_session() { let state = Arc::new(Mutex::new(state(Some(hosted_session())))); let order = frame_order_prefix( @@ -1983,6 +1984,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn lost_replace_and_clear_ack_retries_clear_before_an_empty_session() { let (writer, mut commands) = mpsc::unbounded_channel::(); let (_frames_tx, frames) = mpsc::unbounded_channel(); @@ -2085,6 +2087,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn admit_prompt_matches_the_ts_refusal_order() { let none = Arc::new(Mutex::new(state(None))); assert_eq!( @@ -2144,6 +2147,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn arm_cancel_arms_a_running_turn_a_stop_retry_or_nothing() { let mut running = state(Some(hosted_session())); @@ -2178,6 +2182,7 @@ mod tests { assert!(failed.session.as_ref().unwrap().cancel_task.is_some()); } + #[pa_test_scratch::pa_test] #[test] fn a_cancel_while_a_stop_runs_never_arms_a_second_stop() { let mut stopping = state(Some(hosted_session())); diff --git a/crates/pa-daemon/src/acp/jsonrpc.rs b/crates/pa-daemon/src/acp/jsonrpc.rs index b25514bea..04d97ad56 100644 --- a/crates/pa-daemon/src/acp/jsonrpc.rs +++ b/crates/pa-daemon/src/acp/jsonrpc.rs @@ -96,6 +96,7 @@ pub fn notification(method: &str, params: &Value) -> Value { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn parses_request_notification_and_errors() { let request = @@ -125,6 +126,7 @@ mod tests { assert_eq!(invalid["error"]["code"], INVALID_REQUEST); } + #[pa_test_scratch::pa_test] #[test] fn response_shapes() { assert_eq!( diff --git a/crates/pa-daemon/src/acp/mcp.rs b/crates/pa-daemon/src/acp/mcp.rs index d861f7836..c1db906a7 100644 --- a/crates/pa-daemon/src/acp/mcp.rs +++ b/crates/pa-daemon/src/acp/mcp.rs @@ -321,6 +321,7 @@ mod tests { json!({ "name": name, "type": "http", "url": url, "headers": headers }) } + #[pa_test_scratch::pa_test] #[test] fn admits_stdio_with_cwd_and_env() { let servers = resolve_acp_mcp_servers( @@ -346,6 +347,7 @@ mod tests { assert_eq!(env.get("A").map(String::as_str), Some("1")); } + #[pa_test_scratch::pa_test] #[test] fn drops_schema_invalid_entries_like_the_sdk() { // Missing required env (SDK z.array(zEnvVariable)): entry dropped, @@ -382,6 +384,7 @@ mod tests { )); } + #[pa_test_scratch::pa_test] #[test] fn rejects_invalid_names_and_duplicates() { let err = resolve_acp_mcp_servers(&[stdio("-bad")], Path::new("/tmp")).unwrap_err(); @@ -394,6 +397,7 @@ mod tests { assert_eq!(err, "duplicate MCP server name: dup"); } + #[pa_test_scratch::pa_test] #[test] fn rejects_stdio_shape_problems() { let err = resolve_acp_mcp_servers( @@ -410,6 +414,7 @@ mod tests { assert_eq!(err, "MCP server n has an invalid stdio command"); } + #[pa_test_scratch::pa_test] #[test] fn rejects_environment_shape_problems() { let entry = |env: Value| json!({ "name": "e", "type": "stdio", "command": "cat", "args": [], "env": env }); @@ -435,6 +440,7 @@ mod tests { assert_eq!(err, "MCP server e has an invalid environment entry"); } + #[pa_test_scratch::pa_test] #[test] fn rejects_http_shape_problems() { let err = resolve_acp_mcp_servers( @@ -463,6 +469,7 @@ mod tests { assert_eq!(err, "MCP server h has an invalid HTTP URL"); } + #[pa_test_scratch::pa_test] #[test] fn header_identity_is_case_insensitive() { let err = resolve_acp_mcp_servers( @@ -477,6 +484,7 @@ mod tests { assert_eq!(err, "MCP server hdr has duplicate header x-a"); } + #[pa_test_scratch::pa_test] #[test] fn tool_names_follow_the_tighter_limit() { let long = "a".repeat(51); diff --git a/crates/pa-daemon/src/acp/meta.rs b/crates/pa-daemon/src/acp/meta.rs index a0390ae89..bd9313eea 100644 --- a/crates/pa-daemon/src/acp/meta.rs +++ b/crates/pa-daemon/src/acp/meta.rs @@ -168,6 +168,7 @@ pub fn prime_agent_meta(payload: &PrimeAgentSessionMeta) -> Value { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn meta_wraps_under_the_namespace_key() { let wrapped = prime_agent_meta(&PrimeAgentSessionMeta { @@ -188,6 +189,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn acp_stop_reason_keeps_cancel_and_truncation() { use super::super::types::AcpStopReason; @@ -209,6 +211,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn quiescence_serializes_camel_case() { let wrapped = prime_agent_meta(&PrimeAgentSessionMeta { diff --git a/crates/pa-daemon/src/acp/types.rs b/crates/pa-daemon/src/acp/types.rs index ffe804843..8a33818f1 100644 --- a/crates/pa-daemon/src/acp/types.rs +++ b/crates/pa-daemon/src/acp/types.rs @@ -410,6 +410,7 @@ mod tests { use super::*; use serde_json::json; + #[pa_test_scratch::pa_test] #[test] fn initialize_result_matches_the_served_surface() { let value = serde_json::to_value(initialize_result("9.9.9")).unwrap(); @@ -429,6 +430,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn tool_kind_map_matches_the_ts_map() { assert_eq!(AcpToolKind::of_tool("python_repl"), AcpToolKind::Execute); @@ -439,6 +441,7 @@ mod tests { assert_eq!(AcpToolKind::of_tool("fetch"), AcpToolKind::Other); } + #[pa_test_scratch::pa_test] #[test] fn prompt_blocks_split_text_and_images() { let prompt = json!([ @@ -459,6 +462,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn malformed_image_block_is_rejected() { let prompt = json!([{ "type": "image", "data": "AAAA" }]); @@ -466,6 +470,7 @@ mod tests { assert_eq!(error, PromptBlockError::InvalidImage); } + #[pa_test_scratch::pa_test] #[test] fn config_option_update_carries_the_ts_tag_and_payload() { let update = AcpSessionUpdate::ConfigOptionUpdate { @@ -495,6 +500,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn update_variants_carry_the_ts_tags() { let chunk = AcpSessionUpdate::AgentMessageChunk { diff --git a/crates/pa-daemon/src/acp/wire_events.rs b/crates/pa-daemon/src/acp/wire_events.rs index 5e7d87f96..e1a0eade9 100644 --- a/crates/pa-daemon/src/acp/wire_events.rs +++ b/crates/pa-daemon/src/acp/wire_events.rs @@ -457,6 +457,7 @@ fn ipython_rich_output(result: Option<&Value>) -> Option { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn assistant_deltas_map_to_chunks() { let mut state = WireMappingState::default(); @@ -488,6 +489,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn goal_update_maps_to_the_namespaced_goal_meta() { // The GoalState fields the meta carries, @@ -523,6 +525,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn user_messages_and_lifecycle_events_map_to_nothing() { let mut state = WireMappingState::default(); @@ -542,6 +545,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn tool_calls_and_completions_map_like_the_ts_adapter() { let mut state = WireMappingState::default(); @@ -573,6 +577,7 @@ mod tests { assert_eq!(value["content"][0]["content"]["text"], "1\n"); } + #[pa_test_scratch::pa_test] #[test] fn compaction_end_publishes_the_meta_payload() { let mut state = WireMappingState::default(); @@ -591,6 +596,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn assistant_stop_reason_is_captured_from_message_end() { let stop = assistant_stop(&json!({ @@ -606,6 +612,7 @@ mod tests { .is_none()); } + #[pa_test_scratch::pa_test] #[test] fn empty_tool_results_carry_no_content() { let mut state = WireMappingState::default(); @@ -624,6 +631,7 @@ mod tests { assert!(value.get("content").is_none(), "no empty content: {value}"); } + #[pa_test_scratch::pa_test] #[test] fn empty_text_blocks_drop_out_of_the_joined_result() { let mut state = WireMappingState::default(); @@ -647,6 +655,7 @@ mod tests { update.to_bare_value()["_meta"]["ai.primeintellect.prime-agent"].clone() } + #[pa_test_scratch::pa_test] #[test] fn rlm_child_update_maps_to_the_subagents_meta() { let mut state = WireMappingState::default(); @@ -699,6 +708,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn ipython_sent_agent_message_maps_the_target_fallback() { let mut state = WireMappingState::default(); diff --git a/crates/pa-daemon/src/agent_engine/config.rs b/crates/pa-daemon/src/agent_engine/config.rs index 6e53889c6..816e79986 100644 --- a/crates/pa-daemon/src/agent_engine/config.rs +++ b/crates/pa-daemon/src/agent_engine/config.rs @@ -128,6 +128,7 @@ mod tests { /// The create payload's legacy `executionMode` remains accepted; /// a create without one (an agent-spawned session) stays `None`. + #[pa_test_scratch::pa_test] #[test] fn create_resources_read_the_execution_mode() { let payload = serde_json::json!({ "cwd": "/tmp", "executionMode": "interactive" }); diff --git a/crates/pa-daemon/src/agent_engine/context_selection_tests.rs b/crates/pa-daemon/src/agent_engine/context_selection_tests.rs index 81d87a422..093ebe164 100644 --- a/crates/pa-daemon/src/agent_engine/context_selection_tests.rs +++ b/crates/pa-daemon/src/agent_engine/context_selection_tests.rs @@ -222,6 +222,7 @@ impl Drop for OwnedModelServer { } } +#[pa_test_scratch::pa_test] #[test] fn branch_summary_ack_failure_reaches_no_model() { let dir = tempfile::tempdir().unwrap(); // TempDir is private and RAII-owned. @@ -387,6 +388,7 @@ fn branch_summary_ack_failure_reaches_no_model() { drop(server); // Always stops, wakes, and joins its owned server thread. } +#[pa_test_scratch::pa_test] #[test] fn admitted_current_has_empty_proof_without_traversing_suffix() { // Current is intentionally not a graph validator; SDK owns prefix validation. @@ -403,6 +405,7 @@ fn admitted_current_has_empty_proof_without_traversing_suffix() { ); } +#[pa_test_scratch::pa_test] #[test] fn admitted_empty_returns_exact_fifo_users_on_selected_branch() { let entries = vec![ @@ -423,6 +426,7 @@ fn admitted_empty_returns_exact_fifo_users_on_selected_branch() { ); } +#[pa_test_scratch::pa_test] #[test] fn admitted_leaf_excludes_boundary_and_unselected_sibling() { let entries = vec![ @@ -449,6 +453,7 @@ fn admitted_leaf_excludes_boundary_and_unselected_sibling() { assert!(error.to_string().contains("boundary is absent"), "{error}"); } +#[pa_test_scratch::pa_test] #[test] fn admitted_missing_entry_fails_closed() { let entries = vec![user_entry("tip", Some("missing"), "body")]; @@ -461,6 +466,7 @@ fn admitted_missing_entry_fails_closed() { assert!(admitted_input_ids(&[], Some("missing"), &ContextStartupBoundary::Empty).is_err()); } +#[pa_test_scratch::pa_test] #[test] fn admitted_missing_leaf_boundary_fails_closed() { let entries = vec![user_entry("tip", None, "body")]; @@ -479,6 +485,7 @@ fn admitted_missing_leaf_boundary_fails_closed() { .is_err()); } +#[pa_test_scratch::pa_test] #[test] fn admitted_cycle_fails_closed() { let entries = vec![ @@ -490,6 +497,7 @@ fn admitted_cycle_fails_closed() { assert!(error.to_string().contains("contains a cycle"), "{error}"); } +#[pa_test_scratch::pa_test] #[test] fn admitted_same_body_distinct_ids_are_preserved() { let entries = vec![ diff --git a/crates/pa-daemon/src/agent_engine/goalcore.rs b/crates/pa-daemon/src/agent_engine/goalcore.rs index 5209b0a39..dcf3aaa88 100644 --- a/crates/pa-daemon/src/agent_engine/goalcore.rs +++ b/crates/pa-daemon/src/agent_engine/goalcore.rs @@ -318,6 +318,7 @@ mod tests { use crate::agent_engine::tests::{admit, faux_engine_with_settings, FAUX_TEST_LOCK}; use std::sync::Arc; + #[pa_test_scratch::pa_test] #[test] fn max_depth_facade_and_pending_flush_keep_exact_metadata_payloads() { let _faux = FAUX_TEST_LOCK @@ -373,6 +374,7 @@ mod tests { assert!(engine.pending_max_depth.lock().unwrap().is_none()); } + #[pa_test_scratch::pa_test] #[test] fn blocked_goal_driver_cannot_refresh_state_or_pending_handle_mirrors() { let _faux = FAUX_TEST_LOCK diff --git a/crates/pa-daemon/src/agent_engine/model.rs b/crates/pa-daemon/src/agent_engine/model.rs index b76c51dd5..81ab47d35 100644 --- a/crates/pa-daemon/src/agent_engine/model.rs +++ b/crates/pa-daemon/src/agent_engine/model.rs @@ -701,6 +701,7 @@ mod refresh_tests { }).to_string()).unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn refresh_metadata_defers_then_adopts_same_id_without_replacing_credentials() { let dir = tempfile::TempDir::new().unwrap(); @@ -758,6 +759,7 @@ mod refresh_tests { .load(std::sync::atomic::Ordering::SeqCst)); } + #[pa_test_scratch::pa_test] #[test] fn refresh_metadata_serializes_with_the_public_model_switch_gate() { use std::cell::Cell; @@ -845,6 +847,7 @@ mod refresh_tests { ); } + #[pa_test_scratch::pa_test] #[test] fn refresh_metadata_lazy_anchor_survives_removal_and_default_change_at_build() { let dir = tempfile::TempDir::new().unwrap(); @@ -898,6 +901,7 @@ mod refresh_tests { ); } + #[pa_test_scratch::pa_test] #[test] fn refresh_metadata_lazy_anchor_yields_to_explicit_switch_and_replacement() { let dir = tempfile::TempDir::new().unwrap(); @@ -920,6 +924,7 @@ mod refresh_tests { assert!(engine.session.blocking_lock().is_none()); } + #[pa_test_scratch::pa_test] #[test] fn refresh_metadata_keeps_a_removed_selected_model() { let dir = tempfile::TempDir::new().unwrap(); @@ -942,6 +947,7 @@ mod refresh_tests { engine.apply_scheduled_model_metadata_refresh().unwrap(); assert_eq!(engine.session_model().unwrap(), original); } + #[pa_test_scratch::pa_test] #[test] fn lazy_refresh_retains_selected_identity_on_the_first_public_prompt() { use tokio::io::{AsyncReadExt, AsyncWriteExt}; diff --git a/crates/pa-daemon/src/agent_engine/tests/abort.rs b/crates/pa-daemon/src/agent_engine/tests/abort.rs index 41c1a9176..447bec7d5 100644 --- a/crates/pa-daemon/src/agent_engine/tests/abort.rs +++ b/crates/pa-daemon/src/agent_engine/tests/abort.rs @@ -4,6 +4,7 @@ use super::*; /// The eager turn abort: an abort landing mid-provider-wait cancels the /// in-flight fetch immediately; the aborted row carries `EMPTY_USAGE`, /// never the goal accounting. +#[pa_test_scratch::pa_test] #[test] fn abort_in_flight_turn_cancels_a_mid_provider_wait() { let _faux = FAUX_TEST_LOCK @@ -168,6 +169,7 @@ fn abort_in_flight_turn_cancels_a_mid_provider_wait() { /// Latch cancellation at actual run registration, not before a run exists. /// The lifecycle owns both history rows and the aborted settle; no provider /// request starts and the next delivery still serves the first script step. +#[pa_test_scratch::pa_test] #[test] fn abort_at_registered_run_start_preserves_the_accepted_turn_without_a_provider_call() { let _faux = FAUX_TEST_LOCK @@ -259,6 +261,7 @@ fn abort_at_registered_run_start_preserves_the_accepted_turn_without_a_provider_ ); } +#[pa_test_scratch::pa_test] #[test] fn settled_turn_emits_the_terminal_turn_end_payload() { let _faux = FAUX_TEST_LOCK @@ -302,6 +305,7 @@ fn settled_turn_emits_the_terminal_turn_end_payload() { assert!(tool_results.is_empty(), "the text-only turn ran no tools"); } +#[pa_test_scratch::pa_test] #[test] fn settled_turn_emits_the_run_agent_end_payload() { let _faux = FAUX_TEST_LOCK @@ -362,6 +366,7 @@ fn settled_turn_emits_the_run_agent_end_payload() { /// One `agent_end` per agent run: a retried run restarts with its own /// frames; the retry's `agent_end` carries only the retry's messages (the /// failed row left the loop context first), and its opening frames forward. +#[pa_test_scratch::pa_test] #[test] fn retried_run_restarts_with_its_own_agent_frames() { let _faux = FAUX_TEST_LOCK @@ -572,6 +577,7 @@ fn kernel_start_failure( /// force-abort path settles the tool race) - not keep the turn alive while /// the cell runs out. Red: the run thread wedged past the cell's sleep /// (the daemon worker's `run_turn_once` awaits the admission forever). +#[pa_test_scratch::pa_test] #[test] fn abort_in_flight_turn_cancels_a_running_kernel_cell() { let Some(kernel_python) = live_kernel_python() else { diff --git a/crates/pa-daemon/src/agent_engine/tests/compaction.rs b/crates/pa-daemon/src/agent_engine/tests/compaction.rs index 138e0f31d..92dde26f9 100644 --- a/crates/pa-daemon/src/agent_engine/tests/compaction.rs +++ b/crates/pa-daemon/src/agent_engine/tests/compaction.rs @@ -7,6 +7,7 @@ use super::*; /// alongside the headroom (the combined input+output ceiling). const FAUX_REQUEST_BUDGET: u64 = 16_384; +#[pa_test_scratch::pa_test] #[test] fn no_retained_boundary_native_archive_is_acked_and_cold_restored_by_the_real_owner() { use pa_types::session::FileEntry; @@ -306,6 +307,7 @@ fn no_retained_boundary_native_archive_is_acked_and_cold_restored_by_the_real_ow /// The automatic threshold compaction at the turn boundary. The faux /// provider estimates usage from the serialized context, so the headroom /// sits halfway between a baseline turn and the baseline plus the big prompt. +#[pa_test_scratch::pa_test] #[test] fn threshold_crossing_auto_compacts_with_the_event_pair() { let _faux = FAUX_TEST_LOCK @@ -417,6 +419,7 @@ fn threshold_crossing_auto_compacts_with_the_event_pair() { /// fresh resolution drifts mid-session (R8). The settings default changes /// under the built session, so `resolve_model` lands on a dead provider — /// but the threshold arm follows `session_model`. +#[pa_test_scratch::pa_test] #[test] fn threshold_compaction_stays_on_the_session_provider_after_a_resolution_drift() { let _faux = FAUX_TEST_LOCK @@ -599,6 +602,7 @@ fn threshold_compaction_stays_on_the_session_provider_after_a_resolution_drift() )); } +#[pa_test_scratch::pa_test] #[test] fn retire_clears_the_provider_target_for_the_replacement_build() { let _faux = FAUX_TEST_LOCK @@ -744,6 +748,7 @@ fn outcome_row_and_end_event( (row_index, event) } +#[pa_test_scratch::pa_test] #[test] fn threshold_skip_records_the_durable_outcome_row() { let _faux = FAUX_TEST_LOCK @@ -815,6 +820,7 @@ fn threshold_skip_records_the_durable_outcome_row() { ); } +#[pa_test_scratch::pa_test] #[test] fn requested_compaction_skip_records_the_durable_outcome_row() { let _faux = FAUX_TEST_LOCK @@ -867,6 +873,7 @@ fn requested_compaction_skip_records_the_durable_outcome_row() { assert!(outcome_row_in_live_context(&engine)); } +#[pa_test_scratch::pa_test] #[test] fn threshold_compaction_aborted_mid_run_records_the_cancelled_outcome() { let _faux = FAUX_TEST_LOCK @@ -945,6 +952,7 @@ fn threshold_compaction_aborted_mid_run_records_the_cancelled_outcome() { ); } +#[pa_test_scratch::pa_test] #[test] fn requested_compaction_aborted_mid_run_records_the_cancelled_outcome() { let _faux = FAUX_TEST_LOCK @@ -1024,6 +1032,7 @@ fn requested_compaction_aborted_mid_run_records_the_cancelled_outcome() { ); } +#[pa_test_scratch::pa_test] #[test] fn threshold_below_the_headroom_stays_silent() { let _faux = FAUX_TEST_LOCK @@ -1088,6 +1097,7 @@ fn compaction_events(events: &[EngineEvent]) -> Vec { .collect() } +#[pa_test_scratch::pa_test] #[test] fn compact_session_command_emits_the_ts_event_pair_on_a_skip() { let (_engine, events) = run_prompts( @@ -1121,6 +1131,7 @@ fn compact_session_command_emits_the_ts_event_pair_on_a_skip() { assert_eq!(events.last(), Some(&EngineEvent::Done(Ok(())))); } +#[pa_test_scratch::pa_test] #[test] fn compact_session_command_emits_the_result_on_success() { // Two big turns (~12k tokens each) push the history past the @@ -1185,6 +1196,7 @@ fn compact_session_command_emits_the_result_on_success() { assert_eq!(rows[0]["customType"], "session_slash_command"); } +#[pa_test_scratch::pa_test] #[test] fn threshold_crossing_inside_one_run_compacts_before_the_next_model_turn() { let _faux = FAUX_TEST_LOCK @@ -1228,6 +1240,7 @@ fn threshold_crossing_inside_one_run_compacts_before_the_next_model_turn() { ); } +#[pa_test_scratch::pa_test] #[test] fn failed_mid_run_compaction_resumes_without_retrying_each_tool_round() { let _faux = FAUX_TEST_LOCK @@ -1284,6 +1297,7 @@ fn failed_mid_run_compaction_resumes_without_retrying_each_tool_round() { /// machinery armed: the suppression is reserved for a summary attempt /// that failed to commit (cursor: "Recheck mismatch disables further /// compaction"). +#[pa_test_scratch::pa_test] #[test] fn a_not_due_recheck_keeps_threshold_checks_armed() { use crate::auto_compaction::AutoCompactionRun; @@ -1301,6 +1315,7 @@ fn a_not_due_recheck_keeps_threshold_checks_armed() { ); } +#[pa_test_scratch::pa_test] #[test] fn low_custom_percentage_compacts_real_history_once_and_then_makes_progress() { let _faux = FAUX_TEST_LOCK diff --git a/crates/pa-daemon/src/agent_engine/tests/context_usage.rs b/crates/pa-daemon/src/agent_engine/tests/context_usage.rs index 872a6b573..5594b910b 100644 --- a/crates/pa-daemon/src/agent_engine/tests/context_usage.rs +++ b/crates/pa-daemon/src/agent_engine/tests/context_usage.rs @@ -1,5 +1,6 @@ use super::*; +#[pa_test_scratch::pa_test] #[test] fn stats_and_attach_follow_history_index_before_and_after_an_edit() { let _faux = FAUX_TEST_LOCK diff --git a/crates/pa-daemon/src/agent_engine/tests/failover_facts.rs b/crates/pa-daemon/src/agent_engine/tests/failover_facts.rs index 9fd6e9270..004f132bd 100644 --- a/crates/pa-daemon/src/agent_engine/tests/failover_facts.rs +++ b/crates/pa-daemon/src/agent_engine/tests/failover_facts.rs @@ -46,6 +46,7 @@ fn request(listener: &TcpListener) -> TcpStream { stream } +#[pa_test_scratch::pa_test] #[test] #[allow(clippy::too_many_lines)] // One real primary-failure / held-backup / restore episode. fn failover_rebinds_model_facts_before_the_backup_can_restore_primary() { diff --git a/crates/pa-daemon/src/agent_engine/tests/goal.rs b/crates/pa-daemon/src/agent_engine/tests/goal.rs index b33390dea..7d4a84134 100644 --- a/crates/pa-daemon/src/agent_engine/tests/goal.rs +++ b/crates/pa-daemon/src/agent_engine/tests/goal.rs @@ -1,6 +1,7 @@ //! The goal tests (recovery, continuation minting, the goal loop's turn-end accounting). use super::*; +#[pa_test_scratch::pa_test] #[test] fn recovery_rebuild_rehydrates_the_goal_from_the_session_file() { let _faux = FAUX_TEST_LOCK @@ -98,6 +99,7 @@ fn recovery_rebuild_rehydrates_the_goal_from_the_session_file() { /// injected context row (TS `createGoalContextMessage`: text first, images /// after) — the row is the turn's only image carrier, session commands /// never admit a user row. +#[pa_test_scratch::pa_test] #[test] fn goal_start_keeps_the_prompt_images_on_the_context_row() { let _faux = FAUX_TEST_LOCK @@ -208,6 +210,7 @@ fn wire_assistant_message(text: String) -> Value { /// One-store recovery: the worker respawns with `--resume `, /// so the rebuilt session's branch carries the pre-crash history and a /// post-recovery compact runs over it — never a skip on the empty branch. +#[pa_test_scratch::pa_test] #[test] fn recovered_engine_compaction_walk_sees_the_durable_history() { let _faux = FAUX_TEST_LOCK @@ -283,6 +286,7 @@ fn recovered_engine_compaction_walk_sees_the_durable_history() { assert!(compaction_entry_in_entries(&engine)); } +#[pa_test_scratch::pa_test] #[test] fn post_compaction_goal_continuation_mint() { let _faux = FAUX_TEST_LOCK @@ -386,6 +390,7 @@ fn post_compaction_goal_continuation_mint() { /// post-compaction mint over an ALREADY-armed deferral delivers the /// OWED continuation exactly once; a fresh mint would leave the /// armed flag behind and the settle sites deliver a second one. +#[pa_test_scratch::pa_test] #[test] fn post_compaction_mint_delivers_the_armed_deferral_once() { let _faux = FAUX_TEST_LOCK @@ -463,6 +468,7 @@ pub(crate) fn admit_request( }); } +#[pa_test_scratch::pa_test] #[test] fn goal_turn_end_mints_the_loop_until_the_goal_completes() { let _faux = FAUX_TEST_LOCK @@ -566,6 +572,7 @@ fn goal_turn_end_mints_the_loop_until_the_goal_completes() { assert!(goal_work.lock().unwrap().is_empty()); } +#[pa_test_scratch::pa_test] #[test] fn paused_goal_mints_no_turn_end_continuation() { let _faux = FAUX_TEST_LOCK @@ -607,6 +614,7 @@ fn paused_goal_mints_no_turn_end_continuation() { assert_eq!(engine.goal_state_value()["status"], "idle"); } +#[pa_test_scratch::pa_test] #[test] fn budget_exhausted_stops_with_the_ts_budget_steer() { let _faux = FAUX_TEST_LOCK @@ -667,6 +675,7 @@ fn budget_exhausted_stops_with_the_ts_budget_steer() { assert_eq!(events.last(), Some(&EngineEvent::Done(Ok(())))); } +#[pa_test_scratch::pa_test] #[test] fn queued_input_defers_the_turn_end_mint() { let _faux = FAUX_TEST_LOCK @@ -712,6 +721,7 @@ fn queued_input_defers_the_turn_end_mint() { assert_eq!(engine.goal_state_value()["continuationsUsed"], 1); } +#[pa_test_scratch::pa_test] #[test] fn running_children_owe_the_continuation_and_settle_delivers_it() { let _faux = FAUX_TEST_LOCK @@ -814,6 +824,7 @@ fn engine_session_entries(engine: &AgentSessionEngine) -> Vec AgentSessionEngine { /// A credential another process wrote (the `/login` scenario) reaches the /// running session through the reload: the provider target rebinds. +#[pa_test_scratch::pa_test] #[test] fn reload_rebinds_the_request_auth_from_the_credential_store() { let dir = tempfile::TempDir::new().unwrap(); @@ -129,6 +130,7 @@ fn reload_rebinds_the_request_auth_from_the_credential_store() { /// With nothing stored for the live model the reload keeps the slot /// untouched (a models.json lost mid-session loses nothing) — the MCP /// re-read alone still runs. +#[pa_test_scratch::pa_test] #[test] fn reload_with_nothing_stored_keeps_the_target() { let dir = tempfile::TempDir::new().unwrap(); @@ -216,6 +218,7 @@ fn write_two_model_provider(agent_dir: &std::path::Path) { /// The live model never retargets through a reload: a routed image /// episode serves on its own target and an unflagged session must not /// follow a changed settings default — only the request auth rebinds. +#[pa_test_scratch::pa_test] #[test] fn reload_keeps_the_live_model_and_rebinds_its_auth() { let dir = tempfile::TempDir::new().unwrap(); @@ -271,6 +274,7 @@ fn reload_keeps_the_live_model_and_rebinds_its_auth() { /// Before the session's first build there is no live target to refresh: /// the reload installs nothing (the build binds its own target) — the MCP /// re-read alone runs. +#[pa_test_scratch::pa_test] #[test] fn reload_without_a_live_target_installs_nothing() { let dir = tempfile::TempDir::new().unwrap(); @@ -293,6 +297,7 @@ fn reload_without_a_live_target_installs_nothing() { /// attempt (overflow retries, failover restores): the reload must refresh /// the armed route's auth too, or the next attempt reinstalls the stale /// credentials a re-login just replaced. +#[pa_test_scratch::pa_test] #[test] fn reload_refreshes_the_armed_image_route_target_auth() { let dir = tempfile::TempDir::new().unwrap(); @@ -373,6 +378,7 @@ fn reload_refreshes_the_armed_image_route_target_auth() { /// store: a credential rotated (and reloaded) during the failover serves /// from the store, never the pre-failover capture; the capture only backs /// a resolution that yields nothing. +#[pa_test_scratch::pa_test] #[test] fn restored_primary_target_serves_the_store_auth() { let dir = tempfile::TempDir::new().unwrap(); @@ -508,6 +514,7 @@ fn prime_inference_backed_engine(dir: &std::path::Path) -> AgentSessionEngine { /// A rotated credential REPLACES the request headers: a fresh key that /// carries no team header must clear the previous credential's /// `X-Prime-Team-ID`, never serve the stale team context on the new key. +#[pa_test_scratch::pa_test] #[test] fn reload_clears_headers_when_the_fresh_credential_carries_none() { let dir = tempfile::TempDir::new().unwrap(); @@ -552,6 +559,7 @@ fn reload_clears_headers_when_the_fresh_credential_carries_none() { /// resolved key paired with the captured headers: a credential rotated /// during the failover carries its own (empty) headers, clearing the /// captured `X-Prime-Team-ID` the pre-failover credential pinned. +#[pa_test_scratch::pa_test] #[test] fn restored_primary_target_serves_the_resolved_header_pair() { let dir = tempfile::TempDir::new().unwrap(); @@ -582,6 +590,7 @@ fn restored_primary_target_serves_the_resolved_header_pair() { /// cannot be parsed, so the MCP manager keeps its previous credentials /// and the reload answers with the storage error instead of a success /// the session did not apply. +#[pa_test_scratch::pa_test] #[test] fn reload_reports_the_auth_store_failure() { let dir = tempfile::TempDir::new().unwrap(); @@ -639,6 +648,7 @@ fn reload_reports_the_auth_store_failure() { /// when the store read fails, the restore keeps the override key and the /// captured headers (the last-good team context), never the header-less /// resolution the broken store produced. +#[pa_test_scratch::pa_test] #[test] fn restored_primary_target_keeps_the_override_key_and_captured_headers_off_a_failed_store() { let dir = tempfile::TempDir::new().unwrap(); @@ -679,6 +689,7 @@ fn restored_primary_target_keeps_the_override_key_and_captured_headers_off_a_fai /// leaves the target untouched: the resolution would serve the /// configured models.json fallback key, which is not a stored /// credential — the same never-clears contract a broken store keeps. +#[pa_test_scratch::pa_test] #[test] fn reload_keeps_the_target_when_the_credential_leaves_the_store() { let dir = tempfile::TempDir::new().unwrap(); @@ -725,6 +736,7 @@ fn reload_keeps_the_target_when_the_credential_leaves_the_store() { ); } +#[pa_test_scratch::pa_test] #[test] fn reload_ollama_caps_restores_targets_routes_and_loop_budgets_without_auth() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/agent_engine/tests/rlm_children.rs b/crates/pa-daemon/src/agent_engine/tests/rlm_children.rs index 449365f29..752eb0739 100644 --- a/crates/pa-daemon/src/agent_engine/tests/rlm_children.rs +++ b/crates/pa-daemon/src/agent_engine/tests/rlm_children.rs @@ -2,6 +2,7 @@ use super::*; use pa_core::session_engine::rlm_host::persisted_rlm_max_depth; +#[pa_test_scratch::pa_test] #[test] fn persisted_rlm_max_depth_reads_validated_log_and_rejects_damage() { use pa_core::session_log::{Outcome, SessionLog}; @@ -42,6 +43,7 @@ fn persisted_rlm_max_depth_reads_validated_log_and_rejects_damage() { /// The settled-child kernel release policy (TS #2483): with no registered /// jobs the release probe fires; a jobs probe reporting this session's jobs /// defers it. +#[pa_test_scratch::pa_test] #[test] fn release_settled_child_kernel_defers_to_scheduled_jobs_and_fires_the_release_probe() { let dir = tempfile::TempDir::new().unwrap(); @@ -81,6 +83,7 @@ fn release_settled_child_kernel_defers_to_scheduled_jobs_and_fires_the_release_p /// (a revival rebuilds only settled ledger rows; the passivation stop /// closes every row) while the kernel release still fires — releasing /// a kernel keeps the worker and its registry resident. +#[pa_test_scratch::pa_test] #[test] fn can_passivate_worker_mirrors_the_release_gates_and_adds_the_registry_rule() { let dir = tempfile::TempDir::new().unwrap(); diff --git a/crates/pa-daemon/src/agent_engine/tests/saved_context.rs b/crates/pa-daemon/src/agent_engine/tests/saved_context.rs index f356a1a74..8177bcdf7 100644 --- a/crates/pa-daemon/src/agent_engine/tests/saved_context.rs +++ b/crates/pa-daemon/src/agent_engine/tests/saved_context.rs @@ -47,6 +47,7 @@ fn oracle_session() -> ( (file, path, dir) } +#[pa_test_scratch::pa_test] #[test] fn saved_context_windowed_matches_full_parse_without_a_boundary() { let (mut file, path, _dir) = oracle_session(); @@ -64,6 +65,7 @@ fn saved_context_windowed_matches_full_parse_without_a_boundary() { assert_saved_context_equals_reference("no-boundary session", &path); } +#[pa_test_scratch::pa_test] #[test] fn saved_context_windowed_matches_full_parse_with_changes_inside_the_window() { let (mut file, path, _dir) = oracle_session(); @@ -88,6 +90,7 @@ fn saved_context_windowed_matches_full_parse_with_changes_inside_the_window() { assert_saved_context_equals_reference("boundary, changes inside the window", &path); } +#[pa_test_scratch::pa_test] #[test] fn saved_context_windowed_matches_full_parse_with_model_only_before_the_boundary() { let (mut file, path, _dir) = oracle_session(); @@ -113,6 +116,7 @@ fn saved_context_windowed_matches_full_parse_with_model_only_before_the_boundary assert_saved_context_equals_reference("boundary, model only before", &path); } +#[pa_test_scratch::pa_test] #[test] fn saved_context_windowed_matches_full_parse_with_thinking_only_before_the_boundary() { let (mut file, path, _dir) = oracle_session(); @@ -135,6 +139,7 @@ fn saved_context_windowed_matches_full_parse_with_thinking_only_before_the_bound assert_saved_context_equals_reference("boundary, thinking only before", &path); } +#[pa_test_scratch::pa_test] #[test] fn saved_context_refuses_a_corrupt_committed_row_without_repair() { let (mut file, path, _dir) = oracle_session(); @@ -167,6 +172,7 @@ fn saved_context_refuses_a_corrupt_committed_row_without_repair() { assert_eq!(std::fs::read(&path).unwrap(), damaged); } +#[pa_test_scratch::pa_test] #[test] fn saved_context_from_the_open_store_matches_the_file_read_and_the_reference() { let (mut file, path, _dir) = oracle_session(); diff --git a/crates/pa-daemon/src/agent_engine/tests/session.rs b/crates/pa-daemon/src/agent_engine/tests/session.rs index 41edb44c0..0cdf59874 100644 --- a/crates/pa-daemon/src/agent_engine/tests/session.rs +++ b/crates/pa-daemon/src/agent_engine/tests/session.rs @@ -2,6 +2,7 @@ use super::*; use crate::engine::PromptBatchRow; +#[pa_test_scratch::pa_test] #[test] fn lazy_replacement_keeps_canonical_rows_committed_after_the_pending_branch() { use crate::engine::SessionEngine as _; @@ -79,6 +80,7 @@ fn lazy_replacement_keeps_canonical_rows_committed_after_the_pending_branch() { /// the core session). The faux provider registers under `FAUX_TEST_LOCK` /// on a blocking thread (the lock is std, so it never rides an await). #[tokio::test] +#[pa_test_scratch::pa_test] async fn get_commands_enumerates_skills_before_the_first_prompt() { use crate::engine::SessionEngine as _; let (engine, _dir) = tokio::task::spawn_blocking(|| { @@ -159,6 +161,7 @@ async fn get_commands_enumerates_skills_before_the_first_prompt() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn refused_completed_retirement_keeps_cached_runtime_and_accepted_queue() { let (engine, _events) = tokio::task::spawn_blocking(|| { run_prompts( @@ -189,6 +192,7 @@ async fn refused_completed_retirement_keeps_cached_runtime_and_accepted_queue() } #[tokio::test] +#[pa_test_scratch::pa_test] async fn replacement_discard_seals_retained_runtime_without_claiming_empty_queue() { let (engine, _events) = tokio::task::spawn_blocking(|| { run_prompts( @@ -219,6 +223,7 @@ async fn replacement_discard_seals_retained_runtime_without_claiming_empty_queue } #[tokio::test] +#[pa_test_scratch::pa_test] async fn replacement_teardown_retires_the_session_and_the_funnel_adopts_the_branch() { let engine = { let (engine, _events) = tokio::task::spawn_blocking(|| { @@ -313,6 +318,7 @@ async fn replacement_teardown_retires_the_session_and_the_funnel_adopts_the_bran } #[tokio::test] +#[pa_test_scratch::pa_test] async fn live_branch_rebuild_reloads_the_goal_state_from_the_moved_branch() { let engine = { let (engine, _events) = tokio::task::spawn_blocking(|| { @@ -508,6 +514,7 @@ fn run_skill_prompt(prompt: &str) -> Vec { run_skill_prompt_body("Run the demo protocol.", prompt, &[]).1 } +#[pa_test_scratch::pa_test] #[test] fn a_bare_skill_invocation_admits_the_expanded_block() { let events = run_skill_prompt("/skill:demo-skill"); @@ -540,6 +547,7 @@ fn a_bare_skill_invocation_admits_the_expanded_block() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_skill_invocation_with_args_persists_the_block_and_the_args() { let events = run_skill_prompt("/skill:demo-skill fix the flake"); @@ -559,6 +567,7 @@ fn a_skill_invocation_with_args_persists_the_block_and_the_args() { assert_eq!(assistant_texts(&events), vec!["ok"]); } +#[pa_test_scratch::pa_test] #[test] fn a_batched_bare_skill_row_admits_on_the_expanded_block() { let (engine, events) = @@ -591,6 +600,7 @@ fn a_batched_bare_skill_row_admits_on_the_expanded_block() { assert_eq!(assistant_texts(&events), vec!["ok"]); } +#[pa_test_scratch::pa_test] #[test] fn a_bare_invocation_of_a_close_tagged_body_expands() { let (_engine, events) = run_skill_prompt_body( diff --git a/crates/pa-daemon/src/agent_engine/tests/streaming.rs b/crates/pa-daemon/src/agent_engine/tests/streaming.rs index a9d37b4b7..1eedd4870 100644 --- a/crates/pa-daemon/src/agent_engine/tests/streaming.rs +++ b/crates/pa-daemon/src/agent_engine/tests/streaming.rs @@ -3,6 +3,7 @@ use super::*; /// Images ride as multimodal blocks after the text, even when the model /// turn cannot run. +#[pa_test_scratch::pa_test] #[test] fn prompt_images_ride_the_user_message_content() { let dir = tempfile::TempDir::new().unwrap(); @@ -42,6 +43,7 @@ fn prompt_images_ride_the_user_message_content() { ); } +#[pa_test_scratch::pa_test] #[test] fn assistant_updates_stream_live_while_the_turn_runs() { let _faux = FAUX_TEST_LOCK @@ -131,6 +133,7 @@ fn assistant_updates_stream_live_while_the_turn_runs() { assert!(final_len >= 40 * 3, "final partial is the full text"); } +#[pa_test_scratch::pa_test] #[test] fn agent_engine_streams_updates_and_final_message() { let _faux = FAUX_TEST_LOCK @@ -189,6 +192,7 @@ fn agent_engine_streams_updates_and_final_message() { /// The worker persists the accepted row before the lazy core builds. Its /// pre-admission leaf must keep that row out of restored model history, while /// repeated text and image blocks remain distinct turns after a runtime rebuild. +#[pa_test_scratch::pa_test] #[test] fn lazy_build_restores_only_the_pre_admission_prompt_context() { let _faux = FAUX_TEST_LOCK @@ -417,6 +421,7 @@ fn lazy_build_restores_only_the_pre_admission_prompt_context() { } } +#[pa_test_scratch::pa_test] #[test] fn cold_real_owner_preserves_legacy_custom_rows_as_generic_custom_rows() { use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -724,6 +729,7 @@ fn cold_real_owner_preserves_legacy_custom_rows_as_generic_custom_rows() { assert_eq!(std::fs::read(&path).unwrap(), physical); } +#[pa_test_scratch::pa_test] #[test] fn opaque_legacy_payload_is_preserved_without_becoming_a_model_message() { let kind = "legacy.custom"; @@ -760,6 +766,7 @@ fn opaque_legacy_payload_is_preserved_without_becoming_a_model_message() { /// The helper poll proves the existing gate contract even with a cached SDK. /// The real prompt below still persists through the actual canonical owner. +#[pa_test_scratch::pa_test] #[test] fn cached_sdk_acceptance_waits_for_build_gate_before_user_receipt() { let _faux = FAUX_TEST_LOCK @@ -831,6 +838,7 @@ fn cached_sdk_acceptance_waits_for_build_gate_before_user_receipt() { ); } +#[pa_test_scratch::pa_test] #[test] fn refused_canonical_model_and_thinking_switches_do_not_publish_new_state() { let _faux = FAUX_TEST_LOCK @@ -894,6 +902,7 @@ fn refused_canonical_model_and_thinking_switches_do_not_publish_new_state() { assert_eq!(engine.effective_thinking(), previous_thinking); } +#[pa_test_scratch::pa_test] #[test] fn lazy_startup_two_accepted_batch_inputs_are_excluded_then_delivered_once() { let _faux = FAUX_TEST_LOCK @@ -1016,6 +1025,7 @@ fn lazy_startup_two_accepted_batch_inputs_are_excluded_then_delivered_once() { assert!(std::fs::read(&path).unwrap().starts_with(&accepted_bytes)); } +#[pa_test_scratch::pa_test] #[test] fn live_stream_metadata_snapshot_preserves_provider_terminal_and_next_epoch() { use pa_agent::stream::{AssistantMessageEvent, ModelStream, StreamFn}; @@ -1207,6 +1217,7 @@ fn live_stream_metadata_snapshot_preserves_provider_terminal_and_next_epoch() { } } +#[pa_test_scratch::pa_test] #[test] fn cold_switch_uses_caller_persistence_and_hot_switch_commits_once_through_sink() { let _faux = FAUX_TEST_LOCK @@ -1275,6 +1286,7 @@ fn cold_switch_uses_caller_persistence_and_hot_switch_commits_once_through_sink( ); } +#[pa_test_scratch::pa_test] #[test] fn cached_user_and_custom_admissions_are_durable_and_visible_once() { let _faux = FAUX_TEST_LOCK diff --git a/crates/pa-daemon/src/agent_message_ingest.rs b/crates/pa-daemon/src/agent_message_ingest.rs index 24d59bae6..b5229885f 100644 --- a/crates/pa-daemon/src/agent_message_ingest.rs +++ b/crates/pa-daemon/src/agent_message_ingest.rs @@ -187,6 +187,7 @@ mod tests { /// A pause clears queued agent messages but keeps client prompts. #[tokio::test] + #[pa_test_scratch::pa_test] async fn status_pause_resume_and_clear_match_ts_shapes() { let worker = created_worker().await; @@ -273,6 +274,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn clear_reports_the_follow_up_lane() { let worker = created_worker().await; let delivered = worker diff --git a/crates/pa-daemon/src/agent_messaging/controller_tests.rs b/crates/pa-daemon/src/agent_messaging/controller_tests.rs index 76676f2e9..b53d2efd7 100644 --- a/crates/pa-daemon/src/agent_messaging/controller_tests.rs +++ b/crates/pa-daemon/src/agent_messaging/controller_tests.rs @@ -163,6 +163,7 @@ fn input() -> AgentMessageSendInput { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn family_reads_siblings_from_the_supervisor_roster() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("sup.sock"); @@ -187,6 +188,7 @@ async fn family_reads_siblings_from_the_supervisor_roster() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn family_labels_children_and_parent_from_the_registry() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("sup.sock"); @@ -247,6 +249,7 @@ async fn family_labels_children_and_parent_from_the_registry() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn family_resolves_the_parent_by_session_id() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("sup.sock"); @@ -276,6 +279,7 @@ async fn family_resolves_the_parent_by_session_id() { /// members keyed by their durable session id (the wake-resolvable /// selector), the spawn-time live id kept as an alias. #[tokio::test] +#[pa_test_scratch::pa_test] async fn family_keeps_off_roster_children_addressable() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("sup.sock"); @@ -307,6 +311,7 @@ async fn family_keeps_off_roster_children_addressable() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn refused_ticket_falls_back_to_the_supervisor_route() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("sup.sock"); @@ -328,6 +333,7 @@ async fn refused_ticket_falls_back_to_the_supervisor_route() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn self_target_is_refused() { let controller = controller(std::path::PathBuf::from("/nonexistent.sock"), None); let error = controller @@ -349,6 +355,7 @@ async fn self_target_is_refused() { /// worker purpose, then `worker_deliver_message` carrying the TS /// sender identity block, and the receipt maps onto the kernel shape. #[tokio::test] +#[pa_test_scratch::pa_test] async fn direct_ticket_delivers_to_the_target_worker_socket() { let dir = tempfile::TempDir::new().unwrap(); let worker_socket = dir.path().join("worker.sock"); @@ -478,6 +485,7 @@ async fn direct_ticket_delivers_to_the_target_worker_socket() { assert_eq!(delivery["sender"]["clientId"], "agent"); } +#[pa_test_scratch::pa_test] #[test] fn same_session_file_resolves_the_storage_root_alias() { assert!(same_session_file( @@ -500,6 +508,7 @@ fn same_session_file_resolves_the_storage_root_alias() { )); } +#[pa_test_scratch::pa_test] #[test] fn summaries_label_the_nuclear_family_by_durable_edges() { let identity = FamilyIdentity { @@ -568,6 +577,7 @@ fn summaries_label_the_nuclear_family_by_durable_edges() { .any(|s| s.active_session_id.as_deref() == Some("root555"))); } +#[pa_test_scratch::pa_test] #[test] fn summaries_bind_a_child_one_level_down_and_leave_a_same_depth_fork_out() { let parent = FamilyIdentity { @@ -645,6 +655,7 @@ fn summaries_bind_a_child_one_level_down_and_leave_a_same_depth_fork_out() { ); } +#[pa_test_scratch::pa_test] #[test] fn summaries_treat_a_root_fork_as_a_root() { let parent = FamilyIdentity { @@ -731,6 +742,7 @@ fn summaries_treat_a_root_fork_as_a_root() { /// TS #2493: observe rows carry the typed family status (the busy verdict) plus the /// separate live activity axis — a quiet row is `idle`, never the pre-fix `inactive`. +#[pa_test_scratch::pa_test] #[test] fn summaries_carry_the_typed_status_and_activity() { let identity = FamilyIdentity { @@ -805,6 +817,7 @@ fn summaries_carry_the_typed_status_and_activity() { assert_eq!(passivated.activity, None); } +#[pa_test_scratch::pa_test] #[test] fn summaries_label_root_siblings_and_never_foreign_children() { let identity = FamilyIdentity { @@ -841,6 +854,7 @@ fn summaries_label_root_siblings_and_never_foreign_children() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn family_resolves_a_moved_parent_by_the_peers_roster_alias() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("sup.sock"); @@ -869,6 +883,7 @@ async fn family_resolves_a_moved_parent_by_the_peers_roster_alias() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn family_joins_a_replaced_child_by_its_durable_ids() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("sup.sock"); @@ -905,6 +920,7 @@ async fn family_joins_a_replaced_child_by_its_durable_ids() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn family_resolves_a_moved_parent_by_the_session_file_alias() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("sup.sock"); diff --git a/crates/pa-daemon/src/agent_roster.rs b/crates/pa-daemon/src/agent_roster.rs index 79e2ac4f2..650760c3b 100644 --- a/crates/pa-daemon/src/agent_roster.rs +++ b/crates/pa-daemon/src/agent_roster.rs @@ -476,6 +476,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn write_classifies_and_indexes() { let roster = locked(); @@ -493,6 +494,7 @@ mod tests { assert_eq!(entry.status, AgentRosterStatus::Running); } + #[pa_test_scratch::pa_test] #[test] fn session_file_ownership_converges() { let roster = locked(); @@ -512,6 +514,7 @@ mod tests { assert_eq!(roster.entries().len(), 1); } + #[pa_test_scratch::pa_test] #[test] fn delete_is_idempotent() { let roster = locked(); @@ -522,6 +525,7 @@ mod tests { roster.delete("s1"); } + #[pa_test_scratch::pa_test] #[test] fn queued_children_classify_running_with_label() { let roster = locked(); @@ -533,6 +537,7 @@ mod tests { assert_eq!(entry.status_label.as_deref(), Some("queued")); } + #[pa_test_scratch::pa_test] #[test] fn seeded_rows_carry_the_marker_and_never_double_key() { let roster = locked(); @@ -571,6 +576,7 @@ mod tests { assert_eq!(hydrated.summary["cwd"], "/tmp/project"); } + #[pa_test_scratch::pa_test] #[test] fn worker_entries_filter_by_worker() { let roster = locked(); @@ -582,6 +588,7 @@ mod tests { assert_eq!(w1[0].agent_id, "s1"); } + #[pa_test_scratch::pa_test] #[test] fn delta_sequence_gate_drops_stale_snapshots() { let roster = locked(); @@ -610,6 +617,7 @@ mod tests { assert!(!roster.accept_delta_sequence("w1", "i2", 1)); } + #[pa_test_scratch::pa_test] #[test] fn pull_gate_orders_authoritative_writes_by_the_snapshot_counter() { let roster = locked(); @@ -648,6 +656,7 @@ mod tests { assert!(roster.accept_delta_sequence("w1", "i2", 4)); } + #[pa_test_scratch::pa_test] #[test] fn replacement_watermarks_stay_bounded() { let roster = locked(); @@ -669,6 +678,7 @@ mod tests { /// The bucket folds' ordering rule (the delta watermark's twin): a /// fold that started earlier never overwrites a bucket applied by a /// newer one, whatever order the two folds FINISH in. + #[pa_test_scratch::pa_test] #[test] fn an_older_bucket_fold_never_overwrites_a_newer_one() { let roster = locked(); diff --git a/crates/pa-daemon/src/async_safe_runtime.rs b/crates/pa-daemon/src/async_safe_runtime.rs index 7a82c7ffa..5a0c34bc1 100644 --- a/crates/pa-daemon/src/async_safe_runtime.rs +++ b/crates/pa-daemon/src/async_safe_runtime.rs @@ -49,6 +49,7 @@ impl Drop for AsyncSafeRuntime { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn dropping_from_an_async_context_does_not_panic() { // The exact production crash: an engine teardown drops the runtime diff --git a/crates/pa-daemon/src/backpressure.rs b/crates/pa-daemon/src/backpressure.rs index c9c394063..e6f51109d 100644 --- a/crates/pa-daemon/src/backpressure.rs +++ b/crates/pa-daemon/src/backpressure.rs @@ -112,6 +112,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_saturated_worker_answers_client_requests_with_the_typed_overload_refusal() { let dir = tempfile::TempDir::new().expect("temp dir"); let supervisor = supervisor(dir.path()); @@ -189,6 +190,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_saturated_internal_route_admits_once_a_slot_frees() { let dir = tempfile::TempDir::new().expect("temp dir"); let supervisor = supervisor(dir.path()); @@ -235,6 +237,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_full_queue_answers_client_requests_with_the_same_refusal() { let dir = tempfile::TempDir::new().expect("temp dir"); let supervisor = supervisor(dir.path()); @@ -292,6 +295,7 @@ mod tests { /// retired worker refuses the client route after admission, before /// anything is enqueued behind the stop. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_retired_worker_admits_no_client_request() { let dir = tempfile::TempDir::new().expect("temp dir"); let supervisor = supervisor(dir.path()); diff --git a/crates/pa-daemon/src/bash_notices.rs b/crates/pa-daemon/src/bash_notices.rs index 56da47973..5f516f86a 100644 --- a/crates/pa-daemon/src/bash_notices.rs +++ b/crates/pa-daemon/src/bash_notices.rs @@ -119,6 +119,7 @@ fn validate_consumed(data: &Value) -> anyhow::Result { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn completion_validation_matches_the_ts_contract() { assert!(validate_completion(&serde_json::json!({ diff --git a/crates/pa-daemon/src/boot_reap.rs b/crates/pa-daemon/src/boot_reap.rs index 43e17ef33..e31ac200b 100644 --- a/crates/pa-daemon/src/boot_reap.rs +++ b/crates/pa-daemon/src/boot_reap.rs @@ -682,6 +682,7 @@ mod tests { } #[cfg(target_os = "linux")] + #[pa_test_scratch::pa_test] #[test] fn the_abandoned_id_filter_matches_the_stamped_env_only() { let unstamped_guard = ReapOnDrop( @@ -747,6 +748,7 @@ mod tests { #[cfg(target_os = "linux")] #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_real_process_stops_inside_the_term_grace() { let mut child = std::process::Command::new("sleep") .arg("300") @@ -766,6 +768,7 @@ mod tests { /// the guard's kill); its marker file is the readiness barrier. #[cfg(target_os = "linux")] #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_term_ignoring_process_dies_to_the_stop_escalation() { let dir = tempfile::TempDir::new().expect("temp dir"); let trap_armed = dir.path().join("trap-armed"); @@ -793,6 +796,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_vanished_pid_reports_already_gone() { let mut child = std::process::Command::new("true") .spawn() @@ -803,6 +807,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_recycled_pid_is_never_signaled() { let mut child = std::process::Command::new("sleep") .arg("300") @@ -831,6 +836,7 @@ mod tests { let _ = child.wait(); } + #[pa_test_scratch::pa_test] #[test] fn worker_argv_shapes() { let worker = ["/bin/prime-agent", "worker"] @@ -890,6 +896,7 @@ mod tests { } #[cfg(target_os = "linux")] + #[pa_test_scratch::pa_test] #[test] fn the_exe_gate_reads_the_kernel_binary() { let mut child = std::process::Command::new("sleep") @@ -904,6 +911,7 @@ mod tests { let _ = child.wait(); } + #[pa_test_scratch::pa_test] #[test] fn the_exe_gate_accepts_replaced_binaries() { let replaced = "/opt/prime-agent/bin/prime-agent (deleted)"; @@ -914,6 +922,7 @@ mod tests { } #[cfg(target_os = "linux")] + #[pa_test_scratch::pa_test] #[test] fn the_supervisor_match_normalizes_both_spellings() { let direct = [ @@ -950,6 +959,7 @@ mod tests { } #[cfg(target_os = "linux")] + #[pa_test_scratch::pa_test] #[test] fn our_worker_socket_names_only() { let supervisor = Path::new("/tmp/prime-agent-1000/daemon.sock"); @@ -977,6 +987,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn supervisor_argv_shapes() { let product = [ diff --git a/crates/pa-daemon/src/child_status_notices.rs b/crates/pa-daemon/src/child_status_notices.rs index 30994880f..8c6fa0fc7 100644 --- a/crates/pa-daemon/src/child_status_notices.rs +++ b/crates/pa-daemon/src/child_status_notices.rs @@ -77,6 +77,7 @@ mod tests { use super::*; use serde_json::json; + #[pa_test_scratch::pa_test] #[test] fn a_mint_consumes_exactly_once() { let nonce = mint(); @@ -87,6 +88,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn everything_a_caller_might_send_consumes_nothing() { assert!(!consume(None), "an absent nonce is no capability"); @@ -97,6 +99,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn the_reserved_kinds_match_exactly() { for kind in RESERVED_CUSTOM_KINDS { diff --git a/crates/pa-daemon/src/compaction.rs b/crates/pa-daemon/src/compaction.rs index 83f24c306..f1b411944 100644 --- a/crates/pa-daemon/src/compaction.rs +++ b/crates/pa-daemon/src/compaction.rs @@ -454,6 +454,7 @@ fn compaction_end_event(outcome: &CompactionOutcome, custom_instructions: Option mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn compaction_result_value_mirrors_the_ts_datakeys() { let result = pa_core::session_engine::compaction_exec::CompactionResult { @@ -507,6 +508,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn event_shapes_match_ts() { let run = crate::engine::CompactionRun { @@ -600,6 +602,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn interrupted_disclosure_is_the_auto_abort_row_stamped_with_the_declaration() { let disclosure = interrupted_compaction_disclosure(&json!({ diff --git a/crates/pa-daemon/src/compaction_supervision.rs b/crates/pa-daemon/src/compaction_supervision.rs index 6ef9af955..aace80c9a 100644 --- a/crates/pa-daemon/src/compaction_supervision.rs +++ b/crates/pa-daemon/src/compaction_supervision.rs @@ -543,6 +543,7 @@ mod tests { supervision } + #[pa_test_scratch::pa_test] #[test] fn armed_run_settles_on_its_own_end() { let supervision = supervision_with_run("manual"); @@ -551,6 +552,7 @@ mod tests { assert_eq!(supervision.declare_terminal_if_unresolved(epoch), None); } + #[pa_test_scratch::pa_test] #[test] fn unresolved_abort_declares_terminal() { let supervision = supervision_with_run("threshold"); @@ -566,6 +568,7 @@ mod tests { assert_eq!(supervision.declare_terminal_if_unresolved(epoch), None); } + #[pa_test_scratch::pa_test] #[test] fn a_newer_run_escapes_an_older_watch() { let supervision = supervision_with_run("manual"); @@ -582,12 +585,14 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn abort_without_a_run_supervises_nothing() { let supervision = CompactionSupervision::default(); assert_eq!(supervision.request_abort(), None); } + #[pa_test_scratch::pa_test] #[test] fn worker_gone_declares_only_aborted_runs() { let plain = supervision_with_run("manual"); @@ -609,6 +614,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn fallback_arm_is_abort_requested_manual() { let supervision = CompactionSupervision::default(); @@ -624,6 +630,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn fallback_arm_respects_a_live_run() { let supervision = supervision_with_run("threshold"); @@ -643,6 +650,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_delayed_start_frame_carries_the_fallback_abort() { let supervision = CompactionSupervision::default(); @@ -667,6 +675,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_normal_replacement_arms_unaborted() { let supervision = supervision_with_run("manual"); @@ -687,6 +696,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn epochs_stay_monotonic_across_clears() { let supervision = supervision_with_run("manual"); @@ -698,6 +708,7 @@ mod tests { assert_eq!(supervision.declare_terminal_if_unresolved(first), None); } + #[pa_test_scratch::pa_test] #[test] fn journal_survives_restart_until_consumed_or_cleared() { let dir = std::env::temp_dir().join(format!("pa-comp-sup-{}", uuid::Uuid::new_v4())); @@ -752,6 +763,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn a_manual_declaration_never_displaces_a_pending_record() { let dir = std::env::temp_dir().join(format!("pa-comp-sup-{}", uuid::Uuid::new_v4())); @@ -808,6 +820,7 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + #[pa_test_scratch::pa_test] #[test] fn a_failed_durable_write_stays_retryable_until_the_replay() { let dir = std::env::temp_dir().join(format!("pa-comp-sup-{}", uuid::Uuid::new_v4())); @@ -851,6 +864,7 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + #[pa_test_scratch::pa_test] #[test] fn terminal_journal_read_failure_stops_recovery() { let dir = std::env::temp_dir().join(format!("pa-comp-sup-{}", uuid::Uuid::new_v4())); @@ -864,6 +878,7 @@ mod tests { std::fs::remove_dir_all(&dir).unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn terminal_journal_open_heals_torn_utf8_tail() { let dir = std::env::temp_dir().join(format!("pa-comp-sup-{}", uuid::Uuid::new_v4())); @@ -899,6 +914,7 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + #[pa_test_scratch::pa_test] #[test] fn corrupt_complete_terminal_identifiers_are_preserved_before_recovery_fails() { for newline_terminated in [true, false] { @@ -936,6 +952,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn a_competing_terminal_writer_cannot_replace_an_active_append() { use std::io::Write; @@ -985,6 +1002,7 @@ mod tests { #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_competing_supervisor_does_not_heal_before_socket_admission() { use std::io::Write; let dir = std::path::PathBuf::from("/tmp").join(format!("pa-c-{}", uuid::Uuid::new_v4())); diff --git a/crates/pa-daemon/src/context_tree_cache.rs b/crates/pa-daemon/src/context_tree_cache.rs index 9414707fc..f0fc5b830 100644 --- a/crates/pa-daemon/src/context_tree_cache.rs +++ b/crates/pa-daemon/src/context_tree_cache.rs @@ -454,6 +454,7 @@ mod tests { json!({ "id": id, "label": "child", "status": status }) } + #[pa_test_scratch::pa_test] #[test] fn settled_children_keep_their_cached_row() { let cache = cache_with_walk("session-a", &[("child-live", 100)], &[]); @@ -468,6 +469,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn replaced_session_snapshots_never_serve() { let cache = cache_with_walk("session-old", &[("child-live", 100)], &["child-disk"]); @@ -481,6 +483,7 @@ mod tests { assert_eq!(children.len(), 2, "live backfill + persisted row"); } + #[pa_test_scratch::pa_test] #[test] fn live_identity_overlays_the_cached_body() { let cache = cache_with_walk("session-a", &[("child-live", 100)], &[]); @@ -491,6 +494,7 @@ mod tests { assert_eq!(children[0]["totalUsage"]["input"], json!(100)); } + #[pa_test_scratch::pa_test] #[test] fn invalidated_children_leave_the_tree_immediately() { let cache = cache_with_walk("session-a", &[("child-live", 100)], &["child-disk"]); @@ -524,6 +528,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn an_in_flight_walk_cannot_republish_a_deleted_child() { let cache = cache_with_walk("session-a", &[("child-live", 100)], &[]); @@ -549,6 +554,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_newly_live_child_rides_its_cached_persisted_usage() { // The persisted row carries REAL usage (the seeded tree's spend) — @@ -583,6 +589,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn cold_cache_serves_live_rows_with_the_usage_fallback() { let cache = ContextTreeCache::new(); diff --git a/crates/pa-daemon/src/context_tree_children.rs b/crates/pa-daemon/src/context_tree_children.rs index 08ccc6f48..06882fde9 100644 --- a/crates/pa-daemon/src/context_tree_children.rs +++ b/crates/pa-daemon/src/context_tree_children.rs @@ -327,6 +327,7 @@ mod tests { child_dir } + #[pa_test_scratch::pa_test] #[test] fn disk_children_carry_usage_label_status_and_model() { let root = dir(); @@ -382,6 +383,7 @@ mod tests { /// A subagent's node attributes its spend to ITS model: the by-model bucket /// subtracts the grandchild's attribution exactly like `ownUsage` /// ($0.065 = $0.088 aggregate - $0.023 grandchild). + #[pa_test_scratch::pa_test] #[test] fn disk_child_attributes_its_own_spend_to_its_model() { let root = dir(); @@ -507,6 +509,7 @@ mod tests { let _ = std::fs::remove_dir_all(&root); } + #[pa_test_scratch::pa_test] #[test] fn walk_lists_sub_dirs_and_skips_ids() { let root = dir(); @@ -538,6 +541,7 @@ mod tests { let _ = std::fs::remove_dir_all(&root); } + #[pa_test_scratch::pa_test] #[test] fn grandchildren_load_from_the_childs_sibling_tree() { let root = dir(); @@ -571,6 +575,7 @@ mod tests { let _ = std::fs::remove_dir_all(&root); } + #[pa_test_scratch::pa_test] #[test] fn deleted_grandchildren_stay_hidden() { let root = dir(); @@ -612,6 +617,7 @@ mod tests { let _ = std::fs::remove_dir_all(&root); } + #[pa_test_scratch::pa_test] #[test] fn ghost_gapped_child_files_still_report_usage() { let root = dir(); @@ -645,6 +651,7 @@ mod tests { let _ = std::fs::remove_dir_all(&root); } + #[pa_test_scratch::pa_test] #[test] fn session_artifacts_dir_follows_the_agent_dir() { assert_eq!( diff --git a/crates/pa-daemon/src/create_reuse.rs b/crates/pa-daemon/src/create_reuse.rs index bc63a0615..f1059909c 100644 --- a/crates/pa-daemon/src/create_reuse.rs +++ b/crates/pa-daemon/src/create_reuse.rs @@ -390,6 +390,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_client_owned_create_names_the_live_binding_on_owner_conflicts() { let resident = resident_with(Some("daemon-tui:1"), "live-id"); let conflict = client_owned_conflict( @@ -407,6 +408,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_plain_create_never_conflicts_on_ownership() { let resident = resident_with(Some("daemon-tui:1"), "live-id"); assert!( @@ -417,6 +419,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_owning_clients_reopen_reuses() { let resident = resident_with(Some("daemon-tui:1"), "live-id"); assert!(client_owned_conflict( @@ -430,6 +433,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_unowned_worker_is_reusable() { let resident = resident_with(None, "live-id"); assert!(client_owned_conflict( @@ -443,6 +447,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_unlaunched_registration_counts_as_dead() { let resident = resident_with(None, "live-id"); assert!(!resident_process_alive(&resident).await); @@ -476,6 +481,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_spawned_identity_keeps_a_live_holder_alive() { let pid = std::process::id(); let start_id = crate::lease::get_process_start_id(pid); @@ -484,6 +490,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_recycled_pid_counts_as_dead() { let pid = std::process::id(); let resident = resident_with_identity(u64::from(pid), Some("1/1")); @@ -491,6 +498,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_unverifiable_identity_counts_as_alive() { let pid = std::process::id(); let resident = resident_with_identity(u64::from(pid), None); diff --git a/crates/pa-daemon/src/descriptor.rs b/crates/pa-daemon/src/descriptor.rs index 833ba0d70..31e287ec5 100644 --- a/crates/pa-daemon/src/descriptor.rs +++ b/crates/pa-daemon/src/descriptor.rs @@ -469,6 +469,7 @@ mod tests { use super::*; use serde_json::Map; + #[pa_test_scratch::pa_test] #[test] fn write_file_atomic_replaces_an_existing_destination() { let dir = tempfile::tempdir().unwrap(); @@ -482,6 +483,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn unsynced_atomic_write_replaces_an_existing_destination() { let dir = tempfile::tempdir().unwrap(); @@ -495,6 +497,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn persist_worker_at_unsynced_stamps_and_round_trips() { let dir = tempfile::tempdir().unwrap(); @@ -533,6 +536,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn persisted_supervisor_config_round_trips_through_the_unsynced_write() { let dir = tempfile::tempdir().unwrap(); @@ -565,6 +569,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn durable_create_round_trips() { let payload = json!({ @@ -584,6 +589,7 @@ mod tests { assert_eq!(rebuilt["script"], "/script.json"); } + #[pa_test_scratch::pa_test] #[test] fn descriptor_validates_against_socket() { let descriptor = WorkerDescriptor { diff --git a/crates/pa-daemon/src/engine/tests.rs b/crates/pa-daemon/src/engine/tests.rs index 6e4173865..b709e9582 100644 --- a/crates/pa-daemon/src/engine/tests.rs +++ b/crates/pa-daemon/src/engine/tests.rs @@ -3,6 +3,7 @@ use super::*; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; +#[pa_test_scratch::pa_test] #[test] fn scripted_engine_replays_then_echoes() { let engine = ScriptedEngine::from_value( @@ -42,6 +43,7 @@ fn scripted_engine_replays_then_echoes() { } } +#[pa_test_scratch::pa_test] #[test] fn scripted_assistant_and_tool_events_use_complete_native_message_wires() { let engine = ScriptedEngine::from_value(&json!({"responses": [{ @@ -91,6 +93,7 @@ fn scripted_assistant_and_tool_events_use_complete_native_message_wires() { assert_eq!(messages[2]["content"][0]["text"], "done"); } +#[pa_test_scratch::pa_test] #[test] fn cancellation_stops_the_prompt() { let engine = ScriptedEngine::default(); diff --git a/crates/pa-daemon/src/goal_continuation.rs b/crates/pa-daemon/src/goal_continuation.rs index f364a63ad..b969ef582 100644 --- a/crates/pa-daemon/src/goal_continuation.rs +++ b/crates/pa-daemon/src/goal_continuation.rs @@ -559,6 +559,7 @@ mod tests { .expect("background bash probe lock") = Some(probe); } + #[pa_test_scratch::pa_test] #[test] fn live_background_bash_holds_the_goal_continuation_until_it_settles() { let _faux = FAUX_TEST_LOCK @@ -641,6 +642,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn unresolved_goal_handoff_is_display_only_and_cannot_admit_continuations() { let _faux = FAUX_TEST_LOCK diff --git a/crates/pa-daemon/src/goal_state_persist.rs b/crates/pa-daemon/src/goal_state_persist.rs index 9bcdea605..66ec235de 100644 --- a/crates/pa-daemon/src/goal_state_persist.rs +++ b/crates/pa-daemon/src/goal_state_persist.rs @@ -180,6 +180,7 @@ mod tests { path } + #[pa_test_scratch::pa_test] #[test] fn latest_valid_entry_wins() { let dir = tempfile::TempDir::new().unwrap(); @@ -193,6 +194,7 @@ mod tests { assert_eq!(state.continuations_used, 2); } + #[pa_test_scratch::pa_test] #[test] fn missing_or_invalid_files_answer_none() { let dir = tempfile::TempDir::new().unwrap(); @@ -224,6 +226,7 @@ mod tests { assert_eq!(persisted_goal_state(Some(&empty)), None); } + #[pa_test_scratch::pa_test] #[test] fn invalid_entry_data_is_skipped() { let dir = tempfile::TempDir::new().unwrap(); @@ -260,6 +263,7 @@ mod tests { /// Parity fixture: a real `thread_goal_state` row captured from the TS /// binary's session file (the f18 battery run, 2026-09-19) parses and /// rehydrates through the Rust reader unchanged. + #[pa_test_scratch::pa_test] #[test] fn captured_ts_row_rehydrates_unchanged() { let ts_row = json!({ @@ -289,6 +293,7 @@ mod tests { assert_eq!(state.created_at, Some(1_789_781_423_253)); } + #[pa_test_scratch::pa_test] #[test] fn branch_entry_scan_matches_the_store_read() { let dir = tempfile::TempDir::new().unwrap(); diff --git a/crates/pa-daemon/src/herdr.rs b/crates/pa-daemon/src/herdr.rs index d9bea2205..c06da71d8 100644 --- a/crates/pa-daemon/src/herdr.rs +++ b/crates/pa-daemon/src/herdr.rs @@ -937,6 +937,7 @@ mod tests { .collect() } + #[pa_test_scratch::pa_test] #[test] fn the_socket_target_maps_windows_and_passes_unix_through() { // Unix paths pass through unchanged on both platforms. @@ -963,6 +964,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn the_config_requires_the_pane_env() { // No Herdr pane: no config (the connector is a no-op). @@ -1019,6 +1021,7 @@ mod tests { assert_eq!(invalid.retry_grace, Duration::from_millis(2500)); } + #[pa_test_scratch::pa_test] #[test] fn the_error_hold_reads_the_terminal_assistant_row() { // The terminal assistant row's error becomes the hold message. @@ -1063,6 +1066,7 @@ mod tests { assert_eq!(error_hold_message(&[]), None); } + #[pa_test_scratch::pa_test] #[test] fn the_resume_argv_rides_only_valid_targets() { let argv = valid_resume_argv(Some("019e71ec-e08a-75a9-b573-000000000001.jsonl")); @@ -1090,6 +1094,7 @@ mod tests { assert_eq!(valid_resume_argv(Some("id\u{0007}")), None); } + #[pa_test_scratch::pa_test] #[test] fn the_seq_never_restarts_below_a_used_value() { // The process-global seq is monotonic and floor-clamped: within @@ -1208,6 +1213,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_reporter_publishes_the_wire_contract_states() { let socket_path = temp_socket("wire"); let (requests, server) = fake_herdr(&socket_path); @@ -1263,6 +1269,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_error_end_holds_then_blocks_with_the_message() { let socket_path = temp_socket("hold"); let (requests, server) = fake_herdr(&socket_path); @@ -1295,6 +1302,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_retry_within_the_grace_keeps_the_pane_working() { let socket_path = temp_socket("retry"); let (requests, server) = fake_herdr(&socket_path); @@ -1333,6 +1341,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_release_is_the_last_write_and_never_reclaims() { let socket_path = temp_socket("release"); let (requests, server) = fake_herdr(&socket_path); @@ -1366,6 +1375,7 @@ mod tests { /// failure state: the successor's `session_start` publishes clean /// (idle), never the old blocked/error shape. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_replacement_resets_the_predecessor_failure_state() { let socket_path = temp_socket("reset"); let (requests, server) = fake_herdr(&socket_path); @@ -1420,6 +1430,7 @@ mod tests { /// The stale-generation gate: a replaced reporter's racing boundary /// events never reach the wire — only the successor's do. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_stale_generation_reporter_never_writes() { let socket_path = temp_socket("stale"); let (requests, server) = fake_herdr(&socket_path); @@ -1463,6 +1474,7 @@ mod tests { /// A runaway tuning env cannot overflow the deadline arithmetic: /// the value caps at the JS `setTimeout` bound instead of panicking /// the reporter task with `Instant + Duration`. + #[pa_test_scratch::pa_test] #[test] fn runaway_tuning_values_cap_instead_of_panicking() { let config = HerdrConfig::from_env(&env(&[ @@ -1484,6 +1496,7 @@ mod tests { /// and the dropped release still acks so the quit close does not /// stall on the timeout. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_stale_release_neither_writes_nor_stalls() { let socket_path = temp_socket("stale-release"); let (requests, server) = fake_herdr(&socket_path); @@ -1518,6 +1531,7 @@ mod tests { /// uid that is not ours). #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_pane_socket_fence_decides_by_type_and_owner() { let socket_path = temp_socket("fence"); let listener = tokio::net::UnixListener::bind(&socket_path).unwrap(); @@ -1568,6 +1582,7 @@ mod tests { /// drops the report before the connect, exactly like a missing /// socket. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_reporter_into_a_non_socket_target_stays_silent() { // A LIVE listener exists at the real path: the impostor the // reporter receives is a symlink pointing AT it. If the fence @@ -1604,6 +1619,7 @@ mod tests { /// fence treats `None` as reject (fail closed — the probe must never /// fall back to uid 0, which would accept a root-owned socket). #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn a_failed_uid_probe_fails_closed() { assert!( @@ -1618,6 +1634,7 @@ mod tests { /// boundary once the socket exists. The old queue-time marking /// deduped it away forever — this test fails on that shape. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_state_is_re_sent_after_the_socket_comes_up() { let socket_path = temp_socket("late-boot"); @@ -1673,6 +1690,7 @@ mod tests { /// Concurrent seq minting never duplicates: the first-seed race's /// loser must advance the shared counter like every other caller. + #[pa_test_scratch::pa_test] #[test] fn concurrent_seq_mints_never_duplicate() { let all = std::sync::Mutex::new(Vec::new()); @@ -1694,6 +1712,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_dropped_reporter_stays_silent_without_releasing() { let socket_path = temp_socket("silent"); let (requests, server) = fake_herdr(&socket_path); @@ -1742,6 +1761,7 @@ mod tests { server.abort(); } + #[pa_test_scratch::pa_test] #[test] fn the_noop_reporter_is_inert() { let noop = HerdrReporter::default(); diff --git a/crates/pa-daemon/src/hold_refusal.rs b/crates/pa-daemon/src/hold_refusal.rs index 882064b29..597c6d950 100644 --- a/crates/pa-daemon/src/hold_refusal.rs +++ b/crates/pa-daemon/src/hold_refusal.rs @@ -396,6 +396,7 @@ mod tests { /// No third "open a different session" option: the user is already /// in the picker (operator-directed, 2026-09-24). + #[pa_test_scratch::pa_test] #[test] fn the_typescript_refusal_is_exact() { let hold = HoldIdentity { @@ -436,6 +437,7 @@ Session: ts01ab"; ); } + #[pa_test_scratch::pa_test] #[test] fn hostile_values_stay_paste_safe() { let hold = HoldIdentity { @@ -503,6 +505,7 @@ Session: ts01ab"; ); } + #[pa_test_scratch::pa_test] #[test] fn the_thisbuild_and_anonymous_refusals_stay_actionable() { let hold = HoldIdentity { @@ -538,6 +541,7 @@ Session: ts01ab"; ); } + #[pa_test_scratch::pa_test] #[test] fn the_footer_reads_the_session_name_and_the_path_fallback() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -584,6 +588,7 @@ Session: ts01ab"; ); } + #[pa_test_scratch::pa_test] #[test] fn corrupt_session_does_not_supply_a_partial_name() { let dir = tempfile::tempdir().unwrap(); @@ -604,6 +609,7 @@ Session: ts01ab"; /// The classification matrix. The rust shapes contain the /// `prime-agent` substring family, so their checks must win first. + #[pa_test_scratch::pa_test] #[test] fn the_holder_classification_matrix() { let own = Path::new("/Users/k/.local/share/prime-agent/prime-agent"); @@ -734,6 +740,7 @@ Session: ts01ab"; assert_eq!(classify_from(Some(dev), Some(dev)), HolderFlavor::ThisBuild); } + #[pa_test_scratch::pa_test] #[test] fn the_create_failure_response_splits_typed_and_untyped() { let hold = SessionAlreadyActiveError { diff --git a/crates/pa-daemon/src/image_route.rs b/crates/pa-daemon/src/image_route.rs index d85567f97..29787f7e0 100644 --- a/crates/pa-daemon/src/image_route.rs +++ b/crates/pa-daemon/src/image_route.rs @@ -374,6 +374,7 @@ mod tests { }] } + #[pa_test_scratch::pa_test] #[test] fn image_route_resolves_the_configured_image_model() { let dir = tempfile::TempDir::new().unwrap(); @@ -393,6 +394,7 @@ mod tests { assert!(none.is_none()); } + #[pa_test_scratch::pa_test] #[test] fn image_route_refusals_name_the_setting() { let dir = tempfile::TempDir::new().unwrap(); @@ -438,6 +440,7 @@ mod tests { /// The end-to-end routed episode: the settled assistant row tags the /// image model, and the settle restores the session target (TS: the /// next dispatch re-evaluates the routing). + #[pa_test_scratch::pa_test] #[test] fn image_turn_serves_on_the_image_model_and_restores() { let _faux = FAUX_TEST_LOCK @@ -523,6 +526,7 @@ mod tests { registration.unregister(); } + #[pa_test_scratch::pa_test] #[test] fn image_turn_without_image_model_fails_with_the_refusal() { let _faux = FAUX_TEST_LOCK diff --git a/crates/pa-daemon/src/journal.rs b/crates/pa-daemon/src/journal.rs index 4423c942e..78bd9c1a6 100644 --- a/crates/pa-daemon/src/journal.rs +++ b/crates/pa-daemon/src/journal.rs @@ -619,6 +619,7 @@ mod tests { dir.join(name) } + #[pa_test_scratch::pa_test] #[test] fn worker_journal_read_failures_are_not_empty_recovery_state() { let path = temp_path("unreadable.jsonl"); @@ -633,6 +634,7 @@ mod tests { fs::remove_dir_all(path.parent().unwrap()).unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn worker_journal_keeps_latest_per_session() { let path = temp_path("worker.recovery.jsonl"); @@ -651,6 +653,7 @@ mod tests { let _ = fs::remove_dir_all(path.parent().unwrap()); } + #[pa_test_scratch::pa_test] #[test] fn worker_journal_interrupted_evidence_tracks_latest_busy() { let path = temp_path("interrupted.recovery.jsonl"); @@ -671,6 +674,7 @@ mod tests { let _ = fs::remove_dir_all(path.parent().unwrap()); } + #[pa_test_scratch::pa_test] #[test] fn worker_journal_batched_checkpoint_matches_sequential_form() { let sequential_path = temp_path("sequential.recovery.jsonl"); @@ -749,6 +753,7 @@ mod tests { let _ = fs::remove_dir_all(batched_path.parent().unwrap()); } + #[pa_test_scratch::pa_test] #[test] fn worker_journal_batched_checkpoint_is_all_or_nothing() { let path = temp_path("allornothing.recovery.jsonl"); @@ -767,6 +772,7 @@ mod tests { /// TS parity oracle: TS compacts at every changed-idle record, and so /// does the port. + #[pa_test_scratch::pa_test] #[test] fn worker_journal_settle_compacts_single_session() { let path = temp_path("settle-compacts.recovery.jsonl"); @@ -808,6 +814,7 @@ mod tests { let _ = fs::remove_dir_all(path.parent().unwrap()); } + #[pa_test_scratch::pa_test] #[test] fn worker_journal_batched_settle_compacts_and_restores() { let path = temp_path("batched-settle.recovery.jsonl"); @@ -877,6 +884,7 @@ mod tests { /// An unchanged verdict appends the snapshot alone and never compacts /// (TS `record` early-returns before its compaction check). + #[pa_test_scratch::pa_test] #[test] fn worker_journal_unchanged_verdict_does_not_compact() { let path = temp_path("unchanged-nocompact.recovery.jsonl"); @@ -896,6 +904,7 @@ mod tests { let _ = fs::remove_dir_all(path.parent().unwrap()); } + #[pa_test_scratch::pa_test] #[test] fn worker_journal_missing_or_unreadable_file_is_not_interrupted() { let path = temp_path("missing.recovery.jsonl"); @@ -905,6 +914,7 @@ mod tests { let _ = fs::remove_dir_all(path.parent().unwrap()); } + #[pa_test_scratch::pa_test] #[test] fn worker_journal_open_skips_torn_utf8_tail() { let path = temp_path("torn-utf8-tail.recovery.jsonl"); @@ -964,6 +974,7 @@ mod tests { let _ = fs::remove_dir_all(path.parent().unwrap()); } + #[pa_test_scratch::pa_test] #[test] fn worker_journal_open_heals_torn_ascii_tail() { let path = temp_path("torn-ascii-tail.recovery.jsonl"); @@ -994,6 +1005,7 @@ mod tests { let _ = fs::remove_dir_all(path.parent().unwrap()); } + #[pa_test_scratch::pa_test] #[test] fn corrupt_complete_queue_bytes_are_preserved_before_recovery_fails() { for newline_terminated in [true, false] { @@ -1033,6 +1045,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn corrupt_complete_worker_identifiers_are_preserved_before_recovery_fails() { for newline_terminated in [true, false] { @@ -1062,6 +1075,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn a_complete_worker_record_without_newline_survives_healing() { let path = temp_path("complete-eof.recovery.jsonl"); @@ -1081,6 +1095,7 @@ mod tests { fs::remove_dir_all(path.parent().unwrap()).unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn competing_worker_writers_cannot_replace_an_active_append() { for contender in ["open", "settle"] { @@ -1128,6 +1143,7 @@ mod tests { } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] #[allow(clippy::used_underscore_binding)] // Intentionally duplicate the private lifetime guard to model an inherited descriptor. fn dropping_a_journal_releases_ownership_while_a_duplicate_handle_survives() { diff --git a/crates/pa-daemon/src/lease.rs b/crates/pa-daemon/src/lease.rs index f2705fd75..c9e81f625 100644 --- a/crates/pa-daemon/src/lease.rs +++ b/crates/pa-daemon/src/lease.rs @@ -246,6 +246,7 @@ mod tests { use std::sync::Arc; use std::time::Instant; + #[pa_test_scratch::pa_test] #[test] fn execution_lock_conflicts_until_last_owner_drops() { let dir = tempfile::tempdir().unwrap(); @@ -263,6 +264,7 @@ mod tests { assert_eq!(next.session_path, canonical_session_path(&path)); } + #[pa_test_scratch::pa_test] #[test] fn release_keeps_the_lock_inode_and_old_handle_cannot_unlock_successor() { let dir = tempfile::tempdir().unwrap(); @@ -296,6 +298,7 @@ mod tests { held_inode.try_lock().unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn courtesy_header_never_decides_ownership() { let dir = tempfile::tempdir().unwrap(); @@ -325,6 +328,7 @@ mod tests { acquire_runtime_session_lease(&path, dir.path()).unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn resident_execution_lock_does_not_hold_the_append_lock() { let dir = tempfile::tempdir().unwrap(); @@ -342,6 +346,7 @@ mod tests { // A real process holds the production lock until stdin closes. The parent // waits for an explicit ready line, not a timer or PID-based guess. + #[pa_test_scratch::pa_test] #[test] fn execution_lock_process_helper() { let Some(dir) = std::env::var_os("PA_EXECUTION_LOCK_TEST_DIR") else { @@ -355,6 +360,7 @@ mod tests { let _ = std::io::stdin().read(&mut byte).unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn process_exit_and_crash_release_execution_ownership_immediately() { for crash in [false, true] { diff --git a/crates/pa-daemon/src/mcp_login.rs b/crates/pa-daemon/src/mcp_login.rs index b3fa6cc05..c6a286815 100644 --- a/crates/pa-daemon/src/mcp_login.rs +++ b/crates/pa-daemon/src/mcp_login.rs @@ -212,6 +212,7 @@ mod tests { /// The fixture OAuth server's responses answer through the scripted /// transport; the real callback listener catches the redirect. #[tokio::test] + #[pa_test_scratch::pa_test] async fn worker_begin_login_persists_creds_and_unlocks_gating() -> Result<()> { use tokio::io::{AsyncReadExt, AsyncWriteExt}; let agent = tempfile::tempdir()?; @@ -376,6 +377,7 @@ mod tests { /// An unknown server fails with the TS wording; the handler stays /// registered so the kernel surfaces the error to the model. #[tokio::test] + #[pa_test_scratch::pa_test] async fn worker_begin_login_rejects_unknown_servers() -> Result<()> { let agent = tempfile::tempdir()?; let http = Arc::new(ScriptedHttp::fixture()); @@ -411,6 +413,7 @@ mod tests { /// The UI contract for the worker: no manual paste channel, and the /// fallback prompt refuses (the callback is the only completion path). #[tokio::test] + #[pa_test_scratch::pa_test] async fn worker_ui_has_no_paste_surface() { let ui = WorkerMcpLoginUi::with_auth_url_file(None); assert!(ui.on_manual_code_input().is_none()); @@ -424,6 +427,7 @@ mod tests { /// `AuthCredential::Oauth` still serializes the binding fields the /// persisted fixture credential shows above (shape regression fence). + #[pa_test_scratch::pa_test] #[test] fn oauth_credential_serializes_ts_binding_fields() { let credential = AuthCredential::Oauth { diff --git a/crates/pa-daemon/src/messaging.rs b/crates/pa-daemon/src/messaging.rs index 336d895a2..5f664439f 100644 --- a/crates/pa-daemon/src/messaging.rs +++ b/crates/pa-daemon/src/messaging.rs @@ -486,6 +486,7 @@ mod tests { DaemonWorkerDescriptor, DaemonWorkerLifecycle, DurableDaemonCreateCommand, }; + #[pa_test_scratch::pa_test] #[test] fn sender_endpoint_carries_the_durable_parent_edge() { let sender = sender_endpoint_from_summary( @@ -580,6 +581,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn unknown_target_answers_with_the_ts_error() { let supervisor = supervisor(); let response = supervisor @@ -595,6 +597,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn unknown_source_fails_like_the_ts_source_lookup() { let supervisor = supervisor(); supervisor.registry.insert(resident("target-1")).await; @@ -609,6 +612,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn self_target_is_refused() { let supervisor = supervisor(); supervisor.registry.insert(resident("solo-1")).await; @@ -623,6 +627,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn ambiguous_saved_selector_carries_the_catalog_error() { let supervisor = supervisor(); let sessions = crate::paths::sessions_dir(&supervisor.options.agent_dir).unwrap(); @@ -643,6 +648,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn ledger_edges_match_by_name_child_id_and_session_id() { let edge = crate::rlm_ledger::RlmLedgerEdge { @@ -662,6 +668,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn delivery_routes_worker_deliver_message_to_the_target() { let supervisor = supervisor(); supervisor.registry.insert(resident("target-1")).await; diff --git a/crates/pa-daemon/src/model_allowlist.rs b/crates/pa-daemon/src/model_allowlist.rs index d00e36e28..4a5750fdf 100644 --- a/crates/pa-daemon/src/model_allowlist.rs +++ b/crates/pa-daemon/src/model_allowlist.rs @@ -92,6 +92,7 @@ mod tests { std::fs::write(dir.join("settings.json"), value).unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn load_reads_the_global_scope_only() { let dir = tempfile::tempdir().expect("tempdir"); @@ -117,6 +118,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn load_trims_and_drops_empty_lists() { let dir = tempfile::tempdir().expect("tempdir"); @@ -136,6 +138,7 @@ mod tests { )); } + #[pa_test_scratch::pa_test] #[test] fn assert_allowed_passes_without_an_allowlist_and_types_the_refusal() { assert_allowed(&DaemonAllowlist::Unrestricted, "anything/model").unwrap(); @@ -148,6 +151,7 @@ mod tests { assert_eq!(refusal.selector, "zai/glm-5.3"); } + #[pa_test_scratch::pa_test] #[test] fn an_unreadable_settings_document_fails_closed() { let dir = tempfile::tempdir().expect("tempdir"); @@ -169,6 +173,7 @@ mod tests { assert!(matches!(state, DaemonAllowlist::Unrestricted)); } + #[pa_test_scratch::pa_test] #[test] fn a_malformed_allowed_models_value_fails_closed() { let dir = tempfile::tempdir().expect("tempdir"); @@ -210,6 +215,7 @@ mod tests { /// A NON-OBJECT global document (`[]`, `"bad"`) is a corrupted /// document, not an absent key: the guard fails closed. + #[pa_test_scratch::pa_test] #[test] fn a_non_object_global_document_fails_closed() { let dir = tempfile::tempdir().expect("tempdir"); diff --git a/crates/pa-daemon/src/model_catalog.rs b/crates/pa-daemon/src/model_catalog.rs index 836b173f0..cffbc1b22 100644 --- a/crates/pa-daemon/src/model_catalog.rs +++ b/crates/pa-daemon/src/model_catalog.rs @@ -652,6 +652,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn picker_open_returns_instantly_and_the_auth_change_refresh_lands() { let mut fixture = fixture(create_phase_answers()).await; // A login switched the account between the create path's warm-up @@ -737,6 +738,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn concurrent_opens_coalesce_into_one_refresh() { let mut fixture = fixture(create_phase_answers()).await; write_auth_json(&fixture.agent_dir, "sk-account-b", "team-b"); @@ -814,6 +816,7 @@ mod tests { /// Repeat picker opens inside the hourly window stay gated: no new /// fetches, no event, so event -> re-fetch -> refresh terminates. #[tokio::test] + #[pa_test_scratch::pa_test] async fn repeat_opens_inside_the_gate_add_no_fetches_and_stay_silent() { let mut fixture = fixture(create_phase_answers()).await; let requests_before = fixture.server.request_count(); @@ -845,6 +848,7 @@ mod tests { /// model, a thinking session sends no `reasoning_effort`, and a route /// that only thinks when asked emits no thinking at all. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_private_route_with_declared_reasoning_serves_addressable_levels() { let answers = vec![ Answer::Raw(ok_json(&catalog_aggregate(&["probe-v1"]))), @@ -882,6 +886,7 @@ mod tests { /// success would wipe the authorized private models and rewrite the /// fingerprint cache with an empty set and a fresh TTL. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_malformed_entitlement_payload_keeps_the_authorized_private_models() { let fixture = fixture(create_phase_answers()).await; // Age the on-disk authorization past its TTL so the next refresh @@ -949,6 +954,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn refresh_failure_keeps_the_last_good_catalog_and_stays_silent() { let mut fixture = fixture(create_phase_answers()).await; write_auth_json(&fixture.agent_dir, "sk-account-c", "team-c"); diff --git a/crates/pa-daemon/src/model_refresh_worker.rs b/crates/pa-daemon/src/model_refresh_worker.rs index 006b4264e..a573f3f2c 100644 --- a/crates/pa-daemon/src/model_refresh_worker.rs +++ b/crates/pa-daemon/src/model_refresh_worker.rs @@ -99,6 +99,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn worker_refresh_reports_are_direct_and_empty_sources_do_not_fetch() { let dir = tempfile::TempDir::new().unwrap(); let worker = worker(dir.path()); @@ -114,6 +115,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn worker_apply_snapshots_is_allowed_while_busy_and_keeps_current_turn() { let dir = tempfile::TempDir::new().unwrap(); let worker = worker(dir.path()); @@ -129,6 +131,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn refresh_commands_reject_invalid_payloads_without_changing_turn() { let dir = tempfile::TempDir::new().unwrap(); let worker = worker(dir.path()); diff --git a/crates/pa-daemon/src/model_switch.rs b/crates/pa-daemon/src/model_switch.rs index 81fe462e5..23b4672ae 100644 --- a/crates/pa-daemon/src/model_switch.rs +++ b/crates/pa-daemon/src/model_switch.rs @@ -314,6 +314,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn set_model_refuses_models_outside_the_allowlist() { async fn dispatch_set_model( worker: &std::sync::Arc, @@ -380,6 +381,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn set_model_refuses_an_unsigned_in_provider_with_the_typed_sign_in_error() { let dir = std::env::temp_dir().join(format!("pa-worker-si-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -436,6 +438,7 @@ mod tests { assert_eq!(response.error_info, None); } + #[pa_test_scratch::pa_test] #[test] fn thinking_levels_wire_names_match_the_enum() { // Every wire name must parse; the list is the exact TS @@ -449,6 +452,7 @@ mod tests { assert!(pa_ai::models::thinking_level_from_str("sideways").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn resolution_classifies_the_sign_in_refusal() { let dir = tempfile::tempdir().expect("tempdir"); @@ -489,6 +493,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn an_unauthorized_private_model_keeps_the_ts_refusal() { let dir = tempfile::tempdir().expect("tempdir"); @@ -509,6 +514,7 @@ mod tests { /// A stale-auth provider keeps the switch (the TS daemon's /// full-catalog fallback; the lookup never mutates stale state). + #[pa_test_scratch::pa_test] #[test] fn stale_auth_keeps_the_set_model_switch() { let dir = tempfile::tempdir().expect("tempdir"); @@ -546,6 +552,7 @@ mod tests { (model.provider.clone(), model.id.clone()) } + #[pa_test_scratch::pa_test] #[test] fn resolution_errors_carry_the_ts_message() { let dir = tempfile::tempdir().expect("tempdir"); diff --git a/crates/pa-daemon/src/overflow_compaction.rs b/crates/pa-daemon/src/overflow_compaction.rs index 948e47c05..257ecb022 100644 --- a/crates/pa-daemon/src/overflow_compaction.rs +++ b/crates/pa-daemon/src/overflow_compaction.rs @@ -519,6 +519,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn overflow_compacts_retries_once_then_reports_the_failure() { let _faux = FAUX_TEST_LOCK @@ -609,6 +610,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn overflow_retry_succeeds_on_the_compacted_context() { let _faux = FAUX_TEST_LOCK @@ -653,6 +655,7 @@ mod tests { assert_eq!(user_messages(&probe_events).len(), 1); } + #[pa_test_scratch::pa_test] #[test] fn combined_limit_overflow_compacts_and_retries() { let _faux = FAUX_TEST_LOCK @@ -697,6 +700,7 @@ mod tests { assert!(outcome_rows(&probe_events).is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn overflow_recovery_skip_surfaces_the_warning_row() { let _faux = FAUX_TEST_LOCK @@ -741,6 +745,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn stale_overflow_error_recovers_before_the_next_prompt() { let _faux = FAUX_TEST_LOCK @@ -809,6 +814,7 @@ mod tests { assert_eq!(user_messages(&next_events).len(), 1); } + #[pa_test_scratch::pa_test] #[test] fn non_overflow_error_never_triggers_the_arm() { let _faux = FAUX_TEST_LOCK @@ -833,6 +839,7 @@ mod tests { assert!(matches!(done_result(&error_events), Some(Err(_)))); } + #[pa_test_scratch::pa_test] #[test] fn overflow_recovery_aborted_mid_run_records_the_cancelled_outcome() { let _faux = FAUX_TEST_LOCK @@ -903,6 +910,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn overflow_error_with_compaction_disabled_ends_without_recovery() { let _faux = FAUX_TEST_LOCK diff --git a/crates/pa-daemon/src/ownership.rs b/crates/pa-daemon/src/ownership.rs index 6432c70bf..02f35bf1c 100644 --- a/crates/pa-daemon/src/ownership.rs +++ b/crates/pa-daemon/src/ownership.rs @@ -338,6 +338,7 @@ mod tests { /// the identity and the scan serves again — on the reconciled /// identity only. #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_owned_session_scan_refuses_a_quarantined_identity() { let dir = std::env::temp_dir().join(format!("pa-own-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); diff --git a/crates/pa-daemon/src/paths.rs b/crates/pa-daemon/src/paths.rs index d39708192..6db59ecce 100644 --- a/crates/pa-daemon/src/paths.rs +++ b/crates/pa-daemon/src/paths.rs @@ -169,6 +169,7 @@ pub fn mtime_age(path: &Path) -> Option { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn log_path_hashes_socket() { let path = daemon_log_path( diff --git a/crates/pa-daemon/src/peer.rs b/crates/pa-daemon/src/peer.rs index 2377805bb..c6601732b 100644 --- a/crates/pa-daemon/src/peer.rs +++ b/crates/pa-daemon/src/peer.rs @@ -398,6 +398,7 @@ mod tests { const NOW: u64 = 1_000_000; + #[pa_test_scratch::pa_test] #[test] fn grant_issue_burn_single_use() { let store = PeerGrantStore::new(); @@ -413,6 +414,7 @@ mod tests { assert_eq!(replay.unwrap_err(), PEER_AUTH_FAILED); } + #[pa_test_scratch::pa_test] #[test] fn grant_burns_even_on_wrong_token() { let store = PeerGrantStore::new(); @@ -435,6 +437,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn grant_expires() { let store = PeerGrantStore::new(); @@ -451,6 +454,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn grant_registration_rejects_bad_shape() { let store = PeerGrantStore::new(); @@ -507,6 +511,7 @@ mod tests { .expect("register"); } + #[pa_test_scratch::pa_test] #[test] fn grant_cap_sweeps_expired() { let store = PeerGrantStore::new(); @@ -545,6 +550,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn peer_gate_requires_session_plane_and_matching_session() { let grant = grant(&soon(NOW, 10_000)); @@ -575,6 +581,7 @@ mod tests { )); } + #[pa_test_scratch::pa_test] #[test] fn worker_purpose_grants_burn_and_gate_to_delivery() { let store = PeerGrantStore::new(); @@ -621,6 +628,7 @@ mod tests { assert!(!role.streams_events()); } + #[pa_test_scratch::pa_test] #[test] fn peer_session_attach_gates_event_stream() { let role = ConnectionRole::SessionClient { diff --git a/crates/pa-daemon/src/peer_tickets.rs b/crates/pa-daemon/src/peer_tickets.rs index ae2b7c4bc..fcb36c584 100644 --- a/crates/pa-daemon/src/peer_tickets.rs +++ b/crates/pa-daemon/src/peer_tickets.rs @@ -270,6 +270,7 @@ fn mint_grant( mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn minted_grants_expire_in_ten_seconds_and_are_unique() { let first = mint_grant("inst-1", "abc123", PeerGrantPurpose::SessionClient); @@ -300,6 +301,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn worker_peer_ticket_auth_and_self_target() { use crate::registry::ResidentWorker; use pa_types::daemon::{ @@ -392,6 +394,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn worker_states_match_ts_names() { use DaemonWorkerLifecycle as L; diff --git a/crates/pa-daemon/src/platform/paths.rs b/crates/pa-daemon/src/platform/paths.rs index c53c9c608..8cd591c34 100644 --- a/crates/pa-daemon/src/platform/paths.rs +++ b/crates/pa-daemon/src/platform/paths.rs @@ -93,6 +93,7 @@ mod tests { use super::*; #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn default_endpoints_are_separate_from_typescript_for_the_real_uid() { let uid = pa_core::platform::process::current_user_id(); @@ -118,6 +119,7 @@ mod tests { } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn generated_endpoints_fit_even_when_tmpdir_is_deep() { use std::os::unix::net::SocketAddr; @@ -146,6 +148,7 @@ mod tests { /// a client that connects by the descriptor's path string cannot address a deep socket, /// so a deep `TMPDIR` loses to a connectable directory on every Unix. #[cfg(target_os = "linux")] + #[pa_test_scratch::pa_test] #[test] fn deep_tmpdir_yields_to_a_connectable_directory() { use std::os::unix::net::SocketAddr; @@ -166,6 +169,7 @@ mod tests { } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn deep_tmpdirs_get_distinct_socket_directories() { let first = PathBuf::from(format!("/{}", "a".repeat(120))); @@ -174,6 +178,7 @@ mod tests { } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn short_tmpdir_keeps_the_rust_socket_directory() { assert_eq!( @@ -182,6 +187,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn worker_socket_names_are_deterministic_and_supervisor_scoped() { let supervisor = Path::new("/fixture/first/daemon.sock"); @@ -196,6 +202,7 @@ mod tests { assert!(a.starts_with(socket_dir())); } + #[pa_test_scratch::pa_test] #[test] #[cfg(windows)] fn windows_default_endpoints_are_separate_from_typescript() { diff --git a/crates/pa-daemon/src/plugin_commands.rs b/crates/pa-daemon/src/plugin_commands.rs index 7664730cc..4510419cf 100644 --- a/crates/pa-daemon/src/plugin_commands.rs +++ b/crates/pa-daemon/src/plugin_commands.rs @@ -400,6 +400,7 @@ return { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn worker_discovery_and_invocation_share_the_real_lua_generation() { let fixture = Fixture::new().await; let catalog = fixture.catalog().await; @@ -441,6 +442,7 @@ return { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn reload_retires_targets_and_disable_removes_inventory_without_history() { let fixture = Fixture::new().await; let old = fixture @@ -513,6 +515,7 @@ return { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn worker_rejects_busy_streaming_and_unknown_without_model_fallback() { let fixture = Fixture::new().await; let before = fixture.rows(); @@ -544,6 +547,7 @@ return { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn deferred_job_publication_fences_sessions_and_surfaces_persistence_errors() { let fixture = Fixture::new().await; let session = fixture @@ -610,6 +614,7 @@ return { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn deferred_job_success_and_failure_reach_custom_message_transport_once() { for mode in ["generic", "failed", "projected", "malformed"] { let fixture = Fixture::new().await; @@ -734,6 +739,7 @@ end}}} } #[tokio::test] + #[pa_test_scratch::pa_test] async fn failed_reload_keeps_the_last_good_inventory_and_manager_reports_diagnostic() { let fixture = Fixture::new().await; let before = fixture.catalog().await; diff --git a/crates/pa-daemon/src/prompt_admission.rs b/crates/pa-daemon/src/prompt_admission.rs index 2cfd7909a..725c9613d 100644 --- a/crates/pa-daemon/src/prompt_admission.rs +++ b/crates/pa-daemon/src/prompt_admission.rs @@ -618,6 +618,7 @@ impl Worker { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn rekey_moves_a_live_admission_under_the_new_session_id() { let table = PromptAdmissionTable::default(); @@ -634,6 +635,7 @@ mod tests { assert!(table.with(&old_key, |_| ()).is_none()); } + #[pa_test_scratch::pa_test] #[test] fn rekey_never_overwrites_an_occupied_destination() { let table = PromptAdmissionTable::default(); @@ -646,6 +648,7 @@ mod tests { assert!(table.with(&to, |_| ()).is_some()); } + #[pa_test_scratch::pa_test] #[test] fn sole_admission_id_match_resolves_but_ambiguity_stays_unknown() { let table = PromptAdmissionTable::default(); @@ -659,6 +662,7 @@ mod tests { assert_eq!(table.sole_key_for_admission_id(""), None); } + #[pa_test_scratch::pa_test] #[test] fn a_nul_in_either_key_half_is_refused_at_registration() { let table = PromptAdmissionTable::default(); diff --git a/crates/pa-daemon/src/protocol.rs b/crates/pa-daemon/src/protocol.rs index e3b6662e0..b3ca94507 100644 --- a/crates/pa-daemon/src/protocol.rs +++ b/crates/pa-daemon/src/protocol.rs @@ -1058,6 +1058,7 @@ mod tests { use super::*; use serde_json::json; + #[pa_test_scratch::pa_test] #[test] fn kernel_bash_activity_commands_are_session_scoped() { for (command, kind) in [ @@ -1083,6 +1084,7 @@ mod tests { assert!(default_server_capabilities().contains(&"kernel_bash_activity".to_string())); } + #[pa_test_scratch::pa_test] #[test] fn envelope_round_trips() { let line = r#"{"type":"command","id":"c1","protocol":{"name":"prime-agent.daemon","version":7},"command":{"type":"list","all":true}}"#; @@ -1091,6 +1093,7 @@ mod tests { assert!(matches!(envelope.command, DaemonCommand::List { .. })); } + #[pa_test_scratch::pa_test] #[test] fn supervisor_parser_preserves_envelope_and_bare_error_shapes() { let cases = [ @@ -1133,6 +1136,7 @@ mod tests { assert_eq!(serde_json::to_value(parsed.command).unwrap(), command); } + #[pa_test_scratch::pa_test] #[test] fn unknown_command_is_preserved() { let line = r#"{"type":"command","id":"c2","protocol":{"name":"prime-agent.daemon","version":7},"command":{"type":"bogus_command","activeSessionId":"x"}}"#; @@ -1140,6 +1144,7 @@ mod tests { assert_eq!(err.to_string(), "Unknown daemon command: bogus_command"); } + #[pa_test_scratch::pa_test] #[test] fn old_protocol_is_rejected() { let line = r#"{"type":"command","id":"c3","protocol":{"name":"prime-agent.daemon","version":6},"command":{"type":"list"}}"#; @@ -1147,6 +1152,7 @@ mod tests { assert!(err.to_string().contains("protocol 7 or newer")); } + #[pa_test_scratch::pa_test] #[test] fn replay_info_matches_ts() { let info = create_daemon_replay_info(None, 5, "legacy"); @@ -1180,6 +1186,7 @@ mod tests { /// The preparing-restart refusal keeps the TS plain message for old /// clients and carries the typed `update_restarting` info. + #[pa_test_scratch::pa_test] #[test] fn update_preparing_refusal_carries_the_typed_error_info() { let failure = response_failure( @@ -1194,6 +1201,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn response_line_serializes_in_the_ts_key_order() { let success = response_success(Some("k1"), "compact", Some(json!({"x": 1}))); @@ -1208,6 +1216,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn response_line_bytes_matches_the_reference_tree_path() { let shapes: Vec = vec![ diff --git a/crates/pa-daemon/src/queue_commands.rs b/crates/pa-daemon/src/queue_commands.rs index 2f731c11f..3650dd57a 100644 --- a/crates/pa-daemon/src/queue_commands.rs +++ b/crates/pa-daemon/src/queue_commands.rs @@ -273,6 +273,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_labeled_preview_row_is_addressed_and_edited_by_its_preview() { let worker = created_worker().await; { @@ -327,6 +328,7 @@ mod tests { /// replace so an edit can never report `applied` while the turn /// still delivers the old injected content; delete still applies. #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_injected_heartbeat_row_rejects_replace_but_deletes() { let worker = created_worker().await; { @@ -394,6 +396,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn mutate_delete_moves_and_replaces_match_ts_status_wire() { let worker = created_worker().await; worker @@ -520,6 +523,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn resume_queue_matches_the_ts_wire_shapes() { let worker = created_worker().await; let response = worker.dispatch("resume_queue", &json!({})).await; @@ -540,6 +544,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn delete_rejects_the_waiting_caller() { let worker = created_worker().await; let (done_tx, done_rx) = tokio::sync::oneshot::channel(); @@ -585,6 +590,7 @@ mod tests { /// A `replace` on an accepted agent-message delivery is rejected: its content must stay /// byte-identical to the prompt the turn runs on. Move and delete stay applicable. #[tokio::test] + #[pa_test_scratch::pa_test] async fn replace_rejects_a_queued_agent_message_delivery() { let worker = created_worker().await; let delivered = worker @@ -680,6 +686,7 @@ mod tests { /// A cross-lane replace is an arrival in the target lane: the edited user /// item lands after earlier user items and before parked agent messages. #[tokio::test] + #[pa_test_scratch::pa_test] async fn cross_lane_replace_lands_before_parked_agent_messages() { for (source, target, source_command, target_command, delivery_mode) in [ ("followUp", "steering", "follow_up", "steer", "steer"), diff --git a/crates/pa-daemon/src/recovery_pacing.rs b/crates/pa-daemon/src/recovery_pacing.rs index 28f6939ee..2dc6b0537 100644 --- a/crates/pa-daemon/src/recovery_pacing.rs +++ b/crates/pa-daemon/src/recovery_pacing.rs @@ -43,6 +43,7 @@ mod tests { use std::sync::atomic::{AtomicUsize, Ordering}; #[tokio::test] + #[pa_test_scratch::pa_test] async fn bounded_fanout_caps_concurrency_and_runs_every_job() { let in_flight = std::sync::Arc::new(AtomicUsize::new(0)); let max_seen = std::sync::Arc::new(AtomicUsize::new(0)); @@ -70,6 +71,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn bounded_fanout_survives_a_panic_in_one_job() { let ran = std::sync::Arc::new(AtomicUsize::new(0)); let jobs: Vec<_> = (0..4) diff --git a/crates/pa-daemon/src/registration.rs b/crates/pa-daemon/src/registration.rs index 1dceec155..20a25b4ec 100644 --- a/crates/pa-daemon/src/registration.rs +++ b/crates/pa-daemon/src/registration.rs @@ -322,6 +322,7 @@ mod tests { /// Only the supervisor's unknown-worker verdict is definitive: the /// transient failures stay retryable, and the loop's own /// "registration rejected" wrap still exposes the verdict inside it. + #[pa_test_scratch::pa_test] #[test] fn only_the_unknown_worker_verdict_is_definitive() { assert!(is_definitive_rejection( @@ -391,6 +392,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn worker_registers_then_re_registers_with_same_identity() { let dir = tempfile::TempDir::new().expect("temp dir"); let supervisor_socket = dir.path().join("supervisor.sock"); @@ -469,6 +471,7 @@ mod tests { /// A definitive rejection on the HELD connection retires too: the /// in-place `SessionCreated` re-registration can carry the unknown-worker verdict. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_definitive_rejection_on_the_held_connection_retires() { let dir = tempfile::TempDir::new().expect("temp dir"); let supervisor_socket = dir.path().join("supervisor.sock"); @@ -522,6 +525,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_tombstoned_registration_refusal_retires_the_worker() { let dir = tempfile::TempDir::new().expect("temp dir"); let supervisor_socket = dir.path().join("supervisor.sock"); @@ -585,6 +589,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_definitive_rejection_retires_and_a_transient_one_retries() { let dir = tempfile::TempDir::new().expect("temp dir"); let supervisor_socket = dir.path().join("supervisor.sock"); diff --git a/crates/pa-daemon/src/registry.rs b/crates/pa-daemon/src/registry.rs index 55410e453..4129b8163 100644 --- a/crates/pa-daemon/src/registry.rs +++ b/crates/pa-daemon/src/registry.rs @@ -808,6 +808,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn registrations_bump_epoch_and_records_survive_removal() { let registry = SessionRegistry::new(); let worker = resident("abc123def456"); @@ -825,6 +826,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn resolve_by_suffix_and_name() { let registry = SessionRegistry::new(); let named = resident("aaa111bbb222"); @@ -845,6 +847,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn forget_drops_registration_and_adoption_gate() { let registry = SessionRegistry::new(); registry.insert(resident("abc123def456")).await; @@ -865,6 +868,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn adoption_guard_serializes_same_worker() { let registry = Arc::new(SessionRegistry::new()); let first = { @@ -885,6 +889,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_older_catalog_read_never_poisons_the_stored_snapshot() { use serde_json::json; @@ -941,6 +946,7 @@ mod tests { ) } + #[pa_test_scratch::pa_test] #[test] fn owned_reap_binding_rejects_mismatched_or_uncertain_identity() { let (record, _sender) = owned_reap_record(7, Some("generation"), Some(true)); @@ -979,6 +985,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn owned_reap_rejects_stale_completed_record_and_descriptor_successors() { let budget = std::time::Duration::from_millis(20); let (resident, record, _sender) = reap_fixture(Some(true)).await; @@ -998,6 +1005,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn owned_reap_error_closed_channel_and_timeout_fail_closed() { let budget = std::time::Duration::from_millis(20); let (resident, record, _sender) = reap_fixture(Some(false)).await; @@ -1018,6 +1026,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn owned_reap_revalidates_descriptor_after_completion_without_holding_locks() { let (resident, record, sender) = reap_fixture(None).await; let waiting_resident = Arc::clone(&resident); @@ -1044,6 +1053,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn owned_reap_revalidates_token_after_completion() { let (resident, record, sender) = reap_fixture(None).await; let waiting_resident = Arc::clone(&resident); @@ -1070,6 +1080,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn adopted_reap_capture_rejects_later_owned_or_descriptor_generation() { let resident = resident("adopted-reap"); { diff --git a/crates/pa-daemon/src/revival_gate.rs b/crates/pa-daemon/src/revival_gate.rs index 4bf8f82d5..05e267641 100644 --- a/crates/pa-daemon/src/revival_gate.rs +++ b/crates/pa-daemon/src/revival_gate.rs @@ -165,6 +165,7 @@ mod tests { dir } + #[pa_test_scratch::pa_test] #[test] fn fresh_busy_evidence_passes_the_gate() { let file = session_file(Some("active")); @@ -179,6 +180,7 @@ mod tests { .is_none()); } + #[pa_test_scratch::pa_test] #[test] fn stale_busy_evidence_vetoes_the_revival() { let file = session_file(Some("active")); @@ -195,6 +197,7 @@ mod tests { assert!(matches!(veto, RevivalVeto::StaleBusyEvidence { .. })); } + #[pa_test_scratch::pa_test] #[test] fn an_unparsable_evidence_timestamp_vetoes_the_revival() { let file = session_file(Some("active")); @@ -204,6 +207,7 @@ mod tests { assert!(matches!(veto, RevivalVeto::StaleBusyEvidence { .. })); } + #[pa_test_scratch::pa_test] #[test] fn a_future_dated_evidence_timestamp_vetoes_the_revival() { let file = session_file(Some("active")); @@ -221,6 +225,7 @@ mod tests { assert!(matches!(veto, RevivalVeto::StaleBusyEvidence { .. })); } + #[pa_test_scratch::pa_test] #[test] fn evidence_within_the_clock_skew_bound_still_passes() { let file = session_file(Some("active")); @@ -240,6 +245,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_kept_update_row_skips_the_freshness_bound() { let file = session_file(Some("active")); @@ -250,6 +256,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn the_give_up_verdict_vetoes_even_fresh_busy_evidence() { let file = session_file(Some("active")); @@ -262,6 +269,7 @@ mod tests { assert!(matches!(veto, RevivalVeto::GaveUp)); } + #[pa_test_scratch::pa_test] #[test] fn the_archived_belt_vetoes_even_fresh_busy_evidence() { // The zombie shape: a stopped session whose journal still holds a busy record. @@ -278,6 +286,7 @@ mod tests { assert!(matches!(veto, RevivalVeto::SessionArchived)); } + #[pa_test_scratch::pa_test] #[test] fn the_archived_belt_vetoes_a_kept_update_row() { // A stop that landed during the update window is durable intent: @@ -289,6 +298,7 @@ mod tests { assert!(matches!(veto, RevivalVeto::SessionArchived)); } + #[pa_test_scratch::pa_test] #[test] fn a_live_foreign_lease_vetoes_the_revival() { let file = session_file(Some("active")); @@ -308,6 +318,7 @@ mod tests { assert!(matches!(veto, RevivalVeto::LiveLeaseHeld { .. })); } + #[pa_test_scratch::pa_test] #[test] fn a_released_lease_does_not_veto() { let file = session_file(Some("active")); diff --git a/crates/pa-daemon/src/rlm_child_model.rs b/crates/pa-daemon/src/rlm_child_model.rs index fe4b22e9d..ddb4feb39 100644 --- a/crates/pa-daemon/src/rlm_child_model.rs +++ b/crates/pa-daemon/src/rlm_child_model.rs @@ -241,6 +241,7 @@ mod tests { .unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn resolves_parent_exact_and_short_form_references() { let dir = tempfile::TempDir::new().unwrap(); @@ -296,6 +297,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn the_allowlist_refuses_resolved_models_loudly() { let dir = tempfile::TempDir::new().unwrap(); @@ -357,6 +359,7 @@ mod tests { assert_eq!(resolved, "test-provider/glm-5.3"); } + #[pa_test_scratch::pa_test] #[test] fn unmatched_references_carry_the_ts_error_with_close_matches() { let dir = tempfile::TempDir::new().unwrap(); @@ -395,6 +398,7 @@ mod tests { assert!(!error.to_string().contains("close matches:"), "{error}"); } + #[pa_test_scratch::pa_test] #[test] fn thinking_support_follows_the_resolved_model() { let dir = tempfile::TempDir::new().unwrap(); @@ -414,6 +418,7 @@ mod tests { /// The child-propagation regression: a spawned child resolves an /// entitled private `internal/*` model through the worker's same disk caches. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_spawned_child_resolves_an_entitled_private_model() { use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -520,6 +525,7 @@ mod tests { /// The catalog-repo child-resolution regression: a fetched entry the compiled fallback lacks /// resolves through the on-disk provider catalog, once its provider is auth-configured. + #[pa_test_scratch::pa_test] #[test] fn a_spawned_child_resolves_a_catalog_repo_entry_the_compiled_fallback_lacks() { const PROBE_ID: &str = "gpt-6-probe"; @@ -609,6 +615,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn roster_text_is_collapsed_and_capped() { let label = rlm_child_label(" ship the\nlane "); @@ -625,6 +632,7 @@ mod tests { assert!(preview.ends_with("...")); } + #[pa_test_scratch::pa_test] #[test] fn the_binding_lane_keeps_far_more_than_the_preview_cap() { // The collect envelope's full-answer lane: a fenced JSON output diff --git a/crates/pa-daemon/src/rlm_child_usage.rs b/crates/pa-daemon/src/rlm_child_usage.rs index d4d235553..cb632b438 100644 --- a/crates/pa-daemon/src/rlm_child_usage.rs +++ b/crates/pa-daemon/src/rlm_child_usage.rs @@ -167,6 +167,7 @@ mod tests { /// a later user row is a direct user prompt, and an aborted /// completion folds nowhere. The captured numbers verify the /// `spawn_task` batch: 50,208 input + 2,929 output, $0.0089957. + #[pa_test_scratch::pa_test] #[test] fn origin_walk_and_cursor_over_a_child_file() { let entries = vec![ @@ -230,6 +231,7 @@ mod tests { /// The usage fold itself: rows accumulate per origin across the walk /// (two `spawn_task` completions sum their fields). + #[pa_test_scratch::pa_test] #[test] fn batches_sum_across_completions_of_one_origin() { let entries = vec![ diff --git a/crates/pa-daemon/src/rlm_children/host.rs b/crates/pa-daemon/src/rlm_children/host.rs index 966a396f5..d46df4765 100644 --- a/crates/pa-daemon/src/rlm_children/host.rs +++ b/crates/pa-daemon/src/rlm_children/host.rs @@ -713,6 +713,7 @@ mod kickoff_tests { } } + #[pa_test_scratch::pa_test] #[test] fn kickoff_presence_requires_valid_durable_envelopes() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/rlm_children/lifecycle.rs b/crates/pa-daemon/src/rlm_children/lifecycle.rs index a8a11b8cd..37243b687 100644 --- a/crates/pa-daemon/src/rlm_children/lifecycle.rs +++ b/crates/pa-daemon/src/rlm_children/lifecycle.rs @@ -892,6 +892,7 @@ mod exit_capture_tests { /// The exit capture reads the child's last say from its durable file /// after the worker is gone: the newest non-empty assistant text wins. + #[pa_test_scratch::pa_test] #[test] fn the_exit_capture_reader_takes_the_last_assistant_row() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/rlm_children/spawn_name_reservation_tests.rs b/crates/pa-daemon/src/rlm_children/spawn_name_reservation_tests.rs index d6d2db999..4da174e3d 100644 --- a/crates/pa-daemon/src/rlm_children/spawn_name_reservation_tests.rs +++ b/crates/pa-daemon/src/rlm_children/spawn_name_reservation_tests.rs @@ -159,6 +159,7 @@ fn spawn_request(name: &str, prompt: &str) -> RlmSpawnRequest { /// The reservation lifecycle: the name is held across the parked admission — a racing same-name /// spawn fails closed — and freed at the settle, after which the live registry owns the name. #[tokio::test] +#[pa_test_scratch::pa_test] async fn holds_a_spawn_name_reservation_until_admission_settles_then_frees_it() { let (create_seen_tx, mut create_seen_rx) = mpsc::unbounded_channel(); let (verdict_tx, verdict_rx) = mpsc::unbounded_channel(); @@ -202,6 +203,7 @@ async fn holds_a_spawn_name_reservation_until_admission_settles_then_frees_it() /// A cancelled admission frees the reserved name: the boxed /// `RlmHostFuture` is cancellable, so the reservation must release with it. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_cancelled_spawn_admission_frees_the_reserved_name() { let (create_seen_tx, mut create_seen_rx) = mpsc::unbounded_channel(); let (verdict_tx, verdict_rx) = mpsc::unbounded_channel(); @@ -239,6 +241,7 @@ async fn a_cancelled_spawn_admission_frees_the_reserved_name() { /// The failure path: a failed admission (the create errors after the /// reservation was held) frees the name, so the same name spawns again. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_failed_admission_frees_the_reserved_name() { let (create_seen_tx, mut create_seen_rx) = mpsc::unbounded_channel(); let (verdict_tx, verdict_rx) = mpsc::unbounded_channel(); @@ -273,6 +276,7 @@ async fn a_failed_admission_frees_the_reserved_name() { /// name never selects — and a miss outside the caller's own session and /// its direct children fails closed. #[tokio::test] +#[pa_test_scratch::pa_test] async fn rename_resolves_child_targets_by_id_only() { let (create_seen_tx, mut create_seen_rx) = mpsc::unbounded_channel(); let (verdict_tx, verdict_rx) = mpsc::unbounded_channel(); @@ -311,6 +315,7 @@ async fn rename_resolves_child_targets_by_id_only() { /// route (`renamedBy: parent`), and on success the parent-side record /// takes the new name — the old name stops matching, the new one hits. #[tokio::test] +#[pa_test_scratch::pa_test] async fn parent_rename_forwards_and_reseeds_the_record_name() { let (create_seen_tx, mut create_seen_rx) = mpsc::unbounded_channel(); let (verdict_tx, verdict_rx) = mpsc::unbounded_channel(); @@ -366,6 +371,7 @@ async fn parent_rename_forwards_and_reseeds_the_record_name() { /// its durable session id) routes to the caller's own worker through the /// supervisor with no `renamedBy` marker. #[tokio::test] +#[pa_test_scratch::pa_test] async fn self_rename_targets_the_caller_without_the_parent_marker() { let (create_seen_tx, _create_seen_rx) = mpsc::unbounded_channel(); let (_verdict_tx, verdict_rx) = mpsc::unbounded_channel(); @@ -402,6 +408,7 @@ async fn self_rename_targets_the_caller_without_the_parent_marker() { /// A second rename must not overtake the first command and then let its /// earlier parent-side record write replace the final worker name. #[tokio::test] +#[pa_test_scratch::pa_test] async fn concurrent_parent_renames_keep_the_last_applied_name() { let (create_seen_tx, mut create_seen_rx) = mpsc::unbounded_channel(); let (verdict_tx, verdict_rx) = mpsc::unbounded_channel(); diff --git a/crates/pa-daemon/src/rlm_children/usage_emit_tests.rs b/crates/pa-daemon/src/rlm_children/usage_emit_tests.rs index 092e8fd5b..61027f262 100644 --- a/crates/pa-daemon/src/rlm_children/usage_emit_tests.rs +++ b/crates/pa-daemon/src/rlm_children/usage_emit_tests.rs @@ -123,6 +123,7 @@ fn child_file(dir: &Path) -> PathBuf { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn emit_reads_once_and_advances_the_cursor() { let tmp = tempfile::tempdir().unwrap(); let file = child_file(tmp.path()); @@ -154,6 +155,7 @@ async fn emit_reads_once_and_advances_the_cursor() { /// A failed delivery keeps the cursor so the next emission re-delivers the /// same rows; once the sink persists, the report lands exactly once. #[tokio::test] +#[pa_test_scratch::pa_test] async fn emit_keeps_the_cursor_until_the_sink_persists() { let tmp = tempfile::tempdir().unwrap(); let file = child_file(tmp.path()); @@ -182,6 +184,7 @@ async fn emit_keeps_the_cursor_until_the_sink_persists() { /// A failed final observation keeps its report owed; the follow-up forget /// replays it before the registration drops instead of orphaning it. #[tokio::test] +#[pa_test_scratch::pa_test] async fn forget_replays_the_retained_report_before_unregistering() { let tmp = tempfile::tempdir().unwrap(); let file = child_file(tmp.path()); @@ -209,6 +212,7 @@ async fn forget_replays_the_retained_report_before_unregistering() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn emit_without_a_sink_consumes_nothing() { let tmp = tempfile::tempdir().unwrap(); let file = child_file(tmp.path()); @@ -220,6 +224,7 @@ async fn emit_without_a_sink_consumes_nothing() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn emit_tolerates_missing_and_absent_files() { let tmp = tempfile::tempdir().unwrap(); let sessions = registry(Path::new("/agent")); @@ -239,6 +244,7 @@ async fn emit_tolerates_missing_and_absent_files() { /// (tombstones/torn/`meta`/foreign parents excluded), the cursor lazy /// until a delivery primes it at the tail. #[tokio::test] +#[pa_test_scratch::pa_test] async fn reseed_lists_live_ledger_children_settled_and_bills_only_after_a_delivery() { let tmp = tempfile::tempdir().unwrap(); let agent = tmp.path().join("agent"); @@ -385,6 +391,7 @@ async fn reseed_lists_live_ledger_children_settled_and_bills_only_after_a_delive /// Cancellation after delivery starts retains the exact interval; rows arriving /// behind it are drained once before the caller's final forget. #[tokio::test] +#[pa_test_scratch::pa_test] async fn canceled_interval_keeps_identity_and_drains_new_rows_before_forget() { struct CancelFirstSink { attempts: std::sync::Mutex>, @@ -481,6 +488,7 @@ async fn canceled_interval_keeps_identity_and_drains_new_rows_before_forget() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn failed_final_replay_preserves_report_and_registration_for_a_bounded_retry() { let tmp = tempfile::tempdir().unwrap(); let file = child_file(tmp.path()); @@ -603,6 +611,7 @@ async fn retirement_registry( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn repeated_delete_replays_retired_usage_without_repeating_lifecycle_work() { let tmp = tempfile::tempdir().unwrap(); let file = child_file(tmp.path()); @@ -693,6 +702,7 @@ async fn repeated_delete_replays_retired_usage_without_repeating_lifecycle_work( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn repeated_close_replays_retired_usage_without_a_second_kill() { let tmp = tempfile::tempdir().unwrap(); let file = child_file(tmp.path()); @@ -960,16 +970,19 @@ async fn cancellation_after_ack_preserves_retirement(caller: RetirementCaller) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn delete_canceled_after_kill_ack_retries_without_a_second_kill() { cancellation_after_ack_preserves_retirement(RetirementCaller::Delete).await; } #[tokio::test] +#[pa_test_scratch::pa_test] async fn close_canceled_after_kill_ack_retries_without_a_second_kill() { cancellation_after_ack_preserves_retirement(RetirementCaller::Close).await; } #[tokio::test] +#[pa_test_scratch::pa_test] async fn concurrent_close_replays_debt_after_the_first_caller_retires_the_roster() { let tmp = tempfile::tempdir().unwrap(); let file = child_file(tmp.path()); @@ -1051,11 +1064,13 @@ async fn concurrent_close_replays_debt_after_the_first_caller_retires_the_roster } #[tokio::test] +#[pa_test_scratch::pa_test] async fn inactive_delete_finishes_a_running_record_whose_kill_already_acknowledged() { cancellation_after_ack_preserves_retirement(RetirementCaller::InactiveAfterDelete).await; } #[tokio::test] +#[pa_test_scratch::pa_test] async fn close_preserves_final_usage_across_a_transient_child_file_read_failure() { let tmp = tempfile::tempdir().unwrap(); let file = child_file(tmp.path()); @@ -1317,11 +1332,13 @@ async fn settled_watcher_replays_only_one_failed_final_interval(failure: FinalWa } #[tokio::test] +#[pa_test_scratch::pa_test] async fn settled_watcher_replays_a_failed_final_emit_before_its_notice_and_settle() { settled_watcher_replays_only_one_failed_final_interval(FinalWatcherFailure::Transient).await; } #[tokio::test] +#[pa_test_scratch::pa_test] async fn settled_watcher_caps_a_persistent_final_failure_and_preserves_the_debt() { settled_watcher_replays_only_one_failed_final_interval(FinalWatcherFailure::Persistent).await; } diff --git a/crates/pa-daemon/src/rlm_children/watch_tests.rs b/crates/pa-daemon/src/rlm_children/watch_tests.rs index 7509068c4..60cf64b9f 100644 --- a/crates/pa-daemon/src/rlm_children/watch_tests.rs +++ b/crates/pa-daemon/src/rlm_children/watch_tests.rs @@ -351,6 +351,7 @@ async fn spawn_child(sessions: &SupervisorChildSessions) -> RlmSpawnHandle { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn roster_snapshot_does_not_wait_for_a_slow_child_worker() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -373,6 +374,7 @@ async fn roster_snapshot_does_not_wait_for_a_slow_child_worker() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn spawned_child_can_finish_before_the_parent_turn_ends() { let (follow_up_tx, mut follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -390,6 +392,7 @@ async fn spawned_child_can_finish_before_the_parent_turn_ends() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn spawn_admits_the_kickoff_before_it_returns() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let child_subagents = Arc::new(FakeChildSubagents { @@ -420,6 +423,7 @@ async fn spawn_admits_the_kickoff_before_it_returns() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_settled_child_without_a_reply_delivers_the_terminal_notice() { let (follow_up_tx, mut follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -454,6 +458,7 @@ async fn a_settled_child_without_a_reply_delivers_the_terminal_notice() { /// leaves inside the grace (the idle passivation's stop, a crash) keeps /// the settled verdict, and the settle tail (notice, funnel) still runs. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_worker_leaving_inside_the_settle_grace_keeps_the_verdict() { let (follow_up_tx, mut follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = sessions_with_fake_supervisor( @@ -481,6 +486,7 @@ async fn a_worker_leaving_inside_the_settle_grace_keeps_the_verdict() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn child_updates_surface_through_the_sink() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -532,6 +538,7 @@ async fn child_updates_surface_through_the_sink() { /// A cancelled run's watcher settle leaves the display `running`, so a /// restart relists the child as `error` instead of `completed`. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_cancelled_child_keeps_its_display_running_through_the_watcher_settle() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -577,6 +584,7 @@ fn assert_failure_row(follow_up: &Value, child_id: &str, error: &str) { /// A child whose task prompt cannot be routed settles `error`, delivers /// the TS failure row and releases the owed continuation. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_child_whose_task_prompt_cannot_be_routed_delivers_the_failure_notice() { let (follow_up_tx, mut follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -611,6 +619,7 @@ async fn a_child_whose_task_prompt_cannot_be_routed_delivers_the_failure_notice( /// A short tick keeps the paused clock's auto-advance from firing link /// deadlines while the real-socket round trips are in flight. #[tokio::test(start_paused = true)] +#[pa_test_scratch::pa_test] async fn an_unreachable_child_delivers_the_failure_notice_instead_of_no_reply() { tokio::spawn(async { let mut tick = tokio::time::interval(Duration::from_secs(1)); @@ -644,6 +653,7 @@ static VERDICT_LANDED: tokio::sync::Notify = tokio::sync::Notify::const_new(); /// read and its unreachable give-up claim: the claim keeps that verdict, /// and the watcher still runs its settle tail. #[tokio::test(start_paused = true)] +#[pa_test_scratch::pa_test] async fn a_verdict_landing_inside_the_unreachable_give_up_still_runs_the_settle_tail() { tokio::spawn(async { let mut tick = tokio::time::interval(Duration::from_secs(1)); @@ -691,6 +701,7 @@ async fn a_verdict_landing_inside_the_unreachable_give_up_still_runs_the_settle_ /// marks settled (post-#3171 an unsettled failed run parks /// `waitForRlmQuiescence` forever). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_failed_prompt_is_settled_before_spawn_returns() { let (follow_up_tx, mut follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -737,6 +748,7 @@ async fn a_failed_prompt_is_settled_before_spawn_returns() { /// task prompt fails: TS sends the catch-arm row regardless of reply /// count (`agent-session.ts:13026-13045`). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_replied_child_whose_prompt_fails_still_delivers_the_failure_row() { let (follow_up_tx, mut follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -764,6 +776,7 @@ async fn a_replied_child_whose_prompt_fails_still_delivers_the_failure_row() { /// once the grandchild finishes, the child settles and the parent is /// quiet again. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_child_with_a_running_grandchild_keeps_the_parent_running() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let grandchild = Arc::new(FakeChildSubagents { @@ -805,6 +818,7 @@ async fn a_child_with_a_running_grandchild_keeps_the_parent_running() { /// A `collect` with a timeout waits out a child whose own turn ended but /// whose grandchild still runs, instead of answering `running` at once. #[tokio::test] +#[pa_test_scratch::pa_test] async fn collect_with_a_timeout_waits_for_a_running_grandchild() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let grandchild = Arc::new(FakeChildSubagents { @@ -864,6 +878,7 @@ async fn one_running_child(sessions: &SupervisorChildSessions) { /// `close_children`: every tracked child is stopped through the supervisor — a plain stop, no /// delete marker; the registry empties, and no terminal notice is owed. #[tokio::test] +#[pa_test_scratch::pa_test] async fn close_children_stops_the_child_and_clears_the_roster() { let (follow_up_tx, mut follow_up_rx) = mpsc::unbounded_channel(); // A long idle keeps the child mid-run while the close fires, so the @@ -901,6 +916,7 @@ async fn close_children_stops_the_child_and_clears_the_roster() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn close_children_treats_an_already_gone_child_as_a_no_op() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = sessions_with_fake_supervisor( @@ -926,6 +942,7 @@ async fn close_children_treats_an_already_gone_child_as_a_no_op() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn close_children_keeps_a_failed_child_tracked() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -948,6 +965,7 @@ async fn close_children_keeps_a_failed_child_tracked() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_replied_child_gets_no_terminal_notice() { let (follow_up_tx, mut follow_up_rx) = mpsc::unbounded_channel(); // A slow idle wait keeps the child "running" while the test marks @@ -966,6 +984,7 @@ async fn a_replied_child_gets_no_terminal_notice() { /// A target whose delete receipt already returned resolves immediately to the settled cancelled /// envelope without spending the timeout budget; unknown selectors keep erroring. #[tokio::test] +#[pa_test_scratch::pa_test] async fn collect_answers_a_just_deleted_target_with_the_cancelled_envelope() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -1043,6 +1062,7 @@ async fn collect_answers_a_just_deleted_target_with_the_cancelled_envelope() { /// a same-name spawn admits again — and the delete of a settled child /// returns the terminal row instead of erroring. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_deleted_settled_child_releases_its_name_slot_and_deletes_idempotently() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -1096,6 +1116,7 @@ async fn a_deleted_settled_child_releases_its_name_slot_and_deletes_idempotently /// the live read first, the durable session file second — so the parent-side /// reader sees the child's final say, not a bare failure row. #[tokio::test(start_paused = true)] +#[pa_test_scratch::pa_test] async fn a_failed_settle_captures_the_childs_last_assistant_text() { tokio::spawn(async { let mut tick = tokio::time::interval(Duration::from_secs(1)); @@ -1136,6 +1157,7 @@ async fn a_failed_settle_captures_the_childs_last_assistant_text() { /// fill now runs on every refresh: it writes only when the fresh round trip /// produced a text AND the row has no answer yet. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_none_first_answer_capture_recovers_on_a_later_collect() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -1179,6 +1201,7 @@ async fn a_none_first_answer_capture_recovers_on_a_later_collect() { /// the roster preview stays the compact form; the deleted envelope's /// binding lane is empty (the tombstone only keeps the preview). #[tokio::test] +#[pa_test_scratch::pa_test] async fn collect_carries_the_full_answer_text_of_a_settled_child() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -1230,6 +1253,7 @@ async fn collect_carries_the_full_answer_text_of_a_settled_child() { /// The inactive delete (a settled retained child) leaves the same tombstone as the live delete, so /// `collect` answers a just-deleted selector with the settled cancelled envelope. #[tokio::test] +#[pa_test_scratch::pa_test] async fn collect_answers_the_cancelled_envelope_after_an_inactive_delete() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let (sessions, _kill_rx) = @@ -1271,6 +1295,7 @@ async fn collect_answers_the_cancelled_envelope_after_an_inactive_delete() { /// A child that already settled never re-scores as an error when its worker leaves afterward; a /// still-RUNNING child does (the crash class the error verdict exists for). +#[pa_test_scratch::pa_test] #[test] fn an_already_settled_child_never_re_scores_as_an_unreachable_error() { let base = || ChildRecord { @@ -1330,6 +1355,7 @@ fn an_already_settled_child_never_re_scores_as_an_unreachable_error() { /// the capture entirely — zero `get_last_assistant_text` reads, the /// standing capture unchanged. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_unreachable_give_up_skips_the_exit_capture_when_a_capture_stands() { let (follow_up_tx, _follow_up_rx) = mpsc::unbounded_channel(); let child_subagents = Arc::new(FakeChildSubagents::default()); diff --git a/crates/pa-daemon/src/rlm_ledger/tests.rs b/crates/pa-daemon/src/rlm_ledger/tests.rs index 29797ba5d..74ec89753 100644 --- a/crates/pa-daemon/src/rlm_ledger/tests.rs +++ b/crates/pa-daemon/src/rlm_ledger/tests.rs @@ -33,6 +33,7 @@ fn write_session_log(path: &Path, rows: &[Value]) { } } +#[pa_test_scratch::pa_test] #[test] fn legacy_registry_probe_reads_the_header_line_bounded() { let dir = temp_dir("legacy-bounded"); @@ -65,6 +66,7 @@ fn legacy_registry_probe_reads_the_header_line_bounded() { ); } +#[pa_test_scratch::pa_test] #[test] fn legacy_registry_probe_resolves_a_readable_header_over_a_corrupt_tail() { let dir = temp_dir("legacy-corrupt-tail"); @@ -90,6 +92,7 @@ fn legacy_registry_probe_resolves_a_readable_header_over_a_corrupt_tail() { ); } +#[pa_test_scratch::pa_test] #[test] fn legacy_registry_probe_rejects_uncommitted_or_corrupt_log_headers() { let dir = temp_dir("legacy-header-invalid"); @@ -116,6 +119,7 @@ fn legacy_registry_probe_rejects_uncommitted_or_corrupt_log_headers() { assert_eq!(legacy_registry_path(&parent), None); } +#[pa_test_scratch::pa_test] #[test] fn ledger_path_hashes_the_canonical_sessions_dir() { let dir = temp_dir("path"); @@ -127,6 +131,7 @@ fn ledger_path_hashes_the_canonical_sessions_dir() { assert_ne!(a, c); } +#[pa_test_scratch::pa_test] #[test] fn spawn_rename_delete_replay_in_order() { let dir = temp_dir("replay"); @@ -167,6 +172,7 @@ fn spawn_rename_delete_replay_in_order() { assert_eq!(ledger.edges(true).unwrap(), tombstones); } +#[pa_test_scratch::pa_test] #[test] fn edge_is_live_reflects_tombstones_and_files() { let dir = temp_dir("liveness"); @@ -227,6 +233,7 @@ fn edge_is_live_reflects_tombstones_and_files() { // canonical path recorded at spawn can later become a symlink, so the // replay index alone cannot establish that no live edge matches a path. #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn edge_is_live_revalidates_paths_without_a_ledger_append() { use std::os::unix::fs::symlink; @@ -292,6 +299,7 @@ fn edge_is_live_revalidates_paths_without_a_ledger_append() { /// A respawned child id: the tombstoned edge at the old path stays dead, /// the new path's edge is live, and a later respawn on the old path's key /// re-lives that edge in place (the fold keeps one edge per key). +#[pa_test_scratch::pa_test] #[test] fn a_respawned_child_id_on_a_new_path_is_live_and_the_old_one_is_not() { let dir = temp_dir("respawn"); @@ -325,6 +333,7 @@ fn a_respawned_child_id_on_a_new_path_is_live_and_the_old_one_is_not() { assert!(ledger.edge_is_live("sub-1", &b.to_string_lossy())); } +#[pa_test_scratch::pa_test] #[test] fn dead_child_or_parent_drops_from_live_edges() { let dir = temp_dir("live"); @@ -350,6 +359,7 @@ fn dead_child_or_parent_drops_from_live_edges() { /// A recorded edge path whose file moved resolves through its durable session id, and the returned /// edge carries the resolved path; a session with no file anywhere stays dead. +#[pa_test_scratch::pa_test] #[test] fn moved_edge_paths_resolve_through_the_session_id() { let agent_dir = temp_dir("agent"); @@ -408,6 +418,7 @@ fn moved_edge_paths_resolve_through_the_session_id() { assert_eq!(raw[0].child, recorded_child); } +#[pa_test_scratch::pa_test] #[test] fn the_artifact_index_updates_after_a_new_partition() { let agent_dir = temp_dir("index-partition"); @@ -471,6 +482,7 @@ fn the_artifact_index_updates_after_a_new_partition() { /// resolve (no per-edge stats, no artifacts-tree walk), while the own /// edges resolve - a moved child through its session id - and a /// tombstoned own child is skipped before any resolution. +#[pa_test_scratch::pa_test] #[test] fn live_edges_of_parent_bounds_the_liveness_work() { let agent_dir = temp_dir("scoped"); @@ -568,6 +580,7 @@ fn live_edges_of_parent_bounds_the_liveness_work() { assert_eq!(unscoped.resolved.len(), 103); } +#[pa_test_scratch::pa_test] #[test] fn a_dead_endpoint_under_an_archived_parent_resolves_without_a_tree_walk() { let agent_dir = temp_dir("archive-dead"); @@ -608,6 +621,7 @@ fn a_dead_endpoint_under_an_archived_parent_resolves_without_a_tree_walk() { /// dir) still lists its children through the scoped read; an edge whose /// recorded parent merely shares the opened file's stem but resolves to /// another live file is not the opened parent's. +#[pa_test_scratch::pa_test] #[test] fn live_edges_of_parent_follows_a_moved_parent() { let agent_dir = temp_dir("scoped-moved"); @@ -663,6 +677,7 @@ fn live_edges_of_parent_follows_a_moved_parent() { ); } +#[pa_test_scratch::pa_test] #[test] fn duplicate_child_path_and_bad_spawn_inputs_fail_but_bad_lines_skip() { let dir = temp_dir("dup"); @@ -715,6 +730,7 @@ fn duplicate_child_path_and_bad_spawn_inputs_fail_but_bad_lines_skip() { assert_eq!(ids, ["sub-1", "sub-4"]); } +#[pa_test_scratch::pa_test] #[test] fn unknown_op_records_are_skipped_forward_compatible() { let dir = temp_dir("fwd"); @@ -739,6 +755,7 @@ fn unknown_op_records_are_skipped_forward_compatible() { assert_eq!(edges[0].child_id, "sub-1"); } +#[pa_test_scratch::pa_test] #[test] fn seeds_from_legacy_registries_once_and_atomically() { let dir = temp_dir("seed"); @@ -779,6 +796,7 @@ fn seeds_from_legacy_registries_once_and_atomically() { assert!(first.contains("\"op\":\"meta\"")); } +#[pa_test_scratch::pa_test] #[test] fn display_entries_round_trip_and_tombstones_stick() { let dir = temp_dir("display"); @@ -807,6 +825,7 @@ fn display_entries_round_trip_and_tombstones_stick() { assert!(!write_rlm_subagent_display(&entry).unwrap()); } +#[pa_test_scratch::pa_test] #[test] fn display_entry_file_is_owner_only() { let dir = temp_dir("display-mode"); @@ -870,6 +889,7 @@ fn assistant_usage_row(id: &str, cost: f64) -> String { /// The deletion amendment's snapshot rides the delete record, merges into the same tombstoned edge, /// and survives an idempotent re-tombstone until a fresh capture replaces it. +#[pa_test_scratch::pa_test] #[test] fn delete_amendment_carries_the_usage_snapshot() { let dir = temp_dir("amendment"); @@ -940,6 +960,7 @@ fn delete_amendment_carries_the_usage_snapshot() { /// The writer never records what the reader refuses: a negative or NaN /// usage cost rides as absent (a bare delete record), so the ledger stays readable. +#[pa_test_scratch::pa_test] #[test] fn append_delete_with_usage_sanitizes_a_rejectable_cost() { let dir = temp_dir("usage-neg"); @@ -986,6 +1007,7 @@ fn append_delete_with_usage_sanitizes_a_rejectable_cost() { ); } +#[pa_test_scratch::pa_test] #[test] fn tombstone_child_path_with_usage_snapshots_every_edge() { let dir = temp_dir("path-usage"); @@ -1029,6 +1051,7 @@ fn tombstone_child_path_with_usage_snapshots_every_edge() { /// child $0.40 + its deleted grandchild $0.10 => the parent's bucket /// $0.50). The snapshots are OWN-ONLY: one carrying the child's /// aggregate would double count the grandchild. +#[pa_test_scratch::pa_test] #[test] fn bucket_folds_own_snapshots_post_order_without_double_counting() { let dir = temp_dir("bucket-fixture"); @@ -1133,6 +1156,7 @@ fn bucket_folds_own_snapshots_post_order_without_double_counting() { /// Legacy tombstones (pre-capture): a live transcript rides its own row /// (billing both would double the spend); once it is gone the documented historical gap bills zero. +#[pa_test_scratch::pa_test] #[test] fn bucket_legacy_tombstones_fall_back_then_gap_to_zero() { let dir = temp_dir("bucket-legacy"); @@ -1188,6 +1212,7 @@ fn bucket_legacy_tombstones_fall_back_then_gap_to_zero() { /// falls back to the transcript's own-usage fold. A transcript directly /// in the sessions dir keeps its catalog row and stays skipped (the /// flat-dir tests above pin that half). +#[pa_test_scratch::pa_test] #[test] fn bucket_bills_tombstoned_children_without_catalog_rows() { let dir = temp_dir("bucket-no-row"); @@ -1296,6 +1321,7 @@ fn bucket_bills_tombstoned_children_without_catalog_rows() { /// A raced ledger claims each tombstoned path once (first writer wins): /// one child path billed to two parents would double the spend. +#[pa_test_scratch::pa_test] #[test] fn bucket_claims_each_tombstoned_path_once() { let dir = temp_dir("bucket-claim"); @@ -1370,6 +1396,7 @@ fn bucket_claims_each_tombstoned_path_once() { /// A recreated path is live: its old tombstone never bills spend that /// the new live child's own row carries. +#[pa_test_scratch::pa_test] #[test] fn bucket_skips_recreated_live_paths() { let dir = temp_dir("bucket-live"); @@ -1410,6 +1437,7 @@ fn bucket_skips_recreated_live_paths() { assert!(bucket.is_empty(), "a live path never bills the bucket"); } +#[pa_test_scratch::pa_test] #[test] fn the_bucket_updates_after_an_append_on_the_same_ledger() { let dir = temp_dir("bucket-append"); @@ -1468,6 +1496,7 @@ fn the_bucket_updates_after_an_append_on_the_same_ledger() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_restored_tombstoned_child_stops_billing_the_parent_without_an_append() { let dir = temp_dir("bucket-restore"); @@ -1513,6 +1542,7 @@ fn a_restored_tombstoned_child_stops_billing_the_parent_without_an_append() { ); } +#[pa_test_scratch::pa_test] #[test] fn the_artifact_index_rechecks_deleted_and_relocated_transcripts_without_an_append() { let dir = temp_dir("index-disk-change"); @@ -1547,6 +1577,7 @@ fn the_artifact_index_rechecks_deleted_and_relocated_transcripts_without_an_appe assert_eq!(ledger.live_edges().unwrap(), expected); } +#[pa_test_scratch::pa_test] #[test] fn artifact_misses_stay_cached_until_a_directory_changes() { let dir = temp_dir("index-negative-cache"); diff --git a/crates/pa-daemon/src/rlm_roster.rs b/crates/pa-daemon/src/rlm_roster.rs index 0c4c1e7cb..7fb42b616 100644 --- a/crates/pa-daemon/src/rlm_roster.rs +++ b/crates/pa-daemon/src/rlm_roster.rs @@ -271,6 +271,7 @@ mod tests { write_session_text(path, &content); } + #[pa_test_scratch::pa_test] #[test] fn passive_child_summary_carries_the_persisted_thinking_level() { let dir = temp_dir("thinking"); @@ -318,6 +319,7 @@ mod tests { .is_none()); } + #[pa_test_scratch::pa_test] #[test] fn passive_child_summary_carries_the_saved_usage_summary() { let dir = temp_dir("usage"); @@ -366,6 +368,7 @@ mod tests { write_session_text(path, &content); } + #[pa_test_scratch::pa_test] #[test] fn walks_passive_children_from_saved_and_resident_roots() { let dir = temp_dir("walk"); @@ -461,6 +464,7 @@ mod tests { assert_eq!(walked[0].edge.child_id, "sub-2"); } + #[pa_test_scratch::pa_test] #[test] fn passive_rows_carry_the_subagent_identity() { let dir = temp_dir("rows"); diff --git a/crates/pa-daemon/src/rlm_surface.rs b/crates/pa-daemon/src/rlm_surface.rs index 92c7ebad6..32947a3a5 100644 --- a/crates/pa-daemon/src/rlm_surface.rs +++ b/crates/pa-daemon/src/rlm_surface.rs @@ -128,6 +128,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cancel_rlm_child_answers_the_ts_cancelled_shape() { let worker = created_worker().await; let response = worker @@ -141,6 +142,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn delete_rlm_subagent_answers_the_ts_not_found_shape() { let worker = created_worker().await; let response = worker @@ -154,6 +156,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn set_rlm_max_depth_answers_the_ts_result_shape() { let worker = created_worker().await; let response = worker @@ -193,6 +196,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn missing_required_fields_fail() { let worker = created_worker().await; for command_type in ["cancel_rlm_child", "delete_rlm_subagent"] { diff --git a/crates/pa-daemon/src/roster_activity.rs b/crates/pa-daemon/src/roster_activity.rs index d0864be23..bfa4ef276 100644 --- a/crates/pa-daemon/src/roster_activity.rs +++ b/crates/pa-daemon/src/roster_activity.rs @@ -225,6 +225,7 @@ mod tests { OutboundFrame::session_event(serde_json::to_vec(&payload).unwrap()) } + #[pa_test_scratch::pa_test] #[test] fn every_ts_trigger_event_type_flushes() { for event_type in ROSTER_SESSION_EVENT_TRIGGERS { @@ -236,6 +237,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn non_trigger_events_and_frame_kinds_stay_silent() { for event_type in [ @@ -284,6 +286,7 @@ mod tests { ))); } + #[pa_test_scratch::pa_test] #[test] fn the_disabled_queue_never_pushes() { let queue = RosterPushQueue::disabled(); @@ -294,6 +297,7 @@ mod tests { /// supervisor collapses into a couple of flushes with the latest state. #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_burst_collapses_behind_a_slow_supervisor() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("sup.sock"); @@ -389,6 +393,7 @@ mod tests { /// the first request is answered. #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_wedged_supervisor_holds_one_in_flight_roster_push() { type StubArrival = (Value, tokio::net::unix::OwnedWriteHalf); let dir = tempfile::TempDir::new().unwrap(); diff --git a/crates/pa-daemon/src/rpc/protocol.rs b/crates/pa-daemon/src/rpc/protocol.rs index 0956d8d7b..4caa10da6 100644 --- a/crates/pa-daemon/src/rpc/protocol.rs +++ b/crates/pa-daemon/src/rpc/protocol.rs @@ -141,6 +141,7 @@ pub fn command_streaming_behavior( mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn success_absent_data_omits_the_key() { let response = success(None, "prompt", ResponseData::Absent); @@ -151,6 +152,7 @@ mod tests { assert!(response.get("id").is_none(), "absent id omits the key"); } + #[pa_test_scratch::pa_test] #[test] fn success_null_data_keeps_the_key() { let response = success( @@ -162,6 +164,7 @@ mod tests { assert_eq!(response["data"], Value::Null, "null data keeps the key"); } + #[pa_test_scratch::pa_test] #[test] fn parse_errors_carry_the_ts_prefix() { match parse_line("{nope") { @@ -189,6 +192,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn commands_parse_with_id_echo() { let ParsedLine::Command(command) = parse_line( diff --git a/crates/pa-daemon/src/saved_session_commands.rs b/crates/pa-daemon/src/saved_session_commands.rs index 5225723ef..2a9a1d073 100644 --- a/crates/pa-daemon/src/saved_session_commands.rs +++ b/crates/pa-daemon/src/saved_session_commands.rs @@ -985,6 +985,7 @@ mod tombstone_usage_tests { /// The deleted-descendant bucket still bills the parent after the /// transcript is gone (the Rust-side instance of TS #2506's Macroscope race). + #[pa_test_scratch::pa_test] #[test] fn saved_session_delete_captures_usage_before_the_unlink() { let root = temp_dir("capture"); @@ -1031,6 +1032,7 @@ mod tombstone_usage_tests { ); } + #[pa_test_scratch::pa_test] #[test] fn top_level_deletes_never_capture() { let root = temp_dir("top-level"); @@ -1053,6 +1055,7 @@ mod tombstone_usage_tests { } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn symlink_delete_tombstones_the_edge_keyed_at_the_target() { let root = temp_dir("symlink-del"); @@ -1101,6 +1104,7 @@ mod tombstone_usage_tests { } #[cfg(unix)] + #[pa_test_scratch::pa_test] #[test] fn a_non_regular_session_path_captures_nothing() { let root = tempfile::Builder::new() diff --git a/crates/pa-daemon/src/scheduled_jobs/tests.rs b/crates/pa-daemon/src/scheduled_jobs/tests.rs index 1e0e58844..26707cec3 100644 --- a/crates/pa-daemon/src/scheduled_jobs/tests.rs +++ b/crates/pa-daemon/src/scheduled_jobs/tests.rs @@ -69,6 +69,7 @@ fn write_active_session(dir: &std::path::Path) -> (String, std::path::PathBuf) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_fire_at_a_killed_session_cancels_and_skips() { let dir = std::env::temp_dir().join(format!("pa-sched-dead-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -133,6 +134,7 @@ async fn a_fire_at_a_killed_session_cancels_and_skips() { /// A heartbeat parks as the injected `heartbeat_prompt` row with the TS preview (the /// queue strip reads `Heartbeat prompt: `, the turn text keeps the raw content). #[tokio::test] +#[pa_test_scratch::pa_test] async fn heartbeat_fire_parks_the_labeled_preview_on_its_lane() { let dir = std::env::temp_dir().join(format!("pa-sched-fire-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -238,6 +240,7 @@ async fn heartbeat_fire_parks_the_labeled_preview_on_its_lane() { /// heartbeat re-fired ~120x): a real error settles as a run, abort/withdrawal /// as a clean run and a skip. #[tokio::test] +#[pa_test_scratch::pa_test] async fn settles_classify_ran_failed_or_skipped() { // Park one fire, settle it with `settle`, and return the verdict. async fn settle_one( @@ -334,6 +337,7 @@ async fn settles_classify_ran_failed_or_skipped() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn rlm_heartbeat_mutation_hook_fires_into_the_session_queue() { let dir = std::env::temp_dir().join(format!("pa-hb-fire-{}", uuid::Uuid::new_v4())); let sessions_dir = dir.join("sessions"); diff --git a/crates/pa-daemon/src/scheduling_catalog.rs b/crates/pa-daemon/src/scheduling_catalog.rs index 3ce34bad6..58859e317 100644 --- a/crates/pa-daemon/src/scheduling_catalog.rs +++ b/crates/pa-daemon/src/scheduling_catalog.rs @@ -886,6 +886,7 @@ mod tests { /// A worker registering while the blocking artifact scan is in flight /// owns its job before the passive path can write to the shared store. #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn a_worker_registered_during_the_scan_gets_its_heartbeat_manage() { use crate::registry::{ResidentWorker, WorkerReply}; use crate::supervisor::subscribers::ClientSubscriptions; @@ -1045,6 +1046,7 @@ mod tests { /// first read STILL answers the warm row — a read that scanned inline /// at that moment would see the deleted fixture and answer nothing. #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_passive_catalog_warms_at_boot_and_the_first_read_serves_the_snapshot() { let dir = tempfile::tempdir().expect("temp dir"); let agent_dir = dir.path().join("agent"); @@ -1142,6 +1144,7 @@ mod tests { /// adopt signal unfired the snapshot never lands; once the signal /// fires, it does. #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_boot_warmup_waits_out_the_adopt_pass_before_scanning() { let dir = tempfile::tempdir().expect("temp dir"); let agent_dir = dir.path().join("agent"); diff --git a/crates/pa-daemon/src/session_archive.rs b/crates/pa-daemon/src/session_archive.rs index 60c485c6a..3e94336a6 100644 --- a/crates/pa-daemon/src/session_archive.rs +++ b/crates/pa-daemon/src/session_archive.rs @@ -348,6 +348,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn age_rule_archives_at_and_past_the_boundary() { let now = SystemTime::now(); @@ -362,6 +363,7 @@ mod tests { assert_eq!(ids, vec!["old", "edge"]); } + #[pa_test_scratch::pa_test] #[test] fn age_rule_off_archives_nothing() { let now = SystemTime::now(); @@ -370,6 +372,7 @@ mod tests { assert!(doomed.is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn count_rule_keeps_the_newest_cap_and_spares_protected() { let now = SystemTime::now(); @@ -397,6 +400,7 @@ mod tests { assert_eq!(ids, vec!["c"]); } + #[pa_test_scratch::pa_test] #[test] fn count_rule_under_the_cap_archives_nothing() { let now = SystemTime::now(); @@ -408,6 +412,7 @@ mod tests { assert!(doomed.is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn both_rules_union_without_duplicates() { let now = SystemTime::now(); @@ -423,6 +428,7 @@ mod tests { assert_eq!(ids, vec!["old", "b"]); } + #[pa_test_scratch::pa_test] #[test] fn sweep_moves_doomed_sessions_and_keeps_the_rest() { let dir = tempfile::tempdir().expect("temp dir"); @@ -452,6 +458,7 @@ mod tests { assert!(!old.is_file(), "aged session left the sessions dir"); } + #[pa_test_scratch::pa_test] #[test] fn sweep_with_both_rules_off_is_a_noop() { let dir = tempfile::tempdir().expect("temp dir"); @@ -472,6 +479,7 @@ mod tests { assert!(old.is_file()); } + #[pa_test_scratch::pa_test] #[test] fn restore_round_trips_an_archived_session() { let dir = tempfile::tempdir().expect("temp dir"); @@ -490,6 +498,7 @@ mod tests { assert!(restore_session(dir.path(), &archive, &sessions, "missing").is_err()); } + #[pa_test_scratch::pa_test] #[test] fn a_destination_created_after_the_precheck_is_never_replaced() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/session_bindings.rs b/crates/pa-daemon/src/session_bindings.rs index 9ed85ccd1..d7cb06389 100644 --- a/crates/pa-daemon/src/session_bindings.rs +++ b/crates/pa-daemon/src/session_bindings.rs @@ -124,6 +124,7 @@ fn canonical_binding_path(path: &str) -> String { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn record_indexes_by_active_id_and_file() { let table = SessionBindingTable::new(); @@ -136,6 +137,7 @@ mod tests { assert_eq!(binding.session_file.as_deref(), Some("/tmp/sess.jsonl")); } + #[pa_test_scratch::pa_test] #[test] fn supersede_repoints_the_old_id_at_the_new_binding() { let table = SessionBindingTable::new(); @@ -159,6 +161,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_second_supersede_repoints_every_older_id() { let table = SessionBindingTable::new(); @@ -188,6 +191,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn rebinding_the_same_id_is_not_a_supersede() { let table = SessionBindingTable::new(); @@ -198,6 +202,7 @@ mod tests { .is_none()); } + #[pa_test_scratch::pa_test] #[test] fn unknown_and_empty_ids_have_no_binding() { let table = SessionBindingTable::new(); @@ -208,6 +213,7 @@ mod tests { assert!(table.binding_for("").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn a_binding_without_a_session_file_never_supersedes() { let table = SessionBindingTable::new(); @@ -219,6 +225,7 @@ mod tests { assert!(table.binding_for("worker-2").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn a_deleted_session_file_forgets_its_ids() { let table = SessionBindingTable::new(); @@ -243,6 +250,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn forgetting_one_file_keeps_other_files_bound() { let table = SessionBindingTable::new(); @@ -261,6 +269,7 @@ mod tests { assert!(table.binding_for("worker-1").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn a_different_session_at_a_reused_file_path_never_supersedes() { let table = SessionBindingTable::new(); @@ -288,6 +297,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn an_identity_less_record_never_supersedes() { // A boot registration racing the create carries no session id: it @@ -312,6 +322,7 @@ mod tests { assert_eq!(superseded.0, vec!["worker-1".to_string()]); } + #[pa_test_scratch::pa_test] #[test] fn two_identity_less_records_never_supersede_each_other() { let table = SessionBindingTable::new(); @@ -333,6 +344,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn distinct_files_keep_distinct_bindings() { let table = SessionBindingTable::new(); diff --git a/crates/pa-daemon/src/session_catalog.rs b/crates/pa-daemon/src/session_catalog.rs index 3562a4614..5b3963c55 100644 --- a/crates/pa-daemon/src/session_catalog.rs +++ b/crates/pa-daemon/src/session_catalog.rs @@ -91,6 +91,7 @@ mod tests { (session.session_id().to_string(), path) } + #[pa_test_scratch::pa_test] #[test] fn resolves_by_id_prefix_and_exact_name() { let dir = temp_dir(); @@ -107,6 +108,7 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + #[pa_test_scratch::pa_test] #[test] fn local_scope_wins_and_global_is_the_fallback() { let dir = temp_dir(); @@ -125,6 +127,7 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + #[pa_test_scratch::pa_test] #[test] fn ambiguous_selectors_carry_the_ts_error() { let dir = temp_dir(); @@ -136,6 +139,7 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + #[pa_test_scratch::pa_test] #[test] fn an_archived_match_restores_into_the_sessions_dir() { let dir = temp_dir(); @@ -158,6 +162,7 @@ mod tests { assert_eq!(again.path, dir.join(session_file_name(&id))); } + #[pa_test_scratch::pa_test] #[test] fn live_matches_win_over_archived_ones() { let dir = temp_dir(); @@ -173,6 +178,7 @@ mod tests { assert!(dir.join(session_file_name(&live_id)).is_file()); } + #[pa_test_scratch::pa_test] #[test] fn an_ambiguous_archive_selector_carries_the_ts_error() { let dir = temp_dir(); @@ -184,6 +190,7 @@ mod tests { assert_eq!(error.to_string(), "Ambiguous session selector \"alpha\""); } + #[pa_test_scratch::pa_test] #[test] fn a_miss_is_none_not_an_error() { let dir = temp_dir(); diff --git a/crates/pa-daemon/src/session_commands.rs b/crates/pa-daemon/src/session_commands.rs index 5a4c8b0e5..e0de6824c 100644 --- a/crates/pa-daemon/src/session_commands.rs +++ b/crates/pa-daemon/src/session_commands.rs @@ -172,6 +172,7 @@ pub(crate) fn custom_message_value( mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn session_command_prompt_parsing() { let command = parse_prompt_session_command("/goal status").unwrap(); @@ -182,6 +183,7 @@ mod tests { assert!(parse_prompt_session_command("/model").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn custom_rows_serialize_with_custom_role() { let command = parse_prompt_session_command("/compact focus").unwrap(); diff --git a/crates/pa-daemon/src/session_custom.rs b/crates/pa-daemon/src/session_custom.rs index a022f1fce..2c98d857d 100644 --- a/crates/pa-daemon/src/session_custom.rs +++ b/crates/pa-daemon/src/session_custom.rs @@ -346,6 +346,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn append_custom_message_records_the_row() { let worker = created_worker().await; let response = worker @@ -383,6 +384,7 @@ mod tests { /// ` by parent` suffix when the rename is parent-directed); a first /// name, or a rename that keeps the name, leaves none. #[tokio::test] + #[pa_test_scratch::pa_test] async fn rename_leaves_a_displayed_notice_only_when_a_name_changed() { let worker = created_worker_named(None).await; // A first name leaves no notice (there was no previous name). @@ -432,6 +434,7 @@ mod tests { /// `restore_next_turn` parks the rows and the next delivered turn /// replays them first (TS `prefixMessages` order). #[tokio::test] + #[pa_test_scratch::pa_test] async fn restore_next_turn_replays_before_the_next_prompt() { let worker = created_worker().await; let response = worker @@ -475,6 +478,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn restore_actions_restores_and_validates() { let worker = created_worker().await; let snapshot = |actions: Value| { @@ -592,6 +596,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn restore_actions_keeps_priority_tags_and_source_fallback() { let worker = created_worker().await; let pause = worker.dispatch("acquire_session_input_pause", &json!({ @@ -680,6 +685,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn restore_actions_refuses_the_reserved_child_status_kinds() { let worker = created_worker().await; let notice_row = json!({ @@ -738,6 +744,7 @@ mod tests { /// A restored queued heartbeat still reads `Heartbeat prompt: ` and delivers as the /// `heartbeat_prompt` component. #[tokio::test] + #[pa_test_scratch::pa_test] async fn restore_actions_restores_the_labeled_preview() { let worker = created_worker().await; let content = "[heartbeat: every 10m run#0]\n\nnudge the mission"; @@ -868,6 +875,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn reload_answers_success() { let worker = created_worker().await; let response = worker @@ -884,6 +892,7 @@ mod tests { /// back onto the executor. #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] + #[pa_test_scratch::pa_test] async fn reload_parks_the_engine_reload_off_the_runtime() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() diff --git a/crates/pa-daemon/src/session_export.rs b/crates/pa-daemon/src/session_export.rs index 17a451de9..4910d2e25 100644 --- a/crates/pa-daemon/src/session_export.rs +++ b/crates/pa-daemon/src/session_export.rs @@ -324,6 +324,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn export_html_writes_the_session_data() { let dir = tempfile::TempDir::new().expect("temp dir"); let core = Arc::new(Mutex::new(core_with_session(dir.path()))); @@ -347,6 +348,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn export_jsonl_rechains_the_branch() { let dir = tempfile::TempDir::new().expect("temp dir"); let core = Arc::new(Mutex::new(core_with_session(dir.path()))); @@ -380,6 +382,7 @@ mod tests { assert_eq!(second["parentId"], "e1"); } + #[pa_test_scratch::pa_test] #[test] fn jsonl_export_refuses_the_source_and_a_live_destination() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -416,6 +419,7 @@ mod tests { assert_eq!(std::fs::read(&source).expect("source bytes"), source_before); } + #[pa_test_scratch::pa_test] #[test] fn failed_jsonl_export_preserves_the_source_and_existing_destination() { let dir = tempfile::TempDir::new().expect("temp dir"); @@ -446,6 +450,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn export_requires_the_session_store() { let dir = tempfile::TempDir::new().expect("temp dir"); let mut core = core_with_session(dir.path()); diff --git a/crates/pa-daemon/src/session_input_pause.rs b/crates/pa-daemon/src/session_input_pause.rs index 5543c0504..d764eebbc 100644 --- a/crates/pa-daemon/src/session_input_pause.rs +++ b/crates/pa-daemon/src/session_input_pause.rs @@ -267,6 +267,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn internal_pause_releases_only_its_own_hold_on_drop() { let table = InputPauseTable::new(); let notify = std::sync::Arc::new(tokio::sync::Notify::new()); @@ -287,6 +288,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_pause_wakes_idle_wait_holding_queued_input() { let worker = created_worker().await; { @@ -334,6 +336,7 @@ mod tests { /// Wire shape: acquire answers `{ pauseId }`, the same lease /// deduplicates to the same id, a different lease mints a new one. #[tokio::test] + #[pa_test_scratch::pa_test] async fn acquire_dedupes_on_the_lease_key() { let worker = created_worker().await; let first = worker @@ -376,6 +379,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn release_answers_the_ts_outcome_ladder() { let worker = created_worker().await; let acquire = worker @@ -425,6 +429,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_gate_holds_queued_input_until_released() { let worker = created_worker().await; worker diff --git a/crates/pa-daemon/src/session_navigation.rs b/crates/pa-daemon/src/session_navigation.rs index c52132137..3a3fa8478 100644 --- a/crates/pa-daemon/src/session_navigation.rs +++ b/crates/pa-daemon/src/session_navigation.rs @@ -510,6 +510,7 @@ mod tests { )); } + #[pa_test_scratch::pa_test] #[test] fn import_publication_never_overwrites_and_respects_the_append_lock() { let dir = tempfile::tempdir().unwrap(); @@ -535,6 +536,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn import_prepare_preserves_current_bytes_on_invalid_sources_and_collisions() { let worker = created_worker().await; let dir = tempfile::tempdir().unwrap(); @@ -582,6 +584,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn new_session_answers_the_ts_cancelled_shape() { let worker = created_worker().await; let response = worker @@ -598,6 +601,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn switch_session_replaces_the_store_and_fails_on_missing_files() { let worker = created_worker().await; let response = worker @@ -622,6 +626,7 @@ mod tests { // awaited turns that consume its queue. #[allow(clippy::await_holding_lock)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn replacement_flows_retire_only_on_a_prepared_file() { let _faux = crate::agent_engine::FAUX_TEST_LOCK .lock() @@ -741,6 +746,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn switch_session_rebinds_the_worker_cwd_and_new_session_keeps_it() { let worker = created_worker().await; let state = worker @@ -811,6 +817,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn fork_rebinds_the_scheduled_jobs_onto_the_forked_session() { let dir = tempfile::TempDir::new().expect("temp dir"); let sessions_dir = dir.path().join("sessions"); @@ -897,6 +904,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn import_jsonl_answers_the_ts_file_not_found_error() { let worker = created_worker().await; let response = worker @@ -921,6 +929,7 @@ mod tests { /// The typed issue carries the fallback cwd the client's confirm answers with. #[tokio::test] + #[pa_test_scratch::pa_test] async fn import_jsonl_answers_the_ts_missing_cwd_error_info() { let dir = std::env::temp_dir().join(format!("pa-import-cwd-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); diff --git a/crates/pa-daemon/src/session_scan.rs b/crates/pa-daemon/src/session_scan.rs index 96091895b..322e45275 100644 --- a/crates/pa-daemon/src/session_scan.rs +++ b/crates/pa-daemon/src/session_scan.rs @@ -111,6 +111,7 @@ mod tests { infos.into_iter().map(|(info, _)| info).collect() } + #[pa_test_scratch::pa_test] #[test] fn rows_match_the_sequential_fold_and_order() { let dir = temp_dir(); @@ -123,17 +124,20 @@ mod tests { assert_eq!(scanned[0].name.as_deref(), Some("gamma")); } + #[pa_test_scratch::pa_test] #[test] fn empty_dir_lists_nothing() { let dir = temp_dir(); assert!(list_sessions(&dir).is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn missing_dir_lists_nothing() { assert!(list_sessions(&temp_dir().join("absent")).is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn skips_a_file_whose_first_parseable_line_is_not_the_session_header() { let dir = temp_dir(); @@ -161,6 +165,7 @@ mod tests { assert!(list_sessions(&dir).is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn rejects_a_corrupt_first_line_even_when_a_later_header_is_valid() { let dir = temp_dir(); @@ -170,6 +175,7 @@ mod tests { assert!(list_sessions(&dir).is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn rejects_a_blank_first_line_in_a_log() { let dir = temp_dir(); @@ -179,6 +185,7 @@ mod tests { assert!(list_sessions(&dir).is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn still_lists_a_file_with_an_over_long_header_line() { let dir = temp_dir(); @@ -196,6 +203,7 @@ mod tests { assert_eq!(scanned[0].cwd, long_cwd); } + #[pa_test_scratch::pa_test] #[test] // Runs on demand: `cargo test -p pa-daemon --release -- --ignored roster_scan_wall_clock // --nocapture`. @@ -219,6 +227,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn list_sessions_with_emits_rows_newest_first_with_scan_counts() { let dir = temp_dir(); @@ -260,6 +269,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn list_sessions_with_stops_when_the_consumer_stops() { let dir = temp_dir(); diff --git a/crates/pa-daemon/src/session_stats/tests.rs b/crates/pa-daemon/src/session_stats/tests.rs index f610362a3..1aa66ea87 100644 --- a/crates/pa-daemon/src/session_stats/tests.rs +++ b/crates/pa-daemon/src/session_stats/tests.rs @@ -6,6 +6,7 @@ use crate::session_store::log_reader_tests::write_jsonl_fixture; /// The captured-attribution fixture end to end: the folded totals — cost /// $0 → $0.0089957, input 2690 → 52898 — `totalTokens` stays 23032. +#[pa_test_scratch::pa_test] #[test] fn captured_attribution_fixture_stats_count_the_fold() { let path = crate::session_store::log_reader_tests::captured_attribution_log(); @@ -94,6 +95,7 @@ fn entry_with_usage(total_tokens: u64) -> (&'static str, Value) { } /// The usage accounting bridges the gap. +#[pa_test_scratch::pa_test] #[test] fn ghost_gap_does_not_zero_the_token_totals() { let dir = tempfile::TempDir::new().unwrap(); @@ -134,6 +136,7 @@ fn ghost_gap_does_not_zero_the_token_totals() { assert_eq!(stats["userMessages"], json!(2)); } +#[pa_test_scratch::pa_test] #[test] fn counts_messages_tool_calls_and_tokens() { let store = store_with(&[ @@ -162,6 +165,7 @@ fn counts_messages_tool_calls_and_tokens() { assert_eq!(stats, expected); } +#[pa_test_scratch::pa_test] #[test] fn aborted_assistant_usage_counts_toward_recorded_totals() { let store = store_with(&[ @@ -185,6 +189,7 @@ fn aborted_assistant_usage_counts_toward_recorded_totals() { /// The compaction boundary against the windowed reader: the windowed store /// never loads the pre-cut ancestry and must still report the same active /// numbers as the full store. +#[pa_test_scratch::pa_test] #[test] fn compaction_boundary_serves_the_windowed_reader() { let dir = tempfile::TempDir::new().unwrap(); @@ -283,6 +288,7 @@ fn compaction_boundary_serves_the_windowed_reader() { /// spend TS drops from the active stats; the kept region is what TS reports /// post-compaction. Point `PA_ACTIVE_STATS_CAPTURED_FIXTURE` at a local copy /// to run it (real captures are never committed). +#[pa_test_scratch::pa_test] #[test] #[ignore = "set PA_ACTIVE_STATS_CAPTURED_FIXTURE to the captured session path"] fn captured_compaction_boundary_matches_ts_active_stats() { @@ -321,6 +327,7 @@ fn captured_compaction_boundary_matches_ts_active_stats() { /// The compaction boundary in miniature: kept rows plus a ghost-parent row /// are what the active stats report; the side-question FORK is spend the /// reloaded list drops (it survives on whole-file surfaces). +#[pa_test_scratch::pa_test] #[test] fn compaction_boundary_drops_the_pre_cut_ancestry() { let dir = tempfile::TempDir::new().unwrap(); @@ -401,6 +408,7 @@ fn compaction_boundary_drops_the_pre_cut_ancestry() { /// TS `buildSessionContext` records the last compaction along its leaf-to-root path only, /// so the active line keeps its own full history. +#[pa_test_scratch::pa_test] #[test] fn an_abandoned_branchs_compaction_never_bounds_the_active_list() { let dir = tempfile::TempDir::new().unwrap(); diff --git a/crates/pa-daemon/src/session_store/context_selection.rs b/crates/pa-daemon/src/session_store/context_selection.rs index 36099240f..4aea78133 100644 --- a/crates/pa-daemon/src/session_store/context_selection.rs +++ b/crates/pa-daemon/src/session_store/context_selection.rs @@ -54,6 +54,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn absent_choice_returns_none() { let mut store = SessionFile::create("/repo", None, 0); @@ -63,6 +64,7 @@ mod tests { assert_eq!(store.latest_context_selection().unwrap(), None); } + #[pa_test_scratch::pa_test] #[test] fn valid_latest_choice_wins_without_parsing_older_data() { let mut store = SessionFile::create("/repo", None, 0); @@ -82,6 +84,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn latest_malformed_choice_does_not_skip_older_choice() { for fields in [ @@ -107,6 +110,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn unsupported_choice_version_is_rejected() { let mut store = SessionFile::create("/repo", None, 0); @@ -121,6 +125,7 @@ mod tests { assert!(store.latest_context_selection().is_err()); } + #[pa_test_scratch::pa_test] #[test] fn unknown_choice_field_is_rejected() { let mut store = SessionFile::create("/repo", None, 0); @@ -135,6 +140,7 @@ mod tests { assert!(store.latest_context_selection().is_err()); } + #[pa_test_scratch::pa_test] #[test] fn choice_strategy_requires_a_slash() { let mut store = SessionFile::create("/repo", None, 0); @@ -142,6 +148,7 @@ mod tests { assert!(store.latest_context_selection().is_err()); } + #[pa_test_scratch::pa_test] #[test] fn choice_strategy_matches_the_existing_split_once_validation() { // Schema validation is not strategy lookup: do not add route policy here. @@ -155,6 +162,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn only_matching_custom_entry_type_is_read() { let mut store = SessionFile::create("/repo", None, 0); @@ -181,6 +189,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn choice_is_session_wide_not_limited_to_the_active_branch() { let mut store = SessionFile::create("/repo", None, 0); @@ -200,6 +209,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn choice_outside_retained_window_is_read_from_sparse_metadata() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/session_store/display_tests.rs b/crates/pa-daemon/src/session_store/display_tests.rs index c12946bc6..941f864c0 100644 --- a/crates/pa-daemon/src/session_store/display_tests.rs +++ b/crates/pa-daemon/src/session_store/display_tests.rs @@ -22,6 +22,7 @@ fn display_row(kind: &str, id: &str, parent: Option<&str>, fields: Value) -> Val row } +#[pa_test_scratch::pa_test] #[test] fn display_projection_keeps_chronology_and_branch_local_receipts_without_changing_model_context() { let sent = json!({"id":"receipt","message":"sent","deliveryStatus":"queued","target":{"activeSessionId":"active","sessionId":"session","sessionName":"child"}}); @@ -136,6 +137,7 @@ fn display_projection_keeps_chronology_and_branch_local_receipts_without_changin ); } +#[pa_test_scratch::pa_test] #[test] fn display_projection_refuses_missing_parents_and_cycles() { for rows in [ diff --git a/crates/pa-daemon/src/session_store/info.rs b/crates/pa-daemon/src/session_store/info.rs index 416cf8853..e4feb4732 100644 --- a/crates/pa-daemon/src/session_store/info.rs +++ b/crates/pa-daemon/src/session_store/info.rs @@ -749,6 +749,7 @@ pub fn find_most_recent_session_for_cwd(session_dir: &Path, cwd: &str) -> Option mod cache_tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn cached_prefix_resume_subtracts_a_duplicate_attribution_once() { use std::io::{BufReader, Seek, SeekFrom}; @@ -795,6 +796,7 @@ mod cache_tests { dir.close().unwrap(); } + #[pa_test_scratch::pa_test] #[test] fn attribution_ids_share_the_retained_usage_budget_and_trigger_lru_eviction() { let generation = SessionInfoGeneration { diff --git a/crates/pa-daemon/src/session_store/log_reader_tests.rs b/crates/pa-daemon/src/session_store/log_reader_tests.rs index b0e98a709..24d6c50b4 100644 --- a/crates/pa-daemon/src/session_store/log_reader_tests.rs +++ b/crates/pa-daemon/src/session_store/log_reader_tests.rs @@ -71,6 +71,7 @@ fn fixture(dir: &Path, id: &str) -> (SessionLog, PathBuf) { (log, dir.join(session_file_name(id))) } +#[pa_test_scratch::pa_test] #[test] fn log_readers_list_headers_and_resume_a_sidecar_from_real_rows() { let dir = tempfile::tempdir().unwrap(); @@ -98,6 +99,7 @@ fn log_readers_list_headers_and_resume_a_sidecar_from_real_rows() { assert_eq!(read_session_info(&path), Some(resumed)); } +#[pa_test_scratch::pa_test] #[test] fn log_reader_ignores_a_torn_append_without_mutating_or_locking() { let dir = tempfile::tempdir().unwrap(); @@ -118,6 +120,7 @@ fn log_reader_ignores_a_torn_append_without_mutating_or_locking() { assert_eq!(fs::read(&path).unwrap(), bytes); } +#[pa_test_scratch::pa_test] #[test] fn log_reader_cannot_tell_an_edited_bare_row_from_an_original_one() { let dir = tempfile::tempdir().unwrap(); @@ -135,6 +138,7 @@ fn log_reader_cannot_tell_an_edited_bare_row_from_an_original_one() { ); } +#[pa_test_scratch::pa_test] #[test] fn log_reader_refuses_a_malformed_line_and_leaves_the_bytes() { let dir = tempfile::tempdir().unwrap(); @@ -147,6 +151,7 @@ fn log_reader_refuses_a_malformed_line_and_leaves_the_bytes() { assert_eq!(fs::read(&path).unwrap(), bytes, "no implicit repair"); } +#[pa_test_scratch::pa_test] #[test] fn log_reader_folds_a_legacy_bare_log_without_repair() { let dir = tempfile::tempdir().unwrap(); @@ -160,6 +165,7 @@ fn log_reader_folds_a_legacy_bare_log_without_repair() { assert_eq!(fs::read(&path).unwrap(), header.as_bytes()); } +#[pa_test_scratch::pa_test] #[test] fn log_archive_round_trip_preserves_bytes_and_catalog_identity() { let dir = tempfile::tempdir().unwrap(); @@ -196,6 +202,7 @@ fn log_archive_round_trip_preserves_bytes_and_catalog_identity() { assert_eq!(list_sessions(&sessions), vec![resolved]); } +#[pa_test_scratch::pa_test] #[test] fn log_archive_does_not_move_a_locked_or_protected_session() { let dir = tempfile::tempdir().unwrap(); @@ -237,6 +244,7 @@ fn log_archive_does_not_move_a_locked_or_protected_session() { assert!(path.is_file()); } +#[pa_test_scratch::pa_test] #[test] #[ignore = "subprocess execution-lock holder for the archive regression"] fn archive_execution_holder() { @@ -249,6 +257,7 @@ fn archive_execution_holder() { std::io::stdin().read_line(&mut release).unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn log_archive_spares_an_execution_owned_by_a_foreign_process() { use std::io::{BufRead, BufReader}; @@ -317,6 +326,7 @@ fn log_archive_spares_an_execution_owned_by_a_foreign_process() { ); } +#[pa_test_scratch::pa_test] #[test] fn log_restore_refuses_a_held_source_or_live_target_execution_lock() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/session_store/tests.rs b/crates/pa-daemon/src/session_store/tests.rs index 5ba5df8f3..2c180f24c 100644 --- a/crates/pa-daemon/src/session_store/tests.rs +++ b/crates/pa-daemon/src/session_store/tests.rs @@ -17,6 +17,7 @@ fn captured_attribution_fixture() -> PathBuf { super::log_reader_tests::captured_attribution_log() } +#[pa_test_scratch::pa_test] #[test] fn bounded_header_matches_the_line_read() { let dir = temp_dir(); @@ -32,6 +33,7 @@ fn bounded_header_matches_the_line_read() { assert!(is_valid_session_file(&path)); } +#[pa_test_scratch::pa_test] #[test] fn bounded_header_rejects_a_non_json_first_line() { let dir = temp_dir(); @@ -41,6 +43,7 @@ fn bounded_header_rejects_a_non_json_first_line() { assert!(!is_valid_session_file(&path)); } +#[pa_test_scratch::pa_test] #[test] fn bounded_header_refuses_an_over_long_first_line() { let dir = temp_dir(); @@ -54,6 +57,7 @@ fn bounded_header_refuses_an_over_long_first_line() { assert!(read_session_header(&path).is_some()); } +#[pa_test_scratch::pa_test] #[test] fn bounded_header_refuses_an_unterminated_first_line() { let dir = temp_dir(); @@ -67,6 +71,7 @@ fn bounded_header_refuses_an_unterminated_first_line() { assert!(read_session_header(&path).is_none()); } +#[pa_test_scratch::pa_test] #[test] fn bounded_header_strips_a_crlf_line_return() { let dir = temp_dir(); @@ -82,6 +87,7 @@ fn bounded_header_strips_a_crlf_line_return() { ); } +#[pa_test_scratch::pa_test] #[test] fn bounded_header_treats_an_empty_file_as_headerless() { let dir = temp_dir(); @@ -91,6 +97,7 @@ fn bounded_header_treats_an_empty_file_as_headerless() { assert!(!is_valid_session_file(&path)); } +#[pa_test_scratch::pa_test] #[test] fn open_folds_captured_child_usage_attributions() { let store = SessionFile::open(&captured_attribution_fixture()).unwrap(); @@ -107,6 +114,7 @@ fn open_folds_captured_child_usage_attributions() { assert_eq!(usage["cost"]["total"].as_f64(), Some(0.008_995_7)); } +#[pa_test_scratch::pa_test] #[test] fn append_entry_folds_a_live_child_usage_attribution() { let mut store = SessionFile::create("/tmp", None, 0); @@ -142,6 +150,7 @@ fn append_entry_folds_a_live_child_usage_attribution() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_malformed_aggregate_does_not_zero_the_target_row() { let mut store = SessionFile::create("/tmp", None, 0); @@ -169,6 +178,7 @@ fn a_malformed_aggregate_does_not_zero_the_target_row() { } /// The end-of-load fold installs the newest cumulative aggregate (TS in-process fold parity). +#[pa_test_scratch::pa_test] #[test] fn the_depth_two_chain_reports_the_folded_aggregate() { let dir = tempfile::TempDir::new().unwrap(); @@ -256,6 +266,7 @@ fn the_depth_two_chain_reports_the_folded_aggregate() { /// [`SessionFile::open_windowed`]) hydrate the gate from the file — the /// reattach/resume contract: a session that warned once never warns again /// however it reopens. A fresh session serves the gate closed. +#[pa_test_scratch::pa_test] #[test] fn marking_the_warning_persists_and_both_reopens_hydrate_it() { let dir = temp_dir(); @@ -309,6 +320,7 @@ fn marking_the_warning_persists_and_both_reopens_hydrate_it() { /// disagreed, so the two reopen paths answered differently on the same /// file (and `install_full_history` could overwrite the windowed /// answer with the full scan's). +#[pa_test_scratch::pa_test] #[test] fn an_off_branch_marker_never_hydrates_the_full_open_gate() { let dir = temp_dir(); @@ -386,6 +398,7 @@ fn an_off_branch_marker_never_hydrates_the_full_open_gate() { .anthropic_warning_shown()); } +#[pa_test_scratch::pa_test] #[test] fn creates_and_loads_a_session() { let dir = temp_dir(); @@ -416,6 +429,7 @@ fn creates_and_loads_a_session() { } /// A cyclic file would otherwise hang the create's blocking task. +#[pa_test_scratch::pa_test] #[test] fn a_cyclic_parent_chain_terminates_the_branch_walk() { let mut session = SessionFile::create("/tmp", None, 0); @@ -440,6 +454,7 @@ fn a_cyclic_parent_chain_terminates_the_branch_walk() { } /// A malformed or empty level never replaces a prior good one. +#[pa_test_scratch::pa_test] #[test] fn scan_keeps_the_latest_persisted_thinking_level() { let dir = temp_dir(); @@ -455,6 +470,7 @@ fn scan_keeps_the_latest_persisted_thinking_level() { } /// The in-memory index only adopts entries the file accepted. +#[pa_test_scratch::pa_test] #[test] fn failed_persist_keeps_the_store_walkable() { let dir = temp_dir(); @@ -506,6 +522,7 @@ fn failed_persist_keeps_the_store_walkable() { /// The replay's dedup predicate is the disclosure row's fields: the exact /// row is recognized wherever it came from; a different disclosure stays distinct. +#[pa_test_scratch::pa_test] #[test] fn declaration_stamped_entry_survives_reload_as_the_same_identity() { let dir = temp_dir(); @@ -553,6 +570,7 @@ fn declaration_stamped_entry_survives_reload_as_the_same_identity() { /// The missing id was minted but never persisted, so the walk continues from the gap entry's /// file predecessor (the writer's leaf at the time). +#[pa_test_scratch::pa_test] #[test] fn branch_bridged_bridges_ghost_parent_gaps() { let dir = temp_dir(); @@ -589,6 +607,7 @@ fn branch_bridged_bridges_ghost_parent_gaps() { let _ = fs::remove_dir_all(&dir); } +#[pa_test_scratch::pa_test] #[test] fn branch_bridged_skips_abandoned_chains_after_a_persisted_branch_move() { let dir = temp_dir(); @@ -617,6 +636,7 @@ fn branch_bridged_skips_abandoned_chains_after_a_persisted_branch_move() { } /// Forked-off entries stay excluded; only a MISSING parent bridges. +#[pa_test_scratch::pa_test] #[test] fn branch_bridged_matches_the_strict_walk_on_clean_files() { let dir = temp_dir(); @@ -648,6 +668,7 @@ fn branch_bridged_matches_the_strict_walk_on_clean_files() { let _ = fs::remove_dir_all(&dir); } +#[pa_test_scratch::pa_test] #[test] fn scan_builds_transcript_search_text() { let dir = temp_dir(); @@ -674,6 +695,7 @@ fn scan_builds_transcript_search_text() { /// Raw usage keyed by id, aggregates replacing raw blocks, child spend /// subtracted — `session_usage`'s tests pin the fold, this pins the scan's wiring. +#[pa_test_scratch::pa_test] #[test] fn scan_folds_the_saved_row_usage_summary() { let dir = temp_dir(); @@ -734,6 +756,7 @@ fn scan_folds_the_saved_row_usage_summary() { } /// TS `JSON.parse` keeps the row, so every present field survives the partial block. +#[pa_test_scratch::pa_test] #[test] fn scan_keeps_messages_with_partial_usage_objects() { let dir = temp_dir(); @@ -764,6 +787,7 @@ fn scan_keeps_messages_with_partial_usage_objects() { let _ = fs::remove_dir_all(&dir); } +#[pa_test_scratch::pa_test] #[test] fn scan_omits_usage_without_billable_work() { let dir = temp_dir(); @@ -778,6 +802,7 @@ fn scan_omits_usage_without_billable_work() { let _ = fs::remove_dir_all(&dir); } +#[pa_test_scratch::pa_test] #[test] fn transcript_search_text_caps_at_the_ts_limit() { let dir = temp_dir(); @@ -803,6 +828,7 @@ fn transcript_search_text_caps_at_the_ts_limit() { let _ = fs::remove_dir_all(&dir); } +#[pa_test_scratch::pa_test] #[test] fn search_text_char_counter_stays_in_lockstep_with_the_corpus() { // The O(1) running counter must equal `chars().count()` of the corpus at @@ -836,6 +862,7 @@ fn search_text_char_counter_stays_in_lockstep_with_the_corpus() { assert_eq!(acc.search_text_chars, SESSION_LIST_SEARCH_TEXT_MAX_CHARS); } +#[pa_test_scratch::pa_test] #[test] fn search_text_char_counter_matches_the_legacy_append() { // The reference append (the pre-counter shape: count, then extend) must produce the same @@ -867,6 +894,7 @@ fn search_text_char_counter_matches_the_legacy_append() { } } +#[pa_test_scratch::pa_test] #[test] fn search_text_counter_lockstep_names_every_corpus_mutation_path() { // Every corpus-mutating path at the accumulator level: (1) a fresh fold's @@ -974,6 +1002,7 @@ fn search_text_counter_lockstep_names_every_corpus_mutation_path() { ); } +#[pa_test_scratch::pa_test] #[test] fn durable_first_kept_entry_id_pins_the_boundary_the_read_retains() { // The parity scenario the frame diff caught: the engine reports an id that @@ -1023,6 +1052,7 @@ fn durable_first_kept_entry_id_pins_the_boundary_the_read_retains() { assert_eq!(crate::types::message_text(&messages[2]), "second turn done"); } +#[pa_test_scratch::pa_test] #[test] fn entry_chain_links_parents() { let mut session = SessionFile::create("/tmp", None, 0); @@ -1036,6 +1066,7 @@ fn entry_chain_links_parents() { } /// The id mint checks collisions against the maintained `by_id` index, not a rebuilt map. +#[pa_test_scratch::pa_test] #[test] fn append_cost_does_not_grow_with_the_store() { let mut small = SessionFile::create("/tmp", None, 0); @@ -1069,6 +1100,7 @@ fn append_cost_does_not_grow_with_the_store() { ); } +#[pa_test_scratch::pa_test] #[test] fn malformed_complete_rows_are_refused_without_repair() { let dir = temp_dir(); @@ -1090,6 +1122,7 @@ fn malformed_complete_rows_are_refused_without_repair() { /// Scalar settings restoration must not consume or clear an accepted context /// archive. The real core model-context builders still recover it afterwards. +#[pa_test_scratch::pa_test] #[test] fn windowed_settings_projection_preserves_the_accepted_context_archive() { let dir = tempfile::tempdir().unwrap(); @@ -1185,6 +1218,7 @@ fn windowed_settings_projection_preserves_the_accepted_context_archive() { /// (verified against the TS binary's session file, battery run /// 20260921T140248Z): type, id, parentId, timestamp, summary, firstKeptEntryId, /// tokensBefore, details, fromHook, customInstructions?, usage. +#[pa_test_scratch::pa_test] #[test] fn durable_compaction_row_serializes_in_the_ts_key_order() { let entry = pa_types::session::CompactionEntry { @@ -1265,6 +1299,7 @@ fn durable_compaction_row_serializes_in_the_ts_key_order() { ); } +#[pa_test_scratch::pa_test] #[test] fn resume_tail_window_matches_the_rolling_reference() { let mut state = SessionScanState::fresh(SessionInfoGeneration { @@ -1315,6 +1350,7 @@ fn resume_tail_window_matches_the_rolling_reference() { assert_eq!(state.tail, reference); } +#[pa_test_scratch::pa_test] #[test] fn session_header_line_leads_with_the_type_tag() { let header = SessionHeader { @@ -1331,6 +1367,7 @@ fn session_header_line_leads_with_the_type_tag() { assert!(line.starts_with("{\"type\":\"session\",\"version\":3,\"id\":\"abc\"")); } +#[pa_test_scratch::pa_test] #[test] fn listing_and_frozen_usage_agree_on_duplicate_attribution_ids() { let dir = temp_dir(); @@ -1379,6 +1416,7 @@ fn listing_and_frozen_usage_agree_on_duplicate_attribution_ids() { fs::remove_dir_all(dir).unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn real_reopen_preserves_exact_typed_header_and_unknown_fields_for_live_owner() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/session_store_info_tests.rs b/crates/pa-daemon/src/session_store_info_tests.rs index 3df9b3883..405d1e445 100644 --- a/crates/pa-daemon/src/session_store_info_tests.rs +++ b/crates/pa-daemon/src/session_store_info_tests.rs @@ -219,6 +219,7 @@ fn reencode(content: &str) -> String { fs::read_to_string(path).unwrap() } +#[pa_test_scratch::pa_test] #[test] #[ignore = "writes fixtures through the durable append path for byte-equivalence evidence"] fn bulk_large_session_fixture_matches_durable_appends() { @@ -228,6 +229,7 @@ fn bulk_large_session_fixture_matches_durable_appends() { session_fixture::assert_durable_equivalent(&path); } +#[pa_test_scratch::pa_test] #[test] #[ignore = "writes fixtures through the durable append path for byte-equivalence evidence"] fn bulk_zero_usage_session_fixtures_match_durable_appends() { @@ -259,6 +261,7 @@ fn bulk_large_session_fixture(path: &Path) { assert_eq!(fixture.finish(), 2_005); } +#[pa_test_scratch::pa_test] #[test] fn streaming_fold_matches_legacy_across_large_file_and_appends() { let dir = test_dir(); @@ -279,6 +282,7 @@ fn streaming_fold_matches_legacy_across_large_file_and_appends() { fs::remove_dir_all(dir).unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn cache_rejects_replacement_and_same_length_in_place_rewrite() { let dir = test_dir(); @@ -311,6 +315,7 @@ fn cache_rejects_replacement_and_same_length_in_place_rewrite() { fs::remove_dir_all(dir).unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn untimestamped_fallback_is_not_cached() { let dir = test_dir(); @@ -329,6 +334,7 @@ fn untimestamped_fallback_is_not_cached() { fs::remove_dir_all(dir).unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn captured_fixture_matches_legacy_if_available() { let Ok(path) = std::env::var("PA_SESSION_INFO_CAPTURED_FIXTURE") else { @@ -337,6 +343,7 @@ fn captured_fixture_matches_legacy_if_available() { assert_fold_matches(Path::new(&path)); } +#[pa_test_scratch::pa_test] #[test] #[ignore = "run with PA_SESSION_INFO_CAPTURED_FIXTURE to benchmark the real corpus"] fn captured_fixture_cold_and_warm_timings() { @@ -367,6 +374,7 @@ fn captured_fixture_cold_and_warm_timings() { ); } +#[pa_test_scratch::pa_test] #[test] fn a_torn_trailing_line_folds_once_completed() { let dir = test_dir(); @@ -399,6 +407,7 @@ fn a_torn_trailing_line_folds_once_completed() { assert!(completed.all_messages_text.contains("torn text")); } +#[pa_test_scratch::pa_test] #[test] fn a_same_size_rewrite_rescans_from_the_top() { let dir = test_dir(); @@ -434,6 +443,7 @@ fn a_same_size_rewrite_rescans_from_the_top() { assert_fold_matches(&path); } +#[pa_test_scratch::pa_test] #[test] fn multi_round_appends_match_the_legacy_fold() { let dir = test_dir(); @@ -457,6 +467,7 @@ fn multi_round_appends_match_the_legacy_fold() { assert_eq!(final_info.message_count, 250); } +#[pa_test_scratch::pa_test] #[test] fn a_failed_prefix_check_rescans_from_byte_zero() { let dir = test_dir(); @@ -509,6 +520,7 @@ fn a_failed_prefix_check_rescans_from_byte_zero() { /// cache (and so persistable) only on Unix - `read_session_info_from`'s /// store gate - so no sidecar exists to load elsewhere. #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn a_persisted_scan_state_resumes_like_the_full_fold() { let dir = test_dir(); @@ -596,6 +608,7 @@ fn a_persisted_scan_state_resumes_like_the_full_fold() { /// it), and scans cold past a corrupt one or one at another version. /// Unix-only like its sibling: only Unix certifies a state to persist. #[cfg(unix)] +#[pa_test_scratch::pa_test] #[test] fn a_symlinked_lease_release_persists_a_sidecar_the_next_read_serves() { let dir = test_dir(); @@ -639,6 +652,7 @@ fn a_symlinked_lease_release_persists_a_sidecar_the_next_read_serves() { fs::remove_dir_all(dir).unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn a_valid_unterminated_final_line_folds_only_after_its_newline() { let dir = test_dir(); @@ -677,6 +691,7 @@ fn bulk_zero_usage_session_fixture(path: &Path, index: usize) { assert_eq!(fixture.finish(), 2); } +#[pa_test_scratch::pa_test] #[test] fn zero_usage_states_are_capped_by_count_not_only_the_usage_budget() { let dir = test_dir(); @@ -707,6 +722,7 @@ fn zero_usage_states_are_capped_by_count_not_only_the_usage_budget() { )))); } +#[pa_test_scratch::pa_test] #[test] fn scan_cache_recency_tracks_updates_and_removals_without_growth() { let dir = test_dir(); @@ -753,6 +769,7 @@ fn scan_cache_recency_tracks_updates_and_removals_without_growth() { /// The old-record regression (the Mac bug's shape): `modified` is the /// header's creation timestamp, never a scan-time `now()`. +#[pa_test_scratch::pa_test] #[test] fn no_timestamp_record_modified_is_the_header_time_across_rescans() { let dir = test_dir(); @@ -785,6 +802,7 @@ fn no_timestamp_record_modified_is_the_header_time_across_rescans() { } /// TS falls to `stats.mtime` — including after an mtime cache bust — never the scan time. +#[pa_test_scratch::pa_test] #[test] fn unparseable_header_modified_falls_back_to_the_file_mtime() { let dir = test_dir(); @@ -809,6 +827,7 @@ fn unparseable_header_modified_falls_back_to_the_file_mtime() { fs::remove_dir_all(dir).unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn message_timestamps_still_win_over_the_header_fallback() { let dir = test_dir(); @@ -834,6 +853,7 @@ fn message_timestamps_still_win_over_the_header_fallback() { /// The parser rejects an impossible calendar date (2026-02-31) instead of normalizing it /// into March (TS `Date.parse` rejects it too). +#[pa_test_scratch::pa_test] #[test] fn impossible_calendar_date_header_falls_back_to_the_file_mtime() { let dir = test_dir(); @@ -856,6 +876,7 @@ fn impossible_calendar_date_header_falls_back_to_the_file_mtime() { } /// A durable zero stays distinct from an unavailable value (blank). +#[pa_test_scratch::pa_test] #[test] fn epoch_zero_mtime_renders_the_epoch_not_blank() { let dir = test_dir(); @@ -871,6 +892,7 @@ fn epoch_zero_mtime_renders_the_epoch_not_blank() { fs::remove_dir_all(dir).unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn content_borrow_matches_full_parse_across_content_matrix() { let header = @@ -1025,6 +1047,7 @@ fn content_borrow_matches_full_parse_across_content_matrix() { fs::remove_dir_all(empty_dir).unwrap(); } +#[pa_test_scratch::pa_test] #[test] #[allow(clippy::used_underscore_binding)] // the envelope scalars the fold // keeps only for acceptance (`_timestamp`, `_parent_id`) @@ -1252,6 +1275,7 @@ fn borrowed_metadata_reads_match_full_parse_across_shape_matrix() { /// The single-writer premise: a fold by a process that does not hold the /// file's lease (the daemon catalog's cold read) never persists a sidecar. +#[pa_test_scratch::pa_test] #[test] fn a_non_holder_fold_writes_no_sidecar() { let dir = test_dir(); diff --git a/crates/pa-daemon/src/session_store_stream_tests.rs b/crates/pa-daemon/src/session_store_stream_tests.rs index f8da38d7b..9c4425bd6 100644 --- a/crates/pa-daemon/src/session_store_stream_tests.rs +++ b/crates/pa-daemon/src/session_store_stream_tests.rs @@ -23,6 +23,7 @@ fn fixture() -> (tempfile::TempDir, std::path::PathBuf) { (dir, path) } +#[pa_test_scratch::pa_test] #[test] fn native_replay_matches_the_read_only_sdk_row_for_row() { let (_dir, path) = fixture(); @@ -42,6 +43,7 @@ fn native_replay_matches_the_read_only_sdk_row_for_row() { assert_eq!(std::fs::read(&path).unwrap(), before); } +#[pa_test_scratch::pa_test] #[test] fn damaged_native_rows_are_refused_without_repair() { // A same-length edit is not damage any more: a bare row carries no @@ -69,6 +71,7 @@ fn damaged_native_rows_are_refused_without_repair() { } } +#[pa_test_scratch::pa_test] #[test] fn legacy_raw_rows_are_refused_without_repair() { let dir = tempfile::tempdir().unwrap(); @@ -79,6 +82,7 @@ fn legacy_raw_rows_are_refused_without_repair() { assert_eq!(std::fs::read(&path).unwrap(), bytes); } +#[pa_test_scratch::pa_test] #[test] fn native_open_keeps_the_empty_and_missing_header_errors() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/session_store_window_tests.rs b/crates/pa-daemon/src/session_store_window_tests.rs index 54e13cb86..fd77bceeb 100644 --- a/crates/pa-daemon/src/session_store_window_tests.rs +++ b/crates/pa-daemon/src/session_store_window_tests.rs @@ -4,6 +4,7 @@ use super::*; /// compaction boundary: the windowed store's `session_stats` equals the full /// open's — the ACTIVE totals (TS cuts `state.messages` at the compaction) — /// never losing or double-counting the attributed child spend. +#[pa_test_scratch::pa_test] #[test] fn windowed_open_folds_attributions_on_both_sides_of_the_boundary() { let dir = tempfile::tempdir().unwrap(); @@ -87,6 +88,7 @@ fn windowed_open_folds_attributions_on_both_sides_of_the_boundary() { assert_eq!(stats["cost"].as_f64(), Some(0.03)); } +#[pa_test_scratch::pa_test] #[test] fn window_preserves_transcript_metadata_and_append_then_hydrate() { let dir = tempfile::tempdir().unwrap(); @@ -181,6 +183,7 @@ fn window_preserves_transcript_metadata_and_append_then_hydrate() { assert_eq!(reopened.entries.len(), window.entries.len()); } +#[pa_test_scratch::pa_test] #[test] #[ignore = "requires a captured local session path"] fn captured_window_matches_full_transcript_and_stats() { @@ -285,6 +288,7 @@ fn usage_of(input: u64, output: u64, cache_read: u64, total: f64) -> Value { /// One shared walk backs both the materialized fold and the scalar scan: /// across every window shape the scan must reproduce exactly the scalars the /// old full-clone fold computed. +#[pa_test_scratch::pa_test] #[test] fn scan_message_scalars_match_the_materialized_fold_across_window_shapes() { let dir = tempfile::tempdir().unwrap(); @@ -428,6 +432,7 @@ fn scan_message_scalars_match_the_materialized_fold_across_window_shapes() { /// The compaction boundary shapes pin the materialized fold itself (the /// scan's reference): the exact windowed sequence. +#[pa_test_scratch::pa_test] #[test] fn walk_pins_the_compaction_boundary_sequences() { let dir = tempfile::tempdir().unwrap(); @@ -495,6 +500,7 @@ fn assert_windowed_restored_settings_match_the_full_open(name: &str, path: &std: ); } +#[pa_test_scratch::pa_test] #[test] fn windowed_restored_settings_match_the_full_open() { let dir = tempfile::tempdir().unwrap(); @@ -536,6 +542,7 @@ fn windowed_restored_settings_match_the_full_open() { assert_windowed_restored_settings_match_the_full_open("whole-file window", &path); } +#[pa_test_scratch::pa_test] #[test] fn non_message_compaction_boundary_retains_the_persisted_timeline() { for boundary_type in ["custom", "session_state"] { diff --git a/crates/pa-daemon/src/session_transport.rs b/crates/pa-daemon/src/session_transport.rs index 364d8fa9d..c8cd3fcaa 100644 --- a/crates/pa-daemon/src/session_transport.rs +++ b/crates/pa-daemon/src/session_transport.rs @@ -715,6 +715,7 @@ mod tests { /// A row written while a reader scans the same session file: the lock is /// refused three times and then free, so the row must land instead of the /// turn being refused for a holder that was about to release. + #[pa_test_scratch::pa_test] #[test] fn a_transient_lock_holder_is_ridden_out_instead_of_refusing_the_row() { let dir = temp_dir("busy-first"); @@ -867,6 +868,7 @@ mod tests { .success()); } + #[pa_test_scratch::pa_test] #[test] fn fresh_publication_captures_git_without_changing_reopened_absent_git() { let dir = tempfile::tempdir().unwrap(); @@ -907,6 +909,7 @@ mod tests { assert_eq!(std::fs::read(&absent_path).unwrap(), bytes); } + #[pa_test_scratch::pa_test] #[test] fn a_fresh_wire_refuses_identical_and_different_rival_headers() { for same_header in [true, false] { @@ -944,6 +947,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn a_fresh_wire_refuses_torn_bytes_without_repairing_them() { let dir = temp_dir("fresh-torn"); @@ -958,6 +962,7 @@ mod tests { assert_eq!(std::fs::read(path).unwrap(), bytes); } + #[pa_test_scratch::pa_test] #[test] fn an_unknown_first_header_keeps_its_recovery_and_retries_once() { let dir = temp_dir("unknown-first"); @@ -1017,6 +1022,7 @@ mod tests { assert_eq!(log.read_since(0).unwrap().len(), 2); } + #[pa_test_scratch::pa_test] #[test] fn an_undecided_row_retries_into_exactly_one_file_row() { let dir = temp_dir("undecided"); @@ -1077,6 +1083,7 @@ mod tests { assert_eq!(rows[1].body, body); } + #[pa_test_scratch::pa_test] #[test] fn an_exact_path_refuses_legacy_bytes_and_creates_fresh_log_rows() { let dir = temp_dir("exact-path"); @@ -1095,6 +1102,7 @@ mod tests { assert!(replay.entries().is_empty()); } + #[pa_test_scratch::pa_test] #[test] fn a_fresh_wires_first_flush_writes_the_header_then_the_rows() { let dir = temp_dir("fresh-wire"); @@ -1127,6 +1135,7 @@ mod tests { let _ = (user, assistant); } + #[pa_test_scratch::pa_test] #[test] fn a_payload_pathed_fresh_session_rekeys_to_its_path_id() { let dir = temp_dir("rekey"); @@ -1157,6 +1166,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_reopen_replays_the_log_and_flows_new_appends_past_the_cursor() { let dir = temp_dir("reopen"); @@ -1198,6 +1208,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_refused_row_is_durable_nowhere_never_indexed() { let dir = temp_dir("refused"); @@ -1226,6 +1237,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_minimum_serving_path_runs_a_log_session_end_to_end() { let dir = temp_dir("e2e"); let agent_dir = dir.join("agent"); @@ -1384,6 +1396,7 @@ mod tests { .expect("messages array") .clone() } + #[pa_test_scratch::pa_test] #[test] fn an_attribution_aggregates_the_same_way_through_the_log_funnel() { let dir = temp_dir("probe"); @@ -1457,6 +1470,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn review_foreign_rows_join_the_serving_fold_before_append() { let dir = temp_dir("review-follow"); @@ -1488,6 +1502,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn review_public_retry_does_not_duplicate_an_unknown_row() { let dir = temp_dir("review-public-retry"); @@ -1519,6 +1534,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn an_external_repair_of_a_damaged_bare_log_changes_nothing() { let dir = temp_dir("review-repair"); @@ -1570,6 +1586,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn review_selected_branch_survives_sessionfile_reopen() { let dir = temp_dir("review-selection"); @@ -1595,6 +1612,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn review_new_intent_resolves_the_previous_unknown_before_minting() { let dir = temp_dir("review-next-intent"); @@ -1633,6 +1651,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn review_cloned_folds_observe_independent_positions() { let dir = temp_dir("review-clone"); diff --git a/crates/pa-daemon/src/session_tree.rs b/crates/pa-daemon/src/session_tree.rs index 9e0b1cbf1..1dc9d275a 100644 --- a/crates/pa-daemon/src/session_tree.rs +++ b/crates/pa-daemon/src/session_tree.rs @@ -418,6 +418,7 @@ mod tests { (dir, store) } + #[pa_test_scratch::pa_test] #[test] fn flat_tree_carries_labels() { let (_dir, mut store) = temp_store(); @@ -434,6 +435,7 @@ mod tests { assert_eq!(labeled["entry"]["id"], json!(a)); } + #[pa_test_scratch::pa_test] #[test] fn labels_last_write_wins_and_clears() { let (_dir, mut store) = temp_store(); @@ -445,6 +447,7 @@ mod tests { assert_eq!(state.labels.get(&a), None); } + #[pa_test_scratch::pa_test] #[test] fn user_messages_for_forking_lists_texted_user_messages() { let (_dir, mut store) = temp_store(); @@ -460,6 +463,7 @@ mod tests { assert_eq!(messages[0]["text"], json!("first prompt")); } + #[pa_test_scratch::pa_test] #[test] fn branch_to_moves_leaf_and_validates() { let (_dir, mut store) = temp_store(); @@ -476,6 +480,7 @@ mod tests { assert_eq!(store.leaf_id(), None); } + #[pa_test_scratch::pa_test] #[test] fn branch_summary_preserves_paid_output_and_unknown_details() { let (_dir, mut store) = temp_store(); @@ -502,6 +507,7 @@ mod tests { assert_eq!(entry.parent_id.as_deref(), Some(parent.as_str())); } + #[pa_test_scratch::pa_test] #[test] fn branch_summary_entry_shape() { let (_dir, mut store) = temp_store(); @@ -527,6 +533,7 @@ mod tests { /// A summary served by an auxiliary model persists its serving identity on /// the entry: the per-model cost fold bills the row on the model that billed it. + #[pa_test_scratch::pa_test] #[test] fn branch_summary_entry_records_the_serving_model() { let (_dir, mut store) = temp_store(); @@ -551,6 +558,7 @@ mod tests { assert_eq!(entry.fields["usage"]["totalTokens"], json!(55)); } + #[pa_test_scratch::pa_test] #[test] fn fork_file_keeps_path_and_carries_labels() { let (dir, mut store) = temp_store(); @@ -576,6 +584,7 @@ mod tests { let _ = c; } + #[pa_test_scratch::pa_test] #[test] fn replace_with_branch_swaps_in_memory_entries() { let (_dir, mut store) = temp_store(); @@ -594,6 +603,7 @@ mod tests { /// file — a fork whose kept path carries the marker answers open (its /// first open draws no second warning), and a fork cut ABOVE the /// marker (the genuinely-new-session case) answers closed. + #[pa_test_scratch::pa_test] #[test] fn forked_stores_hydrate_the_warning_gate_from_their_own_rows() { let (dir, mut store) = temp_store(); @@ -635,6 +645,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn file_entries_round_trip() { let (_dir, mut store) = temp_store(); @@ -643,6 +654,7 @@ mod tests { assert_eq!(entries.len(), 1); assert_eq!(entries[0].id().unwrap(), a); } + #[pa_test_scratch::pa_test] #[test] fn selection_survives_reopen_without_a_following_message() { let dir = tempfile::tempdir().unwrap(); @@ -668,6 +680,7 @@ mod tests { store.branch_to(None).unwrap(); assert_eq!(SessionFile::open(&path).unwrap().leaf_id(), None); } + #[pa_test_scratch::pa_test] #[test] fn legacy_open_never_repairs_or_rewrites_the_source() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/session_usage.rs b/crates/pa-daemon/src/session_usage.rs index f1964877f..3f5354ad3 100644 --- a/crates/pa-daemon/src/session_usage.rs +++ b/crates/pa-daemon/src/session_usage.rs @@ -493,6 +493,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn duplicate_attribution_ids_subtract_once_and_preserve_latest_aggregate() { let assistant = message( @@ -531,6 +532,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn orphan_ids_are_not_consumed_and_legacy_attributions_remain_distinct() { let mut orphan = attribution("a", &usage(20, 2, 2.0), &usage(120, 12, 10.0)); @@ -567,6 +569,7 @@ mod tests { /// The latest aggregate replaces the raw block, every child block /// accumulates, and the summary subtracts the child spend (no double count). + #[pa_test_scratch::pa_test] #[test] fn latest_aggregate_replaces_raw_and_child_usage_accumulates() { let summary = scan_summary(&[ @@ -599,6 +602,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn attribution_without_a_present_target_folds_nothing() { let assistant = message( @@ -634,6 +638,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn summarization_usage_is_added() { let summary = scan_summary(&[ @@ -670,6 +675,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn no_billable_work_is_none() { assert_eq!(scan_summary(&[]), None); @@ -690,6 +696,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn child_attribution_drift_clamps_at_zero() { let summary = scan_summary(&[ @@ -709,6 +716,7 @@ mod tests { } /// The map keeps first-insertion order so the cost sums stay bit-identical to the TS fold. + #[pa_test_scratch::pa_test] #[test] fn cost_sums_follow_insertion_order() { let line = |id: &str, cost: f64| { @@ -729,6 +737,7 @@ mod tests { /// TS `JSON.parse` keeps the row (absent fields count as zero) — the wire shape is /// `{input, output, totalTokens}` without `cacheRead`/`cacheWrite`/`cost`. + #[pa_test_scratch::pa_test] #[test] fn partial_usage_objects_keep_the_row() { let summary = scan_summary(&[ @@ -749,6 +758,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn overflowing_usage_saturates_never_panics() { let line = |id: &str| { @@ -773,6 +783,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn read_own_usage_summary_scans_a_file() { use std::io::Write; @@ -821,6 +832,7 @@ mod tests { /// `SAVED_USAGE_FIXTURE= cargo test --ignored`. The devbox /// fixture pins the fold against the TS-computed summary: own spend only — /// the attributed child spend stays on the child rows. + #[pa_test_scratch::pa_test] #[test] #[ignore = "needs a captured session fixture (SAVED_USAGE_FIXTURE)"] fn captured_session_summary_matches_the_ts_fold() { diff --git a/crates/pa-daemon/src/setting_switches.rs b/crates/pa-daemon/src/setting_switches.rs index 37a2c6648..f6b6d038d 100644 --- a/crates/pa-daemon/src/setting_switches.rs +++ b/crates/pa-daemon/src/setting_switches.rs @@ -610,6 +610,7 @@ mod tests { /// (not "auto"), steering "all" (queued steers co-deliver as ONE turn), /// follow-up "one-at-a-time". #[tokio::test] + #[pa_test_scratch::pa_test] async fn connection_state_seeds_the_settings_switches() { let worker = created_worker().await; let response = worker @@ -663,6 +664,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cycle_model_on_a_non_switching_engine_fails_like_set_model() { let dir = std::env::temp_dir().join(format!("pa-worker-cm2-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -687,6 +689,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cycle_model_refuses_models_outside_the_allowlist() { let dir = std::env::temp_dir().join(format!("pa-worker-cm3-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -735,6 +738,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn create_resolves_the_models_scope_for_the_session() { let dir = std::env::temp_dir().join(format!("pa-worker-scope-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -820,6 +824,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_fresh_scoped_create_persists_the_scoped_startup_pick_in_its_file() { let dir = std::env::temp_dir().join(format!("pa-worker-scope-file-{}", uuid::Uuid::new_v4())); @@ -870,6 +875,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn set_scoped_models_stores_and_validates() { let worker = created_worker().await; let scoped = json!([ @@ -908,6 +914,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cycle_thinking_level_without_reasoning_answers_null() { let worker = created_worker().await; let response = worker @@ -923,6 +930,7 @@ mod tests { /// The durable row keeps the REQUESTED tier while an unsupported request clamps to /// `default` in the active state. #[tokio::test] + #[pa_test_scratch::pa_test] async fn set_service_tier_records_the_durable_row() { let worker = created_worker().await; let tier_rows = |worker: &Worker| { @@ -999,6 +1007,7 @@ mod tests { /// On the scripted engine (no model) the restored preference re-clamps the tier to `default`. #[tokio::test] + #[pa_test_scratch::pa_test] async fn replacement_reseed_restores_the_tier_preference() { let worker = created_worker().await; worker.reseed_service_tier_for_replacement(); @@ -1032,6 +1041,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn set_transport_persists_the_setting() { let dir = std::env::temp_dir().join(format!("pa-worker-tr-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(dir.join("agent")).unwrap(); @@ -1062,6 +1072,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn queue_mode_switches_update_the_state() { let worker = created_worker().await; for (command, field) in [ @@ -1100,6 +1111,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn set_auto_retry_persists_the_toggle() { let dir = std::env::temp_dir().join(format!("pa-worker-ar-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(dir.join("agent")).unwrap(); @@ -1121,6 +1133,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn set_auto_compaction_persists_the_toggle() { let dir = std::env::temp_dir().join(format!("pa-worker-ac-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(dir.join("agent")).unwrap(); @@ -1178,6 +1191,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn set_auto_compaction_fails_without_flipping_on_a_failed_save() { let dir = std::env::temp_dir().join(format!("pa-worker-acf-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -1208,6 +1222,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn abort_retry_answers_success() { let worker = created_worker().await; let response = worker diff --git a/crates/pa-daemon/src/side_question.rs b/crates/pa-daemon/src/side_question.rs index 7fe2d3b7b..63c06f25c 100644 --- a/crates/pa-daemon/src/side_question.rs +++ b/crates/pa-daemon/src/side_question.rs @@ -426,6 +426,7 @@ mod tests { /// The close paths abort every live run and wait for the cancelled events to /// queue: the settle returns only after the terminal frame reached the pump. #[tokio::test] + #[pa_test_scratch::pa_test] async fn shutdown_settle_queues_the_cancelled_events() { let pump = Arc::new(EventPump::new()); let mut receiver = pump.subscribe(); @@ -465,6 +466,7 @@ mod tests { /// A close owns the registry's tail: a racing start is rejected instead of /// being admitted into a worker about to exit (its pane would wedge). #[tokio::test] + #[pa_test_scratch::pa_test] async fn start_during_the_close_is_rejected() { let pump = Arc::new(EventPump::new()); let manager = SideQuestionManager::new( @@ -490,6 +492,7 @@ mod tests { /// The detach abort keeps the registry entry until the run's terminal /// cancelled event queued (a detach racing a close must not empty the registry). #[tokio::test] + #[pa_test_scratch::pa_test] async fn detach_abort_settles_the_entry_it_aborts() { let pump = Arc::new(EventPump::new()); let mut receiver = pump.subscribe(); @@ -536,6 +539,7 @@ mod tests { /// stale entry (the probe runs without awaiting, so the multi-thread /// flavor is required — a current-thread runtime would deadlock). #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + #[pa_test_scratch::pa_test] async fn same_id_restart_after_the_cancelled_event_is_admitted() { let pump = Arc::new(EventPump::new()); let mut receiver = pump.subscribe(); diff --git a/crates/pa-daemon/src/snapshot_stream.rs b/crates/pa-daemon/src/snapshot_stream.rs index 908a3fedd..66477377f 100644 --- a/crates/pa-daemon/src/snapshot_stream.rs +++ b/crates/pa-daemon/src/snapshot_stream.rs @@ -362,6 +362,7 @@ mod tests { }) } + #[pa_test_scratch::pa_test] #[test] fn elision_empties_image_payloads_and_keeps_their_metadata() { let payload = format!("{}{}", tiny_png(64, 32), "A".repeat(500_000)); @@ -393,6 +394,7 @@ mod tests { assert_eq!(messages[2]["content"][0]["text"], json!("done")); } + #[pa_test_scratch::pa_test] #[test] fn elision_marks_unparseable_headers_with_the_size_only() { // A payload whose dimensions do not parse from the bounded prefix carries the byte @@ -406,6 +408,7 @@ mod tests { assert!(block.get("widthPx").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn elision_skips_empty_payloads_and_non_tool_results() { // A user message carrying an image block (the pasted-image wire) stays verbatim: @@ -429,6 +432,7 @@ mod tests { assert!(elided[0]["content"][1].get("elidedBytes").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn the_image_elision_capability_is_the_gate() { assert!(wants_image_elision(&[ @@ -442,6 +446,7 @@ mod tests { assert!(!wants_image_elision(&[])); } + #[pa_test_scratch::pa_test] #[test] fn streamed_result_strips_the_transcript_and_adds_the_stream() { let data = attach_result(&[message(0), message(1)]); @@ -465,6 +470,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn legacy_top_level_transcript_leaves_an_empty_copy() { let mut data = attach_result(&[message(0)]); @@ -476,6 +482,7 @@ mod tests { assert_eq!(streamed["messages"], json!([])); } + #[pa_test_scratch::pa_test] #[test] fn headerless_worker_result_fails_the_attach() { let error = stream_attach( @@ -504,6 +511,7 @@ mod tests { .contains("event cursor")); } + #[pa_test_scratch::pa_test] #[test] fn event_lines_begin_chunk_end_reassemble_the_transcript() { let messages: Vec = (0..5).map(message).collect(); @@ -538,6 +546,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn chunking_respects_the_byte_budget_and_never_splits_a_message() { let big = json!({ "role": "user", "content": "x".repeat(SNAPSHOT_TARGET_CHUNK_BYTES + 1) }); @@ -572,6 +581,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn malformed_transcript_fails_the_transfer_after_the_response() { let mut data = attach_result(&[message(0)]); @@ -603,6 +613,7 @@ mod tests { assert_eq!(line["snapshotId"], streamed["snapshotStream"]["id"]); } + #[pa_test_scratch::pa_test] #[test] fn capabilities_normalize_like_the_supervisor() { let normalized = diff --git a/crates/pa-daemon/src/socket.rs b/crates/pa-daemon/src/socket.rs index 340b60afd..441f873cb 100644 --- a/crates/pa-daemon/src/socket.rs +++ b/crates/pa-daemon/src/socket.rs @@ -260,6 +260,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn missing_path_prepares_as_a_no_op() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -268,6 +269,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_dangling_symlink_is_rejected_as_not_a_socket() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -278,6 +280,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn non_socket_file_at_the_path_is_refused_and_preserved() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -288,6 +291,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn live_listener_is_never_unlinked() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -312,6 +316,7 @@ mod tests { /// (macOS has no `/proc` and the fd probes would always read false). #[cfg(target_os = "linux")] #[tokio::test] + #[pa_test_scratch::pa_test] async fn dropping_the_listener_is_the_graceful_exit_close() { use std::io::Write; use std::os::fd::AsRawFd; @@ -368,6 +373,7 @@ mod tests { /// the dead file the matching identity describes (the still-ours /// direction: a respawn does not wait out the stale-socket path). #[tokio::test] + #[pa_test_scratch::pa_test] async fn exit_cleanup_after_close_spares_a_live_successor_with_a_matching_identity() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -400,6 +406,7 @@ mod tests { /// backlog also refuses, so those platforms never reach this arm). #[cfg(target_os = "linux")] #[tokio::test] + #[pa_test_scratch::pa_test] async fn exit_cleanup_after_close_unlinks_the_dead_still_ours_file() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -415,6 +422,7 @@ mod tests { /// file; the next bind's stale-socket prepare clears it instead. #[cfg(not(target_os = "linux"))] #[tokio::test] + #[pa_test_scratch::pa_test] async fn exit_cleanup_off_linux_preserves_the_dead_file_until_the_next_bind() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -437,6 +445,7 @@ mod tests { /// inode can exactly match a poisoned bind-time identity capture. #[cfg(target_os = "linux")] #[tokio::test] + #[pa_test_scratch::pa_test] async fn exit_cleanup_preserves_a_backlogged_successor_with_a_matching_identity() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -482,6 +491,7 @@ mod tests { #[cfg(target_os = "linux")] #[tokio::test] + #[pa_test_scratch::pa_test] async fn exit_cleanup_unlinks_a_closed_listener_on_a_long_socket_path() { let dir = tempfile::TempDir::new().unwrap(); let deep = dir.path().join("a".repeat(80)).join("b".repeat(80)); @@ -495,6 +505,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn stale_socket_file_is_removed_and_the_path_rebinds() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -508,6 +519,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn unlink_refuses_a_live_listener_even_when_marked_stale() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -520,6 +532,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn unlink_refuses_a_replaced_file_with_a_new_identity() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -539,6 +552,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn unlink_is_a_no_op_when_the_file_is_already_gone() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -548,6 +562,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cleanup_waits_while_a_rival_startup_holds_the_lock() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); @@ -573,6 +588,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn cleanup_is_deferred_while_a_rival_holds_the_lock() { let dir = tempfile::TempDir::new().unwrap(); @@ -590,6 +606,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_stale_cleanup_lock_of_a_crashed_holder_is_reclaimed() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("daemon.sock"); diff --git a/crates/pa-daemon/src/state_getters/state_getters_tests.rs b/crates/pa-daemon/src/state_getters/state_getters_tests.rs index d8293c976..71db7931c 100644 --- a/crates/pa-daemon/src/state_getters/state_getters_tests.rs +++ b/crates/pa-daemon/src/state_getters/state_getters_tests.rs @@ -62,6 +62,7 @@ async fn created_worker() -> Arc { /// `heartbeat` is present and null (no cron store on this worker). #[tokio::test] +#[pa_test_scratch::pa_test] async fn get_connection_state_matches_the_ts_shape() { let worker = created_worker().await; let response = worker @@ -120,6 +121,7 @@ async fn get_connection_state_matches_the_ts_shape() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn get_rlm_children_carries_the_sequence() { let worker = created_worker().await; let response = worker @@ -145,6 +147,7 @@ async fn get_rlm_children_carries_the_sequence() { /// Child attributions move the split between `ownUsage` and `totalUsage`. #[tokio::test] +#[pa_test_scratch::pa_test] async fn get_context_tree_matches_the_ts_root_node() { let worker = created_worker().await; let response = worker @@ -185,6 +188,7 @@ async fn get_context_tree_matches_the_ts_root_node() { /// own row (input 2690, cost $0, `totalTokens` clamped to zero); `totalUsage` /// carries the attributed child spend (input 52898, cost $0.0089957). #[tokio::test] +#[pa_test_scratch::pa_test] async fn get_context_tree_folds_the_captured_attributions() { let root = std::env::temp_dir().join(format!("pa-worker-af-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&root).unwrap(); @@ -239,6 +243,7 @@ async fn get_context_tree_folds_the_captured_attributions() { /// models mid-conversation accumulates the per-model costs INCLUDING the /// switch's cache-write burst (the cost blocks are `calculate_cost` records). #[tokio::test] +#[pa_test_scratch::pa_test] async fn get_context_tree_breaks_own_usage_down_by_model() { let root = std::env::temp_dir().join(format!("pa-worker-bm-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&root).unwrap(); @@ -329,6 +334,7 @@ async fn get_context_tree_breaks_own_usage_down_by_model() { /// makes the buckets sum past `ownUsage`, so `ownUsageByModel` is omitted /// and the display degrades to the plain totals instead of overstating the node. #[tokio::test] +#[pa_test_scratch::pa_test] async fn get_context_tree_omits_the_breakdown_when_an_attribution_exceeds_its_bucket() { let root = std::env::temp_dir().join(format!("pa-worker-bmx-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&root).unwrap(); @@ -387,6 +393,7 @@ async fn get_context_tree_omits_the_breakdown_when_an_attribution_exceeds_its_bu /// The control for the omission rule: a fitting attribution reconciles and the breakdown /// stays served. #[tokio::test] +#[pa_test_scratch::pa_test] async fn get_context_tree_keeps_the_breakdown_when_an_attribution_fits_its_bucket() { let root = std::env::temp_dir().join(format!("pa-worker-bmf-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&root).unwrap(); @@ -441,6 +448,7 @@ async fn get_context_tree_keeps_the_breakdown_when_an_attribution_fits_its_bucke /// `get_context_tree` surfaces the persisted child sessions: idle, settled, and /// restart-orphaned subagents all appear, with real usage and grandchildren. #[tokio::test] +#[pa_test_scratch::pa_test] async fn get_context_tree_lists_persisted_children() { let root = std::env::temp_dir().join(format!("pa-worker-ct-{}", uuid::Uuid::new_v4())); let agent_dir = root.join("agent"); @@ -557,6 +565,7 @@ async fn get_context_tree_lists_persisted_children() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn commands_and_resources_match_the_empty_loader_shape() { let worker = created_worker().await; let response = worker @@ -581,6 +590,7 @@ async fn commands_and_resources_match_the_empty_loader_shape() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn get_session_context_matches_the_ts_context_shape() { let worker = created_worker().await; let response = worker @@ -629,6 +639,7 @@ async fn get_session_context_matches_the_ts_context_shape() { /// No prompt (empty string, the TS key present) and no tools (the `toolDefinition` /// key omitted, like the TS `undefined` field). #[tokio::test] +#[pa_test_scratch::pa_test] async fn system_prompt_and_tool_definition_match_the_ts_shapes() { let worker = created_worker().await; let response = worker @@ -663,6 +674,7 @@ async fn system_prompt_and_tool_definition_match_the_ts_shapes() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn rlm_max_depth_status_matches_the_ts_shape() { let worker = created_worker().await; let response = worker @@ -679,6 +691,7 @@ async fn rlm_max_depth_status_matches_the_ts_shape() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn model_catalog_and_available_models_match_the_ts_shapes() { let dir = tempfile::tempdir().expect("tempdir"); std::fs::create_dir_all(dir.path().join("agent")).expect("agent dir"); diff --git a/crates/pa-daemon/src/state_getters/usage.rs b/crates/pa-daemon/src/state_getters/usage.rs index c8a0e1755..44a0c2b3d 100644 --- a/crates/pa-daemon/src/state_getters/usage.rs +++ b/crates/pa-daemon/src/state_getters/usage.rs @@ -290,6 +290,7 @@ pub(crate) fn compute_own_usage_by_model( mod usage_tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn own_usage_subtracts_child_attributions() { let assistant = json!({ @@ -354,6 +355,7 @@ mod usage_tests { /// A duplicated attribution id — a retried durable append whose bytes /// landed but whose fsync errored — is subtracted once: own usage keeps /// one batch, the total keeps its last-wins aggregate. + #[pa_test_scratch::pa_test] #[test] fn a_duplicated_attribution_id_is_subtracted_once() { let assistant = json!({ @@ -403,6 +405,7 @@ mod usage_tests { /// A `branch_summary` row served by an auxiliary model (TS #2411) bills on /// the model its entry records, not the timeline's current model. + #[pa_test_scratch::pa_test] #[test] fn branch_summary_usage_bills_on_the_row_recorded_auxiliary_model() { let entry = |value: &Value, id: &str| crate::session_store::SessionEntry { @@ -463,6 +466,7 @@ mod usage_tests { /// A windowed load seeds the timeline with the retained-window boundary's /// model; without a seed (a full-history foreign file) the breakdown stays omitted. + #[pa_test_scratch::pa_test] #[test] fn window_seed_resolves_rows_before_the_first_model_change() { let entry = |value: &Value, id: &str| crate::session_store::SessionEntry { diff --git a/crates/pa-daemon/src/stop_cleanup.rs b/crates/pa-daemon/src/stop_cleanup.rs index acf4c6562..552d9cd36 100644 --- a/crates/pa-daemon/src/stop_cleanup.rs +++ b/crates/pa-daemon/src/stop_cleanup.rs @@ -597,6 +597,7 @@ mod tests { serde_json::from_value(raw["jobs"][0].clone()).unwrap() } + #[pa_test_scratch::pa_test] #[test] fn finalize_cancels_the_tree_and_archives_the_root() { let root = temp_dir(); @@ -639,6 +640,7 @@ mod tests { assert_eq!(info.state.as_deref(), Some("archived")); } + #[pa_test_scratch::pa_test] #[test] fn finalize_skips_a_tree_a_live_worker_covers() { let root = temp_dir(); @@ -663,6 +665,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn capture_reads_the_frozen_transcript_before_any_sweep() { let root = temp_dir(); @@ -744,6 +747,7 @@ mod tests { /// The snapshot is OWN usage: the bucket's post-order fold re-adds the grandchild's /// own snapshot, and an aggregate would double count it. + #[pa_test_scratch::pa_test] #[test] fn capture_is_own_only_never_the_attribution_aggregate() { let root = temp_dir(); @@ -811,6 +815,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn capture_skips_live_children_and_plain_kills() { let root = temp_dir(); @@ -842,6 +847,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn capture_with_no_child_id_amends_every_tombstoned_edge() { let root = temp_dir(); diff --git a/crates/pa-daemon/src/streaming.rs b/crates/pa-daemon/src/streaming.rs index a49a1c975..a8d8f6e03 100644 --- a/crates/pa-daemon/src/streaming.rs +++ b/crates/pa-daemon/src/streaming.rs @@ -194,6 +194,7 @@ mod tests { use std::sync::Arc; use tokio::sync::broadcast; + #[pa_test_scratch::pa_test] #[test] fn direct_sends_flush_the_parked_update_first() { let (pump, mut rx) = subscribe(); @@ -215,6 +216,7 @@ mod tests { assert!(rx.try_recv().is_err(), "no further frames"); } + #[pa_test_scratch::pa_test] #[test] fn a_newer_snapshot_merges_the_superseded_deltas() { let (pump, mut rx) = subscribe(); @@ -252,6 +254,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn a_kind_switch_replaces_the_run() { let (pump, mut rx) = subscribe(); @@ -283,6 +286,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn close_stops_parking_and_flushing() { let (pump, mut rx) = subscribe(); @@ -304,6 +308,7 @@ mod tests { assert!(rx.try_recv().is_err(), "a closed turn parks nothing"); } + #[pa_test_scratch::pa_test] #[test] fn flush_without_parked_frames_is_a_kept_alive_noop() { let (pump, mut rx) = subscribe(); diff --git a/crates/pa-daemon/src/supervisor/accept_loop.rs b/crates/pa-daemon/src/supervisor/accept_loop.rs index 91a233308..f5f5eeaed 100644 --- a/crates/pa-daemon/src/supervisor/accept_loop.rs +++ b/crates/pa-daemon/src/supervisor/accept_loop.rs @@ -188,6 +188,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn recoverable_accept_errors_do_not_exit_the_loop() { let dir = TempDir::new().unwrap(); let supervisor = test_supervisor(&dir); @@ -220,6 +221,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn recoverable_error_storms_back_off_but_never_escalate() { let dir = TempDir::new().unwrap(); let supervisor = test_supervisor(&dir); @@ -254,6 +256,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn non_recoverable_accept_errors_back_off_and_keep_serving() { let dir = TempDir::new().unwrap(); let supervisor = test_supervisor(&dir); @@ -288,6 +291,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn a_served_connection_resets_the_give_up_budget() { let dir = TempDir::new().unwrap(); let supervisor = test_supervisor(&dir); @@ -315,6 +319,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn permanent_accept_failure_escalates_after_the_budget() { let dir = TempDir::new().unwrap(); let supervisor = test_supervisor(&dir); @@ -346,6 +351,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn accept_errors_while_shutting_down_do_not_back_off_or_escalate() { let dir = TempDir::new().unwrap(); let supervisor = test_supervisor(&dir); @@ -375,6 +381,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn a_shutdown_wake_ends_the_backoff_early() { let dir = TempDir::new().unwrap(); let supervisor = test_supervisor(&dir); diff --git a/crates/pa-daemon/src/supervisor/adoption.rs b/crates/pa-daemon/src/supervisor/adoption.rs index 831fa0661..053816c51 100644 --- a/crates/pa-daemon/src/supervisor/adoption.rs +++ b/crates/pa-daemon/src/supervisor/adoption.rs @@ -24,6 +24,7 @@ fn recorded_process_alive( mod recorded_process_tests { use super::recorded_process_alive; + #[pa_test_scratch::pa_test] #[test] fn unobservable_start_id_keeps_live_tombstone_owned_by_recorded_pid() { assert!(recorded_process_alive(Some(true), Some("original"), None)); @@ -843,6 +844,7 @@ mod rlm_child_admission_tests { use super::*; #[tokio::test] + #[pa_test_scratch::pa_test] async fn restored_child_admission_preserves_completed_display_and_ledger_edge() { let dir = tempfile::tempdir().expect("fixture"); let agent_dir = dir.path().join("agent"); @@ -902,6 +904,7 @@ mod launch_admission_tests { use super::*; #[tokio::test] + #[pa_test_scratch::pa_test] async fn terminal_stop_refuses_boot_adoption_and_unknown_registration_before_publication() { let dir = tempfile::tempdir().expect("fixture"); let supervisor = Arc::new( @@ -957,6 +960,7 @@ mod pid_range_tests { use super::*; #[tokio::test] + #[pa_test_scratch::pa_test] async fn oversized_pid_is_refused_before_registration_or_boot_adoption_work() { let dir = tempfile::tempdir().expect("fixture"); let supervisor = Arc::new( @@ -1048,6 +1052,7 @@ mod registration_uncertainty_tests { use super::*; #[tokio::test] + #[pa_test_scratch::pa_test] async fn missing_or_empty_registration_identity_preserves_known_and_unknown_state() { for known in [false, true] { for observed in [None, Some(String::new())] { diff --git a/crates/pa-daemon/src/supervisor/clients.rs b/crates/pa-daemon/src/supervisor/clients.rs index 7eea70f9f..484a6558f 100644 --- a/crates/pa-daemon/src/supervisor/clients.rs +++ b/crates/pa-daemon/src/supervisor/clients.rs @@ -1134,6 +1134,7 @@ mod tests { /// shutdown task has not claimed its owner yet. Keep the receiver alive /// through that cleanup window, then release the real shutdown dispatch. #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_late_shutdown_cannot_send_into_a_retired_client_queue() { let dir = tempfile::TempDir::new().unwrap(); let supervisor = Arc::new( @@ -1208,6 +1209,7 @@ mod tests { #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_shutdown_request_logs_its_client() { let dir = tempfile::TempDir::new().unwrap(); let options = SupervisorOptions { @@ -1265,6 +1267,7 @@ mod tests { #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_lagged_client_event_stream_is_logged() { use tokio::io::AsyncReadExt as _; let dir = tempfile::TempDir::new().unwrap(); @@ -1389,6 +1392,7 @@ mod tests { /// the slot clears, but the descriptor read can yield to a new client. #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn reconnect_during_expired_cleanup_keeps_owned_worker() { let dir = tempfile::TempDir::new().unwrap(); let supervisor = Arc::new( @@ -1463,6 +1467,7 @@ mod tests { /// of firing at the disconnect. #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_client_owned_worker_stops_after_its_owner_s_last_connection_closes() { let dir = tempfile::TempDir::new().unwrap(); let supervisor = Arc::new( diff --git a/crates/pa-daemon/src/supervisor/dead_child_delete_tests.rs b/crates/pa-daemon/src/supervisor/dead_child_delete_tests.rs index 3bdcb4dd4..f47a3252b 100644 --- a/crates/pa-daemon/src/supervisor/dead_child_delete_tests.rs +++ b/crates/pa-daemon/src/supervisor/dead_child_delete_tests.rs @@ -122,6 +122,7 @@ async fn route_delete(supervisor: &Arc) -> Value { /// succeeds from the ledger boundary alone instead of answering the route's /// not-connected failure after the stop already ran. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_delete_of_a_dead_workers_child_completes_without_a_handshake() { let Fixture { _dir, @@ -150,6 +151,7 @@ async fn a_delete_of_a_dead_workers_child_completes_without_a_handshake() { /// Liveness, not route state, gates the short-circuit: a live worker still /// receives the kill. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_delete_of_a_live_workers_child_still_routes_the_kill() { let Fixture { _dir, @@ -210,6 +212,7 @@ async fn a_delete_of_a_live_workers_child_still_routes_the_kill() { /// A retry after the boundary already stands is idempotent once the worker is /// gone, and refused while its process still runs. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_retried_delete_after_the_tombstone_is_gated_on_the_worker_process() { let Fixture { _dir, diff --git a/crates/pa-daemon/src/supervisor/handshake_tests.rs b/crates/pa-daemon/src/supervisor/handshake_tests.rs index 0b0d6877f..e66bd7bef 100644 --- a/crates/pa-daemon/src/supervisor/handshake_tests.rs +++ b/crates/pa-daemon/src/supervisor/handshake_tests.rs @@ -75,6 +75,7 @@ async fn answer_supervisor_frame(socket: &mut FakeWorkerSocket, request_id: &str } #[tokio::test] +#[pa_test_scratch::pa_test] async fn handshake_channel_stays_private_until_auth_answers() { let dir = std::env::temp_dir().join(format!("pa-handshake-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -157,11 +158,13 @@ async fn handshake_channel_stays_private_until_auth_answers() { /// A tombstoned stop's entire silent-peer authentication uses the strict /// one-second budget, closes both transport halves, and drops its pending slot. #[tokio::test] +#[pa_test_scratch::pa_test] async fn silent_peer_stop_auth_closes_socket_without_leaving_pending() { run_silent_peer_auth(false).await; } #[tokio::test] +#[pa_test_scratch::pa_test] async fn cancelled_auth_closes_socket_without_leaving_pending() { run_silent_peer_auth(true).await; } @@ -243,6 +246,7 @@ async fn run_silent_peer_auth(cancel_connect: bool) { /// the wire carries EXACTLY the auth frame (no route rides the private /// channel), the registration itself succeeds, and the launch completes. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_mid_handshake_registration_cannot_kill_the_handshake() { let dir = std::env::temp_dir().join(format!("pa-wedge-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -345,6 +349,7 @@ async fn a_mid_handshake_registration_cannot_kill_the_handshake() { /// lock, so the stale install is dropped and the newer channel stays /// routable. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_stale_epoch_never_overwrites_the_installed_channel() { let dir = std::env::temp_dir().join(format!("pa-install-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -420,6 +425,7 @@ async fn a_stale_epoch_never_overwrites_the_installed_channel() { /// slots when the socket ends, so a route waiting on the worker's answer /// cannot outlive the connection it was sent on. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_lost_worker_connection_fails_its_in_flight_route() { let dir = std::env::temp_dir().join(format!("pa-lost-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -509,6 +515,7 @@ async fn a_lost_worker_connection_fails_its_in_flight_route() { /// New supervisors must not send optional commands to old or partial workers. #[tokio::test] +#[pa_test_scratch::pa_test] async fn model_refresh_requires_negotiated_worker_capability_and_revision() { for (data, expected) in [ ( @@ -667,6 +674,7 @@ fn assert_no_retirement(supervisor: &Supervisor, resident: &ResidentWorker) { #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_graceful_shutdown_refusal_preserves_worker_then_retry_or_force_completes() { use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; for (command, force) in [("shutdown", false), ("restart", false), ("shutdown", true)] { @@ -746,6 +754,7 @@ async fn public_graceful_shutdown_refusal_preserves_worker_then_retry_or_force_c } #[tokio::test] +#[pa_test_scratch::pa_test] async fn per_session_graceful_stop_refusal_does_not_retire_and_can_retry() { let (_dir, supervisor, resident, verdict, worker) = accounting_refusal_fixture("w-close").await; super::worker_lifecycle::retirement_overrides() @@ -767,6 +776,7 @@ async fn per_session_graceful_stop_refusal_does_not_retire_and_can_retry() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn concurrent_shutdown_attempt_cannot_duplicate_stop_or_reopen_completed_gate() { let (_dir, supervisor, resident, verdict, worker) = accounting_refusal_fixture("w-close").await; let first = { @@ -793,6 +803,7 @@ async fn concurrent_shutdown_attempt_cannot_duplicate_stop_or_reopen_completed_g #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn public_plain_kill_refusal_does_not_run_finally_retirement() { use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; let (_dir, supervisor, resident, verdict, worker) = accounting_refusal_fixture("w-close").await; @@ -841,6 +852,7 @@ async fn public_plain_kill_refusal_does_not_run_finally_retirement() { #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn first_signal_accounting_refusal_preserves_worker_without_closing_event() { let (_dir, supervisor, resident, verdict, worker) = accounting_refusal_fixture("w-close").await; super::worker_lifecycle::retirement_overrides() @@ -874,6 +886,7 @@ async fn first_signal_accounting_refusal_preserves_worker_without_closing_event( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn idle_eviction_fences_racing_client_routes_until_refusal_or_retirement() { let (_dir, supervisor, resident, verdict, worker) = accounting_refusal_fixture("w-idle").await; super::worker_lifecycle::retirement_overrides() @@ -943,6 +956,7 @@ async fn idle_eviction_fences_racing_client_routes_until_refusal_or_retirement() } #[tokio::test] +#[pa_test_scratch::pa_test] async fn partial_shutdown_retry_targets_only_the_worker_that_refused_accounting() { let (_dir, supervisor, closed, closed_verdict, closed_worker) = accounting_refusal_fixture("a-closed").await; diff --git a/crates/pa-daemon/src/supervisor/launch_admission_tests.rs b/crates/pa-daemon/src/supervisor/launch_admission_tests.rs index e275fd1af..ef1fe0aa2 100644 --- a/crates/pa-daemon/src/supervisor/launch_admission_tests.rs +++ b/crates/pa-daemon/src/supervisor/launch_admission_tests.rs @@ -25,6 +25,7 @@ async fn stopping(supervisor: &Supervisor) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn launch_admission_refuses_after_terminal_stop() { let (_dir, supervisor) = fixture(); supervisor.begin_shutdown(/*force*/ true).await; @@ -33,6 +34,7 @@ async fn launch_admission_refuses_after_terminal_stop() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn terminal_drain_waits_for_every_clone_of_the_owned_launch_permit() { let (_dir, supervisor) = fixture(); let permit = supervisor @@ -64,6 +66,7 @@ async fn terminal_drain_waits_for_every_clone_of_the_owned_launch_permit() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn stopped_launch_reentry_refuses_without_waiting_for_the_exclusive_fence() { let (_dir, supervisor) = fixture(); supervisor.shutting_down.store(true, Ordering::SeqCst); @@ -76,6 +79,7 @@ async fn stopped_launch_reentry_refuses_without_waiting_for_the_exclusive_fence( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn uncertain_launch_cleanup_never_certifies_terminal_exit() { let (_dir, supervisor) = fixture(); supervisor @@ -92,6 +96,7 @@ async fn uncertain_launch_cleanup_never_certifies_terminal_exit() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn known_worker_boot_callback_does_not_reenter_a_queued_fair_read_fence() { let (dir, supervisor) = fixture(); let permit = supervisor @@ -145,6 +150,7 @@ async fn known_worker_boot_callback_does_not_reenter_a_queued_fair_read_fence() } #[tokio::test] +#[pa_test_scratch::pa_test] async fn queued_terminal_writer_does_not_invert_unknown_registration_and_boot_adoption_guards() { let (_dir, supervisor) = fixture(); let worker_id = "admission-inversion"; @@ -214,6 +220,7 @@ async fn queued_terminal_writer_does_not_invert_unknown_registration_and_boot_ad } #[tokio::test] +#[pa_test_scratch::pa_test] async fn admission_fast_check_race_refuses_after_terminal_writer_queues() { let (_dir, supervisor) = fixture(); let outer = supervisor diff --git a/crates/pa-daemon/src/supervisor/launch_budget.rs b/crates/pa-daemon/src/supervisor/launch_budget.rs index 5df7eeae9..68efdd5a4 100644 --- a/crates/pa-daemon/src/supervisor/launch_budget.rs +++ b/crates/pa-daemon/src/supervisor/launch_budget.rs @@ -48,6 +48,7 @@ pub(super) const WORKER_PROBE_BACKOFF_MAX_MS: u64 = 2_000; mod windows_tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn windows_budgets_match_the_ts_values() { assert_eq!(DEFAULT_WORKER_CONNECT_TIMEOUT_MS, 90_000); diff --git a/crates/pa-daemon/src/supervisor/model_refresh/tests.rs b/crates/pa-daemon/src/supervisor/model_refresh/tests.rs index c47b9cfcb..930129b29 100644 --- a/crates/pa-daemon/src/supervisor/model_refresh/tests.rs +++ b/crates/pa-daemon/src/supervisor/model_refresh/tests.rs @@ -75,6 +75,7 @@ fn report(status: &str) -> Value { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn zero_workers_never_opens_saved_sessions_or_launches_processes() { let h = Harness::new(); let sessions = h.dir.path().join("agent/sessions/saved"); @@ -87,6 +88,7 @@ async fn zero_workers_never_opens_saved_sessions_or_launches_processes() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn coalesces_clients_and_only_fetches_missing_sibling_sources() { let mut h = Harness::new(); let (leader, mut leader_rx) = h.worker("01-leader").await; @@ -149,6 +151,7 @@ async fn coalesces_clients_and_only_fetches_missing_sibling_sources() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn leader_election_skips_invalid_reports_and_does_not_leak_errors() { let mut h = Harness::new(); let (bad, bad_rx) = h.worker("01-invalid").await; @@ -181,6 +184,7 @@ async fn leader_election_skips_invalid_reports_and_does_not_leak_errors() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn never_restarts_or_wakes_unready_dead_retired_or_old_workers() { let mut h = Harness::new(); let mut channels = Vec::new(); @@ -222,6 +226,7 @@ async fn never_restarts_or_wakes_unready_dead_retired_or_old_workers() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reports_worst_per_source_without_credential_scoped_counts() { for (first, second, expected) in [ ("skipped", "updated", "updated"), @@ -249,6 +254,7 @@ async fn reports_worst_per_source_without_credential_scoped_counts() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn sweep_survives_requester_cancellation() { let mut h = Harness::new(); let (leader, mut rx) = h.worker("01").await; @@ -283,6 +289,7 @@ async fn sweep_survives_requester_cancellation() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn whole_sweep_deadline_marks_unvisited_workers_unavailable() { let mut h = Harness::new(); let mut workers = Vec::new(); @@ -320,6 +327,7 @@ async fn whole_sweep_deadline_marks_unvisited_workers_unavailable() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn snapshot_fanout_never_exceeds_four_workers() { let mut h = Harness::new(); let (leader, rx) = h.worker("00").await; @@ -372,6 +380,7 @@ async fn snapshot_fanout_never_exceeds_four_workers() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn reports_preserve_leader_source_order_and_snapshot_followers_do_not_fetch() { let mut h = Harness::new(); let (leader, rx) = h.worker("01").await; @@ -405,6 +414,7 @@ async fn reports_preserve_leader_source_order_and_snapshot_followers_do_not_fetc } #[tokio::test] +#[pa_test_scratch::pa_test] async fn client_refresh_has_a_two_minute_route_budget_and_rejects_old_workers() { let mut h = Harness::new(); let (worker, mut requests) = h.worker("refresh-route").await; diff --git a/crates/pa-daemon/src/supervisor/plugin_command_tests.rs b/crates/pa-daemon/src/supervisor/plugin_command_tests.rs index 90dd51b6b..d18c32bde 100644 --- a/crates/pa-daemon/src/supervisor/plugin_command_tests.rs +++ b/crates/pa-daemon/src/supervisor/plugin_command_tests.rs @@ -2,6 +2,7 @@ use super::*; #[tokio::test] +#[pa_test_scratch::pa_test] async fn plugin_commands_never_reach_old_or_reconnected_workers() { let dir = tempfile::tempdir().unwrap(); let supervisor = Arc::new( diff --git a/crates/pa-daemon/src/supervisor/root_identity.rs b/crates/pa-daemon/src/supervisor/root_identity.rs index bc3ccfe91..777616cd6 100644 --- a/crates/pa-daemon/src/supervisor/root_identity.rs +++ b/crates/pa-daemon/src/supervisor/root_identity.rs @@ -358,6 +358,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn successive_swaps_land_the_identity_on_the_final_row() { let dir = std::env::temp_dir().join(format!("pa-root-id-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -416,6 +417,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_failed_identity_persist_is_repaired_by_the_next_roster_write() { let dir = std::env::temp_dir().join(format!("pa-root-id-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -478,6 +480,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_durable_pending_moves_the_boot_identity_before_any_routing() { let dir = std::env::temp_dir().join(format!("pa-root-id-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -626,6 +629,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_child_roster_delta_never_lifts_the_root_quarantine() { let dir = std::env::temp_dir().join(format!("pa-root-id-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -684,6 +688,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_path_backed_replacement_clears_the_no_session_replay_flag() { let dir = std::env::temp_dir().join(format!("pa-root-id-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -740,6 +745,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_quarantined_resident_never_serves_until_the_live_word_lands() { let dir = std::env::temp_dir().join(format!("pa-root-id-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); diff --git a/crates/pa-daemon/src/supervisor/routing.rs b/crates/pa-daemon/src/supervisor/routing.rs index 349de3c10..64c3fe042 100644 --- a/crates/pa-daemon/src/supervisor/routing.rs +++ b/crates/pa-daemon/src/supervisor/routing.rs @@ -1219,6 +1219,7 @@ mod roster_wake_tests { json!({"id":id,"sessionId":id,"sessionFile":path,"runtimeKind":"top-level","rlmDepth":0}) } + #[pa_test_scratch::pa_test] #[test] fn exact_passive_durable_id_preserves_custom_path_and_active_id_preference() { let mut roster = crate::agent_roster::AgentRoster::new(); @@ -1242,6 +1243,7 @@ mod roster_wake_tests { .is_none()); } + #[pa_test_scratch::pa_test] #[test] fn distinct_passive_files_with_same_durable_id_are_ambiguous() { let mut roster = crate::agent_roster::AgentRoster::new(); diff --git a/crates/pa-daemon/src/supervisor/sessions.rs b/crates/pa-daemon/src/supervisor/sessions.rs index dacef4b6d..64c58f2f2 100644 --- a/crates/pa-daemon/src/supervisor/sessions.rs +++ b/crates/pa-daemon/src/supervisor/sessions.rs @@ -902,6 +902,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn a_wedged_resident_does_not_hold_the_all_true_list_past_the_client_deadline() { let dir = tempfile::TempDir::new().expect("temp dir"); let supervisor = Arc::new(supervisor(dir.path())); @@ -951,6 +952,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn a_named_create_name_check_does_not_wait_out_the_client_deadline_behind_a_wedged_resident( ) { let dir = tempfile::TempDir::new().expect("temp dir"); diff --git a/crates/pa-daemon/src/supervisor/signals_shutdown.rs b/crates/pa-daemon/src/supervisor/signals_shutdown.rs index aef778f52..631880058 100644 --- a/crates/pa-daemon/src/supervisor/signals_shutdown.rs +++ b/crates/pa-daemon/src/supervisor/signals_shutdown.rs @@ -265,6 +265,7 @@ mod terminal_truth_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn tombstone_write_failure_never_clears_resident_or_publishes_terminal_exit() { let (dir, supervisor) = fixture(); let blocked_parent = dir.path().join("not-a-directory"); @@ -283,6 +284,7 @@ mod terminal_truth_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn unresolved_typed_retirement_never_clears_resident_or_publishes_terminal_exit() { use super::super::worker_lifecycle::{retirement_overrides, WorkerRetirement}; for outcome in [ @@ -317,6 +319,7 @@ mod terminal_truth_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn incomplete_first_resident_does_not_skip_independent_resident_or_retry() { use super::super::worker_lifecycle::{retirement_overrides, WorkerRetirement}; for failure in [ diff --git a/crates/pa-daemon/src/supervisor/spawn_record_tests.rs b/crates/pa-daemon/src/supervisor/spawn_record_tests.rs index 7de72027f..9f6248a67 100644 --- a/crates/pa-daemon/src/supervisor/spawn_record_tests.rs +++ b/crates/pa-daemon/src/supervisor/spawn_record_tests.rs @@ -32,6 +32,7 @@ fn spawn_record_witness(tag: &str) -> (Arc, std::path::PathBuf) { /// state until the create-completion persist owns the next durable /// write. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_known_resident_registration_writes_nothing_to_disk() { let dir = std::env::temp_dir().join(format!("pa-regskip-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -124,6 +125,7 @@ async fn a_known_resident_registration_writes_nothing_to_disk() { /// worker probe (nothing listens on the per-test socket), after the /// spawn record served. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_relaunch_spawn_record_serves_the_durable_persist() { let (supervisor, dir) = spawn_record_witness("relaunch"); let descriptor_path = dir.join("w-relaunch.json"); @@ -223,6 +225,7 @@ async fn a_relaunch_spawn_record_serves_the_durable_persist() { /// unfixed tree the persist failure is discarded and the launch only fails /// later, at the connect probe, with no spawn record behind it. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_spawn_record_persist_failure_kills_the_child_and_fails_the_launch() { let (supervisor, dir) = spawn_record_witness("persistfail"); let descriptor_path = dir.join("w-persistfail.json"); @@ -276,6 +279,7 @@ async fn a_spawn_record_persist_failure_kills_the_child_and_fails_the_launch() { /// launch path; it fails at the worker probe (no live worker), after /// the spawn record served. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_fresh_create_spawn_record_keeps_the_unsynced_shape() { let (supervisor, dir) = spawn_record_witness("freshcreate"); let create = DaemonCommand::Create { diff --git a/crates/pa-daemon/src/supervisor/subscribers.rs b/crates/pa-daemon/src/supervisor/subscribers.rs index f23fcb84f..1dc75d9a5 100644 --- a/crates/pa-daemon/src/supervisor/subscribers.rs +++ b/crates/pa-daemon/src/supervisor/subscribers.rs @@ -228,6 +228,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn publish_reaches_only_the_attached_connection() { let registry = SessionSubscribers::new(); let (first_tx, mut first_rx) = queue(8); @@ -253,6 +254,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn detach_stops_delivery_at_the_detach_instant() { let registry = SessionSubscribers::new(); let (tx, mut rx) = queue(8); @@ -266,6 +268,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn rebind_moves_the_subscription_between_ids() { let registry = SessionSubscribers::new(); let (tx, mut rx) = queue(8); @@ -285,6 +288,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_full_queue_drops_once_per_stall_cycle() { let registry = SessionSubscribers::new(); let (tx, mut rx) = queue(2); @@ -313,6 +317,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_closed_queue_prunes_its_subscription() { let registry = SessionSubscribers::new(); let (tx, rx) = queue(2); @@ -329,6 +334,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn attach_is_idempotent_and_disconnect_clears_every_session() { let registry = SessionSubscribers::new(); let (tx, mut rx) = queue(8); diff --git a/crates/pa-daemon/src/supervisor/supervision.rs b/crates/pa-daemon/src/supervisor/supervision.rs index cabdc5210..45838a3ab 100644 --- a/crates/pa-daemon/src/supervisor/supervision.rs +++ b/crates/pa-daemon/src/supervisor/supervision.rs @@ -1276,6 +1276,7 @@ mod tests { /// token never wins), and `RLM_DEPTH` is an explicit removal even /// when the client forwarded one — the only removal, so the daemon's /// own env stays the inherited base. + #[pa_test_scratch::pa_test] #[test] fn the_client_env_rides_under_the_internal_overrides() { let client = std::collections::BTreeMap::from([ @@ -1324,6 +1325,7 @@ mod tests { /// The recursion marker is stripped even with no client env at all /// (audit #9): a supervisor started inside an agent's shell spawns /// depth-0 workers. + #[pa_test_scratch::pa_test] #[test] fn rlm_depth_is_stripped_without_a_client_env() { let internal = std::collections::BTreeMap::from([( @@ -1380,6 +1382,7 @@ mod owned_reap_causal_tests { /// Terminal shutdown must join OS reaping, not merely observe zombie death. #[tokio::test] + #[pa_test_scratch::pa_test] async fn terminal_shutdown_waits_for_owned_os_reaping() { let dir = tempfile::tempdir().expect("fixture"); let supervisor = Arc::new( @@ -1528,6 +1531,7 @@ mod launch_rollback_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cancelled_owned_launch_retains_admission_until_exact_child_is_reaped() { let (dir, supervisor) = fixture(); let admission = supervisor @@ -1591,6 +1595,7 @@ mod launch_rollback_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn unpolled_rollback_cancellation_records_debt_before_permit_release() { let (dir, supervisor) = fixture(); let admission = supervisor @@ -1657,6 +1662,7 @@ mod launch_rollback_tests { .expect("fixture child reaped by Tokio drop cleanup"); } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cancelled_physical_launch_before_spawn_releases_admission_without_publication() { let (dir, supervisor) = fixture(); let resident = resident(&supervisor, dir.path(), 0); @@ -1698,6 +1704,7 @@ mod launch_rollback_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn cancelled_physical_launch_before_descriptor_drains_actual_child_cleanup() { let (dir, supervisor) = fixture(); let resident = resident(&supervisor, dir.path(), 0); @@ -1757,6 +1764,7 @@ mod orphan_callback_truth_tests { use super::*; #[tokio::test] + #[pa_test_scratch::pa_test] async fn rollback_admission_covers_orphan_callback_success_panic_and_abort() { // Each case owns a fresh supervisor, child, journal path and pause. for mode in ["success", "panic", "abort"] { @@ -1866,6 +1874,7 @@ mod spawn_identity_capture_tests { use super::*; #[tokio::test] + #[pa_test_scratch::pa_test] async fn owned_record_and_descriptor_reuse_one_spawn_identity_observation_including_none() { for captured in [None, Some("captured-once".to_string())] { let dir = tempfile::tempdir().expect("fixture"); diff --git a/crates/pa-daemon/src/supervisor/tests.rs b/crates/pa-daemon/src/supervisor/tests.rs index 18b9405c5..a02676793 100644 --- a/crates/pa-daemon/src/supervisor/tests.rs +++ b/crates/pa-daemon/src/supervisor/tests.rs @@ -8,6 +8,7 @@ use proptest::test_runner::RngSeed; /// the give-up cap (the storm's counter could never grow while /// relaunch-spawns kept resetting it); a child that lived past the /// stable window was healthy, so its death starts a fresh count. +#[pa_test_scratch::pa_test] #[test] fn churn_accumulates_and_a_stable_lifetime_resets() { let descriptor: DaemonWorkerDescriptor = serde_json::from_value(serde_json::json!({ @@ -50,6 +51,7 @@ fn churn_accumulates_and_a_stable_lifetime_resets() { /// A failed relaunch produced no worker, so the count accumulates instead of /// resetting. #[tokio::test(start_paused = true)] +#[pa_test_scratch::pa_test] async fn a_failed_relaunch_accumulates_to_the_give_up_cap() { let dir = tempfile::TempDir::new().unwrap(); let agent_dir = dir.path().join("agent"); @@ -110,6 +112,7 @@ async fn a_failed_relaunch_accumulates_to_the_give_up_cap() { } #[tokio::test(start_paused = true)] +#[pa_test_scratch::pa_test] async fn a_stop_during_the_storm_leaves_the_terminal_state_to_the_stop() { let dir = tempfile::TempDir::new().unwrap(); let agent_dir = dir.path().join("agent"); @@ -174,6 +177,7 @@ async fn a_stop_during_the_storm_leaves_the_terminal_state_to_the_stop() { /// runtime the paused clock cannot advance. #[cfg(any(target_os = "linux", target_os = "macos"))] // the kernel-watch arms #[tokio::test(start_paused = true)] +#[pa_test_scratch::pa_test] async fn an_adopted_watch_hands_off_at_exit_without_a_timer() { let dir = tempfile::TempDir::new().unwrap(); let agent_dir = dir.path().join("agent"); @@ -259,6 +263,7 @@ async fn an_adopted_watch_hands_off_at_exit_without_a_timer() { /// The adopted predecessor must still hand off, even with an unchanged epoch. #[cfg(any(target_os = "linux", target_os = "macos"))] #[tokio::test(start_paused = true)] +#[pa_test_scratch::pa_test] async fn a_pid_only_replacement_keeps_the_adopted_predecessor_out_of_crash_recovery() { let dir = tempfile::TempDir::new().unwrap(); let agent_dir = dir.path().join("agent"); @@ -342,6 +347,7 @@ fn adopted_watch_resident(dir: &std::path::Path, pid: u32) -> Arc Arc Value { /// has this race (its roster deltas ride one ordered supervisor /// client socket). #[tokio::test] +#[pa_test_scratch::pa_test] async fn worker_roster_delta_drops_stale_sequences() { fn summary(level: &str) -> Value { serde_json::json!({ @@ -369,6 +370,7 @@ fn delta_frame(worker_token: &str, summary: Value, removed: Vec) -> Work /// push per mutation. A subscriber counts the pushes, so a duplicate /// is wire-visible. #[tokio::test] +#[pa_test_scratch::pa_test] async fn worker_roster_delta_pushes_one_update_per_flip() { let dir = tempfile::tempdir().expect("temp dir"); let supervisor = Arc::new(supervisor_with_registered_worker(dir.path()).await); @@ -407,6 +409,7 @@ async fn worker_roster_delta_pushes_one_update_per_flip() { /// the same single push (the TS apply writes entries and deletes /// removals before the one `scheduleRosterPush` flush). #[tokio::test] +#[pa_test_scratch::pa_test] async fn worker_roster_delta_batches_removals_into_the_same_push() { let dir = tempfile::tempdir().expect("temp dir"); let supervisor = Arc::new(supervisor_with_registered_worker(dir.path()).await); @@ -477,6 +480,7 @@ async fn worker_roster_delta_batches_removals_into_the_same_push() { /// --nocapture`. #[ignore = "manual roster delta push benchmark"] #[tokio::test] +#[pa_test_scratch::pa_test] async fn roster_delta_push_benchmark() { const FLIPS: usize = 2000; const WARMUP_FLIPS: usize = 50; diff --git a/crates/pa-daemon/src/supervisor_roster/passivation.rs b/crates/pa-daemon/src/supervisor_roster/passivation.rs index fa36d19df..0761f2fc5 100644 --- a/crates/pa-daemon/src/supervisor_roster/passivation.rs +++ b/crates/pa-daemon/src/supervisor_roster/passivation.rs @@ -15,6 +15,7 @@ use pa_types::daemon::agent_roster::AgentRosterStatus; /// the roster through the subscribe answer - the old per-switch /// reseed read the whole family here. #[tokio::test] +#[pa_test_scratch::pa_test] async fn subscribe_is_a_pure_in_memory_snapshot() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; register_root_worker(&supervisor, "w-root", &root_file).await; @@ -68,6 +69,7 @@ async fn subscribe_is_a_pure_in_memory_snapshot() { /// match their last published forms, so the wire never re-ships an /// unchanged row. #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_identical_rewrite_does_not_broadcast() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; register_root_worker(&supervisor, "w-root", &root_file).await; @@ -97,6 +99,7 @@ async fn an_identical_rewrite_does_not_broadcast() { /// and the changed form becomes the new diff baseline (the guard /// compares against the last published form, not the first). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_changed_rewrite_broadcasts_and_resets_the_diff_baseline() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; register_root_worker(&supervisor, "w-root", &root_file).await; @@ -136,6 +139,7 @@ async fn a_changed_rewrite_broadcasts_and_resets_the_diff_baseline() { /// its model, thinking level, and cwd, and drops only the /// live-runtime fields. One push carries the settled row. #[tokio::test] +#[pa_test_scratch::pa_test] async fn stop_passivates_an_anchored_child_preserving_display_fields() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; register_root_worker(&supervisor, "w-root", &root_file).await; @@ -181,6 +185,7 @@ async fn stop_passivates_an_anchored_child_preserving_display_fields() { /// ledger-seed hydrate writes and the agents view reads (the /// `thinking_level` e2e's post-stop assertion). #[tokio::test] +#[pa_test_scratch::pa_test] async fn passivation_normalizes_the_live_model_descriptor_to_the_durable_pair() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; register_root_worker(&supervisor, "w-root", &root_file).await; @@ -217,6 +222,7 @@ async fn passivation_normalizes_the_live_model_descriptor_to_the_durable_pair() /// exists for it), so its captured spend bills through the bucket /// on the parent's row - not through a row anywhere. #[tokio::test] +#[pa_test_scratch::pa_test] async fn stop_carries_the_deleted_childs_spend_to_its_parent() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; let agent_dir = dir.join("agent"); @@ -336,6 +342,7 @@ async fn stop_carries_the_deleted_childs_spend_to_its_parent() { /// event, and the parent's roster row bills the deleted child's /// captured spend in the delete's own push. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_saved_delete_without_a_roster_row_bills_the_parent() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; let agent_dir = dir.join("agent"); @@ -455,6 +462,7 @@ async fn a_saved_delete_without_a_roster_row_bills_the_parent() { /// (TS keeps every stopped non-ephemeral row visible: the operator's /// rows-disappear report), surviving later stops' unowned sweeps. #[tokio::test] +#[pa_test_scratch::pa_test] async fn stop_removes_unanchored_children_and_passivates_the_top_level_row() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; let agent_dir = dir.join("agent"); @@ -631,6 +639,7 @@ async fn stop_removes_unanchored_children_and_passivates_the_top_level_row() { /// root returns to the saved catalog alone, while another root's /// anchored seeded row keeps its display. #[tokio::test] +#[pa_test_scratch::pa_test] async fn stop_prunes_seeded_rows_of_a_family_that_lost_its_root() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; let agent_dir = dir.join("agent"); @@ -721,6 +730,7 @@ async fn stop_prunes_seeded_rows_of_a_family_that_lost_its_root() { /// clean, so the agents view's first frame never dumps the dead /// family's rows as top-level entries. #[tokio::test] +#[pa_test_scratch::pa_test] async fn stop_leaves_the_first_roster_snapshot_clean_behind_hundreds_of_seeded_rows() { let (dir, supervisor, root_file, _child_file) = roster_fixture().await; let agent_dir = dir.join("agent"); @@ -790,6 +800,7 @@ async fn stop_leaves_the_first_roster_snapshot_clean_behind_hundreds_of_seeded_r /// TS `passivatedWorkerRosterEntry` keeps the registration marks that // were true and strips the live-runtime fields, including the // heartbeat's own active flag. +#[pa_test_scratch::pa_test] #[test] fn passivation_keeps_registration_marks_and_strips_live_fields() { let passivated = passivated_summary(json!({ @@ -848,6 +859,7 @@ fn passivation_keeps_registration_marks_and_strips_live_fields() { /// replaces the passivated row with the live one, so a resumed /// session never renders its stale passive row. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_reregistration_replaces_the_passive_row() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; register_root_worker(&supervisor, "w-root", &root_file).await; diff --git a/crates/pa-daemon/src/supervisor_roster_seed.rs b/crates/pa-daemon/src/supervisor_roster_seed.rs index 2c8fd27ca..bda179614 100644 --- a/crates/pa-daemon/src/supervisor_roster_seed.rs +++ b/crates/pa-daemon/src/supervisor_roster_seed.rs @@ -543,6 +543,7 @@ pub(crate) mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn descent_matches_at_any_parent_walk_step() { let edges = [ @@ -592,6 +593,7 @@ pub(crate) mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn seeded_rows_shape_matches_the_ts_entry() { let dir = std::env::temp_dir().join(format!("pa-seed-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -821,6 +823,7 @@ pub(crate) mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn boot_seed_hydrates_once_and_publishes_one_update() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; register_root_worker(&supervisor, "w-root", &root_file).await; @@ -862,6 +865,7 @@ pub(crate) mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn boot_seed_skips_rows_the_roster_already_holds() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; register_root_worker(&supervisor, "w-root", &root_file).await; @@ -893,6 +897,7 @@ pub(crate) mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn family_seed_renders_edges_then_hydrates_in_the_background() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; register_root_worker(&supervisor, "w-root", &root_file).await; @@ -946,6 +951,7 @@ pub(crate) mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn hydration_loses_to_a_newer_worker_write() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; register_root_worker(&supervisor, "w-root", &root_file).await; @@ -980,6 +986,7 @@ pub(crate) mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn stale_seeded_snapshots_never_publish() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; let agent_dir = dir.join("agent"); @@ -1026,6 +1033,7 @@ pub(crate) mod tests { /// The row is corrupt but present (the liveness walk drops deleted files). #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_unhydrated_seeded_row_retries_on_the_next_family_walk() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; let agent_dir = dir.join("agent"); @@ -1086,6 +1094,7 @@ pub(crate) mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_registration_seed_publishes_a_late_worker_family() { let (dir, supervisor, root_file, child_file) = roster_fixture().await; register_root_worker(&supervisor, "w-late", &root_file).await; diff --git a/crates/pa-daemon/src/ts_era.rs b/crates/pa-daemon/src/ts_era.rs index 45a688cf7..498225119 100644 --- a/crates/pa-daemon/src/ts_era.rs +++ b/crates/pa-daemon/src/ts_era.rs @@ -34,6 +34,7 @@ mod tests { files } + #[pa_test_scratch::pa_test] #[test] fn ordinary_boot_hook_preserves_legacy_runtime_and_shared_state() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/types.rs b/crates/pa-daemon/src/types.rs index 88108d600..95e28342b 100644 --- a/crates/pa-daemon/src/types.rs +++ b/crates/pa-daemon/src/types.rs @@ -243,6 +243,7 @@ mod tests { use super::*; use serde_json::json; + #[pa_test_scratch::pa_test] #[test] fn extracts_text_from_content_blocks() { let message = json!({ @@ -253,6 +254,7 @@ mod tests { assert_eq!(message_role(&message), Some("user")); } + #[pa_test_scratch::pa_test] #[test] fn session_summary_serializes_snake_case_and_reads_camel_case() { let wire = r#"{ diff --git a/crates/pa-daemon/src/update_prepare.rs b/crates/pa-daemon/src/update_prepare.rs index fc0944ced..15566785b 100644 --- a/crates/pa-daemon/src/update_prepare.rs +++ b/crates/pa-daemon/src/update_prepare.rs @@ -578,6 +578,7 @@ mod tests { UpdateId::from(String::from(name)) } + #[pa_test_scratch::pa_test] #[test] fn begin_is_idempotent_and_refuses_other_ids() { let coordinator = PrepareCoordinator::new(); @@ -609,6 +610,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn transitions_walk_the_spec_path() { let coordinator = PrepareCoordinator::new(); @@ -634,6 +636,7 @@ mod tests { assert_eq!(coordinator.drain_complete(&id("u1")), PrepareOp::NotActive); } + #[pa_test_scratch::pa_test] #[test] fn illegal_transitions_and_wrong_ids_do_not_apply() { let coordinator = PrepareCoordinator::new(); @@ -652,6 +655,7 @@ mod tests { assert_eq!(coordinator.active_state(), Some(PrepareState::Draining)); } + #[pa_test_scratch::pa_test] #[test] fn prepare_deadline_watchdog_aborts_back_to_serving() { let coordinator = PrepareCoordinator::new(); @@ -676,6 +680,7 @@ mod tests { assert_eq!(coordinator.active_state(), Some(PrepareState::Draining)); } + #[pa_test_scratch::pa_test] #[test] fn commit_is_idempotent_while_stopping_and_abandon_takes_it() { let coordinator = PrepareCoordinator::new(); @@ -727,6 +732,7 @@ mod tests { assert!(coordinator.abandon_stopping(&id("u2")).is_none()); } + #[pa_test_scratch::pa_test] #[test] fn prepared_self_expiry_survives_coordinator_death() { // Spec §5/I1: a coordinator dying after the ack leaves at worst a @@ -761,6 +767,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn expiry_wait_parks_without_timers_and_rearms_when_the_budget_moves() { struct WakeCount(AtomicUsize); impl Wake for WakeCount { @@ -811,6 +818,7 @@ mod tests { assert!(armed.elapsed() < Duration::from_secs(1)); } + #[pa_test_scratch::pa_test] #[test] fn abort_is_idempotent_and_owns_only_prepare_phases() { let coordinator = PrepareCoordinator::new(); @@ -844,6 +852,7 @@ mod tests { assert_eq!(coordinator.active_state(), Some(PrepareState::Stopping)); } + #[pa_test_scratch::pa_test] #[test] fn admission_gate_matches_the_ts_contract() { // Reads and attach always pass, whatever the state. @@ -883,6 +892,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn marker_expiry_helpers_agree_with_pa_types_verdict() { let budget = budget(); @@ -914,6 +924,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn prepared_artifact_lifecycle_is_durable_and_idempotent() { let dir = tempfile::tempdir().expect("tempdir"); @@ -957,6 +968,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn mutation_drain_latch_waits_and_times_out() { let latch = MutationDrainLatch::new(); latch.begin(); diff --git a/crates/pa-daemon/src/update_restore.rs b/crates/pa-daemon/src/update_restore.rs index 482b469f0..1391114ad 100644 --- a/crates/pa-daemon/src/update_restore.rs +++ b/crates/pa-daemon/src/update_restore.rs @@ -906,6 +906,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn legacy_restore_replays_context_and_actions_before_continuing_each_interrupted_kind() { for flag in [ "streaming", @@ -976,6 +977,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn legacy_restore_resumes_an_accepted_turn_without_duplicating_its_prompt() { let mut row = two_row_roster().sessions.remove(0); row.should_resume = true; @@ -1014,6 +1016,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn legacy_restore_does_not_resume_idle_sessions_and_reports_failed_queue_restore() { let mut row = two_row_roster().sessions.remove(0); row.queue.actions = json!({ "formatVersion": 1, "actions": [{"id": "queued"}] }); @@ -1062,6 +1065,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn legacy_restore_releases_input_pause_when_abort_fails() { let mut row = two_row_roster().sessions.remove(0); row.should_resume = true; @@ -1102,6 +1106,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn legacy_manifest_restores_real_worker_context_and_both_queue_lanes() { let dir = tempfile::TempDir::new().unwrap(); let worker = crate::worker::Worker::new( @@ -1163,6 +1168,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn legacy_busy_restore_keeps_follow_up_behind_continuation_with_a_running_worker() { let dir = tempfile::TempDir::new().unwrap(); let worker = crate::worker::Worker::new( @@ -1247,6 +1253,7 @@ mod tests { worker.work_notify.notify_one(); } + #[pa_test_scratch::pa_test] #[test] fn legacy_child_metadata_replaces_only_the_old_parent_handle() { let mut payload = json!({ "runtimeMetadata": { @@ -1269,6 +1276,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn hello_resume_reports_progress_before_and_after_settle() { let progress = RestoreProgress::new(); @@ -1299,6 +1307,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn queued_attach_unblocks_when_only_its_target_settles() { let progress = std::sync::Arc::new(RestoreProgress::new()); progress.begin(Some(&two_row_roster())); @@ -1321,6 +1330,7 @@ mod tests { assert!(tokio::time::timeout(tick, queued_a).await.is_ok()); } + #[pa_test_scratch::pa_test] #[test] fn settle_target_failure_answers_the_typed_attach_error_per_row() { let progress = RestoreProgress::new(); @@ -1336,6 +1346,7 @@ mod tests { assert!(progress.settled_failure("unknown-id").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn registry_shaped_selectors_own_their_row_and_ambiguous_ones_own_nothing() { let progress = RestoreProgress::new(); @@ -1362,6 +1373,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn an_adoption_settle_skips_a_row_pending_its_continuation() { let mut roster = two_row_roster(); roster.sessions[0].should_resume = true; @@ -1386,6 +1398,7 @@ mod tests { assert!(tokio::time::timeout(tick, queued_a).await.is_ok()); } + #[pa_test_scratch::pa_test] #[test] fn legacy_adoption_waits_for_manifest_queue_replay_even_when_idle() { let mut roster = two_row_roster(); @@ -1399,6 +1412,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn a_continuation_skip_is_still_progress_for_the_other_waiters() { let mut roster = two_row_roster(); roster.sessions[0].should_resume = true; @@ -1430,6 +1444,7 @@ mod tests { } #[tokio::test(start_paused = true)] + #[pa_test_scratch::pa_test] async fn settle_progress_rearms_a_waiters_quiet_budget_past_the_first_deadline() { let progress = std::sync::Arc::new(RestoreProgress::new()); progress.begin(Some(&two_row_roster())); @@ -1455,6 +1470,7 @@ mod tests { assert!(tokio::time::timeout(tick, queued_a).await.is_ok()); } + #[pa_test_scratch::pa_test] #[test] fn settle_target_without_a_registered_pass_is_a_no_op() { let progress = RestoreProgress::new(); @@ -1464,6 +1480,7 @@ mod tests { assert!(progress.settled_failure("a-1").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn restore_rows_sort_bottom_up_deepest_first() { let row = |id: &str, depth: u32, subagent: bool| UpdateRosterSession { @@ -1499,6 +1516,7 @@ mod tests { assert_eq!(ids, ["grandchild", "child", "top"]); } + #[pa_test_scratch::pa_test] #[test] fn settled_failure_matches_durable_active_and_stem_selectors() { let progress = RestoreProgress::new(); @@ -1546,6 +1564,7 @@ mod tests { assert!(progress.settled_failure("unknown-id").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn boot_sweep_removes_socket_dir_and_legacy_names() { let dir = tempfile::TempDir::new().unwrap(); @@ -1570,6 +1589,7 @@ mod tests { assert!(other_socket_dir.exists()); } + #[pa_test_scratch::pa_test] #[test] fn boot_sweep_preserves_socket_bound_lost_reply_sources_until_attempts_finish() { let dir = tempfile::TempDir::new().unwrap(); @@ -1643,6 +1663,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn consume_roster_env_none_without_the_env() { // NOTE: process env is global; this documents the None path only when no diff --git a/crates/pa-daemon/src/update_roster.rs b/crates/pa-daemon/src/update_roster.rs index a97bb436d..05713079b 100644 --- a/crates/pa-daemon/src/update_roster.rs +++ b/crates/pa-daemon/src/update_roster.rs @@ -511,6 +511,7 @@ mod tests { } } + #[pa_test_scratch::pa_test] #[test] fn roster_assembles_all_four_sections() { let dir = tempfile::tempdir().unwrap(); @@ -631,6 +632,7 @@ mod tests { assert!(!encoded.as_object().unwrap().contains_key("archived")); } + #[pa_test_scratch::pa_test] #[test] fn missing_session_id_fails_the_row() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/update_stop.rs b/crates/pa-daemon/src/update_stop.rs index f00db551a..ba047b279 100644 --- a/crates/pa-daemon/src/update_stop.rs +++ b/crates/pa-daemon/src/update_stop.rs @@ -190,6 +190,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn stopped_and_refused_verdicts_carry_the_spec_budgets() { let fake = Arc::new(FakeWorkers { acks: Mutex::new(vec![true, true, false]), @@ -227,6 +228,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn no_ack_means_no_kill_and_the_verdict_names_the_worker() { // The spec's slice-3 verifier: a worker that never acks is Refused // (the session keeps running — nothing signals or kills). @@ -247,6 +249,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn ts_worker_request_timeout_parity() { // TS `UPDATE_RESTART_WORKER_REQUEST_TIMEOUT_MS = 90_000`. diff --git a/crates/pa-daemon/src/user_bash.rs b/crates/pa-daemon/src/user_bash.rs index b68521339..3bb966939 100644 --- a/crates/pa-daemon/src/user_bash.rs +++ b/crates/pa-daemon/src/user_bash.rs @@ -991,6 +991,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn execute_bash_and_wait_matches_the_ts_result_shape() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; @@ -1040,6 +1041,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn an_abort_stays_with_every_admitted_run_when_another_run_starts() { let user_bash = UserBash::new(); @@ -1064,6 +1066,7 @@ mod tests { assert!(!user_bash.is_running()); } + #[pa_test_scratch::pa_test] #[test] fn an_abandoned_awaited_run_releases_the_flag() { let user_bash = UserBash::new(); @@ -1079,6 +1082,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_awaited_bash_run_reports_running_to_the_connection_state() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; @@ -1125,6 +1129,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn execute_bash_claims_the_slot_and_aborts() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; @@ -1289,6 +1294,7 @@ mod tests { /// child would keep running and hold the output pipes open. #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn abort_bash_kills_the_commands_child_processes() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; @@ -1314,6 +1320,7 @@ mod tests { /// leaves the user's processes running. #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn shutdown_kills_the_running_commands_child_processes() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; @@ -1332,6 +1339,7 @@ mod tests { /// holding the inherited output pipes does not hold the run open (TS `waitForChildProcess`). #[cfg(unix)] #[tokio::test] + #[pa_test_scratch::pa_test] async fn a_backgrounded_process_does_not_hold_the_run_open() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; @@ -1368,6 +1376,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn transient_execute_bash_records_nothing() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; @@ -1403,6 +1412,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn execute_bash_and_wait_refuses_a_missing_cwd() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; @@ -1425,6 +1435,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn sanitize_output_matches_the_ts_chain() { assert_eq!(sanitize_output("clean\r\noutput"), "clean\noutput"); @@ -1439,6 +1450,7 @@ mod tests { assert_eq!(sanitize_output("format\u{fff9}gone"), "formatgone"); } + #[pa_test_scratch::pa_test] #[test] fn truncate_tail_keeps_the_tail_budget() { let (content, truncated) = truncate_tail("one\ntwo\nthree\n"); @@ -1469,6 +1481,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_shutdown_gate_cannot_close_between_a_streamed_claim_and_its_registration() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; @@ -1512,6 +1525,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_shutdown_gate_cannot_close_between_an_awaited_admission_and_its_registration() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; @@ -1555,6 +1569,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn the_close_abort_cancels_an_admitted_awaited_run_and_settles_after_it() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; @@ -1583,6 +1598,7 @@ mod tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn an_awaited_dispatch_against_a_closing_gate_records_no_row() { let cwd = tempfile::tempdir().expect("tempdir"); let worker = created_worker(cwd.path()).await; diff --git a/crates/pa-daemon/src/util.rs b/crates/pa-daemon/src/util.rs index 2a6ef5aae..152a8d88e 100644 --- a/crates/pa-daemon/src/util.rs +++ b/crates/pa-daemon/src/util.rs @@ -124,6 +124,7 @@ fn civil_from_days(z: i64) -> (i64, u32, u32) { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn iso_matches_known_dates() { assert_eq!(iso_from_unix_ms(0), "1970-01-01T00:00:00.000Z"); @@ -139,6 +140,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn iso_rejects_impossible_calendar_dates() { assert_eq!(iso_to_unix_ms("2026-02-31T00:00:00Z"), None); diff --git a/crates/pa-daemon/src/worker/agent_message_tests.rs b/crates/pa-daemon/src/worker/agent_message_tests.rs index 65e3168ba..e58b656c0 100644 --- a/crates/pa-daemon/src/worker/agent_message_tests.rs +++ b/crates/pa-daemon/src/worker/agent_message_tests.rs @@ -43,6 +43,7 @@ fn queue_texts(core: &Mutex, lane: Lane) -> Vec { /// Receipt shape: id, source, target, sender echo, delivered status + timestamp, /// and the rendered prompt on the steering lane. #[tokio::test] +#[pa_test_scratch::pa_test] async fn deliver_message_answers_the_ts_receipt_shape() { let worker = created_worker().await; let response = worker @@ -101,6 +102,7 @@ async fn deliver_message_answers_the_ts_receipt_shape() { /// The row's content is the rendered prompt; the details carry the identity the /// collapsed card reads, and the marker still targets `agent_messages_clear`/`pause`. #[tokio::test] +#[pa_test_scratch::pa_test] async fn deliver_message_carries_the_agent_message_custom_row() { let worker = created_worker().await; let response = worker @@ -164,6 +166,7 @@ async fn deliver_message_carries_the_agent_message_custom_row() { /// An explicit `follow_up` delivery queues behind current work instead of steering. #[tokio::test] +#[pa_test_scratch::pa_test] async fn deliver_message_follow_up_lane_and_subagent_sender() { let worker = created_worker().await; let response = worker @@ -197,6 +200,7 @@ async fn deliver_message_follow_up_lane_and_subagent_sender() { /// A busy session reports `queued` with `queuedAt` (`queueIfBusy`). #[tokio::test] +#[pa_test_scratch::pa_test] async fn deliver_message_while_busy_queues() { let worker = created_worker().await; worker.core.lock().unwrap().busy = true; @@ -223,6 +227,7 @@ async fn deliver_message_while_busy_queues() { /// Agent-message deliveries admit as background work: later user input jumps /// them, FIFO behind earlier user input, on both lanes. #[tokio::test] +#[pa_test_scratch::pa_test] async fn user_input_jumps_parked_agent_message_deliveries() { for (command, delivery_mode, lane) in [ ("steer", "steer", "steering"), @@ -272,6 +277,7 @@ async fn user_input_jumps_parked_agent_message_deliveries() { /// The pending-capacity guard fails with the TS error string. #[tokio::test] +#[pa_test_scratch::pa_test] async fn deliver_message_respects_the_pending_capacity() { let worker = created_worker().await; { @@ -313,6 +319,7 @@ async fn deliver_message_respects_the_pending_capacity() { /// TS `createAttachResult` key order: the slim response carries the messages /// exactly once; the non-slim duplicate is byte-identical to the copy. #[tokio::test] +#[pa_test_scratch::pa_test] async fn attach_response_wire_bytes_keep_the_ts_key_order() { let worker = created_worker().await; { @@ -435,12 +442,14 @@ async fn attach_response_wire_bytes_keep_the_ts_key_order() { /// nothing (unix: the link endpoint is an `AF_UNIX` socket). #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn clear_queue_bounces_dropped_agent_messages_to_their_senders() { assert_clear_queue_bounces(/*restore_queue*/ false).await; } #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn clear_queue_bounces_recovered_agent_messages_to_their_senders() { assert_clear_queue_bounces(/*restore_queue*/ true).await; } @@ -571,6 +580,7 @@ async fn assert_clear_queue_bounces(restore_queue: bool) { /// boundary. An idle target therefore wakes on the first delivery instead of /// refusing it, and the gate does not outlive the hold. #[tokio::test] +#[pa_test_scratch::pa_test] async fn deliver_message_releases_a_stale_suspension_on_an_idle_target() { let worker = created_worker().await; worker.core.lock().unwrap().queued_input_suspended = true; @@ -604,6 +614,7 @@ async fn deliver_message_releases_a_stale_suspension_on_an_idle_target() { /// it instead of failing, and the receipt says queued plus why. The next /// resume boundary (an explicit `resume_queue` here) delivers the park. #[tokio::test] +#[pa_test_scratch::pa_test] async fn deliver_message_parks_under_a_held_suspension_with_receipt_truth() { let worker = created_worker().await; crate::worker::tests::park_steering_row(&worker, "held user row"); @@ -656,6 +667,7 @@ async fn deliver_message_parks_under_a_held_suspension_with_receipt_truth() { /// parked rows are agent-message deliveries must not outlive the turn that /// parked them (issue #33), or two agents could keep a session deaf by talking. #[tokio::test] +#[pa_test_scratch::pa_test] async fn agent_rows_never_protect_a_hold() { let worker = created_worker().await; { @@ -698,6 +710,7 @@ async fn agent_rows_never_protect_a_hold() { /// parked keeps the row parked after the turn settles, so `queued` alone would /// tell the caller it will deliver at the turn boundary when it will not. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_busy_target_under_a_protected_hold_reports_the_hold() { let worker = created_worker().await; crate::worker::tests::park_steering_row(&worker, "held user row"); @@ -742,6 +755,7 @@ async fn a_busy_target_under_a_protected_hold_reports_the_hold() { /// row, no compaction window) is queued behind the turn alone. The turn /// boundary releases that gate, so the receipt must not claim a hold. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_busy_target_under_an_unprotected_hold_reports_a_plain_park() { let worker = created_worker().await; { @@ -775,6 +789,7 @@ async fn a_busy_target_under_an_unprotected_hold_reports_a_plain_park() { /// A compaction window outranks a standing hold in the receipt: the delivery /// cannot run until the compaction ends, whatever the hold does afterwards. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_compaction_window_outranks_the_hold_reason() { let worker = created_worker().await; crate::worker::tests::park_steering_row(&worker, "held user row"); @@ -805,6 +820,7 @@ async fn the_compaction_window_outranks_the_hold_reason() { /// distinction is deterministic - a caller learns deliverability from its own /// answer instead of retrying blind (issue #32). #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_idle_hold_refuses_a_plain_prompt_and_parks_an_agent_message() { let worker = created_worker().await; crate::worker::tests::park_steering_row(&worker, "held user row"); diff --git a/crates/pa-daemon/src/worker/commands.rs b/crates/pa-daemon/src/worker/commands.rs index 934b2d54c..f6902a681 100644 --- a/crates/pa-daemon/src/worker/commands.rs +++ b/crates/pa-daemon/src/worker/commands.rs @@ -973,6 +973,7 @@ mod bounce_text_tests { use super::cleared_agent_message_bounce_text; use pa_core::session_engine::agent_messaging::DEFAULT_AGENT_MESSAGE_MAX_CHARS; + #[pa_test_scratch::pa_test] #[test] fn bounce_text_limits_receiver_and_body_without_losing_the_notice() { for (receiver, message) in [ diff --git a/crates/pa-daemon/src/worker/compaction_admission_tests.rs b/crates/pa-daemon/src/worker/compaction_admission_tests.rs index 0f26b2cd8..3d1fdea9f 100644 --- a/crates/pa-daemon/src/worker/compaction_admission_tests.rs +++ b/crates/pa-daemon/src/worker/compaction_admission_tests.rs @@ -98,6 +98,7 @@ async fn wait_for_state(readiness: impl Fn() -> bool) { /// A steer whose resume site fires MID-COMPACTION must DEFER: it delivers after /// the window (the tail wake), `compaction_end` preceding the racing row. #[tokio::test] +#[pa_test_scratch::pa_test] async fn steer_mid_compaction_defers_and_delivers_after_the_window() { let worker = compaction_admission_worker(json!({ "responses": [ { "summary": "racing window summary", "delayMs": 1500 } ], @@ -206,6 +207,7 @@ async fn steer_mid_compaction_defers_and_delivers_after_the_window() { /// With no compaction in flight the same steer and a plain prompt admit as before. #[tokio::test] +#[pa_test_scratch::pa_test] async fn idle_sessions_admit_the_steering_and_plain_prompt_classes() { let worker = compaction_admission_worker(json!({})).await; let mut subscription = worker.events.subscribe(); diff --git a/crates/pa-daemon/src/worker/context_selection.rs b/crates/pa-daemon/src/worker/context_selection.rs index be79080eb..a43d50e99 100644 --- a/crates/pa-daemon/src/worker/context_selection.rs +++ b/crates/pa-daemon/src/worker/context_selection.rs @@ -231,6 +231,7 @@ fn unreadable_compaction_reason(rest: &pa_types::JsonMap) -> String { mod tests { use super::*; + #[pa_test_scratch::pa_test] #[test] fn admitted_terminal_rows_persist_during_shutdown_until_execution_lock_release() { let dir = tempfile::tempdir().unwrap(); @@ -294,6 +295,7 @@ mod tests { assert!(SessionFile::open(&path).unwrap().entry("late").is_none()); } + #[pa_test_scratch::pa_test] #[test] fn an_unreadable_compaction_row_reports_the_session_and_reason_without_touching_the_file() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/pa-daemon/src/worker/prompt_image_tests.rs b/crates/pa-daemon/src/worker/prompt_image_tests.rs index fe676c756..bbb6150ce 100644 --- a/crates/pa-daemon/src/worker/prompt_image_tests.rs +++ b/crates/pa-daemon/src/worker/prompt_image_tests.rs @@ -2,6 +2,7 @@ use super::*; use serde_json::json; +#[pa_test_scratch::pa_test] #[test] fn parses_wire_images_and_drops_incomplete_entries() { let payload = json!({ @@ -19,6 +20,7 @@ fn parses_wire_images_and_drops_incomplete_entries() { assert_eq!(images[0].mime_type, "image/png"); } +#[pa_test_scratch::pa_test] #[test] fn missing_or_empty_images_admit_text_only() { assert!(parse_prompt_images(&json!({ "message": "plain" })).is_empty()); @@ -44,6 +46,7 @@ fn test_worker() -> Arc { /// The attachments ride the queue item into the engine as multimodal user content. #[tokio::test] +#[pa_test_scratch::pa_test] async fn prompt_with_images_queues_the_images_with_the_message() { let worker = test_worker(); let created = worker diff --git a/crates/pa-daemon/src/worker/recovery_verdict_tests.rs b/crates/pa-daemon/src/worker/recovery_verdict_tests.rs index f9480c83a..a05829c7e 100644 --- a/crates/pa-daemon/src/worker/recovery_verdict_tests.rs +++ b/crates/pa-daemon/src/worker/recovery_verdict_tests.rs @@ -44,6 +44,7 @@ fn latest_record(worker: &Worker) -> crate::journal::WorkerRecoveryRecord { /// The admission (not the pickup) proves the work, so a plain boot revives the worker. #[tokio::test] +#[pa_test_scratch::pa_test] async fn idle_time_injected_admission_is_busy_evidence() { let worker = created_worker_with_journal().await; // Settle first: the create record's busy=true must not mask the @@ -91,6 +92,7 @@ async fn idle_time_injected_admission_is_busy_evidence() { /// An idle session wakes on an invisible injected row; the admission is journal busy evidence. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_bash_completion_notice_admits_the_steering_lane_with_busy_evidence() { let worker = created_worker_with_journal().await; worker.dispatch("clear_queue", &json!({})).await; @@ -156,6 +158,7 @@ async fn a_bash_completion_notice_admits_the_steering_lane_with_busy_evidence() /// A busy session queues the notice as a visible steer row (TS `queueIfBusy`). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_bash_completion_notice_on_a_busy_session_queues_a_visible_steer_row() { let worker = created_worker_with_journal().await; worker.core.lock().unwrap().busy = true; @@ -181,6 +184,7 @@ async fn a_bash_completion_notice_on_a_busy_session_queues_a_visible_steer_row() /// The withdrawal settles the busy evidence so the journal never promises a replay. #[tokio::test] +#[pa_test_scratch::pa_test] async fn bash_consumed_withdraws_the_undelivered_notice_and_settles() { let worker = created_worker_with_journal().await; worker.dispatch("clear_queue", &json!({})).await; @@ -248,6 +252,7 @@ async fn bash_consumed_withdraws_the_undelivered_notice_and_settles() { /// Cancelling an owned queued admission settles the verdict: removed rows /// leave no busy evidence and no replayable snapshot. #[tokio::test] +#[pa_test_scratch::pa_test] async fn cancelled_admission_drop_settles_the_verdict() { let worker = created_worker_with_journal().await; worker.dispatch("clear_queue", &json!({})).await; @@ -287,6 +292,7 @@ async fn cancelled_admission_drop_settles_the_verdict() { /// The in-flight turn is live work: only its own `turn_end` (after the idle flip) settles it. #[tokio::test] +#[pa_test_scratch::pa_test] async fn mid_turn_withdrawal_keeps_the_in_flight_turn_busy() { let worker = created_worker_with_journal().await; // Mid-turn: the runner is streaming, and the withdrawal leaves diff --git a/crates/pa-daemon/src/worker/replacement_gate_tests.rs b/crates/pa-daemon/src/worker/replacement_gate_tests.rs index 09a8f2acd..fd25cda6d 100644 --- a/crates/pa-daemon/src/worker/replacement_gate_tests.rs +++ b/crates/pa-daemon/src/worker/replacement_gate_tests.rs @@ -100,6 +100,7 @@ fn recording_worker(dir: &Path, events: std::sync::Arc (Option, Vec std::sync::Arc /// TS `compact()`'s active-goal branch: a successful compact mints the owed continuation. #[tokio::test] +#[pa_test_scratch::pa_test] async fn compact_with_active_goal_schedules_the_continue() { let worker = goal_dispatch_worker(json!({ "status": "active", @@ -86,6 +87,7 @@ async fn compact_with_active_goal_schedules_the_continue() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn compact_with_active_goal_and_parked_work_skips_the_mint() { let worker = goal_dispatch_worker(json!({ "status": "active", @@ -144,6 +146,7 @@ async fn compact_with_active_goal_and_parked_work_skips_the_mint() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn compact_with_paused_goal_never_continues() { let worker = goal_dispatch_worker(json!({ "status": "paused", @@ -193,6 +196,7 @@ async fn compact_with_paused_goal_never_continues() { /// the faux script into a misleading count mismatch). #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn goal_turn_end_loop_runs_to_completion() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() @@ -322,6 +326,7 @@ async fn goal_turn_end_loop_runs_to_completion() { #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn goal_pause_withdraws_the_queued_continuation() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() @@ -451,6 +456,7 @@ fn thread_goal_state_rows(path: &std::path::Path) -> Vec { /// The mirror row is what a recovery rebuild replays. #[tokio::test] +#[pa_test_scratch::pa_test] async fn goal_update_events_mirror_the_durable_goal_row() { let (worker, file) = goal_dispatch_worker_with_store(json!({ "emitUpdateOnPrompt": true, @@ -483,6 +489,7 @@ async fn goal_update_events_mirror_the_durable_goal_row() { /// The mint persists its row before the `goal_update`, so the count survives a crash. #[tokio::test] +#[pa_test_scratch::pa_test] async fn compact_mint_persists_the_goal_state_row() { let (worker, file) = goal_dispatch_worker_with_store(json!({ "status": "active", diff --git a/crates/pa-daemon/src/worker/tests/kill_broadcast_tests.rs b/crates/pa-daemon/src/worker/tests/kill_broadcast_tests.rs index 985108ef5..c9d8e411b 100644 --- a/crates/pa-daemon/src/worker/tests/kill_broadcast_tests.rs +++ b/crates/pa-daemon/src/worker/tests/kill_broadcast_tests.rs @@ -5,6 +5,7 @@ use super::*; /// accounting skips it. #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn aborted_turn_row_broadcasts_and_persists_through_the_worker_gate() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() @@ -189,6 +190,7 @@ async fn aborted_turn_row_broadcasts_and_persists_through_the_worker_gate() { /// revives the session. #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn kill_cancels_the_sessions_scheduled_jobs() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() @@ -284,6 +286,7 @@ async fn kill_cancels_the_sessions_scheduled_jobs() { /// `session_closed` frame. #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn kill_cancels_a_mid_provider_wait_turn_and_surfaces_the_aborted_row() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() @@ -428,6 +431,7 @@ async fn kill_cancels_a_mid_provider_wait_turn_and_surfaces_the_aborted_row() { /// stays off the wire and file while `abort` broadcasts it. #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn compact_interrupt_swallows_the_aborted_row() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() @@ -527,6 +531,7 @@ async fn compact_interrupt_swallows_the_aborted_row() { /// row. Its actual empty vector must survive the worker's collector and writer. #[allow(clippy::await_holding_lock)] // the unchanged first response uses the process-global faux registry #[tokio::test] +#[pa_test_scratch::pa_test] async fn provider_aborted_empty_content_survives_worker_wire_and_journal() { use crate::agent_engine::tests::abort_fixture::{AbortCase, AbortFixture, NATIVE_RESPONSE_ID}; diff --git a/crates/pa-daemon/src/worker/tests/queue_tests.rs b/crates/pa-daemon/src/worker/tests/queue_tests.rs index e93036ef9..38afe612b 100644 --- a/crates/pa-daemon/src/worker/tests/queue_tests.rs +++ b/crates/pa-daemon/src/worker/tests/queue_tests.rs @@ -18,6 +18,7 @@ fn priority_test_item(message: &str, policy: TurnPolicy) -> QueuedItem { } } +#[pa_test_scratch::pa_test] #[test] fn queue_priority_interleaves_lanes_fifo_and_preserves_explicit_order() { let mut core = SessionCore::test_core(None, "/tmp".to_string()); @@ -118,6 +119,7 @@ fn queue_priority_interleaves_lanes_fifo_and_preserves_explicit_order() { ); } +#[pa_test_scratch::pa_test] #[test] fn queue_priority_drains_four_tiers_and_pinned_front() { let mut core = SessionCore::test_core(None, "/tmp".to_string()); @@ -159,6 +161,7 @@ fn queue_priority_drains_four_tiers_and_pinned_front() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn rpc_custom_rows_do_not_gain_human_queue_priority() { let worker = created_dispatch_worker().await; let pause = worker.dispatch("acquire_session_input_pause", &json!({ @@ -216,6 +219,7 @@ async fn rpc_custom_rows_do_not_gain_human_queue_priority() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn waiting_rpc_prompt_overtakes_background_steer_and_settles() { let worker = created_dispatch_worker().await; let pause = worker.dispatch("acquire_session_input_pause", &json!({ @@ -272,6 +276,7 @@ async fn waiting_rpc_prompt_overtakes_background_steer_and_settles() { assert!(settled.success, "waiting prompt failed: {settled:?}"); } +#[pa_test_scratch::pa_test] #[test] fn legacy_queue_record_priority_defaults_by_row_and_keeps_order() { let dir = std::env::temp_dir().join(format!("pa-worker-{}", uuid::Uuid::new_v4())); @@ -308,6 +313,7 @@ fn legacy_queue_record_priority_defaults_by_row_and_keeps_order() { std::fs::remove_dir_all(dir).unwrap(); } +#[pa_test_scratch::pa_test] #[test] fn queue_snapshot_round_trips_through_the_recovery_journal() { let dir = std::env::temp_dir().join(format!("pa-worker-{}", uuid::Uuid::new_v4())); @@ -382,6 +388,7 @@ fn queue_snapshot_round_trips_through_the_recovery_journal() { } /// A version-1 queue snapshot (pre-item text lanes a prior binary wrote). +#[pa_test_scratch::pa_test] #[test] fn a_version_one_queue_snapshot_restores_as_plain_rows() { let dir = std::env::temp_dir().join(format!("pa-worker-{}", uuid::Uuid::new_v4())); @@ -408,6 +415,7 @@ fn a_version_one_queue_snapshot_restores_as_plain_rows() { /// Only the visible plain-user steering items arm; agent-message deliveries /// and injected custom rows never join, and an empty lane arms nothing. #[tokio::test] +#[pa_test_scratch::pa_test] async fn forced_batch_arming_classifies_the_visible_plain_rows() { let worker = created_dispatch_worker().await; { diff --git a/crates/pa-daemon/src/worker/tests/shutdown_usage_tests.rs b/crates/pa-daemon/src/worker/tests/shutdown_usage_tests.rs index bbc140c18..c2af55869 100644 --- a/crates/pa-daemon/src/worker/tests/shutdown_usage_tests.rs +++ b/crates/pa-daemon/src/worker/tests/shutdown_usage_tests.rs @@ -107,6 +107,7 @@ async fn child_with_usage( #[allow(clippy::await_holding_lock)] // The faux provider registry is process-global. #[tokio::test] +#[pa_test_scratch::pa_test] async fn shutdown_flushes_child_usage_before_closing_canonical_authority() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() @@ -151,6 +152,7 @@ async fn shutdown_flushes_child_usage_before_closing_canonical_authority() { #[allow(clippy::await_holding_lock)] // The faux provider registry is process-global. #[tokio::test] +#[pa_test_scratch::pa_test] async fn close_refuses_to_discard_owed_usage_after_source_conflict() { use std::io::Write; let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK @@ -198,6 +200,7 @@ async fn close_refuses_to_discard_owed_usage_after_source_conflict() { #[allow(clippy::await_holding_lock)] // The faux provider registry is process-global. #[tokio::test] +#[pa_test_scratch::pa_test] async fn close_keeps_accounting_reachable_until_child_source_can_be_read() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() diff --git a/crates/pa-daemon/src/worker/tests/sidecar_exit_tests.rs b/crates/pa-daemon/src/worker/tests/sidecar_exit_tests.rs index 1fa0269ff..627d8d8b0 100644 --- a/crates/pa-daemon/src/worker/tests/sidecar_exit_tests.rs +++ b/crates/pa-daemon/src/worker/tests/sidecar_exit_tests.rs @@ -65,6 +65,7 @@ async fn kill(worker: &Worker) { #[cfg(unix)] #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_ended_worker_session_leaves_a_current_info_sidecar() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() @@ -93,6 +94,7 @@ async fn an_ended_worker_session_leaves_a_current_info_sidecar() { #[cfg(unix)] #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_reopened_session_ends_with_a_current_info_sidecar() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() diff --git a/crates/pa-daemon/src/worker/tests/summary_tests.rs b/crates/pa-daemon/src/worker/tests/summary_tests.rs index 698b3827a..a9631dac5 100644 --- a/crates/pa-daemon/src/worker/tests/summary_tests.rs +++ b/crates/pa-daemon/src/worker/tests/summary_tests.rs @@ -13,6 +13,7 @@ fn inputs() -> SummaryInputs { } } +#[pa_test_scratch::pa_test] #[test] fn sender_child_edge_decides_the_relationship_label() { let true_child = json!({ @@ -70,6 +71,7 @@ fn sender_child_edge_decides_the_relationship_label() { )); } +#[pa_test_scratch::pa_test] #[test] fn summary_lifecycle_is_message_based() { let empty = SessionCore::test_core(None, "/tmp".to_string()); @@ -124,6 +126,7 @@ fn summary_lifecycle_is_message_based() { /// its subagents runs (each child counts its own descendants the same /// way), so every roster surface classifies it running; with no running /// subagents it is idle again. Its own-work flag stays its own. +#[pa_test_scratch::pa_test] #[test] fn running_subagents_keep_an_idle_session_working() { let core = SessionCore::test_core(None, "/tmp".to_string()); @@ -158,6 +161,7 @@ fn running_subagents_keep_an_idle_session_working() { /// The live row's `usage` is the whole-file own-usage fold the saved /// row publishes, including spend before the latest compaction and the /// compaction's own call. +#[pa_test_scratch::pa_test] #[test] fn live_summary_usage_is_the_catalog_fold() { let dir = std::env::temp_dir().join(format!("pa-worker-usage-{}", uuid::Uuid::new_v4())); @@ -243,6 +247,7 @@ fn live_summary_usage_is_the_catalog_fold() { } /// The live row bills the turn's own spend instead of reporting nothing. +#[pa_test_scratch::pa_test] #[test] fn pathless_summary_usage_folds_the_in_memory_entries() { let mut store = crate::session_store::SessionFile::create("/tmp", None, 0); @@ -269,6 +274,7 @@ fn pathless_summary_usage_folds_the_in_memory_entries() { ); } +#[pa_test_scratch::pa_test] #[test] fn display_ids_are_twelve_hex() { let id = crate::util::new_display_id(); @@ -279,6 +285,7 @@ fn display_ids_are_twelve_hex() { /// The summary carries the live note, and the next run's boundaries clear it. #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn summary_carries_the_live_note_until_the_run_boundaries_clear_it() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() @@ -353,6 +360,7 @@ async fn summary_carries_the_live_note_until_the_run_boundaries_clear_it() { /// an injected pending receipt or a substitute canonical authority. #[allow(clippy::await_holding_lock)] // the faux registry must span the async worker flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn state_and_prompt_admission_wait_for_existing_build_gate() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK .lock() diff --git a/crates/pa-daemon/src/worker/tests/warning_marker_tests.rs b/crates/pa-daemon/src/worker/tests/warning_marker_tests.rs index 2de86f6df..162e9cbf7 100644 --- a/crates/pa-daemon/src/worker/tests/warning_marker_tests.rs +++ b/crates/pa-daemon/src/worker/tests/warning_marker_tests.rs @@ -70,6 +70,7 @@ fn worker_in(dir: &std::path::Path, session_id: &str) -> Worker { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_mark_command_persists_and_serves_the_gate() { let dir = tempfile::tempdir().unwrap(); let session_dir = dir.path().join("sessions"); diff --git a/crates/pa-daemon/src/worker/tests/windowed_attach_tests.rs b/crates/pa-daemon/src/worker/tests/windowed_attach_tests.rs index f6efc7ec1..da441245b 100644 --- a/crates/pa-daemon/src/worker/tests/windowed_attach_tests.rs +++ b/crates/pa-daemon/src/worker/tests/windowed_attach_tests.rs @@ -156,6 +156,7 @@ const TUI_CAPABILITIES: &[&str] = &[ ]; #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_windowed_attach_serves_a_tool_result_safe_tail() { let dir = session_dir(); let path = dir.join("windowed-tail.jsonl"); @@ -279,6 +280,7 @@ async fn a_windowed_attach_serves_a_tool_result_safe_tail() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_windowed_attach_never_cuts_inside_the_compaction_retained_segment() { let dir = session_dir(); let path = dir.join("windowed-compacted.jsonl"); @@ -328,6 +330,7 @@ async fn a_windowed_attach_never_cuts_inside_the_compaction_retained_segment() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_windowed_attach_preserves_iso_and_fractional_prompt_times() { for timestamp in [ json!(2000.75), @@ -369,6 +372,7 @@ async fn a_windowed_attach_preserves_iso_and_fractional_prompt_times() { /// a windowed attach streams the tail alone, and the summary keeps the /// session total the backfill cursor (`historyBefore`) completes. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_chunked_windowed_attach_streams_the_count_it_carries() { let dir = session_dir(); let path = dir.join("windowed-chunked.jsonl"); @@ -439,6 +443,7 @@ async fn a_chunked_windowed_attach_streams_the_count_it_carries() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_windowed_attach_keeps_interleaved_tool_pairs_together() { for scenario in [0, 1, 2] { let crossing = scenario != 0; @@ -538,6 +543,7 @@ async fn branched_worker() -> (tempfile::TempDir, std::sync::Arc) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn anchored_backfill_rejects_other_client_branch_navigation() { for target in ["sibling", "m0000300"] { let (_dir, worker) = branched_worker().await; @@ -580,6 +586,7 @@ async fn anchored_backfill_rejects_other_client_branch_navigation() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn anchored_backfill_accepts_descendant_appends_and_restored_branch() { let (_dir, worker) = branched_worker().await; let original = full_messages(&worker).await; @@ -623,6 +630,7 @@ async fn anchored_backfill_accepts_descendant_appends_and_restored_branch() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn display_transcript_restores_precompaction_history_without_sibling_leakage() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("display-history.jsonl"); @@ -741,6 +749,7 @@ async fn display_transcript_restores_precompaction_history_without_sibling_leaka } #[tokio::test] +#[pa_test_scratch::pa_test] async fn display_transcript_fences_full_replacements_and_prefixes() { let (_dir, worker) = branched_worker().await; let mut caps = TUI_CAPABILITIES.to_vec(); @@ -825,6 +834,7 @@ async fn display_transcript_fences_full_replacements_and_prefixes() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn display_transcript_attach_uses_original_client_capabilities() { let (_dir, worker) = branched_worker().await; for (outer, client, expected) in [ @@ -848,6 +858,7 @@ async fn display_transcript_attach_uses_original_client_capabilities() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn display_transcript_corrupt_branch_attach_falls_back_without_sibling_leakage() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("incomplete.jsonl"); diff --git a/crates/pa-daemon/src/worker/turn_stream_tests.rs b/crates/pa-daemon/src/worker/turn_stream_tests.rs index eb9d6fdf1..31d247ba8 100644 --- a/crates/pa-daemon/src/worker/turn_stream_tests.rs +++ b/crates/pa-daemon/src/worker/turn_stream_tests.rs @@ -239,6 +239,7 @@ async fn gate_sighting_events( /// A sighting on the trailing `Done` of a self-completed run must not arm the /// fallback's silence — the closer still pairs the run's `agent_start`. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_late_abort_sighting_on_a_completed_runs_done_keeps_the_fallback_closer() { let events = gate_sighting_events(vec![EngineEvent::Done(Ok(()))], true, false).await; let starts = positions_of(&events, "agent_start"); @@ -258,6 +259,7 @@ async fn a_late_abort_sighting_on_a_completed_runs_done_keeps_the_fallback_close /// `DoneAborted` with no engine `agent_end`: the aborted-outcome carrier arms the /// silence. #[tokio::test] +#[pa_test_scratch::pa_test] async fn done_aborted_arms_the_fallback_silence() { let events = gate_sighting_events(vec![EngineEvent::DoneAborted], true, false).await; assert!( @@ -269,6 +271,7 @@ async fn done_aborted_arms_the_fallback_silence() { /// A settle frame that would forward on a plain flag sighting drops when /// `suppress_aborted_row` is set. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_suppressed_row_sighting_drops_and_arms_the_silence() { let events = gate_sighting_events( vec![ @@ -296,6 +299,7 @@ async fn the_suppressed_row_sighting_drops_and_arms_the_silence() { /// Engine-only stores cannot persist these transitions: the worker must /// commit both rows in the same stream order as the assistant/tool rows. #[tokio::test] +#[pa_test_scratch::pa_test] async fn model_transitions_reach_the_worker_owned_session_file() { for abort_suppressed in [None, Some(false), Some(true)] { let dir = tempfile::tempdir().unwrap(); @@ -397,6 +401,7 @@ async fn model_transitions_reach_the_worker_owned_session_file() { /// cannot fence the engine's durable restore. File-backed prompts capture the /// leaf after next-turn prefix rows have persisted. #[tokio::test] +#[pa_test_scratch::pa_test] async fn prompt_restore_boundary_is_supplied_only_for_file_backed_stores() { let dir = tempfile::tempdir().unwrap(); for file_backed in [false, true] { diff --git a/crates/pa-daemon/src/worker/turn_stream_tests/abort_idle_race.rs b/crates/pa-daemon/src/worker/turn_stream_tests/abort_idle_race.rs index 50a64cde7..1b259590b 100644 --- a/crates/pa-daemon/src/worker/turn_stream_tests/abort_idle_race.rs +++ b/crates/pa-daemon/src/worker/turn_stream_tests/abort_idle_race.rs @@ -81,6 +81,7 @@ fn dump_hang_state(worker: &Worker) -> String { // whole async flow (every rep registers into the same registry). #[allow(clippy::await_holding_lock)] #[tokio::test] +#[pa_test_scratch::pa_test] #[ignore = "the rate harness: run with PA_RACE_* knobs (see the module docs)"] async fn abort_and_send_idle_race_rate_harness() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK diff --git a/crates/pa-daemon/src/worker/turn_stream_tests/broadcast.rs b/crates/pa-daemon/src/worker/turn_stream_tests/broadcast.rs index 89a227fd2..e4755dd3b 100644 --- a/crates/pa-daemon/src/worker/turn_stream_tests/broadcast.rs +++ b/crates/pa-daemon/src/worker/turn_stream_tests/broadcast.rs @@ -98,6 +98,7 @@ async fn turn_session_events_with_custom_message( } #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_injected_custom_turn_replaces_the_user_row() { let engine = Arc::new( ScriptedEngine::from_value(&json!({ @@ -147,6 +148,7 @@ async fn an_injected_custom_turn_replaces_the_user_row() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_delivered_agent_message_turn_emits_the_custom_row() { let dir = std::env::temp_dir().join(format!("pa-worker-amw-{}", uuid::Uuid::new_v4())); std::fs::create_dir_all(&dir).unwrap(); @@ -233,6 +235,7 @@ async fn a_delivered_agent_message_turn_emits_the_custom_row() { /// TS emits one `agent_end` per agent run; the worker's trailing fallback stays silent. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_settled_turn_broadcasts_the_engine_agent_end_with_its_messages() { let engine = Arc::new( ScriptedEngine::from_value(&json!({ "responses": ["settled reply"] })).unwrap_or_default(), @@ -278,6 +281,7 @@ async fn a_settled_turn_broadcasts_the_engine_agent_end_with_its_messages() { /// The bare `agent_end` fallback (a Rust-only shape kept for the TUI's silent-failure backstop). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_turn_without_a_model_turn_keeps_the_bare_fallback_frames() { let events = turn_session_events(Arc::new(DoneOnlyEngine)).await; let turn_ends = positions_of(&events, "turn_end"); @@ -307,6 +311,7 @@ async fn a_turn_without_a_model_turn_keeps_the_bare_fallback_frames() { /// carries only the retry's messages; no bare synthesized frame trails. #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_retried_turn_broadcasts_one_agent_end_per_run() { fn roles_of(frame: &Value) -> Vec { frame["messages"] diff --git a/crates/pa-daemon/src/worker/turn_stream_tests/burst.rs b/crates/pa-daemon/src/worker/turn_stream_tests/burst.rs index d587f30ba..61666c434 100644 --- a/crates/pa-daemon/src/worker/turn_stream_tests/burst.rs +++ b/crates/pa-daemon/src/worker/turn_stream_tests/burst.rs @@ -121,6 +121,7 @@ fn texts_at(events: &[Value], positions: &[usize]) -> Vec { /// A provider that outruns the flush tick still broadcasts at most one /// parked update per tick — never one wire frame per delta. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_provider_burst_broadcasts_one_coalesced_update_per_tick_not_per_delta() { const DELTAS: usize = 120; // 1ms spacing: the burst spans ~120ms, so the 50ms flusher tick @@ -167,6 +168,7 @@ async fn a_provider_burst_broadcasts_one_coalesced_update_per_tick_not_per_delta /// medians, not single runs. #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] #[ignore = "run with cargo test -p pa-daemon --release streamed_turn_pipeline_benchmark -- --ignored --nocapture"] async fn streamed_turn_pipeline_benchmark() { for text_kb in [64usize, 256, 512] { @@ -217,6 +219,7 @@ async fn streamed_turn_pipeline_benchmark() { /// `text_delta` update before `message_end` carries the final content. #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_last_parked_update_carries_the_final_content() { let _faux = crate::agent_engine::FAUX_TEST_LOCK .lock() @@ -258,6 +261,7 @@ async fn the_last_parked_update_carries_the_final_content() { /// The client sees the full message without a tick wait and nothing lands out of order. #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_instant_burst_flushes_the_final_snapshot_with_its_settle_frame() { const DELTAS: usize = 200; let engine = Arc::new(BurstStreamEngine { diff --git a/crates/pa-daemon/src/worker/turn_stream_tests/early_abort.rs b/crates/pa-daemon/src/worker/turn_stream_tests/early_abort.rs index 850369413..52beff0f0 100644 --- a/crates/pa-daemon/src/worker/turn_stream_tests/early_abort.rs +++ b/crates/pa-daemon/src/worker/turn_stream_tests/early_abort.rs @@ -131,6 +131,7 @@ async fn exact_bound_history( } #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::await_holding_lock)] // Faux's process-global registry owns the whole flow. async fn abort_before_first_engine_event_keeps_the_accepted_turn_and_settles_idle() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK @@ -337,6 +338,7 @@ async fn abort_before_first_engine_event_keeps_the_accepted_turn_and_settles_idl } #[tokio::test] +#[pa_test_scratch::pa_test] async fn plain_abort_keeps_only_the_initial_delivery_not_a_queued_continuation() { let user = json!({ "role": "user", "content": [{ "type": "text", "text": "accepted" }] }); let queued = json!({ "role": "user", "content": [{ "type": "text", "text": "not accepted" }] }); @@ -358,6 +360,7 @@ async fn plain_abort_keeps_only_the_initial_delivery_not_a_queued_continuation() } #[tokio::test] +#[pa_test_scratch::pa_test] async fn compact_suppression_still_drops_the_initial_delivery() { let events = gate_sighting_events( vec![EngineEvent::UserMessage(json!({ diff --git a/crates/pa-daemon/src/worker/turn_stream_tests/feed.rs b/crates/pa-daemon/src/worker/turn_stream_tests/feed.rs index 84842838c..b6a0cc83b 100644 --- a/crates/pa-daemon/src/worker/turn_stream_tests/feed.rs +++ b/crates/pa-daemon/src/worker/turn_stream_tests/feed.rs @@ -4,6 +4,7 @@ use super::*; /// The `done` waiter fires after the idle flip and queue projection, never pre-idle. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_waiting_prompt_resolves_only_after_the_turn_settles() { let engine: Arc = Arc::new( ScriptedEngine::from_value(&json!({ "responses": ["settled reply"] })).unwrap_or_default(), @@ -96,6 +97,7 @@ fn live_feed_runner(engine: Arc, socket: std::path::PathBuf) /// tool executes and end idle once the turn settles. #[cfg(unix)] #[tokio::test] +#[pa_test_scratch::pa_test] async fn roster_feed_publishes_live_tool_activity() { let dir = tempfile::TempDir::new().unwrap(); let socket = dir.path().join("sup.sock"); diff --git a/crates/pa-daemon/src/worker/turn_stream_tests/interleave.rs b/crates/pa-daemon/src/worker/turn_stream_tests/interleave.rs index 935d4a9df..74b2220f4 100644 --- a/crates/pa-daemon/src/worker/turn_stream_tests/interleave.rs +++ b/crates/pa-daemon/src/worker/turn_stream_tests/interleave.rs @@ -378,6 +378,7 @@ async fn release_the_gate_and_settle(gate: &GateHoldEngine, fired: tokio::task:: /// below shares this fixture; without this proof a missing ask would be /// vacuous. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_unraced_fire_passes_the_gate_and_asks_the_supervisor_to_stop() { let probe = StopAskProbe::spawn(); let gate = Arc::new(GateHoldEngine::new()); @@ -405,6 +406,7 @@ async fn the_unraced_fire_passes_the_gate_and_asks_the_supervisor_to_stop() { /// window): the post-await revalidation cancels the stop, and the racing /// client's hold survives intact (the stop would have disconnected it). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_client_attaching_at_the_gate_cancels_the_stop() { let probe = StopAskProbe::spawn(); let gate = Arc::new(GateHoldEngine::new()); @@ -437,6 +439,7 @@ async fn a_client_attaching_at_the_gate_cancels_the_stop() { /// the stop cancels — the queued work lives only on the resident worker, /// so the graceful stop would have discarded it — and both rows survive. #[tokio::test] +#[pa_test_scratch::pa_test] async fn lane_work_parking_at_the_gate_cancels_the_stop() { let probe = StopAskProbe::spawn(); let gate = Arc::new(GateHoldEngine::new()); @@ -485,6 +488,7 @@ async fn lane_work_parking_at_the_gate_cancels_the_stop() { /// (the round-7 window): the stop cancels — the shutdown would have /// cancelled the compaction mid-run. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_manual_compaction_starting_at_the_gate_cancels_the_stop() { let probe = StopAskProbe::spawn(); let gate = Arc::new(GateHoldEngine::new()); @@ -505,6 +509,7 @@ async fn a_manual_compaction_starting_at_the_gate_cancels_the_stop() { /// lost. The `queued_input_suspended` arm stands for the suspension /// predicate set (the input-pause lease arm shares the same `||` term). #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_input_suspension_engaging_at_the_gate_cancels_the_stop() { let probe = StopAskProbe::spawn(); let gate = Arc::new(GateHoldEngine::new()); @@ -524,6 +529,7 @@ async fn an_input_suspension_engaging_at_the_gate_cancels_the_stop() { /// left the user's process running (the awaited-run bracket holds the same /// `isBashRunning` contribution the exclusive slot does). #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_user_bash_admitted_at_the_gate_cancels_the_stop() { let probe = StopAskProbe::spawn(); let gate = Arc::new(GateHoldEngine::new()); @@ -552,6 +558,7 @@ async fn a_user_bash_admitted_at_the_gate_cancels_the_stop() { /// `passivateSession` checks `shuttingDown` only before its fresh-snapshot /// await. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_shutdown_starting_at_the_gate_cancels_the_stop() { let probe = StopAskProbe::spawn(); let gate = Arc::new(GateHoldEngine::new()); @@ -639,6 +646,7 @@ async fn wait_for_event( /// This pins the gate, not its order against the bash abort (see the /// module docs). #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_shutdown_gate_refuses_a_bash_admitted_inside_the_stop() { let (worker, _dir) = interleave_worker().await; // The settle seam: a compaction in flight parks the graceful stop at @@ -688,6 +696,7 @@ async fn the_shutdown_gate_refuses_a_bash_admitted_inside_the_stop() { /// pre-window interleave) is aborted by the stop — the settled run reports /// cancelled, so the worker's exit never leaves the user's process running. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_bash_admitted_before_the_gate_is_aborted_by_the_stop() { let (worker, _dir) = interleave_worker().await; let mut events = worker.events.subscribe(); @@ -730,6 +739,7 @@ async fn a_bash_admitted_before_the_gate_is_aborted_by_the_stop() { /// gate disabled forever. The retain now rides the registration's /// verdict). #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_close_beats_the_late_attach_registration() { let (worker, _dir) = interleave_worker().await; // THE CLOSE: the attach guard's Drop ran first (the connection's EOF @@ -780,6 +790,7 @@ async fn the_close_beats_the_late_attach_registration() { /// its core retain stands — its release rides the routed detach, so the /// token-gated verdict must not hold it. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_routed_attach_without_a_token_keeps_the_core_retain() { let (worker, _dir) = interleave_worker().await; let response = worker @@ -802,6 +813,7 @@ async fn a_routed_attach_without_a_token_keeps_the_core_retain() { /// close — the live connection's attach registers, and the close releases /// both the registry entry and the core hold. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_registration_beats_the_close_and_the_release_frees_the_hold() { let (worker, _dir) = interleave_worker().await; let response = worker @@ -850,6 +862,7 @@ async fn the_registration_beats_the_close_and_the_release_frees_the_hold() { /// same connection re-registers, and the eventual close releases it (no /// leak either way). #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_detach_is_not_final_the_reattach_registers_and_the_close_releases() { let (worker, _dir) = interleave_worker().await; let attach = worker @@ -897,6 +910,7 @@ async fn the_detach_is_not_final_the_reattach_registers_and_the_close_releases() /// The shared-client-id reconnect shape (the round-6/9 sibling holds): the /// id leaves the core only when the LAST live connection holding it goes. #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_shared_client_id_survives_one_connection_close_while_the_other_holds() { let (worker, _dir) = interleave_worker().await; let first = worker @@ -935,6 +949,7 @@ async fn a_shared_client_id_survives_one_connection_close_while_the_other_holds( /// and the clear runs BEFORE the insert, so the overflowing release still /// rejects its own late registration. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_released_token_set_caps_at_8192() { let (worker, _dir) = interleave_worker().await; for index in 0..8193 { diff --git a/crates/pa-daemon/src/worker/turn_stream_tests/park.rs b/crates/pa-daemon/src/worker/turn_stream_tests/park.rs index 1e9d0b0ec..397fff48b 100644 --- a/crates/pa-daemon/src/worker/turn_stream_tests/park.rs +++ b/crates/pa-daemon/src/worker/turn_stream_tests/park.rs @@ -72,6 +72,7 @@ impl SessionEngine for ReleaseCountingEngine { /// The bounded timeout is the failure bound (positive arm) and the absence bound (gated arms). #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_idle_park_releases_a_parent_owned_childs_kernel_only() { struct ParkedProbe { releases: std::sync::Arc, @@ -195,6 +196,7 @@ impl SessionEngine for AdmitProbeEngine { /// A resume site that clears the suspension MID-WINDOW must not admit a racing turn. #[tokio::test] +#[pa_test_scratch::pa_test] async fn compacting_window_parks_a_cleared_suspension_until_it_ends() { let engine = Arc::new(AdmitProbeEngine::default()); let runner = burst_runner(Arc::clone(&engine) as Arc); @@ -278,6 +280,7 @@ pub(super) fn passivation_settings(dir: &std::path::Path, value: &serde_json::Va } #[tokio::test] +#[pa_test_scratch::pa_test] async fn idle_passivation_window_arms_only_for_idle_unattached_sessions() { let dir = tempfile::TempDir::new().unwrap(); let agent_dir = dir.path().join("agent"); @@ -325,6 +328,7 @@ async fn idle_passivation_window_arms_only_for_idle_unattached_sessions() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn idle_passivation_refuses_while_the_lanes_hold_undelivered_input() { // A parked steer or follow-up lives only on the resident worker, so neither // the window nor the fire's fence may pass while the lanes hold it. @@ -395,6 +399,7 @@ async fn idle_passivation_refuses_while_the_lanes_hold_undelivered_input() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn idle_passivation_fire_rechecks_the_fresh_state_and_reports_the_threshold() { // The fire's fresh-snapshot fence: an attached client (or an armed scheduled // job via the engine gate) cancels the stop even when the window armed before diff --git a/crates/pa-daemon/src/worker/turn_stream_tests/queue.rs b/crates/pa-daemon/src/worker/turn_stream_tests/queue.rs index ed939e85a..17659ed5f 100644 --- a/crates/pa-daemon/src/worker/turn_stream_tests/queue.rs +++ b/crates/pa-daemon/src/worker/turn_stream_tests/queue.rs @@ -4,6 +4,7 @@ use super::*; #[tokio::test] +#[pa_test_scratch::pa_test] async fn suspended_runner_parks_a_queued_item_until_resumed() { let engine = ScriptedEngine::default(); let runner = burst_runner(Arc::new(engine)); @@ -144,6 +145,7 @@ fn delivered_rows(events: &[Value]) -> Vec<(String, String)> { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn steering_mode_all_batches_the_queued_prefix_into_one_turn() { let engine: Arc = Arc::new( ScriptedEngine::from_value(&json!({ "responses": ["batched reply"] })).unwrap_or_default(), @@ -191,6 +193,7 @@ async fn steering_mode_all_batches_the_queued_prefix_into_one_turn() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_default_mode_co_delivers_the_queued_steering_prefix() { let engine: Arc = Arc::new( ScriptedEngine::from_value(&json!({ "responses": ["batched reply"] })).unwrap_or_default(), @@ -236,6 +239,7 @@ async fn the_default_mode_co_delivers_the_queued_steering_prefix() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn one_at_a_time_delivers_each_queued_steer_as_its_own_turn() { // The burst harness has no session store, so the scripted engine serves // its first response for EVERY turn (prompt_index stays 0): the turns @@ -280,6 +284,7 @@ async fn one_at_a_time_delivers_each_queued_steer_as_its_own_turn() { /// An item queued after the arm stays out of the batch. #[tokio::test] +#[pa_test_scratch::pa_test] async fn forced_batch_delivers_the_armed_prefix_as_one_turn() { let engine: Arc = Arc::new( ScriptedEngine::from_value(&json!({ "responses": ["batch reply"] })).unwrap_or_default(), @@ -330,6 +335,7 @@ async fn forced_batch_delivers_the_armed_prefix_as_one_turn() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn mode_all_never_batches_across_policy_classes() { let engine: Arc = Arc::new( ScriptedEngine::from_value(&json!({ "responses": ["lane reply"] })).unwrap_or_default(), @@ -370,6 +376,7 @@ async fn mode_all_never_batches_across_policy_classes() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn follow_up_mode_all_batches_the_follow_up_lane() { let engine: Arc = Arc::new( ScriptedEngine::from_value(&json!({ "responses": ["follow-up batch reply"] })) @@ -411,6 +418,7 @@ async fn follow_up_mode_all_batches_the_follow_up_lane() { /// Kevin's acceptance case: ALL visible steers send together; the follow-up runs once idle. #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow async fn abort_and_send_queued_delivers_the_steering_batch_then_the_follow_ups() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK @@ -602,6 +610,7 @@ async fn abort_and_send_queued_delivers_the_steering_batch_then_the_follow_ups() /// Answers immediately while both the aborted turn and the follow-up's reply are held. #[tokio::test] +#[pa_test_scratch::pa_test] #[allow(clippy::await_holding_lock)] // the faux registry is process-global: the guard must span the async flow async fn abort_and_send_queued_acks_before_the_follow_up_delivery() { let _faux = crate::agent_engine::tests::FAUX_TEST_LOCK @@ -847,6 +856,7 @@ impl SessionEngine for NoteWitnessEngine { /// The queued async bash completion's delivery keeps the note its cut run /// accepted mid-flight; the note clears only at the run's true end. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_async_completion_notice_delivery_keeps_the_live_note() { let engine = Arc::new(NoteWitnessEngine::default()); let runner = burst_runner(engine.clone()); @@ -890,6 +900,7 @@ async fn the_async_completion_notice_delivery_keeps_the_live_note() { /// An ordinary queued follow-up retains the note until its own final end, like steering. #[tokio::test] +#[pa_test_scratch::pa_test] async fn queued_follow_up_keeps_the_note_until_its_final_end() { let engine = Arc::new(NoteWitnessEngine::default()); let runner = burst_runner(engine.clone()); @@ -924,6 +935,7 @@ async fn queued_follow_up_keeps_the_note_until_its_final_end() { /// `AgentEnd`'s queued-work decision must be reconsidered if the queue is withdrawn /// before the final idle snapshot. #[tokio::test] +#[pa_test_scratch::pa_test] async fn withdrawing_follow_up_after_agent_end_clears_the_note_at_settle() { let engine = Arc::new(NoteWitnessEngine::default()); let runner = burst_runner(engine.clone()); @@ -951,6 +963,7 @@ async fn withdrawing_follow_up_after_agent_end_clears_the_note_at_settle() { /// Clearing queued work while a run is active preserves its note, but clearing the /// last queued work after the run settled ends the retained note's lifetime. #[tokio::test] +#[pa_test_scratch::pa_test] async fn clearing_an_idle_queue_drops_the_retained_note() { let dir = tempfile::tempdir().unwrap(); let engine = Arc::new(NoteWitnessEngine::default()); @@ -1096,6 +1109,7 @@ impl SessionEngine for AbortSwallowedEngine { /// still settles idle at the same settle: the note — the roster /// summary's `progressNote` source — must not survive that idle settle. #[tokio::test] +#[pa_test_scratch::pa_test] async fn an_aborted_run_clears_the_note_at_its_idle_settle() { let engine = Arc::new(AbortSwallowedEngine::default()); let runner = burst_runner(engine.clone()); @@ -1130,6 +1144,7 @@ async fn an_aborted_run_clears_the_note_at_its_idle_settle() { /// core-then-note snapshot as `SummaryInputs`. Idle must never become /// observable with the stopped run's note still present. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] +#[pa_test_scratch::pa_test] async fn an_aborted_run_never_exposes_an_idle_summary_with_its_old_note() { let (release, receiver) = std::sync::mpsc::channel(); let gate = Arc::new(NoteClearGate { diff --git a/crates/pa-daemon/src/worker/turn_stream_tests/queue/withdrawal.rs b/crates/pa-daemon/src/worker/turn_stream_tests/queue/withdrawal.rs index 91f6da686..e2cb33cac 100644 --- a/crates/pa-daemon/src/worker/turn_stream_tests/queue/withdrawal.rs +++ b/crates/pa-daemon/src/worker/turn_stream_tests/queue/withdrawal.rs @@ -2,6 +2,7 @@ use super::*; #[tokio::test] +#[pa_test_scratch::pa_test] async fn queue_withdrawals_clear_only_the_last_idle_notes() { for command in [ "mutate_queued_message", diff --git a/crates/pa-daemon/src/worker/update_snapshot_tests.rs b/crates/pa-daemon/src/worker/update_snapshot_tests.rs index e84d1ce24..d217c24eb 100644 --- a/crates/pa-daemon/src/worker/update_snapshot_tests.rs +++ b/crates/pa-daemon/src/worker/update_snapshot_tests.rs @@ -31,6 +31,7 @@ async fn snapshot_after_create() -> (Arc, DaemonResponse) { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn queue_action_rows_serve_the_labeled_preview() { let (worker, _) = snapshot_after_create().await; { @@ -89,6 +90,7 @@ async fn queue_action_rows_serve_the_labeled_preview() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn update_snapshot_reports_the_session_and_flushes_the_journal() { let (worker, response) = snapshot_after_create().await; assert!(response.success, "snapshot must succeed: {response:?}"); @@ -112,6 +114,7 @@ async fn update_snapshot_reports_the_session_and_flushes_the_journal() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn update_snapshot_failure_preserves_live_and_recovery_state() { let (worker, _) = snapshot_after_create().await; { @@ -183,6 +186,7 @@ async fn update_snapshot_failure_preserves_live_and_recovery_state() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn update_snapshot_requires_a_recovery_journal() { let (worker, _) = snapshot_after_create().await; worker.recovery.lock().unwrap().take(); @@ -195,6 +199,7 @@ async fn update_snapshot_requires_a_recovery_journal() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn update_snapshot_reflects_queued_work() { let (worker, _) = snapshot_after_create().await; worker @@ -247,6 +252,7 @@ fn queued_user_item(message: &str) -> QueuedItem { /// The rider flags exactly the injected rows (operator 2026-09-25), never a same-text user row. #[tokio::test] +#[pa_test_scratch::pa_test] async fn the_action_snapshot_flags_parked_child_status_notices() { let (worker, _) = snapshot_after_create().await; let notice_text = @@ -298,6 +304,7 @@ async fn the_action_snapshot_flags_parked_child_status_notices() { } #[tokio::test] +#[pa_test_scratch::pa_test] async fn a_follow_up_notice_parks_with_typed_provenance() { let (worker, _) = snapshot_after_create().await; let content = "[child-exited: no-reply child:lane]\n\nLast assistant text: done".to_string(); @@ -362,6 +369,7 @@ async fn a_follow_up_notice_parks_with_typed_provenance() { /// The spoof matrix (the operator's anti-spoof mandate). #[tokio::test] +#[pa_test_scratch::pa_test] async fn reserved_kind_spoofs_reject_and_lookalikes_park_unflagged() { let (worker, _) = snapshot_after_create().await; let content = "[child-exited: no-reply child:lane]".to_string(); @@ -452,6 +460,7 @@ async fn reserved_kind_spoofs_reject_and_lookalikes_park_unflagged() { } /// A notice-free projection keeps the TS wire shape (the field is skipped). +#[pa_test_scratch::pa_test] #[test] fn the_rider_serializes_only_when_a_notice_is_parked() { let empty = SessionActionSnapshot::default(); @@ -503,6 +512,7 @@ fn the_rider_serializes_only_when_a_notice_is_parked() { /// Operator directive 2026-09-28: internal prompts never render as individual queue rows. #[tokio::test] +#[pa_test_scratch::pa_test] async fn injected_continuations_mark_their_own_rider_only() { let (worker, _) = snapshot_after_create().await; let continuation = "[goal: continuation]\n\nKeep driving the goal.".to_string(); @@ -606,6 +616,7 @@ async fn injected_continuations_mark_their_own_rider_only() { /// The rider folds the row, never an omission: the browse affordance keeps the queue inspectable. #[tokio::test] +#[pa_test_scratch::pa_test] async fn injected_continuations_still_project_their_lane_text() { let (worker, _) = snapshot_after_create().await; { @@ -639,6 +650,7 @@ async fn injected_continuations_still_project_their_lane_text() { /// Operator safeguard: journal restore must preserve the typed provenance. #[tokio::test] +#[pa_test_scratch::pa_test] async fn restored_lane_rows_keep_the_child_status_provenance() { let (worker, _) = snapshot_after_create().await; let content = "[child-exited: no-reply child:lane]\n\nLast assistant text: done".to_string(); diff --git a/crates/pa-daemon/src/worker_resume_settings_tests.rs b/crates/pa-daemon/src/worker_resume_settings_tests.rs index c41f11e75..227634bfe 100644 --- a/crates/pa-daemon/src/worker_resume_settings_tests.rs +++ b/crates/pa-daemon/src/worker_resume_settings_tests.rs @@ -70,6 +70,7 @@ mod resume_settings_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn compacted_create_restores_settings_and_honors_explicit_overrides() { let dir = tempfile::tempdir().unwrap(); for mode in [0, 1, 2, 3, 4] { @@ -179,6 +180,7 @@ mod resume_settings_tests { } #[tokio::test] + #[pa_test_scratch::pa_test] async fn create_backfills_the_default_tier_when_the_resumed_file_has_none() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("no-tier.jsonl"); diff --git a/crates/pa-daemon/src/worker_stderr.rs b/crates/pa-daemon/src/worker_stderr.rs index 4c8ad7fab..2390c868a 100644 --- a/crates/pa-daemon/src/worker_stderr.rs +++ b/crates/pa-daemon/src/worker_stderr.rs @@ -193,6 +193,7 @@ mod tests { filetime::set_file_mtime(path, mtime).expect("set mtime"); } + #[pa_test_scratch::pa_test] #[test] fn tail_reads_the_last_4k_from_a_line_boundary() { use std::fmt::Write as _; @@ -222,6 +223,7 @@ mod tests { assert!(tail.starts_with("panic trace line")); } + #[pa_test_scratch::pa_test] #[test] fn tail_is_none_for_missing_and_empty_logs() { let dir = tempfile::tempdir().expect("temp dir"); @@ -233,6 +235,7 @@ mod tests { assert!(matches!(read_tail(&path), Ok(None))); } + #[pa_test_scratch::pa_test] #[test] fn spawn_open_truncates_a_leftover_log() { let dir = tempfile::tempdir().expect("temp dir"); @@ -252,6 +255,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn not_ready_error_carries_the_tail() { let dir = tempfile::tempdir().expect("temp dir"); @@ -277,6 +281,7 @@ mod tests { assert!(message.contains(" thread 'main' panicked")); } + #[pa_test_scratch::pa_test] #[test] fn not_ready_error_keeps_the_bare_headline_for_a_silent_worker() { let dir = tempfile::tempdir().expect("temp dir"); @@ -288,6 +293,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn prune_keeps_the_newest_retained_logs() { let dir = tempfile::tempdir().expect("temp dir"); @@ -346,6 +352,7 @@ mod tests { ); } + #[pa_test_scratch::pa_test] #[test] fn socket_log_retention_keeps_the_newest_and_spares_foreign_logs() { let dir = tempfile::tempdir().expect("temp dir"); @@ -386,6 +393,7 @@ mod tests { assert!(jsonl.exists()); } + #[pa_test_scratch::pa_test] #[test] fn prune_spares_a_fresh_burst_of_launches() { let dir = tempfile::tempdir().expect("temp dir"); -- knotmirror 0.0.1 From 1aeb5436154f8aa0be1ec48b83100e0f6910de23 Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Sat, 21 Nov 2026 12:09:37 +0000 Subject: [PATCH 6/9] docs(timing): describe local timing and coverage workflow --- crates/pa-test-scratch/README.md | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/crates/pa-test-scratch/README.md b/crates/pa-test-scratch/README.md index 85812696c..acec5e3e9 100644 --- a/crates/pa-test-scratch/README.md +++ b/crates/pa-test-scratch/README.md @@ -43,3 +43,55 @@ flag is unwind state, not the harness outcome (`should_panic` can pass). Write failures panic during normal completion. During unwinding they are reported to stderr without a second panic; the runner must reject the missing record. + +## Developer runner + +From the workspace root, use a credential-free Cargo cache already populated for +`--locked --offline`, and a kernel venv synced and readiness-qualified from this +checkout. Export `CARGO_HOME` and `CARGO_TARGET_DIR` as absolute paths. Set +`PRIME_AGENT_KERNEL_PYTHON`, `PA_CORE_KERNEL_PYTHON`, and `PA_E2E_KERNEL_PYTHON` +to that same venv interpreter. No live credentials are inherited by test targets. + +```console +uv run scripts/test_timings.py run --slots 8 --audit --output /tmp/weave-timing-run +uv run scripts/test_timings.py run --slots 8 --package pa-core --audit +uv run scripts/test_timings.py run --slots 1 --package pa-daemon --target context_latency_e2e +uv run scripts/test_timings.py table /tmp/weave-timing-run +``` + +The runner builds the selected default test artifacts once and executes whole +binaries with their crate working directories and native libtest concurrency. +It never filters individual tests or retries failures. Each binary gets private +home, agent, socket, and temporary paths. `kernel_dispose_e2e` and +`replacement_kernel_e2e` run exclusively after all other binaries because their +fixtures inspect the machine-wide kernel process census. Workspace/crate runs +finish with native Cargo doctests; `--target` selects integration binaries only. + +Slots `1`, `8`, and `16` are measurement options, not an assertion that more slots +are faster. The summary lists every target's wall, user CPU, and system CPU time. +It separately reports execution wall time and total wall time including the warm +build and inventory preparation. This Unix runner requires `wait4` for per-child +CPU accounting. Retained manifests contain commands, isolated environments, +load snapshots, harness logs, and the original sidecars. + +Coverage compares the default harness's listed nonignored tests and completed +test statuses with the launched process's records. Missing or duplicate records +fail integration and `pa-core`/`pa-daemon` unit runs, including failed and +expected-panic tests. Captured test stdout is not used. `--audit` checks every +integration source test attribute and the two selected crates' unit source. +Other crates' unit tests without attributes and doctests are reported as +uncovered, with crate and unit names retained in the manifest; +`--require-all-timing` additionally makes missing unit timing fail. Ignored tests +keep the native default and are not executed. + +The sorted per-test table includes named span totals and unattributed duration. +Overlapping spans are unioned when computing coverage, so nested spans do not +make unattributed time negative. Unattributed time is not classified as computation. +A directory of raw JSONL sidecars also works with `table`, but harness outcomes +and inventory coverage are unknown without a runner manifest. Target wall and +CPU time are not invented from test timestamps. CPU accounting uses `wait4` and +includes reaped child work; still-running detached descendants are not included. + +Use `--disable-timing` on the same built target for the collector overhead control; +this retains the macro's disabled guard branch, so compare with a native baseline +as well when reporting total instrumentation overhead. -- knotmirror 0.0.1 From 478b2fe51527ab692fc68b27e4f1e82a0ea83597 Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Sat, 21 Nov 2026 12:38:40 +0000 Subject: [PATCH 7/9] fix(timing): preserve test session setup in the local runner Launch each test under a supervisor so its own setsid call remains valid. Read sidecars using the actual test PID and forward cancellation to that process. --- scripts/test_test_timings.py | 51 +++++++++++++++++++++++++++++++++ scripts/test_timing_launcher.py | 50 ++++++++++++++++++++++++++++++++ scripts/test_timings.py | 11 +++++-- 3 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 scripts/test_timing_launcher.py diff --git a/scripts/test_test_timings.py b/scripts/test_test_timings.py index fa7453517..366c192ee 100644 --- a/scripts/test_test_timings.py +++ b/scripts/test_test_timings.py @@ -53,6 +53,57 @@ class ChildOwnership(unittest.TestCase): self.assertFalse({signal.SIGINT, signal.SIGTERM} & set(json.loads(stdout))) self.assertFalse(children.active) + def test_launcher_child_can_create_its_own_session(self): + children = Children() + pid_file = self.cwd / "binary.pid" + launcher = Path(__file__).with_name("test_timing_launcher.py") + code = "import json, os; os.setsid(); print(json.dumps({'pid': os.getpid(), 'sid': os.getsid(0)}))" + child = children.spawn( + [sys.executable, "-I", str(launcher), "--pid-file", str(pid_file), "--", + sys.executable, "-I", "-c", code], cwd=self.cwd, env=self.env, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + try: + children.resume_signals() + stdout, stderr = child.communicate() + finally: + child.wait() + children.complete(child) + self.assertEqual((child.returncode, stderr), (0, "")) + actual_pid = int(pid_file.read_text()) + self.assertNotEqual(actual_pid, child.pid) + self.assertEqual(json.loads(stdout), {"pid": actual_pid, "sid": actual_pid}) + + def test_launcher_forwards_term_to_child_in_separate_session(self): + children = Children() + pid_file = self.cwd / "binary.pid" + launcher = Path(__file__).with_name("test_timing_launcher.py") + child = children.spawn( + [sys.executable, "-I", str(launcher), "--pid-file", str(pid_file), "--", + sys.executable, "-I", "-c", "import os, signal; os.setsid(); print('ready', flush=True); signal.pause()"], + cwd=self.cwd, env=self.env, stdout=subprocess.PIPE, text=True) + + def reap(): + try: + return child.wait() + finally: + children.complete(child) + + try: + with ThreadPoolExecutor(max_workers=1) as workers: + future = workers.submit(reap) + try: + children.resume_signals() + self.assertEqual(child.stdout.readline(), "ready\n") + actual_pid = int(pid_file.read_text()) + self.assertEqual(os.getsid(actual_pid), actual_pid) + self.assertNotEqual(actual_pid, child.pid) + finally: + children.cancel() + self.assertEqual(future.result(), -signal.SIGTERM) + self.assertFalse(children.active) + finally: + child.stdout.close() + def test_cancel_signals_only_tracked_group_and_owner_reaps(self): children = Children() child = children.spawn( diff --git a/scripts/test_timing_launcher.py b/scripts/test_timing_launcher.py new file mode 100644 index 000000000..f8f21ef33 --- /dev/null +++ b/scripts/test_timing_launcher.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +import argparse +import os +from pathlib import Path +import signal +import subprocess + + +def main(): + parser = argparse.ArgumentParser(description="Launch a test as a non-session-leader child.") + parser.add_argument("--pid-file", type=Path, required=True) + parser.add_argument("command", nargs=argparse.REMAINDER) + args = parser.parse_args() + command = args.command[1:] if args.command[:1] == ["--"] else args.command + if not command: + parser.error("a test binary is required") + child = None + pending = [] + + def forward(signum, frame): + if child is None: + pending.append(signum) + else: + try: + child.send_signal(signum) + except ProcessLookupError: + pass + + for signum in (signal.SIGINT, signal.SIGTERM): + signal.signal(signum, forward) + child = subprocess.Popen(command) + for signum in pending: + forward(signum, None) + try: + args.pid_file.write_text(f"{child.pid}\n") + code = child.wait() + except BaseException: + child.kill() + child.wait() + raise + if code < 0: + signum = -code + if signum != signal.SIGKILL: + signal.signal(signum, signal.SIG_DFL) + os.kill(os.getpid(), signum) + return code + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/test_timings.py b/scripts/test_timings.py index 4ee1b4eb0..328728f18 100644 --- a/scripts/test_timings.py +++ b/scripts/test_timings.py @@ -16,6 +16,7 @@ import re import shutil import signal import subprocess +import sys import tempfile import time from threading import Event, RLock, current_thread, main_thread @@ -267,7 +268,10 @@ def execute(target, repo, ambient, run_dir, disabled, children): target["inventory"], target["ignored"] = inventory( target["binary"], cwd, env, directory, target["commands"], children) target["expected_nonignored_count"] = len(set(target["inventory"]) - set(target["ignored"])) - command = [target["binary"]] + pid_file = private / "binary.pid" + command = [sys.executable, "-I", str(Path(__file__).with_name("test_timing_launcher.py")), + "--pid-file", str(pid_file), "--", target["binary"]] + target["pid_file"] = str(pid_file) target["commands"].append({"command": command, "cwd": str(cwd), "environment": env}) with (directory / "harness.log").open("w") as output: started = time.monotonic_ns() @@ -275,7 +279,7 @@ def execute(target, repo, ambient, run_dir, disabled, children): target["start_monotonic_ns"] = started child = children.spawn(command, cwd=cwd, env=env, stdout=output, stderr=subprocess.STDOUT) - target["pid"] = child.pid + target["launcher_pid"] = child.pid try: children.resume_signals() _, status, usage = os.wait4(child.pid, 0) @@ -293,6 +297,7 @@ def execute(target, repo, ambient, run_dir, disabled, children): target.update(exit_code=child.returncode, elapsed_ns=time.monotonic_ns() - started, end_unix_ns=time.time_ns(), cpu_user_seconds=usage.ru_utime, cpu_system_seconds=usage.ru_stime) + target["pid"] = int(pid_file.read_text().strip()) try: target["statuses"] = statuses((directory / "harness.log").read_text(), target["inventory"], target["ignored"]) @@ -300,7 +305,7 @@ def execute(target, repo, ambient, run_dir, disabled, children): except ValueError as error: target["statuses"] = [] target["errors"].append(str(error)) - target["records"] = read_records(timing_dir, target["binary"], child.pid) + target["records"] = read_records(timing_dir, target["binary"], target["pid"]) target["errors"].extend(reconcile(target, target["records"], disabled)) if child.returncode: target["errors"].append(f"binary exited {child.returncode}") -- knotmirror 0.0.1 From 33278e89459fb230463ad698eb4737e6f964dbdc Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Sat, 21 Nov 2026 14:15:26 +0000 Subject: [PATCH 8/9] fix(timing): capture process configuration before test setup Keep the timing destination and enabled state stable when fixtures replace the environment. Verify enabled and disabled recording in isolated child processes. --- crates/pa-test-scratch/README.md | 4 ++ crates/pa-test-scratch/src/lib.rs | 1 + crates/pa-test-scratch/src/timing.rs | 29 ++++++++++--- crates/pa-test-scratch/tests/timing.rs | 56 ++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 6 deletions(-) diff --git a/crates/pa-test-scratch/README.md b/crates/pa-test-scratch/README.md index acec5e3e9..bda2a9d3e 100644 --- a/crates/pa-test-scratch/README.md +++ b/crates/pa-test-scratch/README.md @@ -30,6 +30,10 @@ thread, resolved through a thread-ID registry. It does not find test context after task migration; use explicit recorders there. Finish all spawned work and drop its spans before the test returns; the test guard writes its collected spans on drop. +Timing configuration is captured once by the startup hook before test bodies run. +Platforms without that hook capture it on first use. Later environment changes +do not alter the enabled flag or destination. + Timing is enabled by default. `PA_TEST_TIMING=0` disables timing and file output for overhead comparisons. `PA_TEST_TIMING_DIR` selects the destination; otherwise it is the workspace `target/test-timings` directory. Each process appends to diff --git a/crates/pa-test-scratch/src/lib.rs b/crates/pa-test-scratch/src/lib.rs index 964f216af..935faf9e6 100644 --- a/crates/pa-test-scratch/src/lib.rs +++ b/crates/pa-test-scratch/src/lib.rs @@ -133,6 +133,7 @@ mod hook { } extern "C" fn install() { + crate::timing::capture_config(); let _ = root(); } diff --git a/crates/pa-test-scratch/src/timing.rs b/crates/pa-test-scratch/src/timing.rs index ad0dcf920..b2f990eee 100644 --- a/crates/pa-test-scratch/src/timing.rs +++ b/crates/pa-test-scratch/src/timing.rs @@ -12,6 +12,26 @@ type Spans = Mutex>; static RECORDERS: OnceLock>>> = OnceLock::new(); static OUTPUT: OnceLock, String>> = OnceLock::new(); +static CONFIG: OnceLock = OnceLock::new(); + +struct TimingConfig { + enabled: bool, + directory: PathBuf, +} + +pub(crate) fn capture_config() { + let _ = config(); +} + +fn config() -> &'static TimingConfig { + CONFIG.get_or_init(|| TimingConfig { + enabled: !std::env::var_os("PA_TEST_TIMING").is_some_and(|value| value == "0"), + directory: std::env::var_os("PA_TEST_TIMING_DIR").map_or_else( + || PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../target/test-timings"), + PathBuf::from, + ), + }) +} pub struct TestTiming { state: Option, @@ -44,7 +64,7 @@ struct SpanState { impl TestTiming { #[must_use] pub fn start(full_name: &str) -> Self { - if std::env::var_os("PA_TEST_TIMING").is_some_and(|value| value == "0") { + if !config().enabled { return Self { state: None }; } let started = Instant::now(); @@ -189,11 +209,8 @@ fn binary_name() -> String { fn write_record(record: &Value) -> Result<(), String> { let output = OUTPUT.get_or_init(|| { - let directory = std::env::var_os("PA_TEST_TIMING_DIR").map_or_else( - || PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../target/test-timings"), - PathBuf::from, - ); - std::fs::create_dir_all(&directory).map_err(|error| error.to_string())?; + let directory = &config().directory; + std::fs::create_dir_all(directory).map_err(|error| error.to_string())?; let binary = binary_name(); let pid = std::process::id(); OpenOptions::new() diff --git a/crates/pa-test-scratch/tests/timing.rs b/crates/pa-test-scratch/tests/timing.rs index cab3d6640..4ccb44019 100644 --- a/crates/pa-test-scratch/tests/timing.rs +++ b/crates/pa-test-scratch/tests/timing.rs @@ -20,3 +20,59 @@ fn timing_retains_should_panic_behavior() { let _span = timing::span("unwind"); panic!("timed test panic"); } + +#[pa_test_scratch::pa_test] +#[test] +fn timing_configuration_survives_environment_changes() { + if let Ok(mode) = std::env::var("PA_TIMING_CONFIG_CHILD") { + let keys: Vec<_> = std::env::vars_os().map(|(key, _)| key).collect(); + for key in keys { + std::env::remove_var(key); + } + std::env::set_var("PA_TEST_TIMING", if mode == "enabled" { "0" } else { "1" }); + let timing = pa_test_scratch::TestTiming::start("timing::after_environment_change"); + let _span = timing.span("after_environment_change"); + return; + } + + let executable = std::env::current_exe().expect("test executable"); + let root = std::env::temp_dir().join(format!("timing-config-{}", std::process::id())); + for mode in ["enabled", "disabled"] { + let directory = root.join(mode); + let output = directory.join("timings"); + std::fs::create_dir_all(&directory).expect("isolated child directory"); + let status = std::process::Command::new(&executable) + .args([ + "--exact", + "timing_configuration_survives_environment_changes", + "--test-threads=1", + ]) + .env_clear() + .env("PA_TIMING_CONFIG_CHILD", mode) + .env("PA_TEST_TIMING", if mode == "enabled" { "1" } else { "0" }) + .env("PA_TEST_TIMING_DIR", &output) + .env("PA_TEST_SCRATCH_ROOT", directory.join("scratch")) + .status() + .expect("run isolated timing child"); + assert!(status.success(), "{mode} timing child failed"); + if mode == "enabled" { + let files: Vec<_> = std::fs::read_dir(&output) + .expect("original timing destination") + .map(|entry| entry.expect("timing output entry").path()) + .collect(); + assert_eq!(files.len(), 1); + let contents = std::fs::read_to_string(&files[0]).expect("timing records"); + let records: Vec = contents + .lines() + .map(|line| serde_json::from_str(line).expect("timing JSON")) + .collect(); + assert_eq!(records.len(), 2); + assert!(records.iter().all(|record| { + record["test"] == "timing_configuration_survives_environment_changes" + && record["outcome"] == "returned" + })); + } else { + assert!(!output.exists(), "disabled timing created output"); + } + } +} -- knotmirror 0.0.1 From e7e5c1fe8132725ddfdbcca3d8a92a1d8e9cc8f1 Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Sat, 21 Nov 2026 15:50:59 +0000 Subject: [PATCH 9/9] fix(timing): make sidecar recording explicitly opt-in Keep ordinary test runs free of timing output unless a destination is set. Test macro guard placement and the disabled branch, and measure the actual unset-destination path in the local runner. --- crates/pa-test-macros/src/lib.rs | 93 ++++++++++++++++++++++++-- crates/pa-test-scratch/README.md | 14 ++-- crates/pa-test-scratch/src/timing.rs | 21 ++++-- crates/pa-test-scratch/tests/timing.rs | 69 ++++++++++++++++--- scripts/test_test_timings.py | 24 ++++++- scripts/test_timings.py | 17 +++-- 6 files changed, 207 insertions(+), 31 deletions(-) diff --git a/crates/pa-test-macros/src/lib.rs b/crates/pa-test-macros/src/lib.rs index 6d5ed485e..08cf434a4 100644 --- a/crates/pa-test-macros/src/lib.rs +++ b/crates/pa-test-macros/src/lib.rs @@ -12,12 +12,20 @@ pub fn pa_test(args: TokenStream, input: TokenStream) -> TokenStream { .to_compile_error() .into(); } - let mut function = parse_macro_input!(input as ItemFn); + let function = instrument(parse_macro_input!(input as ItemFn)); + quote!(#function).into() +} + +fn instrument(mut function: ItemFn) -> ItemFn { let name = &function.sig.ident; let guard = syn::parse_quote! { - let _pa_test_timing = ::pa_test_scratch::TestTiming::start( - concat!(module_path!(), "::", stringify!(#name)) - ); + let _pa_test_timing = if ::pa_test_scratch::TestTiming::is_enabled() { + ::pa_test_scratch::TestTiming::start( + concat!(module_path!(), "::", stringify!(#name)) + ) + } else { + ::pa_test_scratch::TestTiming::default() + }; }; let first_statement = function .block @@ -26,5 +34,80 @@ pub fn pa_test(args: TokenStream, input: TokenStream) -> TokenStream { .position(|statement| !matches!(statement, syn::Stmt::Item(_))) .unwrap_or(function.block.stmts.len()); function.block.stmts.insert(first_statement, guard); - quote!(#function).into() + function +} + +#[cfg(test)] +mod tests { + use super::instrument; + use syn::{Expr, Item, Pat, Stmt}; + + #[test] + fn expansion_keeps_leading_items_before_the_first_local_guard() { + let original = syn::parse_quote! { + #[test] + fn sample() { + use std::time::Instant; + struct Fixture; + let fixture = Fixture; + drop(fixture); + } + }; + let expanded = instrument(original); + assert_eq!(expanded.attrs.len(), 1); + assert!(expanded.attrs[0].path().is_ident("test")); + assert!(matches!(expanded.block.stmts[0], Stmt::Item(Item::Use(_)))); + assert!(matches!( + expanded.block.stmts[1], + Stmt::Item(Item::Struct(_)) + )); + let Stmt::Local(guard) = &expanded.block.stmts[2] else { + panic!("the first executable statement must create the guard"); + }; + let Pat::Ident(binding) = &guard.pat else { + panic!("the guard must be a named local"); + }; + assert_eq!(binding.ident, "_pa_test_timing"); + let Stmt::Local(fixture) = &expanded.block.stmts[3] else { + panic!("fixture locals must follow the guard"); + }; + let Pat::Ident(binding) = &fixture.pat else { + panic!("the original fixture binding must remain intact"); + }; + assert_eq!(binding.ident, "fixture"); + } + + #[test] + fn disabled_expansion_branch_has_no_record_start_call() { + let expanded = instrument(syn::parse_quote! { fn sample() {} }); + let Stmt::Local(guard) = &expanded.block.stmts[0] else { + panic!("the expansion must create a guard"); + }; + let Expr::If(branch) = &*guard.init.as_ref().expect("guard initializer").expr else { + panic!("recording must be conditional at runtime"); + }; + let Expr::Call(condition) = &*branch.cond else { + panic!("the condition must read the captured enabled state"); + }; + let Expr::Path(condition_path) = &*condition.func else { + panic!("the condition must call the timing API"); + }; + assert_eq!( + condition_path.path.segments.last().unwrap().ident, + "is_enabled" + ); + let Expr::Block(disabled) = &*branch.else_branch.as_ref().expect("disabled branch").1 + else { + panic!("disabled recording must have its own block"); + }; + assert_eq!(disabled.block.stmts.len(), 1); + let Stmt::Expr(Expr::Call(call), None) = &disabled.block.stmts[0] else { + panic!("the disabled branch must only construct an inert guard"); + }; + let Expr::Path(path) = &*call.func else { + panic!("the disabled branch must call Default"); + }; + assert_eq!(path.path.segments.last().unwrap().ident, "default"); + assert!(call.args.is_empty()); + } } diff --git a/crates/pa-test-scratch/README.md b/crates/pa-test-scratch/README.md index bda2a9d3e..28c2532aa 100644 --- a/crates/pa-test-scratch/README.md +++ b/crates/pa-test-scratch/README.md @@ -19,7 +19,9 @@ the wrapper's first executable statement and first local, so it drops after runtime and fixture locals. Leading item declarations stay in place; they do not execute before the guard. -- `TestTiming::start(full_name)` starts a test manually. +- `TestTiming::is_enabled()` reads the captured opt-in configuration. +- `TestTiming::default()` creates an inactive guard without recording. +- `TestTiming::start(full_name)` starts a test manually when enabled. - `_pa_test_timing.span("fixture")` returns an owned `TimingSpan`. - `_pa_test_timing.recorder()` returns a cloneable `TimingRecorder`. - `TimingRecorder::span(name)` starts an owned span from helpers or spawned tasks. @@ -34,10 +36,12 @@ Timing configuration is captured once by the startup hook before test bodies run Platforms without that hook capture it on first use. Later environment changes do not alter the enabled flag or destination. -Timing is enabled by default. `PA_TEST_TIMING=0` disables timing and file output -for overhead comparisons. `PA_TEST_TIMING_DIR` selects the destination; otherwise -it is the workspace `target/test-timings` directory. Each process appends to -`-.jsonl`, with writes serialized within that process. +Timing is opt-in: set `PA_TEST_TIMING_DIR` to a non-empty destination to record. +An unset or empty destination disables timing without creating directories or +sidecars. `PA_TEST_TIMING=0` also disables timing for overhead comparisons, even +when a destination is configured. There is no default output directory. +Each enabled process appends to `-.jsonl` in the configured +destination, with writes serialized within that process. Each JSON line has `kind: "test"`, `test` (libtest name without the crate prefix), `binary`, `pid`, `start_unix_ns`, `end_unix_ns`, `elapsed_ns`, `panicking`, diff --git a/crates/pa-test-scratch/src/timing.rs b/crates/pa-test-scratch/src/timing.rs index b2f990eee..9fea4cc89 100644 --- a/crates/pa-test-scratch/src/timing.rs +++ b/crates/pa-test-scratch/src/timing.rs @@ -24,15 +24,17 @@ pub(crate) fn capture_config() { } fn config() -> &'static TimingConfig { - CONFIG.get_or_init(|| TimingConfig { - enabled: !std::env::var_os("PA_TEST_TIMING").is_some_and(|value| value == "0"), - directory: std::env::var_os("PA_TEST_TIMING_DIR").map_or_else( - || PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../target/test-timings"), - PathBuf::from, - ), + CONFIG.get_or_init(|| { + let directory = std::env::var_os("PA_TEST_TIMING_DIR").filter(|value| !value.is_empty()); + TimingConfig { + enabled: directory.is_some() + && !std::env::var_os("PA_TEST_TIMING").is_some_and(|value| value == "0"), + directory: directory.map_or_else(PathBuf::new, PathBuf::from), + } }) } +#[derive(Default)] pub struct TestTiming { state: Option, } @@ -62,9 +64,14 @@ struct SpanState { } impl TestTiming { + #[must_use] + pub fn is_enabled() -> bool { + config().enabled + } + #[must_use] pub fn start(full_name: &str) -> Self { - if !config().enabled { + if !Self::is_enabled() { return Self { state: None }; } let started = Instant::now(); diff --git a/crates/pa-test-scratch/tests/timing.rs b/crates/pa-test-scratch/tests/timing.rs index 4ccb44019..8ebfa13af 100644 --- a/crates/pa-test-scratch/tests/timing.rs +++ b/crates/pa-test-scratch/tests/timing.rs @@ -25,23 +25,37 @@ fn timing_retains_should_panic_behavior() { #[test] fn timing_configuration_survives_environment_changes() { if let Ok(mode) = std::env::var("PA_TIMING_CONFIG_CHILD") { + let late_directory = + std::env::var_os("PA_TIMING_CONFIG_LATE_DIR").expect("late timing destination"); let keys: Vec<_> = std::env::vars_os().map(|(key, _)| key).collect(); for key in keys { std::env::remove_var(key); } std::env::set_var("PA_TEST_TIMING", if mode == "enabled" { "0" } else { "1" }); + std::env::set_var("PA_TEST_TIMING_DIR", late_directory); + assert_eq!( + pa_test_scratch::TestTiming::is_enabled(), + mode == "enabled" || mode == "invalid" + ); let timing = pa_test_scratch::TestTiming::start("timing::after_environment_change"); let _span = timing.span("after_environment_change"); return; } let executable = std::env::current_exe().expect("test executable"); + let binary = executable + .file_name() + .expect("test binary name") + .to_string_lossy(); let root = std::env::temp_dir().join(format!("timing-config-{}", std::process::id())); - for mode in ["enabled", "disabled"] { + for mode in ["enabled", "disabled", "unset", "empty", "invalid"] { let directory = root.join(mode); let output = directory.join("timings"); std::fs::create_dir_all(&directory).expect("isolated child directory"); - let status = std::process::Command::new(&executable) + let invalid = directory.join("not-a-directory"); + std::fs::write(&invalid, "blocking file").expect("invalid output destination"); + let mut command = std::process::Command::new(&executable); + command .args([ "--exact", "timing_configuration_survives_environment_changes", @@ -49,12 +63,44 @@ fn timing_configuration_survives_environment_changes() { ]) .env_clear() .env("PA_TIMING_CONFIG_CHILD", mode) - .env("PA_TEST_TIMING", if mode == "enabled" { "1" } else { "0" }) - .env("PA_TEST_TIMING_DIR", &output) + .env("PA_TIMING_CONFIG_LATE_DIR", &invalid) + .env("PA_TEST_TIMING", if mode == "disabled" { "0" } else { "1" }) .env("PA_TEST_SCRATCH_ROOT", directory.join("scratch")) - .status() - .expect("run isolated timing child"); - assert!(status.success(), "{mode} timing child failed"); + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()); + match mode { + "enabled" | "disabled" => { + command.env("PA_TEST_TIMING_DIR", &output); + } + "unset" => {} + "empty" => { + command.env("PA_TEST_TIMING_DIR", ""); + } + "invalid" => { + command.env("PA_TEST_TIMING_DIR", &invalid); + } + _ => unreachable!("known timing configuration mode"), + } + let child = command.spawn().expect("run isolated timing child"); + let pid = child.id(); + let result = child.wait_with_output().expect("wait for timing child"); + let log = format!( + "{}{}", + String::from_utf8_lossy(&result.stdout), + String::from_utf8_lossy(&result.stderr) + ); + if mode == "invalid" { + assert!( + !result.status.success(), + "invalid timing destination succeeded" + ); + assert!( + log.contains("test timing write failed:"), + "missing loud failure: {log}" + ); + } else { + assert!(result.status.success(), "{mode} timing child failed: {log}"); + } if mode == "enabled" { let files: Vec<_> = std::fs::read_dir(&output) .expect("original timing destination") @@ -72,7 +118,14 @@ fn timing_configuration_survives_environment_changes() { && record["outcome"] == "returned" })); } else { - assert!(!output.exists(), "disabled timing created output"); + assert!(!output.exists(), "inactive timing created output"); } + let legacy_output = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../target/test-timings") + .join(format!("{binary}-{pid}.jsonl")); + assert!( + !legacy_output.exists(), + "timing used the removed default destination" + ); } } diff --git a/scripts/test_test_timings.py b/scripts/test_test_timings.py index 366c192ee..038ac7b70 100644 --- a/scripts/test_test_timings.py +++ b/scripts/test_test_timings.py @@ -10,7 +10,7 @@ import sys import tempfile import unittest -from test_timings import Children, load_timing_run, reconcile, span_totals, statuses +from test_timings import Children, configure_timing, load_timing_run, reconcile, span_totals, statuses def target(required=True): @@ -138,6 +138,28 @@ class ChildOwnership(unittest.TestCase): class TimingReports(unittest.TestCase): + def test_disabled_timing_has_no_destination_or_records_directory(self): + with tempfile.TemporaryDirectory() as state: + directory = Path(state) + pid_file = directory / "binary.pid" + pid_file.write_text("123\n") + env = {"PA_TEST_TIMING_DIR": "inherited-destination", "PA_TEST_TIMING": "1"} + records = directory / "records" + configure_timing(env, records, disabled=True) + self.assertNotIn("PA_TEST_TIMING_DIR", env) + self.assertNotIn("PA_TEST_TIMING", env) + self.assertFalse(records.exists()) + self.assertEqual(pid_file.read_text(), "123\n") + self.assertEqual(reconcile(target(), [], disabled=True), []) + + def test_enabled_timing_uses_explicit_destination(self): + with tempfile.TemporaryDirectory() as state: + records = Path(state) / "records" + env = {"PA_TEST_TIMING_DIR": "inherited-destination", "PA_TEST_TIMING": "0"} + configure_timing(env, records, disabled=False) + self.assertTrue(records.is_dir()) + self.assertEqual(env, {"PA_TEST_TIMING_DIR": str(records)}) + def test_harness_status_keeps_expected_panic_success_separate_from_guard(self): fixture = target() fixture["statuses"] = statuses( diff --git a/scripts/test_timings.py b/scripts/test_timings.py index 328728f18..a5df21a3f 100644 --- a/scripts/test_timings.py +++ b/scripts/test_timings.py @@ -115,6 +115,14 @@ def environment(repo, state, ambient): return env +def configure_timing(env, directory, disabled): + env.pop("PA_TEST_TIMING", None) + env.pop("PA_TEST_TIMING_DIR", None) + if not disabled: + directory.mkdir() + env["PA_TEST_TIMING_DIR"] = str(directory) + + def checked(command, cwd, env, log, commands, children): commands.append({"command": command, "cwd": str(cwd), "environment": env}) child = children.spawn(command, cwd=cwd, env=env, stdout=subprocess.PIPE, @@ -257,9 +265,7 @@ def execute(target, repo, ambient, run_dir, disabled, children): try: env = environment(repo, private, ambient) timing_dir = directory / "records" - timing_dir.mkdir() - env["PA_TEST_TIMING"] = "0" if disabled else "1" - env["PA_TEST_TIMING_DIR"] = str(timing_dir) + configure_timing(env, timing_dir, disabled) deps = str(Path(target["binary"]).parent) loader = "DYLD_FALLBACK_LIBRARY_PATH" if os.uname().sysname == "Darwin" else "LD_LIBRARY_PATH" env[loader] = os.pathsep.join(filter(None, [deps, env.get(loader)])) @@ -331,7 +337,7 @@ def execute_doctests(repo, ambient, run_dir, selection, children): try: env = environment(repo, private, ambient) env.pop("PA_TEST_TIMING_DIR", None) - env["PA_TEST_TIMING"] = "0" + env.pop("PA_TEST_TIMING", None) command = ["cargo", "test", "--locked", "--offline", *selection, "--doc"] target.update(command=command, cwd=str(repo), environment=env, state_root=str(private)) with (directory / "harness.log").open("w") as output: @@ -600,7 +606,8 @@ def main(): help="require lib/bin/proc-macro unit coverage too; doctest timing remains uncovered") runner.add_argument("--target", action="append", help="integration target name; repeat to select whole binaries") runner.add_argument("--output", type=Path) - runner.add_argument("--disable-timing", action="store_true", help="measure harness overhead without guard records") + runner.add_argument("--disable-timing", action="store_true", + help="exercise timing off path: unset PA_TEST_TIMING_DIR; do not create a records directory") viewer = commands.add_parser("table") viewer.add_argument("run_dir", type=Path, help="runner run directory or raw JSONL sidecar directory") args = parser.parse_args()