@aldus-runtime/gate-engine 0.2.0-next.21 → 0.2.0-next.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/spend.d.ts +41 -2
- package/dist/spend.d.ts.map +1 -1
- package/dist/spend.js.map +1 -1
- package/package.json +3 -3
- package/src/spend.ts +41 -2
package/dist/spend.d.ts
CHANGED
|
@@ -68,9 +68,48 @@ export interface SpendGrant {
|
|
|
68
68
|
* Absent reads as `"refuse"`.
|
|
69
69
|
*/
|
|
70
70
|
unestimatedExecution?: "refuse" | "reserve_max_per_request";
|
|
71
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Maximum total spend authorized across the Run (§13.2 "maximum authorized cost").
|
|
73
|
+
*
|
|
74
|
+
* **Two different things consume it**, and confusing them mis-sizes a grant in either direction:
|
|
75
|
+
*
|
|
76
|
+
* - **settled charges**, permanently — the actual `CostRecord` amounts;
|
|
77
|
+
* - **active and unresolved reservations**, at their *reserved* amount until they settle.
|
|
78
|
+
*
|
|
79
|
+
* `availableAuthorization` is `maxTotal − settled − active`, and on settlement a reservation
|
|
80
|
+
* stops being counted at what it reserved and starts being counted at what it actually cost —
|
|
81
|
+
* so **unused headroom returns**.
|
|
82
|
+
*
|
|
83
|
+
* That matters under `unestimatedExecution: "reserve_max_per_request"`, where each unestimated
|
|
84
|
+
* dispatch reserves the *whole* per-request ceiling because there is no smaller truthful number.
|
|
85
|
+
* `maxTotal ÷ maxPerRequest` bounds how many such dispatches can be **outstanding at once** — in
|
|
86
|
+
* flight, or with billing still unresolved. It does **not** bound the run: once they settle
|
|
87
|
+
* below the ceiling the difference is available again, and a $25 / $3 grant can authorize far
|
|
88
|
+
* more than eight sequential dispatches when each settles cheaply.
|
|
89
|
+
*
|
|
90
|
+
* Both readings mis-size a grant. Read as a lifetime pool it ignores that eight worst-case
|
|
91
|
+
* reservations can be outstanding before any of them settles; read as a concurrency bound alone
|
|
92
|
+
* it over-provisions a run whose charges are small. Measured by an adopter: a $3 / $3 grant
|
|
93
|
+
* permitted one dispatch and refused a case dispatching twice, with the budget almost untouched
|
|
94
|
+
* — because the first had not settled yet.
|
|
95
|
+
*/
|
|
72
96
|
maxTotal: Money;
|
|
73
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Maximum spend authorized for any single request (§19.3 "per-request ... limits").
|
|
99
|
+
*
|
|
100
|
+
* **What this means changed with ADR-0044 while its type did not.** It was a statement about
|
|
101
|
+
* what a *backend* enforces, so leaving it unset where the backend enforces nothing was the
|
|
102
|
+
* honest choice — binding a ceiling would have recorded a protection that did not exist.
|
|
103
|
+
*
|
|
104
|
+
* It is now what the *runtime reserves* before dispatch. Unset is still valid and still
|
|
105
|
+
* compiles, and under `unestimatedExecution: "reserve_max_per_request"` it makes every
|
|
106
|
+
* unestimated dispatch refuse, because there is no truthful amount to reserve
|
|
107
|
+
* (see {@link unestimatedPolicyIsSatisfiable}).
|
|
108
|
+
*
|
|
109
|
+
* Called out because the type system has nothing to say about a field whose meaning moved: an
|
|
110
|
+
* adopter migrating hit exactly this, and the comment in their own file argued for the choice
|
|
111
|
+
* that is now wrong.
|
|
112
|
+
*/
|
|
74
113
|
maxPerRequest?: Money;
|
|
75
114
|
}
|
|
76
115
|
/**
|
package/dist/spend.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spend.d.ts","sourceRoot":"","sources":["../src/spend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAa7B;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,eAAe,CAAC;AAEpD,8FAA8F;AAC9F,MAAM,WAAW,UAAU;IACzB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,iD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version":3,"file":"spend.js","sourceRoot":"","sources":["../src/spend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,GAIpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,aAAa,EACb,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"spend.js","sourceRoot":"","sources":["../src/spend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,GAIpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,aAAa,EACb,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,CAAC;AA0FpD;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,OAAO,kBAAkB,CAAC;QACxB,2FAA2F;QAC3F,wEAAwE;QACxE,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE;QACzD,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,IAAI,QAAQ;QAC5D,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,IAAI;KAC3C,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,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M;YACN,WAAW,EACT,YAAY,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,4BAA4B;gBACnE,GAAG,WAAW,CAAC,SAAS,CAAC,mCAAmC;gBAC5D,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,mBAAmB;SACtF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,MAAM;QACN,cAAc,EAAE,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC;KACzD,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aldus-runtime/gate-engine",
|
|
3
|
-
"version": "0.2.0-next.
|
|
3
|
+
"version": "0.2.0-next.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Aldus Gate Engine — hash-bound human gates, cascading invalidation, and spend authorization.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"typecheck:test": "tsc -p tsconfig.test.json"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@aldus-runtime/core": "0.2.0-next.
|
|
36
|
+
"@aldus-runtime/core": "0.2.0-next.23"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@aldus-runtime/testkit": "0.2.0-next.
|
|
39
|
+
"@aldus-runtime/testkit": "0.2.0-next.23",
|
|
40
40
|
"@types/node": "^26.2.0",
|
|
41
41
|
"typescript": "^7.0.2",
|
|
42
42
|
"vitest": "^4.1.10"
|
package/src/spend.ts
CHANGED
|
@@ -88,9 +88,48 @@ export interface SpendGrant {
|
|
|
88
88
|
* Absent reads as `"refuse"`.
|
|
89
89
|
*/
|
|
90
90
|
unestimatedExecution?: "refuse" | "reserve_max_per_request";
|
|
91
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Maximum total spend authorized across the Run (§13.2 "maximum authorized cost").
|
|
93
|
+
*
|
|
94
|
+
* **Two different things consume it**, and confusing them mis-sizes a grant in either direction:
|
|
95
|
+
*
|
|
96
|
+
* - **settled charges**, permanently — the actual `CostRecord` amounts;
|
|
97
|
+
* - **active and unresolved reservations**, at their *reserved* amount until they settle.
|
|
98
|
+
*
|
|
99
|
+
* `availableAuthorization` is `maxTotal − settled − active`, and on settlement a reservation
|
|
100
|
+
* stops being counted at what it reserved and starts being counted at what it actually cost —
|
|
101
|
+
* so **unused headroom returns**.
|
|
102
|
+
*
|
|
103
|
+
* That matters under `unestimatedExecution: "reserve_max_per_request"`, where each unestimated
|
|
104
|
+
* dispatch reserves the *whole* per-request ceiling because there is no smaller truthful number.
|
|
105
|
+
* `maxTotal ÷ maxPerRequest` bounds how many such dispatches can be **outstanding at once** — in
|
|
106
|
+
* flight, or with billing still unresolved. It does **not** bound the run: once they settle
|
|
107
|
+
* below the ceiling the difference is available again, and a $25 / $3 grant can authorize far
|
|
108
|
+
* more than eight sequential dispatches when each settles cheaply.
|
|
109
|
+
*
|
|
110
|
+
* Both readings mis-size a grant. Read as a lifetime pool it ignores that eight worst-case
|
|
111
|
+
* reservations can be outstanding before any of them settles; read as a concurrency bound alone
|
|
112
|
+
* it over-provisions a run whose charges are small. Measured by an adopter: a $3 / $3 grant
|
|
113
|
+
* permitted one dispatch and refused a case dispatching twice, with the budget almost untouched
|
|
114
|
+
* — because the first had not settled yet.
|
|
115
|
+
*/
|
|
92
116
|
maxTotal: Money;
|
|
93
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Maximum spend authorized for any single request (§19.3 "per-request ... limits").
|
|
119
|
+
*
|
|
120
|
+
* **What this means changed with ADR-0044 while its type did not.** It was a statement about
|
|
121
|
+
* what a *backend* enforces, so leaving it unset where the backend enforces nothing was the
|
|
122
|
+
* honest choice — binding a ceiling would have recorded a protection that did not exist.
|
|
123
|
+
*
|
|
124
|
+
* It is now what the *runtime reserves* before dispatch. Unset is still valid and still
|
|
125
|
+
* compiles, and under `unestimatedExecution: "reserve_max_per_request"` it makes every
|
|
126
|
+
* unestimated dispatch refuse, because there is no truthful amount to reserve
|
|
127
|
+
* (see {@link unestimatedPolicyIsSatisfiable}).
|
|
128
|
+
*
|
|
129
|
+
* Called out because the type system has nothing to say about a field whose meaning moved: an
|
|
130
|
+
* adopter migrating hit exactly this, and the comment in their own file argued for the choice
|
|
131
|
+
* that is now wrong.
|
|
132
|
+
*/
|
|
94
133
|
maxPerRequest?: Money;
|
|
95
134
|
}
|
|
96
135
|
|