@wowok/agent-mcp 2.4.3 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/runtime.d.ts +4 -0
- package/dist/config/runtime.js +29 -5
- package/dist/harness/auto-escalation.d.ts +27 -0
- package/dist/harness/auto-escalation.js +68 -0
- package/dist/index.js +21 -0
- package/dist/knowledge/allocation-confirm.d.ts +115 -0
- package/dist/knowledge/allocation-confirm.js +534 -0
- package/dist/knowledge/allocation-context.d.ts +58 -0
- package/dist/knowledge/allocation-context.js +249 -0
- package/dist/knowledge/allocation-ledger.d.ts +67 -0
- package/dist/knowledge/allocation-ledger.js +463 -0
- package/dist/knowledge/allocation-puzzle.d.ts +135 -0
- package/dist/knowledge/allocation-puzzle.js +298 -0
- package/dist/knowledge/allocation-risk.d.ts +78 -0
- package/dist/knowledge/allocation-risk.js +568 -0
- package/dist/knowledge/allocation-templates.d.ts +38 -0
- package/dist/knowledge/allocation-templates.js +970 -0
- package/dist/knowledge/allocation-translation.d.ts +72 -0
- package/dist/knowledge/allocation-translation.js +585 -0
- package/dist/knowledge/arb-risk.d.ts +37 -0
- package/dist/knowledge/arb-risk.js +210 -0
- package/dist/knowledge/arbitration-confirm.d.ts +135 -0
- package/dist/knowledge/arbitration-confirm.js +559 -0
- package/dist/knowledge/arbitration-context.d.ts +81 -0
- package/dist/knowledge/arbitration-context.js +505 -0
- package/dist/knowledge/arbitration-ledger.d.ts +62 -0
- package/dist/knowledge/arbitration-ledger.js +521 -0
- package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
- package/dist/knowledge/arbitration-puzzle.js +304 -0
- package/dist/knowledge/arbitration-risk.d.ts +112 -0
- package/dist/knowledge/arbitration-risk.js +433 -0
- package/dist/knowledge/arbitration-templates.d.ts +38 -0
- package/dist/knowledge/arbitration-templates.js +276 -0
- package/dist/knowledge/arbitration-translation.d.ts +91 -0
- package/dist/knowledge/arbitration-translation.js +487 -0
- package/dist/knowledge/bridge-risk.d.ts +36 -0
- package/dist/knowledge/bridge-risk.js +263 -0
- package/dist/knowledge/contact-risk.d.ts +32 -0
- package/dist/knowledge/contact-risk.js +200 -0
- package/dist/knowledge/demand-confirm.d.ts +32 -0
- package/dist/knowledge/demand-confirm.js +206 -0
- package/dist/knowledge/demand-risk.d.ts +30 -0
- package/dist/knowledge/demand-risk.js +240 -0
- package/dist/knowledge/demand-translation.d.ts +55 -0
- package/dist/knowledge/demand-translation.js +354 -0
- package/dist/knowledge/deployment-scanner.d.ts +63 -0
- package/dist/knowledge/deployment-scanner.js +762 -0
- package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
- package/dist/knowledge/examples-scanner-cli.js +26 -0
- package/dist/knowledge/examples-scanner.d.ts +121 -0
- package/dist/knowledge/examples-scanner.js +825 -0
- package/dist/knowledge/flywheel-loop.d.ts +3 -0
- package/dist/knowledge/flywheel-loop.js +32 -3
- package/dist/knowledge/glossary.js +3 -1
- package/dist/knowledge/guard-confirm.d.ts +86 -0
- package/dist/knowledge/guard-confirm.js +406 -0
- package/dist/knowledge/guard-context.d.ts +56 -0
- package/dist/knowledge/guard-context.js +287 -0
- package/dist/knowledge/guard-design-patterns.d.ts +37 -0
- package/dist/knowledge/guard-design-patterns.js +257 -0
- package/dist/knowledge/guard-puzzle.js +3 -2
- package/dist/knowledge/guard-risk.d.ts +1 -1
- package/dist/knowledge/guard-risk.js +12 -14
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +6 -5
- package/dist/knowledge/index.d.ts +342 -0
- package/dist/knowledge/index.js +344 -0
- package/dist/knowledge/machine-confirm.d.ts +102 -0
- package/dist/knowledge/machine-confirm.js +559 -0
- package/dist/knowledge/machine-context.d.ts +160 -0
- package/dist/knowledge/machine-context.js +812 -0
- package/dist/knowledge/machine-ledger.d.ts +41 -0
- package/dist/knowledge/machine-ledger.js +315 -0
- package/dist/knowledge/machine-puzzle.d.ts +206 -0
- package/dist/knowledge/machine-puzzle.js +494 -0
- package/dist/knowledge/machine-risk.d.ts +75 -0
- package/dist/knowledge/machine-risk.js +644 -0
- package/dist/knowledge/machine-templates.d.ts +92 -0
- package/dist/knowledge/machine-templates.js +1592 -0
- package/dist/knowledge/machine-topology.d.ts +57 -0
- package/dist/knowledge/machine-topology.js +234 -0
- package/dist/knowledge/machine-translation.d.ts +96 -0
- package/dist/knowledge/machine-translation.js +513 -0
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
- package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
- package/dist/knowledge/mcp-schema-audit.js +772 -0
- package/dist/knowledge/onchain-constants.d.ts +4 -0
- package/dist/knowledge/onchain-constants.js +35 -0
- package/dist/knowledge/order-confirm.d.ts +115 -0
- package/dist/knowledge/order-confirm.js +573 -0
- package/dist/knowledge/order-context.d.ts +66 -0
- package/dist/knowledge/order-context.js +390 -0
- package/dist/knowledge/order-ledger.d.ts +69 -0
- package/dist/knowledge/order-ledger.js +341 -0
- package/dist/knowledge/order-puzzle.d.ts +159 -0
- package/dist/knowledge/order-puzzle.js +255 -0
- package/dist/knowledge/order-risk.d.ts +66 -0
- package/dist/knowledge/order-risk.js +653 -0
- package/dist/knowledge/order-templates.d.ts +50 -0
- package/dist/knowledge/order-templates.js +368 -0
- package/dist/knowledge/order-translation.d.ts +78 -0
- package/dist/knowledge/order-translation.js +550 -0
- package/dist/knowledge/passport-confirm.d.ts +130 -0
- package/dist/knowledge/passport-confirm.js +531 -0
- package/dist/knowledge/passport-context.d.ts +59 -0
- package/dist/knowledge/passport-context.js +306 -0
- package/dist/knowledge/passport-ledger.d.ts +48 -0
- package/dist/knowledge/passport-ledger.js +282 -0
- package/dist/knowledge/passport-puzzle.d.ts +108 -0
- package/dist/knowledge/passport-puzzle.js +333 -0
- package/dist/knowledge/passport-risk.d.ts +70 -0
- package/dist/knowledge/passport-risk.js +450 -0
- package/dist/knowledge/passport-templates.d.ts +40 -0
- package/dist/knowledge/passport-templates.js +568 -0
- package/dist/knowledge/passport-translation.d.ts +68 -0
- package/dist/knowledge/passport-translation.js +516 -0
- package/dist/knowledge/payment-risk.d.ts +33 -0
- package/dist/knowledge/payment-risk.js +182 -0
- package/dist/knowledge/permission-confirm.d.ts +110 -0
- package/dist/knowledge/permission-confirm.js +426 -0
- package/dist/knowledge/permission-context.d.ts +58 -0
- package/dist/knowledge/permission-context.js +224 -0
- package/dist/knowledge/permission-ledger.d.ts +38 -0
- package/dist/knowledge/permission-ledger.js +403 -0
- package/dist/knowledge/permission-puzzle.d.ts +122 -0
- package/dist/knowledge/permission-puzzle.js +173 -0
- package/dist/knowledge/permission-risk.d.ts +76 -0
- package/dist/knowledge/permission-risk.js +411 -0
- package/dist/knowledge/permission-templates.d.ts +38 -0
- package/dist/knowledge/permission-templates.js +234 -0
- package/dist/knowledge/permission-translation.d.ts +57 -0
- package/dist/knowledge/permission-translation.js +350 -0
- package/dist/knowledge/personal-risk.d.ts +36 -0
- package/dist/knowledge/personal-risk.js +212 -0
- package/dist/knowledge/progress-confirm.d.ts +108 -0
- package/dist/knowledge/progress-confirm.js +456 -0
- package/dist/knowledge/progress-context.d.ts +123 -0
- package/dist/knowledge/progress-context.js +452 -0
- package/dist/knowledge/progress-ledger.d.ts +63 -0
- package/dist/knowledge/progress-ledger.js +327 -0
- package/dist/knowledge/progress-puzzle.d.ts +82 -0
- package/dist/knowledge/progress-puzzle.js +219 -0
- package/dist/knowledge/progress-risk.d.ts +74 -0
- package/dist/knowledge/progress-risk.js +461 -0
- package/dist/knowledge/progress-templates.d.ts +38 -0
- package/dist/knowledge/progress-templates.js +228 -0
- package/dist/knowledge/progress-translation.d.ts +52 -0
- package/dist/knowledge/progress-translation.js +401 -0
- package/dist/knowledge/proof-confirm.d.ts +31 -0
- package/dist/knowledge/proof-confirm.js +187 -0
- package/dist/knowledge/proof-risk.d.ts +33 -0
- package/dist/knowledge/proof-risk.js +207 -0
- package/dist/knowledge/proof-translation.d.ts +52 -0
- package/dist/knowledge/proof-translation.js +283 -0
- package/dist/knowledge/registrar-risk.d.ts +34 -0
- package/dist/knowledge/registrar-risk.js +217 -0
- package/dist/knowledge/repository-confirm.d.ts +36 -0
- package/dist/knowledge/repository-confirm.js +242 -0
- package/dist/knowledge/repository-risk.d.ts +40 -0
- package/dist/knowledge/repository-risk.js +312 -0
- package/dist/knowledge/repository-translation.d.ts +58 -0
- package/dist/knowledge/repository-translation.js +422 -0
- package/dist/knowledge/resource-risk.d.ts +32 -0
- package/dist/knowledge/resource-risk.js +157 -0
- package/dist/knowledge/reward-confirm.d.ts +113 -0
- package/dist/knowledge/reward-confirm.js +496 -0
- package/dist/knowledge/reward-context.d.ts +127 -0
- package/dist/knowledge/reward-context.js +504 -0
- package/dist/knowledge/reward-ledger.d.ts +96 -0
- package/dist/knowledge/reward-ledger.js +502 -0
- package/dist/knowledge/reward-puzzle.d.ts +97 -0
- package/dist/knowledge/reward-puzzle.js +288 -0
- package/dist/knowledge/reward-risk.d.ts +84 -0
- package/dist/knowledge/reward-risk.js +545 -0
- package/dist/knowledge/reward-translation.d.ts +58 -0
- package/dist/knowledge/reward-translation.js +501 -0
- package/dist/knowledge/safety-rules.js +11 -3
- package/dist/knowledge/scenario-modes.d.ts +53 -0
- package/dist/knowledge/scenario-modes.js +302 -0
- package/dist/knowledge/service-confirm.d.ts +152 -0
- package/dist/knowledge/service-confirm.js +699 -0
- package/dist/knowledge/service-context.d.ts +66 -0
- package/dist/knowledge/service-context.js +403 -0
- package/dist/knowledge/service-ledger.d.ts +71 -0
- package/dist/knowledge/service-ledger.js +609 -0
- package/dist/knowledge/service-puzzle.d.ts +158 -0
- package/dist/knowledge/service-puzzle.js +236 -0
- package/dist/knowledge/service-risk.d.ts +108 -0
- package/dist/knowledge/service-risk.js +615 -0
- package/dist/knowledge/service-templates.d.ts +39 -0
- package/dist/knowledge/service-templates.js +418 -0
- package/dist/knowledge/service-translation.d.ts +103 -0
- package/dist/knowledge/service-translation.js +622 -0
- package/dist/knowledge/tools-reference.d.ts +17 -0
- package/dist/knowledge/tools-reference.js +151 -0
- package/dist/knowledge/treasury-confirm.d.ts +133 -0
- package/dist/knowledge/treasury-confirm.js +512 -0
- package/dist/knowledge/treasury-context.d.ts +64 -0
- package/dist/knowledge/treasury-context.js +363 -0
- package/dist/knowledge/treasury-ledger.d.ts +42 -0
- package/dist/knowledge/treasury-ledger.js +300 -0
- package/dist/knowledge/treasury-puzzle.d.ts +163 -0
- package/dist/knowledge/treasury-puzzle.js +216 -0
- package/dist/knowledge/treasury-risk.d.ts +86 -0
- package/dist/knowledge/treasury-risk.js +440 -0
- package/dist/knowledge/treasury-templates.d.ts +38 -0
- package/dist/knowledge/treasury-templates.js +316 -0
- package/dist/knowledge/treasury-translation.d.ts +78 -0
- package/dist/knowledge/treasury-translation.js +498 -0
- package/dist/knowledge/util-risk.d.ts +30 -0
- package/dist/knowledge/util-risk.js +135 -0
- package/dist/project/business-puzzle.d.ts +47 -0
- package/dist/project/business-puzzle.js +372 -0
- package/dist/project/deployment-doc.d.ts +61 -0
- package/dist/project/deployment-doc.js +432 -0
- package/dist/project/risk-aggregator.d.ts +50 -0
- package/dist/project/risk-aggregator.js +280 -0
- package/dist/project/substep-trace.d.ts +130 -0
- package/dist/project/substep-trace.js +332 -0
- package/dist/schema/call/allocation.d.ts +34 -34
- package/dist/schema/call/arbitration.d.ts +141 -141
- package/dist/schema/call/base.d.ts +386 -386
- package/dist/schema/call/base.js +3 -3
- package/dist/schema/call/bridge-handler.d.ts +5 -2
- package/dist/schema/call/bridge.d.ts +159 -159
- package/dist/schema/call/contact.d.ts +110 -110
- package/dist/schema/call/demand.d.ts +76 -76
- package/dist/schema/call/handler.d.ts +2 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +58 -58
- package/dist/schema/call/order.d.ts +98 -110
- package/dist/schema/call/permission-handler.d.ts +5 -0
- package/dist/schema/call/permission-handler.js +54 -0
- package/dist/schema/call/permission.d.ts +108 -108
- package/dist/schema/call/personal.d.ts +14 -14
- package/dist/schema/call/progress.d.ts +57 -72
- package/dist/schema/call/progress.js +7 -4
- package/dist/schema/call/proof.d.ts +18 -18
- package/dist/schema/call/proof.js +12 -7
- package/dist/schema/call/repository.d.ts +154 -154
- package/dist/schema/call/reward.d.ts +55 -55
- package/dist/schema/call/service.d.ts +231 -231
- package/dist/schema/call/treasury.d.ts +93 -93
- package/dist/schema/config/index.d.ts +178 -5
- package/dist/schema/config/index.js +52 -1
- package/dist/schema/local/index.d.ts +3554 -836
- package/dist/schema/local/index.js +2 -1
- package/dist/schema/messenger/index.d.ts +162 -162
- package/dist/schema/operations.d.ts +1058 -1074
- package/dist/schema/operations.js +7 -1
- package/dist/schema/project/index.d.ts +1412 -6
- package/dist/schema/project/index.js +441 -3
- package/dist/schema/query/index.d.ts +672 -672
- package/dist/schema/schema-query/index.d.ts +23 -3
- package/dist/schema/schema-query/index.js +13 -2
- package/dist/schema/sync-layer4.d.ts +21 -0
- package/dist/schema/sync-layer4.js +261 -0
- package/dist/schema/trust/index.d.ts +26 -26
- package/dist/schemas/account_operation.output.json +718 -0
- package/dist/schemas/config_operation.output.json +173 -0
- package/dist/schemas/index.json +9 -1
- package/dist/schemas/local_info_operation.output.json +718 -0
- package/dist/schemas/local_mark_operation.output.json +718 -0
- package/dist/schemas/onchain_operations.output.json +3 -2
- package/dist/schemas/onchain_operations.schema.json +1809 -336
- package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
- package/dist/schemas/onchain_operations_contact.schema.json +2 -1
- package/dist/schemas/onchain_operations_demand.schema.json +2 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
- package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
- package/dist/schemas/onchain_operations_guard.schema.json +578 -579
- package/dist/schemas/onchain_operations_machine.schema.json +2 -1
- package/dist/schemas/onchain_operations_order.schema.json +13 -9
- package/dist/schemas/onchain_operations_payment.schema.json +0 -514
- package/dist/schemas/onchain_operations_permission.schema.json +0 -514
- package/dist/schemas/onchain_operations_personal.schema.json +0 -514
- package/dist/schemas/onchain_operations_progress.schema.json +14 -10
- package/dist/schemas/onchain_operations_proof.schema.json +699 -0
- package/dist/schemas/onchain_operations_repository.schema.json +2 -1
- package/dist/schemas/onchain_operations_reward.schema.json +2 -1
- package/dist/schemas/onchain_operations_service.schema.json +2 -1
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
- package/dist/schemas/onchain_table_data.schema.json +32 -1
- package/dist/schemas/project_operation.output.json +918 -0
- package/dist/schemas/project_operation.schema.json +474 -3
- package/dist/schemas/query_toolkit.output.json +14906 -6
- package/dist/schemas/schema_query.output.json +38 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/handlers/config.d.ts +1 -1
- package/dist/tools/handlers/config.js +21 -18
- package/dist/tools/handlers/file-export.d.ts +2 -2
- package/dist/tools/handlers/local.d.ts +3 -30
- package/dist/tools/handlers/local.js +14 -3
- package/dist/tools/handlers/messenger.d.ts +1 -1
- package/dist/tools/handlers/messenger.js +2 -1
- package/dist/tools/handlers/onchain.d.ts +1 -1
- package/dist/tools/handlers/onchain.js +24 -22
- package/dist/tools/handlers/project.d.ts +1 -1
- package/dist/tools/handlers/project.js +262 -18
- package/dist/tools/handlers/query.d.ts +4 -4
- package/dist/tools/handlers/schema-query.d.ts +1 -1
- package/dist/tools/handlers/schema-query.js +21 -20
- package/dist/tools/handlers/trust.d.ts +1 -1
- package/dist/tools/handlers/trust.js +2 -2
- package/dist/tools/handlers/wip.d.ts +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +96 -25
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +3 -2
- package/dist/tools/shared.d.ts +13 -22
- package/dist/tools/types.d.ts +5 -5
- package/dist/tools/wrap.d.ts +10 -2
- package/dist/tools/wrap.js +212 -0
- package/package.json +3 -3
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import { MAX_VOTING_GUARD_COUNT, } from "@wowok/wowok";
|
|
2
|
+
import { ARBITRATION_SCENES, DUAL_GUARD_MATRIX, ARB_STATUS_CODE, ARB_TERMINAL_STATUSES, findSceneByPermissionIndex, inferSceneFromIntent, getScenesByCategory, getDualGuardMatrixEntry, isValidArbStatusTransition, isTerminalArbStatus, getActiveArbitrationPermissions, getAllArbitrationPermissions, } from "./arbitration-ledger.js";
|
|
3
|
+
import { getTemplatesByScene, } from "./arbitration-templates.js";
|
|
4
|
+
import { ARBITRATION_CONSTRAINT_RULES, matchSemanticPattern, } from "./arbitration-translation.js";
|
|
5
|
+
import { getAllRiskRules, assessArbitrationRisks, } from "./arbitration-risk.js";
|
|
6
|
+
import { initPuzzleFromIntent, checkPuzzleCompleteness, } from "./arbitration-puzzle.js";
|
|
7
|
+
import { ARBITRATION_OPERATION_CHECKLIST, ARBITRATION_CONFIRMATION_QUESTIONS, } from "./arbitration-confirm.js";
|
|
8
|
+
export const ARBITRATION_CONTEXT_VERSION = "1.0.0";
|
|
9
|
+
export function buildArbitrationContext(input) {
|
|
10
|
+
const max_length = input.max_length ?? 4500;
|
|
11
|
+
let matched_scene;
|
|
12
|
+
if (input.intent) {
|
|
13
|
+
matched_scene = inferSceneFromIntent(input.intent);
|
|
14
|
+
}
|
|
15
|
+
else if (input.target_permission_index !== undefined) {
|
|
16
|
+
matched_scene = findSceneByPermissionIndex(input.target_permission_index);
|
|
17
|
+
}
|
|
18
|
+
else if (input.target_operation_category) {
|
|
19
|
+
const scenes = getScenesByCategory(input.target_operation_category);
|
|
20
|
+
if (scenes.length > 0)
|
|
21
|
+
matched_scene = scenes[0];
|
|
22
|
+
}
|
|
23
|
+
let matched_template;
|
|
24
|
+
if (matched_scene) {
|
|
25
|
+
const templates = getTemplatesByScene(matched_scene.id);
|
|
26
|
+
if (templates.length > 0)
|
|
27
|
+
matched_template = templates[0];
|
|
28
|
+
}
|
|
29
|
+
let matched_pattern;
|
|
30
|
+
if (input.intent) {
|
|
31
|
+
const patterns = matchSemanticPattern(input.intent);
|
|
32
|
+
if (patterns.length > 0)
|
|
33
|
+
matched_pattern = patterns[0];
|
|
34
|
+
}
|
|
35
|
+
let puzzle_state;
|
|
36
|
+
let puzzle_completeness;
|
|
37
|
+
if (input.mode === "initial_design" && input.intent) {
|
|
38
|
+
puzzle_state = initPuzzleFromIntent({ rule_sentence: input.intent });
|
|
39
|
+
puzzle_completeness = checkPuzzleCompleteness(puzzle_state);
|
|
40
|
+
}
|
|
41
|
+
const relevant_risks = filterRiskRules(input.mode, input.stakeholder, matched_scene);
|
|
42
|
+
let risk_assessment;
|
|
43
|
+
if (input.mode === "pre_publish" && input.arbitration_json) {
|
|
44
|
+
const ctx = {
|
|
45
|
+
object: input.arbitration_json.object,
|
|
46
|
+
description: input.arbitration_json.description,
|
|
47
|
+
location: input.arbitration_json.location,
|
|
48
|
+
fee: input.arbitration_json.fee,
|
|
49
|
+
pause: input.arbitration_json.pause,
|
|
50
|
+
dispute: input.arbitration_json.dispute,
|
|
51
|
+
confirm: input.arbitration_json.confirm,
|
|
52
|
+
voting_deadline_change: input.arbitration_json.voting_deadline_change,
|
|
53
|
+
vote: input.arbitration_json.vote,
|
|
54
|
+
feedback: input.arbitration_json.feedback,
|
|
55
|
+
arbitration: input.arbitration_json.arbitration,
|
|
56
|
+
reset: input.arbitration_json.reset,
|
|
57
|
+
arb_withdraw: input.arbitration_json.arb_withdraw,
|
|
58
|
+
fees_transfer: input.arbitration_json.fees_transfer,
|
|
59
|
+
usage_guard: input.arbitration_json.usage_guard,
|
|
60
|
+
voting_guard: input.arbitration_json.voting_guard,
|
|
61
|
+
um: input.arbitration_json.um,
|
|
62
|
+
builder: input.arbitration_json.builder,
|
|
63
|
+
current_arb_status: input.current_arb_status,
|
|
64
|
+
expected_arb_status: input.arbitration_json.arbitration ? "Arbitrated" : input.current_arb_status,
|
|
65
|
+
};
|
|
66
|
+
risk_assessment = assessArbitrationRisks(ctx);
|
|
67
|
+
}
|
|
68
|
+
const relevant_checklist = filterChecklist(input.mode);
|
|
69
|
+
const relevant_questions = filterQuestions(input.mode);
|
|
70
|
+
const relevant_constraints = filterConstraints(input.mode, matched_scene);
|
|
71
|
+
const relevant_permissions = input.stakeholder === "system"
|
|
72
|
+
? getAllArbitrationPermissions()
|
|
73
|
+
: getActiveArbitrationPermissions();
|
|
74
|
+
let dual_guard_matrix_entry;
|
|
75
|
+
if (input.voting_guard_empty !== undefined && input.usage_guard_none !== undefined) {
|
|
76
|
+
dual_guard_matrix_entry = getDualGuardMatrixEntry(input.voting_guard_empty, input.usage_guard_none);
|
|
77
|
+
}
|
|
78
|
+
else if (matched_scene) {
|
|
79
|
+
const vEmpty = matched_scene.requires_voting_guard === "empty";
|
|
80
|
+
const uNone = matched_scene.requires_usage_guard === "none";
|
|
81
|
+
dual_guard_matrix_entry = getDualGuardMatrixEntry(vEmpty, uNone);
|
|
82
|
+
}
|
|
83
|
+
const arb_lifecycle_context = buildArbLifecycleContext(input.current_arb_status, matched_scene);
|
|
84
|
+
const cross_object_refs = buildCrossObjectRefs(matched_scene);
|
|
85
|
+
const onchain_constraints = buildOnchainConstraints();
|
|
86
|
+
const rendering_hints = buildRenderingHints(input.mode, max_length, !!input.arbitration_json?.arbitration, !!input.arbitration_json?.builder);
|
|
87
|
+
return {
|
|
88
|
+
version: ARBITRATION_CONTEXT_VERSION,
|
|
89
|
+
mode: input.mode,
|
|
90
|
+
stakeholder_perspective: input.stakeholder,
|
|
91
|
+
matched_scene,
|
|
92
|
+
matched_template,
|
|
93
|
+
matched_pattern,
|
|
94
|
+
puzzle_state,
|
|
95
|
+
puzzle_completeness,
|
|
96
|
+
relevant_risks,
|
|
97
|
+
risk_assessment,
|
|
98
|
+
relevant_checklist,
|
|
99
|
+
relevant_questions,
|
|
100
|
+
relevant_permissions,
|
|
101
|
+
relevant_constraints,
|
|
102
|
+
dual_guard_matrix_entry,
|
|
103
|
+
arb_lifecycle_context,
|
|
104
|
+
cross_object_refs,
|
|
105
|
+
onchain_constraints,
|
|
106
|
+
rendering_hints,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function filterRiskRules(mode, stakeholder, scene) {
|
|
110
|
+
const rules = getAllRiskRules();
|
|
111
|
+
if (mode === "initial_design") {
|
|
112
|
+
return rules.filter(r => r.category === "structural" || r.category === "authority");
|
|
113
|
+
}
|
|
114
|
+
if (mode === "pre_publish") {
|
|
115
|
+
return rules;
|
|
116
|
+
}
|
|
117
|
+
if (mode === "stakeholder_review" && stakeholder) {
|
|
118
|
+
if (stakeholder === "owner") {
|
|
119
|
+
return rules.filter(r => r.category === "authority" || r.category === "lifecycle" || r.category === "cross_object");
|
|
120
|
+
}
|
|
121
|
+
if (stakeholder === "arbiter") {
|
|
122
|
+
return rules.filter(r => r.category === "authority" || r.category === "lifecycle");
|
|
123
|
+
}
|
|
124
|
+
if (stakeholder === "voter") {
|
|
125
|
+
return rules.filter(r => r.category === "structural" || r.category === "lifecycle");
|
|
126
|
+
}
|
|
127
|
+
if (stakeholder === "disputant") {
|
|
128
|
+
return rules.filter(r => r.category === "semantic" || r.category === "lifecycle");
|
|
129
|
+
}
|
|
130
|
+
if (stakeholder === "system") {
|
|
131
|
+
return rules.filter(r => r.category === "structural" || r.category === "cross_object");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (mode === "post_publish_modify") {
|
|
135
|
+
return rules.filter(r => r.category === "lifecycle" || r.category === "cross_object");
|
|
136
|
+
}
|
|
137
|
+
return rules;
|
|
138
|
+
}
|
|
139
|
+
function filterChecklist(mode) {
|
|
140
|
+
if (mode === "initial_design") {
|
|
141
|
+
return ARBITRATION_OPERATION_CHECKLIST.filter(i => ["C-AB-01", "C-AB-02", "C-AB-03", "C-AB-04"].includes(i.id));
|
|
142
|
+
}
|
|
143
|
+
return [...ARBITRATION_OPERATION_CHECKLIST];
|
|
144
|
+
}
|
|
145
|
+
function filterQuestions(mode) {
|
|
146
|
+
if (mode === "pre_publish") {
|
|
147
|
+
return [...ARBITRATION_CONFIRMATION_QUESTIONS];
|
|
148
|
+
}
|
|
149
|
+
if (mode === "post_publish_modify") {
|
|
150
|
+
return ARBITRATION_CONFIRMATION_QUESTIONS.filter(q => q.id !== "QAB5");
|
|
151
|
+
}
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
function filterConstraints(mode, scene) {
|
|
155
|
+
if (mode === "initial_design") {
|
|
156
|
+
return ARBITRATION_CONSTRAINT_RULES.filter(c => c.category === "structural");
|
|
157
|
+
}
|
|
158
|
+
if (mode === "pre_publish") {
|
|
159
|
+
return [...ARBITRATION_CONSTRAINT_RULES];
|
|
160
|
+
}
|
|
161
|
+
if (scene) {
|
|
162
|
+
const categoryMap = {
|
|
163
|
+
lifecycle: ["structural", "authority"],
|
|
164
|
+
dispute: ["semantic", "lifecycle"],
|
|
165
|
+
voting: ["semantic", "lifecycle"],
|
|
166
|
+
ruling: ["authority", "lifecycle"],
|
|
167
|
+
fund: ["cross_object"],
|
|
168
|
+
guard: ["structural", "semantic"],
|
|
169
|
+
governance: ["authority"],
|
|
170
|
+
};
|
|
171
|
+
const cats = categoryMap[scene.operation_category] ?? [];
|
|
172
|
+
return ARBITRATION_CONSTRAINT_RULES.filter(c => cats.includes(c.category));
|
|
173
|
+
}
|
|
174
|
+
return [...ARBITRATION_CONSTRAINT_RULES];
|
|
175
|
+
}
|
|
176
|
+
function buildArbLifecycleContext(current_status, scene) {
|
|
177
|
+
if (!current_status && !scene)
|
|
178
|
+
return undefined;
|
|
179
|
+
const is_terminal = current_status ? isTerminalArbStatus(current_status) : false;
|
|
180
|
+
const valid_next_statuses = [];
|
|
181
|
+
if (current_status) {
|
|
182
|
+
const allStatuses = [
|
|
183
|
+
"Principal_confirming",
|
|
184
|
+
"Arbitrator_confirming",
|
|
185
|
+
"Voting",
|
|
186
|
+
"Arbitrated",
|
|
187
|
+
"Objectionable",
|
|
188
|
+
"Finished",
|
|
189
|
+
"Withdrawn",
|
|
190
|
+
];
|
|
191
|
+
for (const target of allStatuses) {
|
|
192
|
+
if (target !== current_status && isValidArbStatusTransition(current_status, target)) {
|
|
193
|
+
valid_next_statuses.push(target);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const valid_operations_from_here = [];
|
|
198
|
+
for (const s of ARBITRATION_SCENES) {
|
|
199
|
+
if (current_status && s.required_arb_status && s.required_arb_status.includes(current_status)) {
|
|
200
|
+
valid_operations_from_here.push(s.id);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
current_status,
|
|
205
|
+
current_status_code: current_status ? ARB_STATUS_CODE[current_status] : undefined,
|
|
206
|
+
is_terminal,
|
|
207
|
+
valid_next_statuses,
|
|
208
|
+
valid_operations_from_here,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function buildCrossObjectRefs(scene) {
|
|
212
|
+
const refs = [];
|
|
213
|
+
const outboundRefs = [
|
|
214
|
+
{
|
|
215
|
+
object: "Order",
|
|
216
|
+
field: "dispute.order",
|
|
217
|
+
scene_id: "arbitration_dispute",
|
|
218
|
+
description: "dispute() takes Order address — Order is the source of disputes",
|
|
219
|
+
direction: "references",
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
object: "Arb",
|
|
223
|
+
field: "dispute (spawns Arb)",
|
|
224
|
+
scene_id: "arbitration_dispute",
|
|
225
|
+
description: "Each dispute() creates a new Arb case object with 7-state lifecycle",
|
|
226
|
+
direction: "references",
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
object: "Guard",
|
|
230
|
+
field: "voting_guard / usage_guard",
|
|
231
|
+
scene_id: "arbitration_voting_guard_config / arbitration_usage_guard_config",
|
|
232
|
+
description: "voting_guard controls vote weight (max 50); usage_guard filters who can file disputes",
|
|
233
|
+
direction: "references",
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
object: "Allocation",
|
|
237
|
+
field: "fees_transfer.to.allocation",
|
|
238
|
+
scene_id: "arbitration_fees_transfer",
|
|
239
|
+
description: "Withdrawn fees can be routed to Allocation for arbiter compensation distribution",
|
|
240
|
+
direction: "references",
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
object: "Treasury",
|
|
244
|
+
field: "fees_transfer.to.treasury",
|
|
245
|
+
scene_id: "arbitration_fees_transfer",
|
|
246
|
+
description: "Withdrawn fees can be routed to Treasury as alternative destination",
|
|
247
|
+
direction: "references",
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
object: "Contact",
|
|
251
|
+
field: "um",
|
|
252
|
+
scene_id: "arbitration_um_set",
|
|
253
|
+
description: "um (Contact object) for arbitrator ↔ disputant communication channel",
|
|
254
|
+
direction: "references",
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
object: "Payment",
|
|
258
|
+
field: "fees_transfer.payment_remark / payment_index",
|
|
259
|
+
scene_id: "arbitration_fees_transfer",
|
|
260
|
+
description: "fees_transfer creates Payment object with remark + index for audit trail",
|
|
261
|
+
direction: "references",
|
|
262
|
+
},
|
|
263
|
+
];
|
|
264
|
+
const inboundRefs = [
|
|
265
|
+
{
|
|
266
|
+
object: "Service",
|
|
267
|
+
field: "arbitrations (MAX_ARBITRATION_COUNT=20)",
|
|
268
|
+
scene_id: "service_arbitration_config",
|
|
269
|
+
description: "Service embeds up to 20 Arbitration references for dispute resolution per service",
|
|
270
|
+
direction: "referenced_by",
|
|
271
|
+
},
|
|
272
|
+
];
|
|
273
|
+
if (scene) {
|
|
274
|
+
const sceneId = scene.id;
|
|
275
|
+
return [...outboundRefs, ...inboundRefs].filter(r => r.scene_id === sceneId || r.scene_id.includes(sceneId.split("_")[1] ?? ""));
|
|
276
|
+
}
|
|
277
|
+
return [...outboundRefs, ...inboundRefs];
|
|
278
|
+
}
|
|
279
|
+
function buildOnchainConstraints() {
|
|
280
|
+
return [
|
|
281
|
+
{
|
|
282
|
+
name: "MAX_VOTING_GUARD_COUNT",
|
|
283
|
+
value: MAX_VOTING_GUARD_COUNT,
|
|
284
|
+
description: "Maximum voting_guard entries per Arbitration (Move source: arbitration.move:25)",
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
name: "ARBITRATION_PERMISSION_INDEX_RANGE",
|
|
288
|
+
value: "350-368 (352 reserved)",
|
|
289
|
+
description: "19 built-in permission indexes for Arbitration — most among all 22 objects",
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: "ARB_STATE_COUNT",
|
|
293
|
+
value: 7,
|
|
294
|
+
description: "Arb has 7-state lifecycle: Principal_confirming → Arbitrator_confirming → Voting → Arbitrated → Objectionable → Finished/Withdrawn",
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
name: "ARB_TERMINAL_STATUSES",
|
|
298
|
+
value: ARB_TERMINAL_STATUSES.length,
|
|
299
|
+
description: `Terminal statuses: ${ARB_TERMINAL_STATUSES.join(", ")} (no further transitions)`,
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: "DUAL_GUARD_COMBINATIONS",
|
|
303
|
+
value: DUAL_GUARD_MATRIX.length,
|
|
304
|
+
description: "4 dual-Guard combos: (voting_guard empty/non-empty) × (usage_guard none/some)",
|
|
305
|
+
},
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
function buildRenderingHints(mode, max_length, hasIndemnity, hasOwnershipTransfer) {
|
|
309
|
+
return {
|
|
310
|
+
include_puzzle_template: mode === "initial_design",
|
|
311
|
+
include_risk_details: mode === "pre_publish" || mode === "stakeholder_review",
|
|
312
|
+
include_questions: mode === "pre_publish",
|
|
313
|
+
include_dual_guard_matrix: mode === "initial_design" || mode === "pre_publish",
|
|
314
|
+
include_arb_lifecycle: mode === "pre_publish" || mode === "post_publish_modify" || mode === "stakeholder_review",
|
|
315
|
+
include_immutability_warning: mode === "post_publish_modify",
|
|
316
|
+
include_indemnity_warning: hasIndemnity,
|
|
317
|
+
include_ownership_transfer_warning: hasOwnershipTransfer,
|
|
318
|
+
max_length,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
export function buildPromptFromArbitrationContext(bundle) {
|
|
322
|
+
const lines = [];
|
|
323
|
+
const h = bundle.rendering_hints;
|
|
324
|
+
lines.push(`═══ Arbitration Context (mode: ${bundle.mode}) ═══`);
|
|
325
|
+
lines.push("");
|
|
326
|
+
if (bundle.stakeholder_perspective) {
|
|
327
|
+
lines.push(`Stakeholder perspective: ${bundle.stakeholder_perspective}`);
|
|
328
|
+
lines.push("");
|
|
329
|
+
}
|
|
330
|
+
if (bundle.matched_scene) {
|
|
331
|
+
lines.push(`Scene: ${bundle.matched_scene.name}`);
|
|
332
|
+
lines.push(`Category: ${bundle.matched_scene.operation_category}`);
|
|
333
|
+
lines.push(`Permission index: ${bundle.matched_scene.permission_index} (${bundle.matched_scene.permission_name})`);
|
|
334
|
+
if (bundle.matched_scene.required_arb_status && bundle.matched_scene.required_arb_status.length > 0) {
|
|
335
|
+
lines.push(`Required Arb status: ${bundle.matched_scene.required_arb_status.join(" | ")}`);
|
|
336
|
+
}
|
|
337
|
+
if (bundle.matched_scene.resulting_arb_status) {
|
|
338
|
+
lines.push(`Resulting Arb status: ${bundle.matched_scene.resulting_arb_status}`);
|
|
339
|
+
}
|
|
340
|
+
lines.push(`Has _with_passport variant: ${bundle.matched_scene.has_passport_variant ? "YES" : "NO"}`);
|
|
341
|
+
lines.push("");
|
|
342
|
+
}
|
|
343
|
+
if (bundle.matched_template) {
|
|
344
|
+
lines.push(`Suggested template: ${bundle.matched_template.id} — ${bundle.matched_template.name}`);
|
|
345
|
+
lines.push(`Description: ${bundle.matched_template.description}`);
|
|
346
|
+
lines.push("");
|
|
347
|
+
}
|
|
348
|
+
if (bundle.matched_pattern) {
|
|
349
|
+
lines.push(`Matched pattern: ${bundle.matched_pattern.id} — ${bundle.matched_pattern.pattern_name}`);
|
|
350
|
+
lines.push(`Intent: ${bundle.matched_pattern.semantic_intent}`);
|
|
351
|
+
lines.push("");
|
|
352
|
+
}
|
|
353
|
+
if (h.include_puzzle_template && bundle.puzzle_completeness) {
|
|
354
|
+
const c = bundle.puzzle_completeness;
|
|
355
|
+
lines.push("─ Puzzle Completeness ──────────────");
|
|
356
|
+
lines.push(`Complete: ${c.complete ? "YES" : "NO"}`);
|
|
357
|
+
if (c.missing.length > 0) {
|
|
358
|
+
lines.push(`Missing dimensions: ${c.missing.join(", ")}`);
|
|
359
|
+
}
|
|
360
|
+
lines.push(`Next step: ${c.next_step}`);
|
|
361
|
+
lines.push("");
|
|
362
|
+
}
|
|
363
|
+
if (h.include_dual_guard_matrix && bundle.dual_guard_matrix_entry) {
|
|
364
|
+
const m = bundle.dual_guard_matrix_entry;
|
|
365
|
+
lines.push("─ Dual-Guard Matrix Entry ──────────────");
|
|
366
|
+
lines.push(`Voting guard: ${m.voting_guard_empty ? "EMPTY (open vote)" : "NON-EMPTY (weighted)"}`);
|
|
367
|
+
lines.push(`Usage guard: ${m.usage_guard_none ? "NONE (open dispute)" : "SOME (filtered dispute)"}`);
|
|
368
|
+
lines.push(`Vote method: ${m.vote_method}`);
|
|
369
|
+
lines.push(`Dispute method: ${m.dispute_method}`);
|
|
370
|
+
lines.push(`Scenario: ${m.scenario}`);
|
|
371
|
+
lines.push("");
|
|
372
|
+
}
|
|
373
|
+
if (h.include_arb_lifecycle && bundle.arb_lifecycle_context) {
|
|
374
|
+
const lc = bundle.arb_lifecycle_context;
|
|
375
|
+
lines.push("─ Arb 7-State Lifecycle Context ──────────────");
|
|
376
|
+
if (lc.current_status) {
|
|
377
|
+
lines.push(`Current Arb status: ${lc.current_status} (code ${lc.current_status_code})`);
|
|
378
|
+
lines.push(`Terminal: ${lc.is_terminal ? "YES — no further transitions" : "NO"}`);
|
|
379
|
+
if (lc.valid_next_statuses.length > 0) {
|
|
380
|
+
lines.push(`Valid next statuses: ${lc.valid_next_statuses.join(", ")}`);
|
|
381
|
+
}
|
|
382
|
+
if (lc.valid_operations_from_here.length > 0) {
|
|
383
|
+
lines.push(`Valid operations from here (${lc.valid_operations_from_here.length}):`);
|
|
384
|
+
for (const op of lc.valid_operations_from_here.slice(0, 6)) {
|
|
385
|
+
lines.push(` - ${op}`);
|
|
386
|
+
}
|
|
387
|
+
if (lc.valid_operations_from_here.length > 6) {
|
|
388
|
+
lines.push(` ... and ${lc.valid_operations_from_here.length - 6} more`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
lines.push("No current Arb status provided — lifecycle context inactive");
|
|
394
|
+
}
|
|
395
|
+
lines.push("");
|
|
396
|
+
}
|
|
397
|
+
if (h.include_risk_details && bundle.relevant_risks.length > 0) {
|
|
398
|
+
lines.push(`─ Relevant Risk Rules (${bundle.relevant_risks.length}) ──────────────`);
|
|
399
|
+
for (const r of bundle.relevant_risks.slice(0, 6)) {
|
|
400
|
+
lines.push(` ${r.id} — ${r.trigger}`);
|
|
401
|
+
}
|
|
402
|
+
if (bundle.relevant_risks.length > 6) {
|
|
403
|
+
lines.push(` ... and ${bundle.relevant_risks.length - 6} more`);
|
|
404
|
+
}
|
|
405
|
+
lines.push("");
|
|
406
|
+
}
|
|
407
|
+
if (bundle.risk_assessment) {
|
|
408
|
+
lines.push("─ Risk Assessment ──────────────");
|
|
409
|
+
lines.push(`Overall risk: ${bundle.risk_assessment.overall_risk}`);
|
|
410
|
+
lines.push(`Detected: ${bundle.risk_assessment.risks.length} risk(s)`);
|
|
411
|
+
if (bundle.risk_assessment.risks.length > 0) {
|
|
412
|
+
for (const r of bundle.risk_assessment.risks.slice(0, 3)) {
|
|
413
|
+
lines.push(` [${r.level}] ${r.id}: ${r.title}`);
|
|
414
|
+
}
|
|
415
|
+
if (bundle.risk_assessment.risks.length > 3) {
|
|
416
|
+
lines.push(` ... and ${bundle.risk_assessment.risks.length - 3} more`);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
lines.push("");
|
|
420
|
+
}
|
|
421
|
+
if (bundle.relevant_permissions.length > 0) {
|
|
422
|
+
lines.push(`─ Relevant Permissions (${bundle.relevant_permissions.length}) ──────────────`);
|
|
423
|
+
for (const p of bundle.relevant_permissions.slice(0, 10)) {
|
|
424
|
+
const reserved = p.is_reserved ? " [RESERVED]" : "";
|
|
425
|
+
lines.push(` [${p.index}] ${p.name}${reserved}: ${p.description}`);
|
|
426
|
+
}
|
|
427
|
+
if (bundle.relevant_permissions.length > 10) {
|
|
428
|
+
lines.push(` ... and ${bundle.relevant_permissions.length - 10} more`);
|
|
429
|
+
}
|
|
430
|
+
lines.push("");
|
|
431
|
+
}
|
|
432
|
+
if (bundle.relevant_constraints.length > 0) {
|
|
433
|
+
lines.push(`─ Relevant Constraint Rules (${bundle.relevant_constraints.length}) ──────────────`);
|
|
434
|
+
for (const c of bundle.relevant_constraints.slice(0, 5)) {
|
|
435
|
+
lines.push(` ${c.id} [${c.category}]: ${c.rule}`);
|
|
436
|
+
}
|
|
437
|
+
if (bundle.relevant_constraints.length > 5) {
|
|
438
|
+
lines.push(` ... and ${bundle.relevant_constraints.length - 5} more`);
|
|
439
|
+
}
|
|
440
|
+
lines.push("");
|
|
441
|
+
}
|
|
442
|
+
if (h.include_indemnity_warning) {
|
|
443
|
+
lines.push("⚠️ INDEMNITY OPERATION DETECTED — arbitration.indemnity transfers WOW from arbiter to disputant");
|
|
444
|
+
lines.push(" This is IRREVERSIBLE once the ruling is finalized. Verify indemnity amount carefully.");
|
|
445
|
+
lines.push("");
|
|
446
|
+
}
|
|
447
|
+
if (h.include_ownership_transfer_warning) {
|
|
448
|
+
lines.push("⚠️ OWNERSHIP TRANSFER DETECTED — builder field transfers Arbitration ownership");
|
|
449
|
+
lines.push(" This is IRREVERSIBLE. Original owner will lose all administrative rights.");
|
|
450
|
+
lines.push("");
|
|
451
|
+
}
|
|
452
|
+
if (h.include_immutability_warning) {
|
|
453
|
+
lines.push("ℹ️ POST-PUBLISH MODIFICATION — Arbitration is already on-chain");
|
|
454
|
+
lines.push(" Some fields can be modified (description, location, fee, voting_guard, usage_guard)");
|
|
455
|
+
lines.push(" but core properties (coin_type, permission object) are immutable.");
|
|
456
|
+
lines.push("");
|
|
457
|
+
}
|
|
458
|
+
if (bundle.cross_object_refs.length > 0) {
|
|
459
|
+
lines.push(`─ Cross-Object References (${bundle.cross_object_refs.length}) ──────────────`);
|
|
460
|
+
for (const r of bundle.cross_object_refs.slice(0, 6)) {
|
|
461
|
+
const arrow = r.direction === "references" ? "→" : "←";
|
|
462
|
+
lines.push(` ${arrow} ${r.object}.${r.field} (${r.direction}) — ${r.description}`);
|
|
463
|
+
}
|
|
464
|
+
if (bundle.cross_object_refs.length > 6) {
|
|
465
|
+
lines.push(` ... and ${bundle.cross_object_refs.length - 6} more`);
|
|
466
|
+
}
|
|
467
|
+
lines.push("");
|
|
468
|
+
}
|
|
469
|
+
if (bundle.onchain_constraints.length > 0) {
|
|
470
|
+
lines.push("─ On-chain Constraints ──────────────");
|
|
471
|
+
for (const c of bundle.onchain_constraints) {
|
|
472
|
+
lines.push(` ${c.name} = ${c.value} — ${c.description}`);
|
|
473
|
+
}
|
|
474
|
+
lines.push("");
|
|
475
|
+
}
|
|
476
|
+
return lines.join("\n");
|
|
477
|
+
}
|
|
478
|
+
export function getArbitrationContextSummary(bundle) {
|
|
479
|
+
const parts = [
|
|
480
|
+
`mode=${bundle.mode}`,
|
|
481
|
+
`scene=${bundle.matched_scene?.id ?? "none"}`,
|
|
482
|
+
`risks=${bundle.relevant_risks.length}`,
|
|
483
|
+
`permissions=${bundle.relevant_permissions.length}`,
|
|
484
|
+
`constraints=${bundle.relevant_constraints.length}`,
|
|
485
|
+
];
|
|
486
|
+
if (bundle.stakeholder_perspective)
|
|
487
|
+
parts.push(`stakeholder=${bundle.stakeholder_perspective}`);
|
|
488
|
+
if (bundle.risk_assessment)
|
|
489
|
+
parts.push(`overall_risk=${bundle.risk_assessment.overall_risk}`);
|
|
490
|
+
if (bundle.dual_guard_matrix_entry) {
|
|
491
|
+
parts.push(`dual_guard=${bundle.dual_guard_matrix_entry.vote_method}+${bundle.dual_guard_matrix_entry.dispute_method}`);
|
|
492
|
+
}
|
|
493
|
+
if (bundle.arb_lifecycle_context?.current_status) {
|
|
494
|
+
parts.push(`arb_status=${bundle.arb_lifecycle_context.current_status}`);
|
|
495
|
+
}
|
|
496
|
+
if (bundle.cross_object_refs.length > 0)
|
|
497
|
+
parts.push(`xrefs=${bundle.cross_object_refs.length}`);
|
|
498
|
+
return parts.join(", ");
|
|
499
|
+
}
|
|
500
|
+
export { ARBITRATION_LEDGER_VERSION, ARBITRATION_SCENES, ARBITRATION_PERMISSIONS, DUAL_GUARD_MATRIX, ARB_STATUS_CODE, ARB_TERMINAL_STATUSES, findSceneById, findSceneByPermissionIndex, inferSceneFromIntent, getScenesByCategory, getDualGuardMatrixEntry, isValidArbStatusTransition, isTerminalArbStatus, getActiveArbitrationPermissions, getAllArbitrationPermissions, } from "./arbitration-ledger.js";
|
|
501
|
+
export { ARBITRATION_TEMPLATES_VERSION, ARBITRATION_TEMPLATES, suggestTemplateForScene, getTemplatesByScene, getTemplateById, } from "./arbitration-templates.js";
|
|
502
|
+
export { ARBITRATION_TRANSLATION_VERSION, SEMANTIC_TO_SCHEMA_RULES, ARBITRATION_CONSTRAINT_RULES, matchSemanticPattern, explainArbitrationCallData, explainPermissionIndex, explainArbStatus, } from "./arbitration-translation.js";
|
|
503
|
+
export { ARBITRATION_RISK_VERSION, getAllRiskRules, assessArbitrationRisks, } from "./arbitration-risk.js";
|
|
504
|
+
export { ARBITRATION_CONFIRM_VERSION, ARBITRATION_OPERATION_CHECKLIST, ARBITRATION_CONFIRMATION_QUESTIONS, runArbitrationConfirmGate, } from "./arbitration-confirm.js";
|
|
505
|
+
export { initPuzzleFromIntent, checkPuzzleCompleteness, validateConstraints, } from "./arbitration-puzzle.js";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface ArbitrationScene {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
operation_category: "lifecycle" | "dispute" | "voting" | "ruling" | "fund" | "guard" | "governance";
|
|
5
|
+
permission_index: number;
|
|
6
|
+
permission_name: string;
|
|
7
|
+
required_arb_status?: ArbStatus[];
|
|
8
|
+
resulting_arb_status?: ArbStatus;
|
|
9
|
+
requires_voting_guard?: "empty" | "non_empty" | "any" | "not_applicable";
|
|
10
|
+
requires_usage_guard?: "none" | "some" | "any" | "not_applicable";
|
|
11
|
+
has_passport_variant: boolean;
|
|
12
|
+
governed_operations: string[];
|
|
13
|
+
common_patterns: string[];
|
|
14
|
+
recommended_templates: string[];
|
|
15
|
+
}
|
|
16
|
+
export type ArbStatus = "Principal_confirming" | "Arbitrator_confirming" | "Voting" | "Arbitrated" | "Objectionable" | "Finished" | "Withdrawn";
|
|
17
|
+
export declare const ARB_STATUS_CODE: Record<ArbStatus, number>;
|
|
18
|
+
export declare const ARB_TERMINAL_STATUSES: ArbStatus[];
|
|
19
|
+
export declare const ARB_STATUS_ALIASES: Record<string, ArbStatus>;
|
|
20
|
+
export interface ArbitrationPermissionEntry {
|
|
21
|
+
index: number;
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
governed_operations: string[];
|
|
25
|
+
is_reserved?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare const ARBITRATION_PERMISSIONS: ArbitrationPermissionEntry[];
|
|
28
|
+
export interface VotingGuardEntry {
|
|
29
|
+
guard: string;
|
|
30
|
+
vote_weight: {
|
|
31
|
+
GuardIdentifier: number;
|
|
32
|
+
} | {
|
|
33
|
+
FixedValue: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface DualGuardMatrix {
|
|
37
|
+
voting_guard_empty: boolean;
|
|
38
|
+
usage_guard_none: boolean;
|
|
39
|
+
dispute_method: "dispute" | "dispute_with_passport";
|
|
40
|
+
vote_method: "vote" | "vote_with_voting_guard";
|
|
41
|
+
scenario: string;
|
|
42
|
+
}
|
|
43
|
+
export declare const DUAL_GUARD_MATRIX: DualGuardMatrix[];
|
|
44
|
+
export declare const ARBITRATION_SCENES: ArbitrationScene[];
|
|
45
|
+
export declare const ARBITRATION_LEDGER_VERSION = "1.0.0";
|
|
46
|
+
export declare function getScenesByCategory(category: ArbitrationScene["operation_category"]): ArbitrationScene[];
|
|
47
|
+
export declare function findSceneById(id: string): ArbitrationScene | undefined;
|
|
48
|
+
export declare function findSceneByPermissionIndex(index: number): ArbitrationScene | undefined;
|
|
49
|
+
export declare function getPermissionByIndex(index: number): ArbitrationPermissionEntry | undefined;
|
|
50
|
+
export declare function getPermissionByName(name: string): ArbitrationPermissionEntry | undefined;
|
|
51
|
+
export declare function isReservedIndex(index: number): boolean;
|
|
52
|
+
export declare function isUsedPermissionIndex(index: number): boolean;
|
|
53
|
+
export declare function getActivePermissionCount(): number;
|
|
54
|
+
export declare function inferSceneFromIntent(intent: string): ArbitrationScene | undefined;
|
|
55
|
+
export declare function getDualGuardMatrixEntry(votingGuardEmpty: boolean, usageGuardNone: boolean): DualGuardMatrix;
|
|
56
|
+
export declare function isValidArbStatusTransition(from: ArbStatus, to: ArbStatus): boolean;
|
|
57
|
+
export declare function isTerminalArbStatus(status: ArbStatus): boolean;
|
|
58
|
+
export declare function getScenesProducingStatus(status: ArbStatus): ArbitrationScene[];
|
|
59
|
+
export declare function getScenesRequiringStatus(status: ArbStatus): ArbitrationScene[];
|
|
60
|
+
export declare function getArbitrationScenesCount(): number;
|
|
61
|
+
export declare function getAllArbitrationPermissions(): ArbitrationPermissionEntry[];
|
|
62
|
+
export declare function getActiveArbitrationPermissions(): ArbitrationPermissionEntry[];
|