Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions prompts/m5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# M5 - Notes CRUD + BlockNote + CRDT / Phase Prompts

Fresh-session prompts for M5. Run one phase per clean session. Do not start the
next phase until the previous phase is committed and verified.

## Worktree

M5 should run after M4 is merged to `main`.

```bash
cd /Users/h4yfans/sideproject/memry-worktrees/spike-tauri-m4
git fetch origin
git worktree add ../spike-tauri-m5 -b m5/notes-crud-blocknote-crdt main
cd ../spike-tauri-m5
```

If the branch name is random, rename it before pushing:

```bash
git branch -m m5/notes-crud-blocknote-crdt
```

All prompts assume this root:

```text
/Users/h4yfans/sideproject/memry-worktrees/spike-tauri-m5
```

## Execution Order

| Phase | Prompt | Task | Plan Tasks | Status |
|-------|--------|------|------------|--------|
| A | `m5-phase-a-crdt-foundation.md` | Rust yrs CRDT core, DocStore, apply/snapshot/state-vector/compaction/wire | 1-9 | TODO |
| B | `m5-phase-b-db-schema-notes.md` | CRDT migrations plus notes/folders/tags DB primitives | 10-19 | TODO |
| C | `m5-phase-c-db-properties-crdt-persistence.md` | Property definitions plus CRDT update/snapshot persistence | 20-22 | TODO |
| D | `m5-phase-d-notes-core-commands.md` | Notes command skeleton, create/get/update/delete/list | 23-28 | TODO |
| E | `m5-phase-e-notes-advanced-commands.md` | Rename/move/exists/local-only/tags/links/aggregate tests | 29-32 | TODO |
| F | `m5-phase-f-folder-commands.md` | Folder CRUD, configs, templates, positions | 33-35 | TODO |
| G | `m5-phase-g-property-commands.md` | Property definition and option command surface | 36-37 | TODO |
| H | `m5-phase-h-deferred-stubs-parity.md` | File metadata/open/reveal plus deferred M6/M8 mock ledger | 38-39 | TODO |
| I | `m5-phase-i-crdt-commands.md` | CRDT Tauri command surface, chunks, capabilities, tests | 40-46 | TODO |
| J | `m5-phase-j-renderer-provider-blocknote.md` | Renderer origin tags, Yjs provider, BlockNote binding, mock swap | 47-50 | TODO |
| K | `m5-phase-k-md-to-yjs-seed.md` | Markdown to BlockNote blocks and idempotent Y.Doc seed | 51-52 | TODO |
| L | `m5-phase-l-registration-devtools-bindings.md` | Devtools, registrations, capabilities, bindings, event parity | 53-56 | TODO |
| M | `m5-phase-m-renderer-legacy-contract-cleanup.md` | Replace legacy sync_crdt path, rehome contracts, IPC cleanup | 57-60 | TODO |
| N | `m5-phase-n-runtime-e2e.md` | Real Tauri runtime e2e lane | 65-71 | TODO |
| O | `m5-phase-o-final-verification-ledger.md` | Full verification, manual dogfood, carry-forward ledger | 72-74 | TODO |

The source plan has 13 chunks. These prompts split the largest DB and notes-command
chunks into smaller sessions to reduce integration churn.

## Global Rules

1. Worktree root: `/Users/h4yfans/sideproject/memry-worktrees/spike-tauri-m5`
2. Branch: `m5/notes-crud-blocknote-crdt`
3. Source of truth: `docs/superpowers/plans/2026-04-26-m5-notes-crud-blocknote-crdt.md`
4. Parent spec: `docs/superpowers/specs/2026-04-24-electron-to-tauri-full-migration-design.md`
5. Predecessor: M4 must be merged before M5 starts.
6. New work goes only to `apps/desktop-tauri/` unless a phase explicitly says otherwise.
7. `apps/desktop/**` is read-only reference material. Do not change Electron during M5.
8. Tauri command names are snake_case. Tauri events use kebab-case unless the plan
explicitly preserves a compatibility alias.
9. CRDT fragment name is exactly `prosemirror`.
10. Inline CRDT IPC update cap is 8 KB; larger updates use chunk commands.
11. Commit format: `m5(<scope>): <description>`.
12. No branding in branch names, commit bodies, PR descriptions, or generated docs.

## Required Method

Each implementation phase starts by invoking:

- `superpowers:using-superpowers`
- `superpowers:test-driven-development` for phases that write code
- `superpowers:systematic-debugging` for failures with non-obvious cause
- `superpowers:verification-before-completion` before reporting complete

Use RED-GREEN for every task with a test file in the plan. Confirm the RED failure
before implementation, then confirm GREEN before committing.

## Phase Handoff

At the end of every phase, run the smallest full-phase gate listed in that prompt,
then report:

```text
Phase <X> complete.
Tasks covered: <task numbers>
Commits: <count> (<first hash>..<last hash>)
Verification: <commands and result>
Next: Phase <Y> - <prompt filename>
Blockers: <none | list>
```

## Emergency Stop

Stop and report if:

- M4 is not merged or baseline checks are red.
- `yrs` APIs differ from the plan enough to change the CRDT design.
- renderer contracts conflict with generated Specta bindings.
- any production build would still rely on an unledgered mock route.
- `devtools_*` commands leak into production capabilities or generated production
command lists.
- runtime e2e requires fake JS-only CRDT convergence instead of real `crdt_*` commands.

Do not guess. Identify root cause, state the smallest fix, and wait if the fix changes
scope.
110 changes: 110 additions & 0 deletions prompts/m5/m5-phase-a-crdt-foundation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# M5 Phase A - CRDT Foundation

Fresh session prompt. This phase lands the Rust `yrs` CRDT core before any command
exposes it.

---

## PROMPT START

You are implementing **Phase A of Milestone M5** for Memry's Electron to Tauri
migration. This phase executes plan Tasks 1-9 from
`docs/superpowers/plans/2026-04-26-m5-notes-crud-blocknote-crdt.md`.

### Context

**Worktree:** `/Users/h4yfans/sideproject/memry-worktrees/spike-tauri-m5`
**Branch:** `m5/notes-crud-blocknote-crdt`
**Plan:** `docs/superpowers/plans/2026-04-26-m5-notes-crud-blocknote-crdt.md`
**Spec:** `docs/superpowers/specs/2026-04-24-electron-to-tauri-full-migration-design.md`
**Prompts README:** `prompts/m5/README.md`

M5 replaces mock notes/CRDT behavior with a Rust-owned authoritative Y.Doc runtime.
Phase A only builds the Rust CRDT core. It does not add DB persistence, commands,
renderer wiring, or runtime e2e.

### Prerequisite Verification

```bash
cd /Users/h4yfans/sideproject/memry-worktrees/spike-tauri-m5
git rev-parse --abbrev-ref HEAD # expect: m5/notes-crud-blocknote-crdt
git log --oneline main | head -10 # expect M4 merged
test -f apps/desktop-tauri/src-tauri/Cargo.toml
test -f apps/desktop-tauri/src-tauri/src/error.rs
test -f apps/desktop-tauri/src-tauri/src/app_state.rs
test -f apps/desktop-tauri/src-tauri/src/lib.rs
grep -q '^yrs = "0.21"' apps/desktop-tauri/src-tauri/Cargo.toml
pnpm --filter @memry/desktop-tauri cargo:check
pnpm --filter @memry/desktop-tauri cargo:test
pnpm --filter @memry/desktop-tauri bindings:check
pnpm --filter @memry/desktop-tauri command:parity
```

If any command fails, STOP and report. Do not start M5 on an unverified M4 base.

### Your Scope

Execute Tasks 1-9 in order:

- **Task 1:** Add `lru` and `once_cell` dependencies.
- **Task 2:** Add `AppError::Crdt` and `From<yrs>` decode/apply error impls.
- **Task 3:** Add `crdt/mod.rs`, `CrdtRuntime`, origin tag, and `AppState` wiring.
- **Task 4:** Implement `DocStore`, `DocHandle`, `get_or_init`, `get`, `drop_doc`.
- **Task 5:** Implement `crdt/apply.rs` with `apply_update_v1`.
- **Task 6:** Implement `crdt/snapshot.rs` with snapshot and diff encoders.
- **Task 7:** Implement `crdt/state_vector.rs`.
- **Task 8:** Implement `crdt/compaction.rs` and threshold constants.
- **Task 9:** Implement `crdt/wire.rs` with `CRDT_UPDATE_EVENT` and payload types.

### Methodology

1. Invoke `superpowers:using-superpowers` and `superpowers:test-driven-development`.
2. Read plan Tasks 1-9 fully before editing. Use the code snippets there as the
implementation baseline, but adapt to the exact repo APIs.
3. Keep the outer `DocStore` map lock short. Do not hold it across Yjs transactions.
4. Stamp updates with a stable non-zero origin tag.
5. Commit once per task when source changed.

### Acceptance Criteria

```bash
cd /Users/h4yfans/sideproject/memry-worktrees/spike-tauri-m5

test -f apps/desktop-tauri/src-tauri/src/crdt/mod.rs
test -f apps/desktop-tauri/src-tauri/src/crdt/docstore.rs
test -f apps/desktop-tauri/src-tauri/src/crdt/apply.rs
test -f apps/desktop-tauri/src-tauri/src/crdt/snapshot.rs
test -f apps/desktop-tauri/src-tauri/src/crdt/state_vector.rs
test -f apps/desktop-tauri/src-tauri/src/crdt/compaction.rs
test -f apps/desktop-tauri/src-tauri/src/crdt/wire.rs

cd apps/desktop-tauri/src-tauri
cargo test --test error_crdt_test
cargo test --test crdt_runtime_test
cargo test --test crdt_docstore_test
cargo test --test crdt_apply_test
cargo test --test crdt_snapshot_test
cargo test --test crdt_state_vector_test
cargo test --test crdt_compaction_test
cargo test --test crdt_wire_test

cd /Users/h4yfans/sideproject/memry-worktrees/spike-tauri-m5
pnpm --filter @memry/desktop-tauri cargo:check
pnpm --filter @memry/desktop-tauri cargo:clippy -- -D warnings
pnpm --filter @memry/desktop-tauri cargo:test -- --test 'crdt_*'
```

### When Done

Report:

```text
Phase A complete.
Tasks covered: 1, 2, 3, 4, 5, 6, 7, 8, 9
Commits: <count> (<first hash>..<last hash>)
Verification: crdt/error tests + cargo check/clippy/test
Next: Phase B - prompts/m5/m5-phase-b-db-schema-notes.md
Blockers: <none | list>
```

## PROMPT END
105 changes: 105 additions & 0 deletions prompts/m5/m5-phase-b-db-schema-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# M5 Phase B - DB Schema + Notes DB Primitives

Fresh session prompt. This phase adds the CRDT migrations and fleshes out the notes,
folder-config, position, cache, and tag DB modules.

---

## PROMPT START

You are implementing **Phase B of Milestone M5**. This phase executes plan Tasks
10-19 from `docs/superpowers/plans/2026-04-26-m5-notes-crud-blocknote-crdt.md`.

### Context

**Worktree:** `/Users/h4yfans/sideproject/memry-worktrees/spike-tauri-m5`
**Branch:** `m5/notes-crud-blocknote-crdt`
**Plan:** `docs/superpowers/plans/2026-04-26-m5-notes-crud-blocknote-crdt.md`
**Previous phase:** `prompts/m5/m5-phase-a-crdt-foundation.md`

Phase A created the in-memory CRDT runtime. Phase B builds the local data persistence
base needed by notes/folder/property/CRDT commands. It does not expose Tauri commands.

### Prerequisite Verification

```bash
cd /Users/h4yfans/sideproject/memry-worktrees/spike-tauri-m5
git rev-parse --abbrev-ref HEAD
test -f apps/desktop-tauri/src-tauri/src/crdt/docstore.rs
test -f apps/desktop-tauri/src-tauri/src/crdt/wire.rs
pnpm --filter @memry/desktop-tauri cargo:test -- --test 'crdt_*'
pnpm --filter @memry/desktop-tauri cargo:clippy -- -D warnings
```

If any command fails, STOP and fix Phase A first.

### Your Scope

Execute Tasks 10-19 in order:

- **Task 10:** Capture schema diff baseline and inspect Electron SQL as read-only
reference. No commit.
- **Task 11:** Add migration `0029_crdt_updates.sql` and migration test.
- **Task 12:** Add migration `0030_crdt_snapshots.sql` and migration test.
- **Task 13:** Register both migrations in `db/migrations.rs`.
- **Task 14:** Declare/re-export DB modules in `db/mod.rs`.
- **Task 15:** Implement `db/note_metadata.rs` CRUD, soft delete, rename, local-only,
exists, list helpers, and tests.
- **Task 16:** Implement `db/note_positions.rs` reorder/get/drop helpers and tests.
- **Task 17:** Implement `db/notes_cache.rs` refresh/list/count/delete helpers and
tests. Add a migration only if the table is actually missing.
- **Task 18:** Implement `db/folder_configs.rs` get/set/delete/template inheritance
and tests.
- **Task 19:** Implement `db/tag_definitions.rs` list/count/upsert/rename behavior
and tests.

### Methodology

1. Invoke `superpowers:using-superpowers` and `superpowers:test-driven-development`.
2. Read plan Tasks 10-19 fully before editing.
3. Use Electron SQL only as reference; do not modify `apps/desktop/**`.
4. Add `test_helpers` only if missing, behind the same cfg pattern already used in
the Tauri crate.
5. Keep SQL simple and explicit. No speculative indexing beyond the plan.
6. Commit once per task when source changed.

### Acceptance Criteria

```bash
cd /Users/h4yfans/sideproject/memry-worktrees/spike-tauri-m5

test -f apps/desktop-tauri/src-tauri/migrations/0029_crdt_updates.sql
test -f apps/desktop-tauri/src-tauri/migrations/0030_crdt_snapshots.sql
test -f apps/desktop-tauri/src-tauri/src/db/note_metadata.rs
test -f apps/desktop-tauri/src-tauri/src/db/note_positions.rs
test -f apps/desktop-tauri/src-tauri/src/db/notes_cache.rs
test -f apps/desktop-tauri/src-tauri/src/db/folder_configs.rs
test -f apps/desktop-tauri/src-tauri/src/db/tag_definitions.rs

cd apps/desktop-tauri/src-tauri
cargo test --test migrations_test
cargo test --test db_note_metadata_test
cargo test --test db_note_positions_test
cargo test --test db_notes_cache_test
cargo test --test db_folder_configs_test
cargo test --test db_tag_definitions_test

cd /Users/h4yfans/sideproject/memry-worktrees/spike-tauri-m5
pnpm --filter @memry/desktop-tauri cargo:test -- --test 'db_*' --test migrations_test
pnpm --filter @memry/desktop-tauri cargo:clippy -- -D warnings
```

### When Done

Report:

```text
Phase B complete.
Tasks covered: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
Commits: <count> (<first hash>..<last hash>)
Verification: migrations_test + db note/folder/tag tests + cargo clippy
Next: Phase C - prompts/m5/m5-phase-c-db-properties-crdt-persistence.md
Blockers: <none | list>
```

## PROMPT END
Loading
Loading