Skip to content

feat: move several models in one sqb mv and match carried declaration layouts - #1206

Merged
kvlonge merged 4 commits into
mainfrom
feat/batch-moves
Oct 21, 2026
Merged

kvlonge merged 4 commits into
mainfrom
feat/batch-moves

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Why

Restructuring a project means many sqb mv calls. Each one compiles the project twice, and the states between moves are often invalid even when the end state is valid, for example when a macro has to be carried up and back down. A carried declaration also ignored the destination role's layout, so a grouped role got a direct file that layout rule SQBRDECLARATION302 then rejected.

Changes

  • A carried declaration file matches the destination role: an empty role keeps the source's group folder, a grouped role keeps the group, and a direct role drops it. A direct file that must join a grouped role is refused with a message to group it first.
  • sqb mv accepts several TARGET DESTINATION pairs, or --from-file with one pair per line (# comments allowed). The project compiles once before, every move is planned against the final state, and the final state is verified with one compile. The batch is all-or-nothing, --dry-run prints the combined plan, and JSON output adds moves.
  • A batch is refused if it moves a model twice, sends two models to one file, gives two models one name, or reuses a name another move gives up. Any move is refused when two declaration files would land on one path, naming both.
  • A single move plans and prints as before.
  • Docs for both changes.

Verification

  • Rust unit tests for role layouts, batch planning conflicts, shared declaration targets and move-pair parsing; CLI dispatch tests.
  • E2E tests on DuckDB: grouped and direct destinations, the refused direct-into-grouped move, a batch that no order of single moves allows (two compiles), --from-file, dry run, and conflicting batches (including two same-named declaration files) leaving files unchanged.
  • make check-ci; refactor E2E and integration tests; compiler differential failure corpus (refactor goldens unchanged).

When sqb mv carries a scoped declaration to a wider owner, the file now
matches the layout of the role folder it lands in instead of always being
written directly in it. An empty role keeps the source's group folder, a
grouped role keeps the source's group, and a direct role drops it. A file
without a group that must join a grouped role is refused with a message to
move it into a group first, rather than writing a layout that verification
rejects for mixing direct and grouped files.

Placement relocation now accepts several resource moves at once.
sqb mv now takes several TARGET DESTINATION pairs, or --from-file with one
pair per line (tab or space separated, # comments and blank lines allowed).
The project compiles once before planning and the edited project once
after. Every move is planned together: declarations and unit tests are
placed for the state after all moves, a model may take a file or name
another move leaves, and a batch that moves a model twice, sends two models
to one file or gives them one name is refused. Nothing is written unless
the whole batch verifies; --dry-run prints the combined plan, and JSON
output lists the moves. A single move plans and prints as before.
Two carried declaration files could share one target, either from two moved models' same-named local files or from grouped files flattened into a direct role. Planning now refuses this up front, naming both files, instead of leaving it to a confusing verification compile error.
@kvlonge
kvlonge enabled auto-merge (squash) October 21, 2026 21:54
@kvlonge
kvlonge merged commit 601ccfc into main Oct 21, 2026
46 checks passed
@kvlonge
kvlonge deleted the feat/batch-moves branch October 21, 2026 22:51
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