Skip to content

feat(memory): add semantic maintenance API - #638

Merged
delete-cloud merged 1 commit into
mainfrom
feat/semantic-memory-maintenance-surface
Jun 27, 2026
Merged

delete-cloud merged 1 commit into
mainfrom
feat/semantic-memory-maintenance-surface

Conversation

@delete-cloud

@delete-cloud delete-cloud commented Jun 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add admin-only semantic memory maintenance status/rebuild endpoints
  • route destructive rebuild through SessionManager and runtime maintenance admission fencing
  • document the HTTP maintenance authority boundary in ADR-0072 and add a task packet
  • cover admin auth, active-turn fencing, disabled semantic memory, missing TopicStore, owner conflict, and schema validation

Verification

  • uv run ruff format --check src/coding_agent/server/schemas.py src/coding_agent/server/http_server.py src/coding_agent/server/session_manager.py tests/ui/test_http_server.py tests/ui/test_session_manager_runtime.py && uv run ruff check src/coding_agent/server/schemas.py src/coding_agent/server/http_server.py src/coding_agent/server/session_manager.py tests/ui/test_http_server.py tests/ui/test_session_manager_runtime.py
  • uv run pytest tests/coding_agent/test_semantic_maintenance.py tests/ui/test_session_manager_runtime.py -k "semantic" -v
  • uv run pytest tests/ui/test_http_server.py -k "SemanticMemoryMaintenance or MemoryReviewTransitions" -v
  • git diff --check

Review Gate

  • design reviewed by subagents until no P0/P1 findings
  • implementation reviewed by subagent: no P1/P2 findings

Summary by CodeRabbit

  • New Features

    • Added admin-only semantic memory status and rebuild controls for sessions.
    • Rebuild now returns a clear report and supports explicit validation options.
  • Bug Fixes

    • Prevents destructive rebuilds while a session is active or when ownership conflicts occur.
    • Returns clearer conflict and not-found responses for disabled or unavailable session memory.
    • Ensures status checks do not modify stored data.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d1db608d-cf16-4318-ba0f-86b5f23ad0da

📥 Commits

Reviewing files that changed from the base of the PR and between 55fd2b2 and d0e866b.

📒 Files selected for processing (7)
  • coding-agent/.opencode/prompts/tasks/semantic-memory-maintenance-surface-task-packet.md
  • coding-agent/docs/adr/0072-tape-memory-semantic-index-and-enable-switch.md
  • coding-agent/src/coding_agent/server/http_server.py
  • coding-agent/src/coding_agent/server/schemas.py
  • coding-agent/src/coding_agent/server/session_manager.py
  • coding-agent/tests/ui/test_http_server.py
  • coding-agent/tests/ui/test_session_manager_runtime.py

📝 Walkthrough

Walkthrough

Adds admin-only semantic memory status and rebuild endpoints. The server, SessionManager, schemas, and tests now support read-only status queries, exclusive rebuild admission, strict request validation, and conflict/authorization mappings.

Changes

Semantic memory maintenance

Layer / File(s) Summary
Contract, schemas, and SessionManager rebuild path
coding-agent/.opencode/prompts/tasks/semantic-memory-maintenance-surface-task-packet.md, coding-agent/docs/adr/0072-tape-memory-semantic-index-and-enable-switch.md, coding-agent/src/coding_agent/server/schemas.py, coding-agent/src/coding_agent/server/session_manager.py, coding-agent/tests/ui/test_session_manager_runtime.py
Defines the semantic maintenance surface, adds strict status and rebuild models, implements SessionManager.semantic_memory_status() and rebuild_semantic_memory(), and covers rebuild admission plus active-turn fencing in runtime tests.
Admin HTTP routes and API tests
coding-agent/src/coding_agent/server/http_server.py, coding-agent/tests/ui/test_http_server.py
Adds the semantic status and rebuild routes, maps runtime and ownership errors to HTTP responses, and exercises admin authorization, conflict handling, report mapping, and request validation.

Sequence Diagram(s)

sequenceDiagram
  participant AdminClient
  participant http_server
  participant SessionManager
  participant RuntimeMaintenanceAdmissionService
  participant SemanticMemoryMaintainer

  AdminClient->>http_server: GET /sessions/{session_id}/memory/semantic/status
  http_server->>SessionManager: semantic_memory_status(session_id)
  SessionManager->>SemanticMemoryMaintainer: status()
  SemanticMemoryMaintainer-->>SessionManager: SemanticMemoryStatus
  SessionManager-->>http_server: SemanticMemoryStatusResponse
  http_server-->>AdminClient: 200 OK

  AdminClient->>http_server: POST /sessions/{session_id}/memory/semantic/rebuild
  http_server->>SessionManager: rebuild_semantic_memory(session_id, batch_size, allow_rebuild)
  SessionManager->>RuntimeMaintenanceAdmissionService: run_exclusive(session_id, rebuild)
  RuntimeMaintenanceAdmissionService->>SemanticMemoryMaintainer: rebuild(batch_size, allow_rebuild)
  SemanticMemoryMaintainer-->>SessionManager: SemanticSyncReport
  SessionManager-->>http_server: SemanticMemoryRebuildResponse
  http_server-->>AdminClient: 200 OK or 409 conflict
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

I thumped my feet at the moonlit gate,
The semantic crumbs came home just great.
No active turn got in the way,
The rebuild danced and hopped away.
🐇✨ Fresh memories now tidy and bright.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding semantic memory maintenance API endpoints and related support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/semantic-memory-maintenance-surface

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@delete-cloud
delete-cloud merged commit 92f74fc into main Jun 27, 2026
2 checks passed
@delete-cloud
delete-cloud deleted the feat/semantic-memory-maintenance-surface branch June 27, 2026 06:45
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.

1 participant