@neat.is/core 0.6.4 → 0.7.0
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/{chunk-UCDXHLCJ.js → chunk-5RIL3U5A.js} +3687 -722
- package/dist/chunk-5RIL3U5A.js.map +1 -0
- package/dist/{chunk-ZLAZ7PLC.js → chunk-N5L3RBGP.js} +3 -2
- package/dist/{chunk-7QXN726V.js → chunk-Q6DPK3RA.js} +2 -2
- package/dist/chunk-UBQ4ZZT3.js +840 -0
- package/dist/chunk-UBQ4ZZT3.js.map +1 -0
- package/dist/cli.cjs +4596 -3449
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +263 -133
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +4143 -3129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +119 -106
- package/dist/index.d.ts +119 -106
- package/dist/index.js +4 -4
- package/dist/neatd.cjs +4153 -3139
- package/dist/neatd.cjs.map +1 -1
- package/dist/neatd.js +3 -3
- package/dist/{otel-grpc-WXKM7YBW.js → otel-grpc-ZNC2QED2.js} +3 -3
- package/dist/server.cjs +3563 -674
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +3 -3
- package/package.json +3 -2
- package/dist/chunk-22X2YM5H.js +0 -2810
- package/dist/chunk-22X2YM5H.js.map +0 -1
- package/dist/chunk-UCDXHLCJ.js.map +0 -1
- /package/dist/{chunk-ZLAZ7PLC.js.map → chunk-N5L3RBGP.js.map} +0 -0
- /package/dist/{chunk-7QXN726V.js.map → chunk-Q6DPK3RA.js.map} +0 -0
- /package/dist/{otel-grpc-WXKM7YBW.js.map → otel-grpc-ZNC2QED2.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MultiDirectedGraph } from 'graphology';
|
|
2
|
-
import { GraphNode, GraphEdge, StaleEvent, ErrorEvent, BlastRadiusResult, RootCauseResult,
|
|
2
|
+
import { GraphNode, GraphEdge, EdgeTypeValue, StaleEvent, ErrorEvent, BlastRadiusResult, RootCauseResult, RegistryEntry, RegistryStatus, RegistryFile } from '@neat.is/types';
|
|
3
3
|
export { StaleEvent } from '@neat.is/types';
|
|
4
4
|
import { FastifyInstance } from 'fastify';
|
|
5
5
|
|
|
@@ -110,6 +110,123 @@ declare class Projects {
|
|
|
110
110
|
attachSearchIndex(name: string, index: SearchIndex | undefined): void;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* A connector implements exactly one method. Everything downstream of
|
|
115
|
+
* `poll()` — resolving a static call site, minting the OBSERVED edge — is
|
|
116
|
+
* shared, generic code in connectors/index.ts.
|
|
117
|
+
*/
|
|
118
|
+
interface ObservedConnector {
|
|
119
|
+
readonly provider: string;
|
|
120
|
+
poll(ctx: ConnectorContext): Promise<ObservedSignal[]>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Everything a connector's `poll()` needs, resolved once at connector setup
|
|
124
|
+
* — never re-derived at poll time.
|
|
125
|
+
*
|
|
126
|
+
* `credentials` is opaque here on purpose: its shape is entirely provider-
|
|
127
|
+
* and profile-defined (local vs hosted — docs/contracts/connectors.md §3).
|
|
128
|
+
* It flows through to `poll()` only. Never log it, never write it into a
|
|
129
|
+
* node or edge, never let it reach the graph snapshot (contract §6, and the
|
|
130
|
+
* `.env`-contents rule docs/contracts.md Rule 4 already states for local
|
|
131
|
+
* config).
|
|
132
|
+
*/
|
|
133
|
+
interface ConnectorContext {
|
|
134
|
+
projectDir: string;
|
|
135
|
+
credentials: Record<string, unknown>;
|
|
136
|
+
since?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* `file:line` the provider's own signal carries, when it does (rare — see
|
|
140
|
+
* docs/connectors/README.md §Provider interface, which notes this is
|
|
141
|
+
* "usually resolved by the mapping layer below, not here"). Reconciled onto
|
|
142
|
+
* the EXTRACTED service-relative path by the shared fuse step the same way
|
|
143
|
+
* an OTel span's call site is (file-awareness.md §4).
|
|
144
|
+
*/
|
|
145
|
+
interface ConnectorCallSite {
|
|
146
|
+
file: string;
|
|
147
|
+
line: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* One provider-agnostic observation. `targetKind`/`targetName` are the
|
|
151
|
+
* provider's own vocabulary (`'supabase-table'`/`'orders'`,
|
|
152
|
+
* `'route'`/`'GET /users/:id'`, ...) — resolving that pair to a NEAT node id
|
|
153
|
+
* is the one genuinely provider-specific step (README.md's pipeline
|
|
154
|
+
* diagram), supplied to `runConnectorPoll` (connectors/index.ts) as a
|
|
155
|
+
* `resolveTarget` callback. Everything downstream of that resolution — file
|
|
156
|
+
* grain fusion, OBSERVED mint — is shared.
|
|
157
|
+
*/
|
|
158
|
+
interface ObservedSignal {
|
|
159
|
+
targetKind: string;
|
|
160
|
+
targetName: string;
|
|
161
|
+
callCount: number;
|
|
162
|
+
errorCount: number;
|
|
163
|
+
lastObservedIso: string;
|
|
164
|
+
callSite?: ConnectorCallSite;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* What a provider's target-resolution step hands back for one signal. The
|
|
169
|
+
* generic pipeline needs both endpoints of the edge it's about to mint:
|
|
170
|
+
*
|
|
171
|
+
* - `serviceName` is the NEAT manifest service whose code produced the
|
|
172
|
+
* signal — the edge's source. The shared pipeline turns it into a plain
|
|
173
|
+
* ServiceNode id, or a FileNode id once the fuse step below resolves the
|
|
174
|
+
* signal's callSite against it.
|
|
175
|
+
* - `targetNodeId` is the id the provider's own mapping already resolved —
|
|
176
|
+
* an `infraId(...)` sub-resource, a RouteNode, a ServiceNode, whatever
|
|
177
|
+
* (see each provider's docs/connectors/<provider>.md §Fusion).
|
|
178
|
+
*
|
|
179
|
+
* Returning `null` skips the signal honestly: an unresolvable target never
|
|
180
|
+
* fabricates a node or edge (the same discipline file-awareness.md §6
|
|
181
|
+
* states for OTel ingest).
|
|
182
|
+
*/
|
|
183
|
+
interface ResolvedConnectorTarget {
|
|
184
|
+
targetNodeId: string;
|
|
185
|
+
serviceName: string;
|
|
186
|
+
edgeType: EdgeTypeValue;
|
|
187
|
+
/**
|
|
188
|
+
* Set when `targetNodeId` names an InfraNode no static extractor has (yet)
|
|
189
|
+
* declared — the honest "observed but undeclared" fallback
|
|
190
|
+
* (docs/contracts/connectors.md §4a, ADR-133). A provider's `resolveTarget`
|
|
191
|
+
* has no mutation authority of its own (ADR-030), so it declares the need
|
|
192
|
+
* here instead of creating the node itself; the generic pipeline below
|
|
193
|
+
* calls `ensureInfraNode` before minting the edge. `targetNodeId` MUST equal
|
|
194
|
+
* `infraId(kind, name)` when this is set.
|
|
195
|
+
*/
|
|
196
|
+
ensureInfraNode?: {
|
|
197
|
+
kind: string;
|
|
198
|
+
name: string;
|
|
199
|
+
provider: string;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
type ResolveConnectorTarget = (signal: ObservedSignal, ctx: ConnectorContext) => ResolvedConnectorTarget | null;
|
|
203
|
+
interface ConnectorPollResult {
|
|
204
|
+
signalCount: number;
|
|
205
|
+
edgesCreated: number;
|
|
206
|
+
edgesUpdated: number;
|
|
207
|
+
unresolved: number;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* One poll cycle: fetch, map, fuse, mint. Pure with respect to `ctx` — the
|
|
211
|
+
* caller (`startConnectorPollLoop` below, or a one-shot `neat sync`) owns
|
|
212
|
+
* advancing `ctx.since` between calls.
|
|
213
|
+
*/
|
|
214
|
+
declare function runConnectorPoll(connector: ObservedConnector, ctx: ConnectorContext, graph: NeatGraph, resolveTarget: ResolveConnectorTarget): Promise<ConnectorPollResult>;
|
|
215
|
+
/**
|
|
216
|
+
* One project's registered connector, ready for `daemon.ts` to poll on an
|
|
217
|
+
* interval. Deliberately thin — no config-loading or credential-broker logic
|
|
218
|
+
* lives here (that's provider- and profile-specific, later work per
|
|
219
|
+
* docs/contracts/connectors.md §3); this is just the seam a daemon slot
|
|
220
|
+
* wires a connector through.
|
|
221
|
+
*/
|
|
222
|
+
interface ConnectorRegistration {
|
|
223
|
+
id?: string;
|
|
224
|
+
connector: ObservedConnector;
|
|
225
|
+
credentials: Record<string, unknown>;
|
|
226
|
+
resolveTarget: ResolveConnectorTarget;
|
|
227
|
+
intervalMs?: number;
|
|
228
|
+
}
|
|
229
|
+
|
|
113
230
|
interface BuildApiOptions {
|
|
114
231
|
projects?: Projects;
|
|
115
232
|
startedAt?: number;
|
|
@@ -134,6 +251,7 @@ interface BuildApiOptions {
|
|
|
134
251
|
path: string;
|
|
135
252
|
};
|
|
136
253
|
connectorsHome?: string;
|
|
254
|
+
runPoll?: typeof runConnectorPoll;
|
|
137
255
|
}
|
|
138
256
|
declare function buildApi(opts: BuildApiOptions): Promise<FastifyInstance>;
|
|
139
257
|
|
|
@@ -349,111 +467,6 @@ interface GraphDiff {
|
|
|
349
467
|
declare function loadSnapshotForDiff(target: string): Promise<PersistedSnapshot>;
|
|
350
468
|
declare function computeGraphDiff(liveGraph: NeatGraph, baseSnapshot: PersistedSnapshot, currentExportedAt?: string): GraphDiff;
|
|
351
469
|
|
|
352
|
-
/**
|
|
353
|
-
* A connector implements exactly one method. Everything downstream of
|
|
354
|
-
* `poll()` — resolving a static call site, minting the OBSERVED edge — is
|
|
355
|
-
* shared, generic code in connectors/index.ts.
|
|
356
|
-
*/
|
|
357
|
-
interface ObservedConnector {
|
|
358
|
-
readonly provider: string;
|
|
359
|
-
poll(ctx: ConnectorContext): Promise<ObservedSignal[]>;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Everything a connector's `poll()` needs, resolved once at connector setup
|
|
363
|
-
* — never re-derived at poll time.
|
|
364
|
-
*
|
|
365
|
-
* `credentials` is opaque here on purpose: its shape is entirely provider-
|
|
366
|
-
* and profile-defined (local vs hosted — docs/contracts/connectors.md §3).
|
|
367
|
-
* It flows through to `poll()` only. Never log it, never write it into a
|
|
368
|
-
* node or edge, never let it reach the graph snapshot (contract §6, and the
|
|
369
|
-
* `.env`-contents rule docs/contracts.md Rule 4 already states for local
|
|
370
|
-
* config).
|
|
371
|
-
*/
|
|
372
|
-
interface ConnectorContext {
|
|
373
|
-
projectDir: string;
|
|
374
|
-
credentials: Record<string, unknown>;
|
|
375
|
-
since?: string;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* `file:line` the provider's own signal carries, when it does (rare — see
|
|
379
|
-
* docs/connectors/README.md §Provider interface, which notes this is
|
|
380
|
-
* "usually resolved by the mapping layer below, not here"). Reconciled onto
|
|
381
|
-
* the EXTRACTED service-relative path by the shared fuse step the same way
|
|
382
|
-
* an OTel span's call site is (file-awareness.md §4).
|
|
383
|
-
*/
|
|
384
|
-
interface ConnectorCallSite {
|
|
385
|
-
file: string;
|
|
386
|
-
line: number;
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* One provider-agnostic observation. `targetKind`/`targetName` are the
|
|
390
|
-
* provider's own vocabulary (`'supabase-table'`/`'orders'`,
|
|
391
|
-
* `'route'`/`'GET /users/:id'`, ...) — resolving that pair to a NEAT node id
|
|
392
|
-
* is the one genuinely provider-specific step (README.md's pipeline
|
|
393
|
-
* diagram), supplied to `runConnectorPoll` (connectors/index.ts) as a
|
|
394
|
-
* `resolveTarget` callback. Everything downstream of that resolution — file
|
|
395
|
-
* grain fusion, OBSERVED mint — is shared.
|
|
396
|
-
*/
|
|
397
|
-
interface ObservedSignal {
|
|
398
|
-
targetKind: string;
|
|
399
|
-
targetName: string;
|
|
400
|
-
callCount: number;
|
|
401
|
-
errorCount: number;
|
|
402
|
-
lastObservedIso: string;
|
|
403
|
-
callSite?: ConnectorCallSite;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* What a provider's target-resolution step hands back for one signal. The
|
|
408
|
-
* generic pipeline needs both endpoints of the edge it's about to mint:
|
|
409
|
-
*
|
|
410
|
-
* - `serviceName` is the NEAT manifest service whose code produced the
|
|
411
|
-
* signal — the edge's source. The shared pipeline turns it into a plain
|
|
412
|
-
* ServiceNode id, or a FileNode id once the fuse step below resolves the
|
|
413
|
-
* signal's callSite against it.
|
|
414
|
-
* - `targetNodeId` is the id the provider's own mapping already resolved —
|
|
415
|
-
* an `infraId(...)` sub-resource, a RouteNode, a ServiceNode, whatever
|
|
416
|
-
* (see each provider's docs/connectors/<provider>.md §Fusion).
|
|
417
|
-
*
|
|
418
|
-
* Returning `null` skips the signal honestly: an unresolvable target never
|
|
419
|
-
* fabricates a node or edge (the same discipline file-awareness.md §6
|
|
420
|
-
* states for OTel ingest).
|
|
421
|
-
*/
|
|
422
|
-
interface ResolvedConnectorTarget {
|
|
423
|
-
targetNodeId: string;
|
|
424
|
-
serviceName: string;
|
|
425
|
-
edgeType: EdgeTypeValue;
|
|
426
|
-
/**
|
|
427
|
-
* Set when `targetNodeId` names an InfraNode no static extractor has (yet)
|
|
428
|
-
* declared — the honest "observed but undeclared" fallback
|
|
429
|
-
* (docs/contracts/connectors.md §4a, ADR-133). A provider's `resolveTarget`
|
|
430
|
-
* has no mutation authority of its own (ADR-030), so it declares the need
|
|
431
|
-
* here instead of creating the node itself; the generic pipeline below
|
|
432
|
-
* calls `ensureInfraNode` before minting the edge. `targetNodeId` MUST equal
|
|
433
|
-
* `infraId(kind, name)` when this is set.
|
|
434
|
-
*/
|
|
435
|
-
ensureInfraNode?: {
|
|
436
|
-
kind: string;
|
|
437
|
-
name: string;
|
|
438
|
-
provider: string;
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
|
-
type ResolveConnectorTarget = (signal: ObservedSignal, ctx: ConnectorContext) => ResolvedConnectorTarget | null;
|
|
442
|
-
/**
|
|
443
|
-
* One project's registered connector, ready for `daemon.ts` to poll on an
|
|
444
|
-
* interval. Deliberately thin — no config-loading or credential-broker logic
|
|
445
|
-
* lives here (that's provider- and profile-specific, later work per
|
|
446
|
-
* docs/contracts/connectors.md §3); this is just the seam a daemon slot
|
|
447
|
-
* wires a connector through.
|
|
448
|
-
*/
|
|
449
|
-
interface ConnectorRegistration {
|
|
450
|
-
id?: string;
|
|
451
|
-
connector: ObservedConnector;
|
|
452
|
-
credentials: Record<string, unknown>;
|
|
453
|
-
resolveTarget: ResolveConnectorTarget;
|
|
454
|
-
intervalMs?: number;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
470
|
/**
|
|
458
471
|
* Multi-project daemon (ADR-049).
|
|
459
472
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MultiDirectedGraph } from 'graphology';
|
|
2
|
-
import { GraphNode, GraphEdge, StaleEvent, ErrorEvent, BlastRadiusResult, RootCauseResult,
|
|
2
|
+
import { GraphNode, GraphEdge, EdgeTypeValue, StaleEvent, ErrorEvent, BlastRadiusResult, RootCauseResult, RegistryEntry, RegistryStatus, RegistryFile } from '@neat.is/types';
|
|
3
3
|
export { StaleEvent } from '@neat.is/types';
|
|
4
4
|
import { FastifyInstance } from 'fastify';
|
|
5
5
|
|
|
@@ -110,6 +110,123 @@ declare class Projects {
|
|
|
110
110
|
attachSearchIndex(name: string, index: SearchIndex | undefined): void;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* A connector implements exactly one method. Everything downstream of
|
|
115
|
+
* `poll()` — resolving a static call site, minting the OBSERVED edge — is
|
|
116
|
+
* shared, generic code in connectors/index.ts.
|
|
117
|
+
*/
|
|
118
|
+
interface ObservedConnector {
|
|
119
|
+
readonly provider: string;
|
|
120
|
+
poll(ctx: ConnectorContext): Promise<ObservedSignal[]>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Everything a connector's `poll()` needs, resolved once at connector setup
|
|
124
|
+
* — never re-derived at poll time.
|
|
125
|
+
*
|
|
126
|
+
* `credentials` is opaque here on purpose: its shape is entirely provider-
|
|
127
|
+
* and profile-defined (local vs hosted — docs/contracts/connectors.md §3).
|
|
128
|
+
* It flows through to `poll()` only. Never log it, never write it into a
|
|
129
|
+
* node or edge, never let it reach the graph snapshot (contract §6, and the
|
|
130
|
+
* `.env`-contents rule docs/contracts.md Rule 4 already states for local
|
|
131
|
+
* config).
|
|
132
|
+
*/
|
|
133
|
+
interface ConnectorContext {
|
|
134
|
+
projectDir: string;
|
|
135
|
+
credentials: Record<string, unknown>;
|
|
136
|
+
since?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* `file:line` the provider's own signal carries, when it does (rare — see
|
|
140
|
+
* docs/connectors/README.md §Provider interface, which notes this is
|
|
141
|
+
* "usually resolved by the mapping layer below, not here"). Reconciled onto
|
|
142
|
+
* the EXTRACTED service-relative path by the shared fuse step the same way
|
|
143
|
+
* an OTel span's call site is (file-awareness.md §4).
|
|
144
|
+
*/
|
|
145
|
+
interface ConnectorCallSite {
|
|
146
|
+
file: string;
|
|
147
|
+
line: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* One provider-agnostic observation. `targetKind`/`targetName` are the
|
|
151
|
+
* provider's own vocabulary (`'supabase-table'`/`'orders'`,
|
|
152
|
+
* `'route'`/`'GET /users/:id'`, ...) — resolving that pair to a NEAT node id
|
|
153
|
+
* is the one genuinely provider-specific step (README.md's pipeline
|
|
154
|
+
* diagram), supplied to `runConnectorPoll` (connectors/index.ts) as a
|
|
155
|
+
* `resolveTarget` callback. Everything downstream of that resolution — file
|
|
156
|
+
* grain fusion, OBSERVED mint — is shared.
|
|
157
|
+
*/
|
|
158
|
+
interface ObservedSignal {
|
|
159
|
+
targetKind: string;
|
|
160
|
+
targetName: string;
|
|
161
|
+
callCount: number;
|
|
162
|
+
errorCount: number;
|
|
163
|
+
lastObservedIso: string;
|
|
164
|
+
callSite?: ConnectorCallSite;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* What a provider's target-resolution step hands back for one signal. The
|
|
169
|
+
* generic pipeline needs both endpoints of the edge it's about to mint:
|
|
170
|
+
*
|
|
171
|
+
* - `serviceName` is the NEAT manifest service whose code produced the
|
|
172
|
+
* signal — the edge's source. The shared pipeline turns it into a plain
|
|
173
|
+
* ServiceNode id, or a FileNode id once the fuse step below resolves the
|
|
174
|
+
* signal's callSite against it.
|
|
175
|
+
* - `targetNodeId` is the id the provider's own mapping already resolved —
|
|
176
|
+
* an `infraId(...)` sub-resource, a RouteNode, a ServiceNode, whatever
|
|
177
|
+
* (see each provider's docs/connectors/<provider>.md §Fusion).
|
|
178
|
+
*
|
|
179
|
+
* Returning `null` skips the signal honestly: an unresolvable target never
|
|
180
|
+
* fabricates a node or edge (the same discipline file-awareness.md §6
|
|
181
|
+
* states for OTel ingest).
|
|
182
|
+
*/
|
|
183
|
+
interface ResolvedConnectorTarget {
|
|
184
|
+
targetNodeId: string;
|
|
185
|
+
serviceName: string;
|
|
186
|
+
edgeType: EdgeTypeValue;
|
|
187
|
+
/**
|
|
188
|
+
* Set when `targetNodeId` names an InfraNode no static extractor has (yet)
|
|
189
|
+
* declared — the honest "observed but undeclared" fallback
|
|
190
|
+
* (docs/contracts/connectors.md §4a, ADR-133). A provider's `resolveTarget`
|
|
191
|
+
* has no mutation authority of its own (ADR-030), so it declares the need
|
|
192
|
+
* here instead of creating the node itself; the generic pipeline below
|
|
193
|
+
* calls `ensureInfraNode` before minting the edge. `targetNodeId` MUST equal
|
|
194
|
+
* `infraId(kind, name)` when this is set.
|
|
195
|
+
*/
|
|
196
|
+
ensureInfraNode?: {
|
|
197
|
+
kind: string;
|
|
198
|
+
name: string;
|
|
199
|
+
provider: string;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
type ResolveConnectorTarget = (signal: ObservedSignal, ctx: ConnectorContext) => ResolvedConnectorTarget | null;
|
|
203
|
+
interface ConnectorPollResult {
|
|
204
|
+
signalCount: number;
|
|
205
|
+
edgesCreated: number;
|
|
206
|
+
edgesUpdated: number;
|
|
207
|
+
unresolved: number;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* One poll cycle: fetch, map, fuse, mint. Pure with respect to `ctx` — the
|
|
211
|
+
* caller (`startConnectorPollLoop` below, or a one-shot `neat sync`) owns
|
|
212
|
+
* advancing `ctx.since` between calls.
|
|
213
|
+
*/
|
|
214
|
+
declare function runConnectorPoll(connector: ObservedConnector, ctx: ConnectorContext, graph: NeatGraph, resolveTarget: ResolveConnectorTarget): Promise<ConnectorPollResult>;
|
|
215
|
+
/**
|
|
216
|
+
* One project's registered connector, ready for `daemon.ts` to poll on an
|
|
217
|
+
* interval. Deliberately thin — no config-loading or credential-broker logic
|
|
218
|
+
* lives here (that's provider- and profile-specific, later work per
|
|
219
|
+
* docs/contracts/connectors.md §3); this is just the seam a daemon slot
|
|
220
|
+
* wires a connector through.
|
|
221
|
+
*/
|
|
222
|
+
interface ConnectorRegistration {
|
|
223
|
+
id?: string;
|
|
224
|
+
connector: ObservedConnector;
|
|
225
|
+
credentials: Record<string, unknown>;
|
|
226
|
+
resolveTarget: ResolveConnectorTarget;
|
|
227
|
+
intervalMs?: number;
|
|
228
|
+
}
|
|
229
|
+
|
|
113
230
|
interface BuildApiOptions {
|
|
114
231
|
projects?: Projects;
|
|
115
232
|
startedAt?: number;
|
|
@@ -134,6 +251,7 @@ interface BuildApiOptions {
|
|
|
134
251
|
path: string;
|
|
135
252
|
};
|
|
136
253
|
connectorsHome?: string;
|
|
254
|
+
runPoll?: typeof runConnectorPoll;
|
|
137
255
|
}
|
|
138
256
|
declare function buildApi(opts: BuildApiOptions): Promise<FastifyInstance>;
|
|
139
257
|
|
|
@@ -349,111 +467,6 @@ interface GraphDiff {
|
|
|
349
467
|
declare function loadSnapshotForDiff(target: string): Promise<PersistedSnapshot>;
|
|
350
468
|
declare function computeGraphDiff(liveGraph: NeatGraph, baseSnapshot: PersistedSnapshot, currentExportedAt?: string): GraphDiff;
|
|
351
469
|
|
|
352
|
-
/**
|
|
353
|
-
* A connector implements exactly one method. Everything downstream of
|
|
354
|
-
* `poll()` — resolving a static call site, minting the OBSERVED edge — is
|
|
355
|
-
* shared, generic code in connectors/index.ts.
|
|
356
|
-
*/
|
|
357
|
-
interface ObservedConnector {
|
|
358
|
-
readonly provider: string;
|
|
359
|
-
poll(ctx: ConnectorContext): Promise<ObservedSignal[]>;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Everything a connector's `poll()` needs, resolved once at connector setup
|
|
363
|
-
* — never re-derived at poll time.
|
|
364
|
-
*
|
|
365
|
-
* `credentials` is opaque here on purpose: its shape is entirely provider-
|
|
366
|
-
* and profile-defined (local vs hosted — docs/contracts/connectors.md §3).
|
|
367
|
-
* It flows through to `poll()` only. Never log it, never write it into a
|
|
368
|
-
* node or edge, never let it reach the graph snapshot (contract §6, and the
|
|
369
|
-
* `.env`-contents rule docs/contracts.md Rule 4 already states for local
|
|
370
|
-
* config).
|
|
371
|
-
*/
|
|
372
|
-
interface ConnectorContext {
|
|
373
|
-
projectDir: string;
|
|
374
|
-
credentials: Record<string, unknown>;
|
|
375
|
-
since?: string;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* `file:line` the provider's own signal carries, when it does (rare — see
|
|
379
|
-
* docs/connectors/README.md §Provider interface, which notes this is
|
|
380
|
-
* "usually resolved by the mapping layer below, not here"). Reconciled onto
|
|
381
|
-
* the EXTRACTED service-relative path by the shared fuse step the same way
|
|
382
|
-
* an OTel span's call site is (file-awareness.md §4).
|
|
383
|
-
*/
|
|
384
|
-
interface ConnectorCallSite {
|
|
385
|
-
file: string;
|
|
386
|
-
line: number;
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* One provider-agnostic observation. `targetKind`/`targetName` are the
|
|
390
|
-
* provider's own vocabulary (`'supabase-table'`/`'orders'`,
|
|
391
|
-
* `'route'`/`'GET /users/:id'`, ...) — resolving that pair to a NEAT node id
|
|
392
|
-
* is the one genuinely provider-specific step (README.md's pipeline
|
|
393
|
-
* diagram), supplied to `runConnectorPoll` (connectors/index.ts) as a
|
|
394
|
-
* `resolveTarget` callback. Everything downstream of that resolution — file
|
|
395
|
-
* grain fusion, OBSERVED mint — is shared.
|
|
396
|
-
*/
|
|
397
|
-
interface ObservedSignal {
|
|
398
|
-
targetKind: string;
|
|
399
|
-
targetName: string;
|
|
400
|
-
callCount: number;
|
|
401
|
-
errorCount: number;
|
|
402
|
-
lastObservedIso: string;
|
|
403
|
-
callSite?: ConnectorCallSite;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* What a provider's target-resolution step hands back for one signal. The
|
|
408
|
-
* generic pipeline needs both endpoints of the edge it's about to mint:
|
|
409
|
-
*
|
|
410
|
-
* - `serviceName` is the NEAT manifest service whose code produced the
|
|
411
|
-
* signal — the edge's source. The shared pipeline turns it into a plain
|
|
412
|
-
* ServiceNode id, or a FileNode id once the fuse step below resolves the
|
|
413
|
-
* signal's callSite against it.
|
|
414
|
-
* - `targetNodeId` is the id the provider's own mapping already resolved —
|
|
415
|
-
* an `infraId(...)` sub-resource, a RouteNode, a ServiceNode, whatever
|
|
416
|
-
* (see each provider's docs/connectors/<provider>.md §Fusion).
|
|
417
|
-
*
|
|
418
|
-
* Returning `null` skips the signal honestly: an unresolvable target never
|
|
419
|
-
* fabricates a node or edge (the same discipline file-awareness.md §6
|
|
420
|
-
* states for OTel ingest).
|
|
421
|
-
*/
|
|
422
|
-
interface ResolvedConnectorTarget {
|
|
423
|
-
targetNodeId: string;
|
|
424
|
-
serviceName: string;
|
|
425
|
-
edgeType: EdgeTypeValue;
|
|
426
|
-
/**
|
|
427
|
-
* Set when `targetNodeId` names an InfraNode no static extractor has (yet)
|
|
428
|
-
* declared — the honest "observed but undeclared" fallback
|
|
429
|
-
* (docs/contracts/connectors.md §4a, ADR-133). A provider's `resolveTarget`
|
|
430
|
-
* has no mutation authority of its own (ADR-030), so it declares the need
|
|
431
|
-
* here instead of creating the node itself; the generic pipeline below
|
|
432
|
-
* calls `ensureInfraNode` before minting the edge. `targetNodeId` MUST equal
|
|
433
|
-
* `infraId(kind, name)` when this is set.
|
|
434
|
-
*/
|
|
435
|
-
ensureInfraNode?: {
|
|
436
|
-
kind: string;
|
|
437
|
-
name: string;
|
|
438
|
-
provider: string;
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
|
-
type ResolveConnectorTarget = (signal: ObservedSignal, ctx: ConnectorContext) => ResolvedConnectorTarget | null;
|
|
442
|
-
/**
|
|
443
|
-
* One project's registered connector, ready for `daemon.ts` to poll on an
|
|
444
|
-
* interval. Deliberately thin — no config-loading or credential-broker logic
|
|
445
|
-
* lives here (that's provider- and profile-specific, later work per
|
|
446
|
-
* docs/contracts/connectors.md §3); this is just the seam a daemon slot
|
|
447
|
-
* wires a connector through.
|
|
448
|
-
*/
|
|
449
|
-
interface ConnectorRegistration {
|
|
450
|
-
id?: string;
|
|
451
|
-
connector: ObservedConnector;
|
|
452
|
-
credentials: Record<string, unknown>;
|
|
453
|
-
resolveTarget: ResolveConnectorTarget;
|
|
454
|
-
intervalMs?: number;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
470
|
/**
|
|
458
471
|
* Multi-project daemon (ADR-049).
|
|
459
472
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
routeSpanToProject,
|
|
3
3
|
startDaemon
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UBQ4ZZT3.js";
|
|
5
5
|
import {
|
|
6
6
|
ProjectNameCollisionError,
|
|
7
7
|
addProject,
|
|
@@ -37,15 +37,15 @@ import {
|
|
|
37
37
|
thresholdForEdgeType,
|
|
38
38
|
touchLastSeen,
|
|
39
39
|
writeAtomically
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-5RIL3U5A.js";
|
|
41
41
|
import {
|
|
42
42
|
startOtelGrpcReceiver
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-Q6DPK3RA.js";
|
|
44
44
|
import {
|
|
45
45
|
buildOtelReceiver,
|
|
46
46
|
logSpanHandler,
|
|
47
47
|
parseOtlpRequest
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-N5L3RBGP.js";
|
|
49
49
|
export {
|
|
50
50
|
ProjectNameCollisionError,
|
|
51
51
|
addProject,
|