@amalgm/live 0.2.30 → 0.2.32
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/PURPOSE.md +30 -1
- package/README.md +1 -0
- package/dist/apply/content-results.d.ts +26 -0
- package/dist/apply/content-results.d.ts.map +1 -0
- package/dist/apply/content-results.js +52 -0
- package/dist/apply/content-results.js.map +1 -0
- package/dist/apply/contracts.d.ts +191 -0
- package/dist/apply/contracts.d.ts.map +1 -0
- package/dist/apply/contracts.js +47 -0
- package/dist/apply/contracts.js.map +1 -0
- package/dist/apply/index.d.ts +10 -0
- package/dist/apply/index.d.ts.map +1 -0
- package/dist/apply/index.js +10 -0
- package/dist/apply/index.js.map +1 -0
- package/dist/apply/local-work.d.ts +10 -0
- package/dist/apply/local-work.d.ts.map +1 -0
- package/dist/apply/local-work.js +17 -0
- package/dist/apply/local-work.js.map +1 -0
- package/dist/apply/plans.d.ts +14 -0
- package/dist/apply/plans.d.ts.map +1 -0
- package/dist/apply/plans.js +183 -0
- package/dist/apply/plans.js.map +1 -0
- package/dist/apply/rail.d.ts +25 -0
- package/dist/apply/rail.d.ts.map +1 -0
- package/dist/apply/rail.js +304 -0
- package/dist/apply/rail.js.map +1 -0
- package/dist/apply/repository-result.d.ts +25 -0
- package/dist/apply/repository-result.d.ts.map +1 -0
- package/dist/apply/repository-result.js +83 -0
- package/dist/apply/repository-result.js.map +1 -0
- package/dist/apply/selection.d.ts +14 -0
- package/dist/apply/selection.d.ts.map +1 -0
- package/dist/apply/selection.js +63 -0
- package/dist/apply/selection.js.map +1 -0
- package/dist/apply/type-adapters.d.ts +13 -0
- package/dist/apply/type-adapters.d.ts.map +1 -0
- package/dist/apply/type-adapters.js +37 -0
- package/dist/apply/type-adapters.js.map +1 -0
- package/dist/detection/adapter-contract.d.ts +11 -8
- package/dist/detection/adapter-contract.d.ts.map +1 -1
- package/dist/detection/adapter-contract.js +5 -5
- package/dist/detection/adapter-contract.js.map +1 -1
- package/dist/detection/echo.d.ts +1 -1
- package/dist/detection/echo.d.ts.map +1 -1
- package/dist/detection/echo.js +8 -1
- package/dist/detection/echo.js.map +1 -1
- package/dist/detection/territory.d.ts +19 -0
- package/dist/detection/territory.d.ts.map +1 -1
- package/dist/detection/territory.js +50 -0
- package/dist/detection/territory.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/records/rail.d.ts +2 -0
- package/dist/records/rail.d.ts.map +1 -1
- package/dist/records/rail.js +6 -0
- package/dist/records/rail.js.map +1 -1
- package/dist-cjs/apply/content-results.js +57 -0
- package/dist-cjs/apply/content-results.js.map +1 -0
- package/dist-cjs/apply/contracts.js +53 -0
- package/dist-cjs/apply/contracts.js.map +1 -0
- package/dist-cjs/apply/index.js +28 -0
- package/dist-cjs/apply/index.js.map +1 -0
- package/dist-cjs/apply/local-work.js +20 -0
- package/dist-cjs/apply/local-work.js.map +1 -0
- package/dist-cjs/apply/plans.js +187 -0
- package/dist-cjs/apply/plans.js.map +1 -0
- package/dist-cjs/apply/rail.js +308 -0
- package/dist-cjs/apply/rail.js.map +1 -0
- package/dist-cjs/apply/repository-result.js +86 -0
- package/dist-cjs/apply/repository-result.js.map +1 -0
- package/dist-cjs/apply/selection.js +66 -0
- package/dist-cjs/apply/selection.js.map +1 -0
- package/dist-cjs/apply/type-adapters.js +41 -0
- package/dist-cjs/apply/type-adapters.js.map +1 -0
- package/dist-cjs/detection/adapter-contract.js +5 -5
- package/dist-cjs/detection/adapter-contract.js.map +1 -1
- package/dist-cjs/detection/echo.js +8 -1
- package/dist-cjs/detection/echo.js.map +1 -1
- package/dist-cjs/detection/territory.js +51 -0
- package/dist-cjs/detection/territory.js.map +1 -1
- package/dist-cjs/index.js +1 -0
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/records/rail.js +6 -0
- package/dist-cjs/records/rail.js.map +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Event-driven portable Apply/Verify orchestration. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.EntityApplyRail = exports.ENTITY_APPLY_RETRY_MAX_MS = exports.ENTITY_APPLY_RETRY_BASE_MS = exports.ENTITY_APPLY_DEFAULT_WORK_LIMIT = exports.ENTITY_APPLY_DEFAULT_CONCURRENCY = void 0;
|
|
5
|
+
const contracts_js_1 = require("./contracts.js");
|
|
6
|
+
const plans_js_1 = require("./plans.js");
|
|
7
|
+
const selection_js_1 = require("./selection.js");
|
|
8
|
+
exports.ENTITY_APPLY_DEFAULT_CONCURRENCY = 8;
|
|
9
|
+
exports.ENTITY_APPLY_DEFAULT_WORK_LIMIT = 64;
|
|
10
|
+
exports.ENTITY_APPLY_RETRY_BASE_MS = 1_000;
|
|
11
|
+
exports.ENTITY_APPLY_RETRY_MAX_MS = 30_000;
|
|
12
|
+
async function boundedMap(values, concurrency, visit) {
|
|
13
|
+
const results = new Array(values.length);
|
|
14
|
+
let cursor = 0;
|
|
15
|
+
const workers = Array.from({ length: Math.min(concurrency, values.length) }, async () => {
|
|
16
|
+
while (true) {
|
|
17
|
+
const index = cursor;
|
|
18
|
+
cursor += 1;
|
|
19
|
+
if (index >= values.length)
|
|
20
|
+
return;
|
|
21
|
+
results[index] = await visit(values[index]);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
await Promise.all(workers);
|
|
25
|
+
return results;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Apply has only two wake sources: Receive committed new Inbox work, or local
|
|
29
|
+
* state changed in a way that may release a pending-local gate. Unsettled
|
|
30
|
+
* machine truth alone schedules bounded retry; an idle rail never polls.
|
|
31
|
+
*/
|
|
32
|
+
class EntityApplyRail {
|
|
33
|
+
#options;
|
|
34
|
+
#concurrency;
|
|
35
|
+
#workLimit;
|
|
36
|
+
#onBackgroundError;
|
|
37
|
+
#started = false;
|
|
38
|
+
#stopped = false;
|
|
39
|
+
#needsApply = false;
|
|
40
|
+
#retryRequested = false;
|
|
41
|
+
#running = null;
|
|
42
|
+
#retry = null;
|
|
43
|
+
#retryAttempt = 0;
|
|
44
|
+
constructor(options) {
|
|
45
|
+
this.#options = options;
|
|
46
|
+
this.#concurrency = options.concurrency ?? exports.ENTITY_APPLY_DEFAULT_CONCURRENCY;
|
|
47
|
+
this.#workLimit = options.workLimit ?? exports.ENTITY_APPLY_DEFAULT_WORK_LIMIT;
|
|
48
|
+
this.#onBackgroundError = options.onBackgroundError ?? (() => undefined);
|
|
49
|
+
if (!Number.isSafeInteger(this.#concurrency) || this.#concurrency < 1
|
|
50
|
+
|| !Number.isSafeInteger(this.#workLimit) || this.#workLimit < 1) {
|
|
51
|
+
throw new Error('entity Apply concurrency and work limit must be positive integers');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Resume durable intents and then consume already-received Inbox work. */
|
|
55
|
+
async start() {
|
|
56
|
+
if (this.#started)
|
|
57
|
+
throw new Error('entity Apply rail already started');
|
|
58
|
+
if (this.#stopped)
|
|
59
|
+
throw new Error('entity Apply rail is stopped');
|
|
60
|
+
this.#started = true;
|
|
61
|
+
this.#needsApply = true;
|
|
62
|
+
await this.#runExplicitly();
|
|
63
|
+
}
|
|
64
|
+
/** Receive calls only after its Inbox transaction commits. */
|
|
65
|
+
recordsAvailable() {
|
|
66
|
+
if (this.#stopped)
|
|
67
|
+
return;
|
|
68
|
+
this.#needsApply = true;
|
|
69
|
+
if (this.#started)
|
|
70
|
+
this.#kick();
|
|
71
|
+
}
|
|
72
|
+
/** Record/Send or Detect calls after a local gate may have changed. */
|
|
73
|
+
localStateChanged() {
|
|
74
|
+
this.recordsAvailable();
|
|
75
|
+
}
|
|
76
|
+
/** Await work known at this boundary. It never creates an idle query loop. */
|
|
77
|
+
async flush() {
|
|
78
|
+
if (!this.#started)
|
|
79
|
+
throw new Error('entity Apply rail has not started');
|
|
80
|
+
if (this.#stopped)
|
|
81
|
+
return;
|
|
82
|
+
this.#needsApply = true;
|
|
83
|
+
await this.#runExplicitly();
|
|
84
|
+
}
|
|
85
|
+
async stop() {
|
|
86
|
+
if (this.#stopped)
|
|
87
|
+
return;
|
|
88
|
+
this.#stopped = true;
|
|
89
|
+
this.#cancelRetry();
|
|
90
|
+
await this.#running?.catch(() => undefined);
|
|
91
|
+
}
|
|
92
|
+
async #runExplicitly() {
|
|
93
|
+
this.#cancelRetry();
|
|
94
|
+
try {
|
|
95
|
+
// A finishing drain can hand a late flag to a successor from its final
|
|
96
|
+
// microtask. An explicit caller owns that successor as well.
|
|
97
|
+
do {
|
|
98
|
+
await this.#ensureRun();
|
|
99
|
+
} while (!this.#stopped && (this.#needsApply || this.#running !== null));
|
|
100
|
+
if (this.#retryRequested)
|
|
101
|
+
this.#scheduleRetry();
|
|
102
|
+
else
|
|
103
|
+
this.#retryAttempt = 0;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
this.#scheduleRetry();
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
#kick() {
|
|
111
|
+
if (!this.#started || this.#stopped)
|
|
112
|
+
return;
|
|
113
|
+
this.#cancelRetry();
|
|
114
|
+
void this.#ensureRun().then(() => {
|
|
115
|
+
if (this.#retryRequested)
|
|
116
|
+
this.#scheduleRetry();
|
|
117
|
+
else
|
|
118
|
+
this.#retryAttempt = 0;
|
|
119
|
+
}, (error) => {
|
|
120
|
+
this.#onBackgroundError(error);
|
|
121
|
+
this.#scheduleRetry();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
#ensureRun() {
|
|
125
|
+
if (this.#running)
|
|
126
|
+
return this.#running;
|
|
127
|
+
const running = this.#drain();
|
|
128
|
+
this.#running = running;
|
|
129
|
+
void running.finally(() => {
|
|
130
|
+
if (this.#running === running)
|
|
131
|
+
this.#running = null;
|
|
132
|
+
if (!this.#stopped && this.#needsApply)
|
|
133
|
+
this.#kick();
|
|
134
|
+
}).catch(() => undefined);
|
|
135
|
+
return running;
|
|
136
|
+
}
|
|
137
|
+
async #drain() {
|
|
138
|
+
this.#retryRequested = false;
|
|
139
|
+
while (!this.#stopped && this.#needsApply) {
|
|
140
|
+
this.#needsApply = false;
|
|
141
|
+
const entities = new Set();
|
|
142
|
+
const cursors = new Set();
|
|
143
|
+
let afterCursor = null;
|
|
144
|
+
let madeProgress = false;
|
|
145
|
+
do {
|
|
146
|
+
const page = await this.#options.store.readApplyWork(this.#workLimit, afterCursor);
|
|
147
|
+
if (!page || !Array.isArray(page.work)
|
|
148
|
+
|| (page.nextCursor !== null
|
|
149
|
+
&& (typeof page.nextCursor !== 'string' || page.nextCursor.length === 0))) {
|
|
150
|
+
throw new Error('entity Apply store returned an invalid work page');
|
|
151
|
+
}
|
|
152
|
+
if (page.work.length > this.#workLimit
|
|
153
|
+
|| (page.work.length === 0 && page.nextCursor !== null)) {
|
|
154
|
+
throw new Error('entity Apply store violated its work-page bound');
|
|
155
|
+
}
|
|
156
|
+
for (const item of page.work) {
|
|
157
|
+
if (entities.has(item.entityId)) {
|
|
158
|
+
throw new Error(`entity Apply store returned ${item.entityId} twice in one scan`);
|
|
159
|
+
}
|
|
160
|
+
entities.add(item.entityId);
|
|
161
|
+
}
|
|
162
|
+
const results = await boundedMap(page.work, this.#concurrency, (item) => this.#applyOne(item));
|
|
163
|
+
if (results.includes('retry'))
|
|
164
|
+
this.#retryRequested = true;
|
|
165
|
+
if (results.includes('progress'))
|
|
166
|
+
madeProgress = true;
|
|
167
|
+
afterCursor = page.nextCursor;
|
|
168
|
+
if (afterCursor !== null && cursors.has(afterCursor)) {
|
|
169
|
+
throw new Error('entity Apply store repeated a work-page cursor');
|
|
170
|
+
}
|
|
171
|
+
if (afterCursor !== null)
|
|
172
|
+
cursors.add(afterCursor);
|
|
173
|
+
} while (!this.#stopped && afterCursor !== null);
|
|
174
|
+
if (madeProgress)
|
|
175
|
+
this.#needsApply = true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async #applyOne(work) {
|
|
179
|
+
const selected = (0, selection_js_1.selectEntityApply)(work);
|
|
180
|
+
if (work.intent === null) {
|
|
181
|
+
if (await this.#options.store.hasLocalWorkAfter(work.authorityId, work.entityId, selected.target.globalSequence)) {
|
|
182
|
+
return 'blocked';
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const plan = (0, plans_js_1.planSelectedEntityApply)(work, selected, this.#options.sha256Hex);
|
|
186
|
+
const adapter = this.#options.effects.adapterFor(plan.target.type);
|
|
187
|
+
let intent;
|
|
188
|
+
if (work.intent === null) {
|
|
189
|
+
intent = (0, contracts_js_1.createApplyIntent)({
|
|
190
|
+
authorityId: work.authorityId,
|
|
191
|
+
entityId: work.entityId,
|
|
192
|
+
fromSequence: work.resolvedThrough,
|
|
193
|
+
target: selected.target,
|
|
194
|
+
createdAt: this.#options.now(),
|
|
195
|
+
});
|
|
196
|
+
await this.#options.store.beginIntent(intent);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
intent = work.intent;
|
|
200
|
+
}
|
|
201
|
+
if (intent.phase !== 'revealed'
|
|
202
|
+
&& await this.#options.store.hasLocalWorkAfter(intent.authorityId, intent.entityId, intent.throughSequence)) {
|
|
203
|
+
await this.#abandon(intent, plan, adapter);
|
|
204
|
+
return 'progress';
|
|
205
|
+
}
|
|
206
|
+
if (intent.phase === 'declared') {
|
|
207
|
+
const guard = await adapter.apply.guard(intent, plan);
|
|
208
|
+
if (guard.kind === 'retry')
|
|
209
|
+
return 'retry';
|
|
210
|
+
if (guard.kind === 'local-change') {
|
|
211
|
+
if (!await this.#options.store.hasLocalWorkAfter(intent.authorityId, intent.entityId, intent.throughSequence)) {
|
|
212
|
+
await this.#options.effects.captureLocal(intent, plan, 'before-reveal');
|
|
213
|
+
}
|
|
214
|
+
if (!await this.#options.store.hasLocalWorkAfter(intent.authorityId, intent.entityId, intent.throughSequence)) {
|
|
215
|
+
throw new Error('Apply local capture returned without durable Outbox work after its target');
|
|
216
|
+
}
|
|
217
|
+
await this.#abandon(intent, plan, adapter);
|
|
218
|
+
return 'progress';
|
|
219
|
+
}
|
|
220
|
+
if (guard.kind === 'already-target') {
|
|
221
|
+
// Revealed means visible ground owns the target, whether this pass
|
|
222
|
+
// installed it or the early guard proved it was already present.
|
|
223
|
+
intent = (0, contracts_js_1.advanceApplyIntent)((0, contracts_js_1.advanceApplyIntent)(intent, 'prepared'), 'revealed');
|
|
224
|
+
await this.#options.store.setIntentPhase(intent);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
if (await this.#options.store.hasLocalWorkAfter(intent.authorityId, intent.entityId, intent.throughSequence)) {
|
|
228
|
+
await this.#abandon(intent, plan, adapter);
|
|
229
|
+
return 'progress';
|
|
230
|
+
}
|
|
231
|
+
await adapter.apply.prepare(intent, plan);
|
|
232
|
+
intent = (0, contracts_js_1.advanceApplyIntent)(intent, 'prepared');
|
|
233
|
+
await this.#options.store.setIntentPhase(intent);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (intent.phase === 'prepared') {
|
|
237
|
+
if (await this.#options.store.hasLocalWorkAfter(intent.authorityId, intent.entityId, intent.throughSequence)) {
|
|
238
|
+
await this.#abandon(intent, plan, adapter);
|
|
239
|
+
return 'progress';
|
|
240
|
+
}
|
|
241
|
+
const guard = await adapter.apply.guard(intent, plan);
|
|
242
|
+
if (guard.kind === 'retry')
|
|
243
|
+
return 'retry';
|
|
244
|
+
if (guard.kind === 'local-change') {
|
|
245
|
+
if (!await this.#options.store.hasLocalWorkAfter(intent.authorityId, intent.entityId, intent.throughSequence)) {
|
|
246
|
+
await this.#options.effects.captureLocal(intent, plan, 'before-reveal');
|
|
247
|
+
}
|
|
248
|
+
if (!await this.#options.store.hasLocalWorkAfter(intent.authorityId, intent.entityId, intent.throughSequence)) {
|
|
249
|
+
throw new Error('Apply local capture returned without durable Outbox work after its target');
|
|
250
|
+
}
|
|
251
|
+
await this.#abandon(intent, plan, adapter);
|
|
252
|
+
return 'progress';
|
|
253
|
+
}
|
|
254
|
+
if (guard.kind === 'safe') {
|
|
255
|
+
// Close the window between the disk guard and the reveal as far as the
|
|
256
|
+
// durable local queue can prove. The host's recoverable replacement
|
|
257
|
+
// owns the remaining syscall-sized race.
|
|
258
|
+
if (await this.#options.store.hasLocalWorkAfter(intent.authorityId, intent.entityId, intent.throughSequence)) {
|
|
259
|
+
await this.#abandon(intent, plan, adapter);
|
|
260
|
+
return 'progress';
|
|
261
|
+
}
|
|
262
|
+
await adapter.apply.reveal(intent, plan);
|
|
263
|
+
}
|
|
264
|
+
intent = (0, contracts_js_1.advanceApplyIntent)(intent, 'revealed');
|
|
265
|
+
await this.#options.store.setIntentPhase(intent);
|
|
266
|
+
}
|
|
267
|
+
const verification = await adapter.verify.verify(intent, plan);
|
|
268
|
+
if (verification.kind === 'retry')
|
|
269
|
+
return 'retry';
|
|
270
|
+
if (verification.kind === 'local-change') {
|
|
271
|
+
if (!await this.#options.store.hasLocalWorkAfter(intent.authorityId, intent.entityId, intent.throughSequence)) {
|
|
272
|
+
await this.#options.effects.captureLocal(intent, plan, 'after-reveal');
|
|
273
|
+
}
|
|
274
|
+
if (!await this.#options.store.hasLocalWorkAfter(intent.authorityId, intent.entityId, intent.throughSequence)) {
|
|
275
|
+
throw new Error('Apply post-reveal capture returned without durable Outbox work after its target');
|
|
276
|
+
}
|
|
277
|
+
await adapter.apply.discard(intent, plan);
|
|
278
|
+
await this.#options.store.completeIntent(intent, { kind: 'superseded-by-local' });
|
|
279
|
+
return 'progress';
|
|
280
|
+
}
|
|
281
|
+
await adapter.apply.discard(intent, plan);
|
|
282
|
+
await this.#options.store.completeIntent(intent, { kind: 'materialized' });
|
|
283
|
+
return 'progress';
|
|
284
|
+
}
|
|
285
|
+
async #abandon(intent, plan, adapter) {
|
|
286
|
+
await adapter.apply.discard(intent, plan);
|
|
287
|
+
await this.#options.store.cancelIntent(intent);
|
|
288
|
+
}
|
|
289
|
+
#scheduleRetry() {
|
|
290
|
+
if (this.#stopped || this.#retry)
|
|
291
|
+
return;
|
|
292
|
+
const base = Math.min(exports.ENTITY_APPLY_RETRY_MAX_MS, exports.ENTITY_APPLY_RETRY_BASE_MS * (2 ** Math.min(this.#retryAttempt, 16)));
|
|
293
|
+
const random = Math.max(0, Math.min(1, this.#options.schedule.random()));
|
|
294
|
+
const delay = Math.round(base * (0.5 + random));
|
|
295
|
+
this.#retryAttempt += 1;
|
|
296
|
+
this.#retry = this.#options.schedule.schedule(delay, () => {
|
|
297
|
+
this.#retry = null;
|
|
298
|
+
this.#needsApply = true;
|
|
299
|
+
this.#kick();
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
#cancelRetry() {
|
|
303
|
+
this.#retry?.cancel();
|
|
304
|
+
this.#retry = null;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
exports.EntityApplyRail = EntityApplyRail;
|
|
308
|
+
//# sourceMappingURL=rail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rail.js","sourceRoot":"","sources":["../../src/apply/rail.ts"],"names":[],"mappings":";AAAA,wDAAwD;;;AAExD,iDAQwB;AACxB,yCAAqD;AACrD,iDAAmD;AAEtC,QAAA,gCAAgC,GAAG,CAAC,CAAC;AACrC,QAAA,+BAA+B,GAAG,EAAE,CAAC;AACrC,QAAA,0BAA0B,GAAG,KAAK,CAAC;AACnC,QAAA,yBAAyB,GAAG,MAAM,CAAC;AAIhD,KAAK,UAAU,UAAU,CACvB,MAAoB,EACpB,WAAmB,EACnB,KAAoC;IAEpC,MAAM,OAAO,GAAG,IAAI,KAAK,CAAS,MAAM,CAAC,MAAM,CAAC,CAAC;IACjD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,E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AAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC1C,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,cAAc;QACZ,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CACnB,iCAAyB,EACzB,kCAA0B,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CACrE,CAAC;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACzE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,aAAa,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;YACxD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAED,YAAY;QACV,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;CACF;AA7SD,0CA6SC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Portable proof of one incremental Git Card + Checkpoint transport chain. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.prepareRepositoryResult = prepareRepositoryResult;
|
|
5
|
+
const repo_states_js_1 = require("../entities/repo-states.js");
|
|
6
|
+
const portableRepositoryPath = (path) => path.length > 0
|
|
7
|
+
&& !path.startsWith('/')
|
|
8
|
+
&& !path.includes('\0')
|
|
9
|
+
&& path.split('/').every((part) => part !== '' && part !== '.' && part !== '..');
|
|
10
|
+
function assertTransportTruth(state, sha256Hex) {
|
|
11
|
+
const cardId = (0, repo_states_js_1.deriveCardId)(state.card, sha256Hex);
|
|
12
|
+
const checkpointId = (0, repo_states_js_1.deriveCheckpointId)(state.checkpoint, sha256Hex);
|
|
13
|
+
const stateId = (0, repo_states_js_1.deriveStateId)(cardId, checkpointId, sha256Hex);
|
|
14
|
+
if (state.cardId !== cardId || state.checkpointId !== checkpointId || state.stateId !== stateId) {
|
|
15
|
+
throw new Error('repository Apply transport IDs do not describe its Card + Checkpoint');
|
|
16
|
+
}
|
|
17
|
+
if (state.pack !== null && sha256Hex(state.pack.bytes) !== state.pack.sha256) {
|
|
18
|
+
throw new Error('repository Apply Git pack failed verification');
|
|
19
|
+
}
|
|
20
|
+
const paths = new Set();
|
|
21
|
+
for (const file of state.checkpoint.untracked) {
|
|
22
|
+
if (!portableRepositoryPath(file.path) || paths.has(file.path)
|
|
23
|
+
|| !['100644', '100755', '120000'].includes(file.mode)) {
|
|
24
|
+
throw new Error('repository Apply Checkpoint has an invalid untracked path or mode');
|
|
25
|
+
}
|
|
26
|
+
paths.add(file.path);
|
|
27
|
+
if (file.content !== null && sha256Hex(file.content) !== file.sha256) {
|
|
28
|
+
throw new Error(`repository Apply Checkpoint content failed verification for ${file.path}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const entry of state.identityDelta.upsert) {
|
|
32
|
+
if (!portableRepositoryPath(entry.path)) {
|
|
33
|
+
throw new Error('repository Apply identity map has an unsafe path');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (state.identityDelta.remove.some((path) => !portableRepositoryPath(path))) {
|
|
37
|
+
throw new Error('repository Apply identity map has an unsafe removal path');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Verify a sealed transport suffix before a host invokes Git. With a null
|
|
42
|
+
* base the chain must be complete from its reset node. With a durable local
|
|
43
|
+
* base, the first incremental node must name that exact transport frontier.
|
|
44
|
+
*/
|
|
45
|
+
function prepareRepositoryResult(plan, nodes, base, sha256Hex) {
|
|
46
|
+
if (nodes.length === 0)
|
|
47
|
+
throw new Error('repository Apply transport chain is empty');
|
|
48
|
+
let priorVersion = base.transportVersion;
|
|
49
|
+
let identity = base.identity;
|
|
50
|
+
if ((base.transportVersion === null) !== (base.identity === null)) {
|
|
51
|
+
throw new Error('repository Apply base frontier is incomplete');
|
|
52
|
+
}
|
|
53
|
+
const transports = [];
|
|
54
|
+
for (const node of nodes) {
|
|
55
|
+
if (sha256Hex(node.bytes) !== node.transportVersion) {
|
|
56
|
+
throw new Error('repository Apply transport failed its immutable hash');
|
|
57
|
+
}
|
|
58
|
+
const state = (0, repo_states_js_1.decodeRepositoryTransport)(node.bytes);
|
|
59
|
+
if (state.parentTransportVersion !== priorVersion) {
|
|
60
|
+
throw new Error('repository Apply transport chain is discontinuous');
|
|
61
|
+
}
|
|
62
|
+
assertTransportTruth(state, sha256Hex);
|
|
63
|
+
identity = (0, repo_states_js_1.applyRepositoryIdentity)(identity, state, sha256Hex);
|
|
64
|
+
transports.push(state);
|
|
65
|
+
priorVersion = node.transportVersion;
|
|
66
|
+
}
|
|
67
|
+
const latest = transports.at(-1);
|
|
68
|
+
if (priorVersion !== plan.transportVersion
|
|
69
|
+
|| latest.parentTransportVersion !== plan.parentTransportVersion
|
|
70
|
+
|| latest.stateId !== plan.stateId
|
|
71
|
+
|| latest.cardId !== plan.cardId
|
|
72
|
+
|| latest.checkpointId !== plan.checkpointId) {
|
|
73
|
+
throw new Error('repository Apply chain does not produce its accepted complete result');
|
|
74
|
+
}
|
|
75
|
+
const missingUntracked = latest.checkpoint.untracked.find((file) => file.content === null);
|
|
76
|
+
if (missingUntracked) {
|
|
77
|
+
throw new Error(`repository Apply Checkpoint omitted untracked content for ${missingUntracked.path}`);
|
|
78
|
+
}
|
|
79
|
+
return Object.freeze({
|
|
80
|
+
transports: Object.freeze(transports),
|
|
81
|
+
latest,
|
|
82
|
+
transportVersion: priorVersion,
|
|
83
|
+
identity: Object.freeze([...identity]),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=repository-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository-result.js","sourceRoot":"","sources":["../../src/apply/repository-result.ts"],"names":[],"mappings":";AAAA,+EAA+E;;AAwE/E,0DA4CC;AAlHD,+DAQoC;AAqBpC,MAAM,sBAAsB,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;OACpE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;OACrB,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;OACpB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC;AAEnF,SAAS,oBAAoB,CAAC,KAA0B,EAAE,SAAoB;IAC5E,MAAM,MAAM,GAAG,IAAA,6BAAY,EAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACnD,MAAM,YAAY,GAAG,IAAA,mCAAkB,EAAC,KAAK,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IACrE,MAAM,OAAO,GAAG,IAAA,8BAAa,EAAC,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IAC/D,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,IAAI,KAAK,CAAC,YAAY,KAAK,YAAY,IAAI,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U,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC;IACvC,CAAC;IACD,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAwB,CAAC;IACxD,IAAI,YAAY,KAAK,IAAI,CAAC,gBAAgB;WACrC,MAAM,CAAC,sBAAsB,KAAK,IAAI,CAAC,sBAAsB;WAC7D,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO;WAC/B,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;WAC7B,MAAM,CAAC,YAAY,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;IAC1F,CAAC;IACD,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;IAC3F,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,6DAA6D,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;IACxG,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;QACrC,MAAM;QACN,gBAAgB,EAAE,YAAY;QAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAI,QAAyC,CAAC,CAAC;KACzE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Gap-free per-entity Apply selection and complete-result coalescing. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.selectEntityApply = selectEntityApply;
|
|
5
|
+
const cloud_js_1 = require("../entities/cloud.js");
|
|
6
|
+
const contracts_js_1 = require("../records/contracts.js");
|
|
7
|
+
const contracts_js_2 = require("./contracts.js");
|
|
8
|
+
/**
|
|
9
|
+
* Select the exact target named by a recovering intent, otherwise the newest
|
|
10
|
+
* contiguous complete result. The host may reveal only this target; every
|
|
11
|
+
* earlier selected row becomes resolved after target Verify succeeds.
|
|
12
|
+
*/
|
|
13
|
+
function selectEntityApply(work) {
|
|
14
|
+
if (!work.authorityId || !work.entityId
|
|
15
|
+
|| !Number.isSafeInteger(work.resolvedThrough) || work.resolvedThrough < 0
|
|
16
|
+
|| work.records.length === 0) {
|
|
17
|
+
throw new Error('entity Apply work is invalid');
|
|
18
|
+
}
|
|
19
|
+
let expected = work.resolvedThrough + 1;
|
|
20
|
+
for (const record of work.records) {
|
|
21
|
+
const checked = (0, contracts_js_1.checkAcceptedEntityRecord)(record);
|
|
22
|
+
if (!checked.ok)
|
|
23
|
+
throw new Error(checked.error);
|
|
24
|
+
if (record.authorityId !== work.authorityId || record.entityId !== work.entityId) {
|
|
25
|
+
throw new Error('one entity Apply batch cannot cross authority or UUID channels');
|
|
26
|
+
}
|
|
27
|
+
if (record.globalSequence !== expected) {
|
|
28
|
+
throw new Error(`entity Apply work has a gap before sequence ${record.globalSequence}`);
|
|
29
|
+
}
|
|
30
|
+
expected += 1;
|
|
31
|
+
}
|
|
32
|
+
if (work.materialized !== null) {
|
|
33
|
+
const current = (0, cloud_js_1.assertRecord)(work.materialized.record);
|
|
34
|
+
if (current.uuid !== work.entityId
|
|
35
|
+
|| !Number.isSafeInteger(work.materialized.globalSequence)
|
|
36
|
+
|| work.materialized.globalSequence < 1
|
|
37
|
+
|| work.materialized.globalSequence > work.resolvedThrough) {
|
|
38
|
+
throw new Error('entity Apply materialization proof is invalid');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
let through = work.records.at(-1).globalSequence;
|
|
42
|
+
if (work.intent !== null) {
|
|
43
|
+
(0, contracts_js_2.assertApplyIntent)(work.intent);
|
|
44
|
+
if (work.intent.authorityId !== work.authorityId
|
|
45
|
+
|| work.intent.entityId !== work.entityId
|
|
46
|
+
|| work.intent.fromSequence !== work.resolvedThrough) {
|
|
47
|
+
throw new Error('entity Apply intent does not own this work range');
|
|
48
|
+
}
|
|
49
|
+
through = work.intent.throughSequence;
|
|
50
|
+
}
|
|
51
|
+
const index = through - work.resolvedThrough - 1;
|
|
52
|
+
const target = work.records[index];
|
|
53
|
+
if (!target)
|
|
54
|
+
throw new Error('entity Apply intent target is absent from Inbox work');
|
|
55
|
+
if (work.intent !== null
|
|
56
|
+
&& (target.mutationId !== work.intent.targetMutationId
|
|
57
|
+
|| target.resultState !== work.intent.targetState
|
|
58
|
+
|| target.change.result.type !== work.intent.targetType)) {
|
|
59
|
+
throw new Error('entity Apply intent target does not match its retained Inbox record');
|
|
60
|
+
}
|
|
61
|
+
return Object.freeze({
|
|
62
|
+
records: Object.freeze(work.records.slice(0, index + 1)),
|
|
63
|
+
target,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../../src/apply/selection.ts"],"names":[],"mappings":";AAAA,0EAA0E;;AAgB1E,8CAmDC;AAjED,mDAAoD;AACpD,0DAA+F;AAC/F,iDAAyE;AAOzE;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,IAAqB;IACrD,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,QAAQ;WAClC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC;WACvE,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,QAAQ,GAAG,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;IACxC,KAAK,MAAM,MAAM,IAAI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AI,IAAI,CAAC,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW;eAC3C,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ;eACtC,IAAI,CAAC,MAAM,CAAC,YAAY,KAAK,IAAI,CAAC,eAAe,EAAE,CAAC;YACvD,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;IACxC,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IACrF,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI;WACnB,CAAC,MAAM,CAAC,UAAU,KAAK,IAAI,CAAC,MAAM,CAAC,gBAAgB;eACjD,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC,MAAM,CAAC,WAAW;eAC9C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QACxD,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Bridge the canonical entity type registry to the Apply/Verify coordinator. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.entityApplyEffects = entityApplyEffects;
|
|
5
|
+
exports.buildEntityApplyEffects = buildEntityApplyEffects;
|
|
6
|
+
const adapter_contract_js_1 = require("../detection/adapter-contract.js");
|
|
7
|
+
const types_js_1 = require("../entities/types.js");
|
|
8
|
+
/**
|
|
9
|
+
* Adapt the already-convicted one-type/one-adapter registry for Apply. The
|
|
10
|
+
* subsystem refuses partial support: every type selected at runtime must bind
|
|
11
|
+
* both complete sockets, never a generic fallback or a path-based guess.
|
|
12
|
+
*/
|
|
13
|
+
function entityApplyEffects(byType, captureLocal) {
|
|
14
|
+
const operational = new Map();
|
|
15
|
+
for (const [type, descriptor] of byType) {
|
|
16
|
+
if (!(0, types_js_1.isEntityType)(type)) {
|
|
17
|
+
throw new Error(`Apply adapter registry contains unknown entity type ${JSON.stringify(type)}`);
|
|
18
|
+
}
|
|
19
|
+
const { apply, verify } = descriptor.rails;
|
|
20
|
+
if (!apply || !verify) {
|
|
21
|
+
throw new Error(`adapter ${descriptor.name} cannot Apply ${type} until both Apply and Verify sockets are bound`);
|
|
22
|
+
}
|
|
23
|
+
operational.set(type, Object.freeze({ name: descriptor.name, apply, verify }));
|
|
24
|
+
}
|
|
25
|
+
return Object.freeze({
|
|
26
|
+
adapterFor(type) {
|
|
27
|
+
const adapter = operational.get(type);
|
|
28
|
+
if (!adapter)
|
|
29
|
+
throw new Error(`entity type ${type} has no operational Apply adapter`);
|
|
30
|
+
return adapter;
|
|
31
|
+
},
|
|
32
|
+
captureLocal(intent, plan, position) {
|
|
33
|
+
return captureLocal(intent, plan, position);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** Build the universal physical-type registry, refusing any missing type. */
|
|
38
|
+
function buildEntityApplyEffects(adapters, captureLocal) {
|
|
39
|
+
return entityApplyEffects((0, adapter_contract_js_1.buildTypeMap)(adapters, types_js_1.ENTITY_TYPES), captureLocal);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=type-adapters.js.map
|
|
@@ -0,0 +1 @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AM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC9C,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,6EAA6E;AAC7E,SAAgB,uBAAuB,CACrC,QAA2B,EAC3B,YAAgC;IAEhC,OAAO,kBAAkB,CAAC,IAAA,kCAAY,EAAC,QAAQ,EAAE,uBAAY,CAAC,EAAE,YAAY,CAAC,CAAC;AAChF,CAAC"}
|
|
@@ -44,15 +44,15 @@ exports.RAILS = Object.freeze([
|
|
|
44
44
|
/**
|
|
45
45
|
* The ratified sockets — for each rail that has one, the exact surfaces
|
|
46
46
|
* every binding adapter implements. Same names, same shapes, every
|
|
47
|
-
* type.
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* verify join only when the Send/Receive rails exist to derive their
|
|
51
|
-
* socket from. A socket is ratified from a real consumer or it is not
|
|
47
|
+
* type. Detect, Apply, and Verify are ratified from their real portable
|
|
48
|
+
* consumers. Watch, Record, Send, and Receive need no type-specific surface
|
|
49
|
+
* at this bar. A socket is ratified from a real consumer or it is not
|
|
52
50
|
* ratified at all.
|
|
53
51
|
*/
|
|
54
52
|
exports.SOCKETS = Object.freeze({
|
|
55
53
|
detect: Object.freeze(['truth']),
|
|
54
|
+
apply: Object.freeze(['prepare', 'guard', 'reveal', 'discard']),
|
|
55
|
+
verify: Object.freeze(['verify']),
|
|
56
56
|
});
|
|
57
57
|
/**
|
|
58
58
|
* Convict a malformed adapter descriptor loudly; return it (typed)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-contract.js","sourceRoot":"","sources":["../../src/detection/adapter-contract.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;
|
|
1
|
+
{"version":3,"file":"adapter-contract.js","sourceRoot":"","sources":["../../src/detection/adapter-contract.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;AA0EH,sCA6CC;AAQD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pC,QAAA,UAAU,cAK0B;AAEjD;;;;;;;;;;GAUG;AACU,QAAA,gBAAgB,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC/D,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,4FAA4F;KACxG,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;CACzB,CAAC,CAAC"}
|
|
@@ -16,7 +16,14 @@ function echoDecision(notebook, observed) {
|
|
|
16
16
|
: { kind: 'retry', reason: observed.reason };
|
|
17
17
|
}
|
|
18
18
|
if (notebook.status === 'active') {
|
|
19
|
-
|
|
19
|
+
const exactTransport = notebook.transportVersion === null
|
|
20
|
+
? observed.truth === 'present'
|
|
21
|
+
&& (observed.transportVersion === undefined || observed.transportVersion === null)
|
|
22
|
+
: observed.truth === 'present'
|
|
23
|
+
&& observed.transportVersion === notebook.transportVersion;
|
|
24
|
+
return observed.truth === 'present'
|
|
25
|
+
&& observed.version === notebook.version
|
|
26
|
+
&& exactTransport
|
|
20
27
|
? { kind: 'silence' }
|
|
21
28
|
: { kind: 'detect' };
|
|
22
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"echo.js","sourceRoot":"","sources":["../../src/detection/echo.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAUH,
|
|
1
|
+
{"version":3,"file":"echo.js","sourceRoot":"","sources":["../../src/detection/echo.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAUH,oCAsBC;AAtBD,SAAgB,YAAY,CAC1B,QAA4E,EAC5E,QAAsB;IAEtB,IAAI,QAAQ,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;QACnC,OAAO,QAAQ,CAAC,MAAM,KAAK,SAAS;YAClC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;YACnB,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CA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