stitchkit 0.71.0 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/application/admission.d.ts +22 -2
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/channel.d.ts +28 -0
- package/dist/application/channel.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-contract.d.ts +20 -0
- package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock.d.ts +17 -0
- package/dist/application/diagnostic-journal-lock.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-manager.d.ts +2 -1
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-storage.d.ts +4 -1
- package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
- package/dist/application/diagnostic-journal.d.ts +4 -2
- package/dist/application/diagnostic-journal.d.ts.map +1 -1
- package/dist/application-opentelemetry.js +1 -1
- package/dist/application.d.ts +3 -3
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +134 -21
- package/dist/browser/resumable.d.ts +56 -0
- package/dist/browser/resumable.d.ts.map +1 -0
- package/dist/{index-zpyj7hsv.js → index-3cwck0rm.js} +98 -33
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +103 -14
- package/dist/primitives/audit.d.ts +52 -0
- package/dist/primitives/audit.d.ts.map +1 -0
- package/dist/primitives/deadline.d.ts +39 -0
- package/dist/primitives/deadline.d.ts.map +1 -0
- package/dist/primitives/decimal.d.ts +10 -0
- package/dist/primitives/decimal.d.ts.map +1 -0
- package/dist/primitives/delivery.d.ts +96 -0
- package/dist/primitives/delivery.d.ts.map +1 -0
- package/dist/primitives/event.d.ts +42 -0
- package/dist/primitives/event.d.ts.map +1 -0
- package/dist/primitives/export-operation.d.ts +89 -0
- package/dist/primitives/export-operation.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +12 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/lifecycle.d.ts +90 -0
- package/dist/primitives/lifecycle.d.ts.map +1 -0
- package/dist/primitives/migration-checks.d.ts +15 -0
- package/dist/primitives/migration-checks.d.ts.map +1 -0
- package/dist/primitives/money.d.ts +43 -0
- package/dist/primitives/money.d.ts.map +1 -0
- package/dist/primitives/owner-scope.d.ts +30 -0
- package/dist/primitives/owner-scope.d.ts.map +1 -0
- package/dist/primitives/permission.d.ts +28 -0
- package/dist/primitives/permission.d.ts.map +1 -0
- package/dist/primitives/quantity.d.ts +57 -0
- package/dist/primitives/quantity.d.ts.map +1 -0
- package/dist/primitives.d.ts +3 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +750 -0
- package/llms-full.txt +246 -3
- package/llms.txt +1 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -518,7 +518,7 @@ The full guide and API reference, in [`docs/`](./docs/README.md):
|
|
|
518
518
|
contributors; [CONTRIBUTING.md](./CONTRIBUTING.md) points here.
|
|
519
519
|
- **[Architecture decisions](./docs/decisions/)** — the *why* behind the design.
|
|
520
520
|
- **[Roadmap](./ROADMAP.md)** · **[Changelog](./CHANGELOG.md)** ·
|
|
521
|
-
|
|
521
|
+
security via **[SECURITY.md](./SECURITY.md)**.
|
|
522
522
|
|
|
523
523
|
## License
|
|
524
524
|
|
|
@@ -5,6 +5,23 @@ export declare const BoundedRateBudgetSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
5
5
|
intervalMs: z.ZodNumber;
|
|
6
6
|
}, z.core.$strict>>;
|
|
7
7
|
export type BoundedRateBudget = z.infer<typeof BoundedRateBudgetSchema>;
|
|
8
|
+
export declare const BoundedAdmissionPerKeyLimitsSchema: z.ZodReadonly<z.ZodObject<{
|
|
9
|
+
maxConcurrent: z.ZodNumber;
|
|
10
|
+
rate: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
|
|
11
|
+
limit: z.ZodNumber;
|
|
12
|
+
intervalMs: z.ZodNumber;
|
|
13
|
+
}, z.core.$strict>>>;
|
|
14
|
+
}, z.core.$strict>>;
|
|
15
|
+
export type BoundedAdmissionPerKeyLimits = z.infer<typeof BoundedAdmissionPerKeyLimitsSchema>;
|
|
16
|
+
/**
|
|
17
|
+
* A ceiling declared per key rather than once for all keys.
|
|
18
|
+
*
|
|
19
|
+
* Resolved on a key's first admission and cached with its record, so a resolver that reads
|
|
20
|
+
* configuration is called once per live key rather than once per acquire. Eviction under
|
|
21
|
+
* `maxKeys` drops the record and the cached ceiling together, which is also how a changed
|
|
22
|
+
* configuration is adopted: evict the key, and the next admission resolves it again.
|
|
23
|
+
*/
|
|
24
|
+
export type BoundedAdmissionPerKeyLimitResolver = (key: string) => BoundedAdmissionPerKeyLimits;
|
|
8
25
|
export declare const BoundedAdmissionPolicySchema: z.ZodReadonly<z.ZodObject<{
|
|
9
26
|
global: z.ZodObject<{
|
|
10
27
|
maxConcurrent: z.ZodNumber;
|
|
@@ -13,14 +30,17 @@ export declare const BoundedAdmissionPolicySchema: z.ZodReadonly<z.ZodObject<{
|
|
|
13
30
|
intervalMs: z.ZodNumber;
|
|
14
31
|
}, z.core.$strict>>>;
|
|
15
32
|
}, z.core.$strict>;
|
|
16
|
-
perKey: z.ZodOptional<z.ZodObject<{
|
|
33
|
+
perKey: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
17
34
|
maxConcurrent: z.ZodNumber;
|
|
18
35
|
maxKeys: z.ZodNumber;
|
|
19
36
|
rate: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
|
|
20
37
|
limit: z.ZodNumber;
|
|
21
38
|
intervalMs: z.ZodNumber;
|
|
22
39
|
}, z.core.$strict>>>;
|
|
23
|
-
}, z.core.$strict
|
|
40
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
41
|
+
maxKeys: z.ZodNumber;
|
|
42
|
+
limits: z.ZodCustom<BoundedAdmissionPerKeyLimitResolver, BoundedAdmissionPerKeyLimitResolver>;
|
|
43
|
+
}, z.core.$strict>]>>;
|
|
24
44
|
}, z.core.$strict>>;
|
|
25
45
|
export type BoundedAdmissionPolicy = z.infer<typeof BoundedAdmissionPolicySchema>;
|
|
26
46
|
export declare const BoundedAdmissionStateSchema: z.ZodEnum<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../../src/application/admission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIhF,eAAO,MAAM,uBAAuB;;;mBAMvB,CAAC;AACd,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,4BAA4B
|
|
1
|
+
{"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../../src/application/admission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIhF,eAAO,MAAM,uBAAuB;;;mBAMvB,CAAC;AACd,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,kCAAkC;;;;;;mBAMlC,CAAC;AACd,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAE9F;;;;;;;GAOG;AACH,MAAM,MAAM,mCAAmC,GAAG,CAChD,GAAG,EAAE,MAAM,KACR,4BAA4B,CAAC;AAOlC,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;mBA+B5B,CAAC;AACd,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;A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A7D,YAA4B,MAAM,EAAE,WAAW,GAAG,WAAW,EAK5D;CACF;AAaD,uFAAuF;AACvF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,GAAG,gBAAgB,CAgTvF"}
|
|
@@ -80,6 +80,7 @@ export declare const CreditWindowSnapshotSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
80
80
|
acquired: z.ZodNumber;
|
|
81
81
|
refused: z.ZodNumber;
|
|
82
82
|
replenishedBytes: z.ZodNumber;
|
|
83
|
+
waiting: z.ZodNumber;
|
|
83
84
|
}, z.core.$strict>>;
|
|
84
85
|
export type CreditWindowSnapshot = z.infer<typeof CreditWindowSnapshotSchema>;
|
|
85
86
|
export interface CreditLease {
|
|
@@ -94,8 +95,35 @@ export type CreditAcquireResult = {
|
|
|
94
95
|
readonly outcome: 'refused';
|
|
95
96
|
readonly reason: 'closed' | 'larger-than-window' | 'insufficient-credit';
|
|
96
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* A waiting acquire's refusals.
|
|
100
|
+
*
|
|
101
|
+
* `insufficient-credit` is absent by construction: waiting is what the caller asked for instead
|
|
102
|
+
* of that answer. What remains are the conditions no amount of waiting changes — a closed window
|
|
103
|
+
* and a request larger than the window — plus the two ways a wait ends on the caller's terms.
|
|
104
|
+
*/
|
|
105
|
+
export type CreditWaitRefusalReason = 'closed' | 'larger-than-window' | 'timed-out' | 'aborted';
|
|
106
|
+
export type CreditWaitResult = {
|
|
107
|
+
readonly outcome: 'leased';
|
|
108
|
+
readonly lease: CreditLease;
|
|
109
|
+
} | {
|
|
110
|
+
readonly outcome: 'refused';
|
|
111
|
+
readonly reason: CreditWaitRefusalReason;
|
|
112
|
+
};
|
|
113
|
+
export interface CreditAcquireWaitOptions {
|
|
114
|
+
readonly signal?: AbortSignal;
|
|
115
|
+
/** Caller wait budget. Absent means wait until credit, close or abort. */
|
|
116
|
+
readonly timeoutMs?: number;
|
|
117
|
+
}
|
|
97
118
|
export interface CreditWindow {
|
|
119
|
+
/** Non-blocking: grants or refuses against the credit available right now. */
|
|
98
120
|
acquire(bytes: number): CreditAcquireResult;
|
|
121
|
+
/**
|
|
122
|
+
* Waiting: resolves when the consumer replenishes enough credit, or refuses with a named
|
|
123
|
+
* reason. Waiters are served in arrival order, so a large request ahead of a small one delays
|
|
124
|
+
* it rather than being overtaken — predictable ordering is worth more here than throughput.
|
|
125
|
+
*/
|
|
126
|
+
acquire(bytes: number, options: CreditAcquireWaitOptions): Promise<CreditWaitResult>;
|
|
99
127
|
close(): CreditWindowSnapshot;
|
|
100
128
|
getSnapshot(): CreditWindowSnapshot;
|
|
101
129
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/application/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,0BAA0B;;;EAAgC,CAAC;AACxE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,yBAAyB;;;;;EAAmD,CAAC;AAC1F,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;mBAe5B,CAAC;AACd,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACtC,2CAA2C;IAC3C,QAA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CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAA;CAAE,CAAC;AAE9E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAAC;IAC5C;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACrF,KAAK,IAAI,oBAAoB,CAAC;IAC9B,WAAW,IAAI,oBAAoB,CAAC;CACrC;AAOD,yFAAyF;AACzF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CA4J3F"}
|
|
@@ -7,6 +7,11 @@ export declare const DiagnosticJournalLimitsSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
7
7
|
maxFiles: z.ZodNumber;
|
|
8
8
|
}, z.core.$strict>>;
|
|
9
9
|
export type DiagnosticJournalLimits = z.infer<typeof DiagnosticJournalLimitsSchema>;
|
|
10
|
+
export declare const DiagnosticJournalLockPolicySchema: z.ZodEnum<{
|
|
11
|
+
"reclaim-stale": "reclaim-stale";
|
|
12
|
+
refuse: "refuse";
|
|
13
|
+
}>;
|
|
14
|
+
export type DiagnosticJournalLockPolicy = z.infer<typeof DiagnosticJournalLockPolicySchema>;
|
|
10
15
|
export declare const DiagnosticJournalStateSchema: z.ZodEnum<{
|
|
11
16
|
closed: "closed";
|
|
12
17
|
draining: "draining";
|
|
@@ -44,6 +49,13 @@ export declare const DiagnosticJournalStatusSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
44
49
|
maxFileBytes: z.ZodNumber;
|
|
45
50
|
maxFiles: z.ZodNumber;
|
|
46
51
|
}, z.core.$strict>>;
|
|
52
|
+
lock: z.ZodReadonly<z.ZodObject<{
|
|
53
|
+
policy: z.ZodEnum<{
|
|
54
|
+
"reclaim-stale": "reclaim-stale";
|
|
55
|
+
refuse: "refuse";
|
|
56
|
+
}>;
|
|
57
|
+
reclaimedStale: z.ZodBoolean;
|
|
58
|
+
}, z.core.$strict>>;
|
|
47
59
|
received: z.ZodNumber;
|
|
48
60
|
accepted: z.ZodNumber;
|
|
49
61
|
refused: z.ZodNumber;
|
|
@@ -148,6 +160,14 @@ export interface DiagnosticJournalConfig<SCHEMA extends z.ZodType> {
|
|
|
148
160
|
readonly limits: DiagnosticJournalLimits;
|
|
149
161
|
/** Created file and lock permissions. Default `0o600`. */
|
|
150
162
|
readonly mode?: number;
|
|
163
|
+
/**
|
|
164
|
+
* What to do about a lock that is already present. Default `refuse`.
|
|
165
|
+
*
|
|
166
|
+
* `reclaim-stale` reclaims it only when the recorded owner is provably gone — a liveness
|
|
167
|
+
* check, never an age heuristic, because a slow writer and a dead one are indistinguishable
|
|
168
|
+
* by time and the lock exists for exactly that case.
|
|
169
|
+
*/
|
|
170
|
+
readonly lock?: DiagnosticJournalLockPolicy;
|
|
151
171
|
/** Diagnostics are isolated and are never written back into this journal. */
|
|
152
172
|
readonly onFailure?: (failure: DiagnosticJournalFailure) => void | Promise<void>;
|
|
153
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic-journal-contract.d.ts","sourceRoot":"","sources":["../../src/application/diagnostic-journal-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,6BAA6B;;;;;;mBAS7B,CAAC;AACd,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,eAAO,MAAM,4BAA4B;;;;;EAAm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I,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,2BAA2B,CAAC;IAC5C,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClF;AAED,MAAM,WAAW,iBAAiB,CAAC,KAAK;IACtC,6EAA6E;IAC7E,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,6BAA6B,CAAC;IACpD,8FAA8F;IAC9F,KAAK,CAAC,OAAO,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACpF,SAAS,IAAI,uBAAuB,CAAC;IACrC,kGAAkG;IAClG,KAAK,CAAC,OAAO,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;CACtF;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE3E"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { open } from 'node:fs/promises';
|
|
2
|
+
import type { DiagnosticJournalLockPolicy } from './diagnostic-journal-contract.js';
|
|
3
|
+
type FileHandle = Awaited<ReturnType<typeof open>>;
|
|
4
|
+
export interface AcquiredDiagnosticJournalLock {
|
|
5
|
+
readonly handle: FileHandle;
|
|
6
|
+
readonly reclaimedStale: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Take the journal's exclusive lock under the configured policy.
|
|
10
|
+
*
|
|
11
|
+
* `refuse` is the default and rethrows the `EEXIST` a present lock produces. `reclaim-stale`
|
|
12
|
+
* rethrows that same error unless the recorded owner is provably gone, so it is a strict superset
|
|
13
|
+
* of `refuse`: every refusal a caller sees today it still sees, with the identical error.
|
|
14
|
+
*/
|
|
15
|
+
export declare function acquireDiagnosticJournalLock(lockPath: string, mode: number, policy: DiagnosticJournalLockPolicy): Promise<AcquiredDiagnosticJournalLock>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=diagnostic-journal-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-journal-lock.d.ts","sourceRoot":"","sources":["../../src/application/diagnostic-journal-lock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAU,MAAM,kBAAkB,CAAC;AAGhD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAEjF,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;AAEnD,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC;AAqED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,6BAA6B,CAAC,CAiBxC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { type DiagnosticJournal, type DiagnosticJournalFailure, type DiagnosticJournalLimits } from './diagnostic-journal-contract.js';
|
|
2
|
+
import { type DiagnosticJournal, type DiagnosticJournalFailure, type DiagnosticJournalLimits, type DiagnosticJournalStatus } from './diagnostic-journal-contract.js';
|
|
3
3
|
import { type DiagnosticJournalStorage } from './diagnostic-journal-storage.js';
|
|
4
4
|
interface DiagnosticJournalManagerConfig<SCHEMA extends z.ZodType> {
|
|
5
5
|
readonly eventSchema: SCHEMA;
|
|
6
6
|
readonly epoch: string;
|
|
7
7
|
readonly limits: DiagnosticJournalLimits;
|
|
8
|
+
readonly lock: DiagnosticJournalStatus['lock'];
|
|
8
9
|
readonly onFailure?: (failure: DiagnosticJournalFailure) => void | Promise<void>;
|
|
9
10
|
}
|
|
10
11
|
export declare function createDiagnosticJournalManager<SCHEMA extends z.ZodType>(config: DiagnosticJournalManagerConfig<SCHEMA>, storage: DiagnosticJournalStorage): DiagnosticJournal<z.input<SCHEMA>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic-journal-manager.d.ts","sourceRoot":"","sources":["../../src/application/diagnostic-journal-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAG7B,KAAK,uBAAuB,
|
|
1
|
+
{"version":3,"file":"diagnostic-journal-manager.d.ts","sourceRoot":"","sources":["../../src/application/diagnostic-journal-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAG7B,KAAK,uBAAuB,EAI5B,KAAK,uBAAuB,EAK7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,wBAAwB,EAE9B,MAAM,8BAA8B,CAAC;AAEtC,UAAU,8BAA8B,CAAC,MAAM,SAAS,CAAC,CAAC,OAAO;IAC/D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClF;AAiBD,wBAAgB,8BAA8B,CAAC,MAAM,SAAS,CAAC,CAAC,OAAO,EACrE,MAAM,EAAE,8BAA8B,CAAC,MAAM,CAAC,EAC9C,OAAO,EAAE,wBAAwB,GAChC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAgOpC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DiagnosticJournalFailurePhase } from './diagnostic-journal-contract.js';
|
|
1
|
+
import type { DiagnosticJournalFailurePhase, DiagnosticJournalLockPolicy } from './diagnostic-journal-contract.js';
|
|
2
2
|
export interface DiagnosticJournalStorageSnapshot {
|
|
3
3
|
readonly currentFileBytes: number;
|
|
4
4
|
readonly retainedFiles: number;
|
|
@@ -9,6 +9,8 @@ export interface DiagnosticJournalStorageAppendResult extends DiagnosticJournalS
|
|
|
9
9
|
readonly rotated: boolean;
|
|
10
10
|
}
|
|
11
11
|
export interface DiagnosticJournalStorage {
|
|
12
|
+
/** This storage took its lock by reclaiming one whose owner was provably gone. */
|
|
13
|
+
readonly reclaimedStale: boolean;
|
|
12
14
|
append(bytes: Uint8Array): Promise<DiagnosticJournalStorageAppendResult>;
|
|
13
15
|
snapshot(): DiagnosticJournalStorageSnapshot;
|
|
14
16
|
close(): Promise<void>;
|
|
@@ -22,6 +24,7 @@ interface RotatingStorageConfig {
|
|
|
22
24
|
readonly maxFileBytes: number;
|
|
23
25
|
readonly maxFiles: number;
|
|
24
26
|
readonly mode: number;
|
|
27
|
+
readonly lock: DiagnosticJournalLockPolicy;
|
|
25
28
|
}
|
|
26
29
|
/** One exclusive local writer. The lock is deliberately not a cross-crash lease. */
|
|
27
30
|
export declare function createRotatingDiagnosticJournalStorage(config: RotatingStorageConfig): Promise<DiagnosticJournalStorage>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic-journal-storage.d.ts","sourceRoot":"","sources":["../../src/application/diagnostic-journal-storage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"diagnostic-journal-storage.d.ts","sourceRoot":"","sources":["../../src/application/diagnostic-journal-storage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,6BAA6B,EAC7B,2BAA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* `flush()` observes completed append calls, not an fsync or durable-delivery receipt. One live
|
|
7
|
-
* manager exclusively owns the injected path; an abrupt process death
|
|
8
|
-
*
|
|
7
|
+
* manager exclusively owns the injected path; an abrupt process death leaves its `.lock` file
|
|
8
|
+
* behind. By default an operator removes it after proving the previous owner is gone; `lock:
|
|
9
|
+
* 'reclaim-stale'` makes the journal prove that itself, which is what an unattended service
|
|
10
|
+
* restarted by its supervisor needs.
|
|
9
11
|
*/
|
|
10
12
|
export declare function createDiagnosticJournal<SCHEMA extends z.ZodType>(config: DiagnosticJournalConfig<SCHEMA>): Promise<DiagnosticJournal<z.input<SCHEMA>>>;
|
|
11
13
|
//# sourceMappingURL=diagnostic-journal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic-journal.d.ts","sourceRoot":"","sources":["../../src/application/diagnostic-journal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,
|
|
1
|
+
{"version":3,"file":"diagnostic-journal.d.ts","sourceRoot":"","sources":["../../src/application/diagnostic-journal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAI7B,MAAM,+BAA+B,CAAC;AAIvC;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAAC,MAAM,SAAS,CAAC,CAAC,OAAO,EACpE,MAAM,EAAE,uBAAuB,CAAC,MAAM,CAAC,GACtC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAoB7C"}
|
package/dist/application.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { type ActivityId, ActivityIdSchema, type ActivityLiveState, ActivityLiveStateSchema, type ActivityProjection, type ActivityProjectionConfig, type ActivityProjectionSubscriberError, type ActivitySnapshot, ActivitySnapshotSchema, type ActivityStageId, ActivityStageIdSchema, type ActivityStageSnapshot, ActivityStageSnapshotSchema, type ActivityToken, ActivityTokenBrand, type ActivityTransition, createActivityProjection, } from './application/activity.js';
|
|
2
|
-
export { type BoundedAdmission, type BoundedAdmissionClock, type BoundedAdmissionConfig, type BoundedAdmissionDrainOptions, type BoundedAdmissionDrainResult, type BoundedAdmissionForceResult, type BoundedAdmissionLeaseResult, type BoundedAdmissionPolicy, BoundedAdmissionPolicySchema, BoundedAdmissionRefusalError, type BoundedAdmissionRefusalReason, BoundedAdmissionRefusalReasonSchema, type BoundedAdmissionRefusedResult, type BoundedAdmissionResult, type BoundedAdmissionSnapshot, BoundedAdmissionSnapshotSchema, type BoundedAdmissionState, BoundedAdmissionStateSchema, type BoundedOperationLease, type BoundedOperationRunContext, type BoundedOperationRunOptions, BoundedOperationWaitError, type BoundedRateBudget, BoundedRateBudgetSchema, createBoundedAdmission, } from './application/admission.js';
|
|
3
|
-
export { type BoundedChannel, type BoundedChannelCloseOptions, type BoundedChannelConfig, type BoundedChannelOfferResult, type BoundedChannelPolicy, BoundedChannelPolicySchema, BoundedChannelReaderError, type BoundedChannelSnapshot, BoundedChannelSnapshotSchema, type BoundedChannelState, BoundedChannelStateSchema, type CreditAcquireResult, type CreditLease, type CreditWindow, type CreditWindowSnapshot, CreditWindowSnapshotSchema, createBoundedChannel, createCreditWindow, } from './application/channel.js';
|
|
2
|
+
export { type BoundedAdmission, type BoundedAdmissionClock, type BoundedAdmissionConfig, type BoundedAdmissionDrainOptions, type BoundedAdmissionDrainResult, type BoundedAdmissionForceResult, type BoundedAdmissionLeaseResult, type BoundedAdmissionPerKeyLimitResolver, type BoundedAdmissionPerKeyLimits, BoundedAdmissionPerKeyLimitsSchema, type BoundedAdmissionPolicy, BoundedAdmissionPolicySchema, BoundedAdmissionRefusalError, type BoundedAdmissionRefusalReason, BoundedAdmissionRefusalReasonSchema, type BoundedAdmissionRefusedResult, type BoundedAdmissionResult, type BoundedAdmissionSnapshot, BoundedAdmissionSnapshotSchema, type BoundedAdmissionState, BoundedAdmissionStateSchema, type BoundedOperationLease, type BoundedOperationRunContext, type BoundedOperationRunOptions, BoundedOperationWaitError, type BoundedRateBudget, BoundedRateBudgetSchema, createBoundedAdmission, } from './application/admission.js';
|
|
3
|
+
export { type BoundedChannel, type BoundedChannelCloseOptions, type BoundedChannelConfig, type BoundedChannelOfferResult, type BoundedChannelPolicy, BoundedChannelPolicySchema, BoundedChannelReaderError, type BoundedChannelSnapshot, BoundedChannelSnapshotSchema, type BoundedChannelState, BoundedChannelStateSchema, type CreditAcquireResult, type CreditAcquireWaitOptions, type CreditLease, type CreditWaitRefusalReason, type CreditWaitResult, type CreditWindow, type CreditWindowSnapshot, CreditWindowSnapshotSchema, createBoundedChannel, createCreditWindow, } from './application/channel.js';
|
|
4
4
|
export { createDiagnosticJournal } from './application/diagnostic-journal.js';
|
|
5
|
-
export { type DiagnosticJournal, type DiagnosticJournalCloseResult, DiagnosticJournalCloseResultSchema, type DiagnosticJournalConfig, type DiagnosticJournalFailure, type DiagnosticJournalFailurePhase, DiagnosticJournalFailurePhaseSchema, type DiagnosticJournalFrame, DiagnosticJournalFrameSchema, type DiagnosticJournalLimits, DiagnosticJournalLimitsSchema, type DiagnosticJournalRefusalReason, DiagnosticJournalRefusalReasonSchema, type DiagnosticJournalState, DiagnosticJournalStateSchema, type DiagnosticJournalStatus, DiagnosticJournalStatusSchema, type DiagnosticJournalSubmitResult, DiagnosticJournalSubmitResultSchema, type DiagnosticJournalWaitOptions, type DiagnosticJournalWaitResult, DiagnosticJournalWaitResultSchema, } from './application/diagnostic-journal-contract.js';
|
|
5
|
+
export { type DiagnosticJournal, type DiagnosticJournalCloseResult, DiagnosticJournalCloseResultSchema, type DiagnosticJournalConfig, type DiagnosticJournalFailure, type DiagnosticJournalFailurePhase, DiagnosticJournalFailurePhaseSchema, type DiagnosticJournalFrame, DiagnosticJournalFrameSchema, type DiagnosticJournalLimits, DiagnosticJournalLimitsSchema, type DiagnosticJournalLockPolicy, DiagnosticJournalLockPolicySchema, type DiagnosticJournalRefusalReason, DiagnosticJournalRefusalReasonSchema, type DiagnosticJournalState, DiagnosticJournalStateSchema, type DiagnosticJournalStatus, DiagnosticJournalStatusSchema, type DiagnosticJournalSubmitResult, DiagnosticJournalSubmitResultSchema, type DiagnosticJournalWaitOptions, type DiagnosticJournalWaitResult, DiagnosticJournalWaitResultSchema, } from './application/diagnostic-journal-contract.js';
|
|
6
6
|
export { type ApplicationEventSink, type ApplicationEventSinkConfig, type ApplicationLifecycleEvent, ApplicationLifecycleEventSchema, applicationLifecycleEvent, createApplicationEventSink, } from './application/events.js';
|
|
7
7
|
export { type ApplicationHealthHandlerOptions, ApplicationHealthHandlerOptionsSchema, type ApplicationOperationalHandlers, type ApplicationOperationalHandlersOptions, ApplicationOperationalHandlersOptionsSchema, createApplicationHealthHandler, createApplicationOperationalHandlers, } from './application/health.js';
|
|
8
8
|
export { type ApplicationAdmission, ApplicationAdmissionError, type ApplicationConfig, type ApplicationHandle, type ApplicationOperationLease, type ApplicationResourceFailure, type ApplicationResourcePhase, type ApplicationShutdownBudget, ApplicationShutdownBudgetSchema, type ApplicationShutdownOptions, ApplicationShutdownOptionsSchema, createApplication, } from './application/kernel.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EACtC,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,aAAa,EAClB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,wB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,+BAA+B,EAC/B,KAAK,0BAA0B,EAC/B,gCAAgC,EAChC,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,oBAAoB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,4BAA4B,EACjC,kCAAkC,EAClC,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,KAAK,aAAa,EAClB,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,0BAA0B,EAC1B,KAAK,2BAA2B,EAChC,iCAAiC,EACjC,KAAK,yBAAyB,EAC9B,+BAA+B,EAC/B,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,KAAK,2BAA2B,EAChC,iCAAiC,EACjC,KAAK,uBAAuB,EAC5B,6BAA6B,EAC7B,KAAK,oBAAoB,EACzB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,qBAAqB,GACtB,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EACtC,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,aAAa,EAClB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,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+B,EAC/B,KAAK,0BAA0B,EAC/B,gCAAgC,EAChC,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,oBAAoB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,4BAA4B,EACjC,kCAAkC,EAClC,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,KAAK,aAAa,EAClB,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,0BAA0B,EAC1B,KAAK,2BAA2B,EAChC,iCAAiC,EACjC,KAAK,yBAAyB,EAC9B,+BAA+B,EAC/B,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,KAAK,2BAA2B,EAChC,iCAAiC,EACjC,KAAK,uBAAuB,EAC5B,6BAA6B,EAC7B,KAAK,oBAAoB,EACzB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,qBAAqB,GACtB,MAAM,+BAA+B,CAAC"}
|
package/dist/application.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
createBoundedChannel,
|
|
21
21
|
createCreditWindow,
|
|
22
22
|
createManagedSchedule
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-3cwck0rm.js";
|
|
24
24
|
import {
|
|
25
25
|
createBoundedSinkManager
|
|
26
26
|
} from "./index-a59da114.js";
|
|
@@ -59,16 +59,27 @@ var BoundedRateBudgetSchema = z.object({
|
|
|
59
59
|
limit: PositiveSafeIntegerSchema,
|
|
60
60
|
intervalMs: PositiveSafeIntegerSchema
|
|
61
61
|
}).strict().readonly();
|
|
62
|
+
var BoundedAdmissionPerKeyLimitsSchema = z.object({
|
|
63
|
+
maxConcurrent: PositiveSafeIntegerSchema,
|
|
64
|
+
rate: BoundedRateBudgetSchema.optional()
|
|
65
|
+
}).strict().readonly();
|
|
66
|
+
var PerKeyLimitResolverSchema = z.custom((value) => typeof value === "function", { message: "perKey.limits must be a function of the key" });
|
|
62
67
|
var BoundedAdmissionPolicySchema = z.object({
|
|
63
68
|
global: z.object({
|
|
64
69
|
maxConcurrent: PositiveSafeIntegerSchema,
|
|
65
70
|
rate: BoundedRateBudgetSchema.optional()
|
|
66
71
|
}).strict(),
|
|
67
|
-
perKey: z.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
perKey: z.union([
|
|
73
|
+
z.object({
|
|
74
|
+
maxConcurrent: PositiveSafeIntegerSchema,
|
|
75
|
+
maxKeys: PositiveSafeIntegerSchema,
|
|
76
|
+
rate: BoundedRateBudgetSchema.optional()
|
|
77
|
+
}).strict(),
|
|
78
|
+
z.object({
|
|
79
|
+
maxKeys: PositiveSafeIntegerSchema,
|
|
80
|
+
limits: PerKeyLimitResolverSchema
|
|
81
|
+
}).strict()
|
|
82
|
+
]).optional()
|
|
72
83
|
}).strict().readonly();
|
|
73
84
|
var BoundedAdmissionStateSchema = z.enum(["accepting", "draining", "closed"]);
|
|
74
85
|
var BoundedAdmissionRefusalReasonSchema = z.enum([
|
|
@@ -153,6 +164,18 @@ function createBoundedAdmission(config) {
|
|
|
153
164
|
lastNow = value;
|
|
154
165
|
return value;
|
|
155
166
|
};
|
|
167
|
+
const resolveKeyLimits = (key) => {
|
|
168
|
+
const perKey = policy.perKey;
|
|
169
|
+
if (!perKey)
|
|
170
|
+
return;
|
|
171
|
+
if ("limits" in perKey) {
|
|
172
|
+
return BoundedAdmissionPerKeyLimitsSchema.parse(perKey.limits(key));
|
|
173
|
+
}
|
|
174
|
+
return BoundedAdmissionPerKeyLimitsSchema.parse({
|
|
175
|
+
maxConcurrent: perKey.maxConcurrent,
|
|
176
|
+
...perKey.rate && { rate: perKey.rate }
|
|
177
|
+
});
|
|
178
|
+
};
|
|
156
179
|
const pruneRate = (samples, intervalMs, at) => {
|
|
157
180
|
let expired = 0;
|
|
158
181
|
while (expired < samples.length && at - (samples[expired]?.at ?? at) >= intervalMs) {
|
|
@@ -165,8 +188,8 @@ function createBoundedAdmission(config) {
|
|
|
165
188
|
if (policy.global.rate)
|
|
166
189
|
pruneRate(globalRate, policy.global.rate.intervalMs, at);
|
|
167
190
|
for (const [key, record] of keys) {
|
|
168
|
-
if (
|
|
169
|
-
pruneRate(record.rate,
|
|
191
|
+
if (record.limits?.rate) {
|
|
192
|
+
pruneRate(record.rate, record.limits.rate.intervalMs, at);
|
|
170
193
|
}
|
|
171
194
|
if (record.active === 0 && record.rate.length === 0)
|
|
172
195
|
keys.delete(key);
|
|
@@ -221,22 +244,23 @@ function createBoundedAdmission(config) {
|
|
|
221
244
|
if (policy.perKey && key !== undefined) {
|
|
222
245
|
if (!keyRecord && keys.size >= policy.perKey.maxKeys)
|
|
223
246
|
return refuse("key-capacity");
|
|
224
|
-
if (keyRecord && keyRecord.active >=
|
|
247
|
+
if (keyRecord?.limits && keyRecord.active >= keyRecord.limits.maxConcurrent) {
|
|
225
248
|
return refuse("key-concurrency");
|
|
226
249
|
}
|
|
227
250
|
}
|
|
228
251
|
if (policy.global.rate && globalRate.length >= policy.global.rate.limit) {
|
|
229
252
|
return refuse("global-rate", retryAfter(globalRate, policy.global.rate, at));
|
|
230
253
|
}
|
|
231
|
-
|
|
232
|
-
|
|
254
|
+
const keyRate = keyRecord?.limits?.rate;
|
|
255
|
+
if (keyRate && keyRecord && keyRecord.rate.length >= keyRate.limit) {
|
|
256
|
+
return refuse("key-rate", retryAfter(keyRecord.rate, keyRate, at));
|
|
233
257
|
}
|
|
234
258
|
if (key !== undefined && !keyRecord) {
|
|
235
|
-
keyRecord = { active: 0, rate: [] };
|
|
259
|
+
keyRecord = { active: 0, rate: [], limits: resolveKeyLimits(key) };
|
|
236
260
|
keys.set(key, keyRecord);
|
|
237
261
|
}
|
|
238
262
|
const globalSample = policy.global.rate ? { at } : undefined;
|
|
239
|
-
const keySample =
|
|
263
|
+
const keySample = keyRecord?.limits?.rate ? { at } : undefined;
|
|
240
264
|
active += 1;
|
|
241
265
|
if (keyRecord)
|
|
242
266
|
keyRecord.active += 1;
|
|
@@ -413,6 +437,7 @@ var DiagnosticJournalLimitsSchema = z2.object({
|
|
|
413
437
|
maxFileBytes: PositiveSafeIntegerSchema2,
|
|
414
438
|
maxFiles: PositiveSafeIntegerSchema2
|
|
415
439
|
}).strict().readonly();
|
|
440
|
+
var DiagnosticJournalLockPolicySchema = z2.enum(["refuse", "reclaim-stale"]);
|
|
416
441
|
var DiagnosticJournalStateSchema = z2.enum(["open", "draining", "closed", "failed"]);
|
|
417
442
|
var DiagnosticJournalRefusalReasonSchema = z2.enum([
|
|
418
443
|
"closed",
|
|
@@ -435,6 +460,10 @@ var DiagnosticJournalStatusSchema = z2.object({
|
|
|
435
460
|
state: DiagnosticJournalStateSchema,
|
|
436
461
|
epoch: z2.uuid(),
|
|
437
462
|
limits: DiagnosticJournalLimitsSchema,
|
|
463
|
+
lock: z2.object({
|
|
464
|
+
policy: DiagnosticJournalLockPolicySchema,
|
|
465
|
+
reclaimedStale: z2.boolean()
|
|
466
|
+
}).strict().readonly(),
|
|
438
467
|
received: z2.number().int().nonnegative(),
|
|
439
468
|
accepted: z2.number().int().nonnegative(),
|
|
440
469
|
refused: z2.number().int().nonnegative(),
|
|
@@ -493,9 +522,86 @@ function parseDiagnosticJournalMode(mode) {
|
|
|
493
522
|
import { z as z3 } from "zod";
|
|
494
523
|
|
|
495
524
|
// src/application/diagnostic-journal-storage.ts
|
|
496
|
-
import { constants } from "node:fs";
|
|
497
|
-
import { lstat, open, readdir, realpath, rename, unlink } from "node:fs/promises";
|
|
525
|
+
import { constants as constants2 } from "node:fs";
|
|
526
|
+
import { lstat, open as open2, readdir, realpath, rename, unlink as unlink2 } from "node:fs/promises";
|
|
498
527
|
import { basename, dirname, isAbsolute, resolve } from "node:path";
|
|
528
|
+
|
|
529
|
+
// src/application/diagnostic-journal-lock.ts
|
|
530
|
+
import { constants } from "node:fs";
|
|
531
|
+
import { open, unlink } from "node:fs/promises";
|
|
532
|
+
import { hostname } from "node:os";
|
|
533
|
+
function isExisting(error) {
|
|
534
|
+
return isRecord(error) && error.code === "EEXIST";
|
|
535
|
+
}
|
|
536
|
+
function readOwner(text) {
|
|
537
|
+
let parsed;
|
|
538
|
+
try {
|
|
539
|
+
parsed = JSON.parse(text);
|
|
540
|
+
} catch {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if (!isRecord(parsed))
|
|
544
|
+
return;
|
|
545
|
+
const { pid, host, acquiredAt } = parsed;
|
|
546
|
+
if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0)
|
|
547
|
+
return;
|
|
548
|
+
if (typeof host !== "string" || host.length === 0)
|
|
549
|
+
return;
|
|
550
|
+
if (typeof acquiredAt !== "string")
|
|
551
|
+
return;
|
|
552
|
+
return { pid, host, acquiredAt };
|
|
553
|
+
}
|
|
554
|
+
function isGone(owner) {
|
|
555
|
+
if (owner.host !== hostname())
|
|
556
|
+
return false;
|
|
557
|
+
try {
|
|
558
|
+
process.kill(owner.pid, 0);
|
|
559
|
+
return false;
|
|
560
|
+
} catch (error) {
|
|
561
|
+
return isRecord(error) && error.code === "ESRCH";
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
async function readLockOwner(lockPath) {
|
|
565
|
+
let handle;
|
|
566
|
+
try {
|
|
567
|
+
handle = await open(lockPath, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
568
|
+
return readOwner(await handle.readFile("utf8"));
|
|
569
|
+
} catch {
|
|
570
|
+
return;
|
|
571
|
+
} finally {
|
|
572
|
+
await handle?.close().catch(() => {
|
|
573
|
+
return;
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
async function createExclusive(lockPath, mode) {
|
|
578
|
+
const handle = await open(lockPath, "wx", mode);
|
|
579
|
+
const owner = {
|
|
580
|
+
pid: process.pid,
|
|
581
|
+
host: hostname(),
|
|
582
|
+
acquiredAt: new Date().toISOString()
|
|
583
|
+
};
|
|
584
|
+
await handle.writeFile(`${JSON.stringify(owner)}
|
|
585
|
+
`, "utf8");
|
|
586
|
+
return handle;
|
|
587
|
+
}
|
|
588
|
+
async function acquireDiagnosticJournalLock(lockPath, mode, policy) {
|
|
589
|
+
try {
|
|
590
|
+
return { handle: await createExclusive(lockPath, mode), reclaimedStale: false };
|
|
591
|
+
} catch (error) {
|
|
592
|
+
if (policy !== "reclaim-stale" || !isExisting(error))
|
|
593
|
+
throw error;
|
|
594
|
+
const owner = await readLockOwner(lockPath);
|
|
595
|
+
if (!owner || !isGone(owner))
|
|
596
|
+
throw error;
|
|
597
|
+
await unlink(lockPath).catch(() => {
|
|
598
|
+
return;
|
|
599
|
+
});
|
|
600
|
+
return { handle: await createExclusive(lockPath, mode), reclaimedStale: true };
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// src/application/diagnostic-journal-storage.ts
|
|
499
605
|
class DiagnosticJournalStorageError extends Error {
|
|
500
606
|
phase;
|
|
501
607
|
constructor(phase, message, options) {
|
|
@@ -513,7 +619,7 @@ async function removeIfPresent(path) {
|
|
|
513
619
|
if (info.isSymbolicLink() || !info.isFile()) {
|
|
514
620
|
throw new Error("Diagnostic journal generations must be regular files");
|
|
515
621
|
}
|
|
516
|
-
await
|
|
622
|
+
await unlink2(path);
|
|
517
623
|
} catch (error) {
|
|
518
624
|
if (!isMissing(error))
|
|
519
625
|
throw error;
|
|
@@ -552,7 +658,7 @@ async function createRotatingDiagnosticJournalStorage(config) {
|
|
|
552
658
|
const parent = await realpath(dirname(config.path));
|
|
553
659
|
const journalPath = resolve(parent, basename(config.path));
|
|
554
660
|
const lockPath = `${journalPath}.lock`;
|
|
555
|
-
const lock = await
|
|
661
|
+
const { handle: lock, reclaimedStale } = await acquireDiagnosticJournalLock(lockPath, config.mode, config.lock);
|
|
556
662
|
let handle;
|
|
557
663
|
let currentFileBytes = 0;
|
|
558
664
|
let retainedFiles = 1;
|
|
@@ -560,7 +666,7 @@ async function createRotatingDiagnosticJournalStorage(config) {
|
|
|
560
666
|
let partialTails = 0;
|
|
561
667
|
let closed = false;
|
|
562
668
|
const openCurrent = async () => {
|
|
563
|
-
handle = await
|
|
669
|
+
handle = await open2(journalPath, constants2.O_APPEND | constants2.O_CREAT | constants2.O_RDWR | constants2.O_NOFOLLOW, config.mode);
|
|
564
670
|
const info = await handle.stat();
|
|
565
671
|
if (!info.isFile()) {
|
|
566
672
|
await handle.close();
|
|
@@ -624,7 +730,7 @@ async function createRotatingDiagnosticJournalStorage(config) {
|
|
|
624
730
|
await lock.close().catch(() => {
|
|
625
731
|
return;
|
|
626
732
|
});
|
|
627
|
-
await
|
|
733
|
+
await unlink2(lockPath).catch(() => {
|
|
628
734
|
return;
|
|
629
735
|
});
|
|
630
736
|
throw error;
|
|
@@ -636,6 +742,7 @@ async function createRotatingDiagnosticJournalStorage(config) {
|
|
|
636
742
|
partialTails
|
|
637
743
|
});
|
|
638
744
|
return {
|
|
745
|
+
reclaimedStale,
|
|
639
746
|
async append(bytes) {
|
|
640
747
|
if (closed || !handle) {
|
|
641
748
|
throw new DiagnosticJournalStorageError("write", "Diagnostic journal storage is closed");
|
|
@@ -668,7 +775,7 @@ async function createRotatingDiagnosticJournalStorage(config) {
|
|
|
668
775
|
}
|
|
669
776
|
try {
|
|
670
777
|
await lock.close();
|
|
671
|
-
await
|
|
778
|
+
await unlink2(lockPath);
|
|
672
779
|
} catch (error) {
|
|
673
780
|
failure ??= error;
|
|
674
781
|
}
|
|
@@ -822,6 +929,7 @@ function createDiagnosticJournalManager(config, storage) {
|
|
|
822
929
|
state,
|
|
823
930
|
epoch: config.epoch,
|
|
824
931
|
limits,
|
|
932
|
+
lock: config.lock,
|
|
825
933
|
received,
|
|
826
934
|
accepted,
|
|
827
935
|
refused,
|
|
@@ -917,16 +1025,19 @@ function createDiagnosticJournalManager(config, storage) {
|
|
|
917
1025
|
// src/application/diagnostic-journal.ts
|
|
918
1026
|
async function createDiagnosticJournal(config) {
|
|
919
1027
|
const limits = DiagnosticJournalLimitsSchema.parse(config.limits);
|
|
1028
|
+
const lock = DiagnosticJournalLockPolicySchema.parse(config.lock ?? "refuse");
|
|
920
1029
|
const storage = await createRotatingDiagnosticJournalStorage({
|
|
921
1030
|
path: config.path,
|
|
922
1031
|
maxFileBytes: limits.maxFileBytes,
|
|
923
1032
|
maxFiles: limits.maxFiles,
|
|
924
|
-
mode: parseDiagnosticJournalMode(config.mode)
|
|
1033
|
+
mode: parseDiagnosticJournalMode(config.mode),
|
|
1034
|
+
lock
|
|
925
1035
|
});
|
|
926
1036
|
return createDiagnosticJournalManager({
|
|
927
1037
|
eventSchema: config.eventSchema,
|
|
928
1038
|
epoch: randomUUID(),
|
|
929
1039
|
limits,
|
|
1040
|
+
lock: { policy: lock, reclaimedStale: storage.reclaimedStale },
|
|
930
1041
|
...config.onFailure && { onFailure: config.onFailure }
|
|
931
1042
|
}, storage);
|
|
932
1043
|
}
|
|
@@ -1092,6 +1203,7 @@ export {
|
|
|
1092
1203
|
DiagnosticJournalStatusSchema,
|
|
1093
1204
|
DiagnosticJournalStateSchema,
|
|
1094
1205
|
DiagnosticJournalRefusalReasonSchema,
|
|
1206
|
+
DiagnosticJournalLockPolicySchema,
|
|
1095
1207
|
DiagnosticJournalLimitsSchema,
|
|
1096
1208
|
DiagnosticJournalFrameSchema,
|
|
1097
1209
|
DiagnosticJournalFailurePhaseSchema,
|
|
@@ -1108,6 +1220,7 @@ export {
|
|
|
1108
1220
|
BoundedAdmissionRefusalReasonSchema,
|
|
1109
1221
|
BoundedAdmissionRefusalError,
|
|
1110
1222
|
BoundedAdmissionPolicySchema,
|
|
1223
|
+
BoundedAdmissionPerKeyLimitsSchema,
|
|
1111
1224
|
ApplicationStatusProjectionSchema,
|
|
1112
1225
|
ApplicationSnapshotSinkStatusSchema,
|
|
1113
1226
|
ApplicationSnapshotSchema,
|