@habitat-ai/service 0.2.3 → 0.3.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/service/impl.d.ts +6 -6
- package/dist/service/modules/catalog/module.d.ts +6 -6
- package/dist/service/modules/catalog/router/catalog.router.d.ts +3 -3
- package/dist/service/modules/catalog/router/catalog.router.js +84 -18
- package/dist/service/modules/catalog/router.d.ts +3 -3
- package/dist/service/router.d.ts +3 -3
- package/package.json +3 -3
package/dist/service/impl.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Context } from "./base.js";
|
|
|
3
3
|
/** Unconfigured Habitat implementer used for aggregate router implementation. */
|
|
4
4
|
export declare const impl: import("@orpc/server").Implementer<{
|
|
5
5
|
readonly catalog: {
|
|
6
|
-
resolve: import("@orpc/contract").ProcedureContract<import("
|
|
6
|
+
resolve: import("@orpc/contract").ProcedureContract<import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
7
7
|
_tag: import("typebox").TLiteral<"Resolved">;
|
|
8
8
|
catalog: import("typebox").TObject<{
|
|
9
9
|
schemaVersion: import("typebox").TLiteral<3>;
|
|
@@ -217,7 +217,7 @@ export declare const impl: import("@orpc/server").Implementer<{
|
|
|
217
217
|
message: import("typebox").TString;
|
|
218
218
|
}>>;
|
|
219
219
|
}>]>>, object>;
|
|
220
|
-
check: import("@orpc/contract").ProcedureContract<import("
|
|
220
|
+
check: import("@orpc/contract").ProcedureContract<import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{
|
|
221
221
|
selectors: import("typebox").TOptional<import("typebox").TObject<{
|
|
222
222
|
owner: import("typebox").TOptional<import("typebox").TString>;
|
|
223
223
|
instance: import("typebox").TOptional<import("typebox").TString>;
|
|
@@ -225,7 +225,7 @@ export declare const impl: import("@orpc/server").Implementer<{
|
|
|
225
225
|
rules: import("typebox").TOptional<import("typebox").TArray<import("typebox").TString>>;
|
|
226
226
|
runner: import("typebox").TOptional<import("typebox").TString>;
|
|
227
227
|
}>>;
|
|
228
|
-
}>>, import("
|
|
228
|
+
}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
229
229
|
_tag: import("typebox").TLiteral<"CatalogRejected">;
|
|
230
230
|
issues: import("typebox").TArray<import("typebox").TObject<{
|
|
231
231
|
code: import("typebox").TUnion<[import("typebox").TLiteral<"authority-anchor-mismatch">, import("typebox").TLiteral<"authority-blueprint-missing">, import("typebox").TLiteral<"authority-compatibility-invalid">, import("typebox").TLiteral<"authority-definition-invalid">, import("typebox").TLiteral<"authority-definition-kind-mismatch">, import("typebox").TLiteral<"authority-duplicate-blueprint">, import("typebox").TLiteral<"authority-duplicate-instance">, import("typebox").TLiteral<"authority-duplicate-rule">, import("typebox").TLiteral<"authority-filesystem-failed">, import("typebox").TLiteral<"authority-json-invalid">, import("typebox").TLiteral<"authority-manifest-invalid">, import("typebox").TLiteral<"authority-order-invalid">, import("typebox").TLiteral<"authority-path-escape">, import("typebox").TLiteral<"authority-path-invalid">, import("typebox").TLiteral<"authority-path-kind-mismatch">, import("typebox").TLiteral<"authority-path-missing">, import("typebox").TLiteral<"authority-package-name-mismatch">, import("typebox").TLiteral<"authority-policy-pack-members-unsupported">, import("typebox").TLiteral<"authority-resolution-failed">, import("typebox").TLiteral<"authority-rule-invalid">, import("typebox").TLiteral<"authority-schema-invalid">, import("typebox").TLiteral<"authority-toml-invalid">, import("typebox").TLiteral<"authority-version-mismatch">, import("typebox").TLiteral<"authority-workspace-root-invalid">]>;
|
|
@@ -366,7 +366,7 @@ export declare const impl: import("@orpc/server").Implementer<{
|
|
|
366
366
|
/** Root Habitat lineage with the official Effect-oRPC extension admitted once. */
|
|
367
367
|
export declare const service: import("@orpc/server").Implementer<{
|
|
368
368
|
readonly catalog: {
|
|
369
|
-
resolve: import("@orpc/contract").ProcedureContract<import("
|
|
369
|
+
resolve: import("@orpc/contract").ProcedureContract<import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
370
370
|
_tag: import("typebox").TLiteral<"Resolved">;
|
|
371
371
|
catalog: import("typebox").TObject<{
|
|
372
372
|
schemaVersion: import("typebox").TLiteral<3>;
|
|
@@ -580,7 +580,7 @@ export declare const service: import("@orpc/server").Implementer<{
|
|
|
580
580
|
message: import("typebox").TString;
|
|
581
581
|
}>>;
|
|
582
582
|
}>]>>, object>;
|
|
583
|
-
check: import("@orpc/contract").ProcedureContract<import("
|
|
583
|
+
check: import("@orpc/contract").ProcedureContract<import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{
|
|
584
584
|
selectors: import("typebox").TOptional<import("typebox").TObject<{
|
|
585
585
|
owner: import("typebox").TOptional<import("typebox").TString>;
|
|
586
586
|
instance: import("typebox").TOptional<import("typebox").TString>;
|
|
@@ -588,7 +588,7 @@ export declare const service: import("@orpc/server").Implementer<{
|
|
|
588
588
|
rules: import("typebox").TOptional<import("typebox").TArray<import("typebox").TString>>;
|
|
589
589
|
runner: import("typebox").TOptional<import("typebox").TString>;
|
|
590
590
|
}>>;
|
|
591
|
-
}>>, import("
|
|
591
|
+
}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
592
592
|
_tag: import("typebox").TLiteral<"CatalogRejected">;
|
|
593
593
|
issues: import("typebox").TArray<import("typebox").TObject<{
|
|
594
594
|
code: import("typebox").TUnion<[import("typebox").TLiteral<"authority-anchor-mismatch">, import("typebox").TLiteral<"authority-blueprint-missing">, import("typebox").TLiteral<"authority-compatibility-invalid">, import("typebox").TLiteral<"authority-definition-invalid">, import("typebox").TLiteral<"authority-definition-kind-mismatch">, import("typebox").TLiteral<"authority-duplicate-blueprint">, import("typebox").TLiteral<"authority-duplicate-instance">, import("typebox").TLiteral<"authority-duplicate-rule">, import("typebox").TLiteral<"authority-filesystem-failed">, import("typebox").TLiteral<"authority-json-invalid">, import("typebox").TLiteral<"authority-manifest-invalid">, import("typebox").TLiteral<"authority-order-invalid">, import("typebox").TLiteral<"authority-path-escape">, import("typebox").TLiteral<"authority-path-invalid">, import("typebox").TLiteral<"authority-path-kind-mismatch">, import("typebox").TLiteral<"authority-path-missing">, import("typebox").TLiteral<"authority-package-name-mismatch">, import("typebox").TLiteral<"authority-policy-pack-members-unsupported">, import("typebox").TLiteral<"authority-resolution-failed">, import("typebox").TLiteral<"authority-rule-invalid">, import("typebox").TLiteral<"authority-schema-invalid">, import("typebox").TLiteral<"authority-toml-invalid">, import("typebox").TLiteral<"authority-version-mismatch">, import("typebox").TLiteral<"authority-workspace-root-invalid">]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Catalog implementer exposing the vocabulary required by resolve and check. */
|
|
2
2
|
export declare const module: import("@orpc/server").SharedRouterImplementerWithMiddlewares<{
|
|
3
|
-
resolve: import("@orpc/contract").ProcedureContract<import("
|
|
3
|
+
resolve: import("@orpc/contract").ProcedureContract<import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
4
4
|
_tag: import("typebox").TLiteral<"Resolved">;
|
|
5
5
|
catalog: import("typebox").TObject<{
|
|
6
6
|
schemaVersion: import("typebox").TLiteral<3>;
|
|
@@ -214,7 +214,7 @@ export declare const module: import("@orpc/server").SharedRouterImplementerWithM
|
|
|
214
214
|
message: import("typebox").TString;
|
|
215
215
|
}>>;
|
|
216
216
|
}>]>>, object>;
|
|
217
|
-
check: import("@orpc/contract").ProcedureContract<import("
|
|
217
|
+
check: import("@orpc/contract").ProcedureContract<import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{
|
|
218
218
|
selectors: import("typebox").TOptional<import("typebox").TObject<{
|
|
219
219
|
owner: import("typebox").TOptional<import("typebox").TString>;
|
|
220
220
|
instance: import("typebox").TOptional<import("typebox").TString>;
|
|
@@ -222,7 +222,7 @@ export declare const module: import("@orpc/server").SharedRouterImplementerWithM
|
|
|
222
222
|
rules: import("typebox").TOptional<import("typebox").TArray<import("typebox").TString>>;
|
|
223
223
|
runner: import("typebox").TOptional<import("typebox").TString>;
|
|
224
224
|
}>>;
|
|
225
|
-
}>>, import("
|
|
225
|
+
}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
226
226
|
_tag: import("typebox").TLiteral<"CatalogRejected">;
|
|
227
227
|
issues: import("typebox").TArray<import("typebox").TObject<{
|
|
228
228
|
code: import("typebox").TUnion<[import("typebox").TLiteral<"authority-anchor-mismatch">, import("typebox").TLiteral<"authority-blueprint-missing">, import("typebox").TLiteral<"authority-compatibility-invalid">, import("typebox").TLiteral<"authority-definition-invalid">, import("typebox").TLiteral<"authority-definition-kind-mismatch">, import("typebox").TLiteral<"authority-duplicate-blueprint">, import("typebox").TLiteral<"authority-duplicate-instance">, import("typebox").TLiteral<"authority-duplicate-rule">, import("typebox").TLiteral<"authority-filesystem-failed">, import("typebox").TLiteral<"authority-json-invalid">, import("typebox").TLiteral<"authority-manifest-invalid">, import("typebox").TLiteral<"authority-order-invalid">, import("typebox").TLiteral<"authority-path-escape">, import("typebox").TLiteral<"authority-path-invalid">, import("typebox").TLiteral<"authority-path-kind-mismatch">, import("typebox").TLiteral<"authority-path-missing">, import("typebox").TLiteral<"authority-package-name-mismatch">, import("typebox").TLiteral<"authority-policy-pack-members-unsupported">, import("typebox").TLiteral<"authority-resolution-failed">, import("typebox").TLiteral<"authority-rule-invalid">, import("typebox").TLiteral<"authority-schema-invalid">, import("typebox").TLiteral<"authority-toml-invalid">, import("typebox").TLiteral<"authority-version-mismatch">, import("typebox").TLiteral<"authority-workspace-root-invalid">]>;
|
|
@@ -373,7 +373,7 @@ export declare const module: import("@orpc/server").SharedRouterImplementerWithM
|
|
|
373
373
|
sourceInventory: import("resources/source-inventory/dist/contract.js").SourceInventoryResource<never>;
|
|
374
374
|
workspaceRoot: string;
|
|
375
375
|
policyPack: import("../../base.js").SelectedPolicyPack;
|
|
376
|
-
}, import("
|
|
376
|
+
}, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
377
377
|
_tag: import("typebox").TLiteral<"Resolved">;
|
|
378
378
|
catalog: import("typebox").TObject<{
|
|
379
379
|
schemaVersion: import("typebox").TLiteral<3>;
|
|
@@ -594,7 +594,7 @@ export declare const module: import("@orpc/server").SharedRouterImplementerWithM
|
|
|
594
594
|
sourceInventory: import("resources/source-inventory/dist/contract.js").SourceInventoryResource<never>;
|
|
595
595
|
workspaceRoot: string;
|
|
596
596
|
policyPack: import("../../base.js").SelectedPolicyPack;
|
|
597
|
-
}, import("
|
|
597
|
+
}, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{
|
|
598
598
|
selectors: import("typebox").TOptional<import("typebox").TObject<{
|
|
599
599
|
owner: import("typebox").TOptional<import("typebox").TString>;
|
|
600
600
|
instance: import("typebox").TOptional<import("typebox").TString>;
|
|
@@ -602,7 +602,7 @@ export declare const module: import("@orpc/server").SharedRouterImplementerWithM
|
|
|
602
602
|
rules: import("typebox").TOptional<import("typebox").TArray<import("typebox").TString>>;
|
|
603
603
|
runner: import("typebox").TOptional<import("typebox").TString>;
|
|
604
604
|
}>>;
|
|
605
|
-
}>>, import("
|
|
605
|
+
}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
606
606
|
_tag: import("typebox").TLiteral<"CatalogRejected">;
|
|
607
607
|
issues: import("typebox").TArray<import("typebox").TObject<{
|
|
608
608
|
code: import("typebox").TUnion<[import("typebox").TLiteral<"authority-anchor-mismatch">, import("typebox").TLiteral<"authority-blueprint-missing">, import("typebox").TLiteral<"authority-compatibility-invalid">, import("typebox").TLiteral<"authority-definition-invalid">, import("typebox").TLiteral<"authority-definition-kind-mismatch">, import("typebox").TLiteral<"authority-duplicate-blueprint">, import("typebox").TLiteral<"authority-duplicate-instance">, import("typebox").TLiteral<"authority-duplicate-rule">, import("typebox").TLiteral<"authority-filesystem-failed">, import("typebox").TLiteral<"authority-json-invalid">, import("typebox").TLiteral<"authority-manifest-invalid">, import("typebox").TLiteral<"authority-order-invalid">, import("typebox").TLiteral<"authority-path-escape">, import("typebox").TLiteral<"authority-path-invalid">, import("typebox").TLiteral<"authority-path-kind-mismatch">, import("typebox").TLiteral<"authority-path-missing">, import("typebox").TLiteral<"authority-package-name-mismatch">, import("typebox").TLiteral<"authority-policy-pack-members-unsupported">, import("typebox").TLiteral<"authority-resolution-failed">, import("typebox").TLiteral<"authority-rule-invalid">, import("typebox").TLiteral<"authority-schema-invalid">, import("typebox").TLiteral<"authority-toml-invalid">, import("typebox").TLiteral<"authority-version-mismatch">, import("typebox").TLiteral<"authority-workspace-root-invalid">]>;
|
|
@@ -8,7 +8,7 @@ export declare const catalog: {
|
|
|
8
8
|
sourceInventory: import("@habitat-ai/resource-source-inventory").SourceInventoryResource<never>;
|
|
9
9
|
workspaceRoot: string;
|
|
10
10
|
policyPack: import("../../../base.js").SelectedPolicyPack;
|
|
11
|
-
}, import("
|
|
11
|
+
}, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
12
12
|
_tag: import("typebox").TLiteral<"Resolved">;
|
|
13
13
|
catalog: import("typebox").TObject<{
|
|
14
14
|
schemaVersion: import("typebox").TLiteral<3>;
|
|
@@ -229,7 +229,7 @@ export declare const catalog: {
|
|
|
229
229
|
sourceInventory: import("@habitat-ai/resource-source-inventory").SourceInventoryResource<never>;
|
|
230
230
|
workspaceRoot: string;
|
|
231
231
|
policyPack: import("../../../base.js").SelectedPolicyPack;
|
|
232
|
-
}, import("
|
|
232
|
+
}, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{
|
|
233
233
|
selectors: import("typebox").TOptional<import("typebox").TObject<{
|
|
234
234
|
owner: import("typebox").TOptional<import("typebox").TString>;
|
|
235
235
|
instance: import("typebox").TOptional<import("typebox").TString>;
|
|
@@ -237,7 +237,7 @@ export declare const catalog: {
|
|
|
237
237
|
rules: import("typebox").TOptional<import("typebox").TArray<import("typebox").TString>>;
|
|
238
238
|
runner: import("typebox").TOptional<import("typebox").TString>;
|
|
239
239
|
}>>;
|
|
240
|
-
}>>, import("
|
|
240
|
+
}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
241
241
|
_tag: import("typebox").TLiteral<"CatalogRejected">;
|
|
242
242
|
issues: import("typebox").TArray<import("typebox").TObject<{
|
|
243
243
|
code: import("typebox").TUnion<[import("typebox").TLiteral<"authority-anchor-mismatch">, import("typebox").TLiteral<"authority-blueprint-missing">, import("typebox").TLiteral<"authority-compatibility-invalid">, import("typebox").TLiteral<"authority-definition-invalid">, import("typebox").TLiteral<"authority-definition-kind-mismatch">, import("typebox").TLiteral<"authority-duplicate-blueprint">, import("typebox").TLiteral<"authority-duplicate-instance">, import("typebox").TLiteral<"authority-duplicate-rule">, import("typebox").TLiteral<"authority-filesystem-failed">, import("typebox").TLiteral<"authority-json-invalid">, import("typebox").TLiteral<"authority-manifest-invalid">, import("typebox").TLiteral<"authority-order-invalid">, import("typebox").TLiteral<"authority-path-escape">, import("typebox").TLiteral<"authority-path-invalid">, import("typebox").TLiteral<"authority-path-kind-mismatch">, import("typebox").TLiteral<"authority-path-missing">, import("typebox").TLiteral<"authority-package-name-mismatch">, import("typebox").TLiteral<"authority-policy-pack-members-unsupported">, import("typebox").TLiteral<"authority-resolution-failed">, import("typebox").TLiteral<"authority-rule-invalid">, import("typebox").TLiteral<"authority-schema-invalid">, import("typebox").TLiteral<"authority-toml-invalid">, import("typebox").TLiteral<"authority-version-mismatch">, import("typebox").TLiteral<"authority-workspace-root-invalid">]>;
|
|
@@ -599,21 +599,22 @@ const check = module.check.effect(function* ({ context, input }) {
|
|
|
599
599
|
};
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
const reports =
|
|
603
|
-
|
|
602
|
+
const reports = new Array(preparations.length);
|
|
603
|
+
const readyGritEvaluations = [];
|
|
604
|
+
for (const [applicationIndex, prepared] of preparations.entries()) {
|
|
604
605
|
if (prepared.kind === "structure") {
|
|
605
606
|
if (prepared.preparation.kind === "failed") {
|
|
606
|
-
reports
|
|
607
|
+
reports[applicationIndex] = prepared.preparation.report;
|
|
607
608
|
continue;
|
|
608
609
|
}
|
|
609
610
|
const admitted = prepared.preparation.value;
|
|
610
611
|
const application = admitted.application;
|
|
611
612
|
if (admitted.scopes.length === 0) {
|
|
612
|
-
reports
|
|
613
|
+
reports[applicationIndex] = evaluatedStructureApplication(application, []);
|
|
613
614
|
continue;
|
|
614
615
|
}
|
|
615
616
|
if (inventoryPreparation.kind === "failed") {
|
|
616
|
-
reports
|
|
617
|
+
reports[applicationIndex] = failedStructureApplication(application, "InventoryFailed", inventoryPreparation.detail);
|
|
617
618
|
continue;
|
|
618
619
|
}
|
|
619
620
|
if (inventoryPreparation.kind === "not-required") {
|
|
@@ -627,50 +628,87 @@ const check = module.check.effect(function* ({ context, input }) {
|
|
|
627
628
|
return yield* prepareStructureObservations(structureChildObservationPaths(plan, roots.kinds), roots.kinds);
|
|
628
629
|
});
|
|
629
630
|
if (observations.kind === "failed") {
|
|
630
|
-
reports
|
|
631
|
+
reports[applicationIndex] = failedStructureApplication(application, "StructureObservationFailed", observations.detail);
|
|
631
632
|
continue;
|
|
632
633
|
}
|
|
633
|
-
reports
|
|
634
|
+
reports[applicationIndex] = evaluatedStructureApplication(application, evaluateStructurePlan(plan, observations.kinds));
|
|
634
635
|
continue;
|
|
635
636
|
}
|
|
636
637
|
const application = prepared.application;
|
|
637
638
|
const patternAttempt = yield* Effect.result(context.fileSystem.readFileString(application.runner.pattern.absolutePath));
|
|
638
639
|
if (patternAttempt._tag === "Failure") {
|
|
639
|
-
reports
|
|
640
|
+
reports[applicationIndex] = failedApplication(application, "PatternReadFailed", `Unable to read pattern asset "${application.runner.pattern.relativePath}".`);
|
|
640
641
|
continue;
|
|
641
642
|
}
|
|
642
643
|
const program = extractGritProgram(patternAttempt.success);
|
|
643
644
|
if (!program.ok) {
|
|
644
|
-
reports
|
|
645
|
+
reports[applicationIndex] = failedApplication(application, "PatternInvalid", program.detail);
|
|
645
646
|
continue;
|
|
646
647
|
}
|
|
647
648
|
const subjectPreparation = yield* prepareGritSubjects(application, context.workspaceRoot, context.fileSystem, context.path);
|
|
648
649
|
if (subjectPreparation.kind === "failed") {
|
|
649
|
-
reports
|
|
650
|
+
reports[applicationIndex] = failedApplication(application, "SetupFailed", subjectPreparation.detail);
|
|
650
651
|
continue;
|
|
651
652
|
}
|
|
652
653
|
if (subjectPreparation.kind === "not-applicable") {
|
|
653
654
|
if (!isCompatibilityRule(application)) {
|
|
654
655
|
return yield* Effect.die(new Error("Version-three Grit applications cannot be not applicable."));
|
|
655
656
|
}
|
|
656
|
-
reports
|
|
657
|
+
reports[applicationIndex] = notApplicableApplication(application);
|
|
657
658
|
continue;
|
|
658
659
|
}
|
|
659
660
|
const subjects = subjectPreparation.subjects;
|
|
660
|
-
|
|
661
|
+
readyGritEvaluations.push({
|
|
662
|
+
applicationIndex,
|
|
663
|
+
application,
|
|
664
|
+
programId: `application-${applicationIndex}`,
|
|
661
665
|
program: program.program,
|
|
666
|
+
subjects,
|
|
662
667
|
subjectPaths: subjects.map((subject) => subject.absolutePath),
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
for (const evaluations of groupGritEvaluations(readyGritEvaluations)) {
|
|
671
|
+
const first = evaluations[0];
|
|
672
|
+
if (first === undefined) {
|
|
673
|
+
return yield* Effect.die(new Error("A Grit evaluation group must not be empty."));
|
|
674
|
+
}
|
|
675
|
+
const evaluation = yield* Effect.result(context.ruleEvaluation.evaluate({
|
|
676
|
+
programs: evaluations.map(({ programId, program }) => ({ id: programId, program })),
|
|
677
|
+
subjectPaths: first.subjectPaths,
|
|
663
678
|
}));
|
|
664
679
|
if (evaluation._tag === "Failure") {
|
|
665
|
-
|
|
680
|
+
for (const prepared of evaluations) {
|
|
681
|
+
reports[prepared.applicationIndex] = failedApplication(prepared.application, evaluation.failure.reason, evaluation.failure.detail);
|
|
682
|
+
}
|
|
666
683
|
continue;
|
|
667
684
|
}
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
685
|
+
const resultMismatch = evaluationResultMismatch(evaluations, evaluation.success.results);
|
|
686
|
+
if (resultMismatch !== undefined) {
|
|
687
|
+
for (const prepared of evaluations) {
|
|
688
|
+
reports[prepared.applicationIndex] = failedApplication(prepared.application, "InvalidOutput", resultMismatch);
|
|
689
|
+
}
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
const results = indexEvaluationResults(evaluation.success.results);
|
|
693
|
+
for (const prepared of evaluations) {
|
|
694
|
+
const result = results.get(prepared.programId);
|
|
695
|
+
if (result === undefined) {
|
|
696
|
+
return yield* Effect.die(new Error(`Validated evaluation result '${prepared.programId}' is absent.`));
|
|
697
|
+
}
|
|
698
|
+
const normalized = normalizeFindings(result.findings, prepared.subjects, context.workspaceRoot, context.path);
|
|
699
|
+
reports[prepared.applicationIndex] = normalized.ok
|
|
700
|
+
? evaluatedApplication(prepared.application, normalized.findings)
|
|
701
|
+
: failedApplication(prepared.application, "FindingPathInvalid", normalized.detail);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
const completedReports = [];
|
|
705
|
+
for (const [applicationIndex, report] of reports.entries()) {
|
|
706
|
+
if (report === undefined) {
|
|
707
|
+
return yield* Effect.die(new Error(`Habitat check produced no report for application ${applicationIndex}.`));
|
|
708
|
+
}
|
|
709
|
+
completedReports.push(report);
|
|
672
710
|
}
|
|
673
|
-
return completedCheck(
|
|
711
|
+
return completedCheck(completedReports);
|
|
674
712
|
});
|
|
675
713
|
/** Grouped catalog operation tree consumed by the module composition face. */
|
|
676
714
|
export const catalog = { resolve, check };
|
|
@@ -707,6 +745,34 @@ function hasExactCauseCode(error, code) {
|
|
|
707
745
|
const cause = "cause" in error.reason ? error.reason.cause : undefined;
|
|
708
746
|
return typeof cause === "object" && cause !== null && "code" in cause && cause.code === code;
|
|
709
747
|
}
|
|
748
|
+
function groupGritEvaluations(evaluations) {
|
|
749
|
+
const groups = new Map();
|
|
750
|
+
for (const evaluation of evaluations) {
|
|
751
|
+
const key = JSON.stringify(evaluation.subjectPaths);
|
|
752
|
+
const group = groups.get(key);
|
|
753
|
+
if (group === undefined)
|
|
754
|
+
groups.set(key, [evaluation]);
|
|
755
|
+
else
|
|
756
|
+
group.push(evaluation);
|
|
757
|
+
}
|
|
758
|
+
return [...groups.values()];
|
|
759
|
+
}
|
|
760
|
+
function evaluationResultMismatch(evaluations, results) {
|
|
761
|
+
if (results.length !== evaluations.length) {
|
|
762
|
+
return `Rule evaluator returned ${results.length} program results for ${evaluations.length} requested programs.`;
|
|
763
|
+
}
|
|
764
|
+
const uniqueIds = new Set(results.map(({ programId }) => programId));
|
|
765
|
+
if (uniqueIds.size !== results.length) {
|
|
766
|
+
return "Rule evaluator returned duplicate program result identities.";
|
|
767
|
+
}
|
|
768
|
+
const unexpected = results.find((result, index) => result.programId !== evaluations[index]?.programId);
|
|
769
|
+
return unexpected === undefined
|
|
770
|
+
? undefined
|
|
771
|
+
: "Rule evaluator did not preserve requested program result order and identity.";
|
|
772
|
+
}
|
|
773
|
+
function indexEvaluationResults(results) {
|
|
774
|
+
return new Map(results.map((result) => [result.programId, result]));
|
|
775
|
+
}
|
|
710
776
|
function prepareGritSubjects(application, workspaceRoot, fileSystem, path) {
|
|
711
777
|
if (!isCompatibilityRule(application)) {
|
|
712
778
|
return Effect.succeed({
|
|
@@ -7,7 +7,7 @@ export declare const router: {
|
|
|
7
7
|
sourceInventory: import("resources/source-inventory/dist/contract.js").SourceInventoryResource<never>;
|
|
8
8
|
workspaceRoot: string;
|
|
9
9
|
policyPack: import("../../base.js").SelectedPolicyPack;
|
|
10
|
-
}, import("
|
|
10
|
+
}, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
11
11
|
_tag: import("typebox").TLiteral<"Resolved">;
|
|
12
12
|
catalog: import("typebox").TObject<{
|
|
13
13
|
schemaVersion: import("typebox").TLiteral<3>;
|
|
@@ -228,7 +228,7 @@ export declare const router: {
|
|
|
228
228
|
sourceInventory: import("resources/source-inventory/dist/contract.js").SourceInventoryResource<never>;
|
|
229
229
|
workspaceRoot: string;
|
|
230
230
|
policyPack: import("../../base.js").SelectedPolicyPack;
|
|
231
|
-
}, import("
|
|
231
|
+
}, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{
|
|
232
232
|
selectors: import("typebox").TOptional<import("typebox").TObject<{
|
|
233
233
|
owner: import("typebox").TOptional<import("typebox").TString>;
|
|
234
234
|
instance: import("typebox").TOptional<import("typebox").TString>;
|
|
@@ -236,7 +236,7 @@ export declare const router: {
|
|
|
236
236
|
rules: import("typebox").TOptional<import("typebox").TArray<import("typebox").TString>>;
|
|
237
237
|
runner: import("typebox").TOptional<import("typebox").TString>;
|
|
238
238
|
}>>;
|
|
239
|
-
}>>, import("
|
|
239
|
+
}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
240
240
|
_tag: import("typebox").TLiteral<"CatalogRejected">;
|
|
241
241
|
issues: import("typebox").TArray<import("typebox").TObject<{
|
|
242
242
|
code: import("typebox").TUnion<[import("typebox").TLiteral<"authority-anchor-mismatch">, import("typebox").TLiteral<"authority-blueprint-missing">, import("typebox").TLiteral<"authority-compatibility-invalid">, import("typebox").TLiteral<"authority-definition-invalid">, import("typebox").TLiteral<"authority-definition-kind-mismatch">, import("typebox").TLiteral<"authority-duplicate-blueprint">, import("typebox").TLiteral<"authority-duplicate-instance">, import("typebox").TLiteral<"authority-duplicate-rule">, import("typebox").TLiteral<"authority-filesystem-failed">, import("typebox").TLiteral<"authority-json-invalid">, import("typebox").TLiteral<"authority-manifest-invalid">, import("typebox").TLiteral<"authority-order-invalid">, import("typebox").TLiteral<"authority-path-escape">, import("typebox").TLiteral<"authority-path-invalid">, import("typebox").TLiteral<"authority-path-kind-mismatch">, import("typebox").TLiteral<"authority-path-missing">, import("typebox").TLiteral<"authority-package-name-mismatch">, import("typebox").TLiteral<"authority-policy-pack-members-unsupported">, import("typebox").TLiteral<"authority-resolution-failed">, import("typebox").TLiteral<"authority-rule-invalid">, import("typebox").TLiteral<"authority-schema-invalid">, import("typebox").TLiteral<"authority-toml-invalid">, import("typebox").TLiteral<"authority-version-mismatch">, import("typebox").TLiteral<"authority-workspace-root-invalid">]>;
|
package/dist/service/router.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const router: {
|
|
|
8
8
|
sourceInventory: import("resources/source-inventory/dist/contract.js").SourceInventoryResource<never>;
|
|
9
9
|
workspaceRoot: string;
|
|
10
10
|
policyPack: import("./base.js").SelectedPolicyPack;
|
|
11
|
-
}, import("
|
|
11
|
+
}, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
12
12
|
_tag: import("typebox").TLiteral<"Resolved">;
|
|
13
13
|
catalog: import("typebox").TObject<{
|
|
14
14
|
schemaVersion: import("typebox").TLiteral<3>;
|
|
@@ -229,7 +229,7 @@ export declare const router: {
|
|
|
229
229
|
sourceInventory: import("resources/source-inventory/dist/contract.js").SourceInventoryResource<never>;
|
|
230
230
|
workspaceRoot: string;
|
|
231
231
|
policyPack: import("./base.js").SelectedPolicyPack;
|
|
232
|
-
}, import("
|
|
232
|
+
}, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TObject<{
|
|
233
233
|
selectors: import("typebox").TOptional<import("typebox").TObject<{
|
|
234
234
|
owner: import("typebox").TOptional<import("typebox").TString>;
|
|
235
235
|
instance: import("typebox").TOptional<import("typebox").TString>;
|
|
@@ -237,7 +237,7 @@ export declare const router: {
|
|
|
237
237
|
rules: import("typebox").TOptional<import("typebox").TArray<import("typebox").TString>>;
|
|
238
238
|
runner: import("typebox").TOptional<import("typebox").TString>;
|
|
239
239
|
}>>;
|
|
240
|
-
}>>, import("
|
|
240
|
+
}>>, import("@habitat-ai/typebox-adapter").TypeBoxStandardSchema<import("typebox").TUnion<[import("typebox").TObject<{
|
|
241
241
|
_tag: import("typebox").TLiteral<"CatalogRejected">;
|
|
242
242
|
issues: import("typebox").TArray<import("typebox").TObject<{
|
|
243
243
|
code: import("typebox").TUnion<[import("typebox").TLiteral<"authority-anchor-mismatch">, import("typebox").TLiteral<"authority-blueprint-missing">, import("typebox").TLiteral<"authority-compatibility-invalid">, import("typebox").TLiteral<"authority-definition-invalid">, import("typebox").TLiteral<"authority-definition-kind-mismatch">, import("typebox").TLiteral<"authority-duplicate-blueprint">, import("typebox").TLiteral<"authority-duplicate-instance">, import("typebox").TLiteral<"authority-duplicate-rule">, import("typebox").TLiteral<"authority-filesystem-failed">, import("typebox").TLiteral<"authority-json-invalid">, import("typebox").TLiteral<"authority-manifest-invalid">, import("typebox").TLiteral<"authority-order-invalid">, import("typebox").TLiteral<"authority-path-escape">, import("typebox").TLiteral<"authority-path-invalid">, import("typebox").TLiteral<"authority-path-kind-mismatch">, import("typebox").TLiteral<"authority-path-missing">, import("typebox").TLiteral<"authority-package-name-mismatch">, import("typebox").TLiteral<"authority-policy-pack-members-unsupported">, import("typebox").TLiteral<"authority-resolution-failed">, import("typebox").TLiteral<"authority-rule-invalid">, import("typebox").TLiteral<"authority-schema-invalid">, import("typebox").TLiteral<"authority-toml-invalid">, import("typebox").TLiteral<"authority-version-mismatch">, import("typebox").TLiteral<"authority-workspace-root-invalid">]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@habitat-ai/service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"test": "bun test test"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@habitat-ai/resource-rule-evaluation": "0.
|
|
28
|
-
"@habitat-ai/resource-source-inventory": "0.
|
|
27
|
+
"@habitat-ai/resource-rule-evaluation": "0.3.0",
|
|
28
|
+
"@habitat-ai/resource-source-inventory": "0.3.0",
|
|
29
29
|
"@opentelemetry/api": "^1.9.0",
|
|
30
30
|
"@orpc/contract": "2.0.0-beta.20",
|
|
31
31
|
"@orpc/experimental-effect": "2.0.0-beta.20",
|