Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ Design: `docs/superpowers/specs/2026-11-22-memory-claims-design.md` and
filters (tags or tags_all required) oldest first, capped at `GRAPH_MAX_NODES` (400) or `GRAPH_FULL_MAX_NODES` (100) for
full content, with `count(*) over ()` as `total`, then reads `memory_links` between those ids (the links policy hides
unreadable or deleted ends), the superseded set, and the batched claims. No decay and no `touch_accessed`.
`withUpdatedAt` adds each node's `updatedAt`; only `web-api` asks for it (the browser's diff needs it to see an edit
past the snippet), so the MCP tool's output stays as it was.

**Blackboard skill.** `skills/blackboard/` is a Claude Code skill, made of instructions only, that runs shared-goal
boards on these tools: graph, claim_next, claims, links and search browse. It has no server code of its own. The design
Expand Down
3 changes: 2 additions & 1 deletion supabase/functions/_shared/pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ export class PgMemoryStore implements MemoryStore {
const scopeIds = await this.resolveScopeIds(tx, f.scopes);
if (scopeIds.length === 0) return { nodes: [], edges: [], truncated: false, total: 0 };
const rows = await tx<Row[]>`
select id, scope, category, tags, content, created_at, count(*) over () as total
select id, scope, category, tags, content, created_at, updated_at, count(*) over () as total
from agent_memory.memory_view
where scope_id = any(${scopeIds}::uuid[])
and (${f.category ?? null}::text is null or category = ${f.category ?? null}::text)
Expand All @@ -639,6 +639,7 @@ export class PgMemoryStore implements MemoryStore {
tags: r.tags,
createdAt: iso(r.created_at),
};
if (f.withUpdatedAt) n.updatedAt = iso(r.updated_at);
if (full) n.content = r.content;
else n.snippet = snippet(r.content, GRAPH_SNIPPET_CHARS);
return n;
Expand Down
3 changes: 3 additions & 0 deletions supabase/functions/_shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export interface GraphFilters {
tagsAll?: string[];
/** 'short' (default): a snippet per node; 'full': the whole content, with a lower node cap. */
detail?: 'short' | 'full';
/** Give each node its `updatedAt`, so a caller that polls sees a content edit past the snippet (the web UI). */
withUpdatedAt?: boolean;
}

export interface GraphNode {
Expand All @@ -123,6 +125,7 @@ export interface GraphNode {
category: MemoryCategory;
tags: string[];
createdAt: string;
updatedAt?: string;
snippet?: string;
content?: string;
superseded?: true;
Expand Down
2 changes: 2 additions & 0 deletions supabase/functions/_shared/web-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ export async function routeWebApi(req: Request, store: WebStore): Promise<Respon
tagsAll,
scopes: list(p, 'scope'),
detail: detail as 'short' | 'full' | undefined,
// The browser re-reads a goal or progress memory when this moves: an edit past the snippet changes nothing else.
withUpdatedAt: true,
})),
);
}
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/pg-store-graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ Deno.test('graph returns matching nodes oldest first with every link among them'
assertEquals([n.scope, n.category, n.snippet, n.content], [w.alpha.name, 'other', 'intent', undefined]);
assertEquals(n.tags.includes('kind:intent'), true);
assertEquals(typeof n.createdAt, 'string');
assertEquals(n.updatedAt, undefined);
}));

Deno.test('graph gives updatedAt only when asked, and it moves when the content changes', () =>
withWorld(async (w, _a, mk) => {
const s = mk(w.rw.id);
const tag = freshTag();
// The limit line sits past the snippet, so only updatedAt shows the edit.
const head = `Goal: ${'x'.repeat(200)}`;
const goal = await s.store(w.alpha.name, req(`${head}\nMax intents: 20`, [tag, 'kind:goal']));
const before = (await s.graph({ tagsAll: [tag], withUpdatedAt: true })).nodes[0];
assertEquals(before.updatedAt, goal.updatedAt);
await s.update(goal.id, { content: `${head}\nMax intents: 30` });
const after = (await s.graph({ tagsAll: [tag], withUpdatedAt: true })).nodes[0];
assertEquals(after.snippet, before.snippet);
assertEquals(typeof after.updatedAt, 'string');
assertEquals(after.updatedAt !== before.updatedAt, true);
}));

Deno.test('graph short gives 160-character snippets; full gives content and caps at 100', () =>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/web-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Deno.test('GET /graph requires tags_all and passes the filters', async () => {
assertEquals(await r.json(), EMPTY_GRAPH);
assertEquals(s.calls, [{
fn: 'graph',
args: [{ tagsAll: ['board:x', 'kind:goal'], scopes: ['a'], detail: 'full' }],
args: [{ tagsAll: ['board:x', 'kind:goal'], scopes: ['a'], detail: 'full', withUpdatedAt: true }],
}]);
});

Expand Down
9 changes: 9 additions & 0 deletions tests/unit/web-public.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Deno.test('workerLabel falls back to the claim session, then the claim descripti

type Node = {
id: string;
updatedAt?: string;
scope: string;
category: string;
tags: string[];
Expand Down Expand Up @@ -155,6 +156,14 @@ Deno.test('diffGraph sees tags, snippet and superseded changes', () => {
assertEquals(diffGraph(prev, next).changed, ['a', 'b', 'c']);
});

Deno.test('diffGraph sees a content edit below the snippet through updatedAt', () => {
const at = '2026-01-01T00:00:00.000Z';
const prev = graph(node('a', { updatedAt: at }), node('b'));
const next = graph(node('a', { updatedAt: '2026-01-01T00:00:05.000Z' }), node('b'));
assertEquals(diffGraph(prev, next).changed, ['a']);
assertEquals(diffGraph(prev, graph(node('a', { updatedAt: at }), node('b'))).changed, []);
});

Deno.test('diffGraph sees a claim appear, disappear or move', () => {
const claim = { by: 'me', until: null, description: 'd', session: { id: '1', label: 'w1' } };
assertEquals(diffGraph(graph(node('a')), graph(node('a', { claim }))).changed, ['a']);
Expand Down
12 changes: 10 additions & 2 deletions web/public/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* id: string;
* tags: string[];
* snippet?: string;
* updatedAt?: string;
* superseded?: true;
* claim?: Claim;
* }} GraphNode
Expand All @@ -28,11 +29,18 @@ function claimKey(c) {
* @returns {string}
*/
function nodeKey(n) {
return JSON.stringify([[...n.tags].sort(), n.snippet ?? null, n.superseded === true, claimKey(n.claim)]);
return JSON.stringify([
[...n.tags].sort(),
n.snippet ?? null,
n.updatedAt ?? null,
n.superseded === true,
claimKey(n.claim),
]);
}

/**
* Which node ids appeared, vanished or changed (tags, snippet, superseded or the whole claim) between two graphs.
* Which node ids appeared, vanished or changed (tags, snippet, updatedAt, superseded or the whole claim) between two
* graphs. updatedAt is what shows an edit past the snippet, such as the goal's `Max intents:` line.
* @param {GraphResult | null} prev
* @param {GraphResult} next
* @returns {{ added: string[]; removed: string[]; changed: string[] }}
Expand Down
Loading