Skip to content

Audit Phase 7: docstring coverage rollout to 100% - #289

Draft
cl126162 wants to merge 8 commits into
stack-06-phase56-breaking-semantics-registrationfrom
stack-07-phase7-docstring-coverage
Draft

cl126162 wants to merge 8 commits into
stack-06-phase56-breaking-semantics-registrationfrom
stack-07-phase7-docstring-coverage

Conversation

@cl126162

@cl126162 cl126162 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Seventh PR in the sequential `hydrogym-audit-v2` stack. Targets #288 (Phase 5/6).

Scope (Phase 7 — docstring coverage)

  • Add `test/measure_docstrings.py`, a small AST-based coverage tool
    (counts public classes/functions/methods with a docstring vs without,
    per file and in total)
  • Roll out missing docstrings across `core.py`, the Firedrake backend,
    the JAX backend, and the remaining lower-coverage files
  • Task 7.2: wire the tool into CI as a coverage floor (99%) and close
    the final private-helper gaps

Verified

  • `ruff check .`, `ruff format --check .`, `isort . --check-only --diff`,
    codespell all clean (added a follow-up commit for 2 formatting findings)
  • `python test/measure_docstrings.py --fail-under 99` run live at the
    tip of this chunk: 454/454 (100.0%), floor satisfied

🤖 Generated with Claude Code

@cl126162
cl126162 force-pushed the stack-06-phase56-breaking-semantics-registration branch from fd93b01 to 3118738 Compare September 7, 2026 06:31
@cl126162
cl126162 force-pushed the stack-07-phase7-docstring-coverage branch from e5b3799 to b64ca89 Compare September 7, 2026 06:31
@cl126162
cl126162 force-pushed the stack-06-phase56-breaking-semantics-registration branch from 3118738 to 89c1938 Compare September 7, 2026 10:15
clagemann126162 and others added 8 commits September 7, 2026 12:15
test/measure_docstrings.py: ast.get_docstring-based coverage counter over
module-level and nested class/function definitions, mirroring the audit's
method. Dev-only helper (not wired into pytest); invoked with explicit
file args or the 16-file DEFAULT_TARGETS list (the audit's target set,
corrected to paths that exist: the audit's linearized.py/irkx.py/
env_base.py/jax envs/cylinder.py entries do not exist anywhere in the
repo history).

Validation: python3 -m py_compile clean; run against core.py reports
48/48 (100.0%) matching the just-landed 12bae69.

Co-Authored-By: Claude Code <noreply@anthropic.com>
(cherry picked from commit 11b6bd6780c3712f647e3f433f45a27e36f28427)
Docstrings-only change to hydrogym/core.py: no code, signature, logic, or
import edits. Google-style, matching pydoc-markdown.yaml; documents the
two deprecation shims and the unknown-config-key warning.

Coverage per test/measure_docstrings.py (ast.get_docstring, have/total):
hydrogym/core.py 39/48 (81.2%) -> 48/48 (100.0%).

Validation: python3 -m py_compile clean (PYTHONPYCACHEPREFIX=/tmp, since
the repo's root-owned __pycache__ dirs reject writes in this env);
pytest unavailable in the bare env (container tier covers test_core.py,
whose semantics are unchanged by a docstring-only diff).

Co-Authored-By: Claude Code <noreply@anthropic.com>
(cherry picked from commit 12bae69acc96bb48552184cb46fa4441aa3147a7)
Google-style docstrings (docs/pydoc-markdown.yaml processor, style of
hydrogym/maia/env_core.py) added to all public functions, methods, and
classes lacking them. Docstrings only — no changes to code, signatures,
logic, or imports. Coverage measured with test/measure_docstrings.py:

- hydrogym/firedrake/flow.py:            27/46 (58.7%) -> 45/46 (97.8%)
- hydrogym/firedrake/solvers/base.py:      1/9  (11.1%) -> 9/9  (100%)
- hydrogym/firedrake/actuator.py:          2/5  (40.0%) -> 5/5  (100%)
- hydrogym/firedrake/envs/cavity/flow.py:  1/10 (10.0%) -> 10/10 (100%)
- hydrogym/firedrake/envs/cylinder/flow.py: 5/16 (31.2%) -> 16/16 (100%)
- hydrogym/firedrake/envs/pinball/flow.py: 0/11 (0.0%)  -> 11/12 (91.7%)
- hydrogym/firedrake/envs/step/flow.py:    2/14 (14.3%) -> 14/14 (100%)

Remaining undocumented are private nested helpers only: the '_inner'
closure in FlowConfig._complex_shift_inv_operator and the '_lift_drag'
closure in Pinball.configure_observations.

Note: audit target files solvers/linearized.py, solvers/irkx.py, and
envs/env_base.py do not exist in this repo (nor anywhere in its git
history), so they had no coverage to roll out.

Co-Authored-By: Claude Code <noreply@anthropic.com>
(cherry picked from commit da0535ee8296c2e2af1c476d7b0fa852ad7e0403)
Google-style docstrings for every public class/function/method in the
JAX backend (docstring lines only; no code, signatures, or logic changed).
Coverage per test/measure_docstrings.py (ast.get_docstring, have/total):

- hydrogym/jax/env_core.py:      13/65 (20.0%) -> 63/65 (96.9%)
- hydrogym/jax/solvers/base.py:   2/12 (16.7%) ->  9/12 (75.0%)
- hydrogym/jax/envs/channel.py:   2/37 ( 5.4%) -> 34/37 (91.9%)
- hydrogym/jax/envs/kolmogorov.py: 18/49 (36.7%) -> 40/49 (81.6%)
- hydrogym/jax/equation.py:       0/12 ( 0.0%) -> 12/12 (100%)

Remaining undocumented nodes are private helpers, dunders with adjacent
explanatory comments, and trivial nested closures (time_step_fn,
inner_scan, add_state, forcing_hat, step_fn, calculate_velocity,
scan_fn, dstream_func_*, obs_one_state, one) plus private
_calculate_velocity_point/_trajectory_mean_obs/_clip_action and the
__getattr__ proxy. hydrogym/jax/envs/cylinder.py does not exist in the
tree (reported MISSING by the measure script); nothing to document.

(cherry picked from commit b65e669735d5589da3f945b14719467a8755823e)
bdf_ext.py 0%→100%, stabilization.py 0%→100%, jax/solvers/base.py
75%→100%, jax/envs/kolmogorov.py 82%→100%, jax/envs/channel.py
92%→100%, firedrake/envs/pinball/flow.py 92%→100%. Google-style,
matching pydoc-markdown.yaml's processor. Also corrected two
pre-existing inaccurate docstrings (RKCN.step signature description,
kolmogorov forcing_term args). Zero functional changes — verified
diff contains only docstring/comment lines.

measure_docstrings.py DEFAULT_TARGETS extended to the Finding-4
files (data_manager, hf_env_mixin, core_external, nek/env,
maia/env_core, jaxfluids/env_core). Full default-set coverage now
448/454 (98.7%).

Validation: python3 test/measure_docstrings.py before/after; in-memory
compile() of all 7 touched files (py_compile blocked by unwritable
__pycache__ in sandbox). Docs build not runnable (no node_modules).

Co-Authored-By: Claude Code <noreply@anthropic.com>
(cherry picked from commit 154ad139fb9199f70c67ddc77da1a234bdb215c8)
measure_docstrings.py gains a --fail-under <pct> flag that exits 1
when TOTAL coverage drops below the floor; a new 'Docstring coverage
floor' job in test.yml runs it (stdlib-only, seconds) at the 99% level
achieved by the Phase 7 rollout (99.8% = 453/454 after this commit;
the single remaining gap is nek/env.py's __init__, deferred to avoid
same-file conflict with the in-flight Task 6.2 agent).

Also documents the last private helpers outside nek/ (firedrake/flow
_inner, jax/env_core _clip_action/__getattr__, core_external
_require_mpi, jaxfluids _init_from_hf). Zero functional changes.

Validation: python3 test/measure_docstrings.py --fail-under 99 exits 0
at 99.8%; workflow YAML edited in place (validated structure by tool
run above; pyyaml unavailable in sandbox).

Co-Authored-By: Claude Code <noreply@anthropic.com>
(cherry picked from commit 2f8133b1cbdd7e8738c67e947e53580545e028b8)
Deferred during Task 6.2 to avoid a same-file conflict with the
in-flight RPC-batching agent. Default-set coverage is now 454/454
(100%).

Co-Authored-By: Claude Code <noreply@anthropic.com>
(cherry picked from commit 6212fb4fa43d38325d8df7d261a6bd8459196bc9)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@cl126162
cl126162 force-pushed the stack-07-phase7-docstring-coverage branch from b64ca89 to 0f8f043 Compare September 7, 2026 10:15
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.

2 participants