@yahyahammad/venastine 0.1.0 → 0.3.8

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 (130) hide show
  1. package/.env.example +19 -14
  2. package/CONFIG_ARCHITECTURE.md +2002 -0
  3. package/NOTICE +1 -1
  4. package/README.md +249 -93
  5. package/agents/builtin/build.md +73 -0
  6. package/agents/builtin/general.md +80 -0
  7. package/agents/builtin/plan.md +23 -5
  8. package/agents/builtin/test.md +65 -0
  9. package/agents/builtin/writer.md +67 -0
  10. package/agents/manager.py +261 -195
  11. package/agents/subagent_tool.py +280 -23
  12. package/agents/tui_commands.py +31 -21
  13. package/bin/venastine.mjs +528 -382
  14. package/bin/venastine.py +71 -0
  15. package/cli_commands.py +835 -0
  16. package/config.py +95 -1198
  17. package/config.yaml +1090 -0
  18. package/config_edit.py +1301 -0
  19. package/config_schema.py +966 -0
  20. package/config_update.py +749 -0
  21. package/core/agent_activity.py +256 -0
  22. package/core/ansi.py +452 -0
  23. package/core/approval.py +27 -5
  24. package/core/call_view.py +364 -0
  25. package/core/cancel.py +121 -0
  26. package/core/chatgpt_auth.py +747 -0
  27. package/core/claims_view.py +107 -0
  28. package/core/client.py +1249 -82
  29. package/core/commands.py +454 -0
  30. package/core/compaction.py +1735 -959
  31. package/core/config_loader.py +516 -97
  32. package/core/connect.py +686 -0
  33. package/core/events.py +68 -6
  34. package/core/file_mentions.py +280 -0
  35. package/core/interaction.py +87 -4
  36. package/core/line_pattern.py +128 -0
  37. package/core/loop.py +2566 -1353
  38. package/core/memory.py +482 -370
  39. package/core/pipeline_models.py +23 -9
  40. package/core/provider_errors.py +234 -0
  41. package/core/reasoning/confidence_scoring.py +70 -54
  42. package/core/reasoning/json_retry.py +19 -1
  43. package/core/reasoning/orchestrator.py +232 -53
  44. package/core/reasoning/output_writer.py +90 -31
  45. package/core/reasoning/payload_validation.py +133 -7
  46. package/core/reasoning/pipeline_storage.py +427 -361
  47. package/core/reasoning/review.py +659 -615
  48. package/core/reasoning/scholar.py +38 -14
  49. package/core/reasoning/source_corpus.py +110 -4
  50. package/core/replay.py +315 -167
  51. package/core/session.py +36 -12
  52. package/core/session_view.py +259 -0
  53. package/core/session_wake.py +259 -0
  54. package/core/shell_sessions.py +1553 -0
  55. package/core/workspace_trust.py +1 -1
  56. package/credentials.py +308 -180
  57. package/database.py +82 -1
  58. package/{PRIVACY.md → docs/PRIVACY.md} +19 -7
  59. package/docs/SECURITY.md +108 -0
  60. package/docs/THIRD_PARTY_NOTICES.md +148 -0
  61. package/env_secrets.py +118 -77
  62. package/json_store.py +236 -16
  63. package/logging_setup.py +121 -11
  64. package/main.py +1672 -198
  65. package/mcp_client/client.py +257 -23
  66. package/mcp_client/config.py +484 -379
  67. package/mcp_client/registration.py +163 -2
  68. package/memories/manager.py +15 -0
  69. package/memories/tui_commands.py +21 -14
  70. package/package.json +303 -73
  71. package/project_init/config_files.py +4 -0
  72. package/project_init/generator.py +201 -37
  73. package/project_init/manifest.py +418 -406
  74. package/project_init/tui_commands.py +7 -4
  75. package/prompts/revalidate.md +1 -1
  76. package/prompts/revise.md +17 -15
  77. package/prompts/system_prompts.py +64 -10
  78. package/providers.json.example +94 -92
  79. package/pyproject.toml +149 -100
  80. package/requirements.txt +252 -29
  81. package/safety/policy_enforcement.py +1082 -682
  82. package/security/askpass.py +419 -0
  83. package/security/capability.py +37 -7
  84. package/security/confine.py +484 -0
  85. package/security/hosted.py +182 -0
  86. package/security/permissions.py +54 -7
  87. package/security/posture.py +124 -12
  88. package/security/protected_paths.py +198 -6
  89. package/security/sandbox.py +3262 -139
  90. package/security/secrets.py +855 -0
  91. package/skills/tui_commands.py +3 -4
  92. package/storage.py +1338 -1005
  93. package/tools/base.py +465 -305
  94. package/tools/builtin/_math_common.py +306 -16
  95. package/tools/builtin/_net_common.py +267 -61
  96. package/tools/builtin/arxiv.py +681 -223
  97. package/tools/builtin/ask_user.py +231 -213
  98. package/tools/builtin/discrete_math.py +35 -4
  99. package/tools/builtin/fetch_url.py +239 -21
  100. package/tools/builtin/file_ops.py +341 -33
  101. package/tools/builtin/geometry.py +184 -148
  102. package/tools/builtin/get_time.py +2 -2
  103. package/tools/builtin/linear_algebra.py +66 -23
  104. package/tools/builtin/load_skill.py +10 -0
  105. package/tools/builtin/logic.py +171 -12
  106. package/tools/builtin/pin.py +46 -12
  107. package/tools/builtin/probability_stats.py +224 -228
  108. package/tools/builtin/project_docs.py +80 -21
  109. package/tools/builtin/remember.py +21 -4
  110. package/tools/builtin/shell.py +586 -67
  111. package/tools/builtin/shell_sessions.py +613 -0
  112. package/tools/builtin/symbolic_math.py +80 -10
  113. package/tools/builtin/todo.py +5 -3
  114. package/tools/builtin/web_search.py +329 -151
  115. package/tools/context.py +23 -0
  116. package/tools/isolation.py +387 -314
  117. package/tools/registry.py +374 -29
  118. package/tui/app.py +5281 -397
  119. package/tui/app.tcss +290 -9
  120. package/tui/commands.py +26 -61
  121. package/tui/diffs.py +286 -265
  122. package/tui/history.py +128 -0
  123. package/tui/hosted_driver.py +102 -0
  124. package/tui/markdown.py +1329 -0
  125. package/tui/meters.py +364 -0
  126. package/tui/screens.py +346 -92
  127. package/tui/themes.py +599 -366
  128. package/tui/widgets.py +2673 -116
  129. package/SECURITY.md +0 -88
  130. package/THIRD_PARTY_NOTICES.md +0 -100
@@ -40,20 +40,24 @@ loop"; it is "do it inside _manager".
40
40
 
41
41
  import asyncio
42
42
  import contextlib
43
+ import json
43
44
  import logging
44
45
  import threading
45
46
  import time
46
47
  from typing import Optional
47
48
 
48
- import config as _harness_config
49
49
  from mcp import Client
50
50
  from mcp.client.sse import sse_client
51
51
  from mcp.client.stdio import StdioServerParameters, stdio_client
52
52
  from mcp.client.streamable_http import (
53
- create_mcp_http_client, streamable_http_client,
53
+ create_mcp_http_client,
54
+ streamable_http_client,
54
55
  )
55
56
  from mcp.shared.exceptions import MCPError
56
57
 
58
+ import config as _harness_config
59
+ from safety.policy_enforcement import TOKEN_CHARS, fragment_end
60
+
57
61
  logger = logging.getLogger(__name__)
58
62
 
59
63
  # Rev. 1 S12: MCP servers are third-party code and can hang. A generous default
@@ -70,6 +74,19 @@ SHUTDOWN_TIMEOUT_S = 15.0
70
74
  # single name to shrink.
71
75
  TEARDOWN_BUDGET_S = _harness_config.TEARDOWN_BUDGET_S
72
76
 
77
+ # How much of a structured error payload rides in the error STRING.
78
+ # D23 promises call_tool() returns one error shape, so a server's
79
+ # structured_content on a failure belongs inside that string rather than
80
+ # in a second key every consumer of a dispatch error would have to learn
81
+ # (A32). Bounded because the payload is third-party and the string reaches
82
+ # a model: 500 is room for the {code, retry_after, message} an error
83
+ # payload actually carries, and the cut is visible for the reason
84
+ # _catalog_text's is.
85
+ #
86
+ # The result AS A WHOLE has its own bound, `max_read_chars` (A79); see
87
+ # _normalize.
88
+ MAX_ERROR_DETAIL_CHARS = 500
89
+
73
90
  # Per-server, inside the manager. CONNECT_TIMEOUT_S is the caller-side
74
91
  # budget for ALL servers together; without a per-server bound one hung
75
92
  # handshake spends it and every server after it in the loop is starved of
@@ -154,7 +171,68 @@ def _shutdown_loop(join_timeout: float = SHUTDOWN_TIMEOUT_S) -> None:
154
171
  _thread = None
155
172
 
156
173
 
157
- def _normalize(result) -> dict:
174
+ def _detail(structured) -> str:
175
+ """A structured payload as one bounded line, for the error string.
176
+
177
+ default=str so a payload holding something JSON cannot carry is still
178
+ reported rather than raising inside the error path -- D23's promise
179
+ that this module returns one error shape has to mean always, which is
180
+ the same argument the broad except in call_tool() makes.
181
+ """
182
+ try:
183
+ rendered = json.dumps(structured, default=str, sort_keys=True)
184
+ except Exception:
185
+ rendered = repr(structured)
186
+ rendered = " ".join(rendered.split())
187
+ if len(rendered) <= MAX_ERROR_DETAIL_CHARS:
188
+ return rendered
189
+ return rendered[:MAX_ERROR_DETAIL_CHARS - 1].rstrip() + "\u2026"
190
+
191
+
192
+ def _cut(text: str, limit: int) -> str:
193
+ """The first *limit* characters of *text*, less a word the cut split.
194
+
195
+ The redactor runs after this, on the dispatch path, and cannot match
196
+ half a credential. So when the character past the cut is a token
197
+ character, the token-character run the cut ends inside goes too: the
198
+ rule A72 made for a shell session's dropped middle. A cut that fell
199
+ between two words drops nothing more.
200
+ """
201
+ if len(text) <= limit:
202
+ return text
203
+ kept = text[:limit]
204
+ if text[limit] in TOKEN_CHARS:
205
+ kept = kept[:fragment_end(kept)]
206
+ return kept
207
+
208
+
209
+ def _json_chars(structured) -> Optional[int]:
210
+ """How many characters *structured* takes as JSON, or None when it
211
+ cannot be rendered -- which _normalize reads as too large to keep,
212
+ since nothing can say how large it is."""
213
+ try:
214
+ return len(json.dumps(structured, default=str, ensure_ascii=False))
215
+ except Exception:
216
+ return None
217
+
218
+
219
+ def _repeats(structured, text: str) -> bool:
220
+ """Whether *structured* is the server's text over again.
221
+
222
+ The SDK's own server sends a tool that returns a string as that text
223
+ AND as `{"result": <the text>}`, and a typed return as the JSON in
224
+ both places. A dropped copy of the text is no loss, and the note says
225
+ so, so the model does not call again for something it already has.
226
+ """
227
+ if structured == {"result": text}:
228
+ return True
229
+ try:
230
+ return json.loads(text) == structured
231
+ except Exception:
232
+ return False
233
+
234
+
235
+ def _normalize(result, tool_name: str = "") -> dict:
158
236
  """CallToolResult -> the plain dict shape every other tool handler
159
237
  returns (D23).
160
238
 
@@ -187,24 +265,117 @@ def _normalize(result) -> dict:
187
265
  v2 renamed these fields to snake_case (.content/.structured_content/
188
266
  .is_error); §17's sketch reads the v1 camelCase spellings and would
189
267
  silently see is_error as always-False against v2.
268
+
269
+ THE RESULT IS BOUNDED HERE, AS A WHOLE, AT `max_read_chars` (A79).
270
+ Every other producer of third-party text bounds what it hands on, and
271
+ this one handed on anything: 10 MB of text, of structured content or
272
+ of an error message went through whole, into the thread and the
273
+ model's context, behind a redaction pass that took 1.2-2.5 s over it.
274
+ The server's text is cut at the bound with a note giving the size it
275
+ had. A structured payload is kept whole if it fits in what the text
276
+ left of the bound, and otherwise dropped with a note -- never cut,
277
+ since a JSON document cut short can read as complete. A server that
278
+ follows the MCP spec sends structured output as text as well, so the
279
+ text usually carries what was dropped, and the note says when it was
280
+ a repeat (see `_repeats`). The bound is `max_read_chars`
281
+ because it is already how much one read is, and the compaction
282
+ headroom check measures a read against it.
190
283
  """
284
+ bound = int(_harness_config.MAX_READ_CHARS)
191
285
  blocks = getattr(result, "content", None) or []
192
- text = "\n".join(
193
- b.text for b in blocks
194
- if getattr(b, "type", None) == "text" and getattr(b, "text", None)
195
- )
196
- if not text and blocks:
197
- # Non-text blocks (images, embedded resources) are dropped to a
198
- # placeholder: the harness has no multimodal tool-result path, and
199
- # inventing one here is scope the rest of the design can't carry.
200
- kinds = sorted({getattr(b, "type", "unknown") for b in blocks})
201
- text = f"[non-text MCP content: {', '.join(kinds)}]"
286
+ kept, dropped = [], []
287
+ for block in blocks:
288
+ kind = getattr(block, "type", None) or "unknown"
289
+ if kind == "text":
290
+ value = getattr(block, "text", None)
291
+ if value:
292
+ kept.append(value)
293
+ # AN EMPTY TEXT BLOCK HAS NOTHING TO DROP. It is filtered out
294
+ # of the join either way, but counting it as dropped content
295
+ # made the placeholder contradict itself -- `text("")` came
296
+ # back as "[non-text MCP content: text]", reporting the kind
297
+ # as non-text when the kind is text.
298
+ continue
299
+ dropped.append(kind)
300
+
301
+ full = "\n".join(kept)
302
+ text = _cut(full, bound)
303
+ sent, shown = len(full), len(text)
304
+ if dropped:
305
+ # APPENDED, NOT SUBSTITUTED (A32). Non-text blocks (images,
306
+ # embedded resources) are still dropped -- the harness has no
307
+ # multimodal tool-result path, and inventing one here is scope the
308
+ # rest of the design can't carry. What changed is WHEN the
309
+ # disclosure happens: the placeholder used to fire only when NO
310
+ # text survived, so a result carrying text AND non-text dropped
311
+ # the non-text silently, and "Chart generated:" with no chart and
312
+ # no note is a result the model will answer from. CallToolResult.
313
+ # content is a REQUIRED list of mixed block types on the installed
314
+ # SDK, so that shape is first-class in the protocol rather than
315
+ # hypothetical.
316
+ kinds = ", ".join(sorted(set(dropped)))
317
+ note = f"[non-text MCP content: {kinds}]"
318
+ text = f"{text}\n{note}" if text else note
319
+ # ONE WARNING NAMING THE TOOL AND WHAT CHANGED, which is the rule
320
+ # #49 was filed to establish and which this function broke on all
321
+ # three of its dropping paths. The tool name is a PARAMETER
322
+ # because this function could not name the tool -- it took the
323
+ # result alone, so the rule was unsatisfiable here as written.
324
+ logger.warning(
325
+ "MCP tool %s returned %d non-text block(s) (%s); this harness "
326
+ "has no multimodal tool-result path, so they were dropped and "
327
+ "the result says so in band.",
328
+ tool_name or "<unknown>", len(dropped), kinds)
329
+
330
+ if shown < sent:
331
+ # After the non-text note, so neither note is what the cut takes.
332
+ note = (f"[MCP result cut: the server sent {sent:,} characters of "
333
+ f"text, and the {shown:,} shown end at the last word break "
334
+ f"inside the bound, max_read_chars ({bound:,})]")
335
+ text = f"{text}\n{note}" if text else note
336
+ logger.warning(
337
+ "MCP tool %s returned %d characters of text; it was cut to %d "
338
+ "(max_read_chars is %d) and the result says so in band.",
339
+ tool_name or "<unknown>", sent, shown, bound)
202
340
 
341
+ structured = getattr(result, "structured_content", None)
203
342
  if getattr(result, "is_error", False):
204
- return {"error": text or "MCP tool call failed"}
343
+ message = text or "MCP tool call failed"
344
+ if structured is not None:
345
+ # D23's ONE error shape, not a second key (A32): a server
346
+ # reporting {code: 429, retry_after: 30} used to lose it
347
+ # entirely, so the one thing that would have explained the
348
+ # failure was the one thing dropped.
349
+ detail = _detail(structured)
350
+ message = f"{message} (server detail: {detail})"
351
+ logger.warning(
352
+ "MCP tool %s failed with a structured payload; it is "
353
+ "folded into the error string: %s",
354
+ tool_name or "<unknown>", detail)
355
+ return {"error": message}
356
+
357
+ if structured is not None:
358
+ size, room = _json_chars(structured), bound - shown
359
+ if size is None or size > room:
360
+ if size is None:
361
+ why = "it could not be rendered as JSON to be measured"
362
+ else:
363
+ why = (f"it is {size:,} characters as JSON, and the text "
364
+ f"left {room:,} of the bound, max_read_chars "
365
+ f"({bound:,})")
366
+ if _repeats(structured, full):
367
+ why += "; it repeats the server's text"
368
+ note = f"[MCP structured result dropped: {why}]"
369
+ text = f"{text}\n{note}" if text else note
370
+ logger.warning(
371
+ "MCP tool %s returned structured content of %s characters "
372
+ "with %d left of max_read_chars; it was dropped and the "
373
+ "result says so in band.",
374
+ tool_name or "<unknown>",
375
+ "unmeasurable" if size is None else size, room)
376
+ structured = None
205
377
 
206
378
  out = {"content": text}
207
- structured = getattr(result, "structured_content", None)
208
379
  if structured is not None:
209
380
  out["result"] = structured
210
381
  return out
@@ -259,8 +430,6 @@ class MCPClient:
259
430
  headers=dict(cfg.headers) or None,
260
431
  )
261
432
  if cfg.transport == "http":
262
- if not cfg.headers:
263
- return cfg.url
264
433
  # `headers` was parsed into ServerConfig and then never used:
265
434
  # a bare URL carries none of them, so a server configured with
266
435
  # an Authorization header connected UNAUTHENTICATED, with
@@ -268,13 +437,49 @@ class MCPClient:
268
437
  # live on the httpx2 client, and the SDK ships the helper that
269
438
  # applies its own MCP defaults alongside them -- so this uses
270
439
  # that rather than hand-building a client and losing the
271
- # SSE-friendly timeouts.
440
+ # SSE-friendly timeouts. Without headers the SDK builds its own
441
+ # client, exactly as Client() does for a bare URL.
442
+ #
443
+ # NEVER a bare URL now, even without headers (batch 208): mcp
444
+ # 2.3.0 fails a call whose one server-sent event exceeds
445
+ # `max_sse_event_size`, and a bare URL takes the SDK's 1 MiB,
446
+ # which a streamed screenshot passes. config.yaml's
447
+ # `mcp_max_event_bytes` is the ceiling, read per connection. It
448
+ # bounds STREAMED answers only: one sent as plain JSON is read
449
+ # whole (CONFIG_ARCHITECTURE.md has the measurement). The legacy
450
+ # "sse" branch above keeps the SDK's fixed 1 MiB: `sse_client`
451
+ # takes no size.
272
452
  return streamable_http_client(
273
453
  cfg.url,
274
- http_client=create_mcp_http_client(headers=dict(cfg.headers)),
454
+ http_client=(create_mcp_http_client(headers=dict(cfg.headers))
455
+ if cfg.headers else None),
456
+ max_sse_event_size=_harness_config.MCP_MAX_EVENT_BYTES,
275
457
  )
276
458
  raise ValueError(cfg.error or "unusable server configuration")
277
459
 
460
+ @staticmethod
461
+ def _reason(e: BaseException, budget: Optional[float] = None) -> str:
462
+ """Why a server is unusable, in one string for BOTH consumers.
463
+
464
+ Batch 121, from the owner's log: `MCP server 'joplin' failed to
465
+ connect: ` and nothing after the colon. The per-server
466
+ asyncio.timeout raises TimeoutError, whose str() is "" -- so the
467
+ %s below rendered nothing, and the one message that explains a
468
+ silent MCP named no cause at all.
469
+
470
+ It was also TWO strings: `failures` carried the exception type and
471
+ the log line did not, so the better of the two never reached the
472
+ place a user looks first. One copy now, and the timeout names its
473
+ budget because "it timed out" without a duration leaves the
474
+ reader unable to tell a dead server from a slow one.
475
+ """
476
+ text = str(e)
477
+ if text:
478
+ return f"{type(e).__name__}: {text}"
479
+ if isinstance(e, TimeoutError) and budget is not None:
480
+ return f"{type(e).__name__} (no handshake within {budget}s)"
481
+ return type(e).__name__
482
+
278
483
  async def _manager(self):
279
484
  """Owns the AsyncExitStack for the whole process lifetime, in ONE
280
485
  task. See the module docstring -- this shape is required, not
@@ -313,9 +518,10 @@ class MCPClient:
313
518
  # others, or a single stale entry makes the whole
314
519
  # harness unusable. §17's sketch had no try/except
315
520
  # here at all.
316
- self.failures[name] = f"{type(e).__name__}: {e}"
521
+ why = self._reason(e, SERVER_CONNECT_TIMEOUT_S)
522
+ self.failures[name] = why
317
523
  logger.warning("MCP server %r failed to connect: %s",
318
- name, e)
524
+ name, why)
319
525
  self._ready.set()
320
526
  await self._shutdown.wait()
321
527
  except Exception:
@@ -331,6 +537,17 @@ class MCPClient:
331
537
  ordinary startup code; the bridge does the rest."""
332
538
  if not self.server_configs:
333
539
  return
540
+ if self._task is not None:
541
+ # #219, batch 213, the owner's choice of raising over tearing
542
+ # down first. Every attribute below is rebound, so a second call
543
+ # used to abandon the first generation's manager parked on a
544
+ # `_shutdown` nothing could set any more -- its child processes
545
+ # with it, and no straggler warning. Nothing reconnects today
546
+ # (one call site, main.py); F7's runtime /mcp would, and it has
547
+ # to disconnect on purpose.
548
+ raise RuntimeError(
549
+ "connect_all() on an MCP client that is already connected; "
550
+ "call disconnect_all() first")
334
551
  loop = _ensure_loop()
335
552
 
336
553
  async def _start():
@@ -340,8 +557,9 @@ class MCPClient:
340
557
  self._task = loop.create_task(self._manager())
341
558
  await self._ready.wait()
342
559
 
560
+ started = asyncio.run_coroutine_threadsafe(_start(), loop)
343
561
  try:
344
- asyncio.run_coroutine_threadsafe(_start(), loop).result(timeout=timeout)
562
+ started.result(timeout=timeout)
345
563
  except Exception:
346
564
  # A timeout here used to abandon the manager permanently. It
347
565
  # would still be parked mid-connect holding every child process
@@ -350,6 +568,19 @@ class MCPClient:
350
568
  # server orphaned every other server's subprocess -- the exact
351
569
  # inversion of this file's "one unreachable server must never
352
570
  # take down the others" invariant.
571
+ #
572
+ # `started` IS RELEASED TOO (A33), and it is a different object
573
+ # from the manager: _start() is still awaiting _ready when the
574
+ # caller's budget runs out, and the two lines below stop the
575
+ # loop out from under it. Left pending, asyncio reports "Task
576
+ # was destroyed but it is pending!" through its own logger at
577
+ # whatever moment the GC gets to it -- and the TUI's
578
+ # TranscriptLogHandler is on the ROOT logger, so that line can
579
+ # surface in a user's transcript naming nothing and
580
+ # attributable to nothing. Cancelled FIRST, while the loop is
581
+ # still running to deliver it; _cancel_manager() needs the
582
+ # same loop alive and _shutdown_loop() is what ends it.
583
+ started.cancel()
353
584
  self._cancel_manager()
354
585
  self.clients.clear()
355
586
  self._catalogs.clear()
@@ -392,7 +623,7 @@ class MCPClient:
392
623
  read_timeout_seconds=protocol_timeout)
393
624
  future = asyncio.run_coroutine_threadsafe(coro, loop)
394
625
  try:
395
- return _normalize(future.result(timeout=timeout))
626
+ return _normalize(future.result(timeout=timeout), tool_name)
396
627
  except MCPError as e:
397
628
  # v2 raises for protocol-level failures -- including timeout,
398
629
  # which is code -32001 -- where v1 reported everything in
@@ -495,5 +726,8 @@ class MCPClient:
495
726
 
496
727
  self.clients.clear()
497
728
  self._catalogs.clear()
729
+ # #219. Keyed by server name, so a clean close kept from this
730
+ # generation would answer for the next one's straggler check.
731
+ self._closed.clear()
498
732
  self._task = None
499
733
  _shutdown_loop(join_timeout=max(0.5, remaining()))