Skip to content

chore(policy): document every policy field and deny missing docs - #135

Draft
siloteemu wants to merge 1 commit into
ROCm:mainfrom
siloteemu:chore/policy-field-docs
Draft

siloteemu wants to merge 1 commit into
ROCm:mainfrom
siloteemu:chore/policy-field-docs

Conversation

@siloteemu

Copy link
Copy Markdown

Motivation

  • A person or tool writing a policy should be able to learn, from the code and the generated API documentation, what each policy field is for, which values it accepts and what its default is.
  • #![deny(missing_docs)] keeps that true as the policy model grows: a new public item without a doc comment fails the build. A separate hand-kept reference would drift from the code.

Technical Details

  • One file changed: crates/axis-core/src/policy.rs.
  • /// doc comments on every public type, enum variant and field of the policy model, on PolicyError, and on the three public methods that had none (RuntimeContainment::as_str, RuntimeProvider::as_str, ProcessPolicy::effective_max_processes).
  • #![deny(missing_docs)] is an inner attribute of the policy module only. Other modules of axis-core are unaffected, and private and pub(crate) items are not checked.
  • Where the code establishes a default, or a validation refusal made in policy.rs, the comment states it. Where the code establishes nothing more, the comment states only the value form and the default.
  • Existing comments are unchanged; the diff only adds lines. The only non-comment additions are the attribute and one blank line.
  • The comments contain no code blocks, so no doc-tests are added.
  • No dependency, Cargo.lock, workflow or bundled policy change.
  • For reviewers: a later PR that adds a public item to policy.rs must document it, and a change to a default should update the Default: line in the same PR. If the process-limit defaults change (see fix(policy): implicit process limits fail on hosts without writable cgroup v2 #89), update the Default: lines on those fields in the same change.

Security impact: none. Documentation and a compile-time lint only; no behaviour change, and no change to parsing, validation or defaults (shown by the round trip in the Test Plan).

Test Plan

Linux (x86_64), locally:

  • The first block of local checks in DEVELOPMENT.md: cargo fmt --all -- --check, cargo fmt --manifest-path gui/linux/Cargo.toml -- --check, cargo clippy --locked --all-targets -- -D warnings, cargo test --locked, bash scripts/test_security_tier0.sh.
  • RUSTDOCFLAGS="-D warnings" cargo doc --locked -p axis-core --no-deps.
  • axis policy validate on all 17 bundled policies (policies/*.yaml, policies/agents/*.yaml).
  • Round trip: each bundled policy parsed with Policy::from_file and re-serialized (YAML and Debug dump) on main and on this branch, and the outputs compared.
  • Lint check: a throwaway undocumented public field added to policy.rs to confirm the build fails (not committed).

macOS and Windows: not run locally, because they cannot be compiled on this host; CI covers them. policy.rs has no platform-specific items, so the lint checks the same set of items on every target.

Test Result

  • cargo fmt (both): PASS. cargo clippy: PASS. cargo doc with -D warnings: PASS.
  • axis policy validate: 17/17 valid.
  • Round trip: 17 policies, outputs identical on main and on this branch (empty diff).
  • cargo test --locked: 1040 passed, 46 failed, 6 not run (marked #[ignore]). The same 46 tests fail identically on an unmodified main on this host: sandbox, seccomp/MXC and exit-status tests in axis-sandbox, axis-cli and axis-daemon that need a runtime environment this host does not have. None is in axis-core; its tests pass (250 unit tests, 5 policy fixture tests).
  • scripts/test_security_tier0.sh: the axis-core steps pass. Its final axis-sandbox MXC step fails with 20 tests, identically on unmodified main, for the same reason.
  • Lint check: the build fails, and the diagnostic names the file and line and quotes the field:
error: missing documentation for a struct field
    --> crates/axis-core/src/policy.rs:1003:5
     |
1003 |     pub zz_throwaway_undocumented_field: bool,
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
note: the lint level is defined here
    --> crates/axis-core/src/policy.rs:10:9
     |
  10 | #![deny(missing_docs)]
     |         ^^^^^^^^^^^^
error: could not compile `axis-core` (lib) due to 1 previous error

Skipped:

  • The e2e scripts in DEVELOPMENT.md (e2e/linux/test_sandbox.sh, test_e2e_daemon.sh, e2e/agents/test_agents.sh). They exercise changed policies and the launch path, which this change does not touch, and they need an MXC runtime this host does not have.
  • macOS and Windows tests: not run locally; CI runs them.

Add a doc comment to every public type, enum variant and field of the
policy model, stating the values it accepts and its default and, where
the policy code makes it clear, what it is for, so a policy author can
find these in the code and the generated API documentation.

Enable `#![deny(missing_docs)]` in the policy module so that a new
public item without documentation fails the build. The lint is scoped
to this module; other modules of the crate are unchanged.

Existing comments are kept as they were and only missing lines are
added. There is no change to code, dependencies or bundled policies.

Signed-off-by: Teemu Kuusisto <[email protected]>
@siloteemu
siloteemu force-pushed the chore/policy-field-docs branch from e089dc8 to b7d9444 Compare November 25, 2026 15:58

This branch has not been deployed

No deployments
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