Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .devspark.work/roadmap/roadmap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Roadmap: git-spark

## Direction

git-spark is a Git-only analytics CLI and library for maintainers and engineering leads. It turns
`git log` into reports a team can trust and share. Over the next few releases the outcomes that matter
are:

1. **Every number is right.** A metric is either derived correctly from Git or not shown
(constitution principles 1 and 5).
2. **Every option does what it says.** A flag or config key either works or is removed.
3. **Reports are safe to share.** Redaction is complete, and the local report server does not expose
repository data to the network.

Breadth (new metrics, new outputs) comes after these. Each item below ships on its own and leaves the
tool releasable.

## Current Baseline

Assessed on 2026-11-21 at `main` `6ec37fa` (git-spark 2.0.2 published, PR #19 merged, unreleased).

- **Collection** streams `git log --no-merges --numstat` with `\x1e`/`\x1f` separators
(`src/core/collector.ts`). Since PR #19 the collector matches `git log` commit counts exactly,
`--path` takes Git pathspec globs, and `--branch` combines with `--path`. These three fixes sit in
CHANGELOG `[Unreleased]` waiting for 2.0.3.
- **Analysis** lives in one 2,597-line `src/core/analyzer.ts`. The HTML output was decomposed earlier
(issues #5, #6, #9 closed); the analyzer was not.
- **Quality gates** pass: 345 tests, coverage 80.23% branches / 96.2% functions / 94.92% lines,
production `npm audit` clean. Dependabot alert #75 is the allowlisted dev-only minimatch advisory
(GHSA-g3hv-75wg-m249) in `audit-ci.jsonc`.
- **Code review (2026-11-21)** found the defects listed under Findings and the outcome-sized
problems turned into Prospective Specs below. Evidence for each is in the PS or finding.

## Themes

Priority order. Lower `order` comes first within a theme.

- **Trustworthy numbers**
- [ps-001 Accurate per-file change records](specs/ps-001-accurate-file-change-records.md)
- [ps-002 Correct contributor identity](specs/ps-002-correct-contributor-identity.md)
- [ps-003 Timezone-consistent day and hour buckets](specs/ps-003-timezone-consistent-buckets.md)
- [ps-004 Exact date windows](specs/ps-004-exact-date-windows.md)
- [ps-005 Accurate commit message scoring](specs/ps-005-accurate-commit-message-scoring.md)
- **Options that do what they say**
- [ps-006 Complete, collision-free email redaction](specs/ps-006-complete-email-redaction.md)
- [ps-007 Honor or retire inert options](specs/ps-007-honor-or-retire-inert-options.md)
- [ps-008 Multiple and exclude path filters](specs/ps-008-multiple-and-exclude-path-filters.md)
- **Maintainability**
- [ps-009 Decompose the analyzer](specs/ps-009-decompose-the-analyzer.md)

## Findings

Defects too small for a Prospective Spec. Each is independent and fits `/devspark-quickfix`.

F1 to F4 (the `validate` import, the `html --serve` network exposure, `analyze` ignoring global
options, and `NaN%` bus factor) were fixed on branch `chore/roadmap-and-cli-fixes` and are listed in
CHANGELOG `[Unreleased]`.

| # | Severity | Defect | Evidence |
| - | -------- | ------ | -------- |
| F5 | Low | The streaming collector ignores `git log`'s exit code and stderr, so a failing `git log` yields a partial or empty report instead of an error. | `src/core/collector.ts:265-274` |
| F6 | Low | Finding the first commit date reads the entire `git log --all` into memory under a 60 s timeout; on very large repositories it times out and silently returns `null`, which disables range capping. `git log --all --max-parents=0` returns only root commits. | `src/utils/git.ts:212-232` |
| F7 | Low | On Windows, `--open` runs `cmd.exe /c start "" <path>`; an output path containing `&` or `^` is interpreted by `cmd`. The path is user-supplied, so impact is self-inflicted. | `src/cli/report-command.ts:281-284` |

## Planning Housekeeping

Open items carried over from other planning records, consolidated here:

- **Release 2.0.3** with the PR #19 fixes (CHANGELOG `[Unreleased]`). Release work, not a PS.
- **Article update**: after 2.0.3 ships, update the `--path` note in "Getting to Know Your Repository
with git-spark" (https://claude.ai/artifact/CULQDaKVQDNo8oShqN3nXN), which says `**` globs do not
work.
- **DevSpark migration record** (`.devspark.work/migrations/2026-10-20-devspark.md`): its work is
complete. It stays in `.devspark.work/` because the release archiver needs a
`.knowledge/taxonomy-registry.json` lifecycle entry to archive an uncategorized document. Adding that
registry entry lets the next release archive it.
- **Docs date re-stamp**: `postbuild` (`scripts/update-docs-version.js`) rewrites dates in
`docs/index.html` and `docs/performance-tuning.md` on every build, including the pre-push build,
leaving the tree dirty after each push. Stamp only during release.
- **Dependabot #75**: allowlisted dev-only minimatch advisory; drop the allowlist entry when typedoc
ships a fixed minimatch.

## Decisions

- **2026-11-21: One roadmap.** All planning lives in this roadmap. Durable decisions stay in
`.knowledge/architecture/decisions.md`; the CHANGELOG records what shipped. Basis: the developer asked
to consolidate planning into a single DevSpark roadmap.

## Delivered

None yet.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
id: ps-001
title: Accurate per-file change records
status: proposed
order: 10
depends_on: []
blockers: []
delivery: []
---

# ps-001: Accurate per-file change records

## Outcome

Every file change in a report names the real file and its real change status. Hotspots, risk
scores, file counts, file-type breakdowns, and author file ownership then describe files that exist.

## Current Reality

- `git log --numstat` reports renames in brace form, for example
`{.devspark.work => .archive/2026-10-20}/specs/.../spec.md`. `parseFileStats` splits on ` => `, so
the recorded path becomes `.archive/2026-10-20}/specs/.../spec.md` and the old path becomes
`{.devspark.work` (`src/core/collector.ts:336-340`). In this repository 110 of 134 rename lines use
brace form, so most renames produce corrupted paths.
- Status is guessed from line counts: any change with insertions and no deletions is `added`, and any
with deletions and no insertions is `deleted` (`collector.ts:341-345`). An edit that only appends
lines is reported as a new file.

## Scope and Independence

In scope: correct path and old-path expansion for both brace and plain rename forms, and change status
taken from Git (added, modified, deleted, renamed) rather than inferred. Out of scope: following
history across renames (`--follow`) and merging a renamed file's stats with its old path.

Standalone: the collector's `FileChange` contract is unchanged in shape; only its values become
correct. Shipping this alone leaves every report more accurate.

## Future Health

Keeps one `git log` invocation (Git can emit `--numstat` together with `--raw` or `--name-status`).
Leaves room for later rename-aware history without changing the contract again.

## Dependencies and Decisions

None. Decide whether the JSON `status` change is a fix (patch) or a behavior change (minor) at
release; it changes values, not the schema.

## Completion Expectations

A regression test with a brace-form rename and an append-only edit shows the correct path, old path,
and status. On this repository no recorded path contains `{` or `}` unless the real filename does.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
id: ps-002
title: Correct contributor identity
status: proposed
order: 20
depends_on: []
blockers: []
delivery: []
---

# ps-002: Correct contributor identity

## Outcome

One person counts as one contributor, and co-authored commits are recognized. Contributor counts, bus
factor, and author profiles then match how a team would describe itself.

## Current Reality

- The collector reads raw `%an`/`%ae` (`src/core/collector.ts:182`), so a repository's `.mailmap` is
ignored. Authors are keyed by email (`src/core/analyzer.ts:308,1405`). The 2026-11-21 repo story
found one person under three email identities in this repository, which inflates contributor count
and deflates bus-factor concentration.
- Co-author detection matches only `Co-authored-by:` exactly (`collector.ts:368`). Git trailers are
case-insensitive; this repository has 36 commit bodies with `Co-Authored-By:` that are missed versus
13 detected.
- File ownership is keyed by author name in one place and by email elsewhere
(`analyzer.ts:1222-1231` versus `:821`), so the same person can be split or merged depending on the
section.

## Scope and Independence

In scope: honoring `.mailmap` (Git's `%aN`/`%aE` do this natively), case-insensitive co-author
trailers, and one identity key used consistently across analyses. Out of scope: heuristic identity
merging without a `.mailmap` (guessing would violate constitution principle 1), and bot exclusion
(ps-007).

Standalone: repositories without a `.mailmap` behave as today except for co-author detection.

## Future Health

A single identity key makes ps-006 (redaction) simpler: redact at output, never as the grouping key.

## Dependencies and Decisions

None. Document in the author section's limitations that identity follows `.mailmap`.

## Completion Expectations

A test repository with a `.mailmap` mapping two emails to one person reports one author. A
`Co-Authored-By:` trailer marks the commit co-authored. Every section uses the same author key.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
id: ps-003
title: Timezone-consistent day and hour buckets
status: proposed
order: 30
depends_on: []
blockers: []
delivery: []
---

# ps-003: Timezone-consistent day and hour buckets

## Outcome

Every per-day and per-hour figure uses the analysis timezone (`--timezone` or config, default
`America/Chicago`), and the same commit lands in the same day everywhere in a report, whatever
timezone the machine running git-spark uses.

## Current Reality

- Daily trends convert with `new Date(date.toLocaleString('en-US', { timeZone }))` and then take
`toISOString()` as the day key (`src/core/daily-trends-helpers.ts:11-14`,
`src/core/daily-trends.ts:168-169`). The round trip is only correct on a UTC machine. Verified on an
`America/Chicago` machine: a commit at 8 pm Chicago time on 2026-11-21 is bucketed as 2026-11-22.
On a developer laptop, every evening commit moves to the next day.
- Author work patterns (hour of day, weekend, after hours) use `Date.getHours()`/`getDay()` in the
machine's timezone and ignore `--timezone` (`src/core/analyzer.ts:410-422`). The same repository
gives different patterns locally and in CI.
- The timeline buckets by UTC date (`analyzer.ts:1249,1270`), which disagrees with daily trends.

## Scope and Independence

In scope: one timezone-aware day/hour helper built on `Intl.DateTimeFormat#formatToParts` (no new
dependency), used by daily trends, author work patterns, and the timeline. Out of scope: per-author
timezones taken from commit offsets (a possible later option).

Standalone: no output schema change; values become correct and consistent.

## Future Health

Removes the "would use date-fns-tz in production" placeholder comment. A single helper lets a later
"author's local time" option be a one-line switch.

## Dependencies and Decisions

Decide whether hour-of-day patterns should use the analysis timezone (consistent, recommended) or each
commit's own offset (closer to the author's clock). Record the choice in the metric's limitations.

## Completion Expectations

Tests run with `TZ` set to a non-UTC zone and show identical day keys and hour buckets to a UTC run.
Daily trends and the timeline agree on per-day commit counts.
51 changes: 51 additions & 0 deletions .devspark.work/roadmap/specs/ps-004-exact-date-windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
id: ps-004
title: Exact date windows
status: proposed
order: 40
depends_on: []
blockers: []
delivery: []
---

# ps-004: Exact date windows

## Outcome

`--since`, `--until`, `--days`, and `periods` select exactly the commits a user expects: whole days
from the start of `--since` through the end of `--until`, independent of the time of day the command
runs.

## Current Reality

- Git reads a bare `YYYY-MM-DD` as that date at the current time of day (the reason for the PR #19-era
first-commit fix in `src/core/collector.ts:137-142`). Bare dates are still passed through for
`--since`/`--until`, so `--since 2026-11-01 --until 2026-11-21` run at 9 am drops commits before
9 am on Nov 1 and after 9 am on Nov 21.
- `--days` derives a bare UTC date (`collector.ts:122-128`), so the window shifts with clock time and
UTC offset. `periods` does the same for its lookback start (`src/cli/periods-command.ts:71`).
- `--since X --until X` (a single day) is rejected as "Since date must be before until date"
(`src/utils/validation.ts:43-48`).

## Scope and Independence

In scope: expanding bare dates to explicit start-of-day and end-of-day timestamps in the analysis
timezone, `--days N` as an exact timestamp offset, allowing single-day ranges, and stating the
resolved window in report metadata. Out of scope: new relative-date syntax.

Standalone: CLI syntax is unchanged; results become deterministic.

## Future Health

Uses the timezone helper from ps-003 if it has shipped; otherwise uses the same `Intl` approach so the
two converge. Keeps `options` immutable rather than mutating `options.since` (`collector.ts:126,142`),
which the current regression test relies on and should check through metadata instead.

## Dependencies and Decisions

No hard dependency. Ship ps-003 first if both are planned, so both use one timezone helper.

## Completion Expectations

Tests at fixed fake clock times (morning, evening, across a UTC date change) return the same commits
for the same window. A single-day range is accepted. The report shows the resolved window.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
id: ps-005
title: Accurate commit message scoring
status: proposed
order: 50
depends_on: []
blockers: []
delivery: []
---

# ps-005: Accurate commit message scoring

## Outcome

The governance score rewards the commit practices it claims to measure, and no longer penalizes
detailed commit messages.

## Current Reality

- The length rule (10 to 72 characters earns 0.15) is applied to the whole message, subject plus
body (`src/core/analyzer.ts:1469`, message built at `src/core/collector.ts:310`). Any commit with a
body fails it. In this repository 107 of 222 non-merge commits have a body and lose the points.
- The conventional-commit pattern does not accept breaking-change markers (`feat!:`, `feat(api)!:`)
or the `revert` type (`src/utils/validation.ts:299`).
- WIP detection matches `wip` anywhere, including "wipe" and "swipe" (`validation.ts:303`).
Traceability counts the words "fixes", "closes", or "resolves" anywhere, even without an issue
reference (`validation.ts:302`).
- Governance weights in config (`analysis.weights.governance`) are not used; the weights are
hard-coded (`analyzer.ts:1467-1471`).

## Scope and Independence

In scope: applying the length rule to the subject line, matching the Conventional Commits 1.0 header
grammar, word-boundary WIP detection, and requiring an actual reference for traceability. Out of
scope: honoring config weights (ps-007 decides whether those keys stay).

Standalone: the score changes value, not shape. The governance section's limitations text describes
the rules exactly.

## Future Health

Moves the scoring rules next to `validateCommitMessage` so the rules and the score cannot drift.

## Dependencies and Decisions

The score will rise for well-documented repositories. Call this out in the CHANGELOG so users
comparing scores across versions are not misled.

## Completion Expectations

Table-driven tests cover subject length with and without a body, `feat!:`, `revert:`, "wipe", and
"fixes the build" without an issue reference.
Loading
Loading