Seed a rig from a declarative spec

Closes #28 (closed) (#28 (closed)).

just lab seed --file <spec> applies a JSON spec to a deployed base. Each object is found by a natural key and created only when missing, so a second run makes no write call. A malformed spec or an unknown key is refused before any call, on the laptop and again on the VM.

flowchart TD
  A[spec file] --> B{parse and validate}
  B -- malformed or unknown key --> X[refuse, exit 2, no call]
  B -- ok --> C[ship to the VM]
  C --> D[groups, then users]
  D --> E[projects]
  E --> F{found by natural key?}
  F -- yes --> G[report exists]
  F -- no --> H[create]
  G --> I[members, labels, commits, branches, issues, merge requests]
  H --> I

Natural keys: group and project by full path, user by username, member by user, label and branch by name, commit by branch plus file path, issue by title, merge request by source and target branch. A spec carries no password or token; the server sets each user's random password.

Named seeds:

  • dap-project is the shipped spec gce/seeds/dap-project.json, and now also a rerun that changes nothing.
  • mr-activity builds its spec from the knobs and applies it. The projects come from GPT's output at run time, so no static file can name them. Authorship is now a deterministic Zipf spread rather than RANDOM, and the script no longer embeds a password.
  • gpt stays a script (it drives an external generator) and dap-bootstrap stays a script (Rails services, composite-identity settings, flags and model wiring have no REST form).

Verification:

  • seed-spec-selftest.sh applies a spec twice against a stub API and asserts equal objects and zero writes on the second run, refuses malformed and unknown-key specs with no call, and runs mr-activity twice.
  • Live proof on one omnibus rig (torn down): a spec of 2 groups, 2 users, 1 project with 2 members, 2 labels, 3 commits, 1 extra branch, 2 issues and 1 merged merge request. Run 1 made 16 objects, run 2 made 0 and found 15 present, and the counts read back from the API were equal after each run. seed dap-project ran twice the same way: 2 created, then 0. The first live run also found a defect the stub missed: a merge removes the source branch, so a rerun tried to recreate its files. The second commit fixes it and the stub now removes the branch on merge.
  • The word budget stays at its ceiling: seeding.md gives up as many words as the spec section adds.

AI-Assisted: yes

Edited by Andrew Dunn

Merge request reports

Loading
Loading