Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(report): report changes covers the last 90 days unless --since says otherwise (#3924)

Raghav Chamadiya7d418949f33c
diff --git a/docs/reference/CLI_REFERENCE.md b/docs/reference/CLI_REFERENCE.md
index 3d90ec2c8..1d41b7cea 100644
--- a/docs/reference/CLI_REFERENCE.md
+++ b/docs/reference/CLI_REFERENCE.md
@@ -1686,7 +1686,7 @@ repowise report assessment [PATH] [--sections a,b] [--format json|markdown|html|
`repowise report inventory [PATH]` renders the `inventory` section alone, with the same `--format`, `--out`, `--workspace`, `--no-workspace` and `--repo` options: the component inventory a software inventory review (PCI DSS 6.3.2) asks for. Its JSON `data` keeps every component's owner teams, languages, entry points and packages; the text lists the components with no declared owner team.
-`repowise report changes [PATH] [--since DATE] [--until DATE] [--format json|markdown|html|csv] [--out FILE] [--refresh] [--no-build]` is the change-management evidence an audit asks for (SOC 2 CC8.1, ISO 27001 A.8.32, PCI DSS 6.5): for every change merged in the period, its components and owning teams, its review record (git holds none, so it reads "not recorded in git" unless `Approved-by` trailers or a `change-metadata` source supply one), measured and inferred reaching tests, the verdict of the condition rules in `.repowise/policies.yaml` ("no policy configured" without one; gate rules are not re-run), its provenance, and whether a later commit reverted it or named it as the cause of a fix. A period summary counts those answers and a method appendix states what git alone cannot attest; unknown is counted apart, never as a failure, and people are counted, never named. It shares one evidence pass with `changes export`, which builds and stores any missing checklist in the index, a few at a time, after printing to stderr how many it will build and roughly how long; `--no-build` reports kept checklists only and counts the rest as unknown.
+`repowise report changes [PATH] [--since DATE|all] [--until DATE] [--format json|markdown|html|csv] [--out FILE] [--refresh] [--no-build]` is the change-management evidence an audit asks for (SOC 2 CC8.1, ISO 27001 A.8.32, PCI DSS 6.5): for every change merged in the period, its components and owning teams, its review record (git holds none, so it reads "not recorded in git" unless `Approved-by` trailers or a `change-metadata` source supply one), measured and inferred reaching tests, the verdict of the condition rules in `.repowise/policies.yaml` ("no policy configured" without one; gate rules are not re-run), its provenance, and whether a later commit reverted it or named it as the cause of a fix. A period summary counts those answers and a method appendix states what git alone cannot attest; unknown is counted apart, never as a failure, and people are counted, never named. It shares one evidence pass with `changes export`, which builds and stores any missing checklist in the index, a few at a time, after printing to stderr how many it will build and roughly how long; `--no-build` reports kept checklists only and counts the rest as unknown. Without `--since` the period is the 90 days before the newest indexed commit (or before `--until`, when earlier), and `--since all` covers every indexed change; the period summary and the method appendix state which window the report used.
Basis `unresolved` means the evidence is missing. Each per-component section opens with one summary row counting components by outcome; a component gets its own item only when there is something to note (an ownership finding, a bus factor of 2 or less on a component the catalog gives a criticality or tags, hotspots, a stale decision, provided contracts, or unresolved or gated evidence), the rest are named in the summary, and the JSON `data` keeps every component's figures. Local paths are removed from every item. A section is a `Section` on `SeamRegistry("report-section")`: each module in `repowise/core/report/sections/` registers one, a plugin registers its own the same way, and a section whose data is absent returns `None` and is left out, as `outcomes` is until a change's checklist has been opened. Renderers live on `SeamRegistry("report-renderer")` and are picked with `--format`. Modernization candidates are not reported, since no existing signal measures them.
diff --git a/packages/cli/src/repowise/cli/commands/changes_cmd.py b/packages/cli/src/repowise/cli/commands/changes_cmd.py
index ef9083ac2..ee6ce99c4 100644
--- a/packages/cli/src/repowise/cli/commands/changes_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/changes_cmd.py
@@ -119,8 +119,14 @@ async def _export(
session, repo_id = opened
on = attribution_enabled(root)
done = 0
+ # An export is the whole window it names; without --since, every indexed change.
request = PeriodRequest(
- since=since, until=until, refresh=refresh, progress=build_progress, plan=build_plan
+ since=since,
+ until=until,
+ window_days=None,
+ refresh=refresh,
+ progress=build_progress,
+ plan=build_plan,
)
async for row, evidence in period_evidence(session, repo_id, root, request):
record = change_record(row, attribution=on)
diff --git a/packages/cli/src/repowise/cli/commands/report_changes_cmd.py b/packages/cli/src/repowise/cli/commands/report_changes_cmd.py
index 86b670626..360885377 100644
--- a/packages/cli/src/repowise/cli/commands/report_changes_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/report_changes_cmd.py
@@ -3,9 +3,10 @@
Every change merged between ``--since`` and ``--until`` with whether it carries
a review record, which tests reach it, the local change policy's verdict, the
teams accountable for what it touched, its provenance and its outcomes, plus a
-period summary and a method appendix. Built the way ``report assessment``
-builds its document and rendered by the same renderers (JSON, Markdown, HTML,
-CSV). A change without a kept checklist has one built and stored first, as
+period summary and a method appendix. Without ``--since`` the period is the 90
+days before the newest indexed commit; ``--since all`` covers every change.
+Built the way ``report assessment`` builds its document and rendered by the
+same renderers (JSON, Markdown, HTML, CSV). A change without a kept checklist has one built and stored first, as
``repowise changes export`` does, unless ``--no-build``; the count to build,
an estimate and progress go to stderr.
"""
@@ -25,13 +26,25 @@ from repowise.cli.helpers import (
silence_logs_for_machine_output_until_close,
)
+#: ``--since all``: every indexed change rather than the default window.
+ALL_HISTORY = "all"
+
+
+def _since(ctx: click.Context, param: click.Parameter, value: str | None) -> datetime | str | None:
+ """``--since``: a date, :data:`ALL_HISTORY`, or unset for the default window."""
+ if value is None:
+ return None
+ if value.strip().lower() == ALL_HISTORY:
+ return ALL_HISTORY
+ return click.DateTime().convert(value, param, ctx)
+
@dataclass(frozen=True)
class ChangesReportOptions:
"""The command line of ``repowise report changes``, as click parses it."""
path: str | None = None
- since: datetime | None = None
+ since: datetime | str | None = None
until: datetime | None = None
fmt: str = "markdown"
out_path: str | None = None
@@ -41,9 +54,14 @@ class ChangesReportOptions:
no_workspace: bool = False
repo_alias: str | None = None
+ @property
+ def whole_history(self) -> bool:
+ return self.since == ALL_HISTORY
+
def period(self) -> tuple[datetime | None, datetime | None]:
"""``(since, until)`` in UTC; raises when the period is empty."""
- since, until = (d.replace(tzinfo=UTC) if d else None for d in (self.since, self.until))
+ start = None if self.whole_history else self.since
+ since, until = (d.replace(tzinfo=UTC) if d else None for d in (start, self.until))
if since and until and since >= until:
raise click.BadParameter("--since must be before --until", param_hint="--since")
return since, until
@@ -52,7 +70,13 @@ class ChangesReportOptions:
@click.command("changes")
@click.argument("path", required=False, type=click.Path(exists=True, file_okay=False))
@click.option(
- "--since", type=click.DateTime(), default=None, help="Merged on or after this date (UTC)."
+ "--since",
+ default=None,
+ callback=_since,
+ metavar="DATE|all",
+ # The day count is DEFAULT_WINDOW_DAYS, written out to keep `--help` off the core import.
+ help="Merged on or after this date (UTC); default the 90 days before the newest indexed "
+ "commit, `all` for every indexed change.",
)
@click.option("--until", type=click.DateTime(), default=None, help="Merged before this date (UTC).")
@click.option(
@@ -81,7 +105,7 @@ def changes_command(**params: Any) -> None:
"""
from repowise.cli.commands.changes_cmd import build_plan, build_progress
from repowise.cli.commands.report_assessment_cmd import _build, _emit, _renderer, _scope
- from repowise.core.changes.period import PeriodRequest
+ from repowise.core.changes.period import DEFAULT_WINDOW_DAYS, PeriodRequest
from repowise.core.report.build import available_sections
opts = ChangesReportOptions(**params)
@@ -101,9 +125,14 @@ def changes_command(**params: Any) -> None:
"since": since.isoformat() if since else None,
"until": until.isoformat() if until else None,
}
+ window_days = None if opts.whole_history else DEFAULT_WINDOW_DAYS
+ if since is None and window_days:
+ # Each repo's start is measured from its own newest commit; the summary names it.
+ scope["period"]["window_days"] = window_days
request = PeriodRequest(
since=since,
until=until,
+ window_days=window_days,
refresh=opts.refresh,
build=not opts.no_build,
plan=build_plan,
diff --git a/packages/core/src/repowise/core/changes/period.py b/packages/core/src/repowise/core/changes/period.py
index ef7a6da29..85d81bce8 100644
--- a/packages/core/src/repowise/core/changes/period.py
+++ b/packages/core/src/repowise/core/changes/period.py
@@ -10,6 +10,9 @@ is done once for the period: the HEAD and window outcomes are read at, and the
deep fix-history walk the risk item stands on (one ``git log`` primes every
change's walk, see
:func:`~repowise.core.analysis.change_risk.fix_history.prime_fix_pressure`).
+With no start date a period covers the :data:`DEFAULT_WINDOW_DAYS` before the
+newest indexed commit (see :meth:`PeriodRequest.resolved`), so a first run on a
+long history does not build a checklist for every change it ever merged.
Builds in a page run side by side, each on its own read session, and each is
kept the moment it finishes, so an interrupt or a failed build loses only the
builds still running. A checklist another writer kept meanwhile (the server,
@@ -21,8 +24,8 @@ from __future__ import annotations
import asyncio
import subprocess
from collections.abc import AsyncIterator, Callable, Sequence
-from dataclasses import dataclass
-from datetime import datetime
+from dataclasses import dataclass, replace
+from datetime import UTC, datetime, timedelta
from pathlib import Path
from types import SimpleNamespace
from typing import Any
@@ -31,6 +34,7 @@ import structlog
from repowise.core.changes import collect
from repowise.core.changes.evidence import ChangeEvidence
+from repowise.core.events.snapshot import RECENT_DAYS
logger = structlog.get_logger(__name__)
@@ -42,6 +46,9 @@ DEFAULT_CONCURRENCY = 4
#: Wall seconds per checklist built at :data:`DEFAULT_CONCURRENCY`, measured on
#: a mid-size repository (rw-demo, 32 changes); used only for an estimate.
SECONDS_PER_BUILD = 3.0
+#: Days a period with no start date covers, back from the newest indexed commit
+#: (the recent-activity window the rest of the index measures).
+DEFAULT_WINDOW_DAYS = RECENT_DAYS
#: Pages in a row the fix-history walk may answer nothing before it is dropped.
_PRIME_MISSES = 3
@@ -56,7 +63,10 @@ class PeriodRequest:
"""Which changes a period pass reads, and how it builds missing checklists.
*since* is inclusive and *until* exclusive, on ``merged_at``; ``None``
- leaves that side open. *refresh* rebuilds every checklist; without *build*
+ leaves that side open, except that a request with no *since* and a
+ *window_days* starts that many days before the newest indexed commit (or
+ *until*, when earlier); ``window_days=None`` covers every indexed change.
+ *refresh* rebuilds every checklist; without *build*
nothing is built, and a change with no kept checklist comes with ``None``.
*plan* is told how many checklists will be built before the first starts;
*progress* is told about each build.
@@ -64,12 +74,32 @@ class PeriodRequest:
since: datetime | None = None
until: datetime | None = None
+ window_days: int | None = DEFAULT_WINDOW_DAYS
refresh: bool = False
build: bool = True
concurrency: int = DEFAULT_CONCURRENCY
progress: Progress | None = None
plan: Plan | None = None
+ async def resolved(self, session: Any, repo_id: str) -> PeriodRequest:
+ """This request with its start date fixed. *window_days* is kept only
+ when the start came from it, so a caller can say which period it read."""
+ from sqlalchemy import func, select
+
+ from repowise.core.persistence.models import GitCommit
+
+ if self.since is not None or not self.window_days:
+ return replace(self, window_days=None)
+ newest = await session.scalar(
+ select(func.max(GitCommit.committed_at)).where(GitCommit.repository_id == repo_id)
+ )
+ if newest is None: # nothing indexed to measure back from
+ return replace(self, window_days=None)
+ anchor = newest if newest.tzinfo else newest.replace(tzinfo=UTC)
+ if self.until is not None and self.until < anchor:
+ anchor = self.until
+ return replace(self, since=anchor - timedelta(days=self.window_days))
+
@dataclass(frozen=True)
class _Pass:
@@ -210,6 +240,7 @@ async def period_evidence(
"""``(row, checklist)`` for each change *request* names, newest first."""
from repowise.core.persistence.crud import ChangeFilter, list_change_keys
+ request = await request.resolved(session, repo_id)
keys = await list_change_keys(
session, repo_id, ChangeFilter(since=request.since, until=request.until)
)
@@ -238,6 +269,7 @@ async def period_evidence(
__all__ = [
"DEFAULT_CONCURRENCY",
+ "DEFAULT_WINDOW_DAYS",
"PAGE",
"SECONDS_PER_BUILD",
"PeriodRequest",
diff --git a/packages/core/src/repowise/core/report/model.py b/packages/core/src/repowise/core/report/model.py
index dbfeb4597..5c7cf515a 100644
--- a/packages/core/src/repowise/core/report/model.py
+++ b/packages/core/src/repowise/core/report/model.py
@@ -131,7 +131,8 @@ class ReportContext:
head_commit: str | None = None
#: The period a ``changes`` report covers and how it builds missing
#: checklists (a :class:`~repowise.core.changes.period.PeriodRequest`);
- #: ``None`` is every indexed change, building what is missing.
+ #: ``None`` is the default request: the 90 days before the newest
+ #: indexed commit, building what is missing.
period: PeriodRequest | None = None
_cache: dict[str, Any] = field(default_factory=dict)
diff --git a/packages/core/src/repowise/core/report/sections/changes.py b/packages/core/src/repowise/core/report/sections/changes.py
index 10f2fd030..f684bdc71 100644
--- a/packages/core/src/repowise/core/report/sections/changes.py
+++ b/packages/core/src/repowise/core/report/sections/changes.py
@@ -14,7 +14,7 @@ changes export`` uses too, which builds and keeps any missing checklist.
from __future__ import annotations
-from datetime import UTC, datetime
+from datetime import UTC, datetime, timedelta
from typing import Any
from repowise.core.report.change_answers import ANSWERS, EntryContext, entry
@@ -31,10 +31,13 @@ _METHOD = (
# -- the pass -----------------------------------------------------------------
-def _request(ctx: ReportContext) -> Any:
+async def _request(ctx: ReportContext) -> Any:
+ """The period the report covers, its start fixed (by default the
+ :data:`~repowise.core.changes.period.DEFAULT_WINDOW_DAYS` before the newest
+ indexed commit)."""
from repowise.core.changes.period import PeriodRequest
- return ctx.period or PeriodRequest()
+ return await (ctx.period or PeriodRequest()).resolved(ctx.session, ctx.repository_id)
async def _period(ctx: ReportContext) -> dict[str, Any]:
@@ -59,9 +62,10 @@ async def _read_period(ctx: ReportContext) -> dict[str, Any]:
policy, policy_error = _load_policy(ctx)
on = attribution_enabled(ctx.repo_root)
+ request = await _request(ctx)
pairs = []
async for row, evidence in period_evidence(
- ctx.session, ctx.repository_id, ctx.repo_root, _request(ctx)
+ ctx.session, ctx.repository_id, ctx.repo_root, request
):
pairs.append((change_record(row, attribution=on), evidence and evidence.to_dict()))
wanted = {s for rec, _ in pairs for s in rec["commits"]}
@@ -78,7 +82,8 @@ async def _read_period(ctx: ReportContext) -> dict[str, Any]:
"policy_error": policy_error,
"attribution": on,
"metadata_source": resolve_source()[0],
- "window": await _window(ctx),
+ "request": request,
+ "window": await _window(ctx, request),
}
@@ -121,13 +126,13 @@ def _utc(value: datetime) -> datetime:
return value if value.tzinfo else value.replace(tzinfo=UTC)
-async def _oldest_gap(ctx: ReportContext, oldest: Any) -> str | None:
+async def _oldest_gap(ctx: ReportContext, request: Any, oldest: Any) -> str | None:
"""Why the period starts before the oldest change the index holds, if it does."""
import asyncio
from repowise.core.git_refs import resolve
- since = _request(ctx).since
+ since = request.since
oldest_at = _utc(oldest[0])
if since is not None and since >= oldest_at:
return None
@@ -139,13 +144,13 @@ async def _oldest_gap(ctx: ReportContext, oldest: Any) -> str | None:
)
-async def _head_gap(ctx: ReportContext, newest: datetime | None) -> str | None:
+async def _head_gap(ctx: ReportContext, request: Any, newest: datetime | None) -> str | None:
"""Why changes after the indexed commit are missing, if the period reaches them."""
import asyncio
from repowise.core.git_refs import resolve
- until = _request(ctx).until
+ until = request.until
if until is not None and newest is not None and until <= _utc(newest):
return None
head = await asyncio.to_thread(resolve, str(ctx.repo_root), "HEAD")
@@ -157,7 +162,7 @@ async def _head_gap(ctx: ReportContext, newest: datetime | None) -> str | None:
)
-async def _window(ctx: ReportContext) -> dict[str, Any]:
+async def _window(ctx: ReportContext, request: Any) -> dict[str, Any]:
"""Whether the index holds every change the period asks for.
The index keeps the newest ``commit_limit`` main-line commits, and only up
@@ -180,8 +185,8 @@ async def _window(ctx: ReportContext) -> dict[str, Any]:
gaps = [
gap
for gap in (
- await _oldest_gap(ctx, oldest) if oldest is not None else None,
- await _head_gap(ctx, newest),
+ await _oldest_gap(ctx, request, oldest) if oldest is not None else None,
+ await _head_gap(ctx, request, newest),
)
if gap
]
@@ -260,21 +265,44 @@ def _iso(value: datetime | None) -> str | None:
return value.isoformat() if value else None
-def _period_check(ctx: ReportContext, entries: list[dict[str, Any]]) -> dict[str, Any]:
- request = _request(ctx)
+def _span(request: Any) -> str:
since = request.since.date().isoformat() if request.since else "the oldest indexed change"
until = f"before {request.until.date().isoformat()}" if request.until else "to the newest"
+ return f"from {since} {until}"
+
+
+def _window_words(request: Any) -> str:
+ """How the period's start was chosen, in words."""
+ if request.window_days:
+ anchor = request.since + timedelta(days=request.window_days)
+ to = "--until" if anchor == request.until else "the newest indexed commit"
+ return (
+ f"the {request.window_days} days before {anchor.date().isoformat()} ({to}), the "
+ "default without --since; --since DATE sets the start and --since all covers "
+ "every indexed change"
+ )
+ if request.since is not None:
+ return "the start --since gave"
+ return "every indexed change (--since all)"
+
+
+def _period_check(period: dict[str, Any], entries: list[dict[str, Any]]) -> dict[str, Any]:
+ request = period["request"]
by_category: dict[str, int] = {}
for e in entries:
by_category[e["category"]] = by_category.get(e["category"], 0) + 1
return check(
"changes-in-period",
- reason=f"{len(entries)} change(s) merged from {since} {until}",
- details=[f"{k}: {v}" for k, v in sorted(by_category.items())],
+ reason=f"{len(entries)} change(s) merged {_span(request)}",
+ details=[
+ f"period: {_window_words(request)}",
+ *(f"{k}: {v}" for k, v in sorted(by_category.items())),
+ ],
method=_METHOD,
basis="measured",
data={"changes": len(entries), "by_category": by_category,
- "since": _iso(request.since), "until": _iso(request.until)},
+ "since": _iso(request.since), "until": _iso(request.until),
+ "window_days": request.window_days},
)
@@ -448,7 +476,7 @@ async def _collect_summary(ctx: ReportContext) -> list[dict[str, Any]]:
period = await _period(ctx)
entries: list[dict[str, Any]] = period["entries"]
return [
- _period_check(ctx, entries),
+ _period_check(period, entries),
_window_check(period["window"]),
_checklists_check(entries),
_review_check(period, entries),
@@ -523,6 +551,13 @@ def _policy_reason(period: dict[str, Any]) -> str:
)
+def _period_reason(request: Any) -> str:
+ return (
+ f"The period runs {_span(request)}: {_window_words(request)}. A change counts "
+ "in it by the date it was merged (UTC)."
+ )
+
+
def _snapshot_reason(ctx: ReportContext) -> str:
head = (ctx.head_commit or "")[:12] or "the indexed commit"
return (
@@ -536,6 +571,7 @@ async def _collect_method(ctx: ReportContext) -> list[dict[str, Any]]:
period = await _period(ctx)
entries = period["entries"]
items = [
+ ("period", _period_reason(period["request"]), "measured"),
("review", _review_reason(period["metadata_source"]),
"declared" if any(e["review"]["status"] == "known" for e in entries) else "unresolved"),
("tests", _STATED["tests"],
diff --git a/tests/unit/core/test_report_changes.py b/tests/unit/core/test_report_changes.py
index 8380b3919..e150e2ecb 100644
--- a/tests/unit/core/test_report_changes.py
+++ b/tests/unit/core/test_report_changes.py
@@ -355,8 +355,9 @@ async def test_no_policy_file_reads_no_policy_configured(ctx, builds):
async def test_method_appendix_says_what_git_cannot_attest(ctx, builds):
method = _section(await _document(ctx), "change-method")
- assert {"review", "tests", "policy", "accountability", "provenance", "outcomes",
+ assert {"period", "review", "tests", "policy", "accountability", "provenance", "outcomes",
"snapshot", "not-attested"} == set(method)
+ assert "the start --since gave" in method["period"]["reason"]
assert "not recorded in" in method["review"]["reason"]
assert method["not-attested"]["basis"] == "unresolved"
@@ -420,6 +421,78 @@ def test_cli_writes_the_pack_and_reports_progress(root: Path, builds, tmp_path:
assert bad.exit_code != 0 and "--since must be before --until" in bad.output + bad.stderr
+# -- the default period ----------------------------------------------------------
+
+#: Merged more than 90 days before the newest indexed commit (HEAD1, 2026-03-01).
+OLD = _change("pr-0", "0", "f" * 40, "fix: old", datetime(2025, 11, 1, tzinfo=UTC), "fix")
+
+
+async def test_no_since_covers_90_days_before_the_newest_commit(ctx, builds):
+ from dataclasses import replace
+
+ from repowise.core.changes.period import DEFAULT_WINDOW_DAYS, PeriodRequest, period_evidence
+
+ await _add_changes(ctx.repo_root, [OLD])
+ request = await PeriodRequest().resolved(ctx.session, ctx.repository_id)
+ assert DEFAULT_WINDOW_DAYS == 90 and request.window_days == 90
+ assert request.since == datetime(2025, 12, 1, tzinfo=UTC)
+ got = [r.change_id async for r, _e in period_evidence(
+ ctx.session, ctx.repository_id, ctx.repo_root, PeriodRequest())]
+ assert got == ["pr-3", "pr-2", "pr-1"]
+
+ # An earlier --until is the anchor instead of the newest commit.
+ until = datetime(2026, 1, 15, tzinfo=UTC)
+ early = await PeriodRequest(until=until).resolved(ctx.session, ctx.repository_id)
+ assert early.since == datetime(2025, 10, 17, tzinfo=UTC)
+
+ doc = await _document(replace(ctx, period=PeriodRequest()))
+ summary = _section(doc, "change-summary")["changes-in-period"]
+ assert summary["data"]["window_days"] == 90 and summary["data"]["changes"] == 3
+ assert summary["data"]["since"] == "2025-12-01T00:00:00+00:00"
+ assert "90 days before 2026-03-01 (the newest indexed commit)" in summary["details"][0]
+ method = _section(doc, "change-method")["period"]["reason"]
+ assert "from 2025-12-01" in method and "--since all" in method
+
+
+async def test_explicit_since_wins_and_all_covers_every_change(ctx, builds):
+ from repowise.core.changes.period import PeriodRequest, period_evidence
+
+ await _add_changes(ctx.repo_root, [OLD])
+ given = await PeriodRequest(since=SINCE).resolved(ctx.session, ctx.repository_id)
+ assert given.since == SINCE and given.window_days is None
+ every = PeriodRequest(window_days=None)
+ assert (await every.resolved(ctx.session, ctx.repository_id)).since is None
+ got = [r.change_id async for r, _e in period_evidence(
+ ctx.session, ctx.repository_id, ctx.repo_root, every)]
+ assert got == ["pr-3", "pr-2", "pr-1", "pr-0"]
+
+
+def test_cli_defaults_to_the_window_and_takes_since_all(root: Path, builds, tmp_path: Path) -> None:
+ from repowise.cli.helpers import run_async
+ from repowise.cli.main import cli
+ from repowise.core.changes.period import DEFAULT_WINDOW_DAYS
+
+ run_async(_add_changes(root, [OLD]))
+ runner = CliRunner(mix_stderr=False)
+ out = tmp_path / "pack.json"
+ args = ["report", "changes", str(root), "--no-workspace", "--format", "json", "--out", str(out)]
+
+ assert runner.invoke(cli, args).exit_code == 0
+ doc = json.loads(out.read_text(encoding="utf-8"))
+ assert doc["scope"]["period"] == {"since": None, "until": None, "window_days": 90}
+ assert set(_section(doc, "changes")) == {"#1", "#2", "#3"}
+
+ assert runner.invoke(cli, [*args, "--since", "all"]).exit_code == 0
+ doc = json.loads(out.read_text(encoding="utf-8"))
+ assert doc["scope"]["period"] == {"since": None, "until": None}
+ assert set(_section(doc, "changes")) == {"#0", "#1", "#2", "#3"}
+
+ help_text = runner.invoke(cli, ["report", "changes", "--help"]).output
+ assert f"{DEFAULT_WINDOW_DAYS} days" in help_text and "`all`" in help_text
+ bad = runner.invoke(cli, [*args, "--since", "yesterday"])
+ assert bad.exit_code != 0
+
+
# -- the pass under load, failure and other writers ---------------------------