test(sdk): give the isolation and retry-negative tests teeth

Three tests that would pass against a broken implementation:

- `kv`/`docs` cross-app isolation asserted only that app B sees nothing — an
  execution_id-keyed (or script_id-keyed) bridge would pass that AND every
  single-execution round-trip, with app-scoped persistence entirely gone. Added
  the positive control: app A re-reads its own value in a LATER execution (a fresh
  execution_id/script_id via `baseline_request`), which only holds if storage is
  keyed by app_id.

- `retry_policy_rejects_bogus_backoff` asserted a bare `is_err()`, which passes if
  `retry::policy` is unregistered (ErrorFunctionNotFound), on a script typo, or if
  every policy is rejected. Now it pins the message (`backoff`) and adds a
  valid-backoff control that must succeed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-07-15 19:38:31 +02:00
parent 95d6b95272
commit a7fb7ea23c
3 changed files with 69 additions and 7 deletions

View File

@@ -501,8 +501,27 @@ async fn docs_bridge_preserves_cross_app_isolation() {
v == ()
"#
);
let body = run_script(engine, &reader_src, baseline_request(app_b)).await;
assert_eq!(body, json!(true));
let body = run_script(engine.clone(), &reader_src, baseline_request(app_b)).await;
assert_eq!(body, json!(true), "app B must not see app A's document");
// Positive control — without it this test has no teeth (an execution_id-keyed
// bridge would pass the negative above). `baseline_request` mints a fresh
// execution_id/script_id per call, so this re-read under app_a is a different
// execution than the writer; it must still find A's own doc.
let reader_a = format!(
r#"
let c = docs::collection("shared");
let v = c.get("{id_a_str}");
if v == () {{ "MISSING" }} else {{ v.data.from }}
"#
);
let body = run_script(engine, &reader_a, baseline_request(app_a)).await;
assert_eq!(
body,
json!("a"),
"app A must read back its own document in a later execution — storage is \
keyed by app_id, not execution_id/script_id"
);
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]