@xema/omni-protocol 0.1.110 → 0.1.111

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 (2) hide show
  1. package/dist/testing.js +33 -25
  2. package/package.json +1 -1
package/dist/testing.js CHANGED
@@ -515,8 +515,12 @@ export async function exerciseAdapter(adapter, context, options = {}) {
515
515
  unsubscribeAuthentication = session.subscribe(onAuthenticationState);
516
516
  unsubscribe = second.subscribe(onEnvelope);
517
517
  clientLive = true;
518
+ // The second client has been told nothing: the switch is per connection, and the reader
519
+ // holds its connect snapshot to no team until it is sent again, after its capacity.
520
+ leadFeaturesOn = false;
518
521
  const restated = await second.setCapacity({ count: capacityStated ?? 1 });
519
522
  violations.push(...validateResult(restated, "setCapacity", "drive.reload.setCapacity"));
523
+ await switchOnLeadFeatures(second, "drive.reload");
520
524
  },
521
525
  };
522
526
  // Every snapshot the run reads, the connect snapshot and a reloaded client's, is read the same
@@ -619,40 +623,44 @@ export async function exerciseAdapter(adapter, context, options = {}) {
619
623
  }
620
624
  // The provider assumes nothing of the team feature: the application says on every connect,
621
625
  // and once it has said on, the whole team is owed, once. Before that nothing of the team
622
- // reaches the lead, which the reader held the connect snapshot to.
623
- if (current().capabilities.lead === true && typeof live.executeTeam === "function") {
626
+ // reaches the lead, which the reader held the connect snapshot to. A reloaded client is a
627
+ // connect too: it is told again, after its capacity, and held the same way.
628
+ const switchOnLeadFeatures = async (on, at) => {
629
+ if (current().capabilities.lead !== true || typeof on.executeTeam !== "function")
630
+ return;
624
631
  const from = events.length;
625
632
  let switched;
626
633
  // On from the moment the application says so: the provider may answer with the team at once.
627
634
  leadFeaturesOn = true;
628
635
  try {
629
- switched = await live.executeTeam({ command: { type: "lead-features", enabled: true } });
636
+ switched = await on.executeTeam({ command: { type: "lead-features", enabled: true } });
630
637
  }
631
638
  catch (error) {
632
639
  leadFeaturesOn = false;
633
- violations.push({ rule: "team.switch.rejected", path: "connection.executeTeam", message: `lead-features on was rejected: ${String(error)}` });
640
+ violations.push({ rule: "team.switch.rejected", path: `${at}.executeTeam`, message: `lead-features on was rejected: ${String(error)}` });
634
641
  }
635
- if (switched !== undefined) {
636
- violations.push(...validateResult(switched, "executeTeam", "connection.executeTeam"));
637
- ruleEvaluated("team.required");
638
- const ms = options.driveTimeoutMs ?? 5000;
639
- const isBaseline = (envelope) => isRecord(envelope?.event) && envelope.event.type === "team-updated";
640
- const baseline = events.slice(from).some(isBaseline) || await new Promise(resolve => {
641
- const timer = setTimeout(() => { waiters.delete(waiter); resolve(false); }, ms);
642
- const waiter = (envelope) => {
643
- if (!isBaseline(envelope))
644
- return;
645
- clearTimeout(timer);
646
- waiters.delete(waiter);
647
- resolve(true);
648
- };
649
- waiters.add(waiter);
650
- });
651
- if (!baseline)
652
- violations.push({ rule: "team.required", path: "event.team",
653
- message: `the application switched the team feature on and no team-updated followed within ${ms}ms: the whole team is owed once it is on, members: [] when nobody is in it` });
654
- }
655
- }
642
+ if (switched === undefined)
643
+ return;
644
+ violations.push(...validateResult(switched, "executeTeam", `${at}.executeTeam`));
645
+ ruleEvaluated("team.required");
646
+ const ms = options.driveTimeoutMs ?? 5000;
647
+ const isBaseline = (envelope) => isRecord(envelope?.event) && envelope.event.type === "team-updated";
648
+ const baseline = events.slice(from).some(isBaseline) || await new Promise(resolve => {
649
+ const timer = setTimeout(() => { waiters.delete(waiter); resolve(false); }, ms);
650
+ const waiter = (envelope) => {
651
+ if (!isBaseline(envelope))
652
+ return;
653
+ clearTimeout(timer);
654
+ waiters.delete(waiter);
655
+ resolve(true);
656
+ };
657
+ waiters.add(waiter);
658
+ });
659
+ if (!baseline)
660
+ violations.push({ rule: "team.required", path: "event.team",
661
+ message: `the application switched the team feature on and no team-updated followed within ${ms}ms: the whole team is owed once it is on, members: [] when nobody is in it` });
662
+ };
663
+ await switchOnLeadFeatures(live, "connection");
656
664
  if (options.drive) {
657
665
  const localAudio = isRecord(first) && isRecord(first.audio) && isRecord(first.audio.input) && first.audio.input.status === "available"
658
666
  ? first.audio.input.localAudio : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xema/omni-protocol",
3
- "version": "0.1.110",
3
+ "version": "0.1.111",
4
4
  "description": "The Omni protocol: the contract every provider adapter implements",
5
5
  "type": "module",
6
6
  "license": "MIT",