Skip to content

fix(sdd): treat a negative SDD compound as an exclusion, not an invocation - #1039

Open
dyool17 wants to merge 1 commit into
Gentleman-Programming:mainfrom
dyool17:fix/classifier-negative-compound
Open

dyool17 wants to merge 1 commit into
Gentleman-Programming:mainfrom
dyool17:fix/classifier-negative-compound

Conversation

@dyool17

@dyool17 dyool17 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Closes #1038

Summary

  • Discount a negative SDD compound (non-SDD, non SDD) when testing for an SDD mention, so a brief that rules the workflow out no longer classifies as affirmative intent.
  • Fix it on the mention test rather than by adding another phrase to the exclusion list, because the exclusion list is structurally unable to match a compound.
  • Add regression coverage for the compound, for a mixed brief that still asks for the workflow, and for a word merely ending in non.

Root cause

hasAffirmativeSddIntent gates on /\bsdd\b/i. The hyphen in non-SDD is a word boundary, so that test matches the token inside the compound. An anchored imperative such as Implement then satisfies the intent half, and isSddPreflightTrigger returns true for a brief that explicitly excludes the workflow.

The negative-exclusion regexes in isSddPreflightTrigger cannot cover this, which is why this is a fix on the mention test and not another entry in that list. They match negated clausesdon't / do not / never / not want|need|plan|intend|use, plus the Spanish sin usar / no quiero|necesito|... forms — and each requires the negation and the token to sit in the same clause. A compound is a single token, so there is no clause-level negation for them to match.

The fix uses a negative lookbehind on the mention test, so only the negated occurrence is discounted rather than the whole text:

const SDD_MENTION = /(?<!\bnon[-\s])\bsdd\b/i;

Scope

This is the classification defect only. It is independent of transport and reaches the interactive parent, where the false positive opens the session preflight dialog during an unrelated request.

It is also the first half of #1001, whose second half — the RPC input hook consuming the resulting rejection — is fixed separately in #1036. The two are independent and can land in either order: #1036 touches extensions/gentle-ai.ts, this one touches lib/sdd-preflight.ts.

Changes

File Change
lib/sdd-preflight.ts Gate hasAffirmativeSddIntent on a mention that is not part of a negative compound
tests/sdd-preflight.test.ts New regression test for negative compounds, plus the two boundary controls

Test plan

Added a negative SDD compound is an exclusion, not an invocation to tests/sdd-preflight.test.ts. It fails on main on the first case and passes with the fix, and it pins both boundaries so the lookbehind cannot be over-broad:

  • non-SDD, Non-SDD and non SDD briefs must not trigger.
  • Implement the non-SDD path, then let's plan the SDD change. must still trigger — only the negated mention is discounted, not the text.
  • Implement the canon-SDD alignment. must still trigger — a word merely ending in non never suppresses the mention that follows.

Classifier output on the reproduction set from #1038, before and after:

BEFORE                                                  AFTER
true   "Implement the non-SDD path for this runner."    false
true   "Implement the Non-SDD fallback."                false
true   "Create the non SDD branch of the dispatcher."   false
false  "I do not want to use SDD"                       false

Full local run on Linux, Node 24, with the pinned gentle-ai v2.9.1 installed:

  • pnpm test — exit 0 (2409 unit tests, provider-contract mirror check, runtime harness)
  • pnpm run typecheck200 recorded diagnostic(s), no regressions
  • pnpm run check:runtime-modulesruntime matches TypeScript sources
  • node scripts/verify-package-files.mjs169 files check passed

Summary by CodeRabbit

  • Bug Fixes
    • Improved SDD preflight detection to correctly ignore negated phrases such as “non-SDD” and “non SDD.”
    • Requests that include a separate affirmative SDD mention continue to trigger the appropriate preflight workflow.
    • Added coverage for related wording variations to improve detection consistency.

…ation

`hasAffirmativeSddIntent` gated on a bare `\bsdd\b` mention. The hyphen in
`non-SDD` is a word boundary, so that test matched the token inside the
compound: a brief that explicitly rules the workflow out classified as
affirmative SDD intent and opened session preflight.

The negative-exclusion regexes could not cover this. They match negated clauses
(`do not use SDD`, `sin usar SDD`), each requiring the negation and the token to
sit in the same clause; a compound is a single token, so no clause-level
negation is present to match.

Discount only the negated occurrence, with a lookbehind on the mention test
rather than another phrase in the exclusion list. A brief that excludes one path
and still asks for the workflow elsewhere keeps its affirmative mention, and a
word merely ending in `non` never suppresses the mention that follows it.
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 029754d7-7a5f-41ff-90ab-62f4ac79750d

📥 Commits

Reviewing files that changed from the base of the PR and between 0da9bcc and 223c2e3.

📒 Files selected for processing (2)
  • lib/sdd-preflight.ts
  • tests/sdd-preflight.test.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The SDD preflight classifier now ignores non-SDD and non SDD mentions while preserving separate affirmative SDD mentions. Regression tests cover these cases and related compound terms.

Changes

SDD intent classification

Layer / File(s) Summary
Filter negative SDD compounds
lib/sdd-preflight.ts, tests/sdd-preflight.test.ts
The affirmative SDD matcher excludes mentions preceded by non- or non . Tests verify negative compounds do not trigger preflight, while separate positive mentions and terms ending in non still trigger it.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: alan-thegentleman

Merge Risk: ⚪ Minimal · up to 223c2

Negative SDD compounds no longer invoke preflight while separate affirmative requests remain recognized. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. 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 clearly and concisely describes the main change: treating negative SDD compounds as exclusions instead of invocations.
Linked Issues check ✅ Passed The change addresses #1038. SDD_MENTION excludes SDD when it is preceded by non- or non . hasAffirmativeSddIntent uses this test before the existing intent check. Regression tests verify `no…
Out of Scope Changes check ✅ Passed The changed production code and tests are directly related to #1038. The added tests provide regression coverage for the reported classification defect and its required edge cases. No unrelated change…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

bug(sdd): a negative SDD compound classifies as affirmative preflight intent

1 participant