hikoutei 0.8.38 → 0.8.39
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/application/sync/service/SyncServiceBootstrap.d.ts.map +1 -1
- package/dist/application/sync/service/SyncServiceBootstrap.js +18 -1
- package/dist/application/sync/service/SyncServiceBootstrap.js.map +1 -1
- package/dist/application/sync/service/systemStateReadiness.d.ts +35 -0
- package/dist/application/sync/service/systemStateReadiness.d.ts.map +1 -0
- package/dist/application/sync/service/systemStateReadiness.js +51 -0
- package/dist/application/sync/service/systemStateReadiness.js.map +1 -0
- package/package.json +1 -1
|
@@ -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;AAyCH,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,CA4H9B"}
|
|
@@ -29,6 +29,7 @@ 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";
|
|
32
33
|
import { createWriterOptions, throwSyncResolutionError, validateServiceOptions, } from "./serviceOptions.js";
|
|
33
34
|
/**
|
|
34
35
|
* Opens, provisions, and starts one internal sync service.
|
|
@@ -94,7 +95,23 @@ export async function createInternalSyncService(options) {
|
|
|
94
95
|
effectSupervisor,
|
|
95
96
|
});
|
|
96
97
|
const provider = new MikroOrmScalarPersistenceProvider(runtime.storage, generated.bindings, runtime.flushCoordinator);
|
|
97
|
-
|
|
98
|
+
// The runtime object is the readiness key: the beforeClose hook runs
|
|
99
|
+
// only after this assignment, so the captured reference is always the
|
|
100
|
+
// fully constructed runtime. Unregistering happens BEFORE the stop
|
|
101
|
+
// handler runs, so a closing runtime reports ready (no outbox to drain)
|
|
102
|
+
// the moment its close begins.
|
|
103
|
+
let hikoutei;
|
|
104
|
+
const hikouteiClose = async () => {
|
|
105
|
+
unregisterSystemStateReadiness(hikoutei);
|
|
106
|
+
await stop();
|
|
107
|
+
};
|
|
108
|
+
hikoutei = createInternalHikoutei(provider, descriptors, hikouteiClose);
|
|
109
|
+
// Register the runtime's System_State readiness right after bootstrap so
|
|
110
|
+
// external convergence barriers can wait on the drain; the runtime is
|
|
111
|
+
// unregistered on close (see hikouteiClose). Never part of the public
|
|
112
|
+
// API — the registration is keyed to the internal/public runtime object
|
|
113
|
+
// and read only through this internal module.
|
|
114
|
+
registerSystemStateReadiness(hikoutei, runtime.storage);
|
|
98
115
|
effectSupervisor.start();
|
|
99
116
|
pollingSupervisor.start();
|
|
100
117
|
return {
|
|
@@ -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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E;QACzE,sEAAsE;QACtE,sEAAsE;QACtE,wEAAwE;QACxE,8CAA8C;QAC9C,4BAA4B,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACxD,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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal System_State readiness controller for external convergence
|
|
3
|
+
* barriers.
|
|
4
|
+
*
|
|
5
|
+
* External tooling (for example the local multi-table soak runner's live
|
|
6
|
+
* convergence phase) needs to know when a runtime's System_State outbox
|
|
7
|
+
* drain has finished so its own batched sheet reads do not compete with
|
|
8
|
+
* the initial drain on the shared request limiter. The sync service
|
|
9
|
+
* registers every runtime it bootstraps here and unregisters it when the
|
|
10
|
+
* runtime closes; a runtime that was never registered (plain local-only
|
|
11
|
+
* mode, or an already-closed runtime) reports ready immediately.
|
|
12
|
+
*
|
|
13
|
+
* This module is deliberately internal: it is never re-exported from
|
|
14
|
+
* `src/index.ts`, and applications observe readiness only through the
|
|
15
|
+
* library's own behavior.
|
|
16
|
+
*/
|
|
17
|
+
import type { Hikoutei } from "../../../api/Hikoutei.js";
|
|
18
|
+
import type { MikroOrmSqliteAdapter } from "../../../adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteAdapter.js";
|
|
19
|
+
import { type SystemStateDrainReadiness } from "@hikoutei/ikisaki";
|
|
20
|
+
/** Registers one bootstrapped runtime for readiness queries. */
|
|
21
|
+
export declare function registerSystemStateReadiness(runtime: Hikoutei, storage: MikroOrmSqliteAdapter): void;
|
|
22
|
+
/** Unregisters one runtime (called on close, before storage is released). */
|
|
23
|
+
export declare function unregisterSystemStateReadiness(runtime: Hikoutei): void;
|
|
24
|
+
/**
|
|
25
|
+
* Reports the CURRENT System_State drain readiness of one runtime.
|
|
26
|
+
*
|
|
27
|
+
* Only the System_State projection's claimable in-flight effects are
|
|
28
|
+
* considered — never the whole-outbox idle state. A pending follower behind
|
|
29
|
+
* a conflict/blocked_candidate/failed predecessor is not claimable drain
|
|
30
|
+
* work and never defers, so an open conflict cannot stall the barrier. A
|
|
31
|
+
* runtime without a registered sync service (local-only mode, or already
|
|
32
|
+
* closed) has no outbox to drain and is ready immediately.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readRuntimeSystemStateReadiness(runtime: Hikoutei): Promise<SystemStateDrainReadiness>;
|
|
35
|
+
//# sourceMappingURL=systemStateReadiness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemStateReadiness.d.ts","sourceRoot":"","sources":["../../../../src/application/sync/service/systemStateReadiness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mFAAmF,CAAC;AAC/H,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,mBAAmB,CAAC;AAiB3B,gEAAgE;AAChE,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAEN;AAED,6EAA6E;AAC7E,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,CAEtE;AAED;;;;;;;;;GASG;AACH,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC,yBAAyB,CAAC,CAIpC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal System_State readiness controller for external convergence
|
|
3
|
+
* barriers.
|
|
4
|
+
*
|
|
5
|
+
* External tooling (for example the local multi-table soak runner's live
|
|
6
|
+
* convergence phase) needs to know when a runtime's System_State outbox
|
|
7
|
+
* drain has finished so its own batched sheet reads do not compete with
|
|
8
|
+
* the initial drain on the shared request limiter. The sync service
|
|
9
|
+
* registers every runtime it bootstraps here and unregisters it when the
|
|
10
|
+
* runtime closes; a runtime that was never registered (plain local-only
|
|
11
|
+
* mode, or an already-closed runtime) reports ready immediately.
|
|
12
|
+
*
|
|
13
|
+
* This module is deliberately internal: it is never re-exported from
|
|
14
|
+
* `src/index.ts`, and applications observe readiness only through the
|
|
15
|
+
* library's own behavior.
|
|
16
|
+
*/
|
|
17
|
+
import { readSystemStateDrainReadinessWithAdapter, } from "@hikoutei/ikisaki";
|
|
18
|
+
/**
|
|
19
|
+
* Registry of bootstrapped runtimes keyed by the runtime object itself.
|
|
20
|
+
*
|
|
21
|
+
* A WeakMap keeps the registry inert: a runtime that is garbage-collected
|
|
22
|
+
* without closing (or whose registration leaked) never pins its storage
|
|
23
|
+
* or SQLite file open, and the key is the exact public `Hikoutei` object
|
|
24
|
+
* the caller holds.
|
|
25
|
+
*/
|
|
26
|
+
const registeredRuntimes = new WeakMap();
|
|
27
|
+
/** Registers one bootstrapped runtime for readiness queries. */
|
|
28
|
+
export function registerSystemStateReadiness(runtime, storage) {
|
|
29
|
+
registeredRuntimes.set(runtime, { storage });
|
|
30
|
+
}
|
|
31
|
+
/** Unregisters one runtime (called on close, before storage is released). */
|
|
32
|
+
export function unregisterSystemStateReadiness(runtime) {
|
|
33
|
+
registeredRuntimes.delete(runtime);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reports the CURRENT System_State drain readiness of one runtime.
|
|
37
|
+
*
|
|
38
|
+
* Only the System_State projection's claimable in-flight effects are
|
|
39
|
+
* considered — never the whole-outbox idle state. A pending follower behind
|
|
40
|
+
* a conflict/blocked_candidate/failed predecessor is not claimable drain
|
|
41
|
+
* work and never defers, so an open conflict cannot stall the barrier. A
|
|
42
|
+
* runtime without a registered sync service (local-only mode, or already
|
|
43
|
+
* closed) has no outbox to drain and is ready immediately.
|
|
44
|
+
*/
|
|
45
|
+
export async function readRuntimeSystemStateReadiness(runtime) {
|
|
46
|
+
const entry = registeredRuntimes.get(runtime);
|
|
47
|
+
if (entry === undefined)
|
|
48
|
+
return { status: "ready" };
|
|
49
|
+
return readSystemStateDrainReadinessWithAdapter(entry.storage);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=systemStateReadiness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemStateReadiness.js","sourceRoot":"","sources":["../../../../src/application/sync/service/systemStateReadiness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EACL,wCAAwC,GAEzC,MAAM,mBAAmB,CAAC;AAO3B;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAA+B,CAAC;AAEtE,gEAAgE;AAChE,MAAM,UAAU,4BAA4B,CAC1C,OAAiB,EACjB,OAA8B;IAE9B,kBAAkB,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,8BAA8B,CAAC,OAAiB;IAC9D,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,OAAiB;IAEjB,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACpD,OAAO,wCAAwC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACjE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hikoutei",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.39",
|
|
4
4
|
"description": "Typed repository and safe write layer for Google Sheets-backed MVPs. SQLite-authoritative entity lifecycle with asynchronous Google Sheets projection.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|