refactor: issue #111 remaining cleanups — loader fan-out, read-lines helper, dead code, __main__ guard, copier portability - #148
Conversation
…helper, dead code, __main__ guard, copier portability (tsk_20260720_0001) - #3: consolidate the governance-loader fan-out so check-governance.sh and marker-scan.sh each start the loader at most once (governance.py --emit). - #4: add read_lines_into_array to scripts/lib/common.sh, use it in the five governance scripts, and collapse check-traceability.sh's per-criterion triple jq to a single pass. - ROBUSTNESS: harden the key⇥tab⇥value multiplexing at both sites (governance.py --emit and check-traceability.sh's single-jq-pass demux) so a tab-containing value is preserved end-to-end and a newline-containing value causes a loud non-zero-exit error instead of being silently dropped. - #5: remove the unused check_tool/check_file macros from Makefile.fragments/defs.mk; wire governance.py's --list argument to actually list all directives (query-governance.sh --list stays byte-identical to baseline); fix governance-rules.yaml's RECOMMENDED count comment to (3). - #6: guard governance_review/__main__.py with `if __name__ == "__main__"` so importing the module no longer executes main() or raises SystemExit; `python -m governance_review` is unaffected. - #7: make copier.yml's _tasks deletions Windows-portable (YAML-list command form / inline python instead of rm, rm -rf, find -delete) and stop the .gitkeep sweep from traversing .git. Items #1 and #2 of issue #111 were already resolved on main by the #110 fix (PR #132) and remain non-goals for this change. Refs #111 bash-3.2 hardening (macOS): guard empty read_lines_into_array array expansions with ${arr[@]+...} so check scripts don't abort under set -u on bash 3.2 when a governance/traceability list is empty; test harness made bash-3.2-safe and make-target tests skip on unrendered template source.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (16)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThe PR replaces shell-dependent template pruning, adds consolidated governance data emission and shared Bash parsing, refactors validation scripts to consume these protocols, removes unused Makefile helpers, guards Python CLI execution, and adds regression coverage for cleanup and delimiter handling. ChangesTemplate portability
Governance data flow
Cleanup regression coverage
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Script
participant GovernanceLoader
participant GovernanceRules
participant Awk
Script->>GovernanceLoader: request marker or enforcement sections
GovernanceLoader->>GovernanceRules: read configured values
GovernanceRules-->>GovernanceLoader: return values
GovernanceLoader-->>Script: emit section<TAB>value rows
Script->>Awk: demultiplex emitted rows
Awk-->>Script: preserve field values and arrays
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| ErrorProne | 4 medium 9 high |
| Security | 73 high |
| Complexity | 2 medium |
🟢 Metrics 64 complexity · 0 duplication
Metric Results Complexity 64 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
28df24b
into
main
Closes #111.
Resolves the five remaining items of the issue #111 cleanup epic. Items #1 (coverage theater) and #2 (triplicated-prune sync test) were already resolved on
mainby the #110 fix (PR #132) — verified, not re-touched.Items
check-governance.shcollapses four--list-*governance-loader subprocesses into one--emit required_files,required_agents,required_skills,optional_dirs;marker-scan.shcollapses two into one. ~6→2 interpreter starts permake validate.read_lines_into_arrayinscripts/lib/common.sh, used by all five governance scripts;check-traceability.sh's per-criterion triplejqcollapsed to one pass.check_tool/check_filemacros fromMakefile.fragments/defs.mk; wired the previously parsed-but-unread--listflag inscripts/lib/governance.pyto actually list (keepsquery-governance.sh --listworking); fixed theRECOMMENDED (4)→(3)comment.__main__guard —scripts/governance_review/governance_review/__main__.pyno longer runs the CLI / raisesSystemExiton import;python -m governance_reviewstill works.copier.yml_tasksdeletions converted from POSIXrm/findto Windows-portable YAML-listpythoncommands (shell=False); the.gitkeepsweep no longer traverses.git.Robustness / correctness
--emitandcheck-traceability.shfield-multiplexing preserve values containing embedded tabs and fail loudly on embedded newlines (no silent truncation/drop) at both sites.read_lines_into_arrayresults are expanded with the${arr[@]+...}guard so check scripts don't abort underset -uon bash 3.2 when a governance/traceability list is legitimately empty (caught during local macOS validation; a Linux-only run misses it).Validation (GitHub Actions is billing-locked; gated on local validation)
main(no new failures; +25 passing, 2 make-target tests skip on unrendered template source)./bin/bash3.2, including empty-list cases.npm testpasses; shellcheck 0 findings; ruff/ty clean.Produced via the ADWS pipeline (job
job_20260720_0001, verdict PROMOTE — 7/7 gates, consensus 2 rounds clean, grader 6/6) plus an operator-completed bash-3.2 fix validated on macOS. Evidence tree:artifacts/job_20260720_0001/.Summary by CodeRabbit
Bug Fixes
Refactor
Tests