Skip to content

Drift Near-Miss Hints (Cycle 0023) - #10

Merged
flyingrobots merged 4 commits into
mainfrom
cycles/0023-drift-near-miss-hints
Apr 7, 2026
Merged

flyingrobots merged 4 commits into
mainfrom
cycles/0023-drift-near-miss-hints

Conversation

@flyingrobots

Copy link
Copy Markdown
Owner

Summary

When method drift reports an unmatched playback question, it now shows the closest test description as a "Near miss" hint if the token overlap (Jaccard similarity) exceeds 0.7.

  • Near-miss hints are informational only — exit code stays 2 for any drift
  • Deterministic — punctuation-stripped token overlap, no external deps, no LLM
  • Solves immediate pain — cycle 0022's witness showed 6/6 questions as "drift" when they were actually covered by tests with slightly different wording

Example output:

- Human: `method drift` shows near-miss hints for unmatched questions.
  Near miss: "method drift shows near-miss hints for unmatched questions"

Changes

  • src/drift.ts — findNearMiss() and tokenSimilarity() functions
  • tests/drift.test.ts — 8 new dedicated drift detection tests
  • tests/cli.test.ts — updated existing test to expect near-miss output

Test plan

  • 110 tests pass (102 prior + 8 new)
  • Build clean
  • Cycle closed with retro and witness

Add near-miss hints to drift output when playback questions are close
but not exactly matching test descriptions.
New tests/drift.test.ts with 8 tests:
- Exact match (pass), no match (fail), near-miss hint shown,
  exit code preserved, no hint when distant, deterministic output,
  empty cycles.
3 tests fail: near-miss hint feature not yet implemented.
When a playback question has no exact match, the drift output now shows
the closest test description as a "Near miss" hint if the token overlap
(Jaccard similarity) exceeds 0.7. This helps operators see whether a
mismatch is trivial wording vs a genuinely missing test.

- Near-miss hints never change exit code (still exits 2 for drift)
- Uses deterministic punctuation-stripped token overlap, no external deps
- Threshold hardcoded at 0.7 (sensible default, configurable later)
- Updated existing CLI test to expect near-miss output
Hill met. Drift detector now shows near-miss hints for close-but-not-
exact playback question matches. Uses Jaccard token similarity >= 0.7.
Exit codes unchanged. 8 new dedicated drift tests.

110 tests pass. No drift. No new debt.
@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@flyingrobots has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 47 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 27 minutes and 47 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a6c2d15e-173d-4723-af7f-857a7e237563

📥 Commits

Reviewing files that changed from the base of the PR and between 76d3019 and b27295e.

📒 Files selected for processing (7)
  • docs/design/0023-drift-near-miss-hints/drift-near-miss-hints.md
  • docs/method/backlog/cool-ideas/PROCESS_drift-near-miss-hints.md
  • docs/method/retro/0023-drift-near-miss-hints/drift-near-miss-hints.md
  • docs/method/retro/0023-drift-near-miss-hints/witness/verification.md
  • src/drift.ts
  • tests/cli.test.ts
  • tests/drift.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cycles/0023-drift-near-miss-hints

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@flyingrobots
flyingrobots merged commit a283233 into main Apr 7, 2026
2 of 3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b27295e748

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/drift.ts

function tokenSimilarity(left: string, right: string): number {
const tokenize = (value: string): Set<string> =>
new Set(value.replace(/[^\p{L}\p{N}\s]/gu, '').split(' ').filter((t) => t.length > 0));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Split tokens on punctuation when scoring near misses

The near-miss scorer currently removes punctuation before splitting on spaces, which merges adjacent words into one token (for example, near-miss becomes nearmiss). That makes punctuation-only wording differences look much less similar than intended and can suppress hints for otherwise close questions (especially shorter ones), reducing the accuracy of the feature this commit adds. Treating punctuation as a delimiter (e.g., replacing with spaces or splitting on non-alphanumerics) avoids these false negatives.

Useful? React with 👍 / 👎.

@flyingrobots
flyingrobots deleted the cycles/0023-drift-near-miss-hints branch April 7, 2026 07:08
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