witan-code 0.12.2__tar.gz → 0.12.3__tar.gz

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 (99) hide show
  1. {witan_code-0.12.2 → witan_code-0.12.3}/CHANGELOG.md +25 -0
  2. {witan_code-0.12.2 → witan_code-0.12.3}/PKG-INFO +2 -2
  3. {witan_code-0.12.2 → witan_code-0.12.3}/pyproject.toml +7 -5
  4. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_remote_store.py +46 -1
  5. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/cli.py +5 -1
  6. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/remote/proxy.py +7 -1
  7. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/remote/store.py +16 -3
  8. {witan_code-0.12.2 → witan_code-0.12.3}/.gitignore +0 -0
  9. {witan_code-0.12.2 → witan_code-0.12.3}/README.md +0 -0
  10. {witan_code-0.12.2 → witan_code-0.12.3}/config/claude.json +0 -0
  11. {witan_code-0.12.2 → witan_code-0.12.3}/config/copilot.json +0 -0
  12. {witan_code-0.12.2 → witan_code-0.12.3}/config/pi.json +0 -0
  13. {witan_code-0.12.2 → witan_code-0.12.3}/docs/BRANCH_INDEXING.md +0 -0
  14. {witan_code-0.12.2 → witan_code-0.12.3}/docs/CLI_REFERENCE.md +0 -0
  15. {witan_code-0.12.2 → witan_code-0.12.3}/docs/EDGE_PRECISION_TIERS.md +0 -0
  16. {witan_code-0.12.2 → witan_code-0.12.3}/docs/PACKAGE_MAP.md +0 -0
  17. {witan_code-0.12.2 → witan_code-0.12.3}/docs/STAGE2_STITCHING.md +0 -0
  18. {witan_code-0.12.2 → witan_code-0.12.3}/docs/SYMBOL_FORMAT.md +0 -0
  19. {witan_code-0.12.2 → witan_code-0.12.3}/docs/SYMBOL_TABLE.md +0 -0
  20. {witan_code-0.12.2 → witan_code-0.12.3}/docs/USER_GUIDE.md +0 -0
  21. {witan_code-0.12.2 → witan_code-0.12.3}/install.sh +0 -0
  22. {witan_code-0.12.2 → witan_code-0.12.3}/tests/__init__.py +0 -0
  23. {witan_code-0.12.2 → witan_code-0.12.3}/tests/conftest.py +0 -0
  24. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_batched_deletes.py +0 -0
  25. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_branches.py +0 -0
  26. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_bridge.py +0 -0
  27. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_chunked_load.py +0 -0
  28. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_cli_dispatch.py +0 -0
  29. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_cli_hooks.py +0 -0
  30. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_cli_output_format.py +0 -0
  31. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_config.py +0 -0
  32. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_config_targets.py +0 -0
  33. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_context.py +0 -0
  34. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_crossrepo.py +0 -0
  35. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_edges.py +0 -0
  36. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_elicit.py +0 -0
  37. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_enrichment.py +0 -0
  38. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_github_app.py +0 -0
  39. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_graph.py +0 -0
  40. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_hooks.py +0 -0
  41. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_identity.py +0 -0
  42. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_indexer.py +0 -0
  43. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_indexer_scope.py +0 -0
  44. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_ingest.py +0 -0
  45. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_languages.py +0 -0
  46. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_maintenance.py +0 -0
  47. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_package_map.py +0 -0
  48. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_reaper.py +0 -0
  49. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_remote_proxy.py +0 -0
  50. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_repo.py +0 -0
  51. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_server.py +0 -0
  52. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_setup.py +0 -0
  53. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_stitch.py +0 -0
  54. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_store.py +0 -0
  55. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_symbol_table.py +0 -0
  56. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_tasks.py +0 -0
  57. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_views.py +0 -0
  58. {witan_code-0.12.2 → witan_code-0.12.3}/tests/test_visualize.py +0 -0
  59. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/__init__.py +0 -0
  60. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/__main__.py +0 -0
  61. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/bridge.py +0 -0
  62. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/bridge_extractors.py +0 -0
  63. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/config.py +0 -0
  64. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/context.py +0 -0
  65. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/edges.py +0 -0
  66. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/elicit.py +0 -0
  67. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/extensions/pi/codegraph.ts +0 -0
  68. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/github_app.py +0 -0
  69. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/graph.py +0 -0
  70. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/hooks.py +0 -0
  71. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/identity.py +0 -0
  72. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/indexer.py +0 -0
  73. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/ingest.py +0 -0
  74. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/maintenance.py +0 -0
  75. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/output.py +0 -0
  76. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/package_map.py +0 -0
  77. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/queries/bridge.gq +0 -0
  78. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/queries/code_mutations.gq +0 -0
  79. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/queries/code_read.gq +0 -0
  80. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/queries/delete.gq +0 -0
  81. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/queries_ts/bash.scm +0 -0
  82. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/queries_ts/hcl.scm +0 -0
  83. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/queries_ts/python.scm +0 -0
  84. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/queries_ts/sql.scm +0 -0
  85. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/queries_ts/typescript.scm +0 -0
  86. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/queries_ts/yaml.scm +0 -0
  87. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/reaper.py +0 -0
  88. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/remote/__init__.py +0 -0
  89. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/remote/oidc.py +0 -0
  90. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/repo.py +0 -0
  91. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/schema/bridge-schema.pg +0 -0
  92. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/schema/code-schema.pg +0 -0
  93. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/server.py +0 -0
  94. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/setup.py +0 -0
  95. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/skills/witan-code/SKILL.md +0 -0
  96. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/stitch.py +0 -0
  97. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/store.py +0 -0
  98. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/views.py +0 -0
  99. {witan_code-0.12.2 → witan_code-0.12.3}/witan_code/visualize.py +0 -0
@@ -6,6 +6,31 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/) (pre-1.0:
7
7
  a MINOR bump may include breaking changes).
8
8
 
9
+ ## [0.12.3] - 2026-08-07
10
+
11
+ ### Fixed
12
+
13
+ - A server-side tool error against the deployed cluster reads as a sentence
14
+ rather than a traceback. `witan-code`'s entrypoint already classified the
15
+ four remote failures the `witan` CLI does, but a tool that ran and *refused* —
16
+ a Cedar denial on a code graph the caller may not read, a branch the cluster
17
+ does not have — came back as `fastmcp.exceptions.ToolError`, which is not a
18
+ `RuntimeError` and so escaped as a traceback out of `witan-code symbols`.
19
+ - ★ Fixed on **both** of this package's transports, not just the proxy.
20
+ Index and write commands reach the deployment through `StoreRef.client()` and
21
+ `StoreSession`, which holds its own connection and does its own
22
+ classification — so classifying in `RemoteMCPProxy` alone would have left
23
+ every refusal on the store path escaping exactly as before. `StoreSession.call`
24
+ now raises `RemoteToolFailed` on both of its arms: the first attempt, and the
25
+ re-invoke after a reconnect, so a refusal that happens to follow a dropped
26
+ socket is not left as the one uncovered case.
27
+
28
+ ### Changed
29
+
30
+ - Floor bumped to `witan-core>=0.14` for `remote.proxy.RemoteToolFailed`, which
31
+ `witan_code/remote/proxy.py` re-exports at module scope. Bumped in the same
32
+ change that adds the caller, per the pin comment.
33
+
9
34
  ## [0.12.2] - 2026-08-07
10
35
 
11
36
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: witan-code
3
- Version: 0.12.2
3
+ Version: 0.12.3
4
4
  Summary: witan-code — tree-sitter code graph + cross-repo bridge (mounts under `witan code`)
5
5
  Project-URL: Homepage, https://github.com/mitodl/agent-kit/tree/main/mcp/servers/witan-code
6
6
  Project-URL: Repository, https://github.com/mitodl/agent-kit
@@ -26,7 +26,7 @@ Requires-Dist: tree-sitter-sql<0.4,>=0.3
26
26
  Requires-Dist: tree-sitter-typescript<0.24,>=0.23
27
27
  Requires-Dist: tree-sitter-yaml<0.8,>=0.7
28
28
  Requires-Dist: tree-sitter<0.26,>=0.25
29
- Requires-Dist: witan-core[cli,observability,remote]<1,>=0.12
29
+ Requires-Dist: witan-core[cli,observability,remote]<1,>=0.14
30
30
  Provides-Extra: tasks
31
31
  Requires-Dist: fastmcp-tasks<5,>=4.0.0b1; extra == 'tasks'
32
32
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "witan-code"
3
- version = "0.12.2"
3
+ version = "0.12.3"
4
4
  description = "witan-code — tree-sitter code graph + cross-repo bridge (mounts under `witan code`)"
5
5
  readme = "README.md"
6
6
  license = "BSD-3-Clause"
@@ -22,11 +22,13 @@ dependencies = [
22
22
  # and it has now been tripped THREE times. If you add a witan_core symbol in
23
23
  # the same change as its caller, bump this line in that change: the
24
24
  # workspace resolves witan-core by path, so nothing here can catch it.
25
- # (>=0.11 was required for chunking.MCP_LOAD_MAX_BYTES, evaluated as a
26
- # default argument; >=0.10 for witan_core.chunking + load_batch, both moved
27
- # up from this package; >=0.9 for observability.middleware; >=0.8 for
25
+ # (>=0.14 was required for remote.proxy.RemoteToolFailed, re-exported at
26
+ # module scope by witan_code/remote/proxy.py and named by cli.py's cli();
27
+ # >=0.11 for chunking.MCP_LOAD_MAX_BYTES, evaluated as a default argument;
28
+ # >=0.10 for witan_core.chunking + load_batch, both moved up from this
29
+ # package; >=0.9 for observability.middleware; >=0.8 for
28
30
  # OmnigraphClient.change_many with chunk_size.)
29
- "witan-core[cli,remote,observability]>=0.12,<1",
31
+ "witan-core[cli,remote,observability]>=0.14,<1",
30
32
  "fastmcp>=3.4.2,<5",
31
33
  "cyclopts>=4,<5",
32
34
  # [targets.<name>] override models (config.py) — also transitively pulled
@@ -459,6 +459,7 @@ def test_a_dropped_socket_is_still_retried_after_the_size_guard():
459
459
  def test_an_ordinary_tool_failure_is_not_read_as_a_size_refusal():
460
460
  """A tool error relays the server's text, which can quote the caller's data."""
461
461
  from fastmcp.exceptions import ToolError
462
+ from witan_code.remote.store import RemoteToolFailed
462
463
 
463
464
  log: list = []
464
465
  session = StoreSession(
@@ -466,7 +467,51 @@ def test_an_ordinary_tool_failure_is_not_read_as_a_size_refusal():
466
467
  lambda: "jwt",
467
468
  lambda _t: _RefusesForSize(log, ToolError("no view named 'payload-413'")),
468
469
  )
469
- with pytest.raises(ToolError):
470
+ with pytest.raises(RemoteToolFailed) as caught:
471
+ RemoteStoreClient(REPO, session).list_branches()
472
+ assert not isinstance(caught.value, RemotePayloadTooLarge)
473
+
474
+
475
+ def test_a_refused_store_call_reads_as_a_sentence_not_a_traceback():
476
+ """This session is witan-code's OTHER transport, and it needs the same fix.
477
+
478
+ Index and write commands reach the deployment through `StoreRef.client()`
479
+ and this session, not through `RemoteMCPProxy` — so classifying refusals in
480
+ the proxy alone left every one of them escaping as a raw `ToolError`, which
481
+ is not a `RuntimeError` and so slips past `cli()`'s guard tuple.
482
+ """
483
+ from fastmcp.exceptions import ToolError
484
+ from witan_code.remote.store import RemoteToolFailed
485
+
486
+ refusal = ToolError("cedar: read denied on graph 'code'")
487
+ session = StoreSession(
488
+ "http://x/mcp", lambda: "jwt", lambda _t: _RefusesForSize([], refusal)
489
+ )
490
+ with pytest.raises(RemoteToolFailed, match="cedar: read denied") as caught:
491
+ RemoteStoreClient(REPO, session).list_branches()
492
+ assert isinstance(caught.value, RuntimeError)
493
+ assert caught.value.__cause__ is refusal
494
+
495
+
496
+ def test_a_refusal_on_the_post_reconnect_retry_is_classified_too():
497
+ """A refusal that happens to follow a dropped socket takes the other arm.
498
+
499
+ The generic arm reconnects and re-invokes; classifying only the first
500
+ attempt would let exactly the same refusal escape as a traceback whenever
501
+ it landed after a dead connection rather than before one.
502
+ """
503
+ from fastmcp.exceptions import ToolError
504
+ from witan_code.remote.store import RemoteToolFailed
505
+
506
+ log: list = []
507
+ clients = iter(
508
+ [
509
+ _FakeClient(log, fail_first=True),
510
+ _RefusesForSize(log, ToolError("no view named 'branches'")),
511
+ ]
512
+ )
513
+ session = StoreSession("http://x/mcp", lambda: "jwt", lambda _t: next(clients))
514
+ with pytest.raises(RemoteToolFailed, match="no view named 'branches'"):
470
515
  RemoteStoreClient(REPO, session).list_branches()
471
516
 
472
517
 
@@ -1012,7 +1012,7 @@ def cli() -> None:
1012
1012
  from rich.console import Console
1013
1013
 
1014
1014
  from .remote.oidc import RemoteAuthError
1015
- from .remote.proxy import RemoteToolUnavailable, RemoteUnreachable
1015
+ from .remote.proxy import RemoteToolFailed, RemoteToolUnavailable, RemoteUnreachable
1016
1016
  from .remote.store import RemotePayloadTooLarge
1017
1017
 
1018
1018
  try:
@@ -1022,9 +1022,13 @@ def cli() -> None:
1022
1022
  # rejected, printed a traceback out of `witan-code symbols`.
1023
1023
  # RemotePayloadTooLarge comes from the store session rather than the proxy:
1024
1024
  # this CLI's oversized bodies are index batches, not tool arguments.
1025
+ # RemoteToolFailed covers the tool running and refusing — a Cedar denial on
1026
+ # a code graph the caller may not read, or a branch the cluster does not
1027
+ # have.
1025
1028
  except (
1026
1029
  RemoteAuthError,
1027
1030
  RemotePayloadTooLarge,
1031
+ RemoteToolFailed,
1028
1032
  RemoteToolUnavailable,
1029
1033
  RemoteUnreachable,
1030
1034
  ) as exc:
@@ -16,11 +16,17 @@ from typing import Callable
16
16
  from witan_core.remote.config import RemoteConfig
17
17
  from witan_core.remote.proxy import (
18
18
  RemoteMCPProxy,
19
+ RemoteToolFailed,
19
20
  RemoteToolUnavailable,
20
21
  RemoteUnreachable,
21
22
  )
22
23
 
23
- __all__ = ["RemoteServerProxy", "RemoteToolUnavailable", "RemoteUnreachable"]
24
+ __all__ = [
25
+ "RemoteServerProxy",
26
+ "RemoteToolFailed",
27
+ "RemoteToolUnavailable",
28
+ "RemoteUnreachable",
29
+ ]
24
30
 
25
31
  # Tools that only mean anything against a local checkout. `code_reindex` IS
26
32
  # registered on the deployment (it is the same server module), but running it
@@ -33,7 +33,11 @@ from fastmcp.client.auth import BearerAuth
33
33
  from fastmcp.client.transports import StreamableHttpTransport
34
34
  from fastmcp.exceptions import ToolError
35
35
  from witan_core.observability import get_logger
36
- from witan_core.remote.proxy import RemotePayloadTooLarge, payload_too_large
36
+ from witan_core.remote.proxy import (
37
+ RemotePayloadTooLarge,
38
+ RemoteToolFailed,
39
+ payload_too_large,
40
+ )
37
41
 
38
42
  from witan_core import chunking
39
43
 
@@ -41,6 +45,7 @@ __all__ = [
41
45
  "RemotePayloadTooLarge",
42
46
  "RemoteStoreClient",
43
47
  "RemoteStoreUnsupported",
48
+ "RemoteToolFailed",
44
49
  "StoreSession",
45
50
  "close_sessions",
46
51
  "session_for",
@@ -181,7 +186,7 @@ class StoreSession:
181
186
  # The server ran the tool and it failed — a refusal, a bad
182
187
  # query, a store error. Reconnecting would only run it again.
183
188
  _refuse_if_too_large(exc, tool, self.url)
184
- raise
189
+ raise RemoteToolFailed(str(exc)) from exc
185
190
  except Exception as exc: # noqa: BLE001 — transport-shaped; retry once
186
191
  _refuse_if_too_large(exc, tool, self.url)
187
192
  # Info: one reconnect is routine (idle session dropped), but a
@@ -190,7 +195,15 @@ class StoreSession:
190
195
  logger.info("witan.code.remote.reconnecting", tool=tool, exc_info=True)
191
196
  self._disconnect()
192
197
  self._connect()
193
- return self._invoke(tool, arguments)
198
+ try:
199
+ return self._invoke(tool, arguments)
200
+ except ToolError as refused:
201
+ # The reconnect succeeded and the server refused the retry.
202
+ # Classified here too, or a refusal that happened to follow
203
+ # a dropped socket escapes as the raw traceback the first
204
+ # arm exists to prevent.
205
+ _refuse_if_too_large(refused, tool, self.url)
206
+ raise RemoteToolFailed(str(refused)) from refused
194
207
 
195
208
  def has_tool(self, tool: str) -> bool:
196
209
  """Whether the deployment serves ``tool``.
File without changes
File without changes
File without changes
File without changes