Skip to content

chronometer: subdirectory scans lose all temporal data — the git gate checks (root/.git).exists() #2976

Closed

Description

@squid-protocol

Chronometer._initialize_history_scan enables git only when (self.root / ".git").exists() (gitgalaxy/metrics/chronometer.py:110). .git only exists at the repository ROOT, so any scan rooted at a subdirectory of a repo — galaxyscope path/to/repo/src, or every keyword-rosetta corpus scan (data/<lang>/) — silently loses the entire temporal pipeline: the mtime fallback fires, a fresh checkout's uniform mtimes trip the TEMPORAL COLLAPSE guard, and every file reads the neutral (stability 50, churn 0). This is why the rosetta corpus reports risk_stability flat 50 and risk_churn 0 in all 46 languages despite the files having real git history (keyword-rosetta bias_data.json, risk_churn.calc: null).

A second latent mismatch bites as soon as the gate is fixed: with cwd=<subdir>, git ls-files emits cwd-relative paths but git log --name-only emits repo-relative paths, so the churn/mtime maps would be keyed differently from both the tracked-files denominator and the scanner's scan-root-relative rel_path (galaxyscope.py:1627, :2363) — every lookup would still miss.

Fix (one layer, chronometer only):

  1. Gate on git -C <root> rev-parse --is-inside-work-tree == true (resolves upward from any subdir; a worktree's .git file pointer passes identically).
  2. Scope the history stream to the subtree and its cwd-relative names: git log --since=1.year --name-only --relative ... -- . — keys then match ls-files and rel_path, and the guards spend their 15s budget on the scanned subtree instead of the whole monorepo's log.

Both changes are no-ops for a scan rooted at the repo root (--relative -- . at root is today's output), so existing root scans, the crucible, and the golden masters are unaffected; non-git temp dirs keep the exact (50, 0) fallback. Corpus effect after the fix: churn/stability read real values in the never-gated commit-age context group (keyword-rosetta side is regen-only).

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:infra

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions