@wowok/skills 1.1.13 → 1.2.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/LICENSE +1 -2
- package/examples/Insurance/Insurance.md +309 -72
- package/examples/MyShop/MyShop.md +169 -39
- package/examples/MyShop_Advanced/MyShop_Advanced.md +415 -49
- package/examples/ThreeBody_Signature/ThreeBody_Signature.md +200 -18
- package/examples/Travel/Travel.md +234 -59
- package/package.json +1 -1
- package/wowok-guard/SKILL.md +192 -1
- package/wowok-machine/SKILL.md +72 -0
- package/wowok-order/APPENDIX.md +33 -33
- package/wowok-provider/SKILL.md +26 -12
- package/wowok-scenario/SKILL.md +10 -0
- package/wowok-tools/SKILL.md +2 -2
package/wowok-guard/SKILL.md
CHANGED
|
@@ -78,6 +78,101 @@ A Guard is fundamentally a **data computation tree**: deterministic data (on-cha
|
|
|
78
78
|
|
|
79
79
|
**Guard essence**: A deterministic data set (Type 1 + Type 4) + submitted data (Type 3, must have constraint rules and defined types) → derived through finite operation rules → a single boolean result. The semantics are deterministic — you only need to fill in the "data object source meaning" and "field meaning" (e.g., "the permission address of service A", "the current node time of workflow B").
|
|
80
80
|
|
|
81
|
+
### Verifier Constraint Levels — Designing Who Can Pass
|
|
82
|
+
|
|
83
|
+
When a Guard uses `context(Signer)`, the designer chooses how strictly to constrain the verifier's identity. Three levels exist, trading off **security** against **convenience**. Evaluating designer intent and dismantling the semantic execution plan across these levels is a core capability — choose the right level for each scene.
|
|
84
|
+
|
|
85
|
+
#### Level 1 — Strict Single-Identity Binding (avoid unless justified)
|
|
86
|
+
|
|
87
|
+
**Pattern**: `logic_equal[context(Signer), identifier[N](fixed_address)]`
|
|
88
|
+
|
|
89
|
+
- **Maximally secure**: only ONE address can pass
|
|
90
|
+
- **Maximally inconvenient**: if that address is unavailable (key loss, personnel change, rotation), the Guard permanently blocks the operation — Guards are **immutable** after publish
|
|
91
|
+
- **Use only when**: the role is permanently tied to one address AND the designer explicitly accepts the lock-in risk
|
|
92
|
+
- **Risk rule**: `R-C4-04` (info) flags this pattern with a convenience reminder
|
|
93
|
+
- **Example**: `logic_equal[context(Signer), identifier[5](myshop_merchant)]`
|
|
94
|
+
|
|
95
|
+
> ⚠️ **Avoid Level 1 unless you understand the lock-in risk.** Prefer Level 2 (identity-set) or Level 3 (scene-combined) whenever possible.
|
|
96
|
+
|
|
97
|
+
#### Level 2 — Identity-Set Binding (recommended for role-based access)
|
|
98
|
+
|
|
99
|
+
**Pattern**: `logic_or` of multiple identity checks — Signer is ANY of a valid set.
|
|
100
|
+
|
|
101
|
+
**Key semantic insight — Address vs Bool return types**:
|
|
102
|
+
Guard queries that verify identity fall into two categories based on their return type, and this determines how they participate in a `logic_or`:
|
|
103
|
+
|
|
104
|
+
| Return Type | Query Examples | Construction in `logic_or` |
|
|
105
|
+
|-------------|---------------|---------------------------|
|
|
106
|
+
| **Address** | `1562 order.owner`, `1002 permission.owner`, `1488 service.permission` | Must wrap each in `logic_equal[query, context(Signer)]` to produce a Bool |
|
|
107
|
+
| **Bool** (suffix "has") | `1567 order.agent has`, `1004 permission.admin has`, `1006 permission.entity has` | Use **directly** as a `logic_or` child — they already return a verdict; pass `context(Signer)` as a parameter |
|
|
108
|
+
|
|
109
|
+
**Example — Order-holder identity set** (Signer is owner OR agent):
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"type": "logic_or",
|
|
113
|
+
"nodes": [
|
|
114
|
+
{
|
|
115
|
+
"type": "logic_equal",
|
|
116
|
+
"nodes": [
|
|
117
|
+
{"type": "query", "query": 1562, "object": {"identifier": 0}, "parameters": []},
|
|
118
|
+
{"type": "context", "context": "Signer"}
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"type": "query",
|
|
123
|
+
"query": 1567,
|
|
124
|
+
"object": {"identifier": 0},
|
|
125
|
+
"parameters": [{"type": "context", "context": "Signer"}]
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
Here `1562` returns Address → wrapped in `logic_equal`; `1567` returns Bool → used directly with `context(Signer)` as its parameter.
|
|
131
|
+
|
|
132
|
+
**Example — Service-provider identity set** (Signer is permission.owner OR has admin):
|
|
133
|
+
|
|
134
|
+
Three sub-patterns with increasing flexibility:
|
|
135
|
+
|
|
136
|
+
1. **Static permission address** (simplest, breaks if Service rotates permission):
|
|
137
|
+
Query `1002`/`1004` against a table-constant permission address. If the Service changes its permission (like a company changing its board), the Guard must be rebuilt.
|
|
138
|
+
|
|
139
|
+
2. **Dynamic permission address** (survives rotation — **RECOMMENDED**):
|
|
140
|
+
The caller submits a permission address; the Guard verifies `query(1488: service.permission) == submitted_perm`, then checks `1002`/`1004` against the submitted permission. This survives permission rotation without rebuilding the Guard.
|
|
141
|
+
|
|
142
|
+
3. **Repository-based address set** (most flexible, most complex — **only for extreme flexibility needs**):
|
|
143
|
+
The permission address set is stored in a Repository and queried dynamically. This allows runtime configuration of the authorized set, but adds significant complexity.
|
|
144
|
+
|
|
145
|
+
> 💡 **`logic_or` wrapping of the Signer check suppresses R-C4-04** — this is the recommended Level 2 alternative to Level 1 strict binding.
|
|
146
|
+
|
|
147
|
+
#### Level 3 — Scene-Combined Constraint (verify whether Signer binding is even needed)
|
|
148
|
+
|
|
149
|
+
Before adding any Signer binding, evaluate the Guard's usage scene. **Many scenes do not need Signer binding at all** — the scene itself ensures safety through other mechanisms.
|
|
150
|
+
|
|
151
|
+
| Scene | Is Signer binding needed? | Why |
|
|
152
|
+
|-------|--------------------------|-----|
|
|
153
|
+
| Service `order_allocators` + `sharing.who=Entity` | **NO** | Funds flow to a fixed Treasury/address regardless of caller — `sharing.who` already guarantees recipient safety (R-C3-06 safe) |
|
|
154
|
+
| Service `order_allocators` + `sharing.who=Signer` | **YES (Level 2 dynamic)** | Funds flow to caller — must bind Signer to authorized recipient (e.g., `order.owner`) |
|
|
155
|
+
| Machine `forward` guard | **MAYBE** | Forward's `permissionIndex`/`namedOperator` already verifies operator permission; Signer binding only needed if submitted data must belong to operator |
|
|
156
|
+
| Service `buy_guard` | **Usually NO** | The customer is the caller; identity checks via whitelist/credentials suffice |
|
|
157
|
+
| Reward `guard` | **Depends** | If claim is one-time (record count), no Signer binding needed; if claim amount is submitted, bind Signer |
|
|
158
|
+
| Arbitration `voting_guard` | **NO** (weight from query, not Signer) | Weight must come from on-chain EntityRegistrar, not submission (R-C3-02) |
|
|
159
|
+
|
|
160
|
+
**Decision flow**:
|
|
161
|
+
1. Does the scene's host object already verify the operator? (e.g., Machine forward) → Signer binding may be redundant
|
|
162
|
+
2. Does `sharing.who` route funds to a fixed recipient? → Signer binding unnecessary (R-C3-06 safe)
|
|
163
|
+
3. Does the resource flow matter more than who triggers it? → Focus on flow safety, not caller identity
|
|
164
|
+
4. Only if resources flow to the caller AND no other layer verifies identity → add Level 2 Signer binding
|
|
165
|
+
|
|
166
|
+
#### One Guard One Purpose Principle
|
|
167
|
+
|
|
168
|
+
Each Guard should serve **ONE specific purpose**, documented in its `description`:
|
|
169
|
+
- **Scenario**: where the Guard is attached (which host object, which binding field)
|
|
170
|
+
- **Verification rules**: concise statement of what conditions are checked
|
|
171
|
+
- **Risk notes**: which risks are mitigated (R-C3-01/05/06, etc.) and which trade-offs apply
|
|
172
|
+
- **Verifier constraint level**: which Level (1/2/3) is used and why
|
|
173
|
+
|
|
174
|
+
General-purpose Guards designed for `rely` composition are the exception — they need explicit general rules and composition documentation. All other Guards should be single-purpose.
|
|
175
|
+
|
|
81
176
|
### Where Guards Attach in the Ecosystem
|
|
82
177
|
|
|
83
178
|
Guards are not standalone — they plug into other WoWok objects as validation rules. Understanding these integration points is essential because the **context** of the Guard determines what data is available to it and what happens when it fails.
|
|
@@ -161,7 +256,7 @@ The Guard table is the **complete declaration of information** the Guard consume
|
|
|
161
256
|
|-------|---------|---------------|
|
|
162
257
|
| `identifier` | Unique index (0–255). The computation tree uses this number to reference the entry. | Always |
|
|
163
258
|
| `b_submission` | Whether the **caller** must provide this value at runtime. `true` = runtime submission; `false` = pre-set constant. | Always |
|
|
164
|
-
| `value_type` | The type of the value: Bool, Address, String, U8–U256, or vector types.
|
|
259
|
+
| `value_type` | The type of the value: Bool, Address, String, U8–U256, or vector types. Accepts both string names (preferred, e.g., `"Address"`, `"U64"`) and numeric codes (e.g., `1`, `6`). Use `wowok_buildin_info` with info `"value types"` for the complete mapping. SDK deserialization returns string names. | Always |
|
|
165
260
|
| `value` | The constant value when `b_submission` is false; a placeholder when `b_submission` is true. | When `b_submission` is false |
|
|
166
261
|
| `name` | Human-readable label describing what this entry represents. | Always |
|
|
167
262
|
|
|
@@ -429,6 +524,102 @@ These constraints are checked at Guard verification time (gen_passport or actual
|
|
|
429
524
|
- **RUN_TX_01**: The Passport's `tx_hash` must match the current transaction.
|
|
430
525
|
- **RUN_RELY_01**: Rely guards must have been added to the passport.
|
|
431
526
|
|
|
527
|
+
### Readability Conventions — Prefer String Names Over Numeric IDs
|
|
528
|
+
|
|
529
|
+
> **Built-in MCP convention**: Whenever the schema accepts BOTH a numeric ID and a human-readable string name for the same field, **always prefer the string name** in examples, documentation, and AI-generated JSON. Numeric IDs are accepted for backward compatibility and compact machine output, but string names are the canonical form for any human-readable artifact.
|
|
530
|
+
|
|
531
|
+
This convention is grounded in the user-experience principle: *"Wherever the interface supports it, optimize from the user's understanding as the starting point."* A reader who sees `"query": "order.service"` understands the intent immediately; `"query": 1563` requires an extra lookup against the `GUARDQUERY` registry.
|
|
532
|
+
|
|
533
|
+
#### Fields Affected
|
|
534
|
+
|
|
535
|
+
| Field | String form (preferred) | Numeric form (avoid) | Source of truth |
|
|
536
|
+
|-------|-------------------------|----------------------|-----------------|
|
|
537
|
+
| `query` | `"order.service"` | `1563` | `GUARDQUERY` registry (375 entries, exported by `@wowok/wowok`) |
|
|
538
|
+
| `value_type` | `"Address"`, `"U64"`, `"String"` | `1`, `6`, `2` | `ValueType` enum |
|
|
539
|
+
| `context` | `"Signer"`, `"Clock"`, `"Guard"` | (numeric not accepted) | `Context` enum |
|
|
540
|
+
| `convert_witness` | `"OrderProgress"`, `"OrderMachine"` | `100`, `101` | `WitnessType` enum (SDK `parseWitnessType` / `witnessTypeToString`) |
|
|
541
|
+
|
|
542
|
+
#### Why String Names
|
|
543
|
+
|
|
544
|
+
1. **Self-documenting JSON** — `"query": "order.service"` reads as intent; `1563` is opaque.
|
|
545
|
+
2. **Stable across registry renumbering** — names are part of the public contract; numeric IDs are an implementation detail.
|
|
546
|
+
3. **Case-insensitive matching** — `isValidGuardQueryName` lowercases both sides, so `"Order.Service"` and `"order.service"` are equivalent. Use the canonical lowercase form in examples.
|
|
547
|
+
4. **Lint-friendly** — string names survive refactoring; numeric IDs silently rot when an ID is deprecated.
|
|
548
|
+
|
|
549
|
+
#### Canonical Name Examples
|
|
550
|
+
|
|
551
|
+
The most common queries used in allocator Guards (R-C3-05 / R-C3-06 protection):
|
|
552
|
+
|
|
553
|
+
| Numeric ID | Canonical name | Returns | Typical use |
|
|
554
|
+
|------------|----------------|---------|-------------|
|
|
555
|
+
| `1253` | `progress.current` | String | Verify order is at a named node (with `convert_witness: 100`) |
|
|
556
|
+
| `1563` | `order.service` | Address | Cross-service theft protection (R-C3-05) |
|
|
557
|
+
| `1562` | `order.owner` | Address | Signer binding for refunds (R-C3-06 Level 2 dynamic) |
|
|
558
|
+
| `1272` | `progress.current_time` | U64 | Time-lock comparisons |
|
|
559
|
+
| `1488` | `service.permission` | Address | Verify Service's Permission object |
|
|
560
|
+
| `1002` | `permission.owner` | Address | Signer == permission owner (Level 1 fixed) |
|
|
561
|
+
| `1004` | `permission.admin has` | Bool | Caller is in admin set (Level 2 identity-set) |
|
|
562
|
+
| `1567` | `order.agent has` | Bool | Verify caller is an order agent |
|
|
563
|
+
|
|
564
|
+
#### WitnessType String Names
|
|
565
|
+
|
|
566
|
+
The `convert_witness` field accepts both numeric IDs (100-108) and string names. String matching is case-insensitive and accepts both the full enum name (`"TypeOrderProgress"`) and the shortened form without the `"Type"` prefix (`"OrderProgress"`). The shortened form is preferred for readability.
|
|
567
|
+
|
|
568
|
+
| Numeric ID | Shortened name (preferred) | Full enum name | Source → Target |
|
|
569
|
+
|------------|----------------------------|----------------|-----------------|
|
|
570
|
+
| `100` | `"OrderProgress"` | `"TypeOrderProgress"` | Order → Progress |
|
|
571
|
+
| `101` | `"OrderMachine"` | `"TypeOrderMachine"` | Order → Machine |
|
|
572
|
+
| `102` | `"OrderService"` | `"TypeOrderService"` | Order → Service |
|
|
573
|
+
| `103` | `"ProgressMachine"` | `"TypeProgressMachine"` | Progress → Machine |
|
|
574
|
+
| `104` | `"ArbOrder"` | `"TypeArbOrder"` | Arb → Order |
|
|
575
|
+
| `105` | `"ArbArbitration"` | `"TypeArbArbitration"` | Arb → Arbitration |
|
|
576
|
+
| `106` | `"ArbProgress"` | `"TypeArbProgress"` | Arb → Progress |
|
|
577
|
+
| `107` | `"ArbMachine"` | `"TypeArbMachine"` | Arb → Machine |
|
|
578
|
+
| `108` | `"ArbService"` | `"TypeArbService"` | Arb → Service |
|
|
579
|
+
|
|
580
|
+
SDK functions: `parseWitnessType(input)` converts string→number; `witnessTypeToString(type)` converts number→string (returns the shortened form). The SDK's Guard deserialization (`parseQueryNode`) already returns `convert_witness` as a string name.
|
|
581
|
+
|
|
582
|
+
#### Deserialization Output — All Protocol Constants Return Strings
|
|
583
|
+
|
|
584
|
+
The SDK's Guard deserialization (`query_objects` / `guard2file`) returns ALL protocol constants as user-friendly strings, not numeric IDs:
|
|
585
|
+
|
|
586
|
+
| Field | Returned as | Example | Conversion function |
|
|
587
|
+
|-------|-------------|---------|---------------------|
|
|
588
|
+
| `query` | String name | `"order.service"` | `GUARDQUERY` registry lookup |
|
|
589
|
+
| `value_type` | String name | `"Address"`, `"U64"` | `valueTypeToString()` |
|
|
590
|
+
| `convert_witness` | String name | `"OrderProgress"` | `witnessTypeToString()` |
|
|
591
|
+
| `context` | String literal | `"Signer"`, `"Clock"`, `"Guard"` | Hardcoded string |
|
|
592
|
+
| `object_type` | String name | `"Order"`, `"Service"` | `numberToObjectType` mapping |
|
|
593
|
+
| `type` (node discriminator) | String literal | `"logic_and"`, `"query"` | Always string |
|
|
594
|
+
|
|
595
|
+
This means `guard2file` JSON/Markdown output and `query_objects` results are fully self-documenting without requiring numeric ID lookups.
|
|
596
|
+
|
|
597
|
+
#### Example — Before and After
|
|
598
|
+
|
|
599
|
+
**Before (numeric, opaque):**
|
|
600
|
+
```json
|
|
601
|
+
{
|
|
602
|
+
"type": "logic_equal",
|
|
603
|
+
"nodes": [
|
|
604
|
+
{"type": "query", "query": 1563, "object": {"identifier": 0, "convert_witness": 100}, "parameters": []},
|
|
605
|
+
{"type": "identifier", "identifier": 2}
|
|
606
|
+
]
|
|
607
|
+
}
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
**After (string, self-documenting):**
|
|
611
|
+
```json
|
|
612
|
+
{
|
|
613
|
+
"type": "logic_equal",
|
|
614
|
+
"nodes": [
|
|
615
|
+
{"type": "query", "query": "order.service", "object": {"identifier": 0, "convert_witness": "OrderProgress"}, "parameters": []},
|
|
616
|
+
{"type": "identifier", "identifier": 2}
|
|
617
|
+
]
|
|
618
|
+
}
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
Both forms are schema-valid and produce identical on-chain behavior; the string form is preferred for all human-readable output.
|
|
622
|
+
|
|
432
623
|
---
|
|
433
624
|
|
|
434
625
|
## Tool Reference
|
package/wowok-machine/SKILL.md
CHANGED
|
@@ -36,6 +36,78 @@ Design, build, and operate automated workflow templates.
|
|
|
36
36
|
|
|
37
37
|
Machines are **immutable after `publish: true`**; Guards are **CREATE-only**. Design the complete workflow before publishing.
|
|
38
38
|
|
|
39
|
+
## Semantic Layer (Knowledge Modules)
|
|
40
|
+
|
|
41
|
+
The Machine knowledge system provides 8 TypeScript modules that encode the canonical design knowledge for Machine generation. These modules power the L4 Harness Plan Loop and are the **source of truth** for scene/template selection, pattern matching, risk evaluation, topology analysis, and the fail-closed publish gate.
|
|
42
|
+
|
|
43
|
+
> **Design reference**: [Machine Design Reference](../references/machine-design-reference.md) — covering architecture, core elements, puzzle model, translation patterns, risk rules, and publish flow. Verification notes (06 §14) are embedded in code as `MACHINE_VERIFICATION_NOTES`.
|
|
44
|
+
|
|
45
|
+
### Module API Reference
|
|
46
|
+
|
|
47
|
+
| Module | Entry Points | Purpose |
|
|
48
|
+
|--------|--------------|---------|
|
|
49
|
+
| `machine-ledger.ts` | `MACHINE_SCENES`, `inferSceneFromFlow(flow)`, `findScene(id)` | 10 industry scenes + keyword-based scene inference |
|
|
50
|
+
| `machine-templates.ts` | `MACHINE_TEMPLATES`, `getTemplateById(id)`, `fillTemplate(id, params)`, `forkTemplate(id, overrides)`, `walkDecisionTree(answers)` | 10 starter templates + parameter fill + Q1-Q9 decision tree |
|
|
51
|
+
| `machine-translation.ts` | `SEMANTIC_TO_MACHINE_RULES`, `MACHINE_CONSTRAINT_RULES`, `matchSemanticPattern(text)`, `identifyExecutionMode(threshold, fwdCount)`, `identifyTopology(pairs)`, `explainForwardPermission(fwd)` | 12 semantic patterns + 28 on-chain constraints (creation/structure/node_operation/publish/runtime) |
|
|
52
|
+
| `machine-topology.ts` | `analyzeTopology(nodes, pairs)`, `identifyTopologyPattern(topology)`, `formatTopologySummary(topology)`, `MAX_NODE_COUNT=200`, `MAX_NODE_PAIR_COUNT=40`, `MAX_FORWARD_COUNT=20` | DAG analysis: entry/terminal/orphaned/dead-branch/cycle, on-chain limit checks |
|
|
53
|
+
| `machine-risk.ts` | `MACHINE_RISK_RULES` (39 rules), `assessMachineRisks(machine, ctx)`, `getRiskRulesByCategory(cat)`, `getRiskSummary(assessment)` | 5 risk dimensions (R-M1 structural, R-M2 guard, R-M3 permission, R-M4 immutability, R-M5 environment) |
|
|
54
|
+
| `machine-puzzle.ts` | `initPuzzleFromIntent(intent)`, `initPuzzleFromTemplate(id)`, `checkPuzzleCompleteness(puzzle)`, `recommendNextStep(puzzle)`, `derivePuzzleFromMachineJson(json)`, `generateConfirmationText(puzzle)` | 8-dimension information model (A-H): business_flow, node_design, guard_acceptance, permission_model, threshold_weight, branch_topology, overall_objective, risk_assessment |
|
|
55
|
+
| `machine-confirm.ts` | `PUBLISH_CHECKLIST` (10 items C-01..C-10), `CONFIRMATION_QUESTIONS` (6 items Q1-Q6), `runStaticChecklist(machine)`, `integrateRiskAssessment(machine, ctx)`, `parseUserConfirmation(input)`, `verifyEnvironment(machine, ctx, isMainnet)`, `confirmPublish(machine, ctx, isMainnet, userInput)`, `progressiveCheck(machine, scope)`, `overrideBlockWithReason(result, reason)`, `generateFullConfirmationText(...)` | 4-layer fail-closed gate: checklist → risk → user → environment. **CRITICAL risks cannot be overridden.** |
|
|
56
|
+
| `machine-context.ts` | `injectMachineContext(intent, mode, options)`, `suggestWorkflow(intent)`, `buildPromptFromContext(bundle)`, `getMachineKnowledgeSnapshot()`, `getRelatedGuardScenes(sceneId)`, `getVerificationNotes(mode?)`, `CONTEXT_PRESETS.{newUserIntent, midDesignReview, prePublishFull, crossMachine, guardIntegration, allocationIntegration}` | Aggregator module. **8 injection modes** select curated subset of knowledge based on user task. Use this as the main entry point. |
|
|
57
|
+
|
|
58
|
+
### The 8 Context Injection Modes
|
|
59
|
+
|
|
60
|
+
The user's current task determines what context to surface (never dump everything):
|
|
61
|
+
|
|
62
|
+
| Mode | When to Use | What It Surfaces |
|
|
63
|
+
|------|-------------|------------------|
|
|
64
|
+
| `initial_design` | User just described intent | Matched scene + top 3 templates + initial puzzle |
|
|
65
|
+
| `mid_design_review` | User is mid-design | Missing puzzle dimensions + structure/node_op constraints |
|
|
66
|
+
| `pre_publish_check` | User about to publish | Full risk assessment + progressive checklist (R5 subset) + verification notes |
|
|
67
|
+
| `post_publish_runtime` | Machine already published | Runtime-only constraints + environment risks |
|
|
68
|
+
| `intent_match` | Lightweight intent inference | Top 2 templates + creation constraints (no verification notes) |
|
|
69
|
+
| `cross_machine` | Cross-Machine dependency design | P-M-CROSS-MACHINE pattern + structure/publish constraints |
|
|
70
|
+
| `guard_integration` | Deep-dive on Guard binding | Guard bridge to `guard-ledger.ts` + R-M2 risks |
|
|
71
|
+
| `allocation_integration` | Deep-dive on Allocator at terminals | P-M-ALLOCATION-INTEGRATED pattern + Allocator-related risks |
|
|
72
|
+
|
|
73
|
+
### Recommended Usage Pattern
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
// 1. First user message — lightweight workflow suggestion
|
|
77
|
+
const suggestion = suggestWorkflow(userIntent);
|
|
78
|
+
// suggestion.matched_scene, suggestion.suggested_templates, suggestion.initial_puzzle, suggestion.next_step
|
|
79
|
+
|
|
80
|
+
// 2. Mid-design — inject context to surface missing info
|
|
81
|
+
const bundle = injectMachineContext(intent, 'mid_design_review', { existing_puzzle: puzzle });
|
|
82
|
+
|
|
83
|
+
// 3. Pre-publish — full ConfirmGate
|
|
84
|
+
const gate = confirmPublish(machineJson, projectContext, isMainnet, userConfirmationInput);
|
|
85
|
+
if (gate.status !== 'approved') {
|
|
86
|
+
// STOP — do not call onchain_operations with publish: true
|
|
87
|
+
console.log(gate.block_reason);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 4. Or use the preset wrapper for common cases
|
|
91
|
+
const preset = CONTEXT_PRESETS.prePublishFull(intent, machineJson, projectContext);
|
|
92
|
+
const prompt = buildPromptFromContext(preset); // inject into AI prompt
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Verification Notes (06 §14)
|
|
96
|
+
|
|
97
|
+
Five topics were verified at the code level. These notes are embedded in `MACHINE_VERIFICATION_NOTES` and surfaced whenever the consumer's mode touches them:
|
|
98
|
+
|
|
99
|
+
| Topic | Judgment | Verified Semantic |
|
|
100
|
+
|-------|----------|-------------------|
|
|
101
|
+
| `bReplace` | YES | Acts at pairs-list level of an existing node (NOT whole-Machine). `false`=merge, `true`=replace that node's pairs list. |
|
|
102
|
+
| `um` | PARTIAL | Messenger Contact reference (off-chain metadata). Omitting has zero on-chain impact. |
|
|
103
|
+
| `consensus_repositories` | PARTIAL | Declarative-only field. Not consumed by on-chain flow. Hint for off-chain tooling. |
|
|
104
|
+
| `namedOperator_assignment` | PARTIAL | Move `progress::new` does NOT accept namedOperator. MCP/SDK translates to separate `namedOperator_add` tx (permission index 221). |
|
|
105
|
+
| `cross_machine_dependency` | PARTIAL | Indirect via `progress::new -> assert_published`. Use `convert_witness` TypeOrderProgress (100) / TypeOrderProgressSession (103). |
|
|
106
|
+
|
|
107
|
+
> **Test coverage**: 8 `.spec.ts` files covering machine-ledger, machine-templates, machine-translation, machine-topology, machine-risk, machine-puzzle, machine-confirm, and machine-context — over 400 tests, all passing.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
39
111
|
## Machine Architecture
|
|
40
112
|
|
|
41
113
|
```
|
package/wowok-order/APPENDIX.md
CHANGED
|
@@ -266,27 +266,27 @@ The structure populated by `customer_intelligence` service:
|
|
|
266
266
|
"risk_score": 72,
|
|
267
267
|
"risk_level": "medium_low",
|
|
268
268
|
"recommendations": [
|
|
269
|
-
"
|
|
270
|
-
"
|
|
269
|
+
"Require merchant to configure Arbitration service before ordering",
|
|
270
|
+
"Negotiate refund terms via Messenger"
|
|
271
271
|
],
|
|
272
272
|
"reminders": [
|
|
273
273
|
{
|
|
274
274
|
"id": "evaluate_high_risk",
|
|
275
275
|
"stage": "evaluate",
|
|
276
276
|
"priority": "required",
|
|
277
|
-
"message": "🔴
|
|
277
|
+
"message": "🔴 Comprehensive risk score 45/100, strongly recommend not purchasing"
|
|
278
278
|
},
|
|
279
279
|
{
|
|
280
280
|
"id": "evaluate_ambiguous_guard",
|
|
281
281
|
"stage": "evaluate",
|
|
282
282
|
"priority": "required",
|
|
283
|
-
"message": "🔴
|
|
283
|
+
"message": "🔴 Detected 2 ambiguous Guards, manual review required before proceeding"
|
|
284
284
|
}
|
|
285
285
|
],
|
|
286
286
|
"preference_match": {
|
|
287
287
|
"score": 78,
|
|
288
|
-
"matches": ["
|
|
289
|
-
"mismatches": ["
|
|
288
|
+
"matches": ["Price 10% below market average", "Has arbitration", "Has compensation fund"],
|
|
289
|
+
"mismatches": ["Delivery timeline exceeds expectations"]
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
}
|
|
@@ -299,32 +299,32 @@ The structure populated by `customer_intelligence` service:
|
|
|
299
299
|
When the user mentions an industry, load the corresponding preference template and risk checks:
|
|
300
300
|
|
|
301
301
|
**freelance** (free-agent services):
|
|
302
|
-
- Ask: "
|
|
302
|
+
- Ask: "Is WIP hash verification needed? Are milestone nodes configured?"
|
|
303
303
|
- Risk checks: WIP verified, milestone nodes, refund path, Messenger
|
|
304
304
|
- Preference template: 30-day cycle, 4h response, require arb + comp
|
|
305
305
|
|
|
306
306
|
**rental** (equipment/property rental):
|
|
307
|
-
- Ask: "
|
|
307
|
+
- Ask: "What is the lock duration? Does the compensation fund cover the order amount?"
|
|
308
308
|
- Risk checks: compensation full, lock duration safe, arbitration, user-operable
|
|
309
309
|
- Preference template: 7-day cycle, 8h response, conservative risk appetite
|
|
310
310
|
|
|
311
311
|
**education** (courses/coaching):
|
|
312
|
-
- Ask: "
|
|
312
|
+
- Ask: "The course cycle is long, can you accept 90-day delivery? Is the refund path clear?"
|
|
313
313
|
- Risk checks: refund path, compensation, arbitration, long-cycle tolerance
|
|
314
314
|
- Preference template: 90-day cycle, 24h response, conservative, flexible delivery
|
|
315
315
|
|
|
316
316
|
**travel** (travel/booking services):
|
|
317
|
-
- Ask: "
|
|
317
|
+
- Ask: "Urgent delivery, can the seller respond within 2 hours? Are milestone nodes complete?"
|
|
318
318
|
- Risk checks: urgent delivery, compensation full, refund path, Messenger
|
|
319
319
|
- Preference template: 14-day cycle, 2h response, conservative, urgent delivery
|
|
320
320
|
|
|
321
321
|
**subscription** (recurring services):
|
|
322
|
-
- Ask: "
|
|
322
|
+
- Ask: "Is there no lock-in? Is there a user-operable path?"
|
|
323
323
|
- Risk checks: no-lockin (no dead-end), refund path, user-operable, optional comp
|
|
324
324
|
- Preference template: 30-day cycle, 24h response, aggressive risk, basic after-sales
|
|
325
325
|
|
|
326
326
|
**retail** (physical goods):
|
|
327
|
-
- Ask: "WIP
|
|
327
|
+
- Ask: "Has WIP been verified? Does compensation cover the order? Is arbitration configured?"
|
|
328
328
|
- Risk checks: WIP verified, compensation full, refund path, arbitration
|
|
329
329
|
- Preference template: 7-day cycle, 8h response, balanced risk, full after-sales
|
|
330
330
|
|
|
@@ -394,14 +394,14 @@ After R9 (order creation), the post-purchase phase begins. Use `post-purchase.ts
|
|
|
394
394
|
```
|
|
395
395
|
User wants refund or refund Allocator fired:
|
|
396
396
|
├── refunded_amount vs order_amount?
|
|
397
|
-
│ ├── 100% refunded → "
|
|
398
|
-
│ ├── Partial refund → "
|
|
397
|
+
│ ├── 100% refunded → "Refund completed" (info)
|
|
398
|
+
│ ├── Partial refund → "Refund incomplete, shortfall X" (recommended)
|
|
399
399
|
│ │ └── Next step: query order state + contact merchant via Messenger
|
|
400
|
-
│ ├── 0 refund + user-initiated → "
|
|
400
|
+
│ ├── 0 refund + user-initiated → "Waiting for merchant refund" (recommended)
|
|
401
401
|
│ │ └── Next step: monitor via order_monitor service
|
|
402
|
-
│ ├── 0 refund + refund path exists → "
|
|
402
|
+
│ ├── 0 refund + refund path exists → "Refund can be triggered via Allocator" (recommended)
|
|
403
403
|
│ │ └── Next step: advance to refund node via order.progress
|
|
404
|
-
│ └── 0 refund + no refund path → "
|
|
404
|
+
│ └── 0 refund + no refund path → "No refund path, arbitration required" (required)
|
|
405
405
|
│ └── Next step: file arbitration dispute (see Phase 4)
|
|
406
406
|
```
|
|
407
407
|
|
|
@@ -410,14 +410,14 @@ User wants refund or refund Allocator fired:
|
|
|
410
410
|
```
|
|
411
411
|
User reports quality problem:
|
|
412
412
|
├── WIP hash comparison
|
|
413
|
-
│ ├── current_wip_hash != original_wip_hash → "WIP
|
|
413
|
+
│ ├── current_wip_hash != original_wip_hash → "WIP mismatch" (required)
|
|
414
414
|
│ │ └── Document: re-verify via wip_file, generate WTS evidence
|
|
415
|
-
│ └── wip_hash missing → "
|
|
415
|
+
│ └── wip_hash missing → "Request merchant to provide WIP hash verification" (recommended)
|
|
416
416
|
│
|
|
417
417
|
├── Evidence collection
|
|
418
|
-
│ ├── evidence empty → "
|
|
419
|
-
│ ├── evidence < 3 items → "
|
|
420
|
-
│ └── evidence ≥ 3 items → "
|
|
418
|
+
│ ├── evidence empty → "Collect evidence: screenshots, chat logs, delivery samples" (required)
|
|
419
|
+
│ ├── evidence < 3 items → "Add more evidence to strengthen arbitration case" (recommended)
|
|
420
|
+
│ └── evidence ≥ 3 items → "Evidence sufficient, consider filing arbitration" (info)
|
|
421
421
|
│
|
|
422
422
|
└── Next step: hand off to Phase 4 (arbitration support) if unresolved
|
|
423
423
|
```
|
|
@@ -427,12 +427,12 @@ User reports quality problem:
|
|
|
427
427
|
```
|
|
428
428
|
Seller not responding on Messenger:
|
|
429
429
|
├── Days since last reply?
|
|
430
|
-
│ ├── ≤ 3 days → "
|
|
431
|
-
│ ├── > 3 days → "
|
|
430
|
+
│ ├── ≤ 3 days → "Merchant may be busy, waiting for reply" (info)
|
|
431
|
+
│ ├── > 3 days → "Persistent non-response, send reminder message" (recommended)
|
|
432
432
|
│ │ └── Next step: send Messenger reminder + document stall
|
|
433
|
-
│ ├── > 7 days + has_arbitration → "
|
|
433
|
+
│ ├── > 7 days + has_arbitration → "Recommend filing arbitration" (required)
|
|
434
434
|
│ │ └── Next step: file arbitration dispute (see Phase 4)
|
|
435
|
-
│ └── > 7 days + no arbitration → "
|
|
435
|
+
│ └── > 7 days + no arbitration → "No arbitration channel, funds may be frozen" (required)
|
|
436
436
|
│ └── Next step: escalate to WoWok community / off-chain recourse
|
|
437
437
|
│
|
|
438
438
|
└── If order_monitor service is ON, these alerts fire automatically
|
|
@@ -443,19 +443,19 @@ Seller not responding on Messenger:
|
|
|
443
443
|
```
|
|
444
444
|
Filing arbitration dispute:
|
|
445
445
|
├── arbitration_initiated?
|
|
446
|
-
│ ├── NO → "
|
|
446
|
+
│ ├── NO → "Recommend filing arbitration application" (required)
|
|
447
447
|
│ │ └── Generate application template:
|
|
448
|
-
│ │ title: "
|
|
448
|
+
│ │ title: "Order {order_id} delivery dispute application"
|
|
449
449
|
│ │ description: template auto-filled from puzzle + evidence
|
|
450
|
-
│ │ evidence_required: [
|
|
450
|
+
│ │ evidence_required: [Chat logs, Delivery screenshots, WIP hash comparison]
|
|
451
451
|
│ │ claim: refund / compensation / specific performance
|
|
452
452
|
│ │
|
|
453
453
|
│ └── YES → check status
|
|
454
|
-
│ ├── arb_window_days ≤ 3 → "
|
|
454
|
+
│ ├── arb_window_days ≤ 3 → "Arbitration window closing soon" (required)
|
|
455
455
|
│ │ └── Next step: expedite evidence submission
|
|
456
|
-
│ ├── evidence empty → "
|
|
457
|
-
│ ├── evidence < 3 → "
|
|
458
|
-
│ └── evidence ≥ 3 → "
|
|
456
|
+
│ ├── evidence empty → "Submit evidence" (required)
|
|
457
|
+
│ ├── evidence < 3 → "Add more evidence to strengthen arbitration case" (recommended)
|
|
458
|
+
│ └── evidence ≥ 3 → "Evidence sufficient, waiting for arbitration result" (info)
|
|
459
459
|
│
|
|
460
460
|
└── Result interpretation guide:
|
|
461
461
|
├── State (3) Arbitrated → user can accept or object
|
package/wowok-provider/SKILL.md
CHANGED
|
@@ -163,20 +163,34 @@ STEP 5: Post-Publish (MODIFY Service — mutable after publish)
|
|
|
163
163
|
|
|
164
164
|
### Service Object Relationships
|
|
165
165
|
|
|
166
|
+
> **Authoritative source**: [Object Collaboration Diagram](../references/object-collaboration.md) §1 (22-object collaboration DAG, 83 relationships).
|
|
167
|
+
> This tree is a simplified view. Cross-reference the above for the full graph and [Object Boundary Conditions](../references/object-collaboration.md#boundary-conditions) for mutability rules.
|
|
168
|
+
|
|
166
169
|
```
|
|
167
170
|
Service (merchant storefront)
|
|
168
|
-
├──
|
|
169
|
-
├──
|
|
170
|
-
├──
|
|
171
|
-
├──
|
|
172
|
-
├──
|
|
173
|
-
├──
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
171
|
+
├── permission → Permission (required, mutable after publish)
|
|
172
|
+
├── machine → Machine (required, IMMUTABLE after publish)
|
|
173
|
+
├── order_allocators → Allocation[] (optional, mutable after publish)
|
|
174
|
+
├── arbitrations → Arbitration[] (optional, mutable after publish, max 20)
|
|
175
|
+
├── compensation_fund → Treasury (optional, mutable after publish)
|
|
176
|
+
├── sales → Repository (optional, mutable after publish; products with WIP files)
|
|
177
|
+
├── rewards → Reward[] (optional, mutable after publish)
|
|
178
|
+
├── um → Contact (optional, mutable after publish; customer service)
|
|
179
|
+
├── customer_required → Personal (optional, mutable after publish; customer data schema)
|
|
180
|
+
└── buy_guard → Guard (optional, mutable after publish; gates order placement)
|
|
181
|
+
|
|
182
|
+
Order (per purchase, runtime-created)
|
|
183
|
+
├── builder → Customer (immutable after creation)
|
|
184
|
+
├── service → Service snapshot (immutable after creation)
|
|
185
|
+
├── machine → Machine (immutable after creation)
|
|
186
|
+
├── progress → Progress (immutable after binding)
|
|
187
|
+
├── arbitration → Arbitration (optional, immutable once set)
|
|
188
|
+
└── allocation → Fund distribution engine (triggered via Progress.forward)
|
|
189
|
+
|
|
190
|
+
Cross-object references (see [Object Collaboration Diagram §6](../references/object-collaboration.md#guard-and-machine-global-usage) for Guard/Machine global usage):
|
|
191
|
+
- Guard is referenced by 9 object types (Service.buy_guard, Machine.forward.guard, Allocation.allocation_guard, Arbitration.voting_guard, Reward.claim_guard, Repository.write_guard, Treasury.external_guard, Demand.recommend_guard, Passport.guard)
|
|
192
|
+
- Machine is referenced by 4 object types (Service.machine, Order.machine, Progress.machine, Order snapshot)
|
|
193
|
+
- Permission is the central hub — 11 objects hold BuiltinPermissionIndex (see [Object Collaboration Diagram §5](../references/object-collaboration.md#permission-reverse-reference-table) for reverse-reference table)
|
|
180
194
|
```
|
|
181
195
|
|
|
182
196
|
### Allocators + Machine Integration
|
package/wowok-scenario/SKILL.md
CHANGED
|
@@ -31,6 +31,16 @@ when_to_use:
|
|
|
31
31
|
|
|
32
32
|
A **driving mode** is a curated bundle of: industry traits, default Permission indexes, default Machine node graph, default Guard templates, default Allocator strategy, a 10-round build script, an audit checklist, and a failure playbook. Modes are **presets, not constraints** — every underlying MCP operation remains available. Users can override any default or switch to `general` (free) mode at any time.
|
|
33
33
|
|
|
34
|
+
> **Authoritative cross-reference**: This skill's mode definitions are aligned with the following internal references:
|
|
35
|
+
> - [Guard Template Library](../references/guard-template-library.md) — Guard templates referenced by mode `Guards` column
|
|
36
|
+
> - [Machine Template Library](../references/machine-template-library.md) — Machine shapes referenced by mode `Machine Shape` column
|
|
37
|
+
> - [Machine Scenario Ledger](../references/machine-scenario-ledger.md) — 10 business scenarios per mode
|
|
38
|
+
> - [Guard Scenario Ledger](../references/guard-scenario-ledger.md) — Guard usage scenarios per mode
|
|
39
|
+
> - [Merchant Scenario Coordination §5](../references/merchant-scenario-coordination.md) — 6 industry modes × merchant perspective
|
|
40
|
+
> - [On-chain Constants](../references/onchain-constants.md) — Permission index ranges and capacity limits
|
|
41
|
+
>
|
|
42
|
+
> When a mode's defaults disagree with these references, the **design references** in this directory are authoritative (P15 decision: bidirectional cross-reference, with design references as single source of truth for object semantics).
|
|
43
|
+
|
|
34
44
|
### What Driving Modes Solve
|
|
35
45
|
|
|
36
46
|
The "object_type wall" — new users do not know which Machine topology, which Guards, which Allocator strategy fits their industry. Modes pre-answer these questions using best practices distilled from real usage (and refined by Loop Engineering over time).
|
package/wowok-tools/SKILL.md
CHANGED
|
@@ -266,8 +266,8 @@ When explaining a specific technique to users, reference where it appears:
|
|
|
266
266
|
|
|
267
267
|
| Trap | Fix |
|
|
268
268
|
|------|-----|
|
|
269
|
-
| **Transaction fails, gas error** | → [Pre-Flight: Gas & Faucet](
|
|
270
|
-
| **Don't know how to build a service** | → [Examples Reference](#examples-reference
|
|
269
|
+
| **Transaction fails, gas error** | → [Pre-Flight: Gas & Faucet](#pre-flight-gas--faucet). AI should auto-check balance + faucet. |
|
|
270
|
+
| **Don't know how to build a service** | → [Examples Reference](#examples-reference). Match user intent → example, extract JSON templates. |
|
|
271
271
|
| `gen_passport` called as standalone tool | It's not — use `onchain_operations` with `operation_type: "gen_passport"` |
|
|
272
272
|
| Missing `data` wrapper | Only `gen_passport` omits it; `payment`/`personal` omit `submission` |
|
|
273
273
|
| String `object` passed expecting CREATE | String = existing (MODIFY), Object = new (CREATE) → [safety §1.1](../wowok-safety/SKILL.md) |
|