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,259 +0,0 @@
|
|
|
1
|
-
/** SQL statements used by the effect outbox state machine. */
|
|
2
|
-
import { SYNC_EFFECT_RECOVERY_ERROR_CODES } from "./effectOutboxContracts.js";
|
|
3
|
-
import { FENCE_EXISTS_SQL } from "../shared/writerLease.js";
|
|
4
|
-
export { FENCE_EXISTS_SQL } from "../shared/writerLease.js";
|
|
5
|
-
export const RECOVERABLE_EFFECT_ERROR_CODE_SQL = [
|
|
6
|
-
SYNC_EFFECT_RECOVERY_ERROR_CODES.LEASE_EXPIRED_REQUIRES_POSTCONDITION,
|
|
7
|
-
SYNC_EFFECT_RECOVERY_ERROR_CODES.PROVIDER_RETRYABLE_ERROR,
|
|
8
|
-
// Pre-rename databases may carry the legacy provider code; failed rows
|
|
9
|
-
// written with it must stay recoverable, not strand permanently.
|
|
10
|
-
SYNC_EFFECT_RECOVERY_ERROR_CODES.LEGACY_GATEWAY_RETRYABLE_ERROR,
|
|
11
|
-
SYNC_EFFECT_RECOVERY_ERROR_CODES.POSTCONDITION_READ_FAILED,
|
|
12
|
-
SYNC_EFFECT_RECOVERY_ERROR_CODES.POSTCONDITION_UNAVAILABLE,
|
|
13
|
-
SYNC_EFFECT_RECOVERY_ERROR_CODES.POSTCONDITION_UNAPPLIED_REQUIRES_REDRIVE,
|
|
14
|
-
].map((code) => `'${code}'`)
|
|
15
|
-
.join(", ");
|
|
16
|
-
export const CLAIM_EFFECT_SQL = `
|
|
17
|
-
UPDATE sheet_effect_outbox AS candidate
|
|
18
|
-
SET status = 'processing', claim_token = ?, writer_epoch = ?, lease_until = ?,
|
|
19
|
-
dispatch_id = ?, next_attempt_at = NULL, next_probe_at = NULL,
|
|
20
|
-
attempts = attempts + 1
|
|
21
|
-
WHERE candidate.effect_id = ?
|
|
22
|
-
AND candidate.status IN ('pending', 'failed', 'delivery_uncertain')
|
|
23
|
-
AND (
|
|
24
|
-
candidate.status = 'pending'
|
|
25
|
-
OR (candidate.status = 'failed' AND
|
|
26
|
-
(candidate.next_attempt_at IS NULL OR candidate.next_attempt_at <= ?))
|
|
27
|
-
OR (candidate.status = 'delivery_uncertain' AND
|
|
28
|
-
(candidate.next_probe_at IS NULL OR candidate.next_probe_at <= ?))
|
|
29
|
-
)
|
|
30
|
-
AND EXISTS (${FENCE_EXISTS_SQL})
|
|
31
|
-
AND NOT EXISTS (
|
|
32
|
-
SELECT 1
|
|
33
|
-
FROM sheet_effect_outbox AS predecessor
|
|
34
|
-
WHERE predecessor.logical_sheet_id = candidate.logical_sheet_id
|
|
35
|
-
AND predecessor.target_kind = candidate.target_kind
|
|
36
|
-
AND predecessor.target_id = candidate.target_id
|
|
37
|
-
AND predecessor.stream_sequence < candidate.stream_sequence
|
|
38
|
-
AND predecessor.status NOT IN ('applied', 'superseded')
|
|
39
|
-
)
|
|
40
|
-
`;
|
|
41
|
-
export const RENEW_EFFECT_LEASE_SQL = `
|
|
42
|
-
UPDATE sheet_effect_outbox
|
|
43
|
-
SET lease_until = ?
|
|
44
|
-
WHERE effect_id = ? AND status = 'processing' AND claim_token = ?
|
|
45
|
-
AND writer_epoch = ? AND lease_until IS NOT NULL AND lease_until > ?
|
|
46
|
-
AND EXISTS (${FENCE_EXISTS_SQL})
|
|
47
|
-
`;
|
|
48
|
-
export const INSERT_PENDING_EFFECT_SQL = `
|
|
49
|
-
INSERT INTO sheet_effect_outbox (
|
|
50
|
-
effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,
|
|
51
|
-
projection, row_binding_id, conflict_id, target_kind, target_id,
|
|
52
|
-
target_entity_revision, target_field_revision_hash, target_canonical_commit_id,
|
|
53
|
-
expected_visible_revision, expected_visible_hash, repair_guard_hash,
|
|
54
|
-
source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,
|
|
55
|
-
stream_sequence, created_at, status
|
|
56
|
-
)
|
|
57
|
-
SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending'
|
|
58
|
-
WHERE EXISTS (${FENCE_EXISTS_SQL})
|
|
59
|
-
`;
|
|
60
|
-
export const APPLY_EFFECT_RESULT_SQL = `
|
|
61
|
-
UPDATE sheet_effect_outbox
|
|
62
|
-
SET status = ?, last_error_code = ?, last_error_message = ?,
|
|
63
|
-
claim_token = NULL, lease_until = NULL, next_attempt_at = NULL,
|
|
64
|
-
next_probe_at = NULL, uncertain_since = NULL
|
|
65
|
-
WHERE effect_id = ?
|
|
66
|
-
AND status = 'processing'
|
|
67
|
-
AND claim_token = ?
|
|
68
|
-
AND writer_epoch = ?
|
|
69
|
-
AND lease_until IS NOT NULL
|
|
70
|
-
AND lease_until > ?
|
|
71
|
-
AND EXISTS (${FENCE_EXISTS_SQL})
|
|
72
|
-
`;
|
|
73
|
-
export const SUPERSEDE_EFFECT_SQL = `
|
|
74
|
-
UPDATE sheet_effect_outbox
|
|
75
|
-
SET status = 'superseded', supersedes_effect_id = ?
|
|
76
|
-
WHERE effect_id = ?
|
|
77
|
-
AND status IN ('pending', 'processing', 'delivery_uncertain', 'blocked_candidate', 'conflict', 'failed')
|
|
78
|
-
AND EXISTS (${FENCE_EXISTS_SQL})
|
|
79
|
-
`;
|
|
80
|
-
export const INSERT_REPLANNED_EFFECT_SQL = `
|
|
81
|
-
INSERT INTO sheet_effect_outbox (
|
|
82
|
-
effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,
|
|
83
|
-
projection, row_binding_id, conflict_id, target_kind, target_id,
|
|
84
|
-
target_entity_revision, target_field_revision_hash, target_canonical_commit_id,
|
|
85
|
-
expected_visible_revision, expected_visible_hash, repair_guard_hash,
|
|
86
|
-
source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,
|
|
87
|
-
stream_sequence, predecessor_effect_id, created_at, status
|
|
88
|
-
)
|
|
89
|
-
SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending'
|
|
90
|
-
WHERE EXISTS (${FENCE_EXISTS_SQL})
|
|
91
|
-
`;
|
|
92
|
-
export const RECOVER_EXPIRED_LEASES_SQL = `
|
|
93
|
-
UPDATE sheet_effect_outbox
|
|
94
|
-
SET status = 'delivery_uncertain', claim_token = NULL, lease_until = NULL,
|
|
95
|
-
uncertain_since = COALESCE(uncertain_since, ?), next_probe_at = ?,
|
|
96
|
-
last_error_code = '${SYNC_EFFECT_RECOVERY_ERROR_CODES.LEASE_EXPIRED_REQUIRES_POSTCONDITION}',
|
|
97
|
-
last_error_message = 'Read the remote postcondition before retrying this effect.'
|
|
98
|
-
WHERE status = 'processing' AND lease_until IS NOT NULL AND lease_until <= ?
|
|
99
|
-
AND EXISTS (${FENCE_EXISTS_SQL})
|
|
100
|
-
`;
|
|
101
|
-
export const REQUEUE_CLAIMED_EFFECT_SQL = `
|
|
102
|
-
UPDATE sheet_effect_outbox
|
|
103
|
-
SET status = 'pending', claim_token = NULL, lease_until = NULL,
|
|
104
|
-
next_attempt_at = ?, uncertain_since = NULL, next_probe_at = NULL,
|
|
105
|
-
last_error_code = ?, last_error_message = ?
|
|
106
|
-
WHERE effect_id = ? AND status = 'processing' AND claim_token = ?
|
|
107
|
-
AND writer_epoch = ? AND lease_until IS NOT NULL AND lease_until > ?
|
|
108
|
-
AND EXISTS (${FENCE_EXISTS_SQL})
|
|
109
|
-
`;
|
|
110
|
-
export const RELEASE_UNPROCESSED_EFFECT_SQL = `
|
|
111
|
-
UPDATE sheet_effect_outbox
|
|
112
|
-
SET status = 'pending', claim_token = NULL, lease_until = NULL,
|
|
113
|
-
next_attempt_at = ?, uncertain_since = NULL, next_probe_at = NULL,
|
|
114
|
-
last_error_code = 'provider_batch_deferred',
|
|
115
|
-
last_error_message = 'Provider acknowledged a bounded batch before this effect.'
|
|
116
|
-
WHERE effect_id = ? AND status = 'processing' AND claim_token = ?
|
|
117
|
-
AND writer_epoch = ? AND lease_until IS NOT NULL AND lease_until > ?
|
|
118
|
-
AND EXISTS (${FENCE_EXISTS_SQL})
|
|
119
|
-
`;
|
|
120
|
-
export const MARK_DELIVERY_UNCERTAIN_SQL = `
|
|
121
|
-
UPDATE sheet_effect_outbox
|
|
122
|
-
SET status = 'delivery_uncertain', claim_token = NULL, lease_until = NULL,
|
|
123
|
-
uncertain_since = COALESCE(uncertain_since, ?), next_probe_at = ?,
|
|
124
|
-
last_error_code = ?, last_error_message = ?
|
|
125
|
-
WHERE effect_id = ? AND status = 'processing' AND claim_token = ?
|
|
126
|
-
AND writer_epoch = ? AND lease_until IS NOT NULL AND lease_until > ?
|
|
127
|
-
AND EXISTS (${FENCE_EXISTS_SQL})
|
|
128
|
-
`;
|
|
129
|
-
export const SELECT_PENDING_EFFECTS_BY_TARGET_SQL = `
|
|
130
|
-
SELECT effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,
|
|
131
|
-
projection, row_binding_id, conflict_id, target_kind, target_id,
|
|
132
|
-
target_entity_revision, target_field_revision_hash, target_canonical_commit_id,
|
|
133
|
-
expected_visible_revision, expected_visible_hash, repair_guard_hash,
|
|
134
|
-
source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,
|
|
135
|
-
stream_sequence, created_at, next_attempt_at, uncertain_since,
|
|
136
|
-
next_probe_at, dispatch_id, status
|
|
137
|
-
FROM sheet_effect_outbox
|
|
138
|
-
WHERE logical_sheet_id = ? AND target_kind = ? AND target_id = ?
|
|
139
|
-
AND status = 'pending'
|
|
140
|
-
AND NOT EXISTS (
|
|
141
|
-
SELECT 1
|
|
142
|
-
FROM sheet_effect_outbox AS predecessor
|
|
143
|
-
WHERE predecessor.logical_sheet_id = sheet_effect_outbox.logical_sheet_id
|
|
144
|
-
AND predecessor.target_kind = sheet_effect_outbox.target_kind
|
|
145
|
-
AND predecessor.target_id = sheet_effect_outbox.target_id
|
|
146
|
-
AND predecessor.stream_sequence < sheet_effect_outbox.stream_sequence
|
|
147
|
-
AND predecessor.status NOT IN ('applied', 'superseded')
|
|
148
|
-
)
|
|
149
|
-
ORDER BY stream_sequence
|
|
150
|
-
`;
|
|
151
|
-
export const SELECT_READY_EFFECTS_SQL = `
|
|
152
|
-
SELECT effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,
|
|
153
|
-
projection, row_binding_id, conflict_id, target_kind, target_id,
|
|
154
|
-
target_entity_revision, target_field_revision_hash, target_canonical_commit_id,
|
|
155
|
-
expected_visible_revision, expected_visible_hash, repair_guard_hash,
|
|
156
|
-
source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,
|
|
157
|
-
stream_sequence, created_at, next_attempt_at, uncertain_since,
|
|
158
|
-
next_probe_at, dispatch_id, status
|
|
159
|
-
FROM sheet_effect_outbox AS candidate
|
|
160
|
-
WHERE (
|
|
161
|
-
(candidate.status = 'pending' AND
|
|
162
|
-
(candidate.next_attempt_at IS NULL OR candidate.next_attempt_at <= ?))
|
|
163
|
-
OR (
|
|
164
|
-
candidate.status = 'failed'
|
|
165
|
-
AND candidate.last_error_code IN (${RECOVERABLE_EFFECT_ERROR_CODE_SQL})
|
|
166
|
-
AND (candidate.next_attempt_at IS NULL OR candidate.next_attempt_at <= ?)
|
|
167
|
-
)
|
|
168
|
-
OR (
|
|
169
|
-
candidate.status = 'delivery_uncertain'
|
|
170
|
-
AND (candidate.next_probe_at IS NULL OR candidate.next_probe_at <= ?)
|
|
171
|
-
)
|
|
172
|
-
)
|
|
173
|
-
AND NOT EXISTS (
|
|
174
|
-
SELECT 1
|
|
175
|
-
FROM sheet_effect_outbox AS predecessor
|
|
176
|
-
WHERE predecessor.logical_sheet_id = candidate.logical_sheet_id
|
|
177
|
-
AND predecessor.target_kind = candidate.target_kind
|
|
178
|
-
AND predecessor.target_id = candidate.target_id
|
|
179
|
-
AND predecessor.stream_sequence < candidate.stream_sequence
|
|
180
|
-
AND predecessor.status NOT IN ('applied', 'superseded')
|
|
181
|
-
)
|
|
182
|
-
ORDER BY candidate.logical_sheet_id, candidate.physical_sheet_id,
|
|
183
|
-
candidate.target_kind, candidate.target_id, candidate.stream_sequence
|
|
184
|
-
LIMIT ?
|
|
185
|
-
`;
|
|
186
|
-
/**
|
|
187
|
-
* Bounded head-of-line selection restricted to potential fast-append rows.
|
|
188
|
-
*
|
|
189
|
-
* Only the SQL-visible append shape is filtered here (pending status,
|
|
190
|
-
* readiness, predecessor ordering, and the revision-zero baseline on the
|
|
191
|
-
* System_State/Sync_Conflicts routes); the worker re-validates each returned
|
|
192
|
-
* row's payload (createIfMissing) before claiming. Rows that fail that
|
|
193
|
-
* payload validation drain through the regular claim path instead.
|
|
194
|
-
*/
|
|
195
|
-
export const SELECT_READY_FAST_APPEND_EFFECTS_SQL = `
|
|
196
|
-
SELECT effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,
|
|
197
|
-
projection, row_binding_id, conflict_id, target_kind, target_id,
|
|
198
|
-
target_entity_revision, target_field_revision_hash, target_canonical_commit_id,
|
|
199
|
-
expected_visible_revision, expected_visible_hash, repair_guard_hash,
|
|
200
|
-
source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,
|
|
201
|
-
stream_sequence, created_at, next_attempt_at, uncertain_since,
|
|
202
|
-
next_probe_at, dispatch_id, status
|
|
203
|
-
FROM sheet_effect_outbox AS candidate
|
|
204
|
-
WHERE candidate.status = 'pending'
|
|
205
|
-
AND (candidate.next_attempt_at IS NULL OR candidate.next_attempt_at <= ?)
|
|
206
|
-
AND candidate.effect_kind IN ('system_projection', 'resolution_projection')
|
|
207
|
-
AND candidate.projection IN ('system_state', 'sync_conflicts')
|
|
208
|
-
AND candidate.target_kind IN ('entity', 'conflict')
|
|
209
|
-
AND candidate.expected_visible_revision = 0
|
|
210
|
-
AND candidate.expected_visible_hash = ''
|
|
211
|
-
AND NOT EXISTS (
|
|
212
|
-
SELECT 1
|
|
213
|
-
FROM sheet_effect_outbox AS predecessor
|
|
214
|
-
WHERE predecessor.logical_sheet_id = candidate.logical_sheet_id
|
|
215
|
-
AND predecessor.target_kind = candidate.target_kind
|
|
216
|
-
AND predecessor.target_id = candidate.target_id
|
|
217
|
-
AND predecessor.stream_sequence < candidate.stream_sequence
|
|
218
|
-
AND predecessor.status NOT IN ('applied', 'superseded')
|
|
219
|
-
)
|
|
220
|
-
ORDER BY candidate.logical_sheet_id, candidate.physical_sheet_id,
|
|
221
|
-
candidate.target_kind, candidate.target_id, candidate.stream_sequence
|
|
222
|
-
LIMIT ?
|
|
223
|
-
`;
|
|
224
|
-
export const COUNT_PENDING_OR_PROCESSING_EFFECTS_SQL = `
|
|
225
|
-
SELECT COUNT(*) AS count
|
|
226
|
-
FROM sheet_effect_outbox
|
|
227
|
-
WHERE status IN ('pending', 'processing', 'delivery_uncertain')
|
|
228
|
-
`;
|
|
229
|
-
export const UPSERT_VISIBLE_STATE_SQL = `
|
|
230
|
-
INSERT INTO sheet_visible_state (
|
|
231
|
-
physical_sheet_id, projection, row_binding_id, confirmed_snapshot_hash,
|
|
232
|
-
confirmed_visible_revision, confirmed_entity_revision, last_observed_hash
|
|
233
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
234
|
-
ON CONFLICT(physical_sheet_id, projection, row_binding_id)
|
|
235
|
-
DO UPDATE SET
|
|
236
|
-
confirmed_snapshot_hash = excluded.confirmed_snapshot_hash,
|
|
237
|
-
confirmed_visible_revision = excluded.confirmed_visible_revision,
|
|
238
|
-
confirmed_entity_revision = excluded.confirmed_entity_revision,
|
|
239
|
-
last_observed_hash = excluded.last_observed_hash
|
|
240
|
-
WHERE sheet_visible_state.confirmed_visible_revision <= excluded.confirmed_visible_revision
|
|
241
|
-
`;
|
|
242
|
-
export const UPSERT_VISIBLE_FIELD_STATE_SQL = `
|
|
243
|
-
INSERT INTO sheet_visible_field_state (
|
|
244
|
-
physical_sheet_id, projection, row_binding_id, field_name,
|
|
245
|
-
confirmed_field_hash, confirmed_visible_revision, candidate_epoch,
|
|
246
|
-
last_observed_field_hash
|
|
247
|
-
) VALUES (?, ?, ?, ?, ?, ?, 0, ?)
|
|
248
|
-
ON CONFLICT(physical_sheet_id, projection, row_binding_id, field_name)
|
|
249
|
-
DO UPDATE SET
|
|
250
|
-
confirmed_field_hash = excluded.confirmed_field_hash,
|
|
251
|
-
confirmed_visible_revision = excluded.confirmed_visible_revision,
|
|
252
|
-
last_observed_field_hash = excluded.last_observed_field_hash
|
|
253
|
-
WHERE sheet_visible_field_state.confirmed_visible_revision <= excluded.confirmed_visible_revision
|
|
254
|
-
`;
|
|
255
|
-
/**
|
|
256
|
-
* Claims a pending effect for processing.
|
|
257
|
-
* Uses CAS on status to ensure only one worker wins.
|
|
258
|
-
*/
|
|
259
|
-
//# sourceMappingURL=effectOutboxSql.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effectOutboxSql.js","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/outbound/effectOutboxSql.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAE9D,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,gCAAgC,CAAC,oCAAoC;IACrE,gCAAgC,CAAC,wBAAwB;IACzD,uEAAuE;IACvE,iEAAiE;IACjE,gCAAgC,CAAC,8BAA8B;IAC/D,gCAAgC,CAAC,yBAAyB;IAC1D,gCAAgC,CAAC,yBAAyB;IAC1D,gCAAgC,CAAC,wCAAwC;CAC1E,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC;KACzB,IAAI,CAAC,IAAI,CAAC,CAAC;AAEd,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;kBAcd,gBAAgB;;;;;;;;;;CAUjC,CAAC;AAEF,M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** Validation, projection confirmation, fencing, and SQL parameter helpers. */
|
|
2
|
-
import type { FencingContext } from "../shared/writerLease.js";
|
|
3
|
-
import type { ApplyResultOptions, ClaimEffectOptions, EffectProjectionConfirmation, MarkDeliveryUncertainOptions, NewEffect, RetryClaimedEffectOptions } from "./effectOutboxContracts.js";
|
|
4
|
-
import type { SqlExecutor, SqlParameter, SqlRow } from "../../../../adapter/persistence/contracts/sql.js";
|
|
5
|
-
import type { PendingEffect } from "./effectOutboxContracts.js";
|
|
6
|
-
/** Promotes one raw outbox SQL row into the closed pending-effect contract. */
|
|
7
|
-
export declare function decodePendingEffectRow(row: SqlRow, index?: number): PendingEffect;
|
|
8
|
-
export declare function validateProjectionConfirmation(confirmation: EffectProjectionConfirmation): void;
|
|
9
|
-
export declare function validateApplyResultOptions(options: ApplyResultOptions): void;
|
|
10
|
-
/** Verifies that read-back evidence belongs to the effect currently being applied. */
|
|
11
|
-
export declare function assertProjectionConfirmationTargetWithSql(sql: SqlExecutor, effectId: string, claimToken: string, confirmation: EffectProjectionConfirmation): Promise<void>;
|
|
12
|
-
export declare function validateEffectLeaseDuration(leaseDurationMs: number): void;
|
|
13
|
-
export declare function validateReadyEffectLimit(limit: number): void;
|
|
14
|
-
/** Writes confirmed row and field state through the active async SQL context. */
|
|
15
|
-
export declare function writeProjectionConfirmationWithSql(sql: SqlExecutor, confirmation: EffectProjectionConfirmation): Promise<void>;
|
|
16
|
-
export declare function requireCurrentFenceWithSql(sql: SqlExecutor, fence: FencingContext): Promise<void>;
|
|
17
|
-
export declare function claimEffectParameters(options: ClaimEffectOptions): readonly SqlParameter[];
|
|
18
|
-
export declare function applyEffectResultParameters(options: ApplyResultOptions): readonly SqlParameter[];
|
|
19
|
-
export declare function effectInsertParameters(effect: NewEffect): readonly SqlParameter[];
|
|
20
|
-
export declare function pendingEffectParameters(effect: NewEffect, fence: FencingContext): readonly SqlParameter[];
|
|
21
|
-
export declare function markDeliveryUncertainParameters(options: MarkDeliveryUncertainOptions): readonly SqlParameter[];
|
|
22
|
-
export declare function retryClaimedEffectParameters(options: RetryClaimedEffectOptions): readonly SqlParameter[];
|
|
23
|
-
export declare function replannedEffectParameters(effect: NewEffect, oldEffectId: string, fence: FencingContext): readonly SqlParameter[];
|
|
24
|
-
/** Internal control-flow signal that forces the enclosing async savepoint to roll back. */
|
|
25
|
-
export declare class AsyncFenceLostError extends Error {
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=effectOutboxSupport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effectOutboxSupport.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/outbound/effectOutboxSupport.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAsB/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM/D,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,SAAS,EACT,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,MAAM,EACP,MAAM,kDAAkD,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAQhE,+EAA+E;AAC/E,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,CAuEjF;AAkFD,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,4BAA4B,GAAG,IAAI,CAyB/F;AAaD,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAgB5E;AAUD,sFAAsF;AACtF,wBAAsB,yCAAyC,CAC7D,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,4BAA4B,GACzC,OAAO,CAAC,IAAI,CAAC,CAYf;AAED,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAOzE;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAO5D;AAED,iFAAiF;AACjF,wBAAsB,kCAAkC,CACtD,GAAG,EAAE,WAAW,EAChB,YAAY,EAAE,4BAA4B,GACzC,OAAO,CAAC,IAAI,CAAC,CAkCf;AAED,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,SAAS,YAAY,EAAE,CAW1F;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,kBAAkB,GAAG,SAAS,YAAY,EAAE,CAWhG;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,YAAY,EAAE,CAwBjF;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,cAAc,GACpB,SAAS,YAAY,EAAE,CAMzB;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,4BAA4B,GACpC,SAAS,YAAY,EAAE,CAYzB;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,yBAAyB,GACjC,SAAS,YAAY,EAAE,CAWzB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,cAAc,GACpB,SAAS,YAAY,EAAE,CAOzB;AAED,2FAA2F;AAC3F,qBAAa,mBAAoB,SAAQ,KAAK;CAAG"}
|
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
/** Validation, projection confirmation, fencing, and SQL parameter helpers. */
|
|
2
|
-
import { STORAGE_ERROR_CODES, StorageError } from "../../errors.js";
|
|
3
|
-
import { EFFECT_KINDS, EFFECT_STATUSES, EFFECT_TARGET_KINDS, } from "../../../../domain/model/constants.js";
|
|
4
|
-
import { isSemanticRevision, requireSemanticString, } from "../../../../shared/identity/types.js";
|
|
5
|
-
import { isRecord } from "../../../../shared/encoding/typeGuards.js";
|
|
6
|
-
import { isNonEmptyString } from "../../../../shared/validation.js";
|
|
7
|
-
import { APPLICABILITY_KINDS } from "../../../../shared/state/constants.js";
|
|
8
|
-
import { fenceParameters, isFencingValidWithSql, } from "../shared/writerLease.js";
|
|
9
|
-
import { toSqlNullable } from "../../sqlite/sqlState.js";
|
|
10
|
-
import { UPSERT_VISIBLE_FIELD_STATE_SQL, UPSERT_VISIBLE_STATE_SQL, } from "./effectOutboxSql.js";
|
|
11
|
-
const READ_CLAIMED_EFFECT_TARGET_SQL = `
|
|
12
|
-
SELECT physical_sheet_id, projection, row_binding_id
|
|
13
|
-
FROM sheet_effect_outbox
|
|
14
|
-
WHERE effect_id = ? AND claim_token = ? AND status = 'processing'
|
|
15
|
-
`;
|
|
16
|
-
/** Promotes one raw outbox SQL row into the closed pending-effect contract. */
|
|
17
|
-
export function decodePendingEffectRow(row, index) {
|
|
18
|
-
const label = index === undefined ? "pending effect" : `pending effect[${index}]`;
|
|
19
|
-
const expectedVisibleRevision = requireSqlRevision(row.expected_visible_revision, `${label}.expected_visible_revision`);
|
|
20
|
-
const expectedVisibleHashText = requireSqlTextAllowEmpty(row.expected_visible_hash, `${label}.expected_visible_hash`);
|
|
21
|
-
if (expectedVisibleHashText.length === 0 && expectedVisibleRevision !== 0) {
|
|
22
|
-
throwInvalidPendingEffect(`${label}.expected_visible_hash may be empty only at revision zero`);
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
effect_id: requirePendingString(row.effect_id, `${label}.effect_id`),
|
|
26
|
-
effect_kind: requireEffectKind(row.effect_kind, `${label}.effect_kind`),
|
|
27
|
-
commit_id: requireSqlText(row.commit_id, `${label}.commit_id`),
|
|
28
|
-
logical_sheet_id: requireSqlText(row.logical_sheet_id, `${label}.logical_sheet_id`),
|
|
29
|
-
physical_sheet_id: requirePendingString(row.physical_sheet_id, `${label}.physical_sheet_id`),
|
|
30
|
-
projection: requireSqlText(row.projection, `${label}.projection`),
|
|
31
|
-
row_binding_id: requireNullablePendingString(row.row_binding_id, `${label}.row_binding_id`),
|
|
32
|
-
conflict_id: requireNullableSqlText(row.conflict_id, `${label}.conflict_id`),
|
|
33
|
-
target_kind: requireEffectTargetKind(row.target_kind, `${label}.target_kind`),
|
|
34
|
-
target_id: requireSqlText(row.target_id, `${label}.target_id`),
|
|
35
|
-
target_entity_revision: requireNullableSqlRevision(row.target_entity_revision, `${label}.target_entity_revision`),
|
|
36
|
-
target_field_revision_hash: requireNullableSqlText(row.target_field_revision_hash, `${label}.target_field_revision_hash`),
|
|
37
|
-
target_canonical_commit_id: requireNullableSqlText(row.target_canonical_commit_id, `${label}.target_canonical_commit_id`),
|
|
38
|
-
expected_visible_revision: expectedVisibleRevision,
|
|
39
|
-
expected_visible_hash: expectedVisibleHashText.length === 0
|
|
40
|
-
? ""
|
|
41
|
-
: requireSemanticString(expectedVisibleHashText, `${label}.expected_visible_hash`),
|
|
42
|
-
repair_guard_hash: requireNullableSqlText(row.repair_guard_hash, `${label}.repair_guard_hash`),
|
|
43
|
-
source_quarantine_id: requireNullableSqlText(row.source_quarantine_id, `${label}.source_quarantine_id`),
|
|
44
|
-
payload_json: requireSqlText(row.payload_json, `${label}.payload_json`),
|
|
45
|
-
payload_hash: requirePendingString(row.payload_hash, `${label}.payload_hash`),
|
|
46
|
-
effect_dedupe_key: requirePendingString(row.effect_dedupe_key, `${label}.effect_dedupe_key`),
|
|
47
|
-
stream_sequence: requireSqlRevision(row.stream_sequence, `${label}.stream_sequence`),
|
|
48
|
-
created_at: requireSqlRevision(row.created_at, `${label}.created_at`),
|
|
49
|
-
next_attempt_at: requireNullableSqlRevision(row.next_attempt_at, `${label}.next_attempt_at`),
|
|
50
|
-
uncertain_since: requireNullableSqlRevision(row.uncertain_since, `${label}.uncertain_since`),
|
|
51
|
-
next_probe_at: requireNullableSqlRevision(row.next_probe_at, `${label}.next_probe_at`),
|
|
52
|
-
dispatch_id: requireNullableSqlText(row.dispatch_id, `${label}.dispatch_id`),
|
|
53
|
-
status: requireEffectStatus(row.status, `${label}.status`),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function requireSqlText(value, label) {
|
|
57
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
58
|
-
throwInvalidPendingEffect(`${label} must be non-empty text`);
|
|
59
|
-
}
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
62
|
-
function requirePendingString(value, label) {
|
|
63
|
-
return requireSemanticString(requireSqlText(value, label), label);
|
|
64
|
-
}
|
|
65
|
-
function requireNullablePendingString(value, label) {
|
|
66
|
-
if (value === null)
|
|
67
|
-
return null;
|
|
68
|
-
return requirePendingString(value, label);
|
|
69
|
-
}
|
|
70
|
-
function requireSqlTextAllowEmpty(value, label) {
|
|
71
|
-
if (typeof value !== "string") {
|
|
72
|
-
throwInvalidPendingEffect(`${label} must be text`);
|
|
73
|
-
}
|
|
74
|
-
return value;
|
|
75
|
-
}
|
|
76
|
-
function requireNullableSqlText(value, label) {
|
|
77
|
-
if (value === null || value === undefined)
|
|
78
|
-
return null;
|
|
79
|
-
return requireSqlText(value, label);
|
|
80
|
-
}
|
|
81
|
-
function requireSqlRevision(value, label) {
|
|
82
|
-
if (!isSemanticRevision(value)) {
|
|
83
|
-
throwInvalidPendingEffect(`${label} must be a non-negative safe integer`);
|
|
84
|
-
}
|
|
85
|
-
return value;
|
|
86
|
-
}
|
|
87
|
-
function requireNullableSqlRevision(value, label) {
|
|
88
|
-
if (value === null || value === undefined)
|
|
89
|
-
return null;
|
|
90
|
-
return requireSqlRevision(value, label);
|
|
91
|
-
}
|
|
92
|
-
function requireEffectKind(value, label) {
|
|
93
|
-
if (value === EFFECT_KINDS.SYSTEM_PROJECTION ||
|
|
94
|
-
value === EFFECT_KINDS.CANDIDATE_RECONCILE ||
|
|
95
|
-
value === EFFECT_KINDS.SYSTEM_REPAIR ||
|
|
96
|
-
value === EFFECT_KINDS.RESOLUTION_PROJECTION ||
|
|
97
|
-
value === EFFECT_KINDS.RESOLUTION_DELETE ||
|
|
98
|
-
value === EFFECT_KINDS.USER_INPUT_DELETE)
|
|
99
|
-
return value;
|
|
100
|
-
throwInvalidPendingEffect(`${label} is unsupported`);
|
|
101
|
-
}
|
|
102
|
-
function requireEffectTargetKind(value, label) {
|
|
103
|
-
if (value === EFFECT_TARGET_KINDS.ENTITY ||
|
|
104
|
-
value === EFFECT_TARGET_KINDS.ROW_BINDING ||
|
|
105
|
-
value === EFFECT_TARGET_KINDS.PROJECTION_ROW ||
|
|
106
|
-
value === EFFECT_TARGET_KINDS.CONFLICT)
|
|
107
|
-
return value;
|
|
108
|
-
throwInvalidPendingEffect(`${label} is unsupported`);
|
|
109
|
-
}
|
|
110
|
-
function requireEffectStatus(value, label) {
|
|
111
|
-
if (value === EFFECT_STATUSES.PENDING ||
|
|
112
|
-
value === EFFECT_STATUSES.PROCESSING ||
|
|
113
|
-
value === EFFECT_STATUSES.DELIVERY_UNCERTAIN ||
|
|
114
|
-
value === EFFECT_STATUSES.APPLIED ||
|
|
115
|
-
value === EFFECT_STATUSES.BLOCKED_CANDIDATE ||
|
|
116
|
-
value === EFFECT_STATUSES.SUPERSEDED ||
|
|
117
|
-
value === EFFECT_STATUSES.CONFLICT ||
|
|
118
|
-
value === EFFECT_STATUSES.FAILED)
|
|
119
|
-
return value;
|
|
120
|
-
throwInvalidPendingEffect(`${label} is unsupported`);
|
|
121
|
-
}
|
|
122
|
-
function throwInvalidPendingEffect(message) {
|
|
123
|
-
throw new StorageError(STORAGE_ERROR_CODES.INVALID_PENDING_EFFECT, message);
|
|
124
|
-
}
|
|
125
|
-
export function validateProjectionConfirmation(confirmation) {
|
|
126
|
-
if (!isRecord(confirmation)) {
|
|
127
|
-
throwInvalidProjectionConfirmation("projection confirmation must be an object");
|
|
128
|
-
}
|
|
129
|
-
if (!isNonEmptyString(confirmation.physicalSheetId) ||
|
|
130
|
-
!isNonEmptyString(confirmation.projection) ||
|
|
131
|
-
!isNonEmptyString(confirmation.rowBindingId) ||
|
|
132
|
-
!isNonEmptyString(confirmation.visibleHash) ||
|
|
133
|
-
!isSemanticRevision(confirmation.visibleRevision) ||
|
|
134
|
-
confirmation.visibleRevision < 1 ||
|
|
135
|
-
!isApplicabilityNumber(confirmation.entityRevision) ||
|
|
136
|
-
!isRecord(confirmation.fieldHashes)) {
|
|
137
|
-
throwInvalidProjectionConfirmation("projection confirmation has an invalid identity, revision, or field state");
|
|
138
|
-
}
|
|
139
|
-
for (const [fieldName, hash] of Object.entries(confirmation.fieldHashes)) {
|
|
140
|
-
if (fieldName.length === 0 || !isNonEmptyString(hash)) {
|
|
141
|
-
throwInvalidProjectionConfirmation("projection confirmation contains an invalid field hash");
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
function isApplicabilityNumber(value) {
|
|
146
|
-
return isRecord(value) && (value.kind === APPLICABILITY_KINDS.NOT_APPLICABLE ||
|
|
147
|
-
value.kind === APPLICABILITY_KINDS.APPLICABLE && isSemanticRevision(value.value));
|
|
148
|
-
}
|
|
149
|
-
function throwInvalidProjectionConfirmation(message) {
|
|
150
|
-
throw new StorageError(STORAGE_ERROR_CODES.INVALID_PROJECTION_CONFIRMATION, message);
|
|
151
|
-
}
|
|
152
|
-
export function validateApplyResultOptions(options) {
|
|
153
|
-
if (!isTerminalEffectStatus(options.status)) {
|
|
154
|
-
throw new StorageError(STORAGE_ERROR_CODES.INVALID_EFFECT_RESULT, `effect result status ${String(options.status)} is not terminal`);
|
|
155
|
-
}
|
|
156
|
-
if (options.status !== EFFECT_STATUSES.APPLIED && options.projectionConfirmation !== undefined) {
|
|
157
|
-
throw new StorageError(STORAGE_ERROR_CODES.INVALID_EFFECT_RESULT, "only an applied effect may advance confirmed projection state");
|
|
158
|
-
}
|
|
159
|
-
if (options.projectionConfirmation !== undefined) {
|
|
160
|
-
validateProjectionConfirmation(options.projectionConfirmation);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
function isTerminalEffectStatus(value) {
|
|
164
|
-
return value === EFFECT_STATUSES.APPLIED ||
|
|
165
|
-
value === EFFECT_STATUSES.BLOCKED_CANDIDATE ||
|
|
166
|
-
value === EFFECT_STATUSES.SUPERSEDED ||
|
|
167
|
-
value === EFFECT_STATUSES.CONFLICT ||
|
|
168
|
-
value === EFFECT_STATUSES.FAILED;
|
|
169
|
-
}
|
|
170
|
-
/** Verifies that read-back evidence belongs to the effect currently being applied. */
|
|
171
|
-
export async function assertProjectionConfirmationTargetWithSql(sql, effectId, claimToken, confirmation) {
|
|
172
|
-
const row = await sql.get(READ_CLAIMED_EFFECT_TARGET_SQL, [effectId, claimToken]);
|
|
173
|
-
if (row === undefined ||
|
|
174
|
-
row.physical_sheet_id !== confirmation.physicalSheetId ||
|
|
175
|
-
row.projection !== confirmation.projection ||
|
|
176
|
-
row.row_binding_id !== confirmation.rowBindingId) {
|
|
177
|
-
throwInvalidProjectionConfirmation("projection confirmation does not belong to the claimed effect");
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
export function validateEffectLeaseDuration(leaseDurationMs) {
|
|
181
|
-
if (!Number.isSafeInteger(leaseDurationMs) || leaseDurationMs <= 0) {
|
|
182
|
-
throw new StorageError(STORAGE_ERROR_CODES.INVALID_EFFECT_OPTIONS, "effect lease duration must be a positive safe integer");
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
export function validateReadyEffectLimit(limit) {
|
|
186
|
-
if (!Number.isSafeInteger(limit) || limit < 1) {
|
|
187
|
-
throw new StorageError(STORAGE_ERROR_CODES.INVALID_EFFECT_OPTIONS, "ready effect limit must be a positive safe integer");
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
/** Writes confirmed row and field state through the active async SQL context. */
|
|
191
|
-
export async function writeProjectionConfirmationWithSql(sql, confirmation) {
|
|
192
|
-
const row = await sql.run(UPSERT_VISIBLE_STATE_SQL, [
|
|
193
|
-
confirmation.physicalSheetId,
|
|
194
|
-
confirmation.projection,
|
|
195
|
-
confirmation.rowBindingId,
|
|
196
|
-
confirmation.visibleHash,
|
|
197
|
-
confirmation.visibleRevision,
|
|
198
|
-
toSqlNullable(confirmation.entityRevision),
|
|
199
|
-
confirmation.visibleHash,
|
|
200
|
-
]);
|
|
201
|
-
if (row.changes !== 1) {
|
|
202
|
-
throw new StorageError(STORAGE_ERROR_CODES.PROJECTION_CONFIRMATION_REGRESSION, "projection confirmation would move visible state backwards");
|
|
203
|
-
}
|
|
204
|
-
for (const [fieldName, hash] of Object.entries(confirmation.fieldHashes)) {
|
|
205
|
-
const field = await sql.run(UPSERT_VISIBLE_FIELD_STATE_SQL, [
|
|
206
|
-
confirmation.physicalSheetId,
|
|
207
|
-
confirmation.projection,
|
|
208
|
-
confirmation.rowBindingId,
|
|
209
|
-
fieldName,
|
|
210
|
-
hash,
|
|
211
|
-
confirmation.visibleRevision,
|
|
212
|
-
hash,
|
|
213
|
-
]);
|
|
214
|
-
if (field.changes !== 1) {
|
|
215
|
-
throw new StorageError(STORAGE_ERROR_CODES.PROJECTION_CONFIRMATION_REGRESSION, "projection confirmation would move a field visible state backwards");
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
export async function requireCurrentFenceWithSql(sql, fence) {
|
|
220
|
-
if (!(await isFencingValidWithSql(sql, fence))) {
|
|
221
|
-
throw new StorageError(STORAGE_ERROR_CODES.STALE_WRITER_FENCE, "writer fencing is stale or expired");
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
export function claimEffectParameters(options) {
|
|
225
|
-
return [
|
|
226
|
-
options.claimToken,
|
|
227
|
-
options.writerEpoch,
|
|
228
|
-
options.now + options.leaseDurationMs,
|
|
229
|
-
options.dispatchId ?? "dispatch:" + options.claimToken,
|
|
230
|
-
options.effectId,
|
|
231
|
-
options.now,
|
|
232
|
-
options.now,
|
|
233
|
-
...fenceParameters(options),
|
|
234
|
-
];
|
|
235
|
-
}
|
|
236
|
-
export function applyEffectResultParameters(options) {
|
|
237
|
-
return [
|
|
238
|
-
options.status,
|
|
239
|
-
toSqlNullable(options.lastErrorCode),
|
|
240
|
-
toSqlNullable(options.lastErrorMessage),
|
|
241
|
-
options.effectId,
|
|
242
|
-
options.claimToken,
|
|
243
|
-
options.writerEpoch,
|
|
244
|
-
options.now,
|
|
245
|
-
...fenceParameters(options),
|
|
246
|
-
];
|
|
247
|
-
}
|
|
248
|
-
export function effectInsertParameters(effect) {
|
|
249
|
-
return [
|
|
250
|
-
effect.effectId,
|
|
251
|
-
effect.effectKind,
|
|
252
|
-
effect.commitId,
|
|
253
|
-
effect.logicalSheetId,
|
|
254
|
-
effect.physicalSheetId,
|
|
255
|
-
effect.projection,
|
|
256
|
-
toSqlNullable(effect.rowBindingId),
|
|
257
|
-
toSqlNullable(effect.conflictId),
|
|
258
|
-
effect.targetKind,
|
|
259
|
-
effect.targetId,
|
|
260
|
-
toSqlNullable(effect.targetEntityRevision),
|
|
261
|
-
toSqlNullable(effect.targetFieldRevisionHash),
|
|
262
|
-
toSqlNullable(effect.targetCanonicalCommitId),
|
|
263
|
-
effect.expectedVisibleRevision,
|
|
264
|
-
effect.expectedVisibleHash,
|
|
265
|
-
toSqlNullable(effect.repairGuardHash),
|
|
266
|
-
toSqlNullable(effect.sourceQuarantineId),
|
|
267
|
-
effect.payloadJson,
|
|
268
|
-
effect.payloadHash,
|
|
269
|
-
effect.effectDedupeKey,
|
|
270
|
-
effect.streamSequence,
|
|
271
|
-
];
|
|
272
|
-
}
|
|
273
|
-
export function pendingEffectParameters(effect, fence) {
|
|
274
|
-
return [
|
|
275
|
-
...effectInsertParameters(effect),
|
|
276
|
-
fence.now,
|
|
277
|
-
...fenceParameters(fence),
|
|
278
|
-
];
|
|
279
|
-
}
|
|
280
|
-
export function markDeliveryUncertainParameters(options) {
|
|
281
|
-
return [
|
|
282
|
-
options.uncertainSince,
|
|
283
|
-
options.nextProbeAt,
|
|
284
|
-
options.lastErrorCode,
|
|
285
|
-
options.lastErrorMessage,
|
|
286
|
-
options.effectId,
|
|
287
|
-
options.claimToken,
|
|
288
|
-
options.writerEpoch,
|
|
289
|
-
options.now,
|
|
290
|
-
...fenceParameters(options),
|
|
291
|
-
];
|
|
292
|
-
}
|
|
293
|
-
export function retryClaimedEffectParameters(options) {
|
|
294
|
-
return [
|
|
295
|
-
options.nextAttemptAt ?? options.now + 1_000,
|
|
296
|
-
options.lastErrorCode,
|
|
297
|
-
options.lastErrorMessage,
|
|
298
|
-
options.effectId,
|
|
299
|
-
options.claimToken,
|
|
300
|
-
options.writerEpoch,
|
|
301
|
-
options.now,
|
|
302
|
-
...fenceParameters(options),
|
|
303
|
-
];
|
|
304
|
-
}
|
|
305
|
-
export function replannedEffectParameters(effect, oldEffectId, fence) {
|
|
306
|
-
return [
|
|
307
|
-
...effectInsertParameters(effect),
|
|
308
|
-
oldEffectId,
|
|
309
|
-
fence.now,
|
|
310
|
-
...fenceParameters(fence),
|
|
311
|
-
];
|
|
312
|
-
}
|
|
313
|
-
/** Internal control-flow signal that forces the enclosing async savepoint to roll back. */
|
|
314
|
-
export class AsyncFenceLostError extends Error {
|
|
315
|
-
}
|
|
316
|
-
//# sourceMappingURL=effectOutboxSupport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effectOutboxSupport.js","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/outbound/effectOutboxSupport.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,mBAAmB,GACpB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GAGtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,2CAA2C,CAAC;AACrE,OAAO,EAAE,gBAAgB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