mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-17 23:52:34 +00:00
Both sides rewrote the same crates. This branch replaced fabro's sandbox layer with the sandbox driver: one RunSandbox, no Sandbox trait, driver events consumed directly, MockSandbox over the driver's doubles. Main replaced fabro's LLM layer with lithos-llm: fabro-model deleted, the catalog and provider ids from lithos, credentials through the lithos CredentialProvider, clients built with build_client. Every conflict was one of those two renames meeting in an import list or a signature, so the rule was mechanical: sandbox names resolve to this branch, LLM names to main. Where main's newer code still used the old sandbox API — new session tests over Arc::new(MockSandbox), the SDK example's LocalSandbox, test fakes typed as Arc<dyn Sandbox> — it is ported to RunSandbox and the mock helper. Where this branch still used fabro-model or Client::from_source, main's replacement stands. One combined future in the CLI runner crossed clippy's size budget and is boxed at its call. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
84 lines
2.6 KiB
Rust
84 lines
2.6 KiB
Rust
use std::path::Path;
|
|
use std::sync::Arc;
|
|
|
|
use fabro_agent::{RunSandbox, local_sandbox};
|
|
use fabro_auth::test_support;
|
|
use fabro_hooks::{
|
|
HookContext, HookDecision, HookDefinition, HookEvent, HookExecutionContext, HookRunner,
|
|
HookSettings, InterpString,
|
|
};
|
|
use fabro_llm::credentials::CredentialProvider;
|
|
use fabro_llm::lithos_catalog::Catalog;
|
|
use fabro_types::RunId;
|
|
use tokio::fs;
|
|
|
|
fn test_llm_source() -> Arc<dyn CredentialProvider> {
|
|
test_support::vault_only_credential_source()
|
|
}
|
|
|
|
fn test_catalog() -> Arc<Catalog> {
|
|
Arc::new(fabro_llm::default_catalog())
|
|
}
|
|
|
|
async fn test_sandbox() -> Arc<RunSandbox> {
|
|
Arc::new(
|
|
local_sandbox(std::env::current_dir().expect("test process should have a cwd"))
|
|
.await
|
|
.expect("local sandbox should be created"),
|
|
)
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn host_command_hook_uses_host_workdir_not_sandbox_workdir() {
|
|
let host_work_dir =
|
|
std::env::temp_dir().join(format!("fabro-host-hook-cwd-{}", std::process::id()));
|
|
let _ = fs::remove_dir_all(&host_work_dir).await;
|
|
fs::create_dir_all(&host_work_dir)
|
|
.await
|
|
.expect("test should create host hook cwd");
|
|
let container_only_work_dir = Path::new("/workspace/fabro-host-hook-repro-missing");
|
|
assert!(
|
|
!container_only_work_dir.exists(),
|
|
"reproduction requires a container-only cwd that does not exist on the host"
|
|
);
|
|
|
|
let runner = HookRunner::new(
|
|
HookSettings {
|
|
hooks: vec![HookDefinition {
|
|
name: Some("host-marker".to_string()),
|
|
event: HookEvent::RunStart,
|
|
command: Some(InterpString::parse("printf ran > marker.txt")),
|
|
hook_type: None,
|
|
matcher: None,
|
|
blocking: Some(true),
|
|
timeout_ms: Some(5000),
|
|
sandbox: Some(false),
|
|
}],
|
|
},
|
|
test_llm_source(),
|
|
test_catalog(),
|
|
);
|
|
let context = HookContext::new(
|
|
HookEvent::RunStart,
|
|
RunId::new(),
|
|
"host-hook-cwd".to_string(),
|
|
);
|
|
|
|
let decision = runner
|
|
.run(&context, test_sandbox().await, HookExecutionContext {
|
|
host_source_dir: Some(host_work_dir.clone()),
|
|
sandbox_work_dir: Some(container_only_work_dir.to_path_buf()),
|
|
})
|
|
.await;
|
|
|
|
assert_eq!(decision, HookDecision::Proceed);
|
|
assert_eq!(
|
|
fs::read_to_string(host_work_dir.join("marker.txt"))
|
|
.await
|
|
.expect("host hook should create marker file"),
|
|
"ran"
|
|
);
|
|
fs::remove_dir_all(&host_work_dir)
|
|
.await
|
|
.expect("test should clean up host hook cwd");
|
|
}
|