Skip to content

feat: add idempotent GitHub issue creation from repo analysis - #43

Merged
taras merged 1 commit into
mainfrom
feat/cleanup-issues
Mar 18, 2026
Merged

taras merged 1 commit into
mainfrom
feat/cleanup-issues

Conversation

@taras

@taras taras commented Mar 18, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Adds a CleanupIssues.md EMA component that creates, updates, and closes GitHub issues based on the top 5 file clusters from the deterministic repo analysis.

Why?

The repo analysis pipeline produces actionable cleanup findings but they were trapped in a markdown report artifact. This closes the loop by creating trackable GitHub issues that reflect the current state of code health.

How idempotency works

Each issue body contains a marker: <!-- ema-cleanup:{file} -->. On each run:

Existing issue? File in top 5? Action
No Yes Create new issue
Yes Yes Update title + body
Yes No Close with comment

Issue identity is driven by buildCleanupAnalysis() — deterministic code, not LLM output. Running the analysis 10 times produces exactly 5 open issues (assuming same data).

Changes

  • .reviews/components/CleanupIssues.md (new) — persist eval component with sequential GitHub API calls, marker-based idempotent lookup, ema-cleanup label management
  • .reviews/components/RepoPolicyReport.md — adds <CleanupIssues> invocation after the report
  • .github/workflows/repo-analysis.yml — adds issues: write permission, passes GITHUB_TOKEN and GITHUB_REPOSITORY env vars
  • specs/code-review-agent-spec.md — documents §13.8 cleanup issues lifecycle

Scope confirmation

  • All changed files relate to the stated purpose
  • No drive-by refactors or "while I'm here" cleanups
  • No formatting changes mixed with functional changes

Verification

  • Lint: 77 files, 0 errors
  • Typecheck: clean
  • Tests: 78 passed, 0 failed
  • Behavioral verification: dispatch workflow after merge

CleanupIssues.md creates/updates/closes GitHub issues for the top 5
file clusters from buildCleanupAnalysis(). Each issue body contains
a marker comment (<!-- ema-cleanup:{file} -->) for idempotent lookup.
Issues are labeled ema-cleanup and managed deterministically:

- No matching issue + file in top 5 → create
- Matching issue + file in top 5 → update title and body
- Matching issue + file NOT in top 5 → close with comment

Issue identity is driven by deterministic cluster data (file path,
score, violation count, co-occurring rules, category breakdown),
not LLM output. Local runs skip silently (no GITHUB_TOKEN).

Also adds issues:write permission to repo-analysis.yml and passes
GITHUB_TOKEN and GITHUB_REPOSITORY env vars to the analysis step.
@github-actions

Copy link
Copy Markdown

PR #43: feat: add idempotent GitHub issue creation from repo analysis

4 files, +183 / -1

Scope

✅ PR scope looks good.

Structural

✅ No structural bloat detected.

Slop

Static Analysis

✅ Oxlint found no issues.

Correctness

No extraneous code patterns detected.

@taras
taras merged commit 4982643 into main Mar 18, 2026
3 checks passed
@taras
taras deleted the feat/cleanup-issues branch March 18, 2026 00:34
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