You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dylint: ban raw .fbuild path literals outside fbuild-paths; ratchet to zero #1349
fbuild-paths declares itself the single source of truth for all .fbuild paths (crates/fbuild-paths/src/lib.rs:3), but the .fbuild / .fbuild/build path segments are hardcoded as raw string literals in 69 files across the workspace — including production code:
plus ~25 test files hand-rolling fixture layouts like dir.join(".fbuild/build/uno/release/...")
Raw literals drift from the real layout rules (env-segment auto-collapse, FBUILD_BUILD_DIR override, PIO .build/pio layouts — see agents/docs/path-conventions.md) and silently break compile_cwd_from_output / BuildLayout consumers when the layout evolves.
Proposal
New dylint lintdylints/ban_raw_fbuild_path (pattern after the existing dylints/ban_raw_subprocess crate): flag string literals containing .fbuild outside crates/fbuild-paths/src/** (the sanctioned definition site).
Export canonical primitives from fbuild-paths: FBUILD_DIR_NAME / BUILD_DIR_NAME consts plus the existing project_fbuild_dir() / BuildLayout::resolve() so call sites have a mechanical replacement.
Ratchet: land the lint with a baseline allowlist of the current 69 files; each file must be sanitized (route through BuildLayout / the new consts) and removed from the allowlist; the allowlist may only shrink. CI fails on any new raw-literal site.
Test fixtures should build layouts via fbuild_paths::BuildLayout::new(project, env, profile).resolve() instead of hand-rolled join(".fbuild/build/...") chains.
Acceptance
dylints/ban_raw_fbuild_path lint crate exists, wired into the dylint CI gate alongside ban_raw_subprocess
Baseline allowlist checked in; count recorded in this issue
Allowlist reaches zero (or only fbuild-paths definition sites remain)
Acceptance items 1 and 2 landed in #1353 (merged as 49ec69c).
Item 1 — lint crate wired into the Dylint gate.dylints/ban_raw_fbuild_path flags any string literal whose contents include .fbuild. It catches both real-world shapes — Path::join(".fbuild") segments and format!(".fbuild/build/{}/release/...") templates — because rustc lowers format_args! pieces to HIR Lit nodes, so the late pass sees them. Discovered via [workspace.metadata.dylint] libraries = [{ path = "dylints/*" }]; registered in the root exclude list, ci/hooks/crate_guard.py, and dylints/README.md.
Item 2 — baseline recorded: 47 files. Plus one permanent exemption, crates/fbuild-paths/src/lib.rs, the definition site itself.
The baseline came from a comment-stripping, raw-string- and escape-aware Rust string-literal scanner rather than a line grep, then was trued up against cargo-dylint dylint --lib ban_raw_fbuild_path -- --workspace --all-targets, which now exits 0 with zero violations. Two notes for whoever picks up the ratchet:
crates/fbuild-cli/src/cli/args.rs is on the list because clap's #[derive(Subcommand)] stringifies /// doc text into help strings; the literal's call site is the #[derive] item, so the whole file is exempt rather than one doc line.
assert!(cond) synthesizes "assertion failed: <stringified cond>" with no source span at all. Those are dropped by a dummy-span guard — a diagnostic nobody can locate is one nobody can fix.
Item 3 — ratchet to zero — remains open, which is why this issue stays open. The list is shrink-only and that is now enforced, not just documented: ci/check_fbuild_path_baseline.py diffs src/allowlist.txt against origin/main in the Dylint job and fails on any added entry. Removals always pass.
Also exported for the sanitization work: fbuild_paths::FBUILD_DIR_NAME and fbuild_paths::BUILD_DIR_NAME, alongside the existing get_project_fbuild_dir, get_project_build_root, and BuildLayout::resolve. Per-file recipe is in dylints/ban_raw_fbuild_path/README.md → Rollout: sanitize, delete the line, bump the crate version to bust the Dylint .so cache.
Baseline was 48 entries at landing. #1383 takes it to 43 by sanitizing all five fbuild-deploy sites (lpc.rs, lpc_debugger_reflash.rs, probe_rs.rs, wchisp.rs, wlink.rs).
The batch found a live instance of exactly what this issue predicted: all five had re-derived ~/.fbuild/{dev|prod}/tools with var_os("FBUILD_DEV_MODE").is_some(), while fbuild_paths::is_dev_mode() requires the literal 1. FBUILD_DEV_MODE=0 therefore sent managed tools to the dev tree while every other path stayed in prod.
One structural note for the tail of the ratchet: fbuild-core cannot use fbuild_paths::FBUILD_DIR_NAME — fbuild-paths depends on fbuild-core, not the reverse. Those two entries need either a const that lives in fbuild-core and is re-exported by fbuild-paths, or to stay as permanently-sanctioned sites. Worth deciding before the last batch rather than during it.
Activity
fix(dylint): resolve `.fbuild` literal spans to their macro call site
feat(dylint): ban raw `.fbuild` path literals outside fbuild-paths
fix(dylint): resolve `.fbuild` literal spans to their macro call site
fix(dylint): enforce the shrink-only baseline and correct the layout …
feat(dylint): ban raw `.fbuild` path literals outside fbuild-paths
fix(dylint): resolve `.fbuild` literal spans to their macro call site
fix(dylint): enforce the shrink-only baseline and correct the layout …
feat(dylint): ban raw `.fbuild` path literals outside fbuild-paths (#…
zackees commentedon Aug 22, 2026
Acceptance items 1 and 2 landed in #1353 (merged as 49ec69c).
Item 1 — lint crate wired into the Dylint gate.
dylints/ban_raw_fbuild_pathflags any string literal whose contents include.fbuild. It catches both real-world shapes —Path::join(".fbuild")segments andformat!(".fbuild/build/{}/release/...")templates — because rustc lowersformat_args!pieces to HIRLitnodes, so the late pass sees them. Discovered via[workspace.metadata.dylint] libraries = [{ path = "dylints/*" }]; registered in the rootexcludelist,ci/hooks/crate_guard.py, anddylints/README.md.Item 2 — baseline recorded: 47 files. Plus one permanent exemption,
crates/fbuild-paths/src/lib.rs, the definition site itself.The baseline came from a comment-stripping, raw-string- and escape-aware Rust string-literal scanner rather than a line grep, then was trued up against
cargo-dylint dylint --lib ban_raw_fbuild_path -- --workspace --all-targets, which now exits 0 with zero violations. Two notes for whoever picks up the ratchet:crates/fbuild-cli/src/cli/args.rsis on the list because clap's#[derive(Subcommand)]stringifies///doc text into help strings; the literal's call site is the#[derive]item, so the whole file is exempt rather than one doc line.assert!(cond)synthesizes"assertion failed: <stringified cond>"with no source span at all. Those are dropped by a dummy-span guard — a diagnostic nobody can locate is one nobody can fix.Item 3 — ratchet to zero — remains open, which is why this issue stays open. The list is shrink-only and that is now enforced, not just documented:
ci/check_fbuild_path_baseline.pydiffssrc/allowlist.txtagainstorigin/mainin the Dylint job and fails on any added entry. Removals always pass.Also exported for the sanitization work:
fbuild_paths::FBUILD_DIR_NAMEandfbuild_paths::BUILD_DIR_NAME, alongside the existingget_project_fbuild_dir,get_project_build_root, andBuildLayout::resolve. Per-file recipe is indylints/ban_raw_fbuild_path/README.md→ Rollout: sanitize, delete the line, bump the crate version to bust the Dylint.socache.fix(build): fail the stage-2 oracle closed and document the cache-roo…
fix(build): anchor rebuild signatures to the compile workspace (#1350)
zackees commentedon Aug 23, 2026
Baseline was 48 entries at landing. #1383 takes it to 43 by sanitizing all five
fbuild-deploysites (lpc.rs,lpc_debugger_reflash.rs,probe_rs.rs,wchisp.rs,wlink.rs).The batch found a live instance of exactly what this issue predicted: all five had re-derived
~/.fbuild/{dev|prod}/toolswithvar_os("FBUILD_DEV_MODE").is_some(), whilefbuild_paths::is_dev_mode()requires the literal1.FBUILD_DEV_MODE=0therefore sent managed tools to the dev tree while every other path stayed in prod.Remaining 43, by crate: fbuild-build 12, fbuild-build-engine 10, fbuild-cli 9, fbuild-daemon 6, fbuild-core 2, fbuild-paths 1 (the sanctioned definition site), fbuild-library-select 1, fbuild-library 1, fbuild-build-arm 1.
One structural note for the tail of the ratchet:
fbuild-corecannot usefbuild_paths::FBUILD_DIR_NAME—fbuild-pathsdepends onfbuild-core, not the reverse. Those two entries need either a const that lives infbuild-coreand is re-exported byfbuild-paths, or to stay as permanently-sanctioned sites. Worth deciding before the last batch rather than during it.chore(paths): route fbuild-deploy tool paths through fbuild-paths (#1383
2 remaining items
fix(daemon): let the install-state note name the directory actually c…
chore(daemon): make daemon diagnostics name real paths, ratchet six s…
fix(daemon): let the install-state note name the directory actually c…
fix(daemon): follow FBUILD_BUILD_DIR in the generic install-state note
chore(daemon): make daemon diagnostics name real paths, ratchet six s…
fix(daemon): let the install-state note name the directory actually c…
fix(daemon): follow FBUILD_BUILD_DIR in the generic install-state note
chore(daemon): make daemon diagnostics name real paths, ratchet six s…
chore(build-engine): route production `.fbuild` walks through fbuild-…
chore(build-engine): route production `.fbuild` walks through fbuild-…
chore(cli): route fbuild-cli through fbuild-paths; document the clap …
chore(build-engine): build test fixtures from the canonical path segm…
chore: use BUILD_DIR_NAME for the segment that follows FBUILD_DIR_NAME
chore(build): finish the `.fbuild` ratchet — baseline reaches zero (#…