@habitat-ai/service 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.
- package/dist/client.d.ts +16 -0
- package/dist/client.js +16 -0
- package/dist/service/base.d.ts +28 -0
- package/dist/service/base.js +1 -0
- package/dist/service/contract.d.ts +10 -0
- package/dist/service/contract.js +5 -0
- package/dist/service/impl.d.ts +508 -0
- package/dist/service/impl.js +7 -0
- package/dist/service/modules/catalog/contract/catalog.d.ts +252 -0
- package/dist/service/modules/catalog/contract/catalog.js +13 -0
- package/dist/service/modules/catalog/contract/index.d.ts +3 -0
- package/dist/service/modules/catalog/contract/index.js +3 -0
- package/dist/service/modules/catalog/model/dto/catalog.d.ts +276 -0
- package/dist/service/modules/catalog/model/dto/catalog.js +380 -0
- package/dist/service/modules/catalog/model/dto/check.d.ts +104 -0
- package/dist/service/modules/catalog/model/dto/check.js +305 -0
- package/dist/service/modules/catalog/model/dto/structure.d.ts +23 -0
- package/dist/service/modules/catalog/model/dto/structure.js +93 -0
- package/dist/service/modules/catalog/model/policy/catalog.d.ts +109 -0
- package/dist/service/modules/catalog/model/policy/catalog.js +607 -0
- package/dist/service/modules/catalog/model/policy/check.d.ts +57 -0
- package/dist/service/modules/catalog/model/policy/check.js +207 -0
- package/dist/service/modules/catalog/model/policy/structure.d.ts +64 -0
- package/dist/service/modules/catalog/model/policy/structure.js +249 -0
- package/dist/service/modules/catalog/module.d.ts +521 -0
- package/dist/service/modules/catalog/module.js +12 -0
- package/dist/service/modules/catalog/router/catalog.router.d.ts +266 -0
- package/dist/service/modules/catalog/router/catalog.router.js +659 -0
- package/dist/service/modules/catalog/router.d.ts +265 -0
- package/dist/service/modules/catalog/router.js +3 -0
- package/dist/service/router.d.ts +267 -0
- package/dist/service/router.js +4 -0
- package/package.json +49 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
/** Maximum stable issues returned by one rejected resolution. */
|
|
3
|
+
export const MAX_CATALOG_ISSUES = 100;
|
|
4
|
+
const IdSchema = Type.String({
|
|
5
|
+
minLength: 1,
|
|
6
|
+
maxLength: 200,
|
|
7
|
+
pattern: "^[a-z0-9][a-z0-9_-]*$",
|
|
8
|
+
description: "Lowercase Habitat identity.",
|
|
9
|
+
});
|
|
10
|
+
const ProjectIdSchema = Type.String({
|
|
11
|
+
minLength: 1,
|
|
12
|
+
maxLength: 250,
|
|
13
|
+
description: "Repository project identity that owns an admitted instance.",
|
|
14
|
+
});
|
|
15
|
+
const InstanceIdSchema = Type.String({
|
|
16
|
+
minLength: 1,
|
|
17
|
+
maxLength: 250,
|
|
18
|
+
pattern: "^(?!.*\\.\\.)(?:@[a-z0-9][a-z0-9._-]*/)?[a-z0-9][a-z0-9._-]*$",
|
|
19
|
+
description: "Repository-unique Habitat instance identity.",
|
|
20
|
+
});
|
|
21
|
+
const RelativePathSchema = Type.String({
|
|
22
|
+
minLength: 1,
|
|
23
|
+
maxLength: 4_096,
|
|
24
|
+
description: "Normalized repository-relative path.",
|
|
25
|
+
});
|
|
26
|
+
const PackageNameSchema = Type.String({
|
|
27
|
+
minLength: 1,
|
|
28
|
+
maxLength: 214,
|
|
29
|
+
description: "Exact npm package identity.",
|
|
30
|
+
});
|
|
31
|
+
const PackageVersionSchema = Type.String({
|
|
32
|
+
minLength: 1,
|
|
33
|
+
maxLength: 200,
|
|
34
|
+
description: "Version declared by the selected npm package.",
|
|
35
|
+
});
|
|
36
|
+
const AbsolutePathSchema = Type.String({
|
|
37
|
+
minLength: 1,
|
|
38
|
+
maxLength: 16_384,
|
|
39
|
+
description: "Resolved absolute filesystem path.",
|
|
40
|
+
});
|
|
41
|
+
const PathKindSchema = Type.Union([Type.Literal("directory"), Type.Literal("file")], {
|
|
42
|
+
description: "Expected filesystem entry kind.",
|
|
43
|
+
});
|
|
44
|
+
const RuleLaneSchema = Type.Union([Type.Literal("enforced"), Type.Literal("advisory")], {
|
|
45
|
+
description: "Policy lane declared by a Habitat rule.",
|
|
46
|
+
});
|
|
47
|
+
const PatternNameSchema = Type.String({
|
|
48
|
+
minLength: 1,
|
|
49
|
+
maxLength: 500,
|
|
50
|
+
description: "Named Grit pattern invoked by a rule.",
|
|
51
|
+
});
|
|
52
|
+
const RuleMessageSchema = Type.String({
|
|
53
|
+
minLength: 1,
|
|
54
|
+
maxLength: 8_192,
|
|
55
|
+
description: "Caller-facing message for a rule finding.",
|
|
56
|
+
});
|
|
57
|
+
const RuleRemediationSchema = Type.Union([Type.String({ maxLength: 16_384 }), Type.Null()], {
|
|
58
|
+
description: "Remediation guidance when the rule supplies it.",
|
|
59
|
+
});
|
|
60
|
+
const CatalogIssueCodeSchema = Type.Union([
|
|
61
|
+
Type.Literal("authority-anchor-mismatch"),
|
|
62
|
+
Type.Literal("authority-blueprint-missing"),
|
|
63
|
+
Type.Literal("authority-compatibility-invalid"),
|
|
64
|
+
Type.Literal("authority-definition-invalid"),
|
|
65
|
+
Type.Literal("authority-definition-kind-mismatch"),
|
|
66
|
+
Type.Literal("authority-duplicate-blueprint"),
|
|
67
|
+
Type.Literal("authority-duplicate-instance"),
|
|
68
|
+
Type.Literal("authority-duplicate-rule"),
|
|
69
|
+
Type.Literal("authority-filesystem-failed"),
|
|
70
|
+
Type.Literal("authority-json-invalid"),
|
|
71
|
+
Type.Literal("authority-manifest-invalid"),
|
|
72
|
+
Type.Literal("authority-order-invalid"),
|
|
73
|
+
Type.Literal("authority-path-escape"),
|
|
74
|
+
Type.Literal("authority-path-invalid"),
|
|
75
|
+
Type.Literal("authority-path-kind-mismatch"),
|
|
76
|
+
Type.Literal("authority-path-missing"),
|
|
77
|
+
Type.Literal("authority-package-name-mismatch"),
|
|
78
|
+
Type.Literal("authority-policy-pack-members-unsupported"),
|
|
79
|
+
Type.Literal("authority-resolution-failed"),
|
|
80
|
+
Type.Literal("authority-rule-invalid"),
|
|
81
|
+
Type.Literal("authority-schema-invalid"),
|
|
82
|
+
Type.Literal("authority-toml-invalid"),
|
|
83
|
+
Type.Literal("authority-version-mismatch"),
|
|
84
|
+
Type.Literal("authority-workspace-root-invalid"),
|
|
85
|
+
], { description: "Closed stable catalog issue identity." });
|
|
86
|
+
/** npm metadata fields that own selected policy-pack package identity. */
|
|
87
|
+
export const PolicyPackPackageJsonSchema = Type.Object({
|
|
88
|
+
name: PackageNameSchema,
|
|
89
|
+
version: PackageVersionSchema,
|
|
90
|
+
}, { additionalProperties: true, description: "Selected policy-pack npm metadata." });
|
|
91
|
+
const PolicyPackBlueprintMemberSchema = Type.Object({
|
|
92
|
+
id: IdSchema,
|
|
93
|
+
version: Type.Integer({ minimum: 1, description: "Exact blueprint version." }),
|
|
94
|
+
path: RelativePathSchema,
|
|
95
|
+
}, { additionalProperties: false, description: "One declared policy-pack blueprint member." });
|
|
96
|
+
/** Closed selected policy-pack protocol 1 manifest. */
|
|
97
|
+
export const PolicyPackManifestSchema = Type.Object({
|
|
98
|
+
protocolVersion: Type.Literal(1, { description: "Supported policy-pack protocol." }),
|
|
99
|
+
blueprints: Type.Array(PolicyPackBlueprintMemberSchema, {
|
|
100
|
+
description: "Closed declared blueprint member set.",
|
|
101
|
+
}),
|
|
102
|
+
}, { additionalProperties: false, description: "Closed Habitat policy-pack manifest." });
|
|
103
|
+
const BlueprintGritAcquisitionSchema = Type.Object({
|
|
104
|
+
kind: Type.Union([Type.Literal("check"), Type.Literal("apply-dry-run")], {
|
|
105
|
+
description: "Rule evaluation operation admitted for the Grit runner.",
|
|
106
|
+
}),
|
|
107
|
+
rootRoles: Type.Array(IdSchema, {
|
|
108
|
+
uniqueItems: true,
|
|
109
|
+
description: "Root roles whose bound paths enter evaluation.",
|
|
110
|
+
}),
|
|
111
|
+
selections: Type.Array(IdSchema, {
|
|
112
|
+
uniqueItems: true,
|
|
113
|
+
description: "Selection axes whose members enter evaluation.",
|
|
114
|
+
}),
|
|
115
|
+
}, { additionalProperties: false, description: "Blueprint-level Grit acquisition declaration." });
|
|
116
|
+
const BlueprintStructureRunnerSchema = Type.Object({
|
|
117
|
+
name: Type.Literal("habitat", { description: "Native Habitat runner identity." }),
|
|
118
|
+
mode: Type.Literal("structure", { description: "Native structural evaluation mode." }),
|
|
119
|
+
structure: RelativePathSchema,
|
|
120
|
+
}, { additionalProperties: false, description: "Blueprint structural runner declaration." });
|
|
121
|
+
const BlueprintGritRunnerSchema = Type.Object({
|
|
122
|
+
name: Type.Literal("grit", { description: "Grit runner identity." }),
|
|
123
|
+
pattern: RelativePathSchema,
|
|
124
|
+
patternName: PatternNameSchema,
|
|
125
|
+
acquisition: BlueprintGritAcquisitionSchema,
|
|
126
|
+
}, { additionalProperties: false, description: "Blueprint Grit runner declaration." });
|
|
127
|
+
const BlueprintRuleDefinitionSchema = Type.Object({
|
|
128
|
+
id: IdSchema,
|
|
129
|
+
lane: RuleLaneSchema,
|
|
130
|
+
message: RuleMessageSchema,
|
|
131
|
+
remediate: RuleRemediationSchema,
|
|
132
|
+
runner: Type.Union([BlueprintStructureRunnerSchema, BlueprintGritRunnerSchema], {
|
|
133
|
+
description: "Mechanical runner declaration resolved for each application.",
|
|
134
|
+
}),
|
|
135
|
+
}, { additionalProperties: false, description: "One reusable blueprint rule." });
|
|
136
|
+
const BlueprintRootDefinitionSchema = Type.Object({
|
|
137
|
+
id: IdSchema,
|
|
138
|
+
required: Type.Boolean({ description: "Whether every instance must bind this root role." }),
|
|
139
|
+
kind: PathKindSchema,
|
|
140
|
+
}, { additionalProperties: false, description: "One named instance root role." });
|
|
141
|
+
const BlueprintSelectionDefinitionSchema = Type.Object({
|
|
142
|
+
id: IdSchema,
|
|
143
|
+
root: IdSchema,
|
|
144
|
+
kind: PathKindSchema,
|
|
145
|
+
memberPattern: Type.String({
|
|
146
|
+
minLength: 1,
|
|
147
|
+
maxLength: 2_048,
|
|
148
|
+
description: "Regular expression that admits member identities.",
|
|
149
|
+
}),
|
|
150
|
+
pathTemplate: Type.String({
|
|
151
|
+
minLength: 1,
|
|
152
|
+
maxLength: 4_096,
|
|
153
|
+
description: "Root-relative path template containing one {member} placeholder.",
|
|
154
|
+
}),
|
|
155
|
+
}, { additionalProperties: false, description: "Package-style selected-member axis." });
|
|
156
|
+
/** Closed schema for one version 3 blueprint definition document. */
|
|
157
|
+
export const BlueprintDefinitionSchema = Type.Object({
|
|
158
|
+
schemaVersion: Type.Literal(1, { description: "Blueprint document schema version." }),
|
|
159
|
+
id: IdSchema,
|
|
160
|
+
version: Type.Integer({ minimum: 1, description: "Positive blueprint version." }),
|
|
161
|
+
rules: Type.Array(BlueprintRuleDefinitionSchema, {
|
|
162
|
+
description: "Sorted reusable rules supplied by this blueprint version.",
|
|
163
|
+
}),
|
|
164
|
+
instance: Type.Object({
|
|
165
|
+
manifest: Type.Literal("habitat.toml", {
|
|
166
|
+
description: "Only admitted instance manifest basename.",
|
|
167
|
+
}),
|
|
168
|
+
anchorRoot: IdSchema,
|
|
169
|
+
roots: Type.Array(BlueprintRootDefinitionSchema, {
|
|
170
|
+
minItems: 1,
|
|
171
|
+
description: "Sorted closed root-role vocabulary for instances.",
|
|
172
|
+
}),
|
|
173
|
+
selections: Type.Array(BlueprintSelectionDefinitionSchema, {
|
|
174
|
+
description: "Sorted closed package-style selection vocabulary.",
|
|
175
|
+
}),
|
|
176
|
+
}, { additionalProperties: false, description: "Instance vocabulary for this blueprint." }),
|
|
177
|
+
}, { additionalProperties: false, description: "Version 3 local blueprint definition authority." });
|
|
178
|
+
/** Closed schema for one version 3 local instance document. */
|
|
179
|
+
export const HabitatInstanceManifestSchema = Type.Object({
|
|
180
|
+
schemaVersion: Type.Literal(1, { description: "Instance document schema version." }),
|
|
181
|
+
id: InstanceIdSchema,
|
|
182
|
+
ownerProject: ProjectIdSchema,
|
|
183
|
+
blueprint: IdSchema,
|
|
184
|
+
blueprintVersion: Type.Integer({
|
|
185
|
+
minimum: 1,
|
|
186
|
+
description: "Exact selected blueprint version.",
|
|
187
|
+
}),
|
|
188
|
+
roots: Type.Record(IdSchema, RelativePathSchema, {
|
|
189
|
+
additionalProperties: false,
|
|
190
|
+
description: "Root-role bindings keyed by blueprint root identity.",
|
|
191
|
+
}),
|
|
192
|
+
selections: Type.Record(IdSchema, Type.Array(IdSchema, {
|
|
193
|
+
minItems: 1,
|
|
194
|
+
uniqueItems: true,
|
|
195
|
+
description: "Sorted selected member identities for one axis.",
|
|
196
|
+
}), { additionalProperties: false, description: "Selected members keyed by axis identity." }),
|
|
197
|
+
}, { additionalProperties: false, description: "Version 3 local Habitat instance authority." });
|
|
198
|
+
const LocalAuthorityProvenanceSchema = Type.Object({
|
|
199
|
+
kind: Type.Literal("local", { description: "Local repository authority kind." }),
|
|
200
|
+
authorityRoot: AbsolutePathSchema,
|
|
201
|
+
relativePath: RelativePathSchema,
|
|
202
|
+
}, { additionalProperties: false, description: "Local authority origin for a resolved fact." });
|
|
203
|
+
const BlueprintDefinitionRecordSchema = Type.Object({
|
|
204
|
+
definition: BlueprintDefinitionSchema,
|
|
205
|
+
provenance: LocalAuthorityProvenanceSchema,
|
|
206
|
+
}, { additionalProperties: false, description: "Admitted local blueprint with provenance." });
|
|
207
|
+
const ResolvedRootSchema = Type.Object({
|
|
208
|
+
id: IdSchema,
|
|
209
|
+
required: Type.Boolean({ description: "Whether the blueprint requires this root." }),
|
|
210
|
+
kind: PathKindSchema,
|
|
211
|
+
path: RelativePathSchema,
|
|
212
|
+
}, { additionalProperties: false, description: "Resolved instance root binding." });
|
|
213
|
+
const ResolvedSelectionMemberSchema = Type.Object({
|
|
214
|
+
id: IdSchema,
|
|
215
|
+
kind: PathKindSchema,
|
|
216
|
+
path: RelativePathSchema,
|
|
217
|
+
}, { additionalProperties: false, description: "Resolved selected member path." });
|
|
218
|
+
const ResolvedSelectionSchema = Type.Object({
|
|
219
|
+
id: IdSchema,
|
|
220
|
+
root: IdSchema,
|
|
221
|
+
members: Type.Array(ResolvedSelectionMemberSchema, {
|
|
222
|
+
minItems: 1,
|
|
223
|
+
description: "Resolved members in stable identity order.",
|
|
224
|
+
}),
|
|
225
|
+
}, { additionalProperties: false, description: "Resolved package-style selection." });
|
|
226
|
+
const ResolvedBlueprintInstanceSchema = Type.Object({
|
|
227
|
+
id: InstanceIdSchema,
|
|
228
|
+
ownerProject: ProjectIdSchema,
|
|
229
|
+
blueprint: IdSchema,
|
|
230
|
+
blueprintVersion: Type.Integer({ minimum: 1, description: "Resolved blueprint version." }),
|
|
231
|
+
manifestPath: RelativePathSchema,
|
|
232
|
+
roots: Type.Array(ResolvedRootSchema, {
|
|
233
|
+
minItems: 1,
|
|
234
|
+
description: "Bound instance roots in stable role order.",
|
|
235
|
+
}),
|
|
236
|
+
selections: Type.Array(ResolvedSelectionSchema, {
|
|
237
|
+
description: "Resolved selected-member axes in stable identity order.",
|
|
238
|
+
}),
|
|
239
|
+
}, { additionalProperties: false, description: "One fully admitted local blueprint instance." });
|
|
240
|
+
const ResolvedRuleAssetSchema = Type.Object({
|
|
241
|
+
provenance: LocalAuthorityProvenanceSchema,
|
|
242
|
+
relativePath: RelativePathSchema,
|
|
243
|
+
absolutePath: AbsolutePathSchema,
|
|
244
|
+
}, { additionalProperties: false, description: "Resolved local runner asset." });
|
|
245
|
+
const ResolvedRootBindingSchema = Type.Object({
|
|
246
|
+
rootRole: IdSchema,
|
|
247
|
+
required: Type.Boolean({ description: "Whether the application requires this binding." }),
|
|
248
|
+
kind: PathKindSchema,
|
|
249
|
+
path: Type.Optional(RelativePathSchema),
|
|
250
|
+
}, { additionalProperties: false, description: "Structure-runner root binding." });
|
|
251
|
+
const AcquisitionSourceSchema = Type.Union([
|
|
252
|
+
Type.Object({
|
|
253
|
+
kind: Type.Literal("root-role", { description: "Root-role acquisition source." }),
|
|
254
|
+
id: IdSchema,
|
|
255
|
+
}, { additionalProperties: false, description: "Acquisition from one bound root role." }),
|
|
256
|
+
Type.Object({
|
|
257
|
+
kind: Type.Literal("selection", { description: "Selected-member acquisition source." }),
|
|
258
|
+
id: IdSchema,
|
|
259
|
+
member: IdSchema,
|
|
260
|
+
}, { additionalProperties: false, description: "Acquisition from one selected member." }),
|
|
261
|
+
], { description: "Origin of one resolved acquisition path." });
|
|
262
|
+
const ResolvedAcquisitionEntrySchema = Type.Object({
|
|
263
|
+
source: AcquisitionSourceSchema,
|
|
264
|
+
kind: PathKindSchema,
|
|
265
|
+
path: RelativePathSchema,
|
|
266
|
+
}, { additionalProperties: false, description: "One resolved Grit acquisition entry." });
|
|
267
|
+
const ResolvedStructureRunnerSchema = Type.Object({
|
|
268
|
+
name: Type.Literal("habitat", { description: "Native Habitat runner identity." }),
|
|
269
|
+
mode: Type.Literal("structure", { description: "Native structural evaluation mode." }),
|
|
270
|
+
structure: ResolvedRuleAssetSchema,
|
|
271
|
+
rootBindings: Type.Array(ResolvedRootBindingSchema, {
|
|
272
|
+
minItems: 1,
|
|
273
|
+
description: "Resolved root bindings available to the structure runner.",
|
|
274
|
+
}),
|
|
275
|
+
}, { additionalProperties: false, description: "Resolved structure runner facts." });
|
|
276
|
+
const ResolvedGritRunnerSchema = Type.Object({
|
|
277
|
+
name: Type.Literal("grit", { description: "Grit runner identity." }),
|
|
278
|
+
pattern: ResolvedRuleAssetSchema,
|
|
279
|
+
patternName: PatternNameSchema,
|
|
280
|
+
acquisition: Type.Object({
|
|
281
|
+
kind: Type.Union([Type.Literal("check"), Type.Literal("apply-dry-run")], {
|
|
282
|
+
description: "Resolved Grit operation kind.",
|
|
283
|
+
}),
|
|
284
|
+
entries: Type.Array(ResolvedAcquisitionEntrySchema, {
|
|
285
|
+
minItems: 1,
|
|
286
|
+
description: "Resolved acquisition paths in stable source order.",
|
|
287
|
+
}),
|
|
288
|
+
}, { additionalProperties: false, description: "Resolved Grit acquisition facts." }),
|
|
289
|
+
}, { additionalProperties: false, description: "Resolved Grit runner facts." });
|
|
290
|
+
const ResolvedRuleApplicationSchema = Type.Object({
|
|
291
|
+
ownerProject: ProjectIdSchema,
|
|
292
|
+
instanceId: InstanceIdSchema,
|
|
293
|
+
blueprint: IdSchema,
|
|
294
|
+
blueprintVersion: Type.Integer({ minimum: 1, description: "Resolved blueprint version." }),
|
|
295
|
+
ruleId: IdSchema,
|
|
296
|
+
manifestPath: RelativePathSchema,
|
|
297
|
+
lane: RuleLaneSchema,
|
|
298
|
+
message: RuleMessageSchema,
|
|
299
|
+
remediate: RuleRemediationSchema,
|
|
300
|
+
provenance: LocalAuthorityProvenanceSchema,
|
|
301
|
+
runner: Type.Union([ResolvedStructureRunnerSchema, ResolvedGritRunnerSchema], {
|
|
302
|
+
description: "Fully resolved runner and acquisition facts.",
|
|
303
|
+
}),
|
|
304
|
+
}, { additionalProperties: false, description: "One resolved instance/rule application." });
|
|
305
|
+
const CompatibilityRuleSchema = Type.Object({
|
|
306
|
+
id: IdSchema,
|
|
307
|
+
ownerProject: ProjectIdSchema,
|
|
308
|
+
manifestPath: RelativePathSchema,
|
|
309
|
+
}, { additionalProperties: false, description: "Inert version 2 rule identity summary." });
|
|
310
|
+
/** Closed compatibility index source schema. */
|
|
311
|
+
export const CompatibilityIndexSchema = Type.Object({
|
|
312
|
+
$comment: Type.Optional(Type.String({ description: "Optional legacy index comment." })),
|
|
313
|
+
schemaVersion: Type.Literal(2, { description: "Legacy registry schema version." }),
|
|
314
|
+
ownerRoots: Type.Record(ProjectIdSchema, RelativePathSchema, {
|
|
315
|
+
minProperties: 1,
|
|
316
|
+
description: "Legacy owner roots keyed by project identity.",
|
|
317
|
+
}),
|
|
318
|
+
}, { additionalProperties: false, description: "Legacy version 2 registry index." });
|
|
319
|
+
/** Minimum TypeBox admission schema for an inert legacy rule manifest. */
|
|
320
|
+
export const CompatibilityRuleSourceSchema = Type.Object({
|
|
321
|
+
schemaVersion: Type.Literal(2, { description: "Legacy rule schema version." }),
|
|
322
|
+
id: IdSchema,
|
|
323
|
+
ownerProject: ProjectIdSchema,
|
|
324
|
+
}, { additionalProperties: true, description: "Legacy rule source identity projected inertly." });
|
|
325
|
+
const CompatibilityCatalogSchema = Type.Object({
|
|
326
|
+
schemaVersion: Type.Literal(2, { description: "Legacy compatibility catalog version." }),
|
|
327
|
+
ownerRoots: Type.Record(ProjectIdSchema, RelativePathSchema, {
|
|
328
|
+
description: "Validated legacy owner roots keyed by project identity.",
|
|
329
|
+
}),
|
|
330
|
+
rules: Type.Array(CompatibilityRuleSchema, {
|
|
331
|
+
description: "Stable inert legacy rule identity summaries.",
|
|
332
|
+
}),
|
|
333
|
+
}, { additionalProperties: false, description: "Inert version 2 compatibility facts." });
|
|
334
|
+
const ResolvedPolicyPackSchema = Type.Object({
|
|
335
|
+
name: PackageNameSchema,
|
|
336
|
+
version: PackageVersionSchema,
|
|
337
|
+
protocolVersion: Type.Literal(1, {
|
|
338
|
+
description: "Admitted policy-pack protocol version.",
|
|
339
|
+
}),
|
|
340
|
+
blueprints: Type.Array(PolicyPackBlueprintMemberSchema, {
|
|
341
|
+
description: "Admitted blueprint members in manifest order.",
|
|
342
|
+
}),
|
|
343
|
+
}, { additionalProperties: false, description: "One admitted selected policy pack." });
|
|
344
|
+
const HabitatCatalogSchema = Type.Object({
|
|
345
|
+
schemaVersion: Type.Literal(3, { description: "Resolved authority catalog version." }),
|
|
346
|
+
policyPack: ResolvedPolicyPackSchema,
|
|
347
|
+
blueprints: Type.Array(BlueprintDefinitionRecordSchema, {
|
|
348
|
+
description: "Admitted local blueprints in stable identity/version order.",
|
|
349
|
+
}),
|
|
350
|
+
instances: Type.Array(ResolvedBlueprintInstanceSchema, {
|
|
351
|
+
description: "Resolved instances in stable identity order.",
|
|
352
|
+
}),
|
|
353
|
+
applications: Type.Array(ResolvedRuleApplicationSchema, {
|
|
354
|
+
description: "Resolved applications in stable rule/instance order.",
|
|
355
|
+
}),
|
|
356
|
+
compatibility: CompatibilityCatalogSchema,
|
|
357
|
+
}, { additionalProperties: false, description: "Complete local Habitat authority catalog." });
|
|
358
|
+
/** Closed empty request; the service owns repository authority enumeration. */
|
|
359
|
+
export const ResolveCatalogInputSchema = Type.Object({}, { additionalProperties: false, description: "Catalog resolution request." });
|
|
360
|
+
/** Closed stable issue schema returned for expected admission failures. */
|
|
361
|
+
export const CatalogIssueSchema = Type.Object({
|
|
362
|
+
code: CatalogIssueCodeSchema,
|
|
363
|
+
path: Type.String({ maxLength: 4_096, description: "Source or repository path at fault." }),
|
|
364
|
+
message: Type.String({ minLength: 1, maxLength: 8_192, description: "Bounded issue detail." }),
|
|
365
|
+
}, { additionalProperties: false, description: "One expected catalog admission issue." });
|
|
366
|
+
/** Closed resolved/rejected result union for catalog resolution. */
|
|
367
|
+
export const ResolveCatalogResultSchema = Type.Union([
|
|
368
|
+
Type.Object({
|
|
369
|
+
_tag: Type.Literal("Resolved", { description: "Successful resolution discriminant." }),
|
|
370
|
+
catalog: HabitatCatalogSchema,
|
|
371
|
+
}, { additionalProperties: false, description: "Successfully resolved catalog result." }),
|
|
372
|
+
Type.Object({
|
|
373
|
+
_tag: Type.Literal("Rejected", { description: "Rejected resolution discriminant." }),
|
|
374
|
+
issues: Type.Array(CatalogIssueSchema, {
|
|
375
|
+
minItems: 1,
|
|
376
|
+
maxItems: MAX_CATALOG_ISSUES,
|
|
377
|
+
description: "Bounded stable admission issues.",
|
|
378
|
+
}),
|
|
379
|
+
}, { additionalProperties: false, description: "Expected rejected catalog result." }),
|
|
380
|
+
], { description: "Resolved or rejected Habitat catalog outcome." });
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type Static, Type } from "typebox";
|
|
2
|
+
/** Closed request for checking the currently resolved Habitat catalog. */
|
|
3
|
+
export declare const CheckCatalogInputSchema: Type.TObject<{
|
|
4
|
+
selectors: Type.TOptional<Type.TObject<{
|
|
5
|
+
owner: Type.TOptional<Type.TString>;
|
|
6
|
+
instance: Type.TOptional<Type.TString>;
|
|
7
|
+
rule: Type.TOptional<Type.TString>;
|
|
8
|
+
rules: Type.TOptional<Type.TArray<Type.TString>>;
|
|
9
|
+
runner: Type.TOptional<Type.TString>;
|
|
10
|
+
}>>;
|
|
11
|
+
}>;
|
|
12
|
+
/** Closed total result for one current-catalog check. */
|
|
13
|
+
export declare const CheckCatalogResultSchema: Type.TUnion<[Type.TObject<{
|
|
14
|
+
_tag: Type.TLiteral<"CatalogRejected">;
|
|
15
|
+
issues: Type.TArray<Type.TObject<{
|
|
16
|
+
code: Type.TUnion<[Type.TLiteral<"authority-anchor-mismatch">, Type.TLiteral<"authority-blueprint-missing">, Type.TLiteral<"authority-compatibility-invalid">, Type.TLiteral<"authority-definition-invalid">, Type.TLiteral<"authority-definition-kind-mismatch">, Type.TLiteral<"authority-duplicate-blueprint">, Type.TLiteral<"authority-duplicate-instance">, Type.TLiteral<"authority-duplicate-rule">, Type.TLiteral<"authority-filesystem-failed">, Type.TLiteral<"authority-json-invalid">, Type.TLiteral<"authority-manifest-invalid">, Type.TLiteral<"authority-order-invalid">, Type.TLiteral<"authority-path-escape">, Type.TLiteral<"authority-path-invalid">, Type.TLiteral<"authority-path-kind-mismatch">, Type.TLiteral<"authority-path-missing">, Type.TLiteral<"authority-package-name-mismatch">, Type.TLiteral<"authority-policy-pack-members-unsupported">, Type.TLiteral<"authority-resolution-failed">, Type.TLiteral<"authority-rule-invalid">, Type.TLiteral<"authority-schema-invalid">, Type.TLiteral<"authority-toml-invalid">, Type.TLiteral<"authority-version-mismatch">, Type.TLiteral<"authority-workspace-root-invalid">]>;
|
|
17
|
+
path: Type.TString;
|
|
18
|
+
message: Type.TString;
|
|
19
|
+
}>>;
|
|
20
|
+
}>, Type.TObject<{
|
|
21
|
+
_tag: Type.TLiteral<"SelectionRejected">;
|
|
22
|
+
issues: Type.TArray<Type.TObject<{
|
|
23
|
+
code: Type.TUnion<[Type.TLiteral<"selector-empty">, Type.TLiteral<"selector-unknown">, Type.TLiteral<"selector-wrong-namespace">, Type.TLiteral<"runner-unsupported">]>;
|
|
24
|
+
selector: Type.TString;
|
|
25
|
+
message: Type.TString;
|
|
26
|
+
}>>;
|
|
27
|
+
}>, Type.TObject<{
|
|
28
|
+
_tag: Type.TLiteral<"Completed">;
|
|
29
|
+
ok: Type.TBoolean;
|
|
30
|
+
applications: Type.TArray<Type.TUnion<[Type.TObject<{
|
|
31
|
+
ownerProject: Type.TString;
|
|
32
|
+
instanceId: Type.TString;
|
|
33
|
+
ruleId: Type.TString;
|
|
34
|
+
runner: Type.TLiteral<"grit">;
|
|
35
|
+
lane: Type.TUnion<[Type.TLiteral<"enforced">, Type.TLiteral<"advisory">]>;
|
|
36
|
+
locked: Type.TLiteral<false>;
|
|
37
|
+
status: Type.TUnion<[Type.TLiteral<"pass">, Type.TLiteral<"fail">, Type.TLiteral<"advisory-findings">, Type.TLiteral<"error">]>;
|
|
38
|
+
message: Type.TString;
|
|
39
|
+
remediate: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
40
|
+
disposition: Type.TUnion<[Type.TObject<{
|
|
41
|
+
kind: Type.TLiteral<"evaluated">;
|
|
42
|
+
}>, Type.TObject<{
|
|
43
|
+
kind: Type.TLiteral<"failed">;
|
|
44
|
+
reason: Type.TUnion<[Type.TUnion<[Type.TLiteral<"InvalidInput">, Type.TLiteral<"SetupFailed">, Type.TLiteral<"ExecutionFailed">, Type.TLiteral<"TimedOut">, Type.TLiteral<"InvalidOutput">]>, Type.TLiteral<"PatternReadFailed">, Type.TLiteral<"PatternInvalid">, Type.TLiteral<"FindingPathInvalid">]>;
|
|
45
|
+
detail: Type.TString;
|
|
46
|
+
}>]>;
|
|
47
|
+
findings: Type.TArray<Type.TObject<{
|
|
48
|
+
path: Type.TString;
|
|
49
|
+
start: Type.TObject<{
|
|
50
|
+
line: Type.TReadonly<Type.TInteger>;
|
|
51
|
+
column: Type.TReadonly<Type.TInteger>;
|
|
52
|
+
offset: Type.TReadonly<Type.TInteger>;
|
|
53
|
+
}>;
|
|
54
|
+
end: Type.TObject<{
|
|
55
|
+
line: Type.TReadonly<Type.TInteger>;
|
|
56
|
+
column: Type.TReadonly<Type.TInteger>;
|
|
57
|
+
offset: Type.TReadonly<Type.TInteger>;
|
|
58
|
+
}>;
|
|
59
|
+
message: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
60
|
+
severity: Type.TUnion<[Type.TLiteral<"error">, Type.TLiteral<"advisory">]>;
|
|
61
|
+
baselined: Type.TLiteral<false>;
|
|
62
|
+
}>>;
|
|
63
|
+
}>, Type.TObject<{
|
|
64
|
+
ownerProject: Type.TString;
|
|
65
|
+
instanceId: Type.TString;
|
|
66
|
+
ruleId: Type.TString;
|
|
67
|
+
runner: Type.TLiteral<"habitat">;
|
|
68
|
+
lane: Type.TUnion<[Type.TLiteral<"enforced">, Type.TLiteral<"advisory">]>;
|
|
69
|
+
locked: Type.TLiteral<false>;
|
|
70
|
+
status: Type.TUnion<[Type.TLiteral<"pass">, Type.TLiteral<"fail">, Type.TLiteral<"advisory-findings">, Type.TLiteral<"error">]>;
|
|
71
|
+
message: Type.TString;
|
|
72
|
+
remediate: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
73
|
+
disposition: Type.TUnion<[Type.TObject<{
|
|
74
|
+
kind: Type.TLiteral<"evaluated">;
|
|
75
|
+
}>, Type.TObject<{
|
|
76
|
+
kind: Type.TLiteral<"failed">;
|
|
77
|
+
reason: Type.TUnion<[Type.TLiteral<"StructureReadFailed">, Type.TLiteral<"StructureInvalid">, Type.TLiteral<"InventoryFailed">, Type.TLiteral<"StructureObservationFailed">]>;
|
|
78
|
+
detail: Type.TString;
|
|
79
|
+
}>]>;
|
|
80
|
+
findings: Type.TArray<Type.TObject<{
|
|
81
|
+
path: Type.TString;
|
|
82
|
+
code: Type.TUnion<[Type.TLiteral<"root-missing">, Type.TLiteral<"wrong-root-kind">, Type.TLiteral<"missing-required-child">, Type.TLiteral<"forbidden-child">, Type.TLiteral<"unexpected-child">]>;
|
|
83
|
+
message: Type.TString;
|
|
84
|
+
severity: Type.TUnion<[Type.TLiteral<"error">, Type.TLiteral<"advisory">]>;
|
|
85
|
+
baselined: Type.TLiteral<false>;
|
|
86
|
+
}>>;
|
|
87
|
+
}>]>>;
|
|
88
|
+
}>]>;
|
|
89
|
+
/** Caller request for one current-catalog check. */
|
|
90
|
+
export type CheckCatalogInput = Static<typeof CheckCatalogInputSchema>;
|
|
91
|
+
/** Total result for one current-catalog check. */
|
|
92
|
+
export type CheckCatalogResult = Static<typeof CheckCatalogResultSchema>;
|
|
93
|
+
/** One semantic report within a completed check. */
|
|
94
|
+
export type CheckApplicationReport = Extract<CheckCatalogResult, {
|
|
95
|
+
_tag: "Completed";
|
|
96
|
+
}>["applications"][number];
|
|
97
|
+
/** One public path-only native Habitat structure finding. */
|
|
98
|
+
export type StructureCheckFinding = Extract<CheckApplicationReport, {
|
|
99
|
+
runner: "habitat";
|
|
100
|
+
}>["findings"][number];
|
|
101
|
+
/** One expected selection refusal. */
|
|
102
|
+
export type CheckSelectionIssue = Extract<CheckCatalogResult, {
|
|
103
|
+
_tag: "SelectionRejected";
|
|
104
|
+
}>["issues"][number];
|