Refactor: structured INPUT parameter availability (Phase 1) - #7783
Open
Stardust0831 wants to merge 2 commits into
Open
Refactor: structured INPUT parameter availability (Phase 1)#7783Stardust0831 wants to merge 2 commits into
Stardust0831 wants to merge 2 commits into
Conversation
The Input_Item availability field mixes prose and ad-hoc conditions as free text, which cannot be consumed programmatically for tree-structured docs, validation or agent tooling. Add a small dependency-free parser (tools/03_code_analysis/availability_parser.py) that normalises the historical spellings (==, =, 'is set to', 'contains') onto a canonical form and classifies each value as an Expression, a bare Label, or Unstructured prose waiting for review. - availability_parser.py: parse_availability() -> Availability - test_availability_parser.py: unit tests - generate_input_main.py: add --check-availability to report the Expression/Label/Unstructured distribution without changing the generated markdown. On the current docs/parameters.yaml this classifies 217 non-empty values as 82 Expression / 84 Label / 51 Unstructured.
Make the Input_Item availability field a concrete, machine-readable boolean
condition (single source of truth) so the INPUT docs, validation and tooling
can consume the actual condition instead of free text or bare tags.
- Add AvailabilityKind/AvailabilityCondition/AvailabilityExpr and
parse_availability() in a new module (availability.{h,cpp}, wired into CMake).
- Input_Item now carries availability_kind + availability_expr and a
set_availability() helper that keeps the canonical string and the structured
form in sync (single source of truth).
- Rewrite all 217 non-empty availability registrations to canonical boolean
syntax; the exported YAML classifies them as 216 Expression / 0 Unstructured.
- Export the structured fields from --generate-parameters-yaml (input_help.cpp).
- Consume the structured fields in generate_input_main.py; extend
availability_parser.py to the canonical grammar and cover it with tests.
- Regenerate docs/parameters.yaml and input-main.md.
Former bare "label"-style tags (e.g. "OFDFT", "Numerical atomic orbital basis")
are now expressed as concrete conditions (esolver_type==ofdft, basis_type==lcao,
...) so they can be evaluated by validation/error tooling. mixing_tau has no hard
gate, so its availability is empty (always available); its meta-GGA relevance is
kept in the description.
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.
Reminder
AGENTS.mdanddocs/developers_guide/agent_governance.md.source/changes.Linked Issue
Ref #7719 — normalize INPUT
availabilityinto a machine-readable form and align it with parameter validation.Unit Tests and/or Case Tests for my changes
python3 tools/03_code_analysis/test_availability_parser.py— 17 tests, all pass (incl. precedence forand/or/parentheses,containssemantics, and a validation that every non-emptyavailabilityindocs/parameters.yamlparses asExpression).source/source_io/test_serial/availability_test.cppwired into the test build (BUILD_TESTING=ON); covers leaf/in-set/contains/and-or nesting/round-trip/empty/string-end edge inputs.abacus --generate-parameters-yaml— COMPLETED; regenerateddocs/parameters.yamlandinput-main.md(generated output byte-consistent with the checked-in docs).docs/parameters.yamlhas 526 params / 216 non-emptyavailability, all concrete booleanExpression(0Label/ 0Unstructured).What's changed?
Make the
Input_Itemavailabilityfield a single-source, machine-evaluable boolean condition so the INPUT docs, validation and tooling can consume and evaluate it instead of re-parsing free text or bare tags.source/source_io/module_parameter/availability.{h,cpp}(wired into CMake) withAvailabilityCondition/AvailabilityExprandparse_availability()(operators==/!=/>/>=/</<=/in/contains, combinatorsand/or/,,(...)grouping).Input_Itemkeeps the canonicalavailabilitystring plusavailability_expr(parsed tree) and aset_availability()helper keeping both in sync (single source of truth).OFDFT,Numerical atomic orbital basis, ...) are now concrete conditions over existing parameters (esolver_type==ofdft,basis_type==lcao,calculation==gen_bessel,dft_plus_u==1, ...). Vector parameters usecontains(e.g.td_ttype contains 2) to preserve containment semantics.--generate-parameters-yamlnow emits the canonicalavailabilitystring (empty string = always available) and nothing else, keeping the YAML lean; the structured parse tree stays in C++ for a future validation/error layer.docs/parameters.yamlandinput-main.md.Manual fidelity: rewrites preserve the manual's original meaning. Where the manual states a gate the code does not enforce via an INPUT boolean, it is called out in Governance Notes.
Governance Notes
docs/parameters.yamlanddocs/advanced/input_files/input-main.mdregenerated from the new binary (per AGENTS.md). Full old→new mapping was reviewed locally.source/source_io/module_parameter/input_item.hgains anavailability_exprmember and the newavailabilitymodule; metadata-only, no runtime/numerical behavior change.input_item.hincludesavailability.hbecauseInput_ItemholdsAvailabilityExprby value (a forward declaration is not possible);availability.hincludes<string>/<vector>for its members (std::string,std::vector). Required includes, not reducible to forward declarations.mixing_dmr: manual>= 0.0(always true) kept asmixing_restart>=0; esolver checks> 0— likely loose manual wording.mixing_tau: "Only relevant for meta-GGA" is a note decided at runtime (XC_Functional::get_ked_flag), not an INPUT gate; availability empty, note kept in description.fixed_ibrav: encoded asrelax_method in [cg 2] and latname != none(both manual clauses; the latter also enforced bycheck_value).