witan-code 0.13.0__tar.gz → 0.13.2__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.
- {witan_code-0.13.0 → witan_code-0.13.2}/CHANGELOG.md +41 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/PKG-INFO +2 -2
- {witan_code-0.13.0 → witan_code-0.13.2}/pyproject.toml +42 -4
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_remote_proxy.py +23 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/cli.py +13 -3
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/remote/oidc.py +17 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/remote/proxy.py +9 -2
- {witan_code-0.13.0 → witan_code-0.13.2}/.gitignore +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/README.md +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/config/claude.json +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/config/copilot.json +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/config/pi.json +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/docs/BRANCH_INDEXING.md +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/docs/CLI_REFERENCE.md +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/docs/EDGE_PRECISION_TIERS.md +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/docs/PACKAGE_MAP.md +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/docs/STAGE2_STITCHING.md +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/docs/SYMBOL_FORMAT.md +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/docs/SYMBOL_TABLE.md +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/docs/USER_GUIDE.md +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/install.sh +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/__init__.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/conftest.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_batched_deletes.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_branches.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_bridge.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_chunked_load.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_cli_dispatch.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_cli_hooks.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_cli_output_format.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_config.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_config_targets.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_context.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_crossrepo.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_edges.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_elicit.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_enrichment.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_github_app.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_graph.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_hooks.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_identity.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_indexer.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_indexer_scope.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_ingest.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_languages.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_maintenance.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_package_map.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_reaper.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_remote_store.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_repo.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_server.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_setup.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_stitch.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_store.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_symbol_table.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_tasks.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_views.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/tests/test_visualize.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/__init__.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/__main__.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/bridge.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/bridge_extractors.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/config.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/context.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/edges.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/elicit.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/extensions/pi/codegraph.ts +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/github_app.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/graph.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/hooks.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/identity.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/indexer.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/ingest.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/maintenance.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/output.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/package_map.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/queries/bridge.gq +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/queries/code_mutations.gq +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/queries/code_read.gq +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/queries/delete.gq +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/queries_ts/bash.scm +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/queries_ts/hcl.scm +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/queries_ts/python.scm +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/queries_ts/sql.scm +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/queries_ts/typescript.scm +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/queries_ts/yaml.scm +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/reaper.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/remote/__init__.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/remote/store.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/repo.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/schema/bridge-schema.pg +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/schema/code-schema.pg +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/server.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/setup.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/skills/witan-code/SKILL.md +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/stitch.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/store.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/views.py +0 -0
- {witan_code-0.13.0 → witan_code-0.13.2}/witan_code/visualize.py +0 -0
|
@@ -6,6 +6,47 @@ 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.13.2] - 2026-08-17
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **Raised the `witan-core` floor to `>=0.23`**, continuing the behavioural
|
|
14
|
+
floor added in 0.13.1 and for a reason specific to this package's write path.
|
|
15
|
+
|
|
16
|
+
0.22 retried `recovery_required` on a write; 0.23 makes it terminal, because
|
|
17
|
+
the same response can also mean the write's table effects already landed. The
|
|
18
|
+
ambiguous half of that is a **foreign writer** winning after local
|
|
19
|
+
arbitration — and this package's branched clients are exactly that, falling
|
|
20
|
+
back to the embedded CLI subprocess rather than going through the single
|
|
21
|
+
served writer process. So an index write racing another writer is precisely
|
|
22
|
+
where a wrong retry would duplicate rows.
|
|
23
|
+
|
|
24
|
+
## [0.13.1] - 2026-08-17
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Raised the `witan-core` floor to `>=0.22`, so an index write that loses a
|
|
29
|
+
race retries instead of failing outright.** 0.22 classifies a write-authority
|
|
30
|
+
conflict (HTTP 409, and the CLI's equivalent wording) as retryable rather
|
|
31
|
+
than fatal.
|
|
32
|
+
|
|
33
|
+
That matters here for a different reason than it does in `witan-council`, and
|
|
34
|
+
the difference is worth stating: `RemoteStoreClient.change` never sets
|
|
35
|
+
`surface_conflict`, so the compare-and-swap half of that fix is irrelevant to
|
|
36
|
+
the code graph. The ordinary-writer half is not. This package's **branched**
|
|
37
|
+
clients deliberately fall back to the CLI subprocess — `_transport()` returns
|
|
38
|
+
`None` whenever `_extra_args` is non-empty, because omnigraph's HTTP API has
|
|
39
|
+
no request-side branch selector — so every write from a branch view is
|
|
40
|
+
classified by `_classify_cli_error`, which treated the conflict as fatal.
|
|
41
|
+
|
|
42
|
+
On witan-core 0.21, a branch-view write that merely raced another writer on
|
|
43
|
+
the shared graph fails; on 0.22 it retries and commits.
|
|
44
|
+
|
|
45
|
+
A **behavioural** floor, and a deliberate exception to this package's stated
|
|
46
|
+
"floors track what this package actually imports" rule — the same rule under
|
|
47
|
+
which the 0.19/0.20 trace-context releases were explicitly *not* pinned. The
|
|
48
|
+
difference is that those changed nothing on this package's write path.
|
|
49
|
+
|
|
9
50
|
## [0.13.0] - 2026-08-13
|
|
10
51
|
|
|
11
52
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: witan-code
|
|
3
|
-
Version: 0.13.
|
|
3
|
+
Version: 0.13.2
|
|
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.
|
|
29
|
+
Requires-Dist: witan-core[cli,observability,remote]<1,>=0.23
|
|
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.13.
|
|
3
|
+
version = "0.13.2"
|
|
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,7 +22,14 @@ 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
|
-
# (
|
|
25
|
+
# (NOT raised for witan-core 0.19/0.20's trace-context work, deliberately.
|
|
26
|
+
# Nothing here imports `trace_context_middleware`, and standalone
|
|
27
|
+
# `witan-code serve` is stdio-only — the ASGI middleware is installed by
|
|
28
|
+
# `witan serve`, whose own package declares the floor it needs. Raising this
|
|
29
|
+
# one would buy no behaviour and would misstate the minimum. Floors here
|
|
30
|
+
# track what this package actually imports, not what was released alongside
|
|
31
|
+
# it;
|
|
32
|
+
# >=0.17 for remote.proxy.RemoteWriteIndeterminate AND gateway_failure,
|
|
26
33
|
# both imported at module scope by remote/store.py — so an older witan-core
|
|
27
34
|
# fails at IMPORT, exactly like the cases above; it does not degrade into
|
|
28
35
|
# retrying an indeterminate write, because the module holding that retry is
|
|
@@ -35,7 +42,38 @@ dependencies = [
|
|
|
35
42
|
# >=0.10 for witan_core.chunking + load_batch, both moved up from this
|
|
36
43
|
# package; >=0.9 for observability.middleware; >=0.8 for
|
|
37
44
|
# OmnigraphClient.change_many with chunk_size.)
|
|
38
|
-
|
|
45
|
+
#
|
|
46
|
+
# ★ >=0.22 IS A BEHAVIOURAL FLOOR, the first here, and it is a deliberate
|
|
47
|
+
# exception to the "floors here track what this package actually imports"
|
|
48
|
+
# rule stated above — so read this before treating that rule as absolute.
|
|
49
|
+
# Nothing new is imported; an older witan-core loads fine and is wrong
|
|
50
|
+
# quietly.
|
|
51
|
+
#
|
|
52
|
+
# 0.22 classifies a write-authority conflict (HTTP 409, and the CLI's
|
|
53
|
+
# equivalent prose) as RETRYABLE rather than FATAL. That matters HERE, and
|
|
54
|
+
# not for the CAS reason it matters in witan-council: `change` above never
|
|
55
|
+
# sets `surface_conflict`, so the compare-and-swap half is irrelevant to the
|
|
56
|
+
# code graph. The ordinary-writer half is not. This package's BRANCHED
|
|
57
|
+
# clients deliberately fall back to the CLI subprocess — `_transport()`
|
|
58
|
+
# returns None whenever `_extra_args` is non-empty, because omnigraph's HTTP
|
|
59
|
+
# API has no request-side branch selector — so every write from a branch
|
|
60
|
+
# view is classified by `_classify_cli_error`, where the conflict was fatal.
|
|
61
|
+
# On 0.21 an index write that merely lost a race to a concurrent writer on
|
|
62
|
+
# the shared graph fails outright; on 0.22 it retries and commits.
|
|
63
|
+
#
|
|
64
|
+
# Maintainer decision 2026-08-17. Note this is the case the earlier
|
|
65
|
+
# parenthetical explicitly declined for 0.19/0.20 — the difference is that
|
|
66
|
+
# trace-context work changed nothing on this package's write path, and this
|
|
67
|
+
# does.
|
|
68
|
+
# >=0.23 continues the behavioural floor above, for a reason specific to
|
|
69
|
+
# THIS package's write path: 0.22 retried `recovery_required` on a write,
|
|
70
|
+
# and 0.23 makes it terminal because the same response can mean the effects
|
|
71
|
+
# already landed. The ambiguous half of that is a FOREIGN WRITER winning
|
|
72
|
+
# after local arbitration — and this package's branched clients are exactly
|
|
73
|
+
# that, since they fall back to the embedded CLI subprocess rather than the
|
|
74
|
+
# single served writer process. So an index write racing another writer is
|
|
75
|
+
# where a wrong retry would actually duplicate rows.
|
|
76
|
+
"witan-core[cli,remote,observability]>=0.23,<1",
|
|
39
77
|
"fastmcp>=3.4.2,<5",
|
|
40
78
|
"cyclopts>=4,<5",
|
|
41
79
|
# [targets.<name>] override models (config.py) — also transitively pulled
|
|
@@ -119,7 +157,7 @@ testpaths = ["tests"]
|
|
|
119
157
|
packages = ["witan_code"]
|
|
120
158
|
|
|
121
159
|
[tool.bumpversion]
|
|
122
|
-
current_version = "0.13.
|
|
160
|
+
current_version = "0.13.2"
|
|
123
161
|
allow_dirty = true
|
|
124
162
|
|
|
125
163
|
[[tool.bumpversion.files]]
|
|
@@ -242,3 +242,26 @@ def test_cli_prints_an_unreachable_remote_instead_of_a_traceback(monkeypatch, ca
|
|
|
242
242
|
cli_module.cli()
|
|
243
243
|
assert exit_code.value.code == 1
|
|
244
244
|
assert "witan-code is down at X" in capsys.readouterr().out
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def test_cli_prints_a_rejected_credential_instead_of_a_traceback(monkeypatch, capsys):
|
|
248
|
+
"""★ witan-code's handler has to list this too.
|
|
249
|
+
|
|
250
|
+
The remote path can now raise `RemoteCredentialRejected` — on a write, or on
|
|
251
|
+
a read whose refreshed retry is refused again. The `witan` CLI was updated
|
|
252
|
+
and this one was not, so it would have escaped as the traceback the whole
|
|
253
|
+
handler exists to prevent.
|
|
254
|
+
"""
|
|
255
|
+
from types import SimpleNamespace
|
|
256
|
+
|
|
257
|
+
from witan_code import cli as cli_module
|
|
258
|
+
from witan_code.remote.proxy import RemoteCredentialRejected
|
|
259
|
+
|
|
260
|
+
def _rejected():
|
|
261
|
+
raise RemoteCredentialRejected("witan-code: it rejected the credential")
|
|
262
|
+
|
|
263
|
+
monkeypatch.setattr(cli_module, "app", SimpleNamespace(meta=_rejected))
|
|
264
|
+
with pytest.raises(SystemExit) as exit_code:
|
|
265
|
+
cli_module.cli()
|
|
266
|
+
assert exit_code.value.code == 1
|
|
267
|
+
assert "rejected the credential" in capsys.readouterr().out
|
|
@@ -62,10 +62,14 @@ def _srv():
|
|
|
62
62
|
print(exc)
|
|
63
63
|
raise SystemExit(1) from None
|
|
64
64
|
if remote is not None:
|
|
65
|
-
from .remote.oidc import default_token_provider
|
|
65
|
+
from .remote.oidc import default_token_provider, default_token_refresher
|
|
66
66
|
from .remote.proxy import RemoteServerProxy
|
|
67
67
|
|
|
68
|
-
_server = RemoteServerProxy(
|
|
68
|
+
_server = RemoteServerProxy(
|
|
69
|
+
remote,
|
|
70
|
+
default_token_provider(remote),
|
|
71
|
+
default_token_refresher(remote),
|
|
72
|
+
)
|
|
69
73
|
else:
|
|
70
74
|
from . import server as server_module
|
|
71
75
|
|
|
@@ -1012,7 +1016,12 @@ def cli() -> None:
|
|
|
1012
1016
|
from rich.console import Console
|
|
1013
1017
|
|
|
1014
1018
|
from .remote.oidc import RemoteAuthError
|
|
1015
|
-
from .remote.proxy import
|
|
1019
|
+
from .remote.proxy import (
|
|
1020
|
+
RemoteCredentialRejected,
|
|
1021
|
+
RemoteToolFailed,
|
|
1022
|
+
RemoteToolUnavailable,
|
|
1023
|
+
RemoteUnreachable,
|
|
1024
|
+
)
|
|
1016
1025
|
from .remote.store import RemotePayloadTooLarge
|
|
1017
1026
|
|
|
1018
1027
|
try:
|
|
@@ -1027,6 +1036,7 @@ def cli() -> None:
|
|
|
1027
1036
|
# have.
|
|
1028
1037
|
except (
|
|
1029
1038
|
RemoteAuthError,
|
|
1039
|
+
RemoteCredentialRejected,
|
|
1030
1040
|
RemotePayloadTooLarge,
|
|
1031
1041
|
RemoteToolFailed,
|
|
1032
1042
|
RemoteToolUnavailable,
|
|
@@ -40,6 +40,7 @@ __all__ = [
|
|
|
40
40
|
"cache_path",
|
|
41
41
|
"decode_claims",
|
|
42
42
|
"default_token_provider",
|
|
43
|
+
"default_token_refresher",
|
|
43
44
|
"discover_endpoints",
|
|
44
45
|
"get_valid_token",
|
|
45
46
|
"login",
|
|
@@ -78,3 +79,19 @@ def logout(cfg: RemoteConfig) -> bool:
|
|
|
78
79
|
def default_token_provider(cfg: RemoteConfig) -> Callable[[], str]:
|
|
79
80
|
"""A zero-arg callable the proxy calls per request to get a fresh token."""
|
|
80
81
|
return lambda: get_valid_token(cfg)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def default_token_refresher(cfg: RemoteConfig) -> Callable[[str], str]:
|
|
85
|
+
"""Force-mint a token, given the one the deployment rejected.
|
|
86
|
+
|
|
87
|
+
Handed to the proxy alongside the provider so it can recover from a
|
|
88
|
+
credential the deployment rejected while this client still believed it was
|
|
89
|
+
good — see ``RemoteMCPProxy.__init__``. Separate from the provider because
|
|
90
|
+
the provider is allowed to answer from cache, which on a rejected token is
|
|
91
|
+
exactly the wrong answer.
|
|
92
|
+
|
|
93
|
+
Takes the rejected token rather than re-reading it: under concurrent 401s
|
|
94
|
+
the cache may already hold somebody else's fresh one, and refreshing that
|
|
95
|
+
would spend a rotating refresh token for nothing.
|
|
96
|
+
"""
|
|
97
|
+
return lambda rejected: _auth(cfg).force_refresh(rejected)
|
|
@@ -15,6 +15,7 @@ from typing import Callable
|
|
|
15
15
|
|
|
16
16
|
from witan_core.remote.config import RemoteConfig
|
|
17
17
|
from witan_core.remote.proxy import (
|
|
18
|
+
RemoteCredentialRejected,
|
|
18
19
|
RemoteMCPProxy,
|
|
19
20
|
RemoteToolFailed,
|
|
20
21
|
RemoteToolUnavailable,
|
|
@@ -22,6 +23,7 @@ from witan_core.remote.proxy import (
|
|
|
22
23
|
)
|
|
23
24
|
|
|
24
25
|
__all__ = [
|
|
26
|
+
"RemoteCredentialRejected",
|
|
25
27
|
"RemoteServerProxy",
|
|
26
28
|
"RemoteToolFailed",
|
|
27
29
|
"RemoteToolUnavailable",
|
|
@@ -39,8 +41,13 @@ _LOCAL_ONLY = frozenset({"code_reindex"})
|
|
|
39
41
|
class RemoteServerProxy(RemoteMCPProxy):
|
|
40
42
|
"""Mirrors the ``witan_code.server`` tool surface, dispatching over MCP."""
|
|
41
43
|
|
|
42
|
-
def __init__(
|
|
43
|
-
|
|
44
|
+
def __init__(
|
|
45
|
+
self,
|
|
46
|
+
cfg: RemoteConfig,
|
|
47
|
+
token_provider: Callable[[], str],
|
|
48
|
+
token_refresher: Callable[[], str] | None = None,
|
|
49
|
+
) -> None:
|
|
50
|
+
super().__init__(cfg.url, token_provider, token_refresher)
|
|
44
51
|
self._url_source = cfg.url_source
|
|
45
52
|
|
|
46
53
|
def _is_admin_tool(self, name: str) -> bool:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|