archctx-contracts 0.13.0 → 0.14.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.
@@ -5,7 +5,7 @@ import {
5
5
  ARCHITECTURE_SEMANTIC_FACETS,
6
6
  isArchitectureCapabilityProofStatus,
7
7
  type ArchitectureCapabilityProofStatusV1,
8
- type ArchitectureDigestSetV1,
8
+ type ArchitectureDigestSetV2,
9
9
  type ArchitectureSemanticFacet,
10
10
  type Sha256Digest
11
11
  } from "./projection";
@@ -16,21 +16,23 @@ import { digestJson, isRepoRelativePosixPath, type Json } from "./schema";
16
16
  * projection engine writes it and reads its semantic baseline and per-target rows back; this module
17
17
  * is the only definition of its shape, of its byte layout and of every value derived from it.
18
18
  *
19
- * `schemaVersion` is `v3` (#327). The file holds no global digest of all owned sources: header
20
- * lines change only on a protocol upgrade, the one Git-visible anchor is
21
- * `semanticBaseline.modelDigest`, and every other line belongs to one capability or one target.
22
- * Two pull requests that touch different capabilities therefore rewrite disjoint lines. The global
23
- * digests a run still needs (source tree, flow proof, projection) are computed from the rows when
24
- * the manifest is read (`architectureDocsProjectionManifestDigests`).
19
+ * `schemaVersion` is `v4` (ADR-0056). The file records no digest of raw source: a target row holds
20
+ * only what the render produced, so a source edit that changes no output, no proof evidence and no
21
+ * header line leaves the file byte-identical. Header lines change only on a protocol upgrade, the
22
+ * one Git-visible anchor is `semanticBaseline.modelDigest`, and every other line belongs to one
23
+ * capability or one target. Two pull requests that touch different capabilities therefore rewrite
24
+ * disjoint lines. The global digests a run still needs (flow proof, projection) are computed from
25
+ * the rows when the manifest is read (`architectureDocsProjectionManifestDigests`).
25
26
  *
26
- * A `v1` or `v2` manifest is read only for its `schemaVersion` and refused with
27
+ * A `v1`, `v2` or `v3` manifest is read only for its `schemaVersion` and refused with
27
28
  * `projection-manifest-upgrade-required`; nothing else in it is read.
28
29
  */
29
- export const ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION = "archcontext.architecture-docs-projection-manifest/v3" as const;
30
+ export const ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION = "archcontext.architecture-docs-projection-manifest/v4" as const;
30
31
  /** Manifest versions earlier releases wrote. Only their `schemaVersion` is read, to refuse them. */
31
32
  export const SUPERSEDED_ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSIONS = [
32
33
  "archcontext.architecture-docs-projection-manifest/v1",
33
- "archcontext.architecture-docs-projection-manifest/v2"
34
+ "archcontext.architecture-docs-projection-manifest/v2",
35
+ "archcontext.architecture-docs-projection-manifest/v3"
34
36
  ] as const;
35
37
  /**
36
38
  * The one-time re-baseline an operator runs after the migration preconditions in the runbook are
@@ -44,7 +46,7 @@ export const ARCHITECTURE_DOCS_PROJECTION_MANIFEST_MIGRATION_GUIDE = "docs/runbo
44
46
  export const PROJECTION_MANIFEST_UPGRADE_REQUIRED = "projection-manifest-upgrade-required" as const;
45
47
  /** The reason code of a current-format manifest that fails its contract; restore it from Git. */
46
48
  export const PROJECTION_MANIFEST_INVALID = "projection-manifest-invalid" as const;
47
- /** The reason code of a declared source footprint that no stamping target carries a stamp for. */
49
+ /** The reason code of a declared source footprint that no entity-summary or topology target documents. */
48
50
  export const PROJECTION_FOOTPRINT_UNCOVERED = "projection-footprint-uncovered" as const;
49
51
  export const ARCHITECTURE_DOCS_PROJECTION_PROVENANCE_SCHEMA_VERSION = "archcontext.architecture-docs-projection-provenance/v3" as const;
50
52
  export const ARCHITECTURE_DOCS_LAYOUT_VERSION_V1 = "archcontext.docs-layout/v1" as const;
@@ -73,14 +75,12 @@ export interface ArchitectureSemanticStateV1 {
73
75
  * The inputs besides the model that the flow proofs of one projection were compiled from, per
74
76
  * capability. Committed acceptance compares the manifest's value with a fresh measurement: a
75
77
  * capability whose proof moved while its semantic fingerprint held is explained by the journaled
76
- * model only when its member stamps, its selector-evidence digest and the renderer are unchanged.
78
+ * model only when its selector-evidence digest and the renderer are unchanged (ADR-0056 §5).
77
79
  */
78
- export interface ArchitectureProjectionProofEvidenceV1 {
80
+ export interface ArchitectureProjectionProofEvidenceV2 {
79
81
  rendererVersion: string;
80
82
  /** Per capability: digest of the proof-relevant selector evidence its flows cite. */
81
83
  selectorEvidenceDigests: Record<string, string>;
82
- /** Per node that declares `source.include`: the content digest of its footprint. */
83
- sourceStamps: Record<string, string>;
84
84
  }
85
85
 
86
86
  /**
@@ -106,30 +106,12 @@ export type ArchitectureDocsProjectionGeneratedFromV1 = {
106
106
  codeGraphVersion: string;
107
107
  };
108
108
 
109
- /**
110
- * One 1–2–5 magnitude bucket: the half-open range `[lower, upper)` that contains a measured count.
111
- * `{ lower: 0, upper: 1 }` holds only zero; otherwise `lower` is `1`, `2` or `5` times a power of ten
112
- * and `upper` is the next step on that ladder.
113
- */
114
- export interface ArchitectureScaleBucketV1 {
115
- lower: number;
116
- upper: number;
117
- }
118
-
119
- /**
120
- * The measured size of a node's declared `source.include` minus `source.exclude` footprint, as
121
- * buckets. The module document prints exactly these buckets; the exact counts are never committed.
122
- */
123
- export interface ArchitectureCapabilityScaleV1 {
124
- fileCountBucket: ArchitectureScaleBucketV1;
125
- lineCountBucket: ArchitectureScaleBucketV1;
126
- }
127
-
128
109
  /**
129
110
  * One target row of the committed manifest, keyed by `targetId`. The targetId and the renderer
130
- * version are not repeated in the row: the key and the manifest header carry them.
111
+ * version are not repeated in the row: the key and the manifest header carry them. A row records
112
+ * no source state; its `outputDigest` is the target's freshness identity (ADR-0056 §1).
131
113
  */
132
- export interface ArchitectureDocsProjectionManifestTargetV3 {
114
+ export interface ArchitectureDocsProjectionManifestTargetV4 {
133
115
  type: ProjectionTargetType;
134
116
  scope: { kind: ProjectionTargetScopeKind; id?: string; entityKind?: string };
135
117
  path: string;
@@ -137,25 +119,15 @@ export interface ArchitectureDocsProjectionManifestTargetV3 {
137
119
  format: ProjectionTargetFormat;
138
120
  /** `digestJson({ targetId, body })` of the generated body: the region of a `mixed` target, the whole file of a `generated` one. */
139
121
  outputDigest: string;
140
- /**
141
- * The content digest of every declared source footprint this target documents, by node id. On an
142
- * `entity-summary` row a footprint belongs to its node's nearest ancestor-or-self that has an
143
- * entity-summary target, so it is stamped on exactly one such row. A runtime topology node's
144
- * footprint (ADR-0049) is stamped on every runtime topology row instead, and those rows carry
145
- * identical stamps. No other target type carries stamps.
146
- */
147
- sourceStamps?: Record<string, string>;
148
- /** Present exactly when `sourceStamps` stamps the target's own node: the scale buckets its document prints (#264). */
149
- scale?: ArchitectureCapabilityScaleV1;
150
122
  }
151
123
 
152
124
  /** One capability of the committed semantic baseline. */
153
- export interface ArchitectureDocsProjectionManifestCapabilityV3 extends ArchitectureCapabilitySemanticStateV1 {
125
+ export interface ArchitectureDocsProjectionManifestCapabilityV4 extends ArchitectureCapabilitySemanticStateV1 {
154
126
  /** Digest of the proof-relevant selector evidence for the selectors this capability's flows cite. */
155
127
  selectorEvidenceDigest: string;
156
128
  }
157
129
 
158
- export interface ArchitectureDocsProjectionManifestV3 {
130
+ export interface ArchitectureDocsProjectionManifestV4 {
159
131
  schemaVersion: typeof ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION;
160
132
  /**
161
133
  * The renderer that wrote this manifest. Any renderer is readable: a renderer bump re-renders
@@ -172,9 +144,9 @@ export interface ArchitectureDocsProjectionManifestV3 {
172
144
  /** The one Git-visible anchor: the digest of the model this baseline was compiled from. */
173
145
  modelDigest: string;
174
146
  /** Sorted and unique by capabilityId. */
175
- capabilities: ArchitectureDocsProjectionManifestCapabilityV3[];
147
+ capabilities: ArchitectureDocsProjectionManifestCapabilityV4[];
176
148
  };
177
- targets: Record<string, ArchitectureDocsProjectionManifestTargetV3>;
149
+ targets: Record<string, ArchitectureDocsProjectionManifestTargetV4>;
178
150
  }
179
151
 
180
152
  const SHA256 = /^sha256:[a-f0-9]{64}$/;
@@ -183,20 +155,20 @@ const TARGET_TYPES: Record<ProjectionTargetType, true> = {
183
155
  "entity-summary": true,
184
156
  "relation-summary": true,
185
157
  "decision-index": true,
186
- "architecture-changelog": true,
187
158
  "diagram-mermaid": true,
188
159
  "diagram-structurizr": true,
189
160
  "diagram-likec4": true,
190
161
  "diagram-runtime-topology": true,
191
162
  "runtime-topology-summary": true,
163
+ "architecture-history": true,
192
164
  "agent-context": true
193
165
  };
194
- /** The whole-model targets that render the runtime topology and carry its nodes' stamps (ADR-0049). */
166
+ /** The whole-model targets that render the runtime topology (ADR-0049); they document its nodes' footprints. */
195
167
  export const RUNTIME_TOPOLOGY_TARGET_TYPES = ["diagram-runtime-topology", "runtime-topology-summary"] as const satisfies readonly ProjectionTargetType[];
196
168
  export function isRuntimeTopologyTargetType(type: unknown): type is (typeof RUNTIME_TOPOLOGY_TARGET_TYPES)[number] {
197
169
  return typeof type === "string" && (RUNTIME_TOPOLOGY_TARGET_TYPES as readonly string[]).includes(type);
198
170
  }
199
- const SCOPE_KINDS: Record<ProjectionTargetScopeKind, true> = { repository: true, entity: true, relation: true, decision: true, diagram: true, changelog: true };
171
+ const SCOPE_KINDS: Record<ProjectionTargetScopeKind, true> = { repository: true, entity: true, relation: true, decision: true, diagram: true };
200
172
  const OWNERSHIPS: Record<ProjectionTargetOwnership, true> = { generated: true, mixed: true };
201
173
  const FORMATS: Record<ProjectionTargetFormat, true> = { markdown: true, mermaid: true, "structurizr-json": true, likec4: true };
202
174
 
@@ -226,35 +198,22 @@ export function architectureDocsProjectionManifestIssues(value: unknown): string
226
198
  issues.push("manifest.targets must be an object keyed by targetId");
227
199
  return issues;
228
200
  }
229
- const paths = new Set<string>();
230
- const stampOwners = new Map<string, string>();
231
- let topologyStamps: { targetId: string; stamps: string } | undefined;
201
+ // Every path appears in one row, except that agent-context rows share a contract file when their
202
+ // nodes differ: each row owns only its node's region (ADR-0056 §9).
203
+ const rowsByPath = new Map<string, { agentContext: boolean; scopeId: unknown }[]>();
232
204
  for (const [targetId, row] of Object.entries(targets)) {
233
205
  const prefix = `manifest.targets[${JSON.stringify(targetId)}]`;
234
206
  if (!isNonEmptyString(targetId)) issues.push("manifest.targets keys must be non-empty targetIds");
235
207
  issues.push(...manifestTargetIssues(row, prefix));
236
- const path = record(row)?.path;
208
+ const target = record(row);
209
+ const path = target?.path;
237
210
  if (typeof path === "string") {
238
- if (paths.has(path)) issues.push(`${prefix}.path is recorded by another target`);
239
- paths.add(path);
240
- }
241
- const stamps = record(record(row)?.sourceStamps) ?? {};
242
- if (isRuntimeTopologyTargetType(record(row)?.type)) {
243
- // Every topology row renders the same topology, so all of them carry one stamp set.
244
- const serialized = JSON.stringify(Object.keys(stamps).sort(compareStrings).map((nodeId) => [nodeId, stamps[nodeId]]));
245
- if (topologyStamps === undefined) topologyStamps = { targetId, stamps: serialized };
246
- else if (topologyStamps.stamps !== serialized) issues.push(`${prefix}.sourceStamps must equal the sourceStamps of ${topologyStamps.targetId}`);
247
- for (const nodeId of Object.keys(stamps)) {
248
- const owner = stampOwners.get(nodeId);
249
- if (owner !== undefined && !isRuntimeTopologyTargetType(record(targets[owner])?.type)) issues.push(`${prefix}.sourceStamps.${nodeId} is already stamped on ${owner}`);
250
- else if (owner === undefined) stampOwners.set(nodeId, targetId);
211
+ const current = { agentContext: target!.type === "agent-context", scopeId: record(target!.scope)?.id };
212
+ const others = rowsByPath.get(path) ?? [];
213
+ if (others.some((other) => !current.agentContext || !other.agentContext || other.scopeId === current.scopeId)) {
214
+ issues.push(`${prefix}.path is recorded by another target`);
251
215
  }
252
- continue;
253
- }
254
- for (const nodeId of Object.keys(stamps)) {
255
- const owner = stampOwners.get(nodeId);
256
- if (owner !== undefined) issues.push(`${prefix}.sourceStamps.${nodeId} is already stamped on ${owner}`);
257
- else stampOwners.set(nodeId, targetId);
216
+ rowsByPath.set(path, [...others, current]);
258
217
  }
259
218
  }
260
219
  return issues;
@@ -294,7 +253,7 @@ export function isSupersededArchitectureDocsProjectionManifestSchemaVersion(sche
294
253
  * - Each capability entry is indented JSON and starts with its own `capabilityId` line.
295
254
  * - Each target row is one line, after a line holding its `targetId` key, in canonical key order.
296
255
  */
297
- export function serializeArchitectureDocsProjectionManifest(manifest: ArchitectureDocsProjectionManifestV3): string {
256
+ export function serializeArchitectureDocsProjectionManifest(manifest: ArchitectureDocsProjectionManifestV4): string {
298
257
  const capabilities = [...manifest.semanticBaseline.capabilities]
299
258
  .sort((left, right) => compareStrings(left.capabilityId, right.capabilityId))
300
259
  .map(canonicalCapability);
@@ -330,7 +289,7 @@ export function serializeArchitectureDocsProjectionManifest(manifest: Architectu
330
289
  }
331
290
 
332
291
  /** The runtime semantic state the baseline records: capability entries without their evidence, plus the two aggregates. */
333
- export function architectureDocsProjectionManifestSemanticState(manifest: ArchitectureDocsProjectionManifestV3): ArchitectureSemanticStateV1 {
292
+ export function architectureDocsProjectionManifestSemanticState(manifest: ArchitectureDocsProjectionManifestV4): ArchitectureSemanticStateV1 {
334
293
  return architectureSemanticStateFromCapabilities(manifest.semanticBaseline.capabilities.map(({ selectorEvidenceDigest: _selectorEvidenceDigest, ...capability }) => capability));
335
294
  }
336
295
 
@@ -348,34 +307,23 @@ export function architectureSemanticStateFromCapabilities(capabilities: readonly
348
307
  };
349
308
  }
350
309
 
351
- /**
352
- * Every stamp the rows record, by node id. A valid manifest stamps each node on one entity-summary
353
- * row, or with one digest on every runtime topology row.
354
- */
355
- export function architectureDocsProjectionManifestSourceStamps(manifest: ArchitectureDocsProjectionManifestV3): Record<string, string> {
356
- const stamps: Record<string, string> = {};
357
- for (const row of Object.values(manifest.targets)) Object.assign(stamps, row.sourceStamps ?? {});
358
- return stamps;
359
- }
360
-
361
- /** The proof evidence the baseline was compiled from, as `ArchitectureProjectionProofEvidenceV1`. */
362
- export function architectureDocsProjectionManifestProofEvidence(manifest: ArchitectureDocsProjectionManifestV3): ArchitectureProjectionProofEvidenceV1 {
310
+ /** The proof evidence the baseline was compiled from, as `ArchitectureProjectionProofEvidenceV2`. */
311
+ export function architectureDocsProjectionManifestProofEvidence(manifest: ArchitectureDocsProjectionManifestV4): ArchitectureProjectionProofEvidenceV2 {
363
312
  return {
364
313
  rendererVersion: manifest.rendererVersion,
365
- selectorEvidenceDigests: Object.fromEntries(manifest.semanticBaseline.capabilities.map((capability) => [capability.capabilityId, capability.selectorEvidenceDigest])),
366
- sourceStamps: architectureDocsProjectionManifestSourceStamps(manifest)
314
+ selectorEvidenceDigests: Object.fromEntries(manifest.semanticBaseline.capabilities.map((capability) => [capability.capabilityId, capability.selectorEvidenceDigest]))
367
315
  };
368
316
  }
369
317
 
370
318
  /**
371
- * The declared source tree digest: the digest of every footprint stamp, by node id. Runtime
372
- * provenance and the read-time value of a committed manifest use this one formula, so they agree
373
- * exactly when every stamp agrees.
319
+ * The declared source tree digest of runtime provenance: the digest of every node's footprint
320
+ * digest, by node id. It binds the CodeGraph index and the expected snapshot to the measured tree
321
+ * and is never committed (ADR-0056 §4).
374
322
  */
375
- export function architectureSourceStampsDigest(stamps: Readonly<Record<string, string>>): Sha256Digest {
323
+ export function architectureSourceTreeDigest(footprintDigests: Readonly<Record<string, string>>): Sha256Digest {
376
324
  return digestJson({
377
325
  schemaVersion: "archcontext.architecture-source-stamps/v1",
378
- stamps: Object.keys(stamps).sort(compareStrings).map((nodeId) => ({ nodeId, digest: stamps[nodeId]! }))
326
+ stamps: Object.keys(footprintDigests).sort(compareStrings).map((nodeId) => ({ nodeId, digest: footprintDigests[nodeId]! }))
379
327
  } as unknown as Json) as Sha256Digest;
380
328
  }
381
329
 
@@ -394,10 +342,9 @@ export function architectureProjectionOutputsDigest(input: {
394
342
  }
395
343
 
396
344
  /** The global digests of a committed manifest, computed from its rows at read time. */
397
- export function architectureDocsProjectionManifestDigests(manifest: ArchitectureDocsProjectionManifestV3): ArchitectureDigestSetV1 {
345
+ export function architectureDocsProjectionManifestDigests(manifest: ArchitectureDocsProjectionManifestV4): ArchitectureDigestSetV2 {
398
346
  return {
399
347
  modelDigest: manifest.semanticBaseline.modelDigest as Sha256Digest,
400
- sourceTreeDigest: architectureSourceStampsDigest(architectureDocsProjectionManifestSourceStamps(manifest)),
401
348
  flowProofDigest: architectureDocsProjectionManifestSemanticState(manifest).flowProofFingerprint as Sha256Digest,
402
349
  projectionDigest: architectureProjectionOutputsDigest({
403
350
  rendererVersion: manifest.rendererVersion,
@@ -463,7 +410,7 @@ function generatedFromIssues(value: unknown, prefix: string): string[] {
463
410
  return issues;
464
411
  }
465
412
 
466
- function canonicalCapability(capability: ArchitectureDocsProjectionManifestCapabilityV3): ArchitectureDocsProjectionManifestCapabilityV3 {
413
+ function canonicalCapability(capability: ArchitectureDocsProjectionManifestCapabilityV4): ArchitectureDocsProjectionManifestCapabilityV4 {
467
414
  return {
468
415
  capabilityId: capability.capabilityId,
469
416
  memberNodeIds: [...capability.memberNodeIds],
@@ -475,7 +422,7 @@ function canonicalCapability(capability: ArchitectureDocsProjectionManifestCapab
475
422
  };
476
423
  }
477
424
 
478
- function canonicalTargetRow(row: ArchitectureDocsProjectionManifestTargetV3): ArchitectureDocsProjectionManifestTargetV3 {
425
+ function canonicalTargetRow(row: ArchitectureDocsProjectionManifestTargetV4): ArchitectureDocsProjectionManifestTargetV4 {
479
426
  return {
480
427
  type: row.type,
481
428
  scope: {
@@ -486,41 +433,14 @@ function canonicalTargetRow(row: ArchitectureDocsProjectionManifestTargetV3): Ar
486
433
  path: row.path,
487
434
  ownership: row.ownership,
488
435
  format: row.format,
489
- outputDigest: row.outputDigest,
490
- ...(row.sourceStamps !== undefined
491
- ? { sourceStamps: Object.fromEntries(Object.keys(row.sourceStamps).sort(compareStrings).map((nodeId) => [nodeId, row.sourceStamps![nodeId]!])) }
492
- : {}),
493
- ...(row.scale !== undefined
494
- ? {
495
- scale: {
496
- fileCountBucket: { lower: row.scale.fileCountBucket.lower, upper: row.scale.fileCountBucket.upper },
497
- lineCountBucket: { lower: row.scale.lineCountBucket.lower, upper: row.scale.lineCountBucket.upper }
498
- }
499
- }
500
- : {})
436
+ outputDigest: row.outputDigest
501
437
  };
502
438
  }
503
439
 
504
- /** True when the value is a valid 1–2–5 magnitude bucket (see ArchitectureScaleBucketV1). */
505
- export function isArchitectureScaleBucket(value: unknown): value is ArchitectureScaleBucketV1 {
506
- const bucket = record(value);
507
- if (!bucket || Object.keys(bucket).length !== 2) return false;
508
- const { lower, upper } = bucket;
509
- if (typeof lower !== "number" || typeof upper !== "number" || !Number.isSafeInteger(lower) || !Number.isSafeInteger(upper)) return false;
510
- if (lower === 0) return upper === 1;
511
- let magnitude = 1;
512
- while (magnitude * 10 <= lower) magnitude *= 10;
513
- const mantissa = lower / magnitude;
514
- if (mantissa === 1) return upper === 2 * magnitude;
515
- if (mantissa === 2) return upper === 5 * magnitude;
516
- if (mantissa === 5) return upper === 10 * magnitude;
517
- return false;
518
- }
519
-
520
440
  function manifestTargetIssues(value: unknown, prefix: string): string[] {
521
441
  const target = record(value);
522
442
  if (!target) return [`${prefix} must be an object`];
523
- const issues = exactKeys(target, ["type", "scope", "path", "ownership", "format", "outputDigest"], ["sourceStamps", "scale"], prefix);
443
+ const issues = exactKeys(target, ["type", "scope", "path", "ownership", "format", "outputDigest"], [], prefix);
524
444
  if (typeof target.type !== "string" || !Object.hasOwn(TARGET_TYPES, target.type)) issues.push(`${prefix}.type is unsupported`);
525
445
  const scope = record(target.scope);
526
446
  if (!scope || typeof scope.kind !== "string" || !Object.hasOwn(SCOPE_KINDS, scope.kind)) issues.push(`${prefix}.scope.kind is unsupported`);
@@ -534,32 +454,9 @@ function manifestTargetIssues(value: unknown, prefix: string): string[] {
534
454
  if (typeof target.ownership !== "string" || !Object.hasOwn(OWNERSHIPS, target.ownership)) issues.push(`${prefix}.ownership is unsupported`);
535
455
  if (typeof target.format !== "string" || !Object.hasOwn(FORMATS, target.format)) issues.push(`${prefix}.format is unsupported`);
536
456
  if (!isDigest(target.outputDigest)) issues.push(`${prefix}.outputDigest must be a SHA-256 digest`);
537
- if (target.sourceStamps !== undefined && target.type !== "entity-summary" && !isRuntimeTopologyTargetType(target.type)) {
538
- issues.push(`${prefix}.sourceStamps are only allowed on entity-summary and runtime topology targets`);
539
- }
540
- if (target.scale !== undefined && target.type !== "entity-summary") issues.push(`${prefix}.scale is only allowed on entity-summary targets`);
541
- if (target.sourceStamps !== undefined) {
542
- const stamps = record(target.sourceStamps);
543
- if (!stamps || Object.keys(stamps).length === 0) issues.push(`${prefix}.sourceStamps must be a non-empty object keyed by node id`);
544
- else {
545
- for (const [nodeId, digest] of Object.entries(stamps)) {
546
- if (!isNonEmptyString(nodeId)) issues.push(`${prefix}.sourceStamps keys must be non-empty node ids`);
547
- if (!isDigest(digest)) issues.push(`${prefix}.sourceStamps.${nodeId} must be a SHA-256 digest`);
548
- }
549
- }
550
- }
551
- const ownNodeId = scope?.id;
552
- const stampsOwnNode = typeof ownNodeId === "string" && record(target.sourceStamps) !== undefined && Object.hasOwn(record(target.sourceStamps)!, ownNodeId);
553
- if (stampsOwnNode !== (target.scale !== undefined)) issues.push(`${prefix}.scale must be present exactly when sourceStamps stamps the target's own node`);
554
- if (target.scale !== undefined) {
555
- const scale = record(target.scale);
556
- if (!scale) issues.push(`${prefix}.scale must be an object`);
557
- else {
558
- issues.push(...exactKeys(scale, ["fileCountBucket", "lineCountBucket"], [], `${prefix}.scale`));
559
- for (const field of ["fileCountBucket", "lineCountBucket"] as const) {
560
- if (!isArchitectureScaleBucket(scale[field])) issues.push(`${prefix}.scale.${field} must be a 1-2-5 magnitude bucket`);
561
- }
562
- }
457
+ if (target.type === "agent-context"
458
+ && (target.ownership !== "mixed" || target.format !== "markdown" || scope?.kind !== "entity" || !isNonEmptyString(scope.id))) {
459
+ issues.push(`${prefix} agent-context rows must be mixed, markdown and entity-scoped with an id`);
563
460
  }
564
461
  return issues;
565
462
  }
@@ -599,7 +496,11 @@ function versionNumber(value: unknown, family: string): number | undefined {
599
496
  return Number.isSafeInteger(version) ? version : undefined;
600
497
  }
601
498
 
602
- /** Pure engine compatibility; absent floors retain the v3 behavior. Future formats never rebaseline. */
499
+ /**
500
+ * Pure engine compatibility; absent floors retain the v3 behavior. Future formats never rebaseline.
501
+ * Floors require a current or superseded declared schema. A superseded manifest's floors are
502
+ * evaluated against this engine, as v4 floors are; they only decide whether this engine may replace it.
503
+ */
603
504
  export function architectureDocsProjectionCompatibilityIssues(value: unknown, engine: { rendererVersion: string; protocolVersion: string } = {
604
505
  rendererVersion: ARCHITECTURE_DOCS_RENDERER_VERSION, protocolVersion: PROJECTION_REQUEST_SCHEMA_VERSION
605
506
  }): string[] {
@@ -607,7 +508,10 @@ export function architectureDocsProjectionCompatibilityIssues(value: unknown, en
607
508
  if (!manifest) return [];
608
509
  const issues: string[] = [];
609
510
  if (["minimumRendererVersion", "minimumProtocolVersion"].some(key => Object.hasOwn(manifest, key))
610
- && manifest.schemaVersion !== ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION) issues.push("projection manifest floors require the current schema");
511
+ && manifest.schemaVersion !== ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION
512
+ && !(typeof manifest.schemaVersion === "string" && isSupersededArchitectureDocsProjectionManifestSchemaVersion(manifest.schemaVersion))) {
513
+ issues.push("projection manifest floors require a current or superseded schema");
514
+ }
611
515
  if (typeof manifest.schemaVersion === "string" && manifest.schemaVersion !== ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION
612
516
  && !isSupersededArchitectureDocsProjectionManifestSchemaVersion(manifest.schemaVersion)) issues.push("projection manifest schema is unsupported by this engine");
613
517
  for (const [key, family, current] of [
@@ -62,7 +62,7 @@ export interface ProjectionPublishRunV1 {
62
62
  publisher: ProjectionPublisherKind;
63
63
  /** Repository-relative generated paths the published commit changes, sorted. */
64
64
  files: string[];
65
- /** `ProjectionResultV2.status` of the apply this run made, or null without one. */
65
+ /** `ProjectionResultV3.status` of the apply this run made, or null without one. */
66
66
  projectionStatus: string | null;
67
67
  humanActions: ProjectionPublishHumanActionV1[];
68
68
  error: { code: string; reasonCode?: string; message: string; severity?: "notice" | "warning" | "error" | "critical"; retryable?: boolean; action?: string; details?: { [key: string]: Json } } | null;