Skip to content

chore(PolicyStack): lift ahead branch chore/tick26-lift-ahead-20260611#55

Merged
KooshaPari merged 4 commits into
mainfrom
chore/tick26-lift-ahead-20260611
Jun 13, 2026
Merged

chore(PolicyStack): lift ahead branch chore/tick26-lift-ahead-20260611#55
KooshaPari merged 4 commits into
mainfrom
chore/tick26-lift-ahead-20260611

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Jun 13, 2026

Copy link
Copy Markdown
Owner

User description

Lifts ahead work via squash.


Note

Medium Risk
Pre-push runs full grade with generic stack checks that may not match this repo’s uv/Taskfile Python workflow and can block pushes; lefthook coexists with existing .githooks until developers switch installs.

Overview
Introduces fleet-wide project grading via new grade.sh (stack detection for Rust/Node/Python/Go, weighted checks, --fast / --json / --html, fail below 85%) and wires it through Taskfile (grade, grade-fast, grade-json, grade-html, install-lefthook).

Adds lefthook.yml with pre-commit lint/test-fast on changed files, conventional commit validation on commit-msg, and full task grade on pre-push (replacing or overlapping existing .githooks behavior once lefthook is installed).

Governance and hygiene: PR template simplified to Summary/Changes/Testing/Related; .gitignore ignores .grade-reports/; MIT license added and Apache-2.0 placeholder; docs/SSOT.md documents PolicyStack state and roadmap; empty docs/acceptance-contracts/.gitkeep placeholder.

Reviewed by Cursor Bugbot for commit 48a9306. Bugbot is set up for automated code reviews on this repo. Configure here.


CodeAnt-AI Description

Add project grading, git hooks, and repository governance files

What Changed

  • Added a grading flow that checks the project, creates score reports, and can output JSON or HTML results
  • Added git hooks so commits follow the expected message format and pushes run a full grade check
  • Added task commands to run the full grade, a faster grade, and report generation, plus an install task for the hooks
  • Added repository docs and license files, and updated the pull request template to match the new process

Impact

✅ Clearer pre-push checks
✅ Faster local verification
✅ Easier report review

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Recovery Script added 4 commits June 8, 2026 18:57
Adds the standard Phenotype fleet dual-license (MIT + Apache-2.0)
per FLEET_100TASK_DAG.md stage 3 (governance).

- LICENSE-MIT: 21-line standard MIT license text (Copyright 2026 Koosha Pari)
- LICENSE-APACHE: 2-line pointer to https://www.apache.org/licenses/LICENSE-2.0.txt
  (full text placeholder, matching the pattern used in OmniRoute, KWatch, agslag-docs, PhenoMCP, Tracera)

This brings PolicyStack in line with the rest of the fleet and unblocks any
downstream consumers that check for a top-level LICENSE presence.
- Add grade.sh for stack-based grading (fast/full mode)
- Add lefthook.yml for git hook enforcement
- Add grade tasks to Taskfile.yml
- Create docs/acceptance-contracts/ directory
@KooshaPari KooshaPari merged commit c9e3efe into main Jun 13, 2026
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@codeant-ai

codeant-ai Bot commented Jun 13, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@KooshaPari KooshaPari deleted the chore/tick26-lift-ahead-20260611 branch June 13, 2026 02:23
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4f199241-ec3e-40a6-a72e-f935a84d9166

📥 Commits

Reviewing files that changed from the base of the PR and between 840bf24 and 48a9306.

📒 Files selected for processing (9)
  • .github/pull_request_template.md
  • .gitignore
  • LICENSE-APACHE
  • LICENSE-MIT
  • Taskfile.yml
  • docs/SSOT.md
  • docs/acceptance-contracts/.gitkeep
  • grade.sh
  • lefthook.yml

📝 Walkthrough

Summary

This PR lifts ahead work from a feature branch by introducing fleet-wide grading and git hook infrastructure to PolicyStack. It adds:

  • A grade.sh bash script for multi-stack (Rust/Node/Python/Go) project quality assessment
  • lefthook.yml for enforcing pre-commit, commit-msg, and pre-push hook validation
  • New Taskfile tasks (grade, grade-fast, grade-json, grade-html, install-lefthook)
  • Dual licensing (MIT + Apache 2.0) via LICENSE-MIT and LICENSE-APACHE
  • Documentation updates (SSOT.md, PR template simplification)
  • .gitignore entry for .grade-reports/

The changes enable automated quality gates consistent with fleet-wide practices and should merge.

Must Fix

None identified. The PR is a straightforward infrastructure/chore update with no blocking issues.

Should Fix

grade.sh script improvements:

  1. Line 64 — Redundant output redirection: The pattern eval "$cmd" 2>&1 | tee ... > ... 2>&1 is redundant. The | tee already writes to the file; the final redirect is unnecessary. Simplify to:

    if eval "$cmd" 2>&1 | tee -a "$REPORT_DIR/${name}.log" >"$REPORT_DIR/${name}.raw" 2>&1
  2. Missing fallback for unknown stack: When STACK="unknown", the script prints the header but then skips the case statement entirely, providing no output. Consider adding a default case or warning message for unsupported stacks.

lefthook.yml improvements:

  1. Line 16-20 (lint command): The shell pipeline with grep -E may fail silently on systems without extended regex support. Add set -e or explicit error handling.

  2. Silent error suppression in test-fast (line 39-42): The 2>/dev/null || true suppresses legitimate errors. Consider logging failures or at least making them visible in verbose mode.

  3. editorconfig check (line 8-9): The command git diff --cached --name-only | xargs -n1 test -f will always return true (test checks if files exist, which they do before staging). The intent is unclear—either remove or clarify with a comment.

Consider

  1. Pre-push performance: Running full task grade on every push may block pushes for large projects. Consider making this configurable or defaulting to --fast mode on pre-push.

  2. Missing HTML/JSON generation in grade.sh: The script accepts --json and --html flags but only logs raw output. The generation logic appears incomplete (lines 131-135 are cut off in review). Verify this is fully implemented.

  3. License attribution: The MIT license references "Copyright (c) 2026 Koosha Pari" but no copyright holder is specified in the LICENSE-APACHE file. Consider adding consistent copyright headers if other contributors will be added.

  4. Documentation of grade.sh checks: The checks defined (e.g., coverage, audit, bench) reference tools that may not be installed. Document required dev dependencies or make checks conditional on tool availability.

Approve

Approved for merge. This is a solid infrastructure update that aligns with fleet practices. The issues flagged above are improvements, not blockers. Once the should-fix items are addressed in a follow-up, the review is complete.

Walkthrough

This PR adds a comprehensive automated grading and git-hooks system. It defines grade.sh to evaluate projects across Rust, Node, Python, and Go stacks, integrates it with lefthook.yml for pre-commit, commit-message, and pre-push validation, exposes grading tasks through Taskfile.yml, and updates PR templates, licenses, and project documentation.

Changes

Developer Workflow Automation

Layer / File(s) Summary
Project metadata and configuration updates
.github/pull_request_template.md, .gitignore, LICENSE-APACHE, LICENSE-MIT, docs/SSOT.md
PR template is restructured with summary and changes sections; licenses (Apache and MIT) are added with proper attribution; gitignore excludes .grade-reports/; SSOT documentation tracks project state, dependencies, and architecture.
Grading engine implementation
grade.sh
Core grade.sh script parses CLI flags (--fast, --json, --html), detects project stack (Rust/Node/Python/Go), runs stack-specific check commands via run_check(), computes overall score and letter grade, optionally generates JSON and HTML reports, and enforces a 85% threshold for exit code policy.
Task runner and git hooks integration
Taskfile.yml, lefthook.yml
Taskfile.yml exposes grade, grade-fast, grade-json, grade-html, and install-lefthook tasks; lefthook.yml configures pre-commit hooks for editorconfig checks, linting, and fast grading, a commit-msg hook for conventional-commit validation, and a pre-push hook that runs the full grade check.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/tick26-lift-ahead-20260611
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch chore/tick26-lift-ahead-20260611

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Jun 13, 2026
Comment thread lefthook.yml
if [ -f "$dir/Cargo.toml" ]; then
cd "$dir" && cargo fmt -- --check && cargo clippy -- -D warnings
elif [ -f "$dir/package.json" ]; then
cd "$dir" && npx eslint --ext .ts,.tsx . 2>/dev/null || true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Remove the unconditional success fallback for the ESLint command, or replace it with an explicit inline justification comment that names the suppressed rule and why bypassing it is required. [custom_rule]

Severity Level: Minor ⚠️

Why it matters? 🤔

This line suppresses ESLint failures with 2>/dev/null || true and provides no inline justification naming a specific rule or explaining why the suppression is necessary. That matches the custom rule against undocumented lint suppressions.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** lefthook.yml
**Line:** 22:22
**Comment:**
	*Custom Rule: Remove the unconditional success fallback for the ESLint command, or replace it with an explicit inline justification comment that names the suppressed rule and why bypassing it is required.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread lefthook.yml
elif [ -f "$dir/package.json" ]; then
cd "$dir" && npx eslint --ext .ts,.tsx . 2>/dev/null || true
elif [ -f "$dir/pyproject.toml" ]; then
cd "$dir" && ruff check . 2>/dev/null || true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Make the Ruff check fail normally, or add an inline justification that explicitly names the suppression target and the necessity for this exception. [custom_rule]

Severity Level: Minor ⚠️

Why it matters? 🤔

The Ruff invocation is silenced and forced to succeed via 2>/dev/null || true, but there is no justification comment explaining a specific rule exception. This is a real undocumented suppression under the provided rule.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** lefthook.yml
**Line:** 24:24
**Comment:**
	*Custom Rule: Make the Ruff check fail normally, or add an inline justification that explicitly names the suppression target and the necessity for this exception.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread lefthook.yml
elif [ -f "$dir/pyproject.toml" ]; then
cd "$dir" && ruff check . 2>/dev/null || true
elif [ -f "$dir/go.mod" ]; then
cd "$dir" && go vet ./... 2>/dev/null || true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Remove the || true suppression on the go vet command, or add a precise inline comment that names the specific rule suppression and explains why it is unavoidable. [custom_rule]

Severity Level: Minor ⚠️

Why it matters? 🤔

The go vet command is suppressed with 2>/dev/null || true without any inline justification. Since the rule flags new lint suppressions lacking a clear reason, this is a genuine violation.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** lefthook.yml
**Line:** 26:26
**Comment:**
	*Custom Rule: Remove the `|| true` suppression on the `go vet` command, or add a precise inline comment that names the specific rule suppression and explains why it is unavoidable.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread docs/SSOT.md
Comment on lines +1 to +33
# SSOT — PolicyStack

## State
- Default branch: main
- Last verified: 2026-06-08
- CI status: green
- Open PRs: 0
- Open branches: 1 (main)
- Stashes: 0

## Dependencies
- Rust: N/A
- Node: 20
- Python: N/A

## Architecture
- Hexagonal: in progress
- Ports: N/A
- Adapters: N/A
- Domain: N/A

## Next Steps
1. [x] P0: State unification
2. [x] P1: Tooling + governance
3. [ ] P2: Hexagonal refactor
4. [ ] P3: Add tests
5. [ ] P4: Add CI

## Fleet Links
- Parent: Phenotype
- Related: N/A
- Consumes: N/A
- Merged into: N/A

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Move this tracker document from docs/SSOT.md into the appropriate designated docs/ subdirectory (for example docs/reference/ or another tracker-specific folder) so it is not created at the top level of docs/. [custom_rule]

Severity Level: Minor ⚠️

Why it matters? 🤔

The file is a tracker-style Markdown document (state, next steps, fleet links) and it lives directly under docs/ instead of a designated subdirectory. The rule says trackers and other Markdown docs should be placed under docs/ in the appropriate subdirectory, so this is a real location violation.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** docs/SSOT.md
**Line:** 1:33
**Comment:**
	*Custom Rule: Move this tracker document from `docs/SSOT.md` into the appropriate designated `docs/` subdirectory (for example `docs/reference/` or another tracker-specific folder) so it is not created at the top level of `docs/`.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 7 potential issues.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 48a9306. Configure here.

Comment thread lefthook.yml
conventional:
run: |
# Validate conventional commit format
MSG=$(cat "$1")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Commit-msg hook wrong argument

High Severity

The commit-msg hook reads the message with cat "$1", but Lefthook inline run blocks expect the {1} template for the commit message file path. $1 is not substituted, so validation reads the wrong input and conventional-commit enforcement is unreliable.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 48a9306. Configure here.

Comment thread lefthook.yml
cd "$dir" && ruff check . 2>/dev/null || true
elif [ -f "$dir/go.mod" ]; then
cd "$dir" && go vet ./... 2>/dev/null || true
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pre-commit lint skips test dirs

Medium Severity

The lint hook resolves dirname of each staged file and only runs checks when that directory contains Cargo.toml, package.json, pyproject.toml, or go.mod. Changes under tests/ (and most subfolders) never match, so pre-commit lint silently skips the bulk of this repo’s Python tests.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 48a9306. Configure here.

Comment thread grade.sh
if [[ -f "Cargo.toml" ]]; then STACK="rust"; fi
if [[ -f "package.json" ]]; then STACK="node"; fi
if [[ -f "pyproject.toml" || -f "setup.py" ]]; then STACK="python"; fi
if [[ -f "go.mod" ]]; then STACK="go"; fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stack detection last file wins

Medium Severity

grade.sh sets STACK with independent if statements, so later markers overwrite earlier ones. This repo has both package.json and pyproject.toml, so grading runs only the Python suite with hardcoded src/ paths and pip install -e '.[dev]', which do not match PolicyStack’s layout or pyproject.toml.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 48a9306. Configure here.

Comment thread lefthook.yml
elif [ -f "$dir/pyproject.toml" ]; then
cd "$dir" && ruff check . 2>/dev/null || true
elif [ -f "$dir/go.mod" ]; then
cd "$dir" && go vet ./... 2>/dev/null || true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pre-commit ignores lint failures

Medium Severity

Several pre-commit commands append || true (eslint, ruff, go vet, and task grade-fast), so those steps always exit successfully even when lint or fast grade fails. The hook cannot block bad commits despite appearing to run checks.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 48a9306. Configure here.

Comment thread Taskfile.yml
cmds:
- lefthook install
status:
- test -f .git/hooks/lefthook

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wrong lefthook install probe

Low Severity

The install-lefthook task’s status checks for .git/hooks/lefthook, but lefthook install installs standard hook entrypoints like pre-commit and commit-msg, not a file named lefthook. The status check never succeeds, so the task always reruns install.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 48a9306. Configure here.

Comment thread lefthook.yml
if [ -f "Justfile" ]; then
just grade
elif [ -f "Taskfile.yml" ]; then
task grade

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Justfile name case mismatch

Medium Severity

Hooks test for Justfile (capital J), but this repository’s runner file is justfile. On case-insensitive filesystems the check matches and runs just grade, which has no grade recipe, instead of task grade from Taskfile.yml.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 48a9306. Configure here.

Comment thread lefthook.yml
parallel: true
commands:
editorconfig:
run: git diff --cached --name-only | xargs -n1 test -f && echo "Checking editorconfig..."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Editorconfig hook is noop

Low Severity

The editorconfig pre-commit command only runs test -f on staged paths and prints “Checking editorconfig…”. It never invokes EditorConfig or any formatter, so it cannot detect EditorConfig violations.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 48a9306. Configure here.

@sonarqubecloud

Copy link
Copy Markdown

Comment thread grade.sh
Comment on lines +97 to +107
run_check "install" "pip install -e '.[dev]'" 1
run_check "test-unit" "pytest -v" 3
run_check "lint" "ruff check src" 2
run_check "fmt" "ruff format --check src" 2
run_check "typecheck" "mypy src" 2
run_check "test-fuzz" "pytest -v --fuzz" 1 true
run_check "test-mutation" "mutmut run" 1 true
run_check "test-perf" "pytest -v --perf" 1 true
run_check "coverage" "pytest --cov=src --cov-report=term-missing --cov-fail-under=85" 2 true
run_check "security" "bandit -r src" 1
run_check "audit" "pip-audit" 1 true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 Architect Review — HIGH

The Python grading path assumes a pip-installed .[dev] extra and a top-level src/ package, but this repo's Python workflow is uv/Taskfile-based with no dev extra and no src/ directory, so task grade (and the pre-push hook that runs it) will consistently fail for environment/layout reasons rather than actual project quality.

Suggestion: Align the Python checks with this repository's existing contract (uv/Taskfile commands, real package paths, and declared extras), or make Python stack detection adaptive/opt-out for this repo so pre-push only blocks on checks that match the current Python toolchain and layout.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is an **Architect / Logical Review** comment left during a code review. These reviews are first-class, important findings — not optional suggestions. Do NOT dismiss this as a 'big architectural change' just because the title says architect review; most of these can be resolved with a small, localized fix once the intent is understood.

**Path:** grade.sh
**Line:** 97:107
**Comment:**
	*HIGH: The Python grading path assumes a pip-installed `.[dev]` extra and a top-level `src/` package, but this repo's Python workflow is uv/Taskfile-based with no `dev` extra and no `src/` directory, so `task grade` (and the pre-push hook that runs it) will consistently fail for environment/layout reasons rather than actual project quality.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
If a suggested approach is provided above, use it as the authoritative instruction. If no explicit code suggestion is given, you MUST still draft and apply your own minimal, localized fix — do not punt back with 'no suggestion provided, review manually'. Keep the change as small as possible: add a guard clause, gate on a loading state, reorder an await, wrap in a conditional, etc. Do not refactor surrounding code or expand scope beyond the finding.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix

Comment thread grade.sh
Comment on lines +46 to +52
if [[ "$FAST" == true && "$fast_skip" == true ]]; then
CHECKS+=("{\"name\":\"$name\",\"status\":\"skipped\",\"score\":0,\"max\":$weight,\"detail\":\"skipped in fast mode\"}")
return 0
fi

MAX=$((MAX + weight))
if eval "$cmd" 2>&1 | tee "$REPORT_DIR/${name}.log" >"$REPORT_DIR/${name}.raw" 2>&1; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: In fast mode, skipped checks keep their original max value in per-check records but are excluded from global MAX, so report totals become inconsistent and percentages are not comparable to the check table. Set skipped check max to 0 or include skipped weights in global totals consistently. [logic error]

Severity Level: Major ⚠️
- ⚠️ `grade-fast` summaries inconsistent with per-check weights and scores.
- ⚠️ Developers misjudge quality when skipped checks inflated aggregate percentage.
Steps of Reproduction ✅
1. Run fast grading through `task grade-fast` (Task defined at
`/workspace/PolicyStack/Taskfile.yml:217-220`, executing `./grade.sh --fast`) or via the
lefthook `pre-commit.test-fast` command at `/workspace/PolicyStack/lefthook.yml:35-44`,
which calls `task grade-fast` when source files change.

2. With `--fast`, `grade.sh` sets `FAST=true` in its argument parsing (lines `15-22`), and
then processes checks for the detected stack (e.g., Python at `grade.sh:96-108` or Go at
`70-79`), some of which are marked as heavy by passing `true` as the `fast_skip` argument.

3. For any heavy check (such as Python coverage at `grade.sh:66` or Go race tests at `76`)
where `fast_skip=true`, the `if` block at `grade.sh:46-48` executes: it appends a JSON
record with `"status":"skipped","score":0,"max":$weight` to `CHECKS` and returns early
without executing the command.

4. Because these skipped checks return before line `51`, their weights are not added to
the global `MAX` accumulator, so the summary percentage computed at `grade.sh:127-132`
uses a denominator that excludes skipped checks, while the per-check records in JSON/HTML
(constructed at `141-157` and `162-193`) still display the original `max` values for
skipped checks, making the aggregate `SCORE/MAX` percentage inconsistent with the detailed
check weights developers see in reports.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** grade.sh
**Line:** 46:52
**Comment:**
	*Logic Error: In fast mode, skipped checks keep their original `max` value in per-check records but are excluded from global `MAX`, so report totals become inconsistent and percentages are not comparable to the check table. Set skipped check `max` to `0` or include skipped weights in global totals consistently.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread grade.sh
Comment on lines +57 to +58
local detail="$(head -5 "$REPORT_DIR/${name}.raw" | tr '\n' ' ')"
CHECKS+=("{\"name\":\"$name\",\"status\":\"fail\",\"score\":0,\"max\":$weight,\"detail\":\"$detail\"}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Failed command output is injected into JSON strings without escaping, so any quote or backslash in command output can produce invalid JSON in reports. Escape detail properly (or build JSON with a serializer) before appending to CHECKS. [type error]

Severity Level: Major ⚠️
-`task grade-json` may emit invalid JSON grade report files.
- ⚠️ Downstream JSON consumers break parsing on errorful grade runs.
Steps of Reproduction ✅
1. Invoke JSON grading via `task grade-json` from the project root (Task `grade-json` is
defined at `/workspace/PolicyStack/Taskfile.yml:222-225` and runs `./grade.sh --json`),
which sets `JSON=true` in `grade.sh` argument parsing at lines `15-22`.

2. Ensure at least one check fails; for example, because there is no `src/` directory, the
Python lint/typecheck/security checks at `grade.sh:99-101,105-106` fail when
`STACK="python"`, writing error output into `.grade-reports/<name>.raw`.

3. On each failure, `run_check` at `grade.sh:57-58` reads the first five lines of the
command's raw output into `detail` using `head -5 "$REPORT_DIR/${name}.raw" | tr '\n' '
'`, then interpolates `$detail` directly into a JSON-like string appended to the `CHECKS`
array, without escaping embedded quotes or backslashes from the tool output.

4. When the JSON block at `grade.sh:142-157` writes `$REPORT_DIR/grade.json`, it inlines
`$(IFS=,; echo "${CHECKS[*]}")` into the `"checks"` array; any `detail` containing
characters such as `"` or `\` (common in CLI error messages) produces syntactically
invalid JSON, so the generated `grade.json` cannot be parsed reliably by downstream tools.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** grade.sh
**Line:** 57:58
**Comment:**
	*Type Error: Failed command output is injected into JSON strings without escaping, so any quote or backslash in command output can produce invalid JSON in reports. Escape `detail` properly (or build JSON with a serializer) before appending to `CHECKS`.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread grade.sh
run_check "audit" "npm audit --audit-level=moderate" 1
;;
python)
run_check "install" "pip install -e '.[dev]'" 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The Python install step calls pip install -e '.[dev]', but this repository's pyproject.toml does not define a dev extra, so the install check will fail immediately and force the whole grade to fail. Use the project's actual dependency workflow (the repo already uses uv in Taskfile) or install without a nonexistent extra. [api mismatch]

Severity Level: Major ⚠️
- ❌ Python install check always fails due to missing 'dev' extra.
- ⚠️ Grade summary includes avoidable failure, reducing trust in tool.
Steps of Reproduction ✅
1. From the repository root `/workspace/PolicyStack`, note that `pyproject.toml` exists
(verified at `/workspace/PolicyStack/pyproject.toml:1-8`), so `grade.sh` will detect
`STACK=\"python\"` via the stack detection logic at `grade.sh:26-31`.

2. Run `task grade` (Taskfile target defined at
`/workspace/PolicyStack/Taskfile.yml:212-215`), which executes `./grade.sh` and therefore
enters the `python)` case in `grade.sh` at lines `96-108`.

3. Inside the Python case, the install check at `grade.sh:97` runs `run_check "install"
"pip install -e '.[dev]'" 1`, invoking `pip install -e '.[dev]'` in the project root.

4. Inspect `pyproject.toml` at `/workspace/PolicyStack/pyproject.toml:5-32` and observe
there is no `[project.optional-dependencies]` or `dev` extra defined, so `pip install -e
'.[dev]'` fails on every run; `run_check` treats the non-zero exit as a failed check, and
`grade.sh` always records the Python install step as `[FAIL] install` for this repository.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** grade.sh
**Line:** 97:97
**Comment:**
	*Api Mismatch: The Python install step calls `pip install -e '.[dev]'`, but this repository's `pyproject.toml` does not define a `dev` extra, so the install check will fail immediately and force the whole grade to fail. Use the project's actual dependency workflow (the repo already uses `uv` in Taskfile) or install without a nonexistent extra.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread grade.sh
Comment on lines +99 to +106
run_check "lint" "ruff check src" 2
run_check "fmt" "ruff format --check src" 2
run_check "typecheck" "mypy src" 2
run_check "test-fuzz" "pytest -v --fuzz" 1 true
run_check "test-mutation" "mutmut run" 1 true
run_check "test-perf" "pytest -v --perf" 1 true
run_check "coverage" "pytest --cov=src --cov-report=term-missing --cov-fail-under=85" 2 true
run_check "security" "bandit -r src" 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: These Python checks are hardcoded to src, but this repo has no top-level src/ directory, so lint/typecheck/security/coverage checks fail due to wrong paths rather than real quality issues. Point checks at the real Python locations used by the project. [incorrect variable usage]

Severity Level: Critical 🚨
- ❌ Pre-push `task grade` fails from ruff,mypy,bandit on src.
- ⚠️ Developers blocked pushing despite healthy tests and real sources.
Steps of Reproduction ✅
1. List the project root (`/workspace/PolicyStack`) and observe there is no top-level
`src/` directory (confirmed by `ls` output), while Python sources live in files like
`policy_lib.py`, `resolve.py`, and under `cli/src/policy_federation` (see
`/workspace/PolicyStack/cli/src/policy_federation/*.py` from the Glob results).

2. Confirm the project is Python-based via `Taskfile.yml:8-29`, where `PROJECT_LANG`
chooses `python` when `pyproject.toml` exists, and note the Python build/test tasks set
`PYTHONPATH` to include `cli/src` (e.g., `Taskfile.yml:52-56` and `100-104`), reinforcing
that the real source tree is not `src/`.

3. Run `task grade` (defined at `/workspace/PolicyStack/Taskfile.yml:212-215`) or trigger
the pre-push hook defined in `/workspace/PolicyStack/lefthook.yml:63-73`, which both
execute `./grade.sh` and cause `grade.sh` to detect `STACK="python"` (lines `26-31`) and
enter the Python case at `grade.sh:96-108`.

4. In the Python case, `grade.sh` runs several checks against `src` at lines `99-101` and
`105-106`: `ruff check src`, `ruff format --check src`, `mypy src`, `pytest --cov=src
--cov-report=term-missing --cov-fail-under=85`, and `bandit -r src`; because `src/` does
not exist in this repo, these commands fail due to bad paths, causing multiple checks to
be marked as failed and pushing the overall grade percentage (computed at
`grade.sh:127-132`) below the configured pass threshold even when the actual Python
sources and tests are healthy.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** grade.sh
**Line:** 99:106
**Comment:**
	*Incorrect Variable Usage: These Python checks are hardcoded to `src`, but this repo has no top-level `src/` directory, so lint/typecheck/security/coverage checks fail due to wrong paths rather than real quality issues. Point checks at the real Python locations used by the project.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@codeant-ai

codeant-ai Bot commented Jun 13, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant