Skip to content

feat(stack): run stacklet migrations once, in order, on stack up - #231

Merged
arthware-dev merged 3 commits into
feature/0.5.0-beta.1from
feat/stacklet-migrations
Oct 16, 2026
Merged

arthware-dev merged 3 commits into
feature/0.5.0-beta.1from
feat/stacklet-migrations

Conversation

@arthware-dev

Copy link
Copy Markdown
Contributor

Summary

  • A stacklet ships data migrations as migrations/NNNN_<name>.py. stack up runs the pending ones once, in order, after a healthy start; the first failure stops the run and exits 1 with the containers up. stack doctor lists pending, failed and newer-than-checkout migrations; stack update names arriving ones and warns before moving to a release that lacks an applied one.
  • The record lives with the data in <data_dir>/<id>/.migrations.json. A family memory migration also ends its commit with Migration: <id>/<NNNN> and returns the sha; it counts as applied while that commit is in the repository and runs again when it is gone.
  • The to-do move (memory/0001) and the photo move (docs/0001, now a bot-runner command) run through it.

Merge mode: rebase. The three commits stand alone and each passes commit-lint.

Closes: #220

Test added 3 commits October 16, 2026 17:07
A stacklet that changes data it already wrote had nowhere to put the
change, so each one invented its own trigger and its own record. Now a
stacklet ships `migrations/NNNN_<name>.py` with `def run(ctx)`, and
`stack up` runs the pending ones after `on_start_ready`, once every
health check passed, in number order.

- The record lives with the data: `<data_dir>/<id>/.migrations.json`.
  A migration that commits to a repository on the code host declares
  `REPO`, ends its commit message with `ctx.trailer`
  (`Migration: <id>/<NNNN>`) and returns the sha; it counts as applied
  while that commit is in the repository, and runs again once a
  restore has taken it away.
- The first failure stops the run, is printed and recorded, and
  `stack up` exits 1 with the containers left running. The rest wait;
  the next `stack up` retries it.
- Commands that start several stacklets start all of them first, then
  migrate in dependency order. Bare `stack restart` goes the same way.
- `stack doctor` lists pending, failed, and data migrated by a newer
  release. `stack update` names the migrations a release brings and,
  before moving to a release that lacks one applied here, says so.
- `stack.bot_runner.call` runs a bot-runner command and raises on
  failure, for migrations whose work needs a bot's code.

The contract is in `docs/stack-reference.md` under Migrations, which
also corrects the runtime state directory to `.stack/`.

Refs: #220
`stack up memory` read every topic's `todos.md` on every start to move
it to `lists/`, and a failure was only a warning. The move is now
migration memory/0001: it runs once per instance, its commit carries
`Migration: memory/0001`, and a commit Forgejo refuses (a list edited
meanwhile) fails `stack up memory` and is retried on the next one.

Refs: #220
The archivist moved the photos filed as bookmarks to notes a minute
after it started, left a marker file in its data dir, and logged a
failure inside the bot runner where nobody saw it. The move is now
migration docs/0001, run by `stack up docs` through a new bot-runner
command, `migrate-photos-to-notes`, which downloads an old entry's
upload with the archivist's own Matrix session. Its commit carries
`Migration: docs/0001`, a failure fails `stack up docs`, and the old
marker file is removed. An instance that already moved its photos runs
it once more and finds nothing to move.

Refs: #220
@arthware-dev
arthware-dev force-pushed the feat/stacklet-migrations branch from 95e32c9 to 851c0a6 Compare October 16, 2026 15:07
@arthware-dev
arthware-dev merged commit 8f0adf2 into feature/0.5.0-beta.1 Oct 16, 2026
1 check passed
arthware-dev added a commit that referenced this pull request Oct 17, 2026
## Summary

- A stacklet ships data migrations as `migrations/NNNN_<name>.py`. `stack up` runs the pending ones once, in order, after a healthy start; the first failure stops the run and exits 1 with the containers up. `stack doctor` lists pending, failed and newer-than-checkout migrations; `stack update` names arriving ones and warns before moving to a release that lacks an applied one.
- The record lives with the data in `<data_dir>/<id>/.migrations.json`. A family memory migration also ends its commit with `Migration: <id>/<NNNN>` and returns the sha; it counts as applied while that commit is in the repository and runs again when it is gone.
- The to-do move (memory/0001) and the photo move (docs/0001, now a bot-runner command) run through it.

Merge mode: rebase. The three commits stand alone and each passes commit-lint.

Closes: #220
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