@wowok/agent-mcp 2.7.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/config/runtime.d.ts +1 -1
- package/dist/config/runtime.js +1 -1
- package/dist/examples/rental-ziroom-machine-create.json +1 -2
- package/dist/examples/rental-ziroom-permission-create.json +1 -2
- package/dist/examples/rental-ziroom-service-create.json +1 -2
- package/dist/experience/experience-reuse.js +1 -1
- package/dist/experience/index.d.ts +2 -1
- package/dist/experience/index.js +1 -1
- package/dist/experience/persistence-config.d.ts +6 -0
- package/dist/experience/persistence-config.js +1 -0
- package/dist/experience/persistence.d.ts +21 -0
- package/dist/experience/persistence.js +1 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/experience/user-profile.js +1 -1
- package/dist/extensions/business-modules.d.ts +1 -1
- package/dist/extensions/capability-manifest.d.ts +2 -83
- package/dist/extensions/capability-manifest.js +1 -1
- package/dist/extensions/constraint-registry.d.ts +6 -4
- package/dist/extensions/constraint-registry.js +1 -1
- package/dist/extensions/index.d.ts +4 -5
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/metric-registry.d.ts +6 -4
- package/dist/extensions/metric-registry.js +1 -1
- package/dist/extensions/mode-evaluator.d.ts +2 -3
- package/dist/extensions/mode-evaluator.js +1 -1
- package/dist/extensions/registry.d.ts +3 -25
- package/dist/extensions/registry.js +1 -1
- package/dist/extensions/types.d.ts +1 -69
- package/dist/goal/GoalClassifier.d.ts +17 -0
- package/dist/goal/GoalClassifier.js +1 -0
- package/dist/goal/GoalEngine.d.ts +155 -0
- package/dist/goal/GoalEngine.js +1 -0
- package/dist/goal/GoalStore.d.ts +27 -0
- package/dist/goal/GoalStore.js +1 -0
- package/dist/goal/plan-approval.d.ts +5 -0
- package/dist/goal/plan-approval.js +1 -0
- package/dist/goal/types.d.ts +80 -0
- package/dist/goal/types.js +1 -0
- package/dist/harness/index.d.ts +2 -7
- package/dist/harness/index.js +1 -1
- package/dist/harness/plan.d.ts +1 -1
- package/dist/harness/types.d.ts +0 -35
- package/dist/index.js +1 -1
- package/dist/knowledge/account-marks.d.ts +36 -0
- package/dist/knowledge/account-marks.js +1 -0
- package/dist/knowledge/audit-rules.d.ts +3 -1
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/examples-scanner-cli.js +1 -1
- package/dist/knowledge/examples-scanner.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +13 -9
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/goal-completion.d.ts +19 -0
- package/dist/knowledge/goal-completion.js +1 -0
- package/dist/knowledge/guard-bindings.d.ts +21 -0
- package/dist/knowledge/guard-bindings.js +1 -0
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.d.ts +6 -3
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
- package/dist/knowledge/mcp-schema-audit.js +1 -1
- package/dist/knowledge/operation-dictionary.js +1 -1
- package/dist/knowledge/passport-confirm.js +1 -1
- package/dist/knowledge/passport-puzzle.js +1 -1
- package/dist/knowledge/passport-translation.js +1 -1
- package/dist/knowledge/proof-risk.js +1 -1
- package/dist/knowledge/reward-risk.d.ts +1 -1
- package/dist/knowledge/reward-risk.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +2 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-topology.d.ts +43 -0
- package/dist/knowledge/scenario-topology.js +1 -0
- package/dist/knowledge/service-translation.js +1 -1
- package/dist/knowledge/supply-chain.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +36 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/knowledge/workspace-lists.d.ts +57 -0
- package/dist/knowledge/workspace-lists.js +1 -0
- package/dist/loop-engineering/context-collect.d.ts +1 -1
- package/dist/monitor/EventRouter.d.ts +10 -0
- package/dist/monitor/EventRouter.js +1 -0
- package/dist/monitor/EventStore.d.ts +32 -12
- package/dist/monitor/EventStore.js +1 -1
- package/dist/monitor/MonitorLoop.d.ts +81 -0
- package/dist/monitor/MonitorLoop.js +1 -0
- package/dist/monitor/ProblemBridge.d.ts +32 -0
- package/dist/monitor/ProblemBridge.js +1 -0
- package/dist/monitor/ScopeResolver.d.ts +59 -0
- package/dist/monitor/ScopeResolver.js +1 -0
- package/dist/monitor/SubscriptionStore.d.ts +13 -0
- package/dist/monitor/SubscriptionStore.js +1 -0
- package/dist/monitor/SuggestionBridge.d.ts +38 -0
- package/dist/monitor/SuggestionBridge.js +1 -0
- package/dist/monitor/normalize.d.ts +8 -0
- package/dist/monitor/normalize.js +1 -0
- package/dist/monitor/types.d.ts +89 -0
- package/dist/monitor/types.js +1 -0
- package/dist/participation/arbitrator-interest.d.ts +20 -0
- package/dist/participation/arbitrator-interest.js +1 -0
- package/dist/participation/demander-interest.d.ts +23 -0
- package/dist/participation/demander-interest.js +1 -0
- package/dist/persona/address-format.d.ts +1 -1
- package/dist/persona/address-format.js +1 -1
- package/dist/persona/distill-goal.d.ts +20 -0
- package/dist/persona/distill-goal.js +1 -0
- package/dist/persona/index.d.ts +2 -0
- package/dist/persona/index.js +1 -1
- package/dist/persona/model.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -0
- package/dist/{project → playbooks/service-build}/context-assembly.d.ts +9 -4
- package/dist/playbooks/service-build/context-assembly.js +1 -0
- package/dist/{project → playbooks/service-build}/game-theory.d.ts +1 -1
- package/dist/playbooks/service-build/index.d.ts +14 -0
- package/dist/playbooks/service-build/index.js +1 -0
- package/dist/{project → playbooks/service-build}/intent-analyzer.d.ts +1 -1
- package/dist/playbooks/service-build/intent-analyzer.js +1 -0
- package/dist/playbooks/service-build/machine-nodes.js +1 -0
- package/dist/{project → playbooks/service-build}/machine-panorama.d.ts +5 -3
- package/dist/playbooks/service-build/machine-panorama.js +1 -0
- package/dist/{project → playbooks/service-build}/merchant-guide.d.ts +21 -1
- package/dist/playbooks/service-build/merchant-guide.js +1 -0
- package/dist/{project → playbooks/service-build}/mode-actions.d.ts +32 -8
- package/dist/playbooks/service-build/mode-actions.js +1 -0
- package/dist/playbooks/service-build/namespace.d.ts +2 -0
- package/dist/playbooks/service-build/namespace.js +1 -0
- package/dist/{project → playbooks/service-build}/object-panorama.d.ts +2 -3
- package/dist/playbooks/service-build/object-panorama.js +1 -0
- package/dist/{project → playbooks/service-build}/participation-radar.d.ts +4 -5
- package/dist/playbooks/service-build/participation-radar.js +1 -0
- package/dist/{project → playbooks/service-build}/pipeline-actions.d.ts +9 -9
- package/dist/playbooks/service-build/pipeline-actions.js +1 -0
- package/dist/playbooks/service-build/process.d.ts +6 -0
- package/dist/playbooks/service-build/process.js +1 -0
- package/dist/playbooks/service-build/relationship-profile.d.ts +2 -0
- package/dist/playbooks/service-build/relationship-profile.js +1 -0
- package/dist/playbooks/service-build/risk-aggregator.js +1 -0
- package/dist/{project → playbooks/service-build}/semantic-graph.d.ts +7 -3
- package/dist/playbooks/service-build/semantic-graph.js +1 -0
- package/dist/{project → playbooks/service-build}/service-panorama.d.ts +3 -19
- package/dist/playbooks/service-build/service-panorama.js +1 -0
- package/dist/relationship/derivation.d.ts +88 -0
- package/dist/relationship/derivation.js +1 -0
- package/dist/relationship/incentive.d.ts +38 -0
- package/dist/relationship/incentive.js +1 -0
- package/dist/relationship/index.d.ts +4 -0
- package/dist/relationship/index.js +1 -0
- package/dist/relationship/registry.d.ts +13 -0
- package/dist/relationship/registry.js +1 -0
- package/dist/relationship/types.d.ts +45 -0
- package/dist/relationship/types.js +1 -0
- package/dist/review/arb.d.ts +6 -0
- package/dist/review/arb.js +1 -0
- package/dist/review/demand.d.ts +3 -0
- package/dist/review/demand.js +1 -0
- package/dist/review/index.d.ts +3 -0
- package/dist/review/index.js +1 -0
- package/dist/review/machine.d.ts +3 -0
- package/dist/review/machine.js +1 -0
- package/dist/review/order.d.ts +9 -0
- package/dist/review/order.js +1 -0
- package/dist/review/progress.d.ts +3 -0
- package/dist/review/progress.js +1 -0
- package/dist/review/repository.d.ts +3 -0
- package/dist/review/repository.js +1 -0
- package/dist/review/service.d.ts +5 -0
- package/dist/review/service.js +1 -0
- package/dist/review/types.d.ts +156 -0
- package/dist/review/types.js +1 -0
- package/dist/rules.d.ts +2 -2
- package/dist/rules.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/safety/index.d.ts +1 -1
- package/dist/safety/index.js +1 -1
- package/dist/safety/preview.d.ts +1 -0
- package/dist/safety/preview.js +1 -1
- package/dist/schema/call/allocation.d.ts +1 -1
- package/dist/schema/call/arbitration.d.ts +1 -1
- package/dist/schema/call/base.d.ts +1 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +29 -7
- package/dist/schema/call/bridge.js +1 -1
- package/dist/schema/call/contact.d.ts +1 -1
- package/dist/schema/call/contact.js +1 -1
- package/dist/schema/call/demand.d.ts +1 -1
- package/dist/schema/call/demand.js +1 -1
- package/dist/schema/call/guard.d.ts +3 -3
- package/dist/schema/call/handler.d.ts +0 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +2 -2
- package/dist/schema/call/order.d.ts +1 -1
- package/dist/schema/call/payment.d.ts +1 -1
- package/dist/schema/call/permission.d.ts +1 -1
- package/dist/schema/call/personal.d.ts +1 -1
- package/dist/schema/call/progress.d.ts +1 -1
- package/dist/schema/call/proof.d.ts +2 -2
- package/dist/schema/call/repository.d.ts +1 -1
- package/dist/schema/call/repository.js +1 -1
- package/dist/schema/call/reward.d.ts +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +1 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/call/treasury.d.ts +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/goal/index.d.ts +343 -0
- package/dist/schema/goal/index.js +1 -0
- package/dist/schema/goal/planning.d.ts +465 -0
- package/dist/schema/goal/planning.js +1 -0
- package/dist/schema/index.d.ts +1 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +323 -1
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/industry-pack/modes.d.ts +326 -0
- package/dist/schema/industry-pack/modes.js +1 -0
- package/dist/schema/intent-radar/index.d.ts +19 -19
- package/dist/schema/local/index.d.ts +11 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +258 -19
- package/dist/schema/operations.js +1 -1
- package/dist/schema/permission/index.d.ts +1 -0
- package/dist/schema/permission/index.js +1 -1
- package/dist/schema/persona/index.d.ts +40 -0
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/query/bi.d.ts +912 -0
- package/dist/schema/query/bi.js +1 -0
- package/dist/schema/query/index.d.ts +663 -2
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/utils/skills-recommendation.d.ts +0 -1
- package/dist/schema/utils/skills-recommendation.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +32 -3
- package/dist/schemas/account_operation.schema.json +8 -4
- package/dist/schemas/bridge_operation.output.json +26 -3
- package/dist/schemas/bridge_operation.schema.json +85 -13
- package/dist/schemas/config_operation.output.json +1 -1
- package/dist/schemas/config_operation.schema.json +1 -1
- package/dist/schemas/goal_operation.schema.json +1092 -0
- package/dist/schemas/guard2file.schema.json +3 -3
- package/dist/schemas/index.json +12 -13
- package/dist/schemas/industry_pack_operation.output.json +1073 -0
- package/dist/schemas/industry_pack_operation.schema.json +236 -2
- package/dist/schemas/local_info_operation.output.json +2 -2
- package/dist/schemas/local_mark_operation.output.json +2 -2
- package/dist/schemas/machineNode2file.schema.json +3 -3
- package/dist/schemas/messenger_operation.output.json +2 -2
- package/dist/schemas/monitor_events.output.json +78 -3
- package/dist/schemas/monitor_events.schema.json +24 -1
- package/dist/schemas/monitor_subscription.output.json +1462 -0
- package/dist/schemas/monitor_subscription.schema.json +327 -0
- package/dist/schemas/onchain_events.output.json +5 -5
- package/dist/schemas/onchain_operations.output.json +2 -2
- package/dist/schemas/onchain_operations.schema.json +100 -100
- package/dist/schemas/onchain_operations_allocation.schema.json +7 -7
- package/dist/schemas/onchain_operations_arbitration.schema.json +6 -6
- package/dist/schemas/onchain_operations_contact.schema.json +6 -6
- package/dist/schemas/onchain_operations_demand.schema.json +6 -6
- package/dist/schemas/onchain_operations_gen_passport.schema.json +3 -3
- package/dist/schemas/onchain_operations_gen_proof.schema.json +3 -3
- package/dist/schemas/onchain_operations_guard.schema.json +3 -3
- package/dist/schemas/onchain_operations_machine.schema.json +5 -5
- package/dist/schemas/onchain_operations_order.schema.json +5 -5
- package/dist/schemas/onchain_operations_payment.schema.json +4 -4
- package/dist/schemas/onchain_operations_permission.schema.json +5 -5
- package/dist/schemas/onchain_operations_personal.schema.json +3 -3
- package/dist/schemas/onchain_operations_progress.schema.json +5 -5
- package/dist/schemas/onchain_operations_proof.schema.json +3 -3
- package/dist/schemas/onchain_operations_repository.schema.json +7 -7
- package/dist/schemas/onchain_operations_reward.schema.json +9 -9
- package/dist/schemas/onchain_operations_service.schema.json +11 -11
- package/dist/schemas/onchain_operations_treasury.schema.json +9 -9
- package/dist/schemas/onchain_table_data.output.json +399 -2
- package/dist/schemas/onchain_table_data.schema.json +22 -22
- package/dist/schemas/permission_operation.schema.json +6 -2
- package/dist/schemas/persona_operation.output.json +145 -0
- package/dist/schemas/persona_operation.schema.json +28 -2
- package/dist/schemas/query_toolkit.output.json +1514 -22
- package/dist/schemas/query_toolkit.schema.json +465 -11
- package/dist/schemas/workflow_operation.schema.json +4 -4
- package/dist/task/ProcessStore.d.ts +98 -0
- package/dist/task/ProcessStore.js +1 -0
- package/dist/task/playbook.d.ts +11 -0
- package/dist/task/playbook.js +1 -0
- package/dist/task/stage-gate.d.ts +22 -0
- package/dist/task/stage-gate.js +1 -0
- package/dist/{project → task}/substep-trace.d.ts +6 -45
- package/dist/task/types.d.ts +144 -0
- package/dist/task/types.js +1 -0
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/goal.d.ts +4 -0
- package/dist/tools/handlers/goal.js +1 -0
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/local.d.ts +4 -3
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/monitor.d.ts +24 -0
- package/dist/tools/handlers/monitor.js +1 -1
- package/dist/tools/handlers/network.d.ts +1 -0
- package/dist/tools/handlers/network.js +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/permission.js +1 -1
- package/dist/tools/handlers/persona.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/watch.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/rules-hook.d.ts +1 -0
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +5 -4
- package/dist/harness/checkpoint.d.ts +0 -8
- package/dist/harness/checkpoint.js +0 -1
- package/dist/knowledge/deployment-scanner.d.ts +0 -66
- package/dist/knowledge/deployment-scanner.js +0 -1
- package/dist/mode-market/index.d.ts +0 -3
- package/dist/mode-market/index.js +0 -1
- package/dist/mode-market/registry.d.ts +0 -53
- package/dist/mode-market/registry.js +0 -1
- package/dist/mode-market/review.d.ts +0 -27
- package/dist/mode-market/review.js +0 -1
- package/dist/mode-market/submission.d.ts +0 -25
- package/dist/mode-market/submission.js +0 -1
- package/dist/project/business-puzzle.js +0 -1
- package/dist/project/context-assembly.js +0 -1
- package/dist/project/deployment-bridge.d.ts +0 -5
- package/dist/project/deployment-bridge.js +0 -1
- package/dist/project/deployment-doc.d.ts +0 -190
- package/dist/project/deployment-doc.js +0 -1
- package/dist/project/edit-planner.d.ts +0 -123
- package/dist/project/edit-planner.js +0 -1
- package/dist/project/evaluation-fix.spec.d.ts +0 -1
- package/dist/project/evaluation-fix.spec.js +0 -1
- package/dist/project/evaluation.d.ts +0 -127
- package/dist/project/evaluation.js +0 -1
- package/dist/project/graph-builder.d.ts +0 -51
- package/dist/project/graph-builder.js +0 -1
- package/dist/project/graph.d.ts +0 -70
- package/dist/project/graph.js +0 -1
- package/dist/project/handlers.d.ts +0 -524
- package/dist/project/handlers.js +0 -1
- package/dist/project/index.d.ts +0 -91
- package/dist/project/index.js +0 -1
- package/dist/project/intent-analyzer.js +0 -1
- package/dist/project/machine-nodes.js +0 -1
- package/dist/project/machine-panorama.js +0 -1
- package/dist/project/merchant-guide.js +0 -1
- package/dist/project/mode-actions.js +0 -1
- package/dist/project/namespace.d.ts +0 -72
- package/dist/project/namespace.js +0 -1
- package/dist/project/object-panorama.js +0 -1
- package/dist/project/participation-radar.js +0 -1
- package/dist/project/pipeline-actions.js +0 -1
- package/dist/project/project-store.d.ts +0 -110
- package/dist/project/project-store.js +0 -1
- package/dist/project/query.d.ts +0 -43
- package/dist/project/query.js +0 -1
- package/dist/project/risk-aggregator.js +0 -1
- package/dist/project/semantic-assembler.d.ts +0 -93
- package/dist/project/semantic-assembler.js +0 -1
- package/dist/project/semantic-graph.js +0 -1
- package/dist/project/service-panorama.js +0 -1
- package/dist/project/stage-gate.d.ts +0 -52
- package/dist/project/stage-gate.js +0 -1
- package/dist/project/task-tracker.d.ts +0 -30
- package/dist/project/task-tracker.js +0 -1
- package/dist/schema/project/index.d.ts +0 -2021
- package/dist/schema/project/index.js +0 -1
- package/dist/schema/task-status.d.ts +0 -62
- package/dist/schema/task-status.js +0 -1
- package/dist/schemas/project_operation.output.json +0 -7877
- package/dist/schemas/project_operation.schema.json +0 -1139
- package/dist/schemas/query_task_status.output.json +0 -211
- package/dist/schemas/query_task_status.schema.json +0 -18
- package/dist/tools/handlers/project.d.ts +0 -2
- package/dist/tools/handlers/project.js +0 -1
- package/dist/tools/handlers/task-status.d.ts +0 -2
- package/dist/tools/handlers/task-status.js +0 -1
- /package/dist/{project → playbooks/service-build}/business-puzzle.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/game-theory.js +0 -0
- /package/dist/{project → playbooks/service-build}/machine-nodes.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/object-type.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/object-type.js +0 -0
- /package/dist/{project → playbooks/service-build}/reverse-mapping.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/reverse-mapping.js +0 -0
- /package/dist/{project → playbooks/service-build}/risk-aggregator.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/workflow-design-assessment.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/workflow-design-assessment.js +0 -0
- /package/dist/{project → task}/substep-trace.js +0 -0
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import type { ProjectObjectType, IndustryMode } from "./namespace.js";
|
|
2
|
-
import type { EdgeKind } from "./graph.js";
|
|
3
|
-
export interface DeploymentObject {
|
|
4
|
-
entry_id: string;
|
|
5
|
-
object_type: ProjectObjectType;
|
|
6
|
-
name: string;
|
|
7
|
-
reused_from?: string;
|
|
8
|
-
publish_required: boolean;
|
|
9
|
-
description?: string;
|
|
10
|
-
config?: Record<string, unknown>;
|
|
11
|
-
status?: "draft" | "deployed";
|
|
12
|
-
}
|
|
13
|
-
export interface DeploymentDagEdge {
|
|
14
|
-
from: string;
|
|
15
|
-
to: string;
|
|
16
|
-
edge_kind: EdgeKind | string;
|
|
17
|
-
field_path: string;
|
|
18
|
-
required_at_publish: boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface DeploymentScenario {
|
|
21
|
-
scenario_id: string;
|
|
22
|
-
description: string;
|
|
23
|
-
primary_object: string;
|
|
24
|
-
supporting_objects: string[];
|
|
25
|
-
test_step_refs?: string[];
|
|
26
|
-
}
|
|
27
|
-
export interface DeploymentStep {
|
|
28
|
-
step: number;
|
|
29
|
-
object_type: ProjectObjectType;
|
|
30
|
-
operation: string;
|
|
31
|
-
substep_count: number;
|
|
32
|
-
depends_on: number[];
|
|
33
|
-
entry_id: string;
|
|
34
|
-
network_phase: "testnet" | "mainnet" | "both";
|
|
35
|
-
}
|
|
36
|
-
export interface DeploymentDocInput {
|
|
37
|
-
project_prefix: string;
|
|
38
|
-
business_intent: string;
|
|
39
|
-
industry: IndustryMode | string;
|
|
40
|
-
version: string;
|
|
41
|
-
author?: string;
|
|
42
|
-
scenario_mode?: string;
|
|
43
|
-
objects: DeploymentObject[];
|
|
44
|
-
edges: DeploymentDagEdge[];
|
|
45
|
-
steps: DeploymentStep[];
|
|
46
|
-
scenarios?: DeploymentScenario[];
|
|
47
|
-
risk_status?: "RISK_PASSED" | "RISK_BLOCKED" | "RISK_PENDING_CONFIRM" | "RISK_CANCELLED";
|
|
48
|
-
risk_critical_count?: number;
|
|
49
|
-
risk_high_count?: number;
|
|
50
|
-
detail_level?: "summary" | "detailed" | "full";
|
|
51
|
-
}
|
|
52
|
-
export interface DeploymentDocValidationResult {
|
|
53
|
-
valid: boolean;
|
|
54
|
-
checks: Array<{
|
|
55
|
-
check_id: string;
|
|
56
|
-
description: string;
|
|
57
|
-
status: "PASS" | "FAIL" | "WARN";
|
|
58
|
-
notes?: string;
|
|
59
|
-
}>;
|
|
60
|
-
errors: string[];
|
|
61
|
-
}
|
|
62
|
-
export interface GasEstimate {
|
|
63
|
-
total_gas_mist: number;
|
|
64
|
-
per_object: Array<{
|
|
65
|
-
entry_id: string;
|
|
66
|
-
object_type: string;
|
|
67
|
-
create_gas_mist: number;
|
|
68
|
-
publish_gas_mist: number;
|
|
69
|
-
}>;
|
|
70
|
-
publish_gas_mist: number;
|
|
71
|
-
}
|
|
72
|
-
export declare function generateDeploymentDoc(input: DeploymentDocInput): string;
|
|
73
|
-
export declare function estimateDeploymentGas(input: Pick<DeploymentDocInput, "objects">): GasEstimate;
|
|
74
|
-
export declare function validateDeploymentDoc(input: DeploymentDocInput): DeploymentDocValidationResult;
|
|
75
|
-
export declare function getStandardTopoOrder(): ProjectObjectType[];
|
|
76
|
-
export interface StageGoal {
|
|
77
|
-
stage: 1 | 2 | 3 | 4 | 5;
|
|
78
|
-
goal_statement: string;
|
|
79
|
-
derived_from: string[];
|
|
80
|
-
success_criteria: Array<{
|
|
81
|
-
criterion_id: string;
|
|
82
|
-
description: string;
|
|
83
|
-
measurable: boolean;
|
|
84
|
-
target_value?: string;
|
|
85
|
-
}>;
|
|
86
|
-
}
|
|
87
|
-
export interface StageAssessment {
|
|
88
|
-
stage: 1 | 2 | 3 | 4 | 5;
|
|
89
|
-
assessed_at: number;
|
|
90
|
-
goal_completion: Record<string, number>;
|
|
91
|
-
findings: Array<{
|
|
92
|
-
finding_id: string;
|
|
93
|
-
severity: "info" | "warn" | "critical";
|
|
94
|
-
criterion_id: string;
|
|
95
|
-
description: string;
|
|
96
|
-
evidence: unknown;
|
|
97
|
-
}>;
|
|
98
|
-
recommendations: string[];
|
|
99
|
-
}
|
|
100
|
-
export interface StageRiskPolicy {
|
|
101
|
-
stage: 1 | 2 | 3 | 4 | 5;
|
|
102
|
-
risks: Array<{
|
|
103
|
-
risk_id: string;
|
|
104
|
-
category: "naming" | "dependency" | "operational" | "financial" | "security";
|
|
105
|
-
description: string;
|
|
106
|
-
likelihood: "low" | "medium" | "high";
|
|
107
|
-
impact: "low" | "medium" | "high" | "critical";
|
|
108
|
-
mitigation: string;
|
|
109
|
-
owner: "ai" | "user" | "system";
|
|
110
|
-
}>;
|
|
111
|
-
active_controls: Array<{
|
|
112
|
-
control_id: string;
|
|
113
|
-
control_type: "preventive" | "detective" | "corrective";
|
|
114
|
-
target_risk: string;
|
|
115
|
-
implementation: string;
|
|
116
|
-
verified: boolean;
|
|
117
|
-
}>;
|
|
118
|
-
residual_risks: string[];
|
|
119
|
-
}
|
|
120
|
-
export interface StageVerification {
|
|
121
|
-
stage: 1 | 2 | 3 | 4 | 5;
|
|
122
|
-
verified_at: number;
|
|
123
|
-
goal_verification: Record<string, {
|
|
124
|
-
passed: boolean;
|
|
125
|
-
evidence: unknown;
|
|
126
|
-
}>;
|
|
127
|
-
d_checks: Array<{
|
|
128
|
-
check_id: string;
|
|
129
|
-
status: "pass" | "fail" | "warn";
|
|
130
|
-
message: string;
|
|
131
|
-
evidence: unknown;
|
|
132
|
-
}>;
|
|
133
|
-
cross_stage_checks: Array<{
|
|
134
|
-
check_id: string;
|
|
135
|
-
involves_stages: number[];
|
|
136
|
-
description: string;
|
|
137
|
-
passed: boolean;
|
|
138
|
-
evidence: unknown;
|
|
139
|
-
}>;
|
|
140
|
-
stage_passed: boolean;
|
|
141
|
-
blocking_issues: string[];
|
|
142
|
-
}
|
|
143
|
-
export interface ValidationChainLink {
|
|
144
|
-
source_type: "project_invariant" | "project_goal";
|
|
145
|
-
source_id: string;
|
|
146
|
-
target_type: "stage_goal" | "stage_risk" | "stage_verification";
|
|
147
|
-
target_stage: 1 | 2 | 3 | 4 | 5;
|
|
148
|
-
target_id: string;
|
|
149
|
-
derivation_logic: string;
|
|
150
|
-
}
|
|
151
|
-
export interface PropagationRule {
|
|
152
|
-
rule_id: string;
|
|
153
|
-
trigger: {
|
|
154
|
-
stage: number;
|
|
155
|
-
event: "verification_passed" | "verification_failed";
|
|
156
|
-
};
|
|
157
|
-
effect: {
|
|
158
|
-
target: "project_invariant" | "next_stage";
|
|
159
|
-
action: "verify" | "block";
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
export interface ValidationChainGraph {
|
|
163
|
-
version: string;
|
|
164
|
-
generated_at: number;
|
|
165
|
-
project_invariants: Array<{
|
|
166
|
-
invariant_id: string;
|
|
167
|
-
description: string;
|
|
168
|
-
verified_by_stages: number[];
|
|
169
|
-
}>;
|
|
170
|
-
stage_units: Array<{
|
|
171
|
-
stage: 1 | 2 | 3 | 4 | 5;
|
|
172
|
-
goal_id: string;
|
|
173
|
-
assessment_id: string;
|
|
174
|
-
risk_policy_id: string;
|
|
175
|
-
verification_id: string;
|
|
176
|
-
artifacts: string[];
|
|
177
|
-
}>;
|
|
178
|
-
derivations: ValidationChainLink[];
|
|
179
|
-
propagation_rules: PropagationRule[];
|
|
180
|
-
impact_map: Record<string, string[]>;
|
|
181
|
-
}
|
|
182
|
-
export interface DeploymentDocSetResult {
|
|
183
|
-
readme_path: string;
|
|
184
|
-
relations_path: string;
|
|
185
|
-
stage_dirs: Record<1 | 2 | 3 | 4 | 5, string>;
|
|
186
|
-
all_files: string[];
|
|
187
|
-
relations: ValidationChainGraph;
|
|
188
|
-
all_stages_passed: boolean;
|
|
189
|
-
}
|
|
190
|
-
export declare function generateDeploymentDocSet(prefix: string, version: string, input: DeploymentDocInput): DeploymentDocSetResult;
|
|
@@ -1 +0,0 @@
|
|
|
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']},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};}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
import { type MachineNodeForRender, type MachineEdgeForRender } from "../knowledge/machine-render.js";
|
|
3
|
-
import { type GuardNodeForRender } from "../knowledge/guard-render.js";
|
|
4
|
-
import type { ProjectOperationInputSchema } from "../schema/project/index.js";
|
|
5
|
-
type ProjectInput = z.infer<typeof ProjectOperationInputSchema>;
|
|
6
|
-
export declare function handlePlanObjectEdit(v: ProjectInput): Promise<{
|
|
7
|
-
action: "plan_object_edit";
|
|
8
|
-
plan_id: string;
|
|
9
|
-
object_kind: "guard" | "machine";
|
|
10
|
-
object_address: string;
|
|
11
|
-
object_name: string | null;
|
|
12
|
-
expected_hash: string;
|
|
13
|
-
diff: {
|
|
14
|
-
added: string[];
|
|
15
|
-
removed: string[];
|
|
16
|
-
modified: string[];
|
|
17
|
-
summary: string;
|
|
18
|
-
};
|
|
19
|
-
warnings: {
|
|
20
|
-
id: string;
|
|
21
|
-
description: string;
|
|
22
|
-
impact: string;
|
|
23
|
-
}[];
|
|
24
|
-
blocking_errors: {
|
|
25
|
-
id: string;
|
|
26
|
-
description: string;
|
|
27
|
-
impact: string;
|
|
28
|
-
}[];
|
|
29
|
-
can_apply: boolean;
|
|
30
|
-
prepared_call: unknown;
|
|
31
|
-
expires_at: string;
|
|
32
|
-
summary: string;
|
|
33
|
-
}>;
|
|
34
|
-
export declare function handleApplyObjectEdit(v: ProjectInput): Promise<{
|
|
35
|
-
action: "apply_object_edit";
|
|
36
|
-
plan_id: string;
|
|
37
|
-
applied: boolean;
|
|
38
|
-
hash_match: boolean;
|
|
39
|
-
prepared_call: null;
|
|
40
|
-
error: string;
|
|
41
|
-
next_step: string;
|
|
42
|
-
} | {
|
|
43
|
-
action: "apply_object_edit";
|
|
44
|
-
plan_id: string;
|
|
45
|
-
applied: boolean;
|
|
46
|
-
hash_match: boolean;
|
|
47
|
-
prepared_call: unknown;
|
|
48
|
-
error: null;
|
|
49
|
-
next_step: string;
|
|
50
|
-
}>;
|
|
51
|
-
export declare function handlePatchMachineNodes(v: ProjectInput): Promise<{
|
|
52
|
-
action: "patch_machine_nodes";
|
|
53
|
-
machine_address: string;
|
|
54
|
-
machine_name: string | null;
|
|
55
|
-
operations_applied: number;
|
|
56
|
-
operations_failed: {
|
|
57
|
-
operation: string;
|
|
58
|
-
error: string;
|
|
59
|
-
}[];
|
|
60
|
-
patched_nodes: MachineNodeForRender[];
|
|
61
|
-
patched_edges: MachineEdgeForRender[];
|
|
62
|
-
diff: {
|
|
63
|
-
added: string[];
|
|
64
|
-
removed: string[];
|
|
65
|
-
modified: string[];
|
|
66
|
-
summary: string;
|
|
67
|
-
};
|
|
68
|
-
warnings: {
|
|
69
|
-
id: string;
|
|
70
|
-
description: string;
|
|
71
|
-
impact: string;
|
|
72
|
-
}[];
|
|
73
|
-
blocking_errors: {
|
|
74
|
-
id: string;
|
|
75
|
-
description: string;
|
|
76
|
-
impact: string;
|
|
77
|
-
}[];
|
|
78
|
-
can_apply: boolean;
|
|
79
|
-
prepared_call: unknown;
|
|
80
|
-
summary: string;
|
|
81
|
-
}>;
|
|
82
|
-
export declare function handlePatchGuardTree(v: ProjectInput): Promise<{
|
|
83
|
-
action: "patch_guard_tree";
|
|
84
|
-
guard_address: string;
|
|
85
|
-
guard_name: string | null;
|
|
86
|
-
operations_applied: number;
|
|
87
|
-
operations_failed: {
|
|
88
|
-
operation: string;
|
|
89
|
-
error: string;
|
|
90
|
-
}[];
|
|
91
|
-
patched_root: GuardNodeForRender;
|
|
92
|
-
patched_table: {
|
|
93
|
-
identifier: number;
|
|
94
|
-
name?: string;
|
|
95
|
-
value_type: string | number;
|
|
96
|
-
b_submission: boolean;
|
|
97
|
-
value?: unknown;
|
|
98
|
-
}[];
|
|
99
|
-
patched_rely: {
|
|
100
|
-
guards: string[];
|
|
101
|
-
logic_or?: boolean;
|
|
102
|
-
} | null;
|
|
103
|
-
diff: {
|
|
104
|
-
added: string[];
|
|
105
|
-
removed: string[];
|
|
106
|
-
modified: string[];
|
|
107
|
-
summary: string;
|
|
108
|
-
};
|
|
109
|
-
warnings: {
|
|
110
|
-
id: string;
|
|
111
|
-
description: string;
|
|
112
|
-
impact: string;
|
|
113
|
-
}[];
|
|
114
|
-
blocking_errors: {
|
|
115
|
-
id: string;
|
|
116
|
-
description: string;
|
|
117
|
-
impact: string;
|
|
118
|
-
}[];
|
|
119
|
-
can_apply: boolean;
|
|
120
|
-
prepared_call: unknown;
|
|
121
|
-
summary: string;
|
|
122
|
-
}>;
|
|
123
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{randomUUID,createHash}from'node:crypto';import{LocalProject,LocalMark,query_objects}from'@wowok/wowok';import{MAX_NODE_COUNT}from'../knowledge/onchain-constants.js';import{fetchMachineNodes}from'./machine-nodes.js';import{parseMachineTreeIndented}from'../knowledge/machine-render.js';import{parseGuardTreeIndented,parseGuardTableJSON}from'../knowledge/guard-render.js';const PLAN_TTL_MS=0xa*0x3c*0x3e8,planStore=new Map();function cleanupExpiredPlans(){const a=Date['now']();for(const [b,c]of planStore){a>c['expires_at']&&planStore['delete'](b);}}const localProject=LocalProject['Instance']();async function resolveProjectId(a){if(a['project_id'])return a['project_id'];if(a['project']){const b=await localProject['getProjectByPrefix'](a['project']);if(!b)throw new Error('Project\x20not\x20found\x20by\x20prefix:\x20'+a['project']);return b['id'];}throw new Error('Either\x20\x27project_id\x27\x20or\x20\x27project\x27\x20(prefix)\x20is\x20required\x20for\x20this\x20action');}async function resolveObjectAddress(a){if(a['object_address']){const b=a['object_address'],c=/^0x[0-9a-fA-F]{32,64}$/['test'](b),d=b['startsWith']('draft:');if(!c&&!d)throw new Error('Invalid\x20object_address\x20format:\x20\x27'+b['slice'](0x0,0x28)+'\x27.\x20'+'Expected\x20a\x20valid\x20WOW\x20address\x20(0x\x20+\x2032-64\x20hex\x20chars)\x20or\x20\x27draft:<name>\x27\x20sentinel.');return b;}if(a['object_name_add']){const e=await LocalMark['Instance']()['get'](a['object_name_add']);if(e?.['address'])return e['address'];throw new Error('LocalMark\x20name\x20not\x20found:\x20'+a['object_name_add']);}throw new Error('Either\x20\x27object_address\x27\x20or\x20\x27object_name_add\x27\x20is\x20required');}function sha256(a){return createHash('sha256')['update'](a,'utf8')['digest']('hex');}function diffMachine(a,b,c,d){const f=[],g=[],h=[],i=new Set(a['map'](o=>o['name'])),j=new Set(c['map'](o=>o['name']));for(const n of j){if(!i['has'](n))f['push']('node:\x20'+n);}for(const o of i){if(!j['has'](o))g['push']('node:\x20'+o);}const k=new Map();for(const p of b)k['set'](p['from']+'->'+p['to'],p);const l=new Map();for(const q of d)l['set'](q['from']+'->'+q['to'],q);for(const [r,s]of l){if(!k['has'](r))f['push']('edge:\x20'+r);else{const t=k['get'](r);t['threshold']!==s['threshold']&&h['push']('edge\x20'+r+':\x20threshold\x20'+t['threshold']+'\x20->\x20'+s['threshold']);const u=new Set(t['forwards']['map'](w=>w['name'])),v=new Set(s['forwards']['map'](w=>w['name']));for(const w of v){if(!u['has'](w))f['push']('forward:\x20'+r+'\x20/\x20'+w);else{const x=t['forwards']['find'](A=>A['name']===w),y=s['forwards']['find'](A=>A['name']===w),z=[];if(x['guard']!==y['guard'])z['push']('guard\x20'+x['guard']+'\x20->\x20'+y['guard']);if(x['permission_index']!==y['permission_index'])z['push']('perm\x20'+x['permission_index']+'\x20->\x20'+y['permission_index']);if(x['named_operator']!==y['named_operator'])z['push']('op\x20'+x['named_operator']+'\x20->\x20'+y['named_operator']);if(x['weight']!==y['weight'])z['push']('weight\x20'+x['weight']+'\x20->\x20'+y['weight']);z['length']>0x0&&h['push']('forward\x20'+r+'\x20/\x20'+w+':\x20'+z['join'](',\x20'));}}for(const A of u){!v['has'](A)&&g['push']('forward:\x20'+r+'\x20/\x20'+A);}}}for(const B of k['keys']()){if(!l['has'](B))g['push']('edge:\x20'+B);}const m=f['length']+'\x20added,\x20'+g['length']+'\x20removed,\x20'+h['length']+'\x20modified';return{'added':f,'removed':g,'modified':h,'summary':m};}function diffGuard(a,b,c,d){const e=[],f=[],g=[];function h(l,m,n){if(!l&&m){e['push']('node:\x20'+n+'\x20('+m['type']+')');return;}if(l&&!m){f['push']('node:\x20'+n+'\x20('+l['type']+')');return;}if(!l||!m)return;if(l['type']!==m['type']){g['push']('node\x20'+n+':\x20type\x20'+l['type']+'\x20->\x20'+m['type']);return;}l['type']==='identifier'&&m['type']==='identifier'&&(l['identifier']!==m['identifier']&&g['push']('node\x20'+n+':\x20identifier\x20'+l['identifier']+'\x20->\x20'+m['identifier']));l['type']==='context'&&m['type']==='context'&&(l['context']!==m['context']&&g['push']('node\x20'+n+':\x20context\x20'+l['context']+'\x20->\x20'+m['context']));l['type']==='query'&&m['type']==='query'&&(l['query']!==m['query']&&g['push']('node\x20'+n+':\x20query\x20'+l['query']+'\x20->\x20'+m['query']));const o=getGuardChildren(l),p=getGuardChildren(m),q=Math['max'](o['length'],p['length']);for(let r=0x0;r<q;r++){h(o[r]?.['node'],p[r]?.['node'],n+'.'+(p[r]?.['label']??o[r]?.['label']??r));}}h(a,b,'root');const i=new Map(c['map'](l=>[l['identifier'],l])),j=new Map(d['map'](l=>[l['identifier'],l]));for(const [l,m]of j){if(!i['has'](l))e['push']('table:\x20id['+l+']');else{const n=i['get'](l),o=[];if(n['value_type']!==m['value_type'])o['push']('type\x20'+n['value_type']+'\x20->\x20'+m['value_type']);if(n['b_submission']!==m['b_submission'])o['push']('submission\x20'+n['b_submission']+'\x20->\x20'+m['b_submission']);if(JSON['stringify'](n['value'])!==JSON['stringify'](m['value']))o['push']('value\x20changed');if(o['length']>0x0)g['push']('table\x20id['+l+']:\x20'+o['join'](',\x20'));}}for(const p of i['keys']()){if(!j['has'](p))f['push']('table:\x20id['+p+']');}const k=e['length']+'\x20added,\x20'+f['length']+'\x20removed,\x20'+g['length']+'\x20modified';return{'added':e,'removed':f,'modified':g,'summary':k};}function getGuardChildren(a){const b=[];if(a['nodes'])a['nodes']['forEach']((d,e)=>b['push']({'node':d,'label':'child['+e+']'}));if(a['node'])b['push']({'node':a['node'],'label':'child'});if(a['nodeLeft'])b['push']({'node':a['nodeLeft'],'label':'left'});if(a['nodeRight'])b['push']({'node':a['nodeRight'],'label':'right'});if(a['parameters'])a['parameters']['forEach']((d,e)=>b['push']({'node':d,'label':'param['+e+']'}));if(a['historyIdx'])b['push']({'node':a['historyIdx'],'label':'historyIdx'});if(a['sessionIdx'])b['push']({'node':a['sessionIdx'],'label':'sessionIdx'});if(a['forwardIdx'])b['push']({'node':a['forwardIdx'],'label':'forwardIdx'});if(a['where'])b['push']({'node':a['where'],'label':'where'});if(a['find'])b['push']({'node':a['find'],'label':'find'});if(a['objectLeft'])b['push']({'node':a['objectLeft'],'label':'objLeft'});if(a['objectRight'])b['push']({'node':a['objectRight'],'label':'objRight'});if(a['recipient'])b['push']({'node':a['recipient'],'label':'recipient'});return b;}function validateMachine(a,b){const c=[],d=[],e=b['some'](i=>i['from']==='');!e&&d['push']({'id':'E-01','description':'No\x20entry\x20forward\x20found\x20(no\x20edge\x20with\x20from=\x27\x27).\x20Every\x20Machine\x20must\x20have\x20at\x20least\x20one\x20entry\x20forward.','impact':'The\x20Machine\x20cannot\x20start\x20—\x20no\x20way\x20to\x20create\x20the\x20first\x20Progress\x20entry.'});const f=new Set(a['map'](i=>i['name']));for(const i of b){i['from']&&!f['has'](i['from'])&&d['push']({'id':'E-02','description':'Edge\x20'+i['from']+'->'+i['to']+'\x20references\x20unknown\x20source\x20node\x20\x27'+i['from']+'\x27.','impact':'The\x20on-chain\x20Machine\x20will\x20reject\x20this\x20—\x20all\x20edge\x20endpoints\x20must\x20exist\x20as\x20nodes.'}),!f['has'](i['to'])&&d['push']({'id':'E-02','description':'Edge\x20'+i['from']+'->'+i['to']+'\x20references\x20unknown\x20target\x20node\x20\x27'+i['to']+'\x27.','impact':'The\x20on-chain\x20Machine\x20will\x20reject\x20this\x20—\x20all\x20edge\x20endpoints\x20must\x20exist\x20as\x20nodes.'});}a['length']>MAX_NODE_COUNT&&d['push']({'id':'E-03','description':'Node\x20count\x20'+a['length']+'\x20exceeds\x20on-chain\x20MAX_NODE_COUNT\x20('+MAX_NODE_COUNT+').','impact':'The\x20on-chain\x20Machine\x20will\x20reject\x20this\x20—\x20split\x20the\x20workflow\x20into\x20multiple\x20Machines.'});const g=new Set(b['filter'](j=>j['from']!=='')['map'](j=>j['to'])),h=new Set(b['filter'](j=>j['from']==='')['map'](j=>j['to']));for(const j of a){!g['has'](j['name'])&&!h['has'](j['name'])&&c['push']({'id':'W-01','description':'Node\x20\x27'+j['name']+'\x27\x20has\x20no\x20incoming\x20edges\x20and\x20is\x20not\x20an\x20entry\x20node\x20(unreachable).','impact':'This\x20node\x20will\x20never\x20be\x20reached\x20during\x20workflow\x20execution.'});}for(const k of b){k['from']===k['to']&&k['from']!==''&&c['push']({'id':'W-02','description':'Self-loop\x20detected\x20on\x20node\x20\x27'+k['from']+'\x27\x20(revision\x20cycle).','impact':'This\x20is\x20intentional\x20for\x20revision\x20workflows,\x20but\x20ensure\x20there\x27s\x20an\x20exit\x20forward\x20to\x20break\x20the\x20cycle.'});}return{'warnings':c,'blocking_errors':d};}function validateGuard(a,b){const c=[],d=[];if(!a)return d['push']({'id':'E-01','description':'Guard\x20tree\x20has\x20no\x20root\x20node.','impact':'The\x20on-chain\x20Guard\x20will\x20reject\x20this\x20—\x20every\x20Guard\x20must\x20have\x20a\x20root\x20computation\x20node.'}),{'warnings':c,'blocking_errors':d};const e=new Set(b['map'](k=>k['identifier'])),f=new Set();function g(k){k['type']==='identifier'&&typeof k['identifier']==='number'&&f['add'](k['identifier']);for(const l of getGuardChildren(k)){g(l['node']);}}g(a);for(const k of f){!e['has'](k)&&d['push']({'id':'E-02','description':'Identifier\x20'+k+'\x20is\x20referenced\x20in\x20the\x20tree\x20but\x20not\x20defined\x20in\x20the\x20table.','impact':'The\x20on-chain\x20Guard\x20will\x20reject\x20this\x20—\x20all\x20identifier\x20references\x20must\x20have\x20a\x20table\x20entry.'});}b['length']>0x100&&d['push']({'id':'E-03','description':'Table\x20size\x20'+b['length']+'\x20exceeds\x20on-chain\x20MAX_TABLE_SIZE\x20(256).','impact':'The\x20on-chain\x20Guard\x20will\x20reject\x20this\x20—\x20reduce\x20the\x20number\x20of\x20table\x20entries.'});const h=b['filter'](l=>l['b_submission']);for(const l of h){if(!f['has'](l['identifier'])){const m=l['name']?'\x27'+l['name']+'\x27\x20(id='+l['identifier']+')':'id='+l['identifier'];c['push']({'id':'W-01','description':'Submission\x20slot\x20'+m+'\x20is\x20declared\x20in\x20the\x20table\x20but\x20never\x20referenced\x20by\x20any\x20identifier\x20node\x20in\x20the\x20tree.','impact':'This\x20slot\x20is\x20dead\x20—\x20submitting\x20a\x20value\x20for\x20it\x20has\x20no\x20effect\x20on\x20the\x20guard\x20result.\x20Remove\x20it\x20or\x20add\x20an\x20identifier\x20reference.'});}}for(const n of b){if(!f['has'](n['identifier'])){if(n['b_submission'])continue;const o=n['name']?'\x27'+n['name']+'\x27\x20(id='+n['identifier']+')':'id='+n['identifier'];c['push']({'id':'W-02','description':'Table\x20entry\x20'+o+'\x20is\x20declared\x20but\x20never\x20referenced\x20by\x20any\x20identifier\x20node\x20in\x20the\x20tree.','impact':'This\x20entry\x20is\x20orphaned\x20—\x20it\x20consumes\x20table\x20space\x20without\x20affecting\x20the\x20guard\x20result.\x20Remove\x20it\x20to\x20reduce\x20table\x20size.'});}}function i(p,q){if(q>0x10)return q;const r=getGuardChildren(p);if(r['length']===0x0)return q;return Math['max'](...r['map'](s=>i(s['node'],q+0x1)));}const j=i(a,0x1);return j>0x10&&c['push']({'id':'W-03','description':'Guard\x20tree\x20depth\x20'+j+'\x20exceeds\x2016\x20(heuristic\x20threshold\x20for\x20on-chain\x20recursion\x20safety).','impact':'Deep\x20trees\x20may\x20hit\x20on-chain\x20stack/gas\x20limits\x20or\x20fail\x20audit.\x20Consider\x20flattening\x20logic\x20(e.g.\x20split\x20into\x20multiple\x20guards\x20connected\x20via\x20rely)\x20or\x20simplifying\x20nested\x20computations.'}),{'warnings':c,'blocking_errors':d};}function prepareMachineCall(a,b,c,d){const e=new Map();for(const h of c){e['set'](h['name'],{'name':h['name'],'description':h['description']??null,'pairs':[]});}for(const i of d){!e['has'](i['to'])&&e['set'](i['to'],{'name':i['to'],'description':null,'pairs':[]}),e['get'](i['to'])['pairs']['push']({'prev_node':i['from'],'threshold':i['threshold'],'forwards':i['forwards']['map'](j=>({'name':j['name'],'weight':j['weight'],'namedOperator':j['named_operator']??'','permissionIndex':j['permission_index']??0x0,'guard':j['guard']?{'guard':j['guard']}:null,'retained_submission':j['retained_submission']??null}))});}const f=Array['from'](e['values']()),g=JSON['stringify'](f,null,0x2);return{'operation_type':'machine','data':{'namedNew':{'name':a??b},'node':{'json_or_markdown':g},'bReplace':!![]}};}function prepareGuardCall(a,b,c,d,e){const f={'namedNew':{'name':a??b},'root':{'type':'inline_json','json':JSON['stringify'](c,null,0x2)},'table':d['map'](g=>({'identifier':g['identifier'],'b_submission':g['b_submission'],'value_type':typeof g['value_type']==='string'?g['value_type']:g['value_type'],'value':g['value'],'name':g['name']}))};return e&&Array['isArray'](e['guards'])&&e['guards']['length']>0x0&&(f['rely']={'guards':e['guards'],'logic_or':e['logic_or']}),{'operation_type':'guard','data':f};}export async function handlePlanObjectEdit(a){cleanupExpiredPlans();const b=await resolveProjectId(a),c=await resolveObjectAddress(a),d=a['object_kind'],e=a['edit_format']??'tree_outline',f=a['edited_content'];if(!d)throw new Error('\x27object_kind\x27\x20is\x20required\x20for\x20plan_object_edit\x20(must\x20be\x20\x27machine\x27\x20or\x20\x27guard\x27)');if(!f)throw new Error('\x27edited_content\x27\x20is\x20required\x20for\x20plan_object_edit');const g=await localProject['getProject'](b);if(!g)throw new Error('Project\x20not\x20found\x20(id:\x20'+b+')');let h=null;try{const x=await LocalMark['Instance']()['get'](c);h=x?.['name']??null;}catch{}const i=g['network']??'testnet';let j;d==='machine'?j=parseMachineTreeIndented(f):j=parseGuardTreeIndented(f);if(!j['success']||!j['data']){const y={'plan_id':randomUUID(),'object_kind':d,'object_address':c,'object_name':h,'expected_hash':sha256(f),'edited_content':f,'edit_format':e,'diff':{'added':[],'removed':[],'modified':[],'summary':'parse\x20failed\x20—\x20no\x20diff\x20computed'},'warnings':[],'blocking_errors':[{'id':'E-PARSE','description':'Failed\x20to\x20parse\x20edited\x20content:\x20'+j['errors']['join'](';\x20'),'impact':'The\x20edited\x20content\x20is\x20malformed\x20and\x20cannot\x20be\x20applied.\x20Fix\x20the\x20syntax\x20and\x20try\x20again.'}],'can_apply':![],'prepared_call':null,'created_at':Date['now'](),'expires_at':Date['now']()+PLAN_TTL_MS,'summary':'Parse\x20failed\x20—\x20'+j['errors']['length']+'\x20error(s)'};return planStore['set'](y['plan_id'],y),{'action':'plan_object_edit','plan_id':y['plan_id'],'object_kind':y['object_kind'],'object_address':y['object_address'],'object_name':y['object_name'],'expected_hash':y['expected_hash'],'diff':y['diff'],'warnings':y['warnings'],'blocking_errors':y['blocking_errors'],'can_apply':y['can_apply'],'prepared_call':y['prepared_call'],'expires_at':new Date(y['expires_at'])['toISOString'](),'summary':y['summary']};}const k=sha256(JSON['stringify'](j['data'])+f);if(d==='machine'){const z=j['data']['nodes'],A=j['data']['edges'];let B=[],C=[];try{const I=await fetchCurrentMachine(c,i);B=I['nodes'],C=I['edges'];}catch{}const D=diffMachine(B,C,z,A),E=validateMachine(z,A),F=E['blocking_errors']['length']===0x0,G=F?prepareMachineCall(h,c,z,A):null,H={'plan_id':randomUUID(),'object_kind':d,'object_address':c,'object_name':h,'expected_hash':k,'edited_content':f,'edit_format':e,'diff':D,'warnings':E['warnings'],'blocking_errors':E['blocking_errors'],'can_apply':F,'prepared_call':G,'created_at':Date['now'](),'expires_at':Date['now']()+PLAN_TTL_MS,'summary':'Machine\x20edit:\x20'+D['summary']+'.\x20'+E['blocking_errors']['length']+'\x20blocking\x20error(s),\x20'+E['warnings']['length']+'\x20warning(s).'};return planStore['set'](H['plan_id'],H),{'action':'plan_object_edit','plan_id':H['plan_id'],'object_kind':H['object_kind'],'object_address':H['object_address'],'object_name':H['object_name'],'expected_hash':H['expected_hash'],'diff':H['diff'],'warnings':H['warnings'],'blocking_errors':H['blocking_errors'],'can_apply':H['can_apply'],'prepared_call':H['prepared_call'],'expires_at':new Date(H['expires_at'])['toISOString'](),'summary':H['summary']};}const l=j['data'];let m=[];const n=parseGuardTableJSON(f);if(n&&n['length']>0x0)m=n;else{const J=f['match'](/##\s*Table[^\n]*\n([\s\S]*?)(?=\n##\s|$)/i);if(J){const K=J[0x1]['split']('\x0a')['filter'](L=>L['trim']()['startsWith']('|\x20'));for(const L of K['slice'](0x2)){const M=L['split']('|')['map'](N=>N['trim']())['filter'](Boolean);M['length']>=0x4&&m['push']({'identifier':parseInt(M[0x0],0xa),'b_submission':M[0x1]==='true','value_type':M[0x2],'value':M[0x3]==='-'?undefined:M[0x3],'name':M[0x4]==='-'?undefined:M[0x4]});}}}let o=null,p=[],q=null;try{const N=await fetchCurrentGuard(c,i);o=N['root'],p=N['table'],q=N['rely'];}catch{}const r=diffGuard(o??l,l,p,m),s=validateGuard(l,m),t=s['blocking_errors']['length']===0x0,u=t?prepareGuardCall(h,c,l,m,q):null,w={'plan_id':randomUUID(),'object_kind':d,'object_address':c,'object_name':h,'expected_hash':k,'edited_content':f,'edit_format':e,'diff':r,'warnings':s['warnings'],'blocking_errors':s['blocking_errors'],'can_apply':t,'prepared_call':u,'created_at':Date['now'](),'expires_at':Date['now']()+PLAN_TTL_MS,'summary':'Guard\x20edit:\x20'+r['summary']+'.\x20'+s['blocking_errors']['length']+'\x20blocking\x20error(s),\x20'+s['warnings']['length']+'\x20warning(s).'};return planStore['set'](w['plan_id'],w),{'action':'plan_object_edit','plan_id':w['plan_id'],'object_kind':w['object_kind'],'object_address':w['object_address'],'object_name':w['object_name'],'expected_hash':w['expected_hash'],'diff':w['diff'],'warnings':w['warnings'],'blocking_errors':w['blocking_errors'],'can_apply':w['can_apply'],'prepared_call':w['prepared_call'],'expires_at':new Date(w['expires_at'])['toISOString'](),'summary':w['summary']};}export async function handleApplyObjectEdit(a){cleanupExpiredPlans();const b=a['plan_id'],c=a['expected_hash'];if(!b)throw new Error('\x27plan_id\x27\x20is\x20required\x20for\x20apply_object_edit');if(!c)throw new Error('\x27expected_hash\x27\x20is\x20required\x20for\x20apply_object_edit');const d=planStore['get'](b);if(!d)return{'action':'apply_object_edit','plan_id':b,'applied':![],'hash_match':![],'prepared_call':null,'error':'Plan\x20not\x20found\x20(id:\x20'+b+').\x20The\x20plan\x20may\x20have\x20expired\x20(10-minute\x20TTL)\x20or\x20never\x20existed.','next_step':'Re-run\x20plan_object_edit\x20to\x20create\x20a\x20new\x20plan.'};if(Date['now']()>d['expires_at'])return planStore['delete'](b),{'action':'apply_object_edit','plan_id':b,'applied':![],'hash_match':![],'prepared_call':null,'error':'Plan\x20expired\x20at\x20'+new Date(d['expires_at'])['toISOString']()+'.\x20Plans\x20have\x20a\x2010-minute\x20TTL.','next_step':'Re-run\x20plan_object_edit\x20to\x20create\x20a\x20new\x20plan.'};const e=d['expected_hash']===c;if(!e)return{'action':'apply_object_edit','plan_id':b,'applied':![],'hash_match':![],'prepared_call':null,'error':'Hash\x20mismatch\x20—\x20the\x20on-chain\x20state\x20may\x20have\x20changed\x20between\x20plan\x20and\x20apply,\x20or\x20the\x20edited_content\x20was\x20modified.\x20Expected:\x20'+d['expected_hash']+',\x20got:\x20'+c+'.','next_step':'Re-run\x20plan_object_edit\x20to\x20create\x20a\x20fresh\x20plan\x20based\x20on\x20the\x20current\x20on-chain\x20state.'};if(!d['can_apply'])return{'action':'apply_object_edit','plan_id':b,'applied':![],'hash_match':!![],'prepared_call':null,'error':'Plan\x20has\x20'+d['blocking_errors']['length']+'\x20blocking\x20error(s).\x20Fix\x20them\x20before\x20applying:\x20'+d['blocking_errors']['map'](f=>f['description'])['join'](';\x20'),'next_step':'Fix\x20the\x20blocking\x20errors\x20in\x20the\x20edited\x20content,\x20then\x20re-run\x20plan_object_edit.'};return{'action':'apply_object_edit','plan_id':b,'applied':!![],'hash_match':!![],'prepared_call':d['prepared_call'],'error':null,'next_step':'Pass\x20the\x20prepared_call\x20to\x20onchain_operations\x20to\x20execute\x20the\x20edit\x20on-chain.\x20Review\x20the\x20call\x20data\x20before\x20executing\x20—\x20it\x20will\x20modify\x20the\x20on-chain\x20object.'};}async function fetchCurrentMachine(a,b){const c=await fetchMachineNodes(a,b),d=new Map(),e=[];for(const f of c){const g=f['name'];if(!g)continue;!d['has'](g)&&d['set'](g,{'name':g,'description':null});const h=Array['isArray'](f['value'])?f['value']:[];for(const i of h){if(!i||typeof i!=='object')continue;const j=typeof i['prev_node']==='string'?i['prev_node']:'',k=g,l=typeof i['threshold']==='number'?i['threshold']:0x1,m=Array['isArray'](i['forwards'])?i['forwards']:[],n=m['map'](o=>({'name':o['name']??'','weight':o['weight']??0x1,'named_operator':o['namedOperator']??null,'permission_index':o['permissionIndex']??null,'guard':o['guard']?.['guard']??o['guard']??null,'retained_submission':o['retained_submission']??null}));e['push']({'from':j,'to':k,'threshold':l,'forwards':n});}}for(const o of e){if(!d['has'](o['from']))d['set'](o['from'],{'name':o['from'],'description':null});if(!d['has'](o['to']))d['set'](o['to'],{'name':o['to'],'description':null});}return{'nodes':Array['from'](d['values']()),'edges':e};}async function fetchCurrentGuard(a,b){const c=await query_objects({'objects':[a],'network':b}),d=c?.['objects']?.[0x0]??null;if(!d)throw new Error('Guard\x20'+a+'\x20not\x20found\x20on\x20'+b);const e=d['root']??d['data']?.['root']??null,f=d['table']??d['data']?.['table']??[],g=d['relies']??d['data']?.['relies']??null,h=d['relies_logic_and']??d['data']?.['relies_logic_and']??null;let i=null;return Array['isArray'](g)&&g['length']>0x0&&(i={'guards':g,'logic_or':typeof h==='boolean'?!h:undefined}),{'root':e,'table':Array['isArray'](f)?f['map'](j=>({'identifier':j['identifier'],'name':j['name'],'value_type':j['value_type'],'b_submission':j['b_submission'],'value':j['value']})):[],'rely':i};}function parsePatchOperation(a){const b=a['trim']()['split'](/\s+/);if(b['length']<0x2)return null;const [c,d,...e]=b;if(c==='add'&&d==='node'&&e['length']>=0x1)return{'type':'add_node','args':e,'raw':a};if(c==='remove'&&d==='node'&&e['length']>=0x1)return{'type':'remove_node','args':e,'raw':a};if(c==='add'&&d==='edge'&&e['length']>=0x2)return{'type':'add_edge','args':e,'raw':a};if(c==='remove'&&d==='edge'&&e['length']>=0x2)return{'type':'remove_edge','args':e,'raw':a};if(c==='add'&&d==='forward'&&e['length']>=0x3)return{'type':'add_forward','args':e,'raw':a};if(c==='remove'&&d==='forward'&&e['length']>=0x3)return{'type':'remove_forward','args':e,'raw':a};if(c==='set'&&d==='threshold'&&e['length']>=0x3)return{'type':'set_threshold','args':e,'raw':a};if(c==='set'&&d==='guard'&&e['length']>=0x4)return{'type':'set_guard','args':e,'raw':a};if(c==='set'&&d==='permission'&&e['length']>=0x4)return{'type':'set_permission','args':e,'raw':a};if(c==='set'&&d==='operator'&&e['length']>=0x4)return{'type':'set_operator','args':e,'raw':a};if(c==='set'&&d==='weight'&&e['length']>=0x4)return{'type':'set_weight','args':e,'raw':a};if(c==='set'&&d==='retained_submission'&&e['length']>=0x4)return{'type':'set_retained_submission','args':e,'raw':a};if(c==='set'&&d==='description'&&e['length']>=0x2)return{'type':'set_description','args':e,'raw':a};return null;}function applyPatchOperation(a,b,c){switch(a['type']){case'add_node':{const d=a['args'][0x0];if(b['some'](e=>e['name']===d))return{'success':![],'error':'Node\x20\x27'+d+'\x27\x20already\x20exists'};return b['push']({'name':d,'description':null}),{'success':!![]};}case'remove_node':{const e=a['args'][0x0],f=b['findIndex'](h=>h['name']===e);if(f===-0x1)return{'success':![],'error':'Node\x20\x27'+e+'\x27\x20not\x20found'};const g=c['some'](h=>h['from']===e||h['to']===e);if(g)return{'success':![],'error':'Node\x20\x27'+e+'\x27\x20has\x20edges\x20—\x20remove\x20them\x20first'};return b['splice'](f,0x1),{'success':!![]};}case'add_edge':{const [h,i]=a['args'];if(!b['some'](j=>j['name']===i))return{'success':![],'error':'Target\x20node\x20\x27'+i+'\x27\x20not\x20found'};if(h!==''&&!b['some'](j=>j['name']===h))return{'success':![],'error':'Source\x20node\x20\x27'+h+'\x27\x20not\x20found'};if(c['some'](j=>j['from']===h&&j['to']===i))return{'success':![],'error':'Edge\x20\x27'+h+'->'+i+'\x27\x20already\x20exists'};return c['push']({'from':h,'to':i,'threshold':0x1,'forwards':[]}),{'success':!![]};}case'remove_edge':{const [j,k]=a['args'],l=c['findIndex'](m=>m['from']===j&&m['to']===k);if(l===-0x1)return{'success':![],'error':'Edge\x20\x27'+j+'->'+k+'\x27\x20not\x20found'};return c['splice'](l,0x1),{'success':!![]};}case'add_forward':{const [m,n,o]=a['args'],p=c['find'](q=>q['from']===m&&q['to']===n);if(!p)return{'success':![],'error':'Edge\x20\x27'+m+'->'+n+'\x27\x20not\x20found'};if(p['forwards']['some'](q=>q['name']===o))return{'success':![],'error':'Forward\x20\x27'+o+'\x27\x20already\x20exists\x20on\x20edge\x20\x27'+m+'->'+n+'\x27'};return p['forwards']['push']({'name':o,'weight':0x1,'named_operator':null,'permission_index':null,'guard':null,'retained_submission':null}),{'success':!![]};}case'remove_forward':{const [q,r,s]=a['args'],t=c['find'](v=>v['from']===q&&v['to']===r);if(!t)return{'success':![],'error':'Edge\x20\x27'+q+'->'+r+'\x27\x20not\x20found'};const u=t['forwards']['findIndex'](v=>v['name']===s);if(u===-0x1)return{'success':![],'error':'Forward\x20\x27'+s+'\x27\x20not\x20found\x20on\x20edge\x20\x27'+q+'->'+r+'\x27'};return t['forwards']['splice'](u,0x1),{'success':!![]};}case'set_threshold':{const [v,w,x]=a['args'],y=parseInt(x,0xa);if(isNaN(y)||y<0x1)return{'success':![],'error':'Invalid\x20threshold\x20value:\x20'+x};const z=c['find'](A=>A['from']===v&&A['to']===w);if(!z)return{'success':![],'error':'Edge\x20\x27'+v+'->'+w+'\x27\x20not\x20found'};return z['threshold']=y,{'success':!![]};}case'set_guard':{const [A,B,C,D]=a['args'],E=c['find'](G=>G['from']===A&&G['to']===B);if(!E)return{'success':![],'error':'Edge\x20\x27'+A+'->'+B+'\x27\x20not\x20found'};const F=E['forwards']['find'](G=>G['name']===C);if(!F)return{'success':![],'error':'Forward\x20\x27'+C+'\x27\x20not\x20found\x20on\x20edge\x20\x27'+A+'->'+B+'\x27'};return F['guard']=D==='none'?null:D,{'success':!![]};}case'set_permission':{const [G,H,I,J]=a['args'],K=c['find'](N=>N['from']===G&&N['to']===H);if(!K)return{'success':![],'error':'Edge\x20\x27'+G+'->'+H+'\x27\x20not\x20found'};const L=K['forwards']['find'](N=>N['name']===I);if(!L)return{'success':![],'error':'Forward\x20\x27'+I+'\x27\x20not\x20found\x20on\x20edge\x20\x27'+G+'->'+H+'\x27'};const M=parseInt(J,0xa);if(isNaN(M)||M<0x0)return{'success':![],'error':'Invalid\x20permission\x20index:\x20'+J+'\x20(must\x20be\x20a\x20non-negative\x20integer)'};return L['permission_index']=M,{'success':!![]};}case'set_operator':{const [N,O,P,...Q]=a['args'],R=Q['join']('\x20'),S=c['find'](U=>U['from']===N&&U['to']===O);if(!S)return{'success':![],'error':'Edge\x20\x27'+N+'->'+O+'\x27\x20not\x20found'};const T=S['forwards']['find'](U=>U['name']===P);if(!T)return{'success':![],'error':'Forward\x20\x27'+P+'\x27\x20not\x20found\x20on\x20edge\x20\x27'+N+'->'+O+'\x27'};return R==='none'?T['named_operator']=null:T['named_operator']=R,{'success':!![]};}case'set_weight':{const [U,V,W,X]=a['args'],Y=c['find'](a1=>a1['from']===U&&a1['to']===V);if(!Y)return{'success':![],'error':'Edge\x20\x27'+U+'->'+V+'\x27\x20not\x20found'};const Z=Y['forwards']['find'](a1=>a1['name']===W);if(!Z)return{'success':![],'error':'Forward\x20\x27'+W+'\x27\x20not\x20found\x20on\x20edge\x20\x27'+U+'->'+V+'\x27'};const a0=parseInt(X,0xa);if(isNaN(a0)||a0<0x1)return{'success':![],'error':'Invalid\x20weight:\x20'+X+'\x20(must\x20be\x20a\x20positive\x20integer)'};return Z['weight']=a0,{'success':!![]};}case'set_retained_submission':{const [a1,a2,a3,a4]=a['args'],a5=c['find'](a8=>a8['from']===a1&&a8['to']===a2);if(!a5)return{'success':![],'error':'Edge\x20\x27'+a1+'->'+a2+'\x27\x20not\x20found'};const a6=a5['forwards']['find'](a8=>a8['name']===a3);if(!a6)return{'success':![],'error':'Forward\x20\x27'+a3+'\x27\x20not\x20found\x20on\x20edge\x20\x27'+a1+'->'+a2+'\x27'};if(a4==='none')return a6['retained_submission']=null,{'success':!![]};const a7=a4['split'](',')['map'](a8=>{const a9=parseInt(a8['trim'](),0xa);if(isNaN(a9)||a9<0x0)return-0x1;return a9;});if(a7['some'](a8=>a8<0x0))return{'success':![],'error':'Invalid\x20retained_submission\x20indices:\x20'+a4+'\x20(must\x20be\x20comma-separated\x20non-negative\x20integers\x20or\x20\x27none\x27)'};return a6['retained_submission']=a7,{'success':!![]};}case'set_description':{const [a8,...a9]=a['args'],aa=b['find'](ac=>ac['name']===a8);if(!aa)return{'success':![],'error':'Node\x20\x27'+a8+'\x27\x20not\x20found'};const ab=a9['join']('\x20');return aa['description']=ab==='none'?null:ab,{'success':!![]};}default:return{'success':![],'error':'Unknown\x20operation\x20type:\x20'+a['type']};}}export async function handlePatchMachineNodes(a){const b=await resolveProjectId(a),c=await resolveObjectAddress(a),d=a['patch_operations']??[];if(d['length']===0x0)throw new Error('\x27patch_operations\x27\x20is\x20required\x20for\x20patch_machine_nodes\x20(non-empty\x20array)');const e=await localProject['getProject'](b);if(!e)throw new Error('Project\x20not\x20found\x20(id:\x20'+b+')');let f=null;try{const s=await LocalMark['Instance']()['get'](c);f=s?.['name']??null;}catch{}const g=e['network']??'testnet',h=await fetchCurrentMachine(c,g),i=h['nodes']['map'](t=>({...t})),j=h['edges']['map'](t=>({...t,'forwards':t['forwards']['map'](u=>({...u}))})),k=[];let l=0x0;for(const t of d){const u=parsePatchOperation(t);if(!u){k['push']({'operation':t,'error':'Invalid\x20operation\x20format.\x20See\x20patch_operations\x20schema\x20for\x20supported\x20formats.'});continue;}const w=applyPatchOperation(u,h['nodes'],h['edges']);w['success']?l++:k['push']({'operation':t,'error':w['error']??'Unknown\x20error'});}const m=diffMachine(i,j,h['nodes'],h['edges']),n=validateMachine(h['nodes'],h['edges']),o=[];for(const x of k){o['push']({'id':'E-OP','description':'Operation\x20\x27'+x['operation']+'\x27\x20failed:\x20'+x['error'],'impact':'This\x20operation\x20was\x20not\x20applied.\x20The\x20patch\x20cannot\x20be\x20executed\x20on-chain\x20until\x20all\x20operations\x20succeed.'});}for(const y of n['blocking_errors']){o['push'](y);}const p=o['length']===0x0,q=p?prepareMachineCall(f,c,h['nodes'],h['edges']):null,r='Patch:\x20'+l+'\x20applied,\x20'+k['length']+'\x20failed.\x20'+m['summary']+'.';return{'action':'patch_machine_nodes','machine_address':c,'machine_name':f,'operations_applied':l,'operations_failed':k,'patched_nodes':h['nodes'],'patched_edges':h['edges'],'diff':m,'warnings':n['warnings'],'blocking_errors':o['length']>0x0?o:[],'can_apply':p,'prepared_call':q,'summary':r};}function parseGuardPatchOperation(a){const b=a['trim']()['split'](/\s+/);if(b['length']<0x2)return null;const [c,d,...e]=b;if(c==='add'&&d==='table'&&e['length']>=0x4)return{'type':'add_table','args':e,'raw':a};if(c==='remove'&&d==='table'&&e['length']>=0x1)return{'type':'remove_table','args':e,'raw':a};if(c==='set'&&d==='table_value'&&e['length']>=0x2)return{'type':'set_table_value','args':e,'raw':a};if(c==='set'&&d==='table_name'&&e['length']>=0x2)return{'type':'set_table_name','args':e,'raw':a};if(c==='set'&&d==='table_submission'&&e['length']>=0x2)return{'type':'set_table_submission','args':e,'raw':a};if(c==='set'&&d==='root'&&e['length']>=0x1)return{'type':'set_root','args':e,'raw':a};if(c==='set'&&d==='rely'&&e['length']>=0x1)return{'type':'set_rely','args':e,'raw':a};return null;}function tryParseJSON(a){try{return JSON['parse'](a);}catch{return undefined;}}function applyGuardPatchOperation(a,b){switch(a['type']){case'add_table':{const [c,d,e,f,...g]=a['args'],h=parseInt(c,0xa);if(isNaN(h)||h<0x0)return{'success':![],'error':'Invalid\x20table\x20identifier:\x20'+c+'\x20(must\x20be\x20a\x20non-negative\x20integer)'};if(b['table']['some'](l=>l['identifier']===h))return{'success':![],'error':'Table\x20identifier\x20'+h+'\x20already\x20exists'};const i=f==='true',j=/^[0-9]+$/['test'](e)?parseInt(e,0xa):e;let k=undefined;if(g['length']>0x0){const l=g['join']('\x20');l!=='none'&&(k=tryParseJSON(l),k===undefined&&(k=l));}return b['table']['push']({'identifier':h,'name':d==='none'?undefined:d,'value_type':j,'b_submission':i,'value':k}),{'success':!![]};}case'remove_table':{const [m]=a['args'],n=parseInt(m,0xa);if(isNaN(n))return{'success':![],'error':'Invalid\x20table\x20identifier:\x20'+m};const o=b['table']['findIndex'](p=>p['identifier']===n);if(o===-0x1)return{'success':![],'error':'Table\x20identifier\x20'+n+'\x20not\x20found'};return b['table']['splice'](o,0x1),{'success':!![]};}case'set_table_value':{const [p,...q]=a['args'],r=parseInt(p,0xa);if(isNaN(r))return{'success':![],'error':'Invalid\x20table\x20identifier:\x20'+p};const s=b['table']['find'](u=>u['identifier']===r);if(!s)return{'success':![],'error':'Table\x20identifier\x20'+r+'\x20not\x20found'};const t=q['join']('\x20');if(t==='none')s['value']=undefined;else{const u=tryParseJSON(t);s['value']=u!==undefined?u:t;}return{'success':!![]};}case'set_table_name':{const [v,w,...x]=a['args'],y=parseInt(v,0xa);if(isNaN(y))return{'success':![],'error':'Invalid\x20table\x20identifier:\x20'+v};const z=b['table']['find'](B=>B['identifier']===y);if(!z)return{'success':![],'error':'Table\x20identifier\x20'+y+'\x20not\x20found'};const A=x['length']>0x0?[w,...x]['join']('\x20'):w;return z['name']=A==='none'?undefined:A,{'success':!![]};}case'set_table_submission':{const [B,C]=a['args'],D=parseInt(B,0xa);if(isNaN(D))return{'success':![],'error':'Invalid\x20table\x20identifier:\x20'+B};const E=b['table']['find'](F=>F['identifier']===D);if(!E)return{'success':![],'error':'Table\x20identifier\x20'+D+'\x20not\x20found'};if(C!=='true'&&C!=='false')return{'success':![],'error':'Invalid\x20b_submission\x20value:\x20'+C+'\x20(must\x20be\x20\x27true\x27\x20or\x20\x27false\x27)'};return E['b_submission']=C==='true',{'success':!![]};}case'set_root':{const F=a['args']['join']('\x20'),G=tryParseJSON(F);if(G===undefined||typeof G!=='object'||G===null)return{'success':![],'error':'Invalid\x20root\x20JSON:\x20\x27'+F['slice'](0x0,0x50)+'\x27\x20(must\x20be\x20a\x20valid\x20JSON\x20object)'};if(typeof G['type']!=='string')return{'success':![],'error':'Root\x20JSON\x20must\x20have\x20a\x20\x27type\x27\x20field\x20(string).\x20Got:\x20'+JSON['stringify'](Object['keys'](G))['slice'](0x0,0x50)};return{'success':!![],'newRoot':G};}case'set_rely':{const [H]=a['args'];if(H==='none')return b['rely']=null,{'success':!![]};const I=H['split'](',')['map'](J=>J['trim']())['filter'](J=>J['length']>0x0);if(I['length']===0x0)return{'success':![],'error':'Invalid\x20rely\x20value:\x20\x27'+H+'\x27\x20(expected\x20\x27none\x27\x20or\x20comma-separated\x20addresses)'};return b['rely']={'guards':I,'logic_or':b['rely']?.['logic_or']??![]},{'success':!![]};}default:return{'success':![],'error':'Unknown\x20Guard\x20patch\x20operation\x20type:\x20'+a['type']};}}export async function handlePatchGuardTree(a){const b=await resolveProjectId(a),c=await resolveObjectAddress(a),d=a['patch_operations']??[];if(d['length']===0x0)throw new Error('\x27patch_operations\x27\x20is\x20required\x20for\x20patch_guard_tree\x20(non-empty\x20array)');const e=await localProject['getProject'](b);if(!e)throw new Error('Project\x20not\x20found\x20(id:\x20'+b+')');let f=null;try{const u=await LocalMark['Instance']()['get'](c);f=u?.['name']??null;}catch{}const h=e['network']??'testnet',i=await fetchCurrentGuard(c,h),j=JSON['parse'](JSON['stringify'](i['root'])),k=i['table']['map'](w=>({...w,'value':w['value']!==undefined?JSON['parse'](JSON['stringify'](w['value'])):undefined})),l=[];let m=0x0,n=i['root'];for(const w of d){const x=parseGuardPatchOperation(w);if(!x){l['push']({'operation':w,'error':'Invalid\x20Guard\x20patch\x20operation\x20format.\x20See\x20patch_operations\x20schema\x20for\x20supported\x20formats.'});continue;}const y=applyGuardPatchOperation(x,{'root':n,'table':i['table'],'rely':i['rely']});y['success']?(m++,y['newRoot']&&(n=y['newRoot'])):l['push']({'operation':w,'error':y['error']??'Unknown\x20error'});}if(i['rely']&&Array['isArray'](i['rely']['guards'])){const z=[];for(const A of i['rely']['guards']){if(/^0x[0-9a-fA-F]{32,64}$/['test'](A))z['push'](A);else try{const B=await LocalMark['Instance']()['get'](A);B?.['address']?z['push'](B['address']):z['push'](A);}catch{z['push'](A);}}i['rely']['guards']=z;}const o=diffGuard(j,n,k,i['table']),p=validateGuard(n,i['table']),q=[];for(const C of l){q['push']({'id':'E-OP','description':'Operation\x20\x27'+C['operation']+'\x27\x20failed:\x20'+C['error'],'impact':'This\x20operation\x20was\x20not\x20applied.\x20The\x20patch\x20cannot\x20be\x20executed\x20on-chain\x20until\x20all\x20operations\x20succeed.'});}for(const D of p['blocking_errors']){q['push'](D);}const r=q['length']===0x0,s=r?prepareGuardCall(f,c,n,i['table'],i['rely']):null,t='Guard\x20patch:\x20'+m+'\x20applied,\x20'+l['length']+'\x20failed.\x20'+o['summary']+'.';return{'action':'patch_guard_tree','guard_address':c,'guard_name':f,'operations_applied':m,'operations_failed':l,'patched_root':n,'patched_table':i['table'],'patched_rely':i['rely'],'diff':o,'warnings':p['warnings'],'blocking_errors':q['length']>0x0?q:[],'can_apply':r,'prepared_call':s,'summary':t};}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{describe,it,expect}from'vitest';import{extractProjectEvaluationFacts}from'./evaluation.js';const SERVICE_ADDR='0x142b87262916f7b99dad034940815dd8cf862314c9d4a863a08584265c46b719',MACHINE_ADDR='0x157cf1aa07f1152a593a0a9a92d96ed8fbb146fd48065636565ef0f6b75e9465',PERMISSION_ADDR='0x1035f7c5ade2d66cec5a74dcc9440c80994fb8183dbea8a6da0f6f2cfc40d6bd',GUARD_WITHDRAW='0x1a7427f066374a774532fa677b8ba7a43aa480f6f6e4c9aca84b0a43c4247b76',GUARD_REFUND='0x1a4292ee44ae040988cd2c9a5b62e265246a0c33dad5256e1c63922ea25a7049',ARB_ADDR='0x13d328b529a261fdff25078ce34fff405ee663fe9d82ec1847869877ffc71b8a',CONTACT_ADDR='0x24a455e428ab4332a101d4863090b9204900b2ef8470a4250e6bed8bca12b76d';function projectObject(a,b,c){return{'id':'obj-'+c,'projectId':'p1','objectAddress':a,'objectType':b,'objectName':c,'role':'dependency','tags':null,'addedAt':0x0,'metadata':null};}function cacheEntry(a,b,c){return{'address':a,'objectType':b,'data':JSON['stringify'](c),'fetchedAt':0x0,'network':'testnet'};}describe('evaluate_project\x20A-fix:\x20bindings\x20derived\x20from\x20on-chain\x20cache',()=>{it('detects\x20Service\x20critical\x20bindings\x20with\x20an\x20EMPTY\x20graph\x20(build_graph\x20not\x20run)',()=>{const a={'machine':MACHINE_ADDR,'permission':PERMISSION_ADDR,'um':CONTACT_ADDR,'buy_guard':null,'order_allocators':{'description':'order\x20revenue\x20allocation','threshold':'0','allocators':[{'guard':GUARD_WITHDRAW,'sharing':0x2710},{'guard':GUARD_REFUND,'sharing':0x2710}]},'arbitrations':[ARB_ADDR]},b={'permission':PERMISSION_ADDR},c=[projectObject(SERVICE_ADDR,'Service','myshop_service_v2'),projectObject(MACHINE_ADDR,'Machine','myshop_machine_v2'),projectObject(PERMISSION_ADDR,'Permission','myshop_permission_v2'),projectObject(GUARD_WITHDRAW,'Guard','myshop_withdraw_guard_v2'),projectObject(GUARD_REFUND,'Guard','myshop_refund_guard_v2'),projectObject(ARB_ADDR,'Arbitration','myshop_arbitration_v2'),projectObject(CONTACT_ADDR,'Contact','myshop_aftersales_contact_v2')],d=new Map([[SERVICE_ADDR,cacheEntry(SERVICE_ADDR,'Service',a)],[MACHINE_ADDR,cacheEntry(MACHINE_ADDR,'Machine',b)]]),e=extractProjectEvaluationFacts({'project':{'id':'p1','prefix':'myshop','name':'myshop','description':null,'industry':'retail','perspective':'producer','status':'active','labels':null,'currentVersion':null,'serviceAddress':SERVICE_ADDR,'defaultAccount':null,'network':'testnet','createdAt':0x0,'updatedAt':0x0,'metadata':null},'objects':c,'edges':[],'objectCache':d}),f=g=>SERVICE_ADDR+'#'+g;expect(e['bindingIndex']['get'](f('machine'))?.['has'](MACHINE_ADDR))['toBe'](!![]),expect(e['bindingIndex']['get'](f('permission'))?.['has'](PERMISSION_ADDR))['toBe'](!![]),expect(e['bindingIndex']['get'](f('order_allocators'))?.['has'](GUARD_WITHDRAW))['toBe'](!![]),expect(e['bindingIndex']['get'](f('order_allocators'))?.['has'](GUARD_REFUND))['toBe'](!![]),expect(e['bindingIndex']['get'](f('arbitrations'))?.['has'](ARB_ADDR))['toBe'](!![]),expect(e['bindingIndex']['get'](f('um'))?.['has'](CONTACT_ADDR))['toBe'](!![]),expect(e['bindingIndex']['get'](MACHINE_ADDR+'#permission')?.['has'](PERMISSION_ADDR))['toBe'](!![]);}),it('still\x20merges\x20edge-derived\x20bindings\x20when\x20the\x20graph\x20IS\x20built',()=>{const a={'machine':MACHINE_ADDR,'permission':PERMISSION_ADDR},b=[projectObject(SERVICE_ADDR,'Service','myshop_service_v2'),projectObject(MACHINE_ADDR,'Machine','myshop_machine_v2')],c=new Map([[SERVICE_ADDR,cacheEntry(SERVICE_ADDR,'Service',a)]]),d=extractProjectEvaluationFacts({'project':{'id':'p1','prefix':'myshop','name':'myshop','description':null,'industry':'retail','perspective':'producer','status':'active','labels':null,'currentVersion':null,'serviceAddress':SERVICE_ADDR,'defaultAccount':null,'network':'testnet','createdAt':0x0,'updatedAt':0x0,'metadata':null},'objects':b,'edges':[{'id':'e1','projectId':'p1','sourceObject':SERVICE_ADDR,'targetObject':MACHINE_ADDR,'edgeSource':'internal','relationshipType':'bind','fieldName':'machine','depth':0x1,'verified':!![],'weight':0x1,'direction':null,'metadata':null,'cachedAt':0x0}],'objectCache':c});expect(d['bindingIndex']['get'](SERVICE_ADDR+'#machine')?.['has'](MACHINE_ADDR))['toBe'](!![]);});});
|