Repository navigation
feat(pg): Research schema on PostgreSQL (L-R-1 #634, PR 1) - #936
Merged
Merged
Conversation
Add backend/db/schema/130_research.sql: Concepts whose names and aliases share one concept_keys namespace (identity_key, checked at COMMIT), the Concept hierarchy, Positions, Arguments/Stances, the global verdict seed, Argument targets and citations with the #60 §8.5 identity, and the derived concept/argument mention and note-state tables. Register both argument_sources keys in the Work merge relationship registry (it leaves DEFERRED), and have the merge plan name every citing Argument and the Work-level citations that collapse. Refs #613, #634 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017jgbjrTtg1i9iUrndjRxvp
|
Architecture Inside the changed components — 1 viewComponent view — Research Storage Internal schema tables and external relational bounds introduced for Research. Data flow Review ✨ Nothing flagged · reviewed Tip Set 🪧 More tips
Thanks for using PR Lens! It's free for OSS. If it helped, a star helps other teams find it. |
This comment has been minimized.
This comment has been minimized.
Fooftilly
temporarily deployed
to
project-automation
October 26, 2026 07:44 — with
GitHub Actions
Inactive
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This was referenced Oct 26, 2026
This branch was previously deployed
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.
Requested by Nikola · project thread
Summary
First PR of slice L-R-1 (Research). Like L-O-1 and L-P-1, it starts with the schema, so the domain PRs that follow have every Research table to build on.
backend/db/schema/130_research.sqladds:concept_aliasesand aconcept_keystable. A Concept's name and the aliases of every Concept share oneUNIQUE (library_id, key)namespace onprks.identity_key(the same rule asnormalize_concept_key). It is built liketag_keys, with deferred keys checked at COMMIT, so a name and a concurrent alias of the same key cannot both commit.[[concept:…]]resolution will use this index, not the Python full scan (§8.1, §8.4). A rename moves the name's key row and keeps the old name as an alias, asconcept_sync.set_identity_on_conndoes.concept_parents), Positions, Arguments/Stances, the globalargument_verdictsseed (SQLite's four rows) and Argument targets. Names are stored canonical, and the text bounds areresearch_network.py's, counted in characters.argument_sourceswith the [Roadmap] Work Identity, Editions, Versions & Deduplication #60 §8.5 identity. The row key is the list position. A citation is either Work-level or pinned to a Version of the cited Work, and only exact duplicates are refused (NULLS NOT DISTINCT). A pinned citation follows its Version on a move (ON UPDATE CASCADE).derived.concept_mentions,derived.argument_mentionsandderived.work_note_state, with no foreign keys. Onlyresearch.reindex_workwill write them, and it deletes a gone Work's rows itself (§8.4).Revision ownership (§13.2 gate). A Concept's aliases and key rows, and an Argument's targets and sources, are the only cascades into revision-owning rows. Their owner's own scopes (
concept-identity,argument-targets,argument-sources) describe them, and the owner's delete tombstones those scopes. Everything else is NO ACTION:concept-parentson the other end, so they do not cascade.POSITION_IN_USEandARGUMENT_TARGETED.argument-sources. On PostgreSQL, the Work delete will remove them and advance that scope once the Research commands land.Work merge registry.
argument_sourcesmoves frommerge.DEFERREDtomerge.RELATIONSHIPS:UNIONandREFUSED, and is a peer table;FOLLOWS.merge.preparenow also reportsciting_arguments, the Arguments whoseargument-sourcesrevision a merge advances, andcitations_collapsed, the Work-level citations of the source that the target already has exactly. A comment inPEER_WRITERSnotes thatCREATE_ARGUMENTandSET_ARGUMENT_SOURCESmust join it with their PostgreSQL handlers.Related issues
Refs #634
Refs #613
Refs #614
Scope / non-goals
Schema, schema tests and the merge registry only. Planned L-R-1 follow-ups, one PR each:
argument-sources, andCREATE_ARGUMENT/SET_ARGUMENT_SOURCESjoiningPEER_WRITERS.research.reindex_workjob (per-Work advisory lock, noteFOR SHARE, gone-Work cleanup), enqueued by note commands and by the Work delete, plus the §8.4 pause-point tests.No facade method, sync handler or route changes in this PR.
server.pyand shared lane files other than the listed one-liners are untouched.Validation
Local (PostgreSQL 18.x through
scripts/test-postgres, throwaway cluster):tests.pg.test_research_schema: 23 tests OK. These cover names/aliases sharing one key (Greek, Cyrillic, ß, NFC), three concurrency races onconcept_keys, rename, hierarchy, targets and verdicts, citation identity, Library isolation, derived tables, and the cascade list.tests.pg.test_work_merge_foundations: OK, including the new citation-plan test and the registry and peer-table checks against live keys.tests/pgsuite: 1118 tests OK.scripts/check_pg_schema.py: the fresh schema matches the regeneratedsnapshot.json.ruff check backend tests/pg: clean. Pyright (pyrightconfig.typed-slice.json, 1.1.414): 0 errors.scripts/check_invariants.py: OK.Migration / compatibility impact
New PostgreSQL baseline file
130_research.sql(pre-1.0, no data migration). SQLite is unchanged. On PostgreSQL, a Work cited by an Argument refuses deletion until Research PR 2 lands. No API can create a citation on PostgreSQL yet.Generated by Claude Code