From 7e6c0fc1d94d80a35539ad5d7e5980adaf131751 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 00:18:03 -0600 Subject: [PATCH 1/4] docs(id): amend Notion importer design for the data-source model (#8555) --- doc/2026-11-10_design_id6436.md | 40 +++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/doc/2026-11-10_design_id6436.md b/doc/2026-11-10_design_id6436.md index f545fa79cd..498f8c4709 100644 --- a/doc/2026-11-10_design_id6436.md +++ b/doc/2026-11-10_design_id6436.md @@ -3,6 +3,7 @@ - Date: 2026-11-10 - Status: **decision-ready proposal** — design only; no importer code is implemented here. - Issue: [#6436](https://github.com/developing-today/code/issues/6436), parent programme [#5678](https://github.com/developing-today/code/issues/5678), programme epic [#2056](https://github.com/developing-today/code/issues/2056). +- Amendment (2026-11-11, [#8555](https://github.com/developing-today/code/issues/8555)): the database model below is amended for the Notion API `2025-09-03` **data-source model** — a database is a container of one or more data sources, and schemas, row queries and relation targets are scoped per data source (`data_source_id`). The amendment touches Recommendation 2–3, §0, §1.2–§1.3, §2.2, §3, §6/§6.1/§6.2, §8 and the implementation slicing; no other decision in this design changes. - Object model: [#2048](https://github.com/developing-today/code/issues/2048) as landed in `doc/2026-11-01_design_id2048.md`: stable logical notes (`note.create` = stable note ID), signed immutable revisions (`note.revise` naming parents and a content blob), structured typed references (target note ID, sigil/type, authored surface, optional pinned revision), tags as signed observed-remove claims, names/aliases as claims, tombstone removal, group `Read`/`Write` as the authority model. This design **consumes** those decisions; it does not re-decide them. - Sibling importer designs: [#5848](https://github.com/developing-today/code/issues/5848) (Joplin) at `doc/2026-11-08_design_id5848.md` and [#5847](https://github.com/developing-today/code/issues/5847) (Logseq) at `doc/2026-11-08_design_id5847.md`. This design follows their shape deliberately — same manifest contract, same invariant set, same corpus discipline — so the importer family stays one design with per-source deltas. Where Notion forces a different answer, the difference is stated as a delta (§0). - Read-authority constraint (ruled on #6436; do not re-litigate): ID knowledge defaults to public read; owners may grant read to any number of groups and/or users; resolution order is **object → user default → server config → public**. §7 states how this design complies and how imported Notion access metadata is handled. @@ -16,8 +17,8 @@ How does a Notion workspace — pages made of typed blocks, databases whose rows **Import is a mapping into the object model, recorded in a persisted import manifest, acquired hybrid (export for content fidelity, API for inventory and identity), and it is one-shot plus idempotent re-import — never a sync emulation.** The shape is the Joplin/Logseq record's; the Notion deltas are these: 1. **Pages → logical notes; blocks are content, not notes.** Each Notion page becomes one logical note (`note.create`, initial revision blob = the page's block tree rendered to the model's content form after reference rewriting, §3). A **block is not a note**: blocks are structure *inside* a note's revision content, carried as an explicit block tree with stable block identities in the manifest — the Logseq rule (§2.1 of #5847), adopted unchanged. Notion pages nest (child pages), but a child page is a full page with its own URL and permissions, so a child page **is** its own note, linked to its parent by a typed reference — nesting of *pages* is graph structure, nesting of *blocks* is content (§2.1). -2. **Databases are the hard part, and they are claims, not a new object type.** A Notion database becomes: one note for the database itself (its description page content, if any), one note per row (a row *is* a page), the database's property schema recorded as provenance claims on the database note, and each row's property values recorded as claims on the row note (§2.2). Relations become typed references between row notes; rollups and formulas are **derived values** — imported as recorded provenance claims naming their formula/rollup definition, never as silently-authoritative values (§2.3). No database object type is added to the model. -3. **Stable identity comes from Notion's own IDs.** Every Notion page, database, and block has a UUID. The manifest maps Notion UUID ↔ note ID (and block UUID ↔ (note ID, block identity)), which is what makes re-import idempotent and duplicate detection decidable (§6). An import without a manifest is a failed import — same contract as #5848. +2. **Databases are the hard part, and they are claims, not a new object type.** A Notion database becomes: one note for the database itself (its description page content, if any), one note per row (a row *is* a page), the property schema of **each of the database's data sources** recorded as provenance claims on the database note, scoped to that data source, and each row's property values recorded as claims on the row note, interpreted against the schema of the data source the row belongs to (§2.2). A database is a *container*: since API version `2025-09-03` it holds one or more independently identified data sources, and there is no single per-database schema to record. Relations become typed references between row notes; rollups and formulas are **derived values** — imported as recorded provenance claims naming their formula/rollup definition, never as silently-authoritative values (§2.3). No database object type is added to the model. +3. **Stable identity comes from Notion's own IDs.** Every Notion page, database, data source, and block has a UUID. The manifest maps Notion UUID ↔ note ID (and block UUID ↔ (note ID, block identity), and `data_source_id` ↔ (database note ID, data-source identity)), which is what makes re-import idempotent and duplicate detection decidable (§6). An import without a manifest is a failed import — same contract as #5848. 4. **Hybrid acquisition: export is the content source of record; the API is the inventory and identity source.** A workspace export carries content and files the API serves poorly (and file URLs from the API expire); the API carries complete identity, database schemas, relations, and comments that an export flattens or omits. Neither alone is sufficient; §1 states what each path covers and what each loses, and the fidelity report (§6.4) is computed against the API inventory even when content came from the export. 5. **Notion access metadata is reported, never applied.** Who a page was shared with, whether it was published to the web, and workspace membership are recorded as provenance claims and named in the fidelity report. The importer creates **no** grants and **no** alternate read path; every imported object resolves read authority by the ruled order (object → user default → server config → public) exactly like a native object (§7). Applying a source-visibility mapping is a separate, explicit user action outside the importer. 6. **Comments import as claims with provenance, where the API exposes them.** A comment becomes a comment claim on the note (author Notion user ID + display name as recorded provenance, timestamp, body blob), never a revision — comments are discussion *about* the object, not content *of* it. Where the acquisition path cannot supply comments, the loss is named per page in the fidelity report, not silently dropped (§2.4). @@ -28,8 +29,8 @@ How does a Notion workspace — pages made of typed blocks, databases whose rows | --- | --- | --- | --- | | Primary content unit | Note / page = the note; blocks are content inside it | Same | Notion pages are the reading and revision unit; blocks are content structure | | Nesting | Folders / namespaces are claims, not containment | Child pages are separate notes + typed parent reference; block nesting is content | A Notion child page has its own identity, URL and sharing; a nested block does not | -| Identity | Joplin note ID / page name + block UUID | Notion UUID for pages, databases **and** blocks, from the API | Notion's API exposes stable UUIDs for all three; export alone does not reliably | -| Structured data | Joplin: none. Logseq: page/block properties as claims | **Databases**: schema as provenance claims, row values as claims, relations as typed references, rollups/formulas as derived-value provenance claims | Databases are Notion's centre of gravity; neither sibling has an equivalent | +| Identity | Joplin note ID / page name + block UUID | Notion UUID for pages, databases, **data sources** and blocks, from the API | Notion's API exposes stable UUIDs for all four; export alone does not reliably | +| Structured data | Joplin: none. Logseq: page/block properties as claims | **Databases**: per-data-source schema as provenance claims, row values as claims against their source's schema, relations as typed references, rollups/formulas as derived-value provenance claims | Databases are Notion's centre of gravity; neither sibling has an equivalent | | Source shapes | JEX / Markdown dir; graph directory / EDN | Workspace export (Markdown+CSV or HTML) **plus** API inventory — hybrid required | Export loses relations/comments/schema typing; API loses file permanence and some block fidelity | | Access metadata | Not modelled by either source | Present (sharing, publish-to-web) and **must not** become ID authority — provenance + report only (§7) | #6436's ruled read-authority order forbids an importer-created read path | | Lossy list | Plugin markup, E2EE; query blocks, whiteboards | Synced blocks (cross-page), linked-database views, rollups-as-live-values, Notion AI content, template buttons, wikis' verification badges | Notion features with no note-model counterpart | @@ -51,12 +52,13 @@ Two acquisition paths exist. The design uses both, for different jobs. - **What it is:** an integration (internal, per-workspace) with a bearer token calls the public API: search, page and database retrieval, block-children traversal, comments, users. The integration sees **only** pages/databases explicitly shared with it — inventory completeness is bounded by what was shared, and the import's inventory step must state the share set it could see. - **Prerequisites and constraints:** a workspace admin creates the integration and shares each top-level page/database with it; the token is a credential — §6.5 governs its handling. The API is rate-limited (on the order of 3 requests/second per integration) and paginated; a large workspace inventory is a long, resumable crawl, not a single call. API responses are versioned by a `Notion-Version` header; the importer pins one version per import and records it in the manifest. -- **Coverage:** stable UUIDs for every page, database and block; full database schemas (property types, select options, relation targets, rollup/formula definitions); block trees with types the export flattens; comments (for integrations with comment capabilities, on pages/blocks shared with it); user directory for author provenance. +- **Coverage:** stable UUIDs for every page, database, data source and block; full per-data-source database schemas (property types, select options, relation targets, rollup/formula definitions); block trees with types the export flattens; comments (for integrations with comment capabilities, on pages/blocks shared with it); user directory for author provenance. +- **Data sources (API `2025-09-03`):** a database is a container of one or more **data sources**, each identified by a `data_source_id`. The database object names its data sources; the schema lives on the data source, rows are queried per data source, and a relation property's target is a data source. Inventory therefore includes a **discovery step**: for every database, enumerate its data sources, retrieve each source's schema, and record each `data_source_id` in the manifest (§6) before any row is read. Pinning an older `Notion-Version` does not avoid this model: Notion documents that database reads and queries fail when a second data source is added, so an importer that assumes one schema per database breaks on exactly the databases this step exists to find. - **Coverage gaps:** file blocks carry **expiring** signed URLs — files must be fetched during the import run, never referenced (§4); some block types are API-invisible or read-only representations of richer editor state (synced blocks resolve to their source block's children only at the source); page *sharing* detail (who can read) is not exposed — the API cannot tell the importer who a page was shared with, which is one reason §7 maps access metadata from export/admin observation only where available and otherwise reports it as unknown. ### §1.3 The hybrid rule -Inventory and identity always come from the API crawl (UUIDs, schemas, relations, comments). Content comes from the export when an export of the same workspace is supplied, matched to inventory by UUID where the export flavour carries it and otherwise by the manifest's recorded title+path matching with every uncertain match named in the fidelity report; where no export is supplied, content comes from the API block crawl and the report names the export-only losses (chiefly file permanence risk already handled by §4, and any block types the API represents more lossily). An import that cannot reach the API at all (export-only) is a **degraded mode**: identity falls back to content-hash + path keys in the manifest, re-import idempotency weakens to hash equality, and the fidelity report must headline the degradation — the Logseq Markdown-only rule, restated for Notion. +Inventory and identity always come from the API crawl (UUIDs, per-data-source schemas, relations, comments), and the crawl enumerates every database's data sources (§1.2) — a database whose sources were not enumerated is an incomplete inventory item, counted as such in the fidelity report, never silently treated as single-source. Content comes from the export when an export of the same workspace is supplied, matched to inventory by UUID where the export flavour carries it and otherwise by the manifest's recorded title+path matching with every uncertain match named in the fidelity report; where no export is supplied, content comes from the API block crawl and the report names the export-only losses (chiefly file permanence risk already handled by §4, and any block types the API represents more lossily). An import that cannot reach the API at all (export-only) is a **degraded mode**: identity falls back to content-hash + path keys in the manifest, re-import idempotency weakens to hash equality, and the fidelity report must headline the degradation — the Logseq Markdown-only rule, restated for Notion. ## §2 Entity mapping @@ -76,18 +78,21 @@ Inventory and identity always come from the API crawl (UUIDs, schemas, relations | Notion item | #2048 mapping | Notes | | --- | --- | --- | -| Database | One logical note (body = the database page's own content blocks, if any) + schema provenance claims | The schema (property names, types, select/multi-select options, relation targets, rollup and formula definitions) is recorded verbatim as provenance claims on the database note, so a reader can reconstruct what the database *was* even where values degrade. | -| Database row | Logical note + typed reference to the database note | A row is a page: it has a UUID, a body (its page content), and property values. Row body → revision content exactly like a page; property values → claims (next rows). | +| Database | One logical note (body = the database page's own content blocks, if any) + per-data-source schema provenance claims | A database is a **container** (API `2025-09-03`): it owns one or more data sources and has no single schema of its own. The database note records the container and the identity of each of its data sources; each source's schema is recorded under that source (next row). | +| Data source | Schema provenance claims on the database note, scoped by `data_source_id`, + a data-source identity in the manifest (§6) | The schema (property names, types, select/multi-select options, relation targets, rollup and formula definitions) is recorded verbatim as provenance claims **for that data source**, so a reader can reconstruct what each source *was* even where values degrade. Two sources of one database may carry the same property name with different types or options — the claims are never merged, because the `data_source_id` is part of their identity. A data source is not a note: it has no content of its own beyond its schema, so it takes the database note as its claim surface, exactly as the database's own schema did before this amendment. | +| Database row | Logical note + typed reference to the database note | A row is a page: it has a UUID, a body (its page content), and property values. A row belongs to exactly one data source of its database, and the manifest records which: row body → revision content exactly like a page; property values → claims (next rows), interpreted against **that source's** schema — rows are queried per data source (§1.2), never per database. | | Linked database (a view of a database elsewhere) | A typed reference to the database note at the block position | A linked database is a *view*, not a copy: importing it as a second database would fork identity. Views/filters/sorts are presentation state and are **not** imported; the loss is named once per linked database in the fidelity report. | | Property: title | The row note's name/alias claim source | Every database has exactly one title property; it plays the page-title role. | | Property: rich text, number, checkbox, date, URL, email, phone, status, select, multi-select | Claims on the row note, typed by the schema | Select/status option *definitions* live in the schema claims; values are claim values. Multi-value properties are multi-value claims, not comma-joined strings. | | Property: people | Claims whose values are recorded Notion user references (ID + display name provenance) | Notion users are **not** ID principals. A people value never creates an ID user, group, or grant (§7); it is a provenance fact about the source. | | Property: files & media | Blob references as claim values (§4) | The files themselves are blobs; the claim names the blob. | -| Property: relation | **Typed references** between row notes, recorded in the manifest's reference metadata | The model's reference type for a relation is the relation's schema identity (database + property), so the two directions of a two-way relation resolve to the same reference pair and re-import does not duplicate them. | -| Property: rollup, formula | Derived-value provenance claims: computed display value **plus** the verbatim rollup/formula definition and its inputs | The imported value is a snapshot fact ("Notion computed X at import time from definition D"), never a live computation. If a later ID-side mechanism evaluates formulas, it consumes the recorded definition; the importer does not invent one. | +| Property: relation | **Typed references** between row notes, recorded in the manifest's reference metadata | The model's reference type for a relation is the relation's schema identity (**database + data source + property**), so the two directions of a two-way relation resolve to the same reference pair and re-import does not duplicate them. The relation's target is the data source named in its schema: a relation defined in one source of a database produces references only for rows of that source, and its values resolve only against rows of the target data source. | +| Property: rollup, formula | Derived-value provenance claims: computed display value **plus** the verbatim rollup/formula definition and its inputs | The imported value is a snapshot fact ("Notion computed X at import time from definition D"), never a live computation. If a later ID-side mechanism evaluates formulas, it consumes the recorded definition; the importer does not invent one. A rollup aggregates over a relation property, so its recorded inputs are scoped like the relation's: the rollup lives in one data source and reads rows of the relation's target data source. | | Property: unique ID, created time, last edited time, created by, last edited by | Provenance claims on the row note | System properties are source facts, handled like page timestamps. | | Property: button, verification, Notion AI fields | Not imported as values; named in the fidelity report per database | Actions and AI-generated content have no claim form in the model; the schema claim still records that the property existed. | +**Multi-source databases.** Everything in §2.2 is written per data source precisely so a database with more than one source imports faithfully: discovery enumerates the sources (§1.2), each source's schema is claimed separately, each row is read from and validated against its own source, and relations resolve inside the source pair their schema names. The failure this prevents is conflation — two sources' rows read under one schema, values silently mistyped where property names collide, and relations resolved against the wrong source's rows — and, on the API itself, outright failure of database-level reads once a second source exists (§1.2). A single-source database is the degenerate case of the same rules (one source, discovered the same way), not a separate code path. + ### §2.3 Relations are references, and references are the graph Relations, page mentions, and inline links to pages are all the same underlying thing in Notion — a pointer to a page — and they map to the model's one mechanism, the typed reference, differing only in reference type and authored surface (schema relation vs. in-content mention vs. link). This uniformity is what keeps the imported graph navigable as a graph (backlinks are the reverse index of the same references, computed, not stored twice) and what §3's rewriting relies on. @@ -120,7 +125,7 @@ Rules: every block type is exactly one of **clean** (a model content form exists - **Page links and mentions** (`notion.so//-`, `notion://` forms, export relative paths, and in-text mentions) rewrite to typed references to the target note, using the manifest's UUID → note ID map. A link whose target is outside the import set stays a verbatim external URL **and** is counted in the fidelity report as an externalised link — the importer never rewrites a link to a note it did not import. - **Block links** (URLs with a `#` fragment) rewrite to a typed reference to the owning note **plus** a block selector in the manifest's reference metadata — the Logseq rule: the revision-pin slot names revisions only and is never used for blocks. -- **Database relations** rewrite per §2.2; a relation value naming a row outside the import set is recorded as a provenance claim with the source row's title/UUID and counted as an externalised relation. +- **Database relations** rewrite per §2.2 — the reference type carries the relation's (database, data source, property) identity and the value resolves against rows of the relation's target data source; a relation value naming a row outside the import set is recorded as a provenance claim with the source row's title/UUID and counted as an externalised relation. - **Backlinks** are not imported as data: they are the reverse view of the imported references and must be derivable from them. The acceptance checks (§8) include a backlink spot-check precisely because a missed reference rewrite shows up there first. - Link rewriting happens against the **completed** inventory (two-pass import: inventory and identity first, content second), so forward references to pages imported later in the run resolve. Single-pass rewriting is the known way importer families produce dangling links; it is prohibited by the implementation slicing below. @@ -137,7 +142,7 @@ Export from ID back to Notion is **not** an importer feature and Notion offers n ## §6 Invariants implementation must hold -1. **Manifest first.** Every import produces a persisted manifest before it is considered to have happened: source workspace identity, acquisition paths used and API version pinned, Notion UUID ↔ note ID, block UUID ↔ (note ID, block identity), source file ↔ blob, relation/reference rewrites, per-page outcome (clean / degraded / failed / skipped) with reasons. An import without a manifest is a failed import. +1. **Manifest first.** Every import produces a persisted manifest before it is considered to have happened: source workspace identity, acquisition paths used and API version pinned, Notion UUID ↔ note ID, block UUID ↔ (note ID, block identity), `data_source_id` ↔ (database note ID, data-source identity) with each row's owning data source recorded, source file ↔ blob, relation/reference rewrites, per-page outcome (clean / degraded / failed / skipped) with reasons. An import without a manifest is a failed import. 2. **Idempotent re-import.** Re-running an import over an unchanged workspace changes nothing: identity resolves through the manifest, unchanged content hashes produce no new revisions, and the run reports itself a no-op. Concurrent heads stay visible until an explicit merge (#2048) — a re-import that finds locally-edited content does not overwrite it; it creates its revision alongside and the conflict is a named fidelity-report section, resolved by a person or an explicit merge, never by importer fiat. 3. **No destructive replacement.** The importer never deletes, tombstones, or rewrites an existing ID object to make the source "win". Source-side deletions between imports are *reported* (pages in the manifest, absent from the new inventory) and nothing more, unless a user runs an explicit, separate reconciliation action that this design does not create. 4. **No silent drops — the fidelity report is accounting, not prose.** §6.4. @@ -146,11 +151,11 @@ Export from ID back to Notion is **not** an importer feature and Notion offers n ### §6.1 Identity and duplicate detection -Identity is the Notion UUID (API mode). Two pages with the same title are two notes; one page moved or renamed is the same note (UUID stable across moves/renames — that is the property the whole design leans on, and the corpus in §8 tests it). In degraded export-only mode, identity is (export path + title + content hash) and the report must say duplicate detection is best-effort: two same-title pages in the same folder are the known ambiguous case and are surfaced for a user decision at inventory time, not guessed. +Identity is the Notion UUID (API mode). Two pages with the same title are two notes; one page moved or renamed is the same note (UUID stable across moves/renames — that is the property the whole design leans on, and the corpus in §8 tests it). A data source's identity is its `data_source_id`, scoped to its database: two data sources of one database are two distinct schema identities even where their property names coincide, and a row's identity includes the data source it was read from, recorded in the manifest (§6 invariant 1). In degraded export-only mode, identity is (export path + title + content hash) and the report must say duplicate detection is best-effort: two same-title pages in the same folder are the known ambiguous case and are surfaced for a user decision at inventory time, not guessed. ### §6.2 Repeat / incremental import -Notion has no changes feed the importer can rely on, so "incremental" means: full inventory re-crawl, manifest diff, import only new/changed objects (changed = `last_edited_time` advanced **or** content hash differs — both are checked, because property-only edits move one and block edits can move the other first). The diff categories are exactly: new, changed, unchanged, missing-from-source (§6 invariant 3), and each is a fidelity-report count with a per-item listing available. +Notion has no changes feed the importer can rely on, so "incremental" means: full inventory re-crawl (including re-enumeration of every database's data sources — a source added since the last import is a new inventory object, and a database that gains a second source is a *changed* object whose rows must be re-scoped to their sources), manifest diff, import only new/changed objects (changed = `last_edited_time` advanced **or** content hash differs — both are checked, because property-only edits move one and block edits can move the other first; database schema diffs are computed per data source, never per database). The diff categories are exactly: new, changed, unchanged, missing-from-source (§6 invariant 3), and each is a fidelity-report count with a per-item listing available. ### §6.3 Recovery from partial imports @@ -183,7 +188,7 @@ Where this touches a parent decision: it does not amend one. #2048's group `Read A representative Notion workspace, built once as a fixture (export archive + recorded API responses, so the corpus runs offline and deterministically), containing at minimum: - **Pages/blocks:** a page nesting every clean and degraded block type from §2.5 at least twice, at depth ≥ 3; toggles with rich children; a synced block referenced from two other pages; child pages at depth ≥ 2; two pages with identical titles in different parents and in the same parent. -- **Databases:** a database exercising every property type in §2.2, including a two-way relation to a second database, a rollup over that relation, a formula combining properties, a linked-database view placed on a page, and rows whose bodies contain blocks, files and relations to rows outside the corpus set (the externalised-relation case). +- **Databases:** a database exercising every property type in §2.2, including a two-way relation to a second database, a rollup over that relation, a formula combining properties, a linked-database view placed on a page, and rows whose bodies contain blocks, files and relations to rows outside the corpus set (the externalised-relation case). Plus a **multi-source database**: one database container holding two data sources whose schemas differ — a property name present in both sources with different types, a relation defined in only one source (targeting a data source of the second database), and rows in both sources — so per-source discovery, schema scoping, row queries and relation resolution (§1.2, §2.2) are all exercised against the conflation failure. - **Files:** the same image attached on two pages and as a row property; a file large enough to exercise staged fetch; one deliberately unfetchable file (expired URL) for the missing-resource path. - **Comments:** a page with a discussion, replies, a resolved discussion, and a block-anchored comment; a page the fixture integration cannot see comments on (coverage accounting case). - **Identity/repeat:** the corpus imported twice (second run must be a no-op); the corpus re-imported after a source-side rename and move (identity must follow the UUID); after a source-side property-only edit and a block-only edit (§6.2's two change signals); after a local ID-side edit to an imported note (conflict path, §6 invariant 2); after a source-side deletion (report-only path, §6 invariant 3). @@ -198,6 +203,7 @@ A representative Notion workspace, built once as a fixture (export archive + rec 5. Read-authority: for every imported object, a read-resolution probe returns the result predicted by the ruled order given the test world's grants — and for the page the fixture had published to the web, the probe confirms **no** grant was created by the import (§7 point 3). 6. Missing-resource run: the unfetchable file's page is marked degraded, the file is named in the report, and no stored content references the expired URL (§4). 7. Comments: every fixture comment the acquisition path could see exists as a claim on the expected note/block; every page it could not is listed in the comments-coverage section (§2.4). +8. Multi-source: for the multi-source fixture database, the manifest records both `data_source_id`s under the one database note; the two sources' schema claims are disjoint (the colliding property name appears once per source, with each source's type); every row's claims validate against its own source's schema and no row's against the other's; and the relation defined in only one source produces typed references for rows of that source only, resolving to rows of its target data source (§1.2, §2.2, §3). ## Open questions — Drew-owned, preserved, not decided here @@ -229,9 +235,9 @@ Options A and B are retained as the degraded modes of C (§1.3), not as separate In dependency order; each slice is independently landable and testable against §8's corpus subset: -1. **Manifest + inventory:** manifest store and staged-state machine (§6.3), API inventory crawl with share-set accounting (§1.2), edition/version recording. +1. **Manifest + inventory:** manifest store and staged-state machine (§6.3), API inventory crawl with share-set accounting and per-database data-source enumeration (§1.2), edition/version recording. 2. **Page/block core:** block tree → revision content for the clean classes of §2.5, identity mapping, two-pass link rewriting (§3), files (§4). -3. **Databases:** schema claims, row claims, relation references, rollup/formula provenance (§2.2). +3. **Databases:** per-data-source schema claims, row claims scoped to their row's data source, relation references, rollup/formula provenance (§2.2). 4. **Comments + degradation completion:** comment claims (§2.4), the unsupported/degraded classes of §2.5, export-content matching for hybrid mode (§1.3). 5. **Fidelity report + re-import:** report generation with inventory reconciliation (§6.4), incremental diff and conflict surfacing (§6.2), corpus completion and the §8 acceptance harness. From 9f57c38302757788be8f1e0bba6ab4ec98df3395 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 01:27:11 -0600 Subject: [PATCH 2/4] docs(id): address Codex P2s on #8558 - row identity is page UUID alone; preserve per-source title/description --- doc/2026-11-10_design_id6436.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/2026-11-10_design_id6436.md b/doc/2026-11-10_design_id6436.md index 498f8c4709..dbe60bc8c3 100644 --- a/doc/2026-11-10_design_id6436.md +++ b/doc/2026-11-10_design_id6436.md @@ -79,7 +79,7 @@ Inventory and identity always come from the API crawl (UUIDs, per-data-source sc | Notion item | #2048 mapping | Notes | | --- | --- | --- | | Database | One logical note (body = the database page's own content blocks, if any) + per-data-source schema provenance claims | A database is a **container** (API `2025-09-03`): it owns one or more data sources and has no single schema of its own. The database note records the container and the identity of each of its data sources; each source's schema is recorded under that source (next row). | -| Data source | Schema provenance claims on the database note, scoped by `data_source_id`, + a data-source identity in the manifest (§6) | The schema (property names, types, select/multi-select options, relation targets, rollup and formula definitions) is recorded verbatim as provenance claims **for that data source**, so a reader can reconstruct what each source *was* even where values degrade. Two sources of one database may carry the same property name with different types or options — the claims are never merged, because the `data_source_id` is part of their identity. A data source is not a note: it has no content of its own beyond its schema, so it takes the database note as its claim surface, exactly as the database's own schema did before this amendment. | +| Data source | Schema provenance claims plus the source's own title and description as provenance claims, on the database note, scoped by `data_source_id`, + a data-source identity in the manifest (§6) | The schema (property names, types, select/multi-select options, relation targets, rollup and formula definitions) is recorded verbatim as provenance claims **for that data source**, so a reader can reconstruct what each source *was* even where values degrade. Two sources of one database may carry the same property name with different types or options — the claims are never merged, because the `data_source_id` is part of their identity. A data source is not a note, so it takes the database note as its claim surface, exactly as the database's own schema did before this amendment — but it is not content-free beyond its schema: the data-source object carries its own rich-text title and description, and both are recorded verbatim as source-scoped provenance claims alongside the schema (preserving the database's own description or the row pages' titles does not preserve these per-source values). | | Database row | Logical note + typed reference to the database note | A row is a page: it has a UUID, a body (its page content), and property values. A row belongs to exactly one data source of its database, and the manifest records which: row body → revision content exactly like a page; property values → claims (next rows), interpreted against **that source's** schema — rows are queried per data source (§1.2), never per database. | | Linked database (a view of a database elsewhere) | A typed reference to the database note at the block position | A linked database is a *view*, not a copy: importing it as a second database would fork identity. Views/filters/sorts are presentation state and are **not** imported; the loss is named once per linked database in the fidelity report. | | Property: title | The row note's name/alias claim source | Every database has exactly one title property; it plays the page-title role. | @@ -151,7 +151,7 @@ Export from ID back to Notion is **not** an importer feature and Notion offers n ### §6.1 Identity and duplicate detection -Identity is the Notion UUID (API mode). Two pages with the same title are two notes; one page moved or renamed is the same note (UUID stable across moves/renames — that is the property the whole design leans on, and the corpus in §8 tests it). A data source's identity is its `data_source_id`, scoped to its database: two data sources of one database are two distinct schema identities even where their property names coincide, and a row's identity includes the data source it was read from, recorded in the manifest (§6 invariant 1). In degraded export-only mode, identity is (export path + title + content hash) and the report must say duplicate detection is best-effort: two same-title pages in the same folder are the known ambiguous case and are surfaced for a user decision at inventory time, not guessed. +Identity is the Notion UUID (API mode). Two pages with the same title are two notes; one page moved or renamed is the same note (UUID stable across moves/renames — that is the property the whole design leans on, and the corpus in §8 tests it). A data source's identity is its `data_source_id`, scoped to its database: two data sources of one database are two distinct schema identities even where their property names coincide, and a row's identity is its page UUID alone — the data source it was read from is recorded in the manifest (§6 invariant 1) as mutable membership metadata used for schema interpretation, never as part of the row's identity: Notion can move an existing page to a different data source while retaining its page_id, so a row that moves sources is the same note on re-import (its manifest membership is updated), not a missing object plus a new object. In degraded export-only mode, identity is (export path + title + content hash) and the report must say duplicate detection is best-effort: two same-title pages in the same folder are the known ambiguous case and are surfaced for a user decision at inventory time, not guessed. ### §6.2 Repeat / incremental import From ccb366933e06e791b96d28e3520e518002245ee7 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 02:50:37 -0600 Subject: [PATCH 3/4] docs(id): key relation identity by data source + property, not parent database (#8555) --- doc/2026-11-10_design_id6436.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/2026-11-10_design_id6436.md b/doc/2026-11-10_design_id6436.md index dbe60bc8c3..e28b4f2dbb 100644 --- a/doc/2026-11-10_design_id6436.md +++ b/doc/2026-11-10_design_id6436.md @@ -86,7 +86,7 @@ Inventory and identity always come from the API crawl (UUIDs, per-data-source sc | Property: rich text, number, checkbox, date, URL, email, phone, status, select, multi-select | Claims on the row note, typed by the schema | Select/status option *definitions* live in the schema claims; values are claim values. Multi-value properties are multi-value claims, not comma-joined strings. | | Property: people | Claims whose values are recorded Notion user references (ID + display name provenance) | Notion users are **not** ID principals. A people value never creates an ID user, group, or grant (§7); it is a provenance fact about the source. | | Property: files & media | Blob references as claim values (§4) | The files themselves are blobs; the claim names the blob. | -| Property: relation | **Typed references** between row notes, recorded in the manifest's reference metadata | The model's reference type for a relation is the relation's schema identity (**database + data source + property**), so the two directions of a two-way relation resolve to the same reference pair and re-import does not duplicate them. The relation's target is the data source named in its schema: a relation defined in one source of a database produces references only for rows of that source, and its values resolve only against rows of the target data source. | +| Property: relation | **Typed references** between row notes, recorded in the manifest's reference metadata | The model's reference type for a relation is the relation's schema identity (**data source + property** — the `data_source_id` and the property's ID; the parent database is **not** part of it, so a data source moved to another database keeps the same reference type for its relations), so the two directions of a two-way relation resolve to the same reference pair and re-import does not duplicate them. The relation's target is the data source named in its schema: a relation defined in one source of a database produces references only for rows of that source, and its values resolve only against rows of the target data source. | | Property: rollup, formula | Derived-value provenance claims: computed display value **plus** the verbatim rollup/formula definition and its inputs | The imported value is a snapshot fact ("Notion computed X at import time from definition D"), never a live computation. If a later ID-side mechanism evaluates formulas, it consumes the recorded definition; the importer does not invent one. A rollup aggregates over a relation property, so its recorded inputs are scoped like the relation's: the rollup lives in one data source and reads rows of the relation's target data source. | | Property: unique ID, created time, last edited time, created by, last edited by | Provenance claims on the row note | System properties are source facts, handled like page timestamps. | | Property: button, verification, Notion AI fields | Not imported as values; named in the fidelity report per database | Actions and AI-generated content have no claim form in the model; the schema claim still records that the property existed. | @@ -125,7 +125,7 @@ Rules: every block type is exactly one of **clean** (a model content form exists - **Page links and mentions** (`notion.so//-`, `notion://` forms, export relative paths, and in-text mentions) rewrite to typed references to the target note, using the manifest's UUID → note ID map. A link whose target is outside the import set stays a verbatim external URL **and** is counted in the fidelity report as an externalised link — the importer never rewrites a link to a note it did not import. - **Block links** (URLs with a `#` fragment) rewrite to a typed reference to the owning note **plus** a block selector in the manifest's reference metadata — the Logseq rule: the revision-pin slot names revisions only and is never used for blocks. -- **Database relations** rewrite per §2.2 — the reference type carries the relation's (database, data source, property) identity and the value resolves against rows of the relation's target data source; a relation value naming a row outside the import set is recorded as a provenance claim with the source row's title/UUID and counted as an externalised relation. +- **Database relations** rewrite per §2.2 — the reference type carries the relation's (data source, property) identity and the value resolves against rows of the relation's target data source; a relation value naming a row outside the import set is recorded as a provenance claim with the source row's title/UUID and counted as an externalised relation. - **Backlinks** are not imported as data: they are the reverse view of the imported references and must be derivable from them. The acceptance checks (§8) include a backlink spot-check precisely because a missed reference rewrite shows up there first. - Link rewriting happens against the **completed** inventory (two-pass import: inventory and identity first, content second), so forward references to pages imported later in the run resolve. Single-pass rewriting is the known way importer families produce dangling links; it is prohibited by the implementation slicing below. @@ -151,7 +151,7 @@ Export from ID back to Notion is **not** an importer feature and Notion offers n ### §6.1 Identity and duplicate detection -Identity is the Notion UUID (API mode). Two pages with the same title are two notes; one page moved or renamed is the same note (UUID stable across moves/renames — that is the property the whole design leans on, and the corpus in §8 tests it). A data source's identity is its `data_source_id`, scoped to its database: two data sources of one database are two distinct schema identities even where their property names coincide, and a row's identity is its page UUID alone — the data source it was read from is recorded in the manifest (§6 invariant 1) as mutable membership metadata used for schema interpretation, never as part of the row's identity: Notion can move an existing page to a different data source while retaining its page_id, so a row that moves sources is the same note on re-import (its manifest membership is updated), not a missing object plus a new object. In degraded export-only mode, identity is (export path + title + content hash) and the report must say duplicate detection is best-effort: two same-title pages in the same folder are the known ambiguous case and are surfaced for a user decision at inventory time, not guessed. +Identity is the Notion UUID (API mode). Two pages with the same title are two notes; one page moved or renamed is the same note (UUID stable across moves/renames — that is the property the whole design leans on, and the corpus in §8 tests it). A data source's identity is its `data_source_id` alone, independent of its parent database: Notion allows a data source to move between databases (the update-data-source `parent.database_id` change) while its `data_source_id`, property IDs and relation values remain unchanged, so the parent database is recorded in the manifest as mutable membership metadata (updated on re-import when a source has moved), never as part of the source's identity — and relation identity follows the same rule (§2.2): keyed by data source + property, so a moved source's relations keep their reference type rather than being re-minted under the new database. Two data sources of one database are two distinct schema identities even where their property names coincide, and a row's identity is its page UUID alone — the data source it was read from is recorded in the manifest (§6 invariant 1) as mutable membership metadata used for schema interpretation, never as part of the row's identity: Notion can move an existing page to a different data source while retaining its page_id, so a row that moves sources is the same note on re-import (its manifest membership is updated), not a missing object plus a new object. In degraded export-only mode, identity is (export path + title + content hash) and the report must say duplicate detection is best-effort: two same-title pages in the same folder are the known ambiguous case and are surfaced for a user decision at inventory time, not guessed. ### §6.2 Repeat / incremental import From 0ecd2666e616383432dc191f00642fde9a1eb1a2 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 02:58:57 -0600 Subject: [PATCH 4/4] docs(id): canonicalize two-way relation identity via dual_property.synced_property_id; define source-move graph updates (#8555) --- doc/2026-11-10_design_id6436.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/2026-11-10_design_id6436.md b/doc/2026-11-10_design_id6436.md index e28b4f2dbb..12886aefa5 100644 --- a/doc/2026-11-10_design_id6436.md +++ b/doc/2026-11-10_design_id6436.md @@ -86,7 +86,7 @@ Inventory and identity always come from the API crawl (UUIDs, per-data-source sc | Property: rich text, number, checkbox, date, URL, email, phone, status, select, multi-select | Claims on the row note, typed by the schema | Select/status option *definitions* live in the schema claims; values are claim values. Multi-value properties are multi-value claims, not comma-joined strings. | | Property: people | Claims whose values are recorded Notion user references (ID + display name provenance) | Notion users are **not** ID principals. A people value never creates an ID user, group, or grant (§7); it is a provenance fact about the source. | | Property: files & media | Blob references as claim values (§4) | The files themselves are blobs; the claim names the blob. | -| Property: relation | **Typed references** between row notes, recorded in the manifest's reference metadata | The model's reference type for a relation is the relation's schema identity (**data source + property** — the `data_source_id` and the property's ID; the parent database is **not** part of it, so a data source moved to another database keeps the same reference type for its relations), so the two directions of a two-way relation resolve to the same reference pair and re-import does not duplicate them. The relation's target is the data source named in its schema: a relation defined in one source of a database produces references only for rows of that source, and its values resolve only against rows of the target data source. | +| Property: relation | **Typed references** between row notes, recorded in the manifest's reference metadata | The model's reference type for a relation is the relation's schema identity (**data source + property** — the `data_source_id` and the property's ID; the parent database is **not** part of it, so a data source moved to another database keeps the same reference type for its relations), For a two-way (dual) relation the two sides carry **different** (data source, property) pairs, so neither side's pair alone is the shared identity: the canonical reference type is the unordered pair of both sides' (data_source_id, property_id), joined through the relation schema's `dual_property.synced_property_id`, which names the matching property on the target data source; the canonical direction is the side whose (data_source_id, property_id) sorts first, and both sides import as that one reference type, so re-import does not duplicate them. A one-way relation's reference type is its single (data source, property) pair. The relation's target is the data source named in its schema: a relation defined in one source of a database produces references only for rows of that source, and its values resolve only against rows of the target data source. | | Property: rollup, formula | Derived-value provenance claims: computed display value **plus** the verbatim rollup/formula definition and its inputs | The imported value is a snapshot fact ("Notion computed X at import time from definition D"), never a live computation. If a later ID-side mechanism evaluates formulas, it consumes the recorded definition; the importer does not invent one. A rollup aggregates over a relation property, so its recorded inputs are scoped like the relation's: the rollup lives in one data source and reads rows of the relation's target data source. | | Property: unique ID, created time, last edited time, created by, last edited by | Provenance claims on the row note | System properties are source facts, handled like page timestamps. | | Property: button, verification, Notion AI fields | Not imported as values; named in the fidelity report per database | Actions and AI-generated content have no claim form in the model; the schema claim still records that the property existed. | @@ -151,7 +151,7 @@ Export from ID back to Notion is **not** an importer feature and Notion offers n ### §6.1 Identity and duplicate detection -Identity is the Notion UUID (API mode). Two pages with the same title are two notes; one page moved or renamed is the same note (UUID stable across moves/renames — that is the property the whole design leans on, and the corpus in §8 tests it). A data source's identity is its `data_source_id` alone, independent of its parent database: Notion allows a data source to move between databases (the update-data-source `parent.database_id` change) while its `data_source_id`, property IDs and relation values remain unchanged, so the parent database is recorded in the manifest as mutable membership metadata (updated on re-import when a source has moved), never as part of the source's identity — and relation identity follows the same rule (§2.2): keyed by data source + property, so a moved source's relations keep their reference type rather than being re-minted under the new database. Two data sources of one database are two distinct schema identities even where their property names coincide, and a row's identity is its page UUID alone — the data source it was read from is recorded in the manifest (§6 invariant 1) as mutable membership metadata used for schema interpretation, never as part of the row's identity: Notion can move an existing page to a different data source while retaining its page_id, so a row that moves sources is the same note on re-import (its manifest membership is updated), not a missing object plus a new object. In degraded export-only mode, identity is (export path + title + content hash) and the report must say duplicate detection is best-effort: two same-title pages in the same folder are the known ambiguous case and are surfaced for a user decision at inventory time, not guessed. +Identity is the Notion UUID (API mode). Two pages with the same title are two notes; one page moved or renamed is the same note (UUID stable across moves/renames — that is the property the whole design leans on, and the corpus in §8 tests it). A data source's identity is its `data_source_id` alone, independent of its parent database: Notion allows a data source to move between databases (the update-data-source `parent.database_id` change) while its `data_source_id`, property IDs and relation values remain unchanged, so the parent database is recorded in the manifest as mutable membership metadata (updated on re-import when a source has moved), never as part of the source's identity — and relation identity follows the same rule (§2.2): keyed by data source + property, so a moved source's relations keep their reference type rather than being re-minted under the new database. When a source has moved databases since the previous import, re-import records its current schema claims on the new database note and supersedes the prior current claims on the old database note — the superseded claims remain in the claim history as provenance of the earlier import, with the move named in the manifest and the fidelity report — and updates each of its rows' membership references to the new database note, while the rows keep their page-UUID identity throughout. Two data sources of one database are two distinct schema identities even where their property names coincide, and a row's identity is its page UUID alone — the data source it was read from is recorded in the manifest (§6 invariant 1) as mutable membership metadata used for schema interpretation, never as part of the row's identity: Notion can move an existing page to a different data source while retaining its page_id, so a row that moves sources is the same note on re-import (its manifest membership is updated), not a missing object plus a new object. In degraded export-only mode, identity is (export path + title + content hash) and the report must say duplicate detection is best-effort: two same-title pages in the same folder are the known ambiguous case and are surfaced for a user decision at inventory time, not guessed. ### §6.2 Repeat / incremental import