Skip to content

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

fix(memory): keep erase successful when success reporting fails

Steven Enamakelfbcf66e068d2
diff --git a/app/src/components/memory/MemoryEraseAllCard.test.tsx b/app/src/components/memory/MemoryEraseAllCard.test.tsx
index 399bbbde01..e7c4591c20 100644
--- a/app/src/components/memory/MemoryEraseAllCard.test.tsx
+++ b/app/src/components/memory/MemoryEraseAllCard.test.tsx
@@ -89,6 +89,21 @@ describe('MemoryEraseAllCard', () => {
);
});
+ it('keeps the erase a success when the success reporting throws', async () => {
+ hoisted.erase.mockResolvedValue({ erased_scopes: 1 });
+ hoisted.track.mockImplementationOnce(() => {
+ throw new Error('analytics boom');
+ });
+ const onErased = vi.fn();
+ renderWithProviders(<MemoryEraseAllCard onErased={onErased} />);
+ await openDialog();
+ fireEvent.click(screen.getByTestId('memory-erase-ack'));
+ fireEvent.click(screen.getByTestId('memory-erase-confirm'));
+
+ await waitFor(() => expect(onErased).toHaveBeenCalledTimes(1));
+ expect(screen.queryByTestId('memory-erase-error')).not.toBeInTheDocument();
+ });
+
it('contains a rejected async refresh callback', async () => {
hoisted.erase.mockResolvedValue({ erased_scopes: 1 });
const onErased = vi.fn(() => Promise.reject(new Error('refresh boom')));
diff --git a/app/src/components/memory/MemoryEraseAllCard.tsx b/app/src/components/memory/MemoryEraseAllCard.tsx
index 812d8ef3b6..22de9446f5 100644
--- a/app/src/components/memory/MemoryEraseAllCard.tsx
+++ b/app/src/components/memory/MemoryEraseAllCard.tsx
@@ -90,14 +90,6 @@ export default function MemoryEraseAllCard({
try {
const result = await memoryEraseAll();
log('erase_all ok: erased_scopes=%d', result?.erased_scopes ?? 0);
- trackAnalyticsEvent('memory_erased_all');
- toast.add({
- type: 'success',
- title: t('memoryPage.settings.erasedToast'),
- description: t('memoryPage.settings.erasedToastBody'),
- });
- setOpen(false);
- setAcknowledged(false);
erased = true;
} catch (err) {
const key = eraseErrorKey(err);
@@ -106,8 +98,21 @@ export default function MemoryEraseAllCard({
} finally {
setErasing(false);
}
- // The erase has already succeeded; a refresh failure must not read as one.
+ // The erase has already succeeded; reporting or refresh failures must not
+ // read as a failed erase.
if (erased) {
+ try {
+ trackAnalyticsEvent('memory_erased_all');
+ toast.add({
+ type: 'success',
+ title: t('memoryPage.settings.erasedToast'),
+ description: t('memoryPage.settings.erasedToastBody'),
+ });
+ setOpen(false);
+ setAcknowledged(false);
+ } catch (err) {
+ log('erase_all success reporting failed: %s', err instanceof Error ? err.name : 'unknown');
+ }
try {
await onErased?.();
} catch (err) {
diff --git a/gitbooks/features/privacy-and-security.md b/gitbooks/features/privacy-and-security.md
index dbf04b9838..00192cf601 100644
--- a/gitbooks/features/privacy-and-security.md
+++ b/gitbooks/features/privacy-and-security.md
@@ -29,7 +29,7 @@ Your workspace files, settings and audio buffers stay on your machine. **Your me
| | |
| ------------------------------- | --------------------------------------------------------------- |
-| **Memory items** | **Not local.** Stored in CortexDB by your selected engine (see below). |
+| **Memory items** | **Not local with hosted memory.** Stored in CortexDB by your selected engine (see below); a CortexDB you self-host on your own machine keeps it there. |
| **Memory bookkeeping** | Local: the job queue and sync, backfill and import progress under `<workspace>/memory/`, the sources list in `config.toml`, a CortexDB key in the OS keychain. No memory content. |
| **Audio capture buffers** | Local. Discarded after STT. |
| **Local model state** | Local. |
@@ -43,7 +43,7 @@ Memory items are your brain documents, logged conversation turns, learnings, and
| **TinyHumans** (hosted) | The core sends each request over TLS to the TinyHumans backend's `/memory/*` routes, authenticated with your session or TinyHumans API key. The backend applies a per-user rate limit and billing, then forwards to a CortexDB proxy that places every scope under your own tenant root. | Only your account. The proxy derives the tenant from your credential, not from the request, so one user cannot read or write another's memory. TinyHumans operates the service. |
| **CortexDB** (direct) | The core calls CortexDB itself (`api-v1.cortexdb.ai`, or a self-hosted endpoint) with your own CortexDB API key, kept in the OS keychain. It does not go through the TinyHumans backend. | Whoever holds that key, and the operator of that endpoint. |
-Inside either engine, memory is kept below a root for the signed-in person (`user:<id>`), so it can be listed, confined and erased as one tree. Learnings and the brain are shared by your agents; each agent's conversations are tagged with that agent.
+Inside either engine, memory is kept below a root derived from the active config identity (`user:<id>` for a TinyHumans account, `user:local-<digest>` for a local identity), so it can be listed, confined and erased as one tree. Learnings and the brain are shared by your agents; each agent's conversations are tagged with that agent.
We make no claim beyond TLS in transit and per-user tenant isolation for hosted memory. In particular, these docs do not promise end-to-end or client-side encryption: the hosted service can read what it stores, which is how it answers recall.
diff --git a/gitbooks/guides/privacy-sensitive-data.md b/gitbooks/guides/privacy-sensitive-data.md
index 7e9b7723ea..ecdd6f2f2d 100644
--- a/gitbooks/guides/privacy-sensitive-data.md
+++ b/gitbooks/guides/privacy-sensitive-data.md
@@ -15,7 +15,7 @@ If you want the engineering detail, read [Privacy & Security](../features/privac
## The one-sentence version
-**Your settings and secrets stay on your computer; your memory is stored in CortexDB (hosted by TinyHumans for your account, or your own). The OpenHuman backend handles what has to be brokered: signing you in, hosted memory, routing model requests, and talking to the services you connect.**
+**Your settings and local secrets stay on your computer; your memory is stored in CortexDB (hosted by TinyHumans for your account, or your own). The OpenHuman backend handles what has to be brokered: signing you in, hosted memory, routing model requests, and talking to the services you connect.**
Everything below is an expansion of that sentence.
@@ -31,9 +31,9 @@ These never leave your computer as raw data:
| **Local model state** | If you use [local AI](local-model.md), your own runtime and its models stay on-device. |
| **Your persona and settings** | The files that define how your assistant behaves and what it's allowed to do. |
-## Your memory is stored off your machine
+## Where your memory is stored
-When memory is on, documents, conversations, learnings and the beliefs built from them are stored in **CortexDB**, not on your computer (with no engine available, memory is off and nothing is stored):
+When memory is on, documents, conversations, learnings and the beliefs built from them are stored in **CortexDB**. With TinyHumans-hosted memory they are not stored on your computer; a CortexDB you self-host may keep them on your own machine (with no engine available, memory is off and nothing is stored):
- **TinyHumans engine (default when signed in):** stored in the hosted CortexDB that TinyHumans runs, through the TinyHumans backend. Each account gets its own isolated tenant, so other users cannot see your memory. TinyHumans operates that service.
- **CortexDB engine:** stored in your own CortexDB account or self-hosted CortexDB, reached directly with your key. A CortexDB you run on your own machine keeps the data on that machine.
diff --git a/tests/memory_v2_e2e.rs b/tests/memory_v2_e2e.rs
index 05e0f09c75..939511b324 100644
--- a/tests/memory_v2_e2e.rs
+++ b/tests/memory_v2_e2e.rs
@@ -1025,6 +1025,41 @@ async fn erase_all_needs_confirmation_and_erases_the_whole_hosted_memory() {
)
.await;
assert_eq!(after["items"], json!([]), "{after}");
+ // Another account's memory is untouched, and a repeated erase is a no-op.
+ let second = f
+ .call(
+ "openhuman.auth_store_session",
+ json!({ "token": format!("{MOCK_TOKEN}-second"), "user_id": "second-user" }),
+ )
+ .await;
+ assert!(second.get("error").is_none(), "{second}");
+ f.learn("a fact that belongs to the second account").await;
+ f.relogin().await;
+ f.ok("openhuman.memory_erase_all", json!({ "confirm": true }))
+ .await;
+ let again = f
+ .ok(
+ "openhuman.memory_items_list",
+ json!({ "filter": { "kinds": ["learning"] } }),
+ )
+ .await;
+ assert_eq!(again["items"], json!([]), "{again}");
+ let second = f
+ .call(
+ "openhuman.auth_store_session",
+ json!({ "token": format!("{MOCK_TOKEN}-second"), "user_id": "second-user" }),
+ )
+ .await;
+ assert!(second.get("error").is_none(), "{second}");
+ let kept = f
+ .ok_until(
+ "openhuman.memory_items_list",
+ json!({ "filter": { "kinds": ["learning"] } }),
+ |v| !ids_of(v, "items").is_empty(),
+ )
+ .await;
+ assert_eq!(ids_of(&kept, "items").len(), 1, "{kept}");
+ f.relogin().await;
let docs_after = f
.ok(
"openhuman.memory_items_list",