Skip to content

Add file-type context and tighten PAT confidence guidance#67

Merged
oshorefueled merged 3 commits intomainfrom
enh/improve-directive
Mar 4, 2026
Merged

Add file-type context and tighten PAT confidence guidance#67
oshorefueled merged 3 commits intomainfrom
enh/improve-directive

Conversation

@oshorefueled
Copy link
Contributor

@oshorefueled oshorefueled commented Mar 4, 2026

Why

The LLM directive gave no guidance on file structure or confidence calibration, causing excessive false positives — especially in MDX files where structural elements like cards and tabs are not continuous prose. Confidence scores were also under-constrained, surfacing too many marginal findings.

What

  • Rewrite the default directive with <goal>, <content_metadata>, <context>, <evaluation_boundaries>, and <surfacing_criteria> sections
  • Inject file extension into the directive via {{file_type}} so the LLM interprets structural boundaries correctly for MDX vs plain Markdown
  • Plumb file extension as EvalContext through BaseEvaluatorrunPromptStructuredRequestBuilder → directive substitution
  • Fix: {{file_type}} placeholder is now unconditionally replaced (empty string when absent) — previously it leaked as a literal string when no file type was provided
  • Tighten PAT schema descriptions for plausible_non_violation and confidence to push ambiguous findings below 0.7
  • Expand VectorLint preset from 3 rules to 8: add Capitalization, Consistency, Inclusivity, PassiveVoice, UnsupportedClaims, Wordiness; remove Directness and PseudoAdvice

Scope

In scope

  • Bundled preset rules (additions and removals)
  • Default directive content and {{file_type}} templating
  • PAT structured-output schema descriptions
  • File-type context plumbing through BaseEvaluatorLLMProviderRequestBuilder

Behavior impact

  • Users running RunRules=VectorLint get 8 checks instead of 3; Directness and PseudoAdvice checks no longer run — existing configs referencing them will silently produce no findings for those rules
  • Every LLM evaluation call now receives a richer system prompt; confidence distributions may shift, with fewer marginal findings surfaced
  • MDX files get an explicit structural hint in the prompt, reducing false positives on list items, cards, and tabs

Risk

  • Prompt regression: the directive rewrite changes LLM behavior for all evaluations. No golden-set tests guard recall changes — run against representative content before merging to production
  • Silent rule removal: Directness and PseudoAdvice are deleted without a deprecation notice; communicate in release notes
  • meta.json count: description says "7 built-in checks" but the directory contains 8 .md files — cosmetic, but worth correcting

How to test / verify

Checks run

  • npx vitest run → 31 test files, 218 tests passed, 0 failures

Manual verification

  1. Confirm 8 rules load: ls presets/VectorLint/*.md | wc -l8
  2. Run against a .mdx file: npm run dev -- <path>.mdx --rules VectorLint/AIPattern — confirm no {{file_type}} literal in output or verbose prompt logs
  3. Run against a file with no extension — confirm no crash and no {{file_type}} in the prompt
  4. Check Directness and PseudoAdvice no longer appear: ls presets/VectorLint/ | grep -E "directness|pseudo" → no output

Rollback

Revert to main. No config mutations, migrations, or persistent state — rollback is immediate with no data impact. Users who relied on Directness or PseudoAdvice will need to restore those files manually from git history.

Summary by CodeRabbit

  • New Features

    • Added eight built-in lint checks for document quality (Capitalization, Consistency, Inclusivity, Passive Voice, Repetition, Unsupported Claims, Wordiness, and an updated VectorLint pattern set).
    • Evaluations now consider file-type context for more accurate rule application.
  • Changes

    • Shifted AI pattern detection from term lists to structural, pattern, and tone-oriented guidance.
    • Expanded evaluation directives and scoring guidance.
  • Removals

    • Removed Directness and Pseudo-Advice presets.

…dance

- Rewrite default directive with goal, content_metadata, context,
  evaluation_boundaries, and surfacing_criteria sections to reduce
  false positives in structured-format files (MDX, etc.)
- Plumb file extension as EvalContext through BaseEvaluator →
  runPromptStructured → RequestBuilder → {{file_type}} substitution
  in the directive system prompt
- Fix {{file_type}} placeholder always replaced (empty string when
  absent) to prevent literal leakage into prompts; add regression tests
- Tighten PAT schema descriptions for plausible_non_violation and
  confidence to calibrate LLM scoring below 0.7 for ambiguous matches
- Expand VectorLint preset from 3 to 8 rules: add Capitalization,
  Consistency, Inclusivity, PassiveVoice, UnsupportedClaims, Wordiness;
  remove Directness and PseudoAdvice
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2cf5f9ae-1a27-40ee-937f-8e959ab2a5ee

📥 Commits

Reviewing files that changed from the base of the PR and between eefe666 and d56ec8d.

📒 Files selected for processing (10)
  • presets/VectorLint/ai-pattern.md
  • presets/VectorLint/capitalization.md
  • presets/VectorLint/consistency.md
  • presets/VectorLint/inclusivity.md
  • presets/VectorLint/passive-voice.md
  • presets/VectorLint/repetition.md
  • presets/VectorLint/unsupported-claims.md
  • presets/VectorLint/wordiness.md
  • src/providers/request-builder.ts
  • tests/request-builder.test.ts

📝 Walkthrough

Walkthrough

This PR adds seven new VectorLint checks, removes two deprecated presets, standardizes preset front-matter, adds many test fixtures, and threads an EvalContext (fileType) through evaluators, request builders, and LLM providers so prompts can be templated per file type.

Changes

Cohort / File(s) Summary
Preset Additions
presets/VectorLint/capitalization.md, presets/VectorLint/consistency.md, presets/VectorLint/inclusivity.md, presets/VectorLint/passive-voice.md, presets/VectorLint/unsupported-claims.md, presets/VectorLint/wordiness.md
Added six new check presets (standardized front-matter: evaluator: base, evaluateAs: document, severity warning) describing detection rules for capitalization, consistency, inclusivity, passive voice, unsupported claims, and wordiness.
Preset Rework
presets/VectorLint/ai-pattern.md, presets/VectorLint/repetition.md
Updated front-matter to new specVersion/evaluator format and replaced legacy criteria lists with pattern/structure/tone-oriented guidance and simplified repetition rule.
Removed Presets
presets/VectorLint/directness.md, presets/VectorLint/pseudo-advice.md
Deleted two legacy preset documents and their example-driven guidance.
Preset Metadata
presets/meta.json
Updated VectorLint description to note "8 built-in checks."
Evaluator & Context Threading
src/evaluators/base-evaluator.ts, src/providers/llm-provider.ts, src/providers/request-builder.ts, src/providers/vercel-ai-provider.ts
Introduced EvalContext (optional fileType?: string); BaseEvaluator now extracts file extension and passes context into runJudgeEvaluation/runCheckEvaluation; LLMProvider and providers accept and forward optional context; RequestBuilder templates {{file_type}}.
Prompt & Schema
src/prompts/directive-loader.ts, src/prompts/schema.ts
Rewrote DEFAULT_DIRECTIVE content (new evaluation boundaries and surfacing criteria) and enriched schema field descriptions for plausible_non_violation and confidence (descriptions only).
Tests & Fixtures
tests/fixtures/... (capitalization, consistency, inclusivity, passive-voice, repetition, unsupported-claims, wordiness directories)
Added .vectorlint.ini configs, rule markdowns, test.md and test-false-positive.md fixtures for each new/updated rule set.
Unit Tests Updated
tests/request-builder.test.ts, tests/vercel-ai-provider.test.ts
Added tests for {{file_type}} substitution and updated provider test call-sites to pass the new (optional) context parameter.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as BaseEvaluator.evaluate(file, content)
    participant Ext as Path.extname
    participant Ctx as EvalContext(fileType)
    participant Eval as runJudgeEvaluation / runCheckEvaluation
    participant LLM as LLMProvider.runPromptStructured
    participant RB as RequestBuilder.buildPromptBodyForStructured
    participant Provider as VercelAIProvider

    Caller->>Ext: extract file extension
    Ext-->>Ctx: create context { fileType }
    Caller->>Eval: call with content + context
    Eval->>LLM: runPromptStructured(content, prompt, schema, context)
    LLM->>RB: buildPromptBodyForStructured(originalBody, context)
    RB->>RB: replace {{file_type}} with context.fileType
    RB-->>LLM: return templated system prompt
    LLM->>Provider: provider sends prompt to model (context-aware)
    Provider-->>Eval: structured LLM result
    Eval-->>Caller: aggregated evaluation result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ayo6706

Poem

🐰 New rules hop in, tidy and bright,
File types whisper to prompts at night,
Checks multiply, fixtures bloom,
Context threads through every room—
A linting dance, quick as a bite!

🚥 Pre-merge checks | ✅ 2 | ❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add file-type context and tighten PAT confidence guidance' directly and clearly summarizes the main architectural changes: file-type context injection and confidence threshold tightening.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enh/improve-directive

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.

String.prototype.replace(string) only substitutes the first match.
Switch to replaceAll to ensure custom directives with multiple
{{file_type}} tokens are fully resolved; add regression test covering
a directive with two occurrences.
New rules get 1.0.0; AIPattern and Repetition get 2.0.0 to reflect
their rewrites from the previous commit.
@oshorefueled oshorefueled merged commit 868e204 into main Mar 4, 2026
2 checks passed
@oshorefueled oshorefueled deleted the enh/improve-directive branch March 4, 2026 08:29
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