onto-mcp 0.3.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/.onto/authority/core-lens-registry.yaml +134 -0
- package/.onto/authority/core-lexicon.yaml +1562 -0
- package/.onto/authority/diagnostic-codes.yaml +94 -0
- package/.onto/domains/accounting/competency_qs.md +384 -0
- package/.onto/domains/accounting/concepts.md +186 -0
- package/.onto/domains/accounting/conciseness_rules.md +160 -0
- package/.onto/domains/accounting/dependency_rules.md +239 -0
- package/.onto/domains/accounting/domain_scope.md +213 -0
- package/.onto/domains/accounting/extension_cases.md +416 -0
- package/.onto/domains/accounting/logic_rules.md +226 -0
- package/.onto/domains/accounting/structure_spec.md +298 -0
- package/.onto/domains/accounting-kr/competency_qs.md +562 -0
- package/.onto/domains/accounting-kr/concepts.md +187 -0
- package/.onto/domains/accounting-kr/conciseness_rules.md +125 -0
- package/.onto/domains/accounting-kr/dependency_rules.md +93 -0
- package/.onto/domains/accounting-kr/domain_scope.md +140 -0
- package/.onto/domains/accounting-kr/extension_cases.md +343 -0
- package/.onto/domains/accounting-kr/logic_rules.md +160 -0
- package/.onto/domains/accounting-kr/structure_spec.md +85 -0
- package/.onto/domains/business/competency_qs.md +263 -0
- package/.onto/domains/business/concepts.md +200 -0
- package/.onto/domains/business/conciseness_rules.md +135 -0
- package/.onto/domains/business/dependency_rules.md +113 -0
- package/.onto/domains/business/domain_scope.md +240 -0
- package/.onto/domains/business/extension_cases.md +249 -0
- package/.onto/domains/business/logic_rules.md +134 -0
- package/.onto/domains/business/structure_spec.md +114 -0
- package/.onto/domains/finance/competency_qs.md +362 -0
- package/.onto/domains/finance/concepts.md +194 -0
- package/.onto/domains/finance/conciseness_rules.md +155 -0
- package/.onto/domains/finance/dependency_rules.md +171 -0
- package/.onto/domains/finance/domain_scope.md +215 -0
- package/.onto/domains/finance/extension_cases.md +350 -0
- package/.onto/domains/finance/logic_rules.md +191 -0
- package/.onto/domains/finance/structure_spec.md +182 -0
- package/.onto/domains/llm-native-development/competency_qs.md +430 -0
- package/.onto/domains/llm-native-development/concepts.md +242 -0
- package/.onto/domains/llm-native-development/conciseness_rules.md +163 -0
- package/.onto/domains/llm-native-development/dependency_rules.md +216 -0
- package/.onto/domains/llm-native-development/domain_scope.md +197 -0
- package/.onto/domains/llm-native-development/extension_cases.md +474 -0
- package/.onto/domains/llm-native-development/logic_rules.md +123 -0
- package/.onto/domains/llm-native-development/prompt_interface.md +49 -0
- package/.onto/domains/llm-native-development/structure_spec.md +245 -0
- package/.onto/domains/market-intelligence/competency_qs.md +274 -0
- package/.onto/domains/market-intelligence/concepts.md +233 -0
- package/.onto/domains/market-intelligence/conciseness_rules.md +165 -0
- package/.onto/domains/market-intelligence/dependency_rules.md +197 -0
- package/.onto/domains/market-intelligence/domain_scope.md +231 -0
- package/.onto/domains/market-intelligence/extension_cases.md +425 -0
- package/.onto/domains/market-intelligence/logic_rules.md +247 -0
- package/.onto/domains/market-intelligence/structure_spec.md +209 -0
- package/.onto/domains/ontology/competency_qs.md +394 -0
- package/.onto/domains/ontology/concepts.md +172 -0
- package/.onto/domains/ontology/conciseness_rules.md +134 -0
- package/.onto/domains/ontology/dependency_rules.md +125 -0
- package/.onto/domains/ontology/domain_scope.md +114 -0
- package/.onto/domains/ontology/extension_cases.md +501 -0
- package/.onto/domains/ontology/logic_rules.md +114 -0
- package/.onto/domains/ontology/problem_framing_profile.md +67 -0
- package/.onto/domains/ontology/structure_spec.md +115 -0
- package/.onto/domains/palantir-foundry/RESEARCH_NOTES.md +911 -0
- package/.onto/domains/palantir-foundry/competency_qs.md +191 -0
- package/.onto/domains/palantir-foundry/competitive_comparison.md +329 -0
- package/.onto/domains/palantir-foundry/concepts.md +197 -0
- package/.onto/domains/palantir-foundry/conciseness_rules.md +245 -0
- package/.onto/domains/palantir-foundry/dependency_rules.md +135 -0
- package/.onto/domains/palantir-foundry/domain_scope.md +395 -0
- package/.onto/domains/palantir-foundry/extension_cases.md +210 -0
- package/.onto/domains/palantir-foundry/logic_rules.md +172 -0
- package/.onto/domains/palantir-foundry/structure_spec.md +291 -0
- package/.onto/domains/software-engineering/competency_qs.md +538 -0
- package/.onto/domains/software-engineering/concepts.md +238 -0
- package/.onto/domains/software-engineering/conciseness_rules.md +167 -0
- package/.onto/domains/software-engineering/dependency_rules.md +216 -0
- package/.onto/domains/software-engineering/domain_scope.md +183 -0
- package/.onto/domains/software-engineering/extension_cases.md +551 -0
- package/.onto/domains/software-engineering/logic_rules.md +240 -0
- package/.onto/domains/software-engineering/problem_framing_profile.md +68 -0
- package/.onto/domains/software-engineering/structure_spec.md +185 -0
- package/.onto/domains/ui-design/competency_qs.md +567 -0
- package/.onto/domains/ui-design/concepts.md +194 -0
- package/.onto/domains/ui-design/conciseness_rules.md +190 -0
- package/.onto/domains/ui-design/dependency_rules.md +323 -0
- package/.onto/domains/ui-design/domain_scope.md +340 -0
- package/.onto/domains/ui-design/extension_cases.md +563 -0
- package/.onto/domains/ui-design/logic_rules.md +349 -0
- package/.onto/domains/ui-design/structure_spec.md +252 -0
- package/.onto/domains/visual-design/competency_qs.md +472 -0
- package/.onto/domains/visual-design/concepts.md +147 -0
- package/.onto/domains/visual-design/conciseness_rules.md +186 -0
- package/.onto/domains/visual-design/dependency_rules.md +282 -0
- package/.onto/domains/visual-design/domain_scope.md +290 -0
- package/.onto/domains/visual-design/extension_cases.md +480 -0
- package/.onto/domains/visual-design/logic_rules.md +232 -0
- package/.onto/domains/visual-design/structure_spec.md +213 -0
- package/.onto/principles/llm-native-development-guideline.md +401 -0
- package/.onto/principles/llm-runtime-interface-principles.md +665 -0
- package/.onto/principles/non-specialist-communication-guideline.md +74 -0
- package/.onto/principles/ontology-as-code-guideline.md +243 -0
- package/.onto/principles/ontology-as-code-naming-charter.md +130 -0
- package/.onto/principles/product-locality-principle.md +129 -0
- package/.onto/principles/productization-charter.md +569 -0
- package/.onto/processes/evolve/material-kind-adapter-contract.md +113 -0
- package/.onto/processes/reconstruct/reconstruct-boundary-contract.md +366 -0
- package/.onto/processes/reconstruct/source-profile-contract.md +107 -0
- package/.onto/processes/reconstruct/source-profiles/code.md +72 -0
- package/.onto/processes/reconstruct/source-profiles/database.md +74 -0
- package/.onto/processes/reconstruct/source-profiles/document.md +71 -0
- package/.onto/processes/reconstruct/source-profiles/spreadsheet.md +79 -0
- package/.onto/processes/review/binding-contract.md +270 -0
- package/.onto/processes/review/execution-preparation-artifacts.md +281 -0
- package/.onto/processes/review/interpretation-contract.md +245 -0
- package/.onto/processes/review/issue-stance-deliberation-contract.md +761 -0
- package/.onto/processes/review/lens-prompt-contract.md +402 -0
- package/.onto/processes/review/lens-registry.md +127 -0
- package/.onto/processes/review/pre-dispatch-contracts.md +428 -0
- package/.onto/processes/review/productized-live-path.md +398 -0
- package/.onto/processes/review/prompt-execution-runner-contract.md +187 -0
- package/.onto/processes/review/record-contract.md +427 -0
- package/.onto/processes/review/record-field-mapping.md +337 -0
- package/.onto/processes/review/review-context-manifest-contract.md +356 -0
- package/.onto/processes/review/review-execution-ux-contract.md +809 -0
- package/.onto/processes/review/review-target-profile-contract.md +259 -0
- package/.onto/processes/review/shared-phenomenon-contract.md +129 -0
- package/.onto/processes/review/synthesize-prompt-contract.md +343 -0
- package/.onto/processes/shared/target-material-kind-contract.md +198 -0
- package/.onto/roles/axiology.md +81 -0
- package/.onto/roles/conciseness.md +36 -0
- package/.onto/roles/coverage.md +34 -0
- package/.onto/roles/dependency.md +37 -0
- package/.onto/roles/evolution.md +35 -0
- package/.onto/roles/logic.md +104 -0
- package/.onto/roles/pragmatics.md +32 -0
- package/.onto/roles/semantics.md +36 -0
- package/.onto/roles/structure.md +33 -0
- package/.onto/roles/synthesize.md +92 -0
- package/AGENTS.md +240 -0
- package/CLAUDE.md +39 -0
- package/README.md +287 -0
- package/bin/onto +92 -0
- package/dist/cli.js +101 -0
- package/dist/core-api/reconstruct-api.js +222 -0
- package/dist/core-api/review-api.js +1271 -0
- package/dist/core-runtime/cli/assemble-review-record.js +431 -0
- package/dist/core-runtime/cli/bootstrap-review-binding.js +186 -0
- package/dist/core-runtime/cli/codex-nested-dispatch.js +226 -0
- package/dist/core-runtime/cli/codex-nested-dispatch.test.js +390 -0
- package/dist/core-runtime/cli/codex-nested-teamlead-executor.js +464 -0
- package/dist/core-runtime/cli/codex-nested-teamlead-executor.test.js +335 -0
- package/dist/core-runtime/cli/codex-review-unit-executor.js +228 -0
- package/dist/core-runtime/cli/complete-review-session.js +64 -0
- package/dist/core-runtime/cli/complexity-assessment.js +153 -0
- package/dist/core-runtime/cli/coordinator-helpers.js +583 -0
- package/dist/core-runtime/cli/coordinator-state-machine-deliberation.test.js +167 -0
- package/dist/core-runtime/cli/coordinator-state-machine.js +794 -0
- package/dist/core-runtime/cli/e2e-codex-multi-agent-fixes.test.js +615 -0
- package/dist/core-runtime/cli/e2e-start-review-session.test.js +312 -0
- package/dist/core-runtime/cli/health.js +44 -0
- package/dist/core-runtime/cli/inline-http-review-unit-executor.js +656 -0
- package/dist/core-runtime/cli/inline-http-review-unit-executor.test.js +567 -0
- package/dist/core-runtime/cli/materialize-review-execution-preparation.js +104 -0
- package/dist/core-runtime/cli/materialize-review-prompt-packets.js +952 -0
- package/dist/core-runtime/cli/migrate-session-roots.js +118 -0
- package/dist/core-runtime/cli/mock-review-unit-executor.js +285 -0
- package/dist/core-runtime/cli/onto-tools.js +369 -0
- package/dist/core-runtime/cli/prepare-review-session.js +272 -0
- package/dist/core-runtime/cli/render-review-final-output.js +350 -0
- package/dist/core-runtime/cli/repo-layout-migration-replace.smoke.test.js +106 -0
- package/dist/core-runtime/cli/review-invoke-auto-resolution.test.js +268 -0
- package/dist/core-runtime/cli/review-invoke-coordinator-topology.test.js +136 -0
- package/dist/core-runtime/cli/review-invoke-resolver-caching.test.js +201 -0
- package/dist/core-runtime/cli/review-invoke-topology-dispatch.test.js +192 -0
- package/dist/core-runtime/cli/review-invoke.js +2030 -0
- package/dist/core-runtime/cli/run-review-prompt-execution.js +2152 -0
- package/dist/core-runtime/cli/session-root-guard.js +168 -0
- package/dist/core-runtime/cli/spawn-watcher.js +173 -0
- package/dist/core-runtime/cli/spawn-watcher.test.js +457 -0
- package/dist/core-runtime/cli/start-review-session.js +68 -0
- package/dist/core-runtime/cli/strip-wrapping-code-fence.js +56 -0
- package/dist/core-runtime/cli/strip-wrapping-code-fence.test.js +79 -0
- package/dist/core-runtime/cli/teamcreate-lens-deliberation-executor.js +412 -0
- package/dist/core-runtime/cli/teamcreate-lens-deliberation-executor.test.js +351 -0
- package/dist/core-runtime/cli/topology-executor-mapping.js +139 -0
- package/dist/core-runtime/cli/topology-executor-mapping.test.js +173 -0
- package/dist/core-runtime/cli/write-review-interpretation.js +81 -0
- package/dist/core-runtime/config/onto-config-cli.js +278 -0
- package/dist/core-runtime/config/onto-config-key-path.js +288 -0
- package/dist/core-runtime/config/onto-config-key-path.test.js +195 -0
- package/dist/core-runtime/config/onto-config-preview.js +108 -0
- package/dist/core-runtime/config/onto-config-preview.test.js +132 -0
- package/dist/core-runtime/discovery/config-chain.js +118 -0
- package/dist/core-runtime/discovery/config-chain.test.js +103 -0
- package/dist/core-runtime/discovery/config-profile.js +199 -0
- package/dist/core-runtime/discovery/config-profile.test.js +233 -0
- package/dist/core-runtime/discovery/host-detection.js +33 -0
- package/dist/core-runtime/discovery/host-detection.test.js +186 -0
- package/dist/core-runtime/discovery/installation-paths.js +21 -0
- package/dist/core-runtime/discovery/installation-paths.test.js +65 -0
- package/dist/core-runtime/discovery/lens-registry.js +60 -0
- package/dist/core-runtime/discovery/lens-registry.test.js +81 -0
- package/dist/core-runtime/discovery/onto-home.js +71 -0
- package/dist/core-runtime/discovery/path-normalization.js +28 -0
- package/dist/core-runtime/discovery/path-normalization.test.js +22 -0
- package/dist/core-runtime/discovery/plugin-path.js +72 -0
- package/dist/core-runtime/discovery/plugin-path.test.js +95 -0
- package/dist/core-runtime/discovery/project-root.js +47 -0
- package/dist/core-runtime/discovery/settings-chain.js +353 -0
- package/dist/core-runtime/discovery/walk-up.js +17 -0
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile-defense.js +344 -0
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile-defense.test.js +915 -0
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile.js +564 -0
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile.test.js +708 -0
- package/dist/core-runtime/evolve/adapters/code-product/parsers/brief-parser.js +165 -0
- package/dist/core-runtime/evolve/adapters/code-product/parsers/brief-parser.test.js +227 -0
- package/dist/core-runtime/evolve/adapters/code-product/validators/validate.js +59 -0
- package/dist/core-runtime/evolve/adapters/code-product/validators/validate.test.js +205 -0
- package/dist/core-runtime/evolve/adapters/methodology/adapter.js +16 -0
- package/dist/core-runtime/evolve/adapters/methodology/adapter.test.js +9 -0
- package/dist/core-runtime/evolve/adapters/methodology/perspectives/authority-consistency.js +298 -0
- package/dist/core-runtime/evolve/adapters/methodology/perspectives/authority-consistency.test.js +70 -0
- package/dist/core-runtime/evolve/adapters/methodology/scope-types/process.js +46 -0
- package/dist/core-runtime/evolve/adapters/methodology/scope-types/process.test.js +73 -0
- package/dist/core-runtime/evolve/adapters/registry.js +47 -0
- package/dist/core-runtime/evolve/adapters/registry.test.js +67 -0
- package/dist/core-runtime/evolve/cli.js +256 -0
- package/dist/core-runtime/evolve/commands/align.js +194 -0
- package/dist/core-runtime/evolve/commands/align.test.js +82 -0
- package/dist/core-runtime/evolve/commands/apply.js +161 -0
- package/dist/core-runtime/evolve/commands/apply.test.js +138 -0
- package/dist/core-runtime/evolve/commands/close.js +39 -0
- package/dist/core-runtime/evolve/commands/close.test.js +99 -0
- package/dist/core-runtime/evolve/commands/defer.js +40 -0
- package/dist/core-runtime/evolve/commands/defer.test.js +134 -0
- package/dist/core-runtime/evolve/commands/draft.js +323 -0
- package/dist/core-runtime/evolve/commands/draft.test.js +178 -0
- package/dist/core-runtime/evolve/commands/e2e-evolve-full-cycle.test.js +208 -0
- package/dist/core-runtime/evolve/commands/error-messages.js +125 -0
- package/dist/core-runtime/evolve/commands/error-messages.test.js +167 -0
- package/dist/core-runtime/evolve/commands/propose-align.js +222 -0
- package/dist/core-runtime/evolve/commands/propose-align.test.js +136 -0
- package/dist/core-runtime/evolve/commands/reconstruct.js +330 -0
- package/dist/core-runtime/evolve/commands/reconstruct.test.js +278 -0
- package/dist/core-runtime/evolve/commands/shared.js +22 -0
- package/dist/core-runtime/evolve/commands/stale-check.js +103 -0
- package/dist/core-runtime/evolve/commands/stale-check.test.js +84 -0
- package/dist/core-runtime/evolve/commands/start.js +887 -0
- package/dist/core-runtime/evolve/commands/start.test.js +396 -0
- package/dist/core-runtime/evolve/config/project-config.js +99 -0
- package/dist/core-runtime/evolve/config/project-config.test.js +170 -0
- package/dist/core-runtime/evolve/renderers/align-packet.js +280 -0
- package/dist/core-runtime/evolve/renderers/align-packet.test.js +332 -0
- package/dist/core-runtime/evolve/renderers/draft-packet.js +303 -0
- package/dist/core-runtime/evolve/renderers/draft-packet.test.js +377 -0
- package/dist/core-runtime/evolve/renderers/format.js +5 -0
- package/dist/core-runtime/evolve/renderers/scope-md.js +237 -0
- package/dist/core-runtime/evolve/renderers/scope-md.test.js +306 -0
- package/dist/core-runtime/govern/cli.js +369 -0
- package/dist/core-runtime/govern/cli.test.js +314 -0
- package/dist/core-runtime/govern/drift-engine.js +103 -0
- package/dist/core-runtime/govern/drift-engine.test.js +319 -0
- package/dist/core-runtime/govern/promote-principle.js +206 -0
- package/dist/core-runtime/govern/promote-principle.test.js +368 -0
- package/dist/core-runtime/govern/queue.js +81 -0
- package/dist/core-runtime/govern/types.js +16 -0
- package/dist/core-runtime/install/cli.js +530 -0
- package/dist/core-runtime/install/detect.js +128 -0
- package/dist/core-runtime/install/detect.test.js +155 -0
- package/dist/core-runtime/install/gitignore-update.js +74 -0
- package/dist/core-runtime/install/gitignore-update.test.js +64 -0
- package/dist/core-runtime/install/install-integration.test.js +373 -0
- package/dist/core-runtime/install/prompts.js +389 -0
- package/dist/core-runtime/install/prompts.test.js +293 -0
- package/dist/core-runtime/install/types.js +26 -0
- package/dist/core-runtime/install/validation.js +295 -0
- package/dist/core-runtime/install/validation.test.js +313 -0
- package/dist/core-runtime/install/writer.js +254 -0
- package/dist/core-runtime/install/writer.test.js +218 -0
- package/dist/core-runtime/learning/extractor.js +461 -0
- package/dist/core-runtime/learning/feedback.js +179 -0
- package/dist/core-runtime/learning/health-report.js +165 -0
- package/dist/core-runtime/learning/health-report.test.js +169 -0
- package/dist/core-runtime/learning/loader.js +388 -0
- package/dist/core-runtime/learning/loader.test.js +102 -0
- package/dist/core-runtime/learning/promote/apply-state.js +240 -0
- package/dist/core-runtime/learning/promote/audit-obligation.js +195 -0
- package/dist/core-runtime/learning/promote/collector.js +432 -0
- package/dist/core-runtime/learning/promote/degraded-state.js +125 -0
- package/dist/core-runtime/learning/promote/domain-doc-proposer.js +166 -0
- package/dist/core-runtime/learning/promote/e2e-promote.test.js +6385 -0
- package/dist/core-runtime/learning/promote/health-snapshot.js +150 -0
- package/dist/core-runtime/learning/promote/insight-reclassifier.js +544 -0
- package/dist/core-runtime/learning/promote/judgment-auditor.js +517 -0
- package/dist/core-runtime/learning/promote/panel-reviewer.js +1158 -0
- package/dist/core-runtime/learning/promote/promote-executor.js +1675 -0
- package/dist/core-runtime/learning/promote/promoter.js +307 -0
- package/dist/core-runtime/learning/promote/retirement.js +122 -0
- package/dist/core-runtime/learning/promote/types.js +23 -0
- package/dist/core-runtime/learning/prompt-sections.js +51 -0
- package/dist/core-runtime/learning/shared/artifact-registry-init.js +45 -0
- package/dist/core-runtime/learning/shared/artifact-registry.js +254 -0
- package/dist/core-runtime/learning/shared/audit-obligation-kernel.js +73 -0
- package/dist/core-runtime/learning/shared/audit-state.js +99 -0
- package/dist/core-runtime/learning/shared/duplicate-check.js +28 -0
- package/dist/core-runtime/learning/shared/llm-caller.js +831 -0
- package/dist/core-runtime/learning/shared/llm-caller.test.js +601 -0
- package/dist/core-runtime/learning/shared/llm-tool-loop.js +393 -0
- package/dist/core-runtime/learning/shared/mode.js +25 -0
- package/dist/core-runtime/learning/shared/paths.js +84 -0
- package/dist/core-runtime/learning/shared/paths.test.js +79 -0
- package/dist/core-runtime/learning/shared/patterns.js +37 -0
- package/dist/core-runtime/learning/shared/recoverability.js +355 -0
- package/dist/core-runtime/learning/shared/recovery-context.js +374 -0
- package/dist/core-runtime/learning/shared/scope.js +1 -0
- package/dist/core-runtime/learning/shared/semantic-classifier.js +94 -0
- package/dist/core-runtime/learning/shared/specs/apply-execution-state-spec.js +42 -0
- package/dist/core-runtime/learning/shared/specs/audit-state-spec.js +37 -0
- package/dist/core-runtime/learning/shared/specs/backup-metadata-spec.js +39 -0
- package/dist/core-runtime/learning/shared/specs/emergency-log-spec.js +41 -0
- package/dist/core-runtime/learning/shared/specs/layout-version-spec.js +38 -0
- package/dist/core-runtime/learning/shared/specs/promote-decisions-spec.js +43 -0
- package/dist/core-runtime/learning/shared/specs/promote-report-spec.js +113 -0
- package/dist/core-runtime/learning/shared/specs/prune-log-spec.js +36 -0
- package/dist/core-runtime/learning/shared/specs/recovery-resolution-spec.js +48 -0
- package/dist/core-runtime/learning/shared/specs/restore-manifest-spec.js +43 -0
- package/dist/core-runtime/learning/shared/specs/spec-helpers.js +64 -0
- package/dist/core-runtime/learning/usage-tracker.js +190 -0
- package/dist/core-runtime/learning/usage-tracker.test.js +176 -0
- package/dist/core-runtime/llm/llm-caller.js +649 -0
- package/dist/core-runtime/llm/llm-tool-loop.js +401 -0
- package/dist/core-runtime/llm/model-switcher.js +62 -0
- package/dist/core-runtime/logger.js +22 -0
- package/dist/core-runtime/onboard/detect-review-axes.js +122 -0
- package/dist/core-runtime/onboard/detect-review-axes.test.js +127 -0
- package/dist/core-runtime/onboard/write-review-block.js +188 -0
- package/dist/core-runtime/onboard/write-review-block.test.js +240 -0
- package/dist/core-runtime/readers/brownfield-builder.js +150 -0
- package/dist/core-runtime/readers/brownfield-builder.test.js +136 -0
- package/dist/core-runtime/readers/code-chunk-collector.js +53 -0
- package/dist/core-runtime/readers/code-chunk-collector.test.js +136 -0
- package/dist/core-runtime/readers/file-utils.js +240 -0
- package/dist/core-runtime/readers/file-utils.test.js +146 -0
- package/dist/core-runtime/readers/lexicon-citation-check.js +93 -0
- package/dist/core-runtime/readers/lexicon-citation-check.test.js +77 -0
- package/dist/core-runtime/readers/mcp-figma.js +30 -0
- package/dist/core-runtime/readers/mcp-figma.test.js +82 -0
- package/dist/core-runtime/readers/mcp-generic.js +31 -0
- package/dist/core-runtime/readers/mcp-generic.test.js +76 -0
- package/dist/core-runtime/readers/ontology-index.js +148 -0
- package/dist/core-runtime/readers/ontology-index.test.js +245 -0
- package/dist/core-runtime/readers/ontology-query.js +168 -0
- package/dist/core-runtime/readers/ontology-query.test.js +311 -0
- package/dist/core-runtime/readers/ontology-resolve.js +48 -0
- package/dist/core-runtime/readers/ontology-resolve.test.js +48 -0
- package/dist/core-runtime/readers/patterns/index.js +7 -0
- package/dist/core-runtime/readers/review-log.js +213 -0
- package/dist/core-runtime/readers/review-log.test.js +313 -0
- package/dist/core-runtime/readers/scan-local.js +102 -0
- package/dist/core-runtime/readers/scan-local.test.js +102 -0
- package/dist/core-runtime/readers/scan-tarball.js +121 -0
- package/dist/core-runtime/readers/scan-tarball.test.js +283 -0
- package/dist/core-runtime/readers/scan-vault.js +34 -0
- package/dist/core-runtime/readers/scan-vault.test.js +81 -0
- package/dist/core-runtime/readers/types.js +42 -0
- package/dist/core-runtime/readers/types.test.js +94 -0
- package/dist/core-runtime/readers/viewpoint-collectors.js +229 -0
- package/dist/core-runtime/reconstruct/artifact-types.js +1 -0
- package/dist/core-runtime/reconstruct/directive-validation.js +123 -0
- package/dist/core-runtime/reconstruct/materialize-preparation.js +251 -0
- package/dist/core-runtime/reconstruct/record.js +198 -0
- package/dist/core-runtime/reconstruct/run.js +578 -0
- package/dist/core-runtime/reconstruct/seed-candidate-validation.js +356 -0
- package/dist/core-runtime/reconstruct/source-observations.js +62 -0
- package/dist/core-runtime/reconstruct/source-profiles.js +73 -0
- package/dist/core-runtime/release-channel/release-channel.js +90 -0
- package/dist/core-runtime/review/artifact-types.js +13 -0
- package/dist/core-runtime/review/citation-audit.js +204 -0
- package/dist/core-runtime/review/citation-audit.test.js +165 -0
- package/dist/core-runtime/review/controlled-lens-deliberation.js +125 -0
- package/dist/core-runtime/review/execution-plan-resolver.js +247 -0
- package/dist/core-runtime/review/execution-plan-resolver.test.js +243 -0
- package/dist/core-runtime/review/execution-topology-resolver-axis-first.test.js +246 -0
- package/dist/core-runtime/review/execution-topology-resolver.js +401 -0
- package/dist/core-runtime/review/execution-topology-resolver.test.js +315 -0
- package/dist/core-runtime/review/failure-records.js +57 -0
- package/dist/core-runtime/review/inline-context-embedder.js +141 -0
- package/dist/core-runtime/review/inline-context-embedder.test.js +154 -0
- package/dist/core-runtime/review/issue-artifact-runtime.js +859 -0
- package/dist/core-runtime/review/legacy-mode-policy.js +88 -0
- package/dist/core-runtime/review/lens-completion-policy.js +17 -0
- package/dist/core-runtime/review/materializers-effort-persist.test.js +79 -0
- package/dist/core-runtime/review/materializers.js +963 -0
- package/dist/core-runtime/review/ontology-path-classifier.js +179 -0
- package/dist/core-runtime/review/ontology-path-classifier.test.js +216 -0
- package/dist/core-runtime/review/packet-boundary-policy.js +215 -0
- package/dist/core-runtime/review/packet-boundary-policy.test.js +107 -0
- package/dist/core-runtime/review/participating-lens-paths.js +61 -0
- package/dist/core-runtime/review/participating-lens-paths.test.js +73 -0
- package/dist/core-runtime/review/review-artifact-utils.js +287 -0
- package/dist/core-runtime/review/review-config-legacy-translate.js +244 -0
- package/dist/core-runtime/review/review-config-legacy-translate.test.js +161 -0
- package/dist/core-runtime/review/review-config-validator.js +289 -0
- package/dist/core-runtime/review/review-config-validator.test.js +236 -0
- package/dist/core-runtime/review/review-execution-profile.js +193 -0
- package/dist/core-runtime/review/review-execution-route.js +52 -0
- package/dist/core-runtime/review/review-progress-contract.js +123 -0
- package/dist/core-runtime/review/review-record-validation.js +251 -0
- package/dist/core-runtime/review/review-result-classification.js +379 -0
- package/dist/core-runtime/review/review-state-machine.js +39 -0
- package/dist/core-runtime/review/route-visibility.js +125 -0
- package/dist/core-runtime/review/shape-pipeline-audit.test.js +311 -0
- package/dist/core-runtime/review/shape-to-topology-id.js +117 -0
- package/dist/core-runtime/review/shape-to-topology-id.test.js +132 -0
- package/dist/core-runtime/review/topology-shape-derivation.js +155 -0
- package/dist/core-runtime/review/topology-shape-derivation.test.js +195 -0
- package/dist/core-runtime/scope-runtime/constants.js +12 -0
- package/dist/core-runtime/scope-runtime/constraint-pool.js +166 -0
- package/dist/core-runtime/scope-runtime/constraint-pool.test.js +674 -0
- package/dist/core-runtime/scope-runtime/domain-validation-log.js +135 -0
- package/dist/core-runtime/scope-runtime/domain-validation-log.test.js +156 -0
- package/dist/core-runtime/scope-runtime/eval-persistence.js +65 -0
- package/dist/core-runtime/scope-runtime/eval-persistence.test.js +84 -0
- package/dist/core-runtime/scope-runtime/event-pipeline.js +64 -0
- package/dist/core-runtime/scope-runtime/event-pipeline.test.js +450 -0
- package/dist/core-runtime/scope-runtime/event-store.js +39 -0
- package/dist/core-runtime/scope-runtime/event-store.test.js +95 -0
- package/dist/core-runtime/scope-runtime/gate-guard.js +348 -0
- package/dist/core-runtime/scope-runtime/gate-guard.test.js +1047 -0
- package/dist/core-runtime/scope-runtime/hash.js +4 -0
- package/dist/core-runtime/scope-runtime/hash.test.js +33 -0
- package/dist/core-runtime/scope-runtime/id.js +4 -0
- package/dist/core-runtime/scope-runtime/id.test.js +17 -0
- package/dist/core-runtime/scope-runtime/reducer.js +297 -0
- package/dist/core-runtime/scope-runtime/reducer.test.js +759 -0
- package/dist/core-runtime/scope-runtime/scope-manager.js +161 -0
- package/dist/core-runtime/scope-runtime/state-machine.js +309 -0
- package/dist/core-runtime/scope-runtime/state-machine.test.js +704 -0
- package/dist/core-runtime/scope-runtime/types.js +116 -0
- package/dist/core-runtime/scope-runtime/types.test.js +69 -0
- package/dist/core-runtime/target-material-kind.js +256 -0
- package/dist/core-runtime/translate/render-for-user.js +169 -0
- package/dist/core-runtime/translate/render-for-user.test.js +122 -0
- package/dist/mcp/server.js +1011 -0
- package/dist/mcp/tool-schemas.js +93 -0
- package/dist/providers/capability-contract.js +1 -0
- package/package.json +68 -0
- package/settings.example.json +33 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve all standard paths for a scope.
|
|
5
|
+
*/
|
|
6
|
+
export function resolveScopePaths(scopesDir, scopeId) {
|
|
7
|
+
const base = join(scopesDir, scopeId);
|
|
8
|
+
return {
|
|
9
|
+
scopeId,
|
|
10
|
+
base,
|
|
11
|
+
events: join(base, "events.ndjson"),
|
|
12
|
+
state: join(base, "state"),
|
|
13
|
+
surface: join(base, "surface"),
|
|
14
|
+
build: join(base, "build"),
|
|
15
|
+
inputs: join(base, "inputs"),
|
|
16
|
+
constraintPool: join(base, "state", "constraint-pool.json"),
|
|
17
|
+
verdictLog: join(base, "state", "verdict-log.json"),
|
|
18
|
+
realitySnapshot: join(base, "state", "reality-snapshot.json"),
|
|
19
|
+
sourcesYaml: join(base, "inputs", "sources.yaml"),
|
|
20
|
+
scopeMd: join(base, "scope.md"),
|
|
21
|
+
brief: join(base, "inputs", "brief.md"),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
// ─── Scope ID generation ───
|
|
25
|
+
/**
|
|
26
|
+
* Normalize a project name for use in scope IDs.
|
|
27
|
+
* Lowercase, spaces→hyphens, remove chars except alphanumeric and hyphens,
|
|
28
|
+
* collapse consecutive hyphens, trim leading/trailing hyphens.
|
|
29
|
+
*/
|
|
30
|
+
export function normalizeProjectName(name) {
|
|
31
|
+
return name
|
|
32
|
+
.toLowerCase()
|
|
33
|
+
.replace(/\s+/g, "-")
|
|
34
|
+
.replace(/[^a-z0-9-]/g, "")
|
|
35
|
+
.replace(/-+/g, "-")
|
|
36
|
+
.replace(/^-|-$/g, "");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generate a scope ID in `{projectName}-{YYYYMMDD}-{NNN}` format.
|
|
40
|
+
*
|
|
41
|
+
* 1. Normalizes projectName (lowercase, spaces→hyphens, special chars removed)
|
|
42
|
+
* 2. Gets today's date as YYYYMMDD
|
|
43
|
+
* 3. Scans existing directories matching `{normalized}-{YYYYMMDD}-*`
|
|
44
|
+
* 4. Returns next sequential NNN (001-based, 3-digit zero-padded)
|
|
45
|
+
*/
|
|
46
|
+
export function generateScopeId(scopesDir, projectName, date) {
|
|
47
|
+
const normalized = normalizeProjectName(projectName);
|
|
48
|
+
if (normalized.length === 0) {
|
|
49
|
+
throw new Error("projectName must contain at least one alphanumeric character");
|
|
50
|
+
}
|
|
51
|
+
const d = date ?? new Date();
|
|
52
|
+
const yyyymmdd = String(d.getFullYear()) +
|
|
53
|
+
String(d.getMonth() + 1).padStart(2, "0") +
|
|
54
|
+
String(d.getDate()).padStart(2, "0");
|
|
55
|
+
const prefix = `${normalized}-${yyyymmdd}-`;
|
|
56
|
+
let maxN = 0;
|
|
57
|
+
if (existsSync(scopesDir)) {
|
|
58
|
+
const entries = readdirSync(scopesDir, { withFileTypes: true });
|
|
59
|
+
for (const entry of entries) {
|
|
60
|
+
if (entry.isDirectory() && entry.name.startsWith(prefix)) {
|
|
61
|
+
const suffix = entry.name.slice(prefix.length);
|
|
62
|
+
const n = parseInt(suffix, 10);
|
|
63
|
+
if (!isNaN(n) && n > maxN) {
|
|
64
|
+
maxN = n;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const nnn = String(maxN + 1).padStart(3, "0");
|
|
70
|
+
return `${normalized}-${yyyymmdd}-${nnn}`;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Generate a brief.md template for a scope.
|
|
74
|
+
*
|
|
75
|
+
* 1. What it is: brief.md는 /start 실행 전에 작성하는 프로젝트 준비 문서 템플릿입니다.
|
|
76
|
+
* 변경 목적, 대상 사용자, 기대 결과 등 필수 정보를 수집합니다.
|
|
77
|
+
* 2. Why it exists: 소스 스캔 전에 프로젝트의 방향과 맥락을 명확히 해야
|
|
78
|
+
* grounding 단계에서 올바른 constraint를 발견할 수 있습니다.
|
|
79
|
+
* 3. How it relates: createScope가 호출할 때 inputs/brief.md로 기록되며,
|
|
80
|
+
* 에이전트가 /start 실행 시 이 파일의 내용을 참조합니다.
|
|
81
|
+
*/
|
|
82
|
+
export function generateBriefTemplate(projectName, defaultSources) {
|
|
83
|
+
const sourcesSection = defaultSources && defaultSources.length > 0
|
|
84
|
+
? defaultSources
|
|
85
|
+
.map((s) => {
|
|
86
|
+
const desc = s.description ?? `${s.type}: ${s.identifier}`;
|
|
87
|
+
return `- [x] ${desc} (${s.type}: ${s.identifier})`;
|
|
88
|
+
})
|
|
89
|
+
.join("\n")
|
|
90
|
+
: "- 환경설정 파일(.sprint-kit.yaml)이 없거나 소스가 정의되지 않았습니다.";
|
|
91
|
+
return `# ${projectName} — Brief
|
|
92
|
+
|
|
93
|
+
<!-- 이 문서는 /start 실행 전에 작성하는 프로젝트 준비 문서입니다. -->
|
|
94
|
+
<!-- 필수 항목을 채운 후 /start ${projectName}을 다시 실행하면 프로세스가 시작됩니다. -->
|
|
95
|
+
|
|
96
|
+
## 변경 목적 (필수)
|
|
97
|
+
<!-- 왜 이 변경이 필요한가요? 해결하려는 문제를 설명해 주세요. -->
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## 대상 사용자 (필수)
|
|
102
|
+
<!-- 이 변경이 영향을 미치는 사용자는 누구인가요? -->
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## 기대 결과 (필수)
|
|
107
|
+
<!-- 이 변경이 성공하면 어떤 상태가 되나요? -->
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
## 포함 범위
|
|
112
|
+
<!-- 이번에 포함할 기능이나 변경 사항을 나열해 주세요. (선택) -->
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
## 제외 범위
|
|
117
|
+
<!-- 이번에 포함하지 않을 사항을 나열해 주세요. (선택) -->
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
## 제약 및 참고사항
|
|
122
|
+
<!-- 이미 알고 있는 제약(일정, 기술 제한 등)이나 참고할 정보를 적어 주세요. (선택) -->
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## 소스
|
|
127
|
+
<!-- .sprint-kit.yaml에서 자동 로드됨. 추가 소스를 아래에 기입하세요. -->
|
|
128
|
+
|
|
129
|
+
### 자동 로드 (환경설정)
|
|
130
|
+
${sourcesSection}
|
|
131
|
+
|
|
132
|
+
### 추가 소스
|
|
133
|
+
- [ ] (여기에 추가 소스를 기입하세요)
|
|
134
|
+
`;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create a scope directory with all standard subdirectories.
|
|
138
|
+
* Returns the resolved paths. Idempotent — safe to call on existing scope.
|
|
139
|
+
*
|
|
140
|
+
* If projectName is provided, generates scopeId automatically using
|
|
141
|
+
* `{projectName}-{YYYYMMDD}-{NNN}` format.
|
|
142
|
+
* If only scopeId is provided (backward compat), uses it directly.
|
|
143
|
+
*/
|
|
144
|
+
export function createScope(scopesDir, scopeId, options) {
|
|
145
|
+
const finalScopeId = options?.projectName != null
|
|
146
|
+
? generateScopeId(scopesDir, options.projectName, options.date)
|
|
147
|
+
: scopeId;
|
|
148
|
+
const paths = resolveScopePaths(scopesDir, finalScopeId);
|
|
149
|
+
const dirs = [paths.base, paths.state, paths.surface, paths.build, paths.inputs];
|
|
150
|
+
for (const dir of dirs) {
|
|
151
|
+
if (!existsSync(dir)) {
|
|
152
|
+
mkdirSync(dir, { recursive: true });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (!existsSync(paths.brief)) {
|
|
156
|
+
const name = options?.projectName ?? scopeId;
|
|
157
|
+
const template = generateBriefTemplate(name, options?.defaultSources);
|
|
158
|
+
writeFileSync(paths.brief, template, "utf-8");
|
|
159
|
+
}
|
|
160
|
+
return paths;
|
|
161
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { TERMINAL_STATES, OBSERVATIONAL_EVENT_TYPES } from "./types.js";
|
|
2
|
+
const OBSERVATIONAL_SET = new Set(OBSERVATIONAL_EVENT_TYPES);
|
|
3
|
+
// State × TransitionEvent matrix.
|
|
4
|
+
// Only explicitly listed combinations are allowed. Everything else is denied.
|
|
5
|
+
const MATRIX = {
|
|
6
|
+
// ── draft ──
|
|
7
|
+
draft: {
|
|
8
|
+
"input.attached": { next: "draft", kind: "self" },
|
|
9
|
+
"grounding.started": { next: "draft", kind: "self" },
|
|
10
|
+
"grounding.completed": { next: "grounded", kind: "forward" },
|
|
11
|
+
"constraint.discovered": { next: "draft", kind: "self" },
|
|
12
|
+
},
|
|
13
|
+
// ── grounded ──
|
|
14
|
+
grounded: {
|
|
15
|
+
"align.proposed": { next: "align_proposed", kind: "forward" },
|
|
16
|
+
"constraint.discovered": { next: "grounded", kind: "self" },
|
|
17
|
+
"snapshot.marked_stale": { next: "grounded", kind: "self" },
|
|
18
|
+
"exploration.started": { next: "exploring", kind: "forward" },
|
|
19
|
+
},
|
|
20
|
+
// ── exploring ──
|
|
21
|
+
exploring: {
|
|
22
|
+
"exploration.round_completed": { next: "exploring", kind: "self" },
|
|
23
|
+
"exploration.phase_transitioned": { next: "exploring", kind: "self" },
|
|
24
|
+
"align.proposed": { next: "align_proposed", kind: "forward" },
|
|
25
|
+
"constraint.discovered": { next: "exploring", kind: "self" },
|
|
26
|
+
"snapshot.marked_stale": { next: "exploring", kind: "self" },
|
|
27
|
+
"redirect.to_grounding": { next: "grounded", kind: "backward" },
|
|
28
|
+
},
|
|
29
|
+
// ── align_proposed ──
|
|
30
|
+
align_proposed: {
|
|
31
|
+
"align.locked": { next: "align_locked", kind: "forward" },
|
|
32
|
+
"align.revised": { next: "align_proposed", kind: "self" },
|
|
33
|
+
"snapshot.marked_stale": { next: "align_proposed", kind: "self" },
|
|
34
|
+
"redirect.to_grounding": { next: "grounded", kind: "backward" },
|
|
35
|
+
},
|
|
36
|
+
// ── align_locked ──
|
|
37
|
+
align_locked: {
|
|
38
|
+
"surface.generated": { next: "surface_iterating", kind: "forward" },
|
|
39
|
+
"snapshot.marked_stale": { next: "align_proposed", kind: "backward" },
|
|
40
|
+
},
|
|
41
|
+
// ── surface_iterating ──
|
|
42
|
+
surface_iterating: {
|
|
43
|
+
"surface.revision_requested": {
|
|
44
|
+
next: "surface_iterating",
|
|
45
|
+
kind: "self",
|
|
46
|
+
},
|
|
47
|
+
"surface.revision_applied": { next: "surface_iterating", kind: "self" },
|
|
48
|
+
"surface.confirmed": { next: "surface_confirmed", kind: "forward" },
|
|
49
|
+
"constraint.discovered": { next: "surface_iterating", kind: "self" },
|
|
50
|
+
"redirect.to_align": { next: "align_proposed", kind: "backward" },
|
|
51
|
+
"snapshot.marked_stale": { next: "surface_iterating", kind: "self" },
|
|
52
|
+
},
|
|
53
|
+
// ── surface_confirmed ──
|
|
54
|
+
surface_confirmed: {
|
|
55
|
+
"constraint.discovered": { next: "surface_confirmed", kind: "self" },
|
|
56
|
+
"constraint.decision_recorded": {
|
|
57
|
+
next: "surface_confirmed",
|
|
58
|
+
kind: "self",
|
|
59
|
+
conditional: ["constraints_resolved"],
|
|
60
|
+
},
|
|
61
|
+
"constraint.clarify_requested": {
|
|
62
|
+
next: "surface_confirmed",
|
|
63
|
+
kind: "self",
|
|
64
|
+
},
|
|
65
|
+
"constraint.clarify_resolved": {
|
|
66
|
+
next: "surface_confirmed",
|
|
67
|
+
kind: "self",
|
|
68
|
+
conditional: ["constraints_resolved"],
|
|
69
|
+
},
|
|
70
|
+
"constraint.invalidated": {
|
|
71
|
+
next: "surface_confirmed",
|
|
72
|
+
kind: "self",
|
|
73
|
+
conditional: ["constraints_resolved"],
|
|
74
|
+
},
|
|
75
|
+
"target.locked": { next: "target_locked", kind: "forward" },
|
|
76
|
+
"surface.change_required": {
|
|
77
|
+
next: "surface_iterating",
|
|
78
|
+
kind: "backward",
|
|
79
|
+
},
|
|
80
|
+
"redirect.to_align": { next: "align_proposed", kind: "backward" },
|
|
81
|
+
"snapshot.marked_stale": { next: "surface_confirmed", kind: "self" },
|
|
82
|
+
},
|
|
83
|
+
// ── constraints_resolved ──
|
|
84
|
+
constraints_resolved: {
|
|
85
|
+
"constraint.discovered": {
|
|
86
|
+
next: "surface_confirmed",
|
|
87
|
+
kind: "backward",
|
|
88
|
+
},
|
|
89
|
+
"constraint.decision_recorded": {
|
|
90
|
+
next: "constraints_resolved",
|
|
91
|
+
kind: "self",
|
|
92
|
+
},
|
|
93
|
+
"constraint.invalidated": { next: "constraints_resolved", kind: "self" },
|
|
94
|
+
"target.locked": { next: "target_locked", kind: "forward" },
|
|
95
|
+
"surface.change_required": {
|
|
96
|
+
next: "surface_iterating",
|
|
97
|
+
kind: "backward",
|
|
98
|
+
},
|
|
99
|
+
"redirect.to_align": { next: "align_proposed", kind: "backward" },
|
|
100
|
+
"snapshot.marked_stale": { next: "constraints_resolved", kind: "self" },
|
|
101
|
+
},
|
|
102
|
+
// ── target_locked ──
|
|
103
|
+
target_locked: {
|
|
104
|
+
"constraint.discovered": { next: "target_locked", kind: "self" },
|
|
105
|
+
"compile.started": { next: "target_locked", kind: "self" },
|
|
106
|
+
"compile.completed": { next: "compiled", kind: "forward" },
|
|
107
|
+
"compile.constraint_gap_found": {
|
|
108
|
+
next: "constraints_resolved",
|
|
109
|
+
kind: "backward",
|
|
110
|
+
},
|
|
111
|
+
"snapshot.marked_stale": {
|
|
112
|
+
next: "constraints_resolved",
|
|
113
|
+
kind: "backward",
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
// ── compiled ──
|
|
117
|
+
compiled: {
|
|
118
|
+
"constraint.discovered": { next: "compiled", kind: "self" },
|
|
119
|
+
"compile.constraint_gap_found": {
|
|
120
|
+
next: "constraints_resolved",
|
|
121
|
+
kind: "backward",
|
|
122
|
+
},
|
|
123
|
+
"apply.started": { next: "compiled", kind: "self" },
|
|
124
|
+
"apply.completed": { next: "applied", kind: "forward" },
|
|
125
|
+
"apply.decision_gap_found": {
|
|
126
|
+
next: "constraints_resolved",
|
|
127
|
+
kind: "backward",
|
|
128
|
+
},
|
|
129
|
+
"snapshot.marked_stale": { next: "grounded", kind: "backward" },
|
|
130
|
+
},
|
|
131
|
+
// ── applied ──
|
|
132
|
+
applied: {
|
|
133
|
+
"validation.started": { next: "applied", kind: "self" },
|
|
134
|
+
"validation.completed": {
|
|
135
|
+
next: "validated",
|
|
136
|
+
kind: "forward",
|
|
137
|
+
conditional: ["constraints_resolved", "grounded"],
|
|
138
|
+
},
|
|
139
|
+
"snapshot.marked_stale": { next: "applied", kind: "self" },
|
|
140
|
+
},
|
|
141
|
+
// ── validated ──
|
|
142
|
+
validated: {
|
|
143
|
+
"scope.closed": { next: "closed", kind: "forward" },
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
// validation.completed has conditional next state (pass vs fail).
|
|
147
|
+
// The matrix records the default (pass → validated).
|
|
148
|
+
// Gate guard / pipeline handles fail variants.
|
|
149
|
+
// This is documented here for completeness but the conditional logic
|
|
150
|
+
// lives in gate-guard.ts (Phase 2).
|
|
151
|
+
// ─── Public API ───
|
|
152
|
+
/**
|
|
153
|
+
* Check whether a transition event is allowed from the given state.
|
|
154
|
+
* Returns the outcome (allowed + next state, or denied).
|
|
155
|
+
*/
|
|
156
|
+
export function canTransition(state, eventType) {
|
|
157
|
+
const stateRow = MATRIX[state];
|
|
158
|
+
if (!stateRow) {
|
|
159
|
+
return { allowed: false };
|
|
160
|
+
}
|
|
161
|
+
const entry = stateRow[eventType];
|
|
162
|
+
if (!entry) {
|
|
163
|
+
return { allowed: false };
|
|
164
|
+
}
|
|
165
|
+
const result = {
|
|
166
|
+
allowed: true,
|
|
167
|
+
next_state: entry.next,
|
|
168
|
+
kind: entry.kind,
|
|
169
|
+
};
|
|
170
|
+
if (entry.conditional) {
|
|
171
|
+
result.conditional_targets = entry.conditional;
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Check whether a global event is allowed from the given state.
|
|
177
|
+
* Global events (scope.deferred, scope.rejected) are allowed from every non-terminal state.
|
|
178
|
+
*/
|
|
179
|
+
export function canApplyGlobal(state, eventType) {
|
|
180
|
+
if (TERMINAL_STATES.has(state)) {
|
|
181
|
+
return { allowed: false };
|
|
182
|
+
}
|
|
183
|
+
const targetState = eventType === "scope.deferred" ? "deferred" : "rejected";
|
|
184
|
+
return { allowed: true, next_state: targetState, kind: "forward" };
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Check whether an observational event is allowed from the given state.
|
|
188
|
+
* Observational events are allowed in every non-terminal state.
|
|
189
|
+
* They do not change state (state_after === state_before).
|
|
190
|
+
*/
|
|
191
|
+
export function canApplyObservational(state, _eventType) {
|
|
192
|
+
if (TERMINAL_STATES.has(state)) {
|
|
193
|
+
return { allowed: false };
|
|
194
|
+
}
|
|
195
|
+
return { allowed: true, next_state: state, kind: "self" };
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Unified check: given current state and any event type, return the transition outcome.
|
|
199
|
+
*/
|
|
200
|
+
export function resolveTransition(state, eventType) {
|
|
201
|
+
// Global events
|
|
202
|
+
if (eventType === "scope.deferred" || eventType === "scope.rejected") {
|
|
203
|
+
return canApplyGlobal(state, eventType);
|
|
204
|
+
}
|
|
205
|
+
// Observational events
|
|
206
|
+
if (OBSERVATIONAL_SET.has(eventType)) {
|
|
207
|
+
return canApplyObservational(state, eventType);
|
|
208
|
+
}
|
|
209
|
+
// Transition events
|
|
210
|
+
return canTransition(state, eventType);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get all allowed events from a given state (transition events only).
|
|
214
|
+
* Useful for debugging and testing.
|
|
215
|
+
*/
|
|
216
|
+
export function allowedTransitionEvents(state) {
|
|
217
|
+
const stateRow = MATRIX[state];
|
|
218
|
+
if (!stateRow)
|
|
219
|
+
return [];
|
|
220
|
+
return Object.keys(stateRow);
|
|
221
|
+
}
|
|
222
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
223
|
+
// Multi-domain state machine definitions (W-B-02 dedup)
|
|
224
|
+
//
|
|
225
|
+
// 본 파일이 모든 onto 프로세스 state machine 의 단일 SSOT.
|
|
226
|
+
// - Design scope: 위의 MATRIX (15 states)
|
|
227
|
+
// - Review coordinator: REVIEW_TRANSITIONS (9 states)
|
|
228
|
+
// - Reconstruct session: RECONSTRUCT_TRANSITIONS (8 states)
|
|
229
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
230
|
+
// ─── Review coordinator (10 states) ───
|
|
231
|
+
// auto 3: preparing, validating_lenses, completing
|
|
232
|
+
// await 4: awaiting_lens_dispatch, awaiting_adjudication, awaiting_synthesize_dispatch, awaiting_deliberation
|
|
233
|
+
// terminal 3: completed, halted_partial, failed
|
|
234
|
+
export const REVIEW_STATES = [
|
|
235
|
+
"preparing",
|
|
236
|
+
"awaiting_lens_dispatch",
|
|
237
|
+
"validating_lenses",
|
|
238
|
+
"awaiting_adjudication",
|
|
239
|
+
"awaiting_synthesize_dispatch",
|
|
240
|
+
"awaiting_deliberation",
|
|
241
|
+
"completing",
|
|
242
|
+
"completed",
|
|
243
|
+
"halted_partial",
|
|
244
|
+
"failed",
|
|
245
|
+
];
|
|
246
|
+
export const REVIEW_TERMINAL_STATES = new Set([
|
|
247
|
+
"completed",
|
|
248
|
+
"halted_partial",
|
|
249
|
+
"failed",
|
|
250
|
+
]);
|
|
251
|
+
export const REVIEW_TRANSITIONS = {
|
|
252
|
+
"(init)": ["preparing"],
|
|
253
|
+
preparing: ["awaiting_lens_dispatch", "failed"],
|
|
254
|
+
awaiting_lens_dispatch: ["validating_lenses"],
|
|
255
|
+
validating_lenses: ["awaiting_adjudication", "awaiting_deliberation", "halted_partial", "failed"],
|
|
256
|
+
awaiting_adjudication: ["awaiting_deliberation", "failed"],
|
|
257
|
+
awaiting_deliberation: ["awaiting_synthesize_dispatch", "failed"],
|
|
258
|
+
awaiting_synthesize_dispatch: ["completing"],
|
|
259
|
+
completing: ["completed", "failed"],
|
|
260
|
+
completed: [],
|
|
261
|
+
halted_partial: [],
|
|
262
|
+
failed: [],
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Review coordinator 전이 검증.
|
|
266
|
+
*/
|
|
267
|
+
export function canReviewTransition(from, to) {
|
|
268
|
+
const allowed = REVIEW_TRANSITIONS[from];
|
|
269
|
+
return allowed != null && allowed.includes(to);
|
|
270
|
+
}
|
|
271
|
+
// ─── Reconstruct session (8 states) ───
|
|
272
|
+
// build.md 의 Phase 0~4 를 형식화한 상태 모델.
|
|
273
|
+
// auto 4: negotiating, gathering_context, exploring, adjudicating
|
|
274
|
+
// await 2: awaiting_user_review, processing_responses
|
|
275
|
+
// terminal 2: converted, reconstruct_failed
|
|
276
|
+
export const RECONSTRUCT_STATES = [
|
|
277
|
+
"negotiating",
|
|
278
|
+
"gathering_context",
|
|
279
|
+
"reconstruct_exploring",
|
|
280
|
+
"adjudicating",
|
|
281
|
+
"awaiting_user_review",
|
|
282
|
+
"processing_responses",
|
|
283
|
+
"converting",
|
|
284
|
+
"converted",
|
|
285
|
+
"reconstruct_failed",
|
|
286
|
+
];
|
|
287
|
+
export const RECONSTRUCT_TERMINAL_STATES = new Set([
|
|
288
|
+
"converted",
|
|
289
|
+
"reconstruct_failed",
|
|
290
|
+
]);
|
|
291
|
+
export const RECONSTRUCT_TRANSITIONS = {
|
|
292
|
+
"(init)": ["negotiating"],
|
|
293
|
+
negotiating: ["gathering_context", "reconstruct_failed"], // Phase 0
|
|
294
|
+
gathering_context: ["reconstruct_exploring", "reconstruct_failed"], // Phase 0.5
|
|
295
|
+
reconstruct_exploring: ["adjudicating", "reconstruct_failed"], // Phase 1 (Stage 1+2)
|
|
296
|
+
adjudicating: ["awaiting_user_review", "reconstruct_failed"], // Phase 2
|
|
297
|
+
awaiting_user_review: ["processing_responses", "reconstruct_failed"], // Phase 3
|
|
298
|
+
processing_responses: ["converting", "awaiting_user_review", "reconstruct_failed"], // Phase 3.5 (re-entry 가능)
|
|
299
|
+
converting: ["converted", "reconstruct_failed"], // Phase 4
|
|
300
|
+
converted: [],
|
|
301
|
+
reconstruct_failed: [],
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Reconstruct session 전이 검증.
|
|
305
|
+
*/
|
|
306
|
+
export function canReconstructTransition(from, to) {
|
|
307
|
+
const allowed = RECONSTRUCT_TRANSITIONS[from];
|
|
308
|
+
return allowed != null && allowed.includes(to);
|
|
309
|
+
}
|