canopycms 0.0.61 → 0.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/ai/json-to-markdown.js +1 -2
  2. package/dist/ai/json-to-markdown.js.map +1 -1
  3. package/dist/api/__test__/mock-client.d.ts +5 -1
  4. package/dist/api/__test__/mock-client.d.ts.map +1 -1
  5. package/dist/api/__test__/mock-client.js +9 -2
  6. package/dist/api/__test__/mock-client.js.map +1 -1
  7. package/dist/api/admin-branch-health.d.ts +36 -1
  8. package/dist/api/admin-branch-health.d.ts.map +1 -1
  9. package/dist/api/admin-branch-health.js +176 -2
  10. package/dist/api/admin-branch-health.js.map +1 -1
  11. package/dist/api/admin.d.ts +8 -1
  12. package/dist/api/admin.d.ts.map +1 -1
  13. package/dist/api/admin.js.map +1 -1
  14. package/dist/api/branch.d.ts.map +1 -1
  15. package/dist/api/branch.js +16 -2
  16. package/dist/api/branch.js.map +1 -1
  17. package/dist/api/client.d.ts +5 -1
  18. package/dist/api/client.d.ts.map +1 -1
  19. package/dist/api/client.js +6 -0
  20. package/dist/api/client.js.map +1 -1
  21. package/dist/api/comments.d.ts +2 -2
  22. package/dist/api/content.d.ts +11 -5
  23. package/dist/api/content.d.ts.map +1 -1
  24. package/dist/api/content.js +79 -6
  25. package/dist/api/content.js.map +1 -1
  26. package/dist/api/entries.d.ts +10 -0
  27. package/dist/api/entries.d.ts.map +1 -1
  28. package/dist/api/entries.js +40 -15
  29. package/dist/api/entries.js.map +1 -1
  30. package/dist/api/schema.d.ts +4 -4
  31. package/dist/api/schema.d.ts.map +1 -1
  32. package/dist/api/schema.js +13 -13
  33. package/dist/api/schema.js.map +1 -1
  34. package/dist/assets/transform.d.ts.map +1 -1
  35. package/dist/assets/transform.js +19 -6
  36. package/dist/assets/transform.js.map +1 -1
  37. package/dist/branch-health.d.ts +13 -0
  38. package/dist/branch-health.d.ts.map +1 -1
  39. package/dist/branch-health.js +23 -0
  40. package/dist/branch-health.js.map +1 -1
  41. package/dist/cli/cli.js +858 -537
  42. package/dist/cli/generate-ai-content.js +760 -455
  43. package/dist/cli/init.js +25 -7
  44. package/dist/cli/template-files/Dockerfile.cms.template +19 -1
  45. package/dist/cli/template-files/canopycms.config.ts.template +7 -0
  46. package/dist/cli/template-files/cms-stack.ts.template +7 -1
  47. package/dist/client.d.ts +1 -0
  48. package/dist/client.d.ts.map +1 -1
  49. package/dist/client.js.map +1 -1
  50. package/dist/config/schemas/field.d.ts +15 -15
  51. package/dist/config/types.d.ts +2 -2
  52. package/dist/config/types.d.ts.map +1 -1
  53. package/dist/config/types.js +0 -1
  54. package/dist/config/types.js.map +1 -1
  55. package/dist/config/validation.d.ts +9 -0
  56. package/dist/config/validation.d.ts.map +1 -1
  57. package/dist/config/validation.js +14 -0
  58. package/dist/config/validation.js.map +1 -1
  59. package/dist/content-id-index.d.ts +97 -5
  60. package/dist/content-id-index.d.ts.map +1 -1
  61. package/dist/content-id-index.js +170 -18
  62. package/dist/content-id-index.js.map +1 -1
  63. package/dist/content-store.d.ts +81 -7
  64. package/dist/content-store.d.ts.map +1 -1
  65. package/dist/content-store.js +443 -258
  66. package/dist/content-store.js.map +1 -1
  67. package/dist/editor/BranchManager.d.ts.map +1 -1
  68. package/dist/editor/BranchManager.js +18 -6
  69. package/dist/editor/BranchManager.js.map +1 -1
  70. package/dist/editor/CanopyEditor.d.ts.map +1 -1
  71. package/dist/editor/CanopyEditor.js +2 -2
  72. package/dist/editor/CanopyEditor.js.map +1 -1
  73. package/dist/editor/CanopyEditorPage.d.ts +9 -1
  74. package/dist/editor/CanopyEditorPage.d.ts.map +1 -1
  75. package/dist/editor/CanopyEditorPage.js +9 -2
  76. package/dist/editor/CanopyEditorPage.js.map +1 -1
  77. package/dist/editor/Editor.d.ts +9 -1
  78. package/dist/editor/Editor.d.ts.map +1 -1
  79. package/dist/editor/Editor.js +58 -24
  80. package/dist/editor/Editor.js.map +1 -1
  81. package/dist/editor/FormRenderer.d.ts.map +1 -1
  82. package/dist/editor/FormRenderer.js +12 -0
  83. package/dist/editor/FormRenderer.js.map +1 -1
  84. package/dist/editor/admin/SystemHealthPanel.js +6 -2
  85. package/dist/editor/admin/SystemHealthPanel.js.map +1 -1
  86. package/dist/editor/components/EntryCreateModal.d.ts +9 -1
  87. package/dist/editor/components/EntryCreateModal.d.ts.map +1 -1
  88. package/dist/editor/components/EntryCreateModal.js +4 -1
  89. package/dist/editor/components/EntryCreateModal.js.map +1 -1
  90. package/dist/editor/fields/DateTimeField.d.ts +46 -0
  91. package/dist/editor/fields/DateTimeField.d.ts.map +1 -0
  92. package/dist/editor/fields/DateTimeField.js +66 -0
  93. package/dist/editor/fields/DateTimeField.js.map +1 -0
  94. package/dist/editor/fields/NumberField.d.ts +34 -0
  95. package/dist/editor/fields/NumberField.d.ts.map +1 -0
  96. package/dist/editor/fields/NumberField.js +53 -0
  97. package/dist/editor/fields/NumberField.js.map +1 -0
  98. package/dist/editor/fields/NumberListField.d.ts +25 -0
  99. package/dist/editor/fields/NumberListField.d.ts.map +1 -0
  100. package/dist/editor/fields/NumberListField.js +53 -0
  101. package/dist/editor/fields/NumberListField.js.map +1 -0
  102. package/dist/editor/hooks/useBranchManager.d.ts.map +1 -1
  103. package/dist/editor/hooks/useBranchManager.js +115 -26
  104. package/dist/editor/hooks/useBranchManager.js.map +1 -1
  105. package/dist/editor/hooks/useDraftManager.d.ts +8 -0
  106. package/dist/editor/hooks/useDraftManager.d.ts.map +1 -1
  107. package/dist/editor/hooks/useDraftManager.js +261 -21
  108. package/dist/editor/hooks/useDraftManager.js.map +1 -1
  109. package/dist/editor/hooks/useEntryManager.d.ts +21 -0
  110. package/dist/editor/hooks/useEntryManager.d.ts.map +1 -1
  111. package/dist/editor/hooks/useEntryManager.js +25 -2
  112. package/dist/editor/hooks/useEntryManager.js.map +1 -1
  113. package/dist/editor/theme.d.ts +8 -8
  114. package/dist/git-manager.d.ts +51 -7
  115. package/dist/git-manager.d.ts.map +1 -1
  116. package/dist/git-manager.js +105 -14
  117. package/dist/git-manager.js.map +1 -1
  118. package/dist/http/handler.d.ts.map +1 -1
  119. package/dist/http/handler.js +70 -27
  120. package/dist/http/handler.js.map +1 -1
  121. package/dist/http/router.d.ts.map +1 -1
  122. package/dist/http/router.js +40 -3
  123. package/dist/http/router.js.map +1 -1
  124. package/dist/operating-mode/deployment-name-fixtures.d.ts +29 -0
  125. package/dist/operating-mode/deployment-name-fixtures.d.ts.map +1 -0
  126. package/dist/operating-mode/deployment-name-fixtures.js +55 -0
  127. package/dist/operating-mode/deployment-name-fixtures.js.map +1 -0
  128. package/dist/operating-mode/deployment-name.d.ts +9 -0
  129. package/dist/operating-mode/deployment-name.d.ts.map +1 -1
  130. package/dist/operating-mode/deployment-name.js +9 -1
  131. package/dist/operating-mode/deployment-name.js.map +1 -1
  132. package/dist/operating-mode/index.d.ts +2 -1
  133. package/dist/operating-mode/index.d.ts.map +1 -1
  134. package/dist/operating-mode/index.js +4 -1
  135. package/dist/operating-mode/index.js.map +1 -1
  136. package/dist/operating-mode/mode-env.d.ts +58 -0
  137. package/dist/operating-mode/mode-env.d.ts.map +1 -0
  138. package/dist/operating-mode/mode-env.js +97 -0
  139. package/dist/operating-mode/mode-env.js.map +1 -0
  140. package/dist/resolve-canopy-user.d.ts +34 -0
  141. package/dist/resolve-canopy-user.d.ts.map +1 -0
  142. package/dist/resolve-canopy-user.js +55 -0
  143. package/dist/resolve-canopy-user.js.map +1 -0
  144. package/dist/schema/schema-store.d.ts +53 -2
  145. package/dist/schema/schema-store.d.ts.map +1 -1
  146. package/dist/schema/schema-store.js +92 -21
  147. package/dist/schema/schema-store.js.map +1 -1
  148. package/dist/server.d.ts +9 -0
  149. package/dist/server.d.ts.map +1 -1
  150. package/dist/server.js +9 -0
  151. package/dist/server.js.map +1 -1
  152. package/dist/services.d.ts.map +1 -1
  153. package/dist/services.js +40 -6
  154. package/dist/services.js.map +1 -1
  155. package/dist/settings-workspace.d.ts +40 -0
  156. package/dist/settings-workspace.d.ts.map +1 -1
  157. package/dist/settings-workspace.js +139 -151
  158. package/dist/settings-workspace.js.map +1 -1
  159. package/dist/types.d.ts +10 -0
  160. package/dist/types.d.ts.map +1 -1
  161. package/dist/utils/content-write-lock.d.ts +127 -0
  162. package/dist/utils/content-write-lock.d.ts.map +1 -0
  163. package/dist/utils/content-write-lock.js +170 -0
  164. package/dist/utils/content-write-lock.js.map +1 -0
  165. package/dist/utils/error.d.ts +1 -1
  166. package/dist/utils/error.js +1 -1
  167. package/dist/utils/git.d.ts +16 -0
  168. package/dist/utils/git.d.ts.map +1 -1
  169. package/dist/utils/git.js +22 -0
  170. package/dist/utils/git.js.map +1 -1
  171. package/dist/utils/sanitize-href.d.ts +28 -3
  172. package/dist/utils/sanitize-href.d.ts.map +1 -1
  173. package/dist/utils/sanitize-href.js +64 -6
  174. package/dist/utils/sanitize-href.js.map +1 -1
  175. package/dist/validation/entry-link-validator.d.ts +1 -1
  176. package/dist/validation/entry-link-validator.js +3 -3
  177. package/dist/validation/entry-link-validator.js.map +1 -1
  178. package/dist/validation/entry-validator.js +1 -1
  179. package/dist/validation/entry-validator.js.map +1 -1
  180. package/dist/worker/cms-worker.d.ts +13 -0
  181. package/dist/worker/cms-worker.d.ts.map +1 -1
  182. package/dist/worker/cms-worker.js +326 -264
  183. package/dist/worker/cms-worker.js.map +1 -1
  184. package/package.json +2 -2
@@ -0,0 +1,127 @@
1
+ /**
2
+ * [SYNC-C1] Cross-host mutual exclusion between the worker's rebase loop and
3
+ * content writes against the same branch working tree.
4
+ *
5
+ * Production runs a Lambda (API) and an EC2 worker over one EFS filesystem.
6
+ * `ContentStore`'s write/delete/rename critical sections were guarded only by
7
+ * the in-process mutex (`utils/async-mutex`), which does not cross that
8
+ * boundary, while `CmsWorker.rebaseActiveBranches()` rewrites the very same
9
+ * working tree. A write landing after `git rebase` started is destroyed two
10
+ * ways -- `git checkout --theirs <file>` overwrites it with the branch's
11
+ * committed version (and the rebase then SUCCEEDS, logging nothing), and
12
+ * `git rebase --abort` hard-resets the tree. Either way the editor already got
13
+ * its 200. This lock is what serializes the two.
14
+ *
15
+ * **Asymmetric by design.** The worker retries every branch on its next sync
16
+ * cycle (~5 minutes) while the editor is a person waiting on a save, so the
17
+ * worker yields and the writer waits:
18
+ *
19
+ * - Worker: {@link tryAcquireContentWriteLock} -- zero retries. On contention
20
+ * it skips that branch this cycle (an extension of the existing
21
+ * skip-dirty-branches behavior) and picks it up next cycle.
22
+ * - Writers: {@link withContentWriteLock} -- a short bounded wait, then a
23
+ * retriable failure the API surfaces as a 409.
24
+ *
25
+ * **Reads never take this lock.** An extra EFS round-trip on every read is not
26
+ * an acceptable price, and a read racing a rebase gets a consistent-enough
27
+ * older or newer file, never a destroyed one.
28
+ *
29
+ * ## Why the lock is anchored on `{branchRoot}/.canopy-meta`
30
+ *
31
+ * proper-lockfile keys its module-level `locks{}` bookkeeping (refresh timer,
32
+ * release function) by the **target path** passed to `lock()`, NOT by
33
+ * `lockfilePath`. The provisioning lock targets `path.dirname(branchRoot)` --
34
+ * the shared content-branches directory -- so anchoring here on that same
35
+ * directory with a different lock NAME would land on the same registry key:
36
+ * one process holding both (a Lambda container provisioning a workspace and
37
+ * writing content) would have the second acquisition clobber the first's
38
+ * bookkeeping. Targeting `{branchRoot}/.canopy-meta` instead gives:
39
+ *
40
+ * - a distinct in-process registry key from the provisioning lock (and from
41
+ * every other branch's content lock -- the provisioning locks already share
42
+ * one key across branches);
43
+ * - a distinct on-disk lock directory, so the server-enforced mkdir cannot
44
+ * collide either; and
45
+ * - no deadlock potential: the two locks are never both required, and the only
46
+ * possible acquisition order (provision, then write) is consistent.
47
+ *
48
+ * `.canopy-meta/` is git-excluded in every branch clone (`ensureGitExclude`),
49
+ * so the lock directory can never dirty the working tree or be swept into
50
+ * `git add .` at publish time.
51
+ *
52
+ * ## Honest caveat (do not oversell this)
53
+ *
54
+ * `proper-lockfile` decides a holder is dead by reading the lock directory's
55
+ * mtime with `fs.stat`, which on EFS is served through the NFS attribute
56
+ * cache. A live holder refreshes every `stale/2`, but a waiter can read a
57
+ * cached mtime and conclude the lock is stale when it is not, taking it over.
58
+ * The failure mode of a bad takeover is exactly today's behavior (two
59
+ * unsynchronized writers), so this is a strict improvement -- not a proof of
60
+ * mutual exclusion. See docs/concurrency.md.
61
+ */
62
+ /** On-disk name of the lock marker (a directory, created by mkdir). */
63
+ export declare const CONTENT_WRITE_LOCK_NAME = "content-write.lock";
64
+ /**
65
+ * Default bounded wait for a content write.
66
+ *
67
+ * Deliberately short. A rebase holds this lock for a fetch plus a replay plus
68
+ * N conflict rounds of git subprocesses on EFS -- far longer than any wait an
69
+ * interactive save can absorb, and longer than the API's own latency budget.
70
+ * So the wait is not sized to outlast a rebase (nothing reasonable could); it
71
+ * is sized to absorb lock handoff and the short holds of other writers, and to
72
+ * turn everything longer into a fast, explicit "retry" the editor can act on
73
+ * rather than a request that hangs toward the Lambda timeout. The worker
74
+ * revisits the branch next cycle, so the blocked state is transient.
75
+ *
76
+ * This is ALSO the writer-vs-writer budget, not only the rebase one. The lock
77
+ * is per-branch-root, so every write to one branch now serializes behind it
78
+ * where in-process serialization used to be per-entry -- bounded on Lambda
79
+ * (one invocation per container), but real under `next dev` and build-time
80
+ * provisioning across worker processes. The case to watch is a write whose
81
+ * in-lock path triggers a full `idIndex()` rescan of a large tree over EFS:
82
+ * that can plausibly exceed this budget and start 409ing unrelated saves.
83
+ * Making it configurable for prod tuning is tracked in
84
+ * .claude/future-tasks/content-write-lock-tuning-and-granularity.md.
85
+ */
86
+ export declare const DEFAULT_CONTENT_WRITE_LOCK_WAIT_MS = 2000;
87
+ /**
88
+ * Thrown when the bounded wait expires with the branch's content lock still
89
+ * held. Retriable -- callers translate this into a 409 with a message that
90
+ * says so.
91
+ *
92
+ * The message says "syncing OR another save" because BOTH produce it. The
93
+ * lock is taken by `write`/`delete`/`renameEntry` and by the admin
94
+ * repair-content-duplicates action as well as by the worker's rebase, so a
95
+ * message naming only the rebase was a confident claim about something that
96
+ * may not be happening. `api/content.ts` routes this error ahead of the
97
+ * generic conflict specifically so the editor sees this wording, which makes
98
+ * the wording load-bearing rather than cosmetic.
99
+ */
100
+ export declare class ContentWriteLockBusyError extends Error {
101
+ constructor(message?: string);
102
+ }
103
+ /**
104
+ * Acquire the branch's content-write lock WITHOUT waiting.
105
+ *
106
+ * Throws an error with `code === 'ELOCKED'` when a live holder has it. Used by
107
+ * the worker's rebase loop (which skips the branch and retries next cycle) and
108
+ * by tests standing in for a writer.
109
+ */
110
+ export declare function tryAcquireContentWriteLock(branchRoot: string): Promise<() => Promise<void>>;
111
+ /**
112
+ * Acquire the branch's content-write lock with a short bounded wait.
113
+ *
114
+ * Retries ONLY on genuine contention (`ELOCKED`), the same discipline
115
+ * `withOccFileLock` uses: proper-lockfile's own retry loop retries blindly on
116
+ * any error, which would burn the whole budget re-hitting e.g. ENOENT after
117
+ * the branch directory was deleted out from under the caller.
118
+ *
119
+ * @throws ContentWriteLockBusyError when the budget expires under contention.
120
+ */
121
+ export declare function acquireContentWriteLock(branchRoot: string, waitMs?: number): Promise<() => Promise<void>>;
122
+ /**
123
+ * Run `fn` holding the branch's content-write lock, releasing it in a
124
+ * `finally` so a throw can never strand it.
125
+ */
126
+ export declare function withContentWriteLock<T>(branchRoot: string, fn: () => Promise<T>, waitMs?: number): Promise<T>;
127
+ //# sourceMappingURL=content-write-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-write-lock.d.ts","sourceRoot":"","sources":["../../src/utils/content-write-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAUH,uEAAuE;AACvE,eAAO,MAAM,uBAAuB,uBAAuB,CAAA;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,kCAAkC,OAAO,CAAA;AAEtD;;;;;;;;;;;;GAYG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;gBAEhD,OAAO,SAAuI;CAKjJ;AAYD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAE3F;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,MAA2C,GAClD,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAe9B;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,CAAC,EAC1C,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,MAAM,GAAE,MAA2C,GAClD,OAAO,CAAC,CAAC,CAAC,CAOZ"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * [SYNC-C1] Cross-host mutual exclusion between the worker's rebase loop and
3
+ * content writes against the same branch working tree.
4
+ *
5
+ * Production runs a Lambda (API) and an EC2 worker over one EFS filesystem.
6
+ * `ContentStore`'s write/delete/rename critical sections were guarded only by
7
+ * the in-process mutex (`utils/async-mutex`), which does not cross that
8
+ * boundary, while `CmsWorker.rebaseActiveBranches()` rewrites the very same
9
+ * working tree. A write landing after `git rebase` started is destroyed two
10
+ * ways -- `git checkout --theirs <file>` overwrites it with the branch's
11
+ * committed version (and the rebase then SUCCEEDS, logging nothing), and
12
+ * `git rebase --abort` hard-resets the tree. Either way the editor already got
13
+ * its 200. This lock is what serializes the two.
14
+ *
15
+ * **Asymmetric by design.** The worker retries every branch on its next sync
16
+ * cycle (~5 minutes) while the editor is a person waiting on a save, so the
17
+ * worker yields and the writer waits:
18
+ *
19
+ * - Worker: {@link tryAcquireContentWriteLock} -- zero retries. On contention
20
+ * it skips that branch this cycle (an extension of the existing
21
+ * skip-dirty-branches behavior) and picks it up next cycle.
22
+ * - Writers: {@link withContentWriteLock} -- a short bounded wait, then a
23
+ * retriable failure the API surfaces as a 409.
24
+ *
25
+ * **Reads never take this lock.** An extra EFS round-trip on every read is not
26
+ * an acceptable price, and a read racing a rebase gets a consistent-enough
27
+ * older or newer file, never a destroyed one.
28
+ *
29
+ * ## Why the lock is anchored on `{branchRoot}/.canopy-meta`
30
+ *
31
+ * proper-lockfile keys its module-level `locks{}` bookkeeping (refresh timer,
32
+ * release function) by the **target path** passed to `lock()`, NOT by
33
+ * `lockfilePath`. The provisioning lock targets `path.dirname(branchRoot)` --
34
+ * the shared content-branches directory -- so anchoring here on that same
35
+ * directory with a different lock NAME would land on the same registry key:
36
+ * one process holding both (a Lambda container provisioning a workspace and
37
+ * writing content) would have the second acquisition clobber the first's
38
+ * bookkeeping. Targeting `{branchRoot}/.canopy-meta` instead gives:
39
+ *
40
+ * - a distinct in-process registry key from the provisioning lock (and from
41
+ * every other branch's content lock -- the provisioning locks already share
42
+ * one key across branches);
43
+ * - a distinct on-disk lock directory, so the server-enforced mkdir cannot
44
+ * collide either; and
45
+ * - no deadlock potential: the two locks are never both required, and the only
46
+ * possible acquisition order (provision, then write) is consistent.
47
+ *
48
+ * `.canopy-meta/` is git-excluded in every branch clone (`ensureGitExclude`),
49
+ * so the lock directory can never dirty the working tree or be swept into
50
+ * `git add .` at publish time.
51
+ *
52
+ * ## Honest caveat (do not oversell this)
53
+ *
54
+ * `proper-lockfile` decides a holder is dead by reading the lock directory's
55
+ * mtime with `fs.stat`, which on EFS is served through the NFS attribute
56
+ * cache. A live holder refreshes every `stale/2`, but a waiter can read a
57
+ * cached mtime and conclude the lock is stale when it is not, taking it over.
58
+ * The failure mode of a bad takeover is exactly today's behavior (two
59
+ * unsynchronized writers), so this is a strict improvement -- not a proof of
60
+ * mutual exclusion. See docs/concurrency.md.
61
+ */
62
+ import path from 'node:path';
63
+ import { isNodeError } from './error.js';
64
+ import { tryAcquireProvisioningLock } from './provisioning-lock.js';
65
+ /** Directory the lock marker lives in, relative to the branch root. */
66
+ const META_DIR = '.canopy-meta';
67
+ /** On-disk name of the lock marker (a directory, created by mkdir). */
68
+ export const CONTENT_WRITE_LOCK_NAME = 'content-write.lock';
69
+ /**
70
+ * Default bounded wait for a content write.
71
+ *
72
+ * Deliberately short. A rebase holds this lock for a fetch plus a replay plus
73
+ * N conflict rounds of git subprocesses on EFS -- far longer than any wait an
74
+ * interactive save can absorb, and longer than the API's own latency budget.
75
+ * So the wait is not sized to outlast a rebase (nothing reasonable could); it
76
+ * is sized to absorb lock handoff and the short holds of other writers, and to
77
+ * turn everything longer into a fast, explicit "retry" the editor can act on
78
+ * rather than a request that hangs toward the Lambda timeout. The worker
79
+ * revisits the branch next cycle, so the blocked state is transient.
80
+ *
81
+ * This is ALSO the writer-vs-writer budget, not only the rebase one. The lock
82
+ * is per-branch-root, so every write to one branch now serializes behind it
83
+ * where in-process serialization used to be per-entry -- bounded on Lambda
84
+ * (one invocation per container), but real under `next dev` and build-time
85
+ * provisioning across worker processes. The case to watch is a write whose
86
+ * in-lock path triggers a full `idIndex()` rescan of a large tree over EFS:
87
+ * that can plausibly exceed this budget and start 409ing unrelated saves.
88
+ * Making it configurable for prod tuning is tracked in
89
+ * .claude/future-tasks/content-write-lock-tuning-and-granularity.md.
90
+ */
91
+ export const DEFAULT_CONTENT_WRITE_LOCK_WAIT_MS = 2000;
92
+ /**
93
+ * Thrown when the bounded wait expires with the branch's content lock still
94
+ * held. Retriable -- callers translate this into a 409 with a message that
95
+ * says so.
96
+ *
97
+ * The message says "syncing OR another save" because BOTH produce it. The
98
+ * lock is taken by `write`/`delete`/`renameEntry` and by the admin
99
+ * repair-content-duplicates action as well as by the worker's rebase, so a
100
+ * message naming only the rebase was a confident claim about something that
101
+ * may not be happening. `api/content.ts` routes this error ahead of the
102
+ * generic conflict specifically so the editor sees this wording, which makes
103
+ * the wording load-bearing rather than cosmetic.
104
+ */
105
+ export class ContentWriteLockBusyError extends Error {
106
+ constructor(message = 'This branch is busy (syncing with the base branch, or another save is in flight); the change was not saved. Try again in a moment.') {
107
+ super(message);
108
+ this.name = 'ContentWriteLockBusyError';
109
+ }
110
+ }
111
+ /** The directory proper-lockfile anchors on -- also its in-process registry key. */
112
+ function lockTargetDir(branchRoot) {
113
+ return path.join(path.resolve(branchRoot), META_DIR);
114
+ }
115
+ const sleep = (ms) => new Promise((resolve) => {
116
+ setTimeout(resolve, ms);
117
+ });
118
+ /**
119
+ * Acquire the branch's content-write lock WITHOUT waiting.
120
+ *
121
+ * Throws an error with `code === 'ELOCKED'` when a live holder has it. Used by
122
+ * the worker's rebase loop (which skips the branch and retries next cycle) and
123
+ * by tests standing in for a writer.
124
+ */
125
+ export function tryAcquireContentWriteLock(branchRoot) {
126
+ return tryAcquireProvisioningLock(lockTargetDir(branchRoot), CONTENT_WRITE_LOCK_NAME);
127
+ }
128
+ /**
129
+ * Acquire the branch's content-write lock with a short bounded wait.
130
+ *
131
+ * Retries ONLY on genuine contention (`ELOCKED`), the same discipline
132
+ * `withOccFileLock` uses: proper-lockfile's own retry loop retries blindly on
133
+ * any error, which would burn the whole budget re-hitting e.g. ENOENT after
134
+ * the branch directory was deleted out from under the caller.
135
+ *
136
+ * @throws ContentWriteLockBusyError when the budget expires under contention.
137
+ */
138
+ export async function acquireContentWriteLock(branchRoot, waitMs = DEFAULT_CONTENT_WRITE_LOCK_WAIT_MS) {
139
+ const startedAt = Date.now();
140
+ for (let attempt = 0;; attempt++) {
141
+ try {
142
+ return await tryAcquireContentWriteLock(branchRoot);
143
+ }
144
+ catch (err) {
145
+ if (!isNodeError(err) || err.code !== 'ELOCKED')
146
+ throw err;
147
+ const remaining = waitMs - (Date.now() - startedAt);
148
+ if (remaining <= 0)
149
+ throw new ContentWriteLockBusyError();
150
+ // Exponential backoff with jitter, capped so a long budget still polls
151
+ // often enough to pick the lock up promptly when the holder releases.
152
+ const base = Math.min(40 * 2 ** attempt, 250);
153
+ await sleep(Math.min(base * (0.5 + Math.random()), remaining));
154
+ }
155
+ }
156
+ }
157
+ /**
158
+ * Run `fn` holding the branch's content-write lock, releasing it in a
159
+ * `finally` so a throw can never strand it.
160
+ */
161
+ export async function withContentWriteLock(branchRoot, fn, waitMs = DEFAULT_CONTENT_WRITE_LOCK_WAIT_MS) {
162
+ const release = await acquireContentWriteLock(branchRoot, waitMs);
163
+ try {
164
+ return await fn();
165
+ }
166
+ finally {
167
+ await release();
168
+ }
169
+ }
170
+ //# sourceMappingURL=content-write-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-write-lock.js","sourceRoot":"","sources":["../../src/utils/content-write-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAEhE,uEAAuE;AACvE,MAAM,QAAQ,GAAG,cAAc,CAAA;AAE/B,uEAAuE;AACvE,MAAM,CAAC,MAAM,uBAAuB,GAAG,oBAAoB,CAAA;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,CAAA;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAClD,YACE,OAAO,GAAG,oIAAoI;QAE9I,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;IACzC,CAAC;CACF;AAED,oFAAoF;AACpF,SAAS,aAAa,CAAC,UAAkB;IACvC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAA;AACtD,CAAC;AAED,MAAM,KAAK,GAAG,CAAC,EAAU,EAAiB,EAAE,CAC1C,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IACtB,UAAU,CAA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AuB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IACjE,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,EAAE,CAAA;IACnB,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,EAAE,CAAA;IACjB,CAAC;AACH,CAAC"}
@@ -15,7 +15,7 @@
15
15
  * try {
16
16
  * await riskyOperation()
17
17
  * } catch (err: unknown) {
18
- * console.error('Operation failed:', getErrorMessage(err))
18
+ * canopyLogError('Operation failed:', getErrorMessage(err))
19
19
  * }
20
20
  * ```
21
21
  */
@@ -15,7 +15,7 @@
15
15
  * try {
16
16
  * await riskyOperation()
17
17
  * } catch (err: unknown) {
18
- * console.error('Operation failed:', getErrorMessage(err))
18
+ * canopyLogError('Operation failed:', getErrorMessage(err))
19
19
  * }
20
20
  * ```
21
21
  */
@@ -56,6 +56,22 @@ export declare function isNonFastForwardRejection(message: string): boolean;
56
56
  * callers MUST pin the locale (`gitChildEnv`/`gitNetworkChildEnv`).
57
57
  */
58
58
  export declare function isStaleLeaseRejection(message: string): boolean;
59
+ /**
60
+ * Whether a `git fetch <remote> <branch>` failure is specifically "that ref
61
+ * doesn't exist on the remote" -- the ONLY benign fetch outcome, meaning the
62
+ * branch has never been pushed.
63
+ *
64
+ * Narrow on purpose, and the narrowness is the whole point. This predicate
65
+ * exists because a bare `catch` around the fetch classified EVERY failure --
66
+ * unreachable remote, auth denial, permission error on the workspace, corrupt
67
+ * object store -- as "nothing to pull", which callers then logged as normal
68
+ * and proceeded past. Anything this does not recognize must reach the caller
69
+ * as the genuine error it is.
70
+ *
71
+ * Same locale caveat as the predicates above: the text is gettext-translated,
72
+ * so callers MUST run git with a locale-pinning env (`gitChildEnv`).
73
+ */
74
+ export declare function isMissingRemoteRefFailure(message: string): boolean;
59
75
  /**
60
76
  * Detect the current HEAD branch name for a given repository root.
61
77
  * Returns the branch name, or the provided fallback (default 'main')
@@ -1 +1 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/utils/git.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AO,CAElE;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAe,GACxB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,IAAI,EAAE,aAAa,CAAA;IACnB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAMlB"}
package/dist/utils/git.js CHANGED
@@ -115,6 +115,28 @@ const STALE_LEASE_REASON = 'stale info';
115
115
  export function isStaleLeaseRejection(message) {
116
116
  return message.includes(REJECTED_MARKER) && message.includes(STALE_LEASE_REASON);
117
117
  }
118
+ // git's message when `git fetch <remote> <branch>` names a ref the remote does
119
+ // not have. Both spellings occur: modern git prints the lowercase form, older
120
+ // versions and some transports capitalize it.
121
+ const MISSING_REMOTE_REF_REASONS = ["couldn't find remote ref", "Couldn't find remote ref"];
122
+ /**
123
+ * Whether a `git fetch <remote> <branch>` failure is specifically "that ref
124
+ * doesn't exist on the remote" -- the ONLY benign fetch outcome, meaning the
125
+ * branch has never been pushed.
126
+ *
127
+ * Narrow on purpose, and the narrowness is the whole point. This predicate
128
+ * exists because a bare `catch` around the fetch classified EVERY failure --
129
+ * unreachable remote, auth denial, permission error on the workspace, corrupt
130
+ * object store -- as "nothing to pull", which callers then logged as normal
131
+ * and proceeded past. Anything this does not recognize must reach the caller
132
+ * as the genuine error it is.
133
+ *
134
+ * Same locale caveat as the predicates above: the text is gettext-translated,
135
+ * so callers MUST run git with a locale-pinning env (`gitChildEnv`).
136
+ */
137
+ export function isMissingRemoteRefFailure(message) {
138
+ return MISSING_REMOTE_REF_REASONS.some((reason) => message.includes(reason));
139
+ }
118
140
  /**
119
141
  * Detect the current HEAD branch name for a given repository root.
120
142
  * Returns the branch name, or the provided fallback (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0BAA0B,EAAE,0BAA0B,CAAC,CAAA;AAE3F;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAe;IACvD,OAAO,0BAA0B,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;AAC9E,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAgB,EAChB,WAAmB,MAAM;IAEzB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,SAAS,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC5C,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QAClE,OAAO,IAAI,IAAI,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAA;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAA;IACjB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAKvC;IACC,IAAI,OAAO,CAAC,iBAAiB;QAAE,OAAO,OAAO,CAAC,iBAAiB,CAAA;IAC/D,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3B,OAAO,gBAAgB,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;IAC9D,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,9 +1,34 @@
1
1
  /**
2
2
  * Sanitize an untrusted URL for use in `href` attributes.
3
3
  *
4
- * Parses the input with `new URL()` and only allows `http:` and `https:` protocols,
5
- * blocking `javascript:`, `data:`, `vbscript:`, and other dangerous schemes.
6
- * Returns the fallback (default `'#'`) for invalid or disallowed URLs.
4
+ * Handles both absolute URLs (`https://example.com`) and relative
5
+ * references (`/about`, `docs/guide`, `#section`, `?q=1`) by parsing
6
+ * against a fixed sentinel base, then only allows `http:` and `https:`
7
+ * protocols, blocking `javascript:`, `data:`, `vbscript:`, and other
8
+ * dangerous schemes (an absolute URL supplies its own protocol regardless
9
+ * of the sentinel). Returns the fallback (default `'#'`) for invalid,
10
+ * empty, or disallowed input.
11
+ *
12
+ * Design decisions (deliberate, not oversights):
13
+ * - Protocol-relative input is rejected rather than resolved onto the
14
+ * sentinel's `https:` scheme. In a CMS content field, `//host` is far more
15
+ * likely to be a paste error or an injection attempt than an intentional
16
+ * protocol-relative link, so we don't let it through as an absolute
17
+ * off-site URL. This is enforced by checking whether the input DECLARES a
18
+ * scheme, not by matching a `//` prefix: WHATWG URL treats backslash as
19
+ * equivalent to slash for special schemes, so `/\evil.com`, `\\evil.com`
20
+ * and `\/evil.com` are all protocol-relative in effect. An earlier version
21
+ * of this function checked `startsWith('//')` and let all three through as
22
+ * `https://evil.com/` -- an open redirect out of the one function whose
23
+ * job is to prevent exactly that.
24
+ * - Fragment-only (`#section`) and query-only (`?q=1`) input resolves
25
+ * against the sentinel with pathname `/`; we strip that synthetic leading
26
+ * slash so the result stays a same-page reference (`#section`) instead of
27
+ * silently becoming a navigation to the site root (`/#section`).
28
+ * - Path-relative input with no leading slash (`docs/guide`) is returned as
29
+ * a root-relative path (`/docs/guide`). There is no notion of "current
30
+ * page" at sanitize time, so true path-relative resolution can't be
31
+ * reproduced faithfully - root-relative is the closest safe behavior.
7
32
  *
8
33
  * This utility breaks CodeQL's taint chain by constructing a new string from
9
34
  * the parsed URL rather than passing the original input through.
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize-href.d.ts","sourceRoot":"","sources":["../../src/utils/sanitize-href.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,SAAM,GAAG,MAAM,CAUhE"}
1
+ {"version":3,"file":"sanitize-href.d.ts","sourceRoot":"","sources":["../../src/utils/sanitize-href.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,SAAM,GAAG,MAAM,CAyChE"}
@@ -1,9 +1,38 @@
1
+ // Fixed sentinel base so relative references (root-relative, path-relative,
2
+ // fragment-only, query-only) resolve instead of throwing under `new URL()`.
3
+ // Never exposed in output - see the relative-reference branch below.
4
+ const SENTINEL_BASE = 'https://relative.invalid';
1
5
  /**
2
6
  * Sanitize an untrusted URL for use in `href` attributes.
3
7
  *
4
- * Parses the input with `new URL()` and only allows `http:` and `https:` protocols,
5
- * blocking `javascript:`, `data:`, `vbscript:`, and other dangerous schemes.
6
- * Returns the fallback (default `'#'`) for invalid or disallowed URLs.
8
+ * Handles both absolute URLs (`https://example.com`) and relative
9
+ * references (`/about`, `docs/guide`, `#section`, `?q=1`) by parsing
10
+ * against a fixed sentinel base, then only allows `http:` and `https:`
11
+ * protocols, blocking `javascript:`, `data:`, `vbscript:`, and other
12
+ * dangerous schemes (an absolute URL supplies its own protocol regardless
13
+ * of the sentinel). Returns the fallback (default `'#'`) for invalid,
14
+ * empty, or disallowed input.
15
+ *
16
+ * Design decisions (deliberate, not oversights):
17
+ * - Protocol-relative input is rejected rather than resolved onto the
18
+ * sentinel's `https:` scheme. In a CMS content field, `//host` is far more
19
+ * likely to be a paste error or an injection attempt than an intentional
20
+ * protocol-relative link, so we don't let it through as an absolute
21
+ * off-site URL. This is enforced by checking whether the input DECLARES a
22
+ * scheme, not by matching a `//` prefix: WHATWG URL treats backslash as
23
+ * equivalent to slash for special schemes, so `/\evil.com`, `\\evil.com`
24
+ * and `\/evil.com` are all protocol-relative in effect. An earlier version
25
+ * of this function checked `startsWith('//')` and let all three through as
26
+ * `https://evil.com/` -- an open redirect out of the one function whose
27
+ * job is to prevent exactly that.
28
+ * - Fragment-only (`#section`) and query-only (`?q=1`) input resolves
29
+ * against the sentinel with pathname `/`; we strip that synthetic leading
30
+ * slash so the result stays a same-page reference (`#section`) instead of
31
+ * silently becoming a navigation to the site root (`/#section`).
32
+ * - Path-relative input with no leading slash (`docs/guide`) is returned as
33
+ * a root-relative path (`/docs/guide`). There is no notion of "current
34
+ * page" at sanitize time, so true path-relative resolution can't be
35
+ * reproduced faithfully - root-relative is the closest safe behavior.
7
36
  *
8
37
  * This utility breaks CodeQL's taint chain by constructing a new string from
9
38
  * the parsed URL rather than passing the original input through.
@@ -16,11 +45,40 @@
16
45
  * ```
17
46
  */
18
47
  export function sanitizeHref(url, fallback = '#') {
48
+ const trimmed = url.trim();
49
+ if (trimmed === '')
50
+ return fallback;
19
51
  try {
20
- const parsed = new URL(url);
21
- if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {
22
- return parsed.href;
52
+ const parsed = new URL(trimmed, SENTINEL_BASE);
53
+ if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
54
+ return fallback;
55
+ }
56
+ // Reject protocol-relative references in EVERY spelling, by testing the
57
+ // property we actually care about rather than by enumerating syntax.
58
+ //
59
+ // A string-prefix check on '//' is not sufficient: WHATWG URL treats a
60
+ // backslash as equivalent to a forward slash for special schemes, so
61
+ // '/\evil.com', '\\evil.com' and '\/evil.com' are all protocol-relative
62
+ // in effect and each resolved to https://evil.com/ while sailing past a
63
+ // startsWith('//') guard. Tabs and newlines are stripped during parsing
64
+ // too, so the set of spellings is not one you can enumerate confidently.
65
+ //
66
+ // The property that actually distinguishes "the author asked for another
67
+ // origin" from "the parser inferred one" is whether the input DECLARES a
68
+ // scheme. If it does not and still resolved off the sentinel, it is
69
+ // protocol-relative however it was written.
70
+ const declaresScheme = /^[a-z][a-z0-9+.-]*:/i.test(trimmed);
71
+ if (parsed.origin !== SENTINEL_BASE && !declaresScheme)
72
+ return fallback;
73
+ if (parsed.origin === SENTINEL_BASE) {
74
+ // Input was relative: return it as a relative reference rather than
75
+ // an absolute URL rebased onto the sentinel host.
76
+ const relative = parsed.pathname + parsed.search + parsed.hash;
77
+ // Fragment-only/query-only input resolves with pathname '/'; strip
78
+ // that synthetic leading slash so it stays a same-page reference.
79
+ return parsed.pathname === '/' && !trimmed.startsWith('/') ? relative.slice(1) : relative;
23
80
  }
81
+ return parsed.href;
24
82
  }
25
83
  catch {
26
84
  // invalid URL
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize-href.js","sourceRoot":"","sources":["../../src/utils/sanitize-href.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,QAAQ,GAAG,GAAG;IACtD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QAC3B,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAChE,OAAO,MAAM,CAAC,IAAI,CAAA;QACpB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,cAAc;IAChB,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
1
+ {"version":3,"file":"sanitize-href.js","sourceRoot":"","sources":["../../src/utils/sanitize-href.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,qEAAqE;AACrE,MAAM,aAAa,GAAG,0BAA0B,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,QAAQ,GAAG,GAAG;IACtD,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAA;IAC1B,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,QAAQ,CAAA;IAEnC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;QAC9C,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAChE,OAAO,QAAQ,CAAA;QACjB,CAAC;QAED,wEAAwE;QACxE,qEAAqE;QACrE,EAAE;QACF,uEAAuE;QACvE,qEAAqE;QACrE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,yEAAyE;QACzE,EAAE;QACF,yEAAyE;QACzE,yEAAyE;QACzE,oEAAoE;QACpE,4CAA4C;QAC5C,MAAM,cAAc,GAAG,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3D,IAAI,MAAM,CAAC,MAAM,KAAK,aAAa,IAAI,CAAC,cAAc;YAAE,OAAO,QAAQ,CAAA;QAEvE,IAAI,MAAM,CAAC,MAAM,KAAK,aAAa,EAAE,CAAC;YACpC,oEAAoE;YACpE,kDAAkD;YAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAA;YAC9D,mEAAmE;YACnE,kEAAkE;YAClE,OAAO,MAAM,CAAC,QAAQ,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;QAC3F,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;IAAC,MAAM,CAAC;QACP,cAAc;IAChB,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -20,7 +20,7 @@ export interface EntryLinkValidationResult {
20
20
  /**
21
21
  * Validate entry links in body/markdown/mdx fields of the provided data.
22
22
  *
23
- * Scans all markdown, mdx, and rich-text fields for entry:ID patterns
23
+ * Scans all markdown and mdx fields for entry:ID patterns
24
24
  * and checks that each referenced ID exists in the content index.
25
25
  */
26
26
  export declare function validateEntryLinks(data: Record<string, unknown>, schema: readonly FieldConfig[], idIndex: ContentIdIndex, bodyContent?: string): EntryLinkValidationResult;
@@ -11,7 +11,7 @@ import { findFieldsByType } from './field-traversal.js';
11
11
  /**
12
12
  * Validate entry links in body/markdown/mdx fields of the provided data.
13
13
  *
14
- * Scans all markdown, mdx, and rich-text fields for entry:ID patterns
14
+ * Scans all markdown and mdx fields for entry:ID patterns
15
15
  * and checks that each referenced ID exists in the content index.
16
16
  */
17
17
  export function validateEntryLinks(data, schema, idIndex, bodyContent) {
@@ -20,8 +20,8 @@ export function validateEntryLinks(data, schema, idIndex, bodyContent) {
20
20
  if (bodyContent) {
21
21
  checkText(bodyContent, 'body', 'body', idIndex, warnings);
22
22
  }
23
- // Check markdown/mdx/rich-text fields in structured data
24
- const markdownTypes = ['markdown', 'mdx', 'rich-text'];
23
+ // Check markdown/mdx fields in structured data
24
+ const markdownTypes = ['markdown', 'mdx'];
25
25
  for (const fieldType of markdownTypes) {
26
26
  const contexts = findFieldsByType(schema, data, fieldType);
27
27
  for (const ctx of contexts) {
@@ -1 +1 @@
1
- {"version":3,"file":"entry-link-validator.js","sourceRoot":"","sources":["../../src/validation/entry-link-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAapD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAA6B,EAC7B,MAA8B,EAC9B,OAAuB,EACvB,WAAoB;IAEpB,MAAM,QAAQ,GAAuB,EAAE,CAAA;IAEvC,sEAAsE;IACtE,IAAI,WAAW,EAAE,CAAC;QAChB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC3D,CAAC;IAED,yDAAyD;IACzD,MAAM,aAAa,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I,KAAK,OAAO,EAAE,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC;gBACZ,KAAK,EAAE,SAAS;gBAChB,SAAS;gBACT,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,OAAO,EAAE,sCAAsC,IAAI,CAAC,EAAE,EAAE;aACzD,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -28,7 +28,7 @@ import { findBodyFieldName } from '../utils/body-field.js';
28
28
  import { isDataOnlyFormat } from '../utils/format.js';
29
29
  const KNOWN_FIELD_TYPES = new Set(fieldTypes);
30
30
  /** Field types whose value is a plain string. */
31
- const STRING_FIELD_TYPES = new Set(['string', 'rich-text', 'markdown', 'mdx', 'code']);
31
+ const STRING_FIELD_TYPES = new Set(['string', 'markdown', 'mdx', 'code']);
32
32
  function isPlainRecord(value) {
33
33
  return typeof value === 'object' && value !== null && !Array.isArray(value);
34
34
  }