onto-mcp 0.3.2 → 0.4.1
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 +149 -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 +174 -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 +214 -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,564 +0,0 @@
|
|
|
1
|
-
import { formatPerspective, isPolicyChangeRequired, } from "../../../../scope-runtime/types.js";
|
|
2
|
-
import { contentHash } from "../../../../scope-runtime/hash.js";
|
|
3
|
-
import { makeId } from "../../../../scope-runtime/id.js";
|
|
4
|
-
import { compileDefense, } from "./compile-defense.js";
|
|
5
|
-
// ─── Main ───
|
|
6
|
-
/**
|
|
7
|
-
* Compile confirmed scope into Build Spec + delta-set + validation-plan.
|
|
8
|
-
*
|
|
9
|
-
* Pure function: no side effects, no file I/O, no event recording.
|
|
10
|
-
* The caller (agent protocol) is responsible for saving files and recording events.
|
|
11
|
-
*/
|
|
12
|
-
export function compile(input) {
|
|
13
|
-
// Step 1: Input validation
|
|
14
|
-
const validationError = validateInput(input);
|
|
15
|
-
if (validationError) {
|
|
16
|
-
return { success: false, reason: validationError };
|
|
17
|
-
}
|
|
18
|
-
const { state } = input;
|
|
19
|
-
// Step 2: Assign IDs
|
|
20
|
-
const implItems = assignImplIds(input.implementations);
|
|
21
|
-
const implIdMap = new Map(implItems.map((item, i) => [i, item.impl_id]));
|
|
22
|
-
const changeItems = assignChangeIds(input.changes, implIdMap);
|
|
23
|
-
// Step 3: Assemble structures
|
|
24
|
-
const section3 = buildSection3(state);
|
|
25
|
-
const section4 = buildSection4(implItems);
|
|
26
|
-
const deltaSet = buildDeltaSet(state, changeItems);
|
|
27
|
-
const valItems = buildValidationPlan(state, input.injectValidations);
|
|
28
|
-
// Step 4: Compile Defense
|
|
29
|
-
const buildSpecData = {
|
|
30
|
-
section3: section3.filter((e) => e.decision !== "invalidated"),
|
|
31
|
-
section4,
|
|
32
|
-
};
|
|
33
|
-
const defenseResult = compileDefense(state, buildSpecData, deltaSet, valItems, input.brownfieldDetail, input.brownfield);
|
|
34
|
-
if (!defenseResult.passed) {
|
|
35
|
-
return {
|
|
36
|
-
success: false,
|
|
37
|
-
reason: `Compile Defense failed: ${defenseResult.violations.length} violation(s)`,
|
|
38
|
-
violations: defenseResult.violations,
|
|
39
|
-
warnings: defenseResult.warnings,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
const defenseWarnings = defenseResult.warnings;
|
|
43
|
-
// Step 5–6: Render + hash (2-pass for circular reference)
|
|
44
|
-
// - coreHash = hash of Section 1-4 only (used in deltaSet.build_spec_hash)
|
|
45
|
-
// - buildSpecHash = hash of full Build Spec (Section 1-7, used in compile.completed payload)
|
|
46
|
-
// Note: validation-plan is rendered before Build Spec hash is known.
|
|
47
|
-
// build_spec_hash reference is added by the agent when saving the file.
|
|
48
|
-
const validationPlanMd = renderValidationPlanMd(state, valItems);
|
|
49
|
-
const validationPlanHash = contentHash(validationPlanMd);
|
|
50
|
-
const coreMd = renderBuildSpecCore(input, implItems, section3);
|
|
51
|
-
const coreHash = contentHash(coreMd);
|
|
52
|
-
deltaSet.build_spec_hash = coreHash;
|
|
53
|
-
const deltaSetJson = JSON.stringify(deltaSet, null, 2);
|
|
54
|
-
const deltaSetHash = contentHash(deltaSetJson);
|
|
55
|
-
const refSections = renderSection5(deltaSetHash, deltaSet.changes) +
|
|
56
|
-
renderSection6(validationPlanHash, valItems.length);
|
|
57
|
-
// Brownfield Detail (separate file)
|
|
58
|
-
const brownfieldDetailMd = renderBrownfieldDetail(input.brownfieldDetail);
|
|
59
|
-
const brownfieldDetailHash = contentHash(brownfieldDetailMd);
|
|
60
|
-
// Section 7 (Tier 1+2 with references to brownfield-detail.md)
|
|
61
|
-
const section7 = renderSection7(input.brownfield, brownfieldDetailHash).join("\n") + "\n";
|
|
62
|
-
const buildSpecMd = coreMd + refSections + section7;
|
|
63
|
-
const buildSpecHash = contentHash(buildSpecMd);
|
|
64
|
-
// Step 7: Return
|
|
65
|
-
return {
|
|
66
|
-
success: true,
|
|
67
|
-
buildSpecMd,
|
|
68
|
-
buildSpecHash,
|
|
69
|
-
buildSpecData,
|
|
70
|
-
brownfieldDetailMd,
|
|
71
|
-
brownfieldDetailHash,
|
|
72
|
-
deltaSetJson,
|
|
73
|
-
deltaSetHash,
|
|
74
|
-
deltaSet,
|
|
75
|
-
validationPlanMd,
|
|
76
|
-
validationPlanHash,
|
|
77
|
-
validationPlan: valItems,
|
|
78
|
-
warnings: defenseWarnings ?? [],
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
// ─── Validation ───
|
|
82
|
-
function validateInput(input) {
|
|
83
|
-
const { state } = input;
|
|
84
|
-
if (state.current_state !== "target_locked") {
|
|
85
|
-
return `state.current_state must be "target_locked", got "${state.current_state}"`;
|
|
86
|
-
}
|
|
87
|
-
if (!state.compile_ready) {
|
|
88
|
-
return "state.compile_ready is false — constraints may be unresolved or snapshot is stale";
|
|
89
|
-
}
|
|
90
|
-
if (!state.surface_hash) {
|
|
91
|
-
return "state.surface_hash is missing — surface must be confirmed before compile";
|
|
92
|
-
}
|
|
93
|
-
if (!state.direction) {
|
|
94
|
-
return "state.direction is missing — align must be locked before compile";
|
|
95
|
-
}
|
|
96
|
-
if (!state.scope_boundaries) {
|
|
97
|
-
return "state.scope_boundaries is missing — align must be locked before compile";
|
|
98
|
-
}
|
|
99
|
-
// Check for disallowed decisions
|
|
100
|
-
for (const c of state.constraint_pool.constraints) {
|
|
101
|
-
if (c.status === "invalidated")
|
|
102
|
-
continue;
|
|
103
|
-
if (c.decision === "clarify" || c.decision === "modify-direction") {
|
|
104
|
-
return `${c.constraint_id} has decision "${c.decision}" which must be resolved before compile`;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// Validate impl indices
|
|
108
|
-
for (let i = 0; i < input.changes.length; i++) {
|
|
109
|
-
for (const idx of input.changes[i].related_impl_indices) {
|
|
110
|
-
if (idx < 0 || idx >= input.implementations.length) {
|
|
111
|
-
return `changes[${i}].related_impl_indices contains invalid index ${idx} (implementations has ${input.implementations.length} items)`;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
// Validate inject validations coverage
|
|
116
|
-
const injectCsts = new Set(state.constraint_pool.constraints
|
|
117
|
-
.filter((c) => c.status !== "invalidated" && c.decision === "inject")
|
|
118
|
-
.map((c) => c.constraint_id));
|
|
119
|
-
const coveredCsts = new Set(input.injectValidations.map((v) => v.related_cst));
|
|
120
|
-
const missingValidations = [...injectCsts].filter(id => !coveredCsts.has(id));
|
|
121
|
-
if (missingValidations.length > 0) {
|
|
122
|
-
return `inject constraints missing injectValidation: ${missingValidations.join(", ")}`;
|
|
123
|
-
}
|
|
124
|
-
// Validate inject constraints have at least one CHG
|
|
125
|
-
const chgCsts = new Set(input.changes.flatMap((c) => c.related_cst));
|
|
126
|
-
const missingChanges = [...injectCsts].filter(id => !chgCsts.has(id));
|
|
127
|
-
if (missingChanges.length > 0) {
|
|
128
|
-
return `inject constraints missing CHG in changes: ${missingChanges.join(", ")}`;
|
|
129
|
-
}
|
|
130
|
-
// Validate every IMPL has at least one CHG referencing it
|
|
131
|
-
for (let i = 0; i < input.implementations.length; i++) {
|
|
132
|
-
const hasChg = input.changes.some((c) => c.related_impl_indices.includes(i));
|
|
133
|
-
if (!hasChg) {
|
|
134
|
-
return `implementations[${i}] ("${input.implementations[i].summary}") has no CHG referencing it via related_impl_indices`;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
// Validate brownfield required fields
|
|
138
|
-
if (!input.brownfield.related_files || !Array.isArray(input.brownfield.related_files)) {
|
|
139
|
-
return "brownfield.related_files is required and must be an array of BrownfieldFileEntry";
|
|
140
|
-
}
|
|
141
|
-
if (!input.brownfield.module_dependencies || !Array.isArray(input.brownfield.module_dependencies)) {
|
|
142
|
-
return "brownfield.module_dependencies is required and must be an array of BrownfieldDepEntry";
|
|
143
|
-
}
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
function assignImplIds(implementations) {
|
|
147
|
-
return implementations.map((item, i) => ({
|
|
148
|
-
...item,
|
|
149
|
-
impl_id: makeId("IMPL-", i + 1),
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
|
-
function assignChangeIds(changes, implIdMap) {
|
|
153
|
-
return changes.map((c, i) => ({
|
|
154
|
-
change_id: makeId("CHG-", i + 1),
|
|
155
|
-
action: c.action,
|
|
156
|
-
file_path: c.file_path,
|
|
157
|
-
description: c.description,
|
|
158
|
-
related_impl: c.related_impl_indices.map((idx) => implIdMap.get(idx)),
|
|
159
|
-
related_cst: c.related_cst,
|
|
160
|
-
before_context: c.before_context,
|
|
161
|
-
after_context: c.after_context,
|
|
162
|
-
acceptance_criteria: c.acceptance_criteria,
|
|
163
|
-
}));
|
|
164
|
-
}
|
|
165
|
-
// ─── Assembly ───
|
|
166
|
-
function buildSection3(state) {
|
|
167
|
-
return state.constraint_pool.constraints
|
|
168
|
-
.filter((c) => c.status !== "invalidated")
|
|
169
|
-
.map((c) => ({
|
|
170
|
-
constraint_id: c.constraint_id,
|
|
171
|
-
decision: c.decision,
|
|
172
|
-
}));
|
|
173
|
-
}
|
|
174
|
-
function buildSection4(implItems) {
|
|
175
|
-
return implItems.map((item) => ({
|
|
176
|
-
impl_id: item.impl_id,
|
|
177
|
-
related_cst: item.related_cst,
|
|
178
|
-
}));
|
|
179
|
-
}
|
|
180
|
-
function buildDeltaSet(state, changeItems) {
|
|
181
|
-
return {
|
|
182
|
-
scope_id: state.scope_id,
|
|
183
|
-
surface_hash: state.surface_hash,
|
|
184
|
-
build_spec_hash: "", // filled after core hash
|
|
185
|
-
changes: changeItems,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function buildValidationPlan(state, injectValidations) {
|
|
189
|
-
const items = [];
|
|
190
|
-
let valCounter = 0;
|
|
191
|
-
const nextValId = () => makeId("VAL-", ++valCounter);
|
|
192
|
-
// inject (agent-written)
|
|
193
|
-
for (const iv of injectValidations) {
|
|
194
|
-
items.push({
|
|
195
|
-
val_id: nextValId(),
|
|
196
|
-
related_cst: iv.related_cst,
|
|
197
|
-
decision_type: "inject",
|
|
198
|
-
target: iv.target,
|
|
199
|
-
method: iv.method,
|
|
200
|
-
pass_criteria: iv.pass_criteria,
|
|
201
|
-
fail_action: iv.fail_action,
|
|
202
|
-
edge_cases: iv.edge_cases,
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
// defer (auto-generated)
|
|
206
|
-
for (const c of constraintsByDecision(state, "defer")) {
|
|
207
|
-
const sourceFiles = c.source_refs.map((r) => r.source).join(", ");
|
|
208
|
-
items.push({
|
|
209
|
-
val_id: nextValId(),
|
|
210
|
-
related_cst: c.constraint_id,
|
|
211
|
-
decision_type: "defer",
|
|
212
|
-
target: `${c.summary} 비간섭 확인`,
|
|
213
|
-
method: `검증 파일: ${sourceFiles}. 해당 파일이 이번 변경에서 수정되지 않았는지 확인`,
|
|
214
|
-
pass_criteria: `${sourceFiles} 변경 없음`,
|
|
215
|
-
fail_action: "의도하지 않은 간섭 발견 시 constraints_resolved로 복귀하여 재결정",
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
// override (auto-generated)
|
|
219
|
-
for (const c of constraintsByDecision(state, "override")) {
|
|
220
|
-
const sourceFiles = c.source_refs.map((r) => r.source).join(", ");
|
|
221
|
-
items.push({
|
|
222
|
-
val_id: nextValId(),
|
|
223
|
-
related_cst: c.constraint_id,
|
|
224
|
-
decision_type: "override",
|
|
225
|
-
target: `${c.summary} 비반영 확인`,
|
|
226
|
-
method: `검증 파일: ${sourceFiles}. 해당 constraint 관련 코드 변경이 없는지 확인`,
|
|
227
|
-
pass_criteria: `${c.constraint_id} 관련 변경 없음`,
|
|
228
|
-
fail_action: "의도적 비반영 위반 발견 시 constraints_resolved로 복귀하여 재결정",
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
return items;
|
|
232
|
-
}
|
|
233
|
-
function constraintsByDecision(state, decision) {
|
|
234
|
-
return state.constraint_pool.constraints.filter((c) => c.status !== "invalidated" && c.decision === decision);
|
|
235
|
-
}
|
|
236
|
-
// ─── Build Spec Rendering ───
|
|
237
|
-
function renderBuildSpecCore(input, implItems, section3) {
|
|
238
|
-
const lines = [];
|
|
239
|
-
lines.push(...renderSection1(input.state));
|
|
240
|
-
lines.push(...renderSection2(input.state, input.surfaceSummary));
|
|
241
|
-
lines.push(...renderSection3(input.state, section3));
|
|
242
|
-
lines.push(...renderSection4(implItems));
|
|
243
|
-
// Section 5, 6 are inserted by compile() after hash calculation (2-pass)
|
|
244
|
-
// Section 7 is appended last in the final assembly
|
|
245
|
-
return lines.join("\n") + "\n";
|
|
246
|
-
}
|
|
247
|
-
function renderSection1(state) {
|
|
248
|
-
const lines = [];
|
|
249
|
-
lines.push(`# Build Spec: ${state.title}`);
|
|
250
|
-
lines.push("");
|
|
251
|
-
lines.push("## 1. Scope Summary");
|
|
252
|
-
lines.push("");
|
|
253
|
-
lines.push("| 항목 | 값 |");
|
|
254
|
-
lines.push("|------|-----|");
|
|
255
|
-
lines.push(`| scope ID | ${state.scope_id} |`);
|
|
256
|
-
lines.push(`| 제목 | ${state.title} |`);
|
|
257
|
-
lines.push(`| 방향 | ${state.direction} |`);
|
|
258
|
-
lines.push(`| scope type | ${state.entry_mode} |`);
|
|
259
|
-
lines.push("");
|
|
260
|
-
const b = state.scope_boundaries;
|
|
261
|
-
lines.push("**범위 — 포함:**");
|
|
262
|
-
for (const item of b.in)
|
|
263
|
-
lines.push(`- ${item}`);
|
|
264
|
-
lines.push("");
|
|
265
|
-
lines.push("**범위 — 제외:**");
|
|
266
|
-
for (const item of b.out)
|
|
267
|
-
lines.push(`- ${item}`);
|
|
268
|
-
lines.push("");
|
|
269
|
-
return lines;
|
|
270
|
-
}
|
|
271
|
-
function renderSection2(state, surfaceSummary) {
|
|
272
|
-
const lines = [];
|
|
273
|
-
const surfaceDir = state.surface_path ??
|
|
274
|
-
(state.entry_mode === "experience" ? "surface/preview/" : "surface/contract-diff/");
|
|
275
|
-
lines.push("## 2. Confirmed Surface");
|
|
276
|
-
lines.push("");
|
|
277
|
-
lines.push(`- **surface 경로**: \`${surfaceDir}\``);
|
|
278
|
-
lines.push(`- **content hash**: \`${state.surface_hash}\``);
|
|
279
|
-
lines.push("");
|
|
280
|
-
lines.push("**시나리오 요약:**");
|
|
281
|
-
lines.push(surfaceSummary);
|
|
282
|
-
lines.push("");
|
|
283
|
-
return lines;
|
|
284
|
-
}
|
|
285
|
-
function renderSection3(state, section3) {
|
|
286
|
-
const lines = [];
|
|
287
|
-
lines.push("## 3. Constraint Decision Map");
|
|
288
|
-
lines.push("");
|
|
289
|
-
lines.push("| CST-ID | 관점 | 요약 | 결정 | Build Spec 내 처리 |");
|
|
290
|
-
lines.push("|--------|------|------|------|-------------------|");
|
|
291
|
-
// Include all constraints (including invalidated) for traceability
|
|
292
|
-
for (const c of state.constraint_pool.constraints) {
|
|
293
|
-
const perspective = formatPerspective(c.perspective);
|
|
294
|
-
const treatment = decisionTreatment(c);
|
|
295
|
-
lines.push(`| ${c.constraint_id} | ${perspective} | ${c.summary} | ${c.decision ?? "—"} | ${treatment} |`);
|
|
296
|
-
}
|
|
297
|
-
// Policy change warning
|
|
298
|
-
const policyChangeCsts = state.constraint_pool.constraints.filter(isPolicyChangeRequired);
|
|
299
|
-
if (policyChangeCsts.length > 0) {
|
|
300
|
-
lines.push("");
|
|
301
|
-
lines.push("> **정책 변경 검토 필요:**");
|
|
302
|
-
for (const c of policyChangeCsts) {
|
|
303
|
-
lines.push(`> - ${c.constraint_id}: 기존 정책 변경을 전제합니다. 구현 전 법무/정책 검토가 필요합니다.${c.evidence_note ? ` 참고: ${c.evidence_note}` : ""}`);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
// Also show invalidated separately (collapsed when 3+)
|
|
307
|
-
const invalidated = state.constraint_pool.constraints.filter((c) => c.status === "invalidated");
|
|
308
|
-
if (invalidated.length > 0) {
|
|
309
|
-
lines.push("");
|
|
310
|
-
if (invalidated.length >= 3) {
|
|
311
|
-
lines.push("<details>");
|
|
312
|
-
lines.push(`<summary>무효화된 항목 (${invalidated.length}건)</summary>`);
|
|
313
|
-
lines.push("");
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
lines.push("**무효화된 항목:**");
|
|
317
|
-
}
|
|
318
|
-
for (const c of invalidated) {
|
|
319
|
-
lines.push(`- ${c.constraint_id}: ${c.invalidation_reason ?? "방향 변경으로 해당 없음"}`);
|
|
320
|
-
}
|
|
321
|
-
if (invalidated.length >= 3) {
|
|
322
|
-
lines.push("");
|
|
323
|
-
lines.push("</details>");
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
lines.push("");
|
|
327
|
-
return lines;
|
|
328
|
-
}
|
|
329
|
-
function decisionTreatment(c) {
|
|
330
|
-
if (c.status === "invalidated") {
|
|
331
|
-
return `해당 없음. 사유: ${c.invalidation_reason ?? "방향 변경"}`;
|
|
332
|
-
}
|
|
333
|
-
const policySuffix = isPolicyChangeRequired(c) ? " [정책 변경 검토 필요]" : "";
|
|
334
|
-
switch (c.decision) {
|
|
335
|
-
case "inject": {
|
|
336
|
-
return `Section 4에서 구현. ${c.selected_option ?? ""}`.trim() + policySuffix;
|
|
337
|
-
}
|
|
338
|
-
case "defer":
|
|
339
|
-
return `이번 범위에서 제외. 이유: ${c.rationale ?? c.selected_option ?? "—"}`;
|
|
340
|
-
case "override":
|
|
341
|
-
return `무시. 이유: ${c.rationale ?? c.selected_option ?? "—"}`;
|
|
342
|
-
default:
|
|
343
|
-
return "—";
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
function renderSection4(implItems) {
|
|
347
|
-
const lines = [];
|
|
348
|
-
lines.push("## 4. Implementation Plan");
|
|
349
|
-
lines.push("");
|
|
350
|
-
if (implItems.length === 0) {
|
|
351
|
-
lines.push("구현 항목 없음.");
|
|
352
|
-
lines.push("");
|
|
353
|
-
return lines;
|
|
354
|
-
}
|
|
355
|
-
for (const item of implItems) {
|
|
356
|
-
lines.push(`### ${item.impl_id} | ${item.related_cst.join(", ")}`);
|
|
357
|
-
lines.push("");
|
|
358
|
-
lines.push(`- **요약:** ${item.summary}`);
|
|
359
|
-
lines.push(`- **변경 대상:** ${item.target}`);
|
|
360
|
-
lines.push(`- **변경 내용:** ${item.detail}`);
|
|
361
|
-
if (item.depends_on && item.depends_on.length > 0) {
|
|
362
|
-
lines.push(`- **의존성:** ${item.depends_on.join(", ")}`);
|
|
363
|
-
}
|
|
364
|
-
if (item.guardrail) {
|
|
365
|
-
lines.push(`- **guardrail:** ${item.guardrail}`);
|
|
366
|
-
}
|
|
367
|
-
if (item.pseudocode) {
|
|
368
|
-
lines.push("- **pseudocode:**");
|
|
369
|
-
lines.push("```");
|
|
370
|
-
lines.push(item.pseudocode);
|
|
371
|
-
lines.push("```");
|
|
372
|
-
}
|
|
373
|
-
if (item.test_strategy) {
|
|
374
|
-
lines.push(`- **test strategy:** ${item.test_strategy}`);
|
|
375
|
-
}
|
|
376
|
-
if (item.assumptions && item.assumptions.length > 0) {
|
|
377
|
-
lines.push("- **전제 가정:**");
|
|
378
|
-
for (const a of item.assumptions) {
|
|
379
|
-
lines.push(` - ${a}`);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
lines.push("");
|
|
383
|
-
}
|
|
384
|
-
return lines;
|
|
385
|
-
}
|
|
386
|
-
function renderSection5(deltaSetHash, changes) {
|
|
387
|
-
const counts = { create: 0, modify: 0, delete: 0 };
|
|
388
|
-
for (const c of changes)
|
|
389
|
-
counts[c.action]++;
|
|
390
|
-
const parts = [];
|
|
391
|
-
if (counts.create > 0)
|
|
392
|
-
parts.push(`create ${counts.create}건`);
|
|
393
|
-
if (counts.modify > 0)
|
|
394
|
-
parts.push(`modify ${counts.modify}건`);
|
|
395
|
-
if (counts.delete > 0)
|
|
396
|
-
parts.push(`delete ${counts.delete}건`);
|
|
397
|
-
const lines = [];
|
|
398
|
-
lines.push("## 5. Delta Set Reference");
|
|
399
|
-
lines.push("");
|
|
400
|
-
lines.push("- **delta-set 경로**: `build/delta-set.json`");
|
|
401
|
-
lines.push(`- **변경 파일 수**: ${parts.join(", ") || "0건"}`);
|
|
402
|
-
lines.push(`- **content hash**: \`${deltaSetHash}\``);
|
|
403
|
-
lines.push("");
|
|
404
|
-
return lines.join("\n");
|
|
405
|
-
}
|
|
406
|
-
function renderSection6(valPlanHash, valCount) {
|
|
407
|
-
const lines = [];
|
|
408
|
-
lines.push("## 6. Validation Plan Reference");
|
|
409
|
-
lines.push("");
|
|
410
|
-
lines.push("- **validation-plan 경로**: `build/validation-plan.md`");
|
|
411
|
-
lines.push(`- **검증 항목 수**: ${valCount}건`);
|
|
412
|
-
lines.push(`- **content hash**: \`${valPlanHash}\``);
|
|
413
|
-
lines.push("");
|
|
414
|
-
return lines.join("\n");
|
|
415
|
-
}
|
|
416
|
-
function renderSection7(brownfield, detailHash) {
|
|
417
|
-
const lines = [];
|
|
418
|
-
const detailFile = "brownfield-detail.md";
|
|
419
|
-
lines.push("## 7. Brownfield Context");
|
|
420
|
-
lines.push("");
|
|
421
|
-
lines.push(`상세: [\`build/${detailFile}\`](${detailFile}) (hash: \`${detailHash.slice(0, 8)}\`)`);
|
|
422
|
-
lines.push("");
|
|
423
|
-
// Split related_files into non-test (Tier 1) and test (Tier 2)
|
|
424
|
-
const nonTestFiles = brownfield.related_files.filter(f => !f.role.startsWith("test ("));
|
|
425
|
-
const testFiles = brownfield.related_files.filter(f => f.role.startsWith("test ("));
|
|
426
|
-
// Tier 1: Non-test related files (always expanded)
|
|
427
|
-
if (nonTestFiles.length > 0) {
|
|
428
|
-
lines.push(`### 변경 대상 파일 (${nonTestFiles.length}건)`);
|
|
429
|
-
lines.push("");
|
|
430
|
-
lines.push("| 경로 | 역할 | 상세 |");
|
|
431
|
-
lines.push("|------|------|------|");
|
|
432
|
-
for (const f of nonTestFiles) {
|
|
433
|
-
lines.push(`| \`${f.path}\` | ${f.role} | [→ 상세](${detailFile}#${f.detail_anchor}) |`);
|
|
434
|
-
}
|
|
435
|
-
lines.push("");
|
|
436
|
-
}
|
|
437
|
-
// Tier 2: Test files (collapsed)
|
|
438
|
-
if (testFiles.length > 0) {
|
|
439
|
-
lines.push("<details>");
|
|
440
|
-
lines.push(`<summary>테스트 파일 (${testFiles.length}건)</summary>`);
|
|
441
|
-
lines.push("");
|
|
442
|
-
lines.push("| 경로 | 역할 | 상세 |");
|
|
443
|
-
lines.push("|------|------|------|");
|
|
444
|
-
for (const f of testFiles) {
|
|
445
|
-
lines.push(`| \`${f.path}\` | ${f.role} | [→ 상세](${detailFile}#${f.detail_anchor}) |`);
|
|
446
|
-
}
|
|
447
|
-
lines.push("");
|
|
448
|
-
lines.push("</details>");
|
|
449
|
-
lines.push("");
|
|
450
|
-
}
|
|
451
|
-
// Tier 1: Module dependencies (always expanded)
|
|
452
|
-
if (brownfield.module_dependencies.length > 0) {
|
|
453
|
-
lines.push(`### 직접 의존 모듈 (${brownfield.module_dependencies.length}건)`);
|
|
454
|
-
lines.push("");
|
|
455
|
-
lines.push("| 모듈 | 의존 대상 | 상세 |");
|
|
456
|
-
lines.push("|------|----------|------|");
|
|
457
|
-
for (const d of brownfield.module_dependencies) {
|
|
458
|
-
lines.push(`| ${d.module} | ${d.depends_on} | [→ 상세](${detailFile}#${d.detail_anchor}) |`);
|
|
459
|
-
}
|
|
460
|
-
lines.push("");
|
|
461
|
-
}
|
|
462
|
-
// Tier 2: API contracts (collapsed)
|
|
463
|
-
if (brownfield.api_contracts && brownfield.api_contracts.length > 0) {
|
|
464
|
-
lines.push("<details>");
|
|
465
|
-
lines.push(`<summary>API 계약 (${brownfield.api_contracts.length}건)</summary>`);
|
|
466
|
-
lines.push("");
|
|
467
|
-
lines.push("| endpoint | method | 설명 | 상세 |");
|
|
468
|
-
lines.push("|----------|--------|------|------|");
|
|
469
|
-
for (const a of brownfield.api_contracts) {
|
|
470
|
-
lines.push(`| ${a.endpoint} | ${a.method} | ${a.description} | [→ 상세](${detailFile}#${a.detail_anchor}) |`);
|
|
471
|
-
}
|
|
472
|
-
lines.push("");
|
|
473
|
-
lines.push("</details>");
|
|
474
|
-
lines.push("");
|
|
475
|
-
}
|
|
476
|
-
// Tier 2: DB schemas (collapsed)
|
|
477
|
-
if (brownfield.db_schemas && brownfield.db_schemas.length > 0) {
|
|
478
|
-
lines.push("<details>");
|
|
479
|
-
lines.push(`<summary>DB 스키마 (${brownfield.db_schemas.length}건)</summary>`);
|
|
480
|
-
lines.push("");
|
|
481
|
-
lines.push("| 테이블 | 컬럼 | 상세 |");
|
|
482
|
-
lines.push("|--------|------|------|");
|
|
483
|
-
for (const s of brownfield.db_schemas) {
|
|
484
|
-
lines.push(`| ${s.table} | ${s.columns} | [→ 상세](${detailFile}#${s.detail_anchor}) |`);
|
|
485
|
-
}
|
|
486
|
-
lines.push("");
|
|
487
|
-
lines.push("</details>");
|
|
488
|
-
lines.push("");
|
|
489
|
-
}
|
|
490
|
-
// Tier 2: Config/env (collapsed)
|
|
491
|
-
if (brownfield.config_env && brownfield.config_env.length > 0) {
|
|
492
|
-
lines.push("<details>");
|
|
493
|
-
lines.push(`<summary>설정/환경 변수 (${brownfield.config_env.length}건)</summary>`);
|
|
494
|
-
lines.push("");
|
|
495
|
-
lines.push("| 키 | 설명 | 상세 |");
|
|
496
|
-
lines.push("|-----|------|------|");
|
|
497
|
-
for (const e of brownfield.config_env) {
|
|
498
|
-
lines.push(`| ${e.key} | ${e.description} | [→ 상세](${detailFile}#${e.detail_anchor}) |`);
|
|
499
|
-
}
|
|
500
|
-
lines.push("");
|
|
501
|
-
lines.push("</details>");
|
|
502
|
-
lines.push("");
|
|
503
|
-
}
|
|
504
|
-
return lines;
|
|
505
|
-
}
|
|
506
|
-
// ─── Brownfield Detail Rendering ───
|
|
507
|
-
function renderBrownfieldDetail(detail) {
|
|
508
|
-
const lines = [];
|
|
509
|
-
lines.push("# Brownfield Detail");
|
|
510
|
-
lines.push("");
|
|
511
|
-
lines.push(`scope: ${detail.scope_id}`);
|
|
512
|
-
lines.push("");
|
|
513
|
-
for (const section of detail.sections) {
|
|
514
|
-
lines.push(`<a id="${section.anchor}"></a>`);
|
|
515
|
-
lines.push("");
|
|
516
|
-
lines.push(`## ${section.title}`);
|
|
517
|
-
lines.push("");
|
|
518
|
-
lines.push(`**소스:** ${section.source}`);
|
|
519
|
-
lines.push("");
|
|
520
|
-
lines.push(section.content);
|
|
521
|
-
lines.push("");
|
|
522
|
-
}
|
|
523
|
-
return lines.join("\n");
|
|
524
|
-
}
|
|
525
|
-
// ─── Validation Plan Rendering ───
|
|
526
|
-
function renderValidationPlanMd(state, valItems) {
|
|
527
|
-
const lines = [];
|
|
528
|
-
lines.push(`# Validation Plan: ${state.title}`);
|
|
529
|
-
lines.push("");
|
|
530
|
-
lines.push(`scope: ${state.scope_id}`);
|
|
531
|
-
lines.push("");
|
|
532
|
-
lines.push("---");
|
|
533
|
-
lines.push("");
|
|
534
|
-
for (const v of valItems) {
|
|
535
|
-
const cstEntry = state.constraint_pool.constraints.find((c) => c.constraint_id === v.related_cst);
|
|
536
|
-
const policyTag = cstEntry && isPolicyChangeRequired(cstEntry)
|
|
537
|
-
? " [정책 변경 검토 필요]"
|
|
538
|
-
: "";
|
|
539
|
-
lines.push(`### ${v.val_id} | ${v.related_cst} | ${v.decision_type}${policyTag}`);
|
|
540
|
-
lines.push("");
|
|
541
|
-
lines.push(`**검증 대상:** ${v.target}`);
|
|
542
|
-
lines.push(`**검증 방법:** ${v.method}`);
|
|
543
|
-
lines.push(`**통과 조건:** ${v.pass_criteria}`);
|
|
544
|
-
lines.push(`**실패 시 조치:** ${v.fail_action}`);
|
|
545
|
-
if (cstEntry && isPolicyChangeRequired(cstEntry)) {
|
|
546
|
-
lines.push("");
|
|
547
|
-
lines.push(`> **정책 변경 전제**: 이 항목은 기존 정책 변경을 전제합니다. 검증 전 법무/정책 검토 완료 여부를 확인하세요.`);
|
|
548
|
-
}
|
|
549
|
-
if (v.edge_cases && v.edge_cases.length > 0) {
|
|
550
|
-
lines.push("");
|
|
551
|
-
lines.push("**Edge cases:**");
|
|
552
|
-
lines.push("");
|
|
553
|
-
lines.push("| 시나리오 | 예상 결과 |");
|
|
554
|
-
lines.push("|---------|----------|");
|
|
555
|
-
for (const ec of v.edge_cases) {
|
|
556
|
-
lines.push(`| ${ec.scenario} | ${ec.expected_result} |`);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
lines.push("");
|
|
560
|
-
lines.push("---");
|
|
561
|
-
lines.push("");
|
|
562
|
-
}
|
|
563
|
-
return lines.join("\n");
|
|
564
|
-
}
|