@cleocode/core 2026.10.12 → 2026.10.13-rc.ci.682
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.
- package/dist/build-provenance.json +2 -2
- package/dist/cloud/nexus-auth.d.ts.map +1 -1
- package/dist/cloud/nexus-auth.js +11 -2
- package/dist/cloud/nexus-auth.js.map +1 -1
- package/dist/cloud/nexus-cloud-status.d.ts.map +1 -1
- package/dist/cloud/nexus-cloud-status.js +18 -5
- package/dist/cloud/nexus-cloud-status.js.map +1 -1
- package/dist/cloud/nexus-credentials.d.ts +3 -2
- package/dist/cloud/nexus-credentials.d.ts.map +1 -1
- package/dist/cloud/nexus-credentials.js +58 -14
- package/dist/cloud/nexus-credentials.js.map +1 -1
- package/dist/cloud/nexus-logout.d.ts.map +1 -1
- package/dist/cloud/nexus-logout.js +12 -2
- package/dist/cloud/nexus-logout.js.map +1 -1
- package/dist/cloud/nexus-vault-state.d.ts.map +1 -1
- package/dist/cloud/nexus-vault-state.js +6 -26
- package/dist/cloud/nexus-vault-state.js.map +1 -1
- package/dist/config/registry.d.ts +21 -0
- package/dist/config/registry.d.ts.map +1 -1
- package/dist/config/registry.js +41 -0
- package/dist/config/registry.js.map +1 -1
- package/dist/dispatch/mvi-projection.d.ts.map +1 -1
- package/dist/dispatch/mvi-projection.js +2 -0
- package/dist/dispatch/mvi-projection.js.map +1 -1
- package/dist/docs/docs-ops.d.ts +15 -14
- package/dist/docs/docs-ops.d.ts.map +1 -1
- package/dist/docs/docs-ops.js +32 -96
- package/dist/docs/docs-ops.js.map +1 -1
- package/dist/docs/docs-read-model.d.ts +19 -10
- package/dist/docs/docs-read-model.d.ts.map +1 -1
- package/dist/docs/docs-read-model.js +31 -47
- package/dist/docs/docs-read-model.js.map +1 -1
- package/dist/docs/docs-update.d.ts +51 -1
- package/dist/docs/docs-update.d.ts.map +1 -1
- package/dist/docs/docs-update.js +235 -13
- package/dist/docs/docs-update.js.map +1 -1
- package/dist/docs/doctor.d.ts +26 -4
- package/dist/docs/doctor.d.ts.map +1 -1
- package/dist/docs/doctor.js +260 -102
- package/dist/docs/doctor.js.map +1 -1
- package/dist/docs/fetch-result.d.ts +30 -10
- package/dist/docs/fetch-result.d.ts.map +1 -1
- package/dist/docs/fetch-result.js +100 -15
- package/dist/docs/fetch-result.js.map +1 -1
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +1 -0
- package/dist/docs/index.js.map +1 -1
- package/dist/docs/legacy-doc-migration.d.ts +182 -0
- package/dist/docs/legacy-doc-migration.d.ts.map +1 -0
- package/dist/docs/legacy-doc-migration.js +480 -0
- package/dist/docs/legacy-doc-migration.js.map +1 -0
- package/dist/docs/publications-store.d.ts +67 -0
- package/dist/docs/publications-store.d.ts.map +1 -0
- package/dist/docs/publications-store.js +193 -0
- package/dist/docs/publications-store.js.map +1 -0
- package/dist/docs/publish-pr.d.ts.map +1 -1
- package/dist/docs/publish-pr.js +31 -18
- package/dist/docs/publish-pr.js.map +1 -1
- package/dist/docs/section-leases.d.ts +233 -0
- package/dist/docs/section-leases.d.ts.map +1 -0
- package/dist/docs/section-leases.js +344 -0
- package/dist/docs/section-leases.js.map +1 -0
- package/dist/docs/section-merge.d.ts +159 -0
- package/dist/docs/section-merge.d.ts.map +1 -0
- package/dist/docs/section-merge.js +215 -0
- package/dist/docs/section-merge.js.map +1 -0
- package/dist/docs/section-write-path.d.ts +191 -0
- package/dist/docs/section-write-path.d.ts.map +1 -0
- package/dist/docs/section-write-path.js +423 -0
- package/dist/docs/section-write-path.js.map +1 -0
- package/dist/docs/stats.d.ts +56 -0
- package/dist/docs/stats.d.ts.map +1 -0
- package/dist/docs/stats.js +119 -0
- package/dist/docs/stats.js.map +1 -0
- package/dist/gc/cleanup.d.ts +1 -1
- package/dist/gc/cleanup.d.ts.map +1 -1
- package/dist/gc/cleanup.js +10 -1
- package/dist/gc/cleanup.js.map +1 -1
- package/dist/gc/janitor.js +1 -1
- package/dist/gc/janitor.js.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/memory/pipeline-manifest-sqlite.d.ts +34 -0
- package/dist/memory/pipeline-manifest-sqlite.d.ts.map +1 -1
- package/dist/memory/pipeline-manifest-sqlite.js +114 -0
- package/dist/memory/pipeline-manifest-sqlite.js.map +1 -1
- package/dist/nexus/analyze-orchestrator.d.ts +5 -1
- package/dist/nexus/analyze-orchestrator.d.ts.map +1 -1
- package/dist/nexus/analyze-orchestrator.js +25 -13
- package/dist/nexus/analyze-orchestrator.js.map +1 -1
- package/dist/nexus/assessment-store.d.ts +8 -4
- package/dist/nexus/assessment-store.d.ts.map +1 -1
- package/dist/nexus/assessment-store.js +18 -27
- package/dist/nexus/assessment-store.js.map +1 -1
- package/dist/orchestration/index.d.ts.map +1 -1
- package/dist/orchestration/index.js +6 -0
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/lean-change.d.ts +104 -5
- package/dist/orchestration/lean-change.d.ts.map +1 -1
- package/dist/orchestration/lean-change.js +162 -6
- package/dist/orchestration/lean-change.js.map +1 -1
- package/dist/orchestration/spawn-prompt.d.ts +6 -1
- package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
- package/dist/orchestration/spawn-prompt.js +3 -1
- package/dist/orchestration/spawn-prompt.js.map +1 -1
- package/dist/orchestration/spawn.d.ts.map +1 -1
- package/dist/orchestration/spawn.js +6 -0
- package/dist/orchestration/spawn.js.map +1 -1
- package/dist/release/open.d.ts.map +1 -1
- package/dist/release/open.js +6 -2
- package/dist/release/open.js.map +1 -1
- package/dist/release/plan.d.ts.map +1 -1
- package/dist/release/plan.js +33 -2
- package/dist/release/plan.js.map +1 -1
- package/dist/resources/admission-ledger.d.ts +5 -0
- package/dist/resources/admission-ledger.d.ts.map +1 -1
- package/dist/resources/admission-ledger.js +1 -1
- package/dist/resources/admission-ledger.js.map +1 -1
- package/dist/resources/run-admission.d.ts.map +1 -1
- package/dist/resources/run-admission.js +4 -1
- package/dist/resources/run-admission.js.map +1 -1
- package/dist/resources/run-governed.d.ts +29 -4
- package/dist/resources/run-governed.d.ts.map +1 -1
- package/dist/resources/run-governed.js +113 -73
- package/dist/resources/run-governed.js.map +1 -1
- package/dist/sentient/worktree-dispatch.d.ts +12 -1
- package/dist/sentient/worktree-dispatch.d.ts.map +1 -1
- package/dist/sentient/worktree-dispatch.js +19 -0
- package/dist/sentient/worktree-dispatch.js.map +1 -1
- package/dist/spawn/branch-lock.d.ts +11 -1
- package/dist/spawn/branch-lock.d.ts.map +1 -1
- package/dist/spawn/branch-lock.js +54 -4
- package/dist/spawn/branch-lock.js.map +1 -1
- package/dist/sticky/archive.d.ts +1 -0
- package/dist/sticky/archive.d.ts.map +1 -1
- package/dist/sticky/archive.js +13 -0
- package/dist/sticky/archive.js.map +1 -1
- package/dist/sticky/engine-ops.d.ts.map +1 -1
- package/dist/sticky/engine-ops.js +7 -0
- package/dist/sticky/engine-ops.js.map +1 -1
- package/dist/store/attachment-repair.d.ts +10 -4
- package/dist/store/attachment-repair.d.ts.map +1 -1
- package/dist/store/attachment-repair.js +52 -25
- package/dist/store/attachment-repair.js.map +1 -1
- package/dist/store/attachment-store.d.ts.map +1 -1
- package/dist/store/attachment-store.js +27 -18
- package/dist/store/attachment-store.js.map +1 -1
- package/dist/store/blob-keep.d.ts +83 -0
- package/dist/store/blob-keep.d.ts.map +1 -1
- package/dist/store/blob-keep.js +139 -0
- package/dist/store/blob-keep.js.map +1 -1
- package/dist/store/blob-ops.d.ts +24 -0
- package/dist/store/blob-ops.d.ts.map +1 -1
- package/dist/store/blob-ops.js +47 -0
- package/dist/store/blob-ops.js.map +1 -1
- package/dist/store/conduit-doc-history.d.ts +209 -0
- package/dist/store/conduit-doc-history.d.ts.map +1 -1
- package/dist/store/conduit-doc-history.js +315 -3
- package/dist/store/conduit-doc-history.js.map +1 -1
- package/dist/store/decision-adr-links.d.ts +11 -0
- package/dist/store/decision-adr-links.d.ts.map +1 -1
- package/dist/store/decision-adr-links.js +20 -1
- package/dist/store/decision-adr-links.js.map +1 -1
- package/dist/store/display-id-alias.d.ts +8 -2
- package/dist/store/display-id-alias.d.ts.map +1 -1
- package/dist/store/display-id-alias.js +8 -3
- package/dist/store/display-id-alias.js.map +1 -1
- package/dist/store/lock.d.ts +18 -0
- package/dist/store/lock.d.ts.map +1 -1
- package/dist/store/lock.js +41 -0
- package/dist/store/lock.js.map +1 -1
- package/dist/store/row-identity-registry.d.ts.map +1 -1
- package/dist/store/row-identity-registry.js +17 -0
- package/dist/store/row-identity-registry.js.map +1 -1
- package/dist/store/schema/cleo-project/conduit.d.ts +16 -0
- package/dist/store/schema/cleo-project/conduit.d.ts.map +1 -1
- package/dist/store/schema/cleo-project/conduit.js +8 -0
- package/dist/store/schema/cleo-project/conduit.js.map +1 -1
- package/dist/store/schema/cleo-project/docs.d.ts +294 -0
- package/dist/store/schema/cleo-project/docs.d.ts.map +1 -1
- package/dist/store/schema/cleo-project/docs.js +82 -0
- package/dist/store/schema/cleo-project/docs.js.map +1 -1
- package/dist/store/sync/hlc.d.ts +9 -0
- package/dist/store/sync/hlc.d.ts.map +1 -1
- package/dist/store/sync/hlc.js +9 -0
- package/dist/store/sync/hlc.js.map +1 -1
- package/dist/store/sync/merge/engine.d.ts.map +1 -1
- package/dist/store/sync/merge/engine.js +4 -2
- package/dist/store/sync/merge/engine.js.map +1 -1
- package/dist/store/sync/merge/rules.d.ts +12 -1
- package/dist/store/sync/merge/rules.d.ts.map +1 -1
- package/dist/store/sync/merge/rules.js +76 -1
- package/dist/store/sync/merge/rules.js.map +1 -1
- package/dist/store/sync/replica-registry.d.ts +6 -2
- package/dist/store/sync/replica-registry.d.ts.map +1 -1
- package/dist/store/sync/replica-registry.js +21 -9
- package/dist/store/sync/replica-registry.js.map +1 -1
- package/dist/store/sync/timestamp-canon.d.ts.map +1 -1
- package/dist/store/sync/timestamp-canon.js +6 -0
- package/dist/store/sync/timestamp-canon.js.map +1 -1
- package/dist/store/table-classification.d.ts +58 -0
- package/dist/store/table-classification.d.ts.map +1 -1
- package/dist/store/table-classification.js +72 -0
- package/dist/store/table-classification.js.map +1 -1
- package/dist/store/twin-collapse.d.ts.map +1 -1
- package/dist/store/twin-collapse.js +4 -1
- package/dist/store/twin-collapse.js.map +1 -1
- package/dist/store/vault-manifest.d.ts +10 -1
- package/dist/store/vault-manifest.d.ts.map +1 -1
- package/dist/store/vault-manifest.js +59 -1
- package/dist/store/vault-manifest.js.map +1 -1
- package/dist/tasks/affected-scope.d.ts +11 -0
- package/dist/tasks/affected-scope.d.ts.map +1 -1
- package/dist/tasks/affected-scope.js +30 -11
- package/dist/tasks/affected-scope.js.map +1 -1
- package/dist/tasks/cancel-ops.d.ts.map +1 -1
- package/dist/tasks/cancel-ops.js +7 -2
- package/dist/tasks/cancel-ops.js.map +1 -1
- package/dist/tasks/change-set.d.ts +22 -0
- package/dist/tasks/change-set.d.ts.map +1 -1
- package/dist/tasks/change-set.js +119 -2
- package/dist/tasks/change-set.js.map +1 -1
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +7 -0
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/done-plan.d.ts +5 -0
- package/dist/tasks/done-plan.d.ts.map +1 -1
- package/dist/tasks/done-plan.js +54 -19
- package/dist/tasks/done-plan.js.map +1 -1
- package/dist/tasks/engine-wrap.d.ts +4 -0
- package/dist/tasks/engine-wrap.d.ts.map +1 -1
- package/dist/tasks/engine-wrap.js +20 -4
- package/dist/tasks/engine-wrap.js.map +1 -1
- package/dist/tasks/evidence-paths.d.ts +11 -0
- package/dist/tasks/evidence-paths.d.ts.map +1 -1
- package/dist/tasks/evidence-paths.js +12 -0
- package/dist/tasks/evidence-paths.js.map +1 -1
- package/dist/tools/fs.d.ts +7 -3
- package/dist/tools/fs.d.ts.map +1 -1
- package/dist/tools/fs.js +23 -8
- package/dist/tools/fs.js.map +1 -1
- package/dist/worktree/list.d.ts.map +1 -1
- package/dist/worktree/list.js +9 -0
- package/dist/worktree/list.js.map +1 -1
- package/dist/worktree/prune.d.ts.map +1 -1
- package/dist/worktree/prune.js +52 -1
- package/dist/worktree/prune.js.map +1 -1
- package/migrations/drizzle-cleo-project/20261013000000_t13360-migrated-doc-import/migration.sql +61 -0
- package/migrations/drizzle-cleo-project/20261014000000_t13362-docs-publications-ledger/migration.sql +45 -0
- package/package.json +13 -13
- package/templates/CLEO-INJECTION.md +1 -1
- package/templates/CLEO-REFERENCE.md +2 -2
|
@@ -14,12 +14,18 @@
|
|
|
14
14
|
* Binary docs keep `bytesBase64` (≤ 1 MB inline cap).
|
|
15
15
|
* - **`refCount` is the real value** from the read model
|
|
16
16
|
* (`attachments.ref_count`; 0 for manifest-only blobs).
|
|
17
|
-
* - **`path` resolves against the
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* - **`path` always resolves against the blob store**
|
|
18
|
+
* (`.cleo/blobs/blobs/<sha256>`) — the canonical byte location since the
|
|
19
|
+
* legacy `.cleo/attachments/sha256/` tree was retired as a read surface
|
|
20
|
+
* (T13362). `fetchContent` reads the same location, so the reported path
|
|
21
|
+
* always matches where the envelope's bytes came from.
|
|
20
22
|
* - **mime/type come from the record**, never literals.
|
|
23
|
+
* - **Recorded CRDT head conflicts surface** as `headConflict` (T13604): the
|
|
24
|
+
* fetched content is the winning projection; losing edits survive in the
|
|
25
|
+
* append-only version history. Absent on a clean head — the no-conflict
|
|
26
|
+
* envelope is unchanged.
|
|
21
27
|
*
|
|
22
|
-
* @task T13352 (
|
|
28
|
+
* @task T13352 (envelope shape) · T13604 (head-conflict surfacing)
|
|
23
29
|
* @see ResolvedDoc — packages/core/src/docs/docs-read-model.ts
|
|
24
30
|
* @see readDoc — sibling read API with the same utf-8-vs-base64 body rule
|
|
25
31
|
*/
|
|
@@ -36,11 +42,14 @@ import type { ResolvedDoc } from './docs-read-model.js';
|
|
|
36
42
|
*/
|
|
37
43
|
export declare function isTextMime(mime: string | null): boolean;
|
|
38
44
|
/**
|
|
39
|
-
* Resolve the on-disk storage path for a doc
|
|
40
|
-
*
|
|
41
|
-
* (`.cleo/blobs/blobs/<sha256>`)
|
|
42
|
-
*
|
|
43
|
-
* content
|
|
45
|
+
* Resolve the on-disk storage path for a doc.
|
|
46
|
+
*
|
|
47
|
+
* The blob store (`.cleo/blobs/blobs/<sha256>`) is the canonical byte
|
|
48
|
+
* location for every doc — `DocsReadModel.fetchContent` reads bytes by
|
|
49
|
+
* content address since the legacy `.cleo/attachments/sha256/` tree was
|
|
50
|
+
* retired as a read surface (T13362), so the envelope reports that same
|
|
51
|
+
* location regardless of which registry the doc's metadata resolved from.
|
|
52
|
+
* Returns undefined for docs without a content hash.
|
|
44
53
|
*
|
|
45
54
|
* @param doc - The resolved doc record.
|
|
46
55
|
* @param cleoDir - The project's `.cleo` directory.
|
|
@@ -80,5 +89,16 @@ export declare function buildDocsFetchResult(opts: {
|
|
|
80
89
|
* field. Omitted when the doc has no live links.
|
|
81
90
|
*/
|
|
82
91
|
linkedDecisions?: string[];
|
|
83
|
-
}): DocsFetchResult
|
|
92
|
+
}): Promise<DocsFetchResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Resolve the conduit head version uid for a slug (T13674) — the version the
|
|
95
|
+
* fetched body was projected from. Returns undefined for slug-less docs,
|
|
96
|
+
* docs outside the conduit family, and any store read failure (the base
|
|
97
|
+
* parameter stays opt-in; a degraded store must not break fetch).
|
|
98
|
+
*
|
|
99
|
+
* @param projectRoot - Project root.
|
|
100
|
+
* @param slug - The doc's slug (`ResolvedDoc.slug`), or null.
|
|
101
|
+
* @returns The head version uid, or undefined when not applicable.
|
|
102
|
+
*/
|
|
103
|
+
export declare function readDocHeadVersionUid(projectRoot: string, slug: string | null): Promise<string | undefined>;
|
|
84
104
|
//# sourceMappingURL=fetch-result.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-result.d.ts","sourceRoot":"","sources":["../../src/docs/fetch-result.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fetch-result.d.ts","sourceRoot":"","sources":["../../src/docs/fetch-result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,KAAK,EACV,eAAe,EAGhB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAsBxD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAKvD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGrF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,GAAG,EAAE,WAAW,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B,GAAG,OAAO,CAAC,eAAe,CAAC,CA4C3B;AAED;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GAAG,IAAI,GAClB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAe7B"}
|
|
@@ -14,19 +14,24 @@
|
|
|
14
14
|
* Binary docs keep `bytesBase64` (≤ 1 MB inline cap).
|
|
15
15
|
* - **`refCount` is the real value** from the read model
|
|
16
16
|
* (`attachments.ref_count`; 0 for manifest-only blobs).
|
|
17
|
-
* - **`path` resolves against the
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* - **`path` always resolves against the blob store**
|
|
18
|
+
* (`.cleo/blobs/blobs/<sha256>`) — the canonical byte location since the
|
|
19
|
+
* legacy `.cleo/attachments/sha256/` tree was retired as a read surface
|
|
20
|
+
* (T13362). `fetchContent` reads the same location, so the reported path
|
|
21
|
+
* always matches where the envelope's bytes came from.
|
|
20
22
|
* - **mime/type come from the record**, never literals.
|
|
23
|
+
* - **Recorded CRDT head conflicts surface** as `headConflict` (T13604): the
|
|
24
|
+
* fetched content is the winning projection; losing edits survive in the
|
|
25
|
+
* append-only version history. Absent on a clean head — the no-conflict
|
|
26
|
+
* envelope is unchanged.
|
|
21
27
|
*
|
|
22
|
-
* @task T13352 (
|
|
28
|
+
* @task T13352 (envelope shape) · T13604 (head-conflict surfacing)
|
|
23
29
|
* @see ResolvedDoc — packages/core/src/docs/docs-read-model.ts
|
|
24
30
|
* @see readDoc — sibling read API with the same utf-8-vs-base64 body rule
|
|
25
31
|
*/
|
|
26
32
|
import { Buffer } from 'node:buffer';
|
|
27
33
|
import { join } from 'node:path';
|
|
28
34
|
import { resolveCleoDir } from '../paths.js';
|
|
29
|
-
import { blobFilePath } from '../store/blob-keep.js';
|
|
30
35
|
/** Largest body inlined into the envelope (matches the historical cap). */
|
|
31
36
|
const MAX_INLINE_BYTES = 1024 * 1024;
|
|
32
37
|
/**
|
|
@@ -63,11 +68,14 @@ export function isTextMime(mime) {
|
|
|
63
68
|
return base.startsWith('text/') || TEXT_APPLICATION_MIMES.has(base);
|
|
64
69
|
}
|
|
65
70
|
/**
|
|
66
|
-
* Resolve the on-disk storage path for a doc
|
|
67
|
-
*
|
|
68
|
-
* (`.cleo/blobs/blobs/<sha256>`)
|
|
69
|
-
*
|
|
70
|
-
* content
|
|
71
|
+
* Resolve the on-disk storage path for a doc.
|
|
72
|
+
*
|
|
73
|
+
* The blob store (`.cleo/blobs/blobs/<sha256>`) is the canonical byte
|
|
74
|
+
* location for every doc — `DocsReadModel.fetchContent` reads bytes by
|
|
75
|
+
* content address since the legacy `.cleo/attachments/sha256/` tree was
|
|
76
|
+
* retired as a read surface (T13362), so the envelope reports that same
|
|
77
|
+
* location regardless of which registry the doc's metadata resolved from.
|
|
78
|
+
* Returns undefined for docs without a content hash.
|
|
71
79
|
*
|
|
72
80
|
* @param doc - The resolved doc record.
|
|
73
81
|
* @param cleoDir - The project's `.cleo` directory.
|
|
@@ -77,10 +85,7 @@ export function isTextMime(mime) {
|
|
|
77
85
|
export function docsStoragePath(doc, cleoDir) {
|
|
78
86
|
if (!doc.sha256)
|
|
79
87
|
return undefined;
|
|
80
|
-
|
|
81
|
-
return join(cleoDir, 'blobs', 'blobs', doc.sha256);
|
|
82
|
-
}
|
|
83
|
-
return blobFilePath(cleoDir, doc.sha256, doc.mimeType ?? 'text/markdown');
|
|
88
|
+
return join(cleoDir, 'blobs', 'blobs', doc.sha256);
|
|
84
89
|
}
|
|
85
90
|
/**
|
|
86
91
|
* Build the canonical `docs.fetch` result from a resolved doc and its
|
|
@@ -95,7 +100,7 @@ export function docsStoragePath(doc, cleoDir) {
|
|
|
95
100
|
* @returns The typed {@link DocsFetchResult}.
|
|
96
101
|
* @task T13352
|
|
97
102
|
*/
|
|
98
|
-
export function buildDocsFetchResult(opts) {
|
|
103
|
+
export async function buildDocsFetchResult(opts) {
|
|
99
104
|
const { doc, content, projectRoot, attachmentBackend, linkedDecisions } = opts;
|
|
100
105
|
const cleoDir = resolveCleoDir(projectRoot);
|
|
101
106
|
const contentBytes = Buffer.from(content, 'utf-8');
|
|
@@ -103,6 +108,12 @@ export function buildDocsFetchResult(opts) {
|
|
|
103
108
|
const text = isTextMime(doc.mimeType);
|
|
104
109
|
const contentField = inline && text ? content : undefined;
|
|
105
110
|
const bytesBase64 = inline && !text ? contentBytes.toString('base64') : undefined;
|
|
111
|
+
const headConflict = await readDocHeadConflict(projectRoot, doc.slug);
|
|
112
|
+
// T13674: expose the conduit head version the fetched body was projected
|
|
113
|
+
// from, so a writer can pass it back as docs.update baseVersionUid and a
|
|
114
|
+
// stale base is merged/conflicted instead of silently overwriting a
|
|
115
|
+
// concurrent edit. Absent for docs outside the conduit family.
|
|
116
|
+
const headVersionUid = await readDocHeadVersionUid(projectRoot, doc.slug);
|
|
106
117
|
return {
|
|
107
118
|
metadata: {
|
|
108
119
|
id: doc.id,
|
|
@@ -118,6 +129,7 @@ export function buildDocsFetchResult(opts) {
|
|
|
118
129
|
...(doc.displayNumber !== null ? { displayNumber: doc.displayNumber } : {}),
|
|
119
130
|
...(doc.title ? { title: doc.title } : {}),
|
|
120
131
|
...(doc.blobName ? { blobName: doc.blobName } : {}),
|
|
132
|
+
...(headVersionUid !== undefined ? { headVersionUid } : {}),
|
|
121
133
|
},
|
|
122
134
|
path: docsStoragePath(doc, cleoDir),
|
|
123
135
|
sizeBytes: contentBytes.length,
|
|
@@ -127,7 +139,80 @@ export function buildDocsFetchResult(opts) {
|
|
|
127
139
|
...(attachmentBackend !== undefined
|
|
128
140
|
? { attachmentBackend: attachmentBackend }
|
|
129
141
|
: {}),
|
|
142
|
+
...(headConflict !== undefined ? { headConflict } : {}),
|
|
130
143
|
...(linkedDecisions !== undefined && linkedDecisions.length > 0 ? { linkedDecisions } : {}),
|
|
131
144
|
};
|
|
132
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Resolve the conduit head version uid for a slug (T13674) — the version the
|
|
148
|
+
* fetched body was projected from. Returns undefined for slug-less docs,
|
|
149
|
+
* docs outside the conduit family, and any store read failure (the base
|
|
150
|
+
* parameter stays opt-in; a degraded store must not break fetch).
|
|
151
|
+
*
|
|
152
|
+
* @param projectRoot - Project root.
|
|
153
|
+
* @param slug - The doc's slug (`ResolvedDoc.slug`), or null.
|
|
154
|
+
* @returns The head version uid, or undefined when not applicable.
|
|
155
|
+
*/
|
|
156
|
+
export async function readDocHeadVersionUid(projectRoot, slug) {
|
|
157
|
+
if (slug === null)
|
|
158
|
+
return undefined;
|
|
159
|
+
try {
|
|
160
|
+
const { dbExists } = await import('../store/sqlite.js');
|
|
161
|
+
if (!dbExists(projectRoot))
|
|
162
|
+
return undefined;
|
|
163
|
+
const { resolveConduitDocUid, getConduitDocHead } = await import('../store/conduit-doc-history.js');
|
|
164
|
+
const docUid = await resolveConduitDocUid(projectRoot, slug);
|
|
165
|
+
if (docUid === null)
|
|
166
|
+
return undefined;
|
|
167
|
+
const head = await getConduitDocHead(projectRoot, docUid);
|
|
168
|
+
return head?.headVersionUid ?? undefined;
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Surface a doc's recorded CRDT head conflicts on the fetch envelope
|
|
176
|
+
* (T13604): when the conduit's current-version projection carries recorded
|
|
177
|
+
* conflicts, the fetched content is the winning projection and the losing
|
|
178
|
+
* edits survive in the append-only version history. Absent for slug-less
|
|
179
|
+
* docs, docs outside the conduit family, and docs with a clean head — the
|
|
180
|
+
* no-conflict envelope is byte-identical to before.
|
|
181
|
+
*
|
|
182
|
+
* @param projectRoot - Project root.
|
|
183
|
+
* @param slug - The doc's slug (`ResolvedDoc.slug`), or null.
|
|
184
|
+
* @returns The head-conflict summary, or undefined when nothing to surface.
|
|
185
|
+
*/
|
|
186
|
+
async function readDocHeadConflict(projectRoot, slug) {
|
|
187
|
+
if (slug === null)
|
|
188
|
+
return undefined;
|
|
189
|
+
try {
|
|
190
|
+
const { dbExists } = await import('../store/sqlite.js');
|
|
191
|
+
if (!dbExists(projectRoot))
|
|
192
|
+
return undefined;
|
|
193
|
+
const { resolveConduitDocUid, getConduitDocHead } = await import('../store/conduit-doc-history.js');
|
|
194
|
+
const docUid = await resolveConduitDocUid(projectRoot, slug);
|
|
195
|
+
if (docUid === null)
|
|
196
|
+
return undefined;
|
|
197
|
+
const head = await getConduitDocHead(projectRoot, docUid);
|
|
198
|
+
if (!head || head.conflictCount === 0)
|
|
199
|
+
return undefined;
|
|
200
|
+
let lastConflict;
|
|
201
|
+
if (head.lastConflictJson) {
|
|
202
|
+
try {
|
|
203
|
+
lastConflict = JSON.parse(head.lastConflictJson);
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
lastConflict = undefined;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
conflictCount: head.conflictCount,
|
|
211
|
+
...(lastConflict !== undefined ? { lastConflict } : {}),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
133
218
|
//# sourceMappingURL=fetch-result.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-result.js","sourceRoot":"","sources":["../../src/docs/fetch-result.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fetch-result.js","sourceRoot":"","sources":["../../src/docs/fetch-result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAMjC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,2EAA2E;AAC3E,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAAC;AAErC;;;;GAIG;AACH,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC;IAC1D,kBAAkB;IAClB,iBAAiB;IACjB,kBAAkB;IAClB,oBAAoB;IACpB,wBAAwB;IACxB,wBAAwB;IACxB,kBAAkB;IAClB,kBAAkB;IAClB,qBAAqB;CACtB,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,IAAmB;IAC5C,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW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AAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACxD,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/docs/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export type { DocsDriftItem, DocsFindSimilarHit, DocsFindSimilarResult, DocsGrap
|
|
|
26
26
|
export { buildDocsGraph, DEFAULT_FIND_SIMILAR_LIMIT, DEFAULT_FIND_SIMILAR_THRESHOLD, findSimilarDocs, listDocVersions, listPublications, mergeDocs, publishDocs, rankDocs, recordPublication, searchAllProjectDocs, searchDocs, statusDocs, syncFromGit, } from './docs-ops.js';
|
|
27
27
|
export type { ExportDocumentOptions, ExportDocumentResult } from './export-document.js';
|
|
28
28
|
export { exportDocument } from './export-document.js';
|
|
29
|
+
export { readDocsPublicationSha256Set, readDocsPublications, upsertDocsPublication, } from './publications-store.js';
|
|
29
30
|
export type { CheckSlugSimilarityOptions, SimilarityCheckResult, SimilarityConfig, SimilarityMode, } from './similarity-check.js';
|
|
30
31
|
export { checkSlugSimilarity, DEFAULT_SIMILARITY_MODE, DEFAULT_SIMILARITY_THRESHOLD, parseSimilarityConfig, } from './similarity-check.js';
|
|
31
32
|
export type { SupersedeDocInput, SupersedeDocParams, SupersedeDocResult, } from './supersede.js';
|
package/dist/docs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,YAAY,EACV,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,0BAA0B,EAC1B,8BAA8B,EAC9B,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,YAAY,EACV,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,eAAe,EACf,eAAe,EACf,oBAAo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,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,0BAA0B,EAC1B,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/docs/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export { SET_ALIAS_INVALID_CODE, SET_ALIAS_NOT_FOUND_CODE, SET_ALIAS_TAKEN_CODE,
|
|
|
20
20
|
export { generateDocsLlmsTxt } from './docs-generator.js';
|
|
21
21
|
export { buildDocsGraph, DEFAULT_FIND_SIMILAR_LIMIT, DEFAULT_FIND_SIMILAR_THRESHOLD, findSimilarDocs, listDocVersions, listPublications, mergeDocs, publishDocs, rankDocs, recordPublication, searchAllProjectDocs, searchDocs, statusDocs, syncFromGit, } from './docs-ops.js';
|
|
22
22
|
export { exportDocument } from './export-document.js';
|
|
23
|
+
export { readDocsPublicationSha256Set, readDocsPublications, upsertDocsPublication, } from './publications-store.js';
|
|
23
24
|
export { checkSlugSimilarity, DEFAULT_SIMILARITY_MODE, DEFAULT_SIMILARITY_THRESHOLD, parseSimilarityConfig, } from './similarity-check.js';
|
|
24
25
|
export { SUPERSEDE_NOT_FOUND_CODE, SUPERSEDE_SAME_SLUG_CODE, supersedeDoc, } from './supersede.js';
|
|
25
26
|
export { validateDocBody } from './validate-body.js';
|
package/dist/docs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/docs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAS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,CAAC;AAG1C,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAU1E,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,UAAU,EACV,OAAO,EACP,eAAe,EACf,uBAAuB,EACvB,YAAY,EACZ,UAAU,EACV,0BAA0B,EAC1B,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,0BAA0B,EAC1B,cAAc,GACf,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T13360 — honest migration of legacy docs into the re-keyed store
|
|
3
|
+
* (spec `cleodocs-rearch-design` §5, D11165).
|
|
4
|
+
*
|
|
5
|
+
* Imports every legacy CleoDocs document (`docs_attachments` rows — the
|
|
6
|
+
* D11-collapse twin of the legacy `attachments` registry) into the T13354
|
|
7
|
+
* re-keyed conduit history family, inside the T13448 migration safety
|
|
8
|
+
* harness:
|
|
9
|
+
*
|
|
10
|
+
* backup → BEGIN IMMEDIATE → before-fingerprints → step → verify →
|
|
11
|
+
* COMMIT (only when every check passed) / ROLLBACK
|
|
12
|
+
*
|
|
13
|
+
* Honesty contract (the spec's words are the ACs):
|
|
14
|
+
*
|
|
15
|
+
* - **Every imported history row is labeled `origin: 'migrated'`** — no
|
|
16
|
+
* imported row poses as native (AC1).
|
|
17
|
+
* - **No fabricated authors, no invented version numbers** — authors come
|
|
18
|
+
* from the legacy docs audit log's real `actor`; when no provenance
|
|
19
|
+
* exists the row is system-attributed (`system:migration`), the AC's
|
|
20
|
+
* sanctioned "system attribution", never an invented human (AC2).
|
|
21
|
+
* Version ordinals are derived from the real audit-event order.
|
|
22
|
+
* - **Dangling-pointer docs are content-captured or marked dangling** —
|
|
23
|
+
* a doc whose recorded path is missing or ephemeral (worktree/tmp) gets
|
|
24
|
+
* its bytes recovered from the content-addressed blob store when
|
|
25
|
+
* possible (captured); otherwise it is recorded in
|
|
26
|
+
* `conduit_doc_migration_ledger` with `status: 'dangling'`, the legacy
|
|
27
|
+
* pointer and the reason — never silently imported (AC3).
|
|
28
|
+
* - **Idempotent** — every write carries a NATURAL uid (doc slug; (doc
|
|
29
|
+
* uid, content hash, event timestamp); ledger slug), so a re-run derives
|
|
30
|
+
* the same uids and `ON CONFLICT DO NOTHING` turns it into a verified
|
|
31
|
+
* no-op; docs already in the ledger are skipped. The second run's
|
|
32
|
+
* harness verification proves zero deltas and unchanged hashes (AC4).
|
|
33
|
+
*
|
|
34
|
+
* The migration is exposed as `cleo docs migrate` (dispatch op
|
|
35
|
+
* `docs.migrate`); it takes its own pre-step VACUUM INTO backup through the
|
|
36
|
+
* harness and needs no `--force` (it is additive — nothing is deleted).
|
|
37
|
+
*
|
|
38
|
+
* Cross-device identity (T13638): the audit log (`docs-audit.jsonl`) is a
|
|
39
|
+
* DEVICE-LOCAL file — it never syncs. Version identity therefore CANNOT
|
|
40
|
+
* derive from a row's position in it (`evt-<i>` was v1 and diverged across
|
|
41
|
+
* devices). Every imported version's natural uid is instead a pure function
|
|
42
|
+
* of the version's real facts — (doc uid, content hash, event timestamp) —
|
|
43
|
+
* so two devices migrating the same synced legacy doc derive IDENTICAL uids
|
|
44
|
+
* for the same content whatever their local audit logs hold, and two
|
|
45
|
+
* different contents can never collide on one uid. The doc uid, the ledger
|
|
46
|
+
* receipt, and the head projection were already device-independent.
|
|
47
|
+
*
|
|
48
|
+
* Existing installs: a store that already ran the t13360 import keeps its
|
|
49
|
+
* position-derived version uids — the ledger receipt makes the migration
|
|
50
|
+
* one-shot per doc, so the content-derived derivation applies to newly
|
|
51
|
+
* migrated rows only (accepted mixed state, per the task's (a) option; no
|
|
52
|
+
* re-key migration, since the spec does not mandate one).
|
|
53
|
+
*
|
|
54
|
+
* @module
|
|
55
|
+
* @task T13360
|
|
56
|
+
* @task T13633 — review round 2: leaf HLC constant, native-conflict count,
|
|
57
|
+
* cross-device caveat
|
|
58
|
+
* @task T13638 — version uids derived from (doc uid, content hash, event
|
|
59
|
+
* timestamp), never from the device-local audit position
|
|
60
|
+
* @epic T13340
|
|
61
|
+
* @saga T13339
|
|
62
|
+
*/
|
|
63
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
64
|
+
import { type MigrationRunReport, type MigrationStep, type MigrationStepReport } from '../store/migration-safety.js';
|
|
65
|
+
/**
|
|
66
|
+
* The honest system attribution for migrated rows with no real author
|
|
67
|
+
* provenance (spec §5 "system attribution"). Never an invented human name.
|
|
68
|
+
*/
|
|
69
|
+
export declare const MIGRATION_SYSTEM_AUTHOR = "system:migration";
|
|
70
|
+
/** One history row to import for one doc. */
|
|
71
|
+
interface PlannedVersion {
|
|
72
|
+
/** Real audit actor, or {@link MIGRATION_SYSTEM_AUTHOR}. */
|
|
73
|
+
readonly authorAgentId: string;
|
|
74
|
+
/** SHA-256 hex of this version's body. */
|
|
75
|
+
readonly contentHash: string;
|
|
76
|
+
/** Body size in bytes. */
|
|
77
|
+
readonly sizeBytes: number;
|
|
78
|
+
/** Measured token count. */
|
|
79
|
+
readonly tokens: number;
|
|
80
|
+
/** Real provenance instant (audit event ts, or the row's created_at). */
|
|
81
|
+
readonly createdAt: string;
|
|
82
|
+
/** Honest summary of what this row is. */
|
|
83
|
+
readonly changeSummary: string;
|
|
84
|
+
}
|
|
85
|
+
/** The import decision for one legacy doc. */
|
|
86
|
+
interface PlannedDoc {
|
|
87
|
+
readonly slug: string;
|
|
88
|
+
readonly status: 'captured' | 'dangling';
|
|
89
|
+
readonly reason: string;
|
|
90
|
+
readonly legacyPath: string | null;
|
|
91
|
+
readonly legacySha256: string;
|
|
92
|
+
/** Captured bytes (null when dangling). */
|
|
93
|
+
readonly content: Buffer | null;
|
|
94
|
+
readonly format: string;
|
|
95
|
+
readonly title: string | null;
|
|
96
|
+
readonly createdAt: string;
|
|
97
|
+
readonly versions: readonly PlannedVersion[];
|
|
98
|
+
/** Doc-row author (author of the last imported version). */
|
|
99
|
+
readonly fromAgentId: string;
|
|
100
|
+
}
|
|
101
|
+
/** Statically-declared per-table row deltas (fed to the harness verifier). */
|
|
102
|
+
export interface LegacyMigrationPlan {
|
|
103
|
+
/** The single harness step executing this plan. */
|
|
104
|
+
readonly step: MigrationStep;
|
|
105
|
+
/** Rows the step will add per table (all zero on a re-run). */
|
|
106
|
+
readonly expectedDelta: Readonly<Record<string, number>>;
|
|
107
|
+
/** Planned doc imports (for reporting/tests). */
|
|
108
|
+
readonly docs: readonly PlannedDoc[];
|
|
109
|
+
readonly counts: {
|
|
110
|
+
readonly toCapture: number;
|
|
111
|
+
readonly toMarkDangling: number;
|
|
112
|
+
/** Docs already receipted by an earlier run (idempotency skips). */
|
|
113
|
+
readonly toSkip: number;
|
|
114
|
+
/**
|
|
115
|
+
* Legacy slugs that already exist NATIVELY in `conduit_attachments` — the
|
|
116
|
+
* migration never clobbers a native doc, and these are counted
|
|
117
|
+
* explicitly (not silently lumped into `toSkip`) so the operator can
|
|
118
|
+
* reconcile them by hand (T13633).
|
|
119
|
+
*/
|
|
120
|
+
readonly nativeConflicts: number;
|
|
121
|
+
readonly versions: number;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Derive the import plan for every legacy doc — the SAME derivation runs in
|
|
126
|
+
* `planLegacyDocMigration` (to declare the harness's expected deltas) and
|
|
127
|
+
* inside the step (inside the transaction), so the deltas match by
|
|
128
|
+
* construction and any divergence fails verification and rolls back.
|
|
129
|
+
*
|
|
130
|
+
* Read-only: never writes; reads the store, the blob files and the audit
|
|
131
|
+
* log.
|
|
132
|
+
*
|
|
133
|
+
* @internal Exported for tests.
|
|
134
|
+
*/
|
|
135
|
+
export declare function deriveLegacyDocMigrationPlan(projectRoot: string): Promise<{
|
|
136
|
+
docs: PlannedDoc[];
|
|
137
|
+
skipped: number;
|
|
138
|
+
nativeConflicts: number;
|
|
139
|
+
expectedDelta: Record<string, number>;
|
|
140
|
+
}>;
|
|
141
|
+
/**
|
|
142
|
+
* Plan the migration: derive the work, declare the harness's expected deltas,
|
|
143
|
+
* and build the single harness step. Call immediately before
|
|
144
|
+
* {@link runLegacyDocMigration} — the plan and the step re-derive from the
|
|
145
|
+
* same state, and the harness fails verification (rolling back) if a
|
|
146
|
+
* concurrent write lands in between.
|
|
147
|
+
*
|
|
148
|
+
* @param projectRoot - Absolute path to the CLEO project root.
|
|
149
|
+
* @returns The plan (step + declared deltas + per-doc decisions).
|
|
150
|
+
* @task T13360
|
|
151
|
+
*/
|
|
152
|
+
export declare function planLegacyDocMigration(opts: {
|
|
153
|
+
projectRoot: string;
|
|
154
|
+
}): Promise<LegacyMigrationPlan>;
|
|
155
|
+
/** Result wrapper around the harness run report. */
|
|
156
|
+
export interface LegacyMigrationRunResult {
|
|
157
|
+
/** The harness report (backup receipt, per-table verification, transaction). */
|
|
158
|
+
readonly report: MigrationRunReport;
|
|
159
|
+
/** Counts from the plan that built the step. */
|
|
160
|
+
readonly counts: LegacyMigrationPlan['counts'];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Run the legacy docs migration inside the T13448 harness: pre-step VACUUM
|
|
164
|
+
* INTO backup → BEGIN IMMEDIATE → before-fingerprints → import → verify →
|
|
165
|
+
* COMMIT, or ROLLBACK on any failure (the failed step is never visible).
|
|
166
|
+
* Additive only — nothing is deleted, so no `force` is required.
|
|
167
|
+
*
|
|
168
|
+
* @param opts.projectRoot - Absolute path to the CLEO project root.
|
|
169
|
+
* @param opts.db - Live native handle on the project store (chokepoint-opened).
|
|
170
|
+
* @param opts.cwd - Invocation directory (the restore path's worktree guard).
|
|
171
|
+
* @param opts.onStepReport - Optional per-step report sink.
|
|
172
|
+
* @returns The harness report plus plan counts.
|
|
173
|
+
* @task T13360
|
|
174
|
+
*/
|
|
175
|
+
export declare function runLegacyDocMigration(opts: {
|
|
176
|
+
projectRoot: string;
|
|
177
|
+
db: DatabaseSync;
|
|
178
|
+
cwd: string;
|
|
179
|
+
onStepReport?: (report: MigrationStepReport) => void;
|
|
180
|
+
}): Promise<LegacyMigrationRunResult>;
|
|
181
|
+
export {};
|
|
182
|
+
//# sourceMappingURL=legacy-doc-migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-doc-migration.d.ts","sourceRoot":"","sources":["../../src/docs/legacy-doc-migration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYhD,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAGzB,MAAM,8BAA8B,CAAC;AAOtC;;;GAGG;AACH,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAS1D,6CAA6C;AAC7C,UAAU,cAAc;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,0BAA0B;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,4BAA4B;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,8CAA8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