@motebit/protocol 1.3.0 → 2.0.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/README.md +4 -2
- package/dist/artifact-type.d.ts +32 -6
- package/dist/artifact-type.d.ts.map +1 -1
- package/dist/artifact-type.js +10 -0
- package/dist/artifact-type.js.map +1 -1
- package/dist/event-type.d.ts +62 -0
- package/dist/event-type.d.ts.map +1 -0
- package/dist/event-type.js +123 -0
- package/dist/event-type.js.map +1 -0
- package/dist/index.d.ts +107 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/dist/memory-events.d.ts +13 -0
- package/dist/memory-events.d.ts.map +1 -1
- package/dist/perception.d.ts +41 -2
- package/dist/perception.d.ts.map +1 -1
- package/dist/routing.d.ts +266 -0
- package/dist/routing.d.ts.map +1 -0
- package/dist/routing.js +88 -0
- package/dist/routing.js.map +1 -0
- package/dist/sensitivity.d.ts +50 -0
- package/dist/sensitivity.d.ts.map +1 -1
- package/dist/sensitivity.js +57 -0
- package/dist/sensitivity.js.map +1 -1
- package/dist/settlement-asset.d.ts +92 -0
- package/dist/settlement-asset.d.ts.map +1 -0
- package/dist/settlement-asset.js +82 -0
- package/dist/settlement-asset.js.map +1 -0
- package/dist/settlement-mode.d.ts +144 -13
- package/dist/settlement-mode.d.ts.map +1 -1
- package/dist/settlement-mode.js +45 -1
- package/dist/settlement-mode.js.map +1 -1
- package/dist/trust-algebra.d.ts +1 -1
- package/dist/trust-algebra.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settlement-asset types — the closed vocabulary of stablecoin assets
|
|
3
|
+
* the protocol clears settlement in.
|
|
4
|
+
*
|
|
5
|
+
* Permissive floor (Apache-2.0). Layer 0. Sub-phase A of the
|
|
6
|
+
* asset-pluggability commitment named in
|
|
7
|
+
* [`docs/doctrine/off-ramp-as-user-action.md`](../../../docs/doctrine/off-ramp-as-user-action.md)
|
|
8
|
+
* § "Asset pluggability":
|
|
9
|
+
*
|
|
10
|
+
* > "settlement is asset-pluggable. USDC is the bootstrap stablecoin.
|
|
11
|
+
* > A `SettlementAsset` closed union (`"USDC"` only at land) with a
|
|
12
|
+
* > bespoke coverage test should ship as sub-phase A of this arc — a
|
|
13
|
+
* > typed vocabulary consumers can reference, promoted to the 8th
|
|
14
|
+
* > registered registry per `registry-pattern-canonical.md` when a
|
|
15
|
+
* > second asset (PYUSD, USDP, etc.) arrives as a real consumer
|
|
16
|
+
* > (sub-phase B)."
|
|
17
|
+
*
|
|
18
|
+
* Sub-phase A intentionally stops short of the full eight-artifact
|
|
19
|
+
* registered-registry set: the per-registry coverage gate, perturbation
|
|
20
|
+
* probe, drift-defenses inventory entry, and `REGISTERED_REGISTRIES`
|
|
21
|
+
* append are deferred until a second asset materializes as a real
|
|
22
|
+
* consumer. With a single literal there is no cross-implementation
|
|
23
|
+
* drift surface to defend against yet; the four criteria in
|
|
24
|
+
* [`docs/doctrine/registry-pattern-canonical.md`](../../../docs/doctrine/registry-pattern-canonical.md)
|
|
25
|
+
* § "When to add a registry to `REGISTERED_REGISTRIES`" require "real
|
|
26
|
+
* or anticipated drift," which this sub-phase does not meet. What it
|
|
27
|
+
* does meet: interop law (the field is signed on `SovereignRail` and
|
|
28
|
+
* read by independent verifiers), multi-consumer (rail + relay book-
|
|
29
|
+
* keeping + agent discovery), wire-format presence (`SovereignRail.asset`
|
|
30
|
+
* is the protocol-shaped boundary). Three of four criteria → bespoke
|
|
31
|
+
* coverage; the fourth criterion gates the registry promotion.
|
|
32
|
+
*
|
|
33
|
+
* **The registry membership IS the protocol-vs-product wall** (per the
|
|
34
|
+
* off-ramp doctrine memo's "asset-pluggability" section): if `"MOTE"`
|
|
35
|
+
* is ever added to `ALL_SETTLEMENT_ASSETS`, it's protocol; if it
|
|
36
|
+
* isn't, it's a motebit-cloud product overlay that converts to/from a
|
|
37
|
+
* protocol-level asset at its boundaries. A future MOTE stablecoin is
|
|
38
|
+
* **not** an architectural endpoint — it's a candidate motebit-cloud
|
|
39
|
+
* convenience product, evaluated against asset-pluggability when its
|
|
40
|
+
* compliance, market, and economic case can stand on its own
|
|
41
|
+
* (deferred per the `feedback_no_mote_stablecoin` memory).
|
|
42
|
+
*
|
|
43
|
+
* Semantic note — `SettlementAsset` is distinct from "currency".
|
|
44
|
+
* `BatchWithdrawalItem.currency`, `DepositResult.currency`,
|
|
45
|
+
* `WithdrawalResult.currency`, `CapabilityPrice.currency`, and
|
|
46
|
+
* `BudgetAllocation.currency` retain `string` typing because they
|
|
47
|
+
* mix fiat ("USD" via Stripe) and stablecoin ("USDC" via x402) across
|
|
48
|
+
* guest-rail kinds. Only fields whose semantic is unambiguously a
|
|
49
|
+
* settlement asset — `SovereignRail.asset` is the canonical site —
|
|
50
|
+
* tighten to this closed union. The fiat/stablecoin distinction lives
|
|
51
|
+
* at the rail-kind boundary, not in this vocabulary.
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* Canonical iteration order over `SettlementAsset`, frozen. The single
|
|
55
|
+
* source of truth for "every settlement asset" — exhaustive switches,
|
|
56
|
+
* bookkeeping enumerations, and the future per-registry coverage gate
|
|
57
|
+
* (sub-phase B) enumerate through this array.
|
|
58
|
+
*
|
|
59
|
+
* Same shape as `ALL_SUITE_IDS`, `ALL_TOKEN_AUDIENCES`,
|
|
60
|
+
* `ALL_CONTENT_ARTIFACT_TYPES`, `ALL_TASK_SHAPES`,
|
|
61
|
+
* `ALL_SENSITIVITY_LEVELS`, `ALL_EVENT_TYPES`, `ALL_SETTLEMENT_MODES`.
|
|
62
|
+
* The array shape is established before the registry is registered so
|
|
63
|
+
* that the sub-phase B promotion is a one-line `REGISTERED_REGISTRIES`
|
|
64
|
+
* append, not a refactor.
|
|
65
|
+
*/
|
|
66
|
+
export const ALL_SETTLEMENT_ASSETS = Object.freeze([
|
|
67
|
+
"USDC",
|
|
68
|
+
]);
|
|
69
|
+
/**
|
|
70
|
+
* Type guard — narrows `unknown` to `SettlementAsset`. Consumers that
|
|
71
|
+
* derive settlement-asset values from external sources (peer rail
|
|
72
|
+
* announcements, signed `SovereignRail` declarations, discovery
|
|
73
|
+
* responses) call this before dispatching so an unchecked cast is a
|
|
74
|
+
* fail-open path the type system can't catch.
|
|
75
|
+
*
|
|
76
|
+
* Same shape as `isSuiteId`, `isTokenAudience`, `isContentArtifactType`,
|
|
77
|
+
* `isTaskShape`, `isSensitivityLevel`, `isEventType`, `isSettlementMode`.
|
|
78
|
+
*/
|
|
79
|
+
export function isSettlementAsset(value) {
|
|
80
|
+
return typeof value === "string" && ALL_SETTLEMENT_ASSETS.includes(value);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=settlement-asset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlement-asset.js","sourceRoot":"","sources":["../src/settlement-asset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAmBH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA+B,MAAM,CAAC,MAAM,CAAC;IAC7E,MAAM;CACc,CAAC,CAAC;AAExB;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,qBAA2C,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -7,8 +7,102 @@
|
|
|
7
7
|
/** How money moves for a task: through the relay's virtual accounts, or directly onchain. */
|
|
8
8
|
export type SettlementMode = "relay" | "p2p";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* The narrow subset of `SettlementMode` that the relay is permitted to
|
|
11
|
+
* write for **new** worker-settlement rows after Arc 3 of the off-ramp
|
|
12
|
+
* arc. Reads accept the full `SettlementMode` union (legacy `"relay"`
|
|
13
|
+
* rows must remain readable for audit, verifier, and federation
|
|
14
|
+
* compat); writes are structurally restricted to `"p2p"`.
|
|
15
|
+
*
|
|
16
|
+
* This is the asymmetric-typing enforcement shape from
|
|
17
|
+
* [`architecture_disjointness_by_construction`](../../../../.claude/projects/-Users-daniel-src-motebit/memory/architecture_disjointness_by_construction.md)
|
|
18
|
+
* — the surface stays open for reads but closed for writes; legacy
|
|
19
|
+
* data remains verifiable but no new code can re-introduce the
|
|
20
|
+
* relay-custody worker-settlement path. The doctrine: *the relay does
|
|
21
|
+
* not accept delegator-paid funds on behalf of a worker*. The type:
|
|
22
|
+
* `WritableSettlementMode = Extract<SettlementMode, "p2p">`. The
|
|
23
|
+
* structural enforcement: a compile error at every site that tries to
|
|
24
|
+
* write `"relay"` for a worker settlement.
|
|
25
|
+
*
|
|
26
|
+
* Composes with the prior arcs' Layer 1 enforcement shapes:
|
|
27
|
+
* - Surface deletion (`BridgeSettlementRail.withdraw`) — Arc 1
|
|
28
|
+
* - Marker interface (`WithdrawableGuestRail`) — Arc 1
|
|
29
|
+
* - Asymmetric typing (this) — Arc 3
|
|
30
|
+
*
|
|
31
|
+
* Doctrine: [`docs/doctrine/off-ramp-as-user-action.md`](../../../docs/doctrine/off-ramp-as-user-action.md) § "Arc 3 close".
|
|
32
|
+
*/
|
|
33
|
+
export type WritableSettlementMode = Extract<SettlementMode, "p2p">;
|
|
34
|
+
/**
|
|
35
|
+
* Canonical iteration order over `SettlementMode`, frozen. The single
|
|
36
|
+
* source of truth for "every settlement mode" — drift gates, exhaustive
|
|
37
|
+
* switches, settlement-eligibility evaluators, and the protocol's
|
|
38
|
+
* registry-coverage gate (`check-settlement-mode-canonical`) all
|
|
39
|
+
* enumerate through this array.
|
|
40
|
+
*
|
|
41
|
+
* Promoted to a registered registry per
|
|
42
|
+
* [`docs/doctrine/registry-pattern-canonical.md`](../../../docs/doctrine/registry-pattern-canonical.md)
|
|
43
|
+
* on 2026-05-15 — the seventh instance after `SuiteId`, `TokenAudience`,
|
|
44
|
+
* `ContentArtifactType`, `TaskShape`, `SensitivityLevel`, and
|
|
45
|
+
* `EventType`. The four criteria are met: interop law (cross-
|
|
46
|
+
* implementation agreement required for settlement to clear), multi-
|
|
47
|
+
* consumer (relay, agents, discovery, settlement-rails, eligibility
|
|
48
|
+
* evaluator), wire-format presence (`SettlementEligibility.mode`,
|
|
49
|
+
* `AgentDiscovery.settlement_modes[]`), anticipated drift (the closed
|
|
50
|
+
* union will grow when a third mode lands — escrow / hybrid / batched —
|
|
51
|
+
* and silently breaking peers without the structural lock would
|
|
52
|
+
* fail interoperability).
|
|
53
|
+
*
|
|
54
|
+
* Same shape as `ALL_SUITE_IDS`, `ALL_TOKEN_AUDIENCES`,
|
|
55
|
+
* `ALL_CONTENT_ARTIFACT_TYPES`, `ALL_TASK_SHAPES`,
|
|
56
|
+
* `ALL_SENSITIVITY_LEVELS`, `ALL_EVENT_TYPES`. Adding a settlement
|
|
57
|
+
* mode is intentional protocol-level work: new union entry + new
|
|
58
|
+
* entry here + gate reference update + spec update if wire-format-
|
|
59
|
+
* relevant.
|
|
60
|
+
*/
|
|
61
|
+
export declare const ALL_SETTLEMENT_MODES: readonly SettlementMode[];
|
|
62
|
+
/**
|
|
63
|
+
* Type guard — narrows `unknown` to `SettlementMode`. Consumers that
|
|
64
|
+
* derive settlement-mode values from external sources (peer
|
|
65
|
+
* negotiation, discovery responses, relay routing decisions) call
|
|
66
|
+
* this before dispatching so an unchecked cast is a fail-open path
|
|
67
|
+
* the type system can't catch.
|
|
68
|
+
*
|
|
69
|
+
* Same shape as `isSuiteId`, `isTokenAudience`,
|
|
70
|
+
* `isContentArtifactType`, `isTaskShape`, `isSensitivityLevel`,
|
|
71
|
+
* `isEventType`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function isSettlementMode(value: unknown): value is SettlementMode;
|
|
74
|
+
/**
|
|
75
|
+
* Proof of direct onchain payment for a P2P-settled task. After Arc 2
|
|
76
|
+
* of the off-ramp arc, the delegator's single signed Solana
|
|
77
|
+
* transaction composes TWO atomic SPL Transfer instructions:
|
|
78
|
+
*
|
|
79
|
+
* 1. **Worker leg** — delegator → worker, amount = `amount_micro`
|
|
80
|
+
* (the worker's listing unit_cost, what they earn net).
|
|
81
|
+
* 2. **Fee leg** — delegator → relay treasury, amount =
|
|
82
|
+
* `fee_amount_micro` (the platform fee, derived from the gross
|
|
83
|
+
* via `platform_fee_rate`).
|
|
84
|
+
*
|
|
85
|
+
* Both legs land atomically (either the whole tx succeeds or it
|
|
86
|
+
* doesn't); the `p2p-verifier` walks the on-chain `transfers[]` to
|
|
87
|
+
* confirm both legs match the declared addresses + amounts. The relay
|
|
88
|
+
* treasury address is the relay's identity-derived Solana wallet
|
|
89
|
+
* (`deriveSolanaAddress(relay.publicKey)`) — same address that funds
|
|
90
|
+
* `SolanaMemoSubmitter` for anchoring and that `OperatorSolanaTransfer`
|
|
91
|
+
* uses for Path 0 withdrawals. Delegators discover it via the published
|
|
92
|
+
* relay public key on `/.well-known/motebit.json` or
|
|
93
|
+
* `/.well-known/motebit-transparency.json`.
|
|
94
|
+
*
|
|
95
|
+
* Doctrine: `docs/doctrine/off-ramp-as-user-action.md` — Arc 2 closes
|
|
96
|
+
* the sibling-doc contradiction between the top-level `CLAUDE.md`
|
|
97
|
+
* Economic Loop "5% applies through both lanes" claim and
|
|
98
|
+
* `services/relay/CLAUDE.md` rule 8's pre-Arc-2 "Fee: zero on P2P"
|
|
99
|
+
* policy. The fee is now structurally present on every P2P settlement
|
|
100
|
+
* as a direct delegator→treasury leg.
|
|
101
|
+
*
|
|
102
|
+
* **Breaking change from pre-Arc-2 P2pPaymentProof shape**: the new
|
|
103
|
+
* `fee_to_address` + `fee_amount_micro` fields are required. The
|
|
104
|
+
* worker-leg fields (`to_address`, `amount_micro`) keep their existing
|
|
105
|
+
* semantics — they describe only the worker leg, not the gross.
|
|
12
106
|
*/
|
|
13
107
|
export interface P2pPaymentProof {
|
|
14
108
|
/** Onchain transaction signature (Solana base58, 87-88 chars). */
|
|
@@ -19,8 +113,27 @@ export interface P2pPaymentProof {
|
|
|
19
113
|
network: string;
|
|
20
114
|
/** Worker's declared settlement address (base58 for Solana). */
|
|
21
115
|
to_address: string;
|
|
22
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Worker leg amount in micro-units (USDC 6 decimals). Equals the
|
|
118
|
+
* worker's listing unit_cost — what the worker earns net.
|
|
119
|
+
*/
|
|
23
120
|
amount_micro: number;
|
|
121
|
+
/**
|
|
122
|
+
* Relay treasury Solana address (base58). Derivable from the relay's
|
|
123
|
+
* published Ed25519 public key via `deriveSolanaAddress(publicKey)`
|
|
124
|
+
* (see `@motebit/wallet-solana`). Delegators MUST fetch the relay's
|
|
125
|
+
* public key from a verified source (transparency declaration or
|
|
126
|
+
* pinned config) — passing a wrong address sends the fee leg to a
|
|
127
|
+
* non-relay address and verification fails-closed.
|
|
128
|
+
*/
|
|
129
|
+
fee_to_address: string;
|
|
130
|
+
/**
|
|
131
|
+
* Fee leg amount in micro-units. The platform fee, computed as
|
|
132
|
+
* `gross - amount_micro` where `gross = amount_micro / (1 - platformFeeRate)`.
|
|
133
|
+
* The verifier validates this matches the relay's recorded
|
|
134
|
+
* `platform_fee_rate` against the declared `amount_micro`.
|
|
135
|
+
*/
|
|
136
|
+
fee_amount_micro: number;
|
|
24
137
|
}
|
|
25
138
|
/** Verification status of an onchain payment proof. */
|
|
26
139
|
export type PaymentVerificationStatus = "pending" | "verified" | "failed";
|
|
@@ -52,17 +165,35 @@ export interface SolvencyProof {
|
|
|
52
165
|
signature: string;
|
|
53
166
|
}
|
|
54
167
|
/**
|
|
55
|
-
* Result of policy-based settlement
|
|
168
|
+
* Result of policy-based settlement-eligibility evaluation. After Arc 3
|
|
169
|
+
* of the off-ramp arc, the eligibility check no longer routes between
|
|
170
|
+
* relay-custody and P2P — P2P is the only worker-settlement path. The
|
|
171
|
+
* gate now answers a binary question: "can this delegator-worker pair
|
|
172
|
+
* transact at all?"
|
|
173
|
+
*
|
|
174
|
+
* Disjunctive eligibility per [`docs/doctrine/off-ramp-as-user-action.md`](../../../docs/doctrine/off-ramp-as-user-action.md):
|
|
175
|
+
* - **Established-pair branch**: trust ≥ 0.6 AND interactions ≥ 5
|
|
176
|
+
* AND no_active_disputes AND worker_has_settlement_address.
|
|
177
|
+
* - **New-pair branch**: `delegator_acknowledges_no_history_risk`
|
|
178
|
+
* AND no_active_disputes AND worker_not_blocked AND
|
|
179
|
+
* worker_has_settlement_address.
|
|
180
|
+
*
|
|
181
|
+
* The disjunctive type encodes "allowed implies p2p" structurally —
|
|
182
|
+
* the `mode` field uses `WritableSettlementMode` so consumers that
|
|
183
|
+
* destructure `{ mode }` on an allowed result get the narrow type;
|
|
184
|
+
* the disallowed case has no `mode` field because there's no
|
|
185
|
+
* fallback rail to route to.
|
|
56
186
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
187
|
+
* Composes with [[trust_as_economic_membrane]] — the established-pair
|
|
188
|
+
* branch is the trust-as-fast-path; the new-pair branch is the
|
|
189
|
+
* cold-start unlock with explicit consent.
|
|
59
190
|
*/
|
|
60
|
-
export
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/** Selected settlement mode. */
|
|
64
|
-
mode: SettlementMode;
|
|
65
|
-
/** Human-readable reason for the decision. */
|
|
191
|
+
export type SettlementEligibility = {
|
|
192
|
+
allowed: true;
|
|
193
|
+
mode: WritableSettlementMode;
|
|
66
194
|
reason: string;
|
|
67
|
-
}
|
|
195
|
+
} | {
|
|
196
|
+
allowed: false;
|
|
197
|
+
reason: string;
|
|
198
|
+
};
|
|
68
199
|
//# sourceMappingURL=settlement-mode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settlement-mode.d.ts","sourceRoot":"","sources":["../src/settlement-mode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,6FAA6F;AAC7F,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"settlement-mode.d.ts","sourceRoot":"","sources":["../src/settlement-mode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,6FAA6F;AAC7F,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,KAAK,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,cAAc,EAGpC,CAAC;AAEvB;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAID,uDAAuD;AACvD,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAI1E;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,4CAA4C;IAC5C,gBAAgB,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,UAAU,EAAE,OAAO,CAAC;IACpB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;CACnB;AAID;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,sBAAsB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC/D;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/settlement-mode.js
CHANGED
|
@@ -4,5 +4,49 @@
|
|
|
4
4
|
* Permissive floor (Apache-2.0): these types define the interoperable format
|
|
5
5
|
* for settlement mode selection and payment proof verification.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Canonical iteration order over `SettlementMode`, frozen. The single
|
|
9
|
+
* source of truth for "every settlement mode" — drift gates, exhaustive
|
|
10
|
+
* switches, settlement-eligibility evaluators, and the protocol's
|
|
11
|
+
* registry-coverage gate (`check-settlement-mode-canonical`) all
|
|
12
|
+
* enumerate through this array.
|
|
13
|
+
*
|
|
14
|
+
* Promoted to a registered registry per
|
|
15
|
+
* [`docs/doctrine/registry-pattern-canonical.md`](../../../docs/doctrine/registry-pattern-canonical.md)
|
|
16
|
+
* on 2026-05-15 — the seventh instance after `SuiteId`, `TokenAudience`,
|
|
17
|
+
* `ContentArtifactType`, `TaskShape`, `SensitivityLevel`, and
|
|
18
|
+
* `EventType`. The four criteria are met: interop law (cross-
|
|
19
|
+
* implementation agreement required for settlement to clear), multi-
|
|
20
|
+
* consumer (relay, agents, discovery, settlement-rails, eligibility
|
|
21
|
+
* evaluator), wire-format presence (`SettlementEligibility.mode`,
|
|
22
|
+
* `AgentDiscovery.settlement_modes[]`), anticipated drift (the closed
|
|
23
|
+
* union will grow when a third mode lands — escrow / hybrid / batched —
|
|
24
|
+
* and silently breaking peers without the structural lock would
|
|
25
|
+
* fail interoperability).
|
|
26
|
+
*
|
|
27
|
+
* Same shape as `ALL_SUITE_IDS`, `ALL_TOKEN_AUDIENCES`,
|
|
28
|
+
* `ALL_CONTENT_ARTIFACT_TYPES`, `ALL_TASK_SHAPES`,
|
|
29
|
+
* `ALL_SENSITIVITY_LEVELS`, `ALL_EVENT_TYPES`. Adding a settlement
|
|
30
|
+
* mode is intentional protocol-level work: new union entry + new
|
|
31
|
+
* entry here + gate reference update + spec update if wire-format-
|
|
32
|
+
* relevant.
|
|
33
|
+
*/
|
|
34
|
+
export const ALL_SETTLEMENT_MODES = Object.freeze([
|
|
35
|
+
"relay",
|
|
36
|
+
"p2p",
|
|
37
|
+
]);
|
|
38
|
+
/**
|
|
39
|
+
* Type guard — narrows `unknown` to `SettlementMode`. Consumers that
|
|
40
|
+
* derive settlement-mode values from external sources (peer
|
|
41
|
+
* negotiation, discovery responses, relay routing decisions) call
|
|
42
|
+
* this before dispatching so an unchecked cast is a fail-open path
|
|
43
|
+
* the type system can't catch.
|
|
44
|
+
*
|
|
45
|
+
* Same shape as `isSuiteId`, `isTokenAudience`,
|
|
46
|
+
* `isContentArtifactType`, `isTaskShape`, `isSensitivityLevel`,
|
|
47
|
+
* `isEventType`.
|
|
48
|
+
*/
|
|
49
|
+
export function isSettlementMode(value) {
|
|
50
|
+
return typeof value === "string" && ALL_SETTLEMENT_MODES.includes(value);
|
|
51
|
+
}
|
|
8
52
|
//# sourceMappingURL=settlement-mode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settlement-mode.js","sourceRoot":"","sources":["../src/settlement-mode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
1
|
+
{"version":3,"file":"settlement-mode.js","sourceRoot":"","sources":["../src/settlement-mode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiCH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA8B,MAAM,CAAC,MAAM,CAAC;IAC3E,OAAO;IACP,KAAK;CACc,CAAC,CAAC;AAEvB;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,oBAA0C,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAClG,CAAC"}
|
package/dist/trust-algebra.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare function composeTrustChain(scores: number[]): number;
|
|
|
32
32
|
export declare function joinParallelRoutes(scores: number[]): number;
|
|
33
33
|
export declare const REFERENCE_TRUST_THRESHOLDS: TrustTransitionThresholds;
|
|
34
34
|
/**
|
|
35
|
-
* @deprecated since 1.0.1, removed in
|
|
35
|
+
* @deprecated since 1.0.1, removed in 3.0.0. Use {@link REFERENCE_TRUST_THRESHOLDS} instead.
|
|
36
36
|
*
|
|
37
37
|
* Reason: the `DEFAULT_` prefix read as "THE value every motebit
|
|
38
38
|
* implementation uses," but trust-transition thresholds are motebit
|
package/dist/trust-algebra.js
CHANGED
|
@@ -71,7 +71,7 @@ export const REFERENCE_TRUST_THRESHOLDS = {
|
|
|
71
71
|
demote_minTasks: 3,
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
74
|
-
* @deprecated since 1.0.1, removed in
|
|
74
|
+
* @deprecated since 1.0.1, removed in 3.0.0. Use {@link REFERENCE_TRUST_THRESHOLDS} instead.
|
|
75
75
|
*
|
|
76
76
|
* Reason: the `DEFAULT_` prefix read as "THE value every motebit
|
|
77
77
|
* implementation uses," but trust-transition thresholds are motebit
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motebit/protocol",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Motebit protocol — identity, receipts, credentials, delegation, settlement, and trust algebra for sovereign AI agents. Types, semirings, routing primitives. Apache-2.0, zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|