@devtrack-solution/codesdd 1.2.3 → 1.2.4-rc3

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 (139) hide show
  1. package/.sdd/skills/curated/devtrack-api/SKILL.md +12 -5
  2. package/.sdd/skills/curated/devtrack-api/agents/claude-code.yaml +8 -0
  3. package/.sdd/skills/curated/devtrack-api/agents/codex.yaml +8 -0
  4. package/.sdd/skills/curated/devtrack-api/agents/cursor.yaml +8 -0
  5. package/.sdd/skills/curated/devtrack-api/agents/gemini.yaml +8 -0
  6. package/.sdd/skills/curated/devtrack-api/agents/kimi.yaml +8 -0
  7. package/.sdd/skills/curated/devtrack-api/agents/openai.yaml +4 -2
  8. package/.sdd/skills/curated/devtrack-api/agents/opencode.yaml +10 -0
  9. package/.sdd/skills/curated/devtrack-api/references/application-presentation.md +2 -2
  10. package/.sdd/skills/curated/devtrack-api/references/contract-pack.yaml +55 -0
  11. package/.sdd/skills/curated/devtrack-api/references/domain-modeling.md +13 -13
  12. package/.sdd/skills/curated/devtrack-api/references/foundation-layout.md +2 -3
  13. package/.sdd/skills/curated/devtrack-api/references/implementation-checklist.md +1 -1
  14. package/.sdd/skills/curated/devtrack-api/references/portable-agent-contract.md +41 -0
  15. package/.sdd/skills/curated/devtrack-api/references/typeorm-infrastructure.md +7 -9
  16. package/README.md +159 -5
  17. package/dist/applications/sdd/index.d.ts +16 -0
  18. package/dist/applications/sdd/index.js +16 -0
  19. package/dist/commands/config.js +171 -10
  20. package/dist/commands/sdd/execution.js +345 -15
  21. package/dist/commands/sdd/plugin.js +5 -0
  22. package/dist/commands/sdd/shared.d.ts +1 -0
  23. package/dist/commands/sdd/shared.js +10 -0
  24. package/dist/commands/sdd.js +38 -3
  25. package/dist/core/cli/command-matrix.js +9 -0
  26. package/dist/core/cli-command-quality.js +9 -0
  27. package/dist/core/completions/command-registry.js +45 -0
  28. package/dist/core/config-schema.d.ts +18 -1
  29. package/dist/core/config-schema.js +48 -5
  30. package/dist/core/global-config.d.ts +16 -0
  31. package/dist/core/sdd/agent-binding.d.ts +10 -10
  32. package/dist/core/sdd/agent-runtime-contract.d.ts +204 -0
  33. package/dist/core/sdd/agent-runtime-contract.js +200 -0
  34. package/dist/core/sdd/check.d.ts +2 -0
  35. package/dist/core/sdd/check.js +40 -2
  36. package/dist/core/sdd/coordination/coordination-adapters.d.ts +15 -8
  37. package/dist/core/sdd/coordination/coordination-adapters.js +43 -15
  38. package/dist/core/sdd/coordination/index.d.ts +1 -0
  39. package/dist/core/sdd/coordination/index.js +1 -0
  40. package/dist/core/sdd/coordination/redis-runtime.d.ts +131 -0
  41. package/dist/core/sdd/coordination/redis-runtime.js +698 -0
  42. package/dist/core/sdd/deepagent-contracts.d.ts +98 -4
  43. package/dist/core/sdd/deepagent-contracts.js +62 -0
  44. package/dist/core/sdd/default-bootstrap-files.d.ts +2 -2
  45. package/dist/core/sdd/default-bootstrap-files.js +14 -8
  46. package/dist/core/sdd/default-skills.js +108 -4
  47. package/dist/core/sdd/devtrack-api-appliance.d.ts +8 -1
  48. package/dist/core/sdd/devtrack-api-appliance.js +46 -23
  49. package/dist/core/sdd/docs-sync.js +21 -15
  50. package/dist/core/sdd/domain/capability-diff.d.ts +63 -0
  51. package/dist/core/sdd/domain/capability-diff.js +200 -0
  52. package/dist/core/sdd/domain/change-safety-guardrails.d.ts +74 -0
  53. package/dist/core/sdd/domain/change-safety-guardrails.js +333 -0
  54. package/dist/core/sdd/domain/semantic-intent-classifier.d.ts +29 -0
  55. package/dist/core/sdd/domain/semantic-intent-classifier.js +117 -0
  56. package/dist/core/sdd/foundation-artifact-map-validator.d.ts +16 -0
  57. package/dist/core/sdd/foundation-artifact-map-validator.js +71 -0
  58. package/dist/core/sdd/foundation-layer-manifest.d.ts +24 -0
  59. package/dist/core/sdd/foundation-layer-manifest.js +117 -0
  60. package/dist/core/sdd/intent-guard.d.ts +22 -0
  61. package/dist/core/sdd/intent-guard.js +67 -0
  62. package/dist/core/sdd/json-schema.js +9 -1
  63. package/dist/core/sdd/legacy-operations.js +76 -1
  64. package/dist/core/sdd/migrate-workspace.js +39 -0
  65. package/dist/core/sdd/package-security-gates.d.ts +21 -0
  66. package/dist/core/sdd/package-security-gates.js +119 -0
  67. package/dist/core/sdd/package-structure-gate.js +3 -8
  68. package/dist/core/sdd/parallel-feat-automation.d.ts +181 -3
  69. package/dist/core/sdd/parallel-feat-automation.js +212 -0
  70. package/dist/core/sdd/plugin-broker.d.ts +223 -4
  71. package/dist/core/sdd/plugin-broker.js +10 -0
  72. package/dist/core/sdd/plugin-cli.d.ts +30 -0
  73. package/dist/core/sdd/plugin-cli.js +70 -3
  74. package/dist/core/sdd/plugin-evidence.d.ts +73 -0
  75. package/dist/core/sdd/plugin-manifest.d.ts +69 -1
  76. package/dist/core/sdd/plugin-manifest.js +10 -0
  77. package/dist/core/sdd/plugin-policy-pack.d.ts +1 -1
  78. package/dist/core/sdd/plugin-registry.d.ts +141 -5
  79. package/dist/core/sdd/plugin-sdk-contract.d.ts +363 -0
  80. package/dist/core/sdd/plugin-sdk-contract.js +268 -0
  81. package/dist/core/sdd/plugin-skill-binding.d.ts +1 -1
  82. package/dist/core/sdd/quality-validation.d.ts +84 -11
  83. package/dist/core/sdd/release-readiness.d.ts +19 -0
  84. package/dist/core/sdd/release-readiness.js +472 -0
  85. package/dist/core/sdd/runtime-boundary-contract.d.ts +45 -0
  86. package/dist/core/sdd/runtime-boundary-contract.js +90 -0
  87. package/dist/core/sdd/sdk-agent-plugin-quality-gates.d.ts +150 -0
  88. package/dist/core/sdd/sdk-agent-plugin-quality-gates.js +258 -0
  89. package/dist/core/sdd/services/agent-run.service.d.ts +38 -6
  90. package/dist/core/sdd/services/agent-run.service.js +73 -1
  91. package/dist/core/sdd/services/capability-diff.service.d.ts +18 -0
  92. package/dist/core/sdd/services/capability-diff.service.js +26 -0
  93. package/dist/core/sdd/services/change-safety-preflight.service.d.ts +17 -0
  94. package/dist/core/sdd/services/change-safety-preflight.service.js +17 -0
  95. package/dist/core/sdd/services/context.service.d.ts +43 -340
  96. package/dist/core/sdd/services/context.service.js +323 -9
  97. package/dist/core/sdd/services/finalize.service.d.ts +25 -0
  98. package/dist/core/sdd/services/finalize.service.js +178 -16
  99. package/dist/core/sdd/services/frontend-impact.service.d.ts +1 -1
  100. package/dist/core/sdd/services/semantic-intent-classifier.service.d.ts +6 -0
  101. package/dist/core/sdd/services/semantic-intent-classifier.service.js +7 -0
  102. package/dist/core/sdd/state.d.ts +1 -0
  103. package/dist/core/sdd/state.js +251 -29
  104. package/dist/core/sdd/store/sdd-stores.js +2 -2
  105. package/dist/core/sdd/structural-health.d.ts +13 -13
  106. package/dist/core/sdd/types.d.ts +27 -12
  107. package/dist/core/sdd/types.js +4 -0
  108. package/dist/core/sdd/views.js +17 -0
  109. package/dist/core/sdd/workspace-schemas.d.ts +387 -7
  110. package/dist/core/sdd/workspace-schemas.js +196 -64
  111. package/dist/domains/sdd/index.d.ts +6 -0
  112. package/dist/domains/sdd/index.js +6 -0
  113. package/dist/infrastructures/sdd/index.d.ts +7 -0
  114. package/dist/infrastructures/sdd/index.js +6 -0
  115. package/dist/presentations/cli/sdd/index.d.ts +3 -0
  116. package/dist/presentations/cli/sdd/index.js +3 -0
  117. package/dist/shared/sdd/index.d.ts +3 -0
  118. package/dist/shared/sdd/index.js +2 -0
  119. package/package.json +9 -6
  120. package/schemas/sdd/2-plan.schema.json +207 -2
  121. package/schemas/sdd/5-quality.schema.json +281 -25
  122. package/schemas/sdd/agent-runtime-command-plan.schema.json +212 -0
  123. package/schemas/sdd/agent-runtime-opencode-run-evidence.schema.json +270 -0
  124. package/schemas/sdd/codesdd-plugin.schema.json +171 -0
  125. package/schemas/sdd/deepagent-run-request.schema.json +316 -0
  126. package/schemas/sdd/parallel-feat-automation-plan.schema.json +89 -0
  127. package/schemas/sdd/parallel-feat-scheduler-request.schema.json +116 -0
  128. package/schemas/sdd/parallel-feat-scheduler-result.schema.json +404 -0
  129. package/schemas/sdd/plugin-artifact-manifest.schema.json +109 -0
  130. package/schemas/sdd/plugin-artifact-map.schema.json +223 -0
  131. package/schemas/sdd/plugin-evidence-manifest.schema.json +109 -0
  132. package/schemas/sdd/plugin-language-runtime.schema.json +103 -0
  133. package/schemas/sdd/plugin-package-governance.schema.json +74 -0
  134. package/schemas/sdd/plugin-registry.schema.json +171 -0
  135. package/schemas/sdd/plugin-runtime-invocation-plan.schema.json +109 -0
  136. package/schemas/sdd/quality-evidence-bundle.schema.json +109 -0
  137. package/schemas/sdd/sdk-agent-plugin-quality-gate-input.schema.json +168 -0
  138. package/schemas/sdd/sdk-agent-plugin-quality-gate-report.schema.json +160 -0
  139. package/schemas/sdd/workspace-catalog.schema.json +3776 -398
@@ -0,0 +1,117 @@
1
+ export const CODESDD_FOUNDATION_LAYER_IDS = [
2
+ 'domains',
3
+ 'applications',
4
+ 'infrastructures',
5
+ 'presentations',
6
+ 'shared',
7
+ ];
8
+ export const CODESDD_FOUNDATION_LAYER_MANIFEST = [
9
+ {
10
+ layer: 'domains',
11
+ root: 'src/domains',
12
+ entrypoint: 'src/domains/sdd/index.ts',
13
+ legacy_roots: ['src/core/sdd/domain'],
14
+ role: 'Pure CodeSDD lifecycle, traceability, title, transition, and guardrail domain rules.',
15
+ migration_status: 'active-facade',
16
+ },
17
+ {
18
+ layer: 'applications',
19
+ root: 'src/applications',
20
+ entrypoint: 'src/applications/sdd/index.ts',
21
+ legacy_roots: ['src/core/sdd/services'],
22
+ role: 'Use-case and orchestration services for CodeSDD lifecycle and command workflows.',
23
+ migration_status: 'active-facade',
24
+ },
25
+ {
26
+ layer: 'infrastructures',
27
+ root: 'src/infrastructures',
28
+ entrypoint: 'src/infrastructures/sdd/index.ts',
29
+ legacy_roots: ['src/core/sdd/store', 'src/core/sdd/coordination'],
30
+ role: 'Filesystem, YAML state, Redis, cache, lock, queue, and event adapters.',
31
+ migration_status: 'active-facade',
32
+ },
33
+ {
34
+ layer: 'presentations',
35
+ root: 'src/presentations',
36
+ entrypoint: 'src/presentations/cli/sdd/index.ts',
37
+ legacy_roots: ['src/commands', 'src/cli'],
38
+ role: 'CLI and operator-facing command surfaces.',
39
+ migration_status: 'active-facade',
40
+ },
41
+ {
42
+ layer: 'shared',
43
+ root: 'src/shared',
44
+ entrypoint: 'src/shared/sdd/index.ts',
45
+ legacy_roots: ['src/core/sdd/types.ts', 'src/core/sdd/workspace-schemas.ts', 'src/core/shared'],
46
+ role: 'Shared contracts, schema documents, and reusable utility boundaries.',
47
+ migration_status: 'active-facade',
48
+ },
49
+ ];
50
+ export function listCodesddFoundationLayerRoots(manifest = CODESDD_FOUNDATION_LAYER_MANIFEST) {
51
+ return manifest.map((entry) => entry.root);
52
+ }
53
+ export function validateCodesddFoundationLayerManifest(manifest = CODESDD_FOUNDATION_LAYER_MANIFEST) {
54
+ const findings = [];
55
+ const seenLayers = new Set();
56
+ const seenRoots = new Set();
57
+ for (const layer of CODESDD_FOUNDATION_LAYER_IDS) {
58
+ if (!manifest.some((entry) => entry.layer === layer)) {
59
+ findings.push({
60
+ code: 'FOUNDATION_LAYER_MISSING',
61
+ layer,
62
+ message: `Foundation-like layer ${layer} must be declared.`,
63
+ });
64
+ }
65
+ }
66
+ for (const entry of manifest) {
67
+ if (seenLayers.has(entry.layer)) {
68
+ findings.push({
69
+ code: 'FOUNDATION_LAYER_DUPLICATE',
70
+ layer: entry.layer,
71
+ message: `Foundation-like layer ${entry.layer} is declared more than once.`,
72
+ });
73
+ }
74
+ seenLayers.add(entry.layer);
75
+ if (seenRoots.has(entry.root)) {
76
+ findings.push({
77
+ code: 'FOUNDATION_LAYER_DUPLICATE',
78
+ layer: entry.layer,
79
+ path: entry.root,
80
+ message: `Foundation-like root ${entry.root} is declared more than once.`,
81
+ });
82
+ }
83
+ seenRoots.add(entry.root);
84
+ const expectedRoot = `src/${entry.layer}`;
85
+ if (entry.root !== expectedRoot) {
86
+ findings.push({
87
+ code: 'FOUNDATION_LAYER_ROOT_MISMATCH',
88
+ layer: entry.layer,
89
+ path: entry.root,
90
+ message: `Layer ${entry.layer} must use plural root ${expectedRoot}.`,
91
+ });
92
+ }
93
+ if (!entry.entrypoint.startsWith(`${entry.root}/`)) {
94
+ findings.push({
95
+ code: 'FOUNDATION_LAYER_ENTRYPOINT_MISMATCH',
96
+ layer: entry.layer,
97
+ path: entry.entrypoint,
98
+ message: `Layer ${entry.layer} entrypoint must live under ${entry.root}.`,
99
+ });
100
+ }
101
+ for (const legacyRoot of entry.legacy_roots) {
102
+ if (legacyRoot.includes('/.codesdd') || legacyRoot.startsWith('.codesdd')) {
103
+ findings.push({
104
+ code: 'FOUNDATION_LAYER_FORBIDDEN_PROJECT_RUNTIME',
105
+ layer: entry.layer,
106
+ path: legacyRoot,
107
+ message: 'Foundation-like layer mappings must not use project-local .codesdd runtime paths.',
108
+ });
109
+ }
110
+ }
111
+ }
112
+ return {
113
+ valid: findings.length === 0,
114
+ findings,
115
+ };
116
+ }
117
+ //# sourceMappingURL=foundation-layer-manifest.js.map
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ export declare const sddIntentGuardInputSchema: z.ZodObject<{
3
+ request: z.ZodString;
4
+ featureRef: z.ZodOptional<z.ZodString>;
5
+ }, z.core.$strip>;
6
+ export declare const sddIntentGuardResultSchema: z.ZodObject<{
7
+ request: z.ZodString;
8
+ classification: z.ZodEnum<{
9
+ change_request: "change_request";
10
+ read_only: "read_only";
11
+ outside_codesdd: "outside_codesdd";
12
+ }>;
13
+ requires_codesdd_planning: z.ZodBoolean;
14
+ feature_ref: z.ZodOptional<z.ZodString>;
15
+ reason: z.ZodString;
16
+ required_commands: z.ZodArray<z.ZodString>;
17
+ warnings: z.ZodArray<z.ZodString>;
18
+ }, z.core.$strip>;
19
+ export type SddIntentGuardInput = z.input<typeof sddIntentGuardInputSchema>;
20
+ export type SddIntentGuardResult = z.infer<typeof sddIntentGuardResultSchema>;
21
+ export declare function evaluateSddIntentGuard(input: SddIntentGuardInput): SddIntentGuardResult;
22
+ //# sourceMappingURL=intent-guard.d.ts.map
@@ -0,0 +1,67 @@
1
+ import { z } from 'zod';
2
+ import { CLI_NAME } from '../branding.js';
3
+ const FEATURE_REF_PATTERN = /^FEAT-\d{4}$/;
4
+ const changeIntentPattern = /\b(add|alter|apply|build|change|code|commit|create|delete|edit|execute|fix|generate|implement|install|move|refactor|remove|rename|resolve|run|scaffold|update|write|ajust|altere|aplique|corrija|crie|edite|execute|faca|faça|gere|implemente|mova|remova|renomeie|resolva|rode|atualize)\b/i;
5
+ const readOnlyPattern = /\b(read-only|readonly|no edit|no edits|sem editar|somente leitura|apenas leia|apenas leitura|explique|explique-me|analise|review|status|estado atual|listar|list|show|mostrar)\b/i;
6
+ const outsideSddPattern = /\b(skip codesdd|sem codesdd|fora do codesdd|outside codesdd|do not use codesdd|nao use codesdd|não use codesdd)\b/i;
7
+ export const sddIntentGuardInputSchema = z.object({
8
+ request: z.string().min(1),
9
+ featureRef: z.string().regex(FEATURE_REF_PATTERN).optional(),
10
+ });
11
+ export const sddIntentGuardResultSchema = z.object({
12
+ request: z.string(),
13
+ classification: z.enum(['change_request', 'read_only', 'outside_codesdd']),
14
+ requires_codesdd_planning: z.boolean(),
15
+ feature_ref: z.string().regex(FEATURE_REF_PATTERN).optional(),
16
+ reason: z.string(),
17
+ required_commands: z.array(z.string()),
18
+ warnings: z.array(z.string()),
19
+ });
20
+ export function evaluateSddIntentGuard(input) {
21
+ const parsed = sddIntentGuardInputSchema.parse(input);
22
+ const request = parsed.request.trim();
23
+ const explicitlyOutside = outsideSddPattern.test(request);
24
+ const readOnly = readOnlyPattern.test(request) && !changeIntentPattern.test(request);
25
+ const changeRequest = changeIntentPattern.test(request) && !explicitlyOutside;
26
+ if (explicitlyOutside) {
27
+ return sddIntentGuardResultSchema.parse({
28
+ request,
29
+ classification: 'outside_codesdd',
30
+ requires_codesdd_planning: false,
31
+ feature_ref: parsed.featureRef,
32
+ reason: 'The request explicitly opts out of CodeSDD handling.',
33
+ required_commands: [],
34
+ warnings: ['Only honor this opt-out when it does not conflict with repository governance policy.'],
35
+ });
36
+ }
37
+ if (!changeRequest || readOnly) {
38
+ return sddIntentGuardResultSchema.parse({
39
+ request,
40
+ classification: 'read_only',
41
+ requires_codesdd_planning: false,
42
+ feature_ref: parsed.featureRef,
43
+ reason: 'The request is read-only and does not imply implementation, edits, validation, execution, or finalize.',
44
+ required_commands: [],
45
+ warnings: [],
46
+ });
47
+ }
48
+ const featureCommand = parsed.featureRef
49
+ ? `${CLI_NAME} sdd context ${parsed.featureRef}`
50
+ : `${CLI_NAME} sdd context <FEAT-ID>`;
51
+ return sddIntentGuardResultSchema.parse({
52
+ request,
53
+ classification: 'change_request',
54
+ requires_codesdd_planning: true,
55
+ feature_ref: parsed.featureRef,
56
+ reason: 'The request implies implementation, edits, validation, execution, or finalize in an initialized CodeSDD repository.',
57
+ required_commands: [
58
+ `${CLI_NAME} sdd onboard system`,
59
+ `${CLI_NAME} sdd next`,
60
+ featureCommand,
61
+ ],
62
+ warnings: parsed.featureRef
63
+ ? []
64
+ : ['Bind this request to the active or ready FEAT returned by CodeSDD before coding.'],
65
+ });
66
+ }
67
+ //# sourceMappingURL=intent-guard.js.map
@@ -6,11 +6,14 @@ import { pluginArtifactManifestSchema, pluginDryRunExecutionPlanSchema, pluginRo
6
6
  import { pluginPolicyEvaluationSchema } from './plugin-policy.js';
7
7
  import { pluginPolicyPackEvaluationSchema, pluginPolicyPackSchema } from './plugin-policy-pack.js';
8
8
  import { pluginComplianceIndexSchema, pluginEvidenceManifestSchema, pluginValidationManifestSchema, } from './plugin-evidence.js';
9
+ import { buildPluginSdkJsonSchemas } from './plugin-sdk-contract.js';
9
10
  import { pluginSkillBindingResolutionSchema, pluginSkillBindingSchema, } from './plugin-skill-binding.js';
10
11
  import { agentBindingAdapterSchema, agentBindingResolutionSchema, } from './agent-binding.js';
11
- import { parallelFeatAutomationPlanSchema, parallelFeatAutomationRequestSchema, } from './parallel-feat-automation.js';
12
+ import { buildAgentRuntimeJsonSchemas } from './agent-runtime-contract.js';
13
+ import { parallelFeatAutomationPlanSchema, parallelFeatAutomationRequestSchema, parallelFeatSchedulerRequestSchema, parallelFeatSchedulerResultSchema, } from './parallel-feat-automation.js';
12
14
  import { backlogProjectionPlanSchema, backlogProviderContractSchema, } from './backlog-provider-contract.js';
13
15
  import { qualityArchitectureSchema, qualityEvidenceBundleSchema, qualityRunSchema, qualityScenarioSchema, } from './quality-validation.js';
16
+ import { buildSdkAgentPluginQualityGateJsonSchemas } from './sdk-agent-plugin-quality-gates.js';
14
17
  import { deepagentDecisionEvidenceSchema, deepagentEnvContractSchema, deepagentQualityEvidenceSchema, deepagentRunEvidenceSchema, deepagentRunPlanSchema, deepagentRunRequestSchema, deepagentSubagentEvidenceSchema, deepagentToolCallEvidenceSchema, } from './deepagent-contracts.js';
15
18
  import { adrFrontmatterSchema, debateFrontmatterSchema, discardedFrontmatterSchema, epicFrontmatterSchema, insightFrontmatterSchema, } from './governance-schemas.js';
16
19
  const JSON_SCHEMA_DRAFT = 'https://json-schema.org/draft/2020-12/schema';
@@ -70,6 +73,7 @@ export function buildWorkspaceJsonSchemaCatalog() {
70
73
  plugin_manifests: {
71
74
  'codesdd-plugin.yaml': buildPluginManifestJsonSchema(),
72
75
  },
76
+ plugin_sdk_contracts: buildPluginSdkJsonSchemas(),
73
77
  plugin_registries: {
74
78
  'plugin-registry.yaml': normalizeJsonSchemaDocument(toJSONSchema(pluginRegistryStateSchema), 'CodeSDD Plugin Registry State', 'Machine-readable state contract for registered CodeSDD enterprise plugins.'),
75
79
  },
@@ -115,9 +119,12 @@ export function buildWorkspaceJsonSchemaCatalog() {
115
119
  agent_binding_resolutions: {
116
120
  'agent-binding-resolution.yaml': normalizeJsonSchemaDocument(toJSONSchema(agentBindingResolutionSchema), 'CodeSDD Agent Binding Resolution', 'Machine-readable resolution result for selecting a compatible coding-agent adapter for a FEAT task.'),
117
121
  },
122
+ agent_runtime_contracts: buildAgentRuntimeJsonSchemas(),
118
123
  parallel_feat_automation: {
119
124
  'parallel-feat-automation-request.yaml': normalizeJsonSchemaDocument(toJSONSchema(parallelFeatAutomationRequestSchema), 'CodeSDD Parallel FEAT Automation Request', 'Machine-readable input contract for planning safe parallel FEAT execution waves.'),
120
125
  'parallel-feat-automation-plan.yaml': normalizeJsonSchemaDocument(toJSONSchema(parallelFeatAutomationPlanSchema), 'CodeSDD Parallel FEAT Automation Plan', 'Machine-readable execution plan for safe parallel FEAT waves, quality gates, and commit boundaries.'),
126
+ 'parallel-feat-scheduler-request.yaml': normalizeJsonSchemaDocument(toJSONSchema(parallelFeatSchedulerRequestSchema), 'CodeSDD Parallel FEAT Scheduler Request', 'Machine-readable input contract for dependency-aware chained FEAT wave scheduling.'),
127
+ 'parallel-feat-scheduler-result.yaml': normalizeJsonSchemaDocument(toJSONSchema(parallelFeatSchedulerResultSchema), 'CodeSDD Parallel FEAT Scheduler Result', 'Machine-readable scheduler result linking chained FEAT waves, blocked dependencies, and the execution plan.'),
121
128
  },
122
129
  backlog_integrations: {
123
130
  'backlog-provider-contract.yaml': normalizeJsonSchemaDocument(toJSONSchema(backlogProviderContractSchema), 'CodeSDD Backlog Provider Contract', 'Machine-readable provider contract for projecting canonical CodeSDD backlog state to external planning tools.'),
@@ -128,6 +135,7 @@ export function buildWorkspaceJsonSchemaCatalog() {
128
135
  'quality-run.yaml': normalizeJsonSchemaDocument(toJSONSchema(qualityRunSchema), 'CodeSDD Quality Run', 'Machine-readable execution record for a CodeSDD quality validation scenario.'),
129
136
  'quality-architecture-schema.yaml': normalizeJsonSchemaDocument(toJSONSchema(qualityArchitectureSchema), 'CodeSDD Quality Architecture Schema', 'Machine-readable architecture gateway contract for generated product validation.'),
130
137
  'quality-evidence-bundle.yaml': normalizeJsonSchemaDocument(toJSONSchema(qualityEvidenceBundleSchema), 'CodeSDD Quality Evidence Bundle', 'Machine-readable evidence bundle contract tying scenario, run, artifacts, checksums, findings, and exceptions together.'),
138
+ ...buildSdkAgentPluginQualityGateJsonSchemas(),
131
139
  },
132
140
  deepagent_execution: {
133
141
  'deepagent-run-request.yaml': normalizeJsonSchemaDocument(toJSONSchema(deepagentRunRequestSchema), 'CodeSDD DeepAgent Run Request', 'Machine-readable request contract for governed DeepAgents execution with scoped tools, write policy, env contract, and expected evidence.'),
@@ -1028,6 +1028,74 @@ export function buildActivePlanDoc(feature, recommendedBundles) {
1028
1028
  const baseDocument = {
1029
1029
  schema_version: 1,
1030
1030
  feature_id: feature.id,
1031
+ governance: {
1032
+ state_boundary: 'codesdd-canonical-sdd-state',
1033
+ planning_artifacts: [
1034
+ '.sdd/state/backlog.yaml',
1035
+ `.sdd/${feature.status === 'IN_PROGRESS' ? 'active' : 'planned'}/${feature.id}/1-spec.yaml`,
1036
+ `.sdd/${feature.status === 'IN_PROGRESS' ? 'active' : 'planned'}/${feature.id}/2-plan.yaml`,
1037
+ `.sdd/${feature.status === 'IN_PROGRESS' ? 'active' : 'planned'}/${feature.id}/5-quality.yaml`,
1038
+ ],
1039
+ decision_refs: Array.from(new Set([feature.origin_ref, ...feature.acceptance_refs].filter(Boolean))),
1040
+ planned_state_writes: [
1041
+ '.sdd/state/backlog.yaml',
1042
+ '.sdd/state/transition-log.yaml',
1043
+ ],
1044
+ rollback_plan: 'If validation fails, revert only the scoped feature workspace/state entries and regenerate CodeSDD views from canonical state.',
1045
+ validation_gates: [
1046
+ {
1047
+ name: 'SDD diagnose',
1048
+ command: `${CLI_NAME} sdd diagnose`,
1049
+ expected: 'Structural CodeSDD health has no blockers or errors.',
1050
+ },
1051
+ {
1052
+ name: 'SDD check render',
1053
+ command: `${CLI_NAME} sdd check --render`,
1054
+ expected: 'Canonical state validates and generated views are synchronized.',
1055
+ },
1056
+ ],
1057
+ },
1058
+ execution_plan: {
1059
+ mode: 'single-feature',
1060
+ state_boundary_ref: 'codesdd-canonical-sdd-state',
1061
+ command_sequence: [
1062
+ {
1063
+ name: 'Load CodeSDD context',
1064
+ command: `${CLI_NAME} sdd context ${feature.id}`,
1065
+ writes_state: false,
1066
+ expected_state_writes: [],
1067
+ },
1068
+ {
1069
+ name: 'Declare frontend impact',
1070
+ command: `${CLI_NAME} sdd frontend-impact ${feature.id} --status required|none --reason "..."`,
1071
+ writes_state: true,
1072
+ expected_state_writes: ['.sdd/state/backlog.yaml', '.sdd/state/transition-log.yaml'],
1073
+ },
1074
+ {
1075
+ name: 'Finalize feature',
1076
+ command: `${CLI_NAME} sdd finalize --ref ${feature.id}`,
1077
+ writes_state: true,
1078
+ expected_state_writes: [
1079
+ '.sdd/state/backlog.yaml',
1080
+ '.sdd/state/finalize-queue.yaml',
1081
+ '.sdd/state/transition-log.yaml',
1082
+ `.sdd/archived/${feature.id}/`,
1083
+ ],
1084
+ },
1085
+ ],
1086
+ allowed_state_writes: [
1087
+ `.sdd/active/${feature.id}/`,
1088
+ `.sdd/archived/${feature.id}/`,
1089
+ '.sdd/state/backlog.yaml',
1090
+ '.sdd/state/finalize-queue.yaml',
1091
+ '.sdd/state/transition-log.yaml',
1092
+ ],
1093
+ forbidden_state_writes: ['.codesdd/**', 'external-context/**'],
1094
+ handoff_artifacts: [
1095
+ `.sdd/active/${feature.id}/5-quality.yaml`,
1096
+ `.sdd/archived/${feature.id}/`,
1097
+ ],
1098
+ },
1031
1099
  architectural_impact: {
1032
1100
  description: `Touches ${feature.touches.join(', ') || 'the active SDD workspace'} with lock domains ${feature.lock_domains.join(', ') || 'none declared'}.`,
1033
1101
  affected_modules: feature.touches,
@@ -1136,6 +1204,11 @@ export function buildActiveQualityDoc(feature) {
1136
1204
  },
1137
1205
  requirements: [],
1138
1206
  },
1207
+ runtime_quality_gates: {
1208
+ mode: 'observe',
1209
+ performance: [],
1210
+ flakiness: [],
1211
+ },
1139
1212
  q95_ledger: {
1140
1213
  threshold: 95,
1141
1214
  score: 0,
@@ -2016,7 +2089,9 @@ export function inferOriginType(input) {
2016
2089
  return 'direct';
2017
2090
  }
2018
2091
  export async function buildFinalizeQueue(paths, backlogItems, queueItems) {
2019
- const queueByFeature = new Map(queueItems.map((item) => [item.feature_id, item]));
2092
+ const queueByFeature = new Map(queueItems
2093
+ .filter((item) => item.status === 'PENDING')
2094
+ .map((item) => [item.feature_id, item]));
2020
2095
  const archiveRoot = resolveLegacySpecSubpath(paths.projectRoot, 'changes', 'archive');
2021
2096
  for (const item of backlogItems) {
2022
2097
  if (!item.change_name)
@@ -198,6 +198,35 @@ function migratePlan(featureId, parsed) {
198
198
  const doc = {
199
199
  schema_version: 1,
200
200
  feature_id: featureId,
201
+ governance: {
202
+ state_boundary: 'codesdd-canonical-sdd-state',
203
+ planning_artifacts: [`.sdd/active/${featureId}/2-plan.yaml`],
204
+ decision_refs: [featureId],
205
+ planned_state_writes: [],
206
+ rollback_plan: 'Review the migrated workspace plan and revert only the scoped migration files if validation fails.',
207
+ validation_gates: [
208
+ {
209
+ name: 'Workspace schema validation',
210
+ command: `codesdd sdd migrate-workspace --feat ${featureId}`,
211
+ expected: 'Migrated plan document validates against the canonical workspace schema.',
212
+ },
213
+ ],
214
+ },
215
+ execution_plan: {
216
+ mode: 'single-feature',
217
+ state_boundary_ref: 'codesdd-canonical-sdd-state',
218
+ command_sequence: [
219
+ {
220
+ name: 'Validate migrated workspace',
221
+ command: `codesdd sdd migrate-workspace --feat ${featureId}`,
222
+ writes_state: true,
223
+ expected_state_writes: [`.sdd/active/${featureId}/2-plan.yaml`],
224
+ },
225
+ ],
226
+ allowed_state_writes: [`.sdd/active/${featureId}/`],
227
+ forbidden_state_writes: ['.codesdd/**', 'external-context/**'],
228
+ handoff_artifacts: [`.sdd/active/${featureId}/5-quality.yaml`],
229
+ },
201
230
  architectural_impact: {
202
231
  description: ensureText(featureId, 'architectural_impact.description', section(parsed, ['architectural impact', 'impacto arquitetural', 'plan', 'plano']), 1, missing),
203
232
  affected_modules: affected,
@@ -304,6 +333,16 @@ function migrateQuality(featureId, parsed) {
304
333
  },
305
334
  requirements: [],
306
335
  },
336
+ token_budget_gates: {
337
+ require_numeric_efficiency: true,
338
+ fail_below_percent: 95,
339
+ telemetry: [],
340
+ },
341
+ runtime_quality_gates: {
342
+ mode: 'observe',
343
+ performance: [],
344
+ flakiness: [],
345
+ },
307
346
  q95_ledger: {
308
347
  threshold: 95,
309
348
  score: 0,
@@ -0,0 +1,21 @@
1
+ export interface PackageSecurityIssue {
2
+ code: string;
3
+ path: string;
4
+ message: string;
5
+ }
6
+ export interface PackageSecurityGateReport {
7
+ status: 'pass' | 'fail';
8
+ package_allowlist: {
9
+ status: 'pass' | 'fail';
10
+ allowed_files: string[];
11
+ issues: PackageSecurityIssue[];
12
+ };
13
+ secret_scan: {
14
+ status: 'pass' | 'fail';
15
+ scanned_files: number;
16
+ issues: PackageSecurityIssue[];
17
+ };
18
+ }
19
+ export declare function evaluatePackageSecurityGates(projectRoot: string): Promise<PackageSecurityGateReport>;
20
+ export declare function evaluatePackageFileAllowlist(files: string[]): PackageSecurityIssue[];
21
+ //# sourceMappingURL=package-security-gates.d.ts.map
@@ -0,0 +1,119 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { promises as fs } from 'node:fs';
3
+ import path from 'node:path';
4
+ import fg from 'fast-glob';
5
+ const FORBIDDEN_PACKAGE_FILE_PATTERNS = [
6
+ /^\.env/u,
7
+ /^\.npmrc$/u,
8
+ /^\.sdd\/state\//u,
9
+ /^\.git/u,
10
+ /^node_modules\//u,
11
+ /^coverage\//u,
12
+ /^\.turbo\//u,
13
+ /^\.cache\//u,
14
+ /(?:^|\/)[^/]+\.log$/u,
15
+ /(?:^|\/)(?:secret|secrets|credential|credentials)(?:\/|$)/u,
16
+ ];
17
+ const SECRET_SIGNATURES = [
18
+ { code: 'PRIVATE_KEY', pattern: /-----BEGIN (?:RSA |DSA |EC |OPENSSH |)PRIVATE KEY-----/u },
19
+ { code: 'NPM_TOKEN', pattern: /\/\/registry\.npmjs\.org\/:_authToken=(?!\$\{NODE_AUTH_TOKEN\})\S+/u },
20
+ { code: 'OPENAI_KEY', pattern: /\bsk-[A-Za-z0-9_-]{24,}\b/u },
21
+ { code: 'GITHUB_TOKEN', pattern: /\bgh[pousr]_[A-Za-z0-9_]{24,}\b/u },
22
+ { code: 'AWS_ACCESS_KEY', pattern: /\bAKIA[0-9A-Z]{16}\b/u },
23
+ ];
24
+ const SECRET_SCAN_IGNORE = [
25
+ 'node_modules/**',
26
+ 'dist/**',
27
+ 'coverage/**',
28
+ '.git/**',
29
+ '.sdd/state/**',
30
+ '.sdd/archived/**',
31
+ '.sdd/active/**',
32
+ '.sdd/planned/**',
33
+ 'pnpm-lock.yaml',
34
+ ];
35
+ export async function evaluatePackageSecurityGates(projectRoot) {
36
+ const packageJson = await readPackageJson(projectRoot);
37
+ const allowedFiles = normalizePackageFiles(packageJson.files ?? []);
38
+ const packageIssues = evaluatePackageFileAllowlist(allowedFiles);
39
+ const secretScan = await scanForHighConfidenceSecrets(projectRoot);
40
+ return {
41
+ status: packageIssues.length === 0 && secretScan.issues.length === 0 ? 'pass' : 'fail',
42
+ package_allowlist: {
43
+ status: packageIssues.length === 0 ? 'pass' : 'fail',
44
+ allowed_files: allowedFiles,
45
+ issues: packageIssues,
46
+ },
47
+ secret_scan: {
48
+ status: secretScan.issues.length === 0 ? 'pass' : 'fail',
49
+ scanned_files: secretScan.scannedFiles,
50
+ issues: secretScan.issues,
51
+ },
52
+ };
53
+ }
54
+ export function evaluatePackageFileAllowlist(files) {
55
+ const issues = [];
56
+ for (const file of files) {
57
+ const normalized = normalizePath(file);
58
+ if (FORBIDDEN_PACKAGE_FILE_PATTERNS.some((pattern) => pattern.test(normalized))) {
59
+ issues.push({
60
+ code: 'PACKAGE_FILE_FORBIDDEN',
61
+ path: normalized,
62
+ message: 'Package publish allowlist includes a forbidden path or pattern.',
63
+ });
64
+ }
65
+ }
66
+ return issues;
67
+ }
68
+ async function scanForHighConfidenceSecrets(projectRoot) {
69
+ const files = await fg(['**/*'], {
70
+ cwd: projectRoot,
71
+ onlyFiles: true,
72
+ dot: true,
73
+ ignore: SECRET_SCAN_IGNORE,
74
+ });
75
+ const issues = [];
76
+ let scannedFiles = 0;
77
+ for (const relativeFile of files) {
78
+ const normalized = normalizePath(relativeFile);
79
+ if (isBinaryLike(normalized))
80
+ continue;
81
+ if (normalized === '.npmrc' && existsSync(path.join(projectRoot, normalized))) {
82
+ issues.push({
83
+ code: 'LOCAL_NPMRC',
84
+ path: normalized,
85
+ message: 'Project-local .npmrc is not allowed in release readiness.',
86
+ });
87
+ continue;
88
+ }
89
+ const content = await fs.readFile(path.join(projectRoot, normalized), 'utf-8').catch(() => '');
90
+ scannedFiles += 1;
91
+ for (const signature of SECRET_SIGNATURES) {
92
+ if (signature.pattern.test(content)) {
93
+ issues.push({
94
+ code: signature.code,
95
+ path: normalized,
96
+ message: 'High-confidence secret signature detected.',
97
+ });
98
+ }
99
+ }
100
+ }
101
+ return { scannedFiles, issues };
102
+ }
103
+ function normalizePackageFiles(files) {
104
+ return files
105
+ .filter((file) => typeof file === 'string')
106
+ .map(normalizePath)
107
+ .filter(Boolean);
108
+ }
109
+ function normalizePath(value) {
110
+ return value.replace(/\\/gu, '/').replace(/^\.\/+/u, '').trim();
111
+ }
112
+ function isBinaryLike(fileName) {
113
+ return /\.(?:png|jpg|jpeg|gif|webp|pdf|tgz|zip|gz|br|woff2?)$/iu.test(fileName);
114
+ }
115
+ async function readPackageJson(projectRoot) {
116
+ const content = await fs.readFile(path.join(projectRoot, 'package.json'), 'utf-8');
117
+ return JSON.parse(content);
118
+ }
119
+ //# sourceMappingURL=package-security-gates.js.map
@@ -219,7 +219,7 @@ function buildInfrastructureLayer(subsystems, contexts) {
219
219
  name: 'adapters/',
220
220
  kind: 'dir',
221
221
  children: [
222
- ...(subsystems.includes('orm') ? [buildOrmSubsystem(contexts)] : []),
222
+ ...(subsystems.includes('orm') ? [buildOrmSubsystem()] : []),
223
223
  ...subsystems.filter((s) => s !== 'orm').map((subsystem) => {
224
224
  const subsystemNode = {
225
225
  name: `${subsystem}/`,
@@ -236,14 +236,14 @@ function buildInfrastructureLayer(subsystems, contexts) {
236
236
  ],
237
237
  };
238
238
  }
239
- function buildOrmSubsystem(contexts) {
239
+ function buildOrmSubsystem() {
240
240
  return {
241
241
  name: 'orm/',
242
242
  kind: 'dir',
243
243
  children: [
244
244
  { name: 'typeorm.config.ts', kind: 'file', description: 'TypeORM root configuration' },
245
245
  { name: 'typeorm-cli.datasource.ts', kind: 'file', description: 'TypeORM CLI datasource' },
246
- { name: 'typeorm.module.ts', kind: 'file', description: 'Root TypeORM module' },
246
+ { name: 'orm.module.ts', kind: 'file', description: 'Single ORM module exporting TypeORM repositories' },
247
247
  {
248
248
  name: 'entities/',
249
249
  kind: 'dir',
@@ -264,11 +264,6 @@ function buildOrmSubsystem(contexts) {
264
264
  kind: 'dir',
265
265
  children: [{ name: '<timestamp>-<action>.migration.ts', kind: 'file', description: 'Database migration' }],
266
266
  },
267
- ...contexts.map((context) => ({
268
- name: `${context}-orm.module.ts`,
269
- kind: 'file',
270
- description: `${context} TypeORM module`,
271
- })),
272
267
  ],
273
268
  };
274
269
  }