@motebit/protocol 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/artifact-type.d.ts +144 -0
- package/dist/artifact-type.d.ts.map +1 -0
- package/dist/artifact-type.js +107 -0
- package/dist/artifact-type.js.map +1 -0
- package/dist/audience.d.ts +108 -0
- package/dist/audience.d.ts.map +1 -0
- package/dist/audience.js +104 -0
- package/dist/audience.js.map +1 -0
- package/dist/co-browse.d.ts +369 -0
- package/dist/co-browse.d.ts.map +1 -0
- package/dist/co-browse.js +64 -0
- package/dist/co-browse.js.map +1 -0
- package/dist/computer-use.d.ts +463 -3
- package/dist/computer-use.d.ts.map +1 -1
- package/dist/computer-use.js +40 -0
- package/dist/computer-use.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 +257 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +84 -1
- 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/money.d.ts +33 -0
- package/dist/money.d.ts.map +1 -0
- package/dist/money.js +41 -0
- package/dist/money.js.map +1 -0
- package/dist/perception.d.ts +347 -0
- package/dist/perception.d.ts.map +1 -0
- package/dist/perception.js +9 -0
- package/dist/perception.js.map +1 -0
- package/dist/retention-policy.d.ts +8 -1
- package/dist/retention-policy.d.ts.map +1 -1
- package/dist/retention-policy.js +18 -0
- package/dist/retention-policy.js.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 +123 -0
- package/dist/sensitivity.d.ts.map +1 -0
- package/dist/sensitivity.js +154 -0
- package/dist/sensitivity.js.map +1 -0
- 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/transparency.d.ts +116 -0
- package/dist/transparency.d.ts.map +1 -0
- package/dist/transparency.js +67 -0
- package/dist/transparency.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
* The closed set of stablecoin assets the protocol clears settlement in.
|
|
55
|
+
*
|
|
56
|
+
* Single member at land — USDC is the bootstrap stablecoin. Additions
|
|
57
|
+
* are intentional protocol-level work (sub-phase B): new union member +
|
|
58
|
+
* `ALL_SETTLEMENT_ASSETS` entry + sibling-rail support + registry-
|
|
59
|
+
* pattern-canonical promotion to the 8th registered registry.
|
|
60
|
+
*
|
|
61
|
+
* Why a closed union, not `string`: a third-party motebit implementation
|
|
62
|
+
* receiving a `SovereignRail.asset` value of `"USDT"` or `"DAI"` from a
|
|
63
|
+
* peer should fail-closed (unknown asset) rather than silently continue.
|
|
64
|
+
* The vocabulary IS the interop boundary.
|
|
65
|
+
*/
|
|
66
|
+
export type SettlementAsset = "USDC";
|
|
67
|
+
/**
|
|
68
|
+
* Canonical iteration order over `SettlementAsset`, frozen. The single
|
|
69
|
+
* source of truth for "every settlement asset" — exhaustive switches,
|
|
70
|
+
* bookkeeping enumerations, and the future per-registry coverage gate
|
|
71
|
+
* (sub-phase B) enumerate through this array.
|
|
72
|
+
*
|
|
73
|
+
* Same shape as `ALL_SUITE_IDS`, `ALL_TOKEN_AUDIENCES`,
|
|
74
|
+
* `ALL_CONTENT_ARTIFACT_TYPES`, `ALL_TASK_SHAPES`,
|
|
75
|
+
* `ALL_SENSITIVITY_LEVELS`, `ALL_EVENT_TYPES`, `ALL_SETTLEMENT_MODES`.
|
|
76
|
+
* The array shape is established before the registry is registered so
|
|
77
|
+
* that the sub-phase B promotion is a one-line `REGISTERED_REGISTRIES`
|
|
78
|
+
* append, not a refactor.
|
|
79
|
+
*/
|
|
80
|
+
export declare const ALL_SETTLEMENT_ASSETS: readonly SettlementAsset[];
|
|
81
|
+
/**
|
|
82
|
+
* Type guard — narrows `unknown` to `SettlementAsset`. Consumers that
|
|
83
|
+
* derive settlement-asset values from external sources (peer rail
|
|
84
|
+
* announcements, signed `SovereignRail` declarations, discovery
|
|
85
|
+
* responses) call this before dispatching so an unchecked cast is a
|
|
86
|
+
* fail-open path the type system can't catch.
|
|
87
|
+
*
|
|
88
|
+
* Same shape as `isSuiteId`, `isTokenAudience`, `isContentArtifactType`,
|
|
89
|
+
* `isTaskShape`, `isSensitivityLevel`, `isEventType`, `isSettlementMode`.
|
|
90
|
+
*/
|
|
91
|
+
export declare function isSettlementAsset(value: unknown): value is SettlementAsset;
|
|
92
|
+
//# sourceMappingURL=settlement-asset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlement-asset.d.ts","sourceRoot":"","sources":["../src/settlement-asset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAIH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,eAAe,EAErC,CAAC;AAExB;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operator-transparency declaration — the trust-anchor primitive.
|
|
3
|
+
*
|
|
4
|
+
* The motebit relay publishes a signed declaration of its observability
|
|
5
|
+
* posture at `/.well-known/motebit-transparency.json`. The declaration
|
|
6
|
+
* commits the operator to one Ed25519 public key (`relay_public_key`)
|
|
7
|
+
* and to the operator-defined `content` payload. Verifiers pin that
|
|
8
|
+
* key as the trust anchor for every other relay-asserted artifact:
|
|
9
|
+
* content-artifact manifests on state-export endpoints, settlement
|
|
10
|
+
* receipts the operator counter-signs, federation handshakes.
|
|
11
|
+
*
|
|
12
|
+
* This module exports the binding wire types per
|
|
13
|
+
* `spec/relay-transparency-v1.md` (2b-i, the trust-anchor primitive).
|
|
14
|
+
* The operator-comparison vocabulary (Stage 2b-ii — retention/processor
|
|
15
|
+
* field standardization) is deferred until a second motebit-compatible
|
|
16
|
+
* operator forces field standardization; the `content` field stays
|
|
17
|
+
* operator-defined here and verifiers MUST NOT reject declarations on
|
|
18
|
+
* unknown `content` fields.
|
|
19
|
+
*
|
|
20
|
+
* Doctrine: `docs/doctrine/operator-transparency.md`,
|
|
21
|
+
* `docs/doctrine/nist-alignment.md` §8 "savant gap closure",
|
|
22
|
+
* `docs/doctrine/self-attesting-system.md`.
|
|
23
|
+
*
|
|
24
|
+
* Permissive floor (Apache-2.0), type-only, zero runtime deps.
|
|
25
|
+
*/
|
|
26
|
+
import type { SuiteId } from "./crypto-suite.js";
|
|
27
|
+
/**
|
|
28
|
+
* The pinned cryptosuite for transparency declarations. JCS
|
|
29
|
+
* canonicalization (RFC 8785) + Ed25519 + hex signature encoding.
|
|
30
|
+
* Matches the identity-file + credential-anchor + content-artifact
|
|
31
|
+
* family. See `SUITE_REGISTRY` in `./crypto-suite.ts`.
|
|
32
|
+
*/
|
|
33
|
+
export declare const TRANSPARENCY_SUITE: SuiteId;
|
|
34
|
+
/**
|
|
35
|
+
* Canonical memo prefix the relay emits when anchoring the
|
|
36
|
+
* declaration hash to Solana via the Memo program. Full memo shape:
|
|
37
|
+
* `motebit:transparency:v1:{hash_hex}`. Verifiers scan for this
|
|
38
|
+
* prefix at the relay's pinned anchor address. See
|
|
39
|
+
* `spec/relay-transparency-v1.md` §5.2.
|
|
40
|
+
*/
|
|
41
|
+
export declare const TRANSPARENCY_ANCHOR_MEMO_PREFIX: "motebit:transparency:v1:";
|
|
42
|
+
/**
|
|
43
|
+
* Current spec identifier. Bumps require explicit doctrine alignment
|
|
44
|
+
* + a new wire-format spec doc — the verifier MUST reject declarations
|
|
45
|
+
* with unrecognized `spec` values.
|
|
46
|
+
*/
|
|
47
|
+
export declare const TRANSPARENCY_SPEC_ID: "motebit-transparency/draft-2026-04-14";
|
|
48
|
+
/**
|
|
49
|
+
* Operator-transparency declaration — the trust-anchor envelope.
|
|
50
|
+
*
|
|
51
|
+
* Wire format (foundation law) — see `spec/relay-transparency-v1.md` §3.1
|
|
52
|
+
* for the binding shape. Field names, types, and the canonical-JSON
|
|
53
|
+
* ordering of the signed payload are protocol law. The `content` field
|
|
54
|
+
* is operator-extensible — the protocol commits to the envelope, not
|
|
55
|
+
* to the posture vocabulary inside `content`.
|
|
56
|
+
*
|
|
57
|
+
* Hash derivation: `sha256(utf8(canonicalJson({spec, declared_at,
|
|
58
|
+
* relay_id, relay_public_key, content})))` — the post-sign fields
|
|
59
|
+
* `hash`, `suite`, `signature` are NOT included in the canonical bytes.
|
|
60
|
+
* Two implementations that hash the same payload MUST produce the same
|
|
61
|
+
* hex string byte-for-byte. Per `spec/relay-transparency-v1.md` §4.
|
|
62
|
+
*/
|
|
63
|
+
export interface SignedTransparencyDeclaration {
|
|
64
|
+
/** Spec identifier — e.g. `"motebit-transparency/draft-2026-04-14"`. Bump on breaking schema changes. */
|
|
65
|
+
readonly spec: string;
|
|
66
|
+
/** Epoch milliseconds when the declaration was minted. */
|
|
67
|
+
readonly declared_at: number;
|
|
68
|
+
/** Relay's identity — same MotebitId space as agent identities. */
|
|
69
|
+
readonly relay_id: string;
|
|
70
|
+
/** Hex-encoded Ed25519 public key (32 bytes / 64 chars). */
|
|
71
|
+
readonly relay_public_key: string;
|
|
72
|
+
/**
|
|
73
|
+
* Operator-defined posture payload — retention, processors,
|
|
74
|
+
* jurisdiction, honest gaps. Opaque to the protocol. Verifiers MUST
|
|
75
|
+
* NOT reject declarations on unknown `content` fields. Cross-operator
|
|
76
|
+
* comparison vocabulary is deferred to Stage 2b-ii.
|
|
77
|
+
*/
|
|
78
|
+
readonly content: unknown;
|
|
79
|
+
/** Hex-encoded SHA-256 of the canonical-JSON of the signed payload. */
|
|
80
|
+
readonly hash: string;
|
|
81
|
+
/** Cryptosuite identifier — `motebit-jcs-ed25519-hex-v1` today. */
|
|
82
|
+
readonly suite: SuiteId;
|
|
83
|
+
/** Hex-encoded Ed25519 signature over the canonical-JSON of the signed payload. */
|
|
84
|
+
readonly signature: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The five-field signed payload — what `hash` and `signature` cover.
|
|
88
|
+
* Exposed as a type so producers can construct + canonicalize the
|
|
89
|
+
* exact bytes the verifier checks against. The post-sign fields
|
|
90
|
+
* (`hash`, `suite`, `signature`) are appended AFTER signing and are
|
|
91
|
+
* NOT part of this payload.
|
|
92
|
+
*/
|
|
93
|
+
export type TransparencySignedPayload = Pick<SignedTransparencyDeclaration, "spec" | "declared_at" | "relay_id" | "relay_public_key" | "content">;
|
|
94
|
+
/**
|
|
95
|
+
* Onchain anchor record — the verifier's view of a memo found at the
|
|
96
|
+
* relay's pinned anchor address. Returned by
|
|
97
|
+
* `@motebit/state-export-client::lookupTransparencyAnchor` on success.
|
|
98
|
+
* Per `spec/relay-transparency-v1.md` §5.
|
|
99
|
+
*/
|
|
100
|
+
export interface TransparencyAnchorRecord {
|
|
101
|
+
/** Solana transaction signature containing the anchor memo. */
|
|
102
|
+
readonly tx_hash: string;
|
|
103
|
+
/** Anchored hash (the declaration's `hash` field at time of anchoring), lowercase hex. */
|
|
104
|
+
readonly anchored_hash_hex: string;
|
|
105
|
+
/** Solana address (base58 pubkey) where the anchor lives. Pinned out-of-band by the verifier. */
|
|
106
|
+
readonly anchor_address: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Type guard — narrows `unknown` to `SignedTransparencyDeclaration`.
|
|
110
|
+
* Structural shape only; does NOT verify the signature, anchor, or
|
|
111
|
+
* succession chain. Verifiers call this before parsing then proceed
|
|
112
|
+
* through the verification algorithm in `spec/relay-transparency-v1.md`
|
|
113
|
+
* §4.1.
|
|
114
|
+
*/
|
|
115
|
+
export declare function isSignedTransparencyDeclaration(value: unknown): value is SignedTransparencyDeclaration;
|
|
116
|
+
//# sourceMappingURL=transparency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transparency.d.ts","sourceRoot":"","sources":["../src/transparency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAsC,CAAC;AAExE;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,EAAG,0BAAmC,CAAC;AAEnF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAG,uCAAgD,CAAC;AAErF;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,6BAA6B;IAC5C,yGAAyG;IACzG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,mFAAmF;IACnF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,6BAA6B,EAC7B,MAAM,GAAG,aAAa,GAAG,UAAU,GAAG,kBAAkB,GAAG,SAAS,CACrE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0FAA0F;IAC1F,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,iGAAiG;IACjG,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,6BAA6B,CAaxC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operator-transparency declaration — the trust-anchor primitive.
|
|
3
|
+
*
|
|
4
|
+
* The motebit relay publishes a signed declaration of its observability
|
|
5
|
+
* posture at `/.well-known/motebit-transparency.json`. The declaration
|
|
6
|
+
* commits the operator to one Ed25519 public key (`relay_public_key`)
|
|
7
|
+
* and to the operator-defined `content` payload. Verifiers pin that
|
|
8
|
+
* key as the trust anchor for every other relay-asserted artifact:
|
|
9
|
+
* content-artifact manifests on state-export endpoints, settlement
|
|
10
|
+
* receipts the operator counter-signs, federation handshakes.
|
|
11
|
+
*
|
|
12
|
+
* This module exports the binding wire types per
|
|
13
|
+
* `spec/relay-transparency-v1.md` (2b-i, the trust-anchor primitive).
|
|
14
|
+
* The operator-comparison vocabulary (Stage 2b-ii — retention/processor
|
|
15
|
+
* field standardization) is deferred until a second motebit-compatible
|
|
16
|
+
* operator forces field standardization; the `content` field stays
|
|
17
|
+
* operator-defined here and verifiers MUST NOT reject declarations on
|
|
18
|
+
* unknown `content` fields.
|
|
19
|
+
*
|
|
20
|
+
* Doctrine: `docs/doctrine/operator-transparency.md`,
|
|
21
|
+
* `docs/doctrine/nist-alignment.md` §8 "savant gap closure",
|
|
22
|
+
* `docs/doctrine/self-attesting-system.md`.
|
|
23
|
+
*
|
|
24
|
+
* Permissive floor (Apache-2.0), type-only, zero runtime deps.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* The pinned cryptosuite for transparency declarations. JCS
|
|
28
|
+
* canonicalization (RFC 8785) + Ed25519 + hex signature encoding.
|
|
29
|
+
* Matches the identity-file + credential-anchor + content-artifact
|
|
30
|
+
* family. See `SUITE_REGISTRY` in `./crypto-suite.ts`.
|
|
31
|
+
*/
|
|
32
|
+
export const TRANSPARENCY_SUITE = "motebit-jcs-ed25519-hex-v1";
|
|
33
|
+
/**
|
|
34
|
+
* Canonical memo prefix the relay emits when anchoring the
|
|
35
|
+
* declaration hash to Solana via the Memo program. Full memo shape:
|
|
36
|
+
* `motebit:transparency:v1:{hash_hex}`. Verifiers scan for this
|
|
37
|
+
* prefix at the relay's pinned anchor address. See
|
|
38
|
+
* `spec/relay-transparency-v1.md` §5.2.
|
|
39
|
+
*/
|
|
40
|
+
export const TRANSPARENCY_ANCHOR_MEMO_PREFIX = "motebit:transparency:v1:";
|
|
41
|
+
/**
|
|
42
|
+
* Current spec identifier. Bumps require explicit doctrine alignment
|
|
43
|
+
* + a new wire-format spec doc — the verifier MUST reject declarations
|
|
44
|
+
* with unrecognized `spec` values.
|
|
45
|
+
*/
|
|
46
|
+
export const TRANSPARENCY_SPEC_ID = "motebit-transparency/draft-2026-04-14";
|
|
47
|
+
/**
|
|
48
|
+
* Type guard — narrows `unknown` to `SignedTransparencyDeclaration`.
|
|
49
|
+
* Structural shape only; does NOT verify the signature, anchor, or
|
|
50
|
+
* succession chain. Verifiers call this before parsing then proceed
|
|
51
|
+
* through the verification algorithm in `spec/relay-transparency-v1.md`
|
|
52
|
+
* §4.1.
|
|
53
|
+
*/
|
|
54
|
+
export function isSignedTransparencyDeclaration(value) {
|
|
55
|
+
if (typeof value !== "object" || value === null)
|
|
56
|
+
return false;
|
|
57
|
+
const o = value;
|
|
58
|
+
return (typeof o.spec === "string" &&
|
|
59
|
+
typeof o.declared_at === "number" &&
|
|
60
|
+
typeof o.relay_id === "string" &&
|
|
61
|
+
typeof o.relay_public_key === "string" &&
|
|
62
|
+
"content" in o &&
|
|
63
|
+
typeof o.hash === "string" &&
|
|
64
|
+
typeof o.suite === "string" &&
|
|
65
|
+
typeof o.signature === "string");
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=transparency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transparency.js","sourceRoot":"","sources":["../src/transparency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAY,4BAA4B,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,0BAAmC,CAAC;AAEnF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,uCAAgD,CAAC;AAoErF;;;;;;GAMG;AACH,MAAM,UAAU,+BAA+B,CAC7C,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,OAAO,CACL,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ;QAC1B,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ;QACjC,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ;QAC9B,OAAO,CAAC,CAAC,gBAAgB,KAAK,QAAQ;QACtC,SAAS,IAAI,CAAC;QACd,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ;QAC1B,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ;QAC3B,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ,CAChC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motebit/protocol",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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",
|