Skip to content

feat: add ctx score — diff-scoped quality scorecard + suite documentation#8

Merged
saldestechnology merged 7 commits into
mainfrom
feat/score
Jul 9, 2026
Merged

feat: add ctx score — diff-scoped quality scorecard + suite documentation#8
saldestechnology merged 7 commits into
mainfrom
feat/score

Conversation

@saldestechnology

Copy link
Copy Markdown
Collaborator

Summary

PR 7 of the Quality Intelligence Suite. Base is main but 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.

  • New ctx score command: answers did this change make the codebase better or worse? over changed files only. Metrics: complexity_delta (two-sided, baseline parsed from git show REF:path in 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 in data.failed_conditions).
  • Fast: 2001-file repo with 3 changed files scores in 205 ms (2 s budget; #[ignore]d benchmark included). Incremental index refresh only, never a full reindex.
  • Refactor: check engine moved from the bin crate to ctx::check lib module so score can compose it — CLI behavior unchanged, all check tests pass unmodified.
  • Suite documentation: six Docusaurus command pages (check/hotspots/duplicates/similar/score/map) + a Quality Gates integration page (exit-code philosophy, reference Claude Code hooks settings, CLAUDE.md guidance), JSON contract linked into the site, README Quality Gates section. Docs site build validated (npm run build succeeds).

⚠️ Docs note: this PR adds site pages — worth a local preview (cd docs/website && npm start) before merging.

Test plan

  • 247 tests green (15 new for score: fail-on parser matrix, add/revert delta symmetry, copy-paste → new_duplication, gate flip 1↔0, added/deleted file edges, JSON shape, benchmark).
  • clippy -D warnings, fmt --check, --no-default-features build clean.

🤖 Generated with Claude Code

# 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.
@saldestechnology
saldestechnology merged commit af64ce6 into main Jul 9, 2026
7 checks passed
@saldestechnology
saldestechnology deleted the feat/score branch July 9, 2026 19:05
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