Skip to content

Monotonic create timestamps, future-dated guard, codegen_on_up, hardened skill - #2

Closed
heryr wants to merge 1 commit into
mainfrom
feat/guardrails-and-codegen-on-up
Closed

Monotonic create timestamps, future-dated guard, codegen_on_up, hardened skill#2
heryr wants to merge 1 commit into
mainfrom
feat/guardrails-and-codegen-on-up

Conversation

@heryr

@heryr heryr commented Jul 23, 2026

Copy link
Copy Markdown
Member

Hardens miiigrate against hand-written migration file names and closes the type-drift gap, following a real incident where an agent bypassed migrate::create and forged a future-dated timestamp (…120000).

Changes

  • Monotonic migrate::create — new files are stamped after the latest migration on disk, so a future-dated hand-written name can never make subsequent files sort before an applied migration. Warns when it has to skip ahead of the clock.
  • Future-dated guardmigrate::status returns a new future_dated list; migrate::up logs a warning before applying such a file. 5-minute clock-skew tolerance.
  • codegen_on_up — new config knob (default: enabled when types_out is set) that runs migrate::codegen after an up that applied at least one migration; migrate::up returns the written path as types_path. Codegen failures are logged and never fail the run.
  • SKILL.md rewritten — triggers on any database/schema work and states the hard rules: always scaffold with migrate::create, one migration per logical change, never edit applied files, check types_path after up.
  • Docs: functions, configuration, README, changelog.

Validation

cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test (52 tests) all green.

- migrate::create stamps new files after the latest migration on disk, so
  a hand-written future-dated name can never make new files sort before an
  applied migration
- migrate::status returns future_dated; migrate::up warns before applying
  a future-dated file (5-minute clock-skew tolerance)
- codegen_on_up config (default: enabled when types_out is set) runs
  migrate::codegen after an up that applied migrations; migrate::up returns
  the written path as types_path
- SKILL.md rewritten: triggers on any database/schema work and states the
  hard rules (always migrate::create, one migration per change, never edit
  applied files)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@heryr heryr closed this Jul 23, 2026
@heryr

heryr commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

Merged manually into main as adf9782 (squash) — the GitHub API kept reporting the pre-amend head SHA after a force-push, blocking gh pr merge and reopen. Content is identical to the CI-validated branch. Released in v0.1.3.

heryr added a commit that referenced this pull request Jul 23, 2026
)

- migrate::create stamps new files after the latest migration on disk, so a
  hand-written future-dated name can never make new files sort before an
  applied migration
- migrate::status returns future_dated; migrate::up warns before applying a
  future-dated file (5-minute clock-skew tolerance)
- codegen_on_up config (default: enabled when types_out is set) runs
  migrate::codegen after an up that applied migrations; migrate::up returns
  the written path as types_path
- SKILL.md rewritten: triggers on any database/schema work and states the
  hard rules (always migrate::create, one migration per change, never edit
  applied files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant