@mimir-labs/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/implementation/adapters/agents-md/adapter.d.ts +2 -0
  4. package/dist/implementation/adapters/agents-md/adapter.js +35 -0
  5. package/dist/implementation/adapters/agents-md/adapter.js.map +1 -0
  6. package/dist/implementation/adapters/copilot/adapter.d.ts +2 -0
  7. package/dist/implementation/adapters/copilot/adapter.js +34 -0
  8. package/dist/implementation/adapters/copilot/adapter.js.map +1 -0
  9. package/dist/implementation/adapters/cursor/adapter.d.ts +2 -0
  10. package/dist/implementation/adapters/cursor/adapter.js +33 -0
  11. package/dist/implementation/adapters/cursor/adapter.js.map +1 -0
  12. package/dist/implementation/adapters/index.d.ts +5 -0
  13. package/dist/implementation/adapters/index.js +23 -0
  14. package/dist/implementation/adapters/index.js.map +1 -0
  15. package/dist/implementation/adapters/managed-section.d.ts +5 -0
  16. package/dist/implementation/adapters/managed-section.js +37 -0
  17. package/dist/implementation/adapters/managed-section.js.map +1 -0
  18. package/dist/implementation/adapters/registry.d.ts +11 -0
  19. package/dist/implementation/adapters/registry.js +50 -0
  20. package/dist/implementation/adapters/registry.js.map +1 -0
  21. package/dist/implementation/adapters/types.d.ts +19 -0
  22. package/dist/implementation/adapters/types.js +3 -0
  23. package/dist/implementation/adapters/types.js.map +1 -0
  24. package/dist/implementation/configuration/manifest-loader.d.ts +16 -0
  25. package/dist/implementation/configuration/manifest-loader.js +64 -0
  26. package/dist/implementation/configuration/manifest-loader.js.map +1 -0
  27. package/dist/implementation/configuration/package-config.d.ts +12 -0
  28. package/dist/implementation/configuration/package-config.js +33 -0
  29. package/dist/implementation/configuration/package-config.js.map +1 -0
  30. package/dist/implementation/dependency-discovery/discover-providers.d.ts +6 -0
  31. package/dist/implementation/dependency-discovery/discover-providers.js +39 -0
  32. package/dist/implementation/dependency-discovery/discover-providers.js.map +1 -0
  33. package/dist/implementation/doctor/evaluator.d.ts +16 -0
  34. package/dist/implementation/doctor/evaluator.js +269 -0
  35. package/dist/implementation/doctor/evaluator.js.map +1 -0
  36. package/dist/implementation/generation/examples/existing-aps/src/Modal.d.ts +4 -0
  37. package/dist/implementation/generation/examples/existing-aps/src/Modal.js +7 -0
  38. package/dist/implementation/generation/examples/existing-aps/src/Modal.js.map +1 -0
  39. package/dist/implementation/generation/examples/existing-aps/src/index.d.ts +1 -0
  40. package/dist/implementation/generation/examples/existing-aps/src/index.js +6 -0
  41. package/dist/implementation/generation/examples/existing-aps/src/index.js.map +1 -0
  42. package/dist/implementation/generation/examples/missing-metadata/src/Input.d.ts +6 -0
  43. package/dist/implementation/generation/examples/missing-metadata/src/Input.js +6 -0
  44. package/dist/implementation/generation/examples/missing-metadata/src/Input.js.map +1 -0
  45. package/dist/implementation/generation/examples/missing-metadata/src/index.d.ts +1 -0
  46. package/dist/implementation/generation/examples/missing-metadata/src/index.js +6 -0
  47. package/dist/implementation/generation/examples/missing-metadata/src/index.js.map +1 -0
  48. package/dist/implementation/generation/examples/react-exports/src/Button.d.ts +5 -0
  49. package/dist/implementation/generation/examples/react-exports/src/Button.js +7 -0
  50. package/dist/implementation/generation/examples/react-exports/src/Button.js.map +1 -0
  51. package/dist/implementation/generation/examples/react-exports/src/Button.stories.d.ts +16 -0
  52. package/dist/implementation/generation/examples/react-exports/src/Button.stories.js +20 -0
  53. package/dist/implementation/generation/examples/react-exports/src/Button.stories.js.map +1 -0
  54. package/dist/implementation/generation/examples/react-exports/src/index.d.ts +1 -0
  55. package/dist/implementation/generation/examples/react-exports/src/index.js +6 -0
  56. package/dist/implementation/generation/examples/react-exports/src/index.js.map +1 -0
  57. package/dist/implementation/generation/extractors/readme-extractor.d.ts +2 -0
  58. package/dist/implementation/generation/extractors/readme-extractor.js +58 -0
  59. package/dist/implementation/generation/extractors/readme-extractor.js.map +1 -0
  60. package/dist/implementation/generation/extractors/storybook-extractor.d.ts +2 -0
  61. package/dist/implementation/generation/extractors/storybook-extractor.js +64 -0
  62. package/dist/implementation/generation/extractors/storybook-extractor.js.map +1 -0
  63. package/dist/implementation/generation/extractors/typescript-extractor.d.ts +2 -0
  64. package/dist/implementation/generation/extractors/typescript-extractor.js +138 -0
  65. package/dist/implementation/generation/extractors/typescript-extractor.js.map +1 -0
  66. package/dist/implementation/generation/generate-service.d.ts +6 -0
  67. package/dist/implementation/generation/generate-service.js +121 -0
  68. package/dist/implementation/generation/generate-service.js.map +1 -0
  69. package/dist/implementation/generation/provenance/provenance-builder.d.ts +6 -0
  70. package/dist/implementation/generation/provenance/provenance-builder.js +44 -0
  71. package/dist/implementation/generation/provenance/provenance-builder.js.map +1 -0
  72. package/dist/implementation/generation/resource-builders/component-builder.d.ts +2 -0
  73. package/dist/implementation/generation/resource-builders/component-builder.js +68 -0
  74. package/dist/implementation/generation/resource-builders/component-builder.js.map +1 -0
  75. package/dist/implementation/generation/resource-builders/example-builder.d.ts +5 -0
  76. package/dist/implementation/generation/resource-builders/example-builder.js +10 -0
  77. package/dist/implementation/generation/resource-builders/example-builder.js.map +1 -0
  78. package/dist/implementation/generation/types.d.ts +80 -0
  79. package/dist/implementation/generation/types.js +3 -0
  80. package/dist/implementation/generation/types.js.map +1 -0
  81. package/dist/implementation/generators/aps-generator.d.ts +7 -0
  82. package/dist/implementation/generators/aps-generator.js +11 -0
  83. package/dist/implementation/generators/aps-generator.js.map +1 -0
  84. package/dist/implementation/generators/index.d.ts +4 -0
  85. package/dist/implementation/generators/index.js +15 -0
  86. package/dist/implementation/generators/index.js.map +1 -0
  87. package/dist/implementation/generators/registry.d.ts +8 -0
  88. package/dist/implementation/generators/registry.js +30 -0
  89. package/dist/implementation/generators/registry.js.map +1 -0
  90. package/dist/implementation/generators/types.d.ts +4 -0
  91. package/dist/implementation/generators/types.js +3 -0
  92. package/dist/implementation/generators/types.js.map +1 -0
  93. package/dist/implementation/io/fs.d.ts +6 -0
  94. package/dist/implementation/io/fs.js +47 -0
  95. package/dist/implementation/io/fs.js.map +1 -0
  96. package/dist/implementation/io/json.d.ts +1 -0
  97. package/dist/implementation/io/json.js +7 -0
  98. package/dist/implementation/io/json.js.map +1 -0
  99. package/dist/implementation/query/resource-summary.d.ts +4 -0
  100. package/dist/implementation/query/resource-summary.js +32 -0
  101. package/dist/implementation/query/resource-summary.js.map +1 -0
  102. package/dist/implementation/services/context-service.d.ts +4 -0
  103. package/dist/implementation/services/context-service.js +22 -0
  104. package/dist/implementation/services/context-service.js.map +1 -0
  105. package/dist/implementation/services/discovery-service.d.ts +1 -0
  106. package/dist/implementation/services/discovery-service.js +8 -0
  107. package/dist/implementation/services/discovery-service.js.map +1 -0
  108. package/dist/implementation/services/doctor-service.d.ts +1 -0
  109. package/dist/implementation/services/doctor-service.js +8 -0
  110. package/dist/implementation/services/doctor-service.js.map +1 -0
  111. package/dist/implementation/services/generate-service.d.ts +7 -0
  112. package/dist/implementation/services/generate-service.js +10 -0
  113. package/dist/implementation/services/generate-service.js.map +1 -0
  114. package/dist/implementation/services/governance-service.d.ts +1 -0
  115. package/dist/implementation/services/governance-service.js +28 -0
  116. package/dist/implementation/services/governance-service.js.map +1 -0
  117. package/dist/implementation/services/init-service.d.ts +6 -0
  118. package/dist/implementation/services/init-service.js +49 -0
  119. package/dist/implementation/services/init-service.js.map +1 -0
  120. package/dist/implementation/services/sync-service.d.ts +8 -0
  121. package/dist/implementation/services/sync-service.js +35 -0
  122. package/dist/implementation/services/sync-service.js.map +1 -0
  123. package/dist/implementation/services/validate-service.d.ts +1 -0
  124. package/dist/implementation/services/validate-service.js +8 -0
  125. package/dist/implementation/services/validate-service.js.map +1 -0
  126. package/dist/implementation/synchronization/agents-md.d.ts +2 -0
  127. package/dist/implementation/synchronization/agents-md.js +46 -0
  128. package/dist/implementation/synchronization/agents-md.js.map +1 -0
  129. package/dist/implementation/synchronization/context-generator.d.ts +7 -0
  130. package/dist/implementation/synchronization/context-generator.js +110 -0
  131. package/dist/implementation/synchronization/context-generator.js.map +1 -0
  132. package/dist/implementation/validation-engine/validate-package.d.ts +10 -0
  133. package/dist/implementation/validation-engine/validate-package.js +123 -0
  134. package/dist/implementation/validation-engine/validate-package.js.map +1 -0
  135. package/dist/index.d.ts +15 -0
  136. package/dist/index.js +31 -0
  137. package/dist/index.js.map +1 -0
  138. package/dist/protocol/compatibility/aps-component-schema.d.ts +17 -0
  139. package/dist/protocol/compatibility/aps-component-schema.js +85 -0
  140. package/dist/protocol/compatibility/aps-component-schema.js.map +1 -0
  141. package/dist/protocol/compatibility/aps-example-schema.d.ts +14 -0
  142. package/dist/protocol/compatibility/aps-example-schema.js +63 -0
  143. package/dist/protocol/compatibility/aps-example-schema.js.map +1 -0
  144. package/dist/protocol/compatibility/aps-manifest-schema.d.ts +15 -0
  145. package/dist/protocol/compatibility/aps-manifest-schema.js +115 -0
  146. package/dist/protocol/compatibility/aps-manifest-schema.js.map +1 -0
  147. package/dist/protocol/compatibility/aps-migration-schema.d.ts +14 -0
  148. package/dist/protocol/compatibility/aps-migration-schema.js +65 -0
  149. package/dist/protocol/compatibility/aps-migration-schema.js.map +1 -0
  150. package/dist/protocol/compatibility/aps-pattern-schema.d.ts +15 -0
  151. package/dist/protocol/compatibility/aps-pattern-schema.js +67 -0
  152. package/dist/protocol/compatibility/aps-pattern-schema.js.map +1 -0
  153. package/dist/protocol/compatibility/aps-rule-schema.d.ts +13 -0
  154. package/dist/protocol/compatibility/aps-rule-schema.js +55 -0
  155. package/dist/protocol/compatibility/aps-rule-schema.js.map +1 -0
  156. package/dist/protocol/compatibility/index.d.ts +14 -0
  157. package/dist/protocol/compatibility/index.js +6 -0
  158. package/dist/protocol/compatibility/index.js.map +1 -0
  159. package/dist/protocol/governance/applicability-validator.d.ts +2 -0
  160. package/dist/protocol/governance/applicability-validator.js +108 -0
  161. package/dist/protocol/governance/applicability-validator.js.map +1 -0
  162. package/dist/protocol/governance/conflict-validator.d.ts +2 -0
  163. package/dist/protocol/governance/conflict-validator.js +129 -0
  164. package/dist/protocol/governance/conflict-validator.js.map +1 -0
  165. package/dist/protocol/governance/evidence-validator.d.ts +2 -0
  166. package/dist/protocol/governance/evidence-validator.js +97 -0
  167. package/dist/protocol/governance/evidence-validator.js.map +1 -0
  168. package/dist/protocol/governance/identity-validator.d.ts +2 -0
  169. package/dist/protocol/governance/identity-validator.js +79 -0
  170. package/dist/protocol/governance/identity-validator.js.map +1 -0
  171. package/dist/protocol/governance/index.d.ts +79 -0
  172. package/dist/protocol/governance/index.js +115 -0
  173. package/dist/protocol/governance/index.js.map +1 -0
  174. package/dist/protocol/governance/lifecycle-validator.d.ts +2 -0
  175. package/dist/protocol/governance/lifecycle-validator.js +93 -0
  176. package/dist/protocol/governance/lifecycle-validator.js.map +1 -0
  177. package/dist/protocol/governance/provenance-validator.d.ts +2 -0
  178. package/dist/protocol/governance/provenance-validator.js +170 -0
  179. package/dist/protocol/governance/provenance-validator.js.map +1 -0
  180. package/dist/protocol/manifest/api-resource.d.ts +26 -0
  181. package/dist/protocol/manifest/api-resource.js +3 -0
  182. package/dist/protocol/manifest/api-resource.js.map +1 -0
  183. package/dist/protocol/manifest/common.d.ts +44 -0
  184. package/dist/protocol/manifest/common.js +3 -0
  185. package/dist/protocol/manifest/common.js.map +1 -0
  186. package/dist/protocol/manifest/component-resource.d.ts +48 -0
  187. package/dist/protocol/manifest/component-resource.js +3 -0
  188. package/dist/protocol/manifest/component-resource.js.map +1 -0
  189. package/dist/protocol/manifest/event-resource.d.ts +16 -0
  190. package/dist/protocol/manifest/event-resource.js +3 -0
  191. package/dist/protocol/manifest/event-resource.js.map +1 -0
  192. package/dist/protocol/manifest/example-resource.d.ts +17 -0
  193. package/dist/protocol/manifest/example-resource.js +3 -0
  194. package/dist/protocol/manifest/example-resource.js.map +1 -0
  195. package/dist/protocol/manifest/index.d.ts +13 -0
  196. package/dist/protocol/manifest/index.js +3 -0
  197. package/dist/protocol/manifest/index.js.map +1 -0
  198. package/dist/protocol/manifest/legacy-v1.d.ts +47 -0
  199. package/dist/protocol/manifest/legacy-v1.js +3 -0
  200. package/dist/protocol/manifest/legacy-v1.js.map +1 -0
  201. package/dist/protocol/manifest/manifest.d.ts +28 -0
  202. package/dist/protocol/manifest/manifest.js +3 -0
  203. package/dist/protocol/manifest/manifest.js.map +1 -0
  204. package/dist/protocol/manifest/migration-resource.d.ts +22 -0
  205. package/dist/protocol/manifest/migration-resource.js +3 -0
  206. package/dist/protocol/manifest/migration-resource.js.map +1 -0
  207. package/dist/protocol/manifest/model-resource.d.ts +21 -0
  208. package/dist/protocol/manifest/model-resource.js +3 -0
  209. package/dist/protocol/manifest/model-resource.js.map +1 -0
  210. package/dist/protocol/manifest/pattern-resource.d.ts +14 -0
  211. package/dist/protocol/manifest/pattern-resource.js +3 -0
  212. package/dist/protocol/manifest/pattern-resource.js.map +1 -0
  213. package/dist/protocol/manifest/resource.d.ts +24 -0
  214. package/dist/protocol/manifest/resource.js +3 -0
  215. package/dist/protocol/manifest/resource.js.map +1 -0
  216. package/dist/protocol/manifest/rule-resource.d.ts +27 -0
  217. package/dist/protocol/manifest/rule-resource.js +3 -0
  218. package/dist/protocol/manifest/rule-resource.js.map +1 -0
  219. package/dist/protocol/manifest/service-resource.d.ts +14 -0
  220. package/dist/protocol/manifest/service-resource.js +3 -0
  221. package/dist/protocol/manifest/service-resource.js.map +1 -0
  222. package/dist/shared/json.d.ts +2 -0
  223. package/dist/shared/json.js +14 -0
  224. package/dist/shared/json.js.map +1 -0
  225. package/package.json +46 -0
@@ -0,0 +1,79 @@
1
+ import type { ApsManifest, ApsResourceType } from "../manifest";
2
+ export type KnowledgeSourceType = "typescript" | "storybook" | "readme" | "human" | "static-analysis" | "architecture-policy" | "external";
3
+ export type KnowledgeConfidence = "low" | "medium" | "high";
4
+ export type KnowledgeAuthority = "advisory" | "required" | "policy";
5
+ export type GovernanceApplicability = {
6
+ framework?: string | string[];
7
+ language?: string | string[];
8
+ runtime?: string | string[];
9
+ platform?: string | string[];
10
+ layer?: string | string[];
11
+ boundedContext?: string | string[];
12
+ [key: string]: unknown;
13
+ };
14
+ export type GovernanceEvidence = {
15
+ evidenceId?: string;
16
+ sourceType: KnowledgeSourceType;
17
+ sourceRef: string;
18
+ extractedAt: string;
19
+ confidence: KnowledgeConfidence;
20
+ authority: KnowledgeAuthority;
21
+ scope?: string;
22
+ sourceVersion?: string;
23
+ freshnessTtlDays?: number;
24
+ applicability?: GovernanceApplicability;
25
+ extractor?: string;
26
+ [key: string]: unknown;
27
+ };
28
+ export type GovernanceConflict = {
29
+ id?: string;
30
+ fieldPath?: string;
31
+ candidates?: Array<Record<string, unknown>>;
32
+ selectedCandidateId?: string;
33
+ rejectedCandidateIds?: string[];
34
+ explanation?: string;
35
+ [key: string]: unknown;
36
+ };
37
+ export type GovernanceResource = {
38
+ type?: ApsResourceType | string;
39
+ id?: string;
40
+ name?: string;
41
+ description?: string;
42
+ metadata?: Record<string, unknown>;
43
+ deprecated?: unknown;
44
+ deprecationReason?: unknown;
45
+ replacementResourceIds?: unknown;
46
+ migrationIds?: unknown;
47
+ lifecycleState?: unknown;
48
+ [key: string]: unknown;
49
+ };
50
+ export type GovernanceIssue = {
51
+ code: string;
52
+ path: string;
53
+ message: string;
54
+ };
55
+ export type GovernanceCounters = {
56
+ governedFields: number;
57
+ fieldsWithEvidence: number;
58
+ fieldsWithProvenance: number;
59
+ };
60
+ export type GovernanceValidatorResult = {
61
+ errors: GovernanceIssue[];
62
+ warnings: GovernanceIssue[];
63
+ counters: GovernanceCounters;
64
+ };
65
+ export type GovernanceValidationResult = {
66
+ valid: boolean;
67
+ errors: GovernanceIssue[];
68
+ warnings: GovernanceIssue[];
69
+ metrics: {
70
+ resourcesChecked: number;
71
+ evidenceCoverage: number;
72
+ provenanceCoverage: number;
73
+ };
74
+ };
75
+ export declare function collectGovernanceResources(manifest: ApsManifest): {
76
+ resources: GovernanceResource[];
77
+ warnings: GovernanceIssue[];
78
+ };
79
+ export declare function validateGovernance(manifest: ApsManifest): GovernanceValidationResult;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectGovernanceResources = collectGovernanceResources;
4
+ exports.validateGovernance = validateGovernance;
5
+ const json_1 = require("../../shared/json");
6
+ const applicability_validator_1 = require("./applicability-validator");
7
+ const conflict_validator_1 = require("./conflict-validator");
8
+ const evidence_validator_1 = require("./evidence-validator");
9
+ const identity_validator_1 = require("./identity-validator");
10
+ const lifecycle_validator_1 = require("./lifecycle-validator");
11
+ const provenance_validator_1 = require("./provenance-validator");
12
+ const LEGACY_SECTION_TYPES = [
13
+ { key: "components", type: "component" },
14
+ { key: "apis", type: "api" },
15
+ { key: "services", type: "service" },
16
+ { key: "models", type: "model" },
17
+ { key: "events", type: "event" },
18
+ { key: "patterns", type: "pattern" },
19
+ { key: "rules", type: "rule" },
20
+ { key: "migrations", type: "migration" },
21
+ { key: "examples", type: "example" }
22
+ ];
23
+ function toPercentage(numerator, denominator) {
24
+ if (denominator === 0) {
25
+ return 0;
26
+ }
27
+ return Number(((numerator / denominator) * 100).toFixed(2));
28
+ }
29
+ function normalizeResourceEntry(entry, fallbackType, warnings, path) {
30
+ if (typeof entry === "string") {
31
+ return {
32
+ type: fallbackType,
33
+ name: entry
34
+ };
35
+ }
36
+ if (!(0, json_1.isObject)(entry)) {
37
+ warnings.push({
38
+ code: "APS_GOV_RESOURCE_ENTRY_SKIPPED",
39
+ path,
40
+ message: "Resource entry is not an object or string and was skipped"
41
+ });
42
+ return null;
43
+ }
44
+ return {
45
+ ...entry,
46
+ type: typeof entry.type === "string" ? entry.type : fallbackType
47
+ };
48
+ }
49
+ function collectGovernanceResources(manifest) {
50
+ const resources = [];
51
+ const warnings = [];
52
+ if (Array.isArray(manifest.resources)) {
53
+ for (let index = 0; index < manifest.resources.length; index += 1) {
54
+ const entry = manifest.resources[index];
55
+ if ((0, json_1.isObject)(entry)) {
56
+ resources.push(entry);
57
+ }
58
+ else {
59
+ warnings.push({
60
+ code: "APS_GOV_RESOURCE_ENTRY_SKIPPED",
61
+ path: `manifest.resources[${index}]`,
62
+ message: "resources entry is not an object and was skipped"
63
+ });
64
+ }
65
+ }
66
+ }
67
+ for (const section of LEGACY_SECTION_TYPES) {
68
+ const value = manifest[section.key];
69
+ if (!Array.isArray(value)) {
70
+ continue;
71
+ }
72
+ for (let index = 0; index < value.length; index += 1) {
73
+ const normalized = normalizeResourceEntry(value[index], section.type, warnings, `manifest.${section.key}[${index}]`);
74
+ if (normalized) {
75
+ resources.push(normalized);
76
+ }
77
+ }
78
+ }
79
+ return { resources, warnings };
80
+ }
81
+ function mergeValidatorResults(results) {
82
+ return {
83
+ errors: results.flatMap((result) => result.errors),
84
+ warnings: results.flatMap((result) => result.warnings),
85
+ counters: {
86
+ governedFields: results.reduce((acc, result) => acc + result.counters.governedFields, 0),
87
+ fieldsWithEvidence: results.reduce((acc, result) => acc + result.counters.fieldsWithEvidence, 0),
88
+ fieldsWithProvenance: results.reduce((acc, result) => acc + result.counters.fieldsWithProvenance, 0)
89
+ }
90
+ };
91
+ }
92
+ function validateGovernance(manifest) {
93
+ const collected = collectGovernanceResources(manifest);
94
+ const validators = [
95
+ (0, provenance_validator_1.validateProvenance)(collected.resources),
96
+ (0, evidence_validator_1.validateEvidence)(collected.resources),
97
+ (0, lifecycle_validator_1.validateLifecycle)(collected.resources),
98
+ (0, applicability_validator_1.validateApplicability)(collected.resources),
99
+ (0, identity_validator_1.validateIdentity)(collected.resources, manifest),
100
+ (0, conflict_validator_1.validateConflicts)(collected.resources)
101
+ ];
102
+ const merged = mergeValidatorResults(validators);
103
+ const allWarnings = [...collected.warnings, ...merged.warnings];
104
+ return {
105
+ valid: merged.errors.length === 0,
106
+ errors: merged.errors,
107
+ warnings: allWarnings,
108
+ metrics: {
109
+ resourcesChecked: collected.resources.length,
110
+ evidenceCoverage: toPercentage(merged.counters.fieldsWithEvidence, merged.counters.governedFields),
111
+ provenanceCoverage: toPercentage(merged.counters.fieldsWithProvenance, merged.counters.governedFields)
112
+ }
113
+ };
114
+ }
115
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/protocol/governance/index.ts"],"names":[],"mappings":";;AAoJA,gEA2CC;AAcD,gDA+BC;AA5OD,4CAA6C;AAE7C,uEAAkE;AAClE,6DAAyD;AACzD,6DAAwD;AACxD,6DAAwD;AACxD,+DAA0D;AAC1D,iEAA4D;AA6F5D,MAAM,oBAAoB,GAAkD;IAC1E,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE;IACxC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE;IAC5B,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;IACpC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE;IAChC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE;IAChC,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;IACpC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE;IAC9B,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE;IACxC,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;CACrC,CAAC;AAEF,SAAS,YAAY,CAAC,SAAiB,EAAE,WAAmB;IAC1D,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,CAAC,SAAS,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,sBAAsB,CAC7B,KAAc,EACd,YAA6B,EAC7B,QAA2B,EAC3B,IAAY;IAEZ,IAAI,OAAO,K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ernanceResource[]): GovernanceValidatorResult;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateLifecycle = validateLifecycle;
4
+ const json_1 = require("../../shared/json");
5
+ function hasText(value) {
6
+ return typeof value === "string" && value.trim().length > 0;
7
+ }
8
+ function hasNonEmptyStringArray(value) {
9
+ return Array.isArray(value) && value.some((item) => hasText(item));
10
+ }
11
+ function getDeprecationReason(resource) {
12
+ if (hasText(resource.deprecationReason)) {
13
+ return resource.deprecationReason;
14
+ }
15
+ if ((0, json_1.isObject)(resource.deprecated) && hasText(resource.deprecated.reason)) {
16
+ return resource.deprecated.reason;
17
+ }
18
+ return null;
19
+ }
20
+ function hasReplacementOrMigration(resource) {
21
+ if (hasNonEmptyStringArray(resource.replacementResourceIds)) {
22
+ return true;
23
+ }
24
+ if (hasNonEmptyStringArray(resource.migrationIds)) {
25
+ return true;
26
+ }
27
+ if ((0, json_1.isObject)(resource.deprecated)) {
28
+ if (Array.isArray(resource.deprecated.replacement) && resource.deprecated.replacement.length > 0) {
29
+ return true;
30
+ }
31
+ if (hasNonEmptyStringArray(resource.deprecated.migrationIds)) {
32
+ return true;
33
+ }
34
+ }
35
+ return false;
36
+ }
37
+ function validateLifecycle(resources) {
38
+ const errors = [];
39
+ const warnings = [];
40
+ for (let index = 0; index < resources.length; index += 1) {
41
+ const resource = resources[index];
42
+ const lifecycleState = hasText(resource.lifecycleState)
43
+ ? resource.lifecycleState
44
+ : null;
45
+ const deprecated = resource.deprecated === true || lifecycleState === "deprecated";
46
+ const removed = lifecycleState === "removed";
47
+ if (deprecated) {
48
+ const basePath = `resources[${index}]`;
49
+ const reason = getDeprecationReason(resource);
50
+ if (!reason) {
51
+ errors.push({
52
+ code: "APS_GOV_DEPRECATION_REASON_REQUIRED",
53
+ path: `${basePath}.deprecationReason`,
54
+ message: "Deprecated resources must declare deprecationReason"
55
+ });
56
+ }
57
+ if (!hasReplacementOrMigration(resource)) {
58
+ errors.push({
59
+ code: "APS_GOV_DEPRECATION_SUCCESSOR_REQUIRED",
60
+ path: basePath,
61
+ message: "Deprecated resources must define replacementResourceIds or migrationIds"
62
+ });
63
+ }
64
+ }
65
+ if (removed) {
66
+ const basePath = `resources[${index}]`;
67
+ if (!hasReplacementOrMigration(resource) && !getDeprecationReason(resource)) {
68
+ errors.push({
69
+ code: "APS_GOV_REMOVED_HISTORY_REQUIRED",
70
+ path: basePath,
71
+ message: "Removed resources must preserve historical references (replacement/migration/reason)"
72
+ });
73
+ }
74
+ if (!hasText(resource.id)) {
75
+ warnings.push({
76
+ code: "APS_GOV_REMOVED_ID_RECOMMENDED",
77
+ path: `${basePath}.id`,
78
+ message: "Removed resources should keep stable id for historical traceability"
79
+ });
80
+ }
81
+ }
82
+ }
83
+ return {
84
+ errors,
85
+ warnings,
86
+ counters: {
87
+ governedFields: 0,
88
+ fieldsWithEvidence: 0,
89
+ fieldsWithProvenance: 0
90
+ }
91
+ };
92
+ }
93
+ //# sourceMappingURL=lifecycle-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle-validator.js","sourceRoot":"","sources":["../../../src/protocol/governance/lifecycle-validator.ts"],"names":[],"mappings":";;AA6CA,8CA8DC;AA3GD,4CAA6C;AAG7C,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAc;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,oBAAoB,CAAC,QAA4B;IACxD,IAAI,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACxC,OAAO,QAAQ,CAAC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EAAE,qEAAqE;iBAC/E,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM;QACN,QAAQ;QACR,QAAQ,EAAE;YACR,cAAc,EAAE,CAAC;YACjB,kBAAkB,EAAE,CAAC;YACrB,oBAAoB,EAAE,CAAC;SACxB;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { GovernanceResource, GovernanceValidatorResult } from "./index";
2
+ export declare function validateProvenance(resources: GovernanceResource[]): GovernanceValidatorResult;
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateProvenance = validateProvenance;
4
+ const json_1 = require("../../shared/json");
5
+ const VALID_SOURCE_TYPES = new Set([
6
+ "typescript",
7
+ "storybook",
8
+ "readme",
9
+ "human",
10
+ "static-analysis",
11
+ "architecture-policy",
12
+ "external"
13
+ ]);
14
+ const VALID_CONFIDENCE = new Set(["low", "medium", "high"]);
15
+ const VALID_AUTHORITY = new Set(["advisory", "required", "policy"]);
16
+ function getGovernance(resource) {
17
+ if (!(0, json_1.isObject)(resource.metadata)) {
18
+ return {};
19
+ }
20
+ const governance = resource.metadata.governance;
21
+ return (0, json_1.isObject)(governance) ? governance : {};
22
+ }
23
+ function getGovernedFields(resource) {
24
+ const governance = getGovernance(resource);
25
+ const fields = governance.fields;
26
+ if (!(0, json_1.isObject)(fields)) {
27
+ return [];
28
+ }
29
+ const governedFields = [];
30
+ for (const [fieldName, fieldValue] of Object.entries(fields)) {
31
+ if ((0, json_1.isObject)(fieldValue)) {
32
+ governedFields.push([fieldName, fieldValue]);
33
+ }
34
+ }
35
+ return governedFields;
36
+ }
37
+ function readEvidence(fieldConfig) {
38
+ if (!Array.isArray(fieldConfig.evidence)) {
39
+ return [];
40
+ }
41
+ return fieldConfig.evidence.filter((item) => (0, json_1.isObject)(item));
42
+ }
43
+ function validateEvidenceShape(evidence, path, errors, warnings) {
44
+ let valid = true;
45
+ if (typeof evidence.sourceType !== "string" || !VALID_SOURCE_TYPES.has(evidence.sourceType)) {
46
+ errors.push({
47
+ code: "APS_GOV_INVALID_SOURCE_TYPE",
48
+ path,
49
+ message: "Evidence.sourceType is required and must be a valid source type"
50
+ });
51
+ valid = false;
52
+ }
53
+ if (typeof evidence.sourceRef !== "string" || evidence.sourceRef.trim() === "") {
54
+ errors.push({
55
+ code: "APS_GOV_INVALID_SOURCE_REF",
56
+ path,
57
+ message: "Evidence.sourceRef is required and must be a non-empty string"
58
+ });
59
+ valid = false;
60
+ }
61
+ if (typeof evidence.extractedAt !== "string" || Number.isNaN(Date.parse(evidence.extractedAt))) {
62
+ errors.push({
63
+ code: "APS_GOV_INVALID_EXTRACTED_AT",
64
+ path,
65
+ message: "Evidence.extractedAt is required and must be an ISO date string"
66
+ });
67
+ valid = false;
68
+ }
69
+ if (typeof evidence.confidence !== "string" || !VALID_CONFIDENCE.has(evidence.confidence)) {
70
+ errors.push({
71
+ code: "APS_GOV_INVALID_CONFIDENCE",
72
+ path,
73
+ message: "Evidence.confidence is required and must be low|medium|high"
74
+ });
75
+ valid = false;
76
+ }
77
+ if (typeof evidence.authority !== "string" || !VALID_AUTHORITY.has(evidence.authority)) {
78
+ errors.push({
79
+ code: "APS_GOV_INVALID_AUTHORITY",
80
+ path,
81
+ message: "Evidence.authority is required and must be advisory|required|policy"
82
+ });
83
+ valid = false;
84
+ }
85
+ if (evidence.authority === "policy") {
86
+ if (evidence.sourceType !== "architecture-policy" && evidence.sourceType !== "human") {
87
+ errors.push({
88
+ code: "APS_GOV_POLICY_SOURCE_INVALID",
89
+ path,
90
+ message: "Policy evidence must come from architecture-policy or human sources"
91
+ });
92
+ valid = false;
93
+ }
94
+ if (!(0, json_1.isObject)(evidence.applicability)) {
95
+ errors.push({
96
+ code: "APS_GOV_POLICY_APPLICABILITY_REQUIRED",
97
+ path,
98
+ message: "Policy evidence requires applicability context"
99
+ });
100
+ valid = false;
101
+ }
102
+ }
103
+ if (evidence.authority === "required") {
104
+ if (typeof evidence.scope !== "string" || evidence.scope.trim() === "") {
105
+ errors.push({
106
+ code: "APS_GOV_REQUIRED_SCOPE_MISSING",
107
+ path,
108
+ message: "Required evidence must define scope"
109
+ });
110
+ valid = false;
111
+ }
112
+ }
113
+ if (evidence.authority === "advisory" && evidence.confidence === "low") {
114
+ warnings.push({
115
+ code: "APS_GOV_LOW_CONFIDENCE_ADVISORY",
116
+ path,
117
+ message: "Advisory evidence with low confidence is acceptable but weak"
118
+ });
119
+ }
120
+ return valid;
121
+ }
122
+ function validateProvenance(resources) {
123
+ const errors = [];
124
+ const warnings = [];
125
+ let governedFields = 0;
126
+ let fieldsWithEvidence = 0;
127
+ let fieldsWithProvenance = 0;
128
+ for (let index = 0; index < resources.length; index += 1) {
129
+ const resource = resources[index];
130
+ const fields = getGovernedFields(resource);
131
+ for (const [fieldName, fieldConfig] of fields) {
132
+ governedFields += 1;
133
+ const basePath = `resources[${index}].metadata.governance.fields.${fieldName}`;
134
+ const evidenceList = readEvidence(fieldConfig);
135
+ const fieldAuthority = typeof fieldConfig.authority === "string" ? fieldConfig.authority : "advisory";
136
+ if (evidenceList.length > 0) {
137
+ fieldsWithEvidence += 1;
138
+ }
139
+ if ((fieldAuthority === "policy" || fieldAuthority === "required") && evidenceList.length === 0) {
140
+ errors.push({
141
+ code: "APS_GOV_EVIDENCE_REQUIRED",
142
+ path: basePath,
143
+ message: `Field authority '${fieldAuthority}' requires evidence`
144
+ });
145
+ }
146
+ let hasValidProvenance = false;
147
+ for (let evidenceIndex = 0; evidenceIndex < evidenceList.length; evidenceIndex += 1) {
148
+ const evidence = evidenceList[evidenceIndex];
149
+ const evidencePath = `${basePath}.evidence[${evidenceIndex}]`;
150
+ const valid = validateEvidenceShape(evidence, evidencePath, errors, warnings);
151
+ if (valid) {
152
+ hasValidProvenance = true;
153
+ }
154
+ }
155
+ if (hasValidProvenance) {
156
+ fieldsWithProvenance += 1;
157
+ }
158
+ }
159
+ }
160
+ return {
161
+ errors,
162
+ warnings,
163
+ counters: {
164
+ governedFields,
165
+ fieldsWithEvidence,
166
+ fieldsWithProvenance
167
+ }
168
+ };
169
+ }
170
+ //# sourceMappingURL=provenance-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provenance-validator.js","sourceRoot":"","sources":["../../../src/protocol/governance/provenance-validator.ts"],"names":[],"mappings":";;AA0JA,gDAuDC;AAjND,4CAA6C;AAW7C,MAAM,kBAAkB,GAA6B,IAAI,GAAG,CAAC;IAC3D,YAAY;IACZ,WAAW;IACX,QAAQ;IACR,OAAO;IACP,iBAAiB;IACjB,qBAAqB;IACrB,UAAU;CACX,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAA6B,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AACtF,MAAM,eAAe,GAA4B,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE7F,SAAS,aAAa,CAAC,QAA4B;IACjD,IAAI,CAAC,IAAA,eAAQ,EAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;IAChD,OAAO,IAAA,eAAQ,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,iBAAiB,CAAC,QAA4B;IACrD,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAEjC,IAAI,CAAC,IAAA,eAAQ,EAAC,MAAM,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,cAAc,GAA6C,EAAE,CAAC;IACpE,KAAK,MAAM,CAAC,SAAS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CAAC;IAED,OAAO;QACL,MAAM;QACN,QAAQ;QACR,QAAQ,EAAE;YACR,cAAc;YACd,kBAAkB;YAClB,oBAAoB;SACrB;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { ApsResourceReference, ApsRuleBinding } from "./common";
2
+ import type { ApsResource } from "./resource";
3
+ export interface ApsApiParameter {
4
+ name: string;
5
+ location?: "path" | "query" | "header" | "cookie" | "body" | string;
6
+ type?: string;
7
+ required?: boolean;
8
+ description?: string;
9
+ [key: string]: unknown;
10
+ }
11
+ export interface ApsApiResource extends ApsResource {
12
+ type: "api";
13
+ name: string;
14
+ protocol?: "http" | "grpc" | "graphql" | "websocket" | string;
15
+ method?: string;
16
+ path?: string;
17
+ operationId?: string;
18
+ request?: Record<string, unknown>;
19
+ response?: Record<string, unknown>;
20
+ auth?: Record<string, unknown>;
21
+ parameters?: ApsApiParameter[];
22
+ errors?: Array<Record<string, unknown>>;
23
+ rules?: ApsRuleBinding[];
24
+ examples?: ApsResourceReference[];
25
+ [key: string]: unknown;
26
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=api-resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-resource.js","sourceRoot":"","sources":["../../../src/protocol/manifest/api-resource.ts"],"names":[],"mappings":""}
@@ -0,0 +1,44 @@
1
+ export type ApsStringMap = Record<string, string>;
2
+ export type ApsSeverity = "error" | "warning" | "info" | "hint" | string;
3
+ export type ApsScope = "resource" | "package" | "project" | "workspace" | "global" | string;
4
+ export interface ApsResourceReference {
5
+ id?: string;
6
+ name?: string;
7
+ type?: string;
8
+ package?: string;
9
+ import?: string;
10
+ path?: string;
11
+ [key: string]: unknown;
12
+ }
13
+ export interface ApsVersionConstraint {
14
+ minVersion?: string;
15
+ maxVersion?: string;
16
+ range?: string;
17
+ since?: string;
18
+ until?: string;
19
+ [key: string]: unknown;
20
+ }
21
+ export interface ApsDeprecation {
22
+ deprecated: boolean;
23
+ since?: string;
24
+ replacement?: ApsResourceReference[];
25
+ reason?: string;
26
+ removeIn?: string;
27
+ migrationIds?: string[];
28
+ [key: string]: unknown;
29
+ }
30
+ export interface ApsRuleBinding {
31
+ id?: string;
32
+ name?: string;
33
+ severity?: ApsSeverity;
34
+ [key: string]: unknown;
35
+ }
36
+ export interface ApsInlineExample {
37
+ title?: string;
38
+ description?: string;
39
+ language?: string;
40
+ imports?: string[];
41
+ code?: string;
42
+ explanation?: string;
43
+ [key: string]: unknown;
44
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/protocol/manifest/common.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ import type { ApsDeprecation, ApsInlineExample, ApsResourceReference, ApsRuleBinding, ApsVersionConstraint } from "./common";
2
+ import type { ApsResource } from "./resource";
3
+ export interface ApsComponentProp {
4
+ name: string;
5
+ type?: string;
6
+ required?: boolean;
7
+ default?: unknown;
8
+ description?: string;
9
+ values?: unknown[];
10
+ [key: string]: unknown;
11
+ }
12
+ export interface ApsComponentVariant {
13
+ name: string;
14
+ description?: string;
15
+ conditions?: string[];
16
+ [key: string]: unknown;
17
+ }
18
+ export interface ApsComponentState {
19
+ name: string;
20
+ description?: string;
21
+ transitions?: string[];
22
+ [key: string]: unknown;
23
+ }
24
+ export interface ApsComponentResource extends ApsResource {
25
+ type: "component";
26
+ name: string;
27
+ package?: string;
28
+ import?: string;
29
+ importLocation?: string;
30
+ category?: string;
31
+ intendedUsage?: string | string[];
32
+ whenToUse?: string[];
33
+ whenNotToUse?: string[];
34
+ alternatives?: ApsResourceReference[];
35
+ relatedResources?: ApsResourceReference[];
36
+ props?: ApsComponentProp[];
37
+ variants?: ApsComponentVariant[];
38
+ states?: ApsComponentState[];
39
+ rules?: ApsRuleBinding[];
40
+ examples?: ApsResourceReference[];
41
+ antiExamples?: ApsInlineExample[];
42
+ deprecated?: boolean | ApsDeprecation;
43
+ migrations?: string[];
44
+ versionConstraints?: ApsVersionConstraint;
45
+ aliases?: string[];
46
+ tags?: string[];
47
+ [key: string]: unknown;
48
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=component-resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-resource.js","sourceRoot":"","sources":["../../../src/protocol/manifest/component-resource.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import type { ApsResourceReference, ApsRuleBinding } from "./common";
2
+ import type { ApsResource } from "./resource";
3
+ export interface ApsEventResource extends ApsResource {
4
+ type: "event";
5
+ name: string;
6
+ topic?: string;
7
+ publisher?: string;
8
+ consumers?: string[];
9
+ payloadSchema?: Record<string, unknown>;
10
+ deliverySemantics?: "at-most-once" | "at-least-once" | "exactly-once" | string;
11
+ ordering?: "unordered" | "partitioned" | "global" | string;
12
+ relatedResources?: ApsResourceReference[];
13
+ rules?: ApsRuleBinding[];
14
+ examples?: ApsResourceReference[];
15
+ [key: string]: unknown;
16
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=event-resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-resource.js","sourceRoot":"","sources":["../../../src/protocol/manifest/event-resource.ts"],"names":[],"mappings":""}