Skip to content

chore(build-codegen): Phase-9 gap closure — 6 missed env vars + Set-by column + per-crate rustdoc#301

Merged
githubrobbi merged 4 commits into
mainfrom
chore/build-codegen-gap-closure-phase-9
May 20, 2026
Merged

chore(build-codegen): Phase-9 gap closure — 6 missed env vars + Set-by column + per-crate rustdoc#301
githubrobbi merged 4 commits into
mainfrom
chore/build-codegen-gap-closure-phase-9

Conversation

@githubrobbi
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #300 (Phase-9 build/codegen/env-var policy). Deep audit
against playbook §1013-1078 and progress.txt Phase 9 plan §0.2 + §1

  • §2 identified 5 gaps that landed post-merge. This PR closes
    them with a doc-only changeset plus one audit-script bug fix; no
    runtime behavior changes.
# Gap Resolution
A §5 Set by column required by plan §0.2 item 5 was missing Added across all 7 sub-tables in build_codegen_policy.md §5.
B Per-crate # Environment rustdoc sections (plan §1 row 9f deliverable) were deferred Added to 7 crate roots: uffs-cli/main.rs, uffs-client/lib.rs, uffs-core/lib.rs, uffs-daemon/lib.rs, uffs-mcp/lib.rs, uffs-mft/lib.rs, uffs-security/lib.rs.
C crates/uffs-cli/build.rs rustdoc missing the env-var listing required by plan §2 criterion 3 ("build inputs explicit") Added # Environment + # Inputs / tools / platform sections.
D Audit count_includes over-counted include_*! use sites by 1 (doc-comment on line 27 of crates/uffs-text/src/case_fold.rs was being counted alongside the real include_bytes!) Fixed count_includes() to filter doc-comment + block-comment lines and require !( invocation.
E Audit _extract_env_var_names missed env::var_os(\"NAME\") + const-name indirection patterns, causing 6 env vars to be absent from §5 Extended detection to cover both shapes.

Quantitative delta

Metric Pre-#300 baseline Post-#300 (claimed) Actual (this PR)
Distinct env-var names 36 36 42
include_*! use sites 2 2 1
§5.4 UFFS runtime knobs entries 9 9 15

6 newly-detected env vars

All landed in §5.4 UFFS runtime knobs:

Env var Crate Read shape Default
UFFS_CACHE_PROFILE uffs-core + uffs-mft env::var_os(\"…\").is_some() unset = false
UFFS_HOT_TO_WARM_IDLE_SECS uffs-daemon const indirection (HOT_TO_WARM_IDLE_ENV) 60 sec
UFFS_REBUILD_CHILDREN_ALWAYS uffs-mft env::var_os(\"…\").is_some() unset = false
UFFS_SEARCH_MAX_CONCURRENCY uffs-daemon const indirection (Self::SEARCH_CONCURRENCY_ENV) auto-tuned
UFFS_SKIP_ORPHANS uffs-mft env::var_os(\"…\").is_some() unset = false
UFFS_USN_REFRESH_INTERVAL_SECS uffs-daemon const indirection (USN_REFRESH_INTERVAL_ENV) 300 sec

Stale-default corrections (during §5.4 rewrite)

Env var Old (wrong) New (matches pub(crate) const)
UFFS_PARKED_TO_COLD_IDLE_SECS 300 sec 86 400 sec (24 h)
UFFS_WARM_TO_PARKED_IDLE_SECS 60 sec 300 sec (5 min)

Commits (atomic, 4 total)

  1. fix(audit): detect env::var_os + const-name indirection + filter include_*! doc-comments
    • 3 surgical regex fixes in scripts/dev/build_codegen_audit.sh.
    • Caveat noted inline: bare-local indirection (let foo = \"UFFS_X\"; env::var(foo);) is NOT detected, but no such pattern exists in the workspace as of 2026-05-19.
  2. docs(build-codegen-policy): add 6 missed env vars + 'Set by' column + corrected defaults
  3. docs(cli): add Environment section to uffs-cli/build.rs rustdoc
    • 2 new rustdoc subsections (# Environment, # Inputs / tools / platform).
  4. docs(crates): add Environment rustdoc section to 7 crate roots
    • One section per affected crate, content tailored to the env vars that crate actually reads.
    • Cross-link to build_codegen_policy.md §5 registry per playbook §1049-1056.

Rule adherence

  • Rule 1 (no suppression): zero #[allow(rustdoc::*)], zero lint disables. Two real broken intra-doc-links (fs::daemon_socket_pathfs::set_file_permissions_owner_only, daemon_spawn::ElevationPolicy → described in prose since daemon_spawn is pub(crate)) fixed at root.
  • Rule 2 (surgical fixes): minimal regex tightening + table additions only; no broader refactor.
  • Rule 3 (preserve contracts): zero runtime behavior change; zero public-API change.
  • Rule 4 (don't dodge tests): existing \$UFFS_TEST_ENV_NEVER_SET_12345 sentinel still correctly excluded by prod-only globs; verified post-fix.
  • Rule 5 (atomic commits): 4 commits, one per gap-cluster, with clear root-cause messages.

Verification

  • bash scripts/dev/build_codegen_audit.sh → 42 distinct env-var names ✅
  • All 6 new env vars + 0 false positives ✅
  • Test sentinel `UFFS_TEST_ENV_NEVER_SET_12345` correctly excluded ✅
  • cargo check workspace + RUSTDOCFLAGS=\"-D warnings\" cargo doc --no-deps --workspace
  • Full pre-push gate green (lint-fast + rustdoc + doc-tests + tests + smoke + lint-ci-windows, 176 s)

Refs #298, follows #300.

…ude_*! doc-comments

Three surgical fixes to scripts/dev/build_codegen_audit.sh detection
regexes uncovered by the Phase-9 gap-closure audit (post-PR #300):

1. _extract_env_var_names() now also matches:
   * (std::)?env::var_os("NAME")  -- the absence-checking idiom
     used in uffs-core + uffs-mft for UFFS_CACHE_PROFILE,
     UFFS_REBUILD_CHILDREN_ALWAYS, UFFS_SKIP_ORPHANS.
   * const NAME: &str = "VAR";    -- const-name indirection.  When
     the read site uses env::var(Self::FOO) (non-literal), the literal
     value lives only in the const declaration.  Detection is gated to
     known env-var prefixes (UFFS_/RUST_/XDG_/CARGO_) to avoid flagging
     arbitrary string consts.  Catches UFFS_HOT_TO_WARM_IDLE_SECS,
     UFFS_SEARCH_MAX_CONCURRENCY, UFFS_USN_REFRESH_INTERVAL_SECS.

2. count_includes() now skips doc-comment + block-comment lines using
   the same filter as _extract_env_var_names() and requires the macro
   to be invoked ("!("), not merely mentioned.  Fixes the prior
   over-count of 2 -> 1 for crates/uffs-text/src/case_fold.rs (the
   doc-comment on line 27 was being counted as a use site alongside
   the real include_bytes!("upcase_default.bin") on line 28).

Caveat documented inline: bare-local indirection
(let foo = "UFFS_X"; env::var(foo);) is NOT detected.  No such
pattern exists in the workspace as of 2026-05-19.

Result: workspace baseline corrected from 36 -> 42 distinct env-var
names and from 2 -> 1 include_*! site.  Per-crate counts updated
across the policy doc + final report in subsequent commits on this
branch.

Refs #298.
… corrected defaults

Gap-closure follow-up to PR #300 — addresses gaps A, E and stale-default
corrections identified by the deep audit against playbook \u00a71013-1078 +
plan \u00a70.2 item 5.

Changes to docs/architecture/code-quality/build_codegen_policy.md:

1. \u00a73.5 env-var contract extended:
   * Documents the four detection shapes the audit script supports
     (env::var, env::var_os, env!/option_env!, const-name indirection).
   * Requires every \u00a75 row to carry the 'Set by' field listing the
     expected writer (Cargo / OS / operator / CI workflow / test
     harness / etc).

2. \u00a75 registry rewritten:
   * 6 new rows in \u00a75.4 (UFFS runtime knobs) for env vars the audit
     script missed pre-fix (commit 339a1be in this branch):
       - UFFS_CACHE_PROFILE       (uffs-core + uffs-mft, env::var_os)
       - UFFS_HOT_TO_WARM_IDLE_SECS (uffs-daemon, const indirection)
       - UFFS_REBUILD_CHILDREN_ALWAYS (uffs-mft, env::var_os)
       - UFFS_SEARCH_MAX_CONCURRENCY  (uffs-daemon, const indirection)
       - UFFS_SKIP_ORPHANS        (uffs-mft, env::var_os)
       - UFFS_USN_REFRESH_INTERVAL_SECS (uffs-daemon, const indirection)
   * New 'Set by' column on all 7 sub-tables.
   * Corrected stale defaults: UFFS_PARKED_TO_COLD_IDLE_SECS 300 ->
     86400 (24 h), UFFS_WARM_TO_PARKED_IDLE_SECS 60 -> 300 (5 min) -
     matching the actual pub(crate) const values in
     crates/uffs-daemon/src/cache/policy.rs.
   * Source-header SHA bumped to aeb9807 (post-#300).
   * Footer total: 36 -> 42 distinct env-var names; sub-counts
     rewritten (\u00a75.4 grew 9 -> 15).

3. \u00a72 lint-posture surface count updated: 36 -> 42.

4. \u00a710 decisions log:
   * 9-gap row added describing the 5-gap delta + 2-default
     correction.
   * 9b/9c/9d/9e/9f/9g rows retro-tagged 'this PR' -> '#300' (they
     all merged in PR #300; only the new 9-gap row carries the
     'this PR' marker for the current branch).

Rule-1 adherence: zero suppression hacks; doc-only.
Rule-3 adherence: no source code or public API change.

Refs #298.
Phase-9 gap closure (refs #298): document the two CARGO_CFG_* env vars
the script reads, plus a consolidated files/tools/platform inputs-
explicit block, per plan acceptance criterion 3 + playbook section
1049-1056.

Doc-only.  Zero behavior change.
Phase-9 gap-closure (refs #298) -- per-crate # Environment sections
cross-linked to build_codegen_policy.md section 5.

Sections (one per affected crate, content tailored to env vars that
crate actually reads):

* uffs-cli/src/main.rs (5 runtime vars; build-time vars cross-ref to
  build.rs section).
* uffs-client/src/lib.rs (5 vars incl XDG_RUNTIME_DIR + UFFS_CLIENT_*).
* uffs-core/src/lib.rs (1 var -- UFFS_CACHE_PROFILE, 8 read sites).
* uffs-daemon/src/lib.rs (10 vars incl 4 const-indirect cache-tier
  knobs + UFFS_SEARCH_MAX_CONCURRENCY).
* uffs-mcp/src/lib.rs (4 vars incl UFFS_MCP_AUTH_TOKEN).
* uffs-mft/src/lib.rs (12 vars incl 3 env::var_os dev knobs).
* uffs-security/src/lib.rs (2 vars -- UFFS_DEV, USERNAME).

Each section: 4-column Markdown table (Env var / Type / Default /
Notes), INTERNAL / STANDARD / CARGO semver class tag per row, inline
call-out for env::var_os shape and for const-indirect read paths.

Doc-only.  Zero behavior change.  cargo check on all 7 crates green.
cargo fmt applied to satisfy line-wrap.

Refs #298.
@githubrobbi githubrobbi merged commit ff8b897 into main May 20, 2026
21 checks passed
@githubrobbi githubrobbi deleted the chore/build-codegen-gap-closure-phase-9 branch May 20, 2026 00:21
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