phase: 107_git_full_history_dates
Build and Push Containers / build-and-push-app (push) Successful in 1m49s
Build and Push Containers / build-and-push-db (push) Successful in 12s

All green — verification complete. Final report:

**Phase 107 — final verification pass (all tasks already in `complete/`)**

- **Verified:** `clone_or_pull` full-history fix (no `--depth` clone; `--is-shallow-repository` probe → one-time `git fetch --unshallow` self-heal → `git pull --ff-only`; D12 fail-loud) in `scripts/git_sync.py`; E2E suite `tests/e2e/test_git_source_dates.py` present; all five stale shallow/tip-date narratives corrected (no residual claims repo-wide; `docs_push.py` `--depth` fetches untouched as designed).
- **Unit+integration:** `uv run pytest tests/unit/test_git_sync.py tests/integration/test_git_file_dates.py tests/integration/test_import_docs_git.py tests/integration/test_sync_api.py -v --no-cov` → **66 passed** (D10 tip-date test replaced by `test_url_clone_yields_true_per_file_dates` + `test_existing_shallow_checkout_self_heals`; unit pins: clone argv w/o `--depth`, probe→unshallow→pull order, unshallow-failure → `GitSyncError`).
- **New E2E in isolation:** `uv run pytest tests/e2e/test_git_source_dates.py -v --no-cov` → **4 passed** (old file 2020-06-15 ≠ tip file 2024-06-15 in `GET /api/docs`, Sources `Created`/`Updated` columns, viewer `Created` badge ISO title; folder `updated_at` subtree maxes).
- **Phase-106 regressions in isolation:** `test_document_dates.py` → 6 passed; `test_sync_button.py` → 3 passed; `test_git_sources_admin.py` → 6 passed.
- **Full gates:** `uv run pytest` → **2302 passed**; `uv run pytest --cov=app --cov-report=term-missing` → **TOTAL 99%** (>90%); `uv run ruff check . && uv run pyright` → **clean, 0 errors**.
- **Completion criteria:** 1 ✅ non-shallow URL clone + true per-file dates · 2 ✅ self-heal / plain-pull / fail-loud · 3 ✅ both suites green, bug-pin replaced · 4 ✅ E2E green in isolation · 5 ✅ all regressions + full suite + coverage + lint · 6 ✅ narratives corrected · 7 — no commit made (harness override: changes left in working tree; task files already in `complete/`).
- **No defects found; no deviations.** Next pending phase: **108_history_wire_check**.
This commit is contained in:
2026-09-13 23:21:39 -04:00
parent addbd4ca08
commit 6bcee831ec
24 changed files with 1337 additions and 74 deletions
+69 -23
View File
@@ -1,21 +1,26 @@
"""Integration: phase 106 task 03 — ``file_commit_dates`` against real
git scratch repos (D2/D10).
git scratch repos (D2; phase 107 D11 supersedes phase 106 D10).
Builds scratch repositories with controlled ``GIT_COMMITTER_DATE``s
(the 2026-09-13 verification recipe: file ``a.md`` committed once in
2020, file ``b.md`` committed in 2020 and touched again in 2024, a
``docs/deep.md`` subdirectory file committed once in 2020) and pins
the VERIFIED checkout behavior:
the VERIFIED checkout behavior (phase 107):
* a LOCAL-PATH ``clone_or_pull`` keeps FULL history (git's own
"--depth is ignored in local clones" warning — the ``--depth 1``
flag stays, D10) → TRUE per-file last-commit dates (first-sighting
wins: ``a.md`` 2020, ``b.md`` 2024, ``docs/deep.md`` 2020);
* a shallow URL-transport clone (``file://``, made directly in this
test — the test harness, not ``clone_or_pull``, makes this one) →
the TIP commit's date for EVERY working-tree file (the
shallow-boundary property, D10: uniform per repo, real across
repos);
* a LOCAL-PATH ``clone_or_pull`` checkout is FULL history → TRUE
per-file last-commit dates (first-sighting wins: ``a.md`` 2020,
``b.md`` 2024, ``docs/deep.md`` 2020);
* a URL-TRANSPORT (``file://``) ``clone_or_pull`` checkout is FULL
history TOO (D11: no ``--depth`` on the clone) → the SAME true
per-file dates — the regression pin for the 2026-09-16 bug
(pre-fix, D10's shallow ``--depth 1`` clone returned the TIP date
for EVERY file, uniform per repo);
* an EXISTING shallow checkout (made ``--depth 1`` directly by the
test harness — simulating every pre-phase-107 deployed checkout)
self-heals on the next ``clone_or_pull``: the
``--is-shallow-repository`` probe finds it shallow → ``git fetch
--unshallow`` → ``git pull --ff-only`` → no longer shallow, true
per-file dates;
* fail-soft: a directory without ``.git``, an empty repo (no
commits), a git failure, and a malformed log output all yield
``{}`` — a date walk must never break a sync (the importer, task
@@ -39,6 +44,7 @@ from scripts.git_sync import (
_parse_commit_dates, # pyright: ignore[reportPrivateUsage]
clone_or_pull,
file_commit_dates,
run_git,
)
@@ -103,10 +109,10 @@ def scratch_repo(tmp_path: Path) -> Path:
def test_local_clone_yields_true_per_file_dates(scratch_repo: Path, tmp_path: Path) -> None:
"""(a) LOCAL-PATH ``clone_or_pull`` → full history (git warns
"--depth is ignored in local clones" and does not shallow) → TRUE
per-file last-commit dates: the first (newest) sighting of each
path wins — ``b.md`` the 2024 touch, the rest the 2020 commit."""
"""(a) LOCAL-PATH ``clone_or_pull`` → full history (no ``--depth``
at all, phase 107 D11) → TRUE per-file last-commit dates: the
first (newest) sighting of each path wins — ``b.md`` the 2024
touch, the rest the 2020 commit."""
dest = tmp_path / "local"
clone_or_pull(str(scratch_repo), dest)
assert (dest / ".git").exists() # a real checkout
@@ -117,21 +123,61 @@ def test_local_clone_yields_true_per_file_dates(scratch_repo: Path, tmp_path: Pa
}
def test_shallow_file_clone_yields_tip_date_for_every_file(
scratch_repo: Path, tmp_path: Path
) -> None:
"""(b) SHALLOW URL-TRANSPORT clone (``file://``, made directly in
the test — D10): in a shallow clone git reports the TIP commit as
every existing file's last commit (the shallow boundary is each
file's history root) → EVERY working-tree file carries the tip
date, uniform within the repo."""
def test_url_clone_yields_true_per_file_dates(scratch_repo: Path, tmp_path: Path) -> None:
"""(b) URL-TRANSPORT ``clone_or_pull`` (``file://`` through the REAL
function — the 2026-09-16 regression pin): the checkout is FULL
history (no ``--depth`` — phase 107 D11 supersedes phase 106 D10)
→ NOT shallow, and TRUE per-file last-commit dates: the 2020 files
stay 2020 and ``b.md`` (touched again at the tip) gets the 2024
tip date. PRE-FIX this returned DATE_B (the uniform tip date) for
all three files — the exact bug the owner reported.
"""
dest = tmp_path / "url-clone"
clone_or_pull(f"file://{scratch_repo}", dest)
assert (dest / ".git").exists() # a real checkout
assert (
run_git(["git", "rev-parse", "--is-shallow-repository"], cwd=dest).strip()
== "false"
) # a full-history checkout, not shallow
assert file_commit_dates(dest) == {
"a.md": DATE_A,
"b.md": DATE_B, # touched again by the tip commit
"docs/deep.md": DATE_A,
}
def test_existing_shallow_checkout_self_heals(scratch_repo: Path, tmp_path: Path) -> None:
"""(c) an EXISTING shallow checkout — built ``--depth 1`` directly
by the harness, simulating every pre-phase-107 deployed checkout
(live + dev homelab included) — self-heals on the next
``clone_or_pull`` (D11): the ``--is-shallow-repository`` probe
finds it shallow → the ONE-TIME ``git fetch --unshallow`` restores
the full history (no re-clone) → the usual ``--ff-only`` pull. Pre-
heal: shallow + the uniform tip date for all files; post-heal:
full history + true per-file dates."""
dest = tmp_path / "shallow"
_git(tmp_path, "clone", "-q", "--depth", "1", f"file://{scratch_repo}", str(dest))
# Pre-heal: the deployed state the fix must cure.
assert (
run_git(["git", "rev-parse", "--is-shallow-repository"], cwd=dest).strip()
== "true"
)
assert file_commit_dates(dest) == {
"a.md": DATE_B,
"b.md": DATE_B,
"docs/deep.md": DATE_B,
}
clone_or_pull(f"file://{scratch_repo}", dest)
# Post-heal: full history and true per-file dates, same as (b).
assert (
run_git(["git", "rev-parse", "--is-shallow-repository"], cwd=dest).strip()
== "false"
)
assert file_commit_dates(dest) == {
"a.md": DATE_A,
"b.md": DATE_B,
"docs/deep.md": DATE_A,
}
def test_directory_without_dotgit_fails_soft(tmp_path: Path) -> None:
+1 -1
View File
@@ -689,7 +689,7 @@ def test_main_git_failure_aborts_before_import(
def failing_clone(url: str, dest: Path | str) -> Path:
raise GitSyncError(
f"git clone --depth 1 {url} failed (exit 128): "
f"git clone {url} failed (exit 128): "
"fatal: repository not found"
)
+1 -1
View File
@@ -862,7 +862,7 @@ def test_git_failure_marks_failed_and_skips_import(
def failing_clone(url: str, dest: Path | str) -> Path:
raise GitSyncError(
f"git clone --depth 1 {url} failed (exit 128): "
f"git clone {url} failed (exit 128): "
"fatal: repository not found"
)