@smartkomm/plexus-cli 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +863 -2
  2. package/dist/cli.mjs +5432 -0
  3. package/dist/skill/.managed-by-plexus-cli +1 -0
  4. package/dist/skill/SKILL.md +224 -0
  5. package/dist/skill/references/accounts/email-changes.md +46 -0
  6. package/dist/skill/references/agents/use-shared-tools.md +52 -0
  7. package/dist/skill/references/applications/inspect-process-store.md +61 -0
  8. package/dist/skill/references/applications/start-a-test-application.md +66 -0
  9. package/dist/skill/references/audit/answer-access-request.md +115 -0
  10. package/dist/skill/references/config/attach-a-template.md +117 -0
  11. package/dist/skill/references/config/init-tenant.md +121 -0
  12. package/dist/skill/references/config/onboard-tenant.md +71 -0
  13. package/dist/skill/references/config/rename-program-stage.md +99 -0
  14. package/dist/skill/references/config/set-tenant-branding.md +150 -0
  15. package/dist/skill/references/config/set-tenant-terms.md +50 -0
  16. package/dist/skill/references/config/set-up-billing-catalog.md +73 -0
  17. package/dist/skill/references/config/update-tenant-config.md +174 -0
  18. package/dist/skill/references/config/wipe-tenant-config.md +107 -0
  19. package/dist/skill/references/export/create-named-export.md +47 -0
  20. package/dist/skill/references/feedback/create-and-triage-feedback.md +69 -0
  21. package/dist/skill/references/feedback/manage-feedback-tags.md +57 -0
  22. package/dist/skill/references/finance/change-contract-grant.md +36 -0
  23. package/dist/skill/references/finance/record-submission-date.md +33 -0
  24. package/dist/skill/references/interessenten/list-interessenten.md +54 -0
  25. package/dist/skill/references/marketing/demo-video-links.md +101 -0
  26. package/dist/skill/references/notifications/debug-mail-delivery.md +77 -0
  27. package/dist/skill/references/notifications/mail-level.md +90 -0
  28. package/dist/skill/references/notifications/reword-a-letter.md +155 -0
  29. package/dist/skill/references/notifications/trace-a-login.md +50 -0
  30. package/dist/skill/references/offer/add-workflow-node.md +268 -0
  31. package/dist/skill/references/offer/addresses.md +129 -0
  32. package/dist/skill/references/offer/appointment-task.md +79 -0
  33. package/dist/skill/references/offer/assignment-rule.md +195 -0
  34. package/dist/skill/references/offer/attach-form-to-workflow.md +79 -0
  35. package/dist/skill/references/offer/author-form-scenarios.md +97 -0
  36. package/dist/skill/references/offer/author-manifest-meta.md +94 -0
  37. package/dist/skill/references/offer/author-smartform.md +102 -0
  38. package/dist/skill/references/offer/bind-node-input.md +76 -0
  39. package/dist/skill/references/offer/completeness-check.md +137 -0
  40. package/dist/skill/references/offer/countersign-node.md +91 -0
  41. package/dist/skill/references/offer/create-pedagogy-unit.md +55 -0
  42. package/dist/skill/references/offer/declare-node-reads.md +99 -0
  43. package/dist/skill/references/offer/edit-live-tenant-offer.md +144 -0
  44. package/dist/skill/references/offer/edit-smartform.md +121 -0
  45. package/dist/skill/references/offer/edit-workflow-node.md +126 -0
  46. package/dist/skill/references/offer/engage-push-node.md +147 -0
  47. package/dist/skill/references/offer/insert-and-rewire-node.md +67 -0
  48. package/dist/skill/references/offer/node-tasks.md +162 -0
  49. package/dist/skill/references/offer/optional-assessment.md +65 -0
  50. package/dist/skill/references/offer/publish-offer-bundle.md +117 -0
  51. package/dist/skill/references/offer/set-offer-capacities.md +78 -0
  52. package/dist/skill/references/offer/staff-input-if-node.md +112 -0
  53. package/dist/skill/references/offer/task-appointment-result.md +69 -0
  54. package/dist/skill/references/offer/task-family-request.md +69 -0
  55. package/dist/skill/references/offer/task-result-files.md +52 -0
  56. package/dist/skill/references/offer/template-document-node.md +113 -0
  57. package/dist/skill/references/offer/workflow-default-channels.md +69 -0
  58. package/dist/skill/references/resolver/manage-contract-resolver.md +161 -0
  59. package/dist/skill/references/retention/erase-due-applications.md +99 -0
  60. package/dist/skill/references/retention/erase-due-parties.md +107 -0
  61. package/dist/skill/references/roles/migrate-parent-assignments.md +31 -0
  62. package/dist/skill/references/signing/README.md +113 -0
  63. package/dist/skill/references/signing/connect-a-school.md +90 -0
  64. package/dist/skill/references/signing/rotate-the-key.md +41 -0
  65. package/dist/skill/references/stammdaten/purge-deleted-person.md +68 -0
  66. package/dist/skill/references/stripe/connect-a-school.md +107 -0
  67. package/dist/skill/references/stripe/request-and-verify-a-payment.md +78 -0
  68. package/dist/skill/references/test-actions/drive-a-test-application.md +69 -0
  69. package/dist/skill/references/users/add-platform-admin.md +59 -0
  70. package/dist/skill/references/users/add-platform-user.md +59 -0
  71. package/dist/skill/references/users/add-tenant-admin.md +75 -0
  72. package/dist/skill/references/users/change-login-email.md +55 -0
  73. package/dist/skill/references/users/cli-access-for-tenant-admin.md +117 -0
  74. package/dist/skill/references/users/delete-permission-group.md +76 -0
  75. package/dist/skill/references/users/grant-cross-tenant-access.md +57 -0
  76. package/dist/skill/references/users/grant-feedback-assignable.md +43 -0
  77. package/dist/skill/references/users/set-password.md +57 -0
  78. package/dist/skill/references/users/use-test-account.md +79 -0
  79. package/dist/skill/references/worker-ops/debug-worker-jobs.md +90 -0
  80. package/dist/skill/references/worker-ops/verify-migrations.md +51 -0
  81. package/dist/spec.snapshot.json +156821 -0
  82. package/package.json +53 -4
package/README.md CHANGED
@@ -1,3 +1,864 @@
1
- # Temporary Holding Version
1
+ # plexus-cli — the unified Plexus admin + config CLI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ One **pure-TypeScript** CLI for operating and configuring Plexus against any
4
+ environment (local / staging / prod) — runtime ops, introspection, and
5
+ admission-offer config-as-code from a single binary. The system command is
6
+ `plexus-cli`.
7
+
8
+ ## Install (system tool)
9
+
10
+ Published publicly on npmjs.org as `@smartkomm/plexus-cli` (Node.js 22 or newer);
11
+ install it globally and run from anywhere:
12
+
13
+ ```bash
14
+ npm i -g @smartkomm/plexus-cli
15
+
16
+ plexus-cli --help # all commands, grouped by category
17
+ plexus-cli <command> --help # per-command help (clipanion auto-generates it)
18
+ ```
19
+
20
+ > The command is `plexus-cli`; only the package name is scoped (`plexus-cli` on
21
+ > npm belongs to someone else). The package holds no credential — every call needs
22
+ > your own `plx_…` token.
23
+
24
+ ### The agent skill
25
+
26
+ `plexus-cli agent tools --json` exposes the shared agent tool schemas.
27
+ `plexus-cli agent invoke --tool <name> --json` accepts tool input as JSON on
28
+ stdin. Commands use the same parser as ordinary CLI invocations; workspace
29
+ files are relative to the current directory. See the
30
+ [shared-tools recipe](playbooks/agents/use-shared-tools.md).
31
+
32
+ On every start the installed CLI keeps an agent skill current for Claude Code
33
+ (`~/.claude/skills/plexus-cli/`) and Codex (`~/.codex/skills/plexus-cli/`) — whichever
34
+ of the two exists: `SKILL.md` plus every playbook as `references/`, each marked with the
35
+ right it needs (tenant token or platform operator). A directory of that name the CLI did
36
+ not write is left alone (one warning); remove it to get the bundled skill. A failed write
37
+ warns once and never fails the command. The installed directory belongs to the CLI: an
38
+ edit inside it is replaced by the next release. `PLEXUS_CLI_NO_SKILL=1` switches the
39
+ installation off (a development build, a CI machine).
40
+
41
+ ### Or link the working tree as the global binary (dev machines)
42
+
43
+ Instead of the published package you can point the global `plexus-cli` at your local
44
+ build — **from the primary checkout only** (never a worktree):
45
+
46
+ ```bash
47
+ cd <primary checkout> && pnpm --dir app/tools/plexus-cli link:global
48
+ ```
49
+
50
+ This builds `dist/cli.mjs` and symlinks `~/.local/bin/plexus-cli` at it. The symlink
51
+ tracks the checkout, so a later `pnpm build` refreshes the binary. `link:global`
52
+ **refuses to run inside a worktree** — a worktree's `dist/` is deleted on teardown,
53
+ which would leave a dead symlink (the recurring "No such file" breakage).
54
+
55
+ ## Develop in-repo
56
+
57
+ The CLI lives in `app/tools/plexus-cli/`. To run the working tree (not the published
58
+ build) against a backend — this is also how you test **CLI code changes against a
59
+ specific worktree's backend** (run it from inside that worktree; `--env local` follows
60
+ your cwd), without touching the global binary:
61
+
62
+ ```bash
63
+ cd app/tools/plexus-cli
64
+ pnpm install # one-time: tool deps (clipanion, esbuild, tsx…)
65
+ pnpm dev -- <command> [...flags] # = node --import tsx cli.ts
66
+ pnpm build # → dist/cli.mjs (the published bundle)
67
+ pnpm link:global # (primary checkout only) build + symlink the global binary
68
+ pnpm typecheck # tsc against the live backend (build-from-truth gate)
69
+ pnpm test # node --import tsx --test (also: `pnpm test:cli` from app/)
70
+ pnpm spec # regenerate spec.snapshot.json from the code (no backend)
71
+ ```
72
+
73
+ ## How it's built — in-repo source, bundled to ship
74
+
75
+ The CLI imports the backend's **real types, the generated `api`, and the publish-gate
76
+ validators directly** from `app/convex/**`. The publish workflow type-checks against
77
+ that live tree and **bundles it** (esbuild) into a standalone artifact — so the
78
+ benefits are baked in at build time:
79
+
80
+ 1. **Typed `api`, zero drift** — every call's args + returns are inferred end-to-end
81
+ from the live function definitions; the published bundle is the real code,
82
+ type-checked and *versioned*, never a hand-maintained re-derivation.
83
+ 2. **`no-explicit-any` everywhere** — the call surface is fully typed; the only
84
+ unavoidable casts are `as unknown as T` (admin auth, the generic `call`).
85
+ 3. **Offline validation against the *real* publish gate** — `offer validate` runs the
86
+ same `runWorkflowValidators` / `runFormValidators` the server runs, inlined into
87
+ the bundle (works on any machine, no repo, no deployment).
88
+
89
+ The only caveats: the installed CLI is a point-in-time release (rebuild/republish to
90
+ pick up backend changes), and `--env local` resolves the deployment from your current
91
+ worktree (run it from inside a checkout) — the staging/prod token path works anywhere.
92
+
93
+ ## Auth & environments
94
+
95
+ Connection config resolves in this order: **`--env`/`--tenant` flags → env-vars →
96
+ `~/.config/agent-tools/plexus.yml`**.
97
+
98
+ ```yaml
99
+ # ~/.config/agent-tools/plexus.yml
100
+ plexus:
101
+ default_env: local
102
+ default_tenant: test
103
+ environments:
104
+ local: {} # DYNAMIC — follows your current rdu worktree (see below); no values needed
105
+ staging: { convex_url: "<staging Convex URL>", site_url: "<staging site URL>", token: "plx_…" } # from the platform operator
106
+ prod: { convex_url: "https://db.plexus.swop.schule", site_url: "https://actions.db.plexus.swop.schule", token: "plx_…" }
107
+ ```
108
+
109
+ Env-var fallback (no YAML): `PLEXUS_ENV`, `PLEXUS_CONVEX_URL`, `PLEXUS_SITE_URL`,
110
+ `PLEXUS_TOKEN`, `PLEXUS_TENANT`.
111
+
112
+ **Token path (faithful):** a `plx_…` API token (mint one in the app under
113
+ **Settings → API-Token**) is exchanged at `{site_url}/cli/token` for a short-lived
114
+ RS256 JWT, cached at `~/.config/agent-tools/plexus-jwt-<env>.json`. Every call
115
+ lands as the real authenticated user through the public API + its gates.
116
+
117
+ **Local path (`--env local`):** zero config — the CLI follows whichever rdu worktree
118
+ you run it from. It resolves that deployment's URL from the worktree's `.env` files
119
+ and bootstraps a deterministic platform-admin token with the rdu admin key
120
+ (`apiTokens:devSeedToken`, DEV_MODE-only), then takes the same token→JWT path. The
121
+ **cwd** decides the target deployment, not where the binary was installed. Run
122
+ `plexus-cli --env local config show` to see the resolved `deployment` + `authMode`
123
+ (`local-bootstrap`). Full workflow + gotchas:
124
+ `docs/engineering/plexus-cli.md` §"Local dev across rdu worktrees".
125
+
126
+ ## Commands
127
+
128
+ | Group | Commands |
129
+ |---|---|
130
+ | **local** | `config`, `functions`, `describe`, `offer validate` |
131
+ | **introspection** | `functions [--kind] [--grep]`, `describe <fn>`, `call <fn> [--kind] key=value…` |
132
+ | **identity** | `whoami`, `tenants`, `units` |
133
+ | **catalog** | `catalog {plan,apply} --file catalog.json` · `catalog export --out catalog.json` — articles with the programs selling them, packages, need-based tiers and Word templates of a tenant, by stable key; a DOCX is replaced only when its SHA-256 differs; export → plan is `same`. Recipe [playbooks/config/set-up-billing-catalog.md](./playbooks/config/set-up-billing-catalog.md) |
134
+ | **applications** | `applications {list,counts} --offer <slug>` · `applications show <id>` · `applications store <id> [--json]` (the process store, every address resolved — [playbooks/applications/inspect-process-store.md](./playbooks/applications/inspect-process-store.md)) · `applications start-test --offer --run <key\|id> --stage <key\|id> (--applicant <email> \| --party <id>) [--staff-input <key>=true\|false …]` (every staff input the offer declares, once each) · `applications discard-test <id>` — recipe [playbooks/applications/start-a-test-application.md](./playbooks/applications/start-a-test-application.md) |
135
+ | **retention** | `retention plan` (read-only) · `retention apply [--confirm --expect <n>]` — a tenant's applications past their retention period, and their erasure by hand (dry run without `--confirm`; a count other than `--expect` erases nothing). Nothing erases on a schedule; recipe and the DSGVO duty: [playbooks/retention/erase-due-applications.md](./playbooks/retention/erase-due-applications.md). `retention parties plan` · `retention parties apply [--confirm --expect <n>]` — the same for persons past the tenant's deletion rule (hard delete with history and files; blocked persons are listed and skipped, `--expect` counts the deletable ones): [playbooks/retention/erase-due-parties.md](./playbooks/retention/erase-due-parties.md) |
136
+ | **test-actions** | `test-actions list --application <id> [--node]` · `test-actions run --application <id> --action <id> [--node] [--no-auto-submit] [--param key=value …]` (`--param`: the action's params, values JSON like `call`'s, e.g. `--param confirmed=true` for an action that asks first) — the test-mode popover of a test application (scenarios, `auto-fill-files`, `submit-form`, …); recipe [playbooks/test-actions/drive-a-test-application.md](./playbooks/test-actions/drive-a-test-application.md) |
137
+ | **migrations** | `migrations status [--recent]` — the deployed release's pending migrations; exit 1 while one is not `success` (recipe [playbooks/worker-ops/verify-migrations.md](./playbooks/worker-ops/verify-migrations.md)) |
138
+ | **tokens** | `tokens list`, `tokens create <name>`, `tokens revoke <id>` — minting needs `_platform.apiTokens.manage` (opt-in) or the tenant right `administration.apiTokens.manage` (every `tenant_admin` holds it); list and revoke your own always work. `tokens create <name> --for <email> [--output <csv>] [--quiet]` mints one FOR a tenant administrator or platform operator to hand over (`_platform.users.manage` AND `_platform.apiTokens.manage`; the target must hold `administration.apiTokens.manage` in a tenant, or the platform right `_platform.apiTokens.manage`) — recipe [playbooks/users/cli-access-for-tenant-admin.md](./playbooks/users/cli-access-for-tenant-admin.md) |
139
+ | **users** | `users {list,show,add,remove,set-group,unset-group,groups,set-platform-admin,set-platform-permission,create,provision,provision-platform-admin,provision-platform-user,set-password,login-trail,set-email,delete,doctor,relink-auth}` — `login-trail <email> [--since 24h]` lists refusals, letters with the relay's answer, sessions and the last password change; `remove` / `unset-group` / `delete` are refused while a `wip` or published workflow's assignment rule names the person (replace them first: „Person ersetzen" in the workflow editor, then publish); `--replace-with <configKey>` hands their active applications over (required while they are responsible for any) and never rewrites a rule |
140
+ | **platform** | `platform {tenants,users,workers}` |
141
+ | **stammdaten** | `stammdaten persons [-q] [--limit] [--all] [--deleted]`, `stammdaten persons purge <partyId> [--confirm]` (the only hard delete of a person, plan unless `--confirm`) |
142
+ | **admission** | `admission laeufe` · `assignment simulate --dir <bundle> --env-json '<json>'\|--env-file <f> [--creator <label>] [--rotation-previous <slot>=<key>]… [--open <key>=<n>]… [--left <key>]…` (evaluate an offer bundle's assignment rule — `graph.assignmentRules` in its `workflow.json`, every slot, the matched row per slot — offline; recipe `playbooks/offer/assignment-rule.md`) |
143
+ | **generator** | Contract generators (`finanzen_vertraege.contracts.manage`): `generator {list,show,usages,runs}` · `generator {create,update,clone,seal,archive,restore,delete-draft}` · `generator source {export,save}` · `generator scenarios {test,approve}` · `generator {export,apply}` (one-file round trip) · `generator template {list,upload}` · `generator setup {plan,apply}` (offer setup by catalog keys). **Combined generators**: `generator combined export <key@rev> [--out]` writes the declaration (mask, parts pinned as `key@revision`, names) · `generator combined save <file>` writes it back — onto the exported revision (guarded by `expectedSourceRevision`; an unedited export writes nothing) or, without `id`, as the first draft of a new key · `generator combined plan <key@rev> --input <json> [--strict]` (sandbox: which parts run, what each misses; exits 0 like `generator test`, with `--strict` 1 when the input would not generate — a missing field, an undecided part, a roster issue, a part's refusal) · `generator combined create --key … --name … --name-en …` (empty draft); seal/clone/archive with the ordinary verbs. The server's `[generator/…]` refusals print verbatim. Recipe [playbooks/resolver/manage-contract-resolver.md](./playbooks/resolver/manage-contract-resolver.md). |
144
+ | **imports** | `imports {status,trigger,trigger-all}` |
145
+ | **feedback** | `feedback {list,screenshot,to-issue,sync,set-status}` |
146
+ | **demo** | `demo videos` (the catalogue: id, date, title, length) · `demo link create (--to <name> [--email] \| --from <utf-8 csv> [--out <csv>]) [--video <id>] [--campaign] [--note]` · `demo link list [--campaign]` · `demo link stats [<code> \| --campaign]` · `demo link revoke <code>` · `demo link delete <code> [--confirm]` (erases the link with everything recorded; a dry run without `--confirm`) — personalised links to the public demo video page and their viewing statistics (a visit counts once the page was visible 5 s or the visitor interacted; watched seconds come from the player, `%` = how much the best single visit actually played). Needs `_platform.demoLinks.manage`; recipe [playbooks/marketing/demo-video-links.md](./playbooks/marketing/demo-video-links.md) |
147
+ | **notifications** | Operator's log (`_platform.notifications.monitor`): `notifications {list,show,retry,sweeper-status,self-test}`; `list` filters by `--status`, `--template`, `--to`, `--since 24h` and shows the relay's answer (`smtp`). Why a sign-in failed: `users login-trail <email> --since 24h` (recipe [playbooks/notifications/trace-a-login.md](./playbooks/notifications/trace-a-login.md)). School's wording (tenant-scoped, `notifications._self.access` / `.mail.configure`): `notifications letters {list,show,set,reset}` · `notifications chrome {show,set}` — see ["The words a school sends"](#the-words-a-school-sends-notifications-letters--chrome). |
148
+ | **offer** | `offer {create,show,set,delete,restore,list,status}` · `offer run {add,set,archive,restore}` · `offer level {add,rename,move,remove,restore}` · `offer capacity set` · `offer unit {create,ensure-pedagogy}` (make a school applyable: create unit + pedagogy bridge) · `offer {export,validate,plan,diff,apply}` |
149
+ | **offer form** | `offer form {list,show,add,set,rm}` · `offer form section {add,set,move,rm}` · `offer form field {add,set,move,rm}` · `offer form outcome {add,set,rm}` · `offer form effect {add,set,rm}` · `offer form repeated {add,set,rm}` · `offer form computed {add,set,rm}` · `offer form scenario {add,set,rm}` (test-mode prefills; `--prefill k=v` typed by field; `add --from <id>` derives a variant) · `offer form env set --keys … --sample <scenario>=<json>` (the `$env` keys the form reads) (offline bundle authoring; every mutator runs the real publish-gate validators before writing). `field set` covers all editable props (bucket/placeholder/help-text/enum/enum-ref/enum-list-key/multiple/required-for/docRef/consent + validation expressions; enum/enum-ref/enum-list-key are mutually exclusive — `--enum-list-key` binds a tenant `custom_field_lists` key, `--multiple` makes it multi-select); `effect set` is per-kind (bucket/identity/orgKind/from/to/relKind/target/map); `section set --parent` reparents; `section set --visible-to <key,…>` restricts who on the school's side reads the section's values (`""` clears); `field/section move --before\|--after\|--to-top\|--to-bottom` reorders. Every SmartForm text is ONE `{ de, en }` field: a German text needs its English in the same call (`--label-en`, `--placeholder-en`, `--help-text-en`, …) — the German is never copied into `en`. |
150
+ | **offer workflow** | `offer workflow node {list,add,set,rm,reads}` · `offer workflow show` — author the workflow graph (splice nodes, keep progress layout/routing in sync). `node add --type form --form <slug>` binds a SmartForm (`--new-form` scaffolds + binds); the folded `governedDocument` node (offer/contract lifecycle) cannot be **added** by the CLI yet — author it in bundle JSON and gate it through `offer validate` / `offer apply --publish`; on an existing one `node set --approval release|none` switches the Freigabe before the document goes out (`none` drops its team + title, `release` takes `--approve-title`, default „<Dokument> freigeben“) and `--confirm-issue true|false` makes „Bereitstellen“ ask before the family sees the document (approval `none` only); on a signing node `--confirm-terms true|false` switches the confirmation of the contract terms before the signed copy's upload (default on) and `--terms-question-de/-en` rewords it — the same edits as the IDE's Knotendetails → Einstellungen. `node add --type review [--reads '<address>,…']` adds a „Prüfung" that parks, and whose outcomes wait until the named fields are ticked; `--on-edge <from>:<outcome>` splices any new node onto exactly that edge and `--progress <event>=<state>` puts its board event on an existing state (recipe [playbooks/offer/insert-and-rewire-node.md](./playbooks/offer/insert-and-rewire-node.md)). Every flag that reads another node's data takes a full ADDRESS naming its producer (`'$node.form.admission.kind.vorname'`, `'$task.reducedFee.reducedFee'`, `'$derived.schulgeld'`, `'$env.applicant.language'` — single quotes) — a bare key is refused with the addresses visible at the node, nothing is bound implicitly; `node reads --node <id>` lists what arrives at a node; see ["Addresses"](#addresses-what-a-node-reads-and-who-produces-it). `node add --type countersign` adds „Unterschrift (intern)" — see ["Countersignature node"](#countersignature-node-unterschrift-intern). `node add --type if --condition '<expr>'` adds a branch on one DSL expression over `$env` (outcomes `true`/`false`, route with `--outcomes`; `node set --condition` replaces it), and `staff-input {list,set,remove}` declares the staff inputs it reads as `$env.staffInput.<key>` — see ["Staff inputs and the if node"](#staff-inputs-and-the-if-node). `node set-input --dir <bundle> --node <id> --input <key> (--address '<address>' | --from <formNode> --field <path> | --literal <json> | --clear)` sets one input cell — e.g. a template's language field to `$env.applicant.language` (recipe [playbooks/offer/bind-node-input.md](./playbooks/offer/bind-node-input.md)). `node set` edits a node in place — `--label`, decision `--assign-decision`/`--comment-required`, form `--form` rebind (a slug on a form node; the instance address on a resolver contract / engagePush), setFlag `--target`, countersign/engagePush `--contract`, engagePush `--payment`, if `--condition`, `--person`, `--outcomes` routing rewrite (`--type` is not editable → rm+add). `node rm` is refused while an address elsewhere names the node, listing every such place. `node {set,clear}-notification` binds/unbinds the LETTER a node sends at one of its declared events — see ["Notifications on a workflow node"](#notifications-on-a-workflow-node). `node {set,add,remove}-reads` declares which form fields a decision/document node reads before acting — see ["Readiness reads on a workflow node"](#readiness-reads-on-a-workflow-node). `node add --type completenessCheck` + `node {set,add,remove}-requires` author the gate that waits for outstanding documents — see ["Completeness check"](#completeness-check-documents-owed-before-the-process-ends). `node task {add,set,rm}` edits ONE composed task of a node — result, cross-node `blocks`, condition, evidence, description, family request, optional — and `node optional-action {set,remove}` one entry under „Weiteres" — see ["Tasks on a workflow node"](#tasks-on-a-workflow-node). `channels {list,add,rm}` authors the default chat channels every application of the version starts with (`graph.channels`; automatic per-team channels are listed read-only) — recipe [playbooks/offer/workflow-default-channels.md](./playbooks/offer/workflow-default-channels.md). |
151
+ | **offer manifest** | `offer manifest set` (applicant-mode/signature-level/window/capacity/selection) · `offer role {add,set,rm,list}` (roleInstances) · `offer leistung {add,rm}` (offline bundle authoring; enum values validated client-side fail-loud, since the manifest gate checks structure not enum values). |
152
+
153
+ **Writing commands name their environment.** Every client command is classified in ONE
154
+ list, `plexus/writeVerbs.ts` (read · write · write only with `--confirm` · `call` by its
155
+ kind), and ONE guard (`ClientCommand.caller`) applies it: a writing run refuses without
156
+ `--env` on the command line (a configured default or `PLEXUS_ENV` is not enough), and a
157
+ production target needs `--allow-prod` — decided on the RESOLVED deployment URL, so any
158
+ environment that points at the URL `plexus.yml` names for `prod` is production
159
+ (`plexus/writeTarget.ts`, `core/config.ts` `knownProdConvexUrls`). The check runs before any
160
+ network access; a `plexus.yml` without a `prod` entry makes writes refuse. Reads are
161
+ unaffected (`--allow-prod` on a read is ignored, with a note on stderr). A `--confirm`
162
+ command's dry-run counts as a read; a write verb's own `--dry-run` flag (`feedback to-issue`,
163
+ `imports trigger`) does not — it still needs `--env`. `writeVerbs.test.ts` fails when a new
164
+ command is not classified, so none ships unguarded; a command listed as a read that reaches a
165
+ mutation or action at runtime throws, naming itself. `--env local` connects only to THIS machine — its admin-key bootstrap is a mutation even for
166
+ a read, so the target's host must resolve to loopback or to an address of one of this machine's
167
+ interfaces (rdu's Traefik host of a worktree does; a remote deployment does not). `seed` is outside the guard: it runs
168
+ `convex run` against the current worktree's own deployment, never through `plexus.yml`.
169
+
170
+ `seed --if-needed` is the local startup path: it pushes current code, initializes
171
+ an empty database once, joins an active seed, or preserves a completed seed.
172
+ Failed/incomplete seeds and untracked populated databases require an explicit
173
+ rebuild. Without `--if-needed`, `seed` is destructive. `--applicants none` and
174
+ `--finance-showcase none` select the lean fixtures; switching local profiles
175
+ preserves existing data until an explicit rebuild. `--only <cases>` drives just
176
+ those applicant cases and implies `--finance-showcase none` unless
177
+ `--finance-showcase` is given. At most `PLEXUS_SEED_SLOTS` (default 2) seeds run at
178
+ once on one machine, across all checkouts: a seed waits for a free slot (an
179
+ `flock` under `~/.cache/plexus/seed-slots/`, printing who holds them) and keeps it
180
+ until its run is terminal; `--timeout` bounds the wait and the seed together. A
181
+ failed run is reported at once with its phase and error; five unreadable status
182
+ polls in a row end the command with the last error. Recipe:
183
+ [Initialize or rebuild local demo data](playbooks/worker-ops/rebuild-local-data.md).
184
+
185
+ Every command supports `--json` (raw output; default is a table). Network commands
186
+ take `--env` / `--tenant`. `functions` / `describe` / `offer validate` / `config`
187
+ work offline (no deployment).
188
+
189
+ ### Provisioning admins
190
+
191
+ Two distinct shapes for a tenant-less platform operator:
192
+
193
+ - `users create <email> --platform-admin` — mints the identity + the `_platform.*`
194
+ row **with** a generated credential (printed once; `--output` writes the
195
+ `email,password` row to a CSV). It takes no display name, so the account carries
196
+ none. No verb produces an identity that cannot log in.
197
+ - `users provision-platform-admin <email> --name "…"` — the **credentialed,
198
+ ready-to-log-in** full-admin path (creates the Better Auth credential too and
199
+ grants every `_platform.*` permission).
200
+ - `users provision-platform-user <email> --name "…" --permission _platform.schema.read`
201
+ — the credentialed limited-platform path. It creates the Better Auth credential
202
+ and grants exactly the repeated `--permission` values.
203
+
204
+ Both platform provisioning commands need `_platform.users.manage` (your own
205
+ platform-admin token, no Convex admin key) and refuse an email that already has
206
+ tenant access (the `_platform.* XOR tenant-access` invariant). `users provision` does
207
+ the same credentialed onboarding for a *tenant* user (`--tenant <slug> --group
208
+ tenant_admin`).
209
+
210
+ Step-by-step recipes (exact commands + verification + gotchas):
211
+ [playbooks/users/add-platform-admin.md](./playbooks/users/add-platform-admin.md) ·
212
+ [playbooks/users/add-platform-user.md](./playbooks/users/add-platform-user.md) ·
213
+ [playbooks/users/add-tenant-admin.md](./playbooks/users/add-tenant-admin.md). For any
214
+ common CLI task, see [playbooks/](./playbooks/README.md).
215
+
216
+ ### E-signature (`signing` command group)
217
+
218
+ `plexus-cli signing {list,start,show,void,resend,reconcile}` — the Signaturvorgang
219
+ (DocuSign or inSign) over the public `signing.*` functions; gated on
220
+ `finanzen_vertraege.contracts.manage`. `start` goes out through the tenant's ACTIVE
221
+ connection — there is no provider to pick.
222
+
223
+ `plexus-cli signing connection {show,test,set,activate,remove,reseal}` and `plexus-cli signing status` (key slots: what is sealed under which key; `reseal` after a key rotation, both platform-wide under `_platform.config.manage` — docs/signing/operations.md → "Rotating the key") — the school's own
224
+ account at a provider (`signingConnections.*`). `show` and `test` need
225
+ `finanzen_vertraege.contracts.manage`; `set`, `activate` and `remove` the platform right
226
+ `_platform.config.manage`. A secret (DocuSign's Connect HMAC key, inSign's API password)
227
+ enters only through `--secret-stdin` or `--secret-file` and is never printed — `show`
228
+ lists its name and fingerprint. Recipes: `playbooks/signing/README.md`,
229
+ `playbooks/signing/connect-a-school.md`; setup + runbook:
230
+ `docs/signing/{README,docusign-setup,insign,operations}.md`.
231
+
232
+ ### The words a school sends (`notifications letters` / `chrome`)
233
+
234
+ A **letter** is code: named **blocks** with the text Plexus wrote. A school may
235
+ rewrite a block, and what is stored is **only that deviation** — every block it
236
+ leaves alone keeps following the platform text, so a later improvement still
237
+ reaches it.
238
+
239
+ ```bash
240
+ plexus-cli --tenant test notifications letters list # catalog + who deviates
241
+ plexus-cli --tenant test notifications letters show applicant.tasksOpen # the letter's placeholders + each block's text
242
+ plexus-cli --env <env> --tenant test notifications letters set applicant.tasksOpen \
243
+ --slot intro="bei {{schoolName}} warten {{taskCount}} Aufgaben auf Sie."
244
+ plexus-cli --env <env> --tenant test notifications letters set applicant.tasksOpen --slot-file intro=./intro.txt
245
+ plexus-cli --env <env> --tenant test notifications letters reset applicant.tasksOpen --slot intro
246
+ plexus-cli --env <env> --tenant test notifications letters reset applicant.tasksOpen --all
247
+ plexus-cli --tenant test notifications chrome {show,set} # greeting / sign-off / sender name
248
+ ```
249
+
250
+ Semantics worth knowing before using them:
251
+
252
+ - **`set` merges** across blocks; a block whose text equals the platform default
253
+ is **dropped rather than stored**, so the command's `deviating blocks` line can
254
+ be shorter than what you submitted. That is the backend's answer, not a CLI
255
+ filter — the CLI never resolves a default, checks a placeholder, or merges a
256
+ letter.
257
+ - **`reset` needs `--all`** to drop a whole letter: naming nothing must not mean
258
+ everything.
259
+ - **A letter with no blocks cannot be reworded.** Today that is only the
260
+ retired `applicant.reentry`, shown as `— (not editable)`; the sign-in letters
261
+ (category `login`) are rewordable, but their link must stand alone.
262
+ - **Placeholders are an allowlist per block.** An undeclared `{{x}}` throws with
263
+ every finding named; nothing is written.
264
+ - These are tenant-scoped (`--tenant`) and gated on `notifications._self.access`
265
+ (read) / `notifications.mail.configure` (write) — **not** the platform
266
+ `_platform.notifications.monitor` that the delivery log uses.
267
+ - The deviations are **config-as-code** (`notificationLetters`, identity
268
+ `templateId:locale:scopeKey`; the frame is `tenant.notificationChrome`), so
269
+ `config export|set|apply` promote them across environments.
270
+
271
+ Recipe: [playbooks/notifications/reword-a-letter.md](./playbooks/notifications/reword-a-letter.md).
272
+ Model + invariants: `docs/engineering/notifications.md`.
273
+
274
+ ### Addresses (what a node reads, and who produces it)
275
+
276
+ A node reads another node's data only through a full **address** in the field
277
+ that reads it — there are no data edges (`wires`) any more, no form
278
+ implied by the node and no bare keys. Control edges (`next`) only route. The
279
+ producer must run on every path before the reader.
280
+
281
+ | Address | Names |
282
+ |---|---|
283
+ | `$node.<formNode>.admission[.<field>]` | the form instance a form node creates, or one field / export / party leaf of it |
284
+ | `$node.<node>.document` · `.contract` · `.payment` | a document node's newest revision · a resolver contract · a payment |
285
+ | `$task.<task>.<key>` | the value the ONE task `<task>` writes under store key `<key>` |
286
+ | `$derived.<key>` · `$env.applicant.language` | a computed price · a fact about the application |
287
+
288
+ ```bash
289
+ plexus-cli offer workflow node reads --dir ./bundle --node contract [--json] # what arrives: address, origin, config path, producer
290
+ plexus-cli offer workflow node set-input --dir ./bundle --node contract --input schulgeld --address '$derived.schulgeld'
291
+ plexus-cli offer workflow node set-reads --dir ./bundle --node contract --from form --field kind.vorname,kind.nachname
292
+ plexus-cli offer workflow node add --dir ./bundle --type setFlag ... --flag-key vertrag --target '$node.form.admission'
293
+ plexus-cli offer workflow node add --dir ./bundle --type form ... --adopt-form '$node.form.admission'
294
+ ```
295
+
296
+ Address-taking flags: `set-input --address` (short form `--from <formNode>
297
+ --field <path>`), `*-reads` / `*-requires --address` (same short form), `node
298
+ add --reads` / `--require` / `--person` / `--target` / `--adopt-form` /
299
+ `--contract` / `--payment` / engagePush `--form`, `node set --target` /
300
+ `--contract` / `--payment` / `--person` / `--form` (on a resolver contract or
301
+ engagePush), task `--when` / `--reads` / `--documents` (`artifact:<own slot>`,
302
+ `field:<address>`, `document:$node.<node>.document`) /
303
+ `--family-request-fields` / `--family-request-from`, and a record field's
304
+ `"suggest":{"kind":"form","address":"$node.…"}`. Pricing-rule conditions and
305
+ `processStore[].derive.reduction` have no verb: the bundle JSON carries
306
+ `$task.<task>.<key>` identifiers (`$task.geschwisterrang.geschwisterRangSchule >= 3`).
307
+ A malformed address or a bare key is refused with the list of addresses visible
308
+ at the node (`visibleAddressesAt`, the rule the gate applies too); everything
309
+ else is the publish gate, run before writing: `[address/shape|bareIdentifier|unknown|unknownOwner|unknownKey|ownerNotWriter|taskOwnerTaken|notVisible|pathNotInTarget|typeMismatch|notFormInstance|mixedForms|envCohortBound|missing]`.
310
+ Only errors the edit introduces block it. `node rm` refuses while any address
311
+ names the node (`addressesNaming`) and lists config path + address of each.
312
+ A bundle exported before addresses is refused (`[graph/retiredField]`: `wires`, a
313
+ binding with `path`, `adoptForm: true`) — export it again. Recipe:
314
+ [playbooks/offer/addresses.md](./playbooks/offer/addresses.md); model (visibility, `$env`
315
+ vocabulary, the store behind `$task`): `docs/engineering/workflow-engine.md`.
316
+
317
+ ### Countersignature node („Unterschrift (intern)")
318
+
319
+ The school countersigns the contract the family signed: a `countersign` node
320
+ after a checked resolver contract (`production: resolver` +
321
+ `responseStrategy: signedUploadChecked`). Its one row „Vertrag gegenzeichnen"
322
+ books the Träger on the revision its `contract` address names, sends the
323
+ node's `countersigned` letter and routes `countersigned`.
324
+
325
+ ```bash
326
+ plexus-cli offer workflow node add --dir ./bundle --type countersign \
327
+ --id gegenzeichnung --label "Gegenzeichnung" --label-en "Countersignature" \
328
+ --on-edge contract:signed \
329
+ --assign-team schulverwaltung [--title "Vertrag gegenzeichnen" --title-en "Countersign the contract"] [--due-in-days 5] \
330
+ --contract '$node.contract.contract' \
331
+ --notification countersigned=admission.contractCountersigned
332
+ ```
333
+
334
+ Publish rules: `[countersign/assign]`, `[countersign/sourceNotCheckedContract]`,
335
+ `[countersign/twice]`, `[countersign/dueInDays]`, `[address/missing]` (no
336
+ `contract`), `[notification/missingBinding]` (the letter is required). Recipe:
337
+ [playbooks/offer/countersign-node.md](./playbooks/offer/countersign-node.md).
338
+
339
+ ### Staff inputs and the if node
340
+
341
+ Values staff set when they start an application: `graph.staffInputs`
342
+ declares them (v1: `boolean`, a checkbox in „+ Bewerbung"), an `if` node reads
343
+ one in its condition as `$env.staffInput.<key>` and routes `true` / `false`
344
+ (never parks). Every staff start — cockpit, lead conversion,
345
+ `applications start-test --staff-input <key>=true|false` — must set every
346
+ declared input; a self-service start records `false`.
347
+
348
+ ```bash
349
+ plexus-cli offer workflow staff-input set staffApplication --dir ./bundle \
350
+ --label "Mitarbeiterbewerbung" --label-en "Staff application" # --label-de is an alias of --label
351
+ plexus-cli offer workflow staff-input list --dir ./bundle
352
+ plexus-cli offer workflow staff-input remove staffApplication --dir ./bundle
353
+ plexus-cli offer workflow node add --dir ./bundle --type if \
354
+ --id staffCheck --label "Mitarbeiterbewerbung?" --label-en "Staff application?" \
355
+ --on-edge form:standard --condition '$env.staffInput.staffApplication' \
356
+ --outcomes true:review,false:fee # a staff child skips the fee
357
+ plexus-cli offer workflow node set --dir ./bundle --id staffCheck --condition '<expr>'
358
+ ```
359
+
360
+ Publish rules: `[staffInput/*]`, `[if/condition]`, `[if/unroutedOutcome]`; a
361
+ SmartForm, document or rule cannot read a staff input
362
+ (`[address/staffInputConditionOnly]`). Recipe:
363
+ [playbooks/offer/staff-input-if-node.md](./playbooks/offer/staff-input-if-node.md).
364
+
365
+ ### Readiness reads on a workflow node
366
+
367
+ `reads: [Address]` on a `decision`, `review` or document-producing `governedDocument`
368
+ node names the SmartForm fields (`$node.<formNode>.admission.<field>`, one form
369
+ per list) a human reads before the node acts — for an
370
+ **uploaded** contract the fields staff copy into it, since an upload
371
+ binds no field. The readiness gate holds the node's actions while one of them has
372
+ an open correction or is empty where the form requires it; once the document is
373
+ issued they are **consumed** (a correction is refused until it is rescinded).
374
+
375
+ ```bash
376
+ plexus-cli offer workflow node set-reads --dir ./bundle --node contract \
377
+ --from form --field kind.surname,kind.geburtsdatum,derivedConstellation # replaces the list
378
+ plexus-cli offer workflow node add-reads --dir ./bundle --node contract --address '$node.form.admission.kind.homeAddress'
379
+ plexus-cli offer workflow node remove-reads --dir ./bundle --node contract --address '$node.form.admission.kind.homeAddress'
380
+ plexus-cli offer workflow node set-reads --dir ./bundle --node contract --clear
381
+ plexus-cli offer workflow node list --dir ./bundle # the `reads` column
382
+ ```
383
+
384
+ Addresses are checked **offline** against the form their owner node pins, by the
385
+ same `[address/*]` / `[readiness/*]` rules and the same per-form-node field
386
+ universe publish uses (`readinessUniverse`): a field the form lacks, a field
387
+ inside a repeated block, a duplicate, two forms in one list, a form that does not
388
+ run before the node, or `reads` on a node the gate does not govern refuses the write. Only
389
+ errors the edit *introduces* block it; errors the bundle already carried are
390
+ printed as warnings. `offer validate` runs the same rules (it used to skip them
391
+ offline), and `offer plan` prints one `~reads:<node>` row per node with the
392
+ addresses added and removed. Recipe: [playbooks/offer/declare-node-reads.md](./playbooks/offer/declare-node-reads.md).
393
+
394
+ ### Completeness check (documents owed before the process ends)
395
+
396
+ `completenessCheck` holds the process until the SmartForm fields it `requires`
397
+ are there, by a deadline; entered with nothing missing it completes at once.
398
+
399
+ ```bash
400
+ # --require: ≥ 1, repeatable · one of --deadline-days/--deadline-until ·
401
+ # --guest-role and --person: both or neither · the `requested` letter is required
402
+ plexus-cli offer workflow node add --dir ./bundle --type completenessCheck \
403
+ --id nachreichen --label "Vollständigkeitsprüfung" --label-en "Completeness check" \
404
+ --require '$node.form.admission.kind.masernschutz,$node.form.admission.kind.geburtsurkunde' \
405
+ --deadline-days 14 \
406
+ --guest-role gasthoerer --person '$node.form.admission.beneficiary' \
407
+ --notification requested=admission.documentsRequested \
408
+ --outcomes rejected:joinAbsage,absage:endAbsage
409
+ plexus-cli offer workflow node set-requires|add-requires|remove-requires --dir ./bundle --node nachreichen (--address '<address>,…' | --from form --field <path>,…)
410
+ plexus-cli offer workflow node set --dir ./bundle --id nachreichen [--deadline-days n | --deadline-until d] [--guest-role r --person p | --guest-role ""]
411
+ ```
412
+
413
+ `--notification <event>=<templateId>` works on every `node add` (it writes the
414
+ same binding `set-notification` does); it is needed in the same call whenever the
415
+ type declares an event **required**, since `node add` validates before writing.
416
+ Nothing is defaulted: no deadline, no person, no letter, no form — `requires` and
417
+ the guest role's person name the form they read by address. The node's
418
+ `[completenessCheck/*]` rules run offline (field keys against the carried form);
419
+ the tenant role catalog (`unknownRole`, `nonLeafRole`) and the letter catalog only
420
+ at `offer apply --publish`. `*-requires` edits behave like `*-reads` (only errors
421
+ the edit introduces block it; removing the last address is refused). Recipe:
422
+ [playbooks/offer/completeness-check.md](./playbooks/offer/completeness-check.md).
423
+
424
+ ### Tasks on a workflow node
425
+
426
+ `node.tasks[]` are the composed tasks a node spawns on enter. `task add|set|rm`
427
+ edits one of them by `--node` + `--key`; `set` changes only the flags it is given.
428
+
429
+ ```bash
430
+ plexus-cli offer workflow node task add --dir ./bundle --node reviewEingereicht --key einschaetzung \
431
+ --title "Einschätzung abgeben" [--title-en "…"] --team oeffentlichkeitsarbeit [--kind task|approval] \
432
+ [--due-in-days 3] \
433
+ [--blocks aufnahme:decision | --blocks <siblingKey>] \
434
+ [--result freetext|recommendation|choice|record|pricedItem|reduction|appointment] [--option key=Label[|English]]… \
435
+ [--writes '$task.<thisKey>.<storeKey>'] [--prices '$derived.<key>'] [--item <catalogKey>] \
436
+ [--result-label "…" [--result-label-en "…"]] \
437
+ [--text-required | --no-text-required] [--chat all|team:<group>|<channelKey>] \
438
+ [--when '$node.<form>.admission.<booleanExport>' --on-condition-return respawn|stayClosed] \
439
+ [--reads '$node.<form>.admission.a,…'] [--documents 'artifact:<slot>,field:<address>,document:<address>'] \
440
+ [--family-request-fields '<address>,…' | --family-request-from '$node.<form>.admission'] \
441
+ [--locks-evidence] [--description "…" [--description-en "…"]] \
442
+ [--files | --no-files] [--optional "Keine Einschätzung abgeben" [--optional-en "No assessment"]]
443
+ plexus-cli offer workflow node task set --dir ./bundle --node <n> --key <k> [any flag above] \
444
+ [--clear-blocks] [--clear-result] [--clear-when] [--clear-reads] [--clear-locks-evidence] [--clear-documents] [--clear-description] [--clear-family-request] [--clear-optional]
445
+ plexus-cli offer workflow node task rm --dir ./bundle --node <n> --key <k>
446
+ ```
447
+
448
+ `--blocks <templateKey>` is a sibling on the same node; `<nodeId>:<templateKey>` a
449
+ template on a later node (stored as `blocks.node` only when it differs from `--node`).
450
+ `--option` replaces its list. `--locks-evidence`: once the task is
451
+ decided, its evidence (`--reads` + the fields behind `--when`) takes no correction, flag
452
+ or cohort move until its team reopens the task (`applicationTasks.reopen`). The CLI refuses malformed input in German
453
+ (unknown result type, `--option` on a non-choice result, `--text-required` on free text,
454
+ `--chat external`, …); the graph rules
455
+ (`[workItems/*]`, `[taskResult/*]`) are the publish validators, run before every write —
456
+ only errors the edit introduces block it. `rm` is refused while another task's `blocks`
457
+ (or an optional action) names the task, and lists those dependents. Output: a
458
+ `before`/`after` field diff; `--json` → `{action, node, key, before, after, changes,
459
+ dropped}`. Recipe: [playbooks/offer/node-tasks.md](./playbooks/offer/node-tasks.md).
460
+
461
+ `--optional "<Knopf>"` makes a task OPTIONAL: nothing waits for it (publish
462
+ refuses it together with `blocks`, `gatesNode`, `locksEvidence`, `completableIf`), its
463
+ holder may close it without a result with that button, and a decision made while it is
464
+ open makes it „hinfällig". `--files` lets a free text / recommendation / choice that writes
465
+ no value (`result.writes`) take files — text and files become one message of the result's chat.
466
+
467
+ A result with a value (`choice`, `pricedItem`, `reduction`) writes it under the task's own
468
+ address — `--writes '$task.<thisKey>.<storeKey>'` (stored as the bare `result.writes`;
469
+ another task's address or a path is refused) — and names it with `--result-label`
470
+ (`--result-label-en`; without it the German stands in). `--item <catalogKey>` (pricedItem)
471
+ names the billing item it prices; `--prices '$derived.<key>'` (reduction) the derived price
472
+ it lowers. A kind change drops what no longer fits and lists it under `dropped`.
473
+
474
+ `node optional-action set|remove --dir <bundle> --node <decision> --key <k>` authors one
475
+ entry under „Weiteres" (a `spawnTasks` binding): `--label [--label-en]`, `--tasks a,b`
476
+ (keys of the node's tasks), `--trigger <group>` (who may press it), `--repeatable`,
477
+ `--description [--description-en]`, `--clear-trigger`, `--clear-description`. `set`
478
+ creates it when new (`--label` + `--tasks` required); `remove` is refused while
479
+ `requiresOneOf` names the key. Recipe:
480
+ [playbooks/offer/optional-assessment.md](./playbooks/offer/optional-assessment.md).
481
+
482
+ ### Notifications on a workflow node
483
+
484
+ A node **type** declares at which **events** it can write to a family and with
485
+ which typed arguments; the authored **node** binds a letter to one of them.
486
+ Neither half can invent the other — a school that says nothing on a rejection
487
+ simply binds nothing.
488
+
489
+ ```bash
490
+ plexus-cli offer workflow node set-notification --dir ./bundle \
491
+ --node freigabe --event rejected --template admission.rejected
492
+ plexus-cli offer workflow node set-notification --dir ./bundle \
493
+ --node contract --event issued --template admission.documentIssued
494
+ # --literal amount=12000 # a fixed value
495
+ # --disabled # authored, switched off
496
+ plexus-cli offer workflow node clear-notification --dir ./bundle --node freigabe --event rejected
497
+ plexus-cli offer workflow node list --dir ./bundle # the `letters` column
498
+ ```
499
+
500
+ An argument **binds itself** when exactly one of the event's arguments (or an
501
+ ambient one such as `tenantSlug`) carries its name and a compatible type;
502
+ `--literal` exists for what the event cannot supply. The addresses a node reads
503
+ are not a source — no executor hands them to the send, so the gate does not offer
504
+ them. Like every other node mutator,
505
+ both commands run the real publish-gate validators before writing — so an event
506
+ the node type does not declare fails here. What offline validation cannot see is
507
+ the letter **catalog** (`analysis/validators.ts` must stay free of the
508
+ notification registry so the browser IDE and this CLI can import it), so an
509
+ unknown `--template` id and an unresolvable argument are caught server-side at
510
+ `offer apply --publish`. Run it.
511
+
512
+ ### Generic escape hatch
513
+
514
+ ```bash
515
+ plexus-cli call parties:listForMainPage client=test q="Müller"
516
+ ```
517
+
518
+ Without `--kind`, `call` runs only a query: it looks the function up in the offline spec
519
+ below and refuses a mutation or action by name (a write is always an explicit
520
+ `--kind mutation|action` — the default environment may be prod). A function the spec does
521
+ not know (newer than the snapshot, or a typo) needs `--kind`.
522
+
523
+ `call` also checks the arguments against the spec BEFORE the request: a missing required
524
+ argument, an unknown one or a wrong type is named with the expected type
525
+ (`missing configKey (string)`). A production deployment would answer them only with
526
+ „Server Error" and a GlitchTip event. A value the spec types as text keeps its text
527
+ (`q=2026` stays `"2026"`). A function the snapshot does not know (explicit `--kind`) is
528
+ called unchecked, with a note on stderr.
529
+
530
+ A refusal prints as `[CODE] <German sentence>` on stderr (every command, not only
531
+ `call`): the server sends `{ de, en }` and the CLI shows the German, which is
532
+ what playbooks quote. A stored text in a result (a failure, a reason) prints as its German
533
+ in tables and as the raw `{ de, en }` under `--json`.
534
+
535
+ `functions` / `describe` read a committed snapshot (`spec.snapshot.json`).
536
+ Regenerate it with the tool's in-repo `spec` script (run from
537
+ `app/tools/plexus-cli/`) after changing a public function's arguments, return
538
+ validator, kind, or adding/removing one. No backend needed; the `cliSpecParity`
539
+ test fails until the committed file matches the code:
540
+
541
+ ```bash
542
+ pnpm spec # = tsx scripts/regen-spec.ts (imports app/convex/**, exportArgs/exportReturns of every public function → spec.snapshot.json)
543
+ ```
544
+
545
+ The snapshot drives display and `call`'s query check (`call` builds its reference
546
+ directly). A stale snapshot makes `call` ask for `--kind` on a new function.
547
+
548
+ ## Offer / admission CRUD
549
+
550
+ **Model.** An offer's identity = **name + unit**. The title is the bare program name
551
+ (`"Kosmetik"`); the school/location is the **pedagogic-unit link** (the namespace).
552
+ **Runs** (Schuljahre) and **levels** (Klassenstufen) are settings of the offer. A
553
+ **smartform** and a **workflow** are optional later stages that make the offer
554
+ *applyable* — a draft offer needs neither.
555
+
556
+ **Lifecycle:** `create (name + unit) → add runs / levels / capacity → [smartform → workflow → applyable]`.
557
+
558
+ ### Imperative CRUD
559
+
560
+ ```bash
561
+ plexus-cli --env <env> offer create --slug kosmetik-bs --title "Kosmetik" --title-en "Cosmetics" --unit <unit key>
562
+ plexus-cli offer show --slug kosmetik-bs # title, unit, levels, runs, capacity, state
563
+ plexus-cli --env <env> offer set --slug kosmetik-bs --title "Kosmetik" --title-en "Cosmetics" --unit <unit key>
564
+ plexus-cli offer list [--all] # --all includes archived (soft-deleted)
565
+
566
+ plexus-cli --env <env> offer level add --slug kosmetik-bs --name "Jahr 1" --name-en "Year 1" --grade 1 [--key jahr-1]
567
+ plexus-cli --env <env> offer level rename --slug kosmetik-bs --level jahr-1 --name "Jahrgang 1" --name-en "Year 1"
568
+ plexus-cli offer level remove|restore --slug kosmetik-bs --level jahr-1
569
+
570
+ plexus-cli --env <env> offer run add --slug kosmetik-bs --name "Schuljahr 2026/27" --name-en "School year 2026/27" [--key 2026-27] --start 2026-08-01 --capacity 20
571
+ plexus-cli offer run set|archive|restore --slug kosmetik-bs --run 2026-27
572
+
573
+ plexus-cli --env <env> offer capacity set --slug kosmetik-bs --run 2026-27 --level jahr-1 --capacity 15|unlimited [--open|--close]
574
+
575
+ plexus-cli offer delete|restore --slug kosmetik-bs # soft-delete (archive) / restore
576
+ ```
577
+
578
+ **Deletes are soft (archive) — restorable, never orphaning.** `offer delete`,
579
+ `offer run archive`, and `offer level remove` set an archive marker: the row stays and
580
+ keeps resolving for anything that references it (offering cells, applications), but the
581
+ item is hidden from active lists and is **not applyable** in the portal. `restore`
582
+ clears the marker. There is **no hard delete**. `offer level remove` is **refused**
583
+ (`[stage/hasActiveApplications]`) while an active application sits on the level —
584
+ rename it instead; open leads on it only print a warning.
585
+
586
+ A level's identity is its **key** (`offer level add --key`, or derived from `--name`
587
+ when omitted — and it keeps that value after a rename); a run's is its key too
588
+ (`offer run add --key`), a unit's its config key. `--level`, `--run` and `--unit`
589
+ take those keys, never a name. The bundle carries the same keys; see "Stage
590
+ identity" below.
591
+
592
+ **Names a reader sees are German AND English.** Every flag that sets one
593
+ has an English twin (`--title-en`, `--name-en`, `--label-en`, `--program-name-en`);
594
+ creating needs both. Changing only the English keeps the German. Changing only
595
+ the German follows the one edit rule of every config text (`editedLocalizedText`):
596
+ refused when the stored English is a real translation (it would describe the old
597
+ German); an untranslated English (blank, or a copy of the German) becomes blank —
598
+ the German is never copied into it. A name is written by a mutation that refuses
599
+ a blank language, so for a name the CLI refuses that up front: a German rename
600
+ always needs its English twin (`--name-en`, `--title-en`, `--label-en`).
601
+
602
+ ### Declarative config-as-code (bundles, for promotion)
603
+
604
+ Offers are also versioned bundles on disk — use this for cross-env promotion or a
605
+ reviewable whole-offer change.
606
+
607
+ **A real tenant's bundle is never committed.** Prod is its source of truth: export
608
+ it from prod into a scratch dir OUTSIDE the repo, edit, `plan`, `apply` — recipe:
609
+ [edit-live-tenant-offer](playbooks/offer/edit-live-tenant-offer.md). Always pass `--env`
610
+ (the default is prod) and `--out` (the default `offers/<tenant>/<slug>` is relative to the
611
+ current directory). Staging gets a real tenant's bundle only by an explicit
612
+ `export --env prod` → `apply --env staging`. Only the `test` tenant's offers are in git,
613
+ and those come from the seed (`app/config/templates/test/**`), not from a bundle dir.
614
+
615
+ ```
616
+ offers/<tenant>/<offerSlug>/
617
+ bundle.yaml # index — module, tenant, slugs, label, links, program, pinned
618
+ manifest.json # == saveManifestDraft.data (incl. progressLayout)
619
+ smartform.json # OPTIONAL — == saveSmartFormDraft.definition (absent for a draft offer)
620
+ workflow.json # OPTIONAL — { graph, progressWiring } (absent for a draft offer)
621
+ ```
622
+
623
+ ```bash
624
+ plexus-cli offer export --tenant test --slug grundschule-havelland --out offers/test/gymnasium
625
+ # edit bundle.yaml (slugs/label/unit/stages/runs) + the JSON blobs
626
+ plexus-cli offer validate --dir offers/test/gymnasium # offline, real publish gate
627
+ plexus-cli offer plan --dir offers/test/gymnasium # stamp resolver pins from the env + validate + remote↔local diff (smartform/workflow = ∅ when absent)
628
+ plexus-cli --env <env> offer apply [--publish] --dir offers/test/gymnasium
629
+ plexus-cli offer status --tenant test --slug gymnasium-havelland # applyable?
630
+ ```
631
+
632
+ **Resolver pins are stamped from the environment.** A contract node pins
633
+ `resolver: { key, revision }`; publish stamps what that sealed revision says
634
+ (`inputSchema`, `parties`, `schemaDigest`, and `parts` for a combined
635
+ generator). `offer plan` and `offer apply` fetch the same stamp
636
+ (`workflow:getResolverPinStamps`) and write it onto the in-memory bundle
637
+ before validating, so a new combined pin produces `$node.<n>.contracts`
638
+ offline exactly as it will after publish, and the generator's parameters are
639
+ checked against the node's inputs. A pin the environment cannot stamp (no such
640
+ revision, not sealed) is a blocking `[resolver/pinNotStamped]` issue.
641
+ `offer validate` stays offline: it warns about each unstamped pin, and its
642
+ `contract` / `contracts` address checks on such a node are only as good as
643
+ that guess.
644
+
645
+ **Stage identity.** `program.stages[]` entries are `{ key, name, gradeLevel? }`; `key`
646
+ is required (`offer validate`). `offer apply` matches levels **by key**: a changed name
647
+ renames the same row, a new key adds a level, a removed key archives it (refused while
648
+ an active application sits on it), a re-listed archived key restores it, and the array
649
+ order is the display order. `offer plan` lists each change as `~stage` / `+stage` /
650
+ `-stage`, and marks a `-stage` the apply would refuse (`REFUSED: n active
651
+ application(s)`). Rules: `docs/engineering/config-as-code/README.md` → "Stage identity";
652
+ recipe: [Rename a program stage](./playbooks/config/rename-program-stage.md).
653
+
654
+ **Capacities.** Each `program.runs[]` entry carries its cells as
655
+ `capacities: { <stageKey>: { isOpen, capacity } }` (`capacity`: whole number,
656
+ `unlimited`, or `null` = unconfigured). Export writes every cell; `offer plan` shows each
657
+ changed cell as `~cap <run>×<stage> from → to`; `offer apply` writes only those (listed
658
+ cells are authoritative, unlisted ones untouched). Recipe:
659
+ [Set an offer's seat capacities](./playbooks/offer/set-offer-capacities.md).
660
+
661
+ A **workflow-less draft** exports/applies a **manifest-only** bundle (no
662
+ `smartform.json` / `workflow.json`). Apply order mirrors the seed
663
+ (`init/seed/admission/seedAdmissionPortal.ts`): manifest → scaffold (pedagogy-unit link
664
+ + program spine) → smartform (if present) → workflow (if present). Drafts are written
665
+ **only on a canonical-JSON diff** (byte-equal blob = no-op), but the **offer flip is
666
+ decided against the LIVE generation**: `--publish` releases whenever the draft says
667
+ something the live head does not, even when your bundle changed nothing. `--stage
668
+ internal` stages the draft as the testable candidate instead of releasing it, and
669
+ `offer status` prints the draft / internal / live revisions plus whether a release is
670
+ pending. Recipe: [Release an offer bundle](./playbooks/offer/publish-offer-bundle.md).
671
+ The imperative commands and `offer apply` go through the **same** backend mutations —
672
+ one write path, no duplication.
673
+
674
+ > **New schools:** create a brand-new school + its `pedagogy_units` bridge with
675
+ > `offer unit create --name "<School>" --name-en "<English>"` (or upgrade an existing unit with
676
+ > `offer unit ensure-pedagogy --unit <unit key>`); then `offer create --unit <unit key>`
677
+ > links it (a unit made by `offer unit create` has no config key yet — address it by
678
+ > its URL slug until config-as-code adopts it) (the link path also ensures the bridge). A unit must still belong to a
679
+ > tenant legal entity (auto-resolved from the tenant's first legal entity).
680
+
681
+ ## Tenant config-as-code (`config` command group)
682
+
683
+ The `config` group drives the config-as-code engine (a tenant's **Stammdaten shape**:
684
+ custom fields, lists, display groups, roles + role-field bindings, foundation, and search
685
+ config) against any environment. Tenant config is **declarative + DB-authoritative** — no
686
+ reseeds to change live config. The model/architecture lives in
687
+ [`docs/engineering/config-as-code/`](../../../docs/engineering/config-as-code/README.md);
688
+ the copy-paste task recipes live in [`playbooks/config/`](./playbooks/config). This section
689
+ is the **command reference**.
690
+
691
+ All commands take `--env <local|staging|prod>` and `--json`. They call the **public,
692
+ gated** surface (`convex/config/api.ts`, one gate `convex/config/access.ts`), so the token
693
+ owner must hold `_platform.config.read` (read/dry-run) or `_platform.config.manage` (commit).
694
+ The local rdu admin key does **not** satisfy the gate — use a token even locally (see Auth).
695
+
696
+ **A school's own administrator.** The tenant rights `administration.config.read` /
697
+ `.manage` (part of the derived `tenant_admin`; held tenant-wide) open `config export`, `config apply`,
698
+ `config set` and `config targets --tenant` for **that tenant only**. A tenant-scoped apply
699
+ is refused (`FORBIDDEN`, naming the field) when it would create a tenant, use
700
+ `--from blueprint`, pass `--allow-destructive`, change a platform-owned setting — every
701
+ `tenant.*` key except `branding`, `brandingAssets`, `notificationChrome` (modules,
702
+ `defaultApplicantGroupKey`, `mailLevel`, `magicLinkLogin`, terms, …) or the import `source`
703
+ — name a `foundation.users` address that is not an active member with a login, or put a
704
+ `_platform.*` right in a group; changing groups or `foundation.users` additionally needs
705
+ `administration.permissions.manage` / `administration.users.manage`. `wipe`, `prune-offers`, `--scope platform` and setup mode
706
+ stay platform-only. Recipe:
707
+ [playbooks/users/cli-access-for-tenant-admin.md](./playbooks/users/cli-access-for-tenant-admin.md).
708
+
709
+ ```
710
+ plexus-cli config show # resolved connection for the env (no network)
711
+ plexus-cli config targets --tenant <slug> [--json] # the registry + live per-tenant counts
712
+ plexus-cli --env <env> config apply --tenant <slug>|--scope platform \
713
+ --from <blueprint|env:<src>|snapshot:<path>> \
714
+ [--confirm] [--allow-destructive] \
715
+ [--output <file>] [--quiet] [--json]
716
+ plexus-cli --env <env> config set --tenant <slug> --target <id> --field <path> --value <v> [--confirm] [--json]
717
+ plexus-cli config export --tenant <slug> [--out <path>] # live → app/config/.dev/<slug>/config.json
718
+ plexus-cli --env <env> config wipe --tenant <slug> --target <id|all> [--cascade] [--confirm] [--allow-destructive] [--json]
719
+ ```
720
+
721
+ Assignment rules are **not** a tenant config target: the rule is part of each offer's
722
+ workflow (`graph.assignmentRules` in the bundle's `workflow.json`) and travels with
723
+ `offer export` / `offer apply`. See `playbooks/offer/assignment-rule.md`.
724
+
725
+ **Two granularities, one gate.** A surgical single-field `set` and a whole-tenant `apply` are
726
+ the same engine — same validators (`tenantConfig/lib/validate.ts`), same diff/patch primitive.
727
+ `set` patches one field of one existing row; it **cannot delete a row** (use export → edit →
728
+ apply for removals).
729
+
730
+ ### `apply` — the core verb
731
+ - **Dry-run unless `--confirm`.** The dry-run output *is* the plan: aggregate
732
+ `created / updated / deleted / unchanged` counts, plus:
733
+ - `+ create <target> <key>` — each row the apply **inserts** (admission custom fields /
734
+ derived attributes included), so `created` is exactly the number of these rows. A
735
+ member of a permission group is named `<group>/<config key or login address>`
736
+ (`foundation.permissionGroups.members`). A deployment that predates the list prints one
737
+ `+ create (unnamed)` line instead.
738
+ - `~ update <target> <key>` — each config row the apply **patches** (admission custom
739
+ fields / derived attributes included, dry run too); an idempotent row counts as
740
+ unchanged, so `updated` is exactly the number of these rows.
741
+ - `- delete <target> <key>` — each config row the reconciler **prunes** because it is absent
742
+ from the source (search targets/filters/options, result icons, role-fields, target
743
+ requirements, template placeholders). These need **no** `--allow-destructive`.
744
+ - `- orphan <target>/<table> <key>` — rows in the five upsert-only tables (display-groups,
745
+ lists, custom_fields, roles, permission_groups) the reconciler will **not** auto-delete;
746
+ labelled *would destroy* and removed only with `--confirm --allow-destructive`.
747
+ - `~ slug units/<key> <from> → <to>` — an existing unit whose config `slug` moves its URL.
748
+ The old `/e/units/<from>` (and `?unit=<from>`) no longer reaches this unit — there is no
749
+ redirect, and a unit created later may take `<from>`.
750
+ A slug another unit holds fails the apply with `[unit/slugTaken]`.
751
+ - **A committing apply can return secrets.** If the config carries `foundation.users`,
752
+ every listed user that has no login account yet gets one **minted here**, and its
753
+ generated password is printed as a `+ account <email> password: …` row — once, because
754
+ the server keeps only the hash. So `apply --confirm` on such a tenant is not safe to run
755
+ in a shared terminal or a pasted log unless you redirect them:
756
+ - `--output <file>` — append each `email,password` to that CSV (header written when the
757
+ file is new/empty). Same flag, same format, same append semantics as `users provision`.
758
+ - `--quiet` — keep the plaintext off stdout (the row then reads `password: (not echoed)`);
759
+ use it **with** `--output`, or the password is gone.
760
+ - A **dry run mints nothing**: the flags are inert there, and `--output` neither creates
761
+ nor touches the file. The plan instead shows `! no account <email>` per user who *would*
762
+ get one.
763
+ - `--from blueprint` — the repo template (only `test` today).
764
+ - `--from env:<src>` — **cross-env promote**: opens a second client for `<src>`, exports its
765
+ live config, and applies it inline to `--env` (re-plans against the target's live state).
766
+ - `--from snapshot:<path>` — apply a `.dev` JSON snapshot.
767
+ - `--scope platform` — platform-scope config (a stub today; no platform targets yet).
768
+
769
+ JSON shape: `{ tenant, dryRun, counts: {created,updated,unchanged,deleted}, orphans: [{target,table,key,id}], deletions: [{target,key}], updates: [{target,key}], slugChanges: [{unitKey,from,to}], accounts: {created, minted: [{email,password}], pending: [email]}, destroyed? }`.
770
+ Note that `--json` prints `accounts.minted` verbatim — `--quiet` governs the table only,
771
+ exactly as on `users provision`.
772
+
773
+ ### `set` — surgical edit
774
+ `--target` is a setField locator (`display-groups`, `fields`, `lists`, `roles`, `units`,
775
+ `permission-groups`, `legal-entities`, `search-filters`, `party-result-icons`) — these differ
776
+ from the `config targets` registry ids. `--field` is a dot-path (`label.de`). The whole
777
+ resulting config is validated before the inline apply, so an invalid edit fails loud and writes
778
+ nothing.
779
+
780
+ ### `export` — cross-env snapshot producer
781
+ Reconstructs a full `TenantConfigDefinition` from live rows and writes
782
+ `app/config/.dev/<tenant>/config.json` (gitignored). The round-trip is **exact** — feeding the
783
+ export back through `apply --from snapshot:` yields all-unchanged — so it is how a real tenant's
784
+ config moves between environments. **Prod is the source of truth for every real tenant**:
785
+ export from `--env prod`, never from a copy in the repo — no real tenant's config is
786
+ committed (the former one-time snapshot fixtures are gone; a test fails the gate on any real
787
+ tenant's file under `app/config/`). Staging gets it only by an explicit
788
+ `config apply --env staging --from env:prod` (or a prod snapshot).
789
+
790
+ ### `files` — the tenant file library (blank templates)
791
+ A school's Vorlagen (`tenant_files`) ride the config as `files[]`: `key`, `label`,
792
+ `filename`, `mimeType`, and the content **by hash** (`sha256`, `sizeBytes`) — never inline.
793
+ An export from before file references (`fileName` / `size`) is refused with `[config/fileRefRenamed]`:
794
+ export again. `export` also downloads each file to `files/<key>/<filename>` beside `config.json` and
795
+ writes its `path`; on `apply --from snapshot:` the file on disk decides the hash. `apply`
796
+ uploads only the files whose hash the target does not hold (a dry run uploads nothing and
797
+ lists them), `--from env:` downloads them from the source env, and the `test` blueprint's
798
+ bytes are bundled server-side. A stored file absent from `files` is reported as an **orphan**
799
+ and removed only with `--allow-destructive` — then still refused with `[file/inUse]` while any
800
+ form version names it. Library writes accept only uploads staged for this tenant's library
801
+ (a `tenantFiles` upload ticket, bound with `uploads.registerUpload`); a `filename` is one path segment. Direct verbs:
802
+
803
+ ```bash
804
+ plexus-cli --tenant <slug> files list
805
+ plexus-cli --env <env> --tenant <slug> files put <key> <path> [--label "…" --label-en "…"] [--file-name …] # new key: both languages
806
+ plexus-cli --env <env> --tenant <slug> files remove <key> # alias: files rm
807
+ plexus-cli offer form field attach --dir <bundle> --key <field> --file-key <key> [--render download|inlineLink] [--label … --label-en …]
808
+ plexus-cli offer form field detach --dir <bundle> --key <field> --file-key <key>
809
+ ```
810
+
811
+ Recipe: [`playbooks/config/attach-a-template.md`](./playbooks/config/attach-a-template.md).
812
+
813
+ ### `wipe`
814
+ Without `--confirm` it is a dry run that prints per table what it would clear (and any block) and deletes nothing; `--cascade` also clears the dependent data target;
815
+ the heavy tier (the `masterdata` and `contract-setup` data targets, the `foundation` config target, or `--target all`)
816
+ additionally needs `--allow-destructive`. The config↔data interlock blocks a config wipe with
817
+ dependent live data unless `--cascade`. `--target all` is the teardown: it purges the applications,
818
+ drains every target, then deletes the tenant row. Every wipe deletes the stored files only its rows
819
+ held (the logo stays: sent mail links it). See [`playbooks/config/wipe-tenant-config.md`](./playbooks/config/wipe-tenant-config.md).
820
+
821
+ ### Migrations are not a `config` verb
822
+ Renames / field-type changes — anything that changes the **shape** of existing rows — run
823
+ through the standard migrations lane (`convex/migrations.ts` + `migrations:runPending`),
824
+ deployment-globally, **before** `bootstrap`/`apply`. `apply` only moves config *values* into the
825
+ shape that already exists. For a manual local run: `npx convex run migrations:runPending`.
826
+
827
+ ### Deploy protocol (local + steady state)
828
+ - **Local dev:** `pnpm dev` on a fresh DB runs `config/bootstrap`, which idempotently applies the
829
+ template tenant(s) + demo. Develop against the `test` template; change it with
830
+ `config apply --tenant test --env local --confirm` (no wipe).
831
+ - **Staging / prod (every deploy):** CI runs, after `migrations:runPending`,
832
+ `npx convex run config/bootstrap:bootstrap '{"demo":<true on staging|false on prod>}'`.
833
+ `bootstrap` is **idempotent and non-destructive** — it applies `--scope platform` + the
834
+ template tenants (`TEMPLATE_TENANT_KEYS = ["test"]`) + (staging) demo. **Real tenants are never
835
+ touched** by CI; establish/update them manually (see the playbooks).
836
+ - **Setup mode** (platform-admin right-rail tab) is the in-app data-plane half of the onboarding
837
+ loop: edit config (CLI) → load N sampled rows → test → wipe the subset → adjust → reload.
838
+
839
+ ### Auth
840
+ Config commands need a platform-admin **JWT**; point your `~/.config/agent-tools/plexus.yml`
841
+ `<env>` entry at it. Locally, mint one for a seeded platform admin (`DEV_MODE`):
842
+
843
+ ```bash
844
+ npx convex run --url <convex-url> --admin-key <key> apiTokens:devSeedToken \
845
+ '{"email":"admin@plexus.swop.schule","name":"config-cli","plaintext":"plx_..."}'
846
+ ```
847
+
848
+ After adding new `_platform.*` perms, re-sync the admin's row (locally: `pnpm seed`; staging/prod:
849
+ call `init/seed/seedPlatformAdmins:seedPlatformAdminMut` per admin). For automation that
850
+ legitimately bypasses the user gate (CI, deploy bootstrap), call the **internal** engine
851
+ functions with the admin key rather than the public `config/api:*`.
852
+
853
+ ## Architecture
854
+
855
+ ```
856
+ core/ # GENERIC, brand-neutral, zero backend-type imports
857
+ transport.ts auth.ts jwt-cache.ts config.ts output.ts spec.ts command.ts
858
+ plexus/ # BRANDED — imports backend types + validators
859
+ branding.ts client.ts command.ts commands/* modules/admission.ts offer/*
860
+ cli.ts # clipanion bootstrap — registers every command group
861
+ ```
862
+
863
+ See `CLAUDE.md` in this directory for the design rules (the thin-client /
864
+ "where does a change belong" principle).