Skip to content

docs(architecture): add build_codegen_policy.md + CONTRIBUTING cross-link (refs #298)#300

Merged
githubrobbi merged 1 commit into
mainfrom
chore/build-codegen-policy-phase-9
May 19, 2026
Merged

docs(architecture): add build_codegen_policy.md + CONTRIBUTING cross-link (refs #298)#300
githubrobbi merged 1 commit into
mainfrom
chore/build-codegen-policy-phase-9

Conversation

@githubrobbi
Copy link
Copy Markdown
Collaborator

Summary

Phase 9c+9d+9e+9f+9g closeout — workspace policy doc for build scripts, proc-macro crates, declarative macros, codegen binaries, and the environment-variable surface. Mirrors the structure established by:

  • panic_policy.md (Phase 5e)
  • allocation_policy.md (Phase 6f)
  • trait_policy.md (Phase 7g)
  • dependency_policy.md (Phase 8c)

Tracking issue: #298.

Doc structure (10 sections, 383 LOC)

\u00a7 Title Highlights
1 The rule One-liner + 4 class tables: B1-B3 build.rs / M1-M3 macros / C1-C2 codegen
2 Lint posture 0 new clippy lints; positive contract via build_codegen_audit.sh + 4 existing *-drift gates
3 Per-section contracts The \u00a7988-mirror sub-contracts for build.rs / proc-macro / macro_rules / codegen / env-var
4 Hygiene rules 6 rules covering no-new-build.rs / no-new-proc-macro / no-control-flow-hiding / no-new-codegen-without-drift-detector / no-new-env-var-without-registry / naming conventions
5 Environment variable registry 36 distinct names across 7 scope categories (build-time / standard-runtime / logging / UFFS runtime / UFFS client / build-release / test-only)
6 Per-crate registry build.rs / proc-macro / macro_rules / codegen tables
7 Anti-patterns 8 rejected patterns
8 Audit cadence per-phase + per-introduction + annual
9 Cross-references links to panic / allocation / trait / dependency policies, gates manifest, release automation
10 Decisions log 8 entries 9a-9g, append-only

Current posture documented (SHA 0433065c7, Phase 9 entry)

  • 1 build.rs (uffs-cli) \u2014 class B2 + B3 (MSVC-gated PE resource embedding + /DELAYLOAD linker args).
  • 0 proc-macro crates \u2014 deliberate workspace posture; introducing one requires the \u00a73.2 contract.
  • 6 macro_rules! declarations \u2014 all in uffs-mft, 5 \u00d7 M1 (binary-read helpers) + 1 \u00d7 M2+M3 (drive_letter_consts!).
  • 4 codegen binaries \u2014 3 \u00d7 C1 (gen-hooks, gen-workflow, manifest-audit \u2014 all drift-detected) + 1 \u00d7 C2 (ci-pipeline \u2014 release orchestrator).
  • 36 distinct env-var names \u2014 fully inventoried in \u00a75 with name / scope / type / default / where-read / semver-class per row.

CONTRIBUTING.md edit

Adds a new \u00a7"Build, codegen, and env-var policy" section (15 lines) between the existing \u00a7"Feature flag and dependency policy" and \u00a7"Docs map" sections. Cross-links to the new policy doc. Mirrors the 15-line summary shape of the 4 existing policy sections.

Companion findings (local-only, gitignored \u2014 not part of this PR)

  • docs/dev/baseline/2026-05-19/phase_9_build_audit_findings.md (9b verdict: PASS, no drift)
  • docs/dev/baseline/2026-05-19/phase_9_macro_audit_findings.md (9d verdict: PASS, no drift; 1 refactor candidate deferred)
  • docs/dev/baseline/2026-05-19/phase_9_codegen_inventory.md (9e verdict: PASS, no drift)

Rule-1 adherence

Zero #[allow] introductions; zero clippy lint changes; zero source code modifications. Doc-only PR. The single existing #[allow(clippy::expect_used)] in crates/uffs-cli/build.rs is documented in the new policy doc \u00a73.1 as the workspace-approved panic_policy.md \u00a71 exception for build-host failure modes (does not change in this PR).

Rule-3 adherence

Preserves behavior \u2014 no source code changed, no public API changed, no observable behavior changed.

Out-of-scope (deferred to follow-ups)

Closes #298 only at Phase-9 closeout (this PR is 9c-9g; final report + issue close land in 9h).

…link (refs #298)

Phase 9c+9d+9e+9f+9g closeout: workspace policy doc for build scripts,
proc-macro crates, declarative macros, codegen binaries, and the
environment-variable surface.  Mirrors the structure established by
`panic_policy.md` (5e), `allocation_policy.md` (6f),
`trait_policy.md` (7g), and `dependency_policy.md` (8c).

Doc contents:

- \u00a71  The rule (one-liner + 4 class tables: B1-B3 build.rs / M1-M3
  macros / C1-C2 codegen)
- \u00a72  Lint posture (0 new clippy lints; positive contract via
  `build_codegen_audit.sh` + 4 existing `*-drift` gates)
- \u00a73  Per-section contracts (build.rs / proc-macro / macro_rules /
  codegen / env-var) \u2014 the \u00a7988-mirror sub-contracts
- \u00a74  Hygiene rules (6 rules covering no-new-build.rs /
  no-new-proc-macro / no-control-flow-hiding / no-new-codegen-without-
  drift-detector / no-new-env-var-without-registry / naming conventions)
- \u00a75  Environment variable registry \u2014 36 distinct names across 7
  scope categories (build-time / standard-runtime / logging / UFFS
  runtime / UFFS client / build-release / test-only)
- \u00a76  Per-crate registry (build.rs / proc-macro / macro_rules /
  codegen tables)
- \u00a77  Anti-patterns (8 rejected patterns)
- \u00a78  Audit cadence (per-phase + per-introduction + annual)
- \u00a79  Cross-references
- \u00a710 Decisions log (8 entries 9a-9g)

CONTRIBUTING.md edit: adds a new \u00a7"Build, codegen, and env-var
policy" section between the existing \u00a7"Feature flag and dependency
policy" and \u00a7"Docs map" sections.  Cross-links to the new policy doc.
Mirrors the 15-line summary shape of the 4 existing policy sections.

Companion findings (local-only, gitignored):
- docs/dev/baseline/2026-05-19/phase_9_build_audit_findings.md
- docs/dev/baseline/2026-05-19/phase_9_macro_audit_findings.md
- docs/dev/baseline/2026-05-19/phase_9_codegen_inventory.md

Tracking issue: #298.

Rule-1 adherence: zero `#[allow]` introductions; zero clippy lint
changes; zero source code modifications.  Doc-only PR.  The single
existing `#[allow(clippy::expect_used)]` in `crates/uffs-cli/build.rs`
is documented in the new policy doc \u00a73.1 as the workspace-approved
`panic_policy.md` \u00a71 exception for build-host failure modes.

Rule-3 adherence: preserves behavior \u2014 no source code changed, no
public API changed, no observable behavior changed.
@githubrobbi githubrobbi enabled auto-merge (squash) May 19, 2026 22:15
@githubrobbi githubrobbi merged commit aeb9807 into main May 19, 2026
19 checks passed
@githubrobbi githubrobbi deleted the chore/build-codegen-policy-phase-9 branch May 19, 2026 22:16
githubrobbi added a commit that referenced this pull request May 20, 2026
…y column + per-crate rustdoc (#301)

* fix(audit): detect env::var_os + const-name indirection + filter include_*! 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.

* docs(build-codegen-policy): add 6 missed env vars + 'Set by' column + 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.

* docs(cli): add Environment section to uffs-cli/build.rs rustdoc

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.

* docs(crates): add Environment rustdoc section to 7 crate roots

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.
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.

[playbook-phase-9] Build scripts, macros, and code generation

1 participant