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,708 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { compile } from "./compile.js";
|
|
3
|
-
import { contentHash } from "../../../../scope-runtime/hash.js";
|
|
4
|
-
// ─── Helpers ───
|
|
5
|
-
function makeEntry(id, overrides = {}) {
|
|
6
|
-
return {
|
|
7
|
-
constraint_id: id, perspective: "code", summary: `summary ${id}`,
|
|
8
|
-
severity: "recommended", discovery_stage: "draft_phase2", decision_owner: "product_owner",
|
|
9
|
-
impact_if_ignored: `impact ${id}`, source_refs: [{ source: "src/test.ts", detail: "d" }],
|
|
10
|
-
evidence_status: "unverified",
|
|
11
|
-
status: "decided", decision: "inject", selected_option: "opt", discovered_at: 1, decided_at: 2,
|
|
12
|
-
...overrides,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function makePool(...entries) {
|
|
16
|
-
let req = 0, rec = 0, dec = 0, inv = 0, cp = 0, und = 0;
|
|
17
|
-
for (const e of entries) {
|
|
18
|
-
if (e.severity === "required")
|
|
19
|
-
req++;
|
|
20
|
-
else
|
|
21
|
-
rec++;
|
|
22
|
-
if (e.status === "decided")
|
|
23
|
-
dec++;
|
|
24
|
-
if (e.status === "invalidated")
|
|
25
|
-
inv++;
|
|
26
|
-
if (e.status === "clarify_pending")
|
|
27
|
-
cp++;
|
|
28
|
-
if (e.status === "undecided")
|
|
29
|
-
und++;
|
|
30
|
-
}
|
|
31
|
-
return { constraints: entries, summary: { total: entries.length, required: req, recommended: rec, decided: dec, clarify_pending: cp, invalidated: inv, undecided: und } };
|
|
32
|
-
}
|
|
33
|
-
function makeState(pool, overrides = {}) {
|
|
34
|
-
return {
|
|
35
|
-
scope_id: "SC-TEST", title: "Test Scope", description: "d", entry_mode: "experience",
|
|
36
|
-
current_state: "target_locked", direction: "test direction",
|
|
37
|
-
scope_boundaries: { in: ["feature A"], out: ["feature B"] },
|
|
38
|
-
surface_hash: "abc123", constraint_pool: pool,
|
|
39
|
-
stale: false, compile_ready: true, convergence_blocked: false,
|
|
40
|
-
revision_count_align: 0, revision_count_surface: 0, retry_count_compile: 0,
|
|
41
|
-
snapshot_revision: 0, pre_apply_completed: false, prd_review_completed: false,
|
|
42
|
-
verdict_log: [], feedback_history: [], latest_revision: 10,
|
|
43
|
-
...overrides,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function makeBrownfield() {
|
|
47
|
-
return {
|
|
48
|
-
related_files: [{ path: "src/app.ts", role: "entry point", detail_anchor: "app-entry" }],
|
|
49
|
-
module_dependencies: [{ module: "app", depends_on: "db", detail_anchor: "dep-app-db" }],
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function makeBrownfieldDetail() {
|
|
53
|
-
return {
|
|
54
|
-
scope_id: "SC-TEST",
|
|
55
|
-
sections: [
|
|
56
|
-
{ anchor: "app-entry", source: "local", title: "app.ts", content: "Entry point of the application" },
|
|
57
|
-
{ anchor: "dep-app-db", source: "local", title: "app → db", content: "App module depends on db module" },
|
|
58
|
-
],
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function makeFullInput(overrides = {}) {
|
|
62
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }), makeEntry("CST-002", { decision: "defer", source_refs: [{ source: "src/other.ts", detail: "d" }] }));
|
|
63
|
-
return {
|
|
64
|
-
state: makeState(pool),
|
|
65
|
-
implementations: [
|
|
66
|
-
{ summary: "Add feature A", related_cst: ["CST-001"], target: "src/feature.ts", detail: "Create file" },
|
|
67
|
-
],
|
|
68
|
-
changes: [
|
|
69
|
-
{ action: "create", file_path: "src/feature.ts", description: "New file", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
70
|
-
],
|
|
71
|
-
brownfield: makeBrownfield(),
|
|
72
|
-
brownfieldDetail: makeBrownfieldDetail(),
|
|
73
|
-
surfaceSummary: "Test scenario summary",
|
|
74
|
-
injectValidations: [
|
|
75
|
-
{ related_cst: "CST-001", target: "feature A", method: "unit test", pass_criteria: "passes", fail_action: "fix", edge_cases: [{ scenario: "empty input", expected_result: "returns error" }] },
|
|
76
|
-
],
|
|
77
|
-
...overrides,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
// ─── Input Validation ───
|
|
81
|
-
describe("compile — input validation", () => {
|
|
82
|
-
it("fails when state is not target_locked", () => {
|
|
83
|
-
const input = makeFullInput({ state: makeState(makePool(), { current_state: "compiled" }) });
|
|
84
|
-
const result = compile(input);
|
|
85
|
-
expect(result.success).toBe(false);
|
|
86
|
-
if (!result.success)
|
|
87
|
-
expect(result.reason).toContain("target_locked");
|
|
88
|
-
});
|
|
89
|
-
it("fails when compile_ready is false", () => {
|
|
90
|
-
const input = makeFullInput({ state: makeState(makePool(), { compile_ready: false }) });
|
|
91
|
-
const result = compile(input);
|
|
92
|
-
expect(result.success).toBe(false);
|
|
93
|
-
if (!result.success)
|
|
94
|
-
expect(result.reason).toContain("compile_ready");
|
|
95
|
-
});
|
|
96
|
-
it("fails when surface_hash is missing", () => {
|
|
97
|
-
const input = makeFullInput({ state: makeState(makePool(), { surface_hash: undefined }) });
|
|
98
|
-
const result = compile(input);
|
|
99
|
-
expect(result.success).toBe(false);
|
|
100
|
-
if (!result.success)
|
|
101
|
-
expect(result.reason).toContain("surface_hash");
|
|
102
|
-
});
|
|
103
|
-
it("fails when direction is missing", () => {
|
|
104
|
-
const input = makeFullInput({ state: makeState(makePool(), { direction: undefined }) });
|
|
105
|
-
const result = compile(input);
|
|
106
|
-
expect(result.success).toBe(false);
|
|
107
|
-
if (!result.success)
|
|
108
|
-
expect(result.reason).toContain("direction");
|
|
109
|
-
});
|
|
110
|
-
it("fails when scope_boundaries is missing", () => {
|
|
111
|
-
const input = makeFullInput({ state: makeState(makePool(), { scope_boundaries: undefined }) });
|
|
112
|
-
const result = compile(input);
|
|
113
|
-
expect(result.success).toBe(false);
|
|
114
|
-
if (!result.success)
|
|
115
|
-
expect(result.reason).toContain("scope_boundaries");
|
|
116
|
-
});
|
|
117
|
-
it("fails when clarify decision exists", () => {
|
|
118
|
-
const pool = makePool(makeEntry("CST-001", { decision: "clarify" }));
|
|
119
|
-
const input = makeFullInput({ state: makeState(pool) });
|
|
120
|
-
const result = compile(input);
|
|
121
|
-
expect(result.success).toBe(false);
|
|
122
|
-
if (!result.success)
|
|
123
|
-
expect(result.reason).toContain("clarify");
|
|
124
|
-
});
|
|
125
|
-
it("fails when modify-direction decision exists", () => {
|
|
126
|
-
const pool = makePool(makeEntry("CST-001", { decision: "modify-direction" }));
|
|
127
|
-
const input = makeFullInput({ state: makeState(pool) });
|
|
128
|
-
const result = compile(input);
|
|
129
|
-
expect(result.success).toBe(false);
|
|
130
|
-
if (!result.success)
|
|
131
|
-
expect(result.reason).toContain("modify-direction");
|
|
132
|
-
});
|
|
133
|
-
it("fails when related_impl_indices is out of range", () => {
|
|
134
|
-
const input = makeFullInput({
|
|
135
|
-
changes: [{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [99], related_cst: ["CST-001"] }],
|
|
136
|
-
});
|
|
137
|
-
const result = compile(input);
|
|
138
|
-
expect(result.success).toBe(false);
|
|
139
|
-
if (!result.success)
|
|
140
|
-
expect(result.reason).toContain("invalid index");
|
|
141
|
-
});
|
|
142
|
-
it("fails when inject constraint has no validation", () => {
|
|
143
|
-
const input = makeFullInput({ injectValidations: [] });
|
|
144
|
-
const result = compile(input);
|
|
145
|
-
expect(result.success).toBe(false);
|
|
146
|
-
if (!result.success)
|
|
147
|
-
expect(result.reason).toContain("CST-001");
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
// ─── ID Assignment ───
|
|
151
|
-
describe("compile — ID assignment", () => {
|
|
152
|
-
it("assigns sequential IMPL IDs", () => {
|
|
153
|
-
const input = makeFullInput({
|
|
154
|
-
implementations: [
|
|
155
|
-
{ summary: "A", related_cst: ["CST-001"], target: "a.ts", detail: "d" },
|
|
156
|
-
{ summary: "B", related_cst: ["CST-001"], target: "b.ts", detail: "d" },
|
|
157
|
-
],
|
|
158
|
-
changes: [
|
|
159
|
-
{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
160
|
-
{ action: "create", file_path: "b.ts", description: "d", related_impl_indices: [1], related_cst: ["CST-001"] },
|
|
161
|
-
],
|
|
162
|
-
});
|
|
163
|
-
const result = compile(input);
|
|
164
|
-
expect(result.success).toBe(true);
|
|
165
|
-
if (result.success) {
|
|
166
|
-
expect(result.buildSpecData.section4.map((s) => s.impl_id)).toEqual(["IMPL-001", "IMPL-002"]);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
it("assigns sequential CHG IDs", () => {
|
|
170
|
-
const input = makeFullInput();
|
|
171
|
-
const result = compile(input);
|
|
172
|
-
expect(result.success).toBe(true);
|
|
173
|
-
if (result.success) {
|
|
174
|
-
expect(result.deltaSet.changes.map((c) => c.change_id)).toEqual(["CHG-001"]);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
it("maps related_impl_indices to IMPL IDs", () => {
|
|
178
|
-
const input = makeFullInput();
|
|
179
|
-
const result = compile(input);
|
|
180
|
-
expect(result.success).toBe(true);
|
|
181
|
-
if (result.success) {
|
|
182
|
-
expect(result.deltaSet.changes[0].related_impl).toEqual(["IMPL-001"]);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
it("assigns sequential VAL IDs (inject first, then defer)", () => {
|
|
186
|
-
const input = makeFullInput();
|
|
187
|
-
const result = compile(input);
|
|
188
|
-
expect(result.success).toBe(true);
|
|
189
|
-
if (result.success) {
|
|
190
|
-
expect(result.validationPlan.map((v) => v.val_id)).toEqual(["VAL-001", "VAL-002"]);
|
|
191
|
-
expect(result.validationPlan[0].decision_type).toBe("inject");
|
|
192
|
-
expect(result.validationPlan[1].decision_type).toBe("defer");
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
// ─── Defense Integration ───
|
|
197
|
-
describe("compile — defense integration", () => {
|
|
198
|
-
it("fails when inject has no IMPL", () => {
|
|
199
|
-
const input = makeFullInput({ implementations: [], changes: [] });
|
|
200
|
-
const result = compile(input);
|
|
201
|
-
expect(result.success).toBe(false);
|
|
202
|
-
if (!result.success) {
|
|
203
|
-
// validateInput catches missing CHG/IMPL before compile-defense runs
|
|
204
|
-
expect(result.reason).toContain("inject constraint");
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
it("passes with valid full input", () => {
|
|
208
|
-
const result = compile(makeFullInput());
|
|
209
|
-
expect(result.success).toBe(true);
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
// ─── Markdown Structure ───
|
|
213
|
-
describe("compile — Build Spec markdown", () => {
|
|
214
|
-
it("contains all 7 section headers", () => {
|
|
215
|
-
const result = compile(makeFullInput());
|
|
216
|
-
expect(result.success).toBe(true);
|
|
217
|
-
if (!result.success)
|
|
218
|
-
return;
|
|
219
|
-
const md = result.buildSpecMd;
|
|
220
|
-
expect(md).toContain("## 1. Scope Summary");
|
|
221
|
-
expect(md).toContain("## 2. Confirmed Surface");
|
|
222
|
-
expect(md).toContain("## 3. Constraint Decision Map");
|
|
223
|
-
expect(md).toContain("## 4. Implementation Plan");
|
|
224
|
-
expect(md).toContain("## 5. Delta Set Reference");
|
|
225
|
-
expect(md).toContain("## 6. Validation Plan Reference");
|
|
226
|
-
expect(md).toContain("## 7. Brownfield Context");
|
|
227
|
-
});
|
|
228
|
-
it("includes scope info in Section 1", () => {
|
|
229
|
-
const result = compile(makeFullInput());
|
|
230
|
-
expect(result.buildSpecMd).toContain("SC-TEST");
|
|
231
|
-
expect(result.buildSpecMd).toContain("test direction");
|
|
232
|
-
expect(result.buildSpecMd).toContain("feature A");
|
|
233
|
-
});
|
|
234
|
-
it("includes all CST-IDs in Section 3", () => {
|
|
235
|
-
const result = compile(makeFullInput());
|
|
236
|
-
expect(result.buildSpecMd).toContain("CST-001");
|
|
237
|
-
expect(result.buildSpecMd).toContain("CST-002");
|
|
238
|
-
});
|
|
239
|
-
it("includes IMPL details in Section 4", () => {
|
|
240
|
-
const result = compile(makeFullInput());
|
|
241
|
-
expect(result.buildSpecMd).toContain("IMPL-001");
|
|
242
|
-
expect(result.buildSpecMd).toContain("Add feature A");
|
|
243
|
-
});
|
|
244
|
-
it("test files in brownfield are rendered as Tier 2 (collapsed)", () => {
|
|
245
|
-
const brownfield = {
|
|
246
|
-
related_files: [
|
|
247
|
-
{ path: "src/app.ts", role: "typescript (local)", detail_anchor: "app-entry" },
|
|
248
|
-
{ path: "src/app.test.ts", role: "test (local)", detail_anchor: "app-test" },
|
|
249
|
-
],
|
|
250
|
-
module_dependencies: [],
|
|
251
|
-
};
|
|
252
|
-
const result = compile(makeFullInput({ brownfield }));
|
|
253
|
-
// Non-test file is in Tier 1 (always visible)
|
|
254
|
-
expect(result.buildSpecMd).toContain("### 변경 대상 파일 (1건)");
|
|
255
|
-
expect(result.buildSpecMd).toContain("src/app.ts");
|
|
256
|
-
// Test file is in Tier 2 (collapsed <details>)
|
|
257
|
-
expect(result.buildSpecMd).toContain("<summary>테스트 파일 (1건)</summary>");
|
|
258
|
-
expect(result.buildSpecMd).toContain("src/app.test.ts");
|
|
259
|
-
});
|
|
260
|
-
it("Tier 1 items are always visible, Tier 2 uses <details>", () => {
|
|
261
|
-
const brownfield = {
|
|
262
|
-
related_files: [{ path: "src/app.ts", role: "entry", detail_anchor: "app-entry" }],
|
|
263
|
-
module_dependencies: [{ module: "app", depends_on: "db", detail_anchor: "dep-app-db" }],
|
|
264
|
-
api_contracts: [{ endpoint: "/api/test", method: "GET", description: "test", detail_anchor: "api-test" }],
|
|
265
|
-
};
|
|
266
|
-
const result = compile(makeFullInput({ brownfield }));
|
|
267
|
-
// Tier 1: always visible (no <details> wrapping)
|
|
268
|
-
expect(result.buildSpecMd).toContain("### 변경 대상 파일");
|
|
269
|
-
expect(result.buildSpecMd).toContain("### 직접 의존 모듈");
|
|
270
|
-
// Tier 2: collapsed with <details>
|
|
271
|
-
expect(result.buildSpecMd).toContain("<details>");
|
|
272
|
-
expect(result.buildSpecMd).toContain("API 계약");
|
|
273
|
-
// detail reference links
|
|
274
|
-
expect(result.buildSpecMd).toContain("[→ 상세](brownfield-detail.md#app-entry)");
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
describe("compile — validation-plan markdown", () => {
|
|
278
|
-
it("contains VAL headers with correct format", () => {
|
|
279
|
-
const result = compile(makeFullInput());
|
|
280
|
-
expect(result.validationPlanMd).toContain("### VAL-001 | CST-001 | inject");
|
|
281
|
-
expect(result.validationPlanMd).toContain("### VAL-002 | CST-002 | defer");
|
|
282
|
-
});
|
|
283
|
-
it("includes all 4 required fields per VAL", () => {
|
|
284
|
-
const result = compile(makeFullInput());
|
|
285
|
-
expect(result.validationPlanMd).toContain("**검증 대상:**");
|
|
286
|
-
expect(result.validationPlanMd).toContain("**검증 방법:**");
|
|
287
|
-
expect(result.validationPlanMd).toContain("**통과 조건:**");
|
|
288
|
-
expect(result.validationPlanMd).toContain("**실패 시 조치:**");
|
|
289
|
-
});
|
|
290
|
-
it("auto-generates defer VAL with source_refs", () => {
|
|
291
|
-
const result = compile(makeFullInput());
|
|
292
|
-
const deferVal = result.validationPlan.find((v) => v.decision_type === "defer");
|
|
293
|
-
expect(deferVal).toBeDefined();
|
|
294
|
-
expect(deferVal.method).toContain("src/other.ts");
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
describe("compile — delta-set JSON", () => {
|
|
298
|
-
it("produces valid JSON", () => {
|
|
299
|
-
const result = compile(makeFullInput());
|
|
300
|
-
const parsed = JSON.parse(result.deltaSetJson);
|
|
301
|
-
expect(parsed.scope_id).toBe("SC-TEST");
|
|
302
|
-
expect(parsed.changes).toHaveLength(1);
|
|
303
|
-
});
|
|
304
|
-
it("includes surface_hash and build_spec_hash", () => {
|
|
305
|
-
const result = compile(makeFullInput());
|
|
306
|
-
expect(result.deltaSet.surface_hash).toBe("abc123");
|
|
307
|
-
expect(result.deltaSet.build_spec_hash).toBeTruthy();
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
// ─── Hash Integrity ───
|
|
311
|
-
describe("compile — hash integrity", () => {
|
|
312
|
-
it("buildSpecHash matches contentHash(buildSpecMd)", () => {
|
|
313
|
-
const result = compile(makeFullInput());
|
|
314
|
-
expect(result.buildSpecHash).toBe(contentHash(result.buildSpecMd));
|
|
315
|
-
});
|
|
316
|
-
it("deltaSetHash matches contentHash(deltaSetJson)", () => {
|
|
317
|
-
const result = compile(makeFullInput());
|
|
318
|
-
expect(result.deltaSetHash).toBe(contentHash(result.deltaSetJson));
|
|
319
|
-
});
|
|
320
|
-
it("validationPlanHash matches contentHash(validationPlanMd)", () => {
|
|
321
|
-
const result = compile(makeFullInput());
|
|
322
|
-
expect(result.validationPlanHash).toBe(contentHash(result.validationPlanMd));
|
|
323
|
-
});
|
|
324
|
-
it("delta-set.build_spec_hash is non-empty", () => {
|
|
325
|
-
const result = compile(makeFullInput());
|
|
326
|
-
expect(result.deltaSet.build_spec_hash.length).toBeGreaterThan(0);
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
// ─── Edge Cases ───
|
|
330
|
-
describe("compile — edge cases", () => {
|
|
331
|
-
it("handles override constraint with auto-generated VAL", () => {
|
|
332
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }), makeEntry("CST-002", { decision: "override", source_refs: [{ source: "src/policy.ts", detail: "d" }] }));
|
|
333
|
-
const input = makeFullInput({
|
|
334
|
-
state: makeState(pool),
|
|
335
|
-
injectValidations: [
|
|
336
|
-
{ related_cst: "CST-001", target: "t", method: "m", pass_criteria: "p", fail_action: "f", edge_cases: [{ scenario: "null input", expected_result: "error" }] },
|
|
337
|
-
],
|
|
338
|
-
});
|
|
339
|
-
const result = compile(input);
|
|
340
|
-
expect(result.success).toBe(true);
|
|
341
|
-
if (result.success) {
|
|
342
|
-
const overrideVal = result.validationPlan.find((v) => v.decision_type === "override");
|
|
343
|
-
expect(overrideVal).toBeDefined();
|
|
344
|
-
expect(overrideVal.method).toContain("src/policy.ts");
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
it("handles invalidated constraint (excluded from defense, included in markdown)", () => {
|
|
348
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }), makeEntry("CST-INV", { status: "invalidated", decision: undefined, invalidation_reason: "direction changed" }));
|
|
349
|
-
const input = makeFullInput({ state: makeState(pool) });
|
|
350
|
-
const result = compile(input);
|
|
351
|
-
expect(result.success).toBe(true);
|
|
352
|
-
if (result.success) {
|
|
353
|
-
expect(result.buildSpecMd).toContain("CST-INV");
|
|
354
|
-
expect(result.buildSpecMd).toContain("direction changed");
|
|
355
|
-
// Defense section3 should NOT include invalidated
|
|
356
|
-
expect(result.buildSpecData.section3.find((s) => s.constraint_id === "CST-INV")).toBeUndefined();
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
it("handles multiple implementations for one constraint", () => {
|
|
360
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }));
|
|
361
|
-
const input = {
|
|
362
|
-
state: makeState(pool),
|
|
363
|
-
implementations: [
|
|
364
|
-
{ summary: "Impl A", related_cst: ["CST-001"], target: "a.ts", detail: "d" },
|
|
365
|
-
{ summary: "Impl B", related_cst: ["CST-001"], target: "b.ts", detail: "d" },
|
|
366
|
-
],
|
|
367
|
-
changes: [
|
|
368
|
-
{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
369
|
-
{ action: "modify", file_path: "b.ts", description: "d", related_impl_indices: [1], related_cst: ["CST-001"] },
|
|
370
|
-
],
|
|
371
|
-
brownfield: makeBrownfield(),
|
|
372
|
-
brownfieldDetail: makeBrownfieldDetail(),
|
|
373
|
-
surfaceSummary: "s",
|
|
374
|
-
injectValidations: [
|
|
375
|
-
{ related_cst: "CST-001", target: "t", method: "m", pass_criteria: "p", fail_action: "f", edge_cases: [{ scenario: "null input", expected_result: "error" }] },
|
|
376
|
-
],
|
|
377
|
-
};
|
|
378
|
-
const result = compile(input);
|
|
379
|
-
expect(result.success).toBe(true);
|
|
380
|
-
if (result.success) {
|
|
381
|
-
expect(result.deltaSet.changes).toHaveLength(2);
|
|
382
|
-
expect(result.buildSpecData.section4).toHaveLength(2);
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
it("is deterministic — same input produces same output", () => {
|
|
386
|
-
const input = makeFullInput();
|
|
387
|
-
const r1 = compile(input);
|
|
388
|
-
const r2 = compile(input);
|
|
389
|
-
expect(r1.buildSpecHash).toBe(r2.buildSpecHash);
|
|
390
|
-
expect(r1.deltaSetHash).toBe(r2.deltaSetHash);
|
|
391
|
-
expect(r1.validationPlanHash).toBe(r2.validationPlanHash);
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
// ─── Additional Edge Cases ───
|
|
395
|
-
describe("compile — additional edge cases", () => {
|
|
396
|
-
it("all defer constraints: no IMPL, defer-only validation plan", () => {
|
|
397
|
-
const pool = makePool(makeEntry("CST-001", { decision: "defer", source_refs: [{ source: "src/a.ts", detail: "d" }] }), makeEntry("CST-002", { decision: "defer", source_refs: [{ source: "src/b.ts", detail: "d" }] }));
|
|
398
|
-
const input = makeFullInput({
|
|
399
|
-
state: makeState(pool),
|
|
400
|
-
implementations: [],
|
|
401
|
-
changes: [],
|
|
402
|
-
injectValidations: [],
|
|
403
|
-
});
|
|
404
|
-
const result = compile(input);
|
|
405
|
-
expect(result.success).toBe(true);
|
|
406
|
-
if (result.success) {
|
|
407
|
-
expect(result.validationPlan).toHaveLength(2);
|
|
408
|
-
expect(result.validationPlan.every((v) => v.decision_type === "defer")).toBe(true);
|
|
409
|
-
expect(result.buildSpecMd).toContain("구현 항목 없음");
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
it("all override constraints: override-only validation plan", () => {
|
|
413
|
-
const pool = makePool(makeEntry("CST-001", { decision: "override", source_refs: [{ source: "a.ts", detail: "d" }] }));
|
|
414
|
-
const input = makeFullInput({
|
|
415
|
-
state: makeState(pool),
|
|
416
|
-
implementations: [],
|
|
417
|
-
changes: [],
|
|
418
|
-
injectValidations: [],
|
|
419
|
-
});
|
|
420
|
-
const result = compile(input);
|
|
421
|
-
expect(result.success).toBe(true);
|
|
422
|
-
if (result.success) {
|
|
423
|
-
expect(result.validationPlan).toHaveLength(1);
|
|
424
|
-
expect(result.validationPlan[0].decision_type).toBe("override");
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
it("brownfield with all optional sections", () => {
|
|
428
|
-
const brownfield = {
|
|
429
|
-
related_files: [{ path: "src/app.ts", role: "entry", detail_anchor: "app-entry" }],
|
|
430
|
-
module_dependencies: [{ module: "app", depends_on: "db", detail_anchor: "dep-app-db" }],
|
|
431
|
-
api_contracts: [{ endpoint: "/api/test", method: "GET", description: "test endpoint", detail_anchor: "api-test" }],
|
|
432
|
-
db_schemas: [{ table: "users", columns: "id, name", detail_anchor: "schema-users" }],
|
|
433
|
-
config_env: [{ key: "DB_URL", description: "database connection", detail_anchor: "config-db-url" }],
|
|
434
|
-
};
|
|
435
|
-
const input = makeFullInput({ brownfield });
|
|
436
|
-
const result = compile(input);
|
|
437
|
-
expect(result.success).toBe(true);
|
|
438
|
-
if (result.success) {
|
|
439
|
-
expect(result.buildSpecMd).toContain("API 계약");
|
|
440
|
-
expect(result.buildSpecMd).toContain("DB 스키마");
|
|
441
|
-
expect(result.buildSpecMd).toContain("설정/환경 변수");
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
it("empty brownfield fields", () => {
|
|
445
|
-
const brownfield = {
|
|
446
|
-
related_files: [],
|
|
447
|
-
module_dependencies: [],
|
|
448
|
-
};
|
|
449
|
-
const input = makeFullInput({ brownfield });
|
|
450
|
-
const result = compile(input);
|
|
451
|
-
expect(result.success).toBe(true);
|
|
452
|
-
if (result.success) {
|
|
453
|
-
const section7Start = result.buildSpecMd.indexOf("## 7. Brownfield Context");
|
|
454
|
-
const section7Content = result.buildSpecMd.slice(section7Start);
|
|
455
|
-
expect(section7Content).not.toContain("<details>");
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
it("interface entry_mode uses contract-diff path", () => {
|
|
459
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }));
|
|
460
|
-
const input = makeFullInput({
|
|
461
|
-
state: makeState(pool, { entry_mode: "interface" }),
|
|
462
|
-
});
|
|
463
|
-
const result = compile(input);
|
|
464
|
-
expect(result.success).toBe(true);
|
|
465
|
-
if (result.success) {
|
|
466
|
-
expect(result.buildSpecMd).toContain("surface/contract-diff/");
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
it("3+ invalidated shows collapsible details", () => {
|
|
470
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }), makeEntry("CST-INV1", { status: "invalidated", decision: undefined, invalidation_reason: "r1" }), makeEntry("CST-INV2", { status: "invalidated", decision: undefined, invalidation_reason: "r2" }), makeEntry("CST-INV3", { status: "invalidated", decision: undefined, invalidation_reason: "r3" }));
|
|
471
|
-
const input = makeFullInput({ state: makeState(pool) });
|
|
472
|
-
const result = compile(input);
|
|
473
|
-
expect(result.success).toBe(true);
|
|
474
|
-
if (result.success) {
|
|
475
|
-
expect(result.buildSpecMd).toContain("<details>");
|
|
476
|
-
expect(result.buildSpecMd).toContain("무효화된 항목 (3건)");
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
it("exactly 2 invalidated shows plain list", () => {
|
|
480
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }), makeEntry("CST-INV1", { status: "invalidated", decision: undefined, invalidation_reason: "r1" }), makeEntry("CST-INV2", { status: "invalidated", decision: undefined, invalidation_reason: "r2" }));
|
|
481
|
-
const input = makeFullInput({ state: makeState(pool) });
|
|
482
|
-
const result = compile(input);
|
|
483
|
-
expect(result.success).toBe(true);
|
|
484
|
-
if (result.success) {
|
|
485
|
-
const section3Start = result.buildSpecMd.indexOf("## 3. Constraint Decision Map");
|
|
486
|
-
const section4Start = result.buildSpecMd.indexOf("## 4. Implementation Plan");
|
|
487
|
-
const section3Content = result.buildSpecMd.slice(section3Start, section4Start);
|
|
488
|
-
expect(section3Content).toContain("무효화된 항목:");
|
|
489
|
-
expect(section3Content).not.toContain("<details>");
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
it("multiple injectValidations for same CST produces multiple VALs", () => {
|
|
493
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }), makeEntry("CST-002", { decision: "inject" }));
|
|
494
|
-
const input = makeFullInput({
|
|
495
|
-
state: makeState(pool),
|
|
496
|
-
implementations: [
|
|
497
|
-
{ summary: "A", related_cst: ["CST-001"], target: "a.ts", detail: "d" },
|
|
498
|
-
{ summary: "B", related_cst: ["CST-002"], target: "b.ts", detail: "d" },
|
|
499
|
-
],
|
|
500
|
-
changes: [
|
|
501
|
-
{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
502
|
-
{ action: "create", file_path: "b.ts", description: "d", related_impl_indices: [1], related_cst: ["CST-002"] },
|
|
503
|
-
],
|
|
504
|
-
injectValidations: [
|
|
505
|
-
{ related_cst: "CST-001", target: "t1", method: "m1", pass_criteria: "p1", fail_action: "f1", edge_cases: [{ scenario: "null", expected_result: "error" }] },
|
|
506
|
-
{ related_cst: "CST-002", target: "t2", method: "m2", pass_criteria: "p2", fail_action: "f2", edge_cases: [{ scenario: "null", expected_result: "error" }] },
|
|
507
|
-
],
|
|
508
|
-
});
|
|
509
|
-
const result = compile(input);
|
|
510
|
-
expect(result.success).toBe(true);
|
|
511
|
-
if (result.success) {
|
|
512
|
-
const injectVals = result.validationPlan.filter(v => v.decision_type === "inject");
|
|
513
|
-
expect(injectVals).toHaveLength(2);
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
it("implementation with depends_on shows in Section 4", () => {
|
|
517
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }));
|
|
518
|
-
const input = makeFullInput({
|
|
519
|
-
state: makeState(pool),
|
|
520
|
-
implementations: [
|
|
521
|
-
{ summary: "Base", related_cst: ["CST-001"], target: "base.ts", detail: "base detail" },
|
|
522
|
-
{ summary: "Derived", related_cst: ["CST-001"], target: "derived.ts", detail: "derived detail", depends_on: ["IMPL-001"] },
|
|
523
|
-
],
|
|
524
|
-
changes: [
|
|
525
|
-
{ action: "create", file_path: "base.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
526
|
-
{ action: "create", file_path: "derived.ts", description: "d", related_impl_indices: [1], related_cst: ["CST-001"] },
|
|
527
|
-
],
|
|
528
|
-
});
|
|
529
|
-
const result = compile(input);
|
|
530
|
-
expect(result.success).toBe(true);
|
|
531
|
-
if (result.success) {
|
|
532
|
-
expect(result.buildSpecMd).toContain("**의존성:** IMPL-001");
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
it("implementation with guardrail shows in Section 4", () => {
|
|
536
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }));
|
|
537
|
-
const input = makeFullInput({
|
|
538
|
-
state: makeState(pool),
|
|
539
|
-
implementations: [
|
|
540
|
-
{ summary: "A", related_cst: ["CST-001"], target: "a.ts", detail: "d", guardrail: "API 호환 유지" },
|
|
541
|
-
],
|
|
542
|
-
changes: [
|
|
543
|
-
{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
544
|
-
],
|
|
545
|
-
});
|
|
546
|
-
const result = compile(input);
|
|
547
|
-
expect(result.success).toBe(true);
|
|
548
|
-
if (result.success) {
|
|
549
|
-
expect(result.buildSpecMd).toContain("**guardrail:** API 호환 유지");
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
it("implementation with assumptions shows in Section 4", () => {
|
|
553
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }));
|
|
554
|
-
const input = makeFullInput({
|
|
555
|
-
state: makeState(pool),
|
|
556
|
-
implementations: [
|
|
557
|
-
{ summary: "A", related_cst: ["CST-001"], target: "a.ts", detail: "d", assumptions: ["DB 스키마 변경 없음", "API 하위 호환 유지"] },
|
|
558
|
-
],
|
|
559
|
-
changes: [
|
|
560
|
-
{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
561
|
-
],
|
|
562
|
-
});
|
|
563
|
-
const result = compile(input);
|
|
564
|
-
expect(result.success).toBe(true);
|
|
565
|
-
if (result.success) {
|
|
566
|
-
expect(result.buildSpecMd).toContain("**전제 가정:**");
|
|
567
|
-
expect(result.buildSpecMd).toContain("DB 스키마 변경 없음");
|
|
568
|
-
expect(result.buildSpecMd).toContain("API 하위 호환 유지");
|
|
569
|
-
}
|
|
570
|
-
});
|
|
571
|
-
it("implementation without assumptions does not render assumptions section", () => {
|
|
572
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }));
|
|
573
|
-
const input = makeFullInput({
|
|
574
|
-
state: makeState(pool),
|
|
575
|
-
implementations: [
|
|
576
|
-
{ summary: "A", related_cst: ["CST-001"], target: "a.ts", detail: "d" },
|
|
577
|
-
],
|
|
578
|
-
changes: [
|
|
579
|
-
{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
580
|
-
],
|
|
581
|
-
});
|
|
582
|
-
const result = compile(input);
|
|
583
|
-
expect(result.success).toBe(true);
|
|
584
|
-
if (result.success) {
|
|
585
|
-
expect(result.buildSpecMd).not.toContain("**전제 가정:**");
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
it("Section 5 action counts format (create 2건 + modify 3건)", () => {
|
|
589
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }));
|
|
590
|
-
const input = makeFullInput({
|
|
591
|
-
state: makeState(pool),
|
|
592
|
-
implementations: [
|
|
593
|
-
{ summary: "A", related_cst: ["CST-001"], target: "a.ts", detail: "d" },
|
|
594
|
-
],
|
|
595
|
-
changes: [
|
|
596
|
-
{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
597
|
-
{ action: "create", file_path: "b.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
598
|
-
{ action: "modify", file_path: "c.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
599
|
-
{ action: "modify", file_path: "d.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
600
|
-
{ action: "modify", file_path: "e.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
601
|
-
],
|
|
602
|
-
});
|
|
603
|
-
const result = compile(input);
|
|
604
|
-
expect(result.success).toBe(true);
|
|
605
|
-
if (result.success) {
|
|
606
|
-
expect(result.buildSpecMd).toContain("create 2건");
|
|
607
|
-
expect(result.buildSpecMd).toContain("modify 3건");
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
|
-
it("Section 5 with only delete actions shows delete count", () => {
|
|
611
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject" }));
|
|
612
|
-
const input = makeFullInput({
|
|
613
|
-
state: makeState(pool),
|
|
614
|
-
implementations: [
|
|
615
|
-
{ summary: "A", related_cst: ["CST-001"], target: "a.ts", detail: "d" },
|
|
616
|
-
],
|
|
617
|
-
changes: [
|
|
618
|
-
{ action: "delete", file_path: "old.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] },
|
|
619
|
-
],
|
|
620
|
-
});
|
|
621
|
-
const result = compile(input);
|
|
622
|
-
expect(result.success).toBe(true);
|
|
623
|
-
if (result.success) {
|
|
624
|
-
expect(result.buildSpecMd).toContain("delete 1건");
|
|
625
|
-
}
|
|
626
|
-
});
|
|
627
|
-
it("defer with multiple source_refs", () => {
|
|
628
|
-
const pool = makePool(makeEntry("CST-001", {
|
|
629
|
-
decision: "defer",
|
|
630
|
-
source_refs: [{ source: "a.ts", detail: "d" }, { source: "b.ts", detail: "d" }],
|
|
631
|
-
}));
|
|
632
|
-
const input = makeFullInput({
|
|
633
|
-
state: makeState(pool),
|
|
634
|
-
implementations: [],
|
|
635
|
-
changes: [],
|
|
636
|
-
injectValidations: [],
|
|
637
|
-
});
|
|
638
|
-
const result = compile(input);
|
|
639
|
-
expect(result.success).toBe(true);
|
|
640
|
-
if (result.success) {
|
|
641
|
-
const deferVal = result.validationPlan.find((v) => v.decision_type === "defer");
|
|
642
|
-
expect(deferVal).toBeDefined();
|
|
643
|
-
expect(deferVal.method).toContain("a.ts");
|
|
644
|
-
expect(deferVal.method).toContain("b.ts");
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
});
|
|
648
|
-
// ─── requires_policy_change rendering ───
|
|
649
|
-
describe("compile — requires_policy_change output", () => {
|
|
650
|
-
it("Section 3 shows policy change warning for inject + requires_policy_change", () => {
|
|
651
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject", requires_policy_change: true, evidence_note: "정책 변경 근거" }));
|
|
652
|
-
const input = makeFullInput({
|
|
653
|
-
state: makeState(pool),
|
|
654
|
-
implementations: [{ summary: "feat", related_cst: ["CST-001"], target: "t", detail: "d" }],
|
|
655
|
-
changes: [{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] }],
|
|
656
|
-
injectValidations: [{ related_cst: "CST-001", target: "t", method: "m", pass_criteria: "p", fail_action: "f", edge_cases: [{ scenario: "s", expected_result: "r" }] }],
|
|
657
|
-
});
|
|
658
|
-
const result = compile(input);
|
|
659
|
-
expect(result.success).toBe(true);
|
|
660
|
-
if (result.success) {
|
|
661
|
-
expect(result.buildSpecMd).toContain("정책 변경 검토 필요");
|
|
662
|
-
expect(result.buildSpecMd).toContain("CST-001");
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
it("decisionTreatment appends [정책 변경 검토 필요] for inject + requires_policy_change", () => {
|
|
666
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject", requires_policy_change: true }));
|
|
667
|
-
const input = makeFullInput({
|
|
668
|
-
state: makeState(pool),
|
|
669
|
-
implementations: [{ summary: "feat", related_cst: ["CST-001"], target: "t", detail: "d" }],
|
|
670
|
-
changes: [{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] }],
|
|
671
|
-
injectValidations: [{ related_cst: "CST-001", target: "t", method: "m", pass_criteria: "p", fail_action: "f", edge_cases: [{ scenario: "s", expected_result: "r" }] }],
|
|
672
|
-
});
|
|
673
|
-
const result = compile(input);
|
|
674
|
-
expect(result.success).toBe(true);
|
|
675
|
-
if (result.success) {
|
|
676
|
-
expect(result.buildSpecMd).toContain("[정책 변경 검토 필요]");
|
|
677
|
-
}
|
|
678
|
-
});
|
|
679
|
-
it("validation plan shows policy warning for inject + requires_policy_change", () => {
|
|
680
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject", requires_policy_change: true }));
|
|
681
|
-
const input = makeFullInput({
|
|
682
|
-
state: makeState(pool),
|
|
683
|
-
implementations: [{ summary: "feat", related_cst: ["CST-001"], target: "t", detail: "d" }],
|
|
684
|
-
changes: [{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] }],
|
|
685
|
-
injectValidations: [{ related_cst: "CST-001", target: "t", method: "m", pass_criteria: "p", fail_action: "f", edge_cases: [{ scenario: "s", expected_result: "r" }] }],
|
|
686
|
-
});
|
|
687
|
-
const result = compile(input);
|
|
688
|
-
expect(result.success).toBe(true);
|
|
689
|
-
if (result.success) {
|
|
690
|
-
expect(result.validationPlanMd).toContain("정책 변경 전제");
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
it("no policy warning when requires_policy_change is false", () => {
|
|
694
|
-
const pool = makePool(makeEntry("CST-001", { decision: "inject", requires_policy_change: false }));
|
|
695
|
-
const input = makeFullInput({
|
|
696
|
-
state: makeState(pool),
|
|
697
|
-
implementations: [{ summary: "feat", related_cst: ["CST-001"], target: "t", detail: "d" }],
|
|
698
|
-
changes: [{ action: "create", file_path: "a.ts", description: "d", related_impl_indices: [0], related_cst: ["CST-001"] }],
|
|
699
|
-
injectValidations: [{ related_cst: "CST-001", target: "t", method: "m", pass_criteria: "p", fail_action: "f", edge_cases: [{ scenario: "s", expected_result: "r" }] }],
|
|
700
|
-
});
|
|
701
|
-
const result = compile(input);
|
|
702
|
-
expect(result.success).toBe(true);
|
|
703
|
-
if (result.success) {
|
|
704
|
-
expect(result.buildSpecMd).not.toContain("정책 변경 검토 필요");
|
|
705
|
-
expect(result.validationPlanMd).not.toContain("정책 변경 전제");
|
|
706
|
-
}
|
|
707
|
-
});
|
|
708
|
-
});
|