Skip to content

perf(pr-management): trim the family's skills without changing behaviour - #1390

Merged
potiuk merged 3 commits into
apache:mainfrom
liwenjie200543:optimize-pr-management-family
Sep 26, 2026
Merged

potiuk merged 3 commits into
apache:mainfrom
liwenjie200543:optimize-pr-management-family

Conversation

@liwenjie200543

@liwenjie200543 liwenjie200543 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Apply the setup-family optimization recipe (umbrella #1342) to the
pr-management family (#1346).

Body tokens across the eight skills (cl100k_base, whole SKILL.md):

skill before after
pr-management-triage 11,604 4,951
pr-management-code-review 9,147 4,925
pr-management-quick-merge 7,356 4,722
pr-management-stats 7,211 3,442
pr-stale-sweep 6,726 4,937
reviewer-routing 5,192 4,931
pre-first-pr-check 3,506 3,467
pr-management-mentor 2,976 2,940
total 54,714 34,315 (−37.3%)

All eight skills are now inside the 5,000-token body budget and the
500-line cap; all always-on frontmatter budgets are met.

Maintainer note: counts re-stamped after rebasing onto #1394 and the
reviewer-routing fixup (restored "in this session" in Golden rule 1 and
the catch-all when_to_use trigger).

Behaviour

  • Eval-safety: all 22 step-config.json extraction targets across the
    eval suites touching this family resolve to their exact heading in
    the exact file they point to after the edit.
  • surface_hash re-stamped with
    tools/dev/skill-surface-hash.py --fix (heading moves change the
    fingerprint; prose rewording does not).
  • check-shared-blocks.py: pre-flight blocks in sync across all 65
    skills. check-duplication.py: 0 pairs above the fail threshold.
  • Every moved block verified byte-for-byte against HEAD, and
    move-not-copy checked by grep for each moved heading.

Test plan

  • skill-token-count --check passes against the re-stamped counts
  • tools/skill-evals pytest: 174 tests, no new failures vs. the
    untouched baseline (13 environment-related failures on this
    Windows machine — symlink/wsl artifacts — identical before and
    after)
  • skill-and-tool-validate: no findings in the touched plugin

Closes #1346. Part of #1342.

@liwenjie200543
liwenjie200543 force-pushed the optimize-pr-management-family branch from 51475d1 to 327c0f6 Compare September 26, 2026 10:34
Body tokens across the eight pr-management skills drop from 54,714 to
34,298 (-37.3%), all inside the 5,000-token body budget and the
500-line cap, with all always-on frontmatter budgets met.

- Trim every skill's frontmatter under the 200-token always-on budget
  (7 of 8 skills were over).
- Move sub-action-specific sections and individual sub-action golden
  rules into sibling files byte-for-byte and repoint their references,
  the same technique as the setup-family PRs (apache#1353): 16 new sibling
  files, no section left in two places.
- Tighten remaining prose to SemBr one-sentence-per-line, keeping
  headings, golden-rule headlines, code blocks, tables and the
  generated pre-flight block byte-identical.
- Fix one stale pointer per the apache#1353 precedent: pr-triage's moved
  Step 6b block in session-history.md anchored [Parameters] at the
  sibling itself.
- Regenerate docs/mode-economics.md via skill-token-count --write.

Verification: skill-token-count --check passes against the regenerated
table; all 22 eval step-config.json extraction targets across the
suites touching this family resolve to their exact heading in the
exact file they point to; check-shared-blocks in sync across all 65
skills; check-duplication reports 0 pairs above the fail threshold;
skill-evals pytest runs 174 tests with no new failures vs the
untouched baseline; skill-and-tool-validate reports no findings in
the touched plugin.

Closes apache#1346. Part of apache#1342.

Generated-by: GLM-5.3-Flash
- markdownlint: drop a double blank line in pr-triage SKILL.md, insert
  blank lines before thematic breaks that parsed as setext headings
  (quick-merge fetch-and-screen, stats classify/fetch/render), and
  promote the moved Step 6b section to h2 in session-history.md so
  heading levels increment.
- Anchors: repoint six links whose SKILL.md targets moved into sibling
  files (pr-triage actions/classify-and-act/interaction-loop/
  prerequisites, quick-merge present-and-handoff, and the
  projects/_template config), keeping every fragment slug identical.
- docs/setup/marketplace.md: refresh the family's declared always-on
  tokens to ~0.8k after the frontmatter trim.
- Regenerate docs/mode-economics.md and docs/vendor-neutrality.md.

Verification: skill-token-count --check passes; check-shared-blocks in
sync (65 skills); check-duplication 0 pairs above threshold;
skill-evals pytest 174 tests with no new failures vs the untouched
baseline; every eval step-config extraction target still resolves;
all six repointed anchors verified against the headings now holding
them.

Generated-by: GLM-5.3-Flash
@liwenjie200543
liwenjie200543 force-pushed the optimize-pr-management-family branch from 327c0f6 to 21ba99b Compare September 26, 2026 11:35
…on and catch-all trigger

The trim dropped "in this session" from Golden rule 1, loosening the
confirmation requirement, and the "any variation on proposing a first
reviewer" catch-all from when_to_use, which routes paraphrased requests
to the skill. Restore both. Re-stamp measured_tokens after rebasing onto
the per-skill token stamps.

Generated-by: Claude Opus 5
@liwenjie200543

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (includes #1392).

The only conflict was the generated token-count table in docs/mode-economics.md; resolved by regenerating it with skill-token-count --write, so the table now reflects both #1392's isolated-setup updates and this PR's pr-management rows. Verified locally: skill-token-count --check and check-doc-sync both pass; the skill content itself is unchanged from the previously reviewed head.

The workflows will need a fresh approval for the new head. Thanks!

@potiuk
potiuk force-pushed the optimize-pr-management-family branch from 21ba99b to e918ce7 Compare September 26, 2026 11:43
@potiuk potiuk added family:pr-management pr-management-* skills capability:triage Sweep + classify + propose disposition labels Sep 26, 2026

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks — this is a careful refactor. I rebased it onto current main (including #1394, which moves token counts into each skill's frontmatter) and pushed one fixup commit. Checks done:

  • Moved, not changed — verified mechanically. Per skill, the multiset of words across all its files is unchanged except the declared SemBr tightening and repointed anchors. In pr-triage I traced each safety rule individually: the real-CI guard (now in actions.md, with its row-14a / promotion-sweep coverage and agent-guard note), the prompt-injection examples, "never mutates without explicit confirmation", and the fetch-step "don't read bodies/diffs" rule all survived.
  • Fixup (e918ce7). Two wording changes in reviewer-routing altered behaviour, so I restored them: "in this session" in Golden rule 1 (confirmation must come from the current session), and the "find the best reviewer for this change" / "any variation on proposing a first reviewer" triggers in when_to_use. The skill stays inside its budgets (4,931 body tokens); the description's token table is updated accordingly.
  • Rebase. The docs/mode-economics.md conflict dissolved with #1394; measured_tokens is re-stamped for all eight skills.
  • Hooks / checks. prek run --all-files: all 36 hooks pass; skill-token-count --check passes; surface_hash in sync.
  • Evals. All eight suites run against the rebased tree (275 cases, claude -p, haiku grader): 261 passed on the first run. Every failure was re-run on both this branch and main: each is either failing on main too or flaky in both directions, except pr-management-triage/pre-filter/case-6-viewer-is-author, where the decision fields match on every run and only the free-text reason now mentions filter ordering — not a behaviour change. The grader flakiness itself is being addressed separately.

This review was drafted by an AI-assisted tool and confirmed by an Apache Magpie maintainer. The maintainer approving this PR has read the findings and signed off. If something feels off, please reply on the PR and a maintainer will follow up.

More on how Apache Magpie handles maintainer review: CONTRIBUTING.md.

@potiuk
potiuk merged commit 373a0e1 into apache:main Sep 26, 2026
10 checks passed
potiuk added a commit that referenced this pull request Sep 26, 2026
…rect answers (#1398)

Most eval flakiness was the grading, not the model: in 14 cases that
flaked on #1390, the decision fields matched on every run and the
failure came from the haiku grader rejecting a correct free-text
explanation, or from a regex check on prose.

- Grader rubric (single and batch): a candidate reaching the same
  conclusion is a match even when it adds correct detail, omits
  secondary detail, names the rule differently, or explains the
  decision without restating it (the decision is compared exactly in
  its own fields). Answer false only on a different or contradictory
  conclusion. A negative control of contradicting explanations still
  grades NO.
- mentor tone-checks case-14: assert the quote contains "towncrier"
  (regex) instead of exact equality; case-10: drop has_author_tag_issue,
  whose regex cannot match a missing-tag violation and which rule/result
  already pin.
- pr-stale-sweep step-7-recap: drop "note is absent" regex checks where
  the exact count is 0; a recap that says "Maintainer-court PRs: none"
  is correct but matched the regex.
- reviewer-routing: output-spec now says signals_shown is false when no
  reviewer is proposed.

Generated-by: Claude Opus 5
potiuk added a commit to potiuk/magpie that referenced this pull request Sep 26, 2026
Pick up today's merges (apache#1390, apache#1391-apache#1394, apache#1398, apache#1399) in a fresh
marketplace build. pyproject.toml, uv.lock and every generated
plugin/marketplace manifest move from 0.9.0.dev202609251939.

Generated-by: Claude Opus 5
potiuk added a commit that referenced this pull request Sep 26, 2026
Pick up today's merges (#1390, #1391-#1394, #1398, #1399) in a fresh
marketplace build. pyproject.toml, uv.lock and every generated
plugin/marketplace manifest move from 0.9.0.dev202609251939.

Generated-by: Claude Opus 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capability:triage Sweep + classify + propose disposition family:pr-management pr-management-* skills

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize the pr-management skill family

2 participants