Skip to content

Markdown Store + Memory Content Contract - #2

Merged
nonnil merged 3 commits into
mainfrom
symphony/tra-2-markdown-store
May 9, 2026
Merged

Markdown Store + Memory Content Contract#2
nonnil merged 3 commits into
mainfrom
symphony/tra-2-markdown-store

Conversation

@nonnil

@nonnil nonnil commented May 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds the markdown content store contract for {storePath}/memories/{memoryId}/CONTENT.md.
  • Adds writer/reader APIs with deterministic frontmatter serialization and parsing.
  • Adds filesystem-isolated Vitest coverage for path resolution, roundtrip parsing, missing/malformed content errors, fixture generation, and remote image link preservation.
  • Hardens rework feedback around temp-file replacement/cleanup and readable artifact parsing for CRLF, BOM, and frontmatter-only files.
  • Switches Playwright's CI web server command to bun run start so CI reuses the app built by bun run verify instead of timing out on vinxi dev.

API Names

  • resolveMemoryContentPath
  • createMemoryContentFixture
  • writeMemoryContent
  • readMemoryContent
  • MemoryContentFrontmatter
  • WriteMemoryContentInput
  • ReadMemoryContentResult

Sample CONTENT.md

---
id: "018f2d6d-7cbd-7a4c-8d32-9f0b5f0ef111"
url: "https://example.com/fixture"
title: "Fixture"
captured_at: "2026-05-09T06:00:00.000Z"
extraction_status: "link_only"
---
A fixture body.

Validation

  • npm test -- tests/server/store/memory-content.test.ts -> failed before implementation with missing src/server/store/memory-content, then passed after implementation: 1 file, 8 tests.
  • npm run typecheck -> pass.
  • npm test -> pass, 2 files, 13 tests.
  • npm run build -> pass.
  • env GIT_DIR=.tmp/gitdir GIT_WORK_TREE=. git diff --check -> pass.
  • Rework red/green: focused store test failed before the fix with 4 review regressions, then passed after the fix: 1 file, 12 tests.
  • Rework push preflight hook reran typecheck, test, and build successfully.
  • GitHub PR Markdown Store + Memory Content Contract #2 Verify on commit 7fadc3f -> pass.
  • npm run test:e2e -> blocked locally by macOS Chromium sandbox permission (bootstrap_check_in ... Permission denied); CI is the source of truth for this check.
  • Push preflight hook also reran typecheck, test, and build successfully.

bun is not available on PATH in this Symphony workspace, so I used the equivalent npm scripts against the installed dependencies.

Downstream Assumptions

  • Task 4 importer code should persist the returned relativePath as memories/{memoryId}/CONTENT.md.
  • Task 4 should supply a UUID v7 memoryId; the path resolver rejects non-UUID-v7 path segments.
  • Task 6 reader/rendering code should consume readMemoryContent output and keep tags/categories sourced from SQLite, not frontmatter.
  • Remote image markdown and HTML image URLs are left untouched by this store layer; downloading or rewriting images remains out of scope.

Summary by CodeRabbit

  • New Features

    • Added memory content persistence with read/write capabilities, including frontmatter metadata (id, URL, title, capture timestamp, extraction status).
    • Implemented robust error handling for invalid memory identifiers, missing content, and malformed frontmatter.
    • Ensured safe concurrent write operations with proper file management.
  • Tests

    • Added comprehensive test coverage for memory content storage, including path resolution, round-trip persistence, and error handling scenarios.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bfd9ff37-979b-4ac2-9a7a-3149a02398c3

📥 Commits

Reviewing files that changed from the base of the PR and between 2bde0bf and aacad5f.

📒 Files selected for processing (4)
  • playwright.config.ts
  • src/server/store/index.ts
  • src/server/store/memory-content.ts
  • tests/server/store/memory-content.test.ts

📝 Walkthrough

Walkthrough

This PR introduces a new memory content storage system (src/server/store/memory-content.ts) for persisting per-memory CONTENT.md files with validated frontmatter and markdown bodies, plus comprehensive test coverage. It also refactors playwright.config.ts to derive baseURL and webServer command from configurable constants instead of hardcoded values.

Changes

Memory Content Storage System

Layer / File(s) Summary
Type Definitions and Error Schema
src/server/store/memory-content.ts
Defines public interfaces: MemoryContentStoreConfig, MemoryContentFrontmatter (id, url, title, capturedAt, extractionStatus), ResolvedMemoryContentPath, read/write input/output types, and MemoryContentStoreError with error codes.
Path Resolution
src/server/store/memory-content.ts
Implements resolveMemoryContentPath to validate memoryId against UUIDv7 pattern and derive memories/{memoryId}/CONTENT.md paths, rejecting invalid IDs.
Fixture Creation
src/server/store/memory-content.ts
Implements createMemoryContentFixture to generate deterministic markdown with quoted-string YAML-like frontmatter block and markdown body.
Write and Read Operations
src/server/store/memory-content.ts
Implements writeMemoryContent (serialize, write to temp file, atomic rename) and readMemoryContent (load, parse, validate frontmatter against memoryId).
Frontmatter Parsing and Validation
src/server/store/memory-content.ts
Implements parsers for frontmatter/markdown extraction, BOM stripping, line-by-line key/value parsing with rejection of disallowed keys (tags, categories), validation of required fields, and type guards.
Module Export
src/server/store/index.ts
Adds wildcard re-export from ./memory-content to expose public API through store index.
Test Suite
tests/server/store/memory-content.test.ts
Covers path resolution, write/read round-tripping, YAML formatting, remote image preservation, concurrent write safety with temp file cleanup, fixture determinism, and error modes (missing content, malformed frontmatter, CRLF/BOM/edge cases).

Playwright Configuration Refactoring

Layer / File(s) Summary
Configuration Constants and Logic
playwright.config.ts
Introduces port constant (4173) and derives baseURL; constructs webServerCommand conditionally on process.env.CI to select bun run start (CI) or bun run dev (local).
Configuration Integration
playwright.config.ts
Updates webServer.command, webServer.url, and use.baseURL to use computed values, removing prior hardcoded build/start commands and URL strings.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant resolveOp as resolveMemoryContentPath
  participant writeOp as writeMemoryContent
  participant readOp as readMemoryContent
  participant FileSystem

  Client->>resolveOp: config + memoryId
  resolveOp->>resolveOp: Validate UUIDv7
  resolveOp->>Client: ResolvedMemoryContentPath
  
  Client->>writeOp: config + memoryId + frontmatter + markdown
  writeOp->>FileSystem: Create memories/{memoryId}
  writeOp->>FileSystem: Write temp .CONTENT.md.tmp
  writeOp->>FileSystem: Atomic rename to CONTENT.md
  writeOp->>Client: WriteMemoryContentResult
  
  Client->>readOp: config + memoryId
  readOp->>FileSystem: Load CONTENT.md
  readOp->>readOp: Strip BOM + parse frontmatter
  readOp->>readOp: Validate all fields + memoryId match
  readOp->>Client: ReadMemoryContentResult
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • hauntedfail/Trauma#1: Both PRs modify playwright.config.ts, changing how the webServer command and baseURL/webServer.url are computed.

Poem

🐰 Memories now persist in markdown's gentle fold,
With frontmatter fields of UUID and gold,
Concurrent writes dance safe through temp file grace,
While Playwright leaps with constants in place!
No more hardcoded strings—config blooms anew. 🌱

✨ 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 symphony/tra-2-markdown-store

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 and usage tips.

@nonnil
nonnil force-pushed the symphony/tra-2-markdown-store branch from 744710a to 4a787ed Compare May 9, 2026 06:50
@nonnil
nonnil marked this pull request as ready for review May 9, 2026 06:52
@nonnil
nonnil requested a review from Copilot May 9, 2026 07:18
@nonnil

nonnil commented May 9, 2026

Copy link
Copy Markdown
Member Author

review @codex @claude

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a filesystem-backed “memory content” contract (memories/{memoryId}/CONTENT.md) with deterministic frontmatter serialization/parsing, plus tests and a small Playwright CI web-server tweak to use the built app.

Changes:

  • Added src/server/store/memory-content.ts implementing path resolution, fixture generation, atomic-ish writes, and strict frontmatter parsing/validation.
  • Added Vitest coverage for path isolation, read/write roundtrips, malformed/missing content, and remote-image link preservation.
  • Updated Playwright webServer command selection to use bun run start in CI and bun run dev locally.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/server/store/memory-content.test.ts Adds filesystem-isolated tests covering resolver, writer/reader roundtrip, and failure modes.
src/server/store/memory-content.ts Implements the CONTENT.md contract, including UUIDv7 path validation and deterministic frontmatter handling.
src/server/store/index.ts Re-exports the new store APIs from the store module entrypoint.
playwright.config.ts Uses bun run start in CI to reuse the prebuilt app, keeping local dev on bun run dev.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/server/store/memory-content.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a787ed92a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/store/memory-content.ts Outdated
Comment thread src/server/store/memory-content.ts Outdated
Comment thread src/server/store/memory-content.ts Outdated
Comment thread src/server/store/memory-content.ts Outdated

@nonnil nonnil left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nonnil
nonnil merged commit 0ac3788 into main May 9, 2026
1 of 2 checks passed
@nonnil
nonnil deleted the symphony/tra-2-markdown-store branch May 9, 2026 10:57
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