Skip to content

Delete migration logic the zero-users rule prohibits: unused MigrationRegistry and a completed schema-description backfill #2389

Closed

Description

@malibio

Problem

CLAUDE.md is unambiguous: no migration strategies, no transition periods, no backward compatibility — NodeSpace has zero users and the database can be reset at any time. Migration logic exists anyway, in two forms that should not, plus one that is legitimate and must stay.

This is maintenance tax on a guarantee the project explicitly does not offer.

What exists

1. MigrationRegistry — 531 lines, never used

packages/core/src/services/migration_registry.rs. Lazy node-migration infrastructure: _schema_version tracking, v1→v2→v3 transform chaining, per-node upgrade on access.

No transform is ever registered. MigrationRegistry::new() is constructed at node_service/mod.rs:924, stored at :807, cloned at :877, threaded into NodeService at :1027 — and the only register_migration calls anywhere outside the registry's own unit tests are commented out in a doc example (services/migrations/mod.rs:19-20).

services/mod.rs:9 labels it accurately: "Schema migration infrastructure (for future use)". It is dead weight that can never fire, and it drags a field through NodeService's construction and clone paths.

Delete the module, its services/migrations/ companion, the NodeService field, and the re-exports at services/mod.rs:188.

2. backfill_schema_description_subtrees — a real migration, already complete

packages/core/src/services/node_service/mod.rs:1627. Migrates schema descriptions from a legacy properties.description string to a child-node subtree (so they are embedded and semantically discoverable).

Added in #1354 (28c66eb9, 2026-06-06), whose commit message names it directly: "NodeService startup: backfill migration for existing schemas with properties.description." A follow-up commit in the same PR reads "Fix backfill idempotency" — so it was reviewed, and the review improved the migration rather than questioning whether one should exist.

It is also already complete everywhere it can run: on a clean v0.2.7 install, 0 of 19 schemas carry a legacy properties.description. The function runs at every startup, finds nothing, and returns.

Its only remaining reachable behaviour is a bug that compounds. bulk_create_hierarchy failing at :1697 is handled correctly (warn, continue, trigger intact, retried next startup). But remove_property_key failing at :1708 warns and then falls through, incrementing backfilled: the subtree is written, the trigger stays set, and the next startup writes another subtree. Every duplicate feeds the schema's embedding, so semantic search for that type degrades per failed startup.

Delete the function and its startup call. (A dedupe guard was proposed in the atomicity work; deleting is the smaller change and the one consistent with the project's rules.)

3. db/migrations/ — legitimate, keep

packages/core/src/db/migrations/ (v001–v004) is not the kind of migration the rule prohibits. It is the SQL schema bootstrap: migrations::run(conn) at db/sqlite_store/mod.rs:186 is how a database gets its tables at all — v001 alone creates 13 tables/indexes. backup_before_pending_migrations (:156) and run_up_to (:444) are part of that machinery.

A fresh database needs its schema created, and a versioned bootstrap is a reasonable way to express that. Do not remove this. If anything it is worth a comment distinguishing it from the prohibited kind, since the shared word "migration" is what makes the two easy to conflate.

Why this happened, and the prevention half

Worth addressing beyond the deletion, since the rule was in force the whole time and did not fire at authoring or review.

The plausible reason: CLAUDE.md's prohibition reads as being about product compatibility — don't support old NodeSpace versions, don't do phased rollouts. A change to an internal data shape feels like a different category to whoever is mid-change, so "how do existing databases get the new shape?" surfaces as a legitimate engineering question rather than a prohibited one. It is not a different category; a startup backfill for an old format is exactly what the rule forbids.

The rule also states a prohibition without an alternative. Under zero users the alternative is simply: change the format and reset the database. Saying so explicitly gives an author something to reach for instead of writing a backfill.

  • CLAUDE.md's no-migration rule names internal data-shape changes explicitly, not just product/version compatibility
  • It states what to do instead — change the format, reset the database — rather than only what not to do
  • It distinguishes the prohibited kind from the legitimate SQL schema bootstrap in db/migrations/, which shares the word

Acceptance criteria

  • services/migration_registry.rs deleted, along with services/migrations/
  • NodeService's migration_registry field and its construction/clone sites removed (node_service/mod.rs:807, :877, :924, :1027)
  • Re-exports removed (services/mod.rs:28, :188) and the "for future use" note at :9 deleted with them
  • backfill_schema_description_subtrees deleted along with its startup call
  • db/migrations/ left intact, with a comment marking it as the schema bootstrap rather than a data migration
  • No remaining startup path performs a data backfill or format upgrade
  • _schema_version in node properties audited: confirm whether anything still reads it once the registry is gone, and remove it if not
  • Full test suite green; any test existing only to cover deleted migration code is deleted with it
  • CLAUDE.md updated per the prevention items above

Context

Surfaced while reviewing the write-atomicity survey, which flagged the backfill's compounding-duplicate failure and proposed a dedupe guard. Deleting is the smaller and more consistent fix. The registry was found alongside it.

Activity

  1. malibio commented on Sep 7, 2026

    @malibio
    CollaboratorAuthor

    Baseline (worktree issue-2389-delete-migration-logic): Frontend: 4852 passed (230 test files), 0 failed.

  2. self-assigned this
    on Sep 7, 2026
  3. added 2 commits that reference this issue on Sep 7, 2026
    6b27609
    58f98cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions