Skip to content

Tighten sweep output: dedupe categories, expand deterministic findings, fix recently-changed amplification - #132

Merged
theletterf merged 1 commit into
mainfrom
improve-sweep-output-quality
May 5, 2026
Merged

theletterf merged 1 commit into
mainfrom
improve-sweep-output-quality

Conversation

@theletterf

Copy link
Copy Markdown
Member

Summary

Five concrete improvements to the seven sweep workflows, driven by analysis of the first end-to-end run on elastic/docs-content (issues #6263–#6269).

1. Frontmatter sweep stops overlapping with applies-to sweep

docs-frontmatter-audit emits missing-applies-to and invalid-applies-to; the dedicated docs-applies-to-sweep also flags those. Both issues duplicated each other. Frontmatter sweep now drops those two categories from its emitted output and explicitly defers to gh-aw-docs-applies-to-sweep.

2. Deterministic findings are no longer thrown away by an LLM-style cap

The typos issue noted codespell raised 202 raw findings, 20 retained after filtering (capped at 20 per policy) — we discarded 90% of accurate signal. Same applied to staleness's broken-external-link, stale-content, stale-screenshot categories (all lychee or python-pre-step output, no agent judgment involved). The cap was designed to keep judgment findings reviewable; deterministic ones don't need it.

Now:

  • typos and staleness emit all deterministic findings, capped only by a hard 400-row safety belt (GitHub issue body limit ≈ 65,536 characters);
  • the per-issue cap (max-per-fix-issue) applies only to the LLM-judgment category unsupported-version-mention in staleness; the input is not used at all for typos.

3. Recently-changed pass no longer swallows the corpus

Look at the first run's stats: staleness reported 629 recently-changed · 725 total in scope for a 96-page slice; coherence reported 2718 recently-changed · 2762 total in scope · corpus 2716 pages — effectively 100% of the corpus was "recent," so rotation had no effect at all.

Two fixes, applied to all six rotating sweeps (typos is full-repo, no rotation):

  • tighten git log --since='7 days ago' → '2 days ago';
  • fall back to slice-only when recent_count exceeds 2 × target-batch-size, with a console line recently-changed pass produced N pages (>2x target batch M); disabling for this run so the operator can see why.

4. Findings now sort predictably

Every sweep sorts by severity (high → medium → low), then file ascending, then line ascending. Findings on the same file end up adjacent so an author can fix one file in one PR. Caps count distinct files, not rows.

5. Openings sweep won't emit vague suggested_fix values

First run produced rows like "review and refresh; either update content or move to archive" — non-actionable. The openings prompt now explicitly tells the agent to omit suggested_fix rather than emit generic advice.

Out of scope (filed separately if confirmed)

The style, frontmatter, and openings issues from the first run (#6266, #6267, #6268) came back with identical bodies and frontmatter-audit findings, while the applies-to sweep produced correct applies-to-specific output. Either the agent runtime aliased prompts across sibling reusable workflows in the same orchestrator run, or the style/openings agents collapsed onto the easiest available skill (docs-frontmatter-audit). I did not fix this here because the fix is plausibly upstream in gh-aw, not in our prompt content. Worth investigating once we have the agent step logs to confirm what skill(skill: …) each actually invoked.

Test plan

  • make compile passes with 0 errors / 0 warnings (verified locally).
  • After merge + release: re-run docs-quality-sweep on docs-content with sweeps=all. Confirm the new typos issue includes ~all 200+ codespell findings (modulo false-positive filter), not 20.
  • Confirm the staleness issue lists every broken-external-link and stale-screenshot finding (no longer truncated to the cap).
  • Confirm recent_count is small (the 2-day window should give a much lower number; if a corpus-wide rebase happens, the operator should see the disable-message in the agent step log).
  • Confirm the YAML block opens with severity: high rows.
  • Confirm the frontmatter sweep no longer emits missing-applies-to / invalid-applies-to rows; those should appear only in the applies-to sweep's issue.

🤖 Generated with Claude Code

…s, fix recently-changed amplification

Driven by the seven fix-issues that landed from the first end-to-end run on
elastic/docs-content (#6263–#6269). Five concrete pain points + their
fixes:

1. **Frontmatter sweep was overlapping with applies-to sweep**.
   `docs-frontmatter-audit` emits `missing-applies-to` and
   `invalid-applies-to`; the dedicated `docs-applies-to-sweep` also flags
   them. Both issues end up duplicating each other. Frontmatter sweep
   now drops those two categories from its emitted output and explicitly
   defers to `gh-aw-docs-applies-to-sweep`.

2. **Deterministic findings were being thrown away by an LLM-style cap**.
   The typos issue noted `codespell raised 202 raw findings, 20
   retained after filtering (capped at 20 per policy)`. We discarded
   90 % of perfectly accurate signal. The same applied to staleness'
   `broken-external-link`, `stale-content`, and `stale-screenshot`
   categories — all lychee or python-pre-step output, no agent judgment
   involved. The cap was designed to keep *judgment* findings reviewable;
   deterministic ones don't need it. Both sweeps now:
   - emit *all* deterministic findings, capped only by a hard 400-row
     safety belt (GitHub issue body limit ≈ 65,536 characters);
   - keep the per-issue cap only on the LLM-judgment categories
     (`unsupported-version-mention` for staleness; nothing in typos —
     the input is now ignored there).

3. **The recently-changed pass was swallowing the entire corpus**, so
   rotation had no effect. On the first docs-content run the staleness
   sweep reported `629 recently-changed · 725 total in scope` for a
   96-page slice; coherence reported `2718 recently-changed · 2762 total
   in scope · corpus 2716 pages` — i.e. effectively 100 % of the corpus
   was "recent." Two fixes:
   - tighten `git log --since='7 days ago'` → `'2 days ago'`;
   - fall back to slice-only when `recent_count` exceeds `2 × target-batch-size`,
     printing `recently-changed pass produced N pages (>2x target batch
     M); disabling for this run` so the operator can see why.
   Applied to all six rotating sweeps. Typos is full-repo, no rotation,
   no recent-pass — left unchanged.

4. **Findings were not sorted predictably**. Authors reading the YAML
   block want highest-leverage rows first and want all rows for a single
   file adjacent. Every sweep now sorts by `severity` (high → medium →
   low), then `file` ascending, then `line` ascending; multiple findings
   on the same `file` end up grouped naturally. Caps now count distinct
   files, not rows.

5. **Vague `suggested_fix` values**. The openings sweep's first run
   produced rows like `"review and refresh; either update content or
   move to archive"` — non-actionable. Openings prompt now explicitly
   tells the agent to omit `suggested_fix` rather than emit generic
   advice. (The other sweeps already did this implicitly via the Rigor
   fragment; openings was the outlier because the underlying
   `docs-page-opening-optimizer` skill produces narrative rewrites.)

## Out of scope for this PR

The first run produced one notable bug we did *not* fix here: the
style, frontmatter, and openings issues (#6266, #6267, #6268) all came
back with **identical bodies and frontmatter-audit findings**, while the
applies-to sweep produced its own correct output. Either the agent
runtime aliased prompts across sibling reusable workflows in the same
orchestrator run, or the style/openings agents collapsed onto the
easiest available skill (`docs-frontmatter-audit`). Worth investigating
separately once we have the agent step logs of those three jobs —
filing a follow-up after we can confirm what `skill(skill: …)` they
actually invoked. Not in this PR because the fix is plausibly upstream
in gh-aw, not in our prompt content.

`make compile` produces 0 errors, 0 warnings.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@theletterf
theletterf requested a review from a team as a code owner May 5, 2026 10:59
@theletterf
theletterf requested a review from Mpdreamz May 5, 2026 10:59
@theletterf theletterf self-assigned this May 5, 2026
@theletterf theletterf added the fix label May 5, 2026
@theletterf
theletterf merged commit b45090a into main May 5, 2026
3 of 4 checks passed
@theletterf
theletterf deleted the improve-sweep-output-quality branch May 5, 2026 11:17
theletterf added a commit to elastic/docs-content that referenced this pull request May 5, 2026
…n` master (#6271)

## Summary

Refactors the docs-quality-sweep installation to work around
[github/gh-aw#30338](github/gh-aw#30338).

The current orchestrator (merged via #6255) uses `workflow_call` to fan
out to seven gh-aw reusable workflows in parallel. gh-aw v0.71.x derives
a single artifact prefix per orchestrator run from `github.workflow +
github.run_id`, both of which are identical for every reusable
workflow_call invocation in one run. Result: all seven sub-workflows
upload and download the **same** `<prefix>-activation.zip` and
`<prefix>-agent.zip`. Last activation wins the race; every agent loads
the same prompt. Three of the seven fix-issues from the first run came
back with frontmatter-audit findings regardless of which sweep was
supposed to run (#6266 / #6267 / #6268).

Until upstream lands a fix, this PR dispatches each sweep as its own
independent workflow run.

## New layout

| File | Role |
|---|---|
| `docs-quality-sweep.yml` (modified) | Master dispatcher. Triggers on
`workflow_dispatch`. One job that uses `gh workflow run` to fire each
selected sub-workflow. Exits in seconds. |
| `docs-frontmatter-sweep.yml` (new) | Calls
`elastic/docs-actions/.github/workflows/gh-aw-docs-frontmatter-sweep.lock.yml@v1`.
|
| `docs-applies-to-sweep.yml` (new) | Calls the applies-to reusable. |
| `docs-openings-sweep.yml` (new) | Calls the openings reusable. |
| `docs-style-sweep.yml` (new) | Calls the style reusable. |
| `docs-typos-sweep.yml` (new) | Calls the typos reusable. |
| `docs-staleness-sweep.yml` (new) | Calls the staleness reusable. |
| `docs-coherence-sweep.yml` (new) | Calls the coherence reusable. |

Each sub-workflow has its own \`github.workflow\` and its own
\`github.run_id\`, so the artifact prefix gh-aw computes is now distinct
per sweep — no collision.

## UX

`gh workflow run docs-quality-sweep.yml -f sweeps=all` still works as
the single dispatch point. The master prints \`→ dispatching
docs-<name>-sweep.yml\` for each selected sweep and exits in a few
seconds; the sub-runs appear separately in the Actions tab.

Selective dispatch still works via the \`sweeps\` input:

\`\`\`bash
gh workflow run docs-quality-sweep.yml -f sweeps=frontmatter,typos
\`\`\`

Sub-workflows can also be dispatched directly without going through the
master, e.g. for retrying just one sweep:

\`\`\`bash
gh workflow run docs-style-sweep.yml
\`\`\`

That wasn't possible with the previous \`workflow_call\` orchestrator.

## Why \`GITHUB_TOKEN\` is enough

\`workflow_dispatch\` and \`repository_dispatch\` are explicit
exceptions to the "GITHUB_TOKEN can't trigger workflows" rule (per the
GitHub Actions docs). The master uses the auto-provided token; no PAT or
App token needed. The master itself only needs \`actions: write\`; the
sub-workflows retain \`actions: read\` + \`issues: write\` for fix-issue
creation.

## Trade-offs vs. the old orchestrator

| | old (\`uses:\`) | new (\`gh workflow run\`) |
|---|---|---|
| Single dispatch point | ✓ | ✓ |
| Artifact-name isolation | ❌ collides (gh-aw#30338) | ✓ each sub-run
independent |
| Visible as one workflow run | ✓ | master + 7 separate sub-runs |
| Per-sweep retry without re-running everything | ❌ | ✓ |
| \`sweeps=…\` filter | ✓ | ✓ |
| Number of files in this repo | 1 | 8 |

The 8-file footprint is the only real regression and it's bounded —
they're trigger templates, not maintained logic.

## Test plan

- [ ] Merge this PR.
- [ ] Dispatch \`docs-quality-sweep.yml\` with \`sweeps=typos\`
(cheapest, no APM). Confirm the master run finishes in under a minute
and a separate \`Docs typos sweep\` run appears in the Actions tab.
- [ ] Confirm the new typos issue lands here (no longer capped at 20 —
should reflect ~all codespell findings once docs-actions PR #132 ships).
- [ ] Dispatch with \`sweeps=frontmatter,style\`. Confirm two separate
sub-runs appear, each with distinct artifact names
(\`<unique-prefix-A>-activation.zip\` for frontmatter,
\`<unique-prefix-B>-activation.zip\` for style — verify in the agent
step logs).
- [ ] Confirm the resulting two fix-issues have **distinct** content —
frontmatter findings in the frontmatter issue, style findings in the
style issue. This is the regression we're trying to fix.
- [ ] Once happy, dispatch with \`sweeps=all\` and confirm seven
sub-runs each produce a category-correct fix-issue.

## Related

- gh-aw issue:
[github/gh-aw#30338](github/gh-aw#30338)
- docs-actions PR adding the underlying sweep prompts:
[elastic/docs-actions#132](elastic/docs-actions#132)
(open) — improves the per-sweep output once the agent prompts are no
longer cross-contaminating.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant