Skip to content

Add governance report pack with validator, tests, Makefile, pre-commit and CI workflow#65

Merged
OneFineStarstuff merged 2 commits into
mainfrom
codex/develop-ai-governance-frameworks-for-enterprises
Apr 27, 2026
Merged

Add governance report pack with validator, tests, Makefile, pre-commit and CI workflow#65
OneFineStarstuff merged 2 commits into
mainfrom
codex/develop-ai-governance-frameworks-for-enterprises

Conversation

@OneFineStarstuff

@OneFineStarstuff OneFineStarstuff commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Provide a machine-validated, multi-audience governance report pack (board, regulator, engineering, enterprise) and ensure report structure, index, and manifest integrity.
  • Enforce local and CI validation of report artifacts to prevent missing sections, manifest mismatches, or schema regressions.

Description

  • Add a set of governance reports under docs/reports/ plus a README_GOVERNANCE_REPORTS.md, a machine-readable governance_reports_manifest.json, and its JSON Schema at docs/schemas/governance_reports_manifest.schema.json.
  • Implement a validator tool tools/validate_governance_reports.py that checks required <title>, <abstract>, <content> wrappers, required section anchors per report, README index entries, manifest consistency, and schema requirements, and supports --json output.
  • Add unit tests tool_tests/test_validate_governance_reports.py covering file validation, README index checks, manifest and schema validations, and JSON output mode.
  • Introduce developer automation: Makefile targets (governance-test, governance-validate, governance-validate-json, governance-validate-json-check, governance-check), a local pre-commit hook config .pre-commit-config.yaml to run the validator on commit/push, and a GitHub Actions workflow .github/workflows/governance-reports.yml to run the full validation suite in CI.

Testing

  • Ran the unit test suite with python3 -m unittest discover tool_tests, which executed the validator tests and succeeded.
  • Executed the validator in JSON mode with python3 tools/validate_governance_reports.py --json, which returned a status: passed payload for the added reports.
  • Executed the full check via make governance-check (runs tests + validator + JSON status check), which completed successfully in local verification and is wired into the CI workflow for automated runs.

Codex Task

Summary by Sourcery

Introduce a machine-validated governance report pack with automated validation and CI integration.

New Features:

  • Add multi-audience governance report markdown documents and a governance reports README index.
  • Provide a governance reports manifest and JSON schema to describe and validate the report inventory.
  • Implement a governance report validator CLI that enforces structural tags, required section anchors, README index consistency, and manifest integrity with optional JSON output.

Enhancements:

  • Add Makefile targets and local pre-commit hooks to run governance report validation and tests as part of developer workflows.
  • Add a GitHub Actions workflow to run the governance validation suite, including tests and pre-commit hooks, on relevant changes in CI.

Tests:

  • Add unit tests for the governance report validator covering file structure checks, README index validation, manifest/schema validation, and JSON output mode.

@code-genius-code-coverage

Copy link
Copy Markdown

The files' contents are under analysis for test generation.

@semanticdiff-com

semanticdiff-com Bot commented Apr 27, 2026

Copy link
Copy Markdown

@vercel

vercel Bot commented Apr 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v0-one-fine-starstuff-github-io Ready Ready Preview, Comment, Open in v0 Apr 27, 2026 7:34am

@difflens

difflens Bot commented Apr 27, 2026

Copy link
Copy Markdown

View changes in DiffLens

@sourcery-ai

sourcery-ai Bot commented Apr 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a structured governance report pack with a machine-validated manifest, plus a Python validator wired into tests, Makefile targets, pre-commit, and a GitHub Actions workflow to enforce report integrity locally and in CI.

Sequence diagram for local and CI governance report validation

sequenceDiagram
    actor Developer
    participant Git as git
    participant PreCommit as pre_commit_hooks
    participant Make as make
    participant Validator as validate_governance_reports_py
    participant Tests as unittest_suite
    participant CI as github_actions

    Developer->>Git: git commit
    Git->>PreCommit: run pre-commit (pre-commit stage)
    PreCommit->>Make: make governance-validate
    Make->>Validator: python3 tools/validate_governance_reports.py
    Validator-->>Make: exit code (0/1)
    Make-->>PreCommit: propagate status
    PreCommit-->>Git: allow or block commit

    Developer->>Git: git push
    Git->>PreCommit: run pre-push hooks
    PreCommit->>Make: make governance-check
    Make->>Tests: python3 -m unittest discover tool_tests
    Tests-->>Make: test results
    Make->>Validator: python3 tools/validate_governance_reports.py
    Validator-->>Make: validation status
    Make->>Validator: python3 tools/validate_governance_reports.py --json
    Validator-->>Make: JSON payload {status, counts}
    Make-->>PreCommit: propagate status
    PreCommit-->>Git: allow or block push

    Developer->>CI: open PR / push
    CI->>CI: Governance Reports Validation workflow
    CI->>PreCommit: pre-commit run --all-files
    PreCommit->>Make: make governance-validate (pre-commit stage)
    Make->>Validator: validate_governance_reports.py
    Validator-->>Make: status
    Make-->>PreCommit: status
    PreCommit-->>CI: status
    CI->>Make: make governance-check
    Make->>Tests: run tool_tests
    Tests-->>Make: results
    Make->>Validator: validate_governance_reports.py (CLI + JSON check)
    Validator-->>Make: status
    Make-->>CI: final status
Loading

Flow diagram for validate_governance_reports.py logic

flowchart TD
    Start([start]) --> ParseArgs[parse_arguments]
    ParseArgs --> CollectErrors[collect_validation_errors]

    subgraph collect_validation_errors
        CE1[for_each_report_in_REPORT_RULES]
        CE1 --> VF[validate_file]
        VF --> CE2[accumulate_errors_and_count]
        CE2 --> VR[validate_readme_index]
        VR --> VM[validate_manifest]
        VM --> VMS[validate_manifest_schema]
    end

    CollectErrors --> HasErrors{all_errors_empty?}

    HasErrors -- no --> HandleFail[prepare_failure_output]
    HandleFail --> FailJson{--json_flag?}
    FailJson -- yes --> PrintFailJson[print JSON status:failed,error_count,errors]
    FailJson -- no --> PrintFailText[print_human_readable_errors]
    PrintFailJson --> ExitFail[exit_code_1]
    PrintFailText --> ExitFail

    HasErrors -- yes --> HandleSuccess[prepare_success_output]
    HandleSuccess --> SuccJson{--json_flag?}
    SuccJson -- yes --> PrintSuccJson[print JSON status:passed,counts]
    SuccJson -- no --> PrintSuccText[print summary line]
    PrintSuccJson --> ExitOK[exit_code_0]
    PrintSuccText --> ExitOK

    subgraph validate_file
        VFCheck1[check_required_tags]
        VFCheck2[check_single_title_abstract_content_blocks]
        VFCheck3[check_title_non_empty_len>=10]
        VFCheck4[check_required_headings_present]
    end

    subgraph validate_manifest
        VMRead[read_manifest_JSON]
        VMSchema[maybe_read_schema_root_and_item_required_sets]
        VMFields[check_root_fields_version_report_pack_reports]
        VMReportsIter[iterate_reports_list]
        VMReportChecks[check_path_audience_required_types_and_existence]
        VMConsistency[check_manifest_vs_expected_report_paths]
    end

    subgraph validate_manifest_schema
        SMRead[read_schema_JSON]
        SMRootReq[check_root_required_has_version_report_pack_reports]
        SMProps[check_reports_properties_items_required_path_audience_required]
    end
Loading

File-Level Changes

Change Details Files
Introduce multi-audience governance report pack with required structural wrappers and section anchors.
  • Add institutional governance reference report with <title>// wrappers and anchored sections for scope, regulatory alignment, architecture, AGI/ASI containment, and roadmap.
  • Add board-focused brief, regulator exam pack template, and engineering implementation playbook, each with required headings enforced by the validator.
  • Document the pack, validation commands, and optional git hooks in a governance reports README, including JSON-mode validation and Makefile-based workflows.
docs/reports/INSTITUTIONAL_GRADE_AGI_ASI_GOVERNANCE_2026_2030.md
docs/reports/BOARD_BRIEF_AGI_ASI_GOVERNANCE_2026_2030.md
docs/reports/REGULATOR_EXAM_PACK_AI_GOVERNANCE_2026_2030.md
docs/reports/ENGINEERING_IMPLEMENTATION_PLAYBOOK_AI_GOVERNANCE_2026_2030.md
docs/reports/README_GOVERNANCE_REPORTS.md
docs/reports/governance_reports_manifest.json
docs/schemas/governance_reports_manifest.schema.json
Add a Python validator that enforces report structure, README index consistency, and manifest/schema integrity, with JSON output support.
  • Implement validate_file to enforce presence and uniqueness of <title>// blocks, minimal title length, and report-specific required headings.
  • Implement validate_readme_index to ensure the README lists all governed reports plus manifest, schema, and required validation commands.
  • Implement validate_manifest and validate_manifest_schema to check manifest metadata, per-report fields, path existence, one-to-one mapping to report files, and required fields defined in the JSON Schema.
  • Add collect_validation_errors and a CLI main that aggregates all checks and optionally emits machine-readable JSON with pass/fail status and counts.
tools/validate_governance_reports.py
Add unit tests for validator behavior and CLI JSON mode.
  • Cover happy-path validation of report files with required headings and error cases for missing tags, missing headings, duplicate wrappers, and missing files.
  • Test README index validation for presence/absence of reports, manifest, schema, and validation commands.
  • Test manifest validation for missing or unexpected report entries, nonexistent paths, missing metadata, and schema-enforced required fields.
  • Test manifest schema validation logic and the CLI --json mode for a passing status payload.
  • Verify collect_validation_errors returns the expected types.
tool_tests/test_validate_governance_reports.py
Wire governance validation into developer workflows via Makefile, pre-commit, and GitHub Actions CI.
  • Add Makefile targets to run validator tests, structural validation, JSON-mode validation, and a composite governance-check that chains them.
  • Configure a local pre-commit hook to run governance-validate on pre-commit and governance-check on pre-push.
  • Add a GitHub Actions workflow that triggers on changes to reports, schema, validator, tests, Makefile, pre-commit config, or workflow file, running pre-commit and the governance-check target on Python 3.11 with cached environments.
Makefile
.pre-commit-config.yaml
.github/workflows/governance-reports.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gitnotebooks

gitnotebooks Bot commented Apr 27, 2026

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@OneFineStarstuff has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 48 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 924a07ce-baef-4530-a7ee-132095577897

📥 Commits

Reviewing files that changed from the base of the PR and between 9063c12 and 98699fe.

📒 Files selected for processing (12)
  • .github/workflows/governance-reports.yml
  • .pre-commit-config.yaml
  • Makefile
  • docs/reports/BOARD_BRIEF_AGI_ASI_GOVERNANCE_2026_2030.md
  • docs/reports/ENGINEERING_IMPLEMENTATION_PLAYBOOK_AI_GOVERNANCE_2026_2030.md
  • docs/reports/INSTITUTIONAL_GRADE_AGI_ASI_GOVERNANCE_2026_2030.md
  • docs/reports/README_GOVERNANCE_REPORTS.md
  • docs/reports/REGULATOR_EXAM_PACK_AI_GOVERNANCE_2026_2030.md
  • docs/reports/governance_reports_manifest.json
  • docs/schemas/governance_reports_manifest.schema.json
  • tool_tests/test_validate_governance_reports.py
  • tools/validate_governance_reports.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/develop-ai-governance-frameworks-for-enterprises

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 and usage tips.

@difflens

difflens Bot commented Apr 27, 2026

Copy link
Copy Markdown

View changes in DiffLens

@penify-dev

penify-dev Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@codacy-production

codacy-production Bot commented Apr 27, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 15 high · 18 medium · 67 minor

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

Results:
100 new issues

Category Results
Compatibility 14 medium
Documentation 37 minor
ErrorProne 15 high
CodeStyle 30 minor
Complexity 4 medium

View in Codacy

🟢 Metrics 117 complexity · 2 duplication

Metric Results
Complexity 117
Duplication 2

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.

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 1 security issue, 4 other issues, and left some high level feedback:

Security issues:

  • Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)

General comments:

  • The governance-validate-json-check Makefile target hardcodes /tmp as the output directory, which can be brittle on non-POSIX environments; consider using tempfile (or at least ${TMPDIR}) via a small Python helper to make the check portable.
  • The validate_file logic relies on simple substring counting for tags and headings, which can be tripped by commented-out sections or duplicated headings; you might want to tighten this by parsing the wrappers and headings more structurally (e.g., regex over specific regions) to reduce false positives as the documents evolve.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `governance-validate-json-check` Makefile target hardcodes `/tmp` as the output directory, which can be brittle on non-POSIX environments; consider using `tempfile` (or at least `${TMPDIR}`) via a small Python helper to make the check portable.
- The `validate_file` logic relies on simple substring counting for tags and headings, which can be tripped by commented-out sections or duplicated headings; you might want to tighten this by parsing the wrappers and headings more structurally (e.g., regex over specific regions) to reduce false positives as the documents evolve.

## Individual Comments

### Comment 1
<location path="tools/validate_governance_reports.py" line_range="149-151" />
<code_context>
+    if "report_pack" in root_required and (not isinstance(report_pack, str) or not report_pack.strip()):
+        errors.append(f"{path}: 'report_pack' must be a non-empty string")
+
+    reports = data.get("reports")
+    if not isinstance(reports, list):
+        return [f"{path}: 'reports' must be a list"]
+
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Returning immediately on non-list `reports` discards earlier manifest errors

This early return drops any errors already collected (e.g., missing fields, invalid `version`/`report_pack`, schema errors). Instead of returning a new single-item list, append this message to `errors` and return `errors`, so callers see the complete set of issues.

```suggestion
    report_pack = data.get("report_pack")
    if "report_pack" in root_required and (not isinstance(report_pack, str) or not report_pack.strip()):
        errors.append(f"{path}: 'report_pack' must be a non-empty string")

    reports = data.get("reports")
    if not isinstance(reports, list):
        errors.append(f"{path}: 'reports' must be a list")
        return errors
```
</issue_to_address>

### Comment 2
<location path="tool_tests/test_validate_governance_reports.py" line_range="245" />
<code_context>
+            self.assertTrue(any("'version' must be a non-empty string" in e for e in errors))
+            self.assertTrue(any("'report_pack' must be a non-empty string" in e for e in errors))
+
+    def test_validate_manifest_schema_accepts_valid_schema(self):
+        with tempfile.TemporaryDirectory() as tmpdir:
+            path = Path(tmpdir) / "schema.json"
</code_context>
<issue_to_address>
**suggestion (testing):** Extend validate_manifest_schema tests to cover malformed schema structures and type errors

Right now we only cover a valid schema and missing required fields, but `validate_manifest_schema` has several other guard paths that go untested: invalid/non-JSON input, non-dict root, non-list `required`, non-dict `properties`, missing or non-dict `reports`, non-dict `items`, and non-list `items.required`. Please add a few minimal tests that exercise each of these malformed-schema cases so those branches are covered and remain stable as the schema structure evolves.

Suggested implementation:

```python
    def test_validate_manifest_schema_accepts_valid_schema(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            path = Path(tmpdir) / "schema.json"
            path.write_text(
                """
{
  "required": ["version", "report_pack", "reports"],
  "properties": {
    "reports": {
      "items": {
        "required": ["path", "audience", "required"]
      }
    }
  }
}
                """
            )
            errors = validate_manifest_schema(path)
            self.assertEqual(errors, [])

    def test_validate_manifest_schema_rejects_invalid_json(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            path = Path(tmpdir) / "schema.json"
            # Intentionally invalid JSON
            path.write_text("{ this is not valid json }")
            errors = validate_manifest_schema(path)
            self.assertTrue(errors)
            self.assertTrue(
                any("invalid JSON" in e or "JSON" in e for e in errors),
                msg=f"Expected an invalid JSON error, got: {errors}",
            )

    def test_validate_manifest_schema_rejects_non_dict_root(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            path = Path(tmpdir) / "schema.json"
            path.write_text("[]")
            errors = validate_manifest_schema(path)
            self.assertTrue(errors)
            self.assertTrue(
                any("root" in e and "object" in e for e in errors),
                msg=f"Expected a non-dict root error, got: {errors}",
            )

    def test_validate_manifest_schema_rejects_non_list_required(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            path = Path(tmpdir) / "schema.json"
            path.write_text(
                """
{
  "required": "version",
  "properties": {}
}
                """
            )
            errors = validate_manifest_schema(path)
            self.assertTrue(errors)
            self.assertTrue(
                any("'required' must be a list" in e for e in errors),
                msg=f"Expected 'required' must be a list error, got: {errors}",
            )

    def test_validate_manifest_schema_rejects_non_dict_properties(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            path = Path(tmpdir) / "schema.json"
            path.write_text(
                """
{
  "required": ["version"],
  "properties": []
}
                """
            )
            errors = validate_manifest_schema(path)
            self.assertTrue(errors)
            self.assertTrue(
                any("'properties' must be an object" in e or "'properties' must be a dict" in e for e in errors),
                msg=f"Expected 'properties' must be a dict error, got: {errors}",
            )

    def test_validate_manifest_schema_rejects_missing_reports_property(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            path = Path(tmpdir) / "schema.json"
            path.write_text(
                """
{
  "required": ["version", "report_pack", "reports"],
  "properties": {}
}
                """
            )
            errors = validate_manifest_schema(path)
            self.assertTrue(errors)
            self.assertTrue(
                any("'reports' property" in e or "reports" in e for e in errors),
                msg=f"Expected missing 'reports' property error, got: {errors}",
            )

    def test_validate_manifest_schema_rejects_non_dict_reports_property(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            path = Path(tmpdir) / "schema.json"
            path.write_text(
                """
{
  "required": ["version", "report_pack", "reports"],
  "properties": {
    "reports": []
  }
}
                """
            )
            errors = validate_manifest_schema(path)
            self.assertTrue(errors)
            self.assertTrue(
                any("'reports' must be an object" in e or "'reports' must be a dict" in e for e in errors),
                msg=f"Expected 'reports' must be a dict error, got: {errors}",
            )

    def test_validate_manifest_schema_rejects_non_dict_items(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            path = Path(tmpdir) / "schema.json"
            path.write_text(
                """
{
  "required": ["version", "report_pack", "reports"],
  "properties": {
    "reports": {
      "items": []
    }
  }
}
                """
            )
            errors = validate_manifest_schema(path)
            self.assertTrue(errors)
            self.assertTrue(
                any("'items' must be an object" in e or "'items' must be a dict" in e for e in errors),
                msg=f"Expected 'items' must be a dict error, got: {errors}",
            )

    def test_validate_manifest_schema_rejects_non_list_items_required(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            path = Path(tmpdir) / "schema.json"
            path.write_text(
                """
{
  "required": ["version", "report_pack", "reports"],
  "properties": {
    "reports": {
      "items": {
        "required": "path"
      }
    }
  }
}
                """
            )
            errors = validate_manifest_schema(path)
            self.assertTrue(errors)
            self.assertTrue(
                any("'items.required' must be a list" in e or "items.required" in e for e in errors),
                msg=f"Expected 'items.required' must be a list error, got: {errors}",
            )

```

These tests assume `validate_manifest_schema(path)`:
1. Returns a list of human-readable error strings instead of raising exceptions.
2. Uses messages containing phrases like:
   - "invalid JSON" for JSON parse errors
   - "'required' must be a list"
   - "'properties' must be an object" / "dict"
   - "'reports' must be an object" / "dict"
   - "'items' must be an object" / "dict"
   - "'items.required' must be a list" or similar.

If the actual error messages differ, update the `any(... in e ...)` predicates to match the real strings (you can run the tests and adjust to the exact wording emitted by `validate_manifest_schema`). The structural aspects of the tests (what kind of malformed schema they feed in) should remain the same.
</issue_to_address>

### Comment 3
<location path="tool_tests/test_validate_governance_reports.py" line_range="94" />
<code_context>
+            self.assertEqual(len(errors), 1)
+            self.assertIn("missing file", errors[0])
+
+    def test_validate_readme_index_accepts_valid_readme(self):
+        with tempfile.TemporaryDirectory() as tmpdir:
+            path = Path(tmpdir) / "README_GOVERNANCE_REPORTS.md"
</code_context>
<issue_to_address>
**suggestion (testing):** Add a test for validate_readme_index when the README is missing

Please add a test that calls `validate_readme_index` with a non-existent README path and asserts that the `missing file: ...` error is returned. This will cover the missing-file branch and guard against regressions if the README is deleted or renamed.

Suggested implementation:

```python
    def test_validate_file_rejects_missing_file(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            missing = Path(tmpdir) / "missing.md"
            errors = validate_file(missing, [])
            self.assertEqual(len(errors), 1)
            self.assertIn("missing file", errors[0])

    def test_validate_readme_index_rejects_missing_readme(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            missing_readme = Path(tmpdir) / "README_GOVERNANCE_REPORTS.md"
            errors = validate_readme_index(missing_readme)
            self.assertEqual(len(errors), 1)
            self.assertIn("missing file", errors[0])

    def test_validate_readme_index_accepts_valid_readme(self):

```

If `validate_readme_index` is not already imported into this test module, add it to the relevant import statement (likely alongside `validate_file`) at the top of `tool_tests/test_validate_governance_reports.py`.
</issue_to_address>

### Comment 4
<location path="tool_tests/test_validate_governance_reports.py" line_range="35" />
<code_context>
+
+
+class ValidateGovernanceReportsTests(unittest.TestCase):
+    def test_validate_file_accepts_valid_document(self):
+        with tempfile.TemporaryDirectory() as tmpdir:
+            path = Path(tmpdir) / "doc.md"
</code_context>
<issue_to_address>
**suggestion (testing):** Consider adding tests for title-length validation and other validate_file failure modes

Current `validate_file` tests cover missing tags, duplicate blocks, missing headings, and missing files, but they don’t exercise the title-length branch (`title is empty or too short`). Please add a test that writes a document with a `<title>` block containing an empty or very short string and asserts the `title is empty or too short` error. If straightforward, also add a case where all required tags are present but counts don’t match (e.g., two `<title>` and one `</title>`) to verify the "expected exactly one ..." errors are raised.
</issue_to_address>

### Comment 5
<location path="tool_tests/test_validate_governance_reports.py" line_range="334-339" />
<code_context>
        result = subprocess.run(
            [sys.executable, "tools/validate_governance_reports.py", "--json"],
            check=True,
            capture_output=True,
            text=True,
        )
</code_context>
<issue_to_address>
**security (python.lang.security.audit.dangerous-subprocess-use-audit):** Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

*Source: opengrep*
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread tools/validate_governance_reports.py
Comment thread tool_tests/test_validate_governance_reports.py
Comment thread tool_tests/test_validate_governance_reports.py
Comment thread tool_tests/test_validate_governance_reports.py
Comment thread tool_tests/test_validate_governance_reports.py
@netlify

netlify Bot commented Apr 27, 2026

Copy link
Copy Markdown

Deploy Preview for onefinestarstuff failed.

Name Link
🔨 Latest commit 98699fe
🔍 Latest deploy log https://app.netlify.com/projects/onefinestarstuff/deploys/69ef116472ad2b000817885e

…nterprises

Signed-off-by: 𝐎𝐧𝐞 𝐅𝐢𝐧𝐞 𝐒𝐭𝐚𝐫𝐬𝐭𝐮𝐟𝐟 <onefinestarstuff@gmail.com>
@difflens

difflens Bot commented Apr 27, 2026

Copy link
Copy Markdown

View changes in DiffLens

@OneFineStarstuff OneFineStarstuff merged commit 917dde1 into main Apr 27, 2026
29 of 93 checks passed
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.

3 participants