Browse the documentation
Memory Field (ADR-018) Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Ship a shared, deterministic memory-field primitive (constellation + pipeline) that vidoxlabs.dev renders at build time and ViWeb renders at runtime, with the same look from one source.
Architecture: Follows the ADR-013 stage precedent. lib/memory-field.js is pure (layout, SVG, text equivalent, contrast report, pipeline SVG); lib/memory-field.css carries every visual and the four motions from emitted tokens; npm run tokens ships both to dist/; the MCP tool memory_field returns SVG plus report; dist/standard.json carries rules.memoryField.
Tech Stack: Node (CommonJS, node:test), SVG, CSS (tokens via --vi-colors-*), MCP stdio server.
Spec: SKILL.md § ADR-018 (written in Task 1). Design approved in session 2026-11-18 (sections 1 and 2; sections 3 to 5 written into the ADR on the owner’s instruction to keep going).
Global Constraints
- Animated properties:
transformandopacityonly (ADR-008). Nostroke-dashoffsetanimation. - Durations and easings come from tokens: 150/200/300/500ms, ambient drift 32s, pulse 6s.
- Every motion renders its final state under
prefers-reduced-motion: reduceand under[data-motion="paused"]on the root (WCAG 2.2.2). - No inline
styleattribute in emitted SVG; colour from classes only (style-src 'self'). - Meaningful (lit) lines reach ≥ 3:1 on every surface of their theme (WCAG 1.4.11, ADR-013 item 4). Rest edges are
aria-hidden. - Link tokens stay ≥ 15 ΔE00 from every persona and status hex and ≥ 20 ΔE00 from each other.
- No persona colour marks a link type (ADR-004, ADR-017 item 8). Never colour alone: each code also has a dash or marker and a text label.
- Deterministic: no
Math.random, no clock. Same input and seed give byte-identical output. - Budget: ≤ 300 nodes and ≤ 3,000 edges, else typed error
MEMORY_FIELD_OVER_BUDGET.
File Structure
- Modify
DESIGN.md: eightborder-graph-{cluster,reasoned,linked,tree}-{base,light}colour tokens. - Modify
SKILL.md: ADR-018 record. - Create
lib/memory-field.js: constants,layoutMemoryField,renderMemoryFieldSvg,renderMemoryFieldTable,memoryFieldContrastReport,renderMemoryPipelineSvg. - Create
lib/memory-field.css: link, node and state styling; the four motions. - Create
test/memory-field.test.js. - Modify
scripts/generate-tokens.js(emitdist/memory-field.css,dist/memory-field-sample.svg,dist/memory-pipeline-sample.svg),scripts/generate-standard.js(rules.memoryField),mcp-server.js(memory_fieldtool),package.jsontest list if needed. - Create
scripts/generate-memory-field-fragment.jsand generatedpreview/memory-field.html,preview/memory-pipeline.html; register them inpreview/index.html. - Modify
AGENTS.md: list the primitive and tool.
Task 1: Tokens and ADR-018 record
Files: Modify DESIGN.md, SKILL.md; Test test/memory-field.test.js (token section).
Produces: tokens border-graph-cluster-base #5EEAD4, -light #0F766E; border-graph-reasoned-base #FDE047, -light #854D0E; border-graph-linked-base #60A5FA, -light #0369A1; border-graph-tree-base #FECDD3, -light #86198F.
- Write failing tests: each base token ≥ 3:1 on the three dark surfaces, each light token ≥ 3:1 on the three light surfaces; ΔE00 ≥ 15 to every persona/status hex; pairwise ≥ 20.
- Run
node --test test/memory-field.test.js; expect FAIL (tokens missing). - Add tokens to
DESIGN.mdbesideborder-graph-line-*; write ADR-018 inSKILL.md. - Run
npm run tokens && npm test; expect PASS (fix any token-contract tests that enumerate colours). - Commit
Add ADR-018 memory field and the four graph link tokens.
Task 2: Deterministic layout
Produces: layoutMemoryField(data, { seed = 1, width = 960, height = 600, iterations = 240 }) -> { width, height, nodes: [{ id, label, cls, group, href, x, y, r, band }], edges: [{ id, source, target, code, count, x1, y1, x2, y2, cx, cy, length, angle }], synthetic }. Throws MemoryFieldError with code MEMORY_FIELD_OVER_BUDGET or MEMORY_FIELD_INVALID.
- Tests: identical output for identical input (JSON equal) and for shuffled-free reruns; different seed changes positions; all nodes inside bounds minus radius; unknown edge endpoint →
MEMORY_FIELD_INVALID; unknown code/class →MEMORY_FIELD_INVALID; 301 nodes →MEMORY_FIELD_OVER_BUDGET; radius steps are exactly the threeNODE_RADII; band fromlastRecalledAtrelative tonowinput (no clock). - Implement mulberry32 PRNG, group ring seeding, fixed-step force relaxation (repulsion, edge spring, group gravity, centre gravity, cooling), clamp, round to 0.1.
- Commit.
Task 3: SVG, text equivalent, contrast report
Produces: renderMemoryFieldSvg(layout, { title, desc, focus = null }) string; renderMemoryFieldTable(layout) HTML string; memoryFieldContrastReport(tokens, { theme = 'base' }) → { theme, minContrast, links: { CR: { token, value, worst, surfaces } ... }, pass }.
- Tests: SVG has
role="group",<title>/<desc>, a rest layer witharia-hidden="true", nostyle=attribute, every node carriesdata-class/data-band, every lit edge carriesdata-code; focus marks lit/dim states;synthetic: trueprints the synthetic caption; table lists every node with links grouped by code label; report passes for both themes and fails when a token is swapped for the hairline. - Implement.
- Commit.
Task 4: Stylesheet and the four motions
Files: lib/memory-field.css.
- Tests (parse CSS text): every
@keyframesonly touchestransform/opacity; every link code maps to its--vi-colors-border-graph-*variable; light theme block remaps under[data-theme="light"]; aprefers-reduced-motion: reduceblock and a[data-motion="paused"]block setanimation: none; no hex literals. - Implement motions: entrance draw-in (
scaleXon lit edge lines, node fade by band), recall pulse (data-state="recalling": a pulse dot translated along each lit edge, then non-hits dim), Forget retraction (data-state="forgetting": edgesscaleXto 0 toward the node, node fades), ambient drift (.vi-mf--ambientslow translate of the rest layer on the drift token) and pipeline flow (pulse dots translating along pipeline connectors on the pulse token). - Commit.
Task 5: Pipeline renderer
Produces: renderMemoryPipelineSvg(spec, { title, desc }) where spec = { width, height, groups: [{ id, label, x, y, w, h }], stages: [{ id, label, sub, x, y, w, h, kind: 'store' | 'step' }], flows: [{ from, to, label, code? }] }; SAMPLE_PIPELINE (the Vidoxlabs memory architecture, synthetic-free: names real components only).
- Tests: deterministic; stores render cylinder paths, steps render rounded rects; every flow has an arrow marker, a pulse element and a text label; unknown stage id →
MEMORY_FIELD_INVALID; nostyle=. - Implement.
- Commit.
Task 6: Distribution
-
generate-tokens.jsemitsmemory-field.cssand the two sample SVGs; extend the token test that lists dist outputs. -
generate-standard.jsaddsrules.memoryField(codes, tokens, budget, motions, stopsUnder) and an ADR-018 section instandard.md;test/standard.test.jsasserts parity. -
mcp-server.jsaddsmemory_field(input:data,seed,width,height,theme,includeSvg; output: report + svg + table); MCP smoke test lists it. - Generated fragments
preview/memory-field.html,preview/memory-pipeline.html; catalog entry;npm run lintpasses. -
AGENTS.mdlists the primitive and tool. - Run
npm run tokens && npm run lint && npm test; commit; push branch; open draft PR stacked onfeat/adr-014-conversation-surface.