Repository navigation
fix(#2983): explicit baseline commit for StateRehydrator / --incremental - #3000
Merged
Merged
Conversation
StateRehydrator picked its delta-scan baseline as `ORDER BY commit_date DESC LIMIT 1`. That is correct only for a DB holding one lineage scanned forward. The exposure-history program (#2982) accumulates many commits of one repo in a single DB (keyed `(repo_name, commit_hash)`), where "latest by date" is not the baseline the caller means — an incremental scan rehydrates whichever commit has the newest author date and `git diff <that>` produces a nonsense delta silently. Commit dates are also non-monotonic (rebases, clock skew, imported history), so even forward walks aren't safe. - state_rehydrator: add `load_state(repo_name, commit_hash=None)`. None keeps the latest-by-date behavior; an explicit hash is verified present for the repo and used directly — a missing hash returns None (refuses to substitute a different commit) rather than producing a silent nonsense diff. `load_latest_state` kept as a thin back-compat alias. - galaxyscope: new `--baseline COMMIT_SHA` (default None, fully backward compatible), threaded into the `--incremental` rehydrate call; warns if given without `--incremental`. `execute_incremental_scan` unchanged — it already diffs against the baseline commit recorded in the rehydrated state. - tests: explicit baseline selects that commit (not newest-by-date), missing baseline returns None, and `load_state(None)` matches the legacy alias. Unlocks the longitudinal mode #2982 is heading toward: onboard at commit X, then walk history with `--incremental DB --baseline <previous>` per commit. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HqtNR72fsoL5g57yBBYGX3
Contributor
Zero-tolerance ruff format compliance for the ruff-audit gate. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HqtNR72fsoL5g57yBBYGX3
…state) The CLI incremental path now calls StateRehydrator.load_state(...) (#2983), so the rehydrator mocks in test_galaxyscope.py must stub load_state, not the load_latest_state alias — otherwise the auto-mock returns a truthy value and the None-baseline fallback assertion (execute_pipeline) never fires. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HqtNR72fsoL5g57yBBYGX3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2983.
Problem
StateRehydratorpicked its delta-scan baseline asSELECT commit_hash FROM repo_data WHERE repo_name=? ORDER BY commit_date DESC LIMIT 1. That's right only for a DB holding one lineage scanned forward. The exposure-history program (#2982) accumulates many commits of one repo in a single DB (the schema keys state by(repo_name, commit_hash)), and there:git diff <that>produces a nonsense delta silently.Change
state_rehydrator.py—load_state(repo_name, commit_hash=None).Nonekeeps today's latest-by-date behavior; an explicit hash is verified present for the repo and used directly. A missing hash returnsNoneand prints a refusal — it never substitutes a different commit (the silent nonsense-delta this issue is about).load_latest_statekept as a thin back-compat alias.galaxyscope.py— new--baseline COMMIT_SHA(default unset → unchanged behavior), threaded into the--incrementalrehydrate call asload_state(project_name, args.baseline). Warns if--baselineis passed without--incremental.execute_incremental_scanneeds nothing new — it already diffs against the baseline commit recorded in the rehydrated state.Fully backward-compatible: default path is byte-identical to before.
Tests
tests/core_engine/test_state_rehydrator.py(8 existing + 3 new, all green):None(no silent substitution);load_state(None)matches the legacyload_latest_statealias.Ruff: source files clean; test file only trips
S101(assert-in-test), consistent with the rest of the suite.Unlocks
The longitudinal mode #2982 is heading toward: onboard at commit X with one full scan, then walk history applying
--incremental DB --baseline <previous>per commit.🤖 Generated with Claude Code
https://claude.ai/code/session_01HqtNR72fsoL5g57yBBYGX3