Skip to content

fix(doctor): probe ast-grep so bootstrap stops reporting ok on a machine where edit.ast-grep-plan cannot run - #143

Merged
2233admin merged 1 commit into
mainfrom
dogfood/F4-doctor-blind-to-ast-grep
Aug 3, 2026
Merged

fix(doctor): probe ast-grep so bootstrap stops reporting ok on a machine where edit.ast-grep-plan cannot run#143
2233admin merged 1 commit into
mainfrom
dogfood/F4-doctor-blind-to-ast-grep

Conversation

@2233admin

Copy link
Copy Markdown
Owner

The finding

code-intel doctor bootstrap --repo-path . --no-require-repowise --require-provider-conformance --json returned "ok": true, "missing": [], and a tools array of exactly six entries: rg, git, python, repowise, repomix, sentrux. The probe list is hardcoded in crates/code-intel-cli/src/doctor_bootstrap/mod.rs and contained no ast-grep.

That is a blind spot with three independent confirmations in this tree:

  • orchestration/integrations.json ships edit.ast-grep-plan as a capability with runtimeAdapter: edit.ast-grep-plan.compat.
  • crates/code-intel-cli/src/structured_edit.rs resolves tool_path::resolve("ast-grep") and shells out to ast-grep --version; a machine without it fails at capability-exec time with AdapterError::Unavailable("start ast-grep: ...").
  • .github/workflows/ci.yml installs a sha256-pinned ast-grep 0.42.3 in both jobs and throws on a version mismatch, and orchestration/toolchain-versions.v1.json carries an ast-grep entry with a command probe.

So CI treated ast-grep as a hard dependency while the doctor treated it as nonexistent.

The fix

One probe added to the tools vector, required: false.

Optional is the honest setting, not a softening: orchestration/toolchain-versions.v1.json already declares ast-grep with "required": false, and integrations.json declares edit.ast-grep-plan with "required": false. Making it required would have flipped the doctor red on every installed machine without ast-grep — a gate change, not a bug fix. What changes is that the observation now reports the tool: found plus a resolved source path, and a MISSING ast-grep line in the human rendering when it is absent, instead of silently omitting it.

No existing green turns red, and no gate was weakened, waived, or relabelled.

Tests

Two, both of which fail if the one-line probe is reverted:

  1. doctor_bootstrap::tests::observation_carries_the_v1_contract_and_every_retired_check — the existing tool-name-order assertion gains "ast-grep".
  2. the_probe_list_covers_the_external_tool_a_shipped_capability_shells_out_to (new, tests/doctor_bootstrap_cli.rs) — reads the shipped orchestration/integrations.json, confirms edit.ast-grep-plan is still a runtime capability, and only then requires the probe list to cover it. The manifest read is the point: retiring the capability relaxes the test instead of leaving a restated constant behind.

Revert proof. With probe::probe_tool("ast-grep", false, prefix) removed and nothing else changed:

test the_probe_list_covers_the_external_tool_a_shipped_capability_shells_out_to ... FAILED
  doctor bootstrap never probes ast-grep: [rg, git, python, repowise, repomix, sentrux]

test doctor_bootstrap::tests::observation_carries_the_v1_contract_and_every_retired_check ... FAILED
  left:  ["rg", "git", "python", "repowise", "repomix", "sentrux"]
  right: ["rg", "git", "python", "repowise", "repomix", "sentrux", "ast-grep"]

Restored, both pass.

Digest re-pin

capabilityDeclaration.implementation.toolchainDigests for the doctor capability pins doctor_bootstrap/mod.rs. Re-pinned by hand (b4b6fc64… -> ef26c267…) and verified with sha256, per the known repin --write blind spot (#133). registry_toolchain_digests_bind_the_adapter_and_dispatch_sources caught the stale pin and now passes.

Verification

  • cargo test --workspace --locked — 2959 passed, 51 suites, fully green.
  • cargo fmt -p code-intel -- --check — clean.
  • Authoritative self-scan (run execute --repo . --manifest orchestration/integrations.json --doctor-require-repowise false) — exit 0, "failures": {"domain": [], "process": []}, all 8 nodes verdict: pass.
  • God-file ratchet checked by hand before editing: mod.rs sits at 25 recognised functions, and the rule is functions > 25 && loc > 400. Adding any new fn to that file — including a test fn — would have made it a god file and tripped the ratchet. That is why the new test lives in tests/doctor_bootstrap_cli.rs and the in-file change is a comment plus one expression. Post-change: mod.rs loc 779 / 25 fns, doctor_bootstrap_cli.rs loc 312 / 11 fns — neither trips it.

Post-fix output

{"found": true, "name": "ast-grep", "required": false,
 "source": "...\\Scripts\\ast-grep.exe"}

Seven entries now, and the doctor answers for a tool a shipped capability cannot run without.

Refs the dogfooding finding F4-doctor-blind-to-ast-grep. Do not merge without review.

…t-grep-plan

`doctor bootstrap --json` reported a `tools` array of exactly six entries —
rg, git, python, repowise, repomix, sentrux — because the probe list is
hardcoded in doctor_bootstrap/mod.rs. ast-grep was not in it.

Meanwhile `orchestration/integrations.json` ships `edit.ast-grep-plan` as a
capability with `runtimeAdapter: edit.ast-grep-plan.compat`, and that adapter
resolves `ast-grep` through `tool_path` before shelling out to
`ast-grep --version`. On a machine without ast-grep the doctor answered
`ok: true, missing: []` and the truth only arrived at capability-exec time as
`AdapterError::Unavailable("start ast-grep: ...")`. CI treats the tool as a
hard dependency — both jobs install a sha256-pinned 0.42.3 and throw on a
version mismatch — while the doctor treated it as nonexistent.

The probe is optional (`required: false`), matching what
`orchestration/toolchain-versions.v1.json` already declares for ast-grep and
matching repomix, so no machine that was green turns red. The fix is that the
observation now reports the tool at all: `found` plus a resolved `source`,
and a `MISSING ast-grep` line in the human rendering when it is absent.

Tests: the existing tool-name-order assertion in mod.rs gains "ast-grep", and
a new integration test reads the shipped manifest, confirms
`edit.ast-grep-plan` is still a runtime capability, and only then requires the
probe list to cover it — so retiring the capability relaxes the test instead
of leaving a restated constant behind. Both fail with the probe line removed.

`capabilityDeclaration.implementation.toolchainDigests` for the doctor
capability is re-pinned to mod.rs's new sha256 (verified by hand; #133).

Refs #F4-doctor-blind-to-ast-grep
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@repowise-bot

repowise-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🔒 Repowise is not analyzing this repository

The PR bot is free on public repositories. This one is private, which needs a Pro plan.

See plans · Manage this repository

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • The diagnostic tool now detects and reports whether the optional ast-grep tool is available.
    • Tool availability is displayed as a clear true/false status in diagnostic results.
  • Bug Fixes

    • Updated integration metadata to ensure diagnostics use the correct toolchain configuration.

Walkthrough

The doctor bootstrap now probes ast-grep as an optional tool and reports its availability. Contract and CLI regression tests verify the observation. The doctor integration declaration also uses an updated toolchain digest.

Changes

Doctor bootstrap observation

Layer / File(s) Summary
Integration toolchain contract
orchestration/integrations.json
The doctor capability declaration replaces one toolchain digest.
ast-grep probing and validation
crates/code-intel-cli/src/doctor_bootstrap/mod.rs, crates/code-intel-cli/tests/doctor_bootstrap_cli.rs
Bootstrap observations include optional ast-grep probing. Contract and CLI tests verify the tool name and boolean availability status.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

I hop through the doctor’s report,
ast-grep joins the tool support.
A boolean tells if it was found,
Tests keep the contract sound.
The rabbit stamps the digest bright. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding an optional ast-grep probe to doctor bootstrap.
Description check ✅ Passed The description directly explains the ast-grep probe, its optional status, tests, digest update, and verification results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Code Intel change risk

Score Percentile Level
56/100 35th (vs last 49 commits) 🟢 low

Top signals

  • Diff shape: 3 file(s), +64/-2 (max file share 0.82)
  • Test asymmetry: source changed, tests touched
  • Bug-magnet: 19 fix commit(s) in touched files (180d)
  • Churn: 42 commit(s) touching these files (90d)

revspec: origin/main..HEAD · threshold: percentile >= 90 blocks unless labeled risk-accepted · code-intel change risk

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
crates/code-intel-cli/tests/doctor_bootstrap_cli.rs (1)

251-304: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Cover the complete manifest-to-observation contract.

The test only checks that ast-grep exists, is optional in the output, and has a boolean found value. It does not compare against the capability's required field in orchestration/integrations.json, verify the emitted source, or exercise a controlled missing-tool case. A regression that drops source or always reports found: false can pass.

Capture the manifest entry, assert its required value, compare it with probed["required"], and assert that source matches found. Also assert that an absent optional tool is not added to missing.

Suggested assertions
-    let ships_ast_grep_plan = manifest["integrations"]
+    let capability = manifest["integrations"]
         .as_array()
         .expect("integrations array")
         .iter()
-        .any(|entry| entry["id"] == "edit.ast-grep-plan" && entry["runtimeAdapter"].is_string());
-    assert!(
-        ships_ast_grep_plan,
-        "edit.ast-grep-plan is no longer a shipped runtime capability; drop this test rather than weakening it"
-    );
+        .find(|entry| entry["id"] == "edit.ast-grep-plan")
+        .expect("edit.ast-grep-plan capability");
+    assert!(capability["runtimeAdapter"].is_string());
+    assert_eq!(capability["required"], json!(false));

-    assert_eq!(probed["required"], json!(false));
-    assert!(probed["found"].is_boolean());
+    assert_eq!(probed["required"], capability["required"]);
+    let found = probed["found"].as_bool().expect("found boolean");
+    let source = probed["source"].as_str().expect("source string");
+    assert_eq!(found, !source.is_empty());
+    assert!(!observation["missing"]
+        .as_array()
+        .expect("missing array")
+        .iter()
+        .any(|value| value == "ast-grep"));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/code-intel-cli/tests/doctor_bootstrap_cli.rs` around lines 251 - 304,
Strengthen the test
the_probe_list_covers_the_external_tool_a_shipped_capability_shells_out_to by
retaining the matching edit.ast-grep-plan manifest entry, reading its required
value, and asserting it matches probed["required"]. Verify the probe emits a
source consistent with probed["found"], and in the controlled missing-tool
scenario assert that ast-grep is not included in the observation's missing list
because it is optional.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/code-intel-cli/tests/doctor_bootstrap_cli.rs`:
- Around line 251-304: Strengthen the test
the_probe_list_covers_the_external_tool_a_shipped_capability_shells_out_to by
retaining the matching edit.ast-grep-plan manifest entry, reading its required
value, and asserting it matches probed["required"]. Verify the probe emits a
source consistent with probed["found"], and in the controlled missing-tool
scenario assert that ast-grep is not included in the observation's missing list
because it is optional.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 33cc104c-e15c-4165-809c-1fe24bd83ffb

📥 Commits

Reviewing files that changed from the base of the PR and between ade9e45 and e80d3a1.

📒 Files selected for processing (3)
  • crates/code-intel-cli/src/doctor_bootstrap/mod.rs
  • crates/code-intel-cli/tests/doctor_bootstrap_cli.rs
  • orchestration/integrations.json

@2233admin
2233admin merged commit c5d3905 into main Aug 3, 2026
8 checks passed
@2233admin 2233admin mentioned this pull request Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant