Skip to content

feat: fix AI false-positive breaking verdicts; add acknowledgedChanges#57

Merged
jacekradko merged 1 commit into
mainfrom
jacek/fix-ai-false-positives-56
Jun 2, 2026
Merged

feat: fix AI false-positive breaking verdicts; add acknowledgedChanges#57
jacekradko merged 1 commit into
mainfrom
jacek/fix-ai-false-positives-56

Conversation

@jacekradko

Copy link
Copy Markdown
Contributor

Fixes #56, where the AI reviewer confirmed two backwards-compatible changes as breaking (clerk/javascript#8700) and returned "confirmed" rather than a downgrade, so --ai-apply-downgrades had nothing to act on.

The optional-Pick case was a pure reasoning gap (the referenced definition was already in the model's context), so it's fixed with prompt rules. The output-type case needed structure, not prompting: the focused verdict context only ever showed a type's forward references, never its callers, so the model couldn't tell a read-only response type from one consumers construct. It now ships a "Usage sites" block of each changed type's referrers. The load-bearing part is that those referrers are gathered across the package's sibling subpath surfaces, because the analyzer runs per-subpath and the changed type (@clerk/shared/types) and the function that returns it (@clerk/shared/react) live in different rollups. detector.ts threads the sibling current .api.json paths in; matching is by canonicalReference, and anything unresolved (including cross-package usage) falls back to breaking.

Also adds acknowledgedChanges, a config allowlist to green a verified-safe break by name or glob. Unlike an AI downgrade it's unconditional and not gated behind a flag.

Both AI fixes only ever enable a downgrade, which still stays behind --ai-apply-downgrades, so the default path still can't clear a real break. The directionality rule is a pragmatic heuristic (a consumer could construct any exported type), which is the judgment worth a close look in review.

The two live regression tests in ai-verdict.test.mjs reproduce the exact false positives but are gated on a real API key; the nightly ai-smoke workflow runs them. Everything else is deterministic and runs in pnpm test.

Three fixes for #56, where the reviewer confirmed two backwards-compatible
changes as breaking and returned "confirmed" rather than a downgrade, so
--ai-apply-downgrades had nothing to act on.

- Prompt rules: adding an optional property (including one widened into a
  Pick/Omit) is non-breaking, and no verdict may stay conditional on a fact
  already resolvable from context.
- Usage-site context: the focused verdict prompt now lists each changed
  type's referrers so the model can tell a read-only output type from a
  consumer-constructed input. Referrers are gathered across the package's
  sibling subpath surfaces (the type and the function returning it usually
  live in different rollups), threaded via
  AiPackageContext.siblingCurrentApiJsonPaths and matched by
  canonicalReference; an unresolved reference falls back to breaking.
- acknowledgedChanges config: unconditionally downgrade a verified-safe
  breaking change by name or glob and tag it in the report.

Both AI fixes only ever enable a downgrade, still gated behind
--ai-apply-downgrades, so the default path cannot clear a real break.
@pkg-pr-new

pkg-pr-new Bot commented Jun 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/clerk/break-check/@clerk/break-check@57

commit: 8bea6df

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-06-02T19:54:41.504Z

Summary

Metric Count
Packages analyzed 1
Packages with changes 1
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 2

@clerk/break-check

Current version: 0.0.1
Recommended bump: MINOR → 0.1.0

🟢 Additions (2)

Added: AiPackageContext.siblingCurrentApiJsonPaths

+ siblingCurrentApiJsonPaths?: string[];

Added property AiPackageContext.siblingCurrentApiJsonPaths

Added: ApiChange.acknowledged

+ acknowledged?: boolean;

Added property ApiChange.acknowledged


Report generated by Break Check

@jacekradko
jacekradko merged commit e6f0b3e into main Jun 2, 2026
8 checks passed
@jacekradko
jacekradko deleted the jacek/fix-ai-false-positives-56 branch June 2, 2026 20:27
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.

AI reviewer confirms two false-positive breaking changes (added optional Pick'd field; additive field on output type)

1 participant