Skip to content

refactor: issue #111 remaining cleanups — loader fan-out, read-lines helper, dead code, __main__ guard, copier portability - #148

Merged
Anthony Johnson II (AJ-EthereaLogic-ai) merged 1 commit into
mainfrom
adws/job_20260720_0001/refactor-cleanup
Jul 20, 2026
Merged

refactor: issue #111 remaining cleanups — loader fan-out, read-lines helper, dead code, __main__ guard, copier portability#148
Anthony Johnson II (AJ-EthereaLogic-ai) merged 1 commit into
mainfrom
adws/job_20260720_0001/refactor-cleanup

Conversation

@AJ-EthereaLogic-ai

@AJ-EthereaLogic-ai Anthony Johnson II (AJ-EthereaLogic-ai) commented Jul 20, 2026

Copy link
Copy Markdown
Member

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 main by the #110 fix (PR #132) — verified, not re-touched.

Items

  • Phase 2 — navigation layer (Layer 1) #3 Loader fan-outcheck-governance.sh collapses four --list-* governance-loader subprocesses into one --emit required_files,required_agents,required_skills,optional_dirs; marker-scan.sh collapses two into one. ~6→2 interpreter starts per make validate.
  • docs(scaffold): add Phase 12–15 planning materials and ignore .vscode #4 Shared read-lines helper + jq collapse — new read_lines_into_array in scripts/lib/common.sh, used by all five governance scripts; check-traceability.sh's per-criterion triple jq collapsed to one pass.
  • Land extension-build rails (Phases 12–15 planning) #5 Dead code — removed unused check_tool/check_file macros from Makefile.fragments/defs.mk; wired the previously parsed-but-unread --list flag in scripts/lib/governance.py to actually list (keeps query-governance.sh --list working); fixed the RECOMMENDED (4)(3) comment.
  • Phase 3 — Layer 4 runtime enforcement #6 __main__ guardscripts/governance_review/governance_review/__main__.py no longer runs the CLI / raises SystemExit on import; python -m governance_review still works.
  • Phase 4 — Layer 5 external validation #7 Copier portabilitycopier.yml _tasks deletions converted from POSIX rm/find to Windows-portable YAML-list python commands (shell=False); the .gitkeep sweep no longer traverses .git.

Robustness / correctness

  • The --emit and check-traceability.sh field-multiplexing preserve values containing embedded tabs and fail loudly on embedded newlines (no silent truncation/drop) at both sites.
  • macOS bash 3.2 hardening: empty read_lines_into_array results are expanded with the ${arr[@]+...} guard so check scripts don't abort under set -u on 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)

  • Template pytest failure-set parity with main (no new failures; +25 passing, 2 make-target tests skip on unrendered template source).
  • All 5 governance scripts byte-identical to baseline on a rendered scaffold under macOS /bin/bash 3.2, including empty-list cases.
  • TypeScript scaffold renders + npm test passes; 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

    • Improved project cleanup and generation on Windows and other environments without shell-specific deletion tools.
    • Validation checks now handle missing directories, special characters, and malformed data more reliably.
    • Corrected the governance recommendations count.
  • Refactor

    • Streamlined governance and validation workflows for more consistent results.
    • Removed obsolete build-tool checks.
  • Tests

    • Added broad regression coverage for cleanup, governance validation, command-line behavior, and traceability handling.

…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.
Copilot AI review requested due to automatic review settings July 20, 2026 02:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The job was not started because the account is locked due to a billing issue.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 009853a9-9680-4744-ad84-5cc9d7234ce1

📥 Commits

Reviewing files that changed from the base of the PR and between 85450f0 and 9efc6ec.

📒 Files selected for processing (16)
  • copier.yml
  • {{cookiecutter.project_slug}}/Makefile.fragments/defs.mk
  • {{cookiecutter.project_slug}}/governance-rules.yaml
  • {{cookiecutter.project_slug}}/scripts/check-action-pins.sh
  • {{cookiecutter.project_slug}}/scripts/check-doc-drift.sh
  • {{cookiecutter.project_slug}}/scripts/check-governance.sh
  • {{cookiecutter.project_slug}}/scripts/check-traceability.sh
  • {{cookiecutter.project_slug}}/scripts/governance_review/governance_review/__main__.py
  • {{cookiecutter.project_slug}}/scripts/lib/common.sh
  • {{cookiecutter.project_slug}}/scripts/lib/governance.py
  • {{cookiecutter.project_slug}}/scripts/marker-scan.sh
  • {{cookiecutter.project_slug}}/tests/test_common_lib.py
  • {{cookiecutter.project_slug}}/tests/test_governance_cleanup.py
  • {{cookiecutter.project_slug}}/tests/test_governance_loader.py
  • {{cookiecutter.project_slug}}/tests/test_governance_review.py
  • {{cookiecutter.project_slug}}/tests/test_validation_scripts.py
💤 Files with no reviewable changes (1)
  • {{cookiecutter.project_slug}}/Makefile.fragments/defs.mk

📝 Walkthrough

Walkthrough

The 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.

Changes

Template portability

Layer / File(s) Summary
Portable pruning tasks
copier.yml
Language, integration, release, promptfoo, and placeholder cleanup now use inline Python filesystem operations instead of POSIX-only deletion commands.

Governance data flow

Layer / File(s) Summary
Governance emission protocol
scripts/lib/governance.py, scripts/lib/common.sh, tests/test_common_lib.py, tests/test_governance_loader.py
The loader emits multiple tab-delimited sections in one invocation, validates values, centralizes directive listing, and supports shared newline-safe array parsing with CLI coverage.
Validation script integration
scripts/check-governance.sh, scripts/marker-scan.sh, scripts/check-traceability.sh, scripts/check-doc-drift.sh, scripts/check-action-pins.sh, tests/test_validation_scripts.py
Validation scripts use consolidated loader output, shared line parsing, guarded failures, and single-pass traceability demultiplexing while preserving delimiter regression coverage.

Cleanup regression coverage

Layer / File(s) Summary
Dead-code and entrypoint cleanup
{{cookiecutter.project_slug}}/Makefile.fragments/defs.mk, {{cookiecutter.project_slug}}/governance-rules.yaml, {{cookiecutter.project_slug}}/scripts/governance_review/governance_review/__main__.py, tests/test_governance_cleanup.py, tests/test_governance_review.py
Unused Makefile macros are removed, the recommended-rule count is corrected, CLI execution is guarded, and cleanup plus import/runtime behavior are tested.

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
Loading

Possibly related PRs

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is specific and accurately summarizes the main cleanup and refactor work in the PR.
Linked Issues check ✅ Passed The PR implements the linked cleanup items: loader fan-out reduction, shared line reader, dead-code removal, main guard, and portable Copier pruning.
Out of Scope Changes check ✅ Passed The changes stay within the linked cleanup scope and do not introduce obvious unrelated work.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch adws/job_20260720_0001/refactor-cleanup

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 82 high · 6 medium

Alerts:
⚠ 88 issues (≤ 0 issues of at least minor severity)

Results:
88 new issues

Category Results
ErrorProne 4 medium
9 high
Security 73 high
Complexity 2 medium

View in Codacy

🟢 Metrics 64 complexity · 0 duplication

Metric Results
Complexity 64
Duplication 0

View in Codacy

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.

@AJ-EthereaLogic-ai
Anthony Johnson II (AJ-EthereaLogic-ai) merged commit 28df24b into main Jul 20, 2026
4 of 36 checks passed
@AJ-EthereaLogic-ai
Anthony Johnson II (AJ-EthereaLogic-ai) deleted the adws/job_20260720_0001/refactor-cleanup branch July 20, 2026 02:29
Anthony Johnson II (AJ-EthereaLogic-ai) added a commit that referenced this pull request Jul 20, 2026
…e sync) (#149)

Record issue #111's five remaining cleanups (PR #148): July fixes-table row, current-state refresh (follow-on queue now #144 only), and a provenance entry noting the two Critic-caught RETRYs and the macOS bash-3.2 regression the Linux/bash-5 pipeline can't see.
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.

Refactoring & optimization: coverage theater, triplicated prune logic, loader fan-out, dead code

3 participants