hikoutei 0.4.2 → 0.4.3
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/outbound/SheetsEffectDispatcher.d.ts +64 -0
- package/dist/application/sync/outbound/SheetsEffectDispatcher.d.ts.map +1 -0
- package/dist/application/sync/outbound/SheetsEffectDispatcher.js +440 -0
- package/dist/application/sync/outbound/SheetsEffectDispatcher.js.map +1 -0
- package/dist/application/sync/service/SyncServiceBootstrap.d.ts +3 -4
- package/dist/application/sync/service/SyncServiceBootstrap.d.ts.map +1 -1
- package/dist/application/sync/service/SyncServiceBootstrap.js +7 -4
- package/dist/application/sync/service/SyncServiceBootstrap.js.map +1 -1
- package/dist/application/sync/telemetry/syncTiming.d.ts +20 -33
- package/dist/application/sync/telemetry/syncTiming.d.ts.map +1 -1
- package/dist/application/sync/telemetry/syncTiming.js +14 -12
- package/dist/application/sync/telemetry/syncTiming.js.map +1 -1
- package/dist/infrastructure/storage/errors.d.ts +10 -5
- package/dist/infrastructure/storage/errors.d.ts.map +1 -1
- package/dist/infrastructure/storage/errors.js +10 -7
- package/dist/infrastructure/storage/errors.js.map +1 -1
- package/dist/infrastructure/storage/index.d.ts +6 -4
- package/dist/infrastructure/storage/index.d.ts.map +1 -1
- package/dist/infrastructure/storage/index.js +3 -2
- package/dist/infrastructure/storage/index.js.map +1 -1
- package/dist/infrastructure/storage/sqlite/schema.d.ts +12 -11
- package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -1
- package/dist/infrastructure/storage/sqlite/schema.js +17 -109
- package/dist/infrastructure/storage/sqlite/schema.js.map +1 -1
- package/dist/infrastructure/storage/state/canonical/canonicalCommit.d.ts +2 -2
- package/dist/infrastructure/storage/state/canonical/canonicalCommit.d.ts.map +1 -1
- package/dist/infrastructure/storage/state/canonical/canonicalCommit.js +2 -2
- package/dist/infrastructure/storage/state/canonical/canonicalCommit.js.map +1 -1
- package/dist/infrastructure/storage/state/mapped/mappedPersistenceContext.d.ts +1 -2
- package/dist/infrastructure/storage/state/mapped/mappedPersistenceContext.d.ts.map +1 -1
- package/dist/infrastructure/storage/state/mapped/mappedPersistenceContext.js +1 -2
- package/dist/infrastructure/storage/state/mapped/mappedPersistenceContext.js.map +1 -1
- package/dist/infrastructure/storage/state/observation/observationCanonical.d.ts +1 -1
- package/dist/infrastructure/storage/state/observation/observationCanonical.d.ts.map +1 -1
- package/dist/infrastructure/storage/state/observation/observationQuarantine.d.ts +1 -1
- package/dist/infrastructure/storage/state/observation/observationQuarantine.d.ts.map +1 -1
- package/dist/infrastructure/storage/state/observation/observationQuarantine.js +1 -1
- package/dist/infrastructure/storage/state/observation/observationQuarantine.js.map +1 -1
- package/dist/infrastructure/storage/state/observation/observationTypes.d.ts +1 -1
- package/dist/infrastructure/storage/state/observation/observationTypes.d.ts.map +1 -1
- package/dist/infrastructure/storage/state/observation/observationValidation.d.ts +1 -1
- package/dist/infrastructure/storage/state/observation/observationValidation.d.ts.map +1 -1
- package/dist/infrastructure/storage/state/observation/observationWriter.d.ts +1 -1
- package/dist/infrastructure/storage/state/observation/observationWriter.d.ts.map +1 -1
- package/dist/infrastructure/storage/state/observation/observationWriter.js +1 -2
- package/dist/infrastructure/storage/state/observation/observationWriter.js.map +1 -1
- package/dist/infrastructure/storage/state/resolution/resolutionWriter.d.ts +1 -2
- package/dist/infrastructure/storage/state/resolution/resolutionWriter.d.ts.map +1 -1
- package/dist/infrastructure/storage/state/resolution/resolutionWriter.js +1 -2
- package/dist/infrastructure/storage/state/resolution/resolutionWriter.js.map +1 -1
- package/dist/infrastructure/storage/state/resolution/resolutionWriterContracts.d.ts +1 -1
- package/dist/infrastructure/storage/state/resolution/resolutionWriterContracts.d.ts.map +1 -1
- package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.d.ts +1 -1
- package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.d.ts.map +1 -1
- package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.js +1 -1
- package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.js.map +1 -1
- package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.d.ts +1 -1
- package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.d.ts.map +1 -1
- package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.js +2 -2
- package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.js.map +1 -1
- package/dist/infrastructure/storage/sync/shared/spreadsheetAuthority.d.ts +1 -1
- package/dist/infrastructure/storage/sync/shared/spreadsheetAuthority.d.ts.map +1 -1
- package/dist/infrastructure/storage/sync/shared/spreadsheetAuthority.js +1 -1
- package/dist/infrastructure/storage/sync/shared/spreadsheetAuthority.js.map +1 -1
- package/dist/infrastructure/storage/sync/shared/syncRegistry.d.ts +1 -1
- package/dist/infrastructure/storage/sync/shared/syncRegistry.js +1 -1
- package/package.json +13 -7
- package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.d.ts +0 -66
- package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.d.ts.map +0 -1
- package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.js +0 -123
- package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.js.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectSupervisor.d.ts +0 -111
- package/dist/application/sync/outbound/effects/SyncEffectSupervisor.d.ts.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectSupervisor.js +0 -369
- package/dist/application/sync/outbound/effects/SyncEffectSupervisor.js.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorker.d.ts +0 -127
- package/dist/application/sync/outbound/effects/SyncEffectWorker.d.ts.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorker.js +0 -552
- package/dist/application/sync/outbound/effects/SyncEffectWorker.js.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.d.ts +0 -85
- package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.d.ts.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.js +0 -74
- package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.js.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.d.ts +0 -31
- package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.d.ts.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.js +0 -222
- package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.js.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.d.ts +0 -14
- package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.d.ts.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.js +0 -25
- package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.js.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.d.ts +0 -61
- package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.d.ts.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.js +0 -296
- package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.js.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.d.ts +0 -17
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.d.ts.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.js +0 -80
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.js.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.d.ts +0 -13
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.d.ts.map +0 -1
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.js +0 -248
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.js.map +0 -1
- package/dist/infrastructure/storage/sync/outbound/effectOutbox.d.ts +0 -141
- package/dist/infrastructure/storage/sync/outbound/effectOutbox.d.ts.map +0 -1
- package/dist/infrastructure/storage/sync/outbound/effectOutbox.js +0 -318
- package/dist/infrastructure/storage/sync/outbound/effectOutbox.js.map +0 -1
- package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.d.ts +0 -143
- package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.d.ts.map +0 -1
- package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.js +0 -16
- package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.js.map +0 -1
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.d.ts +0 -33
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.d.ts.map +0 -1
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.js +0 -259
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.js.map +0 -1
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.d.ts +0 -27
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.d.ts.map +0 -1
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.js +0 -316
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.js.map +0 -1
- package/dist/infrastructure/storage/sync/shared/writerLease.d.ts +0 -76
- package/dist/infrastructure/storage/sync/shared/writerLease.d.ts.map +0 -1
- package/dist/infrastructure/storage/sync/shared/writerLease.js +0 -189
- package/dist/infrastructure/storage/sync/shared/writerLease.js.map +0 -1
- package/docs/advanced-sheets-gateway-concurrency-problem.md +0 -434
- package/docs/architecture.md +0 -224
- package/docs/ci.md +0 -293
- package/docs/code-guidelines.md +0 -248
- package/docs/development.md +0 -74
- package/docs/gateway-removal-inventory.md +0 -147
- package/docs/git-workflow.md +0 -224
- package/docs/google-sheets-sync-scaling-strategy.md +0 -459
- package/docs/mikro-orm-adapter-spike.md +0 -89
- package/docs/quick-start.md +0 -137
- package/docs/sql-layer-plan.md +0 -59
- package/docs/sync-bulk-write-benchmark.md +0 -2117
- package/docs/sync-observability.md +0 -100
- package/docs/task-queue-write-model.md +0 -640
- package/docs/typed-sheets-mvp-scope-2026-06-29.md +0 -490
- package/docs/typed-sheets-plan.md +0 -417
- package/docs/write-and-synchronization-flow.md +0 -179
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Durable per-spreadsheet authority records used to fence remote mutations. */
|
|
2
2
|
import { STORAGE_ERROR_CODES, StorageError } from "../../errors.js";
|
|
3
|
-
import { isFencingValidWithSql } from "
|
|
3
|
+
import { isFencingValidWithSql } from "@hikoutei/outbox";
|
|
4
4
|
const READ_PHYSICAL_AUTHORITY_SQL = `
|
|
5
5
|
SELECT physical.spreadsheet_id, authority.owner_id, authority.authority_epoch,
|
|
6
6
|
authority.authority_token, authority.updated_at
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spreadsheetAuthority.js","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/shared/spreadsheetAuthority.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"spreadsheetAuthority.js","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/shared/spreadsheetAuthority.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAuB,MAAM,kBAAkB,CAAC;AAE9E,MAAM,2BAA2B,GAAG;;;;;;;CAOnC,CAAC;AAEF,MAAM,oBAAoB,GAAG;;;;CAI5B,CAAC;AAEF,MAAM,oBAAoB,GAAG;;;;;CAK5B,CAAC;AAcF,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,GAAgB,EAChB,OAAwF;IAExF,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,YAA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AS,IAAI,GAAG,CAAC,eAAe,KAAK,IAAI,EAAE,CAAC;QACtE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO;QACL,aAAa,EAAE,GAAG,CAAC,cAAc;QACjC,OAAO,EAAE,GAAG,CAAC,QAAQ,IAAI,EAAE;QAC3B,cAAc,EAAE,GAAG,CAAC,eAAe;QACnC,cAAc,EAAE,GAAG,CAAC,eAAe;QACnC,SAAS,EAAE,GAAG,CAAC,UAAU,IAAI,CAAC;KAC/B,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,OAA0B,EAC1B,eAAuB;IAEvB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,+BAA+B,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { type RegisteredProjectionKind } from "../../../../domain/model/constants.js";
|
|
9
9
|
import type { SqlExecutor, SqlStorageAdapter } from "../../../../adapter/persistence/contracts/sql.js";
|
|
10
|
-
import { type FencingContext } from "
|
|
10
|
+
import { type FencingContext } from "@hikoutei/outbox";
|
|
11
11
|
/** The only projection labels accepted by the v1 runtime registry. */
|
|
12
12
|
export type RegisteredProjection = RegisteredProjectionKind;
|
|
13
13
|
/** Immutable logical/physical registration supplied by deployment setup. */
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { STORAGE_ERROR_CODES, StorageError } from "../../errors.js";
|
|
9
9
|
import { REGISTERED_PROJECTION_KINDS, } from "../../../../domain/model/constants.js";
|
|
10
10
|
import { withSqlSavepoint } from "../../sqlite/sqlTransaction.js";
|
|
11
|
-
import { isFencingValidWithSql, } from "
|
|
11
|
+
import { isFencingValidWithSql, } from "@hikoutei/outbox";
|
|
12
12
|
const READ_LOGICAL_SHEET_REGISTRATION_SQL = `
|
|
13
13
|
SELECT schema_version, ownership_manifest_json, business_key_field, anchor_mode, enabled
|
|
14
14
|
FROM sheet_registry
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hikoutei",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Hikoutei — typed repository and safe write layer for Google Sheets-backed MVPs.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://github.com/ManddarinShop/Hikoutei#readme",
|
|
13
13
|
"type": "module",
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=22.3"
|
|
16
|
+
},
|
|
14
17
|
"main": "./dist/index.js",
|
|
15
18
|
"types": "./dist/index.d.ts",
|
|
16
19
|
"exports": {
|
|
@@ -20,15 +23,14 @@
|
|
|
20
23
|
}
|
|
21
24
|
},
|
|
22
25
|
"files": [
|
|
23
|
-
"dist"
|
|
24
|
-
"docs"
|
|
26
|
+
"dist"
|
|
25
27
|
],
|
|
26
28
|
"scripts": {
|
|
27
29
|
"clean": "node scripts/clean-dist.mjs",
|
|
28
|
-
"build": "npm run clean && tsc -p tsconfig.json",
|
|
29
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
30
|
-
"typecheck:test": "tsc -p tsconfig.test.json",
|
|
31
|
-
"test": "vitest run
|
|
30
|
+
"build": "npm run build -w @hikoutei/outbox && npm run clean && tsc -p tsconfig.json",
|
|
31
|
+
"typecheck": "npm run build -w @hikoutei/outbox && tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"typecheck:test": "npm run build -w @hikoutei/outbox && tsc -p tsconfig.test.json && tsc -p packages/outbox/tsconfig.test.json",
|
|
33
|
+
"test": "npm run build -w @hikoutei/outbox && vitest run"
|
|
32
34
|
},
|
|
33
35
|
"keywords": [
|
|
34
36
|
"google-sheets",
|
|
@@ -37,9 +39,13 @@
|
|
|
37
39
|
"optimistic-locking"
|
|
38
40
|
],
|
|
39
41
|
"license": "MIT",
|
|
42
|
+
"workspaces": [
|
|
43
|
+
"packages/*"
|
|
44
|
+
],
|
|
40
45
|
"dependencies": {
|
|
41
46
|
"@googleapis/sheets": "^14.0.0",
|
|
42
47
|
"@hikoutei/kohkai": "0.1.0",
|
|
48
|
+
"@hikoutei/outbox": "0.1.0",
|
|
43
49
|
"google-auth-library": "^11.0.0"
|
|
44
50
|
},
|
|
45
51
|
"devDependencies": {
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/** Adaptive route batch sizing for the durable outbound effect worker. */
|
|
2
|
-
export declare const ADAPTIVE_EFFECT_BATCH_LIMITS: {
|
|
3
|
-
readonly MINIMUM: 5;
|
|
4
|
-
readonly INITIAL: 10;
|
|
5
|
-
readonly MAXIMUM: 20;
|
|
6
|
-
};
|
|
7
|
-
export declare const DEFAULT_EFFECT_BATCH_COALESCE_WINDOW_MS = 500;
|
|
8
|
-
export declare const EFFECT_BATCH_HIGH_LATENCY_THRESHOLD_MS = 30000;
|
|
9
|
-
export declare const EFFECT_BATCH_STABLE_SUCCESSES_TO_GROW = 3;
|
|
10
|
-
export declare const EFFECT_BATCH_GROWTH_STEP = 5;
|
|
11
|
-
export interface AdaptiveEffectBatchObservation {
|
|
12
|
-
readonly durationMs: number;
|
|
13
|
-
readonly responseSucceeded: boolean;
|
|
14
|
-
readonly responseLoss: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Keeps a small, process-local batch policy while SQLite remains the durable
|
|
18
|
-
* queue. A failed or slow route backs off without changing effect evidence;
|
|
19
|
-
* repeated healthy responses grow the route back toward the safe maximum.
|
|
20
|
-
*/
|
|
21
|
-
export declare class AdaptiveEffectBatchController {
|
|
22
|
-
private readonly minimum;
|
|
23
|
-
private readonly maximum;
|
|
24
|
-
private readonly initial;
|
|
25
|
-
private readonly coalesceWindowMs;
|
|
26
|
-
private readonly highLatencyThresholdMs;
|
|
27
|
-
private readonly stableSuccessesToGrow;
|
|
28
|
-
private readonly growthStep;
|
|
29
|
-
private readonly appendDispatchIntervalMs;
|
|
30
|
-
private readonly routes;
|
|
31
|
-
private lastDispatchAt;
|
|
32
|
-
private lastAppendDispatchAt;
|
|
33
|
-
constructor(options?: {
|
|
34
|
-
readonly minimum?: number;
|
|
35
|
-
readonly initial?: number;
|
|
36
|
-
readonly maximum?: number;
|
|
37
|
-
readonly coalesceWindowMs?: number;
|
|
38
|
-
readonly highLatencyThresholdMs?: number;
|
|
39
|
-
readonly stableSuccessesToGrow?: number;
|
|
40
|
-
readonly growthStep?: number;
|
|
41
|
-
/** Minimum interval between fast-append request starts; 0 disables the throttle. */
|
|
42
|
-
readonly appendDispatchIntervalMs?: number;
|
|
43
|
-
});
|
|
44
|
-
/** Returns the current route limit without touching durable effect state. */
|
|
45
|
-
limitFor(routeKey: string): number;
|
|
46
|
-
/** Marks a route dispatch so the next selection can coalesce a short burst. */
|
|
47
|
-
beginDispatch(routeKey: string, now?: number): number;
|
|
48
|
-
/** Updates only the process-local limit from the completed provider attempt. */
|
|
49
|
-
observe(routeKey: string, observation: AdaptiveEffectBatchObservation): void;
|
|
50
|
-
/** Waits at most the configured short coalescing window before selection. */
|
|
51
|
-
waitForCoalescing(now?: number): Promise<number>;
|
|
52
|
-
/**
|
|
53
|
-
* Records the start of one fast-append request so the next append request
|
|
54
|
-
* waits only the remaining throttle interval. The marker is process-local
|
|
55
|
-
* and survives supervisor passes because the controller outlives one pass.
|
|
56
|
-
*/
|
|
57
|
-
beginAppendDispatch(now?: number): void;
|
|
58
|
-
/**
|
|
59
|
-
* Waits only the time remaining since the last fast-append request started.
|
|
60
|
-
* Regular applyEffects dispatch never waits on this throttle; when the
|
|
61
|
-
* interval is 0 (direct workers and fake providers) this returns immediately.
|
|
62
|
-
*/
|
|
63
|
-
waitForAppendThrottle(now?: number): Promise<number>;
|
|
64
|
-
private routeState;
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=AdaptiveEffectBatchController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AdaptiveEffectBatchController.d.ts","sourceRoot":"","sources":["../../../../../src/application/sync/outbound/effects/AdaptiveEffectBatchController.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,eAAO,MAAM,4BAA4B;;;;CAI/B,CAAC;AAEX,eAAO,MAAM,uCAAuC,MAAM,CAAC;AAC3D,eAAO,MAAM,sCAAsC,QAAS,CAAC;AAC7D,eAAO,MAAM,qCAAqC,IAAI,CAAC;AACvD,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAOD;;;;GAIG;AACH,qBAAa,6BAA6B;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAS;IAChD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;IAC/C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAS;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IACxD,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,oBAAoB,CAAqB;gBAE9B,OAAO,GAAE;QAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QACnC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;QACzC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;QACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAC7B,oFAAoF;QACpF,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;KACvC;IA6BN,6EAA6E;IACtE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIzC,+EAA+E;IACxE,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,MAAM;IAMxE,gFAAgF;IACzE,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,8BAA8B,GAAG,IAAI;IAiBnF,6EAA6E;IAChE,iBAAiB,CAAC,GAAG,GAAE,MAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAQzE;;;;OAIG;IACI,mBAAmB,CAAC,GAAG,GAAE,MAAmB,GAAG,IAAI;IAI1D;;;;OAIG;IACU,qBAAqB,CAAC,GAAG,GAAE,MAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAU7E,OAAO,CAAC,UAAU;CAOnB"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/** Adaptive route batch sizing for the durable outbound effect worker. */
|
|
2
|
-
export const ADAPTIVE_EFFECT_BATCH_LIMITS = {
|
|
3
|
-
MINIMUM: 5,
|
|
4
|
-
INITIAL: 10,
|
|
5
|
-
MAXIMUM: 20,
|
|
6
|
-
};
|
|
7
|
-
export const DEFAULT_EFFECT_BATCH_COALESCE_WINDOW_MS = 500;
|
|
8
|
-
export const EFFECT_BATCH_HIGH_LATENCY_THRESHOLD_MS = 30_000;
|
|
9
|
-
export const EFFECT_BATCH_STABLE_SUCCESSES_TO_GROW = 3;
|
|
10
|
-
export const EFFECT_BATCH_GROWTH_STEP = 5;
|
|
11
|
-
/**
|
|
12
|
-
* Keeps a small, process-local batch policy while SQLite remains the durable
|
|
13
|
-
* queue. A failed or slow route backs off without changing effect evidence;
|
|
14
|
-
* repeated healthy responses grow the route back toward the safe maximum.
|
|
15
|
-
*/
|
|
16
|
-
export class AdaptiveEffectBatchController {
|
|
17
|
-
minimum;
|
|
18
|
-
maximum;
|
|
19
|
-
initial;
|
|
20
|
-
coalesceWindowMs;
|
|
21
|
-
highLatencyThresholdMs;
|
|
22
|
-
stableSuccessesToGrow;
|
|
23
|
-
growthStep;
|
|
24
|
-
appendDispatchIntervalMs;
|
|
25
|
-
routes = new Map();
|
|
26
|
-
lastDispatchAt;
|
|
27
|
-
lastAppendDispatchAt;
|
|
28
|
-
constructor(options = {}) {
|
|
29
|
-
this.minimum = requireBatchLimit(options.minimum ?? ADAPTIVE_EFFECT_BATCH_LIMITS.MINIMUM, "minimum");
|
|
30
|
-
this.initial = requireBatchLimit(options.initial ?? ADAPTIVE_EFFECT_BATCH_LIMITS.INITIAL, "initial");
|
|
31
|
-
this.maximum = requireBatchLimit(options.maximum ?? ADAPTIVE_EFFECT_BATCH_LIMITS.MAXIMUM, "maximum");
|
|
32
|
-
if (this.minimum > this.initial || this.initial > this.maximum) {
|
|
33
|
-
throw new RangeError("adaptive effect batch limits must satisfy minimum <= initial <= maximum");
|
|
34
|
-
}
|
|
35
|
-
this.coalesceWindowMs = requireNonNegativeInteger(options.coalesceWindowMs ?? DEFAULT_EFFECT_BATCH_COALESCE_WINDOW_MS, "coalesceWindowMs");
|
|
36
|
-
this.highLatencyThresholdMs = requirePositiveInteger(options.highLatencyThresholdMs ?? EFFECT_BATCH_HIGH_LATENCY_THRESHOLD_MS, "highLatencyThresholdMs");
|
|
37
|
-
this.stableSuccessesToGrow = requirePositiveInteger(options.stableSuccessesToGrow ?? EFFECT_BATCH_STABLE_SUCCESSES_TO_GROW, "stableSuccessesToGrow");
|
|
38
|
-
this.growthStep = requirePositiveInteger(options.growthStep ?? EFFECT_BATCH_GROWTH_STEP, "growthStep");
|
|
39
|
-
this.appendDispatchIntervalMs = requireNonNegativeInteger(options.appendDispatchIntervalMs ?? 0, "appendDispatchIntervalMs");
|
|
40
|
-
}
|
|
41
|
-
/** Returns the current route limit without touching durable effect state. */
|
|
42
|
-
limitFor(routeKey) {
|
|
43
|
-
return this.routeState(routeKey).limit;
|
|
44
|
-
}
|
|
45
|
-
/** Marks a route dispatch so the next selection can coalesce a short burst. */
|
|
46
|
-
beginDispatch(routeKey, now = Date.now()) {
|
|
47
|
-
this.routeState(routeKey);
|
|
48
|
-
this.lastDispatchAt = now;
|
|
49
|
-
return this.limitFor(routeKey);
|
|
50
|
-
}
|
|
51
|
-
/** Updates only the process-local limit from the completed provider attempt. */
|
|
52
|
-
observe(routeKey, observation) {
|
|
53
|
-
const state = this.routeState(routeKey);
|
|
54
|
-
const unhealthy = observation.responseLoss ||
|
|
55
|
-
!observation.responseSucceeded ||
|
|
56
|
-
observation.durationMs > this.highLatencyThresholdMs;
|
|
57
|
-
if (unhealthy) {
|
|
58
|
-
state.limit = Math.max(this.minimum, Math.floor(state.limit / 2));
|
|
59
|
-
state.stableSuccesses = 0;
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
state.stableSuccesses += 1;
|
|
63
|
-
if (state.stableSuccesses >= this.stableSuccessesToGrow) {
|
|
64
|
-
state.limit = Math.min(this.maximum, state.limit + this.growthStep);
|
|
65
|
-
state.stableSuccesses = 0;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/** Waits at most the configured short coalescing window before selection. */
|
|
69
|
-
async waitForCoalescing(now = Date.now()) {
|
|
70
|
-
if (this.lastDispatchAt === undefined || this.coalesceWindowMs === 0)
|
|
71
|
-
return 0;
|
|
72
|
-
const remaining = this.lastDispatchAt + this.coalesceWindowMs - now;
|
|
73
|
-
if (remaining <= 0)
|
|
74
|
-
return 0;
|
|
75
|
-
await new Promise((resolve) => setTimeout(resolve, remaining));
|
|
76
|
-
return remaining;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Records the start of one fast-append request so the next append request
|
|
80
|
-
* waits only the remaining throttle interval. The marker is process-local
|
|
81
|
-
* and survives supervisor passes because the controller outlives one pass.
|
|
82
|
-
*/
|
|
83
|
-
beginAppendDispatch(now = Date.now()) {
|
|
84
|
-
this.lastAppendDispatchAt = now;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Waits only the time remaining since the last fast-append request started.
|
|
88
|
-
* Regular applyEffects dispatch never waits on this throttle; when the
|
|
89
|
-
* interval is 0 (direct workers and fake providers) this returns immediately.
|
|
90
|
-
*/
|
|
91
|
-
async waitForAppendThrottle(now = Date.now()) {
|
|
92
|
-
if (this.appendDispatchIntervalMs === 0 || this.lastAppendDispatchAt === undefined) {
|
|
93
|
-
return 0;
|
|
94
|
-
}
|
|
95
|
-
const remaining = this.lastAppendDispatchAt + this.appendDispatchIntervalMs - now;
|
|
96
|
-
if (remaining <= 0)
|
|
97
|
-
return 0;
|
|
98
|
-
await new Promise((resolve) => setTimeout(resolve, remaining));
|
|
99
|
-
return remaining;
|
|
100
|
-
}
|
|
101
|
-
routeState(routeKey) {
|
|
102
|
-
const existing = this.routes.get(routeKey);
|
|
103
|
-
if (existing !== undefined)
|
|
104
|
-
return existing;
|
|
105
|
-
const state = { limit: this.initial, stableSuccesses: 0 };
|
|
106
|
-
this.routes.set(routeKey, state);
|
|
107
|
-
return state;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function requireBatchLimit(value, label) {
|
|
111
|
-
return requirePositiveInteger(value, label);
|
|
112
|
-
}
|
|
113
|
-
function requirePositiveInteger(value, label) {
|
|
114
|
-
if (!Number.isSafeInteger(value) || value <= 0)
|
|
115
|
-
throw new RangeError(`adaptive ${label} must be a positive safe integer`);
|
|
116
|
-
return value;
|
|
117
|
-
}
|
|
118
|
-
function requireNonNegativeInteger(value, label) {
|
|
119
|
-
if (!Number.isSafeInteger(value) || value < 0)
|
|
120
|
-
throw new RangeError(`adaptive ${label} must be a non-negative safe integer`);
|
|
121
|
-
return value;
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=AdaptiveEffectBatchController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AdaptiveEffectBatchController.js","sourceRoot":"","sources":["../../../../../src/application/sync/outbound/effects/AdaptiveEffectBatchController.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;CACH,CAAC;AAEX,MAAM,CAAC,MAAM,uCAAuC,GAAG,GAAG,CAAC;AAC3D,MAAM,CAAC,MAAM,sCAAsC,GAAG,MAAM,CAAC;AAC7D,MAAM,CAAC,MAAM,qCAAqC,GAAG,CAAC,CAAC;AACvD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAY1C;;;;GAIG;AACH,MAAM,OAAO,6BAA6B;IACvB,OAAO,CAAS;IAChB,OAAO,CAAS;IAChB,OAAO,CAAS;IAChB,gBAAgB,CAAS;IACzB,sBAAsB,CAAS;IAC/B,qBAAqB,CAAS;IAC9B,UAAU,CAAS;IACnB,wBAAwB,CAAS;IACjC,MAAM,GAAG,IAAI,GAAG,EAAsB,CAAC;IAChD,cAAc,CAAqB;IACnC,oBAAoB,CAAqB;IAEjD,YAAmB,UAUf,EAAE;QACJ,IAAI,CAAC,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,OAAO,IAAI,4BAA4B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACrG,IAAI,CAAC,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,OAAO,IAAI,4BAA4B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACrG,IAAI,CAAC,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,OAAO,IAAI,4BAA4B,CAAC,OAAO,EA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AAED,SAAS,yBAAyB,CAAC,KAAa,EAAE,KAAa;IAC7D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,YAAY,KAAK,sCAAsC,CAAC,CAAC;IAC7H,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Keeps the bounded effect worker running until the durable outbox is idle.
|
|
3
|
-
*
|
|
4
|
-
* The supervisor provides liveness around `runSyncEffectWorker*()`: one pass
|
|
5
|
-
* still handles a bounded batch, while this loop starts the next pass and
|
|
6
|
-
* backs off after failures. It also coalesces manual and background triggers so
|
|
7
|
-
* one process cannot run two effect passes concurrently.
|
|
8
|
-
*/
|
|
9
|
-
import type { ReconciliationScanReport } from "../reconciliation/ReconciliationScanner.js";
|
|
10
|
-
import { type SyncEffectWorkerReport, type SyncEffectWorkerWithAdapterOptions } from "./SyncEffectWorker.js";
|
|
11
|
-
import { type AdaptiveEffectBatchController as AdaptiveEffectBatchControllerType } from "./AdaptiveEffectBatchController.js";
|
|
12
|
-
export type SyncEffectWorkerSupervisorWait = (durationMs: number) => Promise<void>;
|
|
13
|
-
type RunPass = () => Promise<SyncEffectWorkerReport>;
|
|
14
|
-
/** Periodic reconciliation(불일치 보정) task attached to the effect loop. */
|
|
15
|
-
export interface SyncEffectWorkerSupervisorReconciliationOptions {
|
|
16
|
-
/** Minimum delay between scan attempts. The first scan runs immediately. */
|
|
17
|
-
readonly intervalMs?: number;
|
|
18
|
-
/** Confirms that no pending or processing outbox work remains before scanning. */
|
|
19
|
-
readonly isOutboxIdle?: () => Promise<boolean>;
|
|
20
|
-
/** Runs one scan and enqueues corrections into the durable outbox. */
|
|
21
|
-
readonly run: () => Promise<ReconciliationScanReport>;
|
|
22
|
-
/** Receives a completed scan without being allowed to stop the loop. */
|
|
23
|
-
readonly onReport?: (report: ReconciliationScanReport) => void;
|
|
24
|
-
/** Receives scan failures; the effect worker continues independently. */
|
|
25
|
-
readonly onError?: (error: unknown) => void;
|
|
26
|
-
}
|
|
27
|
-
/** Options for the runtime loop; `runPass` is injectable for deterministic tests. */
|
|
28
|
-
export interface SyncEffectWorkerSupervisorLoopOptions {
|
|
29
|
-
readonly runPass: RunPass;
|
|
30
|
-
readonly idleIntervalMs?: number;
|
|
31
|
-
readonly errorBackoffInitialMs?: number;
|
|
32
|
-
readonly errorBackoffMaxMs?: number;
|
|
33
|
-
readonly random?: () => number;
|
|
34
|
-
readonly wait?: SyncEffectWorkerSupervisorWait;
|
|
35
|
-
readonly now?: () => number;
|
|
36
|
-
readonly reconciliation?: SyncEffectWorkerSupervisorReconciliationOptions;
|
|
37
|
-
readonly onReport?: (report: SyncEffectWorkerReport) => void;
|
|
38
|
-
readonly onError?: (error: unknown) => void;
|
|
39
|
-
}
|
|
40
|
-
/** Worker options with a clock supplied by the supervisor on every pass. */
|
|
41
|
-
export type CreateSyncEffectWorkerSupervisorOptions = Omit<SyncEffectWorkerWithAdapterOptions, "now" | "workerId" | "maxEffects" | "writerLeaseDurationMs" | "effectLeaseDurationMs" | "requestTimeoutMs"> & {
|
|
42
|
-
readonly workerId?: string;
|
|
43
|
-
readonly maxEffects?: number;
|
|
44
|
-
readonly writerLeaseDurationMs?: number;
|
|
45
|
-
readonly effectLeaseDurationMs?: number;
|
|
46
|
-
readonly requestTimeoutMs?: number;
|
|
47
|
-
readonly batchController?: AdaptiveEffectBatchControllerType;
|
|
48
|
-
readonly now?: () => number;
|
|
49
|
-
readonly idleIntervalMs?: number;
|
|
50
|
-
readonly errorBackoffInitialMs?: number;
|
|
51
|
-
readonly errorBackoffMaxMs?: number;
|
|
52
|
-
readonly random?: () => number;
|
|
53
|
-
readonly wait?: SyncEffectWorkerSupervisorWait;
|
|
54
|
-
readonly reconciliation?: SyncEffectWorkerSupervisorReconciliationOptions;
|
|
55
|
-
readonly onReport?: (report: SyncEffectWorkerReport) => void;
|
|
56
|
-
readonly onError?: (error: unknown) => void;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Runs one bounded effect pass at a time and continues while work is making
|
|
60
|
-
* progress. `stop()` waits for the current remote call to finish before the
|
|
61
|
-
* loop exits, so the caller does not close SQLite underneath an active pass.
|
|
62
|
-
*/
|
|
63
|
-
export declare class SyncEffectWorkerSupervisor {
|
|
64
|
-
private readonly runPass;
|
|
65
|
-
private readonly idleIntervalMs;
|
|
66
|
-
private readonly errorBackoffInitialMs;
|
|
67
|
-
private readonly errorBackoffMaxMs;
|
|
68
|
-
private readonly random;
|
|
69
|
-
private readonly wait;
|
|
70
|
-
private readonly now;
|
|
71
|
-
private readonly reconciliation;
|
|
72
|
-
private readonly reconciliationIntervalMs;
|
|
73
|
-
private readonly onReport;
|
|
74
|
-
private readonly onError;
|
|
75
|
-
private running;
|
|
76
|
-
private acceptingPasses;
|
|
77
|
-
private loopPromise;
|
|
78
|
-
private inFlightPass;
|
|
79
|
-
private inFlightReconciliation;
|
|
80
|
-
private stopPromise;
|
|
81
|
-
private nextReconciliationAt;
|
|
82
|
-
private wakeWaiter;
|
|
83
|
-
constructor(options: SyncEffectWorkerSupervisorLoopOptions);
|
|
84
|
-
/** Starts the background drain loop; repeated calls are harmless. */
|
|
85
|
-
start(): void;
|
|
86
|
-
/** Returns whether the supervisor is accepting background work. */
|
|
87
|
-
isRunning(): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Runs one pass or joins the pass already running in this process.
|
|
90
|
-
* Manual HTTP triggers therefore cannot create a second concurrent worker.
|
|
91
|
-
*/
|
|
92
|
-
runOnce(): Promise<SyncEffectWorkerReport>;
|
|
93
|
-
/** Stops scheduling new passes and waits for the active pass to finish. */
|
|
94
|
-
stop(): Promise<void>;
|
|
95
|
-
private runLoop;
|
|
96
|
-
/** Runs the reconciliation task when its interval has elapsed. */
|
|
97
|
-
private runScheduledReconciliation;
|
|
98
|
-
/** Coalesces a manual/scheduled reconciliation call in this process. */
|
|
99
|
-
private runReconciliationOnce;
|
|
100
|
-
private notifyReconciliationReport;
|
|
101
|
-
private notifyReconciliationError;
|
|
102
|
-
private notifyReport;
|
|
103
|
-
private notifyError;
|
|
104
|
-
private waitFor;
|
|
105
|
-
private clearInFlightPass;
|
|
106
|
-
private clearInFlightReconciliation;
|
|
107
|
-
}
|
|
108
|
-
/** Creates a supervisor that supplies a fresh timestamp to every worker pass. */
|
|
109
|
-
export declare function createSyncEffectWorkerSupervisor(options: CreateSyncEffectWorkerSupervisorOptions): SyncEffectWorkerSupervisor;
|
|
110
|
-
export {};
|
|
111
|
-
//# sourceMappingURL=SyncEffectSupervisor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SyncEffectSupervisor.d.ts","sourceRoot":"","sources":["../../../../../src/application/sync/outbound/effects/SyncEffectSupervisor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACxC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,6BAA6B,IAAI,iCAAiC,EACxE,MAAM,oCAAoC,CAAC;AAS5C,MAAM,MAAM,8BAA8B,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AACnF,KAAK,OAAO,GAAG,MAAM,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAErD,wEAAwE;AACxE,MAAM,WAAW,+CAA+C;IAC9D,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,kFAAkF;IAClF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,sEAAsE;IACtE,QAAQ,CAAC,GAAG,EAAE,MAAM,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACtD,wE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