Expand description
ctx score engine: a quality scorecard for the changes between a git
reference and the current working tree.
The pipeline is:
- Refresh the index incrementally (never a full reindex).
- Collect the changed-file set relative to the reference.
- For every changed file, compute the same metrics on two sides:
- current: from the index, restricted to the file (per-file queries only – no global scans).
- baseline: by parsing the file’s content at the reference in memory (no database writes).
- Diff the two sides into deltas, detect newly introduced duplication, and run the architecture-rules check.
§Approximation
Per-function complexity is 2 * fan_out + same_file_fan_in. The baseline
side is parsed in isolation, so cross-file callers are unknowable there;
fan-in is therefore approximated as same-file callers on both sides
so the delta compares like with like. This is surfaced as a note in both
human and JSON output.
Structs§
- Fail
Condition - One parsed
--fail-oncondition (metric OP value). - File
Score - Per-changed-file breakdown (both sides of the delta metrics).
- Metrics
- The flat metric set of a score run. Field names are the exact metric
names accepted by
--fail-onand emitted underdata.metricsin JSON. - Score
Report - The complete result of a score run.
Enums§
- Op
- Comparison operator in a
--fail-oncondition.
Constants§
- DUP_
MIN_ TOKENS - Minimum normalized token count for the
new_duplicationmetric. - DUP_
THRESHOLD - Jaccard threshold used for the
new_duplicationmetric. - FAN_
IN_ NOTE - Note attached whenever complexity deltas are reported.
- NO_
RULES_ NOTE - Note attached when
.ctx/rules.tomldoes not exist.
Functions§
- compute_
score - Compute the score of the working tree (plus commits since the merge base)
against
reference. - failed_
conditions - The subset of
conditionssatisfied bymetrics(each one fails the gate). - parse_
fail_ on - Parse a comma-separated
--fail-onexpression like"new_duplication>0, complexity_delta >= 10".