fix(runtime): isolate agent state by project (#101)
This commit is contained in:
@ -7,7 +7,9 @@ use std::sync::Arc;
|
||||
|
||||
use domain::ids::ProfileId;
|
||||
use domain::ports::{FileSystem, ProfileStore, RemotePath, SecretRef, StoreError};
|
||||
use domain::profile::{AgentProfile, ContextInjection, OpenCodeConfig, OpenCodeProviderConfig, StructuredAdapter};
|
||||
use domain::profile::{
|
||||
AgentProfile, ContextInjection, OpenCodeConfig, OpenCodeProviderConfig, StructuredAdapter,
|
||||
};
|
||||
use infrastructure::{FsProfileStore, LocalFileSystem};
|
||||
use uuid::Uuid;
|
||||
|
||||
@ -173,11 +175,20 @@ async fn profiles_file_is_camelcase_versioned() {
|
||||
/// cloud provider (`opencodeProvider`) — the two mutually exclusive OpenCode
|
||||
/// backends. A profile carrying both is inconsistent.
|
||||
fn opencode_backends() -> (OpenCodeConfig, OpenCodeProviderConfig) {
|
||||
let local =
|
||||
OpenCodeConfig::new("http://localhost:8080/v1", None, "qwen3-coder-30b", None, None).unwrap();
|
||||
let cloud =
|
||||
OpenCodeProviderConfig::new("anthropic", "claude-sonnet-5", SecretRef::new("secret-cloud"))
|
||||
.unwrap();
|
||||
let local = OpenCodeConfig::new(
|
||||
"http://localhost:8080/v1",
|
||||
None,
|
||||
"qwen3-coder-30b",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
let cloud = OpenCodeProviderConfig::new(
|
||||
"anthropic",
|
||||
"claude-sonnet-5",
|
||||
SecretRef::new("secret-cloud"),
|
||||
)
|
||||
.unwrap();
|
||||
(local, cloud)
|
||||
}
|
||||
|
||||
@ -203,15 +214,21 @@ async fn read_doc_repairs_stale_opencode_when_both_sections_present() {
|
||||
|
||||
let fs = LocalFileSystem::new();
|
||||
let doc = serde_json::json!({ "version": 1, "profiles": [corrupted] });
|
||||
fs.write(&tmp.child("profiles.json"), &serde_json::to_vec_pretty(&doc).unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
fs.write(
|
||||
&tmp.child("profiles.json"),
|
||||
&serde_json::to_vec_pretty(&doc).unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let store = store(&tmp);
|
||||
let listed = store.list().await.expect("read repairs instead of failing");
|
||||
assert_eq!(listed.len(), 1, "corrupted profile preserved as an entry");
|
||||
let repaired = &listed[0];
|
||||
assert!(repaired.opencode.is_none(), "stale local `opencode` dropped on read");
|
||||
assert!(
|
||||
repaired.opencode.is_none(),
|
||||
"stale local `opencode` dropped on read"
|
||||
);
|
||||
assert_eq!(
|
||||
repaired.opencode_provider.as_ref().unwrap().provider_id,
|
||||
"anthropic",
|
||||
|
||||
Reference in New Issue
Block a user