@consiliency/contract 0.0.1 → 0.2.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.
Files changed (62) hide show
  1. package/README.md +44 -4
  2. package/conformance/vectors/adoption-absent-ungoverned.json +16 -0
  3. package/conformance/vectors/adoption-adopted-governed.json +18 -0
  4. package/conformance/vectors/adoption-declared-false-ungoverned.json +17 -0
  5. package/conformance/vectors/adoption-partial-scope.json +18 -0
  6. package/conformance/vectors/canonical-html-contract-loaded.json +15 -0
  7. package/conformance/vectors/coordination-announce-intent-does-not-lease.json +38 -0
  8. package/conformance/vectors/coordination-done-does-not-release-lease.json +38 -0
  9. package/conformance/vectors/coordination-handoff-does-not-transfer-holder.json +38 -0
  10. package/conformance/vectors/coordination-message-does-not-mutate-lease.json +38 -0
  11. package/conformance/vectors/doc-label-foreign-governed-false.json +19 -0
  12. package/conformance/vectors/doc-label-present-nonconforming.json +19 -0
  13. package/conformance/vectors/edge-label-unmanaged-cross-repo.json +30 -0
  14. package/conformance/vectors/governed-set-undeclared-ungoverned.json +18 -0
  15. package/conformance/vectors/ignore-set-nested-path-any-depth.json +19 -0
  16. package/conformance/vectors/ignore-set-scratch-never-governed.json +19 -0
  17. package/conformance/vectors/interface-invalid-host-path.json +26 -0
  18. package/conformance/vectors/interface-valid-realized-and-promised.json +36 -0
  19. package/conformance/vectors/lease-acquire.json +35 -0
  20. package/conformance/vectors/lease-event-carries-lease.json +28 -0
  21. package/conformance/vectors/lease-expire.json +25 -0
  22. package/conformance/vectors/lease-expiry-boundary.json +25 -0
  23. package/conformance/vectors/lease-hard-degrades-to-soft.json +35 -0
  24. package/conformance/vectors/lease-hard-mode-atomic.json +35 -0
  25. package/conformance/vectors/lease-release.json +26 -0
  26. package/conformance/vectors/lease-renew.json +36 -0
  27. package/conformance/vectors/loop-gate-invalid-blocking-default.json +15 -0
  28. package/conformance/vectors/loop-gate-missing-doc-warns.json +16 -0
  29. package/conformance/vectors/manifest-invalid-absolute-path.json +20 -0
  30. package/conformance/vectors/manifest-invalid-certified-maturity.json +20 -0
  31. package/conformance/vectors/manifest-invalid-path-and-ref.json +20 -0
  32. package/conformance/vectors/manifest-invalid-unknown-archetype.json +18 -0
  33. package/conformance/vectors/manifest-valid-baseline-only.json +20 -0
  34. package/conformance/vectors/manifest-valid-product.json +21 -0
  35. package/conformance/vectors/version-skew-compatible.json +15 -0
  36. package/conformance/vectors/version-skew-incompatible-warns.json +15 -0
  37. package/core/canonical-html/contract-v1.json +459 -0
  38. package/core/canonical-html/provenance.json +22 -0
  39. package/core/contract.json +55 -0
  40. package/core/registries/archetypes.json +62 -0
  41. package/core/registries/default-ignore-set.json +30 -0
  42. package/core/registries/document-classes.json +33 -0
  43. package/core/registries/maturity-labels.json +48 -0
  44. package/core/registries/required-documents.json +74 -0
  45. package/core/schemas/canonical-html-v1.schema.json +15 -0
  46. package/core/schemas/contract-version-status.schema.json +26 -0
  47. package/core/schemas/coordination-channel-protocol.schema.json +53 -0
  48. package/core/schemas/coordination-scenario.schema.json +67 -0
  49. package/core/schemas/decision.schema.json +31 -0
  50. package/core/schemas/governance-scope-scenario.schema.json +62 -0
  51. package/core/schemas/interface-declaration.schema.json +69 -0
  52. package/core/schemas/lease-event.schema.json +17 -0
  53. package/core/schemas/lease-store-protocol.schema.json +117 -0
  54. package/core/schemas/lease.schema.json +42 -0
  55. package/core/schemas/loop-gate-protocol.schema.json +25 -0
  56. package/core/schemas/loop-gate-scenario.schema.json +25 -0
  57. package/core/schemas/manifest.schema.json +140 -0
  58. package/core/schemas/version-skew-protocol.schema.json +32 -0
  59. package/core/schemas/version-skew-scenario.schema.json +13 -0
  60. package/package.json +8 -2
  61. package/src/index.d.ts +7 -1
  62. package/src/index.js +47 -7
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://consiliency.io/contracts/loop-gate-protocol.schema.json",
4
+ "title": "Consiliency loop gate protocol",
5
+ "type": "object",
6
+ "required": ["schema", "gate_families", "default_policy"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "schema": {"const": "consiliency.loop_gate_protocol.v1"},
10
+ "gate_families": {
11
+ "type": "array",
12
+ "items": {"enum": ["presence", "freshness", "local-integrity", "cross-repo-integrity", "version-skew"]},
13
+ "uniqueItems": true
14
+ },
15
+ "default_policy": {
16
+ "type": "object",
17
+ "required": ["severity_default", "blocking_opt_in"],
18
+ "additionalProperties": false,
19
+ "properties": {
20
+ "severity_default": {"const": "warn"},
21
+ "blocking_opt_in": {"type": "boolean"}
22
+ }
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://consiliency.io/contracts/loop-gate-scenario.schema.json",
4
+ "title": "Consiliency loop gate conformance scenario",
5
+ "type": "object",
6
+ "required": ["schema", "gate"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "schema": {"const": "consiliency.loop_gate_scenario.v1"},
10
+ "gate": {"enum": ["presence", "freshness", "local-integrity", "cross-repo-integrity", "version-skew"]},
11
+ "missing": {
12
+ "type": "array",
13
+ "items": {"type": "string", "pattern": "^[a-z0-9][a-z0-9_.-]*$"}
14
+ },
15
+ "severity_default": {"type": "string"},
16
+ "consumer_policy": {
17
+ "type": "object",
18
+ "required": ["blocking_opt_in"],
19
+ "additionalProperties": false,
20
+ "properties": {
21
+ "blocking_opt_in": {"type": "boolean"}
22
+ }
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,140 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://consiliency.io/contracts/manifest.schema.json",
4
+ "title": ".consiliency manifest",
5
+ "type": "object",
6
+ "required": ["schema", "contract_version", "repo", "declaration", "documents", "interfaces"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "schema": {"const": "consiliency.manifest.v1"},
10
+ "contract_version": {"type": "string", "pattern": "^0\\.2\\.\\d+$"},
11
+ "repo": {
12
+ "type": "object",
13
+ "required": ["id", "display_name", "default_branch"],
14
+ "additionalProperties": false,
15
+ "properties": {
16
+ "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9_.-]*$"},
17
+ "display_name": {"type": "string", "minLength": 1},
18
+ "default_branch": {"type": "string", "minLength": 1},
19
+ "homepage": {"type": "string"}
20
+ }
21
+ },
22
+ "declaration": {
23
+ "oneOf": [
24
+ {
25
+ "type": "object",
26
+ "required": ["mode"],
27
+ "additionalProperties": false,
28
+ "properties": {"mode": {"const": "baseline-only"}}
29
+ },
30
+ {
31
+ "type": "object",
32
+ "required": ["mode", "archetypes"],
33
+ "additionalProperties": false,
34
+ "properties": {
35
+ "mode": {"const": "archetyped"},
36
+ "archetypes": {
37
+ "type": "array",
38
+ "minItems": 1,
39
+ "uniqueItems": true,
40
+ "items": {"enum": ["product", "service", "library", "infra", "tooling-meta", "experiment", "document"]}
41
+ },
42
+ "modifiers": {
43
+ "type": "array",
44
+ "uniqueItems": true,
45
+ "items": {"enum": ["data-bearing", "public", "regulated", "user-facing"]}
46
+ }
47
+ }
48
+ }
49
+ ]
50
+ },
51
+ "documents": {
52
+ "type": "array",
53
+ "items": {"$ref": "#/$defs/document"},
54
+ "uniqueItems": true
55
+ },
56
+ "interfaces": {"$ref": "#/$defs/repoRelativePath"},
57
+ "legacy_layouts": {
58
+ "type": "array",
59
+ "items": {"$ref": "#/$defs/repoRelativePath"}
60
+ },
61
+ "adoption": {"$ref": "#/$defs/adoptionProfile"},
62
+ "governed_set": {
63
+ "type": "array",
64
+ "uniqueItems": true,
65
+ "items": {"$ref": "#/$defs/governedSelector"}
66
+ }
67
+ },
68
+ "$defs": {
69
+ "adoptionProfile": {
70
+ "type": "object",
71
+ "required": ["adopted", "contract_version", "archetype", "adopted_scope"],
72
+ "additionalProperties": false,
73
+ "properties": {
74
+ "adopted": {
75
+ "type": "boolean",
76
+ "description": "true = the repo consents to be governed for the facets in adopted_scope (which must be non-empty). false = an explicit, recorded declaration of non-adoption: the repo is UNGOVERNED for every facet even though a profile is present. A repo with no adoption profile at all is likewise ungoverned; adopted:false is the explicit, auditable form of that state."
77
+ },
78
+ "contract_version": {"type": "string", "pattern": "^0\\.2\\.\\d+$"},
79
+ "archetype": {"enum": ["product", "service", "library", "infra", "tooling-meta", "experiment", "document", "baseline-only"]},
80
+ "adopted_scope": {
81
+ "type": "array",
82
+ "uniqueItems": true,
83
+ "items": {"enum": ["layout", "gates", "projections", "cert"]}
84
+ }
85
+ },
86
+ "allOf": [
87
+ {
88
+ "if": {"properties": {"adopted": {"const": true}}, "required": ["adopted"]},
89
+ "then": {"properties": {"adopted_scope": {"minItems": 1}}}
90
+ }
91
+ ]
92
+ },
93
+ "governedSelector": {
94
+ "type": "object",
95
+ "required": ["by", "value"],
96
+ "additionalProperties": false,
97
+ "properties": {
98
+ "by": {"enum": ["path", "glob", "class"]},
99
+ "value": {
100
+ "type": "string",
101
+ "minLength": 1,
102
+ "not": {"anyOf": [{"pattern": "^/"}, {"pattern": "(^|/)\\.\\.(/|$)"}, {"pattern": "^[A-Za-z]:[\\\\/]"}]}
103
+ }
104
+ }
105
+ },
106
+ "repoRelativePath": {
107
+ "type": "string",
108
+ "minLength": 1,
109
+ "not": {"anyOf": [{"pattern": "^/"}, {"pattern": "(^|/)\\.\\.(/|$)"}, {"pattern": "^[A-Za-z]:[\\\\/]"}]}
110
+ },
111
+ "externalRef": {
112
+ "type": "object",
113
+ "required": ["kind", "value"],
114
+ "additionalProperties": false,
115
+ "properties": {
116
+ "kind": {"enum": ["org-ref", "url", "opaque-external-ref"]},
117
+ "value": {"type": "string", "minLength": 1}
118
+ }
119
+ },
120
+ "document": {
121
+ "type": "object",
122
+ "required": ["id", "class", "maturity", "target_level", "required"],
123
+ "oneOf": [
124
+ {"required": ["path"], "not": {"required": ["ref"]}},
125
+ {"required": ["ref"], "not": {"required": ["path"]}}
126
+ ],
127
+ "additionalProperties": false,
128
+ "properties": {
129
+ "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9_.-]*$"},
130
+ "class": {"enum": ["intent-ground", "intent-plan", "proj-S", "proj-code", "ops-fact", "static", "index"]},
131
+ "path": {"$ref": "#/$defs/repoRelativePath"},
132
+ "ref": {"$ref": "#/$defs/externalRef"},
133
+ "maturity": {"enum": ["presence-only", "hash-checked", "realized-edge-observed"]},
134
+ "target_level": {"enum": ["L0", "L1"]},
135
+ "required": {"type": "boolean"},
136
+ "last_attested_at": {"type": "string"}
137
+ }
138
+ }
139
+ }
140
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://consiliency.io/contracts/version-skew-protocol.schema.json",
4
+ "title": "Consiliency version skew protocol",
5
+ "type": "object",
6
+ "required": ["schema", "contract_version", "compatible_ranges", "default_behavior"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "schema": {"const": "consiliency.version_skew_protocol.v1"},
10
+ "contract_version": {"const": "0.2.0"},
11
+ "compatible_ranges": {
12
+ "type": "object",
13
+ "required": ["contract", "package"],
14
+ "additionalProperties": false,
15
+ "properties": {
16
+ "contract": {"const": ">=0.2.0 <0.3.0"},
17
+ "package": {"const": ">=0.2.0 <0.3.0"}
18
+ }
19
+ },
20
+ "prerelease_policy": {"enum": ["reject-by-default"]},
21
+ "build_metadata_policy": {"enum": ["ignored-for-compatibility"]},
22
+ "default_behavior": {
23
+ "type": "object",
24
+ "required": ["phase0_severity", "auto_mutation_allowed"],
25
+ "additionalProperties": false,
26
+ "properties": {
27
+ "phase0_severity": {"const": "warn"},
28
+ "auto_mutation_allowed": {"const": false}
29
+ }
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://consiliency.io/contracts/version-skew-scenario.schema.json",
4
+ "title": "Consiliency version skew conformance scenario",
5
+ "type": "object",
6
+ "required": ["schema", "contract_version", "package_version"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "schema": {"const": "consiliency.version_skew_scenario.v1"},
10
+ "contract_version": {"type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$"},
11
+ "package_version": {"type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$"}
12
+ }
13
+ }
package/package.json CHANGED
@@ -1,16 +1,22 @@
1
1
  {
2
2
  "name": "@consiliency/contract",
3
- "version": "0.0.1",
4
- "description": "Consiliency cross-repo contract package: the .consiliency layout, archetype registry, required-doc sets, interface-declaration schema, loop-gate protocol, canonical_html.v1, and the version-skew protocol. Vendored by agent-harness and governed-pipeline; owned by neither. v0.0.x is a provisioning placeholder — contract content lands in 0.1.0.",
3
+ "version": "0.2.0",
4
+ "description": "Consiliency cross-repo contract package: shared JSON contract data, conformance vectors, thin npm/PyPI readers, and the canonical_html.v1 public contract surface.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "src/index.js",
8
8
  "types": "src/index.d.ts",
9
9
  "files": [
10
+ "core",
11
+ "conformance",
10
12
  "src",
11
13
  "README.md",
12
14
  "LICENSE"
13
15
  ],
16
+ "scripts": {
17
+ "test": "node --test tests/*.test.mjs",
18
+ "pack:check": "node tests/package-content.test.mjs"
19
+ },
14
20
  "publishConfig": {
15
21
  "access": "public"
16
22
  },
package/src/index.d.ts CHANGED
@@ -1,2 +1,8 @@
1
1
  export declare const CONTRACT_PACKAGE: "@consiliency/contract";
2
- export declare const STATUS: "placeholder";
2
+ export declare const CONTRACT_VERSION: "0.2.0";
3
+ export declare const CONTRACT: Record<string, unknown>;
4
+ export declare function loadContract(): Record<string, unknown>;
5
+ export declare function loadSchema(name: string): Record<string, unknown>;
6
+ export declare function loadRegistry(name: string): Record<string, unknown>;
7
+ export declare function listVectors(): string[];
8
+ export declare function loadVector(name: string): Record<string, unknown>;
package/src/index.js CHANGED
@@ -1,8 +1,48 @@
1
- // @consiliency/contract — provisioning placeholder (v0.0.x).
2
- //
3
- // The normative contract (the `.consiliency/` layout + manifest schema, the archetype
4
- // registry, required-doc sets, the interface-declaration schema, the loop-gate
5
- // protocol, `canonical_html.v1`, and the version-skew protocol) lands in 0.1.0 as
6
- // shared JSON data + conformance vectors, in byte-parity with the PyPI reader.
1
+ import { readdirSync, readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
7
5
  export const CONTRACT_PACKAGE = "@consiliency/contract";
8
- export const STATUS = "placeholder";
6
+ export const CONTRACT_VERSION = "0.2.0";
7
+
8
+ const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
9
+
10
+ function readJson(relativePath) {
11
+ return JSON.parse(readFileSync(join(packageRoot, relativePath), "utf8"));
12
+ }
13
+
14
+ function assertKnown(mapping, name, type) {
15
+ const relativePath = mapping[name];
16
+ if (!relativePath) {
17
+ throw new Error(`Unknown ${type}: ${name}`);
18
+ }
19
+ return relativePath;
20
+ }
21
+
22
+ export const CONTRACT = readJson("core/contract.json");
23
+
24
+ export function loadContract() {
25
+ return readJson("core/contract.json");
26
+ }
27
+
28
+ export function loadSchema(name) {
29
+ return readJson(assertKnown(CONTRACT.schemas, name, "schema"));
30
+ }
31
+
32
+ export function loadRegistry(name) {
33
+ return readJson(assertKnown(CONTRACT.registries, name, "registry"));
34
+ }
35
+
36
+ export function listVectors() {
37
+ return readdirSync(join(packageRoot, CONTRACT.conformance.vector_root))
38
+ .filter((name) => name.endsWith(".json"))
39
+ .sort();
40
+ }
41
+
42
+ export function loadVector(name) {
43
+ const filename = name.endsWith(".json") ? name : `${name}.json`;
44
+ if (!listVectors().includes(filename)) {
45
+ throw new Error(`Unknown vector: ${name}`);
46
+ }
47
+ return readJson(join(CONTRACT.conformance.vector_root, filename));
48
+ }