@cleocode/contracts 2026.5.96 → 2026.5.98
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__/enums.test.d.ts +14 -0
- package/dist/__tests__/enums.test.d.ts.map +1 -0
- package/dist/__tests__/enums.test.js +75 -0
- package/dist/__tests__/enums.test.js.map +1 -0
- package/dist/__tests__/jobs.test.d.ts +11 -0
- package/dist/__tests__/jobs.test.d.ts.map +1 -0
- package/dist/__tests__/jobs.test.js +48 -0
- package/dist/__tests__/jobs.test.js.map +1 -0
- package/dist/__tests__/memory-wire-shapes.test.d.ts +19 -0
- package/dist/__tests__/memory-wire-shapes.test.d.ts.map +1 -0
- package/dist/__tests__/memory-wire-shapes.test.js +119 -0
- package/dist/__tests__/memory-wire-shapes.test.js.map +1 -0
- package/dist/__tests__/operation-def.test.d.ts +20 -0
- package/dist/__tests__/operation-def.test.d.ts.map +1 -0
- package/dist/__tests__/operation-def.test.js +111 -0
- package/dist/__tests__/operation-def.test.js.map +1 -0
- package/dist/__tests__/provenance.test.d.ts +18 -0
- package/dist/__tests__/provenance.test.d.ts.map +1 -0
- package/dist/__tests__/provenance.test.js +142 -0
- package/dist/__tests__/provenance.test.js.map +1 -0
- package/dist/__tests__/scaffold-diagnostics.test.d.ts +19 -0
- package/dist/__tests__/scaffold-diagnostics.test.d.ts.map +1 -0
- package/dist/__tests__/scaffold-diagnostics.test.js +70 -0
- package/dist/__tests__/scaffold-diagnostics.test.js.map +1 -0
- package/dist/dispatch/identity.d.ts +72 -0
- package/dist/dispatch/identity.d.ts.map +1 -0
- package/dist/dispatch/identity.js +72 -0
- package/dist/dispatch/identity.js.map +1 -0
- package/dist/dispatch/operation-def.d.ts +92 -0
- package/dist/dispatch/operation-def.d.ts.map +1 -0
- package/dist/dispatch/operation-def.js +31 -0
- package/dist/dispatch/operation-def.js.map +1 -0
- package/dist/doctor.d.ts +43 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/enums.d.ts +123 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/enums.js +139 -0
- package/dist/enums.js.map +1 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +39 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +19 -0
- package/dist/jobs.js.map +1 -0
- package/dist/memory/budgeted.d.ts +67 -0
- package/dist/memory/budgeted.d.ts.map +1 -0
- package/dist/memory/budgeted.js +17 -0
- package/dist/memory/budgeted.js.map +1 -0
- package/dist/memory/fetch.d.ts +58 -0
- package/dist/memory/fetch.d.ts.map +1 -0
- package/dist/memory/fetch.js +19 -0
- package/dist/memory/fetch.js.map +1 -0
- package/dist/memory/observe.d.ts +158 -0
- package/dist/memory/observe.d.ts.map +1 -0
- package/dist/memory/observe.js +46 -0
- package/dist/memory/observe.js.map +1 -0
- package/dist/memory/search.d.ts +137 -0
- package/dist/memory/search.d.ts.map +1 -0
- package/dist/memory/search.js +22 -0
- package/dist/memory/search.js.map +1 -0
- package/dist/memory/timeline.d.ts +89 -0
- package/dist/memory/timeline.d.ts.map +1 -0
- package/dist/memory/timeline.js +22 -0
- package/dist/memory/timeline.js.map +1 -0
- package/dist/operations/focus.d.ts +199 -0
- package/dist/operations/focus.d.ts.map +1 -0
- package/dist/operations/focus.js +15 -0
- package/dist/operations/focus.js.map +1 -0
- package/dist/operations/index.d.ts +1 -0
- package/dist/operations/index.d.ts.map +1 -1
- package/dist/operations/index.js +1 -0
- package/dist/operations/index.js.map +1 -1
- package/dist/operations/session.d.ts +65 -0
- package/dist/operations/session.d.ts.map +1 -1
- package/dist/operations/tasks.d.ts +38 -0
- package/dist/operations/tasks.d.ts.map +1 -1
- package/dist/provenance.d.ts +257 -0
- package/dist/provenance.d.ts.map +1 -0
- package/dist/provenance.js +42 -0
- package/dist/provenance.js.map +1 -0
- package/dist/release/plan.d.ts +7 -7
- package/dist/scaffold-diagnostics.d.ts +110 -0
- package/dist/scaffold-diagnostics.d.ts.map +1 -0
- package/dist/scaffold-diagnostics.js +28 -0
- package/dist/scaffold-diagnostics.js.map +1 -0
- package/dist/session.d.ts +37 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js.map +1 -1
- package/dist/tasks/archive.d.ts +3 -3
- package/package.json +42 -2
- package/src/__tests__/enums.test.ts +114 -0
- package/src/__tests__/jobs.test.ts +76 -0
- package/src/__tests__/memory-wire-shapes.test.ts +371 -0
- package/src/__tests__/operation-def.test.ts +185 -0
- package/src/__tests__/provenance.test.ts +259 -0
- package/src/__tests__/scaffold-diagnostics.test.ts +137 -0
- package/src/dispatch/identity.ts +109 -0
- package/src/dispatch/operation-def.ts +102 -0
- package/src/doctor.ts +44 -0
- package/src/enums.ts +144 -0
- package/src/index.ts +79 -1
- package/src/jobs.ts +45 -0
- package/src/memory/budgeted.ts +75 -0
- package/src/memory/fetch.ts +66 -0
- package/src/memory/observe.ts +176 -0
- package/src/memory/search.ts +145 -0
- package/src/memory/timeline.ts +100 -0
- package/src/operations/focus.ts +226 -0
- package/src/operations/index.ts +1 -0
- package/src/operations/session.ts +67 -0
- package/src/operations/tasks.ts +40 -0
- package/src/provenance.ts +335 -0
- package/src/scaffold-diagnostics.ts +119 -0
- package/src/session.ts +37 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatch operation-def contracts.
|
|
3
|
+
*
|
|
4
|
+
* Canonical home for the {@link OperationDef} and {@link Resolution}
|
|
5
|
+
* interfaces that describe a single dispatchable CQRS operation and the
|
|
6
|
+
* result of resolving one from the operation registry.
|
|
7
|
+
*
|
|
8
|
+
* Promoted to `@cleocode/contracts` in Phase 0b of the SG-ARCH-SOLID Saga
|
|
9
|
+
* (T9831 · E-CONTRACTS-FOUNDATION T9832 · T9954). Originally defined in
|
|
10
|
+
* `packages/cleo/src/dispatch/registry.ts` (lines 14-41 / 43-53). The
|
|
11
|
+
* `packages/cleo` definition is now a re-export shim — every consumer of
|
|
12
|
+
* `OperationDef` / `Resolution` continues to compile unchanged.
|
|
13
|
+
*
|
|
14
|
+
* This promotion unblocks E-CLI-BOUNDARY (T9833) — the registry data
|
|
15
|
+
* relocation can now move {@link OPERATIONS} into `@cleocode/contracts`
|
|
16
|
+
* (or split it without changing the type's canonical home) without
|
|
17
|
+
* crossing a circular dependency.
|
|
18
|
+
*
|
|
19
|
+
* NOT promoted (intentional — different concern):
|
|
20
|
+
* - `OPERATIONS: OperationDef[]` — the registry data itself remains in
|
|
21
|
+
* `packages/cleo/src/dispatch/registry.ts` and is the subject of the
|
|
22
|
+
* follow-up E-CLI-BOUNDARY epic.
|
|
23
|
+
* - The helper functions (`resolve`, `validateRequiredParams`,
|
|
24
|
+
* `getByDomain`, `getByGateway`, `getByTier`, `getActiveDomains`,
|
|
25
|
+
* `getCounts`, `deriveGatewayMatrix`, `getGatewayDomains`) — they
|
|
26
|
+
* operate on the data and remain colocated with it.
|
|
27
|
+
*
|
|
28
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9954 (Phase 0b)
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import type { ParamDef } from '../operations/params.js';
|
|
32
|
+
import type { CanonicalDomain, Gateway, Tier } from './identity.js';
|
|
33
|
+
|
|
34
|
+
// Re-export the upstream identity types so consumers can pull every
|
|
35
|
+
// dispatch-related shape from a single subpath without having to know
|
|
36
|
+
// which leaf file each type lives in.
|
|
37
|
+
export type { CanonicalDomain, Gateway, ParamDef, Tier };
|
|
38
|
+
|
|
39
|
+
// ── OperationDef ─────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Definition of a single dispatchable operation.
|
|
43
|
+
*
|
|
44
|
+
* Each entry in the operation registry (currently in
|
|
45
|
+
* `packages/cleo/src/dispatch/registry.ts`'s `OPERATIONS` array)
|
|
46
|
+
* conforms to this interface. The dispatcher uses these definitions to
|
|
47
|
+
* (1) route a {@link CanonicalDomain} + operation-name + {@link Gateway}
|
|
48
|
+
* triple to its handler, (2) validate that all required parameters are
|
|
49
|
+
* present, and (3) emit dispatch-validation telemetry.
|
|
50
|
+
*
|
|
51
|
+
* Originally defined in `packages/cleo/src/dispatch/registry.ts:14-41`.
|
|
52
|
+
*
|
|
53
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9954 (Phase 0b)
|
|
54
|
+
*/
|
|
55
|
+
export interface OperationDef {
|
|
56
|
+
/** The CQRS gateway ('query' or 'mutate'). */
|
|
57
|
+
gateway: Gateway;
|
|
58
|
+
/** The canonical domain this operation belongs to. */
|
|
59
|
+
domain: CanonicalDomain;
|
|
60
|
+
/** The specific operation name (e.g. 'show', 'skill.list'). */
|
|
61
|
+
operation: string;
|
|
62
|
+
/** Brief description of what the operation does. */
|
|
63
|
+
description: string;
|
|
64
|
+
/** Agent progressive-disclosure tier (0=basic, 1=memory/check, 2=full). */
|
|
65
|
+
tier: Tier;
|
|
66
|
+
/** Whether the operation is safe to retry. */
|
|
67
|
+
idempotent: boolean;
|
|
68
|
+
/** Whether this operation requires an active session. */
|
|
69
|
+
sessionRequired: boolean;
|
|
70
|
+
/** List of parameter keys that MUST be present in the request. */
|
|
71
|
+
requiredParams: string[];
|
|
72
|
+
/**
|
|
73
|
+
* Fully-described parameter list. Replaces `requiredParams` when populated.
|
|
74
|
+
* Empty array = "no declared params" (not "no params accepted").
|
|
75
|
+
* Optional during T4897 migration — defaults to [] when absent.
|
|
76
|
+
* @see T4897 for progressive migration
|
|
77
|
+
*/
|
|
78
|
+
params?: ParamDef[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ── Resolution ───────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Resolution output for a dispatch request.
|
|
85
|
+
*
|
|
86
|
+
* Returned by the `resolve(gateway, domain, operation)` helper in the
|
|
87
|
+
* operation registry. Bundles the resolved {@link OperationDef} with the
|
|
88
|
+
* already-typed `domain` + `operation` strings so downstream consumers
|
|
89
|
+
* don't have to re-narrow them.
|
|
90
|
+
*
|
|
91
|
+
* Originally defined in `packages/cleo/src/dispatch/registry.ts:43-53`.
|
|
92
|
+
*
|
|
93
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9954 (Phase 0b)
|
|
94
|
+
*/
|
|
95
|
+
export interface Resolution {
|
|
96
|
+
/** The canonical domain. */
|
|
97
|
+
domain: CanonicalDomain;
|
|
98
|
+
/** The operation name. */
|
|
99
|
+
operation: string;
|
|
100
|
+
/** The definition of the matched operation. */
|
|
101
|
+
def: OperationDef;
|
|
102
|
+
}
|
package/src/doctor.ts
CHANGED
|
@@ -156,6 +156,50 @@ export interface ComprehensiveAuditResult {
|
|
|
156
156
|
anomalies: WorktreeAnomaly[];
|
|
157
157
|
/** Total anomaly count. Non-zero triggers exit code 2. */
|
|
158
158
|
count: number;
|
|
159
|
+
/**
|
|
160
|
+
* `true` when the audit was aborted early due to a width budget overflow
|
|
161
|
+
* or a timeout. The `anomalies` list reflects only the entries scanned
|
|
162
|
+
* before the abort — results may be incomplete.
|
|
163
|
+
*/
|
|
164
|
+
isPartial?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Machine-readable reason the scan was cut short.
|
|
167
|
+
* - `'timeout'`: the configured `timeoutMs` was exceeded.
|
|
168
|
+
* - `'overflow'`: a per-level entry count exceeded `maxEntriesPerLevel`.
|
|
169
|
+
*/
|
|
170
|
+
partialReason?: 'timeout' | 'overflow';
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Result shape returned by the budgeted orphan scanner
|
|
175
|
+
* ({@link scanWorktreeOrphansBudgeted}).
|
|
176
|
+
*
|
|
177
|
+
* Wraps the bare `OrphanEntry[]` from `scanWorktreeOrphans` with optional
|
|
178
|
+
* partial-result metadata so callers can surface incomplete scans to the
|
|
179
|
+
* operator without changing the existing `OrphanEntry[]` return type.
|
|
180
|
+
*/
|
|
181
|
+
export interface OrphanScanResult {
|
|
182
|
+
/** Discovered orphan entries (may be incomplete when `isPartial` is `true`). */
|
|
183
|
+
orphans: OrphanEntry[];
|
|
184
|
+
/**
|
|
185
|
+
* `true` when the scan was aborted before completion due to a budget
|
|
186
|
+
* overflow or timeout. The `orphans` list reflects only entries found
|
|
187
|
+
* before the abort.
|
|
188
|
+
*/
|
|
189
|
+
isPartial: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Machine-readable reason the scan was cut short.
|
|
192
|
+
* - `'timeout'`: the configured `timeoutMs` was exceeded.
|
|
193
|
+
* - `'overflow'`: a per-level entry count exceeded `maxEntriesPerLevel`.
|
|
194
|
+
* `undefined` when `isPartial` is `false`.
|
|
195
|
+
*/
|
|
196
|
+
partialReason?: 'timeout' | 'overflow';
|
|
197
|
+
/**
|
|
198
|
+
* Human-readable warning message produced when the soft-warn threshold
|
|
199
|
+
* was crossed (entries per level exceeded `softWarnEntriesPerLevel` but
|
|
200
|
+
* stayed under the hard stop). `undefined` when no warning was triggered.
|
|
201
|
+
*/
|
|
202
|
+
softWarnMessage?: string;
|
|
159
203
|
}
|
|
160
204
|
|
|
161
205
|
/**
|
package/src/enums.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical task-axis enum constants.
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for the runtime const arrays that back the
|
|
5
|
+
* task-axis discriminators (kind, scope, severity, size, archive reason,
|
|
6
|
+
* relation type). Promoted from `packages/core/src/store/tasks-schema.ts`
|
|
7
|
+
* in Phase 0c of the SG-ARCH-SOLID Saga so that downstream packages can
|
|
8
|
+
* import the values without pulling in the Drizzle schema runtime.
|
|
9
|
+
*
|
|
10
|
+
* `tasks-schema.ts` imports these arrays back for Drizzle's
|
|
11
|
+
* `text({ enum: ... })` column declarations, which preserves byte-identical
|
|
12
|
+
* row-type narrowing and produces zero schema DDL change. `tasks-schema.ts`
|
|
13
|
+
* also re-exports each constant under its original name to preserve the
|
|
14
|
+
* existing public surface for every internal `import * as schema` consumer.
|
|
15
|
+
*
|
|
16
|
+
* The corresponding union types (`TaskKind`, `TaskScope`, `TaskSeverity`,
|
|
17
|
+
* `TaskSize`, `ArchiveReasonValue`, etc.) already live in their respective
|
|
18
|
+
* domain modules (`./task.ts`, `./tasks/archive.ts`) and are re-exported
|
|
19
|
+
* from the package root.
|
|
20
|
+
*
|
|
21
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9955 (Phase 0c)
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Task kind axis — describes the intent of the work rather than its
|
|
26
|
+
* position in the hierarchy. Defaults to `'work'` to preserve semantics
|
|
27
|
+
* for tasks created before T944.
|
|
28
|
+
*
|
|
29
|
+
* Note: the DB column is named `role`; the TypeScript field is `kind`
|
|
30
|
+
* (T9067 deferral).
|
|
31
|
+
*
|
|
32
|
+
* @task T944
|
|
33
|
+
* @task T9072
|
|
34
|
+
*/
|
|
35
|
+
export const TASK_KINDS = ['work', 'research', 'experiment', 'bug', 'spike', 'release'] as const;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Task scope axis — describes the granularity of the work (project-wide
|
|
39
|
+
* vs. feature-scoped vs. unit-scoped). Orthogonal to type and kind.
|
|
40
|
+
*
|
|
41
|
+
* Backfill mapping from legacy `type` during migration:
|
|
42
|
+
* - `type='epic'` → `scope='project'`
|
|
43
|
+
* - `type='task'` → `scope='feature'` (also used for NULL legacy rows)
|
|
44
|
+
* - `type='subtask'` → `scope='unit'`
|
|
45
|
+
*
|
|
46
|
+
* @task T944
|
|
47
|
+
*/
|
|
48
|
+
export const TASK_SCOPES = ['project', 'feature', 'unit'] as const;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Task severity axis — applies to ANY task kind (not just `kind='bug'`).
|
|
52
|
+
*
|
|
53
|
+
* Enforced by a CHECK constraint:
|
|
54
|
+
* `severity IS NULL OR severity IN ('P0','P1','P2','P3')`
|
|
55
|
+
*
|
|
56
|
+
* The original T944 constraint coupled severity to `role='bug'`. T9073
|
|
57
|
+
* widened the constraint so that spikes, incidents, research tasks, and
|
|
58
|
+
* any other kind can carry a severity level. Priority and severity are
|
|
59
|
+
* fully orthogonal axes — setting severity does NOT auto-map to priority
|
|
60
|
+
* (no SEVERITY_MAP on add/update).
|
|
61
|
+
*
|
|
62
|
+
* OWNER-WRITE-ONLY (T944 / T9073 / owner mandate): severity is set
|
|
63
|
+
* through owner-authenticated paths only (signed attestation via
|
|
64
|
+
* `appendSignedSeverityAttestation`). This prevents a prompt-injection
|
|
65
|
+
* exploit where a compromised agent could mark a P0 task as P3 to
|
|
66
|
+
* force-ship.
|
|
67
|
+
*
|
|
68
|
+
* @task T944
|
|
69
|
+
* @task T9073
|
|
70
|
+
*/
|
|
71
|
+
export const TASK_SEVERITIES = ['P0', 'P1', 'P2', 'P3'] as const;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Task size sentinel values matching the DB CHECK constraint on
|
|
75
|
+
* `tasks.size`. CLEO favors qualitative sizing over time estimates
|
|
76
|
+
* (see `cleo memory` rule "No time estimates").
|
|
77
|
+
*
|
|
78
|
+
* @task T944
|
|
79
|
+
*/
|
|
80
|
+
export const TASK_SIZES = ['small', 'medium', 'large'] as const;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Truth-grade archive reason values enforced by a SQLite CHECK
|
|
84
|
+
* constraint on `tasks.archive_reason` (see migration
|
|
85
|
+
* `20260424000000_t1408-archive-reason-enum`).
|
|
86
|
+
*
|
|
87
|
+
* Council 2026-04-24 (FINDING #28 + T1407 follow-through) replaced the
|
|
88
|
+
* legacy unconstrained TEXT column with this 6-value enum. Rows that
|
|
89
|
+
* pre-dated the migration with non-conforming values (`completed`,
|
|
90
|
+
* `deleted`, etc.) were normalized to `'completed-unverified'` before
|
|
91
|
+
* the CHECK was applied, so EVERY existing row satisfies one of these
|
|
92
|
+
* literals (or is `NULL`).
|
|
93
|
+
*
|
|
94
|
+
* Semantics:
|
|
95
|
+
* - `verified` — closure passed all gates with audit-grade evidence.
|
|
96
|
+
* - `reconciled` — closure derived by reconciliation against an
|
|
97
|
+
* external source of truth (e.g. external task tracker).
|
|
98
|
+
* - `superseded` — closure because another task subsumes the work.
|
|
99
|
+
* - `shadowed` — closure because the task was experiment- or
|
|
100
|
+
* proposal-shadowed by a newer plan.
|
|
101
|
+
* - `cancelled` — closure via explicit cancellation
|
|
102
|
+
* (`status='cancelled'`).
|
|
103
|
+
* - `completed-unverified` — closure happened but verification was skipped,
|
|
104
|
+
* incomplete, or failed; metrics MUST NOT count
|
|
105
|
+
* these as quality completions without opt-in.
|
|
106
|
+
*
|
|
107
|
+
* @task T1408
|
|
108
|
+
* @epic T1407
|
|
109
|
+
*/
|
|
110
|
+
export const ARCHIVE_REASONS = [
|
|
111
|
+
'verified',
|
|
112
|
+
'reconciled',
|
|
113
|
+
'superseded',
|
|
114
|
+
'shadowed',
|
|
115
|
+
'cancelled',
|
|
116
|
+
'completed-unverified',
|
|
117
|
+
] as const;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Task relation types matching the DB CHECK constraint on
|
|
121
|
+
* `task_relations.relation_type`.
|
|
122
|
+
*
|
|
123
|
+
* - `related` — generic non-blocking association
|
|
124
|
+
* - `blocks` — source MUST complete before target can proceed
|
|
125
|
+
* - `duplicates` — source is a duplicate of target (target is canonical)
|
|
126
|
+
* - `absorbs` — source's work was absorbed into target
|
|
127
|
+
* - `fixes` — source fixes target (bug→fix linkage)
|
|
128
|
+
* - `extends` — source extends or refines target
|
|
129
|
+
* - `supersedes` — source replaces target (target is retired)
|
|
130
|
+
* - `groups` — source groups target (Saga→Epic per ADR-073)
|
|
131
|
+
*
|
|
132
|
+
* @task T944
|
|
133
|
+
* @task ADR-073 (`groups` relation for Saga membership)
|
|
134
|
+
*/
|
|
135
|
+
export const TASK_RELATION_TYPES = [
|
|
136
|
+
'related',
|
|
137
|
+
'blocks',
|
|
138
|
+
'duplicates',
|
|
139
|
+
'absorbs',
|
|
140
|
+
'fixes',
|
|
141
|
+
'extends',
|
|
142
|
+
'supersedes',
|
|
143
|
+
'groups',
|
|
144
|
+
] as const;
|
package/src/index.ts
CHANGED
|
@@ -269,6 +269,11 @@ export type {
|
|
|
269
269
|
DependencySpec,
|
|
270
270
|
} from './dependency.js';
|
|
271
271
|
export type { AdapterManifest, DetectionPattern } from './discovery.js';
|
|
272
|
+
// === Dispatch Identity Contracts (T9954 — Phase 0b of SG-ARCH-SOLID / E-CONTRACTS-FOUNDATION) ===
|
|
273
|
+
export type { CanonicalDomain, Gateway, Tier } from './dispatch/identity.js';
|
|
274
|
+
export { CANONICAL_DOMAINS } from './dispatch/identity.js';
|
|
275
|
+
// === Dispatch OperationDef + Resolution (T9954 — Phase 0b of SG-ARCH-SOLID / E-CONTRACTS-FOUNDATION) ===
|
|
276
|
+
export type { OperationDef, Resolution } from './dispatch/operation-def.js';
|
|
272
277
|
// === DocsAccessor Contracts (T9063) ===
|
|
273
278
|
export type {
|
|
274
279
|
DocExportFormat,
|
|
@@ -294,10 +299,11 @@ export {
|
|
|
294
299
|
DocKindConfigError,
|
|
295
300
|
DocKindRegistry,
|
|
296
301
|
} from './docs-taxonomy.js';
|
|
297
|
-
// === Doctor: Worktree-Orphan Audit + Prune Types (T9790, T9808) ===
|
|
302
|
+
// === Doctor: Worktree-Orphan Audit + Prune Types (T9790, T9808, T9962) ===
|
|
298
303
|
export type {
|
|
299
304
|
ComprehensiveAuditResult,
|
|
300
305
|
OrphanEntry,
|
|
306
|
+
OrphanScanResult,
|
|
301
307
|
PruneAuditEntry,
|
|
302
308
|
PruneResult,
|
|
303
309
|
WorktreeAnomaly,
|
|
@@ -317,6 +323,15 @@ export {
|
|
|
317
323
|
engineSuccess,
|
|
318
324
|
unwrap,
|
|
319
325
|
} from './engine-result.js';
|
|
326
|
+
// === Task-Axis Enum Constants (T9955 — promoted from core/store/tasks-schema.ts) ===
|
|
327
|
+
export {
|
|
328
|
+
ARCHIVE_REASONS,
|
|
329
|
+
TASK_KINDS,
|
|
330
|
+
TASK_RELATION_TYPES,
|
|
331
|
+
TASK_SCOPES,
|
|
332
|
+
TASK_SEVERITIES,
|
|
333
|
+
TASK_SIZES,
|
|
334
|
+
} from './enums.js';
|
|
320
335
|
// === Error Utilities ===
|
|
321
336
|
export {
|
|
322
337
|
ClassifierUnregisteredAgentError,
|
|
@@ -444,6 +459,8 @@ export {
|
|
|
444
459
|
} from './graph.js';
|
|
445
460
|
export type { AdapterHookProvider } from './hooks.js';
|
|
446
461
|
export type { AdapterInstallProvider, InstallOptions, InstallResult } from './install.js';
|
|
462
|
+
// === Background Job Status (T9955 — promoted from core/store/tasks-schema.ts) ===
|
|
463
|
+
export type { BackgroundJobStatus } from './jobs.js';
|
|
447
464
|
export type {
|
|
448
465
|
CleoResponse,
|
|
449
466
|
ConformanceReport,
|
|
@@ -530,8 +547,37 @@ export type {
|
|
|
530
547
|
export type { ResolvedCredential } from './llm/resolved-credential.js';
|
|
531
548
|
// === Logger contract (T9766 — centralized from @cleocode/core) ===
|
|
532
549
|
export type { LoggerConfig } from './logger.js';
|
|
550
|
+
// === BRAIN memory wire-shape contracts (T9956 — promoted from @cleocode/core) ===
|
|
551
|
+
export type {
|
|
552
|
+
BudgetedEntry,
|
|
553
|
+
BudgetedResult,
|
|
554
|
+
BudgetedRetrievalOptions,
|
|
555
|
+
} from './memory/budgeted.js';
|
|
533
556
|
// === ContextEngine contract (canonical home — T9304) ===
|
|
534
557
|
export type { CompressedContext, ContextEngine } from './memory/context-engine.js';
|
|
558
|
+
export type {
|
|
559
|
+
FetchBrainEntriesParams,
|
|
560
|
+
FetchBrainEntriesResult,
|
|
561
|
+
FetchedBrainEntry,
|
|
562
|
+
} from './memory/fetch.js';
|
|
563
|
+
export type {
|
|
564
|
+
BrainObservationSourceType,
|
|
565
|
+
DocAttachmentObservationPayload,
|
|
566
|
+
ObserveBrainParams,
|
|
567
|
+
ObserveBrainResult,
|
|
568
|
+
} from './memory/observe.js';
|
|
569
|
+
export { BRAIN_OBSERVATION_SOURCE_TYPES } from './memory/observe.js';
|
|
570
|
+
export type {
|
|
571
|
+
BrainCompactHit,
|
|
572
|
+
SearchBrainCompactParams,
|
|
573
|
+
SearchBrainCompactResult,
|
|
574
|
+
} from './memory/search.js';
|
|
575
|
+
export type {
|
|
576
|
+
BrainAnchor,
|
|
577
|
+
TimelineBrainParams,
|
|
578
|
+
TimelineBrainResult,
|
|
579
|
+
TimelineNeighbor,
|
|
580
|
+
} from './memory/timeline.js';
|
|
535
581
|
export type {
|
|
536
582
|
BridgeDecision,
|
|
537
583
|
BridgeLearning,
|
|
@@ -1047,6 +1093,7 @@ export type {
|
|
|
1047
1093
|
DepGraphIssue,
|
|
1048
1094
|
DepsTreeEdge,
|
|
1049
1095
|
DepsTreeNode,
|
|
1096
|
+
TaskShowAttachmentEntry,
|
|
1050
1097
|
TasksAddBatchParams,
|
|
1051
1098
|
TasksAddBatchResult,
|
|
1052
1099
|
TasksAddParams,
|
|
@@ -1283,6 +1330,30 @@ export type {
|
|
|
1283
1330
|
ProjectType,
|
|
1284
1331
|
TestFramework,
|
|
1285
1332
|
} from './project-context.js';
|
|
1333
|
+
// === Provenance Graph Unions (T9955 — promoted from core/store/tasks-schema.ts) ===
|
|
1334
|
+
// Note: ReleaseChannel/ReleaseKind/ReleaseScheme/ReleaseStatus collide with the
|
|
1335
|
+
// existing `./release/channel.js` + `./release/plan.js` + `./task.js` exports
|
|
1336
|
+
// (different domains, different value sets). The colliding 4 are re-exported
|
|
1337
|
+
// here under `Provenance…`-qualified aliases. The other 12 keep their natural
|
|
1338
|
+
// names — they are unique across the package.
|
|
1339
|
+
export type {
|
|
1340
|
+
BrainReleaseLinkType,
|
|
1341
|
+
CommitConventionalType,
|
|
1342
|
+
CommitFileChangeType,
|
|
1343
|
+
CommitLinkKind,
|
|
1344
|
+
CommitLinkSource,
|
|
1345
|
+
PrLinkKind,
|
|
1346
|
+
PrLinkSource,
|
|
1347
|
+
PrState,
|
|
1348
|
+
ReleaseArtifactType,
|
|
1349
|
+
ReleaseChangeType,
|
|
1350
|
+
ReleaseChannel as ProvenanceReleaseChannel,
|
|
1351
|
+
ReleaseClassifiedBy,
|
|
1352
|
+
ReleaseImpact,
|
|
1353
|
+
ReleaseKind as ProvenanceReleaseKind,
|
|
1354
|
+
ReleaseScheme as ProvenanceReleaseScheme,
|
|
1355
|
+
ReleaseStatus as ProvenanceReleaseStatus,
|
|
1356
|
+
} from './provenance.js';
|
|
1286
1357
|
export type { AdapterPathProvider } from './provider-paths.js';
|
|
1287
1358
|
// === Release Channel ===
|
|
1288
1359
|
export type { ChannelValidationResult, ReleaseChannel } from './release/channel.js';
|
|
@@ -1409,6 +1480,13 @@ export type {
|
|
|
1409
1480
|
TaskRefPriority,
|
|
1410
1481
|
TaskSummary,
|
|
1411
1482
|
} from './results.js';
|
|
1483
|
+
// === Scaffold + Diagnostic Result Types (SG-ARCH-SOLID T9831 / E-CONTRACTS-FOUNDATION T9832) ===
|
|
1484
|
+
export type {
|
|
1485
|
+
CheckResult,
|
|
1486
|
+
CheckStatus,
|
|
1487
|
+
HookCheckResult,
|
|
1488
|
+
ScaffoldResult,
|
|
1489
|
+
} from './scaffold-diagnostics.js';
|
|
1412
1490
|
// === SDK Tool Contract (Category B harness-agnostic SDK utilities — T1768 / ADR-064) ===
|
|
1413
1491
|
export type { SdkTool, SdkToolIdentity } from './sdk-tool.js';
|
|
1414
1492
|
// === Sentient Tier-2 Types (T1008) ===
|
package/src/jobs.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background job contracts.
|
|
3
|
+
*
|
|
4
|
+
* Canonical home for the durable-job lifecycle types. Promoted from
|
|
5
|
+
* `packages/core/src/store/tasks-schema.ts` in Phase 0c of the
|
|
6
|
+
* SG-ARCH-SOLID Saga so that the cleo dispatch layer
|
|
7
|
+
* (`@cleocode/cleo/dispatch/lib/background-jobs.ts`) can import the
|
|
8
|
+
* status union without pulling in the Drizzle schema runtime.
|
|
9
|
+
*
|
|
10
|
+
* The `BACKGROUND_JOB_STATUSES` const array remains in `tasks-schema.ts`
|
|
11
|
+
* because Drizzle's `text({ enum: ... })` column declaration narrows the
|
|
12
|
+
* runtime row type directly from that `as const` literal. `tasks-schema.ts`
|
|
13
|
+
* re-exports {@link BackgroundJobStatus} from this module to preserve the
|
|
14
|
+
* existing public surface.
|
|
15
|
+
*
|
|
16
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9955 (Phase 0c)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Lifecycle status of a durable background job persisted in `tasks.db`.
|
|
21
|
+
*
|
|
22
|
+
* - `pending` — created but not yet picked up by a worker
|
|
23
|
+
* - `running` — actively executing; emits heartbeats
|
|
24
|
+
* - `complete` — finished successfully (`result` populated, `error` NULL)
|
|
25
|
+
* - `failed` — finished with an error (`error` populated, `result` NULL)
|
|
26
|
+
* - `cancelled` — explicitly cancelled by a caller
|
|
27
|
+
* - `orphaned` — was `running` when the process exited; requires human/agent review
|
|
28
|
+
*
|
|
29
|
+
* Jobs survive process restart; any row with `status='running'` at startup
|
|
30
|
+
* is transitioned to `status='orphaned'` so humans/agents can triage them.
|
|
31
|
+
*
|
|
32
|
+
* @task T641
|
|
33
|
+
* @remarks
|
|
34
|
+
* The values here MUST stay aligned with `BACKGROUND_JOB_STATUSES` in
|
|
35
|
+
* `tasks-schema.ts`; that const array drives the Drizzle row type. A
|
|
36
|
+
* compile-time structural assertion in
|
|
37
|
+
* `packages/contracts/src/__tests__/jobs.test.ts` pins both sides.
|
|
38
|
+
*/
|
|
39
|
+
export type BackgroundJobStatus =
|
|
40
|
+
| 'pending'
|
|
41
|
+
| 'running'
|
|
42
|
+
| 'complete'
|
|
43
|
+
| 'failed'
|
|
44
|
+
| 'cancelled'
|
|
45
|
+
| 'orphaned';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Budget-aware BRAIN retrieval wire shapes.
|
|
3
|
+
*
|
|
4
|
+
* Canonical home for the parameters and result types of the public
|
|
5
|
+
* `retrieveWithBudget` operation — hybrid (FTS5 + vector KNN + graph) BRAIN
|
|
6
|
+
* search with token-bounded result accounting. Used by the session-briefing
|
|
7
|
+
* pipeline (`buildRetrievalBundle`) to assemble cross-table context within
|
|
8
|
+
* a caller-specified token budget.
|
|
9
|
+
*
|
|
10
|
+
* Promoted from `packages/core/src/memory/brain-retrieval.ts` (T549
|
|
11
|
+
* Wave 3-A region, lines 1305-1340) to `@cleocode/contracts` in Phase 0e
|
|
12
|
+
* of SG-ARCH-SOLID (E-CONTRACTS-FOUNDATION).
|
|
13
|
+
*
|
|
14
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9956 (Phase 0e)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// ── BudgetedRetrievalOptions ────────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Optional filters for `retrieveWithBudget`.
|
|
21
|
+
*
|
|
22
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9956 (Phase 0e)
|
|
23
|
+
*/
|
|
24
|
+
export interface BudgetedRetrievalOptions {
|
|
25
|
+
/** Filter by cognitive types (semantic / episodic / procedural). */
|
|
26
|
+
types?: Array<'semantic' | 'episodic' | 'procedural'>;
|
|
27
|
+
/** Filter by memory tiers (short / medium / long). */
|
|
28
|
+
tiers?: Array<'short' | 'medium' | 'long'>;
|
|
29
|
+
/** When true, only return verified entries. Default: false. */
|
|
30
|
+
verified?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ── BudgetedEntry ───────────────────────────────────────────────────
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A single entry returned by `retrieveWithBudget`.
|
|
37
|
+
*
|
|
38
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9956 (Phase 0e)
|
|
39
|
+
*/
|
|
40
|
+
export interface BudgetedEntry {
|
|
41
|
+
/** Entry identifier. */
|
|
42
|
+
id: string;
|
|
43
|
+
/** Source BRAIN table (e.g. `observation`, `decision`, `pattern`, `learning`). */
|
|
44
|
+
type: string;
|
|
45
|
+
/** Display title for the entry. */
|
|
46
|
+
title: string;
|
|
47
|
+
/** Full text payload (narrative / decision text / pattern body / learning insight). */
|
|
48
|
+
text: string;
|
|
49
|
+
/** Fused relevance score: FTS50% + vector40% + graph10% × qualityScore. */
|
|
50
|
+
score: number;
|
|
51
|
+
/** Estimated token cost for this entry (~chars/4). */
|
|
52
|
+
tokensEstimated: number;
|
|
53
|
+
/** Memory tier for this entry. */
|
|
54
|
+
memoryTier?: string;
|
|
55
|
+
/** Cognitive type for this entry. */
|
|
56
|
+
memoryType?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ── BudgetedResult ──────────────────────────────────────────────────
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Result envelope returned by `retrieveWithBudget`.
|
|
63
|
+
*
|
|
64
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9956 (Phase 0e)
|
|
65
|
+
*/
|
|
66
|
+
export interface BudgetedResult {
|
|
67
|
+
/** Entries selected within the requested token budget, ranked by fused score. */
|
|
68
|
+
entries: BudgetedEntry[];
|
|
69
|
+
/** Total tokens consumed by returned entries. */
|
|
70
|
+
tokensUsed: number;
|
|
71
|
+
/** Tokens remaining from the original budget. */
|
|
72
|
+
tokensRemaining: number;
|
|
73
|
+
/** Number of entries excluded due to budget constraints. */
|
|
74
|
+
excluded: number;
|
|
75
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BRAIN entry-fetch wire shapes.
|
|
3
|
+
*
|
|
4
|
+
* Canonical home for the parameters and result types of the public
|
|
5
|
+
* `fetchBrainEntries` operation — Layer 3 of CLEO's 3-layer BRAIN retrieval
|
|
6
|
+
* pattern (search → timeline → fetch). Returns the full row payload for a
|
|
7
|
+
* caller-supplied list of IDs, typically derived from a prior `searchBrainCompact`
|
|
8
|
+
* or `timelineBrain` call.
|
|
9
|
+
*
|
|
10
|
+
* Promoted from `packages/core/src/memory/brain-retrieval.ts` to
|
|
11
|
+
* `@cleocode/contracts` in Phase 0e of SG-ARCH-SOLID
|
|
12
|
+
* (E-CONTRACTS-FOUNDATION).
|
|
13
|
+
*
|
|
14
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9956 (Phase 0e)
|
|
15
|
+
* @see Layer 1: {@link ./search.ts}
|
|
16
|
+
* @see Layer 2: {@link ./timeline.ts}
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// ── FetchBrainEntriesParams ─────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Parameters for `fetchBrainEntries`.
|
|
23
|
+
*
|
|
24
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9956 (Phase 0e)
|
|
25
|
+
*/
|
|
26
|
+
export interface FetchBrainEntriesParams {
|
|
27
|
+
/** Entry identifiers to fetch in a single batch. */
|
|
28
|
+
ids: string[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ── FetchedBrainEntry ───────────────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A single fetched entry with its full row payload.
|
|
35
|
+
*
|
|
36
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9956 (Phase 0e)
|
|
37
|
+
*/
|
|
38
|
+
export interface FetchedBrainEntry {
|
|
39
|
+
/** Entry identifier. */
|
|
40
|
+
id: string;
|
|
41
|
+
/** Source BRAIN table (e.g. `observation`, `decision`, `pattern`, `learning`). */
|
|
42
|
+
type: string;
|
|
43
|
+
/**
|
|
44
|
+
* Raw row payload as returned by the underlying SQL query.
|
|
45
|
+
*
|
|
46
|
+
* Typed as `unknown` because the shape varies by `type`. Callers narrow
|
|
47
|
+
* via a discriminated read or pass the value through to a renderer.
|
|
48
|
+
*/
|
|
49
|
+
data: unknown;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ── FetchBrainEntriesResult ─────────────────────────────────────────
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Result envelope returned by `fetchBrainEntries`.
|
|
56
|
+
*
|
|
57
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9956 (Phase 0e)
|
|
58
|
+
*/
|
|
59
|
+
export interface FetchBrainEntriesResult {
|
|
60
|
+
/** Resolved entries, in the order they were found (not necessarily input order). */
|
|
61
|
+
results: FetchedBrainEntry[];
|
|
62
|
+
/** Entry identifiers that could not be resolved against any BRAIN table. */
|
|
63
|
+
notFound: string[];
|
|
64
|
+
/** Approximate token cost of the returned payload (~chars/4). */
|
|
65
|
+
tokensEstimated: number;
|
|
66
|
+
}
|