Repository navigation
Add maintenance health scores - #221
Conversation
bd79675 to
0af096c
Compare
andrew
left a comment
There was a problem hiding this comment.
A few things before this can land.
Schema collision with #215. This PR sets SchemaVersion = 12 and adds maintainer-related columns to packages. The maintainers PR (#215) also sets SchemaVersion = 12 and adds a maintainers JSON column. Whichever lands second will need to rebase, and the maintainer_count integer here duplicates info that #215's maintainers column already carries (it's len(JSON)).
Since #215 is older and farther along, please defer to it: drop the dedicated maintainer_count column from the health schema, and either read the count from #215's cached maintainers blob on cache hit or just compute len(pkg.Maintainers) from the BulkLookup result on miss. After #215 lands, rebase and bump SchemaVersion accordingly. The other health columns (downloads, downloads_period, dependent_packages_count, dependent_repos_count, health_synced_at) are fine to keep.
At-risk vs threshold split. --threshold controls what's displayed, but at_risk_dependencies is computed against a hardcoded score < 75. If I set --threshold=60 I'd expect "at risk" to mean "below 60". Either tie the count to --threshold or document in --help that the at-risk bucket is fixed and the threshold is just a display filter.
Score model is opaque. The penalties (30/25/10/5) are hardcoded in maintenanceHealthScore with no user-facing explanation. The README should at least sketch what lowers the score (no/single maintainer, low usage, missing download data) so the numbers aren't surprising.
|
Heads-up: #225 just landed and centralizes the user agent string into a package-level |
0af096c to
72c0b07
Compare
fixed. i dropped the dedicated |
Fixed after rebasing onto current main. |
andrew
left a comment
There was a problem hiding this comment.
Threshold/scoring/userAgent fixes are right. Two issues to address before this can land:
Maintainer count missing on cache hit. healthDataFromCached populates downloads / dependent counts but leaves MaintainerCount at its zero value. The next call to maintenanceHealthScore then takes the case 0 branch (-30 and signals = ["no maintainer data"]), so every cached row scores 30 points lower than the same row would score on a cold cache. That defeats the cache. The earlier review asked you to either keep a maintainer count column or read it from #215's maintainers JSON blob on hit. Since #215 has just landed, the right move now is to read packages.maintainers alongside the health columns in GetCachedPackageHealth and set cached.MaintainerCount = len(parsedMaintainers). A regression test that runs the command twice (first cold, second cached) and asserts the scores match would also be welcome.
Rebase needed. #215 merged this morning and also bumps SchemaVersion to 12, adds the maintainers/maintainers_synced_at columns to packages, and expands the docs/internals.md cache paragraph. After rebasing:
- bump
SchemaVersionto 13 - keep #215's new
packagescolumns (this PR's CREATE TABLE additions go beside them) - in docs/internals.md, extend the now-expanded "funding / maintainers / deprecated" sentence to also mention
health, instead of inserting in the middle - the README network-commands sentence will also need a 3-way merge to keep
maintainersand addhealth
72c0b07 to
733af76
Compare
Rebased onto main after #215. SchemaVersion is now 13 and the packages schema keeps the maintainers cache columns plus the health metadata columns. GetCachedPackageHealth now selects packages.maintainers and derives MaintainerCount from the parsed maintainer JSON, so cache hits no longer score 30 points lower. Health lookups also save the maintainer list returned by enrichment into the existing maintainers cache and i added a regression test that runs cold then cached and asserts the maintainer count and score stay the same. README and docs/internals.md were merged to keep maintainers and add health in the network/cache wording. Verified with go test ./..., go tool golangci-lint run ./..., and git diff --check upstream/main..HEAD. |
andrew
left a comment
There was a problem hiding this comment.
Cache/schema/docs fixes all look right; CI is green and the regression test is exactly the shape I asked for.
One small boundary inconsistency to fix before merge.
AtRiskDependencies and display use different thresholds. In buildHealthResult, at-risk is incremented for score < threshold while display continues only on score > threshold. So with --threshold=70, a dependency scoring exactly 70 appears in the list but isn't counted in the at-risk summary. The flag help says "at or below this threshold; at-risk count uses the same threshold", which reads as <= for both.
Tighten the at-risk check to score <= threshold (one-line change in cmd/health.go), and add a boundary case to TestBuildHealthResult — e.g. a dep with score equal to the threshold should be both displayed and counted as at-risk.
733af76 to
4bcee98
Compare
fixed. AtRiskDependencies now uses the same inclusive threshold as display ( i also added a boundary case to TestBuildHealthResult confirming a dependency scoring exactly at the threshold is both displayed and counted as at-risk. Verified with go test ./cmd -run Health, go test ./..., go tool golangci-lint run ./..., and git diff --check. |
andrew
left a comment
There was a problem hiding this comment.
Tested locally — build, full test suite, and smoke run on a fresh repo all good. Threshold filter and JSON output behave as documented.
Closes #22
Summary
git pkgs healthto score dependency maintenance healthpackagestable with a 24h TTL--threshold,--all,--ecosystem,--commit,--branchand--format=jsonTests
go test ./cmd -run 'TestBuildHealthResult|TestFetchHealthPackageData|TestPagerFlagAccepted'go test ./internal/databasego test ./...git diff --check