Skip to content

feat(api,ui): v15 β€” analogical reasoning + memory health dock tabs - #42

Merged
wesleyscholl merged 1 commit into
mainfrom
claude/kohaku-live-web-ui-56i7je
Jun 22, 2026
Merged

feat(api,ui): v15 β€” analogical reasoning + memory health dock tabs#42
wesleyscholl merged 1 commit into
mainfrom
claude/kohaku-live-web-ui-56i7je

Conversation

@konjoinfinity

Copy link
Copy Markdown
Contributor

Summary

  • 5 new API endpoints wiring AnalogicalMemory into the REST surface
    • POST /analogy/extract β€” prose β†’ triples (pure parse, no store)
    • POST /analogy/learn β€” extract + fold triples into subject records
    • POST /analogy/get β€” attribute query: get(record, attr) β†’ cleaned-up value + confidence
    • POST /analogy/transfer β€” A:B::C:? Kanerva (2010) analogical transfer via VSA algebra
    • GET /analogy/records β€” list known subject record names
  • 9 new API tests β€” 73 total passing
  • "Analogy" dock tab β€” the HDC-native capability no vector DB can match
    • Left: prose textarea β†’ Extract (parse only) or Learn (store) β†’ animated triple rows with subject/attribute/value/confidence
    • Right top: attribute lookup β€” record name + attribute β†’ cleaned-up answer with ranked candidates
    • Right bottom: A:B::C:? live-preview equation box (inputs update the display as you type) β†’ Transfer resolves D with confidence + runner-ups
  • "Health" dock tab β€” live memory diagnostics
    • Animated SVG arc gauge (green/amber/rose by score)
    • 2Γ—2 stat grid: total / stale / expired / duplicates
    • Recommendations list
    • Preview stale / Delete stale buttons with dry-run support

Test plan

  • python -m pytest api/test_api.py -q β†’ 73 passed
  • ruff check api/main.py api/test_api.py β†’ clean
  • Open /live β†’ "Analogy" and "Health" tabs visible in dock
  • Paste "The capital of France is Paris. The currency of France is euro." β†’ Extract β†’ triples animate in
  • Click Learn β†’ toast confirms, record count increments
  • Attribute query: name=France, attribute=capital β†’ "Paris" with confidence
  • Transfer: source=France, target=Germany, value=euro β†’ transfers to mark
  • Health tab: gauge animates to score, stale/dupe counts populate
  • Preview stale: reports count without deleting; Delete stale: gauge refreshes

πŸ€– Generated with Claude Code


Generated by Claude Code

Backend (api/main.py):
- AnalogicalMemory wired into RestState
- POST /analogy/extract β€” prose β†’ triples (no-store, pure parse)
- POST /analogy/learn  β€” extract + fold triples into AnalogicalMemory
- POST /analogy/get    β€” attribute query: get(record, attr) β†’ AnalogyResult
- POST /analogy/transfer β€” A:B::C:? Kanerva (2010) analogical transfer
- GET  /analogy/records  β€” list known subject records

Tests (api/test_api.py): 9 new tests for analogy endpoints; 73 total passing

UI (demo/kohaku-live.html):
- New "Analogy" dock tab:
  Β· Left: prose textarea β†’ Extract (parse only) / Learn (store) buttons;
    animated triple rows (subject Β· .attribute = value Β· confidence%)
  Β· Right top: attribute query (record + attr β†’ cleaned-up value with
    ranked candidates)
  Β· Right bottom: A:B::C:? live-preview equation box, inputs update
    the display as you type; Transfer button resolves D and shows
    confidence + runner-up candidates
- New "Health" dock tab:
  Β· Animated SVG arc gauge (green/amber/rose by score threshold)
  Β· 2Γ—2 stat grid: total / stale / expired / duplicates
  Β· Recommendations list with β—† bullets
  Β· Preview stale / Delete stale buttons with dry-run support
  Β· switchTab wired: analogy β†’ analogyRefreshRecords(), health β†’ healthLoad()
@wesleyscholl
wesleyscholl marked this pull request as ready for review June 22, 2026 23:21
@wesleyscholl
wesleyscholl merged commit 37e676d into main Jun 22, 2026
8 checks passed
@wesleyscholl
wesleyscholl deleted the claude/kohaku-live-web-ui-56i7je branch June 22, 2026 23:21
konjoinfinity pushed a commit that referenced this pull request Jun 22, 2026
…posed modules

main (#42) added the analogical-memory feature to the OLD monolithic api/main.py
+ api/test_api.py, which this branch had decomposed. Resolution: keep the
decomposition and port #42's purely-additive changes into the new structure β€”
- 9 analogy pydantic models β†’ api/models.py
- RestState.analogy (AnalogicalMemory) β†’ api/_helpers.py (+ conftest reset)
- 5 /analogy/* routes β†’ new api/routers/analogy.py (register(app, ctx)),
  wired in create_app between episodes and agents (original order preserved)
- analogy tests β†’ new api/test_analogy_api.py (test_api.py stays deleted)

Verified: 0 files >500L repo-wide; api suite 78 passed (only the pre-existing
env-only test_health rust-accel assertion fails); ruff check/format clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants