Skip to content

feat: repeatable dhruv check for committed changes - #179

Merged
rahul05ranjan merged 11 commits into
mainfrom
feat/check-committed-review
Oct 9, 2026
Merged

rahul05ranjan merged 11 commits into
mainfrom
feat/check-committed-review

Conversation

@rahul05ranjan

@rahul05ranjan rahul05ranjan commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

dhruv check --base <git-ref>
  compare merge-base..HEAD committed source
  report changed-line advisory Findings
  emit text or one versioned JSON result
  state policy, exclusions, coverage, and exit status

Adds a read-only Built-in Command for local branches and CI. The optional .dhruv-check.json policy is read from the resolved base commit, so a pull request cannot narrow its own review scope. check bypasses repository Plugin Commands and sends only bounded selected changes to the configured Ollama endpoint. The adoption guide includes local usage, policy and JSON contracts, and a GitHub Actions example.

Closes #165. Closes #166. Closes #167. Closes #168. Closes #169.

Evidence

  • Before: review --diff covers uncommitted edits; no command reviewed a committed merge-base range with machine-readable Findings and coverage.
    After: command-level tests cover Git ranges, changed-line validation, invalid model output, JSON failures, policy overrides, strict coverage, plugin avoidance, and prompt byte limits.
  • Local validation on the review-fix branch: lint, type check, build, and the full Jest suite passed (27 suites, 556 tests). CI on the final SHA passed lint, type checking, build, tests, and installed-package smoke on Windows, macOS, and Linux. The test Git helper was corrected after the earlier Windows failure on null-device config and hooks paths.
  • The guide's workflow is checked structurally, and its command is exercised against a stand-in Ollama service. The workflow itself has not run on a real self-hosted GitHub runner with Ollama.

Merge Danger

Door: two-way

Blast Radius: CLI dispatch, Git Source Ingestion, configured Ollama requests, JSON Command Presentation, and local/CI review policy.

Findings remain advisory. Complete coverage means the selected source fit the configured scope and limits; it does not establish that the model found every problem. Pull request code can contain prompt-injection text, so the example CI job keeps the result as an artifact for human review.

Add dhruv check --base <git-ref>: reviews merge-base..HEAD with
argument-safe Git calls, deterministic size limits and new-side changed
lines, starts without loading Plugin Commands, and is authorized in the
separate security allowlist.
A request with cache: false neither reads nor writes .dhruv-cache, so a
caller reviewing an untrusted checkout can keep model responses off disk.
Ask the model for structured candidates and report only those on a
new-side changed line of an analyzed file, with a documented severity,
reason, evidence and recommendation. Invalid and off-diff candidates are
omitted and counted, duplicates collapse deterministically, and an
unparseable response fails the run without echoing it. Text shows a
summary; JSON is one schemaVersion 1 object for success and failure.
check bypasses the response cache so model output stays off disk.
Read a versioned policy, .dhruv-check.json, from the HEAD commit as JSON
data: include and exclude globs, changed-file and patch-byte limits and a
minimum shown severity. An invalid policy or option fails before any AI
request, and each setting has a command-line option that replaces it for
one run without touching the checked-in file.

Source Ingestion now reports ignored, unreadable and truncated changes
besides the existing reasons, counts exclusions by reason, and truncates
an oversized patch at a hunk boundary instead of dropping the file.
Incomplete coverage stays advisory and visible in text and JSON;
--strict-coverage turns it into status "incomplete" with exit code 2.
The JSON result grows additively and stays schemaVersion 1.
The Ollama client was built without a host, so every request went to
127.0.0.1:11434 while only the status probe read OLLAMA_HOST: status
could report a remote server that generation never used. Both now read
the same endpoint, which is what lets a command run against an Ollama
service on another machine. An empty OLLAMA_HOST means the local default.
A Built-in Command can now carry help notes, printed after its examples.
check uses them for what its options do not say: it reads commits only,
findings are advisory, --json writes one versioned object, what each exit
code means, and where the adoption guide lives.
docs/check.md leads with the local command and a copyable workflow for a
self-hosted runner that reaches a company-operated Ollama service, then
keeps the options, policy file, exclusion reasons, JSON result, exit codes
and error kinds in reference tables. The workflow lives in the guide, so
this repository does not run it.

The guide states the behaviour as built: the policy is read from the HEAD
commit, so a pull request can loosen its own review and the result shows
it; limits count patch bytes; removal-only changes and unsupported file
types are not sent; findings are advisory and validation covers location
and structure only; check writes logs/ where it runs.

The README links the guide, separates check from review --diff, documents
OLLAMA_HOST, and notes that check never loads plugins. CONTEXT.md gains
Committed Range, Check Policy, Finding and Coverage.
A contract test reads docs/check.md and the README and checks them against
the definitions and against real runs with a fake AIClient: every shown
command line uses options check accepts, the guide's text and JSON
examples are reproduced exactly, the example policy is accepted and
applied, and the option, policy, exclusion, severity, JSON key, exit code
and error kind tables match what runs produce.

The GitHub Actions example is parsed and checked for full history, the
pull request head, no credentials, no repository code, and a result that
reaches only the artifact. Its command is then run for real against a
stand-in Ollama service through OLLAMA_HOST, in a checkout that carries a
plugin and its own Dhruv configuration.

COVERAGE_BREAKING is exported so the documented reasons stay in step.
@rahul05ranjan
rahul05ranjan marked this pull request as ready for review October 9, 2026 19:23
@rahul05ranjan
rahul05ranjan merged commit 84fe1ff into main Oct 9, 2026
19 checks passed
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

1 participant