Skip to content

Pattern miner: Add code-health-auditor archetype: bounded structural code-quality audits - #157

Merged
pelikhan merged 3 commits into
mainfrom
pattern-miner/code-health-auditor-f3d696c76e692793
Aug 24, 2026
Merged

Pattern miner: Add code-health-auditor archetype: bounded structural code-quality audits#157
pelikhan merged 3 commits into
mainfrom
pattern-miner/code-health-auditor-f3d696c76e692793

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Upstream evidence

Mined githubnext-agentics/files/workflows/ (from data/import-sources.json's githubnext/agentics source):

  • duplicate-code-detector.md — schedule/workflow_dispatch trigger, create-issue safe-output with expires: 2d, title-prefix, assignees: copilot, bounded to one recurring defect pattern per run.
  • large-file-simplifier.md — schedule trigger with skip-if-match: 'is:issue is:open in:title "[large-file-simplifier]"', tracker-id: large-file-simplifier, create-issue with expires: 2d and assignees: copilot, bounded to the single largest file exceeding a size threshold.
  • code-simplifier.md — schedule trigger with skip-if-match: 'is:pr is:open in:title "[code-simplifier]"', tracker-id: code-simplifier, create-pull-request with expires: 1d.

Confirmed as a deliberate, documented pattern (not a one-off) in github-gh-aw/files/.github/aw/syntax-agentic.md, which documents tracker-id as a first-class field ("tag all created assets ... enables searching and retrieving assets associated with this workflow") and in github-gh-aw/files/.github/aw/safe-outputs-content.md, which documents assignees: [user1, copilot] ("use 'copilot' for bot") as a supported create-issue/create-pull-request option.

Recurring pattern found

Three upstream workflows demonstrate the same shape: a scheduled, bounded structural code-health audit (oversized files, duplicated code, unnecessary complexity) that reports or fixes exactly one finding per run, guarded against re-triggering with tracker-id + skip-if-match (or deduplicate-style title checks) and expires on the created asset, with assignees: copilot so remediation can continue automatically.

Why the existing library did not cover it

  • code-improvement is issue-driven, general-purpose bug/CI fixing — not scheduled structural auditing.
  • linter-miner proposes new lint rules from recurring defects, not one-off structural findings (file size, duplication) reported directly as an issue/PR.
  • performance-nut targets runtime/build performance, not structural code health (size, duplication).
  • No existing archetype's tips mention tracker-id/skip-if-match dedup guards or assignees: copilot, both of which recur across all three source workflows and the upstream docs.

What changed

  • Added patterns/archetypes/code-health-auditor.json — new curated archetype (success_rate: null, count: 0, top_repos: []) recommending schedule trigger, create-issue safe output, create-issue tool, phase-based prompt style, with tips on scoping to one structural dimension, using tracker-id/skip-if-match, expires, and assignees: copilot.
  • Appended code-health-auditor to archetypes in patterns/manifest.json.
  • Added the code-health-auditor runtime generation entry (icon, capabilities, instructions, prompt body) to patterns/workflow-generation.json.

No other files were touched.

Validation

  • npm test — 183 tests passed across all 12 test files.
  • npm run build — production build succeeded; new archetype JSON emitted correctly under dist/patterns/archetypes/.

Candidates deliberately left out

  • assignees: copilot as a standalone tip on existing archetypes — folded into the new archetype's tips instead of touching unrelated curated entries, per the "keep changes minimal" rule.
  • A separate "duplicate-detector" or "large-file" archetype — the three upstream workflows are different instances of one shape (bounded structural audit with dedup guards), so they were merged into a single code-health-auditor archetype rather than three near-duplicate entries.
  • cost-tracker.md (workflow_run trigger) — only one upstream example, and workflow_run is already flagged as a documented anti-pattern (13% success) in the library; not enough corroboration to add as a new archetype.
  • repository-quality-improver.md's cache-memory focus-area rotation — interesting but only one upstream example without corroborating documentation recommending it as a named pattern; left out per the two-workflow-minimum rule.

Generated by Pattern Miner · auto · 76.2 AIC · ⌖ 3.37 AIC · ⊞ 8.3K ·

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@pelikhan pelikhan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot these AWs should use LSP tool

Copilot AI and others added 2 commits August 24, 2026 11:33
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

@copilot these AWs should use LSP tool

Implemented in 22f4c08 (with configuration validation in 6526fc1). Generated Copilot code-health auditor workflows now configure TypeScript/JavaScript LSP, use it before text search, and allow the Node registry needed to install the server.

Copilot AI requested a review from pelikhan August 24, 2026 11:36
@pelikhan
pelikhan marked this pull request as ready for review August 24, 2026 11:47
@pelikhan
pelikhan merged commit 506e71c into main Aug 24, 2026
1 check passed
@pelikhan
pelikhan deleted the pattern-miner/code-health-auditor-f3d696c76e692793 branch August 24, 2026 11:47

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewer: matt-pocock (TypeScript/JS-focused)

Reviewed the diff (new code-health-auditor archetype + lspFor() LSP wiring in src/js/workflow.js, plus the guard-fix commit validating command/fileExtensions before emitting LSP config).

No blocking issues found:

  • lspFor correctly returns null for non-Copilot engines and now defensively filters out incomplete LSP entries (missing command or empty fileExtensions) before emitting YAML — good guard against malformed template data producing broken frontmatter.
  • New archetype JSON and generation entry follow the existing schema/conventions used by sibling archetypes.
  • Test suite passes locally (185/185, including the two new tests covering LSP frontmatter generation and the non-Copilot-engine no-op case).

Minor non-blocking observations (not requesting changes):

  • lspFor's validity check only inspects the first LSP entry structurally; if patterns ever defines multiple languages per archetype with mixed validity, only the invalid ones are dropped, which is the intended behavior — confirmed correct, no action needed.
  • The generated args array is serialized with simple string quoting ("${arg}" via template) rather than a YAML-safe serializer; fine today since values are static/curated JSON, but would be worth a sanitize/escape step if archetype data ever becomes user-editable.

No merge-blocking concerns.

Generated by Specialist PR Review for #157 · auto · 25.2 AIC · ⌖ 2.51 AIC · ⊞ 7.9K

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