Skip to content

feat(history): memory entry history, snapshots, and rollback and test(integration) dual framework tests and docs(api) added API documentation - #1

Merged
KB-perByte merged 6 commits into
KB-perByte:mainfrom
tyraziel:memory-history-subsystem
Jul 25, 2026
Merged

Conversation

@tyraziel

@tyraziel tyraziel commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add trigger-based memory_entries_history table that captures every content,
    embedding, and delete mutation on memory_entries — view counter flushes and
    reuse increments are excluded
  • Add hiveshare snapshots; restore creates a new hiveshare from the snapshot,
    leaving the original untouched
  • Add entry copy endpoint for rollforward merges between hiveshares
  • Per-entry rollback restores embedding from history when available, only
    enqueues a re-embed job when the history embedding is NULL
  • Per-entry undelete re-inserts a deleted entry from its history record
  • Migration backfills existing entries into the history table on upgrade
  • Optional retention via HISTORY_TTL_DAYS and HISTORY_MAX_VERSIONS env vars
    (default 0 = keep forever)
  • Add equivalent pytest and bash/curl integration test suites across all
    subsystems (auth, hiveshare, memory, metrics, history, infrastructure)
  • Add make targets: smoke-test, smoke-test-full, integration-test, dev-clean
  • Support CONTAINER_RUNTIME variable (default docker) for podman users
  • Migrate target falls back to container exec when psql is not installed locally
  • Add CLAUDE.md with testing and build conventions
  • Surface area is API + CLI only (no MCP tools)
  • Add API.md documenting all 24 endpoints with inputs, outputs, status codes,
    and curl examples
  • Add scripts/test-api-examples.sh verifying every curl example (92 checks)
  • Add make psql target for interactive database access via container
  • Add CLAUDE.md with project guidelines, testing tenets, and build conventions

New endpoints

Method Path Description
GET /hiveshares/{id}/memory/{entryId}/history List entry versions
POST /hiveshares/{id}/memory/{entryId}/rollback Rollback to a version
POST /hiveshares/{id}/memory/undelete Restore a deleted entry
POST /hiveshares/{id}/memory/copy Copy entries between hiveshares
POST /hiveshares/{id}/snapshots Create snapshot
GET /hiveshares/{id}/snapshots List snapshots
GET /hiveshares/{id}/snapshots/{snapshotId} Get snapshot detail
POST /hiveshares/{id}/snapshots/{snapshotId}/restore Restore to new hiveshare
DELETE /hiveshares/{id}/snapshots/{snapshotId} Delete snapshot

Test plan

  • make smoke-test — 9 checks, 0 failed
  • make smoke-test-full — 6 suites, 106 checks, 0 failed
  • make integration-test — 41 tests, 0 failed
  • Verify HISTORY_TTL_DAYS and HISTORY_MAX_VERSIONS purge old history rows
  • Test with CONTAINER_RUNTIME=podman
  • ./scripts/test-api-examples.sh — 92 checks, 0 failed

Generated with AI assistance: Claude Code / Opus 4.6 (Anthropic)

tyraziel added 3 commits July 22, 2026 16:19
  Add trigger-based history tracking for memory entries, hiveshare
  snapshots with restore-to-new-hiveshare, and entry copy for
  rollforward merges.

  - migration 005: history table with embedding column, trigger on
    content/summary/tags/metadata/embedding changes and deletes,
    snapshot and snapshot_entries tables
  - HistoryStore with rollback, undelete, snapshot CRUD, restore,
    copy, and configurable purge (HISTORY_TTL_DAYS, HISTORY_MAX_VERSIONS)
  - 9 new API endpoints and 9 new CLI commands
  - rollback restores embedding from history when available, only
    enqueues re-embed job when history embedding is NULL

  Assisted-by: Claude Code / Opus 4.6 (Anthropic)
Ensure pre-migration entries have a baseline history row so they
can be rolled back or included in snapshots. Uses WHERE NOT EXISTS
guard for idempotency.

Assisted-by: Claude Code / Opus 4.6 (Anthropic)
…INER_RUNTIME

  Add pytest (tests/) and bash/curl (scripts/smoke-test-*.sh) integration
  tests with equivalent coverage across auth, hiveshare, memory, metrics,
  history, and infrastructure subsystems. Bash harness auto-discovers
  smoke-test-*.sh scripts. Both frameworks use unique timestamped users
  for re-runnability without a fresh database.

  Add make targets: smoke-test, smoke-test-full, integration-test, and
  dev-clean. Support CONTAINER_RUNTIME variable (default docker) for
  podman users. Migrate target falls back to container exec when psql
  is not installed locally.

  Assisted-by: Claude Code / Opus 4.6 (Anthropic)
@tyraziel tyraziel changed the title feat(history): memory entry history, snapshots, and rollback feat(history): memory entry history, snapshots, and rollback and test(integration) dual framework tests Jul 23, 2026
@tyraziel tyraziel changed the title feat(history): memory entry history, snapshots, and rollback and test(integration) dual framework tests feat(history): memory entry history, snapshots, and rollback and test(integration) dual framework tests and docs(api) added API documentation Jul 24, 2026
@tyraziel
tyraziel marked this pull request as ready for review July 24, 2026 15:35
  Document all 24 endpoints with inputs, outputs, status codes, and
  curl examples. Add scripts/test-api-examples.sh to verify every
  example against the running server (92 checks). Add make psql target
  for interactive database access.

  Assisted-by: Claude Code / Opus 4.6 (Anthropic)
@tyraziel
tyraziel force-pushed the memory-history-subsystem branch from 86843b7 to be31e92 Compare July 24, 2026 15:42
KB-perByte and others added 2 commits July 25, 2026 16:25
Rebase history subsystem onto memory→hive rename (006 migration, /hives
routes). Fix copy IDOR, snapshot restore ownership, source_ref conflicts,
purge-by-age, and delete-snapshot status codes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@KB-perByte

Copy link
Copy Markdown
Owner

@tyraziel I like the changes in this PR, added a couple of things based on our upstream.
I am getting this in. Planning to have fun with snapshots at this point.. I would love to find a better name that suits the hiveshare(tool) - hive (brain) terminology!

Cheers and thanks for the contribution.

@KB-perByte
KB-perByte merged commit 4e937fa into KB-perByte:main Jul 25, 2026
2 checks passed
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.

2 participants