stitchkit 0.72.5 → 0.73.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.
@@ -168,6 +168,17 @@ export interface DiagnosticJournalConfig<SCHEMA extends z.ZodType> {
168
168
  * by time and the lock exists for exactly that case.
169
169
  */
170
170
  readonly lock?: DiagnosticJournalLockPolicy;
171
+ /**
172
+ * This machine's stable identity, overriding platform detection.
173
+ *
174
+ * The lock records it so a machine that renames itself is still recognised as itself — a host
175
+ * name is mutable state, and treating it as identity left a renamed machine unable to reclaim
176
+ * its own abandoned lock. Detection covers `/etc/machine-id` and the macOS platform UUID; state
177
+ * it here on a platform that offers neither, or when the deployment knows better. It must be
178
+ * stable across restarts and distinct per machine: a value shared by two machines is the one
179
+ * mistake this guard exists to prevent.
180
+ */
181
+ readonly machineIdentity?: string;
171
182
  /** Diagnostics are isolated and are never written back into this journal. */
172
183
  readonly onFailure?: (failure: DiagnosticJournalFailure) => void | Promise<void>;
173
184
  }
@@ -181,4 +192,17 @@ export interface DiagnosticJournal<INPUT> {
181
192
  close(options?: DiagnosticJournalWaitOptions): Promise<DiagnosticJournalCloseResult>;
182
193
  }
183
194
  export declare function parseDiagnosticJournalMode(mode: number | undefined): number;
195
+ /** Why a present lock was not reclaimed. Attached to the thrown `EEXIST`, never thrown itself. */
196
+ export interface DiagnosticJournalLockDiagnosis {
197
+ readonly attribution: 'this-machine' | 'another-machine' | 'unattributable';
198
+ readonly liveness: 'alive' | 'gone' | 'not-probed';
199
+ readonly owner: {
200
+ pid: number;
201
+ host: string;
202
+ acquiredAt: string;
203
+ machine?: string;
204
+ } | null;
205
+ }
206
+ /** Read the diagnosis a refused acquisition attached to its error, if it carried one. */
207
+ export declare function readDiagnosticJournalLockDiagnosis(error: unknown): DiagnosticJournalLockDiagnosis | undefined;
184
208
  //# sourceMappingURL=diagnostic-journal-contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostic-journal-contract.d.ts","s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AM,CAAC;IAClC,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;AAaD,kGAAkG;AAClG,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,WAAW,EAAE,cAAc,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;IAC5E,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,YAAY,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAC5F;AAED,yFAAyF;AACzF,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,GACb,8BAA8B,GAAG,SAAS,CAM5C"}
@@ -5,13 +5,32 @@ export interface AcquiredDiagnosticJournalLock {
5
5
  readonly handle: FileHandle;
6
6
  readonly reclaimedStale: boolean;
7
7
  }
8
+ /**
9
+ * `IOPlatformUUID` out of an `ioreg` dump, or `null` when the dump does not carry one.
10
+ *
11
+ * @internal Exported for the tests: the registry only exists on darwin, so a parser folded into the
12
+ * spawn could never be exercised anywhere else — and this branch decides the identity of the very
13
+ * machines the lock policy was fixed for.
14
+ */
15
+ export declare function parsePlatformUuid(dump: string): string | null;
16
+ /**
17
+ * @internal `command` is a seam for the tests. macOS keeps no machine-id file, so the I/O cannot be
18
+ * removed — but which executable answers can be, and that makes the branch provable off darwin.
19
+ */
20
+ export declare function readDarwinPlatformUuid(command?: string): Promise<string | null>;
8
21
  /**
9
22
  * Take the journal's exclusive lock under the configured policy.
10
23
  *
11
24
  * `refuse` is the default and rethrows the `EEXIST` a present lock produces. `reclaim-stale`
12
25
  * rethrows that same error unless the recorded owner is provably gone, so it is a strict superset
13
26
  * of `refuse`: every refusal a caller sees today it still sees, with the identical error.
27
+ *
28
+ * A refusal under `reclaim-stale` carries its reason on that error, readable through
29
+ * `readDiagnosticJournalLockDiagnosis`. It is attached rather than thrown so the error a caller
30
+ * already handles does not change shape; the point is that "the owner is alive" and "this lock
31
+ * cannot be attributed to this host" stop being the same silent answer. The consumer that met this
32
+ * printed "another process is running against this state" — a sentence it had no evidence for.
14
33
  */
15
- export declare function acquireDiagnosticJournalLock(lockPath: string, mode: number, policy: DiagnosticJournalLockPolicy): Promise<AcquiredDiagnosticJournalLock>;
34
+ export declare function acquireDiagnosticJournalLock(lockPath: string, mode: number, policy: DiagnosticJournalLockPolicy, declaredIdentity?: string): Promise<AcquiredDiagnosticJournalLock>;
16
35
  export {};
17
36
  //# sourceMappingURL=diagnostic-journal-lock.d.ts.map
@@ -1 +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
+ {"version":3,"file":"diagnostic-journal-lock.d.ts","sourceRoot":"","sources":["../../src/application/diagnostic-journal-lock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAoB,MAAM,kBAAkB,CAAC;AAI1D,OAAO,KAAK,EAEV,2BAA2B,EAC5B,MAAM,+BAA+B,CAAC;AAEvC,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;AA6DD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,SAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBtF;AAiGD;;;;;;;;;;;;GAYG;AACH,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,2BAA2B,EACnC,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,6BAA6B,CAAC,CA2BxC"}
@@ -25,6 +25,7 @@ interface RotatingStorageConfig {
25
25
  readonly maxFiles: number;
26
26
  readonly mode: number;
27
27
  readonly lock: DiagnosticJournalLockPolicy;
28
+ readonly machineIdentity?: string;
28
29
  }
29
30
  /** One exclusive local writer. The lock is deliberately not a cross-crash lease. */
30
31
  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,EACV,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,+BAA+B,CAAC;AAGvC,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,oCACf,SAAQ,gCAAgC;IACxC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,wBAAwB;IACvC,kFAAkF;IAClF,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;IACzE,QAAQ,IAAI,gCAAgC,CAAC;IAC7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,qBAAa,6BAA8B,SAAQ,KAAK;aAEpC,KAAK,EAAE,6BAA6B;IADtD,YACkB,KAAK,EAAE,6BAA6B,EACpD,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY,EAIvB;CACF;AAED,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,2BAA2B,CAAC;CAC5C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AC3C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AA4CD,oFAAoF;AACpF,wBAAsB,sCAAsC,CAC1D,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,wBAAwB,CAAC,CAwJnC"}
@@ -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,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"}
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,CAqB7C"}
@@ -2,7 +2,7 @@ export { type ActivityId, ActivityIdSchema, type ActivityLiveState, ActivityLive
2
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
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 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';
5
+ export { type DiagnosticJournal, type DiagnosticJournalCloseResult, DiagnosticJournalCloseResultSchema, type DiagnosticJournalConfig, type DiagnosticJournalFailure, type DiagnosticJournalFailurePhase, DiagnosticJournalFailurePhaseSchema, type DiagnosticJournalFrame, DiagnosticJournalFrameSchema, type DiagnosticJournalLimits, DiagnosticJournalLimitsSchema, type DiagnosticJournalLockDiagnosis, type DiagnosticJournalLockPolicy, DiagnosticJournalLockPolicySchema, type DiagnosticJournalRefusalReason, DiagnosticJournalRefusalReasonSchema, type DiagnosticJournalState, DiagnosticJournalStateSchema, type DiagnosticJournalStatus, DiagnosticJournalStatusSchema, type DiagnosticJournalSubmitResult, DiagnosticJournalSubmitResultSchema, type DiagnosticJournalWaitOptions, type DiagnosticJournalWaitResult, DiagnosticJournalWaitResultSchema, readDiagnosticJournalLockDiagnosis, } 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,kBAA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ACnC,6BAA6B,EAC7B,KAAK,6BAA6B,GACnC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAC/B,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,+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,KAA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AA6B,EAClC,mCAAmC,EACnC,6BAA6B,EAC7B,KAAK,6BAA6B,GACnC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAC/B,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,+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"}
@@ -520,6 +520,12 @@ var DiagnosticJournalFrameSchema = z2.object({
520
520
  function parseDiagnosticJournalMode(mode) {
521
521
  return FileModeSchema.parse(mode ?? 384);
522
522
  }
523
+ function readDiagnosticJournalLockDiagnosis(error) {
524
+ if (!isRecord(error))
525
+ return;
526
+ const diagnosis = error.journalLock;
527
+ return isRecord(diagnosis) ? diagnosis : undefined;
528
+ }
523
529
 
524
530
  // src/application/diagnostic-journal-manager.ts
525
531
  import { z as z3 } from "zod";
@@ -530,9 +536,11 @@ import { lstat, open as open2, readdir, realpath, rename, unlink as unlink2 } fr
530
536
  import { basename, dirname, isAbsolute, resolve } from "node:path";
531
537
 
532
538
  // src/application/diagnostic-journal-lock.ts
539
+ import { execFile } from "node:child_process";
533
540
  import { constants } from "node:fs";
534
- import { open, unlink } from "node:fs/promises";
535
- import { hostname } from "node:os";
541
+ import { open, readFile, unlink } from "node:fs/promises";
542
+ import { hostname, platform } from "node:os";
543
+ import { promisify } from "node:util";
536
544
  function isExisting(error) {
537
545
  return isRecord(error) && error.code === "EEXIST";
538
546
  }
@@ -545,25 +553,79 @@ function readOwner(text) {
545
553
  }
546
554
  if (!isRecord(parsed))
547
555
  return;
548
- const { pid, host, acquiredAt } = parsed;
556
+ const { pid, host, acquiredAt, machine } = parsed;
549
557
  if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0)
550
558
  return;
551
559
  if (typeof host !== "string" || host.length === 0)
552
560
  return;
553
561
  if (typeof acquiredAt !== "string")
554
562
  return;
555
- return { pid, host, acquiredAt };
563
+ const identified = typeof machine === "string" && machine.length > 0 ? { machine } : {};
564
+ return { pid, host, acquiredAt, ...identified };
565
+ }
566
+ var detectedIdentity;
567
+ async function firstReadableLine(paths) {
568
+ for (const path of paths) {
569
+ try {
570
+ const text = (await readFile(path, "utf8")).trim();
571
+ if (text.length > 0)
572
+ return text;
573
+ } catch {}
574
+ }
575
+ return null;
576
+ }
577
+ var run = promisify(execFile);
578
+ function parsePlatformUuid(dump) {
579
+ return /"IOPlatformUUID"\s*=\s*"([^"]+)"/.exec(dump)?.[1] ?? null;
556
580
  }
557
- function isGone(owner) {
558
- if (owner.host !== hostname())
559
- return false;
581
+ async function readDarwinPlatformUuid(command = "ioreg") {
582
+ try {
583
+ const { stdout } = await run(command, ["-rd1", "-c", "IOPlatformExpertDevice"], {
584
+ timeout: 2000,
585
+ maxBuffer: 1 << 20,
586
+ encoding: "utf8"
587
+ });
588
+ return parsePlatformUuid(stdout);
589
+ } catch {
590
+ return null;
591
+ }
592
+ }
593
+ async function machineIdentity(declared) {
594
+ if (declared !== undefined)
595
+ return declared;
596
+ if (detectedIdentity !== undefined)
597
+ return detectedIdentity;
598
+ detectedIdentity = platform() === "darwin" ? await readDarwinPlatformUuid() : await firstReadableLine(["/etc/machine-id", "/var/lib/dbus/machine-id"]);
599
+ return detectedIdentity;
600
+ }
601
+ function attribute(owner, identity) {
602
+ if (identity !== null && owner.machine !== undefined) {
603
+ return owner.machine === identity ? "this-machine" : "another-machine";
604
+ }
605
+ return owner.host === hostname() ? "this-machine" : "unattributable";
606
+ }
607
+ function probeLiveness(owner) {
560
608
  try {
561
609
  process.kill(owner.pid, 0);
562
- return false;
610
+ return "alive";
563
611
  } catch (error) {
564
- return isRecord(error) && error.code === "ESRCH";
612
+ return isRecord(error) && error.code === "ESRCH" ? "gone" : "alive";
565
613
  }
566
614
  }
615
+ async function diagnose(owner, declaredIdentity) {
616
+ if (!owner)
617
+ return { attribution: "unattributable", liveness: "not-probed", owner: null };
618
+ const attribution = attribute(owner, await machineIdentity(declaredIdentity));
619
+ const record = {
620
+ pid: owner.pid,
621
+ host: owner.host,
622
+ acquiredAt: owner.acquiredAt,
623
+ ...owner.machine !== undefined && { machine: owner.machine }
624
+ };
625
+ if (attribution !== "this-machine")
626
+ return { attribution, liveness: "not-probed", owner: record };
627
+ return { attribution, liveness: probeLiveness(owner), owner: record };
628
+ }
567
629
  async function readLockOwner(lockPath) {
568
630
  let handle;
569
631
  try {
@@ -577,30 +639,42 @@ async function readLockOwner(lockPath) {
577
639
  });
578
640
  }
579
641
  }
580
- async function createExclusive(lockPath, mode) {
642
+ async function createExclusive(lockPath, mode, declaredIdentity) {
581
643
  const handle = await open(lockPath, "wx", mode);
644
+ const identity = await machineIdentity(declaredIdentity);
582
645
  const owner = {
583
646
  pid: process.pid,
584
647
  host: hostname(),
585
- acquiredAt: new Date().toISOString()
648
+ acquiredAt: new Date().toISOString(),
649
+ ...identity !== null && { machine: identity }
586
650
  };
587
651
  await handle.writeFile(`${JSON.stringify(owner)}
588
652
  `, "utf8");
589
653
  return handle;
590
654
  }
591
- async function acquireDiagnosticJournalLock(lockPath, mode, policy) {
655
+ async function acquireDiagnosticJournalLock(lockPath, mode, policy, declaredIdentity) {
592
656
  try {
593
- return { handle: await createExclusive(lockPath, mode), reclaimedStale: false };
657
+ return {
658
+ handle: await createExclusive(lockPath, mode, declaredIdentity),
659
+ reclaimedStale: false
660
+ };
594
661
  } catch (error) {
595
662
  if (policy !== "reclaim-stale" || !isExisting(error))
596
663
  throw error;
597
664
  const owner = await readLockOwner(lockPath);
598
- if (!owner || !isGone(owner))
665
+ const diagnosis = await diagnose(owner, declaredIdentity);
666
+ if (!owner || diagnosis.liveness !== "gone") {
667
+ if (isRecord(error))
668
+ Object.assign(error, { journalLock: diagnosis });
599
669
  throw error;
670
+ }
600
671
  await unlink(lockPath).catch(() => {
601
672
  return;
602
673
  });
603
- return { handle: await createExclusive(lockPath, mode), reclaimedStale: true };
674
+ return {
675
+ handle: await createExclusive(lockPath, mode, declaredIdentity),
676
+ reclaimedStale: true
677
+ };
604
678
  }
605
679
  }
606
680
 
@@ -661,7 +735,7 @@ async function createRotatingDiagnosticJournalStorage(config) {
661
735
  const parent = await realpath(dirname(config.path));
662
736
  const journalPath = resolve(parent, basename(config.path));
663
737
  const lockPath = `${journalPath}.lock`;
664
- const { handle: lock, reclaimedStale } = await acquireDiagnosticJournalLock(lockPath, config.mode, config.lock);
738
+ const { handle: lock, reclaimedStale } = await acquireDiagnosticJournalLock(lockPath, config.mode, config.lock, config.machineIdentity);
665
739
  let handle;
666
740
  let currentFileBytes = 0;
667
741
  let retainedFiles = 1;
@@ -1034,7 +1108,8 @@ async function createDiagnosticJournal(config) {
1034
1108
  maxFileBytes: limits.maxFileBytes,
1035
1109
  maxFiles: limits.maxFiles,
1036
1110
  mode: parseDiagnosticJournalMode(config.mode),
1037
- lock
1111
+ lock,
1112
+ ...config.machineIdentity !== undefined && { machineIdentity: config.machineIdentity }
1038
1113
  });
1039
1114
  return createDiagnosticJournalManager({
1040
1115
  eventSchema: config.eventSchema,
@@ -1179,6 +1254,7 @@ function managedServerResource(config) {
1179
1254
  });
1180
1255
  }
1181
1256
  export {
1257
+ readDiagnosticJournalLockDiagnosis,
1182
1258
  projectApplicationStatus,
1183
1259
  managedServerResource,
1184
1260
  managedResourceDependencyId,
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/browser/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AAMrB,OAAO,EAEL,KAAK,UAAU,IAAI,WAAW,EAG9B,KAAK,mBAAmB,EACzB,MAAM,QAAQ,CAAC;AAEhB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgE/C,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClE,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,IA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gB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAAC;IAClD,gFAAgF;IAChF,MAAM,IAAI,IAAI,CAAC;IACf,oEAAoE;IACpE,gBAAgB,IAAI,IAAI,CAAC;CAC1B;AAED,gFAAgF;AAChF,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,CA+N/E"}
@@ -248,6 +248,9 @@ function responseTraceId(response) {
248
248
 
249
249
  // src/browser/http.ts
250
250
  var API_ERROR_BRAND = Symbol.for("stitchkit.ApiError");
251
+ function messageForCode(code, message) {
252
+ return message !== undefined && message.length > 0 ? message : `${code} (no message supplied)`;
253
+ }
251
254
 
252
255
  class ApiError extends Error {
253
256
  code;
@@ -256,7 +259,7 @@ class ApiError extends Error {
256
259
  hint;
257
260
  traceId;
258
261
  constructor(code, status = 0, details, message, hint, traceId, options) {
259
- super(message ?? `API Error: ${code}`, options);
262
+ super(messageForCode(code, message), options);
260
263
  this.code = code;
261
264
  this.status = status;
262
265
  this.details = details;
@@ -464,14 +467,26 @@ function createEndpointMethod(endpoint, execute, contractConfig) {
464
467
  if (endpointHasArguments(endpoint) || hasScopedArguments) {
465
468
  const method2 = (requestArgs) => execute(readClientRequestArgs(requestArgs), undefined);
466
469
  return Object.assign(method2, {
467
- withOptions: (requestArgs, options) => execute(readClientRequestArgs(requestArgs), readClientRequestOptions(options))
470
+ withOptions: (...args) => {
471
+ refuseExtraWithOptionsArguments(endpoint, args.length, 2);
472
+ return execute(readClientRequestArgs(args[0]), readClientRequestOptions(args[1]));
473
+ }
468
474
  });
469
475
  }
470
476
  const method = () => execute({}, undefined);
471
477
  return Object.assign(method, {
472
- withOptions: (options) => execute({}, readClientRequestOptions(options))
478
+ withOptions: (...args) => {
479
+ refuseExtraWithOptionsArguments(endpoint, args.length, 1);
480
+ return execute({}, readClientRequestOptions(args[0]));
481
+ }
473
482
  });
474
483
  }
484
+ function refuseExtraWithOptionsArguments(endpoint, received, expected) {
485
+ if (received <= expected)
486
+ return;
487
+ const shape = expected === 1 ? "withOptions(options)" : "withOptions(args, options)";
488
+ throw new TypeError(`${endpoint.method} ${endpoint.path}: this endpoint declares ${expected === 1 ? "no input" : "an input"}, so its method is ${shape} — it received ${received} arguments. ` + "An extra argument here is dropped, and a request options object in the dropped position " + "sends the request without them: an abort signal placed there never reaches the server.");
489
+ }
475
490
  function createHttpExecutor(endpoint, prefix, client, config) {
476
491
  const httpMethod = endpoint.method.toLowerCase();
477
492
  return (requestArgs, options) => {
package/dist/index.js CHANGED
@@ -463,6 +463,9 @@ function responseTraceId(response) {
463
463
 
464
464
  // src/browser/http.ts
465
465
  var API_ERROR_BRAND = Symbol.for("stitchkit.ApiError");
466
+ function messageForCode(code, message) {
467
+ return message !== undefined && message.length > 0 ? message : `${code} (no message supplied)`;
468
+ }
466
469
 
467
470
  class ApiError extends Error {
468
471
  code;
@@ -471,7 +474,7 @@ class ApiError extends Error {
471
474
  hint;
472
475
  traceId;
473
476
  constructor(code, status = 0, details, message, hint, traceId, options) {
474
- super(message ?? `API Error: ${code}`, options);
477
+ super(messageForCode(code, message), options);
475
478
  this.code = code;
476
479
  this.status = status;
477
480
  this.details = details;
@@ -671,7 +674,7 @@ function createHttpClient(config) {
671
674
  const response = isHTTPError(error) ? error.response : undefined;
672
675
  const status = response?.status ?? 0;
673
676
  const msg = error instanceof Error ? error.message : undefined;
674
- throw new ApiError("UNKNOWN_ERROR", status, msg ? { message: msg } : undefined, undefined, undefined, responseTraceId(response));
677
+ throw new ApiError("UNKNOWN_ERROR", status, msg ? { message: msg } : undefined, msg, undefined, responseTraceId(response), { cause: error });
675
678
  }
676
679
  }
677
680
  return {
@@ -927,14 +930,26 @@ function createEndpointMethod(endpoint, execute, contractConfig) {
927
930
  if (endpointHasArguments(endpoint) || hasScopedArguments) {
928
931
  const method2 = (requestArgs) => execute(readClientRequestArgs(requestArgs), undefined);
929
932
  return Object.assign(method2, {
930
- withOptions: (requestArgs, options) => execute(readClientRequestArgs(requestArgs), readClientRequestOptions(options))
933
+ withOptions: (...args) => {
934
+ refuseExtraWithOptionsArguments(endpoint, args.length, 2);
935
+ return execute(readClientRequestArgs(args[0]), readClientRequestOptions(args[1]));
936
+ }
931
937
  });
932
938
  }
933
939
  const method = () => execute({}, undefined);
934
940
  return Object.assign(method, {
935
- withOptions: (options) => execute({}, readClientRequestOptions(options))
941
+ withOptions: (...args) => {
942
+ refuseExtraWithOptionsArguments(endpoint, args.length, 1);
943
+ return execute({}, readClientRequestOptions(args[0]));
944
+ }
936
945
  });
937
946
  }
947
+ function refuseExtraWithOptionsArguments(endpoint, received, expected) {
948
+ if (received <= expected)
949
+ return;
950
+ const shape = expected === 1 ? "withOptions(options)" : "withOptions(args, options)";
951
+ throw new TypeError(`${endpoint.method} ${endpoint.path}: this endpoint declares ${expected === 1 ? "no input" : "an input"}, so its method is ${shape} — it received ${received} arguments. ` + "An extra argument here is dropped, and a request options object in the dropped position " + "sends the request without them: an abort signal placed there never reaches the server.");
952
+ }
938
953
  function createHttpExecutor(endpoint, prefix, client, config) {
939
954
  const httpMethod = endpoint.method.toLowerCase();
940
955
  return (requestArgs, options) => {
package/dist/remote.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ApiError,
3
3
  createClient
4
- } from "./index-6d32zk83.js";
4
+ } from "./index-0tfm7beg.js";
5
5
  import"./index-1rxswfbv.js";
6
6
  import"./index-nt1mp8km.js";
7
7
  import {
package/dist/testing.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  import {
25
25
  createClient,
26
26
  createClients
27
- } from "./index-6d32zk83.js";
27
+ } from "./index-0tfm7beg.js";
28
28
  import"./index-1rxswfbv.js";
29
29
  import"./index-nt1mp8km.js";
30
30
  import {
package/llms-full.txt CHANGED
@@ -61,7 +61,7 @@ own, recorded as an ADR.
61
61
  | `stitchkit/testing` | tests on Bun or Node | stable | in-process generated clients over a real Fetch handler, plus the store and managed-resource conformance kits |
62
62
  | `stitchkit/declaration` | build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
63
63
  | `stitchkit/react` | browser | stable | `createCursorQuery`, `createCacheBridge` |
64
- | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 10 of the 17 minors since 0.56.2, most recently 0.69.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
64
+ | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 10 of the 18 minors since 0.56.2, most recently 0.69.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
65
65
  | `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
66
66
  | `stitchkit/agent-runtime/coding-tools` | server (Bun or Node) | evolving | bounded host-authorized direct file and shell tools; a root boundary, not an OS sandbox |
67
67
  | `stitchkit/agent-runtime/openrouter` | server | evolving | isolated OpenRouter language-model adapter |
@@ -69,7 +69,7 @@ own, recorded as an ADR.
69
69
  | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
70
70
  | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
71
71
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
72
- | `stitchkit/application` | server | evolving<br>_redefined in 4 of the 17 minors since 0.56.2, most recently 0.72.0_ | managed resource graph, readiness, admission, schedules and bounded shutdown |
72
+ | `stitchkit/application` | server | evolving<br>_redefined in 4 of the 18 minors since 0.56.2, most recently 0.72.0_ | managed resource graph, readiness, admission, schedules and bounded shutdown |
73
73
  | `stitchkit/application/grammy` | server | evolving | isolated grammY polling and webhook lifecycle adapters |
74
74
  | `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
75
75
 
@@ -2005,6 +2005,18 @@ proves that the remote operation did not begin; Stitchkit never silently retries
2005
2005
  an ambiguous write. Response consumption/cancellation belongs to the operation,
2006
2006
  and `close()` interrupts active work and destroys owned connections.
2007
2007
 
2008
+ **A caller's cancellation reaches the server on both lanes.** The transport picks
2009
+ a raw-socket lane under Bun and `node:http` elsewhere, and both propagate
2010
+ `AbortSignal` the same way: aborting the request tears the connection down, and
2011
+ the handler's `ctx.signal` fires — measured at roughly 300 ms for a 200 ms abort
2012
+ over either lane, matching plain TCP. `close()` is a different thing: it ends the
2013
+ *transport*, not one request, and a request-level abort does not close it.
2014
+
2015
+ The one way to see cancellation appear not to work is to pass the signal to the
2016
+ plain callable — `api.thing(args, { signal })` — where options are ignored in
2017
+ silence. See [per-call cancellation](#per-call-cancellation): `withOptions` is the
2018
+ only door.
2019
+
2008
2020
  The response total is a unary-body policy, not a stream-buffer measurement. A
2009
2021
  long-lived NDJSON/SSE client opts into streaming explicitly instead of choosing
2010
2022
  an arbitrarily large integer:
@@ -2078,6 +2090,28 @@ including an explicitly declared empty `200` or `205`. A missing body for a
2078
2090
  declared output, or a body for an endpoint with no output, fails loudly instead
2079
2091
  of changing the typed result.
2080
2092
 
2093
+ Validation runs in one direction. The response is checked against the endpoint's
2094
+ `output` schema before it reaches the caller; arguments are **not** checked
2095
+ against `input` or `params` before the request is sent. A value the contract
2096
+ forbids travels to the server and comes back as a `VALIDATION_ERROR` — `400`,
2097
+ naming every offending field in the `message` and again in `details.issues` as
2098
+ `{ path, code, message }`. That holds for a JSON body, a query string and a path
2099
+ parameter alike, so a rejected argument always costs a round trip.
2100
+
2101
+ An application that needs a local refusal can parse the schema itself before
2102
+ calling — `contract.endpoints.<name>.input` is the same Zod object the server
2103
+ validates with:
2104
+
2105
+ ```ts
2106
+ const parsed = contract.endpoints.create.input.safeParse(args)
2107
+ if (!parsed.success) return refuse(parsed.error)
2108
+ await api.create(args)
2109
+ ```
2110
+
2111
+ It then owns a second error shape beside this one, so make the local refusal name
2112
+ the offending fields too. A caller who receives a bare code with no text cannot
2113
+ tell which gate refused or why — and reads it as a refusal of permission.
2114
+
2081
2115
  An explicit contract `HEAD` operation is exposed like any other typed method.
2082
2116
  Because HEAD endpoints are `rawResponse`, it resolves to the untouched
2083
2117
  `Response`, giving the caller direct access to status and headers without JSON
@@ -2115,11 +2149,22 @@ mistaking their callback context for Stitchkit transport options.
2115
2149
  argument is ignored, in silence, and the request runs to completion while the
2116
2150
  caller believes it was cancelled or bounded. TypeScript refuses the extra
2117
2151
  argument at a typed call site and says nothing at an untyped one, which is where
2118
- the mistake actually happens. Nothing can catch it at runtime either: probing the
2119
- second argument is exactly what the callback safety above forbids, since reading
2120
- a foreign object's `signal` may execute someone else's getter. So the rule is
2121
- simply this — **per-call options only ever go through `withOptions`**, and a
2122
- cancellation that appears to do nothing is the first thing to check.
2152
+ the mistake actually happens. Nothing can catch it at runtime **on the bare
2153
+ callable**: probing its second argument is exactly what the callback safety above
2154
+ forbids, since reading a foreign object's `signal` may execute someone else's
2155
+ getter. So the rule is simply this — **per-call options only ever go through
2156
+ `withOptions`**, and a cancellation that appears to do nothing is the first thing
2157
+ to check.
2158
+
2159
+ `withOptions` itself is guarded, because there the count settles it without
2160
+ reading anything. Its arity depends on the endpoint — one argument when there is
2161
+ no contract input, two when there is — and a call carrying more throws a
2162
+ `TypeError` naming the endpoint and the correct shape. That guard exists because
2163
+ the silent version of this mistake is expensive: the options are dropped, the
2164
+ request goes out uncancelled, the caller still receives `REQUEST_ABORTED`
2165
+ (cancellation is decided from the signal it was handed, not from what the
2166
+ transport did), and the server runs the operation to its own deadline. Every
2167
+ symptom then points at the transport, and the investigation goes there.
2123
2168
 
2124
2169
  ```ts
2125
2170
  const controller = new AbortController()
@@ -9496,6 +9541,63 @@ makes one thing your job rather than the resolver's:
9496
9541
  The mechanical part is identical either way. Only the *noticing* differs, and an
9497
9542
  exact pin moves it onto you.
9498
9543
 
9544
+ ## Released migration: 0.73.0
9545
+
9546
+ Two breaking changes. Nothing you send to a server changed, and only one of these
9547
+ can reach a call site the compiler already checks.
9548
+
9549
+ ### If you call `withOptions` from a call site that lost its types
9550
+
9551
+ `withOptions` takes one argument on an endpoint with no contract input, two when
9552
+ there is one. Passing two to a no-input endpoint used to succeed and silently
9553
+ drop the options: the request went out **uncancelled**, the caller still received
9554
+ `REQUEST_ABORTED` — cancellation is decided from the signal it was handed, not
9555
+ from what the transport did — and the server ran the operation to its own
9556
+ deadline. Every symptom then points at the transport, and the investigation goes
9557
+ there. It now throws a `TypeError` naming the endpoint and the correct shape.
9558
+
9559
+ ```ts
9560
+ // before — the options were dropped and the request was never cancelled
9561
+ api.ping.withOptions({}, { signal })
9562
+
9563
+ // after
9564
+ api.ping.withOptions({ signal })
9565
+ ```
9566
+
9567
+ A typed call site already refused the wrong arity, so this reaches only code that
9568
+ does not have the types: a `Record<string, …>` view of the client, a hand-written
9569
+ double, a dynamic dispatch. The guard counts arguments and never reads them, so a
9570
+ method handed to a callback API behaves exactly as before.
9571
+
9572
+ ### If you match on `ApiError.message`
9573
+
9574
+ An `ApiError` that nothing explained used to carry `API Error: ${code}` — a
9575
+ string that reads like an explanation while only restating the code, so a caller
9576
+ could not tell an origin that explained a failure from one that said nothing. It
9577
+ now says which it is.
9578
+
9579
+ ```ts
9580
+ // before
9581
+ err.message === 'API Error: INVALID_INPUT'
9582
+
9583
+ // after
9584
+ err.message === 'INVALID_INPUT (no message supplied)' // better: match err.code
9585
+ ```
9586
+
9587
+ Match `err.code` instead: it is the contract, and it did not change. An error
9588
+ carrying a real message is untouched. An empty message now counts as no message,
9589
+ for the same reason — an empty string is not an explanation either.
9590
+
9591
+ Two related fixes need no migration, but change what you will see. An error the
9592
+ transport raised through `createHttpClient` now carries the transport's own text
9593
+ in `message` and the original error as `cause`, where before it carried neither
9594
+ and filed the text under `details.message` alone; if you followed the retry rule
9595
+ in [the client guide](./client.md) — inspect the adapter's `cause`, retry only
9596
+ when it proves dispatch did not happen — that rule was not executable on this
9597
+ transport and now is. And the client guide now states which direction validation
9598
+ runs: responses are checked against `output`, arguments are **not** checked
9599
+ before being sent.
9600
+
9499
9601
  ## Released migration: 0.72.0
9500
9602
 
9501
9603
  Nothing you *pass* changed. Both items are about types you read or build, and
@@ -12760,6 +12862,7 @@ cutovers are covered by the executable
12760
12862
  | `DiagnosticJournalConfig` / `DiagnosticJournal` | _type_ | owner schema/path/limits/failure observer and the synchronous `submit`, bounded-wait `flush`/`close`, status handle |
12761
12863
  | `DiagnosticJournalLimitsSchema` / `DiagnosticJournalLimits` | schema / _type_ | positive event, pending-item, pending-byte, file-byte and retained-file limits |
12762
12864
  | `DiagnosticJournalLockPolicySchema` / `DiagnosticJournalLockPolicy` | schema / _type_ | `refuse` (default) or `reclaim-stale`, which reclaims only a lock whose recorded owner is provably gone |
12865
+ | `readDiagnosticJournalLockDiagnosis` / `DiagnosticJournalLockDiagnosis` | function / _type_ | why a `reclaim-stale` acquisition refused — owner alive, another machine, or a lock this host cannot attribute — read off the thrown `EEXIST` |
12763
12866
  | `DiagnosticJournalSubmitResultSchema` / `DiagnosticJournalSubmitResult` | schema / _type_ | accepted epoch/sequence or explicit invalid, oversized, capacity, closed or failed refusal |
12764
12867
  | `DiagnosticJournalStatusSchema` / `DiagnosticJournalStatus` | schema / _type_ | state, limits, exact admission/write/failure counters, pending ownership, rotations, partial tails and last safe sequences |
12765
12868
  | `DiagnosticJournalFrameSchema` / `DiagnosticJournalFrame` | schema / _type_ | version-1 JSONL frame carrying process epoch, contiguous accepted sequence and schema-validated JSON event |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.72.5",
3
+ "version": "0.73.0",
4
4
  "description": "Contract-first backend framework — one defineContract() into an HTTP API, MCP tools, AI-agent tools and a typed client. Bun and Node.",
5
5
  "keywords": [
6
6
  "bun",