@trillboards/edge-sdk 0.2.257 → 0.2.260
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/deploy/windows/ci/test-published-install.ps1 +19 -0
- package/deploy/windows/e2e/test-recorder-family.ps1 +16 -2
- package/dist/DetectorFields.d.ts +2 -1
- package/dist/DetectorFields.d.ts.map +1 -1
- package/dist/DetectorFields.js +6 -3
- package/dist/DetectorFields.js.map +1 -1
- package/dist/EdgeAgent.js +1 -1
- package/dist/FloorObjects.d.ts +342 -0
- package/dist/FloorObjects.d.ts.map +1 -0
- package/dist/FloorObjects.js +961 -0
- package/dist/FloorObjects.js.map +1 -0
- package/dist/SceneMarks.d.ts +1 -1
- package/dist/SceneMarks.d.ts.map +1 -1
- package/dist/SceneMarks.js +1 -1
- package/dist/SceneMarks.js.map +1 -1
- package/dist/ScopedVlmReview.d.ts +5 -1
- package/dist/ScopedVlmReview.d.ts.map +1 -1
- package/dist/ScopedVlmReview.js +40 -4
- package/dist/ScopedVlmReview.js.map +1 -1
- package/dist/SensingProfileClient.d.ts +20 -0
- package/dist/SensingProfileClient.d.ts.map +1 -1
- package/dist/SensingProfileClient.js +17 -1
- package/dist/SensingProfileClient.js.map +1 -1
- package/dist/UniformSceneStore.d.ts +7 -0
- package/dist/UniformSceneStore.d.ts.map +1 -1
- package/dist/UniformSceneStore.js +26 -1
- package/dist/UniformSceneStore.js.map +1 -1
- package/dist/diagnose.d.ts +1 -1
- package/dist/diagnose.js +1 -1
- package/dist/localSensing.d.ts +8 -0
- package/dist/localSensing.d.ts.map +1 -1
- package/dist/localSensing.js +14 -0
- package/dist/localSensing.js.map +1 -1
- package/package.json +2 -2
- package/retained/ProfileAuthorityClient.cjs +2 -0
- package/retained/RetainedCaptureClient.cjs +3 -1
- package/retained/WebsiteAdmissionCaptureClient.cjs +57 -4
- package/retained/__tests__/runtime.test.cjs +10 -0
- package/retained/__tests__/website-admission-realtime.test.cjs +114 -6
- package/retained/__tests__/website-admission.test.cjs +30 -0
|
@@ -313,6 +313,9 @@ test('normal website startup resolves thirteen paired cameras with two active pr
|
|
|
313
313
|
const nonceSet = new Set();
|
|
314
314
|
const cameras = Array.from({ length: 13 }, (_, i) => ({ name: 'camera-' + i, screenId: 'screen_' + i,
|
|
315
315
|
deviceToken: 'synthetic-token-' + i, rtspUrl: 'rtsp://fixture.invalid/channel-' + i }));
|
|
316
|
+
// The camera's own least gap between looks, as the server serves it (only a whole number in 2000..60000;
|
|
317
|
+
// 1999 is what a connector must refuse if it ever arrived).
|
|
318
|
+
const minLookGapMs = new Map([[cameras[0].screenId, 10000], [cameras[1].screenId, 1999]]);
|
|
316
319
|
const server = http.createServer(async(req, res) => {
|
|
317
320
|
const url = new URL(req.url, 'http://127.0.0.1'), cameraId = url.searchParams.get('screen_id');
|
|
318
321
|
if(url.pathname==='/ready'){
|
|
@@ -351,6 +354,7 @@ test('normal website startup resolves thirteen paired cameras with two active pr
|
|
|
351
354
|
}) : null;
|
|
352
355
|
res.end(JSON.stringify({ success: true, screenId: cameraId, profileState: active ? 'active' : 'inactive',
|
|
353
356
|
...(websiteReviewAdmission ? { websiteReviewAdmission } : {}),
|
|
357
|
+
...(minLookGapMs.has(cameraId) ? { minLookGapMs: minLookGapMs.get(cameraId) } : {}),
|
|
354
358
|
profileName: active ? 'Door profile' : null, profileId: active ? 'door-' + cameraId : null,
|
|
355
359
|
profileType: active ? 'custom_intent' : null, fields: active ? [field] : [], absenceWatchedFields: [],
|
|
356
360
|
retainedPilot: { version: 1, reviewFieldSet: 'declared' },
|
|
@@ -394,6 +398,10 @@ test('normal website startup resolves thirteen paired cameras with two active pr
|
|
|
394
398
|
firstContext.websiteReviewAdmission.rules[0].waitMs = 1;
|
|
395
399
|
assert.equal(runtime.clients[0].captureReviewContext().websiteReviewAdmission.rules[0].waitMs, 10000);
|
|
396
400
|
assert.equal(runtime.clients[1].captureReviewContext().websiteReviewAdmission, undefined);
|
|
401
|
+
// The profile's gap reaches the website admission through the real native and authority clients,
|
|
402
|
+
// and stays out of the captured (hashed) review context.
|
|
403
|
+
assert.deepEqual(runtime.clients.map(client => client.minLookGapMs()), [10000, ...Array(12).fill(null)]);
|
|
404
|
+
assert.equal(Object.hasOwn(firstContext, 'minLookGapMs'), false);
|
|
397
405
|
// No camera/model activity: verify the real client's profile TTL changes
|
|
398
406
|
// only while it holds the short-lived server admission hint.
|
|
399
407
|
const nativeClient = runtime.clients[0].client.client;
|
|
@@ -402,7 +410,9 @@ test('normal website startup resolves thirteen paired cameras with two active pr
|
|
|
402
410
|
Date.now = () => fetchedAt + 4999;
|
|
403
411
|
await runtime.clients[0].prepareReview(); assert.equal(profiles, 13);
|
|
404
412
|
Date.now = () => fetchedAt + 5000;
|
|
413
|
+
minLookGapMs.delete(cameras[0].screenId); // a later profile without the key: no last value is held
|
|
405
414
|
await runtime.clients[0].prepareReview(); assert.equal(profiles, 14);
|
|
415
|
+
assert.equal(runtime.clients[0].minLookGapMs(), null);
|
|
406
416
|
await runtime.clients[1].prepareReview(); assert.equal(profiles, 14);
|
|
407
417
|
} finally { Date.now = originalNow; }
|
|
408
418
|
assert.equal(opens, 0); assert.equal(models, 0);
|
|
@@ -60,10 +60,13 @@ function scene(at, moving) {
|
|
|
60
60
|
if (moving) for (let i = 0; i < 40; i++) data[(i * 13 + Math.floor(at / 100)) % data.length] = 220;
|
|
61
61
|
return { width: 32, height: 24, data };
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
// minLookGapMs: per camera, what its native client reports as the profile's minLookGapMs (any raw value).
|
|
64
|
+
// A camera not named gets today's client, which has no such method; state.gaps changes a value mid-run.
|
|
65
|
+
function rig(t, names = ['phone'], { freshnessMs = LIVE_BOUND_MS, grouping = false, liveLookIntervalMs, moving = [], onOfferStall,
|
|
66
|
+
minLookGapMs = {} } = {}) {
|
|
64
67
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'website-admission-realtime-'));
|
|
65
68
|
const groupers = new Map();
|
|
66
|
-
const state = { now: 1000, answer: true, accepted: true, receiptVersion: 1 };
|
|
69
|
+
const state = { now: 1000, answer: true, accepted: true, receiptVersion: 1, gaps: { ...minLookGapMs } };
|
|
67
70
|
const archives = new Map(), clients = new Map(), current = new Map(), server = new Map();
|
|
68
71
|
const calls = [], uploads = [];
|
|
69
72
|
t.after(() => {
|
|
@@ -96,6 +99,7 @@ function rig(t, names = ['phone'], { freshnessMs = LIVE_BOUND_MS, grouping = fal
|
|
|
96
99
|
evidenceReview: { version: state.receiptVersion, capturedAtMs: req.capturedAt } } };
|
|
97
100
|
},
|
|
98
101
|
};
|
|
102
|
+
if (Object.hasOwn(minLookGapMs, name)) client.minLookGapMs = () => state.gaps[name];
|
|
99
103
|
clients.set(name, client);
|
|
100
104
|
}
|
|
101
105
|
const archive = new WebsiteAdmissionCaptureClient(client, path.join(root, 'archive-' + name), {
|
|
@@ -404,9 +408,9 @@ test('a website wait window keeps the camera\'s live look; the server still conf
|
|
|
404
408
|
// The Texas store PC at night, 2026-11-09: five alert cameras, camera 23's drawn area changing on
|
|
405
409
|
// every frame and the other four still, on a box that finishes ~1.46 looks a second. Served one at
|
|
406
410
|
// a time here, 700 ms each on the 100 ms clock: the same throughput.
|
|
407
|
-
async function texasNight(t, liveLookIntervalMs) {
|
|
411
|
+
async function texasNight(t, liveLookIntervalMs, minLookGapMs) {
|
|
408
412
|
const names = ['c20', 'c22', 'c23', 'c24', 'c3'], LOOK_MS = 700;
|
|
409
|
-
const r = rig(t, names, { grouping: true, liveLookIntervalMs, moving: ['c23'] }); r.state.answer = false;
|
|
413
|
+
const r = rig(t, names, { grouping: true, liveLookIntervalMs, moving: ['c23'], minLookGapMs }); r.state.answer = false;
|
|
410
414
|
const looks = [];
|
|
411
415
|
let busyUntil = 0;
|
|
412
416
|
for (let at = 1000; at <= 61000; at += 100) {
|
|
@@ -426,9 +430,9 @@ async function texasNight(t, liveLookIntervalMs) {
|
|
|
426
430
|
const mine = looks.filter(look => look.name === name);
|
|
427
431
|
const gaps = mine.slice(1).map((look, i) => look.capturedAt - mine[i].capturedAt);
|
|
428
432
|
cameras[name] = { looks: mine.length, share: mine.length / looks.length, gapP50: pct(gaps, 0.5), gapP90: pct(gaps, 0.9),
|
|
429
|
-
gapMax: Math.max(...gaps), ageMax: Math.max(...mine.map(look => look.startedAt - look.capturedAt)) };
|
|
433
|
+
gapMin: Math.min(...gaps), gapMax: Math.max(...gaps), ageMax: Math.max(...mine.map(look => look.startedAt - look.capturedAt)) };
|
|
430
434
|
}
|
|
431
|
-
return { looks, cameras };
|
|
435
|
+
return { looks, cameras, r };
|
|
432
436
|
}
|
|
433
437
|
|
|
434
438
|
test('Texas shape: the still cameras starve beside the changing one without a live-look interval', async t => {
|
|
@@ -452,6 +456,110 @@ test('Texas shape: with the live-look interval every camera gets one look per ro
|
|
|
452
456
|
}
|
|
453
457
|
});
|
|
454
458
|
|
|
459
|
+
// A camera's own least gap between looks: the retained profile's minLookGapMs, which the native client
|
|
460
|
+
// reports and the website admission reads (WebsiteAdmissionCaptureClient.withinMinLookGap).
|
|
461
|
+
async function stillCamera(t, minLookGapMs = {}, { until = 30000, step } = {}) {
|
|
462
|
+
const r = rig(t, ['person'], { grouping: true, liveLookIntervalMs: 2000, minLookGapMs }); r.state.answer = false;
|
|
463
|
+
const looked = [];
|
|
464
|
+
for (let at = 1000; at <= until; at += 500) {
|
|
465
|
+
step?.(r, at);
|
|
466
|
+
r.capture('person', at, { websiteReviewAdmission: undefined });
|
|
467
|
+
if (r.pump().length) { const item = await r.review(); await r.upload(); looked.push(item.enqueuedAtMs); }
|
|
468
|
+
}
|
|
469
|
+
return { r, looked };
|
|
470
|
+
}
|
|
471
|
+
const gapsOf = looked => looked.slice(1).map((at, i) => at - looked[i]);
|
|
472
|
+
let texasToday = null; // today's client on the Texas shape, shared by the comparisons below
|
|
473
|
+
const texasBaseline = async t => (texasToday ??= await texasNight(t, 2000));
|
|
474
|
+
|
|
475
|
+
const rowAt = (r, name, at) => [...r.archives.get(name).records.values()].find(row => row.capturedAt === at);
|
|
476
|
+
|
|
477
|
+
test('min look gap: a camera with the key spaces its looks at least that far apart', async t => {
|
|
478
|
+
for (const gap of [3000, 5000, 10000]) {
|
|
479
|
+
const { r, looked } = await stillCamera(t, { person: gap });
|
|
480
|
+
const detail = gap + ' ' + JSON.stringify(looked);
|
|
481
|
+
assert(looked.length >= 3 && gapsOf(looked).every(g => g >= gap), detail);
|
|
482
|
+
// A held view stays a saved original with no answer; the archive says why it was not looked at.
|
|
483
|
+
const held = [...r.archives.get('person').records.values()].filter(row => row.disposition === 'archived_min_look_gap');
|
|
484
|
+
assert(held.length && held.every(row => row.selectionReason === 'before_min_look_gap' && !row.result && !row.selected), detail);
|
|
485
|
+
r.assertOriginal('person', held[0]); r.assertOriginal('person', held.at(-1));
|
|
486
|
+
if (gap === 5000) assert.deepEqual(looked, [1000, 6000, 11000, 16000, 21000, 26000]);
|
|
487
|
+
}
|
|
488
|
+
// The Texas shape: the changing camera (every round today) and one still camera keep their gaps;
|
|
489
|
+
// the turns they give up go to the cameras that share the rotation.
|
|
490
|
+
const today = await texasBaseline(t);
|
|
491
|
+
const { cameras } = await texasNight(t, 2000, { c23: 10000, c20: 5000 });
|
|
492
|
+
t.diagnostic(JSON.stringify(cameras));
|
|
493
|
+
assert(cameras.c23.looks >= 5 && cameras.c23.gapMin >= 10000, 'c23 ' + JSON.stringify(cameras.c23));
|
|
494
|
+
assert(cameras.c20.looks >= 10 && cameras.c20.gapMin >= 5000, 'c20 ' + JSON.stringify(cameras.c20));
|
|
495
|
+
for (const name of ['c22', 'c24', 'c3']) {
|
|
496
|
+
assert(cameras[name].looks > today.cameras[name].looks && cameras[name].gapP90 <= today.cameras[name].gapP90,
|
|
497
|
+
name + ' ' + JSON.stringify(cameras[name]));
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
test('min look gap: a camera without the key behaves exactly as today', async t => {
|
|
502
|
+
const today = await stillCamera(t); // today's native client: no minLookGapMs at all
|
|
503
|
+
assert.deepEqual(today.looked.slice(0, 7), [1000, 3000, 5000, 6000, 8000, 10000, 12000]);
|
|
504
|
+
// Absent, or a value the server never serves (only a whole number of ms in 2000..60000): the shared rotation.
|
|
505
|
+
for (const raw of [undefined, null, 1999, 60001, 2500.5, '10000', NaN, Infinity, -5000, { ms: 10000 }]) {
|
|
506
|
+
const { r, looked } = await stillCamera(t, { person: raw });
|
|
507
|
+
assert.deepEqual(looked, today.looked, String(raw));
|
|
508
|
+
assert.equal(r.archives.get('person').minLookGapMs(), null);
|
|
509
|
+
assert(![...r.archives.get('person').records.values()].some(row => row.disposition === 'archived_min_look_gap'));
|
|
510
|
+
}
|
|
511
|
+
// A later profile without the key (the server's settings read failed, or the owner cleared it): the
|
|
512
|
+
// camera is back on the shared rotation from its next decision. No last value is held.
|
|
513
|
+
const cleared = await stillCamera(t, { person: 10000 }, { step: (r, at) => { if (at === 11500) r.state.gaps.person = undefined; } });
|
|
514
|
+
// From 11000 on: the live look every 2 s and the grouper's own 10 s quiet check (16000), as today.
|
|
515
|
+
assert.deepEqual(cleared.looked, [1000, 11000, 13000, 15000, 16000, 18000, 20000, 22000, 24000, 26000, 28000, 30000]);
|
|
516
|
+
// Five cameras, none with a usable key: today's looks, frame for frame.
|
|
517
|
+
const baseline = await texasBaseline(t);
|
|
518
|
+
const keyless = await texasNight(t, 2000, { c20: undefined, c22: null, c23: 1999, c24: 60001, c3: '10000' });
|
|
519
|
+
assert.deepEqual(keyless.looks, baseline.looks);
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
test('min look gap: the value never shortens the derived cadence', async t => {
|
|
523
|
+
// The box gives each Texas camera one look per 3.5 s round. A gap at or below the round, on every
|
|
524
|
+
// camera, changes nothing, frame for frame (3500: a look exactly the gap apart is allowed).
|
|
525
|
+
const baseline = await texasBaseline(t);
|
|
526
|
+
const below = await texasNight(t, 2000, { c20: 2000, c22: 3000, c23: 3500, c24: 2500, c3: 3000 });
|
|
527
|
+
assert.deepEqual(below.looks, baseline.looks);
|
|
528
|
+
// Alone, a still camera is looked at every 2 s plus once 1 s after one (the grouper's 5 s follow-up).
|
|
529
|
+
// A gap only holds looks the derived cadence chose: never one of its own, never more of them, and
|
|
530
|
+
// never two closer together than the derived cadence or the gap would put them.
|
|
531
|
+
const today = await stillCamera(t);
|
|
532
|
+
for (const gap of [2000, 3000, 5000]) {
|
|
533
|
+
const { r, looked } = await stillCamera(t, { person: gap });
|
|
534
|
+
const detail = gap + ' ' + JSON.stringify(looked);
|
|
535
|
+
assert(looked.length < today.looked.length, detail);
|
|
536
|
+
assert(Math.min(...gapsOf(looked)) >= Math.max(gap, Math.min(...gapsOf(today.looked))), detail);
|
|
537
|
+
for (const at of looked) assert(['group_selected', 'live_look_interval'].includes(rowAt(r, 'person', at).selectionReason), detail);
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
test('min look gap: live looks inside a wait window honour it; the deadline check keeps its reserved slot', async t => {
|
|
542
|
+
const r = rig(t, ['phone'], { liveLookIntervalMs: 2000, minLookGapMs: { phone: 6000 } });
|
|
543
|
+
const first = r.capture('phone', 1000); await r.serve(); // true: the ten-second wait starts at 1000
|
|
544
|
+
const looked = [];
|
|
545
|
+
for (let at = 1500; at < 11000; at += 500) {
|
|
546
|
+
r.capture('phone', at);
|
|
547
|
+
if (r.pump().length) { const item = await r.review(); await r.upload(); looked.push(item.enqueuedAtMs); }
|
|
548
|
+
}
|
|
549
|
+
assert.deepEqual(looked, [7000], 'Today: [3000, 5000, 7000, 9000]');
|
|
550
|
+
assert.equal(rowAt(r, 'phone', 3000).disposition, 'archived_min_look_gap');
|
|
551
|
+
assert.equal(rowAt(r, 'phone', 9000).disposition, 'archived_min_look_gap');
|
|
552
|
+
// 4 s after the 7000 look, inside the gap: held, the endpoint could slip past the server's grace.
|
|
553
|
+
const due = r.capture('phone', 11000); r.pump();
|
|
554
|
+
const item = r.spool.take(undefined, 'review');
|
|
555
|
+
assert.equal(item.spoolId, due.id);
|
|
556
|
+
assert.equal(item.reviewPriority, 'urgent');
|
|
557
|
+
await r.review(item); const delivered = await r.upload();
|
|
558
|
+
assert.equal(delivered.decision.eligible, true);
|
|
559
|
+
assert.equal(delivered.decision.confirmationBasis, 'first_and_follow_up');
|
|
560
|
+
assert.equal(delivered.decision.state.anchorCapturedAtMs, first.capturedAt);
|
|
561
|
+
});
|
|
562
|
+
|
|
455
563
|
const exemptions = {
|
|
456
564
|
temporalReviewContract: { version: 1, cameraId: 'phone', field: 'phone_use', mode: 'any', minObservations: 1,
|
|
457
565
|
durationMs: 0, maxGapMs: 2000, unknownPolicy: 'reset_confirmation_keep_alert_latch' },
|
|
@@ -831,3 +831,33 @@ test('ordinary admission does not mark an expired anchor as an urgent confirmati
|
|
|
831
831
|
assert.notEqual(selected.scheduledReviewPriority,'urgent');
|
|
832
832
|
assert.equal(selected.candidate.reviewContext.websiteReviewAdmission.phoneSearch,undefined);
|
|
833
833
|
});
|
|
834
|
+
|
|
835
|
+
test('a phone search inside the camera\'s own least gap between looks is omitted; a deadline confirmation is not', async t => {
|
|
836
|
+
let now = 1000;
|
|
837
|
+
const f = fixture(t, { realtimeReview: { freshnessMs: 180000, now: () => now } });
|
|
838
|
+
f.client.minLookGapMs = () => 12000;
|
|
839
|
+
const queue = new DurableVlmCandidateSpool({ directory: path.join(f.directory, 'spool'), reviewWindowMs: 150000,
|
|
840
|
+
retentionMs: 86400000, preserveArchivedPending: true, priorityScheduling: true, maxFrames: 64, maxPerFeed: 64,
|
|
841
|
+
maxBytes: 4000000, retryInitialMs: 500, now: () => now });
|
|
842
|
+
queue.startRun(); f.archive.attachReviewQueue(queue);
|
|
843
|
+
const request = item => ({ evidenceId: item.spoolId, capturedAt: item.enqueuedAtMs, jpeg: item.jpeg,
|
|
844
|
+
reviewContext: item.reviewContext, cachedAnalysis: item.cachedAnalysis, checkpointAnalysis: saved => queue.checkpoint(item, saved) });
|
|
845
|
+
const looks = [];
|
|
846
|
+
const step = async (at, answer) => {
|
|
847
|
+
now = at; f.capture(at, phoneContext(at, { intervalMs: 500 }));
|
|
848
|
+
for (const candidate of f.archive.pendingOrderedCandidates()) assert(['buffered', 'coalesced'].includes(queue.offer(candidate, now)));
|
|
849
|
+
const item = queue.take(now, 'review'); if (!item) return;
|
|
850
|
+
f.answer(answer); await f.archive.reviewCandidate(request(item)); queue.readyForDelivery(item);
|
|
851
|
+
const saved = queue.take(now, 'delivery'); await f.archive.analyze(request(saved)); queue.complete(saved);
|
|
852
|
+
looks.push({ at: item.enqueuedAtMs, priority: item.reviewPriority ?? 'normal' });
|
|
853
|
+
};
|
|
854
|
+
await step(1000, false);
|
|
855
|
+
for (let at = 1500; at < 13000; at += 500) await step(at, false);
|
|
856
|
+
await step(13000, true); // a positive starts the ten-second wait at 13000
|
|
857
|
+
for (let at = 13500; at <= 23000; at += 500) await step(at, true);
|
|
858
|
+
assert.deepEqual(looks.map(look => look.at), [1000, 13000, 23000]);
|
|
859
|
+
assert.equal(looks[2].priority, 'urgent', 'The confirmation 10 s after its anchor keeps its slot inside the 12 s gap');
|
|
860
|
+
const held = [...f.archive.records.values()].filter(row => row.capturedAt > 1000 && row.capturedAt < 13000);
|
|
861
|
+
assert(held.length && held.every(row => row.disposition === 'archived_min_look_gap'
|
|
862
|
+
&& row.selectionReason === 'before_min_look_gap' && row.phoneAdmissionOmission?.reason === 'before_min_look_gap'));
|
|
863
|
+
});
|