@cello-protocol/daemon 0.0.20 → 0.0.21

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.
@@ -145,6 +145,13 @@ export declare class SessionNodeManager {
145
145
  * dialability the conservative default and fires transport.autonat.unavailable.
146
146
  */
147
147
  autoNatProbers?: () => string[];
148
+ /**
149
+ * M8B F14: backoff schedule for standing-receiver create retries. Attempt 1 runs
150
+ * immediately; each entry is the delay before the next attempt. Default covers the
151
+ * fixed-port race where a teardown and a re-arm interleave (EADDRINUSE clears once
152
+ * the old node's port is released). Tests inject short delays or [] (no retries).
153
+ */
154
+ standingReceiverRetryDelaysMs?: number[];
148
155
  });
149
156
  /**
150
157
  * CELLO-M7-MSG-001: wire the durable-backstop side effects of the awaiting-ACK
@@ -498,6 +505,8 @@ export declare class SessionNodeManager {
498
505
  } | {
499
506
  ok: false;
500
507
  reason: string;
508
+ reportedRootHex?: string;
509
+ sequenceNumber?: number;
501
510
  }>;
502
511
  /**
503
512
  * CELLO-M7-UPGRADE-001 (DOD-UP-1): readiness of a session for B to RATIFY a unilateral seal
@@ -627,6 +636,8 @@ export declare class SessionNodeManager {
627
636
  /**
628
637
  * DOD-LOOP-1: public hook for the composition root to create an agent's standing receiver when
629
638
  * the agent comes online (cello_start_agent), and to tear it down when it goes offline.
639
+ * M8B F14: also called from the inbound accept path (ensure on demand). Marks the agent as
640
+ * WANTING a receiver, which arms the teardown re-arm in destroySessionNode/retireSessionNode.
630
641
  */
631
642
  ensureStandingReceiverForAgent(agentName: string): Promise<void>;
632
643
  removeStandingReceiverForAgent(agentName: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"session-node-manager.d.ts","sourceRoot":"","sources":["../src/session-node-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAMH,OAAO,EACL,KAAK,cAAc,EAIpB,MAA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AG;QAAE,OAAO,EAAE,UAAU,CAAC;QAAC,cAAc,CAAC,EAAE,UAAU,CAAC;QAAC,cAAc,CAAC,EAAE,UAAU,CAAA;KAAE;IAmB5H;;;OAGG;IACH,oBAAoB,CAClB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,UAAU,EAC1B,cAAc,EAAE,UAAU,EAC1B,WAAW,EAAE,UAAU,EACvB,aAAa,CAAC,EAAE,MAAM,GACrB,IAAI;IA4HP;;;;;;;;;;;;;;OAcG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,IAAI;IAyMzG;;;;;OAKG;IACG,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhE,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA0EvE"}
@@ -104,6 +104,13 @@ export class SessionNodeManager {
104
104
  // prevents two concurrent ensure() calls from building two nodes for the same agent.
105
105
  #standingReceivers = new Map();
106
106
  #standingReceiverCreating = new Set();
107
+ // M8B F14: agents that SHOULD have a standing receiver — marked by
108
+ // ensureStandingReceiverForAgent (cello_start_agent / the inbound accept path) and
109
+ // unmarked by removeStandingReceiverForAgent (cello_stop_agent). Consulted by the
110
+ // teardown re-arm so a session-node teardown never re-arms an offline agent.
111
+ #agentsWantingReceiver = new Set();
112
+ // M8B F14: standing-receiver create retry schedule (see constructor opts).
113
+ #srRetryDelaysMs;
107
114
  // Agents whose removeStandingReceiverForAgent ran while an #ensureStandingReceiver for them was
108
115
  // in flight (parked on createNode/start, so the map had no entry to delete yet). The in-flight
109
116
  // ensure checks this after start() and tears the fresh node down instead of installing an SR for
@@ -164,7 +171,10 @@ export class SessionNodeManager {
164
171
  // M7-UPGRADE-002: sessions for which B has already submitted its responder SEAL leaf (via
165
172
  // auto-ack OR cello_close_session). Idempotency guard — A's SEAL ctrl leaf may be delivered
166
173
  // more than once (and the relay echoes leaves), so auto-ack fires AT MOST ONCE per session.
167
- #responderSealSubmitted = new Set();
174
+ // M8B FINDING-1: the value carries the first successful submit's reportedRootHex/sequenceNumber
175
+ // (null while the submit is still in flight), so a RETRY close can escalate to a unilateral
176
+ // seal with the original reported root instead of deadlocking on seal_pending_bilateral.
177
+ #responderSealSubmitted = new Map();
168
178
  // M7-SESSION-001 (M-1 PUSH): optional callback fired when a session changes
169
179
  // state, so the composition root can dispatch a session_state_changed
170
180
  // notification to live MCP clients. Injected via a setter AFTER construction
@@ -203,6 +213,7 @@ export class SessionNodeManager {
203
213
  this.#contentTtfMs = opts.contentTtfMs;
204
214
  }
205
215
  this.#autoNatProbers = opts.autoNatProbers ?? (() => []);
216
+ this.#srRetryDelaysMs = opts.standingReceiverRetryDelaysMs ?? [1_000, 5_000, 15_000];
206
217
  }
207
218
  /**
208
219
  * CELLO-M7-MSG-001: wire the durable-backstop side effects of the awaiting-ACK
@@ -1024,6 +1035,26 @@ export class SessionNodeManager {
1024
1035
  agentName: entry.agentName,
1025
1036
  reason,
1026
1037
  });
1038
+ // M8B F14 (fix 1): the torn-down node has just released its port — on a fixed-port
1039
+ // deployment this is the FIRST moment a previously-failed re-arm can succeed. Re-arm
1040
+ // the standing receiver for an online agent that has none (async, never awaited).
1041
+ this.#rearmAfterTeardown(agentName);
1042
+ }
1043
+ /**
1044
+ * M8B F14: re-arm an online agent's standing receiver after a session-node teardown
1045
+ * freed resources (notably the fixed port). No-op when the agent is offline, already
1046
+ * has a receiver, or one is being created. The re-arm is a NEW async flow — it mints
1047
+ * its own correlationId (via the ensure default) rather than inheriting the torn-down
1048
+ * session's.
1049
+ */
1050
+ #rearmAfterTeardown(agentName) {
1051
+ if (this.#shuttingDown)
1052
+ return;
1053
+ if (!this.#agentsWantingReceiver.has(agentName))
1054
+ return;
1055
+ if (this.#standingReceivers.has(agentName) || this.#standingReceiverCreating.has(agentName))
1056
+ return;
1057
+ void this.#ensureStandingReceiver(agentName);
1027
1058
  }
1028
1059
  /**
1029
1060
  * round-2 finding #5: retire a session's live libp2p node WITHOUT changing its
@@ -1058,6 +1089,8 @@ export class SessionNodeManager {
1058
1089
  agentName: entry.agentName,
1059
1090
  reason: "sealing",
1060
1091
  });
1092
+ // M8B F14 (fix 1): same re-arm point as destroySessionNode — the retired node freed its port.
1093
+ this.#rearmAfterTeardown(agentName);
1061
1094
  }
1062
1095
  /** Drop the in-memory tree + received-content caches for a torn-down session (DOD-LOOP-1: per (agent, session)). */
1063
1096
  #evictSessionCaches(agentName, sessionId) {
@@ -1345,6 +1378,10 @@ export class SessionNodeManager {
1345
1378
  agentName,
1346
1379
  reason: "interrupted",
1347
1380
  });
1381
+ // M8B F14 (fix 1): the relay-detected interruption is the THIRD teardown path that
1382
+ // frees the fixed port — it must re-arm too, or a session ending on a network blip
1383
+ // leaves the agent deaf again (review finding on the F14 fix).
1384
+ this.#rearmAfterTeardown(agentName);
1348
1385
  }
1349
1386
  this.#logger.warn("session.interrupted.detected", {
1350
1387
  sessionId,
@@ -1744,40 +1781,63 @@ export class SessionNodeManager {
1744
1781
  // two near-simultaneous triggers (e.g. B's own close racing A's delivered SEAL ctrl leaf) cannot
1745
1782
  // both submit. Cleared below on a relay submit failure so a genuine retry can proceed.
1746
1783
  if (this.#responderSealSubmitted.has(sealKey)) {
1747
- return { ok: false, reason: "responder_seal_already_submitted" };
1748
- }
1749
- this.#responderSealSubmitted.add(sealKey);
1750
- const finalRootHex = this.getSessionTreeRootHex(agentName, sessionId);
1751
- const sealPayload = encodeSealPayload({
1752
- session_id: entry.relaySessionIdBytes,
1753
- final_root: new Uint8Array(Buffer.from(finalRootHex, "hex")),
1754
- close_timestamp: Date.now(),
1755
- attestation: "PENDING",
1756
- });
1757
- // content_hash = SHA-256(0x02 || seal_payload) — the ctrl leaf kind byte is 0x02.
1758
- const contentHash = new Uint8Array(createHash("sha256").update(new Uint8Array([LEAF_KIND_CTRL])).update(sealPayload).digest());
1759
- const result = await entry.relayClient.submitLeaf(entry.node, entry.relaySessionIdBytes, contentHash, LEAF_KIND_CTRL);
1760
- if (!result.ok) {
1761
- // Clear the idempotency mark so a genuine retry (agent close / reconnect) can proceed (DB-001).
1784
+ // M8B FINDING-1: carry the FIRST submit's reported root/sequence so a retry close can
1785
+ // still escalate to a unilateral seal. A null value means that submit is still in
1786
+ // flight — return the bare reason and let the caller fall back to the pending path.
1787
+ const prior = this.#responderSealSubmitted.get(sealKey);
1788
+ return prior
1789
+ ? {
1790
+ ok: false,
1791
+ reason: "responder_seal_already_submitted",
1792
+ reportedRootHex: prior.reportedRootHex,
1793
+ sequenceNumber: prior.sequenceNumber,
1794
+ }
1795
+ : { ok: false, reason: "responder_seal_already_submitted" };
1796
+ }
1797
+ this.#responderSealSubmitted.set(sealKey, null);
1798
+ // A throw anywhere before the mark is finalized would strand the null in-flight marker
1799
+ // and lock every future close out of escalation (a FINDING-1-shaped deadlock via a
1800
+ // different trigger) — clear the mark on any unexpected exception.
1801
+ try {
1802
+ const finalRootHex = this.getSessionTreeRootHex(agentName, sessionId);
1803
+ const sealPayload = encodeSealPayload({
1804
+ session_id: entry.relaySessionIdBytes,
1805
+ final_root: new Uint8Array(Buffer.from(finalRootHex, "hex")),
1806
+ close_timestamp: Date.now(),
1807
+ attestation: "PENDING",
1808
+ });
1809
+ // content_hash = SHA-256(0x02 || seal_payload) — the ctrl leaf kind byte is 0x02.
1810
+ const contentHash = new Uint8Array(createHash("sha256").update(new Uint8Array([LEAF_KIND_CTRL])).update(sealPayload).digest());
1811
+ const result = await entry.relayClient.submitLeaf(entry.node, entry.relaySessionIdBytes, contentHash, LEAF_KIND_CTRL);
1812
+ if (!result.ok) {
1813
+ // Clear the idempotency mark so a genuine retry (agent close / reconnect) can proceed (DB-001).
1814
+ this.#responderSealSubmitted.delete(sealKey);
1815
+ this.#logger.warn("session.seal.leaf.submit.failed", { sessionId, reason: result.reason, correlationId });
1816
+ return { ok: false, reason: result.reason };
1817
+ }
1818
+ // SESSION-002: the reported_root for a unilateral seal is the content-hash root the
1819
+ // local tree WOULD have with this SEAL ctrl leaf appended — the same root the directory
1820
+ // rebuilds from the relay's content-hash chain (the relay records the identical
1821
+ // content_hash for this ctrl leaf). Computed without mutating the durable tree /
1822
+ // message_count, so the bilateral + interrupted seal paths are unaffected.
1823
+ const contentHashHex = Buffer.from(contentHash).toString("hex");
1824
+ const reportedRootHex = this.getSessionTree(agentName, sessionId).rootWithAppendedHex(contentHashHex);
1825
+ // M8B FINDING-1: durably associate the submit's escalation values with the idempotency
1826
+ // mark, so any LATER close call can retrieve them via the already-submitted result.
1827
+ this.#responderSealSubmitted.set(sealKey, { reportedRootHex, sequenceNumber: result.sequence_number });
1828
+ this.#logger.info("session.seal.leaf.submitted", {
1829
+ sessionId,
1830
+ sequenceNumber: result.sequence_number,
1831
+ correlationId,
1832
+ });
1833
+ // M7-UPGRADE-002: #responderSealSubmitted was set synchronously at the top of this method —
1834
+ // the guard now blocks any second submit (auto-ack OR a redelivered counterparty SEAL ctrl leaf).
1835
+ return { ok: true, sequenceNumber: result.sequence_number, reportedRootHex };
1836
+ }
1837
+ catch (err) {
1762
1838
  this.#responderSealSubmitted.delete(sealKey);
1763
- this.#logger.warn("session.seal.leaf.submit.failed", { sessionId, reason: result.reason, correlationId });
1764
- return { ok: false, reason: result.reason };
1765
- }
1766
- // SESSION-002: the reported_root for a unilateral seal is the content-hash root the
1767
- // local tree WOULD have with this SEAL ctrl leaf appended — the same root the directory
1768
- // rebuilds from the relay's content-hash chain (the relay records the identical
1769
- // content_hash for this ctrl leaf). Computed without mutating the durable tree /
1770
- // message_count, so the bilateral + interrupted seal paths are unaffected.
1771
- const contentHashHex = Buffer.from(contentHash).toString("hex");
1772
- const reportedRootHex = this.getSessionTree(agentName, sessionId).rootWithAppendedHex(contentHashHex);
1773
- this.#logger.info("session.seal.leaf.submitted", {
1774
- sessionId,
1775
- sequenceNumber: result.sequence_number,
1776
- correlationId,
1777
- });
1778
- // M7-UPGRADE-002: #responderSealSubmitted was set synchronously at the top of this method —
1779
- // the guard now blocks any second submit (auto-ack OR a redelivered counterparty SEAL ctrl leaf).
1780
- return { ok: true, sequenceNumber: result.sequence_number, reportedRootHex };
1839
+ throw err;
1840
+ }
1781
1841
  }
1782
1842
  /**
1783
1843
  * CELLO-M7-UPGRADE-001 (DOD-UP-1): readiness of a session for B to RATIFY a unilateral seal
@@ -2582,8 +2642,15 @@ export class SessionNodeManager {
2582
2642
  * DOD-LOOP-1: ensure the given agent has a standing receiver node (idempotent). Created when an
2583
2643
  * agent comes online (cello_start_agent) and replaced after it is handed off to a session. The
2584
2644
  * `#standingReceiverCreating` guard prevents two concurrent ensure() calls (e.g. the
2585
- * cello_start_agent hook racing a consume-site retry) from building two nodes for one agent. A
2586
- * create failure logs + leaves no entry; the next consume-site ensure() call retries on demand.
2645
+ * cello_start_agent hook racing a consume-site retry) from building two nodes for one agent.
2646
+ *
2647
+ * M8B F14: a create failure no longer strands the agent deaf. Each ensure runs a BOUNDED
2648
+ * retry loop (`standingReceiverRetryDelaysMs`, default 1s/5s/15s) — covering the fixed-port
2649
+ * race where the consumed receiver still holds the port until its session node is torn down —
2650
+ * and when every attempt fails, fires the alarm-worthy `session.standing_receiver.dead`
2651
+ * (error level), distinct from the per-attempt `session.node.create.failed`. Re-arm is also
2652
+ * kicked from destroySessionNode/retireSessionNode (the moment the port frees) and from the
2653
+ * inbound accept path (ensure on demand), so one failure can never leave the agent deaf forever.
2587
2654
  */
2588
2655
  async #ensureStandingReceiver(agentName, correlationId = randomUUID()) {
2589
2656
  if (this.#standingReceivers.has(agentName) || this.#standingReceiverCreating.has(agentName))
@@ -2594,76 +2661,111 @@ export class SessionNodeManager {
2594
2661
  this.#standingReceiverRemoving.delete(agentName);
2595
2662
  this.#standingReceiverCreating.add(agentName);
2596
2663
  try {
2597
- const sessionId = `standing_receiver_${randomUUID()}`;
2598
- const gater = new SessionConnectionGater({
2599
- sessionId,
2600
- allowedPeerId: null, // open counterparty unknown at creation time
2601
- logger: this.#logger,
2602
- });
2603
- let node;
2604
- try {
2605
- node = await this.#factory.createNode({ sessionId, connectionGater: gater, nodeType: "standing_receiver" });
2606
- await node.start();
2607
- }
2608
- catch (err) {
2609
- this.#logger.error("session.node.create.failed", {
2610
- sessionId,
2611
- agentName: `${STANDING_RECEIVER_AGENT_NAME}:${agentName}`,
2612
- error: err instanceof Error ? err.message : String(err),
2613
- correlationId,
2614
- });
2615
- return; // not ready — callers check getStandingReceiverReady / retry via ensure on demand
2616
- }
2617
- // M2: gracefulShutdown may have begun while this node was starting (ensure runs un-awaited).
2618
- // Don't install an orphan bound to a TCP port — stop it and bail.
2619
- if (this.#shuttingDown) {
2620
- try {
2621
- await node.stop();
2664
+ let lastError = "";
2665
+ for (let attempt = 0; attempt <= this.#srRetryDelaysMs.length; attempt++) {
2666
+ if (attempt > 0) {
2667
+ await new Promise((r) => setTimeout(r, this.#srRetryDelaysMs[attempt - 1]));
2622
2668
  }
2623
- catch { /* best-effort */ }
2624
- return;
2625
- }
2626
- // L1: the agent may have gone offline (cello_stop_agent → removeStandingReceiverForAgent)
2627
- // while this ensure was parked on start(). Removal found no map entry to delete, so the
2628
- // tombstone is how we learn of it — tear the fresh node down rather than install an SR for
2629
- // an offline agent.
2630
- if (this.#standingReceiverRemoving.has(agentName)) {
2631
- this.#standingReceiverRemoving.delete(agentName);
2632
- try {
2633
- await node.stop();
2669
+ if (this.#shuttingDown)
2670
+ return;
2671
+ // L1 tombstone: the agent went offline while we were creating / backing off.
2672
+ if (this.#standingReceiverRemoving.has(agentName)) {
2673
+ this.#standingReceiverRemoving.delete(agentName);
2674
+ return;
2634
2675
  }
2635
- catch { /* best-effort */ }
2636
- return;
2676
+ const result = await this.#tryCreateStandingReceiver(agentName, correlationId);
2677
+ if (result.outcome !== "failed")
2678
+ return; // installed, or cleanly aborted (shutdown/offline)
2679
+ lastError = result.error;
2637
2680
  }
2638
- // CELLO-M7-TRANSPORT-001: wrap in a NodeAutoNatService so its dialability drives session-
2639
- // address advertisement and the transport.autonat.* events fire.
2640
- const autoNat = new NodeAutoNatService({
2641
- node,
2642
- logger: this.#logger,
2643
- nodeType: "standing_receiver",
2644
- probers: this.#autoNatProbers(),
2681
+ // M8B F14 (fix 4): an agent that WANTS a receiver has none after every attempt — the
2682
+ // deaf-agent state. Fail LOUD so it is alarm-visible instead of a quiet degradation.
2683
+ this.#logger.error("session.standing_receiver.dead", {
2684
+ agentName,
2685
+ reason: lastError,
2686
+ attempts: this.#srRetryDelaysMs.length + 1,
2687
+ correlationId,
2645
2688
  });
2646
- autoNat.emitInitialResult();
2647
- this.#standingReceivers.set(agentName, { node, gater, autoNat });
2648
- this.#logger.info("session.node.created", {
2689
+ }
2690
+ finally {
2691
+ this.#standingReceiverCreating.delete(agentName);
2692
+ }
2693
+ }
2694
+ /** One standing-receiver create attempt (extracted for the M8B F14 retry loop). */
2695
+ async #tryCreateStandingReceiver(agentName, correlationId) {
2696
+ const sessionId = `standing_receiver_${randomUUID()}`;
2697
+ const gater = new SessionConnectionGater({
2698
+ sessionId,
2699
+ allowedPeerId: null, // open — counterparty unknown at creation time
2700
+ logger: this.#logger,
2701
+ });
2702
+ let node;
2703
+ try {
2704
+ node = await this.#factory.createNode({ sessionId, connectionGater: gater, nodeType: "standing_receiver" });
2705
+ await node.start();
2706
+ }
2707
+ catch (err) {
2708
+ const error = err instanceof Error ? err.message : String(err);
2709
+ this.#logger.error("session.node.create.failed", {
2649
2710
  sessionId,
2650
2711
  agentName: `${STANDING_RECEIVER_AGENT_NAME}:${agentName}`,
2651
- sessionPeerId: node.getPeerId(),
2712
+ error,
2652
2713
  correlationId,
2653
2714
  });
2715
+ return { outcome: "failed", error };
2654
2716
  }
2655
- finally {
2656
- this.#standingReceiverCreating.delete(agentName);
2717
+ // M2: gracefulShutdown may have begun while this node was starting (ensure runs un-awaited).
2718
+ // Don't install an orphan bound to a TCP port — stop it and bail.
2719
+ if (this.#shuttingDown) {
2720
+ try {
2721
+ await node.stop();
2722
+ }
2723
+ catch { /* best-effort */ }
2724
+ return { outcome: "aborted" };
2725
+ }
2726
+ // L1: the agent may have gone offline (cello_stop_agent → removeStandingReceiverForAgent)
2727
+ // while this ensure was parked on start(). Removal found no map entry to delete, so the
2728
+ // tombstone is how we learn of it — tear the fresh node down rather than install an SR for
2729
+ // an offline agent.
2730
+ if (this.#standingReceiverRemoving.has(agentName)) {
2731
+ this.#standingReceiverRemoving.delete(agentName);
2732
+ try {
2733
+ await node.stop();
2734
+ }
2735
+ catch { /* best-effort */ }
2736
+ return { outcome: "aborted" };
2657
2737
  }
2738
+ // CELLO-M7-TRANSPORT-001: wrap in a NodeAutoNatService so its dialability drives session-
2739
+ // address advertisement and the transport.autonat.* events fire.
2740
+ const autoNat = new NodeAutoNatService({
2741
+ node,
2742
+ logger: this.#logger,
2743
+ nodeType: "standing_receiver",
2744
+ probers: this.#autoNatProbers(),
2745
+ });
2746
+ autoNat.emitInitialResult();
2747
+ this.#standingReceivers.set(agentName, { node, gater, autoNat });
2748
+ this.#logger.info("session.node.created", {
2749
+ sessionId,
2750
+ agentName: `${STANDING_RECEIVER_AGENT_NAME}:${agentName}`,
2751
+ sessionPeerId: node.getPeerId(),
2752
+ correlationId,
2753
+ });
2754
+ return { outcome: "installed" };
2658
2755
  }
2659
2756
  /**
2660
2757
  * DOD-LOOP-1: public hook for the composition root to create an agent's standing receiver when
2661
2758
  * the agent comes online (cello_start_agent), and to tear it down when it goes offline.
2759
+ * M8B F14: also called from the inbound accept path (ensure on demand). Marks the agent as
2760
+ * WANTING a receiver, which arms the teardown re-arm in destroySessionNode/retireSessionNode.
2662
2761
  */
2663
2762
  async ensureStandingReceiverForAgent(agentName) {
2763
+ this.#agentsWantingReceiver.add(agentName);
2664
2764
  await this.#ensureStandingReceiver(agentName);
2665
2765
  }
2666
2766
  async removeStandingReceiverForAgent(agentName) {
2767
+ // M8B F14: the agent no longer wants a receiver — disarm the teardown re-arm.
2768
+ this.#agentsWantingReceiver.delete(agentName);
2667
2769
  const sr = this.#standingReceivers.get(agentName);
2668
2770
  if (!sr) {
2669
2771
  // L1: an #ensureStandingReceiver for this agent may be in flight (parked on start(), so no