Skip to content

Isolate Codex logs per top-level test (generalize #274)#275

Merged
ElonSG merged 1 commit into
devfrom
feat/per-test-runtime-log-isolation
Jul 14, 2026
Merged

Isolate Codex logs per top-level test (generalize #274)#275
ElonSG merged 1 commit into
devfrom
feat/per-test-runtime-log-isolation

Conversation

@ElonSG

@ElonSG ElonSG commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What

Generalizes #274 ("Isolate run-graph Codex logs"). #274 gave each run_graph invocation a tempdir-scoped FKST_RUNTIME_LOG_DIR (consumer side). This gives each top-level test function its own fresh tempdir-scoped FKST_RUNTIME_LOG_DIR, so no top-level test can see another's Codex status records.

Why

A downstream packages test that drives a real (mocked) Codex-spawning department leaks a Codex status record into the ambient FKST_RUNTIME_LOG_DIR. #274 stopped run-graph consumers from seeing such records, but the producer leak remained: any top-level test's leaked status record was still visible to sibling top-level tests in the same process via fkst.codex_runs (running/recent). That is the class this closes — a real incident had an observation test leak a role=fix status record that suppressed a later run-graph test's mocked spawn on the pre-#274 engine.

Change

with_top_level_runtime_log_dir creates a fresh tempdir/logs per top-level test, applies FKST_RUNTIME_LOG_DIR via DeptRunEnvGuard, and restores/removes the prior env value error-safely on success, Lua error, and panic unwind (test_runner.rs:111,157-174). Reuses #274's mechanism; the inner per-run_graph-invocation isolation is preserved. Scope is minimal — only the Codex log dir, not RUNTIME_ROOT/DURABLE_ROOT.

Tests

  • cargo build -p fkst-framework = 0; cargo test -p fkst-framework --test test_runner_cli = 38 passed/0; --test run_graph_cli = 0; --test sdk_codex = 0.
  • Regression test tests/test_runner_cli.rs:2258: top-level test A records a mocked Codex status, top-level test B asserts fkst.codex_runs shows no cross-test record — exits 101 before this change and 0 after, proving isolation.
  • (The managed sandbox denies the observe integration test's Unix-domain socket bind with EPERM, unrelated.)

Reviewed by 3 independent perspectives (error-safe restore / minimal scope / regression proves isolation) — all approve.

⟦AI:FKST⟧

Generalize #274's per-run_graph Codex log isolation to each top-level Lua test. This closes the producer-side ambient FKST_RUNTIME_LOG_DIR leak that let observation tests pollute later run_graph consumers in the same harness process.

Reuse the existing Department env guard for error-safe restoration, and cover cross-test status isolation plus error and panic cleanup.

⟦AI:FKST⟧
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.56604% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/fkst-framework/src/test_runner.rs 70.58% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ElonSG
ElonSG merged commit e3355b4 into dev Jul 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants