@lucern/pack-host 1.0.28 → 1.0.30

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 (67) hide show
  1. package/dist/contracts.d.ts +35 -35
  2. package/dist/contracts.js.map +1 -1
  3. package/dist/dependencyResolution.d.ts +3 -3
  4. package/dist/dependencyResolution.js +83 -59
  5. package/dist/dependencyResolution.js.map +1 -1
  6. package/dist/domain-pack/authoring.core.d.ts +82 -82
  7. package/dist/domain-pack/authoring.core.js +7 -6
  8. package/dist/domain-pack/authoring.core.js.map +1 -1
  9. package/dist/domain-pack/authoring.js +400 -281
  10. package/dist/domain-pack/authoring.js.map +1 -1
  11. package/dist/domain-pack/authoring.validation.js +400 -281
  12. package/dist/domain-pack/authoring.validation.js.map +1 -1
  13. package/dist/domain-pack/contracts.d.ts +95 -95
  14. package/dist/domain-pack/contracts.js.map +1 -1
  15. package/dist/domain-pack/index.js +416 -285
  16. package/dist/domain-pack/index.js.map +1 -1
  17. package/dist/domain-pack/ontology/software-entities-v1.d.ts +7 -7
  18. package/dist/domain-pack/ontology/software-entities-v1.js.map +1 -1
  19. package/dist/domain-pack/packs/developer-reasoning.js +7 -1
  20. package/dist/domain-pack/packs/developer-reasoning.js.map +1 -1
  21. package/dist/domain-pack/packs/engineering-accelerator.js.map +1 -1
  22. package/dist/domain-pack/packs/index.js +333 -239
  23. package/dist/domain-pack/packs/index.js.map +1 -1
  24. package/dist/domain-pack/shaping.d.ts +15 -15
  25. package/dist/domain-pack/shaping.js +326 -238
  26. package/dist/domain-pack/shaping.js.map +1 -1
  27. package/dist/domain-pack/validation.d.ts +6 -6
  28. package/dist/domain-pack/validation.js +318 -236
  29. package/dist/domain-pack/validation.js.map +1 -1
  30. package/dist/domain-pack.js +416 -285
  31. package/dist/domain-pack.js.map +1 -1
  32. package/dist/index.d.ts +6 -6
  33. package/dist/index.js +3793 -3643
  34. package/dist/index.js.map +1 -1
  35. package/dist/lifecycle.d.ts +9 -9
  36. package/dist/lifecycle.js.map +1 -1
  37. package/dist/manifestValidation.d.ts +9 -9
  38. package/dist/manifestValidation.js.map +1 -1
  39. package/dist/manifests/chat-v1.js.map +1 -1
  40. package/dist/manifests/deals-v1.js +1 -6
  41. package/dist/manifests/deals-v1.js.map +1 -1
  42. package/dist/manifests/decisions-v1.js.map +1 -1
  43. package/dist/manifests/documents-v1.js.map +1 -1
  44. package/dist/manifests/epistemic-algorithms-v1.js.map +1 -1
  45. package/dist/manifests/graph-visualization-v1.js.map +1 -1
  46. package/dist/manifests/index.js +1 -6
  47. package/dist/manifests/index.js.map +1 -1
  48. package/dist/manifests/news-v1.js.map +1 -1
  49. package/dist/manifests/philosophy-mode-v1.js.map +1 -1
  50. package/dist/manifests/sprints-v1.js.map +1 -1
  51. package/dist/manifests/task-management-v1.js.map +1 -1
  52. package/dist/manifests/team-analysis-v1.js.map +1 -1
  53. package/dist/manifests/themes-v1.js.map +1 -1
  54. package/dist/manifests/user-profiles-v1.js.map +1 -1
  55. package/dist/manifests.js +1 -6
  56. package/dist/manifests.js.map +1 -1
  57. package/dist/namespacePolicy.d.ts +6 -6
  58. package/dist/namespacePolicy.js.map +1 -1
  59. package/dist/proof-attestation.json +1 -1
  60. package/dist/registry.js +84 -65
  61. package/dist/registry.js.map +1 -1
  62. package/dist/runtime.d.ts +6 -6
  63. package/dist/runtime.js +83 -59
  64. package/dist/runtime.js.map +1 -1
  65. package/dist/serviceContracts.d.ts +4 -4
  66. package/dist/serviceContracts.js.map +1 -1
  67. package/package.json +1 -1
@@ -63,12 +63,13 @@ function defineDomainPack(input) {
63
63
  // src/domain-pack/authoring.core.ts
64
64
  var DOMAIN_PACK_MANIFEST_KIND = "lucern-domain-pack-manifest";
65
65
  var CURRENT_MANIFEST_VERSION = "1.0.0";
66
+ var YAML_NUMERIC_SCALAR = /^-?\d+(?:\.\d+)?$/;
66
67
  function isPlainObject(value) {
67
68
  return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
68
69
  }
69
70
  function dedupeStrings2(values) {
70
71
  if (!values) {
71
- return void 0;
72
+ return;
72
73
  }
73
74
  return Array.from(
74
75
  new Set(values.map((value) => value.trim()).filter((value) => value.length))
@@ -79,7 +80,7 @@ function normalizeRuntimeTargets2(values) {
79
80
  }
80
81
  function normalizeFrameworks(frameworks) {
81
82
  if (!frameworks) {
82
- return void 0;
83
+ return;
83
84
  }
84
85
  return frameworks.map((framework) => ({
85
86
  ...framework,
@@ -91,7 +92,7 @@ function normalizeFrameworks(frameworks) {
91
92
  }
92
93
  function normalizeSchemaExtensions(extensions) {
93
94
  if (!extensions) {
94
- return void 0;
95
+ return;
95
96
  }
96
97
  return extensions.map((extension) => ({
97
98
  ...extension,
@@ -104,7 +105,7 @@ function normalizeSchemaExtensions(extensions) {
104
105
  }
105
106
  function normalizeOntologyExtensions(extensions) {
106
107
  if (!extensions) {
107
- return void 0;
108
+ return;
108
109
  }
109
110
  return extensions.map((extension) => ({
110
111
  ...extension,
@@ -143,7 +144,7 @@ function normalizeLineage(lineage) {
143
144
  }
144
145
  function normalizeMetadata(metadata) {
145
146
  if (!metadata) {
146
- return void 0;
147
+ return;
147
148
  }
148
149
  return {
149
150
  description: metadata.description?.trim(),
@@ -271,7 +272,7 @@ function parseYamlScalar(raw) {
271
272
  if (value === "false") {
272
273
  return false;
273
274
  }
274
- if (/^-?\d+(?:\.\d+)?$/.test(value)) {
275
+ if (YAML_NUMERIC_SCALAR.test(value)) {
275
276
  return Number(value);
276
277
  }
277
278
  if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
@@ -813,9 +814,14 @@ function checkDuplicateIds(items, idField, path) {
813
814
  }
814
815
  return issues;
815
816
  }
816
- function validateDomainPack(pack) {
817
- const issues = [];
818
- if (!pack.packId || !pack.packId.trim()) {
817
+ function checkOptionalDuplicateIds(items, idField, path) {
818
+ if (!items) {
819
+ return [];
820
+ }
821
+ return checkDuplicateIds(items, idField, path);
822
+ }
823
+ function validatePackIdentity(pack, issues) {
824
+ if (typeof pack.packId !== "string" || pack.packId.trim().length === 0) {
819
825
  issues.push(issue("MISSING_PACK_ID", "packId is required", "packId"));
820
826
  } else if (!KEBAB_CASE.test(pack.packId)) {
821
827
  issues.push(
@@ -826,10 +832,10 @@ function validateDomainPack(pack) {
826
832
  )
827
833
  );
828
834
  }
829
- if (!pack.name || !pack.name.trim()) {
835
+ if (typeof pack.name !== "string" || pack.name.trim().length === 0) {
830
836
  issues.push(issue("MISSING_NAME", "name is required", "name"));
831
837
  }
832
- if (!pack.version || !pack.version.trim()) {
838
+ if (typeof pack.version !== "string" || pack.version.trim().length === 0) {
833
839
  issues.push(issue("MISSING_VERSION", "version is required", "version"));
834
840
  } else if (!SEMVER.test(pack.version)) {
835
841
  issues.push(
@@ -840,6 +846,8 @@ function validateDomainPack(pack) {
840
846
  )
841
847
  );
842
848
  }
849
+ }
850
+ function validateOntologyBindings(pack, issues) {
843
851
  if (!pack.ontologyBindings || pack.ontologyBindings.length === 0) {
844
852
  issues.push(
845
853
  issue(
@@ -900,6 +908,8 @@ function validateDomainPack(pack) {
900
908
  );
901
909
  }
902
910
  }
911
+ }
912
+ function validateTopicRoots(pack, issues) {
903
913
  if (!pack.topicRoots || pack.topicRoots.length === 0) {
904
914
  issues.push(
905
915
  issue(
@@ -908,270 +918,343 @@ function validateDomainPack(pack) {
908
918
  "topicRoots"
909
919
  )
910
920
  );
911
- } else {
921
+ return;
922
+ }
923
+ issues.push(
924
+ ...checkOptionalDuplicateIds(pack.topicRoots, "slug", "topicRoots")
925
+ );
926
+ }
927
+ function validateOperatingSystemPrompts(operatingSystem, issues) {
928
+ if (!operatingSystem.prompts) {
929
+ return;
930
+ }
931
+ issues.push(
932
+ ...checkOptionalDuplicateIds(
933
+ operatingSystem.prompts,
934
+ "promptId",
935
+ "operatingSystem.prompts"
936
+ )
937
+ );
938
+ for (const [index, prompt] of operatingSystem.prompts.entries()) {
939
+ issues.push(...validatePromptBinding(prompt, index));
940
+ }
941
+ }
942
+ function validateOperatingSystemTools(operatingSystem, issues) {
943
+ if (!operatingSystem.tools) {
944
+ return;
945
+ }
946
+ issues.push(
947
+ ...checkOptionalDuplicateIds(
948
+ operatingSystem.tools,
949
+ "toolId",
950
+ "operatingSystem.tools"
951
+ )
952
+ );
953
+ for (const [index, tool] of operatingSystem.tools.entries()) {
954
+ issues.push(...validateToolBinding(tool, index));
955
+ }
956
+ }
957
+ function validateOperatingSystemSetupAssets(operatingSystem, issues) {
958
+ if (!operatingSystem.setupAssets) {
959
+ return;
960
+ }
961
+ issues.push(
962
+ ...checkOptionalDuplicateIds(
963
+ operatingSystem.setupAssets,
964
+ "assetId",
965
+ "operatingSystem.setupAssets"
966
+ )
967
+ );
968
+ for (const [index, asset] of operatingSystem.setupAssets.entries()) {
969
+ issues.push(...validateSetupAsset(asset, index));
970
+ }
971
+ }
972
+ function validateOperatingSystemTopicTemplates(operatingSystem, knownRootSlugs, issues) {
973
+ const templateSlugs = /* @__PURE__ */ new Set();
974
+ if (!operatingSystem.topicTemplates) {
975
+ return templateSlugs;
976
+ }
977
+ issues.push(
978
+ ...checkOptionalDuplicateIds(
979
+ operatingSystem.topicTemplates,
980
+ "slug",
981
+ "operatingSystem.topicTemplates"
982
+ )
983
+ );
984
+ for (const template of operatingSystem.topicTemplates) {
985
+ if (template.slug) {
986
+ templateSlugs.add(template.slug);
987
+ }
988
+ }
989
+ const knownTopicSlugs = /* @__PURE__ */ new Set([...knownRootSlugs, ...templateSlugs]);
990
+ for (const [index, template] of operatingSystem.topicTemplates.entries()) {
991
+ issues.push(...validateTopicTemplate(template, index, knownTopicSlugs));
992
+ }
993
+ return templateSlugs;
994
+ }
995
+ function validateOperatingSystemInstallProfiles(operatingSystem, knownRootSlugs, templateSlugs, issues) {
996
+ if (!operatingSystem.installProfiles) {
997
+ return;
998
+ }
999
+ issues.push(
1000
+ ...checkOptionalDuplicateIds(
1001
+ operatingSystem.installProfiles,
1002
+ "profileId",
1003
+ "operatingSystem.installProfiles"
1004
+ )
1005
+ );
1006
+ const knownPromptIds = new Set(
1007
+ operatingSystem.prompts?.map((prompt) => prompt.promptId) ?? []
1008
+ );
1009
+ const knownToolIds = new Set(
1010
+ operatingSystem.tools?.map((tool) => tool.toolId) ?? []
1011
+ );
1012
+ const knownAssetIds = new Set(
1013
+ operatingSystem.setupAssets?.map((asset) => asset.assetId) ?? []
1014
+ );
1015
+ const knownTopicSlugs = /* @__PURE__ */ new Set([...knownRootSlugs, ...templateSlugs]);
1016
+ for (const [index, profile] of operatingSystem.installProfiles.entries()) {
912
1017
  issues.push(
913
- ...checkDuplicateIds(
914
- pack.topicRoots,
915
- "slug",
916
- "topicRoots"
1018
+ ...validateInstallProfile(
1019
+ profile,
1020
+ index,
1021
+ knownPromptIds,
1022
+ knownToolIds,
1023
+ knownAssetIds,
1024
+ knownTopicSlugs
917
1025
  )
918
1026
  );
919
1027
  }
920
- if (pack.operatingSystem) {
921
- const knownRootSlugs = new Set(
922
- pack.topicRoots?.map((topic) => topic.slug) ?? []
923
- );
924
- if (pack.operatingSystem.prompts) {
925
- issues.push(
926
- ...checkDuplicateIds(
927
- pack.operatingSystem.prompts,
928
- "promptId",
929
- "operatingSystem.prompts"
930
- )
931
- );
932
- pack.operatingSystem.prompts.forEach((prompt, index) => {
933
- issues.push(...validatePromptBinding(prompt, index));
934
- });
935
- }
936
- if (pack.operatingSystem.tools) {
937
- issues.push(
938
- ...checkDuplicateIds(
939
- pack.operatingSystem.tools,
940
- "toolId",
941
- "operatingSystem.tools"
942
- )
943
- );
944
- pack.operatingSystem.tools.forEach((tool, index) => {
945
- issues.push(...validateToolBinding(tool, index));
946
- });
947
- }
948
- if (pack.operatingSystem.setupAssets) {
949
- issues.push(
950
- ...checkDuplicateIds(
951
- pack.operatingSystem.setupAssets,
952
- "assetId",
953
- "operatingSystem.setupAssets"
954
- )
955
- );
956
- pack.operatingSystem.setupAssets.forEach((asset, index) => {
957
- issues.push(...validateSetupAsset(asset, index));
958
- });
959
- }
960
- const templateSlugs = /* @__PURE__ */ new Set();
961
- if (pack.operatingSystem.topicTemplates) {
962
- issues.push(
963
- ...checkDuplicateIds(
964
- pack.operatingSystem.topicTemplates,
965
- "slug",
966
- "operatingSystem.topicTemplates"
967
- )
968
- );
969
- pack.operatingSystem.topicTemplates.forEach((template) => {
970
- if (template.slug) {
971
- templateSlugs.add(template.slug);
972
- }
973
- });
974
- const knownTopicSlugs = /* @__PURE__ */ new Set([...knownRootSlugs, ...templateSlugs]);
975
- pack.operatingSystem.topicTemplates.forEach((template, index) => {
976
- issues.push(...validateTopicTemplate(template, index, knownTopicSlugs));
977
- });
978
- }
979
- if (pack.operatingSystem.installProfiles) {
980
- issues.push(
981
- ...checkDuplicateIds(
982
- pack.operatingSystem.installProfiles,
983
- "profileId",
984
- "operatingSystem.installProfiles"
985
- )
986
- );
987
- const knownPromptIds = new Set(
988
- pack.operatingSystem.prompts?.map((prompt) => prompt.promptId) ?? []
989
- );
990
- const knownToolIds = new Set(
991
- pack.operatingSystem.tools?.map((tool) => tool.toolId) ?? []
992
- );
993
- const knownAssetIds = new Set(
994
- pack.operatingSystem.setupAssets?.map((asset) => asset.assetId) ?? []
995
- );
996
- const knownTopicSlugs = /* @__PURE__ */ new Set([...knownRootSlugs, ...templateSlugs]);
997
- pack.operatingSystem.installProfiles.forEach((profile, index) => {
998
- issues.push(
999
- ...validateInstallProfile(
1000
- profile,
1001
- index,
1002
- knownPromptIds,
1003
- knownToolIds,
1004
- knownAssetIds,
1005
- knownTopicSlugs
1006
- )
1007
- );
1008
- });
1009
- }
1028
+ }
1029
+ function validateOperatingSystem(pack, issues) {
1030
+ if (!pack.operatingSystem) {
1031
+ return;
1010
1032
  }
1033
+ const knownRootSlugs = new Set(
1034
+ pack.topicRoots?.map((topic) => topic.slug) ?? []
1035
+ );
1036
+ validateOperatingSystemPrompts(pack.operatingSystem, issues);
1037
+ validateOperatingSystemTools(pack.operatingSystem, issues);
1038
+ validateOperatingSystemSetupAssets(pack.operatingSystem, issues);
1039
+ const templateSlugs = validateOperatingSystemTopicTemplates(
1040
+ pack.operatingSystem,
1041
+ knownRootSlugs,
1042
+ issues
1043
+ );
1044
+ validateOperatingSystemInstallProfiles(
1045
+ pack.operatingSystem,
1046
+ knownRootSlugs,
1047
+ templateSlugs,
1048
+ issues
1049
+ );
1050
+ }
1051
+ function validateRoles(pack, issues) {
1011
1052
  if (!pack.roles || pack.roles.length === 0) {
1012
1053
  issues.push(
1013
1054
  issue("MISSING_ROLES", "At least one reasoning role is required", "roles")
1014
1055
  );
1015
1056
  } else {
1016
- issues.push(
1017
- ...checkDuplicateIds(
1018
- pack.roles,
1019
- "roleId",
1020
- "roles"
1021
- )
1022
- );
1057
+ issues.push(...checkOptionalDuplicateIds(pack.roles, "roleId", "roles"));
1023
1058
  }
1024
- const knownGateIds = new Set(pack.gates?.map((g) => g.gateId) ?? []);
1025
- const knownArtifactIds = new Set(
1026
- pack.artifacts?.map((a) => a.artifactId) ?? []
1027
- );
1028
- const knownRoleIds = new Set(pack.roles?.map((r) => r.roleId) ?? []);
1029
- if (pack.gates) {
1059
+ }
1060
+ function validateGates(pack, issues) {
1061
+ if (!pack.gates) {
1062
+ return;
1063
+ }
1064
+ issues.push(...checkOptionalDuplicateIds(pack.gates, "gateId", "gates"));
1065
+ for (const [index, gate] of pack.gates.entries()) {
1066
+ if (!gate.criteria || gate.criteria.length === 0) {
1067
+ issues.push(
1068
+ issue(
1069
+ "EMPTY_GATE_CRITERIA",
1070
+ `Gate "${gate.gateId}" has no criteria`,
1071
+ `gates[${index}].criteria`,
1072
+ "warning"
1073
+ )
1074
+ );
1075
+ continue;
1076
+ }
1030
1077
  issues.push(
1031
- ...checkDuplicateIds(
1032
- pack.gates,
1033
- "gateId",
1034
- "gates"
1078
+ ...checkOptionalDuplicateIds(
1079
+ gate.criteria,
1080
+ "criterionId",
1081
+ `gates[${index}].criteria`
1035
1082
  )
1036
1083
  );
1037
- for (const [i, gate] of pack.gates.entries()) {
1038
- if (!gate.criteria || gate.criteria.length === 0) {
1039
- issues.push(
1040
- issue(
1041
- "EMPTY_GATE_CRITERIA",
1042
- `Gate "${gate.gateId}" has no criteria`,
1043
- `gates[${i}].criteria`,
1044
- "warning"
1045
- )
1046
- );
1047
- } else {
1048
- issues.push(
1049
- ...checkDuplicateIds(
1050
- gate.criteria,
1051
- "criterionId",
1052
- `gates[${i}].criteria`
1053
- )
1054
- );
1055
- }
1056
- }
1057
1084
  }
1085
+ }
1086
+ function validateArtifacts(pack, issues) {
1058
1087
  if (pack.artifacts) {
1059
1088
  issues.push(
1060
- ...checkDuplicateIds(
1061
- pack.artifacts,
1062
- "artifactId",
1063
- "artifacts"
1064
- )
1089
+ ...checkOptionalDuplicateIds(pack.artifacts, "artifactId", "artifacts")
1065
1090
  );
1066
1091
  }
1067
- if (pack.workflows) {
1068
- issues.push(
1069
- ...checkDuplicateIds(
1070
- pack.workflows,
1071
- "workflowId",
1072
- "workflows"
1073
- )
1074
- );
1075
- for (const [wi, workflow] of pack.workflows.entries()) {
1076
- for (const gateId of workflow.gateCheckpoints) {
1077
- if (!knownGateIds.has(gateId)) {
1078
- issues.push(
1079
- issue(
1080
- "UNKNOWN_GATE_REF",
1081
- `Workflow "${workflow.workflowId}" references unknown gate "${gateId}"`,
1082
- `workflows[${wi}].gateCheckpoints`
1083
- )
1084
- );
1085
- }
1086
- }
1087
- for (const artifactId of workflow.requiredArtifacts) {
1088
- if (!knownArtifactIds.has(artifactId)) {
1089
- issues.push(
1090
- issue(
1091
- "UNKNOWN_ARTIFACT_REF",
1092
- `Workflow "${workflow.workflowId}" references unknown artifact "${artifactId}"`,
1093
- `workflows[${wi}].requiredArtifacts`
1094
- )
1095
- );
1096
- }
1097
- }
1098
- for (const [si, step] of workflow.steps.entries()) {
1099
- for (const roleId of step.requiredRoles) {
1100
- if (!knownRoleIds.has(roleId)) {
1101
- issues.push(
1102
- issue(
1103
- "UNKNOWN_ROLE_REF",
1104
- `Step "${step.stepId}" references unknown role "${roleId}"`,
1105
- `workflows[${wi}].steps[${si}].requiredRoles`
1106
- )
1107
- );
1108
- }
1109
- }
1110
- if (step.gateId && !knownGateIds.has(step.gateId)) {
1111
- issues.push(
1112
- issue(
1113
- "UNKNOWN_GATE_REF",
1114
- `Step "${step.stepId}" references unknown gate "${step.gateId}"`,
1115
- `workflows[${wi}].steps[${si}].gateId`
1116
- )
1117
- );
1118
- }
1119
- if (step.produces) {
1120
- for (const artifactId of step.produces) {
1121
- if (!knownArtifactIds.has(artifactId)) {
1122
- issues.push(
1123
- issue(
1124
- "UNKNOWN_ARTIFACT_REF",
1125
- `Step "${step.stepId}" references unknown artifact "${artifactId}"`,
1126
- `workflows[${wi}].steps[${si}].produces`
1127
- )
1128
- );
1129
- }
1130
- }
1131
- }
1132
- }
1092
+ }
1093
+ function domainPackReferenceSets(pack) {
1094
+ return {
1095
+ knownGateIds: new Set(pack.gates?.map((gate) => gate.gateId) ?? []),
1096
+ knownArtifactIds: new Set(
1097
+ pack.artifacts?.map((artifact) => artifact.artifactId) ?? []
1098
+ ),
1099
+ knownRoleIds: new Set(pack.roles?.map((role) => role.roleId) ?? [])
1100
+ };
1101
+ }
1102
+ function validateWorkflowGateReferences(workflow, workflowIndex, knownGateIds, issues) {
1103
+ for (const gateId of workflow.gateCheckpoints) {
1104
+ if (!knownGateIds.has(gateId)) {
1105
+ issues.push(
1106
+ issue(
1107
+ "UNKNOWN_GATE_REF",
1108
+ `Workflow "${workflow.workflowId}" references unknown gate "${gateId}"`,
1109
+ `workflows[${workflowIndex}].gateCheckpoints`
1110
+ )
1111
+ );
1133
1112
  }
1134
1113
  }
1135
- if (pack.inquiryShaping) {
1136
- if (pack.inquiryShaping.questionTemplates) {
1114
+ }
1115
+ function validateWorkflowArtifactReferences(workflow, workflowIndex, knownArtifactIds, issues) {
1116
+ for (const artifactId of workflow.requiredArtifacts) {
1117
+ if (!knownArtifactIds.has(artifactId)) {
1137
1118
  issues.push(
1138
- ...checkDuplicateIds(
1139
- pack.inquiryShaping.questionTemplates,
1140
- "templateId",
1141
- "inquiryShaping.questionTemplates"
1119
+ issue(
1120
+ "UNKNOWN_ARTIFACT_REF",
1121
+ `Workflow "${workflow.workflowId}" references unknown artifact "${artifactId}"`,
1122
+ `workflows[${workflowIndex}].requiredArtifacts`
1142
1123
  )
1143
1124
  );
1144
- pack.inquiryShaping.questionTemplates.forEach((template, index) => {
1145
- issues.push(...validateQuestionTemplate(template, index));
1146
- });
1147
1125
  }
1148
- if (pack.inquiryShaping.taskTemplates) {
1126
+ }
1127
+ }
1128
+ function validateWorkflowStepReferences(step, workflowIndex, stepIndex, refs, issues) {
1129
+ for (const roleId of step.requiredRoles) {
1130
+ if (!refs.knownRoleIds.has(roleId)) {
1149
1131
  issues.push(
1150
- ...checkDuplicateIds(
1151
- pack.inquiryShaping.taskTemplates,
1152
- "templateId",
1153
- "inquiryShaping.taskTemplates"
1132
+ issue(
1133
+ "UNKNOWN_ROLE_REF",
1134
+ `Step "${step.stepId}" references unknown role "${roleId}"`,
1135
+ `workflows[${workflowIndex}].steps[${stepIndex}].requiredRoles`
1154
1136
  )
1155
1137
  );
1156
- pack.inquiryShaping.taskTemplates.forEach((template, index) => {
1157
- issues.push(...validateTaskTemplate(template, index));
1158
- });
1159
1138
  }
1160
- if (pack.inquiryShaping.frameworkHints) {
1139
+ }
1140
+ if (step.gateId && !refs.knownGateIds.has(step.gateId)) {
1141
+ issues.push(
1142
+ issue(
1143
+ "UNKNOWN_GATE_REF",
1144
+ `Step "${step.stepId}" references unknown gate "${step.gateId}"`,
1145
+ `workflows[${workflowIndex}].steps[${stepIndex}].gateId`
1146
+ )
1147
+ );
1148
+ }
1149
+ for (const artifactId of step.produces ?? []) {
1150
+ if (!refs.knownArtifactIds.has(artifactId)) {
1161
1151
  issues.push(
1162
- ...checkDuplicateIds(
1163
- pack.inquiryShaping.frameworkHints.map((hint) => ({
1164
- frameworkName: hint.frameworkName
1165
- })),
1166
- "frameworkName",
1167
- "inquiryShaping.frameworkHints"
1152
+ issue(
1153
+ "UNKNOWN_ARTIFACT_REF",
1154
+ `Step "${step.stepId}" references unknown artifact "${artifactId}"`,
1155
+ `workflows[${workflowIndex}].steps[${stepIndex}].produces`
1168
1156
  )
1169
1157
  );
1170
- pack.inquiryShaping.frameworkHints.forEach((hint, index) => {
1171
- issues.push(...validateFrameworkHint(hint, index));
1172
- });
1173
1158
  }
1174
1159
  }
1160
+ }
1161
+ function validateWorkflows(pack, refs, issues) {
1162
+ if (!pack.workflows) {
1163
+ return;
1164
+ }
1165
+ issues.push(
1166
+ ...checkOptionalDuplicateIds(pack.workflows, "workflowId", "workflows")
1167
+ );
1168
+ for (const [workflowIndex, workflow] of pack.workflows.entries()) {
1169
+ validateWorkflowGateReferences(
1170
+ workflow,
1171
+ workflowIndex,
1172
+ refs.knownGateIds,
1173
+ issues
1174
+ );
1175
+ validateWorkflowArtifactReferences(
1176
+ workflow,
1177
+ workflowIndex,
1178
+ refs.knownArtifactIds,
1179
+ issues
1180
+ );
1181
+ for (const [stepIndex, step] of workflow.steps.entries()) {
1182
+ validateWorkflowStepReferences(
1183
+ step,
1184
+ workflowIndex,
1185
+ stepIndex,
1186
+ refs,
1187
+ issues
1188
+ );
1189
+ }
1190
+ }
1191
+ }
1192
+ function validateInquiryQuestionTemplates(pack, issues) {
1193
+ if (!pack.inquiryShaping?.questionTemplates) {
1194
+ return;
1195
+ }
1196
+ issues.push(
1197
+ ...checkOptionalDuplicateIds(
1198
+ pack.inquiryShaping.questionTemplates,
1199
+ "templateId",
1200
+ "inquiryShaping.questionTemplates"
1201
+ )
1202
+ );
1203
+ for (const [
1204
+ index,
1205
+ template
1206
+ ] of pack.inquiryShaping.questionTemplates.entries()) {
1207
+ issues.push(...validateQuestionTemplate(template, index));
1208
+ }
1209
+ }
1210
+ function validateInquiryTaskTemplates(pack, issues) {
1211
+ if (!pack.inquiryShaping?.taskTemplates) {
1212
+ return;
1213
+ }
1214
+ issues.push(
1215
+ ...checkOptionalDuplicateIds(
1216
+ pack.inquiryShaping.taskTemplates,
1217
+ "templateId",
1218
+ "inquiryShaping.taskTemplates"
1219
+ )
1220
+ );
1221
+ for (const [index, template] of pack.inquiryShaping.taskTemplates.entries()) {
1222
+ issues.push(...validateTaskTemplate(template, index));
1223
+ }
1224
+ }
1225
+ function validateInquiryFrameworkHints(pack, issues) {
1226
+ if (!pack.inquiryShaping?.frameworkHints) {
1227
+ return;
1228
+ }
1229
+ issues.push(
1230
+ ...checkDuplicateIds(
1231
+ pack.inquiryShaping.frameworkHints.map((hint) => ({
1232
+ frameworkName: hint.frameworkName
1233
+ })),
1234
+ "frameworkName",
1235
+ "inquiryShaping.frameworkHints"
1236
+ )
1237
+ );
1238
+ for (const [index, hint] of pack.inquiryShaping.frameworkHints.entries()) {
1239
+ issues.push(...validateFrameworkHint(hint, index));
1240
+ }
1241
+ }
1242
+ function validateInquiryShaping(pack, issues) {
1243
+ validateInquiryQuestionTemplates(pack, issues);
1244
+ validateInquiryTaskTemplates(pack, issues);
1245
+ validateInquiryFrameworkHints(pack, issues);
1246
+ }
1247
+ function validateDomainPack(pack) {
1248
+ const issues = [];
1249
+ validatePackIdentity(pack, issues);
1250
+ validateOntologyBindings(pack, issues);
1251
+ validateTopicRoots(pack, issues);
1252
+ validateOperatingSystem(pack, issues);
1253
+ validateRoles(pack, issues);
1254
+ validateGates(pack, issues);
1255
+ validateArtifacts(pack, issues);
1256
+ validateWorkflows(pack, domainPackReferenceSets(pack), issues);
1257
+ validateInquiryShaping(pack, issues);
1175
1258
  return {
1176
1259
  valid: issues.filter((i) => i.severity === "error").length === 0,
1177
1260
  issues
@@ -1462,7 +1545,7 @@ function validateOntologyExtensions(extensions) {
1462
1545
  extension.entityTypes?.forEach(
1463
1546
  (entityType, entityTypeIndex) => {
1464
1547
  const entityPath = `${path}.entityTypes[${entityTypeIndex}]`;
1465
- if (!entityType.value || !KEBAB_CASE2.test(entityType.value)) {
1548
+ if (!(entityType.value && KEBAB_CASE2.test(entityType.value))) {
1466
1549
  issues.push(
1467
1550
  issue2(
1468
1551
  "INVALID_ONTOLOGY_ENTITY_VALUE",
@@ -1499,7 +1582,7 @@ function validateOntologyExtensions(extensions) {
1499
1582
  extension.edgeTypes?.forEach(
1500
1583
  (edgeType, edgeTypeIndex) => {
1501
1584
  const edgePath = `${path}.edgeTypes[${edgeTypeIndex}]`;
1502
- if (!edgeType.value || !KEBAB_CASE2.test(edgeType.value)) {
1585
+ if (!(edgeType.value && KEBAB_CASE2.test(edgeType.value))) {
1503
1586
  issues.push(
1504
1587
  issue2(
1505
1588
  "INVALID_ONTOLOGY_EDGE_VALUE",
@@ -1655,15 +1738,15 @@ function validateLineage(lineage, packId) {
1655
1738
  function scanLegacyPublicKeys(value, path = "") {
1656
1739
  const issues = [];
1657
1740
  if (Array.isArray(value)) {
1658
- value.forEach((entry, index) => {
1741
+ for (const [index, entry] of value.entries()) {
1659
1742
  issues.push(...scanLegacyPublicKeys(entry, `${path}[${index}]`));
1660
- });
1743
+ }
1661
1744
  return issues;
1662
1745
  }
1663
1746
  if (!isPlainObject2(value)) {
1664
1747
  return issues;
1665
1748
  }
1666
- Object.entries(value).forEach(([key, entryValue]) => {
1749
+ for (const [key, entryValue] of Object.entries(value)) {
1667
1750
  const nextPath = path ? `${path}.${key}` : key;
1668
1751
  if (LEGACY_PUBLIC_KEYS.has(key)) {
1669
1752
  issues.push(
@@ -1676,7 +1759,7 @@ function scanLegacyPublicKeys(value, path = "") {
1676
1759
  );
1677
1760
  }
1678
1761
  issues.push(...scanLegacyPublicKeys(entryValue, nextPath));
1679
- });
1762
+ }
1680
1763
  return issues;
1681
1764
  }
1682
1765
  function createManifestDigest(manifest) {
@@ -1741,12 +1824,7 @@ function parseFailureResult(error, format) {
1741
1824
  manifest: null,
1742
1825
  manifestDigest: null,
1743
1826
  issues: [
1744
- issue2(
1745
- "PARSE_ERROR",
1746
- describeParseFailure(error),
1747
- "manifest",
1748
- "parse"
1749
- )
1827
+ issue2("PARSE_ERROR", describeParseFailure(error), "manifest", "parse")
1750
1828
  ],
1751
1829
  counts: emptyCounts()
1752
1830
  };
@@ -1772,23 +1850,28 @@ function collectRuntimeTargets(manifest) {
1772
1850
  return [];
1773
1851
  }
1774
1852
  const targets = /* @__PURE__ */ new Set();
1775
- manifest.frameworks?.forEach(
1776
- (framework) => framework.runtimeTargets?.forEach((target) => targets.add(target))
1777
- );
1778
- manifest.pack.operatingSystem?.prompts?.forEach(
1779
- (prompt) => prompt.runtimeTargets?.forEach((target) => targets.add(target))
1780
- );
1781
- manifest.pack.operatingSystem?.tools?.forEach(
1782
- (tool) => tool.runtimeTargets?.forEach((target) => targets.add(target))
1783
- );
1784
- manifest.pack.operatingSystem?.setupAssets?.forEach(
1785
- (asset) => asset.runtimeTargets?.forEach((target) => targets.add(target))
1786
- );
1787
- manifest.pack.operatingSystem?.installProfiles?.forEach(
1788
- (profile) => targets.add(profile.runtimeTarget)
1789
- );
1853
+ for (const framework of manifest.frameworks ?? []) {
1854
+ addRuntimeTargets(targets, framework.runtimeTargets);
1855
+ }
1856
+ for (const prompt of manifest.pack.operatingSystem?.prompts ?? []) {
1857
+ addRuntimeTargets(targets, prompt.runtimeTargets);
1858
+ }
1859
+ for (const tool of manifest.pack.operatingSystem?.tools ?? []) {
1860
+ addRuntimeTargets(targets, tool.runtimeTargets);
1861
+ }
1862
+ for (const asset of manifest.pack.operatingSystem?.setupAssets ?? []) {
1863
+ addRuntimeTargets(targets, asset.runtimeTargets);
1864
+ }
1865
+ for (const profile of manifest.pack.operatingSystem?.installProfiles ?? []) {
1866
+ targets.add(profile.runtimeTarget);
1867
+ }
1790
1868
  return Array.from(targets).sort();
1791
1869
  }
1870
+ function addRuntimeTargets(targets, values) {
1871
+ for (const target of values ?? []) {
1872
+ targets.add(target);
1873
+ }
1874
+ }
1792
1875
  function describeLineage(lineage) {
1793
1876
  if (!lineage) {
1794
1877
  return null;
@@ -1832,20 +1915,35 @@ function buildLineageEdge(manifest) {
1832
1915
  return {
1833
1916
  edgeType: "remixed_from",
1834
1917
  childPackId: pack.packId,
1835
- parentPackId: lineage.parentPackId,
1836
- parentVersion: lineage.parentVersion
1918
+ parentPackId: readLineageField(lineage.parentPackId, "parentPackId"),
1919
+ parentVersion: readLineageField(lineage.parentVersion, "parentVersion")
1837
1920
  };
1838
1921
  }
1839
1922
  return {
1840
1923
  edgeType: "supersedes",
1841
1924
  childPackId: pack.packId,
1842
- parentPackId: lineage.supersedesPackId,
1843
- parentVersion: lineage.parentVersion
1925
+ parentPackId: readLineageField(
1926
+ lineage.supersedesPackId,
1927
+ "supersedesPackId"
1928
+ ),
1929
+ parentVersion: readLineageField(lineage.parentVersion, "parentVersion")
1844
1930
  };
1845
1931
  }
1932
+ function readLineageField(value, field) {
1933
+ if (typeof value === "string" && value.length > 0) {
1934
+ return value;
1935
+ }
1936
+ throw new Error(`Cannot publish domain pack with missing lineage.${field}.`);
1937
+ }
1938
+ function readPublicationArtifact(value, field) {
1939
+ if (typeof value === "string" && value.length > 0) {
1940
+ return value;
1941
+ }
1942
+ throw new Error(`Cannot publish domain pack with missing ${field}.`);
1943
+ }
1846
1944
  function publishDomainPackAuthoringManifest(manifest) {
1847
1945
  const preview = previewDomainPackAuthoringManifest(manifest);
1848
- if (!preview.readyToPublish || !preview.manifest || !preview.manifestDigest) {
1946
+ if (!(preview.readyToPublish && preview.manifest && preview.manifestDigest)) {
1849
1947
  return {
1850
1948
  published: false,
1851
1949
  preview,
@@ -1862,14 +1960,20 @@ function publishDomainPackAuthoringManifest(manifest) {
1862
1960
  manifestDigest: preview.manifestDigest,
1863
1961
  manifest: preview.manifest,
1864
1962
  lineageEdge: buildLineageEdge(preview.manifest),
1865
- canonicalJson: preview.canonicalJson,
1866
- canonicalYaml: preview.canonicalYaml
1963
+ canonicalJson: readPublicationArtifact(
1964
+ preview.canonicalJson,
1965
+ "canonicalJson"
1966
+ ),
1967
+ canonicalYaml: readPublicationArtifact(
1968
+ preview.canonicalYaml,
1969
+ "canonicalYaml"
1970
+ )
1867
1971
  }
1868
1972
  };
1869
1973
  }
1870
1974
  function publishDomainPackAuthoringManifestSource(source, format) {
1871
1975
  const preview = previewDomainPackAuthoringManifestSource(source, format);
1872
- if (!preview.readyToPublish || !preview.manifest || !preview.manifestDigest) {
1976
+ if (!(preview.readyToPublish && preview.manifest && preview.manifestDigest)) {
1873
1977
  return {
1874
1978
  published: false,
1875
1979
  preview,
@@ -1886,8 +1990,14 @@ function publishDomainPackAuthoringManifestSource(source, format) {
1886
1990
  manifestDigest: preview.manifestDigest,
1887
1991
  manifest: preview.manifest,
1888
1992
  lineageEdge: buildLineageEdge(preview.manifest),
1889
- canonicalJson: preview.canonicalJson,
1890
- canonicalYaml: preview.canonicalYaml
1993
+ canonicalJson: readPublicationArtifact(
1994
+ preview.canonicalJson,
1995
+ "canonicalJson"
1996
+ ),
1997
+ canonicalYaml: readPublicationArtifact(
1998
+ preview.canonicalYaml,
1999
+ "canonicalYaml"
2000
+ )
1891
2001
  }
1892
2002
  };
1893
2003
  }
@@ -1913,19 +2023,28 @@ function createDomainPackAuthoringTools() {
1913
2023
  name: AUTHORING_TOOL_NAMES.validate,
1914
2024
  description: "Validate a domain pack authoring manifest and return structural, lineage, terminology, and extension issues.",
1915
2025
  inputSchema,
1916
- execute: (args) => validateDomainPackAuthoringManifestSource(args.manifestText, args.format)
2026
+ execute: (args) => validateDomainPackAuthoringManifestSource(
2027
+ args.manifestText,
2028
+ args.format
2029
+ )
1917
2030
  }),
1918
2031
  preview: asToolDefinition({
1919
2032
  name: AUTHORING_TOOL_NAMES.preview,
1920
2033
  description: "Preview a domain pack manifest with canonical JSON/YAML renderings, runtime targets, and publication readiness.",
1921
2034
  inputSchema,
1922
- execute: (args) => previewDomainPackAuthoringManifestSource(args.manifestText, args.format)
2035
+ execute: (args) => previewDomainPackAuthoringManifestSource(
2036
+ args.manifestText,
2037
+ args.format
2038
+ )
1923
2039
  }),
1924
2040
  publish: asToolDefinition({
1925
2041
  name: AUTHORING_TOOL_NAMES.publish,
1926
2042
  description: "Build a publication-ready domain pack artifact when validation passes, including remix/fork lineage metadata.",
1927
2043
  inputSchema,
1928
- execute: (args) => publishDomainPackAuthoringManifestSource(args.manifestText, args.format)
2044
+ execute: (args) => publishDomainPackAuthoringManifestSource(
2045
+ args.manifestText,
2046
+ args.format
2047
+ )
1929
2048
  })
1930
2049
  };
1931
2050
  }
@@ -2064,7 +2183,7 @@ var TASK_PRIORITY_WEIGHT = {
2064
2183
  };
2065
2184
  function dedupeStrings3(values) {
2066
2185
  if (!values || values.length === 0) {
2067
- return void 0;
2186
+ return;
2068
2187
  }
2069
2188
  const normalized = values.map((value) => value.trim()).filter(Boolean);
2070
2189
  return normalized.length > 0 ? Array.from(new Set(normalized)) : void 0;
@@ -2137,7 +2256,11 @@ function checkDuplicateIds2(items, idField, path) {
2137
2256
  }
2138
2257
  if (seen.has(id)) {
2139
2258
  issues.push(
2140
- issue3("DUPLICATE_ID", `Duplicate ${idField} "${id}"`, `${path}.${idField}`)
2259
+ issue3(
2260
+ "DUPLICATE_ID",
2261
+ `Duplicate ${idField} "${id}"`,
2262
+ `${path}.${idField}`
2263
+ )
2141
2264
  );
2142
2265
  }
2143
2266
  seen.add(id);
@@ -2263,7 +2386,9 @@ function createShapingContributionRegistry(packs = []) {
2263
2386
  }
2264
2387
  const packValidation = validateDomainPack(pack);
2265
2388
  if (!packValidation.valid) {
2266
- throw new Error(formatRegistrationIssues(pack.packId, packValidation.issues));
2389
+ throw new Error(
2390
+ formatRegistrationIssues(pack.packId, packValidation.issues)
2391
+ );
2267
2392
  }
2268
2393
  const contribution = buildShapingContribution(pack);
2269
2394
  const contributionValidation = validateShapingContribution(contribution);
@@ -2521,7 +2646,13 @@ var DEVELOPER_REASONING_PACK = defineDomainPack({
2521
2646
  questionType: "counterfactual",
2522
2647
  priority: "high",
2523
2648
  template: "What existing behavior or verification path would regress if {{hypothesis}} is false?",
2524
- whenObjectiveIncludes: ["build", "implement", "add", "extend", "support"]
2649
+ whenObjectiveIncludes: [
2650
+ "build",
2651
+ "implement",
2652
+ "add",
2653
+ "extend",
2654
+ "support"
2655
+ ]
2525
2656
  }
2526
2657
  ],
2527
2658
  taskTemplates: [