@cleocode/contracts 2026.5.60 → 2026.5.62
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__/nexus-scope-map.test.d.ts +8 -0
- package/dist/__tests__/nexus-scope-map.test.d.ts.map +1 -0
- package/dist/__tests__/nexus-scope-map.test.js +145 -0
- package/dist/__tests__/nexus-scope-map.test.js.map +1 -0
- package/dist/branch-lock.d.ts +11 -0
- package/dist/branch-lock.d.ts.map +1 -1
- package/dist/branch-lock.js +11 -0
- package/dist/branch-lock.js.map +1 -1
- package/dist/config.d.ts +21 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/data-accessor.d.ts +2 -0
- package/dist/data-accessor.d.ts.map +1 -1
- package/dist/data-accessor.js.map +1 -1
- package/dist/engine-result.d.ts +170 -0
- package/dist/engine-result.d.ts.map +1 -0
- package/dist/engine-result.js +123 -0
- package/dist/engine-result.js.map +1 -0
- package/dist/errors.d.ts +24 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +31 -0
- package/dist/errors.js.map +1 -1
- package/dist/exit-codes.d.ts +8 -1
- package/dist/exit-codes.d.ts.map +1 -1
- package/dist/exit-codes.js +7 -0
- package/dist/exit-codes.js.map +1 -1
- package/dist/graph.d.ts +88 -0
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +35 -0
- package/dist/graph.js.map +1 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/operations/nexus-scope-map.d.ts +540 -0
- package/dist/operations/nexus-scope-map.d.ts.map +1 -0
- package/dist/operations/nexus-scope-map.js +556 -0
- package/dist/operations/nexus-scope-map.js.map +1 -0
- package/dist/operations/nexus-scope.d.ts +185 -0
- package/dist/operations/nexus-scope.d.ts.map +1 -0
- package/dist/operations/nexus-scope.js +9 -0
- package/dist/operations/nexus-scope.js.map +1 -0
- package/dist/operations/session.d.ts +79 -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/operations/worktree.d.ts +33 -0
- package/dist/operations/worktree.d.ts.map +1 -1
- package/dist/spawn.d.ts +94 -0
- package/dist/spawn.d.ts.map +1 -1
- package/dist/spawn.js +65 -1
- package/dist/spawn.js.map +1 -1
- package/dist/task.d.ts +17 -2
- package/dist/task.d.ts.map +1 -1
- package/dist/task.js +11 -1
- package/dist/task.js.map +1 -1
- package/dist/tasks.d.ts +0 -2
- package/dist/tasks.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/nexus-scope-map.test.ts +183 -0
- package/src/branch-lock.ts +11 -0
- package/src/config.ts +22 -0
- package/src/data-accessor.ts +3 -0
- package/src/engine-result.ts +220 -0
- package/src/errors.ts +34 -0
- package/src/exit-codes.ts +8 -0
- package/src/graph.ts +112 -0
- package/src/index.ts +49 -2
- package/src/operations/nexus-scope-map.ts +597 -0
- package/src/operations/nexus-scope.ts +217 -0
- package/src/operations/session.ts +87 -0
- package/src/operations/tasks.ts +40 -0
- package/src/operations/worktree.ts +33 -0
- package/src/spawn.ts +141 -0
- package/src/task.ts +30 -1
- package/src/tasks.ts +0 -2
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical EngineResult type — the single discriminated-union shape used by
|
|
3
|
+
* all SDK return paths, dispatch engines, and CLI domain handlers.
|
|
4
|
+
*
|
|
5
|
+
* Defined here in @cleocode/contracts so it is available to every consumer
|
|
6
|
+
* without creating a dependency on @cleocode/core. @cleocode/core re-exports
|
|
7
|
+
* these types and helpers transparently.
|
|
8
|
+
*
|
|
9
|
+
* @epic T1685 — T-CSL-RESET Wave 1: EngineResult canonicalization
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { LAFSPage } from '@cleocode/lafs';
|
|
13
|
+
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// RFC 9457 Problem Details — canonical definition (moved from core/errors.ts)
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* RFC 9457 Problem Details object.
|
|
20
|
+
* Structured error representation for API responses.
|
|
21
|
+
*
|
|
22
|
+
* @see https://www.rfc-editor.org/rfc/rfc9457
|
|
23
|
+
*/
|
|
24
|
+
export interface ProblemDetails {
|
|
25
|
+
/** URI reference identifying the problem type. */
|
|
26
|
+
type: string;
|
|
27
|
+
/** Short human-readable summary of the problem type. */
|
|
28
|
+
title: string;
|
|
29
|
+
/** HTTP status code. */
|
|
30
|
+
status: number;
|
|
31
|
+
/** Human-readable explanation specific to this occurrence. */
|
|
32
|
+
detail: string;
|
|
33
|
+
/** URI reference identifying the specific problem instance. */
|
|
34
|
+
instance?: string;
|
|
35
|
+
/** Extension members carrying additional problem information. */
|
|
36
|
+
extensions?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// EngineResult — discriminated union
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Successful engine result branch — carries `data` and optional `page`.
|
|
45
|
+
*
|
|
46
|
+
* @task T1685 — canonical home moved to contracts
|
|
47
|
+
*/
|
|
48
|
+
export interface EngineSuccess<T = unknown> {
|
|
49
|
+
readonly success: true;
|
|
50
|
+
readonly data: T;
|
|
51
|
+
readonly page?: LAFSPage;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Structured engine error payload — carries machine-readable code + human
|
|
56
|
+
* message plus optional exitCode, details, fix hint, alternative actions,
|
|
57
|
+
* and RFC 9457 problem details.
|
|
58
|
+
*
|
|
59
|
+
* @task T1707 — problemDetails field
|
|
60
|
+
* @task T1685 — canonical home moved to contracts
|
|
61
|
+
*/
|
|
62
|
+
export interface EngineErrorPayload {
|
|
63
|
+
code: string;
|
|
64
|
+
message: string;
|
|
65
|
+
exitCode?: number;
|
|
66
|
+
details?: unknown;
|
|
67
|
+
fix?: string;
|
|
68
|
+
alternatives?: Array<{ action: string; command: string }>;
|
|
69
|
+
/**
|
|
70
|
+
* RFC 9457 problem details for structured error reporting.
|
|
71
|
+
*
|
|
72
|
+
* @see ProblemDetails
|
|
73
|
+
*/
|
|
74
|
+
problemDetails?: ProblemDetails;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Failed engine result branch — carries structured `error`.
|
|
79
|
+
*
|
|
80
|
+
* @task T1685 — canonical home moved to contracts
|
|
81
|
+
*/
|
|
82
|
+
export interface EngineFailure {
|
|
83
|
+
readonly success: false;
|
|
84
|
+
readonly error: EngineErrorPayload;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Canonical EngineResult — discriminated union of success and failure.
|
|
89
|
+
*
|
|
90
|
+
* Use `result.success` to narrow:
|
|
91
|
+
* - `true` → `result.data: T` is present; `result.error` does not exist
|
|
92
|
+
* - `false` → `result.error: EngineErrorPayload` is present; `result.data` does not exist
|
|
93
|
+
*
|
|
94
|
+
* @task T1685 — canonical home moved to contracts
|
|
95
|
+
*/
|
|
96
|
+
export type EngineResult<T = unknown> = EngineSuccess<T> | EngineFailure;
|
|
97
|
+
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// Constructors
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Construct a successful EngineResult.
|
|
104
|
+
*
|
|
105
|
+
* @param data - the operation's payload
|
|
106
|
+
* @param page - optional pagination metadata
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { engineSuccess } from '@cleocode/contracts';
|
|
111
|
+
* return engineSuccess({ items: [], total: 0 });
|
|
112
|
+
* return engineSuccess(items, { mode: 'offset', limit: 10, offset: 0, total: 100, hasMore: true });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export function engineSuccess<T>(data: T, page?: LAFSPage): EngineResult<T> {
|
|
116
|
+
return page ? { success: true, data, page } : { success: true, data };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Construct a failed EngineResult with structured error.
|
|
121
|
+
*
|
|
122
|
+
* @param code - stable machine-readable error code (e.g. `'E_NOT_FOUND'`)
|
|
123
|
+
* @param message - human-readable error description
|
|
124
|
+
* @param options - optional `exitCode`, `details`, `fix`, `alternatives`, `problemDetails`
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* import { engineError } from '@cleocode/contracts';
|
|
129
|
+
* return engineError('E_NOT_FOUND', `Task ${id} not found`, { fix: `cleo show ${id}` });
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export function engineError<T = unknown>(
|
|
133
|
+
code: string,
|
|
134
|
+
message: string,
|
|
135
|
+
options?: {
|
|
136
|
+
exitCode?: number;
|
|
137
|
+
details?: unknown;
|
|
138
|
+
fix?: string;
|
|
139
|
+
alternatives?: Array<{ action: string; command: string }>;
|
|
140
|
+
problemDetails?: ProblemDetails;
|
|
141
|
+
},
|
|
142
|
+
): EngineResult<T> {
|
|
143
|
+
return {
|
|
144
|
+
success: false,
|
|
145
|
+
error: {
|
|
146
|
+
code,
|
|
147
|
+
message,
|
|
148
|
+
...(options?.exitCode !== undefined ? { exitCode: options.exitCode } : {}),
|
|
149
|
+
...(options?.details !== undefined ? { details: options.details } : {}),
|
|
150
|
+
...(options?.fix !== undefined ? { fix: options.fix } : {}),
|
|
151
|
+
...(options?.alternatives ? { alternatives: options.alternatives } : {}),
|
|
152
|
+
...(options?.problemDetails !== undefined ? { problemDetails: options.problemDetails } : {}),
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
// unwrap() — throw-style ergonomic helper for SDK consumers
|
|
159
|
+
// ---------------------------------------------------------------------------
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Error thrown by {@link unwrap} when an {@link EngineResult} carries a
|
|
163
|
+
* failure. Preserves the full {@link EngineErrorPayload} shape so callers
|
|
164
|
+
* can inspect `code`, `message`, `exitCode`, `details`, `fix`,
|
|
165
|
+
* `alternatives`, and `problemDetails` after catching.
|
|
166
|
+
*
|
|
167
|
+
* @task T1725
|
|
168
|
+
*/
|
|
169
|
+
export class EngineResultError extends Error {
|
|
170
|
+
/** Machine-readable error code (e.g. `'E_NOT_FOUND'`). */
|
|
171
|
+
readonly code: string;
|
|
172
|
+
/** Numeric process exit code, if present. */
|
|
173
|
+
readonly exitCode?: number;
|
|
174
|
+
/** Structured field-level details, if present. */
|
|
175
|
+
readonly details?: unknown;
|
|
176
|
+
/** Human-readable fix hint, if present. */
|
|
177
|
+
readonly fix?: string;
|
|
178
|
+
/** Alternative actions the caller may take, if present. */
|
|
179
|
+
readonly alternatives?: Array<{ action: string; command: string }>;
|
|
180
|
+
/** RFC 9457 problem details, if present. */
|
|
181
|
+
readonly problemDetails?: ProblemDetails;
|
|
182
|
+
|
|
183
|
+
constructor(payload: EngineErrorPayload) {
|
|
184
|
+
super(payload.message);
|
|
185
|
+
this.name = 'EngineResultError';
|
|
186
|
+
this.code = payload.code;
|
|
187
|
+
if (payload.exitCode !== undefined) this.exitCode = payload.exitCode;
|
|
188
|
+
if (payload.details !== undefined) this.details = payload.details;
|
|
189
|
+
if (payload.fix !== undefined) this.fix = payload.fix;
|
|
190
|
+
if (payload.alternatives !== undefined) this.alternatives = payload.alternatives;
|
|
191
|
+
if (payload.problemDetails !== undefined) this.problemDetails = payload.problemDetails;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Unwrap an {@link EngineResult}, returning the payload data on success or
|
|
197
|
+
* throwing an {@link EngineResultError} on failure.
|
|
198
|
+
*
|
|
199
|
+
* Intended for public SDK consumers who prefer a throw-style API over the
|
|
200
|
+
* internal discriminated-union pattern. Internal dispatch code SHOULD
|
|
201
|
+
* continue using the `if (result.success)` pattern directly.
|
|
202
|
+
*
|
|
203
|
+
* @param result - an {@link EngineResult} to unwrap
|
|
204
|
+
* @returns the `data` value when `result.success` is `true`
|
|
205
|
+
* @throws {@link EngineResultError} when `result.success` is `false`
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* import { unwrap } from '@cleocode/contracts';
|
|
210
|
+
* const task = unwrap(await engine.getTask(id));
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @task T1725
|
|
214
|
+
*/
|
|
215
|
+
export function unwrap<T>(result: EngineResult<T>): T {
|
|
216
|
+
if (result.success) {
|
|
217
|
+
return result.data;
|
|
218
|
+
}
|
|
219
|
+
throw new EngineResultError(result.error);
|
|
220
|
+
}
|
package/src/errors.ts
CHANGED
|
@@ -199,6 +199,40 @@ export class DecisionValidatorFailedError extends Error {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Thrown when a Lead session attempts to end without delegating any work.
|
|
204
|
+
*
|
|
205
|
+
* Hard gate enforcement for T9230 (ADR-070): a Lead session with
|
|
206
|
+
* `delegate_task_count=0` and `tasks_completed > 0` is a bypass attempt.
|
|
207
|
+
* Leads MUST fan out work to Workers via `delegate_task`.
|
|
208
|
+
*
|
|
209
|
+
* @codeName E_LEAD_BYPASS_DETECTED
|
|
210
|
+
* @task T9230
|
|
211
|
+
* @adr ADR-070
|
|
212
|
+
*/
|
|
213
|
+
export class LeadBypassDetectedError extends Error {
|
|
214
|
+
/** Stable LAFS error code string for envelope emission. */
|
|
215
|
+
readonly code = 'E_LEAD_BYPASS_DETECTED';
|
|
216
|
+
/** Numeric exit code aligned with {@link ExitCode.LEAD_BYPASS_DETECTED} (107). */
|
|
217
|
+
readonly exitCode = 107;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @param tasksCompleted - Number of tasks completed in the session.
|
|
221
|
+
* @param sessionId - The session ID being ended.
|
|
222
|
+
*/
|
|
223
|
+
constructor(
|
|
224
|
+
public readonly tasksCompleted: number,
|
|
225
|
+
public readonly sessionId: string,
|
|
226
|
+
) {
|
|
227
|
+
super(
|
|
228
|
+
`E_LEAD_BYPASS_DETECTED: Lead session ${sessionId} completed ${tasksCompleted} task(s) ` +
|
|
229
|
+
`without any delegate_task call. Leads MUST fan out work to Workers (T9230 / ADR-070). ` +
|
|
230
|
+
`Set CLEO_OWNER_OVERRIDE=1 with reason to override (audited).`,
|
|
231
|
+
);
|
|
232
|
+
this.name = 'LeadBypassDetectedError';
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
202
236
|
/**
|
|
203
237
|
* Normalize any thrown value into a standardized error object.
|
|
204
238
|
*
|
package/src/exit-codes.ts
CHANGED
|
@@ -216,6 +216,14 @@ export enum ExitCode {
|
|
|
216
216
|
* @task T1828
|
|
217
217
|
*/
|
|
218
218
|
DECISION_VALIDATOR_FAILED = 106,
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Lead session attempted to end without delegating any work — `delegate_task_count=0`
|
|
222
|
+
* with `tasks_completed > 0`. Leads MUST fan out to Workers (T9230 / ADR-070).
|
|
223
|
+
* @codeName E_LEAD_BYPASS_DETECTED
|
|
224
|
+
* @task T9230
|
|
225
|
+
*/
|
|
226
|
+
LEAD_BYPASS_DETECTED = 107,
|
|
219
227
|
}
|
|
220
228
|
|
|
221
229
|
/** Check if an exit code represents an error (1-99). */
|
package/src/graph.ts
CHANGED
|
@@ -204,6 +204,118 @@ export function confidenceLabelFromNumeric(confidence: number): GraphEdgeConfide
|
|
|
204
204
|
return 'AMBIGUOUS';
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
+
// ---------------------------------------------------------------------------
|
|
208
|
+
// ConfidenceProvenance — structured provenance for confidence scores
|
|
209
|
+
// ---------------------------------------------------------------------------
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Structured provenance for an EXTRACTED confidence assignment.
|
|
213
|
+
*
|
|
214
|
+
* Used when confidence was derived from direct AST evidence (same-file
|
|
215
|
+
* lookup, import-scoped resolution) or an explicit source annotation.
|
|
216
|
+
*
|
|
217
|
+
* @since T9145
|
|
218
|
+
*/
|
|
219
|
+
export interface ExtractedProvenance {
|
|
220
|
+
/** Discriminant. */
|
|
221
|
+
readonly kind: 'extracted';
|
|
222
|
+
/**
|
|
223
|
+
* AST / static-analysis source that produced this confidence value.
|
|
224
|
+
* Examples: `"ast"`, `"import-scope"`, `"same-file"`, `"defines"`.
|
|
225
|
+
*/
|
|
226
|
+
readonly source: string;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Structured provenance for an INFERRED confidence assignment.
|
|
231
|
+
*
|
|
232
|
+
* Used when confidence was derived from resolution heuristics (cross-file
|
|
233
|
+
* type lookup, heritage-map inference, name matching).
|
|
234
|
+
*
|
|
235
|
+
* @since T9145
|
|
236
|
+
*/
|
|
237
|
+
export interface InferredProvenance {
|
|
238
|
+
/** Discriminant. */
|
|
239
|
+
readonly kind: 'inferred';
|
|
240
|
+
/**
|
|
241
|
+
* Heuristic or rule that produced this confidence value.
|
|
242
|
+
* Examples: `"heritage-map"`, `"name-match"`, `"global-tier"`.
|
|
243
|
+
*/
|
|
244
|
+
readonly heuristic: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Structured provenance for an AMBIGUOUS confidence assignment.
|
|
249
|
+
*
|
|
250
|
+
* Used when confidence is low because multiple candidates were found,
|
|
251
|
+
* the parent is external / unresolvable, or resolution fell to a global stub.
|
|
252
|
+
*
|
|
253
|
+
* @since T9145
|
|
254
|
+
*/
|
|
255
|
+
export interface AmbiguousProvenance {
|
|
256
|
+
/** Discriminant. */
|
|
257
|
+
readonly kind: 'ambiguous';
|
|
258
|
+
/**
|
|
259
|
+
* Candidate node IDs that competed for this resolution slot.
|
|
260
|
+
* May be empty when the ambiguity is due to an unresolvable external type.
|
|
261
|
+
*/
|
|
262
|
+
readonly candidates: ReadonlyArray<string>;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Discriminated union of structured confidence provenance variants.
|
|
267
|
+
*
|
|
268
|
+
* Replaces the bare numeric `confidence` field on {@link GraphRelation} as
|
|
269
|
+
* part of the Beta gradient deprecation (phase 0: addition, phase 1:
|
|
270
|
+
* co-existence, removal at v2026.9).
|
|
271
|
+
*
|
|
272
|
+
* **Backfill mapping** for existing records created without structured
|
|
273
|
+
* provenance:
|
|
274
|
+
* - `confidence === 1.0` → `{ kind: 'extracted', source: 'ast' }`
|
|
275
|
+
* - `confidence >= 0.90` → `{ kind: 'extracted', source: 'legacy' }`
|
|
276
|
+
* - `confidence >= 0.80` → `{ kind: 'inferred', heuristic: 'legacy' }`
|
|
277
|
+
* - `confidence < 0.80` → `{ kind: 'ambiguous', candidates: [] }`
|
|
278
|
+
*
|
|
279
|
+
* @since T9145
|
|
280
|
+
* @deprecated Numeric `confidence` on {@link GraphRelation} will be removed in v2026.9.
|
|
281
|
+
* Use `confidenceProvenance` instead. Migration: `confidenceFromProvenance()` maps back.
|
|
282
|
+
*/
|
|
283
|
+
export type ConfidenceProvenance = ExtractedProvenance | InferredProvenance | AmbiguousProvenance;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Backfill a {@link ConfidenceProvenance} from a legacy numeric confidence value.
|
|
287
|
+
*
|
|
288
|
+
* @param confidence - Numeric confidence in range [0.0, 1.0]
|
|
289
|
+
* @returns A structured provenance record consistent with the numeric value
|
|
290
|
+
* @since T9145
|
|
291
|
+
*/
|
|
292
|
+
export function provenanceFromNumeric(confidence: number): ConfidenceProvenance {
|
|
293
|
+
if (confidence === 1.0) return { kind: 'extracted', source: 'ast' };
|
|
294
|
+
if (confidence >= 0.9) return { kind: 'extracted', source: 'legacy' };
|
|
295
|
+
if (confidence >= 0.8) return { kind: 'inferred', heuristic: 'legacy' };
|
|
296
|
+
return { kind: 'ambiguous', candidates: [] };
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Recover a numeric confidence value from a {@link ConfidenceProvenance} record.
|
|
301
|
+
*
|
|
302
|
+
* Inverse of {@link provenanceFromNumeric} for backward-compat bridging.
|
|
303
|
+
*
|
|
304
|
+
* @param provenance - Structured provenance record
|
|
305
|
+
* @returns Best-effort numeric confidence in range [0.0, 1.0]
|
|
306
|
+
* @since T9145
|
|
307
|
+
*/
|
|
308
|
+
export function confidenceFromProvenance(provenance: ConfidenceProvenance): number {
|
|
309
|
+
switch (provenance.kind) {
|
|
310
|
+
case 'extracted':
|
|
311
|
+
return provenance.source === 'ast' ? 1.0 : 0.95;
|
|
312
|
+
case 'inferred':
|
|
313
|
+
return 0.85;
|
|
314
|
+
case 'ambiguous':
|
|
315
|
+
return 0.5;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
207
319
|
// ---------------------------------------------------------------------------
|
|
208
320
|
// Relation interface
|
|
209
321
|
// ---------------------------------------------------------------------------
|
package/src/index.ts
CHANGED
|
@@ -265,6 +265,20 @@ export type {
|
|
|
265
265
|
StoreDocParams,
|
|
266
266
|
StoreDocResult,
|
|
267
267
|
} from './docs-accessor.js';
|
|
268
|
+
export type {
|
|
269
|
+
EngineErrorPayload,
|
|
270
|
+
EngineFailure,
|
|
271
|
+
EngineResult,
|
|
272
|
+
EngineSuccess,
|
|
273
|
+
ProblemDetails,
|
|
274
|
+
} from './engine-result.js';
|
|
275
|
+
// === EngineResult — canonical discriminated-union SDK type (T1685) ===
|
|
276
|
+
export {
|
|
277
|
+
EngineResultError,
|
|
278
|
+
engineError,
|
|
279
|
+
engineSuccess,
|
|
280
|
+
unwrap,
|
|
281
|
+
} from './engine-result.js';
|
|
268
282
|
// === Error Utilities ===
|
|
269
283
|
export {
|
|
270
284
|
ClassifierUnregisteredAgentError,
|
|
@@ -275,6 +289,7 @@ export {
|
|
|
275
289
|
getErrorMessage,
|
|
276
290
|
isErrorResult,
|
|
277
291
|
isErrorType,
|
|
292
|
+
LeadBypassDetectedError,
|
|
278
293
|
LifecycleScopeDeniedError,
|
|
279
294
|
normalizeError,
|
|
280
295
|
ThinAgentViolationError,
|
|
@@ -352,20 +367,28 @@ export {
|
|
|
352
367
|
AGENT_TYPES,
|
|
353
368
|
BRAIN_OBSERVATION_TYPES,
|
|
354
369
|
} from './facade.js';
|
|
355
|
-
// === Graph Intelligence Types (T512, T529, T1862) ===
|
|
370
|
+
// === Graph Intelligence Types (T512, T529, T1862, T9145) ===
|
|
356
371
|
export type {
|
|
372
|
+
AmbiguousProvenance,
|
|
357
373
|
CommunityNode,
|
|
374
|
+
ConfidenceProvenance,
|
|
375
|
+
ExtractedProvenance,
|
|
358
376
|
GraphEdgeConfidenceLabel,
|
|
359
377
|
GraphNode,
|
|
360
378
|
GraphNodeKind,
|
|
361
379
|
GraphRelation,
|
|
362
380
|
GraphRelationType,
|
|
363
381
|
ImpactResult,
|
|
382
|
+
InferredProvenance,
|
|
364
383
|
KnowledgeGraph,
|
|
365
384
|
ProcessNode,
|
|
366
385
|
SymbolIndex,
|
|
367
386
|
} from './graph.js';
|
|
368
|
-
export {
|
|
387
|
+
export {
|
|
388
|
+
confidenceFromProvenance,
|
|
389
|
+
confidenceLabelFromNumeric,
|
|
390
|
+
provenanceFromNumeric,
|
|
391
|
+
} from './graph.js';
|
|
369
392
|
export type { AdapterHookProvider } from './hooks.js';
|
|
370
393
|
export type { AdapterInstallProvider, InstallOptions, InstallResult } from './install.js';
|
|
371
394
|
export type {
|
|
@@ -752,6 +775,23 @@ export type {
|
|
|
752
775
|
NexusWhyResult,
|
|
753
776
|
NexusWikiParams,
|
|
754
777
|
} from './operations/nexus.js';
|
|
778
|
+
// === Nexus Scope Contracts (T9145 + T9146) ===
|
|
779
|
+
export type {
|
|
780
|
+
MetaWithNexusScope,
|
|
781
|
+
NexusBindingSource,
|
|
782
|
+
NexusEffect,
|
|
783
|
+
NexusOperationDescriptor,
|
|
784
|
+
NexusScope,
|
|
785
|
+
NexusScopeMeta,
|
|
786
|
+
NexusStore,
|
|
787
|
+
ScopeBinding,
|
|
788
|
+
SuggestedNextOp,
|
|
789
|
+
} from './operations/nexus-scope.js';
|
|
790
|
+
export {
|
|
791
|
+
getNexusDescriptor,
|
|
792
|
+
listOpsByScope,
|
|
793
|
+
NEXUS_SCOPE_MAP,
|
|
794
|
+
} from './operations/nexus-scope-map.js';
|
|
755
795
|
// === NEXUS User Profile Types (T1076 PSYCHE Wave 1) ===
|
|
756
796
|
// Re-exported at top level so @cleocode/core/nexus and CLI dispatch can
|
|
757
797
|
// import without the `ops.` namespace hop.
|
|
@@ -812,6 +852,10 @@ export type {
|
|
|
812
852
|
// Session operation param/result types — re-exported at top level for typed-dispatch consumers
|
|
813
853
|
// (T975 Wave D · ADR-051 migration)
|
|
814
854
|
export type {
|
|
855
|
+
BriefingExcludeProvenance,
|
|
856
|
+
BriefingFieldContract,
|
|
857
|
+
BriefingFieldRule,
|
|
858
|
+
ContractViolation,
|
|
815
859
|
DecisionRecord,
|
|
816
860
|
SessionBriefingShowParams,
|
|
817
861
|
SessionBriefingShowResult,
|
|
@@ -894,6 +938,8 @@ export type {
|
|
|
894
938
|
TasksRelatesAddParams,
|
|
895
939
|
TasksRelatesAddResult,
|
|
896
940
|
TasksRelatesParams,
|
|
941
|
+
TasksRelatesRemoveParams,
|
|
942
|
+
TasksRelatesRemoveResult,
|
|
897
943
|
TasksRelatesResult,
|
|
898
944
|
TasksReorderDispatchResult,
|
|
899
945
|
TasksReorderQueryParams,
|
|
@@ -1199,6 +1245,7 @@ export type {
|
|
|
1199
1245
|
VerificationFailure,
|
|
1200
1246
|
VerificationGate,
|
|
1201
1247
|
} from './task.js';
|
|
1248
|
+
export { isTestFixtureOrigin, TASK_ORIGIN_CANONICAL } from './task.js';
|
|
1202
1249
|
// === Task Evidence Types (T801) ===
|
|
1203
1250
|
export type {
|
|
1204
1251
|
CommandOutputEvidence,
|