@fractalsynapse/dsh-chapters 0.0.0-stage → 0.2.20

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 (195) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +76 -2
  3. package/cordis.patch.yml +363 -0
  4. package/docs/architecture.md +692 -0
  5. package/docs/autorun-guide.md +248 -0
  6. package/docs/backlog.md +2022 -0
  7. package/docs/contract.md +938 -0
  8. package/docs/development.md +990 -0
  9. package/docs/host-compaction-seam.md +225 -0
  10. package/docs/host-protected-head-ask.md +80 -0
  11. package/docs/knowledge-repo.md +1332 -0
  12. package/docs/plans-carriage.md +571 -0
  13. package/docs/project-state.md +642 -0
  14. package/docs/provider.md +98 -0
  15. package/docs/superpowers/plans/2026-10-17-chapters-save.md +198 -0
  16. package/docs/superpowers/plans/2026-11-02-chapter-removal.md +151 -0
  17. package/docs/superpowers/specs/2026-11-02-chapter-removal-design.md +115 -0
  18. package/docs/verify.md +561 -0
  19. package/lib/archive.d.ts +161 -0
  20. package/lib/archive.js +229 -0
  21. package/lib/archive.js.map +1 -0
  22. package/lib/arrival.d.ts +23 -0
  23. package/lib/arrival.js +125 -0
  24. package/lib/arrival.js.map +1 -0
  25. package/lib/artifact-query.d.ts +62 -0
  26. package/lib/artifact-query.js +187 -0
  27. package/lib/artifact-query.js.map +1 -0
  28. package/lib/attach.d.ts +46 -0
  29. package/lib/attach.js +120 -0
  30. package/lib/attach.js.map +1 -0
  31. package/lib/auto-save.d.ts +145 -0
  32. package/lib/auto-save.js +334 -0
  33. package/lib/auto-save.js.map +1 -0
  34. package/lib/aux-message.d.ts +17 -0
  35. package/lib/aux-message.js +20 -0
  36. package/lib/aux-message.js.map +1 -0
  37. package/lib/client.js +1419 -0
  38. package/lib/client.js.map +1 -0
  39. package/lib/codegraph.d.ts +76 -0
  40. package/lib/codegraph.js +190 -0
  41. package/lib/codegraph.js.map +1 -0
  42. package/lib/commands.d.ts +52 -0
  43. package/lib/commands.js +946 -0
  44. package/lib/commands.js.map +1 -0
  45. package/lib/compose.d.ts +30 -0
  46. package/lib/compose.js +185 -0
  47. package/lib/compose.js.map +1 -0
  48. package/lib/continue-core.d.ts +245 -0
  49. package/lib/continue-core.js +405 -0
  50. package/lib/continue-core.js.map +1 -0
  51. package/lib/diag.d.ts +55 -0
  52. package/lib/diag.js +186 -0
  53. package/lib/diag.js.map +1 -0
  54. package/lib/engine-core.d.ts +301 -0
  55. package/lib/engine-core.js +531 -0
  56. package/lib/engine-core.js.map +1 -0
  57. package/lib/engine-note.d.ts +35 -0
  58. package/lib/engine-note.js +32 -0
  59. package/lib/engine-note.js.map +1 -0
  60. package/lib/engine.d.ts +329 -0
  61. package/lib/engine.js +1179 -0
  62. package/lib/engine.js.map +1 -0
  63. package/lib/enrich-queue.d.ts +66 -0
  64. package/lib/enrich-queue.js +126 -0
  65. package/lib/enrich-queue.js.map +1 -0
  66. package/lib/enrich-store.d.ts +31 -0
  67. package/lib/enrich-store.js +103 -0
  68. package/lib/enrich-store.js.map +1 -0
  69. package/lib/enrich-wire.d.ts +163 -0
  70. package/lib/enrich-wire.js +353 -0
  71. package/lib/enrich-wire.js.map +1 -0
  72. package/lib/enrich.d.ts +102 -0
  73. package/lib/enrich.js +267 -0
  74. package/lib/enrich.js.map +1 -0
  75. package/lib/gitops.d.ts +107 -0
  76. package/lib/gitops.js +539 -0
  77. package/lib/gitops.js.map +1 -0
  78. package/lib/index.d.ts +241 -0
  79. package/lib/index.js +1162 -0
  80. package/lib/index.js.map +1 -0
  81. package/lib/indexing.d.ts +98 -0
  82. package/lib/indexing.js +223 -0
  83. package/lib/indexing.js.map +1 -0
  84. package/lib/injections.d.ts +90 -0
  85. package/lib/injections.js +165 -0
  86. package/lib/injections.js.map +1 -0
  87. package/lib/last-resort.d.ts +24 -0
  88. package/lib/last-resort.js +27 -0
  89. package/lib/last-resort.js.map +1 -0
  90. package/lib/log-shape.d.ts +38 -0
  91. package/lib/log-shape.js +93 -0
  92. package/lib/log-shape.js.map +1 -0
  93. package/lib/models-command.d.ts +74 -0
  94. package/lib/models-command.js +100 -0
  95. package/lib/models-command.js.map +1 -0
  96. package/lib/notice.d.ts +74 -0
  97. package/lib/notice.js +92 -0
  98. package/lib/notice.js.map +1 -0
  99. package/lib/plans.d.ts +154 -0
  100. package/lib/plans.js +315 -0
  101. package/lib/plans.js.map +1 -0
  102. package/lib/preset.d.ts +186 -0
  103. package/lib/preset.js +212 -0
  104. package/lib/preset.js.map +1 -0
  105. package/lib/prompt-keys.d.ts +7 -0
  106. package/lib/prompt-keys.js +8 -0
  107. package/lib/prompt-keys.js.map +1 -0
  108. package/lib/prompt-loop.d.ts +73 -0
  109. package/lib/prompt-loop.js +147 -0
  110. package/lib/prompt-loop.js.map +1 -0
  111. package/lib/prompt-push.d.ts +47 -0
  112. package/lib/prompt-push.js +115 -0
  113. package/lib/prompt-push.js.map +1 -0
  114. package/lib/prompt-runner.d.ts +48 -0
  115. package/lib/prompt-runner.js +90 -0
  116. package/lib/prompt-runner.js.map +1 -0
  117. package/lib/prompt-state.d.ts +142 -0
  118. package/lib/prompt-state.js +101 -0
  119. package/lib/prompt-state.js.map +1 -0
  120. package/lib/prompt.d.ts +270 -0
  121. package/lib/prompt.js +408 -0
  122. package/lib/prompt.js.map +1 -0
  123. package/lib/provider.d.ts +44 -0
  124. package/lib/provider.js +66 -0
  125. package/lib/provider.js.map +1 -0
  126. package/lib/redact.d.ts +24 -0
  127. package/lib/redact.js +85 -0
  128. package/lib/redact.js.map +1 -0
  129. package/lib/registry.d.ts +187 -0
  130. package/lib/registry.js +235 -0
  131. package/lib/registry.js.map +1 -0
  132. package/lib/removal.d.ts +159 -0
  133. package/lib/removal.js +556 -0
  134. package/lib/removal.js.map +1 -0
  135. package/lib/render.d.ts +97 -0
  136. package/lib/render.js +530 -0
  137. package/lib/render.js.map +1 -0
  138. package/lib/repair-run.d.ts +76 -0
  139. package/lib/repair-run.js +506 -0
  140. package/lib/repair-run.js.map +1 -0
  141. package/lib/repair.d.ts +208 -0
  142. package/lib/repair.js +357 -0
  143. package/lib/repair.js.map +1 -0
  144. package/lib/repo.d.ts +78 -0
  145. package/lib/repo.js +184 -0
  146. package/lib/repo.js.map +1 -0
  147. package/lib/rules-commands.d.ts +46 -0
  148. package/lib/rules-commands.js +379 -0
  149. package/lib/rules-commands.js.map +1 -0
  150. package/lib/rules.d.ts +267 -0
  151. package/lib/rules.js +478 -0
  152. package/lib/rules.js.map +1 -0
  153. package/lib/save-core.d.ts +72 -0
  154. package/lib/save-core.js +220 -0
  155. package/lib/save-core.js.map +1 -0
  156. package/lib/search.d.ts +112 -0
  157. package/lib/search.js +282 -0
  158. package/lib/search.js.map +1 -0
  159. package/lib/session-rules.d.ts +222 -0
  160. package/lib/session-rules.js +454 -0
  161. package/lib/session-rules.js.map +1 -0
  162. package/lib/signature.d.ts +45 -0
  163. package/lib/signature.js +199 -0
  164. package/lib/signature.js.map +1 -0
  165. package/lib/store.d.ts +156 -0
  166. package/lib/store.js +368 -0
  167. package/lib/store.js.map +1 -0
  168. package/lib/sync.d.ts +220 -0
  169. package/lib/sync.js +810 -0
  170. package/lib/sync.js.map +1 -0
  171. package/lib/tools.d.ts +113 -0
  172. package/lib/tools.js +1090 -0
  173. package/lib/tools.js.map +1 -0
  174. package/lib/treedx/client.d.ts +57 -0
  175. package/lib/treedx/client.js +82 -0
  176. package/lib/treedx/client.js.map +1 -0
  177. package/lib/treedx/provider.d.ts +39 -0
  178. package/lib/treedx/provider.js +479 -0
  179. package/lib/treedx/provider.js.map +1 -0
  180. package/lib/treedx/state.d.ts +27 -0
  181. package/lib/treedx/state.js +65 -0
  182. package/lib/treedx/state.js.map +1 -0
  183. package/lib/types.d.ts +210 -0
  184. package/lib/types.js +31 -0
  185. package/lib/types.js.map +1 -0
  186. package/lib/version.d.ts +9 -0
  187. package/lib/version.js +10 -0
  188. package/lib/version.js.map +1 -0
  189. package/lib/vocabulary.d.ts +41 -0
  190. package/lib/vocabulary.js +118 -0
  191. package/lib/vocabulary.js.map +1 -0
  192. package/lib/warnings.d.ts +10 -0
  193. package/lib/warnings.js +18 -0
  194. package/lib/warnings.js.map +1 -0
  195. package/package.json +151 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EAAE,eAAe,EAAqB,MAAM,eAAe,CAAA;AAGlE,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAA;AAiFhD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA2B,EAAE,WAAmB;IAClF,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAA;IAC9E,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,EAAE,CAAA;IAC5B,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,YAAgC;IAC/E,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,4BAA4B,EAAE,CAAA;IAC7E,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC3B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,EAAE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AAK,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;AACtH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAGxC;IACC,MAAM,GAAG,GAA0B,EAAE,CAAA;IACrC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;YACxC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAClH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Knowledge-transport providers (knowledge-repo.md §3.2, extended by the §15
3
+ * amendment "transport is pluggable; git is one provider").
4
+ *
5
+ * The sync loop's transport surface is exactly six verbs — ensureClone,
6
+ * initLocal, removeMirror, stageAllAndCommit, pullFastForward, push — every one
7
+ * returning `{ok, detail, code?}` because §5.3 makes transport best-effort by
8
+ * rule: a transport failure degrades to local-only, it never throws into a
9
+ * conversation. A `SyncProvider` is those verbs plus an identity: `kind` (what
10
+ * the project record says it is, and what status lines print) and `describe`
11
+ * (one honest line for /chapters-status — e.g. which remote, which head).
12
+ *
13
+ * What a provider is NOT: storage. The workspace store stays the truth in
14
+ * every mode (§3.1); the mirror directory is materialized the same way whether
15
+ * a git clone or a remote API fills it, so search, rules, index build, and the
16
+ * read path never learn who transported the bytes. Adding a backend means
17
+ * implementing these six verbs and registering the kind — nothing else may
18
+ * grow provider-specific branches.
19
+ */
20
+ import { type GitDriver } from './gitops.ts';
21
+ import type { ProjectRecord } from './sync.ts';
22
+ export type ProviderKind = 'git' | 'treedx';
23
+ export interface SyncProvider extends GitDriver {
24
+ readonly kind: ProviderKind;
25
+ /** One human line describing where this project's transport points. */
26
+ describe(project: ProjectRecord): string;
27
+ }
28
+ /** The default provider: pure-JS git over HTTPS / local paths (record §3.2). */
29
+ export declare const gitProvider: SyncProvider;
30
+ export declare function registerProvider(provider: SyncProvider): void;
31
+ /**
32
+ * Resolve the transport for a project record. `kind` absent = 'git' (every
33
+ * record written before providers existed parses to this default).
34
+ * Throws for an unknown/unregistered kind — callers degrade loudly (§5.3):
35
+ * the sync pass reports local-only with the reason; nothing silently reroutes.
36
+ */
37
+ export declare function selectProvider(project: Pick<ProjectRecord, 'kind' | 'remote'>): SyncProvider;
38
+ /**
39
+ * Reconcile a remote target's scheme with the configured `knowledgeProvider`
40
+ * policy ('auto' | 'git' | 'treedx'). A contradiction throws — NOTHING ever
41
+ * silently falls back into a different pool; the caller degrades loudly
42
+ * (auto-link skips + warns; /chapters-link refuses with the message).
43
+ */
44
+ export declare function providerKindFor(targetKind: ProviderKind, policy: string): ProviderKind;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Knowledge-transport providers (knowledge-repo.md §3.2, extended by the §15
3
+ * amendment "transport is pluggable; git is one provider").
4
+ *
5
+ * The sync loop's transport surface is exactly six verbs — ensureClone,
6
+ * initLocal, removeMirror, stageAllAndCommit, pullFastForward, push — every one
7
+ * returning `{ok, detail, code?}` because §5.3 makes transport best-effort by
8
+ * rule: a transport failure degrades to local-only, it never throws into a
9
+ * conversation. A `SyncProvider` is those verbs plus an identity: `kind` (what
10
+ * the project record says it is, and what status lines print) and `describe`
11
+ * (one honest line for /chapters-status — e.g. which remote, which head).
12
+ *
13
+ * What a provider is NOT: storage. The workspace store stays the truth in
14
+ * every mode (§3.1); the mirror directory is materialized the same way whether
15
+ * a git clone or a remote API fills it, so search, rules, index build, and the
16
+ * read path never learn who transported the bytes. Adding a backend means
17
+ * implementing these six verbs and registering the kind — nothing else may
18
+ * grow provider-specific branches.
19
+ */
20
+ import { isomorphicDriver } from "./gitops.js";
21
+ /** The default provider: pure-JS git over HTTPS / local paths (record §3.2). */
22
+ export const gitProvider = {
23
+ ...isomorphicDriver,
24
+ kind: 'git',
25
+ describe: (project) => `git · ${project.remote}`,
26
+ };
27
+ // Registration is a map keyed by kind; Phase C's treedx module adds its entry.
28
+ // Kept as a registry (not a switch) so provider selection stays open while
29
+ // `kind` stays closed: an unknown kind is a LOUD refusal, never a silent
30
+ // fallback to git that would sync someone's chapters into the wrong pool.
31
+ const registry = new Map([['git', gitProvider]]);
32
+ export function registerProvider(provider) {
33
+ registry.set(provider.kind, provider);
34
+ }
35
+ /**
36
+ * Resolve the transport for a project record. `kind` absent = 'git' (every
37
+ * record written before providers existed parses to this default).
38
+ * Throws for an unknown/unregistered kind — callers degrade loudly (§5.3):
39
+ * the sync pass reports local-only with the reason; nothing silently reroutes.
40
+ */
41
+ export function selectProvider(project) {
42
+ const kind = project.kind ?? 'git';
43
+ const provider = registry.get(kind);
44
+ if (provider === undefined) {
45
+ throw new Error(`knowledge provider '${kind}' is not registered (remote ${project.remote})`);
46
+ }
47
+ return provider;
48
+ }
49
+ /**
50
+ * Reconcile a remote target's scheme with the configured `knowledgeProvider`
51
+ * policy ('auto' | 'git' | 'treedx'). A contradiction throws — NOTHING ever
52
+ * silently falls back into a different pool; the caller degrades loudly
53
+ * (auto-link skips + warns; /chapters-link refuses with the message).
54
+ */
55
+ export function providerKindFor(targetKind, policy) {
56
+ if (policy === 'auto')
57
+ return targetKind;
58
+ if (policy !== 'git' && policy !== 'treedx') {
59
+ throw new Error(`knowledgeProvider policy '${policy}' is not one of auto | git | treedx`);
60
+ }
61
+ if (policy !== targetKind) {
62
+ throw new Error(`knowledgeProvider policy '${policy}' contradicts the remote target (a ${targetKind} remote) — fix one; there is no automatic fallback`);
63
+ }
64
+ return policy;
65
+ }
66
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,gBAAgB,EAAkB,MAAM,aAAa,CAAA;AAW9D,gFAAgF;AAChF,MAAM,CAAC,MAAM,WAAW,GAAiB;IACvC,GAAG,gBAAgB;IACnB,IAAI,EAAE,KAAK;IACX,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE;CACjD,CAAA;AAED,+EAA+E;AAC/E,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,MAAM,QAAQ,GAAG,IAAI,GAAG,CAA6B,CAAC,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;AAE5E,MAAM,UAAU,gBAAgB,CAAC,QAAsB;IACrD,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAA+C;IAC5E,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,KAAK,CAAA;IAClC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,+BAA+B,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;IAC9F,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,UAAwB,EAAE,MAAc;IACtE,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,UAAU,CAAA;IACxC,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAM,qCAAqC,CAAC,CAAA;IAC3F,CAAC;IACD,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAM,sCAAsC,UAAU,oDAAoD,CAAC,CAAA;IAC1J,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,24 @@
1
+ export interface RedactPattern {
2
+ name: string;
3
+ /** Global regex; the secret is the whole match unless `secretGroup` names a capture group. */
4
+ regex: RegExp;
5
+ /** Capture group holding the secret (e.g. keep `token=`, redact the value). Default: whole match. */
6
+ secretGroup?: number;
7
+ }
8
+ /** Built-in set (record §9). New patterns are config additions, not magic. */
9
+ export declare const DEFAULT_REDACTIONS: readonly RedactPattern[];
10
+ export interface RedactionResult {
11
+ text: string;
12
+ /** Number of secret occurrences replaced. */
13
+ count: number;
14
+ /** Distinct markers produced (for tests/audit; order of first appearance). */
15
+ markers: string[];
16
+ }
17
+ /**
18
+ * Replace every pattern match's secret with its stable marker.
19
+ * `secretGroup` semantics: the named group is the LABEL to keep; the secret
20
+ * is the rest of the match (url-credential-param, bearer). Without it, the
21
+ * whole match is the secret. Markers never re-match any pattern (verified by
22
+ * test), so passes compose safely.
23
+ */
24
+ export declare function redactText(text: string, patterns?: readonly RedactPattern[]): RedactionResult;
package/lib/redact.js ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Deterministic credential redaction (knowledge-repo.md §9).
3
+ *
4
+ * The user's position, adopted: credentials only, deterministic patterns only,
5
+ * everything else byte-identical — the character of the conversation is
6
+ * historical value and stays intact. The marker is deliberate and stable:
7
+ * ⟦redacted:credential sha256=8f3a1c2b⟧
8
+ * (a) obviously not a real value to any model reading a chapter,
9
+ * (b) deterministic per secret — same secret, same marker, so diffs and
10
+ * cross-chapter greps stay stable,
11
+ * (c) leaks nothing but an 8-hex prefix hash, which is also what lets a user
12
+ * ask "which secrets touched my sessions" without exposing them.
13
+ *
14
+ * Patterns are conservative by design and config-extensible; redaction is a
15
+ * speed bump, not a guarantee (the record says so, and so does the in-repo
16
+ * notice). Applied once, at the render chokepoint (src/render.ts), so chapters
17
+ * and artifact files are both covered without caller changes.
18
+ */
19
+ import { createHash } from 'node:crypto';
20
+ /** Built-in set (record §9). New patterns are config additions, not magic. */
21
+ export const DEFAULT_REDACTIONS = [
22
+ { name: 'pem-private-key', regex: /-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----/g },
23
+ { name: 'aws-access-key-id', regex: /\bAKIA[0-9A-Z]{16}\b/g },
24
+ { name: 'github-token', regex: /\b(?:ghp|gho|ghs|ghu)_[A-Za-z0-9]{16,}\b/g },
25
+ { name: 'github-fine-grained', regex: /\bgithub_pat_[A-Za-z0-9_]{16,}\b/g },
26
+ { name: 'openai-style-key', regex: /\bsk-[A-Za-z0-9_-]{16,}\b/g },
27
+ { name: 'jwt', regex: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}\b/g },
28
+ { name: 'bearer-token', regex: /\b(Bearer\s+)[A-Za-z0-9._~+/=-]{16,}/gi, secretGroup: 1 },
29
+ { name: 'url-credential-param', regex: /([?&](?:token|api[_-]?key|apikey|key|secret|password)=)[^&\s"'`]+/gi, secretGroup: 1 },
30
+ ];
31
+ /**
32
+ * `Bearer <tok>` → redact the token, keep the `Bearer ` label: the pattern's
33
+ * `secretGroup` names the capture that is NOT the secret; here we invert —
34
+ * the label is group 1, so the secret is the remainder of the match after
35
+ * the group. Implemented via a post-step in redactText (label-aware patterns).
36
+ */
37
+ function markerFor(secret) {
38
+ const h = createHash('sha256').update(secret, 'utf8').digest('hex').slice(0, 8);
39
+ return `⟦redacted:credential sha256=${h}⟧`;
40
+ }
41
+ /**
42
+ * Replace every pattern match's secret with its stable marker.
43
+ * `secretGroup` semantics: the named group is the LABEL to keep; the secret
44
+ * is the rest of the match (url-credential-param, bearer). Without it, the
45
+ * whole match is the secret. Markers never re-match any pattern (verified by
46
+ * test), so passes compose safely.
47
+ */
48
+ export function redactText(text, patterns = DEFAULT_REDACTIONS) {
49
+ let out = text;
50
+ let count = 0;
51
+ const markers = [];
52
+ for (const p of patterns) {
53
+ const re = new RegExp(p.regex.source, p.regex.flags.includes('g') ? p.regex.flags : p.regex.flags + 'g');
54
+ const matches = Array.from(out.matchAll(re));
55
+ if (matches.length === 0)
56
+ continue;
57
+ // splice back-to-front so earlier indices stay valid
58
+ for (let i = matches.length - 1; i >= 0; i -= 1) {
59
+ const m = matches[i];
60
+ const whole = m[0];
61
+ let keep = '';
62
+ let secret = whole;
63
+ // label-group patterns (bearer, url-credential): the named group is a
64
+ // PREFIX of the match and is kept; the remainder is the secret. Any
65
+ // other shape falls through to whole-match redaction (safe default).
66
+ if (p.secretGroup !== undefined) {
67
+ const label = m[p.secretGroup];
68
+ if (typeof label === 'string' && label.length > 0 && whole.startsWith(label)) {
69
+ keep = label;
70
+ secret = whole.slice(label.length);
71
+ }
72
+ }
73
+ if (secret.length === 0)
74
+ continue;
75
+ const marker = markerFor(secret);
76
+ const start = m.index + keep.length;
77
+ out = out.slice(0, start) + marker + out.slice(start + secret.length);
78
+ count += 1;
79
+ if (!markers.includes(marker))
80
+ markers.push(marker);
81
+ }
82
+ }
83
+ return { text: out, count, markers };
84
+ }
85
+ //# sourceMappingURL=redact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAUxC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAA6B;IAC1D,EAA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CAAC,GAAG,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;YACrE,KAAK,IAAI,CAAC,CAAA;YACV,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACrD,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AACtC,CAAC"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Registry — pure ancestry/numbering state. No cordis, no zod, no I/O: this is
3
+ * the L0 layer (docs/development.md § Test Layers); `src/store.ts` is the thin
4
+ * storage-domain adapter over it, deliberately untested because it is glue.
5
+ *
6
+ * The registry is the SOLE authority on ancestry (contract.md § Lineage: the
7
+ * kernel header carries `parentSession` for seed lineage we deliberately do not
8
+ * use; the UI graph will show our children as unrelated roots). Corruptions it
9
+ * must survive: cycles (walk guard throws, never hangs), duplicate chapter ids
10
+ * (append is idempotent), retry-after-crash (reserve is attempt-keyed, so the
11
+ * same `sourceSession@ceiling` reuses its numbers — archive.ts depends on it).
12
+ *
13
+ * Numbering is per-author-session (invariant: chapters keyed by creating
14
+ * session, so siblings cannot collide), and the flat index is built by the
15
+ * PLUGIN walking the ancestor path — the model never traverses a graph.
16
+ */
17
+ import type { ChapterRecord } from './archive.ts';
18
+ import type { CollectionSignature } from './signature.ts';
19
+ import { type PromptSuggestionState } from './prompt-state.ts';
20
+ export interface SessionState {
21
+ /** Registry-level parent, set at continuation commit. null until linked. */
22
+ parentSession: string | null;
23
+ /** Root of the ancestry tree; the store directory key. Self for a root session. */
24
+ rootSession: string;
25
+ /** Next unallocated chapter number for THIS author session. */
26
+ nextChapterNumber: number;
27
+ /**
28
+ * Next unallocated PLAN-DOCUMENT number for this author session. Its own counter so
29
+ * plan documents never consume a chapter number or reorder the chapter list, while
30
+ * still being allocated through the registry (never by scanning a directory — a
31
+ * concurrent sibling must not be able to pick the same name).
32
+ */
33
+ nextPlanNumber: number;
34
+ chapters: ChapterRecord[];
35
+ /**
36
+ * Write counter, bumped by the store on every accepted put (#59). It exists so a read-modify-write
37
+ * can DETECT that the row moved underneath it — the row is one whole value and five doors plus the
38
+ * turn/end listener write it, so "last writer wins" is not a theoretical concern: in the field a
39
+ * stale enrichment put erased a compaction's committed manifest, reservation, `finalized` entry and
40
+ * chapter record while leaving its file on disk. Optional-with-default so a stored row from before
41
+ * the field parses unchanged.
42
+ */
43
+ rev?: number | undefined;
44
+ /** attemptKey -> numbers, so an idempotent retry reuses rather than duplicates. */
45
+ reservations: Record<string, number[]>;
46
+ /**
47
+ * #113: what the Suggested Next Step bar last offered, and for which turn. `turnSeq` is the identity of
48
+ * an offer — the one-generation-per-turn key — and the pair (`status`, `turnSeq`) is what lets a re-read
49
+ * after a restart say "there is nothing pending" instead of firing a second model call for a finished turn.
50
+ */
51
+ promptSuggestion: PromptSuggestionState;
52
+ /**
53
+ * compactionId -> the plan summarize() committed to: the TOC text already
54
+ * cited `path`, so finalize (possibly after a crash and process restart)
55
+ * must reproduce it exactly. Rebuilding the title from messages is not
56
+ * available post-commit — this manifest is the durable bridge.
57
+ */
58
+ plans: Record<string, {
59
+ number: number;
60
+ path: string;
61
+ title: string;
62
+ summary: string;
63
+ chapters?: PlanChapter[] | undefined;
64
+ }>;
65
+ /**
66
+ * compactionId -> chapter numbers, written when a compaction's chapter bodies
67
+ * are durably finalized post-commit. Idempotence key for the finalizer and
68
+ * the reconciliation scan (FINDINGS § correlation seam).
69
+ */
70
+ finalized: Record<string, number[]>;
71
+ /**
72
+ * Per-turn deterministic signatures, appended at turn/end (knowledge-repo
73
+ * §4.1). The composer (§4.2) reads these at archive time; P2 enrichment may
74
+ * relabel later but never rewrites them. Append-only like chapters.
75
+ */
76
+ collections: CollectionSignature[];
77
+ }
78
+ export declare const freshSession: (sessionId: string) => SessionState;
79
+ /**
80
+ * One composed chapter of a compaction plan (r29): the composer's range,
81
+ * its reserved number and cited path, durable BEFORE the summary text cites
82
+ * them. Legacy single-chapter plans keep the four flat fields and omit this.
83
+ */
84
+ export interface PlanChapter {
85
+ number: number;
86
+ path: string;
87
+ title: string;
88
+ summary: string;
89
+ startSeq: number;
90
+ endSeq: number;
91
+ }
92
+ /** Persist a summarize-time plan so finalization survives a restart. */
93
+ export declare function rememberPlan(state: SessionState, compactionId: string, plan: {
94
+ number: number;
95
+ path: string;
96
+ title: string;
97
+ summary: string;
98
+ chapters?: PlanChapter[];
99
+ }): SessionState;
100
+ /** Record a post-commit finalization for one compaction. Same write twice is a no-op. */
101
+ export declare function markFinalized(state: SessionState, compactionId: string, numbers: readonly number[]): SessionState;
102
+ /** True when a compaction's chapters are already committed (finalizer + scan use this). */
103
+ export declare const isFinalized: (state: SessionState, compactionId: string) => boolean;
104
+ /** Immutably updated copy with `n` numbers reserved for `attemptId`. */
105
+ export declare function reserve(state: SessionState, attemptId: string, count: number): {
106
+ state: SessionState;
107
+ numbers: number[];
108
+ };
109
+ /** The same allocation rule for plan documents, on its own counter. */
110
+ export declare function reservePlan(state: SessionState, attemptId: string, count: number): {
111
+ state: SessionState;
112
+ numbers: number[];
113
+ };
114
+ /**
115
+ * Append verified chapter records.
116
+ *
117
+ * Identity is `(number, sha256)`, never `number` alone (#59). An identical record is a no-op — that is
118
+ * what makes a retry after a crash safe. A record reusing a number for DIFFERENT bytes is not a retry,
119
+ * it is a collision: one door's reservation was rewound by a lost update and another door has now been
120
+ * handed a number whose file already exists. Measured in the field: chapter 15 was spent twice in
121
+ * `session-aac0254e`, and number-only dedupe silently DROPPED the second record while its 960 KB file
122
+ * stayed on disk — a chapter no TOC cites and no tool can find. Refusing is the only honest option.
123
+ */
124
+ /**
125
+ * The ONE test for "may this chapter be shown as knowledge?" (#60, widened by #255). Both tombstone
126
+ * statuses fail it: a `superseded` husk left by repair, and a `removed` stub whose bytes the operator
127
+ * deleted. Every derived layer — the TOC a child is seeded with, the flat index, the enrichment queue,
128
+ * anything else that reads `state.chapters` — goes through this predicate, because a second hand-rolled
129
+ * comparison is how a widened meaning silently fails to reach one layer (#59; the gate is
130
+ * tests/unit/one-predicate.test.ts). Records written before this field existed are `undefined`, i.e.
131
+ * active: legacy archives are never silently hidden by a new filter.
132
+ */
133
+ export declare function isActiveChapter(c: {
134
+ status?: 'superseded' | 'removed' | undefined;
135
+ }): boolean;
136
+ /**
137
+ * The ONE positive arm for the #255 tombstone (chapter-only status value — plan statuses share the
138
+ * word `superseded` but not this one). For auditors that must COUNT removed stubs, not hide them:
139
+ * the knowledge gate above, the count below, one status read each, both here (#59).
140
+ */
141
+ export declare function isRemovedChapter(c: {
142
+ status?: 'superseded' | 'removed' | undefined;
143
+ }): boolean;
144
+ export declare function appendChapters(state: SessionState, records: readonly ChapterRecord[]): SessionState;
145
+ /**
146
+ * Free an attempt's retry key WITHOUT un-spacing its numbers (#59). Reserve-before-write exists so a
147
+ * crash cannot re-issue a number whose file may already be on disk; that guarantee must not be undone
148
+ * here. What this does is stop a burned key from living forever: a door that reserved and then failed
149
+ * (a read-back that did not verify, a refusal after writing) currently leaves `reservations[k]` behind
150
+ * with no file and no record, which is the state the field showed at numbers 20 and 37.
151
+ *
152
+ * `numbersSpent` stays monotonic — only the attempt key goes.
153
+ */
154
+ export declare function releaseReservation(state: SessionState, attemptId: string): SessionState;
155
+ /**
156
+ * Commit point for a continuation: the child inherits the PARENT's root and
157
+ * gets its direct parent recorded. Set once, never rewritten — re-pointing a
158
+ * linked session would silently re-home every chapter below it. Same link
159
+ * twice is a no-op (retry safety); a DIFFERENT link is corruption or a bug,
160
+ * and it throws.
161
+ */
162
+ export declare function linkChild(state: SessionState, parentSessionId: string, parentRootSession: string): SessionState;
163
+ /**
164
+ * Walk parent links root-first. Throws on a cycle or a missing parent — both
165
+ * are registry corruption, and an infinite walk is how a small bad write
166
+ * becomes a hung plugin at the worst moment.
167
+ */
168
+ export declare function ancestorPath(get: (id: string) => SessionState | undefined, sessionId: string, maxDepth?: number): string[];
169
+ export interface IndexEntry {
170
+ /** Session that authored the chapter, for back-links. */
171
+ authorSession: string;
172
+ number: number;
173
+ path: string;
174
+ title: string;
175
+ summary: string;
176
+ /** Integrity verdict supplied by the caller (verifyChapter via its fs port). */
177
+ status: 'ok' | 'modified' | 'missing';
178
+ }
179
+ /**
180
+ * The flat, chronological, numbered index the TOC renders — reading order IS
181
+ * causal order (docs/architecture.md § Ancestry). Ancestor sessions first;
182
+ * within a session, by reserved number. Siblings are excluded by construction:
183
+ * the walk never enters them.
184
+ */
185
+ export declare function buildIndex(path: readonly string[], get: (id: string) => SessionState | undefined, status: (record: ChapterRecord) => IndexEntry['status']): IndexEntry[];
186
+ /** Append one turn's signature. Idempotent per turn (same seqs → no-op), like appendChapters. */
187
+ export declare function appendCollection(state: SessionState, sig: CollectionSignature): SessionState;