Skip to content

mistd skeleton: migrations, scheduler lock and shared types (M1 step 1) - #130

Open
BrandonwLii wants to merge 5 commits into
chore/remove-container-platformfrom
feat/jobs-scheduling-m1
Open

BrandonwLii wants to merge 5 commits into
chore/remove-container-platformfrom
feat/jobs-scheduling-m1

Conversation

@BrandonwLii

Copy link
Copy Markdown
Collaborator

Stacked on #128. Retarget to main once that merges.

Step 1 of the jobs plan. The plan asks the team to agree this layout in one PR, so the main thing to review is the layout and the cross-owner contracts, not the logic.

Layout

Path What
cmd/mistd api (only /healthz so far) and scheduler subcommands; both apply migrations at start
internal/db Pool, embedded migrations in migrations/<owner>/ (apply order: identity, storage, scheduler, executor), advisory locks, and the cross-owner lock order
internal/db/dbtest Fresh database per test: embedded Postgres, or MIST_TEST_DATABASE_URL
internal/executor Executor interface, LaunchSpec (+ SpecHash, Validate), events, executions, receipts
internal/scheduler States, pending reasons, stop causes, operation intents; Run holds leadership
internal/identity Contract only: Authorizer, transaction-aware Admitter.LockGrant, durable Revocations
internal/identity/identitytest In-memory fixture (Alice/Bob in team-a, Carol and Alice in team-b)
internal/clock Injected clock; the fake one comes in step 2

Needs agreement from

  • Lucas (identity): internal/identity/identity.go. This is what the scheduler will call during admission. It takes the caller's pgx.Tx and locks account → membership before the scheduler locks job → allocation → node. The Postgres implementation is yours. Please change the shape here if it doesn't fit.
  • Everyone: the per-owner migration directories and the rule that applied migrations are immutable (a changed checksum fails startup).

Check

  • TestSchedulerMigratesAndHoldsLock: the first scheduler migrates an empty database and holds the lock, a second one waits, then takes over when the first stops.
  • TestSchedulerExitsWhenConnectionLost: killing the leader's lock connection stops the scheduler with an error.
  • There are also tests for the migrator (idempotent, rollback on failure, rejects edited migrations), the spec hash and validation, and the fixture's permission matrix.

go test ./... and go vet ./... pass locally. The race detector hasn't been run (no cgo on my machine).

🤖 Generated with Claude Code

BrandonwLii and others added 5 commits October 26, 2026 14:09
Describe the redesign agreed on October 26: per-team folders, restricted
SSH login, and jobs that run as the researcher's own UID under Mist's own
scheduler, with a pluggable executor (K3s first, native node executor
later). Adds the system overview, one contract doc per component, a
decision log, and the jobs/scheduling implementation plan. README points
to the new design and notes that docs/content describes the old platform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ARCHITECTURE.md gains an owner-boundary diagram with a table of the
contracts between areas, and an end-to-end sequence of one researcher
going from sign-up to results. Each component doc gains one diagram of
how it fits: identity data flow, storage paths, gateway dispatch, API
routing, the scheduling cycle, both executors, the inside of a job,
portal pages to endpoints, and the network topology.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tighten component contracts (API, scheduler, executors, identity, storage,
login gateway, network) and add implementation-contracts.md with release
gates and invariants. Add decisions D18–D23 and update the jobs plan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The old platform (src/ API, cli/, deploy/, web-interface/, Hugo docs site,
fake backend scripts) was never deployed and is superseded by the HPC-style
design in ARCHITECTURE.md. It remains in Git history before this commit.

Rewrite the README around the new design, update ARCHITECTURE.md references,
and fix a stale executors.md anchor in scheduler.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
M1 step 1 of the jobs plan. mistd gets api and scheduler subcommands;
internal/db embeds per-owner migrations and documents the cross-owner
lock order; the scheduler holds a Postgres advisory lock on a dedicated
connection and stops when it is lost. internal/executor defines the
Executor interface, LaunchSpec (with SpecHash and validation), events,
executions and receipts. internal/identity declares the contract
Identity implements, with an in-memory fixture for tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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