@wowok/agent-mcp 2.7.1 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.js +1 -1
- package/dist/config/runtime.js +1 -238
- package/dist/customer/customer-advice.js +1 -130
- package/dist/customer/index.js +1 -11
- package/dist/customer/industry-risks.js +1 -438
- package/dist/customer/info-puzzle.js +1 -681
- package/dist/customer/order-monitor.js +1 -328
- package/dist/customer/order-strategy.js +1 -373
- package/dist/customer/post-purchase.js +1 -351
- package/dist/customer/preorder-compare.js +1 -34
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.js +1 -13
- package/dist/customer/user-preferences.js +1 -460
- package/dist/evaluation/arbitration-game.d.ts +9 -2
- package/dist/evaluation/arbitration-game.js +1 -48
- package/dist/evaluation/builtins/demand-match.js +1 -153
- package/dist/evaluation/builtins/index.js +1 -10
- package/dist/evaluation/builtins/service-risk.js +1 -55
- package/dist/evaluation/capability.js +1 -13
- package/dist/evaluation/composer.js +1 -40
- package/dist/evaluation/engine.js +1 -175
- package/dist/evaluation/extract.js +1 -115
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.js +1 -100
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +1 -11
- package/dist/evaluation/node-game.d.ts +31 -3
- package/dist/evaluation/node-game.js +1 -57
- package/dist/evaluation/region.js +1 -36
- package/dist/evaluation/types.d.ts +1 -0
- package/dist/evaluation/types.js +1 -1
- package/dist/evaluation/user-injection.js +1 -27
- package/dist/experience/experience-reuse.js +1 -103
- package/dist/experience/index.js +1 -5
- package/dist/experience/intent-distill.js +1 -83
- package/dist/experience/realtime-feedback.js +1 -94
- package/dist/experience/types.js +1 -1
- package/dist/experience/user-profile.js +1 -171
- package/dist/extensions/business-modules.js +1 -287
- package/dist/extensions/capability-manifest.js +1 -781
- package/dist/extensions/constraint-registry.js +1 -198
- package/dist/extensions/index.js +1 -6
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.js +1 -315
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.js +1 -1
- package/dist/harness/verify.js +1 -237
- package/dist/index.js +1 -273
- package/dist/intent/enrich.js +1 -67
- package/dist/intent/index.js +1 -60
- package/dist/intent/matcher.js +1 -81
- package/dist/intent/store.js +1 -55
- package/dist/intent/types.js +1 -10
- package/dist/knowledge/acquisition-flywheel.js +1 -192
- package/dist/knowledge/allocation-confirm.js +1 -534
- package/dist/knowledge/allocation-context.js +1 -249
- package/dist/knowledge/allocation-ledger.js +1 -463
- package/dist/knowledge/allocation-puzzle.js +1 -298
- package/dist/knowledge/allocation-risk.js +1 -568
- package/dist/knowledge/allocation-templates.js +1 -970
- package/dist/knowledge/allocation-translation.js +1 -585
- package/dist/knowledge/arb-risk.js +1 -210
- package/dist/knowledge/arbitration-confirm.js +1 -559
- package/dist/knowledge/arbitration-context.js +1 -505
- package/dist/knowledge/arbitration-ledger.js +1 -521
- package/dist/knowledge/arbitration-puzzle.js +1 -304
- package/dist/knowledge/arbitration-risk.js +1 -423
- package/dist/knowledge/arbitration-templates.js +1 -276
- package/dist/knowledge/arbitration-translation.js +1 -487
- package/dist/knowledge/arbitration-trust.js +1 -117
- package/dist/knowledge/audit-rules.js +1 -141
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.js +1 -60
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-risk.js +1 -240
- package/dist/knowledge/demand-translation.js +1 -354
- package/dist/knowledge/deployment-scanner.js +1 -823
- package/dist/knowledge/dynamic-pricing.js +1 -87
- package/dist/knowledge/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -843
- package/dist/knowledge/flywheel-loop.js +1 -404
- package/dist/knowledge/fund-layer.js +1 -973
- package/dist/knowledge/glossary.js +1 -211
- package/dist/knowledge/guard-confirm.js +1 -406
- package/dist/knowledge/guard-context.js +1 -287
- package/dist/knowledge/guard-design-patterns.js +1 -360
- package/dist/knowledge/guard-ledger.js +1 -260
- package/dist/knowledge/guard-lint.js +1 -670
- package/dist/knowledge/guard-migration.js +1 -228
- package/dist/knowledge/guard-puzzle.js +1 -805
- package/dist/knowledge/guard-render.js +1 -700
- package/dist/knowledge/guard-risk.js +1 -1879
- package/dist/knowledge/guard-submission-prompt.js +1 -171
- package/dist/knowledge/guard-templates.js +1 -1105
- package/dist/knowledge/guard-translation.js +1 -1119
- package/dist/knowledge/index.js +1 -436
- package/dist/knowledge/industry-evolution.js +1 -323
- package/dist/knowledge/industry-generalizer.js +1 -381
- package/dist/knowledge/industry-registry.js +1 -174
- package/dist/knowledge/intent-metrics.d.ts +4 -3
- package/dist/knowledge/intent-metrics.js +1 -566
- package/dist/knowledge/machine-confirm.js +1 -559
- package/dist/knowledge/machine-context.js +1 -833
- package/dist/knowledge/machine-ledger.js +1 -338
- package/dist/knowledge/machine-puzzle.js +1 -494
- package/dist/knowledge/machine-render.js +1 -565
- package/dist/knowledge/machine-risk.js +1 -669
- package/dist/knowledge/machine-templates.js +1 -1597
- package/dist/knowledge/machine-topology.js +1 -234
- package/dist/knowledge/machine-translation.js +1 -513
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.js +1 -777
- package/dist/knowledge/onchain-constants.js +1 -35
- package/dist/knowledge/order-confirm.js +1 -573
- package/dist/knowledge/order-context.js +1 -390
- package/dist/knowledge/order-ledger.js +1 -341
- package/dist/knowledge/order-puzzle.js +1 -255
- package/dist/knowledge/order-risk.js +1 -653
- package/dist/knowledge/order-templates.js +1 -368
- package/dist/knowledge/order-translation.js +1 -550
- package/dist/knowledge/overrides-loader.js +1 -65
- package/dist/knowledge/passport-confirm.js +1 -531
- package/dist/knowledge/passport-context.js +1 -306
- package/dist/knowledge/passport-ledger.js +1 -282
- package/dist/knowledge/passport-puzzle.js +1 -333
- package/dist/knowledge/passport-risk.js +1 -450
- package/dist/knowledge/passport-templates.js +1 -568
- package/dist/knowledge/passport-translation.js +1 -516
- package/dist/knowledge/payment-risk.js +1 -249
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- package/dist/knowledge/permission-ledger.js +1 -403
- package/dist/knowledge/permission-puzzle.js +1 -173
- package/dist/knowledge/permission-risk.js +1 -411
- package/dist/knowledge/permission-templates.js +1 -234
- package/dist/knowledge/permission-translation.js +1 -350
- package/dist/knowledge/personal-risk.js +1 -212
- package/dist/knowledge/process-model.js +1 -160
- package/dist/knowledge/progress-confirm.js +1 -456
- package/dist/knowledge/progress-context.js +1 -452
- package/dist/knowledge/progress-ledger.js +1 -330
- package/dist/knowledge/progress-puzzle.js +1 -219
- package/dist/knowledge/progress-risk.js +1 -461
- package/dist/knowledge/progress-templates.js +1 -228
- package/dist/knowledge/progress-translation.js +1 -405
- package/dist/knowledge/proof-confirm.js +1 -187
- package/dist/knowledge/proof-risk.js +1 -207
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/reward-confirm.js +1 -526
- package/dist/knowledge/reward-context.js +1 -504
- package/dist/knowledge/reward-ledger.js +1 -502
- package/dist/knowledge/reward-puzzle.js +1 -300
- package/dist/knowledge/reward-risk.js +1 -627
- package/dist/knowledge/reward-templates.js +1 -197
- package/dist/knowledge/reward-translation.js +1 -501
- package/dist/knowledge/safety-rules.js +1 -404
- package/dist/knowledge/scenario-modes.js +1 -321
- package/dist/knowledge/service-confirm.js +1 -807
- package/dist/knowledge/service-context.js +1 -403
- package/dist/knowledge/service-ledger.js +1 -609
- package/dist/knowledge/service-puzzle.js +1 -236
- package/dist/knowledge/service-risk.js +1 -651
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.js +1 -353
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -178
- package/dist/knowledge/treasury-confirm.js +1 -512
- package/dist/knowledge/treasury-context.js +1 -363
- package/dist/knowledge/treasury-ledger.js +1 -300
- package/dist/knowledge/treasury-puzzle.js +1 -216
- package/dist/knowledge/treasury-risk.js +1 -440
- package/dist/knowledge/treasury-templates.js +1 -358
- package/dist/knowledge/treasury-translation.js +1 -498
- package/dist/knowledge/trust-metrics.js +1 -198
- package/dist/knowledge/util-risk.js +1 -135
- package/dist/loop-engineering/aggregate.js +1 -132
- package/dist/loop-engineering/context-collect.js +1 -83
- package/dist/loop-engineering/diagnose.js +1 -273
- package/dist/loop-engineering/improve.js +1 -405
- package/dist/loop-engineering/index.js +1 -4
- package/dist/loop-engineering/pipeline.js +1 -56
- package/dist/mode-market/index.js +1 -3
- package/dist/mode-market/registry.js +1 -124
- package/dist/mode-market/review.js +1 -214
- package/dist/mode-market/submission.js +1 -85
- package/dist/participation/collaborator-interest.d.ts +23 -0
- package/dist/participation/collaborator-interest.js +1 -0
- package/dist/participation/customer-interest.d.ts +25 -0
- package/dist/participation/customer-interest.js +1 -0
- package/dist/participation/merchant-interest.js +1 -100
- package/dist/participation/radar-core.d.ts +13 -3
- package/dist/participation/radar-core.js +1 -269
- package/dist/participation/supplier-interest.d.ts +25 -0
- package/dist/participation/supplier-interest.js +1 -0
- package/dist/persona/analyzer.js +1 -66
- package/dist/persona/bridge.js +1 -86
- package/dist/persona/defaults.js +1 -195
- package/dist/persona/experience-bridge.js +1 -23
- package/dist/persona/index.js +1 -71
- package/dist/persona/model.js +1 -111
- package/dist/persona/store.js +1 -62
- package/dist/persona/types.d.ts +3 -1
- package/dist/persona/types.js +1 -5
- package/dist/project/business-puzzle.js +1 -383
- package/dist/project/context-assembly.js +1 -254
- package/dist/project/deployment-bridge.js +1 -120
- package/dist/project/deployment-doc.js +1 -1126
- package/dist/project/edit-planner.js +1 -1342
- package/dist/project/evaluation.js +1 -2011
- package/dist/project/game-theory.js +1 -177
- package/dist/project/graph-builder.js +1 -656
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.js +1 -1784
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -301
- package/dist/project/intent-analyzer.js +1 -149
- package/dist/project/machine-nodes.js +1 -36
- package/dist/project/merchant-guide.js +1 -264
- package/dist/project/migration.js +1 -125
- package/dist/project/mode-actions.js +1 -309
- package/dist/project/namespace.js +1 -206
- package/dist/project/participation-radar.js +1 -428
- package/dist/project/pipeline-actions.js +1 -109
- package/dist/project/project-store.js +1 -422
- package/dist/project/query.js +1 -153
- package/dist/project/reverse-mapping.d.ts +34 -0
- package/dist/project/reverse-mapping.js +1 -0
- package/dist/project/risk-aggregator.js +1 -295
- package/dist/project/rollback-policy.js +1 -290
- package/dist/project/semantic-assembler.js +1 -345
- package/dist/project/semantic-graph.js +1 -292
- package/dist/project/stage-gate.js +1 -369
- package/dist/project/substep-trace.js +1 -332
- package/dist/project/task-tracker.js +1 -78
- package/dist/role/derivation.d.ts +18 -0
- package/dist/role/derivation.js +1 -0
- package/dist/role/index.d.ts +5 -0
- package/dist/role/index.js +1 -0
- package/dist/role/model.d.ts +8 -0
- package/dist/role/model.js +1 -0
- package/dist/role/resolution.d.ts +11 -0
- package/dist/role/resolution.js +1 -0
- package/dist/role/types.d.ts +11 -0
- package/dist/role/types.js +1 -0
- package/dist/rules.js +1 -52
- package/dist/safety/confirm-gate.js +1 -88
- package/dist/safety/index.js +1 -3
- package/dist/safety/preview.js +1 -52
- package/dist/schema/call/allocation.js +1 -34
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +15 -15
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge-handler.js +1 -265
- package/dist/schema/call/bridge.d.ts +7 -7
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.js +1 -47
- package/dist/schema/call/guard.js +1 -161
- package/dist/schema/call/handler.js +1 -322
- package/dist/schema/call/index.js +1 -20
- package/dist/schema/call/machine.js +1 -193
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1679
- package/dist/schema/call/service.js +1 -184
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/evaluation/index.d.ts +213 -16
- package/dist/schema/evaluation/index.js +1 -356
- package/dist/schema/index.js +1 -17
- package/dist/schema/intent-radar/index.d.ts +13 -13
- package/dist/schema/intent-radar/index.js +1 -89
- package/dist/schema/local/index.d.ts +21 -21
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +7 -7
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +7 -7
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +54 -54
- package/dist/schema/persona/index.js +1 -148
- package/dist/schema/project/index.d.ts +94 -48
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1646
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.js +1 -286
- package/dist/schema/task-status.js +1 -36
- package/dist/schema/trust/index.js +1 -314
- package/dist/schema/utils/guard-parser.js +1 -419
- package/dist/schema/utils/guard-query-utils.js +1 -46
- package/dist/schema/utils/node-parser.js +1 -369
- package/dist/schema/utils/object-type-utils.js +1 -35
- package/dist/schema/utils/permission-index-utils.js +1 -7
- package/dist/schema/utils/permission-machine-check.js +1 -121
- package/dist/schema/utils/skills-recommendation.js +1 -77
- package/dist/schema-query/index.js +1 -810
- package/dist/schemas/account_operation.output.json +5 -2
- package/dist/schemas/bridge_operation.output.json +5 -2
- package/dist/schemas/evaluation_operation.output.json +112 -7
- package/dist/schemas/evaluation_operation.schema.json +93 -6
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/intent_radar.output.json +4 -1
- package/dist/schemas/intent_radar.schema.json +4 -1
- package/dist/schemas/local_info_operation.output.json +5 -2
- package/dist/schemas/local_mark_operation.output.json +5 -2
- package/dist/schemas/messenger_operation.output.json +5 -2
- package/dist/schemas/onchain_events.output.json +5 -2
- package/dist/schemas/onchain_operations.output.json +5 -2
- package/dist/schemas/onchain_operations.schema.json +4 -4
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +4 -1
- package/dist/schemas/persona_operation.schema.json +4 -1
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_toolkit.output.json +8 -5
- package/dist/schemas/wowok_buildin_info.output.json +132 -0
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- package/dist/telemetry/index.js +1 -112
- package/dist/telemetry/redact.js +1 -23
- package/dist/telemetry/storage.js +1 -80
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/evaluation.js +1 -123
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.js +1 -76
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1180
- package/dist/tools/handlers/persona.js +1 -89
- package/dist/tools/handlers/project.js +1 -211
- package/dist/tools/handlers/query.js +1 -434
- package/dist/tools/handlers/schema-query.js +1 -176
- package/dist/tools/handlers/task-status.js +1 -26
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1382
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.js +1 -130
- package/dist/tools/types.js +1 -1
- package/dist/tools/upgrade-check.d.ts +19 -0
- package/dist/tools/upgrade-check.js +1 -0
- package/dist/tools/wip-deploy-assist.js +1 -306
- package/dist/tools/wrap.js +1 -500
- package/package.json +4 -2
|
@@ -1,333 +1 @@
|
|
|
1
|
-
import { MAX_GUARD_COUNT_PASSPORT, MAX_SUBMISSION_SIZE_PASSPORT, } from "./passport-ledger.js";
|
|
2
|
-
export function initPuzzleFromIntent(intent) {
|
|
3
|
-
const puzzle = {};
|
|
4
|
-
if (intent.protected_operation || intent.verification_rules || intent.consumer_object) {
|
|
5
|
-
puzzle.intent = {
|
|
6
|
-
protected_operation: intent.protected_operation ?? "",
|
|
7
|
-
consumer_object: intent.consumer_object ?? "Service",
|
|
8
|
-
verification_rules: intent.verification_rules ?? [],
|
|
9
|
-
failure_conditions: intent.failure_conditions ?? [],
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
puzzle.verify = {
|
|
13
|
-
tx_hash_binding: true,
|
|
14
|
-
has_verified: false,
|
|
15
|
-
verify_flow: buildDefaultVerifyFlow(),
|
|
16
|
-
};
|
|
17
|
-
puzzle.lifecycle = {
|
|
18
|
-
stages: buildDefaultLifecycleStages(),
|
|
19
|
-
terminal_state: "undecided",
|
|
20
|
-
destroy_before_freeze: true,
|
|
21
|
-
};
|
|
22
|
-
return puzzle;
|
|
23
|
-
}
|
|
24
|
-
export function checkPuzzleCompleteness(puzzle) {
|
|
25
|
-
const missing = [];
|
|
26
|
-
const missing_details = [];
|
|
27
|
-
if (!puzzle.intent) {
|
|
28
|
-
missing.push("A");
|
|
29
|
-
missing_details.push({ dimension: "A", reason: "Intent not specified (protected_operation + verification_rules)" });
|
|
30
|
-
}
|
|
31
|
-
else if (!puzzle.intent.protected_operation) {
|
|
32
|
-
missing.push("A");
|
|
33
|
-
missing_details.push({ dimension: "A", reason: "protected_operation is empty" });
|
|
34
|
-
}
|
|
35
|
-
else if (puzzle.intent.verification_rules.length === 0) {
|
|
36
|
-
missing.push("A");
|
|
37
|
-
missing_details.push({ dimension: "A", reason: "verification_rules is empty — what should each Guard check?" });
|
|
38
|
-
}
|
|
39
|
-
if (!puzzle.binding) {
|
|
40
|
-
missing.push("B");
|
|
41
|
-
missing_details.push({ dimension: "B", reason: "Binding not specified (guard_objects + impack_flags + relies)" });
|
|
42
|
-
}
|
|
43
|
-
else if (puzzle.binding.guard_objects.length === 0) {
|
|
44
|
-
missing.push("B");
|
|
45
|
-
missing_details.push({ dimension: "B", reason: "guard_objects is empty — at least 1 Guard required" });
|
|
46
|
-
}
|
|
47
|
-
else if (!puzzle.binding.impack_flags.some(f => f)) {
|
|
48
|
-
missing.push("B");
|
|
49
|
-
missing_details.push({ dimension: "B", reason: "No impack=true Guard — at least 1 required (E_IMPACK_GUARD_NOT_FOUND)" });
|
|
50
|
-
}
|
|
51
|
-
else if (puzzle.binding.guard_objects.length > MAX_GUARD_COUNT_PASSPORT) {
|
|
52
|
-
missing.push("B");
|
|
53
|
-
missing_details.push({ dimension: "B", reason: `guard_objects count ${puzzle.binding.guard_objects.length} > MAX_GUARD_COUNT_PASSPORT=${MAX_GUARD_COUNT_PASSPORT}` });
|
|
54
|
-
}
|
|
55
|
-
if (!puzzle.submission) {
|
|
56
|
-
missing.push("C");
|
|
57
|
-
missing_details.push({ dimension: "C", reason: "Submission not specified (per-Guard identifier + value + value_type)" });
|
|
58
|
-
}
|
|
59
|
-
else if (!puzzle.submission.size_ok) {
|
|
60
|
-
missing.push("C");
|
|
61
|
-
missing_details.push({
|
|
62
|
-
dimension: "C",
|
|
63
|
-
reason: `max_entry_size ${puzzle.submission.max_entry_size} > MAX_SUBMISSION_SIZE_PASSPORT=${MAX_SUBMISSION_SIZE_PASSPORT}`,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
if (!puzzle.verify) {
|
|
67
|
-
missing.push("D");
|
|
68
|
-
missing_details.push({ dimension: "D", reason: "Verify dimension not initialized (should be auto-filled)" });
|
|
69
|
-
}
|
|
70
|
-
if (!puzzle.result) {
|
|
71
|
-
missing.push("E");
|
|
72
|
-
missing_details.push({ dimension: "E", reason: "Result computation not derived (call buildResultPuzzle from binding)" });
|
|
73
|
-
}
|
|
74
|
-
if (!puzzle.lifecycle) {
|
|
75
|
-
missing.push("F");
|
|
76
|
-
missing_details.push({ dimension: "F", reason: "Lifecycle not initialized (should be auto-filled)" });
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
dimensions: ["A", "B", "C", "D", "E", "F"],
|
|
80
|
-
missing,
|
|
81
|
-
missing_details,
|
|
82
|
-
complete: missing.length === 0,
|
|
83
|
-
next_step: missing.length === 0
|
|
84
|
-
? "Puzzle complete — ready for confirmation text generation"
|
|
85
|
-
: `Next: complete dimension ${missing[0]} — ${missing_details[0].reason}`,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
export function validateConstraints(puzzle) {
|
|
89
|
-
const violations = [];
|
|
90
|
-
if (puzzle.binding && puzzle.binding.guard_objects.length > MAX_GUARD_COUNT_PASSPORT) {
|
|
91
|
-
violations.push({
|
|
92
|
-
constraint_id: "F-PASS-04",
|
|
93
|
-
severity: "CRITICAL",
|
|
94
|
-
message: `Guard count ${puzzle.binding.guard_objects.length} exceeds MAX_GUARD_COUNT_PASSPORT=${MAX_GUARD_COUNT_PASSPORT}`,
|
|
95
|
-
current_value: puzzle.binding.guard_objects.length,
|
|
96
|
-
limit: MAX_GUARD_COUNT_PASSPORT,
|
|
97
|
-
related_move_error: "E_GUARD_COUNT_EXCEEDED (1)",
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
if (puzzle.binding && !puzzle.binding.impack_flags.some(f => f)) {
|
|
101
|
-
violations.push({
|
|
102
|
-
constraint_id: "F-PASS-07",
|
|
103
|
-
severity: "CRITICAL",
|
|
104
|
-
message: "No impack=true Guard — verify() will abort E_IMPACK_GUARD_NOT_FOUND",
|
|
105
|
-
related_move_error: "E_IMPACK_GUARD_NOT_FOUND (9)",
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
if (puzzle.binding) {
|
|
109
|
-
const added = new Set();
|
|
110
|
-
for (let i = 0; i < puzzle.binding.guard_objects.length; i++) {
|
|
111
|
-
const guard = puzzle.binding.guard_objects[i];
|
|
112
|
-
const relies = puzzle.binding.relies_dependencies[i] ?? [];
|
|
113
|
-
for (const rely of relies) {
|
|
114
|
-
if (!added.has(rely)) {
|
|
115
|
-
violations.push({
|
|
116
|
-
constraint_id: "F-PASS-06",
|
|
117
|
-
severity: "HIGH",
|
|
118
|
-
message: `Guard ${guard} (index ${i}) relies on ${rely}, but ${rely} is not added before it (topological order violated)`,
|
|
119
|
-
related_move_error: "E_RELIES_GUARD_NOT_ADDED (2)",
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
added.add(guard);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (puzzle.submission && !puzzle.submission.size_ok) {
|
|
127
|
-
violations.push({
|
|
128
|
-
constraint_id: "F-PASS-05",
|
|
129
|
-
severity: "HIGH",
|
|
130
|
-
message: `Submission max entry size ${puzzle.submission.max_entry_size} > MAX_SUBMISSION_SIZE_PASSPORT=${MAX_SUBMISSION_SIZE_PASSPORT}`,
|
|
131
|
-
current_value: puzzle.submission.max_entry_size,
|
|
132
|
-
limit: MAX_SUBMISSION_SIZE_PASSPORT,
|
|
133
|
-
related_move_error: "E_SUBMISSION_SIZE_EXCEEDED (3)",
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
if (puzzle.binding) {
|
|
137
|
-
const guardToRelies = new Map();
|
|
138
|
-
for (let i = 0; i < puzzle.binding.guard_objects.length; i++) {
|
|
139
|
-
guardToRelies.set(puzzle.binding.guard_objects[i], puzzle.binding.relies_dependencies[i] ?? []);
|
|
140
|
-
}
|
|
141
|
-
for (let i = 0; i < puzzle.binding.guard_objects.length; i++) {
|
|
142
|
-
const guard = puzzle.binding.guard_objects[i];
|
|
143
|
-
const relies = puzzle.binding.relies_dependencies[i] ?? [];
|
|
144
|
-
for (const rely of relies) {
|
|
145
|
-
const relyOfRely = guardToRelies.get(rely) ?? [];
|
|
146
|
-
if (relyOfRely.length > 0) {
|
|
147
|
-
violations.push({
|
|
148
|
-
constraint_id: "F-PASS-12",
|
|
149
|
-
severity: "LOW",
|
|
150
|
-
message: `Guard ${guard} relies on ${rely}, but ${rely} itself has relies ${JSON.stringify(relyOfRely)} — transitive dependencies are not allowed`,
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return violations;
|
|
157
|
-
}
|
|
158
|
-
export function buildResultPuzzle(binding) {
|
|
159
|
-
const impackGuards = binding.guard_objects.filter((_, i) => binding.impack_flags[i]);
|
|
160
|
-
const perGuardLogic = binding.guard_objects.map((guard, i) => {
|
|
161
|
-
const impack = binding.impack_flags[i] ? "impack" : "non_impack";
|
|
162
|
-
const logic = binding.relies_logic[i] ?? "AND";
|
|
163
|
-
const relies = binding.relies_dependencies[i] ?? [];
|
|
164
|
-
const relyPart = relies.length === 0
|
|
165
|
-
? "(no relies)"
|
|
166
|
-
: relies.map(r => `${r}.result`).join(` ${logic} `);
|
|
167
|
-
const computation = relies.length === 0
|
|
168
|
-
? `${guard}.result (standalone)`
|
|
169
|
-
: `${relyPart} ${logic} ${guard}.result`;
|
|
170
|
-
return { guard, impack, relies_logic: logic, relies_guards: relies, computation };
|
|
171
|
-
});
|
|
172
|
-
const overallFormula = impackGuards.length === 0
|
|
173
|
-
? "result = false (no impack Guard — E_IMPACK_GUARD_NOT_FOUND)"
|
|
174
|
-
: `result = AND(${impackGuards.map(g => `${g}.result`).join(", ")})`;
|
|
175
|
-
return {
|
|
176
|
-
decision_rule: "impack_mechanism",
|
|
177
|
-
impack_guards: impackGuards,
|
|
178
|
-
per_guard_logic: perGuardLogic,
|
|
179
|
-
overall_formula: overallFormula,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
export function buildDefaultVerifyFlow() {
|
|
183
|
-
return [
|
|
184
|
-
{ step: 1, action: "pre_check", description: "assert !has_verified (E_HAS_VERIFIED), tx_hash matches (E_DIGEST_NOT_MATCH)" },
|
|
185
|
-
{ step: 2, action: "iterate_guards", description: "for each GuardInfo in self.guard (in addition order)" },
|
|
186
|
-
{ step: 3, action: "calc_relies_result", description: "calculate relies result via AND/OR logic; short-circuit on AND-false or OR-true" },
|
|
187
|
-
{ step: 4, action: "verify_guard_native", description: "guard::verify_guard(guard, submission, impack) — native function, opaque" },
|
|
188
|
-
{ step: 5, action: "check_submission_size", description: "assert BCS submission size ≤ MAX_SUBMISSION_SIZE_PASSPORT=256 (E_SUBMISSION_SIZE_EXCEEDED)" },
|
|
189
|
-
{ step: 6, action: "impack_decision", description: "if impack=true and result=false → set self.result=false, return immediately" },
|
|
190
|
-
{ step: 7, action: "finalize", description: "assert at least 1 impack Guard (E_IMPACK_GUARD_NOT_FOUND); set has_verified=true, self.result=true" },
|
|
191
|
-
];
|
|
192
|
-
}
|
|
193
|
-
export function buildDefaultLifecycleStages() {
|
|
194
|
-
return [
|
|
195
|
-
{ stage: "new", description: "passport::new(clock, ctx) — create Passport, bind tx_hash", completed: false },
|
|
196
|
-
{ stage: "guard_add", description: "passport::guard_add(self, guard, identifiers, values, impack, ctx) — add Guards (repeatable, pre-verify)", completed: false },
|
|
197
|
-
{ stage: "verify", description: "passport::verify(self, ctx) — one-time verification, sets has_verified=true", completed: false },
|
|
198
|
-
{ stage: "use", description: "passport::result / result_for_guard / result_for_permission / submission_get — query results", completed: false },
|
|
199
|
-
{ stage: "freeze_or_destroy", description: "passport::freezen(self) [permanent] OR passport::destroy(self) [release]", completed: false },
|
|
200
|
-
];
|
|
201
|
-
}
|
|
202
|
-
export function generateConfirmationText(puzzle) {
|
|
203
|
-
const lines = [];
|
|
204
|
-
lines.push("═══ Passport Confirmation ═══");
|
|
205
|
-
lines.push("");
|
|
206
|
-
if (puzzle.intent) {
|
|
207
|
-
lines.push("─ A. Intent ──────────────");
|
|
208
|
-
lines.push(`Protected operation: ${puzzle.intent.protected_operation}`);
|
|
209
|
-
lines.push(`Consumer object: ${puzzle.intent.consumer_object}`);
|
|
210
|
-
if (puzzle.intent.verification_rules.length > 0) {
|
|
211
|
-
lines.push("Verification rules:");
|
|
212
|
-
for (const r of puzzle.intent.verification_rules)
|
|
213
|
-
lines.push(` - ${r}`);
|
|
214
|
-
}
|
|
215
|
-
if (puzzle.intent.failure_conditions.length > 0) {
|
|
216
|
-
lines.push("Failure conditions:");
|
|
217
|
-
for (const fc of puzzle.intent.failure_conditions)
|
|
218
|
-
lines.push(` - ${fc}`);
|
|
219
|
-
}
|
|
220
|
-
lines.push("");
|
|
221
|
-
}
|
|
222
|
-
if (puzzle.binding) {
|
|
223
|
-
const b = puzzle.binding;
|
|
224
|
-
lines.push("─ B. Binding ──────────────");
|
|
225
|
-
lines.push(`Guards (${b.guard_objects.length}/${MAX_GUARD_COUNT_PASSPORT}):`);
|
|
226
|
-
b.guard_objects.forEach((g, i) => {
|
|
227
|
-
const impack = b.impack_flags[i] ? "IMPACK" : "non-impack";
|
|
228
|
-
const relies = b.relies_dependencies[i] ?? [];
|
|
229
|
-
const logic = b.relies_logic[i] ?? "AND";
|
|
230
|
-
const relyStr = relies.length === 0 ? "" : ` relies=${JSON.stringify(relies)} (${logic})`;
|
|
231
|
-
lines.push(` [${i}] ${g} — ${impack}${relyStr}`);
|
|
232
|
-
});
|
|
233
|
-
if (b.topological_order.length > 0) {
|
|
234
|
-
lines.push(`Topological order: ${b.topological_order.join(" → ")}`);
|
|
235
|
-
}
|
|
236
|
-
lines.push("");
|
|
237
|
-
}
|
|
238
|
-
if (puzzle.submission) {
|
|
239
|
-
const s = puzzle.submission;
|
|
240
|
-
lines.push("─ C. Submission ──────────────");
|
|
241
|
-
lines.push(`Entries: ${s.submissions.length}, max entry size: ${s.max_entry_size}/${MAX_SUBMISSION_SIZE_PASSPORT} bytes (${s.size_ok ? "OK" : "EXCEEDS"})`);
|
|
242
|
-
for (const sub of s.submissions) {
|
|
243
|
-
lines.push(` - guard=${sub.guard}, identifier=${sub.identifier}, value_type=${sub.value_type}, size=${sub.estimated_size}`);
|
|
244
|
-
}
|
|
245
|
-
lines.push("");
|
|
246
|
-
}
|
|
247
|
-
if (puzzle.verify) {
|
|
248
|
-
const v = puzzle.verify;
|
|
249
|
-
lines.push("─ D. Verify ──────────────");
|
|
250
|
-
lines.push(`tx_hash binding: ${v.tx_hash_binding ? "YES (Move-level hard-coded)" : "NO"}`);
|
|
251
|
-
lines.push(`has_verified: ${v.has_verified}`);
|
|
252
|
-
lines.push(`Verify flow (${v.verify_flow.length} steps):`);
|
|
253
|
-
for (const step of v.verify_flow) {
|
|
254
|
-
lines.push(` ${step.step}. ${step.action}: ${step.description}`);
|
|
255
|
-
}
|
|
256
|
-
lines.push("");
|
|
257
|
-
}
|
|
258
|
-
if (puzzle.result) {
|
|
259
|
-
const r = puzzle.result;
|
|
260
|
-
lines.push("─ E. Result ──────────────");
|
|
261
|
-
lines.push(`Decision rule: ${r.decision_rule}`);
|
|
262
|
-
lines.push(`impack Guards: ${r.impack_guards.length === 0 ? "(none — will fail verify)" : r.impack_guards.join(", ")}`);
|
|
263
|
-
lines.push(`Overall formula: ${r.overall_formula}`);
|
|
264
|
-
if (r.per_guard_logic.length > 0) {
|
|
265
|
-
lines.push("Per-Guard logic:");
|
|
266
|
-
for (const pgl of r.per_guard_logic) {
|
|
267
|
-
lines.push(` - ${pgl.guard} (${pgl.impack}, ${pgl.relies_logic}): ${pgl.computation}`);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
lines.push("");
|
|
271
|
-
}
|
|
272
|
-
if (puzzle.lifecycle) {
|
|
273
|
-
const l = puzzle.lifecycle;
|
|
274
|
-
lines.push("─ F. Lifecycle ──────────────");
|
|
275
|
-
lines.push(`Terminal state: ${l.terminal_state}`);
|
|
276
|
-
for (const stage of l.stages) {
|
|
277
|
-
const mark = stage.completed ? "✓" : "○";
|
|
278
|
-
lines.push(` ${mark} ${stage.stage}: ${stage.description}`);
|
|
279
|
-
}
|
|
280
|
-
lines.push("");
|
|
281
|
-
}
|
|
282
|
-
const violations = validateConstraints(puzzle);
|
|
283
|
-
if (violations.length > 0) {
|
|
284
|
-
lines.push("─ Constraint Violations ──────────────");
|
|
285
|
-
for (const v of violations) {
|
|
286
|
-
lines.push(` [${v.severity}] ${v.constraint_id}: ${v.message}`);
|
|
287
|
-
}
|
|
288
|
-
lines.push("");
|
|
289
|
-
}
|
|
290
|
-
return lines.join("\n");
|
|
291
|
-
}
|
|
292
|
-
export function buildPassportPuzzle(input) {
|
|
293
|
-
const puzzle = initPuzzleFromIntent(input.intent);
|
|
294
|
-
const topological_order = computeTopologicalOrder(input.binding.guard_objects, input.binding.relies_dependencies ?? input.binding.guard_objects.map(() => []));
|
|
295
|
-
puzzle.binding = {
|
|
296
|
-
guard_objects: input.binding.guard_objects,
|
|
297
|
-
impack_flags: input.binding.impack_flags,
|
|
298
|
-
relies_dependencies: input.binding.relies_dependencies ?? input.binding.guard_objects.map(() => []),
|
|
299
|
-
relies_logic: input.binding.relies_logic ?? input.binding.guard_objects.map(() => "AND"),
|
|
300
|
-
topological_order,
|
|
301
|
-
};
|
|
302
|
-
const maxEntrySize = input.submission.reduce((max, s) => Math.max(max, s.estimated_size), 0);
|
|
303
|
-
puzzle.submission = {
|
|
304
|
-
submissions: input.submission,
|
|
305
|
-
max_entry_size: maxEntrySize,
|
|
306
|
-
size_ok: maxEntrySize <= MAX_SUBMISSION_SIZE_PASSPORT,
|
|
307
|
-
};
|
|
308
|
-
puzzle.result = buildResultPuzzle(puzzle.binding);
|
|
309
|
-
if (input.terminal_state) {
|
|
310
|
-
puzzle.lifecycle.terminal_state = input.terminal_state;
|
|
311
|
-
}
|
|
312
|
-
return puzzle;
|
|
313
|
-
}
|
|
314
|
-
function computeTopologicalOrder(guard_objects, relies_dependencies) {
|
|
315
|
-
const order = [];
|
|
316
|
-
const added = new Set();
|
|
317
|
-
for (let i = 0; i < guard_objects.length; i++) {
|
|
318
|
-
const guard = guard_objects[i];
|
|
319
|
-
const relies = relies_dependencies[i] ?? [];
|
|
320
|
-
for (const rely of relies) {
|
|
321
|
-
if (!added.has(rely) && guard_objects.includes(rely)) {
|
|
322
|
-
order.push(rely);
|
|
323
|
-
added.add(rely);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
if (!added.has(guard)) {
|
|
327
|
-
order.push(guard);
|
|
328
|
-
added.add(guard);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
return order;
|
|
332
|
-
}
|
|
333
|
-
export const PASSPORT_PUZZLE_VERSION = "1.0.0";
|
|
1
|
+
import{MAX_GUARD_COUNT_PASSPORT,MAX_SUBMISSION_SIZE_PASSPORT}from'./passport-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['protected_operation']||a['verification_rules']||a['consumer_object'])&&(b['intent']={'protected_operation':a['protected_operation']??'','consumer_object':a['consumer_object']??'Service','verification_rules':a['verification_rules']??[],'failure_conditions':a['failure_conditions']??[]}),b['verify']={'tx_hash_binding':!![],'has_verified':![],'verify_flow':buildDefaultVerifyFlow()},b['lifecycle']={'stages':buildDefaultLifecycleStages(),'terminal_state':'undecided','destroy_before_freeze':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(protected_operation\x20+\x20verification_rules)'});else{if(!a['intent']['protected_operation'])b['push']('A'),c['push']({'dimension':'A','reason':'protected_operation\x20is\x20empty'});else a['intent']['verification_rules']['length']===0x0&&(b['push']('A'),c['push']({'dimension':'A','reason':'verification_rules\x20is\x20empty\x20—\x20what\x20should\x20each\x20Guard\x20check?'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(guard_objects\x20+\x20impack_flags\x20+\x20relies)'});else{if(a['binding']['guard_objects']['length']===0x0)b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'});else{if(!a['binding']['impack_flags']['some'](d=>d))b['push']('B'),c['push']({'dimension':'B','reason':'No\x20impack=true\x20Guard\x20—\x20at\x20least\x201\x20required\x20(E_IMPACK_GUARD_NOT_FOUND)'});else a['binding']['guard_objects']['length']>MAX_GUARD_COUNT_PASSPORT&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20count\x20'+a['binding']['guard_objects']['length']+'\x20>\x20MAX_GUARD_COUNT_PASSPORT='+MAX_GUARD_COUNT_PASSPORT}));}}if(!a['submission'])b['push']('C'),c['push']({'dimension':'C','reason':'Submission\x20not\x20specified\x20(per-Guard\x20identifier\x20+\x20value\x20+\x20value_type)'});else!a['submission']['size_ok']&&(b['push']('C'),c['push']({'dimension':'C','reason':'max_entry_size\x20'+a['submission']['max_entry_size']+'\x20>\x20MAX_SUBMISSION_SIZE_PASSPORT='+MAX_SUBMISSION_SIZE_PASSPORT}));return!a['verify']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Verify\x20dimension\x20not\x20initialized\x20(should\x20be\x20auto-filled)'})),!a['result']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Result\x20computation\x20not\x20derived\x20(call\x20buildResultPuzzle\x20from\x20binding)'})),!a['lifecycle']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Lifecycle\x20not\x20initialized\x20(should\x20be\x20auto-filled)'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];a['binding']&&a['binding']['guard_objects']['length']>MAX_GUARD_COUNT_PASSPORT&&b['push']({'constraint_id':'F-PASS-04','severity':'CRITICAL','message':'Guard\x20count\x20'+a['binding']['guard_objects']['length']+'\x20exceeds\x20MAX_GUARD_COUNT_PASSPORT='+MAX_GUARD_COUNT_PASSPORT,'current_value':a['binding']['guard_objects']['length'],'limit':MAX_GUARD_COUNT_PASSPORT,'related_move_error':'E_GUARD_COUNT_EXCEEDED\x20(1)'});a['binding']&&!a['binding']['impack_flags']['some'](c=>c)&&b['push']({'constraint_id':'F-PASS-07','severity':'CRITICAL','message':'No\x20impack=true\x20Guard\x20—\x20verify()\x20will\x20abort\x20E_IMPACK_GUARD_NOT_FOUND','related_move_error':'E_IMPACK_GUARD_NOT_FOUND\x20(9)'});if(a['binding']){const c=new Set();for(let d=0x0;d<a['binding']['guard_objects']['length'];d++){const e=a['binding']['guard_objects'][d],f=a['binding']['relies_dependencies'][d]??[];for(const g of f){!c['has'](g)&&b['push']({'constraint_id':'F-PASS-06','severity':'HIGH','message':'Guard\x20'+e+'\x20(index\x20'+d+')\x20relies\x20on\x20'+g+',\x20but\x20'+g+'\x20is\x20not\x20added\x20before\x20it\x20(topological\x20order\x20violated)','related_move_error':'E_RELIES_GUARD_NOT_ADDED\x20(2)'});}c['add'](e);}}a['submission']&&!a['submission']['size_ok']&&b['push']({'constraint_id':'F-PASS-05','severity':'HIGH','message':'Submission\x20max\x20entry\x20size\x20'+a['submission']['max_entry_size']+'\x20>\x20MAX_SUBMISSION_SIZE_PASSPORT='+MAX_SUBMISSION_SIZE_PASSPORT,'current_value':a['submission']['max_entry_size'],'limit':MAX_SUBMISSION_SIZE_PASSPORT,'related_move_error':'E_SUBMISSION_SIZE_EXCEEDED\x20(3)'});if(a['binding']){const h=new Map();for(let j=0x0;j<a['binding']['guard_objects']['length'];j++){h['set'](a['binding']['guard_objects'][j],a['binding']['relies_dependencies'][j]??[]);}for(let k=0x0;k<a['binding']['guard_objects']['length'];k++){const l=a['binding']['guard_objects'][k],m=a['binding']['relies_dependencies'][k]??[];for(const n of m){const o=h['get'](n)??[];o['length']>0x0&&b['push']({'constraint_id':'F-PASS-12','severity':'LOW','message':'Guard\x20'+l+'\x20relies\x20on\x20'+n+',\x20but\x20'+n+'\x20itself\x20has\x20relies\x20'+JSON['stringify'](o)+'\x20—\x20transitive\x20dependencies\x20are\x20not\x20allowed'});}}}return b;}export function buildResultPuzzle(a){const b=a['guard_objects']['filter']((e,f)=>a['impack_flags'][f]),c=a['guard_objects']['map']((e,f)=>{const g=a['impack_flags'][f]?'impack':'non_impack',h=a['relies_logic'][f]??'AND',j=a['relies_dependencies'][f]??[],k=j['length']===0x0?'(no\x20relies)':j['map'](m=>m+'.result')['join']('\x20'+h+'\x20'),l=j['length']===0x0?e+'.result\x20(standalone)':k+'\x20'+h+'\x20'+e+'.result';return{'guard':e,'impack':g,'relies_logic':h,'relies_guards':j,'computation':l};}),d=b['length']===0x0?'result\x20=\x20false\x20(no\x20impack\x20Guard\x20—\x20E_IMPACK_GUARD_NOT_FOUND)':'result\x20=\x20AND('+b['map'](e=>e+'.result')['join'](',\x20')+')';return{'decision_rule':'impack_mechanism','impack_guards':b,'per_guard_logic':c,'overall_formula':d};}export function buildDefaultVerifyFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20!has_verified\x20(E_HAS_VERIFIED),\x20tx_hash\x20matches\x20(E_DIGEST_NOT_MATCH)'},{'step':0x2,'action':'iterate_guards','description':'for\x20each\x20GuardInfo\x20in\x20self.guard\x20(in\x20addition\x20order)'},{'step':0x3,'action':'calc_relies_result','description':'calculate\x20relies\x20result\x20via\x20AND/OR\x20logic;\x20short-circuit\x20on\x20AND-false\x20or\x20OR-true'},{'step':0x4,'action':'verify_guard_native','description':'guard::verify_guard(guard,\x20submission,\x20impack)\x20—\x20native\x20function,\x20opaque'},{'step':0x5,'action':'check_submission_size','description':'assert\x20BCS\x20submission\x20size\x20≤\x20MAX_SUBMISSION_SIZE_PASSPORT=256\x20(E_SUBMISSION_SIZE_EXCEEDED)'},{'step':0x6,'action':'impack_decision','description':'if\x20impack=true\x20and\x20result=false\x20→\x20set\x20self.result=false,\x20return\x20immediately'},{'step':0x7,'action':'finalize','description':'assert\x20at\x20least\x201\x20impack\x20Guard\x20(E_IMPACK_GUARD_NOT_FOUND);\x20set\x20has_verified=true,\x20self.result=true'}];}export function buildDefaultLifecycleStages(){return[{'stage':'new','description':'passport::new(clock,\x20ctx)\x20—\x20create\x20Passport,\x20bind\x20tx_hash','completed':![]},{'stage':'guard_add','description':'passport::guard_add(self,\x20guard,\x20identifiers,\x20values,\x20impack,\x20ctx)\x20—\x20add\x20Guards\x20(repeatable,\x20pre-verify)','completed':![]},{'stage':'verify','description':'passport::verify(self,\x20ctx)\x20—\x20one-time\x20verification,\x20sets\x20has_verified=true','completed':![]},{'stage':'use','description':'passport::result\x20/\x20result_for_guard\x20/\x20result_for_permission\x20/\x20submission_get\x20—\x20query\x20results','completed':![]},{'stage':'freeze_or_destroy','description':'passport::freezen(self)\x20[permanent]\x20OR\x20passport::destroy(self)\x20[release]','completed':![]}];}export function generateConfirmationText(a){const c=[];c['push']('═══\x20Passport\x20Confirmation\x20═══'),c['push']('');if(a['intent']){c['push']('─\x20A.\x20Intent\x20──────────────'),c['push']('Protected\x20operation:\x20'+a['intent']['protected_operation']),c['push']('Consumer\x20object:\x20'+a['intent']['consumer_object']);if(a['intent']['verification_rules']['length']>0x0){c['push']('Verification\x20rules:');for(const e of a['intent']['verification_rules'])c['push']('\x20\x20-\x20'+e);}if(a['intent']['failure_conditions']['length']>0x0){c['push']('Failure\x20conditions:');for(const f of a['intent']['failure_conditions'])c['push']('\x20\x20-\x20'+f);}c['push']('');}if(a['binding']){const g=a['binding'];c['push']('─\x20B.\x20Binding\x20──────────────'),c['push']('Guards\x20('+g['guard_objects']['length']+'/'+MAX_GUARD_COUNT_PASSPORT+'):'),g['guard_objects']['forEach']((h,j)=>{const k=g['impack_flags'][j]?'IMPACK':'non-impack',m=g['relies_dependencies'][j]??[],n=g['relies_logic'][j]??'AND',o=m['length']===0x0?'':'\x20relies='+JSON['stringify'](m)+'\x20('+n+')';c['push']('\x20\x20['+j+']\x20'+h+'\x20—\x20'+k+o);}),g['topological_order']['length']>0x0&&c['push']('Topological\x20order:\x20'+g['topological_order']['join']('\x20→\x20')),c['push']('');}if(a['submission']){const h=a['submission'];c['push']('─\x20C.\x20Submission\x20──────────────'),c['push']('Entries:\x20'+h['submissions']['length']+',\x20max\x20entry\x20size:\x20'+h['max_entry_size']+'/'+MAX_SUBMISSION_SIZE_PASSPORT+'\x20bytes\x20('+(h['size_ok']?'OK':'EXCEEDS')+')');for(const i of h['submissions']){c['push']('\x20\x20-\x20guard='+i['guard']+',\x20identifier='+i['identifier']+',\x20value_type='+i['value_type']+',\x20size='+i['estimated_size']);}c['push']('');}if(a['verify']){const j=a['verify'];c['push']('─\x20D.\x20Verify\x20──────────────'),c['push']('tx_hash\x20binding:\x20'+(j['tx_hash_binding']?'YES\x20(Move-level\x20hard-coded)':'NO')),c['push']('has_verified:\x20'+j['has_verified']),c['push']('Verify\x20flow\x20('+j['verify_flow']['length']+'\x20steps):');for(const k of j['verify_flow']){c['push']('\x20\x20'+k['step']+'.\x20'+k['action']+':\x20'+k['description']);}c['push']('');}if(a['result']){const m=a['result'];c['push']('─\x20E.\x20Result\x20──────────────'),c['push']('Decision\x20rule:\x20'+m['decision_rule']),c['push']('impack\x20Guards:\x20'+(m['impack_guards']['length']===0x0?'(none\x20—\x20will\x20fail\x20verify)':m['impack_guards']['join'](',\x20'))),c['push']('Overall\x20formula:\x20'+m['overall_formula']);if(m['per_guard_logic']['length']>0x0){c['push']('Per-Guard\x20logic:');for(const n of m['per_guard_logic']){c['push']('\x20\x20-\x20'+n['guard']+'\x20('+n['impack']+',\x20'+n['relies_logic']+'):\x20'+n['computation']);}}c['push']('');}if(a['lifecycle']){const o=a['lifecycle'];c['push']('─\x20F.\x20Lifecycle\x20──────────────'),c['push']('Terminal\x20state:\x20'+o['terminal_state']);for(const p of o['stages']){const q=p['completed']?'✓':'○';c['push']('\x20\x20'+q+'\x20'+p['stage']+':\x20'+p['description']);}c['push']('');}const d=validateConstraints(a);if(d['length']>0x0){c['push']('─\x20Constraint\x20Violations\x20──────────────');for(const t of d){c['push']('\x20\x20['+t['severity']+']\x20'+t['constraint_id']+':\x20'+t['message']);}c['push']('');}return c['join']('\x0a');}export function buildPassportPuzzle(a){const b=initPuzzleFromIntent(a['intent']),c=computeTopologicalOrder(a['binding']['guard_objects'],a['binding']['relies_dependencies']??a['binding']['guard_objects']['map'](()=>[]));b['binding']={'guard_objects':a['binding']['guard_objects'],'impack_flags':a['binding']['impack_flags'],'relies_dependencies':a['binding']['relies_dependencies']??a['binding']['guard_objects']['map'](()=>[]),'relies_logic':a['binding']['relies_logic']??a['binding']['guard_objects']['map'](()=>'AND'),'topological_order':c};const d=a['submission']['reduce']((e,f)=>Math['max'](e,f['estimated_size']),0x0);return b['submission']={'submissions':a['submission'],'max_entry_size':d,'size_ok':d<=MAX_SUBMISSION_SIZE_PASSPORT},b['result']=buildResultPuzzle(b['binding']),a['terminal_state']&&(b['lifecycle']['terminal_state']=a['terminal_state']),b;}function computeTopologicalOrder(a,b){const c=[],d=new Set();for(let e=0x0;e<a['length'];e++){const f=a[e],g=b[e]??[];for(const h of g){!d['has'](h)&&a['includes'](h)&&(c['push'](h),d['add'](h));}!d['has'](f)&&(c['push'](f),d['add'](f));}return c;}export const PASSPORT_PUZZLE_VERSION='1.0.0';
|