From c8d1d40722d85dae0aaa302e9f3363596fc503f6 Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Sun, 8 Nov 2026 16:17:25 -0600 Subject: [PATCH 1/3] docs(id): record Evernote importer design (#5846) --- doc/2026-11-08_design_id5846.md | 129 ++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 doc/2026-11-08_design_id5846.md diff --git a/doc/2026-11-08_design_id5846.md b/doc/2026-11-08_design_id5846.md new file mode 100644 index 0000000000..639febbe25 --- /dev/null +++ b/doc/2026-11-08_design_id5846.md @@ -0,0 +1,129 @@ +# Design: Evernote importer into the #2048 object model + +- **Date:** 2026-11-08 +- **Status:** decision record — import design only; no importer implementation is included. +- **Issue:** [#5846](https://github.com/developing-today/code/issues/5846), under parent programme [#5678](https://github.com/developing-today/code/issues/5678) and epic [#2056](https://github.com/developing-today/code/issues/2056). +- **Object-model baseline:** #2048 is **CLOSED / COMPLETED** (2026-11-07); its decision record landed in [PR #3885](https://github.com/developing-today/code/pull/3885) as [`doc/2026-11-01_design_id2048.md`](2026-11-01_design_id2048.md). Stable note identity/revisions landed in [PR #3908](https://github.com/developing-today/code/pull/3908); signed `note.link` events and the deterministic head-based backlink projection landed in [PR #4131](https://github.com/developing-today/code/pull/4131), documented in [`doc/2026-11-02T04-52-00Z_feature_note_link_backlink_projection/`](2026-11-02T04-52-00Z_feature_note_link_backlink_projection/2026-11-02T04-52-00Z_feature_note_link_backlink_projection.md). This design consumes that settled state; it does not re-decide it. +- **Related designs:** #5839 owns the still-open content-model choices; #5844 owns the still-open attachment/media cluster. This record does not introduce a collection model or an attachment UI/API in their place. + +## Decision summary + +Import a user-selected ENEX export as a **one-shot, manifest-backed import set**. Each ENEX `` becomes a new ID logical note via `note.create` carrying its first content (that event is also the first revision); the ENEX title becomes an alias/name claim, tags become tag claims, and source timestamps/attributes are provenance rather than ID event times. Decode each resource into content-addressed blob bytes and preserve its source metadata in the import manifest. Normalize the ENML body to a sanitized HTML fragment for the note's content blob, retaining the original ENML as source provenance so unsupported details are recoverable and reportable. + +ENEX supplies neither a stable note ID nor notebook membership in its documented DTD. Therefore identity is ID's, not Evernote's: the import manifest assigns each source entry a local row identity. An identical re-import into the same import set is a no-op. A changed export cannot safely be reconciled automatically; the user must confirm which entries revise existing ID notes and which are new. Titles, timestamps and body hashes may suggest matches but never silently merge notes. Evernote-internal links are converted to `note.link` only after an explicit target mapping; otherwise their authored surface is retained as unresolved, as #2048 requires. + +## 1. Scope and decisions already owned elsewhere + +This record decides the mapping of an Evernote export into the settled note model. It does not implement import, choose when implementation starts, provide continuous sync, or re-decide #5678's product/access rulings. In particular: + +- Stable logical note IDs, immutable revision history, explicit multi-head merges, authored link surfaces and optional revision pins follow #2048 and its landed phases. Link edges are signed `note.link` events; backlinks are derived from asserting source-revision heads, not stored as a second source of truth. +- Imported notes inherit the destination's existing read/write policy. The parent #5678 read default and resolution order (object → user default → server configuration → public) are unchanged; import does not grant access. +- Evernote's export limitations make some source relationships unresolvable. The resulting unresolved state is a documented degradation, not a change to ID's link model or resolver (#2259). +- No ID collection/notebook type is introduced here. The content-model design #5839 is still open. The attachment representation beyond extracted blobs and manifest provenance remains with #5844; this record does not claim a general attachment-viewer contract. + +## 2. Source format and obtaining an export + +Use **ENEX**, not a scrape of Evernote's UI or an account API. Evernote's current help guide directs users to its Mac or Windows desktop app, where they select notes or a notebook and choose **Export… → ENEX**. It supports exporting selected notes or an entire notebook; the exact UI and export-size limits are client-version details, not importer constants. The exported file is a flat `` containing one or more `` records. + +The first-party Export DTD defines each note as title, ENML content, optional created/updated timestamps, repeated tags, optional note attributes and zero or more resources. It has **no note GUID/ID and no notebook-membership field**. Evernote's own import guide also says notebook structures are not preserved by ENEX import. Consequently: + +1. The user creates an import set and supplies a label for the exported selection (for example, the source notebook name). The label is provenance only; it is not treated as a complete notebook hierarchy or an ID collection. +2. A multi-notebook selection is allowed only as a flat import set. Since ENEX does not identify the original notebook per note, the importer reports that per-note notebook placement is unavailable; it must not invent it. +3. The export contains note snapshots, not an Evernote revision history. Import makes no claim to recover prior Evernote versions. +4. ENEX timestamps use the DTD's UTC/Zulu profile when present. Missing timestamps remain missing; the importer does not synthesize source dates from file or import time. + +## 3. Entity and content mapping + +| ENEX source | ID mapping | Decision and fidelity rule | +| --- | --- | --- | +| `` | New logical note: `note.create` with its first content/revision | The create event's ID is the stable logical note ID and first revision ID. ENEX has no stable note ID to reuse. | +| `` | Alias/name claim on the logical note | Names are claims, never identity; duplicate or contested titles remain visible as such. | +| `<content>` (ENML) | Sanitized, normalized HTML fragment in the revision content blob; original ENML retained as source provenance | Preserve supported semantic content. Unsupported constructs produce an explicit placeholder and a fidelity-report entry; never silently disappear. The normalized body format is local to this importer, not a new universal ID content-model decision. | +| Repeated `<tag>` | One ID tag claim per source tag | Preserve exact tag text and case. Re-import does not create duplicate live claims. | +| `<created>`, `<updated>`, `<subject-date>`, `<author>`, `<source>`, `<source-url>`, `<source-application>` | Import provenance claims/manifest fields | These describe the source note; they are not ID event timestamps, revision parents, or identity. | +| `<resource>` | Decoded binary content blob plus an import-manifest resource row | Preserve bytes, declared MIME type, filename and available dimensions/duration/recognition/alternate data. Repeated identical bytes may share the content-addressed blob; resource rows remain distinct. Exact media presentation/reference syntax follows #5844. | +| `<en-media hash=…>` | Resource reference when its hash matches a resource in this export | Verify the Evernote resource hash against decoded bytes before linking. Missing or mismatched targets stay unresolved and are reported. | +| `evernote:///view/…` link | Explicitly mapped ID `note.link`, otherwise unresolved source link | ENEX does not provide a stable note ID-to-export-entry map, and Evernote does not promise cross-account link portability. Never guess a target from title or URL text. | +| Note absent from a later export | No deletion or tombstone | Absence may mean a partial export. Report it as absent; ID content is never removed by omission. | + +ENML is restricted markup, not arbitrary HTML. Parse it as XML with external entity/network resolution disabled. Normalize only the supported semantic subset (paragraphs, headings, lists, basic emphasis, links, checkboxes, simple tables and media placeholders) into a deterministic HTML fragment. Preserve the original ENML bytes in source provenance. Convert `<en-todo>` to a visible checkbox representation; do not infer a new task object. Preserve `<en-crypt>` as encrypted source material plus a visible “not decrypted” placeholder; the importer never handles passphrases or claims decrypted content. Unknown or unsupported elements/attributes are named in the fidelity report, and the preserved source remains available for later conversion. + +Resource bytes are decoded from ENEX base64 and checked before storage. ENEX's `<data>` may contain whitespace; it must be ignored for base64 decoding. For `<en-media>`, Evernote documents the `hash` as the MD5 of resource bytes. The importer verifies that source-level reference before substituting an ID blob reference. A resource that cannot be decoded or verified is reported as unresolved/refused, not replaced by an empty or guessed attachment. OCR/recognition data and alternate representations are retained as provenance; they are not silently promoted to searchable text or a new object type. + +## 4. Import manifest, identity and deduplication + +The manifest is required for an import to be considered successful. It records a generated `import_set_id`, the export/package digest, one manifest row per ENEX note entry, the assigned ID note ID, source title and timestamps, canonical source-entry fingerprint, original ENML provenance, resource mappings, and the user's confirmed match decisions. Persist it as an **exportable, user-owned sidecar** alongside the selected ENEX source, not as a new shared ID note/collection type. The ID event graph remains canonical. The user must carry the sidecar when moving an import set to another device; if it is missing, start a new import set and warn that automatic deduplication/matching is unavailable. The manifest is an import ledger, not another canonical note/link graph. + +Because the Export DTD has no stable note ID, deduplication is conservative: + +1. Re-importing the exact same export digest into the same `import_set_id` is a no-op. +2. Re-importing an entry whose canonical source fingerprint is already recorded in that set is a no-op for that entry. +3. For a changed export, the importer may propose candidates using stable-looking fields such as `created`, title, source URL and content similarity, but these are **hints only**. The user must explicitly map each changed entry to an existing import row (revise) or mark it as a new note. Missing or ambiguous matches block that entry; no title/content-only auto-merge occurs. +4. Once the user confirms a match, a changed source snapshot creates a signed revision on the same logical note, parented from the last imported revision. If ID-side edits have created another head, preserve both heads and report that an explicit ID merge is required; never last-write-wins. +5. A source entry absent from a later export is reported but not deleted. Cross-import-set matching is only a suggestion and never automatic; identical body bytes do not prove two source notes are the same note. + +This trades automatic reconciliation for avoiding a silent duplicate or destructive merge where the source format contains no immutable key. An operator can always start a new import set; doing so intentionally creates new ID note identities. + +## 5. Link and access behavior + +Ordinary safe web links remain links. An Evernote-internal link can become a signed ID `note.link` only when the user confirms the target in the current import set (or explicitly selects an existing ID note). The event names the stable source note ID, the source revision asserting the link, the confirmed stable target note ID, the authored surface, and no revision pin unless the user explicitly chooses an exact target revision. The link projection and backlink behavior are exactly #3816's landed semantics. + +Without that mapping, preserve the authored display surface as inert unresolved text/link and count it in the import report. Do not create placeholder notes, resolve by title, dereference private targets, or assume an Evernote URI still works outside its originating account. Inaccessible targets remain subject to #2048's authorization filtering; an import link or source URL does not grant read authority. + +## 6. Fidelity report and explicit degradation + +Every entry and resource ends in one named state: `imported`, `unchanged`, `needs_match`, `unresolved_link`, `unresolved_resource`, `degraded`, or `refused`, with a reason and source location. The report includes source/manifest counts and makes a mismatch between source entries and accounted entries fail the import. + +The following are explicit v1 limits: + +- ENEX has no stable note ID, notebook membership, or revision history. Stable re-import across edited exports requires user-confirmed matching; notebook hierarchy and old versions cannot be reconstructed from ENEX. +- Evernote internal note links are unresolved unless explicitly mapped. Evernote's public docs do not guarantee those URLs remain valid after cross-account import. +- Encrypted text is not decrypted. Unsupported ENML constructs and metadata without an ID-model mapping remain in the preserved source and are reported; they are not represented as if fully imported. +- Resource bytes and metadata are retained, but presentation beyond blob extraction is subject to the separately owned #5844 media design. Until that contract is settled, an importer must not claim an unsupported media type is renderable. +- Evernote notebook organization is not converted into a new collection model. The source-set label is manifest provenance only while #5839's content model remains unsettled. + +## 7. Alternatives considered + +| Option | Decision | +| --- | --- | +| Store each ENEX note as a standalone `document.put` or file | Reject. It would bypass #2048's stable logical note identity, revision graph and typed link/backlink model. | +| Reuse ENEX data as ID identity, or deduplicate automatically on title/content | Reject. The documented ENEX note schema contains no stable note identifier; names and content can collide or change. ID mints identity and the user confirms changed-entry mappings. | +| Convert everything directly to Markdown and discard ENML | Reject. ENML can contain richer structure/resources than a Markdown-only mapping, so this would silently lose source information. A normalized body plus retained source and an explicit report is safer; this is not a decision about the global export format in #5678. | +| Resolve Evernote internal URLs by title or by guessed GUID | Reject. The ENEX file lacks a reliable note-entry key and Evernote does not promise cross-account portability. Preserve unresolved surface unless a user confirms the target. | +| Emulate Evernote sync or import all account history | Reject for this design. ENEX is a snapshot export and #2048 retains concurrent revision heads; continuous sync/history require separate design and implementation decisions. | +| Invent notebook collections or a generic media API here | Reject. #5839 owns content-model choices and #5844 owns the attachment/media cluster; this importer uses manifest provenance and blobs without pre-empting either. | + +## 8. Invariants for implementation + +1. Each imported ENEX note gets an ID-minted stable logical note ID; title, source GUID-like URL fragments, tags and filenames never become note identity. +2. Note content is an immutable revision blob. Re-import never overwrites a revision; concurrent heads remain visible until an explicit merge. +3. An exact re-import into the same import set is idempotent. A changed source entry cannot revise or duplicate a note without a user-confirmed mapping. +4. Every source note, tag, resource and body link is either mapped, unchanged, unresolved, degraded or refused with an explanation. No silent drops, fabricated targets or empty attachment substitutions. +5. A confirmed internal link targets stable ID note identities and is represented by #3816's signed `note.link`; backlinks are derived from selected source-revision heads. +6. The resource bytes stored for an accepted attachment hash-match the decoded ENEX bytes; an `<en-media>` reference is linked only when its source hash verifies. +7. Import does not delete notes absent from an export, decrypt content, infer notebook hierarchy, invent collection/media APIs, or change the parent read/write authority rules. +8. Original ENML and unsupported source metadata remain recoverable from the manifest/provenance record, and the fidelity report identifies what the normalized body could not represent. + +## 9. Test corpus and oracle + +The oracle is the canonical import manifest plus ID note/link projections and blob hashes. For each fixture, the test compares the accounted source-entry set, stable note IDs, alias/tag claims, revision heads, link targets/surfaces/backlinks, report states, and resource byte hashes. Invalid XML/base64/hash cases must return named errors; a passing test may not rely on visual inspection alone. + +- **Schema/minimal cases:** one note; absent optional timestamps/attributes; multiple notes; whitespace in base64; valid UTC timestamps; XML entities and Unicode titles/body. +- **Identity and dedupe:** duplicate titles; same creation timestamp; byte-identical but distinct note entries; same export imported twice (no new events); reordered export; changed body/title; missing `created`; cross-source-set identical note; ambiguous and user-confirmed matches; new-note choice; omitted source note (no deletion). +- **ENML conversion:** paragraphs/headings, nested lists, emphasis, links, simple tables, checkboxes, unknown elements/attributes, malformed XML, external-entity attempt, and `<en-crypt>`; verify deterministic normalized body and preserved source/report entries. +- **Links:** safe web link; Evernote URI with no match; URI with ambiguous candidates; user-confirmed target; a link to a note outside the export; verify unresolved surface and that only confirmed mappings emit `note.link` events/backlinks. +- **Resources:** PNG, JPEG, PDF, audio and opaque binary; one resource referenced twice; duplicate bytes across notes; orphan resource; missing media target; mismatched MD5; invalid/oversize base64; recognition/alternate data. Accepted bytes must compare equal by SHA-256 after blob storage; unresolved/refused cases must appear in the report. +- **Revision behavior:** first import creates a note; confirmed changed re-import adds a revision to the same note; concurrent ID-side head remains separate; no implicit merge or last-writer-wins selection. + +## 10. Implementation timing and splits + +Implementation timing is separate from this record, as #5846 states. No additional issue is filed by this design: it makes one per-importer decision record, while #5839 and #5844 already own the cross-import content and media decisions. If a later implementation proves import parsing, match review, media conversion, or report generation is independently too large, split it then and link the issue here and on #5846; do not turn this record into an implementation packet. + +## References + +- Evernote Help: [Export Notes and Notebooks as ENEX or HTML](https://help.evernote.com/hc/en-us/articles/209005557-Export-Notes-and-Notebooks-as-ENEX-or-HTML) — desktop export workflow and supported selection. +- Evernote Help: [How to Import Notes and Notebooks](https://help.evernote.com/hc/en-us/articles/360035153274-How-To-Import-Notes-and-Notebooks) — tags and notebook-structure behavior on import. +- Evernote Developer: [Note Export](https://dev.evernote.com/legacy/documentation/cloud/chapters/note_export) and the first-party [ENEX Export DTD](https://xml.evernote.com/pub/evernote-export.dtd) — ENEX structure and timestamps. The DTD is dated/copyrighted 2008; current client workflow is taken from the current Help guide. +- Evernote Developer: [Data Structure](https://dev.evernote.com/legacy/documentation/cloud/chapters/data_structure), [ENML](https://dev.evernote.com/legacy/start/core/enml), and [Note Links](https://dev.evernote.com/legacy/documentation/cloud/chapters/note_links) — resource hashes, restricted markup, encrypted spans and internal-link portability caveat. +- ID object model: [#2048 decision record](2026-11-01_design_id2048.md), [#2048 decision comment](https://github.com/developing-today/code/issues/2048#issuecomment-6560927674), [PR #3885](https://github.com/developing-today/code/pull/3885), [PR #3908](https://github.com/developing-today/code/pull/3908), and the [#3816 note-link record](2026-11-02T04-52-00Z_feature_note_link_backlink_projection/2026-11-02T04-52-00Z_feature_note_link_backlink_projection.md). +- Parent constraints: [#5678](https://github.com/developing-today/code/issues/5678), [content model #5839](https://github.com/developing-today/code/issues/5839), and [attachments/media #5844](https://github.com/developing-today/code/issues/5844). From 04d82095f2776bbffb9b5cceecc44c8a0c60b86e Mon Sep 17 00:00:00 2001 From: repo-worker-code-k <fleet@developing.today> Date: Sun, 8 Nov 2026 19:23:27 -0600 Subject: [PATCH 2/3] docs(id): preserve parent read grant detail --- doc/2026-11-08_design_id5846.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/2026-11-08_design_id5846.md b/doc/2026-11-08_design_id5846.md index 639febbe25..14d0521f19 100644 --- a/doc/2026-11-08_design_id5846.md +++ b/doc/2026-11-08_design_id5846.md @@ -17,7 +17,7 @@ ENEX supplies neither a stable note ID nor notebook membership in its documented This record decides the mapping of an Evernote export into the settled note model. It does not implement import, choose when implementation starts, provide continuous sync, or re-decide #5678's product/access rulings. In particular: - Stable logical note IDs, immutable revision history, explicit multi-head merges, authored link surfaces and optional revision pins follow #2048 and its landed phases. Link edges are signed `note.link` events; backlinks are derived from asserting source-revision heads, not stored as a second source of truth. -- Imported notes inherit the destination's existing read/write policy. The parent #5678 read default and resolution order (object → user default → server configuration → public) are unchanged; import does not grant access. +- Imported notes inherit the destination's existing read/write policy. Preserve #5678's public-read default, the owner's ability to grant read to any number of groups and/or users, and the resolution order (object → user default → server configuration → public); import grants no access and makes no access-control change. - Evernote's export limitations make some source relationships unresolvable. The resulting unresolved state is a documented degradation, not a change to ID's link model or resolver (#2259). - No ID collection/notebook type is introduced here. The content-model design #5839 is still open. The attachment representation beyond extracted blobs and manifest provenance remains with #5844; this record does not claim a general attachment-viewer contract. From 3447e891d89611f9025db46082a8621cb881d277 Mon Sep 17 00:00:00 2001 From: repo-worker-code-k <fleet@developing.today> Date: Sun, 8 Nov 2026 19:31:41 -0600 Subject: [PATCH 3/3] docs(id): preserve ENEX duplicate entries --- doc/2026-11-08_design_id5846.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/2026-11-08_design_id5846.md b/doc/2026-11-08_design_id5846.md index 14d0521f19..50799eff68 100644 --- a/doc/2026-11-08_design_id5846.md +++ b/doc/2026-11-08_design_id5846.md @@ -8,9 +8,9 @@ ## Decision summary -Import a user-selected ENEX export as a **one-shot, manifest-backed import set**. Each ENEX `<note>` becomes a new ID logical note via `note.create` carrying its first content (that event is also the first revision); the ENEX title becomes an alias/name claim, tags become tag claims, and source timestamps/attributes are provenance rather than ID event times. Decode each resource into content-addressed blob bytes and preserve its source metadata in the import manifest. Normalize the ENML body to a sanitized HTML fragment for the note's content blob, retaining the original ENML as source provenance so unsupported details are recoverable and reportable. +Import a user-selected ENEX export as a **one-shot, manifest-backed import set**. Each occurrence the user chooses to add as new becomes an ID logical note via `note.create` carrying its first content (that event is also the first revision); a confirmed re-import match revises the existing logical note instead. The ENEX title becomes an alias/name claim, tags become tag claims, and source timestamps/attributes are provenance rather than ID event times. Decode each resource into content-addressed blob bytes and preserve its source metadata in the import manifest. Normalize the ENML body to a sanitized HTML fragment for the note's content blob, retaining the original ENML as source provenance so unsupported details are recoverable and reportable. -ENEX supplies neither a stable note ID nor notebook membership in its documented DTD. Therefore identity is ID's, not Evernote's: the import manifest assigns each source entry a local row identity. An identical re-import into the same import set is a no-op. A changed export cannot safely be reconciled automatically; the user must confirm which entries revise existing ID notes and which are new. Titles, timestamps and body hashes may suggest matches but never silently merge notes. Evernote-internal links are converted to `note.link` only after an explicit target mapping; otherwise their authored surface is retained as unresolved, as #2048 requires. +ENEX supplies neither a stable note ID nor notebook membership in its documented DTD. Therefore identity is ID's, not Evernote's: the import manifest assigns each source entry a local row identity, even when multiple entries are byte-identical. Re-importing the exact same export digest into the same import set is a no-op. In a changed export, fingerprints and their multiplicities are matching hints only, never proof of source identity: the user confirms whether each candidate occurrence matches an existing ID note or is new. Repeated identical entries preserve their multiplicity and require explicit occurrence-to-row choices. Titles, timestamps and body hashes may suggest matches but never silently merge notes. Evernote-internal links are converted to `note.link` only after an explicit target mapping; otherwise their authored surface is retained as unresolved, as #2048 requires. ## 1. Scope and decisions already owned elsewhere @@ -36,7 +36,7 @@ The first-party Export DTD defines each note as title, ENML content, optional cr | ENEX source | ID mapping | Decision and fidelity rule | | --- | --- | --- | -| `<note>` | New logical note: `note.create` with its first content/revision | The create event's ID is the stable logical note ID and first revision ID. ENEX has no stable note ID to reuse. | +| `<note>` | For a new-note choice, `note.create` with its first content/revision; for a confirmed re-import match, a revision of the mapped logical note | The create event's ID is the stable logical note ID and first revision ID. ENEX has no stable note ID to reuse; re-import matching follows §4. | | `<title>` | Alias/name claim on the logical note | Names are claims, never identity; duplicate or contested titles remain visible as such. | | `<content>` (ENML) | Sanitized, normalized HTML fragment in the revision content blob; original ENML retained as source provenance | Preserve supported semantic content. Unsupported constructs produce an explicit placeholder and a fidelity-report entry; never silently disappear. The normalized body format is local to this importer, not a new universal ID content-model decision. | | Repeated `<tag>` | One ID tag claim per source tag | Preserve exact tag text and case. Re-import does not create duplicate live claims. | @@ -52,13 +52,13 @@ Resource bytes are decoded from ENEX base64 and checked before storage. ENEX's ` ## 4. Import manifest, identity and deduplication -The manifest is required for an import to be considered successful. It records a generated `import_set_id`, the export/package digest, one manifest row per ENEX note entry, the assigned ID note ID, source title and timestamps, canonical source-entry fingerprint, original ENML provenance, resource mappings, and the user's confirmed match decisions. Persist it as an **exportable, user-owned sidecar** alongside the selected ENEX source, not as a new shared ID note/collection type. The ID event graph remains canonical. The user must carry the sidecar when moving an import set to another device; if it is missing, start a new import set and warn that automatic deduplication/matching is unavailable. The manifest is an import ledger, not another canonical note/link graph. +The manifest is required for an import to be considered successful. It records a generated `import_set_id`, the export/package digest, one uniquely identified manifest row per ENEX `<note>` occurrence (including repeated identical entries), the assigned ID note ID, source title and timestamps, canonical source-entry fingerprint, original ENML provenance, resource mappings, and the user's confirmed match decisions. Persist it as an **exportable, user-owned sidecar** alongside the selected ENEX source, not as a new shared ID note/collection type. The ID event graph remains canonical. The user must carry the sidecar when moving an import set to another device; if it is missing, start a new import set and warn that automatic deduplication/matching is unavailable. The manifest is an import ledger, not another canonical note/link graph. Because the Export DTD has no stable note ID, deduplication is conservative: 1. Re-importing the exact same export digest into the same `import_set_id` is a no-op. -2. Re-importing an entry whose canonical source fingerprint is already recorded in that set is a no-op for that entry. -3. For a changed export, the importer may propose candidates using stable-looking fields such as `created`, title, source URL and content similarity, but these are **hints only**. The user must explicitly map each changed entry to an existing import row (revise) or mark it as a new note. Missing or ambiguous matches block that entry; no title/content-only auto-merge occurs. +2. For a changed export, compare canonical source fingerprints as a **multiset**, not a set, to propose candidates only. A fingerprint match—even a unique one—is not proof of source identity: the user confirms whether each candidate occurrence maps to an existing manifest row or is new. Repeated fingerprints require explicit one-to-one occurrence-to-row choices. An additional identical occurrence is never skipped just because that fingerprint is already present. Every `<note>` occurrence remains a distinct manifest row; a new-note choice mints its own ID note unless the user explicitly maps it to an existing note. +3. The importer may propose candidates using stable-looking fields such as `created`, title, source URL and content similarity, but these are **hints only**. The user must explicitly map each changed entry to an existing import row (revise) or mark it as a new note. Missing or ambiguous matches block that entry; no title/content-only auto-merge occurs. 4. Once the user confirms a match, a changed source snapshot creates a signed revision on the same logical note, parented from the last imported revision. If ID-side edits have created another head, preserve both heads and report that an explicit ID merge is required; never last-write-wins. 5. A source entry absent from a later export is reported but not deleted. Cross-import-set matching is only a suggestion and never automatic; identical body bytes do not prove two source notes are the same note. @@ -95,9 +95,9 @@ The following are explicit v1 limits: ## 8. Invariants for implementation -1. Each imported ENEX note gets an ID-minted stable logical note ID; title, source GUID-like URL fragments, tags and filenames never become note identity. +1. Every ENEX `<note>` occurrence has its own manifest row. A new-note choice mints a distinct stable logical note ID for that row, including for byte-identical entries; a confirmed re-import match reuses the mapped ID. Titles, source GUID-like URL fragments, tags, filenames and fingerprints never become note identity. 2. Note content is an immutable revision blob. Re-import never overwrites a revision; concurrent heads remain visible until an explicit merge. -3. An exact re-import into the same import set is idempotent. A changed source entry cannot revise or duplicate a note without a user-confirmed mapping. +3. An exact export-digest re-import into the same import set is idempotent. Changed exports preserve fingerprint multiplicity; fingerprint matches require user confirmation before reuse, and no source entry can be silently dropped, revised or merged. 4. Every source note, tag, resource and body link is either mapped, unchanged, unresolved, degraded or refused with an explanation. No silent drops, fabricated targets or empty attachment substitutions. 5. A confirmed internal link targets stable ID note identities and is represented by #3816's signed `note.link`; backlinks are derived from selected source-revision heads. 6. The resource bytes stored for an accepted attachment hash-match the decoded ENEX bytes; an `<en-media>` reference is linked only when its source hash verifies. @@ -106,10 +106,10 @@ The following are explicit v1 limits: ## 9. Test corpus and oracle -The oracle is the canonical import manifest plus ID note/link projections and blob hashes. For each fixture, the test compares the accounted source-entry set, stable note IDs, alias/tag claims, revision heads, link targets/surfaces/backlinks, report states, and resource byte hashes. Invalid XML/base64/hash cases must return named errors; a passing test may not rely on visual inspection alone. +The oracle is the canonical import manifest plus ID note/link projections and blob hashes. For each fixture, the test compares the accounted source-entry **multiset** and per-fingerprint occurrence counts, manifest rows, stable note IDs, alias/tag claims, revision heads, link targets/surfaces/backlinks, report states, and resource byte hashes. Invalid XML/base64/hash cases must return named errors; a passing test may not rely on visual inspection alone. - **Schema/minimal cases:** one note; absent optional timestamps/attributes; multiple notes; whitespace in base64; valid UTC timestamps; XML entities and Unicode titles/body. -- **Identity and dedupe:** duplicate titles; same creation timestamp; byte-identical but distinct note entries; same export imported twice (no new events); reordered export; changed body/title; missing `created`; cross-source-set identical note; ambiguous and user-confirmed matches; new-note choice; omitted source note (no deletion). +- **Identity and dedupe:** duplicate titles; same creation timestamp; byte-identical but distinct note entries; an extra identical occurrence in a later export; unique and repeated fingerprint matches in changed exports (user-confirmed row pairing or new-note choice); repeated-fingerprint groups after reordering; same export imported twice (no new events); changed body/title; missing `created`; cross-source-set identical note; omitted source note (no deletion). - **ENML conversion:** paragraphs/headings, nested lists, emphasis, links, simple tables, checkboxes, unknown elements/attributes, malformed XML, external-entity attempt, and `<en-crypt>`; verify deterministic normalized body and preserved source/report entries. - **Links:** safe web link; Evernote URI with no match; URI with ambiguous candidates; user-confirmed target; a link to a note outside the export; verify unresolved surface and that only confirmed mappings emit `note.link` events/backlinks. - **Resources:** PNG, JPEG, PDF, audio and opaque binary; one resource referenced twice; duplicate bytes across notes; orphan resource; missing media target; mismatched MD5; invalid/oversize base64; recognition/alternate data. Accepted bytes must compare equal by SHA-256 after blob storage; unresolved/refused cases must appear in the report.