Skip to content

feat: align sweep with Phase 2 naming, add aggregate sweep summary#55

Merged
pruiz merged 2 commits into
masterfrom
feat/phase-2-sweep-alignment
Jun 12, 2026
Merged

feat: align sweep with Phase 2 naming, add aggregate sweep summary#55
pruiz merged 2 commits into
masterfrom
feat/phase-2-sweep-alignment

Conversation

@pruiz

@pruiz pruiz commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Aligns the file-risk sweep tooling with Phase 2 naming conventions and adds an aggregate sweep summary step.

Changes

  • Rename prompts/sweep.mdprompts/phase-2-sweep.md
  • New prompts/phase-2-sweep-summary.md — aggregate sweep rollup prompt (consolidates per-file summaries, forbids new findings/hunting, writes runs/sweep-summary-*.md, prints to screen)
  • Per-file sweeps write runs/phase-2-summary-sweep-<slug>-*.md (satisfies Phase 2 completion gate)
  • find_latest_summary("2") now unconditionally excludes per-file sweep summaries from broad Phase 2 lookup
  • find_latest_sweep_summary() added for runs/sweep-summary-*.md lookup
  • codecome hints: Phase 2 uses filtered lookup; Sweep block surfaces aggregate rollup; removed old per-file sweep scan
  • tools/run-sweep.py: invokes aggregate summary via opencode run after all per-file sweeps succeed (skipped on dry-run); only feeds fresh per-file summaries to the aggregate prompt
  • README/docs updated for new prompt paths and artifact names; removed deprecated CODECOME_USE_WRAPPER references
  • Tests added for sweep exclusion, find_latest_sweep_summary, aggregate summary prompt generation, stale-summary filtering

Follow-up commit (2cc850b) addresses review feedback

  • Docstring now says "extend" not "override" (the implicit Phase 2 sweep exclusion cannot be overridden)
  • exclude_patterns matching uses fnmatch for clarity
  • Removed deprecated CODECOME_USE_WRAPPER branch from per-file sweeps; per-file runs always use the wrapper path
  • Documented why aggregate rollup uses raw opencode run (not a phase-mode run, run-agent.py lacks non-phase utility support)
  • Simplified redundant aggregate-summary guard
  • Aggregate prompt now injects exact per-file summary paths and instructs the model to read only those (not all historical phase-2-summary-sweep-*.md)
  • Fixed slug example in per-file sweep prompt to match slugify() output
  • Timestamped aggregate prompt path instead of fixed name
  • Cleaned CODECOME_USE_WRAPPER from README.md and docs/workflow.md

Artifact naming

File Purpose
runs/phase-2-summary-*.md Broad make phase-2
runs/phase-2-summary-sweep-<slug>-*.md Per-file sweep (Phase 2 completion gate)
runs/sweep-summary-*.md Aggregate sweep rollup (codecome hints Sweep block)
tmp/file-sweep-prompts/sweep-summary-YYYYMMDD-HHMMSS.md Generated aggregate prompt

- Rename prompts/sweep.md → prompts/phase-2-sweep.md
- Add prompts/phase-2-sweep-summary.md (aggregate sweep rollup)
- Per-file sweeps write runs/phase-2-summary-sweep-<slug>-*.md
- Aggregate rollup writes runs/sweep-summary-*.md
- find_latest_summary('2') excludes per-file sweep summaries
- Add find_latest_sweep_summary() for sweep-summary-*.md
- Update codecome hints: Phase 2 uses filtered lookup, Sweep block uses rollup
- run-sweep.py invokes aggregate summary after all per-file sweeps succeed
- Update README and docs for new artifact names
- Add tests for sweep exclusion, find_latest_sweep_summary, aggregate summary
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@pruiz, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 7 minutes and 40 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3fb5cea7-81de-4fa3-8806-3d52bcffaa43

📥 Commits

Reviewing files that changed from the base of the PR and between cb84c51 and 2cc850b.

📒 Files selected for processing (12)
  • .project/phase-2-sweep-alignment-plan.md
  • README.md
  • docs/file-risk-sweeps.md
  • docs/workflow.md
  • prompts/phase-2-sweep-summary.md
  • prompts/phase-2-sweep.md
  • tests/test_phases_completion.py
  • tests/test_run_summary_questions.py
  • tests/test_run_sweep.py
  • tools/codecome.py
  • tools/codecome/run_summary_questions.py
  • tools/run-sweep.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/phase-2-sweep-alignment

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.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Coverage Report

Metric Value
Line Coverage 75.8%
Lines Covered 0 / 0

Download detailed HTML coverage reports per OS/Python from the workflow artifacts.

Generated by pytest-cov on 2026-06-12T19:08:41.737Z

Copilot AI 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.

Pull request overview

This PR aligns the file-risk sweep workflow with Phase 2 naming conventions and adds an aggregate “sweep rollup” step so operators can review one consolidated summary after per-file sweeps complete.

Changes:

  • Renames/updates sweep prompt to Phase 2 sweep mode and switches per-file sweep summaries to runs/phase-2-summary-sweep-<slug>-*.md (so Phase 2 completion gates are satisfied).
  • Adds an aggregate sweep summary prompt (prompts/phase-2-sweep-summary.md) and runner orchestration to produce runs/sweep-summary-*.md after successful per-file sweeps.
  • Updates codecome hints and summary lookup helpers/tests so broad Phase 2 summaries exclude per-file sweep summaries, while Sweep uses the aggregate rollup.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/run-sweep.py Uses Phase 2 sweep prompt and runs an aggregate sweep rollup step after per-file sweeps.
tools/codecome/run_summary_questions.py Adds Phase 2 sweep-summary exclusion to broad summary lookup + adds find_latest_sweep_summary().
tools/codecome.py Updates codecome hints to show Sweep from aggregate sweep-summary-*.md only.
tests/test_run_sweep.py Adds tests for new prompt paths and aggregate sweep summary prompt generation.
tests/test_run_summary_questions.py Adds tests for Phase 2 sweep exclusion + find_latest_sweep_summary().
tests/test_phases_completion.py Adds completion-gate tests verifying sweep uses Phase 2-style summary artifacts.
README.md Updates sweep docs to reflect new prompt paths and artifact naming.
prompts/phase-2-sweep.md Updates sweep prompt to Phase 2 naming and per-file sweep summary path.
prompts/phase-2-sweep-summary.md New aggregate sweep rollup prompt (consolidation-only, no new findings).
docs/file-risk-sweeps.md Updates sweep docs for Phase 2 sweep mode + aggregate rollup behavior and artifacts.
.project/phase-2-sweep-alignment-plan.md Adds design/implementation plan documenting the sweep alignment approach.
Comments suppressed due to low confidence (1)

prompts/phase-2-sweep.md:162

  • The example sweep summary filename uses upload-php (dot replaced with a hyphen), but the sweep runner’s slugify() preserves dots (e.g., upload.php). This mismatch can confuse operators/models about the expected <slug> format.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/codecome/run_summary_questions.py Outdated
@greptile-apps

greptile-apps Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR aligns the file-risk sweep tooling with Phase 2 naming conventions and adds an aggregate sweep summary step that consolidates per-file results into a single rollup after all sweeps complete.

  • Rename prompts/sweep.mdprompts/phase-2-sweep.md; per-file sweep summaries now write to runs/phase-2-summary-sweep-<slug>-*.md, satisfying the Phase 2 completion gate.
  • New prompts/phase-2-sweep-summary.md and run_sweep_summary() orchestrate a final opencode run rollup step that writes runs/sweep-summary-*.md; codecome hints surfaces this via a new Sweep block using find_latest_sweep_summary().
  • find_latest_summary(\"2\") now unconditionally excludes per-file sweep summaries via fnmatch, preventing them from polluting the broad Phase 2 block in codecome hints.

Confidence Score: 5/5

Safe to merge; the naming alignment, lookup helpers, and docs are all internally consistent, and the test coverage is solid.

The core logic is correct and well-tested. The two flagged items are edge-case defensive-coding gaps: the missing runs/ existence check in the fresh_summaries comprehension (inconsistent with every other helper in the file) and the lack of a guard that skips the rollup when no fresh summaries are collected. Neither can cause data loss or incorrect findings; the worst outcome is a confusing empty rollup or a version-dependent OSError on Python less than 3.12.

tools/run-sweep.py — the fresh_summaries collection and the unconditional run_sweep_summary call.

Important Files Changed

Filename Overview
tools/run-sweep.py Adds aggregate sweep-summary orchestration; removes CODECOME_USE_WRAPPER branch; fresh_summaries collection lacks a runs/ existence guard and doesn't skip the rollup when no fresh summaries are found.
tools/codecome/run_summary_questions.py Adds exclude_patterns parameter and sweep-exclusion default for phase-2 lookups; adds find_latest_sweep_summary(); implementation is clean and well-tested.
tools/codecome.py Replaces per-file sweep scan with single aggregate sweep-summary lookup; imports find_latest_sweep_summary; change is clean and correct.
prompts/phase-2-sweep-summary.md New aggregate rollup prompt; correctly forbids fresh hunting and new finding creation; instructs model to use only the injected per-file summary list.
prompts/phase-2-sweep.md Renamed from sweep.md; updated artifact naming to phase-2-summary-sweep--*.md; correctly aligned with Phase 2 conventions.
tests/test_run_sweep.py New test file covering template path, slug, build_prompt_for_file, and build_sweep_summary_prompt; good coverage but no test for the empty fresh_summaries rollup path.
tests/test_run_summary_questions.py Adds sweep-exclusion and find_latest_sweep_summary tests; comprehensive and well-structured.
tests/test_phases_completion.py Adds TestSweepCompletionGate verifying the Phase 2 gate accepts sweep-named summaries; tests are correct and cover the key scenarios.

Sequence Diagram

sequenceDiagram
    participant Op as Operator
    participant RS as run-sweep.py
    participant RA as run-agent.py
    participant OC as opencode run
    participant FS as runs/ (filesystem)

    Op->>RS: "make sweep FILE=..."
    RS->>RS: select files, build per-file prompts
    loop Each selected file
        RS->>RA: --phase 2 --prompt-file sweep-slug.md
        RA->>OC: opencode run auditor agent
        OC-->>FS: phase-2-summary-sweep-slug-TIMESTAMP.md
        OC-->>RA: exit code
        RA-->>RS: exit code Phase 2 completion gate checked
    end
    RS->>RS: collect fresh_summaries mtime filter
    RS->>OC: opencode run --agent auditor sweep-summary prompt
    OC-->>FS: sweep-summary-TIMESTAMP.md
    OC-->>RS: exit code
    RS-->>Op: done aggregate rollup printed to screen

    note over Op: make hints
    Op->>RS: codecome hints
    RS->>FS: find_latest_summary 2 excludes sweep files
    RS->>FS: find_latest_sweep_summary returns sweep-summary files
    RS-->>Op: Phase 2 block plus Sweep block no duplicates
Loading

Reviews (2): Last reviewed commit: "fix: address PR #55 review comments" | Re-trigger Greptile

Comment thread tools/run-sweep.py
Comment thread tools/run-sweep.py Outdated
- Docstring: 'override or extend' → 'extend' (exclude_patterns cannot
  override the implicit Phase 2 sweep exclusion)
- Use fnmatch for exclude_patterns matching instead of Path.match
- Rename test: overrides_default → extends_default
- Remove deprecated CODECOME_USE_WRAPPER branch from run-sweep.py;
  per-file sweeps always use the wrapper path
- Document why aggregate rollup uses raw opencode run
- Simplify aggregate-summary guard: drop redundant len(files) >= 1
- Capture sweep_start_time; only feed fresh per-file summaries to the
  aggregate prompt (avoid stale summary contamination)
- Use timestamped aggregate prompt path instead of fixed name
- Update aggregate prompt to read only injected summary paths
- Fix slug example: upload-php → upload.php
- Clean CODECOME_USE_WRAPPER references from README.md and docs/workflow.md
@pruiz

pruiz commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

Thanks for the reviews. All feedback has been addressed in commit 2cc850b:


Copilot: docstring says "override" but implementation cannot override

Fixed. Docstring now says "extend" instead of "override". The implicit phase-2-summary-sweep-*.md exclusion for Phase 2 calls is always applied; exclude_patterns can extend but not override it. Also renamed test test_explicit_exclude_pattern_overrides_defaulttest_explicit_exclude_pattern_extends_default, and switched matching from Path.match() to fnmatch for clarity.


Greptile: aggregate summary bypasses CODECOME_USE_WRAPPER

CODECOME_USE_WRAPPER is deprecated (see .project/migrate-to-opencode-serve.md and .project/codeql-integration-plan.md which both call for its removal). Rather than supporting it, the follow-up commit:

  • Removed the deprecated CODECOME_USE_WRAPPER branch from run_one_file() entirely — per-file sweeps now always use the wrapper path
  • Added a docstring to run_sweep_summary() explaining why the aggregate rollup uses raw opencode run (it is not a phase-mode run and run-agent.py lacks non-phase utility support)
  • Cleaned CODECOME_USE_WRAPPER references from README.md and docs/workflow.md

Greptile: redundant guards in aggregate-summary call

Fixed. The len(files) >= 1 guard was redundant (earlier if not files: return 0 guarantees non-empty). Simplified to if not args.dry_run: and dropped the dry_run parameter from run_sweep_summary() since it can never be reached during dry-run.


Additional fixes in 2cc850b

  • Stale summary contamination: main() now records sweep_start_time before per-file runs and collects only fresh per-file summaries (mtime >= sweep_start_time) matching phase-2-summary-sweep-{slugify(file)}-*.md. These exact paths are injected into the generated aggregate prompt.
  • Aggregate prompt updated: now tells the model to read only the injected per-file summary paths, not all historical phase-2-summary-sweep-*.md.
  • Slug example fixed: upload-phpupload.php in the per-file sweep prompt to match slugify() output.
  • Timestamped aggregate prompt path: tmp/file-sweep-prompts/sweep-summary-YYYYMMDD-HHMMSS.md instead of fixed sweep-summary-prompt.md.

All 825 non-MockLLM tests pass + frontmatter validation ✓

@pruiz pruiz left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Replying to review threads: all feedback addressed in 2cc850b.

@pruiz pruiz left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

All review feedback addressed in 2cc850b. Thank you both for the thorough review.

Comment thread tools/codecome/run_summary_questions.py
Comment thread tools/run-sweep.py
Comment thread tools/run-sweep.py
@pruiz

pruiz commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

@greptile-apps: your summary analysis and the two inline comments on tools/run-sweep.py were addressed in commit 2cc850b:

  • CODECOME_USE_WRAPPER inconsistency: This env var is deprecated project-wide. Removed the legacy branch from run_one_file() entirely. Aggregate rollup uses raw opencode run by design (not a phase-mode run; documented in the function docstring). Cleaned CODECOME_USE_WRAPPER from README.md and docs/workflow.md.

  • Redundant guards: Simplified to if not args.dry_run: and dropped the dead dry_run parameter from run_sweep_summary().

  • Additional fix: The aggregate prompt now injects exact per-file summary paths (filtered by sweep_start_time) instead of telling the model to read all historical phase-2-summary-sweep-*.md.

Thank you for the review.

@pruiz

pruiz commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

@copilot-pull-request-reviewer: your docstring concern on tools/codecome/run_summary_questions.py was addressed in commit 2cc850b. The docstring now says "extend" instead of "override", matching the implementation where phase-2-summary-sweep-*.md is always excluded for Phase 2 calls regardless of exclude_patterns. The corresponding test was renamed and matching switched to fnmatch for clarity. Thank you.

@greptile-apps

greptile-apps Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

All the changes look correct and address the feedback precisely:

  • CODECOME_USE_WRAPPER branch removed from run_one_file() — per-file runs always use run-agent.py
  • run_sweep_summary() has no dry_run parameter; the guard at the call site is a clean if not args.dry_run:
  • sweep_start_time = time.time() is captured before the loop, and fresh_summaries is filtered by st_mtime >= sweep_start_time
  • Aggregate prompt gets exact timestamped paths injected, with a clear instruction to read only those summaries
  • The docstring on run_sweep_summary correctly explains the raw opencode run choice
  • Prompt path is now timestamped (sweep-summary-YYYYMMDD-HHMMSS.md)

Everything checks out. The stale-summary filtering via sweep_start_time is a particularly solid fix — it's both correct and robust to partial reruns. Thanks for the thorough follow-up.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

@pruiz pruiz merged commit cb06ce2 into master Jun 12, 2026
8 checks passed
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.

2 participants