archctx-contracts 0.13.0 → 0.14.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/fixtures/invalid/projection-result-applied-incomplete-coverage.json +2 -2
- package/fixtures/valid/archctx-capabilities.json +5 -5
- package/fixtures/valid/architecture-refresh-signal.json +1 -3
- package/fixtures/valid/product-version-manifest.json +5 -5
- package/fixtures/valid/projection-manifest.json +2 -4
- package/fixtures/valid/projection-request.json +1 -1
- package/fixtures/valid/projection-result.json +2 -2
- package/fixtures/valid/state-machine-check.json +6 -2
- package/package.json +1 -1
- package/schemas/runtime/archctx-capabilities.schema.json +4 -4
- package/schemas/runtime/architecture-refresh-signal.schema.json +3 -4
- package/schemas/runtime/projection-apply-readback.schema.json +41 -41
- package/schemas/runtime/projection-apply-recovery.schema.json +7 -8
- package/schemas/runtime/projection-manifest.schema.json +21 -108
- package/schemas/runtime/projection-publish-run.schema.json +1 -1
- package/schemas/runtime/projection-request.schema.json +1 -1
- package/schemas/runtime/projection-result.schema.json +20 -21
- package/schemas/runtime/projection-target.schema.json +2 -2
- package/schemas/runtime/state-machine-check.schema.json +20 -2
- package/src/architecture-history.ts +8 -0
- package/src/failure.ts +16 -7
- package/src/ledger.ts +2 -2
- package/src/product-version.ts +1 -1
- package/src/projection-manifest.ts +53 -156
- package/src/projection-writer.ts +1 -1
- package/src/projection.ts +122 -99
- package/src/state-machine.ts +16 -11
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://archcontext.dev/schemas/runtime/projection-manifest.schema.json",
|
|
4
|
-
"title": "
|
|
5
|
-
"description": "The committed docs/architecture/.projection-manifest.json the architecture documentation projection writes (#264, #327). Version
|
|
4
|
+
"title": "ArchitectureDocsProjectionManifestV4",
|
|
5
|
+
"description": "The committed docs/architecture/.projection-manifest.json the architecture documentation projection writes (#264, #327, ADR-0056). Version v4 records no digest of raw source: a target row holds only what the render produced, and its outputDigest is the target's freshness identity, so a source edit that changes no output, no proof evidence and no header line leaves the file byte-identical. Header lines change only on a protocol upgrade, semanticBaseline.modelDigest is the one Git-visible anchor, and every other value belongs to one capability or one target row, so changes to different capabilities rewrite disjoint lines. A v1, v2 or v3 manifest is not valid against this schema and is refused with projection-manifest-upgrade-required. Sorted/unique orders and the byte layout are enforced by architectureDocsProjectionManifestIssues and serializeArchitectureDocsProjectionManifest.",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"additionalProperties": false,
|
|
8
8
|
"required": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"properties": {
|
|
18
18
|
"schemaVersion": {
|
|
19
|
-
"const": "archcontext.architecture-docs-projection-manifest/
|
|
19
|
+
"const": "archcontext.architecture-docs-projection-manifest/v4"
|
|
20
20
|
},
|
|
21
21
|
"rendererVersion": {
|
|
22
22
|
"type": "string",
|
|
@@ -208,41 +208,6 @@
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
},
|
|
211
|
-
"scaleBucket": {
|
|
212
|
-
"type": "object",
|
|
213
|
-
"additionalProperties": false,
|
|
214
|
-
"required": [
|
|
215
|
-
"lower",
|
|
216
|
-
"upper"
|
|
217
|
-
],
|
|
218
|
-
"description": "The half-open 1-2-5 magnitude range [lower, upper) that contains a measured count; {lower: 0, upper: 1} holds only zero.",
|
|
219
|
-
"properties": {
|
|
220
|
-
"lower": {
|
|
221
|
-
"type": "integer",
|
|
222
|
-
"minimum": 0
|
|
223
|
-
},
|
|
224
|
-
"upper": {
|
|
225
|
-
"type": "integer",
|
|
226
|
-
"minimum": 1
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
"scale": {
|
|
231
|
-
"type": "object",
|
|
232
|
-
"additionalProperties": false,
|
|
233
|
-
"required": [
|
|
234
|
-
"fileCountBucket",
|
|
235
|
-
"lineCountBucket"
|
|
236
|
-
],
|
|
237
|
-
"properties": {
|
|
238
|
-
"fileCountBucket": {
|
|
239
|
-
"$ref": "#/$defs/scaleBucket"
|
|
240
|
-
},
|
|
241
|
-
"lineCountBucket": {
|
|
242
|
-
"$ref": "#/$defs/scaleBucket"
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
211
|
"target": {
|
|
247
212
|
"type": "object",
|
|
248
213
|
"additionalProperties": false,
|
|
@@ -254,7 +219,21 @@
|
|
|
254
219
|
"format",
|
|
255
220
|
"outputDigest"
|
|
256
221
|
],
|
|
257
|
-
"description": "One target row, keyed by its targetId. The key and the manifest header carry the targetId and the renderer version, so the row repeats neither.",
|
|
222
|
+
"description": "One target row, keyed by its targetId. The key and the manifest header carry the targetId and the renderer version, so the row repeats neither. An agent-context row owns one node's region in a contract file, so it is mixed, markdown and entity-scoped with an id, and several agent-context rows may share a path when their scope ids differ.",
|
|
223
|
+
"if": {
|
|
224
|
+
"properties": { "type": { "const": "agent-context" } },
|
|
225
|
+
"required": ["type"]
|
|
226
|
+
},
|
|
227
|
+
"then": {
|
|
228
|
+
"properties": {
|
|
229
|
+
"ownership": { "const": "mixed" },
|
|
230
|
+
"format": { "const": "markdown" },
|
|
231
|
+
"scope": {
|
|
232
|
+
"properties": { "kind": { "const": "entity" }, "id": { "type": "string", "minLength": 1 } },
|
|
233
|
+
"required": ["kind", "id"]
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
},
|
|
258
237
|
"properties": {
|
|
259
238
|
"type": {
|
|
260
239
|
"enum": [
|
|
@@ -262,12 +241,12 @@
|
|
|
262
241
|
"entity-summary",
|
|
263
242
|
"relation-summary",
|
|
264
243
|
"decision-index",
|
|
265
|
-
"architecture-changelog",
|
|
266
244
|
"diagram-mermaid",
|
|
267
245
|
"diagram-structurizr",
|
|
268
246
|
"diagram-likec4",
|
|
269
247
|
"diagram-runtime-topology",
|
|
270
248
|
"runtime-topology-summary",
|
|
249
|
+
"architecture-history",
|
|
271
250
|
"agent-context"
|
|
272
251
|
]
|
|
273
252
|
},
|
|
@@ -284,8 +263,7 @@
|
|
|
284
263
|
"entity",
|
|
285
264
|
"relation",
|
|
286
265
|
"decision",
|
|
287
|
-
"diagram"
|
|
288
|
-
"changelog"
|
|
266
|
+
"diagram"
|
|
289
267
|
]
|
|
290
268
|
},
|
|
291
269
|
"id": {
|
|
@@ -329,73 +307,8 @@
|
|
|
329
307
|
},
|
|
330
308
|
"outputDigest": {
|
|
331
309
|
"$ref": "#/$defs/digest"
|
|
332
|
-
},
|
|
333
|
-
"sourceStamps": {
|
|
334
|
-
"type": "object",
|
|
335
|
-
"description": "entity-summary and runtime topology targets only: the content digest of every declared source footprint this target documents, by node id. A footprint belongs to its node's nearest ancestor-or-self with an entity-summary target, so it is stamped on exactly one entity-summary row; a runtime topology node's footprint is stamped on every runtime topology row instead, and those rows carry identical stamps (ADR-0049).",
|
|
336
|
-
"additionalProperties": {
|
|
337
|
-
"$ref": "#/$defs/digest"
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
"scale": {
|
|
341
|
-
"$ref": "#/$defs/scale",
|
|
342
|
-
"description": "Present exactly when sourceStamps stamps the target's own node."
|
|
343
|
-
}
|
|
344
|
-
},
|
|
345
|
-
"allOf": [
|
|
346
|
-
{
|
|
347
|
-
"if": {
|
|
348
|
-
"required": [
|
|
349
|
-
"scale"
|
|
350
|
-
]
|
|
351
|
-
},
|
|
352
|
-
"then": {
|
|
353
|
-
"required": [
|
|
354
|
-
"sourceStamps"
|
|
355
|
-
]
|
|
356
|
-
}
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
"if": {
|
|
360
|
-
"properties": {
|
|
361
|
-
"type": {
|
|
362
|
-
"not": {
|
|
363
|
-
"enum": [
|
|
364
|
-
"entity-summary",
|
|
365
|
-
"diagram-runtime-topology",
|
|
366
|
-
"runtime-topology-summary"
|
|
367
|
-
]
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
"then": {
|
|
373
|
-
"not": {
|
|
374
|
-
"required": [
|
|
375
|
-
"sourceStamps"
|
|
376
|
-
]
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
"if": {
|
|
382
|
-
"properties": {
|
|
383
|
-
"type": {
|
|
384
|
-
"not": {
|
|
385
|
-
"const": "entity-summary"
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
},
|
|
390
|
-
"then": {
|
|
391
|
-
"not": {
|
|
392
|
-
"required": [
|
|
393
|
-
"scale"
|
|
394
|
-
]
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
310
|
}
|
|
398
|
-
|
|
311
|
+
}
|
|
399
312
|
}
|
|
400
313
|
}
|
|
401
314
|
}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"publisher": { "enum": ["command", "gh", "none"] },
|
|
32
32
|
"files": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 }, "description": "Repository-relative generated paths the published commit changes, sorted. Paths only, never contents." },
|
|
33
|
-
"projectionStatus": { "type": ["string", "null"], "description": "
|
|
33
|
+
"projectionStatus": { "type": ["string", "null"], "description": "ProjectionResultV3.status of the apply this run made, or null without one." },
|
|
34
34
|
"humanActions": {
|
|
35
35
|
"type": "array",
|
|
36
36
|
"items": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"minItems": 1,
|
|
16
16
|
"uniqueItems": true,
|
|
17
17
|
"description": "Canonical wire order is lexicographic and is enforced by projectionRequestInvariantIssues.",
|
|
18
|
-
"items": { "enum": ["agent-context", "architecture-docs"] }
|
|
18
|
+
"items": { "enum": ["agent-context", "architecture-docs", "architecture-history"] }
|
|
19
19
|
},
|
|
20
20
|
"changedPaths": {
|
|
21
21
|
"type": "array",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://archcontext.dev/schemas/runtime/projection-result.schema.json",
|
|
4
|
-
"title": "
|
|
4
|
+
"title": "ProjectionResultV3",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"additionalProperties": false,
|
|
7
7
|
"required": ["schemaVersion", "requestId", "status", "inputSnapshot", "outputSnapshot", "affectedNodeIds", "files", "humanActions", "refreshSignals", "receiptDigest"],
|
|
8
8
|
"properties": {
|
|
9
|
-
"schemaVersion": { "const": "archcontext.projection-result/
|
|
9
|
+
"schemaVersion": { "const": "archcontext.projection-result/v3" },
|
|
10
10
|
"requestId": { "type": "string", "pattern": "^[a-zA-Z0-9_.:-]+$", "minLength": 1 },
|
|
11
11
|
"status": { "enum": ["adoption-required", "applied", "applied-partial", "applied-reconcile-required", "blocked", "human-action-required", "noop", "permanent-failure", "planned", "planned-partial", "retryable-failure"] },
|
|
12
12
|
"inputSnapshot": { "$ref": "#/$defs/snapshot" },
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"priorCommittedApplies": { "type": "array", "minItems": 1, "description": "Omitted, never empty. Canonical wire order is by changeSetId and is enforced by projectionResultInvariantIssues.", "items": { "$ref": "#/$defs/priorCommittedApply" } },
|
|
20
20
|
"freshness": { "$ref": "#/$defs/freshness" },
|
|
21
21
|
"architectureDebt": { "$ref": "#/$defs/architectureDebt" },
|
|
22
|
-
"changes": { "type": "array", "description": "Present on every check and plan result and on no other. One entry per target
|
|
22
|
+
"changes": { "type": "array", "description": "Present on every check and plan result and on no other. One entry per target, the projection manifest excluded; targetId is unique, and only agent-context targets share a path (ADR-0056 §9). Canonical wire order is by path, then targetId; the precedence derivation of classification, the reason-code couplings and the binding of plannedAction to files[] and of blocked targets to coverage are enforced by projectionTargetChangesIssues and projectionResultInvariantIssues.", "items": { "$ref": "#/$defs/targetChange" } },
|
|
23
23
|
"replayed": { "const": true, "description": "A repeated apply for the same requestId and request digest returned the committed result without applying again. Excluded from receiptDigest." },
|
|
24
24
|
"written": { "type": "boolean", "description": "Present exactly when replayed is. false: the replay wrote nothing. true: the projection-owned outputs differed from the approved result at the approved snapshot and the replay wrote the committed fixed point again under the original receipt. Excluded from receiptDigest." },
|
|
25
25
|
"majorChangeAcceptance": { "const": "declined-unprovable-proof", "description": "Present only when the request sent acceptObservedMajorChange and the provider declined it because a capability proof is unprovable; humanActions then carries unprovable-required-flow instead of unresolved-major-change." },
|
|
@@ -176,10 +176,9 @@
|
|
|
176
176
|
"digestSet": {
|
|
177
177
|
"type": "object",
|
|
178
178
|
"additionalProperties": false,
|
|
179
|
-
"required": ["modelDigest", "
|
|
179
|
+
"required": ["modelDigest", "flowProofDigest", "projectionDigest"],
|
|
180
180
|
"properties": {
|
|
181
181
|
"modelDigest": { "$ref": "#/$defs/digest" },
|
|
182
|
-
"sourceTreeDigest": { "$ref": "#/$defs/digest" },
|
|
183
182
|
"flowProofDigest": { "$ref": "#/$defs/digest" },
|
|
184
183
|
"projectionDigest": { "$ref": "#/$defs/digest" }
|
|
185
184
|
}
|
|
@@ -213,7 +212,7 @@
|
|
|
213
212
|
"additionalProperties": false,
|
|
214
213
|
"required": ["schemaVersion", "signalId", "idempotencyKey", "mode", "repository", "worktree", "cause", "reasonCodes", "affectedNodeIds", "refreshTargets", "baseDigests", "resultingDigests", "projectionReceiptDigest"],
|
|
215
214
|
"properties": {
|
|
216
|
-
"schemaVersion": { "const": "archcontext.architecture-refresh-signal/
|
|
215
|
+
"schemaVersion": { "const": "archcontext.architecture-refresh-signal/v2" },
|
|
217
216
|
"signalId": { "$ref": "#/$defs/digest" },
|
|
218
217
|
"idempotencyKey": { "$ref": "#/$defs/digest" },
|
|
219
218
|
"mode": { "enum": ["human-action-required", "refresh-required"] },
|
|
@@ -260,25 +259,26 @@
|
|
|
260
259
|
"freshness": {
|
|
261
260
|
"type": "object",
|
|
262
261
|
"additionalProperties": false,
|
|
263
|
-
"description": "Present on check results only. Canonical wire orders and the ok/reasonCodes/
|
|
264
|
-
"required": ["ok", "reasonCodes", "
|
|
262
|
+
"description": "Present on check results only: render-equivalent freshness (ADR-0056 §1). Canonical wire orders and the ok/reasonCodes/staleTargets coupling are enforced by projectionResultInvariantIssues.",
|
|
263
|
+
"required": ["ok", "reasonCodes", "staleTargets"],
|
|
265
264
|
"properties": {
|
|
266
265
|
"ok": { "type": "boolean" },
|
|
267
266
|
"reasonCodes": {
|
|
268
267
|
"type": "array",
|
|
269
268
|
"uniqueItems": true,
|
|
270
|
-
"items": { "enum": ["projection-manifest-
|
|
269
|
+
"items": { "enum": ["projection-manifest-changed", "projection-manifest-missing", "projection-manifest-unreadable", "projection-output-changed"] }
|
|
271
270
|
},
|
|
272
|
-
"
|
|
271
|
+
"staleTargets": {
|
|
273
272
|
"type": "array",
|
|
274
273
|
"items": {
|
|
275
274
|
"type": "object",
|
|
276
275
|
"additionalProperties": false,
|
|
277
|
-
"required": ["
|
|
276
|
+
"required": ["targetId", "path", "committedOutputDigest", "renderedOutputDigest"],
|
|
278
277
|
"properties": {
|
|
279
|
-
"
|
|
280
|
-
"
|
|
281
|
-
"
|
|
278
|
+
"targetId": { "type": "string", "minLength": 1 },
|
|
279
|
+
"path": { "type": "string", "minLength": 1 },
|
|
280
|
+
"committedOutputDigest": { "anyOf": [{ "$ref": "#/$defs/digest" }, { "type": "null" }] },
|
|
281
|
+
"renderedOutputDigest": { "anyOf": [{ "$ref": "#/$defs/digest" }, { "type": "null" }] }
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
}
|
|
@@ -317,8 +317,8 @@
|
|
|
317
317
|
"targetChange": {
|
|
318
318
|
"type": "object",
|
|
319
319
|
"additionalProperties": false,
|
|
320
|
-
"description": "How one target changes since the committed projection and what this run's write does to its file (#327). null is an unknown comparison. classification follows blocked > proof-change (a known proof change) > baseline-missing > semantic-change > output-change >
|
|
321
|
-
"required": ["targetId", "path", "affectedCapabilityIds", "
|
|
320
|
+
"description": "How one target changes since the committed projection and what this run's write does to its file (#327). null is an unknown comparison. classification follows blocked > proof-change (a known proof change) > baseline-missing > semantic-change > output-change > unchanged.",
|
|
321
|
+
"required": ["targetId", "path", "affectedCapabilityIds", "outputChanged", "semanticChanged", "proofChanged", "plannedAction", "classification", "reasonCodes"],
|
|
322
322
|
"properties": {
|
|
323
323
|
"targetId": { "type": "string", "minLength": 1 },
|
|
324
324
|
"path": {
|
|
@@ -327,16 +327,15 @@
|
|
|
327
327
|
"not": { "anyOf": [{ "pattern": "^/" }, { "pattern": "\\\\" }, { "pattern": "(^|/)\\.\\.(/|$)" }] }
|
|
328
328
|
},
|
|
329
329
|
"affectedCapabilityIds": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
|
|
330
|
-
"stampChanged": { "type": ["boolean", "null"] },
|
|
331
330
|
"outputChanged": { "type": "boolean" },
|
|
332
331
|
"semanticChanged": { "type": ["boolean", "null"] },
|
|
333
332
|
"proofChanged": { "type": ["boolean", "null"] },
|
|
334
333
|
"plannedAction": { "enum": ["create", "delete", "none", "update"] },
|
|
335
|
-
"classification": { "enum": ["baseline-missing", "blocked", "output-change", "proof-change", "semantic-change", "
|
|
334
|
+
"classification": { "enum": ["baseline-missing", "blocked", "output-change", "proof-change", "semantic-change", "unchanged"] },
|
|
336
335
|
"reasonCodes": {
|
|
337
336
|
"type": "array",
|
|
338
337
|
"uniqueItems": true,
|
|
339
|
-
"items": { "enum": ["adoption-required", "ambiguous-ownership", "baseline-missing", "file-bytes-changed", "flow-proof-changed", "model-digest-changed", "orphan-review-required", "rendered-output-changed", "selector-evidence-changed", "semantic-fingerprint-changed", "
|
|
338
|
+
"items": { "enum": ["adoption-required", "ambiguous-ownership", "baseline-missing", "file-bytes-changed", "flow-proof-changed", "model-digest-changed", "orphan-review-required", "rendered-output-changed", "selector-evidence-changed", "semantic-fingerprint-changed", "target-added", "target-removed", "target-row-missing", "unprovable-required-flow", "verified-flow-proof-changed"] }
|
|
340
339
|
}
|
|
341
340
|
},
|
|
342
341
|
"allOf": [
|
|
@@ -345,8 +344,8 @@
|
|
|
345
344
|
"then": { "properties": { "plannedAction": { "const": "none" } } }
|
|
346
345
|
},
|
|
347
346
|
{
|
|
348
|
-
"if": { "properties": { "classification": { "
|
|
349
|
-
"then": { "properties": { "plannedAction": { "const": "none" }, "outputChanged": { "const": false }, "
|
|
347
|
+
"if": { "properties": { "classification": { "const": "unchanged" } }, "required": ["classification"] },
|
|
348
|
+
"then": { "properties": { "plannedAction": { "const": "none" }, "outputChanged": { "const": false }, "semanticChanged": { "const": false }, "proofChanged": { "const": false } } }
|
|
350
349
|
},
|
|
351
350
|
{
|
|
352
351
|
"if": { "properties": { "classification": { "const": "unchanged" } }, "required": ["classification"] },
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"targetId": { "type": "string", "pattern": "^projection_target\\.[a-zA-Z0-9_.-]+$" },
|
|
14
14
|
"type": {
|
|
15
15
|
"type": "string",
|
|
16
|
-
"enum": ["architecture-index", "entity-summary", "relation-summary", "decision-index", "
|
|
16
|
+
"enum": ["architecture-index", "entity-summary", "relation-summary", "decision-index", "diagram-mermaid", "diagram-structurizr", "diagram-likec4", "diagram-runtime-topology", "runtime-topology-summary", "architecture-history", "agent-context"]
|
|
17
17
|
},
|
|
18
18
|
"scope": {
|
|
19
19
|
"type": "object",
|
|
20
20
|
"additionalProperties": false,
|
|
21
21
|
"required": ["kind"],
|
|
22
22
|
"properties": {
|
|
23
|
-
"kind": { "type": "string", "enum": ["repository", "entity", "relation", "decision", "diagram"
|
|
23
|
+
"kind": { "type": "string", "enum": ["repository", "entity", "relation", "decision", "diagram"] },
|
|
24
24
|
"id": { "type": "string" },
|
|
25
25
|
"entityKind": { "type": "string" }
|
|
26
26
|
}
|
|
@@ -115,10 +115,28 @@
|
|
|
115
115
|
"path": { "type": "string", "minLength": 1 },
|
|
116
116
|
"symbol": { "type": "string", "minLength": 1 },
|
|
117
117
|
"status": { "enum": ["anchor-missing-path", "anchor-language-unsupported", "anchor-missing-symbol", "anchor-ambiguous-symbol", "unchecked", "anchor-unconfirmed", "anchor-changed", "confirmed"] },
|
|
118
|
-
"digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$", "description": "The file content, or the lines of the one matching declaration, with CRLF read as LF." },
|
|
119
|
-
"
|
|
118
|
+
"digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$", "description": "The file content, or a JSON array of the lines of the one matching declaration and of each direct callee, with CRLF read as LF." },
|
|
119
|
+
"callees": {
|
|
120
|
+
"description": "The direct callees that the digest of a symbol anchor covers, in digest order.",
|
|
121
|
+
"type": "array",
|
|
122
|
+
"items": {
|
|
123
|
+
"type": "object",
|
|
124
|
+
"additionalProperties": false,
|
|
125
|
+
"required": ["path", "qualifiedName"],
|
|
126
|
+
"properties": {
|
|
127
|
+
"path": { "type": "string", "minLength": 1 },
|
|
128
|
+
"qualifiedName": { "type": "string", "minLength": 1 }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"reason": { "enum": ["index-missing", "index-open-failed", "index-stale"], "description": "Why the symbol reader is unavailable, or that the index does not hold the current content of the anchor's file or of a callee's file." }
|
|
120
133
|
},
|
|
121
134
|
"allOf": [
|
|
135
|
+
{
|
|
136
|
+
"if": { "required": ["symbol", "digest"] },
|
|
137
|
+
"then": { "required": ["callees"] },
|
|
138
|
+
"else": { "not": { "required": ["callees"] } }
|
|
139
|
+
},
|
|
122
140
|
{
|
|
123
141
|
"if": { "properties": { "status": { "enum": ["anchor-unconfirmed", "anchor-changed", "confirmed"] } } },
|
|
124
142
|
"then": { "required": ["digest"] },
|
|
@@ -4,6 +4,14 @@ export const ARCHITECTURE_HISTORY_SCHEMA_VERSION = "archcontext.architecture-his
|
|
|
4
4
|
export const ARCHITECTURE_HISTORY_MERMAID_SCHEMA_VERSION = "archcontext.architecture-history-mermaid/v1" as const;
|
|
5
5
|
export const ARCHITECTURE_HISTORY_DERIVATION_VERSION = "v3" as const;
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Why a projection render reads the architecture history (ADR-0056 §8): the request names the
|
|
9
|
+
* `architecture-history` target, or the committed row cannot be carried forward because there is
|
|
10
|
+
* none, its file is missing, or its file does not digest to the row.
|
|
11
|
+
*/
|
|
12
|
+
export const ARCHITECTURE_HISTORY_READ_REASONS = ["target-named", "history-row-missing", "history-file-missing", "history-file-mismatch"] as const;
|
|
13
|
+
export type ArchitectureHistoryReadReason = (typeof ARCHITECTURE_HISTORY_READ_REASONS)[number];
|
|
14
|
+
|
|
7
15
|
export type HistoryErrorCode = "history-model-layout-unsupported" | "history-model-missing" | "history-model-invalid" | "history-model-too-large";
|
|
8
16
|
export interface HistoryNode { id: string; name: string; domain: string | null }
|
|
9
17
|
export interface HistoryEdge { source: string; target: string }
|
package/src/failure.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ARCHITECTURE_HISTORY_READ_REASONS } from "./architecture-history";
|
|
1
2
|
import { changeSetRecoveryDetailsSnapshot } from "./changeset-recovery";
|
|
2
3
|
import { isNativeError } from "node:util/types";
|
|
3
4
|
import { MODEL_VALIDATION_DIAGNOSTIC_CODES } from "./ports";
|
|
@@ -10,6 +11,9 @@ import { ERROR_CATALOG, canonicalize, isRepoRelativePosixPath, type ArchContextE
|
|
|
10
11
|
export type FailureCode = ArchContextErrorCode | "RPC_TIMEOUT" | "RPC_ABORTED";
|
|
11
12
|
export const FAILURE_STAGES = Object.freeze(["debt", "complete", "practice-checkpoint", "cli", "mcp", "hook-checkpoint", "failure-metadata", "public-operation", "native-export", "docs-anchors", "flows-check", "state-machines-check"] as const);
|
|
12
13
|
export type FailureStage = typeof FAILURE_STAGES[number];
|
|
14
|
+
/** The `issues` fact of `state-machine-model-invalid` holds at most this many issues, each of at most this many UTF-8 bytes. */
|
|
15
|
+
export const STATE_MACHINE_FAILURE_ISSUE_LIMIT = 16;
|
|
16
|
+
export const STATE_MACHINE_FAILURE_ISSUE_MAX_BYTES = 256;
|
|
13
17
|
const ERROR_CLASSES = Object.freeze(["Error", "TypeError", "RangeError", "SyntaxError", "ReferenceError", "URIError", "EvalError", "AggregateError", "NonError"]);
|
|
14
18
|
export interface StrictFailure<C extends FailureCode = FailureCode> {
|
|
15
19
|
code: C;
|
|
@@ -40,7 +44,7 @@ export const CODE_FACTS_ISSUE_MESSAGES = Object.freeze({
|
|
|
40
44
|
});
|
|
41
45
|
/** Each reason has a closed fact vocabulary. No source text or recovery binding is a summary fact. */
|
|
42
46
|
const policies: Record<string, Policy> = {
|
|
43
|
-
"history-shallow-repository": { code: "AC_PRECONDITION_FAILED", message: "Architecture history requires a complete Git repository.", action: "unshallow-repository" },
|
|
47
|
+
"history-shallow-repository": { code: "AC_PRECONDITION_FAILED", message: "Architecture history requires a complete Git repository.", action: "unshallow-repository", facts: { historyReadReason: "optional:historyReadReason" } },
|
|
44
48
|
"code-facts-read-not-ready": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "The existing CodeGraph index does not attest to the current source population.", facts: { issues: "codeFactsIssues" }, action: "codegraph-sync", retryable: false },
|
|
45
49
|
"code-facts-snapshot-changed": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "Source or index inputs changed while reading the private snapshot.", action: "retry-read", retryable: true, facts: {} },
|
|
46
50
|
"code-facts-snapshot-limit-exceeded": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "The private CodeGraph snapshot copy exceeds its 512 MiB or 100000 entry limit.", action: "reduce-snapshot-size", retryable: false, facts: { limit: "snapshotLimit", maxBytes: "uint", maxEntries: "uint", sourceBytes: "uint", sourceEntries: "uint", gitBytes: "uint", gitEntries: "uint", gitObjectEntries: "uint", indexBytes: "uint", indexEntries: "uint" } },
|
|
@@ -136,6 +140,7 @@ Object.assign(policies, {
|
|
|
136
140
|
"projection-adoption-profile-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Projection adoption profile invalid.", "facts": {}},
|
|
137
141
|
"projection-adoption-approval-input-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Projection adoption approval input invalid.", "facts": {}},
|
|
138
142
|
"agent-context-input-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Agent context input invalid.", "facts": {}},
|
|
143
|
+
"agent-context-owned-by-projection": {"code": "AC_PRECONDITION_FAILED", "message": "The committed projection manifest owns the agent-context contract files; run archctx docs apply or projection run instead.", "facts": {}},
|
|
139
144
|
"projection-readback-input-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Projection readback input invalid.", "facts": {}},
|
|
140
145
|
"projection-recovery-input-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Projection recovery input invalid.", "facts": {}},
|
|
141
146
|
"projection-readback-result-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Projection readback result invalid.", "facts": {"issueCount": "uint"}},
|
|
@@ -182,8 +187,6 @@ Object.assign(policies, {
|
|
|
182
187
|
"projection-check-mode-invalid": {"code": "AC_SCHEMA_INVALID","message": "Projection check mode invalid.","facts": {}},
|
|
183
188
|
"projection-check-input-invalid": {"code": "AC_SCHEMA_INVALID","message": "Projection check input invalid. Supply valid fields and keep lists sorted and unique.","facts": {}},
|
|
184
189
|
"projection-snapshot-mismatch": {"code": "AC_PRECONDITION_FAILED","message": "Projection snapshot mismatch.","facts": {"field":"optional:snapshotField"}},
|
|
185
|
-
"changed-path-outside-worktree": {"code": "AC_SCHEMA_INVALID","message": "Changed path outside worktree.","facts": {}},
|
|
186
|
-
"changed-path-not-normalized": {"code": "AC_SCHEMA_INVALID","message": "Changed path not normalized.","facts": {}},
|
|
187
190
|
"projection-result-invalid": {"code": "AC_SCHEMA_INVALID","message": "Projection result invalid.","facts": {}},
|
|
188
191
|
"repository-not-registered": {"code": "AC_REPO_NOT_FOUND","message": "Repository not registered.","facts": {}},
|
|
189
192
|
"landscape-invalid": {"code": "AC_SCHEMA_INVALID","message": "Landscape invalid.","facts": {}},
|
|
@@ -381,6 +384,7 @@ const localEnums: Readonly<Record<string, readonly string[]>> = {
|
|
|
381
384
|
upgradeAction: ["upgrade-archctx-runtime"],
|
|
382
385
|
upgradeCommand: ["archctx daemon upgrade"],
|
|
383
386
|
ownershipAction: ["remove-whole-file-outputs-and-reapply"],
|
|
387
|
+
historyReadReason: ARCHITECTURE_HISTORY_READ_REASONS,
|
|
384
388
|
projectionManifestPath: [ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH],
|
|
385
389
|
projectionManifestSchemaVersion: [...SUPERSEDED_ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSIONS, ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION],
|
|
386
390
|
projectionManifestUpgradeCommand: [ARCHITECTURE_DOCS_PROJECTION_MANIFEST_UPGRADE_COMMAND],
|
|
@@ -465,10 +469,10 @@ function localFactValue(rule: string, value: unknown): Json {
|
|
|
465
469
|
// `<path>: <field>: <invariant or schema message>`; issueCount and omittedCount count what does not fit.
|
|
466
470
|
if (!Array.isArray(value)) throw new Error("State machine issues must be an own list");
|
|
467
471
|
const length = Object.getOwnPropertyDescriptor(value, "length")?.value;
|
|
468
|
-
if (!Number.isSafeInteger(length) || length >
|
|
472
|
+
if (!Number.isSafeInteger(length) || length > STATE_MACHINE_FAILURE_ISSUE_LIMIT || Reflect.ownKeys(value).length !== length + 1) throw new Error("State machine issues exceed their closed budget");
|
|
469
473
|
return Array.from({ length }, (_, index) => {
|
|
470
474
|
const field = Object.getOwnPropertyDescriptor(value, String(index));
|
|
471
|
-
if (!field || !("value" in field) || typeof field.value !== "string" || bytes(field.value) >
|
|
475
|
+
if (!field || !("value" in field) || typeof field.value !== "string" || bytes(field.value) > STATE_MACHINE_FAILURE_ISSUE_MAX_BYTES) throw new Error("Invalid state machine issue");
|
|
472
476
|
return field.value;
|
|
473
477
|
});
|
|
474
478
|
}
|
|
@@ -729,6 +733,11 @@ function budgetIssues(value: unknown, depth = 0, maxStringBytes = 256): string[]
|
|
|
729
733
|
return value === null || typeof value === "boolean" ? [] : ["detail value is not JSON"];
|
|
730
734
|
}
|
|
731
735
|
type Attributes = Partial<Pick<StrictFailure, "action" | "severity" | "retryable">>;
|
|
736
|
+
/** A policy with one of these facts, optional or not, allows 1024 bytes for each detail string; any other policy allows 256. */
|
|
737
|
+
function hasExtendedFacts(policy: Policy): boolean {
|
|
738
|
+
return Object.values(policy.facts ?? {}).some(rule => ["publicConfirmationToken", "commandSuggestion", "diagnosticCommands"].includes(rule.replace(/^optional:/, "")));
|
|
739
|
+
}
|
|
740
|
+
|
|
732
741
|
export function knownFailure<C extends FailureCode>(code: C, reasonCode: string, details: unknown = {}, attributes: Attributes = {}): StrictFailure<C> {
|
|
733
742
|
// TypeScript types do not protect this runtime boundary. Do not coerce policy keys.
|
|
734
743
|
if (typeof code !== "string" || typeof reasonCode !== "string") throw new Error("Failure code/reason must be primitive strings");
|
|
@@ -758,7 +767,7 @@ export function knownFailure<C extends FailureCode>(code: C, reasonCode: string,
|
|
|
758
767
|
return { code, message: policy.message, severity, retryable, action, reasonCode, details: projectionRecoveryDetailsSnapshot(reasonCode, details) };
|
|
759
768
|
}
|
|
760
769
|
const safeDetails = detailsFor(policy, details);
|
|
761
|
-
const extendedFacts =
|
|
770
|
+
const extendedFacts = hasExtendedFacts(policy);
|
|
762
771
|
if (budgetIssues(safeDetails, 0, extendedFacts ? 1024 : 256).length || bytes(JSON.stringify(safeDetails)) > 8192 || bytes(policy.message) > 1024) throw new Error("Failure metadata exceeds its UTF-8 budget");
|
|
763
772
|
return { code, message: policy.message, severity, retryable, action, reasonCode, details: safeDetails };
|
|
764
773
|
}
|
|
@@ -859,7 +868,7 @@ export function failureIssues(value: unknown): string[] {
|
|
|
859
868
|
if ((prototype !== Object.prototype && prototype !== null) || keys.length !== fields.length || Object.keys(value).length !== fields.length || keys.some(key => typeof key !== "string" || !fields.includes(key))) return ["failure must match its closed registered contract"];
|
|
860
869
|
const data = Object.fromEntries(fields.map(key => [key, ownData(value, key)]));
|
|
861
870
|
const policy = typeof data.reasonCode === "string" ? policies[data.reasonCode] : undefined;
|
|
862
|
-
const extendedFacts = policy !== undefined && policy.code === data.code &&
|
|
871
|
+
const extendedFacts = policy !== undefined && policy.code === data.code && hasExtendedFacts(policy);
|
|
863
872
|
data.details = policy?.journalRecovery && policy.code === data.code ? changeSetRecoveryDetailsSnapshot(data.details) : policy?.recovery && policy.code === data.code ? projectionRecoveryDetailsSnapshot(data.reasonCode as string, data.details) : jsonDataSnapshot(data.details, 0, extendedFacts ? 1024 : 256);
|
|
864
873
|
if (typeof data.message !== "string" || bytes(data.message) > 1024 || bytes(JSON.stringify(data.details)) > (policy?.recovery || policy?.journalRecovery ? PROJECTION_RECOVERY_DETAILS_LIMIT_BYTES : 8192)) return ["failure exceeds byte/shape budget"];
|
|
865
874
|
const expected = failureFromData(data);
|
package/src/ledger.ts
CHANGED
|
@@ -146,14 +146,14 @@ export type ProjectionTargetType =
|
|
|
146
146
|
| "entity-summary"
|
|
147
147
|
| "relation-summary"
|
|
148
148
|
| "decision-index"
|
|
149
|
-
| "architecture-changelog"
|
|
150
149
|
| "diagram-mermaid"
|
|
151
150
|
| "diagram-structurizr"
|
|
152
151
|
| "diagram-likec4"
|
|
153
152
|
| "diagram-runtime-topology"
|
|
154
153
|
| "runtime-topology-summary"
|
|
154
|
+
| "architecture-history"
|
|
155
155
|
| "agent-context";
|
|
156
|
-
export type ProjectionTargetScopeKind = "repository" | "entity" | "relation" | "decision" | "diagram"
|
|
156
|
+
export type ProjectionTargetScopeKind = "repository" | "entity" | "relation" | "decision" | "diagram";
|
|
157
157
|
export type ProjectionTargetOwnership = "generated" | "mixed";
|
|
158
158
|
export type ProjectionTargetFormat = "markdown" | "mermaid" | "structurizr-json" | "likec4";
|
|
159
159
|
|
package/src/product-version.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const ARCHCONTEXT_PRODUCT_NAME = "archctx";
|
|
2
|
-
export const ARCHCONTEXT_PRODUCT_VERSION = "0.
|
|
2
|
+
export const ARCHCONTEXT_PRODUCT_VERSION = "0.14.0";
|
|
3
3
|
export const ARCHCONTEXT_PACKAGE_MANAGER = "bun@1.4.3";
|
|
4
4
|
export const ARCHCONTEXT_NODE_RANGE = ">=22.22 <26";
|
|
5
5
|
export const LOCAL_RUNTIME_RPC_SCHEMA_VERSION = "archcontext.runtime-rpc/v2";
|