witan-code 0.27.1__tar.gz → 0.29.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.
Files changed (113) hide show
  1. {witan_code-0.27.1 → witan_code-0.29.0}/CHANGELOG.md +111 -0
  2. {witan_code-0.27.1 → witan_code-0.29.0}/PKG-INFO +20 -8
  3. {witan_code-0.27.1 → witan_code-0.29.0}/README.md +18 -6
  4. {witan_code-0.27.1 → witan_code-0.29.0}/changelog.d/README.md +1 -1
  5. {witan_code-0.27.1 → witan_code-0.29.0}/docs/BRANCH_INDEXING.md +4 -2
  6. {witan_code-0.27.1 → witan_code-0.29.0}/pyproject.toml +33 -3
  7. witan_code-0.29.0/tests/test_branches_served.py +114 -0
  8. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_chunked_load.py +82 -0
  9. witan_code-0.29.0/tests/test_cli_help_docstrings.py +9 -0
  10. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_elicit.py +40 -0
  11. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_hooks.py +266 -22
  12. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_indexer_scope.py +304 -1
  13. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_ingest.py +8 -6
  14. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_reaper.py +22 -3
  15. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_remote_store.py +21 -114
  16. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_repo.py +66 -0
  17. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_store.py +15 -8
  18. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/bridge_extractors.py +8 -2
  19. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/cli.py +18 -9
  20. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/extensions/pi/codegraph.ts +21 -6
  21. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/graph.py +19 -26
  22. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/hooks.py +106 -18
  23. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/indexer.py +164 -20
  24. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/ingest.py +1 -1
  25. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/reaper.py +4 -4
  26. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/remote/store.py +10 -48
  27. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/repo.py +122 -0
  28. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/server.py +23 -3
  29. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/store.py +25 -3
  30. witan_code-0.27.1/changelog.d/20261023_162839_blarghmatey_witan_code_codex_hooks.md +0 -3
  31. witan_code-0.27.1/changelog.d/20261023_163336_blarghmatey_witan_code_codex_hooks.md +0 -3
  32. {witan_code-0.27.1 → witan_code-0.29.0}/.gitignore +0 -0
  33. {witan_code-0.27.1 → witan_code-0.29.0}/config/claude.json +0 -0
  34. {witan_code-0.27.1 → witan_code-0.29.0}/config/copilot.json +0 -0
  35. {witan_code-0.27.1 → witan_code-0.29.0}/config/pi.json +0 -0
  36. {witan_code-0.27.1 → witan_code-0.29.0}/conftest.py +0 -0
  37. {witan_code-0.27.1 → witan_code-0.29.0}/docs/CLI_REFERENCE.md +0 -0
  38. {witan_code-0.27.1 → witan_code-0.29.0}/docs/EDGE_PRECISION_TIERS.md +0 -0
  39. {witan_code-0.27.1 → witan_code-0.29.0}/docs/PACKAGE_MAP.md +0 -0
  40. {witan_code-0.27.1 → witan_code-0.29.0}/docs/STAGE2_STITCHING.md +0 -0
  41. {witan_code-0.27.1 → witan_code-0.29.0}/docs/SYMBOL_FORMAT.md +0 -0
  42. {witan_code-0.27.1 → witan_code-0.29.0}/docs/SYMBOL_TABLE.md +0 -0
  43. {witan_code-0.27.1 → witan_code-0.29.0}/docs/USER_GUIDE.md +0 -0
  44. {witan_code-0.27.1 → witan_code-0.29.0}/install.sh +0 -0
  45. {witan_code-0.27.1 → witan_code-0.29.0}/tests/__init__.py +0 -0
  46. {witan_code-0.27.1 → witan_code-0.29.0}/tests/conftest.py +0 -0
  47. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_batched_deletes.py +0 -0
  48. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_branches.py +0 -0
  49. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_bridge.py +0 -0
  50. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_cli_dispatch.py +0 -0
  51. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_cli_hooks.py +0 -0
  52. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_cli_output_format.py +0 -0
  53. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_cli_selected_target.py +0 -0
  54. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_config.py +0 -0
  55. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_config_targets.py +0 -0
  56. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_context.py +0 -0
  57. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_crossrepo.py +0 -0
  58. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_edges.py +0 -0
  59. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_enrichment.py +0 -0
  60. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_github_app.py +0 -0
  61. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_graph.py +0 -0
  62. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_identity.py +0 -0
  63. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_index_failure_diagnostics.py +0 -0
  64. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_index_reports_its_store.py +0 -0
  65. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_index_requires_a_repo_key.py +0 -0
  66. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_indexer.py +0 -0
  67. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_languages.py +0 -0
  68. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_maintenance.py +0 -0
  69. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_package_map.py +0 -0
  70. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_rebuild_honours_the_repo_key.py +0 -0
  71. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_refusal_audit.py +0 -0
  72. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_remote_proxy.py +0 -0
  73. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_server.py +0 -0
  74. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_setup.py +0 -0
  75. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_stitch.py +0 -0
  76. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_symbol_table.py +0 -0
  77. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_tasks.py +0 -0
  78. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_tool_schema.py +0 -0
  79. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_views.py +0 -0
  80. {witan_code-0.27.1 → witan_code-0.29.0}/tests/test_visualize.py +0 -0
  81. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/__init__.py +0 -0
  82. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/__main__.py +0 -0
  83. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/bridge.py +0 -0
  84. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/config.py +0 -0
  85. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/context.py +0 -0
  86. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/edges.py +0 -0
  87. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/elicit.py +0 -0
  88. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/github_app.py +0 -0
  89. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/identity.py +0 -0
  90. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/maintenance.py +0 -0
  91. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/output.py +0 -0
  92. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/package_map.py +0 -0
  93. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/queries/bridge.gq +0 -0
  94. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/queries/code_mutations.gq +0 -0
  95. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/queries/code_read.gq +0 -0
  96. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/queries/delete.gq +0 -0
  97. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/queries_ts/bash.scm +0 -0
  98. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/queries_ts/hcl.scm +0 -0
  99. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/queries_ts/python.scm +0 -0
  100. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/queries_ts/sql.scm +0 -0
  101. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/queries_ts/typescript.scm +0 -0
  102. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/queries_ts/yaml.scm +0 -0
  103. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/remote/__init__.py +0 -0
  104. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/remote/oidc.py +0 -0
  105. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/remote/proxy.py +0 -0
  106. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/schema/bridge-schema.pg +0 -0
  107. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/schema/code-schema.pg +0 -0
  108. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/selected_target.py +0 -0
  109. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/setup.py +0 -0
  110. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/skills/witan-code/SKILL.md +0 -0
  111. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/stitch.py +0 -0
  112. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/views.py +0 -0
  113. {witan_code-0.27.1 → witan_code-0.29.0}/witan_code/visualize.py +0 -0
@@ -8,6 +8,96 @@ a MINOR bump may include breaking changes).
8
8
 
9
9
  <!-- scriv-insert-here -->
10
10
 
11
+ ## [0.29.0] - 2026-11-10
12
+
13
+ ### Changed
14
+
15
+ - With witan-core's packed `chunk_records`, an index whose records fit one
16
+ load batch sends its nodes and edges as one `code_store_load` instead of
17
+ two, so a paced PostToolUse flush to a deployed graph is three commits on
18
+ the branch view (delete, load, content-hash load) instead of four.
19
+ - Through an `OmnigraphClient` (a local store, omnigraph over HTTP, or an
20
+ in-cluster index), a load that fits one batch carries the files' content
21
+ hashes in the same commit instead of a second load, so the flush is two
22
+ commits. One batch commits atomically, so a failed load still leaves the
23
+ files without a hash and the next run re-indexes them. A
24
+ `RemoteStoreClient` keeps the content-hash load, because the store tier
25
+ re-chunks what it receives, and one running an older witan-core splits
26
+ nodes from edges into separate commits.
27
+ - Requires `witan-core>=0.51.1`, the release with the packed
28
+ `chunk_records`. 0.51.0 still works, but adds a commit per flush.
29
+
30
+ ### Fixed
31
+
32
+ - `--help` for `reap-views`, `setup` and the global options shows each
33
+ parameter's description. They were documented as `name: text` on one
34
+ line, which cyclopts' numpydoc parser reads as a parameter type.
35
+ - Indexing inside a git work tree collects git's listing (`git ls-files
36
+ --cached --others --exclude-standard`) instead of walking the disk, so
37
+ files git ignores no longer reach the code graph. The fixed skip list
38
+ only caught a virtualenv named `.venv` or `venv`: a dry estimate of
39
+ open-edx-plugins with `uv sync` into `env/` came to 703,408 records in
40
+ 108 2 MiB loads, against 14,661 records in 5 loads now. The skip list,
41
+ nested-checkout exclusion and extension filter still apply on top. The
42
+ PostToolUse hook holds the files it names to the same rule with one
43
+ `git check-ignore` per batch, and the repo-level bridge extractors read
44
+ the same listing. Outside a work tree, or without a `git` binary, the
45
+ disk is walked as before. A full-repo index purges rows already stored
46
+ for files that are now ignored, wherever the run is allowed to purge, and
47
+ an edit to an ignored file drops that file's existing rows. A repository
48
+ git cannot list (a corrupt index, dubious ownership) is reported and
49
+ indexes nothing rather than falling back to the walk, and a listed path
50
+ under a symlinked directory is skipped.
51
+
52
+ ### Security
53
+
54
+ - 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.
55
+
56
+ ## [0.28.0] - 2026-11-09
57
+
58
+ ### Changed
59
+
60
+ - Requires `witan-core>=0.51`, which pins omnigraph 0.14 (storage format 16)
61
+ and speaks HTTP contract 0.14 or 0.13, whichever the server stamps. A 0.14
62
+ data tier refuses an older client's requests. The floor also covers
63
+ `store_cli_args(..., binary=)`, `OmnigraphClient.commit_list`, the branched
64
+ HTTP transport and `OmnigraphClient(actor=)`.
65
+ - The `schema plan` check on a local code store addresses the store with
66
+ `store_cli_args`, so it takes `--target` on omnigraph 0.14 (which removed
67
+ the positional store URI) and `--store` before it. Code and bridge store
68
+ `init` passes the generated operator config on 0.14 (`init_cli_args`).
69
+ - A branch view on a deployed server reads, writes and lists its commits
70
+ over HTTP, with the branch as a request field, instead of through the
71
+ omnigraph CLI, which 0.14 refuses for a plain-http server.
72
+ `branch_last_write` (the reaper's idleness check) uses
73
+ `OmnigraphClient.commit_list`.
74
+ - A deployment's ingest client asserts the caller's actor to the data tier
75
+ (`Omnigraph-If-Actor`), so on omnigraph 0.14 a token mapped to the wrong
76
+ actor is refused instead of writing under someone else's name. `StoreRef`
77
+ carries the `actor`.
78
+ - The PostToolUse drainer indexes its whole queue as one batch
79
+ (`indexer.index_paths`) and waits `FLUSH_INTERVAL_SECONDS` (30s) since the
80
+ checkout's last flush before starting the next. An edit-heavy session now
81
+ runs at most one index per 30s per checkout (three commits on the branch
82
+ view when the batch is at most 64 changed files and fits one load chunk),
83
+ instead of one index run per edit back to back. The first edit after a
84
+ quiet spell still flushes at once, and edits made during the wait join the
85
+ next flush, so the last edit of a session is still indexed.
86
+ - The Pi extension queues edits through `witan-code reindex-hook` and seeds
87
+ through `witan-code session-init`, the commands the Claude and Codex hooks
88
+ run, instead of a detached `witan-code index` per edit that bypassed the
89
+ drainer.
90
+
91
+ ### Removed
92
+
93
+ - `RemoteStoreClient.change_many` no longer falls back to one
94
+ `code_store_mutate` per statement when the deployment's tool list lacks, or
95
+ fails to return, `code_store_mutate_many`. A failed listing was cached for
96
+ the connection's lifetime, which turned a reindex's deletes into one commit
97
+ per statement. A store tier without `code_store_mutate_many` (served since
98
+ witan-code 0.12.0) now fails the call instead. `StoreSession.has_tool` is
99
+ gone with it.
100
+
11
101
  ## [0.27.1] - 2026-10-26
12
102
 
13
103
  ### Changed
@@ -16,6 +106,27 @@ a MINOR bump may include breaking changes).
16
106
  `witan-cli` Keycloak client will require PKCE, and `witan-code login` on an older
17
107
  witan-core will then fail.
18
108
 
109
+ ### Fixed
110
+
111
+ - `reindex-hook` purges files a Codex `apply_patch` deletes or renames away. It
112
+ read only the headers naming a file left on disk, so a `*** Delete File:`
113
+ path and the `*** Update File:` source of a `*** Move to:` kept their symbols
114
+ in the graph until the next SessionStart full refresh, and
115
+ `code_find_definition` went on returning the old path. The hook now queues
116
+ those paths too, and indexing a file that is no longer on disk
117
+ (`index_path`, which the hook's drainer calls) drops its rows and its
118
+ cross-repo bindings. The drainer used to skip a queued file deleted before it
119
+ ran; it now purges it the same way. (Shipped in 0.27.1, left out at release.)
120
+ - `inject-context` gives Codex guidance for tools Codex has. `witan-code setup`
121
+ registers one bare `UserPromptSubmit` hook for Claude Code and Codex, so
122
+ Codex got Claude's block, which says to load the `code_*` tools with
123
+ `ToolSearch` and to run `/witan-code`; Codex has neither. Without
124
+ `--client`, the command now reads the hook's stdin payload, and a Codex
125
+ payload (it carries `turn_id`) gets Codex's `tool_search` call and a pointer
126
+ to the `witan-code` skill. Any other payload, or none, gets the Claude block
127
+ as before. `--client codex` selects the Codex block explicitly. (Shipped in
128
+ 0.27.1, left out at release.)
129
+
19
130
  ## [0.27.0] - 2026-10-21
20
131
 
21
132
  ### Changed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: witan-code
3
- Version: 0.27.1
3
+ Version: 0.29.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.46
29
+ Requires-Dist: witan-core[cli,observability,remote,sentry]<1,>=0.51.1
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,9 @@ 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're portable
704
- to any platform witan-code installs on (Windows included — no bash/setsid
705
- dependency). Named `witan-code <command>` below (standalone install via
703
+ Four hooks — all bare CLI commands, no wrapper scripts, so they need no
704
+ bash or setsid. They do not run on Windows yet: the hook commands' queue
705
+ lock and state directory still use POSIX-only calls. Named `witan-code <command>` below (standalone install via
706
706
  `witan-code setup`); when `witan setup` folds this bundle in instead (see
707
707
  [Install](#install)), they register as `witan code <command>` so only
708
708
  `witan` needs to be on `PATH`. Register manually per
@@ -757,14 +757,26 @@ scripts to symlink.
757
757
 
758
758
  ## What gets indexed
759
759
 
760
- The walk skips the usual noise directories (`.git`, `node_modules`, `.venv`,
761
- `__pycache__`, `dist`, `build`, the various caches) and — importantly — does
760
+ Inside a git work tree the file set is git's own listing (`git ls-files
761
+ --cached --others --exclude-standard`): tracked files plus untracked files
762
+ that are not ignored. Anything `.gitignore`, `.git/info/exclude` or your
763
+ `core.excludesFile` ignores stays out of the graph, including a virtualenv
764
+ under any name (uv and `python -m venv` write a `*` `.gitignore` into the
765
+ environment they create). The edit hooks apply the same rule: an edit to an
766
+ ignored file is not indexed. Outside a git work tree, or without a `git`
767
+ binary, the indexer walks the directory instead, and only the rules below
768
+ apply.
769
+
770
+ On top of either, the indexer skips the usual noise directories (`.git`,
771
+ `node_modules`, `.venv`, `__pycache__`, `dist`, `build`, the various caches),
772
+ even where git tracks them, and — importantly — does
762
773
  not descend into a **nested checkout**: any subdirectory containing a `.git`
763
774
  entry belongs to a different repository. That covers linked worktrees
764
775
  (`.claude/worktrees/<name>/`, where `.git` is a *file*, not a directory),
765
776
  submodules, and plain clones dropped inside the tree. Their files are that
766
777
  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.
778
+ store serving stale copies of itself under a second set of paths. A
779
+ submodule's files belong in its own repo's graph, not this one's.
768
780
 
769
781
  Indexing *from inside* a worktree still works normally — only descending into
770
782
  one from the parent is refused — so the hooks keep indexing while an agent
@@ -667,9 +667,9 @@ 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're portable
671
- to any platform witan-code installs on (Windows included — no bash/setsid
672
- dependency). Named `witan-code <command>` below (standalone install via
670
+ Four hooks — all bare CLI commands, no wrapper scripts, so they need no
671
+ bash or setsid. They do not run on Windows yet: the hook commands' queue
672
+ lock and state directory still use POSIX-only calls. Named `witan-code <command>` below (standalone install via
673
673
  `witan-code setup`); when `witan setup` folds this bundle in instead (see
674
674
  [Install](#install)), they register as `witan code <command>` so only
675
675
  `witan` needs to be on `PATH`. Register manually per
@@ -724,14 +724,26 @@ scripts to symlink.
724
724
 
725
725
  ## What gets indexed
726
726
 
727
- The walk skips the usual noise directories (`.git`, `node_modules`, `.venv`,
728
- `__pycache__`, `dist`, `build`, the various caches) and — importantly — does
727
+ Inside a git work tree the file set is git's own listing (`git ls-files
728
+ --cached --others --exclude-standard`): tracked files plus untracked files
729
+ that are not ignored. Anything `.gitignore`, `.git/info/exclude` or your
730
+ `core.excludesFile` ignores stays out of the graph, including a virtualenv
731
+ under any name (uv and `python -m venv` write a `*` `.gitignore` into the
732
+ environment they create). The edit hooks apply the same rule: an edit to an
733
+ ignored file is not indexed. Outside a git work tree, or without a `git`
734
+ binary, the indexer walks the directory instead, and only the rules below
735
+ apply.
736
+
737
+ On top of either, the indexer skips the usual noise directories (`.git`,
738
+ `node_modules`, `.venv`, `__pycache__`, `dist`, `build`, the various caches),
739
+ even where git tracks them, and — importantly — does
729
740
  not descend into a **nested checkout**: any subdirectory containing a `.git`
730
741
  entry belongs to a different repository. That covers linked worktrees
731
742
  (`.claude/worktrees/<name>/`, where `.git` is a *file*, not a directory),
732
743
  submodules, and plain clones dropped inside the tree. Their files are that
733
744
  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.
745
+ store serving stale copies of itself under a second set of paths. A
746
+ submodule's files belong in its own repo's graph, not this one's.
735
747
 
736
748
  Indexing *from inside* a worktree still works normally — only descending into
737
749
  one from the parent is refused — so the hooks keep indexing while an agent
@@ -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.0 create` from
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 `omnigraph commit list --branch`, filtered to commits whose
214
- `manifest_branch` is the view itself — `branch list` returns bare names, with no
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.27.1"
3
+ version = "0.29.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"
@@ -188,7 +188,37 @@ dependencies = [
188
188
  # sends PKCE (`S256`) only from 0.46.0, and the `witan-cli` Keycloak client
189
189
  # is switched to require it once that is out. 0.45 imports and runs, then
190
190
  # every `witan-code login` is refused by Keycloak.
191
- "witan-core[cli,remote,observability,sentry]>=0.46,<1",
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
+ #
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
+ "witan-core[cli,remote,observability,sentry]>=0.51.1,<1",
192
222
  "fastmcp>=4,<5",
193
223
  "cyclopts>=4,<6",
194
224
  # [targets.<name>] override models (config.py) — also transitively pulled
@@ -271,7 +301,7 @@ testpaths = ["tests"]
271
301
  packages = ["witan_code"]
272
302
 
273
303
  [tool.bumpversion]
274
- current_version = "0.27.1"
304
+ current_version = "0.29.0"
275
305
  allow_dirty = true
276
306
 
277
307
  [[tool.bumpversion.files]]
@@ -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"}
@@ -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
@@ -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") == []
@@ -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"