@webex/plugin-meetings 3.12.0-next.133 → 3.12.0-next.135

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.
@@ -88,6 +88,7 @@ export type HashTreeParserCallbacks = {
88
88
  locusInfoUpdateCallback: LocusInfoUpdateCallback;
89
89
  syncLatencyTracker?: SyncLatencyTracker;
90
90
  generateTrackingId?: GenerateTrackingId;
91
+ isLlmExpected: () => boolean;
91
92
  };
92
93
  /**
93
94
  * This error is thrown if we receive information that the meeting has ended while we're processing some hash messages.
@@ -121,6 +122,7 @@ declare class HashTreeParser {
121
122
  private dataSetsSyncedDuringBackoff;
122
123
  private syncQueueProcessingPromise;
123
124
  private topLevelHeartbeatIntervalMs?;
125
+ private pendingLlmWatchdogDataSetNames;
124
126
  /**
125
127
  * Constructor for HashTreeParser
126
128
  * @param {Object} options
@@ -479,6 +481,16 @@ declare class HashTreeParser {
479
481
  * @returns {void}
480
482
  */
481
483
  private resetHeartbeatWatchdogs;
484
+ /**
485
+ * Re-evaluates heartbeat watchdog timers for LLM data sets. While LLM is not expected,
486
+ * resetHeartbeatWatchdogs skips setting watchdog timers for LLM data sets and records them in
487
+ * pendingLlmWatchdogDataSetNames. This must be called when LLM transitions to expected (e.g. self
488
+ * reports JOINED) to arm the watchdogs for those pending data sets (avoids a timing issue where
489
+ * the "main"/"atd-active"/"atd-unmuted" data set arrives before the self update). The pending set
490
+ * is consumed and cleared here.
491
+ * @returns {void}
492
+ */
493
+ reevaluateLlmWatchdogs(): void;
482
494
  /**
483
495
  * Stops all timers for the data sets to prevent any further sync attempts.
484
496
  * @returns {void}
@@ -124,6 +124,12 @@ export default class LocusInfo extends EventsScope {
124
124
  * @memberof LocusInfo
125
125
  */
126
126
  init(locus?: any): void;
127
+ /**
128
+ * Whether we expect to receive updates over the LLM connection. This is used by hash tree parsers
129
+ * to decide whether to arm heartbeat watchdog timers for LLM data sets.
130
+ * @returns {boolean}
131
+ */
132
+ private isLlmExpected;
127
133
  /**
128
134
  * Creates a HashTreeParser instance for a given locusUrl and stores it in the map.
129
135
  * @param {Object} params
@@ -869,7 +869,7 @@ var Webinar = _webexCore.WebexPlugin.extend({
869
869
  }, _callee1);
870
870
  }))();
871
871
  },
872
- version: "3.12.0-next.133"
872
+ version: "3.12.0-next.135"
873
873
  });
874
874
  var _default = exports.default = Webinar;
875
875
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -94,5 +94,5 @@
94
94
  "//": [
95
95
  "TODO: upgrade jwt-decode when moving to node 18"
96
96
  ],
97
- "version": "3.12.0-next.133"
97
+ "version": "3.12.0-next.135"
98
98
  }
@@ -110,6 +110,7 @@ export type HashTreeParserCallbacks = {
110
110
  locusInfoUpdateCallback: LocusInfoUpdateCallback;
111
111
  syncLatencyTracker?: SyncLatencyTracker;
112
112
  generateTrackingId?: GenerateTrackingId;
113
+ isLlmExpected: () => boolean;
113
114
  };
114
115
 
115
116
  const SYNC_METRICS_DATA_SETS = [
@@ -176,6 +177,9 @@ class HashTreeParser {
176
177
  private syncQueueProcessingPromise: Promise<void> = Promise.resolve();
177
178
  // top-level heartbeat interval from the most recent message, used as fallback when dataset-level value is missing
178
179
  private topLevelHeartbeatIntervalMs?: number;
180
+ // LLM data sets that were received while LLM was not expected, so their heartbeat watchdog was
181
+ // skipped; reevaluateLlmWatchdogs() arms these once LLM becomes expected and then clears this set
182
+ private pendingLlmWatchdogDataSetNames: Set<string> = new Set();
179
183
  /**
180
184
  * Constructor for HashTreeParser
181
185
  * @param {Object} options
@@ -1222,11 +1226,11 @@ class HashTreeParser {
1222
1226
  // emitted only from the LLM message path, so no completion happens here.
1223
1227
  const updatedObjects = this.parseMessage(message, debugText);
1224
1228
 
1225
- this.resetHeartbeatWatchdogs(message.dataSets);
1226
1229
  this.callLocusInfoUpdateCallback({
1227
1230
  updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
1228
1231
  updatedObjects,
1229
1232
  });
1233
+ this.resetHeartbeatWatchdogs(message.dataSets);
1230
1234
  }
1231
1235
  }
1232
1236
 
@@ -1876,7 +1880,22 @@ class HashTreeParser {
1876
1880
  // dataset-level heartbeatIntervalMs takes priority; fall back to top-level common value
1877
1881
  const heartbeatIntervalMs = dataSet?.heartbeatIntervalMs ?? this.topLevelHeartbeatIntervalMs;
1878
1882
 
1879
- if (!dataSet?.hashTree || !heartbeatIntervalMs) {
1883
+ if (!dataSet?.hashTree || !this.isVisibleDataSet(dataSet.name) || !heartbeatIntervalMs) {
1884
+ // eslint-disable-next-line no-continue
1885
+ continue;
1886
+ }
1887
+
1888
+ if (
1889
+ LLM_DATASET_NAMES.includes(dataSet.name) &&
1890
+ this.callbacks.isLlmExpected &&
1891
+ !this.callbacks.isLlmExpected()
1892
+ ) {
1893
+ LoggerProxy.logger.info(
1894
+ `HashTreeParser#resetHeartbeatWatchdogs --> ${this.debugId} skipping heartbeat watchdog timer for data set "${dataSet.name}" because LLM is disconnected`
1895
+ );
1896
+
1897
+ // remember it so reevaluateLlmWatchdogs() can arm the watchdog once LLM becomes expected
1898
+ this.pendingLlmWatchdogDataSetNames.add(dataSet.name);
1880
1899
  // eslint-disable-next-line no-continue
1881
1900
  continue;
1882
1901
  }
@@ -1888,7 +1907,7 @@ class HashTreeParser {
1888
1907
  dataSet.heartbeatWatchdogTimer = undefined;
1889
1908
 
1890
1909
  LoggerProxy.logger.warn(
1891
- `HashTreeParser#resetHeartbeatWatchdogs --> ${this.debugId} Heartbeat watchdog fired for data set "${dataSet.name}" - no heartbeat received within expected interval, initiating sync`
1910
+ `HashTreeParser#resetHeartbeatWatchdogs --> ${this.debugId} Heartbeat watchdog fired for data set "${dataSet.name}" - no heartbeat received within expected interval(heartbeatIntervalMs=${heartbeatIntervalMs}, backoffTime=${backoffTime}), initiating sync`
1892
1911
  );
1893
1912
 
1894
1913
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.HASH_TREE_HEARTBEAT_WATCHDOG_EXPIRED, {
@@ -1904,6 +1923,50 @@ class HashTreeParser {
1904
1923
  }
1905
1924
  }
1906
1925
 
1926
+ /**
1927
+ * Re-evaluates heartbeat watchdog timers for LLM data sets. While LLM is not expected,
1928
+ * resetHeartbeatWatchdogs skips setting watchdog timers for LLM data sets and records them in
1929
+ * pendingLlmWatchdogDataSetNames. This must be called when LLM transitions to expected (e.g. self
1930
+ * reports JOINED) to arm the watchdogs for those pending data sets (avoids a timing issue where
1931
+ * the "main"/"atd-active"/"atd-unmuted" data set arrives before the self update). The pending set
1932
+ * is consumed and cleared here.
1933
+ * @returns {void}
1934
+ */
1935
+ reevaluateLlmWatchdogs(): void {
1936
+ if (this.state === 'stopped') {
1937
+ return;
1938
+ }
1939
+
1940
+ if (this.pendingLlmWatchdogDataSetNames.size === 0) {
1941
+ return;
1942
+ }
1943
+
1944
+ // consume the pending set - these LLM data sets were received while LLM was not expected
1945
+ const pendingDataSetNames = [...this.pendingLlmWatchdogDataSetNames];
1946
+ this.pendingLlmWatchdogDataSetNames.clear();
1947
+
1948
+ const dataSetsNeedingWatchdog = pendingDataSetNames
1949
+ .map((name) => this.dataSets[name])
1950
+ .filter((dataSet): dataSet is InternalDataSet => {
1951
+ if (!dataSet?.hashTree || dataSet.heartbeatWatchdogTimer) {
1952
+ return false;
1953
+ }
1954
+
1955
+ return this.isVisibleDataSet(dataSet.name);
1956
+ });
1957
+
1958
+ if (dataSetsNeedingWatchdog.length > 0) {
1959
+ LoggerProxy.logger.info(
1960
+ `HashTreeParser#reevaluateLlmWatchdogs --> ${
1961
+ this.debugId
1962
+ } LLM became expected, setting heartbeat watchdog timers for data sets: ${dataSetsNeedingWatchdog
1963
+ .map((ds) => ds.name)
1964
+ .join(', ')}`
1965
+ );
1966
+ this.resetHeartbeatWatchdogs(dataSetsNeedingWatchdog);
1967
+ }
1968
+ }
1969
+
1907
1970
  /**
1908
1971
  * Stops all timers for the data sets to prevent any further sync attempts.
1909
1972
  * @returns {void}
@@ -1936,6 +1999,7 @@ class HashTreeParser {
1936
1999
  this.topLevelHeartbeatIntervalMs = undefined;
1937
2000
  this.syncAllBackoffType = SyncAllBackoffType.NONE;
1938
2001
  this.dataSetsSyncedDuringBackoff = new Set();
2002
+ this.pendingLlmWatchdogDataSetNames = new Set();
1939
2003
  Object.values(this.dataSets).forEach((dataSet) => {
1940
2004
  dataSet.syncAbortController?.abort();
1941
2005
  dataSet.syncAbortController = undefined;
@@ -538,6 +538,15 @@ export default class LocusInfo extends EventsScope {
538
538
  this.updateLinks(locus.links);
539
539
  }
540
540
 
541
+ /**
542
+ * Whether we expect to receive updates over the LLM connection. This is used by hash tree parsers
543
+ * to decide whether to arm heartbeat watchdog timers for LLM data sets.
544
+ * @returns {boolean}
545
+ */
546
+ private isLlmExpected(): boolean {
547
+ return this.parsedLocus.self?.joinedWith?.state === 'JOINED';
548
+ }
549
+
541
550
  /**
542
551
  * Creates a HashTreeParser instance for a given locusUrl and stores it in the map.
543
552
  * @param {Object} params
@@ -568,6 +577,7 @@ export default class LocusInfo extends EventsScope {
568
577
  callbacks: {
569
578
  locusInfoUpdateCallback: this.updateFromHashTree.bind(this, locusUrl),
570
579
  syncLatencyTracker: this.callbacks.syncLatencyTracker,
580
+ isLlmExpected: () => this.isLlmExpected(),
571
581
  // Reuse webex-core's tracking-id interceptor sequence (exposed publicly via
572
582
  // webexTrackingIdSequenceNumbers) so Locus requests share the client's unified
573
583
  // ${sessionId}_${sequence} tracking id space instead of minting an unrelated id. Fall
@@ -2713,6 +2723,7 @@ export default class LocusInfo extends EventsScope {
2713
2723
  */
2714
2724
  updateSelf(self: any) {
2715
2725
  if (self) {
2726
+ const wasLlmExpected = this.isLlmExpected();
2716
2727
  // @ts-ignore
2717
2728
  const parsedSelves = SelfUtils.getSelves(
2718
2729
  this.parsedLocus.self,
@@ -2992,6 +3003,15 @@ export default class LocusInfo extends EventsScope {
2992
3003
  this.parsedLocus.self = parsedSelves.current;
2993
3004
  // @ts-ignore
2994
3005
  this.self = self;
3006
+
3007
+ // If LLM just became expected (self reported JOINED), some hash tree parsers may have skipped
3008
+ // arming heartbeat watchdog timers for LLM data sets whose messages arrived before this
3009
+ // update. Re-evaluate them now so those watchdogs get armed.
3010
+ if (!wasLlmExpected && this.isLlmExpected()) {
3011
+ this.hashTreeParsers.forEach((entry) => {
3012
+ entry.parser.reevaluateLlmWatchdogs();
3013
+ });
3014
+ }
2995
3015
  } else {
2996
3016
  this.compareAndUpdateFlags.compareHostAndSelf = false;
2997
3017
  }
@@ -184,7 +184,8 @@ describe('HashTreeParser', () => {
184
184
  excludedDataSets?: string[],
185
185
  syncLatencyTracker?: any,
186
186
  syncLatencyMeetingId = 'meeting-1',
187
- generateTrackingId?: any
187
+ generateTrackingId?: any,
188
+ isLlmExpected?: () => boolean
188
189
  ) {
189
190
  return new HashTreeParser({
190
191
  initialLocus,
@@ -194,6 +195,7 @@ describe('HashTreeParser', () => {
194
195
  locusInfoUpdateCallback: callback,
195
196
  syncLatencyTracker,
196
197
  generateTrackingId,
198
+ isLlmExpected,
197
199
  },
198
200
  debugId: 'test',
199
201
  excludedDataSets,
@@ -3519,6 +3521,193 @@ describe('HashTreeParser', () => {
3519
3521
  expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3520
3522
  });
3521
3523
 
3524
+ it('skips watchdog timers for LLM datasets when current meeting LLM is not expected', async () => {
3525
+ const parser = createHashTreeParser(
3526
+ undefined,
3527
+ undefined,
3528
+ undefined,
3529
+ undefined,
3530
+ 'meeting-1',
3531
+ undefined,
3532
+ () => false
3533
+ );
3534
+
3535
+ const heartbeatMessage = {
3536
+ dataSets: [
3537
+ {
3538
+ ...createDataSet('main', 16, 1100),
3539
+ root: parser.dataSets.main.hashTree.getRootHash(),
3540
+ },
3541
+ {
3542
+ ...createDataSet('self', 1, 2100),
3543
+ url: parser.dataSets.self.url,
3544
+ root: parser.dataSets.self.hashTree.getRootHash(),
3545
+ },
3546
+ {
3547
+ ...createDataSet('atd-unmuted', 16, 3100),
3548
+ url: parser.dataSets['atd-unmuted'].url,
3549
+ root: parser.dataSets['atd-unmuted'].hashTree.getRootHash(),
3550
+ },
3551
+ ],
3552
+ visibleDataSetsUrl,
3553
+ locusUrl,
3554
+ };
3555
+
3556
+ parser.handleMessage(heartbeatMessage, 'heartbeat with meeting-scoped llm not expected');
3557
+
3558
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3559
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3560
+ expect(parser.dataSets.self.heartbeatWatchdogTimer).to.not.be.undefined;
3561
+ });
3562
+
3563
+ it('arms skipped LLM watchdog timers when reevaluateLlmWatchdogs is called after LLM becomes expected', async () => {
3564
+ let llmExpected = false;
3565
+ const parser = createHashTreeParser(
3566
+ undefined,
3567
+ undefined,
3568
+ undefined,
3569
+ undefined,
3570
+ 'meeting-1',
3571
+ undefined,
3572
+ () => llmExpected
3573
+ );
3574
+
3575
+ const heartbeatMessage = {
3576
+ dataSets: [
3577
+ {
3578
+ ...createDataSet('main', 16, 1100),
3579
+ root: parser.dataSets.main.hashTree.getRootHash(),
3580
+ },
3581
+ {
3582
+ ...createDataSet('self', 1, 2100),
3583
+ url: parser.dataSets.self.url,
3584
+ root: parser.dataSets.self.hashTree.getRootHash(),
3585
+ },
3586
+ {
3587
+ ...createDataSet('atd-unmuted', 16, 3100),
3588
+ url: parser.dataSets['atd-unmuted'].url,
3589
+ root: parser.dataSets['atd-unmuted'].hashTree.getRootHash(),
3590
+ },
3591
+ ],
3592
+ visibleDataSetsUrl,
3593
+ locusUrl,
3594
+ };
3595
+
3596
+ // LLM data set messages arrive before LLM is expected, so their watchdogs are skipped
3597
+ parser.handleMessage(heartbeatMessage, 'heartbeat before llm expected');
3598
+
3599
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3600
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3601
+ const selfTimerBefore = parser.dataSets.self.heartbeatWatchdogTimer;
3602
+ expect(selfTimerBefore).to.not.be.undefined;
3603
+
3604
+ // LLM becomes expected and we re-evaluate the watchdogs
3605
+ llmExpected = true;
3606
+ parser.reevaluateLlmWatchdogs();
3607
+
3608
+ // the previously skipped LLM watchdogs are now armed
3609
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.not.be.undefined;
3610
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.not.be.undefined;
3611
+ // the self (non-LLM) watchdog timer is left untouched
3612
+ expect(parser.dataSets.self.heartbeatWatchdogTimer).to.equal(selfTimerBefore);
3613
+
3614
+ // the pending set is consumed, so a second call after clearing the timers is a no-op
3615
+ clearTimeout(parser.dataSets.main.heartbeatWatchdogTimer);
3616
+ clearTimeout(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer);
3617
+ parser.dataSets.main.heartbeatWatchdogTimer = undefined;
3618
+ parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer = undefined;
3619
+
3620
+ parser.reevaluateLlmWatchdogs();
3621
+
3622
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3623
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3624
+ });
3625
+
3626
+ it('only arms watchdogs for LLM data sets that were actually received in a message', async () => {
3627
+ let llmExpected = false;
3628
+ const parser = createHashTreeParser(
3629
+ undefined,
3630
+ undefined,
3631
+ undefined,
3632
+ undefined,
3633
+ 'meeting-1',
3634
+ undefined,
3635
+ () => llmExpected
3636
+ );
3637
+
3638
+ // only 'main' is received in a message (atd-unmuted exists in this.dataSets with a hash
3639
+ // tree but is never received in any message)
3640
+ const heartbeatMessage = {
3641
+ dataSets: [
3642
+ {
3643
+ ...createDataSet('main', 16, 1100),
3644
+ root: parser.dataSets.main.hashTree.getRootHash(),
3645
+ },
3646
+ ],
3647
+ visibleDataSetsUrl,
3648
+ locusUrl,
3649
+ };
3650
+
3651
+ parser.handleMessage(heartbeatMessage, 'only main received before llm expected');
3652
+
3653
+ // sanity: atd-unmuted has a hash tree but was never received
3654
+ expect(parser.dataSets['atd-unmuted'].hashTree).to.not.be.undefined;
3655
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3656
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3657
+
3658
+ llmExpected = true;
3659
+ parser.reevaluateLlmWatchdogs();
3660
+
3661
+ // 'main' was received, so its watchdog is armed
3662
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.not.be.undefined;
3663
+ // 'atd-unmuted' was never received, so no watchdog is armed even though it has a hash tree
3664
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3665
+ });
3666
+
3667
+ it('does not re-arm or reset an already active LLM watchdog timer when reevaluateLlmWatchdogs is called', async () => {
3668
+ const parser = createHashTreeParser(
3669
+ undefined,
3670
+ undefined,
3671
+ undefined,
3672
+ undefined,
3673
+ 'meeting-1',
3674
+ undefined,
3675
+ () => true
3676
+ );
3677
+
3678
+ parser.handleMessage(
3679
+ createHeartbeatMessage('main', 16, 1100, parser.dataSets.main.hashTree.getRootHash()),
3680
+ 'heartbeat with llm expected'
3681
+ );
3682
+
3683
+ const mainTimerBefore = parser.dataSets.main.heartbeatWatchdogTimer;
3684
+ expect(mainTimerBefore).to.not.be.undefined;
3685
+
3686
+ parser.reevaluateLlmWatchdogs();
3687
+
3688
+ // existing active timer must not be cleared/reset (that would extend its deadline)
3689
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.equal(mainTimerBefore);
3690
+ });
3691
+
3692
+ it('does nothing when reevaluateLlmWatchdogs is called on a stopped parser', async () => {
3693
+ const parser = createHashTreeParser(
3694
+ undefined,
3695
+ undefined,
3696
+ undefined,
3697
+ undefined,
3698
+ 'meeting-1',
3699
+ undefined,
3700
+ () => true
3701
+ );
3702
+
3703
+ parser.stop();
3704
+
3705
+ parser.reevaluateLlmWatchdogs();
3706
+
3707
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3708
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3709
+ });
3710
+
3522
3711
  it('stops all watchdog timers when meeting ends via sentinel message', async () => {
3523
3712
  const parser = createHashTreeParser();
3524
3713
 
@@ -3679,6 +3868,28 @@ describe('HashTreeParser', () => {
3679
3868
  expect(parser.dataSets['atd-active']?.heartbeatWatchdogTimer).to.be.undefined;
3680
3869
  });
3681
3870
 
3871
+ it('does not set watchdog for a data set that has a hash tree but is not in visibleDataSets', async () => {
3872
+ const parser = createHashTreeParser();
3873
+
3874
+ // simulate a dataset that still has a hash tree but is no longer visible
3875
+ parser.visibleDataSets = parser.visibleDataSets.filter((vds) => vds.name !== 'main');
3876
+
3877
+ const heartbeatMessage = {
3878
+ dataSets: [
3879
+ {
3880
+ ...createDataSet('main', 16, 1100),
3881
+ root: parser.dataSets.main.hashTree.getRootHash(),
3882
+ },
3883
+ ],
3884
+ visibleDataSetsUrl,
3885
+ locusUrl,
3886
+ };
3887
+
3888
+ parser.handleMessage(heartbeatMessage, 'heartbeat for non-visible dataset with hash tree');
3889
+
3890
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3891
+ });
3892
+
3682
3893
  it('restarts the watchdog timer after it fires so that future missed heartbeats still trigger syncs', async () => {
3683
3894
  const parser = createHashTreeParser();
3684
3895
  const heartbeatIntervalMs = 5000;
@@ -195,6 +195,38 @@ describe('plugin-meetings', () => {
195
195
  );
196
196
  });
197
197
 
198
+ it('passes an isLlmExpected callback that is true when current device is joined', async () => {
199
+ locusInfo.parsedLocus.self = {
200
+ state: 'LEFT',
201
+ joinedWith: {state: 'JOINED'},
202
+ };
203
+
204
+ await locusInfo.initialSetup({
205
+ trigger: 'locus-message',
206
+ hashTreeMessage: createHashTreeMessage(['dataset1']),
207
+ });
208
+
209
+ const {isLlmExpected} = HashTreeParserStub.firstCall.args[0].callbacks;
210
+
211
+ assert.equal(isLlmExpected(), true);
212
+ });
213
+
214
+ it('passes an isLlmExpected callback that is false when self is joined but current device is not joined', async () => {
215
+ locusInfo.parsedLocus.self = {
216
+ state: 'JOINED',
217
+ joinedWith: {state: 'LEFT'},
218
+ };
219
+
220
+ await locusInfo.initialSetup({
221
+ trigger: 'locus-message',
222
+ hashTreeMessage: createHashTreeMessage(['dataset1']),
223
+ });
224
+
225
+ const {isLlmExpected} = HashTreeParserStub.firstCall.args[0].callbacks;
226
+
227
+ assert.equal(isLlmExpected(), false);
228
+ });
229
+
198
230
  it('should not initialize the hash tree when triggered from a non-hash tree locus message', async () => {
199
231
  const locus = {url: 'http://locus-url.com', participants: []};
200
232
 
@@ -2023,6 +2055,53 @@ describe('plugin-meetings', () => {
2023
2055
  });
2024
2056
 
2025
2057
  describe('#updateSelf', () => {
2058
+ describe('LLM watchdog re-evaluation', () => {
2059
+ it('re-evaluates LLM watchdogs on all hash tree parsers when self transitions to joined', () => {
2060
+ const parserA = {reevaluateLlmWatchdogs: sinon.stub()};
2061
+ const parserB = {reevaluateLlmWatchdogs: sinon.stub()};
2062
+ locusInfo.hashTreeParsers.set('urlA', {parser: parserA});
2063
+ locusInfo.hashTreeParsers.set('urlB', {parser: parserB});
2064
+
2065
+ // start with LLM not expected (no self yet)
2066
+ locusInfo.parsedLocus.self = undefined;
2067
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2068
+
2069
+ // the self fixture's joined device has state JOINED -> isLlmExpected becomes true
2070
+ locusInfo.updateSelf(cloneDeep(self));
2071
+
2072
+ assert.calledOnceWithExactly(parserA.reevaluateLlmWatchdogs);
2073
+ assert.calledOnceWithExactly(parserB.reevaluateLlmWatchdogs);
2074
+ });
2075
+
2076
+ it('does not re-evaluate LLM watchdogs when LLM was already expected before the update', () => {
2077
+ const parser = {reevaluateLlmWatchdogs: sinon.stub()};
2078
+ locusInfo.hashTreeParsers.set('urlA', {parser});
2079
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2080
+
2081
+ // first update establishes the JOINED state (LLM already expected)
2082
+ locusInfo.updateSelf(cloneDeep(self));
2083
+ parser.reevaluateLlmWatchdogs.resetHistory();
2084
+
2085
+ // second update while already joined must not re-trigger re-evaluation
2086
+ locusInfo.updateSelf(cloneDeep(self));
2087
+
2088
+ assert.notCalled(parser.reevaluateLlmWatchdogs);
2089
+ });
2090
+
2091
+ it('does not re-evaluate LLM watchdogs when the self update does not make LLM expected', () => {
2092
+ const parser = {reevaluateLlmWatchdogs: sinon.stub()};
2093
+ locusInfo.hashTreeParsers.set('urlA', {parser});
2094
+
2095
+ locusInfo.parsedLocus.self = undefined;
2096
+ // device url does not match any of self's devices -> joinedWith is undefined -> not expected
2097
+ locusInfo.webex.internal.device.url = 'https://some-other-device-url.com';
2098
+
2099
+ locusInfo.updateSelf(cloneDeep(self));
2100
+
2101
+ assert.notCalled(parser.reevaluateLlmWatchdogs);
2102
+ });
2103
+ });
2104
+
2026
2105
  it('should trigger SELF_MEETING_BRB_CHANGED when brb state changed', () => {
2027
2106
  locusInfo.self = undefined;
2028
2107