Skip to content

feat(core): add stable finding fingerprints to scanner output#161

Merged
Krishan27 merged 1 commit into
mainfrom
feat/stable-fingerprints
Jun 23, 2026
Merged

feat(core): add stable finding fingerprints to scanner output#161
Krishan27 merged 1 commit into
mainfrom
feat/stable-fingerprints

Conversation

@Krishan27

@Krishan27 Krishan27 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Implements ADR 007 — stable fingerprints in FlagUsage
  • Adds fingerprint: string field to FlagUsage using schema launchdarkly:callType:flagKey:normalizedFilePath
  • Fingerprints are stable across line-number changes; dynamic keys get a sequential per-file index
  • Foundation for baseline mode (v1.0.0 milestone)

Changes

  • New src/scanner/fingerprint.ts with generateFingerprint() function
  • src/types.ts: FlagUsage.fingerprint added as required field
  • src/scanner/index.ts: all 7 FlagUsage construction sites now populate fingerprint
  • src/migrator/index.ts: legacy inventory path now generates fingerprint
  • Updated test fixtures in reporter, migrator, validator, and readiness tests to include fingerprint
  • 7 new unit tests in src/scanner/tests/fingerprint.test.ts

Test plan

  • npm test — all 470 tests pass (441 original + 7 new fingerprint tests + 22 test file count)
  • npm run typecheck — passes cleanly
  • Verify fingerprint appears in JSON scan output
  • Verify fingerprint is stable when code is reformatted (line numbers change)

Summary by CodeRabbit

  • New Features

    • Added fingerprint-based identification for flag usage instances across all detection methods.
  • Tests

    • Updated test fixtures and validation helpers to include fingerprint support for flag usage tracking.

Implements ADR 007. Adds fingerprint: string to FlagUsage using schema:
  launchdarkly:callType:flagKey:normalizedFilePath

Fingerprints are stable across line-number changes. Dynamic keys get a
sequential index. Part of the v1.0.0 milestone.

Signed-off-by: Krishan Kant Sharma <krishansharma0327@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Introduces a generateFingerprint function in a new src/scanner/fingerprint.ts module that produces deterministic launchdarkly:<callType>:<flagKey>:<normalizedPath> strings with optional dynamic index suffixes. Adds a required fingerprint: string field to the FlagUsage interface and populates it in all scanner detection branches and the migrator's evidence builder. Updates all test fixtures accordingly.

Changes

Stable FlagUsage fingerprint

Layer / File(s) Summary
FlagUsage contract, fingerprint generator, and unit tests
src/types.ts, src/scanner/fingerprint.ts, src/scanner/tests/fingerprint.test.ts
FlagUsage adds a required fingerprint: string field; generateFingerprint is implemented with path normalization, wildcard key coercion, and optional dynamicIndex appended; a Vitest suite verifies formatting, normalization, indexing, and determinism.
Scanner: fingerprint generation across all detection branches
src/scanner/index.ts
detectUsages imports generateFingerprint, adds a per-file dynamicIndex counter, and populates fingerprint on every pushed FlagUsage across all-flags methods, flag-key variation, isFeatureEnabled, hooks, wrappers, withLDConsumer, and LDProvider JSX.
Migrator: fingerprint in buildEvidenceItem and tests
src/migrator/index.ts, src/migrator/tests/migrator.test.ts
buildEvidenceItem introduces a local flagKey variable and populates usage.fingerprint via generateFingerprint; makeUsage and makeResult fixtures are updated with the expected fingerprint strings.
Test fixture updates across readiness, reporter, and validator
src/readiness/readiness.test.ts, src/reporter/tests/reporter.test.ts, src/validator/tests/validate.test.ts
All FlagUsage test fixtures (makeInventory, staleUsage, activeUsage, dynamicUsage, staleUsage2, wildcard provider usage, makeScanResult) are updated to include the now-required fingerprint field.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Possibly related PRs

  • flaglint/flaglint#160: Directly implements the same "stable finding fingerprint" concept using the identical launchdarkly:<callType>:<flagKey>:<normalizedPath> schema with per-file dynamic indices, making this PR a likely successor or duplicate of that work.

Poem

🐇 Hop hop, a fingerprint now I leave,
On every flag call I detect and weave!
launchdarkly:variation:my-flag:src/app.ts
No line numbers needed, just path and call-type class.
Windows slashes? Normalized with care!
Each usage now has an identity to wear. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(core): add stable finding fingerprints to scanner output' directly and accurately summarizes the main change—introducing stable fingerprints to flag usage detection.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/stable-fingerprints

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying flaglint with  Cloudflare Pages  Cloudflare Pages

Latest commit: 62ff881
Status: ✅  Deploy successful!
Preview URL: https://fb7cb522.flaglint.pages.dev
Branch Preview URL: https://feat-stable-fingerprints.flaglint.pages.dev

View logs

@Krishan27 Krishan27 merged commit 44c8fc5 into main Jun 23, 2026
12 of 13 checks passed
@Krishan27 Krishan27 deleted the feat/stable-fingerprints branch June 23, 2026 03:43
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