Repository navigation
Add stat filters to Tech Debt Initiatives - #120
Merged
Merged
Conversation
A Tech Debt Initiative can now count part of a stat. `remainingFilter` and `completedFilter` take a `StatFilter`: `extras` conditions for code references, or a `details` condition for numeric and boolean stats. Each filtered stat is published at build time as a derived stat, `tdi__<id>__remaining` or `tdi__<id>__completed`, so it gets totals, history, the web report and per-stat JSON/SARIF exports like any other stat. Derived stats are left out of the aggregate stats.sarif. `effectiveRemainingStatKey` and `effectiveCompletedStatKey` name the stat to read for an initiative and are written to tdi_config.json. Invalid filters fail the report, and the invert task now reruns when initiatives change. The examples project gains a filtered initiative. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
amorde
marked this pull request as ready for review
November 4, 2026 21:10
amorde
commented
Nov 9, 2026
No consumer reads tdi_config.json into the Invert models with Gson, so the test and its test dependency are not needed. Defaults are still encoded for readers that are not written in Kotlin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
steve-the-edwards
approved these changes
Nov 9, 2026
A filter can now set an explicit derived stat key, so its history can be versioned independently of the initiative id. Filters only apply to code references stats; the details condition for numeric and boolean stats is removed until that case has its own design. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng stats - Add @jvmoverloads so Java and Groovy callers keep the constructor without filters. - Report filter problems that do not depend on the source stat (blank key, empty extras, invalid matchers) even when the source stat was not collected. - Correct the StatFilters KDoc: only the build uses it, with JVM regex syntax. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A Tech Debt Initiative could only track a whole stat. This lets an initiative count part of a stat, for example only the code references whose
extrasmatch, so one collected stat can back several initiatives.remainingFilterandcompletedFiltertoTechDebtInitiative. AStatFilterholdsextrasconditions on a code references stat. Each condition is aValueMatcher: one of a list of values, a regex, or "present", optionally negated.keyor by defaulttdi__<id>__remainingortdi__<id>__completed, added to every module that has the source stat. It gets totals, history, the web report and the per-stat JSON and SARIF exports like any other stat, and is left out of the aggregatestats.sarif.effectiveRemainingStatKeyandeffectiveCompletedStatKey, the stat to read for an initiative (the derived stat when filtered). They are written totdi_config.json, so consumers that show or export initiative numbers can read them directly.inverttask whentechDebtInitiativeschange.Additional context
Why derived stats. History only stores per-stat totals, so filtering in the browser could not produce a burndown over time. Publishing the filtered result as its own stat means everything downstream (totals, history, exports, the Stat Breakdown and Code References pages) works without changes. For example,
?page=stat_breakdown&remaining=tdi__<id>__remaining&completed=tdi__<id>__completedshows the initiative's progress.Validation. The report fails on a filter on a stat that is not a code references stat, an extra the stat does not declare (a typo would otherwise silently report 0 remaining), an empty or invalid matcher, a blank
key, acompletedFilterwithout acompletedStatKey, a derived key produced more than once (duplicate initiative ids or filter keys), or a derived key that a collected stat already uses. A source stat that was not collected only logs a warning, as unfiltered initiatives do.Semantics.
REGEXfinds a match anywhere in the value; anchor with^…$for a full match.Compatibility.
tdi_config.jsonfiles still decode.tdi_config.jsonthat are not written in Kotlin see every field.@EncodeDefault.History. A derived stat's history is kept by its key.
StatFilter.keyversions a definition independently of the initiativeid; changing what a filter selects without changing the key mixes two definitions in one history. This is documented onTechDebtInitiativeandStatFilter. Charts that plot a stat over time show0for history points from before the derived stat existed.Not included. A report page listing initiatives. The upstream report has none today: Stat Breakdown lists stats, so a filtered initiative's two derived stats appear there separately, under a "Tech Debt Initiatives" category.
Testing.
./gradlew assemble checkpasses (JDK 17), with new tests inStatFiltersTest,TechDebtInitiativeTestandTechDebtInitiativeStatsTest. Running./gradlew :invertinexamples/with--rerun-tasksproduces both derived stats: 15 remaining Ktor wildcard imports and 2 explicit Ktor imports, rendered as "11.8% Complete (2 of 17)".🤖 Generated with Claude Code