witan-code 0.31.0__tar.gz → 0.32.1__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.31.0 → witan_code-0.32.1}/CHANGELOG.md +43 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/PKG-INFO +11 -12
- {witan_code-0.31.0 → witan_code-0.32.1}/README.md +9 -10
- {witan_code-0.31.0 → witan_code-0.32.1}/docs/USER_GUIDE.md +9 -4
- {witan_code-0.31.0 → witan_code-0.32.1}/pyproject.toml +8 -3
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/conftest.py +15 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_branches.py +68 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_diff_impact.py +103 -7
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_indexer_scope.py +158 -3
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_remote_proxy.py +3 -14
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_remote_store.py +3 -4
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_search_docstrings.py +66 -13
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_server.py +21 -1
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_store.py +9 -10
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_tool_schema.py +44 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_why.py +40 -5
- witan_code-0.32.1/tests/test_xref.py +398 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/cli.py +12 -16
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/config.py +5 -48
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/diff_impact.py +42 -13
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/indexer.py +235 -19
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/ingest.py +5 -3
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/queries/code_read.gq +2 -2
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/remote/store.py +5 -3
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/repo.py +27 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/schema/bridge-schema.pg +2 -1
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/schema/code-schema.pg +5 -4
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/server.py +198 -172
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/store.py +24 -22
- witan_code-0.32.1/witan_code/xref.py +347 -0
- witan_code-0.31.0/tests/test_config.py +0 -64
- {witan_code-0.31.0 → witan_code-0.32.1}/.gitignore +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/changelog.d/README.md +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/config/claude.json +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/config/copilot.json +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/config/pi.json +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/conftest.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/docs/BRANCH_INDEXING.md +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/docs/CLI_REFERENCE.md +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/docs/EDGE_PRECISION_TIERS.md +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/docs/PACKAGE_MAP.md +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/docs/STAGE2_STITCHING.md +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/docs/SYMBOL_FORMAT.md +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/docs/SYMBOL_TABLE.md +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/install.sh +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/__init__.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_batched_deletes.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_branches_served.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_bridge.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_chunked_load.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_cli_dispatch.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_cli_help_docstrings.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_cli_hooks.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_cli_output_format.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_cli_selected_target.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_config_targets.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_context.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_crossrepo.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_edges.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_elicit.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_enrichment.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_github_app.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_graph.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_hooks.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_identity.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_index_failure_diagnostics.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_index_reports_its_store.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_index_requires_a_repo_key.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_indexer.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_ingest.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_languages.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_maintenance.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_package_map.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_reaper.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_rebuild_honours_the_repo_key.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_refusal_audit.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_repo.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_setup.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_stitch.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_symbol_table.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_tasks.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_views.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/tests/test_visualize.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/__init__.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/__main__.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/bridge.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/bridge_extractors.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/context.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/edges.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/elicit.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/extensions/pi/codegraph.ts +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/github_app.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/graph.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/hooks.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/identity.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/maintenance.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/output.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/package_map.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/queries/bridge.gq +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/queries/code_mutations.gq +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/queries/delete.gq +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/queries_ts/bash.scm +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/queries_ts/hcl.scm +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/queries_ts/python.scm +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/queries_ts/sql.scm +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/queries_ts/typescript.scm +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/queries_ts/yaml.scm +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/reaper.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/remote/__init__.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/remote/oidc.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/remote/proxy.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/selected_target.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/setup.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/skills/witan-code/SKILL.md +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/stitch.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/views.py +0 -0
- {witan_code-0.31.0 → witan_code-0.32.1}/witan_code/visualize.py +0 -0
|
@@ -8,6 +8,49 @@ a MINOR bump may include breaking changes).
|
|
|
8
8
|
|
|
9
9
|
<!-- scriv-insert-here -->
|
|
10
10
|
|
|
11
|
+
## [0.32.1] - 2026-11-18
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- A TS/JS import that names the repo root (`import { f } from '.'` or `'./'` in a root-level file, `'..'` from one directory down) resolves to the root `index.ts`/`index.js`. It used to resolve to the path `.`, which matched no file, so those calls had no `Calls` edge and `code_callers` missed them. Existing stores get the edges when the importing file is next indexed, or with one `witan-code reindex`.
|
|
16
|
+
|
|
17
|
+
## [0.32.0] - 2026-11-17
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- `code_callers` accepts an optional `branch`, with the semantics `code_impact` and `code_find_definition` already have. A deployed server has no checkout to follow, so a remote caller could only read the default view; `branch="feature/x"` reads that branch's callers or callees. Omitted, the tool follows the checkout's branch view for the current repo as before.
|
|
22
|
+
|
|
23
|
+
- `code_find_definition` takes `symbol_id` in place of `name` to look up one exact id: it returns that symbol alone, or `[]` when the id's repo has no index or the index has no such symbol. A name lookup is capped at 50 rows, so it could not answer "is this id still defined" for a name that repeats across files (every `<module>`, Django's `Command.handle`). The lookup is routed by the id's repo like the other id-routed tools, and `branch` selects the view as it does for a name lookup. Passing both `name` and `symbol_id`, or neither, is refused.
|
|
24
|
+
|
|
25
|
+
- The indexer resolves calls into other files of the repo through each file's imports, for Python (absolute and relative imports, `from pkg import mod`, `import pkg.mod as m`) and TS/JS (relative `import { f }` and `import * as ns`). A call whose callee is an imported name or an attribute chain rooted at one (`f()`, `mod.f()`, `Cls.method()`) gets a `Calls`/`References` edge to the symbol in the other file, so `code_callers`, `code_impact` and `witan code diff-impact` now list callers in other modules, on main and branch views alike. Calls through an instance (`obj.method()`), re-exports, star imports, `require()` and path aliases are not followed. Existing stores need one `witan-code reindex` (or a forced CI index) to get these edges for files that have not changed since.
|
|
26
|
+
- Indexing a file re-links the stored files that mention its module name (and, for a package `__init__.py` or an `index.ts`, the names it defines, since `from . import f` or `from './index'` reaches it without its directory's name), found with one `git grep` over the work tree. Re-indexing a file deletes its symbols and every edge into them, so without this the edit hook's one-file run dropped a module's cross-file callers. It also links a caller written before the module or function it calls. The re-linked files' own rows are not rewritten.
|
|
27
|
+
|
|
28
|
+
- Every tool carries MCP annotations. The `code_*` queries and the read-only
|
|
29
|
+
`code_store_*` tools are `readOnlyHint`; `code_store_open` is
|
|
30
|
+
non-destructive and idempotent; `code_reindex` is destructive and
|
|
31
|
+
idempotent, because it deletes a changed file's rows before loading their
|
|
32
|
+
replacements; the `code_store_mutate*` and `code_store_load` tools are
|
|
33
|
+
destructive.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- `code_search_symbol` returns `{"symbols": [...]}` instead of a bare list, so the result has room for the `note` below. A caller that read the list now reads `result["symbols"]`.
|
|
38
|
+
|
|
39
|
+
- `witan code diff-impact` takes "tests to run" from a symbol's callers when the graph can reach them (a module-level Python function or class, or a module-level TS/JS function). The `git grep` name search now runs only for methods and nested defs, TS/JS classes, interfaces and type aliases, languages without import resolution, and a repo with no code graph, and the label drops "(stand-in)".
|
|
40
|
+
|
|
41
|
+
- The cluster graph-id function moved to witan-core as `witan_core.graph_ids.code_graph_id`, along with `CODE_GRAPH_PREFIX`, `BRIDGE_GRAPH_ID` and `GRAPH_ID_RE`. `witan_code.config` no longer defines them. The ids it returns are unchanged. Requires witan-core 0.57.0.
|
|
42
|
+
|
|
43
|
+
- Parameter descriptions are cut to what an agent needs to choose a value.
|
|
44
|
+
`repo`, `branch`, `symbol_id` and `min_precision` point at the server
|
|
45
|
+
instructions instead of repeating them. The manifest drops from 25,598 to
|
|
46
|
+
21,157 characters.
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
|
|
50
|
+
- A file named directly to the indexer (the edit hook's case) is held to the full walk's path rules as well as git's ignore rules, under the name the walk would list it by. An edit under an excluded directory (e.g. `build/`, `node_modules/`), below a nested checkout, or below a symlinked directory was indexed, and the next full index purged it again. Such a file now writes nothing, and rows it already has are dropped on that edit unless the walk still collects the file under its own resolved path (e.g. an excluded `build/alias.py -> ../a.py` leaves `a.py` alone). `witan code why` reports it as `not indexed: <rule>`, and points rows a rule now excludes at a full index of the repo.
|
|
51
|
+
|
|
52
|
+
- `code_search_symbol` says when it skipped the docstring search. A store whose schema has no `Symbol.docstring` index, or a deployed witan-code tier older than the docstring query, answers with name matches only, and the only sign was a warning in the server's log, which a client of a deployed store never sees. The result now carries a `note` starting `docstring search unavailable` that gives the reason and, in a cross-repo fan-out, how many of the stores searched skipped it. The tool docs also say that only the first 500 characters of a docstring are indexed.
|
|
53
|
+
|
|
11
54
|
## [0.31.0] - 2026-11-13
|
|
12
55
|
|
|
13
56
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: witan-code
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.32.1
|
|
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.57.0
|
|
30
30
|
Provides-Extra: tasks
|
|
31
31
|
Requires-Dist: fastmcp-tasks<5,>=4; extra == 'tasks'
|
|
32
32
|
Description-Content-Type: text/markdown
|
|
@@ -376,14 +376,13 @@ bindings.
|
|
|
376
376
|
|
|
377
377
|
Set `code_server` (env `WITAN_CODE_SERVER`) and each repo's code graph is
|
|
378
378
|
instead a graph on the deployed omnigraph-server, addressed as `--server <url>
|
|
379
|
-
--graph <id>` with the id from `
|
|
379
|
+
--graph <id>` with the id from `witan_core.graph_ids.code_graph_id()` — e.g.
|
|
380
380
|
`https://github.com/mitodl/ol-django` → `code-github-com-mitodl-ol-django`.
|
|
381
|
-
The bridge graph is the fixed `code-bridge`.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
and
|
|
385
|
-
|
|
386
|
-
ids the server actually serves.
|
|
381
|
+
The bridge graph is the fixed `code-bridge`. ol-infrastructure's provisioning
|
|
382
|
+
(`applications/omnigraph/cluster_config.py`) imports the same function from
|
|
383
|
+
witan-core to *declare* the graphs and apply their schema; this client never
|
|
384
|
+
creates one, and indexing a repo the cluster has no graph for fails immediately
|
|
385
|
+
with the id it expected and the ids the server actually serves.
|
|
387
386
|
|
|
388
387
|
This is the **data tier** and is independent of `remote_url`
|
|
389
388
|
([Remote mode](#remote-mode)), which routes read *tools* through a deployed
|
|
@@ -505,10 +504,10 @@ indexer first).
|
|
|
505
504
|
|
|
506
505
|
| Tool | Returns |
|
|
507
506
|
|------|---------|
|
|
508
|
-
| `code_find_definition(name)` | symbols whose name / qualified name matches |
|
|
507
|
+
| `code_find_definition(name)` / `code_find_definition(symbol_id=...)` | symbols whose name / qualified name matches (at most 50 per repo), or the one symbol with that exact id |
|
|
509
508
|
| `code_find_references(symbol_id)` | incoming `References` + `Calls` |
|
|
510
|
-
| `code_callers(symbol_id, direction="callers")` | incoming `Calls`; `direction="callees"` for outgoing |
|
|
511
|
-
| `code_impact(symbol_id, max_depth=5, max_nodes=200)` | transitive callers via BFS |
|
|
509
|
+
| `code_callers(symbol_id, direction="callers", branch=None)` | incoming `Calls`; `direction="callees"` for outgoing |
|
|
510
|
+
| `code_impact(symbol_id, max_depth=5, max_nodes=200, branch=None)` | transitive callers via BFS |
|
|
512
511
|
| `code_symbols_in_file(path)` | symbols defined in a file |
|
|
513
512
|
| `code_search_symbol(query)` | BM25 search over symbol qualified names, then docstrings (name matches first) |
|
|
514
513
|
| `code_reindex(path=None)` | index/re-index the repo or a subpath |
|
|
@@ -343,14 +343,13 @@ bindings.
|
|
|
343
343
|
|
|
344
344
|
Set `code_server` (env `WITAN_CODE_SERVER`) and each repo's code graph is
|
|
345
345
|
instead a graph on the deployed omnigraph-server, addressed as `--server <url>
|
|
346
|
-
--graph <id>` with the id from `
|
|
346
|
+
--graph <id>` with the id from `witan_core.graph_ids.code_graph_id()` — e.g.
|
|
347
347
|
`https://github.com/mitodl/ol-django` → `code-github-com-mitodl-ol-django`.
|
|
348
|
-
The bridge graph is the fixed `code-bridge`.
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
and
|
|
352
|
-
|
|
353
|
-
ids the server actually serves.
|
|
348
|
+
The bridge graph is the fixed `code-bridge`. ol-infrastructure's provisioning
|
|
349
|
+
(`applications/omnigraph/cluster_config.py`) imports the same function from
|
|
350
|
+
witan-core to *declare* the graphs and apply their schema; this client never
|
|
351
|
+
creates one, and indexing a repo the cluster has no graph for fails immediately
|
|
352
|
+
with the id it expected and the ids the server actually serves.
|
|
354
353
|
|
|
355
354
|
This is the **data tier** and is independent of `remote_url`
|
|
356
355
|
([Remote mode](#remote-mode)), which routes read *tools* through a deployed
|
|
@@ -472,10 +471,10 @@ indexer first).
|
|
|
472
471
|
|
|
473
472
|
| Tool | Returns |
|
|
474
473
|
|------|---------|
|
|
475
|
-
| `code_find_definition(name)` | symbols whose name / qualified name matches |
|
|
474
|
+
| `code_find_definition(name)` / `code_find_definition(symbol_id=...)` | symbols whose name / qualified name matches (at most 50 per repo), or the one symbol with that exact id |
|
|
476
475
|
| `code_find_references(symbol_id)` | incoming `References` + `Calls` |
|
|
477
|
-
| `code_callers(symbol_id, direction="callers")` | incoming `Calls`; `direction="callees"` for outgoing |
|
|
478
|
-
| `code_impact(symbol_id, max_depth=5, max_nodes=200)` | transitive callers via BFS |
|
|
476
|
+
| `code_callers(symbol_id, direction="callers", branch=None)` | incoming `Calls`; `direction="callees"` for outgoing |
|
|
477
|
+
| `code_impact(symbol_id, max_depth=5, max_nodes=200, branch=None)` | transitive callers via BFS |
|
|
479
478
|
| `code_symbols_in_file(path)` | symbols defined in a file |
|
|
480
479
|
| `code_search_symbol(query)` | BM25 search over symbol qualified names, then docstrings (name matches first) |
|
|
481
480
|
| `code_reindex(path=None)` | index/re-index the repo or a subpath |
|
|
@@ -236,10 +236,15 @@ Don't re-derive the mechanics here — see:
|
|
|
236
236
|
`branch` argument of `code_find_definition` / `code_search_symbol` /
|
|
237
237
|
`code_symbols_in_file`) to read it.
|
|
238
238
|
- **Caller/impact results look wrong or incomplete.** `Calls`, `References`,
|
|
239
|
-
`Imports`, and `Inherits` are **heuristic** — syntactic name resolution
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
239
|
+
`Imports`, and `Inherits` are **heuristic** — syntactic name resolution.
|
|
240
|
+
A call resolves to a definition in the same file, or, in Python and TS/JS,
|
|
241
|
+
to one in another file of the repo when the callee is an imported name or
|
|
242
|
+
an attribute of one (`mod.func()`, `Cls.method()`). Calls through an
|
|
243
|
+
instance (`obj.method()`), re-exports, star imports, `require()`, path
|
|
244
|
+
aliases, and shadowing aren't followed. After upgrading, run
|
|
245
|
+
`witan-code reindex` once: an incremental run skips unchanged files,
|
|
246
|
+
so their calls into other files are not resolved until they change.
|
|
247
|
+
Treat them as a high-recall starting point for investigation,
|
|
243
248
|
not a verified call graph. `Defines`/`Contains` (and Stage-2 precise
|
|
244
249
|
cross-repo edges) are exact by contrast.
|
|
245
250
|
- **No pre-built `omnigraph` binary for your platform.** Only
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "witan-code"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.32.1"
|
|
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"
|
|
@@ -226,7 +226,12 @@ dependencies = [
|
|
|
226
226
|
# ★ >=0.52 IS AN IMPORT FLOOR: hooks.py imports `witan_core._filelock`
|
|
227
227
|
# (added in witan-core 0.52.0 by #601) at module scope, so 0.51.1 cannot
|
|
228
228
|
# import the hook commands at all.
|
|
229
|
-
|
|
229
|
+
#
|
|
230
|
+
# ★ >=0.57 IS AN IMPORT FLOOR: store.py, indexer.py and ingest.py import
|
|
231
|
+
# `witan_core.graph_ids` at module scope. It moved there from config.py so
|
|
232
|
+
# ol-infrastructure's cluster provisioning can import the same function
|
|
233
|
+
# instead of mirroring it.
|
|
234
|
+
"witan-core[cli,remote,observability,sentry]>=0.57.0,<1",
|
|
230
235
|
"fastmcp>=4,<5",
|
|
231
236
|
"cyclopts>=4,<6",
|
|
232
237
|
# [targets.<name>] override models (config.py) — also transitively pulled
|
|
@@ -309,7 +314,7 @@ testpaths = ["tests"]
|
|
|
309
314
|
packages = ["witan_code"]
|
|
310
315
|
|
|
311
316
|
[tool.bumpversion]
|
|
312
|
-
current_version = "0.
|
|
317
|
+
current_version = "0.32.1"
|
|
313
318
|
allow_dirty = true
|
|
314
319
|
|
|
315
320
|
[[tool.bumpversion.files]]
|
|
@@ -8,6 +8,8 @@ tree-sitter-<lang> wheels, not the optional tree-sitter-language-pack), not an
|
|
|
8
8
|
optional extra — so there's nothing to gate on there.
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
+
import asyncio
|
|
12
|
+
import inspect
|
|
11
13
|
import shutil
|
|
12
14
|
|
|
13
15
|
import pytest
|
|
@@ -19,6 +21,19 @@ requires_stack = pytest.mark.skipif(
|
|
|
19
21
|
reason="requires omnigraph binary",
|
|
20
22
|
)
|
|
21
23
|
|
|
24
|
+
|
|
25
|
+
def tool_fn(tool):
|
|
26
|
+
"""A FastMCP tool as a plain callable; an ``async`` one runs to completion.
|
|
27
|
+
|
|
28
|
+
Called directly rather than through an MCP client, a tool that takes a
|
|
29
|
+
``ctx: Context`` gets none and falls back to its non-interactive default.
|
|
30
|
+
"""
|
|
31
|
+
fn = getattr(tool, "fn", tool)
|
|
32
|
+
if inspect.iscoroutinefunction(fn):
|
|
33
|
+
return lambda *a, **kw: asyncio.run(fn(*a, **kw))
|
|
34
|
+
return fn
|
|
35
|
+
|
|
36
|
+
|
|
22
37
|
# Narrower than requires_stack: maintenance (optimize/cleanup) exercises the
|
|
23
38
|
# omnigraph binary directly and has no tree-sitter involvement.
|
|
24
39
|
requires_omnigraph = pytest.mark.skipif(
|
|
@@ -913,3 +913,71 @@ def test_cross_repo_impact_reads_the_named_branchs_overlay(
|
|
|
913
913
|
|
|
914
914
|
on_main = _fn(srv.code_cross_repo_impact)(retired, branch="main")
|
|
915
915
|
assert {b["repo"] for b in on_main["cross_repo"]} == {PROVIDER}
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
@requires_stack
|
|
919
|
+
def test_callers_reads_the_named_branchs_view(removal_on_an_indexed_branch):
|
|
920
|
+
srv = removal_on_an_indexed_branch
|
|
921
|
+
helper = f"{REPO}#svc.py::helper"
|
|
922
|
+
|
|
923
|
+
def callers(**kwargs):
|
|
924
|
+
return {c["qualified_name"] for c in _fn(srv.code_callers)(helper, **kwargs)}
|
|
925
|
+
|
|
926
|
+
on_branch, on_main = callers(), callers(branch="main")
|
|
927
|
+
assert "fresh" in on_branch and "retired" not in on_branch
|
|
928
|
+
assert "retired" in on_main and "fresh" not in on_main
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
@requires_stack
|
|
932
|
+
def test_callers_reads_a_branch_from_a_server_with_no_checkout(
|
|
933
|
+
removal_on_an_indexed_branch, tmp_path, monkeypatch
|
|
934
|
+
):
|
|
935
|
+
"""A deployed server has no checkout to follow, so without `branch` it
|
|
936
|
+
reads main, and `branch` is the only way to reach a branch's edges."""
|
|
937
|
+
srv = removal_on_an_indexed_branch
|
|
938
|
+
elsewhere = tmp_path / "not-a-repo"
|
|
939
|
+
elsewhere.mkdir()
|
|
940
|
+
monkeypatch.chdir(elsewhere)
|
|
941
|
+
monkeypatch.delenv("WITAN_REPO")
|
|
942
|
+
srv._git_context.clear()
|
|
943
|
+
assert srv._cached_detect() is None
|
|
944
|
+
helper = f"{REPO}#svc.py::helper"
|
|
945
|
+
|
|
946
|
+
def callers(**kwargs):
|
|
947
|
+
return {c["qualified_name"] for c in _fn(srv.code_callers)(helper, **kwargs)}
|
|
948
|
+
|
|
949
|
+
default, on_branch = callers(), callers(branch="feature/x")
|
|
950
|
+
assert "retired" in default and "fresh" not in default
|
|
951
|
+
assert "fresh" in on_branch and "retired" not in on_branch
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
@requires_stack
|
|
955
|
+
def test_callers_keeps_the_branch_after_the_reindex_offer(
|
|
956
|
+
removal_on_an_indexed_branch, monkeypatch
|
|
957
|
+
):
|
|
958
|
+
"""The missing-store fallback indexes the checkout, then must still read
|
|
959
|
+
the view `branch` names, not the checkout's own (feature/x here)."""
|
|
960
|
+
from witan_code import indexer
|
|
961
|
+
|
|
962
|
+
from .test_elicit import _AcceptCtx
|
|
963
|
+
|
|
964
|
+
srv = removal_on_an_indexed_branch
|
|
965
|
+
indexed = []
|
|
966
|
+
real_client_for_symbol = srv._client_for_symbol
|
|
967
|
+
monkeypatch.setattr(
|
|
968
|
+
srv,
|
|
969
|
+
"_client_for_symbol",
|
|
970
|
+
lambda sid, branch=None: (
|
|
971
|
+
real_client_for_symbol(sid, branch) if indexed else None
|
|
972
|
+
),
|
|
973
|
+
)
|
|
974
|
+
monkeypatch.setattr(
|
|
975
|
+
indexer, "index_path", lambda *args, **kwargs: indexed.append(True)
|
|
976
|
+
)
|
|
977
|
+
helper = f"{REPO}#svc.py::helper"
|
|
978
|
+
|
|
979
|
+
rows = _fn(srv.code_callers)(helper, branch="main", ctx=_AcceptCtx(True))
|
|
980
|
+
|
|
981
|
+
assert indexed
|
|
982
|
+
names = {c["qualified_name"] for c in rows}
|
|
983
|
+
assert "retired" in names and "fresh" not in names
|
|
@@ -230,10 +230,10 @@ def test_changed_symbols_reports_files_the_indexer_does_not_parse():
|
|
|
230
230
|
# ── the report, against stubbed tools ─────────────────────────────
|
|
231
231
|
|
|
232
232
|
|
|
233
|
-
def _changed(n):
|
|
233
|
+
def _changed(n, kind="function"):
|
|
234
234
|
return [
|
|
235
235
|
diff_impact.ChangedSymbol(
|
|
236
|
-
f"{REPO}#m.py::f{i}", "m.py", f"f{i}",
|
|
236
|
+
f"{REPO}#m.py::f{i}", "m.py", f"f{i}", kind, i, "modified"
|
|
237
237
|
)
|
|
238
238
|
for i in range(n)
|
|
239
239
|
]
|
|
@@ -256,7 +256,8 @@ def test_report_bounds_every_list_and_says_so():
|
|
|
256
256
|
"modified",
|
|
257
257
|
)
|
|
258
258
|
report = diff_impact.build_report(
|
|
259
|
-
|
|
259
|
+
# Methods, whose tests the graph cannot reach, so the name search runs.
|
|
260
|
+
[*_changed(5, kind="method"), test_change],
|
|
260
261
|
[],
|
|
261
262
|
renamed=["old.py -> m.py"],
|
|
262
263
|
repo=REPO,
|
|
@@ -281,13 +282,109 @@ def test_report_bounds_every_list_and_says_so():
|
|
|
281
282
|
text = diff_impact.render_text(report, header="h")
|
|
282
283
|
assert "Showing 2 of 5 changed symbols" in text
|
|
283
284
|
assert "callers (30, showing 3)" in text
|
|
284
|
-
assert "m.py::f1 (
|
|
285
|
+
assert "m.py::f1 (method, modified) [not in index]" in text
|
|
285
286
|
assert "witan (council) is not installed" in text
|
|
286
287
|
# A rename moves every id in the file, so it must not vanish from the report.
|
|
287
288
|
assert "Renamed files (1): old.py -> m.py" in text
|
|
288
289
|
assert "A renamed file moves every symbol id" in text
|
|
289
290
|
|
|
290
291
|
|
|
292
|
+
def test_a_functions_tests_come_from_its_callers_not_a_name_search():
|
|
293
|
+
"""Python calls resolve across files, so a test calling the function is
|
|
294
|
+
one of its callers, and naming it without calling it is not a test of it."""
|
|
295
|
+
|
|
296
|
+
def no_search(name):
|
|
297
|
+
raise AssertionError(f"searched for {name!r} by name")
|
|
298
|
+
|
|
299
|
+
tools = {
|
|
300
|
+
"code_indexed_repos": lambda: [{"repo": REPO}],
|
|
301
|
+
"code_symbols_in_file": lambda **_: [{"symbol_id": f"{REPO}#m.py::f0"}],
|
|
302
|
+
"code_impact": lambda **_: {
|
|
303
|
+
"impacted": [
|
|
304
|
+
{"symbol_id": f"{REPO}#tests/test_m.py::test_f0", "depth": 1},
|
|
305
|
+
{"symbol_id": f"{REPO}#app.py::serve", "depth": 1},
|
|
306
|
+
],
|
|
307
|
+
"truncated": False,
|
|
308
|
+
},
|
|
309
|
+
"code_cross_repo_impact": lambda **_: {"cross_repo": []},
|
|
310
|
+
}
|
|
311
|
+
report = diff_impact.build_report(
|
|
312
|
+
_changed(1),
|
|
313
|
+
[],
|
|
314
|
+
renamed=[],
|
|
315
|
+
repo=REPO,
|
|
316
|
+
branch=None,
|
|
317
|
+
code=tools.__getitem__,
|
|
318
|
+
work=None,
|
|
319
|
+
test_mentions=no_search,
|
|
320
|
+
view=None,
|
|
321
|
+
limit=10,
|
|
322
|
+
max_items=10,
|
|
323
|
+
)
|
|
324
|
+
row = report["changed_symbols"]["shown"][0]
|
|
325
|
+
assert row["tests_to_run"]["shown"] == ["tests/test_m.py"]
|
|
326
|
+
assert row["callers"]["shown"] == ["app.py::serve"]
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
LINKED_PY = """\
|
|
330
|
+
class Service:
|
|
331
|
+
def run(self):
|
|
332
|
+
return 1
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def helper():
|
|
336
|
+
return 1
|
|
337
|
+
"""
|
|
338
|
+
|
|
339
|
+
LINKED_TS = """\
|
|
340
|
+
export class Store {
|
|
341
|
+
get() {
|
|
342
|
+
return 1;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export interface Shape {
|
|
347
|
+
size: number;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export type Id = string;
|
|
351
|
+
|
|
352
|
+
export function load() {
|
|
353
|
+
return new Store();
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export const make = () => 1;
|
|
357
|
+
"""
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
@pytest.mark.parametrize(
|
|
361
|
+
("path", "line", "qualified_name", "expected"),
|
|
362
|
+
[
|
|
363
|
+
("svc.py", 7, "helper", True),
|
|
364
|
+
("svc.py", 1, "Service", True),
|
|
365
|
+
# Recorded as a function, but called through an instance.
|
|
366
|
+
("svc.py", 3, "Service.run", False),
|
|
367
|
+
("web/s.ts", 14, "load", True),
|
|
368
|
+
("web/s.ts", 17, "make", True),
|
|
369
|
+
# `new Store()` and type positions are not calls the parser captures.
|
|
370
|
+
("web/s.ts", 1, "Store", False),
|
|
371
|
+
("web/s.ts", 3, "Store.get", False),
|
|
372
|
+
("web/s.ts", 8, "Shape", False),
|
|
373
|
+
("web/s.ts", 11, "Id", False),
|
|
374
|
+
],
|
|
375
|
+
)
|
|
376
|
+
def test_graph_reaches_callers_only_for_what_the_resolver_links(
|
|
377
|
+
path, line, qualified_name, expected
|
|
378
|
+
):
|
|
379
|
+
source = {"svc.py": LINKED_PY, "web/s.ts": LINKED_TS}[path]
|
|
380
|
+
files = [diff_impact.FileDiff(path, path, {line}, {line})]
|
|
381
|
+
(sym,), _ = diff_impact.changed_symbols(
|
|
382
|
+
files, repo=REPO, read_blob=lambda *_: source.encode()
|
|
383
|
+
)
|
|
384
|
+
assert sym.qualified_name == qualified_name
|
|
385
|
+
assert diff_impact.graph_reaches_callers(sym) is expected
|
|
386
|
+
|
|
387
|
+
|
|
291
388
|
def test_test_mentions_match_across_one_language_family():
|
|
292
389
|
tools = {
|
|
293
390
|
"code_indexed_repos": list,
|
|
@@ -524,8 +621,7 @@ def test_diff_impact_on_a_fixture_graph(fixture_graph, monkeypatch, capsys):
|
|
|
524
621
|
helper = rows["helper"]
|
|
525
622
|
assert helper["in_index"] is True
|
|
526
623
|
assert "svc.py::Service.run" in helper["callers"]["shown"]
|
|
527
|
-
#
|
|
528
|
-
# found by name: the stand-in for "tests to run".
|
|
624
|
+
# The test file imports and calls helper, so it is one of helper's callers.
|
|
529
625
|
assert helper["tests_to_run"]["shown"] == ["tests/test_svc.py"]
|
|
530
626
|
assert helper["tasks"]["shown"][0]["slug"] == "tk-fix-helper"
|
|
531
627
|
assert helper["memories"]["shown"][0]["slug"] == "les-helper-is-hot"
|
|
@@ -558,7 +654,7 @@ def test_diff_impact_without_witan_says_what_it_skipped(
|
|
|
558
654
|
|
|
559
655
|
assert "svc.py::helper (function, modified)" in out
|
|
560
656
|
assert "callers (2): svc.py::Service.run, svc.py::main" in out
|
|
561
|
-
assert "tests to run (
|
|
657
|
+
assert "tests to run (1): tests/test_svc.py" in out
|
|
562
658
|
assert "tasks (" not in out
|
|
563
659
|
assert "witan (council) is not installed" in out
|
|
564
660
|
|
|
@@ -14,6 +14,7 @@ from types import SimpleNamespace
|
|
|
14
14
|
import pytest
|
|
15
15
|
|
|
16
16
|
from witan_code import indexer
|
|
17
|
+
from witan_core.graph_ids import BRIDGE_GRAPH_ID, code_graph_id
|
|
17
18
|
|
|
18
19
|
from .conftest import requires_stack
|
|
19
20
|
|
|
@@ -563,6 +564,161 @@ def test_an_ignored_file_named_directly_drops_rows_it_already_has(
|
|
|
563
564
|
assert _files(store, cfg) == {"a.py"}
|
|
564
565
|
|
|
565
566
|
|
|
567
|
+
@requires_stack
|
|
568
|
+
def test_a_file_named_directly_is_held_to_the_walks_path_rules(tmp_path, monkeypatch):
|
|
569
|
+
"""An edit under `build/` or a nested checkout writes nothing, so the next
|
|
570
|
+
full index has nothing of it to purge. The `.git` here is one git cannot
|
|
571
|
+
open: a file in a real nested repository has that repository as its root,
|
|
572
|
+
so indexes into its own graph."""
|
|
573
|
+
from witan_code import config as cfg_mod
|
|
574
|
+
from witan_code import store as store_mod
|
|
575
|
+
|
|
576
|
+
src = _repo(tmp_path, monkeypatch)
|
|
577
|
+
(src / "build").mkdir()
|
|
578
|
+
(src / "build" / "gen.py").write_text("def gen():\n return 1\n")
|
|
579
|
+
(src / "vendored").mkdir()
|
|
580
|
+
(src / "vendored" / ".git").mkdir()
|
|
581
|
+
(src / "vendored" / "dep.py").write_text("def dep():\n return 1\n")
|
|
582
|
+
(src / ".gitignore").write_text("scratch/\n")
|
|
583
|
+
(src / "scratch").mkdir()
|
|
584
|
+
(src / "scratch" / "s.py").write_text("def s():\n return 1\n")
|
|
585
|
+
cfg = cfg_mod.load()
|
|
586
|
+
|
|
587
|
+
stats = indexer.index_paths(
|
|
588
|
+
[
|
|
589
|
+
src / "build" / "gen.py",
|
|
590
|
+
src / "vendored" / "dep.py",
|
|
591
|
+
src / "scratch" / "s.py",
|
|
592
|
+
src / "a.py",
|
|
593
|
+
],
|
|
594
|
+
config=cfg,
|
|
595
|
+
)
|
|
596
|
+
|
|
597
|
+
store = store_mod.store_for_repo("https://github.com/test/cg", cfg)
|
|
598
|
+
assert (stats.indexed, stats.purged) == (1, 0)
|
|
599
|
+
assert _files(store, cfg) == {"a.py"}
|
|
600
|
+
assert indexer.index_path(src, config=cfg).purged == 0
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
@requires_stack
|
|
604
|
+
def test_a_symlink_into_an_excluded_path_is_named_as_the_walk_names_it(
|
|
605
|
+
tmp_path, monkeypatch
|
|
606
|
+
):
|
|
607
|
+
"""The walk collects `alias.py` though it points into `build/`, and stores
|
|
608
|
+
it under the resolved id. Checking the resolved path instead would drop on
|
|
609
|
+
every edit the rows each full index writes back."""
|
|
610
|
+
from witan_code import config as cfg_mod
|
|
611
|
+
from witan_code import store as store_mod
|
|
612
|
+
|
|
613
|
+
src = _repo(tmp_path, monkeypatch)
|
|
614
|
+
(src / "build").mkdir()
|
|
615
|
+
(src / "build" / "real.py").write_text("def real():\n return 1\n")
|
|
616
|
+
(src / "alias.py").symlink_to(src / "build" / "real.py")
|
|
617
|
+
cfg = cfg_mod.load()
|
|
618
|
+
indexer.index_path(src, config=cfg)
|
|
619
|
+
store = store_mod.store_for_repo("https://github.com/test/cg", cfg)
|
|
620
|
+
assert _files(store, cfg) == {"a.py", "build/real.py"}
|
|
621
|
+
|
|
622
|
+
stats = indexer.index_paths([src / "alias.py"], config=cfg, force=True)
|
|
623
|
+
|
|
624
|
+
assert (stats.indexed, stats.purged) == (1, 0)
|
|
625
|
+
assert _files(store, cfg) == {"a.py", "build/real.py"}
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
@requires_stack
|
|
629
|
+
def test_a_file_named_through_a_link_from_outside_the_repo_is_indexed(
|
|
630
|
+
tmp_path, monkeypatch
|
|
631
|
+
):
|
|
632
|
+
"""The link's own name is not in the repo, so the rules see the file."""
|
|
633
|
+
from witan_code import config as cfg_mod
|
|
634
|
+
from witan_code import store as store_mod
|
|
635
|
+
|
|
636
|
+
src = _repo(tmp_path, monkeypatch)
|
|
637
|
+
(tmp_path / "link.py").symlink_to(src / "a.py")
|
|
638
|
+
cfg = cfg_mod.load()
|
|
639
|
+
|
|
640
|
+
stats = indexer.index_paths([tmp_path / "link.py"], config=cfg)
|
|
641
|
+
|
|
642
|
+
store = store_mod.store_for_repo("https://github.com/test/cg", cfg)
|
|
643
|
+
assert stats.indexed == 1
|
|
644
|
+
assert _files(store, cfg) == {"a.py"}
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
@requires_stack
|
|
648
|
+
def test_an_excluded_link_keeps_the_rows_of_a_file_the_walk_collects(
|
|
649
|
+
tmp_path, monkeypatch
|
|
650
|
+
):
|
|
651
|
+
"""`build/alias.py` is skipped, but the walk collects `a.py` under its own
|
|
652
|
+
name, so the edit must not drop the rows the next full index writes back."""
|
|
653
|
+
from witan_code import config as cfg_mod
|
|
654
|
+
from witan_code import store as store_mod
|
|
655
|
+
|
|
656
|
+
src = _repo(tmp_path, monkeypatch)
|
|
657
|
+
(src / "build").mkdir()
|
|
658
|
+
(src / "build" / "alias.py").symlink_to(Path("..") / "a.py")
|
|
659
|
+
cfg = cfg_mod.load()
|
|
660
|
+
indexer.index_path(src, config=cfg)
|
|
661
|
+
store = store_mod.store_for_repo("https://github.com/test/cg", cfg)
|
|
662
|
+
assert _files(store, cfg) == {"a.py"}
|
|
663
|
+
|
|
664
|
+
stats = indexer.index_paths([src / "build" / "alias.py"], config=cfg, force=True)
|
|
665
|
+
|
|
666
|
+
assert (stats.indexed, stats.purged) == (0, 0)
|
|
667
|
+
assert _files(store, cfg) == {"a.py"}
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
@pytest.mark.parametrize("through_alias", [False, True])
|
|
671
|
+
@requires_stack
|
|
672
|
+
def test_a_file_named_below_a_symlinked_directory_is_skipped(
|
|
673
|
+
tmp_path, monkeypatch, through_alias
|
|
674
|
+
):
|
|
675
|
+
"""The walk never descends `link/`, so `link/mod.py` is not a name it
|
|
676
|
+
collects, also when the checkout itself is reached through a link from
|
|
677
|
+
outside. The rows `src/mod.py` has under its own name stay."""
|
|
678
|
+
from witan_code import config as cfg_mod
|
|
679
|
+
from witan_code import store as store_mod
|
|
680
|
+
|
|
681
|
+
src = _repo(tmp_path, monkeypatch)
|
|
682
|
+
(src / "src").mkdir()
|
|
683
|
+
(src / "src" / "mod.py").write_text("def mod():\n return 1\n")
|
|
684
|
+
(src / "link").symlink_to("src")
|
|
685
|
+
(tmp_path / "checkout").symlink_to(src)
|
|
686
|
+
cfg = cfg_mod.load()
|
|
687
|
+
indexer.index_path(src, config=cfg)
|
|
688
|
+
store = store_mod.store_for_repo("https://github.com/test/cg", cfg)
|
|
689
|
+
assert _files(store, cfg) == {"a.py", "src/mod.py"}
|
|
690
|
+
|
|
691
|
+
named = (tmp_path / "checkout" if through_alias else src) / "link" / "mod.py"
|
|
692
|
+
stats = indexer.index_paths([named], config=cfg, force=True)
|
|
693
|
+
|
|
694
|
+
assert (stats.indexed, stats.purged) == (0, 0)
|
|
695
|
+
assert _files(store, cfg) == {"a.py", "src/mod.py"}
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
@requires_stack
|
|
699
|
+
def test_an_excluded_file_named_directly_drops_rows_it_already_has(
|
|
700
|
+
tmp_path, monkeypatch
|
|
701
|
+
):
|
|
702
|
+
"""Rows written before a path rule applied go on the file's next edit, as
|
|
703
|
+
the next full index would drop them."""
|
|
704
|
+
from witan_code import config as cfg_mod
|
|
705
|
+
from witan_code import store as store_mod
|
|
706
|
+
|
|
707
|
+
src = _repo(tmp_path, monkeypatch)
|
|
708
|
+
(src / "lib").mkdir()
|
|
709
|
+
(src / "lib" / "dep.py").write_text("def dep():\n return 1\n")
|
|
710
|
+
cfg = cfg_mod.load()
|
|
711
|
+
indexer.index_path(src, config=cfg)
|
|
712
|
+
store = store_mod.store_for_repo("https://github.com/test/cg", cfg)
|
|
713
|
+
assert _files(store, cfg) == {"a.py", "lib/dep.py"}
|
|
714
|
+
|
|
715
|
+
(src / "lib" / ".git").mkdir()
|
|
716
|
+
stats = indexer.index_paths([src / "lib" / "dep.py"], config=cfg)
|
|
717
|
+
|
|
718
|
+
assert (stats.indexed, stats.purged) == (0, 1)
|
|
719
|
+
assert _files(store, cfg) == {"a.py"}
|
|
720
|
+
|
|
721
|
+
|
|
566
722
|
# ── _may_purge: the gate on the one destructive step ─────────────────────────
|
|
567
723
|
|
|
568
724
|
|
|
@@ -703,7 +859,7 @@ def _cluster_cfg(monkeypatch, repo: str, **env: str):
|
|
|
703
859
|
monkeypatch.setenv("WITAN_CODE_SERVER", "https://omnigraph.test")
|
|
704
860
|
for key, value in env.items():
|
|
705
861
|
monkeypatch.setenv(key, value)
|
|
706
|
-
declared = frozenset({
|
|
862
|
+
declared = frozenset({code_graph_id(repo), BRIDGE_GRAPH_ID})
|
|
707
863
|
|
|
708
864
|
def _list_branches(self):
|
|
709
865
|
if self.graph_id not in declared:
|
|
@@ -725,7 +881,6 @@ def test_index_path_addresses_the_provisioned_cluster_graph(tmp_path, monkeypatc
|
|
|
725
881
|
addressing a graph the cluster never declared is the failure this whole
|
|
726
882
|
resolution path exists to prevent.
|
|
727
883
|
"""
|
|
728
|
-
from witan_code import config as cfg_module
|
|
729
884
|
from witan_code import store as store_mod
|
|
730
885
|
from witan_core import omnigraph as og
|
|
731
886
|
|
|
@@ -747,7 +902,7 @@ def test_index_path_addresses_the_provisioned_cluster_graph(tmp_path, monkeypatc
|
|
|
747
902
|
"--server",
|
|
748
903
|
"https://omnigraph.test",
|
|
749
904
|
"--graph",
|
|
750
|
-
|
|
905
|
+
code_graph_id("https://github.com/test/cg"),
|
|
751
906
|
]
|
|
752
907
|
assert client.token == "s3cret"
|
|
753
908
|
# CI owns the default view, so the guard that refused above lets this pass.
|