Skip to content

backfill-component-meta rewrites records outside the feature being extracted #4222

Description

@kevinthelago

Hit twice in two migrations (#4215 Sounds, #4219 Algorithms), caught by hand both times.

What happens

scripts/backfill-component-meta.cjs recomputes composes / role / props for every base-studio-code record, not just the ones an extraction added. The migration recipe says to run it after an extraction — so a Sounds migration rewrites projectspage, and an Algorithms migration rewrites it again.

The rewrite is not cosmetic. deriveComposes resolves an import to a graph component NAME, and only a record or a provides specifier counts — so ProjectCard, ProjectsRail, ProjectSetupPage and DeleteProjectModal (registered CODE, not records) are dropped from projectspage.composes. projectsGraphSeed.test.ts:99 asserts ProjectCard is present, so the suite goes red — but only if the run happens to include features/planner.

Why it keeps slipping through

  • The migration gate naturally scopes to the feature being migrated plus src/appMigrate Glance into the graph (epic #3604) #4185's run did not include features/planner at all, so the identical edit could have landed unnoticed.
  • The diff is one line in a JSON file among several legitimately-changed records, so it does not stand out in git status.

Both times the fix was git checkout -- on the unrelated records. That is a workaround, not a guard.

Options

  • Scope the backfill--only <folder> or a positional path, so an extraction touches only what it extracted. Smallest change, matches how it is actually used.
  • Fix deriveComposes so a registered platform component still counts as an edge. Arguably more correct — projectspage really does compose ProjectCard — but it changes what composes means graph-wide, and the swimlane layout reads it.
  • Leave it and assert — a test that the backfill is idempotent over the committed records, so a drive-by rewrite fails loudly instead of silently.

The first is the obvious one; the second is worth a look because the test's expectation and the deriver's rule genuinely disagree about what composes is for.

Acceptance criteria

  • Running the backfill after an extraction cannot modify records outside it — or, if it does, the difference is intentional and tested.
  • projectspage.composes stops oscillating between migrations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions