onto-mcp 0.3.2 → 0.4.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/processes/reconstruct/actionable-ontology-seed-recomposition-design.md +447 -0
- package/.onto/processes/reconstruct/foundry-style-ontology-seed-contract.md +934 -0
- package/.onto/processes/reconstruct/reconstruct-boundary-contract.md +303 -725
- package/.onto/processes/reconstruct/reconstruct-contract-registry.yaml +1645 -0
- package/.onto/processes/reconstruct/reconstruct-execution-ux-contract.md +26 -22
- package/.onto/processes/reconstruct/source-profile-contract.md +49 -23
- package/.onto/processes/reconstruct/source-profiles/code.md +6 -3
- package/.onto/processes/reconstruct/source-profiles/database.md +5 -2
- package/.onto/processes/reconstruct/source-profiles/document.md +5 -2
- package/.onto/processes/reconstruct/source-profiles/spreadsheet.md +5 -4
- package/.onto/processes/review/review-execution-ux-contract.md +40 -0
- package/.onto/processes/shared/pipeline-execution-ledger-contract.md +26 -10
- package/.onto/processes/shared/target-material-kind-contract.md +29 -16
- package/AGENTS.md +6 -4
- package/README.md +135 -76
- package/dist/cli.js +8 -8
- package/dist/core-api/reconstruct-api.js +117 -31
- package/dist/core-api/review-api.js +47 -0
- package/dist/core-runtime/cli/codex-review-unit-executor.js +39 -2
- package/dist/core-runtime/cli/complete-review-session.js +2 -2
- package/dist/core-runtime/cli/mock-review-unit-executor.js +1 -1
- package/dist/core-runtime/cli/review-invoke.js +9 -9
- package/dist/core-runtime/cli/run-review-prompt-execution.js +39 -5
- package/dist/core-runtime/cli/spawn-watcher.js +266 -47
- package/dist/core-runtime/cli/start-review-session.js +3 -3
- package/dist/core-runtime/llm/llm-caller.js +11 -0
- package/dist/core-runtime/llm/llm-tool-loop.js +2 -0
- package/dist/core-runtime/observability/runtime-stream-observation.js +118 -0
- package/dist/core-runtime/onboard/cli-host.js +149 -0
- package/dist/core-runtime/onboard/host-target.js +22 -0
- package/dist/core-runtime/onboard/json-config-host.js +122 -0
- package/dist/core-runtime/onboard/path-scan.js +26 -0
- package/dist/core-runtime/onboard/prompt.js +51 -0
- package/dist/core-runtime/onboard/register.js +207 -0
- package/dist/core-runtime/onboard/types.js +27 -0
- package/dist/core-runtime/reconstruct/actionable-seed-validation.js +1777 -0
- package/dist/core-runtime/reconstruct/artifact-types.js +10 -4
- package/dist/core-runtime/reconstruct/contract-registry.js +623 -0
- package/dist/core-runtime/reconstruct/domain-id.js +10 -0
- package/dist/core-runtime/reconstruct/governing-snapshot.js +716 -0
- package/dist/core-runtime/reconstruct/material-profile-validation.js +191 -0
- package/dist/core-runtime/reconstruct/materialize-preparation.js +49 -11
- package/dist/core-runtime/reconstruct/pipeline-execution-ledger.js +269 -79
- package/dist/core-runtime/reconstruct/post-seed-validation.js +1194 -51
- package/dist/core-runtime/reconstruct/record.js +104 -20
- package/dist/core-runtime/reconstruct/run.js +2107 -413
- package/dist/core-runtime/reconstruct/seed-claim-projections.js +268 -0
- package/dist/core-runtime/reconstruct/source-profiles.js +93 -4
- package/dist/core-runtime/reconstruct/terminal-validation.js +807 -0
- package/dist/core-runtime/review/review-invocation-runner.js +4 -4
- package/dist/mcp/server.js +110 -38
- package/dist/mcp/tool-schemas.js +20 -6
- package/package.json +8 -17
- package/scripts/onto-review-watch.sh +486 -0
- package/scripts/onto-runtime-watch.sh +122 -0
- package/scripts/postinstall-hint.js +22 -0
- package/.onto/processes/reconstruct/top-level-concept-discovery-contract.md +0 -387
- package/dist/core-runtime/cli/bootstrap-review-binding.js +0 -186
- package/dist/core-runtime/cli/codex-nested-dispatch.test.js +0 -390
- package/dist/core-runtime/cli/codex-nested-teamlead-executor.test.js +0 -335
- package/dist/core-runtime/cli/coordinator-helpers.js +0 -583
- package/dist/core-runtime/cli/coordinator-state-machine-deliberation.test.js +0 -167
- package/dist/core-runtime/cli/coordinator-state-machine.js +0 -794
- package/dist/core-runtime/cli/e2e-codex-multi-agent-fixes.test.js +0 -615
- package/dist/core-runtime/cli/e2e-start-review-session.test.js +0 -312
- package/dist/core-runtime/cli/health.js +0 -44
- package/dist/core-runtime/cli/inline-http-review-unit-executor.test.js +0 -567
- package/dist/core-runtime/cli/materialize-review-execution-preparation.js +0 -104
- package/dist/core-runtime/cli/migrate-session-roots.js +0 -118
- package/dist/core-runtime/cli/repo-layout-migration-replace.smoke.test.js +0 -106
- package/dist/core-runtime/cli/review-invoke-auto-resolution.test.js +0 -268
- package/dist/core-runtime/cli/review-invoke-coordinator-topology.test.js +0 -136
- package/dist/core-runtime/cli/review-invoke-resolver-caching.test.js +0 -201
- package/dist/core-runtime/cli/review-invoke-topology-dispatch.test.js +0 -192
- package/dist/core-runtime/cli/session-root-guard.js +0 -168
- package/dist/core-runtime/cli/spawn-watcher.test.js +0 -457
- package/dist/core-runtime/cli/strip-wrapping-code-fence.test.js +0 -79
- package/dist/core-runtime/cli/teamcreate-lens-deliberation-executor.js +0 -412
- package/dist/core-runtime/cli/teamcreate-lens-deliberation-executor.test.js +0 -351
- package/dist/core-runtime/cli/topology-executor-mapping.js +0 -139
- package/dist/core-runtime/cli/topology-executor-mapping.test.js +0 -173
- package/dist/core-runtime/cli/write-review-interpretation.js +0 -81
- package/dist/core-runtime/config/onto-config-cli.js +0 -278
- package/dist/core-runtime/config/onto-config-key-path.js +0 -288
- package/dist/core-runtime/config/onto-config-key-path.test.js +0 -195
- package/dist/core-runtime/config/onto-config-preview.js +0 -108
- package/dist/core-runtime/config/onto-config-preview.test.js +0 -132
- package/dist/core-runtime/discovery/config-chain.js +0 -118
- package/dist/core-runtime/discovery/config-chain.test.js +0 -103
- package/dist/core-runtime/discovery/config-profile.js +0 -199
- package/dist/core-runtime/discovery/config-profile.test.js +0 -233
- package/dist/core-runtime/discovery/host-detection.test.js +0 -186
- package/dist/core-runtime/discovery/installation-paths.test.js +0 -65
- package/dist/core-runtime/discovery/lens-registry.test.js +0 -81
- package/dist/core-runtime/discovery/path-normalization.test.js +0 -22
- package/dist/core-runtime/discovery/plugin-path.js +0 -72
- package/dist/core-runtime/discovery/plugin-path.test.js +0 -95
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile-defense.js +0 -344
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile-defense.test.js +0 -915
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile.js +0 -564
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile.test.js +0 -708
- package/dist/core-runtime/evolve/adapters/code-product/parsers/brief-parser.js +0 -165
- package/dist/core-runtime/evolve/adapters/code-product/parsers/brief-parser.test.js +0 -227
- package/dist/core-runtime/evolve/adapters/code-product/validators/validate.js +0 -59
- package/dist/core-runtime/evolve/adapters/code-product/validators/validate.test.js +0 -205
- package/dist/core-runtime/evolve/adapters/methodology/adapter.js +0 -16
- package/dist/core-runtime/evolve/adapters/methodology/adapter.test.js +0 -9
- package/dist/core-runtime/evolve/adapters/methodology/perspectives/authority-consistency.js +0 -298
- package/dist/core-runtime/evolve/adapters/methodology/perspectives/authority-consistency.test.js +0 -70
- package/dist/core-runtime/evolve/adapters/methodology/scope-types/process.js +0 -46
- package/dist/core-runtime/evolve/adapters/methodology/scope-types/process.test.js +0 -73
- package/dist/core-runtime/evolve/adapters/registry.js +0 -47
- package/dist/core-runtime/evolve/adapters/registry.test.js +0 -67
- package/dist/core-runtime/evolve/cli.js +0 -256
- package/dist/core-runtime/evolve/commands/align.js +0 -194
- package/dist/core-runtime/evolve/commands/align.test.js +0 -82
- package/dist/core-runtime/evolve/commands/apply.js +0 -161
- package/dist/core-runtime/evolve/commands/apply.test.js +0 -138
- package/dist/core-runtime/evolve/commands/close.js +0 -39
- package/dist/core-runtime/evolve/commands/close.test.js +0 -99
- package/dist/core-runtime/evolve/commands/defer.js +0 -40
- package/dist/core-runtime/evolve/commands/defer.test.js +0 -134
- package/dist/core-runtime/evolve/commands/draft.js +0 -323
- package/dist/core-runtime/evolve/commands/draft.test.js +0 -178
- package/dist/core-runtime/evolve/commands/e2e-evolve-full-cycle.test.js +0 -208
- package/dist/core-runtime/evolve/commands/error-messages.js +0 -125
- package/dist/core-runtime/evolve/commands/error-messages.test.js +0 -167
- package/dist/core-runtime/evolve/commands/propose-align.js +0 -222
- package/dist/core-runtime/evolve/commands/propose-align.test.js +0 -136
- package/dist/core-runtime/evolve/commands/reconstruct.js +0 -330
- package/dist/core-runtime/evolve/commands/reconstruct.test.js +0 -278
- package/dist/core-runtime/evolve/commands/shared.js +0 -22
- package/dist/core-runtime/evolve/commands/stale-check.js +0 -103
- package/dist/core-runtime/evolve/commands/stale-check.test.js +0 -84
- package/dist/core-runtime/evolve/commands/start.js +0 -887
- package/dist/core-runtime/evolve/commands/start.test.js +0 -396
- package/dist/core-runtime/evolve/config/project-config.js +0 -99
- package/dist/core-runtime/evolve/config/project-config.test.js +0 -170
- package/dist/core-runtime/evolve/renderers/align-packet.js +0 -280
- package/dist/core-runtime/evolve/renderers/align-packet.test.js +0 -332
- package/dist/core-runtime/evolve/renderers/draft-packet.js +0 -303
- package/dist/core-runtime/evolve/renderers/draft-packet.test.js +0 -377
- package/dist/core-runtime/evolve/renderers/format.js +0 -5
- package/dist/core-runtime/evolve/renderers/scope-md.js +0 -237
- package/dist/core-runtime/evolve/renderers/scope-md.test.js +0 -306
- package/dist/core-runtime/govern/cli.js +0 -369
- package/dist/core-runtime/govern/cli.test.js +0 -314
- package/dist/core-runtime/govern/drift-engine.js +0 -103
- package/dist/core-runtime/govern/drift-engine.test.js +0 -319
- package/dist/core-runtime/govern/promote-principle.js +0 -206
- package/dist/core-runtime/govern/promote-principle.test.js +0 -368
- package/dist/core-runtime/govern/queue.js +0 -81
- package/dist/core-runtime/govern/types.js +0 -16
- package/dist/core-runtime/install/cli.js +0 -530
- package/dist/core-runtime/install/detect.js +0 -128
- package/dist/core-runtime/install/detect.test.js +0 -155
- package/dist/core-runtime/install/gitignore-update.js +0 -74
- package/dist/core-runtime/install/gitignore-update.test.js +0 -64
- package/dist/core-runtime/install/install-integration.test.js +0 -373
- package/dist/core-runtime/install/prompts.js +0 -389
- package/dist/core-runtime/install/prompts.test.js +0 -293
- package/dist/core-runtime/install/types.js +0 -26
- package/dist/core-runtime/install/validation.js +0 -295
- package/dist/core-runtime/install/validation.test.js +0 -313
- package/dist/core-runtime/install/writer.js +0 -254
- package/dist/core-runtime/install/writer.test.js +0 -218
- package/dist/core-runtime/learning/extractor.js +0 -461
- package/dist/core-runtime/learning/feedback.js +0 -179
- package/dist/core-runtime/learning/health-report.js +0 -165
- package/dist/core-runtime/learning/health-report.test.js +0 -169
- package/dist/core-runtime/learning/loader.js +0 -388
- package/dist/core-runtime/learning/loader.test.js +0 -102
- package/dist/core-runtime/learning/promote/apply-state.js +0 -240
- package/dist/core-runtime/learning/promote/audit-obligation.js +0 -195
- package/dist/core-runtime/learning/promote/collector.js +0 -432
- package/dist/core-runtime/learning/promote/degraded-state.js +0 -125
- package/dist/core-runtime/learning/promote/domain-doc-proposer.js +0 -166
- package/dist/core-runtime/learning/promote/e2e-promote.test.js +0 -6385
- package/dist/core-runtime/learning/promote/health-snapshot.js +0 -150
- package/dist/core-runtime/learning/promote/insight-reclassifier.js +0 -544
- package/dist/core-runtime/learning/promote/judgment-auditor.js +0 -517
- package/dist/core-runtime/learning/promote/panel-reviewer.js +0 -1158
- package/dist/core-runtime/learning/promote/promote-executor.js +0 -1675
- package/dist/core-runtime/learning/promote/promoter.js +0 -307
- package/dist/core-runtime/learning/promote/retirement.js +0 -122
- package/dist/core-runtime/learning/promote/types.js +0 -23
- package/dist/core-runtime/learning/prompt-sections.js +0 -51
- package/dist/core-runtime/learning/shared/artifact-registry-init.js +0 -45
- package/dist/core-runtime/learning/shared/artifact-registry.js +0 -254
- package/dist/core-runtime/learning/shared/audit-obligation-kernel.js +0 -73
- package/dist/core-runtime/learning/shared/audit-state.js +0 -99
- package/dist/core-runtime/learning/shared/duplicate-check.js +0 -28
- package/dist/core-runtime/learning/shared/llm-caller.js +0 -831
- package/dist/core-runtime/learning/shared/llm-caller.test.js +0 -601
- package/dist/core-runtime/learning/shared/llm-tool-loop.js +0 -393
- package/dist/core-runtime/learning/shared/mode.js +0 -25
- package/dist/core-runtime/learning/shared/paths.js +0 -84
- package/dist/core-runtime/learning/shared/paths.test.js +0 -79
- package/dist/core-runtime/learning/shared/patterns.js +0 -37
- package/dist/core-runtime/learning/shared/recoverability.js +0 -355
- package/dist/core-runtime/learning/shared/recovery-context.js +0 -374
- package/dist/core-runtime/learning/shared/scope.js +0 -1
- package/dist/core-runtime/learning/shared/semantic-classifier.js +0 -94
- package/dist/core-runtime/learning/shared/specs/apply-execution-state-spec.js +0 -42
- package/dist/core-runtime/learning/shared/specs/audit-state-spec.js +0 -37
- package/dist/core-runtime/learning/shared/specs/backup-metadata-spec.js +0 -39
- package/dist/core-runtime/learning/shared/specs/emergency-log-spec.js +0 -41
- package/dist/core-runtime/learning/shared/specs/layout-version-spec.js +0 -38
- package/dist/core-runtime/learning/shared/specs/promote-decisions-spec.js +0 -43
- package/dist/core-runtime/learning/shared/specs/promote-report-spec.js +0 -113
- package/dist/core-runtime/learning/shared/specs/prune-log-spec.js +0 -36
- package/dist/core-runtime/learning/shared/specs/recovery-resolution-spec.js +0 -48
- package/dist/core-runtime/learning/shared/specs/restore-manifest-spec.js +0 -43
- package/dist/core-runtime/learning/shared/specs/spec-helpers.js +0 -64
- package/dist/core-runtime/learning/usage-tracker.js +0 -190
- package/dist/core-runtime/learning/usage-tracker.test.js +0 -176
- package/dist/core-runtime/onboard/detect-review-axes.js +0 -122
- package/dist/core-runtime/onboard/detect-review-axes.test.js +0 -127
- package/dist/core-runtime/onboard/write-review-block.js +0 -188
- package/dist/core-runtime/onboard/write-review-block.test.js +0 -240
- package/dist/core-runtime/readers/brownfield-builder.js +0 -150
- package/dist/core-runtime/readers/brownfield-builder.test.js +0 -136
- package/dist/core-runtime/readers/code-chunk-collector.js +0 -53
- package/dist/core-runtime/readers/code-chunk-collector.test.js +0 -136
- package/dist/core-runtime/readers/file-utils.js +0 -240
- package/dist/core-runtime/readers/file-utils.test.js +0 -146
- package/dist/core-runtime/readers/lexicon-citation-check.js +0 -93
- package/dist/core-runtime/readers/lexicon-citation-check.test.js +0 -77
- package/dist/core-runtime/readers/mcp-figma.js +0 -30
- package/dist/core-runtime/readers/mcp-figma.test.js +0 -82
- package/dist/core-runtime/readers/mcp-generic.js +0 -31
- package/dist/core-runtime/readers/mcp-generic.test.js +0 -76
- package/dist/core-runtime/readers/ontology-index.js +0 -148
- package/dist/core-runtime/readers/ontology-index.test.js +0 -245
- package/dist/core-runtime/readers/ontology-query.js +0 -168
- package/dist/core-runtime/readers/ontology-query.test.js +0 -311
- package/dist/core-runtime/readers/ontology-resolve.js +0 -48
- package/dist/core-runtime/readers/ontology-resolve.test.js +0 -48
- package/dist/core-runtime/readers/patterns/index.js +0 -7
- package/dist/core-runtime/readers/review-log.js +0 -213
- package/dist/core-runtime/readers/review-log.test.js +0 -313
- package/dist/core-runtime/readers/scan-local.js +0 -102
- package/dist/core-runtime/readers/scan-local.test.js +0 -102
- package/dist/core-runtime/readers/scan-tarball.js +0 -121
- package/dist/core-runtime/readers/scan-tarball.test.js +0 -283
- package/dist/core-runtime/readers/scan-vault.js +0 -34
- package/dist/core-runtime/readers/scan-vault.test.js +0 -81
- package/dist/core-runtime/readers/types.js +0 -42
- package/dist/core-runtime/readers/types.test.js +0 -94
- package/dist/core-runtime/readers/viewpoint-collectors.js +0 -229
- package/dist/core-runtime/reconstruct/seed-candidate-validation.js +0 -385
- package/dist/core-runtime/review/citation-audit.test.js +0 -165
- package/dist/core-runtime/review/execution-plan-resolver.js +0 -247
- package/dist/core-runtime/review/execution-plan-resolver.test.js +0 -243
- package/dist/core-runtime/review/execution-topology-resolver-axis-first.test.js +0 -246
- package/dist/core-runtime/review/execution-topology-resolver.js +0 -401
- package/dist/core-runtime/review/execution-topology-resolver.test.js +0 -315
- package/dist/core-runtime/review/inline-context-embedder.test.js +0 -154
- package/dist/core-runtime/review/legacy-mode-policy.js +0 -88
- package/dist/core-runtime/review/materializers-effort-persist.test.js +0 -79
- package/dist/core-runtime/review/ontology-path-classifier.js +0 -179
- package/dist/core-runtime/review/ontology-path-classifier.test.js +0 -216
- package/dist/core-runtime/review/packet-boundary-policy.test.js +0 -107
- package/dist/core-runtime/review/participating-lens-paths.test.js +0 -73
- package/dist/core-runtime/review/review-config-legacy-translate.js +0 -244
- package/dist/core-runtime/review/review-config-legacy-translate.test.js +0 -161
- package/dist/core-runtime/review/review-config-validator.js +0 -289
- package/dist/core-runtime/review/review-config-validator.test.js +0 -236
- package/dist/core-runtime/review/shape-pipeline-audit.test.js +0 -311
- package/dist/core-runtime/review/shape-to-topology-id.js +0 -117
- package/dist/core-runtime/review/shape-to-topology-id.test.js +0 -132
- package/dist/core-runtime/review/topology-shape-derivation.js +0 -155
- package/dist/core-runtime/review/topology-shape-derivation.test.js +0 -195
- package/dist/core-runtime/scope-runtime/constants.js +0 -12
- package/dist/core-runtime/scope-runtime/constraint-pool.js +0 -166
- package/dist/core-runtime/scope-runtime/constraint-pool.test.js +0 -674
- package/dist/core-runtime/scope-runtime/domain-validation-log.js +0 -135
- package/dist/core-runtime/scope-runtime/domain-validation-log.test.js +0 -156
- package/dist/core-runtime/scope-runtime/eval-persistence.js +0 -65
- package/dist/core-runtime/scope-runtime/eval-persistence.test.js +0 -84
- package/dist/core-runtime/scope-runtime/event-pipeline.js +0 -64
- package/dist/core-runtime/scope-runtime/event-pipeline.test.js +0 -450
- package/dist/core-runtime/scope-runtime/event-store.js +0 -39
- package/dist/core-runtime/scope-runtime/event-store.test.js +0 -95
- package/dist/core-runtime/scope-runtime/gate-guard.js +0 -348
- package/dist/core-runtime/scope-runtime/gate-guard.test.js +0 -1047
- package/dist/core-runtime/scope-runtime/hash.js +0 -4
- package/dist/core-runtime/scope-runtime/hash.test.js +0 -33
- package/dist/core-runtime/scope-runtime/id.js +0 -4
- package/dist/core-runtime/scope-runtime/id.test.js +0 -17
- package/dist/core-runtime/scope-runtime/reducer.js +0 -297
- package/dist/core-runtime/scope-runtime/reducer.test.js +0 -759
- package/dist/core-runtime/scope-runtime/scope-manager.js +0 -161
- package/dist/core-runtime/scope-runtime/state-machine.js +0 -309
- package/dist/core-runtime/scope-runtime/state-machine.test.js +0 -704
- package/dist/core-runtime/scope-runtime/types.js +0 -116
- package/dist/core-runtime/scope-runtime/types.test.js +0 -69
- package/dist/core-runtime/translate/render-for-user.js +0 -169
- package/dist/core-runtime/translate/render-for-user.test.js +0 -122
- package/dist/providers/capability-contract.js +0 -1
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Evolve runtime adapter.
|
|
3
|
-
*
|
|
4
|
-
* Routes evolve subcommands to the appropriate command handler.
|
|
5
|
-
*/
|
|
6
|
-
import { join } from "node:path";
|
|
7
|
-
import { existsSync, mkdirSync } from "node:fs";
|
|
8
|
-
import { resolveScopePaths } from "../scope-runtime/scope-manager.js";
|
|
9
|
-
export async function handleEvolveCli(ontoHome, argv) {
|
|
10
|
-
const subcommand = argv[0];
|
|
11
|
-
const subArgv = argv.slice(1);
|
|
12
|
-
switch (subcommand) {
|
|
13
|
-
case "start":
|
|
14
|
-
return handleEvolveStart(ontoHome, subArgv);
|
|
15
|
-
case "propose-align":
|
|
16
|
-
return handleEvolveProposeAlign(subArgv);
|
|
17
|
-
case "align":
|
|
18
|
-
return handleEvolveAlign(subArgv);
|
|
19
|
-
case "draft":
|
|
20
|
-
return handleEvolveDraft(subArgv);
|
|
21
|
-
case "apply":
|
|
22
|
-
return handleEvolveApply(subArgv);
|
|
23
|
-
case "close":
|
|
24
|
-
return handleEvolveClose(subArgv);
|
|
25
|
-
case "defer":
|
|
26
|
-
return handleEvolveDefer(subArgv);
|
|
27
|
-
case "--help":
|
|
28
|
-
case "-h":
|
|
29
|
-
case undefined:
|
|
30
|
-
console.log([
|
|
31
|
-
"Usage: evolve <subcommand> [options]",
|
|
32
|
-
"",
|
|
33
|
-
"Subcommands:",
|
|
34
|
-
" start <description> Start or resume an evolve scope",
|
|
35
|
-
" propose-align --scope-id <id> Submit consolidated dialog output → align_proposed",
|
|
36
|
-
" align --scope-id <id> Lock or revise alignment direction",
|
|
37
|
-
" draft --scope-id <id> Generate draft packet / confirm surface / decide constraints",
|
|
38
|
-
" apply --scope-id <id> Apply evolve output to implementation",
|
|
39
|
-
" close --scope-id <id> Close a validated scope",
|
|
40
|
-
" defer --scope-id <id> Defer a non-terminal scope",
|
|
41
|
-
"",
|
|
42
|
-
"Options:",
|
|
43
|
-
" --project-root <path> Project root (default: cwd)",
|
|
44
|
-
" --scopes-dir <path> Scopes directory (default: <project-root>/scopes)",
|
|
45
|
-
" --project-name <name> Project name for scope ID generation",
|
|
46
|
-
" --scope-id <id> Target scope ID (required for align/draft/apply/close)",
|
|
47
|
-
" --entry-mode <mode> 'experience', 'interface', or 'process' (default: experience)",
|
|
48
|
-
" --json <content> propose-align: dialog output JSON; align: verdict JSON",
|
|
49
|
-
" --reason <text> Defer reason (required for defer)",
|
|
50
|
-
" --resume-condition <text> Condition under which scope resumes (required for defer)",
|
|
51
|
-
"",
|
|
52
|
-
"propose-align UX contract:",
|
|
53
|
-
" Agent (Claude Code session / LLM) conducts dialog with Principal using",
|
|
54
|
-
" selection-based choices + natural-language fallback, consolidates answers",
|
|
55
|
-
" across rounds, and on convergence calls propose-align with the resulting",
|
|
56
|
-
" {interpreted_direction, proposed_scope, scenarios, as_is, constraints,",
|
|
57
|
-
" decision_questions}. Runtime owns state machine, event log, packet rendering.",
|
|
58
|
-
].join("\n"));
|
|
59
|
-
return 0;
|
|
60
|
-
default:
|
|
61
|
-
console.error(`[onto] Unknown evolve subcommand: ${subcommand}`);
|
|
62
|
-
console.error("Run evolve help for usage.");
|
|
63
|
-
return 1;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// ─── Shared helpers ───
|
|
67
|
-
function readOption(argv, name) {
|
|
68
|
-
const idx = argv.indexOf(`--${name}`);
|
|
69
|
-
if (idx >= 0 && idx + 1 < argv.length) {
|
|
70
|
-
return argv[idx + 1];
|
|
71
|
-
}
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
function resolveScopePathsFromArgv(argv) {
|
|
75
|
-
const scopeId = readOption(argv, "scope-id");
|
|
76
|
-
if (!scopeId) {
|
|
77
|
-
console.error("[onto] --scope-id is required.");
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
const projectRoot = readOption(argv, "project-root") ?? process.cwd();
|
|
81
|
-
const scopesDir = readOption(argv, "scopes-dir") ?? join(projectRoot, "scopes");
|
|
82
|
-
return resolveScopePaths(scopesDir, scopeId);
|
|
83
|
-
}
|
|
84
|
-
// ─── start ───
|
|
85
|
-
async function handleEvolveStart(_ontoHome, argv) {
|
|
86
|
-
const { executeStart } = await import("./commands/start.js");
|
|
87
|
-
const projectRoot = readOption(argv, "project-root") ?? process.cwd();
|
|
88
|
-
const scopesDir = readOption(argv, "scopes-dir") ?? join(projectRoot, "scopes");
|
|
89
|
-
const projectName = readOption(argv, "project-name");
|
|
90
|
-
const scopeId = readOption(argv, "scope-id");
|
|
91
|
-
const entryMode = (readOption(argv, "entry-mode") ?? "experience");
|
|
92
|
-
// Collect non-flag arguments as description
|
|
93
|
-
const rawInput = argv
|
|
94
|
-
.filter((arg) => !arg.startsWith("--"))
|
|
95
|
-
.join(" ")
|
|
96
|
-
.trim();
|
|
97
|
-
if (!rawInput && !scopeId) {
|
|
98
|
-
console.error("[onto] evolve start requires a description or --scope-id to resume.");
|
|
99
|
-
return 1;
|
|
100
|
-
}
|
|
101
|
-
// Ensure scopes directory exists
|
|
102
|
-
if (!existsSync(scopesDir)) {
|
|
103
|
-
mkdirSync(scopesDir, { recursive: true });
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
const result = await executeStart({
|
|
107
|
-
rawInput: rawInput || "",
|
|
108
|
-
projectRoot,
|
|
109
|
-
scopesDir,
|
|
110
|
-
...(projectName !== undefined ? { projectName } : {}),
|
|
111
|
-
...(scopeId !== undefined ? { scopeId } : {}),
|
|
112
|
-
entryMode,
|
|
113
|
-
onProgress: (msg) => console.log(` ${msg}`),
|
|
114
|
-
});
|
|
115
|
-
if (!result.success) {
|
|
116
|
-
console.error(`[onto] evolve start failed: ${result.reason} (step: ${result.step})`);
|
|
117
|
-
return 1;
|
|
118
|
-
}
|
|
119
|
-
if (result.action === "initialized") {
|
|
120
|
-
console.log(JSON.stringify({
|
|
121
|
-
status: "initialized",
|
|
122
|
-
scope_id: result.scopeId,
|
|
123
|
-
brief_path: result.briefPath,
|
|
124
|
-
message: "Scope initialized. Fill in the brief, then resume evolve start.",
|
|
125
|
-
}, null, 2));
|
|
126
|
-
return 0;
|
|
127
|
-
}
|
|
128
|
-
if (result.action === "resume_info") {
|
|
129
|
-
console.log(JSON.stringify({
|
|
130
|
-
status: "resume",
|
|
131
|
-
scope_id: result.scopeId,
|
|
132
|
-
current_state: result.currentState,
|
|
133
|
-
next_action: result.nextAction,
|
|
134
|
-
}, null, 2));
|
|
135
|
-
return 0;
|
|
136
|
-
}
|
|
137
|
-
if (result.action === "process_scope_created") {
|
|
138
|
-
console.log(JSON.stringify({
|
|
139
|
-
status: "process_scope_created",
|
|
140
|
-
scope_id: result.scopeId,
|
|
141
|
-
authority_sources: result.authoritySources.length,
|
|
142
|
-
authority_consistency: result.authorityConsistency,
|
|
143
|
-
}, null, 2));
|
|
144
|
-
return 0;
|
|
145
|
-
}
|
|
146
|
-
// Full execution result (code-product path)
|
|
147
|
-
console.log(JSON.stringify({
|
|
148
|
-
status: "executed",
|
|
149
|
-
paths: result.paths,
|
|
150
|
-
scan_results: result.scanResults.length,
|
|
151
|
-
scan_errors: result.scanErrors.length,
|
|
152
|
-
total_files: result.totalFiles,
|
|
153
|
-
}, null, 2));
|
|
154
|
-
return 0;
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
console.error(`[onto] evolve start error: ${error instanceof Error ? error.message : String(error)}`);
|
|
158
|
-
return 1;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// ─── align ───
|
|
162
|
-
// ─── propose-align ───
|
|
163
|
-
async function handleEvolveProposeAlign(argv) {
|
|
164
|
-
const paths = resolveScopePathsFromArgv(argv);
|
|
165
|
-
if (!paths)
|
|
166
|
-
return 1;
|
|
167
|
-
const jsonInput = readOption(argv, "json");
|
|
168
|
-
if (!jsonInput) {
|
|
169
|
-
console.error("[onto] evolve propose-align requires --json '<dialog-output>'.");
|
|
170
|
-
console.error('Shape: --json \'{"interpreted_direction":"...","proposed_scope":{"in":[...],"out":[...]},"as_is":{...},"constraints":[...],"decision_questions":[...]}\'');
|
|
171
|
-
console.error("See evolve help for the UX contract (agent owns dialog, runtime owns state/events/packet).");
|
|
172
|
-
return 1;
|
|
173
|
-
}
|
|
174
|
-
const { executeProposeAlign } = await import("./commands/propose-align.js");
|
|
175
|
-
const result = executeProposeAlign(paths, jsonInput);
|
|
176
|
-
console.log(JSON.stringify(result, null, 2));
|
|
177
|
-
return result.success ? 0 : 1;
|
|
178
|
-
}
|
|
179
|
-
// ─── align ───
|
|
180
|
-
async function handleEvolveAlign(argv) {
|
|
181
|
-
const paths = resolveScopePathsFromArgv(argv);
|
|
182
|
-
if (!paths)
|
|
183
|
-
return 1;
|
|
184
|
-
const jsonInput = readOption(argv, "json");
|
|
185
|
-
if (!jsonInput) {
|
|
186
|
-
console.error("[onto] evolve align requires --json '<verdict-object>'.");
|
|
187
|
-
console.error("Example: --json '{\"type\":\"approve\",\"direction\":\"...\",\"scope_in\":[],\"scope_out\":[]}'");
|
|
188
|
-
return 1;
|
|
189
|
-
}
|
|
190
|
-
const { executeAlign } = await import("./commands/align.js");
|
|
191
|
-
const verdict = JSON.parse(jsonInput);
|
|
192
|
-
const result = executeAlign({ paths, verdict });
|
|
193
|
-
console.log(JSON.stringify(result, null, 2));
|
|
194
|
-
return result.success ? 0 : 1;
|
|
195
|
-
}
|
|
196
|
-
// ─── draft ───
|
|
197
|
-
async function handleEvolveDraft(argv) {
|
|
198
|
-
const paths = resolveScopePathsFromArgv(argv);
|
|
199
|
-
if (!paths)
|
|
200
|
-
return 1;
|
|
201
|
-
const jsonInput = readOption(argv, "json");
|
|
202
|
-
if (!jsonInput) {
|
|
203
|
-
console.error("[onto] evolve draft requires --json '<action-object>'.");
|
|
204
|
-
console.error("Example: --json '{\"type\":\"generate_surface\"}'");
|
|
205
|
-
return 1;
|
|
206
|
-
}
|
|
207
|
-
const { executeDraft } = await import("./commands/draft.js");
|
|
208
|
-
const action = JSON.parse(jsonInput);
|
|
209
|
-
const result = executeDraft({ paths, action });
|
|
210
|
-
console.log(JSON.stringify(result, null, 2));
|
|
211
|
-
return result.success ? 0 : 1;
|
|
212
|
-
}
|
|
213
|
-
// ─── apply ───
|
|
214
|
-
async function handleEvolveApply(argv) {
|
|
215
|
-
const paths = resolveScopePathsFromArgv(argv);
|
|
216
|
-
if (!paths)
|
|
217
|
-
return 1;
|
|
218
|
-
const jsonInput = readOption(argv, "json");
|
|
219
|
-
if (!jsonInput) {
|
|
220
|
-
console.error("[onto] evolve apply requires --json '<action-object>'.");
|
|
221
|
-
console.error("Example: --json '{\"type\":\"start_apply\",\"buildSpecHash\":\"...\"}'");
|
|
222
|
-
return 1;
|
|
223
|
-
}
|
|
224
|
-
const projectRoot = readOption(argv, "project-root") ?? process.cwd();
|
|
225
|
-
const { executeApply } = await import("./commands/apply.js");
|
|
226
|
-
const action = JSON.parse(jsonInput);
|
|
227
|
-
const result = executeApply(paths, action, { projectRoot });
|
|
228
|
-
console.log(JSON.stringify(result, null, 2));
|
|
229
|
-
return result.success ? 0 : 1;
|
|
230
|
-
}
|
|
231
|
-
// ─── close ───
|
|
232
|
-
async function handleEvolveClose(argv) {
|
|
233
|
-
const paths = resolveScopePathsFromArgv(argv);
|
|
234
|
-
if (!paths)
|
|
235
|
-
return 1;
|
|
236
|
-
const { executeClose } = await import("./commands/close.js");
|
|
237
|
-
const result = executeClose(paths);
|
|
238
|
-
console.log(JSON.stringify(result, null, 2));
|
|
239
|
-
return result.success ? 0 : 1;
|
|
240
|
-
}
|
|
241
|
-
// ─── defer ───
|
|
242
|
-
async function handleEvolveDefer(argv) {
|
|
243
|
-
const paths = resolveScopePathsFromArgv(argv);
|
|
244
|
-
if (!paths)
|
|
245
|
-
return 1;
|
|
246
|
-
const reason = readOption(argv, "reason");
|
|
247
|
-
const resumeCondition = readOption(argv, "resume-condition");
|
|
248
|
-
if (!reason || !resumeCondition) {
|
|
249
|
-
console.error("[onto] evolve defer requires --reason and --resume-condition.");
|
|
250
|
-
return 1;
|
|
251
|
-
}
|
|
252
|
-
const { executeDefer } = await import("./commands/defer.js");
|
|
253
|
-
const result = executeDefer(paths, reason, resumeCondition);
|
|
254
|
-
console.log(JSON.stringify(result, null, 2));
|
|
255
|
-
return result.success ? 0 : 1;
|
|
256
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /align command orchestration.
|
|
3
|
-
*
|
|
4
|
-
* Processes user verdict on the Align Packet:
|
|
5
|
-
* - approve: lock direction + scope boundaries → align_locked
|
|
6
|
-
* - revise: re-render Align Packet with feedback → stay align_proposed
|
|
7
|
-
* - reject: terminate scope → rejected
|
|
8
|
-
* - redirect: return to grounding → grounded
|
|
9
|
-
*
|
|
10
|
-
* Stale detection and convergence safety are handled here.
|
|
11
|
-
*/
|
|
12
|
-
import { writeFileSync } from "node:fs";
|
|
13
|
-
import { join } from "node:path";
|
|
14
|
-
import { readEvents } from "../../scope-runtime/event-store.js";
|
|
15
|
-
import { reduce } from "../../scope-runtime/reducer.js";
|
|
16
|
-
import { appendScopeEvent } from "../../scope-runtime/event-pipeline.js";
|
|
17
|
-
import { renderAlignPacket } from "../renderers/align-packet.js";
|
|
18
|
-
import { checkStale } from "./stale-check.js";
|
|
19
|
-
import { wrapGateError } from "./error-messages.js";
|
|
20
|
-
import { refreshScopeMd } from "./shared.js";
|
|
21
|
-
import { CONVERGENCE_THRESHOLDS } from "../../scope-runtime/constants.js";
|
|
22
|
-
import { contentHash } from "../../scope-runtime/hash.js";
|
|
23
|
-
// ─── Main ───
|
|
24
|
-
export function executeAlign(input) {
|
|
25
|
-
const { paths, verdict } = input;
|
|
26
|
-
// Step 1: Check current state
|
|
27
|
-
const events = readEvents(paths.events);
|
|
28
|
-
const state = reduce(events);
|
|
29
|
-
if (state.current_state !== "align_proposed") {
|
|
30
|
-
return {
|
|
31
|
-
success: false,
|
|
32
|
-
reason: `현재 상태가 ${state.current_state}입니다. /align은 align_proposed 상태에서만 실행할 수 있습니다.`,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
// Step 2: Stale check (local sources only)
|
|
36
|
-
const staleResult = checkStale(paths);
|
|
37
|
-
if (staleResult.stale) {
|
|
38
|
-
const changedPaths = staleResult.stale_sources.map(s => s.path).join(", ");
|
|
39
|
-
return {
|
|
40
|
-
success: false,
|
|
41
|
-
reason: `소스가 변경되었습니다 (${changedPaths}). /start를 다시 실행하여 재스캔하세요.`,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
// Step 3: Check convergence blocked
|
|
45
|
-
if (state.convergence_blocked) {
|
|
46
|
-
return {
|
|
47
|
-
success: false,
|
|
48
|
-
reason: "수렴 차단 상태입니다. 다음 중 하나를 선택하세요: (1) 방향 변경 (/align redirect) (2) scope 축소 (/align revise) (3) scope 보류 (scope.deferred)",
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
// Step 4: Process verdict
|
|
52
|
-
switch (verdict.type) {
|
|
53
|
-
case "approve":
|
|
54
|
-
return handleApprove(paths, state, verdict);
|
|
55
|
-
case "revise":
|
|
56
|
-
return handleRevise(paths, state, verdict);
|
|
57
|
-
case "reject":
|
|
58
|
-
return handleReject(paths, verdict);
|
|
59
|
-
case "redirect":
|
|
60
|
-
return handleRedirect(paths, verdict);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// ─── Verdict Handlers ───
|
|
64
|
-
function handleApprove(paths, state, verdict) {
|
|
65
|
-
const result = appendScopeEvent(paths, {
|
|
66
|
-
type: "align.locked",
|
|
67
|
-
actor: "user",
|
|
68
|
-
payload: {
|
|
69
|
-
locked_direction: verdict.direction,
|
|
70
|
-
locked_scope_boundaries: {
|
|
71
|
-
in: verdict.scope_in,
|
|
72
|
-
out: verdict.scope_out,
|
|
73
|
-
},
|
|
74
|
-
locked_in_out: true,
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
if (!result.success) {
|
|
78
|
-
return { success: false, reason: wrapGateError(result.reason) };
|
|
79
|
-
}
|
|
80
|
-
refreshScopeMd(paths, result.state);
|
|
81
|
-
return {
|
|
82
|
-
success: true,
|
|
83
|
-
nextState: "align_locked",
|
|
84
|
-
message: "방향과 범위가 확정되었습니다. /draft로 Surface를 생성하세요.",
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function handleRevise(paths, state, verdict) {
|
|
88
|
-
const result = appendScopeEvent(paths, {
|
|
89
|
-
type: "align.revised",
|
|
90
|
-
actor: "user",
|
|
91
|
-
payload: {
|
|
92
|
-
revision_count: state.revision_count_align + 1,
|
|
93
|
-
feedback_scope: verdict.feedbackScope,
|
|
94
|
-
feedback_text: verdict.feedback,
|
|
95
|
-
packet_path: "build/align-packet.md",
|
|
96
|
-
packet_hash: verdict.updatedPacketHash,
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
if (!result.success) {
|
|
100
|
-
return { success: false, reason: wrapGateError(result.reason) };
|
|
101
|
-
}
|
|
102
|
-
// Record convergence observational events based on revision count
|
|
103
|
-
const revCount = state.revision_count_align + 1;
|
|
104
|
-
if (revCount >= CONVERGENCE_THRESHOLDS.blocked) {
|
|
105
|
-
appendScopeEvent(paths, {
|
|
106
|
-
type: "convergence.blocked",
|
|
107
|
-
actor: "system",
|
|
108
|
-
payload: { state: "align_proposed", revision_count: revCount, requires_action: true },
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
else if (revCount >= CONVERGENCE_THRESHOLDS.caution) {
|
|
112
|
-
appendScopeEvent(paths, {
|
|
113
|
-
type: "convergence.diagnosis",
|
|
114
|
-
actor: "system",
|
|
115
|
-
payload: { state: "align_proposed", revision_count: revCount, diagnosis: "반복 수정이 지속되고 있습니다", options: ["방향 변경", "scope 축소", "전문가 상담"] },
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
else if (revCount >= CONVERGENCE_THRESHOLDS.notice) {
|
|
119
|
-
appendScopeEvent(paths, {
|
|
120
|
-
type: "convergence.warning",
|
|
121
|
-
actor: "system",
|
|
122
|
-
payload: { state: "align_proposed", revision_count: revCount, pattern_summary: `${revCount}회 반복 수정 중` },
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
refreshScopeMd(paths);
|
|
126
|
-
let message = "피드백이 반영되었습니다. 수정된 Align Packet을 확인하세요.";
|
|
127
|
-
if (revCount >= CONVERGENCE_THRESHOLDS.blocked) {
|
|
128
|
-
message = "7회 이상 수정되었습니다. 수렴 차단 상태입니다. 다음 중 선택하세요: (1) 방향 변경 (2) scope 축소 (3) scope 보류";
|
|
129
|
-
}
|
|
130
|
-
else if (revCount >= CONVERGENCE_THRESHOLDS.caution) {
|
|
131
|
-
message = `${revCount}회 수정되었습니다. 방향 자체를 재검토하는 것이 좋을 수 있습니다.`;
|
|
132
|
-
}
|
|
133
|
-
else if (revCount >= 3) {
|
|
134
|
-
message = `${revCount}회 수정되었습니다. 피드백 패턴을 확인해 주세요.`;
|
|
135
|
-
}
|
|
136
|
-
return {
|
|
137
|
-
success: true,
|
|
138
|
-
nextState: "align_proposed",
|
|
139
|
-
message,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function handleReject(paths, verdict) {
|
|
143
|
-
const result = appendScopeEvent(paths, {
|
|
144
|
-
type: "scope.rejected",
|
|
145
|
-
actor: "user",
|
|
146
|
-
payload: {
|
|
147
|
-
reason: verdict.reason,
|
|
148
|
-
rejection_basis: verdict.basis,
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
if (!result.success) {
|
|
152
|
-
return { success: false, reason: wrapGateError(result.reason) };
|
|
153
|
-
}
|
|
154
|
-
refreshScopeMd(paths, result.state);
|
|
155
|
-
return {
|
|
156
|
-
success: true,
|
|
157
|
-
nextState: "rejected",
|
|
158
|
-
message: "scope가 거절되었습니다.",
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
function handleRedirect(paths, verdict) {
|
|
162
|
-
const result = appendScopeEvent(paths, {
|
|
163
|
-
type: "redirect.to_grounding",
|
|
164
|
-
actor: "user",
|
|
165
|
-
payload: {
|
|
166
|
-
from_state: "align_proposed",
|
|
167
|
-
reason: verdict.reason,
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
if (!result.success) {
|
|
171
|
-
return { success: false, reason: wrapGateError(result.reason) };
|
|
172
|
-
}
|
|
173
|
-
refreshScopeMd(paths, result.state);
|
|
174
|
-
return {
|
|
175
|
-
success: true,
|
|
176
|
-
nextState: "grounded",
|
|
177
|
-
message: "grounding으로 복귀합니다. 추가 소스를 확보한 뒤 /start를 재실행하세요.",
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
// ─── Packet Rendering (UF-STRUCTURE-PACKET-SEAT) ───
|
|
181
|
-
/**
|
|
182
|
-
* Render an Align Packet and write it to `build/align-packet.md`.
|
|
183
|
-
*
|
|
184
|
-
* Called by the agent when it has assembled AlignPacketContent.
|
|
185
|
-
* Returns the content hash of the written packet (used by align.revised events).
|
|
186
|
-
*/
|
|
187
|
-
export function writeAlignPacket(paths, content) {
|
|
188
|
-
const state = reduce(readEvents(paths.events));
|
|
189
|
-
const md = renderAlignPacket(state, content);
|
|
190
|
-
const packetPath = join(paths.build, "align-packet.md");
|
|
191
|
-
writeFileSync(packetPath, md, "utf-8");
|
|
192
|
-
return { packetPath, packetHash: contentHash(md) };
|
|
193
|
-
}
|
|
194
|
-
// refreshScopeMd is imported from ./shared.ts (UF-CONCISENESS-SCOPE-MD consolidated)
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { executeAlign } from "./align.js";
|
|
6
|
-
import { createScope } from "../../scope-runtime/scope-manager.js";
|
|
7
|
-
import { appendScopeEvent } from "../../scope-runtime/event-pipeline.js";
|
|
8
|
-
import { readEvents } from "../../scope-runtime/event-store.js";
|
|
9
|
-
import { reduce } from "../../scope-runtime/reducer.js";
|
|
10
|
-
let tmpDir;
|
|
11
|
-
beforeEach(() => { tmpDir = mkdtempSync(join(tmpdir(), "sprint-align-")); });
|
|
12
|
-
afterEach(() => { rmSync(tmpDir, { recursive: true, force: true }); });
|
|
13
|
-
/** Set up a scope in align_proposed state */
|
|
14
|
-
function setupAlignProposed() {
|
|
15
|
-
const paths = createScope(tmpDir, "SC-ALIGN-001");
|
|
16
|
-
appendScopeEvent(paths, { type: "scope.created", actor: "user", payload: { title: "Test", description: "d", entry_mode: "experience" } });
|
|
17
|
-
appendScopeEvent(paths, { type: "grounding.started", actor: "system", payload: { sources: [{ type: "add-dir", path_or_url: "/test" }] } });
|
|
18
|
-
appendScopeEvent(paths, { type: "grounding.completed", actor: "system", payload: { snapshot_revision: 1, source_hashes: { "add-dir:/test": "h1" }, perspective_summary: { experience: 1, code: 1, policy: 1 } } });
|
|
19
|
-
appendScopeEvent(paths, { type: "align.proposed", actor: "system", payload: { packet_path: "build/align-packet.md", packet_hash: "hash1", snapshot_revision: 1 } });
|
|
20
|
-
return paths;
|
|
21
|
-
}
|
|
22
|
-
describe("executeAlign", () => {
|
|
23
|
-
it("approve → align_locked", () => {
|
|
24
|
-
const paths = setupAlignProposed();
|
|
25
|
-
const result = executeAlign({
|
|
26
|
-
paths,
|
|
27
|
-
verdict: { type: "approve", direction: "튜터 차단 기능", scope_in: ["차단 생성"], scope_out: ["관리자 차단"] },
|
|
28
|
-
});
|
|
29
|
-
expect(result.success).toBe(true);
|
|
30
|
-
if (!result.success)
|
|
31
|
-
return;
|
|
32
|
-
expect(result.nextState).toBe("align_locked");
|
|
33
|
-
const state = reduce(readEvents(paths.events));
|
|
34
|
-
expect(state.current_state).toBe("align_locked");
|
|
35
|
-
expect(state.direction).toBe("튜터 차단 기능");
|
|
36
|
-
});
|
|
37
|
-
it("revise → stay align_proposed", () => {
|
|
38
|
-
const paths = setupAlignProposed();
|
|
39
|
-
const result = executeAlign({
|
|
40
|
-
paths,
|
|
41
|
-
verdict: { type: "revise", feedback: "범위를 좁혀주세요", feedbackScope: "scope", updatedPacketHash: "hash2" },
|
|
42
|
-
});
|
|
43
|
-
expect(result.success).toBe(true);
|
|
44
|
-
if (!result.success)
|
|
45
|
-
return;
|
|
46
|
-
expect(result.nextState).toBe("align_proposed");
|
|
47
|
-
});
|
|
48
|
-
it("reject → rejected", () => {
|
|
49
|
-
const paths = setupAlignProposed();
|
|
50
|
-
const result = executeAlign({
|
|
51
|
-
paths,
|
|
52
|
-
verdict: { type: "reject", reason: "방향이 잘못됨", basis: "시장 조사 결과" },
|
|
53
|
-
});
|
|
54
|
-
expect(result.success).toBe(true);
|
|
55
|
-
if (!result.success)
|
|
56
|
-
return;
|
|
57
|
-
expect(result.nextState).toBe("rejected");
|
|
58
|
-
});
|
|
59
|
-
it("redirect → grounded", () => {
|
|
60
|
-
const paths = setupAlignProposed();
|
|
61
|
-
const result = executeAlign({
|
|
62
|
-
paths,
|
|
63
|
-
verdict: { type: "redirect", reason: "정보 부족" },
|
|
64
|
-
});
|
|
65
|
-
expect(result.success).toBe(true);
|
|
66
|
-
if (!result.success)
|
|
67
|
-
return;
|
|
68
|
-
expect(result.nextState).toBe("grounded");
|
|
69
|
-
});
|
|
70
|
-
it("fails when not in align_proposed state", () => {
|
|
71
|
-
const paths = createScope(tmpDir, "SC-ALIGN-002");
|
|
72
|
-
appendScopeEvent(paths, { type: "scope.created", actor: "user", payload: { title: "T", description: "d", entry_mode: "experience" } });
|
|
73
|
-
const result = executeAlign({
|
|
74
|
-
paths,
|
|
75
|
-
verdict: { type: "approve", direction: "d", scope_in: [], scope_out: [] },
|
|
76
|
-
});
|
|
77
|
-
expect(result.success).toBe(false);
|
|
78
|
-
if (result.success)
|
|
79
|
-
return;
|
|
80
|
-
expect(result.reason).toContain("align_proposed");
|
|
81
|
-
});
|
|
82
|
-
});
|