@trillboards/edge-sdk 0.2.265 → 0.2.273

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.
Files changed (102) hide show
  1. package/deploy/detector/pyproject.toml +1 -1
  2. package/deploy/detector/tests/test_loader.py +1 -1
  3. package/deploy/detector/tests/test_staff_uniform.py +342 -0
  4. package/deploy/detector/trillboards_detector/_version.py +2 -2
  5. package/deploy/detector/trillboards_detector/loader.py +6 -0
  6. package/deploy/detector/trillboards_detector/registry.py +30 -1
  7. package/deploy/detector/trillboards_detector/server.py +43 -0
  8. package/deploy/detector/trillboards_detector/staff_uniform.py +190 -0
  9. package/deploy/detector/trillboards_detector/tasks.py +9 -1
  10. package/deploy/windows/build-windows.ps1 +3 -0
  11. package/deploy/windows/ci/test-published-install.ps1 +1 -1
  12. package/deploy/windows/e2e/test-recorder-family.ps1 +1 -1
  13. package/deploy/windows/process-priority.ps1 +229 -0
  14. package/dist/ActorPerception.d.ts.map +1 -1
  15. package/dist/ActorPerception.js +3 -1
  16. package/dist/ActorPerception.js.map +1 -1
  17. package/dist/AudienceAnalyzeClient.d.ts +28 -0
  18. package/dist/AudienceAnalyzeClient.d.ts.map +1 -1
  19. package/dist/AudienceAnalyzeClient.js +89 -15
  20. package/dist/AudienceAnalyzeClient.js.map +1 -1
  21. package/dist/CctvLiveViewCoordinator.d.ts +23 -2
  22. package/dist/CctvLiveViewCoordinator.d.ts.map +1 -1
  23. package/dist/CctvLiveViewCoordinator.js +50 -0
  24. package/dist/CctvLiveViewCoordinator.js.map +1 -1
  25. package/dist/ConnectorStatusClient.d.ts +8 -0
  26. package/dist/ConnectorStatusClient.d.ts.map +1 -1
  27. package/dist/ConnectorStatusClient.js +3 -0
  28. package/dist/ConnectorStatusClient.js.map +1 -1
  29. package/dist/DetectorFields.d.ts +113 -6
  30. package/dist/DetectorFields.d.ts.map +1 -1
  31. package/dist/DetectorFields.js +163 -42
  32. package/dist/DetectorFields.js.map +1 -1
  33. package/dist/EdgeAgent.js +1 -1
  34. package/dist/LocalDetectorClient.d.ts +21 -0
  35. package/dist/LocalDetectorClient.d.ts.map +1 -1
  36. package/dist/LocalDetectorClient.js +43 -0
  37. package/dist/LocalDetectorClient.js.map +1 -1
  38. package/dist/NativeReadiness.d.ts.map +1 -1
  39. package/dist/NativeReadiness.js +8 -3
  40. package/dist/NativeReadiness.js.map +1 -1
  41. package/dist/QueueDwell.d.ts +87 -0
  42. package/dist/QueueDwell.d.ts.map +1 -0
  43. package/dist/QueueDwell.js +167 -0
  44. package/dist/QueueDwell.js.map +1 -0
  45. package/dist/ScopedVlmReview.d.ts +11 -1
  46. package/dist/ScopedVlmReview.d.ts.map +1 -1
  47. package/dist/ScopedVlmReview.js +50 -7
  48. package/dist/ScopedVlmReview.js.map +1 -1
  49. package/dist/SensingProfileClient.d.ts +7 -0
  50. package/dist/SensingProfileClient.d.ts.map +1 -1
  51. package/dist/SensingProfileClient.js +1 -0
  52. package/dist/SensingProfileClient.js.map +1 -1
  53. package/dist/config.d.ts +8 -0
  54. package/dist/config.d.ts.map +1 -1
  55. package/dist/config.js.map +1 -1
  56. package/dist/connectorUpdate.d.ts +6 -0
  57. package/dist/connectorUpdate.d.ts.map +1 -1
  58. package/dist/connectorUpdate.js +8 -1
  59. package/dist/connectorUpdate.js.map +1 -1
  60. package/dist/diagnose.d.ts +1 -1
  61. package/dist/diagnose.js +1 -1
  62. package/dist/enterpriseNetwork.d.ts +9 -0
  63. package/dist/enterpriseNetwork.d.ts.map +1 -1
  64. package/dist/enterpriseNetwork.js +14 -0
  65. package/dist/enterpriseNetwork.js.map +1 -1
  66. package/dist/index.d.ts +1 -1
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/localSensing.d.ts +45 -1
  69. package/dist/localSensing.d.ts.map +1 -1
  70. package/dist/localSensing.js +82 -8
  71. package/dist/localSensing.js.map +1 -1
  72. package/dist/mainThreadStall.d.ts +11 -0
  73. package/dist/mainThreadStall.d.ts.map +1 -1
  74. package/dist/mainThreadStall.js +35 -0
  75. package/dist/mainThreadStall.js.map +1 -1
  76. package/dist/pipelineSwitches.d.ts +82 -1
  77. package/dist/pipelineSwitches.d.ts.map +1 -1
  78. package/dist/pipelineSwitches.js +109 -15
  79. package/dist/pipelineSwitches.js.map +1 -1
  80. package/dist/processPriority.d.ts +75 -0
  81. package/dist/processPriority.d.ts.map +1 -0
  82. package/dist/processPriority.js +380 -0
  83. package/dist/processPriority.js.map +1 -0
  84. package/dist/sensingRunMode.d.ts.map +1 -1
  85. package/dist/sensingRunMode.js +22 -3
  86. package/dist/sensingRunMode.js.map +1 -1
  87. package/dist/vehicleEndWarmup.d.ts +60 -0
  88. package/dist/vehicleEndWarmup.d.ts.map +1 -0
  89. package/dist/vehicleEndWarmup.js +209 -0
  90. package/dist/vehicleEndWarmup.js.map +1 -0
  91. package/dist/windowsLiveView.d.ts +3 -1
  92. package/dist/windowsLiveView.d.ts.map +1 -1
  93. package/dist/windowsLiveView.js +2 -0
  94. package/dist/windowsLiveView.js.map +1 -1
  95. package/package.json +4 -4
  96. package/retained/RetainedCaptureClient.cjs +28 -3
  97. package/retained/__tests__/archive-lifecycle.test.cjs +44 -0
  98. package/retained/__tests__/paired-theft-manager.test.cjs +24 -0
  99. package/retained/__tests__/queue-dwell.test.cjs +238 -0
  100. package/retained/__tests__/runtime.test.cjs +3 -0
  101. package/retained/__tests__/support/theft-builder.cjs +3 -1
  102. package/retained/manager.cjs +20 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.policySha256 = exports.DETECTOR_FIELD_METHODS = exports.BUILDING_SIDES = exports.VEHICLE_END_PREPROCESSING = exports.UNIFORM_COLOURS = void 0;
3
+ exports.policySha256 = exports.DETECTOR_FIELD_METHODS = exports.BUILDING_SIDES = exports.VEHICLE_END_PREPROCESSING = exports.STAFF_UNIFORM = exports.STAFF_UNIFORM_PREPROCESSING = exports.UNIFORM_COLOURS = void 0;
4
4
  exports.uniformColourRequest = uniformColourRequest;
5
5
  exports.validStaffBand = validStaffBand;
6
6
  exports.parseDetectorFields = parseDetectorFields;
@@ -11,6 +11,7 @@ exports.decideUniformColourAbsence = decideUniformColourAbsence;
11
11
  exports.onScreen = onScreen;
12
12
  exports.readUniformSceneMemory = readUniformSceneMemory;
13
13
  exports.decideUniformColourAbsenceV2 = decideUniformColourAbsenceV2;
14
+ exports.uniformStudentAsks = uniformStudentAsks;
14
15
  exports.decideUniformColourAbsenceV4 = decideUniformColourAbsenceV4;
15
16
  exports.decideDetectedLabels = decideDetectedLabels;
16
17
  exports.planVehicleGate = planVehicleGate;
@@ -74,6 +75,12 @@ const UNIFORM_COLOUR_BANDS = {
74
75
  pink: { hue: [[0, 10], [221, 255]], minSaturation: 40, maxSaturation: 180, minValue: 150, maxValue: 255 },
75
76
  };
76
77
  exports.UNIFORM_COLOURS = Object.freeze(Object.keys(UNIFORM_COLOUR_BANDS));
78
+ /** The detector service's `staff_uniform.PREPROCESSING`: the client refuses an answer made any other way. */
79
+ exports.STAFF_UNIFORM_PREPROCESSING = 'pil-rgb-box-plus-10pct-clip-floor-jpeg92-letterbox-96x192-bilinear-fill-7c7468-imagenet-v1';
80
+ /** The uniform student m2 (detector staff_uniform.py): P(staff) of one person's crop. */
81
+ exports.STAFF_UNIFORM = { modelId: 'staff_uniform_student_m2', format: 'onnx',
82
+ sha256: 'bbbb24b90e5201dcb3317f4a0947320bd658e59ed14afe379a9cf9576621d13f' };
83
+ const torsoMethod = (f) => f.method === 'uniform_colour_absence_v4' || f.method === 'uniform_colour_absence_v5';
77
84
  function uniformColourRequest(colour, minScore, maxBoxes) {
78
85
  const band = UNIFORM_COLOUR_BANDS[colour];
79
86
  return { version: 2, minScore, maxBoxes,
@@ -95,6 +102,9 @@ const UNIFORM_COLOUR_SCENE = {
95
102
  screenMemory: { minSightings: 3, sameIou: 0.5, memoryMs: 86400000, maxScreens: 64 },
96
103
  fixtures: { minConfidence: 0.05, sameIou: 0.5, gapMs: 120000, holdMs: 600000, maxConfidence: 0.6, expireMs: 86400000, maxTracks: 512 },
97
104
  };
105
+ const UNIFORM_COLOUR_TORSO = { ...UNIFORM_COLOUR_SCENE, uniform: { colour: '*', band: '*' },
106
+ staff: { torsoFraction: 0.6, upperFraction: 0.1, boxFraction: 0.08, minTorsoPixels: 8, poseMinScore: 0.25, maxPosed: 8 },
107
+ identity: { sameIou: 0.3, footWidths: 1, footHeights: 0.5, gapMs: 15000, maxTracks: 64 } };
98
108
  const PINNED = {
99
109
  unattended_customer_v1: { minPersonConfidence: 0.25, screenLabels: ['laptop', 'tv'], screenContainment: 0.8, maxPeople: 32,
100
110
  uniform: { hue: [[0, 10], [240, 255]], minSaturation: 100, minValue: 60, staffFraction: 0.08 } },
@@ -104,9 +114,8 @@ const PINNED = {
104
114
  uniform: { colour: '*', staffFraction: 0.08 } },
105
115
  uniform_colour_absence_v2: UNIFORM_COLOUR_SCENE,
106
116
  uniform_colour_absence_v3: { ...UNIFORM_COLOUR_SCENE, staffRegion: '*' },
107
- uniform_colour_absence_v4: { ...UNIFORM_COLOUR_SCENE, uniform: { colour: '*', band: '*' },
108
- staff: { torsoFraction: 0.6, upperFraction: 0.1, boxFraction: 0.08, minTorsoPixels: 8, poseMinScore: 0.25, maxPosed: 8 },
109
- identity: { sameIou: 0.3, footWidths: 1, footHeights: 0.5, gapMs: 15000, maxTracks: 64 } },
117
+ uniform_colour_absence_v4: UNIFORM_COLOUR_TORSO,
118
+ uniform_colour_absence_v5: { ...UNIFORM_COLOUR_TORSO, student: { model: exports.STAFF_UNIFORM, vetoBelow: 0.3 } },
110
119
  detected_labels_v1: { minConfidence: 0.5 },
111
120
  vehicle_arrival_gate_v1: { vehicleLabels: ['bus', 'car', 'motorcycle', 'truck'], minConfidence: 0.5, minArea: 0.04,
112
121
  sameVehicleIou: 0.6, stationaryIou: 0.8, minStationaryMs: 10000, maxGapMs: 120000 },
@@ -138,7 +147,7 @@ const perCamera = (method, rest) => {
138
147
  return { ...rest, uniform: null };
139
148
  rest = { ...rest, uniform: { ...u, colour: '*' } };
140
149
  }
141
- if (method === 'uniform_colour_absence_v4') {
150
+ if (method === 'uniform_colour_absence_v4' || method === 'uniform_colour_absence_v5') {
142
151
  const u = rest.uniform;
143
152
  if (!keys(u, 'band,colour') || !exports.UNIFORM_COLOURS.includes(u.colour) || !validStaffBand(u.band))
144
153
  return { ...rest, uniform: null };
@@ -202,23 +211,23 @@ function detectorFieldsRequest(policy) {
202
211
  const all = p.fields.some(f => f.method === 'detected_labels_v1');
203
212
  const personMethod = (f) => f.method === 'unattended_customer_v1'
204
213
  || f.method === 'unattended_customer_v2' || f.method === 'uniform_colour_absence_v1'
205
- || f.method === 'uniform_colour_absence_v2' || f.method === 'uniform_colour_absence_v3' || f.method === 'uniform_colour_absence_v4';
214
+ || f.method === 'uniform_colour_absence_v2' || f.method === 'uniform_colour_absence_v3' || torsoMethod(f);
206
215
  const classes = all ? [] : [...new Set(p.fields.flatMap(f => personMethod(f)
207
216
  ? ['person', ...f.screenLabels] : f.method === 'vehicle_arrival_gate_v1' || f.method === 'vehicle_orientation_gate_v1'
208
217
  || f.method === 'vehicle_orientation_gate_v2' ? f.vehicleLabels : f.method === 'floor_object_left_v1' ? ['person'] : []))].sort();
209
- const colourRequests = p.fields.filter(personMethod).map(f => f.method === 'uniform_colour_absence_v4' ? staffBandRequest(f.uniform.band, f.minPersonConfidence, f.maxPeople)
218
+ const colourRequests = p.fields.filter(personMethod).map(f => torsoMethod(f) ? staffBandRequest(f.uniform.band, f.minPersonConfidence, f.maxPeople)
210
219
  : f.method !== 'unattended_customer_v1' && f.method !== 'unattended_customer_v2'
211
220
  ? uniformColourRequest(f.uniform.colour, f.minPersonConfidence, f.maxPeople) : { version: 1, minScore: f.minPersonConfidence, maxBoxes: f.maxPeople,
212
221
  hue: f.uniform.hue.map(r => [r[0], r[1]]),
213
222
  minSaturation: f.uniform.minSaturation, minValue: f.uniform.minValue });
214
223
  if (colourRequests.some(request => !(0, util_1.isDeepStrictEqual)(request, colourRequests[0])))
215
224
  throw Error('Detector fields require one shared colour specification');
216
- // v4 measures each person's torso on the pose of THIS frame's confident people (the held-phone rule's request).
217
- const torso = p.fields.find((f) => f.method === 'uniform_colour_absence_v4');
225
+ // v4 and v5 measure each person's torso on the pose of THIS frame's confident people (the held-phone rule's request).
226
+ const torso = p.fields.find(torsoMethod);
218
227
  // v2's fixtures are seen below the person bar; every rule still applies its own bar to what it counts. The face
219
228
  // watchlist reads no detection of the look (its faces are the face lane's), so it sets no bar.
220
229
  const bars = p.fields.filter(f => f.method !== FaceWatchPolicy_1.WATCHLIST_METHOD).map(f => f.method === 'uniform_colour_absence_v2'
221
- || f.method === 'uniform_colour_absence_v3' || f.method === 'uniform_colour_absence_v4'
230
+ || f.method === 'uniform_colour_absence_v3' || torsoMethod(f)
222
231
  ? Math.min(f.minPersonConfidence, f.fixtures.minConfidence) : personMethod(f) || f.method === 'floor_object_left_v1'
223
232
  ? f.minPersonConfidence : f.minConfidence);
224
233
  return { classes, minConfidence: bars.length ? Math.min(...bars) : 0.5,
@@ -443,23 +452,21 @@ function decideUniformColourAbsenceV2(input) {
443
452
  ...(staffRegion ? { staffAreaPeople } : {}) } };
444
453
  }
445
454
  /**
446
- * uniform_colour_absence_v4 on one look: a customer in the area and no staff member in it, where staff is the
447
- * camera's own band on the torso (>= torsoFraction of at least minTorsoPixels), else on the upper body
448
- * (>= upperFraction), else on the whole box (>= boxFraction), or a person whose box continues one that was staff
449
- * on an earlier look (identity). Screens and fixtures as v2. The answer is decided from the memory as it stood
450
- * BEFORE this look; only a look captured after the memory's last one teaches it. Pure.
455
+ * The colour rule's read of each counted person of one v4/v5 look, before identity: the screens' pictures taken out,
456
+ * `direct` staff by any bar, `seeds` staff by the torso bar (the evidence identity remembers). Shared by the decision
457
+ * and by uniformStudentAsks, so the student is asked about exactly the reads the decision weighs. Validates the inputs.
451
458
  */
452
- function decideUniformColourAbsenceV4(input) {
459
+ function uniformColourReads(input) {
453
460
  const p = parseDetectorFields(input.policy);
454
461
  const m = p.fields.find(f => f.field === input.method.field);
455
- if (m?.method !== 'uniform_colour_absence_v4' || !(0, util_1.isDeepStrictEqual)(m, input.method))
462
+ if (!m || m.method !== input.method.method || !torsoMethod(m) || !(0, util_1.isDeepStrictEqual)(m, input.method))
456
463
  throw Error('Invalid uniform colour method binding');
457
464
  const { width, height } = input.frame, t = input.capturedAtMs;
458
465
  if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width <= 1 || height <= 1)
459
466
  throw Error('Uniform colour absence needs a valid original frame');
460
467
  if (!Number.isSafeInteger(t) || t < 0)
461
468
  throw Error('Uniform colour absence needs the capture time');
462
- const region = uniformRegion(input.region);
469
+ const region = input.region === undefined ? undefined : uniformRegion(input.region);
463
470
  const people = input.detections.map((d, index) => ({ d, index }))
464
471
  .filter(({ d }) => d.label === 'person' && d.confidence >= m.minPersonConfidence);
465
472
  if (people.length > m.maxPeople)
@@ -474,14 +481,11 @@ function decideUniformColourAbsenceV4(input) {
474
481
  throw Error('A person has no measured staff colour');
475
482
  }
476
483
  const prior = readUniformSceneMemory(input.memory);
477
- const S = m.screenMemory, F = m.fixtures, I = m.identity, B = m.staff;
484
+ const S = m.screenMemory, B = m.staff;
478
485
  const seen = input.detections.filter(d => m.screenLabels.includes(d.label)
479
486
  && d.confidence >= m.minPersonConfidence).map(d => d.box);
480
487
  const remembered = prior.screens.filter(s => s.sightings >= S.minSightings && t - s.lastSeenAtMs <= S.memoryMs).map(s => s.box);
481
- const fixtures = prior.tracks.filter(tr => tr.fixture && t - tr.lastSeenAtMs <= F.expireMs).map(tr => tr.box);
482
- const pictures = [], rememberedPictures = [], outside = [], still = [];
483
- const matching = [], nonMatching = [];
484
- const evidence = [];
488
+ const pictures = [], rememberedPictures = [];
485
489
  // Colour first: who is staff on THIS look. Only the torso (the garment itself) is evidence strong enough to
486
490
  // remember: a customer in a red plaid shirt crosses the upper-body and box bars on some looks (camera 23,
487
491
  // Nov 11 00:03Z, 6 of 11 looks) but never the torso bar (0 of 60 customer looks; highest 0.54).
@@ -503,6 +507,64 @@ function decideUniformColourAbsenceV4(input) {
503
507
  direct.set(index, torso || row.upper >= B.upperFraction || box >= B.boxFraction);
504
508
  live.push({ d, index });
505
509
  }
510
+ return { p, m, t, width, height, region, people, fractions, measured, prior, seen, remembered, pictures, rememberedPictures, direct, seeds,
511
+ live };
512
+ }
513
+ /**
514
+ * uniform_colour_absence_v5: the people the student is asked about on this look, in detection order: every counted
515
+ * person (not a picture on a screen) the colour rule reads as staff by any bar. The decision requires an answer for
516
+ * exactly these. Pure.
517
+ */
518
+ function uniformStudentAsks(input) {
519
+ if (input.method?.method !== 'uniform_colour_absence_v5')
520
+ throw Error('Invalid uniform colour method binding');
521
+ const r = uniformColourReads(input);
522
+ return r.live.filter(l => r.direct.get(l.index)).map(l => ({ detectionIndex: l.index, box: { ...l.d.box } }));
523
+ }
524
+ /**
525
+ * uniform_colour_absence_v4 on one look: a customer in the area and no staff member in it, where staff is the
526
+ * camera's own band on the torso (>= torsoFraction of at least minTorsoPixels), else on the upper body
527
+ * (>= upperFraction), else on the whole box (>= boxFraction), or a person whose box continues one that was staff
528
+ * on an earlier look (identity). Screens and fixtures as v2. The answer is decided from the memory as it stood
529
+ * BEFORE this look; only a look captured after the memory's last one teaches it. Pure.
530
+ *
531
+ * uniform_colour_absence_v5 is the same decision with `student`, the uniform student's answer for exactly the people
532
+ * uniformStudentAsks names: a read below the method's vetoBelow drops that person's colour evidence of this look
533
+ * (no direct staff, no seed), so only identity from an earlier look can still make them staff. A null answer keeps
534
+ * the colour rule's read.
535
+ */
536
+ function decideUniformColourAbsenceV4(input) {
537
+ const { p, m, t, width, height, region: inArea, people, fractions, measured, prior, seen, remembered, pictures, rememberedPictures, direct, seeds, live } = uniformColourReads(input);
538
+ const region = inArea;
539
+ const F = m.fixtures, I = m.identity;
540
+ const fixtures = prior.tracks.filter(tr => tr.fixture && t - tr.lastSeenAtMs <= F.expireMs).map(tr => tr.box);
541
+ const outside = [], still = [];
542
+ const matching = [], nonMatching = [];
543
+ const evidence = [];
544
+ // v5: the student's answer for each person the colour rule reads as staff, and the reads it vetoes.
545
+ const answered = new Map(), vetoed = new Set();
546
+ if (m.method === 'uniform_colour_absence_v5') {
547
+ const asked = live.filter(l => direct.get(l.index)).map(l => l.index);
548
+ const reads = input.student;
549
+ if (!Array.isArray(reads) || reads.length !== asked.length || reads.some((a, i) => !a || a.detectionIndex !== asked[i]
550
+ || !(a.pStaff === null || Number.isFinite(a.pStaff) && a.pStaff >= 0 && a.pStaff <= 1)
551
+ || !(a.unavailable === undefined || a.unavailable === true && a.pStaff === null)))
552
+ throw Error('The staff reads have no uniform student answer');
553
+ for (const a of reads) {
554
+ answered.set(a.detectionIndex, a.pStaff);
555
+ if (a.pStaff !== null && a.pStaff < m.student.vetoBelow) {
556
+ vetoed.add(a.detectionIndex);
557
+ direct.set(a.detectionIndex, false);
558
+ seeds.set(a.detectionIndex, false);
559
+ }
560
+ // A read the student could not check keeps this look's colour answer (as v4) but teaches identity nothing:
561
+ // seeded, the person stayed staff on every later look past the student's veto (review of #16560).
562
+ if (a.unavailable === true)
563
+ seeds.set(a.detectionIndex, false);
564
+ }
565
+ }
566
+ else if (input.student !== undefined)
567
+ throw Error('Only uniform_colour_absence_v5 reads the uniform student');
506
568
  // Identity: each person of the memory's latest looks continues at most one box of this look.
507
569
  const tracks = t > prior.lastAtMs ? (prior.people ?? []).filter(q => t - q.lastSeenAtMs <= I.gapMs) : [];
508
570
  const foot = (b) => ({ x: b.x + b.width / 2, y: b.y + b.height });
@@ -536,7 +598,8 @@ function decideUniformColourAbsenceV4(input) {
536
598
  }
537
599
  const row = measured.get(index), fraction = fractions.get(index), staff = staffNow.get(index);
538
600
  evidence.push({ index, torso: row.torso, upper: row.upper, box: fraction, staff,
539
- ...(staff && !direct.get(index) ? { remembered: true } : {}) });
601
+ ...(staff && !direct.get(index) ? { remembered: true } : {}),
602
+ ...(answered.has(index) ? { pStaff: answered.get(index) } : {}), ...(vetoed.has(index) ? { vetoed: true } : {}) });
540
603
  if (staff) {
541
604
  matching.push({ index, fraction });
542
605
  continue;
@@ -556,7 +619,7 @@ function decideUniformColourAbsenceV4(input) {
556
619
  memory = { ...scene, people: [...nowPeople, ...kept].slice(0, I.maxTracks) };
557
620
  }
558
621
  return { value: nonMatching.length > 0 && matching.length === 0, memory,
559
- trace: { method: 'uniform_colour_absence_v4', imageSha256: hash(input.jpeg), policySha256: (0, exports.policySha256)(p),
622
+ trace: { method: m.method, imageSha256: hash(input.jpeg), policySha256: (0, exports.policySha256)(p),
560
623
  colour: m.uniform.colour, people: people.length, pictures, outside, matching, nonMatching, fixtures: still, rememberedPictures,
561
624
  staffEvidence: evidence } };
562
625
  }
@@ -702,6 +765,18 @@ function planVehicleGate(input) {
702
765
  * so a box that changed under it (a door, a person, a pole) inherits its answer
703
766
  * instead of letting the answer drop and the alert fire again; only a reversed
704
767
  * answer is inherited, so a car parking where another left is looked at afresh.
768
+ * An undecided parked vehicle, and the track of a vehicle not yet stationary, stays
769
+ * while a look misses it (no vehicle over it) for 2.5 looks at the camera's own
770
+ * spacing (the interval since the previous look), at least minStationaryMs and
771
+ * at most 3 x minStationaryMs; a vehicle over it is the car moving, and a car
772
+ * decided forward keeps minStationaryMs (a car backing into the spot it left is
773
+ * looked at, not handed its answer). At a
774
+ * 10 s least look gap one missed look otherwise departed the car or restarted
775
+ * its track, and its looks started again: Texas camera 3 (the box misses a lone
776
+ * parked car on 0.5% of its looks, 96 of 19,146, Nov 17-19), its 21 arrival
777
+ * alerts of Nov 17-20 re-timed to 10 s looks: 0.21 alerts per 3 days more than
778
+ * 20 s late with the old keeps, 0.03 with these (0.27 and 0.12 over 15 s). At
779
+ * the 3-4 s spacing of a shared rotation the keep stays minStationaryMs.
705
780
  * The answer is whether any parked vehicle is reversed; an undecided one does
706
781
  * not count yet.
707
782
  */
@@ -719,10 +794,18 @@ function planVehicleOrientation(input) {
719
794
  vehicles.push({ ...d.box });
720
795
  const memory = input.memory && input.memory.version === 2 ? input.memory : undefined;
721
796
  const prior = memory && t > memory.lastAtMs && t - memory.lastAtMs <= m.maxGapMs ? memory : undefined;
797
+ const keepMs = Math.min(Math.max(m.minStationaryMs, 2.5 * (prior ? t - prior.lastAtMs : 0)), 3 * m.minStationaryMs);
798
+ // A vehicle of this frame over an unseen box (IoU >= inheritIou) is that car moving, not a look that missed it: only
799
+ // a miss earns the longer keep (the real video's car backing in left and came back to its box 22 s later).
800
+ const moved = (box) => vehicles.some(v => iou(v, box) >= o.inheritIou);
801
+ // A track seen on the previous look always carries (as before); one a look missed carries for keepMs.
802
+ const live = (prior?.tracks ?? []).filter(tr => tr.lastSeenAtMs === undefined || tr.lastSeenAtMs === prior.lastAtMs
803
+ || t - tr.lastSeenAtMs < keepMs);
722
804
  const tracks = vehicles.map(box => {
723
- const was = prior?.tracks.find(tr => iou(tr.box, box) >= m.stationaryIou);
724
- return { box, firstSeenAtMs: was ? was.firstSeenAtMs : t };
805
+ const was = live.find(tr => iou(tr.box, box) >= m.stationaryIou);
806
+ return { box, firstSeenAtMs: was ? was.firstSeenAtMs : t, lastSeenAtMs: t };
725
807
  });
808
+ const missed = live.filter(tr => !moved(tr.box)).map(tr => ({ ...tr, lastSeenAtMs: tr.lastSeenAtMs ?? prior.lastAtMs }));
726
809
  const stationary = tracks.filter(tr => t - tr.firstSeenAtMs >= m.minStationaryMs).map(tr => tr.box);
727
810
  const parked = [];
728
811
  let departures = 0;
@@ -730,12 +813,13 @@ function planVehicleOrientation(input) {
730
813
  const now = vehicles.find(v => iou(v, p.box) >= m.sameVehicleIou);
731
814
  if (now)
732
815
  parked.push({ ...p, box: now, lastSeenAtMs: t, seen: true });
733
- else if (t - p.lastSeenAtMs < (p.reversed === true ? 3 * m.minStationaryMs : m.minStationaryMs))
816
+ else if (t - p.lastSeenAtMs < (p.reversed === true ? 3 * m.minStationaryMs
817
+ : p.reversed === null && !moved(p.box) ? keepMs : m.minStationaryMs))
734
818
  parked.push({ ...p, seen: false });
735
819
  else
736
820
  departures++;
737
821
  }
738
- let arrivals = 0, inherited = 0;
822
+ let arrivals = 0, inherited = 0, created = 0;
739
823
  for (const s of stationary) {
740
824
  if (parked.some(p => p.seen && iou(p.box, s) >= m.sameVehicleIou))
741
825
  continue;
@@ -748,7 +832,7 @@ function planVehicleOrientation(input) {
748
832
  inherited++;
749
833
  }
750
834
  else
751
- parked.push({ box: { ...s }, lastSeenAtMs: t, looks: [], reversed: null, seen: true });
835
+ parked.push({ box: { ...s }, lastSeenAtMs: t, looks: [], reversed: null, seen: true, id: t * 1024 + created++ });
752
836
  }
753
837
  const due = parked.filter(p => p.seen && p.reversed === null && (p.looks.length === 0
754
838
  || p.looks.length < o.majorityOf && t - p.looks[p.looks.length - 1].atMs >= o.lookIntervalMs)).slice(0, 8);
@@ -774,7 +858,7 @@ function planVehicleOrientation(input) {
774
858
  });
775
859
  const kept = parked.map(({ seen: _seen, ...p }) => p);
776
860
  const reversedParked = kept.filter(p => p.reversed === true).length;
777
- return { value: reversedParked > 0, memory: { version: 2, lastAtMs: t, tracks, parked: kept },
861
+ return { value: reversedParked > 0, memory: { version: 2, lastAtMs: t, tracks: [...tracks, ...missed], parked: kept },
778
862
  trace: { ...base(action), decided, reversedParked } };
779
863
  } };
780
864
  }
@@ -783,7 +867,8 @@ function readVehicleAnnounceMemory(value) {
783
867
  const v = value;
784
868
  const valid = !!v && v.version === 1 && time(v.lastAtMs) && Array.isArray(v.announced) && v.announced.length <= 256
785
869
  && v.announced.every(a => !!a && boxOf(a.box) && time(a.announcedAtMs) && time(a.lastSeenAtMs) && a.announcedAtMs <= a.lastSeenAtMs
786
- && time(a.emptyMs) && a.emptyMs >= 0);
870
+ && time(a.emptyMs) && a.emptyMs >= 0 && (a.announcedBox === undefined || boxOf(a.announcedBox))
871
+ && (a.entryId === undefined || time(a.entryId)));
787
872
  return valid ? v : { version: 1, lastAtMs: -1, announced: [] };
788
873
  }
789
874
  /**
@@ -792,6 +877,17 @@ function readVehicleAnnounceMemory(value) {
792
877
  * announced less than announceMs ago. A position stays announced while a vehicle of the looks keeps overlapping it,
793
878
  * and is forgotten once looks have seen no vehicle there for clearMs: a stretch without looks (camera or connector
794
879
  * down) is not evidence the car left. A late or repeated frame decides from the memory and teaches nothing. Pure.
880
+ * A position follows its own car, the gate's parked entry it was announced for (reversedIds), wherever that entry's
881
+ * box goes, and its car is never announced again; a position whose car's entry is gone (a connector restart, the
882
+ * gate starting afresh, a memory written before positions kept their car) is taken by the first reversed car without
883
+ * a position of its own that stands where it was announced. Any other car is the same stay only where a position was
884
+ * announced, never where its car went, so a spot cannot creep along a row of cars. The gate's parked entry follows its
885
+ * car's detections and passes its answer to a box that replaced it (IoU >= inheritIou), so a fixed position let the
886
+ * entry walk out from under it:
887
+ * Texas camera 3, Nov 18 2026, a nose-in van parked in front of the backed-in pickup announced at 00:55:41Z and hid
888
+ * it, took the pickup's answer at 01:04:55Z, and backing out at 01:09:00Z was announced (IoU 0.298 with the pickup's
889
+ * box): a false alert, 1 of 22 Nov 17-20. The pickup, decided again where it was announced while the entry sat on
890
+ * the van, is the same stay.
795
891
  */
796
892
  function announceReversedVehicles(input) {
797
893
  const A = input.method.announce, t = input.capturedAtMs;
@@ -802,12 +898,14 @@ function announceReversedVehicles(input) {
802
898
  if (t <= prior.lastAtMs)
803
899
  return { value: recent(prior.announced), memory: prior,
804
900
  trace: { held: prior.announced.length, newlyAnnounced: [], cleared: 0 } };
805
- const entries = prior.announced.map(a => ({ ...a, box: { ...a.box } }));
901
+ const entries = prior.announced.map(a => ({ ...a, box: { ...a.box }, announcedBox: { ...(a.announcedBox ?? a.box) } }));
806
902
  // Look time, not the clock: an interval between two looks longer than the gate's maxGapMs (camera or connector
807
903
  // down) adds nothing, so a car still there when looks resume is seen and kept, never announced again.
808
904
  const interval = prior.lastAtMs >= 0 ? t - prior.lastAtMs : 0, counted = interval <= input.method.maxGapMs ? interval : 0;
905
+ // A vehicle where a position was announced keeps it; its own car keeps it below, wherever it went. A vehicle where
906
+ // its car was last seen does not: once that car's entry is gone, a neighbour there held a stale spot for good.
809
907
  for (const a of entries) {
810
- if (input.vehicles.some(v => iou(v, a.box) >= A.sameIou)) {
908
+ if (input.vehicles.some(v => iou(a.announcedBox, v) >= A.sameIou)) {
811
909
  a.lastSeenAtMs = t;
812
910
  a.emptyMs = 0;
813
911
  }
@@ -816,17 +914,40 @@ function announceReversedVehicles(input) {
816
914
  }
817
915
  const kept = entries.filter(a => a.emptyMs < A.clearMs);
818
916
  const cleared = entries.length - kept.length;
917
+ const id = (i) => { const v = input.reversedIds?.[i]; return time(v) ? v : undefined; };
918
+ const live = new Set(input.reversed.map((_, i) => id(i)).filter((k) => k !== undefined));
919
+ const where = (r) => (a) => iou(a.announcedBox, r) >= A.sameIou;
920
+ const owner = input.reversed.map((_, i) => { const k = id(i); return k === undefined ? undefined : kept.find(a => a.entryId === k); });
921
+ input.reversed.forEach((r, i) => {
922
+ const k = id(i);
923
+ if (k === undefined || owner[i])
924
+ return;
925
+ const a = kept.find(e => (e.entryId === undefined || !live.has(e.entryId)) && where(r)(e));
926
+ if (a) {
927
+ a.entryId = k;
928
+ owner[i] = a;
929
+ }
930
+ });
819
931
  const newly = [];
820
- for (const r of input.reversed) {
821
- const at = kept.find(a => iou(a.box, r) >= A.sameIou);
822
- if (at) {
823
- at.lastSeenAtMs = t;
824
- at.emptyMs = 0;
825
- continue;
932
+ input.reversed.forEach((r, i) => {
933
+ const own = owner[i];
934
+ if (own) {
935
+ own.box = { ...r };
936
+ own.lastSeenAtMs = t;
937
+ own.emptyMs = 0;
938
+ return;
826
939
  }
827
- kept.push({ box: { ...r }, announcedAtMs: t, lastSeenAtMs: t, emptyMs: 0 });
940
+ // Where a position was announced: the same stay, not announced (as before).
941
+ const same = kept.find(where(r));
942
+ if (same) {
943
+ same.lastSeenAtMs = t;
944
+ same.emptyMs = 0;
945
+ return;
946
+ }
947
+ const k = id(i);
948
+ kept.push({ box: { ...r }, announcedAtMs: t, lastSeenAtMs: t, emptyMs: 0, announcedBox: { ...r }, ...(k === undefined ? {} : { entryId: k }) });
828
949
  newly.push({ ...r });
829
- }
950
+ });
830
951
  const bounded = kept.map((a, i) => ({ a, i })).sort((x, y) => y.a.lastSeenAtMs - x.a.lastSeenAtMs || x.i - y.i)
831
952
  .slice(0, A.maxAnnounced).sort((x, y) => x.i - y.i).map(e => e.a);
832
953
  return { value: recent(bounded), memory: { version: 1, lastAtMs: t, announced: bounded },