|
| 1 | +# WikiDocs mirror contract |
| 2 | + |
| 3 | +This document is the technical contract between |
| 4 | +[`junghan0611/garden`](https://github.com/junghan0611/garden) and |
| 5 | +[`junghan0611/garden2wikidocs`](https://github.com/junghan0611/garden2wikidocs). |
| 6 | +The public rationale and project timeline live in Denote note |
| 7 | +`20260220T201100` (`§garden2wikidocs — 원본 가든을 건드리지 않는 위키독스 미러`). |
| 8 | + |
| 9 | +## Center |
| 10 | + |
| 11 | +> The garden is the canonical, latest, and authored source. |
| 12 | +> WikiDocs is a Korean-language discovery and reading mirror. |
| 13 | +> `garden2wikidocs` is the translation harness between them. |
| 14 | +
|
| 15 | +WikiDocs may appear before the garden in Korean search results. That is an intended |
| 16 | +property of the discovery surface, not a transfer of authorship or source authority. |
| 17 | +Readers arriving there must have an exact route back to the garden, where backlinks, |
| 18 | +tags, history, comments, source links, and the latest revision live. |
| 19 | + |
| 20 | +## Field ownership |
| 21 | + |
| 22 | +| Field | Authority | |
| 23 | +|---|---| |
| 24 | +| Body, title, description, section | garden Markdown exported from Org | |
| 25 | +| Denote ID, source URL | garden | |
| 26 | +| `date`, `lastmod` | garden frontmatter | |
| 27 | +| WikiDocs `page_id`, mirror URL | `garden2wikidocs/mapping.json` | |
| 28 | +| Mirror synchronization status | `garden2wikidocs` / WikiDocs | |
| 29 | +| Canonical-versus-mirror policy | this garden | |
| 30 | + |
| 31 | +The Denote ID is the join key. Source metadata copied into `mapping.json` remains a |
| 32 | +cache of garden facts; it does not become their authority. |
| 33 | + |
| 34 | +## Data flow |
| 35 | + |
| 36 | +```text |
| 37 | +Org → exported garden Markdown → independent garden deploy |
| 38 | + ↓ read-only |
| 39 | + garden2wikidocs build |
| 40 | + ↓ |
| 41 | + WikiDocs page_id recovery |
| 42 | + ↓ |
| 43 | + garden2wikidocs/mapping.json |
| 44 | + ↓ explicit owner-run import |
| 45 | + garden/quartz/data/wikidocs-mirror.json |
| 46 | + ↓ |
| 47 | + Quartz JSON-LD + visible mirror link |
| 48 | +``` |
| 49 | + |
| 50 | +The garden's Netlify build never reads a sibling checkout and never fetches a remote |
| 51 | +mapping over the network. `scripts/sync-wikidocs-map.mjs` is an explicit import gate: |
| 52 | +it validates the mirror ledger and commits only the minimal Denote-ID-to-URL snapshot |
| 53 | +needed by Quartz. |
| 54 | + |
| 55 | +`garden2wikidocs` must not write into the garden repository. It updates its own ledger |
| 56 | +and reports that a new stable `page_id` is ready; the garden owner decides when to |
| 57 | +import the new snapshot. |
| 58 | + |
| 59 | +## Publication ordering |
| 60 | + |
| 61 | +1. Export and deploy the garden independently. |
| 62 | +2. Let `garden2wikidocs` read the public garden files and update the WikiDocs mirror. |
| 63 | +3. Recover new WikiDocs `page_id` values and audit the mirror. |
| 64 | +4. Explicitly import the refreshed mapping snapshot into the garden. |
| 65 | +5. On the next garden deploy, emit the corresponding JSON-LD and visible mirror links. |
| 66 | + |
| 67 | +A new garden note may temporarily have no WikiDocs mapping. That is normal and must |
| 68 | +not fail a garden build. A mirror outage or delayed `page_id` recovery must never block |
| 69 | +the canonical publication path. |
| 70 | + |
| 71 | +## Garden output |
| 72 | + |
| 73 | +For a mapped Denote page, Quartz adds the stable WikiDocs URL to the page's |
| 74 | +CreativeWork JSON-LD as `sameAs` and shows a compact `WikiDocs mirror` link in content |
| 75 | +metadata. Both are synthesized at build time; Org and exported content Markdown are not |
| 76 | +modified for mirror plumbing. |
| 77 | + |
| 78 | +`sameAs` records a relationship between two renderings of the work. It is not an HTML |
| 79 | +canonical directive and does not grant WikiDocs authority over source metadata. |
| 80 | + |
| 81 | +The garden's existing uppercase-`T` URL behavior deliberately has no per-page |
| 82 | +`<link rel="canonical">`. This mirror integration does not change that invariant. |
| 83 | + |
| 84 | +## Mirror output |
| 85 | + |
| 86 | +Each generated WikiDocs page must contain a separate `원본·최신본` provenance block. |
| 87 | +It is system metadata, not part of the author's `이 노트에 대하여` abstract. |
| 88 | + |
| 89 | +- If an abstract exists: abstract → provenance block → body. |
| 90 | +- If no abstract exists: provenance block → body. |
| 91 | +- The block links to the exact garden URL and identifies the garden as original/latest. |
| 92 | +- It directs readers to the garden for backlinks, tags, history, comments, and updates. |
| 93 | +- Creation and modification dates come only from garden frontmatter. |
| 94 | +- Journal title dates and recent-first ordering use `source_date` (the week/date represented by the journal). |
| 95 | +- Meta, bibliography, notes, and botlog title dates and recent-first ordering use `source_lastmod`, |
| 96 | + falling back to `source_date` only when `lastmod` is absent. |
| 97 | +- Mirror build, Git commit, file mtime, and sync time must never masquerade as either source date. |
| 98 | +- WikiDocs may force its sidebar into ascending title order. Preserve stable titles and `page_id` values; |
| 99 | + provide an explicit recent-first chapter index rather than renumbering every page to fight the sidebar. |
| 100 | +- Mirror sync time belongs at book level, not repeated as a content date on every page. |
| 101 | + |
| 102 | +## Validation contract |
| 103 | + |
| 104 | +### Garden |
| 105 | + |
| 106 | +- Denote IDs and WikiDocs URLs are well formed. |
| 107 | +- Every imported WikiDocs page ID and URL is unique. |
| 108 | +- Every snapshot entry points to an existing garden Denote page. |
| 109 | +- A mapped page emits the exact `sameAs` URL and visible mirror link. |
| 110 | +- An unmapped new garden page remains valid and deployable. |
| 111 | +- Netlify requires no sibling repository or network mapping fetch. |
| 112 | + |
| 113 | +### garden2wikidocs |
| 114 | + |
| 115 | +- Every mirror page has exactly one exact source URL. |
| 116 | +- `gid`, source URL Denote ID, and mapping entry agree. |
| 117 | +- Journal title dates equal garden `date`; all other title dates equal garden `lastmod` with `date` fallback. |
| 118 | +- The provenance block is separate from the author's abstract. |
| 119 | +- An existing WikiDocs `page_id` remains stable across rebuilds. |
| 120 | +- Mirror-internal links use recovered WikiDocs URLs where available and retain the |
| 121 | + garden URL as fallback. |
| 122 | + |
| 123 | +## Change protocol |
| 124 | + |
| 125 | +This file is the cross-repository policy SSOT. A change to source authority, field |
| 126 | +ownership, publication ordering, or the provenance contract is agreed here first. |
| 127 | +The `garden2wikidocs` skill references this contract and owns implementation details of |
| 128 | +the mirror pipeline; the garden owns its importer, local snapshot, structured data, and |
| 129 | +public canonical policy. |
0 commit comments