Skip to content

fix(history): count all imperative samples - #248

Open
404-Page-Found wants to merge 3 commits into
mainfrom
fix/204-count-all-imperative-samples
Open

fix(history): count all imperative samples#248
404-Page-Found wants to merge 3 commits into
mainfrom
fix/204-count-all-imperative-samples

Conversation

@404-Page-Found

@404-Page-Found 404-Page-Found commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Corrects style-profile tone detection so descriptive commit verbs are included in the imperative-rate denominator.

Changes

  • Count every evaluated first word as an imperative sample.
  • Count only imperative-like forms in the numerator.
  • Update regression coverage for mixed imperative and descriptive entries.

Testing

  • npm run build
  • node --test tests/history-profile.test.mjs

Related

Closes #204

Summary by CodeRabbit

  • Bug Fixes

    • Improved commit-message style analysis by more accurately distinguishing imperative and descriptive verb forms.
    • Updated imperative-rate calculations to include recognized descriptive forms for more representative results.
  • Tests

    • Expanded coverage for past-tense, gerund, and base-form verbs with descriptive endings.
    • Updated expected style-profile metrics to reflect the improved classification behavior.

Include descriptive verb forms in the imperative-rate denominator.

Closes #204
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

buildProfile now classifies descriptive verb forms explicitly and includes every detected verb in the imperative-rate denominator. Tests update expected rates for descriptive and base-form verbs with descriptive suffixes.

Changes

Imperative Rate Classification

Layer / File(s) Summary
Descriptive verb classification
src/history/store.ts
Adds suffix-based descriptive verb detection with exceptions for specific base-form verbs.
Profile counting and validation
src/history/store.ts, tests/history-profile.test.mjs
Counts all detected verbs as samples, counts only non-descriptive verbs as imperative, and updates expected imperative rates to 1/3 and 2/3.

Estimated code review effort: 3 (Moderate) | ~15–30 minutes

Suggested reviewers: peter7896

Poem

I twitch my nose at verbs in flight,
Past and present sorted right.
Every sample joins the queue,
Imperative counts stay true.
Hop, hop—profiles now see through!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: correcting imperative-rate counting for history entries.
Linked Issues check ✅ Passed The denominator and numerator logic now counts every evaluated sample while only imperative-like verbs increment the imperative count, matching #204.
Out of Scope Changes check ✅ Passed The verb-classification helper refines the same imperative-rate fix and does not introduce unrelated behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@404-Page-Found

Copy link
Copy Markdown
Contributor Author

@codex review

@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: cdb1b7e302

ℹ️ 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/history/store.ts
Comment on lines +314 to 316
imperativeSampleCount++;
if (!verb.endsWith('ed') && !verb.endsWith('ing')) {
imperativeCount++;

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 Preserve base-form verbs ending in suffix-like text

When history contains base-form imperative verbs whose spelling ends in ed or ing (such as seed or bring), incrementing the denominator here while excluding those verbs from the numerator misclassifies them as descriptive. For fix: add retries, fix: bring retries, and fix: added retries, the rate becomes 1/3 instead of the correct 2/3, so buildStyleGuidance() no longer emits imperative guidance at its 0.5 threshold; classify the verb form rather than relying solely on its suffix before counting the sample.

AGENTS.md reference: AGENTS.md:L63-L63

Useful? React with 👍 / 👎.

Add a set of base-form verbs that end with 'ed' or 'ing' (e.g., 'bleed', 'bring') to avoid counting them as descriptive in the imperative rate calculation. Refactor verb extraction to use optional chaining and fallback. Add test to verify correct behavior.
@404-Page-Found

Copy link
Copy Markdown
Contributor Author

@codex review

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/history/store.ts`:
- Around line 42-43: Normalize the verb to lowercase at the start of
isDescriptiveVerb before both BASE_FORM_VERBS_WITH_SUFFIXES lookup and suffix
checks. Update tests/history-profile.test.mjs lines 70-85 to use capitalized
“Bring” in the fixture while retaining the expected 2 / 3 imperative rate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1d61a79f-baa2-4197-9722-f77fde2ec7b5

📥 Commits

Reviewing files that changed from the base of the PR and between 76c6e18 and 9a355bb.

📒 Files selected for processing (2)
  • src/history/store.ts
  • tests/history-profile.test.mjs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

The project is ESM-only: use .js extensions in local imports and keep verbatimModuleSyntax-compatible TypeScript imports (for example, import type for type-only imports).

Files:

  • src/history/store.ts
src/{history,llm}/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Recent commit history should be stored as JSONL, analyzed by buildProfile() for commit-style patterns, and injected into prompts as style guidance.

Files:

  • src/history/store.ts
tests/**/*.mjs

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.mjs: Use Node.js built-in node:test for test files in tests/ and tests/e2e/; do not use Jest or Mocha.
Write test assertions with node:assert/strict in test files under tests/ and tests/e2e/.

Files:

  • tests/history-profile.test.mjs
🔇 Additional comments (2)
src/history/store.ts (1)

348-352: LGTM!

tests/history-profile.test.mjs (1)

46-68: LGTM!

Comment thread src/history/store.ts
Comment on lines +42 to +43
function isDescriptiveVerb(verb: string): boolean {
return !BASE_FORM_VERBS_WITH_SUFFIXES.has(verb) && (verb.endsWith('ed') || verb.endsWith('ing'));

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Normalize verb casing before suffix classification.

verb preserves commit-message casing, but the exception set is lowercase. Therefore fix: Bring retries is incorrectly treated as descriptive and lowers the imperative rate.

  • src/history/store.ts#L42-L43: normalize verb before both the exception lookup and suffix checks.
  • tests/history-profile.test.mjs#L70-L85: capitalize bring in the fixture (or add a capitalized case) and retain the expected 2 / 3 rate.
Proposed fix
 function isDescriptiveVerb(verb: string): boolean {
-  return !BASE_FORM_VERBS_WITH_SUFFIXES.has(verb) && (verb.endsWith('ed') || verb.endsWith('ing'));
+  const normalizedVerb = verb.toLowerCase();
+  return !BASE_FORM_VERBS_WITH_SUFFIXES.has(normalizedVerb)
+    && (normalizedVerb.endsWith('ed') || normalizedVerb.endsWith('ing'));
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function isDescriptiveVerb(verb: string): boolean {
return !BASE_FORM_VERBS_WITH_SUFFIXES.has(verb) && (verb.endsWith('ed') || verb.endsWith('ing'));
function isDescriptiveVerb(verb: string): boolean {
const normalizedVerb = verb.toLowerCase();
return !BASE_FORM_VERBS_WITH_SUFFIXES.has(normalizedVerb)
&& (normalizedVerb.endsWith('ed') || normalizedVerb.endsWith('ing'));
}
📍 Affects 2 files
  • src/history/store.ts#L42-L43 (this comment)
  • tests/history-profile.test.mjs#L70-L85
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/history/store.ts` around lines 42 - 43, Normalize the verb to lowercase
at the start of isDescriptiveVerb before both BASE_FORM_VERBS_WITH_SUFFIXES
lookup and suffix checks. Update tests/history-profile.test.mjs lines 70-85 to
use capitalized “Bring” in the fixture while retaining the expected 2 / 3
imperative rate.

@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: 9a355bbdd5

ℹ️ 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/history/store.ts
]);

function isDescriptiveVerb(verb: string): boolean {
return !BASE_FORM_VERBS_WITH_SUFFIXES.has(verb) && (verb.endsWith('ed') || verb.endsWith('ing'));

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 Normalize case before checking base-form exceptions

When history contains sentence-case subjects such as Ping server, the extracted verb is Ping, which misses the lowercase ping entry and is classified as descriptive solely because it ends in ing. Repositories using capitalized subjects therefore get an artificially low imperative rate, potentially suppressing the imperative-mood prompt when the rate falls below 50%; lowercase the verb before both checks.

AGENTS.md reference: AGENTS.md:L63-L63

Useful? React with 👍 / 👎.

Comment thread src/history/store.ts
]);

function isDescriptiveVerb(verb: string): boolean {
return !BASE_FORM_VERBS_WITH_SUFFIXES.has(verb) && (verb.endsWith('ed') || verb.endsWith('ing'));

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 Account for compound base verbs in suffix detection

When an imperative subject begins with a compound base verb such as fix: reseed database, reseed ends in ed but is absent from the exception set even though its root seed is present, so the new denominator logic records it as descriptive. The same applies to forms such as preseed and valid base verbs such as shred, causing the learned tone and resulting prompt guidance to be wrong for those histories; the exception logic needs to recognize these base forms rather than relying on this incomplete list.

AGENTS.md reference: AGENTS.md:L63-L63

Useful? React with 👍 / 👎.

The lowercase conversion was missing when checking if a verb ends with 'ed' or 'ing', causing capitalized verbs like 'Bring' to be incorrectly classified as descriptive verbs.
@404-Page-Found

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 9973b1dea5

ℹ️ 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/history/store.ts

function isDescriptiveVerb(verb: string): boolean {
verb = verb.toLowerCase();
return !BASE_FORM_VERBS_WITH_SUFFIXES.has(verb) && (verb.endsWith('ed') || verb.endsWith('ing'));

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 Handle derived base-form verbs before suffix classification

When a commit uses an imperative derived verb such as fix: reseed database, the exact allowlist does not contain reseed, so the ed suffix incorrectly marks it as descriptive. For example, a history containing that subject and fix: added retry produces an imperative rate of 0 instead of 50%, preventing buildStyleGuidance() from preserving the repository's imperative style. Prefix-derived forms such as reseed and preseed need classification beyond an exact-word allowlist.

Useful? React with 👍 / 👎.

@sonarqubecloud

Copy link
Copy Markdown

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.

[History] Imperative-rate calculation skips non-imperative samples

1 participant