@cleocode/contracts 2026.4.12 → 2026.4.13
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/package.json +1 -1
- package/src/backup-manifest.ts +189 -0
- package/src/index.ts +10 -0
package/package.json
CHANGED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BackupManifest — Contract types for the .cleobundle portable backup format.
|
|
3
|
+
*
|
|
4
|
+
* Describes the structure of manifest.json written at the root of every
|
|
5
|
+
* .cleobundle.tar.gz archive produced by `cleo backup export`. The bundled
|
|
6
|
+
* JSON Schema at `schemas/manifest-v1.json` provides runtime validation.
|
|
7
|
+
*
|
|
8
|
+
* @task T343
|
|
9
|
+
* @epic T311
|
|
10
|
+
* @why ADR-038 §3 — manifest.json format for .cleobundle tarballs.
|
|
11
|
+
* Bundled JSON Schema at schemas/manifest-v1.json inside the bundle.
|
|
12
|
+
* @what BackupManifest describes metadata, databases, json files,
|
|
13
|
+
* global files, and integrity block for a portable CLEO backup.
|
|
14
|
+
* @see .cleo/specs/T311-backup-portability-spec.md §3
|
|
15
|
+
* @see .cleo/adrs/ADR-038-backup-portability.md §3
|
|
16
|
+
* @module backup-manifest
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Scope
|
|
21
|
+
// ============================================================================
|
|
22
|
+
|
|
23
|
+
/** Export scope — determines which database tiers and file sets are included. */
|
|
24
|
+
export type BackupScope = 'project' | 'global' | 'all';
|
|
25
|
+
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Backup metadata block
|
|
28
|
+
// ============================================================================
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Top-level metadata for the backup bundle, recording provenance and
|
|
32
|
+
* portability context at export time.
|
|
33
|
+
*/
|
|
34
|
+
export interface BackupMetadata {
|
|
35
|
+
/** ISO-8601 UTC timestamp when the bundle was created. */
|
|
36
|
+
createdAt: string;
|
|
37
|
+
/** Human-readable cleo version string, e.g. "cleo v2026.4.13". */
|
|
38
|
+
createdBy: string;
|
|
39
|
+
/** Export scope. Determines target restore paths. */
|
|
40
|
+
scope: BackupScope;
|
|
41
|
+
/** Project name at export time. Advisory only. */
|
|
42
|
+
projectName?: string;
|
|
43
|
+
/**
|
|
44
|
+
* SHA-256 of project-info.json at export time, hex-encoded (64 chars).
|
|
45
|
+
* Null for global-only scope. Advisory warning if mismatch on import.
|
|
46
|
+
*/
|
|
47
|
+
projectFingerprint?: string;
|
|
48
|
+
/**
|
|
49
|
+
* SHA-256 of `$XDG_DATA_HOME/cleo/machine-key`, hex-encoded (64 chars).
|
|
50
|
+
* Privacy-safe machine identity proxy — not the key itself.
|
|
51
|
+
*/
|
|
52
|
+
machineFingerprint: string;
|
|
53
|
+
/** Machine-parseable CalVer string, e.g. "2026.4.13". */
|
|
54
|
+
cleoVersion: string;
|
|
55
|
+
/** True if this bundle was produced with --encrypt. */
|
|
56
|
+
encrypted: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// Database entry
|
|
61
|
+
// ============================================================================
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Metadata for a single SQLite database file included in the bundle.
|
|
65
|
+
* One entry per in-scope database (tasks, brain, conduit, nexus, signaldock).
|
|
66
|
+
*/
|
|
67
|
+
export interface BackupDatabaseEntry {
|
|
68
|
+
/** Logical database name. */
|
|
69
|
+
name: 'tasks' | 'brain' | 'conduit' | 'nexus' | 'signaldock';
|
|
70
|
+
/** Relative path inside the archive, e.g. "databases/tasks.db". */
|
|
71
|
+
filename: string;
|
|
72
|
+
/** Byte size of the decompressed .db file. */
|
|
73
|
+
size: number;
|
|
74
|
+
/** SHA-256 hex of the decompressed .db bytes (64 lowercase hex chars). */
|
|
75
|
+
sha256: string;
|
|
76
|
+
/**
|
|
77
|
+
* Latest applied migration identifier.
|
|
78
|
+
* For Drizzle-managed DBs: folderMillis string (e.g. "20260327000000").
|
|
79
|
+
* For signaldock.db: SIGNALDOCK_SCHEMA_VERSION constant.
|
|
80
|
+
*/
|
|
81
|
+
schemaVersion: string;
|
|
82
|
+
/**
|
|
83
|
+
* Per-table row counts captured at export time.
|
|
84
|
+
* Displayed by `cleo backup inspect`. Optional at import time.
|
|
85
|
+
*/
|
|
86
|
+
rowCounts?: Record<string, number>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ============================================================================
|
|
90
|
+
// JSON file entry
|
|
91
|
+
// ============================================================================
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Metadata for a managed JSON configuration file included in the bundle.
|
|
95
|
+
* Filename is the path relative to the archive root (includes the `json/` prefix).
|
|
96
|
+
*/
|
|
97
|
+
export interface BackupJsonEntry {
|
|
98
|
+
/** Relative path inside the archive. */
|
|
99
|
+
filename: 'json/config.json' | 'json/project-info.json' | 'json/project-context.json';
|
|
100
|
+
/** Byte size of the file. */
|
|
101
|
+
size: number;
|
|
102
|
+
/** SHA-256 hex of the file bytes (64 lowercase hex chars). */
|
|
103
|
+
sha256: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ============================================================================
|
|
107
|
+
// Global file entry
|
|
108
|
+
// ============================================================================
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Metadata for a global-tier file included in the bundle.
|
|
112
|
+
* Currently only `global-salt` is a managed global file.
|
|
113
|
+
*
|
|
114
|
+
* WARNING: Including global-salt invalidates all agent API keys on the
|
|
115
|
+
* target machine. Agents require re-authentication after import.
|
|
116
|
+
*/
|
|
117
|
+
export interface BackupGlobalFileEntry {
|
|
118
|
+
/** Relative path inside the archive. */
|
|
119
|
+
filename: 'global/global-salt';
|
|
120
|
+
/** Byte size of the file. */
|
|
121
|
+
size: number;
|
|
122
|
+
/** SHA-256 hex of the file bytes (64 lowercase hex chars). */
|
|
123
|
+
sha256: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// Integrity block
|
|
128
|
+
// ============================================================================
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Integrity metadata for the bundle.
|
|
132
|
+
* Covers both the checksums file (per-file) and the manifest self-hash.
|
|
133
|
+
*/
|
|
134
|
+
export interface BackupIntegrity {
|
|
135
|
+
/** Hash algorithm used. Always "sha256" for v1 bundles. */
|
|
136
|
+
algorithm: 'sha256';
|
|
137
|
+
/**
|
|
138
|
+
* Name of the GNU-format checksums file in the archive.
|
|
139
|
+
* Always "checksums.sha256" for v1 bundles.
|
|
140
|
+
*/
|
|
141
|
+
checksumsFile: 'checksums.sha256';
|
|
142
|
+
/**
|
|
143
|
+
* SHA-256 of this manifest JSON with the `manifestHash` field set to an
|
|
144
|
+
* empty string (`""`), then hex-encoded (64 lowercase hex chars).
|
|
145
|
+
* Used by Layer 2 integrity verification (ADR-038 §4.2).
|
|
146
|
+
*/
|
|
147
|
+
manifestHash?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ============================================================================
|
|
151
|
+
// Top-level manifest
|
|
152
|
+
// ============================================================================
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Root structure of `manifest.json` at the root of every .cleobundle archive.
|
|
156
|
+
*
|
|
157
|
+
* The manifest MUST be the first entry in the tar archive to enable efficient
|
|
158
|
+
* streaming inspection without reading the full bundle (ADR-038 §1).
|
|
159
|
+
*
|
|
160
|
+
* The `$schema` field references the bundled JSON Schema at
|
|
161
|
+
* `./schemas/manifest-v1.json` — a relative bundle-root path, ensuring
|
|
162
|
+
* offline validation without network access (T311 spec §3.1, Q6=C).
|
|
163
|
+
*/
|
|
164
|
+
export interface BackupManifest {
|
|
165
|
+
/** Relative path to the bundled JSON Schema for IDE and runtime validation. */
|
|
166
|
+
$schema: './schemas/manifest-v1.json';
|
|
167
|
+
/** Manifest format version. Follows semver; major increments on breaking change. */
|
|
168
|
+
manifestVersion: '1.0.0';
|
|
169
|
+
/** Provenance and portability metadata captured at export time. */
|
|
170
|
+
backup: BackupMetadata;
|
|
171
|
+
/**
|
|
172
|
+
* SQLite database files included in this bundle.
|
|
173
|
+
* Exactly reflects what was exported for the given scope.
|
|
174
|
+
*/
|
|
175
|
+
databases: BackupDatabaseEntry[];
|
|
176
|
+
/**
|
|
177
|
+
* Managed JSON configuration files included in this bundle.
|
|
178
|
+
* Exactly reflects what was exported for the given scope.
|
|
179
|
+
*/
|
|
180
|
+
json: BackupJsonEntry[];
|
|
181
|
+
/**
|
|
182
|
+
* Global-tier files included in this bundle.
|
|
183
|
+
* Present only when --scope global or --scope all was used.
|
|
184
|
+
* Inclusion of global-salt triggers warnings at export and import time.
|
|
185
|
+
*/
|
|
186
|
+
globalFiles?: BackupGlobalFileEntry[];
|
|
187
|
+
/** Bundle integrity metadata (algorithm, checksums file, manifest self-hash). */
|
|
188
|
+
integrity: BackupIntegrity;
|
|
189
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -34,6 +34,16 @@ export type {
|
|
|
34
34
|
CycleTimeDistribution,
|
|
35
35
|
CycleTimePercentiles,
|
|
36
36
|
} from './archive.js';
|
|
37
|
+
// === Backup Manifest Types ===
|
|
38
|
+
export type {
|
|
39
|
+
BackupDatabaseEntry,
|
|
40
|
+
BackupGlobalFileEntry,
|
|
41
|
+
BackupIntegrity,
|
|
42
|
+
BackupJsonEntry,
|
|
43
|
+
BackupManifest,
|
|
44
|
+
BackupMetadata,
|
|
45
|
+
BackupScope,
|
|
46
|
+
} from './backup-manifest.js';
|
|
37
47
|
// === Brain/Memory Types ===
|
|
38
48
|
export type {
|
|
39
49
|
BrainEntryRef,
|