archctx-contracts 0.17.1 → 0.18.1
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/fixtures/valid/archctx-capabilities.json +2 -2
- package/fixtures/valid/product-version-manifest.json +4 -10
- package/package.json +4 -1
- package/schemas/repo/refactor-decision.schema.json +307 -37
- package/schemas/runtime/archctx-capabilities.schema.json +144 -20
- package/schemas/runtime/architecture-debt-delta.schema.json +58 -19
- package/schemas/runtime/architecture-debt.schema.json +42 -42
- package/schemas/runtime/architecture-event.schema.json +1 -1
- package/schemas/runtime/architecture-history.schema.json +354 -0
- package/schemas/runtime/capability-dependencies.schema.json +266 -59
- package/schemas/runtime/cli-check.schema.json +209 -0
- package/schemas/runtime/cli-help.schema.json +28 -0
- package/schemas/runtime/dependency-constraint-evaluation.schema.json +67 -68
- package/schemas/runtime/docs-anchors.schema.json +262 -67
- package/schemas/runtime/doctor-code-facts.schema.json +49 -0
- package/schemas/runtime/evidence-binding.schema.json +1 -1
- package/schemas/runtime/flow-selector-check.schema.json +179 -46
- package/schemas/runtime/hook-debt-checkpoint.schema.json +12 -12
- package/schemas/runtime/index-seed.schema.json +56 -0
- package/schemas/runtime/path-context.schema.json +120 -0
- package/schemas/runtime/product-version-manifest.schema.json +142 -54
- package/schemas/runtime/projection-slice.schema.json +34 -34
- package/schemas/runtime/recommendation-v3.schema.json +372 -1
- package/schemas/runtime/ref-impact-batch-request.schema.json +20 -7
- package/schemas/runtime/ref-impact-batch.schema.json +83 -13
- package/schemas/runtime/ref-impact.schema.json +68 -61
- package/schemas/runtime/refactor-scan-v2.schema.json +1392 -0
- package/schemas/runtime/refactor-simulate.schema.json +553 -0
- package/schemas/runtime/refactor-verify-v2.schema.json +172 -0
- package/schemas/runtime/resolve-path.schema.json +69 -0
- package/schemas/runtime/runtime-recommendation-show.schema.json +531 -2
- package/schemas/runtime/runtime-refactor-scan.schema.json +498 -2
- package/schemas/runtime/runtime-verify.schema.json +274 -56
- package/schemas/runtime/state-machine-check.schema.json +357 -89
- package/schemas/runtime/structural-observation-payload.schema.json +372 -1
- package/schemas/runtime/sync-check.schema.json +77 -0
- package/src/architecture-debt.ts +125 -38
- package/src/architecture-history.ts +168 -42
- package/src/architecture.ts +100 -0
- package/src/cli-read.ts +228 -0
- package/src/docs-anchors.ts +105 -50
- package/src/explorer-occurrence-ports.ts +175 -0
- package/src/explorer-query-ports.ts +270 -0
- package/src/failure.ts +4 -0
- package/src/index-seed.ts +42 -0
- package/src/index.ts +5 -0
- package/src/ledger-records.ts +262 -0
- package/src/ledger.ts +27 -566
- package/src/ownership-dependencies.ts +115 -5
- package/src/ports.ts +6 -541
- package/src/product-version.ts +74 -55
- package/src/projection-apply-types.ts +216 -0
- package/src/projection-apply-validators.ts +355 -0
- package/src/projection-capabilities.ts +181 -0
- package/src/projection-constants.ts +317 -0
- package/src/projection-manifest-types.ts +298 -0
- package/src/projection-manifest.ts +12 -299
- package/src/projection-recovery-validators.ts +229 -0
- package/src/projection-request-validators.ts +326 -0
- package/src/projection-types.ts +365 -0
- package/src/projection-validation-helpers.ts +15 -0
- package/src/projection.ts +7 -1689
- package/src/ref-impact.ts +225 -33
- package/src/refactor-constants.ts +213 -0
- package/src/refactor-decision-validators.ts +351 -0
- package/src/refactor-evidence-types.ts +286 -0
- package/src/refactor-observation-validators.ts +359 -0
- package/src/refactor-resolution-validators.ts +229 -0
- package/src/refactor-snapshot-validators.ts +368 -0
- package/src/refactor-types.ts +270 -0
- package/src/refactor-v2.ts +554 -0
- package/src/refactor-validation-helpers.ts +199 -0
- package/src/refactor.ts +7 -1849
- package/src/review-guards.ts +3 -23
- package/src/runtime-verify.ts +87 -0
- package/src/schema-kit.ts +187 -0
- package/src/schema-registry.ts +73 -0
- package/src/schema.ts +15 -4
- package/src/state-machine-schemas.ts +192 -0
- package/src/state-machine-types.ts +188 -0
- package/src/state-machine.ts +9 -189
- package/fixtures/boundary/agent-job-expired.json +0 -33
- package/fixtures/invalid/adapter-fidelity-reverse-sync.json +0 -9
- package/fixtures/invalid/agent-job-direct-mutation.json +0 -32
- package/fixtures/invalid/cloud-egress-envelope-private-field.json +0 -12
- package/fixtures/invalid/investigation-report-direct-mutation.json +0 -38
- package/fixtures/invalid/investigation-report-missing-proposed-delta.json +0 -19
- package/fixtures/invalid/notification-event-code-field.json +0 -11
- package/fixtures/valid/adapter-fidelity.json +0 -9
- package/fixtures/valid/agent-job.json +0 -33
- package/fixtures/valid/architecture-candidate-delta-policy.json +0 -45
- package/fixtures/valid/architecture-candidate-delta.json +0 -188
- package/fixtures/valid/chatgpt-ga-tool.json +0 -9
- package/fixtures/valid/cloud-egress-envelope.json +0 -11
- package/fixtures/valid/entitlement.json +0 -12
- package/fixtures/valid/investigation-report.json +0 -38
- package/fixtures/valid/likec4-mapping.json +0 -14
- package/fixtures/valid/notification-event.json +0 -10
- package/fixtures/valid/notification-provider.json +0 -12
- package/fixtures/valid/structurizr-mapping.json +0 -15
- package/schemas/cloud/cloud-egress-envelope.schema.json +0 -19
- package/schemas/cloud/entitlement.schema.json +0 -24
- package/schemas/integrations/adapter-fidelity.schema.json +0 -21
- package/schemas/integrations/chatgpt-ga-tool.schema.json +0 -25
- package/schemas/integrations/likec4-mapping.schema.json +0 -32
- package/schemas/integrations/structurizr-mapping.schema.json +0 -33
- package/schemas/runtime/agent-job.schema.json +0 -63
- package/schemas/runtime/architecture-candidate-delta-policy.schema.json +0 -129
- package/schemas/runtime/architecture-candidate-delta.schema.json +0 -386
- package/schemas/runtime/investigation-report.schema.json +0 -119
- package/schemas/runtime/notification-event.schema.json +0 -18
- package/schemas/runtime/notification-provider.schema.json +0 -26
package/src/ports.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ArchitectureWorktreeIdentityV1,
|
|
7
|
-
InvestigationReportV1
|
|
8
|
-
} from "./ledger";
|
|
1
|
+
import { isRepoRelativePosixPath, type Json } from "./schema";
|
|
2
|
+
import type { SourceSelector } from "./explorer-query-ports";
|
|
3
|
+
|
|
4
|
+
export * from "./explorer-query-ports";
|
|
5
|
+
export * from "./explorer-occurrence-ports";
|
|
9
6
|
|
|
10
7
|
export interface WorkspaceRef {
|
|
11
8
|
root: string;
|
|
@@ -128,13 +125,6 @@ export interface SymbolQuery {
|
|
|
128
125
|
limit?: number;
|
|
129
126
|
}
|
|
130
127
|
|
|
131
|
-
export interface SourceSelector {
|
|
132
|
-
path: string;
|
|
133
|
-
symbolId?: string;
|
|
134
|
-
startLine?: number;
|
|
135
|
-
endLine?: number;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
128
|
export interface CodeFactsPort {
|
|
139
129
|
/**
|
|
140
130
|
* Runs before a command's incremental sync: seeds a missing index from the repository's base
|
|
@@ -163,8 +153,6 @@ export interface CodeFactsPort {
|
|
|
163
153
|
|
|
164
154
|
export interface LocalStorePort {
|
|
165
155
|
migrate(): Promise<void>;
|
|
166
|
-
beginSnapshot(snapshot: RepositorySnapshot): Promise<string>;
|
|
167
|
-
commitSnapshot(snapshotId: string): Promise<void>;
|
|
168
156
|
saveTaskState(taskSessionId: string, state: unknown): Promise<void>;
|
|
169
157
|
readTaskState(taskSessionId: string): Promise<unknown | undefined>;
|
|
170
158
|
saveReviewResult(reviewId: string, result: unknown): Promise<void>;
|
|
@@ -231,97 +219,6 @@ export interface PolicyPort {
|
|
|
231
219
|
evaluateReview(input: unknown): Promise<{ result: "pass" | "fail"; findings: unknown[] }>;
|
|
232
220
|
}
|
|
233
221
|
|
|
234
|
-
export type InvestigationContextRisk = "low" | "medium" | "high";
|
|
235
|
-
export type InvestigationContextUncertainty = "low" | "medium" | "high";
|
|
236
|
-
|
|
237
|
-
export interface InvestigationContextBundle {
|
|
238
|
-
schemaVersion: "archcontext.investigation-context-bundle/v1";
|
|
239
|
-
repository: ArchitectureRepositoryIdentityV1;
|
|
240
|
-
worktree: ArchitectureWorktreeIdentityV1;
|
|
241
|
-
taskSessionId: string;
|
|
242
|
-
fingerprint: string;
|
|
243
|
-
trigger: {
|
|
244
|
-
source: ArchitectureEventSource;
|
|
245
|
-
reason: string;
|
|
246
|
-
};
|
|
247
|
-
risk: InvestigationContextRisk;
|
|
248
|
-
uncertainty: InvestigationContextUncertainty;
|
|
249
|
-
summary: string;
|
|
250
|
-
evidenceBindingIds: string[];
|
|
251
|
-
candidateChangeIds: string[];
|
|
252
|
-
inputDigest: string;
|
|
253
|
-
extensions?: Record<string, Json>;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export interface InvestigationRunnerInput {
|
|
257
|
-
job: AgentJobV1;
|
|
258
|
-
context: InvestigationContextBundle;
|
|
259
|
-
maxOutputBytes?: number;
|
|
260
|
-
signal?: AbortSignal;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export interface InvestigationRunnerPort {
|
|
264
|
-
readonly runnerId: string;
|
|
265
|
-
readonly capabilities: {
|
|
266
|
-
provider: string;
|
|
267
|
-
supportsCancellation: boolean;
|
|
268
|
-
canReadRepositoryText: boolean;
|
|
269
|
-
canMutateRepository: false;
|
|
270
|
-
};
|
|
271
|
-
runInvestigation(input: InvestigationRunnerInput): Promise<InvestigationReportV1>;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export interface RendererPort {
|
|
275
|
-
renderProjection(input: { modelDigest: string; model: unknown[] }): Promise<{ path: string; content: string }[]>;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export interface CloudMetadataPort {
|
|
279
|
-
verifyEntitlement(input: { repositoryVisibility: "public" | "private"; accountId?: string }): Promise<{ allowed: boolean; reason?: string }>;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export type NotificationResult = "pass" | "pass_with_warnings" | "fail_action_required";
|
|
283
|
-
export type NotificationRiskLevel = "low" | "medium" | "high" | "critical";
|
|
284
|
-
export type NotificationProviderKind = "github-check" | "slack" | "webhook" | "email";
|
|
285
|
-
|
|
286
|
-
export interface NotificationEvent {
|
|
287
|
-
schemaVersion: "archcontext.notification-event/v1";
|
|
288
|
-
eventId: string;
|
|
289
|
-
prUrl: string;
|
|
290
|
-
result: NotificationResult;
|
|
291
|
-
riskLevel: NotificationRiskLevel;
|
|
292
|
-
commitSha: string;
|
|
293
|
-
runtimeVersion: string;
|
|
294
|
-
occurredAt: string;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export interface NotificationProviderConfig {
|
|
298
|
-
schemaVersion: "archcontext.notification-provider/v1";
|
|
299
|
-
id: string;
|
|
300
|
-
provider: NotificationProviderKind;
|
|
301
|
-
enabled: boolean;
|
|
302
|
-
target: string;
|
|
303
|
-
secretRef?: string;
|
|
304
|
-
unsubscribeUrl?: string;
|
|
305
|
-
retry: {
|
|
306
|
-
maxAttempts: number;
|
|
307
|
-
backoffSeconds: number;
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export interface NotificationDeliveryResult {
|
|
312
|
-
providerId: string;
|
|
313
|
-
delivered: boolean;
|
|
314
|
-
idempotencyKey: string;
|
|
315
|
-
attempt: number;
|
|
316
|
-
statusCode?: number;
|
|
317
|
-
deadLettered?: boolean;
|
|
318
|
-
reason?: string;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
export interface NotificationPublisher {
|
|
322
|
-
publish(event: NotificationEvent): Promise<NotificationDeliveryResult[]>;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
222
|
export interface ModelProjectionFile {
|
|
326
223
|
path: string;
|
|
327
224
|
content: string;
|
|
@@ -341,428 +238,6 @@ export interface ModelInteropImporter {
|
|
|
341
238
|
importInitialModel(input: { content: string; source: "likec4" | "structurizr" }): Promise<{ nodes: Json[]; relations: Json[]; warnings: string[] }>;
|
|
342
239
|
}
|
|
343
240
|
|
|
344
|
-
export type ExplorerVerificationStatus = "MATCHED" | "DRIFT" | "UNKNOWN" | "VERIFIED";
|
|
345
|
-
export type ExplorerPressureLevel = "low" | "medium" | "high";
|
|
346
|
-
|
|
347
|
-
export interface ExplorerServiceContract {
|
|
348
|
-
schemaVersion: "archcontext.explorer-service/v1";
|
|
349
|
-
bindHost: "127.0.0.1";
|
|
350
|
-
protocol: "http-loopback";
|
|
351
|
-
optIn: true;
|
|
352
|
-
defaultEnabled: false;
|
|
353
|
-
tokenTtlSeconds: number;
|
|
354
|
-
readOnly: true;
|
|
355
|
-
allowedMethods: ["GET"];
|
|
356
|
-
egress: "none";
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
export const EXPLORER_VIEW_IDS = ["system-map", "task-impact", "drift-pressure", "data-flow", "external-integrations"] as const;
|
|
360
|
-
export type ExplorerViewIdV2 = typeof EXPLORER_VIEW_IDS[number];
|
|
361
|
-
export type ExplorerSemanticLevelV2 = "overview" | "context" | "detail";
|
|
362
|
-
export type ExplorerOccurrenceRoleV2 = "subject" | "derived-group";
|
|
363
|
-
export type ExplorerSubjectRefKindV2 =
|
|
364
|
-
| "architecture-entity"
|
|
365
|
-
| "architecture-relation"
|
|
366
|
-
| "architecture-constraint"
|
|
367
|
-
| "code-symbol";
|
|
368
|
-
|
|
369
|
-
export interface ExplorerExpectedCursorV2 {
|
|
370
|
-
headSha: string;
|
|
371
|
-
worktreeDigest: string;
|
|
372
|
-
graphDigest: string;
|
|
373
|
-
observedFactsDigest?: string;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
export interface ExplorerProjectionQueryV2 {
|
|
377
|
-
schemaVersion: "archcontext.explorer-projection-query/v2";
|
|
378
|
-
viewId: ExplorerViewIdV2;
|
|
379
|
-
semanticLevel?: ExplorerSemanticLevelV2;
|
|
380
|
-
taskSessionId?: string;
|
|
381
|
-
expectedCursor?: ExplorerExpectedCursorV2;
|
|
382
|
-
focus?: { subjectId: string };
|
|
383
|
-
expandedOccurrenceIds?: string[];
|
|
384
|
-
depth: 0 | 1 | 2;
|
|
385
|
-
budget: {
|
|
386
|
-
maxNodes: number;
|
|
387
|
-
maxRelations: number;
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
export interface ExplorerProjectionCursorV2 {
|
|
392
|
-
repository: ArchitectureRepositoryIdentityV1;
|
|
393
|
-
worktree: ArchitectureWorktreeIdentityV1;
|
|
394
|
-
authoritySource: "git" | "ledger";
|
|
395
|
-
authorityCursor: AuthorityCursorV1 | null;
|
|
396
|
-
evidenceAuthorityCursor: AuthorityCursorV1 | null;
|
|
397
|
-
inputManifestDigest: string;
|
|
398
|
-
compatibilityDigest: string;
|
|
399
|
-
graphDigest: string;
|
|
400
|
-
evidenceStateDigest: string;
|
|
401
|
-
observedFactsDigest: string;
|
|
402
|
-
viewDefinitionDigest: string;
|
|
403
|
-
compilerVersion: "archcontext.explorer-view-compiler/v1";
|
|
404
|
-
taskSessionDigest?: string;
|
|
405
|
-
observedAvailability: { status: "ready" | "unavailable"; reasonCode?: string };
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
export interface ProjectionInputManifestV1 {
|
|
409
|
-
schemaVersion: "archcontext.projection-input-manifest/v1";
|
|
410
|
-
repository: ArchitectureRepositoryIdentityV1;
|
|
411
|
-
worktree: ArchitectureWorktreeIdentityV1;
|
|
412
|
-
authoritySource: "git" | "ledger";
|
|
413
|
-
authorityCursor: AuthorityCursorV1 | null;
|
|
414
|
-
evidenceAuthorityCursor: AuthorityCursorV1 | null;
|
|
415
|
-
queryDigest: string;
|
|
416
|
-
graphDigest: string;
|
|
417
|
-
evidenceStateDigest: string;
|
|
418
|
-
observedFactsDigest: string;
|
|
419
|
-
observedAvailability: { status: "ready" | "unavailable"; reasonCode?: string };
|
|
420
|
-
bindingsDigest: string;
|
|
421
|
-
eventBacklinksDigest: string;
|
|
422
|
-
driftDigest: string | null;
|
|
423
|
-
pressureDigest: string | null;
|
|
424
|
-
taskSessionDigest: string | null;
|
|
425
|
-
readPlan: ProjectionReadPlanV1;
|
|
426
|
-
readSet: ProjectionReadSetV1;
|
|
427
|
-
inputDomains: Record<ProjectionInputDomainV1, ProjectionInputDomainStateV1>;
|
|
428
|
-
viewDefinitionDigest: string;
|
|
429
|
-
compilerVersion: "archcontext.explorer-view-compiler/v1";
|
|
430
|
-
tokenRequired: boolean;
|
|
431
|
-
compatibilityDigest: string;
|
|
432
|
-
manifestDigest: string;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
export type ProjectionInputDomainV1 =
|
|
436
|
-
| "authority"
|
|
437
|
-
| "graph"
|
|
438
|
-
| "evidence"
|
|
439
|
-
| "observed"
|
|
440
|
-
| "bindings"
|
|
441
|
-
| "event-backlinks"
|
|
442
|
-
| "drift"
|
|
443
|
-
| "pressure"
|
|
444
|
-
| "task-session";
|
|
445
|
-
|
|
446
|
-
export type ProjectionInputDomainStateV1 =
|
|
447
|
-
| { requirement: "required"; status: "ready"; digest: string }
|
|
448
|
-
| { requirement: "optional"; status: "ready"; digest: string }
|
|
449
|
-
| { requirement: "optional"; status: "unavailable"; digest: null; reasonCode: string }
|
|
450
|
-
| { requirement: "not-used"; status: "not-used"; digest: null };
|
|
451
|
-
|
|
452
|
-
export const EXPLORER_VIEW_INPUT_REQUIREMENTS = {
|
|
453
|
-
"system-map": {
|
|
454
|
-
authority: "required", graph: "required", evidence: "required", observed: "required", bindings: "required",
|
|
455
|
-
"event-backlinks": "optional", drift: "optional", pressure: "optional", "task-session": "optional"
|
|
456
|
-
},
|
|
457
|
-
"task-impact": {
|
|
458
|
-
authority: "required", graph: "required", evidence: "required", observed: "required", bindings: "required",
|
|
459
|
-
"event-backlinks": "optional", drift: "optional", pressure: "optional", "task-session": "required"
|
|
460
|
-
},
|
|
461
|
-
"drift-pressure": {
|
|
462
|
-
authority: "required", graph: "required", evidence: "required", observed: "required", bindings: "required",
|
|
463
|
-
"event-backlinks": "optional", drift: "required", pressure: "required", "task-session": "optional"
|
|
464
|
-
},
|
|
465
|
-
"data-flow": {
|
|
466
|
-
authority: "required", graph: "required", evidence: "required", observed: "required", bindings: "required",
|
|
467
|
-
"event-backlinks": "optional", drift: "optional", pressure: "optional", "task-session": "optional"
|
|
468
|
-
},
|
|
469
|
-
"external-integrations": {
|
|
470
|
-
authority: "required", graph: "required", evidence: "required", observed: "required", bindings: "required",
|
|
471
|
-
"event-backlinks": "optional", drift: "optional", pressure: "optional", "task-session": "optional"
|
|
472
|
-
}
|
|
473
|
-
} as const satisfies Record<ExplorerViewIdV2, Record<ProjectionInputDomainV1, ProjectionInputDomainStateV1["requirement"]>>;
|
|
474
|
-
|
|
475
|
-
export const PROJECTION_READ_PLANNER_VERSION = "archcontext.projection-read-planner/v1" as const;
|
|
476
|
-
export const EXPLORER_PROJECTION_CACHE_POLICY_SCHEMA_VERSION = "archcontext.explorer-cache-policy/v1" as const;
|
|
477
|
-
|
|
478
|
-
export interface ExplorerProjectionCachePolicyV1 {
|
|
479
|
-
schemaVersion: typeof EXPLORER_PROJECTION_CACHE_POLICY_SCHEMA_VERSION;
|
|
480
|
-
maxEntriesPerScope: number;
|
|
481
|
-
maxBytesPerScope: number;
|
|
482
|
-
maxAgeMs: number;
|
|
483
|
-
maxPinnedEntriesPerScope: number;
|
|
484
|
-
maxPinTtlMs: number;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
export interface ProjectionReadPlanV1 {
|
|
488
|
-
schemaVersion: "archcontext.projection-read-plan/v1";
|
|
489
|
-
plannerVersion: typeof PROJECTION_READ_PLANNER_VERSION;
|
|
490
|
-
kind: "overview-aggregate" | "bounded-context" | "focused-neighborhood";
|
|
491
|
-
source: "git-authority" | "verified-ledger-current";
|
|
492
|
-
queryDigest: string;
|
|
493
|
-
semanticLevel: ExplorerSemanticLevelV2;
|
|
494
|
-
focusSubjectId: string | null;
|
|
495
|
-
expandedKinds: string[];
|
|
496
|
-
depth: 0 | 1 | 2;
|
|
497
|
-
limits: {
|
|
498
|
-
maxEntities: number;
|
|
499
|
-
maxRelations: number;
|
|
500
|
-
maxConstraints: number;
|
|
501
|
-
maxBindings: number;
|
|
502
|
-
maxBacklinks: number;
|
|
503
|
-
maxGraphRows: number;
|
|
504
|
-
};
|
|
505
|
-
requiredDomains: ProjectionInputDomainV1[];
|
|
506
|
-
ordering: "canonical-id-asc";
|
|
507
|
-
truncation: "hard-limit-with-authoritative-totals";
|
|
508
|
-
planDigest: string;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
export interface ProjectionReadSetV1 {
|
|
512
|
-
schemaVersion: "archcontext.projection-read-set/v1";
|
|
513
|
-
planDigest: string;
|
|
514
|
-
selectedGraphDigest: string;
|
|
515
|
-
authoritativeTotals: { entities: number; relations: number; constraints: number };
|
|
516
|
-
entityKindTotals: Array<{ kind: string; count: number }>;
|
|
517
|
-
rowsRead: { entities: number; relations: number; constraints: number; bindings: number; backlinks: number };
|
|
518
|
-
truncated: boolean;
|
|
519
|
-
readSetDigest: string;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
export function explorerProjectionQueryDigestV2(query: ExplorerProjectionQueryV2): string {
|
|
523
|
-
return digestJson({
|
|
524
|
-
schemaVersion: query.schemaVersion,
|
|
525
|
-
viewId: query.viewId,
|
|
526
|
-
semanticLevel: query.semanticLevel ?? "context",
|
|
527
|
-
taskSessionId: query.taskSessionId ?? null,
|
|
528
|
-
focus: query.focus ?? null,
|
|
529
|
-
expandedOccurrenceIds: [...new Set(query.expandedOccurrenceIds ?? [])].sort(),
|
|
530
|
-
depth: query.depth,
|
|
531
|
-
budget: query.budget
|
|
532
|
-
} as unknown as Json);
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
export function canonicalProjectionReadPlanV1(
|
|
536
|
-
query: ExplorerProjectionQueryV2,
|
|
537
|
-
source: ProjectionReadPlanV1["source"]
|
|
538
|
-
): ProjectionReadPlanV1 {
|
|
539
|
-
if (
|
|
540
|
-
query.schemaVersion !== "archcontext.explorer-projection-query/v2"
|
|
541
|
-
|| !(EXPLORER_VIEW_IDS as readonly string[]).includes(query.viewId)
|
|
542
|
-
|| !Number.isInteger(query.depth) || query.depth < 0 || query.depth > 2
|
|
543
|
-
|| !Number.isInteger(query.budget.maxNodes) || query.budget.maxNodes < 1 || query.budget.maxNodes > 1_000
|
|
544
|
-
|| !Number.isInteger(query.budget.maxRelations) || query.budget.maxRelations < 0 || query.budget.maxRelations > 5_000
|
|
545
|
-
) {
|
|
546
|
-
throw new Error("explorer-projection-query-invalid");
|
|
547
|
-
}
|
|
548
|
-
const semanticLevel = query.semanticLevel ?? "context";
|
|
549
|
-
const kind: ProjectionReadPlanV1["kind"] = semanticLevel === "overview"
|
|
550
|
-
? "overview-aggregate"
|
|
551
|
-
: query.focus
|
|
552
|
-
? "focused-neighborhood"
|
|
553
|
-
: "bounded-context";
|
|
554
|
-
const maxEntities = query.budget.maxNodes;
|
|
555
|
-
const maxRelations = query.budget.maxRelations;
|
|
556
|
-
const maxConstraints = Math.max(1, Math.min(2_000, maxEntities * 2));
|
|
557
|
-
const maxBindings = Math.max(1, Math.min(4_000, maxEntities * 4));
|
|
558
|
-
const maxBacklinks = Math.max(1, Math.min(8_000, maxEntities * 8));
|
|
559
|
-
const requirements = EXPLORER_VIEW_INPUT_REQUIREMENTS[query.viewId];
|
|
560
|
-
const withoutDigest = {
|
|
561
|
-
schemaVersion: "archcontext.projection-read-plan/v1" as const,
|
|
562
|
-
plannerVersion: PROJECTION_READ_PLANNER_VERSION,
|
|
563
|
-
kind,
|
|
564
|
-
source,
|
|
565
|
-
queryDigest: explorerProjectionQueryDigestV2(query),
|
|
566
|
-
semanticLevel,
|
|
567
|
-
focusSubjectId: query.focus?.subjectId ?? null,
|
|
568
|
-
expandedKinds: [...new Set((query.expandedOccurrenceIds ?? []).flatMap((id) => {
|
|
569
|
-
const prefix = `occurrence.${query.viewId}.group.kind.`;
|
|
570
|
-
return id.startsWith(prefix) ? [id.slice(prefix.length)] : [];
|
|
571
|
-
}))].sort(),
|
|
572
|
-
depth: query.depth,
|
|
573
|
-
limits: {
|
|
574
|
-
maxEntities,
|
|
575
|
-
maxRelations,
|
|
576
|
-
maxConstraints,
|
|
577
|
-
maxBindings,
|
|
578
|
-
maxBacklinks,
|
|
579
|
-
maxGraphRows: maxEntities + maxRelations + maxConstraints
|
|
580
|
-
},
|
|
581
|
-
requiredDomains: (Object.entries(requirements) as Array<[ProjectionInputDomainV1, ProjectionInputDomainStateV1["requirement"]]>)
|
|
582
|
-
.filter(([, requirement]) => requirement === "required")
|
|
583
|
-
.map(([domain]) => domain)
|
|
584
|
-
.sort(),
|
|
585
|
-
ordering: "canonical-id-asc" as const,
|
|
586
|
-
truncation: "hard-limit-with-authoritative-totals" as const
|
|
587
|
-
};
|
|
588
|
-
return { ...withoutDigest, planDigest: digestJson(withoutDigest as unknown as Json) };
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
export interface ExplorerSubjectRefV2 {
|
|
592
|
-
kind: ExplorerSubjectRefKindV2;
|
|
593
|
-
id: string;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
export interface ExplorerOccurrenceProvenanceV2 {
|
|
597
|
-
declaredEntityIds: string[];
|
|
598
|
-
observedSymbolIds: string[];
|
|
599
|
-
evidenceBindingIds: string[];
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
export type ExplorerAuthorityStateV2 = "BOUND" | "UNBOUND_OBSERVED" | "DECLARED_UNOBSERVED" | "DERIVED";
|
|
603
|
-
|
|
604
|
-
export interface ExplorerPressureEvaluationV2 {
|
|
605
|
-
evaluated: boolean;
|
|
606
|
-
level?: ExplorerPressureLevel;
|
|
607
|
-
score?: number;
|
|
608
|
-
signals: string[];
|
|
609
|
-
inputDigest?: string;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
export interface ExplorerInspectorV2 {
|
|
613
|
-
summary?: string;
|
|
614
|
-
responsibility?: string;
|
|
615
|
-
constraints: Array<{ id: string; kind: string; severity?: string; summary?: string }>;
|
|
616
|
-
decisions: Array<{ eventId: string; title?: string; rationale?: string }>;
|
|
617
|
-
historyEvents: Array<{ eventId: string; title?: string; rationale?: string }>;
|
|
618
|
-
sourceSelectors: SourceSelector[];
|
|
619
|
-
evidenceBindingIds: string[];
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
export interface ExplorerBacklinksV2 {
|
|
623
|
-
appearsInViews: ExplorerViewIdV2[];
|
|
624
|
-
affectedByTaskSessionIds: string[];
|
|
625
|
-
constrainedByIds: string[];
|
|
626
|
-
evidencedByBindingIds: string[];
|
|
627
|
-
changedByEventIds: string[];
|
|
628
|
-
decidedByEventIds: string[];
|
|
629
|
-
incomingRelationIds: string[];
|
|
630
|
-
outgoingRelationIds: string[];
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
export interface ExplorerSubjectOccurrenceV2 {
|
|
634
|
-
occurrenceId: string;
|
|
635
|
-
role: "subject";
|
|
636
|
-
parentOccurrenceId?: string;
|
|
637
|
-
subjectRefs: ExplorerSubjectRefV2[];
|
|
638
|
-
name: string;
|
|
639
|
-
kind: string;
|
|
640
|
-
childrenCount: number;
|
|
641
|
-
expandable: boolean;
|
|
642
|
-
verificationStatus: ExplorerVerificationStatus;
|
|
643
|
-
authorityState: ExplorerAuthorityStateV2;
|
|
644
|
-
pressure: ExplorerPressureEvaluationV2;
|
|
645
|
-
sourceSelectors: SourceSelector[];
|
|
646
|
-
provenance: ExplorerOccurrenceProvenanceV2;
|
|
647
|
-
inspector: ExplorerInspectorV2;
|
|
648
|
-
backlinks: ExplorerBacklinksV2;
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
export interface ExplorerDerivedGroupOccurrenceV2 {
|
|
652
|
-
occurrenceId: string;
|
|
653
|
-
role: "derived-group";
|
|
654
|
-
parentOccurrenceId?: string;
|
|
655
|
-
subjectRefs: [];
|
|
656
|
-
name: string;
|
|
657
|
-
kind: string;
|
|
658
|
-
childrenCount: number;
|
|
659
|
-
expandable: boolean;
|
|
660
|
-
verificationStatus: "UNKNOWN";
|
|
661
|
-
authorityState: "DERIVED";
|
|
662
|
-
pressure: ExplorerPressureEvaluationV2;
|
|
663
|
-
sourceSelectors: [];
|
|
664
|
-
provenance: ExplorerOccurrenceProvenanceV2;
|
|
665
|
-
derivation: {
|
|
666
|
-
ruleId: string;
|
|
667
|
-
inputDigest: string;
|
|
668
|
-
compilerVersion: "archcontext.explorer-view-compiler/v1";
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
export type ExplorerOccurrenceV2 = ExplorerSubjectOccurrenceV2 | ExplorerDerivedGroupOccurrenceV2;
|
|
673
|
-
|
|
674
|
-
export interface ExplorerRelationOccurrenceV2 {
|
|
675
|
-
occurrenceId: string;
|
|
676
|
-
sourceOccurrenceId: string;
|
|
677
|
-
targetOccurrenceId: string;
|
|
678
|
-
kind: string;
|
|
679
|
-
verificationStatus: ExplorerVerificationStatus;
|
|
680
|
-
provenance: {
|
|
681
|
-
declaredRelationIds: string[];
|
|
682
|
-
observedEdgeIds: string[];
|
|
683
|
-
evidenceBindingIds: string[];
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
export interface ExplorerProjectionV2 {
|
|
688
|
-
schemaVersion: "archcontext.explorer-projection/v2";
|
|
689
|
-
view: {
|
|
690
|
-
id: ExplorerViewIdV2;
|
|
691
|
-
title: string;
|
|
692
|
-
question: string;
|
|
693
|
-
};
|
|
694
|
-
availableViews: Array<{ id: ExplorerViewIdV2; enabled: boolean; reason?: string }>;
|
|
695
|
-
semanticLevel: ExplorerSemanticLevelV2;
|
|
696
|
-
breadcrumbs: Array<{ occurrenceId: string; label: string }>;
|
|
697
|
-
cursor: ExplorerProjectionCursorV2;
|
|
698
|
-
inputManifest: ProjectionInputManifestV1;
|
|
699
|
-
occurrences: ExplorerOccurrenceV2[];
|
|
700
|
-
relations: ExplorerRelationOccurrenceV2[];
|
|
701
|
-
page: {
|
|
702
|
-
budget: { maxNodes: number; maxRelations: number };
|
|
703
|
-
totalNodes: number;
|
|
704
|
-
totalRelations: number;
|
|
705
|
-
returnedNodes: number;
|
|
706
|
-
returnedRelations: number;
|
|
707
|
-
truncated: boolean;
|
|
708
|
-
omittedNodeCount: number;
|
|
709
|
-
omittedRelationCount: number;
|
|
710
|
-
};
|
|
711
|
-
projectionDigest: string;
|
|
712
|
-
capabilities: {
|
|
713
|
-
readOnly: true;
|
|
714
|
-
mutationMode: "forbidden";
|
|
715
|
-
egress: "none";
|
|
716
|
-
tokenRequired: boolean;
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
export interface AuthorityCursorV1 {
|
|
721
|
-
schemaVersion: "archcontext.authority-cursor/v1";
|
|
722
|
-
repository: ArchitectureRepositoryIdentityV1;
|
|
723
|
-
worktree: ArchitectureWorktreeIdentityV1;
|
|
724
|
-
eventSequence: number;
|
|
725
|
-
eventId: string;
|
|
726
|
-
eventHash: string;
|
|
727
|
-
graphDigest: string;
|
|
728
|
-
evidenceStateDigest: string;
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
export type ExplorerDeltaClassV2 = "architecture-fact" | "evidence" | "projection";
|
|
732
|
-
|
|
733
|
-
export type ExplorerDeltaFailureReasonV2 =
|
|
734
|
-
| "invalid-delta-query"
|
|
735
|
-
| "projection-cache-miss"
|
|
736
|
-
| "authority-event-missing"
|
|
737
|
-
| "authority-cursor-reversed"
|
|
738
|
-
| "projection-authority-mismatch"
|
|
739
|
-
| "projection-manifest-incompatible";
|
|
740
|
-
|
|
741
|
-
export interface ExplorerDeltaQueryV2 {
|
|
742
|
-
schemaVersion: "archcontext.explorer-delta-query/v2";
|
|
743
|
-
base: { eventId: string; projectionDigest: string };
|
|
744
|
-
head: { eventId: string; projectionDigest: string };
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
export interface ExplorerDeltaChangeV2 {
|
|
748
|
-
deltaClass: ExplorerDeltaClassV2;
|
|
749
|
-
subjectId: string;
|
|
750
|
-
change: "added" | "removed" | "changed";
|
|
751
|
-
fields: string[];
|
|
752
|
-
verificationTransition?: { from: ExplorerVerificationStatus; to: ExplorerVerificationStatus };
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
export interface ExplorerProjectionDeltaV2 {
|
|
756
|
-
schemaVersion: "archcontext.explorer-projection-delta/v2";
|
|
757
|
-
base: AuthorityCursorV1 & { projectionDigest: string; inputManifestDigest: string };
|
|
758
|
-
head: AuthorityCursorV1 & { projectionDigest: string; inputManifestDigest: string };
|
|
759
|
-
factChanges: ExplorerDeltaChangeV2[];
|
|
760
|
-
evidenceChanges: ExplorerDeltaChangeV2[];
|
|
761
|
-
projectionChanges: ExplorerDeltaChangeV2[];
|
|
762
|
-
counts: Record<ExplorerDeltaClassV2, number>;
|
|
763
|
-
deltaDigest: string;
|
|
764
|
-
}
|
|
765
|
-
|
|
766
241
|
export interface RetrievalConfig {
|
|
767
242
|
schemaVersion: "archcontext.retrieval-config/v1";
|
|
768
243
|
defaultMode: "lexical";
|
|
@@ -819,18 +294,8 @@ export interface RetrievalDecisionRecord {
|
|
|
819
294
|
evidenceDigest: string;
|
|
820
295
|
}
|
|
821
296
|
|
|
822
|
-
export interface ChatGptGaToolContract {
|
|
823
|
-
schemaVersion: "archcontext.chatgpt-ga-tool/v1";
|
|
824
|
-
toolName: string;
|
|
825
|
-
surface: "cloud-metadata" | "local-runtime";
|
|
826
|
-
readOnlyByDefault: boolean;
|
|
827
|
-
dataClassification: "cloud-metadata" | "local-metadata" | "local-architecture";
|
|
828
|
-
requiresLocalConfirmationForWrite: boolean;
|
|
829
|
-
disclosure: string;
|
|
830
|
-
}
|
|
831
|
-
|
|
832
297
|
export interface NonLocalEgressChannel {
|
|
833
|
-
channel: "context7" | "
|
|
298
|
+
channel: "context7" | "npm-update-check" | "projection-publishing" | "codegraph-telemetry";
|
|
834
299
|
destination: string;
|
|
835
300
|
trigger: string;
|
|
836
301
|
data: string;
|