fix(test): preserve sealed environment across approval evidence workers

The blocking approval-evidence worker added at 2bbe598ba resolves test config through a barrier held by its awaiting caller. Reuse generation-scoped env_scope_ticket/join_env_scope at this test-only thread boundary, preserving production spawn_blocking behavior and sealed-state safety. Added a bounded trust-read regression, implementation first. Source trace explains CI tool-event timeouts; runtime test and fixes-off evidence are pending the shared governed queue. This local checkpoint does not claim verification or readiness to push.

Signed-off-by: CodeWhale Bot <[email protected]>
This commit is contained in:
CodeWhale Bot committed 2026-09-30 01:38:47 -07:00
1 parent bc3fe38608
commit d213f85f46
1 file changed
+34
+34
View File
@@ -431,7 +431,11 @@ impl<'a> AutoReviewContext<'a> {
let tool_name = tool_name.to_owned();
let params = params.clone();
let workspace = workspace.map(std::path::Path::to_path_buf);
#[cfg(test)]
let env_ticket = crate::test_support::env_scope_ticket();
tokio::task::spawn_blocking(move || {
#[cfg(test)]
let _membership = crate::test_support::join_env_scope(env_ticket);
let trusted = workspace
.as_deref()
.is_some_and(crate::config::is_workspace_trusted);
@@ -2689,6 +2693,36 @@ mod tests {
)
}
#[tokio::test(flavor = "current_thread")]
async fn auto_review_worker_keeps_the_callers_sealed_environment() {
use crate::test_support::{EnvVarGuard, lock_test_env};
use std::time::Duration;
let _lock = lock_test_env();
let home = tempfile::tempdir().expect("test home");
let workspace = tempfile::tempdir().expect("workspace");
let _home = EnvVarGuard::set("CODEWHALE_HOME", home.path());
crate::config::save_workspace_trust(workspace.path()).expect("save trust");
let context = tokio::time::timeout(
Duration::from_secs(2),
AutoReviewContext::from_tool_call_async(
"read_file",
&json!({ "path": "README.md" }),
RunOrigin::Interactive,
ApprovalMode::Auto,
Some(workspace.path()),
),
)
.await
.expect("worker must not wait for its awaiting caller's environment lock")
.expect("evidence");
assert!(
context.workspace_trusted,
"worker must read the sealed trust file"
);
}
#[cfg(unix)]
#[tokio::test(flavor = "current_thread")]
async fn auto_review_filesystem_evidence_does_not_park_runtime() {