Consolidate history and baseline into single file#14
Conversation
Rename .history to history and integrate baseline metadata directly into the history file as a special line format (baseline: version timestamp [summary]). Provides backwards compatibility by automatically migrating legacy .history and .baseline files on first read. Simplifies state management by using a unified HistoryState struct containing both applied migrations and baseline information. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
README.md and CLAUDE.md still referenced the old .history and .baseline files. Updated to document the new unified `history` file format. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use origin/main instead of main for all git diff commands to ensure comparisons are against the actual remote state, not a potentially stale local branch. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Consolidate history and baseline into single file format. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Previously, the migration condition only checked for .history files, causing .baseline-only scenarios to be silently ignored. This could happen if a user created a baseline without ever running migrations. Now properly migrates legacy .baseline files even when no .history file exists. Adds test coverage for this edge case. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔴 validate_baseline fails to account for migrations covered by existing baseline
The validate_baseline function prevents moving a baseline forward when migrations covered by an existing baseline are not in the applied history.
Click to expand
Scenario
- User creates a baseline at version
1f700(migration files deleted, baseline recorded) - User applies new migrations
1f710and1f720(these get recorded in history) - User tries to move baseline forward to
1f720 - Validation fails with "Cannot baseline: migration '1f700-xxx' has not been applied"
Root Cause
At src/baseline.rs:64-71, the validation checks that ALL migrations at or before the target version are in the applied list:
for migration in available {
if version_lte(&migration.version, version) && !applied_ids.contains(migration.id.as_str())
{
bail!("Cannot baseline: migration '{}' has not been applied", migration.id);
}
}However, the function receives existing_baseline (line 41) but only uses it to check for backward movement (lines 50-57). It doesn't consider that migrations at or before the existing baseline version should be treated as "applied" for validation purposes.
Impact
Users cannot advance their baseline once they have an initial baseline set, unless all prior migrations happen to still exist in the applied history. This breaks the intended workflow of progressively moving baselines forward over time.
(Refers to lines 64-71)
Recommendation: Modify the validation to also consider migrations covered by the existing baseline as 'applied'. Add a check like: if let Some(b) = existing_baseline { if version_lte(&migration.version, &b.version) { continue; } } before checking the applied_ids.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
.historytohistory(non-hidden file)baseline: version timestamp [summary].historyand.baselinefiles for backwards compatibilityHistoryStatestructTest plan
🤖 Generated with Claude Code