@devtrack-solution/codesdd 1.2.3 → 1.2.4

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 (213) hide show
  1. package/.sdd/skills/curated/devtrack-api/SKILL.md +98 -12
  2. package/.sdd/skills/curated/devtrack-api/agents/claude-code.yaml +10 -0
  3. package/.sdd/skills/curated/devtrack-api/agents/codex.yaml +10 -0
  4. package/.sdd/skills/curated/devtrack-api/agents/cursor.yaml +10 -0
  5. package/.sdd/skills/curated/devtrack-api/agents/gemini.yaml +10 -0
  6. package/.sdd/skills/curated/devtrack-api/agents/kimi.yaml +10 -0
  7. package/.sdd/skills/curated/devtrack-api/agents/openai.yaml +5 -3
  8. package/.sdd/skills/curated/devtrack-api/agents/opencode.yaml +12 -0
  9. package/.sdd/skills/curated/devtrack-api/references/application-presentation.md +61 -5
  10. package/.sdd/skills/curated/devtrack-api/references/consumer-sync-policy.md +15 -3
  11. package/.sdd/skills/curated/devtrack-api/references/contract-pack.yaml +1951 -0
  12. package/.sdd/skills/curated/devtrack-api/references/domain-modeling.md +16 -14
  13. package/.sdd/skills/curated/devtrack-api/references/field-validation-protocol.md +40 -0
  14. package/.sdd/skills/curated/devtrack-api/references/foundation-layout.md +19 -2
  15. package/.sdd/skills/curated/devtrack-api/references/generated-artifact-invalidation.md +97 -0
  16. package/.sdd/skills/curated/devtrack-api/references/implementation-checklist.md +30 -1
  17. package/.sdd/skills/curated/devtrack-api/references/portable-agent-contract.md +42 -0
  18. package/.sdd/skills/curated/devtrack-api/references/testing-validation.md +22 -1
  19. package/.sdd/skills/curated/devtrack-api/references/typeorm-infrastructure.md +9 -7
  20. package/README.md +280 -29
  21. package/dist/applications/sdd/index.d.ts +16 -0
  22. package/dist/applications/sdd/index.js +16 -0
  23. package/dist/cli/program.js +180 -11
  24. package/dist/commands/config.js +197 -10
  25. package/dist/commands/sdd/execution.js +408 -16
  26. package/dist/commands/sdd/plugin.js +5 -0
  27. package/dist/commands/sdd/shared.d.ts +1 -0
  28. package/dist/commands/sdd/shared.js +10 -0
  29. package/dist/commands/sdd.js +157 -7
  30. package/dist/core/cli/command-matrix.d.ts +18 -0
  31. package/dist/core/cli/command-matrix.js +157 -0
  32. package/dist/core/cli-command-quality.js +11 -0
  33. package/dist/core/completions/command-registry.js +45 -0
  34. package/dist/core/config-schema.d.ts +31 -1
  35. package/dist/core/config-schema.js +79 -5
  36. package/dist/core/config.d.ts +1 -0
  37. package/dist/core/config.js +11 -0
  38. package/dist/core/global-config.d.ts +29 -0
  39. package/dist/core/init.d.ts +2 -2
  40. package/dist/core/init.js +13 -14
  41. package/dist/core/sdd/agent-binding.d.ts +19 -19
  42. package/dist/core/sdd/agent-runtime-contract.d.ts +204 -0
  43. package/dist/core/sdd/agent-runtime-contract.js +200 -0
  44. package/dist/core/sdd/allocator-recovery.d.ts +14 -0
  45. package/dist/core/sdd/allocator-recovery.js +30 -0
  46. package/dist/core/sdd/allocator-security.d.ts +18 -0
  47. package/dist/core/sdd/allocator-security.js +36 -0
  48. package/dist/core/sdd/api-foundation-baseline.d.ts +111 -0
  49. package/dist/core/sdd/api-foundation-baseline.js +151 -0
  50. package/dist/core/sdd/api-foundation-parity.d.ts +114 -0
  51. package/dist/core/sdd/api-foundation-parity.js +131 -0
  52. package/dist/core/sdd/api-profile-catalog.d.ts +36 -0
  53. package/dist/core/sdd/api-profile-catalog.js +132 -0
  54. package/dist/core/sdd/api-profile-dry-run-projection.d.ts +93 -0
  55. package/dist/core/sdd/api-profile-dry-run-projection.js +370 -0
  56. package/dist/core/sdd/api-profile-recipes.d.ts +82 -0
  57. package/dist/core/sdd/api-profile-recipes.js +484 -0
  58. package/dist/core/sdd/artifact-id-allocator.d.ts +368 -0
  59. package/dist/core/sdd/artifact-id-allocator.js +510 -0
  60. package/dist/core/sdd/check.d.ts +52 -1
  61. package/dist/core/sdd/check.js +326 -11
  62. package/dist/core/sdd/coordination/coordination-adapters.d.ts +15 -8
  63. package/dist/core/sdd/coordination/coordination-adapters.js +43 -15
  64. package/dist/core/sdd/coordination/index.d.ts +1 -0
  65. package/dist/core/sdd/coordination/index.js +1 -0
  66. package/dist/core/sdd/coordination/redis-runtime.d.ts +131 -0
  67. package/dist/core/sdd/coordination/redis-runtime.js +698 -0
  68. package/dist/core/sdd/deepagent-contracts.d.ts +99 -5
  69. package/dist/core/sdd/deepagent-contracts.js +62 -0
  70. package/dist/core/sdd/deepagents/reversa-subagents.d.ts +3 -3
  71. package/dist/core/sdd/default-bootstrap-files.d.ts +2 -2
  72. package/dist/core/sdd/default-bootstrap-files.js +14 -10
  73. package/dist/core/sdd/default-skills.js +115 -9
  74. package/dist/core/sdd/devtrack-api-appliance.d.ts +42 -1
  75. package/dist/core/sdd/devtrack-api-appliance.js +159 -32
  76. package/dist/core/sdd/devtrack-api-architecture.d.ts +16 -0
  77. package/dist/core/sdd/devtrack-api-architecture.js +86 -0
  78. package/dist/core/sdd/docs-sync.js +24 -18
  79. package/dist/core/sdd/domain/capability-diff.d.ts +63 -0
  80. package/dist/core/sdd/domain/capability-diff.js +200 -0
  81. package/dist/core/sdd/domain/change-safety-guardrails.d.ts +74 -0
  82. package/dist/core/sdd/domain/change-safety-guardrails.js +333 -0
  83. package/dist/core/sdd/domain/semantic-intent-classifier.d.ts +29 -0
  84. package/dist/core/sdd/domain/semantic-intent-classifier.js +117 -0
  85. package/dist/core/sdd/enterprise-mutating-command-gate.d.ts +27 -0
  86. package/dist/core/sdd/enterprise-mutating-command-gate.js +104 -0
  87. package/dist/core/sdd/enterprise-provenance-gates.d.ts +20 -0
  88. package/dist/core/sdd/enterprise-provenance-gates.js +63 -0
  89. package/dist/core/sdd/enterprise-provisioning-policy.d.ts +26 -0
  90. package/dist/core/sdd/enterprise-provisioning-policy.js +104 -0
  91. package/dist/core/sdd/foundation-artifact-map-validator.d.ts +16 -0
  92. package/dist/core/sdd/foundation-artifact-map-validator.js +71 -0
  93. package/dist/core/sdd/foundation-layer-manifest.d.ts +24 -0
  94. package/dist/core/sdd/foundation-layer-manifest.js +117 -0
  95. package/dist/core/sdd/governance-schemas.d.ts +2 -2
  96. package/dist/core/sdd/governance-schemas.js +11 -2
  97. package/dist/core/sdd/intent-guard.d.ts +22 -0
  98. package/dist/core/sdd/intent-guard.js +67 -0
  99. package/dist/core/sdd/json-schema.js +13 -1
  100. package/dist/core/sdd/legacy-operations.js +169 -5
  101. package/dist/core/sdd/migrate-workspace.js +39 -0
  102. package/dist/core/sdd/package-security-gates.d.ts +21 -0
  103. package/dist/core/sdd/package-security-gates.js +121 -0
  104. package/dist/core/sdd/package-structure-gate.d.ts +85 -3
  105. package/dist/core/sdd/package-structure-gate.js +384 -11
  106. package/dist/core/sdd/parallel-feat-automation.d.ts +185 -7
  107. package/dist/core/sdd/parallel-feat-automation.js +212 -0
  108. package/dist/core/sdd/plugin-broker.d.ts +223 -4
  109. package/dist/core/sdd/plugin-broker.js +10 -0
  110. package/dist/core/sdd/plugin-cli.d.ts +30 -0
  111. package/dist/core/sdd/plugin-cli.js +70 -3
  112. package/dist/core/sdd/plugin-evidence.d.ts +73 -0
  113. package/dist/core/sdd/plugin-manifest.d.ts +69 -1
  114. package/dist/core/sdd/plugin-manifest.js +10 -0
  115. package/dist/core/sdd/plugin-policy-pack.d.ts +1 -1
  116. package/dist/core/sdd/plugin-policy.js +6 -1
  117. package/dist/core/sdd/plugin-registry.d.ts +138 -2
  118. package/dist/core/sdd/plugin-sdk-contract.d.ts +363 -0
  119. package/dist/core/sdd/plugin-sdk-contract.js +268 -0
  120. package/dist/core/sdd/plugin-skill-binding.d.ts +1 -1
  121. package/dist/core/sdd/quality-validation.d.ts +89 -16
  122. package/dist/core/sdd/release-readiness.d.ts +68 -0
  123. package/dist/core/sdd/release-readiness.js +767 -0
  124. package/dist/core/sdd/reversa-architecture-extractor.d.ts +13 -0
  125. package/dist/core/sdd/reversa-architecture-extractor.js +89 -0
  126. package/dist/core/sdd/reversa-artifact-writer.d.ts +18 -0
  127. package/dist/core/sdd/reversa-artifact-writer.js +40 -0
  128. package/dist/core/sdd/reversa-command-policy.d.ts +136 -0
  129. package/dist/core/sdd/reversa-command-policy.js +361 -0
  130. package/dist/core/sdd/reversa-data-extractor.d.ts +11 -0
  131. package/dist/core/sdd/reversa-data-extractor.js +73 -0
  132. package/dist/core/sdd/reversa-equivalence.d.ts +20 -0
  133. package/dist/core/sdd/reversa-equivalence.js +34 -0
  134. package/dist/core/sdd/reversa-evidence.d.ts +298 -0
  135. package/dist/core/sdd/reversa-evidence.js +118 -0
  136. package/dist/core/sdd/reversa-reconstruction.d.ts +29 -0
  137. package/dist/core/sdd/reversa-reconstruction.js +32 -0
  138. package/dist/core/sdd/reversa-rules-extractor.d.ts +12 -0
  139. package/dist/core/sdd/reversa-rules-extractor.js +86 -0
  140. package/dist/core/sdd/reversa-source-safety.d.ts +19 -0
  141. package/dist/core/sdd/reversa-source-safety.js +105 -0
  142. package/dist/core/sdd/reversa-surface-scout.d.ts +13 -0
  143. package/dist/core/sdd/reversa-surface-scout.js +85 -0
  144. package/dist/core/sdd/reversa-ux-mapper.d.ts +11 -0
  145. package/dist/core/sdd/reversa-ux-mapper.js +73 -0
  146. package/dist/core/sdd/runtime-boundary-contract.d.ts +45 -0
  147. package/dist/core/sdd/runtime-boundary-contract.js +90 -0
  148. package/dist/core/sdd/sdk-agent-plugin-quality-gates.d.ts +150 -0
  149. package/dist/core/sdd/sdk-agent-plugin-quality-gates.js +258 -0
  150. package/dist/core/sdd/services/agent-run.service.d.ts +38 -6
  151. package/dist/core/sdd/services/agent-run.service.js +73 -1
  152. package/dist/core/sdd/services/archive-quality-coherence.service.d.ts +17 -0
  153. package/dist/core/sdd/services/archive-quality-coherence.service.js +141 -0
  154. package/dist/core/sdd/services/capability-diff.service.d.ts +18 -0
  155. package/dist/core/sdd/services/capability-diff.service.js +26 -0
  156. package/dist/core/sdd/services/change-safety-preflight.service.d.ts +17 -0
  157. package/dist/core/sdd/services/change-safety-preflight.service.js +17 -0
  158. package/dist/core/sdd/services/context.service.d.ts +43 -340
  159. package/dist/core/sdd/services/context.service.js +323 -9
  160. package/dist/core/sdd/services/decide.service.js +1 -1
  161. package/dist/core/sdd/services/finalize.service.d.ts +27 -0
  162. package/dist/core/sdd/services/finalize.service.js +226 -18
  163. package/dist/core/sdd/services/frontend-impact.service.d.ts +1 -1
  164. package/dist/core/sdd/services/historical-quality-regression.service.d.ts +35 -0
  165. package/dist/core/sdd/services/historical-quality-regression.service.js +228 -0
  166. package/dist/core/sdd/services/ingest-deposito.service.js +1 -1
  167. package/dist/core/sdd/services/planning-execution-coherence.service.d.ts +45 -0
  168. package/dist/core/sdd/services/planning-execution-coherence.service.js +225 -0
  169. package/dist/core/sdd/services/semantic-intent-classifier.service.d.ts +6 -0
  170. package/dist/core/sdd/services/semantic-intent-classifier.service.js +7 -0
  171. package/dist/core/sdd/state.d.ts +1 -0
  172. package/dist/core/sdd/state.js +266 -34
  173. package/dist/core/sdd/store/sdd-stores.js +2 -2
  174. package/dist/core/sdd/structural-health.d.ts +13 -13
  175. package/dist/core/sdd/types.d.ts +30 -15
  176. package/dist/core/sdd/types.js +4 -0
  177. package/dist/core/sdd/views.js +17 -0
  178. package/dist/core/sdd/workspace-schemas.d.ts +428 -7
  179. package/dist/core/sdd/workspace-schemas.js +223 -70
  180. package/dist/core/shared/skill-generation.d.ts +2 -0
  181. package/dist/core/shared/skill-generation.js +19 -2
  182. package/dist/core/shared/tool-detection.d.ts +19 -0
  183. package/dist/core/shared/tool-detection.js +89 -0
  184. package/dist/domains/sdd/index.d.ts +6 -0
  185. package/dist/domains/sdd/index.js +6 -0
  186. package/dist/infrastructures/sdd/index.d.ts +7 -0
  187. package/dist/infrastructures/sdd/index.js +6 -0
  188. package/dist/presentations/cli/sdd/index.d.ts +3 -0
  189. package/dist/presentations/cli/sdd/index.js +3 -0
  190. package/dist/shared/sdd/index.d.ts +3 -0
  191. package/dist/shared/sdd/index.js +2 -0
  192. package/package.json +14 -10
  193. package/schemas/sdd/2-plan.schema.json +207 -2
  194. package/schemas/sdd/5-quality.schema.json +324 -25
  195. package/schemas/sdd/agent-runtime-command-plan.schema.json +212 -0
  196. package/schemas/sdd/agent-runtime-opencode-run-evidence.schema.json +270 -0
  197. package/schemas/sdd/codesdd-plugin.schema.json +171 -0
  198. package/schemas/sdd/deepagent-run-request.schema.json +316 -0
  199. package/schemas/sdd/parallel-feat-automation-plan.schema.json +89 -0
  200. package/schemas/sdd/parallel-feat-scheduler-request.schema.json +116 -0
  201. package/schemas/sdd/parallel-feat-scheduler-result.schema.json +404 -0
  202. package/schemas/sdd/plugin-artifact-manifest.schema.json +109 -0
  203. package/schemas/sdd/plugin-artifact-map.schema.json +223 -0
  204. package/schemas/sdd/plugin-evidence-manifest.schema.json +109 -0
  205. package/schemas/sdd/plugin-language-runtime.schema.json +103 -0
  206. package/schemas/sdd/plugin-package-governance.schema.json +74 -0
  207. package/schemas/sdd/plugin-registry.schema.json +171 -0
  208. package/schemas/sdd/plugin-runtime-invocation-plan.schema.json +109 -0
  209. package/schemas/sdd/quality-evidence-bundle.schema.json +109 -0
  210. package/schemas/sdd/reversa-evidence-bundle.schema.json +466 -0
  211. package/schemas/sdd/sdk-agent-plugin-quality-gate-input.schema.json +168 -0
  212. package/schemas/sdd/sdk-agent-plugin-quality-gate-report.schema.json +160 -0
  213. package/schemas/sdd/workspace-catalog.schema.json +5298 -1409
@@ -1,22 +1,56 @@
1
+ import { createHash } from 'node:crypto';
1
2
  import { z } from 'zod';
3
+ import { validateFoundationArtifactMapArchitecture } from './foundation-artifact-map-validator.js';
4
+ import { pluginArtifactMapSchema } from './plugin-sdk-contract.js';
2
5
  export const DerivationProfileSchema = z.enum(['prototype', 'foundation-compatible', 'enterprise-strict']);
3
6
  export const PreviewGateStatusSchema = z.enum(['pending', 'approved', 'corrected', 'rejected']);
4
7
  export const PackageStructureNodeKindSchema = z.enum(['dir', 'file']);
8
+ export const PreviewContextPatternSchema = z.enum(['bo-pattern', 'entity-pattern', 'application-only']);
9
+ export const PreviewDiagnosticSeveritySchema = z.enum(['warn', 'block']);
5
10
  export const PackageStructureNodeSchema = z.lazy(() => z.object({
6
11
  name: z.string().min(1),
7
12
  kind: PackageStructureNodeKindSchema,
8
13
  description: z.string().optional(),
9
14
  children: z.array(PackageStructureNodeSchema).optional(),
10
15
  }));
16
+ export const ApplicationOnlyContextSchema = z.object({
17
+ context: z.string().min(1),
18
+ path: z.string().min(1),
19
+ reason: z.string().min(1),
20
+ adr_required: z.boolean().default(true),
21
+ contract_rule_ref: z.literal('DTAPI-P1-APPONLY-001'),
22
+ });
23
+ export const PreviewContextClassificationSchema = z.object({
24
+ context: z.string().min(1),
25
+ pattern: PreviewContextPatternSchema,
26
+ source_paths: z.array(z.string().min(1)).default([]),
27
+ decision_refs: z.array(z.string().min(1)).default([]),
28
+ });
29
+ export const PreviewDiagnosticSchema = z.object({
30
+ code: z.string().min(1),
31
+ severity: PreviewDiagnosticSeveritySchema,
32
+ message: z.string().min(1),
33
+ remediation: z.string().min(1),
34
+ path: z.string().min(1).optional(),
35
+ });
11
36
  export const PackageStructurePreviewSchema = z.object({
12
37
  schema_version: z.literal(1),
13
38
  generated_at: z.string(),
14
39
  project_name: z.string().min(1),
15
40
  profile: DerivationProfileSchema,
41
+ source: z.enum(['template', 'artifact-map']).default('template'),
16
42
  contexts: z.array(z.string()),
17
43
  subsystems: z.array(z.string()),
18
44
  transports: z.array(z.string()),
19
45
  tree: PackageStructureNodeSchema,
46
+ foundation_tests_projection: PackageStructureNodeSchema.optional(),
47
+ runtime_scripts_projection: PackageStructureNodeSchema.optional(),
48
+ application_only_contexts: z.array(ApplicationOnlyContextSchema).default([]),
49
+ context_classification: z.array(PreviewContextClassificationSchema).default([]),
50
+ contract_pack_refs: z.array(z.string().min(1)).default([]),
51
+ diagnostics: z.array(PreviewDiagnosticSchema).default([]),
52
+ artifact_languages: z.array(z.string().min(1)).default([]),
53
+ material_signature: z.string().min(1),
20
54
  });
21
55
  export const HumanValidationGateSchema = z.object({
22
56
  gate_id: z.string(),
@@ -27,22 +61,59 @@ export const HumanValidationGateSchema = z.object({
27
61
  approved_by: z.string().optional(),
28
62
  correction_notes: z.string().optional(),
29
63
  exception_refs: z.array(z.string()).default([]),
64
+ contract_pack_refs: z.array(z.string().min(1)).default([]),
65
+ material_signature: z.string().min(1),
66
+ serialized_at: z.string(),
30
67
  });
68
+ const DEFAULT_CONTRACT_PACK_REFS = [
69
+ 'DTAPI-P0-FOUNDATION-001',
70
+ 'DTAPI-P0-PREVIEW-001',
71
+ 'DTAPI-P0-PATH-001',
72
+ 'DTAPI-P0-RUNTIME-SCRIPTS-001',
73
+ 'DTAPI-P1-APPONLY-001',
74
+ ];
75
+ const FOUNDATION_TESTS_ROOT = 'tests/';
76
+ const SUPPORTED_PREVIEW_LANGUAGES = new Set(['typescript', 'javascript']);
77
+ const APPLICATION_ONLY_CONTEXT_REASONS = {
78
+ 'aws-integrations': 'Orchestrates AWS adapter wiring across infrastructure subsystems; invariants stay in infrastructure adapters.',
79
+ foundation: 'Composition root for Foundation-wide use-cases shared by other contexts and does not introduce a bounded domain vocabulary.',
80
+ };
31
81
  export function generatePackageStructurePreview(input) {
82
+ if (input.artifact_map) {
83
+ return generateArtifactMapPackageStructurePreview(input);
84
+ }
32
85
  const profile = input.profile ?? 'foundation-compatible';
33
86
  const contexts = input.contexts ?? ['auth'];
34
87
  const subsystems = input.subsystems ?? ['orm', 'cache', 'configuration'];
35
88
  const transports = input.transports ?? ['rest', 'graphql', 'cli'];
36
89
  const generatedAt = input.generated_at ?? new Date().toISOString();
37
- return {
90
+ const preview = {
38
91
  schema_version: 1,
39
92
  generated_at: generatedAt,
40
93
  project_name: input.project_name,
41
94
  profile,
95
+ source: 'template',
42
96
  contexts,
43
97
  subsystems,
44
98
  transports,
45
99
  tree: buildProjectTree(profile, contexts, subsystems, transports),
100
+ foundation_tests_projection: buildTemplateTestsProjection(),
101
+ runtime_scripts_projection: buildRuntimeScriptsProjection(),
102
+ application_only_contexts: [],
103
+ context_classification: contexts.map((context) => ({
104
+ context,
105
+ pattern: 'bo-pattern',
106
+ source_paths: [`src/domain/${context}/`, `src/application/business/${context}/`],
107
+ decision_refs: [],
108
+ })),
109
+ contract_pack_refs: [...DEFAULT_CONTRACT_PACK_REFS],
110
+ diagnostics: [],
111
+ artifact_languages: ['typescript'],
112
+ material_signature: '',
113
+ };
114
+ return {
115
+ ...preview,
116
+ material_signature: computePreviewSignature(preview),
46
117
  };
47
118
  }
48
119
  export function formatPreviewAsTree(node, prefix = '') {
@@ -58,13 +129,24 @@ export function formatPreviewAsTree(node, prefix = '') {
58
129
  }
59
130
  return lines.join('\n');
60
131
  }
61
- export function buildHumanValidationGate(preview) {
132
+ export function buildHumanValidationGate(preview, options) {
133
+ const exceptionRefs = [...new Set(options?.exception_refs ?? [])];
134
+ const materialSignature = computeGateSignature(preview, exceptionRefs);
135
+ const previousGate = options?.previous_gate;
136
+ const preserveStatus = previousGate?.material_signature === materialSignature;
137
+ const serializedAt = new Date().toISOString();
62
138
  return {
63
139
  gate_id: `GATE-PKG-${preview.project_name.replace(/[^a-zA-Z0-9-]/g, '-')}`,
64
140
  rule_ref: 'DTAPI-P0-PREVIEW-001',
65
- status: 'pending',
141
+ status: preserveStatus ? previousGate.status : 'pending',
66
142
  preview_ref: `devtrack-api-package-preview-${preview.project_name}`,
67
- exception_refs: [],
143
+ approved_at: preserveStatus ? previousGate?.approved_at : undefined,
144
+ approved_by: preserveStatus ? previousGate?.approved_by : undefined,
145
+ correction_notes: preserveStatus ? previousGate?.correction_notes : undefined,
146
+ exception_refs: exceptionRefs,
147
+ contract_pack_refs: preview.contract_pack_refs,
148
+ material_signature: materialSignature,
149
+ serialized_at: serializedAt,
68
150
  };
69
151
  }
70
152
  export function generateDevtrackApiDebGate(input) {
@@ -73,12 +155,18 @@ export function generateDevtrackApiDebGate(input) {
73
155
  return {
74
156
  selected_profile: input.profile ?? 'foundation-compatible',
75
157
  package_preview: preview,
76
- human_validation_gate: gate,
158
+ human_validation_gate: buildHumanValidationGate(preview, {
159
+ previous_gate: input.previous_human_validation_gate,
160
+ exception_refs: gate.exception_refs,
161
+ }),
77
162
  exception_list: [],
78
163
  policy_pool_seed: [
164
+ 'DTAPI-P0-FOUNDATION-001: Foundation evidence wins over generated assumptions',
79
165
  'DTAPI-P0-PROFILE-001: derivation profile must be explicit',
80
166
  'DTAPI-P0-PREVIEW-001: early planning must include package structure preview',
81
167
  'DTAPI-P0-PATH-001: proposed paths must match canonical Foundation paths',
168
+ 'DTAPI-P0-RUNTIME-SCRIPTS-001: Foundation-linked projects require cleanup and port-safe npm/pnpm runtime scripts',
169
+ 'DTAPI-P1-APPONLY-001: application-only contexts require ADR justification',
82
170
  ],
83
171
  };
84
172
  }
@@ -243,7 +331,12 @@ function buildOrmSubsystem(contexts) {
243
331
  children: [
244
332
  { name: 'typeorm.config.ts', kind: 'file', description: 'TypeORM root configuration' },
245
333
  { name: 'typeorm-cli.datasource.ts', kind: 'file', description: 'TypeORM CLI datasource' },
246
- { name: 'typeorm.module.ts', kind: 'file', description: 'Root TypeORM module' },
334
+ { name: 'typeorm.module.ts', kind: 'file', description: 'TypeORM root module with forRootAsync and base forFeature entities' },
335
+ ...contexts.map((context) => ({
336
+ name: `${context}-orm.module.ts`,
337
+ kind: 'file',
338
+ description: `${context} ORM module exporting repository port providers`,
339
+ })),
247
340
  {
248
341
  name: 'entities/',
249
342
  kind: 'dir',
@@ -264,11 +357,6 @@ function buildOrmSubsystem(contexts) {
264
357
  kind: 'dir',
265
358
  children: [{ name: '<timestamp>-<action>.migration.ts', kind: 'file', description: 'Database migration' }],
266
359
  },
267
- ...contexts.map((context) => ({
268
- name: `${context}-orm.module.ts`,
269
- kind: 'file',
270
- description: `${context} TypeORM module`,
271
- })),
272
360
  ],
273
361
  };
274
362
  }
@@ -359,4 +447,289 @@ function buildSharedLayer() {
359
447
  ],
360
448
  };
361
449
  }
450
+ function generateArtifactMapPackageStructurePreview(input) {
451
+ const generatedAt = input.generated_at ?? new Date().toISOString();
452
+ const profile = input.profile ?? 'foundation-compatible';
453
+ const parsed = pluginArtifactMapSchema.safeParse(input.artifact_map);
454
+ const contractPackRefs = [...new Set(input.contract_pack_refs ?? DEFAULT_CONTRACT_PACK_REFS)];
455
+ if (!parsed.success) {
456
+ const fallbackPreview = {
457
+ schema_version: 1,
458
+ generated_at: generatedAt,
459
+ project_name: input.project_name,
460
+ profile,
461
+ source: 'artifact-map',
462
+ contexts: input.contexts ?? [],
463
+ subsystems: input.subsystems ?? [],
464
+ transports: input.transports ?? [],
465
+ tree: { name: 'src/', kind: 'dir', children: [] },
466
+ foundation_tests_projection: { name: FOUNDATION_TESTS_ROOT, kind: 'dir', children: [] },
467
+ runtime_scripts_projection: buildRuntimeScriptsProjection([]),
468
+ application_only_contexts: [],
469
+ context_classification: [],
470
+ contract_pack_refs: contractPackRefs,
471
+ diagnostics: parsed.error.issues.map((issue) => ({
472
+ code: 'DTAPI_PREVIEW_ARTIFACT_MAP_INVALID',
473
+ severity: 'block',
474
+ message: issue.message,
475
+ remediation: 'Validate the artifact map with the CodeSDD plugin SDK before generating the Foundation-compatible preview.',
476
+ path: issue.path.join('.') || undefined,
477
+ })),
478
+ artifact_languages: [],
479
+ material_signature: '',
480
+ };
481
+ return {
482
+ ...fallbackPreview,
483
+ material_signature: computePreviewSignature(fallbackPreview),
484
+ };
485
+ }
486
+ const artifactMap = parsed.data;
487
+ const srcEntries = artifactMap.artifacts.filter((entry) => entry.path.startsWith('src/'));
488
+ const testEntries = artifactMap.artifacts.filter((entry) => entry.path.startsWith(FOUNDATION_TESTS_ROOT));
489
+ const runtimeEntries = artifactMap.artifacts.filter(isRuntimeScriptArtifact);
490
+ const domainContexts = collectDomainContexts(artifactMap.artifacts);
491
+ const applicationContexts = collectApplicationContexts(artifactMap.artifacts);
492
+ const applicationOnlyContexts = buildApplicationOnlyContexts(applicationContexts, domainContexts);
493
+ const contextClassification = buildContextClassification(artifactMap.artifacts, domainContexts, applicationOnlyContexts);
494
+ const diagnostics = [
495
+ ...validateFoundationArtifactMapArchitecture(artifactMap).findings.map(mapFoundationFindingToPreviewDiagnostic),
496
+ ...buildLanguageDiagnostics(artifactMap.artifacts),
497
+ ...(testEntries.length === 0
498
+ ? [
499
+ {
500
+ code: 'DTAPI_PREVIEW_TESTS_MISSING',
501
+ severity: 'warn',
502
+ message: 'Artifact map does not project any Foundation-compatible tests/ artifacts.',
503
+ remediation: 'Project at least the canonical tests/ smoke artifacts before human preview approval.',
504
+ },
505
+ ]
506
+ : []),
507
+ ];
508
+ const preview = {
509
+ schema_version: 1,
510
+ generated_at: generatedAt,
511
+ project_name: input.project_name,
512
+ profile,
513
+ source: 'artifact-map',
514
+ contexts: [...domainContexts],
515
+ subsystems: collectSubsystems(artifactMap.artifacts),
516
+ transports: collectTransports(artifactMap.artifacts),
517
+ tree: buildTreeFromArtifacts(srcEntries, 'src/'),
518
+ foundation_tests_projection: buildTreeFromArtifacts(testEntries, FOUNDATION_TESTS_ROOT),
519
+ runtime_scripts_projection: buildRuntimeScriptsProjection(runtimeEntries),
520
+ application_only_contexts: applicationOnlyContexts,
521
+ context_classification: contextClassification,
522
+ contract_pack_refs: contractPackRefs,
523
+ diagnostics,
524
+ artifact_languages: collectArtifactLanguages(artifactMap.artifacts),
525
+ material_signature: '',
526
+ };
527
+ return {
528
+ ...preview,
529
+ material_signature: computePreviewSignature(preview),
530
+ };
531
+ }
532
+ function buildTemplateTestsProjection() {
533
+ return {
534
+ name: FOUNDATION_TESTS_ROOT,
535
+ kind: 'dir',
536
+ description: 'Foundation-compatible tests projection',
537
+ children: [
538
+ { name: 'app.e2e-spec.ts', kind: 'file', description: 'Initial E2E smoke test' },
539
+ { name: 'jest-e2e.json', kind: 'file', description: 'Jest E2E configuration' },
540
+ ],
541
+ };
542
+ }
543
+ function buildRuntimeScriptsProjection(entries) {
544
+ if (entries !== undefined) {
545
+ return buildTreeFromArtifacts(entries, 'project-root/');
546
+ }
547
+ return {
548
+ name: 'project-root/',
549
+ kind: 'dir',
550
+ description: 'Mandatory npm/pnpm-compatible runtime script projection',
551
+ children: [
552
+ { name: 'package.json', kind: 'file', description: 'Package scripts with cleanup, cleanup:install, start, start:dev, and npm-run internal composition' },
553
+ {
554
+ name: 'scripts/',
555
+ kind: 'dir',
556
+ children: [
557
+ { name: 'cleanup.sh', kind: 'file', description: 'Destructive cleanup for dependencies, build outputs, caches, lockfiles, and compilation residue' },
558
+ { name: 'kill-port.js', kind: 'file', description: 'Port preflight used by start and start:dev before Nest bootstrap' },
559
+ ],
560
+ },
561
+ ],
562
+ };
563
+ }
564
+ function buildTreeFromArtifacts(entries, rootName) {
565
+ const root = { name: rootName, kind: 'dir', children: [] };
566
+ const rootSegments = rootName.replace(/\/$/u, '').split('/');
567
+ for (const entry of [...entries].sort((left, right) => left.path.localeCompare(right.path))) {
568
+ const segments = entry.path.split('/');
569
+ const relativeSegments = rootSegments.every((segment, index) => segments[index] === segment)
570
+ ? segments.slice(rootSegments.length)
571
+ : segments;
572
+ insertArtifactPath(root, relativeSegments, entry.reason);
573
+ }
574
+ return root;
575
+ }
576
+ function isRuntimeScriptArtifact(entry) {
577
+ return entry.path === 'package.json' || entry.path === 'scripts/cleanup.sh' || entry.path === 'scripts/kill-port.js';
578
+ }
579
+ function insertArtifactPath(root, segments, description) {
580
+ if (segments.length === 0)
581
+ return;
582
+ if (!root.children)
583
+ root.children = [];
584
+ const [current, ...rest] = segments;
585
+ const isLeaf = rest.length === 0;
586
+ const nodeName = isLeaf ? current : `${current}/`;
587
+ let node = root.children.find((child) => child.name === nodeName);
588
+ if (!node) {
589
+ node = {
590
+ name: nodeName,
591
+ kind: isLeaf ? 'file' : 'dir',
592
+ description: isLeaf ? description : undefined,
593
+ children: isLeaf ? undefined : [],
594
+ };
595
+ root.children.push(node);
596
+ }
597
+ else if (isLeaf && !node.description) {
598
+ node.description = description;
599
+ }
600
+ if (!isLeaf) {
601
+ insertArtifactPath(node, rest, description);
602
+ }
603
+ }
604
+ function collectDomainContexts(entries) {
605
+ const contexts = new Set();
606
+ for (const entry of entries) {
607
+ const match = /^src\/domain\/([^/]+)\//u.exec(entry.path);
608
+ if (match)
609
+ contexts.add(match[1]);
610
+ }
611
+ return contexts;
612
+ }
613
+ function collectApplicationContexts(entries) {
614
+ const contexts = new Set();
615
+ for (const entry of entries) {
616
+ const match = /^src\/application\/business\/([^/]+)\//u.exec(entry.path);
617
+ if (match)
618
+ contexts.add(match[1]);
619
+ }
620
+ return contexts;
621
+ }
622
+ function buildApplicationOnlyContexts(applicationContexts, domainContexts) {
623
+ return [...applicationContexts]
624
+ .filter((context) => !domainContexts.has(context))
625
+ .sort()
626
+ .map((context) => ({
627
+ context,
628
+ path: `src/application/business/${context}/`,
629
+ reason: APPLICATION_ONLY_CONTEXT_REASONS[context] ??
630
+ 'Application-only orchestration context without a domain counterpart; requires ADR justification before approval.',
631
+ adr_required: true,
632
+ contract_rule_ref: 'DTAPI-P1-APPONLY-001',
633
+ }));
634
+ }
635
+ function buildContextClassification(entries, domainContexts, applicationOnlyContexts) {
636
+ const grouped = new Map();
637
+ for (const entry of entries) {
638
+ const match = /^src\/domain\/([^/]+)\//u.exec(entry.path);
639
+ if (!match)
640
+ continue;
641
+ const context = match[1];
642
+ grouped.set(context, [...(grouped.get(context) ?? []), entry]);
643
+ }
644
+ const classifications = [...domainContexts].sort().map((context) => {
645
+ const contextEntries = grouped.get(context) ?? [];
646
+ const pattern = contextEntries.some((entry) => entry.role === 'entity')
647
+ ? 'entity-pattern'
648
+ : 'bo-pattern';
649
+ return {
650
+ context,
651
+ pattern,
652
+ source_paths: [...new Set(contextEntries.map((entry) => entry.path))],
653
+ decision_refs: [...new Set(contextEntries.flatMap((entry) => entry.decision_refs))],
654
+ };
655
+ });
656
+ return [
657
+ ...classifications,
658
+ ...applicationOnlyContexts.map((item) => ({
659
+ context: item.context,
660
+ pattern: 'application-only',
661
+ source_paths: [item.path],
662
+ decision_refs: [],
663
+ })),
664
+ ];
665
+ }
666
+ function collectSubsystems(entries) {
667
+ return [
668
+ ...new Set(entries
669
+ .map((entry) => /^src\/infrastructure\/adapters\/([^/]+)\//u.exec(entry.path)?.[1])
670
+ .filter((value) => Boolean(value))),
671
+ ];
672
+ }
673
+ function collectTransports(entries) {
674
+ return [
675
+ ...new Set(entries
676
+ .map((entry) => /^src\/presentation\/([^/]+)\//u.exec(entry.path)?.[1])
677
+ .filter((value) => Boolean(value))),
678
+ ];
679
+ }
680
+ function collectArtifactLanguages(entries) {
681
+ return [
682
+ ...new Set(entries.map((entry) => entry.language).filter((value) => value !== undefined)),
683
+ ];
684
+ }
685
+ function buildLanguageDiagnostics(entries) {
686
+ return entries
687
+ .filter((entry) => Boolean(entry.language) && !SUPPORTED_PREVIEW_LANGUAGES.has(entry.language))
688
+ .map((entry) => ({
689
+ code: 'DTAPI_PREVIEW_LANGUAGE_INVALID',
690
+ severity: 'block',
691
+ message: `Artifact "${entry.path}" declares unsupported preview language "${entry.language}".`,
692
+ remediation: 'Use TypeScript or JavaScript for Foundation-compatible devtrack-api preview artifacts, or document a governed exception.',
693
+ path: entry.path,
694
+ }));
695
+ }
696
+ function mapFoundationFindingToPreviewDiagnostic(finding) {
697
+ return {
698
+ code: finding.code,
699
+ severity: finding.severity === 'warn' ? 'warn' : 'block',
700
+ message: finding.message,
701
+ remediation: finding.remediation,
702
+ path: finding.path,
703
+ };
704
+ }
705
+ function computePreviewSignature(preview) {
706
+ return createHash('sha256')
707
+ .update(JSON.stringify({
708
+ project_name: preview.project_name,
709
+ profile: preview.profile,
710
+ source: preview.source,
711
+ contexts: preview.contexts,
712
+ subsystems: preview.subsystems,
713
+ transports: preview.transports,
714
+ tree: preview.tree,
715
+ foundation_tests_projection: preview.foundation_tests_projection,
716
+ runtime_scripts_projection: preview.runtime_scripts_projection,
717
+ application_only_contexts: preview.application_only_contexts,
718
+ context_classification: preview.context_classification,
719
+ contract_pack_refs: preview.contract_pack_refs,
720
+ diagnostics: preview.diagnostics.map((item) => ({ code: item.code, path: item.path, severity: item.severity })),
721
+ artifact_languages: preview.artifact_languages,
722
+ }))
723
+ .digest('hex');
724
+ }
725
+ function computeGateSignature(preview, exceptionRefs) {
726
+ return createHash('sha256')
727
+ .update(JSON.stringify({
728
+ preview_signature: preview.material_signature,
729
+ profile: preview.profile,
730
+ contract_pack_refs: preview.contract_pack_refs,
731
+ exception_refs: [...exceptionRefs].sort(),
732
+ }))
733
+ .digest('hex');
734
+ }
362
735
  //# sourceMappingURL=package-structure-gate.js.map