Skip to content

feat: consolidate AI review workflows + fix architecture generation#118

Merged
Tony363 merged 6 commits into
mainfrom
feat/consolidate-ai-review
Apr 4, 2026
Merged

feat: consolidate AI review workflows + fix architecture generation#118
Tony363 merged 6 commits into
mainfrom
feat/consolidate-ai-review

Conversation

@Tony363

@Tony363 Tony363 commented Apr 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Consolidate 4 AI review workflows into 1: Merges ai-review.yml, claude-review-phase1/2/3.yml into a single ai-code-review.yml with preflight, review, and autofix jobs
  • Rewrite generate-architecture.sh: Replaces the full-overwrite approach (which produced skeletal 46-line output, as seen in PR docs: update ARCHITECTURE.md #110) with marker-based partial updates that preserve hand-curated content (Mermaid diagrams, functional area descriptions, execution flow traces)
  • Fix file counting bugs: Rust files now exclude target/, workflow count only matches .github/workflows/*.yml

Test plan

  • All 59 integration tests pass (tests/integration/test_workflow_configs.py)
  • generate-architecture.sh runs cleanly, outputs 372 lines with all sections preserved
  • Marker-based updates only replace the Codebase Overview table
  • Verify ai-code-review.yml workflow triggers correctly on PR events
  • Verify update-architecture workflow produces correct output on next main push

🤖 Generated with Claude Code

Summary by Sourcery

Update architecture documentation generation to use marker-based partial updates while tightening validation and file metrics.

Enhancements:

  • Refine generate-architecture script to update only marked sections in ARCHITECTURE.md and preserve hand-written content.
  • Improve repository detection and GitNexus querying for architecture stats, including symbol, relationship, and process counts.
  • Tighten file counting logic for Python, Rust, workflow, and documentation files with better directory exclusions.
  • Add stronger validation that ARCHITECTURE.md exists, contains expected markers and sections, and remains above a minimum size after updates.
  • Extend the update-architecture workflow to ignore AGENTS.md changes in triggers and treat AGENTS.md alongside ARCHITECTURE.md when detecting documentation updates.

Documentation:

  • Refresh ARCHITECTURE.md overview metrics and wrap the auto-generated table in explicit markers for automated updates.

Summary by CodeRabbit

  • Chores
    • Switched to marker-based partial updates for the architecture document, consolidated overview metrics into a single table, refreshed “Last updated” handling, and tightened file-count exclusions and dependency checks.
    • Adjusted CI automation to skip runs when only agent docs change and updated change-detection messaging.
  • Bug Fixes
    • Added stricter validation and fail-fast behavior when the architecture file or required markers are missing.
  • Tests
    • Updated and expanded tests to validate update behavior, new metrics, timestamp refresh, and new failure modes.

Tony363 and others added 4 commits April 2, 2026 00:26
Merge ai-review.yml, claude-review-phase1/2/3.yml into a single
ai-code-review.yml with 3 jobs:

- preflight: gate (bot-actor, draft, size, label checks)
- review: comment-only review + conditional PAL MCP consensus
- autofix: opt-in via ai-patch label, creates draft PR

Key changes:
- Default behavior: comment-only review (was 4 concurrent reviews)
- Consensus: opt-in via ai-consensus label or high-stakes files
- Autofix: opt-in via ai-patch label, blocked for forks/protected files
- All actions SHA-pinned, tool syntax normalized to colon form
- Cost monitor updated to reference consolidated workflow
- Recursive trigger safety: GITHUB_TOKEN only, never PAT

Saves $4.50-13.50 per PR by eliminating duplicate reviews.

Addresses: DreamServer PR #683 review items #1, #2, #3

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests were checking for deleted phase2/phase3 workflow files.
Updated to test the new ai-code-review.yml consolidated workflow:
- Renamed fixtures: phase2_config/phase3_config → ai_code_review_config
- Replaced TestPhase2Workflow and TestPhase3Workflow with
  TestAICodeReviewWorkflow validating the 3-job consolidated structure
- Tests now validate: preflight gate, review+consensus, autofix,
  protected file checks, GITHUB_TOKEN usage, draft PR creation

All 12 tests ported to new structure + assertions preserved.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Changed test to look for 'gate' step ID (actual name in workflow)
instead of 'high-stakes' string. The high-stakes file detection is
part of the 'Evaluate gates' step with id='gate'.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The old script did a full overwrite of ARCHITECTURE.md using generic
GitNexus query calls, producing a skeletal 46-line file that lost the
Mermaid diagram, functional area descriptions, execution flow traces,
and testing architecture. The new script uses marker-based updates
(<!-- auto:overview --> markers) to only replace the data-driven
Codebase Overview table while preserving all hand-curated content.

Also fixes file counting bugs (Rust excluded target/, workflows count
only .github/workflows/*.yml) and adds multi-repo detection support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 4, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The architecture generation script moved from full-file rewrites to marker-based partial updates, swapped GitNexus query usage for Cypher-based stats with repo resolution, tightened dependency and validation checks, changed file-count exclusions and overview rendering, and updated the workflow to ignore changes to both ARCHITECTURE.md and AGENTS.md.

Changes

Cohort / File(s) Summary
Script
.github/scripts/generate-architecture.sh
Replaced wholesale ARCHITECTURE.md generation with marker-based updates (<!-- auto:overview --><!-- /auto:overview -->) using awk. Replaced gitnexus query flow with gitnexus cypher stats, added repo resolution to conditionally pass --repo, added awk/mv dependency checks, updated file-exclusion patterns, updated timestamp update and post-run validation to require additional headings, and tightened failure/error handling.
Workflow
.github/workflows/update-architecture.yml
Push trigger now ignores ARCHITECTURE.md and AGENTS.md. The "Check for changes" step diffs both files and updated console/status messages; PR creation gating remains unchanged.
Documentation
ARCHITECTURE.md
Inserted marker delimiters around the overview section, refreshed the "Last updated" timestamp, and updated generated metrics (workflow count changed). Seeded content outside markers preserved.
Tests
tests/github_scripts/test_generate_architecture_sh.py
Adapted tests for marker-update behavior and Cypher-based npx gitnexus usage: updated expected helper functions, adjusted mocked npx responses (list and cypher), tightened output assertions and line-count checks, added failure-mode tests for missing file/markers, and extended restricted-tool symlinks to include awk and mv.

Sequence Diagram(s)

sequenceDiagram
  participant Script as "generate-architecture.sh"
  participant FS as "Filesystem (ARCHITECTURE.md)"
  participant GN as "GitNexus (npx gitnexus)"
  participant Git as "git (diff/commit/PR)"

  Script->>FS: read ARCHITECTURE.md
  alt markers missing
    FS-->>Script: error -> exit
  else markers present
    Script->>GN: run `gitnexus list` (resolve repo)
    GN-->>Script: repo list
    Script->>GN: run `gitnexus cypher` (stats)
    GN-->>Script: cypher results (rows)
    Script->>FS: replace content between markers (awk)
    Script->>FS: update "Last updated" (sed)
    Script->>Git: git diff ARCHITECTURE.md, AGENTS.md
    alt changes detected
      Script->>Git: commit & push / create PR
    else
      Git-->>Script: no changes
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰
Markers nestle where updates play,
Cypher counts hop in to say,
Awk trims lines with nimble feet,
Partial changes, tidy and neat—
A rabbit cheers for docs that stay.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provides a clear summary, test results, and implementation details; however, it does not follow the required repository template with Design Principle Compliance section, Type of Change checkboxes, or proper SOLID/KISS/Let It Crash principle validation. Add the required template sections including Type of Change checkboxes, Design Principle Compliance checklist (Let It Crash, SOLID, KISS, Pure Functions), and Exceptions & Justifications table with proper structure.
Linked Issues check ❓ Inconclusive The PR description mentions 'PR #110' for context but does not explicitly link to issues being fixed or features being implemented (no 'Fixes #X' or 'Closes #X' references visible). Verify and explicitly link related issues using 'Fixes #X', 'Closes #X', or 'Relates to #X' format in the PR description for proper issue tracking.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'consolidate AI review workflows + fix architecture generation' clearly summarizes the two main changes in the changeset: workflow consolidation and architecture generation fixes.
Out of Scope Changes check ✅ Passed The PR consolidates workflows and rewrites architecture generation as intended; however, the scope appears appropriately bounded to stated objectives without introducing unrelated architectural changes.
Docstring Coverage ✅ Passed Docstring coverage is 95.45% which is sufficient. The required threshold is 80.00%.

✏️ 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 feat/consolidate-ai-review

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.

@sourcery-ai

sourcery-ai Bot commented Apr 4, 2026

Copy link
Copy Markdown

Reviewer's Guide

Consolidates AI code review GitHub workflows into a single configurable pipeline and rewrites architecture generation to perform safe, marker-based partial updates of ARCHITECTURE.md with corrected metrics and file counting logic.

File-Level Changes

Change Details Files
Rewrite architecture generation script to perform marker-based partial updates of ARCHITECTURE.md while adding stronger validation and more accurate metrics.
  • Switch from full file overwrite to marker-based replacement of the Codebase Overview section using markers.
  • Introduce repository resolution and optional --repo flag for GitNexus cypher queries, and use cypher-based counts for symbols, relationships, and processes.
  • Tighten file counting logic for Python, Rust, workflows, and documentation, including exclusion of target/, virtualenvs, node_modules, and limiting workflows to .github/workflows/*.yml.
  • Add timestamp update, line-count sanity check, required section validation, and more explicit error messages when markers or sections are missing.
.github/scripts/generate-architecture.sh
ARCHITECTURE.md
Update the architecture update workflow to treat additional docs as part of the generated set and adjust change detection messaging.
  • Exclude AGENTS.md from triggering the workflow while still considering it in the change detection step.
  • Update the change detection step to diff both ARCHITECTURE.md and AGENTS.md and emit generic messages about architecture docs changes.
.github/workflows/update-architecture.yml

Tips and commands

Interacting with Sourcery

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

Customizing Your Experience

Access your dashboard to:

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

Getting Help

@Tony363 Tony363 self-assigned this Apr 4, 2026
@github-actions

github-actions Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

PAL MCP Consensus Not Available

Security-sensitive files were detected, but PAL MCP multi-model consensus is not configured.

To enable consensus: Configure PAL_MCP_API_KEY and PAL_MCP_ENDPOINT secrets.

Claude Code Review results are still available above.

@github-actions

github-actions Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Claude Code Review (via AWS Bedrock)

Overview

PR consolidates architecture generation from full-file regeneration to marker-based partial updates, preserving hand-curated content. Main changes: rewrite of generate-architecture.sh to use marker-based updates, workflow updates to track AGENTS.md, and addition of content markers to ARCHITECTURE.md.

Critical Issues

None blocking - code is functional and represents a design improvement.

High Priority

  1. Fragile Cypher Query Parsing (.github/scripts/generate-architecture.sh:95-101)

    SYMBOL_COUNT=$(cypher_query '...' | jq -r '.markdown' | tail -1 | tr -d '| ' || echo "0")
    • Relies on output format that could change
    • tail -1 | tr -d '| ' is brittle
    • Consider using jq to parse structured output more robustly
    • Add validation that result is numeric before using
  2. Workflow-Script Mismatch (.github/workflows/update-architecture.yml:57)

    • Workflow checks for AGENTS.md changes but script doesn't generate/update it
    • Either remove AGENTS.md from workflow or add generation logic to script
    • Creates confusion about what the workflow actually updates
  3. Input Validation Missing (.github/scripts/generate-architecture.sh:44)

    REPO_NAME="${GITNEXUS_REPO:-}"
    • No validation of GITNEXUS_REPO environment variable
    • Could contain shell metacharacters if malicious
    • Add validation: [[ "$REPO_NAME" =~ ^[a-zA-Z0-9/_-]+$ ]]

Medium Priority

  1. Code Duplication in File Counting (lines 112-143)

    • Exclusion patterns repeated 4 times: .git/*, .gitnexus/*, .venv/*, etc.
    • Extract to shared variable or function:
    EXCLUDE_DIRS=(-not -path './.git/*' -not -path './.gitnexus/*' -not -path './.venv/*')
    PY_COUNT=$(find . -name '*.py' "${EXCLUDE_DIRS[@]}" | wc -l)
  2. Weak Marker Validation (lines 82-94)

    • Only checks for presence of opening and closing markers
    • Doesn't validate marker ordering or nesting
    • Doesn't check if markers are on their own lines
    • Could silently corrupt file if markers are malformed
  3. Incomplete Error Handling

    • No timeout handling for npx gitnexus cypher commands
    • Could hang indefinitely in CI
    • Add timeout: timeout 30s npx gitnexus cypher ...
  4. Repo Name Guessing (line 68)

    basename "$(pwd)"
    • Assumes directory name matches repo identifier in GitNexus
    • May fail if checked out to non-standard directory
    • Add warning/error if repo can't be reliably determined

Positive Observations

Excellent Architecture Pattern - Marker-based partial updates is the right approach for preserving hand-curated content

Good Error Messages - Clear ::error:: messages for CI debugging

Proper Shell Best Practices - Uses set -euo pipefail consistently

Clear Intent - Comments explain the "why" not just the "what"

Improved File Counting - Better exclusions (venv, node_modules, target) vs previous version

Dependency Validation - Checks for required commands upfront

Number Formatting - Adds commas to large numbers for readability

Comprehensive Output Validation - Checks line count, heading, and expected sections

Suggestions for Follow-up

  • Add unit tests for replace_marker_content awk logic
  • Consider using a templating engine (envsubst, mustache) instead of awk for marker replacement
  • Document marker format in ARCHITECTURE.md header
  • Add validation that Cypher queries return expected schema

Review Summary

Category Rating
Security 4/5
Code Quality 3/5
Architecture 4/5
Testing 2/5

Recommendation: Approve with suggestions. The architectural improvement (marker-based updates) is significant and well-executed. Address high-priority items in a follow-up PR to improve robustness.

Generated by Claude Code Review (AWS Bedrock - Sonnet 4.5)

@github-actions

github-actions Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

GitNexus Impact Analysis

NONE Overall Risk Level

Metric Value
Files Analyzed 2
Total Impacted Symbols 0
Affected Processes 1
Affected Modules 1

Per-File Impact

File Risk
.github/workflows/update-architecture.yml NONE
tests/github_scripts/test_generate_architecture_sh.py NONE

Affected Processes

Affected Modules

Detailed Impact by File

Generated by GitNexus impact analysis

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 3 issues, and left some high level feedback:

  • The format_number helper currently uses a simple sed expression that will only insert a single comma on some inputs; consider either relying on raw counts (no formatting) or switching to a more robust formatter to avoid misleading output for larger values.
  • The sed -i invocation in generate-architecture.sh is GNU-specific and will fail on macOS/BSD without a backup suffix; if you expect this script to be run locally as well as in CI, consider using a portable pattern like sed -i.bak ... && rm *.bak or routing through perl/awk instead.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `format_number` helper currently uses a simple `sed` expression that will only insert a single comma on some inputs; consider either relying on raw counts (no formatting) or switching to a more robust formatter to avoid misleading output for larger values.
- The `sed -i` invocation in `generate-architecture.sh` is GNU-specific and will fail on macOS/BSD without a backup suffix; if you expect this script to be run locally as well as in CI, consider using a portable pattern like `sed -i.bak ... && rm *.bak` or routing through `perl`/`awk` instead.

## Individual Comments

### Comment 1
<location path=".github/scripts/generate-architecture.sh" line_range="38" />
<code_context>
+  local repo_list
+  repo_list=$(npx gitnexus list 2>&1 || true)
+  local count
+  count=$(echo "$repo_list" | grep -oP 'Indexed Repositories \(\K[0-9]+' 2>/dev/null || echo "1")
+  if [[ "$count" -le 1 ]]; then
+    # Single repo — no --repo flag needed
</code_context>
<issue_to_address>
**issue (bug_risk):** Using `grep -P` may break on environments where `grep` lacks PCRE support (e.g., macOS default `grep`).

Because `-P` isn’t supported by BSD `grep`, this will return an empty match on those systems and cause `count` to default to `1`, potentially skipping `--repo` even when multiple repos are indexed. Please use a more portable parsing approach (e.g., `sed`/`awk`, `grep -E` with an adjusted pattern, or have `gitnexus list` output a machine-readable format consumable by `jq`).
</issue_to_address>

### Comment 2
<location path=".github/scripts/generate-architecture.sh" line_range="90-91" />
<code_context>

-## Codebase Overview
+# Format numbers with commas
+format_number() {
+  echo "$1" | sed ':a;s/\B[0-9]\{3\}\>$/,&/;ta'
+}

</code_context>
<issue_to_address>
**issue (bug_risk):** Number formatting function is brittle and likely not doing full thousands-grouping as intended.

This sed pattern only inserts a single comma at the end and relies on non‑portable `\B`/`\>` regex extensions, so values like `1234567` may not become `1,234,567`, and behavior can vary between sed implementations. Consider a POSIX‑compatible sed/awk approach for repeated grouping, or drop the formatting and keep raw counts to avoid cross‑platform issues.
</issue_to_address>

### Comment 3
<location path=".github/scripts/generate-architecture.sh" line_range="167" />
<code_context>
+
+# ── Update timestamp ─────────────────────────────────────────────────
+GENERATED_DATE=$(date -u '+%Y-%m-%d %H:%M UTC')
+sed -i "s|^> Last updated:.*|> Last updated: ${GENERATED_DATE}|" "$ARCH_FILE"
+
+# ── Validate output ──────────────────────────────────────────────────
</code_context>
<issue_to_address>
**issue (bug_risk):** In-place `sed -i` usage is not portable between GNU sed and BSD/macOS sed.

On macOS/BSD, `sed -i` requires a backup suffix (e.g. `-i ''`), while GNU `sed` rejects an empty string, so this command will fail on at least one platform. To keep the script portable, either branch on the detected platform when calling `sed`, or avoid `-i` by writing to a temporary file and moving it back (as you do in `replace_marker_content`).
</issue_to_address>

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

local repo_list
repo_list=$(npx gitnexus list 2>&1 || true)
local count
count=$(echo "$repo_list" | grep -oP 'Indexed Repositories \(\K[0-9]+' 2>/dev/null || echo "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.

issue (bug_risk): Using grep -P may break on environments where grep lacks PCRE support (e.g., macOS default grep).

Because -P isn’t supported by BSD grep, this will return an empty match on those systems and cause count to default to 1, potentially skipping --repo even when multiple repos are indexed. Please use a more portable parsing approach (e.g., sed/awk, grep -E with an adjusted pattern, or have gitnexus list output a machine-readable format consumable by jq).

Comment on lines +90 to +91
format_number() {
echo "$1" | sed ':a;s/\B[0-9]\{3\}\>$/,&/;ta'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Number formatting function is brittle and likely not doing full thousands-grouping as intended.

This sed pattern only inserts a single comma at the end and relies on non‑portable \B/\> regex extensions, so values like 1234567 may not become 1,234,567, and behavior can vary between sed implementations. Consider a POSIX‑compatible sed/awk approach for repeated grouping, or drop the formatting and keep raw counts to avoid cross‑platform issues.


# ── Update timestamp ─────────────────────────────────────────────────
GENERATED_DATE=$(date -u '+%Y-%m-%d %H:%M UTC')
sed -i "s|^> Last updated:.*|> Last updated: ${GENERATED_DATE}|" "$ARCH_FILE"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): In-place sed -i usage is not portable between GNU sed and BSD/macOS sed.

On macOS/BSD, sed -i requires a backup suffix (e.g. -i ''), while GNU sed rejects an empty string, so this command will fail on at least one platform. To keep the script portable, either branch on the detected platform when calling sed, or avoid -i by writing to a temporary file and moving it back (as you do in replace_marker_content).

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

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

Inline comments:
In @.github/scripts/generate-architecture.sh:
- Around line 71-87: The current cypher_query() call can silently produce empty
output and the subsequent assignments to SYMBOL_COUNT, EDGE_COUNT, and
PROCESS_COUNT coerce failures to "0"; change this so failures are fatal: have
cypher_query() return a non-zero exit code on error (preserve and echo the error
text), remove the "|| echo '0'" fallback, and after each jq parse (for
SYMBOL_COUNT, EDGE_COUNT, PROCESS_COUNT) validate the result is non-empty and
numeric (e.g., regex test or grep -E '^[0-9]+$'); if any parse fails, write a
clear error via >&2 with the cypher_query output and exit 1 so the workflow
fails rather than producing bogus "0" metrics. Ensure you reference the
cypher_query function and the SYMBOL_COUNT/EDGE_COUNT/PROCESS_COUNT assignments
when making the changes.

In `@ARCHITECTURE.md`:
- Around line 8-18: Update the hand-curated CI/CD sections in ARCHITECTURE.md to
match the auto overview: change both occurrences of "23 workflows" (the "CI/CD
(23 workflows)" heading and "23 GitHub Actions workflows") to "20 workflows",
remove or revise the obsolete "3-phase review" wording and any references to the
removed claude-review-phase1/2/3.yml files so the document no longer lists those
three workflows, and ensure the surrounding descriptive text (the paragraph
referencing the review phases) reflects the current single/updated review
process; search for the exact strings "CI/CD (23 workflows)", "23 GitHub Actions
workflows", "3-phase", and "claude-review-phase1/2/3.yml" to locate and edit the
lines.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2cc311ec-dbfe-49e9-a28e-1ed2ba54eb99

📥 Commits

Reviewing files that changed from the base of the PR and between a7d29ee and a047f59.

📒 Files selected for processing (3)
  • .github/scripts/generate-architecture.sh
  • .github/workflows/update-architecture.yml
  • ARCHITECTURE.md

Comment on lines +71 to +87
cypher_query() {
local query="$1"
local result
# shellcheck disable=SC2086
if ! result=$(npx gitnexus cypher $REPO_FLAG "$query" 2>&1); then
echo "::warning::Cypher query failed: $result" >&2
echo ""
return
fi
echo ""
echo "$result"
}

# ── Generate ARCHITECTURE.md ──────────────────────────────────────────
GENERATED_DATE=$(date -u '+%Y-%m-%d %H:%M UTC')

cat > ARCHITECTURE.md <<EOF
# SuperClaude Architecture
echo "Querying GitNexus knowledge graph..." >&2

> Auto-generated by GitNexus knowledge graph analysis.
> Last updated: ${GENERATED_DATE}
SYMBOL_COUNT=$(cypher_query 'MATCH (n) RETURN count(n) as c' | jq -r '.markdown' | tail -1 | tr -d '| ' || echo "0")
EDGE_COUNT=$(cypher_query 'MATCH ()-[r]->() RETURN count(r) as c' | jq -r '.markdown' | tail -1 | tr -d '| ' || echo "0")
PROCESS_COUNT=$(cypher_query 'MATCH (p:Process) RETURN count(p) as c' | jq -r '.markdown' | tail -1 | tr -d '| ' || echo "0")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

parsed=$(
  if ! out=$(npx gitnexus cypher 'THIS IS NOT CYPHER' 2>&1); then
    printf '%s' ""
  else
    printf '%s' "$out"
  fi | jq -r '.markdown' | tail -1 | tr -d '| ' || echo "0"
)

printf 'Parsed count after a forced cypher failure: %s\n' "$parsed"
test "$parsed" = "0"

Repository: Tony363/SuperClaude

Length of output: 149


🏁 Script executed:

cat -n .github/scripts/generate-architecture.sh | head -100

Repository: Tony363/SuperClaude

Length of output: 3875


🏁 Script executed:

sed -n '88,150p' .github/scripts/generate-architecture.sh

Repository: Tony363/SuperClaude

Length of output: 1964


🏁 Script executed:

sed -n '150,200p' .github/scripts/generate-architecture.sh

Repository: Tony363/SuperClaude

Length of output: 1262


Fail the workflow when GitNexus stats cannot be parsed.

If gitnexus cypher fails or its output shape changes, cypher_query() returns an empty string and lines 85-87 coerce the parse failure to 0. The script then keeps going and publishes a plausible-looking ARCHITECTURE.md with bogus counts (all metrics become "0") instead of failing fast. Downstream validation only checks file structure (line count, headings, sections), not metric correctness.

🛠️ Suggested fix
+extract_count() {
+  jq -er '.markdown' | tail -1 | tr -d '| ' | grep -E '^[0-9]+$'
+}
+
 cypher_query() {
   local query="$1"
   local result
   # shellcheck disable=SC2086
-  if ! result=$(npx gitnexus cypher $REPO_FLAG "$query" 2>&1); then
-    echo "::warning::Cypher query failed: $result" >&2
-    echo ""
-    return
-  fi
+  result=$(npx gitnexus cypher $REPO_FLAG "$query" 2>&1) || {
+    echo "::error::Cypher query failed: $result" >&2
+    exit 1
+  }
   echo "$result"
 }
 
-SYMBOL_COUNT=$(cypher_query 'MATCH (n) RETURN count(n) as c' | jq -r '.markdown' | tail -1 | tr -d '| ' || echo "0")
-EDGE_COUNT=$(cypher_query 'MATCH ()-[r]->() RETURN count(r) as c' | jq -r '.markdown' | tail -1 | tr -d '| ' || echo "0")
-PROCESS_COUNT=$(cypher_query 'MATCH (p:Process) RETURN count(p) as c' | jq -r '.markdown' | tail -1 | tr -d '| ' || echo "0")
+SYMBOL_COUNT=$(cypher_query 'MATCH (n) RETURN count(n) as c' | extract_count)
+EDGE_COUNT=$(cypher_query 'MATCH ()-[r]->() RETURN count(r) as c' | extract_count)
+PROCESS_COUNT=$(cypher_query 'MATCH (p:Process) RETURN count(p) as c' | extract_count)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cypher_query() {
local query="$1"
local result
# shellcheck disable=SC2086
if ! result=$(npx gitnexus cypher $REPO_FLAG "$query" 2>&1); then
echo "::warning::Cypher query failed: $result" >&2
echo ""
return
fi
echo ""
echo "$result"
}
# ── Generate ARCHITECTURE.md ──────────────────────────────────────────
GENERATED_DATE=$(date -u '+%Y-%m-%d %H:%M UTC')
cat > ARCHITECTURE.md <<EOF
# SuperClaude Architecture
echo "Querying GitNexus knowledge graph..." >&2
> Auto-generated by GitNexus knowledge graph analysis.
> Last updated: ${GENERATED_DATE}
SYMBOL_COUNT=$(cypher_query 'MATCH (n) RETURN count(n) as c' | jq -r '.markdown' | tail -1 | tr -d '| ' || echo "0")
EDGE_COUNT=$(cypher_query 'MATCH ()-[r]->() RETURN count(r) as c' | jq -r '.markdown' | tail -1 | tr -d '| ' || echo "0")
PROCESS_COUNT=$(cypher_query 'MATCH (p:Process) RETURN count(p) as c' | jq -r '.markdown' | tail -1 | tr -d '| ' || echo "0")
extract_count() {
jq -er '.markdown' | tail -1 | tr -d '| ' | grep -E '^[0-9]+$'
}
cypher_query() {
local query="$1"
local result
# shellcheck disable=SC2086
result=$(npx gitnexus cypher $REPO_FLAG "$query" 2>&1) || {
echo "::error::Cypher query failed: $result" >&2
exit 1
}
echo "$result"
}
echo "Querying GitNexus knowledge graph..." >&2
SYMBOL_COUNT=$(cypher_query 'MATCH (n) RETURN count(n) as c' | extract_count)
EDGE_COUNT=$(cypher_query 'MATCH ()-[r]->() RETURN count(r) as c' | extract_count)
PROCESS_COUNT=$(cypher_query 'MATCH (p:Process) RETURN count(p) as c' | extract_count)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/scripts/generate-architecture.sh around lines 71 - 87, The current
cypher_query() call can silently produce empty output and the subsequent
assignments to SYMBOL_COUNT, EDGE_COUNT, and PROCESS_COUNT coerce failures to
"0"; change this so failures are fatal: have cypher_query() return a non-zero
exit code on error (preserve and echo the error text), remove the "|| echo '0'"
fallback, and after each jq parse (for SYMBOL_COUNT, EDGE_COUNT, PROCESS_COUNT)
validate the result is non-empty and numeric (e.g., regex test or grep -E
'^[0-9]+$'); if any parse fails, write a clear error via >&2 with the
cypher_query output and exit 1 so the workflow fails rather than producing bogus
"0" metrics. Ensure you reference the cypher_query function and the
SYMBOL_COUNT/EDGE_COUNT/PROCESS_COUNT assignments when making the changes.

Comment thread ARCHITECTURE.md
Comment on lines +8 to +18
<!-- auto:overview -->
| Metric | Count |
|--------|-------|
| Total symbols | 8,994 |
| Relationships | 21,155 |
| Execution flows | 300 |
| Python files | 217 |
| Rust files | 88 |
| GitHub workflows | 23 |
| GitHub workflows | 20 |
| Documentation files | 270 |
<!-- /auto:overview -->

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Manually update the preserved CI/CD sections to match this new count.

The overview now says 20 workflows, but the hand-curated sections later in this file still say CI/CD (23 workflows) on Line 100 and 23 GitHub Actions workflows on Line 265. Line 101 still describes a 3-phase review, and Line 269 still lists the removed claude-review-phase1/2/3.yml files. As-is, the architecture map contradicts itself.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ARCHITECTURE.md` around lines 8 - 18, Update the hand-curated CI/CD sections
in ARCHITECTURE.md to match the auto overview: change both occurrences of "23
workflows" (the "CI/CD (23 workflows)" heading and "23 GitHub Actions
workflows") to "20 workflows", remove or revise the obsolete "3-phase review"
wording and any references to the removed claude-review-phase1/2/3.yml files so
the document no longer lists those three workflows, and ensure the surrounding
descriptive text (the paragraph referencing the review phases) reflects the
current single/updated review process; search for the exact strings "CI/CD (23
workflows)", "23 GitHub Actions workflows", "3-phase", and
"claude-review-phase1/2/3.yml" to locate and edit the lines.

Tests now validate the new marker-based partial update behavior:
- Mock npx handles gitnexus cypher/list commands (not query)
- Seed ARCHITECTURE.md with markers provided to each test
- Assertions check curated content preservation, not full generation
- New tests for missing file and missing marker error paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

PAL MCP Consensus Not Available

Security-sensitive files were detected, but PAL MCP multi-model consensus is not configured.

To enable consensus: Configure PAL_MCP_API_KEY and PAL_MCP_ENDPOINT secrets.

Claude Code Review results are still available above.

@github-actions

github-actions Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Claude Code Review (via AWS Bedrock)

Overview

This PR consolidates AI review workflows and rewrites the architecture generation script to use a marker-based partial update approach. The change shifts from full document regeneration to targeted updates of data-driven sections, preserving hand-curated content. Includes comprehensive test updates and ARCHITECTURE.md marker additions.

Key Changes:

  • Rewrote generate-architecture.sh to use <!-- auto:* --> markers for partial updates
  • Migrated from GitNexus query to cypher commands for graph statistics
  • Added repository resolution logic for multi-repo GitNexus setups
  • Updated tests to validate marker-based updates and content preservation
  • Added AGENTS.md to workflow change detection

Critical Issues

None found. The changes are functional and well-tested.


High Priority

1. File Corruption Risk - Missing Atomic Update (.github/scripts/generate-architecture.sh:136-147)

Issue: The replace_marker_content function creates a temp file but doesn't handle failures atomically. If the mv command fails, the original file could be corrupted.

Risk: Data loss if disk is full or permissions change mid-update.

Recommendation:

replace_marker_content() {
  local file="$1"
  local marker="$2"
  local content="$3"
  local start_marker="<!-- auto:${marker} -->"
  local end_marker="<!-- /auto:${marker} -->"
  local tmp_file="${file}.tmp.$$"  # Add PID for uniqueness

  awk -v start="$start_marker" -v end="$end_marker" -v replacement="$content" '
    $0 == start { print; print replacement; skip = 1; next }
    $0 == end { print; skip = 0; next }
    !skip { print }
  ' "$file" > "$tmp_file" || {
    rm -f "$tmp_file"
    return 1
  }
  
  # Atomic move with backup
  cp "$file" "${file}.bak" && mv "$tmp_file" "$file" || {
    mv "${file}.bak" "$file"  # Restore on failure
    return 1
  }
  rm -f "${file}.bak"
}

2. sed Timestamp Update After Marker Replacement (:154)

Issue: The timestamp update using sed -i happens after marker replacement. If this fails, the file is left with updated metrics but stale timestamp.

Risk: Misleading timestamps indicating when updates occurred.

Recommendation: Either include timestamp in the marker-based update or add error handling:

if ! sed -i "s|^> Last updated:.*|> Last updated: ${GENERATED_DATE}|" "$ARCH_FILE"; then
  echo "::error::Failed to update timestamp in $ARCH_FILE" >&2
  exit 1
fi

3. No Marker Pairing Validation (:32-42)

Issue: Script checks for opening marker but doesn't validate that markers are properly paired or nested correctly.

Risk: Malformed markers could cause silent content deletion by awk script.

Recommendation: Add validation before attempting updates:

validate_markers() {
  local file="$1"
  local marker="$2"
  local start_count=$(grep -c "<!-- auto:${marker} -->" "$file")
  local end_count=$(grep -c "<!-- /auto:${marker} -->" "$file")
  
  if [[ "$start_count" -ne 1 ]] || [[ "$end_count" -ne 1 ]]; then
    echo "::error::Marker auto:${marker} must appear exactly once (start: $start_count, end: $end_count)" >&2
    return 1
  fi
  return 0
}

# Use before replace_marker_content
validate_markers "$ARCH_FILE" "overview" || exit 1

Medium Priority

4. Hardcoded Magic Numbers (:157, :100)

Issue: Minimum line count validation uses hardcoded 100 without explanation.

Recommendation: Extract to named constant with comment explaining threshold:

# Minimum expected line count for valid ARCHITECTURE.md with all sections
MIN_ARCHITECTURE_LINES=100

if [[ "$LINE_COUNT" -lt "$MIN_ARCHITECTURE_LINES" ]]; then
  echo "::error::Generated $ARCH_FILE has only $LINE_COUNT lines (expected >$MIN_ARCHITECTURE_LINES)" >&2
  exit 1
fi

5. Test Coverage Gap - Malformed Markers (tests/github_scripts/test_generate_architecture_sh.py)

Issue: Tests validate missing markers but not malformed ones (duplicate markers, mismatched pairs, nested markers).

Recommendation: Add test cases:

def test_fails_with_duplicate_start_markers(self, run_generate):
    """Script fails when start marker appears multiple times."""
    bad_content = SEED_ARCHITECTURE.replace(
        "<!-- auto:overview -->",
        "<!-- auto:overview -->\n<!-- auto:overview -->"
    )
    result, _ = run_generate(seed_content=bad_content)
    assert result.returncode != 0
    assert "marker" in result.stderr.lower()

def test_fails_with_mismatched_markers(self, run_generate):
    """Script fails when end marker is missing."""
    bad_content = SEED_ARCHITECTURE.replace("<!-- /auto:overview -->", "")
    result, _ = run_generate(seed_content=bad_content)
    assert result.returncode != 0

6. Multiple Find Commands Could Be Optimized (:96-116)

Issue: Four separate find commands traverse the directory tree independently.

Impact: Minor performance impact on large repos.

Recommendation: Consider combining with a single find + case statement:

read PY_COUNT RS_COUNT YML_COUNT MD_COUNT < <(
  find . \( \
    -path './.git' -o \
    -path './.gitnexus' -o \
    -path './.venv' -o \
    -path './venv' -o \
    -path './node_modules' -o \
    -path './target' \
  \) -prune -o -type f \( \
    -name '*.py' -o \
    -name '*.rs' -o \
    -name '*.yml' -o \
    -name '*.md' -o \
    -name '*.rst' \
  \) -print | awk '
    /\.py$/ { py++ }
    /\.rs$/ { rs++ }
    /\.yml$/ && /\.github\/workflows/ { yml++ }
    /\.(md|rst)$/ { md++ }
    END { print py, rs, yml, md }
  '
)

7. Mock Cypher Returns Hardcoded "42" (tests/.../test_generate_architecture_sh.py:251)

Issue: All Cypher queries return the same value, not testing query differentiation.

Recommendation: Make mock query-aware:

elif [[ "$1" == "gitnexus" && "$2" == "cypher" ]]; then
    # Parse query and return appropriate mock data
    if [[ "$*" =~ "count(n)" ]]; then
        echo '{"markdown":"| c |\\n| --- |\\n| 8994 |","row_count":1}'
    elif [[ "$*" =~ "count(r)" ]]; then
        echo '{"markdown":"| c |\\n| --- |\\n| 12567 |","row_count":1}'
    elif [[ "$*" =~ "count(p)" ]]; then
        echo '{"markdown":"| c |\\n| --- |\\n| 300 |","row_count":1}'
    fi

8. No Test for Multi-Repo Scenario (tests/.../test_generate_architecture_sh.py)

Issue: resolve_repo has logic for multiple indexed repos but no test coverage.

Recommendation: Add test with mock returning multiple repos:

def test_handles_multiple_repos(self, mock_bin_dir, tmp_path):
    """Script uses --repo flag when multiple repos are indexed."""
    # Update mock to return multiple repos
    # Verify REPO_FLAG is set correctly

Positive Observations

Excellent Architecture Decision - The marker-based approach is a significant improvement over full regeneration. This allows mixing auto-generated metrics with hand-curated content, solving a major maintainability issue.

Comprehensive Test Rewrite - Tests were completely updated to match the new paradigm with excellent coverage of happy paths and error cases. The SEED_ARCHITECTURE fixture provides a realistic test document.

Better File Exclusions - Added .venv, venv, node_modules, and target to exclusions, preventing incorrect counts from dependencies.

Number Formatting - The format_number function with comma separators greatly improves readability of large metrics.

Repository Resolution - Smart handling of single vs. multi-repo GitNexus setups avoids requiring manual configuration in common cases.

Improved Validation - Changed from basic "file exists and non-empty" to semantic validation (minimum line count, required sections).

Clear Error Messages - All error paths include descriptive messages with ::error:: GitHub Actions annotations.

Function Decomposition - Script is well-organized with clear helper functions (check_deps, resolve_repo, cypher_query, format_number, replace_marker_content).


Review Summary

Category Rating Notes
Security ⭐⭐⭐/5 File corruption risks without atomic updates or rollback. No validation of marker pairing.
Code Quality ⭐⭐⭐⭐/5 Clean, well-organized code with minor issues (hardcoded values, embedded awk scripts).
Architecture ⭐⭐⭐⭐⭐/5 Excellent design. Marker-based partial updates are a major improvement.
Testing ⭐⭐⭐⭐/5 Strong coverage with comprehensive rewrite. Some edge cases missed (malformed markers, multi-repo).

Overall Assessment: This is a high-quality PR that significantly improves the architecture generation system. The marker-based approach is architecturally sound and well-tested. The main concerns are around file corruption risks that should be addressed before merge. Recommend addressing the High Priority items, particularly atomic file updates and marker validation.


Generated by Claude Code Review (AWS Bedrock) - Sonnet 4.5

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/github_scripts/test_generate_architecture_sh.py (2)

344-427: Mark subprocess execution suite as integration/slow.

These tests run shell subprocesses and filesystem setup repeatedly; they should be tagged for selective CI execution.

+@pytest.mark.integration
 class TestExecution:

As per coding guidelines: "Mark slower test journeys with @pytest.mark.slow or integration per pyproject.toml configuration".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/github_scripts/test_generate_architecture_sh.py` around lines 344 -
427, Add the integration/slow pytest marker to the subprocess-heavy tests by
importing pytest and annotating the affected test functions
(test_updates_architecture_md, test_updates_file_counts,
test_preserves_curated_content, test_includes_footer, test_updates_timestamp,
test_fails_without_architecture_md, test_fails_without_markers) with
`@pytest.mark.slow` or `@pytest.mark.integration` as appropriate (or apply a
module-level pytestmark = [pytest.mark.slow] to mark them all), so CI can
selectively run these longer subprocess/filesystem tests.

355-363: Assert cypher-derived counts, not only table labels.

Line 356 says this validates cypher-backed data, but the test only checks header strings. A parsing regression could still pass.

Proposed tightening
 def test_updates_file_counts(self, run_generate):
     """Updated file includes file count table with data from cypher queries."""
     result, content = run_generate()
     assert result.returncode == 0
     assert "Python files" in content
     assert "Rust files" in content
-    assert "Total symbols" in content
-    assert "Relationships" in content
+    assert "| Total symbols | 42 |" in content
+    assert "| Relationships | 42 |" in content
+    assert "| Execution flows | 42 |" in content
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/github_scripts/test_generate_architecture_sh.py` around lines 355 -
363, The test_updates_file_counts test currently only checks for header labels
but should assert the cypher-derived numeric values are present; update the test
(in function test_updates_file_counts using the run_generate fixture) to parse
the generated content and assert numeric counts for each header (e.g., match a
digit or specific expected numbers for "Python files", "Rust files", "Total
symbols", and "Relationships") rather than just the labels—use a regex or
HTML/table cell lookup to locate the cell next to each header and assert it
contains a non-empty numeric string (or the known expected integer) to prevent
regressions that remove/alter the cypher values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/github_scripts/test_generate_architecture_sh.py`:
- Around line 408-427: Add a new test in
tests/github_scripts/test_generate_architecture_sh.py (e.g.,
test_fails_with_missing_closing_marker) that mirrors test_fails_without_markers
but writes an ARCHITECTURE.md containing the opening marker "<!-- auto:overview
-->" without the closing "<!-- /auto:overview -->"; run the script via
subprocess with the same env/cwd setup, assert result.returncode != 0 and that
result.stderr contains an indication of the missing closing marker (e.g., the
string "/auto:overview" or "closing marker") to validate the guard for a missing
closing marker in the script.

---

Nitpick comments:
In `@tests/github_scripts/test_generate_architecture_sh.py`:
- Around line 344-427: Add the integration/slow pytest marker to the
subprocess-heavy tests by importing pytest and annotating the affected test
functions (test_updates_architecture_md, test_updates_file_counts,
test_preserves_curated_content, test_includes_footer, test_updates_timestamp,
test_fails_without_architecture_md, test_fails_without_markers) with
`@pytest.mark.slow` or `@pytest.mark.integration` as appropriate (or apply a
module-level pytestmark = [pytest.mark.slow] to mark them all), so CI can
selectively run these longer subprocess/filesystem tests.
- Around line 355-363: The test_updates_file_counts test currently only checks
for header labels but should assert the cypher-derived numeric values are
present; update the test (in function test_updates_file_counts using the
run_generate fixture) to parse the generated content and assert numeric counts
for each header (e.g., match a digit or specific expected numbers for "Python
files", "Rust files", "Total symbols", and "Relationships") rather than just the
labels—use a regex or HTML/table cell lookup to locate the cell next to each
header and assert it contains a non-empty numeric string (or the known expected
integer) to prevent regressions that remove/alter the cypher values.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6fc51174-c029-4604-adcb-e659b43a6243

📥 Commits

Reviewing files that changed from the base of the PR and between a047f59 and 98a63f3.

📒 Files selected for processing (1)
  • tests/github_scripts/test_generate_architecture_sh.py

Comment on lines +408 to +427
def test_fails_without_markers(self, mock_bin_dir, tmp_path):
"""Script fails with error if ARCHITECTURE.md has no markers."""
work_dir = tmp_path / "no_markers"
work_dir.mkdir()
(work_dir / "ARCHITECTURE.md").write_text("# Architecture\n\nNo markers here.\n")

env = os.environ.copy()
env["PATH"] = f"{mock_bin_dir}:{env['PATH']}"
env["HOME"] = str(tmp_path)

result = subprocess.run(
["bash", str(SCRIPT_PATH)],
capture_output=True,
text=True,
env=env,
cwd=str(work_dir),
timeout=30,
)
assert result.returncode != 0
assert "marker" in result.stderr.lower()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add a dedicated test for missing closing marker.

Current coverage checks “no markers,” but the script has a separate guard for a missing <!-- /auto:overview -->. That path should be validated explicitly.

Suggested additional test
+    def test_fails_without_closing_marker(self, mock_bin_dir, tmp_path):
+        """Script fails if ARCHITECTURE.md is missing the closing overview marker."""
+        work_dir = tmp_path / "missing_closer"
+        work_dir.mkdir()
+        (work_dir / "ARCHITECTURE.md").write_text(
+            "# Architecture\n\n<!-- auto:overview -->\n| Metric | Count |\n"
+        )
+
+        env = os.environ.copy()
+        env["PATH"] = f"{mock_bin_dir}:{env['PATH']}"
+        env["HOME"] = str(tmp_path)
+
+        result = subprocess.run(
+            ["bash", str(SCRIPT_PATH)],
+            capture_output=True,
+            text=True,
+            env=env,
+            cwd=str(work_dir),
+            timeout=30,
+        )
+        assert result.returncode != 0
+        assert "closing marker" in result.stderr.lower() or "/auto:overview" in result.stderr
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/github_scripts/test_generate_architecture_sh.py` around lines 408 -
427, Add a new test in tests/github_scripts/test_generate_architecture_sh.py
(e.g., test_fails_with_missing_closing_marker) that mirrors
test_fails_without_markers but writes an ARCHITECTURE.md containing the opening
marker "<!-- auto:overview -->" without the closing "<!-- /auto:overview -->";
run the script via subprocess with the same env/cwd setup, assert
result.returncode != 0 and that result.stderr contains an indication of the
missing closing marker (e.g., the string "/auto:overview" or "closing marker")
to validate the guard for a missing closing marker in the script.

@Tony363 Tony363 merged commit 85ae1f8 into main Apr 4, 2026
32 checks passed
@Tony363 Tony363 deleted the feat/consolidate-ai-review branch April 4, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant