feat: add ctx score — diff-scoped quality scorecard + suite documentation#8
Merged
Conversation
# Conflicts: # docs/json-output.md # src/commands/mod.rs
Scores the working tree against a git reference (default HEAD) by
computing the same metrics on both sides: the current side from
per-changed-file index queries, the baseline side by parsing each
file's content at the reference in memory (no database writes).
Metrics: complexity_delta (2*fan_out + same-file fan_in, approximated
identically on both sides for comparability), fan_out_delta,
new_duplication (near-duplicate pairs at Jaccard >= 0.85 / >= 50
tokens touching a changed file that did not exist at the baseline;
endpoints matched by (file, parent, name), never by symbol id),
check_violations (via the check engine, same reference),
symbols_added/removed, files_changed.
--fail-on "metric OP value,..." turns the command into a CI gate
(exit 1 when any condition holds); malformed expressions, bad refs,
and invalid rules files are operational errors (exit 2). The index
is refreshed incrementally before scoring, never force-rebuilt.
The ctx check engine moves from the binary crate into a new
ctx::check library module (load_context / collect_violations) so the
score engine can invoke it; the CLI wrapper keeps identical behavior.
Also adds Database::file_call_edges per-file query and publishes
gitutil::{is_git_repo_in, show_file_in} and
fingerprint::symbol_shingles for the engine and tests.
Adds command pages (both docs/ and the docs/website/docs mirror) for check, score, duplicates, hotspots, similar, and map; a Quality Gates integration guide with the exit-code philosophy (0 clean / 1 findings / 2 operational error) and the reference Claude Code hook configuration plus recommended CLAUDE.md guidance; registers the new pages and the JSON output contract in the site sidebar; documents the score --json payload in docs/json-output.md; adds a Quality Gates overview and a Change Scoring section to the README (and check/score to the CLI reference); and updates the agent-facing docs/agents/ctx.md with the check and score commands.
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md # docs/json-output.md
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR 7 of the Quality Intelligence Suite. Base is
mainbut this branch integrates #2 (foundation), #6 (check), and #7 (duplicates) — its diff shrinks to just score + docs as those merge. Review the top 2 commits (feat: add ctx score…,docs: document the quality intelligence suite…) until then.ctx scorecommand: answers did this change make the codebase better or worse? over changed files only. Metrics:complexity_delta(two-sided, baseline parsed fromgit show REF:pathin memory),fan_out_delta,new_duplication(MinHash pairs that didn't exist at baseline, matched by(file, parent, name)),check_violations,symbols_added/removed,files_changed.--against <REF>(default HEAD = score uncommitted changes; use main for PR scoping);--fail-on "metric>value,…"turns it into a CI/hook gate (exit 1, failing conditions on stderr and indata.failed_conditions).#[ignore]d benchmark included). Incremental index refresh only, never a full reindex.ctx::checklib module so score can compose it — CLI behavior unchanged, all check tests pass unmodified.npm run buildsucceeds).cd docs/website && npm start) before merging.Test plan
new_duplication, gate flip 1↔0, added/deleted file edges, JSON shape, benchmark).clippy -D warnings,fmt --check,--no-default-featuresbuild clean.🤖 Generated with Claude Code