@agentic-sdlc-kit/contracts 0.0.0-stage → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +42 -2
- package/dist/agent/capability.d.ts +9 -0
- package/dist/agent/capability.d.ts.map +1 -0
- package/dist/agent/capability.js +31 -0
- package/dist/agent/capability.js.map +1 -0
- package/dist/agent/errors.d.ts +30 -0
- package/dist/agent/errors.d.ts.map +1 -0
- package/dist/agent/errors.js +62 -0
- package/dist/agent/errors.js.map +1 -0
- package/dist/agent/events.d.ts +222 -0
- package/dist/agent/events.d.ts.map +1 -0
- package/dist/agent/events.js +92 -0
- package/dist/agent/events.js.map +1 -0
- package/dist/agent/execution.d.ts +553 -0
- package/dist/agent/execution.d.ts.map +1 -0
- package/dist/agent/execution.js +229 -0
- package/dist/agent/execution.js.map +1 -0
- package/dist/agent/index.d.ts +8 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +19 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/policy.d.ts +135 -0
- package/dist/agent/policy.d.ts.map +1 -0
- package/dist/agent/policy.js +78 -0
- package/dist/agent/policy.js.map +1 -0
- package/dist/agent/provider.d.ts +82 -0
- package/dist/agent/provider.d.ts.map +1 -0
- package/dist/agent/provider.js +33 -0
- package/dist/agent/provider.js.map +1 -0
- package/dist/agent/session.d.ts +17 -0
- package/dist/agent/session.d.ts.map +1 -0
- package/dist/agent/session.js +23 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/application/application-context.d.ts +512 -0
- package/dist/application/application-context.d.ts.map +1 -0
- package/dist/application/application-context.js +42 -0
- package/dist/application/application-context.js.map +1 -0
- package/dist/application/application-persistence.d.ts +846 -0
- package/dist/application/application-persistence.d.ts.map +1 -0
- package/dist/application/application-persistence.js +37 -0
- package/dist/application/application-persistence.js.map +1 -0
- package/dist/application/application-state.d.ts +89 -0
- package/dist/application/application-state.d.ts.map +1 -0
- package/dist/application/application-state.js +66 -0
- package/dist/application/application-state.js.map +1 -0
- package/dist/application/application-transitions.d.ts +23 -0
- package/dist/application/application-transitions.d.ts.map +1 -0
- package/dist/application/application-transitions.js +60 -0
- package/dist/application/application-transitions.js.map +1 -0
- package/dist/application/index.d.ts +5 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +6 -0
- package/dist/application/index.js.map +1 -0
- package/dist/architecture/api-contract.d.ts +259 -0
- package/dist/architecture/api-contract.d.ts.map +1 -0
- package/dist/architecture/api-contract.js +43 -0
- package/dist/architecture/api-contract.js.map +1 -0
- package/dist/architecture/architecture-approval.d.ts +40 -0
- package/dist/architecture/architecture-approval.d.ts.map +1 -0
- package/dist/architecture/architecture-approval.js +24 -0
- package/dist/architecture/architecture-approval.js.map +1 -0
- package/dist/architecture/architecture-options.d.ts +103 -0
- package/dist/architecture/architecture-options.d.ts.map +1 -0
- package/dist/architecture/architecture-options.js +35 -0
- package/dist/architecture/architecture-options.js.map +1 -0
- package/dist/architecture/component-map.d.ts +76 -0
- package/dist/architecture/component-map.d.ts.map +1 -0
- package/dist/architecture/component-map.js +28 -0
- package/dist/architecture/component-map.js.map +1 -0
- package/dist/architecture/data-model.d.ts +252 -0
- package/dist/architecture/data-model.d.ts.map +1 -0
- package/dist/architecture/data-model.js +53 -0
- package/dist/architecture/data-model.js.map +1 -0
- package/dist/architecture/index.d.ts +8 -0
- package/dist/architecture/index.d.ts.map +1 -0
- package/dist/architecture/index.js +9 -0
- package/dist/architecture/index.js.map +1 -0
- package/dist/architecture/operational-design.d.ts +134 -0
- package/dist/architecture/operational-design.d.ts.map +1 -0
- package/dist/architecture/operational-design.js +46 -0
- package/dist/architecture/operational-design.js.map +1 -0
- package/dist/architecture/security-design.d.ts +107 -0
- package/dist/architecture/security-design.d.ts.map +1 -0
- package/dist/architecture/security-design.js +40 -0
- package/dist/architecture/security-design.js.map +1 -0
- package/dist/common/errors.d.ts +40 -0
- package/dist/common/errors.d.ts.map +1 -0
- package/dist/common/errors.js +45 -0
- package/dist/common/errors.js.map +1 -0
- package/dist/common/identifier.d.ts +12 -0
- package/dist/common/identifier.d.ts.map +1 -0
- package/dist/common/identifier.js +21 -0
- package/dist/common/identifier.js.map +1 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +5 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/result.d.ts +28 -0
- package/dist/common/result.d.ts.map +1 -0
- package/dist/common/result.js +33 -0
- package/dist/common/result.js.map +1 -0
- package/dist/evaluation/benchmark.d.ts +88 -0
- package/dist/evaluation/benchmark.d.ts.map +1 -0
- package/dist/evaluation/benchmark.js +34 -0
- package/dist/evaluation/benchmark.js.map +1 -0
- package/dist/evaluation/index.d.ts +3 -0
- package/dist/evaluation/index.d.ts.map +1 -0
- package/dist/evaluation/index.js +4 -0
- package/dist/evaluation/index.js.map +1 -0
- package/dist/evaluation/metrics.d.ts +164 -0
- package/dist/evaluation/metrics.d.ts.map +1 -0
- package/dist/evaluation/metrics.js +64 -0
- package/dist/evaluation/metrics.js.map +1 -0
- package/dist/evolution/experiment.d.ts +85 -0
- package/dist/evolution/experiment.d.ts.map +1 -0
- package/dist/evolution/experiment.js +52 -0
- package/dist/evolution/experiment.js.map +1 -0
- package/dist/evolution/improvement-hypothesis.d.ts +98 -0
- package/dist/evolution/improvement-hypothesis.d.ts.map +1 -0
- package/dist/evolution/improvement-hypothesis.js +59 -0
- package/dist/evolution/improvement-hypothesis.js.map +1 -0
- package/dist/evolution/index.d.ts +3 -0
- package/dist/evolution/index.d.ts.map +1 -0
- package/dist/evolution/index.js +4 -0
- package/dist/evolution/index.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/index.d.ts +4 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +5 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/install-plan.d.ts +168 -0
- package/dist/installer/install-plan.d.ts.map +1 -0
- package/dist/installer/install-plan.js +40 -0
- package/dist/installer/install-plan.js.map +1 -0
- package/dist/installer/ownership-manifest.d.ts +78 -0
- package/dist/installer/ownership-manifest.d.ts.map +1 -0
- package/dist/installer/ownership-manifest.js +30 -0
- package/dist/installer/ownership-manifest.js.map +1 -0
- package/dist/installer/package-manifest.d.ts +55 -0
- package/dist/installer/package-manifest.d.ts.map +1 -0
- package/dist/installer/package-manifest.js +46 -0
- package/dist/installer/package-manifest.js.map +1 -0
- package/dist/learning/engineering-lesson.d.ts +84 -0
- package/dist/learning/engineering-lesson.d.ts.map +1 -0
- package/dist/learning/engineering-lesson.js +47 -0
- package/dist/learning/engineering-lesson.js.map +1 -0
- package/dist/learning/engineering-memory.d.ts +66 -0
- package/dist/learning/engineering-memory.d.ts.map +1 -0
- package/dist/learning/engineering-memory.js +44 -0
- package/dist/learning/engineering-memory.js.map +1 -0
- package/dist/learning/experience-episode.d.ts +176 -0
- package/dist/learning/experience-episode.d.ts.map +1 -0
- package/dist/learning/experience-episode.js +68 -0
- package/dist/learning/experience-episode.js.map +1 -0
- package/dist/learning/experience.d.ts +68 -0
- package/dist/learning/experience.d.ts.map +1 -0
- package/dist/learning/experience.js +22 -0
- package/dist/learning/experience.js.map +1 -0
- package/dist/learning/hypothesis.d.ts +57 -0
- package/dist/learning/hypothesis.d.ts.map +1 -0
- package/dist/learning/hypothesis.js +27 -0
- package/dist/learning/hypothesis.js.map +1 -0
- package/dist/learning/index.d.ts +8 -0
- package/dist/learning/index.d.ts.map +1 -0
- package/dist/learning/index.js +9 -0
- package/dist/learning/index.js.map +1 -0
- package/dist/learning/memory.d.ts +42 -0
- package/dist/learning/memory.d.ts.map +1 -0
- package/dist/learning/memory.js +20 -0
- package/dist/learning/memory.js.map +1 -0
- package/dist/learning/promotion.d.ts +31 -0
- package/dist/learning/promotion.d.ts.map +1 -0
- package/dist/learning/promotion.js +16 -0
- package/dist/learning/promotion.js.map +1 -0
- package/dist/maintenance/bug-fix-workflow.d.ts +57 -0
- package/dist/maintenance/bug-fix-workflow.d.ts.map +1 -0
- package/dist/maintenance/bug-fix-workflow.js +100 -0
- package/dist/maintenance/bug-fix-workflow.js.map +1 -0
- package/dist/maintenance/bug-report.d.ts +62 -0
- package/dist/maintenance/bug-report.d.ts.map +1 -0
- package/dist/maintenance/bug-report.js +49 -0
- package/dist/maintenance/bug-report.js.map +1 -0
- package/dist/maintenance/index.d.ts +6 -0
- package/dist/maintenance/index.d.ts.map +1 -0
- package/dist/maintenance/index.js +7 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/maintenance/performance-baseline.d.ts +80 -0
- package/dist/maintenance/performance-baseline.d.ts.map +1 -0
- package/dist/maintenance/performance-baseline.js +32 -0
- package/dist/maintenance/performance-baseline.js.map +1 -0
- package/dist/maintenance/refactor-contract.d.ts +158 -0
- package/dist/maintenance/refactor-contract.d.ts.map +1 -0
- package/dist/maintenance/refactor-contract.js +65 -0
- package/dist/maintenance/refactor-contract.js.map +1 -0
- package/dist/maintenance/refactor-workflow.d.ts +79 -0
- package/dist/maintenance/refactor-workflow.d.ts.map +1 -0
- package/dist/maintenance/refactor-workflow.js +100 -0
- package/dist/maintenance/refactor-workflow.js.map +1 -0
- package/dist/observer/event-schema.d.ts +49 -0
- package/dist/observer/event-schema.d.ts.map +1 -0
- package/dist/observer/event-schema.js +48 -0
- package/dist/observer/event-schema.js.map +1 -0
- package/dist/observer/index.d.ts +5 -0
- package/dist/observer/index.d.ts.map +1 -0
- package/dist/observer/index.js +6 -0
- package/dist/observer/index.js.map +1 -0
- package/dist/observer/journal.d.ts +83 -0
- package/dist/observer/journal.d.ts.map +1 -0
- package/dist/observer/journal.js +76 -0
- package/dist/observer/journal.js.map +1 -0
- package/dist/observer/retention.d.ts +25 -0
- package/dist/observer/retention.d.ts.map +1 -0
- package/dist/observer/retention.js +21 -0
- package/dist/observer/retention.js.map +1 -0
- package/dist/observer/run-summary.d.ts +260 -0
- package/dist/observer/run-summary.d.ts.map +1 -0
- package/dist/observer/run-summary.js +32 -0
- package/dist/observer/run-summary.js.map +1 -0
- package/dist/patterns/index.d.ts +2 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +3 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/patterns/pattern.d.ts +106 -0
- package/dist/patterns/pattern.d.ts.map +1 -0
- package/dist/patterns/pattern.js +69 -0
- package/dist/patterns/pattern.js.map +1 -0
- package/dist/planning/index.d.ts +2 -0
- package/dist/planning/index.d.ts.map +1 -0
- package/dist/planning/index.js +3 -0
- package/dist/planning/index.js.map +1 -0
- package/dist/planning/task.d.ts +178 -0
- package/dist/planning/task.d.ts.map +1 -0
- package/dist/planning/task.js +35 -0
- package/dist/planning/task.js.map +1 -0
- package/dist/policy/index.d.ts +2 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +3 -0
- package/dist/policy/index.js.map +1 -0
- package/dist/policy/policy.d.ts +83 -0
- package/dist/policy/policy.d.ts.map +1 -0
- package/dist/policy/policy.js +57 -0
- package/dist/policy/policy.js.map +1 -0
- package/dist/product/index.d.ts +5 -0
- package/dist/product/index.d.ts.map +1 -0
- package/dist/product/index.js +6 -0
- package/dist/product/index.js.map +1 -0
- package/dist/product/mvp-scope.d.ts +25 -0
- package/dist/product/mvp-scope.d.ts.map +1 -0
- package/dist/product/mvp-scope.js +18 -0
- package/dist/product/mvp-scope.js.map +1 -0
- package/dist/product/product-brief.d.ts +94 -0
- package/dist/product/product-brief.d.ts.map +1 -0
- package/dist/product/product-brief.js +44 -0
- package/dist/product/product-brief.js.map +1 -0
- package/dist/product/requirements.d.ts +251 -0
- package/dist/product/requirements.d.ts.map +1 -0
- package/dist/product/requirements.js +50 -0
- package/dist/product/requirements.js.map +1 -0
- package/dist/product/traceability.d.ts +50 -0
- package/dist/product/traceability.d.ts.map +1 -0
- package/dist/product/traceability.js +20 -0
- package/dist/product/traceability.js.map +1 -0
- package/dist/project/index.d.ts +3 -0
- package/dist/project/index.d.ts.map +1 -0
- package/dist/project/index.js +4 -0
- package/dist/project/index.js.map +1 -0
- package/dist/project/project-profile.d.ts +79 -0
- package/dist/project/project-profile.d.ts.map +1 -0
- package/dist/project/project-profile.js +53 -0
- package/dist/project/project-profile.js.map +1 -0
- package/dist/project/repository-scan.d.ts +82 -0
- package/dist/project/repository-scan.d.ts.map +1 -0
- package/dist/project/repository-scan.js +29 -0
- package/dist/project/repository-scan.js.map +1 -0
- package/dist/routing/capability-registry.d.ts +87 -0
- package/dist/routing/capability-registry.d.ts.map +1 -0
- package/dist/routing/capability-registry.js +26 -0
- package/dist/routing/capability-registry.js.map +1 -0
- package/dist/routing/escalation.d.ts +25 -0
- package/dist/routing/escalation.d.ts.map +1 -0
- package/dist/routing/escalation.js +21 -0
- package/dist/routing/escalation.js.map +1 -0
- package/dist/routing/index.d.ts +5 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +6 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/routing-policy.d.ts +103 -0
- package/dist/routing/routing-policy.d.ts.map +1 -0
- package/dist/routing/routing-policy.js +32 -0
- package/dist/routing/routing-policy.js.map +1 -0
- package/dist/routing/routing-request.d.ts +63 -0
- package/dist/routing/routing-request.d.ts.map +1 -0
- package/dist/routing/routing-request.js +46 -0
- package/dist/routing/routing-request.js.map +1 -0
- package/dist/runtime-guard/action-classification.d.ts +54 -0
- package/dist/runtime-guard/action-classification.d.ts.map +1 -0
- package/dist/runtime-guard/action-classification.js +90 -0
- package/dist/runtime-guard/action-classification.js.map +1 -0
- package/dist/runtime-guard/audit-event.d.ts +98 -0
- package/dist/runtime-guard/audit-event.d.ts.map +1 -0
- package/dist/runtime-guard/audit-event.js +45 -0
- package/dist/runtime-guard/audit-event.js.map +1 -0
- package/dist/runtime-guard/index.d.ts +4 -0
- package/dist/runtime-guard/index.d.ts.map +1 -0
- package/dist/runtime-guard/index.js +5 -0
- package/dist/runtime-guard/index.js.map +1 -0
- package/dist/runtime-guard/policy-schema.d.ts +139 -0
- package/dist/runtime-guard/policy-schema.d.ts.map +1 -0
- package/dist/runtime-guard/policy-schema.js +50 -0
- package/dist/runtime-guard/policy-schema.js.map +1 -0
- package/dist/scaffolding/index.d.ts +3 -0
- package/dist/scaffolding/index.d.ts.map +1 -0
- package/dist/scaffolding/index.js +4 -0
- package/dist/scaffolding/index.js.map +1 -0
- package/dist/scaffolding/scaffold-contract.d.ts +528 -0
- package/dist/scaffolding/scaffold-contract.d.ts.map +1 -0
- package/dist/scaffolding/scaffold-contract.js +50 -0
- package/dist/scaffolding/scaffold-contract.js.map +1 -0
- package/dist/scaffolding/template-manifest.d.ts +105 -0
- package/dist/scaffolding/template-manifest.d.ts.map +1 -0
- package/dist/scaffolding/template-manifest.js +44 -0
- package/dist/scaffolding/template-manifest.js.map +1 -0
- package/dist/secret-guard/detection-rule.d.ts +33 -0
- package/dist/secret-guard/detection-rule.d.ts.map +1 -0
- package/dist/secret-guard/detection-rule.js +109 -0
- package/dist/secret-guard/detection-rule.js.map +1 -0
- package/dist/secret-guard/finding.d.ts +89 -0
- package/dist/secret-guard/finding.d.ts.map +1 -0
- package/dist/secret-guard/finding.js +85 -0
- package/dist/secret-guard/finding.js.map +1 -0
- package/dist/secret-guard/index.d.ts +5 -0
- package/dist/secret-guard/index.d.ts.map +1 -0
- package/dist/secret-guard/index.js +6 -0
- package/dist/secret-guard/index.js.map +1 -0
- package/dist/secret-guard/redaction-policy.d.ts +26 -0
- package/dist/secret-guard/redaction-policy.d.ts.map +1 -0
- package/dist/secret-guard/redaction-policy.js +30 -0
- package/dist/secret-guard/redaction-policy.js.map +1 -0
- package/dist/secret-guard/scanner-failure.d.ts +59 -0
- package/dist/secret-guard/scanner-failure.d.ts.map +1 -0
- package/dist/secret-guard/scanner-failure.js +40 -0
- package/dist/secret-guard/scanner-failure.js.map +1 -0
- package/dist/specification/index.d.ts +2 -0
- package/dist/specification/index.d.ts.map +1 -0
- package/dist/specification/index.js +3 -0
- package/dist/specification/index.js.map +1 -0
- package/dist/specification/specification.d.ts +229 -0
- package/dist/specification/specification.d.ts.map +1 -0
- package/dist/specification/specification.js +67 -0
- package/dist/specification/specification.js.map +1 -0
- package/dist/stack-pack/index.d.ts +2 -0
- package/dist/stack-pack/index.d.ts.map +1 -0
- package/dist/stack-pack/index.js +3 -0
- package/dist/stack-pack/index.js.map +1 -0
- package/dist/stack-pack/manifest.d.ts +88 -0
- package/dist/stack-pack/manifest.d.ts.map +1 -0
- package/dist/stack-pack/manifest.js +51 -0
- package/dist/stack-pack/manifest.js.map +1 -0
- package/dist/verification/index.d.ts +2 -0
- package/dist/verification/index.d.ts.map +1 -0
- package/dist/verification/index.js +3 -0
- package/dist/verification/index.js.map +1 -0
- package/dist/verification/report.d.ts +95 -0
- package/dist/verification/report.d.ts.map +1 -0
- package/dist/verification/report.js +57 -0
- package/dist/verification/report.js.map +1 -0
- package/dist/workflow/index.d.ts +3 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +4 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/next-action.d.ts +130 -0
- package/dist/workflow/next-action.d.ts.map +1 -0
- package/dist/workflow/next-action.js +92 -0
- package/dist/workflow/next-action.js.map +1 -0
- package/dist/workflow/workflow.d.ts +68 -0
- package/dist/workflow/workflow.d.ts.map +1 -0
- package/dist/workflow/workflow.js +33 -0
- package/dist/workflow/workflow.js.map +1 -0
- package/package.json +31 -3
- package/src/agent/agent.test.ts +451 -0
- package/src/agent/capability.ts +35 -0
- package/src/agent/errors.ts +69 -0
- package/src/agent/events.ts +107 -0
- package/src/agent/execution.ts +275 -0
- package/src/agent/index.ts +19 -0
- package/src/agent/policy.ts +82 -0
- package/src/agent/provider.ts +124 -0
- package/src/agent/session.ts +29 -0
- package/src/application/application-context.ts +47 -0
- package/src/application/application-persistence.ts +44 -0
- package/src/application/application-state.test.ts +107 -0
- package/src/application/application-state.ts +81 -0
- package/src/application/application-transitions.ts +71 -0
- package/src/application/index.ts +5 -0
- package/src/architecture/api-contract.ts +56 -0
- package/src/architecture/architecture-approval.ts +27 -0
- package/src/architecture/architecture-options.ts +42 -0
- package/src/architecture/architecture.test.ts +263 -0
- package/src/architecture/component-map.ts +35 -0
- package/src/architecture/data-model.ts +66 -0
- package/src/architecture/index.ts +8 -0
- package/src/architecture/operational-design.ts +55 -0
- package/src/architecture/security-design.ts +47 -0
- package/src/common/errors.test.ts +46 -0
- package/src/common/errors.ts +114 -0
- package/src/common/identifier.test.ts +51 -0
- package/src/common/identifier.ts +33 -0
- package/src/common/index.ts +4 -0
- package/src/common/result.test.ts +52 -0
- package/src/common/result.ts +50 -0
- package/src/evaluation/benchmark.ts +42 -0
- package/src/evaluation/index.ts +3 -0
- package/src/evaluation/metrics.ts +76 -0
- package/src/evolution/experiment.ts +61 -0
- package/src/evolution/improvement-hypothesis.ts +67 -0
- package/src/evolution/index.ts +3 -0
- package/src/index.test.ts +54 -0
- package/src/index.ts +53 -0
- package/src/installer/index.ts +4 -0
- package/src/installer/install-plan.ts +49 -0
- package/src/installer/ownership-manifest.ts +36 -0
- package/src/installer/package-manifest.ts +54 -0
- package/src/learning/engineering-lesson.ts +55 -0
- package/src/learning/engineering-memory.ts +51 -0
- package/src/learning/experience-episode.ts +76 -0
- package/src/learning/experience.ts +27 -0
- package/src/learning/hypothesis.ts +33 -0
- package/src/learning/index.ts +8 -0
- package/src/learning/memory.ts +25 -0
- package/src/learning/promotion.ts +19 -0
- package/src/maintenance/bug-fix-workflow.ts +119 -0
- package/src/maintenance/bug-report.ts +58 -0
- package/src/maintenance/index.ts +6 -0
- package/src/maintenance/maintenance.test.ts +219 -0
- package/src/maintenance/performance-baseline.ts +35 -0
- package/src/maintenance/refactor-contract.ts +77 -0
- package/src/maintenance/refactor-workflow.ts +121 -0
- package/src/observer/event-schema.ts +54 -0
- package/src/observer/index.ts +5 -0
- package/src/observer/journal.test.ts +73 -0
- package/src/observer/journal.ts +84 -0
- package/src/observer/retention.ts +24 -0
- package/src/observer/run-summary.ts +37 -0
- package/src/patterns/index.ts +2 -0
- package/src/patterns/pattern.ts +80 -0
- package/src/planning/index.ts +2 -0
- package/src/planning/task.ts +47 -0
- package/src/policy/index.ts +2 -0
- package/src/policy/policy.test.ts +50 -0
- package/src/policy/policy.ts +67 -0
- package/src/product/index.ts +5 -0
- package/src/product/mvp-scope.ts +21 -0
- package/src/product/product-brief.test.ts +108 -0
- package/src/product/product-brief.ts +53 -0
- package/src/product/requirements.ts +59 -0
- package/src/product/traceability.ts +25 -0
- package/src/project/index.ts +3 -0
- package/src/project/project-profile.test.ts +98 -0
- package/src/project/project-profile.ts +65 -0
- package/src/project/repository-scan.ts +34 -0
- package/src/routing/capability-registry.ts +31 -0
- package/src/routing/escalation.ts +24 -0
- package/src/routing/index.ts +5 -0
- package/src/routing/routing-policy.ts +38 -0
- package/src/routing/routing-request.ts +55 -0
- package/src/runtime-guard/action-classification.ts +99 -0
- package/src/runtime-guard/audit-event.ts +49 -0
- package/src/runtime-guard/index.ts +4 -0
- package/src/runtime-guard/policy-schema.ts +56 -0
- package/src/runtime-guard/runtime-guard.test.ts +147 -0
- package/src/scaffolding/index.ts +3 -0
- package/src/scaffolding/scaffold-contract.test.ts +107 -0
- package/src/scaffolding/scaffold-contract.ts +63 -0
- package/src/scaffolding/template-manifest.ts +52 -0
- package/src/secret-guard/detection-rule.ts +115 -0
- package/src/secret-guard/finding.ts +93 -0
- package/src/secret-guard/index.ts +5 -0
- package/src/secret-guard/redaction-policy.ts +34 -0
- package/src/secret-guard/scanner-failure.ts +47 -0
- package/src/secret-guard/secret-guard.test.ts +130 -0
- package/src/specification/index.ts +2 -0
- package/src/specification/specification.ts +79 -0
- package/src/stack-pack/index.ts +2 -0
- package/src/stack-pack/manifest.ts +60 -0
- package/src/verification/index.ts +2 -0
- package/src/verification/report.test.ts +91 -0
- package/src/verification/report.ts +62 -0
- package/src/workflow/index.ts +3 -0
- package/src/workflow/next-action.test.ts +101 -0
- package/src/workflow/next-action.ts +101 -0
- package/src/workflow/workflow.ts +49 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// packages/contracts/src/architecture/data-model.ts
|
|
2
|
+
//
|
|
3
|
+
// Entity-relationship and data definitions (M8 Phase C — M8-14).
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
export const DataTypeSchema = z.enum([
|
|
8
|
+
'string',
|
|
9
|
+
'text',
|
|
10
|
+
'integer',
|
|
11
|
+
'decimal',
|
|
12
|
+
'boolean',
|
|
13
|
+
'datetime',
|
|
14
|
+
'date',
|
|
15
|
+
'uuid',
|
|
16
|
+
'json',
|
|
17
|
+
'binary',
|
|
18
|
+
'enum',
|
|
19
|
+
'reference',
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
export const FieldSchema = z.object({
|
|
23
|
+
name: z.string().min(1),
|
|
24
|
+
type: DataTypeSchema,
|
|
25
|
+
required: z.boolean(),
|
|
26
|
+
unique: z.boolean().default(false),
|
|
27
|
+
indexed: z.boolean().default(false),
|
|
28
|
+
// For type === "reference": the referenced entity ID.
|
|
29
|
+
references: z.string().optional(),
|
|
30
|
+
// For type === "enum": the allowed values.
|
|
31
|
+
enumValues: z.array(z.string()).optional(),
|
|
32
|
+
defaultValue: z.unknown().optional(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const EntitySchema = z.object({
|
|
36
|
+
id: z.string(),
|
|
37
|
+
name: z.string().min(1),
|
|
38
|
+
fields: z.array(FieldSchema).min(1),
|
|
39
|
+
// Soft-delete, audit, multi-tenant, etc.
|
|
40
|
+
conventions: z.array(z.string()).default([]),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const RelationshipKindSchema = z.enum(['one-to-one', 'one-to-many', 'many-to-many']);
|
|
44
|
+
|
|
45
|
+
export const RelationshipSchema = z.object({
|
|
46
|
+
id: z.string(),
|
|
47
|
+
fromEntityId: z.string(),
|
|
48
|
+
toEntityId: z.string(),
|
|
49
|
+
kind: RelationshipKindSchema,
|
|
50
|
+
// Whether the relationship is enforced at the DB level or in app code.
|
|
51
|
+
enforcedAt: z.enum(['database', 'application']),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const DataModelSchema = z.object({
|
|
55
|
+
schemaVersion: z.literal(1),
|
|
56
|
+
briefId: z.string(),
|
|
57
|
+
entities: z.array(EntitySchema),
|
|
58
|
+
relationships: z.array(RelationshipSchema),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export type DataType = z.infer<typeof DataTypeSchema>;
|
|
62
|
+
export type Field = z.infer<typeof FieldSchema>;
|
|
63
|
+
export type Entity = z.infer<typeof EntitySchema>;
|
|
64
|
+
export type RelationshipKind = z.infer<typeof RelationshipKindSchema>;
|
|
65
|
+
export type Relationship = z.infer<typeof RelationshipSchema>;
|
|
66
|
+
export type DataModel = z.infer<typeof DataModelSchema>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// packages/contracts/src/architecture/index.ts
|
|
2
|
+
export * from './architecture-options.js';
|
|
3
|
+
export * from './component-map.js';
|
|
4
|
+
export * from './data-model.js';
|
|
5
|
+
export * from './api-contract.js';
|
|
6
|
+
export * from './security-design.js';
|
|
7
|
+
export * from './operational-design.js';
|
|
8
|
+
export * from './architecture-approval.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// packages/contracts/src/architecture/operational-design.ts
|
|
2
|
+
//
|
|
3
|
+
// Operational design contract (M8 Phase C — M8-18).
|
|
4
|
+
// Deployment, configuration, observability plan.
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
export const DeploymentTargetSchema = z.enum([
|
|
9
|
+
'container-orchestrated',
|
|
10
|
+
'container-single-host',
|
|
11
|
+
'serverless',
|
|
12
|
+
'paas',
|
|
13
|
+
'self-hosted-vm',
|
|
14
|
+
'static-hosting',
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
export const ObservabilityChannelSchema = z.enum(['logs', 'metrics', 'traces', 'events']);
|
|
18
|
+
|
|
19
|
+
export const OperationalDesignSchema = z.object({
|
|
20
|
+
schemaVersion: z.literal(1),
|
|
21
|
+
briefId: z.string(),
|
|
22
|
+
deployment: z.object({
|
|
23
|
+
target: DeploymentTargetSchema,
|
|
24
|
+
rationale: z.string().min(1),
|
|
25
|
+
regions: z.array(z.string()).default([]),
|
|
26
|
+
}),
|
|
27
|
+
configuration: z.object({
|
|
28
|
+
// How the app loads config (env, file, secret manager).
|
|
29
|
+
source: z.enum(['env', 'file', 'secret-manager', 'mixed']),
|
|
30
|
+
// Schema for the config variables (names only — never values).
|
|
31
|
+
variables: z.array(
|
|
32
|
+
z.object({
|
|
33
|
+
name: z.string(),
|
|
34
|
+
required: z.boolean(),
|
|
35
|
+
sensitive: z.boolean(),
|
|
36
|
+
description: z.string(),
|
|
37
|
+
}),
|
|
38
|
+
),
|
|
39
|
+
}),
|
|
40
|
+
observability: z.object({
|
|
41
|
+
channels: z.array(ObservabilityChannelSchema),
|
|
42
|
+
sinks: z.array(z.string()),
|
|
43
|
+
// Sampling rate for traces (0.0 to 1.0). Documented as a string to
|
|
44
|
+
// avoid float precision issues in JSON.
|
|
45
|
+
traceSampling: z.string().optional(),
|
|
46
|
+
}),
|
|
47
|
+
scaling: z.object({
|
|
48
|
+
strategy: z.enum(['horizontal', 'vertical', 'none']),
|
|
49
|
+
triggers: z.array(z.string()).default([]),
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export type DeploymentTarget = z.infer<typeof DeploymentTargetSchema>;
|
|
54
|
+
export type ObservabilityChannel = z.infer<typeof ObservabilityChannelSchema>;
|
|
55
|
+
export type OperationalDesign = z.infer<typeof OperationalDesignSchema>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// packages/contracts/src/architecture/security-design.ts
|
|
2
|
+
//
|
|
3
|
+
// Security architecture contract (M8 Phase C — M8-16).
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
export const AuthMethodSchema = z.enum([
|
|
8
|
+
'session',
|
|
9
|
+
'jwt',
|
|
10
|
+
'oauth2',
|
|
11
|
+
'api-key',
|
|
12
|
+
'service-account',
|
|
13
|
+
'none',
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
export const SecurityDesignSchema = z.object({
|
|
17
|
+
schemaVersion: z.literal(1),
|
|
18
|
+
briefId: z.string(),
|
|
19
|
+
authentication: z.object({
|
|
20
|
+
method: AuthMethodSchema,
|
|
21
|
+
rationale: z.string().min(1),
|
|
22
|
+
// Where credentials are stored (never in code).
|
|
23
|
+
credentialStore: z.string().min(1),
|
|
24
|
+
}),
|
|
25
|
+
authorization: z.object({
|
|
26
|
+
model: z.enum(['rbac', 'abac', 'acl', 'none']),
|
|
27
|
+
roles: z.array(z.string()),
|
|
28
|
+
protectedResources: z.array(z.string()),
|
|
29
|
+
}),
|
|
30
|
+
// Threats identified during design and their mitigations.
|
|
31
|
+
threats: z.array(
|
|
32
|
+
z.object({
|
|
33
|
+
id: z.string(),
|
|
34
|
+
threat: z.string().min(1),
|
|
35
|
+
severity: z.enum(['low', 'medium', 'high', 'critical']),
|
|
36
|
+
mitigation: z.string().min(1),
|
|
37
|
+
}),
|
|
38
|
+
),
|
|
39
|
+
// Secrets handling: how the app loads credentials at runtime.
|
|
40
|
+
secrets: z.object({
|
|
41
|
+
loader: z.enum(['env', 'vault', 'file']),
|
|
42
|
+
rotationPolicy: z.string().min(1),
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export type AuthMethod = z.infer<typeof AuthMethodSchema>;
|
|
47
|
+
export type SecurityDesign = z.infer<typeof SecurityDesignSchema>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// packages/contracts/src/common/errors.test.ts
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { Errors, type KitErrorCode } from './errors.js';
|
|
4
|
+
|
|
5
|
+
describe('Errors factory', () => {
|
|
6
|
+
const cases: ReadonlyArray<{
|
|
7
|
+
code: KitErrorCode;
|
|
8
|
+
factory: (m: string) => ReturnType<typeof Errors.internal>;
|
|
9
|
+
}> = [
|
|
10
|
+
{ code: 'CONTRACT_INVALID', factory: (m) => Errors.contractInvalid(m) },
|
|
11
|
+
{ code: 'PROFILE_INVALID', factory: (m) => Errors.profileInvalid(m) },
|
|
12
|
+
{ code: 'PLAN_INVALID', factory: (m) => Errors.planInvalid(m) },
|
|
13
|
+
{ code: 'SPEC_INVALID', factory: (m) => Errors.specInvalid(m) },
|
|
14
|
+
{ code: 'VERIFICATION_FAILED', factory: (m) => Errors.verificationFailed(m) },
|
|
15
|
+
{ code: 'APPROVAL_DENIED', factory: (m) => Errors.approvalDenied(m) },
|
|
16
|
+
{ code: 'APPROVAL_REQUIRED', factory: (m) => Errors.approvalRequired(m) },
|
|
17
|
+
{ code: 'POLICY_VIOLATION', factory: (m) => Errors.policyViolation(m) },
|
|
18
|
+
{ code: 'DISCOVERY_FAILED', factory: (m) => Errors.discoveryFailed(m) },
|
|
19
|
+
{ code: 'ARTIFACT_WRITE_DENIED', factory: (m) => Errors.artifactWriteDenied(m) },
|
|
20
|
+
{ code: 'ARTIFACT_READ_DENIED', factory: (m) => Errors.artifactReadDenied(m) },
|
|
21
|
+
{ code: 'TIMEOUT', factory: (m) => Errors.timeout(m) },
|
|
22
|
+
{ code: 'NOT_IMPLEMENTED', factory: (m) => Errors.notImplemented(m) },
|
|
23
|
+
{ code: 'AGENT_PROVIDER_NOT_CONFIGURED', factory: (m) => Errors.agentProviderNotConfigured(m) },
|
|
24
|
+
{ code: 'INTERNAL', factory: (m) => Errors.internal(m) },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
for (const { code, factory } of cases) {
|
|
28
|
+
it(`constructs ${code} with message and details`, () => {
|
|
29
|
+
const e = factory('hello');
|
|
30
|
+
expect(e.code).toBe(code);
|
|
31
|
+
expect(e.message).toBe('hello');
|
|
32
|
+
expect(e.details).toBeUndefined();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
it('attaches details when provided', () => {
|
|
37
|
+
const e = Errors.profileInvalid('bad', { field: 'stack' });
|
|
38
|
+
expect(e.details).toEqual({ field: 'stack' });
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('attaches cause when provided', () => {
|
|
42
|
+
const cause = new Error('root');
|
|
43
|
+
const e = Errors.internal('wrapped', undefined, cause);
|
|
44
|
+
expect(e.cause).toBe(cause);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// packages/contracts/src/common/errors.ts
|
|
2
|
+
//
|
|
3
|
+
// Structured error type used by every Result<T, KitError>. The `code`
|
|
4
|
+
// field is the contract the caller switches on; the `message` is for
|
|
5
|
+
// humans; `details` is structured context for logs and reports.
|
|
6
|
+
//
|
|
7
|
+
// See docs/contracts/CONTRACTS.md §1.1.
|
|
8
|
+
|
|
9
|
+
export type KitErrorCode =
|
|
10
|
+
| 'CONTRACT_INVALID'
|
|
11
|
+
| 'PROFILE_INVALID'
|
|
12
|
+
| 'PLAN_INVALID'
|
|
13
|
+
| 'SPEC_INVALID'
|
|
14
|
+
| 'VERIFICATION_FAILED'
|
|
15
|
+
| 'APPROVAL_DENIED'
|
|
16
|
+
| 'APPROVAL_REQUIRED'
|
|
17
|
+
| 'POLICY_VIOLATION'
|
|
18
|
+
| 'DISCOVERY_FAILED'
|
|
19
|
+
| 'ARTIFACT_WRITE_DENIED'
|
|
20
|
+
| 'ARTIFACT_READ_DENIED'
|
|
21
|
+
| 'TIMEOUT'
|
|
22
|
+
| 'NOT_IMPLEMENTED'
|
|
23
|
+
| 'AGENT_PROVIDER_NOT_CONFIGURED'
|
|
24
|
+
| 'INTERNAL';
|
|
25
|
+
|
|
26
|
+
export interface KitError {
|
|
27
|
+
readonly code: KitErrorCode;
|
|
28
|
+
readonly message: string;
|
|
29
|
+
readonly cause?: unknown;
|
|
30
|
+
readonly details?: Readonly<Record<string, unknown>>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const kitError = (
|
|
34
|
+
code: KitErrorCode,
|
|
35
|
+
message: string,
|
|
36
|
+
details?: Record<string, unknown>,
|
|
37
|
+
cause?: unknown,
|
|
38
|
+
): KitError => ({
|
|
39
|
+
code,
|
|
40
|
+
message,
|
|
41
|
+
...(details !== undefined ? { details } : {}),
|
|
42
|
+
...(cause !== undefined ? { cause } : {}),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Convenience constructors for the most common error codes. Keeping these
|
|
47
|
+
* in one place makes it easy to audit every site that produces a given code.
|
|
48
|
+
*
|
|
49
|
+
* Each factory accepts an optional `details` and an optional `cause`. The
|
|
50
|
+
* `cause` is attached when the error wraps another error (e.g., a caught
|
|
51
|
+
* exception); `details` carries structured context for logs and reports.
|
|
52
|
+
*/
|
|
53
|
+
export const Errors = {
|
|
54
|
+
contractInvalid: (
|
|
55
|
+
message: string,
|
|
56
|
+
details?: Record<string, unknown>,
|
|
57
|
+
cause?: unknown,
|
|
58
|
+
): KitError => kitError('CONTRACT_INVALID', message, details, cause),
|
|
59
|
+
profileInvalid: (message: string, details?: Record<string, unknown>, cause?: unknown): KitError =>
|
|
60
|
+
kitError('PROFILE_INVALID', message, details, cause),
|
|
61
|
+
planInvalid: (message: string, details?: Record<string, unknown>, cause?: unknown): KitError =>
|
|
62
|
+
kitError('PLAN_INVALID', message, details, cause),
|
|
63
|
+
specInvalid: (message: string, details?: Record<string, unknown>, cause?: unknown): KitError =>
|
|
64
|
+
kitError('SPEC_INVALID', message, details, cause),
|
|
65
|
+
verificationFailed: (
|
|
66
|
+
message: string,
|
|
67
|
+
details?: Record<string, unknown>,
|
|
68
|
+
cause?: unknown,
|
|
69
|
+
): KitError => kitError('VERIFICATION_FAILED', message, details, cause),
|
|
70
|
+
approvalDenied: (message: string, details?: Record<string, unknown>, cause?: unknown): KitError =>
|
|
71
|
+
kitError('APPROVAL_DENIED', message, details, cause),
|
|
72
|
+
approvalRequired: (
|
|
73
|
+
message: string,
|
|
74
|
+
details?: Record<string, unknown>,
|
|
75
|
+
cause?: unknown,
|
|
76
|
+
): KitError => kitError('APPROVAL_REQUIRED', message, details, cause),
|
|
77
|
+
policyViolation: (
|
|
78
|
+
message: string,
|
|
79
|
+
details?: Record<string, unknown>,
|
|
80
|
+
cause?: unknown,
|
|
81
|
+
): KitError => kitError('POLICY_VIOLATION', message, details, cause),
|
|
82
|
+
discoveryFailed: (
|
|
83
|
+
message: string,
|
|
84
|
+
details?: Record<string, unknown>,
|
|
85
|
+
cause?: unknown,
|
|
86
|
+
): KitError => kitError('DISCOVERY_FAILED', message, details, cause),
|
|
87
|
+
artifactWriteDenied: (
|
|
88
|
+
message: string,
|
|
89
|
+
details?: Record<string, unknown>,
|
|
90
|
+
cause?: unknown,
|
|
91
|
+
): KitError => kitError('ARTIFACT_WRITE_DENIED', message, details, cause),
|
|
92
|
+
artifactReadDenied: (
|
|
93
|
+
message: string,
|
|
94
|
+
details?: Record<string, unknown>,
|
|
95
|
+
cause?: unknown,
|
|
96
|
+
): KitError => kitError('ARTIFACT_READ_DENIED', message, details, cause),
|
|
97
|
+
timeout: (message: string, details?: Record<string, unknown>, cause?: unknown): KitError =>
|
|
98
|
+
kitError('TIMEOUT', message, details, cause),
|
|
99
|
+
notImplemented: (message: string, details?: Record<string, unknown>, cause?: unknown): KitError =>
|
|
100
|
+
kitError('NOT_IMPLEMENTED', message, details, cause),
|
|
101
|
+
/**
|
|
102
|
+
* Mode 1 (kit-orchestrated) execution was requested but no agent
|
|
103
|
+
* provider is configured/registered (ADR-0019 §1). The CLI maps this to
|
|
104
|
+
* exit code 3 (blocked / prerequisite missing) and NEVER falls back to
|
|
105
|
+
* pretending a manual workflow completed.
|
|
106
|
+
*/
|
|
107
|
+
agentProviderNotConfigured: (
|
|
108
|
+
message: string,
|
|
109
|
+
details?: Record<string, unknown>,
|
|
110
|
+
cause?: unknown,
|
|
111
|
+
): KitError => kitError('AGENT_PROVIDER_NOT_CONFIGURED', message, details, cause),
|
|
112
|
+
internal: (message: string, details?: Record<string, unknown>, cause?: unknown): KitError =>
|
|
113
|
+
kitError('INTERNAL', message, details, cause),
|
|
114
|
+
} as const;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// packages/contracts/src/common/identifier.test.ts
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { IdentifierSchema, isValidIdentifier } from './identifier.js';
|
|
4
|
+
|
|
5
|
+
describe('IdentifierSchema', () => {
|
|
6
|
+
const valid = [
|
|
7
|
+
'FEATURE-001',
|
|
8
|
+
'TASK-014',
|
|
9
|
+
'RUN-002',
|
|
10
|
+
'unit-tests',
|
|
11
|
+
'typecheck',
|
|
12
|
+
'model-router',
|
|
13
|
+
'a',
|
|
14
|
+
'ab',
|
|
15
|
+
'a-b',
|
|
16
|
+
'a-1',
|
|
17
|
+
'feature-001', // lowercase kebab with digits; valid
|
|
18
|
+
'feature--', // consecutive dashes; technically valid per regex
|
|
19
|
+
'node-typescript',
|
|
20
|
+
'ruby-rails',
|
|
21
|
+
];
|
|
22
|
+
for (const v of valid) {
|
|
23
|
+
it(`accepts ${JSON.stringify(v)}`, () => {
|
|
24
|
+
expect(IdentifierSchema.safeParse(v).success).toBe(true);
|
|
25
|
+
expect(isValidIdentifier(v)).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const invalid = [
|
|
30
|
+
'',
|
|
31
|
+
'FEATURE-1', // needs 3+ digits
|
|
32
|
+
'feature-001-X', // trailing uppercase
|
|
33
|
+
'Feature-001', // mixed case prefix
|
|
34
|
+
'FEATURE-', // missing digits
|
|
35
|
+
'-feature', // leading dash
|
|
36
|
+
'FEATURE 001', // space
|
|
37
|
+
'UPPERCASE', // no dash
|
|
38
|
+
'x'.repeat(65), // too long
|
|
39
|
+
'1starts-with-digit',
|
|
40
|
+
'has_underscore',
|
|
41
|
+
'has.dot',
|
|
42
|
+
'has space',
|
|
43
|
+
'UPPER-With-Dash',
|
|
44
|
+
];
|
|
45
|
+
for (const v of invalid) {
|
|
46
|
+
it(`rejects ${JSON.stringify(v)}`, () => {
|
|
47
|
+
expect(IdentifierSchema.safeParse(v).success).toBe(false);
|
|
48
|
+
expect(isValidIdentifier(v)).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// packages/contracts/src/common/identifier.ts
|
|
2
|
+
//
|
|
3
|
+
// Identifier format contract for FeatureId, TaskId, RunId, CheckId.
|
|
4
|
+
//
|
|
5
|
+
// Two accepted shapes:
|
|
6
|
+
// 1. Uppercase prefix + dash + 3+ digits: FEATURE-001, TASK-014, RUN-002
|
|
7
|
+
// 2. Lowercase kebab-case: unit-tests, typecheck, model-router
|
|
8
|
+
//
|
|
9
|
+
// See docs/contracts/CONTRACTS.md §1.2.
|
|
10
|
+
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
|
|
13
|
+
export const IdentifierSchema = z.union([
|
|
14
|
+
z.string().regex(/^[A-Z]+-[0-9]{3,}$/, 'must match FEATURE-NNN pattern'),
|
|
15
|
+
z.string().regex(/^[a-z][a-z0-9-]{0,63}$/, 'must be lowercase kebab-case, max 64 chars'),
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
export type Identifier = z.infer<typeof IdentifierSchema>;
|
|
19
|
+
|
|
20
|
+
// M1: identifier kinds share the same runtime shape. We keep them as
|
|
21
|
+
// aliases so call sites can express intent without runtime overhead.
|
|
22
|
+
// Future milestones MAY tighten each kind with a stricter regex.
|
|
23
|
+
export type FeatureId = Identifier;
|
|
24
|
+
export type TaskId = Identifier;
|
|
25
|
+
export type RunId = Identifier;
|
|
26
|
+
export type CheckId = Identifier;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Predicate form for use in non-zod contexts.
|
|
30
|
+
*/
|
|
31
|
+
export function isValidIdentifier(value: string): boolean {
|
|
32
|
+
return IdentifierSchema.safeParse(value).success;
|
|
33
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// packages/contracts/src/common/result.test.ts
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { err, mapErr, mapOk, ok, unwrap, type Result } from './result.js';
|
|
4
|
+
import { Errors } from './errors.js';
|
|
5
|
+
|
|
6
|
+
describe('result.ok', () => {
|
|
7
|
+
it('constructs an Ok value', () => {
|
|
8
|
+
const r = ok(42);
|
|
9
|
+
expect(r.ok).toBe(true);
|
|
10
|
+
expect(r.value).toBe(42);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('result.err', () => {
|
|
15
|
+
it('constructs an Err value', () => {
|
|
16
|
+
const e = err(Errors.internal('boom'));
|
|
17
|
+
expect(e.ok).toBe(false);
|
|
18
|
+
expect(e.error.code).toBe('INTERNAL');
|
|
19
|
+
expect(e.error.message).toBe('boom');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('result.unwrap', () => {
|
|
24
|
+
it('returns the value for Ok', () => {
|
|
25
|
+
expect(unwrap(ok('x'))).toBe('x');
|
|
26
|
+
});
|
|
27
|
+
it('throws for Err', () => {
|
|
28
|
+
expect(() => unwrap(err(Errors.internal('boom')))).toThrow(/unwrap called on Err/);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('result.mapOk', () => {
|
|
33
|
+
it('applies the function to Ok', () => {
|
|
34
|
+
expect(mapOk(ok(2), (n) => n * 3)).toEqual(ok(6));
|
|
35
|
+
});
|
|
36
|
+
it('passes Err through unchanged', () => {
|
|
37
|
+
const e: Result<number> = err(Errors.internal('x'));
|
|
38
|
+
expect(mapOk(e, (n) => n * 3)).toBe(e);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('result.mapErr', () => {
|
|
43
|
+
it('applies the function to Err', () => {
|
|
44
|
+
const r = mapErr(err(Errors.internal('a')), (e) => Errors.internal(e.message + 'b'));
|
|
45
|
+
expect(r.ok).toBe(false);
|
|
46
|
+
if (!r.ok) expect(r.error.message).toBe('ab');
|
|
47
|
+
});
|
|
48
|
+
it('passes Ok through unchanged', () => {
|
|
49
|
+
const o = ok(1);
|
|
50
|
+
expect(mapErr(o, (e) => Errors.internal(e.message))).toBe(o);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// packages/contracts/src/common/result.ts
|
|
2
|
+
//
|
|
3
|
+
// Result<T, E> is the standard return shape for every function in `core`
|
|
4
|
+
// and `cli` that can fail in an expected way. Exceptions are reserved for
|
|
5
|
+
// programmer errors (e.g., violating an architectural invariant).
|
|
6
|
+
//
|
|
7
|
+
// See docs/contracts/CONTRACTS.md §1.1 and ADR-0007.
|
|
8
|
+
|
|
9
|
+
import type { KitError } from './errors.js';
|
|
10
|
+
|
|
11
|
+
export interface Ok<T> {
|
|
12
|
+
readonly ok: true;
|
|
13
|
+
readonly value: T;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface Err<E> {
|
|
17
|
+
readonly ok: false;
|
|
18
|
+
readonly error: E;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type Result<T, E = KitError> = Ok<T> | Err<E>;
|
|
22
|
+
|
|
23
|
+
export const ok = <T>(value: T): Ok<T> => ({ ok: true, value });
|
|
24
|
+
|
|
25
|
+
export const err = <E>(error: E): Err<E> => ({ ok: false, error });
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Type-level exhaustiveness helper. Returns the error if `result` is `Err`,
|
|
29
|
+
* otherwise throws (programmer error: the caller should have checked `ok`
|
|
30
|
+
* first). Used in tests and in code paths where a `Err` is genuinely
|
|
31
|
+
* impossible by construction.
|
|
32
|
+
*/
|
|
33
|
+
export function unwrap<T, E>(result: Result<T, E>): T {
|
|
34
|
+
if (result.ok) return result.value;
|
|
35
|
+
throw new Error(`unwrap called on Err: ${JSON.stringify(result.error)}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Functional map over the Ok value. Passes through Err unchanged.
|
|
40
|
+
*/
|
|
41
|
+
export function mapOk<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E> {
|
|
42
|
+
return result.ok ? ok(fn(result.value)) : result;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Functional map over the Err value. Passes through Ok unchanged.
|
|
47
|
+
*/
|
|
48
|
+
export function mapErr<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F> {
|
|
49
|
+
return result.ok ? result : err(fn(result.error));
|
|
50
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// packages/contracts/src/evaluation/benchmark.ts
|
|
2
|
+
//
|
|
3
|
+
// M19 evaluation contract (M19-01) and benchmark suite (M19-02). The kit
|
|
4
|
+
// evaluates itself against a stable benchmark set per RESEARCH.md §13 and
|
|
5
|
+
// the post-M7 §13 roadmap.
|
|
6
|
+
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
export const EVALUATION_SCHEMA_VERSION = 1 as const;
|
|
10
|
+
|
|
11
|
+
export const BenchmarkKindSchema = z.enum([
|
|
12
|
+
'feature',
|
|
13
|
+
'bug-fix',
|
|
14
|
+
'refactor',
|
|
15
|
+
'greenfield',
|
|
16
|
+
'security',
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
export const BenchmarkCaseSchema = z.object({
|
|
20
|
+
id: z.string().regex(/^[A-Z]+-[0-9]{3,}$/),
|
|
21
|
+
title: z.string().min(1),
|
|
22
|
+
kind: BenchmarkKindSchema,
|
|
23
|
+
// The fixture repository to run against.
|
|
24
|
+
fixture: z.string().min(1),
|
|
25
|
+
// The task description given to the kit.
|
|
26
|
+
taskPrompt: z.string().min(1),
|
|
27
|
+
// The acceptance criteria the result must satisfy.
|
|
28
|
+
acceptanceCriteria: z.array(z.string().min(1)).min(1),
|
|
29
|
+
// Whether this case is held-out (not used during improvement experiments).
|
|
30
|
+
heldOut: z.boolean().default(false),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const BenchmarkSuiteSchema = z.object({
|
|
34
|
+
schemaVersion: z.literal(EVALUATION_SCHEMA_VERSION),
|
|
35
|
+
id: z.string(),
|
|
36
|
+
version: z.string().regex(/^\d+\.\d+\.\d+$/, 'semver'),
|
|
37
|
+
cases: z.array(BenchmarkCaseSchema),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export type BenchmarkKind = z.infer<typeof BenchmarkKindSchema>;
|
|
41
|
+
export type BenchmarkCase = z.infer<typeof BenchmarkCaseSchema>;
|
|
42
|
+
export type BenchmarkSuite = z.infer<typeof BenchmarkSuiteSchema>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// packages/contracts/src/evaluation/metrics.ts
|
|
2
|
+
//
|
|
3
|
+
// M19 metrics and evaluation report (M19-11, M19-12). Every meaningful
|
|
4
|
+
// change to workflow logic, model routing, or runtime behavior can be
|
|
5
|
+
// evaluated against a stable benchmark set.
|
|
6
|
+
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
export const MetricSnapshotSchema = z.object({
|
|
10
|
+
// The metric name (e.g., "acceptance-criteria-pass-rate").
|
|
11
|
+
metric: z.string().min(1),
|
|
12
|
+
// The measured value.
|
|
13
|
+
value: z.number(),
|
|
14
|
+
// The unit (e.g., "%", "ms", "count", "tokens").
|
|
15
|
+
unit: z.string().min(1),
|
|
16
|
+
// The number of benchmark cases this was averaged over.
|
|
17
|
+
sampleSize: z.number().int().positive(),
|
|
18
|
+
// Whether this metric is a primary quality gate (a failure here blocks
|
|
19
|
+
// release regardless of other metrics).
|
|
20
|
+
blocking: z.boolean().default(false),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const EvaluationReportSchema = z.object({
|
|
24
|
+
schemaVersion: z.literal(1),
|
|
25
|
+
// The kit version that was evaluated.
|
|
26
|
+
kitVersion: z.string().min(1),
|
|
27
|
+
// The benchmark suite id + version.
|
|
28
|
+
benchmarkSuiteId: z.string(),
|
|
29
|
+
benchmarkSuiteVersion: z.string(),
|
|
30
|
+
// When the evaluation ran.
|
|
31
|
+
ranAt: z.string(),
|
|
32
|
+
// The metrics measured.
|
|
33
|
+
metrics: z.array(MetricSnapshotSchema),
|
|
34
|
+
// Whether the overall result passes the release quality thresholds.
|
|
35
|
+
passesReleaseGates: z.boolean(),
|
|
36
|
+
// Any blocking failures (critical security regressions, etc.).
|
|
37
|
+
blockingFailures: z
|
|
38
|
+
.array(
|
|
39
|
+
z.object({
|
|
40
|
+
metric: z.string(),
|
|
41
|
+
value: z.number(),
|
|
42
|
+
threshold: z.number(),
|
|
43
|
+
severity: z.enum(['high', 'critical']),
|
|
44
|
+
}),
|
|
45
|
+
)
|
|
46
|
+
.default([]),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export type MetricSnapshot = z.infer<typeof MetricSnapshotSchema>;
|
|
50
|
+
export type EvaluationReport = z.infer<typeof EvaluationReportSchema>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Compare two evaluation reports (e.g., baseline vs candidate) and produce
|
|
54
|
+
* a delta. Used by the evolution engine (M34) to decide whether a
|
|
55
|
+
* candidate improvement is actually better.
|
|
56
|
+
*/
|
|
57
|
+
export const ComparisonReportSchema = z.object({
|
|
58
|
+
schemaVersion: z.literal(1),
|
|
59
|
+
baseline: z.string(), // kit version
|
|
60
|
+
candidate: z.string(), // kit version
|
|
61
|
+
metricDeltas: z.array(
|
|
62
|
+
z.object({
|
|
63
|
+
metric: z.string(),
|
|
64
|
+
baselineValue: z.number(),
|
|
65
|
+
candidateValue: z.number(),
|
|
66
|
+
delta: z.number(),
|
|
67
|
+
// Whether the candidate improved on this metric.
|
|
68
|
+
improved: z.boolean(),
|
|
69
|
+
}),
|
|
70
|
+
),
|
|
71
|
+
// Overall verdict: did the candidate pass its guardrails?
|
|
72
|
+
verdict: z.enum(['approved', 'rejected', 'needs-revision']),
|
|
73
|
+
reason: z.string().min(1),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export type ComparisonReport = z.infer<typeof ComparisonReportSchema>;
|