docs(architecture): add allocation_policy.md and CONTRIBUTING.md cross-link (Phase 6f, refs #193)#285
Merged
Merged
Conversation
…s-link (Phase 6f, refs #193) Adds the workspace allocation contract as a standalone document at `docs/architecture/code-quality/allocation_policy.md` and a §Allocation policy section in `CONTRIBUTING.md` summarising the rule and linking to the new doc. Mirrors the Phase 5e `panic_policy.md` pattern (PR #278): a single contract page captures the rule, the five-category decision tree (α / β / γ / δ / ε), the lint posture, the per-site annotation contract, the audit cadence, the workspace cross-references, and the append-only decisions log. Phase 6 sub-phase 6f deliverable per the phase-6 ownership / borrowing / allocation plan §5f. Contents -------- The new `allocation_policy.md` documents: 1. The one-line rule: hot paths never allocate defensively; cold paths may; every prod `.clone()` / `format!()` / `to_owned()` must fit one of five blessed categories. 2. The five categories with patterns, verdicts, and worked examples from the workspace: - **α — Arc clone**: KEEP (explicit `Arc::clone(&x)` form) - **β — Ownership fence**: KEEP (caller has `&T`, API needs `T`) - **γ — Error / log context**: KEEP (cold path) - **δ — Hot-path anti-pattern**: FIX (refactor, never suppress) - **ε — Test helper**: KEEP (out of scope) 3. The lint posture: 5 clone-family lints at `deny` level (`redundant_clone`, `clone_on_ref_ptr`, `cloned_instead_of_copied`, `inefficient_to_string`, `unnecessary_to_owned`) plus the 7 companion lints at `warn`. 4. The per-site annotation contract: every prod allocation site must satisfy one of three justification shapes (self-evident α, β/γ reason text, or δ refactor comment). 5. The audit cadence: `bash scripts/dev/clone_alloc_audit.sh` (the helper shipped in PR #281) produces the workspace inventory; absolute counts must not regress. 6. Workspace cross-references between this doc, `panic_policy.md`, `lint-posture.md`, `Cargo.toml [workspace.lints]`, and `clippy.toml`. 7. Append-only decisions log capturing every cat-δ refactor that has landed in Phase 6 so future contributors can trace the policy's evolution. `CONTRIBUTING.md` gains a §Allocation policy section directly below the existing §Panic policy section, summarising the rule + five categories in roughly 200 words and linking to the full doc. Verification ------------ - `just lint-pre-push` ✅ (95s): every gate green (fmt, file-size, gates-drift, hooks-drift, workflow-drift, fast-drift, manifest-drift, commit-subjects, vet, vet-audit-discipline, machete, typos, reuse, cargo-check, lint-ci, lint-prod, lint-tests, rustdoc, doc-tests, tests, smoke, deny, lint-ci-windows). - Markdown links validated by the `typos` + `reuse` gates plus a manual check against `docs/architecture/code-quality/` (existing `panic_policy.md` and `lint-posture.md` cross-links resolve). - Doc structure mirrors `panic_policy.md` 1:1 so contributors who know one know the other. Behavior & contracts -------------------- - No code change. Documentation-only. - The lint posture described in §2 is already in force as of Phase 6a's `Cargo.toml` (5 deny-level + 7 warn-level clone-family lints). This commit codifies the *contract* behind the lints, not their values. - The decisions log in §7 records PRs #281 / #282 / #283 / #284 as the cat-δ refactors that have landed; future entries follow the same append-only convention as `panic_policy.md` §7. Strict-lint posture ------------------- No code change; lint posture unchanged. refs #193
This was referenced May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 6 sub-phase 6f deliverable per the phase-6 ownership/borrowing/allocation plan §5f (local plan, gitignored under
/docs/dev/).Mirrors the Phase 5e
panic_policy.mdpattern (PR #278): a single contract page captures the rule, the decision tree, the lint posture, the per-site annotation contract, the audit cadence, the workspace cross-references, and an append-only decisions log.What this adds
docs/architecture/code-quality/allocation_policy.md(new, 318 lines)CONTRIBUTING.md§Allocation policy (new section, 20 lines)The new doc covers:
.clone()/format!()/to_owned()must fit one of five blessed categories (α / β / γ / δ / ε), and δ is a bug.deny(redundant_clone,clone_on_ref_ptr,cloned_instead_of_copied,inefficient_to_string,unnecessary_to_owned) + 7 atwarn(the broader Clippy clone-family set). All 12 emit zero diagnostics across the workspace.Arc::clone(&x)form): KEEP&T, API needsT): KEEPString/Vec<T>eliminable by ownership restructuring): FIX, do not suppress#[cfg(test)]-only): KEEP, out of scopebash scripts/dev/clone_alloc_audit.sh(the helper shipped in PR chore(scripts): add clone_alloc_audit.sh — Phase 6a baseline tool (refs #193) #281) produces the workspace inventory; absolute counts must not regress between PRs.panic_policy.md,lint-posture.md,Cargo.toml [workspace.lints], andclippy.toml.clone_alloc_audit.shshipped (Phase 6a, PR chore(scripts): add clone_alloc_audit.sh — Phase 6a baseline tool (refs #193) #281)path_only_top_n/path_sorted_top_nrefactored (Phase 6c, PR fix(uffs-core): drop defensive Vec<u16> clone in path-only / path-sorted top-N hot path (Phase 6c, refs #193) #282)path_resolver::fast/search::dataframe_convertrefactored (Phase 6d, PR fix(uffs-core): drop per-row format!() allocations in path-resolver + result-conversion hot paths (Phase 6d, refs #193) #283)fold_needlehelper returningCow<'_, str>extracted (Phase 6e, PR refactor(uffs-core): extract fold_needle helper returning Cow<'_, str> (Phase 6e, refs #193) #284)CONTRIBUTING.mdgains a §Allocation policy section directly below the existing §Panic policy section, summarising the rule + five categories in ~200 words and linking to the full doc.Why this matters
panic_policy.md.Verification
just lint-pre-push✅ (95s): every gate green — fmt, file-size, gates-drift, hooks-drift, workflow-drift, fast-drift, manifest-drift, commit-subjects, vet, vet-audit-discipline, machete, typos, reuse, cargo-check, lint-ci, lint-prod, lint-tests, rustdoc, doc-tests, tests, smoke, deny, lint-ci-windows.typos+reusegates plus a manual check againstdocs/architecture/code-quality/(existingpanic_policy.mdandlint-posture.mdcross-links resolve correctly).panic_policy.md1:1 (eight sections in the same order) so contributors who know one know the other.Behavior & contracts
Cargo.toml(5 deny-level + 7 warn-level clone-family lints). This commit codifies the contract behind the lints, not their values.panic_policy.md§7.Strict-lint posture
No code change; lint posture unchanged. No new
#[allow]/#[expect]introduced.refs #193