@agentic-sdlc-kit/contracts 0.0.0-stage → 0.9.1
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 +86 -0
- package/dist/installer/ownership-manifest.d.ts.map +1 -0
- package/dist/installer/ownership-manifest.js +34 -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 +153 -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 +87 -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 +40 -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 +168 -0
- package/src/secret-guard/finding.ts +95 -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,54 @@
|
|
|
1
|
+
// packages/contracts/src/observer/event-schema.ts
|
|
2
|
+
//
|
|
3
|
+
// M13 event contract (M13-01, M13-02). Versioned event schema for the
|
|
4
|
+
// run-observer Mod. Every event has a stable id and schema; missing
|
|
5
|
+
// telemetry is represented honestly (never as zero).
|
|
6
|
+
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
export const OBSERVER_EVENT_SCHEMA_VERSION = 1 as const;
|
|
10
|
+
|
|
11
|
+
export const ObserverEventKindSchema = z.enum([
|
|
12
|
+
'session-start',
|
|
13
|
+
'session-end',
|
|
14
|
+
'turn-start',
|
|
15
|
+
'turn-step',
|
|
16
|
+
'turn-complete',
|
|
17
|
+
'agent-spawn',
|
|
18
|
+
'agent-complete',
|
|
19
|
+
'tool-call',
|
|
20
|
+
'tool-result',
|
|
21
|
+
'verification',
|
|
22
|
+
'escalation',
|
|
23
|
+
'failure',
|
|
24
|
+
'blocked-action',
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
export const ObserverEventSchema = z.object({
|
|
28
|
+
schemaVersion: z.literal(OBSERVER_EVENT_SCHEMA_VERSION),
|
|
29
|
+
id: z.string(),
|
|
30
|
+
// The run this event belongs to.
|
|
31
|
+
runId: z.string(),
|
|
32
|
+
// The session this event belongs to (may differ from run if a session
|
|
33
|
+
// spans multiple runs).
|
|
34
|
+
sessionId: z.string().optional(),
|
|
35
|
+
// ISO 8601 timestamp.
|
|
36
|
+
at: z.string(),
|
|
37
|
+
kind: ObserverEventKindSchema,
|
|
38
|
+
// The model and effort in effect when the event occurred (if applicable).
|
|
39
|
+
model: z.string().optional(),
|
|
40
|
+
effort: z.string().optional(),
|
|
41
|
+
// Token usage (only present for turn-complete events where the host
|
|
42
|
+
// exposes it).
|
|
43
|
+
tokensIn: z.number().int().nonnegative().optional(),
|
|
44
|
+
tokensOut: z.number().int().nonnegative().optional(),
|
|
45
|
+
// Estimated cost in arbitrary units (only where reliable data exists).
|
|
46
|
+
estimatedCostUnits: z.number().nonnegative().optional(),
|
|
47
|
+
// A redacted summary of the event payload (never raw secrets).
|
|
48
|
+
summary: z.string(),
|
|
49
|
+
// Whether telemetry for this event is partial (some fields missing).
|
|
50
|
+
partial: z.boolean().default(false),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export type ObserverEvent = z.infer<typeof ObserverEventSchema>;
|
|
54
|
+
export type ObserverEventKind = z.infer<typeof ObserverEventKindSchema>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// packages/contracts/src/observer/journal.test.ts
|
|
2
|
+
//
|
|
3
|
+
// Schema tests for the hash-chained execution journal (ADR-0021 §3).
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { JOURNAL_SCHEMA_VERSION, JournalActorSchema, JournalEventSchema } from './journal.js';
|
|
6
|
+
|
|
7
|
+
const SHA = 'a'.repeat(64); /* any 64-hex string; validity of the digest is core's job to compute */
|
|
8
|
+
|
|
9
|
+
describe('JournalActorSchema', () => {
|
|
10
|
+
it('accepts a declared agent host', () => {
|
|
11
|
+
expect(JournalActorSchema.safeParse({ kind: 'agent', host: 'cursor' }).success).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
it('accepts an undeclared human (honest default, no guessing)', () => {
|
|
14
|
+
expect(JournalActorSchema.safeParse({ kind: 'human' }).success).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
it('rejects an empty host id', () => {
|
|
17
|
+
expect(JournalActorSchema.safeParse({ kind: 'agent', host: '' }).success).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('JournalEventSchema', () => {
|
|
22
|
+
const base = {
|
|
23
|
+
schemaVersion: JOURNAL_SCHEMA_VERSION,
|
|
24
|
+
seq: 0,
|
|
25
|
+
ts: '2026-11-22T00:00:00.000Z',
|
|
26
|
+
featureId: 'FEATURE-001',
|
|
27
|
+
taskId: 'TASK-001',
|
|
28
|
+
kind: 'phase.recorded',
|
|
29
|
+
actor: { kind: 'human' },
|
|
30
|
+
payload: { phase: 'red', status: 'failed', classification: 'assertion' },
|
|
31
|
+
prevHash: 'GENESIS',
|
|
32
|
+
hash: SHA,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
it('accepts a genesis event', () => {
|
|
36
|
+
expect(JournalEventSchema.safeParse(base).success).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('accepts a chained event with a hex prevHash', () => {
|
|
40
|
+
expect(
|
|
41
|
+
JournalEventSchema.safeParse({ ...base, seq: 1, prevHash: SHA, kind: 'phase.recorded' })
|
|
42
|
+
.success,
|
|
43
|
+
).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('rejects a non-hex prevHash', () => {
|
|
47
|
+
expect(JournalEventSchema.safeParse({ ...base, prevHash: 'not-a-hash' }).success).toBe(false);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('rejects GENESIS as an event hash (only prevHash may carry the sentinel)', () => {
|
|
51
|
+
expect(JournalEventSchema.safeParse({ ...base, hash: 'GENESIS' }).success).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('rejects a negative or fractional sequence number', () => {
|
|
55
|
+
expect(JournalEventSchema.safeParse({ ...base, seq: -1 }).success).toBe(false);
|
|
56
|
+
expect(JournalEventSchema.safeParse({ ...base, seq: 1.5 }).success).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('rejects an unknown event kind', () => {
|
|
60
|
+
expect(JournalEventSchema.safeParse({ ...base, kind: 'phase.skipped' }).success).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('rejects a mismatched schema version', () => {
|
|
64
|
+
expect(JournalEventSchema.safeParse({ ...base, schemaVersion: 2 }).success).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('allows a missing taskId for run-level events', () => {
|
|
68
|
+
expect(
|
|
69
|
+
JournalEventSchema.safeParse({ ...base, taskId: undefined, kind: 'workflow.started' })
|
|
70
|
+
.success,
|
|
71
|
+
).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// packages/contracts/src/observer/journal.ts
|
|
2
|
+
//
|
|
3
|
+
// Hash-chained execution journal (ADR-0021 §3).
|
|
4
|
+
//
|
|
5
|
+
// The feature run state (.ai-kit/state/feature-runs/<featureId>.json)
|
|
6
|
+
// is the handoff boundary; the journal is the EXECUTED RECORD: an
|
|
7
|
+
// append-only, tamper-evident, per-run event log at
|
|
8
|
+
// .ai-kit/journal/feature-runs/<featureId>.jsonl.
|
|
9
|
+
//
|
|
10
|
+
// Chain rule: every event carries `prevHash` (the `hash` of the
|
|
11
|
+
// previous event; the literal string 'GENESIS' for seq 0) and `hash`
|
|
12
|
+
// (SHA-256 over the canonical serialization of the event without its
|
|
13
|
+
// `hash` field). `kit journal <featureId> --verify` recomputes the
|
|
14
|
+
// chain and fails on any gap, reordering, or mutation.
|
|
15
|
+
//
|
|
16
|
+
// Honest limits (ADR-0021 §3.4):
|
|
17
|
+
// - Modification, insertion, and reordering of recorded events are
|
|
18
|
+
// DETECTABLE. Tail truncation is NOT detectable from the journal
|
|
19
|
+
// alone — a truncated file is still a valid chain. Anchoring (e.g.
|
|
20
|
+
// recording the final hash in the run report or an external system)
|
|
21
|
+
// is the follow-up; the journal never claims more than it proves.
|
|
22
|
+
// - The journal is observability, never authority: an event never
|
|
23
|
+
// authorizes anything and cannot substitute for evidence records.
|
|
24
|
+
// Journal write failures never block the workflow (the run-observer
|
|
25
|
+
// invariant: telemetry must not block the chain).
|
|
26
|
+
// - `payload` carries redacted, bounded strings only — the same
|
|
27
|
+
// redaction policy and excerpt bound as phase evidence.
|
|
28
|
+
|
|
29
|
+
import { z } from 'zod';
|
|
30
|
+
|
|
31
|
+
export const JOURNAL_SCHEMA_VERSION = 1 as const;
|
|
32
|
+
|
|
33
|
+
/** Semantic events in the life of a feature run. */
|
|
34
|
+
export const JournalEventKindSchema = z.enum([
|
|
35
|
+
/** `kit feature <id> start` created the run state. */
|
|
36
|
+
'workflow.started',
|
|
37
|
+
/** A phase attempt satisfied its invariant and advanced the task. */
|
|
38
|
+
'phase.recorded',
|
|
39
|
+
/** A phase attempt was recorded but did NOT advance (e.g. Red failed with a non-assertion classification). */
|
|
40
|
+
'phase.rejected',
|
|
41
|
+
/** A phase attempt ran and violated its invariant (e.g. Green failed). */
|
|
42
|
+
'phase.failed',
|
|
43
|
+
/** Final verification completed. `payload.status` is 'passed' | 'failed'. */
|
|
44
|
+
'workflow.finalized',
|
|
45
|
+
]);
|
|
46
|
+
export type JournalEventKind = z.infer<typeof JournalEventKindSchema>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Who invoked the kit. The kit CANNOT infer agent vs. human at the CLI
|
|
50
|
+
* boundary — a host declares itself (`--host <id>` or KIT_HOST env) and
|
|
51
|
+
* the kit records the declaration, defaulting to 'human'. An undeclared
|
|
52
|
+
* agent is recorded honestly as what the kit observed, not what it
|
|
53
|
+
* guessed.
|
|
54
|
+
*/
|
|
55
|
+
export const JournalActorSchema = z.object({
|
|
56
|
+
kind: z.enum(['agent', 'human', 'kit']),
|
|
57
|
+
/** Declared host id (e.g. 'claude-code', 'cursor', 'agy', 'github-actions'). */
|
|
58
|
+
host: z.string().min(1).optional(),
|
|
59
|
+
});
|
|
60
|
+
export type JournalActor = z.infer<typeof JournalActorSchema>;
|
|
61
|
+
|
|
62
|
+
/** SHA-256 hex digest (64 lowercase hex chars) or the GENESIS sentinel. */
|
|
63
|
+
const HashSchema = z.string().regex(/^(GENESIS|[0-9a-f]{64})$/, 'expected 64 hex chars or GENESIS');
|
|
64
|
+
|
|
65
|
+
export const JournalEventSchema = z.object({
|
|
66
|
+
schemaVersion: z.literal(JOURNAL_SCHEMA_VERSION),
|
|
67
|
+
/** 0-based position in the chain; strictly increasing, no gaps. */
|
|
68
|
+
seq: z.number().int().nonnegative(),
|
|
69
|
+
/** ISO 8601 timestamp. */
|
|
70
|
+
ts: z.string().min(1),
|
|
71
|
+
/** The feature run this event belongs to (run id == feature id). */
|
|
72
|
+
featureId: z.string().min(1),
|
|
73
|
+
/** Target task, when the event is task-scoped. */
|
|
74
|
+
taskId: z.string().optional(),
|
|
75
|
+
kind: JournalEventKindSchema,
|
|
76
|
+
actor: JournalActorSchema,
|
|
77
|
+
/** Redacted, bounded event detail (evidence excerpts, statuses). */
|
|
78
|
+
payload: z.record(z.unknown()),
|
|
79
|
+
/** Hash of the previous event ('GENESIS' for seq 0). */
|
|
80
|
+
prevHash: HashSchema,
|
|
81
|
+
/** SHA-256 over the canonical serialization of this event without `hash`. */
|
|
82
|
+
hash: HashSchema.refine((h) => h !== 'GENESIS', 'the GENESIS sentinel is only valid as prevHash'),
|
|
83
|
+
});
|
|
84
|
+
export type JournalEvent = z.infer<typeof JournalEventSchema>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// packages/contracts/src/observer/retention.ts
|
|
2
|
+
//
|
|
3
|
+
// M13 retention policy (M13-09). Local retention and cleanup for observer
|
|
4
|
+
// events. Privacy-first: redacted by default, configurable retention.
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
export const RetentionPolicySchema = z.object({
|
|
9
|
+
schemaVersion: z.literal(1),
|
|
10
|
+
// How long to keep events (in days). 0 = delete immediately after
|
|
11
|
+
// summary is written; -1 = keep forever.
|
|
12
|
+
retainDays: z.number().int().default(30),
|
|
13
|
+
// Maximum number of events per run before truncating (cap memory).
|
|
14
|
+
maxEventsPerRun: z.number().int().positive().default(10_000),
|
|
15
|
+
// Whether to redact summaries (strip anything that looks like a path,
|
|
16
|
+
// identifier, or value).
|
|
17
|
+
redactSummaries: z.boolean().default(true),
|
|
18
|
+
// Whether to drop token/cost data (privacy).
|
|
19
|
+
dropUsageData: z.boolean().default(false),
|
|
20
|
+
// Path patterns to never record in summaries.
|
|
21
|
+
redactPathPatterns: z.array(z.string()).default([]),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export type RetentionPolicy = z.infer<typeof RetentionPolicySchema>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// packages/contracts/src/observer/run-summary.ts
|
|
2
|
+
//
|
|
3
|
+
// M13 run summary (M13-06). The shape produced by `kit runs show RUN-001`.
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ObserverEventSchema } from './event-schema.js';
|
|
7
|
+
|
|
8
|
+
export const RunSummarySchema = z.object({
|
|
9
|
+
schemaVersion: z.literal(1),
|
|
10
|
+
runId: z.string(),
|
|
11
|
+
startedAt: z.string(),
|
|
12
|
+
completedAt: z.string().optional(),
|
|
13
|
+
status: z.enum(['in-progress', 'completed', 'failed', 'blocked']),
|
|
14
|
+
// Aggregated metrics. Every field is optional because the observer
|
|
15
|
+
// represents partial telemetry honestly (never as zero).
|
|
16
|
+
totals: z.object({
|
|
17
|
+
turns: z.number().int().nonnegative().optional(),
|
|
18
|
+
toolCalls: z.number().int().nonnegative().optional(),
|
|
19
|
+
agentsSpawned: z.number().int().nonnegative().optional(),
|
|
20
|
+
tokensIn: z.number().int().nonnegative().optional(),
|
|
21
|
+
tokensOut: z.number().int().nonnegative().optional(),
|
|
22
|
+
estimatedCostUnits: z.number().nonnegative().optional(),
|
|
23
|
+
escalations: z.number().int().nonnegative().optional(),
|
|
24
|
+
blockedActions: z.number().int().nonnegative().optional(),
|
|
25
|
+
}),
|
|
26
|
+
// Verification results correlated with this run.
|
|
27
|
+
verificationStatus: z.enum(['passed', 'failed', 'blocked', 'not-run']).optional(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const RunReportSchema = z.object({
|
|
31
|
+
schemaVersion: z.literal(1),
|
|
32
|
+
summary: RunSummarySchema,
|
|
33
|
+
events: z.array(ObserverEventSchema),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export type RunSummary = z.infer<typeof RunSummarySchema>;
|
|
37
|
+
export type RunReport = z.infer<typeof RunReportSchema>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// packages/contracts/src/patterns/pattern.ts
|
|
2
|
+
//
|
|
3
|
+
// M14 pattern catalog contract (M14-08). Language-independent design
|
|
4
|
+
// pattern documentation. Patterns are documented once as concepts, then
|
|
5
|
+
// linked to implementation examples in stack packs.
|
|
6
|
+
//
|
|
7
|
+
// Per the architecture proposal §7: every pattern must explain when it
|
|
8
|
+
// applies, when it does not, and the simpler alternative.
|
|
9
|
+
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
|
|
12
|
+
export const PATTERN_SCHEMA_VERSION = 1 as const;
|
|
13
|
+
|
|
14
|
+
export const PatternCategorySchema = z.enum([
|
|
15
|
+
'architecture',
|
|
16
|
+
'creational',
|
|
17
|
+
'structural',
|
|
18
|
+
'behavioral',
|
|
19
|
+
'resilience',
|
|
20
|
+
'data',
|
|
21
|
+
'testing',
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
export const PatternExampleSchema = z.object({
|
|
25
|
+
stack: z.string().min(1),
|
|
26
|
+
// Path within the stack pack where the example lives.
|
|
27
|
+
path: z.string().min(1),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const PatternSchema = z.object({
|
|
31
|
+
schemaVersion: z.literal(PATTERN_SCHEMA_VERSION),
|
|
32
|
+
id: z.string().regex(/^[a-z][a-z0-9-]*$/, 'pattern id must be kebab-case'),
|
|
33
|
+
name: z.string().min(1),
|
|
34
|
+
category: PatternCategorySchema,
|
|
35
|
+
// The design problem this pattern addresses.
|
|
36
|
+
problem: z.string().min(1),
|
|
37
|
+
// Conditions that justify introducing it.
|
|
38
|
+
whenToUse: z.array(z.string()).min(1),
|
|
39
|
+
// Conditions that argue against it.
|
|
40
|
+
whenNotToUse: z.array(z.string()).min(1),
|
|
41
|
+
// Simpler alternatives that should be considered first.
|
|
42
|
+
simplerAlternatives: z.array(z.string()).min(1),
|
|
43
|
+
// Participants and responsibilities.
|
|
44
|
+
structure: z.string().min(1),
|
|
45
|
+
// What additional complexity the pattern introduces.
|
|
46
|
+
tradeOffs: z.array(z.string()),
|
|
47
|
+
// Implementation examples in specific stacks.
|
|
48
|
+
examples: z.array(PatternExampleSchema).default([]),
|
|
49
|
+
// How to prove the implementation works.
|
|
50
|
+
testingStrategy: z.string().min(1),
|
|
51
|
+
// Alternative and complementary patterns.
|
|
52
|
+
relatedPatterns: z.array(z.string()).default([]),
|
|
53
|
+
// Common misuse.
|
|
54
|
+
antiPatterns: z.array(z.string()).default([]),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export type PatternCategory = z.infer<typeof PatternCategorySchema>;
|
|
58
|
+
export type PatternExample = z.infer<typeof PatternExampleSchema>;
|
|
59
|
+
export type Pattern = z.infer<typeof PatternSchema>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Pattern selection question (used by the design-pattern-selection Skill).
|
|
63
|
+
* Every proposed pattern must answer all five questions (per architecture
|
|
64
|
+
* proposal §7).
|
|
65
|
+
*/
|
|
66
|
+
export const PatternSelectionQuestionSchema = z.object({
|
|
67
|
+
patternId: z.string(),
|
|
68
|
+
// 1. What specific problem exists?
|
|
69
|
+
problem: z.string().min(1),
|
|
70
|
+
// 2. Why is the current design insufficient?
|
|
71
|
+
currentDesignInsufficiency: z.string().min(1),
|
|
72
|
+
// 3. What simpler alternative was considered?
|
|
73
|
+
simplerAlternativeConsidered: z.string().min(1),
|
|
74
|
+
// 4. What complexity will the pattern introduce?
|
|
75
|
+
complexityIntroduced: z.string().min(1),
|
|
76
|
+
// 5. How will the implementation be tested?
|
|
77
|
+
testingApproach: z.string().min(1),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export type PatternSelectionQuestion = z.infer<typeof PatternSelectionQuestionSchema>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// packages/contracts/src/planning/task.ts
|
|
2
|
+
//
|
|
3
|
+
// Task and implementation plan contracts. Declared in M0; produced by the
|
|
4
|
+
// implementation-planning skill in M4 and validated by kit validate-plan.
|
|
5
|
+
//
|
|
6
|
+
// See docs/contracts/CONTRACTS.md §5.
|
|
7
|
+
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
|
|
10
|
+
export const TaskScopeSchema = z.enum(['xs', 's', 'm', 'l', 'xl']);
|
|
11
|
+
export const RiskLevelSchema = z.enum(['low', 'medium', 'high']);
|
|
12
|
+
|
|
13
|
+
export const TaskVerificationSchema = z.object({
|
|
14
|
+
command: z.array(z.string().min(1)).min(1, 'verification command must be a non-empty array'),
|
|
15
|
+
expectedStatus: z.enum(['passed', 'failed', 'skipped', 'blocked']),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const TaskSchema = z.object({
|
|
19
|
+
id: z.string().regex(/^[A-Z]+-[0-9]{3,}$/, 'id must match TASK-NNN'),
|
|
20
|
+
description: z.string().min(1),
|
|
21
|
+
acceptanceCriteria: z.array(z.string().min(1)).min(1),
|
|
22
|
+
verification: TaskVerificationSchema,
|
|
23
|
+
dependencies: z.array(z.string()),
|
|
24
|
+
likelyFiles: z.array(z.string()),
|
|
25
|
+
estimatedScope: TaskScopeSchema,
|
|
26
|
+
risk: RiskLevelSchema,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const DependencyEdgeSchema = z.object({
|
|
30
|
+
from: z.string(),
|
|
31
|
+
to: z.string(),
|
|
32
|
+
reason: z.string().min(1),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const ImplementationPlanSchema = z.object({
|
|
36
|
+
featureId: z.string().regex(/^[A-Z]+-[0-9]{3,}$/, 'featureId must match FEATURE-NNN'),
|
|
37
|
+
tasks: z.array(TaskSchema),
|
|
38
|
+
edges: z.array(DependencyEdgeSchema),
|
|
39
|
+
verticalSlices: z.array(z.array(z.string())),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export type Task = z.infer<typeof TaskSchema>;
|
|
43
|
+
export type TaskVerification = z.infer<typeof TaskVerificationSchema>;
|
|
44
|
+
export type DependencyEdge = z.infer<typeof DependencyEdgeSchema>;
|
|
45
|
+
export type ImplementationPlan = z.infer<typeof ImplementationPlanSchema>;
|
|
46
|
+
export type TaskScope = z.infer<typeof TaskScopeSchema>;
|
|
47
|
+
export type RiskLevel = z.infer<typeof RiskLevelSchema>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// packages/contracts/src/policy/policy.test.ts
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { PolicyDecisionSchema, type PolicyDecision } from './policy.js';
|
|
4
|
+
|
|
5
|
+
const allow: PolicyDecision = { action: 'file.delete', verdict: 'allow', reason: 'scope=1' };
|
|
6
|
+
const deny: PolicyDecision = { action: 'git.force-push', verdict: 'deny', reason: 'always' };
|
|
7
|
+
const requireApproval: PolicyDecision = {
|
|
8
|
+
action: 'db.migrate',
|
|
9
|
+
verdict: 'require-approval',
|
|
10
|
+
reason: 'destructive',
|
|
11
|
+
approver: 'user',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
describe('PolicyDecisionSchema', () => {
|
|
15
|
+
it('accepts allow', () => {
|
|
16
|
+
expect(PolicyDecisionSchema.safeParse(allow).success).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
it('accepts deny', () => {
|
|
19
|
+
expect(PolicyDecisionSchema.safeParse(deny).success).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
it('accepts require-approval', () => {
|
|
22
|
+
expect(PolicyDecisionSchema.safeParse(requireApproval).success).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
it('rejects require-approval without approver', () => {
|
|
25
|
+
const { approver: _omit, ...rest } = requireApproval;
|
|
26
|
+
void _omit;
|
|
27
|
+
expect(PolicyDecisionSchema.safeParse(rest).success).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
it('rejects an unknown verdict', () => {
|
|
30
|
+
expect(PolicyDecisionSchema.safeParse({ ...allow, verdict: 'maybe' }).success).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
it('rejects an unknown action', () => {
|
|
33
|
+
expect(PolicyDecisionSchema.safeParse({ ...allow, action: 'file.format' }).success).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('PolicyDecision discriminated union', () => {
|
|
38
|
+
// Compile-time check that narrowing works on `verdict`. If this compiles,
|
|
39
|
+
// the discriminated union is correctly defined.
|
|
40
|
+
const narrow = (d: PolicyDecision): string => {
|
|
41
|
+
if (d.verdict === 'allow') return `allow:${d.action}`;
|
|
42
|
+
if (d.verdict === 'deny') return `deny:${d.action}`;
|
|
43
|
+
return `require-approval:${d.approver}`;
|
|
44
|
+
};
|
|
45
|
+
it('narrows on verdict', () => {
|
|
46
|
+
expect(narrow(allow)).toBe('allow:file.delete');
|
|
47
|
+
expect(narrow(deny)).toBe('deny:git.force-push');
|
|
48
|
+
expect(narrow(requireApproval)).toBe('require-approval:user');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// packages/contracts/src/policy/policy.ts
|
|
2
|
+
//
|
|
3
|
+
// Policy decision contract. The evaluator in core.policy.evaluator is a
|
|
4
|
+
// pure function: evaluate(action, context, policy) => PolicyDecision.
|
|
5
|
+
//
|
|
6
|
+
// Critical invariant (see docs/security/SECURITY.md §3.2):
|
|
7
|
+
// A bypass that silently turns `deny` into `allow` is a Critical bug.
|
|
8
|
+
// The verdict is terminal for a given action; no later stage may flip it.
|
|
9
|
+
//
|
|
10
|
+
// See docs/contracts/CONTRACTS.md §7 and ADR-0009.
|
|
11
|
+
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
|
|
14
|
+
export const PolicyActionSchema = z.enum([
|
|
15
|
+
'file.delete',
|
|
16
|
+
'file.bulk-modify',
|
|
17
|
+
'db.migrate',
|
|
18
|
+
'db.production-mutate',
|
|
19
|
+
'git.force-push',
|
|
20
|
+
'release.deploy',
|
|
21
|
+
'secret.modify',
|
|
22
|
+
'dependency.remove',
|
|
23
|
+
]);
|
|
24
|
+
export type PolicyAction = z.infer<typeof PolicyActionSchema>;
|
|
25
|
+
|
|
26
|
+
export const VerdictSchema = z.enum(['allow', 'deny', 'require-approval']);
|
|
27
|
+
export type Verdict = z.infer<typeof VerdictSchema>;
|
|
28
|
+
|
|
29
|
+
export const PolicyDecisionSchema = z.discriminatedUnion('verdict', [
|
|
30
|
+
z.object({
|
|
31
|
+
action: PolicyActionSchema,
|
|
32
|
+
verdict: z.literal('allow'),
|
|
33
|
+
reason: z.string().min(1),
|
|
34
|
+
}),
|
|
35
|
+
z.object({
|
|
36
|
+
action: PolicyActionSchema,
|
|
37
|
+
verdict: z.literal('deny'),
|
|
38
|
+
reason: z.string().min(1),
|
|
39
|
+
}),
|
|
40
|
+
z.object({
|
|
41
|
+
action: PolicyActionSchema,
|
|
42
|
+
verdict: z.literal('require-approval'),
|
|
43
|
+
reason: z.string().min(1),
|
|
44
|
+
approver: z.string().min(1),
|
|
45
|
+
}),
|
|
46
|
+
]);
|
|
47
|
+
export type PolicyDecision = z.infer<typeof PolicyDecisionSchema>;
|
|
48
|
+
|
|
49
|
+
export const ApprovalSchema = z.object({
|
|
50
|
+
action: PolicyActionSchema,
|
|
51
|
+
approver: z.string().min(1),
|
|
52
|
+
grantedAt: z.string().min(1),
|
|
53
|
+
rationale: z.string().min(1),
|
|
54
|
+
});
|
|
55
|
+
export type Approval = z.infer<typeof ApprovalSchema>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Context passed to the policy evaluator. M1 only carries the fields
|
|
59
|
+
// needed for the baseline invariants; M10 adds scope, file counts, env
|
|
60
|
+
// (interactive vs CI), and the active approval token.
|
|
61
|
+
*/
|
|
62
|
+
export const PolicyContextSchema = z.object({
|
|
63
|
+
interactive: z.boolean(),
|
|
64
|
+
scopeFileCount: z.number().int().nonnegative().optional(),
|
|
65
|
+
isProduction: z.boolean().optional(),
|
|
66
|
+
});
|
|
67
|
+
export type PolicyContext = z.infer<typeof PolicyContextSchema>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// packages/contracts/src/product/mvp-scope.ts
|
|
2
|
+
//
|
|
3
|
+
// MVP scope definition (M8 Phase B — M8-10).
|
|
4
|
+
//
|
|
5
|
+
// Records what is in the MVP and what is explicitly out of scope. The
|
|
6
|
+
// boundary is enforced: tasks in the implementation plan MUST trace to an
|
|
7
|
+
// MVP-scoped requirement; tasks that trace to out-of-scope requirements
|
|
8
|
+
// are rejected by the plan validator.
|
|
9
|
+
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
|
|
12
|
+
export const MvpScopeSchema = z.object({
|
|
13
|
+
schemaVersion: z.literal(1),
|
|
14
|
+
briefId: z.string(),
|
|
15
|
+
inScopeRequirementIds: z.array(z.string()),
|
|
16
|
+
outOfScopeRequirementIds: z.array(z.string()),
|
|
17
|
+
releaseBoundary: z.enum(['mvp', 'post-mvp', 'future']),
|
|
18
|
+
rationale: z.string().min(1),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type MvpScope = z.infer<typeof MvpScopeSchema>;
|