Skip to content

feat(ci,config): add comment coverage gate for reference.conf#6810

Open
bladehan1 wants to merge 2 commits into
tronprotocol:release_v4.8.2from
bladehan1:feat/ci_reference_comment
Open

feat(ci,config): add comment coverage gate for reference.conf#6810
bladehan1 wants to merge 2 commits into
tronprotocol:release_v4.8.2from
bladehan1:feat/ci_reference_comment

Conversation

@bladehan1
Copy link
Copy Markdown
Collaborator

@bladehan1 bladehan1 commented Jun 2, 2026

What does this PR do?

Adds a comment-coverage CI gate for reference.conf and annotates all previously undocumented configuration keys.

Changes

  1. .github/scripts/check_reference_comments.py (new, 358 lines, zero runtime dependencies)

    • Line-oriented Python 3 scanner — pyhocon is intentionally avoided because it discards comments.
    • Enforces that every key carries either an inline (# / //) comment or a non-blank comment on the immediately preceding line.
    • Array-element keys are deduplicated: only the first occurrence in a homogeneous array is checked (handles rate.limiter entries).
    • --list flag prints every key with its status (commented / dedup / missing) for local debugging.
    • On failure: human-readable violation list + GHA ::error annotations with line N: key.
    • Docstring documents known HOCON edge-case limitations (quoted keys, +=, triple-quoted strings, bare URLs) and explains why each is low-risk for reference.conf.
  2. .github/workflows/pr-check.yml (+6 lines)

    • New step runs immediately after the existing check_reference_conf.py (key-format / depth / port-uniqueness) gate.
    • Any non-zero exit code fails the step and blocks the job; no continue-on-error.
  3. common/src/main/resources/reference.conf

    • All previously undocumented keys now carry inline comments. The committee block includes the /wallet/getchainparameters API key name and ProposalType ID for each governance parameter.

Why are these changes required?

reference.conf is the primary configuration reference for node operators. Before this change most keys had no explanation, forcing operators to read source code. There was no CI enforcement either, so new keys could be merged without documentation.

This PR has been tested by:

  • Manual Testing: python3 .github/scripts/check_reference_comments.py common/src/main/resources/reference.confOK (exit 0)
  • Manual Testing: python3 .github/scripts/check_reference_conf.py common/src/main/resources/reference.confOK: 290 keys, all lowerCamelCase, depth <= 5, service ports unique (exit 0)
  • Manual Testing: check_reference_comments.py --list output verified: 252 commented, 118 dedup, 0 missing
  • committee block comments cross-checked against live mainnet /wallet/getchainparameters API response and ProposalUtil.ProposalType enum in source — all 42 ProposalType IDs and API key names confirmed correct
  • Unit Tests: local test suite .helper/test_reference_conf/run.sh — 41/41 passed (14 comment-coverage fixtures + 17 key-format fixtures + real reference.conf smoke tests)

Extra details

  • HOCON comments (# / //) are fully transparent to Typesafe Config and pyhocon — no runtime behaviour is affected.
  • The gate is intentionally a basic coverage check, not a full HOCON parser. Constructs not used in reference.conf (quoted keys, +=, triple-quoted strings) are documented as known limitations in the script docstring.

Add check_reference_comments.py, a line-oriented Python script that
enforces every key in reference.conf carries an inline or immediately-
preceding comment. Wire it into pr-check.yml as a new CI step directly
after the existing key-format gate.

Annotate all previously undocumented keys in reference.conf with inline
# / // comments. The committee block now includes the
/wallet/getchainparameters API key name and ProposalType ID for each
governance parameter. genesis.block array elements (assets, witnesses)
carry field-level inline comments derived from the existing block
descriptions; there is no genesis.block exemption.
@bladehan1 bladehan1 changed the title ci: add comment coverage gate for reference.conf feat(ci,config): add comment coverage gate for reference.conf Jun 2, 2026
Copy link
Copy Markdown

@KingsDmusk KingsDmusk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants