Skip to content

Feat/20 claude memory#21

Merged
artdaw merged 14 commits intomainfrom
feat/20_claude_memory
Apr 26, 2026
Merged

Feat/20 claude memory#21
artdaw merged 14 commits intomainfrom
feat/20_claude_memory

Conversation

@artdaw
Copy link
Copy Markdown
Owner

@artdaw artdaw commented Apr 26, 2026

Full pivot to v2

artdaw added 12 commits April 26, 2026 11:59
…on DSL

- Move kndl-memory-pack/kndl-memory-mcp/ → packages/kndl-memory/ (@kndl/memory 2.0.0-alpha.1)
- Move kndl-memory-pack/kndl-memory/ → skills/kndl-memory/ (drop-in Claude Skill bundle)
- Delete packages/python/, packages/mcp-server/ (Python DSL retired)
- Delete spec/ (SPECIFICATION.md and kndl.ebnf — no DSL = no grammar)
- Delete kndl-memory-pack/ wrapper directory
- CI: drop python + mcp-server jobs, add node-test job
- Build verified: dist/ generates clean, both binaries (kndl, kndl-memory-mcp) present
…ackends)

- src/types.ts: FactStore async interface (assertFact, supersedeFact, query,
  contradictions, provenanceChain, list, show, close)
- src/core.ts: pure logic only — decay math, time utils, fact construction,
  applyQuery, findContradictions, buildProvenanceChain (no FS/DB imports)
- src/stores/fs.ts: FsFactStore — filesystem backend (Anthropic Memory mount)
- src/stores/sqlite.ts: SqliteFactStore — better-sqlite3, WAL, indexed columns
- src/stores/duckdb.ts: DuckDbFactStore — @duckdb/node-api, columnar
- src/stores/supabase.ts: SupabaseFactStore — @supabase/supabase-js, RLS
- src/stores/index.ts: makeStore() factory dispatching on KNDL_STORAGE env var
- cli.ts + server.ts updated to use makeStore()
- tests/stores.test.ts: 25 tests across FsFactStore + SqliteFactStore on the
  loan-decision corpus (assertFact, list, query, contradictions, show,
  supersedeFact, provenanceChain) + decay math unit tests
- src/notify.ts:
  - NotifyingStore: wraps any FactStore, emits "change" EventEmitter events
    on every assertFact / supersedeFact call (in-process notification)
  - attachFsWatcher: chokidar watches facts/ dir for cross-process FS writes
  - attachSqlitePoller: polls kndl_changes table for cross-process SQLite writes
  - logSqliteChange: helper for SqliteFactStore to write change-log entries
  - SubscriptionRegistry: filter-based subscription map with matches() ranking

- server.ts:
  - Uses NotifyingStore; broadcasts notifications/resources/updated to all
    active sessions when a subscribed fact changes
  - New tools: subscribe, unsubscribe, list_subscriptions
  - New resource: kndl://fact/{id} — live snapshot with effective_confidence
  - --http flag: StreamableHTTPServerTransport on port $PORT (default 8000)
    with per-session transport map (fixes 406/400 errors)
  - stdio mode unchanged; both modes register activeSessions for broadcast
Each bundle exercises: confidence, decay, supersession, contradiction,
derivedFrom, and classification. All 42 facts pass JSON + Fact-shape validation.

loan-decision/  7 facts — credit score supersession, employment, financial distress
iot-sensor/     6 facts — temperature decay/supersession, occupancy, HVAC alert (derivedFrom)
personal-memory/ 5 facts — role supersession, PII classification, preference (derivedFrom)
threat-intel/   5 facts — IOC decay, false-positive retraction (negated), contradiction
clinical/       5 facts — PHI, diagnosis supersession, negated allergy, Rx (derivedFrom)
legal-ediscovery/ 4 facts — testimony supersession, contradicting witness, document auth
scientific-lab/ 5 facts — replicate measurements, outlier retraction, consensus (derivedFrom)
ai-evals/       5 facts — benchmark decay, regression contradiction, capability (derivedFrom)
- src/remote/types.ts: MemoryStoreItem, MemoryStoreClient interface,
  RemoteConfig, SyncResult — typed contracts for the remote layer
- src/remote/anthropic.ts:
  - AnthropicMemoryClient: REST client for Memory Stores beta API using
    fetch() (no SDK dep). Exponential backoff on 429/529. Pagination via
    cursor. NOTE: watch_memory_store deferred pending watermark verification
    (plan Q7 — if /since param confirmed, re-enable)
  - FakeMemoryStoreClient: in-process fake for tests; seed + paginate
- src/remote/sync.ts: pull() driver — translates Memory Store items to
  KNDL Facts; idempotent on source URI + content-hash tag; supersedes on
  content change; contradiction detection after each batch.
  push() → explicit NotImplementedError (v2.1)
- src/remote/config.ts: ~/.kndl/remotes.json read/write; KNDL_REMOTE_STORES
  env var shorthand; addRemote / removeRemote / getRemote helpers
- src/types.ts: add tags?: string[] to FactInput
- src/core.ts: buildFact now copies input.tags onto the Fact
- server.ts: sync_memory_store + list_memory_stores tools (gated on
  ANTHROPIC_API_KEY); watch_memory_store NOT shipped (pending Q7)
- cli.ts: kndl remote add|pull|ls|rm subcommand
- tests/remote.test.ts: 11 loopback tests using FakeMemoryStoreClient —
  no real API calls; covers pull, idempotency, supersession on change,
  push stub, pagination, SQLite backend
…aceholder)

eval/questions.json (rewritten):
  - 33 binary-scored questions across 8 domains × 7 archetypes
  - 8 cross-domain (loan-decision, unchanged from v1)
  - 4 IoT sensor, 3 personal-memory, 4 threat-intel, 4 clinical,
    3 legal-ediscovery, 3 scientific-lab, 3 ai-evals
  - 1 cross-runtime (manual; requires watch_memory_store + managed agent)
  - Threshold: ≥70% KNDL beats vanilla required to ship v2.0

eval/runner.ts:
  - Drives Claude in vanilla mode (facts in system prompt)
  - Claude-as-judge auto-scores each answer binary PASS/FAIL
  - Outputs results.json with pass rate, per-archetype breakdown, verdict
  - MCP mode documented but deferred (requires running server during eval)
  - Run: ANTHROPIC_API_KEY=... tsx eval/runner.ts [--scenario <id>] [--out <path>]

eval/results.json: placeholder; populated by running eval/runner.ts
Route changes (v2.md §9):
  Deleted: /spec, /spec/full, /workflow (SpecPage, SpecFullPage, WorkflowPage)
  New:     /protocol, /skill, /examples, /eval
  Rebuilt: /explorer (fact bundle viewer), / (landing), /mcp (TS install)
  Redirects: /spec → /protocol, /spec/full → /protocol, /workflow → /skill

New pages:
  ProtocolPage  — annotated Fact shape, 21-field reference, decay formula
  SkillPage     — 6 workflow steps, trust thresholds, reasoning rules, decay table
  ExamplesPage  — 8 domain cards with fact counts and feature badges
  EvalPage      — scoreboard (NOT_RUN state + results state)

Rebuilt pages:
  ExplorerPage  — domain selector, fact cards, effective-confidence bar,
                  supersession greying, SPO rows, classification badges
  LandingPage   — WHERE/WHAT/HOW three-layer model, problem statement,
                  fact code block, 6 pillars, 6 use cases, CTA row
  McpPage       — @kndl/memory TypeScript install, 9 tools, remote sync CLI

Data:
  src/data/examples.ts — all 42 facts across 8 domains embedded as TS constants

Infra:
  Nav updated (7 links), sitemap.xml (7 routes), llms.txt rewritten
  Build: 367KB JS / 112KB gzip, 6 prerendered route shells
… release

Migration tool (kndl migrate):
  - Reads v1 SQLite database (kndl_nodes/kndl_edges/kndl_intents)
  - Maps each Node → Fact (subject=node:id, predicate=isa, object=type_name)
  - Maps each Edge → Fact (subject=source, predicate=edge_type, object=target)
  - Maps each Intent → Fact (@type=Action)
  - --dry-run flag for preview; idempotent (skips existing files)
  - kndl migrate --from sqlite:./kndl-v1.db --to ./memory

Schema publish:
  - website/public/context/v1.jsonld — JSON-LD context (served at /context/v1.jsonld)
  - website/public/schema/fact.schema.json — JSON Schema for Fact (21 fields, full descriptions)

Package: @kndl/memory bumped to 2.0.0

README: full rewrite — mental model, fact shape, install, MCP tools table,
  storage backends, migration, repo layout, eval quality bar

Devils_Advocate.md: v2 retro section — phase-by-phase verdict,
  resolved/partial/open weak point audit, one-line conclusion
…lish

MCP server / build:
  - server.ts: restore .js extensions on @modelcontextprotocol/sdk imports
    (linter stripped them; Node.js ESM requires exact extensions for externals)
  - stores/index.ts: static import FsFactStore + SqliteFactStore so tsup
    bundles them inline — fixes ERR_MODULE_NOT_FOUND from hashed chunk names
    (duckdb/supabase remain lazily required, they are optional packages)

Eval runner:
  - Fix flag parser: indexOf(-1)+1=0 read args[0] as scenarioFilter="--out",
    causing 0 scenarios to match and verdict FAIL with 0 questions evaluated
  - Default model: claude-opus-4-5-20251001 (nonexistent) → claude-sonnet-4-6

AI evals example:
  - Replace GPT-5/OpenAI facts with Claude 4 family facts
    (Sonnet 4.5, Sonnet 4.6 1M, Opus 4.7 — supersession + regression + derivedFrom)

Website:
  - ExplorerPage: force-directed graph view; Cards/Graph toggle; drag nodes;
    click to show node detail panel (mobile: slides up from bottom)
  - ExplorerPage: mobile optimisation — toolbar stacks, domainSelect stretches,
    node detail becomes bottom sheet on ≤680px, stats hidden on ≤420px
  - ExamplesPage: whole card is now a Link (not just "Explore →" button)
  - LandingPage: use case cards redesigned with SVG icons + tag badges + "Explore in graph →"
  - LandingPage: CTA cards redesigned with SVG icons, colour-coded by section,
    richer description line, "Go →" explicit action
  - McpPage: corrected tool list (11 not 9), correct storage backends
    (fs/sqlite/duckdb/supabase — no postgres), correct HTTP port (8000 not 7654),
    correct install path, correct remote sync CLI syntax
  - SkillPage: numbered 2-step install section (CLI first, then skill bundle);
    SKILL.md fixes applied (KNDL_STORAGE env var, correct build commands, npx removed)
  - EvalPage: runtime fetch of /eval/results.json instead of static import;
    loading spinner + error card; threshold marker on pass bar;
    NOT_RUN instructions now say "run the runner, redeploy" — no code editing needed

Makefile: kndl-eval writes to website/public/eval/results.json; publish-eval target
SKILL.md: correct setup (pnpm build + npm link), KNDL_STORAGE, bare kndl commands
Nav (all pages):
  - Hamburger menu on ≤680px: 7 links collapse behind animated burger button
  - Full-width drawer with active-link highlight; closes on tap
  - Desktop layout unchanged

Mobile CSS (all pages, ≤680px breakpoint):
  - ProtocolPage: container padding 16px, pre font 11px, table cells tighter
  - McpPage: storageTable collapses to 1-col, storageWhen badge hidden,
    archGrid 1-col, toolRow stacks, layerPills wrap
  - EvalPage: summaryGrid stacks vertically, qArchetype column hidden on mobile,
    notRunCard padding reduced
  - SkillPage: installStep stacks (number above body), downloadCard stacks,
    installCode font 11px
  - ExamplesPage: container padding 16px, cardDesc smaller font
  - LandingPage: heroLogo 36px on 420px, ctaRow 1-col, factCode overflow-x auto
  - ExplorerPage: existing fixes kept (toolbar, nodeDetail bottom sheet)

OG / social meta:
  - index.html: all v1 text replaced with v2 ("The Format Anthropic Memory Was
    Waiting For"); og:image:height corrected 864→860; og:image:alt + twitter:image:alt
    added; removed dead links (spec/SPECIFICATION.md, kndl.ebnf, llms-full.txt);
    JSON-LD updated — SoftwareSourceCode→SoftwareApplication, TechArticle for
    deleted /spec/full removed; noscript updated to v2 three-layer mental model
  - SEO.tsx: softwareSourceCodeSchema updated to SoftwareApplication with v2 desc
  - kndl.png: confirmed 1860×860, served correctly for both root and website

README.md:
  - Full rewrite: centered banner image + badges at top; hook paragraph before
    any technical detail; "Get started in 60 seconds" as first section;
    Why-not-markdown table with aligned columns; complete CLI workflow example;
    HTTP server + Goose/LM Studio multi-agent configs; repo layout tree
- Appendix A: full strategic analysis (pre-pivot devil's advocate) with
  v2 outcome annotations on each weak point, competitor table, alternative
  paths, and use-case domain ranking
- Appendix B: v2 retro — what the plan said vs. what shipped, resolved/
  open/partial breakdown, one-line verdict
- §13 cross-reference updated: Devils_Advocate.md → Appendix A
- Devils_Advocate.md deleted (content lives in v2.md)
@artdaw artdaw self-assigned this Apr 26, 2026
@artdaw artdaw added the 🚀 feature New feature or request label Apr 26, 2026
@artdaw artdaw merged commit 8e488ec into main Apr 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚀 feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant