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,377 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { renderDraftPacket } from "./draft-packet.js";
|
|
5
|
-
import { reduce } from "../../scope-runtime/reducer.js";
|
|
6
|
-
// ─── Helpers ───
|
|
7
|
-
function emptyPool() {
|
|
8
|
-
return { constraints: [], summary: { total: 0, required: 0, recommended: 0, decided: 0, clarify_pending: 0, invalidated: 0, undecided: 0 } };
|
|
9
|
-
}
|
|
10
|
-
function makeEntry(id, overrides = {}) {
|
|
11
|
-
return {
|
|
12
|
-
constraint_id: id, perspective: "code", summary: `summary ${id}`,
|
|
13
|
-
severity: "recommended", discovery_stage: "draft_phase2", decision_owner: "product_owner",
|
|
14
|
-
impact_if_ignored: `impact ${id}`, source_refs: [{ source: "t.ts", detail: "d" }],
|
|
15
|
-
evidence_status: "unverified",
|
|
16
|
-
status: "undecided", discovered_at: 1, ...overrides,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function makePoolWith(...entries) {
|
|
20
|
-
let req = 0, rec = 0, inv = 0;
|
|
21
|
-
for (const e of entries) {
|
|
22
|
-
if (e.severity === "required")
|
|
23
|
-
req++;
|
|
24
|
-
else
|
|
25
|
-
rec++;
|
|
26
|
-
if (e.status === "invalidated")
|
|
27
|
-
inv++;
|
|
28
|
-
}
|
|
29
|
-
return { constraints: entries, summary: { total: entries.length, required: req, recommended: rec, decided: 0, clarify_pending: 0, invalidated: inv, undecided: entries.length - inv } };
|
|
30
|
-
}
|
|
31
|
-
function makeState(overrides = {}) {
|
|
32
|
-
return {
|
|
33
|
-
scope_id: "SC-TEST", title: "테스트", description: "d", entry_mode: "experience",
|
|
34
|
-
current_state: "surface_confirmed", constraint_pool: emptyPool(),
|
|
35
|
-
stale: false, compile_ready: false, convergence_blocked: false,
|
|
36
|
-
revision_count_align: 0, revision_count_surface: 0, retry_count_compile: 0,
|
|
37
|
-
snapshot_revision: 0, pre_apply_completed: false, prd_review_completed: false,
|
|
38
|
-
verdict_log: [], feedback_history: [], latest_revision: 0, ...overrides,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function makeContent(overrides = {}) {
|
|
42
|
-
return {
|
|
43
|
-
surface_path: "surface/preview/", scenario_guide: [],
|
|
44
|
-
constraint_details: [], guardrails: [], decision_questions: [], ...overrides,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function poDet(id) {
|
|
48
|
-
return {
|
|
49
|
-
constraint_id: id, decision_owner: "product_owner", situation: `situation ${id}`,
|
|
50
|
-
options_table: [{ choice: "inject", pros: "빠른 적용", description: "desc", risk: "low", reversal_cost: "낮음" }],
|
|
51
|
-
recommendation: "inject 추천",
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function builderDet(id) {
|
|
55
|
-
return {
|
|
56
|
-
constraint_id: id, decision_owner: "builder", situation: `situation ${id}`,
|
|
57
|
-
builder_decision: "DB 테이블 생성", builder_judgment: "필수. 되돌림 비용 낮음",
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// ─── Golden data ───
|
|
61
|
-
describe("draft-packet — golden data structure", () => {
|
|
62
|
-
it("renders Draft Packet matching golden structure", () => {
|
|
63
|
-
const goldenPath = resolve(import.meta.dirname, "../../scope-runtime/__fixtures__/example-tutor-block/events.ndjson");
|
|
64
|
-
const events = readFileSync(goldenPath, "utf-8").trimEnd().split("\n").map((l) => JSON.parse(l));
|
|
65
|
-
// State at surface_confirmed + all constraints discovered (first 18 events)
|
|
66
|
-
const state = reduce(events.slice(0, 18));
|
|
67
|
-
const content = {
|
|
68
|
-
surface_path: "scopes/SC-2026-001/surface/preview/",
|
|
69
|
-
run_command: "cd surface/preview && npm run dev",
|
|
70
|
-
mockup_revisions: 3,
|
|
71
|
-
scenario_guide: [
|
|
72
|
-
{ scenario: "차단 생성", start: "튜터 프로필", steps: "차단 버튼 → 확인", confirmed: "성공 메시지" },
|
|
73
|
-
{ scenario: "차단 해제", start: "설정 → 차단 관리", steps: "해제 버튼 → 확인", confirmed: "목록에서 제거" },
|
|
74
|
-
],
|
|
75
|
-
constraint_details: [
|
|
76
|
-
{ constraint_id: "CST-001", decision_owner: "product_owner", situation: "매칭 시스템에 제외 기능 없음", options_table: [{ choice: "inject (제외 기능 추가)", pros: "완전한 차단", description: "매칭 시스템에 제외 기능 추가", risk: "가장 큰 변경", reversal_cost: "낮음" }], recommendation: "inject" },
|
|
77
|
-
{ constraint_id: "CST-005", decision_owner: "builder", situation: "차단 정보 저장 공간 없음", builder_decision: "DB 테이블 신규 생성", builder_judgment: "필수. 되돌림 비용 낮음" },
|
|
78
|
-
{ constraint_id: "CST-008", decision_owner: "product_owner", situation: "차단 남용 방지 한도 없음", options_table: [{ choice: "inject (언어별 5명)", pros: "남용 방지", description: "언어별 5명 제한", risk: "한도 낮음 불만", reversal_cost: "낮음" }], recommendation: "inject (언어별 5명)" },
|
|
79
|
-
{ constraint_id: "CST-002", decision_owner: "product_owner", situation: "이용약관 충돌", options_table: [{ choice: "inject (예외 조항)", pros: "법적 안정", description: "약관 예외 추가", risk: "법무 비용", reversal_cost: "중간" }], recommendation: "clarify" },
|
|
80
|
-
{ constraint_id: "CST-003", decision_owner: "product_owner", situation: "버튼 공간 부족", options_table: [{ choice: "inject (간격 확보)", pros: "UX 개선", description: "레이아웃 재배치", risk: "사용자 혼동", reversal_cost: "낮음" }], recommendation: "inject" },
|
|
81
|
-
{ constraint_id: "CST-004", decision_owner: "product_owner", situation: "차단 관리 메뉴 위치", options_table: [{ choice: "defer (현재 유지)", pros: "변경 없음", description: "4번째 항목 유지", risk: "찾기 어려움", reversal_cost: "낮음" }], recommendation: "defer" },
|
|
82
|
-
{ constraint_id: "CST-006", decision_owner: "builder", situation: "API 응답 변경 위험", builder_decision: "optional 필드 방식", builder_judgment: "호환성 유지. 비용 적음", guardrail: "기존 API 응답 형식을 깨지 않는다" },
|
|
83
|
-
{ constraint_id: "CST-007", decision_owner: "product_owner", situation: "개인정보 삭제 의무", options_table: [{ choice: "inject (자동 삭제)", pros: "규정 준수", description: "3년 후 삭제", risk: "차단 자연 해제", reversal_cost: "낮음" }], recommendation: "inject" },
|
|
84
|
-
],
|
|
85
|
-
guardrails: [
|
|
86
|
-
"기존 예약된 수업은 취소하지 않는다",
|
|
87
|
-
"차단 행위는 중복 요청 시 오류 없이 기존 상태를 유지한다",
|
|
88
|
-
"튜터에게 차단 사실을 알리지 않는다",
|
|
89
|
-
"기존 API 응답 형식을 깨지 않는다",
|
|
90
|
-
],
|
|
91
|
-
decision_questions: [
|
|
92
|
-
"위 8건에 대해 각각 선택해 주세요",
|
|
93
|
-
"clarify를 선택한 항목은 해소될 때까지 잠글 수 없습니다",
|
|
94
|
-
"모든 결정이 완료되면 compile을 시작합니다",
|
|
95
|
-
],
|
|
96
|
-
};
|
|
97
|
-
const md = renderDraftPacket(state, content);
|
|
98
|
-
// Section existence
|
|
99
|
-
expect(md).toContain("### 1. 확정된 Surface");
|
|
100
|
-
expect(md).toContain("### 2. 현재까지의 결정 현황");
|
|
101
|
-
expect(md).toContain("### 3. 결정이 필요한 항목");
|
|
102
|
-
expect(md).toContain("### 5. 제약 조건");
|
|
103
|
-
expect(md).toContain("### 6. 지금 결정할 것");
|
|
104
|
-
// CST tracking + severity
|
|
105
|
-
expect(md).toContain("CST-001");
|
|
106
|
-
expect(md).toContain("CST-008");
|
|
107
|
-
expect(md).toContain("필수");
|
|
108
|
-
expect(md).toContain("권장");
|
|
109
|
-
expect(md).toContain("(Builder 결정)");
|
|
110
|
-
// Impact from pool
|
|
111
|
-
expect(md).toContain("차단 버튼을 눌러도 실제 매칭에 반영되지 않습니다");
|
|
112
|
-
// Scenario table
|
|
113
|
-
expect(md).toContain("| 시나리오 | 시작 | 동작 순서 | 확인된 동작 |");
|
|
114
|
-
// Builder format
|
|
115
|
-
expect(md).toContain("Builder 결정 예정");
|
|
116
|
-
expect(md).toContain("guardrail 확인 후 승인");
|
|
117
|
-
// Decision choices
|
|
118
|
-
expect(md).toContain("**Approve**");
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
// ─── Section 2: auto-generated ───
|
|
122
|
-
describe("draft-packet — Section 2 auto status", () => {
|
|
123
|
-
it("shows Align decisions from state", () => {
|
|
124
|
-
const state = makeState({ direction: "test direction", scope_boundaries: { in: ["A"], out: ["B"] } });
|
|
125
|
-
const md = renderDraftPacket(state, makeContent());
|
|
126
|
-
expect(md).toContain("방향 승인");
|
|
127
|
-
expect(md).toContain("범위 확정");
|
|
128
|
-
});
|
|
129
|
-
it("shows grounding CST IDs", () => {
|
|
130
|
-
const entries = [makeEntry("CST-001", { discovery_stage: "grounding" }), makeEntry("CST-002", { discovery_stage: "draft_phase2" })];
|
|
131
|
-
const state = makeState({ constraint_pool: makePoolWith(...entries) });
|
|
132
|
-
const md = renderDraftPacket(state, makeContent());
|
|
133
|
-
expect(md).toContain("CST-001 인지 완료");
|
|
134
|
-
expect(md).not.toContain("CST-002 인지 완료");
|
|
135
|
-
});
|
|
136
|
-
it("shows clarify lock warning", () => {
|
|
137
|
-
const pool = emptyPool();
|
|
138
|
-
pool.summary.clarify_pending = 2;
|
|
139
|
-
pool.summary.total = 5;
|
|
140
|
-
const md = renderDraftPacket(makeState({ constraint_pool: pool }), makeContent());
|
|
141
|
-
expect(md).toContain("2건");
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
// ─── Section 3: sorting ───
|
|
145
|
-
describe("draft-packet — Section 3 sorting", () => {
|
|
146
|
-
it("sorts required before recommended", () => {
|
|
147
|
-
const e1 = makeEntry("CST-002", { severity: "recommended" });
|
|
148
|
-
const e2 = makeEntry("CST-001", { severity: "required" });
|
|
149
|
-
const state = makeState({ constraint_pool: makePoolWith(e1, e2) });
|
|
150
|
-
const content = makeContent({ constraint_details: [poDet("CST-002"), poDet("CST-001")] });
|
|
151
|
-
const md = renderDraftPacket(state, content);
|
|
152
|
-
const idx001 = md.indexOf("CST-001");
|
|
153
|
-
const idx002 = md.indexOf("CST-002");
|
|
154
|
-
expect(idx001).toBeLessThan(idx002);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
// ─── Section 3: PO vs Builder ───
|
|
158
|
-
describe("draft-packet — Section 3 PO/Builder detail", () => {
|
|
159
|
-
it("renders PO detail with options table", () => {
|
|
160
|
-
const entry = makeEntry("CST-001");
|
|
161
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
162
|
-
const content = makeContent({ constraint_details: [poDet("CST-001")] });
|
|
163
|
-
const md = renderDraftPacket(state, content);
|
|
164
|
-
expect(md).toContain("| 선택 | 이점 | 내용 | 리스크 | 되돌림 비용 |");
|
|
165
|
-
expect(md).toContain("추천:");
|
|
166
|
-
expect(md).toContain("선택: ___");
|
|
167
|
-
});
|
|
168
|
-
it("renders Builder detail with builder_decision", () => {
|
|
169
|
-
const entry = makeEntry("CST-001", { decision_owner: "builder" });
|
|
170
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
171
|
-
const content = makeContent({ constraint_details: [builderDet("CST-001")] });
|
|
172
|
-
const md = renderDraftPacket(state, content);
|
|
173
|
-
expect(md).toContain("**Builder가 결정할 사항:**");
|
|
174
|
-
expect(md).toContain("Builder 결정 예정");
|
|
175
|
-
});
|
|
176
|
-
it("renders Builder without guardrail — '제품 관점 제약 조건 없음'", () => {
|
|
177
|
-
const entry = makeEntry("CST-001", { decision_owner: "builder" });
|
|
178
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
179
|
-
const md = renderDraftPacket(state, makeContent({ constraint_details: [builderDet("CST-001")] }));
|
|
180
|
-
expect(md).toContain("제품 관점 제약 조건 없음");
|
|
181
|
-
expect(md).not.toContain("위 guardrail 확인 후 승인");
|
|
182
|
-
});
|
|
183
|
-
it("renders Builder guardrail when present", () => {
|
|
184
|
-
const entry = makeEntry("CST-001", { decision_owner: "builder" });
|
|
185
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
186
|
-
const det = builderDet("CST-001");
|
|
187
|
-
det.guardrail = "API 호환성 유지";
|
|
188
|
-
const md = renderDraftPacket(state, makeContent({ constraint_details: [det] }));
|
|
189
|
-
expect(md).toContain("**guardrail:** API 호환성 유지");
|
|
190
|
-
});
|
|
191
|
-
it("uses pool impact_if_ignored for '처리하지 않으면'", () => {
|
|
192
|
-
const entry = makeEntry("CST-001", { impact_if_ignored: "big problem" });
|
|
193
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
194
|
-
const md = renderDraftPacket(state, makeContent({ constraint_details: [poDet("CST-001")] }));
|
|
195
|
-
expect(md).toContain("**처리하지 않으면:** big problem");
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
// ─── Section 4: invalidated ───
|
|
199
|
-
describe("draft-packet — Section 4 invalidated", () => {
|
|
200
|
-
it("omits section when no invalidated", () => {
|
|
201
|
-
const md = renderDraftPacket(makeState(), makeContent());
|
|
202
|
-
expect(md).not.toContain("### 4.");
|
|
203
|
-
});
|
|
204
|
-
it("shows invalidated constraints", () => {
|
|
205
|
-
const entry = makeEntry("CST-003", { status: "invalidated" });
|
|
206
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
207
|
-
const md = renderDraftPacket(state, makeContent());
|
|
208
|
-
expect(md).toContain("### 4. 시스템이 제외한 항목");
|
|
209
|
-
expect(md).toContain("CST-003");
|
|
210
|
-
expect(md).toContain("복원");
|
|
211
|
-
});
|
|
212
|
-
it("shows required invalidated warning", () => {
|
|
213
|
-
const entry = makeEntry("CST-001", { status: "invalidated", severity: "required" });
|
|
214
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
215
|
-
const md = renderDraftPacket(state, makeContent());
|
|
216
|
-
expect(md).toContain("기능 불능 또는 규정 위반");
|
|
217
|
-
expect(md).toContain("제외에 동의하시나요");
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
// ─── Section 5: guardrails ───
|
|
221
|
-
describe("draft-packet — Section 5 guardrails", () => {
|
|
222
|
-
it("renders guardrail bullets", () => {
|
|
223
|
-
const md = renderDraftPacket(makeState(), makeContent({ guardrails: ["규칙1", "규칙2"] }));
|
|
224
|
-
expect(md).toContain("- 규칙1");
|
|
225
|
-
expect(md).toContain("- 규칙2");
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
// ─── Section 6: decision ───
|
|
229
|
-
describe("draft-packet — Section 6 decision", () => {
|
|
230
|
-
it("shows approve-only when no constraints", () => {
|
|
231
|
-
const md = renderDraftPacket(makeState(), makeContent());
|
|
232
|
-
expect(md).toContain("Approve만 선택");
|
|
233
|
-
});
|
|
234
|
-
it("shows full choices with constraint questions", () => {
|
|
235
|
-
const entry = makeEntry("CST-001");
|
|
236
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
237
|
-
const md = renderDraftPacket(state, makeContent({
|
|
238
|
-
constraint_details: [poDet("CST-001")],
|
|
239
|
-
decision_questions: ["8건에 대해 선택해 주세요"],
|
|
240
|
-
}));
|
|
241
|
-
expect(md).toContain("각 CST 결정");
|
|
242
|
-
expect(md).toContain("compile을 시작합니다");
|
|
243
|
-
});
|
|
244
|
-
it("shows clarify warning when pending", () => {
|
|
245
|
-
const pool = emptyPool();
|
|
246
|
-
pool.summary.clarify_pending = 1;
|
|
247
|
-
pool.summary.total = 1;
|
|
248
|
-
const entry = makeEntry("CST-001");
|
|
249
|
-
pool.constraints = [entry];
|
|
250
|
-
const state = makeState({ constraint_pool: pool });
|
|
251
|
-
const md = renderDraftPacket(state, makeContent({
|
|
252
|
-
constraint_details: [poDet("CST-001")],
|
|
253
|
-
decision_questions: ["선택하세요"],
|
|
254
|
-
}));
|
|
255
|
-
expect(md).toContain("clarify");
|
|
256
|
-
expect(md).toContain("잠글 수 없습니다");
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
// ─── Edge cases: empty and undefined fields ───
|
|
260
|
-
describe("draft-packet — empty/undefined edge cases", () => {
|
|
261
|
-
it("renders with empty scenario_guide (no table)", () => {
|
|
262
|
-
const md = renderDraftPacket(makeState(), makeContent({ scenario_guide: [] }));
|
|
263
|
-
expect(md).toContain("### 1. 확정된 Surface");
|
|
264
|
-
expect(md).not.toContain("| 시나리오 | 시작 |");
|
|
265
|
-
});
|
|
266
|
-
it("renders '없음' when guardrails is empty", () => {
|
|
267
|
-
const md = renderDraftPacket(makeState(), makeContent({ guardrails: [] }));
|
|
268
|
-
expect(md).toContain("없음");
|
|
269
|
-
});
|
|
270
|
-
it("omits run_command when undefined", () => {
|
|
271
|
-
const md = renderDraftPacket(makeState(), makeContent({
|
|
272
|
-
run_command: undefined,
|
|
273
|
-
}));
|
|
274
|
-
expect(md).not.toContain("**실행 방법**");
|
|
275
|
-
});
|
|
276
|
-
it("omits mockup_revisions when undefined", () => {
|
|
277
|
-
const md = renderDraftPacket(makeState(), makeContent({
|
|
278
|
-
mockup_revisions: undefined,
|
|
279
|
-
}));
|
|
280
|
-
expect(md).not.toContain("mockup 반복");
|
|
281
|
-
});
|
|
282
|
-
it("renders run_command when provided", () => {
|
|
283
|
-
const md = renderDraftPacket(makeState(), makeContent({
|
|
284
|
-
run_command: "npm run dev",
|
|
285
|
-
}));
|
|
286
|
-
expect(md).toContain("`npm run dev`");
|
|
287
|
-
});
|
|
288
|
-
it("renders mockup_revisions when provided", () => {
|
|
289
|
-
const md = renderDraftPacket(makeState(), makeContent({
|
|
290
|
-
mockup_revisions: 5,
|
|
291
|
-
}));
|
|
292
|
-
expect(md).toContain("5회 수정 후 주체자 확정");
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
// ─── Validation ───
|
|
296
|
-
describe("draft-packet — validation", () => {
|
|
297
|
-
it("throws when constraint_id not in pool", () => {
|
|
298
|
-
expect(() => renderDraftPacket(makeState(), makeContent({
|
|
299
|
-
constraint_details: [poDet("CST-MISSING")],
|
|
300
|
-
}))).toThrow("CST-MISSING");
|
|
301
|
-
});
|
|
302
|
-
it("throws when decision_owner mismatch", () => {
|
|
303
|
-
const entry = makeEntry("CST-001", { decision_owner: "builder" });
|
|
304
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
305
|
-
expect(() => renderDraftPacket(state, makeContent({
|
|
306
|
-
constraint_details: [poDet("CST-001")], // PO detail for builder constraint
|
|
307
|
-
}))).toThrow("decision_owner");
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
// ─── Section 2: source consistency (content.constraint_details canonical) ───
|
|
311
|
-
describe("draft-packet — Section 2 source consistency", () => {
|
|
312
|
-
it("Section 2 active count matches content.constraint_details length, not pool.summary.total", () => {
|
|
313
|
-
// pool에 3건 있지만 content에는 2건만 — Section 3에 실제 보이는 수와 일치해야 함
|
|
314
|
-
const e1 = makeEntry("CST-001");
|
|
315
|
-
const e2 = makeEntry("CST-002");
|
|
316
|
-
const e3 = makeEntry("CST-003");
|
|
317
|
-
const state = makeState({ constraint_pool: makePoolWith(e1, e2, e3) });
|
|
318
|
-
const content = makeContent({ constraint_details: [poDet("CST-001"), poDet("CST-002")] });
|
|
319
|
-
const md = renderDraftPacket(state, content);
|
|
320
|
-
expect(md).toContain("아래 2건");
|
|
321
|
-
expect(md).not.toContain("아래 3건");
|
|
322
|
-
});
|
|
323
|
-
it("decided/undecided counts derive from pool lookup of detail ids", () => {
|
|
324
|
-
const e1 = makeEntry("CST-001", { status: "decided", decision: "inject" });
|
|
325
|
-
const e2 = makeEntry("CST-002", { status: "undecided" });
|
|
326
|
-
const state = makeState({ constraint_pool: makePoolWith(e1, e2) });
|
|
327
|
-
const content = makeContent({ constraint_details: [poDet("CST-001"), poDet("CST-002")] });
|
|
328
|
-
const md = renderDraftPacket(state, content);
|
|
329
|
-
expect(md).toContain("1건 결정 완료, 1건 미결정");
|
|
330
|
-
});
|
|
331
|
-
it("clarify_pending detail counts into '미결정' group", () => {
|
|
332
|
-
const e1 = makeEntry("CST-001", { status: "clarify_pending" });
|
|
333
|
-
const state = makeState({ constraint_pool: makePoolWith(e1) });
|
|
334
|
-
const content = makeContent({ constraint_details: [poDet("CST-001")] });
|
|
335
|
-
const md = renderDraftPacket(state, content);
|
|
336
|
-
expect(md).toContain("0건 결정 완료, 1건 미결정");
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
describe("draft-packet — validation (invalidated detail rejection)", () => {
|
|
340
|
-
it("throws when constraint_details references an invalidated constraint", () => {
|
|
341
|
-
const entry = makeEntry("CST-001", { status: "invalidated" });
|
|
342
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
343
|
-
expect(() => renderDraftPacket(state, makeContent({
|
|
344
|
-
constraint_details: [poDet("CST-001")],
|
|
345
|
-
}))).toThrow("invalidated");
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
// ─── requires_policy_change rendering ───
|
|
349
|
-
describe("draft-packet — requires_policy_change", () => {
|
|
350
|
-
it("shows policy tag and callout when requires_policy_change=true", () => {
|
|
351
|
-
const entry = makeEntry("CST-001", { requires_policy_change: true, decision: "inject", status: "decided" });
|
|
352
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
353
|
-
const md = renderDraftPacket(state, makeContent({
|
|
354
|
-
constraint_details: [poDet("CST-001")],
|
|
355
|
-
}));
|
|
356
|
-
expect(md).toContain("[정책 변경 검토 필요]");
|
|
357
|
-
expect(md).toContain("정책 변경 전제");
|
|
358
|
-
expect(md).toContain("requires_policy_change=false");
|
|
359
|
-
});
|
|
360
|
-
it("no policy tag when requires_policy_change is false", () => {
|
|
361
|
-
const entry = makeEntry("CST-001", { requires_policy_change: false });
|
|
362
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
363
|
-
const md = renderDraftPacket(state, makeContent({
|
|
364
|
-
constraint_details: [poDet("CST-001")],
|
|
365
|
-
}));
|
|
366
|
-
expect(md).not.toContain("[정책 변경 검토 필요]");
|
|
367
|
-
expect(md).not.toContain("정책 변경 전제");
|
|
368
|
-
});
|
|
369
|
-
it("no policy tag when requires_policy_change is undefined", () => {
|
|
370
|
-
const entry = makeEntry("CST-001"); // no requires_policy_change
|
|
371
|
-
const state = makeState({ constraint_pool: makePoolWith(entry) });
|
|
372
|
-
const md = renderDraftPacket(state, makeContent({
|
|
373
|
-
constraint_details: [poDet("CST-001")],
|
|
374
|
-
}));
|
|
375
|
-
expect(md).not.toContain("[정책 변경 검토 필요]");
|
|
376
|
-
});
|
|
377
|
-
});
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { isPolicyChangeRequired } from "../../scope-runtime/types.js";
|
|
2
|
-
import { MAX_COMPILE_RETRIES } from "../../scope-runtime/constants.js";
|
|
3
|
-
/**
|
|
4
|
-
* Render scope.md — the current status view of a scope.
|
|
5
|
-
*
|
|
6
|
-
* Pure function: (state) → string.
|
|
7
|
-
* No side effects, no external I/O.
|
|
8
|
-
*/
|
|
9
|
-
export function renderScopeMd(state) {
|
|
10
|
-
const lines = [];
|
|
11
|
-
// ── Header ──
|
|
12
|
-
lines.push(`# Scope: ${state.title}`);
|
|
13
|
-
lines.push("");
|
|
14
|
-
// ── Current stage ──
|
|
15
|
-
lines.push("## 현황");
|
|
16
|
-
lines.push("");
|
|
17
|
-
lines.push(`- **상태**: ${formatState(state.current_state)}`);
|
|
18
|
-
if (state.direction) {
|
|
19
|
-
lines.push(`- **방향**: ${state.direction}`);
|
|
20
|
-
}
|
|
21
|
-
lines.push(`- **마지막 업데이트**: revision ${state.latest_revision}`);
|
|
22
|
-
lines.push("");
|
|
23
|
-
// ── Blockers (only when present) ──
|
|
24
|
-
const blockers = collectBlockers(state);
|
|
25
|
-
if (blockers.length > 0) {
|
|
26
|
-
lines.push("## 차단 상태");
|
|
27
|
-
lines.push("");
|
|
28
|
-
for (const b of blockers) {
|
|
29
|
-
lines.push(`- ${b}`);
|
|
30
|
-
}
|
|
31
|
-
lines.push("");
|
|
32
|
-
}
|
|
33
|
-
// ── Next action ──
|
|
34
|
-
lines.push("## 다음 행동");
|
|
35
|
-
lines.push("");
|
|
36
|
-
lines.push(`- ${formatNextAction(state)}`);
|
|
37
|
-
lines.push("");
|
|
38
|
-
// ── Scope boundaries (if locked) ──
|
|
39
|
-
if (state.scope_boundaries) {
|
|
40
|
-
lines.push("## 범위");
|
|
41
|
-
lines.push("");
|
|
42
|
-
if (state.scope_boundaries.in.length > 0) {
|
|
43
|
-
lines.push("**포함:**");
|
|
44
|
-
for (const item of state.scope_boundaries.in) {
|
|
45
|
-
lines.push(`- ${item}`);
|
|
46
|
-
}
|
|
47
|
-
lines.push("");
|
|
48
|
-
}
|
|
49
|
-
if (state.scope_boundaries.out.length > 0) {
|
|
50
|
-
lines.push("**제외:**");
|
|
51
|
-
for (const item of state.scope_boundaries.out) {
|
|
52
|
-
lines.push(`- ${item}`);
|
|
53
|
-
}
|
|
54
|
-
lines.push("");
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// ── Scanned sources ──
|
|
58
|
-
if (state.grounding_sources && state.grounding_sources.length > 0) {
|
|
59
|
-
lines.push("## 스캔 소스");
|
|
60
|
-
lines.push("");
|
|
61
|
-
for (const src of state.grounding_sources) {
|
|
62
|
-
lines.push(`- \`${src.type}\`: ${src.path_or_url}`);
|
|
63
|
-
}
|
|
64
|
-
lines.push("");
|
|
65
|
-
}
|
|
66
|
-
// ── Constraint summary ──
|
|
67
|
-
const { summary } = state.constraint_pool;
|
|
68
|
-
if (summary.total > 0) {
|
|
69
|
-
lines.push("## Constraint 현황");
|
|
70
|
-
lines.push("");
|
|
71
|
-
lines.push(`- 전체: ${summary.total}건 (필수 ${summary.required}, 권장 ${summary.recommended})`);
|
|
72
|
-
lines.push(`- 결정 완료: ${summary.decided}건`);
|
|
73
|
-
if (summary.undecided > 0) {
|
|
74
|
-
lines.push(`- 미결정: ${summary.undecided}건`);
|
|
75
|
-
}
|
|
76
|
-
if (summary.clarify_pending > 0) {
|
|
77
|
-
lines.push(`- clarify 대기: ${summary.clarify_pending}건`);
|
|
78
|
-
}
|
|
79
|
-
if (summary.invalidated > 0) {
|
|
80
|
-
lines.push(`- 제외됨: ${summary.invalidated}건`);
|
|
81
|
-
}
|
|
82
|
-
const policyChangeCount = state.constraint_pool.constraints.filter(isPolicyChangeRequired).length;
|
|
83
|
-
if (policyChangeCount > 0) {
|
|
84
|
-
lines.push(`- 정책 변경 검토 필요: ${policyChangeCount}건`);
|
|
85
|
-
}
|
|
86
|
-
lines.push("");
|
|
87
|
-
}
|
|
88
|
-
// ── Validation results ──
|
|
89
|
-
if (state.validation_result) {
|
|
90
|
-
const vr = state.validation_result;
|
|
91
|
-
lines.push("## 검증 결과");
|
|
92
|
-
lines.push("");
|
|
93
|
-
lines.push(`- **결과**: ${vr.result === "pass" ? "통과" : "실패"}`);
|
|
94
|
-
lines.push(`- **통과**: ${vr.pass_count}건, **실패**: ${vr.fail_count}건`);
|
|
95
|
-
if (vr.fail_count > 0 && vr.items.length > 0) {
|
|
96
|
-
const failItems = vr.items.filter(i => i.result === "fail");
|
|
97
|
-
for (const item of failItems) {
|
|
98
|
-
lines.push(`- ${item.val_id} (${item.related_cst}): ${item.detail}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
lines.push("");
|
|
102
|
-
}
|
|
103
|
-
// ── Constraint decision details (#8) ──
|
|
104
|
-
const decidedConstraints = state.constraint_pool.constraints.filter(c => c.status === "decided");
|
|
105
|
-
if (decidedConstraints.length > 0) {
|
|
106
|
-
lines.push("<details>");
|
|
107
|
-
lines.push(`<summary>Constraint 결정 상세 (${decidedConstraints.length}건)</summary>`);
|
|
108
|
-
lines.push("");
|
|
109
|
-
lines.push("| CST-ID | 결정 | 선택 |");
|
|
110
|
-
lines.push("|--------|------|------|");
|
|
111
|
-
for (const c of decidedConstraints) {
|
|
112
|
-
lines.push(`| ${c.constraint_id} | ${c.decision ?? "-"} | ${c.selected_option ?? "-"} |`);
|
|
113
|
-
}
|
|
114
|
-
lines.push("");
|
|
115
|
-
lines.push("</details>");
|
|
116
|
-
lines.push("");
|
|
117
|
-
}
|
|
118
|
-
// ── Recent decisions ──
|
|
119
|
-
if (state.verdict_log.length > 0) {
|
|
120
|
-
lines.push("## 최근 결정");
|
|
121
|
-
lines.push("");
|
|
122
|
-
const recent = state.verdict_log.slice(-5);
|
|
123
|
-
for (const entry of recent) {
|
|
124
|
-
lines.push(`- ${formatVerdictEntry(entry)}`);
|
|
125
|
-
}
|
|
126
|
-
lines.push("");
|
|
127
|
-
}
|
|
128
|
-
return lines.join("\n");
|
|
129
|
-
}
|
|
130
|
-
// ─── Helpers ───
|
|
131
|
-
const STATE_LABELS = {
|
|
132
|
-
draft: "초안 (소스 스캔 전)",
|
|
133
|
-
grounded: "소스 스캔 완료",
|
|
134
|
-
exploring: "요구사항 탐색 중",
|
|
135
|
-
align_proposed: "Align Packet 검토 중",
|
|
136
|
-
align_locked: "방향·범위 확정됨",
|
|
137
|
-
surface_iterating: "Surface 반복 수정 중",
|
|
138
|
-
surface_confirmed: "Surface 확정됨 — constraint 결정 필요",
|
|
139
|
-
constraints_resolved: "모든 constraint 결정 완료",
|
|
140
|
-
target_locked: "Target 잠김 — compile 진행 중",
|
|
141
|
-
compiled: "Build Spec 생성 완료",
|
|
142
|
-
applied: "구현 적용 완료 — 검증 대기",
|
|
143
|
-
validated: "검증 통과 — 종료 가능",
|
|
144
|
-
closed: "종료됨",
|
|
145
|
-
deferred: "보류됨",
|
|
146
|
-
rejected: "거절됨",
|
|
147
|
-
};
|
|
148
|
-
function formatState(state) {
|
|
149
|
-
return STATE_LABELS[state] ?? state;
|
|
150
|
-
}
|
|
151
|
-
function formatNextAction(state) {
|
|
152
|
-
if (state.stale) {
|
|
153
|
-
return "소스가 변경되었습니다. 재스캔이 필요합니다 (`/start`를 다시 실행하세요)";
|
|
154
|
-
}
|
|
155
|
-
if (state.convergence_blocked) {
|
|
156
|
-
return "수렴 차단 상태입니다. 다음 중 하나를 선택하세요: (1) 방향 변경 (`/align redirect`) (2) scope 축소 (`/align revise`) (3) scope 보류 (`scope.deferred`)";
|
|
157
|
-
}
|
|
158
|
-
switch (state.current_state) {
|
|
159
|
-
case "draft":
|
|
160
|
-
return "소스를 스캔하세요 (`/start`를 실행하세요)";
|
|
161
|
-
case "grounded":
|
|
162
|
-
return "스캔이 끝났습니다. 대화 에이전트가 주체자에게 선택지 기반 질문으로 방향·범위·제약을 확인한 뒤, 수렴된 답을 bounded evolve runtime input으로 제출하세요. Runtime이 constraint.discovered 이벤트 + align-packet.md + align.proposed 이벤트를 기록합니다.";
|
|
163
|
-
case "exploring": {
|
|
164
|
-
const ep = state.exploration_progress;
|
|
165
|
-
const phaseInfo = ep ? ` (Phase ${ep.current_phase}/6: ${ep.current_phase_name})` : "";
|
|
166
|
-
return `요구사항을 탐색하고 있습니다${phaseInfo}. 질문에 답하여 scope를 구체화하세요`;
|
|
167
|
-
}
|
|
168
|
-
case "align_proposed":
|
|
169
|
-
return "Align Packet을 읽고 방향과 범위를 확정하세요 (승인/수정/거절/재스캔 중 선택)";
|
|
170
|
-
case "align_locked":
|
|
171
|
-
return "방향이 확정되었습니다. 화면 설계를 시작하세요 (`/draft`를 실행하세요)";
|
|
172
|
-
case "surface_iterating":
|
|
173
|
-
return state.entry_mode === "experience"
|
|
174
|
-
? "mockup을 확인하세요 (`cd surface/preview && npm run dev`). 수정이 필요하면 피드백을, 맞으면 '확정합니다'라고 말씀하세요"
|
|
175
|
-
: "API 명세를 확인하세요 (`surface/contract-diff/`). 수정이 필요하면 피드백을, 맞으면 '확정합니다'라고 말씀하세요";
|
|
176
|
-
case "surface_confirmed":
|
|
177
|
-
return state.constraint_pool.summary.undecided > 0
|
|
178
|
-
? `${state.constraint_pool.summary.undecided}건의 제약 사항에 대해 결정이 필요합니다. 각 항목의 선택지를 검토하고 결정하세요`
|
|
179
|
-
: state.constraint_pool.summary.clarify_pending > 0
|
|
180
|
-
? `${state.constraint_pool.summary.clarify_pending}건의 확인이 필요합니다. 외부에서 정보를 확보한 뒤 \`/draft\`를 실행하여 결정을 제출하세요`
|
|
181
|
-
: "모든 결정이 완료되었습니다. 확정을 진행합니다 (`/draft`를 실행하세요)";
|
|
182
|
-
case "constraints_resolved":
|
|
183
|
-
if (state.validation_result?.result === "fail") {
|
|
184
|
-
return "검증에서 실패한 항목이 있습니다. 해당 제약 사항을 재검토한 뒤 다시 구현 명세를 생성하세요 (`/draft`를 실행하세요)";
|
|
185
|
-
}
|
|
186
|
-
if (state.retry_count_compile > 0) {
|
|
187
|
-
return `compile 중 새 제약이 발견되었습니다 (재시도 ${state.retry_count_compile}회). 새 제약에 대해 결정한 뒤 진행하세요 (\`/draft\`를 실행하세요)`;
|
|
188
|
-
}
|
|
189
|
-
return "모든 제약 사항이 해결되었습니다. 구현 명세를 생성합니다 (`/draft`를 실행하세요)";
|
|
190
|
-
case "target_locked":
|
|
191
|
-
return "구현 명세(Build Spec)를 생성하고 있습니다";
|
|
192
|
-
case "compiled":
|
|
193
|
-
return "구현 명세가 완성되었습니다. Builder가 코드를 작성합니다";
|
|
194
|
-
case "applied":
|
|
195
|
-
return "코드 작성이 완료되었습니다. 검증을 진행합니다";
|
|
196
|
-
case "validated":
|
|
197
|
-
return "모든 검증을 통과했습니다. 결과를 확인하시고, 완료하려면 '완료'라고 말씀하세요";
|
|
198
|
-
case "closed":
|
|
199
|
-
return "이 scope는 완료되었습니다";
|
|
200
|
-
case "deferred":
|
|
201
|
-
return "이 scope는 보류 중입니다";
|
|
202
|
-
case "rejected":
|
|
203
|
-
return "이 scope는 거절되었습니다";
|
|
204
|
-
default:
|
|
205
|
-
return `현재 상태: ${state.current_state}`;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
function collectBlockers(state) {
|
|
209
|
-
const blockers = [];
|
|
210
|
-
if (state.stale) {
|
|
211
|
-
const sources = state.stale_sources?.map((s) => s.path).join(", ") ?? "알 수 없음";
|
|
212
|
-
blockers.push(`소스가 변경되었습니다: ${sources} (revision ${state.stale_since ?? "?"}부터)`);
|
|
213
|
-
}
|
|
214
|
-
if (state.convergence_blocked) {
|
|
215
|
-
blockers.push("수렴 차단: revise가 차단되었습니다. 행동을 선택해야 합니다");
|
|
216
|
-
}
|
|
217
|
-
if (state.constraint_pool.summary.clarify_pending > 0) {
|
|
218
|
-
blockers.push(`clarify 미해소: ${state.constraint_pool.summary.clarify_pending}건. 해소 전까지 target 잠금 불가`);
|
|
219
|
-
}
|
|
220
|
-
if (state.current_state === "constraints_resolved" && state.retry_count_compile > 0) {
|
|
221
|
-
blockers.push(`compile 중 새 제약이 발견되어 결정이 필요합니다 (재시도 ${state.retry_count_compile}/${MAX_COMPILE_RETRIES}회)`);
|
|
222
|
-
}
|
|
223
|
-
if (state.last_backward_reason) {
|
|
224
|
-
blockers.push(`이전 단계 복귀 사유: ${state.last_backward_reason}`);
|
|
225
|
-
}
|
|
226
|
-
return blockers;
|
|
227
|
-
}
|
|
228
|
-
function formatVerdictEntry(entry) {
|
|
229
|
-
switch (entry.type) {
|
|
230
|
-
case "align.locked":
|
|
231
|
-
return `rev ${entry.revision}: 방향 확정 — "${entry.locked_direction}"`;
|
|
232
|
-
case "constraint.decision_recorded":
|
|
233
|
-
return `rev ${entry.revision}: ${entry.constraint_id} → ${entry.decision} (${entry.decision_owner})`;
|
|
234
|
-
case "constraint.clarify_resolved":
|
|
235
|
-
return `rev ${entry.revision}: ${entry.constraint_id} clarify 해소 → ${entry.decision} (${entry.decision_owner})`;
|
|
236
|
-
}
|
|
237
|
-
}
|