Skip to content

feat(interrogate): add a cost lens, sharpen exposure, completeness and parity, and gate review fixes - #24

Merged
lucasheriques merged 4 commits into
mainfrom
lucas/review-fix-lessons
Nov 12, 2026
Merged

lucasheriques merged 4 commits into
mainfrom
lucas/review-fix-lessons

Conversation

@lucasheriques

Copy link
Copy Markdown
Owner

Why

The pre-PR gate should catch what review bots keep catching. On PostHog/posthog-python#1226 it didn't: after our gate passed, reviewers found six more bugs across five rounds. Those were a broken older supported dependency version, secrets in captured stack-frame source lines, a spec's JSON-member redaction rule not implemented, a background task keeping a traceback alive, an exponential regex, and a quadratic scan on \" runs. #22 and #23's lenses were installed and in the brief the whole time. Two things went wrong:

  • Review fixes went out ungated. The gate ran once before the PR opened. Every later fix went straight to reviewers, and two of them caused the next finding.
  • The lenses had gaps. No lens covers hostile-input cost. Exposure let an adversary pass a leak because an older path leaked the same way. Completeness took its versions from what was installed, not from what the project declares it supports. Nothing sent adversaries to the spec that governs the behavior.

What changed

  • blind-spots.md gains a Cost lens: hostile-input time, grown from small sizes with a per-run timeout, near-match and escape-sequence probes for backtracking regex engines, and memory a long-lived holder keeps alive.
  • Parity also triggers on behavior a spec defines, and reads a spec's blanket requirements ("every captured string").
  • Completeness takes environments from declared support ranges and the CI matrix, and runs the oldest and newest version of each peer.
  • Exposure puts canaries in everything a value copies (source lines, locals, environment), in every shape the contract names, and judges against the contract. A leak on an older path the change doesn't touch becomes a non-blocking follow-up.
  • interrogate's Frame also reads the specs the repo's agent instructions name. Its brief, Verify step and Output gain Follow-ups, and Opening a PR step 5 reports them.
  • bugbot-triage.md's fix rule runs interrogate on every behavior-changing review fix before it's pushed. A one-character regex or limit change counts. It allows one more pass on the fixes for its findings and never a third, and a finding you won't fix holds that push and goes to the user. Babysit step 8 and the multi-phase fix-round rule point every review fix at it, a person's comment included.
  • translation.md records the fork-only departures.

Verification

Replay. Sonnet adversaries got the same brief on the posthog-python commits where reviewers later found bugs. The only thing that changed between runs was the lens file.

Commit Bug reviewers found later main lenses This PR's lenses
8bbd1fb (first gate head) fastmcp 2.x silently loses all analytics missed found
8bbd1fb secrets in frame source lines missed found
8bbd1fb JSON-member credentials unredacted missed found (once Frame named the spec)
8bbd1fb background task keeps the traceback alive missed found
d8a7a55 exponential regex found (my brief primed it) found
9c1cb4f quadratic scan on \" runs missed (at d8a7a55, where it already existed) found (escape-sequence probe)

The new-lens runs also found an unreported gap: object keys skip the JSON-member pass. They each reproduced the bug against the real code, with timings, before/after event dumps, or failing calls.

Gate. Two rounds of Opus and Sonnet adversaries.

  • Round 1 found that the review-fix rule broke Babysit's "In that case" sentence, had no scope and no round cap, and exempted rewrites of the cited lines. It also found the Cost timing unbounded, older-path leaks blocking unrelated PRs, and translation.md contradicting itself. All of these are fixed in 1331ac5.
  • Round 2 found the "one-line value change" exemption, the imported step-2 blocker semantics, human comments skipping the gate, no output slot for follow-ups, and a multi-phase plan conflict. All are fixed in 5cbc168.
  • There's no third round, per Opening a PR step 2. I checked each round-2 finding against the final text instead.
  • bun scripts/check-port.ts reports 0 findings.

Blast radius

  • Gate runs on code with caller-controlled parsing or regex now carry the Cost lens. Over the last 40 non-test commits on posthog-python's main, that's 7.
  • Every behavior-changing review fix now costs one interrogate fan-out, or two at most, before it's pushed. That replaces review rounds like #1226's five.

…p older leaks non-blocking

Gate findings (Opus, Sonnet) on f74f93c:
- The review-fix gate sat in Babysit step 8, between "unless the owning
  PR has merged" and "In that case", so it redirected every fix to a
  follow-up PR; it also had no scope, no rules for its findings, no
  round cap, and an exemption for rewrites of the cited lines (the very
  fix that let the quadratic scan through). It moves to
  bugbot-triage.md's `fix` rule, which every review-fix route uses, with
  a diff scope, Opening a PR step 2's rules, and one more pass at most.
  Babysit returns to main's text.
- Cost probes now start small, grow fourfold, and stop at a per-run
  timeout; at 10,000 characters an exponential regex never returns.
- An older path that leaks the same way is reported as a non-blocking
  follow-up, not a finding that blocks the PR.
- translation.md no longer says upstream gates before the PR opens.
…ow-ups an output slot

Gate round 2 (Opus, Sonnet) on 1331ac5, both raising the same set:
- The "one-line value change" exemption let a one-character regex fix
  through. Any behavior change is gated now, and a one-character regex,
  limit or size change explicitly counts.
- The gate imported Opening a PR step 2's rules, whose blocker means
  "stay a draft" and whose second round re-imports the cited-lines
  exemption. The triage rule now states its own: one more pass whatever
  lines the fixes touch, never a third, and a finding you won't fix
  holds the push and goes to the user.
- Fixes for a person's comment skipped the gate. Babysit step 8 and the
  multi-phase fix-round rule now point every review fix at it.
- An older path's leak had nowhere to go. interrogate's brief, Verify
  and Output gain non-blocking Follow-ups; Opening a PR step 5 lists them.
- translation.md now says upstream lacks interrogate in triage, Babysit
  and fix rounds, not everywhere.

Tested: bun scripts/check-port.ts (0 findings). No third gate round, per
Opening a PR step 2; each finding was checked against the final text.
@lucasheriques lucasheriques self-assigned this Nov 12, 2026
@lucasheriques
lucasheriques merged commit 7f5e872 into main Nov 12, 2026
1 check passed
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