archctx-contracts 0.12.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/hook-debt-checkpoint-failed-read.json +6 -1
- 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/architecture-state-machine.json +158 -0
- package/fixtures/valid/hook-debt-checkpoint.json +6 -1
- 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 +80 -0
- package/package.json +1 -1
- package/schemas/repo/architecture-state-machine.schema.json +153 -0
- package/schemas/runtime/archctx-capabilities.schema.json +4 -4
- package/schemas/runtime/architecture-debt.schema.json +6 -3
- 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 +181 -0
- package/src/architecture-debt.ts +2 -2
- package/src/architecture-history.ts +8 -0
- package/src/failure.ts +29 -6
- package/src/index.ts +1 -0
- 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 +280 -0
- package/src/validator.ts +7 -0
|
@@ -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
|
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://archcontext.dev/schemas/runtime/state-machine-check.schema.json",
|
|
4
|
+
"title": "StateMachineCheckV1",
|
|
5
|
+
"description": "The data of `archctx state-machines check`: for every declared state machine, the size of its reachable global state space, the result of each declared rule, the built-in breaks and the status of each code anchor. The same model gives the same bytes.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": ["schemaVersion", "machines"],
|
|
9
|
+
"properties": {
|
|
10
|
+
"schemaVersion": { "const": "archcontext.state-machine-check/v1" },
|
|
11
|
+
"machines": {
|
|
12
|
+
"description": "Sorted by machine id.",
|
|
13
|
+
"type": "array",
|
|
14
|
+
"items": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"additionalProperties": false,
|
|
17
|
+
"required": ["id", "capabilityId", "reachableStates", "transitions", "rules", "breaks", "anchors"],
|
|
18
|
+
"properties": {
|
|
19
|
+
"id": { "type": "string", "pattern": "^state-machine\\.[a-z][a-z0-9-]*(\\.[a-z0-9][a-z0-9-]*)*$" },
|
|
20
|
+
"capabilityId": { "type": "string", "pattern": "^capability\\.[a-z][a-z0-9-]*(\\.[a-z0-9][a-z0-9-]*)*$" },
|
|
21
|
+
"reachableStates": { "type": "integer", "minimum": 1 },
|
|
22
|
+
"transitions": { "type": "integer", "minimum": 0, "description": "Pairs of a reachable global state and an enabled step that changes it." },
|
|
23
|
+
"rules": {
|
|
24
|
+
"description": "In declaration order.",
|
|
25
|
+
"type": "array",
|
|
26
|
+
"items": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"required": ["id", "kind", "status"],
|
|
30
|
+
"properties": {
|
|
31
|
+
"id": { "$ref": "#/$defs/localId" },
|
|
32
|
+
"kind": { "enum": ["never", "final"] },
|
|
33
|
+
"status": { "enum": ["holds", "broken", "finding-open", "finding-resolved"] },
|
|
34
|
+
"tracking": { "type": "string", "pattern": "^https://[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)*(?::[0-9]{1,5})?(?:[/?#][^\\s]*)?$" },
|
|
35
|
+
"state": { "$ref": "#/$defs/globalState" },
|
|
36
|
+
"path": { "$ref": "#/$defs/path" },
|
|
37
|
+
"protectedBy": {
|
|
38
|
+
"description": "The guards whose removal breaks this holding rule, in declaration order of the guards.",
|
|
39
|
+
"type": "array",
|
|
40
|
+
"items": {
|
|
41
|
+
"type": "object",
|
|
42
|
+
"additionalProperties": false,
|
|
43
|
+
"required": ["event", "step", "region"],
|
|
44
|
+
"properties": {
|
|
45
|
+
"event": { "$ref": "#/$defs/localId" },
|
|
46
|
+
"step": { "$ref": "#/$defs/stepIndex" },
|
|
47
|
+
"region": { "$ref": "#/$defs/localId" }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"allOf": [
|
|
53
|
+
{
|
|
54
|
+
"if": { "properties": { "status": { "enum": ["broken", "finding-open"] } } },
|
|
55
|
+
"then": { "required": ["state", "path"], "not": { "required": ["protectedBy"] } },
|
|
56
|
+
"else": { "not": { "anyOf": [{ "required": ["state"] }, { "required": ["path"] }] } }
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"if": { "properties": { "status": { "enum": ["finding-open", "finding-resolved"] } } },
|
|
60
|
+
"then": { "required": ["tracking"] },
|
|
61
|
+
"else": { "not": { "required": ["tracking"] } }
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"breaks": {
|
|
67
|
+
"description": "Every unreachable state, then every dead step, each in declaration order, then at most one deadlock.",
|
|
68
|
+
"type": "array",
|
|
69
|
+
"items": {
|
|
70
|
+
"oneOf": [
|
|
71
|
+
{
|
|
72
|
+
"type": "object",
|
|
73
|
+
"additionalProperties": false,
|
|
74
|
+
"required": ["kind", "region", "state"],
|
|
75
|
+
"properties": {
|
|
76
|
+
"kind": { "const": "unreachable-state" },
|
|
77
|
+
"region": { "$ref": "#/$defs/localId" },
|
|
78
|
+
"state": { "$ref": "#/$defs/localId" }
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"type": "object",
|
|
83
|
+
"additionalProperties": false,
|
|
84
|
+
"required": ["kind", "event", "step"],
|
|
85
|
+
"properties": {
|
|
86
|
+
"kind": { "const": "dead-step" },
|
|
87
|
+
"event": { "$ref": "#/$defs/localId" },
|
|
88
|
+
"step": { "$ref": "#/$defs/stepIndex" }
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"type": "object",
|
|
93
|
+
"additionalProperties": false,
|
|
94
|
+
"required": ["kind", "state", "path", "count"],
|
|
95
|
+
"properties": {
|
|
96
|
+
"kind": { "const": "deadlock" },
|
|
97
|
+
"state": { "$ref": "#/$defs/globalState" },
|
|
98
|
+
"path": { "$ref": "#/$defs/path" },
|
|
99
|
+
"count": { "type": "integer", "minimum": 1, "description": "The number of deadlocked reachable global states." }
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"anchors": {
|
|
106
|
+
"description": "Every code source of a region or an event, regions first, then events, each in declaration order, with its status against the current file.",
|
|
107
|
+
"type": "array",
|
|
108
|
+
"items": {
|
|
109
|
+
"type": "object",
|
|
110
|
+
"additionalProperties": false,
|
|
111
|
+
"required": ["owner", "ownerId", "path", "status"],
|
|
112
|
+
"properties": {
|
|
113
|
+
"owner": { "enum": ["region", "event"] },
|
|
114
|
+
"ownerId": { "$ref": "#/$defs/localId" },
|
|
115
|
+
"path": { "type": "string", "minLength": 1 },
|
|
116
|
+
"symbol": { "type": "string", "minLength": 1 },
|
|
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 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." }
|
|
133
|
+
},
|
|
134
|
+
"allOf": [
|
|
135
|
+
{
|
|
136
|
+
"if": { "required": ["symbol", "digest"] },
|
|
137
|
+
"then": { "required": ["callees"] },
|
|
138
|
+
"else": { "not": { "required": ["callees"] } }
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"if": { "properties": { "status": { "enum": ["anchor-unconfirmed", "anchor-changed", "confirmed"] } } },
|
|
142
|
+
"then": { "required": ["digest"] },
|
|
143
|
+
"else": { "not": { "required": ["digest"] } }
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"if": { "properties": { "status": { "const": "unchecked" } } },
|
|
147
|
+
"then": { "required": ["reason", "symbol"] },
|
|
148
|
+
"else": { "not": { "required": ["reason"] } }
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"$defs": {
|
|
158
|
+
"localId": { "type": "string", "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$" },
|
|
159
|
+
"stepIndex": { "type": "integer", "minimum": 1, "description": "The 1-based index of the step in its event." },
|
|
160
|
+
"globalState": {
|
|
161
|
+
"description": "One state per region, keyed by region id in declaration order.",
|
|
162
|
+
"type": "object",
|
|
163
|
+
"minProperties": 1,
|
|
164
|
+
"propertyNames": { "$ref": "#/$defs/localId" },
|
|
165
|
+
"additionalProperties": { "$ref": "#/$defs/localId" }
|
|
166
|
+
},
|
|
167
|
+
"path": {
|
|
168
|
+
"description": "The shortest sequence of fired steps from the initial global state.",
|
|
169
|
+
"type": "array",
|
|
170
|
+
"items": {
|
|
171
|
+
"type": "object",
|
|
172
|
+
"additionalProperties": false,
|
|
173
|
+
"required": ["event", "step"],
|
|
174
|
+
"properties": {
|
|
175
|
+
"event": { "$ref": "#/$defs/localId" },
|
|
176
|
+
"step": { "$ref": "#/$defs/stepIndex" }
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
package/src/architecture-debt.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { digestJson, type ArchContextError, type Json } from "./schema";
|
|
|
2
2
|
|
|
3
3
|
/** Measured architecture work, distinct from generated-file freshness and source byte stamps. */
|
|
4
4
|
export const ARCHITECTURE_DEBT_SCHEMA_VERSION = "archcontext.architecture-debt/v1" as const;
|
|
5
|
-
export const ARCHITECTURE_DEBT_KINDS = ["unowned-path", "ambiguous-owner", "undeclared-dependency", "flow-proof-failed", "stale-anchor", "practice-regression"] as const;
|
|
5
|
+
export const ARCHITECTURE_DEBT_KINDS = ["unowned-path", "ambiguous-owner", "undeclared-dependency", "flow-proof-failed", "stale-anchor", "practice-regression", "state-machine-rule", "state-machine-stale"] as const;
|
|
6
6
|
export type ArchitectureDebtKind = typeof ARCHITECTURE_DEBT_KINDS[number];
|
|
7
|
-
export const ARCHITECTURE_DEBT_CHECKS = ["ownership", "anchors", "dependencies", "flows", "practices"] as const;
|
|
7
|
+
export const ARCHITECTURE_DEBT_CHECKS = ["ownership", "anchors", "dependencies", "flows", "state-machines", "practices"] as const;
|
|
8
8
|
export type ArchitectureDebtCheck = typeof ARCHITECTURE_DEBT_CHECKS[number];
|
|
9
9
|
|
|
10
10
|
export interface ArchitectureDebtItemV1 {
|
|
@@ -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";
|
|
@@ -8,8 +9,11 @@ import { ERROR_CATALOG, canonicalize, isRepoRelativePosixPath, type ArchContextE
|
|
|
8
9
|
|
|
9
10
|
/** Only selected entrypoints support transport failures; the legacy AC-only envelope is unchanged. */
|
|
10
11
|
export type FailureCode = ArchContextErrorCode | "RPC_TIMEOUT" | "RPC_ABORTED";
|
|
11
|
-
export const FAILURE_STAGES = Object.freeze(["debt", "complete", "practice-checkpoint", "cli", "mcp", "hook-checkpoint", "failure-metadata", "public-operation", "native-export", "docs-anchors", "flows-check"] as const);
|
|
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" } },
|
|
@@ -55,6 +59,7 @@ const policies: Record<string, Policy> = {
|
|
|
55
59
|
"changed-path-invalid": { code: "AC_SCHEMA_INVALID", message: "Changed paths must be an array of repository-relative POSIX paths.", fields: ["checks"] },
|
|
56
60
|
"debt-report-invalid": { code: "AC_SCHEMA_INVALID", message: "Architecture debt evidence violates its contract.", fields: ["checks"] },
|
|
57
61
|
"projection-manifest-upgrade-required": { code: "AC_PRECONDITION_FAILED", message: `The committed projection manifest requires supported re-baselining. First restore the original model if missing; the manifest digest cannot recover it. With the reviewed model available, follow ${ARCHITECTURE_DOCS_PROJECTION_MANIFEST_MIGRATION_GUIDE} before running ${ARCHITECTURE_DOCS_PROJECTION_MANIFEST_UPGRADE_COMMAND}.`, facts: { manifestPath: "optional:projectionManifestPath", foundSchemaVersion: "optional:projectionManifestSchemaVersion", supportedSchemaVersion: "optional:projectionManifestSchemaVersion", upgradeCommand: "optional:projectionManifestUpgradeCommand", migrationGuide: "optional:projectionManifestMigrationGuide" } },
|
|
62
|
+
"projection-writer-base-moved": { code: "AC_PRECONDITION_FAILED", message: "The remote base no longer points at the requested commit.", retryable: true, facts: { expectedBaseSha: "head", actualBaseSha: "head" } },
|
|
58
63
|
"projection-manifest-invalid": { code: "AC_PRECONDITION_FAILED", message: "The committed projection manifest violates its contract." },
|
|
59
64
|
"architecture-model-ignored": { code: "AC_PRECONDITION_FAILED", action: "commit-architecture-model", message: "Git ignore rules exclude architecture model paths, so the model cannot be committed and a manifest digest cannot rebuild it. Remove or narrow the rule, commit the model, then retry adoption. The diagnostic command prints each deciding rule.", facts: { pathCount: "uint", paths: "optional:diagnosticPaths", commands: "optional:diagnosticCommands", omittedPathCount: "uint" } },
|
|
60
65
|
"projection-footprint-uncovered": { code: "AC_PRECONDITION_FAILED", message: "Declared source footprints lack a projection target." },
|
|
@@ -63,6 +68,7 @@ const policies: Record<string, Policy> = {
|
|
|
63
68
|
"checkpoint-input-invalid": { code: "AC_SCHEMA_INVALID", message: "Checkpoint arguments violate the declared input schema.", fields: ["issueCount"], action: "correct-command-arguments" },
|
|
64
69
|
"cli-input-invalid": { code: "AC_SCHEMA_INVALID", message: "Command arguments violate the declared input contract.", action: "correct-command-arguments" },
|
|
65
70
|
"constraint-model-invalid": { code: "AC_SCHEMA_INVALID", message: "Dependency constraint declarations are invalid.", facts: { issueCount: "uint" }, action: "repair-constraint-declarations" },
|
|
71
|
+
"state-machine-model-invalid": { code: "AC_SCHEMA_INVALID", message: "State machine declarations are invalid. Run archctx validate --json for the full list of issues.", facts: { issues: "stateMachineIssues", issueCount: "uint", omittedCount: "uint" }, action: "repair-state-machine-declarations" },
|
|
66
72
|
"complete-input-invalid": { code: "AC_SCHEMA_INVALID", message: "Completion input violates the caller authority contract.", action: "correct-command-arguments" },
|
|
67
73
|
"hook-event-invalid": { code: "AC_SCHEMA_INVALID", message: "Hook event violates the declared input contract.", action: "correct-command-arguments" },
|
|
68
74
|
"egress-policy-denied": { code: "AC_POLICY_VIOLATION", message: "Local policy refused this operation." },
|
|
@@ -134,6 +140,7 @@ Object.assign(policies, {
|
|
|
134
140
|
"projection-adoption-profile-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Projection adoption profile invalid.", "facts": {}},
|
|
135
141
|
"projection-adoption-approval-input-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Projection adoption approval input invalid.", "facts": {}},
|
|
136
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": {}},
|
|
137
144
|
"projection-readback-input-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Projection readback input invalid.", "facts": {}},
|
|
138
145
|
"projection-recovery-input-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Projection recovery input invalid.", "facts": {}},
|
|
139
146
|
"projection-readback-result-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Projection readback result invalid.", "facts": {"issueCount": "uint"}},
|
|
@@ -180,8 +187,6 @@ Object.assign(policies, {
|
|
|
180
187
|
"projection-check-mode-invalid": {"code": "AC_SCHEMA_INVALID","message": "Projection check mode invalid.","facts": {}},
|
|
181
188
|
"projection-check-input-invalid": {"code": "AC_SCHEMA_INVALID","message": "Projection check input invalid. Supply valid fields and keep lists sorted and unique.","facts": {}},
|
|
182
189
|
"projection-snapshot-mismatch": {"code": "AC_PRECONDITION_FAILED","message": "Projection snapshot mismatch.","facts": {"field":"optional:snapshotField"}},
|
|
183
|
-
"changed-path-outside-worktree": {"code": "AC_SCHEMA_INVALID","message": "Changed path outside worktree.","facts": {}},
|
|
184
|
-
"changed-path-not-normalized": {"code": "AC_SCHEMA_INVALID","message": "Changed path not normalized.","facts": {}},
|
|
185
190
|
"projection-result-invalid": {"code": "AC_SCHEMA_INVALID","message": "Projection result invalid.","facts": {}},
|
|
186
191
|
"repository-not-registered": {"code": "AC_REPO_NOT_FOUND","message": "Repository not registered.","facts": {}},
|
|
187
192
|
"landscape-invalid": {"code": "AC_SCHEMA_INVALID","message": "Landscape invalid.","facts": {}},
|
|
@@ -227,6 +232,7 @@ Object.assign(policies, {
|
|
|
227
232
|
"refactor-decision-approval-required": {"code": "AC_USER_CONFIRMATION_REQUIRED","message": "Refactor decision approval required.","facts": {"recommendationId": "id"}},
|
|
228
233
|
"jobs-input-invalid": {"code": "AC_SCHEMA_INVALID","message": "Jobs input invalid.","facts": {"field":"optional:jobsField"}},
|
|
229
234
|
"job-running-required": {"code": "AC_PRECONDITION_FAILED","message": "Job running required.","facts": {"jobId": "id"}},
|
|
235
|
+
"job-transition-invalid": {"code": "AC_PRECONDITION_FAILED","message": "Job transition invalid.","facts": {"jobId": "id"}},
|
|
230
236
|
"job-context-stale": {"code": "AC_CONTEXT_STALE","message": "Job context stale.","facts": {"jobId": "id","expectedHeadSha": "head","actualHeadSha": "head","expectedWorktreeDigest": "sha256","actualWorktreeDigest": "sha256"}},
|
|
231
237
|
"audit-disabled": {"code": "AC_CAPABILITY_UNSUPPORTED","message": "Audit disabled.","facts": {}},
|
|
232
238
|
"audit-active": {"code": "AC_PRECONDITION_FAILED","message": "Audit active.","facts": {}},
|
|
@@ -378,6 +384,7 @@ const localEnums: Readonly<Record<string, readonly string[]>> = {
|
|
|
378
384
|
upgradeAction: ["upgrade-archctx-runtime"],
|
|
379
385
|
upgradeCommand: ["archctx daemon upgrade"],
|
|
380
386
|
ownershipAction: ["remove-whole-file-outputs-and-reapply"],
|
|
387
|
+
historyReadReason: ARCHITECTURE_HISTORY_READ_REASONS,
|
|
381
388
|
projectionManifestPath: [ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH],
|
|
382
389
|
projectionManifestSchemaVersion: [...SUPERSEDED_ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSIONS, ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION],
|
|
383
390
|
projectionManifestUpgradeCommand: [ARCHITECTURE_DOCS_PROJECTION_MANIFEST_UPGRADE_COMMAND],
|
|
@@ -458,6 +465,17 @@ function localFactValue(rule: string, value: unknown): Json {
|
|
|
458
465
|
return { path, code: code as string };
|
|
459
466
|
});
|
|
460
467
|
}
|
|
468
|
+
if (rule === "stateMachineIssues") {
|
|
469
|
+
// `<path>: <field>: <invariant or schema message>`; issueCount and omittedCount count what does not fit.
|
|
470
|
+
if (!Array.isArray(value)) throw new Error("State machine issues must be an own list");
|
|
471
|
+
const length = Object.getOwnPropertyDescriptor(value, "length")?.value;
|
|
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");
|
|
473
|
+
return Array.from({ length }, (_, index) => {
|
|
474
|
+
const field = Object.getOwnPropertyDescriptor(value, String(index));
|
|
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");
|
|
476
|
+
return field.value;
|
|
477
|
+
});
|
|
478
|
+
}
|
|
461
479
|
if (rule === "diagnosticPaths" || rule === "diagnosticCommands") {
|
|
462
480
|
if (!Array.isArray(value)) throw new Error("Diagnostics must be an own list");
|
|
463
481
|
const length=Object.getOwnPropertyDescriptor(value,"length")?.value;
|
|
@@ -715,6 +733,11 @@ function budgetIssues(value: unknown, depth = 0, maxStringBytes = 256): string[]
|
|
|
715
733
|
return value === null || typeof value === "boolean" ? [] : ["detail value is not JSON"];
|
|
716
734
|
}
|
|
717
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
|
+
|
|
718
741
|
export function knownFailure<C extends FailureCode>(code: C, reasonCode: string, details: unknown = {}, attributes: Attributes = {}): StrictFailure<C> {
|
|
719
742
|
// TypeScript types do not protect this runtime boundary. Do not coerce policy keys.
|
|
720
743
|
if (typeof code !== "string" || typeof reasonCode !== "string") throw new Error("Failure code/reason must be primitive strings");
|
|
@@ -744,7 +767,7 @@ export function knownFailure<C extends FailureCode>(code: C, reasonCode: string,
|
|
|
744
767
|
return { code, message: policy.message, severity, retryable, action, reasonCode, details: projectionRecoveryDetailsSnapshot(reasonCode, details) };
|
|
745
768
|
}
|
|
746
769
|
const safeDetails = detailsFor(policy, details);
|
|
747
|
-
const extendedFacts =
|
|
770
|
+
const extendedFacts = hasExtendedFacts(policy);
|
|
748
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");
|
|
749
772
|
return { code, message: policy.message, severity, retryable, action, reasonCode, details: safeDetails };
|
|
750
773
|
}
|
|
@@ -845,7 +868,7 @@ export function failureIssues(value: unknown): string[] {
|
|
|
845
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"];
|
|
846
869
|
const data = Object.fromEntries(fields.map(key => [key, ownData(value, key)]));
|
|
847
870
|
const policy = typeof data.reasonCode === "string" ? policies[data.reasonCode] : undefined;
|
|
848
|
-
const extendedFacts = policy !== undefined && policy.code === data.code &&
|
|
871
|
+
const extendedFacts = policy !== undefined && policy.code === data.code && hasExtendedFacts(policy);
|
|
849
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);
|
|
850
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"];
|
|
851
874
|
const expected = failureFromData(data);
|
package/src/index.ts
CHANGED
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";
|