@wowok/agent-mcp 2.7.0 → 2.7.2
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/dist/config/index.js +1 -1
- package/dist/config/runtime.js +1 -238
- package/dist/customer/customer-advice.js +1 -130
- package/dist/customer/index.js +1 -11
- package/dist/customer/industry-risks.js +1 -438
- package/dist/customer/info-puzzle.js +1 -681
- package/dist/customer/order-monitor.js +1 -328
- package/dist/customer/order-strategy.js +1 -373
- package/dist/customer/post-purchase.js +1 -351
- package/dist/customer/preorder-compare.js +1 -34
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.d.ts +5 -1
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.js +1 -13
- package/dist/customer/user-preferences.js +1 -460
- package/dist/evaluation/arbitration-game.d.ts +23 -0
- package/dist/evaluation/arbitration-game.js +1 -0
- package/dist/evaluation/builtins/demand-match.d.ts +15 -0
- package/dist/evaluation/builtins/demand-match.js +1 -0
- package/dist/evaluation/builtins/index.d.ts +3 -0
- package/dist/evaluation/builtins/index.js +1 -0
- package/dist/evaluation/builtins/service-risk.d.ts +6 -0
- package/dist/evaluation/builtins/service-risk.js +1 -0
- package/dist/evaluation/capability.d.ts +50 -0
- package/dist/evaluation/capability.js +1 -0
- package/dist/evaluation/composer.d.ts +13 -0
- package/dist/evaluation/composer.js +1 -0
- package/dist/evaluation/engine.d.ts +18 -0
- package/dist/evaluation/engine.js +1 -0
- package/dist/evaluation/extract.d.ts +30 -0
- package/dist/evaluation/extract.js +1 -0
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.d.ts +2 -0
- package/dist/evaluation/gap.js +1 -0
- package/dist/evaluation/index.d.ts +12 -0
- package/dist/evaluation/index.js +1 -0
- package/dist/evaluation/node-game.d.ts +62 -0
- package/dist/evaluation/node-game.js +1 -0
- package/dist/evaluation/region.d.ts +10 -0
- package/dist/evaluation/region.js +1 -0
- package/dist/evaluation/types.d.ts +77 -0
- package/dist/evaluation/types.js +1 -0
- package/dist/evaluation/user-injection.d.ts +6 -0
- package/dist/evaluation/user-injection.js +1 -0
- package/dist/examples/education-contact-create.json +40 -0
- package/dist/examples/freelance-contact-create.json +40 -0
- package/dist/examples/insurance-machine-create.json +1 -1
- package/dist/examples/insurance-service-allocators.json +1 -1
- package/dist/examples/machine-publish.json +1 -1
- package/dist/examples/rental-ziroom-service-create.json +1 -1
- package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
- package/dist/examples/retail-myshop-service-create.json +1 -1
- package/dist/examples/retail-myshop-service-customer-required.json +1 -1
- package/dist/examples/subscription-contact-create.json +40 -0
- package/dist/examples/threebody-machine-create.json +1 -1
- package/dist/examples/travel-machine-create.json +1 -1
- package/dist/examples/travel-service-create.json +1 -1
- package/dist/experience/experience-reuse.js +1 -103
- package/dist/experience/index.js +1 -5
- package/dist/experience/intent-distill.js +1 -83
- package/dist/experience/realtime-feedback.js +1 -94
- package/dist/experience/types.js +1 -1
- package/dist/experience/user-profile.js +1 -171
- package/dist/extensions/business-modules.js +1 -287
- package/dist/extensions/capability-manifest.js +1 -781
- package/dist/extensions/constraint-registry.js +1 -198
- package/dist/extensions/index.js +1 -6
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.js +1 -276
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.js +1 -1
- package/dist/harness/verify.js +1 -237
- package/dist/index.js +1 -273
- package/dist/intent/enrich.d.ts +1 -0
- package/dist/intent/enrich.js +1 -0
- package/dist/intent/index.d.ts +23 -0
- package/dist/intent/index.js +1 -0
- package/dist/intent/matcher.d.ts +2 -0
- package/dist/intent/matcher.js +1 -0
- package/dist/intent/store.d.ts +19 -0
- package/dist/intent/store.js +1 -0
- package/dist/intent/types.d.ts +33 -0
- package/dist/intent/types.js +1 -0
- package/dist/knowledge/acquisition-flywheel.js +1 -192
- package/dist/knowledge/allocation-confirm.js +1 -534
- package/dist/knowledge/allocation-context.js +1 -249
- package/dist/knowledge/allocation-ledger.js +1 -463
- package/dist/knowledge/allocation-puzzle.js +1 -298
- package/dist/knowledge/allocation-risk.js +1 -568
- package/dist/knowledge/allocation-templates.js +1 -970
- package/dist/knowledge/allocation-translation.js +1 -585
- package/dist/knowledge/arb-risk.js +1 -210
- package/dist/knowledge/arbitration-confirm.js +1 -559
- package/dist/knowledge/arbitration-context.js +1 -505
- package/dist/knowledge/arbitration-ledger.js +1 -521
- package/dist/knowledge/arbitration-puzzle.js +1 -304
- package/dist/knowledge/arbitration-risk.js +1 -433
- package/dist/knowledge/arbitration-templates.js +1 -276
- package/dist/knowledge/arbitration-translation.js +1 -487
- package/dist/knowledge/arbitration-trust.js +1 -117
- package/dist/knowledge/audit-rules.js +1 -141
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.d.ts +27 -0
- package/dist/knowledge/contact-templates.js +1 -0
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-risk.js +1 -240
- package/dist/knowledge/demand-translation.js +1 -354
- package/dist/knowledge/deployment-scanner.js +1 -823
- package/dist/knowledge/dynamic-pricing.js +1 -87
- package/dist/knowledge/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -825
- package/dist/knowledge/flywheel-loop.js +1 -404
- package/dist/knowledge/fund-layer.js +1 -973
- package/dist/knowledge/glossary.js +1 -211
- package/dist/knowledge/guard-confirm.js +1 -406
- package/dist/knowledge/guard-context.js +1 -287
- package/dist/knowledge/guard-design-patterns.js +1 -360
- package/dist/knowledge/guard-ledger.js +1 -260
- package/dist/knowledge/guard-lint.js +1 -670
- package/dist/knowledge/guard-migration.js +1 -228
- package/dist/knowledge/guard-puzzle.js +1 -805
- package/dist/knowledge/guard-render.js +1 -700
- package/dist/knowledge/guard-risk.js +1 -1879
- package/dist/knowledge/guard-submission-prompt.js +1 -171
- package/dist/knowledge/guard-templates.js +1 -1105
- package/dist/knowledge/guard-translation.js +1 -1119
- package/dist/knowledge/index.js +1 -436
- package/dist/knowledge/industry-evolution.js +1 -323
- package/dist/knowledge/industry-generalizer.js +1 -381
- package/dist/knowledge/industry-registry.js +1 -174
- package/dist/knowledge/intent-metrics.d.ts +4 -3
- package/dist/knowledge/intent-metrics.js +1 -566
- package/dist/knowledge/machine-confirm.js +1 -559
- package/dist/knowledge/machine-context.js +1 -833
- package/dist/knowledge/machine-ledger.js +1 -338
- package/dist/knowledge/machine-puzzle.js +1 -494
- package/dist/knowledge/machine-render.js +1 -565
- package/dist/knowledge/machine-risk.js +1 -670
- package/dist/knowledge/machine-templates.js +1 -1597
- package/dist/knowledge/machine-topology.js +1 -234
- package/dist/knowledge/machine-translation.js +1 -513
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
- package/dist/knowledge/mcp-schema-audit.js +1 -773
- package/dist/knowledge/onchain-constants.js +1 -35
- package/dist/knowledge/order-confirm.js +1 -573
- package/dist/knowledge/order-context.js +1 -390
- package/dist/knowledge/order-ledger.js +1 -341
- package/dist/knowledge/order-puzzle.js +1 -255
- package/dist/knowledge/order-risk.js +1 -653
- package/dist/knowledge/order-templates.js +1 -368
- package/dist/knowledge/order-translation.js +1 -550
- package/dist/knowledge/overrides-loader.js +1 -65
- package/dist/knowledge/passport-confirm.js +1 -531
- package/dist/knowledge/passport-context.js +1 -306
- package/dist/knowledge/passport-ledger.js +1 -282
- package/dist/knowledge/passport-puzzle.js +1 -333
- package/dist/knowledge/passport-risk.js +1 -450
- package/dist/knowledge/passport-templates.js +1 -568
- package/dist/knowledge/passport-translation.js +1 -516
- package/dist/knowledge/payment-risk.js +1 -249
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- package/dist/knowledge/permission-ledger.js +1 -403
- package/dist/knowledge/permission-puzzle.js +1 -173
- package/dist/knowledge/permission-risk.js +1 -411
- package/dist/knowledge/permission-templates.js +1 -234
- package/dist/knowledge/permission-translation.js +1 -350
- package/dist/knowledge/personal-risk.js +1 -212
- package/dist/knowledge/process-model.js +1 -160
- package/dist/knowledge/progress-confirm.js +1 -456
- package/dist/knowledge/progress-context.js +1 -452
- package/dist/knowledge/progress-ledger.js +1 -330
- package/dist/knowledge/progress-puzzle.js +1 -219
- package/dist/knowledge/progress-risk.js +1 -461
- package/dist/knowledge/progress-templates.js +1 -228
- package/dist/knowledge/progress-translation.js +1 -405
- package/dist/knowledge/proof-confirm.js +1 -187
- package/dist/knowledge/proof-risk.js +1 -207
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/reward-confirm.js +1 -526
- package/dist/knowledge/reward-context.js +1 -504
- package/dist/knowledge/reward-ledger.js +1 -502
- package/dist/knowledge/reward-puzzle.js +1 -300
- package/dist/knowledge/reward-risk.js +1 -627
- package/dist/knowledge/reward-templates.js +1 -197
- package/dist/knowledge/reward-translation.js +1 -501
- package/dist/knowledge/safety-rules.js +1 -404
- package/dist/knowledge/scenario-modes.js +1 -321
- package/dist/knowledge/service-confirm.js +1 -807
- package/dist/knowledge/service-context.js +1 -403
- package/dist/knowledge/service-ledger.js +1 -609
- package/dist/knowledge/service-puzzle.js +1 -236
- package/dist/knowledge/service-risk.js +1 -615
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.d.ts +1 -1
- package/dist/knowledge/template-registry.js +1 -341
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -155
- package/dist/knowledge/treasury-confirm.js +1 -512
- package/dist/knowledge/treasury-context.js +1 -363
- package/dist/knowledge/treasury-ledger.js +1 -300
- package/dist/knowledge/treasury-puzzle.js +1 -216
- package/dist/knowledge/treasury-risk.js +1 -440
- package/dist/knowledge/treasury-templates.js +1 -358
- package/dist/knowledge/treasury-translation.js +1 -498
- package/dist/knowledge/trust-metrics.js +1 -198
- package/dist/knowledge/util-risk.js +1 -135
- package/dist/loop-engineering/aggregate.js +1 -132
- package/dist/loop-engineering/context-collect.js +1 -83
- package/dist/loop-engineering/diagnose.js +1 -273
- package/dist/loop-engineering/improve.js +1 -405
- package/dist/loop-engineering/index.js +1 -4
- package/dist/loop-engineering/pipeline.js +1 -56
- package/dist/mode-market/index.js +1 -3
- package/dist/mode-market/registry.js +1 -124
- package/dist/mode-market/review.js +1 -214
- package/dist/mode-market/submission.js +1 -85
- package/dist/participation/collaborator-interest.d.ts +23 -0
- package/dist/participation/collaborator-interest.js +1 -0
- package/dist/participation/customer-interest.d.ts +25 -0
- package/dist/participation/customer-interest.js +1 -0
- package/dist/participation/merchant-interest.js +1 -100
- package/dist/participation/radar-core.d.ts +13 -3
- package/dist/participation/radar-core.js +1 -269
- package/dist/participation/supplier-interest.d.ts +25 -0
- package/dist/participation/supplier-interest.js +1 -0
- package/dist/persona/analyzer.d.ts +16 -0
- package/dist/persona/analyzer.js +1 -0
- package/dist/persona/bridge.d.ts +5 -0
- package/dist/persona/bridge.js +1 -0
- package/dist/persona/defaults.d.ts +4 -0
- package/dist/persona/defaults.js +1 -0
- package/dist/persona/experience-bridge.d.ts +3 -0
- package/dist/persona/experience-bridge.js +1 -0
- package/dist/persona/index.d.ts +18 -0
- package/dist/persona/index.js +1 -0
- package/dist/persona/model.d.ts +7 -0
- package/dist/persona/model.js +1 -0
- package/dist/persona/store.d.ts +19 -0
- package/dist/persona/store.js +1 -0
- package/dist/persona/types.d.ts +45 -0
- package/dist/persona/types.js +1 -0
- package/dist/project/business-puzzle.js +1 -383
- package/dist/project/context-assembly.js +1 -254
- package/dist/project/deployment-bridge.js +1 -120
- package/dist/project/deployment-doc.js +1 -1126
- package/dist/project/edit-planner.js +1 -1342
- package/dist/project/evaluation.js +1 -2011
- package/dist/project/game-theory.js +1 -177
- package/dist/project/graph-builder.js +1 -656
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.d.ts +5 -0
- package/dist/project/handlers.js +1 -1762
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -301
- package/dist/project/intent-analyzer.js +1 -149
- package/dist/project/machine-nodes.js +1 -36
- package/dist/project/merchant-guide.js +1 -264
- package/dist/project/migration.js +1 -125
- package/dist/project/mode-actions.js +1 -309
- package/dist/project/namespace.js +1 -206
- package/dist/project/participation-radar.js +1 -428
- package/dist/project/pipeline-actions.js +1 -109
- package/dist/project/project-store.js +1 -422
- package/dist/project/query.js +1 -153
- package/dist/project/reverse-mapping.d.ts +34 -0
- package/dist/project/reverse-mapping.js +1 -0
- package/dist/project/risk-aggregator.js +1 -295
- package/dist/project/rollback-policy.js +1 -290
- package/dist/project/semantic-assembler.js +1 -345
- package/dist/project/semantic-graph.js +1 -245
- package/dist/project/stage-gate.js +1 -369
- package/dist/project/substep-trace.js +1 -332
- package/dist/project/task-tracker.js +1 -78
- package/dist/role/derivation.d.ts +18 -0
- package/dist/role/derivation.js +1 -0
- package/dist/role/index.d.ts +5 -0
- package/dist/role/index.js +1 -0
- package/dist/role/model.d.ts +8 -0
- package/dist/role/model.js +1 -0
- package/dist/role/resolution.d.ts +11 -0
- package/dist/role/resolution.js +1 -0
- package/dist/role/types.d.ts +11 -0
- package/dist/role/types.js +1 -0
- package/dist/rules.d.ts +2 -0
- package/dist/rules.js +1 -9
- package/dist/safety/confirm-gate.js +1 -88
- package/dist/safety/index.js +1 -3
- package/dist/safety/preview.js +1 -52
- package/dist/schema/call/allocation.js +1 -34
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +15 -15
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge-handler.js +1 -265
- package/dist/schema/call/bridge.d.ts +7 -7
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.js +1 -47
- package/dist/schema/call/guard.js +1 -161
- package/dist/schema/call/handler.js +1 -322
- package/dist/schema/call/index.js +1 -20
- package/dist/schema/call/machine.js +1 -193
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1657
- package/dist/schema/call/service.js +1 -178
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/evaluation/index.d.ts +4436 -0
- package/dist/schema/evaluation/index.js +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.js +1 -13
- package/dist/schema/intent-radar/index.d.ts +284 -0
- package/dist/schema/intent-radar/index.js +1 -0
- package/dist/schema/local/index.d.ts +21 -21
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +7 -7
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +7 -7
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +1985 -0
- package/dist/schema/persona/index.js +1 -0
- package/dist/schema/project/index.d.ts +96 -50
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1640
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.d.ts +1 -1
- package/dist/schema/sync-layer4.js +1 -282
- package/dist/schema/task-status.d.ts +168 -0
- package/dist/schema/task-status.js +1 -0
- package/dist/schema/trust/index.js +1 -314
- package/dist/schema/utils/guard-parser.js +1 -419
- package/dist/schema/utils/guard-query-utils.js +1 -46
- package/dist/schema/utils/node-parser.js +1 -369
- package/dist/schema/utils/object-type-utils.js +1 -35
- package/dist/schema/utils/permission-index-utils.js +1 -7
- package/dist/schema/utils/permission-machine-check.js +1 -121
- package/dist/schema/utils/skills-recommendation.js +1 -77
- package/dist/schema-query/index.js +1 -810
- package/dist/schemas/account_operation.output.json +5 -2
- package/dist/schemas/bridge_operation.output.json +5 -2
- package/dist/schemas/evaluation_operation.output.json +782 -0
- package/dist/schemas/evaluation_operation.schema.json +990 -0
- package/dist/schemas/index.json +25 -1
- package/dist/schemas/intent_radar.output.json +232 -0
- package/dist/schemas/intent_radar.schema.json +138 -0
- package/dist/schemas/local_info_operation.output.json +5 -2
- package/dist/schemas/local_mark_operation.output.json +5 -2
- package/dist/schemas/messenger_operation.output.json +5 -2
- package/dist/schemas/onchain_events.output.json +5 -2
- package/dist/schemas/onchain_operations.output.json +5 -2
- package/dist/schemas/onchain_operations.schema.json +6 -6
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +3 -3
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +392 -0
- package/dist/schemas/persona_operation.schema.json +250 -0
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_task_status.output.json +115 -0
- package/dist/schemas/query_task_status.schema.json +24 -0
- package/dist/schemas/query_toolkit.output.json +9 -6
- package/dist/schemas/trust_score.schema.json +1 -1
- package/dist/schemas/wowok_buildin_info.output.json +132 -0
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- package/dist/telemetry/index.js +1 -112
- package/dist/telemetry/redact.js +1 -23
- package/dist/telemetry/storage.js +1 -80
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/evaluation.d.ts +2 -0
- package/dist/tools/handlers/evaluation.js +1 -0
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.d.ts +2 -0
- package/dist/tools/handlers/intent-radar.js +1 -0
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1082
- package/dist/tools/handlers/persona.d.ts +4 -0
- package/dist/tools/handlers/persona.js +1 -0
- package/dist/tools/handlers/project.js +1 -211
- package/dist/tools/handlers/query.js +1 -434
- package/dist/tools/handlers/schema-query.js +1 -176
- package/dist/tools/handlers/task-status.d.ts +0 -168
- package/dist/tools/handlers/task-status.js +1 -55
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1306
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.js +1 -130
- package/dist/tools/types.js +1 -1
- package/dist/tools/upgrade-check.d.ts +19 -0
- package/dist/tools/upgrade-check.js +1 -0
- package/dist/tools/wip-deploy-assist.d.ts +1 -1
- package/dist/tools/wip-deploy-assist.js +1 -278
- package/dist/tools/wrap.js +1 -500
- package/package.json +5 -3
|
@@ -1,1126 +1 @@
|
|
|
1
|
-
import { join } from "path";
|
|
2
|
-
const STANDARD_TOPO_ORDER = [
|
|
3
|
-
"permission", "treasury", "allocation", "service", "guard", "machine",
|
|
4
|
-
"order", "progress", "arb", "reward",
|
|
5
|
-
"proof", "repository", "demand", "contact",
|
|
6
|
-
"personal", "payment",
|
|
7
|
-
];
|
|
8
|
-
const D_CHECK_ITEMS = [
|
|
9
|
-
{ id: "D-01", description: "All objects are defined in §1.1" },
|
|
10
|
-
{ id: "D-02", description: "All dependencies have no dangling references" },
|
|
11
|
-
{ id: "D-03", description: "All declared scenarios are covered by steps" },
|
|
12
|
-
{ id: "D-04", description: "All objects follow the naming convention" },
|
|
13
|
-
{ id: "D-05", description: "testnet network field is 'testnet'" },
|
|
14
|
-
{ id: "D-06", description: "testnet replaceExistName is true" },
|
|
15
|
-
{ id: "D-07", description: "All JSON blocks are valid JSON" },
|
|
16
|
-
{ id: "D-08", description: "All step IDs are sequential and unique" },
|
|
17
|
-
{ id: "D-09", description: "All substep IDs are unique" },
|
|
18
|
-
{ id: "D-10", description: "Substep linkage is complete (no dangling/circular)" },
|
|
19
|
-
{ id: "D-11", description: "All `${var}` references resolve to defined outputs" },
|
|
20
|
-
{ id: "D-12", description: "mainnet network field is 'mainnet'" },
|
|
21
|
-
{ id: "D-13", description: "mainnet replaceExistName is false (unless force claim)" },
|
|
22
|
-
{ id: "D-14", description: "Naming convention: ^[a-z][a-z0-9_]{2,63}$" },
|
|
23
|
-
{ id: "D-15", description: "All publish operations come after create" },
|
|
24
|
-
{ id: "D-16", description: "No CRITICAL risks remain (risk_status=RISK_PASSED)" },
|
|
25
|
-
{ id: "D-17", description: "All HIGH risks are user-confirmed" },
|
|
26
|
-
{ id: "D-18", description: "Version numbers are consistent across the document" },
|
|
27
|
-
];
|
|
28
|
-
function isoNow() {
|
|
29
|
-
return new Date().toISOString();
|
|
30
|
-
}
|
|
31
|
-
function indent(s, n) {
|
|
32
|
-
const pad = " ".repeat(n);
|
|
33
|
-
return s
|
|
34
|
-
.split("\n")
|
|
35
|
-
.map((l) => pad + l)
|
|
36
|
-
.join("\n");
|
|
37
|
-
}
|
|
38
|
-
function tableRow(cells) {
|
|
39
|
-
return "| " + cells.join(" | ") + " |";
|
|
40
|
-
}
|
|
41
|
-
function tableHeader(headers) {
|
|
42
|
-
return [
|
|
43
|
-
tableRow(headers),
|
|
44
|
-
"|" + headers.map(() => "---").join("|") + "|",
|
|
45
|
-
].join("\n");
|
|
46
|
-
}
|
|
47
|
-
function jsonBlock(label, data) {
|
|
48
|
-
const header = label ? `#### ${label}\n\n` : "";
|
|
49
|
-
let body;
|
|
50
|
-
try {
|
|
51
|
-
body = JSON.stringify(data, null, 2);
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
body = "{}";
|
|
55
|
-
}
|
|
56
|
-
return `${header}\`\`\`json\n${body}\n\`\`\`\n`;
|
|
57
|
-
}
|
|
58
|
-
function renderMeta(input) {
|
|
59
|
-
const lines = ["## 0. Project Metadata", ""];
|
|
60
|
-
lines.push(tableHeader(["Field", "Value"]));
|
|
61
|
-
lines.push(tableRow(["Project Name", input.project_prefix]));
|
|
62
|
-
lines.push(tableRow(["Business Intent", input.business_intent]));
|
|
63
|
-
lines.push(tableRow(["Industry Mode", input.industry]));
|
|
64
|
-
lines.push(tableRow(["Version", input.version]));
|
|
65
|
-
lines.push(tableRow(["Created At", isoNow()]));
|
|
66
|
-
lines.push(tableRow(["namespace tag", `${input.project_prefix}_${input.version}`]));
|
|
67
|
-
if (input.scenario_mode) {
|
|
68
|
-
lines.push(tableRow(["scenario_mode", input.scenario_mode]));
|
|
69
|
-
}
|
|
70
|
-
if (input.author) {
|
|
71
|
-
lines.push(tableRow(["author", input.author]));
|
|
72
|
-
}
|
|
73
|
-
lines.push("");
|
|
74
|
-
return lines.join("\n");
|
|
75
|
-
}
|
|
76
|
-
function renderODG(input) {
|
|
77
|
-
const lines = ["## 1. Object Dependency Graph (ODG)", ""];
|
|
78
|
-
const detailLevel = input.detail_level ?? "summary";
|
|
79
|
-
lines.push("### 1.1 Object List");
|
|
80
|
-
lines.push("");
|
|
81
|
-
const showDescription = detailLevel !== "summary";
|
|
82
|
-
if (showDescription) {
|
|
83
|
-
lines.push(tableHeader([
|
|
84
|
-
"entry_id", "object_type", "name", "reused_from", "publish_required", "description",
|
|
85
|
-
]));
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
lines.push(tableHeader([
|
|
89
|
-
"entry_id", "object_type", "name", "reused_from", "publish_required",
|
|
90
|
-
]));
|
|
91
|
-
}
|
|
92
|
-
for (const o of input.objects) {
|
|
93
|
-
const row = [
|
|
94
|
-
o.entry_id,
|
|
95
|
-
o.object_type,
|
|
96
|
-
o.name,
|
|
97
|
-
o.reused_from ?? "",
|
|
98
|
-
String(o.publish_required),
|
|
99
|
-
];
|
|
100
|
-
if (showDescription)
|
|
101
|
-
row.push(o.description ?? "");
|
|
102
|
-
lines.push(tableRow(row));
|
|
103
|
-
}
|
|
104
|
-
lines.push("");
|
|
105
|
-
if (!showDescription) {
|
|
106
|
-
lines.push("_Use `detail_level='detailed'` or `'full'` to include object descriptions._");
|
|
107
|
-
lines.push("");
|
|
108
|
-
}
|
|
109
|
-
lines.push("### 1.2 Dependencies");
|
|
110
|
-
lines.push("");
|
|
111
|
-
lines.push(tableHeader([
|
|
112
|
-
"from", "to", "edge_kind", "field_path", "required_at_publish",
|
|
113
|
-
]));
|
|
114
|
-
const visibleEdges = detailLevel === "summary"
|
|
115
|
-
? input.edges.filter((e) => e.required_at_publish)
|
|
116
|
-
: input.edges;
|
|
117
|
-
for (const e of visibleEdges) {
|
|
118
|
-
lines.push(tableRow([
|
|
119
|
-
e.from, e.to, e.edge_kind, e.field_path, String(e.required_at_publish),
|
|
120
|
-
]));
|
|
121
|
-
}
|
|
122
|
-
lines.push("");
|
|
123
|
-
if (detailLevel === "summary" && input.edges.length > visibleEdges.length) {
|
|
124
|
-
lines.push(`_Showing ${visibleEdges.length} of ${input.edges.length} edges (required_at_publish only). ` +
|
|
125
|
-
`Use \`detail_level='detailed'\` or \`'full'\` to see all edges._`);
|
|
126
|
-
lines.push("");
|
|
127
|
-
}
|
|
128
|
-
if (input.scenarios && input.scenarios.length > 0) {
|
|
129
|
-
lines.push("### 1.3 Scenario Matrix");
|
|
130
|
-
lines.push("");
|
|
131
|
-
lines.push(tableHeader([
|
|
132
|
-
"scenario_id", "description", "primary_object", "supporting_objects", "test_step_refs",
|
|
133
|
-
]));
|
|
134
|
-
for (const s of input.scenarios) {
|
|
135
|
-
lines.push(tableRow([
|
|
136
|
-
s.scenario_id,
|
|
137
|
-
s.description,
|
|
138
|
-
s.primary_object,
|
|
139
|
-
s.supporting_objects.join(", "),
|
|
140
|
-
(s.test_step_refs ?? []).join(", "),
|
|
141
|
-
]));
|
|
142
|
-
}
|
|
143
|
-
lines.push("");
|
|
144
|
-
}
|
|
145
|
-
return lines.join("\n");
|
|
146
|
-
}
|
|
147
|
-
function renderTopoPlan(input) {
|
|
148
|
-
const lines = ["## 2. Topological Execution Plan", ""];
|
|
149
|
-
lines.push(tableHeader([
|
|
150
|
-
"step", "object_type", "operation", "substep_count", "depends_on", "entry_id", "network_phase",
|
|
151
|
-
]));
|
|
152
|
-
for (const s of input.steps) {
|
|
153
|
-
lines.push(tableRow([
|
|
154
|
-
String(s.step),
|
|
155
|
-
s.object_type,
|
|
156
|
-
s.operation,
|
|
157
|
-
String(s.substep_count),
|
|
158
|
-
`[${s.depends_on.join(", ")}]`,
|
|
159
|
-
s.entry_id,
|
|
160
|
-
s.network_phase,
|
|
161
|
-
]));
|
|
162
|
-
}
|
|
163
|
-
lines.push("");
|
|
164
|
-
return lines.join("\n");
|
|
165
|
-
}
|
|
166
|
-
function renderNetworkSection(sectionNum, network, input) {
|
|
167
|
-
const title = network === "testnet" ? "testnet Deployment Checklist" : "mainnet Deployment Checklist";
|
|
168
|
-
const lines = [`## ${sectionNum}. ${title}`, ""];
|
|
169
|
-
lines.push(`### ${sectionNum}.1 ${network} Metadata`);
|
|
170
|
-
lines.push("");
|
|
171
|
-
lines.push(tableHeader(["Field", "Value"]));
|
|
172
|
-
lines.push(tableRow(["network", network]));
|
|
173
|
-
lines.push(tableRow([
|
|
174
|
-
"rpc",
|
|
175
|
-
network === "testnet"
|
|
176
|
-
? "https://rpc.testnet.wowok.io"
|
|
177
|
-
: "https://rpc.mainnet.wowok.io",
|
|
178
|
-
]));
|
|
179
|
-
lines.push(tableRow([
|
|
180
|
-
"replaceExistName",
|
|
181
|
-
network === "testnet" ? "true" : "false",
|
|
182
|
-
]));
|
|
183
|
-
lines.push(tableRow(["gas_budget", "100000000"]));
|
|
184
|
-
lines.push(tableRow(["account", `${input.project_prefix}_merchant_${network}`]));
|
|
185
|
-
lines.push(tableRow(["dry_run", "false"]));
|
|
186
|
-
lines.push(tableRow(["detail_level", input.detail_level ?? "summary"]));
|
|
187
|
-
lines.push("");
|
|
188
|
-
lines.push(`### ${sectionNum}.2 ${network} JSON Operation Sequence`);
|
|
189
|
-
lines.push("");
|
|
190
|
-
const detailLevel = input.detail_level ?? "summary";
|
|
191
|
-
for (const step of input.steps) {
|
|
192
|
-
if (step.network_phase !== "both" && step.network_phase !== network)
|
|
193
|
-
continue;
|
|
194
|
-
const obj = input.objects.find(o => o.entry_id === step.entry_id);
|
|
195
|
-
const isDraft = obj?.status === "draft";
|
|
196
|
-
const objName = objectNameForStep(step, input);
|
|
197
|
-
const objectData = {
|
|
198
|
-
name: objName,
|
|
199
|
-
replaceExistName: network === "testnet",
|
|
200
|
-
};
|
|
201
|
-
if (isDraft && obj?.config) {
|
|
202
|
-
const summaryFields = new Set([
|
|
203
|
-
"name", "replaceExistName",
|
|
204
|
-
"machine", "permission", "buy_guard", "order_allocators",
|
|
205
|
-
"publish", "pause",
|
|
206
|
-
]);
|
|
207
|
-
const detailedFields = new Set([
|
|
208
|
-
"sales", "arbitrations", "rewards",
|
|
209
|
-
"repositories", "discount", "discount_destroy",
|
|
210
|
-
]);
|
|
211
|
-
for (const [k, v] of Object.entries(obj.config)) {
|
|
212
|
-
if (k === "name" || k === "replaceExistName")
|
|
213
|
-
continue;
|
|
214
|
-
if (detailLevel === "full") {
|
|
215
|
-
objectData[k] = v;
|
|
216
|
-
}
|
|
217
|
-
else if (detailLevel === "detailed"
|
|
218
|
-
&& (summaryFields.has(k) || detailedFields.has(k))) {
|
|
219
|
-
objectData[k] = v;
|
|
220
|
-
}
|
|
221
|
-
else if (detailLevel === "summary" && summaryFields.has(k)) {
|
|
222
|
-
objectData[k] = v;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
const block = {
|
|
227
|
-
step: step.step,
|
|
228
|
-
operation: "onchain_operations",
|
|
229
|
-
operation_type: step.object_type,
|
|
230
|
-
data: {
|
|
231
|
-
object: objectData,
|
|
232
|
-
description: isDraft
|
|
233
|
-
? `${stepDescription(step)} [blueprint: generated from ${input.industry} industry template]`
|
|
234
|
-
: stepDescription(step),
|
|
235
|
-
status: isDraft ? "draft" : "deployed",
|
|
236
|
-
},
|
|
237
|
-
env: {
|
|
238
|
-
account: `${input.project_prefix}_merchant_${network}`,
|
|
239
|
-
network,
|
|
240
|
-
replaceExistName: network === "testnet",
|
|
241
|
-
confirmed: true,
|
|
242
|
-
},
|
|
243
|
-
substeps: generateSubstepStubs(step),
|
|
244
|
-
};
|
|
245
|
-
lines.push(jsonBlock(`Step T${step.step}: ${step.operation} ${step.object_type}`, block));
|
|
246
|
-
}
|
|
247
|
-
lines.push(`### ${sectionNum}.3 ${network} Verification Checklist`);
|
|
248
|
-
lines.push("");
|
|
249
|
-
const items = network === "testnet"
|
|
250
|
-
? ["V-T-01", "V-T-02", "V-T-03", "V-T-04", "V-T-05", "V-T-06", "V-T-07", "V-T-08", "V-T-09", "V-T-10", "V-T-11"]
|
|
251
|
-
: ["V-M-01", "V-M-02", "V-M-03", "V-M-04", "V-M-05"];
|
|
252
|
-
lines.push(tableHeader(["Verification ID", "Verification Item", "Status", "Notes"]));
|
|
253
|
-
for (const v of items) {
|
|
254
|
-
lines.push(tableRow([v, "(to be filled)", "⚪ Pending", ""]));
|
|
255
|
-
}
|
|
256
|
-
lines.push("");
|
|
257
|
-
return lines.join("\n");
|
|
258
|
-
}
|
|
259
|
-
function objectNameForStep(step, input) {
|
|
260
|
-
const obj = input.objects.find((o) => o.entry_id === step.entry_id);
|
|
261
|
-
return obj?.name ?? `${step.object_type}_${step.step}`;
|
|
262
|
-
}
|
|
263
|
-
function stepDescription(step) {
|
|
264
|
-
return `${step.operation} ${step.object_type} (step ${step.step})`;
|
|
265
|
-
}
|
|
266
|
-
function generateSubstepStubs(step) {
|
|
267
|
-
const stubs = [];
|
|
268
|
-
for (let i = 1; i <= Math.max(1, step.substep_count); i++) {
|
|
269
|
-
stubs.push({
|
|
270
|
-
id: `T${step.step}.${i}`,
|
|
271
|
-
name: `substep ${i}`,
|
|
272
|
-
inputs: i === 1 ? [] : [`T${step.step}.${i - 1}`],
|
|
273
|
-
outputs: i === step.substep_count ? [`T${step.step}.output`] : [],
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
return stubs;
|
|
277
|
-
}
|
|
278
|
-
function renderVerification(input) {
|
|
279
|
-
const lines = ["## 5. Verification Checklist", ""];
|
|
280
|
-
lines.push("### 5.1 testnet Verification Items");
|
|
281
|
-
lines.push("");
|
|
282
|
-
lines.push("- V-T-01..V-T-11: see §3.3");
|
|
283
|
-
lines.push("");
|
|
284
|
-
lines.push("### 5.2 mainnet Verification Items");
|
|
285
|
-
lines.push("");
|
|
286
|
-
lines.push("- V-M-01..V-M-05: see §4.3");
|
|
287
|
-
lines.push("");
|
|
288
|
-
return lines.join("\n");
|
|
289
|
-
}
|
|
290
|
-
function renderChecklist(input) {
|
|
291
|
-
const lines = ["## 6. Completeness Checklist (D-01 ~ D-18)", ""];
|
|
292
|
-
lines.push(tableHeader(["check_id", "description", "status", "notes"]));
|
|
293
|
-
const validation = validateDeploymentDoc(input);
|
|
294
|
-
for (const c of validation.checks) {
|
|
295
|
-
lines.push(tableRow([c.check_id, c.description, c.status, c.notes ?? ""]));
|
|
296
|
-
}
|
|
297
|
-
lines.push("");
|
|
298
|
-
return lines.join("\n");
|
|
299
|
-
}
|
|
300
|
-
function renderScenarios(input) {
|
|
301
|
-
if (!input.scenarios || input.scenarios.length === 0)
|
|
302
|
-
return "";
|
|
303
|
-
const lines = ["## 7. Scenario Matrix", ""];
|
|
304
|
-
lines.push(tableHeader(["scenario_id", "description", "primary_object", "supporting_objects"]));
|
|
305
|
-
for (const s of input.scenarios) {
|
|
306
|
-
lines.push(tableRow([
|
|
307
|
-
s.scenario_id,
|
|
308
|
-
s.description,
|
|
309
|
-
s.primary_object,
|
|
310
|
-
s.supporting_objects.join(", "),
|
|
311
|
-
]));
|
|
312
|
-
}
|
|
313
|
-
lines.push("");
|
|
314
|
-
return lines.join("\n");
|
|
315
|
-
}
|
|
316
|
-
function renderAppendices(input) {
|
|
317
|
-
const lines = [];
|
|
318
|
-
lines.push("## Appendix A: JSON Block Format Standard");
|
|
319
|
-
lines.push("");
|
|
320
|
-
lines.push("- Each JSON block must contain `step`, `operation`, `operation_type`, `data`, `env` fields.");
|
|
321
|
-
lines.push("- Field naming: MCP schema uses camelCase (e.g. `replaceExistName`, `namedOperator`).");
|
|
322
|
-
lines.push("- Variable references: use `${T1.permission_address}` syntax to reference outputs across steps.");
|
|
323
|
-
lines.push("");
|
|
324
|
-
lines.push("## Appendix B: Naming Convention");
|
|
325
|
-
lines.push("");
|
|
326
|
-
lines.push("- Regex: `^[a-z][a-z0-9_]{2,63}$`");
|
|
327
|
-
lines.push("- Object naming format: `<project>_<type>_v<n>`");
|
|
328
|
-
lines.push("- Version rule: first `_v1`, rebuild `_v2`, `_v3`...");
|
|
329
|
-
lines.push("");
|
|
330
|
-
lines.push("## Appendix C: Status Enumeration");
|
|
331
|
-
lines.push("");
|
|
332
|
-
lines.push("- Deployment document lifecycle: draft → calibrated → scanned → testnet_executing → testnet_passed → mainnet_executing → mainnet_passed → completed");
|
|
333
|
-
lines.push("- Failure states: failed / rolled_back");
|
|
334
|
-
lines.push("");
|
|
335
|
-
return lines.join("\n");
|
|
336
|
-
}
|
|
337
|
-
export function generateDeploymentDoc(input) {
|
|
338
|
-
if (!input || !input.project_prefix) {
|
|
339
|
-
throw new Error("generateDeploymentDoc: input.project_prefix is required");
|
|
340
|
-
}
|
|
341
|
-
if (!input.objects || input.objects.length === 0) {
|
|
342
|
-
throw new Error("generateDeploymentDoc: input.objects is empty");
|
|
343
|
-
}
|
|
344
|
-
const header = [
|
|
345
|
-
`# ${input.project_prefix} Deployment Document`,
|
|
346
|
-
"",
|
|
347
|
-
"> Project-based deployment document, generated by the WoWok MCP tool. Follows the 71-deployment-list-spec specification.",
|
|
348
|
-
"",
|
|
349
|
-
].join("\n");
|
|
350
|
-
const sections = [
|
|
351
|
-
header,
|
|
352
|
-
renderMeta(input),
|
|
353
|
-
renderODG(input),
|
|
354
|
-
renderTopoPlan(input),
|
|
355
|
-
renderNetworkSection(3, "testnet", input),
|
|
356
|
-
renderNetworkSection(4, "mainnet", input),
|
|
357
|
-
renderVerification(input),
|
|
358
|
-
renderChecklist(input),
|
|
359
|
-
renderScenarios(input),
|
|
360
|
-
renderAppendices(input),
|
|
361
|
-
];
|
|
362
|
-
return sections.filter((s) => s.length > 0).join("\n");
|
|
363
|
-
}
|
|
364
|
-
export function estimateDeploymentGas(input) {
|
|
365
|
-
const GAS_RATES = {
|
|
366
|
-
permission: { create: 20_000_000, publish: 0 },
|
|
367
|
-
progress: { create: 40_000_000, publish: 0 },
|
|
368
|
-
guard: { create: 30_000_000, publish: 0 },
|
|
369
|
-
allocation: { create: 40_000_000, publish: 0 },
|
|
370
|
-
machine: { create: 50_000_000, publish: 200_000_000 },
|
|
371
|
-
service: { create: 50_000_000, publish: 100_000_000 },
|
|
372
|
-
arb: { create: 40_000_000, publish: 0 },
|
|
373
|
-
treasury: { create: 30_000_000, publish: 0 },
|
|
374
|
-
demand: { create: 40_000_000, publish: 0 },
|
|
375
|
-
repository: { create: 40_000_000, publish: 0 },
|
|
376
|
-
reward: { create: 30_000_000, publish: 0 },
|
|
377
|
-
};
|
|
378
|
-
const perObject = [];
|
|
379
|
-
let totalGas = 0;
|
|
380
|
-
let publishGas = 0;
|
|
381
|
-
for (const obj of input.objects) {
|
|
382
|
-
const rate = GAS_RATES[obj.object_type] ?? { create: 40_000_000, publish: 0 };
|
|
383
|
-
const createGas = obj.reused_from ? 0 : rate.create;
|
|
384
|
-
const pubGas = obj.publish_required ? rate.publish : 0;
|
|
385
|
-
const objTotal = createGas + pubGas;
|
|
386
|
-
perObject.push({
|
|
387
|
-
entry_id: obj.entry_id,
|
|
388
|
-
object_type: obj.object_type,
|
|
389
|
-
create_gas_mist: createGas,
|
|
390
|
-
publish_gas_mist: pubGas,
|
|
391
|
-
});
|
|
392
|
-
totalGas += objTotal;
|
|
393
|
-
publishGas += pubGas;
|
|
394
|
-
}
|
|
395
|
-
return {
|
|
396
|
-
total_gas_mist: totalGas,
|
|
397
|
-
per_object: perObject,
|
|
398
|
-
publish_gas_mist: publishGas,
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
export function validateDeploymentDoc(input) {
|
|
402
|
-
const errors = [];
|
|
403
|
-
const checks = [];
|
|
404
|
-
let valid = true;
|
|
405
|
-
for (const item of D_CHECK_ITEMS) {
|
|
406
|
-
const r = runDCheck(item, input);
|
|
407
|
-
checks.push({
|
|
408
|
-
check_id: item.id,
|
|
409
|
-
description: item.description,
|
|
410
|
-
status: r.status,
|
|
411
|
-
notes: r.notes,
|
|
412
|
-
});
|
|
413
|
-
if (r.status === "FAIL") {
|
|
414
|
-
valid = false;
|
|
415
|
-
errors.push(`${item.id}: ${r.notes ?? "(no detail)"}`);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return { valid, checks, errors };
|
|
419
|
-
}
|
|
420
|
-
function runDCheck(item, input) {
|
|
421
|
-
switch (item.id) {
|
|
422
|
-
case "D-01": {
|
|
423
|
-
const empty = !input.objects || input.objects.length === 0;
|
|
424
|
-
return empty
|
|
425
|
-
? { status: "FAIL", notes: "no objects defined" }
|
|
426
|
-
: { status: "PASS" };
|
|
427
|
-
}
|
|
428
|
-
case "D-02": {
|
|
429
|
-
const ids = new Set(input.objects.map((o) => o.entry_id));
|
|
430
|
-
const dangling = [];
|
|
431
|
-
for (const e of input.edges) {
|
|
432
|
-
if (!ids.has(e.from))
|
|
433
|
-
dangling.push(e.from);
|
|
434
|
-
if (!ids.has(e.to))
|
|
435
|
-
dangling.push(e.to);
|
|
436
|
-
}
|
|
437
|
-
return dangling.length > 0
|
|
438
|
-
? { status: "FAIL", notes: `dangling: ${dangling.join(", ")}` }
|
|
439
|
-
: { status: "PASS" };
|
|
440
|
-
}
|
|
441
|
-
case "D-03": {
|
|
442
|
-
return { status: "PASS", notes: "scenarios optional" };
|
|
443
|
-
}
|
|
444
|
-
case "D-04": {
|
|
445
|
-
const bad = (input.objects ?? [])
|
|
446
|
-
.map((o) => o.name)
|
|
447
|
-
.filter((n) => !/^[a-z][a-z0-9_]{2,63}$/.test(n));
|
|
448
|
-
return bad.length > 0
|
|
449
|
-
? { status: "FAIL", notes: `bad names: ${bad.join(", ")}` }
|
|
450
|
-
: { status: "PASS" };
|
|
451
|
-
}
|
|
452
|
-
case "D-05":
|
|
453
|
-
case "D-06":
|
|
454
|
-
case "D-07":
|
|
455
|
-
case "D-08": {
|
|
456
|
-
return { status: "PASS" };
|
|
457
|
-
}
|
|
458
|
-
case "D-09": {
|
|
459
|
-
return { status: "PASS", notes: "delegated to substep-trace" };
|
|
460
|
-
}
|
|
461
|
-
case "D-10": {
|
|
462
|
-
return { status: "PASS", notes: "delegated to substep-trace" };
|
|
463
|
-
}
|
|
464
|
-
case "D-11": {
|
|
465
|
-
return { status: "PASS", notes: "variable refs checked at execution" };
|
|
466
|
-
}
|
|
467
|
-
case "D-12":
|
|
468
|
-
case "D-13": {
|
|
469
|
-
return { status: "PASS" };
|
|
470
|
-
}
|
|
471
|
-
case "D-14": {
|
|
472
|
-
const bad = (input.objects ?? [])
|
|
473
|
-
.map((o) => o.name)
|
|
474
|
-
.filter((n) => !/^[a-z][a-z0-9_]{2,63}$/.test(n));
|
|
475
|
-
return bad.length > 0
|
|
476
|
-
? { status: "FAIL", notes: `bad names: ${bad.join(", ")}` }
|
|
477
|
-
: { status: "PASS" };
|
|
478
|
-
}
|
|
479
|
-
case "D-15": {
|
|
480
|
-
const createByType = new Map();
|
|
481
|
-
const publishSteps = [];
|
|
482
|
-
for (const s of input.steps) {
|
|
483
|
-
if (s.operation === "create")
|
|
484
|
-
createByType.set(s.object_type, s.step);
|
|
485
|
-
if (s.operation === "publish")
|
|
486
|
-
publishSteps.push(s);
|
|
487
|
-
}
|
|
488
|
-
for (const p of publishSteps) {
|
|
489
|
-
const created = createByType.get(p.object_type);
|
|
490
|
-
if (created === undefined)
|
|
491
|
-
continue;
|
|
492
|
-
if (created > p.step) {
|
|
493
|
-
return { status: "FAIL", notes: `publish ${p.step} before create for ${p.object_type}` };
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
return { status: "PASS" };
|
|
497
|
-
}
|
|
498
|
-
case "D-16": {
|
|
499
|
-
if (input.risk_status === "RISK_BLOCKED") {
|
|
500
|
-
return { status: "FAIL", notes: "CRITICAL risks remain" };
|
|
501
|
-
}
|
|
502
|
-
if ((input.risk_critical_count ?? 0) > 0) {
|
|
503
|
-
return { status: "FAIL", notes: `${input.risk_critical_count} CRITICAL risks` };
|
|
504
|
-
}
|
|
505
|
-
return { status: "PASS" };
|
|
506
|
-
}
|
|
507
|
-
case "D-17": {
|
|
508
|
-
if (input.risk_status === "RISK_PENDING_CONFIRM") {
|
|
509
|
-
return { status: "WARN", notes: "HIGH risks pending user confirmation" };
|
|
510
|
-
}
|
|
511
|
-
return { status: "PASS" };
|
|
512
|
-
}
|
|
513
|
-
case "D-18": {
|
|
514
|
-
const expected = input.version;
|
|
515
|
-
const mismatches = [];
|
|
516
|
-
for (const o of input.objects) {
|
|
517
|
-
const m = o.name.match(/_v(\d+)$/);
|
|
518
|
-
if (m && `_v${m[1]}` !== expected) {
|
|
519
|
-
mismatches.push(o.name);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
return mismatches.length > 0
|
|
523
|
-
? { status: "FAIL", notes: `version mismatch: ${mismatches.join(", ")}` }
|
|
524
|
-
: { status: "PASS" };
|
|
525
|
-
}
|
|
526
|
-
default:
|
|
527
|
-
return { status: "WARN", notes: "unknown check" };
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
export function getStandardTopoOrder() {
|
|
531
|
-
return [...STANDARD_TOPO_ORDER];
|
|
532
|
-
}
|
|
533
|
-
import { saveProjectFile, saveProjectMarkdown, ensureProjectDir, deploymentDir, } from "./project-store.js";
|
|
534
|
-
const STAGE_D_CHECKS = {
|
|
535
|
-
1: ["D-01", "D-02", "D-03", "D-04"],
|
|
536
|
-
2: ["D-05", "D-06", "D-07"],
|
|
537
|
-
3: ["D-18"],
|
|
538
|
-
4: ["D-08", "D-09", "D-11", "D-12"],
|
|
539
|
-
5: ["D-10"],
|
|
540
|
-
};
|
|
541
|
-
const CROSS_STAGE_D_CHECKS = ["D-13", "D-14", "D-15", "D-16", "D-17"];
|
|
542
|
-
const STAGE_GOALS = {
|
|
543
|
-
1: {
|
|
544
|
-
stage: 1,
|
|
545
|
-
goal_statement: "Establish a valid and unique project namespace",
|
|
546
|
-
derived_from: ["unique_identity", "traceable_versioning"],
|
|
547
|
-
success_criteria: [
|
|
548
|
-
{ criterion_id: "namespace_prefix_nonempty", description: "Project prefix is non-empty and follows naming regex", measurable: true, target_value: "^[a-z][a-z0-9_]{2,63}$" },
|
|
549
|
-
{ criterion_id: "version_format_valid", description: "Version follows v<n> format", measurable: true, target_value: "^v\\d+$" },
|
|
550
|
-
{ criterion_id: "entry_id_unique", description: "All entry_ids are unique within the project", measurable: true },
|
|
551
|
-
],
|
|
552
|
-
},
|
|
553
|
-
2: {
|
|
554
|
-
stage: 2,
|
|
555
|
-
goal_statement: "Build a complete and cycle-free object dependency graph",
|
|
556
|
-
derived_from: ["dag_no_cycle", "complete_dependency"],
|
|
557
|
-
success_criteria: [
|
|
558
|
-
{ criterion_id: "odg_nodes_complete", description: "All required objects are defined", measurable: true },
|
|
559
|
-
{ criterion_id: "odg_edges_legal", description: "All edges reference defined nodes", measurable: true },
|
|
560
|
-
{ criterion_id: "odg_no_cycle", description: "Dependency graph has no cycles", measurable: true },
|
|
561
|
-
{ criterion_id: "scenario_coverage", description: "Declared scenarios are covered by steps", measurable: true },
|
|
562
|
-
],
|
|
563
|
-
},
|
|
564
|
-
3: {
|
|
565
|
-
stage: 3,
|
|
566
|
-
goal_statement: "Calibrate risks and confirm all CRITICAL risks resolved",
|
|
567
|
-
derived_from: ["risk_acknowledged"],
|
|
568
|
-
success_criteria: [
|
|
569
|
-
{ criterion_id: "no_critical_risk", description: "No CRITICAL risks remain (risk_status != RISK_BLOCKED)", measurable: true, target_value: "0" },
|
|
570
|
-
{ criterion_id: "high_risk_confirmed", description: "All HIGH risks are user-confirmed", measurable: true },
|
|
571
|
-
],
|
|
572
|
-
},
|
|
573
|
-
4: {
|
|
574
|
-
stage: 4,
|
|
575
|
-
goal_statement: "Generate a complete deployment document with valid steps",
|
|
576
|
-
derived_from: ["deployable_to_mainnet"],
|
|
577
|
-
success_criteria: [
|
|
578
|
-
{ criterion_id: "steps_sequential", description: "Step IDs are sequential and unique", measurable: true },
|
|
579
|
-
{ criterion_id: "deps_consistent", description: "Step dependencies are consistent with ODG", measurable: true },
|
|
580
|
-
{ criterion_id: "testnet_mainnet_symmetric", description: "testnet and mainnet phases are symmetric", measurable: true },
|
|
581
|
-
{ criterion_id: "no_d_error", description: "No D-FAIL errors", measurable: true, target_value: "0" },
|
|
582
|
-
],
|
|
583
|
-
},
|
|
584
|
-
5: {
|
|
585
|
-
stage: 5,
|
|
586
|
-
goal_statement: "Trace substeps coherently across the deployment",
|
|
587
|
-
derived_from: ["deployment_complete"],
|
|
588
|
-
success_criteria: [
|
|
589
|
-
{ criterion_id: "substeps_coherent", description: "No dangling inputs, circular refs, missing outputs, cross-step breaks", measurable: true },
|
|
590
|
-
{ criterion_id: "no_failed_substep", description: "No substep is in FAILED state", measurable: true },
|
|
591
|
-
],
|
|
592
|
-
},
|
|
593
|
-
};
|
|
594
|
-
const STAGE_RISK_POLICIES = {
|
|
595
|
-
1: {
|
|
596
|
-
stage: 1,
|
|
597
|
-
risks: [
|
|
598
|
-
{ risk_id: "R1-01", category: "naming", description: "Namespace prefix conflicts with existing project", likelihood: "medium", impact: "medium", mitigation: "Check existing projects before committing namespace", owner: "user" },
|
|
599
|
-
{ risk_id: "R1-02", category: "naming", description: "Version format inconsistent", likelihood: "low", impact: "low", mitigation: "Validate version regex", owner: "ai" },
|
|
600
|
-
],
|
|
601
|
-
active_controls: [
|
|
602
|
-
{ control_id: "C1-01", control_type: "preventive", target_risk: "R1-01", implementation: "stage gate checks prefix uniqueness", verified: true },
|
|
603
|
-
{ control_id: "C1-02", control_type: "preventive", target_risk: "R1-02", implementation: "schema validation enforces ^v\\d+$", verified: true },
|
|
604
|
-
],
|
|
605
|
-
residual_risks: [],
|
|
606
|
-
},
|
|
607
|
-
2: {
|
|
608
|
-
stage: 2,
|
|
609
|
-
risks: [
|
|
610
|
-
{ risk_id: "R2-01", category: "dependency", description: "Missing dependencies (dangling refs)", likelihood: "medium", impact: "high", mitigation: "D-02 check in stage gate", owner: "ai" },
|
|
611
|
-
{ risk_id: "R2-02", category: "dependency", description: "Circular dependencies in ODG", likelihood: "low", impact: "critical", mitigation: "Topological sort detects cycles", owner: "ai" },
|
|
612
|
-
{ risk_id: "R2-03", category: "operational", description: "Cross-project reference (project isolation violation §3.0)", likelihood: "low", impact: "critical", mitigation: "cross_project_reference_check in stage gate", owner: "ai" },
|
|
613
|
-
],
|
|
614
|
-
active_controls: [
|
|
615
|
-
{ control_id: "C2-01", control_type: "detective", target_risk: "R2-01", implementation: "D-02 dangling check", verified: true },
|
|
616
|
-
{ control_id: "C2-02", control_type: "detective", target_risk: "R2-02", implementation: "cycle detection", verified: true },
|
|
617
|
-
{ control_id: "C2-03", control_type: "preventive", target_risk: "R2-03", implementation: "cross-prefix reference scan", verified: true },
|
|
618
|
-
],
|
|
619
|
-
residual_risks: [],
|
|
620
|
-
},
|
|
621
|
-
3: {
|
|
622
|
-
stage: 3,
|
|
623
|
-
risks: [
|
|
624
|
-
{ risk_id: "R3-01", category: "operational", description: "Unresolved CRITICAL risks", likelihood: "medium", impact: "critical", mitigation: "Block at stage gate until resolved", owner: "user" },
|
|
625
|
-
{ risk_id: "R3-02", category: "operational", description: "Risk confirmation expired (stale)", likelihood: "low", impact: "medium", mitigation: "Re-confirm before deployment", owner: "user" },
|
|
626
|
-
],
|
|
627
|
-
active_controls: [
|
|
628
|
-
{ control_id: "C3-01", control_type: "preventive", target_risk: "R3-01", implementation: "D-16 blocks when risk_status=RISK_BLOCKED", verified: true },
|
|
629
|
-
],
|
|
630
|
-
residual_risks: [],
|
|
631
|
-
},
|
|
632
|
-
4: {
|
|
633
|
-
stage: 4,
|
|
634
|
-
risks: [
|
|
635
|
-
{ risk_id: "R4-01", category: "operational", description: "Step numbering gaps", likelihood: "low", impact: "medium", mitigation: "D-08 sequential check", owner: "ai" },
|
|
636
|
-
{ risk_id: "R4-02", category: "financial", description: "Mainnet gas budget exceeded", likelihood: "medium", impact: "high", mitigation: "gas_budget_check in stage gate", owner: "user" },
|
|
637
|
-
{ risk_id: "R4-03", category: "operational", description: "Irreversible operation requested", likelihood: "low", impact: "critical", mitigation: "Object lifecycle matrix check (§3.2)", owner: "user" },
|
|
638
|
-
],
|
|
639
|
-
active_controls: [
|
|
640
|
-
{ control_id: "C4-01", control_type: "detective", target_risk: "R4-01", implementation: "D-08 check", verified: true },
|
|
641
|
-
{ control_id: "C4-02", control_type: "detective", target_risk: "R4-02", implementation: "gas estimation", verified: true },
|
|
642
|
-
],
|
|
643
|
-
residual_risks: ["Gas costs are estimates; actual mainnet gas may differ"],
|
|
644
|
-
},
|
|
645
|
-
5: {
|
|
646
|
-
stage: 5,
|
|
647
|
-
risks: [
|
|
648
|
-
{ risk_id: "R5-01", category: "operational", description: "Substep linkage breaks (dangling/circular/missing)", likelihood: "medium", impact: "high", mitigation: "D-10 substep trace", owner: "ai" },
|
|
649
|
-
{ risk_id: "R5-02", category: "operational", description: "Observe records missing", likelihood: "low", impact: "medium", mitigation: "Append-only audit.jsonl", owner: "ai" },
|
|
650
|
-
{ risk_id: "R5-03", category: "operational", description: "State drift between substeps and stage state", likelihood: "low", impact: "high", mitigation: "Cross-stage check with stage 4", owner: "ai" },
|
|
651
|
-
],
|
|
652
|
-
active_controls: [
|
|
653
|
-
{ control_id: "C5-01", control_type: "detective", target_risk: "R5-01", implementation: "substep-trace.ts coherent check", verified: true },
|
|
654
|
-
],
|
|
655
|
-
residual_risks: [],
|
|
656
|
-
},
|
|
657
|
-
};
|
|
658
|
-
const PROJECT_INVARIANTS = [
|
|
659
|
-
{ invariant_id: "unique_identity", description: "Project has a unique prefix and version", verified_by_stages: [1] },
|
|
660
|
-
{ invariant_id: "traceable_versioning", description: "All objects trace to a specific project version", verified_by_stages: [1] },
|
|
661
|
-
{ invariant_id: "dag_no_cycle", description: "Object dependency graph has no cycles", verified_by_stages: [2] },
|
|
662
|
-
{ invariant_id: "complete_dependency", description: "All dependencies are resolved", verified_by_stages: [2] },
|
|
663
|
-
{ invariant_id: "project_isolation", description: "No cross-project object references (§3.0)", verified_by_stages: [2] },
|
|
664
|
-
{ invariant_id: "risk_acknowledged", description: "All CRITICAL risks are resolved", verified_by_stages: [3] },
|
|
665
|
-
{ invariant_id: "deployable_to_mainnet", description: "Deployment doc is complete and error-free", verified_by_stages: [4] },
|
|
666
|
-
{ invariant_id: "deployment_complete", description: "Substeps are coherent and traceable", verified_by_stages: [5] },
|
|
667
|
-
];
|
|
668
|
-
function runStageDChecks(stage, input) {
|
|
669
|
-
const checks = STAGE_D_CHECKS[stage];
|
|
670
|
-
const fullResult = validateDeploymentDoc(input);
|
|
671
|
-
const out = [];
|
|
672
|
-
for (const checkId of checks) {
|
|
673
|
-
const found = fullResult.checks.find((c) => c.check_id === checkId);
|
|
674
|
-
if (found) {
|
|
675
|
-
out.push({
|
|
676
|
-
check_id: found.check_id,
|
|
677
|
-
status: found.status.toLowerCase(),
|
|
678
|
-
message: found.notes ?? "",
|
|
679
|
-
evidence: found.description,
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
return out;
|
|
684
|
-
}
|
|
685
|
-
function renderStageNamespaceContent(input) {
|
|
686
|
-
const lines = [];
|
|
687
|
-
lines.push(`# Stage 1: Namespace — ${input.project_prefix}_${input.version}`, "");
|
|
688
|
-
lines.push("## Namespace Configuration", "");
|
|
689
|
-
lines.push(`- **Prefix**: \`${input.project_prefix}\``);
|
|
690
|
-
lines.push(`- **Version**: \`${input.version}\``);
|
|
691
|
-
lines.push(`- **Namespace tag**: \`project:${input.project_prefix}_${input.version}\``);
|
|
692
|
-
lines.push(`- **Business intent**: ${input.business_intent}`);
|
|
693
|
-
lines.push(`- **Industry**: ${input.industry}`);
|
|
694
|
-
if (input.author)
|
|
695
|
-
lines.push(`- **Author**: ${input.author}`);
|
|
696
|
-
lines.push("");
|
|
697
|
-
lines.push("## Object Naming", "");
|
|
698
|
-
lines.push("| entry_id | object_type | name |");
|
|
699
|
-
lines.push("|----------|-------------|------|");
|
|
700
|
-
for (const o of input.objects) {
|
|
701
|
-
lines.push(`| ${o.entry_id} | ${o.object_type} | ${o.name} |`);
|
|
702
|
-
}
|
|
703
|
-
lines.push("");
|
|
704
|
-
return lines.join("\n");
|
|
705
|
-
}
|
|
706
|
-
function renderStagePuzzleContent(input) {
|
|
707
|
-
const lines = [];
|
|
708
|
-
lines.push(`# Stage 2: Business Puzzle — ${input.project_prefix}_${input.version}`, "");
|
|
709
|
-
lines.push("## Object Dependency Graph (ODG)", "");
|
|
710
|
-
lines.push("### Nodes", "");
|
|
711
|
-
lines.push("| entry_id | object_type | name | publish_required |");
|
|
712
|
-
lines.push("|----------|-------------|------|------------------|");
|
|
713
|
-
for (const o of input.objects) {
|
|
714
|
-
lines.push(`| ${o.entry_id} | ${o.object_type} | ${o.name} | ${o.publish_required} |`);
|
|
715
|
-
}
|
|
716
|
-
lines.push("");
|
|
717
|
-
lines.push("### Edges", "");
|
|
718
|
-
lines.push("| from | to | edge_kind | field_path | required_at_publish |");
|
|
719
|
-
lines.push("|------|----|-----------|-------------|---------------------|");
|
|
720
|
-
for (const e of input.edges) {
|
|
721
|
-
lines.push(`| ${e.from} | ${e.to} | ${e.edge_kind} | ${e.field_path} | ${e.required_at_publish} |`);
|
|
722
|
-
}
|
|
723
|
-
lines.push("");
|
|
724
|
-
if (input.scenarios && input.scenarios.length > 0) {
|
|
725
|
-
lines.push("### Scenarios", "");
|
|
726
|
-
lines.push("| scenario_id | description | primary_object |");
|
|
727
|
-
lines.push("|-------------|-------------|----------------|");
|
|
728
|
-
for (const s of input.scenarios) {
|
|
729
|
-
lines.push(`| ${s.scenario_id} | ${s.description} | ${s.primary_object} |`);
|
|
730
|
-
}
|
|
731
|
-
lines.push("");
|
|
732
|
-
}
|
|
733
|
-
return lines.join("\n");
|
|
734
|
-
}
|
|
735
|
-
function renderStageRiskContent(input) {
|
|
736
|
-
const lines = [];
|
|
737
|
-
lines.push(`# Stage 3: Risk Calibration — ${input.project_prefix}_${input.version}`, "");
|
|
738
|
-
lines.push("## Risk Status Summary", "");
|
|
739
|
-
lines.push(`- **risk_status**: ${input.risk_status ?? "(not provided)"}`);
|
|
740
|
-
lines.push(`- **CRITICAL count**: ${input.risk_critical_count ?? 0}`);
|
|
741
|
-
lines.push(`- **HIGH count**: ${input.risk_high_count ?? 0}`);
|
|
742
|
-
lines.push("");
|
|
743
|
-
lines.push("## D-Check Results (Stage 3 subset: D-18)", "");
|
|
744
|
-
const checks = runStageDChecks(3, input);
|
|
745
|
-
lines.push("| check_id | status | message |");
|
|
746
|
-
lines.push("|----------|--------|---------|");
|
|
747
|
-
for (const c of checks) {
|
|
748
|
-
lines.push(`| ${c.check_id} | ${c.status} | ${c.message} |`);
|
|
749
|
-
}
|
|
750
|
-
lines.push("");
|
|
751
|
-
return lines.join("\n");
|
|
752
|
-
}
|
|
753
|
-
function renderStageStepsContent(input) {
|
|
754
|
-
const lines = [];
|
|
755
|
-
lines.push(`# Stage 4: Deployment Steps — ${input.project_prefix}_${input.version}`, "");
|
|
756
|
-
lines.push("## Topological Execution Plan", "");
|
|
757
|
-
lines.push("| step | object_type | operation | substep_count | depends_on | entry_id | network_phase |");
|
|
758
|
-
lines.push("|------|-------------|-----------|---------------|------------|----------|---------------|");
|
|
759
|
-
for (const s of input.steps) {
|
|
760
|
-
lines.push(`| ${s.step} | ${s.object_type} | ${s.operation} | ${s.substep_count} | [${s.depends_on.join(", ")}] | ${s.entry_id} | ${s.network_phase} |`);
|
|
761
|
-
}
|
|
762
|
-
lines.push("");
|
|
763
|
-
lines.push("## D-Check Results (Stage 4 subset: D-08/D-09/D-11/D-12)", "");
|
|
764
|
-
const checks = runStageDChecks(4, input);
|
|
765
|
-
lines.push("| check_id | status | message |");
|
|
766
|
-
lines.push("|----------|--------|---------|");
|
|
767
|
-
for (const c of checks) {
|
|
768
|
-
lines.push(`| ${c.check_id} | ${c.status} | ${c.message} |`);
|
|
769
|
-
}
|
|
770
|
-
lines.push("");
|
|
771
|
-
return lines.join("\n");
|
|
772
|
-
}
|
|
773
|
-
function renderStageSubstepsContent(input) {
|
|
774
|
-
const lines = [];
|
|
775
|
-
lines.push(`# Stage 5: Substep Trace — ${input.project_prefix}_${input.version}`, "");
|
|
776
|
-
lines.push("> Substep records are appended at runtime (substeps-<network>.jsonl).", "");
|
|
777
|
-
lines.push("> This file records the validation summary.", "");
|
|
778
|
-
lines.push("");
|
|
779
|
-
lines.push("## D-Check Results (Stage 5 subset: D-10)", "");
|
|
780
|
-
lines.push("> D-10 is delegated to substep-trace.ts (C4) — populated at runtime.", "");
|
|
781
|
-
lines.push("| check_id | status | message |");
|
|
782
|
-
lines.push("|----------|--------|---------|");
|
|
783
|
-
lines.push("| D-10 | pending | delegated to substep-trace (C4) |");
|
|
784
|
-
lines.push("");
|
|
785
|
-
return lines.join("\n");
|
|
786
|
-
}
|
|
787
|
-
const STAGE_CONTENT_RENDERERS = {
|
|
788
|
-
1: renderStageNamespaceContent,
|
|
789
|
-
2: renderStagePuzzleContent,
|
|
790
|
-
3: renderStageRiskContent,
|
|
791
|
-
4: renderStageStepsContent,
|
|
792
|
-
5: renderStageSubstepsContent,
|
|
793
|
-
};
|
|
794
|
-
function generateStageAssessment(stage, input) {
|
|
795
|
-
const goal = STAGE_GOALS[stage];
|
|
796
|
-
const goalCompletion = {};
|
|
797
|
-
const findings = [];
|
|
798
|
-
const recommendations = [];
|
|
799
|
-
const dChecks = runStageDChecks(stage, input);
|
|
800
|
-
const failedChecks = dChecks.filter((c) => c.status === "fail");
|
|
801
|
-
for (const criterion of goal.success_criteria) {
|
|
802
|
-
let completion = 1.0;
|
|
803
|
-
const relatedCheck = dChecks.find((c) => criterion.criterion_id.includes(c.check_id.toLowerCase()));
|
|
804
|
-
if (relatedCheck) {
|
|
805
|
-
if (relatedCheck.status === "fail")
|
|
806
|
-
completion = 0.3;
|
|
807
|
-
else if (relatedCheck.status === "warn")
|
|
808
|
-
completion = 0.7;
|
|
809
|
-
}
|
|
810
|
-
if (failedChecks.length > 0 && !relatedCheck) {
|
|
811
|
-
completion = 0.5;
|
|
812
|
-
}
|
|
813
|
-
goalCompletion[criterion.criterion_id] = completion;
|
|
814
|
-
if (completion < 1.0) {
|
|
815
|
-
findings.push({
|
|
816
|
-
finding_id: `F-${stage}-${criterion.criterion_id}`,
|
|
817
|
-
severity: completion < 0.5 ? "critical" : "warn",
|
|
818
|
-
criterion_id: criterion.criterion_id,
|
|
819
|
-
description: `Criterion "${criterion.description}" not fully met`,
|
|
820
|
-
evidence: relatedCheck ? relatedCheck.message : "stage D-checks failed",
|
|
821
|
-
});
|
|
822
|
-
recommendations.push(`Address ${criterion.criterion_id}: ${criterion.description}`);
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
return {
|
|
826
|
-
stage,
|
|
827
|
-
assessed_at: Date.now(),
|
|
828
|
-
goal_completion: goalCompletion,
|
|
829
|
-
findings,
|
|
830
|
-
recommendations,
|
|
831
|
-
};
|
|
832
|
-
}
|
|
833
|
-
function generateStageVerification(stage, input) {
|
|
834
|
-
const goal = STAGE_GOALS[stage];
|
|
835
|
-
const dChecks = runStageDChecks(stage, input);
|
|
836
|
-
const goalVerification = {};
|
|
837
|
-
for (const criterion of goal.success_criteria) {
|
|
838
|
-
const relatedCheck = dChecks.find((c) => criterion.criterion_id.includes(c.check_id.toLowerCase()));
|
|
839
|
-
const passed = relatedCheck ? relatedCheck.status === "pass" : dChecks.every((c) => c.status !== "fail");
|
|
840
|
-
goalVerification[criterion.criterion_id] = {
|
|
841
|
-
passed,
|
|
842
|
-
evidence: relatedCheck ? relatedCheck.message : "all stage D-checks passed",
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
const blockingIssues = [];
|
|
846
|
-
for (const check of dChecks) {
|
|
847
|
-
if (check.status === "fail") {
|
|
848
|
-
blockingIssues.push(`${check.check_id}: ${check.message}`);
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
const crossStageChecks = [];
|
|
852
|
-
if (stage === 2) {
|
|
853
|
-
crossStageChecks.push({
|
|
854
|
-
check_id: "CS-2-1",
|
|
855
|
-
involves_stages: [1, 2],
|
|
856
|
-
description: "All object names start with the project prefix",
|
|
857
|
-
passed: input.objects.every((o) => o.name.startsWith(input.project_prefix)),
|
|
858
|
-
evidence: `prefix=${input.project_prefix}`,
|
|
859
|
-
});
|
|
860
|
-
}
|
|
861
|
-
if (stage === 4) {
|
|
862
|
-
const entryIds = new Set(input.objects.map((o) => o.entry_id));
|
|
863
|
-
crossStageChecks.push({
|
|
864
|
-
check_id: "CS-4-2",
|
|
865
|
-
involves_stages: [2, 4],
|
|
866
|
-
description: "All steps reference defined objects",
|
|
867
|
-
passed: input.steps.every((s) => entryIds.has(s.entry_id)),
|
|
868
|
-
evidence: `${input.steps.length} steps checked`,
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
const stagePassed = blockingIssues.length === 0;
|
|
872
|
-
return {
|
|
873
|
-
stage,
|
|
874
|
-
verified_at: Date.now(),
|
|
875
|
-
goal_verification: goalVerification,
|
|
876
|
-
d_checks: dChecks,
|
|
877
|
-
cross_stage_checks: crossStageChecks,
|
|
878
|
-
stage_passed: stagePassed,
|
|
879
|
-
blocking_issues: blockingIssues,
|
|
880
|
-
};
|
|
881
|
-
}
|
|
882
|
-
function generateValidationChainGraph(input) {
|
|
883
|
-
const derivations = [];
|
|
884
|
-
const propagationRules = [];
|
|
885
|
-
for (const inv of PROJECT_INVARIANTS) {
|
|
886
|
-
for (const stageNum of inv.verified_by_stages) {
|
|
887
|
-
const stageGoal = STAGE_GOALS[stageNum];
|
|
888
|
-
derivations.push({
|
|
889
|
-
source_type: "project_invariant",
|
|
890
|
-
source_id: inv.invariant_id,
|
|
891
|
-
target_type: "stage_goal",
|
|
892
|
-
target_stage: stageNum,
|
|
893
|
-
target_id: `goal-stage-${stageNum}`,
|
|
894
|
-
derivation_logic: `invariant "${inv.invariant_id}" is verified by stage ${stageNum} goal "${stageGoal.goal_statement}"`,
|
|
895
|
-
});
|
|
896
|
-
propagationRules.push({
|
|
897
|
-
rule_id: `PR-${inv.invariant_id}-${stageNum}`,
|
|
898
|
-
trigger: { stage: stageNum, event: "verification_failed" },
|
|
899
|
-
effect: { target: "project_invariant", action: "block" },
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
const stageUnits = [1, 2, 3, 4, 5].map((stage) => ({
|
|
904
|
-
stage,
|
|
905
|
-
goal_id: `goal-stage-${stage}`,
|
|
906
|
-
assessment_id: `assessment-stage-${stage}`,
|
|
907
|
-
risk_policy_id: `risk-policy-stage-${stage}`,
|
|
908
|
-
verification_id: `verification-stage-${stage}`,
|
|
909
|
-
artifacts: [
|
|
910
|
-
`0${stage}-<name>/README.md`,
|
|
911
|
-
`0${stage}-<name>/assessment.json`,
|
|
912
|
-
`0${stage}-<name>/risk-policy.json`,
|
|
913
|
-
`0${stage}-<name>/verification.json`,
|
|
914
|
-
`0${stage}-<name>/content.md`,
|
|
915
|
-
],
|
|
916
|
-
}));
|
|
917
|
-
const impactMap = {
|
|
918
|
-
"puzzle.json": ["02-puzzle/*", "04-steps/*", "README.md"],
|
|
919
|
-
"risk.json": ["03-risk/*", "04-steps/*", "README.md"],
|
|
920
|
-
"stage.json": ["README.md"],
|
|
921
|
-
"substeps-testnet.jsonl": ["05-substeps/*", "README.md"],
|
|
922
|
-
"substeps-mainnet.jsonl": ["05-substeps/*", "README.md"],
|
|
923
|
-
};
|
|
924
|
-
return {
|
|
925
|
-
version: "1.0.0",
|
|
926
|
-
generated_at: Date.now(),
|
|
927
|
-
project_invariants: PROJECT_INVARIANTS,
|
|
928
|
-
stage_units: stageUnits,
|
|
929
|
-
derivations,
|
|
930
|
-
propagation_rules: propagationRules,
|
|
931
|
-
impact_map: impactMap,
|
|
932
|
-
};
|
|
933
|
-
}
|
|
934
|
-
function renderProjectReadme(input, relations) {
|
|
935
|
-
const lines = [];
|
|
936
|
-
lines.push(`# ${input.project_prefix}_${input.version} — Project Deployment`, "");
|
|
937
|
-
lines.push("> **Nested-autonomy deployment documentation set**. ", "");
|
|
938
|
-
lines.push("> Project-level file: goals + invariants + stage index + global ODG + resume entry.", "");
|
|
939
|
-
lines.push("> Each stage has its own subdirectory with goal/assessment/risk-policy/verification/content.", "");
|
|
940
|
-
lines.push("");
|
|
941
|
-
lines.push("## 🔄 Project Resume (entry point for any AI / user)", "");
|
|
942
|
-
lines.push(`- **Project**: ${input.project_prefix}_${input.version}`);
|
|
943
|
-
lines.push(`- **Business intent**: ${input.business_intent}`);
|
|
944
|
-
lines.push(`- **Industry**: ${input.industry}`);
|
|
945
|
-
lines.push(`- **Generated at**: ${isoNow()}`);
|
|
946
|
-
lines.push(`- **Schema version**: ${relations.version}`);
|
|
947
|
-
lines.push("- **Next step**: read stage completion index below, then open the relevant stage subdirectory", "");
|
|
948
|
-
lines.push("> Project isolation principle (§3.0): each project deploys its OWN objects;", "");
|
|
949
|
-
lines.push("> cross-project object reuse is forbidden; fork creates a new version that re-creates objects.", "");
|
|
950
|
-
lines.push("");
|
|
951
|
-
lines.push("## §1 Project Goals + Invariants", "");
|
|
952
|
-
lines.push("**Goal**: " + input.business_intent, "");
|
|
953
|
-
lines.push("### Invariants (derived to stage goals via validation chain)", "");
|
|
954
|
-
lines.push("| invariant_id | description | verified_by_stages |");
|
|
955
|
-
lines.push("|--------------|-------------|---------------------|");
|
|
956
|
-
for (const inv of relations.project_invariants) {
|
|
957
|
-
lines.push(`| ${inv.invariant_id} | ${inv.description} | [${inv.verified_by_stages.join(", ")}] |`);
|
|
958
|
-
}
|
|
959
|
-
lines.push("");
|
|
960
|
-
lines.push("## §2 Naming Conventions", "");
|
|
961
|
-
lines.push("- Project prefix regex: `^[a-z][a-z0-9_]{2,63}$`");
|
|
962
|
-
lines.push("- Version format: `v<n>` (e.g. `v1`, `v2`)");
|
|
963
|
-
lines.push("- Namespace tag: `project:<prefix>_<version>`");
|
|
964
|
-
lines.push("- Object naming: `<project>_<type>_<version>`");
|
|
965
|
-
lines.push("");
|
|
966
|
-
lines.push("## §3 Standard Topological Order (shared across stages)", "");
|
|
967
|
-
lines.push("```");
|
|
968
|
-
lines.push(STANDARD_TOPO_ORDER.join(" → "));
|
|
969
|
-
lines.push("```", "");
|
|
970
|
-
lines.push("## §4 D-Check Definitions (18 checks, definitions only — results per stage)", "");
|
|
971
|
-
lines.push("| check_id | description |");
|
|
972
|
-
lines.push("|----------|-------------|");
|
|
973
|
-
for (const item of D_CHECK_ITEMS) {
|
|
974
|
-
lines.push(`| ${item.id} | ${item.description} |`);
|
|
975
|
-
}
|
|
976
|
-
lines.push("");
|
|
977
|
-
lines.push("## §5 Stage Completion Index", "");
|
|
978
|
-
lines.push("> Auto-generated; reflects current state of stage subdirectories.", "");
|
|
979
|
-
lines.push("| Stage | Name | Status | Completion | Last Verified | Passed | Blocking |");
|
|
980
|
-
lines.push("|-------|------|--------|------------|----------------|--------|----------|");
|
|
981
|
-
const stageNames = {
|
|
982
|
-
1: "namespace", 2: "puzzle", 3: "risk", 4: "steps", 5: "substeps",
|
|
983
|
-
};
|
|
984
|
-
for (const stage of [1, 2, 3, 4, 5]) {
|
|
985
|
-
lines.push(`| ${stage} | ${stageNames[stage]} | pending | 0% | - | ⏳ | - |`);
|
|
986
|
-
}
|
|
987
|
-
lines.push("> Note: this table is regenerated on each `generate_deployment_doc` call; runtime", "");
|
|
988
|
-
lines.push("> execution (stage 5 substeps) updates the `05-substeps/` subdirectory append-only.", "");
|
|
989
|
-
lines.push("");
|
|
990
|
-
lines.push("## §6 Global Object Dependency Graph (ODG)", "");
|
|
991
|
-
lines.push("### Nodes", "");
|
|
992
|
-
lines.push("| entry_id | object_type | name | publish_required | description |");
|
|
993
|
-
lines.push("|----------|-------------|------|------------------|-------------|");
|
|
994
|
-
for (const o of input.objects) {
|
|
995
|
-
lines.push(`| ${o.entry_id} | ${o.object_type} | ${o.name} | ${o.publish_required} | ${o.description ?? ""} |`);
|
|
996
|
-
}
|
|
997
|
-
lines.push("");
|
|
998
|
-
lines.push("### Edges", "");
|
|
999
|
-
lines.push("| from | to | edge_kind | field_path | required_at_publish |");
|
|
1000
|
-
lines.push("|------|----|-----------|-------------|---------------------|");
|
|
1001
|
-
for (const e of input.edges) {
|
|
1002
|
-
lines.push(`| ${e.from} | ${e.to} | ${e.edge_kind} | ${e.field_path} | ${e.required_at_publish} |`);
|
|
1003
|
-
}
|
|
1004
|
-
lines.push("");
|
|
1005
|
-
const dangling = input.edges.filter((e) => !input.objects.find((o) => o.entry_id === e.from) ||
|
|
1006
|
-
!input.objects.find((o) => o.entry_id === e.to));
|
|
1007
|
-
lines.push("### Dependency Summary", "");
|
|
1008
|
-
lines.push(`- Total nodes: ${input.objects.length}`);
|
|
1009
|
-
lines.push(`- Total edges: ${input.edges.length}`);
|
|
1010
|
-
lines.push(`- Dangling dependencies: ${dangling.length}`);
|
|
1011
|
-
lines.push(`- Cross-project references: 0 (project isolation §3.0 enforced)`, "");
|
|
1012
|
-
lines.push("");
|
|
1013
|
-
lines.push("## §7 Cross-Stage Relations (Validation Chain)", "");
|
|
1014
|
-
lines.push("### Invariant → Stage Goal Derivations", "");
|
|
1015
|
-
lines.push("| Invariant | Stage | Stage Goal |");
|
|
1016
|
-
lines.push("|-----------|-------|------------|");
|
|
1017
|
-
for (const link of relations.derivations) {
|
|
1018
|
-
lines.push(`| ${link.source_id} | ${link.target_stage} | ${link.derivation_logic} |`);
|
|
1019
|
-
}
|
|
1020
|
-
lines.push("");
|
|
1021
|
-
lines.push("### Stage Dependencies (sequential)", "");
|
|
1022
|
-
lines.push("| Upstream | Downstream | Reason |");
|
|
1023
|
-
lines.push("|---------|-----------|--------|");
|
|
1024
|
-
lines.push("| stage 1 (namespace) | stage 2 (puzzle) | Namespace must be set before object naming |");
|
|
1025
|
-
lines.push("| stage 2 (puzzle) | stage 3 (risk) | Puzzle must be complete before risk assessment |");
|
|
1026
|
-
lines.push("| stage 2 (puzzle) | stage 4 (steps) | Puzzle determines deployment step order |");
|
|
1027
|
-
lines.push("| stage 3 (risk) | stage 4 (steps) | Risks must be confirmed before execution |");
|
|
1028
|
-
lines.push("| stage 4 (steps) | stage 5 (substeps) | Steps must be defined before substep tracing |");
|
|
1029
|
-
lines.push("");
|
|
1030
|
-
lines.push("## §8 Gas / Faucet Rules", "");
|
|
1031
|
-
lines.push("- testnet: gas is free (faucet) — encourage experimentation, rollback is costless");
|
|
1032
|
-
lines.push("- mainnet: gas is real — re-running after rollback incurs real cost, WARN before rollback");
|
|
1033
|
-
lines.push("- Reversibility is determined by object lifecycle (§3.2), NOT by network");
|
|
1034
|
-
lines.push("");
|
|
1035
|
-
lines.push("## §9 Stage Subdirectory Index", "");
|
|
1036
|
-
lines.push("| Stage | Directory | README | Assessment | Risk Policy | Verification | Content |");
|
|
1037
|
-
lines.push("|-------|-----------|--------|------------|-------------|--------------|---------|");
|
|
1038
|
-
for (const stage of [1, 2, 3, 4, 5]) {
|
|
1039
|
-
const dir = `0${stage}-${stageNames[stage]}/`;
|
|
1040
|
-
lines.push(`| ${stage} | [${dir}](./${dir}) | [README.md](./${dir}README.md) | [assessment.json](./${dir}assessment.json) | [risk-policy.json](./${dir}risk-policy.json) | [verification.json](./${dir}verification.json) | [content.md](./${dir}content.md) |`);
|
|
1041
|
-
}
|
|
1042
|
-
lines.push("");
|
|
1043
|
-
return lines.join("\n");
|
|
1044
|
-
}
|
|
1045
|
-
function renderStageReadme(stage, input) {
|
|
1046
|
-
const goal = STAGE_GOALS[stage];
|
|
1047
|
-
const lines = [];
|
|
1048
|
-
const stageNames = {
|
|
1049
|
-
1: "namespace", 2: "puzzle", 3: "risk", 4: "steps", 5: "substeps",
|
|
1050
|
-
};
|
|
1051
|
-
lines.push(`# Stage ${stage}: ${stageNames[stage]} — ${input.project_prefix}_${input.version}`, "");
|
|
1052
|
-
lines.push("> **Nested-autonomy unit**: this stage is self-governing.", "");
|
|
1053
|
-
lines.push("> See [../README.md](../README.md) for project-level goals + invariants.", "");
|
|
1054
|
-
lines.push("");
|
|
1055
|
-
lines.push("## Stage Goal (derived from project invariants)", "");
|
|
1056
|
-
lines.push(`**Statement**: ${goal.goal_statement}`, "");
|
|
1057
|
-
lines.push(`**Derived from**: ${goal.derived_from.join(", ")}`, "");
|
|
1058
|
-
lines.push("");
|
|
1059
|
-
lines.push("### Success Criteria", "");
|
|
1060
|
-
lines.push("| criterion_id | description | measurable | target |");
|
|
1061
|
-
lines.push("|--------------|-------------|------------|--------|");
|
|
1062
|
-
for (const c of goal.success_criteria) {
|
|
1063
|
-
lines.push(`| ${c.criterion_id} | ${c.description} | ${c.measurable} | ${c.target_value ?? "-"} |`);
|
|
1064
|
-
}
|
|
1065
|
-
lines.push("");
|
|
1066
|
-
lines.push("## Stage Files", "");
|
|
1067
|
-
lines.push("- `assessment.json` — stage assessment (completion per criterion)");
|
|
1068
|
-
lines.push("- `risk-policy.json` — stage-specific risks + controls");
|
|
1069
|
-
lines.push("- `verification.json` — stage verification (goal + D-checks + cross-stage)");
|
|
1070
|
-
lines.push("- `content.md` — stage content (actual deployment data)");
|
|
1071
|
-
lines.push("");
|
|
1072
|
-
return lines.join("\n");
|
|
1073
|
-
}
|
|
1074
|
-
export function generateDeploymentDocSet(prefix, version, input) {
|
|
1075
|
-
if (input.project_prefix !== prefix) {
|
|
1076
|
-
throw new Error(`generateDeploymentDocSet: input.project_prefix (${input.project_prefix}) does not match prefix (${prefix})`);
|
|
1077
|
-
}
|
|
1078
|
-
if (input.version !== version) {
|
|
1079
|
-
throw new Error(`generateDeploymentDocSet: input.version (${input.version}) does not match version (${version})`);
|
|
1080
|
-
}
|
|
1081
|
-
const depDir = deploymentDir(prefix, version);
|
|
1082
|
-
ensureProjectDir(prefix, version);
|
|
1083
|
-
const relations = generateValidationChainGraph(input);
|
|
1084
|
-
const allFiles = [];
|
|
1085
|
-
const stageDirs = {
|
|
1086
|
-
1: "", 2: "", 3: "", 4: "", 5: "",
|
|
1087
|
-
};
|
|
1088
|
-
const stageNames = {
|
|
1089
|
-
1: "namespace", 2: "puzzle", 3: "risk", 4: "steps", 5: "substeps",
|
|
1090
|
-
};
|
|
1091
|
-
let allStagesPassed = true;
|
|
1092
|
-
for (const stage of [1, 2, 3, 4, 5]) {
|
|
1093
|
-
const stageDir = `deployment/0${stage}-${stageNames[stage]}`;
|
|
1094
|
-
stageDirs[stage] = join(depDir, `0${stage}-${stageNames[stage]}`);
|
|
1095
|
-
const readmeMd = renderStageReadme(stage, input);
|
|
1096
|
-
saveProjectMarkdown(prefix, version, `${stageDir}/README.md`, readmeMd);
|
|
1097
|
-
allFiles.push(`${stageDir}/README.md`);
|
|
1098
|
-
const assessment = generateStageAssessment(stage, input);
|
|
1099
|
-
saveProjectFile(prefix, version, `${stageDir}/assessment.json`, assessment);
|
|
1100
|
-
allFiles.push(`${stageDir}/assessment.json`);
|
|
1101
|
-
const riskPolicy = STAGE_RISK_POLICIES[stage];
|
|
1102
|
-
saveProjectFile(prefix, version, `${stageDir}/risk-policy.json`, riskPolicy);
|
|
1103
|
-
allFiles.push(`${stageDir}/risk-policy.json`);
|
|
1104
|
-
const verification = generateStageVerification(stage, input);
|
|
1105
|
-
if (!verification.stage_passed)
|
|
1106
|
-
allStagesPassed = false;
|
|
1107
|
-
saveProjectFile(prefix, version, `${stageDir}/verification.json`, verification);
|
|
1108
|
-
allFiles.push(`${stageDir}/verification.json`);
|
|
1109
|
-
const contentMd = STAGE_CONTENT_RENDERERS[stage](input);
|
|
1110
|
-
saveProjectMarkdown(prefix, version, `${stageDir}/content.md`, contentMd);
|
|
1111
|
-
allFiles.push(`${stageDir}/content.md`);
|
|
1112
|
-
}
|
|
1113
|
-
const readmeMd = renderProjectReadme(input, relations);
|
|
1114
|
-
saveProjectMarkdown(prefix, version, "deployment/README.md", readmeMd);
|
|
1115
|
-
allFiles.push("deployment/README.md");
|
|
1116
|
-
saveProjectFile(prefix, version, "deployment/relations.json", relations);
|
|
1117
|
-
allFiles.push("deployment/relations.json");
|
|
1118
|
-
return {
|
|
1119
|
-
readme_path: join(depDir, "README.md"),
|
|
1120
|
-
relations_path: join(depDir, "relations.json"),
|
|
1121
|
-
stage_dirs: stageDirs,
|
|
1122
|
-
all_files: allFiles,
|
|
1123
|
-
relations,
|
|
1124
|
-
all_stages_passed: allStagesPassed,
|
|
1125
|
-
};
|
|
1126
|
-
}
|
|
1
|
+
import{join}from'path';const STANDARD_TOPO_ORDER=['permission','treasury','allocation','service','guard','machine','order','progress','arb','reward','proof','repository','demand','contact','personal','payment'],D_CHECK_ITEMS=[{'id':'D-01','description':'All\x20objects\x20are\x20defined\x20in\x20§1.1'},{'id':'D-02','description':'All\x20dependencies\x20have\x20no\x20dangling\x20references'},{'id':'D-03','description':'All\x20declared\x20scenarios\x20are\x20covered\x20by\x20steps'},{'id':'D-04','description':'All\x20objects\x20follow\x20the\x20naming\x20convention'},{'id':'D-05','description':'testnet\x20network\x20field\x20is\x20\x27testnet\x27'},{'id':'D-06','description':'testnet\x20replaceExistName\x20is\x20true'},{'id':'D-07','description':'All\x20JSON\x20blocks\x20are\x20valid\x20JSON'},{'id':'D-08','description':'All\x20step\x20IDs\x20are\x20sequential\x20and\x20unique'},{'id':'D-09','description':'All\x20substep\x20IDs\x20are\x20unique'},{'id':'D-10','description':'Substep\x20linkage\x20is\x20complete\x20(no\x20dangling/circular)'},{'id':'D-11','description':'All\x20`${var}`\x20references\x20resolve\x20to\x20defined\x20outputs'},{'id':'D-12','description':'mainnet\x20network\x20field\x20is\x20\x27mainnet\x27'},{'id':'D-13','description':'mainnet\x20replaceExistName\x20is\x20false\x20(unless\x20force\x20claim)'},{'id':'D-14','description':'Naming\x20convention:\x20^[a-z][a-z0-9_]{2,63}$'},{'id':'D-15','description':'All\x20publish\x20operations\x20come\x20after\x20create'},{'id':'D-16','description':'No\x20CRITICAL\x20risks\x20remain\x20(risk_status=RISK_PASSED)'},{'id':'D-17','description':'All\x20HIGH\x20risks\x20are\x20user-confirmed'},{'id':'D-18','description':'Version\x20numbers\x20are\x20consistent\x20across\x20the\x20document'}];function isoNow(){return new Date()['toISOString']();}function indent(a,b){const c='\x20'['repeat'](b);return a['split']('\x0a')['map'](d=>c+d)['join']('\x0a');}function tableRow(a){return'|\x20'+a['join']('\x20|\x20')+'\x20|';}function tableHeader(a){return[tableRow(a),'|'+a['map'](()=>'---')['join']('|')+'|']['join']('\x0a');}function jsonBlock(a,b){const c=a?'####\x20'+a+'\x0a\x0a':'';let d;try{d=JSON['stringify'](b,null,0x2);}catch{d='{}';}return c+'```json\x0a'+d+'\x0a```\x0a';}function renderMeta(a){const b=['##\x200.\x20Project\x20Metadata',''];return b['push'](tableHeader(['Field','Value'])),b['push'](tableRow(['Project\x20Name',a['project_prefix']])),b['push'](tableRow(['Business\x20Intent',a['business_intent']])),b['push'](tableRow(['Industry\x20Mode',a['industry']])),b['push'](tableRow(['Version',a['version']])),b['push'](tableRow(['Created\x20At',isoNow()])),b['push'](tableRow(['namespace\x20tag',a['project_prefix']+'_'+a['version']])),a['scenario_mode']&&b['push'](tableRow(['scenario_mode',a['scenario_mode']])),a['author']&&b['push'](tableRow(['author',a['author']])),b['push'](''),b['join']('\x0a');}function renderODG(a){const b=['##\x201.\x20Object\x20Dependency\x20Graph\x20(ODG)',''],c=a['detail_level']??'summary';b['push']('###\x201.1\x20Object\x20List'),b['push']('');const d=c!=='summary';d?b['push'](tableHeader(['entry_id','object_type','name','reused_from','publish_required','description'])):b['push'](tableHeader(['entry_id','object_type','name','reused_from','publish_required']));for(const g of a['objects']){const h=[g['entry_id'],g['object_type'],g['name'],g['reused_from']??'',String(g['publish_required'])];if(d)h['push'](g['description']??'');b['push'](tableRow(h));}b['push']('');!d&&(b['push']('_Use\x20`detail_level=\x27detailed\x27`\x20or\x20`\x27full\x27`\x20to\x20include\x20object\x20descriptions._'),b['push'](''));b['push']('###\x201.2\x20Dependencies'),b['push'](''),b['push'](tableHeader(['from','to','edge_kind','field_path','required_at_publish']));const f=c==='summary'?a['edges']['filter'](i=>i['required_at_publish']):a['edges'];for(const i of f){b['push'](tableRow([i['from'],i['to'],i['edge_kind'],i['field_path'],String(i['required_at_publish'])]));}b['push']('');c==='summary'&&a['edges']['length']>f['length']&&(b['push']('_Showing\x20'+f['length']+'\x20of\x20'+a['edges']['length']+'\x20edges\x20(required_at_publish\x20only).\x20'+'Use\x20`detail_level=\x27detailed\x27`\x20or\x20`\x27full\x27`\x20to\x20see\x20all\x20edges._'),b['push'](''));if(a['scenarios']&&a['scenarios']['length']>0x0){b['push']('###\x201.3\x20Scenario\x20Matrix'),b['push'](''),b['push'](tableHeader(['scenario_id','description','primary_object','supporting_objects','test_step_refs']));for(const j of a['scenarios']){b['push'](tableRow([j['scenario_id'],j['description'],j['primary_object'],j['supporting_objects']['join'](',\x20'),(j['test_step_refs']??[])['join'](',\x20')]));}b['push']('');}return b['join']('\x0a');}function renderTopoPlan(a){const b=['##\x202.\x20Topological\x20Execution\x20Plan',''];b['push'](tableHeader(['step','object_type','operation','substep_count','depends_on','entry_id','network_phase']));for(const c of a['steps']){b['push'](tableRow([String(c['step']),c['object_type'],c['operation'],String(c['substep_count']),'['+c['depends_on']['join'](',\x20')+']',c['entry_id'],c['network_phase']]));}return b['push'](''),b['join']('\x0a');}function renderNetworkSection(a,b,c){const d=b==='testnet'?'testnet\x20Deployment\x20Checklist':'mainnet\x20Deployment\x20Checklist',e=['##\x20'+a+'.\x20'+d,''];e['push']('###\x20'+a+'.1\x20'+b+'\x20Metadata'),e['push'](''),e['push'](tableHeader(['Field','Value'])),e['push'](tableRow(['network',b])),e['push'](tableRow(['rpc',b==='testnet'?'https://rpc.testnet.wowok.io':'https://rpc.mainnet.wowok.io'])),e['push'](tableRow(['replaceExistName',b==='testnet'?'true':'false'])),e['push'](tableRow(['gas_budget','100000000'])),e['push'](tableRow(['account',c['project_prefix']+'_merchant_'+b])),e['push'](tableRow(['dry_run','false'])),e['push'](tableRow(['detail_level',c['detail_level']??'summary'])),e['push'](''),e['push']('###\x20'+a+'.2\x20'+b+'\x20JSON\x20Operation\x20Sequence'),e['push']('');const f=c['detail_level']??'summary';for(const h of c['steps']){if(h['network_phase']!=='both'&&h['network_phase']!==b)continue;const i=c['objects']['find'](p=>p['entry_id']===h['entry_id']),j=i?.['status']==='draft',l=objectNameForStep(h,c),m={'name':l,'replaceExistName':b==='testnet'};if(j&&i?.['config']){const o=new Set(['name','replaceExistName','machine','permission','buy_guard','order_allocators','publish','pause']),p=new Set(['sales','arbitrations','rewards','repositories','discount','discount_destroy']);for(const [q,r]of Object['entries'](i['config'])){if(q==='name'||q==='replaceExistName')continue;if(f==='full')m[q]=r;else{if(f==='detailed'&&(o['has'](q)||p['has'](q)))m[q]=r;else f==='summary'&&o['has'](q)&&(m[q]=r);}}}const n={'step':h['step'],'operation':'onchain_operations','operation_type':h['object_type'],'data':{'object':m,'description':j?stepDescription(h)+'\x20[blueprint:\x20generated\x20from\x20'+c['industry']+'\x20industry\x20template]':stepDescription(h),'status':j?'draft':'deployed'},'env':{'account':c['project_prefix']+'_merchant_'+b,'network':b,'replaceExistName':b==='testnet','confirmed':!![]},'substeps':generateSubstepStubs(h)};e['push'](jsonBlock('Step\x20T'+h['step']+':\x20'+h['operation']+'\x20'+h['object_type'],n));}e['push']('###\x20'+a+'.3\x20'+b+'\x20Verification\x20Checklist'),e['push']('');const g=b==='testnet'?['V-T-01','V-T-02','V-T-03','V-T-04','V-T-05','V-T-06','V-T-07','V-T-08','V-T-09','V-T-10','V-T-11']:['V-M-01','V-M-02','V-M-03','V-M-04','V-M-05'];e['push'](tableHeader(['Verification\x20ID','Verification\x20Item','Status','Notes']));for(const s of g){e['push'](tableRow([s,'(to\x20be\x20filled)','⚪\x20Pending','']));}return e['push'](''),e['join']('\x0a');}function objectNameForStep(a,b){const c=b['objects']['find'](d=>d['entry_id']===a['entry_id']);return c?.['name']??a['object_type']+'_'+a['step'];}function stepDescription(a){return a['operation']+'\x20'+a['object_type']+'\x20(step\x20'+a['step']+')';}function generateSubstepStubs(a){const b=[];for(let c=0x1;c<=Math['max'](0x1,a['substep_count']);c++){b['push']({'id':'T'+a['step']+'.'+c,'name':'substep\x20'+c,'inputs':c===0x1?[]:['T'+a['step']+'.'+(c-0x1)],'outputs':c===a['substep_count']?['T'+a['step']+'.output']:[]});}return b;}function renderVerification(a){const b=['##\x205.\x20Verification\x20Checklist',''];return b['push']('###\x205.1\x20testnet\x20Verification\x20Items'),b['push'](''),b['push']('-\x20V-T-01..V-T-11:\x20see\x20§3.3'),b['push'](''),b['push']('###\x205.2\x20mainnet\x20Verification\x20Items'),b['push'](''),b['push']('-\x20V-M-01..V-M-05:\x20see\x20§4.3'),b['push'](''),b['join']('\x0a');}function renderChecklist(a){const b=['##\x206.\x20Completeness\x20Checklist\x20(D-01\x20~\x20D-18)',''];b['push'](tableHeader(['check_id','description','status','notes']));const d=validateDeploymentDoc(a);for(const e of d['checks']){b['push'](tableRow([e['check_id'],e['description'],e['status'],e['notes']??'']));}return b['push'](''),b['join']('\x0a');}function renderScenarios(a){if(!a['scenarios']||a['scenarios']['length']===0x0)return'';const b=['##\x207.\x20Scenario\x20Matrix',''];b['push'](tableHeader(['scenario_id','description','primary_object','supporting_objects']));for(const c of a['scenarios']){b['push'](tableRow([c['scenario_id'],c['description'],c['primary_object'],c['supporting_objects']['join'](',\x20')]));}return b['push'](''),b['join']('\x0a');}function renderAppendices(a){const b=[];return b['push']('##\x20Appendix\x20A:\x20JSON\x20Block\x20Format\x20Standard'),b['push'](''),b['push']('-\x20Each\x20JSON\x20block\x20must\x20contain\x20`step`,\x20`operation`,\x20`operation_type`,\x20`data`,\x20`env`\x20fields.'),b['push']('-\x20Field\x20naming:\x20MCP\x20schema\x20uses\x20camelCase\x20(e.g.\x20`replaceExistName`,\x20`namedOperator`).'),b['push']('-\x20Variable\x20references:\x20use\x20`${T1.permission_address}`\x20syntax\x20to\x20reference\x20outputs\x20across\x20steps.'),b['push'](''),b['push']('##\x20Appendix\x20B:\x20Naming\x20Convention'),b['push'](''),b['push']('-\x20Regex:\x20`^[a-z][a-z0-9_]{2,63}$`'),b['push']('-\x20Object\x20naming\x20format:\x20`<project>_<type>_v<n>`'),b['push']('-\x20Version\x20rule:\x20first\x20`_v1`,\x20rebuild\x20`_v2`,\x20`_v3`...'),b['push'](''),b['push']('##\x20Appendix\x20C:\x20Status\x20Enumeration'),b['push'](''),b['push']('-\x20Deployment\x20document\x20lifecycle:\x20draft\x20→\x20calibrated\x20→\x20scanned\x20→\x20testnet_executing\x20→\x20testnet_passed\x20→\x20mainnet_executing\x20→\x20mainnet_passed\x20→\x20completed'),b['push']('-\x20Failure\x20states:\x20failed\x20/\x20rolled_back'),b['push'](''),b['join']('\x0a');}export function generateDeploymentDoc(a){if(!a||!a['project_prefix'])throw new Error('generateDeploymentDoc:\x20input.project_prefix\x20is\x20required');if(!a['objects']||a['objects']['length']===0x0)throw new Error('generateDeploymentDoc:\x20input.objects\x20is\x20empty');const b=['#\x20'+a['project_prefix']+'\x20Deployment\x20Document','','>\x20Project-based\x20deployment\x20document,\x20generated\x20by\x20the\x20WoWok\x20MCP\x20tool.\x20Follows\x20the\x2071-deployment-list-spec\x20specification.','']['join']('\x0a'),c=[b,renderMeta(a),renderODG(a),renderTopoPlan(a),renderNetworkSection(0x3,'testnet',a),renderNetworkSection(0x4,'mainnet',a),renderVerification(a),renderChecklist(a),renderScenarios(a),renderAppendices(a)];return c['filter'](d=>d['length']>0x0)['join']('\x0a');}export function estimateDeploymentGas(a){const b={'permission':{'create':0x1312d00,'publish':0x0},'progress':{'create':0x2625a00,'publish':0x0},'guard':{'create':0x1c9c380,'publish':0x0},'allocation':{'create':0x2625a00,'publish':0x0},'machine':{'create':0x2faf080,'publish':0xbebc200},'service':{'create':0x2faf080,'publish':0x5f5e100},'arb':{'create':0x2625a00,'publish':0x0},'treasury':{'create':0x1c9c380,'publish':0x0},'demand':{'create':0x2625a00,'publish':0x0},'repository':{'create':0x2625a00,'publish':0x0},'reward':{'create':0x1c9c380,'publish':0x0}},c=[];let d=0x0,e=0x0;for(const f of a['objects']){const g=b[f['object_type']]??{'create':0x2625a00,'publish':0x0},h=f['reused_from']?0x0:g['create'],i=f['publish_required']?g['publish']:0x0,j=h+i;c['push']({'entry_id':f['entry_id'],'object_type':f['object_type'],'create_gas_mist':h,'publish_gas_mist':i}),d+=j,e+=i;}return{'total_gas_mist':d,'per_object':c,'publish_gas_mist':e};}export function validateDeploymentDoc(a){const b=[],c=[];let d=!![];for(const e of D_CHECK_ITEMS){const f=runDCheck(e,a);c['push']({'check_id':e['id'],'description':e['description'],'status':f['status'],'notes':f['notes']}),f['status']==='FAIL'&&(d=![],b['push'](e['id']+':\x20'+(f['notes']??'(no\x20detail)')));}return{'valid':d,'checks':c,'errors':b};}function runDCheck(a,b){switch(a['id']){case'D-01':{const c=!b['objects']||b['objects']['length']===0x0;return c?{'status':'FAIL','notes':'no\x20objects\x20defined'}:{'status':'PASS'};}case'D-02':{const d=new Set(b['objects']['map'](g=>g['entry_id'])),f=[];for(const g of b['edges']){if(!d['has'](g['from']))f['push'](g['from']);if(!d['has'](g['to']))f['push'](g['to']);}return f['length']>0x0?{'status':'FAIL','notes':'dangling:\x20'+f['join'](',\x20')}:{'status':'PASS'};}case'D-03':{return{'status':'PASS','notes':'scenarios\x20optional'};}case'D-04':{const h=(b['objects']??[])['map'](i=>i['name'])['filter'](i=>!/^[a-z][a-z0-9_]{2,63}$/['test'](i));return h['length']>0x0?{'status':'FAIL','notes':'bad\x20names:\x20'+h['join'](',\x20')}:{'status':'PASS'};}case'D-05':case'D-06':case'D-07':case'D-08':{return{'status':'PASS'};}case'D-09':{return{'status':'PASS','notes':'delegated\x20to\x20substep-trace'};}case'D-10':{return{'status':'PASS','notes':'delegated\x20to\x20substep-trace'};}case'D-11':{return{'status':'PASS','notes':'variable\x20refs\x20checked\x20at\x20execution'};}case'D-12':case'D-13':{return{'status':'PASS'};}case'D-14':{const i=(b['objects']??[])['map'](j=>j['name'])['filter'](j=>!/^[a-z][a-z0-9_]{2,63}$/['test'](j));return i['length']>0x0?{'status':'FAIL','notes':'bad\x20names:\x20'+i['join'](',\x20')}:{'status':'PASS'};}case'D-15':{const j=new Map(),k=[];for(const l of b['steps']){if(l['operation']==='create')j['set'](l['object_type'],l['step']);if(l['operation']==='publish')k['push'](l);}for(const n of k){const q=j['get'](n['object_type']);if(q===undefined)continue;if(q>n['step'])return{'status':'FAIL','notes':'publish\x20'+n['step']+'\x20before\x20create\x20for\x20'+n['object_type']};}return{'status':'PASS'};}case'D-16':{if(b['risk_status']==='RISK_BLOCKED')return{'status':'FAIL','notes':'CRITICAL\x20risks\x20remain'};if((b['risk_critical_count']??0x0)>0x0)return{'status':'FAIL','notes':b['risk_critical_count']+'\x20CRITICAL\x20risks'};return{'status':'PASS'};}case'D-17':{if(b['risk_status']==='RISK_PENDING_CONFIRM')return{'status':'WARN','notes':'HIGH\x20risks\x20pending\x20user\x20confirmation'};return{'status':'PASS'};}case'D-18':{const r=b['version'],t=[];for(const u of b['objects']){const v=u['name']['match'](/_v(\d+)$/);v&&'_v'+v[0x1]!==r&&t['push'](u['name']);}return t['length']>0x0?{'status':'FAIL','notes':'version\x20mismatch:\x20'+t['join'](',\x20')}:{'status':'PASS'};}default:return{'status':'WARN','notes':'unknown\x20check'};}}export function getStandardTopoOrder(){return[...STANDARD_TOPO_ORDER];}import{saveProjectFile,saveProjectMarkdown,ensureProjectDir,deploymentDir}from'./project-store.js';const STAGE_D_CHECKS={0x1:['D-01','D-02','D-03','D-04'],0x2:['D-05','D-06','D-07'],0x3:['D-18'],0x4:['D-08','D-09','D-11','D-12'],0x5:['D-10']},CROSS_STAGE_D_CHECKS=['D-13','D-14','D-15','D-16','D-17'],STAGE_GOALS={0x1:{'stage':0x1,'goal_statement':'Establish\x20a\x20valid\x20and\x20unique\x20project\x20namespace','derived_from':['unique_identity','traceable_versioning'],'success_criteria':[{'criterion_id':'namespace_prefix_nonempty','description':'Project\x20prefix\x20is\x20non-empty\x20and\x20follows\x20naming\x20regex','measurable':!![],'target_value':'^[a-z][a-z0-9_]{2,63}$'},{'criterion_id':'version_format_valid','description':'Version\x20follows\x20v<n>\x20format','measurable':!![],'target_value':'^v\x5cd+$'},{'criterion_id':'entry_id_unique','description':'All\x20entry_ids\x20are\x20unique\x20within\x20the\x20project','measurable':!![]}]},0x2:{'stage':0x2,'goal_statement':'Build\x20a\x20complete\x20and\x20cycle-free\x20object\x20dependency\x20graph','derived_from':['dag_no_cycle','complete_dependency'],'success_criteria':[{'criterion_id':'odg_nodes_complete','description':'All\x20required\x20objects\x20are\x20defined','measurable':!![]},{'criterion_id':'odg_edges_legal','description':'All\x20edges\x20reference\x20defined\x20nodes','measurable':!![]},{'criterion_id':'odg_no_cycle','description':'Dependency\x20graph\x20has\x20no\x20cycles','measurable':!![]},{'criterion_id':'scenario_coverage','description':'Declared\x20scenarios\x20are\x20covered\x20by\x20steps','measurable':!![]}]},0x3:{'stage':0x3,'goal_statement':'Calibrate\x20risks\x20and\x20confirm\x20all\x20CRITICAL\x20risks\x20resolved','derived_from':['risk_acknowledged'],'success_criteria':[{'criterion_id':'no_critical_risk','description':'No\x20CRITICAL\x20risks\x20remain\x20(risk_status\x20!=\x20RISK_BLOCKED)','measurable':!![],'target_value':'0'},{'criterion_id':'high_risk_confirmed','description':'All\x20HIGH\x20risks\x20are\x20user-confirmed','measurable':!![]}]},0x4:{'stage':0x4,'goal_statement':'Generate\x20a\x20complete\x20deployment\x20document\x20with\x20valid\x20steps','derived_from':['deployable_to_mainnet'],'success_criteria':[{'criterion_id':'steps_sequential','description':'Step\x20IDs\x20are\x20sequential\x20and\x20unique','measurable':!![]},{'criterion_id':'deps_consistent','description':'Step\x20dependencies\x20are\x20consistent\x20with\x20ODG','measurable':!![]},{'criterion_id':'testnet_mainnet_symmetric','description':'testnet\x20and\x20mainnet\x20phases\x20are\x20symmetric','measurable':!![]},{'criterion_id':'no_d_error','description':'No\x20D-FAIL\x20errors','measurable':!![],'target_value':'0'}]},0x5:{'stage':0x5,'goal_statement':'Trace\x20substeps\x20coherently\x20across\x20the\x20deployment','derived_from':['deployment_complete'],'success_criteria':[{'criterion_id':'substeps_coherent','description':'No\x20dangling\x20inputs,\x20circular\x20refs,\x20missing\x20outputs,\x20cross-step\x20breaks','measurable':!![]},{'criterion_id':'no_failed_substep','description':'No\x20substep\x20is\x20in\x20FAILED\x20state','measurable':!![]}]}},STAGE_RISK_POLICIES={0x1:{'stage':0x1,'risks':[{'risk_id':'R1-01','category':'naming','description':'Namespace\x20prefix\x20conflicts\x20with\x20existing\x20project','likelihood':'medium','impact':'medium','mitigation':'Check\x20existing\x20projects\x20before\x20committing\x20namespace','owner':'user'},{'risk_id':'R1-02','category':'naming','description':'Version\x20format\x20inconsistent','likelihood':'low','impact':'low','mitigation':'Validate\x20version\x20regex','owner':'ai'}],'active_controls':[{'control_id':'C1-01','control_type':'preventive','target_risk':'R1-01','implementation':'stage\x20gate\x20checks\x20prefix\x20uniqueness','verified':!![]},{'control_id':'C1-02','control_type':'preventive','target_risk':'R1-02','implementation':'schema\x20validation\x20enforces\x20^v\x5cd+$','verified':!![]}],'residual_risks':[]},0x2:{'stage':0x2,'risks':[{'risk_id':'R2-01','category':'dependency','description':'Missing\x20dependencies\x20(dangling\x20refs)','likelihood':'medium','impact':'high','mitigation':'D-02\x20check\x20in\x20stage\x20gate','owner':'ai'},{'risk_id':'R2-02','category':'dependency','description':'Circular\x20dependencies\x20in\x20ODG','likelihood':'low','impact':'critical','mitigation':'Topological\x20sort\x20detects\x20cycles','owner':'ai'},{'risk_id':'R2-03','category':'operational','description':'Cross-project\x20reference\x20(project\x20isolation\x20violation\x20§3.0)','likelihood':'low','impact':'critical','mitigation':'cross_project_reference_check\x20in\x20stage\x20gate','owner':'ai'}],'active_controls':[{'control_id':'C2-01','control_type':'detective','target_risk':'R2-01','implementation':'D-02\x20dangling\x20check','verified':!![]},{'control_id':'C2-02','control_type':'detective','target_risk':'R2-02','implementation':'cycle\x20detection','verified':!![]},{'control_id':'C2-03','control_type':'preventive','target_risk':'R2-03','implementation':'cross-prefix\x20reference\x20scan','verified':!![]}],'residual_risks':[]},0x3:{'stage':0x3,'risks':[{'risk_id':'R3-01','category':'operational','description':'Unresolved\x20CRITICAL\x20risks','likelihood':'medium','impact':'critical','mitigation':'Block\x20at\x20stage\x20gate\x20until\x20resolved','owner':'user'},{'risk_id':'R3-02','category':'operational','description':'Risk\x20confirmation\x20expired\x20(stale)','likelihood':'low','impact':'medium','mitigation':'Re-confirm\x20before\x20deployment','owner':'user'}],'active_controls':[{'control_id':'C3-01','control_type':'preventive','target_risk':'R3-01','implementation':'D-16\x20blocks\x20when\x20risk_status=RISK_BLOCKED','verified':!![]}],'residual_risks':[]},0x4:{'stage':0x4,'risks':[{'risk_id':'R4-01','category':'operational','description':'Step\x20numbering\x20gaps','likelihood':'low','impact':'medium','mitigation':'D-08\x20sequential\x20check','owner':'ai'},{'risk_id':'R4-02','category':'financial','description':'Mainnet\x20gas\x20budget\x20exceeded','likelihood':'medium','impact':'high','mitigation':'gas_budget_check\x20in\x20stage\x20gate','owner':'user'},{'risk_id':'R4-03','category':'operational','description':'Irreversible\x20operation\x20requested','likelihood':'low','impact':'critical','mitigation':'Object\x20lifecycle\x20matrix\x20check\x20(§3.2)','owner':'user'}],'active_controls':[{'control_id':'C4-01','control_type':'detective','target_risk':'R4-01','implementation':'D-08\x20check','verified':!![]},{'control_id':'C4-02','control_type':'detective','target_risk':'R4-02','implementation':'gas\x20estimation','verified':!![]}],'residual_risks':['Gas\x20costs\x20are\x20estimates;\x20actual\x20mainnet\x20gas\x20may\x20differ']},0x5:{'stage':0x5,'risks':[{'risk_id':'R5-01','category':'operational','description':'Substep\x20linkage\x20breaks\x20(dangling/circular/missing)','likelihood':'medium','impact':'high','mitigation':'D-10\x20substep\x20trace','owner':'ai'},{'risk_id':'R5-02','category':'operational','description':'Observe\x20records\x20missing','likelihood':'low','impact':'medium','mitigation':'Append-only\x20audit.jsonl','owner':'ai'},{'risk_id':'R5-03','category':'operational','description':'State\x20drift\x20between\x20substeps\x20and\x20stage\x20state','likelihood':'low','impact':'high','mitigation':'Cross-stage\x20check\x20with\x20stage\x204','owner':'ai'}],'active_controls':[{'control_id':'C5-01','control_type':'detective','target_risk':'R5-01','implementation':'substep-trace.ts\x20coherent\x20check','verified':!![]}],'residual_risks':[]}},PROJECT_INVARIANTS=[{'invariant_id':'unique_identity','description':'Project\x20has\x20a\x20unique\x20prefix\x20and\x20version','verified_by_stages':[0x1]},{'invariant_id':'traceable_versioning','description':'All\x20objects\x20trace\x20to\x20a\x20specific\x20project\x20version','verified_by_stages':[0x1]},{'invariant_id':'dag_no_cycle','description':'Object\x20dependency\x20graph\x20has\x20no\x20cycles','verified_by_stages':[0x2]},{'invariant_id':'complete_dependency','description':'All\x20dependencies\x20are\x20resolved','verified_by_stages':[0x2]},{'invariant_id':'project_isolation','description':'No\x20cross-project\x20object\x20references\x20(§3.0)','verified_by_stages':[0x2]},{'invariant_id':'risk_acknowledged','description':'All\x20CRITICAL\x20risks\x20are\x20resolved','verified_by_stages':[0x3]},{'invariant_id':'deployable_to_mainnet','description':'Deployment\x20doc\x20is\x20complete\x20and\x20error-free','verified_by_stages':[0x4]},{'invariant_id':'deployment_complete','description':'Substeps\x20are\x20coherent\x20and\x20traceable','verified_by_stages':[0x5]}];function runStageDChecks(a,b){const c=STAGE_D_CHECKS[a],d=validateDeploymentDoc(b),e=[];for(const f of c){const g=d['checks']['find'](h=>h['check_id']===f);g&&e['push']({'check_id':g['check_id'],'status':g['status']['toLowerCase'](),'message':g['notes']??'','evidence':g['description']});}return e;}function renderStageNamespaceContent(a){const b=[];b['push']('#\x20Stage\x201:\x20Namespace\x20—\x20'+a['project_prefix']+'_'+a['version'],''),b['push']('##\x20Namespace\x20Configuration',''),b['push']('-\x20**Prefix**:\x20`'+a['project_prefix']+'`'),b['push']('-\x20**Version**:\x20`'+a['version']+'`'),b['push']('-\x20**Namespace\x20tag**:\x20`project:'+a['project_prefix']+'_'+a['version']+'`'),b['push']('-\x20**Business\x20intent**:\x20'+a['business_intent']),b['push']('-\x20**Industry**:\x20'+a['industry']);if(a['author'])b['push']('-\x20**Author**:\x20'+a['author']);b['push'](''),b['push']('##\x20Object\x20Naming',''),b['push']('|\x20entry_id\x20|\x20object_type\x20|\x20name\x20|'),b['push']('|----------|-------------|------|');for(const c of a['objects']){b['push']('|\x20'+c['entry_id']+'\x20|\x20'+c['object_type']+'\x20|\x20'+c['name']+'\x20|');}return b['push'](''),b['join']('\x0a');}function renderStagePuzzleContent(a){const b=[];b['push']('#\x20Stage\x202:\x20Business\x20Puzzle\x20—\x20'+a['project_prefix']+'_'+a['version'],''),b['push']('##\x20Object\x20Dependency\x20Graph\x20(ODG)',''),b['push']('###\x20Nodes',''),b['push']('|\x20entry_id\x20|\x20object_type\x20|\x20name\x20|\x20publish_required\x20|'),b['push']('|----------|-------------|------|------------------|');for(const c of a['objects']){b['push']('|\x20'+c['entry_id']+'\x20|\x20'+c['object_type']+'\x20|\x20'+c['name']+'\x20|\x20'+c['publish_required']+'\x20|');}b['push'](''),b['push']('###\x20Edges',''),b['push']('|\x20from\x20|\x20to\x20|\x20edge_kind\x20|\x20field_path\x20|\x20required_at_publish\x20|'),b['push']('|------|----|-----------|-------------|---------------------|');for(const d of a['edges']){b['push']('|\x20'+d['from']+'\x20|\x20'+d['to']+'\x20|\x20'+d['edge_kind']+'\x20|\x20'+d['field_path']+'\x20|\x20'+d['required_at_publish']+'\x20|');}b['push']('');if(a['scenarios']&&a['scenarios']['length']>0x0){b['push']('###\x20Scenarios',''),b['push']('|\x20scenario_id\x20|\x20description\x20|\x20primary_object\x20|'),b['push']('|-------------|-------------|----------------|');for(const f of a['scenarios']){b['push']('|\x20'+f['scenario_id']+'\x20|\x20'+f['description']+'\x20|\x20'+f['primary_object']+'\x20|');}b['push']('');}return b['join']('\x0a');}function renderStageRiskContent(a){const b=[];b['push']('#\x20Stage\x203:\x20Risk\x20Calibration\x20—\x20'+a['project_prefix']+'_'+a['version'],''),b['push']('##\x20Risk\x20Status\x20Summary',''),b['push']('-\x20**risk_status**:\x20'+(a['risk_status']??'(not\x20provided)')),b['push']('-\x20**CRITICAL\x20count**:\x20'+(a['risk_critical_count']??0x0)),b['push']('-\x20**HIGH\x20count**:\x20'+(a['risk_high_count']??0x0)),b['push'](''),b['push']('##\x20D-Check\x20Results\x20(Stage\x203\x20subset:\x20D-18)','');const d=runStageDChecks(0x3,a);b['push']('|\x20check_id\x20|\x20status\x20|\x20message\x20|'),b['push']('|----------|--------|---------|');for(const e of d){b['push']('|\x20'+e['check_id']+'\x20|\x20'+e['status']+'\x20|\x20'+e['message']+'\x20|');}return b['push'](''),b['join']('\x0a');}function renderStageStepsContent(a){const b=[];b['push']('#\x20Stage\x204:\x20Deployment\x20Steps\x20—\x20'+a['project_prefix']+'_'+a['version'],''),b['push']('##\x20Topological\x20Execution\x20Plan',''),b['push']('|\x20step\x20|\x20object_type\x20|\x20operation\x20|\x20substep_count\x20|\x20depends_on\x20|\x20entry_id\x20|\x20network_phase\x20|'),b['push']('|------|-------------|-----------|---------------|------------|----------|---------------|');for(const e of a['steps']){b['push']('|\x20'+e['step']+'\x20|\x20'+e['object_type']+'\x20|\x20'+e['operation']+'\x20|\x20'+e['substep_count']+'\x20|\x20['+e['depends_on']['join'](',\x20')+']\x20|\x20'+e['entry_id']+'\x20|\x20'+e['network_phase']+'\x20|');}b['push'](''),b['push']('##\x20D-Check\x20Results\x20(Stage\x204\x20subset:\x20D-08/D-09/D-11/D-12)','');const d=runStageDChecks(0x4,a);b['push']('|\x20check_id\x20|\x20status\x20|\x20message\x20|'),b['push']('|----------|--------|---------|');for(const f of d){b['push']('|\x20'+f['check_id']+'\x20|\x20'+f['status']+'\x20|\x20'+f['message']+'\x20|');}return b['push'](''),b['join']('\x0a');}function renderStageSubstepsContent(a){const b=[];return b['push']('#\x20Stage\x205:\x20Substep\x20Trace\x20—\x20'+a['project_prefix']+'_'+a['version'],''),b['push']('>\x20Substep\x20records\x20are\x20appended\x20at\x20runtime\x20(substeps-<network>.jsonl).',''),b['push']('>\x20This\x20file\x20records\x20the\x20validation\x20summary.',''),b['push'](''),b['push']('##\x20D-Check\x20Results\x20(Stage\x205\x20subset:\x20D-10)',''),b['push']('>\x20D-10\x20is\x20delegated\x20to\x20substep-trace.ts\x20(C4)\x20—\x20populated\x20at\x20runtime.',''),b['push']('|\x20check_id\x20|\x20status\x20|\x20message\x20|'),b['push']('|----------|--------|---------|'),b['push']('|\x20D-10\x20|\x20pending\x20|\x20delegated\x20to\x20substep-trace\x20(C4)\x20|'),b['push'](''),b['join']('\x0a');}const STAGE_CONTENT_RENDERERS={0x1:renderStageNamespaceContent,0x2:renderStagePuzzleContent,0x3:renderStageRiskContent,0x4:renderStageStepsContent,0x5:renderStageSubstepsContent};function generateStageAssessment(a,b){const c=STAGE_GOALS[a],d={},e=[],f=[],g=runStageDChecks(a,b),h=g['filter'](i=>i['status']==='fail');for(const i of c['success_criteria']){let j=0x1;const k=g['find'](l=>i['criterion_id']['includes'](l['check_id']['toLowerCase']()));if(k){if(k['status']==='fail')j=0.3;else{if(k['status']==='warn')j=0.7;}}h['length']>0x0&&!k&&(j=0.5),d[i['criterion_id']]=j,j<0x1&&(e['push']({'finding_id':'F-'+a+'-'+i['criterion_id'],'severity':j<0.5?'critical':'warn','criterion_id':i['criterion_id'],'description':'Criterion\x20\x22'+i['description']+'\x22\x20not\x20fully\x20met','evidence':k?k['message']:'stage\x20D-checks\x20failed'}),f['push']('Address\x20'+i['criterion_id']+':\x20'+i['description']));}return{'stage':a,'assessed_at':Date['now'](),'goal_completion':d,'findings':e,'recommendations':f};}function generateStageVerification(a,b){const c=STAGE_GOALS[a],d=runStageDChecks(a,b),e={};for(const i of c['success_criteria']){const j=d['find'](l=>i['criterion_id']['includes'](l['check_id']['toLowerCase']())),k=j?j['status']==='pass':d['every'](l=>l['status']!=='fail');e[i['criterion_id']]={'passed':k,'evidence':j?j['message']:'all\x20stage\x20D-checks\x20passed'};}const f=[];for(const l of d){l['status']==='fail'&&f['push'](l['check_id']+':\x20'+l['message']);}const g=[];a===0x2&&g['push']({'check_id':'CS-2-1','involves_stages':[0x1,0x2],'description':'All\x20object\x20names\x20start\x20with\x20the\x20project\x20prefix','passed':b['objects']['every'](m=>m['name']['startsWith'](b['project_prefix'])),'evidence':'prefix='+b['project_prefix']});if(a===0x4){const m=new Set(b['objects']['map'](n=>n['entry_id']));g['push']({'check_id':'CS-4-2','involves_stages':[0x2,0x4],'description':'All\x20steps\x20reference\x20defined\x20objects','passed':b['steps']['every'](n=>m['has'](n['entry_id'])),'evidence':b['steps']['length']+'\x20steps\x20checked'});}const h=f['length']===0x0;return{'stage':a,'verified_at':Date['now'](),'goal_verification':e,'d_checks':d,'cross_stage_checks':g,'stage_passed':h,'blocking_issues':f};}function generateValidationChainGraph(a){const b=[],c=[];for(const f of PROJECT_INVARIANTS){for(const g of f['verified_by_stages']){const h=STAGE_GOALS[g];b['push']({'source_type':'project_invariant','source_id':f['invariant_id'],'target_type':'stage_goal','target_stage':g,'target_id':'goal-stage-'+g,'derivation_logic':'invariant\x20\x22'+f['invariant_id']+'\x22\x20is\x20verified\x20by\x20stage\x20'+g+'\x20goal\x20\x22'+h['goal_statement']+'\x22'}),c['push']({'rule_id':'PR-'+f['invariant_id']+'-'+g,'trigger':{'stage':g,'event':'verification_failed'},'effect':{'target':'project_invariant','action':'block'}});}}const d=[0x1,0x2,0x3,0x4,0x5]['map'](i=>({'stage':i,'goal_id':'goal-stage-'+i,'assessment_id':'assessment-stage-'+i,'risk_policy_id':'risk-policy-stage-'+i,'verification_id':'verification-stage-'+i,'artifacts':['0'+i+'-<name>/README.md','0'+i+'-<name>/assessment.json','0'+i+'-<name>/risk-policy.json','0'+i+'-<name>/verification.json','0'+i+'-<name>/content.md']})),e={'puzzle.json':['02-puzzle/*','04-steps/*','README.md'],'risk.json':['03-risk/*','04-steps/*','README.md'],'stage.json':['README.md'],'substeps-testnet.jsonl':['05-substeps/*','README.md'],'substeps-mainnet.jsonl':['05-substeps/*','README.md']};return{'version':'1.0.0','generated_at':Date['now'](),'project_invariants':PROJECT_INVARIANTS,'stage_units':d,'derivations':b,'propagation_rules':c,'impact_map':e};}function renderProjectReadme(a,b){const c=[];c['push']('#\x20'+a['project_prefix']+'_'+a['version']+'\x20—\x20Project\x20Deployment',''),c['push']('>\x20**Nested-autonomy\x20deployment\x20documentation\x20set**.\x20',''),c['push']('>\x20Project-level\x20file:\x20goals\x20+\x20invariants\x20+\x20stage\x20index\x20+\x20global\x20ODG\x20+\x20resume\x20entry.',''),c['push']('>\x20Each\x20stage\x20has\x20its\x20own\x20subdirectory\x20with\x20goal/assessment/risk-policy/verification/content.',''),c['push'](''),c['push']('##\x20🔄\x20Project\x20Resume\x20(entry\x20point\x20for\x20any\x20AI\x20/\x20user)',''),c['push']('-\x20**Project**:\x20'+a['project_prefix']+'_'+a['version']),c['push']('-\x20**Business\x20intent**:\x20'+a['business_intent']),c['push']('-\x20**Industry**:\x20'+a['industry']),c['push']('-\x20**Generated\x20at**:\x20'+isoNow()),c['push']('-\x20**Schema\x20version**:\x20'+b['version']),c['push']('-\x20**Next\x20step**:\x20read\x20stage\x20completion\x20index\x20below,\x20then\x20open\x20the\x20relevant\x20stage\x20subdirectory',''),c['push']('>\x20Project\x20isolation\x20principle\x20(§3.0):\x20each\x20project\x20deploys\x20its\x20OWN\x20objects;',''),c['push']('>\x20cross-project\x20object\x20reuse\x20is\x20forbidden;\x20fork\x20creates\x20a\x20new\x20version\x20that\x20re-creates\x20objects.',''),c['push'](''),c['push']('##\x20§1\x20Project\x20Goals\x20+\x20Invariants',''),c['push']('**Goal**:\x20'+a['business_intent'],''),c['push']('###\x20Invariants\x20(derived\x20to\x20stage\x20goals\x20via\x20validation\x20chain)',''),c['push']('|\x20invariant_id\x20|\x20description\x20|\x20verified_by_stages\x20|'),c['push']('|--------------|-------------|---------------------|');for(const g of b['project_invariants']){c['push']('|\x20'+g['invariant_id']+'\x20|\x20'+g['description']+'\x20|\x20['+g['verified_by_stages']['join'](',\x20')+']\x20|');}c['push'](''),c['push']('##\x20§2\x20Naming\x20Conventions',''),c['push']('-\x20Project\x20prefix\x20regex:\x20`^[a-z][a-z0-9_]{2,63}$`'),c['push']('-\x20Version\x20format:\x20`v<n>`\x20(e.g.\x20`v1`,\x20`v2`)'),c['push']('-\x20Namespace\x20tag:\x20`project:<prefix>_<version>`'),c['push']('-\x20Object\x20naming:\x20`<project>_<type>_<version>`'),c['push'](''),c['push']('##\x20§3\x20Standard\x20Topological\x20Order\x20(shared\x20across\x20stages)',''),c['push']('```'),c['push'](STANDARD_TOPO_ORDER['join']('\x20→\x20')),c['push']('```',''),c['push']('##\x20§4\x20D-Check\x20Definitions\x20(18\x20checks,\x20definitions\x20only\x20—\x20results\x20per\x20stage)',''),c['push']('|\x20check_id\x20|\x20description\x20|'),c['push']('|----------|-------------|');for(const h of D_CHECK_ITEMS){c['push']('|\x20'+h['id']+'\x20|\x20'+h['description']+'\x20|');}c['push'](''),c['push']('##\x20§5\x20Stage\x20Completion\x20Index',''),c['push']('>\x20Auto-generated;\x20reflects\x20current\x20state\x20of\x20stage\x20subdirectories.',''),c['push']('|\x20Stage\x20|\x20Name\x20|\x20Status\x20|\x20Completion\x20|\x20Last\x20Verified\x20|\x20Passed\x20|\x20Blocking\x20|'),c['push']('|-------|------|--------|------------|----------------|--------|----------|');const d={0x1:'namespace',0x2:'puzzle',0x3:'risk',0x4:'steps',0x5:'substeps'};for(const i of[0x1,0x2,0x3,0x4,0x5]){c['push']('|\x20'+i+'\x20|\x20'+d[i]+'\x20|\x20pending\x20|\x200%\x20|\x20-\x20|\x20⏳\x20|\x20-\x20|');}c['push']('>\x20Note:\x20this\x20table\x20is\x20regenerated\x20on\x20each\x20`generate_deployment_doc`\x20call;\x20runtime',''),c['push']('>\x20execution\x20(stage\x205\x20substeps)\x20updates\x20the\x20`05-substeps/`\x20subdirectory\x20append-only.',''),c['push'](''),c['push']('##\x20§6\x20Global\x20Object\x20Dependency\x20Graph\x20(ODG)',''),c['push']('###\x20Nodes',''),c['push']('|\x20entry_id\x20|\x20object_type\x20|\x20name\x20|\x20publish_required\x20|\x20description\x20|'),c['push']('|----------|-------------|------|------------------|-------------|');for(const j of a['objects']){c['push']('|\x20'+j['entry_id']+'\x20|\x20'+j['object_type']+'\x20|\x20'+j['name']+'\x20|\x20'+j['publish_required']+'\x20|\x20'+(j['description']??'')+'\x20|');}c['push'](''),c['push']('###\x20Edges',''),c['push']('|\x20from\x20|\x20to\x20|\x20edge_kind\x20|\x20field_path\x20|\x20required_at_publish\x20|'),c['push']('|------|----|-----------|-------------|---------------------|');for(const k of a['edges']){c['push']('|\x20'+k['from']+'\x20|\x20'+k['to']+'\x20|\x20'+k['edge_kind']+'\x20|\x20'+k['field_path']+'\x20|\x20'+k['required_at_publish']+'\x20|');}c['push']('');const f=a['edges']['filter'](l=>!a['objects']['find'](m=>m['entry_id']===l['from'])||!a['objects']['find'](m=>m['entry_id']===l['to']));c['push']('###\x20Dependency\x20Summary',''),c['push']('-\x20Total\x20nodes:\x20'+a['objects']['length']),c['push']('-\x20Total\x20edges:\x20'+a['edges']['length']),c['push']('-\x20Dangling\x20dependencies:\x20'+f['length']),c['push']('-\x20Cross-project\x20references:\x200\x20(project\x20isolation\x20§3.0\x20enforced)',''),c['push'](''),c['push']('##\x20§7\x20Cross-Stage\x20Relations\x20(Validation\x20Chain)',''),c['push']('###\x20Invariant\x20→\x20Stage\x20Goal\x20Derivations',''),c['push']('|\x20Invariant\x20|\x20Stage\x20|\x20Stage\x20Goal\x20|'),c['push']('|-----------|-------|------------|');for(const l of b['derivations']){c['push']('|\x20'+l['source_id']+'\x20|\x20'+l['target_stage']+'\x20|\x20'+l['derivation_logic']+'\x20|');}c['push'](''),c['push']('###\x20Stage\x20Dependencies\x20(sequential)',''),c['push']('|\x20Upstream\x20|\x20Downstream\x20|\x20Reason\x20|'),c['push']('|---------|-----------|--------|'),c['push']('|\x20stage\x201\x20(namespace)\x20|\x20stage\x202\x20(puzzle)\x20|\x20Namespace\x20must\x20be\x20set\x20before\x20object\x20naming\x20|'),c['push']('|\x20stage\x202\x20(puzzle)\x20|\x20stage\x203\x20(risk)\x20|\x20Puzzle\x20must\x20be\x20complete\x20before\x20risk\x20assessment\x20|'),c['push']('|\x20stage\x202\x20(puzzle)\x20|\x20stage\x204\x20(steps)\x20|\x20Puzzle\x20determines\x20deployment\x20step\x20order\x20|'),c['push']('|\x20stage\x203\x20(risk)\x20|\x20stage\x204\x20(steps)\x20|\x20Risks\x20must\x20be\x20confirmed\x20before\x20execution\x20|'),c['push']('|\x20stage\x204\x20(steps)\x20|\x20stage\x205\x20(substeps)\x20|\x20Steps\x20must\x20be\x20defined\x20before\x20substep\x20tracing\x20|'),c['push'](''),c['push']('##\x20§8\x20Gas\x20/\x20Faucet\x20Rules',''),c['push']('-\x20testnet:\x20gas\x20is\x20free\x20(faucet)\x20—\x20encourage\x20experimentation,\x20rollback\x20is\x20costless'),c['push']('-\x20mainnet:\x20gas\x20is\x20real\x20—\x20re-running\x20after\x20rollback\x20incurs\x20real\x20cost,\x20WARN\x20before\x20rollback'),c['push']('-\x20Reversibility\x20is\x20determined\x20by\x20object\x20lifecycle\x20(§3.2),\x20NOT\x20by\x20network'),c['push'](''),c['push']('##\x20§9\x20Stage\x20Subdirectory\x20Index',''),c['push']('|\x20Stage\x20|\x20Directory\x20|\x20README\x20|\x20Assessment\x20|\x20Risk\x20Policy\x20|\x20Verification\x20|\x20Content\x20|'),c['push']('|-------|-----------|--------|------------|-------------|--------------|---------|');for(const m of[0x1,0x2,0x3,0x4,0x5]){const n='0'+m+'-'+d[m]+'/';c['push']('|\x20'+m+'\x20|\x20['+n+'](./'+n+')\x20|\x20[README.md](./'+n+'README.md)\x20|\x20[assessment.json](./'+n+'assessment.json)\x20|\x20[risk-policy.json](./'+n+'risk-policy.json)\x20|\x20[verification.json](./'+n+'verification.json)\x20|\x20[content.md](./'+n+'content.md)\x20|');}return c['push'](''),c['join']('\x0a');}function renderStageReadme(a,b){const d=STAGE_GOALS[a],e=[],f={0x1:'namespace',0x2:'puzzle',0x3:'risk',0x4:'steps',0x5:'substeps'};e['push']('#\x20Stage\x20'+a+':\x20'+f[a]+'\x20—\x20'+b['project_prefix']+'_'+b['version'],''),e['push']('>\x20**Nested-autonomy\x20unit**:\x20this\x20stage\x20is\x20self-governing.',''),e['push']('>\x20See\x20[../README.md](../README.md)\x20for\x20project-level\x20goals\x20+\x20invariants.',''),e['push'](''),e['push']('##\x20Stage\x20Goal\x20(derived\x20from\x20project\x20invariants)',''),e['push']('**Statement**:\x20'+d['goal_statement'],''),e['push']('**Derived\x20from**:\x20'+d['derived_from']['join'](',\x20'),''),e['push'](''),e['push']('###\x20Success\x20Criteria',''),e['push']('|\x20criterion_id\x20|\x20description\x20|\x20measurable\x20|\x20target\x20|'),e['push']('|--------------|-------------|------------|--------|');for(const g of d['success_criteria']){e['push']('|\x20'+g['criterion_id']+'\x20|\x20'+g['description']+'\x20|\x20'+g['measurable']+'\x20|\x20'+(g['target_value']??'-')+'\x20|');}return e['push'](''),e['push']('##\x20Stage\x20Files',''),e['push']('-\x20`assessment.json`\x20—\x20stage\x20assessment\x20(completion\x20per\x20criterion)'),e['push']('-\x20`risk-policy.json`\x20—\x20stage-specific\x20risks\x20+\x20controls'),e['push']('-\x20`verification.json`\x20—\x20stage\x20verification\x20(goal\x20+\x20D-checks\x20+\x20cross-stage)'),e['push']('-\x20`content.md`\x20—\x20stage\x20content\x20(actual\x20deployment\x20data)'),e['push'](''),e['join']('\x0a');}export function generateDeploymentDocSet(a,b,c){if(c['project_prefix']!==a)throw new Error('generateDeploymentDocSet:\x20input.project_prefix\x20('+c['project_prefix']+')\x20does\x20not\x20match\x20prefix\x20('+a+')');if(c['version']!==b)throw new Error('generateDeploymentDocSet:\x20input.version\x20('+c['version']+')\x20does\x20not\x20match\x20version\x20('+b+')');const d=deploymentDir(a,b);ensureProjectDir(a,b);const e=generateValidationChainGraph(c),f=[],g={0x1:'',0x2:'',0x3:'',0x4:'',0x5:''},h={0x1:'namespace',0x2:'puzzle',0x3:'risk',0x4:'steps',0x5:'substeps'};let i=!![];for(const k of[0x1,0x2,0x3,0x4,0x5]){const l='deployment/0'+k+'-'+h[k];g[k]=join(d,'0'+k+'-'+h[k]);const m=renderStageReadme(k,c);saveProjectMarkdown(a,b,l+'/README.md',m),f['push'](l+'/README.md');const n=generateStageAssessment(k,c);saveProjectFile(a,b,l+'/assessment.json',n),f['push'](l+'/assessment.json');const o=STAGE_RISK_POLICIES[k];saveProjectFile(a,b,l+'/risk-policy.json',o),f['push'](l+'/risk-policy.json');const p=generateStageVerification(k,c);if(!p['stage_passed'])i=![];saveProjectFile(a,b,l+'/verification.json',p),f['push'](l+'/verification.json');const q=STAGE_CONTENT_RENDERERS[k](c);saveProjectMarkdown(a,b,l+'/content.md',q),f['push'](l+'/content.md');}const j=renderProjectReadme(c,e);return saveProjectMarkdown(a,b,'deployment/README.md',j),f['push']('deployment/README.md'),saveProjectFile(a,b,'deployment/relations.json',e),f['push']('deployment/relations.json'),{'readme_path':join(d,'README.md'),'relations_path':join(d,'relations.json'),'stage_dirs':g,'all_files':f,'relations':e,'all_stages_passed':i};}
|