hikoutei 0.8.59 → 0.8.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/Hikoutei.d.ts.map +1 -1
- package/dist/api/Hikoutei.js +13 -206
- package/dist/api/Hikoutei.js.map +1 -1
- package/dist/application/sync/service/SyncPollingSupervisor.d.ts +0 -16
- package/dist/application/sync/service/SyncPollingSupervisor.d.ts.map +1 -1
- package/dist/application/sync/service/SyncPollingSupervisor.js +0 -24
- package/dist/application/sync/service/SyncPollingSupervisor.js.map +1 -1
- package/dist/application/sync/service/SyncServiceBootstrap.d.ts.map +1 -1
- package/dist/application/sync/service/SyncServiceBootstrap.js +1 -26
- package/dist/application/sync/service/SyncServiceBootstrap.js.map +1 -1
- package/dist/application/sync/service/effectSupervisor.d.ts.map +1 -1
- package/dist/application/sync/service/effectSupervisor.js +9 -114
- package/dist/application/sync/service/effectSupervisor.js.map +1 -1
- package/dist/application/sync/service/pollingSupervisor.d.ts +0 -17
- package/dist/application/sync/service/pollingSupervisor.d.ts.map +1 -1
- package/dist/application/sync/service/pollingSupervisor.js +3 -103
- package/dist/application/sync/service/pollingSupervisor.js.map +1 -1
- package/dist/application/sync/service/serviceOptions.d.ts.map +1 -1
- package/dist/application/sync/service/serviceOptions.js +17 -27
- package/dist/application/sync/service/serviceOptions.js.map +1 -1
- package/dist/application/sync/service/shutdown.d.ts.map +1 -1
- package/dist/application/sync/service/shutdown.js +2 -6
- package/dist/application/sync/service/shutdown.js.map +1 -1
- package/dist/application/sync/service/syncAutoStart.d.ts +6 -71
- package/dist/application/sync/service/syncAutoStart.d.ts.map +1 -1
- package/dist/application/sync/service/syncAutoStart.js +23 -193
- package/dist/application/sync/service/syncAutoStart.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hikoutei.d.ts","sourceRoot":"","sources":["../../src/api/Hikoutei.ts"],"names":[],"mappings":"AAAA;;;;;;;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B,GAAG,IAAI,CAmBlF;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,QAAQ,CAAC,CAkBnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,QAAQ,CAAC,CA8BnB"}
|
package/dist/api/Hikoutei.js
CHANGED
|
@@ -11,36 +11,16 @@ import { createEntityManager } from "./internalEntityManager.js";
|
|
|
11
11
|
import { HIKOUTEI_ERROR_CODES, HikouteiError } from "./errors.js";
|
|
12
12
|
import { getRegisteredEntityTokens, } from "./entity.js";
|
|
13
13
|
import { resolveEntityDescriptors, } from "./internalEntityRegistry.js";
|
|
14
|
-
import { describeErrorForInternalLog, getHikouteiInternalLogger, logHikouteiInternalEvent, } from "../shared/observability/internalLog.js";
|
|
15
|
-
import { HIKOUTEI_LOG_COMPONENTS, HIKOUTEI_LOG_EVENTS, } from "../shared/observability/logEvents.js";
|
|
16
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
17
14
|
/** Environment variable that supplies the default SQLite path. */
|
|
18
15
|
const HIKOUTEI_DB_PATH_ENV = "HIKOUTEI_DB_PATH";
|
|
19
16
|
/** SQLite path used when neither `dbName` nor the env var is set. */
|
|
20
17
|
const DEFAULT_DB_PATH = "./hikoutei.sqlite";
|
|
21
|
-
const beforeCloseHookContext = new AsyncLocalStorage();
|
|
22
18
|
class HikouteiImpl {
|
|
23
19
|
provider;
|
|
24
20
|
beforeClose;
|
|
25
21
|
/** Root entity manager; call `fork()` before request or job-local work. */
|
|
26
22
|
em;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The single in-flight close attempt. Concurrent close() calls OUTSIDE
|
|
30
|
-
* the active beforeClose hook await this same promise, so cleanup runs
|
|
31
|
-
* exactly once per attempt and every caller observes the same outcome
|
|
32
|
-
* (single-flight). The shared promise represents the FULL close +
|
|
33
|
-
* process-logger-drain operation and settles only AFTER the drain
|
|
34
|
-
* completes (final safe step), so a close() that lands while the first
|
|
35
|
-
* attempt is still draining — including one arriving after
|
|
36
|
-
* performClose() succeeded but before the drain finished — awaits the
|
|
37
|
-
* SAME attempt until the drain is done instead of resolving early on
|
|
38
|
-
* the terminal marker or starting a second cleanup. A close() called
|
|
39
|
-
* from WITHIN the hook resolves immediately instead (MEDIUM 5:
|
|
40
|
-
* awaiting the pending attempt from the hook would self-deadlock). A
|
|
41
|
-
* failed attempt leaves the runtime retryable after the slot release.
|
|
42
|
-
*/
|
|
43
|
-
closeAttempt;
|
|
23
|
+
closed = false;
|
|
44
24
|
constructor(provider, descriptors, beforeClose) {
|
|
45
25
|
this.provider = provider;
|
|
46
26
|
this.beforeClose = beforeClose;
|
|
@@ -48,200 +28,27 @@ class HikouteiImpl {
|
|
|
48
28
|
}
|
|
49
29
|
/** Stops internal service work, then releases the local SQLite connection. */
|
|
50
30
|
async close() {
|
|
51
|
-
|
|
52
|
-
// comes BEFORE the terminal fast path so a caller that arrives after
|
|
53
|
-
// performClose() succeeded but while the final logger drain is still
|
|
54
|
-
// running awaits the SAME attempt (which settles only after drain)
|
|
55
|
-
// instead of resolving early on the closed marker — the shared
|
|
56
|
-
// promise represents the full close + drain operation.
|
|
57
|
-
if (this.closeAttempt !== undefined) {
|
|
58
|
-
// MEDIUM 5: a close awaited from within the ACTIVE beforeClose hook
|
|
59
|
-
// of THIS runtime must not await the pending attempt — the attempt
|
|
60
|
-
// cannot settle until the hook returns, so awaiting it would
|
|
61
|
-
// self-deadlock. The call resolves immediately: the close is already
|
|
62
|
-
// in progress and owned by the outer caller, so the hook must not
|
|
63
|
-
// rely on the reentrant promise for completion. The exemption is
|
|
64
|
-
// scoped to the OWNING runtime (runtime identity in the context) AND
|
|
65
|
-
// to the hook's execution window (`active`): a close() on a
|
|
66
|
-
// DIFFERENT runtime made from inside the hook, or a close() from a
|
|
67
|
-
// DETACHED callback (setImmediate/promise continuation) that runs
|
|
68
|
-
// AFTER the hook's execution window ended, is an ordinary concurrent
|
|
69
|
-
// call and shares that runtime's in-flight attempt, observing its
|
|
70
|
-
// exact outcome (Luna: the flag is cleared in `finally`, so the
|
|
71
|
-
// detached callback cannot bypass the close/drain attempt). Callers
|
|
72
|
-
// OUTSIDE any hook (no context store) keep sharing the attempt too.
|
|
73
|
-
const marker = beforeCloseHookContext.getStore();
|
|
74
|
-
if (marker !== undefined && marker.runtime === this && marker.active) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
return this.closeAttempt;
|
|
78
|
-
}
|
|
79
|
-
// A successful close is terminal and idempotent: later calls resolve
|
|
80
|
-
// immediately without touching the provider again.
|
|
81
|
-
if (this.closeState === "closed")
|
|
31
|
+
if (this.closed)
|
|
82
32
|
return;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
settleAttempt = (outcome) => {
|
|
86
|
-
if (outcome.ok)
|
|
87
|
-
resolve();
|
|
88
|
-
else
|
|
89
|
-
reject(outcome.error);
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
this.closeAttempt = attempt;
|
|
93
|
-
// The shared attempt is observed by concurrent callers outside the
|
|
94
|
-
// hook; when none exists, a failed attempt must not surface as an
|
|
95
|
-
// unhandled rejection. The no-op side handler marks the rejection
|
|
96
|
-
// handled for the runtime while those callers still receive the
|
|
97
|
-
// original rejection.
|
|
98
|
-
attempt.catch(() => undefined);
|
|
99
|
-
// The attempt's outcome is decided ONLY after the process logger
|
|
100
|
-
// drain completes (final safe step): the shared promise represents
|
|
101
|
-
// the full close + drain operation, so a concurrent caller awaiting
|
|
102
|
-
// it (including one that arrived while the drain was running) cannot
|
|
103
|
-
// proceed before every final event is on disk.
|
|
104
|
-
let failed = false;
|
|
105
|
-
let failure;
|
|
33
|
+
this.closed = true;
|
|
34
|
+
let beforeCloseError;
|
|
106
35
|
try {
|
|
107
|
-
await this.
|
|
36
|
+
await this.beforeClose?.();
|
|
108
37
|
}
|
|
109
38
|
catch (error) {
|
|
110
|
-
|
|
111
|
-
// that throws `undefined` is still a FAILED attempt and the shared
|
|
112
|
-
// promise must reject, never resolve.
|
|
113
|
-
failed = true;
|
|
114
|
-
failure = error;
|
|
39
|
+
beforeCloseError = error;
|
|
115
40
|
}
|
|
116
41
|
try {
|
|
117
|
-
|
|
118
|
-
// drain the process logger queue so every final event (including
|
|
119
|
-
// RUNTIME_CLOSED and any close-failure line) is on disk before the
|
|
120
|
-
// attempt settles. Drain is fail-open by contract, and even a
|
|
121
|
-
// throwing drain must never mask the close outcome — it is
|
|
122
|
-
// swallowed, never propagated.
|
|
123
|
-
await getHikouteiInternalLogger().drain();
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
// Fail-open: the drain exists to flush diagnostics, so its failure
|
|
127
|
-
// must not change the close outcome decided above.
|
|
128
|
-
}
|
|
129
|
-
// Settle the shared attempt with the ORIGINAL outcome so every
|
|
130
|
-
// concurrent caller observes exactly the same success or failure.
|
|
131
|
-
if (failed) {
|
|
132
|
-
settleAttempt({ ok: false, error: failure });
|
|
42
|
+
await this.provider.close();
|
|
133
43
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// Release the shared slot only after the attempt settled (final safe
|
|
138
|
-
// step). On success performClose() made the close terminal; on
|
|
139
|
-
// failure performClose() already returned the state to retryable
|
|
140
|
-
// "open", so the NEXT close() call after the slot release genuinely
|
|
141
|
-
// re-runs the cleanup. The original failure is rethrown unchanged to
|
|
142
|
-
// THIS caller after the slot release; concurrent callers already
|
|
143
|
-
// received it through the shared attempt.
|
|
144
|
-
this.closeAttempt = undefined;
|
|
145
|
-
if (failed)
|
|
146
|
-
throw failure;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Runs one full cleanup attempt (beforeClose + provider close).
|
|
150
|
-
*
|
|
151
|
-
* Marks the runtime terminally closed ONLY after the provider close
|
|
152
|
-
* succeeded. EVERY failure — a throwing beforeClose hook, a throwing
|
|
153
|
-
* provider close, or the aggregate of both — explicitly returns the
|
|
154
|
-
* state to retryable `open` before the original error is rethrown
|
|
155
|
-
* unchanged, so the next close() call genuinely re-runs the full
|
|
156
|
-
* cleanup instead of no-oping on a half-closed runtime.
|
|
157
|
-
*/
|
|
158
|
-
async performClose() {
|
|
159
|
-
this.closeState = "closing";
|
|
160
|
-
try {
|
|
161
|
-
let beforeCloseFailed = false;
|
|
162
|
-
let beforeCloseError;
|
|
163
|
-
try {
|
|
164
|
-
const beforeClose = this.beforeClose;
|
|
165
|
-
if (beforeClose !== undefined) {
|
|
166
|
-
// MEDIUM 5: the hook runs inside the marked async context so a
|
|
167
|
-
// close() called from within it is recognized as reentrant for
|
|
168
|
-
// THIS runtime (and never awaits its own pending attempt). The
|
|
169
|
-
// stored runtime identity scopes the exemption: a cross-runtime
|
|
170
|
-
// close() made from the hook is not reentrant.
|
|
171
|
-
//
|
|
172
|
-
// Luna: the exemption is scoped to the hook's EXECUTION WINDOW.
|
|
173
|
-
// Detached setImmediate/promise callbacks scheduled by the hook
|
|
174
|
-
// retain the AsyncLocalStorage store after run() returns, so the
|
|
175
|
-
// active flag is cleared in `finally` once the hook's execution
|
|
176
|
-
// has ended — those callbacks' close() then awaits the same
|
|
177
|
-
// close/drain attempt instead of bypassing it. The flag is
|
|
178
|
-
// cleared even when the hook throws.
|
|
179
|
-
const marker = { runtime: this, active: true };
|
|
180
|
-
try {
|
|
181
|
-
await beforeCloseHookContext.run(marker, () => beforeClose());
|
|
182
|
-
}
|
|
183
|
-
finally {
|
|
184
|
-
marker.active = false;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
44
|
+
catch (providerError) {
|
|
45
|
+
if (beforeCloseError !== undefined) {
|
|
46
|
+
throw new AggregateError([beforeCloseError, providerError], "Hikoutei failed to stop internal work and close SQLite.");
|
|
187
47
|
}
|
|
188
|
-
|
|
189
|
-
// Boolean flag, never `error !== undefined`: a hook that throws
|
|
190
|
-
// `undefined` is still a FAILED hook and must keep the attempt
|
|
191
|
-
// failed and retryable instead of being treated as success.
|
|
192
|
-
beforeCloseFailed = true;
|
|
193
|
-
beforeCloseError = error;
|
|
194
|
-
}
|
|
195
|
-
try {
|
|
196
|
-
await this.provider.close();
|
|
197
|
-
}
|
|
198
|
-
catch (providerError) {
|
|
199
|
-
logHikouteiInternalEvent({
|
|
200
|
-
event: HIKOUTEI_LOG_EVENTS.RUNTIME_CLOSE_FAILED,
|
|
201
|
-
level: "error",
|
|
202
|
-
component: HIKOUTEI_LOG_COMPONENTS.RUNTIME,
|
|
203
|
-
...describeErrorForInternalLog(providerError),
|
|
204
|
-
});
|
|
205
|
-
if (beforeCloseFailed) {
|
|
206
|
-
// Luna: the AggregateError preserves BOTH original failure
|
|
207
|
-
// values as-thrown — including a hook that throws `undefined`
|
|
208
|
-
// or `null`, which are legitimate thrown values. The errors
|
|
209
|
-
// array must never replace the original hook failure with a
|
|
210
|
-
// synthetic Error, so diagnostics can always inspect exactly
|
|
211
|
-
// what each stage threw.
|
|
212
|
-
throw new AggregateError([beforeCloseError, providerError], "Hikoutei failed to stop internal work and close SQLite.");
|
|
213
|
-
}
|
|
214
|
-
throw providerError;
|
|
215
|
-
}
|
|
216
|
-
if (beforeCloseFailed) {
|
|
217
|
-
logHikouteiInternalEvent({
|
|
218
|
-
event: HIKOUTEI_LOG_EVENTS.RUNTIME_CLOSE_FAILED,
|
|
219
|
-
level: "error",
|
|
220
|
-
component: HIKOUTEI_LOG_COMPONENTS.RUNTIME,
|
|
221
|
-
...describeErrorForInternalLog(beforeCloseError),
|
|
222
|
-
});
|
|
223
|
-
// `throw beforeCloseError` is intentional: `undefined` is a
|
|
224
|
-
// legitimate thrown value and the rejection still marks the
|
|
225
|
-
// attempt failed (the caller's catch below returns the state to
|
|
226
|
-
// retryable open).
|
|
227
|
-
throw beforeCloseError;
|
|
228
|
-
}
|
|
229
|
-
this.closeState = "closed";
|
|
230
|
-
logHikouteiInternalEvent({
|
|
231
|
-
event: HIKOUTEI_LOG_EVENTS.RUNTIME_CLOSED,
|
|
232
|
-
level: "info",
|
|
233
|
-
component: HIKOUTEI_LOG_COMPONENTS.RUNTIME,
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
// Explicit state transition for EVERY failure path (beforeClose or
|
|
238
|
-
// provider): the runtime returns to retryable `open` so the next
|
|
239
|
-
// close() re-runs the cleanup. The original error is rethrown
|
|
240
|
-
// unchanged; the shared-attempt slot was already released by the
|
|
241
|
-
// caller's finally block.
|
|
242
|
-
this.closeState = "open";
|
|
243
|
-
throw error;
|
|
48
|
+
throw providerError;
|
|
244
49
|
}
|
|
50
|
+
if (beforeCloseError !== undefined)
|
|
51
|
+
throw beforeCloseError;
|
|
245
52
|
}
|
|
246
53
|
}
|
|
247
54
|
/**
|
package/dist/api/Hikoutei.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hikoutei.js","sourceRoot":"","sources":["../../src/api/Hikoutei.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EACL,yBAAyB,GAG1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wBAAwB,GAEzB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"Hikoutei.js","sourceRoot":"","sources":["../../src/api/Hikoutei.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EACL,yBAAyB,GAG1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wBAAwB,GAEzB,MAAM,6BAA6B,CAAC;AAErC,kEAAkE;AAClE,MAAM,oBAAoB,GAAG,kBAAkB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AC;QACjE,yEAAyE;QACzE,8CAA8C;QAC9C,OAAO,6BAA6B,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,4EAA4E;IAC5E,4DAA4D;IAC5D,MAAM,EAAE,yBAAyB,EAAE,GAAG,MAAM,MAAM,CAChD,8CAA8C,CAC/C,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,yBAAyB,CAAC;QAC7C,MAAM;QACN,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC;QACvB,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,SAAS,4BAA4B,CACnC,OAA0C;IAE1C,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,eAAe;YAClB,MAAM,IAAI,aAAa,CACrB,oBAAoB,CAAC,yBAAyB,EAC9C,gFAAgF,CACjF,CAAC;QACJ,KAAK,gBAAgB;YACnB,MAAM,IAAI,aAAa,CACrB,oBAAoB,CAAC,gBAAgB,EACrC,gBAAgB,OAAO,CAAC,UAAU,iCAAiC,CACpE,CAAC;QACJ,KAAK,iBAAiB;YACpB,MAAM,IAAI,aAAa,CACrB,oBAAoB,CAAC,gBAAgB,EACrC,UAAU,OAAO,CAAC,SAAS,4BAA4B,OAAO,CAAC,eAAe,UAAU,OAAO,CAAC,gBAAgB,IAAI,CACrH,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -7,18 +7,6 @@ export interface SyncPollingSupervisorOptions<Report = unknown> {
|
|
|
7
7
|
readonly errorBackoffInitialMs?: number;
|
|
8
8
|
readonly errorBackoffMaxMs?: number;
|
|
9
9
|
readonly wait?: SyncPollingWait;
|
|
10
|
-
/**
|
|
11
|
-
* Deferral gate applied ONLY to the loop's FIRST pass (default: no gate).
|
|
12
|
-
*
|
|
13
|
-
* The first scheduled pass waits for this promise before any remote
|
|
14
|
-
* read starts, so a host can keep the first polling pass out of an
|
|
15
|
-
* initial drain on a shared request limiter. The gate is consulted once:
|
|
16
|
-
* after it resolves, passes keep the normal interval cadence. A gate
|
|
17
|
-
* that throws surfaces through the normal polling error path and is
|
|
18
|
-
* retried (with backoff) before any pass runs. Manual `runOnce()` calls
|
|
19
|
-
* are deliberately NOT gated: they are explicit caller-driven passes.
|
|
20
|
-
*/
|
|
21
|
-
readonly waitForFirstPass?: () => Promise<void>;
|
|
22
10
|
readonly onReport?: (report: Report) => void;
|
|
23
11
|
readonly onError?: (error: unknown) => void;
|
|
24
12
|
}
|
|
@@ -32,8 +20,6 @@ export declare class SyncPollingSupervisor<Report = unknown> {
|
|
|
32
20
|
private readonly errorBackoffInitialMs;
|
|
33
21
|
private readonly errorBackoffMaxMs;
|
|
34
22
|
private readonly wait;
|
|
35
|
-
private readonly waitForFirstPass;
|
|
36
|
-
private firstPassPending;
|
|
37
23
|
private readonly onReport;
|
|
38
24
|
private readonly onError;
|
|
39
25
|
private running;
|
|
@@ -45,8 +31,6 @@ export declare class SyncPollingSupervisor<Report = unknown> {
|
|
|
45
31
|
constructor(options: SyncPollingSupervisorOptions<Report>);
|
|
46
32
|
/** Starts the immediate-then-periodic polling loop. */
|
|
47
33
|
start(): void;
|
|
48
|
-
/** Returns whether a stop has been requested; used to interrupt gates. */
|
|
49
|
-
isStopping(): boolean;
|
|
50
34
|
/** Runs one pass or joins the pass already in flight. */
|
|
51
35
|
runOnce(): Promise<Report>;
|
|
52
36
|
/** Stops scheduling new polls and waits for the current remote read. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncPollingSupervisor.d.ts","sourceRoot":"","sources":["../../../../src/application/sync/service/SyncPollingSupervisor.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAMrD,KAAK,QAAQ,CAAC,MAAM,IAAI,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;AAC9C,MAAM,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,MAAM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,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;IAC/C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkB;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyC;IAClE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyC;IACjE,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,UAAU,CAA2B;gBAE1B,OAAO,EAAE,4BAA4B,CAAC,MAAM,CAAC;IAmBhE,uDAAuD;IAChD,KAAK,IAAI,IAAI;IAMpB,yDAAyD;IAClD,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAcjC,wEAAwE;IACjE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAed,OAAO;YAiBP,gBAAgB;IAoB9B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,WAAW;CAOpB"}
|
|
@@ -12,8 +12,6 @@ export class SyncPollingSupervisor {
|
|
|
12
12
|
errorBackoffInitialMs;
|
|
13
13
|
errorBackoffMaxMs;
|
|
14
14
|
wait;
|
|
15
|
-
waitForFirstPass;
|
|
16
|
-
firstPassPending = false;
|
|
17
15
|
onReport;
|
|
18
16
|
onError;
|
|
19
17
|
running = false;
|
|
@@ -31,8 +29,6 @@ export class SyncPollingSupervisor {
|
|
|
31
29
|
throw new RangeError("poll maximum error backoff must be at least the initial backoff");
|
|
32
30
|
}
|
|
33
31
|
this.wait = options.wait ?? defaultWait;
|
|
34
|
-
this.waitForFirstPass = options.waitForFirstPass;
|
|
35
|
-
this.firstPassPending = options.waitForFirstPass !== undefined;
|
|
36
32
|
this.onReport = options.onReport;
|
|
37
33
|
this.onError = options.onError;
|
|
38
34
|
}
|
|
@@ -41,17 +37,8 @@ export class SyncPollingSupervisor {
|
|
|
41
37
|
if (this.running || !this.acceptingPasses)
|
|
42
38
|
return;
|
|
43
39
|
this.running = true;
|
|
44
|
-
// A stopped-and-restarted supervisor re-arms the first-pass gate: the
|
|
45
|
-
// loop never restarts (stop() is terminal for the accepting flag), but
|
|
46
|
-
// the flag is re-derived here so a fresh supervisor with a gate always
|
|
47
|
-
// consults it exactly once.
|
|
48
|
-
this.firstPassPending = this.waitForFirstPass !== undefined;
|
|
49
40
|
this.loopPromise = this.runLoop();
|
|
50
41
|
}
|
|
51
|
-
/** Returns whether a stop has been requested; used to interrupt gates. */
|
|
52
|
-
isStopping() {
|
|
53
|
-
return !this.acceptingPasses || !this.running;
|
|
54
|
-
}
|
|
55
42
|
/** Runs one pass or joins the pass already in flight. */
|
|
56
43
|
runOnce() {
|
|
57
44
|
if (!this.acceptingPasses) {
|
|
@@ -86,17 +73,6 @@ export class SyncPollingSupervisor {
|
|
|
86
73
|
let errorBackoff = this.errorBackoffInitialMs;
|
|
87
74
|
while (this.running) {
|
|
88
75
|
try {
|
|
89
|
-
if (this.firstPassPending && this.waitForFirstPass !== undefined) {
|
|
90
|
-
// The FIRST pass is deferred until the host gate resolves (for
|
|
91
|
-
// example the System_State drain readiness check). The flag is
|
|
92
|
-
// cleared only AFTER the gate resolves, so a throwing gate keeps
|
|
93
|
-
// the first pass pending through the normal error backoff; a
|
|
94
|
-
// stop() requested while the gate waits is honored right here.
|
|
95
|
-
await this.waitForFirstPass();
|
|
96
|
-
this.firstPassPending = false;
|
|
97
|
-
if (!this.running)
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
76
|
const report = await this.runOnce();
|
|
101
77
|
this.notifyReport(report);
|
|
102
78
|
errorBackoff = this.errorBackoffInitialMs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncPollingSupervisor.js","sourceRoot":"","sources":["../../../../src/application/sync/service/SyncPollingSupervisor.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,MAAM,wBAAwB,GAAG,MAAM,CAAC;AACxC,MAAM,gCAAgC,GAAG,KAAK,CAAC;AAC/C,MAAM,4BAA4B,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"SyncPollingSupervisor.js","sourceRoot":"","sources":["../../../../src/application/sync/service/SyncPollingSupervisor.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,MAAM,wBAAwB,GAAG,MAAM,CAAC;AACxC,MAAM,gCAAgC,GAAG,KAAK,CAAC;AAC/C,MAAM,4BAA4B,GAAG,MAAM,CAAC;AAe5C;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACf,OAAO,CAAmB;IAC1B,UAAU,CAAS;IACnB,qBAAqB,CAAS;IAC9B,iBAAiB,CAAS;IAC1B,IAAI,CAAkB;IACtB,QAAQ,CAAyC;IACjD,OAAO,CAAyC;IACzD,OAAO,GAAG,KAAK,CAAC;IAChB,eAAe,GAAG,IAAI,CAAC;IACvB,WAAW,CAA4B;IACvC,QAAQ,CAA8B;IACtC,WAAW,CAA4B;IACvC,UAAU,CAA2B;IAE7C,YAAmB,OAA6C;QAC9D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,UAAU,IAAI,wBAAwB,EAAE,eAAe,CAAC,CAAC;QACnG,IAAI,CAAC,qBAAqB,GAAG,eAAe,CAC1C,OAAO,CAAC,qBAAqB,IAAI,gCAAgC,EACjE,oBAAoB,CACrB,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,eAAe,CACtC,OAAO,CAAC,iBAAiB,IAAI,4BAA4B,EACzD,4BAA4B,CAC7B,CAAC;QACF,IAAI,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;YACxD,MAAM,IA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AC,KAAK,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,mDAAmD;QACrD,CAAC;IACH,CAAC;CACF;AAED,SAAS,eAAe,CAAC,KAAa,EAAE,KAAa;IACnD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,UAAU,CAAC,GAAG,KAAK,kCAAkC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,WAAW,CAAC,UAAkB;IACrC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncServiceBootstrap.d.ts","sourceRoot":"","sources":["../../../../src/application/sync/service/SyncServiceBootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"SyncServiceBootstrap.d.ts","sourceRoot":"","sources":["../../../../src/application/sync/service/SyncServiceBootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAoCH,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAChC,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAE7B;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,mBAAmB,CAAC,CA4G9B"}
|
|
@@ -29,9 +29,6 @@ import { createRemoteProvider } from "./remoteProvider.js";
|
|
|
29
29
|
import { createEffectSupervisor } from "./effectSupervisor.js";
|
|
30
30
|
import { createPollingSupervisor } from "./pollingSupervisor.js";
|
|
31
31
|
import { createStopHandler, expireRuntimeWriterLeases } from "./shutdown.js";
|
|
32
|
-
import { registerSystemStateReadiness, unregisterSystemStateReadiness, } from "./systemStateReadiness.js";
|
|
33
|
-
import { describeErrorForInternalLog, logHikouteiInternalEvent, } from "../../../shared/observability/internalLog.js";
|
|
34
|
-
import { HIKOUTEI_LOG_COMPONENTS, HIKOUTEI_LOG_EVENTS, } from "../../../shared/observability/logEvents.js";
|
|
35
32
|
import { createWriterOptions, throwSyncResolutionError, validateServiceOptions, } from "./serviceOptions.js";
|
|
36
33
|
/**
|
|
37
34
|
* Opens, provisions, and starts one internal sync service.
|
|
@@ -97,23 +94,7 @@ export async function createInternalSyncService(options) {
|
|
|
97
94
|
effectSupervisor,
|
|
98
95
|
});
|
|
99
96
|
const provider = new MikroOrmScalarPersistenceProvider(runtime.storage, generated.bindings, runtime.flushCoordinator);
|
|
100
|
-
|
|
101
|
-
// only after this assignment, so the captured reference is always the
|
|
102
|
-
// fully constructed runtime. Unregistering happens BEFORE the stop
|
|
103
|
-
// handler runs, so a closing runtime reports ready (no outbox to drain)
|
|
104
|
-
// the moment its close begins.
|
|
105
|
-
let hikoutei;
|
|
106
|
-
const hikouteiClose = async () => {
|
|
107
|
-
unregisterSystemStateReadiness(hikoutei);
|
|
108
|
-
await stop();
|
|
109
|
-
};
|
|
110
|
-
hikoutei = createInternalHikoutei(provider, descriptors, hikouteiClose);
|
|
111
|
-
// Phase 4: register the runtime's System_State readiness right after
|
|
112
|
-
// bootstrap so external convergence barriers can wait on the drain;
|
|
113
|
-
// unregistered on close (see hikouteiClose). Never part of the public
|
|
114
|
-
// API — the registration is keyed to the internal/public runtime object
|
|
115
|
-
// and read only through this internal module.
|
|
116
|
-
registerSystemStateReadiness(hikoutei, runtime.storage);
|
|
97
|
+
const hikoutei = createInternalHikoutei(provider, descriptors, stop);
|
|
117
98
|
effectSupervisor.start();
|
|
118
99
|
pollingSupervisor.start();
|
|
119
100
|
return {
|
|
@@ -128,12 +109,6 @@ export async function createInternalSyncService(options) {
|
|
|
128
109
|
};
|
|
129
110
|
}
|
|
130
111
|
catch (error) {
|
|
131
|
-
logHikouteiInternalEvent({
|
|
132
|
-
event: HIKOUTEI_LOG_EVENTS.SYNC_SERVICE_START_FAILED,
|
|
133
|
-
level: "error",
|
|
134
|
-
component: HIKOUTEI_LOG_COMPONENTS.SYNC_SERVICE,
|
|
135
|
-
...describeErrorForInternalLog(error),
|
|
136
|
-
});
|
|
137
112
|
// Conflict-route registration claims this runtime's mapped-role writer
|
|
138
113
|
// lease before remote provisioning runs; a provisioning failure would
|
|
139
114
|
// otherwise leave the claim valid for the full lease window and every
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncServiceBootstrap.js","sourceRoot":"","sources":["../../../../src/application/sync/service/SyncServiceBootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,sBAAsB,
|
|
1
|
+
{"version":3,"file":"SyncServiceBootstrap.js","sourceRoot":"","sources":["../../../../src/application/sync/service/SyncServiceBootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,GACzB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,uBAAuB,GACxB,MAAM,kFAAkF,CAAC;AAC1F,OAAO,EACL,2BAA2B,GAC5B,MAAM,kFAAkF,CAAC;AAC1F,OAAO,EACL,iCAAiC,GAClC,MAAM,2FAA2F,CAAC;AACnG,OAAO,EACL,0CAA0C,EAC1C,qCAAqC,GACtC,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EACL,6BAA6B,GAC9B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,oCAAoC,GACrC,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EACL,mCAAmC,EACnC,kCAAkC,GACnC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,oBAAoB,EA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AC,CAC9C,CAAC;QACF,MAAM,IAAI,GAAG,iBAAiB,CAAC;YAC7B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,MAAM;YACN,cAAc;YACd,iBAAiB;YACjB,gBAAgB;SACjB,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,IAAI,iCAAiC,CACpD,OAAO,CAAC,OAAO,EACf,SAAS,CAAC,QAAQ,EAClB,OAAO,CAAC,gBAAgB,CACzB,CAAC;QACF,MAAM,QAAQ,GAAG,sBAAsB,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QACrE,gBAAgB,CAAC,KAAK,EAAE,CAAC;QACzB,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAE1B,OAAO;YACL,QAAQ;YACR,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,qBAAqB;YACrB,sBAAsB;YACtB,gBAAgB;YAChB,iBAAiB;YACjB,IAAI;YACJ,KAAK,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE;SAC9B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,uEAAuE;QACvE,sEAAsE;QACtE,sEAAsE;QACtE,oDAAoD;QACpD,oEAAoE;QACpE,sEAAsE;QACtE,0DAA0D;QAC1D,MAAM,yBAAyB,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC;aACrE,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC1B,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACzD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effectSupervisor.d.ts","sourceRoot":"","sources":["../../../../src/application/sync/service/effectSupervisor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH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