19. Collect commits by date window, and let the author instant own the day
Date: 2026-11-24
Status
Accepted
Relates to 9. Storage trait for DI, 15. Project discovery reports, it does not absorb
Context
The journal claims that a day page holds what happened that day. The git
collector could not deliver that. Git::commits walked 20 commits from HEAD
and returned the timestamps git orders by, the committer instants. Two
failures followed, and issue #114 measured both on 2026-11-21.
A day with more than twenty commits arrived with twenty. Worse, a finished day shrank as newer work landed: the same Saturday page read 57 commits, then 47, then 27 across one day of builds, with no change to Saturday. One repository fell off its own page once its newest twenty commits were all dated the next day.
The second failure was quieter. Git orders a history walk by committer time, and a rebase, amend, or merge rewrites the committer stamp while leaving the author stamp alone. Bucketing by the committer instant therefore filed Saturday’s rebased work on Sunday. Rebase enough of a branch and the record moves days.
Both failures come from one substitution: a count stood in for a date range, and a landing stamp stood in for the moment the work was written.
Decision
Make the collector answer a question about dates.
Git::commits takes a CommitWindow of instants instead of returning a fixed
number of commits, and returns a CommitScan. The window is
settings.commit_window_days civil days ending with today, default 365, which
is how far back the journal writes pages. One number feeds both, so a page can
never be built for a day the collector refused to read. settings.max_commits
defaults to 5000 and bounds the work per repository.
GitCommit carries both authored_at and committed_at. Every site that
decides which day a commit belongs to reads authored_at. The committer
instant stays because it is the only honest key for the walk, not because a
page needs it.
The walk breaks on committed_at and filters on authored_at, inside a floor
padded 30 days past the window start. Ordering and stopping must agree, and
git2::Sort::TIME orders by committer time. Breaking on the author instant
would stop the walk exactly where rebased history begins, dropping the commits
the bug is about. The pad covers the reverse case, a commit whose author stamp
sits ahead of its committer stamp; measured across the 134-project registry,
the largest such gap is about an hour, so 30 days is margin rather than a
guess. CommitScan::scanned records how many commits the walk inspected, so
“did the early exit fire” is measured rather than assumed.
A guard that binds in silence is the original bug at a smaller scale, so
max_commits reports itself. CommitScan::truncated reaches
ProjectContext::git_truncated, and a day page or project page built from a
truncated list carries a visible marker.
Consequences
Day pages stop depending on the clock. Rebuilding 2026-11-21 after a commit lands on 2026-11-24 changes nothing about that Saturday, which is the claim in the issue title and now an assertion in the tests.
Counts rise. A project page reports a year of history instead of twenty
commits, and the dashboard’s fleet total moves from a capped figure to
whatever happened. That is the fix arriving, not a regression, and the PR says
so. Two pages keep their own scope rather than inheriting the window: a project
page lists the newest 50 commits and states how many more the window holds,
and this-week.md counts the commits authored in the week it names.
cerebro build --fresh becomes corrective rather than destructive. While the
count stood, a fresh rebuild could only shrink recorded days. Issue #123, where
an existing day page is skipped instead of rewritten, is unchanged here and
becomes safely repairable on its own.
The public shape changes: GitCommit.time is gone, the Git trait takes a
window, and ProjectContext gained a field. Every consumer moved in the same
commit, so nothing half-migrated survives. Cache files needed no migration; the
scan cache stores timestamps only.