Repository navigation
feat: add check_bare_feature_flags.py pre-commit validator [OMN-5573] - #79
Conversation
Cross-repo pre-commit hook that rejects bare os.getenv("ENABLE_*"),
os.environ.get/["ENABLE_*"], process.env.ENABLE_*, and *_ENABLED
suffix patterns. Lines with ONEX_FLAG_EXEMPT: <reason> are exempt;
exemptions without a reason token are themselves violations.
Approved basenames (feature_flag_resolver.py, contract.yaml,
check_bare_feature_flags.py, model_contract_feature_flag.py) and
path segments (/tests/, /capabilities/, /config_discovery/) are
never flagged.
- New script with entry point check-bare-feature-flags
- 21 unit tests covering all detection/exemption/approval cases
- Hook entry in .pre-commit-hooks.yaml (no-bare-feature-flags)
📝 WalkthroughWalkthroughThis pull request introduces a new pre-commit hook named Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/onex_change_control/scripts/check_bare_feature_flags.py (1)
71-74: Consider making_ScanResultpublic or documenting its semi-public status.
check_file_fullis a public function that returns_ScanResult, but the underscore prefix suggests it's a private type. This creates a minor API inconsistency. For a pre-commit hook with limited external consumers, this is acceptable, but consider renaming toScanResultif external callers are expected.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/onex_change_control/scripts/check_bare_feature_flags.py` around lines 71 - 74, The public function check_file_full returns a dataclass named _ScanResult whose leading underscore implies private scope; either make the type public by renaming _ScanResult to ScanResult or explicitly document its semi-public API surface. Locate the dataclass definition named _ScanResult and either change its identifier to ScanResult and update all references (e.g., return annotations and any instantiations in check_file_full) or add a module-level docstring/comment stating that _ScanResult is intentionally exported for callers of check_file_full, and update __all__ if present to include "_ScanResult" (or "ScanResult" if renamed).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/onex_change_control/scripts/check_bare_feature_flags.py`:
- Around line 71-74: The public function check_file_full returns a dataclass
named _ScanResult whose leading underscore implies private scope; either make
the type public by renaming _ScanResult to ScanResult or explicitly document its
semi-public API surface. Locate the dataclass definition named _ScanResult and
either change its identifier to ScanResult and update all references (e.g.,
return annotations and any instantiations in check_file_full) or add a
module-level docstring/comment stating that _ScanResult is intentionally
exported for callers of check_file_full, and update __all__ if present to
include "_ScanResult" (or "ScanResult" if renamed).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 249bc879-8c5a-447d-99fc-faa6e06f94c8
📒 Files selected for processing (4)
.pre-commit-hooks.yamlpyproject.tomlsrc/onex_change_control/scripts/check_bare_feature_flags.pytests/unit/scripts/test_check_bare_feature_flags.py
Adds contracts/OMN-10316.yaml (ModelTicketContract) and drift/dod_receipts/OMN-10316/ receipts required by the omnibase_infra Receipt Gate CI check. Evidence: - dod-001: pre-commit run --all-files PASSED in all 9 repo worktrees - dod-002: docs-validate / call CI check PASSED on omnibase_compat PR #79 (representative sample; all 9 PRs have auto-merge armed)
OMN-11497: - Update dod-product-pr-79 receipt to final SHA 763ed90 (mypy fix) - Update contract to reflect final SHA OMN-11502 (new): - Add contract for rich terminal display module (PR #80) - dod-product-pr-80: PR #80 head SHA 8f4827c - dod-unit-tests: full suite pass - dod-occ-self: self-binding to OCC PR #1312 Closes OMN-11497, OMN-11502
* docs(OMN-11497): bind ToolRegistry evidence — PR #79 receipts - contracts/OMN-11497.yaml: contract for in-process ToolRegistry ticket - drift/dod_receipts/OMN-11497/dod-product-pr-79: PR #79 head SHA db84543 - drift/dod_receipts/OMN-11497/dod-unit-tests: 12 tool registry tests pass, 616 total - drift/dod_receipts/OMN-11497/dod-occ-self: self-binding receipt Addresses CodeRabbit review: restricted exec globals + ThreadPoolExecutor timeout. Closes OMN-11497 * docs(OMN-11497): update self-binding receipt with OCC PR #1312 SHA * docs(OMN-11497,OMN-11502): update PR #79 receipt + add PR #80 evidence OMN-11497: - Update dod-product-pr-79 receipt to final SHA 763ed90 (mypy fix) - Update contract to reflect final SHA OMN-11502 (new): - Add contract for rich terminal display module (PR #80) - dod-product-pr-80: PR #80 head SHA 8f4827c - dod-unit-tests: full suite pass - dod-occ-self: self-binding to OCC PR #1312 Closes OMN-11497, OMN-11502 * docs(OMN-11497,OMN-11502): fix receipt schema validation errors - OMN-11497 dod-unit-tests: remove extra "12 passed: true" field (extra_forbidden) - OMN-11497 dod-unit-tests: update commit_sha to final SHA 763ed90 - OMN-11502 dod-unit-tests: add required probe_command + probe_stdout fields - OMN-11502 dod-occ-self: fix commit_sha (was "PENDING"), add probe_command + probe_stdout All 6 receipts validate against ModelDodReceipt schema. Closes OMN-11497, OMN-11502 * fix(OMN-11497,OMN-11502): add contract_sha256 to all receipts (OMN-10421 requirement) Receipts produced after 2026-04-30 must record the contract hash. Added sha256 fingerprint of OMN-11497.yaml and OMN-11502.yaml to all six dod_receipt files for these two tickets.
…e_control (OmniNode-ai#558) * feat(OMN-10316): wire docs-validate as required CI gate in onex_change_control Adds .github/workflows/docs-validate.yml caller to the reusable OmniNode-ai/omnibase_core/.github/workflows/validate-docs.yml@main workflow. Also adds .markdown-link-check.json with omni_worktrees/** exclusion (OMN-9607 pattern) so the gate does not scan nested worktree checkouts. dod_evidence: - pre-commit run --all-files: PASSED - workflow file: .github/workflows/docs-validate.yml - link-check config: .markdown-link-check.json * feat(OMN-10316): add ticket contract and DoD receipts for gate wiring Adds contracts/OMN-10316.yaml (ModelTicketContract) and drift/dod_receipts/OMN-10316/ receipts required by the omnibase_infra Receipt Gate CI check. Evidence: - dod-001: pre-commit run --all-files PASSED in all 9 repo worktrees - dod-002: docs-validate / call CI check PASSED on omnibase_compat PR OmniNode-ai#79 (representative sample; all 9 PRs have auto-merge armed) * fix(OMN-10316): remove paths filter so required check runs on every PR * fix(OMN-10316): use file_exists checks to avoid CI shell timeout/pipe issues
Summary
no-bare-feature-flags) that rejects bareos.getenv("ENABLE_*"),os.environ.get/["ENABLE_*"],process.env.ENABLE_*, and*_ENABLEDsuffix env var reads# ONEX_FLAG_EXEMPT: <reason>are exempt; exemptions without a reason token are themselves violationsfeature_flag_resolver.py,contract.yaml,check_bare_feature_flags.py,model_contract_feature_flag.py) and path segments (/tests/,/capabilities/,/config_discovery/) are never flaggedTest plan
uv run pytest tests/unit/scripts/test_check_bare_feature_flags.py -v)pre-commit run --all-filespassespyproject.toml.pre-commit-hooks.yamlCloses OMN-5573
Summary by CodeRabbit
New Features
Chores