@cleocode/contracts 2026.10.13 → 2026.10.14
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/__tests__/memory-wire-shapes.test.js.map +1 -1
- package/dist/acceptance-gate.d.ts +13 -0
- package/dist/acceptance-gate.d.ts.map +1 -1
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/dispatch/operations-registry.d.ts.map +1 -1
- package/dist/dispatch/operations-registry.js +12 -0
- package/dist/dispatch/operations-registry.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/invariants/sync-write-invariants.js +1 -1
- package/dist/invariants/sync-write-invariants.js.map +1 -1
- package/dist/lean.d.ts +36 -0
- package/dist/lean.d.ts.map +1 -1
- package/dist/memory/fetch.d.ts +3 -0
- package/dist/memory/fetch.d.ts.map +1 -1
- package/dist/memory/search.d.ts +9 -0
- package/dist/memory/search.d.ts.map +1 -1
- package/dist/operations/memory.d.ts +5 -0
- package/dist/operations/memory.d.ts.map +1 -1
- package/dist/store-restore.d.ts +27 -0
- package/dist/store-restore.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
- package/src/__tests__/memory-wire-shapes.test.ts +2 -0
- package/src/acceptance-gate.ts +14 -0
- package/src/config.ts +8 -0
- package/src/dispatch/operations-registry.ts +12 -0
- package/src/index.ts +9 -1
- package/src/invariants/sync-write-invariants.ts +1 -1
- package/src/lean.ts +35 -0
- package/src/memory/fetch.ts +4 -0
- package/src/memory/search.ts +12 -0
- package/src/operations/memory.ts +5 -0
- package/src/store-restore.ts +28 -0
|
@@ -67,6 +67,7 @@ type _BrainCompactHitShape = {
|
|
|
67
67
|
rrfScore?: number;
|
|
68
68
|
bm25Score?: number;
|
|
69
69
|
_next?: Record<string, string>;
|
|
70
|
+
scope?: 'project' | 'global';
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
type _AssertBrainCompactHitPinned = AssertEquals1<Equals<BrainCompactHit, _BrainCompactHitShape>>;
|
|
@@ -166,6 +167,7 @@ type _FetchedBrainEntryShape = {
|
|
|
166
167
|
id: string;
|
|
167
168
|
type: string;
|
|
168
169
|
data: unknown;
|
|
170
|
+
scope?: 'project' | 'global';
|
|
169
171
|
};
|
|
170
172
|
|
|
171
173
|
type _AssertFetchedEntryPinned = AssertEquals1<Equals<FetchedBrainEntry, _FetchedBrainEntryShape>>;
|
package/src/acceptance-gate.ts
CHANGED
|
@@ -66,6 +66,12 @@ export interface AcceptanceGateRunOptions
|
|
|
66
66
|
* its cache key. Required, with a one-gate batch, whenever `cache` is not `off`.
|
|
67
67
|
*/
|
|
68
68
|
cacheInputsHash?: string;
|
|
69
|
+
/**
|
|
70
|
+
* The parts behind {@link AcceptanceGateRunOptions.cacheInputsHash}, kept
|
|
71
|
+
* beside a stored pass (outside its MAC) so a later miss can say whether the
|
|
72
|
+
* environment or a task file moved (T13693). Diagnostic only, never trusted.
|
|
73
|
+
*/
|
|
74
|
+
cacheInputs?: AcceptanceGateCacheInputs;
|
|
69
75
|
/**
|
|
70
76
|
* The task's stored typed results before this run (T13525). With
|
|
71
77
|
* `cache: 'only'`, a gate with no cache entry reuses its stored pass when
|
|
@@ -391,6 +397,14 @@ export type GateResultDetails =
|
|
|
391
397
|
|
|
392
398
|
// ─── Result ──────────────────────────────────────────────────────────────────
|
|
393
399
|
|
|
400
|
+
/** The parts of a typed gate's inputs digest a cache-miss diagnostic compares (T13693). */
|
|
401
|
+
export interface AcceptanceGateCacheInputs {
|
|
402
|
+
/** Hash of the gate's effective environment, or null when it has no invocation. */
|
|
403
|
+
environmentHash: string | null;
|
|
404
|
+
/** The captured input files. */
|
|
405
|
+
artifacts: readonly AcceptanceGateArtifact[];
|
|
406
|
+
}
|
|
407
|
+
|
|
394
408
|
/**
|
|
395
409
|
* Exact bytes observed for one declared task input or resolved verification harness.
|
|
396
410
|
* @remarks A missing input is explicit, with both digest and size null. This inventory
|
package/src/config.ts
CHANGED
|
@@ -228,6 +228,14 @@ export interface BrainEmbeddingConfig {
|
|
|
228
228
|
enabled: boolean;
|
|
229
229
|
/** Embedding provider to use (default: 'local'). */
|
|
230
230
|
provider: 'local' | 'openai';
|
|
231
|
+
/**
|
|
232
|
+
* Whether the local provider may download its model from the Hugging Face
|
|
233
|
+
* hub when it is not cached (default: false). Off, CLEO makes no connection
|
|
234
|
+
* for embeddings: a cached model still loads, an absent one is skipped.
|
|
235
|
+
*
|
|
236
|
+
* @task T13716
|
|
237
|
+
*/
|
|
238
|
+
allowModelDownload?: boolean;
|
|
231
239
|
}
|
|
232
240
|
|
|
233
241
|
/**
|
|
@@ -4331,6 +4331,12 @@ export const OPERATIONS: OperationDef[] = [
|
|
|
4331
4331
|
description: 'text parameter',
|
|
4332
4332
|
cli: { positional: true },
|
|
4333
4333
|
},
|
|
4334
|
+
{
|
|
4335
|
+
name: 'scope',
|
|
4336
|
+
type: 'string',
|
|
4337
|
+
required: false,
|
|
4338
|
+
description: 'Store to write: project (default) or global, the synced main brain (T13720)',
|
|
4339
|
+
},
|
|
4334
4340
|
] satisfies ParamDef[],
|
|
4335
4341
|
},
|
|
4336
4342
|
{
|
|
@@ -4356,6 +4362,12 @@ export const OPERATIONS: OperationDef[] = [
|
|
|
4356
4362
|
required: true,
|
|
4357
4363
|
description: 'rationale parameter',
|
|
4358
4364
|
},
|
|
4365
|
+
{
|
|
4366
|
+
name: 'scope',
|
|
4367
|
+
type: 'string',
|
|
4368
|
+
required: false,
|
|
4369
|
+
description: 'Store to write: project (default) or global, the synced main brain (T13720)',
|
|
4370
|
+
},
|
|
4359
4371
|
] satisfies ParamDef[],
|
|
4360
4372
|
},
|
|
4361
4373
|
{
|
package/src/index.ts
CHANGED
|
@@ -898,7 +898,13 @@ export {
|
|
|
898
898
|
isLafsSuccess,
|
|
899
899
|
} from './lafs.js';
|
|
900
900
|
// === ct-lean levels (T13663 / Epic T13418) ===
|
|
901
|
-
export type {
|
|
901
|
+
export type {
|
|
902
|
+
LeanConfig,
|
|
903
|
+
LeanDebtItem,
|
|
904
|
+
LeanDebtReport,
|
|
905
|
+
LeanLevel,
|
|
906
|
+
LeanLevelSource,
|
|
907
|
+
} from './lean.js';
|
|
902
908
|
// === Lease-IPC v1.1 (PARALLEL DbWriterLease contract — T11627 · SG-RUNTIME-UNIFICATION) ===
|
|
903
909
|
export type {
|
|
904
910
|
ChildKilledUnresponsiveResponse,
|
|
@@ -1132,6 +1138,7 @@ export type {
|
|
|
1132
1138
|
export { BRAIN_OBSERVATION_SOURCE_TYPES } from './memory/observe.js';
|
|
1133
1139
|
export type {
|
|
1134
1140
|
BrainCompactHit,
|
|
1141
|
+
MemoryScope,
|
|
1135
1142
|
SearchBrainCompactParams,
|
|
1136
1143
|
SearchBrainCompactResult,
|
|
1137
1144
|
} from './memory/search.js';
|
|
@@ -2494,6 +2501,7 @@ export {
|
|
|
2494
2501
|
// === Store restore (T13240 — restore cleo.db from a named snapshot or backup id) ===
|
|
2495
2502
|
export type {
|
|
2496
2503
|
StoreRecoverResult,
|
|
2504
|
+
StoreRestoreDocsBytes,
|
|
2497
2505
|
StoreRestoreKept,
|
|
2498
2506
|
StoreRestoreResult,
|
|
2499
2507
|
StoreRestoreSource,
|
|
@@ -338,7 +338,7 @@ export const SYNC_WRITE_INVARIANTS: readonly SyncWriteInvariant[] = Object.freez
|
|
|
338
338
|
'derived.mirrors',
|
|
339
339
|
'PAC-07',
|
|
340
340
|
'T12928',
|
|
341
|
-
['tasks_task_labels', 'brain_sticky_tags', '
|
|
341
|
+
['tasks_task_labels', 'brain_sticky_tags', 'tasks_tasks'],
|
|
342
342
|
['owning rows whose JSON or junction changed'],
|
|
343
343
|
'junction tables equal their JSON source',
|
|
344
344
|
),
|
package/src/lean.ts
CHANGED
|
@@ -34,3 +34,38 @@ export interface LeanConfig {
|
|
|
34
34
|
*/
|
|
35
35
|
level?: LeanLevel;
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* One deliberate shortcut, read from a `shortcut: <ceiling>, <upgrade trigger>`
|
|
40
|
+
* comment (or the older `ponytail:` marker) in a git-tracked file (T13664).
|
|
41
|
+
*/
|
|
42
|
+
export interface LeanDebtItem {
|
|
43
|
+
/** Repo-relative path. */
|
|
44
|
+
readonly file: string;
|
|
45
|
+
/** 1-based line number. */
|
|
46
|
+
readonly line: number;
|
|
47
|
+
/** The marker word that matched (`shortcut`, `ponytail`, or a custom marker). */
|
|
48
|
+
readonly marker: string;
|
|
49
|
+
/** The comment text after the marker. */
|
|
50
|
+
readonly text: string;
|
|
51
|
+
/** The limit the shortcut names (text before the first comma). */
|
|
52
|
+
readonly ceiling: string;
|
|
53
|
+
/** When to revisit it (text after the first comma), or `null` when none is named. */
|
|
54
|
+
readonly upgrade: string | null;
|
|
55
|
+
/** `true` when no upgrade trigger is named: the rows that silently rot. */
|
|
56
|
+
readonly noTrigger: boolean;
|
|
57
|
+
/** Stable id from file + marker text, independent of the line number. */
|
|
58
|
+
readonly key: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The ledger `cleo lean debt` prints. */
|
|
62
|
+
export interface LeanDebtReport {
|
|
63
|
+
/** Every marker found, grouped by file in path order. */
|
|
64
|
+
readonly items: readonly LeanDebtItem[];
|
|
65
|
+
/** How many markers name no upgrade trigger. */
|
|
66
|
+
readonly noTriggerCount: number;
|
|
67
|
+
/** Tasks filed by `--file-tasks` (empty otherwise). */
|
|
68
|
+
readonly filed: readonly { readonly key: string; readonly taskId: string }[];
|
|
69
|
+
/** Keys that already had a `lean-debt` task, so none was filed. */
|
|
70
|
+
readonly alreadyFiled: readonly string[];
|
|
71
|
+
}
|
package/src/memory/fetch.ts
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* @see Layer 2: {@link ./timeline.ts}
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import type { MemoryScope } from './search.js';
|
|
20
|
+
|
|
19
21
|
// ── FetchBrainEntriesParams ─────────────────────────────────────────
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -47,6 +49,8 @@ export interface FetchedBrainEntry {
|
|
|
47
49
|
* via a discriminated read or pass the value through to a renderer.
|
|
48
50
|
*/
|
|
49
51
|
data: unknown;
|
|
52
|
+
/** Store the entry came from; absent means the project store (T13720). */
|
|
53
|
+
scope?: MemoryScope;
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
// ── FetchBrainEntriesResult ─────────────────────────────────────────
|
package/src/memory/search.ts
CHANGED
|
@@ -19,6 +19,16 @@
|
|
|
19
19
|
* @see Layer 3: {@link ./fetch.ts}
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
// ── MemoryScope ─────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Which store a BRAIN entry lives in: the project `cleo.db`, or the global
|
|
26
|
+
* `cleo.db` (the main brain, synced on the account's `home:<user>` stream).
|
|
27
|
+
*
|
|
28
|
+
* @task T13720
|
|
29
|
+
*/
|
|
30
|
+
export type MemoryScope = 'project' | 'global';
|
|
31
|
+
|
|
22
32
|
// ── BrainCompactHit ─────────────────────────────────────────────────
|
|
23
33
|
|
|
24
34
|
/**
|
|
@@ -62,6 +72,8 @@ export interface BrainCompactHit {
|
|
|
62
72
|
* by `@cleocode/core`'s `mvi-helpers`.
|
|
63
73
|
*/
|
|
64
74
|
_next?: Record<string, string>;
|
|
75
|
+
/** Store the hit came from; absent means the project store (T13720). */
|
|
76
|
+
scope?: MemoryScope;
|
|
65
77
|
}
|
|
66
78
|
|
|
67
79
|
// ── SearchBrainCompactParams ────────────────────────────────────────
|
package/src/operations/memory.ts
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
import type { BrainCognitiveType, BrainMemoryTier, BrainSourceConfidence } from '../brain.js';
|
|
27
27
|
import type { LAFSPage } from '../lafs.js';
|
|
28
|
+
import type { MemoryScope } from '../memory/search.js';
|
|
28
29
|
|
|
29
30
|
// ============================================================================
|
|
30
31
|
// Shared Memory types (API wire format)
|
|
@@ -777,6 +778,8 @@ export interface MemoryObserveParams {
|
|
|
777
778
|
attachmentRefs?: string[];
|
|
778
779
|
/** Cross-reference to other memory or external IDs (T794). */
|
|
779
780
|
crossRef?: string[];
|
|
781
|
+
/** Store to write: `project` (default) or `global`, the synced main brain (T13720). */
|
|
782
|
+
scope?: MemoryScope;
|
|
780
783
|
}
|
|
781
784
|
/** Result of `memory.observe`. */
|
|
782
785
|
export interface MemoryObserveResult {
|
|
@@ -841,6 +844,8 @@ export interface MemoryDecisionStoreParams {
|
|
|
841
844
|
* Defaults to `'agent'` when not specified.
|
|
842
845
|
*/
|
|
843
846
|
decidedBy?: 'owner' | 'council' | 'agent';
|
|
847
|
+
/** Store to write: `project` (default) or `global`, the synced main brain (T13720). */
|
|
848
|
+
scope?: MemoryScope;
|
|
844
849
|
}
|
|
845
850
|
/** Result of `memory.decision.store`. */
|
|
846
851
|
export interface MemoryDecisionStoreResult {
|
package/src/store-restore.ts
CHANGED
|
@@ -37,6 +37,21 @@ export interface StoreRestoreKept {
|
|
|
37
37
|
readonly sidecars: readonly string[];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The docs byte surfaces restored from a backup id (T13704, T13708): the
|
|
42
|
+
* blob-store and attachment databases and the byte files `docs fetch` reads.
|
|
43
|
+
*/
|
|
44
|
+
export interface StoreRestoreDocsBytes {
|
|
45
|
+
/** `true` only when every recorded database and byte file was verified and placed. */
|
|
46
|
+
readonly complete: boolean;
|
|
47
|
+
/** Databases placed, relative to `.cleo/` (`blobs/manifest.db`, `attachments/index.db`). */
|
|
48
|
+
readonly dbsRestored: readonly string[];
|
|
49
|
+
/** Byte files verified (sha256) and placed. */
|
|
50
|
+
readonly filesRestored: number;
|
|
51
|
+
/** What was not placed, each `<path>: <why>` (missing, sha256 mismatch, integrity_check, busy). */
|
|
52
|
+
readonly failed: readonly string[];
|
|
53
|
+
}
|
|
54
|
+
|
|
40
55
|
/** Result of a store restore (or its dry run). */
|
|
41
56
|
export interface StoreRestoreResult {
|
|
42
57
|
readonly dryRun: boolean;
|
|
@@ -53,6 +68,19 @@ export interface StoreRestoreResult {
|
|
|
53
68
|
readonly removedSidecars: readonly string[];
|
|
54
69
|
/** How to undo the restore (`null` on a dry run, or when nothing was replaced). */
|
|
55
70
|
readonly undo: string | null;
|
|
71
|
+
/**
|
|
72
|
+
* The docs byte surfaces restored with the store (`--id` of a backup that
|
|
73
|
+
* captured them, T13708). Absent otherwise.
|
|
74
|
+
*/
|
|
75
|
+
readonly docsBytes?: StoreRestoreDocsBytes;
|
|
76
|
+
/**
|
|
77
|
+
* `true` when the store was placed but part of the backup was not (a docs
|
|
78
|
+
* byte that was missing or failed verification): the restore is not a
|
|
79
|
+
* clean success and the CLI exits non-zero (T13709).
|
|
80
|
+
*/
|
|
81
|
+
readonly partial?: boolean;
|
|
82
|
+
/** What the partial restore left out, one line each. */
|
|
83
|
+
readonly warnings?: readonly string[];
|
|
56
84
|
}
|
|
57
85
|
|
|
58
86
|
/**
|