@devtrack-solution/codesdd 1.2.4-rc3 → 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 (128) hide show
  1. package/.sdd/skills/curated/devtrack-api/SKILL.md +91 -12
  2. package/.sdd/skills/curated/devtrack-api/agents/claude-code.yaml +2 -0
  3. package/.sdd/skills/curated/devtrack-api/agents/codex.yaml +2 -0
  4. package/.sdd/skills/curated/devtrack-api/agents/cursor.yaml +2 -0
  5. package/.sdd/skills/curated/devtrack-api/agents/gemini.yaml +2 -0
  6. package/.sdd/skills/curated/devtrack-api/agents/kimi.yaml +2 -0
  7. package/.sdd/skills/curated/devtrack-api/agents/openai.yaml +3 -3
  8. package/.sdd/skills/curated/devtrack-api/agents/opencode.yaml +2 -0
  9. package/.sdd/skills/curated/devtrack-api/references/application-presentation.md +59 -3
  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 +1898 -2
  12. package/.sdd/skills/curated/devtrack-api/references/domain-modeling.md +3 -1
  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 +20 -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 +4 -3
  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 -5
  20. package/README.md +122 -25
  21. package/dist/cli/program.js +180 -11
  22. package/dist/commands/config.js +27 -1
  23. package/dist/commands/sdd/execution.js +64 -2
  24. package/dist/commands/sdd.js +119 -4
  25. package/dist/core/cli/command-matrix.d.ts +18 -0
  26. package/dist/core/cli/command-matrix.js +148 -0
  27. package/dist/core/cli-command-quality.js +2 -0
  28. package/dist/core/config-schema.d.ts +14 -1
  29. package/dist/core/config-schema.js +32 -1
  30. package/dist/core/config.d.ts +1 -0
  31. package/dist/core/config.js +11 -0
  32. package/dist/core/global-config.d.ts +13 -0
  33. package/dist/core/init.d.ts +2 -2
  34. package/dist/core/init.js +13 -14
  35. package/dist/core/sdd/agent-binding.d.ts +9 -9
  36. package/dist/core/sdd/agent-runtime-contract.d.ts +4 -4
  37. package/dist/core/sdd/allocator-recovery.d.ts +14 -0
  38. package/dist/core/sdd/allocator-recovery.js +30 -0
  39. package/dist/core/sdd/allocator-security.d.ts +18 -0
  40. package/dist/core/sdd/allocator-security.js +36 -0
  41. package/dist/core/sdd/api-foundation-baseline.d.ts +111 -0
  42. package/dist/core/sdd/api-foundation-baseline.js +151 -0
  43. package/dist/core/sdd/api-foundation-parity.d.ts +114 -0
  44. package/dist/core/sdd/api-foundation-parity.js +131 -0
  45. package/dist/core/sdd/api-profile-catalog.d.ts +36 -0
  46. package/dist/core/sdd/api-profile-catalog.js +132 -0
  47. package/dist/core/sdd/api-profile-dry-run-projection.d.ts +93 -0
  48. package/dist/core/sdd/api-profile-dry-run-projection.js +370 -0
  49. package/dist/core/sdd/api-profile-recipes.d.ts +82 -0
  50. package/dist/core/sdd/api-profile-recipes.js +484 -0
  51. package/dist/core/sdd/artifact-id-allocator.d.ts +368 -0
  52. package/dist/core/sdd/artifact-id-allocator.js +510 -0
  53. package/dist/core/sdd/check.d.ts +50 -1
  54. package/dist/core/sdd/check.js +286 -9
  55. package/dist/core/sdd/deepagent-contracts.d.ts +4 -4
  56. package/dist/core/sdd/deepagents/reversa-subagents.d.ts +3 -3
  57. package/dist/core/sdd/default-bootstrap-files.d.ts +1 -1
  58. package/dist/core/sdd/default-bootstrap-files.js +0 -2
  59. package/dist/core/sdd/default-skills.js +7 -5
  60. package/dist/core/sdd/devtrack-api-appliance.d.ts +34 -0
  61. package/dist/core/sdd/devtrack-api-appliance.js +138 -34
  62. package/dist/core/sdd/devtrack-api-architecture.d.ts +16 -0
  63. package/dist/core/sdd/devtrack-api-architecture.js +86 -0
  64. package/dist/core/sdd/docs-sync.js +3 -3
  65. package/dist/core/sdd/enterprise-mutating-command-gate.d.ts +27 -0
  66. package/dist/core/sdd/enterprise-mutating-command-gate.js +104 -0
  67. package/dist/core/sdd/enterprise-provenance-gates.d.ts +20 -0
  68. package/dist/core/sdd/enterprise-provenance-gates.js +63 -0
  69. package/dist/core/sdd/enterprise-provisioning-policy.d.ts +26 -0
  70. package/dist/core/sdd/enterprise-provisioning-policy.js +104 -0
  71. package/dist/core/sdd/governance-schemas.d.ts +2 -2
  72. package/dist/core/sdd/governance-schemas.js +11 -2
  73. package/dist/core/sdd/json-schema.js +4 -0
  74. package/dist/core/sdd/legacy-operations.js +93 -4
  75. package/dist/core/sdd/package-security-gates.js +2 -0
  76. package/dist/core/sdd/package-structure-gate.d.ts +85 -3
  77. package/dist/core/sdd/package-structure-gate.js +386 -8
  78. package/dist/core/sdd/parallel-feat-automation.d.ts +6 -6
  79. package/dist/core/sdd/plugin-policy.js +6 -1
  80. package/dist/core/sdd/plugin-registry.d.ts +3 -3
  81. package/dist/core/sdd/quality-validation.d.ts +5 -5
  82. package/dist/core/sdd/release-readiness.d.ts +49 -0
  83. package/dist/core/sdd/release-readiness.js +303 -8
  84. package/dist/core/sdd/reversa-architecture-extractor.d.ts +13 -0
  85. package/dist/core/sdd/reversa-architecture-extractor.js +89 -0
  86. package/dist/core/sdd/reversa-artifact-writer.d.ts +18 -0
  87. package/dist/core/sdd/reversa-artifact-writer.js +40 -0
  88. package/dist/core/sdd/reversa-command-policy.d.ts +136 -0
  89. package/dist/core/sdd/reversa-command-policy.js +361 -0
  90. package/dist/core/sdd/reversa-data-extractor.d.ts +11 -0
  91. package/dist/core/sdd/reversa-data-extractor.js +73 -0
  92. package/dist/core/sdd/reversa-equivalence.d.ts +20 -0
  93. package/dist/core/sdd/reversa-equivalence.js +34 -0
  94. package/dist/core/sdd/reversa-evidence.d.ts +298 -0
  95. package/dist/core/sdd/reversa-evidence.js +118 -0
  96. package/dist/core/sdd/reversa-reconstruction.d.ts +29 -0
  97. package/dist/core/sdd/reversa-reconstruction.js +32 -0
  98. package/dist/core/sdd/reversa-rules-extractor.d.ts +12 -0
  99. package/dist/core/sdd/reversa-rules-extractor.js +86 -0
  100. package/dist/core/sdd/reversa-source-safety.d.ts +19 -0
  101. package/dist/core/sdd/reversa-source-safety.js +105 -0
  102. package/dist/core/sdd/reversa-surface-scout.d.ts +13 -0
  103. package/dist/core/sdd/reversa-surface-scout.js +85 -0
  104. package/dist/core/sdd/reversa-ux-mapper.d.ts +11 -0
  105. package/dist/core/sdd/reversa-ux-mapper.js +73 -0
  106. package/dist/core/sdd/sdk-agent-plugin-quality-gates.d.ts +1 -1
  107. package/dist/core/sdd/services/archive-quality-coherence.service.d.ts +17 -0
  108. package/dist/core/sdd/services/archive-quality-coherence.service.js +141 -0
  109. package/dist/core/sdd/services/decide.service.js +1 -1
  110. package/dist/core/sdd/services/finalize.service.d.ts +2 -0
  111. package/dist/core/sdd/services/finalize.service.js +48 -2
  112. package/dist/core/sdd/services/historical-quality-regression.service.d.ts +35 -0
  113. package/dist/core/sdd/services/historical-quality-regression.service.js +228 -0
  114. package/dist/core/sdd/services/ingest-deposito.service.js +1 -1
  115. package/dist/core/sdd/services/planning-execution-coherence.service.d.ts +45 -0
  116. package/dist/core/sdd/services/planning-execution-coherence.service.js +225 -0
  117. package/dist/core/sdd/state.js +15 -5
  118. package/dist/core/sdd/types.d.ts +3 -3
  119. package/dist/core/sdd/workspace-schemas.d.ts +45 -4
  120. package/dist/core/sdd/workspace-schemas.js +27 -6
  121. package/dist/core/shared/skill-generation.d.ts +2 -0
  122. package/dist/core/shared/skill-generation.js +19 -2
  123. package/dist/core/shared/tool-detection.d.ts +19 -0
  124. package/dist/core/shared/tool-detection.js +89 -0
  125. package/package.json +6 -5
  126. package/schemas/sdd/5-quality.schema.json +43 -0
  127. package/schemas/sdd/reversa-evidence-bundle.schema.json +466 -0
  128. package/schemas/sdd/workspace-catalog.schema.json +511 -0
@@ -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
  }
@@ -219,7 +307,7 @@ function buildInfrastructureLayer(subsystems, contexts) {
219
307
  name: 'adapters/',
220
308
  kind: 'dir',
221
309
  children: [
222
- ...(subsystems.includes('orm') ? [buildOrmSubsystem()] : []),
310
+ ...(subsystems.includes('orm') ? [buildOrmSubsystem(contexts)] : []),
223
311
  ...subsystems.filter((s) => s !== 'orm').map((subsystem) => {
224
312
  const subsystemNode = {
225
313
  name: `${subsystem}/`,
@@ -236,14 +324,19 @@ function buildInfrastructureLayer(subsystems, contexts) {
236
324
  ],
237
325
  };
238
326
  }
239
- function buildOrmSubsystem() {
327
+ function buildOrmSubsystem(contexts) {
240
328
  return {
241
329
  name: 'orm/',
242
330
  kind: 'dir',
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: 'orm.module.ts', kind: 'file', description: 'Single ORM module exporting TypeORM repositories' },
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',
@@ -354,4 +447,289 @@ function buildSharedLayer() {
354
447
  ],
355
448
  };
356
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
+ }
357
735
  //# sourceMappingURL=package-structure-gate.js.map
@@ -40,8 +40,8 @@ export declare const parallelFeatAutomationRequestSchema: z.ZodObject<{
40
40
  require_commit_per_feature: z.ZodDefault<z.ZodBoolean>;
41
41
  require_finalize_before_commit: z.ZodDefault<z.ZodBoolean>;
42
42
  agent_provider: z.ZodOptional<z.ZodEnum<{
43
- codex: "codex";
44
43
  opencode: "opencode";
44
+ codex: "codex";
45
45
  deepagents: "deepagents";
46
46
  fake: "fake";
47
47
  "claude-code": "claude-code";
@@ -63,8 +63,8 @@ export declare const parallelFeatSchedulerRequestSchema: z.ZodObject<{
63
63
  require_commit_per_feature: z.ZodDefault<z.ZodBoolean>;
64
64
  require_finalize_before_commit: z.ZodDefault<z.ZodBoolean>;
65
65
  agent_provider: z.ZodOptional<z.ZodEnum<{
66
- codex: "codex";
67
66
  opencode: "opencode";
67
+ codex: "codex";
68
68
  deepagents: "deepagents";
69
69
  fake: "fake";
70
70
  "claude-code": "claude-code";
@@ -94,8 +94,8 @@ export declare const parallelFeatAutomationStepSchema: z.ZodObject<{
94
94
  "local-codex": "local-codex";
95
95
  }>;
96
96
  provider: z.ZodOptional<z.ZodEnum<{
97
- codex: "codex";
98
97
  opencode: "opencode";
98
+ codex: "codex";
99
99
  deepagents: "deepagents";
100
100
  fake: "fake";
101
101
  "claude-code": "claude-code";
@@ -132,8 +132,8 @@ export declare const parallelFeatAutomationWaveSchema: z.ZodObject<{
132
132
  "local-codex": "local-codex";
133
133
  }>;
134
134
  provider: z.ZodOptional<z.ZodEnum<{
135
- codex: "codex";
136
135
  opencode: "opencode";
136
+ codex: "codex";
137
137
  deepagents: "deepagents";
138
138
  fake: "fake";
139
139
  "claude-code": "claude-code";
@@ -194,8 +194,8 @@ export declare const parallelFeatAutomationPlanSchema: z.ZodObject<{
194
194
  "local-codex": "local-codex";
195
195
  }>;
196
196
  provider: z.ZodOptional<z.ZodEnum<{
197
- codex: "codex";
198
197
  opencode: "opencode";
198
+ codex: "codex";
199
199
  deepagents: "deepagents";
200
200
  fake: "fake";
201
201
  "claude-code": "claude-code";
@@ -275,8 +275,8 @@ export declare const parallelFeatSchedulerResultSchema: z.ZodObject<{
275
275
  "local-codex": "local-codex";
276
276
  }>;
277
277
  provider: z.ZodOptional<z.ZodEnum<{
278
- codex: "codex";
279
278
  opencode: "opencode";
279
+ codex: "codex";
280
280
  deepagents: "deepagents";
281
281
  fake: "fake";
282
282
  "claude-code": "claude-code";
@@ -191,7 +191,12 @@ function isProtectedStatePath(value) {
191
191
  }
192
192
  function isSecretPath(value) {
193
193
  const lowerValue = value.toLowerCase();
194
- return lowerValue.split(/[\\/]+/).some((segment) => SECRET_PATH_SEGMENTS.some((token) => segment.includes(token)));
194
+ return lowerValue.split(/[\\/]+/).some((segment) => {
195
+ if (segment === '.env.example') {
196
+ return false;
197
+ }
198
+ return SECRET_PATH_SEGMENTS.some((token) => segment.includes(token));
199
+ });
195
200
  }
196
201
  function deny(code, message, issuePath) {
197
202
  return {
@@ -2,8 +2,8 @@ import { z } from 'zod';
2
2
  import { type PluginCapability, type PluginManifest } from './plugin-manifest.js';
3
3
  export declare const pluginRegistrySourceSchema: z.ZodObject<{
4
4
  type: z.ZodEnum<{
5
- workspace: "workspace";
6
5
  local: "local";
6
+ workspace: "workspace";
7
7
  "enterprise-catalog": "enterprise-catalog";
8
8
  }>;
9
9
  uri: z.ZodString;
@@ -191,8 +191,8 @@ export declare const pluginRegistryEntrySchema: z.ZodObject<{
191
191
  }, z.core.$strip>;
192
192
  source: z.ZodObject<{
193
193
  type: z.ZodEnum<{
194
- workspace: "workspace";
195
194
  local: "local";
195
+ workspace: "workspace";
196
196
  "enterprise-catalog": "enterprise-catalog";
197
197
  }>;
198
198
  uri: z.ZodString;
@@ -392,8 +392,8 @@ export declare const pluginRegistryStateSchema: z.ZodObject<{
392
392
  }, z.core.$strip>;
393
393
  source: z.ZodObject<{
394
394
  type: z.ZodEnum<{
395
- workspace: "workspace";
396
395
  local: "local";
396
+ workspace: "workspace";
397
397
  "enterprise-catalog": "enterprise-catalog";
398
398
  }>;
399
399
  uri: z.ZodString;
@@ -1,13 +1,13 @@
1
1
  import { z } from 'zod';
2
2
  export declare const qualityAuthorityRefSchema: z.ZodObject<{
3
3
  type: z.ZodEnum<{
4
+ skill: "skill";
4
5
  schema: "schema";
5
6
  epic: "epic";
6
7
  feature: "feature";
7
8
  foundation: "foundation";
8
9
  debate: "debate";
9
10
  adr: "adr";
10
- skill: "skill";
11
11
  }>;
12
12
  ref: z.ZodString;
13
13
  path: z.ZodOptional<z.ZodString>;
@@ -52,13 +52,13 @@ export declare const qualityScenarioSchema: z.ZodObject<{
52
52
  intent: z.ZodString;
53
53
  authority: z.ZodArray<z.ZodObject<{
54
54
  type: z.ZodEnum<{
55
+ skill: "skill";
55
56
  schema: "schema";
56
57
  epic: "epic";
57
58
  feature: "feature";
58
59
  foundation: "foundation";
59
60
  debate: "debate";
60
61
  adr: "adr";
61
- skill: "skill";
62
62
  }>;
63
63
  ref: z.ZodString;
64
64
  path: z.ZodOptional<z.ZodString>;
@@ -117,13 +117,13 @@ export declare const qualityArchitectureSchema: z.ZodObject<{
117
117
  stack: z.ZodString;
118
118
  authority: z.ZodArray<z.ZodObject<{
119
119
  type: z.ZodEnum<{
120
+ skill: "skill";
120
121
  schema: "schema";
121
122
  epic: "epic";
122
123
  feature: "feature";
123
124
  foundation: "foundation";
124
125
  debate: "debate";
125
126
  adr: "adr";
126
- skill: "skill";
127
127
  }>;
128
128
  ref: z.ZodString;
129
129
  path: z.ZodOptional<z.ZodString>;
@@ -297,13 +297,13 @@ export declare const qualityEvidenceBundleSchema: z.ZodObject<{
297
297
  intent: z.ZodString;
298
298
  authority: z.ZodArray<z.ZodObject<{
299
299
  type: z.ZodEnum<{
300
+ skill: "skill";
300
301
  schema: "schema";
301
302
  epic: "epic";
302
303
  feature: "feature";
303
304
  foundation: "foundation";
304
305
  debate: "debate";
305
306
  adr: "adr";
306
- skill: "skill";
307
307
  }>;
308
308
  ref: z.ZodString;
309
309
  path: z.ZodOptional<z.ZodString>;
@@ -354,13 +354,13 @@ export declare const qualityEvidenceBundleSchema: z.ZodObject<{
354
354
  stack: z.ZodString;
355
355
  authority: z.ZodArray<z.ZodObject<{
356
356
  type: z.ZodEnum<{
357
+ skill: "skill";
357
358
  schema: "schema";
358
359
  epic: "epic";
359
360
  feature: "feature";
360
361
  foundation: "foundation";
361
362
  debate: "debate";
362
363
  adr: "adr";
363
- skill: "skill";
364
364
  }>;
365
365
  ref: z.ZodString;
366
366
  path: z.ZodOptional<z.ZodString>;