witan-code 0.28.0__tar.gz → 0.30.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.28.0 → witan_code-0.30.0}/CHANGELOG.md +71 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/PKG-INFO +21 -8
- {witan_code-0.28.0 → witan_code-0.30.0}/README.md +19 -6
- {witan_code-0.28.0 → witan_code-0.30.0}/pyproject.toml +14 -3
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_chunked_load.py +82 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_cli_dispatch.py +74 -5
- witan_code-0.30.0/tests/test_cli_help_docstrings.py +9 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_cli_hooks.py +21 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_cli_output_format.py +17 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_elicit.py +40 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_hooks.py +329 -17
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_indexer_scope.py +232 -6
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_remote_proxy.py +17 -5
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_remote_store.py +36 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_repo.py +66 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_store.py +9 -6
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/bridge_extractors.py +8 -2
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/cli.py +66 -40
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/context.py +16 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/hooks.py +75 -37
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/indexer.py +162 -16
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/remote/store.py +25 -1
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/repo.py +122 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/server.py +23 -3
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/store.py +16 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/.gitignore +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/changelog.d/README.md +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/config/claude.json +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/config/copilot.json +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/config/pi.json +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/conftest.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/docs/BRANCH_INDEXING.md +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/docs/CLI_REFERENCE.md +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/docs/EDGE_PRECISION_TIERS.md +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/docs/PACKAGE_MAP.md +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/docs/STAGE2_STITCHING.md +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/docs/SYMBOL_FORMAT.md +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/docs/SYMBOL_TABLE.md +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/docs/USER_GUIDE.md +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/install.sh +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/__init__.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/conftest.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_batched_deletes.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_branches.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_branches_served.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_bridge.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_cli_selected_target.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_config.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_config_targets.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_context.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_crossrepo.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_edges.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_enrichment.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_github_app.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_graph.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_identity.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_index_failure_diagnostics.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_index_reports_its_store.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_index_requires_a_repo_key.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_indexer.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_ingest.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_languages.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_maintenance.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_package_map.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_reaper.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_rebuild_honours_the_repo_key.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_refusal_audit.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_server.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_setup.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_stitch.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_symbol_table.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_tasks.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_tool_schema.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_views.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/tests/test_visualize.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/__init__.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/__main__.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/bridge.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/config.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/edges.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/elicit.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/extensions/pi/codegraph.ts +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/github_app.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/graph.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/identity.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/ingest.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/maintenance.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/output.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/package_map.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/queries/bridge.gq +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/queries/code_mutations.gq +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/queries/code_read.gq +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/queries/delete.gq +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/queries_ts/bash.scm +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/queries_ts/hcl.scm +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/queries_ts/python.scm +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/queries_ts/sql.scm +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/queries_ts/typescript.scm +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/queries_ts/yaml.scm +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/reaper.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/remote/__init__.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/remote/oidc.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/remote/proxy.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/schema/bridge-schema.pg +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/schema/code-schema.pg +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/selected_target.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/setup.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/skills/witan-code/SKILL.md +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/stitch.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/views.py +0 -0
- {witan_code-0.28.0 → witan_code-0.30.0}/witan_code/visualize.py +0 -0
|
@@ -8,6 +8,77 @@ a MINOR bump may include breaking changes).
|
|
|
8
8
|
|
|
9
9
|
<!-- scriv-insert-here -->
|
|
10
10
|
|
|
11
|
+
## [0.30.0] - 2026-11-12
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- The remote store client names itself `witan-code <version>` in its MCP `clientInfo` instead of the SDK default `mcp 0.1.0`, so the deployment's tool-call logs record which witan-code release made each call.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- The pending queue is guarded by its own `codegraph-<digest>.pending.lock` file instead of a lock on the queue file, because Windows locks are mandatory and would block the holder's own reads through another handle. A drainer from the previous version still running during an upgrade does not exclude the new lock, so one queued edit can be dropped, once; the next edit to that file reindexes it.
|
|
20
|
+
- Requires witan-core 0.52.0 or later, the first release with `witan_core._filelock`.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- `witan-code symbols` with no detectable repo now prints its refusal to stderr and exits 1. It printed to stdout and exited 0, so a consumer parsing `--output-format json|toml|yaml` got a sentence instead of a document and could not tell the refusal from success.
|
|
25
|
+
- `witan-code branches --prune` against a remote deployment, a misconfigured remote (e.g. `WITAN_REMOTE_URL` without `WITAN_OIDC_ISSUER`), and a remote failure on any command (deployment unreachable, credential rejected, tool refused) print to stderr instead of stdout. All of them already exited 1. The umbrella `witan code ...` path prints remote failures through `witan`'s own handler instead, which goes to stderr from witan-council 0.48.0 and to stdout before it.
|
|
26
|
+
|
|
27
|
+
- The code-graph hooks (`session-init`, `reindex-hook` and the drainer they spawn) run on Windows. `witan_code.hooks` imported `fcntl` and `context.state_dir` called `os.getuid`, so every hook command failed there. The queue and checkout locks now go through `witan_core._filelock` (`flock` on POSIX, unchanged; `msvcrt.locking` on Windows). Windows cannot hand a lock to a child process, so there the hook checks the lock is free and the drainer takes it itself. The state directory on Windows is `%LOCALAPPDATA%\witan-code\state`, which only its owner can write to, rather than the temp dir, which `TEMP` can point at a shared directory.
|
|
28
|
+
|
|
29
|
+
- Error messages keep a long path on one line (e.g. the `reindex
|
|
30
|
+
--rebuild` refusal naming a subdirectory).
|
|
31
|
+
Rich hard-wrapped them at 80 columns when no standard stream is a
|
|
32
|
+
terminal (an agent's shell, a CI job), which put a newline inside any
|
|
33
|
+
longer path. Tables still wrap to the width.
|
|
34
|
+
|
|
35
|
+
- The edit and SessionStart hooks skip a repo the cluster does not serve instead of indexing it. Each attempt was refused with `ClusterGraphMissing`, which the hook discarded, but the server logged it and counted it as a failed tool call against its error-ratio alert. The drainer asks the cluster for its served graphs once per process (`code_store_graphs` through the MCP tier, `GET /graphs` direct) and indexes as before when that listing fails or comes back empty. An explicit `witan-code index` still reports the refusal.
|
|
36
|
+
|
|
37
|
+
## [0.29.0] - 2026-11-10
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- With witan-core's packed `chunk_records`, an index whose records fit one
|
|
42
|
+
load batch sends its nodes and edges as one `code_store_load` instead of
|
|
43
|
+
two, so a paced PostToolUse flush to a deployed graph is three commits on
|
|
44
|
+
the branch view (delete, load, content-hash load) instead of four.
|
|
45
|
+
- Through an `OmnigraphClient` (a local store, omnigraph over HTTP, or an
|
|
46
|
+
in-cluster index), a load that fits one batch carries the files' content
|
|
47
|
+
hashes in the same commit instead of a second load, so the flush is two
|
|
48
|
+
commits. One batch commits atomically, so a failed load still leaves the
|
|
49
|
+
files without a hash and the next run re-indexes them. A
|
|
50
|
+
`RemoteStoreClient` keeps the content-hash load, because the store tier
|
|
51
|
+
re-chunks what it receives, and one running an older witan-core splits
|
|
52
|
+
nodes from edges into separate commits.
|
|
53
|
+
- Requires `witan-core>=0.51.1`, the release with the packed
|
|
54
|
+
`chunk_records`. 0.51.0 still works, but adds a commit per flush.
|
|
55
|
+
|
|
56
|
+
### Fixed
|
|
57
|
+
|
|
58
|
+
- `--help` for `reap-views`, `setup` and the global options shows each
|
|
59
|
+
parameter's description. They were documented as `name: text` on one
|
|
60
|
+
line, which cyclopts' numpydoc parser reads as a parameter type.
|
|
61
|
+
- Indexing inside a git work tree collects git's listing (`git ls-files
|
|
62
|
+
--cached --others --exclude-standard`) instead of walking the disk, so
|
|
63
|
+
files git ignores no longer reach the code graph. The fixed skip list
|
|
64
|
+
only caught a virtualenv named `.venv` or `venv`: a dry estimate of
|
|
65
|
+
open-edx-plugins with `uv sync` into `env/` came to 703,408 records in
|
|
66
|
+
108 2 MiB loads, against 14,661 records in 5 loads now. The skip list,
|
|
67
|
+
nested-checkout exclusion and extension filter still apply on top. The
|
|
68
|
+
PostToolUse hook holds the files it names to the same rule with one
|
|
69
|
+
`git check-ignore` per batch, and the repo-level bridge extractors read
|
|
70
|
+
the same listing. Outside a work tree, or without a `git` binary, the
|
|
71
|
+
disk is walked as before. A full-repo index purges rows already stored
|
|
72
|
+
for files that are now ignored, wherever the run is allowed to purge, and
|
|
73
|
+
an edit to an ignored file drops that file's existing rows. A repository
|
|
74
|
+
git cannot list (a corrupt index, dubious ownership) is reported and
|
|
75
|
+
indexes nothing rather than falling back to the walk, and a listed path
|
|
76
|
+
under a symlinked directory is skipped.
|
|
77
|
+
|
|
78
|
+
### Security
|
|
79
|
+
|
|
80
|
+
- The "no code graph yet, index it now?" offer is no longer made to a token-authenticated remote caller. It indexed the server's own checkout, so a remote caller (including the web UI, whose token is limited to read tools) could turn a read such as `code_interface_consumers` into a write by accepting the prompt. A local stdio server still makes the offer.
|
|
81
|
+
|
|
11
82
|
## [0.28.0] - 2026-11-09
|
|
12
83
|
|
|
13
84
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: witan-code
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.30.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.52.0
|
|
30
30
|
Provides-Extra: tasks
|
|
31
31
|
Requires-Dist: fastmcp-tasks<5,>=4; extra == 'tasks'
|
|
32
32
|
Description-Content-Type: text/markdown
|
|
@@ -700,9 +700,10 @@ symlink or copy the directory into the equivalent path for your agent.
|
|
|
700
700
|
|
|
701
701
|
## Hooks
|
|
702
702
|
|
|
703
|
-
Four hooks — all bare CLI commands, no wrapper scripts, so they
|
|
704
|
-
|
|
705
|
-
|
|
703
|
+
Four hooks — all bare CLI commands, no wrapper scripts, so they need no
|
|
704
|
+
bash or setsid and run on Windows as well as Linux and macOS (there against
|
|
705
|
+
a remote deployment, since omnigraph publishes no Windows binary for a local
|
|
706
|
+
store). Named `witan-code <command>` below (standalone install via
|
|
706
707
|
`witan-code setup`); when `witan setup` folds this bundle in instead (see
|
|
707
708
|
[Install](#install)), they register as `witan code <command>` so only
|
|
708
709
|
`witan` needs to be on `PATH`. Register manually per
|
|
@@ -757,14 +758,26 @@ scripts to symlink.
|
|
|
757
758
|
|
|
758
759
|
## What gets indexed
|
|
759
760
|
|
|
760
|
-
|
|
761
|
-
|
|
761
|
+
Inside a git work tree the file set is git's own listing (`git ls-files
|
|
762
|
+
--cached --others --exclude-standard`): tracked files plus untracked files
|
|
763
|
+
that are not ignored. Anything `.gitignore`, `.git/info/exclude` or your
|
|
764
|
+
`core.excludesFile` ignores stays out of the graph, including a virtualenv
|
|
765
|
+
under any name (uv and `python -m venv` write a `*` `.gitignore` into the
|
|
766
|
+
environment they create). The edit hooks apply the same rule: an edit to an
|
|
767
|
+
ignored file is not indexed. Outside a git work tree, or without a `git`
|
|
768
|
+
binary, the indexer walks the directory instead, and only the rules below
|
|
769
|
+
apply.
|
|
770
|
+
|
|
771
|
+
On top of either, the indexer skips the usual noise directories (`.git`,
|
|
772
|
+
`node_modules`, `.venv`, `__pycache__`, `dist`, `build`, the various caches),
|
|
773
|
+
even where git tracks them, and — importantly — does
|
|
762
774
|
not descend into a **nested checkout**: any subdirectory containing a `.git`
|
|
763
775
|
entry belongs to a different repository. That covers linked worktrees
|
|
764
776
|
(`.claude/worktrees/<name>/`, where `.git` is a *file*, not a directory),
|
|
765
777
|
submodules, and plain clones dropped inside the tree. Their files are that
|
|
766
778
|
repo's; indexing them here would attribute them to this one and leave the
|
|
767
|
-
store serving stale copies of itself under a second set of paths.
|
|
779
|
+
store serving stale copies of itself under a second set of paths. A
|
|
780
|
+
submodule's files belong in its own repo's graph, not this one's.
|
|
768
781
|
|
|
769
782
|
Indexing *from inside* a worktree still works normally — only descending into
|
|
770
783
|
one from the parent is refused — so the hooks keep indexing while an agent
|
|
@@ -667,9 +667,10 @@ symlink or copy the directory into the equivalent path for your agent.
|
|
|
667
667
|
|
|
668
668
|
## Hooks
|
|
669
669
|
|
|
670
|
-
Four hooks — all bare CLI commands, no wrapper scripts, so they
|
|
671
|
-
|
|
672
|
-
|
|
670
|
+
Four hooks — all bare CLI commands, no wrapper scripts, so they need no
|
|
671
|
+
bash or setsid and run on Windows as well as Linux and macOS (there against
|
|
672
|
+
a remote deployment, since omnigraph publishes no Windows binary for a local
|
|
673
|
+
store). Named `witan-code <command>` below (standalone install via
|
|
673
674
|
`witan-code setup`); when `witan setup` folds this bundle in instead (see
|
|
674
675
|
[Install](#install)), they register as `witan code <command>` so only
|
|
675
676
|
`witan` needs to be on `PATH`. Register manually per
|
|
@@ -724,14 +725,26 @@ scripts to symlink.
|
|
|
724
725
|
|
|
725
726
|
## What gets indexed
|
|
726
727
|
|
|
727
|
-
|
|
728
|
-
|
|
728
|
+
Inside a git work tree the file set is git's own listing (`git ls-files
|
|
729
|
+
--cached --others --exclude-standard`): tracked files plus untracked files
|
|
730
|
+
that are not ignored. Anything `.gitignore`, `.git/info/exclude` or your
|
|
731
|
+
`core.excludesFile` ignores stays out of the graph, including a virtualenv
|
|
732
|
+
under any name (uv and `python -m venv` write a `*` `.gitignore` into the
|
|
733
|
+
environment they create). The edit hooks apply the same rule: an edit to an
|
|
734
|
+
ignored file is not indexed. Outside a git work tree, or without a `git`
|
|
735
|
+
binary, the indexer walks the directory instead, and only the rules below
|
|
736
|
+
apply.
|
|
737
|
+
|
|
738
|
+
On top of either, the indexer skips the usual noise directories (`.git`,
|
|
739
|
+
`node_modules`, `.venv`, `__pycache__`, `dist`, `build`, the various caches),
|
|
740
|
+
even where git tracks them, and — importantly — does
|
|
729
741
|
not descend into a **nested checkout**: any subdirectory containing a `.git`
|
|
730
742
|
entry belongs to a different repository. That covers linked worktrees
|
|
731
743
|
(`.claude/worktrees/<name>/`, where `.git` is a *file*, not a directory),
|
|
732
744
|
submodules, and plain clones dropped inside the tree. Their files are that
|
|
733
745
|
repo's; indexing them here would attribute them to this one and leave the
|
|
734
|
-
store serving stale copies of itself under a second set of paths.
|
|
746
|
+
store serving stale copies of itself under a second set of paths. A
|
|
747
|
+
submodule's files belong in its own repo's graph, not this one's.
|
|
735
748
|
|
|
736
749
|
Indexing *from inside* a worktree still works normally — only descending into
|
|
737
750
|
one from the parent is refused — so the hooks keep indexing while an agent
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "witan-code"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.30.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"
|
|
@@ -211,7 +211,18 @@ dependencies = [
|
|
|
211
211
|
# passes `actor=` to witan-core's `OmnigraphClient`, a keyword added in
|
|
212
212
|
# witan-core 0.51.0 in the same change (Omnigraph-If-Actor). 0.50 imports
|
|
213
213
|
# fine, then a deployed ingest raises TypeError.
|
|
214
|
-
|
|
214
|
+
#
|
|
215
|
+
# ★ >=0.51.1 IS A BEHAVIOURAL FLOOR, like >=0.22: 0.51.1's
|
|
216
|
+
# `chunking.chunk_records` packs nodes and edges into shared batches, so an
|
|
217
|
+
# edit-hook flush that fits one batch is one load and one commit. 0.51.0
|
|
218
|
+
# imports and runs, but batches nodes and edges apart, so every flush adds
|
|
219
|
+
# a commit to the user's code branch. `_hashes_need_deferring` calls the
|
|
220
|
+
# same `chunk_records`, so 0.51.0 stays correct, only slower on the graph.
|
|
221
|
+
#
|
|
222
|
+
# ★ >=0.52 IS AN IMPORT FLOOR: hooks.py imports `witan_core._filelock`
|
|
223
|
+
# (added in witan-core 0.52.0 by #601) at module scope, so 0.51.1 cannot
|
|
224
|
+
# import the hook commands at all.
|
|
225
|
+
"witan-core[cli,remote,observability,sentry]>=0.52.0,<1",
|
|
215
226
|
"fastmcp>=4,<5",
|
|
216
227
|
"cyclopts>=4,<6",
|
|
217
228
|
# [targets.<name>] override models (config.py) — also transitively pulled
|
|
@@ -294,7 +305,7 @@ testpaths = ["tests"]
|
|
|
294
305
|
packages = ["witan_code"]
|
|
295
306
|
|
|
296
307
|
[tool.bumpversion]
|
|
297
|
-
current_version = "0.
|
|
308
|
+
current_version = "0.30.0"
|
|
298
309
|
allow_dirty = true
|
|
299
310
|
|
|
300
311
|
[[tool.bumpversion.files]]
|
|
@@ -112,6 +112,37 @@ def test_defer_swaps_in_a_sentinel_and_returns_the_real_rows():
|
|
|
112
112
|
]
|
|
113
113
|
|
|
114
114
|
|
|
115
|
+
def test_one_batch_through_omnigraph_needs_no_deferred_hashes(monkeypatch):
|
|
116
|
+
records = [_node("a"), _edge("Calls", "a", "b"), _node("b")]
|
|
117
|
+
client = object()
|
|
118
|
+
assert not indexer._hashes_need_deferring(client, records)
|
|
119
|
+
|
|
120
|
+
one_record = len(json.dumps(records[0]).encode()) + 1
|
|
121
|
+
monkeypatch.setattr(indexer, "_ONE_LOAD_MAX_BYTES", one_record)
|
|
122
|
+
assert indexer._hashes_need_deferring(client, records)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def test_the_one_load_budget_is_no_larger_than_omnigraph_clients_chunk_at():
|
|
126
|
+
"""`_hashes_need_deferring` calls a load one commit when it fits this
|
|
127
|
+
budget, which holds only while the client splits at no less."""
|
|
128
|
+
import inspect
|
|
129
|
+
|
|
130
|
+
from witan_code.graph import OmnigraphClient
|
|
131
|
+
|
|
132
|
+
default = inspect.signature(OmnigraphClient.load).parameters["max_bytes"].default
|
|
133
|
+
assert default >= indexer._ONE_LOAD_MAX_BYTES
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def test_a_remote_store_client_always_defers_hashes():
|
|
137
|
+
"""The store tier re-chunks a received load, and an older one splits
|
|
138
|
+
nodes from edges, so one client-side batch is not one commit there."""
|
|
139
|
+
from witan_code.remote.store import RemoteStoreClient, StoreSession
|
|
140
|
+
|
|
141
|
+
session = StoreSession("http://x/mcp", lambda: "jwt", lambda _t: None)
|
|
142
|
+
client = RemoteStoreClient("https://github.com/x/y", session)
|
|
143
|
+
assert indexer._hashes_need_deferring(client, [_node("a")])
|
|
144
|
+
|
|
145
|
+
|
|
115
146
|
def test_sentinel_can_never_collide_with_a_real_hash():
|
|
116
147
|
"""The skip check is `stored == sha256(file)`; the sentinel must never match."""
|
|
117
148
|
digest = hashlib.sha256(b"anything").hexdigest()
|
|
@@ -169,6 +200,9 @@ def test_a_failed_load_leaves_the_file_reindexable(sample_repo, monkeypatch):
|
|
|
169
200
|
from witan_code import config as cfg_mod
|
|
170
201
|
from witan_code import graph as graph_mod
|
|
171
202
|
|
|
203
|
+
# The sample repo fits one batch, which loads hashes and all in one atomic
|
|
204
|
+
# commit; a budget of one byte puts it on the deferred two-load path.
|
|
205
|
+
monkeypatch.setattr(indexer, "_ONE_LOAD_MAX_BYTES", 1)
|
|
172
206
|
real_load = graph_mod.OmnigraphClient.load
|
|
173
207
|
calls = {"n": 0}
|
|
174
208
|
|
|
@@ -188,3 +222,51 @@ def test_a_failed_load_leaves_the_file_reindexable(sample_repo, monkeypatch):
|
|
|
188
222
|
stats = indexer.index_path(sample_repo, config=cfg_mod.load())
|
|
189
223
|
assert stats.indexed >= 1, "the file must be re-indexed, not skipped"
|
|
190
224
|
assert stats.skipped == 0
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@requires_stack
|
|
228
|
+
def test_a_load_that_fits_one_batch_commits_hashes_with_it(sample_repo, monkeypatch):
|
|
229
|
+
"""No sentinel and no second load when the whole write is one batch: the
|
|
230
|
+
hash lands in the same atomic commit as the file's symbols and edges."""
|
|
231
|
+
from witan_code import config as cfg_mod
|
|
232
|
+
from witan_code import graph as graph_mod
|
|
233
|
+
|
|
234
|
+
real_load = graph_mod.OmnigraphClient.load
|
|
235
|
+
loaded: list[list[dict]] = []
|
|
236
|
+
|
|
237
|
+
def _recorded(self, records, mode="merge", **kwargs):
|
|
238
|
+
loaded.append(records)
|
|
239
|
+
return real_load(self, records, mode, **kwargs)
|
|
240
|
+
|
|
241
|
+
monkeypatch.setattr(graph_mod.OmnigraphClient, "load", _recorded)
|
|
242
|
+
indexer.index_path(sample_repo, config=cfg_mod.load())
|
|
243
|
+
|
|
244
|
+
code_loads = [r for r in loaded if any(x.get("type") == "CodeFile" for x in r)]
|
|
245
|
+
assert len(code_loads) == 1
|
|
246
|
+
hashes = [
|
|
247
|
+
x["data"]["content_hash"] for x in code_loads[0] if x.get("type") == "CodeFile"
|
|
248
|
+
]
|
|
249
|
+
assert hashes and indexer._PENDING_CONTENT_HASH not in hashes
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
@requires_stack
|
|
253
|
+
def test_a_failed_single_load_leaves_the_file_reindexable(sample_repo, monkeypatch):
|
|
254
|
+
"""The sentinel's guarantee holds without it when the load is one commit:
|
|
255
|
+
a failed load writes no CodeFile row, so there is no hash to skip on."""
|
|
256
|
+
from witan_code import config as cfg_mod
|
|
257
|
+
from witan_code import graph as graph_mod
|
|
258
|
+
|
|
259
|
+
real_load = graph_mod.OmnigraphClient.load
|
|
260
|
+
|
|
261
|
+
def _fail(self, records, mode="merge", **kwargs):
|
|
262
|
+
msg = "simulated load failure"
|
|
263
|
+
raise RuntimeError(msg)
|
|
264
|
+
|
|
265
|
+
monkeypatch.setattr(graph_mod.OmnigraphClient, "load", _fail)
|
|
266
|
+
with pytest.raises(RuntimeError, match="simulated load failure"):
|
|
267
|
+
indexer.index_path(sample_repo, config=cfg_mod.load())
|
|
268
|
+
|
|
269
|
+
monkeypatch.setattr(graph_mod.OmnigraphClient, "load", real_load)
|
|
270
|
+
stats = indexer.index_path(sample_repo, config=cfg_mod.load())
|
|
271
|
+
assert stats.indexed >= 1, "the file must be re-indexed, not skipped"
|
|
272
|
+
assert stats.skipped == 0
|
|
@@ -9,6 +9,7 @@ regression here fails loudly instead of quietly going local-only.
|
|
|
9
9
|
|
|
10
10
|
from __future__ import annotations
|
|
11
11
|
|
|
12
|
+
import os
|
|
12
13
|
from types import SimpleNamespace
|
|
13
14
|
|
|
14
15
|
import pytest
|
|
@@ -109,7 +110,12 @@ def test_symbols_never_sends_a_directory_name_to_a_deployment(
|
|
|
109
110
|
|
|
110
111
|
monkeypatch.setattr("witan_code.repo.detect", _detect)
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
if remote:
|
|
114
|
+
with pytest.raises(SystemExit) as exc:
|
|
115
|
+
cli_module.symbols()
|
|
116
|
+
assert exc.value.code == 1
|
|
117
|
+
else:
|
|
118
|
+
cli_module.symbols()
|
|
113
119
|
|
|
114
120
|
# Last, not only: the local path loads config, whose target match detects too.
|
|
115
121
|
assert seen[-1] is fallback
|
|
@@ -284,10 +290,13 @@ def test_branches_prune_is_refused_in_remote_mode(monkeypatch, capsys):
|
|
|
284
290
|
monkeypatch.setattr(cli_module, "_srv", lambda: _stub(code_indexed_branches=[]))
|
|
285
291
|
monkeypatch.setattr(cli_module, "_is_remote", lambda: True)
|
|
286
292
|
|
|
287
|
-
with pytest.raises(SystemExit):
|
|
293
|
+
with pytest.raises(SystemExit) as exc:
|
|
288
294
|
cli_module.branches(prune=True)
|
|
289
295
|
|
|
290
|
-
assert
|
|
296
|
+
assert exc.value.code == 1
|
|
297
|
+
captured = capsys.readouterr()
|
|
298
|
+
assert "does not share" in captured.err
|
|
299
|
+
assert captured.out == ""
|
|
291
300
|
|
|
292
301
|
|
|
293
302
|
def test_branches_prune_is_refused_against_a_shared_store(monkeypatch, capsys):
|
|
@@ -354,11 +363,71 @@ def test_rebuild_refuses_a_path_that_is_not_the_repo_root(
|
|
|
354
363
|
with pytest.raises(SystemExit):
|
|
355
364
|
cli_module._rebuild_stores(sub, yes=True, slug="https://github.com/test/cg")
|
|
356
365
|
|
|
357
|
-
|
|
366
|
+
# Rich hard-wraps at the console width, and the wrap point moves with the
|
|
367
|
+
# length of tmp_path (i.e. TMPDIR), so compare with whitespace collapsed.
|
|
368
|
+
out = " ".join(capsys.readouterr().out.split())
|
|
358
369
|
assert "not the repo root" in out
|
|
359
370
|
assert str(root) in out
|
|
360
371
|
|
|
361
372
|
|
|
373
|
+
def _no_terminal(monkeypatch):
|
|
374
|
+
"""Make Rich see no terminal on any standard stream, with COLUMNS unset.
|
|
375
|
+
|
|
376
|
+
Rich sizes a console from fds 0, 1 and 2 before falling back to 80, so
|
|
377
|
+
clearing COLUMNS alone still picks up a terminal under ``pytest -s``.
|
|
378
|
+
"""
|
|
379
|
+
from rich.console import Console
|
|
380
|
+
|
|
381
|
+
def _not_a_terminal(*_args):
|
|
382
|
+
raise OSError
|
|
383
|
+
|
|
384
|
+
monkeypatch.delenv("COLUMNS", raising=False)
|
|
385
|
+
monkeypatch.setattr(os, "get_terminal_size", _not_a_terminal)
|
|
386
|
+
assert Console().width == 80
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def test_rebuild_refusal_keeps_a_long_path_on_one_line_when_piped(
|
|
390
|
+
tmp_path, monkeypatch, capsys
|
|
391
|
+
):
|
|
392
|
+
"""With no standard stream a terminal and COLUMNS unset, Rich renders at
|
|
393
|
+
80 columns, which is how an agent's shell or a CI job sees this CLI. A
|
|
394
|
+
hard-wrapped path longer than that is folded with a newline inside it, so
|
|
395
|
+
the path copied out of the refusal is not the path on disk.
|
|
396
|
+
"""
|
|
397
|
+
from witan_code import repo as repo_module
|
|
398
|
+
|
|
399
|
+
_no_terminal(monkeypatch)
|
|
400
|
+
root = (
|
|
401
|
+
tmp_path
|
|
402
|
+
/ "a-directory-name-long-enough-to-push-the-whole-path-past-eighty-columns"
|
|
403
|
+
)
|
|
404
|
+
sub = root / "src"
|
|
405
|
+
sub.mkdir(parents=True)
|
|
406
|
+
assert len(str(sub)) > 80
|
|
407
|
+
monkeypatch.setattr(repo_module, "git_toplevel", lambda _p: root)
|
|
408
|
+
|
|
409
|
+
with pytest.raises(SystemExit):
|
|
410
|
+
cli_module._rebuild_stores(sub, yes=True, slug="https://github.com/test/cg")
|
|
411
|
+
|
|
412
|
+
lines = capsys.readouterr().out.splitlines()
|
|
413
|
+
assert any(f"{sub} is not the repo root" in line for line in lines), lines
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
@pytest.mark.parametrize("stderr", [False, True])
|
|
417
|
+
def test_print_error_keeps_a_long_path_on_one_line_on_either_stream(
|
|
418
|
+
tmp_path, monkeypatch, capsys, stderr
|
|
419
|
+
):
|
|
420
|
+
_no_terminal(monkeypatch)
|
|
421
|
+
path = tmp_path / ("x" * 80) / "store.omni"
|
|
422
|
+
|
|
423
|
+
cli_module.print_error(f"cannot open [qa] store {path}", stderr=stderr)
|
|
424
|
+
|
|
425
|
+
captured = capsys.readouterr()
|
|
426
|
+
text = captured.err if stderr else captured.out
|
|
427
|
+
assert (captured.out if stderr else captured.err) == ""
|
|
428
|
+
assert any(f"[qa] store {path}" in line for line in text.splitlines()), text
|
|
429
|
+
|
|
430
|
+
|
|
362
431
|
def test_rebuild_refuses_a_file_path_with_real_git(tmp_path, monkeypatch, capsys):
|
|
363
432
|
"""`index`/`reindex` accept a FILE, and `git -C <file>` exits 128.
|
|
364
433
|
|
|
@@ -386,4 +455,4 @@ def test_rebuild_refuses_a_file_path_with_real_git(tmp_path, monkeypatch, capsys
|
|
|
386
455
|
with pytest.raises(SystemExit):
|
|
387
456
|
cli_module._rebuild_stores(target, yes=True, slug="https://github.com/test/cg")
|
|
388
457
|
|
|
389
|
-
assert "not the repo root" in capsys.readouterr().out
|
|
458
|
+
assert "not the repo root" in " ".join(capsys.readouterr().out.split())
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Every witan-code command's parameter docs reach ``--help``."""
|
|
2
|
+
|
|
3
|
+
from testsupport.cli_docstrings import one_line_param_docs
|
|
4
|
+
|
|
5
|
+
from witan_code.cli import app
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_no_command_documents_a_parameter_on_one_line():
|
|
9
|
+
assert one_line_param_docs(app, "witan_code") == []
|
|
@@ -135,3 +135,24 @@ def test_inject_context_cmd_passes_an_explicit_client_through(monkeypatch, clien
|
|
|
135
135
|
command(*bound.args, **bound.kwargs)
|
|
136
136
|
|
|
137
137
|
assert seen == [client]
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@pytest.mark.parametrize(
|
|
141
|
+
("argv", "lock_fd"),
|
|
142
|
+
[
|
|
143
|
+
(["_drain-pending", "repo", "7"], 7), # POSIX: the inherited lock
|
|
144
|
+
(["_drain-pending", "repo"], None), # Windows: the drainer locks
|
|
145
|
+
],
|
|
146
|
+
)
|
|
147
|
+
def test_drain_pending_cmd_takes_an_optional_lock_fd(monkeypatch, argv, lock_fd):
|
|
148
|
+
import witan_code.hooks as hooks_module
|
|
149
|
+
|
|
150
|
+
seen = []
|
|
151
|
+
monkeypatch.setattr(
|
|
152
|
+
hooks_module, "drain_pending", lambda checkout, fd: seen.append(fd)
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
command, bound, _ = cli.app.parse_args(argv)
|
|
156
|
+
command(*bound.args, **bound.kwargs)
|
|
157
|
+
|
|
158
|
+
assert seen == [lock_fd]
|
|
@@ -200,6 +200,23 @@ def test_a_bracketed_title_is_not_escaped_in_structured_output(capsys):
|
|
|
200
200
|
assert json.loads(capsys.readouterr().out)["title"] == "Symbol table — [local]"
|
|
201
201
|
|
|
202
202
|
|
|
203
|
+
@pytest.mark.parametrize("fmt", ["json", "toml", "yaml"])
|
|
204
|
+
def test_symbols_with_no_repo_fails_on_stderr(monkeypatch, capsys, fmt):
|
|
205
|
+
"""A refusal is not a document: stdout stays empty for the parser and the
|
|
206
|
+
exit status says the command did not run."""
|
|
207
|
+
output_module.set_output_format(fmt)
|
|
208
|
+
monkeypatch.setattr(cli_module, "_is_remote", lambda: True)
|
|
209
|
+
monkeypatch.setattr("witan_code.repo.detect", lambda *a, **kw: None)
|
|
210
|
+
|
|
211
|
+
with pytest.raises(SystemExit) as exc:
|
|
212
|
+
cli_module.symbols()
|
|
213
|
+
|
|
214
|
+
assert exc.value.code == 1
|
|
215
|
+
captured = capsys.readouterr()
|
|
216
|
+
assert captured.out == ""
|
|
217
|
+
assert "No repo detected" in captured.err
|
|
218
|
+
|
|
219
|
+
|
|
203
220
|
def test_launcher_sets_output_format_and_forwards_tokens(monkeypatch):
|
|
204
221
|
calls = []
|
|
205
222
|
monkeypatch.setattr(cli_module, "app", lambda tokens: calls.append(tokens))
|
|
@@ -322,6 +322,46 @@ def test_reindex_offer_degrades_on_indexing_failure(tmp_path, monkeypatch):
|
|
|
322
322
|
assert _fn(srv.code_interface_consumers)("env_var", "X", ctx=_AcceptCtx(True)) == []
|
|
323
323
|
|
|
324
324
|
|
|
325
|
+
@requires_stack
|
|
326
|
+
def test_reindex_offer_is_never_made_to_a_remote_caller(tmp_path, monkeypatch):
|
|
327
|
+
"""A token-authenticated caller never gets the index-now offer, even with an
|
|
328
|
+
accepting ctx: it would index the SERVER's checkout, and the web UI's
|
|
329
|
+
read-only token could otherwise reach a write through a bound read tool
|
|
330
|
+
(code_interface_*, code_repo_dependencies)."""
|
|
331
|
+
import fastmcp.server.dependencies as deps
|
|
332
|
+
from fastmcp.server.auth import AccessToken
|
|
333
|
+
|
|
334
|
+
from witan_code import config as cfg_mod
|
|
335
|
+
from witan_code import indexer
|
|
336
|
+
from witan_code import server as srv
|
|
337
|
+
|
|
338
|
+
repo = "https://github.com/test/cg-remote-caller"
|
|
339
|
+
monkeypatch.setenv("WITAN_REPO", repo)
|
|
340
|
+
monkeypatch.setenv("WITAN_CODE_DIR", str(tmp_path / "code"))
|
|
341
|
+
monkeypatch.setattr(srv, "cfg", cfg_mod.load())
|
|
342
|
+
srv._clients.clear()
|
|
343
|
+
|
|
344
|
+
src = tmp_path / "src"
|
|
345
|
+
src.mkdir()
|
|
346
|
+
(src / "svc.py").write_text(SAMPLE)
|
|
347
|
+
monkeypatch.chdir(src)
|
|
348
|
+
srv._git_context.clear()
|
|
349
|
+
|
|
350
|
+
indexed = []
|
|
351
|
+
monkeypatch.setattr(indexer, "index_path", lambda *a, **kw: indexed.append(a))
|
|
352
|
+
ui_token = AccessToken(
|
|
353
|
+
token="t", client_id="witan-ui", scopes=[], claims={"azp": "witan-ui"}
|
|
354
|
+
)
|
|
355
|
+
monkeypatch.setattr(deps, "get_access_token", lambda: ui_token)
|
|
356
|
+
|
|
357
|
+
accept = _AcceptCtx(True)
|
|
358
|
+
assert _fn(srv.code_interface_providers)("env_var", "X", ctx=accept) == []
|
|
359
|
+
assert _fn(srv.code_interface_consumers)("env_var", "X", ctx=accept) == []
|
|
360
|
+
assert _fn(srv.code_repo_dependencies)(ctx=accept) == {"repos": [], "edges": []}
|
|
361
|
+
assert _fn(srv.code_find_references)(f"{repo}#svc.py::helper", ctx=accept) == []
|
|
362
|
+
assert indexed == []
|
|
363
|
+
|
|
364
|
+
|
|
325
365
|
# ── Opportunity 3: code_find_definition disambiguates multi-repo matches ─────
|
|
326
366
|
|
|
327
367
|
RA = "https://github.com/test/def-repo-a"
|