@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
@@ -0,0 +1,298 @@
1
+ import { z } from 'zod';
2
+ export declare const reversaEvidencePhaseSchema: z.ZodEnum<{
3
+ architecture: "architecture";
4
+ surface: "surface";
5
+ rules: "rules";
6
+ data: "data";
7
+ migration: "migration";
8
+ equivalence: "equivalence";
9
+ intake: "intake";
10
+ ux: "ux";
11
+ artifact_generation: "artifact_generation";
12
+ reconstruction: "reconstruction";
13
+ }>;
14
+ export declare const reversaConfidenceSchema: z.ZodEnum<{
15
+ unknown: "unknown";
16
+ low: "low";
17
+ medium: "medium";
18
+ high: "high";
19
+ }>;
20
+ export declare const reversaSourceAttestationSchema: z.ZodObject<{
21
+ source_ref: z.ZodString;
22
+ source_type: z.ZodEnum<{
23
+ config: "config";
24
+ repository: "repository";
25
+ document: "document";
26
+ runtime_log: "runtime_log";
27
+ database_schema: "database_schema";
28
+ manual_note: "manual_note";
29
+ }>;
30
+ trust_level: z.ZodEnum<{
31
+ trusted: "trusted";
32
+ untrusted: "untrusted";
33
+ hostile: "hostile";
34
+ }>;
35
+ sha256: z.ZodOptional<z.ZodString>;
36
+ redaction_status: z.ZodEnum<{
37
+ blocked: "blocked";
38
+ redacted: "redacted";
39
+ not_required: "not_required";
40
+ }>;
41
+ notes: z.ZodOptional<z.ZodString>;
42
+ }, z.core.$strip>;
43
+ export declare const reversaEvidenceFindingSchema: z.ZodObject<{
44
+ id: z.ZodString;
45
+ phase: z.ZodEnum<{
46
+ architecture: "architecture";
47
+ surface: "surface";
48
+ rules: "rules";
49
+ data: "data";
50
+ migration: "migration";
51
+ equivalence: "equivalence";
52
+ intake: "intake";
53
+ ux: "ux";
54
+ artifact_generation: "artifact_generation";
55
+ reconstruction: "reconstruction";
56
+ }>;
57
+ title: z.ZodString;
58
+ summary: z.ZodString;
59
+ confidence: z.ZodEnum<{
60
+ unknown: "unknown";
61
+ low: "low";
62
+ medium: "medium";
63
+ high: "high";
64
+ }>;
65
+ source_refs: z.ZodArray<z.ZodString>;
66
+ contradiction_refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
67
+ promoted_refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
68
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
69
+ }, z.core.$strip>;
70
+ export declare const reversaEvidenceArtifactSchema: z.ZodObject<{
71
+ path: z.ZodString;
72
+ artifact_type: z.ZodEnum<{
73
+ inventory: "inventory";
74
+ architecture_map: "architecture_map";
75
+ business_rules: "business_rules";
76
+ data_model: "data_model";
77
+ ux_map: "ux_map";
78
+ generated_sdd_artifact: "generated_sdd_artifact";
79
+ migration_plan: "migration_plan";
80
+ reconstruction_diff: "reconstruction_diff";
81
+ equivalence_report: "equivalence_report";
82
+ question_set: "question_set";
83
+ }>;
84
+ phase: z.ZodEnum<{
85
+ architecture: "architecture";
86
+ surface: "surface";
87
+ rules: "rules";
88
+ data: "data";
89
+ migration: "migration";
90
+ equivalence: "equivalence";
91
+ intake: "intake";
92
+ ux: "ux";
93
+ artifact_generation: "artifact_generation";
94
+ reconstruction: "reconstruction";
95
+ }>;
96
+ checksum_sha256: z.ZodOptional<z.ZodString>;
97
+ produced_by: z.ZodString;
98
+ write_scope: z.ZodEnum<{
99
+ dry_run: "dry_run";
100
+ read_only: "read_only";
101
+ sandbox: "sandbox";
102
+ approved_apply: "approved_apply";
103
+ }>;
104
+ }, z.core.$strip>;
105
+ export declare const reversaEvidenceValidationSchema: z.ZodObject<{
106
+ id: z.ZodString;
107
+ phase: z.ZodEnum<{
108
+ architecture: "architecture";
109
+ surface: "surface";
110
+ rules: "rules";
111
+ data: "data";
112
+ migration: "migration";
113
+ equivalence: "equivalence";
114
+ intake: "intake";
115
+ ux: "ux";
116
+ artifact_generation: "artifact_generation";
117
+ reconstruction: "reconstruction";
118
+ }>;
119
+ command: z.ZodString;
120
+ status: z.ZodEnum<{
121
+ blocked: "blocked";
122
+ warning: "warning";
123
+ failed: "failed";
124
+ passed: "passed";
125
+ skipped: "skipped";
126
+ }>;
127
+ evidence_ref: z.ZodOptional<z.ZodString>;
128
+ issue_codes: z.ZodDefault<z.ZodArray<z.ZodString>>;
129
+ }, z.core.$strip>;
130
+ export declare const reversaEvidenceBundleSchema: z.ZodObject<{
131
+ schema_version: z.ZodLiteral<1>;
132
+ contract: z.ZodLiteral<"reversa-evidence-bundle/v1">;
133
+ operation_id: z.ZodString;
134
+ generated_at: z.ZodString;
135
+ feature_ref: z.ZodString;
136
+ mode: z.ZodEnum<{
137
+ validate: "validate";
138
+ "read-only": "read-only";
139
+ plan: "plan";
140
+ "apply-sandbox": "apply-sandbox";
141
+ "apply-approved": "apply-approved";
142
+ }>;
143
+ source_attestations: z.ZodArray<z.ZodObject<{
144
+ source_ref: z.ZodString;
145
+ source_type: z.ZodEnum<{
146
+ config: "config";
147
+ repository: "repository";
148
+ document: "document";
149
+ runtime_log: "runtime_log";
150
+ database_schema: "database_schema";
151
+ manual_note: "manual_note";
152
+ }>;
153
+ trust_level: z.ZodEnum<{
154
+ trusted: "trusted";
155
+ untrusted: "untrusted";
156
+ hostile: "hostile";
157
+ }>;
158
+ sha256: z.ZodOptional<z.ZodString>;
159
+ redaction_status: z.ZodEnum<{
160
+ blocked: "blocked";
161
+ redacted: "redacted";
162
+ not_required: "not_required";
163
+ }>;
164
+ notes: z.ZodOptional<z.ZodString>;
165
+ }, z.core.$strip>>;
166
+ findings: z.ZodDefault<z.ZodArray<z.ZodObject<{
167
+ id: z.ZodString;
168
+ phase: z.ZodEnum<{
169
+ architecture: "architecture";
170
+ surface: "surface";
171
+ rules: "rules";
172
+ data: "data";
173
+ migration: "migration";
174
+ equivalence: "equivalence";
175
+ intake: "intake";
176
+ ux: "ux";
177
+ artifact_generation: "artifact_generation";
178
+ reconstruction: "reconstruction";
179
+ }>;
180
+ title: z.ZodString;
181
+ summary: z.ZodString;
182
+ confidence: z.ZodEnum<{
183
+ unknown: "unknown";
184
+ low: "low";
185
+ medium: "medium";
186
+ high: "high";
187
+ }>;
188
+ source_refs: z.ZodArray<z.ZodString>;
189
+ contradiction_refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
190
+ promoted_refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
191
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
192
+ }, z.core.$strip>>>;
193
+ artifacts: z.ZodDefault<z.ZodArray<z.ZodObject<{
194
+ path: z.ZodString;
195
+ artifact_type: z.ZodEnum<{
196
+ inventory: "inventory";
197
+ architecture_map: "architecture_map";
198
+ business_rules: "business_rules";
199
+ data_model: "data_model";
200
+ ux_map: "ux_map";
201
+ generated_sdd_artifact: "generated_sdd_artifact";
202
+ migration_plan: "migration_plan";
203
+ reconstruction_diff: "reconstruction_diff";
204
+ equivalence_report: "equivalence_report";
205
+ question_set: "question_set";
206
+ }>;
207
+ phase: z.ZodEnum<{
208
+ architecture: "architecture";
209
+ surface: "surface";
210
+ rules: "rules";
211
+ data: "data";
212
+ migration: "migration";
213
+ equivalence: "equivalence";
214
+ intake: "intake";
215
+ ux: "ux";
216
+ artifact_generation: "artifact_generation";
217
+ reconstruction: "reconstruction";
218
+ }>;
219
+ checksum_sha256: z.ZodOptional<z.ZodString>;
220
+ produced_by: z.ZodString;
221
+ write_scope: z.ZodEnum<{
222
+ dry_run: "dry_run";
223
+ read_only: "read_only";
224
+ sandbox: "sandbox";
225
+ approved_apply: "approved_apply";
226
+ }>;
227
+ }, z.core.$strip>>>;
228
+ validations: z.ZodDefault<z.ZodArray<z.ZodObject<{
229
+ id: z.ZodString;
230
+ phase: z.ZodEnum<{
231
+ architecture: "architecture";
232
+ surface: "surface";
233
+ rules: "rules";
234
+ data: "data";
235
+ migration: "migration";
236
+ equivalence: "equivalence";
237
+ intake: "intake";
238
+ ux: "ux";
239
+ artifact_generation: "artifact_generation";
240
+ reconstruction: "reconstruction";
241
+ }>;
242
+ command: z.ZodString;
243
+ status: z.ZodEnum<{
244
+ blocked: "blocked";
245
+ warning: "warning";
246
+ failed: "failed";
247
+ passed: "passed";
248
+ skipped: "skipped";
249
+ }>;
250
+ evidence_ref: z.ZodOptional<z.ZodString>;
251
+ issue_codes: z.ZodDefault<z.ZodArray<z.ZodString>>;
252
+ }, z.core.$strip>>>;
253
+ contradictions: z.ZodDefault<z.ZodArray<z.ZodObject<{
254
+ id: z.ZodString;
255
+ finding_refs: z.ZodArray<z.ZodString>;
256
+ summary: z.ZodString;
257
+ resolution_status: z.ZodEnum<{
258
+ accepted_risk: "accepted_risk";
259
+ resolved: "resolved";
260
+ open: "open";
261
+ }>;
262
+ }, z.core.$strip>>>;
263
+ human_questions: z.ZodDefault<z.ZodArray<z.ZodObject<{
264
+ id: z.ZodString;
265
+ question: z.ZodString;
266
+ blocks_phase: z.ZodOptional<z.ZodEnum<{
267
+ architecture: "architecture";
268
+ surface: "surface";
269
+ rules: "rules";
270
+ data: "data";
271
+ migration: "migration";
272
+ equivalence: "equivalence";
273
+ intake: "intake";
274
+ ux: "ux";
275
+ artifact_generation: "artifact_generation";
276
+ reconstruction: "reconstruction";
277
+ }>>;
278
+ required_before_apply: z.ZodDefault<z.ZodBoolean>;
279
+ }, z.core.$strip>>>;
280
+ quality_refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
281
+ residual_risks: z.ZodDefault<z.ZodArray<z.ZodObject<{
282
+ code: z.ZodString;
283
+ severity: z.ZodEnum<{
284
+ low: "low";
285
+ medium: "medium";
286
+ high: "high";
287
+ critical: "critical";
288
+ }>;
289
+ description: z.ZodString;
290
+ mitigation: z.ZodString;
291
+ }, z.core.$strip>>>;
292
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
293
+ }, z.core.$strip>;
294
+ export type ReversaEvidenceBundle = z.infer<typeof reversaEvidenceBundleSchema>;
295
+ export type ReversaEvidencePhase = z.infer<typeof reversaEvidencePhaseSchema>;
296
+ export type ReversaSourceAttestation = z.infer<typeof reversaSourceAttestationSchema>;
297
+ export declare function parseReversaEvidenceBundle(input: unknown): ReversaEvidenceBundle;
298
+ //# sourceMappingURL=reversa-evidence.d.ts.map
@@ -0,0 +1,118 @@
1
+ import { z } from 'zod';
2
+ const FEATURE_REF_PATTERN = /^FEAT-\d{4}$/;
3
+ const OPERATION_ID_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
4
+ const WINDOWS_ABSOLUTE_PATH_PATTERN = /^[A-Za-z]:[\\/]/;
5
+ const jsonObjectSchema = z.record(z.string(), z.unknown());
6
+ const safeRelativePathSchema = z
7
+ .string()
8
+ .min(1)
9
+ .refine((value) => isSafeRelativePath(value), {
10
+ message: 'Path must be relative to the project root and must not contain traversal segments.',
11
+ });
12
+ export const reversaEvidencePhaseSchema = z.enum([
13
+ 'intake',
14
+ 'surface',
15
+ 'architecture',
16
+ 'rules',
17
+ 'data',
18
+ 'ux',
19
+ 'artifact_generation',
20
+ 'migration',
21
+ 'reconstruction',
22
+ 'equivalence',
23
+ ]);
24
+ export const reversaConfidenceSchema = z.enum(['high', 'medium', 'low', 'unknown']);
25
+ export const reversaSourceAttestationSchema = z.object({
26
+ source_ref: safeRelativePathSchema,
27
+ source_type: z.enum(['repository', 'document', 'config', 'runtime_log', 'database_schema', 'manual_note']),
28
+ trust_level: z.enum(['trusted', 'untrusted', 'hostile']),
29
+ sha256: z.string().min(1).optional(),
30
+ redaction_status: z.enum(['not_required', 'redacted', 'blocked']),
31
+ notes: z.string().min(1).optional(),
32
+ });
33
+ export const reversaEvidenceFindingSchema = z.object({
34
+ id: z.string().regex(/^REV-FIND-[A-Z0-9-]+$/),
35
+ phase: reversaEvidencePhaseSchema,
36
+ title: z.string().min(1),
37
+ summary: z.string().min(1),
38
+ confidence: reversaConfidenceSchema,
39
+ source_refs: z.array(safeRelativePathSchema).min(1),
40
+ contradiction_refs: z.array(z.string().min(1)).default([]),
41
+ promoted_refs: z.array(z.string().min(1)).default([]),
42
+ metadata: jsonObjectSchema.default({}),
43
+ });
44
+ export const reversaEvidenceArtifactSchema = z.object({
45
+ path: safeRelativePathSchema,
46
+ artifact_type: z.enum([
47
+ 'inventory',
48
+ 'architecture_map',
49
+ 'business_rules',
50
+ 'data_model',
51
+ 'ux_map',
52
+ 'generated_sdd_artifact',
53
+ 'migration_plan',
54
+ 'reconstruction_diff',
55
+ 'equivalence_report',
56
+ 'question_set',
57
+ ]),
58
+ phase: reversaEvidencePhaseSchema,
59
+ checksum_sha256: z.string().min(1).optional(),
60
+ produced_by: z.string().min(1),
61
+ write_scope: z.enum(['read_only', 'dry_run', 'sandbox', 'approved_apply']),
62
+ });
63
+ export const reversaEvidenceValidationSchema = z.object({
64
+ id: z.string().regex(/^REV-VAL-[A-Z0-9-]+$/),
65
+ phase: reversaEvidencePhaseSchema,
66
+ command: z.string().min(1),
67
+ status: z.enum(['passed', 'warning', 'failed', 'blocked', 'skipped']),
68
+ evidence_ref: safeRelativePathSchema.optional(),
69
+ issue_codes: z.array(z.string().regex(/^[A-Z][A-Z0-9_]*$/)).default([]),
70
+ });
71
+ export const reversaEvidenceBundleSchema = z.object({
72
+ schema_version: z.literal(1),
73
+ contract: z.literal('reversa-evidence-bundle/v1'),
74
+ operation_id: z.string().regex(OPERATION_ID_PATTERN),
75
+ generated_at: z.string().datetime(),
76
+ feature_ref: z.string().regex(FEATURE_REF_PATTERN),
77
+ mode: z.enum(['read-only', 'plan', 'validate', 'apply-sandbox', 'apply-approved']),
78
+ source_attestations: z.array(reversaSourceAttestationSchema).min(1),
79
+ findings: z.array(reversaEvidenceFindingSchema).default([]),
80
+ artifacts: z.array(reversaEvidenceArtifactSchema).default([]),
81
+ validations: z.array(reversaEvidenceValidationSchema).default([]),
82
+ contradictions: z
83
+ .array(z.object({
84
+ id: z.string().regex(/^REV-CONTRA-[A-Z0-9-]+$/),
85
+ finding_refs: z.array(z.string().min(1)).min(2),
86
+ summary: z.string().min(1),
87
+ resolution_status: z.enum(['open', 'resolved', 'accepted_risk']),
88
+ }))
89
+ .default([]),
90
+ human_questions: z
91
+ .array(z.object({
92
+ id: z.string().regex(/^REV-Q-[A-Z0-9-]+$/),
93
+ question: z.string().min(1),
94
+ blocks_phase: reversaEvidencePhaseSchema.optional(),
95
+ required_before_apply: z.boolean().default(false),
96
+ }))
97
+ .default([]),
98
+ quality_refs: z.array(safeRelativePathSchema).default([]),
99
+ residual_risks: z
100
+ .array(z.object({
101
+ code: z.string().regex(/^[A-Z][A-Z0-9_]*$/),
102
+ severity: z.enum(['low', 'medium', 'high', 'critical']),
103
+ description: z.string().min(1),
104
+ mitigation: z.string().min(1),
105
+ }))
106
+ .default([]),
107
+ metadata: jsonObjectSchema.default({}),
108
+ });
109
+ export function parseReversaEvidenceBundle(input) {
110
+ return reversaEvidenceBundleSchema.parse(input);
111
+ }
112
+ function isSafeRelativePath(value) {
113
+ if (value.startsWith('/') || WINDOWS_ABSOLUTE_PATH_PATTERN.test(value)) {
114
+ return false;
115
+ }
116
+ return !value.split(/[\\/]+/u).some((segment) => segment === '..');
117
+ }
118
+ //# sourceMappingURL=reversa-evidence.js.map
@@ -0,0 +1,29 @@
1
+ import type { ReversaArtifactWritePlan } from './reversa-artifact-writer.js';
2
+ export interface ReversaReconstructionPlan {
3
+ schema_version: 1;
4
+ contract: 'reversa-reconstruction-plan/v1';
5
+ feature_ref: string;
6
+ mode: 'apply-sandbox' | 'apply-approved';
7
+ status: 'ready' | 'blocked';
8
+ migration_steps: Array<{
9
+ id: string;
10
+ description: string;
11
+ evidence_ref: string;
12
+ }>;
13
+ sandbox_writes: Array<{
14
+ path: string;
15
+ source_draft_ref: string;
16
+ }>;
17
+ rollback_manifest: {
18
+ required: true;
19
+ path: string;
20
+ rollback_steps: string[];
21
+ };
22
+ blocked_reasons: string[];
23
+ }
24
+ export declare function buildReversaReconstructionPlan(input: {
25
+ writePlan: ReversaArtifactWritePlan;
26
+ mode: 'apply-sandbox' | 'apply-approved';
27
+ approval?: 'reversa-apply';
28
+ }): ReversaReconstructionPlan;
29
+ //# sourceMappingURL=reversa-reconstruction.d.ts.map
@@ -0,0 +1,32 @@
1
+ export function buildReversaReconstructionPlan(input) {
2
+ const blockedReasons = [];
3
+ if (input.writePlan.status === 'needs_clarification') {
4
+ blockedReasons.push('Human clarification is required before reconstruction.');
5
+ }
6
+ if (input.mode === 'apply-approved' && input.approval !== 'reversa-apply') {
7
+ blockedReasons.push('apply-approved reconstruction requires reversa-apply approval.');
8
+ }
9
+ return {
10
+ schema_version: 1,
11
+ contract: 'reversa-reconstruction-plan/v1',
12
+ feature_ref: input.writePlan.feature_ref,
13
+ mode: input.mode,
14
+ status: blockedReasons.length === 0 ? 'ready' : 'blocked',
15
+ migration_steps: input.writePlan.draft_artifacts.map((artifact, index) => ({
16
+ id: `REV-MIG-${String(index + 1).padStart(3, '0')}`,
17
+ description: `Review and reconstruct ${artifact.title} from ${artifact.source_finding_ref}.`,
18
+ evidence_ref: artifact.path,
19
+ })),
20
+ sandbox_writes: input.writePlan.draft_artifacts.map((artifact) => ({
21
+ path: `.sdd/evidence/reversa/${input.writePlan.feature_ref}/sandbox/${artifact.source_finding_ref.toLowerCase()}.yaml`,
22
+ source_draft_ref: artifact.path,
23
+ })),
24
+ rollback_manifest: {
25
+ required: true,
26
+ path: `.sdd/evidence/reversa/${input.writePlan.feature_ref}/rollback-manifest.yaml`,
27
+ rollback_steps: ['remove sandbox writes', 'restore previous generated drafts', 'rerun equivalence gate'],
28
+ },
29
+ blocked_reasons: blockedReasons,
30
+ };
31
+ }
32
+ //# sourceMappingURL=reversa-reconstruction.js.map
@@ -0,0 +1,12 @@
1
+ import type { ReversaEvidenceBundle } from './reversa-evidence.js';
2
+ export interface ReversaRuleSource {
3
+ path: string;
4
+ content: string;
5
+ }
6
+ export declare function buildReversaRulesInventory(input: {
7
+ featureRef: string;
8
+ operationId: string;
9
+ generatedAt: string;
10
+ sources: ReversaRuleSource[];
11
+ }): ReversaEvidenceBundle;
12
+ //# sourceMappingURL=reversa-rules-extractor.d.ts.map
@@ -0,0 +1,86 @@
1
+ import { attestReversaSource } from './reversa-source-safety.js';
2
+ export function buildReversaRulesInventory(input) {
3
+ const accepted = input.sources
4
+ .map((source) => ({ source, attestation: attestReversaSource({ sourcePath: source.path, content: source.content }) }))
5
+ .filter((entry) => entry.attestation.status === 'accepted' && entry.attestation.attestation);
6
+ const blockedCount = input.sources.length - accepted.length;
7
+ const rules = accepted.flatMap(({ source, attestation }) => scanRules(attestation.normalized_path, source.content));
8
+ const workflows = accepted.flatMap(({ source, attestation }) => scanWorkflows(attestation.normalized_path, source.content));
9
+ const findings = [];
10
+ if (rules.length > 0) {
11
+ findings.push({
12
+ id: 'REV-FIND-RULES-INVARIANTS',
13
+ phase: 'rules',
14
+ title: 'Business rules and invariants',
15
+ summary: `Detected ${rules.length} rule, validation or invariant candidates.`,
16
+ confidence: 'medium',
17
+ source_refs: unique(rules.map((entry) => entry.source_ref)),
18
+ contradiction_refs: [],
19
+ promoted_refs: [],
20
+ metadata: { rules },
21
+ });
22
+ }
23
+ if (workflows.length > 0) {
24
+ findings.push({
25
+ id: 'REV-FIND-RULES-WORKFLOWS',
26
+ phase: 'rules',
27
+ title: 'Workflow transitions',
28
+ summary: `Detected ${workflows.length} workflow or state transition candidates.`,
29
+ confidence: 'medium',
30
+ source_refs: unique(workflows.map((entry) => entry.source_ref)),
31
+ contradiction_refs: [],
32
+ promoted_refs: [],
33
+ metadata: { workflows },
34
+ });
35
+ }
36
+ return {
37
+ schema_version: 1,
38
+ contract: 'reversa-evidence-bundle/v1',
39
+ operation_id: input.operationId,
40
+ generated_at: input.generatedAt,
41
+ feature_ref: input.featureRef,
42
+ mode: 'read-only',
43
+ source_attestations: accepted.map((entry) => entry.attestation.attestation),
44
+ findings,
45
+ artifacts: [{
46
+ path: `.sdd/evidence/reversa/${input.featureRef}/business-rules.yaml`,
47
+ artifact_type: 'business_rules',
48
+ phase: 'rules',
49
+ produced_by: 'codesdd reversa rules extractor',
50
+ write_scope: 'read_only',
51
+ }],
52
+ validations: [{
53
+ id: 'REV-VAL-RULES-SAFETY',
54
+ phase: 'rules',
55
+ command: 'buildReversaRulesInventory',
56
+ status: blockedCount === 0 ? 'passed' : 'blocked',
57
+ issue_codes: blockedCount === 0 ? [] : ['UNSAFE_SOURCE_BLOCKED'],
58
+ }],
59
+ contradictions: [],
60
+ human_questions: rules.length === 0 ? [{
61
+ id: 'REV-Q-RULES-MISSING',
62
+ question: 'No explicit business rules were detected. Which workflows or invariants should be reviewed manually?',
63
+ blocks_phase: 'artifact_generation',
64
+ required_before_apply: true,
65
+ }] : [],
66
+ quality_refs: [`.sdd/active/${input.featureRef}/5-quality.yaml`],
67
+ residual_risks: [],
68
+ metadata: { rule_count: rules.length, workflow_count: workflows.length },
69
+ };
70
+ }
71
+ function scanRules(sourceRef, content) {
72
+ return [...content.matchAll(/\b(?:if|validate|ensure|invariant|policy|rule|throw new)\b[^\n;]*/giu)].map((match) => ({
73
+ expression: match[0].trim(),
74
+ source_ref: sourceRef,
75
+ }));
76
+ }
77
+ function scanWorkflows(sourceRef, content) {
78
+ return [...content.matchAll(/\b(?:status|state|stage)\s*=\s*['"]?([A-Za-z0-9_-]+)['"]?/giu)].map((match) => ({
79
+ state: match[1] ?? 'unknown',
80
+ source_ref: sourceRef,
81
+ }));
82
+ }
83
+ function unique(values) {
84
+ return [...new Set(values)];
85
+ }
86
+ //# sourceMappingURL=reversa-rules-extractor.js.map
@@ -0,0 +1,19 @@
1
+ import { type ReversaSourceAttestation } from './reversa-evidence.js';
2
+ export interface ReversaSourceIntakeInput {
3
+ sourcePath: string;
4
+ sourceType?: ReversaSourceAttestation['source_type'];
5
+ content?: string;
6
+ trustLevel?: ReversaSourceAttestation['trust_level'];
7
+ }
8
+ export interface ReversaSourceIntakeResult {
9
+ status: 'accepted' | 'blocked';
10
+ normalized_path: string | null;
11
+ reason: string | null;
12
+ attestation: ReversaSourceAttestation | null;
13
+ redacted_content?: string;
14
+ }
15
+ export declare function attestReversaSource(input: ReversaSourceIntakeInput): ReversaSourceIntakeResult;
16
+ export declare function normalizeReversaSourcePath(value: string): string | null;
17
+ export declare function redactReversaSensitiveText(value: string): string;
18
+ export declare function isReversaCanonicalStatePath(value: string): boolean;
19
+ //# sourceMappingURL=reversa-source-safety.d.ts.map