archctx-contracts 0.9.4 → 0.11.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": "archcontext.capabilities/v1",
3
- "package": { "name": "archctx", "version": "0.9.4" },
3
+ "package": { "name": "archctx", "version": "0.11.0" },
4
4
  "protocols": {
5
5
  "projectionRequest": "archcontext.projection-request/v1",
6
6
  "projectionResult": "archcontext.projection-result/v2",
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": "archcontext.product-version-manifest/v1",
3
3
  "product": {
4
4
  "name": "archctx",
5
- "version": "0.9.4",
5
+ "version": "0.11.0",
6
6
  "distribution": "one-package"
7
7
  },
8
8
  "packageManager": "bun@1.4.3",
@@ -12,25 +12,25 @@
12
12
  "surfaces": {
13
13
  "cli": {
14
14
  "packageName": "@archcontext/surfaces",
15
- "version": "0.9.4",
15
+ "version": "0.11.0",
16
16
  "entrypoint": "archctx"
17
17
  },
18
18
  "daemon": {
19
19
  "packageName": "@archcontext/local-runtime",
20
- "version": "0.9.4",
20
+ "version": "0.11.0",
21
21
  "entrypoint": "archctx daemon start",
22
22
  "rpcSchemaVersion": "archcontext.runtime-rpc/v2"
23
23
  },
24
24
  "mcp": {
25
25
  "packageName": "@archcontext/surfaces",
26
- "version": "0.9.4",
26
+ "version": "0.11.0",
27
27
  "entrypoint": "archctx mcp",
28
28
  "transport": "stdio"
29
29
  }
30
30
  },
31
31
  "schemas": {
32
32
  "schemaSetVersion": "2026-06-25.al0-ledger",
33
- "contractsPackageVersion": "0.9.4",
33
+ "contractsPackageVersion": "0.11.0",
34
34
  "reviewChallenge": "archcontext.review-challenge/v2",
35
35
  "attestation": "archcontext.attestation/v2",
36
36
  "deviceIdentity": "archcontext.device-identity/v1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archctx-contracts",
3
- "version": "0.9.4",
3
+ "version": "0.11.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -0,0 +1,58 @@
1
+ import { isRepoRelativePosixPath } from "./schema";
2
+
3
+ export const ARCHITECTURE_HISTORY_SCHEMA_VERSION = "archcontext.architecture-history/v1" as const;
4
+ export const ARCHITECTURE_HISTORY_MERMAID_SCHEMA_VERSION = "archcontext.architecture-history-mermaid/v1" as const;
5
+ export const ARCHITECTURE_HISTORY_DERIVATION_VERSION = "v3" as const;
6
+
7
+ export type HistoryErrorCode = "history-model-layout-unsupported" | "history-model-missing" | "history-model-invalid" | "history-model-too-large";
8
+ export interface HistoryNode { id: string; name: string; domain: string | null }
9
+ export interface HistoryEdge { source: string; target: string }
10
+ export interface HistoryStructureNode { id: string; kind: "capability" | "module" | "component"; name: string; capability: string | null }
11
+ export interface HistoryDelta {
12
+ baseRev: string | null;
13
+ added: Array<Pick<HistoryStructureNode, "id" | "kind" | "capability">>;
14
+ removed: Array<Pick<HistoryStructureNode, "id" | "kind" | "capability">>;
15
+ renamed: Array<Pick<HistoryStructureNode, "id" | "kind" | "capability"> & { from: string; to: string }>;
16
+ edgesChanged: { added: HistoryEdge[]; removed: HistoryEdge[] };
17
+ }
18
+ export type HistoryState = { nodes: HistoryNode[]; edges: HistoryEdge[]; structure: HistoryStructureNode[]; error?: never } | { nodes: null; edges: null; structure: null; error: { code: HistoryErrorCode; path?: string } };
19
+ export type HistoryMilestone = { rev: string; date: string; subject: string } & ({ nodes: HistoryNode[]; edges: HistoryEdge[]; delta: HistoryDelta; error?: never } | { nodes: null; edges: null; delta: null; error: { code: HistoryErrorCode; path?: string } });
20
+ export interface ArchitectureHistory { schemaVersion: typeof ARCHITECTURE_HISTORY_SCHEMA_VERSION; head: string; total: number; offset: number; limit: number; milestones: HistoryMilestone[] }
21
+
22
+ const object = (v: unknown): v is Record<string, unknown> => typeof v === "object" && v !== null && !Array.isArray(v);
23
+ const string = (v: unknown): v is string => typeof v === "string";
24
+ const edge = (v: unknown) => object(v) && string(v.source) && string(v.target);
25
+ const kind = (v: unknown) => v === "capability" || v === "module" || v === "component";
26
+ const item = (v: unknown) => object(v) && string(v.id) && kind(v.kind) && (v.capability === null || string(v.capability)) && (v.kind !== "capability" || v.capability === v.id);
27
+ const structure = (v: unknown) => item(v) && object(v) && string(v.name);
28
+ const node = (v: unknown) => object(v) && string(v.id) && string(v.name) && (v.domain === null || string(v.domain));
29
+ const errors: readonly string[] = ["history-model-layout-unsupported", "history-model-missing", "history-model-invalid", "history-model-too-large"];
30
+ const sha = (v: unknown) => string(v) && /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(v);
31
+ const count = (v: unknown): v is number => typeof v === "number" && Number.isSafeInteger(v) && v >= 0;
32
+ const error = (v: unknown) => object(v) && string(v.code) && errors.includes(v.code) && (v.path === undefined || (string(v.path) && isRepoRelativePosixPath(v.path)));
33
+ const list = (v: unknown, check: (item: unknown) => unknown) => Array.isArray(v) && v.every(check);
34
+
35
+ /** Cache entries are untrusted and never authority for malformed data. */
36
+ export function decodeArchitectureHistoryState(value: unknown): HistoryState | undefined {
37
+ if (!object(value)) return undefined;
38
+ if (value.nodes === null && value.edges === null && value.structure === null && error(value.error)) return value as unknown as HistoryState;
39
+ if (value.error === undefined && list(value.nodes, node) && list(value.edges, edge) && list(value.structure, structure)) return value as unknown as HistoryState;
40
+ return undefined;
41
+ }
42
+
43
+ export function architectureHistoryIssues(value: unknown): string[] {
44
+ if (!object(value) || value.schemaVersion !== ARCHITECTURE_HISTORY_SCHEMA_VERSION || !sha(value.head) || !count(value.total) || !count(value.offset) || !count(value.limit) || value.limit > 1000 || !Array.isArray(value.milestones) || value.milestones.length > value.limit || value.milestones.length > Math.max(0, value.total - value.offset)) return ["invalid history envelope"];
45
+ let previousValid: string | null = null;
46
+ const valid = value.milestones.every((m: unknown) => {
47
+ if (!object(m) || !sha(m.rev) || !string(m.date) || !string(m.subject)) return false;
48
+ if (m.nodes === null && m.edges === null && m.delta === null) return error(m.error);
49
+ if (m.error !== undefined || !list(m.nodes, node) || !list(m.edges, edge) || !object(m.delta) || (m.delta.baseRev !== null && !sha(m.delta.baseRev)) || (previousValid !== null && m.delta.baseRev !== previousValid) || (previousValid === null && value.offset === 0 && m.delta.baseRev !== null)) return false;
50
+ previousValid = m.rev as string;
51
+ const renamed = (v: unknown) => item(v) && object(v) && string(v.from) && string(v.to);
52
+ return list(m.delta.added, item) && list(m.delta.removed, item) && list(m.delta.renamed, renamed) && object(m.delta.edgesChanged) && list(m.delta.edgesChanged.added, edge) && list(m.delta.edgesChanged.removed, edge);
53
+ });
54
+ return valid ? [] : ["invalid history milestones"];
55
+ }
56
+ export function decodeArchitectureHistory(value: unknown): ArchitectureHistory | undefined {
57
+ return architectureHistoryIssues(value).length === 0 ? value as ArchitectureHistory : undefined;
58
+ }
package/src/failure.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { changeSetRecoveryDetailsSnapshot } from "./changeset-recovery";
2
2
  import { isNativeError } from "node:util/types";
3
3
  import { MODEL_VALIDATION_DIAGNOSTIC_CODES } from "./ports";
4
+ import { ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH } from "./projection";
5
+ import { ARCHITECTURE_DOCS_PROJECTION_MANIFEST_MIGRATION_GUIDE, ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION, ARCHITECTURE_DOCS_PROJECTION_MANIFEST_UPGRADE_COMMAND, SUPERSEDED_ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSIONS } from "./projection-manifest";
4
6
  import { PROJECTION_RECOVERY_DETAILS_LIMIT_BYTES, projectionRecoveryDetailsSnapshot } from "./projection-recovery";
5
7
  import { ERROR_CATALOG, canonicalize, type ArchContextErrorCode, type Json, type Severity } from "./schema";
6
8
 
@@ -38,6 +40,7 @@ export const CODE_FACTS_ISSUE_MESSAGES = Object.freeze({
38
40
  });
39
41
  /** Each reason has a closed fact vocabulary. No source text or recovery binding is a summary fact. */
40
42
  const policies: Record<string, Policy> = {
43
+ "history-shallow-repository": { code: "AC_PRECONDITION_FAILED", message: "Architecture history requires a complete Git repository.", action: "unshallow-repository" },
41
44
  "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 },
42
45
  "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: {} },
43
46
  "code-facts-snapshot-limit-exceeded": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "The private CodeGraph snapshot exceeds its 512 MiB or 100000 entry limit.", action: "reduce-snapshot-size", retryable: false, facts: {} },
@@ -51,7 +54,7 @@ const policies: Record<string, Policy> = {
51
54
  "model-missing": { code: "AC_MODEL_ADOPTION_REQUIRED", message: "Architecture debt requires an adopted model.", fields: ["checks"] },
52
55
  "changed-path-invalid": { code: "AC_SCHEMA_INVALID", message: "Changed paths must be an array of repository-relative POSIX paths.", fields: ["checks"] },
53
56
  "debt-report-invalid": { code: "AC_SCHEMA_INVALID", message: "Architecture debt evidence violates its contract.", fields: ["checks"] },
54
- "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 docs/runbooks/architecture-documentation-projections.md before running archctx docs apply --approved --profile <default|repo-harness/v1>." },
57
+ "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" } },
55
58
  "projection-manifest-invalid": { code: "AC_PRECONDITION_FAILED", message: "The committed projection manifest violates its contract." },
56
59
  "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" } },
57
60
  "projection-footprint-uncovered": { code: "AC_PRECONDITION_FAILED", message: "Declared source footprints lack a projection target." },
@@ -382,6 +385,10 @@ const localEnums: Readonly<Record<string, readonly string[]>> = {
382
385
  upgradeAction: ["upgrade-archctx-runtime"],
383
386
  upgradeCommand: ["archctx daemon upgrade"],
384
387
  ownershipAction: ["remove-whole-file-outputs-and-reapply"],
388
+ projectionManifestPath: [ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH],
389
+ projectionManifestSchemaVersion: [...SUPERSEDED_ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSIONS, ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION],
390
+ projectionManifestUpgradeCommand: [ARCHITECTURE_DOCS_PROJECTION_MANIFEST_UPGRADE_COMMAND],
391
+ projectionManifestMigrationGuide: [ARCHITECTURE_DOCS_PROJECTION_MANIFEST_MIGRATION_GUIDE],
385
392
  ledgerModeField: ["rolloutMode","readMode","writeMode"],
386
393
  depsField: ["from", "into", "importNodeLimit", "edgeLimit"],
387
394
  depsIssue: ["unknown-node", "invalid-limit", "missing-value"],
@@ -581,6 +588,7 @@ const nativeEnums: Readonly<Record<string, readonly string[]>> = {
581
588
  ],
582
589
  "operation": [
583
590
  "rev-parse",
591
+ "log",
584
592
  "ls-tree",
585
593
  "ls-files",
586
594
  "cat-file"
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./control-plane-routes";
2
2
  export * from "./architecture";
3
+ export * from "./architecture-history";
3
4
  export * from "./architecture-debt";
4
5
  export * from "./docs-anchors";
5
6
  export * from "./external-docs";
@@ -1,5 +1,5 @@
1
1
  export const ARCHCONTEXT_PRODUCT_NAME = "archctx";
2
- export const ARCHCONTEXT_PRODUCT_VERSION = "0.9.4";
2
+ export const ARCHCONTEXT_PRODUCT_VERSION = "0.11.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";
@@ -32,6 +32,14 @@ export const SUPERSEDED_ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSIONS =
32
32
  "archcontext.architecture-docs-projection-manifest/v1",
33
33
  "archcontext.architecture-docs-projection-manifest/v2"
34
34
  ] as const;
35
+ /**
36
+ * The one-time re-baseline an operator runs after the migration preconditions in the runbook are
37
+ * met. The profile comes from the repository, not from a superseded manifest, so the command names
38
+ * both supported profiles instead of guessing.
39
+ */
40
+ export const ARCHITECTURE_DOCS_PROJECTION_MANIFEST_UPGRADE_COMMAND = "archctx docs apply --approved --profile <default|repo-harness/v1>" as const;
41
+ /** The operator runbook that pairs a re-baseline with its prerequisites (model restoration, upgrade path, receipt drain). */
42
+ export const ARCHITECTURE_DOCS_PROJECTION_MANIFEST_MIGRATION_GUIDE = "docs/runbooks/architecture-documentation-projections.md" as const;
35
43
  /** The reason code of a refused superseded manifest; the operator re-baselines once with `archctx docs apply --approved`. */
36
44
  export const PROJECTION_MANIFEST_UPGRADE_REQUIRED = "projection-manifest-upgrade-required" as const;
37
45
  /** The reason code of a current-format manifest that fails its contract; restore it from Git. */