Repository navigation
V0-05: Add symmetric Relationships and Thinking Graph invariants - #24
Merged
Merged
Conversation
Adds manual Relationships between Notes in one Thinking Workspace, plus the invariants that keep the Thinking Graph well formed. A Relationship is symmetric and untyped. Each unordered pair is stored once under a canonical endpoint ordering, so either order names the same row and a duplicate is impossible in the module and in the schema. Both endpoints and the Workspace cascade, so no projection can observe an endpoint that no longer names a Note. - New `thinking_graph` module owns canonical ordering, the endpoint rule, and pair validation as pure rules over committed state. - New `relate_notes` and `unrelate_notes` intents, with manual provenance. Asking for a Relationship that already exists commits no second one. Self and cross-Workspace pairs are refused before any transaction opens, so a refusal leaves nothing partial behind. - Migration 0005 adds the `relationships` table with a unique canonical pair, a `note_id_a < note_id_b` check, and cascades on both endpoints. Provenance admits `ai` so a later assistance slice adds rows rather than changing what an existing row means. - New `src/thinking-graph.ts` owns the projections the Note detail surface renders: related lookup, degree, and relation-editor candidates. - The Note detail surface can add, inspect, navigate to, and remove a Relationship. Navigation is transient focus and commits nothing. Relationships stay outside undo history, exactly as Labels do. Undoing a Note delete restores the Note, not the Relationships that cascaded with it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6.
What changed
A Relationship is one symmetric, untyped association between two distinct Notes in the same Thinking Workspace, with manual provenance and a creation time.
src-tauri/src/thinking_graph.rs(new) — the Thinking Graph module: canonical pair ordering, the endpoint rule that makes related lookup order-independent, and pair validation as pure rules over committed state.src-tauri/migrations/0005_relationships.sql(new) —relationshipswithUNIQUE(note_id_a, note_id_b),CHECK(note_id_a < note_id_b), andON DELETE CASCADEfrom both endpoints and the Workspace. Provenance ismanual | ai; onlymanualis written here.relate_notes/unrelate_notesintents on the Thinking Workspace interface, with Tauri commands and client methods. The snapshot now carriesrelationships.src/thinking-graph.ts(new) — the projections the Note detail surface renders: related lookup, degree, and relation-editor candidates.src/App.tsx— from a Note, the thinker can search and select another Note in the active Workspace, create a Relationship, see it on either endpoint, navigate to a related Note, and remove it.Invariants and how they hold
UNIQUE+ON CONFLICT DO NOTHINGin the schemaTesting
npm run checkpasses with no warnings: 30 frontend tests, 16 Rust tests, lint, typecheck, and the Tauri smoke build.src/thinking-graph.test.tscovers the projections directly;src/App.test.tsxcovers add, inspect, navigate, remove, candidate filtering, and cascade from the Note surface.Known limitation
Relationships stay outside undo history, exactly as Labels do. Undoing a Note delete restores the Note, not the Relationships that cascaded with it. Extending the undo mutation vocabulary to carry them would couple the graph to the undo log for a case this issue does not ask about; the audit records the trade-off.
Audit
docs/v0/audits/06-relationships.md— gate PROCEED.🤖 Generated with Claude Code