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