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,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Registry — DD-20 (central spec management).
|
|
3
|
+
*
|
|
4
|
+
* Design authority:
|
|
5
|
+
* - learn-phase3-design-v9.md DD-20 (lazy init + RegistryInitError + schema reject)
|
|
6
|
+
* - learn-phase3-design-v8.md DD-20 (lazy init + write enforcement + pre-v7 reject)
|
|
7
|
+
* - learn-phase3-design-v7.md DD-20 (introduction + spec contract)
|
|
8
|
+
*
|
|
9
|
+
* Why this exists:
|
|
10
|
+
* 1. Every persisted control artifact in Phase 3 must declare a spec
|
|
11
|
+
* describing its kind, supported schema versions, formats, and validators.
|
|
12
|
+
* 2. Without central registration, each artifact would re-implement parsing
|
|
13
|
+
* and version gates ad hoc — v6 review traced multiple drift bugs back to
|
|
14
|
+
* this pattern.
|
|
15
|
+
* 3. Lazy init means runtime entry points do not need to call initArtifactRegistry()
|
|
16
|
+
* explicitly. The first REGISTRY.loadFromFile / saveToFile call performs
|
|
17
|
+
* registration and caches success/failure.
|
|
18
|
+
*
|
|
19
|
+
* CLI-process-scoped runtime assumption (§12.7): Phase 3 commands run in
|
|
20
|
+
* short-lived processes. Init failure caching is per-process and recovery is
|
|
21
|
+
* "restart and re-run" by design. Phase 4 daemon work must revisit this.
|
|
22
|
+
*
|
|
23
|
+
* Write-side enforcement (SYN-CC1):
|
|
24
|
+
* - validate() runs on every save
|
|
25
|
+
* - format binding is derived from the file extension and checked against
|
|
26
|
+
* spec.supported_formats
|
|
27
|
+
* - schema_version on the data object MUST match spec.current_schema_version;
|
|
28
|
+
* undefined is rejected (SYN-CONS-03 v9 fix)
|
|
29
|
+
*/
|
|
30
|
+
import fs from "node:fs";
|
|
31
|
+
import path from "node:path";
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// Errors
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
export class RegistryInitError extends Error {
|
|
36
|
+
cause;
|
|
37
|
+
constructor(message, cause) {
|
|
38
|
+
super(`Artifact registry initialization failed: ${message}`);
|
|
39
|
+
this.name = "RegistryInitError";
|
|
40
|
+
if (cause)
|
|
41
|
+
this.cause = cause;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export class IncompatibleVersionError extends Error {
|
|
45
|
+
constructor(message) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.name = "IncompatibleVersionError";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class InvalidArtifactError extends Error {
|
|
51
|
+
constructor(message) {
|
|
52
|
+
super(message);
|
|
53
|
+
this.name = "InvalidArtifactError";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class UnregisteredArtifactKindError extends Error {
|
|
57
|
+
constructor(message) {
|
|
58
|
+
super(message);
|
|
59
|
+
this.name = "UnregisteredArtifactKindError";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export class ArtifactNotFoundError extends Error {
|
|
63
|
+
constructor(message) {
|
|
64
|
+
super(message);
|
|
65
|
+
this.name = "ArtifactNotFoundError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// Registry
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
class ArtifactRegistry {
|
|
72
|
+
specs = new Map();
|
|
73
|
+
initialized = false;
|
|
74
|
+
cachedInitError = null;
|
|
75
|
+
builtinRegistrar = null;
|
|
76
|
+
/**
|
|
77
|
+
* Inject the built-in spec registrar from artifact-registry-init.ts.
|
|
78
|
+
*
|
|
79
|
+
* The init module is imported lazily (inside ensureInitialized) to break
|
|
80
|
+
* the import cycle: specs need errors from this module, init imports specs,
|
|
81
|
+
* registry needs init. Calling this from artifact-registry-init.ts after
|
|
82
|
+
* spec imports complete keeps the registrar separate from registry core.
|
|
83
|
+
*/
|
|
84
|
+
setBuiltinRegistrar(registrar) {
|
|
85
|
+
this.builtinRegistrar = registrar;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Lazy initialization. Idempotent.
|
|
89
|
+
*
|
|
90
|
+
* Contract (NQ-19 v9):
|
|
91
|
+
* - First call: invoke builtinRegistrar
|
|
92
|
+
* - Subsequent calls: no-op
|
|
93
|
+
* - On failure: wrap as RegistryInitError, cache, throw on every subsequent
|
|
94
|
+
* call (CLI-process-scoped recovery is process restart only)
|
|
95
|
+
*/
|
|
96
|
+
ensureInitialized() {
|
|
97
|
+
if (this.initialized)
|
|
98
|
+
return;
|
|
99
|
+
if (this.cachedInitError)
|
|
100
|
+
throw this.cachedInitError;
|
|
101
|
+
if (!this.builtinRegistrar) {
|
|
102
|
+
// The registrar is wired by artifact-registry-init.ts side-effect import.
|
|
103
|
+
// If callers reach here without that side effect, something invoked the
|
|
104
|
+
// registry before init module loaded — fail loudly.
|
|
105
|
+
this.cachedInitError = new RegistryInitError("no builtin registrar wired. Import 'artifact-registry-init.js' " +
|
|
106
|
+
"from the entry point before using REGISTRY.");
|
|
107
|
+
throw this.cachedInitError;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
this.builtinRegistrar();
|
|
111
|
+
this.initialized = true;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
this.cachedInitError = new RegistryInitError(error instanceof Error ? error.message : String(error), error instanceof Error ? error : undefined);
|
|
115
|
+
throw this.cachedInitError;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Register a spec at init time. Performs structural sanity checks so a
|
|
120
|
+
* mis-declared spec fails at registration rather than at first read/write
|
|
121
|
+
* (SYN-C2 v8 register-time consistency check).
|
|
122
|
+
*/
|
|
123
|
+
register(spec) {
|
|
124
|
+
if (spec.supported_schema_versions.length === 0) {
|
|
125
|
+
throw new Error(`${spec.kind}: supported_schema_versions cannot be empty`);
|
|
126
|
+
}
|
|
127
|
+
if (!spec.supported_schema_versions.includes(spec.current_schema_version)) {
|
|
128
|
+
throw new Error(`${spec.kind}: current_schema_version "${spec.current_schema_version}" ` +
|
|
129
|
+
`not in supported_schema_versions [${spec.supported_schema_versions.join(", ")}]`);
|
|
130
|
+
}
|
|
131
|
+
if (spec.supported_schema_versions.length > 1 && !spec.migrate) {
|
|
132
|
+
throw new Error(`${spec.kind}: supports ${spec.supported_schema_versions.length} schema versions ` +
|
|
133
|
+
`but no migrate function provided`);
|
|
134
|
+
}
|
|
135
|
+
if (spec.supported_formats.length === 0) {
|
|
136
|
+
throw new Error(`${spec.kind}: supported_formats cannot be empty`);
|
|
137
|
+
}
|
|
138
|
+
if (this.specs.has(spec.kind)) {
|
|
139
|
+
throw new Error(`Duplicate artifact kind: ${spec.kind}`);
|
|
140
|
+
}
|
|
141
|
+
this.specs.set(spec.kind, spec);
|
|
142
|
+
}
|
|
143
|
+
get(kind) {
|
|
144
|
+
this.ensureInitialized();
|
|
145
|
+
const spec = this.specs.get(kind);
|
|
146
|
+
if (!spec) {
|
|
147
|
+
throw new UnregisteredArtifactKindError(`Artifact kind '${kind}' not registered. ` +
|
|
148
|
+
`Available: ${[...this.specs.keys()].sort().join(", ")}`);
|
|
149
|
+
}
|
|
150
|
+
return spec;
|
|
151
|
+
}
|
|
152
|
+
loadFromFile(kind, filePath) {
|
|
153
|
+
this.ensureInitialized();
|
|
154
|
+
const spec = this.get(kind);
|
|
155
|
+
if (!fs.existsSync(filePath)) {
|
|
156
|
+
throw new ArtifactNotFoundError(`Artifact file not found: ${filePath}`);
|
|
157
|
+
}
|
|
158
|
+
const format = formatFromPath(filePath, kind, spec);
|
|
159
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
160
|
+
const parsed = spec.parse(content, format);
|
|
161
|
+
const validation = spec.validate(parsed);
|
|
162
|
+
if (!validation.valid) {
|
|
163
|
+
throw new InvalidArtifactError(`${kind}: ${validation.errors.join(", ")}`);
|
|
164
|
+
}
|
|
165
|
+
return parsed;
|
|
166
|
+
}
|
|
167
|
+
saveToFile(kind, filePath, data) {
|
|
168
|
+
this.ensureInitialized();
|
|
169
|
+
const spec = this.get(kind);
|
|
170
|
+
// SYN-CC1 part 1: structural validation before write
|
|
171
|
+
const validation = spec.validate(data);
|
|
172
|
+
if (!validation.valid) {
|
|
173
|
+
throw new InvalidArtifactError(`${kind} validation failed: ${validation.errors.join(", ")}`);
|
|
174
|
+
}
|
|
175
|
+
// SYN-CC1 part 2: format binding from extension
|
|
176
|
+
const format = formatFromPath(filePath, kind, spec);
|
|
177
|
+
// SYN-CC1 part 3 + SYN-CONS-03 (v9): schema_version is required and must
|
|
178
|
+
// match spec.current_schema_version. undefined is rejected.
|
|
179
|
+
const dataObj = data;
|
|
180
|
+
if (dataObj.schema_version === undefined) {
|
|
181
|
+
throw new InvalidArtifactError(`${kind}: data missing required schema_version field. ` +
|
|
182
|
+
`Expected "${spec.current_schema_version}".`);
|
|
183
|
+
}
|
|
184
|
+
if (dataObj.schema_version !== spec.current_schema_version) {
|
|
185
|
+
throw new InvalidArtifactError(`${kind}: data has schema_version "${dataObj.schema_version}" ` +
|
|
186
|
+
`but spec current is "${spec.current_schema_version}".`);
|
|
187
|
+
}
|
|
188
|
+
const content = spec.serialize(data, format);
|
|
189
|
+
const dir = path.dirname(filePath);
|
|
190
|
+
if (!fs.existsSync(dir)) {
|
|
191
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
192
|
+
}
|
|
193
|
+
fs.writeFileSync(filePath, content, "utf8");
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Append-only logs (e.g. emergency-log.jsonl, prune-log.jsonl) need a
|
|
197
|
+
* separate write entry point because they bypass the "single-data-object
|
|
198
|
+
* with schema_version" pattern. Spec.serialize is invoked per-entry; the
|
|
199
|
+
* caller is responsible for newline framing.
|
|
200
|
+
*/
|
|
201
|
+
appendToFile(kind, filePath, entry) {
|
|
202
|
+
this.ensureInitialized();
|
|
203
|
+
const spec = this.get(kind);
|
|
204
|
+
const validation = spec.validate(entry);
|
|
205
|
+
if (!validation.valid) {
|
|
206
|
+
throw new InvalidArtifactError(`${kind} validation failed: ${validation.errors.join(", ")}`);
|
|
207
|
+
}
|
|
208
|
+
const dataObj = entry;
|
|
209
|
+
if (dataObj.schema_version === undefined) {
|
|
210
|
+
throw new InvalidArtifactError(`${kind}: entry missing required schema_version field.`);
|
|
211
|
+
}
|
|
212
|
+
if (dataObj.schema_version !== spec.current_schema_version) {
|
|
213
|
+
throw new InvalidArtifactError(`${kind}: entry has schema_version "${dataObj.schema_version}" ` +
|
|
214
|
+
`but spec current is "${spec.current_schema_version}".`);
|
|
215
|
+
}
|
|
216
|
+
const format = formatFromPath(filePath, kind, spec);
|
|
217
|
+
const line = spec.serialize(entry, format) + "\n";
|
|
218
|
+
const dir = path.dirname(filePath);
|
|
219
|
+
if (!fs.existsSync(dir)) {
|
|
220
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
221
|
+
}
|
|
222
|
+
fs.appendFileSync(filePath, line, "utf8");
|
|
223
|
+
}
|
|
224
|
+
listRegistered() {
|
|
225
|
+
this.ensureInitialized();
|
|
226
|
+
return [...this.specs.keys()].sort();
|
|
227
|
+
}
|
|
228
|
+
/** Test-only reset. Not used in production code paths. */
|
|
229
|
+
__resetForTest() {
|
|
230
|
+
this.specs.clear();
|
|
231
|
+
this.initialized = false;
|
|
232
|
+
this.cachedInitError = null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function formatFromPath(filePath, kind, spec) {
|
|
236
|
+
const ext = path.extname(filePath).slice(1).toLowerCase();
|
|
237
|
+
let format;
|
|
238
|
+
if (ext === "json" || ext === "jsonl") {
|
|
239
|
+
format = "json";
|
|
240
|
+
}
|
|
241
|
+
else if (ext === "yaml" || ext === "yml") {
|
|
242
|
+
format = "yaml";
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
throw new Error(`${kind}: unsupported file extension ".${ext}" (path=${filePath})`);
|
|
246
|
+
}
|
|
247
|
+
if (!spec.supported_formats.includes(format)) {
|
|
248
|
+
throw new Error(`${kind}: format ${format} (from ${filePath}) not in supported_formats ` +
|
|
249
|
+
`[${spec.supported_formats.join(", ")}]`);
|
|
250
|
+
}
|
|
251
|
+
return format;
|
|
252
|
+
}
|
|
253
|
+
/** Singleton instance. */
|
|
254
|
+
export const REGISTRY = new ArtifactRegistry();
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuditObligation kernel — pure types and constants (DD-21 SYN-D1).
|
|
3
|
+
*
|
|
4
|
+
* Design authority: learn-phase3-design-v9.md DD-21, learn-phase3-design-v8.md DD-21.
|
|
5
|
+
*
|
|
6
|
+
* This module is intentionally dependency-free (no I/O, no class, no other
|
|
7
|
+
* modules from learning/). Other modules import enums/types from here so the
|
|
8
|
+
* dependency graph stays low and AuditObligation class can sit above this.
|
|
9
|
+
*
|
|
10
|
+
* Why kernel separation:
|
|
11
|
+
* 1. Lowers import coupling — modules that need only the type/enum (e.g., a
|
|
12
|
+
* reporter that prints a status) do not transitively depend on the class.
|
|
13
|
+
* 2. Construction invariants in AuditObligation can reuse these constants
|
|
14
|
+
* without circular import risk.
|
|
15
|
+
* 3. v6 review's dependency-03 finding: obligation kernel was seated too high.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Legal transition matrix (DD-17 + EXPIRED-UNATTENDED-01 fix in v6 review).
|
|
19
|
+
*
|
|
20
|
+
* Rationale:
|
|
21
|
+
* - pending: initial active state. Can move into in_progress, be waived, or
|
|
22
|
+
* expire unattended (carry-forward exhausted before P-14 picked it up).
|
|
23
|
+
* - in_progress: P-14 is currently processing. Terminates as fulfilled,
|
|
24
|
+
* transient blocked, or no_eligible_agents (irrecoverable).
|
|
25
|
+
* - blocked: transient failure (LLM timeout, etc.). Re-enters pending on the
|
|
26
|
+
* next promote, may also be waived or expire.
|
|
27
|
+
* - no_eligible_agents / fulfilled / waived: terminal.
|
|
28
|
+
* - expired_unattended: ledger-visible but not strictly terminal — operator
|
|
29
|
+
* may waive it after manual review.
|
|
30
|
+
*
|
|
31
|
+
* v6 review found that pending/blocked → expired_unattended ingress was missing
|
|
32
|
+
* from the legal transition matrix; v9 makes it explicit so the carry-forward
|
|
33
|
+
* exhaustion path is enforceable.
|
|
34
|
+
*/
|
|
35
|
+
export const LEGAL_TRANSITIONS = {
|
|
36
|
+
pending: ["in_progress", "waived", "expired_unattended"],
|
|
37
|
+
in_progress: ["fulfilled", "blocked", "no_eligible_agents"],
|
|
38
|
+
blocked: ["pending", "fulfilled", "waived", "expired_unattended"],
|
|
39
|
+
no_eligible_agents: [],
|
|
40
|
+
fulfilled: [],
|
|
41
|
+
waived: [],
|
|
42
|
+
expired_unattended: ["waived"],
|
|
43
|
+
};
|
|
44
|
+
export function isLegalTransition(from, to) {
|
|
45
|
+
return LEGAL_TRANSITIONS[from].includes(to);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Strictly terminal statuses — no outgoing legal transitions.
|
|
49
|
+
*
|
|
50
|
+
* Note: expired_unattended is intentionally NOT included here because the
|
|
51
|
+
* operator can waive it. Use isStrictlyTerminal() if you need the strict set,
|
|
52
|
+
* or check `isActive()` on the AuditObligation class for active/inactive.
|
|
53
|
+
*/
|
|
54
|
+
export const TERMINAL_STATUSES = new Set([
|
|
55
|
+
"fulfilled",
|
|
56
|
+
"no_eligible_agents",
|
|
57
|
+
"waived",
|
|
58
|
+
]);
|
|
59
|
+
export function isTerminalStatus(status) {
|
|
60
|
+
return TERMINAL_STATUSES.has(status);
|
|
61
|
+
}
|
|
62
|
+
export class IllegalTransitionError extends Error {
|
|
63
|
+
constructor(message) {
|
|
64
|
+
super(message);
|
|
65
|
+
this.name = "IllegalTransitionError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export class InvariantViolatedError extends Error {
|
|
69
|
+
constructor(message) {
|
|
70
|
+
super(message);
|
|
71
|
+
this.name = "InvariantViolatedError";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit state ledger — DD-17.
|
|
3
|
+
*
|
|
4
|
+
* Design authority:
|
|
5
|
+
* - learn-phase3-design-v9.md DD-17
|
|
6
|
+
* - learn-phase3-design-v6.md DD-17 (lifecycle definitions)
|
|
7
|
+
* - learn-phase3-design-v8.md DD-21 (class boundary, no transition helper)
|
|
8
|
+
*
|
|
9
|
+
* Responsibility:
|
|
10
|
+
* - Load/save the obligation ledger via REGISTRY
|
|
11
|
+
* - Carry-forward processing (DD-17 lifecycle)
|
|
12
|
+
* - Detect new obligations from PromoteReport thresholds
|
|
13
|
+
*
|
|
14
|
+
* Class boundary:
|
|
15
|
+
* - On disk we use AuditStateJSON (plain). In memory we hold AuditObligation
|
|
16
|
+
* class instances so DD-21 invariants are enforced.
|
|
17
|
+
*/
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
import os from "node:os";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
import { REGISTRY } from "./artifact-registry.js";
|
|
22
|
+
import { AuditObligation } from "../promote/audit-obligation.js";
|
|
23
|
+
export const DEFAULT_AUDIT_STATE_PATH = path.join(os.homedir(), ".onto", "audit-state.yaml");
|
|
24
|
+
export const DEFAULT_MAX_CARRY_FORWARD = 3;
|
|
25
|
+
export function getAuditStatePath(ontoHome) {
|
|
26
|
+
if (ontoHome) {
|
|
27
|
+
return path.join(ontoHome, "audit-state.yaml");
|
|
28
|
+
}
|
|
29
|
+
return DEFAULT_AUDIT_STATE_PATH;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Load audit state. If the file does not exist returns an empty ledger so
|
|
33
|
+
* fresh users do not need to bootstrap manually.
|
|
34
|
+
*/
|
|
35
|
+
export function loadAuditState(filePath) {
|
|
36
|
+
const target = filePath ?? DEFAULT_AUDIT_STATE_PATH;
|
|
37
|
+
if (!fs.existsSync(target)) {
|
|
38
|
+
return { schema_version: "1", obligations: [] };
|
|
39
|
+
}
|
|
40
|
+
const json = REGISTRY.loadFromFile("audit_state", target);
|
|
41
|
+
return {
|
|
42
|
+
schema_version: "1",
|
|
43
|
+
obligations: json.obligations.map((j) => AuditObligation.fromJSON(j)),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function saveAuditState(state, filePath) {
|
|
47
|
+
const target = filePath ?? DEFAULT_AUDIT_STATE_PATH;
|
|
48
|
+
const json = {
|
|
49
|
+
schema_version: "1",
|
|
50
|
+
obligations: state.obligations.map((o) => o.toJSON()),
|
|
51
|
+
};
|
|
52
|
+
REGISTRY.saveToFile("audit_state", target, json);
|
|
53
|
+
}
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// Carry-forward processing
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
/**
|
|
58
|
+
* Advance the carry-forward count for all active (pending/blocked) obligations.
|
|
59
|
+
*
|
|
60
|
+
* Lifecycle (DD-17):
|
|
61
|
+
* - blocked → pending automatically (re-entry on next promote)
|
|
62
|
+
* - pending obligations whose count exceeds max_carry_forward → expired_unattended
|
|
63
|
+
*
|
|
64
|
+
* `expired_unattended` is intentionally NOT a terminal state — the operator
|
|
65
|
+
* can waive it. This visibility is the v6 SYN-D-01 fix: silent cleanup was
|
|
66
|
+
* a governance defect, so the obligation stays on the ledger until explicitly
|
|
67
|
+
* resolved.
|
|
68
|
+
*/
|
|
69
|
+
export function processCarryForward(state, sessionId) {
|
|
70
|
+
for (const ob of state.obligations) {
|
|
71
|
+
if (ob.status !== "pending" && ob.status !== "blocked")
|
|
72
|
+
continue;
|
|
73
|
+
ob.incrementCarryForward();
|
|
74
|
+
if (ob.hasExceededCarryForward()) {
|
|
75
|
+
ob.transition("expired_unattended", `carry_forward_count (${ob.carry_forward_count}) exceeded max ` +
|
|
76
|
+
`(${ob.max_carry_forward})`, { session_id: sessionId });
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (ob.status === "blocked") {
|
|
80
|
+
ob.transition("pending", `Re-entry from blocked (carry_forward ${ob.carry_forward_count})`, { session_id: sessionId });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return state;
|
|
84
|
+
}
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// Helpers
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
export function findObligation(state, obligationId) {
|
|
89
|
+
return state.obligations.find((o) => o.obligation_id === obligationId);
|
|
90
|
+
}
|
|
91
|
+
export function getExpiredUnattended(state) {
|
|
92
|
+
return state.obligations.filter((o) => o.status === "expired_unattended");
|
|
93
|
+
}
|
|
94
|
+
export function getActiveObligations(state) {
|
|
95
|
+
return state.obligations.filter((o) => o.isActive());
|
|
96
|
+
}
|
|
97
|
+
export function countCarriedForward(state) {
|
|
98
|
+
return state.obligations.filter((o) => o.carry_forward_count > 0).length;
|
|
99
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-level dedup — A-10, P-3 (Phase 2/3 공용).
|
|
3
|
+
*
|
|
4
|
+
* CC2 반영: content 부분만 추출 → trim 후 exact match.
|
|
5
|
+
* 태그/소스/임팩트 차이는 A-11(semantic classifier)이 처리.
|
|
6
|
+
*/
|
|
7
|
+
import { CONTENT_CAPTURE } from "./patterns.js";
|
|
8
|
+
/**
|
|
9
|
+
* Extract content portion from a fully assembled learning line.
|
|
10
|
+
* Returns null if the line doesn't match the expected format.
|
|
11
|
+
*/
|
|
12
|
+
export function extractContent(line) {
|
|
13
|
+
const match = line.match(CONTENT_CAPTURE);
|
|
14
|
+
return match?.[1]?.trim() ?? null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Check if new content is an exact duplicate of any existing line's content.
|
|
18
|
+
* A-10: content-level dedup (not full-line match).
|
|
19
|
+
*/
|
|
20
|
+
export function isContentDuplicate(newContent, existingLines) {
|
|
21
|
+
const normalized = newContent.trim();
|
|
22
|
+
for (const line of existingLines) {
|
|
23
|
+
const existing = extractContent(line);
|
|
24
|
+
if (existing && existing === normalized)
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|