Skip to content

[codex] Add guided simplification review enforcement#287

Merged
djm81 merged 7 commits into
devfrom
feature/code-review-12-guided-simplification-enforcement
May 23, 2026
Merged

[codex] Add guided simplification review enforcement#287
djm81 merged 7 commits into
devfrom
feature/code-review-12-guided-simplification-enforcement

Conversation

@djm81
Copy link
Copy Markdown
Contributor

@djm81 djm81 commented May 22, 2026

Summary

Adds guided simplification review enforcement for the code-review and project modules. The change teaches review reports to distinguish safe mechanical cleanup, test-dependent simplification, design-judgment cases, and preserve decisions so IDE/headless LLM agents can apply clean-code fixes without removing meaningful contracts.

What changed

  • Added the OpenSpec change code-review-12-guided-simplification-enforcement and linked backlog tracking for [Change] Guided simplification enforcement for code review #286 under parent feature [Feature] Code Review Simplification Feedback Loop #275 / epic [Epic] specfact code #162.
  • Extended simplify review output with guidance fields, action status, simplification summaries, shadow/enforce behavior, and fix evidence.
  • Updated AI-bloat and Semgrep mapping so simplification findings carry LLM-readable guidance metadata.
  • Enhanced the simplify prompt and code-review skill so users without SpecFact internals are walked through review loading, walkthrough level selection, evidence logging, and headless one-file-at-a-time flow.
  • Added focused tests for review command output, findings serialization, AI-bloat/Semgrep guidance, runner summaries, and prompt/skill resources.

Validation

  • hatch run format
  • targeted simplify/Semgrep guidance unit tests
  • hatch run pytest tests/unit/specfact_code_review/tools/test_semgrep_runner.py --cov packages/specfact-code-review/src/specfact_code_review --cov-report=term-missing --cov-fail-under=0 -q - 42 passed; semgrep_runner.py coverage 80.20%
  • hatch run type-check
  • hatch run lint
  • hatch run sign-modules --changed-only --payload-from-filesystem --bump-version patch --base-ref origin/dev --allow-unsigned
  • hatch run verify-modules-signature --payload-from-filesystem --enforce-version-bump --version-check-base origin/dev
  • SPECFACT_ALLOW_UNSIGNED=1 SPECFACT_CODE_REVIEW_TARGETED_TEST_TIMEOUT=300 hatch run specfact code review run --bug-hunt --json --out .specfact/tmp-local-dev-link-review/changed-bughunt-clean-final.json --scope changed
  • openspec validate code-review-12-guided-simplification-enforcement --strict
  • pre-commit Block 1 quality gates passed
  • pre-commit Block 2 review + contract tests passed: 753 passed, 2 warnings

Closes #286.

@strix-security
Copy link
Copy Markdown

Strix is installed on this repository, but we could not run this PR security review because this workspace does not have an active plan. If you'd like to continue receiving code reviews, you can add a payment method or manage billing here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3cb0c1aa-97b8-4479-91ab-442989335613

📥 Commits

Reviewing files that changed from the base of the PR and between 17d6c5c and a9c1030.

📒 Files selected for processing (7)
  • openspec/changes/code-review-12-guided-simplification-enforcement/TDD_EVIDENCE.md
  • packages/specfact-code-review/module-package.yaml
  • packages/specfact-code-review/src/specfact_code_review/run/commands.py
  • packages/specfact-code-review/src/specfact_code_review/run/findings.py
  • packages/specfact-project/module-package.yaml
  • tests/unit/specfact_code_review/run/test_commands.py
  • tests/unit/specfact_code_review/run/test_findings.py
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (5)
packages/**/module-package.yaml

⚙️ CodeRabbit configuration file

packages/**/module-package.yaml: Validate metadata: name, version, commands, dependencies, and parity with packaged src.
Call out semver and signing implications when manifests or payloads change.

Files:

  • packages/specfact-project/module-package.yaml
  • packages/specfact-code-review/module-package.yaml
**/*.{js,ts,tsx,jsx,py,java,cs,go,rb,php,cpp,c,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Preserve the clean-code compliance gate and its category references (naming, kiss, yagni, dry, and solid)

Files:

  • tests/unit/specfact_code_review/run/test_commands.py
  • tests/unit/specfact_code_review/run/test_findings.py
  • packages/specfact-code-review/src/specfact_code_review/run/findings.py
  • packages/specfact-code-review/src/specfact_code_review/run/commands.py
tests/**/*.py

⚙️ CodeRabbit configuration file

tests/**/*.py: Contract-first and integration tests: migration suites, bundle validation, and flakiness.
Ensure changes to adapters or bridges have targeted coverage.

Files:

  • tests/unit/specfact_code_review/run/test_commands.py
  • tests/unit/specfact_code_review/run/test_findings.py
packages/**/src/**/*.py

⚙️ CodeRabbit configuration file

packages/**/src/**/*.py: Focus on adapter and bridge patterns: imports from specfact_cli (models, runtime, validators),
Typer/Rich command surfaces, and clear boundaries so core upgrades do not silently break bundles.
Flag breaking assumptions about registry loading, lazy imports, and environment/mode behavior.

Files:

  • packages/specfact-code-review/src/specfact_code_review/run/findings.py
  • packages/specfact-code-review/src/specfact_code_review/run/commands.py
openspec/**/*.md

⚙️ CodeRabbit configuration file

openspec/**/*.md: Specification truth: proposal/tasks/spec deltas vs. bundle behavior, CHANGE_ORDER, and
drift vs. shipped modules or docs.

Files:

  • openspec/changes/code-review-12-guided-simplification-enforcement/TDD_EVIDENCE.md
🪛 LanguageTool
openspec/changes/code-review-12-guided-simplification-enforcement/TDD_EVIDENCE.md

[style] ~29-~29: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ode_review/run/test_findings.py -q` - Result after follow-up PR review fixes: 77 pas...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~47-~47: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...t/code-review.json --scope changed` - Result after follow-up PR review fixes: PASS, ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🔇 Additional comments (7)
packages/specfact-project/module-package.yaml (1)

2-2: LGTM!

Also applies to: 30-31

packages/specfact-code-review/module-package.yaml (1)

2-2: LGTM!

Also applies to: 26-27

tests/unit/specfact_code_review/run/test_commands.py (1)

380-399: LGTM!

tests/unit/specfact_code_review/run/test_findings.py (1)

168-184: LGTM!

packages/specfact-code-review/src/specfact_code_review/run/findings.py (1)

198-200: LGTM!

packages/specfact-code-review/src/specfact_code_review/run/commands.py (1)

320-325: LGTM!

openspec/changes/code-review-12-guided-simplification-enforcement/TDD_EVIDENCE.md (1)

13-16: LGTM!

Also applies to: 28-29, 47-47


📝 Walkthrough

Module Surface & Command Changes

specfact-code-review (v0.47.20 → v0.47.23)

The specfact code review run command surface remains stable with no breaking changes to command signatures. New internal command pipeline added:

  • _apply_simplification_fixes(): Applies deterministic, AST-driven line-range rewrites for safe-mechanical simplifications when --fix flag is enabled and review_focus == "simplify". Dispatches findings by rule to four fix handlers (redundant-intermediate inlining, verbose-bool-return collapsing, dead-branch removal, pass-through try/except cleanup).
  • Integration into both interactive (_run_review_with_status) and non-interactive (_run_review_once) flows with appropriate progress callbacks.
  • Post-fix re-run of review to capture updated state in JSON report.

specfact-project (v0.41.12 → v0.41.15)

No command surface changes. Version bump reflects downstream dependency on specfact-code-review enrichments.

Data Model & Contract Changes

ReviewFinding (backward-compatible extension)

Nine new optional fields added to support action-oriented simplification guidance:

  • guidance_kind: Literal["safe_mechanical", "needs_tests", "design_judgment", "preserve"]
  • recommended_action, clean_code_principle, rationale, safety_checks
  • preserve_reason (required when guidance_kind="preserve")
  • action_status, before_ref, after_ref, improvement

All fields are optional; legacy payloads without guided metadata remain valid. Validation enforces: when guidance_kind is set, all guidance fields must be present together; preserve_reason required for preserve guidance; safety_checks cannot be blank.

ReviewReport (additive changes)

  • New optional field: simplification_summary: SimplificationSummary | None
  • Schema version automatically bumped to "1.2" when guided simplification metadata is emitted
  • New _build_simplification_summary() logic aggregates guided findings into per-guidance_kind and per-action_status counts, computing blocking_simplification_count (safe-mechanical findings with recommended/failed statuses)

SimplificationSummary (new model)

Structured summary of simplification findings with counts by guidance kind and action status, including derived totals for blocking findings, applied fixes, and retained items.

CLI Contract Behavior Changes

Enforcement mode (--focus simplify --mode enforce)

  • Report verdict set to FAIL (ci_exit_code=1) when simplification_summary.blocking_simplification_count > 0
  • Only guidance_kind="safe_mechanical" findings contribute to blocking count
  • design_judgment and preserve findings never cause enforcement failure
  • No change to non-simplify focus behavior

Fix mode (--fix with --focus simplify)

  • Applies rewrites only to guidance_kind="safe_mechanical" findings
  • Rewrites are deterministic line-range replacements validated by AST matching
  • Review automatically re-runs post-fix; JSON report records applied/failed/still-recommended outcomes via action_status field
  • Failed rewrites (parse errors, no pattern match) recorded with action status but do not block execution

Cross-Repo Impact & specfact_cli Compatibility

No new imports from specfact_cli introduced. Existing contracts (ModuleIOContract, module_io_shim, registry, runtime, progress utilities) remain unchanged. Module continues to operate within current API envelope without requiring specfact_cli version bumps.

Manifest & Registry

  • specfact-code-review: Integrity metadata (checksum, signature) updated; core_compatibility remains >=0.44.0,<1.0.0
  • specfact-project: Integrity metadata updated; core_compatibility >=0.40.0,<1.0.0
  • Both manifests stable; no new pip dependencies or bundle dependencies added

OpenSpec Change

Change ID: code-review-12-guided-simplification-enforcement
Parent: Feature #275 / Epic #162
Closes: Issue #286 (Guided simplification enforcement for code review)

Includes full spec definitions for:

  • Guided simplification review output (guidance taxonomy, required fields, validation rules)
  • Review-finding-model schema with optional simplification metadata
  • Review-run-command behavior for --focus simplify with enforce/fix semantics
  • Interactive prompt and skill adaptation for walkthrough levels (vibe coder/junior/senior/headless-agent)

Validation evidence: 42 semgrep_runner tests passed (80.20% coverage), OpenSpec strict validation passed, 753 contract tests passed.

Documentation & Resource Updates

  • specfact.08-simplify prompt: Expanded with walkthrough-level concept, headless behavior rules, guidance kind semantics, evidence logging, action-status checklist, and re-run comparison guidance
  • specfact-code-review SKILL: Updated house rules for simplification queue operation, guidance kind interpretation, evidence logging, and headless-mode action-table output (columns: file, line, rule, guidance_kind, recommended_action, action_status, evidence)

No documentation-url-contract breaks; all prompts and skills remain repo-discoverable and validate against updated schema.

Walkthrough

This PR adds guided simplification metadata, validates and aggregates simplification summaries (schema v1.2), implements a deterministic AST-based safe-mechanical fix pipeline used by --focus simplify --fix, enforces failing verdicts only for blocking safe_mechanical findings, updates semgrep/ai-bloat mappings and prompts/skills, adds tests, and bumps module manifests.

Changes

Guided Simplification Enforcement for Code Review

Layer / File(s) Summary
OpenSpec change & docs
openspec/CHANGE_ORDER.md, openspec/changes/code-review-12-guided-simplification-enforcement/*.md
Adds OpenSpec change entry, .openspec metadata, proposal/design/specs/tasks/TDD evidence documenting guided simplification enforcement and JSON/report expectations.
Review Finding Model with Guidance Metadata
packages/specfact-code-review/src/specfact_code_review/run/findings.py, tests/unit/specfact_code_review/run/test_findings.py
Adds GUIDANCE_KINDS and ACTION_STATUSES; extends ReviewFinding with guided fields; adds SimplificationSummary and optional simplification_summary on ReviewReport; schema version advances to 1.2 when guided metadata present.
AI Bloat Findings Enriched with Guidance
packages/specfact-code-review/src/specfact_code_review/tools/ai_bloat_runner.py, tests/unit/specfact_code_review/tools/test_ai_bloat_runner.py
Enriches ai_bloat heuristics with guidance metadata and fixable flags; adds decorator-aware preservation logic and updates many heuristics to emit guidance_kind/recommended_action/rationale/safety_checks.
Semgrep AI-Bloat Guidance Mapping
packages/specfact-code-review/src/specfact_code_review/tools/semgrep_runner.py, tests/unit/specfact_code_review/tools/test_semgrep_runner.py
Introduces _AiBloatGuidance dataclass and AI_BLOAT_GUIDANCE mapping; routes ai_bloat results through _ai_bloat_finding_from_result to populate guidance fields and rewrite hints.
AST-Based Safe Mechanical Fix Pipeline
packages/specfact-code-review/src/specfact_code_review/run/commands.py, tests/unit/specfact_code_review/run/test_commands.py
Adds _apply_simplification_fixes selection/ordering and four AST-based fixers that parse target files, pattern-match by line, compute replacements, and perform validated on-disk line-range splices; integrated before Ruff autofix and review re-run when --fix is enabled in simplify focus.
Enforcement & Simplification Verdict
packages/specfact-code-review/src/specfact_code_review/run/runner.py, tests/unit/specfact_code_review/run/test_runner.py
run_review enforces FAIL/ci_exit_code=1 when focus=="simplify" and simplification_summary.blocking_simplification_count > 0; expected test path helper simplified.
Prompts, Skill docs & Updater
packages/specfact-project/resources/prompts/specfact.08-simplify.md, .vibe/skills/.../SKILL.md, packages/.../resources/skills/.../SKILL.md, packages/specfact-code-review/src/specfact_code_review/rules/updater.py, skills/specfact-code-review/SKILL.md
Updates simplification prompt, skill house rules, and updater to require evidence grounding, walkthrough-level selection, guidance_kind handling (preserve_reason), simplification action logging/evidence, and headless-mode per-file action-table outputs.
Tests
tests/unit/**
Adds and extends tests validating guided fields, report schema/versioning, simplification summary counts, enforcement semantics, fix application order and matching, semgrep mapping, and resource string assertions.
Module Versioning & Integrity
packages/specfact-code-review/module-package.yaml, packages/specfact-project/module-package.yaml
Bumps versions and updates integrity checksum/signature values in manifests.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as "specfact CLI"
  participant Runner as "run_review"
  participant Fixer as "_apply_simplification_fixes"
  participant AST as "ast.parse / matchers"
  participant FS as "SourceFile"
  participant Ruff as "Ruff autofix"

  CLI->>Runner: run --focus simplify [--fix]
  Runner->>Fixer: pass ReviewReport.findings
  Fixer->>AST: parse files & match safe_mechanical patterns
  AST->>Fixer: matched nodes & replacement text
  Fixer->>FS: write replaced line ranges
  FS->>Runner: updated source
  Runner->>Ruff: run Ruff autofix
  Ruff->>Runner: continue review / rerun
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

Suggested labels

change-proposal

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.17% 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
Title check ✅ Passed The PR title '[codex] Add guided simplification review enforcement' clearly describes the main change: adding guided simplification review enforcement functionality.
Description check ✅ Passed The PR description covers the summary of changes, scope, bundle impact, and comprehensive validation evidence including module signing/verification and quality gates.
Linked Issues check ✅ Passed The PR implements all acceptance criteria from #286: backward-compatible JSON, conservative enforce/fix behavior, preserve/design-judgment classification, adaptive prompt/skill walkthroughs, consistent decision policy, and passing validation gates.
Out of Scope Changes check ✅ Passed All code changes directly support guided simplification enforcement objectives: OpenSpec change, findings metadata, AI-bloat/Semgrep mapping, prompt/skill updates, enforce/fix pipeline, and comprehensive test coverage.

✏️ 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 feature/code-review-12-guided-simplification-enforcement

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

@djm81 djm81 self-assigned this May 22, 2026
@djm81 djm81 added enhancement New feature or request codebase Specfact codebase related topic labels May 22, 2026
@djm81 djm81 moved this from Todo to In Progress in SpecFact CLI May 22, 2026
@djm81 djm81 linked an issue May 22, 2026 that may be closed by this pull request
7 tasks
@djm81 djm81 marked this pull request as ready for review May 22, 2026 22:16
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 849d97503b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/specfact-code-review/src/specfact_code_review/run/commands.py Outdated
Comment thread packages/specfact-code-review/src/specfact_code_review/run/commands.py Outdated
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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/specfact-code-review/src/specfact_code_review/rules/updater.py (1)

31-57: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add the missing headless action-table rule to the generated template.

Line 31–57 define canonical DO rules, but the required headless behavior (“one file at a time” + emitted action table fields) is missing here while present in SKILL docs. If updater regenerates files, this drops policy-critical guidance and creates drift.

Suggested patch
 DEFAULT_DO_RULES = (
@@
     "- Log each simplification action as recommended, applied, kept, skipped, failed, with evidence of improvement "
     "or preserved contract",
+    "- In headless mode, process one file at a time and emit an action table: file, line, rule, guidance_kind, "
+    "recommended_action, action_status, evidence",
     "- For merge-quality review, run `specfact code review run --scope changed --bug-hunt --json "
     "--out .specfact/code-review.json`",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/specfact-code-review/src/specfact_code_review/rules/updater.py`
around lines 31 - 57, DEFAULT_DO_RULES is missing the headless action-table
rule; update the DEFAULT_DO_RULES tuple in updater.py to include a rule that
mandates headless runs process one file at a time and emit the action table
fields (e.g., action, target_path, start_line, end_line, edit_text, confidence,
preserve_reason) so regenerated templates keep policy-critical guidance; modify
the string list in DEFAULT_DO_RULES (the constant named DEFAULT_DO_RULES) to add
a concise rule sentence covering "headless: one file at a time" and the required
emitted action-table fields.
🧹 Nitpick comments (1)
tests/unit/test_guided_simplify_resources.py (1)

29-40: ⚡ Quick win

Extend coverage to enforce skill-copy parity across all shipped locations.

This test validates only the bundled skill path. Drift in .vibe/skills/specfact-code-review/SKILL.md or skills/specfact-code-review/SKILL.md would currently pass, which weakens release integrity for synchronized guidance surfaces.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/test_guided_simplify_resources.py` around lines 29 - 40, The test
test_code_review_skill_teaches_llms_how_to_apply_simplification_guidance only
checks the bundled SKILL via SKILL.read_text; extend it to also load and assert
parity for the other shipped SKILL copies by reading the other SKILL.md
locations (e.g., the workspace copy and the .vibe copy) and asserting they
contain the same required strings and/or that their contents are identical to
SKILL.read_text(); update the test to iterate candidate paths, read_text or open
each file, and run the same assertions (or an equality assertion against
SKILL.read_text()) so drift across all shipped locations is caught.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@openspec/changes/code-review-12-guided-simplification-enforcement/specs/review-run-command/spec.md`:
- Around line 9-13: The clause requiring guidance metadata for simplify-focused
findings is currently marked as "SHOULD" but must be normative; change the term
"SHOULD" to "SHALL" in the sentence that reads "retained findings SHOULD include
guidance metadata for actionability, preservation, or design judgment" so the
spec mandates guidance metadata for simplify-focused findings; ensure the
surrounding lines mentioning "simplification-focused findings", the `specfact
code review run --focus simplify --json --out .specfact/code-review.json`
WHEN/THEN/AND block, and the requirement for a "simplification summary" remain
semantically consistent after this change.

In `@packages/specfact-code-review/src/specfact_code_review/run/findings.py`:
- Around line 359-361: The current computation of blocking_simplification_count
only counts safe-mechanical findings where finding.action_status ==
"recommended", which skips unresolved "failed" items; update the generator over
guided (the expression that uses finding.is_safe_mechanical_simplification() and
finding.action_status) so it treats both "recommended" and "failed" as blocking
(for example, check finding.action_status in ("recommended", "failed") or
equivalently that action_status != "resolved") to ensure failed safe-mechanical
items are counted as blocking unresolved findings.
- Around line 189-205: The validator _validate_guided_metadata currently returns
early when guidance_kind is None, allowing guided fields to be set without a
guidance_kind; change it to first check whether any guided-related fields
(recommended_action, clean_code_principle, rationale, safety_checks,
action_status, preserve_reason) are non-null and if so raise ValueError
requiring guidance_kind, then proceed with the existing validation (ensure
recommended_action, clean_code_principle, rationale, safety_checks,
action_status are present when guidance_kind is set and require preserve_reason
when guidance_kind == "preserve"); update _validate_guided_metadata to enforce
presence of guidance_kind whenever any of those guided fields are provided.

---

Outside diff comments:
In `@packages/specfact-code-review/src/specfact_code_review/rules/updater.py`:
- Around line 31-57: DEFAULT_DO_RULES is missing the headless action-table rule;
update the DEFAULT_DO_RULES tuple in updater.py to include a rule that mandates
headless runs process one file at a time and emit the action table fields (e.g.,
action, target_path, start_line, end_line, edit_text, confidence,
preserve_reason) so regenerated templates keep policy-critical guidance; modify
the string list in DEFAULT_DO_RULES (the constant named DEFAULT_DO_RULES) to add
a concise rule sentence covering "headless: one file at a time" and the required
emitted action-table fields.

---

Nitpick comments:
In `@tests/unit/test_guided_simplify_resources.py`:
- Around line 29-40: The test
test_code_review_skill_teaches_llms_how_to_apply_simplification_guidance only
checks the bundled SKILL via SKILL.read_text; extend it to also load and assert
parity for the other shipped SKILL copies by reading the other SKILL.md
locations (e.g., the workspace copy and the .vibe copy) and asserting they
contain the same required strings and/or that their contents are identical to
SKILL.read_text(); update the test to iterate candidate paths, read_text or open
each file, and run the same assertions (or an equality assertion against
SKILL.read_text()) so drift across all shipped locations is caught.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 55881d54-953f-47e4-afcb-94eaa3d9827c

📥 Commits

Reviewing files that changed from the base of the PR and between 47c3a84 and 849d975.

📒 Files selected for processing (27)
  • .vibe/skills/specfact-code-review/SKILL.md
  • openspec/CHANGE_ORDER.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/.openspec.yaml
  • openspec/changes/code-review-12-guided-simplification-enforcement/TDD_EVIDENCE.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/design.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/proposal.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/specs/guided-simplification-review/spec.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/specs/review-finding-model/spec.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/specs/review-run-command/spec.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/tasks.md
  • packages/specfact-code-review/module-package.yaml
  • packages/specfact-code-review/src/specfact_code_review/resources/skills/specfact-code-review/SKILL.md
  • packages/specfact-code-review/src/specfact_code_review/rules/updater.py
  • packages/specfact-code-review/src/specfact_code_review/run/commands.py
  • packages/specfact-code-review/src/specfact_code_review/run/findings.py
  • packages/specfact-code-review/src/specfact_code_review/run/runner.py
  • packages/specfact-code-review/src/specfact_code_review/tools/ai_bloat_runner.py
  • packages/specfact-code-review/src/specfact_code_review/tools/semgrep_runner.py
  • packages/specfact-project/module-package.yaml
  • packages/specfact-project/resources/prompts/specfact.08-simplify.md
  • skills/specfact-code-review/SKILL.md
  • tests/unit/specfact_code_review/run/test_commands.py
  • tests/unit/specfact_code_review/run/test_findings.py
  • tests/unit/specfact_code_review/run/test_runner.py
  • tests/unit/specfact_code_review/tools/test_ai_bloat_runner.py
  • tests/unit/specfact_code_review/tools/test_semgrep_runner.py
  • tests/unit/test_guided_simplify_resources.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (5)
packages/**/module-package.yaml

⚙️ CodeRabbit configuration file

packages/**/module-package.yaml: Validate metadata: name, version, commands, dependencies, and parity with packaged src.
Call out semver and signing implications when manifests or payloads change.

Files:

  • packages/specfact-project/module-package.yaml
  • packages/specfact-code-review/module-package.yaml
openspec/**/*.md

⚙️ CodeRabbit configuration file

openspec/**/*.md: Specification truth: proposal/tasks/spec deltas vs. bundle behavior, CHANGE_ORDER, and
drift vs. shipped modules or docs.

Files:

  • openspec/changes/code-review-12-guided-simplification-enforcement/specs/review-run-command/spec.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/specs/review-finding-model/spec.md
  • openspec/CHANGE_ORDER.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/specs/guided-simplification-review/spec.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/tasks.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/proposal.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/TDD_EVIDENCE.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/design.md
**/*.{js,ts,tsx,jsx,py,java,cs,go,rb,php,cpp,c,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Preserve the clean-code compliance gate and its category references (naming, kiss, yagni, dry, and solid)

Files:

  • tests/unit/test_guided_simplify_resources.py
  • packages/specfact-code-review/src/specfact_code_review/rules/updater.py
  • packages/specfact-code-review/src/specfact_code_review/run/runner.py
  • tests/unit/specfact_code_review/run/test_findings.py
  • packages/specfact-code-review/src/specfact_code_review/run/commands.py
  • tests/unit/specfact_code_review/tools/test_ai_bloat_runner.py
  • tests/unit/specfact_code_review/run/test_commands.py
  • packages/specfact-code-review/src/specfact_code_review/run/findings.py
  • tests/unit/specfact_code_review/tools/test_semgrep_runner.py
  • packages/specfact-code-review/src/specfact_code_review/tools/semgrep_runner.py
  • tests/unit/specfact_code_review/run/test_runner.py
  • packages/specfact-code-review/src/specfact_code_review/tools/ai_bloat_runner.py
tests/**/*.py

⚙️ CodeRabbit configuration file

tests/**/*.py: Contract-first and integration tests: migration suites, bundle validation, and flakiness.
Ensure changes to adapters or bridges have targeted coverage.

Files:

  • tests/unit/test_guided_simplify_resources.py
  • tests/unit/specfact_code_review/run/test_findings.py
  • tests/unit/specfact_code_review/tools/test_ai_bloat_runner.py
  • tests/unit/specfact_code_review/run/test_commands.py
  • tests/unit/specfact_code_review/tools/test_semgrep_runner.py
  • tests/unit/specfact_code_review/run/test_runner.py
packages/**/src/**/*.py

⚙️ CodeRabbit configuration file

packages/**/src/**/*.py: Focus on adapter and bridge patterns: imports from specfact_cli (models, runtime, validators),
Typer/Rich command surfaces, and clear boundaries so core upgrades do not silently break bundles.
Flag breaking assumptions about registry loading, lazy imports, and environment/mode behavior.

Files:

  • packages/specfact-code-review/src/specfact_code_review/rules/updater.py
  • packages/specfact-code-review/src/specfact_code_review/run/runner.py
  • packages/specfact-code-review/src/specfact_code_review/run/commands.py
  • packages/specfact-code-review/src/specfact_code_review/run/findings.py
  • packages/specfact-code-review/src/specfact_code_review/tools/semgrep_runner.py
  • packages/specfact-code-review/src/specfact_code_review/tools/ai_bloat_runner.py
🪛 LanguageTool
openspec/changes/code-review-12-guided-simplification-enforcement/proposal.md

[style] ~33-~33: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... required fields remain compatible. - Affected prompt resources: `packages/specfact-...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~34-~34: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...s/prompts/specfact.08-simplify.md. - **Affected skill resources:** packages/specfact-c...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

openspec/changes/code-review-12-guided-simplification-enforcement/design.md

[style] ~26-~26: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...efactor for design-judgment findings. - No breaking removal of existing simplifica...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~27-~27: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...sting simplification metadata fields. - No claim that findings prove AI authorship...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🔇 Additional comments (24)
packages/specfact-code-review/src/specfact_code_review/run/runner.py (2)

103-105: LGTM!


654-659: LGTM!

tests/unit/specfact_code_review/run/test_runner.py (2)

57-84: LGTM!


226-287: LGTM!

packages/specfact-code-review/src/specfact_code_review/run/commands.py (2)

5-5: LGTM!

Also applies to: 283-416


515-517: LGTM!

Also applies to: 537-542

tests/unit/specfact_code_review/run/test_commands.py (2)

31-60: LGTM!


306-390: LGTM!

openspec/CHANGE_ORDER.md (1)

105-105: LGTM!

openspec/changes/code-review-12-guided-simplification-enforcement/.openspec.yaml (1)

1-2: LGTM!

openspec/changes/code-review-12-guided-simplification-enforcement/TDD_EVIDENCE.md (1)

1-61: LGTM!

openspec/changes/code-review-12-guided-simplification-enforcement/design.md (1)

1-70: LGTM!

openspec/changes/code-review-12-guided-simplification-enforcement/proposal.md (1)

1-46: LGTM!

openspec/changes/code-review-12-guided-simplification-enforcement/specs/guided-simplification-review/spec.md (1)

1-64: LGTM!

openspec/changes/code-review-12-guided-simplification-enforcement/specs/review-finding-model/spec.md (1)

1-19: LGTM!

openspec/changes/code-review-12-guided-simplification-enforcement/tasks.md (1)

1-53: LGTM!

packages/specfact-code-review/module-package.yaml (1)

2-2: LGTM!

Also applies to: 26-27

packages/specfact-project/module-package.yaml (1)

2-2: LGTM!

Also applies to: 30-31

packages/specfact-code-review/src/specfact_code_review/run/findings.py (1)

30-31: LGTM!

Also applies to: 116-187, 220-243, 265-273, 290-318, 345-358, 362-364

tests/unit/specfact_code_review/run/test_findings.py (1)

42-51: LGTM!

Also applies to: 118-155, 281-312

packages/specfact-code-review/src/specfact_code_review/tools/ai_bloat_runner.py (1)

8-9: LGTM!

Also applies to: 30-37, 52-63, 127-139, 150-150, 164-186, 214-228, 275-292, 314-321, 360-366, 390-397, 463-472, 499-504, 532-538, 553-556, 590-595, 619-624, 647-648, 702-709

tests/unit/specfact_code_review/tools/test_ai_bloat_runner.py (1)

33-35: LGTM!

Also applies to: 77-82, 94-100, 205-232

packages/specfact-code-review/src/specfact_code_review/tools/semgrep_runner.py (1)

9-10: LGTM!

Also applies to: 42-87, 254-255, 372-408

tests/unit/specfact_code_review/tools/test_semgrep_runner.py (1)

13-18: LGTM!

Also applies to: 166-170, 271-309, 345-399

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: 1

♻️ Duplicate comments (1)
packages/specfact-code-review/src/specfact_code_review/run/findings.py (1)

191-201: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Require guidance_kind when any guided evidence field is present.

Line 191 excludes before_ref, after_ref, and improvement from the orphan-field check, so those guided fields can still pass without guidance_kind.

Proposed fix
     guided_fields = (
         self.recommended_action,
         self.clean_code_principle,
         self.rationale,
         self.safety_checks,
         self.action_status,
         self.preserve_reason,
+        self.before_ref,
+        self.after_ref,
+        self.improvement,
     )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/specfact-code-review/src/specfact_code_review/run/findings.py`
around lines 191 - 201, The current orphan-field check only looks at
guided_fields (self.recommended_action, self.clean_code_principle,
self.rationale, self.safety_checks, self.action_status, self.preserve_reason)
and thus misses guided evidence fields like self.before_ref, self.after_ref, and
self.improvement; update the validation so that when self.guidance_kind is None
it raises the same ValueError if any of these additional guided fields
(before_ref, after_ref, improvement) are non-None—i.e., extend the any(...)
check to include self.before_ref, self.after_ref, and self.improvement alongside
the existing guided_fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/specfact-code-review/src/specfact_code_review/run/commands.py`:
- Around line 320-327: The current deletion branch removes an if-statement even
when it has an else/orelse block, which can drop executable code; update the
conditional that returns _replace_line_range to first ensure stmt.orelse is
empty (e.g., add "and not stmt.orelse") so the fixer only removes the if when
there is no else path, keeping use of _terminal_return, prior_terminal_tests and
_replace_line_range unchanged.

---

Duplicate comments:
In `@packages/specfact-code-review/src/specfact_code_review/run/findings.py`:
- Around line 191-201: The current orphan-field check only looks at
guided_fields (self.recommended_action, self.clean_code_principle,
self.rationale, self.safety_checks, self.action_status, self.preserve_reason)
and thus misses guided evidence fields like self.before_ref, self.after_ref, and
self.improvement; update the validation so that when self.guidance_kind is None
it raises the same ValueError if any of these additional guided fields
(before_ref, after_ref, improvement) are non-None—i.e., extend the any(...)
check to include self.before_ref, self.after_ref, and self.improvement alongside
the existing guided_fields.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: efcc9463-d4d7-4af0-911b-2964379f22a1

📥 Commits

Reviewing files that changed from the base of the PR and between 849d975 and 17d6c5c.

📒 Files selected for processing (12)
  • openspec/changes/code-review-12-guided-simplification-enforcement/TDD_EVIDENCE.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/specs/review-run-command/spec.md
  • packages/specfact-code-review/module-package.yaml
  • packages/specfact-code-review/src/specfact_code_review/rules/updater.py
  • packages/specfact-code-review/src/specfact_code_review/run/commands.py
  • packages/specfact-code-review/src/specfact_code_review/run/findings.py
  • packages/specfact-project/module-package.yaml
  • tests/unit/specfact_code_review/rules/test_updater.py
  • tests/unit/specfact_code_review/run/test_commands.py
  • tests/unit/specfact_code_review/run/test_findings.py
  • tests/unit/specfact_code_review/run/test_runner.py
  • tests/unit/test_guided_simplify_resources.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,ts,tsx,jsx,py,java,cs,go,rb,php,cpp,c,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Preserve the clean-code compliance gate and its category references (naming, kiss, yagni, dry, and solid)

Files:

  • tests/unit/specfact_code_review/rules/test_updater.py
  • tests/unit/test_guided_simplify_resources.py
  • tests/unit/specfact_code_review/run/test_findings.py
  • tests/unit/specfact_code_review/run/test_runner.py
  • packages/specfact-code-review/src/specfact_code_review/run/commands.py
  • tests/unit/specfact_code_review/run/test_commands.py
  • packages/specfact-code-review/src/specfact_code_review/rules/updater.py
  • packages/specfact-code-review/src/specfact_code_review/run/findings.py
tests/**/*.py

⚙️ CodeRabbit configuration file

tests/**/*.py: Contract-first and integration tests: migration suites, bundle validation, and flakiness.
Ensure changes to adapters or bridges have targeted coverage.

Files:

  • tests/unit/specfact_code_review/rules/test_updater.py
  • tests/unit/test_guided_simplify_resources.py
  • tests/unit/specfact_code_review/run/test_findings.py
  • tests/unit/specfact_code_review/run/test_runner.py
  • tests/unit/specfact_code_review/run/test_commands.py
packages/**/module-package.yaml

⚙️ CodeRabbit configuration file

packages/**/module-package.yaml: Validate metadata: name, version, commands, dependencies, and parity with packaged src.
Call out semver and signing implications when manifests or payloads change.

Files:

  • packages/specfact-code-review/module-package.yaml
  • packages/specfact-project/module-package.yaml
openspec/**/*.md

⚙️ CodeRabbit configuration file

openspec/**/*.md: Specification truth: proposal/tasks/spec deltas vs. bundle behavior, CHANGE_ORDER, and
drift vs. shipped modules or docs.

Files:

  • openspec/changes/code-review-12-guided-simplification-enforcement/specs/review-run-command/spec.md
  • openspec/changes/code-review-12-guided-simplification-enforcement/TDD_EVIDENCE.md
packages/**/src/**/*.py

⚙️ CodeRabbit configuration file

packages/**/src/**/*.py: Focus on adapter and bridge patterns: imports from specfact_cli (models, runtime, validators),
Typer/Rich command surfaces, and clear boundaries so core upgrades do not silently break bundles.
Flag breaking assumptions about registry loading, lazy imports, and environment/mode behavior.

Files:

  • packages/specfact-code-review/src/specfact_code_review/run/commands.py
  • packages/specfact-code-review/src/specfact_code_review/rules/updater.py
  • packages/specfact-code-review/src/specfact_code_review/run/findings.py
🪛 LanguageTool
openspec/changes/code-review-12-guided-simplification-enforcement/TDD_EVIDENCE.md

[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...st_guided_simplify_resources.py -q` - Result after strict metadata fallout fix: 125 ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~23-~23: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...w/tools/test_ai_bloat_runner.py -q - Result after final cleanup: 50 passed. -hatc...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~25-~25: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...passed. - hatch run contract-test - Result after PR review fixes: 758 passed, 2 wa...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~39-~39: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mp --version-check-base origin/dev` - Result after PR review fixes: verified 6 modul...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~41-~41: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...t/code-review.json --scope changed` - Result after PR review fixes: PASS, CI exit 0,...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🔇 Additional comments (4)
tests/unit/specfact_code_review/run/test_commands.py (1)

6-6: LGTM!

Also applies to: 19-25, 38-67, 358-437

packages/specfact-code-review/src/specfact_code_review/rules/updater.py (1)

43-44: LGTM!

packages/specfact-code-review/src/specfact_code_review/run/findings.py (1)

370-371: LGTM!

openspec/changes/code-review-12-guided-simplification-enforcement/TDD_EVIDENCE.md (1)

9-12: LGTM!

Also applies to: 18-21, 25-25, 39-39, 41-41

Comment thread packages/specfact-code-review/src/specfact_code_review/run/commands.py Outdated
@djm81 djm81 merged commit 1174242 into dev May 23, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in SpecFact CLI May 23, 2026
@djm81 djm81 mentioned this pull request May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codebase Specfact codebase related topic enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Change] Guided simplification enforcement for code review

1 participant