Skip to content

feat(#608): mine gap-check signal-to-noise across recent merged PRs - #623

Merged
admarble merged 4 commits into
mainfrom
feature/608-investigate-metrics-gap-check-signal-to-noise-does
May 11, 2026
Merged

admarble merged 4 commits into
mainfrom
feature/608-investigate-metrics-gap-check-signal-to-noise-does

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Adds scripts/analytics/gap-signal.ts which mines QA / spec verdict comments from merged PRs (configurable window), attributes each gap flag to its source SKILL.md section, and classifies fate as actioned_in_pr / filed_followup / dismissed / silent / not_triggered.
  • Investigation report at docs/investigations/qa-gap-signal-to-noise.md covers the 2026-04-01 → 2026-05-10 window (50 PRs, 134 flag rows). Per-section action rate + cost proxy + keep/trim/gate recommendations feed investigate(qa): extract deterministic gap-checks into pre-QA script gate #609.
  • Two clear remove/gate candidates surfaced — §6c (0/11 substantive findings, 156 SKILL.md lines) and §6d (9 findings, 0 actioned/filed). Two clear keeps: §5 cross-file sibling-site scan and spec sibling-site scan.

Pre-PR AC Verification

AC Source Description Status Evidence
AC-1 Original Categorize each flagged gap (actioned_in_pr / filed_followup / dismissed / silent) ✅ Implemented scripts/analytics/gap-signal.ts:classifyFate; .sequant/gap-signal.jsonl (134 rows, gitignored)
AC-2 Original Per-section action rate sorted by section ✅ Implemented displayReport() table; docs/investigations/qa-gap-signal-to-noise.md TL;DR table
AC-3 Original Per-section token cost via word-count proxy ✅ Implemented (with caveat) measureSkillCost() reports lines + words per section. Single-shot ablation deferred per spec — metrics.tokensUsed field is unwired in run logs
AC-4 Original Report at docs/investigations/qa-gap-signal-to-noise.md + summary comment on issue ✅ Implemented New report file; issue comment posted as part of progress update
AC-5 Original For sections < 30% action rate, recommend remove or gate with deterministic precondition ✅ Implemented Recommendations §1–5 in report; #609 referenced for follow-up

Coverage: 5/5 AC items fully met

Test plan

  • npx vitest run scripts/analytics/gap-signal.test.ts — 7/7 pass (covers section attribution, fate classification, action-rate computation, missing-skill-file fallback)
  • npm run build — clean
  • npm run lint — clean (0 errors, 0 warnings)
  • Live mining against 50 merged PRs since 2026-04-01 — 134 flag rows produced, results stable across reruns

Sample-size caveat

§6d had only 14 emits because the section was promoted to mandatory only on 2026-05-06 (PR #584). Re-run this analysis in 60 days to confirm the §6d trim recommendation against more data — the script is rerunnable with a wider window via --since.

Closes #608

Adds scripts/analytics/gap-signal.ts which mines QA / spec verdict
comments from merged PRs (configurable window), attributes each gap
flag to its source SKILL.md section (§4 Q5, §5, §6c, §6d, spec
sibling-site scan, spec AC linter), and classifies fate as
actioned_in_pr / filed_followup / dismissed / silent / not_triggered.

Findings (window 2026-04-01 → 2026-05-10, 50 PRs, 134 flag rows)
written to docs/investigations/qa-gap-signal-to-noise.md.

Two clear remove/gate candidates surfaced:
- §6c (detection-pattern verification): 0/11 substantive findings,
  156 SKILL.md lines — recommend gate by file-glob precondition.
- §6d (Adversarial Re-Read): 9/14 triggered, 0 actioned/filed —
  recommend trim from structured 4-sub-prompt block to 1-paragraph.

Two keeps: §5 cross-file sibling-site scan (33% action rate, 7 lines)
and spec sibling-site scan (29%, 8 lines). Recommendations feed #609.
admarble added 3 commits May 9, 2026 23:41
…te-metrics-gap-check-signal-to-noise-does

# Conflicts:
#	CHANGELOG.md
- AC-2: sort sections descending by actionRate in displayReport (gap-signal.ts:473) and re-render the doc TL;DR table in the same order so console output and doc table agree
- AC-3: add ablation calibration paragraph under Phase B — cost. Measures §6c against full QA SKILL.md (3042/2886 lines, 18,703/17,297 words → ~1,824 token delta per QA invocation, ~90k tokens / 50-PR window for 0 actioned findings); reproduce snippet included; word-count proxy now anchored to a token estimate that other rows can be read against
…gic number

Below-the-line polish on top of the READY_FOR_MERGE PR — addresses the four open suggestions across both QA passes; no AC, no user-facing behavior changes.

- A2: hoist `excerpt.length > 60` cutoff in `extractFlag` to a documented module-level `MIN_EXCERPT_LEN` constant with rationale (shortest real finding observed in the 50-PR window was ~80 chars; shorter slices are NA_RE-evading boilerplate).
- A3: `fetchIssue` now logs `gh` failures (rate-limit, auth, network) to stderr instead of silently returning `null` — silent skips skewed action-rate downward and looked identical to "issue has no comments" in the rolled-up output.
- B1: new test asserts `displayReport` renders sections in descending action-rate order using a synthetic three-section report with deliberately out-of-declaration order.
- B2: `measureSkillCost` now warns to stderr on both silent-failure paths — missing `skillFile` and `skillSectionAnchor` regex miss — instead of silently returning `{lines:0, words:0}`. Closes the doc Risk Assessment's named drift mode where a future renamed QA SKILL.md section would silently report 0-line cost. Existing missing-file test updated to assert the warning fires; new drift test simulates a renamed section.

Tests: 9/9 pass (was 7; +2). `npx tsc --noEmit` clean. Live smoke against 5-PR window confirms zero behavioral regression — same sort order, same per-section counts, no spurious anchor-drift warnings (all 6 production anchors still resolve).
@admarble
admarble merged commit f7b1c04 into main May 11, 2026
5 checks passed
@admarble
admarble deleted the feature/608-investigate-metrics-gap-check-signal-to-noise-does branch May 11, 2026 02:51
admarble added a commit that referenced this pull request May 11, 2026
Gap 1 — §6c precondition greps diff hunks, not file content.

The first cut of this section's precondition shelled out to
`xargs grep -lE ...` against the *current* skill-md file content. All
19 sequant SKILL.md files mention `grep|awk|jq|sed` in unrelated
example code, so the gate triggered on 100% of skill-md PRs and the
cost-saving intent of #608 / #609 evaporated. The fix iterates the
diffed skill-md files and only triggers §6c when the **added lines**
contain the patterns. On 6 historical merged PRs (#623 #620 #621 #617
#622 #547) the new gate skips §6c on 4/6 (67%) — vs 0/6 under the old
content-grep gate. Mirrored across `.claude/skills/`,
`templates/skills/`, `skills/`.

Gap 2 — `extractIdentifiersFromDiff` skips indented locals.

`content = line.slice(1).trimStart()` defeated the comment's claim of
"no nested-block decls" by stripping the indent that distinguishes
top-level from function-body declarations. The dogfood run on #609
surfaced 24 identifiers (17 of them local `const lines = …` /
`let inFence = …` style variables). Dropping `.trimStart()` brings
the surface to top-level decls only. New test asserts indented
`+  const local = …` is skipped while `+const topLevel = …` matches.

Gap 3 — Empirical 5-PR replay for AC-5 / AC-6.

New `--base-sha` / `--head-sha` CLI flags let `precheck.ts` replay
against historical merged PRs. SHAs validated with `/^[0-9a-f]{4,40}$/`
to avoid shell injection. Ran replay against 6 PRs (5 recent +
#547 for AC-6 demo): aggregate ≈ −1,002 tok/PR under the new gate;
PR #620's replay surfaced `acLiteralDiff.missingInPR.length = 8` —
a real catch the inline §1 prose was supposed to make but #608's
data shows §1 surfaced silently for years. Investigation doc
appended with per-PR table + correction to the prior
"true on 0 PRs" calibration claim.

Test count: 27 → 30 (indented-skip + 2 parseArgs flag tests).
`scripts/check-skill-sync.ts` reports qa/SKILL.md synced 3/3.
admarble added a commit that referenced this pull request May 11, 2026
…628)

* feat(#609): extract deterministic QA gap-checks into precheck script

New `scripts/qa/precheck.ts` runs three deterministic gap-checks before
the QA agent and emits `.sequant/gap-precheck.json`:

  - fixtures      — verbatim motivating-example extraction from issue body
                    (feeds §6d Q1 / §6c Step 4)
  - siblingGrep   — changed-identifier scan for cross-file sibling sites
                    (feeds §5)
  - acLiteralDiff — AC checkbox IDs in issue body vs PR body (feeds §1)

`qa/SKILL.md` gains Phase 0c that runs the precheck inline and consumes
its findings. §6c becomes a file-glob hard precondition (no skill-md
diff → emit nothing). §6c Step 4 prefers precheck `fixtures` over the
inline `awk` extractor when available. §6d trims to a single
adversarial paragraph (per #608's 9/14 / 0-actioned signal).

Inline fallback preserved on missing/error/`not_applicable` output.
Mirrored across all three `qa/SKILL.md` copies. Exit code always 0.

Investigation doc at `docs/investigations/qa-precheck-extraction.md`
covers AC-1 (22-row gate classification), AC-2 (per-PR run frequency),
AC-5 (section-size delta calibration via #608's 50-PR window:
~−1,585 tok/invoke window-typical), and AC-6 (regression-coverage
methodology against PR #547 / PR #533 shapes).

Builds on #608's signal-to-noise data which informed Phase A scope.

* fix(#609): close three gaps surfaced in post-commit QA

Gap 1 — §6c precondition greps diff hunks, not file content.

The first cut of this section's precondition shelled out to
`xargs grep -lE ...` against the *current* skill-md file content. All
19 sequant SKILL.md files mention `grep|awk|jq|sed` in unrelated
example code, so the gate triggered on 100% of skill-md PRs and the
cost-saving intent of #608 / #609 evaporated. The fix iterates the
diffed skill-md files and only triggers §6c when the **added lines**
contain the patterns. On 6 historical merged PRs (#623 #620 #621 #617
#622 #547) the new gate skips §6c on 4/6 (67%) — vs 0/6 under the old
content-grep gate. Mirrored across `.claude/skills/`,
`templates/skills/`, `skills/`.

Gap 2 — `extractIdentifiersFromDiff` skips indented locals.

`content = line.slice(1).trimStart()` defeated the comment's claim of
"no nested-block decls" by stripping the indent that distinguishes
top-level from function-body declarations. The dogfood run on #609
surfaced 24 identifiers (17 of them local `const lines = …` /
`let inFence = …` style variables). Dropping `.trimStart()` brings
the surface to top-level decls only. New test asserts indented
`+  const local = …` is skipped while `+const topLevel = …` matches.

Gap 3 — Empirical 5-PR replay for AC-5 / AC-6.

New `--base-sha` / `--head-sha` CLI flags let `precheck.ts` replay
against historical merged PRs. SHAs validated with `/^[0-9a-f]{4,40}$/`
to avoid shell injection. Ran replay against 6 PRs (5 recent +
#547 for AC-6 demo): aggregate ≈ −1,002 tok/PR under the new gate;
PR #620's replay surfaced `acLiteralDiff.missingInPR.length = 8` —
a real catch the inline §1 prose was supposed to make but #608's
data shows §1 surfaced silently for years. Investigation doc
appended with per-PR table + correction to the prior
"true on 0 PRs" calibration claim.

Test count: 27 → 30 (indented-skip + 2 parseArgs flag tests).
`scripts/check-skill-sync.ts` reports qa/SKILL.md synced 3/3.
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.

investigate(metrics): gap-check signal-to-noise — does flagged → action rate justify cumulative QA prompt cost?

1 participant