witan-code 0.27.0__tar.gz → 0.28.0__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.27.0 → witan_code-0.28.0}/CHANGELOG.md +95 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/PKG-INFO +7 -3
- {witan_code-0.27.0 → witan_code-0.28.0}/README.md +5 -1
- {witan_code-0.27.0 → witan_code-0.28.0}/changelog.d/README.md +1 -1
- {witan_code-0.27.0 → witan_code-0.28.0}/docs/BRANCH_INDEXING.md +4 -2
- {witan_code-0.27.0 → witan_code-0.28.0}/pyproject.toml +31 -3
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/conftest.py +24 -0
- witan_code-0.28.0/tests/test_branches_served.py +114 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_cli_hooks.py +60 -2
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_context.py +35 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_hooks.py +332 -26
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_indexer_scope.py +132 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_ingest.py +8 -6
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_reaper.py +22 -3
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_remote_store.py +21 -114
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_store.py +12 -8
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/cli.py +30 -8
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/context.py +50 -10
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/extensions/pi/codegraph.ts +21 -6
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/graph.py +19 -26
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/hooks.py +122 -22
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/indexer.py +91 -10
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/ingest.py +1 -1
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/reaper.py +4 -4
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/remote/store.py +10 -48
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/store.py +25 -3
- witan_code-0.27.0/changelog.d/20261021_142050_blarghmatey_witan_code_drop_bridge_repo_file.md +0 -14
- witan_code-0.27.0/changelog.d/20261021_143525_blarghmatey_witan_coalesce_hot_writes.md +0 -6
- {witan_code-0.27.0 → witan_code-0.28.0}/.gitignore +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/config/claude.json +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/config/copilot.json +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/config/pi.json +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/conftest.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/docs/CLI_REFERENCE.md +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/docs/EDGE_PRECISION_TIERS.md +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/docs/PACKAGE_MAP.md +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/docs/STAGE2_STITCHING.md +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/docs/SYMBOL_FORMAT.md +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/docs/SYMBOL_TABLE.md +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/docs/USER_GUIDE.md +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/install.sh +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/__init__.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_batched_deletes.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_branches.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_bridge.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_chunked_load.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_cli_dispatch.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_cli_output_format.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_cli_selected_target.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_config.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_config_targets.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_crossrepo.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_edges.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_elicit.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_enrichment.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_github_app.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_graph.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_identity.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_index_failure_diagnostics.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_index_reports_its_store.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_index_requires_a_repo_key.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_indexer.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_languages.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_maintenance.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_package_map.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_rebuild_honours_the_repo_key.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_refusal_audit.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_remote_proxy.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_repo.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_server.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_setup.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_stitch.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_symbol_table.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_tasks.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_tool_schema.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_views.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/tests/test_visualize.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/__init__.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/__main__.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/bridge.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/bridge_extractors.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/config.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/edges.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/elicit.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/github_app.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/identity.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/maintenance.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/output.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/package_map.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/queries/bridge.gq +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/queries/code_mutations.gq +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/queries/code_read.gq +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/queries/delete.gq +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/queries_ts/bash.scm +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/queries_ts/hcl.scm +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/queries_ts/python.scm +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/queries_ts/sql.scm +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/queries_ts/typescript.scm +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/queries_ts/yaml.scm +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/remote/__init__.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/remote/oidc.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/remote/proxy.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/repo.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/schema/bridge-schema.pg +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/schema/code-schema.pg +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/selected_target.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/server.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/setup.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/skills/witan-code/SKILL.md +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/stitch.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/views.py +0 -0
- {witan_code-0.27.0 → witan_code-0.28.0}/witan_code/visualize.py +0 -0
|
@@ -8,6 +8,80 @@ a MINOR bump may include breaking changes).
|
|
|
8
8
|
|
|
9
9
|
<!-- scriv-insert-here -->
|
|
10
10
|
|
|
11
|
+
## [0.28.0] - 2026-11-09
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Requires `witan-core>=0.51`, which pins omnigraph 0.14 (storage format 16)
|
|
16
|
+
and speaks HTTP contract 0.14 or 0.13, whichever the server stamps. A 0.14
|
|
17
|
+
data tier refuses an older client's requests. The floor also covers
|
|
18
|
+
`store_cli_args(..., binary=)`, `OmnigraphClient.commit_list`, the branched
|
|
19
|
+
HTTP transport and `OmnigraphClient(actor=)`.
|
|
20
|
+
- The `schema plan` check on a local code store addresses the store with
|
|
21
|
+
`store_cli_args`, so it takes `--target` on omnigraph 0.14 (which removed
|
|
22
|
+
the positional store URI) and `--store` before it. Code and bridge store
|
|
23
|
+
`init` passes the generated operator config on 0.14 (`init_cli_args`).
|
|
24
|
+
- A branch view on a deployed server reads, writes and lists its commits
|
|
25
|
+
over HTTP, with the branch as a request field, instead of through the
|
|
26
|
+
omnigraph CLI, which 0.14 refuses for a plain-http server.
|
|
27
|
+
`branch_last_write` (the reaper's idleness check) uses
|
|
28
|
+
`OmnigraphClient.commit_list`.
|
|
29
|
+
- A deployment's ingest client asserts the caller's actor to the data tier
|
|
30
|
+
(`Omnigraph-If-Actor`), so on omnigraph 0.14 a token mapped to the wrong
|
|
31
|
+
actor is refused instead of writing under someone else's name. `StoreRef`
|
|
32
|
+
carries the `actor`.
|
|
33
|
+
- The PostToolUse drainer indexes its whole queue as one batch
|
|
34
|
+
(`indexer.index_paths`) and waits `FLUSH_INTERVAL_SECONDS` (30s) since the
|
|
35
|
+
checkout's last flush before starting the next. An edit-heavy session now
|
|
36
|
+
runs at most one index per 30s per checkout (three commits on the branch
|
|
37
|
+
view when the batch is at most 64 changed files and fits one load chunk),
|
|
38
|
+
instead of one index run per edit back to back. The first edit after a
|
|
39
|
+
quiet spell still flushes at once, and edits made during the wait join the
|
|
40
|
+
next flush, so the last edit of a session is still indexed.
|
|
41
|
+
- The Pi extension queues edits through `witan-code reindex-hook` and seeds
|
|
42
|
+
through `witan-code session-init`, the commands the Claude and Codex hooks
|
|
43
|
+
run, instead of a detached `witan-code index` per edit that bypassed the
|
|
44
|
+
drainer.
|
|
45
|
+
|
|
46
|
+
### Removed
|
|
47
|
+
|
|
48
|
+
- `RemoteStoreClient.change_many` no longer falls back to one
|
|
49
|
+
`code_store_mutate` per statement when the deployment's tool list lacks, or
|
|
50
|
+
fails to return, `code_store_mutate_many`. A failed listing was cached for
|
|
51
|
+
the connection's lifetime, which turned a reindex's deletes into one commit
|
|
52
|
+
per statement. A store tier without `code_store_mutate_many` (served since
|
|
53
|
+
witan-code 0.12.0) now fails the call instead. `StoreSession.has_tool` is
|
|
54
|
+
gone with it.
|
|
55
|
+
|
|
56
|
+
## [0.27.1] - 2026-10-26
|
|
57
|
+
|
|
58
|
+
### Changed
|
|
59
|
+
|
|
60
|
+
- Requires witan-core 0.46.0, whose device login sends PKCE (`S256`). The
|
|
61
|
+
`witan-cli` Keycloak client will require PKCE, and `witan-code login` on an older
|
|
62
|
+
witan-core will then fail.
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- `reindex-hook` purges files a Codex `apply_patch` deletes or renames away. It
|
|
67
|
+
read only the headers naming a file left on disk, so a `*** Delete File:`
|
|
68
|
+
path and the `*** Update File:` source of a `*** Move to:` kept their symbols
|
|
69
|
+
in the graph until the next SessionStart full refresh, and
|
|
70
|
+
`code_find_definition` went on returning the old path. The hook now queues
|
|
71
|
+
those paths too, and indexing a file that is no longer on disk
|
|
72
|
+
(`index_path`, which the hook's drainer calls) drops its rows and its
|
|
73
|
+
cross-repo bindings. The drainer used to skip a queued file deleted before it
|
|
74
|
+
ran; it now purges it the same way. (Shipped in 0.27.1, left out at release.)
|
|
75
|
+
- `inject-context` gives Codex guidance for tools Codex has. `witan-code setup`
|
|
76
|
+
registers one bare `UserPromptSubmit` hook for Claude Code and Codex, so
|
|
77
|
+
Codex got Claude's block, which says to load the `code_*` tools with
|
|
78
|
+
`ToolSearch` and to run `/witan-code`; Codex has neither. Without
|
|
79
|
+
`--client`, the command now reads the hook's stdin payload, and a Codex
|
|
80
|
+
payload (it carries `turn_id`) gets Codex's `tool_search` call and a pointer
|
|
81
|
+
to the `witan-code` skill. Any other payload, or none, gets the Claude block
|
|
82
|
+
as before. `--client codex` selects the Codex block explicitly. (Shipped in
|
|
83
|
+
0.27.1, left out at release.)
|
|
84
|
+
|
|
11
85
|
## [0.27.0] - 2026-10-21
|
|
12
86
|
|
|
13
87
|
### Changed
|
|
@@ -19,6 +93,27 @@ a MINOR bump may include breaking changes).
|
|
|
19
93
|
- `witan-code cleanup --yes` with neither `--keep` nor `--older-than` now keeps 2 days
|
|
20
94
|
as well, since it shares the default. Pass `--older-than 30d` to keep the
|
|
21
95
|
old window.
|
|
96
|
+
- A local `_bridge.omni` whose schema omnigraph reports it cannot migrate in
|
|
97
|
+
place (`schema plan` answers `supported: false`) is now deleted and recreated
|
|
98
|
+
instead of failing every apply. It comes back empty. Run
|
|
99
|
+
`witan-code reindex <repo root>` in each indexed repo to restore its
|
|
100
|
+
cross-repo bindings. A local bridge created by 0.26.x hits this on the
|
|
101
|
+
first index after upgrading, because of the schema change under Removed.
|
|
102
|
+
(Shipped in 0.27.0, left out at release.)
|
|
103
|
+
- A bridge write clears the repo's symbol table in the same commit as its
|
|
104
|
+
per-file bindings purge, instead of a separate one. Every index that writes
|
|
105
|
+
bindings now costs the bridge one commit fewer, on a graph whose main branch
|
|
106
|
+
every repo shares and whose commits serialize. (Shipped in 0.27.0, left out
|
|
107
|
+
at release.)
|
|
108
|
+
|
|
109
|
+
### Removed
|
|
110
|
+
|
|
111
|
+
- `InterfaceBinding.repo_file` is gone from the bridge schema. The per-file
|
|
112
|
+
purge deletes on `repo` and `file` directly, which GQ 2.1 allows. omnigraph
|
|
113
|
+
0.13 cannot drop the column in place, so a deployed `code-bridge` graph has
|
|
114
|
+
to be recreated and every repo reindexed. Until then, this release's bridge
|
|
115
|
+
writes to that graph fail, because its schema still requires `repo_file`.
|
|
116
|
+
(Shipped in 0.27.0, left out at release.)
|
|
22
117
|
|
|
23
118
|
## [0.26.0] - 2026-10-16
|
|
24
119
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: witan-code
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.28.0
|
|
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,sentry]<1,>=0.
|
|
29
|
+
Requires-Dist: witan-core[cli,observability,remote,sentry]<1,>=0.51
|
|
30
30
|
Provides-Extra: tasks
|
|
31
31
|
Requires-Dist: fastmcp-tasks<5,>=4; extra == 'tasks'
|
|
32
32
|
Description-Content-Type: text/markdown
|
|
@@ -737,7 +737,11 @@ A Pi equivalent of all four lives in one extension,
|
|
|
737
737
|
exact `mcp__<server>__` name, then `tools.<name>({...})`), and
|
|
738
738
|
`--client pi`, which it passes when pi-mcp-adapter's `mcp` tool is
|
|
739
739
|
registered, gives the adapter's proxy (`mcp({ search: ... })`, then
|
|
740
|
-
`mcp({ tool: ..., args: {...} })`).
|
|
740
|
+
`mcp({ tool: ..., args: {...} })`). Codex runs the same bare hook command
|
|
741
|
+
as Claude Code, so without `--client` the block is chosen from the hook's
|
|
742
|
+
stdin payload: a Codex payload (it carries `turn_id`) gets Codex's
|
|
743
|
+
`tool_search` and the `witan-code` skill instead of `ToolSearch` and
|
|
744
|
+
`/witan-code`, and anything else gets Claude's.
|
|
741
745
|
Independent of `witan`'s own `inject-context` hook (no cross-package
|
|
742
746
|
coupling) — register it alone for a witan-code-only install. Prints
|
|
743
747
|
nothing when the repo has neither a store nor an index in flight.
|
|
@@ -704,7 +704,11 @@ A Pi equivalent of all four lives in one extension,
|
|
|
704
704
|
exact `mcp__<server>__` name, then `tools.<name>({...})`), and
|
|
705
705
|
`--client pi`, which it passes when pi-mcp-adapter's `mcp` tool is
|
|
706
706
|
registered, gives the adapter's proxy (`mcp({ search: ... })`, then
|
|
707
|
-
`mcp({ tool: ..., args: {...} })`).
|
|
707
|
+
`mcp({ tool: ..., args: {...} })`). Codex runs the same bare hook command
|
|
708
|
+
as Claude Code, so without `--client` the block is chosen from the hook's
|
|
709
|
+
stdin payload: a Codex payload (it carries `turn_id`) gets Codex's
|
|
710
|
+
`tool_search` and the `witan-code` skill instead of `ToolSearch` and
|
|
711
|
+
`/witan-code`, and anything else gets Claude's.
|
|
708
712
|
Independent of `witan`'s own `inject-context` hook (no cross-package
|
|
709
713
|
coupling) — register it alone for a witan-code-only install. Prints
|
|
710
714
|
nothing when the repo has neither a store nor an index in flight.
|
|
@@ -5,7 +5,7 @@ to `../CHANGELOG.md` — parallel branches editing the same lines in one shared
|
|
|
5
5
|
file is what caused the version/changelog drift `bin/check_versions.py`
|
|
6
6
|
exists to catch.
|
|
7
7
|
|
|
8
|
-
Add one with `just changelog witan-code` (or `uvx scriv@1.8.
|
|
8
|
+
Add one with `just changelog witan-code` (or `uvx scriv@1.8.1 create` from
|
|
9
9
|
this directory's parent), fill in whichever category section(s) apply, and
|
|
10
10
|
commit the file alongside your change. `just bump witan-code <part>` folds
|
|
11
11
|
every pending fragment into `../CHANGELOG.md` under the new version heading
|
|
@@ -210,8 +210,10 @@ witan-code reap-views # report every local stor
|
|
|
210
210
|
witan-code reap-views --store https://… --graph code-x --apply # the scheduled job
|
|
211
211
|
```
|
|
212
212
|
|
|
213
|
-
Idleness comes from
|
|
214
|
-
|
|
213
|
+
Idleness comes from the view's commit list (`GET /graphs/<id>/commits?branch=`
|
|
214
|
+
on a deployed server, `omnigraph commit list --branch` on a local store),
|
|
215
|
+
filtered to commits whose `graph_branch` (`manifest_branch` before omnigraph's
|
|
216
|
+
2026-08-20 rename) is the view itself — `branch list` returns bare names, with no
|
|
215
217
|
date, owner, or size. Two rules follow:
|
|
216
218
|
|
|
217
219
|
* **`main` is never reaped**, however idle. It is the view every reader falls
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "witan-code"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.28.0"
|
|
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"
|
|
@@ -183,7 +183,35 @@ dependencies = [
|
|
|
183
183
|
# prints only from 0.43.0. On 0.42 `--agent codex` is rejected as an
|
|
184
184
|
# invalid value, and `--agent all` writes the reindex hook to Codex
|
|
185
185
|
# without the notice.
|
|
186
|
-
|
|
186
|
+
#
|
|
187
|
+
# ★ >=0.46 IS A BEHAVIOUR FLOOR: the device login in `witan_core.remote.oidc`
|
|
188
|
+
# sends PKCE (`S256`) only from 0.46.0, and the `witan-cli` Keycloak client
|
|
189
|
+
# is switched to require it once that is out. 0.45 imports and runs, then
|
|
190
|
+
# every `witan-code login` is refused by Keycloak.
|
|
191
|
+
#
|
|
192
|
+
# ★ >=0.48 IS A RUNTIME FLOOR of the `strict` kind above: `store.py` calls
|
|
193
|
+
# `store_cli_args(..., binary=)`, a keyword witan-core 0.48.0 added in the
|
|
194
|
+
# same change (omnigraph 0.14 `--target` addressing). 0.46 imports fine,
|
|
195
|
+
# then the first `schema plan` check raises TypeError, so
|
|
196
|
+
# `just check-core-floor` cannot see it.
|
|
197
|
+
#
|
|
198
|
+
# ★ >=0.49 IS A RUNTIME AND BEHAVIOUR FLOOR: `graph.branch_last_write`
|
|
199
|
+
# calls `OmnigraphClient.commit_list`, added in witan-core 0.49.0 in the
|
|
200
|
+
# same change, so on 0.48 the reaper raises AttributeError. 0.49 is also
|
|
201
|
+
# the first that sends a branch view's reads and writes over HTTP; on 0.48
|
|
202
|
+
# they shell out, which the 0.14 CLI refuses for a plain-http server.
|
|
203
|
+
#
|
|
204
|
+
# ★ >=0.50 IS A COMPATIBILITY FLOOR: 0.50.0 pins omnigraph 0.14 (storage
|
|
205
|
+
# format 16) and speaks HTTP contract 0.14 (or 0.13, negotiated). A 0.14
|
|
206
|
+
# server refuses a 0.13 request with `400 api_contract_mismatch`, so 0.49
|
|
207
|
+
# imports and runs, then fails on the first read of a shared code graph
|
|
208
|
+
# once the data tier is on 0.14.
|
|
209
|
+
#
|
|
210
|
+
# ★ >=0.51 IS A RUNTIME FLOOR of the `strict` kind above: `graph.py`
|
|
211
|
+
# passes `actor=` to witan-core's `OmnigraphClient`, a keyword added in
|
|
212
|
+
# witan-core 0.51.0 in the same change (Omnigraph-If-Actor). 0.50 imports
|
|
213
|
+
# fine, then a deployed ingest raises TypeError.
|
|
214
|
+
"witan-core[cli,remote,observability,sentry]>=0.51,<1",
|
|
187
215
|
"fastmcp>=4,<5",
|
|
188
216
|
"cyclopts>=4,<6",
|
|
189
217
|
# [targets.<name>] override models (config.py) — also transitively pulled
|
|
@@ -266,7 +294,7 @@ testpaths = ["tests"]
|
|
|
266
294
|
packages = ["witan_code"]
|
|
267
295
|
|
|
268
296
|
[tool.bumpversion]
|
|
269
|
-
current_version = "0.
|
|
297
|
+
current_version = "0.28.0"
|
|
270
298
|
allow_dirty = true
|
|
271
299
|
|
|
272
300
|
[[tool.bumpversion.files]]
|
|
@@ -127,3 +127,27 @@ def sample_repo(tmp_path, monkeypatch):
|
|
|
127
127
|
src.mkdir()
|
|
128
128
|
(src / "svc.py").write_text(SAMPLE)
|
|
129
129
|
return src
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# Field sets of each agent's UserPromptSubmit stdin payload: Codex's from
|
|
133
|
+
# `UserPromptSubmitCommandInput` (codex-rs/hooks/src/schema.rs at
|
|
134
|
+
# rust-v0.162.1), Claude Code's from its hooks reference. `turn_id` is the
|
|
135
|
+
# Codex extension that tells them apart.
|
|
136
|
+
CODEX_PROMPT_PAYLOAD = {
|
|
137
|
+
"session_id": "019a1b2c-3d4e-7f00-8a9b-0c1d2e3f4a5b",
|
|
138
|
+
"turn_id": "1",
|
|
139
|
+
"transcript_path": None,
|
|
140
|
+
"cwd": "/work/repo",
|
|
141
|
+
"hook_event_name": "UserPromptSubmit",
|
|
142
|
+
"model": "gpt-5-codex",
|
|
143
|
+
"permission_mode": "default",
|
|
144
|
+
"prompt": "where is helper defined?",
|
|
145
|
+
}
|
|
146
|
+
CLAUDE_PROMPT_PAYLOAD = {
|
|
147
|
+
"session_id": "abc123",
|
|
148
|
+
"transcript_path": "/home/u/.claude/projects/x/abc123.jsonl",
|
|
149
|
+
"cwd": "/work/repo",
|
|
150
|
+
"permission_mode": "default",
|
|
151
|
+
"hook_event_name": "UserPromptSubmit",
|
|
152
|
+
"prompt": "where is helper defined?",
|
|
153
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""witan-code's branch views against a real omnigraph-server, over HTTP only.
|
|
2
|
+
|
|
3
|
+
A view's reads, writes and commit list each carry the view's branch. Against a
|
|
4
|
+
deployed server those have to go over HTTP: the 0.14 CLI refuses a plain-http
|
|
5
|
+
server target, which is what the deployed data tier is. So these fail the
|
|
6
|
+
moment anything here shells out, and assert on where each write landed rather
|
|
7
|
+
than on what was sent, because a branch the server ignored would still look
|
|
8
|
+
right on the wire.
|
|
9
|
+
|
|
10
|
+
Needs ``omnigraph-server``; see ``testsupport/omnigraph_server.py``.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import time
|
|
16
|
+
|
|
17
|
+
import pytest
|
|
18
|
+
from testsupport.omnigraph_server import (
|
|
19
|
+
omnigraph_server_bin, # noqa: F401 (a fixture)
|
|
20
|
+
requires_omnigraph_server,
|
|
21
|
+
serve,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
from witan_code import config as cfg_module
|
|
25
|
+
from witan_code.graph import OmnigraphClient
|
|
26
|
+
from witan_core import omnigraph as og
|
|
27
|
+
|
|
28
|
+
pytestmark = requires_omnigraph_server
|
|
29
|
+
|
|
30
|
+
GRAPH = "code-served"
|
|
31
|
+
VIEW = "act-alice/feature_x"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _file(slug: str) -> dict:
|
|
35
|
+
return {
|
|
36
|
+
"id": slug,
|
|
37
|
+
"repo": "github.com/test/repo",
|
|
38
|
+
"path": slug,
|
|
39
|
+
"language": "python",
|
|
40
|
+
"content_hash": "h",
|
|
41
|
+
"indexed_at": "2026-10-28T00:00:00Z",
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _slugs(client: OmnigraphClient) -> set[str]:
|
|
46
|
+
return {row["slug"] for row in client.read("code_read.gq", "all_file_hashes", {})}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@pytest.fixture
|
|
50
|
+
def served(tmp_path, monkeypatch, omnigraph_server_bin): # noqa: F811
|
|
51
|
+
def no_subprocess(*args, **kwargs):
|
|
52
|
+
raise AssertionError(f"shelled out against a served graph: {args}")
|
|
53
|
+
|
|
54
|
+
with serve(tmp_path, cfg_module._SCHEMA_FILE, GRAPH, omnigraph_server_bin) as url:
|
|
55
|
+
monkeypatch.setattr(og.subprocess, "run", no_subprocess)
|
|
56
|
+
|
|
57
|
+
def client(branch: str | None = None) -> OmnigraphClient:
|
|
58
|
+
return OmnigraphClient(
|
|
59
|
+
url, cfg_module._QUERIES_DIR, branch=branch, graph_id=GRAPH
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
yield client
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_a_view_reads_writes_and_dates_its_own_branch_over_http(served):
|
|
66
|
+
main, view = served(), served(VIEW)
|
|
67
|
+
view.ensure_branch()
|
|
68
|
+
|
|
69
|
+
main.change("code_mutations.gq", "insert_file", _file("on-main"))
|
|
70
|
+
view.change("code_mutations.gq", "insert_file", _file("on-view"))
|
|
71
|
+
view.change_many(
|
|
72
|
+
[
|
|
73
|
+
("code_mutations.gq", "insert_file", _file("batched-1")),
|
|
74
|
+
("code_mutations.gq", "insert_file", _file("batched-2")),
|
|
75
|
+
]
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
assert _slugs(main) == {"on-main"}
|
|
79
|
+
assert _slugs(view) == {"on-view", "batched-1", "batched-2"}
|
|
80
|
+
|
|
81
|
+
written = view.branch_last_write(VIEW)
|
|
82
|
+
assert written is not None
|
|
83
|
+
assert abs(written - time.time()) < 300
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_a_view_with_no_writes_of_its_own_has_no_last_write(served):
|
|
87
|
+
served().change("code_mutations.gq", "insert_file", _file("on-main"))
|
|
88
|
+
empty = served("act-bob/untouched")
|
|
89
|
+
empty.ensure_branch()
|
|
90
|
+
|
|
91
|
+
assert served().branch_last_write("act-bob/untouched") is None
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_a_missing_view_is_refused_at_once_not_read_from_main(served, monkeypatch):
|
|
95
|
+
"""0.13 answers a branch that does not exist with 404 `not_found`. Waiting
|
|
96
|
+
cannot create it, so it fails on the first attempt (the sleep would only
|
|
97
|
+
run between retries) instead of spending the call budget."""
|
|
98
|
+
main = served()
|
|
99
|
+
main.change("code_mutations.gq", "insert_file", _file("on-main"))
|
|
100
|
+
|
|
101
|
+
def no_retry(seconds):
|
|
102
|
+
raise AssertionError(f"retried a missing branch (slept {seconds}s)")
|
|
103
|
+
|
|
104
|
+
missing = served("act-alice/never_created")
|
|
105
|
+
|
|
106
|
+
with monkeypatch.context() as patch:
|
|
107
|
+
patch.setattr(og.time, "sleep", no_retry)
|
|
108
|
+
with pytest.raises(RuntimeError, match="not found"):
|
|
109
|
+
missing.read("code_read.gq", "all_file_hashes", {})
|
|
110
|
+
with pytest.raises(RuntimeError, match="not found"):
|
|
111
|
+
missing.change("code_mutations.gq", "insert_file", _file("lost"))
|
|
112
|
+
with pytest.raises(RuntimeError, match="not found"):
|
|
113
|
+
main.commit_list("act-alice/never_created")
|
|
114
|
+
assert _slugs(main) == {"on-main"}
|
|
@@ -5,6 +5,10 @@ exception escape (the hooks are documented as "always exits 0"), and must
|
|
|
5
5
|
not print an extra trailing newline beyond what the backend already returns.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
import io
|
|
9
|
+
import json
|
|
10
|
+
import sys
|
|
11
|
+
|
|
8
12
|
import pytest
|
|
9
13
|
|
|
10
14
|
from witan_code import cli
|
|
@@ -64,8 +68,62 @@ def test_inject_context_cmd_defaults_to_the_claude_client(monkeypatch, capsys):
|
|
|
64
68
|
assert seen == ["claude"]
|
|
65
69
|
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
def _stdin(monkeypatch, payload: dict) -> None:
|
|
72
|
+
"""Hand the command a hook payload on a closed, non-tty stdin."""
|
|
73
|
+
monkeypatch.setattr(sys, "stdin", io.StringIO(json.dumps(payload)))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _run_bare(monkeypatch) -> list[str]:
|
|
77
|
+
import witan_code.context as context_module
|
|
78
|
+
|
|
79
|
+
seen = []
|
|
80
|
+
monkeypatch.setattr(
|
|
81
|
+
context_module, "inject_context", lambda client: seen.append(client) or ""
|
|
82
|
+
)
|
|
83
|
+
command, bound, _ = cli.app.parse_args(["inject-context"])
|
|
84
|
+
command(*bound.args, **bound.kwargs)
|
|
85
|
+
return seen
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_the_bare_command_renders_for_codex_from_a_codex_payload(monkeypatch):
|
|
89
|
+
"""One hook command is registered for Claude Code and Codex alike, so the
|
|
90
|
+
payload is what picks the block."""
|
|
91
|
+
from .conftest import CODEX_PROMPT_PAYLOAD
|
|
92
|
+
|
|
93
|
+
_stdin(monkeypatch, CODEX_PROMPT_PAYLOAD)
|
|
94
|
+
|
|
95
|
+
assert _run_bare(monkeypatch) == ["codex"]
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_the_bare_command_stays_claude_for_a_claude_payload(monkeypatch):
|
|
99
|
+
from .conftest import CLAUDE_PROMPT_PAYLOAD
|
|
100
|
+
|
|
101
|
+
_stdin(monkeypatch, CLAUDE_PROMPT_PAYLOAD)
|
|
102
|
+
|
|
103
|
+
assert _run_bare(monkeypatch) == ["claude"]
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def test_an_explicit_client_does_not_read_stdin(monkeypatch):
|
|
107
|
+
"""The Pi extension passes `--client`; its stdin is not a hook payload."""
|
|
108
|
+
import witan_code.context as context_module
|
|
109
|
+
|
|
110
|
+
from .conftest import CODEX_PROMPT_PAYLOAD
|
|
111
|
+
|
|
112
|
+
_stdin(monkeypatch, CODEX_PROMPT_PAYLOAD)
|
|
113
|
+
seen = []
|
|
114
|
+
monkeypatch.setattr(
|
|
115
|
+
context_module, "inject_context", lambda client: seen.append(client) or ""
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
command, bound, _ = cli.app.parse_args(["inject-context", "--client", "pi"])
|
|
119
|
+
command(*bound.args, **bound.kwargs)
|
|
120
|
+
|
|
121
|
+
assert seen == ["pi"]
|
|
122
|
+
assert sys.stdin.read() != "" # left unread
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@pytest.mark.parametrize("client", ["codex", "pi", "pi-builtin"])
|
|
126
|
+
def test_inject_context_cmd_passes_an_explicit_client_through(monkeypatch, client):
|
|
69
127
|
import witan_code.context as context_module
|
|
70
128
|
|
|
71
129
|
seen = []
|
|
@@ -5,6 +5,7 @@ tests exercise context.py's own orchestration (repo detection, lock-file
|
|
|
5
5
|
check, store-exists branching), not the underlying query.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
import json
|
|
8
9
|
import os
|
|
9
10
|
import shutil
|
|
10
11
|
import subprocess
|
|
@@ -16,6 +17,8 @@ import pytest
|
|
|
16
17
|
|
|
17
18
|
from witan_code import context
|
|
18
19
|
|
|
20
|
+
from .conftest import CLAUDE_PROMPT_PAYLOAD, CODEX_PROMPT_PAYLOAD
|
|
21
|
+
|
|
19
22
|
|
|
20
23
|
def _lock(tmp_path, monkeypatch, project_dir):
|
|
21
24
|
"""The busy marker `indexing_in_progress` reads; create it to fake a run."""
|
|
@@ -463,3 +466,35 @@ def test_inject_context_for_pi_names_the_mcp_proxy_not_toolsearch(
|
|
|
463
466
|
assert "https://github.com/test/cg" in text
|
|
464
467
|
assert "3 files" in text
|
|
465
468
|
assert "No other repo is indexed" in text
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
# ── Codex ─────────────────────────────────────────────────────────────────────
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
def test_a_codex_payload_selects_the_codex_client():
|
|
475
|
+
assert context.client_from_payload(json.dumps(CODEX_PROMPT_PAYLOAD)) == "codex"
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
@pytest.mark.parametrize(
|
|
479
|
+
"payload", [json.dumps(CLAUDE_PROMPT_PAYLOAD), "", "not json", "[1]"]
|
|
480
|
+
)
|
|
481
|
+
def test_anything_but_a_codex_payload_selects_claude(payload):
|
|
482
|
+
assert context.client_from_payload(payload) == "claude"
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
def test_inject_context_for_codex_names_tools_codex_has(tmp_path, monkeypatch):
|
|
486
|
+
"""Codex has no `ToolSearch` and no `/witan-code` command. It defers MCP
|
|
487
|
+
tools behind `tool_search` when the model supports one, and lists them
|
|
488
|
+
directly otherwise, so the search is the fallback for unlisted tools."""
|
|
489
|
+
_indexed(tmp_path, monkeypatch)
|
|
490
|
+
|
|
491
|
+
text = context.inject_context(client="codex")
|
|
492
|
+
|
|
493
|
+
assert "ToolSearch" not in text
|
|
494
|
+
assert "/witan-code" not in text
|
|
495
|
+
assert 'tool_search(query="code_find_definition callers impact")' in text
|
|
496
|
+
assert "`witan-code` skill" in text
|
|
497
|
+
# The status lines above the discovery line are client-neutral.
|
|
498
|
+
assert "https://github.com/test/cg" in text
|
|
499
|
+
assert "3 files" in text
|
|
500
|
+
assert len(text) < 600 # same budget as the Claude block
|