Skip to content

fix(notebook): add endpoint response models - #312

Merged
Lyellr88 merged 1 commit into
Lyellr88:MARM-mainfrom
erfou11:feature/issue-167-notebook-response-models
Oct 16, 2026
Merged

Lyellr88 merged 1 commit into
Lyellr88:MARM-mainfrom
erfou11:feature/issue-167-notebook-response-models

Conversation

@erfou11

@erfou11 erfou11 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #167 for marm_notebook, agreed in the issue discussion.

  • Add file-local response models for all six actions and the existing error response, with extra="forbid".
  • Preserve omitted redaction fields, nullable timestamps, and save responses with either a null or populated memory_id while the mirror is pending.
  • Share the unchanged RedactionSummary with logging now that it has a second consumer.

This stays at the HTTP/OpenAPI boundary. Service behavior and STDIO are unchanged. No documentation changes are needed for the existing fields or workflow; the response schemas now appear in OpenAPI.

Validation

The 53 tests in test_notebook_response_models.py cover full-payload parity through real FastAPI and SQLite, including the write queue, redaction, pending mirrors, errors, and large content. They also check MCP descriptions/input schemas against an untyped route and preserve the 16-tool list. Response drift returns a client-visible HTTP 500; the write tests explicitly show that completed writes are not rolled back.

Local checks on WSL, Python 3.11:

  • python scripts/release-preflight.py, including the default test runner: backend 3344 passed, 5 skipped; Console API 72 passed; frontend 283 passed, with typecheck and production build passing.
  • Ruff, formatting, mypy, and Python compilation passed.

The five skips are three Windows-only cases and two opt-in Docker/destructive smoke cases. Docker and slow STDIO tests were excluded by the runner's defaults; the optional Docker smoke was not run. The WSL run used an isolated shared CBM_CACHE_DIR and pytest temporary directories under /dev/shm. Non-blocking docs/build warnings and best-effort usage-counter logs were reviewed.

Contributor checklist

  • I have personally reviewed and tested this code and PR description. It is not an unattended agent-generated submission.
  • For a new feature or behavior change, this PR links an issue labeled accepted. Bug, test, and doc fixes are exempt. (typing: give endpoints real response models instead of bare dict #167 does not currently have the label; the scope approval is linked above.)
  • I have considered HTTP and STDIO parity for any MCP-facing change.
  • I updated relevant tests and documentation, or explained why neither is needed.

Summary by CodeRabbit

  • Improvements
    • Notebook responses now use consistent, structured formats for successful actions and errors, with optional fields omitted when not set.
    • Redaction summaries use a consistent format across notebook and logging responses, including a total count and counts by redaction type.
    • Response formats reject unexpected fields, helping keep API responses predictable.

Declare response schemas for all six marm_notebook actions and errors.
Keep response payloads unchanged and share RedactionSummary with logging.
Add parity, response-drift, OpenAPI, and MCP metadata tests.

Refs Lyellr88#167
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Lyellr88/marm-memory/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 92bd6497-ecde-449d-a2b7-2173736c52dc
📥 Commits

Reviewing files that changed from the base of the PR and between d9c7767 and a899602.

📒 Files selected for processing: 4
  • marm-mcp-server/marm_mcp_server/core/models.py
  • marm-mcp-server/marm_mcp_server/endpoints/logging.py
  • marm-mcp-server/marm_mcp_server/endpoints/notebook.py
  • marm-mcp-server/tests/test_notebook_response_models.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 2
  • GitHub Check: python
  • GitHub Check: docker
🧰 Additional context used
📓 Path-based instructions: 2
Focus on tests that are flaky, non-isolated, incorrectly asserting behavior, or missing coverage for a changed high-risk path.

⚙️ CodeRabbit configuration file

Files:

  • marm-mcp-server/tests/test_notebook_response_models.py
Prioritize runtime correctness, async/concurrency safety, SQLite transaction safety, auth/rate-limit behavior, release-breaking packaging issues, and MCP protocol compatibility.

⚙️ CodeRabbit configuration file

Files:

  • marm-mcp-server/marm_mcp_server/core/models.py
  • marm-mcp-server/marm_mcp_server/endpoints/logging.py
  • marm-mcp-server/tests/test_notebook_response_models.py
  • marm-mcp-server/marm_mcp_server/endpoints/notebook.py
🔇 Additional comments: 4
marm-mcp-server/marm_mcp_server/core/models.py: 1

3-10: LGTM!

marm-mcp-server/marm_mcp_server/endpoints/logging.py: 1

6-6: LGTM!

marm-mcp-server/marm_mcp_server/endpoints/notebook.py: 1

1-94: LGTM!

marm-mcp-server/tests/test_notebook_response_models.py: 1

1-629: LGTM!

📝 Walkthrough

The logging endpoint now uses a shared redaction summary model. The notebook endpoint now declares typed success and error responses. New tests compare typed and untyped route behavior, validate response schemas, and inspect API metadata.

Changes: Notebook response contracts

Layer / File(s) Summary
Shared redaction summary
marm-mcp-server/marm_mcp_server/core/models.py, marm-mcp-server/marm_mcp_server/endpoints/logging.py
Adds a shared RedactionSummary model and uses it in the logging response.
Notebook response schemas and route
marm-mcp-server/marm_mcp_server/endpoints/notebook.py, marm-mcp-server/tests/test_notebook_response_models.py
Defines typed success and error response variants, configures the notebook route to use their union, and tests MCP metadata and OpenAPI schemas.
Notebook response and persistence parity
marm-mcp-server/tests/test_notebook_response_models.py
Compares typed and untyped responses, status codes, and persisted state across notebook actions, errors, mirror failures, and large content.
Response validation and write behavior
marm-mcp-server/tests/test_notebook_response_models.py
Tests that response-schema mismatches produce HTTP 500 on the typed route, including cases where writes have already completed.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to a8996

No merge-blocking issue is identified; proceed with normal checks.

Pre-merge checks: Passed 2
Passed Passed checks: 2 passed
Check name Status Explanation
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.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@Lyellr88 Lyellr88 added bug Something isn't working python Pull requests that update python code labels Oct 16, 2026
@Lyellr88

Copy link
Copy Markdown
Owner

@erfou11 This looks good on my side. The notebook schemas preserve the existing payloads, including redaction and pending mirrors, and all 120 targeted tests passed. Thanks for continuing the work on #167, I am merging this into MARM-main now.

@Lyellr88
Lyellr88 merged commit 97871d5 into Lyellr88:MARM-main Oct 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants