@engramx/idl 0.16.0-rc.22 → 0.16.0-rc.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/engram.did CHANGED
@@ -207,6 +207,22 @@ type SealedEntry =
207
207
  entryHash: blob;
208
208
  id: nat;
209
209
  };
210
+ type SaleNotice =
211
+ record {
212
+ amountE6: nat;
213
+ buyer: text;
214
+ jobId: opt text;
215
+ kind: variant {
216
+ content;
217
+ "service";
218
+ };
219
+ listingId: text;
220
+ network: text;
221
+ receiptId: text;
222
+ settledAtNs: int;
223
+ token: text;
224
+ txRef: opt text;
225
+ };
210
226
  type Role =
211
227
  variant {
212
228
  Admin;
@@ -267,20 +283,25 @@ type ResyncReport =
267
283
  };
268
284
  startsAcknowledged: nat;
269
285
  };
286
+ type Result_90 =
287
+ variant {
288
+ Err: Error;
289
+ Ok: AgentRecord;
290
+ };
270
291
  type Result_9 =
271
292
  variant {
272
293
  Err: Error;
273
294
  Ok: vec Seat;
274
295
  };
275
- type Result_89 =
296
+ type Result_88 =
276
297
  variant {
277
298
  Err: Error;
278
- Ok: AgentRecord;
299
+ Ok: Eip712Registration;
279
300
  };
280
- type Result_87 =
301
+ type Result_86 =
281
302
  variant {
282
303
  Err: Error;
283
- Ok: Eip712Registration;
304
+ Ok: Conversion;
284
305
  };
285
306
  type Result_85 =
286
307
  variant {
@@ -1410,7 +1431,7 @@ type Engram =
1410
1431
  /// nomination names. That check compares the caller inside the module, where
1411
1432
  /// test/key-replacement.test.mo runs it; this body names no roster gate, because the caller holds
1412
1433
  /// no role here until the move.
1413
- acceptAgentKeyNomination: (agentKey: principal) -> (Result_89);
1434
+ acceptAgentKeyNomination: (agentKey: principal) -> (Result_90);
1414
1435
  /// The person the owner asked again ACCEPTS: they become this engram's sign-in, and the sealed copy
1415
1436
  /// that came with the ask becomes the engram's (sealed for them). Until this call they have no power
1416
1437
  /// at all. Callable only by that person while the ask waits; refused (as at birth) if they are now
@@ -1494,7 +1515,7 @@ type Engram =
1494
1515
  };
1495
1516
  primaryType: text;
1496
1517
  verifyingContract: text;
1497
- }) -> (Result_87);
1518
+ }) -> (Result_88);
1498
1519
  /// ⟨0.16.0, L1⟩ THE ROLE-CONFLICT ARM, and why three refusals here are not the same refusal.
1499
1520
  ///
1500
1521
  /// This method had five distinct ways to say no through one `text`, and a caller could only tell
@@ -1524,6 +1545,29 @@ type Engram =
1524
1545
  /// Named callers: an owner console's seller list for an engram (signed in as its sign-in, for one
1525
1546
  /// opened through another), and the owner kit.
1526
1547
  addSeller: (payTo: text, perDayCapE6: nat, isPayout: bool) -> (Result_11);
1548
+ /// AN AGENT CONVERTS THE ENGRAM'S BALANCE INTO COMPUTE, under the runway rule ⟨2026-11-04, the owner's
1549
+ /// rulings of 2026-11-01, "2 A" and "agree"; `AgentConvert.mo` holds the rule and says why each number⟩.
1550
+ ///
1551
+ /// CALLER: a paired agent whose STORED grant holds the scope "wallet.convert" (`AgentConvert.SCOPE`),
1552
+ /// which only the owner adds (`createAgentInvite` / `setAgentPermissions`); off by default, and no HTTP
1553
+ /// connector token ever carries it (`OAuth.scopesToPermissions`). The OWNER's role is refused by name —
1554
+ /// the owner converts with `convertEarningsToCycles`.
1555
+ ///
1556
+ /// THE RULE: converts only while this engram has under 30 days of compute left by its own reading; at
1557
+ /// least 0.50 and at most 2.00 (or the owner's own per-call cap if lower); at most one conversion under
1558
+ /// the rule in any rolling 24 hours (`agentConvertAtNs`, which holds with the engram-wide ceiling
1559
+ /// removed); counted against that ceiling when one is set; refused under ANY payment freeze (ruled), and
1560
+ /// while another of the engram's own calls is out (its balance reads low then). `amountE6 = null` converts
1561
+ /// as much as allowed: the smaller of the cap and what the wallet holds less the ledger fee — the wallet
1562
+ /// is READ before anything moves, and a wallet that cannot fund 0.50 is refused by name.
1563
+ ///
1564
+ /// STOPPED MID-WAY: if the agent is removed, leaves, loses the grant, payments are frozen or the engram is
1565
+ /// reset while it waits on the ledger or the cashier's deposit address, nothing moves; after the money
1566
+ /// reached the deposit, it is sent back to the wallet less one ledger fee (or held at the biller for the
1567
+ /// owner's next Convert). THE RESIDUAL, stated: a removal landing DURING the cashier's own conversion call
1568
+ /// cannot stop that call — it finishes, and the reply (`finishedBeforeRemovalSeen`) and the record row say
1569
+ /// so. One inter-canister call, bounded by one cap.
1570
+ agentConvertBalance: (token: text, amountE6: opt nat) -> (Result_86);
1527
1571
  /// Returns the write RECEIPT, not just the version.
1528
1572
  ///
1529
1573
  /// The receipt was always computed and then thrown away: MemoryRouter hands back
@@ -1675,6 +1719,20 @@ type Engram =
1675
1719
  /// ⟨2026-10-02⟩ The second parameter is NAMED `amountE6` now, as the census row above rules the
1676
1720
  /// pair — e6 base units of the token named first. A name only: Candid passes arguments by
1677
1721
  /// position, so nothing on the wire moved.
1722
+ ///
1723
+ /// ⟨2026-11-04, the agent-conversion build — the owner's "2 A" and "agree"⟩ The body moved whole into
1724
+ /// `runConversion`, which an agent's `agentConvertBalance` shares; this method keeps its name, its
1725
+ /// signature and its bare `cyclesAdded` reply. Under "2 A" it converts the engram's BALANCE (what the
1726
+ /// owner put in and what it earned are not told apart); the name is the wire's and stays. A FIRST
1727
+ /// engram's owner Convert is unchanged: not counted, not freeze-gated, not runway-bound, not pre-read,
1728
+ /// 10.00 / 5 min. In an engram OPENED THROUGH ANOTHER the key file's Convert runs the agent rule too
1729
+ /// (ruled "agree", question 3: under 30 days, 0.50–2.00, once in 24 hours shared with the agents, the
1730
+ /// wallet read first), keeping its own freeze gate (L18: a guardian's freeze only).
1731
+ /// ⟨2026-11-04, review fix⟩ SHARED with an agent's conversion: the in-flight latch only (one deposit
1732
+ /// account, one pending marker — one conversion at a time, whoever asked), so while an agent's conversion
1733
+ /// is between its deposit and its landing this door answers "another conversion is still in flight". NOT
1734
+ /// shared: the 5-minute cooldown (an agent's landing does not move it) and the latch during an agent's
1735
+ /// wallet read (nothing is held while it reads).
1678
1736
  convertEarningsToCycles: (token: text, amountE6: nat) -> (Result_15);
1679
1737
  /// Owner-only: mint a single-use invite code an agent redeems with `pairAgent`.
1680
1738
  ///
@@ -1824,6 +1882,10 @@ type Engram =
1824
1882
  /// · `convertEarningsToCycles` — the owner's OWN earnings becoming their OWN engram's fuel. A
1825
1883
  /// frozen engram still burns cycles, so freezing this would let a brake starve the thing it
1826
1884
  /// is protecting. Owner-only, capped per call, and it moves nothing outward.
1885
+ /// ⟨2026-11-04, the agent-conversion build — ruled "agree", question 2⟩ An AGENT's conversion
1886
+ /// (`agentConvertBalance`) IS frozen, by any freeze — the owner's own included — before it starts and
1887
+ /// again after each await. The owner's own Convert in a first engram stays as above; in an engram
1888
+ /// opened through another it stops under a guardian's freeze only (L18).
1827
1889
  /// · `approveRequest` — an approval is not a spend. The spend it authorises goes through
1828
1890
  /// `x402SignFor`, which IS frozen, so an approval granted during a freeze simply waits.
1829
1891
  /// · `transferOwnership` — ownership is not a payment, and a guardian's PAYMENTS brake is not
@@ -1844,6 +1906,12 @@ type Engram =
1844
1906
  /// ⟨2026-11-03, the pre-gate fixes — spec §7, "child: sign-in — reads yes"⟩ Also the seated sign-in of
1845
1907
  /// an engram opened through another, as the owner (`#ownerOrSignIn`); a first engram is unchanged.
1846
1908
  getActionAlertStatus: () -> (Result_73) query;
1909
+ /// The agent-conversion rule's numbers.
1910
+ /// PUBLIC: the class of `getTopUpLimits` — a policy, nobody's data. ⟨2026-11-04, the market-route
1911
+ /// build: the marker's colon was missing, so the deployment's PUBLIC-rationale gate read the method as
1912
+ /// unmarked; the reason itself is unchanged.⟩
1913
+ /// The cap an agent meets is `min(maxPerCallE6, getTopUpLimits().maxCkusdcE6s)`.
1914
+ getAgentConvertRule: () -> (AgentConvertRule) query;
1847
1915
  /// Agents need to know what they may revise, so they can read it too. Whole-value config, same
1848
1916
  /// carve-out as getProtectedPaths — and kept a SEPARATE method from it deliberately (L2.2): a
1849
1917
  /// protected path and a revisable path are opposite grants, and one accessor for both would be a
@@ -2310,6 +2378,10 @@ type Engram =
2310
2378
  /// caller. ⟨2026-09-28, the owner's decision to add the ceiling⟩
2311
2379
  /// ⟨CORRECTED 2026-09-29, review finding X-8: "spent" means signed in x402 payments; typed-data
2312
2380
  /// and the engram's registration signatures are not counted here — see `setSpendCeiling`.⟩
2381
+ /// ⟨CORRECTED 2026-11-04, the agent-conversion build, beside the note above⟩ …and, since 2026-11, an
2382
+ /// agent's conversion of the engram's balance into compute (`agentConvertBalance`, in a first engram too);
2383
+ /// in an engram opened through another the key file's Convert as well (since 2026-11-02). Both are reserved
2384
+ /// before their first await and given back when nothing left the wallet.
2313
2385
  ///
2314
2386
  /// OWNER-ONLY, for the reason `getSpendPolicy` is: the limits are the owner's custody
2315
2387
  /// configuration, and the engram-wide total would also tell one agent how much the others spent.
@@ -3905,6 +3977,10 @@ type Engram =
3905
3977
  /// The record entry `spend.setCeiling` carries the new AND the previous value, so a widening is
3906
3978
  /// distinguishable from a tightening afterwards — the reason `spend.setPolicy` records its limits.
3907
3979
  /// Not blocked by a payments freeze, like `setSpendPolicy`: setting a limit moves no money.
3980
+ /// ⟨2026-11-04, the agent-conversion build⟩ What counts against the ceiling: x402 payments, an agent's
3981
+ /// conversion of the engram's balance, and the key file's Convert in an engram opened through another
3982
+ /// (`getSpendCeiling`'s note). Removing the ceiling does NOT free agent conversions: they keep their own
3983
+ /// bound, one in any 24 hours (`agentConvertAtNs`).
3908
3984
  setSpendCeiling: (maxPerDay: opt nat) -> (Result_2);
3909
3985
  /// Set this engram's spending caps.
3910
3986
  ///
@@ -4240,6 +4316,49 @@ type Engram =
4240
4316
  paidThroughNs: opt int;
4241
4317
  scheduleVersion: opt text;
4242
4318
  }) -> (Result_2);
4319
+ /// ⟨2026-11-04, the owner's ruling "1 A": a marketplace sale is paid into the selling engram's own
4320
+ /// wallet, and the engram writes each sale to its record⟩ THE MARKET WRITING A SALE TO THIS ENGRAM'S
4321
+ /// RECORD, after it has paid this engram's own account (ckUSDC) or address (another chain). The
4322
+ /// money does not pass through here and nothing here moves any: a ledger account needs no running
4323
+ /// canister, so the sale is paid whatever state this engram is in, and this method only writes the
4324
+ /// line that says so — one `market.sale` row per sale, its details from `SaleNotice.details`.
4325
+ ///
4326
+ /// GATED TO THE CONFIGURED MARKET (`AccessControl.requireMarketSale`), the pointer the spawning
4327
+ /// registry set once (`sysSetMarketId`). Neither the owner nor an agent may write a sale row: a
4328
+ /// receipt an owner could write is a receipt an owner could forge.
4329
+ ///
4330
+ /// IDEMPOTENT ON THE RECEIPT ID. The market retries a notice it could not deliver (this engram out
4331
+ /// of compute, upgrading, stopped), and a retry of one that did land must learn it succeeded: a
4332
+ /// repeat answers `#Ok` and writes nothing — no row, no denial row (`sysNotifyWalletActivity`'s
4333
+ /// contract). The receipt ids live in `saleReceiptsStable`.
4334
+ ///
4335
+ /// IT AWAITS NOTHING, deliberately, and test/market-route-wiring.test.ts rule E3 holds that: no
4336
+ /// outgoing call means nothing to count under wiring rule 20, and NO WAKE DOOR — a sale brings
4337
+ /// dollars, not compute, so a paused engram's wake would find no room on every engram that is
4338
+ /// actually paused (the design's question 3, defaulted "wakes nothing unless the owner objects").
4339
+ ///
4340
+ /// NOT GATED ON a guardian's payment freeze (that stops this engram's own signing — money out;
4341
+ /// `sysRecordFeeEvent` is not freeze-gated either), on `pauseWrites` (memory writes), or on the
4342
+ /// owner's custody state. A receipt an owner could block is a receipt an owner could hide.
4343
+ ///
4344
+ /// It also stamps `walletActivatedAt` ("market-sale"): money landing in this engram's account IS
4345
+ /// the wallet-bearing event, and it covers services, which the market's listing notice never did.
4346
+ /// The listing notice (`sysNotifyWalletActivity`) stays, as ruled 2026-08-20; whether to retire it
4347
+ /// is the owner's question.
4348
+ ///
4349
+ /// ⟨2026-11-04, the owner's ruling "A", beside the gate paragraph above⟩ NO MARKET SET YET IS "NOT
4350
+ /// YET", NOT A REFUSAL. With `marketId` null the gate's refusal is answered `#Unavailable`, and the
4351
+ /// market PARKS the notice (it drops a sale's line on any other `#Err` at once — the defect this
4352
+ /// closes: the money landed and the line was lost for good). `marketId` is not final: the registry
4353
+ /// sets it later (`sysSetMarketId`), and then `retrySaleNotices` or the seller's next
4354
+ /// `registerSeller` writes the line; the market's 30-day age cap ends the wait. That arm writes NO
4355
+ /// `sysRecordSale.denied` row: nothing was denied, and `retrySaleNotices` is open to any caller, so a
4356
+ /// row per press would be spam on the owner's read log. A caller that is not the configured market,
4357
+ /// once one is set, is still `#Refused` with its row, unchanged. WHAT WOULD MAKE THIS WRONG: a
4358
+ /// `marketId` that can be set to null on purpose (a market retired from an engram) — then null would
4359
+ /// mean "never", and parking for 30 days would hold a line nobody can write.
4360
+ /// Witness: test/market-route/sale-route.test.ts S7 and record-row.test.ts R3.
4361
+ sysRecordSale: (sale: SaleNotice) -> (Result_2);
4243
4362
  /// Give back what a paid security update advanced this engram and the install did not use.
4244
4363
  ///
4245
4364
  /// CALLER: the registry that spawned this engram, right after it installed a security update it
@@ -4555,6 +4674,14 @@ type CycleSnapshot =
4555
4674
  self;
4556
4675
  };
4557
4676
  };
4677
+ type Conversion =
4678
+ record {
4679
+ amountE6: nat;
4680
+ cyclesAdded: nat;
4681
+ daysLeftBefore: opt nat;
4682
+ finishedBeforeRemovalSeen: bool;
4683
+ token: text;
4684
+ };
4558
4685
  type ControlHandover =
4559
4686
  variant {
4560
4687
  MovedByEngram;
@@ -4912,6 +5039,13 @@ type AgentEndReason =
4912
5039
  Reset;
4913
5040
  Resigned;
4914
5041
  };
5042
+ type AgentConvertRule =
5043
+ record {
5044
+ belowDays: nat;
5045
+ maxPerCallE6: nat;
5046
+ minPerCallE6: nat;
5047
+ spacingSeconds: nat;
5048
+ };
4915
5049
  type AgentCard =
4916
5050
  record {
4917
5051
  description: text;
@@ -4966,5 +5100,6 @@ service : (initArgs: opt
4966
5100
  owner: opt principal;
4967
5101
  ownerSignIn: opt principal;
4968
5102
  parent: opt principal;
5103
+ recoveredAtNs: opt int;
4969
5104
  registry: opt principal;
4970
5105
  }) -> Engram
@@ -47,6 +47,12 @@ export interface AgentCard {
47
47
  description: string;
48
48
  services: Array<ServiceEntry>;
49
49
  }
50
+ export interface AgentConvertRule {
51
+ spacingSeconds: bigint;
52
+ minPerCallE6: bigint;
53
+ maxPerCallE6: bigint;
54
+ belowDays: bigint;
55
+ }
50
56
  export type AgentEndReason =
51
57
  | { Resigned: null }
52
58
  | { OwnerRevoked: null }
@@ -319,6 +325,13 @@ export interface CondenseResult {
319
325
  }
320
326
  export type ControlHandover =
321
327
  { MovedByRegistry: null } | { NotHeldHere: null } | { MovedByEngram: null };
328
+ export interface Conversion {
329
+ token: string;
330
+ daysLeftBefore: [] | [bigint];
331
+ amountE6: bigint;
332
+ cyclesAdded: bigint;
333
+ finishedBeforeRemovalSeen: boolean;
334
+ }
322
335
  export interface CycleSnapshot {
323
336
  seq: bigint;
324
337
  source: { balance: null } | { self: null };
@@ -413,7 +426,7 @@ export interface Engram {
413
426
  * / test/key-replacement.test.mo runs it; this body names no roster gate, because the caller holds
414
427
  * / no role here until the move.
415
428
  */
416
- acceptAgentKeyNomination: ActorMethod<[Principal], Result_89>;
429
+ acceptAgentKeyNomination: ActorMethod<[Principal], Result_90>;
417
430
  /**
418
431
  * / The person the owner asked again ACCEPTS: they become this engram's sign-in, and the sealed copy
419
432
  * / that came with the ask becomes the engram's (sealed for them). Until this call they have no power
@@ -497,7 +510,7 @@ export interface Engram {
497
510
  ackIrrevocable: boolean;
498
511
  },
499
512
  ],
500
- Result_87
513
+ Result_88
501
514
  >;
502
515
  /**
503
516
  * / ⟨0.16.0, L1⟩ THE ROLE-CONFLICT ARM, and why three refusals here are not the same refusal.
@@ -533,6 +546,31 @@ export interface Engram {
533
546
  * / opened through another), and the owner kit.
534
547
  */
535
548
  addSeller: ActorMethod<[string, bigint, boolean], Result_11>;
549
+ /**
550
+ * / AN AGENT CONVERTS THE ENGRAM'S BALANCE INTO COMPUTE, under the runway rule ⟨2026-11-04, the owner's
551
+ * / rulings of 2026-11-01, "2 A" and "agree"; `AgentConvert.mo` holds the rule and says why each number⟩.
552
+ * /
553
+ * / CALLER: a paired agent whose STORED grant holds the scope "wallet.convert" (`AgentConvert.SCOPE`),
554
+ * / which only the owner adds (`createAgentInvite` / `setAgentPermissions`); off by default, and no HTTP
555
+ * / connector token ever carries it (`OAuth.scopesToPermissions`). The OWNER's role is refused by name —
556
+ * / the owner converts with `convertEarningsToCycles`.
557
+ * /
558
+ * / THE RULE: converts only while this engram has under 30 days of compute left by its own reading; at
559
+ * / least 0.50 and at most 2.00 (or the owner's own per-call cap if lower); at most one conversion under
560
+ * / the rule in any rolling 24 hours (`agentConvertAtNs`, which holds with the engram-wide ceiling
561
+ * / removed); counted against that ceiling when one is set; refused under ANY payment freeze (ruled), and
562
+ * / while another of the engram's own calls is out (its balance reads low then). `amountE6 = null` converts
563
+ * / as much as allowed: the smaller of the cap and what the wallet holds less the ledger fee — the wallet
564
+ * / is READ before anything moves, and a wallet that cannot fund 0.50 is refused by name.
565
+ * /
566
+ * / STOPPED MID-WAY: if the agent is removed, leaves, loses the grant, payments are frozen or the engram is
567
+ * / reset while it waits on the ledger or the cashier's deposit address, nothing moves; after the money
568
+ * / reached the deposit, it is sent back to the wallet less one ledger fee (or held at the biller for the
569
+ * / owner's next Convert). THE RESIDUAL, stated: a removal landing DURING the cashier's own conversion call
570
+ * / cannot stop that call — it finishes, and the reply (`finishedBeforeRemovalSeen`) and the record row say
571
+ * / so. One inter-canister call, bounded by one cap.
572
+ */
573
+ agentConvertBalance: ActorMethod<[string, [] | [bigint]], Result_86>;
536
574
  /**
537
575
  * / Returns the write RECEIPT, not just the version.
538
576
  * /
@@ -704,6 +742,20 @@ export interface Engram {
704
742
  * / ⟨2026-10-02⟩ The second parameter is NAMED `amountE6` now, as the census row above rules the
705
743
  * / pair — e6 base units of the token named first. A name only: Candid passes arguments by
706
744
  * / position, so nothing on the wire moved.
745
+ * /
746
+ * / ⟨2026-11-04, the agent-conversion build — the owner's "2 A" and "agree"⟩ The body moved whole into
747
+ * / `runConversion`, which an agent's `agentConvertBalance` shares; this method keeps its name, its
748
+ * / signature and its bare `cyclesAdded` reply. Under "2 A" it converts the engram's BALANCE (what the
749
+ * / owner put in and what it earned are not told apart); the name is the wire's and stays. A FIRST
750
+ * / engram's owner Convert is unchanged: not counted, not freeze-gated, not runway-bound, not pre-read,
751
+ * / 10.00 / 5 min. In an engram OPENED THROUGH ANOTHER the key file's Convert runs the agent rule too
752
+ * / (ruled "agree", question 3: under 30 days, 0.50–2.00, once in 24 hours shared with the agents, the
753
+ * / wallet read first), keeping its own freeze gate (L18: a guardian's freeze only).
754
+ * / ⟨2026-11-04, review fix⟩ SHARED with an agent's conversion: the in-flight latch only (one deposit
755
+ * / account, one pending marker — one conversion at a time, whoever asked), so while an agent's conversion
756
+ * / is between its deposit and its landing this door answers "another conversion is still in flight". NOT
757
+ * / shared: the 5-minute cooldown (an agent's landing does not move it) and the latch during an agent's
758
+ * / wallet read (nothing is held while it reads).
707
759
  */
708
760
  convertEarningsToCycles: ActorMethod<[string, bigint], Result_15>;
709
761
  /**
@@ -868,6 +920,10 @@ export interface Engram {
868
920
  * / · `convertEarningsToCycles` — the owner's OWN earnings becoming their OWN engram's fuel. A
869
921
  * / frozen engram still burns cycles, so freezing this would let a brake starve the thing it
870
922
  * / is protecting. Owner-only, capped per call, and it moves nothing outward.
923
+ * / ⟨2026-11-04, the agent-conversion build — ruled "agree", question 2⟩ An AGENT's conversion
924
+ * / (`agentConvertBalance`) IS frozen, by any freeze — the owner's own included — before it starts and
925
+ * / again after each await. The owner's own Convert in a first engram stays as above; in an engram
926
+ * / opened through another it stops under a guardian's freeze only (L18).
871
927
  * / · `approveRequest` — an approval is not a spend. The spend it authorises goes through
872
928
  * / `x402SignFor`, which IS frozen, so an approval granted during a freeze simply waits.
873
929
  * / · `transferOwnership` — ownership is not a payment, and a guardian's PAYMENTS brake is not
@@ -893,6 +949,14 @@ export interface Engram {
893
949
  * / an engram opened through another, as the owner (`#ownerOrSignIn`); a first engram is unchanged.
894
950
  */
895
951
  getActionAlertStatus: ActorMethod<[], Result_73>;
952
+ /**
953
+ * / The agent-conversion rule's numbers.
954
+ * / PUBLIC: the class of `getTopUpLimits` — a policy, nobody's data. ⟨2026-11-04, the market-route
955
+ * / build: the marker's colon was missing, so the deployment's PUBLIC-rationale gate read the method as
956
+ * / unmarked; the reason itself is unchanged.⟩
957
+ * / The cap an agent meets is `min(maxPerCallE6, getTopUpLimits().maxCkusdcE6s)`.
958
+ */
959
+ getAgentConvertRule: ActorMethod<[], AgentConvertRule>;
896
960
  /**
897
961
  * / Agents need to know what they may revise, so they can read it too. Whole-value config, same
898
962
  * / carve-out as getProtectedPaths — and kept a SEPARATE method from it deliberately (L2.2): a
@@ -1434,6 +1498,10 @@ export interface Engram {
1434
1498
  * / caller. ⟨2026-09-28, the owner's decision to add the ceiling⟩
1435
1499
  * / ⟨CORRECTED 2026-09-29, review finding X-8: "spent" means signed in x402 payments; typed-data
1436
1500
  * / and the engram's registration signatures are not counted here — see `setSpendCeiling`.⟩
1501
+ * / ⟨CORRECTED 2026-11-04, the agent-conversion build, beside the note above⟩ …and, since 2026-11, an
1502
+ * / agent's conversion of the engram's balance into compute (`agentConvertBalance`, in a first engram too);
1503
+ * / in an engram opened through another the key file's Convert as well (since 2026-11-02). Both are reserved
1504
+ * / before their first await and given back when nothing left the wallet.
1437
1505
  * /
1438
1506
  * / OWNER-ONLY, for the reason `getSpendPolicy` is: the limits are the owner's custody
1439
1507
  * / configuration, and the engram-wide total would also tell one agent how much the others spent.
@@ -3201,6 +3269,10 @@ export interface Engram {
3201
3269
  * / The record entry `spend.setCeiling` carries the new AND the previous value, so a widening is
3202
3270
  * / distinguishable from a tightening afterwards — the reason `spend.setPolicy` records its limits.
3203
3271
  * / Not blocked by a payments freeze, like `setSpendPolicy`: setting a limit moves no money.
3272
+ * / ⟨2026-11-04, the agent-conversion build⟩ What counts against the ceiling: x402 payments, an agent's
3273
+ * / conversion of the engram's balance, and the key file's Convert in an engram opened through another
3274
+ * / (`getSpendCeiling`'s note). Removing the ceiling does NOT free agent conversions: they keep their own
3275
+ * / bound, one in any 24 hours (`agentConvertAtNs`).
3204
3276
  */
3205
3277
  setSpendCeiling: ActorMethod<[[] | [bigint]], Result_2>;
3206
3278
  /**
@@ -3574,6 +3646,51 @@ export interface Engram {
3574
3646
  ],
3575
3647
  Result_2
3576
3648
  >;
3649
+ /**
3650
+ * / ⟨2026-11-04, the owner's ruling "1 A": a marketplace sale is paid into the selling engram's own
3651
+ * / wallet, and the engram writes each sale to its record⟩ THE MARKET WRITING A SALE TO THIS ENGRAM'S
3652
+ * / RECORD, after it has paid this engram's own account (ckUSDC) or address (another chain). The
3653
+ * / money does not pass through here and nothing here moves any: a ledger account needs no running
3654
+ * / canister, so the sale is paid whatever state this engram is in, and this method only writes the
3655
+ * / line that says so — one `market.sale` row per sale, its details from `SaleNotice.details`.
3656
+ * /
3657
+ * / GATED TO THE CONFIGURED MARKET (`AccessControl.requireMarketSale`), the pointer the spawning
3658
+ * / registry set once (`sysSetMarketId`). Neither the owner nor an agent may write a sale row: a
3659
+ * / receipt an owner could write is a receipt an owner could forge.
3660
+ * /
3661
+ * / IDEMPOTENT ON THE RECEIPT ID. The market retries a notice it could not deliver (this engram out
3662
+ * / of compute, upgrading, stopped), and a retry of one that did land must learn it succeeded: a
3663
+ * / repeat answers `#Ok` and writes nothing — no row, no denial row (`sysNotifyWalletActivity`'s
3664
+ * / contract). The receipt ids live in `saleReceiptsStable`.
3665
+ * /
3666
+ * / IT AWAITS NOTHING, deliberately, and test/market-route-wiring.test.ts rule E3 holds that: no
3667
+ * / outgoing call means nothing to count under wiring rule 20, and NO WAKE DOOR — a sale brings
3668
+ * / dollars, not compute, so a paused engram's wake would find no room on every engram that is
3669
+ * / actually paused (the design's question 3, defaulted "wakes nothing unless the owner objects").
3670
+ * /
3671
+ * / NOT GATED ON a guardian's payment freeze (that stops this engram's own signing — money out;
3672
+ * / `sysRecordFeeEvent` is not freeze-gated either), on `pauseWrites` (memory writes), or on the
3673
+ * / owner's custody state. A receipt an owner could block is a receipt an owner could hide.
3674
+ * /
3675
+ * / It also stamps `walletActivatedAt` ("market-sale"): money landing in this engram's account IS
3676
+ * / the wallet-bearing event, and it covers services, which the market's listing notice never did.
3677
+ * / The listing notice (`sysNotifyWalletActivity`) stays, as ruled 2026-08-20; whether to retire it
3678
+ * / is the owner's question.
3679
+ * /
3680
+ * / ⟨2026-11-04, the owner's ruling "A", beside the gate paragraph above⟩ NO MARKET SET YET IS "NOT
3681
+ * / YET", NOT A REFUSAL. With `marketId` null the gate's refusal is answered `#Unavailable`, and the
3682
+ * / market PARKS the notice (it drops a sale's line on any other `#Err` at once — the defect this
3683
+ * / closes: the money landed and the line was lost for good). `marketId` is not final: the registry
3684
+ * / sets it later (`sysSetMarketId`), and then `retrySaleNotices` or the seller's next
3685
+ * / `registerSeller` writes the line; the market's 30-day age cap ends the wait. That arm writes NO
3686
+ * / `sysRecordSale.denied` row: nothing was denied, and `retrySaleNotices` is open to any caller, so a
3687
+ * / row per press would be spam on the owner's read log. A caller that is not the configured market,
3688
+ * / once one is set, is still `#Refused` with its row, unchanged. WHAT WOULD MAKE THIS WRONG: a
3689
+ * / `marketId` that can be set to null on purpose (a market retired from an engram) — then null would
3690
+ * / mean "never", and parking for 30 days would hold a line nobody can write.
3691
+ * / Witness: test/market-route/sale-route.test.ts S7 and record-row.test.ts R3.
3692
+ */
3693
+ sysRecordSale: ActorMethod<[SaleNotice], Result_2>;
3577
3694
  /**
3578
3695
  * / Give back what a paid security update advanced this engram and the install did not use.
3579
3696
  * /
@@ -4471,9 +4588,10 @@ export type Result_81 = { Ok: AgentWriteReview } | { Err: Error };
4471
4588
  export type Result_82 = { Ok: Page_26 } | { Err: Error };
4472
4589
  export type Result_84 = { Ok: MemoryRangeExport } | { Err: Error };
4473
4590
  export type Result_85 = { Ok: CondenseResult } | { Err: Error };
4474
- export type Result_87 = { Ok: Eip712Registration } | { Err: Error };
4475
- export type Result_89 = { Ok: AgentRecord } | { Err: Error };
4591
+ export type Result_86 = { Ok: Conversion } | { Err: Error };
4592
+ export type Result_88 = { Ok: Eip712Registration } | { Err: Error };
4476
4593
  export type Result_9 = { Ok: Array<Seat> } | { Err: Error };
4594
+ export type Result_90 = { Ok: AgentRecord } | { Err: Error };
4477
4595
  export interface ResyncReport {
4478
4596
  startsAcknowledged: bigint;
4479
4597
  cannotBeRecorded: Array<UnrecordableEngagement>;
@@ -4523,6 +4641,18 @@ export type Role =
4523
4641
  | { Agent: null }
4524
4642
  | { Other: null }
4525
4643
  | { Owner: null };
4644
+ export interface SaleNotice {
4645
+ token: string;
4646
+ txRef: [] | [string];
4647
+ listingId: string;
4648
+ kind: { service: null } | { content: null };
4649
+ jobId: [] | [string];
4650
+ network: string;
4651
+ amountE6: bigint;
4652
+ receiptId: string;
4653
+ buyer: string;
4654
+ settledAtNs: bigint;
4655
+ }
4526
4656
  export interface SealedEntry {
4527
4657
  id: bigint;
4528
4658
  entryHash: Uint8Array | number[];
@@ -90,7 +90,7 @@ export const idlFactory = ({ IDL }) => {
90
90
  Unavailable: IDL.Text,
91
91
  Conflict: IDL.Text,
92
92
  });
93
- const Result_89 = IDL.Variant({ Ok: AgentRecord, Err: Error });
93
+ const Result_90 = IDL.Variant({ Ok: AgentRecord, Err: Error });
94
94
  const Result_2 = IDL.Variant({ Ok: IDL.Null, Err: Error });
95
95
  const HttpHeader = IDL.Record({ value: IDL.Text, name: IDL.Text });
96
96
  const HttpRequestResult = IDL.Record({
@@ -111,7 +111,7 @@ export const idlFactory = ({ IDL }) => {
111
111
  cooloffEndsAtNs: IDL.Int,
112
112
  typeId: IDL.Vec(IDL.Nat8),
113
113
  });
114
- const Result_87 = IDL.Variant({ Ok: Eip712Registration, Err: Error });
114
+ const Result_88 = IDL.Variant({ Ok: Eip712Registration, Err: Error });
115
115
  const GuardianPermissions = IDL.Record({
116
116
  canFreezePayments: IDL.Bool,
117
117
  canRevokeAgents: IDL.Bool,
@@ -119,6 +119,14 @@ export const idlFactory = ({ IDL }) => {
119
119
  canPauseWrites: IDL.Bool,
120
120
  });
121
121
  const Result_15 = IDL.Variant({ Ok: IDL.Nat, Err: Error });
122
+ const Conversion = IDL.Record({
123
+ token: IDL.Text,
124
+ daysLeftBefore: IDL.Opt(IDL.Nat),
125
+ amountE6: IDL.Nat,
126
+ cyclesAdded: IDL.Nat,
127
+ finishedBeforeRemovalSeen: IDL.Bool,
128
+ });
129
+ const Result_86 = IDL.Variant({ Ok: Conversion, Err: Error });
122
130
  const MemorySource = IDL.Variant({
123
131
  sessionTranscript: IDL.Null,
124
132
  human: IDL.Null,
@@ -184,6 +192,12 @@ export const idlFactory = ({ IDL }) => {
184
192
  config: AlertConfig,
185
193
  });
186
194
  const Result_73 = IDL.Variant({ Ok: AlertStatus, Err: Error });
195
+ const AgentConvertRule = IDL.Record({
196
+ spacingSeconds: IDL.Nat,
197
+ minPerCallE6: IDL.Nat,
198
+ maxPerCallE6: IDL.Nat,
199
+ belowDays: IDL.Nat,
200
+ });
187
201
  const Result_66 = IDL.Variant({
188
202
  Ok: IDL.Record({ paths: IDL.Vec(IDL.Text) }),
189
203
  Err: Error,
@@ -1301,6 +1315,18 @@ export const idlFactory = ({ IDL }) => {
1301
1315
  byCaller: IDL.Vec(CallerSignatureCount),
1302
1316
  });
1303
1317
  const Result_7 = IDL.Variant({ Ok: SignatureCounts, Err: Error });
1318
+ const SaleNotice = IDL.Record({
1319
+ token: IDL.Text,
1320
+ txRef: IDL.Opt(IDL.Text),
1321
+ listingId: IDL.Text,
1322
+ kind: IDL.Variant({ service: IDL.Null, content: IDL.Null }),
1323
+ jobId: IDL.Opt(IDL.Text),
1324
+ network: IDL.Text,
1325
+ amountE6: IDL.Nat,
1326
+ receiptId: IDL.Text,
1327
+ buyer: IDL.Text,
1328
+ settledAtNs: IDL.Int,
1329
+ });
1304
1330
  const Result_6 = IDL.Variant({
1305
1331
  Ok: IDL.Record({ returned: IDL.Nat }),
1306
1332
  Err: Error,
@@ -1315,7 +1341,7 @@ export const idlFactory = ({ IDL }) => {
1315
1341
  const Result_1 = IDL.Variant({ Ok: TimersWake, Err: Error });
1316
1342
  const Engram = IDL.Service({
1317
1343
  about: IDL.Func([], [About], ['query']),
1318
- acceptAgentKeyNomination: IDL.Func([IDL.Principal], [Result_89], []),
1344
+ acceptAgentKeyNomination: IDL.Func([IDL.Principal], [Result_90], []),
1319
1345
  acceptSignIn: IDL.Func([], [Result_2], []),
1320
1346
  actionAlertTransform: IDL.Func(
1321
1347
  [
@@ -1349,12 +1375,13 @@ export const idlFactory = ({ IDL }) => {
1349
1375
  ackIrrevocable: IDL.Bool,
1350
1376
  }),
1351
1377
  ],
1352
- [Result_87],
1378
+ [Result_88],
1353
1379
  [],
1354
1380
  ),
1355
1381
  addGuardian: IDL.Func([IDL.Principal, IDL.Text, GuardianPermissions], [Result_2], []),
1356
1382
  addRecordNote: IDL.Func([IDL.Nat, IDL.Text], [Result_15], []),
1357
1383
  addSeller: IDL.Func([IDL.Text, IDL.Nat, IDL.Bool], [Result_11], []),
1384
+ agentConvertBalance: IDL.Func([IDL.Text, IDL.Opt(IDL.Nat)], [Result_86], []),
1358
1385
  appendMemory: IDL.Func([IDL.Text, IDL.Vec(IDL.Nat8), IDL.Opt(MemorySource)], [Result], []),
1359
1386
  applyCondense: IDL.Func([IDL.Nat], [Result_85], []),
1360
1387
  approveGuardian: IDL.Func([IDL.Principal], [Result_2], []),
@@ -1383,6 +1410,7 @@ export const idlFactory = ({ IDL }) => {
1383
1410
  freezePayments: IDL.Func([], [Result_2], []),
1384
1411
  freezePaymentsWithReason: IDL.Func([IDL.Text], [Result_2], []),
1385
1412
  getActionAlertStatus: IDL.Func([], [Result_73], ['query']),
1413
+ getAgentConvertRule: IDL.Func([], [AgentConvertRule], ['query']),
1386
1414
  getAgentRevisablePaths: IDL.Func([], [Result_66], ['query']),
1387
1415
  getAgentSeatWeeks: IDL.Func([IDL.Nat, IDL.Nat], [Result_82], ['query']),
1388
1416
  getAgentWriteReview: IDL.Func([], [Result_81], ['query']),
@@ -1644,6 +1672,7 @@ export const idlFactory = ({ IDL }) => {
1644
1672
  [Result_2],
1645
1673
  [],
1646
1674
  ),
1675
+ sysRecordSale: IDL.Func([SaleNotice], [Result_2], []),
1647
1676
  sysReturnUpgradeAdvance: IDL.Func(
1648
1677
  [
1649
1678
  IDL.Record({
@@ -1702,6 +1731,7 @@ export const init = ({ IDL }) => {
1702
1731
  IDL.Opt(
1703
1732
  IDL.Record({
1704
1733
  owner: IDL.Opt(IDL.Principal),
1734
+ recoveredAtNs: IDL.Opt(IDL.Int),
1705
1735
  registry: IDL.Opt(IDL.Principal),
1706
1736
  ownerSignIn: IDL.Opt(IDL.Principal),
1707
1737
  parent: IDL.Opt(IDL.Principal),