Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(storage): read legacy v1 profile records from the local scope

Steven Enamakelf3147df40ddb
diff --git a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rs b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rs
index cdd4950639..76032d1ecd 100644
--- a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rs
+++ b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rs
@@ -208,10 +208,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
)
.await?;
- // Legacy profile-owned records whose public owners must continue to read
- // them after the profile's real v1-to-v2 boot migration.
+ // Records in an existing desktop profile database use the historical
+ // local scope: the profile directory itself supplied user isolation.
+ // Their owners must continue to read them after the real v1-to-v2 boot
+ // migration.
+ let user_scope = backend.for_scope(&Scope::local()?)?;
put(
- profile_scope.documents(),
+ user_scope.documents(),
"approvals",
"fixture-approval",
json!({
@@ -227,7 +230,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
)
.await?;
put(
- profile_scope.documents(),
+ user_scope.documents(),
"threads_transcript_keys",
"fixture-thread",
json!({"transcript_key": "fixture-transcript-key"}),
@@ -252,7 +255,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.await?;
let secret_store = DocumentSecrets::new(
- &profile_scope,
+ &user_scope,
Arc::new(DerivedKeys::new(Zeroizing::new([0x5a; 32]))),
);
secret_store
diff --git a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/storage.db b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/storage.db
deleted file mode 100644
index 1852a1e6e0..0000000000
Binary files a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/storage.db and /dev/null differ
diff --git a/tests/storage_legacy_profile_boot_e2e.rs b/tests/storage_legacy_profile_boot_e2e.rs
index 6ad3636c56..65442058d1 100644
--- a/tests/storage_legacy_profile_boot_e2e.rs
+++ b/tests/storage_legacy_profile_boot_e2e.rs
@@ -156,9 +156,9 @@ fn desktop_boot_reads_a_preserved_existing_v1_profile_database() {
"boot must leave the historical v1 storage.db byte-for-byte unchanged"
);
- // The desktop's root context is unscoped; profile-owned records are read
- // through the same owners under the active profile context they belong to.
- let workspace = profile.join("workspace");
+ // The profile's V2 workspace resolves its default backend to the exact
+ // storage.db that desktop boot just opened.
+ let workspace = profile.join("files");
let mut config = openhuman_core::config::Config::default();
config.config_path = profile.join("config.toml");
config.workspace_dir = workspace.clone();
@@ -181,15 +181,9 @@ fn desktop_boot_reads_a_preserved_existing_v1_profile_database() {
.build()
.await
.unwrap();
- let profile_context = runtime.context().derive_with(
- openhuman_core::core::runtime::ContextOverlay::new(
- config.clone(),
- openhuman_core::core::runtime::DomainSet::full(),
- openhuman_core::tools::toolpacks::ToolGroups::none(),
- )
- .profile("u1"),
- );
- openhuman_core::core::runtime::CoreContext::scope(profile_context, async {
+ openhuman_core::core::runtime::CoreContext::scope(
+ std::sync::Arc::clone(runtime.context()),
+ async {
let dispatch = openhuman_core::core::runtime::DispatchCtx::ambient();
let thread_store = openhuman_core::threads::store::ConversationStore::new(
dispatch,
@@ -208,7 +202,8 @@ fn desktop_boot_reads_a_preserved_existing_v1_profile_database() {
"approval owner did not read the v1 database record"
);
assert_eq!(approvals[0].request_id, "fixture-approval");
- })
+ },
+ )
.await;
});
})
@@ -222,7 +217,7 @@ fn desktop_boot_reads_a_preserved_existing_v1_profile_database() {
openhuman_core::storage::open(&url).await
})
.unwrap();
- let scope = openhuman_core::storage::Scope::new("u:u1").unwrap();
+ let scope = openhuman_core::storage::Scope::local().unwrap();
let scoped = backend.for_scope(&scope).unwrap();
let secrets = openhuman_core::storage::secrets::over(
&scoped,