Skip to content

chore(release): v0.43.2 — pre-commit review JSON + OpenSpec dogfood rules#462

Closed
djm81 wants to merge 1 commit intodevfrom
chore/pre-commit-review-json-openspec-v0432
Closed

chore(release): v0.43.2 — pre-commit review JSON + OpenSpec dogfood rules#462
djm81 wants to merge 1 commit intodevfrom
chore/pre-commit-review-json-openspec-v0432

Conversation

@djm81
Copy link
Copy Markdown
Collaborator

@djm81 djm81 commented Mar 29, 2026

Description

Release v0.43.2 with pre-commit dogfood code review improvements and OpenSpec task rules for .specfact/code-review.json.

Summary

  • Pre-commit: specfact-code-review-gate runs specfact code review run --json --out .specfact/code-review.json (structured ReviewReport JSON under gitignored .specfact/). Subprocess uses repo root as cwd.
  • Docs: docs/modules/code-review.md updated for JSON output and portable hook example.
  • OpenSpec: openspec/config.yaml — context + tasks rules require a fresh .specfact/code-review.json, re-run when stale, remediate all severities before PR unless excepted in the proposal.
  • Tests: test_pre_commit_code_review.py and test_code_review_module_docs.py aligned with the new CLI.

Fixes n/a (chore/release/process)

New Features n/a

Contract References: None (scripts, tests, docs, openspec config only).

Type of Change

Please check all that apply:

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔒 Contract enforcement (adding/updating @icontract decorators)
  • 🧪 Test enhancement (scenario tests, property-based tests)
  • 🔧 Refactoring (code improvement without functionality change)

Contract-First Testing Evidence

Required for all changes affecting CLI commands or public APIs:

Not applicable to public API surface; unit tests cover script behavior.

Contract Validation

  • Runtime contracts added/updated (@icontract decorators on public APIs)
  • Type checking enforced (@beartype decorators applied)
  • CrossHair exploration completed: hatch run contract-test-exploration
  • Contract violations reviewed and addressed

Test Execution

  • Contract validation: hatch run contract-test-contracts
  • Contract exploration: hatch run contract-test-exploration
  • Scenario tests: hatch run contract-test-scenarios
  • Full test suite: hatch run contract-test-full

Test Quality

  • CLI commands tested with typer test client
  • Edge cases covered with Hypothesis property tests
  • Error handling tested with invalid inputs
  • Rich console output verified manually or with snapshots

How Has This Been Tested?

Contract-First Approach: N/A for new public contracts; targeted pytest for pre-commit and docs.

Manual Testing

  • Tested CLI commands manually
  • Verified rich console output
  • Tested with different input scenarios
  • Checked error messages for clarity

Automated Testing

  • Targeted unit tests: hatch run pytest tests/unit/scripts/test_pre_commit_code_review.py tests/unit/scripts/test_code_review_module_docs.py -q
  • hatch run yaml-lint (openspec/config.yaml)

Test Environment

  • Python version: 3.12 (hatch default env)
  • OS: Linux

Checklist

  • My code follows the style guidelines (PEP 8, ruff format, isort)
  • I have performed a self-review of my code
  • I have added/updated contracts (@icontract, @beartype) — N/A
  • I have added/updated docstrings (Google style)
  • I have made corresponding changes to documentation
  • My changes generate no new warnings (basedpyright, ruff, pylint) for touched paths
  • Targeted tests pass locally
  • I have added tests that prove my fix/feature works
  • Any dependent changes have been merged — N/A

Quality Gates Status

Recommend full CI on merge; targeted checks run locally for this PR.

  • Type checking ✅ (hatch run type-check)
  • Linting ✅ (hatch run lint)
  • Contract validation ✅ (hatch run contract-test-contracts)
  • Contract exploration ✅ (hatch run contract-test-exploration)
  • Scenario tests ✅ (hatch run contract-test-scenarios)

Screenshots/Recordings (if applicable)

N/A

- Pre-commit gate writes ReviewReport JSON to .specfact/code-review.json
- openspec/config.yaml: require fresh review JSON and remediate findings
- Docs and unit tests updated

Made-with: Cursor
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Pre-commit code review now generates structured JSON reports saved to .specfact/code-review.json for IDE and Copilot integration, replacing score-only output.
  • Documentation

    • Updated code review documentation to reflect JSON reporting workflow and output file location.
  • Chores

    • Bumped version to 0.43.2.
    • Enhanced code review evidence requirements in project configuration.
    • Updated test expectations for new JSON report behavior.

Walkthrough

The PR updates the pre-commit code review gate workflow to generate JSON output instead of using score-only mode, bumps the package version to 0.43.2, and updates documentation and configuration to reflect this change.

Changes

Cohort / File(s) Summary
Version bumps
pyproject.toml, setup.py, src/__init__.py, src/specfact_cli/__init__.py
Updated package version from 0.43.1 to 0.43.2 across configuration and module metadata files.
Release documentation
CHANGELOG.md
Added changelog entry for version 0.43.2 documenting the pre-commit workflow update to use JSON output instead of score-only mode.
Code review documentation
docs/modules/code-review.md
Updated documented CLI invocation from --score-only to --json --out .specfact/code-review.json, clarifying that the generated JSON report is gitignored and used by IDE/Copilot workflows.
Dogfood configuration
openspec/config.yaml
Added context-level and per-artifact task requirements for .specfact/code-review.json evidence, including freshness checks, severity-based remediation rules, and re-run procedures documented in TDD_EVIDENCE.md.
Pre-commit gate implementation
scripts/pre_commit_code_review.py
Added _repo_root() helper function, new REVIEW_JSON_OUT constant, and modified build_review_command() to enforce --json and --out flags with postcondition contracts; updated main() to execute subprocess with repository root as working directory.
Pre-commit workflow tests
tests/unit/scripts/test_pre_commit_code_review.py
Updated assertions to verify build_review_command() includes --json, --out, and configured output path; modified stub expectations to confirm subprocess receives cwd parameter and process exit code semantics are preserved.
Documentation tests
tests/unit/scripts/test_code_review_module_docs.py
Loosened command assertion from requiring --score-only to requiring base specfact code review run invocation, and added coverage for .specfact/code-review.json artifact path documentation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

enhancement

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main changes: a release version bump with two primary features (pre-commit review JSON output and OpenSpec dogfood rules), making it directly relevant to the changeset.
Description check ✅ Passed The description is substantially complete, covering summary, change details, type of change, testing approach, and checklist items. Although some contract-testing sections are marked N/A (appropriately for this non-API release), the required information for a chore/release PR is present and thorough.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 chore/pre-commit-review-json-openspec-v0432

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

@djm81 djm81 self-assigned this Mar 29, 2026
@djm81 djm81 added enhancement New feature or request architecture Architecture and design changes QA Quality Assurance labels Mar 29, 2026
@djm81 djm81 moved this from Todo to In Progress in SpecFact CLI Mar 29, 2026
@djm81 djm81 linked an issue Mar 29, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Line 16: The release bullet for the pre-commit hook
`specfact-code-review-gate` is a single long line; wrap it to respect the
markdown 120-character line-length rule by breaking the sentence into multiple
lines while preserving the bullet, inline code and command text (e.g., the
`specfact code review run --json --out .specfact/code-review.json` string and
the reference to `--score-only`), ensuring the `.specfact/` path remains intact
and the resulting lines are each under 120 characters.
- Around line 14-17: Update the 0.43.2 CHANGELOG.md entry to list all meaningful
changes introduced by the PR: expand the "Changed" item about the pre-commit
hook (mention switching the pre-commit specfact-code-review-gate to run
"specfact code review run --json --out .specfact/code-review.json" instead of
"--score-only"), add entries under appropriate headings for the OpenSpec
policy/config changes (e.g., "Changed" or "Added" for new/modified policies),
note documentation updates (under "Changed" or "Added"), and list test updates
or fixes (under "Fixed" or "Changed"); ensure each change references the
relevant feature or file names (e.g., OpenSpec policy/config, specfact
pre-commit gate, docs, tests) and is concise so the 0.43.2 release notes fully
reflect the PR.

In `@openspec/config.yaml`:
- Around line 168-170: Update the freshness rule that invalidates
.specfact/code-review.json so it does not self-invalidate when contributors add
or update supporting evidence files; specifically, modify the policy text around
the ".specfact/code-review.json" freshness check to exclude
openspec/changes/<change-id>/TDD_EVIDENCE.md (or to only consider non-evidence
files in openspec/changes/<change-id>/ for staleness) and add a short note
explaining that TDD_EVIDENCE.md updates are allowed without forcing a new
review; reference the existing freshness check wording that mentions
"openspec/changes/<change-id>/" and the guidance about recording evidence in
"TDD_EVIDENCE.md" when making the change.

In `@scripts/pre_commit_code_review.py`:
- Around line 91-97: The subprocess.run call that invokes
build_review_command(files) in scripts/pre_commit_code_review.py can hang; add a
timeout=300 to that call and wrap it in a try/except that catches
subprocess.TimeoutExpired (import TimeoutExpired from subprocess) and handles it
gracefully: log or print a clear timeout error (including the command or files),
set result to a failure-equivalent (e.g., non-zero return or raise a controlled
exception) so the pre-commit hook fails fast, and ensure the cwd=_repo_root()
usage remains unchanged; keep the rest of the logic that inspects
result.stdout/result.stderr intact.

In `@tests/unit/scripts/test_pre_commit_code_review.py`:
- Around line 67-71: The test's _fake_run currently only asserts
kwargs.get("cwd") is not None; change this to assert the exact expected repo
root to avoid false positives by comparing to the fixture/variable representing
the repo root (e.g., assert kwargs.get("cwd") == repo_root or
expected_repo_root). Keep the other asserts (presence of "--json" and
module.REVIEW_JSON_OUT) and return value the same; update the assertion in the
_fake_run function to perform an equality check against the known repo-root
value used by the test harness.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d32a361a-7b12-480c-839b-e71f0ba61d4a

📥 Commits

Reviewing files that changed from the base of the PR and between cb08cbb and 17ee3c5.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • docs/modules/code-review.md
  • openspec/config.yaml
  • pyproject.toml
  • scripts/pre_commit_code_review.py
  • setup.py
  • src/__init__.py
  • src/specfact_cli/__init__.py
  • tests/unit/scripts/test_code_review_module_docs.py
  • tests/unit/scripts/test_pre_commit_code_review.py

Comment thread CHANGELOG.md
Comment thread CHANGELOG.md
Comment thread openspec/config.yaml
Comment thread scripts/pre_commit_code_review.py
Comment thread tests/unit/scripts/test_pre_commit_code_review.py
@djm81
Copy link
Copy Markdown
Collaborator Author

djm81 commented Mar 29, 2026

superseded by a single PR from feature/doc-frontmatter-schema that includes the same code plus updated OpenSpec artifacts

@djm81 djm81 closed this Mar 29, 2026
@github-project-automation github-project-automation bot moved this from In Progress to Done in SpecFact CLI Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

architecture Architecture and design changes enhancement New feature or request QA Quality Assurance

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Feature] Code Review Core Foundation

1 participant