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,318 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Effect outbox claim, apply, and recovery operations.
|
|
3
|
-
*
|
|
4
|
-
* Per design concurrency/writer-rpc.md and storage-schema.md:
|
|
5
|
-
* - Effects are claimed atomically (CAS on status = 'pending').
|
|
6
|
-
* - Only one worker can claim an effect at a time.
|
|
7
|
-
* - Apply results must pass fencing validation (epoch + token).
|
|
8
|
-
* - Supersede/replan atomically closes old effect and inserts new one.
|
|
9
|
-
*/
|
|
10
|
-
import { STORAGE_ERROR_CODES, StorageError } from "../../errors.js";
|
|
11
|
-
import { withSqlSavepoint } from "../../sqlite/sqlTransaction.js";
|
|
12
|
-
import { fenceParameters, isFencingValidWithSql, } from "../shared/writerLease.js";
|
|
13
|
-
import { decodeSqlRows, } from "../../../../adapter/persistence/contracts/sql.js";
|
|
14
|
-
import { APPLY_EFFECT_RESULT_SQL, CLAIM_EFFECT_SQL, COUNT_PENDING_OR_PROCESSING_EFFECTS_SQL, INSERT_PENDING_EFFECT_SQL, INSERT_REPLANNED_EFFECT_SQL, MARK_DELIVERY_UNCERTAIN_SQL, RECOVER_EXPIRED_LEASES_SQL, RENEW_EFFECT_LEASE_SQL, REQUEUE_CLAIMED_EFFECT_SQL, RELEASE_UNPROCESSED_EFFECT_SQL, SELECT_PENDING_EFFECTS_BY_TARGET_SQL, SELECT_READY_EFFECTS_SQL, SELECT_READY_FAST_APPEND_EFFECTS_SQL, SUPERSEDE_EFFECT_SQL, } from "./effectOutboxSql.js";
|
|
15
|
-
import { applyEffectResultParameters, assertProjectionConfirmationTargetWithSql, AsyncFenceLostError, claimEffectParameters, decodePendingEffectRow, pendingEffectParameters, markDeliveryUncertainParameters, replannedEffectParameters, requireCurrentFenceWithSql, retryClaimedEffectParameters, validateApplyResultOptions, validateEffectLeaseDuration, validateReadyEffectLimit, writeProjectionConfirmationWithSql, } from "./effectOutboxSupport.js";
|
|
16
|
-
export { SYNC_EFFECT_RECOVERY_ERROR_CODES } from "./effectOutboxContracts.js";
|
|
17
|
-
/**
|
|
18
|
-
* Claims a pending effect through an already-active async SQL context.
|
|
19
|
-
*
|
|
20
|
-
* The compare-and-set query and both fencing checks use the same connection,
|
|
21
|
-
* so a worker cannot claim through a different SQLite connection.
|
|
22
|
-
*/
|
|
23
|
-
export async function claimEffectWithSql(sql, options) {
|
|
24
|
-
if (!(await isFencingValidWithSql(sql, options))) {
|
|
25
|
-
return {
|
|
26
|
-
effectId: options.effectId,
|
|
27
|
-
claimToken: options.claimToken,
|
|
28
|
-
status: "not_claimed",
|
|
29
|
-
reason: "stale_fencing",
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
validateEffectLeaseDuration(options.leaseDurationMs);
|
|
33
|
-
const result = await sql.run(CLAIM_EFFECT_SQL, claimEffectParameters(options));
|
|
34
|
-
if (result.changes > 0) {
|
|
35
|
-
return {
|
|
36
|
-
effectId: options.effectId,
|
|
37
|
-
claimToken: options.claimToken,
|
|
38
|
-
status: "claimed",
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
effectId: options.effectId,
|
|
43
|
-
claimToken: options.claimToken,
|
|
44
|
-
status: "not_claimed",
|
|
45
|
-
reason: await isFencingValidWithSql(sql, options) ? "not_claimable" : "stale_fencing",
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/** Claims one effect inside an adapter-owned transaction. */
|
|
49
|
-
export async function claimEffectWithAdapter(storage, options) {
|
|
50
|
-
return storage.transaction(({ sql }) => claimEffectWithSql(sql, options));
|
|
51
|
-
}
|
|
52
|
-
/** Renews a processing effect only while the current writer fence and claim still match. */
|
|
53
|
-
export async function renewEffectLeaseWithSql(sql, options) {
|
|
54
|
-
if (!(await isFencingValidWithSql(sql, options)))
|
|
55
|
-
return false;
|
|
56
|
-
validateEffectLeaseDuration(options.leaseDurationMs);
|
|
57
|
-
const result = await sql.run(RENEW_EFFECT_LEASE_SQL, [
|
|
58
|
-
options.now + options.leaseDurationMs,
|
|
59
|
-
options.effectId,
|
|
60
|
-
options.claimToken,
|
|
61
|
-
options.writerEpoch,
|
|
62
|
-
options.now,
|
|
63
|
-
...fenceParameters(options),
|
|
64
|
-
]);
|
|
65
|
-
return result.changes === 1;
|
|
66
|
-
}
|
|
67
|
-
/** Renews one claimed effect through an adapter-owned transaction. */
|
|
68
|
-
export async function renewEffectLeaseWithAdapter(storage, options) {
|
|
69
|
-
return storage.transaction(({ sql }) => renewEffectLeaseWithSql(sql, options));
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Appends pending effects under the supplied writer fence.
|
|
73
|
-
*
|
|
74
|
-
* This is used for conflict/quarantine effects that do not accompany a
|
|
75
|
-
* canonical field commit. It owns a savepoint so a duplicate dedupe key or a
|
|
76
|
-
* lost fence cannot leave only part of an effect set behind.
|
|
77
|
-
*/
|
|
78
|
-
/**
|
|
79
|
-
* Appends pending effects inside an already-active async SQL transaction.
|
|
80
|
-
*
|
|
81
|
-
* This is the MikroORM-compatible path used when an entity mutation and its
|
|
82
|
-
* Sheets outbox records must commit or roll back together.
|
|
83
|
-
*/
|
|
84
|
-
export async function appendPendingEffectsWithSql(sql, fence, effects) {
|
|
85
|
-
if (effects.length === 0)
|
|
86
|
-
return isFencingValidWithSql(sql, fence);
|
|
87
|
-
if (!(await isFencingValidWithSql(sql, fence)))
|
|
88
|
-
return false;
|
|
89
|
-
try {
|
|
90
|
-
return await withSqlSavepoint(sql, "append_pending_effects", async () => {
|
|
91
|
-
for (const effect of effects) {
|
|
92
|
-
const result = await sql.run(INSERT_PENDING_EFFECT_SQL, pendingEffectParameters(effect, fence));
|
|
93
|
-
if (result.changes === 1)
|
|
94
|
-
continue;
|
|
95
|
-
if (!(await isFencingValidWithSql(sql, fence))) {
|
|
96
|
-
throw new AsyncFenceLostError();
|
|
97
|
-
}
|
|
98
|
-
throw new StorageError(STORAGE_ERROR_CODES.EFFECT_WRITE_FAILED, `could not insert effect ${effect.effectId}`);
|
|
99
|
-
}
|
|
100
|
-
return true;
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
if (error instanceof AsyncFenceLostError)
|
|
105
|
-
return false;
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/** Appends pending effects in one adapter-owned transaction. */
|
|
110
|
-
export async function appendPendingEffectsWithAdapter(storage, fence, effects) {
|
|
111
|
-
return storage.transaction(({ sql }) => appendPendingEffectsWithSql(sql, fence, effects));
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Applies a result to a claimed effect.
|
|
115
|
-
* Validates fencing (claim token + writer epoch) before applying.
|
|
116
|
-
* Returns true if the result was applied, false if fencing failed.
|
|
117
|
-
*/
|
|
118
|
-
/**
|
|
119
|
-
* Applies a claimed effect result through an already-active async SQL context.
|
|
120
|
-
*
|
|
121
|
-
* If projection confirmation fails, the savepoint rolls the effect transition
|
|
122
|
-
* back too; confirmed visible state can never advance without its outbox row.
|
|
123
|
-
*/
|
|
124
|
-
export async function applyEffectResultWithSql(sql, options) {
|
|
125
|
-
if (!(await isFencingValidWithSql(sql, options)))
|
|
126
|
-
return false;
|
|
127
|
-
validateApplyResultOptions(options);
|
|
128
|
-
if (options.projectionConfirmation !== undefined) {
|
|
129
|
-
await assertProjectionConfirmationTargetWithSql(sql, options.effectId, options.claimToken, options.projectionConfirmation);
|
|
130
|
-
}
|
|
131
|
-
return withSqlSavepoint(sql, "apply_effect_result", async () => {
|
|
132
|
-
const result = await sql.run(APPLY_EFFECT_RESULT_SQL, applyEffectResultParameters(options));
|
|
133
|
-
if (result.changes !== 1)
|
|
134
|
-
return false;
|
|
135
|
-
if (options.projectionConfirmation !== undefined) {
|
|
136
|
-
await writeProjectionConfirmationWithSql(sql, options.projectionConfirmation);
|
|
137
|
-
}
|
|
138
|
-
return true;
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
/** Applies one effect result inside an adapter-owned transaction. */
|
|
142
|
-
export async function applyEffectResultWithAdapter(storage, options) {
|
|
143
|
-
return storage.transaction(({ sql }) => applyEffectResultWithSql(sql, options));
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Supersedes an old effect and inserts a new replacement effect atomically.
|
|
147
|
-
* Used for repair replan when the canonical target has advanced.
|
|
148
|
-
*
|
|
149
|
-
* Per design: the old effect is marked 'superseded', a new effect with a new
|
|
150
|
-
* effect_id and new dedupe_key is inserted, and the new effect's
|
|
151
|
-
* predecessor_effect_id links to the old one.
|
|
152
|
-
*/
|
|
153
|
-
/** Supersedes and replans an effect through an already-active async SQL context. */
|
|
154
|
-
export async function supersedeAndReplanWithSql(sql, fence, oldEffectId, newEffect) {
|
|
155
|
-
await requireCurrentFenceWithSql(sql, fence);
|
|
156
|
-
await withSqlSavepoint(sql, "replan", async () => {
|
|
157
|
-
const superseded = await sql.run(SUPERSEDE_EFFECT_SQL, [
|
|
158
|
-
newEffect.effectId,
|
|
159
|
-
oldEffectId,
|
|
160
|
-
...fenceParameters(fence),
|
|
161
|
-
]);
|
|
162
|
-
if (superseded.changes !== 1) {
|
|
163
|
-
await requireCurrentFenceWithSql(sql, fence);
|
|
164
|
-
throw new StorageError(STORAGE_ERROR_CODES.EFFECT_REPLAN_CONFLICT, `effect ${oldEffectId} cannot be replanned from its current status`);
|
|
165
|
-
}
|
|
166
|
-
const inserted = await sql.run(INSERT_REPLANNED_EFFECT_SQL, replannedEffectParameters(newEffect, oldEffectId, fence));
|
|
167
|
-
if (inserted.changes !== 1) {
|
|
168
|
-
await requireCurrentFenceWithSql(sql, fence);
|
|
169
|
-
throw new StorageError(STORAGE_ERROR_CODES.EFFECT_WRITE_FAILED, `effect ${newEffect.effectId} could not be inserted during replan`);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
/** Supersedes and replans an effect inside an adapter-owned transaction. */
|
|
174
|
-
export async function supersedeAndReplanWithAdapter(storage, fence, oldEffectId, newEffect) {
|
|
175
|
-
await storage.transaction(({ sql }) => supersedeAndReplanWithSql(sql, fence, oldEffectId, newEffect));
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Marks expired processing effects as requiring postcondition recovery.
|
|
179
|
-
*
|
|
180
|
-
* The worker must read the remote postcondition before it schedules a retry;
|
|
181
|
-
* an expired lease is not evidence that the remote write did not happen.
|
|
182
|
-
*/
|
|
183
|
-
/** Marks expired effect leases through an already-active async SQL context. */
|
|
184
|
-
export async function recoverExpiredLeasesWithSql(sql, fence) {
|
|
185
|
-
await requireCurrentFenceWithSql(sql, fence);
|
|
186
|
-
const result = await sql.run(RECOVER_EXPIRED_LEASES_SQL, [
|
|
187
|
-
fence.now,
|
|
188
|
-
fence.now,
|
|
189
|
-
fence.now,
|
|
190
|
-
...fenceParameters(fence),
|
|
191
|
-
]);
|
|
192
|
-
return result.changes;
|
|
193
|
-
}
|
|
194
|
-
/** Marks expired effect leases inside an adapter-owned transaction. */
|
|
195
|
-
export async function recoverExpiredLeasesWithAdapter(storage, fence) {
|
|
196
|
-
return storage.transaction(({ sql }) => recoverExpiredLeasesWithSql(sql, fence));
|
|
197
|
-
}
|
|
198
|
-
/** Moves a claimed effect into durable ambiguous-delivery recovery. */
|
|
199
|
-
export async function markDeliveryUncertainWithSql(sql, options) {
|
|
200
|
-
if (!(await isFencingValidWithSql(sql, options)))
|
|
201
|
-
return false;
|
|
202
|
-
if (options.nextProbeAt < options.uncertainSince || options.uncertainSince < 0) {
|
|
203
|
-
throw new StorageError(STORAGE_ERROR_CODES.INVALID_EFFECT_OPTIONS, "uncertain delivery timestamps must be ordered non-negative values");
|
|
204
|
-
}
|
|
205
|
-
const result = await sql.run(MARK_DELIVERY_UNCERTAIN_SQL, markDeliveryUncertainParameters(options));
|
|
206
|
-
return result.changes === 1;
|
|
207
|
-
}
|
|
208
|
-
/** Moves one claimed effect into durable ambiguous-delivery recovery. */
|
|
209
|
-
export async function markDeliveryUncertainWithAdapter(storage, options) {
|
|
210
|
-
return storage.transaction(({ sql }) => markDeliveryUncertainWithSql(sql, options));
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Returns an acknowledged-but-unprocessed batch suffix to pending.
|
|
214
|
-
*
|
|
215
|
-
* This is intentionally narrower than a generic redrive: it may be used only
|
|
216
|
-
* after a valid provider response explicitly says the batch budget stopped
|
|
217
|
-
* before this effect. Unknown response loss remains failed until read-back.
|
|
218
|
-
*/
|
|
219
|
-
/** Returns one acknowledged-but-unprocessed effect through an async SQL context. */
|
|
220
|
-
export async function releaseUnprocessedEffectWithSql(sql, options) {
|
|
221
|
-
if (!(await isFencingValidWithSql(sql, options)))
|
|
222
|
-
return false;
|
|
223
|
-
const result = await sql.run(RELEASE_UNPROCESSED_EFFECT_SQL, [
|
|
224
|
-
options.now + 1_000,
|
|
225
|
-
options.effectId,
|
|
226
|
-
options.claimToken,
|
|
227
|
-
options.writerEpoch,
|
|
228
|
-
options.now,
|
|
229
|
-
...fenceParameters(options),
|
|
230
|
-
]);
|
|
231
|
-
return result.changes === 1;
|
|
232
|
-
}
|
|
233
|
-
/** Returns one acknowledged-but-unprocessed effect inside an adapter transaction. */
|
|
234
|
-
export async function releaseUnprocessedEffectWithAdapter(storage, options) {
|
|
235
|
-
return storage.transaction(({ sql }) => releaseUnprocessedEffectWithSql(sql, options));
|
|
236
|
-
}
|
|
237
|
-
/** Requeues a claimed effect only after the current fence still owns it. */
|
|
238
|
-
/** Requeues a claimed effect through an already-active async SQL context. */
|
|
239
|
-
export async function retryClaimedEffectWithSql(sql, options) {
|
|
240
|
-
if (!(await isFencingValidWithSql(sql, options)))
|
|
241
|
-
return false;
|
|
242
|
-
const result = await sql.run(REQUEUE_CLAIMED_EFFECT_SQL, retryClaimedEffectParameters(options));
|
|
243
|
-
return result.changes === 1;
|
|
244
|
-
}
|
|
245
|
-
/** Requeues a claimed effect inside an adapter-owned transaction. */
|
|
246
|
-
export async function retryClaimedEffectWithAdapter(storage, options) {
|
|
247
|
-
return storage.transaction(({ sql }) => retryClaimedEffectWithSql(sql, options));
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Finds pending effects for a given stream (target), ordered by stream_sequence.
|
|
251
|
-
* Returns the head-of-line effects for a target stream.
|
|
252
|
-
*/
|
|
253
|
-
/** Reads one target stream through an already-active async SQL context. */
|
|
254
|
-
export async function findPendingEffectsByTargetWithSql(sql, logicalSheetId, targetKind, targetId) {
|
|
255
|
-
const rows = await sql.all(SELECT_PENDING_EFFECTS_BY_TARGET_SQL, [
|
|
256
|
-
logicalSheetId,
|
|
257
|
-
targetKind,
|
|
258
|
-
targetId,
|
|
259
|
-
]);
|
|
260
|
-
return decodeSqlRows(rows, decodePendingEffectRow, "pending effects");
|
|
261
|
-
}
|
|
262
|
-
/** Reads one target stream through a fresh adapter read context. */
|
|
263
|
-
export async function findPendingEffectsByTargetWithAdapter(storage, logicalSheetId, targetKind, targetId) {
|
|
264
|
-
return storage.read(({ sql }) => {
|
|
265
|
-
return findPendingEffectsByTargetWithSql(sql, logicalSheetId, targetKind, targetId);
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Returns ordered head-of-line effects across streams for one bounded worker pass.
|
|
270
|
-
*
|
|
271
|
-
* Claiming still performs the authoritative CAS, so a concurrent worker can
|
|
272
|
-
* safely race this advisory selection without processing a later stream item.
|
|
273
|
-
*/
|
|
274
|
-
/** Reads bounded head-of-line effects through an already-active async SQL context. */
|
|
275
|
-
export async function listReadyEffectsWithSql(sql, limit, now = Date.now()) {
|
|
276
|
-
validateReadyEffectLimit(limit);
|
|
277
|
-
if (!Number.isSafeInteger(now) || now < 0) {
|
|
278
|
-
throw new StorageError(STORAGE_ERROR_CODES.INVALID_EFFECT_OPTIONS, "ready effect time must be a non-negative safe integer");
|
|
279
|
-
}
|
|
280
|
-
const rows = await sql.all(SELECT_READY_EFFECTS_SQL, [now, now, now, limit]);
|
|
281
|
-
return decodeSqlRows(rows, decodePendingEffectRow, "ready effects");
|
|
282
|
-
}
|
|
283
|
-
/** Reads bounded head-of-line effects through a fresh adapter read context. */
|
|
284
|
-
export async function listReadyEffectsWithAdapter(storage, limit, now = Date.now()) {
|
|
285
|
-
return storage.read(({ sql }) => listReadyEffectsWithSql(sql, limit, now));
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Reads bounded head-of-line effects that can only be fast-append rows.
|
|
289
|
-
*
|
|
290
|
-
* The query jumps past any regular/recovery backlog in the same ready order,
|
|
291
|
-
* so an arbitrary number of head-of-queue rows cannot starve the bulk append
|
|
292
|
-
* path. Only the SQL-visible append shape is filtered; the worker still
|
|
293
|
-
* validates each row's payload (createIfMissing) before claiming it.
|
|
294
|
-
*/
|
|
295
|
-
/** Reads bounded ready fast-append candidates through an already-active async SQL context. */
|
|
296
|
-
export async function listReadyFastAppendEffectsWithSql(sql, limit, now = Date.now()) {
|
|
297
|
-
validateReadyEffectLimit(limit);
|
|
298
|
-
if (!Number.isSafeInteger(now) || now < 0) {
|
|
299
|
-
throw new StorageError(STORAGE_ERROR_CODES.INVALID_EFFECT_OPTIONS, "ready fast-append effect time must be a non-negative safe integer");
|
|
300
|
-
}
|
|
301
|
-
const rows = await sql.all(SELECT_READY_FAST_APPEND_EFFECTS_SQL, [now, limit]);
|
|
302
|
-
return decodeSqlRows(rows, decodePendingEffectRow, "ready fast-append effects");
|
|
303
|
-
}
|
|
304
|
-
/** Reads bounded ready fast-append candidates through a fresh adapter read context. */
|
|
305
|
-
export async function listReadyFastAppendEffectsWithAdapter(storage, limit, now = Date.now()) {
|
|
306
|
-
return storage.read(({ sql }) => listReadyFastAppendEffectsWithSql(sql, limit, now));
|
|
307
|
-
}
|
|
308
|
-
/** Returns whether normal outbox work is still pending or actively processing. */
|
|
309
|
-
/** Checks whether the durable outbox still has pending or processing work. */
|
|
310
|
-
export async function hasPendingOrProcessingEffectsWithSql(sql) {
|
|
311
|
-
const row = await sql.get(COUNT_PENDING_OR_PROCESSING_EFFECTS_SQL);
|
|
312
|
-
return row !== undefined && row.count > 0;
|
|
313
|
-
}
|
|
314
|
-
/** Checks outbox activity through a fresh adapter read context. */
|
|
315
|
-
export async function hasPendingOrProcessingEffectsWithAdapter(storage) {
|
|
316
|
-
return storage.read(({ sql }) => hasPendingOrProcessingEffectsWithSql(sql));
|
|
317
|
-
}
|
|
318
|
-
//# sourceMappingURL=effectOutbox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effectOutbox.js","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/outbound/effectOutbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EACL,eAAe,EACf,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,GAId,MAAM,kDAAkD,CAAC;AAW1D,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,uCAAuC,EACvC,yBAAyB,EACzB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EAC9B,oCAAoC,EACpC,wBAAwB,EACxB,oCAAoC,EACpC,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,2BAA2B,EAC3B,yCAAyC,EACzC,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,kCAAkC,GACnC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAe9E;;;;;GA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|
1
|
-
/** Public contracts for durable effect outbox rows and transitions. */
|
|
2
|
-
import type { Applicability, EffectKind, EffectStatus, EffectTargetKind, Presence } from "../../../../domain/index.js";
|
|
3
|
-
import type { FencingContext } from "../shared/writerLease.js";
|
|
4
|
-
import type { HikouteiEffectDedupeKey, HikouteiEffectId, HikouteiPayloadHash, HikouteiPhysicalSheetId, HikouteiRowBindingId, HikouteiVisibleHash } from "../../../../shared/identity/types.js";
|
|
5
|
-
export declare const SYNC_EFFECT_RECOVERY_ERROR_CODES: {
|
|
6
|
-
readonly LEASE_EXPIRED_REQUIRES_POSTCONDITION: "lease_expired_requires_postcondition";
|
|
7
|
-
readonly DELIVERY_UNCERTAIN_REQUIRES_PROBE: "delivery_uncertain_requires_probe";
|
|
8
|
-
readonly PROVIDER_RETRYABLE_ERROR: "provider_retryable_error";
|
|
9
|
-
readonly POSTCONDITION_READ_FAILED: "postcondition_read_failed";
|
|
10
|
-
readonly POSTCONDITION_UNAVAILABLE: "postcondition_unavailable";
|
|
11
|
-
readonly POSTCONDITION_UNAPPLIED_REQUIRES_REDRIVE: "postcondition_unapplied_requires_redrive";
|
|
12
|
-
/**
|
|
13
|
-
* Code persisted by pre-rename workers as `gateway_retryable_error`.
|
|
14
|
-
* Accepted alongside PROVIDER_RETRYABLE_ERROR so failed rows written before
|
|
15
|
-
* the provider rename stay recoverable instead of stranding permanently.
|
|
16
|
-
*/
|
|
17
|
-
readonly LEGACY_GATEWAY_RETRYABLE_ERROR: "gateway_retryable_error";
|
|
18
|
-
};
|
|
19
|
-
export type ClaimResult = {
|
|
20
|
-
readonly effectId: string;
|
|
21
|
-
readonly claimToken: string;
|
|
22
|
-
readonly status: "claimed";
|
|
23
|
-
} | {
|
|
24
|
-
readonly effectId: string;
|
|
25
|
-
readonly claimToken: string;
|
|
26
|
-
readonly status: "not_claimed";
|
|
27
|
-
readonly reason: "stale_fencing" | "not_claimable";
|
|
28
|
-
};
|
|
29
|
-
/** Input required to claim an effect with the current worker fence. */
|
|
30
|
-
export interface ClaimEffectOptions extends FencingContext {
|
|
31
|
-
readonly effectId: string;
|
|
32
|
-
readonly claimToken: string;
|
|
33
|
-
/** Durable identity for the remote dispatch represented by this claim. */
|
|
34
|
-
readonly dispatchId?: string;
|
|
35
|
-
readonly leaseDurationMs: number;
|
|
36
|
-
}
|
|
37
|
-
/** Extends an in-flight effect lease without changing its claim token. */
|
|
38
|
-
export interface RenewEffectLeaseOptions extends FencingContext {
|
|
39
|
-
readonly effectId: string;
|
|
40
|
-
readonly claimToken: string;
|
|
41
|
-
readonly leaseDurationMs: number;
|
|
42
|
-
}
|
|
43
|
-
interface ApplyResultOptionsBase extends FencingContext {
|
|
44
|
-
readonly effectId: string;
|
|
45
|
-
readonly claimToken: string;
|
|
46
|
-
readonly lastErrorCode: Presence<string>;
|
|
47
|
-
readonly lastErrorMessage: Presence<string>;
|
|
48
|
-
}
|
|
49
|
-
/** A result that may advance confirmed projection state. */
|
|
50
|
-
export interface AppliedEffectResultOptions extends ApplyResultOptionsBase {
|
|
51
|
-
readonly status: "applied";
|
|
52
|
-
/** Provider read-back evidence committed with the applied outbox result. */
|
|
53
|
-
readonly projectionConfirmation?: EffectProjectionConfirmation;
|
|
54
|
-
}
|
|
55
|
-
/** A result that closes an effect without advancing confirmed projection state. */
|
|
56
|
-
export interface NonAppliedEffectResultOptions extends ApplyResultOptionsBase {
|
|
57
|
-
readonly status: "blocked_candidate" | "superseded" | "conflict" | "failed";
|
|
58
|
-
readonly projectionConfirmation?: never;
|
|
59
|
-
}
|
|
60
|
-
/** Operation-specific apply input with impossible confirmation/status pairs removed. */
|
|
61
|
-
export type ApplyResultOptions = AppliedEffectResultOptions | NonAppliedEffectResultOptions;
|
|
62
|
-
/** Confirmed projection state returned only after a provider postcondition read. */
|
|
63
|
-
export interface EffectProjectionConfirmation {
|
|
64
|
-
readonly physicalSheetId: string;
|
|
65
|
-
readonly projection: string;
|
|
66
|
-
readonly rowBindingId: string;
|
|
67
|
-
readonly visibleRevision: number;
|
|
68
|
-
readonly visibleHash: string;
|
|
69
|
-
readonly entityRevision: Applicability<number>;
|
|
70
|
-
readonly fieldHashes: Readonly<Record<string, string>>;
|
|
71
|
-
}
|
|
72
|
-
/** A pending outbox row prepared by the writer transaction. */
|
|
73
|
-
export interface NewEffect {
|
|
74
|
-
readonly effectId: string;
|
|
75
|
-
readonly effectKind: EffectKind;
|
|
76
|
-
readonly commitId: string;
|
|
77
|
-
readonly logicalSheetId: string;
|
|
78
|
-
readonly physicalSheetId: string;
|
|
79
|
-
readonly projection: string;
|
|
80
|
-
readonly rowBindingId: Presence<string>;
|
|
81
|
-
readonly conflictId: Presence<string>;
|
|
82
|
-
readonly targetKind: EffectTargetKind;
|
|
83
|
-
readonly targetId: string;
|
|
84
|
-
readonly targetEntityRevision: Applicability<number>;
|
|
85
|
-
readonly targetFieldRevisionHash: Applicability<string>;
|
|
86
|
-
readonly targetCanonicalCommitId: Applicability<string>;
|
|
87
|
-
readonly expectedVisibleRevision: number;
|
|
88
|
-
readonly expectedVisibleHash: string;
|
|
89
|
-
readonly repairGuardHash: Presence<string>;
|
|
90
|
-
readonly sourceQuarantineId: Presence<string>;
|
|
91
|
-
readonly payloadJson: string;
|
|
92
|
-
readonly payloadHash: string;
|
|
93
|
-
readonly effectDedupeKey: string;
|
|
94
|
-
readonly streamSequence: number;
|
|
95
|
-
}
|
|
96
|
-
export interface RetryClaimedEffectOptions extends Pick<FencingContext, "role" | "writerEpoch" | "fencingToken" | "now"> {
|
|
97
|
-
readonly effectId: string;
|
|
98
|
-
readonly claimToken: string;
|
|
99
|
-
readonly lastErrorCode: string;
|
|
100
|
-
readonly lastErrorMessage: string;
|
|
101
|
-
/** Durable retry time; defaults to a short bounded delay at the SQL boundary. */
|
|
102
|
-
readonly nextAttemptAt?: number;
|
|
103
|
-
}
|
|
104
|
-
/** Moves a claimed effect into durable ambiguous-delivery recovery. */
|
|
105
|
-
export interface MarkDeliveryUncertainOptions extends Pick<FencingContext, "role" | "writerEpoch" | "fencingToken" | "now"> {
|
|
106
|
-
readonly effectId: string;
|
|
107
|
-
readonly claimToken: string;
|
|
108
|
-
readonly uncertainSince: number;
|
|
109
|
-
readonly nextProbeAt: number;
|
|
110
|
-
readonly lastErrorCode: string;
|
|
111
|
-
readonly lastErrorMessage: string;
|
|
112
|
-
}
|
|
113
|
-
export interface PendingEffect {
|
|
114
|
-
readonly effect_id: HikouteiEffectId;
|
|
115
|
-
readonly effect_kind: EffectKind;
|
|
116
|
-
readonly commit_id: string;
|
|
117
|
-
readonly logical_sheet_id: string;
|
|
118
|
-
readonly physical_sheet_id: HikouteiPhysicalSheetId;
|
|
119
|
-
readonly projection: string;
|
|
120
|
-
readonly row_binding_id: HikouteiRowBindingId | null;
|
|
121
|
-
readonly conflict_id: string | null;
|
|
122
|
-
readonly target_kind: EffectTargetKind;
|
|
123
|
-
readonly target_id: string;
|
|
124
|
-
readonly target_entity_revision: number | null;
|
|
125
|
-
readonly target_field_revision_hash: string | null;
|
|
126
|
-
readonly target_canonical_commit_id: string | null;
|
|
127
|
-
readonly expected_visible_revision: number;
|
|
128
|
-
readonly expected_visible_hash: HikouteiVisibleHash | "";
|
|
129
|
-
readonly repair_guard_hash: string | null;
|
|
130
|
-
readonly source_quarantine_id: string | null;
|
|
131
|
-
readonly payload_json: string;
|
|
132
|
-
readonly payload_hash: HikouteiPayloadHash;
|
|
133
|
-
readonly effect_dedupe_key: HikouteiEffectDedupeKey;
|
|
134
|
-
readonly stream_sequence: number;
|
|
135
|
-
readonly created_at: number;
|
|
136
|
-
readonly next_attempt_at: number | null;
|
|
137
|
-
readonly uncertain_since: number | null;
|
|
138
|
-
readonly next_probe_at: number | null;
|
|
139
|
-
readonly dispatch_id: string | null;
|
|
140
|
-
readonly status: EffectStatus;
|
|
141
|
-
}
|
|
142
|
-
export {};
|
|
143
|
-
//# sourceMappingURL=effectOutboxContracts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effectOutboxContracts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AAM,GAAG,IAAI,CAAC;IACnD,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAC3C,QAAQ,CAAC,qBAAqB,EAAE,mBAAmB,GAAG,EAAE,CAAC;IACzD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,QAAQ,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;IACpD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/** Public contracts for durable effect outbox rows and transitions. */
|
|
2
|
-
export const SYNC_EFFECT_RECOVERY_ERROR_CODES = {
|
|
3
|
-
LEASE_EXPIRED_REQUIRES_POSTCONDITION: "lease_expired_requires_postcondition",
|
|
4
|
-
DELIVERY_UNCERTAIN_REQUIRES_PROBE: "delivery_uncertain_requires_probe",
|
|
5
|
-
PROVIDER_RETRYABLE_ERROR: "provider_retryable_error",
|
|
6
|
-
POSTCONDITION_READ_FAILED: "postcondition_read_failed",
|
|
7
|
-
POSTCONDITION_UNAVAILABLE: "postcondition_unavailable",
|
|
8
|
-
POSTCONDITION_UNAPPLIED_REQUIRES_REDRIVE: "postcondition_unapplied_requires_redrive",
|
|
9
|
-
/**
|
|
10
|
-
* Code persisted by pre-rename workers as `gateway_retryable_error`.
|
|
11
|
-
* Accepted alongside PROVIDER_RETRYABLE_ERROR so failed rows written before
|
|
12
|
-
* the provider rename stay recoverable instead of stranding permanently.
|
|
13
|
-
*/
|
|
14
|
-
LEGACY_GATEWAY_RETRYABLE_ERROR: "gateway_retryable_error",
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=effectOutboxContracts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effectOutboxContracts.js","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/outbound/effectOutboxContracts.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAmBvE,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,oCAAoC,EAAE,sCAAsC;IAC5E,iCAAiC,EAAE,mCAAmC;IACtE,wBAAwB,EAAE,0BAA0B;IACpD,yBAAyB,EAAE,2BAA2B;IACtD,yBAAyB,EAAE,2BAA2B;IACtD,wCAAwC,EAAE,0CAA0C;IACpF;;;;OAIG;IACH,8BAA8B,EAAE,yBAAyB;CACjD,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** SQL statements used by the effect outbox state machine. */
|
|
2
|
-
export { FENCE_EXISTS_SQL } from "../shared/writerLease.js";
|
|
3
|
-
export declare const RECOVERABLE_EFFECT_ERROR_CODE_SQL: string;
|
|
4
|
-
export declare const CLAIM_EFFECT_SQL = "\n UPDATE sheet_effect_outbox AS candidate\n SET status = 'processing', claim_token = ?, writer_epoch = ?, lease_until = ?,\n dispatch_id = ?, next_attempt_at = NULL, next_probe_at = NULL,\n attempts = attempts + 1\n WHERE candidate.effect_id = ?\n AND candidate.status IN ('pending', 'failed', 'delivery_uncertain')\n AND (\n candidate.status = 'pending'\n OR (candidate.status = 'failed' AND\n (candidate.next_attempt_at IS NULL OR candidate.next_attempt_at <= ?))\n OR (candidate.status = 'delivery_uncertain' AND\n (candidate.next_probe_at IS NULL OR candidate.next_probe_at <= ?))\n )\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n AND NOT EXISTS (\n SELECT 1\n FROM sheet_effect_outbox AS predecessor\n WHERE predecessor.logical_sheet_id = candidate.logical_sheet_id\n AND predecessor.target_kind = candidate.target_kind\n AND predecessor.target_id = candidate.target_id\n AND predecessor.stream_sequence < candidate.stream_sequence\n AND predecessor.status NOT IN ('applied', 'superseded')\n )\n";
|
|
5
|
-
export declare const RENEW_EFFECT_LEASE_SQL = "\n UPDATE sheet_effect_outbox\n SET lease_until = ?\n WHERE effect_id = ? AND status = 'processing' AND claim_token = ?\n AND writer_epoch = ? AND lease_until IS NOT NULL AND lease_until > ?\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
6
|
-
export declare const INSERT_PENDING_EFFECT_SQL = "\n INSERT INTO sheet_effect_outbox (\n effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,\n projection, row_binding_id, conflict_id, target_kind, target_id,\n target_entity_revision, target_field_revision_hash, target_canonical_commit_id,\n expected_visible_revision, expected_visible_hash, repair_guard_hash,\n source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,\n stream_sequence, created_at, status\n )\n SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending'\n WHERE EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
7
|
-
export declare const APPLY_EFFECT_RESULT_SQL = "\n UPDATE sheet_effect_outbox\n SET status = ?, last_error_code = ?, last_error_message = ?,\n claim_token = NULL, lease_until = NULL, next_attempt_at = NULL,\n next_probe_at = NULL, uncertain_since = NULL\n WHERE effect_id = ?\n AND status = 'processing'\n AND claim_token = ?\n AND writer_epoch = ?\n AND lease_until IS NOT NULL\n AND lease_until > ?\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
8
|
-
export declare const SUPERSEDE_EFFECT_SQL = "\n UPDATE sheet_effect_outbox\n SET status = 'superseded', supersedes_effect_id = ?\n WHERE effect_id = ?\n AND status IN ('pending', 'processing', 'delivery_uncertain', 'blocked_candidate', 'conflict', 'failed')\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
9
|
-
export declare const INSERT_REPLANNED_EFFECT_SQL = "\n INSERT INTO sheet_effect_outbox (\n effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,\n projection, row_binding_id, conflict_id, target_kind, target_id,\n target_entity_revision, target_field_revision_hash, target_canonical_commit_id,\n expected_visible_revision, expected_visible_hash, repair_guard_hash,\n source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,\n stream_sequence, predecessor_effect_id, created_at, status\n )\n SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending'\n WHERE EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
10
|
-
export declare const RECOVER_EXPIRED_LEASES_SQL: string;
|
|
11
|
-
export declare const REQUEUE_CLAIMED_EFFECT_SQL = "\n UPDATE sheet_effect_outbox\n SET status = 'pending', claim_token = NULL, lease_until = NULL,\n next_attempt_at = ?, uncertain_since = NULL, next_probe_at = NULL,\n last_error_code = ?, last_error_message = ?\n WHERE effect_id = ? AND status = 'processing' AND claim_token = ?\n AND writer_epoch = ? AND lease_until IS NOT NULL AND lease_until > ?\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
12
|
-
export declare const RELEASE_UNPROCESSED_EFFECT_SQL = "\n UPDATE sheet_effect_outbox\n SET status = 'pending', claim_token = NULL, lease_until = NULL,\n next_attempt_at = ?, uncertain_since = NULL, next_probe_at = NULL,\n last_error_code = 'provider_batch_deferred',\n last_error_message = 'Provider acknowledged a bounded batch before this effect.'\n WHERE effect_id = ? AND status = 'processing' AND claim_token = ?\n AND writer_epoch = ? AND lease_until IS NOT NULL AND lease_until > ?\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
13
|
-
export declare const MARK_DELIVERY_UNCERTAIN_SQL = "\n UPDATE sheet_effect_outbox\n SET status = 'delivery_uncertain', claim_token = NULL, lease_until = NULL,\n uncertain_since = COALESCE(uncertain_since, ?), next_probe_at = ?,\n last_error_code = ?, last_error_message = ?\n WHERE effect_id = ? AND status = 'processing' AND claim_token = ?\n AND writer_epoch = ? AND lease_until IS NOT NULL AND lease_until > ?\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
14
|
-
export declare const SELECT_PENDING_EFFECTS_BY_TARGET_SQL = "\n SELECT effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,\n projection, row_binding_id, conflict_id, target_kind, target_id,\n target_entity_revision, target_field_revision_hash, target_canonical_commit_id,\n expected_visible_revision, expected_visible_hash, repair_guard_hash,\n source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,\n stream_sequence, created_at, next_attempt_at, uncertain_since,\n next_probe_at, dispatch_id, status\n FROM sheet_effect_outbox\n WHERE logical_sheet_id = ? AND target_kind = ? AND target_id = ?\n AND status = 'pending'\n AND NOT EXISTS (\n SELECT 1\n FROM sheet_effect_outbox AS predecessor\n WHERE predecessor.logical_sheet_id = sheet_effect_outbox.logical_sheet_id\n AND predecessor.target_kind = sheet_effect_outbox.target_kind\n AND predecessor.target_id = sheet_effect_outbox.target_id\n AND predecessor.stream_sequence < sheet_effect_outbox.stream_sequence\n AND predecessor.status NOT IN ('applied', 'superseded')\n )\n ORDER BY stream_sequence\n";
|
|
15
|
-
export declare const SELECT_READY_EFFECTS_SQL: string;
|
|
16
|
-
/**
|
|
17
|
-
* Bounded head-of-line selection restricted to potential fast-append rows.
|
|
18
|
-
*
|
|
19
|
-
* Only the SQL-visible append shape is filtered here (pending status,
|
|
20
|
-
* readiness, predecessor ordering, and the revision-zero baseline on the
|
|
21
|
-
* System_State/Sync_Conflicts routes); the worker re-validates each returned
|
|
22
|
-
* row's payload (createIfMissing) before claiming. Rows that fail that
|
|
23
|
-
* payload validation drain through the regular claim path instead.
|
|
24
|
-
*/
|
|
25
|
-
export declare const SELECT_READY_FAST_APPEND_EFFECTS_SQL = "\n SELECT effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,\n projection, row_binding_id, conflict_id, target_kind, target_id,\n target_entity_revision, target_field_revision_hash, target_canonical_commit_id,\n expected_visible_revision, expected_visible_hash, repair_guard_hash,\n source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,\n stream_sequence, created_at, next_attempt_at, uncertain_since,\n next_probe_at, dispatch_id, status\n FROM sheet_effect_outbox AS candidate\n WHERE candidate.status = 'pending'\n AND (candidate.next_attempt_at IS NULL OR candidate.next_attempt_at <= ?)\n AND candidate.effect_kind IN ('system_projection', 'resolution_projection')\n AND candidate.projection IN ('system_state', 'sync_conflicts')\n AND candidate.target_kind IN ('entity', 'conflict')\n AND candidate.expected_visible_revision = 0\n AND candidate.expected_visible_hash = ''\n AND NOT EXISTS (\n SELECT 1\n FROM sheet_effect_outbox AS predecessor\n WHERE predecessor.logical_sheet_id = candidate.logical_sheet_id\n AND predecessor.target_kind = candidate.target_kind\n AND predecessor.target_id = candidate.target_id\n AND predecessor.stream_sequence < candidate.stream_sequence\n AND predecessor.status NOT IN ('applied', 'superseded')\n )\n ORDER BY candidate.logical_sheet_id, candidate.physical_sheet_id,\n candidate.target_kind, candidate.target_id, candidate.stream_sequence\n LIMIT ?\n";
|
|
26
|
-
export declare const COUNT_PENDING_OR_PROCESSING_EFFECTS_SQL = "\n SELECT COUNT(*) AS count\n FROM sheet_effect_outbox\n WHERE status IN ('pending', 'processing', 'delivery_uncertain')\n";
|
|
27
|
-
export declare const UPSERT_VISIBLE_STATE_SQL = "\n INSERT INTO sheet_visible_state (\n physical_sheet_id, projection, row_binding_id, confirmed_snapshot_hash,\n confirmed_visible_revision, confirmed_entity_revision, last_observed_hash\n ) VALUES (?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(physical_sheet_id, projection, row_binding_id)\n DO UPDATE SET\n confirmed_snapshot_hash = excluded.confirmed_snapshot_hash,\n confirmed_visible_revision = excluded.confirmed_visible_revision,\n confirmed_entity_revision = excluded.confirmed_entity_revision,\n last_observed_hash = excluded.last_observed_hash\n WHERE sheet_visible_state.confirmed_visible_revision <= excluded.confirmed_visible_revision\n";
|
|
28
|
-
export declare const UPSERT_VISIBLE_FIELD_STATE_SQL = "\n INSERT INTO sheet_visible_field_state (\n physical_sheet_id, projection, row_binding_id, field_name,\n confirmed_field_hash, confirmed_visible_revision, candidate_epoch,\n last_observed_field_hash\n ) VALUES (?, ?, ?, ?, ?, ?, 0, ?)\n ON CONFLICT(physical_sheet_id, projection, row_binding_id, field_name)\n DO UPDATE SET\n confirmed_field_hash = excluded.confirmed_field_hash,\n confirmed_visible_revision = excluded.confirmed_visible_revision,\n last_observed_field_hash = excluded.last_observed_field_hash\n WHERE sheet_visible_field_state.confirmed_visible_revision <= excluded.confirmed_visible_revision\n";
|
|
29
|
-
/**
|
|
30
|
-
* Claims a pending effect for processing.
|
|
31
|
-
* Uses CAS on status to ensure only one worker wins.
|
|
32
|
-
*/
|
|
33
|
-
//# sourceMappingURL=effectOutboxSql.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effectOutboxSql.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/outbound/effectOutboxSql.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAK9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,eAAO,MAAM,iCAAiC,QAUjC,CAAC;AAEd,eAAO,MAAM,gBAAgB,0qCAwB5B,CAAC;AAEF,eAAO,MAAM,sBAAsB,+UAMlC,CAAC;AAEF,eAAO,MAAM,yBAAyB,grBAWrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,ugBAYnC,CAAC;AAEF,eAAO,MAAM,oBAAoB,qWAMhC,CAAC;AAEF,eAAO,MAAM,2BAA2B,0sBAWvC,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAQtC,CAAC;AAEF,eAAO,MAAM,0BAA0B,wfAQtC,CAAC;AAEF,eAAO,MAAM,8BAA8B,ilBAS1C,CAAC;AAEF,eAAO,MAAM,2BAA2B,mgBAQvC,CAAC;AAEF,eAAO,MAAM,oCAAoC,inCAqBhD,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAkCpC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,oCAAoC,8hDA4BhD,CAAC;AAEF,eAAO,MAAM,uCAAuC,kIAInD,CAAC;AAEF,eAAO,MAAM,wBAAwB,2pBAYpC,CAAC;AAEF,eAAO,MAAM,8BAA8B,ioBAY1C,CAAC;AAGF;;;GAGG"}
|