8000 V0-05: Add symmetric Relationships and Thinking Graph invariants by kiran-brahma · Pull Request #24 · kiran-brahma/nodepad-app · GitHub
[go: up one dir, main page]

Skip to content

V0-05: Add symmetric Relationships and Thinking Graph invariants - #24

Merged
kiran-brahma merged 1 commit into
mainfrom
claude/github-issue-6-8c84de
Jul 23, 2026
Merged

kiran-brahma merged 1 commit into
mainfrom
claude/github-issue-6-8c84de

Conversation

@kiran-brahma
Copy link
Copy Markdown
Owner

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) — relationships with UNIQUE(note_id_a, note_id_b), CHECK(note_id_a < note_id_b), and ON DELETE CASCADE from both endpoints and the Workspace. Provenance is manual | ai; only manual is written here.
  • relate_notes / unrelate_notes intents on the Thinking Workspace interface, with Tauri commands and client methods. The snapshot now carries relationships.
  • 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

Acceptance criterion How
Stored once, duplicate creation idempotent Canonical ordering in the module, UNIQUE + ON CONFLICT DO NOTHING in the schema
Either endpoint lists the other One endpoint rule, used by lookup and by the duplicate guard
Self and cross-Workspace fail without partial state Validated from committed Notes before any transaction opens
Deleting either Note removes the Relationship Schema cascade; the in-memory adapter mirrors it
Manual provenance and creation time persist after restart Covered by a reopen test
Navigation focuses without mutating Focus is React state; it is not in the snapshot, the schema, or any intent
No dangling endpoints Unrepresentable via the cascade; asserted in conformance

Testing

npm run check passes with no warnings: 30 frontend tests, 16 Rust tests, lint, typecheck, and the Tauri smoke build.

  • Rust conformance runs against both the SQLite and in-memory adapters and covers reversed endpoint order, duplicates, self-link, cross-Workspace link, missing endpoints, cascade delete, and no dangling endpoints.
  • Three SQLite tests cover reopened state (provenance and creation time), the schema refusing duplicate, reversed, self, and unknown-endpoint rows written around the module, and an injected commit failure leaving the graph unchanged.
  • src/thinking-graph.test.ts covers the projections directly; src/App.test.tsx covers 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

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>
@kiran-brahma
kiran-brahma merged commit 6bfd5d5 into main Jul 23, 2026
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.

V0-05: Add symmetric Relationships and Thinking Graph invariants

1 participant

0