The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(scripts): storage-scenarios second-run corrections
M3gA-Mind87aeb07d0665
diff --git a/scripts/storage-scenarios/README.md b/scripts/storage-scenarios/README.mdindex ec42aa650b..6a7e15ae56 100644--- a/scripts/storage-scenarios/README.md+++ b/scripts/storage-scenarios/README.md@@ -117,6 +117,10 @@ when it is not, #8076), then writes the marker.`target/storage-scenarios/<run-id>/<driver>/`; the operator's`OPENHUMAN_STORAGE_URL`, workspace, master key and backend credentials areremoved from the environment before anything starts.+- The run directory is resolved with `realpath` first: the secrets backend+ refuses a directory with a symlinked ancestor, so a symlinked `target/`+ would otherwise fail every secrets check for a reason that is not the+ product's.- Each core gets a **random master key**, passed through the environment only.It, every token the run mints and every fixture secret are scrubbed from`core.log` and `rpc.jsonl`.@@ -139,7 +143,7 @@ when it is not, #8076), then writes the marker.| B-durability | sqlite, file | everything from A survives a restart; appends in flight when the core is SIGKILLed: every acked message present after reboot, none torn, duplicated or phantom; `PRAGMA integrity_check` = ok (sqlite) or every JSON/JSONL record parses (file) || C-on-disk | sqlite, file | the database opened read-only: each record in the expected collection and scope (`local`); the blob's bytes; secrets are `secrets` documents with no plaintext; neither the provider token nor the session token appears anywhere under HOME || D-isolation | sqlite | two users: separate `storage.db` files; neither sees the other's cron job, thread, voice note or credential over RPC; neither profile directory holds the other's marker; switching back restores the first user's records |-| E-legacy-import | sqlite | a v1 profile seeded with every legacy store: imported (cron jobs with ids kept, flows, notification, approvals, costs, auth profile), one marker per domain, originals byte-identical, the cost ledger renamed, the plaintext legacy token not in the database, and a second boot imports nothing |+| E-legacy-import | sqlite | a v1 profile seeded with every legacy store: imported (cron jobs, shell and agent ones with their ids and a flow-schedule job keyed `flow:<flow id>`; flows, notification, approvals, costs, auth profile), one marker per domain, originals byte-identical, the cost ledger renamed, the plaintext legacy token not in the database, and a second boot imports nothing || F-layout-migration | sqlite | E's profile moved to v2 by `auto_migrate_layout`: `storage_status` says 2, the marker, `storage.db` and `files/`, a non-empty `.tar.zst` backup, no collection shrank, the credential imported and the file archived; then a second v1 profile with **no master key**: the credential file stays byte-identical and its token reaches no database (#8076) || G-clear-app-data | sqlite | `config_reset_local_data` removes the active user's folder and `active_user.toml`, and leaves the other user's folder byte-identical (#8248); with an explicit storage URL, what survives the reset is reported || H-memory-restart | memory | A passes on the memory driver, and after a restart everything is gone, as designed |diff --git a/scripts/storage-scenarios/isolated.mjs b/scripts/storage-scenarios/isolated.mjsindex cce55eccd8..0cdc879c85 100644--- a/scripts/storage-scenarios/isolated.mjs+++ b/scripts/storage-scenarios/isolated.mjs@@ -122,10 +122,10 @@ const legacyImport = {await rig.start();const exp = await tinyflowsExpected();- const cronIds = exp.cron.jobs.map((j) => j.id);+ const cronIds = exp.cron.jobs.map(expectedJobId);const jobs = jobsOf(await rig.tryRpc("openhuman.cron_list", {}));- const missingJobs = exp.cron.jobs.filter((e) => !jobs.some((j) => j.id === e.id));- ctx.check({ id: "E-cron", ok: missingJobs.length === 0, expected: `cron_list has the ${cronIds.length} legacy jobs with their ids kept`, actual: missingJobs.length ? `missing ${missingJobs.map((e) => `${e.id} (${e.name})`).join(", ")}; listed: ${jobs.map((j) => `${j.id} (${j.name})`).join(", ").slice(0, 400)}` : "all listed" });+ const missingJobs = exp.cron.jobs.filter((e) => !jobs.some((j) => j.id === expectedJobId(e)));+ ctx.check({ id: "E-cron", ok: missingJobs.length === 0, expected: `cron_list has the ${cronIds.length} legacy jobs: shell and agent jobs keep their ids, a flow-schedule job is keyed flow:<flow id> (tinyflows-drivers schedule/jobs.rs flow_job_id)`, actual: missingJobs.length ? `missing ${missingJobs.map((e) => `${expectedJobId(e)} (${e.name})`).join(", ")}; listed: ${jobs.map((j) => `${j.id} (${j.name})`).join(", ").slice(0, 400)}` : "all listed" });const notifs = await rig.tryRpc("openhuman.notification_list", { limit: 100 });ctx.check({ id: "E-notifications", ok: json(notifs.value).includes('"n-1"'), expected: "notification_list has legacy notification n-1", actual: notifs.ok ? json(notifs.value).slice(0, 200) : errText(notifs) });const decisions = await rig.tryRpc("openhuman.approval_list_recent_decisions", { limit: 100 });@@ -156,7 +156,9 @@ const legacyImport = {if (!exists(dbFile)) return;const first = withDb(dbFile, (db) => ({ census: db.census(), markers: markerIds(db) }));ctx.result("E-census", first.census);- const missing = LEGACY_EXPECT.markerDomains.filter((d) => !first.markers.some((m) => m.includes(`storage_import/${d}@`)));+ // A finished import leaves `done/storage/storage_import/<domain>@<digest>`;+ // `claim/...` is the lease taken while it ran.+ const missing = LEGACY_EXPECT.markerDomains.filter((d) => !first.markers.some((m) => m.startsWith("done/") && m.includes(`storage_import/${d}@`)));ctx.check({ id: "E-markers", ok: missing.length === 0, expected: `an import marker per domain (${LEGACY_EXPECT.markerDomains.join(", ")})`, actual: `markers: ${first.markers.join(", ") || "none"}; missing ${missing.join(", ") || "none"}` });const leaked = await grepTree(path.join(workspace, "storage"), token);ctx.check({ id: "E-secret-encrypted", ok: leaked.length === 0, expected: "the legacy plaintext token is not in the database after adoption", actual: `${leaked.length} files`, severity: "high" });@@ -172,7 +174,7 @@ const legacyImport = {const was = first.census.find((x) => x.scope === r.scope && x.coll === r.coll);return !was || was.n !== r.n;});- const legacyMarkers = (m) => m.filter((x) => x.includes("storage_import/")).sort();+ const legacyMarkers = (m) => m.filter((x) => x.startsWith("done/") && x.includes("storage_import/")).sort();ctx.check({ id: "E-idempotent", ok: delta.length === 0 && json(legacyMarkers(second.markers)) === json(legacyMarkers(first.markers)), expected: "a second boot adds no imported record and no import marker", actual: delta.length ? json(delta).slice(0, 300) : `unchanged; ${legacyMarkers(second.markers).length} markers` });const other = second.census.filter((r) => !imported(r)).filter((r) => (first.census.find((x) => x.scope === r.scope && x.coll === r.coll)?.n ?? 0) !== r.n);if (other.length) ctx.note("E-bookkeeping-delta", `second boot changed storage bookkeeping (not imported records): ${json(other).slice(0, 400)}`);@@ -196,7 +198,7 @@ const layoutMigration = {const status = await rig.tryRpc("openhuman.storage_status", {});ctx.check({ id: "F-status", ok: json(status.value).includes('"layout_version":2') || pick(status.value, "layout_version", "result.layout_version") === 2, expected: "storage_status reports layout_version 2", actual: status.ok ? json(status.value).slice(0, 200) : errText(status) });const jobs = jobsOf(await rig.tryRpc("openhuman.cron_list", {}));- const cronIds = (await tinyflowsExpected()).cron.jobs.map((j) => j.id);+ const cronIds = (await tinyflowsExpected()).cron.jobs.map(expectedJobId);ctx.check({ id: "F-data-intact-rpc", ok: cronIds.every((id) => jobs.some((j) => j.id === id)), expected: "the imported cron jobs are still listed after the move", actual: `${jobs.filter((j) => cronIds.includes(j.id)).length}/${cronIds.length}` });const creds = json((await rig.tryRpc("openhuman.auth_list_provider_credentials", {})).value);ctx.check({ id: "F-credential-intact", ok: creds.includes(LEGACY_EXPECT.provider), expected: "the legacy credential is still listed after the move", actual: creds.slice(0, 200) });@@ -237,6 +239,9 @@ const layoutMigration = {},};+/** A legacy job's id after import: a flow's schedule job is keyed by its flow. */+const expectedJobId = (job) => (job.job_type === "flow" ? `flow:${job.command}` : job.id);+/*** Ids of the `storage.import_state` documents, decoded: tsd stores a key as* `/`-joined hex segments (`claim/73746f72616765/...`), the step id is inside.diff --git a/scripts/storage-scenarios/legacy.mjs b/scripts/storage-scenarios/legacy.mjsindex a60e463187..04ac64d114 100644--- a/scripts/storage-scenarios/legacy.mjs+++ b/scripts/storage-scenarios/legacy.mjs@@ -26,7 +26,7 @@ export const LEGACY_EXPECT = {costs: ["storscen-cost-1", "storscen-cost-2", "storscen-cost-3"],provider: "storscen-legacy-provider",// The import markers (`storage.import_state`, `storage_import/<domain>@<digest>`).- markerDomains: ["approvals", "devices", "notifications", "task_sources", "cron", "flows", "sessions"],+ markerDomains: ["approval", "devices", "notifications", "task_sources", "cron", "flows", "sessions"],};async function copyTree(from, to) {diff --git a/scripts/storage-scenarios/run.mjs b/scripts/storage-scenarios/run.mjsindex 9c2b39e6ef..f2f026e506 100644--- a/scripts/storage-scenarios/run.mjs+++ b/scripts/storage-scenarios/run.mjs@@ -326,7 +326,10 @@ async function main() {if (!fs.existsSync(opts.coreBin))throw new Error(`core binary not found at ${opts.coreBin}\nbuild it: cargo build -p openhuman-cli --bin openhuman-core`);const runId = new Date().toISOString().replace(/[:.]/g, "-");- const runDir = path.join(opts.runRoot, runId);+ // Resolved: the secrets backend refuses a directory with a symlinked+ // ancestor, and a symlinked target/ must not decide a secrets check.+ await fsp.mkdir(opts.runRoot, { recursive: true });+ const runDir = path.join(fs.realpathSync(opts.runRoot), runId);await fsp.mkdir(runDir, { recursive: true });console.log(`run dir : ${runDir}`);const findings = new Findings();diff --git a/scripts/storage-scenarios/scenarios.mjs b/scripts/storage-scenarios/scenarios.mjsindex 2ea3160692..ddc5086cfa 100644--- a/scripts/storage-scenarios/scenarios.mjs+++ b/scripts/storage-scenarios/scenarios.mjs@@ -82,7 +82,9 @@ async function readBackA(ctx, label) {actual: r.ok ? json(r.value).slice(0, 300) : errText(r),});}- {+ if (a.appended === 0) {+ // Nothing was accepted (A-thread-append is the finding); a read-back adds nothing.+ } else {const r = await ctx.tryRpc("openhuman.threads_messages_list", { thread_id: a.threadId });const msgs = listOf(r.value, "messages");const ours = msgs.filter((m) => String(m.id).startsWith(`storscen-${ctx.tag}-m`));@@ -132,6 +134,14 @@ async function readBackA(ctx, label) {return out;}+/** Secret document ids per scope, hex segments decoded (`secrets` collection). */+function secretIds(db) {+ const hex = (seg) => (/^([0-9a-f]{2})+$/.test(seg) ? Buffer.from(seg, "hex").toString("utf8") : seg);+ const out = {};+ for (const d of db.docs("secrets")) (out[d.scope] ??= []).push(d.id.split("/").map(hex).join("/"));+ return out;+}+// ---------------------------------------------------------------------------// A. write -> read back per port// ---------------------------------------------------------------------------@@ -204,6 +214,7 @@ const writeRead = {if (r.ok) appended += 1;else ctx.state.appendError ??= errText(r);}+ a.appended = appended;ctx.check({id: "A-thread-append",ok: appended === a.messages.length,@@ -346,6 +357,10 @@ const onDisk = {if (ctx.driver === "sqlite") {const dbs = await ctx.dbFiles();+ // Which database holds which secret: a session written before the+ // profile's backend is bound would sit in another file.+ for (const f of dbs)+ ctx.note(`C-secrets-${path.basename(path.dirname(f))}`, `${path.relative(ctx.oh, f)}: ${json(withDb(f, secretIds))}`);const own = dbs.filter((p) => p.includes(`${path.sep}users${path.sep}${a.sessionUser}${path.sep}`));ctx.check({ id: "C-db-location", ok: own.length === 1, expected: `one storage.db under users/${a.sessionUser}/ (layout v2 profile)`, actual: dbs.map((p) => path.relative(ctx.oh, p)).join(", ") || "none" });const file = own[0] ?? dbs[0];@@ -369,6 +384,7 @@ const onDisk = {const leak = secrets.filter((s) => s.body.includes(a.providerToken) || s.body.includes(a.sessionToken));ctx.check({ id: "C-secret-docs", ok: secrets.length > 0 && leak.length === 0, expected: "secrets are encrypted documents (collection `secrets`), no plaintext in their bodies", actual: `${secrets.length} secret docs in ${[...new Set(secrets.map((s) => s.scope))].join(",") || "-"}; ${leak.length} with plaintext` , severity: "high" });ctx.result("census", db.census());+ ctx.result("secret-ids", secretIds(db));ctx.result("scopes", db.scopes());ctx.note("C-census", `scopes on disk: ${db.scopes().join(", ")}; KV rows: ${db.kvRows().length}; tables: ${json(db.tables)}`);});