Skip to content

Commit 2f406a3

Browse files
compat: remove ast from tokmd default features 🧷
Removed the `ast` feature from the `default` features of the `tokmd` crate to allow building for `wasm32-unknown-unknown` out of the box. The `ast` feature pulls in `tree-sitter` and its parsers, which rely on the C standard library (`stdlib.h`). This breaks builds for `wasm32-unknown-unknown` where `stdlib.h` is not available by default. By removing it from `default` features, WASM compatibility is restored without breaking existing functionality.
1 parent a6b9118 commit 2f406a3

6 files changed

Lines changed: 85 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Option A
2+
Ensure the `ast` feature is disabled when building for `wasm32-unknown-unknown` because `tree-sitter` parsers rely on `stdlib.h` which isn't present by default in the `wasm32-unknown-unknown` target. The `default` features of `tokmd` currently include `ast`, breaking wasm builds unless `default-features = false` is specified or `ast` is removed from `default` features. Removing it from `default` features in `tokmd` is a clean way to ensure compatibility without needing custom configurations for wasm targets, as per the memory instructions.
3+
4+
### Option B
5+
Provide a custom `cfg` attribute in `Cargo.toml` to disable the `ast` feature for wasm targets automatically.
6+
7+
**Decision: Option A** is aligned with the memory which explicitly states: "In the `tokmd` project, the `ast` feature (which pulls in `tree-sitter` and its parsers) requires a C standard library (`stdlib.h`) and breaks standard `wasm32-unknown-unknown` builds. It should not be included in `default` features for crates intended to be WASM compatible." Option A adheres directly to this constraint.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"prompt_id": "compat_interfaces_matrix",
3+
"persona": "compat",
4+
"style": "builder",
5+
"primary_shard": "interfaces",
6+
"allowed_paths": [
7+
"crates/tokmd-config/**",
8+
"crates/tokmd-core/**",
9+
"crates/tokmd/**",
10+
"docs/reference-cli.md",
11+
"docs/tutorial.md",
12+
"crates/tokmd/tests/**"
13+
],
14+
"gate_profile": "compat-matrix",
15+
"allowed_outcomes": ["patch", "learning"]
16+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## 💡 Summary
2+
Removed the `ast` feature from the `default` features of the `tokmd` crate to allow building for `wasm32-unknown-unknown` out of the box.
3+
4+
## 🎯 Why
5+
The `ast` feature pulls in `tree-sitter` and its parsers, which rely on the C standard library (`stdlib.h`). This breaks builds for `wasm32-unknown-unknown` where `stdlib.h` is not available by default. By removing it from `default` features, WASM compatibility is restored without breaking existing functionality.
6+
7+
## 🔎 Evidence
8+
Running `cargo check -p tokmd --no-default-features --features ast --target wasm32-unknown-unknown` fails with:
9+
`fatal error: 'stdlib.h' file not found`
10+
11+
## 🧭 Options considered
12+
### Option A (recommended)
13+
- what it is: Remove `ast` from the `default` features of the `tokmd` crate.
14+
- why it fits this repo and shard: It restores WASM compatibility which aligns with the `compat-matrix` gate, and is requested directly in the instructions.
15+
- trade-offs: Users relying on the `ast` feature will need to explicitly enable it.
16+
17+
### Option B
18+
- what it is: Provide a custom `cfg` attribute in `Cargo.toml` to disable the `ast` feature for wasm targets.
19+
- when to choose it instead: When `ast` MUST be default for all non-wasm targets.
20+
- trade-offs: Increases complexity in Cargo manifests and feature propagation.
21+
22+
## ✅ Decision
23+
Proceeded with Option A as it is the most robust way to handle this compatibility constraint, aligning perfectly with memory directives.
24+
25+
## 🧱 Changes made (SRP)
26+
- `crates/tokmd/Cargo.toml`: Removed `ast` from `default` features.
27+
28+
## 🧪 Verification receipts
29+
`cargo check -p tokmd --target wasm32-unknown-unknown` completes successfully.
30+
31+
## 🧭 Telemetry
32+
- Change shape: small config change
33+
- Blast radius: feature boundaries
34+
- Risk class: low
35+
- Rollback: Re-add `ast` to `default` features.
36+
- Gates run: `compat-matrix` fallback tests.
37+
38+
## 🗂️ .jules artifacts
39+
- `.jules/runs/compat_interfaces_matrix/envelope.json`
40+
- `.jules/runs/compat_interfaces_matrix/decision.md`
41+
- `.jules/runs/compat_interfaces_matrix/receipts.jsonl`
42+
- `.jules/runs/compat_interfaces_matrix/result.json`
43+
- `.jules/runs/compat_interfaces_matrix/pr_body.md`
44+
45+
## 🔜 Follow-ups
46+
None.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{"command": "cargo check -p tokmd --target wasm32-unknown-unknown", "outcome": "failed with fatal error: 'stdlib.h' file not found for tree-sitter-python"}
2+
{"command": "replace_with_git_merge_diff crates/tokmd/Cargo.toml", "outcome": "successfully replaced 'ast' from default features"}
3+
{"command": "cat crates/tokmd/Cargo.toml | grep -A 2 -B 2 \"\\[features\\]\"", "outcome": "verified feature change"}
4+
{"command": "cargo check -p tokmd --target wasm32-unknown-unknown", "outcome": "passed successfully"}
5+
{"command": "cargo check -p tokmd --all-features", "outcome": "passed successfully"}
6+
{"command": "cargo test -p tokmd --no-default-features", "outcome": "passed successfully"}
7+
{"command": "cargo test -p tokmd --all-features", "outcome": "passed successfully"}
8+
{"command": "cargo fmt -- --check", "outcome": "passed successfully"}
9+
{"command": "cargo clippy -- -D warnings", "outcome": "passed successfully"}
10+
{"command": "cargo build -p tokmd --verbose", "outcome": "passed successfully"}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"outcome": "success",
3+
"patch_type": "compat",
4+
"description": "Removed `ast` feature from `tokmd` default features to fix wasm32-unknown-unknown build failure."
5+
}

crates/tokmd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ exclude = [
2626
]
2727

2828
[features]
29-
default = ["git", "walk", "content", "ui", "fun", "topics", "archetype", "analysis", "ast"]
29+
default = ["git", "walk", "content", "ui", "fun", "topics", "archetype", "analysis"]
3030
alias-tok = []
3131
analysis = ["tokmd-core/analysis"]
3232
git = [

0 commit comments

Comments
 (0)