agl 43.9.0 → 43.10.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.
Files changed (147) hide show
  1. package/changelog.md +20 -0
  2. package/dist_serve/bundle.js +997 -975
  3. package/dist_serve/bundle.js.map +2 -2
  4. package/dist_ts/00_commitinfo_data.js +2 -2
  5. package/dist_ts/aglapi/aglapisurface.document.js +3 -3
  6. package/dist_ts/classes.accountsactions.d.ts +3 -1
  7. package/dist_ts/classes.accountsactions.js +17 -1
  8. package/dist_ts/classes.authstore.d.ts +6 -0
  9. package/dist_ts/classes.authstore.js +8 -1
  10. package/dist_ts/classes.controller.d.ts +7 -1
  11. package/dist_ts/classes.controller.js +39 -7
  12. package/dist_ts/classes.inferencegateway.js +7 -5
  13. package/dist_ts/classes.inferenceplacement.d.ts +1 -1
  14. package/dist_ts/classes.inferencerouter.d.ts +20 -3
  15. package/dist_ts/classes.inferencerouter.js +37 -10
  16. package/dist_ts/classes.inferenceservice.js +2 -2
  17. package/dist_ts/classes.mcpcallerregistry.d.ts +19 -1
  18. package/dist_ts/classes.mcpcallerregistry.js +33 -7
  19. package/dist_ts/classes.terminalcallers.d.ts +40 -0
  20. package/dist_ts/classes.terminalcallers.js +90 -0
  21. package/dist_ts/classes.terminalmanager.d.ts +20 -1
  22. package/dist_ts/classes.terminalmanager.js +36 -2
  23. package/dist_ts/classes.ticketnotifier.d.ts +2 -2
  24. package/dist_ts/classes.ticketnotifier.js +6 -4
  25. package/dist_ts/classes.ticketorderspread.d.ts +25 -0
  26. package/dist_ts/classes.ticketorderspread.js +52 -0
  27. package/dist_ts/classes.ticketstore.d.ts +60 -5
  28. package/dist_ts/classes.ticketstore.js +176 -40
  29. package/dist_ts/classes.workercallers.d.ts +40 -2
  30. package/dist_ts/classes.workercallers.js +156 -30
  31. package/dist_ts/fleet/classes.boardpump.d.ts +1 -1
  32. package/dist_ts/fleet/classes.boardpump.js +4 -2
  33. package/dist_ts/fleet/classes.claudeworkers.d.ts +18 -5
  34. package/dist_ts/fleet/classes.claudeworkers.js +105 -31
  35. package/dist_ts/fleet/classes.ticketeffects.d.ts +11 -0
  36. package/dist_ts/fleet/classes.ticketeffects.js +28 -1
  37. package/dist_ts/fleet/classes.workers.d.ts +23 -4
  38. package/dist_ts/fleet/classes.workers.js +65 -18
  39. package/dist_ts/fleet/functions.workervalidation.js +7 -4
  40. package/dist_ts/fleet/interfaces.workers.d.ts +16 -2
  41. package/dist_ts/fleet/interfaces.workers.js +8 -1
  42. package/dist_ts/functions.fleetworkercli.d.ts +3 -1
  43. package/dist_ts/functions.fleetworkercli.js +6 -2
  44. package/dist_ts/functions.inferencecli.js +4 -1
  45. package/dist_ts/functions.mcpfleetworkertools.js +3 -3
  46. package/dist_ts/functions.proxycapacity.d.ts +2 -1
  47. package/dist_ts/functions.proxycapacity.js +6 -3
  48. package/dist_ts/functions.proxycapacitycli.js +2 -2
  49. package/dist_ts/functions.workerprocessproof.d.ts +6 -0
  50. package/dist_ts/functions.workerprocessproof.js +8 -3
  51. package/dist_ts/interfaces.auth.d.ts +1 -1
  52. package/dist_ts/interfaces.auth.js +2 -1
  53. package/dist_ts/interfaces.flexipc.d.ts +3 -1
  54. package/dist_ts/interfaces.flexipc.js +1 -1
  55. package/dist_ts_authswitch/authority-contract.d.ts +25 -0
  56. package/dist_ts_authswitch/authority-contract.js +1 -1
  57. package/dist_ts_authswitch/authority-overview.d.ts +7 -0
  58. package/dist_ts_authswitch/authority-overview.js +10 -6
  59. package/dist_ts_authswitch/authority-placement.d.ts +5 -2
  60. package/dist_ts_authswitch/authority-placement.js +6 -3
  61. package/dist_ts_authswitch/classes.authoritybroker.d.ts +6 -0
  62. package/dist_ts_authswitch/classes.authoritybroker.js +26 -1
  63. package/dist_ts_authswitch/classes.authoritycli.d.ts +1 -0
  64. package/dist_ts_authswitch/classes.authoritycli.js +50 -4
  65. package/dist_ts_authswitch/classes.authorityclient.d.ts +3 -1
  66. package/dist_ts_authswitch/classes.authorityclient.js +9 -4
  67. package/dist_ts_authswitch/classes.authoritydaemon.js +7 -1
  68. package/dist_ts_authswitch/classes.authoritydatabase.js +5 -1
  69. package/dist_ts_authswitch/classes.authoritymodels.d.ts +7 -0
  70. package/dist_ts_authswitch/classes.authoritymodels.js +13 -6
  71. package/dist_ts_interfaces/fleetworkers.d.ts +26 -1
  72. package/dist_ts_interfaces/fleetworkers.js +1 -1
  73. package/dist_ts_interfaces/interfaces.d.ts +4 -2
  74. package/dist_ts_interfaces/interfaces.js +1 -1
  75. package/dist_ts_interfaces/mcprequests.d.ts +2 -1
  76. package/dist_ts_interfaces/mcprequests.js +3 -2
  77. package/dist_ts_interfaces/proxycapacity.d.ts +1 -1
  78. package/dist_ts_interfaces/requests.accounts.d.ts +19 -0
  79. package/dist_ts_interfaces/requests.accounts.js +1 -1
  80. package/dist_ts_interfaces/requests.d.ts +2 -2
  81. package/dist_ts_interfaces/requests.fleetworkers.d.ts +3 -1
  82. package/dist_ts_interfaces/requests.js +1 -1
  83. package/dist_ts_migration/classes.documentmigrationrunner.d.ts +8 -1
  84. package/dist_ts_migration/classes.documentmigrationrunner.js +11 -2
  85. package/dist_ts_migration/index.d.ts +1 -0
  86. package/dist_ts_migration/index.js +2 -1
  87. package/dist_ts_migration/v41_ticketclosedcolumn.js +7 -3
  88. package/dist_ts_migration/v43_ticketorderstride.d.ts +54 -0
  89. package/dist_ts_migration/v43_ticketorderstride.js +161 -0
  90. package/docs/authswitch.md +22 -0
  91. package/package.json +1 -1
  92. package/readme.md +71 -4
  93. package/ts/00_commitinfo_data.ts +1 -1
  94. package/ts/aglapi/aglapisurface.document.ts +2 -2
  95. package/ts/classes.accountsactions.ts +25 -0
  96. package/ts/classes.authstore.ts +9 -0
  97. package/ts/classes.controller.ts +37 -3
  98. package/ts/classes.inferencegateway.ts +6 -4
  99. package/ts/classes.inferenceplacement.ts +1 -1
  100. package/ts/classes.inferencerouter.ts +49 -10
  101. package/ts/classes.inferenceservice.ts +1 -1
  102. package/ts/classes.mcpcallerregistry.ts +49 -7
  103. package/ts/classes.terminalcallers.ts +91 -0
  104. package/ts/classes.terminalmanager.ts +41 -1
  105. package/ts/classes.ticketnotifier.ts +5 -3
  106. package/ts/classes.ticketorderspread.ts +50 -0
  107. package/ts/classes.ticketstore.ts +164 -35
  108. package/ts/classes.workercallers.ts +183 -30
  109. package/ts/fleet/classes.boardpump.ts +3 -2
  110. package/ts/fleet/classes.claudeworkers.ts +101 -29
  111. package/ts/fleet/classes.ticketeffects.ts +25 -0
  112. package/ts/fleet/classes.workers.ts +62 -17
  113. package/ts/fleet/functions.workervalidation.ts +6 -3
  114. package/ts/fleet/interfaces.workers.ts +16 -2
  115. package/ts/functions.fleetworkercli.ts +5 -1
  116. package/ts/functions.inferencecli.ts +2 -0
  117. package/ts/functions.mcpfleetworkertools.ts +2 -2
  118. package/ts/functions.proxycapacity.ts +5 -2
  119. package/ts/functions.proxycapacitycli.ts +1 -1
  120. package/ts/functions.workerprocessproof.ts +10 -2
  121. package/ts/interfaces.auth.ts +1 -0
  122. package/ts/interfaces.flexipc.ts +3 -1
  123. package/ts_authswitch/authority-contract.ts +20 -0
  124. package/ts_authswitch/authority-overview.ts +17 -6
  125. package/ts_authswitch/authority-placement.ts +7 -3
  126. package/ts_authswitch/classes.authoritybroker.ts +24 -0
  127. package/ts_authswitch/classes.authoritycli.ts +58 -4
  128. package/ts_authswitch/classes.authorityclient.ts +11 -4
  129. package/ts_authswitch/classes.authoritydaemon.ts +8 -1
  130. package/ts_authswitch/classes.authoritydatabase.ts +3 -0
  131. package/ts_authswitch/classes.authoritymodels.ts +12 -4
  132. package/ts_interfaces/fleetworkers.ts +26 -1
  133. package/ts_interfaces/interfaces.ts +4 -2
  134. package/ts_interfaces/mcprequests.ts +2 -1
  135. package/ts_interfaces/proxycapacity.ts +1 -1
  136. package/ts_interfaces/requests.accounts.ts +17 -0
  137. package/ts_interfaces/requests.fleetworkers.ts +3 -1
  138. package/ts_interfaces/requests.ts +2 -0
  139. package/ts_migration/classes.documentmigrationrunner.ts +12 -1
  140. package/ts_migration/index.ts +1 -0
  141. package/ts_migration/v41_ticketclosedcolumn.ts +6 -2
  142. package/ts_migration/v43_ticketorderstride.ts +156 -0
  143. package/ts_web/00_commitinfo_data.ts +1 -1
  144. package/ts_web/accounts.templates.ts +12 -2
  145. package/ts_web/classes.accountsreadmodel.ts +42 -6
  146. package/ts_web/elements.accounts.ts +45 -3
  147. package/ts_web/elements.harnesscontrollerapp.ts +6 -1
@@ -0,0 +1,161 @@
1
+ import * as plugins from './plugins.js';
2
+ import { TicketModel } from '../dist_ts/classes.ticketmodels.js';
3
+ import { TicketError, ticketOrderStride } from '../dist_ts/classes.ticketstore.js';
4
+ import { AuthError } from '../dist_ts/interfaces.auth.js';
5
+ import { ticketColumns } from '../dist_ts_interfaces/tickets.js';
6
+ import { TicketMigrationMarkerModel } from './v41_ticketmigrationmarkers.js';
7
+ export const ticketOrderStrideMigrationId = 'v43_ticketorderstride';
8
+ /** Ticket documents one query of a column reads. */
9
+ const pageRecords = 500;
10
+ /**
11
+ * The tickets one transaction moves at most. It runs on a live board and holds the board's fence while it writes them,
12
+ * so a mutation that meets it runs again once it commits: 64 keeps that wait short (on a fully loaded host, 200 tickets
13
+ * took 1.8 s in one transaction, and the engine's cost per write grows with its transaction).
14
+ */
15
+ const chunkTickets = 64;
16
+ /**
17
+ * The deadlines in a row one transaction may reach after it lost a write conflict, 20 s each, before the run ends: 60 s
18
+ * without a commit is a board the spread does not get through now, or a transaction too slow for its deadline.
19
+ */
20
+ const deadlinesInARow = 3;
21
+ /**
22
+ * Whether a transaction that the driver ran more than once, so that lost a write conflict, ended without committing at
23
+ * its deadline. `TicketStore.migrate` gives every transaction a deadline, and with one the client rejects with `timeout`
24
+ * when the driver's retries run out (never with `transaction_conflict`, which only a transaction without one meets).
25
+ */
26
+ const lostConflicts = (errorArg) => errorArg instanceof plugins.nosqldb.SmartdataPersistenceError
27
+ && errorArg.code === 'timeout';
28
+ /**
29
+ * AGL-1907: releases before kept each column's orders dense (0, 1, 2, …), so a placement before a ticket finds no free
30
+ * integer and moves a run of tickets by one. Once, every column's tickets take `(rank + 1) × ticketOrderStride` in their
31
+ * board order (by order, then by id, as the board breaks ties), so a placement finds the gap a stride leaves and writes
32
+ * one ticket.
33
+ *
34
+ * It runs after the controller is ready, in the background (`TicketOrderSpread`): the store is correct on dense orders,
35
+ * so nothing waits for it. Column by column in `ticketColumns` order, in transactions of at most `chunkTickets`
36
+ * tickets, each reading the column again. A ticket whose order rises moves after every one above it that rises, from
37
+ * the column's end down, and one whose order falls after every one below it that falls, from the column's head up (the
38
+ * rising ones first): each takes an order between its neighbours' orders as they stand, so the column keeps its board
39
+ * order after every transaction, and the next one, ranking the column again, finds the same ranks and only the tickets
40
+ * not yet moved. A spread column is a fixed point, so a run cut short starts again and finishes the rest; the
41
+ * transaction that completes the last column (`closed`) writes the marker, alone when nothing is left to move, and a
42
+ * later start does nothing whatever the board holds.
43
+ *
44
+ * Each transaction is a step of the ticket store (`TicketStore.migrate`): it takes the board fence every mutation takes
45
+ * and moves the revision of every ticket whose order it changes, and once it commits the store tells clients, devices
46
+ * and the board pump of the new revision and those tickets, as after a mutation. A mutation that meets a step re-runs,
47
+ * and a step that meets a mutation re-runs, as the driver re-runs every transaction that loses a write conflict. A
48
+ * transaction's first attempt reads its column before it takes the fence, so mutations go on while it reads and wait
49
+ * only for its writes; but then any mutation that commits while it reads makes it lose, and a busy board would starve
50
+ * it. An attempt after a lost one therefore takes the fence first: it waits for the mutations in flight, and the
51
+ * mutations that come after it wait for its read and its writes. A transaction that lost to a mutation and then reached the
52
+ * store's 20 s deadline runs again (nothing of it committed), up to `deadlinesInARow` deadlines in a row: a lost
53
+ * conflict does not prove the conflicts made it late (an attempt that won the fence may simply be too slow), so the
54
+ * next deadline in a row after them ends the run as any other failure does, and the next controller start continues
55
+ * it; every commit starts the count again. It changes nothing else of a ticket and adds no history, as the v41 migration did when it closed the released
56
+ * column's gaps.
57
+ */
58
+ export class TicketOrderStrideV43Migration {
59
+ database;
60
+ store;
61
+ constructor(database, store) {
62
+ this.database = database;
63
+ this.store = store;
64
+ }
65
+ /**
66
+ * Runs the spread to its end, one transaction after another, and answers the keys of the tickets whose order it
67
+ * moved, column by column, in the order it first moved them (a mutation that places a ticket before tickets already
68
+ * spread changes their ranks, so the run moves them again). `signalArg` ends it: the run rejects with the signal's
69
+ * reason, and the transaction in flight rolls back unless its commit was already sent.
70
+ */
71
+ async run(signalArg) {
72
+ if (!this.database)
73
+ throw new AuthError('not_initialized', 'The authentication store database is unavailable.');
74
+ if (await TicketMigrationMarkerModel.exact.findStoredOne({ id: ticketOrderStrideMigrationId }, { signal: signalArg }))
75
+ return [];
76
+ const spread = new Set();
77
+ for (const [index, columnId] of ticketColumns.entries()) {
78
+ const last = index === ticketColumns.length - 1;
79
+ /** Whether the column's next transaction lost a write conflict before: its attempts then take the fence first. */
80
+ let lost = false;
81
+ /** The deadlines the column's next transaction reached in a row since the last commit. */
82
+ let deadlines = 0;
83
+ while (true) {
84
+ signalArg.throwIfAborted();
85
+ let attempts = 0;
86
+ let result;
87
+ try {
88
+ result = await this.store.migrate((sessionArg, fenceArg) => {
89
+ attempts += 1;
90
+ return this.chunk(sessionArg, fenceArg, columnId, last ? spread : undefined, lost || attempts > 1);
91
+ }, signalArg);
92
+ }
93
+ catch (errorArg) {
94
+ // The driver ran it again after lost write conflicts until the deadline: it runs again, nothing committed,
95
+ // unless it reached `deadlinesInARow` deadlines without a commit.
96
+ if (attempts > 1 && lostConflicts(errorArg) && ++deadlines < deadlinesInARow) {
97
+ lost = true;
98
+ continue;
99
+ }
100
+ throw errorArg;
101
+ }
102
+ lost = false;
103
+ deadlines = 0;
104
+ for (const key of result.moved)
105
+ spread.add(key);
106
+ if (result.complete)
107
+ break;
108
+ }
109
+ }
110
+ return [...spread];
111
+ }
112
+ /**
113
+ * One attempt of a transaction: up to `chunkTickets` tickets of the column take their stride order, after the board
114
+ * fence, which an attempt after a lost one (`fenceFirstArg`) takes before it reads the column. With `markerArg` (the
115
+ * keys moved so far) the transaction that completes the column writes the marker too. Nothing outside the transaction
116
+ * changes here: the driver may run it again.
117
+ */
118
+ async chunk(sessionArg, fenceArg, columnIdArg, markerArg, fenceFirstArg) {
119
+ const options = { session: sessionArg };
120
+ if (fenceFirstArg)
121
+ await fenceArg();
122
+ const ranked = (await this.page(columnIdArg, sessionArg))
123
+ .sort((leftArg, rightArg) => leftArg.ticket.order - rightArg.ticket.order || (leftArg.id < rightArg.id ? -1 : 1))
124
+ .map((recordArg, rankArg) => ({ record: recordArg, order: (rankArg + 1) * ticketOrderStride }));
125
+ const moving = [...ranked.filter((entryArg) => entryArg.order > entryArg.record.ticket.order).reverse(),
126
+ ...ranked.filter((entryArg) => entryArg.order < entryArg.record.ticket.order)];
127
+ const taken = moving.slice(0, chunkTickets);
128
+ if (taken.length)
129
+ await fenceArg();
130
+ for (const { record, order } of taken) {
131
+ const moved = await TicketModel.exact.transition({ current: record, change: (modelArg) => {
132
+ modelArg.ticket = { ...modelArg.ticket, order, revision: (modelArg.ticket.revision ?? 0) + 1 };
133
+ } }, options);
134
+ if (moved.status !== 'transitioned')
135
+ throw new TicketError('concurrent_change', 'A ticket changed during the order spread.');
136
+ }
137
+ const moved = taken.map((entryArg) => entryArg.record.id);
138
+ const complete = moving.length === taken.length;
139
+ if (markerArg && complete) {
140
+ const inserted = await TicketMigrationMarkerModel.exact.insert({ id: ticketOrderStrideMigrationId, completedAt: new Date().toISOString(),
141
+ tickets: [...new Set([...markerArg, ...moved])] }, options);
142
+ if (inserted.status !== 'inserted')
143
+ throw new TicketError('concurrent_change', 'The order spread ran twice.');
144
+ }
145
+ return { ticketIds: moved, result: { moved, complete } };
146
+ }
147
+ /** Every ticket of a column, read by id a page at a time. */
148
+ async page(columnIdArg, sessionArg) {
149
+ const records = [];
150
+ let after;
151
+ while (true) {
152
+ const page = await TicketModel.exact.findStored({ filter: { 'ticket.columnId': columnIdArg, ...(after ? { id: { $gt: after } } : {}) },
153
+ sort: { id: 1 }, limit: pageRecords, session: sessionArg });
154
+ records.push(...page);
155
+ if (page.length < pageRecords)
156
+ return records;
157
+ after = page.at(-1).id;
158
+ }
159
+ }
160
+ }
161
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidjQzX3RpY2tldG9yZGVyc3RyaWRlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHNfbWlncmF0aW9uL3Y0M190aWNrZXRvcmRlcnN0cmlkZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLGNBQWMsQ0FBQztBQUN4QyxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDNUQsT0FBTyxFQUFFLFdBQVcsRUFBRSxpQkFBaUIsRUFBb0IsTUFBTSw4QkFBOEIsQ0FBQztBQUNoRyxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFDckQsT0FBTyxFQUFFLGFBQWEsRUFBc0IsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRixPQUFPLEVBQUUsMEJBQTBCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU3RSxNQUFNLENBQUMsTUFBTSw0QkFBNEIsR0FBRyx1QkFBdUIsQ0FBQztBQUVwRSxvREFBb0Q7QUFDcEQsTUFBTSxXQUFXLEdBQUcsR0FBRyxDQUFDO0FBQ3hCOzs7O0dBSUc7QUFDSCxNQUFNLFlBQVksR0FBRyxFQUFFLENBQUM7QUFPeEI7OztHQUdHO0FBQ0gsTUFBTSxlQUFlLEdBQUcsQ0FBQyxDQUFDO0FBRTFCOzs7O0dBSUc7QUFDSCxNQUFNLGFBQWEsR0FBRyxDQUFDLFFBQWlCLEVBQVcsRUFBRSxDQUFDLFFBQVEsWUFBWSxPQUFPLENBQUMsT0FBT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UFDLEVBQUUsTUFBTSxFQUFFLEVBQUUsaUJBQWlCLEVBQUUsV0FBVyxFQUFFLEdBQUcsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLEVBQUUsRUFBRSxFQUFFLEVBQUUsR0FBRyxFQUFFLEtBQUssRUFBRSxFQUFFLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFO2dCQUNwSSxJQUFJLEVBQUUsRUFBRSxFQUFFLEVBQUUsQ0FBQyxFQUFFLEVBQUUsS0FBSyxFQUFFLFdBQVcsRUFBRSxPQUFPLEVBQUUsVUFBVSxFQUFFLENBQUMsQ0FBQztZQUM5RCxPQUFPLENBQUMsSUFBSSxDQUFDLEdBQUcsSUFBSSxDQUFDLENBQUM7WUFDdEIsSUFBSSxJQUFJLENBQUMsTUFBTSxHQUFHLFdBQVc7Z0JBQUUsT0FBTyxPQUFPLENBQUM7WUFDOUMsS0FBSyxHQUFHLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUUsQ0FBQyxFQUFFLENBQUM7UUFDMUIsQ0FBQztJQUNILENBQUM7Q0FDRiJ9
@@ -328,6 +328,8 @@ authswitch account set <account-id> --lapses-at <date-time> [--json]
328
328
  authswitch account set <account-id> --clear-lapse [--json]
329
329
  authswitch account set <account-id> --priority [--json]
330
330
  authswitch account set <account-id> --clear-priority [--json]
331
+ authswitch account set <account-id> --pause [--json]
332
+ authswitch account set <account-id> --resume [--json]
331
333
  authswitch account set <account-id> --spend-limit <dollars> [--json]
332
334
  authswitch account set <account-id> --clear-spend-limit [--json]
333
335
  authswitch account set <account-id> --claude-code on|off [--json]
@@ -490,6 +492,26 @@ refuses the store while any account record holds one: run `authswitch account se
490
492
  account before downgrading, since a priority that ended is listed nowhere, yet its record keeps it until the account's
491
493
  next change.
492
494
 
495
+ `account set --pause` pauses an account (AGL-1933) at the revision `account list` reads just before
496
+ (`authswitch.authority.pause { accountId, expectedRevision, paused }`, `AuthSwitchClient.setAccountPause`); `--resume`
497
+ resumes it. The service sets the moment by its own clock and stores it as `pausedAt` in UTC; pausing a paused account
498
+ keeps the moment it was paused at. It has no end: the account stays paused until it is resumed. A paused account takes
499
+ no new work: `authSwitchPlacement` answers the eligibility `never` for it (its last parameter is `pausedAt`), whatever
500
+ its lifecycle and usage, and its score stays what its reading says. The AGL proxy leaves it out of every pool, moves a
501
+ session on it at its next request and refuses a request that reaches only paused accounts as `accounts_paused`.
502
+ Everything else about the account stays and keeps running: its sign-in's renewal, its usage readings, `maxUsagePercent`,
503
+ a reserve lift, its renewal and its lapse date. Pausing ends a priority the account holds, and
504
+ `authswitch.authority.priority` refuses a paused account with `invalid_input` (`The account is paused; resume it before
505
+ giving it priority.`). `account set` and `account list` print `paused since <ISO> (by the owner)`; `list` and `limits`
506
+ show `paused · never placed on` in place of the placement line (`--json`: `pausedAt` on the overview and each limit row,
507
+ null while it is not paused; `account list --json` carries it as `pausedAt`). The account record holds `pausedAt` only
508
+ while the account is paused: resuming removes the member, and so does the account's removal
509
+ (`AuthSwitchAuthorityDatabase.persistAccount`). An earlier service refuses the store while any account record holds
510
+ one: resume every account before downgrading. `account preuse --all` starts nothing on a paused account: it writes a
511
+ skip for each of its logins (`type: 'skipped'`, `reason: 'account_paused'`, in text `reason=account_paused`) and goes
512
+ on; `account preuse <account-id> <login-id>` on a paused account runs as on any other. A client of this release requires `pausedAt` on every account of a
513
+ snapshot (`assertCurrentSnapshot`), so it names an accounts service of an earlier release as outdated.
514
+
493
515
  A Claude account's reading states what its profile says of the subscription as facts (`summaryKey: 'subscription'`):
494
516
  `Subscription status` -- `organization.subscription_status` as received, then what it means from the one shared map
495
517
  (`authority-subscription.ts`, empty: no value is described yet, so each shows `(not described yet)`) -- and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agl",
3
- "version": "43.9.0",
3
+ "version": "43.10.1",
4
4
  "controllerUpgradeManagementVersion": 2,
5
5
  "controllerManagementProtocolVersion": 1,
6
6
  "controllerGatewaySourcesVersion": 1,
package/readme.md CHANGED
@@ -130,6 +130,7 @@ authswitch account set <account-id> --max-usage 80 # keep 20% of each usage wi
130
130
  authswitch account set <account-id> --lapses-at 2026-11-01T00:00:00Z # a canceled subscription ends then
131
131
  authswitch account set <account-id> --renews-at 2026-10-20T09:00:00Z # a Claude subscription renews monthly from then
132
132
  authswitch account set <account-id> --priority # use this account before any other for 24 hours (--clear-priority ends it)
133
+ authswitch account set <account-id> --pause # take no new work on this account until --resume
133
134
  authswitch account recheck <account-id> # read a Claude account now; a healthy read clears its payment problem
134
135
  authswitch --help
135
136
  ```
@@ -216,6 +217,32 @@ holds it only while it is set; an earlier accounts service refuses the store whi
216
217
  `authswitch account set <id> --clear-priority` on every account before downgrading: a priority that ran out is listed
217
218
  nowhere, yet its record keeps it until the account's next change.
218
219
 
220
+ Any account can be **paused**: until its owner resumes it, AGL places no new work on it. The proxy leaves a paused
221
+ account out of every pool, so no new session goes to it, whatever its usage would allow and not even as a last resort;
222
+ a session that runs on it moves to another account of its pool at its next request, as it does from an account that
223
+ left the pool (the placement journal says `left_pool`); and a request that reaches only paused accounts -- a pool whose
224
+ every account is paused, or a client restricted to a paused account, as a Flex session on its chosen ChatGPT account
225
+ is -- is refused with HTTP 503 `accounts_paused` and a message that says the account is paused and to resume it in AGL
226
+ Accounts. Nothing else about the account changes: its sign-in is renewed, its usage is read and its limits, reserve,
227
+ renewal and lapse date stay, so it takes work again the moment it is resumed. A pause has no end of its own. Pausing
228
+ ends a priority the account holds, and a paused account is given none. `authswitch account set <account-id> --pause`
229
+ pauses it and `--resume` resumes it (`authswitch.authority.pause`); the account's page in Settings → Accounts has
230
+ **Pause**, then **Resume**, under Placement (`controller.accounts.pause`, audited `accounts.pause`). The accounts
231
+ service sets the moment by its own clock and keeps it on the account (`pausedAt`). The account's row shows `Paused` as
232
+ its status and opens its second line with `paused`, and its page says since when in the browser's time; `authswitch
233
+ list` and `limits` show `paused · never placed on` (`--json`: `pausedAt`, null while it is not paused, with a placement
234
+ eligibility of `never`), `account list` says `paused since <ISO> (by the owner)`, and `agl proxy status` states the
235
+ account as `paused by the owner since <ISO>; takes no new session until it is resumed` with no placement rank
236
+ (`--json`: `pausedAt`). `agl proxy capacity` counts no paused account as a member of its pool. Flex lists a paused
237
+ ChatGPT account in its account pickers -- the composer's and every model picker's -- as `Paused. Resume it in Settings →
238
+ Accounts.`, not to be chosen (connection status `paused`); a conversation already on it keeps showing it so, is never
239
+ moved to another account, and a message on it is not sent, with the reason. The Accounts overview counts paused accounts
240
+ in a tile of their own (`Paused`), beside those that are ready, held back by usage and in need of you.
241
+ `authswitch account preuse --all` skips a paused account's logins by name (`reason=account_paused`); naming the account
242
+ and login still preuses it. The account record holds
243
+ `pausedAt` only while the account is paused; an earlier accounts service refuses the store while any account record
244
+ holds one, so resume every account before downgrading.
245
+
219
246
  Flex uses every OpenAI account the service holds with a login of its own: each is the Flex connection `flex:authority:<accountId>`, listed wherever Flex accounts are chosen. Flex keeps no login of its own.
220
247
 
221
248
  A Flex session on a ChatGPT account runs through AGL's inference proxy, on the controller's lease of that one account's pool (proxy client `flex`, policy `accountIds: [<accountId>]`): the account the session chose serves it, and the proxy authenticates as the account, applies its maximum usage and limits, and counts every answer's tokens in the [token usage](#token-usage) under the client `flex`. At the account's limit the run reports the limit and its reset; it never moves to another account. The account's model catalog is read by the proxy on that account too. The Flex child is given only the proxy's address and the lease credential, never an account token. When the proxy is not running, a Flex request on a ChatGPT account fails with `INFERENCE_PROXY_UNAVAILABLE`; there is no direct route to ChatGPT. An account whose access ChatGPT keeps rejecting, or the accounts service cannot renew, fails with `PROVIDER_REAUTH_REQUIRED`, repaired by signing it in again in **Settings → Accounts**. Removing an account ends the controller's lease of it at once.
@@ -1181,7 +1208,9 @@ Some state lives only in the MCP process, and a re-exec would lose it. While the
1181
1208
 
1182
1209
  ### Caller identity
1183
1210
 
1184
- Every MCP call carries the identity of the chat it serves, and the controller authorizes on that identity instead of on a task id supplied in the request. When AGL starts a chat it mints a per-start caller credential and writes it into that process's environment as `AGL_MCP_CALLER_CREDENTIAL`; the `agl mcp` server the chat launches reads it from the environment and presents it on the private endpoint. The credential is never an argument, never inheritable, never persisted, never logged, and never echoed in a response. It dies with the chat: a terminal exit, a task losing its exact managed identity, an OpenCode restart, or controller shutdown all revoke it, and the next start mints a new one.
1211
+ Every MCP call carries the identity of the chat it serves, and the controller authorizes on that identity instead of on a task id supplied in the request. When AGL starts a chat it mints a per-start caller credential and writes it into that process's environment as `AGL_MCP_CALLER_CREDENTIAL`; the `agl mcp` server the chat launches reads it from the environment and presents it on the private endpoint. The credential is never an argument, never forwarded through any other environment AGL builds, never persisted, never logged, and never echoed in a response. It dies with the chat: a terminal exit, a task losing its exact managed identity, an OpenCode restart, or controller shutdown all revoke it, and the next start mints a new one.
1212
+
1213
+ Inside a terminal every process inherits the credential, a daemon started from it that outlives the shell as well (Claude Code's background-job daemon, for one). So a terminal's credential is honoured only for a process that still runs inside the terminal: the terminal's start records its root process, the PTY child, by its process ID and start time; before each call the `agl mcp` server names its own process ID to the controller (the process enrollment fleet workers use, see [Fleet workers and watch](#fleet-workers-and-watch)); and a call is the terminal's only when that process holds the call's own loopback connection and the recorded root process, still the same one, is among its ancestors, read from the kernel at that call. A daemon that left the terminal (whose parent is now init), a process that never ran in it, a process naming another process's ID, and every process once the root process is gone call without an identity, exactly as with an unknown credential. A Claude Code background job started from a terminal therefore calls as the fleet worker that binds it, if any, and otherwise anonymously.
1185
1214
 
1186
1215
  A caller is one of three subjects:
1187
1216
 
@@ -1802,7 +1831,8 @@ registry no longer holds as it was `LIST_CURSOR_STALE`, never a silent restart.
1802
1831
  returns every full record unpaged, as `agl fleet worker list` and the private request do by
1803
1832
  default. `fleet_worker_get` (`name` or `id`) returns one worker's full record, archived ones
1804
1833
  included, with the native status, turn outcome and start, native wait and excerpt the controller
1805
- last observed.
1834
+ last observed. A worker whose MCP calls are refused its identity also carries `identity`
1835
+ (`unverified`, `reason`, `since`) in all of them, derived and never stored.
1806
1836
 
1807
1837
  The fleet's own refusals carry a code (AGL-1670), as a tool's error (`FLEET_UNAVAILABLE` when the
1808
1838
  fleet is closing or holds 512 jobs) or as a failed job's `errorCode` beside its `error`:
@@ -2335,7 +2365,7 @@ actor derived from verified controller authority, never an untrusted public iden
2335
2365
  - Landing/release may also supply `body`; its comment commits with the evidence and move.
2336
2366
 
2337
2367
  Only owner/driver may land or release, including on replay. The existing ticket rules and
2338
- contiguous source/destination ordering apply. Evidence links, moves, comments, activity,
2368
+ ordering apply. Evidence links, moves, comments, activity,
2339
2369
  the board revision and an immutable receipt commit in one database transaction through
2340
2370
  the client document models. A first application returns `applied: true`, its board
2341
2371
  `revision`, the ticket snapshot, affected `ticketIds` and optional `comment`; it emits one
@@ -2464,6 +2494,28 @@ that worker, not as the driver or anonymously:
2464
2494
  refusal read while the fleet adopted or re-bound a worker is not remembered.
2465
2495
  A bridge that gets a credential this way presents only it; without one, or when the controller
2466
2496
  rejects or fails the enrollment, it calls as before, with a caller credential it inherited, if any.
2497
+ An inherited terminal credential is honoured only for a process running inside that terminal
2498
+ (see [Caller identity](#caller-identity)), never for a background job its daemon runs.
2499
+ - A worker whose calls are refused its identity is shown, never silently left read-only. Only a
2500
+ call is evidence: when a fresh inventory identified a bridge's parent as the process of a live
2501
+ worker's job (by its process chain, or for a job re-proof) and its enrollment is refused for
2502
+ good, or the worker's refused calls since its last verified one span 60 seconds, the worker
2503
+ carries `identity: { unverified: true, reason, since }` in `agl fleet worker list` (indented and
2504
+ with `--json`), `fleet_worker_list` (summary and full), `fleet_worker_get` and the Driver view's
2505
+ workers, until its next verified call or until it is stopped, archived or re-bound. A worker the
2506
+ fleet itself refuses to identify (a lost or pending dispatch, not live, another profile home) is
2507
+ never shown this way: that is on its record already. `reason` is one of a fixed set of phrases,
2508
+ never error text, a path or an id. Once a worker shows, only a refusal for good for another
2509
+ reason changes the reason; a refusal that may pass never does. The controller derives it in
2510
+ memory from those calls alone, with no timer: a worker that does not call never shows it, and a
2511
+ restart forgets it until the bridge calls again. A job whose Claude Code release file was
2512
+ removed or replaced since it started (its process runs from the releases' directory, but the
2513
+ file fails the check) costs one inventory read to identify its worker; a shell or terminal
2514
+ parent never does and is never shown. Each reason a worker comes to show is noticed once on its
2515
+ ticket, by `AGL worker identity` in the driver role, with what the owner can do; the notice's key
2516
+ and its board receipt are durable, so a restarted controller never writes the same notice again,
2517
+ a notice whose write failed is written by the next `agl fleet reconcile` of the ticket or when
2518
+ the reason shows again, and the notice steers no session.
2467
2519
 
2468
2520
  The bridge exchanges credentials only through the private controller endpoint after Linux
2469
2521
  direct-loopback socket-inode ownership, approved executable/argv and current native
@@ -2665,7 +2717,22 @@ labels; null clears assignee/parentId. The provider closes over
2665
2717
  the selected project when creating tickets. Ordering is global within each column even
2666
2718
  when the board filters by project: always send the target ticket id, not a client-assigned
2667
2719
  order. A move returns **every** record whose order or column changed, including reordered
2668
- neighbors outside the project filter. The store allocates order and fences the sequence,
2720
+ neighbors outside the project filter. `order` is sparse: only its value relative to the other
2721
+ tickets of the column means anything, so never derive a position or a count from it. A ticket
2722
+ leaving a column changes no other ticket there, and a move usually changes only the ticket
2723
+ moved. Earlier releases kept each column's orders contiguous. Once a controller of this release
2724
+ is ready, a background run spreads them a stride apart, in board order, once (migration
2725
+ `v43_ticketorderstride`); the start never waits for it, and a stop ends it, to be continued at
2726
+ the next start. It writes at most 64 tickets per transaction, each transaction fenced on the
2727
+ board like a mutation: it moves the board revision and the revision of every ticket it
2728
+ reorders, adds no activity, and sends `tickets.changed` with those ticket ids once committed.
2729
+ While it runs, a client sees the board reload once per transaction and the `order` values of the
2730
+ column being spread change while the board order stays as it was; a mutation that meets one
2731
+ of its transactions is run again once that transaction commits and succeeds, so it can take a
2732
+ second or more while a large column is spread. A client editing
2733
+ with a ticket revision read before such a commit gets `ticket_revision_conflict`, as after any
2734
+ other change, and reloads the ticket.
2735
+ The store allocates order and fences the sequence,
2669
2736
  authorization and activity in the same embedded-database transaction. A failure leaves
2670
2737
  none of them changed. `outcome_unknown` requires reading before retrying a mutation.
2671
2738
 
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '43.9.0',
6
+ version: '43.10.1',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  }
@@ -5153,9 +5153,9 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
5153
5153
  "recheckAt"
5154
5154
  ],
5155
5155
  "additionalProperties": false,
5156
- "description": "An account the pool counts: a subscription sign-in of a counted plan that has not lapsed."
5156
+ "description": "An account the pool counts: a subscription sign-in of a counted plan that has not lapsed and is not paused."
5157
5157
  },
5158
- "declaration": "/** An account the pool counts: a subscription sign-in of a counted plan that has not lapsed. */\ninterface IProxyCapacityMember {\n /** The account's id (64 hex characters). */\n accountId: string;\n /** Its plan as its held reading states it, one the pool counts. */\n plan: string;\n state: TProxyCapacityMemberState;\n /** The headroom it adds to the room now: its headroom below its threshold while it takes new work, else 0. */\n headroom: number;\n /** The window its headroom is bound by; `null` without a usable reading with a counted window. */\n binding: IProxyCapacityWindow | null;\n /**\n * When the headroom it adds next grows, from its reading alone: the binding window's reset, or the moment it takes\n * work again (a provider 429's rest, a provider refusal, its windows' resets); `null` when it cannot grow or that\n * moment is unknown (a stale reading, a sign-in or payment problem).\n */\n growsAt: string | null;\n /** The headroom it adds from `growsAt` on, at most; `null` with it. */\n growsTo: number | null;\n /** When the account service reads an account it cannot judge now again, when it says; `null` otherwise. */\n recheckAt: string | null;\n}"
5158
+ "declaration": "/** An account the pool counts: a subscription sign-in of a counted plan that has not lapsed and is not paused. */\ninterface IProxyCapacityMember {\n /** The account's id (64 hex characters). */\n accountId: string;\n /** Its plan as its held reading states it, one the pool counts. */\n plan: string;\n state: TProxyCapacityMemberState;\n /** The headroom it adds to the room now: its headroom below its threshold while it takes new work, else 0. */\n headroom: number;\n /** The window its headroom is bound by; `null` without a usable reading with a counted window. */\n binding: IProxyCapacityWindow | null;\n /**\n * When the headroom it adds next grows, from its reading alone: the binding window's reset, or the moment it takes\n * work again (a provider 429's rest, a provider refusal, its windows' resets); `null` when it cannot grow or that\n * moment is unknown (a stale reading, a sign-in or payment problem).\n */\n growsAt: string | null;\n /** The headroom it adds from `growsAt` on, at most; `null` with it. */\n growsTo: number | null;\n /** When the account service reads an account it cannot judge now again, when it says; `null` otherwise. */\n recheckAt: string | null;\n}"
5159
5159
  },
5160
5160
  {
5161
5161
  "name": "IProxyCapacityPool",
@@ -30,6 +30,7 @@ import type {
30
30
  IReq_ControllerAccountsClaudeCode,
31
31
  IReq_ControllerAccountsRenewal,
32
32
  IReq_ControllerAccountsPriority,
33
+ IReq_ControllerAccountsPause,
33
34
  IReq_ControllerAccountsUsageGet,
34
35
  IReq_ControllerAccountsUsageRecheck,
35
36
  TControllerAccountBinding,
@@ -269,6 +270,18 @@ export class AccountsActions {
269
270
  }));
270
271
  },
271
272
  );
273
+ routerArg.addHandler<IReq_ControllerAccountsPause>(
274
+ 'controller.accounts.pause',
275
+ async (requestArg, toolsArg) => {
276
+ const request = assertRequestShape(requestArg, {
277
+ accountId: 'string', expectedRevision: 'number', paused: 'boolean',
278
+ }) as IReq_ControllerAccountsPause['request'];
279
+ // The audit names the action and the peer; the moment is the account's, which the accounts service journals.
280
+ return hostArg.runAudited(toolsArg?.localData, 'accounts.pause', async (signalArg) => ({
281
+ answer: await this.setPause(request, signalArg),
282
+ }));
283
+ },
284
+ );
272
285
  routerArg.addHandler<IReq_ControllerAccountsRemove>(
273
286
  'controller.accounts.remove',
274
287
  async (requestArg, toolsArg) => {
@@ -584,6 +597,18 @@ export class AccountsActions {
584
597
  return answer;
585
598
  }
586
599
 
600
+ /** Pauses an account, or resumes it, and answers once the projection shows it (AGL-1933). */
601
+ public async setPause(
602
+ requestArg: IReq_ControllerAccountsPause['request'],
603
+ signalArg: AbortSignal,
604
+ ): Promise<TControllerAccountsAnswer<plugins.authswitchAuthority.IAuthSwitchAccount>> {
605
+ const answer = await this.answer((clientArg) => clientArg.setAccountPause(
606
+ requestArg.accountId, requestArg.expectedRevision, requestArg.paused, signalArg,
607
+ ));
608
+ if (answer.state === 'done') await this.waitForAccountRevision(answer.value, signalArg);
609
+ return answer;
610
+ }
611
+
587
612
  /** Waits until the controller's projection shows the account at `accountArg`'s revision or later. */
588
613
  private async waitForAccountRevision(
589
614
  accountArg: plugins.authswitchAuthority.IAuthSwitchAccount,
@@ -69,6 +69,7 @@ import {
69
69
  import { ControllerIssuerIdentityModel } from './classes.issueridentitymodels.js';
70
70
  import { ControllerJobModel } from './classes.jobmodels.js';
71
71
  import { TicketModel, TicketBoardModel, TicketCommentModel, TicketActivityModel, TicketQuestionModel, TicketFleetEventModel } from './classes.ticketmodels.js';
72
+ import type { TicketStore } from './classes.ticketstore.js';
72
73
  import {
73
74
  ControllerSystemMetricsHistoryModel,
74
75
  listSystemMetricsHistoryPoints,
@@ -1637,6 +1638,14 @@ export class SmartDataAuthStore implements IAuthStore, IAuthStoreSessionIdentity
1637
1638
  return await new PostDatabaseDocumentMigrationRunner(this.database).runTicketActorNames();
1638
1639
  }
1639
1640
 
1641
+ /**
1642
+ * AGL-1907: once, every column's tickets take orders a stride apart in their board order, a step of `storeArg` at a
1643
+ * time on the live board, until `signalArg` ends it; answers the keys it moved. The controller runs it after `ready`.
1644
+ */
1645
+ public async migrateTicketOrderStride(storeArg: TicketStore, signalArg: AbortSignal): Promise<string[]> {
1646
+ return await new PostDatabaseDocumentMigrationRunner(this.database).runTicketOrderStride(storeArg, signalArg);
1647
+ }
1648
+
1640
1649
  /** The ticket migrations of a controller start, in the runner's order; answers what v41 moved and v43 renamed. */
1641
1650
  public async migrateTicketsAtStart(): Promise<{ closed: string[]; renamed: string[] }> {
1642
1651
  return await new PostDatabaseDocumentMigrationRunner(this.database).runTicketStart(ticketOwnerPrincipalId(await this.getState()));
@@ -594,6 +594,7 @@ import { ControllerJobStore } from './classes.jobstore.js';
594
594
  import { TicketStore, TicketError, type ITicketDeployTargetFacts } from './classes.ticketstore.js';
595
595
  import { TicketNotifier } from './classes.ticketnotifier.js';
596
596
  import { BoardPump, boardPumpActor } from './fleet/classes.boardpump.js';
597
+ import { TicketOrderSpread } from './classes.ticketorderspread.js';
597
598
  import { DeployError, DeployMonitor, closeDeployPlanTicket } from './fleet/classes.deploymonitor.js';
598
599
  import { packageRepositorySlug, readControllerBuild, type IFleetControllerBuild } from './fleet/functions.controllerbuild.js';
599
600
  import { runFleetCommand } from './fleet/classes.runtime.js';
@@ -3427,6 +3428,8 @@ export class OpenCodeController {
3427
3428
  claudeReleases: (releaseArg) => this.observeClaudeRelease(releaseArg, 'fleet'),
3428
3429
  // No controller event names a native thread; the Inbox reads the fleet connection's requests again.
3429
3430
  onNativeCodexAttention: () => this.inbox?.nativeAttentionChanged('codex'),
3431
+ // The views show a worker whose MCP calls run without its identity, as this controller's worker callers derive it (AGL-1888).
3432
+ callerIdentity: (workerIdArg) => this.workerCallers?.workerCallerIdentity(workerIdArg),
3430
3433
  ...(this.fleetWorkerLaunches ? { callers: this.fleetWorkerLaunches } : {}) });
3431
3434
  // The Driver view's direct reports, an open fleet worker and the session feed follow worker changes and newly observed statuses.
3432
3435
  this.fleetWorkers.watchViews(() => {
@@ -3967,6 +3970,7 @@ export class OpenCodeController {
3967
3970
  }
3968
3971
  private ticketNotifier?: TicketNotifier;
3969
3972
  private boardPump?: BoardPump;
3973
+ private ticketOrderSpread?: TicketOrderSpread;
3970
3974
  private deployMonitor?: DeployMonitor;
3971
3975
  /** What this controller was built from, read once: its dependency tree does not change while it runs. */
3972
3976
  private controllerBuild?: Promise<IFleetControllerBuild>;
@@ -11357,6 +11361,10 @@ export class OpenCodeController {
11357
11361
  : { agentSessionId: inputArg.agentSessionId }),
11358
11362
  });
11359
11363
  },
11364
+ // The credential is honoured only for a process running inside the terminal: one descending from this PTY child (AGL-1891).
11365
+ recordCallerProcess: (inputArg) => {
11366
+ this.mcpCallerRegistry.bindTerminalProcess(inputArg.credential, inputArg.process);
11367
+ },
11360
11368
  onTerminalsChanged: (projectIdArg) => {
11361
11369
  void this.pushControllerEvent({
11362
11370
  type: 'terminals.changed',
@@ -11578,7 +11586,9 @@ export class OpenCodeController {
11578
11586
  // its parent runs, from the same fleet's inventory and registry (AGL-1888).
11579
11587
  identifyClaudeProcess: async (request) => this.fleetWorkers
11580
11588
  ? await this.fleetWorkers.identifyCallerProcess(request)
11581
- : { state: 'refused', check: 'inventory', reason: 'the fleet is not running yet', forGood: false } });
11589
+ : { state: 'refused', check: 'inventory', reason: 'the fleet is not running yet', forGood: false },
11590
+ // A worker shown calling without its identity, or verified again: the fleet's views follow, and its ticket is noticed once per reason.
11591
+ workerIdentityChanged: (workerIdArg, identityArg) => { void this.fleetWorkers?.callerIdentityChanged(workerIdArg, identityArg); } });
11582
11592
  this.workerCallers = workerCallers;
11583
11593
  const mcpControllerHost = new ControllerMcpHost({
11584
11594
  controllerPort: runtimeConfig.controllerPort,
@@ -11641,6 +11651,7 @@ export class OpenCodeController {
11641
11651
  });
11642
11652
  this.startBoardPump();
11643
11653
  this.requireDeployMonitor().start();
11654
+ this.startTicketOrderSpread();
11644
11655
  void this.trackOperationPromise(this.normalizeTicketLinkRepos())
11645
11656
  .catch((errorArg) => console.error('Naming the repositories of ticket links as org/name failed.', errorArg));
11646
11657
  // Retained uploads of earlier controllers go once untouched for 24 h, even while no upload follows to sweep them.
@@ -13975,6 +13986,8 @@ export class OpenCodeController {
13975
13986
  this.driverService = undefined;
13976
13987
  });
13977
13988
  await stopPart(async () => { await this.fleetService?.close(); this.fleetService = undefined; });
13989
+ // Before the parts it tells of the tickets it moves, and long before the database closes.
13990
+ await stopPart(async () => { await this.ticketOrderSpread?.stop(); this.ticketOrderSpread = undefined; });
13978
13991
  await stopPart(async () => { await this.boardPump?.close(); this.boardPump = undefined; });
13979
13992
  await stopPart(async () => { await this.deployMonitor?.close(); this.deployMonitor = undefined; });
13980
13993
  await stopPart(async () => { await this.gatewayClient?.close(); this.gatewayClient = undefined; });
@@ -16846,6 +16859,7 @@ export class OpenCodeController {
16846
16859
  connection.status === 'active'
16847
16860
  || connection.status === 'reauthRequired'
16848
16861
  || connection.status === 'inHostCodex'
16862
+ || connection.status === 'paused'
16849
16863
  ))
16850
16864
  .map((connection) => this.toPublicProviderConnection(connection)),
16851
16865
  runtimeAvailable: response.runtimeAvailable,
@@ -18832,6 +18846,16 @@ export class OpenCodeController {
18832
18846
  }, signalArg);
18833
18847
  }
18834
18848
 
18849
+ /**
18850
+ * AGL-1907: once the controller is ready, the one background run that spreads the ticket orders a stride apart, a
18851
+ * ticket-store step at a time; the start never waits for it, and the stop ends it before the database closes.
18852
+ */
18853
+ private startTicketOrderSpread(): void {
18854
+ const authStore = this.requireAuthStore();
18855
+ this.ticketOrderSpread ??= new TicketOrderSpread((signalArg) => authStore.migrateTicketOrderStride(this.ticketStore, signalArg));
18856
+ this.ticketOrderSpread.start();
18857
+ }
18858
+
18835
18859
  /** AGL-210: the loop that finds stalled tickets and tells the driver, configured by `fleet.boardPump`. */
18836
18860
  private startBoardPump(): void {
18837
18861
  this.boardPump ??= new BoardPump({
@@ -21696,7 +21720,7 @@ export class OpenCodeController {
21696
21720
  /**
21697
21721
  * The usable Flex accounts in the order AGL's account placement takes a new conversation now
21698
21722
  * (`authSwitchPlacementOrder`, a priority account first), judged on each account's usage reading as
21699
- * the inference proxy judges it: an account at its limit or reserve, lapsed, or without a reading it
21723
+ * the inference proxy judges it: an account at its limit or reserve, lapsed, paused by its owner, or without a reading it
21700
21724
  * can be judged on takes none. A conversation keeps its account for its life, so accounts rank by their score and
21701
21725
  * headroom alone, with none counted as in flight. The Claude pool, which the proxy places inside,
21702
21726
  * comes last.
@@ -21738,7 +21762,9 @@ export class OpenCodeController {
21738
21762
  account.renewsAt,
21739
21763
  now,
21740
21764
  account.reserveLiftUntil,
21765
+ account.pausedAt,
21741
21766
  );
21767
+ // Lapsed, or paused by its owner (AGL-1933): no new conversation goes to it.
21742
21768
  if (placement.eligibility === 'never') return undefined;
21743
21769
  return {
21744
21770
  id: providerConnectionId,
@@ -22009,6 +22035,12 @@ export class OpenCodeController {
22009
22035
  remedy: 'accountSettings',
22010
22036
  };
22011
22037
  }
22038
+ if (connection?.status === 'paused') {
22039
+ return {
22040
+ reason: `Session Intelligence uses ${label}, but its account is paused. Resume it in Settings → Accounts.`,
22041
+ remedy: 'accountSettings',
22042
+ };
22043
+ }
22012
22044
  if (connection?.status === 'inHostCodex') {
22013
22045
  return {
22014
22046
  reason: `Session Intelligence uses ${label}, but its account runs this host's Codex. `
@@ -22257,7 +22289,8 @@ export class OpenCodeController {
22257
22289
  : !login
22258
22290
  ? undefined
22259
22291
  : login.health === 'ready' || login.health === 'refreshing' || login.health === 'retry_wait'
22260
- ? 'active'
22292
+ // Paused by its owner (AGL-1933): listed, and not to be chosen until it is resumed.
22293
+ ? accountArg.pausedAt !== null ? 'paused' : 'active'
22261
22294
  : 'reauthRequired';
22262
22295
  if (status === undefined) return [];
22263
22296
  return [{
@@ -26444,6 +26477,7 @@ export class OpenCodeController {
26444
26477
  connectionArg.status !== 'active'
26445
26478
  && connectionArg.status !== 'reauthRequired'
26446
26479
  && connectionArg.status !== 'inHostCodex'
26480
+ && connectionArg.status !== 'paused'
26447
26481
  ) {
26448
26482
  throw new Error('The Flex provider connection is not publicly listable.');
26449
26483
  }
@@ -381,12 +381,12 @@ const codexPlanType = (plansArg: readonly string[]): string | undefined => {
381
381
  };
382
382
 
383
383
  /**
384
- * The session's account cannot serve this client's pool: it left the pool, or the client's account restriction
385
- * leaves it out. The session moves to an account of the pool, as it does from an account at its limit.
384
+ * The session's account cannot serve this client's pool: it left the pool, its owner paused it (AGL-1933), or the
385
+ * client's account restriction leaves it out. The session moves to an account of the pool, as it does from an account at its limit.
386
386
  */
387
387
  const sessionAccountOutsidePool = (errorArg: unknown): boolean => errorArg instanceof InferenceRoutingError
388
388
  && (errorArg.code === 'account_left_pool' || errorArg.code === 'account_outside_restriction'
389
- || errorArg.code === 'account_lapsed');
389
+ || errorArg.code === 'account_lapsed' || errorArg.code === 'account_paused');
390
390
 
391
391
  /**
392
392
  * A Claude session's account takes no request for a reason of its own (`InferenceRoutingError.reason`): no usage reading,
@@ -398,7 +398,9 @@ const sessionAccountUnavailable = (errorArg: unknown, accountIdArg: string): boo
398
398
  /** Why a session's own account refused its request, as the placement journal names it; see `TInferencePlacementReason`. */
399
399
  const placementReason = (errorArg: InferenceRoutingError): TInferencePlacementReason =>
400
400
  errorArg.reason !== undefined ? 'unavailable'
401
- : errorArg.code === 'account_left_pool' ? 'left_pool'
401
+ // A paused account left the pool for as long as it is paused; the journal has no reason of its own for it, so an
402
+ // AGL that reads the journal after a rollback knows every reason in it.
403
+ : errorArg.code === 'account_left_pool' || errorArg.code === 'account_paused' ? 'left_pool'
402
404
  : errorArg.code === 'account_outside_restriction' ? 'outside_restriction'
403
405
  : errorArg.code === 'account_lapsed' ? 'lapsed' : errorArg.accountLimit ?? 'exhausted';
404
406
 
@@ -5,7 +5,7 @@ import { inferenceProviders, type TInferenceProvider } from './functions.proxyco
5
5
  * Why a session was placed on its account. `new`: the session had no account. Every other reason moved a session off
6
6
  * the account it had: `exhausted` (a window used up, or the provider refusing until a time it named), `reserved` (its
7
7
  * usage threshold reached), `cooling` (resting after a provider 429 another request met), `provider_429` (the provider
8
- * refused this request with a 429), `left_pool` (removed, signed out, or taken by a native tool), `outside_restriction`
8
+ * refused this request with a 429), `left_pool` (removed, signed out, taken by a native tool, or paused by its owner), `outside_restriction`
9
9
  * (the client's account restriction leaves it out), `lapsed` (its subscription ended), `unavailable` (an account that
10
10
  * takes no request for a reason of its own: no usage reading, no model list, no access, no such model, or a payment
11
11
  * problem) or `returned` (the session was on an API key, and a subscription of the pool could take its request again).