archctx-contracts 0.10.0 → 0.11.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": "archcontext.capabilities/v1",
3
- "package": { "name": "archctx", "version": "0.10.0" },
3
+ "package": { "name": "archctx", "version": "0.11.1" },
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.10.0",
5
+ "version": "0.11.1",
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.10.0",
15
+ "version": "0.11.1",
16
16
  "entrypoint": "archctx"
17
17
  },
18
18
  "daemon": {
19
19
  "packageName": "@archcontext/local-runtime",
20
- "version": "0.10.0",
20
+ "version": "0.11.1",
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.10.0",
26
+ "version": "0.11.1",
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.10.0",
33
+ "contractsPackageVersion": "0.11.1",
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.10.0",
3
+ "version": "0.11.1",
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
@@ -4,7 +4,7 @@ import { MODEL_VALIDATION_DIAGNOSTIC_CODES } from "./ports";
4
4
  import { ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH } from "./projection";
5
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";
6
6
  import { PROJECTION_RECOVERY_DETAILS_LIMIT_BYTES, projectionRecoveryDetailsSnapshot } from "./projection-recovery";
7
- import { ERROR_CATALOG, canonicalize, type ArchContextErrorCode, type Json, type Severity } from "./schema";
7
+ import { ERROR_CATALOG, canonicalize, isRepoRelativePosixPath, type ArchContextErrorCode, type Json, type Severity } from "./schema";
8
8
 
9
9
  /** Only selected entrypoints support transport failures; the legacy AC-only envelope is unchanged. */
10
10
  export type FailureCode = ArchContextErrorCode | "RPC_TIMEOUT" | "RPC_ABORTED";
@@ -40,9 +40,10 @@ export const CODE_FACTS_ISSUE_MESSAGES = Object.freeze({
40
40
  });
41
41
  /** Each reason has a closed fact vocabulary. No source text or recovery binding is a summary fact. */
42
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" },
43
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 },
44
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: {} },
45
- "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: {} },
46
+ "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" } },
46
47
  "code-facts-snapshot-layout-unsupported": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "The repository layout cannot be safely isolated for a zero-write CodeGraph read.", action: "inspect-repository-layout", retryable: false, facts: {} },
47
48
  "daemon-root-missing": { code: "AC_RUNTIME_UNAVAILABLE", message: "The daemon start worktree no longer exists. Stop this daemon using its workspace state directory.", action: "stop-targeted-daemon", retryable: false, facts: {} },
48
49
  "changeset-receipt-journal-unavailable": { code: "AC_PRECONDITION_FAILED", message: "No committed ChangeSet journal exists for this repository and journal id.", action: "select-committed-journal" },
@@ -179,6 +180,7 @@ Object.assign(policies, {
179
180
  "changeset-rollback-conflict": {code: "AC_PRECONDITION_FAILED", message: "ChangeSet rollback is incomplete because the projection manifest changed externally. Preserve the pending journal and backup for manual recovery.", facts: {journalId: "optional:id", changeSetId: "id", manualRecoveryRequired: "boolean"}},
180
181
  "deps-input-invalid": {"code": "AC_SCHEMA_INVALID","message": "Deps input invalid.","facts": {"field":"optional:depsField","issue":"optional:depsIssue"}},
181
182
  "deps-workspace-invalid": {"code": "AC_SCHEMA_INVALID","message": "Deps workspace invalid.","facts": {}},
183
+ "workspace-exports-unsupported": {"code": "AC_SCHEMA_INVALID","message": "A workspace package.json exports value has an unsupported shape.","facts": {"manifestPath":"repoPath","subpath":"exportsSubpath"}},
182
184
  "deps-model-unreadable": {"code": "AC_MODEL_ADOPTION_REQUIRED","message": "Deps model unreadable.","facts": {}},
183
185
  "code-facts-unavailable": {"code": "AC_CODE_FACTS_UNAVAILABLE","message": "Code facts unavailable.","facts": {}},
184
186
  "projection-check-mode-invalid": {"code": "AC_SCHEMA_INVALID","message": "Projection check mode invalid.","facts": {}},
@@ -392,6 +394,7 @@ const localEnums: Readonly<Record<string, readonly string[]>> = {
392
394
  depsField: ["from", "into", "importNodeLimit", "edgeLimit"],
393
395
  depsIssue: ["unknown-node", "invalid-limit", "missing-value"],
394
396
  snapshotField: ["repositoryId", "workspaceId", "headSha", "worktreeDigest"],
397
+ snapshotLimit: ["bytes", "entries"],
395
398
  jobsField: ["workerId"],
396
399
  observedDomain: ["observed"],
397
400
  inputAvailability: ["unavailable"],
@@ -486,6 +489,8 @@ function localFactValue(rule: string, value: unknown): Json {
486
489
  if (rule === "id" && value.length > 0) return value;
487
490
  if (rule === "sha256" && /^sha256:[a-f0-9]{64}$/.test(value)) return value;
488
491
  if (rule === "head" && /^[a-f0-9]{40}$/.test(value)) return value;
492
+ if (rule === "repoPath" && isRepoRelativePosixPath(value)) return value;
493
+ if (rule === "exportsSubpath" && value.startsWith(".")) return value;
489
494
  if (localEnums[rule]?.includes(value)) return value;
490
495
  }
491
496
  throw new Error("Fact violates its closed schema");
@@ -587,6 +592,7 @@ const nativeEnums: Readonly<Record<string, readonly string[]>> = {
587
592
  ],
588
593
  "operation": [
589
594
  "rev-parse",
595
+ "log",
590
596
  "ls-tree",
591
597
  "ls-files",
592
598
  "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.10.0";
2
+ export const ARCHCONTEXT_PRODUCT_VERSION = "0.11.1";
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";