Skip to content

Feature/code review ai bloat detection#270

Merged
djm81 merged 5 commits into
devfrom
feature/code-review-ai-bloat-detection
May 17, 2026
Merged

Feature/code review ai bloat detection#270
djm81 merged 5 commits into
devfrom
feature/code-review-ai-bloat-detection

Conversation

@djm81
Copy link
Copy Markdown
Contributor

@djm81 djm81 commented May 17, 2026

Summary

Introduce AI code bloat detection and review with --fix parameter to remove the moat.

Refs:

  • specfact-cli issue: #
  • related module migration item/change: #

Scope

  • Bundle source changes under packages/
  • Registry/manifest changes (registry/index.json, packages/*/module-package.yaml)
  • CI/workflow changes (.github/workflows/*)
  • Documentation changes (docs/*, README.md, AGENTS.md)
  • Security/signing changes (scripts/sign-modules.py, scripts/verify-modules-signature.py)

Bundle Impact

List impacted bundles and version updates:

  • nold-ai/specfact-project: old -> new
  • nold-ai/specfact-backlog: old -> new
  • nold-ai/specfact-codebase: old -> new
  • nold-ai/specfact-spec: old -> new
  • nold-ai/specfact-govern: old -> new

Validation Evidence

Paste command output snippets or link workflow runs.

Required local gates

  • hatch run format
  • hatch run type-check
  • hatch run lint
  • hatch run yaml-lint
  • hatch run check-bundle-imports
  • hatch run contract-test
  • hatch run smart-test (or hatch run test)

Signature + version integrity (required)

  • hatch run verify-modules-signature --payload-from-filesystem --enforce-version-bump passes (matches PRs targeting dev)
  • If this PR targets main, also confirmed: hatch run verify-modules-signature --require-signature --payload-from-filesystem --enforce-version-bump (and/or approval triggered sign-modules-on-approval for same-repo PRs)
  • Changed bundle versions were bumped when module payloads changed
  • Manifests signed when required by your target branch (CI may sign on approval for dev/main same-repo PRs)

CI and Branch Protection

  • PR orchestrator jobs expected:
    • verify-module-signatures
    • sign-modules-on-approval (on approval, same-repo PRs to dev/main only)
    • quality (3.11)
    • quality (3.12)
    • quality (3.13)
  • Branch protection required checks are aligned with the above

Docs / Pages

  • Bundle/module docs updated in this repo (docs/)
  • Pages workflow impact reviewed (docs-pages.yml, if changed)
  • Cross-links from specfact-cli docs updated (if applicable)

Checklist

  • Self-review completed
  • No unrelated files or generated artifacts included
  • Backward-compatibility/rollout notes documented (if needed)

omit-test added 3 commits May 17, 2026 23:28
Introduces ai_bloat as a sixth principle category in the code-review
pipeline alongside naming/kiss/yagni/dry/solid/clean_code/architecture.
Adds a packaged semgrep rule pack for pattern-shape detectors, an AST
runner for semantic detectors, a parallel ai-bloat-patterns policy pack,
and a /specfact.08-simplify slash-command prompt that drives LLM-mediated
rewrites with per-change human confirmation.

Findings are advisory-only; pre-commit warns but never blocks.

Tracks: #269 (sub-issue of Feature #175 under Modules Epic #162).
Extends tasks.md with section 8 covering root README callout, quickstart
walkthrough with before/after evidence, modules.specfact.io homepage
callout, follow-up tracking issue for the core specfact-cli README, and
explicit honest-framing guardrails ("bloat detection tuned for the shapes
AI code commonly produces" — never an is-this-AI classifier).

Section 9 absorbs the original passing-evidence section. Proposal Impact
section updated to reflect the broader docs scope.

Tracks: #269.
@djm81 djm81 self-assigned this May 17, 2026
@djm81 djm81 added codebase Specfact codebase related topic change-proposal Proposal for a new change labels May 17, 2026
@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 17, 2026

Review Change Stack

📝 Walkthrough

Overview

Specification PR adding an ai_bloat code-review detection principle: design, spec, policy-pack, semgrep rules, AST runner, IDE prompt, tests, and implementation checklist. Documentation-only change (no implementation code yet).

Bundle and module surface

Affected/mentioned bundles/modules (expected packaging changes):

  • specfact-code-review: add semgrep pack, AST runner, policy pack (patch bump).
  • specfact-project: add slash-command prompt resource (patch bump).
  • Also listed as impacted (placeholders): specfact-backlog, specfact-spec, specfact-govern, nold-ai/specfact-project, nold-ai/specfact-codebase — update manifests as appropriate when implementing.

New module surface items:

  • Principle/category: ai_bloat (accepted on ReviewFinding.category/principle).
  • Semgrep rule pack: resources/semgrep-rules/ai-bloat.yaml (≈5 pattern-shape rules; rule IDs ai-bloat.*).
  • AST runner: src/specfact_code_review/tools/ai_bloat_runner.py (semantic detectors for patterns semgrep cannot cover).
  • Policy pack: resources/policy-packs/specfact/ai-bloat-patterns.yaml (principle: ai_bloat, default_mode: advisory).
  • IDE slash-command prompt: resources/prompts/specfact.08-simplify.md — reads .specfact/code-review.json, filters category==ai_bloat, walks edits with per-change accept/reject/skip/explain, never auto-apply.
  • Pre-commit behavior: pre-commit should surface ai_bloat findings as info-only and not fail the hook when only ai_bloat advisories exist.

Behavior vs specfact-cli APIs:

  • No CLI API changes required; specfact-cli's code-review runner and ReviewFinding transport accept new category values and will pick up new modules once republished.
  • The pre-commit hook / code-review run must preserve info-level ai_bloat findings into .specfact/code-review.json for the simplify prompt to consume.

Commands/adapters impact:

  • semgrep_runner must map new rule IDs (ai-bloat.*) into SEMGREP_RULE_CATEGORY mapping.
  • ai_bloat_runner must emit findings compatible with existing ReviewFinding schema (category/principle=ai_bloat, severity=info).

Manifest and integrity

Module-package and registry impacts:

  • Each affected module must update module-package.yaml to declare new resource files and bump semver (patch) for added resources and docs.
  • Additions to module payload: semgrep pack, policy pack, AST runner file, prompt resource — paths must be listed in module-package.yaml.
  • Expected version updates annotated in PR (placeholders for old→new versions).

Signature and verification:

  • verify-modules-signature must be run during CI; signature/version integrity requirements described in PR:
    • verify-modules-signature job required as a validation gate.
    • Signing expected on merge/approval (sign-modules-on-approval job).
    • Requirements differ for targeting dev vs main branches (stronger integrity checks when targeting main).
  • CI/branch-protection jobs expected: verify-module-signatures, sign-modules-on-approval, quality (3.11–3.13 matrix).

Registry/manifest consequences:

  • Registry listings (modules.specfact.io) must include new resources and documentation links in module metadata.
  • Ensure bundle_dependencies / pip_dependencies remain consistent (semgrep, radon, stdlib dependencies currently adequate per proposal).

Cross-repo: specfact-cli and imports/contracts

Specfact-cli impacts:

  • No schema change; ai_bloat is a new accepted principle/category string but no type changes required.
  • Pre-commit and code-review hooks in specfact-cli repo must be coordinated to ensure ai_bloat advisories aren't filtered out (note: amend pre-commit hook to not drop info-level ai_bloat findings when using --level error filters).
  • Update semgrep_runner/SEMGREP_RULE_CATEGORY registration in specfact-cli modules to include ai-bloat.* IDs and ensure contract tests validate mapping.

Contract/test expectations:

  • Contract-test: every rule ID referenced in ai-bloat-patterns.yaml must exist in semgrep pack or be emitted by AST runner.
  • AST runner must emit ReviewFinding entries with category/principle=ai_bloat and severity=info.
  • Integration tests: pre-commit failing-then-passing flow for advisory-only findings; slash-command end-to-end fixture.

Dev-deps and path assumptions:

  • Implementation assumes existing dev-deps (semgrep, radon) available; add any additional tooling to module dev-deps and module-package.yaml if required.
  • Cross-repo follow-ups: open issue in specfact-cli to update core docs and any CLI help referencing the new slash-command.

Documentation

Docs to add/update:

  • modules.specfact.io (module payload pages): new ai_bloat principle reference, detectors table, advisory semantics, prompt walkthrough, examples of findings and suggested rewrites.
  • Update clean-code policy-pack docs to mention ai-bloat-patterns.yaml as a parallel, independently-enabled pack with advisory default.
  • Root README: one-paragraph feature callout and link to quickstart.
  • Add quickstart: install → run code-review → inspect ai_bloat findings → run /specfact.08-simplify → re-run review.
  • TDD_EVIDENCE.md: capture evidence numbers (findings, LOC deltas, timestamps) for marketing & quality gates.
  • Pages/workflow: update pages workflow impact (pages build may need to include new docs) and cross-links from specfact-cli docs.

Documentation URL contract:

  • Modules must include documentation-url metadata pointing to the new docs pages; landing page copy must be "honest framing" (not an AI-authorship classifier).

OpenSpec metadata & scenario coverage

OpenSpec change ID: code-review-ai-bloat-detection (design/spec/tasks included).

Scenario coverage required by spec.md (high level):

  • Semgrep and AST emit ai_bloat findings at category=ai_bloat, severity=info.
  • Simplified equivalents do not trigger findings.
  • Pre-commit surfaces findings without blocking commits for info-only advisories.
  • Policy-pack contract validates rule IDs map to existing detectors.
  • Slash-command filters by category and enforces per-change confirmation; no autonomous edits.
  • Rewrite suggestions reference rule ID and provide actionable hints.
  • Tests: semgrep fixtures, AST-runner fixtures, policy-pack contract test, integration pipeline test asserting advisory-only behavior.

Implementation readiness / Tasks

tasks.md enumerates steps: GitHub scaffolding, spec-first failing tests, semgrep/AST implementation, policy-pack, pre-commit hook update, slash-command authoring, docs, evidence capture, CI/signing, and PR completion checklist (self-review, no unrelated files, backward-compat notes). All tasks are blocking; no implementation code present in this PR.

CI / Branch protection (summary)

Required CI jobs and gates (as listed in PR):

  • Local checks: format, type-check, lint, yaml-lint, check-bundle-imports, contract-test, smart-test/test.
  • CI jobs: verify-module-signatures, sign-modules-on-approval, quality (Python 3.11–3.13).
  • Branch protection should require verify-module-signatures and quality before merging; signing job upon approval.

Walkthrough

Adds a complete specification, proposal, and task checklist for a new ai_bloat code-review principle: semgrep and AST detectors emit advisory ai_bloat findings, a parallel policy-pack enforces advisory-only semantics, and an interactive IDE /specfact.08-simplify prompt drives per-change confirmation for suggested simplifications.

Changes

AI Bloat Detection Feature Specification

Layer / File(s) Summary
Feature Design and Architecture
openspec/changes/code-review-ai-bloat-detection/design.md
Defines ai_bloat goals and non-goals, dual detector strategy (semgrep + AST), rule/ID catalog and rewrite hints, standardized finding metadata (category/principle=ai_bloat, severity=info), the specfact.08-simplify prompt workflow (filter .specfact/code-review.json to ai_bloat, group findings, present drafts, require per-change accept/reject/skip/explain, no autonomous edits), and risks/mitigations.
Proposal and Impact Analysis
openspec/changes/code-review-ai-bloat-detection/proposal.md
Formal proposal introducing ai_bloat principle, required resources (semgrep pack, AST runner, ai-bloat-patterns.yaml policy pack), capability registration, tests/docs scope, and source-tracking metadata.
Formal Specification Requirements
openspec/changes/code-review-ai-bloat-detection/specs/code-review-ai-bloat-detection/spec.md
Exact requirements: runner must accept ai_bloat findings with severity=info, ship resources/semgrep-rules/ai-bloat.yaml and src/specfact_code_review/tools/ai_bloat_runner.py, register ai-bloat-patterns.yaml with default_mode: advisory, include contract tests, and supply resources/prompts/specfact.08-simplify.md with interactive per-change confirmation behavior.
Implementation Checklist and Execution Plan
openspec/changes/code-review-ai-bloat-detection/tasks.md
TDD checklist: GitHub readiness, spec-first failing tests (semgrep/AST/policy-pack/integration), semgrep pack and AST runner implementation, policy-pack/manifest updates, pre-commit hook behavior to preserve ai_bloat advisories, prompt authoring and registration, docs and showcase deliverables, quality gates and TDD evidence collection.
Change Registration and Development Setup
openspec/CHANGE_ORDER.md, .gitignore
New CHANGE_ORDER.md row registering code-review-ai-bloat-detection; .gitignore updated to ignore .vscode/ workspace files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Suggested labels

documentation

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The pull request title does not follow the Conventional Commits-style prefix requirement. Rename the pull request title to use a Conventional Commits-style prefix, such as 'feat: code review AI bloat detection' or 'feat: add AI bloat detection to code review pipeline'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description follows the required template structure with all major sections present and mostly complete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/code-review-ai-bloat-detection

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

@djm81 djm81 changed the base branch from main to dev May 17, 2026 21:41
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: 7900a99423

ℹ️ 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".

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 (3)
openspec/changes/code-review-ai-bloat-detection/design.md (1)

29-31: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Same counting error in Decision 1 heading.

The decision rationale repeats "sixth principle category" when the context establishes seven existing categories.

📊 Proposed fix
-### Decision 1: Introduce `ai_bloat` as a sixth principle category, not a sub-mode of `kiss`/`yagni`
+### Decision 1: Introduce `ai_bloat` as a new principle category, not a sub-mode of `kiss`/`yagni`
🤖 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 `@openspec/changes/code-review-ai-bloat-detection/design.md` around lines 29 -
31, The heading for Decision 1 incorrectly says "sixth principle category" even
though the context lists seven existing categories; update the Decision 1 text
to reference the correct ordinal (e.g., "eighth" or "seventh" as appropriate) or
rephrase to avoid ordinal counting; change the sentence that mentions "sixth
principle category" (near the Decision 1 heading and the sentence that starts
with "The detectors target...") to use the correct ordinal or a non-counting
phrase and keep the references to the new `ai_bloat` category and existing
`kiss`/`yagni` modes intact so `ai_bloat`, `kiss`, and `yagni` remain clearly
named.
openspec/changes/code-review-ai-bloat-detection/proposal.md (1)

18-18: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Category count mismatch: proposal claims "sixth" but context lists seven existing.

Line 3 enumerates seven existing principle categories, making ai_bloat the eighth (or "new"), not sixth. This repeats the counting error from design.md and creates spec inconsistency.

📊 Proposed fix
-- **NEW**: Introduce `ai_bloat` as a sixth principle category alongside `naming | kiss | yagni | dry | solid | clean_code`, surfaced through the existing `ReviewFinding` transport and `.specfact/code-review.json` evidence file. Findings are emitted at `advisory` severity only; they never block commits.
+- **NEW**: Introduce `ai_bloat` as a new principle category alongside `naming | kiss | yagni | dry | solid | clean_code | architecture`, surfaced through the existing `ReviewFinding` transport and `.specfact/code-review.json` evidence file. Findings are emitted at `advisory` severity only; they never block commits.
🤖 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 `@openspec/changes/code-review-ai-bloat-detection/proposal.md` at line 18, The
sentence introducing ai_bloat misstates its ordinal — the prose says "sixth" but
the preceding list contains seven existing categories, so ai_bloat would be the
eighth; update the wording to the correct ordinal (e.g., change "sixth" to
"eighth" or rework the list so there are actually six before adding ai_bloat)
and make the same correction wherever `ai_bloat`, `ReviewFinding`,
`.specfact/code-review.json`, or `design.md` refer to "sixth" to keep the spec
consistent.
openspec/changes/code-review-ai-bloat-detection/specs/code-review-ai-bloat-detection/spec.md (1)

96-96: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Specification claims "six categories" but defines seven earlier.

Line 7 lists seven existing categories (naming | kiss | yagni | dry | solid | clean_code | architecture), yet line 96 states ai_bloat is "distinct from the existing six categories." This inconsistency in the MODIFIED requirement contradicts the specification's own enumeration.

📊 Proposed fix
-- **AND** SHALL state that its principle category is `ai_bloat`, distinct from the existing six categories
+- **AND** SHALL state that its principle category is `ai_bloat`, distinct from the existing categories
🤖 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
`@openspec/changes/code-review-ai-bloat-detection/specs/code-review-ai-bloat-detection/spec.md`
at line 96, The spec incorrectly states "existing six categories" while the
earlier enumeration lists seven categories (naming | kiss | yagni | dry | solid
| clean_code | architecture); update the text that references the count so it
matches the enumeration or adjust the enumeration to six. Specifically, change
the phrase that says "existing six categories" to "existing seven categories"
(or remove/modify a category in the list) so that the `ai_bloat` requirement and
the listed categories are consistent; ensure the terms `ai_bloat` and the
category list (naming | kiss | yagni | dry | solid | clean_code | architecture)
are reconciled.
🤖 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-ai-bloat-detection/design.md`:
- Around line 5-14: The document miscounts existing categories as "six" while
listing seven (`naming`, `kiss`, `yagni`, `dry`, `solid`, `clean_code`,
`architecture`), so update the text to state the correct ordinal (either
"eighth" if adding `ai_bloat` to become eight, or "sixth/seventh" depending on
intended target) and make the same correction wherever "sixth" appears;
specifically reference the ReviewFinding category set and replace each incorrect
"sixth" occurrence with the accurate ordinal and ensure the new `ai_bloat`
addition to the ReviewFinding accepted values is described consistently with the
listed categories.

---

Duplicate comments:
In `@openspec/changes/code-review-ai-bloat-detection/design.md`:
- Around line 29-31: The heading for Decision 1 incorrectly says "sixth
principle category" even though the context lists seven existing categories;
update the Decision 1 text to reference the correct ordinal (e.g., "eighth" or
"seventh" as appropriate) or rephrase to avoid ordinal counting; change the
sentence that mentions "sixth principle category" (near the Decision 1 heading
and the sentence that starts with "The detectors target...") to use the correct
ordinal or a non-counting phrase and keep the references to the new `ai_bloat`
category and existing `kiss`/`yagni` modes intact so `ai_bloat`, `kiss`, and
`yagni` remain clearly named.

In `@openspec/changes/code-review-ai-bloat-detection/proposal.md`:
- Line 18: The sentence introducing ai_bloat misstates its ordinal — the prose
says "sixth" but the preceding list contains seven existing categories, so
ai_bloat would be the eighth; update the wording to the correct ordinal (e.g.,
change "sixth" to "eighth" or rework the list so there are actually six before
adding ai_bloat) and make the same correction wherever `ai_bloat`,
`ReviewFinding`, `.specfact/code-review.json`, or `design.md` refer to "sixth"
to keep the spec consistent.

In
`@openspec/changes/code-review-ai-bloat-detection/specs/code-review-ai-bloat-detection/spec.md`:
- Line 96: The spec incorrectly states "existing six categories" while the
earlier enumeration lists seven categories (naming | kiss | yagni | dry | solid
| clean_code | architecture); update the text that references the count so it
matches the enumeration or adjust the enumeration to six. Specifically, change
the phrase that says "existing six categories" to "existing seven categories"
(or remove/modify a category in the list) so that the `ai_bloat` requirement and
the listed categories are consistent; ensure the terms `ai_bloat` and the
category list (naming | kiss | yagni | dry | solid | clean_code | architecture)
are reconciled.
🪄 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: 0ffd5b0a-e714-438f-bb73-ec8f54b5bc19

📥 Commits

Reviewing files that changed from the base of the PR and between db6dd66 and 7900a99.

📒 Files selected for processing (6)
  • .gitignore
  • openspec/CHANGE_ORDER.md
  • openspec/changes/code-review-ai-bloat-detection/design.md
  • openspec/changes/code-review-ai-bloat-detection/proposal.md
  • openspec/changes/code-review-ai-bloat-detection/specs/code-review-ai-bloat-detection/spec.md
  • openspec/changes/code-review-ai-bloat-detection/tasks.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: quality (3.11)
  • GitHub Check: quality (3.12)
  • GitHub Check: quality (3.13)
🧰 Additional context used
📓 Path-based instructions (1)
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/CHANGE_ORDER.md
  • openspec/changes/code-review-ai-bloat-detection/specs/code-review-ai-bloat-detection/spec.md
  • openspec/changes/code-review-ai-bloat-detection/tasks.md
  • openspec/changes/code-review-ai-bloat-detection/proposal.md
  • openspec/changes/code-review-ai-bloat-detection/design.md
🪛 LanguageTool
openspec/changes/code-review-ai-bloat-detection/specs/code-review-ai-bloat-detection/spec.md

[locale-violation] ~71-~71: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects.
Context: ...tool, and suggest re-running the review afterwards. The prompt SHALL NOT edit files autono...

(AFTERWARDS_US)

openspec/changes/code-review-ai-bloat-detection/tasks.md

[uncategorized] ~5-~5: The official name of this software platform is spelled with a capital “H”.
Context: ...nd change scaffolding - [ ] 1.1 Verify .specfact/backlog/github_hierarchy_cache.md is fresh, confirm t...

(GITHUB)


[locale-violation] ~37-~37: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects.
Context: ... the IDE, and suggest re-running review afterwards. - [ ] 6.2 Add the new command to the p...

(AFTERWARDS_US)

openspec/changes/code-review-ai-bloat-detection/proposal.md

[style] ~22-~22: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... enabled or disabled independently. - NEW: Add an IDE slash-command prompt at `...

(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: ...line against seeded bloat fixtures. - Affected docs: reference docs for the `ai_bloa...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🔇 Additional comments (3)
openspec/CHANGE_ORDER.md (1)

103-103: LGTM!

.gitignore (1)

49-50: LGTM!

openspec/changes/code-review-ai-bloat-detection/tasks.md (1)

1-60: LGTM!

Comment thread openspec/changes/code-review-ai-bloat-detection/design.md 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: 1

🤖 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-ai-bloat-detection/proposal.md`:
- Line 40: The phrase "warn-only" in the release impact sentence is inconsistent
with the rest of the change-set which constrains ai_bloat findings to
severity=info; update the wording to "info-only" and ensure references to the
new resources (`specfact-code-review` and `specfact-project`) state that
`ai_bloat` findings are additive and info-only (never warning/error) so the
sentence aligns with the `ai_bloat` severity contract.
🪄 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: 1974bda5-f14b-446c-ba99-7c9ba6abcb58

📥 Commits

Reviewing files that changed from the base of the PR and between 7900a99 and b7510ec.

📒 Files selected for processing (4)
  • openspec/changes/code-review-ai-bloat-detection/design.md
  • openspec/changes/code-review-ai-bloat-detection/proposal.md
  • openspec/changes/code-review-ai-bloat-detection/specs/code-review-ai-bloat-detection/spec.md
  • openspec/changes/code-review-ai-bloat-detection/tasks.md
✅ Files skipped from review due to trivial changes (1)
  • openspec/changes/code-review-ai-bloat-detection/design.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: quality (3.11)
  • GitHub Check: quality (3.13)
  • GitHub Check: quality (3.12)
🧰 Additional context used
📓 Path-based instructions (1)
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-ai-bloat-detection/proposal.md
  • openspec/changes/code-review-ai-bloat-detection/specs/code-review-ai-bloat-detection/spec.md
  • openspec/changes/code-review-ai-bloat-detection/tasks.md
🪛 LanguageTool
openspec/changes/code-review-ai-bloat-detection/proposal.md

[style] ~22-~22: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... enabled or disabled independently. - NEW: Add an IDE slash-command prompt at `...

(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: ...line against seeded bloat fixtures. - Affected docs: reference docs for the `ai_bloa...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

openspec/changes/code-review-ai-bloat-detection/specs/code-review-ai-bloat-detection/spec.md

[locale-violation] ~72-~72: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects.
Context: ...tool, and suggest re-running the review afterwards. The prompt SHALL NOT edit files autono...

(AFTERWARDS_US)

openspec/changes/code-review-ai-bloat-detection/tasks.md

[uncategorized] ~5-~5: The official name of this software platform is spelled with a capital “H”.
Context: ...nd change scaffolding - [ ] 1.1 Verify .specfact/backlog/github_hierarchy_cache.md is fresh, confirm t...

(GITHUB)


[locale-violation] ~42-~42: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects.
Context: ... the IDE, and suggest re-running review afterwards. - [ ] 6.2 Add the new command to the p...

(AFTERWARDS_US)

🔀 Multi-repo context nold-ai/specfact-cli

nold-ai/specfact-cli — relevant consumers & integration points

  • Semgrep rules/resources (consumed/bundled):

    • tools/semgrep/README.md (docs about tools/semgrep/*.yml and bundling) [::nold-ai/specfact-cli::tools/semgrep/README.md:9,13-17]
    • src/specfact_cli/resources/semgrep/ (packaged semgrep resources referenced from code) [::nold-ai/specfact-cli::src/specfact_cli/resources/semgrep/]
    • pyproject.toml—hatch scripts / CLI shortcuts invoking semgrep configs (scan, scan-all, scan-fix) [::nold-ai/specfact-cli::pyproject.toml:233-236,351]
    • .gitignore / .semgrep entries (packaging / artifacts) [::nold-ai/specfact-cli::.gitignore:124-125]
  • Semgrep runner / extraction / mapping to ReviewFinding:

    • src/specfact_cli/validators/repro_checker.py — semgrep invocation, extraction, and integration into repro checks (_extract_semgrep_findings, _repro_checks_append_semgrep) [::nold-ai/specfact-cli::src/specfact_cli/validators/repro_checker.py:346-355,1003-1030,1116-1121]
    • src/specfact_cli/analyzers/code_analyzer.py — semgrep-driven analysis, finding categorisation, evidence extraction and mapping into features (many helpers: _run_semgrep_patterns, _filter_relevant_semgrep_findings, _categorise_semgrep_finding, _apply_semgrep_findings_to_feature) [::nold-ai/specfact-cli::src/specfact_cli/analyzers/code_analyzer.py:138-146,462-478,555-588,962-1018,1160-1244,1475-1536]
    • openspec/specs/semgrep-runner/spec.md — spec requires semgrep output mapped to List[ReviewFinding] with tool="semgrep" and category="clean_code" (relevant for adding ai_bloat category) [::nold-ai/specfact-cli::openspec/specs/semgrep-runner/spec.md:11-17,21-28]
  • Tests & integration points that will need updates or validation coverage:

    • tests/unit/validators/test_repro_checker.py — unit tests creating semgrep configs and asserting semgrep calls / extraction [::nold-ai/specfact-cli::tests/unit/validators/test_repro_checker.py:267-316]
    • tests/unit/analyzers/test_code_analyzer.py & tests/e2e/test_semgrep_integration_e2e.py — tests verify semgrep env, integration, and processing; adding new rule IDs / category (ai_bloat) may require test fixtures and expectations updates [::nold-ai/specfact-cli::tests/unit/analyzers/test_code_analyzer.py:16-79][::nold-ai/specfact-cli::tests/e2e/test_semgrep_integration_e2e.py:22-78]
    • tests/e2e/test_github_action_workflow.py, tests/integration/... — CI/workflow tests that assert semgrep-driven comments/annotations will be relevant [::nold-ai/specfact-cli::tests/e2e/test_github_action_workflow.py:55-362]
  • Packaging / generation of semgrep rules:

    • src/specfact_cli/importers/speckit_converter.py — generate_semgrep_rules/export and workflow generator references (used by import/generation flows) [::nold-ai/specfact-cli::src/specfact_cli/importers/speckit_converter.py:338-352]
    • src/specfact_cli/generators/workflow_generator.py — generate_semgrep_rules and resource fallback logic (resources vs tools) [::nold-ai/specfact-cli::src/specfact_cli/generators/workflow_generator.py:99-115]
  • Pre-commit / scripts referencing semgrep runtime config:

    • scripts/pre_commit_code_review.py — config of SEMGREP_LOG_FILE and cache paths used by pre-commit review flow (ensure ai_bloat advisories propagate and aren't filtered) [::nold-ai/specfact-cli::scripts/pre_commit_code_review.py:186-188]
    • scripts/license_allowlist.yaml and docs reference semgrep as an allowed dependency (packaging/licensing considerations) [::nold-ai/specfact-cli::scripts/license_allowlist.yaml:39][::nold-ai/specfact-cli::docs/getting-started/installation.md:407]
  • Spec & policy pack places to update for ai_bloat:

    • openspec/specs/clean-code-semgrep-rules/spec.md and other openspec specs reference categories/principles and may need ai_bloat additions or a new ai-bloat-patterns pack (the PR’s proposal to add ai_bloat should align with these specs) [::nold-ai/specfact-cli::openspec/specs/clean-code-semgrep-rules/spec.md:1-16]
    • openspec/specs/semgrep-runner/spec.md requires mapping semgrep output to ReviewFinding — will need acceptance of category="ai_bloat" and severity semantics [::nold-ai/specfact-cli::openspec/specs/semgrep-runner/spec.md:11-17]

Summary assessment

  • The repo already has a mature semgrep integration surface: runner/specs, code that parses semgrep JSON into ReviewFinding-like structures, bundled resources and tests. Adding ai_bloat will require:
    • new semgrep rule files placed under src/specfact_cli/resources/semgrep/ (and/or tools/semgrep/) and packaging updates,
    • updates to categorisation logic/tests to accept category/principle "ai_bloat" and ensure severity/default_mode (advisory/info) semantics are preserved,
    • test fixtures and CI workflow adjustments where semgrep expectations/assertions assume existing categories/rule-ids,
    • policy-pack registration (openspec resources/policy-packs) and any contract tests referencing rule IDs.
🔇 Additional comments (2)
openspec/changes/code-review-ai-bloat-detection/specs/code-review-ai-bloat-detection/spec.md (1)

5-98: LGTM!

openspec/changes/code-review-ai-bloat-detection/tasks.md (1)

11-65: LGTM!

Comment thread openspec/changes/code-review-ai-bloat-detection/proposal.md 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: 1

🤖 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-ai-bloat-detection/proposal.md`:
- Around line 35-41: Add an explicit note about required cross-repo coordination
with specfact-cli: update the Impact section to state that specfact-cli must be
updated to accept the new ai_bloat category, including changes to the
category-mapping logic in code_analyzer.py (the category-mapping block that
currently enumerates expected categories), the semgrep_runner.py rule/spec that
enforces category="clean_code" (to allow category="ai_bloat"), and related test
fixtures that assert category values; mention tests and provide or link to the
tracking issue for those specfact-cli changes.
🪄 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: ea283118-3f13-4996-96e1-5f14e9efee20

📥 Commits

Reviewing files that changed from the base of the PR and between b7510ec and 9874bd7.

📒 Files selected for processing (1)
  • openspec/changes/code-review-ai-bloat-detection/proposal.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: quality (3.13)
  • GitHub Check: quality (3.12)
  • GitHub Check: quality (3.11)
🧰 Additional context used
📓 Path-based instructions (1)
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-ai-bloat-detection/proposal.md
🪛 LanguageTool
openspec/changes/code-review-ai-bloat-detection/proposal.md

[style] ~22-~22: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... enabled or disabled independently. - NEW: Add an IDE slash-command prompt at `...

(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: ...line against seeded bloat fixtures. - Affected docs: reference docs for the `ai_bloa...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🔀 Multi-repo context nold-ai/specfact-cli

nold-ai/specfact-cli — findings

  • No existing ai_bloat identifiers found (search returned no matches). [::nold-ai/specfact-cli::]
  • Semgrep rules directory present: src/specfact_cli/resources/semgrep (contains async.yml, code-quality.yml, feature-detection.yml) — new ai-bloat.yaml should be placed/packaged here. [::nold-ai/specfact-cli::src/specfact_cli/resources/semgrep/]
  • Semgrep-runner spec enforces mapping semgrep → List[ReviewFinding] with category="clean_code" (spec.md header). Adding ai_bloat requires updating spec or allowing category="ai_bloat". [::nold-ai/specfact-cli::openspec/specs/semgrep-runner/spec.md]
  • Semgrep extraction/parsing is implemented in _extract_semgrep_findings and callers:
    • src/specfact_cli/validators/repro_checker.py::_extract_semgrep_findings (parsing JSON/text → structured findings). New rule IDs will be consumed here. [::nold-ai/specfact-cli::src/specfact_cli/validators/repro_checker.py:346]
    • src/specfact_cli/analyzers/code_analyzer.py contains semgrep helpers and categorisation: _run_semgrep_patterns, _filter_relevant_semgrep_findings, and category-mapping logic (many category checks currently expect existing categories like "clean_code", "api", etc.). These locations likely need updates to accept/category-map ai_bloat and ensure severity/default_mode semantics. [::nold-ai/specfact-cli::src/specfact_cli/analyzers/code_analyzer.py:555,962,1195-1228]
  • Tests reference semgrep and category expectations and will need fixture/spec updates:
    • tests/unit/analyzers/test_code_analyzer.py (semgrep runner tests). [::nold-ai/specfact-cli::tests/unit/analyzers/test_code_analyzer.py:1-90]
    • tests/e2e/test_semgrep_integration_e2e.py and other e2e/CI tests that assert semgrep-driven findings/workflow. [::nold-ai/specfact-cli::tests/e2e/test_semgrep_integration_e2e.py]
    • tests/unit/specfact_cli/test_clean_code_principle_gates.py (clean-code principle gates/pack references). Policy-pack and principle documentation will need an ai_bloat parallel pack or spec updates. [::nold-ai/specfact-cli::tests/unit/specfact_cli/test_clean_code_principle_gates.py]
  • Policy/spec surfaces referencing clean-code packs/principles are numerous (openspec and .cursor rules). Adding an ai-bloat-patterns policy-pack and updating openspec/specs to accept principle/category "ai_bloat" is required. Examples: .cursor/rules/clean-code-principles.mdc and openspec specs. [::nold-ai/specfact-cli::.cursor/rules/clean-code-principles.mdc][::nold-ai/specfact-cli::openspec/specs/clean-code-semgrep-rules/spec.md]

Implication summary

  • Add semgrep rule file(s) (ai-bloat.yaml) under src/specfact_cli/resources/semgrep (and packaging).
  • Wire new rule IDs into semgrep parsing (repro_checker / code_analyzer) so ReviewFinding.category/principle accepts "ai_bloat" and preserves severity="info"/advisory semantics.
  • Update tests and openspec/policy-pack references to include ai_bloat rule IDs and advisory behavior.
  • Update specs (semgrep-runner and related) if they hardcode/assume category="clean_code".
🔇 Additional comments (1)
openspec/changes/code-review-ai-bloat-detection/proposal.md (1)

40-40: LGTM!

Comment on lines +35 to +41
## Impact

- **Affected code**: `packages/specfact-code-review/` (new runner, new semgrep rules, new policy pack, manifest version bump, runner orchestration wiring); `packages/specfact-project/` (new packaged prompt resource and manifest payload).
- **Affected tests**: targeted unit tests per detector (one fixture pair per heuristic), semgrep rule fixture tests, policy-pack reference contract tests, and an integration test that exercises the end-to-end review pipeline against seeded bloat fixtures.
- **Affected docs**: reference docs for the `ai_bloat` category, the slash command, and the `advisory`-only model under code-review and review-run on modules.specfact.io, cross-referenced from `clean-code-principles` docs; root `README.md` headline callout; a quickstart walkthrough page demonstrating the end-to-end review → simplify → re-review flow with before/after evidence captured from a real repo; a modules.specfact.io homepage callout. All marketing copy uses the framing "bloat detection tuned for the shapes AI code commonly produces" and does not claim AI-authorship classification. A parallel callout in the core `specfact-cli` README is tracked as a follow-up issue out of scope for this PR.
- **Release impact**: patch version bumps and signature/registry updates for `specfact-code-review` (new resources) and `specfact-project` (new prompt resource); no breaking change to existing finding consumers because `ai_bloat` findings from both packages are purely additive and info-only (emitted at `severity=info`, never `warning` or `error`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Document the required cross-repo coordination with specfact-cli.

The Impact section claims "no breaking change to existing finding consumers" (line 40), but linked repository findings show that specfact-cli requires coordinated updates to consume the new ai_bloat category. Specifically:

  • code_analyzer.py has category-mapping logic (lines 1195–1228) that currently expects existing categories and needs updates to accept/category-map ai_bloat
  • semgrep_runner.py spec enforces category="clean_code" and needs updating to allow category="ai_bloat"
  • Test fixtures assert category expectations and will need updates

Without mentioning this cross-repo dependency, the release plan is incomplete and risks shipping modules that emit findings the CLI cannot properly consume.

Recommendation: Add a bullet under "Affected code" or "Release impact" noting that specfact-cli requires coordinated updates (spec, category-mapping, tests) to consume the new category, and link the corresponding tracking issue if one exists.

As per coding guidelines, tone instructions require focus on "specfact_cli impact" and linked repository findings show "Adding ai_bloat requires updating spec or allowing category='ai_bloat'" in specfact-cli.

🧰 Tools
🪛 LanguageTool

[style] ~39-~39: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...line against seeded bloat fixtures. - Affected docs: reference docs for the `ai_bloa...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🤖 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 `@openspec/changes/code-review-ai-bloat-detection/proposal.md` around lines 35
- 41, Add an explicit note about required cross-repo coordination with
specfact-cli: update the Impact section to state that specfact-cli must be
updated to accept the new ai_bloat category, including changes to the
category-mapping logic in code_analyzer.py (the category-mapping block that
currently enumerates expected categories), the semgrep_runner.py rule/spec that
enforces category="clean_code" (to allow category="ai_bloat"), and related test
fixtures that assert category values; mention tests and provide or link to the
tracking issue for those specfact-cli changes.

@djm81 djm81 merged commit f6a1fca into dev May 17, 2026
11 of 12 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in SpecFact CLI May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change-proposal Proposal for a new change codebase Specfact codebase related topic

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant