@cleocode/contracts 2026.4.99 → 2026.4.101
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/brain-graph.d.ts +245 -0
- package/dist/brain-graph.d.ts.map +1 -0
- package/dist/brain-graph.js +30 -0
- package/dist/brain-graph.js.map +1 -0
- package/dist/exit-codes.d.ts +1 -1
- package/dist/exit-codes.d.ts.map +1 -1
- package/dist/exit-codes.js +1 -1
- package/dist/exit-codes.js.map +1 -1
- package/dist/graph.d.ts +2 -0
- package/dist/graph.d.ts.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/nexus-contract-ops.d.ts +186 -0
- package/dist/nexus-contract-ops.d.ts.map +1 -0
- package/dist/nexus-contract-ops.js +11 -0
- package/dist/nexus-contract-ops.js.map +1 -0
- package/dist/nexus-living-brain-ops.d.ts +314 -0
- package/dist/nexus-living-brain-ops.d.ts.map +1 -0
- package/dist/nexus-living-brain-ops.js +15 -0
- package/dist/nexus-living-brain-ops.js.map +1 -0
- package/dist/nexus-query-ops.d.ts +82 -0
- package/dist/nexus-query-ops.d.ts.map +1 -0
- package/dist/nexus-query-ops.js +11 -0
- package/dist/nexus-query-ops.js.map +1 -0
- package/dist/nexus-route-ops.d.ts +103 -0
- package/dist/nexus-route-ops.d.ts.map +1 -0
- package/dist/nexus-route-ops.js +10 -0
- package/dist/nexus-route-ops.js.map +1 -0
- package/dist/nexus-tasks-bridge-ops.d.ts +68 -0
- package/dist/nexus-tasks-bridge-ops.d.ts.map +1 -0
- package/dist/nexus-tasks-bridge-ops.js +11 -0
- package/dist/nexus-tasks-bridge-ops.js.map +1 -0
- package/dist/nexus-wiki-ops.d.ts +51 -0
- package/dist/nexus-wiki-ops.d.ts.map +1 -0
- package/dist/nexus-wiki-ops.js +11 -0
- package/dist/nexus-wiki-ops.js.map +1 -0
- package/dist/operations/admin.d.ts +1781 -0
- package/dist/operations/admin.d.ts.map +1 -0
- package/dist/operations/admin.js +27 -0
- package/dist/operations/admin.js.map +1 -0
- package/dist/operations/brain.d.ts +34 -26
- package/dist/operations/brain.d.ts.map +1 -1
- package/dist/operations/brain.js +7 -6
- package/dist/operations/brain.js.map +1 -1
- package/dist/operations/docs.d.ts +279 -0
- package/dist/operations/docs.d.ts.map +1 -0
- package/dist/operations/docs.js +31 -0
- package/dist/operations/docs.js.map +1 -0
- package/dist/operations/intelligence.d.ts +319 -0
- package/dist/operations/intelligence.d.ts.map +1 -0
- package/dist/operations/intelligence.js +24 -0
- package/dist/operations/intelligence.js.map +1 -0
- package/dist/operations/orchestrate.d.ts +113 -2
- package/dist/operations/orchestrate.d.ts.map +1 -1
- package/dist/operations/orchestrate.js +3 -2
- package/dist/operations/orchestrate.js.map +1 -1
- package/dist/operations/session.d.ts +185 -47
- package/dist/operations/session.d.ts.map +1 -1
- package/dist/operations/session.js +7 -6
- package/dist/operations/session.js.map +1 -1
- package/dist/operations/sticky.d.ts +264 -0
- package/dist/operations/sticky.d.ts.map +1 -0
- package/dist/operations/sticky.js +19 -0
- package/dist/operations/sticky.js.map +1 -0
- package/dist/operations/validate.d.ts +145 -19
- package/dist/operations/validate.d.ts.map +1 -1
- package/dist/operations/validate.js +3 -3
- package/dist/task-record.d.ts +19 -0
- package/dist/task-record.d.ts.map +1 -1
- package/package.json +41 -1
- package/src/brain-graph.ts +282 -0
- package/src/exit-codes.ts +1 -1
- package/src/graph.ts +2 -0
- package/src/index.ts +109 -0
- package/src/nexus-contract-ops.ts +244 -0
- package/src/nexus-living-brain-ops.ts +345 -0
- package/src/nexus-query-ops.ts +100 -0
- package/src/nexus-route-ops.ts +134 -0
- package/src/nexus-tasks-bridge-ops.ts +71 -0
- package/src/nexus-wiki-ops.ts +53 -0
- package/src/operations/admin.ts +2087 -0
- package/src/operations/brain.ts +34 -26
- package/src/operations/docs.ts +322 -0
- package/src/operations/intelligence.ts +399 -0
- package/src/operations/orchestrate.ts +117 -2
- package/src/operations/session.ts +217 -48
- package/src/operations/sticky.ts +308 -0
- package/src/operations/validate.ts +161 -55
- package/src/task-record.ts +19 -0
package/src/index.ts
CHANGED
|
@@ -132,6 +132,18 @@ export type {
|
|
|
132
132
|
ContradictionDetail,
|
|
133
133
|
SupersededEntry,
|
|
134
134
|
} from './brain.js';
|
|
135
|
+
// === Brain Unified-Graph Types (canonical — T989 unification) ===
|
|
136
|
+
export type {
|
|
137
|
+
BrainConnectionStatus,
|
|
138
|
+
BrainEdge,
|
|
139
|
+
BrainGraph,
|
|
140
|
+
BrainNode,
|
|
141
|
+
BrainNodeKind,
|
|
142
|
+
BrainProjectContext,
|
|
143
|
+
BrainQueryOptions,
|
|
144
|
+
BrainStreamEvent,
|
|
145
|
+
BrainSubstrate,
|
|
146
|
+
} from './brain-graph.js';
|
|
135
147
|
export type { AdapterCapabilities } from './capabilities.js';
|
|
136
148
|
// === Code Symbol Types (tree-sitter AST) ===
|
|
137
149
|
export type {
|
|
@@ -339,6 +351,68 @@ export type {
|
|
|
339
351
|
MemoryBridgeContent,
|
|
340
352
|
SessionSummary,
|
|
341
353
|
} from './memory.js';
|
|
354
|
+
export type {
|
|
355
|
+
Contract,
|
|
356
|
+
ContractCompatibilityMatrix,
|
|
357
|
+
ContractExtractionResult,
|
|
358
|
+
ContractMatch,
|
|
359
|
+
ContractMatchLevel,
|
|
360
|
+
ContractTaskLink,
|
|
361
|
+
GrpcContract,
|
|
362
|
+
HttpContract,
|
|
363
|
+
TopicContract,
|
|
364
|
+
} from './nexus-contract-ops.js';
|
|
365
|
+
// === Living Brain SDK Types (T1068 — 5-substrate traversal primitives) ===
|
|
366
|
+
// === Extended Code Reasoning Types (T1069 — reasonWhySymbol + reasonImpactOfChange) ===
|
|
367
|
+
export type {
|
|
368
|
+
BlastRadiusSummary,
|
|
369
|
+
BrainMemoryRef,
|
|
370
|
+
BrainRiskNote,
|
|
371
|
+
CodeAnchorResult,
|
|
372
|
+
CodeReasonTrace,
|
|
373
|
+
ConduitThreadRef,
|
|
374
|
+
DecisionRef,
|
|
375
|
+
ImpactFullReport,
|
|
376
|
+
LbTaskRef,
|
|
377
|
+
NexusContext,
|
|
378
|
+
NexusEdgeRef,
|
|
379
|
+
NexusNodeAnchor,
|
|
380
|
+
PlasticityMeasure,
|
|
381
|
+
ProposalRef,
|
|
382
|
+
ReasonTraceStep,
|
|
383
|
+
RiskTier,
|
|
384
|
+
SymbolFullContext,
|
|
385
|
+
SymbolImpactEntry,
|
|
386
|
+
TaskCodeImpact,
|
|
387
|
+
TasksForNodeEntry,
|
|
388
|
+
} from './nexus-living-brain-ops.js';
|
|
389
|
+
// === Nexus Query DSL (recursive CTE operations) ===
|
|
390
|
+
export type {
|
|
391
|
+
NexusCteAlias,
|
|
392
|
+
NexusCteMarkdownTable,
|
|
393
|
+
NexusCteParams,
|
|
394
|
+
NexusCtePlaceholder,
|
|
395
|
+
NexusCteResult,
|
|
396
|
+
} from './nexus-query-ops.js';
|
|
397
|
+
// === Route Analysis and Contract Registry Types (T1064, T1065) ===
|
|
398
|
+
export type {
|
|
399
|
+
RouteMapEntry,
|
|
400
|
+
RouteMapResult,
|
|
401
|
+
ShapeCheckCaller,
|
|
402
|
+
ShapeCheckResult,
|
|
403
|
+
ShapeCheckStatus,
|
|
404
|
+
} from './nexus-route-ops.js';
|
|
405
|
+
export type {
|
|
406
|
+
GitLogLinkerResult,
|
|
407
|
+
LinkTaskResult,
|
|
408
|
+
SymbolReference,
|
|
409
|
+
TaskReference,
|
|
410
|
+
} from './nexus-tasks-bridge-ops.js';
|
|
411
|
+
export type {
|
|
412
|
+
CommunityWikiStats,
|
|
413
|
+
NexusWikiResult,
|
|
414
|
+
WikiSymbolRow,
|
|
415
|
+
} from './nexus-wiki-ops.js';
|
|
342
416
|
// === Operations Types (API wire format, namespaced to avoid collision with domain types) ===
|
|
343
417
|
export * as ops from './operations/index.js';
|
|
344
418
|
// Commonly used ops types re-exported at top level for convenience
|
|
@@ -352,6 +426,41 @@ export type {
|
|
|
352
426
|
ParamType,
|
|
353
427
|
} from './operations/params.js';
|
|
354
428
|
export { paramsToCittyArgs } from './operations/params.js';
|
|
429
|
+
// Session operation param/result types — re-exported at top level for typed-dispatch consumers
|
|
430
|
+
// (T975 Wave D · ADR-051 migration)
|
|
431
|
+
export type {
|
|
432
|
+
DecisionRecord,
|
|
433
|
+
SessionBriefingShowParams,
|
|
434
|
+
SessionBriefingShowResult,
|
|
435
|
+
SessionContextDriftParams,
|
|
436
|
+
SessionContextDriftResult,
|
|
437
|
+
SessionDecisionLogParams,
|
|
438
|
+
SessionDecisionLogResult,
|
|
439
|
+
SessionEndParams,
|
|
440
|
+
SessionEndResult,
|
|
441
|
+
SessionFindParams,
|
|
442
|
+
SessionFindResult,
|
|
443
|
+
SessionGcParams,
|
|
444
|
+
SessionGcResult,
|
|
445
|
+
SessionHandoffShowParams,
|
|
446
|
+
SessionHandoffShowResult,
|
|
447
|
+
SessionListParams,
|
|
448
|
+
SessionListResult,
|
|
449
|
+
SessionOps,
|
|
450
|
+
SessionRecordAssumptionParams,
|
|
451
|
+
SessionRecordAssumptionResult,
|
|
452
|
+
SessionRecordDecisionParams,
|
|
453
|
+
SessionRecordDecisionResult,
|
|
454
|
+
SessionResumeParams,
|
|
455
|
+
SessionResumeResult,
|
|
456
|
+
SessionShowParams,
|
|
457
|
+
SessionShowResult,
|
|
458
|
+
SessionStartParams,
|
|
459
|
+
SessionStatusParams,
|
|
460
|
+
SessionStatusResult,
|
|
461
|
+
SessionSuspendParams,
|
|
462
|
+
SessionSuspendResult,
|
|
463
|
+
} from './operations/session.js';
|
|
355
464
|
// === Orchestration Hierarchy ===
|
|
356
465
|
export {
|
|
357
466
|
type AgentHierarchy,
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract extraction and matching types for NEXUS cross-project compatibility.
|
|
3
|
+
*
|
|
4
|
+
* A contract represents a callable API (HTTP endpoint, gRPC service, pub/sub topic)
|
|
5
|
+
* that can be extracted from source code and matched with contracts from other projects
|
|
6
|
+
* to detect compatibility and integration points.
|
|
7
|
+
*
|
|
8
|
+
* @task T1065 — Contract Registry
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* HTTP contract extracted from route analysis.
|
|
13
|
+
*
|
|
14
|
+
* Represents a single HTTP endpoint with its path, method, and request/response schemas.
|
|
15
|
+
*/
|
|
16
|
+
export interface HttpContract {
|
|
17
|
+
/** Unique contract ID (format: `http:<projectId>::<path>::<method>`) */
|
|
18
|
+
id: string;
|
|
19
|
+
|
|
20
|
+
/** Project ID this contract belongs to */
|
|
21
|
+
projectId: string;
|
|
22
|
+
|
|
23
|
+
/** Contract type — always 'http' */
|
|
24
|
+
type: 'http';
|
|
25
|
+
|
|
26
|
+
/** HTTP method (GET, POST, PUT, DELETE, PATCH, etc.) */
|
|
27
|
+
method: string;
|
|
28
|
+
|
|
29
|
+
/** Route path (e.g., `/api/v1/tasks`) */
|
|
30
|
+
path: string;
|
|
31
|
+
|
|
32
|
+
/** Request body schema as JSON string (or '{}' if no body) */
|
|
33
|
+
requestSchemaJson: string;
|
|
34
|
+
|
|
35
|
+
/** Response body schema as JSON string */
|
|
36
|
+
responseSchemaJson: string;
|
|
37
|
+
|
|
38
|
+
/** Source symbol ID (format: `<filePath>::<functionName>`) */
|
|
39
|
+
sourceSymbolId: string;
|
|
40
|
+
|
|
41
|
+
/** Route node ID from NEXUS graph */
|
|
42
|
+
routeNodeId?: string;
|
|
43
|
+
|
|
44
|
+
/** Confidence of extraction [0..1] */
|
|
45
|
+
confidence: number;
|
|
46
|
+
|
|
47
|
+
/** Human-readable summary */
|
|
48
|
+
description?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* gRPC contract extracted from proto file analysis.
|
|
53
|
+
*
|
|
54
|
+
* Represents a single gRPC service method.
|
|
55
|
+
* Extraction may be minimal/stub on projects without .proto files.
|
|
56
|
+
*/
|
|
57
|
+
export interface GrpcContract {
|
|
58
|
+
/** Unique contract ID (format: `grpc:<projectId>::<serviceName>::<methodName>`) */
|
|
59
|
+
id: string;
|
|
60
|
+
|
|
61
|
+
/** Project ID this contract belongs to */
|
|
62
|
+
projectId: string;
|
|
63
|
+
|
|
64
|
+
/** Contract type — always 'grpc' */
|
|
65
|
+
type: 'grpc';
|
|
66
|
+
|
|
67
|
+
/** Service name (e.g., `TaskService`) */
|
|
68
|
+
serviceName: string;
|
|
69
|
+
|
|
70
|
+
/** Method name (e.g., `CreateTask`) */
|
|
71
|
+
methodName: string;
|
|
72
|
+
|
|
73
|
+
/** Request message type name */
|
|
74
|
+
requestMessageType: string;
|
|
75
|
+
|
|
76
|
+
/** Response message type name */
|
|
77
|
+
responseMessageType: string;
|
|
78
|
+
|
|
79
|
+
/** Request message schema as JSON string */
|
|
80
|
+
requestSchemaJson: string;
|
|
81
|
+
|
|
82
|
+
/** Response message schema as JSON string */
|
|
83
|
+
responseSchemaJson: string;
|
|
84
|
+
|
|
85
|
+
/** Source proto file path */
|
|
86
|
+
sourceProtoFile: string;
|
|
87
|
+
|
|
88
|
+
/** Confidence of extraction [0..1] */
|
|
89
|
+
confidence: number;
|
|
90
|
+
|
|
91
|
+
/** Human-readable summary */
|
|
92
|
+
description?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Topic/pub-sub contract extracted from message queue code patterns.
|
|
97
|
+
*
|
|
98
|
+
* Represents a single publish or subscribe to a message topic.
|
|
99
|
+
* Extraction may be minimal/stub on projects without pub/sub patterns.
|
|
100
|
+
*/
|
|
101
|
+
export interface TopicContract {
|
|
102
|
+
/** Unique contract ID (format: `topic:<projectId>::<topicName>::<direction>`) */
|
|
103
|
+
id: string;
|
|
104
|
+
|
|
105
|
+
/** Project ID this contract belongs to */
|
|
106
|
+
projectId: string;
|
|
107
|
+
|
|
108
|
+
/** Contract type — always 'topic' */
|
|
109
|
+
type: 'topic';
|
|
110
|
+
|
|
111
|
+
/** Topic name (e.g., `task.created`) */
|
|
112
|
+
topic: string;
|
|
113
|
+
|
|
114
|
+
/** Direction: 'publish' or 'subscribe' */
|
|
115
|
+
direction: 'publish' | 'subscribe';
|
|
116
|
+
|
|
117
|
+
/** Message payload schema as JSON string */
|
|
118
|
+
payloadSchemaJson: string;
|
|
119
|
+
|
|
120
|
+
/** Source symbol ID (format: `<filePath>::<functionName>`) */
|
|
121
|
+
sourceSymbolId: string;
|
|
122
|
+
|
|
123
|
+
/** Confidence of extraction [0..1] */
|
|
124
|
+
confidence: number;
|
|
125
|
+
|
|
126
|
+
/** Human-readable summary */
|
|
127
|
+
description?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Union type of all contract kinds */
|
|
131
|
+
export type Contract = HttpContract | GrpcContract | TopicContract;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Matching level for contract compatibility.
|
|
135
|
+
*
|
|
136
|
+
* - 'exact': path + method match exactly (HTTP) or full signature match (gRPC)
|
|
137
|
+
* - 'name': service/method names match but signatures may differ
|
|
138
|
+
* - 'fuzzy': BM25 similarity above threshold on path/schema content
|
|
139
|
+
*/
|
|
140
|
+
export type ContractMatchLevel = 'exact' | 'name' | 'fuzzy';
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Result of matching two contracts.
|
|
144
|
+
*
|
|
145
|
+
* Indicates compatibility between a contract in project A and project B.
|
|
146
|
+
*/
|
|
147
|
+
export interface ContractMatch {
|
|
148
|
+
/** Matched contract from project A */
|
|
149
|
+
contractA: Contract;
|
|
150
|
+
|
|
151
|
+
/** Matched contract from project B */
|
|
152
|
+
contractB: Contract;
|
|
153
|
+
|
|
154
|
+
/** Matching level (exact → name → fuzzy cascade) */
|
|
155
|
+
level: ContractMatchLevel;
|
|
156
|
+
|
|
157
|
+
/** Similarity score [0..1] where 1.0 is identical */
|
|
158
|
+
score: number;
|
|
159
|
+
|
|
160
|
+
/** Human-readable explanation of the match */
|
|
161
|
+
reason: string;
|
|
162
|
+
|
|
163
|
+
/** Compatibility verdict: 'compatible', 'incompatible', 'partial' */
|
|
164
|
+
compatibility: 'compatible' | 'incompatible' | 'partial';
|
|
165
|
+
|
|
166
|
+
/** Specific incompatibilities if any (e.g., schema mismatches) */
|
|
167
|
+
incompatibilities?: string[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Contract compatibility matrix between two projects.
|
|
172
|
+
*
|
|
173
|
+
* Result of `cleo nexus contracts show --project-a <p> --project-b <p>`.
|
|
174
|
+
*/
|
|
175
|
+
export interface ContractCompatibilityMatrix {
|
|
176
|
+
/** Project A ID */
|
|
177
|
+
projectAId: string;
|
|
178
|
+
|
|
179
|
+
/** Project B ID */
|
|
180
|
+
projectBId: string;
|
|
181
|
+
|
|
182
|
+
/** All matched contracts */
|
|
183
|
+
matches: ContractMatch[];
|
|
184
|
+
|
|
185
|
+
/** Count of compatible matches */
|
|
186
|
+
compatibleCount: number;
|
|
187
|
+
|
|
188
|
+
/** Count of incompatible matches */
|
|
189
|
+
incompatibleCount: number;
|
|
190
|
+
|
|
191
|
+
/** Count of partial/unresolved matches */
|
|
192
|
+
partialCount: number;
|
|
193
|
+
|
|
194
|
+
/** Overall compatibility percentage */
|
|
195
|
+
overallCompatibility: number;
|
|
196
|
+
|
|
197
|
+
/** Recommendations for integration */
|
|
198
|
+
recommendations: string[];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Result of extracting contracts from a project.
|
|
203
|
+
*
|
|
204
|
+
* Returned by contract extractors.
|
|
205
|
+
*/
|
|
206
|
+
export interface ContractExtractionResult {
|
|
207
|
+
/** Project ID */
|
|
208
|
+
projectId: string;
|
|
209
|
+
|
|
210
|
+
/** HTTP contracts found */
|
|
211
|
+
httpContracts: HttpContract[];
|
|
212
|
+
|
|
213
|
+
/** gRPC contracts found */
|
|
214
|
+
grpcContracts: GrpcContract[];
|
|
215
|
+
|
|
216
|
+
/** Topic/pub-sub contracts found */
|
|
217
|
+
topicContracts: TopicContract[];
|
|
218
|
+
|
|
219
|
+
/** Total contracts extracted */
|
|
220
|
+
totalCount: number;
|
|
221
|
+
|
|
222
|
+
/** Any extraction warnings or notes */
|
|
223
|
+
notes: string[];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Result of linking contracts to affected tasks.
|
|
228
|
+
*
|
|
229
|
+
* When a contract's source symbol is touched by a task (via task_touches_symbol edge),
|
|
230
|
+
* we emit a contract_affected_by_task annotation.
|
|
231
|
+
*/
|
|
232
|
+
export interface ContractTaskLink {
|
|
233
|
+
/** Contract ID */
|
|
234
|
+
contractId: string;
|
|
235
|
+
|
|
236
|
+
/** Task ID that affects this contract */
|
|
237
|
+
taskId: string;
|
|
238
|
+
|
|
239
|
+
/** Type of change (modified, added, removed) */
|
|
240
|
+
changeType: 'modified' | 'added' | 'removed';
|
|
241
|
+
|
|
242
|
+
/** Timestamp of the linkage */
|
|
243
|
+
linkedAt: string;
|
|
244
|
+
}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract types for the Living Brain SDK traversal primitives (T1068).
|
|
3
|
+
*
|
|
4
|
+
* The Living Brain is the cross-substrate query surface for the CLEO agent
|
|
5
|
+
* intelligence layer. It unifies five substrates — NEXUS (code graph),
|
|
6
|
+
* BRAIN (memory), TASKS, SENTIENT (proposals), and CONDUIT (messages) — into
|
|
7
|
+
* a single traversal API.
|
|
8
|
+
*
|
|
9
|
+
* These are LEAF types — zero runtime dependencies.
|
|
10
|
+
*
|
|
11
|
+
* @task T1068
|
|
12
|
+
* @epic T1042
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Sub-interfaces — each substrate's projection
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Caller or callee within the nexus code graph.
|
|
21
|
+
*/
|
|
22
|
+
export interface NexusEdgeRef {
|
|
23
|
+
/** Nexus node ID. */
|
|
24
|
+
nodeId: string;
|
|
25
|
+
/** Human-readable display name. */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Source file path (relative to project root). */
|
|
28
|
+
filePath: string | null;
|
|
29
|
+
/** Node kind ('function', 'class', 'method', etc.). */
|
|
30
|
+
kind: string;
|
|
31
|
+
/** Relation type ('calls', 'imports', 'accesses'). */
|
|
32
|
+
relationType: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Nexus context for a symbol: callers, callees, community, process membership.
|
|
37
|
+
*/
|
|
38
|
+
export interface NexusContext {
|
|
39
|
+
/** Symbol's own nexus node ID. */
|
|
40
|
+
symbolId: string;
|
|
41
|
+
/** Display label. */
|
|
42
|
+
label: string;
|
|
43
|
+
/** File path. */
|
|
44
|
+
filePath: string | null;
|
|
45
|
+
/** Node kind. */
|
|
46
|
+
kind: string;
|
|
47
|
+
/** Community ID this symbol belongs to (if any). */
|
|
48
|
+
communityId: string | null;
|
|
49
|
+
/** Nodes that call/import this symbol. */
|
|
50
|
+
callers: NexusEdgeRef[];
|
|
51
|
+
/** Nodes this symbol calls/imports. */
|
|
52
|
+
callees: NexusEdgeRef[];
|
|
53
|
+
/** Process nodes this symbol participates in. */
|
|
54
|
+
processes: string[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A brain memory node (observation, decision, pattern, learning) that
|
|
59
|
+
* references a code symbol via one of the cross-substrate edge types.
|
|
60
|
+
*/
|
|
61
|
+
export interface BrainMemoryRef {
|
|
62
|
+
/** Brain page node ID (e.g., 'observation:abc123'). */
|
|
63
|
+
nodeId: string;
|
|
64
|
+
/** Node type. */
|
|
65
|
+
nodeType: string;
|
|
66
|
+
/** Human-readable label for the memory entry. */
|
|
67
|
+
label: string;
|
|
68
|
+
/** Quality score of this memory entry (0.0–1.0). */
|
|
69
|
+
qualityScore: number;
|
|
70
|
+
/** Edge type used to connect this memory to the symbol. */
|
|
71
|
+
edgeType: string;
|
|
72
|
+
/** Edge weight. */
|
|
73
|
+
weight: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A task reference linking a task to a code symbol.
|
|
78
|
+
*/
|
|
79
|
+
export interface LbTaskRef {
|
|
80
|
+
/** Task ID (e.g., 'T001'). */
|
|
81
|
+
taskId: string;
|
|
82
|
+
/** Display label for the task. */
|
|
83
|
+
label: string;
|
|
84
|
+
/** Edge weight (confidence). */
|
|
85
|
+
weight: number;
|
|
86
|
+
/** Strategy used to detect the link. */
|
|
87
|
+
matchStrategy: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A sentient proposal entry referencing a code symbol.
|
|
92
|
+
*/
|
|
93
|
+
export interface ProposalRef {
|
|
94
|
+
/** Source system. */
|
|
95
|
+
source: string;
|
|
96
|
+
/** Source ID (nexus node ID for nexus proposals). */
|
|
97
|
+
sourceId: string;
|
|
98
|
+
/** Structured proposal title. */
|
|
99
|
+
title: string;
|
|
100
|
+
/** Proposal rationale. */
|
|
101
|
+
rationale: string;
|
|
102
|
+
/** Proposal weight in [0, 1]. */
|
|
103
|
+
weight: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* A conduit message thread that mentions a symbol.
|
|
108
|
+
*
|
|
109
|
+
* Returns empty array when conduit.db is absent (T1071 schema not yet present).
|
|
110
|
+
*/
|
|
111
|
+
export interface ConduitThreadRef {
|
|
112
|
+
/** Conduit message node ID (format: 'conduit:<id>'). */
|
|
113
|
+
nodeId: string;
|
|
114
|
+
/** Edge weight. */
|
|
115
|
+
weight: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Plasticity measurement for a symbol — aggregate edge weight from nexus_relations.
|
|
120
|
+
*/
|
|
121
|
+
export interface PlasticityMeasure {
|
|
122
|
+
/** Sum of edge weights across all nexus_relations involving this symbol. */
|
|
123
|
+
totalWeight: number;
|
|
124
|
+
/** Number of edges included in the sum. */
|
|
125
|
+
edgeCount: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
// Primary return shapes
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Full cross-substrate context for a code symbol.
|
|
134
|
+
*
|
|
135
|
+
* Returned by {@link getSymbolFullContext}.
|
|
136
|
+
*/
|
|
137
|
+
export interface SymbolFullContext {
|
|
138
|
+
/** Symbol identifier (nexus node ID or name). */
|
|
139
|
+
symbolId: string;
|
|
140
|
+
/** Nexus code graph context: callers, callees, community, process. */
|
|
141
|
+
nexus: NexusContext | null;
|
|
142
|
+
/** Brain memory nodes (observations, decisions, patterns, learnings) linked to this symbol. */
|
|
143
|
+
brainMemories: BrainMemoryRef[];
|
|
144
|
+
/** Tasks that touched files containing this symbol. */
|
|
145
|
+
tasks: LbTaskRef[];
|
|
146
|
+
/** Sentient proposals whose sourceId matches this symbol. */
|
|
147
|
+
sentientProposals: ProposalRef[];
|
|
148
|
+
/** Conduit message threads mentioning this symbol (empty if conduit.db absent). */
|
|
149
|
+
conduitThreads: ConduitThreadRef[];
|
|
150
|
+
/** Plasticity weight sum from nexus_relations. */
|
|
151
|
+
plasticityWeight: PlasticityMeasure;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Code impact analysis for a task.
|
|
156
|
+
*
|
|
157
|
+
* Returned by {@link getTaskCodeImpact}.
|
|
158
|
+
*/
|
|
159
|
+
export interface TaskCodeImpact {
|
|
160
|
+
/** Task ID. */
|
|
161
|
+
taskId: string;
|
|
162
|
+
/** Files listed in the task's files_json array. */
|
|
163
|
+
files: string[];
|
|
164
|
+
/** Symbols in those files (from NEXUS). */
|
|
165
|
+
symbols: SymbolImpactEntry[];
|
|
166
|
+
/** Aggregate blast radius across all symbols. */
|
|
167
|
+
blastRadius: BlastRadiusSummary;
|
|
168
|
+
/** Brain observations with modified_by edges to the task's files. */
|
|
169
|
+
brainObservations: BrainMemoryRef[];
|
|
170
|
+
/** Brain decisions linked to this task via brain_memory_links. */
|
|
171
|
+
decisions: DecisionRef[];
|
|
172
|
+
/** Highest risk tier across all symbols. */
|
|
173
|
+
riskScore: RiskTier;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Impact entry for a single symbol in a task's footprint.
|
|
178
|
+
*/
|
|
179
|
+
export interface SymbolImpactEntry {
|
|
180
|
+
/** Nexus node ID. */
|
|
181
|
+
nexusNodeId: string;
|
|
182
|
+
/** Display label. */
|
|
183
|
+
label: string;
|
|
184
|
+
/** Symbol kind. */
|
|
185
|
+
kind: string;
|
|
186
|
+
/** File path. */
|
|
187
|
+
filePath: string | null;
|
|
188
|
+
/** Risk tier from analyzeImpact BFS. */
|
|
189
|
+
riskLevel: RiskTier;
|
|
190
|
+
/** Total number of affected nodes in BFS. */
|
|
191
|
+
totalAffected: number;
|
|
192
|
+
/** Direct callers (d=1) count. */
|
|
193
|
+
directCallers: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Aggregate blast radius across all symbols in a task's footprint.
|
|
198
|
+
*/
|
|
199
|
+
export interface BlastRadiusSummary {
|
|
200
|
+
/** Total unique affected nodes across all symbols. */
|
|
201
|
+
totalAffected: number;
|
|
202
|
+
/** Maximum risk tier observed. */
|
|
203
|
+
maxRisk: RiskTier;
|
|
204
|
+
/** Number of symbols analyzed. */
|
|
205
|
+
symbolsAnalyzed: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* A brain decision linked to a task.
|
|
210
|
+
*/
|
|
211
|
+
export interface DecisionRef {
|
|
212
|
+
/** Decision ID. */
|
|
213
|
+
decisionId: string;
|
|
214
|
+
/** Decision text. */
|
|
215
|
+
decision: string;
|
|
216
|
+
/** Link type. */
|
|
217
|
+
linkType: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Risk tier for a symbol's impact analysis.
|
|
222
|
+
*/
|
|
223
|
+
export type RiskTier = 'NONE' | 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
224
|
+
|
|
225
|
+
// ---------------------------------------------------------------------------
|
|
226
|
+
// T1069 — Extended Code Reasoning types
|
|
227
|
+
// ---------------------------------------------------------------------------
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* A single step in a code reasoning trace chain.
|
|
231
|
+
*/
|
|
232
|
+
export interface ReasonTraceStep {
|
|
233
|
+
/** Step type discriminant. */
|
|
234
|
+
type: 'decision' | 'observation' | 'task' | 'symbol';
|
|
235
|
+
/** ID of this entry (brain ID, task ID, or nexus node ID). */
|
|
236
|
+
id: string;
|
|
237
|
+
/** Human-readable title or label for this entry. */
|
|
238
|
+
title: string;
|
|
239
|
+
/** References or related IDs (e.g., learning IDs for a decision step). */
|
|
240
|
+
refs: string[];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Full causal trace from a code symbol through brain decisions to tasks.
|
|
245
|
+
*
|
|
246
|
+
* Returned by {@link reasonWhySymbol}.
|
|
247
|
+
*/
|
|
248
|
+
export interface CodeReasonTrace {
|
|
249
|
+
/** The nexus symbol ID queried. */
|
|
250
|
+
symbolId: string;
|
|
251
|
+
/** Human-readable narrative summarizing the trace. */
|
|
252
|
+
narrative: string;
|
|
253
|
+
/** Ordered chain of trace steps from symbol to root context. */
|
|
254
|
+
chain: ReasonTraceStep[];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* A brain risk note associated with a symbol change.
|
|
259
|
+
*/
|
|
260
|
+
export interface BrainRiskNote {
|
|
261
|
+
/** Brain node ID. */
|
|
262
|
+
nodeId: string;
|
|
263
|
+
/** Node type (observation, decision, etc.). */
|
|
264
|
+
nodeType: string;
|
|
265
|
+
/** Human-readable label. */
|
|
266
|
+
label: string;
|
|
267
|
+
/** Edge type that connects this note to the symbol. */
|
|
268
|
+
edgeType: string;
|
|
269
|
+
/** Risk contribution weight. */
|
|
270
|
+
weight: number;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Full merged impact report for a code symbol.
|
|
275
|
+
*
|
|
276
|
+
* Returned by {@link reasonImpactOfChange}.
|
|
277
|
+
*/
|
|
278
|
+
export interface ImpactFullReport {
|
|
279
|
+
/** The nexus symbol ID analyzed. */
|
|
280
|
+
symbolId: string;
|
|
281
|
+
/** Structural blast radius from analyzeImpact BFS. */
|
|
282
|
+
structural: {
|
|
283
|
+
directCallers: number;
|
|
284
|
+
likelyAffected: number;
|
|
285
|
+
mayNeedTesting: number;
|
|
286
|
+
totalAffected: number;
|
|
287
|
+
riskLevel: RiskTier;
|
|
288
|
+
};
|
|
289
|
+
/** Open tasks that reference this symbol (from task_touches_symbol edges). */
|
|
290
|
+
openTasks: Array<{
|
|
291
|
+
taskId: string;
|
|
292
|
+
label: string;
|
|
293
|
+
weight: number;
|
|
294
|
+
}>;
|
|
295
|
+
/** Brain observations/decisions flagging risk for this symbol. */
|
|
296
|
+
brainRiskNotes: BrainRiskNote[];
|
|
297
|
+
/** Merged risk score (highest of structural, open-task count, brain notes). */
|
|
298
|
+
mergedRiskScore: RiskTier;
|
|
299
|
+
/** Human-readable narrative summarizing the combined risk. */
|
|
300
|
+
narrative: string;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Code anchor result for a brain memory entry.
|
|
305
|
+
*
|
|
306
|
+
* Returned by {@link getBrainEntryCodeAnchors}.
|
|
307
|
+
*/
|
|
308
|
+
export interface CodeAnchorResult {
|
|
309
|
+
/** Brain entry ID that was queried. */
|
|
310
|
+
entryId: string;
|
|
311
|
+
/** Nexus nodes linked to this brain entry via code-reference edges. */
|
|
312
|
+
nexusNodes: NexusNodeAnchor[];
|
|
313
|
+
/** For each nexus node, which tasks touched it. */
|
|
314
|
+
tasksForNodes: TasksForNodeEntry[];
|
|
315
|
+
/** Sum of weights on all edges anchoring this brain entry to code. */
|
|
316
|
+
plasticitySignal: number;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* A nexus node anchored to a brain entry.
|
|
321
|
+
*/
|
|
322
|
+
export interface NexusNodeAnchor {
|
|
323
|
+
/** Nexus node ID. */
|
|
324
|
+
nexusNodeId: string;
|
|
325
|
+
/** Display label. */
|
|
326
|
+
label: string;
|
|
327
|
+
/** File path. */
|
|
328
|
+
filePath: string | null;
|
|
329
|
+
/** Node kind. */
|
|
330
|
+
kind: string;
|
|
331
|
+
/** Edge type connecting this node to the brain entry. */
|
|
332
|
+
edgeType: string;
|
|
333
|
+
/** Edge weight. */
|
|
334
|
+
weight: number;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Tasks that touched a specific nexus node.
|
|
339
|
+
*/
|
|
340
|
+
export interface TasksForNodeEntry {
|
|
341
|
+
/** Nexus node ID. */
|
|
342
|
+
nexusNodeId: string;
|
|
343
|
+
/** Tasks that touched this node. */
|
|
344
|
+
tasks: LbTaskRef[];
|
|
345
|
+
}
|