Skip to content

Commit 5c2efd7

Browse files
committed
fix(packaging): ship rules.manifest + schemas to npm; prepare runs build
Closes three packaging defects flagged in the post-governance audit: - package.json files: add rules.manifest.json so consumers installing from npm can read the canonical machine-readable rule surface the repo now treats as load-bearing. (schema/ was already covered.) - prepare: was tsc only; now runs the full build pipeline (tsc + schemas + rules manifest). git-based installs and any workflow that triggers npm prepare get every generated artefact, not just the TypeScript compiler output. - schema/rules.manifest.schema.json: the source comments referenced this file as the validating JSON Schema for rules.manifest.json but it was never emitted. build-schemas.mjs now generates it from RulesManifestSchema alongside the submission-related schemas.
1 parent f800081 commit 5c2efd7

3 files changed

Lines changed: 148 additions & 1 deletion

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"scripts": {
1515
"build": "tsc && node scripts/build-schemas.mjs && node scripts/build-rules-manifest.mjs",
16-
"prepare": "tsc",
16+
"prepare": "tsc && node scripts/build-schemas.mjs && node scripts/build-rules-manifest.mjs",
1717
"test": "vitest run",
1818
"test:watch": "vitest",
1919
"typecheck": "tsc --noEmit",
@@ -35,6 +35,7 @@
3535
"docs/artwork/*.svg",
3636
"docs/artwork/README.md",
3737
"schema",
38+
"rules.manifest.json",
3839
"README.md",
3940
"CHANGELOG.md",
4041
"LICENSE",

schema/rules.manifest.schema.json

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"version": {
5+
"type": "string",
6+
"minLength": 1,
7+
"description": "Manifest format version. Independent of the framework version that generated it."
8+
},
9+
"generatedAt": {
10+
"type": "string",
11+
"format": "date-time"
12+
},
13+
"counts": {
14+
"type": "object",
15+
"properties": {
16+
"total": {
17+
"type": "integer",
18+
"minimum": 0
19+
},
20+
"experimental": {
21+
"type": "integer",
22+
"minimum": 0
23+
},
24+
"stable": {
25+
"type": "integer",
26+
"minimum": 0
27+
},
28+
"deprecated": {
29+
"type": "integer",
30+
"minimum": 0
31+
},
32+
"byEngine": {
33+
"type": "object",
34+
"additionalProperties": {
35+
"type": "integer",
36+
"minimum": 0
37+
},
38+
"propertyNames": {
39+
"enum": [
40+
"source",
41+
"cross",
42+
"vision",
43+
"mobile"
44+
]
45+
}
46+
}
47+
},
48+
"required": [
49+
"total",
50+
"experimental",
51+
"stable",
52+
"deprecated",
53+
"byEngine"
54+
],
55+
"additionalProperties": false,
56+
"description": "Pre-computed counts for downstream consumers (parity CI, release notes, README). Derivable from `rules` but emitted to keep readers from having to recount."
57+
},
58+
"rules": {
59+
"type": "array",
60+
"items": {
61+
"type": "object",
62+
"properties": {
63+
"id": {
64+
"type": "string",
65+
"pattern": "^ahd\\/[a-z0-9/-]+$"
66+
},
67+
"engine": {
68+
"type": "string",
69+
"enum": [
70+
"source",
71+
"cross",
72+
"vision",
73+
"mobile"
74+
]
75+
},
76+
"surface": {
77+
"type": "array",
78+
"items": {
79+
"type": "string"
80+
},
81+
"description": "Subsurfaces the rule operates on (html, css, jsx, tsx, tailwind, svg, vision, mobile, etc.). Optional; mobile and vision rules typically omit since the engine implies the surface."
82+
},
83+
"severity": {
84+
"type": "string",
85+
"enum": [
86+
"error",
87+
"warn",
88+
"info"
89+
],
90+
"description": "error fails CI; warn prints; info advisory. Vision rules ship at warn by convention since they emit from a probabilistic critic."
91+
},
92+
"status": {
93+
"type": "string",
94+
"enum": [
95+
"experimental",
96+
"stable",
97+
"deprecated"
98+
]
99+
},
100+
"introducedAt": {
101+
"type": "string",
102+
"minLength": 1,
103+
"description": "Semver-shaped string identifying the version that first shipped the rule. Pre-0.9 rules use '<= 0.8.x'."
104+
},
105+
"deprecatedAt": {
106+
"type": "string"
107+
},
108+
"deprecationReason": {
109+
"type": "string"
110+
},
111+
"description": {
112+
"type": "string",
113+
"minLength": 1
114+
}
115+
},
116+
"required": [
117+
"id",
118+
"engine",
119+
"severity",
120+
"status",
121+
"introducedAt",
122+
"description"
123+
],
124+
"additionalProperties": false
125+
},
126+
"minItems": 1
127+
}
128+
},
129+
"required": [
130+
"version",
131+
"generatedAt",
132+
"counts",
133+
"rules"
134+
],
135+
"additionalProperties": false,
136+
"$schema": "https://json-schema.org/draft/2020-12/schema",
137+
"$id": "https://ahd.adastra.computer/schema/rules.manifest.schema.json",
138+
"title": "AHD rules manifest (governance Layer 1)"
139+
}

scripts/build-schemas.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const {
2626
ManifestCurrentSchema,
2727
ManifestTargetSchema,
2828
SampleEnvelopeTargetSchema,
29+
RulesManifestSchema,
2930
} = await import(pathToFileURL(distTypes).href);
3031

3132
const schemaDir = resolve(root, "schema");
@@ -67,3 +68,9 @@ emit(
6768
"https://ahd.adastra.computer/schema/sample-envelope.target.schema.json",
6869
"AHD per-sample envelope (target shape)",
6970
);
71+
emit(
72+
"rules.manifest",
73+
RulesManifestSchema,
74+
"https://ahd.adastra.computer/schema/rules.manifest.schema.json",
75+
"AHD rules manifest (governance Layer 1)",
76+
);

0 commit comments

Comments
 (0)