Skip to content

Commit 96d4a70

Browse files
committed
Fix stale route table and a decorative test branch (CL-6288 review)
IMPLEMENTATION.md's route table and "register the three HTTP routes" sentence predated feed and now this PR's three retention routes — the package mounts seven. Added feed, forget, purge, and retention-class rows and corrected the sentence; also listed the optional retention plane methods alongside the existing transform ones. src/memory.test.ts's ownership-wiring fake sql branched on `text.includes("document_id")` with both arms returning an identical row — it read as distinguishing the document-owner and version-owner queries but did not. Dropped the branch; a comment explains real per-query scoping is covered separately in retention-ownership.test.ts.
1 parent 2c4d626 commit 96d4a70

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

‎IMPLEMENTATION.md‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,13 @@ surface, or a migrating host silently loses them.
633633
| `POST /api/tenants/:tenantId/memory/add` | `add` | `{ title, text, access_tags?, share? }` | `200 { documentId, versionId }`; `400` on validation |
634634
| `POST /api/tenants/:tenantId/memory/search` | `search` | `{ query, limit?, kinds?, entity_ids?, sources?, includeEvidence? }` (limit 1–50; `kinds`/`entity_ids`/`sources` narrow retrieval before fusion; unset or `[]` = unfiltered; `includeEvidence` adds a short evidence string when true) | `200 { items[], evidence?, degraded? }`; `400` on bad input |
635635
| `GET /api/tenants/:tenantId/memory/list` | `search` | query `?limit=` (1–100, string on the wire) | `200 { events: [{ at, title, source, tenantId, principalId }] }` — durable recent documents for the caller's scope, filtered with grant-tag access (`canAccessDocument`). One event per document (active live version). |
636+
| `GET /api/tenants/:tenantId/memory/feed` | `search` | query `?after=&limit=&exclude_generator=` | `200 { entries[], nextCursor }` — cursor pull of new live versions. See `docs/FEED.md`. |
637+
| `POST /api/tenants/:tenantId/memory/documents/:documentId/forget` | `forget` | `{ reason? }` | `200 { documentId, versions }`; `403` unless caller is the document's creator; `404` unknown document. Tombstones — content is redacted, not archived; see docs/RETENTION.md. |
638+
| `POST /api/tenants/:tenantId/memory/documents/:documentId/purge` | `purge` | none | `200 { documentId, deleted, reason? }`; `403` unless caller is the document's creator; `404` unknown document. Hard-deletes the row — irreversible; refused while a `durable` version is untombstoned. |
639+
| `POST /api/tenants/:tenantId/memory/versions/:versionId/retention-class` | `forget` | `{ retention_class }` | `200 { versionId, documentId, status }`; `400` invalid class; `403` unless caller is the version's creator; `404` unknown version. |
636640

637-
`registerMemoryRoutes` and `createMemory({ app })` register the three HTTP routes.
641+
`registerMemoryRoutes` and `createMemory({ app })` register these seven HTTP
642+
routes (add, search, list, feed, forget, purge, retention-class).
638643
Agent tools ship in this package as Interchange `defineTool` factories
639644
(`@corbits/memory/tools` / `interchange.tools`): thin HTTP clients that call the
640645
mounted routes with install env (`memoryBaseUrl`, `memoryTenantId`,
@@ -645,7 +650,10 @@ protection — the client has no default timeout. OpenAPI→MCP remains an optio
645650
host bridge. The plane surface is `add` / `search` / `list` / `close`, plus
646651
optional transform methods when backed by the engine DocumentStore
647652
(`createTransformConfig`, `listTransformConfigs`, `runTransform`,
648-
`promoteGeneration`, `demoteGeneration`). Inference stays on the host.
653+
`promoteGeneration`, `demoteGeneration`) and optional retention methods
654+
(`tombstoneDocument`, `hardDeleteDocument`, `setRetentionClass`,
655+
`sweepEphemeral`, `deprecateVersion`) — see docs/RETENTION.md. Inference stays
656+
on the host.
649657

650658
### Share materialization (CL-5873)
651659

‎src/memory.test.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -784,16 +784,20 @@ describe("retention writes — ownership gate (CL-6288)", () => {
784784
}),
785785
);
786786

787-
/** Only "doc-1" / "ver-1" exist, created by OWNER — everything else is a miss. */
787+
/**
788+
* Only "doc-1" / "ver-1" exist, created by OWNER — everything else is a
789+
* miss. resolveDocumentOwner and resolveVersionOwner both just need "a
790+
* creator row" here (their distinct WHERE clauses are unit-tested with
791+
* real scoping in retention-ownership.test.ts) so this fake does not
792+
* branch on query text — a branch whose arms return the same row proves
793+
* nothing and only invites the reader to assume a distinction that isn't
794+
* there.
795+
*/
788796
const sql = Object.assign(
789-
mock((strings: TemplateStringsArray, ...values: unknown[]) => {
790-
const text = strings.join("?");
797+
mock((_strings: TemplateStringsArray, ...values: unknown[]) => {
791798
const isMissing =
792799
values.includes("doc-missing") || values.includes("ver-missing");
793800
if (isMissing) return Promise.resolve([]);
794-
if (text.includes("document_id")) {
795-
return Promise.resolve([{ created_by_principal_id: OWNER }]);
796-
}
797801
return Promise.resolve([{ created_by_principal_id: OWNER }]);
798802
}),
799803
{

0 commit comments

Comments
 (0)