Skip to content

docs(openspec): adopt option E for dbmate→Ent reconciliation - #1186

Merged
kalbasit merged 1 commit into
mainfrom
docs-openspec-adopt-option-e-for
May 22, 2026
Merged

kalbasit merged 1 commit into
mainfrom
docs-openspec-adopt-option-e-for

Conversation

@kalbasit

@kalbasit kalbasit commented May 20, 2026 •

Copy link
Copy Markdown
Owner

The §8 schema-equivalence test exposed real schema drift between the
§7 translated dbmate-era migrations and Ent's expected schema:

  • D10b structural: weak entities need a surrogate id PK column
  • Postgres dialect: dbmate emitted BIGSERIAL; Ent emits BIGINT
    GENERATED BY DEFAULT AS IDENTITY (Atlas refuses to compute the diff
    as an "unexpected attribute change")
  • Cosmetic: index and CHECK constraint naming differs between dbmate
    and Ent's defaults

Refines design D6 to capture Option E (three artifacts + decision
tree):

  1. Translated dbmate-era files stay in the repo as the compatibility
    history for v0.4-era installs with partial dbmate state.

  2. A single bridge migration per dialect (migrations//_
    ent_baseline.sql) transitions the dbmate-era schema to Ent's
    expected schema. SQLite + MySQL bridges are Atlas-generated;
    Postgres is hand-written (~30 lines of ALTER TABLE ... DROP
    DEFAULT / DROP SEQUENCE / ADD GENERATED) for the deliberate
    BIGSERIAL → IDENTITY modernization. v1 is the right cutover point
    for this modernization since the migration cost is bundled with
    the larger dbmate→Ent transition.

  3. Fresh installs (empty DB) skip the 14/8/8 dbmate-era files
    entirely. The adoption code in ncps migrate up invokes Ent's
    runtime Schema.Create(ctx, migrate.Tables...) to produce the
    end-state schema in one operation, then seeds schema_migrations
    with every version stamp from migrations// marked as
    is_applied=true. Goose subsequently sees nothing pending.

The invariant making this work: migrate.Tables and the set of files
under migrations// are kept in lockstep, enforced by §13 CI
checks (ent-codegen-drift-check + schema-equivalence-check).

Future incremental migrations work without code changes: existing
installs apply each new file via goose; fresh installs land directly
on the current end state via Schema.Create + seed all known versions.
A future "squash" change can delete the dbmate-era files once no
v0.x install is left in the wild.

Updates:

  • design.md D6 rewritten with the three-artifact framework, the
    adoption decision tree, long-term incremental flow, and the future
    squash plan. Rejected alternatives (A, C, D) documented with their
    reasons.
  • specs/database-migrations/spec.md gains four new requirements: the
    bridge migration, fresh-install Schema.Create + version seeding,
    incremental migrations via migrations:gen, and future-squash
    accommodation. The partial-dbmate-history scenario is expanded to
    cover the dbmate-era + bridge path explicitly.
  • specs/database-orm/spec.md gains a Schema.Create requirement
    pinning Ent's runtime Create as the canonical fresh-install path
    and asserting equivalence with the goose-applied schema.
  • tasks.md §8 expands from 5 to 7 sub-tasks covering bridge
    authorship per dialect (Atlas-auto for sqlite/mysql; hand-written
    for postgres) and the Schema.Create-vs-applied-migrations golden
    test. §9 expands from 12 to 14 sub-tasks adding the empty-DB
    fresh-install path, the version-stamp seeding step, and a 4-cell
    end-to-end test matrix covering fresh install, v0.4-era partial
    upgrade, dbmate-end-state upgrade, and post-upgrade incremental.

No code changes in this commit. Implementation lands in §8 and §9
next.

Summary by CodeRabbit

  • Documentation
    • Updated database migration design and specifications to define a comprehensive reconciliation strategy for schema adoption across fresh and existing installations.
    • Expanded migration workflow documentation with detailed decision trees and per-dialect bridge migration requirements.
    • Clarified schema-equivalence validation and fresh-install setup procedures in migration specifications.

Review Change Stack

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 20, 2026
@kalbasit

kalbasit commented May 20, 2026 •

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the database migration strategy to 'Option E', which utilizes translated history, a bridge migration, and Ent's Schema.Create for fresh installs. The changes include detailed adoption logic for different database states and requirements for schema equivalence testing. Review feedback highlights the need to reconcile contradictory text in the design document, synchronize PostgreSQL sequences during identity column conversion to prevent primary key collisions, and use dialect-appropriate timestamp functions instead of NOW() for SQLite compatibility. Additionally, it was suggested to enhance the migration state-detection probe to handle recovery from partial fresh installs.

kalbasit added a commit that referenced this pull request May 22, 2026
Five comments on the Option E docs PR:

- PRRT_kwDONV6tZs6DolgE (HIGH): the renamed D6 section introduced a
  contradiction — the legacy adoption sub-sections still said
  "Table doesn't exist → fresh install. Goose creates
  schema_migrations and runs all translated migrations from scratch"
  but Option E handles fresh installs via Schema.Create. Removed
  the contradictory "Table doesn't exist" branches from the
  SQLite/Postgres and MySQL adoption sub-sections and clarified
  that those sub-sections describe the *table-conversion mechanic*
  for the dbmate-shape branch only; the empty-DB case is handled
  by the higher-level Schema.Create path.

- PRRT_kwDONV6tZs6DolgG (HIGH): the BIGSERIAL → IDENTITY conversion
  on Postgres needs sequence sync (setval past max(id)) or the new
  IDENTITY starts at 1 and the first post-bridge INSERT collides.
  The actual hand-written
  20260520212038_postgres_serial_to_identity.sql already does this
  — the doc was just incomplete. Added the explanation.

- PRRT_kwDONV6tZs6DolgM / PRRT_kwDONV6tZs6DolgS: replaced bare
  references to `NOW()` with "the dialect-appropriate function or a
  Go-side time.Now() value" since SQLite uses CURRENT_TIMESTAMP not
  NOW().

- PRRT_kwDONV6tZs6DolgZ: noted the partial-fresh crash recovery
  scenario in tasks.md as a known edge case deferred to follow-up.
  Currently if Schema.Create succeeds but version seeding crashes,
  Detect returns ErrCorruptState. Adding a StatePartialFresh would
  improve robustness but the same DB shape can arise from genuine
  corruption / manual operator actions; auto-recovery would mask
  those. For v1, refusing to adopt is the safer default.
@kalbasit
kalbasit force-pushed the feat-cmd-add-generate-migrations branch from b627978 to 6f35d8c Compare May 22, 2026 15:03
@kalbasit
kalbasit force-pushed the docs-openspec-adopt-option-e-for branch from 6f1453d to edb1683 Compare May 22, 2026 15:03
kalbasit added a commit that referenced this pull request May 22, 2026
Five comments on the Option E docs PR:

- PRRT_kwDONV6tZs6DolgE (HIGH): the renamed D6 section introduced a
  contradiction — the legacy adoption sub-sections still said
  "Table doesn't exist → fresh install. Goose creates
  schema_migrations and runs all translated migrations from scratch"
  but Option E handles fresh installs via Schema.Create. Removed
  the contradictory "Table doesn't exist" branches from the
  SQLite/Postgres and MySQL adoption sub-sections and clarified
  that those sub-sections describe the *table-conversion mechanic*
  for the dbmate-shape branch only; the empty-DB case is handled
  by the higher-level Schema.Create path.

- PRRT_kwDONV6tZs6DolgG (HIGH): the BIGSERIAL → IDENTITY conversion
  on Postgres needs sequence sync (setval past max(id)) or the new
  IDENTITY starts at 1 and the first post-bridge INSERT collides.
  The actual hand-written
  20260520212038_postgres_serial_to_identity.sql already does this
  — the doc was just incomplete. Added the explanation.

- PRRT_kwDONV6tZs6DolgM / PRRT_kwDONV6tZs6DolgS: replaced bare
  references to `NOW()` with "the dialect-appropriate function or a
  Go-side time.Now() value" since SQLite uses CURRENT_TIMESTAMP not
  NOW().

- PRRT_kwDONV6tZs6DolgZ: noted the partial-fresh crash recovery
  scenario in tasks.md as a known edge case deferred to follow-up.
  Currently if Schema.Create succeeds but version seeding crashes,
  Detect returns ErrCorruptState. Adding a StatePartialFresh would
  improve robustness but the same DB shape can arise from genuine
  corruption / manual operator actions; auto-recovery would mask
  those. For v1, refusing to adopt is the safer default.
@kalbasit
kalbasit force-pushed the feat-cmd-add-generate-migrations branch from 6f35d8c to 7b36d2b Compare May 22, 2026 15:17
@kalbasit
kalbasit force-pushed the docs-openspec-adopt-option-e-for branch from edb1683 to 5634b25 Compare May 22, 2026 15:17
kalbasit added a commit that referenced this pull request May 22, 2026
Five comments on the Option E docs PR:

- PRRT_kwDONV6tZs6DolgE (HIGH): the renamed D6 section introduced a
  contradiction — the legacy adoption sub-sections still said
  "Table doesn't exist → fresh install. Goose creates
  schema_migrations and runs all translated migrations from scratch"
  but Option E handles fresh installs via Schema.Create. Removed
  the contradictory "Table doesn't exist" branches from the
  SQLite/Postgres and MySQL adoption sub-sections and clarified
  that those sub-sections describe the *table-conversion mechanic*
  for the dbmate-shape branch only; the empty-DB case is handled
  by the higher-level Schema.Create path.

- PRRT_kwDONV6tZs6DolgG (HIGH): the BIGSERIAL → IDENTITY conversion
  on Postgres needs sequence sync (setval past max(id)) or the new
  IDENTITY starts at 1 and the first post-bridge INSERT collides.
  The actual hand-written
  20260520212038_postgres_serial_to_identity.sql already does this
  — the doc was just incomplete. Added the explanation.

- PRRT_kwDONV6tZs6DolgM / PRRT_kwDONV6tZs6DolgS: replaced bare
  references to `NOW()` with "the dialect-appropriate function or a
  Go-side time.Now() value" since SQLite uses CURRENT_TIMESTAMP not
  NOW().

- PRRT_kwDONV6tZs6DolgZ: noted the partial-fresh crash recovery
  scenario in tasks.md as a known edge case deferred to follow-up.
  Currently if Schema.Create succeeds but version seeding crashes,
  Detect returns ErrCorruptState. Adding a StatePartialFresh would
  improve robustness but the same DB shape can arise from genuine
  corruption / manual operator actions; auto-recovery would mask
  those. For v1, refusing to adopt is the safer default.
@kalbasit
kalbasit force-pushed the feat-cmd-add-generate-migrations branch from 7b36d2b to b6ea721 Compare May 22, 2026 15:32
@kalbasit
kalbasit force-pushed the docs-openspec-adopt-option-e-for branch from 5634b25 to 79d3a6b Compare May 22, 2026 15:33
kalbasit added a commit that referenced this pull request May 22, 2026
Five comments on the Option E docs PR:

- PRRT_kwDONV6tZs6DolgE (HIGH): the renamed D6 section introduced a
  contradiction — the legacy adoption sub-sections still said
  "Table doesn't exist → fresh install. Goose creates
  schema_migrations and runs all translated migrations from scratch"
  but Option E handles fresh installs via Schema.Create. Removed
  the contradictory "Table doesn't exist" branches from the
  SQLite/Postgres and MySQL adoption sub-sections and clarified
  that those sub-sections describe the *table-conversion mechanic*
  for the dbmate-shape branch only; the empty-DB case is handled
  by the higher-level Schema.Create path.

- PRRT_kwDONV6tZs6DolgG (HIGH): the BIGSERIAL → IDENTITY conversion
  on Postgres needs sequence sync (setval past max(id)) or the new
  IDENTITY starts at 1 and the first post-bridge INSERT collides.
  The actual hand-written
  20260520212038_postgres_serial_to_identity.sql already does this
  — the doc was just incomplete. Added the explanation.

- PRRT_kwDONV6tZs6DolgM / PRRT_kwDONV6tZs6DolgS: replaced bare
  references to `NOW()` with "the dialect-appropriate function or a
  Go-side time.Now() value" since SQLite uses CURRENT_TIMESTAMP not
  NOW().

- PRRT_kwDONV6tZs6DolgZ: noted the partial-fresh crash recovery
  scenario in tasks.md as a known edge case deferred to follow-up.
  Currently if Schema.Create succeeds but version seeding crashes,
  Detect returns ErrCorruptState. Adding a StatePartialFresh would
  improve robustness but the same DB shape can arise from genuine
  corruption / manual operator actions; auto-recovery would mask
  those. For v1, refusing to adopt is the safer default.
@kalbasit
kalbasit force-pushed the feat-cmd-add-generate-migrations branch from b6ea721 to 5ab8fb8 Compare May 22, 2026 15:47
@kalbasit
kalbasit force-pushed the docs-openspec-adopt-option-e-for branch from 79d3a6b to 4501ffa Compare May 22, 2026 15:47
@coderabbitai

coderabbitai Bot commented May 22, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR expands the database migration design and specification for consolidating dbmate-era and Ent-managed schemas. It introduces a three-artifact per-dialect model (translated historical migrations, an ent_baseline bridge, and Ent Schema.Create), specifies fresh-install and adoption state machines, documents long-term incremental behavior, and includes concrete task breakdowns and equivalence tests.

Changes

Ent-Atlas Migration Consolidation

Layer / File(s) Summary
Reconciliation architecture and three-artifact model
openspec/changes/migrate-to-ent-and-atlas/design.md
Core design introduces three per-dialect artifacts: translated dbmate-era migrations, a new *_ent_baseline bridge migration (with weak-entity surrogate id and Postgres identity modernization), and Ent runtime Schema.Create for empty databases seeded with schema_migrations versions.
Bridge migration requirements and fresh-install seeding
openspec/changes/migrate-to-ent-and-atlas/specs/database-migrations/spec.md
Specifies per-dialect ent_baseline bridge migration (schema transitions, scenarios, idempotency) and fresh-install behavior via Ent Schema.Create. Covers partial dbmate-history adoption where remaining translated migrations apply before the bridge, preventing re-execution of already-recorded versions.
Canonical fresh-install schema source and equivalence contract
openspec/changes/migrate-to-ent-and-atlas/specs/database-orm/spec.md
Mandates Ent runtime NewMigrate(...).Create(..., migrate.Tables...) as canonical fresh-install path (prohibiting migrations/<dialect>/ replay), with schema equivalence to applying all dialect .sql migrations in timestamp order.
Adoption decision tree and implementation plan
openspec/changes/migrate-to-ent-and-atlas/design.md, openspec/changes/migrate-to-ent-and-atlas/tasks.md
Detailed ncps migrate up state machine covering empty DB, already-adopted, partially adopted, and unexpected states. Adds transactional steps per SQLite/Postgres and backup/recovery paths for MySQL. Replaces §8 task with per-dialect bridge generation and two equivalence tests (migration replay zero-diff and goose vs. Schema.Create byte-equivalence).
Post-v1 incremental behavior, squash plan, and alternative analysis
openspec/changes/migrate-to-ent-and-atlas/design.md
Defines forward-only incremental workflow ensuring both existing and fresh installs converge to byte-identical schemas and versions. Documents future squash plan for removing translated dbmate-era files once pre-v1 installs retire. Explicitly rejects three alternatives with failure analysis.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 From dbmate's past to Ent's bright future,
Three artifacts dance—migrations, bridge, and creator.
Fresh installs leap straight to schema perfection,
While old friends march through the baseline junction.
One converging path, byte-identical and true! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adopting Option E for dbmate-to-Ent schema reconciliation, which is precisely what all four updated files address.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs-openspec-adopt-option-e-for

Comment @coderabbitai help to get the list of available commands and usage tips.

kalbasit added a commit that referenced this pull request May 22, 2026
Five comments on the Option E docs PR:

- PRRT_kwDONV6tZs6DolgE (HIGH): the renamed D6 section introduced a
  contradiction — the legacy adoption sub-sections still said
  "Table doesn't exist → fresh install. Goose creates
  schema_migrations and runs all translated migrations from scratch"
  but Option E handles fresh installs via Schema.Create. Removed
  the contradictory "Table doesn't exist" branches from the
  SQLite/Postgres and MySQL adoption sub-sections and clarified
  that those sub-sections describe the *table-conversion mechanic*
  for the dbmate-shape branch only; the empty-DB case is handled
  by the higher-level Schema.Create path.

- PRRT_kwDONV6tZs6DolgG (HIGH): the BIGSERIAL → IDENTITY conversion
  on Postgres needs sequence sync (setval past max(id)) or the new
  IDENTITY starts at 1 and the first post-bridge INSERT collides.
  The actual hand-written
  20260520212038_postgres_serial_to_identity.sql already does this
  — the doc was just incomplete. Added the explanation.

- PRRT_kwDONV6tZs6DolgM / PRRT_kwDONV6tZs6DolgS: replaced bare
  references to `NOW()` with "the dialect-appropriate function or a
  Go-side time.Now() value" since SQLite uses CURRENT_TIMESTAMP not
  NOW().

- PRRT_kwDONV6tZs6DolgZ: noted the partial-fresh crash recovery
  scenario in tasks.md as a known edge case deferred to follow-up.
  Currently if Schema.Create succeeds but version seeding crashes,
  Detect returns ErrCorruptState. Adding a StatePartialFresh would
  improve robustness but the same DB shape can arise from genuine
  corruption / manual operator actions; auto-recovery would mask
  those. For v1, refusing to adopt is the safer default.
Base automatically changed from feat-cmd-add-generate-migrations to main May 22, 2026 16:01
The §8 schema-equivalence test exposed real schema drift between the
§7 translated dbmate-era migrations and Ent's expected schema:

- D10b structural: weak entities need a surrogate id PK column
- Postgres dialect: dbmate emitted BIGSERIAL; Ent emits BIGINT
  GENERATED BY DEFAULT AS IDENTITY (Atlas refuses to compute the diff
  as an "unexpected attribute change")
- Cosmetic: index and CHECK constraint naming differs between dbmate
  and Ent's defaults

Refines design D6 to capture Option E (three artifacts + decision
tree):

1. Translated dbmate-era files stay in the repo as the compatibility
   history for v0.4-era installs with partial dbmate state.

2. A single bridge migration per dialect (migrations/<dialect>/<ts>_
   ent_baseline.sql) transitions the dbmate-era schema to Ent's
   expected schema. SQLite + MySQL bridges are Atlas-generated;
   Postgres is hand-written (~30 lines of ALTER TABLE ... DROP
   DEFAULT / DROP SEQUENCE / ADD GENERATED) for the deliberate
   BIGSERIAL → IDENTITY modernization. v1 is the right cutover point
   for this modernization since the migration cost is bundled with
   the larger dbmate→Ent transition.

3. Fresh installs (empty DB) skip the 14/8/8 dbmate-era files
   entirely. The adoption code in `ncps migrate up` invokes Ent's
   runtime Schema.Create(ctx, migrate.Tables...) to produce the
   end-state schema in one operation, then seeds schema_migrations
   with every version stamp from migrations/<dialect>/ marked as
   is_applied=true. Goose subsequently sees nothing pending.

The invariant making this work: migrate.Tables and the set of files
under migrations/<dialect>/ are kept in lockstep, enforced by §13 CI
checks (ent-codegen-drift-check + schema-equivalence-check).

Future incremental migrations work without code changes: existing
installs apply each new file via goose; fresh installs land directly
on the current end state via Schema.Create + seed all known versions.
A future "squash" change can delete the dbmate-era files once no
v0.x install is left in the wild.

Updates:
- design.md D6 rewritten with the three-artifact framework, the
  adoption decision tree, long-term incremental flow, and the future
  squash plan. Rejected alternatives (A, C, D) documented with their
  reasons.
- specs/database-migrations/spec.md gains four new requirements: the
  bridge migration, fresh-install Schema.Create + version seeding,
  incremental migrations via migrations:gen, and future-squash
  accommodation. The partial-dbmate-history scenario is expanded to
  cover the dbmate-era + bridge path explicitly.
- specs/database-orm/spec.md gains a Schema.Create requirement
  pinning Ent's runtime Create as the canonical fresh-install path
  and asserting equivalence with the goose-applied schema.
- tasks.md §8 expands from 5 to 7 sub-tasks covering bridge
  authorship per dialect (Atlas-auto for sqlite/mysql; hand-written
  for postgres) and the Schema.Create-vs-applied-migrations golden
  test. §9 expands from 12 to 14 sub-tasks adding the empty-DB
  fresh-install path, the version-stamp seeding step, and a 4-cell
  end-to-end test matrix covering fresh install, v0.4-era partial
  upgrade, dbmate-end-state upgrade, and post-upgrade incremental.

No code changes in this commit. Implementation lands in §8 and §9
next.
@kalbasit
kalbasit force-pushed the docs-openspec-adopt-option-e-for branch from 4501ffa to 1239e34 Compare May 22, 2026 16:02
kalbasit added a commit that referenced this pull request May 22, 2026
Five comments on the Option E docs PR:

- PRRT_kwDONV6tZs6DolgE (HIGH): the renamed D6 section introduced a
  contradiction — the legacy adoption sub-sections still said
  "Table doesn't exist → fresh install. Goose creates
  schema_migrations and runs all translated migrations from scratch"
  but Option E handles fresh installs via Schema.Create. Removed
  the contradictory "Table doesn't exist" branches from the
  SQLite/Postgres and MySQL adoption sub-sections and clarified
  that those sub-sections describe the *table-conversion mechanic*
  for the dbmate-shape branch only; the empty-DB case is handled
  by the higher-level Schema.Create path.

- PRRT_kwDONV6tZs6DolgG (HIGH): the BIGSERIAL → IDENTITY conversion
  on Postgres needs sequence sync (setval past max(id)) or the new
  IDENTITY starts at 1 and the first post-bridge INSERT collides.
  The actual hand-written
  20260520212038_postgres_serial_to_identity.sql already does this
  — the doc was just incomplete. Added the explanation.

- PRRT_kwDONV6tZs6DolgM / PRRT_kwDONV6tZs6DolgS: replaced bare
  references to `NOW()` with "the dialect-appropriate function or a
  Go-side time.Now() value" since SQLite uses CURRENT_TIMESTAMP not
  NOW().

- PRRT_kwDONV6tZs6DolgZ: noted the partial-fresh crash recovery
  scenario in tasks.md as a known edge case deferred to follow-up.
  Currently if Schema.Create succeeds but version seeding crashes,
  Detect returns ErrCorruptState. Adding a StatePartialFresh would
  improve robustness but the same DB shape can arise from genuine
  corruption / manual operator actions; auto-recovery would mask
  those. For v1, refusing to adopt is the safer default.
@kalbasit
kalbasit enabled auto-merge (squash) May 22, 2026 16:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (1)
openspec/changes/migrate-to-ent-and-atlas/tasks.md (1)

82-83: ⚡ Quick win

Make schema-equivalence assertions deterministic.

Line 83 says “byte-equivalence” via catalog introspection, but this is prone to ordering/collation noise across engines unless canonicalization is specified. Add an explicit normalization rule (stable sort/order + normalized metadata projection) before comparing so CI failures reflect real drift only.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openspec/changes/migrate-to-ent-and-atlas/tasks.md` around lines 82 - 83, The
tests TestSchemaEquivalence and TestSchemaCreateMatchesAppliedMigrations
currently compare introspected catalog metadata byte-for-byte; make these
comparisons deterministic by adding a canonicalization step: for the
introspection results (tables, columns, indexes, constraints) produced when
calling migrate.Tables and when introspecting DB-A/DB-B (and before writing temp
diffs or asserting byte-equivalence in TestSchemaEquivalence and
TestSchemaCreateMatchesAppliedMigrations), project only the normalized metadata
fields you care about and apply a stable sort (e.g., sort tables by name,
columns by (table,name,ordinal), indexes/constraints by a stable key) and
normalize textual fields (case/collation, default formatting) so both sides are
comparably ordered and formatted before doing the byte/equality assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@openspec/changes/migrate-to-ent-and-atlas/design.md`:
- Line 154: The phrasing "requires named CHECKs" is unclear; update the sentence
that describes Ent's invariant A1 to say "requires CHECK constraints to be
named" for grammatical clarity. Locate the sentence in the paragraph discussing
"Schema overrides to match dbmate exactly (option D)" and replace the fragment
referencing "Ent's invariant A1 requires named CHECKs" with "Ent's invariant A1
requires CHECK constraints to be named", keeping the surrounding mentions of
SchemaType, StorageKey, and dbmate anonymous CHECK constraints unchanged.
- Around line 101-105: The doc and design disagree on the migrations tracking
table name (the design text uses schema_migrations while D3/spec uses
ncps_schema_versions); pick a single canonical name and make all references
consistent—update the prose around Schema.Create, entSchema.NewMigrate,
migrate.Tables and the “ncps migrate up” flow to use that canonical name, and
adjust the D3/spec and any tests/fixtures that mention ncps_schema_versions (or
vice‑versa) so the CI checks (ent-codegen-drift-check and schema-equivalence
golden test) and the seeding step that writes is_applied=true,tstamp=NOW()
target the same table name everywhere.
- Around line 108-130: The fenced decision-tree block currently has an empty
language tag (```), causing MD040; update the opening fence to include a
language identifier by replacing the opening triple backticks with ```text so
the block begins with ```text and the closing fence remains ``` (i.e., change
``` → ```text for the decision-tree block shown in the diff).

In `@openspec/changes/migrate-to-ent-and-atlas/specs/database-migrations/spec.md`:
- Around line 107-114: The spec must explicitly ensure the Goose tracking table
exists before seeding; update the migrate-up flow so that after calling
entSchema.NewMigrate(drv).Create(ctx, migrate.Tables...) the code invokes a step
to create or ensure the Goose/`schema_migrations` table (e.g., call the Goose
helper that ensures the version table or run a DDL `CREATE TABLE IF NOT EXISTS
schema_migrations ...`) and only then enumerate `migrations.FS` files, parse
timestamps, and insert rows with `is_applied=true` and `tstamp=NOW()` so
subsequent Goose invocations report zero pending migrations.
- Around line 105-115: The spec contains contradictory expectations about fresh
installs: one section requires using Ent's Schema.Create
(entSchema.NewMigrate(drv).Create(...)) and seeding schema_migrations from
migrations.FS, while an earlier "Fresh install" scenario still mandates
replaying translated Goose migrations; pick one canonical behavior and update
the document accordingly. Change the earlier "Scenario: Fresh install" to match
the later "Requirement: Fresh installs skip the dbmate-era history via
Schema.Create" by specifying that on empty DB at `migrate up` the implementation
must call entSchema.NewMigrate(drv).Create(ctx, migrate.Tables...) and then
enumerate migrations.FS to insert is_applied=true rows into schema_migrations
(tstamp=NOW()), and remove any language that requires replaying translated
Goose/dbmate migrations so all test scenarios reference the same flow.

In `@openspec/changes/migrate-to-ent-and-atlas/specs/database-orm/spec.md`:
- Around line 76-83: Replace the ambiguous "no `schema_migrations` row"
fresh-install predicate with a table-shape/existence based check: require that
the database has no application tables and that the `schema_migrations` table
either does not exist or does not match the expected schema/shape (so the
installer treats it as absent); keep the behavior that on this fresh-install
condition the system calls entSchema.NewMigrate(drv).Create(ctx,
migrate.Tables...) and does not execute files under migrations/<dialect>/, and
update the spec language around entSchema.NewMigrate, migrate.Tables and the
fresh-install scenario to reference table existence/shape rather than row
absence.

In `@openspec/changes/migrate-to-ent-and-atlas/tasks.md`:
- Around line 92-94: Detect and recover a MySQL "fresh-install partial failure"
where entSchema.NewMigrate(drv).Create(...) succeeded but seeding
schema_migrations from migrations.FS failed: implement a detection branch that
checks for present schema (e.g. Schema.Create/entSchema.NewMigrate success) plus
missing or incomplete rows in schema_migrations and treat it as a recovery state
(similar to S4/S5); for MySQL perform an idempotent recovery that inserts the
parsed 14-char timestamps from migrations/<dialect>/ into schema_migrations with
is_applied=true and tstamp=NOW() in a single multi-row INSERT (or
rollback/cleanup if unrecoverable), add unit/integration tests that simulate DDL
success then seeding failure and verify migrate up performs the recovery and
leaves schema_migrations consistent, and update the migrate up flow to call this
recovery branch before attempting normal migrations.

---

Nitpick comments:
In `@openspec/changes/migrate-to-ent-and-atlas/tasks.md`:
- Around line 82-83: The tests TestSchemaEquivalence and
TestSchemaCreateMatchesAppliedMigrations currently compare introspected catalog
metadata byte-for-byte; make these comparisons deterministic by adding a
canonicalization step: for the introspection results (tables, columns, indexes,
constraints) produced when calling migrate.Tables and when introspecting
DB-A/DB-B (and before writing temp diffs or asserting byte-equivalence in
TestSchemaEquivalence and TestSchemaCreateMatchesAppliedMigrations), project
only the normalized metadata fields you care about and apply a stable sort
(e.g., sort tables by name, columns by (table,name,ordinal), indexes/constraints
by a stable key) and normalize textual fields (case/collation, default
formatting) so both sides are comparably ordered and formatted before doing the
byte/equality assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5ac1d5b5-1266-48a0-8c8a-83639da0b833

📥 Commits

Reviewing files that changed from the base of the PR and between bdff9ba and 1239e34.

📒 Files selected for processing (4)
  • openspec/changes/migrate-to-ent-and-atlas/design.md
  • openspec/changes/migrate-to-ent-and-atlas/specs/database-migrations/spec.md
  • openspec/changes/migrate-to-ent-and-atlas/specs/database-orm/spec.md
  • openspec/changes/migrate-to-ent-and-atlas/tasks.md

@codecov

codecov Bot commented May 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 5.04%. Comparing base (bdff9ba) to head (1239e34).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1186   +/-   ##
=====================================
  Coverage   5.04%   5.04%           
=====================================
  Files          6       6           
  Lines        436     436           
=====================================
  Hits          22      22           
  Misses       410     410           
  Partials       4       4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kalbasit
kalbasit merged commit a12c5ab into main May 22, 2026
17 checks passed
@kalbasit
kalbasit deleted the docs-openspec-adopt-option-e-for branch May 22, 2026 16:15
kalbasit added a commit that referenced this pull request May 22, 2026
Five comments on the Option E docs PR:

- PRRT_kwDONV6tZs6DolgE (HIGH): the renamed D6 section introduced a
  contradiction — the legacy adoption sub-sections still said
  "Table doesn't exist → fresh install. Goose creates
  schema_migrations and runs all translated migrations from scratch"
  but Option E handles fresh installs via Schema.Create. Removed
  the contradictory "Table doesn't exist" branches from the
  SQLite/Postgres and MySQL adoption sub-sections and clarified
  that those sub-sections describe the *table-conversion mechanic*
  for the dbmate-shape branch only; the empty-DB case is handled
  by the higher-level Schema.Create path.

- PRRT_kwDONV6tZs6DolgG (HIGH): the BIGSERIAL → IDENTITY conversion
  on Postgres needs sequence sync (setval past max(id)) or the new
  IDENTITY starts at 1 and the first post-bridge INSERT collides.
  The actual hand-written
  20260520212038_postgres_serial_to_identity.sql already does this
  — the doc was just incomplete. Added the explanation.

- PRRT_kwDONV6tZs6DolgM / PRRT_kwDONV6tZs6DolgS: replaced bare
  references to `NOW()` with "the dialect-appropriate function or a
  Go-side time.Now() value" since SQLite uses CURRENT_TIMESTAMP not
  NOW().

- PRRT_kwDONV6tZs6DolgZ: noted the partial-fresh crash recovery
  scenario in tasks.md as a known edge case deferred to follow-up.
  Currently if Schema.Create succeeds but version seeding crashes,
  Detect returns ErrCorruptState. Adding a StatePartialFresh would
  improve robustness but the same DB shape can arise from genuine
  corruption / manual operator actions; auto-recovery would mask
  those. For v1, refusing to adopt is the safer default.
kalbasit added a commit that referenced this pull request May 22, 2026
Five comments on the Option E docs PR:

- PRRT_kwDONV6tZs6DolgE (HIGH): the renamed D6 section introduced a
  contradiction — the legacy adoption sub-sections still said
  "Table doesn't exist → fresh install. Goose creates
  schema_migrations and runs all translated migrations from scratch"
  but Option E handles fresh installs via Schema.Create. Removed
  the contradictory "Table doesn't exist" branches from the
  SQLite/Postgres and MySQL adoption sub-sections and clarified
  that those sub-sections describe the *table-conversion mechanic*
  for the dbmate-shape branch only; the empty-DB case is handled
  by the higher-level Schema.Create path.

- PRRT_kwDONV6tZs6DolgG (HIGH): the BIGSERIAL → IDENTITY conversion
  on Postgres needs sequence sync (setval past max(id)) or the new
  IDENTITY starts at 1 and the first post-bridge INSERT collides.
  The actual hand-written
  20260520212038_postgres_serial_to_identity.sql already does this
  — the doc was just incomplete. Added the explanation.

- PRRT_kwDONV6tZs6DolgM / PRRT_kwDONV6tZs6DolgS: replaced bare
  references to `NOW()` with "the dialect-appropriate function or a
  Go-side time.Now() value" since SQLite uses CURRENT_TIMESTAMP not
  NOW().

- PRRT_kwDONV6tZs6DolgZ: noted the partial-fresh crash recovery
  scenario in tasks.md as a known edge case deferred to follow-up.
  Currently if Schema.Create succeeds but version seeding crashes,
  Detect returns ErrCorruptState. Adding a StatePartialFresh would
  improve robustness but the same DB shape can arise from genuine
  corruption / manual operator actions; auto-recovery would mask
  those. For v1, refusing to adopt is the safer default.
kalbasit added a commit that referenced this pull request May 22, 2026
Five comments on the Option E docs PR:

- PRRT_kwDONV6tZs6DolgE (HIGH): the renamed D6 section introduced a
  contradiction — the legacy adoption sub-sections still said
  "Table doesn't exist → fresh install. Goose creates
  schema_migrations and runs all translated migrations from scratch"
  but Option E handles fresh installs via Schema.Create. Removed
  the contradictory "Table doesn't exist" branches from the
  SQLite/Postgres and MySQL adoption sub-sections and clarified
  that those sub-sections describe the *table-conversion mechanic*
  for the dbmate-shape branch only; the empty-DB case is handled
  by the higher-level Schema.Create path.

- PRRT_kwDONV6tZs6DolgG (HIGH): the BIGSERIAL → IDENTITY conversion
  on Postgres needs sequence sync (setval past max(id)) or the new
  IDENTITY starts at 1 and the first post-bridge INSERT collides.
  The actual hand-written
  20260520212038_postgres_serial_to_identity.sql already does this
  — the doc was just incomplete. Added the explanation.

- PRRT_kwDONV6tZs6DolgM / PRRT_kwDONV6tZs6DolgS: replaced bare
  references to `NOW()` with "the dialect-appropriate function or a
  Go-side time.Now() value" since SQLite uses CURRENT_TIMESTAMP not
  NOW().

- PRRT_kwDONV6tZs6DolgZ: noted the partial-fresh crash recovery
  scenario in tasks.md as a known edge case deferred to follow-up.
  Currently if Schema.Create succeeds but version seeding crashes,
  Detect returns ErrCorruptState. Adding a StatePartialFresh would
  improve robustness but the same DB shape can arise from genuine
  corruption / manual operator actions; auto-recovery would mask
  those. For v1, refusing to adopt is the safer default.
kalbasit added a commit that referenced this pull request May 22, 2026
docs(openspec): address PR #1178 review comments

Three review comments on design.md, all valid:

- Tracking-table name inconsistency (PRRT_kwDONV6tZs6DokBc): D5
  said `ncps_schema_versions` while D6 and the database-migrations
  spec said `schema_migrations`. The latter is the intended choice
  (preserves dbmate-era name for operator continuity). Updated D5.

- tstamp NULL → NOT NULL on the SQLite/Postgres adoption block
  (PRRT_kwDONV6tZs6DokBp): goose's actual Postgres dialect emits
  NOT NULL. Updated the design doc + adopt.go's adoptPostgresSteps
  to match.

- tstamp NULL → NOT NULL on the MySQL S3 adoption documentation
  (PRRT_kwDONV6tZs6DokBt): in modern MySQL (with
  explicit_defaults_for_timestamp=ON) the column is effectively
  NOT NULL anyway, so make the spec stricter and consistent.
  No impl change needed — createMySQLSchemaMigrations already uses
  NULL DEFAULT which functions identically.

All migrate-package tests pass under -race against all three
engines after the Postgres NOT NULL change.

fix(Taskfile): quote NAME variable to prevent shell injection

Two review comments on PR #1179 (PRRT_kwDONV6tZs6DolmP and
PRRT_kwDONV6tZs6DolmV): the `{{.NAME}}` template variable was
expanded unquoted into the shell command. Whitespace or shell
metacharacters in NAME would either misparse or open a small shell
injection surface. Wrap in double quotes.

The third comment on this PR (PRRT_kwDONV6tZs6DolmN: goose missing
from go.mod) was correct at the time of the commit but has since
been organically fixed — once §7's apply_test.go imported goose,
`go mod tidy` pulled it in as a direct dep. Resolved without code
change.

test(schema-parity): lowercase introspected names consistently

Two review comments on PR #1181:

- PRRT_kwDONV6tZs6DokIU (mustListTables): the MySQL/Postgres queries
  return table names in their stored case, which can drift from the
  lowercase expectedTables list under some MySQL configs. Lowercase
  on read, matching the column-introspection pattern.

- PRRT_kwDONV6tZs6DokIX (mustListColumns / SQLite branch): SQLite's
  PRAGMA table_info returns column names as-declared; the
  MySQL/Postgres branches already lowercase. Lowercase the SQLite
  branch too for consistency.

The third comment (PRRT_kwDONV6tZs6DokIM: use assert.ElementsMatch
for strict column-set equality instead of Contains) is rejected
with rationale: the same expectedColumns fixture is consumed by
TestSchemaParity (dbmate schema, exact match would work) AND
TestEntSchemaParity (Ent schema, which legitimately adds the
surrogate `id` columns on weak entities per design D10b). Strict
ElementsMatch would fail on TestEntSchemaParity for legitimate
reasons. Contains correctly models "the documented columns must
exist; extras are allowed".

fix(ent-schema): use Nillable for all optional time fields

Two review comments on PR #1182 (PRRT_kwDONV6tZs6DomHI,
PRRT_kwDONV6tZs6DomHL): nullable time fields in the generated Ent
structs were inconsistent — NarFile.ChunkingStartedAt used
sql.NullTime (which marshals as a JSON object), NarFile.LastAccessedAt
and NarInfo.LastAccessedAt used time.Time (which can't distinguish
NULL from the zero value).

Updated the schema source (ent/schema/nar_file.go,
ent/schema/narinfo.go) to chain .Nillable() on all three fields and
removed the now-unused GoType(sql.NullTime{}) override. Regenerated
the ent client.

All three nullable time fields now use *time.Time consistently, both
for JSON-correctness and for distinguishing NULL from zero. The
sqlc.yaml override that originally forced sql.NullTime is no longer
needed (sqlc tree is removed in §12 cleanup).

Tests pass across all three engines under -race.

fix(ent-lint): skip top-level helpers and unparseable edge targets

Four review comments on PR #1183 (PRRT_kwDONV6tZs6Dont7,
PRRT_kwDONV6tZs6DonuJ, PRRT_kwDONV6tZs6DonuN, PRRT_kwDONV6tZs6DonuR):

Three of them point out that checkA1, checkA2, and checkA4 iterate
methods named Fields/Edges but don't verify the function has a
receiver. If a future ent/schema/ file ever contains a top-level
helper function with one of those names, the linter would
incorrectly attribute its body to a non-existent schema. Skip
methods whose receiverTypeName is empty.

The fourth points out that checkA4 was constructing edgeTo entries
even when typeRefName returned "" (the edge target isn't a simple
T.Type expression — e.g. a more complex Ent invocation we don't
model). The resulting empty-target entry would produce confusing
failure messages downstream. Skip the edge in that case.

ent-lint passes against the live ent/schema/ tree; the fixture-based
unit tests pass under -race.

fix(migrations): goose-correct SQLite PRAGMA + MySQL InnoDB defaults

Three review comments on PR #1184:

- PRRT_kwDONV6tZs6DojlB (HIGH): the translated SQLite migration
  20260127223000_allow_multiple_nar_representations.sql uses the
  PRAGMA foreign_keys = OFF / DROP TABLE / RENAME pattern to swap
  the nar_files table. SQLite ignores PRAGMA foreign_keys inside a
  transaction, and goose wraps migrations in a transaction by
  default — so against any data already in narinfo_nar_files, the
  DROP TABLE would fail. Added `-- +goose NO TRANSACTION` plus a
  comment explaining why. Same fix applied to the ent_baseline
  bridge migration (20260520212039_ent_baseline.sql) which also
  uses PRAGMA + table swaps.

- PRRT_kwDONV6tZs6DojlH: 20260131021850_add_chunks.sql for MySQL
  was missing the ENGINE/CHARSET/COLLATE clauses that
  20260101000000_init_schema.sql sets. Without them the tables
  would inherit server defaults that may not be InnoDB +
  utf8mb4_unicode_ci. Added the clauses to both CREATE TABLE
  statements.

- PRRT_kwDONV6tZs6DojlK: the SQLite Down migration in
  20260301000000_add_verified_at_to_nar_files.sql used a fragile
  full-table-swap pattern that required manually maintaining the
  column list. Replaced with the much simpler
  `ALTER TABLE nar_files DROP COLUMN verified_at` (supported by the
  project's go-sqlite3 v1.14.x). This also removes another
  PRAGMA-inside-transaction usage. Down migrations aren't supported
  per design D10, but the cleanup keeps the file honest.

atlas.sum regenerated for all three dialects. All tests pass under
-race across SQLite, PostgreSQL, and MySQL.

Note: the Postgres create_test_db helper function disappeared again
during the test run (this is the third time this session); reinstalled
manually before re-running. May want to investigate why the deps
init isn't sticky between runs.

fix(generate-migrations): use migrate.Tables as source of truth

Review comment on PR #1185 (PRRT_kwDONV6tZs6DonIx): the resetDevDB
helper hardcoded the list of ncps tables to drop before each
migration-generation run. If a future entity is added to ent/schema/
the hardcoded list would silently drift, leaving stale tables in
the dev DB and corrupting the diff.

Switched to enumerating migrate.Tables (already imported in this
file) and appending schema_migrations explicitly. Also restructured
the dialect switch to handle "postgres" explicitly and error on
unknown dialects, so adding a new engine to the loop won't silently
fall through to no-op behavior.

cmd/generate-migrations tests pass; the smoke test verifies the
generator still produces zero diff against the current
schemas/migrations state.

docs(openspec): address PR #1186 review comments

Five comments on the Option E docs PR:

- PRRT_kwDONV6tZs6DolgE (HIGH): the renamed D6 section introduced a
  contradiction — the legacy adoption sub-sections still said
  "Table doesn't exist → fresh install. Goose creates
  schema_migrations and runs all translated migrations from scratch"
  but Option E handles fresh installs via Schema.Create. Removed
  the contradictory "Table doesn't exist" branches from the
  SQLite/Postgres and MySQL adoption sub-sections and clarified
  that those sub-sections describe the *table-conversion mechanic*
  for the dbmate-shape branch only; the empty-DB case is handled
  by the higher-level Schema.Create path.

- PRRT_kwDONV6tZs6DolgG (HIGH): the BIGSERIAL → IDENTITY conversion
  on Postgres needs sequence sync (setval past max(id)) or the new
  IDENTITY starts at 1 and the first post-bridge INSERT collides.
  The actual hand-written
  20260520212038_postgres_serial_to_identity.sql already does this
  — the doc was just incomplete. Added the explanation.

- PRRT_kwDONV6tZs6DolgM / PRRT_kwDONV6tZs6DolgS: replaced bare
  references to `NOW()` with "the dialect-appropriate function or a
  Go-side time.Now() value" since SQLite uses CURRENT_TIMESTAMP not
  NOW().

- PRRT_kwDONV6tZs6DolgZ: noted the partial-fresh crash recovery
  scenario in tasks.md as a known edge case deferred to follow-up.
  Currently if Schema.Create succeeds but version seeding crashes,
  Detect returns ErrCorruptState. Adding a StatePartialFresh would
  improve robustness but the same DB shape can arise from genuine
  corruption / manual operator actions; auto-recovery would mask
  those. For v1, refusing to adopt is the safer default.

test(migrate): robust mysql DSN + MkdirAll in copyMigrations

Two review comments on PR #1187:

- PRRT_kwDONV6tZs6DooEC: the hand-rolled mysqlURLToDSN concatenated
  user/password/host/db into a DSN string, which breaks if the
  password contains `:` or `@`. Switched both copies of the helper
  (migrations/equivalence_test.go and
  pkg/database/migrate/migrate_test.go) to use
  mysqldriver.NewConfig, which handles escaping correctly. Also
  promotes parseTime / loc / multiStatements to proper Config
  fields when they're not already set in the URL params.

- PRRT_kwDONV6tZs6DooEF: copyMigrations in equivalence_test.go used
  os.Create directly, which would fail if a future migrations
  layout introduced subdirectories. Added MkdirAll on the target
  file's parent directory. Today the layout is flat so this is a
  no-op, but the helper is now robust to a future refactor.

Migrations + migrate-package tests pass under -race.

fix(migrate): idiomatic rollback + dynamic appTables + io.Writer plan

Six review comments on PR #1188, all valid:

- PRRT_kwDONV6tZs6DonwL (adopt.go): replace manual `rollback()` calls
  on every error path with a single `defer tx.Rollback()`. The
  deferred call is a no-op after a successful Commit, and the
  pattern is robust to future early-return paths.

- PRRT_kwDONV6tZs6DonwR + PRRT_kwDONV6tZs6DonwW (state.go): the
  hardcoded `appTables` list would drift from the Ent schema as
  entities are added. Switched to populating it at init() from
  `entmigrate.Tables`, matching the same approach we applied to
  cmd/generate-migrations in PR #1185's fix.

- PRRT_kwDONV6tZs6Donwa + PRRT_kwDONV6tZs6Donwc +
  PRRT_kwDONV6tZs6Donwd (ncps/migrate.go): `printPlan` hardcoded
  `os.Stdout`. Updated to take an `io.Writer` (testable + respects
  the cli.Command's configured Writer) and the caller passes
  `cmd.Writer` (falling back to `os.Stdout` if unset).

All migrate-package + ncps tests pass under -race across all three
engines.
kalbasit added a commit that referenced this pull request May 24, 2026
…1251)

## Summary

Consolidation branch addressing unresolved reviewer threads left open
across
merged PRs #1179–#1246. Each fix has its own atomic commit referencing
the
source PR and thread ID; all threads are resolved on GitHub after each
change.

### Bug fixes

- **cache:** touch `nar_file` by fetched row ID, not by narURL fields —
`getNarFileFromDB` can return a `compression=none` fallback whose key
differs
from `narURL`, causing stale `last_accessed_at` and LRU regressions
(#1206)
- **cache:** fail fast on `nil` eager-loaded chunk edges in
`streamCompleteChunks`
and `streamProgressiveChunks` instead of silently `continue`-ing, which
caused
  count mismatches or infinite re-streaming (#1207)
- **cache:** include `narURLsToRemove` in the LRU early-return guard so
orphaned
`NarFile` blobs are passed to `parallelDeleteFromStores` instead of
being
  silently leaked in storage (#1215)
- **cache:** log a warning when LRU candidate fetch hits the
`maxFetchRows` cap
  so operators know eviction scanned only a partial window (#1206)
- **cache/relink:** lower `relinkBatchSize` from 500 → 499 to stay under
SQLite's 999-placeholder limit (500 rows × 2 binds = 1000 > 999) (#1208)
- **database:** close `*sql.DB` in `Open()` when `NewClient` fails
(#1208)
- **migrate/adopt:** use `ErrUnknownState` (not `ErrUnknownDialect`) for
unrecognised `State` values — fixes false-positive `errors.Is` checks
(#1188)
- **generate-migrations:** `parseSkip` validates dialect names,
returning an error
on unknown values like `"myslq"` instead of silently skipping them
(#1187)
- **generate-migrations:** `--sql-only` path now calls `ensureAtlasSum`
after
  writing the stub so `atlas.sum` stays in sync (#1187)
- **generate-migrations:** `runDialect` now returns the generated file
path and
prints it to stdout; `main()` warns when a second boundary falls between
dialect runs so callers know to re-run for a consistent timestamp set
(#1215)
- **generate-migrations:** add `"empty"` to `validateName` reject list
(#1185)
- **nix/ent-lint-check:** add `set -o pipefail` so `ent-lint | tee`
propagates
  a non-zero exit through the pipeline (#1221)
- **e2e:** fix docstring path (`var/ncps/e2e-results/` →
`.e2e-results/`);
`mc mb` and `redis-cli flushall` now use `check=True` so reset failures
  abort the test immediately (#1233)
- **e2e:** `stop_ncps` now verifies the port closes within timeout;
`wait_ready`
  exits early if the child process dies before becoming ready (#1233)
- **run.py:** guard `dbmate` usage with a `shutil.which` check so a
missing
binary fails fast with a clear message instead of an obscure error
(#1234)
- **CI:** pin all external GitHub Action refs to immutable commit SHAs
to
  prevent supply-chain mutation (#1223)
- **CI:** remove `release-*` from pull_request/push triggers; add
`go.mod` and
  `go.sum` to the ent paths-filter (#1235)
- **docs:** replace distroless-incompatible `wget` healthcheck in Docker
Compose
  example with `garage status` (#1223)

### Test fixes

- Replace non-fatal `assert.Len` → `require.Len` before indexing
`stamps[0..2]`
  in `generate-migrations` tests (#1185)
- Add 60 s timeout to the one-time `go build` in the test setup (#1241)
- Fix `cache_prefetch_test.go` to look up `nar_file` by `(hash,
compression,
  query)` instead of hard-coded `id=1` (#1218)
- Apply `NarSize` fallback when `FileSize == 0` in
`testhelper/sqlite.go` to
avoid impossible `file_size=0` fixture rows for `compression=none`
narinfos (#1218)
- Increase `chunkingDelay` from 500 ms → 1 s in `cdc_test.go` to reduce
  flakiness on slow CI machines (#1217)
- Replace `Lock`-with-timeout with `TryLock` in
`cache_distributed_test.go` to
  avoid spurious failures when the lock-hold window is tight (#1217)

### Docs / skills

- Quote PostgreSQL DSNs in shell-command examples to prevent `?`-glob
expansion
  by shells (#1234)
- `migrate-new/SKILL.md`: ent-lint checks A1, A2, A4 — not all five
invariants
  as previously stated (#1225)
- `migrate-down/SKILL.md`: clarify that `DROP COLUMN` is
sensitive/forbidden DDL
per the migration spec and is only permissible as the terminal
expand-contract
step; add the missing "deploy code that always writes non-null" step to
the
  NOT NULL recipe (#1225)
- `openspec/changes/archive/2026-05-23-less-tests/`: fix stale paths,
add `bash`
fence tag, replace "branch coverage" with "statement/block coverage"
(#1245)
- `openspec/specs/test-suite-efficiency/spec.md`: same coverage
terminology
  fix (#1245)
-
`openspec/changes/archive/2026-05-21-migrate-to-ent-and-atlas/design.md`:
  add language tag to decision-tree fence block; fix grammar (#1186)
-
`openspec/changes/archive/2026-05-21-migrate-to-ent-and-atlas/tasks.md`:
update §10.1/§11.1 notes to reflect that `*database.Client` threading
was
  completed in §11, not deferred (#1191, #1192)

## Test plan

- [x] `nix flake check` (includes all unit + integration tests, lint,
ent-lint,
  atlas-sum, helm-unittest, schema-equivalence)
- [x] `go test -race ./...` locally with `eval
"$(enable-integration-tests)"`
- [x] Verify all referenced GitHub threads are marked resolved

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation merge-stack size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant