@intelligo-dev/executions 1.0.0-beta.1 → 1.0.0-beta.13
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/NOTICE +6 -0
- package/README.md +121 -0
- package/dist/db/schema.d.ts +32 -21
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +23 -23
- package/dist/db/schema.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/lifecycle.d.ts +31 -5
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +179 -18
- package/dist/lifecycle.js.map +1 -1
- package/dist/ports.d.ts +33 -14
- package/dist/ports.d.ts.map +1 -1
- package/dist/ports.js +3 -8
- package/dist/ports.js.map +1 -1
- package/dist/pricing.d.ts +107 -137
- package/dist/pricing.d.ts.map +1 -1
- package/dist/pricing.js +129 -85
- package/dist/pricing.js.map +1 -1
- package/dist/queries.d.ts +39 -26
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +96 -39
- package/dist/queries.js.map +1 -1
- package/package.json +41 -13
- package/src/db/schema.ts +87 -0
- package/src/index.ts +73 -0
- package/src/lifecycle.ts +525 -0
- package/src/ports.ts +100 -0
- package/src/pricing.ts +322 -0
- package/src/queries.ts +235 -0
package/dist/lifecycle.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* const run = await executions.begin({ workspaceId, userId, capability });
|
|
5
5
|
* if (!run.allowed) return refuse(run.reason);
|
|
6
6
|
* try {
|
|
7
|
-
* const result = await
|
|
7
|
+
* const result = await supportAgent.generate(messages); // native
|
|
8
8
|
* await run.complete({ usage: result.usage, model: result.model });
|
|
9
9
|
* return result;
|
|
10
10
|
* } catch (error) {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* The handle knows nothing about agents, tools, messages, or streams —
|
|
16
16
|
* only actor, workspace, capability, entitlement, status, usage, cost,
|
|
17
|
-
* credits, and audit
|
|
17
|
+
* credits, and audit.
|
|
18
18
|
*
|
|
19
19
|
* Every terminal transition is idempotent: calling complete() twice, or
|
|
20
20
|
* fail() after complete(), leaves the first outcome in place. Streaming
|
|
@@ -26,7 +26,7 @@ import { db } from "@intelligo-dev/core/db";
|
|
|
26
26
|
import { createLogger } from "@intelligo-dev/core/logger";
|
|
27
27
|
import { recordAuditEvent } from "@intelligo-dev/audit";
|
|
28
28
|
import { and, eq } from "drizzle-orm";
|
|
29
|
-
import { executions } from "./db/schema";
|
|
29
|
+
import { executions } from "./db/schema.js";
|
|
30
30
|
const log = createLogger("Executions");
|
|
31
31
|
function errorMessage(error) {
|
|
32
32
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -45,7 +45,7 @@ export function createExecutions(ports = {}) {
|
|
|
45
45
|
model: input.model,
|
|
46
46
|
})
|
|
47
47
|
: { allowed: true };
|
|
48
|
-
|
|
48
|
+
const row = db.insert(executions).values({
|
|
49
49
|
id,
|
|
50
50
|
workspaceId: input.workspaceId,
|
|
51
51
|
userId: input.userId ?? null,
|
|
@@ -53,13 +53,31 @@ export function createExecutions(ports = {}) {
|
|
|
53
53
|
requestId,
|
|
54
54
|
status: decision.allowed ? "running" : "refused",
|
|
55
55
|
model: input.model ?? null,
|
|
56
|
-
|
|
56
|
+
reservedMicros: decision.estimated?.amount ?? null,
|
|
57
|
+
currency: decision.estimated?.currency ?? null,
|
|
57
58
|
refusalReason: decision.allowed ? null : (decision.reason ?? "refused"),
|
|
58
59
|
startedAt,
|
|
59
60
|
finishedAt: decision.allowed ? null : startedAt,
|
|
60
61
|
durationMs: decision.allowed ? null : 0,
|
|
61
62
|
metadata: input.metadata ?? null,
|
|
62
63
|
});
|
|
64
|
+
try {
|
|
65
|
+
await row;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
// No row means nothing will ever settle or release the hold
|
|
69
|
+
// entitlement just took (a reused `requestId` hits the unique
|
|
70
|
+
// index here), so give it back before failing.
|
|
71
|
+
if (decision.allowed && ports.releaseHold) {
|
|
72
|
+
await ports
|
|
73
|
+
.releaseHold({ workspaceId: input.workspaceId, requestId })
|
|
74
|
+
.catch((releaseError) => log.warn("Hold release failed after insert error", {
|
|
75
|
+
requestId,
|
|
76
|
+
error: errorMessage(releaseError),
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
63
81
|
const usingTrialCredits = decision.usingTrialCredits ?? false;
|
|
64
82
|
if (!decision.allowed) {
|
|
65
83
|
await recordAuditEvent({
|
|
@@ -72,6 +90,7 @@ export function createExecutions(ports = {}) {
|
|
|
72
90
|
metadata: {
|
|
73
91
|
capability: input.capability,
|
|
74
92
|
requestId,
|
|
93
|
+
code: decision.code,
|
|
75
94
|
reason: decision.reason,
|
|
76
95
|
},
|
|
77
96
|
});
|
|
@@ -79,8 +98,9 @@ export function createExecutions(ports = {}) {
|
|
|
79
98
|
id,
|
|
80
99
|
requestId,
|
|
81
100
|
allowed: false,
|
|
101
|
+
code: decision.code,
|
|
82
102
|
reason: decision.reason,
|
|
83
|
-
|
|
103
|
+
estimated: decision.estimated,
|
|
84
104
|
usingTrialCredits,
|
|
85
105
|
async complete() { },
|
|
86
106
|
async fail() { },
|
|
@@ -112,21 +132,28 @@ export function createExecutions(ports = {}) {
|
|
|
112
132
|
id,
|
|
113
133
|
requestId,
|
|
114
134
|
allowed: true,
|
|
115
|
-
|
|
135
|
+
estimated: decision.estimated,
|
|
116
136
|
usingTrialCredits,
|
|
117
137
|
async complete(result = {}) {
|
|
118
138
|
const inputTokens = result.usage?.inputTokens ?? 0;
|
|
119
139
|
const outputTokens = result.usage?.outputTokens ?? 0;
|
|
120
140
|
const totalTokens = result.usage?.totalTokens ?? inputTokens + outputTokens;
|
|
121
141
|
const model = result.model ?? input.model;
|
|
122
|
-
// Claim the right to settle BEFORE spending money
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
|
|
142
|
+
// Claim the right to settle BEFORE spending money, so a second
|
|
143
|
+
// complete() — or a complete() racing a fail() — cannot charge the
|
|
144
|
+
// workspace again.
|
|
145
|
+
// The usage is written with the claim, before any money moves,
|
|
146
|
+
// so a crash after this point leaves enough on the row for
|
|
147
|
+
// reconcile() to finish the job.
|
|
148
|
+
if (!(await transition("running", "settling", {
|
|
149
|
+
model: model ?? null,
|
|
150
|
+
inputTokens,
|
|
151
|
+
outputTokens,
|
|
152
|
+
totalTokens,
|
|
153
|
+
}))) {
|
|
128
154
|
return;
|
|
129
|
-
|
|
155
|
+
}
|
|
156
|
+
let charged;
|
|
130
157
|
if (ports.settleUsage) {
|
|
131
158
|
try {
|
|
132
159
|
const settled = await ports.settleUsage({
|
|
@@ -141,7 +168,7 @@ export function createExecutions(ports = {}) {
|
|
|
141
168
|
usingTrialCredits,
|
|
142
169
|
metadata: result.metadata ?? input.metadata,
|
|
143
170
|
});
|
|
144
|
-
|
|
171
|
+
charged = settled?.charged;
|
|
145
172
|
}
|
|
146
173
|
catch (error) {
|
|
147
174
|
// Usage is money: never silently drop it. The row stays
|
|
@@ -175,7 +202,10 @@ export function createExecutions(ports = {}) {
|
|
|
175
202
|
inputTokens,
|
|
176
203
|
outputTokens,
|
|
177
204
|
totalTokens,
|
|
178
|
-
|
|
205
|
+
chargedMicros: charged?.amount ?? null,
|
|
206
|
+
// Only a real charge names the currency; a free capability
|
|
207
|
+
// leaves whatever the hold wrote.
|
|
208
|
+
...(charged ? { currency: charged.currency } : {}),
|
|
179
209
|
}));
|
|
180
210
|
await recordAuditEvent({
|
|
181
211
|
workspaceId: input.workspaceId,
|
|
@@ -188,7 +218,7 @@ export function createExecutions(ports = {}) {
|
|
|
188
218
|
capability: input.capability,
|
|
189
219
|
model,
|
|
190
220
|
totalTokens,
|
|
191
|
-
|
|
221
|
+
charged,
|
|
192
222
|
},
|
|
193
223
|
});
|
|
194
224
|
},
|
|
@@ -231,6 +261,137 @@ export function createExecutions(ports = {}) {
|
|
|
231
261
|
},
|
|
232
262
|
};
|
|
233
263
|
}
|
|
234
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Finish an execution the happy path did not.
|
|
266
|
+
*
|
|
267
|
+
* `settling` has two readings — the charge never happened, or it
|
|
268
|
+
* committed and the process died before the final flip — and only
|
|
269
|
+
* the ledger can tell them apart, so the `findSettlement` port is
|
|
270
|
+
* asked first. A charge that exists is confirmed onto the row; one
|
|
271
|
+
* that does not is re-run from the usage the claim recorded. A
|
|
272
|
+
* `running` row older than `abandonRunningAfterMs` (the stream died
|
|
273
|
+
* without reaching complete()/fail()) is failed and its hold
|
|
274
|
+
* released; without that option `running` rows are left alone.
|
|
275
|
+
*
|
|
276
|
+
* Every transition is the same compare-and-swap the lifecycle uses,
|
|
277
|
+
* so a reconcile racing a late complete()/fail() cannot double
|
|
278
|
+
* charge or double release.
|
|
279
|
+
*/
|
|
280
|
+
async function reconcile(executionId, options = {}) {
|
|
281
|
+
const rows = await db
|
|
282
|
+
.select()
|
|
283
|
+
.from(executions)
|
|
284
|
+
.where(eq(executions.id, executionId))
|
|
285
|
+
.limit(1);
|
|
286
|
+
const row = rows[0];
|
|
287
|
+
if (!row)
|
|
288
|
+
return { action: "noop", status: "missing" };
|
|
289
|
+
const finish = (fields) => {
|
|
290
|
+
const finishedAt = new Date();
|
|
291
|
+
return {
|
|
292
|
+
finishedAt,
|
|
293
|
+
durationMs: finishedAt.getTime() - row.startedAt.getTime(),
|
|
294
|
+
...fields,
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
const cas = async (from, to, fields) => {
|
|
298
|
+
const updated = await db
|
|
299
|
+
.update(executions)
|
|
300
|
+
.set({ status: to, ...fields })
|
|
301
|
+
.where(and(eq(executions.id, executionId), eq(executions.status, from)))
|
|
302
|
+
.returning();
|
|
303
|
+
return updated.length > 0;
|
|
304
|
+
};
|
|
305
|
+
const audit = (how, extra = {}) => recordAuditEvent({
|
|
306
|
+
workspaceId: row.workspaceId,
|
|
307
|
+
actorId: null,
|
|
308
|
+
actorKind: "system",
|
|
309
|
+
action: "execution.reconciled",
|
|
310
|
+
resourceKind: "execution",
|
|
311
|
+
resourceId: executionId,
|
|
312
|
+
metadata: { requestId: row.requestId, how, ...extra },
|
|
313
|
+
});
|
|
314
|
+
if (row.status === "running") {
|
|
315
|
+
const cutoff = options.abandonRunningAfterMs;
|
|
316
|
+
if (cutoff === undefined ||
|
|
317
|
+
Date.now() - row.startedAt.getTime() < cutoff) {
|
|
318
|
+
return { action: "noop", status: "running" };
|
|
319
|
+
}
|
|
320
|
+
const moved = await cas("running", "failed", finish({ errorMessage: "abandoned: no completion within the cutoff" }));
|
|
321
|
+
if (!moved)
|
|
322
|
+
return { action: "noop", status: "running" };
|
|
323
|
+
if (ports.releaseHold) {
|
|
324
|
+
try {
|
|
325
|
+
await ports.releaseHold({
|
|
326
|
+
workspaceId: row.workspaceId,
|
|
327
|
+
requestId: row.requestId,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
catch (releaseError) {
|
|
331
|
+
log.warn("Hold release failed during reconcile", {
|
|
332
|
+
executionId,
|
|
333
|
+
error: errorMessage(releaseError),
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
await audit("abandoned");
|
|
338
|
+
return { action: "abandoned" };
|
|
339
|
+
}
|
|
340
|
+
if (row.status !== "settling") {
|
|
341
|
+
return { action: "noop", status: row.status };
|
|
342
|
+
}
|
|
343
|
+
if (!ports.findSettlement) {
|
|
344
|
+
// Without a way to ask the ledger, re-running settlement could
|
|
345
|
+
// charge a second time. Refuse to guess.
|
|
346
|
+
return {
|
|
347
|
+
action: "noop",
|
|
348
|
+
status: "settling",
|
|
349
|
+
reason: "no findSettlement port bound; cannot tell whether the charge exists",
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
const existing = await ports.findSettlement({
|
|
353
|
+
workspaceId: row.workspaceId,
|
|
354
|
+
requestId: row.requestId,
|
|
355
|
+
});
|
|
356
|
+
if (existing) {
|
|
357
|
+
const moved = await cas("settling", "succeeded", finish({
|
|
358
|
+
chargedMicros: existing.charged?.amount ?? null,
|
|
359
|
+
...(existing.charged ? { currency: existing.charged.currency } : {}),
|
|
360
|
+
}));
|
|
361
|
+
if (moved) {
|
|
362
|
+
await audit("confirmed", { charged: existing.charged });
|
|
363
|
+
}
|
|
364
|
+
return { action: "confirmed", charged: existing.charged };
|
|
365
|
+
}
|
|
366
|
+
if (!ports.settleUsage || row.totalTokens === null) {
|
|
367
|
+
return {
|
|
368
|
+
action: "noop",
|
|
369
|
+
status: "settling",
|
|
370
|
+
reason: "no usage recorded on the row to settle from",
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
const settled = await ports.settleUsage({
|
|
374
|
+
workspaceId: row.workspaceId,
|
|
375
|
+
userId: row.userId,
|
|
376
|
+
requestId: row.requestId,
|
|
377
|
+
capability: row.capability,
|
|
378
|
+
model: row.model ?? undefined,
|
|
379
|
+
inputTokens: row.inputTokens ?? 0,
|
|
380
|
+
outputTokens: row.outputTokens ?? 0,
|
|
381
|
+
totalTokens: row.totalTokens,
|
|
382
|
+
// Admission's pool choice is not on the row; a settlement port
|
|
383
|
+
// takes the pools in its own order rather than trusting this.
|
|
384
|
+
usingTrialCredits: false,
|
|
385
|
+
metadata: row.metadata ?? undefined,
|
|
386
|
+
});
|
|
387
|
+
const charged = settled?.charged;
|
|
388
|
+
await cas("settling", "succeeded", finish({
|
|
389
|
+
chargedMicros: charged?.amount ?? null,
|
|
390
|
+
...(charged ? { currency: charged.currency } : {}),
|
|
391
|
+
}));
|
|
392
|
+
await audit("settled", { charged });
|
|
393
|
+
return { action: "settled", charged };
|
|
394
|
+
}
|
|
395
|
+
return { begin, reconcile };
|
|
235
396
|
}
|
|
236
397
|
//# sourceMappingURL=lifecycle.js.map
|
package/dist/lifecycle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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AAG,CAAC,MAAM;YAClB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,SAAS;YAC7B,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC;YACjC,YAAY,EAAE,GAAG,CAAC,YAAY,IAAI,CAAC;YACnC,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,+DAA+D;YAC/D,8DAA8D;YAC9D,iBAAiB,EAAE,KAAK;YACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,SAAS;SACpC,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,CAAC;QACjC,MAAM,GAAG,CACP,UAAU,EACV,WAAW,EACX,MAAM,CAAC;YACL,aAAa,EAAE,OAAO,EAAE,MAAM,IAAI,IAAI;YACtC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACnD,CAAC,CACH,CAAC;QACF,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACpC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;IACxC,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAC9B,CAAC"}
|
package/dist/ports.d.ts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Ports the execution lifecycle depends on.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* entitlement decisions live in `entitlements` and the hold/settle
|
|
6
|
-
* mechanics in `credits`, neither of which exists yet. Rather than
|
|
7
|
-
* bake in a dependency that has to be unwound later, the lifecycle
|
|
8
|
-
* declares what it needs and the composition root binds today's
|
|
9
|
-
* billing implementations to it (ADR-0005).
|
|
2
|
+
* Ports the execution lifecycle depends on. `executions` must not
|
|
3
|
+
* import `billing`, so the lifecycle declares what it needs and the
|
|
4
|
+
* composition root binds billing's implementations to it.
|
|
10
5
|
*
|
|
11
6
|
* Both ports are optional: with neither bound, executions still record
|
|
12
7
|
* the lifecycle, they just don't gate or charge. That is what the
|
|
13
8
|
* reference app and any non-metered capability want.
|
|
14
9
|
*/
|
|
10
|
+
import type { Money } from "@intelligo-dev/core/money";
|
|
15
11
|
export type EntitlementDecision = {
|
|
16
12
|
allowed: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Stable, machine-readable refusal code from the entitlement port
|
|
15
|
+
* (e.g. billing's `insufficient_credits`), for transports to map to a
|
|
16
|
+
* status and to localize. Opaque to the lifecycle.
|
|
17
|
+
*/
|
|
18
|
+
code?: string;
|
|
17
19
|
/** Human-readable refusal, surfaced to the caller and recorded. */
|
|
18
20
|
reason?: string;
|
|
19
|
-
/** Worst-case charge held for this execution
|
|
20
|
-
|
|
21
|
+
/** Worst-case charge held for this execution. */
|
|
22
|
+
estimated?: Money;
|
|
21
23
|
/** True when the hold came out of the trial grant. */
|
|
22
24
|
usingTrialCredits?: boolean;
|
|
23
25
|
};
|
|
@@ -42,8 +44,12 @@ export type UsageSettlement = {
|
|
|
42
44
|
metadata?: Record<string, unknown>;
|
|
43
45
|
};
|
|
44
46
|
export type SettlementResult = {
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
+
/** What the port actually charged. */
|
|
48
|
+
charged?: Money;
|
|
49
|
+
};
|
|
50
|
+
export type SettlementQuery = {
|
|
51
|
+
workspaceId: string;
|
|
52
|
+
requestId: string;
|
|
47
53
|
};
|
|
48
54
|
export type ExecutionPorts = {
|
|
49
55
|
/**
|
|
@@ -52,10 +58,23 @@ export type ExecutionPorts = {
|
|
|
52
58
|
*/
|
|
53
59
|
checkEntitlement?: (request: EntitlementRequest) => Promise<EntitlementDecision>;
|
|
54
60
|
/**
|
|
55
|
-
* Record real usage and release the hold.
|
|
56
|
-
*
|
|
61
|
+
* Record real usage and release the hold. Must be idempotent per
|
|
62
|
+
* `requestId`: the lifecycle's compare-and-swap lets one complete()
|
|
63
|
+
* through, but `reconcile()` re-runs settlement for a row stuck in
|
|
64
|
+
* `settling`, and two reconciles — or a reconcile and a settlement
|
|
65
|
+
* still in flight — can reach it for the same request. A second call
|
|
66
|
+
* returns the first charge and debits nothing (billing's
|
|
67
|
+
* `recordTokenUsage` does this under the workspace lock).
|
|
57
68
|
*/
|
|
58
69
|
settleUsage?: (settlement: UsageSettlement) => Promise<SettlementResult | void>;
|
|
70
|
+
/**
|
|
71
|
+
* Answer "was this request already charged?" for `reconcile()`: a
|
|
72
|
+
* row stuck in `settling` may mean the charge never happened OR that
|
|
73
|
+
* it committed and the process died before the final status flip.
|
|
74
|
+
* Return the charge if one exists, null otherwise. Optional; without
|
|
75
|
+
* it, reconcile cannot tell the two apart and leaves the row alone.
|
|
76
|
+
*/
|
|
77
|
+
findSettlement?: (query: SettlementQuery) => Promise<SettlementResult | null>;
|
|
59
78
|
/**
|
|
60
79
|
* Release a hold without charging (run failed before producing
|
|
61
80
|
* usage). Optional: when absent, the hold is left to expire.
|
package/dist/ports.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,sDAAsD;IACtD,iBAAiB,CAAC,EAAE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C,CAAC;IAE9E;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB,CAAC"}
|
package/dist/ports.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Ports the execution lifecycle depends on.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* entitlement decisions live in `entitlements` and the hold/settle
|
|
6
|
-
* mechanics in `credits`, neither of which exists yet. Rather than
|
|
7
|
-
* bake in a dependency that has to be unwound later, the lifecycle
|
|
8
|
-
* declares what it needs and the composition root binds today's
|
|
9
|
-
* billing implementations to it (ADR-0005).
|
|
2
|
+
* Ports the execution lifecycle depends on. `executions` must not
|
|
3
|
+
* import `billing`, so the lifecycle declares what it needs and the
|
|
4
|
+
* composition root binds billing's implementations to it.
|
|
10
5
|
*
|
|
11
6
|
* Both ports are optional: with neither bound, executions still record
|
|
12
7
|
* the lifecycle, they just don't gate or charge. That is what the
|
package/dist/ports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|