Skip to content

feat(api-check): include file path and line number in compliance failure messages#45

Merged
grdsdev merged 3 commits into
mainfrom
feat/sdk-1092-compliance-error-file-location
Jun 25, 2026
Merged

feat(api-check): include file path and line number in compliance failure messages#45
grdsdev merged 3 commits into
mainfrom
feat/sdk-1092-compliance-error-file-location

Conversation

@grdsdev

@grdsdev grdsdev commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

When the CI compliance check fails because a new public symbol is not registered in the capability matrix, the error message now includes the file and line where the symbol is declared — making it faster for contributors to find and fix the issue.

Before:

❌ Capability matrix check failed
New public API detected that is not in the capability matrix:
  - SupabaseClient.signInWithPasskey (supabase-flutter)

After:

❌ Capability matrix check failed
New public API detected that is not in the capability matrix:
  - SupabaseClient.signInWithPasskey (supabase-flutter)
    defined at: Sources/Auth/SupabaseClient.swift:142

Changes

  • ParsedSymbol: adds optional line?: number field (all parsers emit it; absent means the parser couldn't determine it)
  • TypeScript parser (ts-parser.ts): computes 1-based line numbers from the TS AST via sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1
  • Swift SymbolGraph normalizer (normalize-symbolgraph.ts): extracts position.line from location.position (Swift positions are 0-based → +1)
  • Griffe normalizer (normalize-griffe.ts): passes lineno from each Griffe node (Python ast is already 1-based)
  • Dart extractor: threads LineInfo from CompilationUnit.lineInfo and uses firstTokenAfterCommentAndMetadata.offset so annotated declarations report the keyword line, not the @annotation line
  • CheckResult.uncoveredSymbols: changed from string[] to ParsedSymbol[] so the formatter retains file/line context
  • formatErrorMessage: renders defined at: <file>:<line> when location is available

Root cause

scripts/capability-matrix/src/api-check.ts:formatErrorMessage only had symbol names (strings) — it discarded the ParsedSymbol objects from checkNewSymbols before they reached the formatter.

Test plan

  • TypeScript parser: new test verifies line numbers for class, method, function, variable
  • Swift normalizer: 3 new tests for position extraction and missing-position edge cases
  • Griffe normalizer: 3 new tests for lineno extraction and missing-lineno edge case
  • Dart extractor: tests verify all symbols have non-null lines; test verifies annotated members report the keyword line, not the annotation line
  • formatErrorMessage: 3 new tests (file+line, file-only, empty-file)
  • checkNewSymbols: new test verifies file and line survive through to uncoveredSymbols
  • Full TS suite: 136 tests pass
  • Full Dart suite: 13 tests pass

Linear

Closes SDK-1092

grdsdev added 2 commits June 25, 2026 13:59
…ure messages

Parsers now emit a `line` field on each `ParsedSymbol` so the CI check
can show exactly where in the codebase a new public symbol was declared.

- `ParsedSymbol` gains an optional `line?: number` field
- TypeScript parser computes 1-based line numbers from the TS AST
- Swift SymbolGraph normalizer extracts `position.line` (0→1-based)
- Griffe normalizer passes `lineno` from each Griffe node
- Dart extractor threads `LineInfo` through and captures line numbers
  for every class, member, function, and variable declaration
- `CheckResult.uncoveredSymbols` is now `ParsedSymbol[]` (was `string[]`)
  so callers retain the file/line context through to the formatter
- `formatErrorMessage` renders `defined at: <file>:<line>` under each
  symbol when location info is available

Error output now matches the desired shape from SDK-1092:
  - SupabaseClient.signInWithPasskey (supabase-flutter)
    defined at: Sources/Auth/SupabaseClient.swift:142

Linear: SDK-1092
- Use firstTokenAfterCommentAndMetadata.offset in Dart extractor so
  annotated declarations report the line of the keyword, not the @annotation
- Remove mutation in normalize-griffe emit(); use object spread instead
- Rename sym_ → parsed in normalize-symbolgraph for clarity
- Document that Griffe lineno is already 1-based (unlike TS/Swift)
- Add test: line survives through checkNewSymbols into uncoveredSymbols
- Add test: annotated Dart methods report the declaration keyword line
@grdsdev grdsdev requested a review from a team as a code owner June 25, 2026 17:24

@spydon spydon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Only one nit, except for that it looks good!

Comment thread scripts/capability-matrix/src/api-check.ts
@grdsdev grdsdev requested a review from spydon June 25, 2026 18:51
@grdsdev grdsdev merged commit 2f4be47 into main Jun 25, 2026
3 checks passed
@grdsdev grdsdev deleted the feat/sdk-1092-compliance-error-file-location branch June 25, 2026 19:17
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.

2 participants