@smartkomm/plexus-cli 0.1.366 → 0.1.367

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.
package/dist/cli.mjs CHANGED
@@ -4971,7 +4971,7 @@ The library is part of the tenant config (\`files\`):
4971
4971
  \`\`\`
4972
4972
 
4973
4973
  - \`config export\` downloads every file to \`files/<key>/<filename>\` beside
4974
- \`config.json\` and writes \`path\`. Swap a file on disk and \`config apply --from
4974
+ the config file and writes \`path\`. Swap a file on disk and \`config apply --from
4975
4975
  snapshot:\u2026\` uploads it (the file on disk decides the hash).
4976
4976
  - \`apply\` uploads **only** files whose hash the target does not hold; a dry run
4977
4977
  uploads nothing and lists them as \`~ file files/<key>\`.
@@ -5057,9 +5057,9 @@ unchanged tenant show the same hashes; a different hash means the setup changed.
5057
5057
  - The command refuses an \`--out\` that already exists or lies inside a git working tree. It
5058
5058
  writes into \`<out>.partial\` and renames it at the end; if a run stops half-way (with
5059
5059
  \`--all-tenants\`, one failing tenant stops the run), remove \`<out>.partial\` before retrying.
5060
- - Each run records one export on the server; the stored copy and the downloaded \`setup.json\`
5060
+ - Each run records one export on the server; the stored copy and the downloaded setup file
5061
5061
  are the same bytes.
5062
- - \`setup.json\` carries every part (\`partOrder\`) and \`platformRefs\`, the contract input keys the
5062
+ - The setup file carries every part (\`partOrder\`) and \`platformRefs\`, the contract input keys the
5063
5063
  tenant names; a restore onto another deployment needs those first
5064
5064
  ([platform export](platform-setup-export.md)).
5065
5065
  - To change a tenant's configuration, use the config export \u2192 edit \u2192 apply recipe; this export
@@ -5349,7 +5349,7 @@ plexus-cli platform generator input-key list --env <env> # the restor
5349
5349
  an entry the target already deprecated stays deprecated, so an older export restores cleanly.
5350
5350
  - \`--prune\` is refused for the registry: sealed revisions name its keys. Deprecate an entry
5351
5351
  instead (\`platform generator input-key deprecate\`).
5352
- - A tenant's \`setup.json\` lists the platform keys it names (\`platformRefs\`). \`setup plan\` of a
5352
+ - A tenant's setup file lists the platform keys it names (\`platformRefs\`). \`setup plan\` of a
5353
5353
  tenant shows a key the target lacks as "missing platform key", and \`setup apply\` refuses until
5354
5354
  the platform export is applied \u2014 restore the platform first, then the tenants.
5355
5355
  - \`--platform\` and \`--all-tenants\` exclude each other; a platform export directory is refused
@@ -5467,8 +5467,8 @@ after a configuration went wrong, or to set up an empty tenant exactly like the
5467
5467
 
5468
5468
  - \`plexus-cli\` installed; needs a platform operator token (\`_platform.config.manage\` to apply,
5469
5469
  \`_platform.config.read\` to preview).
5470
- - The export directory, complete: \`setup.json\` plus each part's \`files/\` folder. The restore
5471
- targets the tenant named in \`setup.json\`.
5470
+ - The export directory, complete: the setup file plus each part's \`files/\` folder. The restore
5471
+ targets the tenant named in the setup file.
5472
5472
 
5473
5473
  ## Steps
5474
5474
 
@@ -5565,7 +5565,7 @@ Platform-owned: a school's own administrator cannot change it.
5565
5565
  reached yet fails loud (\`[auth/externalSignInRetired]\`) \u2014 run the migration
5566
5566
  (\`migrations:run '{"fn":"migrations:retireReusableSignInLinks"}'\`), never
5567
5567
  edit the row.
5568
- `,"references/config/set-tenant-branding.md":'# Set a tenant\'s external-portal branding\n\n**When to use:** give a tenant\'s public `/e/**` Bewerbungsportal its own white-label\nlook \u2014 brand colors, corner radius, logo size, header style, and font families, plus an\nuploaded logo and uploaded font files \u2014 on staging and/or prod, without a reseed.\n\n## Prerequisites\n\n- `plexus-cli` installed and current (`plexus-cli --help`).\n- A token configured for each target env (`plexus-cli --env <env> config show` prints\n the resolved connection): a platform-admin token holding `_platform.config.manage` (the\n same right that gates `config apply`), or \u2014 for your OWN tenant only \u2014 a tenant\n admin\'s token holding `administration.config.manage` (see\n [CLI access for a tenant admin](../users/cli-access-for-tenant-admin.md)). Such a\n token runs every `plexus-cli branding \u2026` command and `config apply` for its own\n tenant (branding is one of the `tenant.*` settings a school may change); `branding\n show` needs `administration.config.read` at least. The in-app right\n `administration.branding.manage` alone is refused by the CLI. A local admin key\n without a user identity does **not** satisfy this gate.\n- The `plexus-cli branding \u2026` commands must be **live on the target env** first (they\n call backend functions of the same release). A platform operator rolls a release out\n to staging, then prod; only then run the CLI.\n- The tenant **slug** (e.g. `test`). Always **stage on staging first**, verify in the\n browser, then promote to prod.\n\n## The two halves of branding\n\n| Part | Where it lives | How to set it |\n| --- | --- | --- |\n| **Theme tokens** \u2014 colors, radius, logoSize, bannerDensity, filledHeader, websiteUrl, font **families** | `tenant_branding` row columns; config-portable (exported in `tenant.branding`) | `plexus-cli branding set-theme` (surgical) **or** `config apply` (whole-config) |\n| **Logo** | `_storage` id column (a single `primary` slot); carried by config **by hash** (`tenant.brandingAssets.logo`) | `plexus-cli branding set-logo` (one-off upload) **or** `config apply` (bytes from the snapshot / source env) |\n| **Font files** (WOFF2, one per slot `heading` / `body`) | `_storage` id columns; carried by config **by hash** (`tenant.brandingAssets.fontHeading` / `fontBody`) | `plexus-cli branding set-font --slot heading\\|body --file <woff2>` **or** `config apply` |\n\nA `storageId` is deployment-local, so config never carries it. It carries each uploaded\nfile like a library file: `{ sha256, sizeBytes, mimeType }` under `tenant.brandingAssets`, and\n`config export` downloads the bytes beside `config.json` as `branding/<slot>.<ext>`\n(`path` in the entry). `config apply --from snapshot:\u2026` or `--from env:<src>` uploads\nonly the files whose hash the target does not hold; the dry run prints\n`~ brand branding/logo content differs \u2014 would upload`. A missing slot \u2014 or a snapshot\nwithout the block \u2014 leaves the target\'s file untouched. A replaced **logo** file is never\ndeleted (sent mail links it); a replaced **font** file is.\nFonts are served from the app\'s own Convex origin \u2014 **never** point a browser at an\nexternal font host (a private-network host is blocked by the browser; the Google-Fonts\nCDN is a GDPR problem).\n\n## The theme shape\n\nEvery field is optional \u2014 omit a key to fall back to the platform default:\n\n```jsonc\n{\n "colors": {\n "primary": "#1E4BCD", // brand primary \u2192 --color-primary (buttons, rings, filled header)\n "accent": "#0AAA5F", // secondary accent \u2192 --color-accent (links, hovers, dots)\n "background": "#FFFFFF", // portal page bg \u2192 --color-bg\n "foreground": "#111111" // body text \u2192 --color-fg\n },\n "radius": "sharp", // "sharp" | "rounded" | "soft"\n "logoSize": "max", // banner logo height: "sm" | "md" | "lg" | "max" (default lg)\n "bannerDensity": "normal", // "compact" | "normal" | "spacious" (default normal)\n "filledHeader": false, // true \u2192 top nav bar filled with the PRIMARY colour (on-primary text)\n "websiteUrl": "https://www.example-schule.de",\n "fonts": {\n "heading": { "family": "Space Grotesk" }, // family only \u2014 the file is uploaded (set-font)\n "body": { "family": "Lora" }\n }\n}\n```\n\n- `colors.*` are `#RRGGBB` hex strings; `radius`/`logoSize`/`bannerDensity` are the enums above.\n- A font entry is `{ family }`. With an uploaded file for that slot the portal loads it as\n `@font-face` under that family; without one the family must already be available\n (system/bundled). A font `url` is **refused** (`fonts.<slot>.url is no longer\n supported`) \u2014 upload the file instead.\n- Bad values (malformed hex, bad enum, a font `url`) fail loud server-side \u2014 the write\n aborts, no partial state.\n\n## Steps \u2014 the surgical CLI path (recommended)\n\n```bash\n# 1. Inspect current branding (branding + resolved logo URL).\nplexus-cli --env staging --tenant <slug> branding show\n\n# 2. Set the theme tokens from a JSON file (replaces the theme wholesale; leaves the logo).\nplexus-cli --env staging --tenant <slug> branding set-theme --file theme.json\n\n# 3. Upload the logo \u2014 from a local file \u2026\nplexus-cli --env staging --tenant <slug> branding set-logo --file logo.png\n# \u2026 or straight from a URL (fetched + uploaded by the CLI):\nplexus-cli --env staging --tenant <slug> branding set-logo \\\n --url https://cdn.example.com/logo-black.png\n\n# 4. Upload the font files \u2014 the slot\'s family must be set first (step 2), the file is\n# applied under it. WOFF2 only (signature-checked), \u2264 2 MB; a replaced file is deleted.\nplexus-cli --env staging --tenant <slug> branding set-font --slot heading --file heading.woff2\nplexus-cli --env staging --tenant <slug> branding set-font --slot body --file body.woff2\n# (`branding clear-font --slot <slot>` removes a file; the family stays.)\n\n# 5. Verify, then promote to prod (re-run 1\u20134 with --env prod \u2014 never assume prod == staging).\nplexus-cli --env prod --tenant <slug> branding show\n```\n\n- `set-theme` replaces the whole theme (a submitted-absent field clears the stored one),\n mirroring the admin form \u2014 so the file must carry the **complete**\n theme you want.\n- The logo cap: images only, \u2264 3 MB. Pick the variant that reads on the header \u2014 a **dark\n logo** for the default light bar, a **white/inverse logo** when `filledHeader: true`\n (the bar is the dark primary colour). `branding clear-logo` removes it.\n\n## Alternatives\n\n- **Whole-config rollout (`config apply`).** The theme round-trips through the config\n snapshot\'s `tenant.branding` block and the files through `tenant.brandingAssets`, so\n `config export \u2192 edit \u2192 apply` (or `apply --from env:staging` onto prod) carries the\n complete brand, bytes included \u2014 but it re-plans the *entire* tenant config, so prefer\n it when branding rides along with other config changes or moves between environments.\n To swap a file in a snapshot, replace `branding/<slot>.<ext>` and keep its `path`: the\n CLI re-hashes the file on disk. For a one-off change, `set-theme` / `set-logo` /\n `set-font` are surgical.\n- **Admin UI.** A tenant admin (holding `administration.branding.manage`) edits the same\n row live under **Administration \u2192 Branding**. Use it for quick per-tenant tweaks; use the CLI\n for reproducible, cross-env rollout.\n\n## Per Tr\xE4ger (legal entity)\n\nA legal entity can carry its **own** brand: it replaces the tenant\'s brand **as a\nblock** \u2014 theme, logo and fonts together \u2014 on the portal pages of every unit below it\n(`/e/units/<slug>/**`, header included) and in the letters about those units\'\napplications. The nearest legal entity up the unit\'s chain that has a brand wins (a\n`school_group` counts); without one the tenant\'s applies. Pages without a unit (portal\nstart page, school list, login, \u201EMeine Bewerbungen", an application\'s form and documents)\nand letters about no application keep the tenant\'s brand \u2014 the same split as the terms\n(`set-tenant-terms.md`).\n\nEvery `branding` verb takes `--legal-entity <key>` (the entity\'s\n`foundation.legalEntities[].key`); the gate is the same school config right:\n\n```bash\nplexus-cli --env staging --tenant test branding set-theme --legal-entity test_seminare --file seminare.json\nplexus-cli --env staging --tenant test branding set-logo --legal-entity test_seminare --file seminare.png\nplexus-cli --env staging --tenant test branding show --legal-entity test_seminare\n```\n\nIn config the block is `foundation.legalEntities[].branding` (same shape as\n`tenant.branding`) with its files in `.brandingAssets` (snapshot `branding/<key>/<slot>.<ext>`).\nAn entity that declares **neither** has no brand of its own: an apply deletes a row left\nfrom earlier (`branding: {}` keeps a logo-only brand). An unknown key is refused\n(`[branding/unknownLegalEntity]`). Verify: `branding show --legal-entity <key>`, then open\n`/<tenant>/e/units/<unit-slug>` of a unit below it.\n\n## Gotchas\n\n- **Release gate:** a brand-new `plexus-cli branding` verb (or a new theme field) must be\n live on the env before the CLI call resolves \u2014 otherwise the call fails with an unknown\n function. Ask the platform operator whether the release is out.\n- `config export` names the logo and the font files by hash and writes their bytes to\n `branding/`; `branding show` resolves their URLs (`logoUploads`, `fontUploads`). A\n committing apply refuses a changed hash it has no bytes for\n (`[branding/contentMissing]`), a font file that is not WOFF2 (`[branding/fontRefused]`)\n and a font slot without an own family (`[branding/fontFamilyMissing]`).\n- `set-font` refuses (`INVALID`, German message) a slot without a saved\n family, a family named like the back office\'s own fonts (`Inter Variable`, `Azeret Mono\n Variable` \u2014 an `@font-face` is document-wide), anything over 2 MB and anything that is\n not WOFF2 \u2014 convert TTF/OTF/WOFF first (e.g. `woff2_compress`).\n- Removing a family (config / `set-theme`) leaves its file attached but unused; the admin\n page flags it. Clear the file with `branding clear-font` when you drop the family.\n- A deployment that once held external font URLs dropped them on upgrade (the platform\n operator has the list of dropped URLs); re-upload those files with `set-font`.\n- Verify in the browser: DevTools \u2192 Network \u2192 the `.woff2` request from the Convex origin\n answers 200 with `Access-Control-Allow-Origin: <the portal origin>` (fonts load\n cross-origin; Convex storage reflects the requesting origin).\n- This is a live-DB operation; nothing else records it. A `config export` snapshot is\n your only copy \u2014 keep it out of any shared or public place.\n\n## Related\n\n- [Update a tenant\'s config](./update-tenant-config.md) \xB7 [Onboard / establish a tenant](./onboard-tenant.md)\n- Command semantics: `plexus-cli branding <verb> --help`, `plexus-cli config apply --help`.\n',"references/config/set-tenant-terms.md":`# Set a school's terms (\u201EAnmeldung" statt \u201EBewerbung") \u2014 per tenant or per Tr\xE4ger
5568
+ `,"references/config/set-tenant-branding.md":'# Set a tenant\'s external-portal branding\n\n**When to use:** give a tenant\'s public `/e/**` Bewerbungsportal its own white-label\nlook \u2014 brand colors, corner radius, logo size, header style, and font families, plus an\nuploaded logo and uploaded font files \u2014 on staging and/or prod, without a reseed.\n\n## Prerequisites\n\n- `plexus-cli` installed and current (`plexus-cli --help`).\n- A token configured for each target env (`plexus-cli --env <env> config show` prints\n the resolved connection): a platform-admin token holding `_platform.config.manage` (the\n same right that gates `config apply`), or \u2014 for your OWN tenant only \u2014 a tenant\n admin\'s token holding `administration.config.manage` (see\n [CLI access for a tenant admin](../users/cli-access-for-tenant-admin.md)). Such a\n token runs every `plexus-cli branding \u2026` command and `config apply` for its own\n tenant (branding is one of the `tenant.*` settings a school may change); `branding\n show` needs `administration.config.read` at least. The in-app right\n `administration.branding.manage` alone is refused by the CLI. A local admin key\n without a user identity does **not** satisfy this gate.\n- The `plexus-cli branding \u2026` commands must be **live on the target env** first (they\n call backend functions of the same release). A platform operator rolls a release out\n to staging, then prod; only then run the CLI.\n- The tenant **slug** (e.g. `test`). Always **stage on staging first**, verify in the\n browser, then promote to prod.\n\n## The two halves of branding\n\n| Part | Where it lives | How to set it |\n| --- | --- | --- |\n| **Theme tokens** \u2014 colors, radius, logoSize, bannerDensity, filledHeader, websiteUrl, font **families** | `tenant_branding` row columns; config-portable (exported in `tenant.branding`) | `plexus-cli branding set-theme` (surgical) **or** `config apply` (whole-config) |\n| **Logo** | `_storage` id column (a single `primary` slot); carried by config **by hash** (`tenant.brandingAssets.logo`) | `plexus-cli branding set-logo` (one-off upload) **or** `config apply` (bytes from the snapshot / source env) |\n| **Font files** (WOFF2, one per slot `heading` / `body`) | `_storage` id columns; carried by config **by hash** (`tenant.brandingAssets.fontHeading` / `fontBody`) | `plexus-cli branding set-font --slot heading\\|body --file <woff2>` **or** `config apply` |\n\nA `storageId` is deployment-local, so config never carries it. It carries each uploaded\nfile like a library file: `{ sha256, sizeBytes, mimeType }` under `tenant.brandingAssets`, and\n`config export` downloads the bytes beside the config file as `branding/<slot>.<ext>`\n(`path` in the entry). `config apply --from snapshot:\u2026` or `--from env:<src>` uploads\nonly the files whose hash the target does not hold; the dry run prints\n`~ brand branding/logo content differs \u2014 would upload`. A missing slot \u2014 or a snapshot\nwithout the block \u2014 leaves the target\'s file untouched. A replaced **logo** file is never\ndeleted (sent mail links it); a replaced **font** file is.\nFonts are served from the app\'s own Convex origin \u2014 **never** point a browser at an\nexternal font host (a private-network host is blocked by the browser; the Google-Fonts\nCDN is a GDPR problem).\n\n## The theme shape\n\nEvery field is optional \u2014 omit a key to fall back to the platform default:\n\n```jsonc\n{\n "colors": {\n "primary": "#1E4BCD", // brand primary \u2192 --color-primary (buttons, rings, filled header)\n "accent": "#0AAA5F", // secondary accent \u2192 --color-accent (links, hovers, dots)\n "background": "#FFFFFF", // portal page bg \u2192 --color-bg\n "foreground": "#111111" // body text \u2192 --color-fg\n },\n "radius": "sharp", // "sharp" | "rounded" | "soft"\n "logoSize": "max", // banner logo height: "sm" | "md" | "lg" | "max" (default lg)\n "bannerDensity": "normal", // "compact" | "normal" | "spacious" (default normal)\n "filledHeader": false, // true \u2192 top nav bar filled with the PRIMARY colour (on-primary text)\n "websiteUrl": "https://www.example-schule.de",\n "fonts": {\n "heading": { "family": "Space Grotesk" }, // family only \u2014 the file is uploaded (set-font)\n "body": { "family": "Lora" }\n }\n}\n```\n\n- `colors.*` are `#RRGGBB` hex strings; `radius`/`logoSize`/`bannerDensity` are the enums above.\n- A font entry is `{ family }`. With an uploaded file for that slot the portal loads it as\n `@font-face` under that family; without one the family must already be available\n (system/bundled). A font `url` is **refused** (`fonts.<slot>.url is no longer\n supported`) \u2014 upload the file instead.\n- Bad values (malformed hex, bad enum, a font `url`) fail loud server-side \u2014 the write\n aborts, no partial state.\n\n## Steps \u2014 the surgical CLI path (recommended)\n\n```bash\n# 1. Inspect current branding (branding + resolved logo URL).\nplexus-cli --env staging --tenant <slug> branding show\n\n# 2. Set the theme tokens from a JSON file (replaces the theme wholesale; leaves the logo).\nplexus-cli --env staging --tenant <slug> branding set-theme --file theme.json\n\n# 3. Upload the logo \u2014 from a local file \u2026\nplexus-cli --env staging --tenant <slug> branding set-logo --file logo.png\n# \u2026 or straight from a URL (fetched + uploaded by the CLI):\nplexus-cli --env staging --tenant <slug> branding set-logo \\\n --url https://cdn.example.com/logo-black.png\n\n# 4. Upload the font files \u2014 the slot\'s family must be set first (step 2), the file is\n# applied under it. WOFF2 only (signature-checked), \u2264 2 MB; a replaced file is deleted.\nplexus-cli --env staging --tenant <slug> branding set-font --slot heading --file heading.woff2\nplexus-cli --env staging --tenant <slug> branding set-font --slot body --file body.woff2\n# (`branding clear-font --slot <slot>` removes a file; the family stays.)\n\n# 5. Verify, then promote to prod (re-run 1\u20134 with --env prod \u2014 never assume prod == staging).\nplexus-cli --env prod --tenant <slug> branding show\n```\n\n- `set-theme` replaces the whole theme (a submitted-absent field clears the stored one),\n mirroring the admin form \u2014 so the file must carry the **complete**\n theme you want.\n- The logo cap: images only, \u2264 3 MB. Pick the variant that reads on the header \u2014 a **dark\n logo** for the default light bar, a **white/inverse logo** when `filledHeader: true`\n (the bar is the dark primary colour). `branding clear-logo` removes it.\n\n## Alternatives\n\n- **Whole-config rollout (`config apply`).** The theme round-trips through the config\n snapshot\'s `tenant.branding` block and the files through `tenant.brandingAssets`, so\n `config export \u2192 edit \u2192 apply` (or `apply --from env:staging` onto prod) carries the\n complete brand, bytes included \u2014 but it re-plans the *entire* tenant config, so prefer\n it when branding rides along with other config changes or moves between environments.\n To swap a file in a snapshot, replace `branding/<slot>.<ext>` and keep its `path`: the\n CLI re-hashes the file on disk. For a one-off change, `set-theme` / `set-logo` /\n `set-font` are surgical.\n- **Admin UI.** A tenant admin (holding `administration.branding.manage`) edits the same\n row live under **Administration \u2192 Branding**. Use it for quick per-tenant tweaks; use the CLI\n for reproducible, cross-env rollout.\n\n## Per Tr\xE4ger (legal entity)\n\nA legal entity can carry its **own** brand: it replaces the tenant\'s brand **as a\nblock** \u2014 theme, logo and fonts together \u2014 on the portal pages of every unit below it\n(`/e/units/<slug>/**`, header included) and in the letters about those units\'\napplications. The nearest legal entity up the unit\'s chain that has a brand wins (a\n`school_group` counts); without one the tenant\'s applies. Pages without a unit (portal\nstart page, school list, login, \u201EMeine Bewerbungen", an application\'s form and documents)\nand letters about no application keep the tenant\'s brand \u2014 the same split as the terms\n(`set-tenant-terms.md`).\n\nEvery `branding` verb takes `--legal-entity <key>` (the entity\'s\n`foundation.legalEntities[].key`); the gate is the same school config right:\n\n```bash\nplexus-cli --env staging --tenant test branding set-theme --legal-entity test_seminare --file seminare.json\nplexus-cli --env staging --tenant test branding set-logo --legal-entity test_seminare --file seminare.png\nplexus-cli --env staging --tenant test branding show --legal-entity test_seminare\n```\n\nIn config the block is `foundation.legalEntities[].branding` (same shape as\n`tenant.branding`) with its files in `.brandingAssets` (snapshot `branding/<key>/<slot>.<ext>`).\nAn entity that declares **neither** has no brand of its own: an apply deletes a row left\nfrom earlier (`branding: {}` keeps a logo-only brand). An unknown key is refused\n(`[branding/unknownLegalEntity]`). Verify: `branding show --legal-entity <key>`, then open\n`/<tenant>/e/units/<unit-slug>` of a unit below it.\n\n## Gotchas\n\n- **Release gate:** a brand-new `plexus-cli branding` verb (or a new theme field) must be\n live on the env before the CLI call resolves \u2014 otherwise the call fails with an unknown\n function. Ask the platform operator whether the release is out.\n- `config export` names the logo and the font files by hash and writes their bytes to\n `branding/`; `branding show` resolves their URLs (`logoUploads`, `fontUploads`). A\n committing apply refuses a changed hash it has no bytes for\n (`[branding/contentMissing]`), a font file that is not WOFF2 (`[branding/fontRefused]`)\n and a font slot without an own family (`[branding/fontFamilyMissing]`).\n- `set-font` refuses (`INVALID`, German message) a slot without a saved\n family, a family named like the back office\'s own fonts (`Inter Variable`, `Azeret Mono\n Variable` \u2014 an `@font-face` is document-wide), anything over 2 MB and anything that is\n not WOFF2 \u2014 convert TTF/OTF/WOFF first (e.g. `woff2_compress`).\n- Removing a family (config / `set-theme`) leaves its file attached but unused; the admin\n page flags it. Clear the file with `branding clear-font` when you drop the family.\n- A deployment that once held external font URLs dropped them on upgrade (the platform\n operator has the list of dropped URLs); re-upload those files with `set-font`.\n- Verify in the browser: DevTools \u2192 Network \u2192 the `.woff2` request from the Convex origin\n answers 200 with `Access-Control-Allow-Origin: <the portal origin>` (fonts load\n cross-origin; Convex storage reflects the requesting origin).\n- This is a live-DB operation; nothing else records it. A `config export` snapshot is\n your only copy \u2014 keep it out of any shared or public place.\n\n## Related\n\n- [Update a tenant\'s config](./update-tenant-config.md) \xB7 [Onboard / establish a tenant](./onboard-tenant.md)\n- Command semantics: `plexus-cli branding <verb> --help`, `plexus-cli config apply --help`.\n',"references/config/set-tenant-terms.md":`# Set a school's terms (\u201EAnmeldung" statt \u201EBewerbung") \u2014 per tenant or per Tr\xE4ger
5569
5569
 
5570
5570
  **When to use:** a school calls the process by another name \u2014 it runs an
5571
5571
  \u201EAnmeldeverfahren", not a \u201EBewerbungsverfahren". One setting switches the whole product for that school: the UI,
@@ -6652,7 +6652,7 @@ plexus-cli --env prod platform notifications list --template account.loginLink -
6652
6652
  ## Related
6653
6653
 
6654
6654
  - [Debug a mail delivery](./debug-mail-delivery.md)
6655
- `,"references/offer/add-workflow-node.md":"# Add a workflow node to an offer bundle\n\n**When to use:** an offer's admission workflow needs another step (an approval\ngate, a waitlist holding node, a selection terminus, another form, \u2026) and you want\nthe graph + progress board kept in sync automatically \u2014 instead of hand-editing\n`workflow.json` (graph, `progressLayout` states + columns and\n`progressWiring.mappings`) in lockstep.\n\n## Prerequisites\n- **Env / scope:** none for authoring \u2014 `offer workflow node add|delete|list` and\n `offer workflow show` are **offline** (read/write the on-disk bundle, no\n deployment). Only the final `offer apply --publish` is online and needs\n `--env <env>` + a token with offer config rights (`plexus-cli --env <env> whoami`).\n- **A bundle on disk:** scaffold one with `offer init`, or `offer export` an\n existing offer into a directory.\n- **Tooling:** an installed, current `plexus-cli` (`plexus-cli offer workflow node add --help`).\n- **Both languages:** a node's label is ONE `{ de, en }` field \u2014 `--label` AND\n `--label-en` are required (as `--reason` + `--reason-en` on a collectPayment\n node and `<id>:<granted|rejected|waitlisted|other>:<Deutsch>:<English>` per\n `--decision-outcomes` entry).\n- **Supported types:** `form`, `decision`, `review`, `setFlag`, `waitlist`,\n `roleAssign`, `join`, `collectPayment`, `completenessCheck`, `countersign`, `engagePush`, `if`, `end`\n (the list `offer workflow node add --help` prints \u2014 the subset of node types `add` can\n build). `decision` is the\n configurable-decision builder (ATS primitives \u2014 assign-decision, composed\n tasks, artifacts, decision-as-task); there is no `approval` type any more\n (`--type approval` is refused). `setFlag` flips an external\n flag on the form instance it names (`--flag-key` + `--target '$node.<formNode>.admission'`,\n `--flag-value false` lowers it) \u2014 all three land in the node's INPUTS (`inputs.flagKey`,\n `inputs.target` as a binding, `inputs.value`), never as node properties.\n `countersign` (\u201EUnterschrift (intern)\") is the\n school's countersignature of a checked contract \u2014 see\n [Countersign the contract](./countersign-node.md).\n `if` (\u201EWenn\") routes on one DSL expression over `$env` (`--condition\n '$env.staffInput.<key>'`, outcomes `true` / `false` \u2014 route both with\n `--outcomes`) \u2014 see [Branch on a staff input](./staff-input-if-node.md).\n `completenessCheck` waits for outstanding documents (`--require`,\n `--deadline-days`|`--deadline-until`, `--notification requested=\u2026`, optional\n `--guest-role` + `--person`) \u2014 see\n [Wait for outstanding documents](./completeness-check.md). The folded\n `governedDocument` (offer letter / contract) cannot be added by the CLI yet.\n A `form` node binds a SmartForm via `--form` / `--new-form` (see\n [Attach a form to a workflow](./attach-form-to-workflow.md)).\n- **Letters with the node:** `--notification <event>=<templateId>` (repeatable)\n binds a letter in the same call \u2014 required when the type declares the event\n required (completenessCheck `requested`, countersign `countersigned`), since\n `add` validates before writing.\n- **Addresses with the node**: every flag that reads another node's data\n takes a full address naming its producer, in single quotes \u2014 `--reads` /\n `--require` (`'$node.<formNode>.admission.<field>'`), `--person`\n (`'$node.<formNode>.admission.beneficiary'`), `--target` / `--adopt-form`\n (`'$node.<formNode>.admission'`), `--contract`, engagePush `--form` / `--payment`.\n A bare key is refused with the addresses visible at the new node; `add` binds\n NOTHING implicitly. Bundles exported before addresses were introduced (with `wires`) are refused \u2014\n export again. See [Name what a node reads](./addresses.md).\n\n### Payment gate (`collectPayment`)\n`--article <key>` and `--payment-mode online|manual` are **required** (no\ndefault); both are written as the node's parameters (`inputs.article`,\n`inputs.mode` \u2014 the editor lists them under \u201EParameter\" as \u201EArtikel\" and\n\u201EZahlungsweg\"). The article is\na LINK: the key (`billing_item_definitions.configKey`) of a `one_time`\narticle assigned to the offer's program (Finanzen \u2192 Artikel, directly or through\nan offered package). Amount, currency and the Stripe line name are read from the\narticle at runtime \u2014 the node stores no amount, and publish refuses `amount` /\n`currency` on it (`[collectPayment/retiredField]`) as well as an unknown,\nnon-one-time or out-of-program article. A price change in Finanzen applies to\nthe next payment without a republish.\n\n`online`: the family gets a \u201EZahlung leisten\" request row and pays\nthrough Stripe Checkout \u2014 into the account of the node's **payee Tr\xE4ger**:\n`--payee <key>` (a `foundation.legalEntities[].key`, written as\n`inputs.payee`) is **required** with `online` and refused with `manual`.\nPublish refuses an unknown Tr\xE4ger\n(`[collectPayment/unknownPayee]`) and one whose Stripe account cannot take real\nmoney (`[collectPayment/onlineWithoutStripe]`, naming the Tr\xE4ger). It is not the\ncontract's `--traeger`: a fee and a contract may go to different Tr\xE4ger; the process responsible can also close it\n\u201EOhne Online-Zahlung abschlie\xDFen\" with a required reason (e.g. on an\ninstallation without Stripe).\n\n`manual`: the money reaches the school outside Plexus (transfer, cash). The\nfamily sees \u201EBewerbungsgeb\xFChr bezahlen\" with the amount and the note\n(`--reason`); a team confirms the payment with **\u201EZahlungseingang best\xE4tigen\"**\n\u2014 `--confirm-team <permissionGroupKey>` (written as `assign.confirmPayment`) is\n**required** with `manual` and refused with `online`; publish refuses a manual\nnode without it (`[collectPayment/assign]`). The process responsible may still\nclose the step with \u201EZahlung \xFCberspringen\" (optional comment, nothing booked).\nThe routing edge is `paid` either way.\n\nSwitch an existing node with\n`offer workflow node set --node <node> --payment-mode manual --confirm-team <group>`\n(drops the payee), `--payment-mode online --payee <key>` (drops the team),\n`--confirm-team <group>` to let another team confirm, `--payee <key>` to pay\nanother Tr\xE4ger, or `--article <key>` to charge another article; a `requested`\nletter bound on a `manual` node is refused (`[notification/unknownEvent]`).\nA bundle exported with the older parameter \u201EAbrechnung\" (`inputs.settlement`,\n`online | separate`) is moved to `inputs.mode` by `offer upgrade`\n(`separate` \u2192 `manual`).\nApplications already parked on the node stay on the version they are pinned\nto \u2014 moving them onto the new version after `apply --publish` needs a platform\noperator.\n\n### Terminal, fan-in, and role nodes\n- **`end --outcome <outcome> --data-decision <commit|discard>`** authors a\n terminal node's application outcome (`approved` | `rejected` | `withdrawn` |\n `expired`; default `approved`) and \u2014 required, no default \u2014 whether the\n application's data is kept (`commit`) or discarded (`discard`) at this end\n (the outcome never decides that). The state its terminal event reaches\n seals that same outcome \u2014 the CLI writes it into the layout. It\n writes the `applicationOutcome` / `dataDecision` literal inputs the end\n executor reads (the end node's declared slots, shown in the IDE's PARAMETER\n column) (fixing the old gap\n where every CLI-authored end recorded `approved`), and contributes **one**\n outcome-aware terminal column (e.g. a rejected end adds a red *Abgesagt*\n column, not a misleading green *Eingeschrieben*). A second end is inserted\n isolated \u2014 wire predecessors to it with `join --from` or `node set --outcomes`.\n The outcome must match what the progress layout seals for the state its\n terminal event is wired to (`[end/outcomeMismatch]`).\n- **`waitlist --waitlist-order <arrival|manual>`**\n adds the waiting list. The queue's order (by arrival, or sorted by hand) is\n required, never defaulted. A freed seat never promotes on its own: the staff\n of the queue's head get the letter `staff.waitlistVacancy` and press\n \u201ENachr\xFCcken\". Every waitlist node of a process states the same order\n (`[waitlist/policyConflict]`); change it with `offer workflow node set-input`.\n- **`join --from <nodeId>:<outcome>,\u2026`** authors an explicit XOR fan-in\n convergence. Each `--from` pair reroutes that source node's outcome onto the\n join; the join's own onward edge defaults to the end node (override with\n `--outcomes done:<target>`). Multi-input into a join is the one legal\n many-to-one shape (the publish gate rejects multi-input on non-join nodes).\n- **`roleAssign --role <key>`** grants a person-lifecycle role. `--role` is a\n role key of the tenant's catalog (`roles.key`); the catalog is unknown\n offline, so publish checks it. `--mode`\n is `add` (default) | `remove` | `replace`; `--person '<address>'` is required \u2014\n the party that gets the role, a party leaf of a form\n (`--person '$node.form.admission.beneficiary'`). Never defaulted.\n\n### Configurable decision node (`decision`)\nThe `decision` node is the **one configurable decision node** (it replaced the old\n`approval` node; `--type approval` is refused as an unknown type). By default it\ndeclares the type outcomes `approved` / `rejected` / `waitlisted`. To author a\n**custom** outcome set (with your own ids + labels), pass `--decision-outcomes\n<id>:<semantic>:<Deutsch>:<English>,\u2026` \u2014 what the outcome MEANS (`granted` |\n`rejected` | `waitlisted` | `other`) and its label `{ de, en }` are all\nrequired \u2014 and route each with `--outcomes`:\n\n```bash\n# Inquiry decision: direkt aufnehmen / zum Interview / absage.\nplexus-cli offer workflow node add --dir ./demo \\\n --type decision --node decisionInquiry --label \"Erstentscheidung\" --label-en \"Initial decision\" --after form \\\n --decision-outcomes 'direkt:granted:\"Direkt aufnehmen\":\"Admit directly\",interview:other:\"Zum Interview\":\"To the interview\",absage:rejected:\"Absage\":\"Rejection\"' \\\n --outcomes 'direkt:formApplication,interview:interview,absage:joinAbsage' \\\n --assign-decision zulassung --decision-as-task 'Erstentscheidung treffen'\n```\n\nEach entry becomes an outcome `{id, label, semantic}` on `node.outcomes`; the backend\nexecutor + publish gate + cockpit UI all validate and render decisions against\nwhatever set the node declares. `--decision-outcomes` is decision-only (fails loud on\nany other type). The `semantic` is what the outcome MEANS \u2014 never read off the id: it\ndrives readiness (a rejection is never held), the rejection letter, the feed, the\nbutton tone and the capacity board (`capacity:decide` dispatches the one outcome with\nthe meaning). Publish refuses an outcome without one\n(`[decision/outcomeSemanticMissing]`). Change it later with\n`offer workflow node set --outcome-semantics <outcomeId>:<semantic>,\u2026`.\nRoute each declared outcome to a target that exists \u2014 the publish gate checks coverage.\n\n#### ATS lifecycle primitives on a decision node\nA decision node carries the full offer-lifecycle authoring surface:\n\n- **`--assign-decision <groupKey>`** \u2014 the permission group whose members hold the\n synthesized decision Work-Item (= may pick the routing outcome, in ONE act).\n Pairs with `--decision-as-task` (each requires the other \u2014 fails loud). Absent\n = super-user-only decide (the instance's responsible).\n- **`--comment-required <id>[,<id>]`** \u2014 authored outcome ids that require a decider comment.\n- **`--task \u2026`** (repeatable) \u2014 a composed task the node spawns on enter,\n instantiating a code-owned kind (the kind carries the behaviour: actions,\n close protocol, respawn, gate default):\n - `key:task:title:group[:dueInDays]` \u2014 an internal check task (trivial `complete`).\n - `key:approval:title:group[:revisionGroup]` \u2014 an approval; gates the node by\n default. With **`--task-on-reject spawnRevision`** a rejecting verdict\n spawns a revision back to `revisionGroup` (then REQUIRED \u2014 fails loud).\n (`binds` is DELETED. An offer letter or contract with its prepare \u2192 release \u2192\n response arc is a `governedDocument` node, which `node add` cannot create \u2014 author\n it in the bundle JSON, see [Generate a letter from a Word template](./template-document-node.md).)\n- **`--artifact key:type:visibility:label`** (repeatable) \u2014 a versioned artifact SLOT\n (`type` = `offer` | `contract`, a closed list \u2014 anything else is refused, at publish\n `[artifact/unknownType]`; `visibility` = `internal` | `external`). Each slot exposes a\n `<key>Uploaded` node-export.\n- **Assignment rule** (GRAPH-level, no flag) \u2014 who becomes responsible and who owns\n each team is `graph.assignmentRules` in the same `workflow.json`; `node add/set` do\n not touch it. A node that gives work to a team the rule has no slot for makes\n `offer validate` / publish refuse with `[assignment/slotMissing]` \u2014 add a\n `team:<key>` list in the bundle or in the workflow editor (\u201ETeam-Verantwortliche\").\n Recipe: `playbooks/offer/assignment-rule.md`.\n- **`--decision-as-task title[:dueInDays]`** \u2014 surface the decision as a\n first-class queue Work-Item. Requires `--assign-decision` (and vice versa).\n Combining with gating approval tasks is fine: the HARD node gate blocks a\n non-rejecting advance server-side while gate-effective rows are open.\n\n```bash\n# A pre-check with composed tasks: an internal contract slot, a check task, a finance\n# approval gate with a ping-pong revision on reject, and the Schulleitung's decision\n# row (hard-gated on the finance approval). Every team named here needs a\n# `team:<key>` slot in graph.assignmentRules first, else [assignment/slotMissing].\nplexus-cli offer workflow node add --dir ./demo \\\n --type decision --node vorpruefung --label \"Vorpr\xFCfung\" --label-en \"Pre-check\" --after form \\\n --decision-outcomes 'weiter:granted:\"Weiter\":\"Continue\",absage:rejected:\"Absage\":\"Rejection\"' \\\n --outcomes 'weiter:end,absage:end' \\\n --assign-decision schulleitung --decision-as-task 'Vorpr\xFCfung abschlie\xDFen:3' \\\n --artifact 'vorvertrag:contract:internal:Vorvertrag' \\\n --task 'unterlagenPruefen:task:Unterlagen pr\xFCfen:schulleitung:5' \\\n --task 'finanzFreigabe:approval:Finanzierung freigeben:finanzen:schulleitung' \\\n --task-on-reject spawnRevision\n\n# Task-driven selection decision (like the test seed's approvalSchulleitung), gate-less:\nplexus-cli offer workflow node add --dir ./demo \\\n --type decision --node freigabe --label \"Freigabe\" --label-en \"Approval\" --after form \\\n --decision-outcomes 'approved:granted:Aufnehmen:Admit,rejected:rejected:Absagen:Decline,waitlisted:waitlisted:\"Auf die Warteliste\":Waitlist' \\\n --outcomes 'approved:end,rejected:end,waitlisted:end' \\\n --assign-decision schulleitung \\\n --comment-required rejected \\\n --decision-as-task '\xDCber Freigabe entscheiden:5'\n```\n\nAll of the above is validated by the REAL publish gate on `offer validate`; the CLI adds\nfail-loud cross-checks at the flag boundary (`spawnRevision`\nwithout `revisionGroup`, `decision-as-task` \u21D4 `assign-decision` pairing).\n\n## Steps\n```bash\n# 1. Scaffold a minimal linear offer (start \u2192 form \u2192 end).\nplexus-cli offer init --offer demo --title \"Demo Schule\" --title-en \"Demo School\" --tenant test --responsible sekretariat --out ./demo\n\n# 2. Inspect the graph.\nplexus-cli offer workflow node list --dir ./demo\nplexus-cli offer workflow show --dir ./demo\n\n# 3. Insert a decision gate between the form and the end node.\n# --outcomes routes each declared outcome; any omitted outcome defaults to\n# where --after currently points (here end), splicing into the chain.\nplexus-cli offer workflow node add --dir ./demo \\\n --type decision --node approval --label \"Freigabe\" --label-en \"Approval\" --after form \\\n --assign-decision freigeber --decision-as-task 'Freigabe entscheiden' \\\n --outcomes approved:end,rejected:end\n\n# 4. Validate offline against the REAL publish gate (add already ran it; this is\n# the explicit re-check / CI gate).\nplexus-cli offer validate --dir ./demo\n\n# 5. Apply + publish (online). Needs --env + a token; cuts new versions on diff.\nplexus-cli --env <env> --tenant test offer apply --dir ./demo --publish\n```\n\n- **`--node`** is optional \u2014 defaults to the type, numbered from 2 when taken\n (`approval`, `approval2`, \u2026; `makeNodeId`). An id you pass must be a dot-free\n identifier (`^[a-z][A-Za-z0-9]*$`, e.g. `decisionInquiry`) \u2014 `offer validate`\n refuses anything else as `[graph/nodeIdFormat]`.\n- **`--after <nodeId>`** inserts after that node and rewires its onward edge(s)\n to the new node. Omit it to insert immediately before the end node.\n- **`--type form`** binds a SmartForm \u2014 `--form <slug>` (existing) or\n `--new-form --form <slug>` (scaffold + bind). See the dedicated playbook.\n- **Remove** a node (rewires predecessors onto its single successor, strips its\n progress entries, re-validates; refused while an address elsewhere names it):\n ```bash\n plexus-cli offer workflow node delete --dir ./demo --node approval\n ```\n\n## Verify\n```bash\nplexus-cli offer workflow node list --dir ./demo # the node appears, routing is wired\nplexus-cli offer validate --dir ./demo # exit 0 = publish gate clean\n```\n\nFor the approval example, `offer validate` exits 0 with **no manual manifest\nedit**: `offer workflow node add` materialised the `approval.released` process\nstate, its board column, and the `(approval, released) \u2192 process/approval.released`\nwiring mapping. A decision that reads nothing of the form names no address\n(`offer workflow node reads --dir ./demo --node approval` lists nothing). After `offer workflow node delete`, the graph returns to the linear\n`form \u2192 end` shape and validation passes again.\n\n## Idempotency / gotchas\n- **`add` validates before writing.** Any error-severity issue from the real\n publish gate (`runWorkflowValidators` etc.) blocks the write and exits 1 \u2014 the\n bundle is left untouched. A failed `add` never leaves a half-spliced bundle.\n- **Splice defaults can over-route.** Every declared outcome you DON'T name in\n `--outcomes` defaults to the anchor's current onward target. Inserting a\n multi-outcome node (endauswahl, approval) after a node that points at the end\n node routes *all* its outcomes to the end node \u2014 pass `--outcomes` to fan them\n out (e.g. `warteliste:waitlist`).\n- **Nothing is bound implicitly.** A node reads a form only at the address it\n names (`$node.<formNode>.admission.<field>`), and the producer must run on every\n path before it (`[address/notVisible]` otherwise). A `form` node's `smartForm` is\n written as a `{ kind: \"literal\", value: <slug> }`; with\n `--adopt-form '$node.<formNode>.admission'` it continues that instance instead\n (`adoptForm` holds the address; the adopting node produces nothing \u2014 later\n nodes still read the creator's address). Explicit-by-default, matching `offer init`.\n- **`delete` refuses** to remove the start (`eventTrigger`) or `end` node, a node with\n multiple distinct successors (ambiguous splice), and a node any address elsewhere\n still names (its form instance, document, contract, payment, or a value one of\n its tasks writes) \u2014 the refusal lists every naming place (config path +\n address); edit those first. Orphans surface at re-validate and block the write.\n- **Progress labels/tones** come from one built-in default table, shared with the\n `offer init` scaffold. An event with no default falls back to its name +\n neutral tone and prints a warning.\n\n## Related\n- [Attach a form to a workflow](./attach-form-to-workflow.md) \u2014 the `--type form` flow.\n- [Author a SmartForm as code](./author-smartform.md) \u2014 build the form itself.\n- `plexus-cli offer --help` \u2014 the full `offer \u2026` command reference; `offer validate`\n runs the same publish-gate validators as `offer workflow node add`.\n","references/offer/addresses.md":"# Name what a node reads (addresses)\n\n**When to use:** a node must read data another node produces \u2014 the form's answers in a\ncontract, a value a review task records, the contract a countersignature books\non \u2014 or the gate refuses a bundle with an `[address/*]` code. A read **names its\nproducer** in the field that reads it: a full address. There are no data edges any more\n(`node.wires` is gone), no form implied by the node and no bare keys. Control edges (`next`) only\nroute. What a node may read is what is produced on every path before it.\n\n## Prerequisites\n- An offer bundle on disk (`offer init`, or `offer export --offer <slug> --out <dir>`; a live\n tenant's bundle only into a private scratch dir \u2014 see\n [Edit a live tenant's offer](./edit-live-tenant-offer.md)). Fully offline: every verb runs the\n publish gate on the result and writes nothing when the edit introduces an error.\n- **A bundle exported before addresses were introduced is refused** (`[graph/retiredField]` for `wires`, a binding\n with `path`, `adoptForm: true`; `[address/bareIdentifier]` for a bare key). Do not patch it by\n hand \u2014 export it again (the server migration folded the live graph onto addresses).\n- The spelling \u2014 **always in single quotes on the command line**, or the shell expands `$node`:\n\n | Address | Names | Example (demo tenant `test`) |\n |---|---|---|\n | `$node.<formNode>.admission` | the form instance a form node creates | `$node.form.admission` |\n | `$node.<formNode>.admission.<field>` | one field (or export, or party leaf `beneficiary` / `signers`) of it | `$node.form.admission.kind.geburtsurkunde` |\n | `$node.<node>.document` | the newest revision of a document node's slot | `$node.platzangebot.document` |\n | `$node.<node>.contract` | a machine-produced contract (`production: resolver`) | `$node.contract.contract` |\n | `$node.<node>.payment` | a payment node's result | `$node.zahlung.payment` |\n | `$task.<task>.<key>` | the value the ONE task `<task>` writes under store key `<key>` | `$task.reducedFee.reducedFee` |\n | `$env.applicant.language` | a fact about the application nobody produces | |\n\n An adopting form node (`adoptForm`, e.g. `formZusage` in the demo tenant `test`) **produces nothing**: the\n instance stays its creator's, so every later node still reads `$node.form.admission.\u2026`.\n\n## Steps\n```bash\n# What arrives at a node: every address it reads, where it is written, who produces it \u2014\n# including what it reads by carrying (the evidence of a task whose value it reads):\nplexus-cli offer workflow node reads --dir <dir> --node contract\n\n# A bare key is refused with the list of what that node can read \u2014 use it to pick:\nplexus-cli offer workflow node set-reads --dir <dir> --node contract --address kind.vorname\n# \u2192 --address (reads) \"kind.vorname\": ein nackter Schl\xFCssel \u2026\n# An \u201EVertrag\" (contract) lesbar:\n# Bewerbung Gymnasium Havelland \u203A Anmeldung ($node.form.admission)\n# Pr\xFCfung \u203A Schulgeld mit Erm\xE4\xDFigung \u203A Einkommenserm\xE4\xDFigung ($task.reducedFee.reducedFee)\n# \u2026\n\n# The flags that read data (each takes full addresses):\nplexus-cli offer workflow node set-input --dir <dir> --node contract --input reducedFee --address '$task.reducedFee.reducedFee'\nplexus-cli offer workflow node set-reads --dir <dir> --node contract --from form --field kind.vorname,kind.nachname\nplexus-cli offer workflow node set-requires --dir <dir> --node nachreichen --address '$node.form.admission.kind.masernschutz'\nplexus-cli offer workflow node task set --dir <dir> --node reviewEingereicht --key reducedFee \\\n --when '$node.form.admission.ermaessigungBeantragt' --reads '$node.form.admission.gebuehren.einkommensnachweise'\nplexus-cli offer workflow node add --dir <dir> --type setFlag ... --target '$node.form.admission'\nplexus-cli offer workflow node add --dir <dir> --type form ... --adopt-form '$node.form.admission'\nplexus-cli offer workflow node add --dir <dir> --type countersign ... --contract '$node.contract.contract'\n```\n\nThe short form `--from <formNode> --field <path>` (set-input, `*-reads`, `*-requires`) only\ncomposes `$node.<formNode>.admission.<path>` \u2014 it names the node, it never picks one.\n\nWhich flag sets which field:\n\n| Field | Verb / flag |\n|---|---|\n| an input binding | `node set-input --address` (or `--from/--field`) |\n| `reads` (decision / governedDocument) | `node set-reads|add-reads|remove-reads --address` |\n| `requires` (completenessCheck) | `node set-requires|add-requires|remove-requires --address`; at add: `--require` |\n| setFlag `inputs.target` (a binding) | `node add|set --target` |\n| form `adoptForm` | `node add --adopt-form` |\n| resolver governedDocument / engagePush / review `form` | `node set --form '<instance address>'` (engagePush and review also at add) |\n| countersign / engagePush `contract`, engagePush `payment` | `node add|set --contract|--payment` |\n| roleAssign / completenessCheck `person` | `node add|set --person` |\n| task `when`, `reads`, `documents` | `node task add|set --when|--reads|--documents` (`field:<address>`; a document slot \u2014 the node's own or an earlier node's \u2014 is `artifact:<key>`, no address) |\n| task family request | `--family-request-fields <addresses>` or `--family-request-from '$node.<form>.admission'` |\n| record field suggestion | `--field '{\u2026,\"suggest\":{\"kind\":\"form\",\"address\":\"$node.form.admission.alleinerziehend\"}}'` |\n\n## In the IDE instead\nThe Workflow-IDE offers exactly what the gate accepts \u2014 the same rules\n(`addressFieldOptions`), one picker in every editor, never a typed key:\n- **What arrives at a node:** select it \u2014 the bottom bar's \u201EEingang\" column lists\n its reads and what it may read (Formular \xB7 Dokumente \xB7 Zahlungen \xB7 Aufgaben \xB7\n Abgeleitet \xB7 Umgebung), each with producer, address and how it is read; a rose\n entry is a read publish refuses (`[address/notVisible]`). Drag an entry onto a\n parameter to bind it.\n- **Node fields** (`reads`, `requires`, `adoptForm`, `form` /\n `contract` / `payment`): node \u2192 \u201EDetails\" \u2192 \u201EEinstellungen\". A setFlag's form is its\n `target` INPUT: picked in the bottom bar's PARAMETER column, with its flag and\n raise / lower.\n- **Task fields** (`when`, `reads`, `documents`, `familyRequest`, a record's\n suggestion): node \u2192 \u201EDetails\" \u2192 \u201ETeam\".\n- **Pricing-rule conditions and reductions:** bundle only; prices belong to the\n contract generator.\n\n## Verify\n```bash\nplexus-cli offer validate --dir <dir> # exit 0, no [address/*] error\nplexus-cli offer workflow node reads --dir <dir> --node <id> --json\nplexus-cli --env staging --tenant <t> offer plan --dir <dir> # ~ workflow; address:/reads: rows against the live head (see edit-live-tenant-offer.md)\n```\n\n## Idempotency / gotchas\n- **The gate judges every address** before writing: `[address/shape]`, `[address/bareIdentifier]`,\n `[address/unknownOwner]` (no such node / task), `[address/unknownKey]` (the node does not\n produce it \u2014 a form produces `admission`, a resolver contract `contract`, not `document`),\n `[address/ownerNotWriter]` (the task does not write that store key), `[address/notVisible]`\n (the producer is not on EVERY path before the reader \u2014 on a detour the reader would wait\n forever), `[address/pathNotInTarget]` (the form has no such field), `[address/notExported]` (it has\n the field but does not export it, or the `formExports` stamp is stale), `[address/typeMismatch]`\n (a `when` must be a yes/no export, a binding must fit its slot), `[address/notFormInstance]`\n (`target`, `adoptForm`, `form`, `familyRequest.from` name `$node.<creating form>.admission`\n without a path), `[address/mixedForms]` (one list \u2014 node `reads`, `requires`, a task's\n `when` + `reads`, `familyRequest.fields` \u2014 names ONE form), `[address/missing]` (countersign\n `contract`, a resolver's / engagePush's `form`; an unbound setFlag `inputs.target` is the\n required-slot finding). Only errors the edit\n INTRODUCES block it; errors the bundle already had are printed as \u201Evorbestehend\".\n- **A node reads its own results** (a value one of its tasks writes, its own document slot)\n without dominance; it is still in its read list.\n- **`node delete` refuses while an address names the node** \u2014 its form instance, document,\n contract, payment, or a value one of its tasks writes \u2014 and lists every place (config path +\n address). Edit those first; nothing is dropped silently.\n- **Renaming a task key or moving a writing task to another node** changes the address\n (`$task.<task>.<key>`): every reader must be edited, and running applications cannot re-pin\n across it.\n- Nothing reaches a live process until `offer apply --publish`; running applications keep their\n pinned version.\n\n## Related\n- [Bind a node input](./bind-node-input.md) \xB7 [Declare what a document node reads](./declare-node-reads.md)\n- [Add a workflow node](./add-workflow-node.md) \xB7 [Countersign the contract](./countersign-node.md) \xB7 [Node tasks](./node-tasks.md)\n- [Edit a live tenant's offer](./edit-live-tenant-offer.md) \u2014 export, plan and apply against a live tenant\n","references/offer/assignment-rule.md":`# Change an offer's assignment rule (Zust\xE4ndigkeitsregel)
6655
+ `,"references/offer/add-workflow-node.md":"# Add a workflow node to an offer bundle\n\n**When to use:** an offer's admission workflow needs another step (an approval\ngate, a waitlist holding node, a selection terminus, another form, \u2026) and you want\nthe graph + progress board kept in sync automatically \u2014 instead of hand-editing\nThe workflow file (graph, `progressLayout` states + columns and\n`progressWiring.mappings`) in lockstep.\n\n## Prerequisites\n- **Env / scope:** none for authoring \u2014 `offer workflow node add|delete|list` and\n `offer workflow show` are **offline** (read/write the on-disk bundle, no\n deployment). Only the final `offer apply --publish` is online and needs\n `--env <env>` + a token with offer config rights (`plexus-cli --env <env> whoami`).\n- **A bundle on disk:** scaffold one with `offer init`, or `offer export` an\n existing offer into a directory.\n- **Tooling:** an installed, current `plexus-cli` (`plexus-cli offer workflow node add --help`).\n- **Both languages:** a node's label is ONE `{ de, en }` field \u2014 `--label` AND\n `--label-en` are required (as `--reason` + `--reason-en` on a collectPayment\n node and `<id>:<granted|rejected|waitlisted|other>:<Deutsch>:<English>` per\n `--decision-outcomes` entry).\n- **Supported types:** `form`, `decision`, `review`, `setFlag`, `waitlist`,\n `roleAssign`, `join`, `collectPayment`, `completenessCheck`, `countersign`, `engagePush`, `if`, `end`\n (the list `offer workflow node add --help` prints \u2014 the subset of node types `add` can\n build). `decision` is the\n configurable-decision builder (ATS primitives \u2014 assign-decision, composed\n tasks, artifacts, decision-as-task); there is no `approval` type any more\n (`--type approval` is refused). `setFlag` flips an external\n flag on the form instance it names (`--flag-key` + `--target '$node.<formNode>.admission'`,\n `--flag-value false` lowers it) \u2014 all three land in the node's INPUTS (`inputs.flagKey`,\n `inputs.target` as a binding, `inputs.value`), never as node properties.\n `countersign` (\u201EUnterschrift (intern)\") is the\n school's countersignature of a checked contract \u2014 see\n [Countersign the contract](./countersign-node.md).\n `if` (\u201EWenn\") routes on one DSL expression over `$env` (`--condition\n '$env.staffInput.<key>'`, outcomes `true` / `false` \u2014 route both with\n `--outcomes`) \u2014 see [Branch on a staff input](./staff-input-if-node.md).\n `completenessCheck` waits for outstanding documents (`--require`,\n `--deadline-days`|`--deadline-until`, `--notification requested=\u2026`, optional\n `--guest-role` + `--person`) \u2014 see\n [Wait for outstanding documents](./completeness-check.md). The folded\n `governedDocument` (offer letter / contract) cannot be added by the CLI yet.\n A `form` node binds a SmartForm via `--form` / `--new-form` (see\n [Attach a form to a workflow](./attach-form-to-workflow.md)).\n- **Letters with the node:** `--notification <event>=<templateId>` (repeatable)\n binds a letter in the same call \u2014 required when the type declares the event\n required (completenessCheck `requested`, countersign `countersigned`), since\n `add` validates before writing.\n- **Addresses with the node**: every flag that reads another node's data\n takes a full address naming its producer, in single quotes \u2014 `--reads` /\n `--require` (`'$node.<formNode>.admission.<field>'`), `--person`\n (`'$node.<formNode>.admission.beneficiary'`), `--target` / `--adopt-form`\n (`'$node.<formNode>.admission'`), `--contract`, engagePush `--form` / `--payment`.\n A bare key is refused with the addresses visible at the new node; `add` binds\n NOTHING implicitly. Bundles exported before addresses were introduced (with `wires`) are refused \u2014\n export again. See [Name what a node reads](./addresses.md).\n\n### Payment gate (`collectPayment`)\n`--article <key>` and `--payment-mode online|manual` are **required** (no\ndefault); both are written as the node's parameters (`inputs.article`,\n`inputs.mode` \u2014 the editor lists them under \u201EParameter\" as \u201EArtikel\" and\n\u201EZahlungsweg\"). The article is\na LINK: the key (`billing_item_definitions.configKey`) of a `one_time`\narticle assigned to the offer's program (Finanzen \u2192 Artikel, directly or through\nan offered package). Amount, currency and the Stripe line name are read from the\narticle at runtime \u2014 the node stores no amount, and publish refuses `amount` /\n`currency` on it (`[collectPayment/retiredField]`) as well as an unknown,\nnon-one-time or out-of-program article. A price change in Finanzen applies to\nthe next payment without a republish.\n\n`online`: the family gets a \u201EZahlung leisten\" request row and pays\nthrough Stripe Checkout \u2014 into the account of the node's **payee Tr\xE4ger**:\n`--payee <key>` (a `foundation.legalEntities[].key`, written as\n`inputs.payee`) is **required** with `online` and refused with `manual`.\nPublish refuses an unknown Tr\xE4ger\n(`[collectPayment/unknownPayee]`) and one whose Stripe account cannot take real\nmoney (`[collectPayment/onlineWithoutStripe]`, naming the Tr\xE4ger). It is not the\ncontract's `--traeger`: a fee and a contract may go to different Tr\xE4ger; the process responsible can also close it\n\u201EOhne Online-Zahlung abschlie\xDFen\" with a required reason (e.g. on an\ninstallation without Stripe).\n\n`manual`: the money reaches the school outside Plexus (transfer, cash). The\nfamily sees \u201EBewerbungsgeb\xFChr bezahlen\" with the amount and the note\n(`--reason`); a team confirms the payment with **\u201EZahlungseingang best\xE4tigen\"**\n\u2014 `--confirm-team <permissionGroupKey>` (written as `assign.confirmPayment`) is\n**required** with `manual` and refused with `online`; publish refuses a manual\nnode without it (`[collectPayment/assign]`). The process responsible may still\nclose the step with \u201EZahlung \xFCberspringen\" (optional comment, nothing booked).\nThe routing edge is `paid` either way.\n\nSwitch an existing node with\n`offer workflow node set --node <node> --payment-mode manual --confirm-team <group>`\n(drops the payee), `--payment-mode online --payee <key>` (drops the team),\n`--confirm-team <group>` to let another team confirm, `--payee <key>` to pay\nanother Tr\xE4ger, or `--article <key>` to charge another article; a `requested`\nletter bound on a `manual` node is refused (`[notification/unknownEvent]`).\nA bundle exported with the older parameter \u201EAbrechnung\" (`inputs.settlement`,\n`online | separate`) is moved to `inputs.mode` by `offer upgrade`\n(`separate` \u2192 `manual`).\nApplications already parked on the node stay on the version they are pinned\nto \u2014 moving them onto the new version after `apply --publish` needs a platform\noperator.\n\n### Terminal, fan-in, and role nodes\n- **`end --outcome <outcome> --data-decision <commit|discard>`** authors a\n terminal node's application outcome (`approved` | `rejected` | `withdrawn` |\n `expired`; default `approved`) and \u2014 required, no default \u2014 whether the\n application's data is kept (`commit`) or discarded (`discard`) at this end\n (the outcome never decides that). The state its terminal event reaches\n seals that same outcome \u2014 the CLI writes it into the layout. It\n writes the `applicationOutcome` / `dataDecision` literal inputs the end\n executor reads (the end node's declared slots, shown in the IDE's PARAMETER\n column) (fixing the old gap\n where every CLI-authored end recorded `approved`), and contributes **one**\n outcome-aware terminal column (e.g. a rejected end adds a red *Abgesagt*\n column, not a misleading green *Eingeschrieben*). A second end is inserted\n isolated \u2014 wire predecessors to it with `join --from` or `node set --outcomes`.\n The outcome must match what the progress layout seals for the state its\n terminal event is wired to (`[end/outcomeMismatch]`).\n- **`waitlist --waitlist-order <arrival|manual>`**\n adds the waiting list. The queue's order (by arrival, or sorted by hand) is\n required, never defaulted. A freed seat never promotes on its own: the staff\n of the queue's head get the letter `staff.waitlistVacancy` and press\n \u201ENachr\xFCcken\". Every waitlist node of a process states the same order\n (`[waitlist/policyConflict]`); change it with `offer workflow node set-input`.\n- **`join --from <nodeId>:<outcome>,\u2026`** authors an explicit XOR fan-in\n convergence. Each `--from` pair reroutes that source node's outcome onto the\n join; the join's own onward edge defaults to the end node (override with\n `--outcomes done:<target>`). Multi-input into a join is the one legal\n many-to-one shape (the publish gate rejects multi-input on non-join nodes).\n- **`roleAssign --role <key>`** grants a person-lifecycle role. `--role` is a\n role key of the tenant's catalog (`roles.key`); the catalog is unknown\n offline, so publish checks it. `--mode`\n is `add` (default) | `remove` | `replace`; `--person '<address>'` is required \u2014\n the party that gets the role, a party leaf of a form\n (`--person '$node.form.admission.beneficiary'`). Never defaulted.\n\n### Configurable decision node (`decision`)\nThe `decision` node is the **one configurable decision node** (it replaced the old\n`approval` node; `--type approval` is refused as an unknown type). By default it\ndeclares the type outcomes `approved` / `rejected` / `waitlisted`. To author a\n**custom** outcome set (with your own ids + labels), pass `--decision-outcomes\n<id>:<semantic>:<Deutsch>:<English>,\u2026` \u2014 what the outcome MEANS (`granted` |\n`rejected` | `waitlisted` | `other`) and its label `{ de, en }` are all\nrequired \u2014 and route each with `--outcomes`:\n\n```bash\n# Inquiry decision: direkt aufnehmen / zum Interview / absage.\nplexus-cli offer workflow node add --dir ./demo \\\n --type decision --node decisionInquiry --label \"Erstentscheidung\" --label-en \"Initial decision\" --after form \\\n --decision-outcomes 'direkt:granted:\"Direkt aufnehmen\":\"Admit directly\",interview:other:\"Zum Interview\":\"To the interview\",absage:rejected:\"Absage\":\"Rejection\"' \\\n --outcomes 'direkt:formApplication,interview:interview,absage:joinAbsage' \\\n --assign-decision zulassung --decision-as-task 'Erstentscheidung treffen'\n```\n\nEach entry becomes an outcome `{id, label, semantic}` on `node.outcomes`; the backend\nexecutor + publish gate + cockpit UI all validate and render decisions against\nwhatever set the node declares. `--decision-outcomes` is decision-only (fails loud on\nany other type). The `semantic` is what the outcome MEANS \u2014 never read off the id: it\ndrives readiness (a rejection is never held), the rejection letter, the feed, the\nbutton tone and the capacity board (`capacity:decide` dispatches the one outcome with\nthe meaning). Publish refuses an outcome without one\n(`[decision/outcomeSemanticMissing]`). Change it later with\n`offer workflow node set --outcome-semantics <outcomeId>:<semantic>,\u2026`.\nRoute each declared outcome to a target that exists \u2014 the publish gate checks coverage.\n\n#### ATS lifecycle primitives on a decision node\nA decision node carries the full offer-lifecycle authoring surface:\n\n- **`--assign-decision <groupKey>`** \u2014 the permission group whose members hold the\n synthesized decision Work-Item (= may pick the routing outcome, in ONE act).\n Pairs with `--decision-as-task` (each requires the other \u2014 fails loud). Absent\n = super-user-only decide (the instance's responsible).\n- **`--comment-required <id>[,<id>]`** \u2014 authored outcome ids that require a decider comment.\n- **`--task \u2026`** (repeatable) \u2014 a composed task the node spawns on enter,\n instantiating a code-owned kind (the kind carries the behaviour: actions,\n close protocol, respawn, gate default):\n - `key:task:title:group[:dueInDays]` \u2014 an internal check task (trivial `complete`).\n - `key:approval:title:group[:revisionGroup]` \u2014 an approval; gates the node by\n default. With **`--task-on-reject spawnRevision`** a rejecting verdict\n spawns a revision back to `revisionGroup` (then REQUIRED \u2014 fails loud).\n (`binds` is DELETED. An offer letter or contract with its prepare \u2192 release \u2192\n response arc is a `governedDocument` node, which `node add` cannot create \u2014 author\n it in the bundle JSON, see [Generate a letter from a Word template](./template-document-node.md).)\n- **`--artifact key:type:visibility:label`** (repeatable) \u2014 a versioned artifact SLOT\n (`type` = `offer` | `contract`, a closed list \u2014 anything else is refused, at publish\n `[artifact/unknownType]`; `visibility` = `internal` | `external`). Each slot exposes a\n `<key>Uploaded` node-export.\n- **Assignment rule** (GRAPH-level, no flag) \u2014 who becomes responsible and who owns\n each team is `graph.assignmentRules` in the same workflow file; `node add/set` do\n not touch it. A node that gives work to a team the rule has no slot for makes\n `offer validate` / publish refuse with `[assignment/slotMissing]` \u2014 add a\n `team:<key>` list in the bundle or in the workflow editor (\u201ETeam-Verantwortliche\").\n Recipe: `playbooks/offer/assignment-rule.md`.\n- **`--decision-as-task title[:dueInDays]`** \u2014 surface the decision as a\n first-class queue Work-Item. Requires `--assign-decision` (and vice versa).\n Combining with gating approval tasks is fine: the HARD node gate blocks a\n non-rejecting advance server-side while gate-effective rows are open.\n\n```bash\n# A pre-check with composed tasks: an internal contract slot, a check task, a finance\n# approval gate with a ping-pong revision on reject, and the Schulleitung's decision\n# row (hard-gated on the finance approval). Every team named here needs a\n# `team:<key>` slot in graph.assignmentRules first, else [assignment/slotMissing].\nplexus-cli offer workflow node add --dir ./demo \\\n --type decision --node vorpruefung --label \"Vorpr\xFCfung\" --label-en \"Pre-check\" --after form \\\n --decision-outcomes 'weiter:granted:\"Weiter\":\"Continue\",absage:rejected:\"Absage\":\"Rejection\"' \\\n --outcomes 'weiter:end,absage:end' \\\n --assign-decision schulleitung --decision-as-task 'Vorpr\xFCfung abschlie\xDFen:3' \\\n --artifact 'vorvertrag:contract:internal:Vorvertrag' \\\n --task 'unterlagenPruefen:task:Unterlagen pr\xFCfen:schulleitung:5' \\\n --task 'finanzFreigabe:approval:Finanzierung freigeben:finanzen:schulleitung' \\\n --task-on-reject spawnRevision\n\n# Task-driven selection decision (like the test seed's approvalSchulleitung), gate-less:\nplexus-cli offer workflow node add --dir ./demo \\\n --type decision --node freigabe --label \"Freigabe\" --label-en \"Approval\" --after form \\\n --decision-outcomes 'approved:granted:Aufnehmen:Admit,rejected:rejected:Absagen:Decline,waitlisted:waitlisted:\"Auf die Warteliste\":Waitlist' \\\n --outcomes 'approved:end,rejected:end,waitlisted:end' \\\n --assign-decision schulleitung \\\n --comment-required rejected \\\n --decision-as-task '\xDCber Freigabe entscheiden:5'\n```\n\nAll of the above is validated by the REAL publish gate on `offer validate`; the CLI adds\nfail-loud cross-checks at the flag boundary (`spawnRevision`\nwithout `revisionGroup`, `decision-as-task` \u21D4 `assign-decision` pairing).\n\n## Steps\n```bash\n# 1. Scaffold a minimal linear offer (start \u2192 form \u2192 end).\nplexus-cli offer init --offer demo --title \"Demo Schule\" --title-en \"Demo School\" --tenant test --responsible sekretariat --out ./demo\n\n# 2. Inspect the graph.\nplexus-cli offer workflow node list --dir ./demo\nplexus-cli offer workflow show --dir ./demo\n\n# 3. Insert a decision gate between the form and the end node.\n# --outcomes routes each declared outcome; any omitted outcome defaults to\n# where --after currently points (here end), splicing into the chain.\nplexus-cli offer workflow node add --dir ./demo \\\n --type decision --node approval --label \"Freigabe\" --label-en \"Approval\" --after form \\\n --assign-decision freigeber --decision-as-task 'Freigabe entscheiden' \\\n --outcomes approved:end,rejected:end\n\n# 4. Validate offline against the REAL publish gate (add already ran it; this is\n# the explicit re-check / CI gate).\nplexus-cli offer validate --dir ./demo\n\n# 5. Apply + publish (online). Needs --env + a token; cuts new versions on diff.\nplexus-cli --env <env> --tenant test offer apply --dir ./demo --publish\n```\n\n- **`--node`** is optional \u2014 defaults to the type, numbered from 2 when taken\n (`approval`, `approval2`, \u2026; `makeNodeId`). An id you pass must be a dot-free\n identifier (`^[a-z][A-Za-z0-9]*$`, e.g. `decisionInquiry`) \u2014 `offer validate`\n refuses anything else as `[graph/nodeIdFormat]`.\n- **`--after <nodeId>`** inserts after that node and rewires its onward edge(s)\n to the new node. Omit it to insert immediately before the end node.\n- **`--type form`** binds a SmartForm \u2014 `--form <slug>` (existing) or\n `--new-form --form <slug>` (scaffold + bind). See the dedicated playbook.\n- **Remove** a node (rewires predecessors onto its single successor, strips its\n progress entries, re-validates; refused while an address elsewhere names it):\n ```bash\n plexus-cli offer workflow node delete --dir ./demo --node approval\n ```\n\n## Verify\n```bash\nplexus-cli offer workflow node list --dir ./demo # the node appears, routing is wired\nplexus-cli offer validate --dir ./demo # exit 0 = publish gate clean\n```\n\nFor the approval example, `offer validate` exits 0 with **no manual manifest\nedit**: `offer workflow node add` materialised the `approval.released` process\nstate, its board column, and the `(approval, released) \u2192 process/approval.released`\nwiring mapping. A decision that reads nothing of the form names no address\n(`offer workflow node reads --dir ./demo --node approval` lists nothing). After `offer workflow node delete`, the graph returns to the linear\n`form \u2192 end` shape and validation passes again.\n\n## Idempotency / gotchas\n- **`add` validates before writing.** Any error-severity issue from the real\n publish gate (`runWorkflowValidators` etc.) blocks the write and exits 1 \u2014 the\n bundle is left untouched. A failed `add` never leaves a half-spliced bundle.\n- **Splice defaults can over-route.** Every declared outcome you DON'T name in\n `--outcomes` defaults to the anchor's current onward target. Inserting a\n multi-outcome node (endauswahl, approval) after a node that points at the end\n node routes *all* its outcomes to the end node \u2014 pass `--outcomes` to fan them\n out (e.g. `warteliste:waitlist`).\n- **Nothing is bound implicitly.** A node reads a form only at the address it\n names (`$node.<formNode>.admission.<field>`), and the producer must run on every\n path before it (`[address/notVisible]` otherwise). A `form` node's `smartForm` is\n written as a `{ kind: \"literal\", value: <slug> }`; with\n `--adopt-form '$node.<formNode>.admission'` it continues that instance instead\n (`adoptForm` holds the address; the adopting node produces nothing \u2014 later\n nodes still read the creator's address). Explicit-by-default, matching `offer init`.\n- **`delete` refuses** to remove the start (`eventTrigger`) or `end` node, a node with\n multiple distinct successors (ambiguous splice), and a node any address elsewhere\n still names (its form instance, document, contract, payment, or a value one of\n its tasks writes) \u2014 the refusal lists every naming place (config path +\n address); edit those first. Orphans surface at re-validate and block the write.\n- **Progress labels/tones** come from one built-in default table, shared with the\n `offer init` scaffold. An event with no default falls back to its name +\n neutral tone and prints a warning.\n\n## Related\n- [Attach a form to a workflow](./attach-form-to-workflow.md) \u2014 the `--type form` flow.\n- [Author a SmartForm as code](./author-smartform.md) \u2014 build the form itself.\n- `plexus-cli offer --help` \u2014 the full `offer \u2026` command reference; `offer validate`\n runs the same publish-gate validators as `offer workflow node add`.\n","references/offer/addresses.md":"# Name what a node reads (addresses)\n\n**When to use:** a node must read data another node produces \u2014 the form's answers in a\ncontract, a value a review task records, the contract a countersignature books\non \u2014 or the gate refuses a bundle with an `[address/*]` code. A read **names its\nproducer** in the field that reads it: a full address. There are no data edges any more\n(`node.wires` is gone), no form implied by the node and no bare keys. Control edges (`next`) only\nroute. What a node may read is what is produced on every path before it.\n\n## Prerequisites\n- An offer bundle on disk (`offer init`, or `offer export --offer <slug> --out <dir>`; a live\n tenant's bundle only into a private scratch dir \u2014 see\n [Edit a live tenant's offer](./edit-live-tenant-offer.md)). Fully offline: every verb runs the\n publish gate on the result and writes nothing when the edit introduces an error.\n- **A bundle exported before addresses were introduced is refused** (`[graph/retiredField]` for `wires`, a binding\n with `path`, `adoptForm: true`; `[address/bareIdentifier]` for a bare key). Do not patch it by\n hand \u2014 export it again (the server migration folded the live graph onto addresses).\n- The spelling \u2014 **always in single quotes on the command line**, or the shell expands `$node`:\n\n | Address | Names | Example (demo tenant `test`) |\n |---|---|---|\n | `$node.<formNode>.admission` | the form instance a form node creates | `$node.form.admission` |\n | `$node.<formNode>.admission.<field>` | one field (or export, or party leaf `beneficiary` / `signers`) of it | `$node.form.admission.kind.geburtsurkunde` |\n | `$node.<node>.document` | the newest revision of a document node's slot | `$node.platzangebot.document` |\n | `$node.<node>.contract` | a machine-produced contract (`production: resolver`) | `$node.contract.contract` |\n | `$node.<node>.payment` | a payment node's result | `$node.zahlung.payment` |\n | `$task.<task>.<key>` | the value the ONE task `<task>` writes under store key `<key>` | `$task.reducedFee.reducedFee` |\n | `$env.applicant.language` | a fact about the application nobody produces | |\n\n An adopting form node (`adoptForm`, e.g. `formZusage` in the demo tenant `test`) **produces nothing**: the\n instance stays its creator's, so every later node still reads `$node.form.admission.\u2026`.\n\n## Steps\n```bash\n# What arrives at a node: every address it reads, where it is written, who produces it \u2014\n# including what it reads by carrying (the evidence of a task whose value it reads):\nplexus-cli offer workflow node reads --dir <dir> --node contract\n\n# A bare key is refused with the list of what that node can read \u2014 use it to pick:\nplexus-cli offer workflow node set-reads --dir <dir> --node contract --address kind.vorname\n# \u2192 --address (reads) \"kind.vorname\": ein nackter Schl\xFCssel \u2026\n# An \u201EVertrag\" (contract) lesbar:\n# Bewerbung Gymnasium Havelland \u203A Anmeldung ($node.form.admission)\n# Pr\xFCfung \u203A Schulgeld mit Erm\xE4\xDFigung \u203A Einkommenserm\xE4\xDFigung ($task.reducedFee.reducedFee)\n# \u2026\n\n# The flags that read data (each takes full addresses):\nplexus-cli offer workflow node set-input --dir <dir> --node contract --input reducedFee --address '$task.reducedFee.reducedFee'\nplexus-cli offer workflow node set-reads --dir <dir> --node contract --from form --field kind.vorname,kind.nachname\nplexus-cli offer workflow node set-requires --dir <dir> --node nachreichen --address '$node.form.admission.kind.masernschutz'\nplexus-cli offer workflow node task set --dir <dir> --node reviewEingereicht --key reducedFee \\\n --when '$node.form.admission.ermaessigungBeantragt' --reads '$node.form.admission.gebuehren.einkommensnachweise'\nplexus-cli offer workflow node add --dir <dir> --type setFlag ... --target '$node.form.admission'\nplexus-cli offer workflow node add --dir <dir> --type form ... --adopt-form '$node.form.admission'\nplexus-cli offer workflow node add --dir <dir> --type countersign ... --contract '$node.contract.contract'\n```\n\nThe short form `--from <formNode> --field <path>` (set-input, `*-reads`, `*-requires`) only\ncomposes `$node.<formNode>.admission.<path>` \u2014 it names the node, it never picks one.\n\nWhich flag sets which field:\n\n| Field | Verb / flag |\n|---|---|\n| an input binding | `node set-input --address` (or `--from/--field`) |\n| `reads` (decision / governedDocument) | `node set-reads|add-reads|remove-reads --address` |\n| `requires` (completenessCheck) | `node set-requires|add-requires|remove-requires --address`; at add: `--require` |\n| setFlag `inputs.target` (a binding) | `node add|set --target` |\n| form `adoptForm` | `node add --adopt-form` |\n| resolver governedDocument / engagePush / review `form` | `node set --form '<instance address>'` (engagePush and review also at add) |\n| countersign / engagePush `contract`, engagePush `payment` | `node add|set --contract|--payment` |\n| roleAssign / completenessCheck `person` | `node add|set --person` |\n| task `when`, `reads`, `documents` | `node task add|set --when|--reads|--documents` (`field:<address>`; a document slot \u2014 the node's own or an earlier node's \u2014 is `artifact:<key>`, no address) |\n| task family request | `--family-request-fields <addresses>` or `--family-request-from '$node.<form>.admission'` |\n| record field suggestion | `--field '{\u2026,\"suggest\":{\"kind\":\"form\",\"address\":\"$node.form.admission.alleinerziehend\"}}'` |\n\n## In the IDE instead\nThe Workflow-IDE offers exactly what the gate accepts \u2014 the same rules\n(`addressFieldOptions`), one picker in every editor, never a typed key:\n- **What arrives at a node:** select it \u2014 the bottom bar's \u201EEingang\" column lists\n its reads and what it may read (Formular \xB7 Dokumente \xB7 Zahlungen \xB7 Aufgaben \xB7\n Abgeleitet \xB7 Umgebung), each with producer, address and how it is read; a rose\n entry is a read publish refuses (`[address/notVisible]`). Drag an entry onto a\n parameter to bind it.\n- **Node fields** (`reads`, `requires`, `adoptForm`, `form` /\n `contract` / `payment`): node \u2192 \u201EDetails\" \u2192 \u201EEinstellungen\". A setFlag's form is its\n `target` INPUT: picked in the bottom bar's PARAMETER column, with its flag and\n raise / lower.\n- **Task fields** (`when`, `reads`, `documents`, `familyRequest`, a record's\n suggestion): node \u2192 \u201EDetails\" \u2192 \u201ETeam\".\n- **Pricing-rule conditions and reductions:** bundle only; prices belong to the\n contract generator.\n\n## Verify\n```bash\nplexus-cli offer validate --dir <dir> # exit 0, no [address/*] error\nplexus-cli offer workflow node reads --dir <dir> --node <id> --json\nplexus-cli --env staging --tenant <t> offer plan --dir <dir> # ~ workflow; address:/reads: rows against the live head (see edit-live-tenant-offer.md)\n```\n\n## Idempotency / gotchas\n- **The gate judges every address** before writing: `[address/shape]`, `[address/bareIdentifier]`,\n `[address/unknownOwner]` (no such node / task), `[address/unknownKey]` (the node does not\n produce it \u2014 a form produces `admission`, a resolver contract `contract`, not `document`),\n `[address/ownerNotWriter]` (the task does not write that store key), `[address/notVisible]`\n (the producer is not on EVERY path before the reader \u2014 on a detour the reader would wait\n forever), `[address/pathNotInTarget]` (the form has no such field), `[address/notExported]` (it has\n the field but does not export it, or the `formExports` stamp is stale), `[address/typeMismatch]`\n (a `when` must be a yes/no export, a binding must fit its slot), `[address/notFormInstance]`\n (`target`, `adoptForm`, `form`, `familyRequest.from` name `$node.<creating form>.admission`\n without a path), `[address/mixedForms]` (one list \u2014 node `reads`, `requires`, a task's\n `when` + `reads`, `familyRequest.fields` \u2014 names ONE form), `[address/missing]` (countersign\n `contract`, a resolver's / engagePush's `form`; an unbound setFlag `inputs.target` is the\n required-slot finding). Only errors the edit\n INTRODUCES block it; errors the bundle already had are printed as \u201Evorbestehend\".\n- **A node reads its own results** (a value one of its tasks writes, its own document slot)\n without dominance; it is still in its read list.\n- **`node delete` refuses while an address names the node** \u2014 its form instance, document,\n contract, payment, or a value one of its tasks writes \u2014 and lists every place (config path +\n address). Edit those first; nothing is dropped silently.\n- **Renaming a task key or moving a writing task to another node** changes the address\n (`$task.<task>.<key>`): every reader must be edited, and running applications cannot re-pin\n across it.\n- Nothing reaches a live process until `offer apply --publish`; running applications keep their\n pinned version.\n\n## Related\n- [Bind a node input](./bind-node-input.md) \xB7 [Declare what a document node reads](./declare-node-reads.md)\n- [Add a workflow node](./add-workflow-node.md) \xB7 [Countersign the contract](./countersign-node.md) \xB7 [Node tasks](./node-tasks.md)\n- [Edit a live tenant's offer](./edit-live-tenant-offer.md) \u2014 export, plan and apply against a live tenant\n","references/offer/assignment-rule.md":`# Change an offer's assignment rule (Zust\xE4ndigkeitsregel)
6656
6656
 
6657
6657
  **When to use:** decide who becomes responsible for a new application and who owns
6658
6658
  each team's tasks \u2014 for a new offer, after staff changes, or when a workflow starts
@@ -6662,7 +6662,7 @@ is leaving.
6662
6662
  ## What it is (one paragraph)
6663
6663
 
6664
6664
  The assignment rule is a **section of the workflow graph**: \`graph.assignmentRules\`
6665
- in the offer bundle's \`workflow.json\`. It is **one ordered rule list per slot**: per
6665
+ in the offer bundle's workflow file. It is **one ordered rule list per slot**: per
6666
6666
  slot the first row whose condition holds wins, the last row has no condition
6667
6667
  (\`"when": null\`, shown as \u201Esonst"). It is versioned with the offer version \u2014 saved
6668
6668
  with the draft, checked at publish, pinned with the graph. Each new application
@@ -6711,7 +6711,7 @@ a fixed person.
6711
6711
  1. Export the live offer into a private scratch dir (a live tenant's bundle is
6712
6712
  never kept in a shared or versioned place \u2014 see
6713
6713
  [edit-live-tenant-offer](./edit-live-tenant-offer.md)) and edit
6714
- \`workflow.json\` \u2192 \`graph.assignmentRules\`:
6714
+ The workflow file \u2192 \`graph.assignmentRules\`:
6715
6715
 
6716
6716
  \`\`\`bash
6717
6717
  WORK=$(mktemp -d) # any private scratch dir
@@ -6837,7 +6837,7 @@ version (archived ones only run pinned test starts, which fail loud instead). Or
6837
6837
  \u201Esonst \u2192 Team-Queue". Publish refuses until \u201EPerson w\xE4hlen" is replaced.
6838
6838
  - Applications already started keep the rule of the version they are pinned to \u2014
6839
6839
  a published change reaches only new applications.
6840
- - **The bundle is canonical JSON (keys sorted).** When you edit \`workflow.json\` by
6840
+ - **The bundle is canonical JSON (keys sorted).** When you edit the workflow file by
6841
6841
  hand or by script, keep that shape \u2014 a re-serialised file differs from a fresh
6842
6842
  export far from your edit \u2014 and check the result with \`offer validate\` and
6843
6843
  \`offer plan\` (only your rule change should show).
@@ -6847,7 +6847,86 @@ version (archived ones only run pinned test starts, which fail loud instead). Or
6847
6847
  - [Release an offer bundle](./publish-offer-bundle.md) \u2014 publishing and checking it went live.
6848
6848
  - [Edit a live tenant's offer](./edit-live-tenant-offer.md) \u2014 export, plan, apply.
6849
6849
  - \`plexus-cli assignment simulate --help\` \u2014 the test bench's flags.
6850
- `,"references/offer/attach-form-to-workflow.md":'# Attach a SmartForm to a workflow form node\n\n**When to use:** an offer\'s workflow needs a `form` step \u2014 bind an existing\nSmartForm to a new form node, or scaffold a brand-new form and bind it in one\nstep. Replaces hand-editing `workflow.json` + `bundle.yaml` + `smartforms/<slug>.json`\nin lockstep.\n\n## Prerequisites\n- A bundle on disk (`offer init` / `offer export`). Authoring is **offline**;\n only `offer apply --publish` is online (needs `--env` + an API token).\n- An installed, current `plexus-cli` (`plexus-cli --help`).\n\n## Steps\n```bash\n# A. Bind an EXISTING form (created earlier with `offer form add`).\nplexus-cli offer workflow node add --dir <bundle> \\\n --type form --form <form-slug> --label "<Step label>" --label-en "<English step label>" --after <nodeId>\n\n# B. Scaffold a NEW form AND bind it, in one command.\n# --form is the new form\'s slug; --label is the node + form label.\nplexus-cli offer workflow node add --dir <bundle> \\\n --type form --new-form --form zusatzformular --label "Zusatzangaben" --label-en "Additional details" --after approval\n\n# C. CONTINUE the instance an earlier form node created (a second step of the same\n# form, e.g. the Gymnasium\'s `formZusage` after the Zusage): no --form; the node\n# names the instance it continues (single quotes \u2014 the shell expands $).\nplexus-cli offer workflow node add --dir <bundle> \\\n --type form --node formZusage --label "Angaben nach der Zusage" --label-en "Details after the offer" \\\n --after setFlagZusage --adopt-form \'$node.form.admission\'\n\n# Then fill the (new) form out \u2014 see Author a SmartForm as code.\nplexus-cli offer form field add --dir <bundle> --form zusatzformular \\\n --section section.allgemein --key zusatz.notiz --type string --label "Notiz"\n\n# Validate offline against the real publish gate, then publish.\nplexus-cli offer validate --dir <bundle>\nplexus-cli --env <env> --tenant test offer apply --publish --dir <bundle>\n```\n\nThe form node is written with `inputs.smartForm = { kind: "literal", value: <slug> }`,\na default `standard` outcome, and the SmartForm lifecycle progress states\n(`started` / `submitted`) materialised into the process board + wiring automatically.\nThe outcome only routes: later nodes read the answers at the node\'s address,\n`$node.<formNode>.admission.<field>` (see [Name what a node reads](./addresses.md)).\nAn adopting node (C) produces nothing: the instance stays its creator\'s, so every later\nnode still reads `$node.<creator>.admission.\u2026`.\n\n## Verify\n```bash\nplexus-cli offer workflow show --dir <bundle> # the form node + routing appear\nplexus-cli offer form list --dir <bundle> # the bound form shows bound=yes\nplexus-cli offer validate --dir <bundle> # "local validation clean"\n```\n\n## Idempotency / gotchas\n- **`--type form` requires `--form <slug>`** \u2014 bind target (existing) or new slug\n (with `--new-form`) \u2014 or `--adopt-form \'<instance address>\'` (never both). Without\n either, the command fails loud. A bare `--adopt-form form` is refused with the\n addresses visible at the node; an adopting node pointing at a non-creating form is\n `[address/notFormInstance]`.\n- **`--new-form` fails if the slug already exists** (no silent overwrite) and is\n only valid with `--type form`.\n- **Binding a non-existent form fails loud** (`no smartform "<slug>"`) \u2014 create it\n with `offer form add` first, or use `--new-form`.\n- **A scaffolded form starts empty** (one section, default outcome). Add fields\n with `offer form field add` before publishing anything user-facing.\n- **Publish pins the form version.** `offer apply --publish` publishes the\n smartform(s) *then* the workflow, so the workflow pins the just-published version.\n Re-publishing the whole bundle after a form edit re-pins it; a standalone form\n publish would leave the workflow on the old version.\n- **`offer workflow node delete`** of the form node leaves the form carried-but-unbound\n (a warning); remove the form too with `offer form delete` if it\'s no longer needed. It is\n refused while any address still names the node (`$node.<formNode>.admission\u2026` in a\n binding, `reads`, `requires`, a task, `target`, `adoptForm`) \u2014 the refusal lists them.\n\n## Related\n- [Add a workflow node](./add-workflow-node.md) \u2014 other node types + splice rules.\n- [Author a SmartForm as code](./author-smartform.md) \u2014 build the form\'s contents.\n- `plexus-cli offer --help` \u2014 the full `offer \u2026` command reference.\n',"references/offer/author-form-scenarios.md":'# Author a form\'s test scenarios and environment variables\n\n**When to use:** give a SmartForm one-click test-mode prefills (`testScenarios`) or let\nits expressions read where the form is filled in (`env`: `$env.stage.key`, \u2026) \u2014\nwithout hand-editing the form JSON. `$env` is the ONE root for a fact about the\napplication; the graph and the assignment rules read the same variables.\n\n**A scenario fits every grade and school year.** It is a name and values, nothing\nelse: the test application supplies its own environment (grade, school year, offer,\napplicant), exactly like a real application. Two or three scenarios per offer are\nenough \u2014 \u201ERegul\xE4r", \u201EMit Erm\xE4\xDFigung" \u2014 never one per grade. Validation submits every\nscenario under every grade \xD7 school year of the offer and names the grade where one\nfails.\n\n## Prerequisites\n- An offer bundle on disk carrying the form (`offer export \u2026` / `offer init \u2026`).\n- Fully offline; every command runs the publish gate on the result and writes nothing\n when it fails.\n\n## Steps\n```bash\n# A scenario: id (kebab-case), label, prefill. Values are typed by the FIELD:\n# boolean true|false, a multi-select enum a,b, everything else a string.\nplexus-cli offer form scenario add --dir <bundle> --id standard --label "Standardfall" \\\n --label-en "Standard case" \\\n --prefill kind.vorname=Anna --prefill kind.nachname=Muster --prefill agb=true\n\n# Addresses and repeated rows do not fit key=value \u2014 give the whole prefill as JSON:\nplexus-cli offer form scenario add --dir <bundle> --id geschwister --label "Mit Geschwistern" --label-en "With siblings" \\\n --prefill-json \'{"kind.vorname":"Anna","geschwister":[{"name":"Ben"}]}\'\n\n# A variant of an existing scenario: --from copies its prefill, --prefill overrides\n# single keys (e.g. the regular case + a reduced-fee request).\nplexus-cli offer form scenario add --dir <bundle> --id mit-ermaessigung --from standard \\\n --label "Mit Erm\xE4\xDFigung" --label-en "Reduced fees" \\\n --prefill gebuehren.ermaessigung=true\n\n# Edit: --prefill MERGES, --prefill-json REPLACES, --unset removes keys.\nplexus-cli offer form scenario set --dir <bundle> --id standard --prefill kind.vorname=Lea --unset agb\nplexus-cli offer form scenario delete --dir <bundle> --id geschwister\n\n# Environment: declare the keys the form reads. Scenarios sample nothing.\nplexus-cli offer form env set --dir <bundle> --keys stage,run\n\n# Remove the declaration:\nplexus-cli offer form env set --dir <bundle> --keys ""\n```\n\nEnvironment keys: `offer`, `unit`, `stage`, `run`, `applicant` \u2014 the one vocabulary,\nlisted with labels in the IDE tab \u201EUmgebungsvariablen".\n`stage.key` is the BUNDLE key (`program.stages[].key`).\n\n**A value that depends on the grade or school year** is not a scenario\'s business:\ngive the field a `defaultValue` over `$env` (an enrolment date = `$env.run.startDate`)\nand leave it out of every scenario \u2014 an entered value always wins over the default,\nand each test application gets the value of its own cohort. A value for a question\nthat only one grade asks is harmless in the others: the question is hidden there and\nthe value is put aside at submit.\n\n**No fallback.** `$env.applicant.language` is EMPTY (`null`) for an application\nwithout an applicant account (started by staff); `$env.stage.gradeLevel` and\n`$env.run.startDate` can be empty too. `==` is false over null and needs nothing; `!=`\nand `!` are TRUE over null, so the gate refuses them without a guard\n(`[env/unguardedNullable]`) \u2014 write what an empty value means:\n`$env.applicant.language != null && $env.applicant.language != \'de\'`. The names\n(`offer.title`, `unit.name`, `stage.name`, `run.name`) are in the applicant\'s language,\nGerman without an applicant account (declared at the variable).\n\n## Verify\n```bash\nplexus-cli offer validate --dir <bundle> # scenarios are submitted through the real submit gate\nplexus-cli offer form show --dir <bundle>\n```\n\nAfter publishing, run a scenario on a test application from the terminal:\n`plexus-cli --env staging --tenant <t> test-actions run --application <id> --action load-scenario:<scenarioId>`\n\u2014 see [Drive a test application through test mode](../test-actions/drive-a-test-application.md).\n\n## Idempotency / gotchas\n- A scenario that leaves a visible required field empty, or reaches no outcome, is\n refused (`scenario.required-field-unfilled` / `scenario.no-outcome`) \u2014 the message ends\n with the grades and school years where it fails (\u201E\u2014 in: Year 1 \xB7 School year 2026/27").\n docRef fields are never prefilled \u2014 test mode stubs files itself.\n- Offline, validation knows the grades and school years only from `bundle.yaml`\n (`program.stages`, `program.runs`). A bundle without them, or a form that reads\n `offer` / `unit`, gets the warning `scenario.unjudged`: publishing judges the\n scenarios against the offer\'s real cohorts. An offer without any cohort gets\n `scenario.no-environment` \u2014 publish again once one exists.\n- A bundle whose scenarios still carry an environment sample (`testScenarios[].env`,\n one scenario per grade) is refused until `plexus-cli offer upgrade --dir <bundle> --write`\n removes the samples. The upgrade keeps every scenario; the ones that only differed by\n grade are duplicates afterwards \u2014 delete them with `offer form scenario delete`.\n- A bundle exported before `$env` replaced `context` carries `context` (declaration and samples) and\n `$ctx.*` expressions: refused (`[env/retiredField]`, unknown identifier). Export\n again \u2014 the stored definitions on the server already use `$env`.\n- `--from` copies the prefill, not the base\'s description (it describes the base);\n `--from` with `--prefill-json` is refused \u2014 that would discard the copy. The copy is a\n snapshot: a later change to the base does not reach the variant.\n- File fields need no prefill: with \u201EAutomatisch absenden\u201C (default on) loading a scenario\n fills every docRef field of the form\'s sections and groups with an openable stub file\n (named after the field, of a type the field accepts) and then submits \u2014 also the fields\n the scenario only makes visible (income proofs behind `financialAid=true`). The fill runs\n as a scheduled action, so the submit lands a moment later. Without auto-submit, run the\n test action \u201EFile-Felder mit Dummy f\xFCllen\u201C (`auto-fill-files`) yourself. A docRef inside\n a repeated block is not filled.\n- `--prefill` names an unknown key \u2192 refused; so does a docRef or an address key (use\n `--prefill-json` for the address).\n- Label and description need their English in the same call (`--label-en`,\n `--description-en`); see [Edit a SmartForm in depth](./edit-smartform.md) \u2192 English texts.\n\n## Related\n- [Author a SmartForm as code](./author-smartform.md) \xB7 [Edit a SmartForm in depth](./edit-smartform.md)\n',"references/offer/author-manifest-meta.md":'# Author the manifest layer\n\n**When to use:** set the offer\'s display order from the CLI. `manifest.json` carries no\nkey any more (`{}`): the offer title is `bundle.yaml` `label`, the progress layout is\n`workflow.json` `progressLayout`, capacity and the application window belong to the\ncohort (`offer capacity set`, `offer run \u2026`), and the waiting list\'s order is the\nwaitlist node\'s required input `waitlistOrder` (arrival|manual) \u2014 `offer workflow node\nadd --type waitlist --waitlist-order \u2026`, `offer workflow node set-input`, or the IDE\'s\nPARAMETER column. A freed seat promotes nobody on its own.\n\n## Prerequisites\n- An offer bundle on disk (`offer init \u2026` or `offer export \u2026`).\n- Authoring is **fully offline**; only `offer apply --publish` needs an API token of a\n user who may configure the tenant\'s offers (a tenant admin \u2014 see\n [Add a tenant admin](../users/add-tenant-admin.md)).\n- An installed, current `plexus-cli` (`plexus-cli offer manifest set --help`).\n\n## Steps\n```bash\n# Display order among the unit\'s offers (lower = first; "" clears). A family\n# property like the title \u2014 lives on bundle.yaml, applied via createManifest.\nplexus-cli offer manifest set --dir <bundle> --sort-order 20\n\n# Validate + publish.\nplexus-cli offer validate --dir <bundle>\nplexus-cli --env <env> offer apply --publish --dir <bundle>\n```\n\n## Verify\n```bash\nplexus-cli offer validate --dir <bundle> # "local validation clean"\ncat <bundle>/manifest.json # {}\n```\n\n## Idempotency / gotchas\n- **Offer title is a BARE name \u2014 never embed the run/year or levels.** The offer\n `label` (set via `offer init/set --title`) is just the program name, e.g.\n "Grundschule" / "Primary School". The school-year cycle is a separate entity\n (`program_runs.name`, e.g. "2026/27") and grade levels are `program_stages` \u2014 the UI\n shows runs nested under the offer (internal sidebar) and as a separate dropdown\n (external portal), so it **never composes** them into the title. Putting\n "\xB7 Aufnahme 2026/27" in the title makes the cycle show twice. Levels/runs are managed\n with `offer level \u2026` / `offer run \u2026`, not the title.\n- **`--title` (offer label) is the offer-title SoT \u2014 `--program-name` is separate.**\n `offer set --title` (+ `--title-en`) writes the offer title (`offers.label`), the single source the staff Angebote\n tree, external portal, and applicant "Meine Bewerbungen" all read. The underlying\n master-data `programs.name` is a *copy* made at authoring time that only shows in the\n staff master-data admin; it can drift from the label. Use `offer set --program-name\n "<bare name>" --program-name-en "<English>"` (\u2192 `programAdmin.updateProgram`) to bring a drifted program name back in\n line \u2014 e.g. after fixing a label that had been authored with a run/year baked in. You\n almost never need `--program-name`; reach for it only to clean up master-data drift.\n- **`--sort-order` orders offers within a unit** (lower = first); the sibling unit\n order is set as code via tenant config (`TenantConfigUnitDefinition.sortOrder`). Both\n apply to the internal Angebote sidebar AND the external `/e` portal; offers/units\n without a sortOrder fall back to creation-time / alphabetical respectively.\n- **Validate-before-write.** Every mutator runs the real publish gate first; on any\n error it writes **nothing**.\n- **A retired manifest key is refused, never dropped.** `offer validate` (and apply)\n refuse every key by name \u2014 `selection`, `capacity`, `roleInstances`, `leistungen`,\n `applicantMode`, `signatureLevel`, `bewerbungsfenster`, `id`, `label`, `version`,\n `progressLayoutId` \u2014 with "Delete the line". `progressLayout` moves to `workflow.json`\n (without a workflow: delete it).\n\n## Related\n- [Author a SmartForm as code](./author-smartform.md) \xB7 [Edit a workflow node](./edit-workflow-node.md).\n- Command reference: `plexus-cli offer manifest set --help`.\n',"references/offer/author-smartform.md":`# Author a SmartForm as code
6850
+ `,"references/offer/attach-form-to-workflow.md":`# Attach a SmartForm to a workflow form node
6851
+
6852
+ **When to use:** an offer's workflow needs a \`form\` step \u2014 bind an existing
6853
+ SmartForm to a new form node, or scaffold a brand-new form and bind it in one
6854
+ step. Replaces hand-editing the workflow file + the bundle file + \`smartforms/<slug>.json\`
6855
+ in lockstep.
6856
+
6857
+ ## Prerequisites
6858
+ - A bundle on disk (\`offer init\` / \`offer export\`). Authoring is **offline**;
6859
+ only \`offer apply --publish\` is online (needs \`--env\` + an API token).
6860
+ - An installed, current \`plexus-cli\` (\`plexus-cli --help\`).
6861
+
6862
+ ## Steps
6863
+ \`\`\`bash
6864
+ # A. Bind an EXISTING form (created earlier with \`offer form add\`).
6865
+ plexus-cli offer workflow node add --dir <bundle> \\
6866
+ --type form --form <form-slug> --label "<Step label>" --label-en "<English step label>" --after <nodeId>
6867
+
6868
+ # B. Scaffold a NEW form AND bind it, in one command.
6869
+ # --form is the new form's slug; --label is the node + form label.
6870
+ plexus-cli offer workflow node add --dir <bundle> \\
6871
+ --type form --new-form --form zusatzformular --label "Zusatzangaben" --label-en "Additional details" --after approval
6872
+
6873
+ # C. CONTINUE the instance an earlier form node created (a second step of the same
6874
+ # form, e.g. the Gymnasium's \`formZusage\` after the Zusage): no --form; the node
6875
+ # names the instance it continues (single quotes \u2014 the shell expands $).
6876
+ plexus-cli offer workflow node add --dir <bundle> \\
6877
+ --type form --node formZusage --label "Angaben nach der Zusage" --label-en "Details after the offer" \\
6878
+ --after setFlagZusage --adopt-form '$node.form.admission'
6879
+
6880
+ # Then fill the (new) form out \u2014 see Author a SmartForm as code.
6881
+ plexus-cli offer form field add --dir <bundle> --form zusatzformular \\
6882
+ --section section.allgemein --key zusatz.notiz --type string --label "Notiz"
6883
+
6884
+ # Validate offline against the real publish gate, then publish.
6885
+ plexus-cli offer validate --dir <bundle>
6886
+ plexus-cli --env <env> --tenant test offer apply --publish --dir <bundle>
6887
+ \`\`\`
6888
+
6889
+ The form node is written with \`inputs.smartForm = { kind: "literal", value: <slug> }\`,
6890
+ a default \`standard\` outcome, and the SmartForm lifecycle progress states
6891
+ (\`started\` / \`submitted\`) materialised into the process board + wiring automatically.
6892
+ The outcome only routes: later nodes read the answers at the node's address,
6893
+ \`$node.<formNode>.admission.<field>\` (see [Name what a node reads](./addresses.md)).
6894
+ An adopting node (C) produces nothing: the instance stays its creator's, so every later
6895
+ node still reads \`$node.<creator>.admission.\u2026\`.
6896
+
6897
+ ## Verify
6898
+ \`\`\`bash
6899
+ plexus-cli offer workflow show --dir <bundle> # the form node + routing appear
6900
+ plexus-cli offer form list --dir <bundle> # the bound form shows bound=yes
6901
+ plexus-cli offer validate --dir <bundle> # "local validation clean"
6902
+ \`\`\`
6903
+
6904
+ ## Idempotency / gotchas
6905
+ - **\`--type form\` requires \`--form <slug>\`** \u2014 bind target (existing) or new slug
6906
+ (with \`--new-form\`) \u2014 or \`--adopt-form '<instance address>'\` (never both). Without
6907
+ either, the command fails loud. A bare \`--adopt-form form\` is refused with the
6908
+ addresses visible at the node; an adopting node pointing at a non-creating form is
6909
+ \`[address/notFormInstance]\`.
6910
+ - **\`--new-form\` fails if the slug already exists** (no silent overwrite) and is
6911
+ only valid with \`--type form\`.
6912
+ - **Binding a non-existent form fails loud** (\`no smartform "<slug>"\`) \u2014 create it
6913
+ with \`offer form add\` first, or use \`--new-form\`.
6914
+ - **A scaffolded form starts empty** (one section, default outcome). Add fields
6915
+ with \`offer form field add\` before publishing anything user-facing.
6916
+ - **Publish pins the form version.** \`offer apply --publish\` publishes the
6917
+ smartform(s) *then* the workflow, so the workflow pins the just-published version.
6918
+ Re-publishing the whole bundle after a form edit re-pins it; a standalone form
6919
+ publish would leave the workflow on the old version.
6920
+ - **\`offer workflow node delete\`** of the form node leaves the form carried-but-unbound
6921
+ (a warning); remove the form too with \`offer form delete\` if it's no longer needed. It is
6922
+ refused while any address still names the node (\`$node.<formNode>.admission\u2026\` in a
6923
+ binding, \`reads\`, \`requires\`, a task, \`target\`, \`adoptForm\`) \u2014 the refusal lists them.
6924
+
6925
+ ## Related
6926
+ - [Add a workflow node](./add-workflow-node.md) \u2014 other node types + splice rules.
6927
+ - [Author a SmartForm as code](./author-smartform.md) \u2014 build the form's contents.
6928
+ - \`plexus-cli offer --help\` \u2014 the full \`offer \u2026\` command reference.
6929
+ `,"references/offer/author-form-scenarios.md":'# Author a form\'s test scenarios and environment variables\n\n**When to use:** give a SmartForm one-click test-mode prefills (`testScenarios`) or let\nits expressions read where the form is filled in (`env`: `$env.stage.key`, \u2026) \u2014\nwithout hand-editing the form JSON. `$env` is the ONE root for a fact about the\napplication; the graph and the assignment rules read the same variables.\n\n**A scenario fits every grade and school year.** It is a name and values, nothing\nelse: the test application supplies its own environment (grade, school year, offer,\napplicant), exactly like a real application. Two or three scenarios per offer are\nenough \u2014 \u201ERegul\xE4r", \u201EMit Erm\xE4\xDFigung" \u2014 never one per grade. Validation submits every\nscenario under every grade \xD7 school year of the offer and names the grade where one\nfails.\n\n## Prerequisites\n- An offer bundle on disk carrying the form (`offer export \u2026` / `offer init \u2026`).\n- Fully offline; every command runs the publish gate on the result and writes nothing\n when it fails.\n\n## Steps\n```bash\n# A scenario: id (kebab-case), label, prefill. Values are typed by the FIELD:\n# boolean true|false, a multi-select enum a,b, everything else a string.\nplexus-cli offer form scenario add --dir <bundle> --id standard --label "Standardfall" \\\n --label-en "Standard case" \\\n --prefill kind.vorname=Anna --prefill kind.nachname=Muster --prefill agb=true\n\n# Addresses and repeated rows do not fit key=value \u2014 give the whole prefill as JSON:\nplexus-cli offer form scenario add --dir <bundle> --id geschwister --label "Mit Geschwistern" --label-en "With siblings" \\\n --prefill-json \'{"kind.vorname":"Anna","geschwister":[{"name":"Ben"}]}\'\n\n# A variant of an existing scenario: --from copies its prefill, --prefill overrides\n# single keys (e.g. the regular case + a reduced-fee request).\nplexus-cli offer form scenario add --dir <bundle> --id mit-ermaessigung --from standard \\\n --label "Mit Erm\xE4\xDFigung" --label-en "Reduced fees" \\\n --prefill gebuehren.ermaessigung=true\n\n# Edit: --prefill MERGES, --prefill-json REPLACES, --unset removes keys.\nplexus-cli offer form scenario set --dir <bundle> --id standard --prefill kind.vorname=Lea --unset agb\nplexus-cli offer form scenario delete --dir <bundle> --id geschwister\n\n# Environment: declare the keys the form reads. Scenarios sample nothing.\nplexus-cli offer form env set --dir <bundle> --keys stage,run\n\n# Remove the declaration:\nplexus-cli offer form env set --dir <bundle> --keys ""\n```\n\nEnvironment keys: `offer`, `unit`, `stage`, `run`, `applicant` \u2014 the one vocabulary,\nlisted with labels in the IDE tab \u201EUmgebungsvariablen".\n`stage.key` is the BUNDLE key (`program.stages[].key`).\n\n**A value that depends on the grade or school year** is not a scenario\'s business:\ngive the field a `defaultValue` over `$env` (an enrolment date = `$env.run.startDate`)\nand leave it out of every scenario \u2014 an entered value always wins over the default,\nand each test application gets the value of its own cohort. A value for a question\nthat only one grade asks is harmless in the others: the question is hidden there and\nthe value is put aside at submit.\n\n**No fallback.** `$env.applicant.language` is EMPTY (`null`) for an application\nwithout an applicant account (started by staff); `$env.stage.gradeLevel` and\n`$env.run.startDate` can be empty too. `==` is false over null and needs nothing; `!=`\nand `!` are TRUE over null, so the gate refuses them without a guard\n(`[env/unguardedNullable]`) \u2014 write what an empty value means:\n`$env.applicant.language != null && $env.applicant.language != \'de\'`. The names\n(`offer.title`, `unit.name`, `stage.name`, `run.name`) are in the applicant\'s language,\nGerman without an applicant account (declared at the variable).\n\n## Verify\n```bash\nplexus-cli offer validate --dir <bundle> # scenarios are submitted through the real submit gate\nplexus-cli offer form show --dir <bundle>\n```\n\nAfter publishing, run a scenario on a test application from the terminal:\n`plexus-cli --env staging --tenant <t> test-actions run --application <id> --action load-scenario:<scenarioId>`\n\u2014 see [Drive a test application through test mode](../test-actions/drive-a-test-application.md).\n\n## Idempotency / gotchas\n- A scenario that leaves a visible required field empty, or reaches no outcome, is\n refused (`scenario.required-field-unfilled` / `scenario.no-outcome`) \u2014 the message ends\n with the grades and school years where it fails (\u201E\u2014 in: Year 1 \xB7 School year 2026/27").\n docRef fields are never prefilled \u2014 test mode stubs files itself.\n- Offline, validation knows the grades and school years only from the bundle file\n (`program.stages`, `program.runs`). A bundle without them, or a form that reads\n `offer` / `unit`, gets the warning `scenario.unjudged`: publishing judges the\n scenarios against the offer\'s real cohorts. An offer without any cohort gets\n `scenario.no-environment` \u2014 publish again once one exists.\n- A bundle whose scenarios still carry an environment sample (`testScenarios[].env`,\n one scenario per grade) is refused until `plexus-cli offer upgrade --dir <bundle> --write`\n removes the samples. The upgrade keeps every scenario; the ones that only differed by\n grade are duplicates afterwards \u2014 delete them with `offer form scenario delete`.\n- A bundle exported before `$env` replaced `context` carries `context` (declaration and samples) and\n `$ctx.*` expressions: refused (`[env/retiredField]`, unknown identifier). Export\n again \u2014 the stored definitions on the server already use `$env`.\n- `--from` copies the prefill, not the base\'s description (it describes the base);\n `--from` with `--prefill-json` is refused \u2014 that would discard the copy. The copy is a\n snapshot: a later change to the base does not reach the variant.\n- File fields need no prefill: with \u201EAutomatisch absenden\u201C (default on) loading a scenario\n fills every docRef field of the form\'s sections and groups with an openable stub file\n (named after the field, of a type the field accepts) and then submits \u2014 also the fields\n the scenario only makes visible (income proofs behind `financialAid=true`). The fill runs\n as a scheduled action, so the submit lands a moment later. Without auto-submit, run the\n test action \u201EFile-Felder mit Dummy f\xFCllen\u201C (`auto-fill-files`) yourself. A docRef inside\n a repeated block is not filled.\n- `--prefill` names an unknown key \u2192 refused; so does a docRef or an address key (use\n `--prefill-json` for the address).\n- Label and description need their English in the same call (`--label-en`,\n `--description-en`); see [Edit a SmartForm in depth](./edit-smartform.md) \u2192 English texts.\n\n## Related\n- [Author a SmartForm as code](./author-smartform.md) \xB7 [Edit a SmartForm in depth](./edit-smartform.md)\n',"references/offer/author-manifest-meta.md":'# Author the manifest layer\n\n**When to use:** set the offer\'s display order from the CLI. The manifest file carries no\nkey any more (`{}`): the offer title is the bundle file `label`, the progress layout is\nthe workflow file `progressLayout`, capacity and the application window belong to the\ncohort (`offer capacity set`, `offer run \u2026`), and the waiting list\'s order is the\nwaitlist node\'s required input `waitlistOrder` (arrival|manual) \u2014 `offer workflow node\nadd --type waitlist --waitlist-order \u2026`, `offer workflow node set-input`, or the IDE\'s\nPARAMETER column. A freed seat promotes nobody on its own.\n\n## Prerequisites\n- An offer bundle on disk (`offer init \u2026` or `offer export \u2026`).\n- Authoring is **fully offline**; only `offer apply --publish` needs an API token of a\n user who may configure the tenant\'s offers (a tenant admin \u2014 see\n [Add a tenant admin](../users/add-tenant-admin.md)).\n- An installed, current `plexus-cli` (`plexus-cli offer manifest set --help`).\n\n## Steps\n```bash\n# Display order among the unit\'s offers (lower = first; "" clears). A family\n# property like the title \u2014 lives on bundle.yaml, applied via createManifest.\nplexus-cli offer manifest set --dir <bundle> --sort-order 20\n\n# Validate + publish.\nplexus-cli offer validate --dir <bundle>\nplexus-cli --env <env> offer apply --publish --dir <bundle>\n```\n\n## Verify\n```bash\nplexus-cli offer validate --dir <bundle> # "local validation clean"\ncat <bundle>/manifest.json # {}\n```\n\n## Idempotency / gotchas\n- **Offer title is a BARE name \u2014 never embed the run/year or levels.** The offer\n `label` (set via `offer init/set --title`) is just the program name, e.g.\n "Grundschule" / "Primary School". The school-year cycle is a separate entity\n (`program_runs.name`, e.g. "2026/27") and grade levels are `program_stages` \u2014 the UI\n shows runs nested under the offer (internal sidebar) and as a separate dropdown\n (external portal), so it **never composes** them into the title. Putting\n "\xB7 Aufnahme 2026/27" in the title makes the cycle show twice. Levels/runs are managed\n with `offer level \u2026` / `offer run \u2026`, not the title.\n- **`--title` (offer label) is the offer-title SoT \u2014 `--program-name` is separate.**\n `offer set --title` (+ `--title-en`) writes the offer title (`offers.label`), the single source the staff Angebote\n tree, external portal, and applicant "Meine Bewerbungen" all read. The underlying\n master-data `programs.name` is a *copy* made at authoring time that only shows in the\n staff master-data admin; it can drift from the label. Use `offer set --program-name\n "<bare name>" --program-name-en "<English>"` (\u2192 `programAdmin.updateProgram`) to bring a drifted program name back in\n line \u2014 e.g. after fixing a label that had been authored with a run/year baked in. You\n almost never need `--program-name`; reach for it only to clean up master-data drift.\n- **`--sort-order` orders offers within a unit** (lower = first); the sibling unit\n order is set as code via tenant config (`TenantConfigUnitDefinition.sortOrder`). Both\n apply to the internal Angebote sidebar AND the external `/e` portal; offers/units\n without a sortOrder fall back to creation-time / alphabetical respectively.\n- **Validate-before-write.** Every mutator runs the real publish gate first; on any\n error it writes **nothing**.\n- **A retired manifest key is refused, never dropped.** `offer validate` (and apply)\n refuse every key by name \u2014 `selection`, `capacity`, `roleInstances`, `leistungen`,\n `applicantMode`, `signatureLevel`, `bewerbungsfenster`, `id`, `label`, `version`,\n `progressLayoutId` \u2014 with "Delete the line". `progressLayout` moves to the workflow file\n (without a workflow: delete it).\n\n## Related\n- [Author a SmartForm as code](./author-smartform.md) \xB7 [Edit a workflow node](./edit-workflow-node.md).\n- Command reference: `plexus-cli offer manifest set --help`.\n',"references/offer/author-smartform.md":`# Author a SmartForm as code
6851
6930
 
6852
6931
  **When to use:** build or change a customer's application form (sections, fields,
6853
6932
  validation/visibility rules, outcomes) entirely from the CLI \u2014 then publish a new
@@ -6968,7 +7047,7 @@ plexus-cli offer validate --dir <bundle> # "local validation clean"
6968
7047
  form node (\`offer workflow node add --type form\`).
6969
7048
  - [Add a tenant admin](../users/add-tenant-admin.md) \u2014 the token \`offer apply --publish\` needs.
6970
7049
  - Command reference: \`plexus-cli offer form --help\`.
6971
- `,"references/offer/bind-node-input.md":"# Bind a node input to an address (form field, task value, applicant language)\n\n**When to use:** a node's input slot must read a value produced elsewhere \u2014 the applicant's\nlanguage for a template letter (`$env.applicant.language`), a value a task records (`$task.reducedFee.reducedFee`), a form field\n(`$node.form.admission.kind.vorname`) \u2014 or carry a fixed value, or go back to its default.\nReplaces hand edits of `inputs` in the bundle's `workflow.json`.\n\n## Prerequisites\n- An offer bundle on disk (`offer export --offer <slug> --out <dir>`). Fully offline: the command\n runs the publish gate on the result and writes nothing when the edit introduces an error. A\n bundle exported before addresses were introduced is refused (`[graph/retiredField]`: a binding with `path`, `wires`)\n \u2014 export it again.\n- The input is a **slot** the node declares. For a template document (`production: 'template'`)\n the slots are its template's parameters, declared on the template record (catalog\n `documentTemplates[].parameters`) and stamped onto the node by `offer plan` \u2014 add the parameter\n there first, then bind.\n `offer workflow node list --dir <dir>` shows the nodes; an unknown slot is refused with the\n node's slots.\n- The **address** names its producer, which must run on every path before the node \u2014 the model\n and the spelling: [Name what a node reads](./addresses.md). Quote it with single quotes.\n\n## Steps\n```bash\n# The offer letter in the applicant's language (demo tenant `test`: platzangebot, field `sprache`):\nplexus-cli offer workflow node set-input --dir <dir> --node platzangebot --input sprache \\\n --address '$env.applicant.language'\n\n# The reduction staff decided, for the generator's input of type `reduction`:\nplexus-cli offer workflow node set-input --dir <dir> --node contract --input reducedFee \\\n --address '$task.reducedFee.reducedFee'\n\n# A form field \u2014 full address, or the short form that composes the same address:\nplexus-cli offer workflow node set-input --dir <dir> --node contract --input startDate \\\n --address '$node.form.admission.kind.einschulung'\nplexus-cli offer workflow node set-input --dir <dir> --node contract --input startDate \\\n --from form --field kind.einschulung\n\n# A fixed value (JSON: a text needs its quotes):\nplexus-cli offer workflow node set-input --dir <dir> --node platzangebot --input sprache --literal '\"de\"'\n\n# Back to the slot's default:\nplexus-cli offer workflow node set-input --dir <dir> --node platzangebot --input sprache --clear\n```\n\nThe command prints the cell before and after (`binding $env.applicant.language`, `literal \"de\"`,\n`\u2014 (default)`).\n\n## Verify\n```bash\nplexus-cli offer validate --dir <dir>\nplexus-cli offer workflow node reads --dir <dir> --node contract # the binding is listed, origin \u201Egeschrieben\"\nplexus-cli --env staging --tenant <t> offer plan --dir <dir> # expect: ~ workflow\n```\n\n## Idempotency / gotchas\n- Exactly one of `--address`, `--from`+`--field`, `--literal`, `--clear`. A bare key\n (`--address applicant.language`, `--address schulgeld`) is refused with the addresses visible at\n the node \u2014 there is no default source and no guessing.\n- A literal is JSON: `\"de\"`, `3`, `true`, `null`, or a priced item `{\"itemKey\":\u2026,\"grantKeys\":[\u2026]}`\n \u2014 and must fit the slot's value type: an option field takes one\n of its options, a party slot (a roleAssign's `person`) only a binding. This check runs in the\n verb; the publish gate does not (yet) check literals against their slot type.\n- An end node's outcome cells are set with `offer workflow node set --outcome|--data-decision`.\n- `--clear` also removes a cell no slot declares (a dead cell from an old edit).\n- The gate decides whether the address can be read here, before writing: `[address/unknownOwner]`,\n `[address/unknownKey]`, `[address/pathNotInTarget]` (the form has no such field / the stored value no\n such leaf), `[address/notExported]` (the form has the field but does not export it, or the\n bundle's `formExports` stamp is stale \u2014 `export: true`, then `offer workflow restamp-exports`),\n `[address/notVisible]` (the producer does not run on every path before the node),\n `[address/typeMismatch]` (the value does not fit the slot), `[governedDocument/envNotCovered]`\n (a language field needs an option per language `$env.applicant.language` can deliver), the\n uncovered-input contract. An error the bundle already had is named as \u201Evorbestehend\" and does\n not block this edit.\n- Re-running with the same value rewrites the same cell (no change).\n- Nothing reaches a live process until `offer apply --publish`.\n\n## Related\n- [Name what a node reads](./addresses.md) \xB7 [Generate a letter from a Word template](./template-document-node.md)\n- [Declare what a document node reads](./declare-node-reads.md) \xB7 [Edit a live tenant's offer](./edit-live-tenant-offer.md)\n","references/offer/completeness-check.md":"# Wait for outstanding documents (completeness check)\n\n**When to use:** a school lets the process run on while documents are still\nmissing \u2014 the Masernschutz-Nachweis, the birth certificate \u2014 and wants it to end\nonly once they are there, with a deadline (\u201Eerst wenn wirklich alle Unterlagen da\nsind, ist es vorbei\"). The `completenessCheck` node names SmartForm fields\n(`requires`) and a deadline. Entered with nothing missing it completes at once;\notherwise the family gets its fields in **one** task \u201EOffene Felder beantworten\" due by the\ndeadline, the optional guest role is granted, and the node parks until the last\nfield arrives (`complete`) or a person decides: \u201EOhne Nachreichung abschlie\xDFen\"\n(`acceptedIncomplete`) or \u201EBewerbung ablehnen\" (`rejected`). The family's\nwithdrawal arrives as `absage`.\n\n## Prerequisites\n- An offer bundle on disk: `offer init` for a new one, or a **fresh export** of\n the target environment into a private scratch dir (a live tenant's bundle is\n never kept in a shared or versioned place \u2014 the server is its source of truth).\n- The fields exist in the form the bundle's form node pins, as **entered,\n non-repeated** fields (a computed key or a field inside a repeated group\n cannot be handed in). Each is named by its full address,\n `$node.<formNode>.admission.<field>` \u2014 the form node that CREATES the\n instance, in single quotes. A bundle exported before addresses were introduced is\n refused \u2014 export again.\n- For a guest role: a **leaf** role in the tenant's role catalog (e.g.\n `gasthoerer`) \u2014 checked at `offer apply --publish`, not offline.\n- The graph has somewhere to send `rejected` and `absage` (the paths to the\n end of a rejection and of a withdrawal \u2014 an end with `dataDecision: discard`\n takes the application's records back itself, no discard node needed).\n\n## Steps\n```bash\n# 1. Export what is live (read-only).\nplexus-cli --env staging --tenant <tenant> offer export --offer <offer> --out ./bundle\n\n# 2. Add the check. Every flag below except --guest-role/--person is required:\n# - at least one --require address (repeatable, comma-separated),\n# - exactly one deadline: --deadline-days <n> (calendar days after entering)\n# OR --deadline-until <YYYY-MM-DD> (a fixed due day, tenant zone),\n# - the `requested` letter (the node type declares it REQUIRED),\n# - rejected/absage routed to the rejection/withdrawal paths.\n# `requires` and the guest role's person name the form they read; nothing is\n# bound implicitly (a bare key is refused with the addresses the node can read).\nplexus-cli offer workflow node add --dir ./bundle --type completenessCheck \\\n --node nachreichen --label \"Vollst\xE4ndigkeitspr\xFCfung\" --label-en \"Completeness check\" \\\n --require '$node.form.admission.kind.masernschutz,$node.form.admission.kind.geburtsurkunde' \\\n --deadline-days 14 \\\n --guest-role gasthoerer --person '$node.form.admission.beneficiary' \\\n --notification requested=admission.documentsRequested \\\n --outcomes complete:end,acceptedIncomplete:end,rejected:joinAbsage,absage:endAbsage\n\n# Later edits:\nplexus-cli offer workflow node add-requires --dir ./bundle --node nachreichen --address '$node.form.admission.kind.impfpass'\nplexus-cli offer workflow node remove-requires --dir ./bundle --node nachreichen --from form --field kind.impfpass\nplexus-cli offer workflow node set-requires --dir ./bundle --node nachreichen --from form --field kind.masernschutz\nplexus-cli offer workflow node set --dir ./bundle --node nachreichen --deadline-until 2026-10-15\nplexus-cli offer workflow node set --dir ./bundle --node nachreichen --guest-role \"\" # drops role AND person\nplexus-cli offer workflow node set-notification --dir ./bundle \\\n --node nachreichen --event requested --template admission.documentsRequested\n\n# 3. Validate offline, see the difference, publish.\nplexus-cli offer validate --dir ./bundle\nplexus-cli --env staging offer plan --dir ./bundle\nplexus-cli --env staging offer apply --publish --dir ./bundle\n```\n\n## Verify\n```bash\nplexus-cli offer workflow node list --dir ./bundle\n# nachreichen completenessCheck \u2026 complete\u2192\u2026, acceptedIncomplete\u2192\u2026, rejected\u2192\u2026, absage\u2192\u2026\n# letters: requested\u2192admission.documentsRequested\njq '.graph.nodes[] | select(.id==\"nachreichen\") | {requires, deadline, guestRole, inputs}' ./bundle/workflow.json\nplexus-cli offer workflow node reads --dir ./bundle --node nachreichen\n```\nAfter publish, a fresh application that reaches the node with a field empty\nshows the family task \u201EOffene Felder beantworten\" and the board column of the same\nname; a deployment that does not send mail records the letter in Dev Rail\n\u2192 \u201EMail\" instead.\n\n## Idempotency / gotchas\n- **The `requested` letter is required.** Without a binding the family would get\n no mail about the request, so every write refuses it\n (`[notification/missingBinding]`) \u2014 bind it in the `add` call with\n `--notification requested=<templateId>`. `--disabled` counts as missing.\n Offline validation cannot see the letter catalog: a misspelled template id is\n caught only at `offer apply --publish`.\n- **Deadline rules:** exactly one form. `--deadline-days` is a whole number 0\u2013366\n (`[completenessCheck/deadlineDays]`); `--deadline-until` must be a real\n calendar day (`2026-02-30` is refused, `[completenessCheck/deadlineDate]`).\n Passing both, or neither on `add`, fails before anything is written. Past the\n deadline nothing happens by itself: the family and the responsible person are\n told, and a person decides.\n- **Guest role:** the node's `guestRole` input (a fixed role key, chosen in the IDE's\n PARAMETER column from the role catalog). `--guest-role` needs `--person`, and `--person` needs\n `--guest-role` \u2014 nothing is defaulted. The person is a party of a form,\n `$node.form.admission.beneficiary` (the beneficiary the form's contract parties\n name), read live at that address whenever the role is granted or ended; a form\n that does not run before the check is `[address/notVisible]`. The role must be a **leaf** tenant\n role (`[completenessCheck/unknownRole]`, `[completenessCheck/nonLeafRole]`,\n both at publish). It is granted only when something is missing, ended on\n `complete` / `rejected` / `absage`, and **kept on `acceptedIncomplete`** \u2014 the\n school still has to know whose documents are outstanding. A role the person\n already held is never ended.\n- **Entering with nothing missing completes automatically** \u2014 no request, no\n letter, no role; the node passes straight through on `complete`.\n- **Where it lands:** without `--after` the check is spliced in front of the\n FIRST `end` node in `workflow.json` (every edge into that end now enters the\n check) \u2014 make sure that is the positive end. With `--after <node>` the\n anchor's FIRST onward edge is the one rerouted; on an anchor with several\n outcomes (a contract: `signed` + `absage`) that may be the wrong one. Check\n with `node list` and fix with `node set --outcomes`.\n- **Routing:** `complete`, `rejected` and `absage` must be routed\n (`[completenessCheck/unroutedOutcome]`); the staff buttons appear only for the\n outcomes that are wired. Left to the splice default, `rejected`/`absage` run\n into whatever follows (usually the positive end) \u2014 `add` warns about that; route\n them with `--outcomes`.\n- **`requires` edits:** only a completenessCheck carries `requires`\n (`*-requires` on another node fails; for fields a decider reads use\n `*-reads`). Removing the last address is refused (`[completenessCheck/missingRequires]`);\n two forms in one list are `[address/mixedForms]`, a field the form lacks is\n `[address/pathNotInTarget]`.\n Only errors an edit introduces block it.\n- **Hand-authored boards (known CLI gap):** `node add` derives the progress\n states and appends the check's column \u201EUnterlagen nachreichen\"; its\n `rejected`/`withdrawn` states go into the global `col.abgelehnt` /\n `col.abgesagt` columns. A bundle whose board already names its own exit\n columns (e.g. a `c.absage` column labelled \u201EAbgelehnt\")\n then carries two columns with one label, and `node add` refuses the write \u2014\n for ANY node type with such an event (`waitlist`, `decision`, \u2026), not only this\n one. Until `node add` can map events onto existing states, author the node in\n `workflow.json` + the states/columns/wiring in `workflow.json`\n by hand (shape: the Verify `jq` output above) and gate it with `offer validate`\n / `offer apply --publish`. Scaffolded bundles (`offer init`) are not affected.\n- **Running applications keep their pinned version** \u2014 see\n [Declare what a document node reads](./declare-node-reads.md) for re-pin / wipe.\n\n## Related\n- [Add a workflow node](./add-workflow-node.md) \xB7 [Edit a workflow node](./edit-workflow-node.md) \xB7 [Release an offer bundle](./publish-offer-bundle.md)\n- [Reword a letter](../notifications/reword-a-letter.md)\n","references/offer/conditional-optional-action.md":`# Offer an optional action only under a condition
7050
+ `,"references/offer/bind-node-input.md":"# Bind a node input to an address (form field, task value, applicant language)\n\n**When to use:** a node's input slot must read a value produced elsewhere \u2014 the applicant's\nlanguage for a template letter (`$env.applicant.language`), a value a task records (`$task.reducedFee.reducedFee`), a form field\n(`$node.form.admission.kind.vorname`) \u2014 or carry a fixed value, or go back to its default.\nReplaces hand edits of `inputs` in the bundle's workflow file.\n\n## Prerequisites\n- An offer bundle on disk (`offer export --offer <slug> --out <dir>`). Fully offline: the command\n runs the publish gate on the result and writes nothing when the edit introduces an error. A\n bundle exported before addresses were introduced is refused (`[graph/retiredField]`: a binding with `path`, `wires`)\n \u2014 export it again.\n- The input is a **slot** the node declares. For a template document (`production: 'template'`)\n the slots are its template's parameters, declared on the template record (catalog\n `documentTemplates[].parameters`) and stamped onto the node by `offer plan` \u2014 add the parameter\n there first, then bind.\n `offer workflow node list --dir <dir>` shows the nodes; an unknown slot is refused with the\n node's slots.\n- The **address** names its producer, which must run on every path before the node \u2014 the model\n and the spelling: [Name what a node reads](./addresses.md). Quote it with single quotes.\n\n## Steps\n```bash\n# The offer letter in the applicant's language (demo tenant `test`: platzangebot, field `sprache`):\nplexus-cli offer workflow node set-input --dir <dir> --node platzangebot --input sprache \\\n --address '$env.applicant.language'\n\n# The reduction staff decided, for the generator's input of type `reduction`:\nplexus-cli offer workflow node set-input --dir <dir> --node contract --input reducedFee \\\n --address '$task.reducedFee.reducedFee'\n\n# A form field \u2014 full address, or the short form that composes the same address:\nplexus-cli offer workflow node set-input --dir <dir> --node contract --input startDate \\\n --address '$node.form.admission.kind.einschulung'\nplexus-cli offer workflow node set-input --dir <dir> --node contract --input startDate \\\n --from form --field kind.einschulung\n\n# A fixed value (JSON: a text needs its quotes):\nplexus-cli offer workflow node set-input --dir <dir> --node platzangebot --input sprache --literal '\"de\"'\n\n# Back to the slot's default:\nplexus-cli offer workflow node set-input --dir <dir> --node platzangebot --input sprache --clear\n```\n\nThe command prints the cell before and after (`binding $env.applicant.language`, `literal \"de\"`,\n`\u2014 (default)`).\n\n## Verify\n```bash\nplexus-cli offer validate --dir <dir>\nplexus-cli offer workflow node reads --dir <dir> --node contract # the binding is listed, origin \u201Egeschrieben\"\nplexus-cli --env staging --tenant <t> offer plan --dir <dir> # expect: ~ workflow\n```\n\n## Idempotency / gotchas\n- Exactly one of `--address`, `--from`+`--field`, `--literal`, `--clear`. A bare key\n (`--address applicant.language`, `--address schulgeld`) is refused with the addresses visible at\n the node \u2014 there is no default source and no guessing.\n- A literal is JSON: `\"de\"`, `3`, `true`, `null`, or a priced item `{\"itemKey\":\u2026,\"grantKeys\":[\u2026]}`\n \u2014 and must fit the slot's value type: an option field takes one\n of its options, a party slot (a roleAssign's `person`) only a binding. This check runs in the\n verb; the publish gate does not (yet) check literals against their slot type.\n- An end node's outcome cells are set with `offer workflow node set --outcome|--data-decision`.\n- `--clear` also removes a cell no slot declares (a dead cell from an old edit).\n- The gate decides whether the address can be read here, before writing: `[address/unknownOwner]`,\n `[address/unknownKey]`, `[address/pathNotInTarget]` (the form has no such field / the stored value no\n such leaf), `[address/notExported]` (the form has the field but does not export it, or the\n bundle's `formExports` stamp is stale \u2014 `export: true`, then `offer workflow restamp-exports`),\n `[address/notVisible]` (the producer does not run on every path before the node),\n `[address/typeMismatch]` (the value does not fit the slot), `[governedDocument/envNotCovered]`\n (a language field needs an option per language `$env.applicant.language` can deliver), the\n uncovered-input contract. An error the bundle already had is named as \u201Evorbestehend\" and does\n not block this edit.\n- Re-running with the same value rewrites the same cell (no change).\n- Nothing reaches a live process until `offer apply --publish`.\n\n## Related\n- [Name what a node reads](./addresses.md) \xB7 [Generate a letter from a Word template](./template-document-node.md)\n- [Declare what a document node reads](./declare-node-reads.md) \xB7 [Edit a live tenant's offer](./edit-live-tenant-offer.md)\n","references/offer/completeness-check.md":"# Wait for outstanding documents (completeness check)\n\n**When to use:** a school lets the process run on while documents are still\nmissing \u2014 the Masernschutz-Nachweis, the birth certificate \u2014 and wants it to end\nonly once they are there, with a deadline (\u201Eerst wenn wirklich alle Unterlagen da\nsind, ist es vorbei\"). The `completenessCheck` node names SmartForm fields\n(`requires`) and a deadline. Entered with nothing missing it completes at once;\notherwise the family gets its fields in **one** task \u201EOffene Felder beantworten\" due by the\ndeadline, the optional guest role is granted, and the node parks until the last\nfield arrives (`complete`) or a person decides: \u201EOhne Nachreichung abschlie\xDFen\"\n(`acceptedIncomplete`) or \u201EBewerbung ablehnen\" (`rejected`). The family's\nwithdrawal arrives as `absage`.\n\n## Prerequisites\n- An offer bundle on disk: `offer init` for a new one, or a **fresh export** of\n the target environment into a private scratch dir (a live tenant's bundle is\n never kept in a shared or versioned place \u2014 the server is its source of truth).\n- The fields exist in the form the bundle's form node pins, as **entered,\n non-repeated** fields (a computed key or a field inside a repeated group\n cannot be handed in). Each is named by its full address,\n `$node.<formNode>.admission.<field>` \u2014 the form node that CREATES the\n instance, in single quotes. A bundle exported before addresses were introduced is\n refused \u2014 export again.\n- For a guest role: a **leaf** role in the tenant's role catalog (e.g.\n `gasthoerer`) \u2014 checked at `offer apply --publish`, not offline.\n- The graph has somewhere to send `rejected` and `absage` (the paths to the\n end of a rejection and of a withdrawal \u2014 an end with `dataDecision: discard`\n takes the application's records back itself, no discard node needed).\n\n## Steps\n```bash\n# 1. Export what is live (read-only).\nplexus-cli --env staging --tenant <tenant> offer export --offer <offer> --out ./bundle\n\n# 2. Add the check. Every flag below except --guest-role/--person is required:\n# - at least one --require address (repeatable, comma-separated),\n# - exactly one deadline: --deadline-days <n> (calendar days after entering)\n# OR --deadline-until <YYYY-MM-DD> (a fixed due day, tenant zone),\n# - the `requested` letter (the node type declares it REQUIRED),\n# - rejected/absage routed to the rejection/withdrawal paths.\n# `requires` and the guest role's person name the form they read; nothing is\n# bound implicitly (a bare key is refused with the addresses the node can read).\nplexus-cli offer workflow node add --dir ./bundle --type completenessCheck \\\n --node nachreichen --label \"Vollst\xE4ndigkeitspr\xFCfung\" --label-en \"Completeness check\" \\\n --require '$node.form.admission.kind.masernschutz,$node.form.admission.kind.geburtsurkunde' \\\n --deadline-days 14 \\\n --guest-role gasthoerer --person '$node.form.admission.beneficiary' \\\n --notification requested=admission.documentsRequested \\\n --outcomes complete:end,acceptedIncomplete:end,rejected:joinAbsage,absage:endAbsage\n\n# Later edits:\nplexus-cli offer workflow node add-requires --dir ./bundle --node nachreichen --address '$node.form.admission.kind.impfpass'\nplexus-cli offer workflow node remove-requires --dir ./bundle --node nachreichen --from form --field kind.impfpass\nplexus-cli offer workflow node set-requires --dir ./bundle --node nachreichen --from form --field kind.masernschutz\nplexus-cli offer workflow node set --dir ./bundle --node nachreichen --deadline-until 2026-10-15\nplexus-cli offer workflow node set --dir ./bundle --node nachreichen --guest-role \"\" # drops role AND person\nplexus-cli offer workflow node set-notification --dir ./bundle \\\n --node nachreichen --event requested --template admission.documentsRequested\n\n# 3. Validate offline, see the difference, publish.\nplexus-cli offer validate --dir ./bundle\nplexus-cli --env staging offer plan --dir ./bundle\nplexus-cli --env staging offer apply --publish --dir ./bundle\n```\n\n## Verify\n```bash\nplexus-cli offer workflow node list --dir ./bundle\n# nachreichen completenessCheck \u2026 complete\u2192\u2026, acceptedIncomplete\u2192\u2026, rejected\u2192\u2026, absage\u2192\u2026\n# letters: requested\u2192admission.documentsRequested\njq '.graph.nodes[] | select(.id==\"nachreichen\") | {requires, deadline, guestRole, inputs}' ./bundle/workflow.json\nplexus-cli offer workflow node reads --dir ./bundle --node nachreichen\n```\nAfter publish, a fresh application that reaches the node with a field empty\nshows the family task \u201EOffene Felder beantworten\" and the board column of the same\nname; a deployment that does not send mail records the letter in Dev Rail\n\u2192 \u201EMail\" instead.\n\n## Idempotency / gotchas\n- **The `requested` letter is required.** Without a binding the family would get\n no mail about the request, so every write refuses it\n (`[notification/missingBinding]`) \u2014 bind it in the `add` call with\n `--notification requested=<templateId>`. `--disabled` counts as missing.\n Offline validation cannot see the letter catalog: a misspelled template id is\n caught only at `offer apply --publish`.\n- **Deadline rules:** exactly one form. `--deadline-days` is a whole number 0\u2013366\n (`[completenessCheck/deadlineDays]`); `--deadline-until` must be a real\n calendar day (`2026-02-30` is refused, `[completenessCheck/deadlineDate]`).\n Passing both, or neither on `add`, fails before anything is written. Past the\n deadline nothing happens by itself: the family and the responsible person are\n told, and a person decides.\n- **Guest role:** the node's `guestRole` input (a fixed role key, chosen in the IDE's\n PARAMETER column from the role catalog). `--guest-role` needs `--person`, and `--person` needs\n `--guest-role` \u2014 nothing is defaulted. The person is a party of a form,\n `$node.form.admission.beneficiary` (the beneficiary the form's contract parties\n name), read live at that address whenever the role is granted or ended; a form\n that does not run before the check is `[address/notVisible]`. The role must be a **leaf** tenant\n role (`[completenessCheck/unknownRole]`, `[completenessCheck/nonLeafRole]`,\n both at publish). It is granted only when something is missing, ended on\n `complete` / `rejected` / `absage`, and **kept on `acceptedIncomplete`** \u2014 the\n school still has to know whose documents are outstanding. A role the person\n already held is never ended.\n- **Entering with nothing missing completes automatically** \u2014 no request, no\n letter, no role; the node passes straight through on `complete`.\n- **Where it lands:** without `--after` the check is spliced in front of the\n FIRST `end` node in the workflow file (every edge into that end now enters the\n check) \u2014 make sure that is the positive end. With `--after <node>` the\n anchor's FIRST onward edge is the one rerouted; on an anchor with several\n outcomes (a contract: `signed` + `absage`) that may be the wrong one. Check\n with `node list` and fix with `node set --outcomes`.\n- **Routing:** `complete`, `rejected` and `absage` must be routed\n (`[completenessCheck/unroutedOutcome]`); the staff buttons appear only for the\n outcomes that are wired. Left to the splice default, `rejected`/`absage` run\n into whatever follows (usually the positive end) \u2014 `add` warns about that; route\n them with `--outcomes`.\n- **`requires` edits:** only a completenessCheck carries `requires`\n (`*-requires` on another node fails; for fields a decider reads use\n `*-reads`). Removing the last address is refused (`[completenessCheck/missingRequires]`);\n two forms in one list are `[address/mixedForms]`, a field the form lacks is\n `[address/pathNotInTarget]`.\n Only errors an edit introduces block it.\n- **Hand-authored boards (known CLI gap):** `node add` derives the progress\n states and appends the check's column \u201EUnterlagen nachreichen\"; its\n `rejected`/`withdrawn` states go into the global `col.abgelehnt` /\n `col.abgesagt` columns. A bundle whose board already names its own exit\n columns (e.g. a `c.absage` column labelled \u201EAbgelehnt\")\n then carries two columns with one label, and `node add` refuses the write \u2014\n for ANY node type with such an event (`waitlist`, `decision`, \u2026), not only this\n one. Until `node add` can map events onto existing states, author the node in\n the workflow file + the states/columns/wiring in the workflow file\n by hand (shape: the Verify `jq` output above) and gate it with `offer validate`\n / `offer apply --publish`. Scaffolded bundles (`offer init`) are not affected.\n- **Running applications keep their pinned version** \u2014 see\n [Declare what a document node reads](./declare-node-reads.md) for re-pin / wipe.\n\n## Related\n- [Add a workflow node](./add-workflow-node.md) \xB7 [Edit a workflow node](./edit-workflow-node.md) \xB7 [Release an offer bundle](./publish-offer-bundle.md)\n- [Reword a letter](../notifications/reword-a-letter.md)\n","references/offer/conditional-optional-action.md":`# Offer an optional action only under a condition
6972
7051
 
6973
7052
  **Use it to** show an entry under \u201EWeiteres" only on the applications it is meant for \u2014
6974
7053
  a \u201ETaster Day" only for one stage. On every other application the entry does not exist, not
@@ -7051,7 +7130,7 @@ admissions team.
7051
7130
 
7052
7131
  - The answer is exported by the form. If not: mark the field (or a computed boolean over it)
7053
7132
  \`export: true\` in \`smartforms/<slug>.json\`, then run \`plexus-cli offer workflow restamp-exports --dir <dir>\`.
7054
- - The template key: the node's \`assign\` in \`workflow.json\` lists them (e.g. \`prepareDocument\`,
7133
+ - The template key: the node's \`assign\` in the workflow file lists them (e.g. \`prepareDocument\`,
7055
7134
  \`releaseApproval\` on a document node, \`decision\` on a decision). A wrong key is refused with
7056
7135
  the keys the node type knows.
7057
7136
 
@@ -7786,7 +7865,7 @@ who decides on a decision node, rebind a form node to a different
7786
7865
  SmartForm, or rewire where an outcome routes \u2014 without removing and re-adding it.
7787
7866
 
7788
7867
  ## Prerequisites
7789
- - An offer bundle on disk carrying a \`workflow.json\` (\`offer init \u2026\` or \`offer export \u2026\`).
7868
+ - An offer bundle on disk carrying a workflow file (\`offer init \u2026\` or \`offer export \u2026\`).
7790
7869
  - Authoring is **fully offline**; only \`offer apply --publish\` needs an API token of a
7791
7870
  user who may configure the tenant's offers (a tenant admin \u2014 see
7792
7871
  [Add a tenant admin](../users/add-tenant-admin.md)).
@@ -8120,7 +8199,7 @@ was started on, so a new view reaches only applications on the new revision.
8120
8199
 
8121
8200
  **When to use:** a new step must sit between two existing ones \u2014 e.g. \u201EUnterlagen pr\xFCfen"
8122
8201
  between the form and the first decision \u2014 and it must land on an existing board column
8123
- instead of adding one. Replaces the hand-written bundle edits of \`apply-doccheck.py\`
8202
+ instead of adding one. Replaces the hand-written bundle edits of the apply-doccheck script
8124
8203
  (insert a \`review\` node, re-point \`form.next.standard\`, add a progress mapping).
8125
8204
 
8126
8205
  ## Prerequisites
@@ -8213,7 +8292,7 @@ plexus-cli --env staging --tenant <t> offer plan --dir <dir> # expect: ~ wor
8213
8292
  **When to use:** give a workflow node a task a team must do \u2014 with a typed result
8214
8293
  (\u201EEmpfehlung", \u201EAuswahl", Freitext, a priced item or a reduction), a blocking edge onto the same or a later node, a
8215
8294
  spawn condition, evidence fields or its plain-text description \u2014 or change / remove one, without
8216
- hand-editing \`workflow.json\`. Works on any bundle: the \`test\` template, a fixture, or a
8295
+ hand-editing the workflow file. Works on any bundle: the \`test\` template, a fixture, or a
8217
8296
  live tenant's export (then follow [Edit a live tenant's offer](./edit-live-tenant-offer.md)
8218
8297
  around it).
8219
8298
 
@@ -8585,7 +8664,7 @@ generation as **Aktuell**, and the one below it as **Vorg\xE4nger**.
8585
8664
  - [Author a SmartForm as code](./author-smartform.md), [Add a workflow node](./add-workflow-node.md)
8586
8665
  - [Manage a contract resolver](../resolver/manage-contract-resolver.md) \u2014 the
8587
8666
  apply \u2192 assign \u2192 publish order
8588
- `,"references/offer/set-offer-capacities.md":"# Set an offer's seat capacities in its bundle\n\n**When to use:** an offer's Schuljahr \xD7 Klassenstufe grid (seats per cohort, open or\nclosed) should travel with the bundle \u2014 a fresh environment gets the whole grid from one\n`offer apply` instead of one `offer capacity set` per cell.\n\n## Prerequisites\n- An offer bundle on disk (`offer export \u2026`) whose `bundle.yaml` has a `program` block.\n- A token with the tenant's offer-configuration rights (a tenant admin has them) for `offer plan` / `offer apply` on the target env.\n- The stage and run keys of the offer (`program.stages[].key`, `program.runs[].key`) \u2014\n cells sit under a run (by its **bare** key) and are keyed by the **bare** stage key,\n never by a name (names are `{ de, en }` display text).\n\n## Steps\n\nEach run lists its cells under `capacities`, keyed by stage key:\n\n```yaml\nprogram:\n unitKey: primary\n stages:\n - { key: grade-1, name: { de: Klassenstufe 1, en: Grade 1 }, gradeLevel: 1 }\n - { key: grade-2, name: { de: Klassenstufe 2, en: Grade 2 }, gradeLevel: 2 }\n runs:\n - key: \"2026-27\"\n name: { de: Schuljahr 2026/27, en: School year 2026/27 }\n startDate: '2026-08-01'\n endDate: '2027-07-31'\n capacities:\n grade-1: { isOpen: true, capacity: 24 } # 24 seats, accepting\n grade-2: { isOpen: true, capacity: unlimited } # no cap\n # grade-3: { isOpen: false, capacity: null } # null = unconfigured (clears a stored one)\n```\n\n```bash\nplexus-cli offer validate --dir <bundle> # offline: shape + stage keys\nplexus-cli --env <env> offer plan --dir <bundle> # one `~cap run\xD7stage from \u2192 to` row per changed cell\nplexus-cli --env <env> offer apply --dir <bundle> # writes exactly those cells\n```\n\nThe fastest way to get the block right is to let the live offer write it:\n`plexus-cli --env <env> offer export --offer <offer> --out <bundle>` emits every run with\nall its cells.\n\n## Verify\n```bash\nplexus-cli --env <env> offer plan --dir <bundle> # no `cap:` rows left = the grid matches\nplexus-cli --env <env> offer show --offer <offer> # the live grid\n```\n\n## Idempotency / gotchas\n- **A listed cell is authoritative** \u2014 both `isOpen` and `capacity`, every apply;\n `capacity: null` clears a stored capacity. A cell the bundle does **not** list is left\n alone. A re-apply of an unchanged bundle writes nothing.\n- `capacity` is a whole number \u2265 0, `unlimited`, or `null`. **Unconfigured is not\n unlimited:** an application to an open cell with `null` fails loud.\n- A run with `capacities` must not also carry a run-level `isOpen` (validation error):\n the open state lives on each cell. A NEW run with `capacities` is created closed and\n then opened cell by cell. A run **without** `capacities` keeps the old behaviour \u2014 its\n `isOpen` (default open) seeds every cell of a newly created run, and existing cells\n are untouched.\n- **Closing an existing Schuljahr = `isOpen: false` on each of its cells.** A run-level\n `isOpen: false` on an existing run changes nothing and plans no row \u2014 a Schuljahr\n \"closed\" that way stays open; the real close shows one `~cap \u2026 open \u2192 closed` row per\n cell in the plan.\n- For a real tenant the bundle on disk is a fresh `--env prod` export in a scratch dir,\n never a stale or version-controlled copy \u2014 see\n [edit-live-tenant-offer](./edit-live-tenant-offer.md).\n- A cell naming a stage key that neither `program.stages` nor the live program has is\n refused before anything is written (`[capacity/unknownStage]`). A stage the same bundle\n adds plans as `(new)` and is written after the stage exists.\n- `offer run add --capacity` / `offer capacity set` still exist for one-off edits; the\n next `offer apply` of a bundle that lists the cell sets it back. `offer capacity set\n --capacity unlimited` is accepted.\n\n## Related\n- [Rename / remove a program stage](../config/rename-program-stage.md) \u2014 the stage keys cells use.\n- [Release an offer bundle](./publish-offer-bundle.md).\n","references/offer/skip-evaluation.md":`# Let the decider skip the evaluation
8667
+ `,"references/offer/set-offer-capacities.md":"# Set an offer's seat capacities in its bundle\n\n**When to use:** an offer's Schuljahr \xD7 Klassenstufe grid (seats per cohort, open or\nclosed) should travel with the bundle \u2014 a fresh environment gets the whole grid from one\n`offer apply` instead of one `offer capacity set` per cell.\n\n## Prerequisites\n- An offer bundle on disk (`offer export \u2026`) whose bundle file has a `program` block.\n- A token with the tenant's offer-configuration rights (a tenant admin has them) for `offer plan` / `offer apply` on the target env.\n- The stage and run keys of the offer (`program.stages[].key`, `program.runs[].key`) \u2014\n cells sit under a run (by its **bare** key) and are keyed by the **bare** stage key,\n never by a name (names are `{ de, en }` display text).\n\n## Steps\n\nEach run lists its cells under `capacities`, keyed by stage key:\n\n```yaml\nprogram:\n unitKey: primary\n stages:\n - { key: grade-1, name: { de: Klassenstufe 1, en: Grade 1 }, gradeLevel: 1 }\n - { key: grade-2, name: { de: Klassenstufe 2, en: Grade 2 }, gradeLevel: 2 }\n runs:\n - key: \"2026-27\"\n name: { de: Schuljahr 2026/27, en: School year 2026/27 }\n startDate: '2026-08-01'\n endDate: '2027-07-31'\n capacities:\n grade-1: { isOpen: true, capacity: 24 } # 24 seats, accepting\n grade-2: { isOpen: true, capacity: unlimited } # no cap\n # grade-3: { isOpen: false, capacity: null } # null = unconfigured (clears a stored one)\n```\n\n```bash\nplexus-cli offer validate --dir <bundle> # offline: shape + stage keys\nplexus-cli --env <env> offer plan --dir <bundle> # one `~cap run\xD7stage from \u2192 to` row per changed cell\nplexus-cli --env <env> offer apply --dir <bundle> # writes exactly those cells\n```\n\nThe fastest way to get the block right is to let the live offer write it:\n`plexus-cli --env <env> offer export --offer <offer> --out <bundle>` emits every run with\nall its cells.\n\n## Verify\n```bash\nplexus-cli --env <env> offer plan --dir <bundle> # no `cap:` rows left = the grid matches\nplexus-cli --env <env> offer show --offer <offer> # the live grid\n```\n\n## Idempotency / gotchas\n- **A listed cell is authoritative** \u2014 both `isOpen` and `capacity`, every apply;\n `capacity: null` clears a stored capacity. A cell the bundle does **not** list is left\n alone. A re-apply of an unchanged bundle writes nothing.\n- `capacity` is a whole number \u2265 0, `unlimited`, or `null`. **Unconfigured is not\n unlimited:** an application to an open cell with `null` fails loud.\n- A run with `capacities` must not also carry a run-level `isOpen` (validation error):\n the open state lives on each cell. A NEW run with `capacities` is created closed and\n then opened cell by cell. A run **without** `capacities` keeps the old behaviour \u2014 its\n `isOpen` (default open) seeds every cell of a newly created run, and existing cells\n are untouched.\n- **Closing an existing Schuljahr = `isOpen: false` on each of its cells.** A run-level\n `isOpen: false` on an existing run changes nothing and plans no row \u2014 a Schuljahr\n \"closed\" that way stays open; the real close shows one `~cap \u2026 open \u2192 closed` row per\n cell in the plan.\n- For a real tenant the bundle on disk is a fresh `--env prod` export in a scratch dir,\n never a stale or version-controlled copy \u2014 see\n [edit-live-tenant-offer](./edit-live-tenant-offer.md).\n- A cell naming a stage key that neither `program.stages` nor the live program has is\n refused before anything is written (`[capacity/unknownStage]`). A stage the same bundle\n adds plans as `(new)` and is written after the stage exists.\n- `offer run add --capacity` / `offer capacity set` still exist for one-off edits; the\n next `offer apply` of a bundle that lists the cell sets it back. `offer capacity set\n --capacity unlimited` is accepted.\n\n## Related\n- [Rename / remove a program stage](../config/rename-program-stage.md) \u2014 the stage keys cells use.\n- [Release an offer bundle](./publish-offer-bundle.md).\n","references/offer/skip-evaluation.md":`# Let the decider skip the evaluation
8589
8668
 
8590
8669
  **Use it to** let the person who decides go straight to the decision when the decision node
8591
8670
  waits for an evaluation (\`requiresOneOf\`: a Gespr\xE4ch, a Taster Day, a document request): the
@@ -9028,7 +9107,7 @@ until they are published again \u2014 \`offer plan\` shows such an offer as \`wo
9028
9107
 
9029
9108
  ## 2. Author the node in the bundle (JSON)
9030
9109
 
9031
- \`plexus-cli offer workflow node add\` cannot create a governedDocument node; edit \`workflow.json\`
9110
+ \`plexus-cli offer workflow node add\` cannot create a governedDocument node; edit the workflow file
9032
9111
  (export \u2192 edit \u2192 plan \u2192 apply, see [Edit a live tenant's offer](./edit-live-tenant-offer.md)):
9033
9112
 
9034
9113
  \`\`\`jsonc
@@ -9246,7 +9325,7 @@ Two kinds of channel exist in every application of a published version:
9246
9325
  | kind | where it comes from | editable? |
9247
9326
  |---|---|---|
9248
9327
  | automatic | one per team the process gives work to (\`assign\`, composed tasks, \u2026) | no \u2014 follows the graph |
9249
- | default | \`graph.channels\` in \`workflow.json\` | yes \u2014 this playbook |
9328
+ | default | \`graph.channels\` in the workflow file | yes \u2014 this playbook |
9250
9329
 
9251
9330
  Both are read from the application's **pinned** workflow version at chat time. No
9252
9331
  row is written per application, so a new default channel reaches applications
@@ -9254,7 +9333,7 @@ started on the next published version; running applications keep the channels
9254
9333
  of their version.
9255
9334
 
9256
9335
  ## Prerequisites
9257
- - An offer bundle on disk with a \`workflow.json\` (\`offer export \u2026\` or \`offer init \u2026\`).
9336
+ - An offer bundle on disk with a workflow file (\`offer export \u2026\` or \`offer init \u2026\`).
9258
9337
  - Authoring is offline; \`offer apply --publish\` needs a token with the tenant's offer-configuration rights (a tenant admin has them).
9259
9338
  - Members are **permission-group keys** of the tenant (\`plexus-cli --env <env> --tenant <t> users groups\`
9260
9339
  \u2192 \`key\`); the applicant group is not a team.
@@ -9625,7 +9704,7 @@ from \`--protect\` in the deletion set aborts the run here as well.
9625
9704
 
9626
9705
  ## Prerequisites
9627
9706
  - A platform token with \`_platform.config.manage\` (\`_platform.config.read\` is enough for \`plan\`).
9628
- - \`protect.json\`: a JSON array of the application ids that must stay, non-empty.
9707
+ - The protect file: a JSON array of the application ids that must stay, non-empty.
9629
9708
 
9630
9709
  ## Steps
9631
9710
  \`\`\`bash
@@ -11503,7 +11582,7 @@ plexus-cli --env prod jobs list --status running # nothing unexpectedly in
11503
11582
  ## Related
11504
11583
  - Command reference: \`plexus-cli jobs list --help\`, \`plexus-cli platform workers reap --help\`,
11505
11584
  \`plexus-cli platform imports cleanup-orphaned --help\`.
11506
- `,"references/worker-ops/set-import-default-unit.md":"# Set the default unit of an import source\n\n**When to use:** a unit that an import source uses as its default unit has to\ngo, or imported records should attach to another unit by default.\n`org unit delete` refuses the default unit of an import source\n(`[unit/importSourceDefault]`). Point the source at another unit first.\n\n## Prerequisites\n- **Auth:** a platform operator's token with `_platform.config.manage`. A\n school's own token is refused, because the import source belongs to the operator.\n- **Env:** a writing run needs `--env <local|staging|prod>` on the command line,\n and `--allow-prod` against production.\n- You need the source key (`imports status --tenant <slug>`, column `config`)\n and the new unit's config key (`org tree`, column `key`).\n\n## Steps\n\n```bash\n# Plan: shows the current default and the new one, and writes nothing\nplexus-cli --env prod --allow-prod platform imports source set-default-unit <source> --unit <unit-key>\n# Write\nplexus-cli --env prod --allow-prod platform imports source set-default-unit <source> --unit <unit-key> --confirm\n```\n\n## Verify\nRun the plan again. It reports `unchanged`, with the new unit as the default.\n\n## Idempotency / gotchas\n- The unit must be one the source already knows by key (every unit of the\n tenant at the time the source was set up). Otherwise the command refuses with\n `[import-source/unitUnknown]` and lists the keys the source knows.\n- Deleting any other unit removes it from the source's key list automatically.\n Only the default unit blocks a delete.\n- The tenant config names the default unit by key: `source.defaultUnitKey`\n (the order of `foundation.units` means nothing). `config export` writes the\n current default there, so an apply from a fresh export keeps it. **An apply\n from an export taken before this change names the old default and sets it\n back**; its plan shows an update on `source`. Export again after setting the\n default, or set `source.defaultUnitKey` in the scratch export by hand.\n- `config apply` refuses a source without `defaultUnitKey`\n (`[import/defaultUnitMissing]`) or with a key that is not in\n `foundation.units` (`[import/defaultUnitUnknown]`). There is no fallback to\n the first unit. An export taken before this change carries no key: add it before\n the apply.\n\n## Related\n- [Edit a school's organisation structure](../organization/edit-org-structure.md)\n- [Debug a stuck/failed import or worker job](./debug-worker-jobs.md)\n"};var Tp="5a299a07b9e9bdea99400a3aad16ea461293a630af0878af015e0dd8b1d50726",Bw=W_;var yH=new Set(["ENOENT","ENOTDIR","EISDIR","EACCES","EPERM"]);function wH(e){return typeof e=="object"&&e!==null&&"code"in e?e.code:void 0}s(wH,"codeOf");function Y_(e){return e instanceof Error?e.message:String(e)}s(Y_,"messageOf");function Uw(e,t){try{return Ne(e)}catch(n){throw yH.has(wH(n))?new g(`${t}: ${e} is not readable (${Y_(n)})`,{cause:n}):n}}s(Uw,"readBytesFile");function Gw(e,t){return Uw(e,t).toString("utf8")}s(Gw,"readTextFile");function oi(e,t){try{return JSON.parse(e)}catch(n){throw new g(`${t} is no JSON (${Y_(n)})`,{cause:n})}}s(oi,"parseJsonText");function ze(e,t){return oi(Gw(e,t),`${t}: ${e}`)}s(ze,"readJsonFile");var zw=class extends Ae{static{s(this,"AgentToolsCommand")}static paths=[["agent","tools"]];static usage=E.Usage({category:"Agents",description:"Show the shared platform/CLI agent tool schemas and skill revision."});async execute(){return this.print({skillHash:Tp,tools:ud}),0}},Ww=class extends Ae{static{s(this,"AgentInvokeCommand")}static paths=[["agent","invoke"]];static usage=E.Usage({category:"Agents",description:"Invoke a shared agent tool; pipe its JSON input on stdin."});tool=f.String("--tool",{required:!0,description:"plexus|plexus_skill|plexus_workspace"});async execute(){if("isTTY"in this.context.stdin&&this.context.stdin.isTTY===!0)throw new g("plexus: pipe the tool's JSON input on stdin.");let t=oi(await Vw(this.context.stdin),"stdin"),n=await this.context.executePlexusAgentTool(this.tool,t);return this.print(n),0}},H_=[zw,Ww];var Yw=[{key:"fixture_test",email:"test@example.com",firstName:"Test",lastName:"Bewerber"}],Jfe=new Set(Yw.map(e=>e.key));var We=["de","en"];function ca(e,t){return We.every(n=>e[n]===t[n])}s(ca,"sameText");function Ft(e){if(e===null||typeof e!="object"||Array.isArray(e))return"not-localized";let t=e;return Object.keys(t).some(r=>!We.includes(r))?"not-localized":We.filter(r=>{let i=t[r];return typeof i!="string"||i.trim()===""})}s(Ft,"missingLocales");function mo(e){let t=Ft(e);return t!=="not-localized"&&t.length===0}s(mo,"isLocalizedText");function fd(e,t){let n={};for(let r of We){let i=e.map(o=>o[r]);n[r]=i.every(o=>typeof o=="string"&&o.trim()!=="")?t(i,r):""}return n}s(fd,"composeTexts");function Rp(e){return e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}s(Rp,"slugify");var J_="tenant";function Q_(e){if(e.length===0||Rp(e)!==e)return"must be lowercase a-z/0-9 words joined by single dashes";if(e===J_)return`"${J_}" is reserved for the tenant-wide scope`}s(Q_,"unitSlugError");var kH=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function cr(e,t){return`${e}-${t}`}s(cr,"runStorageKey");function Z_(e,t){typeof t!="string"&&de("CONFLICT",{de:`[run/keyNotServed] Das Deployment liefert f\xFCr ein Schuljahr von \u201E${e}\u201C keinen Schl\xFCssel \u2014 es l\xE4uft ein \xE4lteres Release als die CLI. Nach dem n\xE4chsten Release erneut versuchen.`,en:`[run/keyNotServed] The deployment provides no key for a school year of "${e}" \u2014 it runs an older release than the CLI. Try again after the next release.`});let n=`${e}-`;return(!t.startsWith(n)||t.length===n.length)&&de("CONFLICT",{de:`[run/foreignKey] Der Schl\xFCssel \u201E${t}\u201C des Schuljahrs liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${n}<key>\u201C).`,en:`[run/foreignKey] The key "${t}" of the school year is not under the program "${e}" (expected: "${n}<key>").`}),t.slice(n.length)}s(Z_,"bareRunKey");function $p(e){let t=[],n=new Map;return e.forEach((r,i)=>{let o=Ft(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.runs[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?t.push({code:"run/nameMissing",index:i,message:{de:`[run/nameMissing] ${l}: jedes Schuljahr braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[run/nameMissing] ${l}: every run needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&t.push({code:"run/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){t.push({code:"run/keyMissing",index:i,message:{de:`[run/keyMissing] ${l}: jedes Schuljahr braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[run/keyMissing] ${l}: every run needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!kH.test(d)){t.push({code:"run/keyInvalid",index:i,message:{de:`[run/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[run/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=n.get(d);if(c!==void 0){t.push({code:"run/duplicateKey",index:i,message:{de:`[run/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.runs[${c}] verwendet`,en:`[run/duplicateKey] ${l}: key "${d}" is already used by program.runs[${c}]`}});return}n.set(d,i)}),t}s($p,"runSpecIssues");var bH="-stufe-",vH=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function Hw(e){return`${e}${bH}`}s(Hw,"stageKeyPrefix");function ua(e,t){return`${Hw(e)}${t}`}s(ua,"stageStorageKey");function eN(e,t){let n=Hw(e);return t.startsWith(n)&&t.length>n.length}s(eN,"isUnderProgram");function si(e,t){let n=Hw(e);return eN(e,t)||de("CONFLICT",{de:`[stage/foreignKey] Der Stufenschl\xFCssel \u201E${t}\u201C liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${n}<key>\u201C). F\xFChren Sie die Stufe in bundle.yaml unter einem neuen Schl\xFCssel auf; der n\xE4chste Apply archiviert diese Zeile (hinter der Archivsperre) und legt die Stufe mit dem neuen Schl\xFCssel an.`,en:`[stage/foreignKey] The level key "${t}" is not under the program "${e}" (expected: "${n}<key>"). List the level in bundle.yaml under a new key; the next apply archives this row (behind the archive lock) and creates the level with the new key.`}),t.slice(n.length)}s(si,"bareStageKey");function Ep(e){let t=[],n=new Map;return e.forEach((r,i)=>{let o=Ft(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.stages[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?t.push({code:"stage/nameMissing",index:i,message:{de:`[stage/nameMissing] ${l}: jede Klassenstufe braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[stage/nameMissing] ${l}: every stage needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&t.push({code:"stage/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){t.push({code:"stage/keyMissing",index:i,message:{de:`[stage/keyMissing] ${l}: jede Klassenstufe braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[stage/keyMissing] ${l}: every stage needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!vH.test(d)){t.push({code:"stage/keyInvalid",index:i,message:{de:`[stage/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[stage/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=n.get(d);if(c!==void 0){t.push({code:"stage/duplicateKey",index:i,message:{de:`[stage/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.stages[${c}] verwendet`,en:`[stage/duplicateKey] ${l}: key "${d}" is already used by program.stages[${c}]`}});return}n.set(d,i)}),t}s(Ep,"stageSpecIssues");function X_(e){return{de:e.de.trim(),en:e.en.trim()}}s(X_,"trimmedText");function xH(e,t){let n=[];return e.de!==t.de&&n.push(`"${e.de}" \u2192 "${t.de}"`),e.en!==t.en&&n.push(`en "${e.en}" \u2192 "${t.en}"`),n.join(", ")}s(xH,"describeNameChange");function Ip(e,t,n){if(e===null)return t.length>0&&L("planStageReconcile: stages exist but the offer has no program key"),n.map((a,l)=>({op:"insert",key:a.key,name:X_(a.name),...a.gradeLevel!==void 0?{gradeLevel:a.gradeLevel}:{},sequence:l+1}));let r=new Map(t.map(a=>[a.key,a])),i=new Set,o=[];n.forEach(({name:a,...l},d)=>{let c={...l,name:X_(a)},u=ua(e,c.key);i.add(u);let p=d+1,h=r.get(u);if(h===void 0){o.push({op:"insert",key:c.key,name:c.name,...c.gradeLevel!==void 0?{gradeLevel:c.gradeLevel}:{},sequence:p});return}let y={};ca(h.name,c.name)||(y.name=[h.name,c.name]);let b=h.gradeLevel??null,k=c.gradeLevel??null;b!==k&&(y.gradeLevel=[b,k]),h.sequence!==p&&(y.sequence=[h.sequence,p]),(Object.keys(y).length>0||h.archived)&&o.push({op:"update",key:c.key,stageId:h.stageId,name:c.name,changes:y,unarchive:h.archived})});for(let a of[...t].sort((l,d)=>l.sequence-d.sequence))a.archived||i.has(a.key)||o.push({op:"archive",key:eN(e,a.key)?si(e,a.key):a.key,stageId:a.stageId,name:a.name});return o}s(Ip,"planStageReconcile");function Op(e){switch(e.op){case"insert":return`+stage ${e.key} (${e.name.de})`;case"archive":{let t=e.occupancy,n=[...t&&t.activeApplications>0?[`REFUSED: ${t.activeApplications} active application(s) \u2014 [stage/hasActiveApplications]`]:[],...t&&t.openLeads>0?[`${t.openLeads} open lead(s)`]:[]];return`-stage ${e.key} (${e.name.de})${n.length>0?` \u2014 ${n.join("; ")}`:""}`}case"update":{let t=[];if(e.unarchive&&t.push("restored"),e.changes.name&&t.push(xH(e.changes.name[0],e.changes.name[1])),e.changes.gradeLevel){let[n,r]=e.changes.gradeLevel;t.push(`grade ${n??"\u2013"} \u2192 ${r??"\u2013"}`)}return e.changes.sequence&&t.push(`position ${e.changes.sequence[0]} \u2192 ${e.changes.sequence[1]}`),`~stage ${e.key} (${t.join(", ")})`}}}s(Op,"describeStageStep");function _p(e,t){return t.startsWith(e)&&t.length>e.length?t.slice(e.length):void 0}s(_p,"bareUnder");function nN(e,t,n,r){let i=e.flatMap(y=>y.angebote).find(y=>y.offerKey===t);if(i===void 0){let y=e.flatMap(b=>b.angebote.map(k=>k.offerKey));throw new g(`applications start-test: no offer "${t}" (offers: ${y.join(", ")||"none"})`)}if(i.programKey===void 0)throw new g("applications start-test: the deployment does not serve the offer's program key \u2014 it runs an older release than the CLI; try again after the next release");let o=i.programKey;if(o===null)throw new g(`applications start-test: ${t} has no program yet \u2014 no level to start on`);let a=ua(o,""),l=cr(o,""),d=s(y=>_p(a,y)??"(no bundle key)","stageLabel"),c=s(y=>_p(l,y)??"(no bundle key)","runLabel"),u=i.stages.find(y=>y.stageKey===ua(o,r)||y.stageId===r);if(u===void 0){let y=i.stages.map(v=>`${d(v.stageKey)} (${v.stageId})`).join(", "),b=_p(a,r),k=b!==void 0&&i.stages.some(v=>v.stageKey===r)?` \u2014 "${r}" is the stored key; the export names it "${b}"`:"";throw new g(`applications start-test: no level "${r}" in ${t}${k} \u2014 name it by its bundle key or id: ${y}`)}let p=d(u.stageKey),h=u.runs.find(y=>y.runKey===cr(o,n)||y.runId===n);if(h===void 0){let y=u.runs.map(v=>`${c(v.runKey)} (${v.runId})`).join(", "),b=_p(l,n),k=b!==void 0&&u.runs.some(v=>v.runKey===n)?` \u2014 "${n}" is the stored key; the export names it "${b}"`:"";throw new g(`applications start-test: no school year "${n}" for level ${p}${k} \u2014 name it by its bundle key or id: ${y}`)}if(!h.isOpen)throw new g(`applications start-test: school year ${c(h.runKey)} is closed for level ${p}`);return{programRunId:h.runId,programStageId:u.stageId}}s(nN,"resolveStartTarget");function SH(e){return e.kind==="named"?e.name:`(${e.standIn??e.fallback})`}s(SH,"applicantText");function rN(e){return e.map(t=>({id:t.application._id,status:t.deletedAt?`${t.application.status} (gel\xF6scht)`:t.application.status,state:t.currentProcessStateId??"",applicant:SH(t.applicantName),test:t.application.testMode===!0?"test":""}))}s(rN,"applicationRows");var tN=Yw.map(e=>e.email);function iN(e,t,n,r){if(n===void 0&&r===void 0)throw new g("applications start-test: name the applicant \u2014 --party <partyId> or --applicant <email>");if(n!==void 0&&r!==void 0)throw new g("applications start-test: --party or --applicant, not both");if(qw(e,t)&&(r===void 0||!tN.includes(r.trim().toLowerCase())))throw new g(`applications start-test: on prod only for the test account ${tN.join(", ")} (--applicant) \u2014 never a real family's`)}s(iN,"assertStartApplicant");function oN(e){let t={};for(let{address:n,...r}of e.entries)t[n]=r;return{applicationId:e.applicationId,store:t}}s(oN,"processStoreJson");function AH(e){switch(e.kind){case"form":return`form ${e.formInstanceId} (${e.state})`;case"document":return e.file===null?`document ${e.slotKey} (leer)`:`document ${e.slotKey} \xB7 v${e.file.versionNumber} ${e.file.filename??e.file.artifactId}`;case"contract":return`contract ${e.contractId} \xB7 ${e.revision===null?"keine Fassung":`Fassung ${e.revision.snapshotNumber}`} \xB7 ${e.contractStatus}`;case"contracts":return e.contracts.map(t=>`${t.partKey}: contract ${t.contractId} \xB7 ${t.revision===null?"keine Fassung":`Fassung ${t.revision.snapshotNumber}`} \xB7 ${t.contractStatus}`).join("; ")}}s(AH,"refText");function TH(e){return e.state!=="present"?e.reason?.de??"":e.ref!==void 0?AH(e.ref):JSON.stringify(e.value)}s(TH,"holds");function sN(e){return e.entries.map(t=>({address:t.address,state:t.state,holds:TH(t),producer:t.producer?.label??"",written:t.writtenAt===void 0?"":new Date(t.writtenAt).toISOString()}))}s(sN,"storeRows");function Np(e){let t={},n={};for(let r of e){let i=r.indexOf("=");if(i<=0)throw new g(`Expected key=value, got '${r}'.`);let o=r.slice(0,i);if(Object.hasOwn(n,o))throw new g(`'${o}' is given twice.`);let a=r.slice(i+1);n[o]=a;try{t[o]=JSON.parse(a)}catch{t[o]=a}}return{values:t,raw:n}}s(Np,"parseKv");var Jw="started",Pp="submitted",Cp="submitted",aN="load-scenario:";var lN="(Bewerbung)";function dN(e){return{nodeId:lN,actions:e.map(t=>({id:t.id,label:{de:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`,en:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`},...t.disabledReason===void 0?{}:{disabledReason:t.disabledReason}}))}}s(dN,"sharedAsList");function cN(e){return e.disabledReason===void 0?"":e.disabledCount===void 0?e.disabledReason:`${e.disabledReason} (${e.disabledCount})`}s(cN,"disabledText");function uN(e){return e.flatMap(({nodeId:t,actions:n})=>n.map(r=>({node:t,action:r.id,label:r.label.de,disabled:cN(r)})))}s(uN,"actionRows");function fN(e,t,n=[]){let r=e.filter(({actions:d})=>d.some(c=>c.id===t));if(r.length===0){let d=[...new Set(e.flatMap(({actions:c})=>c.map(u=>u.id)))];throw new g(`test-actions run: no current node offers "${t}" (offered: ${d.join(", ")||"nothing"})`)}if(r.length>1)throw new g(`test-actions run: "${t}" is offered by ${r.map(d=>d.nodeId).join(", ")} \u2014 pass --node`);let{nodeId:i,actions:o}=r[0],a=o.find(d=>d.id===t);if(a.disabledReason!==void 0)throw new g(`test-actions run: "${t}" on ${i} is disabled: ${cN(a)}`);if(i!==lN)return i;let l=n[0];if(l===void 0)throw new g(`test-actions run: "${t}" needs a current node \u2014 the application has none`);return l}s(fN,"nodeOfferingAction");function pN(e,t,n){if(e.startsWith(aN)){if(Object.hasOwn(n,"autoSubmit"))throw new g(`test-actions run: ${e}: a scenario's autoSubmit is set by --auto-submit / --no-auto-submit, not --param`);return{autoSubmit:t,...n}}return Object.keys(n).length===0?void 0:{...n}}s(pN,"runParams");var RH=/^[0-9a-hjkmnp-tv-z]{31,37}$/;function ee(e,t){if(!RH.test(e))throw new g(`"${e}" is not a ${t} id \u2014 a Convex id is 31\u201337 characters of 0-9 and a-z without i, l, o, u.`);return e}s(ee,"parseDocumentId");async function $H(e,t){let n=await e.query(S.workflow.getInstance,{applicationId:t});if(n===null)throw new g(`test-actions: application ${t} has no workflow instance`);return n.instance.currentNodeIds}s($H,"currentNodeIds");function EH(e,t){switch(t){case"notTestApplication":return`${e} is not a test application`;case"completed":case"aborted":case"deleted":return`${e} is ${t} \u2014 test actions run only on an active application`;case"missingPermission":return"the caller lacks bewerbungsmanagement.testActions.run"}}s(EH,"refusalText");async function Dp(e,t,n){let r=await e.query(S.workflow.listSharedTestActions,{applicationId:t});if(!r.permitted)throw new g(`test-actions: not permitted \u2014 ${EH(t,r.reason)}`);let i=[];for(let o of n){let a=await e.query(S.workflow.listTestActions,{applicationId:t,nodeId:o});if(a===null)throw new g(`test-actions: node "${o}" is not in this application's workflow (or it has no instance)`);i.push({nodeId:o,actions:a})}return[...i,dN(r.actions)]}s(Dp,"actionsOf");async function mN(e,t,n){return n!==void 0?[n]:await $H(e,t)}s(mN,"nodesOf");var Qw=class extends P{static{s(this,"TestActionsListCommand")}static paths=[["test-actions","list"]];static usage=E.Usage({category:"Admission",description:"List the test-mode actions of the application's current node(s) (scenarios, auto-fill-files, submit, \u2026) and the application-wide ones"});application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});async execute(){let t=ee(this.application,"application"),n=await this.caller(),r=await Dp(n,t,await mN(n,t,this.node));return this.print(r,uN,["node","action","label","disabled"]),0}},Zw=class extends P{static{s(this,"TestActionsRunCommand")}application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});static paths=[["test-actions","run"]];static usage=E.Usage({category:"Admission",description:"Run one test-mode action; a scenario (load-scenario:<id>) also submits unless --no-auto-submit"});action=f.String("--action",{required:!0,description:"Action id, e.g. load-scenario:standard, auto-fill-files, submit-form"});autoSubmit=f.Boolean("--auto-submit",!0,{description:"Scenario only: stub the file fields and submit after loading (default on; --no-auto-submit only loads)"});param=f.Array("--param",{description:"Action parameter key=value (repeatable; the value is JSON where it parses, else text), e.g. --param confirmed=true for an action that asks a question first (its `confirm` in `test-actions list`)"});async execute(){let t=pN(this.action,this.autoSubmit,Np(this.param??[]).values),n=ee(this.application,"application"),r=await this.caller(),i=await mN(r,n,this.node),o=fN(await Dp(r,n,i),this.action,i);return await r.mutation(S.workflow.runTestAction,{applicationId:n,nodeId:o,actionId:this.action,...t===void 0?{}:{params:t}}),this.print({ran:this.action,on:o},a=>[{key:"ran",value:a.ran},{key:"on",value:a.on},{key:"next",value:"test-actions list \u2014 file fills and the submit after them run asynchronously"}]),0}},hN=[Qw,Zw];var Pr=/^[a-z][A-Za-z0-9]*$/;function Xw(e){return typeof e=="string"&&Pr.test(e)}s(Xw,"isNodeId");function fa(e,t){Xw(e)||L(`[graph/nodeIdFormat] "${e}" cannot name a node: a node id is ${Pr.source}.`);let n=new Set(t);if(!n.has(e))return e;let r=2;for(;n.has(`${e}${r}`);)r++;return`${e}${r}`}s(fa,"makeNodeId");var go="$env";function ce(e){if(e.scope==="env")return`${go}.${e.key}`;let t=`$${e.scope}.${e.owner}.${e.key}`;return e.path===void 0?t:`${t}.${e.path}`}s(ce,"formatAddress");var ho=/^[a-z][a-zA-Z0-9_]*$/,IH=/^[A-Za-z_][A-Za-z0-9_]*$/;function Zo(e){return typeof e=="string"&&e.split(".").every(t=>IH.test(t))}s(Zo,"isPath");function Ri(e){if(!e.startsWith("$"))return null;let t=e.slice(1).split("."),[n,...r]=t;switch(n){case"env":{let i=r.join(".");return r.length>0&&Zo(i)?{scope:"env",key:i}:null}case"node":case"task":{let[i,o,...a]=r;return i===void 0||o===void 0||!ho.test(o)||(n==="node"?!Pr.test(i):!ho.test(i))?null:OH({scope:n,owner:i,key:o},a)}default:return null}}s(Ri,"tryParseAddress");function OH(e,t){if(t.length===0)return e;let n=t.join(".");return Zo(n)?{...e,path:n}:null}s(OH,"withPath");function ke(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=t.scope==="env"?["scope","key"]:["scope","owner","key","path"];if(Object.keys(t).some(r=>!n.includes(r))||t.path!==void 0&&!Zo(t.path))return!1;switch(t.scope){case"env":return Zo(t.key);case"node":return typeof t.owner=="string"&&Pr.test(t.owner)&&typeof t.key=="string"&&ho.test(t.key);case"task":return typeof t.owner=="string"&&ho.test(t.owner)&&typeof t.key=="string"&&ho.test(t.key);default:return!1}}s(ke,"isAddress");var yo={offer:{key:"string",title:"string"},unit:{key:"string",name:"string"},stage:{key:"string",name:"string",gradeLevel:"number"},run:{key:"string",name:"string",startDate:"date"},applicant:{language:"enum",channel:"enum"}},pa=Object.keys(yo);function $i(e){return Object.hasOwn(yo,e)}s($i,"isEnvKey");var ek=["self-service","staff"];function gN(e,t){return{kind:"fixed",values:e,labels:t}}s(gN,"fixedSet");var Fp={of:"applicant.language",withoutValue:"de"},Ei={"offer.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Angebot",en:"Offer"}},"offer.title":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Titel des Angebots",en:"Offer title"},nameLanguage:Fp},"unit.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Einheit",en:"Unit"}},"unit.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Einheit",en:"Unit name"},nameLanguage:Fp},"stage.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Klassenstufe (Schl\xFCssel)",en:"Grade (key)"},cohortBound:!0},"stage.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Klassenstufe",en:"Grade name"},cohortBound:!0,nameLanguage:Fp},"stage.gradeLevel":{valueSet:{kind:"open"},nullable:!0,absent:{de:"Die Stufe hat keine Klassenstufe (Kindergarten).",en:"The stage has no grade level (Kindergarten)."},label:{de:"Klassenstufe",en:"Grade level"},cohortBound:!0},"run.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Schuljahr",en:"School year"},cohortBound:!0},"run.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name des Schuljahrs",en:"School year name"},cohortBound:!0,nameLanguage:Fp},"run.startDate":{valueSet:{kind:"open"},nullable:!0,absent:{de:"F\xFCr das Schuljahr ist kein Beginn erfasst.",en:"The school year has no start date."},label:{de:"Beginn des Schuljahrs",en:"School year start"},cohortBound:!0},"applicant.language":{valueSet:gN(We,{de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}}),nullable:!0,absent:{de:"Die Bewerbung hat kein Bewerberkonto (intern angelegt).",en:"The application has no applicant account (started by staff)."},label:{de:"Bewerbersprache",en:"Applicant language"}},"applicant.channel":{valueSet:gN(ek,{staff:{de:"intern",en:"in-house"},"self-service":{de:"online (Familie)",en:"online (family)"}}),nullable:!1,label:{de:"Eingangsweg",en:"Intake channel"}}},Lp={types:yo,fields:Ei},Mp=pa.flatMap(e=>Object.keys(yo[e]).map(t=>`${e}.${t}`));function ur(e){return Object.hasOwn(Ei,e)}s(ur,"isEnvLeaf");function qp(e){return`${go}.${e}`}s(qp,"envIdentifier");function Xo(e){let t=Ei[e],[n,r]=e.split("."),i=yo[n][r];i===void 0&&L(`[env] leaf "${e}" has no type`);let o=t.valueSet;return{leaf:e,type:i,label:t.label,nullable:t.nullable,...t.absent===void 0?{}:{absent:t.absent},...t.nameLanguage===void 0?{}:{nameLanguage:t.nameLanguage},...t.cohortBound===void 0?{}:{cohortBound:t.cohortBound},...o.kind==="fixed"?{enumOptions:o.values.map(a=>{let l=o.labels[a];return l===void 0&&L(`[env] "${e}" names the value "${a}" without a label`),{value:a,label:l}})}:{}}}s(Xo,"envLeaf");var yN="staffInput";var _H=["boolean"],pd=/^[a-z][A-Za-z0-9]*$/;function Kp(e){return e.staffInputs??[]}s(Kp,"staffInputsOf");function jp(e){return`${yN}.${e}`}s(jp,"staffInputLeaf");function wN(e){return`${go}.${jp(e)}`}s(wN,"staffInputIdentifier");function NH(e){let t=`${yN}.`;return e.startsWith(t)?e.slice(t.length):null}s(NH,"staffInputKeyOfLeaf");function ma(e,t){let n=NH(t);return n===null?void 0:Kp(e).find(r=>r.key===n)}s(ma,"declaredStaffInput");function kN(e){return[...Kp(e).map(t=>({leaf:jp(t.key),type:t.type,label:t.label,valueSet:{kind:"open"},nullable:!1,cohortBound:!1})),...Mp.map(t=>{let n=Xo(t);return{leaf:t,type:n.type,label:n.label,valueSet:Ei[t].valueSet,nullable:n.nullable,cohortBound:n.cohortBound===!0}})]}s(kN,"envLeavesFor");function bN(e){return kN(e).filter(t=>!t.cohortBound)}s(bN,"conditionEnvLeaves");function vN(e){return SN(bN(e))}s(vN,"envConditionSchemaFor");function PH(e){return kN(e).map(t=>t.leaf==="stage.key"?{...t,valueSet:{kind:"open"}}:t)}s(PH,"offerConditionEnvLeaves");function xN(e){return SN(PH(e))}s(xN,"offerConditionSchemaFor");function SN(e){let t={},n={};for(let{leaf:r,type:i,valueSet:o,nullable:a}of e){let[l="",d=""]=r.split(".");t[l]={...t[l]??{},[d]:i},n[r]={valueSet:o,nullable:a}}return{types:t,fields:n}}s(SN,"schemaOfLeaves");function AN(e){let t=e.staffInputs;if(t===void 0)return[];if(!Array.isArray(t))return[{path:"staffInputs",reason:{de:"[staffInput/shape] graph.staffInputs muss eine Liste sein.",en:"[staffInput/shape] graph.staffInputs must be a list."}}];let n=[],r=new Set;return t.forEach((i,o)=>{let a=`staffInputs[${o}]`,l=i;if(l===null||typeof l!="object"||typeof l.key!="string"){n.push({path:a,reason:{de:"[staffInput/shape] Eine interne Angabe braucht key, type und label ({ de, en }).",en:"[staffInput/shape] An internal entry needs key, type and label ({ de, en })."}});return}let d={de:`Interne Angabe "${l.key}"`,en:`Internal entry "${l.key}"`};pd.test(l.key)||n.push({path:`${a}.key`,reason:{de:`[staffInput/keyFormat] ${d.de}: Schl\xFCssel beginnt mit einem Kleinbuchstaben und enth\xE4lt nur Buchstaben und Ziffern.`,en:`[staffInput/keyFormat] ${d.en}: the key starts with a lowercase letter and contains only letters and digits.`}}),r.has(l.key)&&n.push({path:`${a}.key`,reason:{de:`[staffInput/duplicateKey] ${d.de}: Schl\xFCssel ist doppelt vergeben.`,en:`[staffInput/duplicateKey] ${d.en}: the key is used twice.`}}),r.add(l.key),_H.includes(l.type)||n.push({path:`${a}.type`,reason:{de:`[staffInput/unknownType] ${d.de}: Typ "${String(l.type)}" \u2014 erlaubt ist nur "boolean" (K\xE4stchen).`,en:`[staffInput/unknownType] ${d.en}: type "${String(l.type)}" \u2014 only "boolean" (checkbox) is allowed.`}});let c=Ft(l.label);c==="not-localized"?n.push({path:`${a}.label`,reason:{de:`[staffInput/shape] ${d.de}: label muss { de, en } sein.`,en:`[staffInput/shape] ${d.en}: label must be { de, en }.`}}):c.length>0&&n.push({path:`${a}.label`,reason:{de:`[i18n/missingTranslation] ${d.de}: Beschriftung fehlt in ${c.join(", ")}.`,en:`[i18n/missingTranslation] ${d.en}: label is missing in ${c.join(", ")}.`}})}),n}s(AN,"staffInputIssues");function Lt(e,t){if(e instanceof $e)return new $e(t(e.message),{cause:e});if(e instanceof g)return new g(t(e.message),{cause:e});let n=dr(e);if(n!==null&&(n.message.de!==""||n.message.en!=="")){let r=e.data,i=typeof r=="string"?t(r):{...r,message:{de:n.message.de===""?"":t(n.message.de),en:n.message.en===""?"":t(n.message.en)}},o=new Dt(i);return o.cause=e,o}return new Error(t(Zl(e)),{cause:e})}s(Lt,"withContext");var uk={required:!0,description:"Offer slug (its offerKey)"},tk=class extends P{static{s(this,"ApplicationsListCommand")}static paths=[["applications","list"]];static usage=E.Usage({category:"Admission",description:"List an offer's applications (id, status, board state, applicant, test)"});offer=f.String("--offer",uk);testOnly=f.Boolean("--test-only",!1,{description:"Only test applications"});async execute(){let t=await this.caller(),n=await t.query(S.admission.listForAngebot,{client:this.requireTenant(t),offerKey:this.offer}),r=rN(n).filter(i=>!this.testOnly||i.test==="test");return this.print(r,i=>i,["id","status","state","applicant","test"]),0}},nk=class extends P{static{s(this,"ApplicationsCountsCommand")}static paths=[["applications","counts"]];static usage=E.Usage({category:"Admission",description:"Count an offer's applications per list"});offer=f.String("--offer",uk);async execute(){let t=await this.caller(),n=await t.query(S.admission.getCountsByListForAngebot,{client:this.requireTenant(t),offerKey:this.offer});return this.print(n,r=>[...Object.entries(r.counts).map(([i,o])=>({list:i,count:String(o)})),{list:"total",count:String(r.total)}],["list","count"]),0}},rk=class extends P{static{s(this,"ApplicationsShowCommand")}static paths=[["applications","show"]];static usage=E.Usage({category:"Admission",description:"One application: status, test flag, offer, current workflow nodes"});application=f.String({required:!0});async execute(){let t=await this.caller(),n=ee(this.application,"application"),r=await t.query(S.admission.get,{applicationId:n});if(r===null)throw new g(`applications show: no application ${n} (or not visible to you)`);let i=await t.query(S.workflow.getInstance,{applicationId:n});return this.print({application:r,currentNodes:i?.instance.currentNodeIds??[]},o=>[{key:"id",value:n},{key:"status",value:o.application.status},{key:"test",value:o.application.testMode?"ja":"nein"},{key:"offer",value:o.application.offerId},{key:"current nodes",value:o.currentNodes.join(", ")}]),0}},ik=class extends P{static{s(this,"ApplicationsStoreCommand")}static paths=[["applications","store"]];static usage=E.Usage({category:"Admission",description:"One application's process store: every address of its pinned graph, resolved (present / pending / absent)",details:"Staff only (applications.manage). --json prints one object keyed by the canonical address ($node\u2026, $task\u2026, $env\u2026). Values are shown whatever their audience \u2014 never hand the output to the family. Recipe: playbooks/applications/inspect-process-store.md."});application=f.String({required:!0});async execute(){let n=await(await this.caller()).query(S.processStoreView.get,{applicationId:ee(this.application,"application")});return this.print(oN(n),()=>sN(n),["address","state","holds","producer","written"]),0}},ok=class extends P{static{s(this,"ApplicationsStartTestCommand")}static paths=[["applications","start-test"]];static usage=E.Usage({category:"Admission",description:"Start a TEST application for an applicant (school year and level by key or id) and show what test mode offers next",details:"Always test mode. --applicant names the account by its login address (on prod only the tenant's test account); --party names the applicant party directly. Without --version it runs on the live generation, like the cockpit."});offer=f.String("--offer",uk);run=f.String("--run",{required:!0,description:"School year: its bundle key as offer export shows it (program.runs[].key) or id \u2014 never its name"});stage=f.String("--stage",{required:!0,description:"Level: its bundle key as offer export shows it (program.stages[].key) or id \u2014 never its name"});party=f.String("--party",{description:"Applicant party id"});applicant=f.String("--applicant",{description:"Applicant account login address (e.g. the test account test@example.com)"});version=f.String("--version",{description:"Offer version id to test (default: the live generation)"});staffInput=f.Array("--staff-input",{description:"A staff input the offer declares, as key=true|false \u2014 repeat it once per input; a staff start must set every one"});proxy=f.Boolean("--proxy",{description:"Start in Stellvertretung (--proxy) or not (--no-proxy); left out, the tenant's default applies, as in the cockpit"});async execute(){let t=await this.caller();iN(this.resolvedTarget(),this.prodUrls(),this.party,this.applicant);let n=this.requireTenant(t),r=nN(await t.query(S.admission.listAdmissionTree,{client:n}),this.offer,this.run,this.stage),i=this.party===void 0?void 0:ee(this.party,"party");if(this.applicant!==void 0){let d=await t.query(S.applicants.partyByEmail,{client:n,email:this.applicant});if(d===null)throw new g(`applications start-test: no applicant account ${this.applicant} at this school (create it in the cockpit first)`);i=d}let o=await t.mutation(S.admission.staffStartApplicationForParty,{client:n,offerKey:this.offer,partyId:i,programRunId:r.programRunId,programStageId:r.programStageId,...this.proxy===void 0?{}:{startInProxy:this.proxy},staffInputs:RN(this.staffInput??[]),testMode:!0,...this.version===void 0?{}:{offerVersionId:ee(this.version,"offer version")}}),a,l;try{let d=await t.query(S.workflow.getInstance,{applicationId:o.applicationId});if(d===null)throw new Error("the started application has no workflow instance");a=d.instance.currentNodeIds,l=(await Dp(t,o.applicationId,a)).flatMap(c=>c.actions.map(u=>u.id))}catch(d){throw Lt(d,c=>`applications start-test: started ${o.applicationId}, but reading its state failed: ${c}`)}return this.print({applicationId:o.applicationId,currentNodes:a,testActions:l},d=>[{key:"application",value:d.applicationId},{key:"current nodes",value:d.currentNodes.join(", ")},{key:"test actions",value:d.testActions.join(", ")},{key:"next",value:`test-actions run --application ${d.applicationId} --action <id>`}]),0}},sk=class extends P{static{s(this,"ApplicationsDiscardTestCommand")}static paths=[["applications","discard-test"]];static usage=E.Usage({category:"Admission",description:"Discard a TEST application (the server refuses a real one), or with --all-test every expired one of the school",details:"With an id: discards that test application. With --all-test --older-than <N>d: lists the school's test applications whose last activity is older than N days (N \u2265 14) and that are not kept as a demo \u2014 a dry run unless --confirm; --confirm discards each expired one the server re-checks, the rest are reported with the reason. Recipe: playbooks/applications/expire-test-applications.md.",examples:[["Dry run","plexus-cli --env prod --tenant <t> applications discard-test --all-test --older-than 14d --dry-run"],["Discard","plexus-cli --env prod --tenant <t> --allow-prod applications discard-test --all-test --older-than 14d --confirm"]]});application=f.String({required:!1});allTest=f.Boolean("--all-test",!1,{description:"Every expired test application of the school instead of one id"});olderThan=f.String("--older-than",{description:"With --all-test: days without activity, as <N>d (N \u2265 14)"});dryRun=f.Boolean("--dry-run",!1,{description:"With --all-test: list only (the default)"});confirm=f.Boolean("--confirm",!1,{description:"With --all-test: discard (else the dry run)"});async execute(){if(!this.allTest){if(this.application===void 0)throw new g("applications discard-test: name an application id, or use --all-test --older-than <N>d");if(this.olderThan!==void 0||this.dryRun||this.confirm)throw new g("applications discard-test: --older-than, --dry-run and --confirm belong to --all-test");return await(await this.caller()).mutation(S.admission.discardTest,{applicationId:ee(this.application,"application")}),this.print({discarded:this.application},u=>[{key:"discarded",value:u.discarded}]),0}if(this.application!==void 0)throw new g("applications discard-test: --all-test takes no application id");if(this.olderThan===void 0)throw new g("applications discard-test --all-test: --older-than <N>d is required");if(this.dryRun&&this.confirm)throw new g("applications discard-test: --dry-run and --confirm exclude each other");let t=CH(this.olderThan),n=await this.caller(),r=this.requireTenant(n),i=[],o=null;for(;;){let c=await n.query(S.admission.testTtlPlan,{client:r,olderThanDays:t,cursor:o});if(i.push(...c.rows),c.isDone)break;o=c.continueCursor}let a=i.map(c=>({...c,result:c.verdict!=="expired"?"kept":c.block!==null?"blocked":this.confirm?"pending":"would discard"})),l=i.filter(c=>c.verdict==="expired"&&c.protectedDemo).map(c=>c.applicationId);if(this.confirm&&l.length>0)throw new g(`applications discard-test --all-test: protected demo application(s) in the discard set, nothing discarded: ${l.join(", ")}`);let d=0;if(this.confirm)for(let c of a.filter(u=>u.result==="pending"))try{await n.mutation(S.admission.discardExpiredTest,{applicationId:c.applicationId,olderThanDays:t}),c.result="discarded"}catch(u){d++,c.result=`failed: ${u instanceof Error?u.message:String(u)}`}return this.print({olderThanDays:t,confirm:this.confirm,rows:a},c=>c.rows.map(u=>({id:u.applicationId,lastActivity:new Date(u.lastActivityAt).toISOString().slice(0,10),verdict:u.verdict,block:u.block??"",result:u.result})),["id","lastActivity","verdict","block","result"]),d>0?1:0}};function CH(e){let t=/^(\d+)d$/.exec(e.trim());if(t===null)throw new g(`--older-than "${e}": expected <N>d, e.g. 14d`);return Number(t[1])}s(CH,"parseDays");var ak=class extends P{static{s(this,"ApplicationsSetKeepDemoCommand")}static paths=[["applications","set-keep-demo"]];static usage=E.Usage({category:"Admission",description:"Mark a TEST application \u201EDemo behalten\u201C (never expires, never discarded), or clear the mark with --off"});application=f.String({required:!0});off=f.Boolean("--off",!1,{description:"Clear the mark"});async execute(){return await(await this.caller()).mutation(S.admission.setKeepAsDemo,{applicationId:ee(this.application,"application"),keep:!this.off}),this.print({application:this.application,keepAsDemo:!this.off},n=>[{key:"application",value:n.application},{key:"keep as demo",value:n.keepAsDemo?"ja":"nein"}]),0}},lk=class extends P{static{s(this,"ApplicationsStaffInputListCommand")}static paths=[["applications","staff-input","list"]];static usage=E.Usage({category:"Admission",description:"An application's internal inputs (set at the start): value, and why one can no longer be corrected"});application=f.String({required:!0});async execute(){let n=await(await this.caller()).query(S.admission.staffInputsOfApplication,{applicationId:ee(this.application,"application")});return this.print(n,r=>r.map(i=>({key:i.key,label:i.label.de,value:String(i.value),correctable:i.block===null?"ja":i.block.de})),["key","label","value","correctable"]),0}},dk=class extends P{static{s(this,"ApplicationsStaffInputSetCommand")}static paths=[["applications","staff-input","set"]];static usage=E.Usage({category:"Admission",description:"Correct one internal input of an application, with a reason \u2014 refused once a node that reads it was entered",examples:[["Untick \u201EKind von Mitarbeitenden\u201C",'plexus-cli --env prod --tenant <t> --allow-prod applications staff-input set <id> --input staffApplication=false --reason "falsch angehakt"']]});application=f.String({required:!0});input=f.String("--input",{required:!0,description:"key=true|false"});reason=f.String("--reason",{required:!0,description:"Why \u2014 recorded on the application's activity feed"});async execute(){let t=await this.caller(),[{key:n,value:r}]=RN([this.input]);return await t.mutation(S.admission.correctStaffInput,{applicationId:ee(this.application,"application"),key:n,value:r,reason:this.reason}),this.print({application:this.application,key:n,value:r},i=>[{key:"application",value:i.application},{key:i.key,value:String(i.value)}]),0}},ck=class extends P{static{s(this,"ApplicationsPurgeCommand")}static paths=[["platform","applications","purge"]];static usage=E.Usage({category:"Admission",description:"Hard-delete one real application staff started for a colleague and already deleted (plan unless --confirm). Needs _platform.config.manage.",details:"Refused unless all hold: a real application (a test one goes with `applications discard-test`), soft-deleted by staff, started by staff, its applicant an internal staff member of the school (also a switched-off one) whose person existed before, no data about anyone else (only empty drafts the form opened), nothing committed yet, and no contract, signing process, payment or Engage push. Deletes the application and every row it created; the staff member's person stays. Afterwards the responsible person can be deactivated.",examples:[["Plan","plexus-cli --env prod --tenant <slug> platform applications purge <applicationId>"],["Apply","plexus-cli --env prod --tenant <slug> --allow-prod platform applications purge <applicationId> --confirm"]]});application=f.String({required:!0});confirm=f.Boolean("--confirm",!1,{description:"Delete for good (without it, only the checks run)."});async execute(){let t=await this.caller(),n=await t.mutation(S.admission.purgeDeletedStaffApplication,{tenantSlug:this.requireTenant(t),applicationId:ee(this.application,"application"),dryRun:!this.confirm});if(this.json)return this.print(n),0;let r=this.context.stdout;return r.write(`${n.applied?"Deleted":"Would delete"} application ${n.applicationId} `),r.write(`(applicant ${n.applicantPartyId}, soft-deleted ${new Date(n.deletedAt).toISOString()})
11585
+ `,"references/worker-ops/set-import-default-unit.md":"# Set the default unit of an import source\n\n**When to use:** a unit that an import source uses as its default unit has to\ngo, or imported records should attach to another unit by default.\n`org unit delete` refuses the default unit of an import source\n(`[unit/importSourceDefault]`). Point the source at another unit first.\n\n## Prerequisites\n- **Auth:** a platform operator's token with `_platform.config.manage`. A\n school's own token is refused, because the import source belongs to the operator.\n- **Env:** a writing run needs `--env <local|staging|prod>` on the command line,\n and `--allow-prod` against production.\n- You need the source key (`imports status --tenant <slug>`, column `config`)\n and the new unit's config key (`org tree`, column `key`).\n\n## Steps\n\n```bash\n# Plan: shows the current default and the new one, and writes nothing\nplexus-cli --env prod --allow-prod platform imports source set-default-unit <source> --unit <unit-key>\n# Write\nplexus-cli --env prod --allow-prod platform imports source set-default-unit <source> --unit <unit-key> --confirm\n```\n\n## Verify\nRun the plan again. It reports `unchanged`, with the new unit as the default.\n\n## Idempotency / gotchas\n- The unit must be one the source already knows by key (every unit of the\n tenant at the time the source was set up). Otherwise the command refuses with\n `[import-source/unitUnknown]` and lists the keys the source knows.\n- Deleting any other unit removes it from the source's key list automatically.\n Only the default unit blocks a delete.\n- The tenant config names the default unit by key: `source.defaultUnitKey`\n (the order of `foundation.units` means nothing). `config export` writes the\n current default there, so an apply from a fresh export keeps it. **An apply\n from an export taken before this change names the old default and sets it\n back**; its plan shows an update on `source`. Export again after setting the\n default, or set `source.defaultUnitKey` in the scratch export by hand.\n- `config apply` refuses a source without `defaultUnitKey`\n (`[import/defaultUnitMissing]`) or with a key that is not in\n `foundation.units` (`[import/defaultUnitUnknown]`). There is no fallback to\n the first unit. An export taken before this change carries no key: add it before\n the apply.\n\n## Related\n- [Edit a school's organisation structure](../organization/edit-org-structure.md)\n- [Debug a stuck/failed import or worker job](./debug-worker-jobs.md)\n"};var Tp="6dab9d77a4e7681702edadd78d9accbb9190380cc354d712965a893df8cc0d27",Bw=W_;var yH=new Set(["ENOENT","ENOTDIR","EISDIR","EACCES","EPERM"]);function wH(e){return typeof e=="object"&&e!==null&&"code"in e?e.code:void 0}s(wH,"codeOf");function Y_(e){return e instanceof Error?e.message:String(e)}s(Y_,"messageOf");function Uw(e,t){try{return Ne(e)}catch(n){throw yH.has(wH(n))?new g(`${t}: ${e} is not readable (${Y_(n)})`,{cause:n}):n}}s(Uw,"readBytesFile");function Gw(e,t){return Uw(e,t).toString("utf8")}s(Gw,"readTextFile");function oi(e,t){try{return JSON.parse(e)}catch(n){throw new g(`${t} is no JSON (${Y_(n)})`,{cause:n})}}s(oi,"parseJsonText");function ze(e,t){return oi(Gw(e,t),`${t}: ${e}`)}s(ze,"readJsonFile");var zw=class extends Ae{static{s(this,"AgentToolsCommand")}static paths=[["agent","tools"]];static usage=E.Usage({category:"Agents",description:"Show the shared platform/CLI agent tool schemas and skill revision."});async execute(){return this.print({skillHash:Tp,tools:ud}),0}},Ww=class extends Ae{static{s(this,"AgentInvokeCommand")}static paths=[["agent","invoke"]];static usage=E.Usage({category:"Agents",description:"Invoke a shared agent tool; pipe its JSON input on stdin."});tool=f.String("--tool",{required:!0,description:"plexus|plexus_skill|plexus_workspace"});async execute(){if("isTTY"in this.context.stdin&&this.context.stdin.isTTY===!0)throw new g("plexus: pipe the tool's JSON input on stdin.");let t=oi(await Vw(this.context.stdin),"stdin"),n=await this.context.executePlexusAgentTool(this.tool,t);return this.print(n),0}},H_=[zw,Ww];var Yw=[{key:"fixture_test",email:"test@example.com",firstName:"Test",lastName:"Bewerber"}],Jfe=new Set(Yw.map(e=>e.key));var We=["de","en"];function ca(e,t){return We.every(n=>e[n]===t[n])}s(ca,"sameText");function Ft(e){if(e===null||typeof e!="object"||Array.isArray(e))return"not-localized";let t=e;return Object.keys(t).some(r=>!We.includes(r))?"not-localized":We.filter(r=>{let i=t[r];return typeof i!="string"||i.trim()===""})}s(Ft,"missingLocales");function mo(e){let t=Ft(e);return t!=="not-localized"&&t.length===0}s(mo,"isLocalizedText");function fd(e,t){let n={};for(let r of We){let i=e.map(o=>o[r]);n[r]=i.every(o=>typeof o=="string"&&o.trim()!=="")?t(i,r):""}return n}s(fd,"composeTexts");function Rp(e){return e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}s(Rp,"slugify");var J_="tenant";function Q_(e){if(e.length===0||Rp(e)!==e)return"must be lowercase a-z/0-9 words joined by single dashes";if(e===J_)return`"${J_}" is reserved for the tenant-wide scope`}s(Q_,"unitSlugError");var kH=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function cr(e,t){return`${e}-${t}`}s(cr,"runStorageKey");function Z_(e,t){typeof t!="string"&&de("CONFLICT",{de:`[run/keyNotServed] Das Deployment liefert f\xFCr ein Schuljahr von \u201E${e}\u201C keinen Schl\xFCssel \u2014 es l\xE4uft ein \xE4lteres Release als die CLI. Nach dem n\xE4chsten Release erneut versuchen.`,en:`[run/keyNotServed] The deployment provides no key for a school year of "${e}" \u2014 it runs an older release than the CLI. Try again after the next release.`});let n=`${e}-`;return(!t.startsWith(n)||t.length===n.length)&&de("CONFLICT",{de:`[run/foreignKey] Der Schl\xFCssel \u201E${t}\u201C des Schuljahrs liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${n}<key>\u201C).`,en:`[run/foreignKey] The key "${t}" of the school year is not under the program "${e}" (expected: "${n}<key>").`}),t.slice(n.length)}s(Z_,"bareRunKey");function $p(e){let t=[],n=new Map;return e.forEach((r,i)=>{let o=Ft(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.runs[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?t.push({code:"run/nameMissing",index:i,message:{de:`[run/nameMissing] ${l}: jedes Schuljahr braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[run/nameMissing] ${l}: every run needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&t.push({code:"run/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){t.push({code:"run/keyMissing",index:i,message:{de:`[run/keyMissing] ${l}: jedes Schuljahr braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[run/keyMissing] ${l}: every run needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!kH.test(d)){t.push({code:"run/keyInvalid",index:i,message:{de:`[run/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[run/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=n.get(d);if(c!==void 0){t.push({code:"run/duplicateKey",index:i,message:{de:`[run/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.runs[${c}] verwendet`,en:`[run/duplicateKey] ${l}: key "${d}" is already used by program.runs[${c}]`}});return}n.set(d,i)}),t}s($p,"runSpecIssues");var bH="-stufe-",vH=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function Hw(e){return`${e}${bH}`}s(Hw,"stageKeyPrefix");function ua(e,t){return`${Hw(e)}${t}`}s(ua,"stageStorageKey");function eN(e,t){let n=Hw(e);return t.startsWith(n)&&t.length>n.length}s(eN,"isUnderProgram");function si(e,t){let n=Hw(e);return eN(e,t)||de("CONFLICT",{de:`[stage/foreignKey] Der Stufenschl\xFCssel \u201E${t}\u201C liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${n}<key>\u201C). F\xFChren Sie die Stufe in bundle.yaml unter einem neuen Schl\xFCssel auf; der n\xE4chste Apply archiviert diese Zeile (hinter der Archivsperre) und legt die Stufe mit dem neuen Schl\xFCssel an.`,en:`[stage/foreignKey] The level key "${t}" is not under the program "${e}" (expected: "${n}<key>"). List the level in bundle.yaml under a new key; the next apply archives this row (behind the archive lock) and creates the level with the new key.`}),t.slice(n.length)}s(si,"bareStageKey");function Ep(e){let t=[],n=new Map;return e.forEach((r,i)=>{let o=Ft(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.stages[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?t.push({code:"stage/nameMissing",index:i,message:{de:`[stage/nameMissing] ${l}: jede Klassenstufe braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[stage/nameMissing] ${l}: every stage needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&t.push({code:"stage/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){t.push({code:"stage/keyMissing",index:i,message:{de:`[stage/keyMissing] ${l}: jede Klassenstufe braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[stage/keyMissing] ${l}: every stage needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!vH.test(d)){t.push({code:"stage/keyInvalid",index:i,message:{de:`[stage/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[stage/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=n.get(d);if(c!==void 0){t.push({code:"stage/duplicateKey",index:i,message:{de:`[stage/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.stages[${c}] verwendet`,en:`[stage/duplicateKey] ${l}: key "${d}" is already used by program.stages[${c}]`}});return}n.set(d,i)}),t}s(Ep,"stageSpecIssues");function X_(e){return{de:e.de.trim(),en:e.en.trim()}}s(X_,"trimmedText");function xH(e,t){let n=[];return e.de!==t.de&&n.push(`"${e.de}" \u2192 "${t.de}"`),e.en!==t.en&&n.push(`en "${e.en}" \u2192 "${t.en}"`),n.join(", ")}s(xH,"describeNameChange");function Ip(e,t,n){if(e===null)return t.length>0&&L("planStageReconcile: stages exist but the offer has no program key"),n.map((a,l)=>({op:"insert",key:a.key,name:X_(a.name),...a.gradeLevel!==void 0?{gradeLevel:a.gradeLevel}:{},sequence:l+1}));let r=new Map(t.map(a=>[a.key,a])),i=new Set,o=[];n.forEach(({name:a,...l},d)=>{let c={...l,name:X_(a)},u=ua(e,c.key);i.add(u);let p=d+1,h=r.get(u);if(h===void 0){o.push({op:"insert",key:c.key,name:c.name,...c.gradeLevel!==void 0?{gradeLevel:c.gradeLevel}:{},sequence:p});return}let y={};ca(h.name,c.name)||(y.name=[h.name,c.name]);let b=h.gradeLevel??null,k=c.gradeLevel??null;b!==k&&(y.gradeLevel=[b,k]),h.sequence!==p&&(y.sequence=[h.sequence,p]),(Object.keys(y).length>0||h.archived)&&o.push({op:"update",key:c.key,stageId:h.stageId,name:c.name,changes:y,unarchive:h.archived})});for(let a of[...t].sort((l,d)=>l.sequence-d.sequence))a.archived||i.has(a.key)||o.push({op:"archive",key:eN(e,a.key)?si(e,a.key):a.key,stageId:a.stageId,name:a.name});return o}s(Ip,"planStageReconcile");function Op(e){switch(e.op){case"insert":return`+stage ${e.key} (${e.name.de})`;case"archive":{let t=e.occupancy,n=[...t&&t.activeApplications>0?[`REFUSED: ${t.activeApplications} active application(s) \u2014 [stage/hasActiveApplications]`]:[],...t&&t.openLeads>0?[`${t.openLeads} open lead(s)`]:[]];return`-stage ${e.key} (${e.name.de})${n.length>0?` \u2014 ${n.join("; ")}`:""}`}case"update":{let t=[];if(e.unarchive&&t.push("restored"),e.changes.name&&t.push(xH(e.changes.name[0],e.changes.name[1])),e.changes.gradeLevel){let[n,r]=e.changes.gradeLevel;t.push(`grade ${n??"\u2013"} \u2192 ${r??"\u2013"}`)}return e.changes.sequence&&t.push(`position ${e.changes.sequence[0]} \u2192 ${e.changes.sequence[1]}`),`~stage ${e.key} (${t.join(", ")})`}}}s(Op,"describeStageStep");function _p(e,t){return t.startsWith(e)&&t.length>e.length?t.slice(e.length):void 0}s(_p,"bareUnder");function nN(e,t,n,r){let i=e.flatMap(y=>y.angebote).find(y=>y.offerKey===t);if(i===void 0){let y=e.flatMap(b=>b.angebote.map(k=>k.offerKey));throw new g(`applications start-test: no offer "${t}" (offers: ${y.join(", ")||"none"})`)}if(i.programKey===void 0)throw new g("applications start-test: the deployment does not serve the offer's program key \u2014 it runs an older release than the CLI; try again after the next release");let o=i.programKey;if(o===null)throw new g(`applications start-test: ${t} has no program yet \u2014 no level to start on`);let a=ua(o,""),l=cr(o,""),d=s(y=>_p(a,y)??"(no bundle key)","stageLabel"),c=s(y=>_p(l,y)??"(no bundle key)","runLabel"),u=i.stages.find(y=>y.stageKey===ua(o,r)||y.stageId===r);if(u===void 0){let y=i.stages.map(v=>`${d(v.stageKey)} (${v.stageId})`).join(", "),b=_p(a,r),k=b!==void 0&&i.stages.some(v=>v.stageKey===r)?` \u2014 "${r}" is the stored key; the export names it "${b}"`:"";throw new g(`applications start-test: no level "${r}" in ${t}${k} \u2014 name it by its bundle key or id: ${y}`)}let p=d(u.stageKey),h=u.runs.find(y=>y.runKey===cr(o,n)||y.runId===n);if(h===void 0){let y=u.runs.map(v=>`${c(v.runKey)} (${v.runId})`).join(", "),b=_p(l,n),k=b!==void 0&&u.runs.some(v=>v.runKey===n)?` \u2014 "${n}" is the stored key; the export names it "${b}"`:"";throw new g(`applications start-test: no school year "${n}" for level ${p}${k} \u2014 name it by its bundle key or id: ${y}`)}if(!h.isOpen)throw new g(`applications start-test: school year ${c(h.runKey)} is closed for level ${p}`);return{programRunId:h.runId,programStageId:u.stageId}}s(nN,"resolveStartTarget");function SH(e){return e.kind==="named"?e.name:`(${e.standIn??e.fallback})`}s(SH,"applicantText");function rN(e){return e.map(t=>({id:t.application._id,status:t.deletedAt?`${t.application.status} (gel\xF6scht)`:t.application.status,state:t.currentProcessStateId??"",applicant:SH(t.applicantName),test:t.application.testMode===!0?"test":""}))}s(rN,"applicationRows");var tN=Yw.map(e=>e.email);function iN(e,t,n,r){if(n===void 0&&r===void 0)throw new g("applications start-test: name the applicant \u2014 --party <partyId> or --applicant <email>");if(n!==void 0&&r!==void 0)throw new g("applications start-test: --party or --applicant, not both");if(qw(e,t)&&(r===void 0||!tN.includes(r.trim().toLowerCase())))throw new g(`applications start-test: on prod only for the test account ${tN.join(", ")} (--applicant) \u2014 never a real family's`)}s(iN,"assertStartApplicant");function oN(e){let t={};for(let{address:n,...r}of e.entries)t[n]=r;return{applicationId:e.applicationId,store:t}}s(oN,"processStoreJson");function AH(e){switch(e.kind){case"form":return`form ${e.formInstanceId} (${e.state})`;case"document":return e.file===null?`document ${e.slotKey} (leer)`:`document ${e.slotKey} \xB7 v${e.file.versionNumber} ${e.file.filename??e.file.artifactId}`;case"contract":return`contract ${e.contractId} \xB7 ${e.revision===null?"keine Fassung":`Fassung ${e.revision.snapshotNumber}`} \xB7 ${e.contractStatus}`;case"contracts":return e.contracts.map(t=>`${t.partKey}: contract ${t.contractId} \xB7 ${t.revision===null?"keine Fassung":`Fassung ${t.revision.snapshotNumber}`} \xB7 ${t.contractStatus}`).join("; ")}}s(AH,"refText");function TH(e){return e.state!=="present"?e.reason?.de??"":e.ref!==void 0?AH(e.ref):JSON.stringify(e.value)}s(TH,"holds");function sN(e){return e.entries.map(t=>({address:t.address,state:t.state,holds:TH(t),producer:t.producer?.label??"",written:t.writtenAt===void 0?"":new Date(t.writtenAt).toISOString()}))}s(sN,"storeRows");function Np(e){let t={},n={};for(let r of e){let i=r.indexOf("=");if(i<=0)throw new g(`Expected key=value, got '${r}'.`);let o=r.slice(0,i);if(Object.hasOwn(n,o))throw new g(`'${o}' is given twice.`);let a=r.slice(i+1);n[o]=a;try{t[o]=JSON.parse(a)}catch{t[o]=a}}return{values:t,raw:n}}s(Np,"parseKv");var Jw="started",Pp="submitted",Cp="submitted",aN="load-scenario:";var lN="(Bewerbung)";function dN(e){return{nodeId:lN,actions:e.map(t=>({id:t.id,label:{de:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`,en:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`},...t.disabledReason===void 0?{}:{disabledReason:t.disabledReason}}))}}s(dN,"sharedAsList");function cN(e){return e.disabledReason===void 0?"":e.disabledCount===void 0?e.disabledReason:`${e.disabledReason} (${e.disabledCount})`}s(cN,"disabledText");function uN(e){return e.flatMap(({nodeId:t,actions:n})=>n.map(r=>({node:t,action:r.id,label:r.label.de,disabled:cN(r)})))}s(uN,"actionRows");function fN(e,t,n=[]){let r=e.filter(({actions:d})=>d.some(c=>c.id===t));if(r.length===0){let d=[...new Set(e.flatMap(({actions:c})=>c.map(u=>u.id)))];throw new g(`test-actions run: no current node offers "${t}" (offered: ${d.join(", ")||"nothing"})`)}if(r.length>1)throw new g(`test-actions run: "${t}" is offered by ${r.map(d=>d.nodeId).join(", ")} \u2014 pass --node`);let{nodeId:i,actions:o}=r[0],a=o.find(d=>d.id===t);if(a.disabledReason!==void 0)throw new g(`test-actions run: "${t}" on ${i} is disabled: ${cN(a)}`);if(i!==lN)return i;let l=n[0];if(l===void 0)throw new g(`test-actions run: "${t}" needs a current node \u2014 the application has none`);return l}s(fN,"nodeOfferingAction");function pN(e,t,n){if(e.startsWith(aN)){if(Object.hasOwn(n,"autoSubmit"))throw new g(`test-actions run: ${e}: a scenario's autoSubmit is set by --auto-submit / --no-auto-submit, not --param`);return{autoSubmit:t,...n}}return Object.keys(n).length===0?void 0:{...n}}s(pN,"runParams");var RH=/^[0-9a-hjkmnp-tv-z]{31,37}$/;function ee(e,t){if(!RH.test(e))throw new g(`"${e}" is not a ${t} id \u2014 a Convex id is 31\u201337 characters of 0-9 and a-z without i, l, o, u.`);return e}s(ee,"parseDocumentId");async function $H(e,t){let n=await e.query(S.workflow.getInstance,{applicationId:t});if(n===null)throw new g(`test-actions: application ${t} has no workflow instance`);return n.instance.currentNodeIds}s($H,"currentNodeIds");function EH(e,t){switch(t){case"notTestApplication":return`${e} is not a test application`;case"completed":case"aborted":case"deleted":return`${e} is ${t} \u2014 test actions run only on an active application`;case"missingPermission":return"the caller lacks bewerbungsmanagement.testActions.run"}}s(EH,"refusalText");async function Dp(e,t,n){let r=await e.query(S.workflow.listSharedTestActions,{applicationId:t});if(!r.permitted)throw new g(`test-actions: not permitted \u2014 ${EH(t,r.reason)}`);let i=[];for(let o of n){let a=await e.query(S.workflow.listTestActions,{applicationId:t,nodeId:o});if(a===null)throw new g(`test-actions: node "${o}" is not in this application's workflow (or it has no instance)`);i.push({nodeId:o,actions:a})}return[...i,dN(r.actions)]}s(Dp,"actionsOf");async function mN(e,t,n){return n!==void 0?[n]:await $H(e,t)}s(mN,"nodesOf");var Qw=class extends P{static{s(this,"TestActionsListCommand")}static paths=[["test-actions","list"]];static usage=E.Usage({category:"Admission",description:"List the test-mode actions of the application's current node(s) (scenarios, auto-fill-files, submit, \u2026) and the application-wide ones"});application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});async execute(){let t=ee(this.application,"application"),n=await this.caller(),r=await Dp(n,t,await mN(n,t,this.node));return this.print(r,uN,["node","action","label","disabled"]),0}},Zw=class extends P{static{s(this,"TestActionsRunCommand")}application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});static paths=[["test-actions","run"]];static usage=E.Usage({category:"Admission",description:"Run one test-mode action; a scenario (load-scenario:<id>) also submits unless --no-auto-submit"});action=f.String("--action",{required:!0,description:"Action id, e.g. load-scenario:standard, auto-fill-files, submit-form"});autoSubmit=f.Boolean("--auto-submit",!0,{description:"Scenario only: stub the file fields and submit after loading (default on; --no-auto-submit only loads)"});param=f.Array("--param",{description:"Action parameter key=value (repeatable; the value is JSON where it parses, else text), e.g. --param confirmed=true for an action that asks a question first (its `confirm` in `test-actions list`)"});async execute(){let t=pN(this.action,this.autoSubmit,Np(this.param??[]).values),n=ee(this.application,"application"),r=await this.caller(),i=await mN(r,n,this.node),o=fN(await Dp(r,n,i),this.action,i);return await r.mutation(S.workflow.runTestAction,{applicationId:n,nodeId:o,actionId:this.action,...t===void 0?{}:{params:t}}),this.print({ran:this.action,on:o},a=>[{key:"ran",value:a.ran},{key:"on",value:a.on},{key:"next",value:"test-actions list \u2014 file fills and the submit after them run asynchronously"}]),0}},hN=[Qw,Zw];var Pr=/^[a-z][A-Za-z0-9]*$/;function Xw(e){return typeof e=="string"&&Pr.test(e)}s(Xw,"isNodeId");function fa(e,t){Xw(e)||L(`[graph/nodeIdFormat] "${e}" cannot name a node: a node id is ${Pr.source}.`);let n=new Set(t);if(!n.has(e))return e;let r=2;for(;n.has(`${e}${r}`);)r++;return`${e}${r}`}s(fa,"makeNodeId");var go="$env";function ce(e){if(e.scope==="env")return`${go}.${e.key}`;let t=`$${e.scope}.${e.owner}.${e.key}`;return e.path===void 0?t:`${t}.${e.path}`}s(ce,"formatAddress");var ho=/^[a-z][a-zA-Z0-9_]*$/,IH=/^[A-Za-z_][A-Za-z0-9_]*$/;function Zo(e){return typeof e=="string"&&e.split(".").every(t=>IH.test(t))}s(Zo,"isPath");function Ri(e){if(!e.startsWith("$"))return null;let t=e.slice(1).split("."),[n,...r]=t;switch(n){case"env":{let i=r.join(".");return r.length>0&&Zo(i)?{scope:"env",key:i}:null}case"node":case"task":{let[i,o,...a]=r;return i===void 0||o===void 0||!ho.test(o)||(n==="node"?!Pr.test(i):!ho.test(i))?null:OH({scope:n,owner:i,key:o},a)}default:return null}}s(Ri,"tryParseAddress");function OH(e,t){if(t.length===0)return e;let n=t.join(".");return Zo(n)?{...e,path:n}:null}s(OH,"withPath");function ke(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=t.scope==="env"?["scope","key"]:["scope","owner","key","path"];if(Object.keys(t).some(r=>!n.includes(r))||t.path!==void 0&&!Zo(t.path))return!1;switch(t.scope){case"env":return Zo(t.key);case"node":return typeof t.owner=="string"&&Pr.test(t.owner)&&typeof t.key=="string"&&ho.test(t.key);case"task":return typeof t.owner=="string"&&ho.test(t.owner)&&typeof t.key=="string"&&ho.test(t.key);default:return!1}}s(ke,"isAddress");var yo={offer:{key:"string",title:"string"},unit:{key:"string",name:"string"},stage:{key:"string",name:"string",gradeLevel:"number"},run:{key:"string",name:"string",startDate:"date"},applicant:{language:"enum",channel:"enum"}},pa=Object.keys(yo);function $i(e){return Object.hasOwn(yo,e)}s($i,"isEnvKey");var ek=["self-service","staff"];function gN(e,t){return{kind:"fixed",values:e,labels:t}}s(gN,"fixedSet");var Fp={of:"applicant.language",withoutValue:"de"},Ei={"offer.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Angebot",en:"Offer"}},"offer.title":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Titel des Angebots",en:"Offer title"},nameLanguage:Fp},"unit.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Einheit",en:"Unit"}},"unit.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Einheit",en:"Unit name"},nameLanguage:Fp},"stage.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Klassenstufe (Schl\xFCssel)",en:"Grade (key)"},cohortBound:!0},"stage.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Klassenstufe",en:"Grade name"},cohortBound:!0,nameLanguage:Fp},"stage.gradeLevel":{valueSet:{kind:"open"},nullable:!0,absent:{de:"Die Stufe hat keine Klassenstufe (Kindergarten).",en:"The stage has no grade level (Kindergarten)."},label:{de:"Klassenstufe",en:"Grade level"},cohortBound:!0},"run.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Schuljahr",en:"School year"},cohortBound:!0},"run.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name des Schuljahrs",en:"School year name"},cohortBound:!0,nameLanguage:Fp},"run.startDate":{valueSet:{kind:"open"},nullable:!0,absent:{de:"F\xFCr das Schuljahr ist kein Beginn erfasst.",en:"The school year has no start date."},label:{de:"Beginn des Schuljahrs",en:"School year start"},cohortBound:!0},"applicant.language":{valueSet:gN(We,{de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}}),nullable:!0,absent:{de:"Die Bewerbung hat kein Bewerberkonto (intern angelegt).",en:"The application has no applicant account (started by staff)."},label:{de:"Bewerbersprache",en:"Applicant language"}},"applicant.channel":{valueSet:gN(ek,{staff:{de:"intern",en:"in-house"},"self-service":{de:"online (Familie)",en:"online (family)"}}),nullable:!1,label:{de:"Eingangsweg",en:"Intake channel"}}},Lp={types:yo,fields:Ei},Mp=pa.flatMap(e=>Object.keys(yo[e]).map(t=>`${e}.${t}`));function ur(e){return Object.hasOwn(Ei,e)}s(ur,"isEnvLeaf");function qp(e){return`${go}.${e}`}s(qp,"envIdentifier");function Xo(e){let t=Ei[e],[n,r]=e.split("."),i=yo[n][r];i===void 0&&L(`[env] leaf "${e}" has no type`);let o=t.valueSet;return{leaf:e,type:i,label:t.label,nullable:t.nullable,...t.absent===void 0?{}:{absent:t.absent},...t.nameLanguage===void 0?{}:{nameLanguage:t.nameLanguage},...t.cohortBound===void 0?{}:{cohortBound:t.cohortBound},...o.kind==="fixed"?{enumOptions:o.values.map(a=>{let l=o.labels[a];return l===void 0&&L(`[env] "${e}" names the value "${a}" without a label`),{value:a,label:l}})}:{}}}s(Xo,"envLeaf");var yN="staffInput";var _H=["boolean"],pd=/^[a-z][A-Za-z0-9]*$/;function Kp(e){return e.staffInputs??[]}s(Kp,"staffInputsOf");function jp(e){return`${yN}.${e}`}s(jp,"staffInputLeaf");function wN(e){return`${go}.${jp(e)}`}s(wN,"staffInputIdentifier");function NH(e){let t=`${yN}.`;return e.startsWith(t)?e.slice(t.length):null}s(NH,"staffInputKeyOfLeaf");function ma(e,t){let n=NH(t);return n===null?void 0:Kp(e).find(r=>r.key===n)}s(ma,"declaredStaffInput");function kN(e){return[...Kp(e).map(t=>({leaf:jp(t.key),type:t.type,label:t.label,valueSet:{kind:"open"},nullable:!1,cohortBound:!1})),...Mp.map(t=>{let n=Xo(t);return{leaf:t,type:n.type,label:n.label,valueSet:Ei[t].valueSet,nullable:n.nullable,cohortBound:n.cohortBound===!0}})]}s(kN,"envLeavesFor");function bN(e){return kN(e).filter(t=>!t.cohortBound)}s(bN,"conditionEnvLeaves");function vN(e){return SN(bN(e))}s(vN,"envConditionSchemaFor");function PH(e){return kN(e).map(t=>t.leaf==="stage.key"?{...t,valueSet:{kind:"open"}}:t)}s(PH,"offerConditionEnvLeaves");function xN(e){return SN(PH(e))}s(xN,"offerConditionSchemaFor");function SN(e){let t={},n={};for(let{leaf:r,type:i,valueSet:o,nullable:a}of e){let[l="",d=""]=r.split(".");t[l]={...t[l]??{},[d]:i},n[r]={valueSet:o,nullable:a}}return{types:t,fields:n}}s(SN,"schemaOfLeaves");function AN(e){let t=e.staffInputs;if(t===void 0)return[];if(!Array.isArray(t))return[{path:"staffInputs",reason:{de:"[staffInput/shape] graph.staffInputs muss eine Liste sein.",en:"[staffInput/shape] graph.staffInputs must be a list."}}];let n=[],r=new Set;return t.forEach((i,o)=>{let a=`staffInputs[${o}]`,l=i;if(l===null||typeof l!="object"||typeof l.key!="string"){n.push({path:a,reason:{de:"[staffInput/shape] Eine interne Angabe braucht key, type und label ({ de, en }).",en:"[staffInput/shape] An internal entry needs key, type and label ({ de, en })."}});return}let d={de:`Interne Angabe "${l.key}"`,en:`Internal entry "${l.key}"`};pd.test(l.key)||n.push({path:`${a}.key`,reason:{de:`[staffInput/keyFormat] ${d.de}: Schl\xFCssel beginnt mit einem Kleinbuchstaben und enth\xE4lt nur Buchstaben und Ziffern.`,en:`[staffInput/keyFormat] ${d.en}: the key starts with a lowercase letter and contains only letters and digits.`}}),r.has(l.key)&&n.push({path:`${a}.key`,reason:{de:`[staffInput/duplicateKey] ${d.de}: Schl\xFCssel ist doppelt vergeben.`,en:`[staffInput/duplicateKey] ${d.en}: the key is used twice.`}}),r.add(l.key),_H.includes(l.type)||n.push({path:`${a}.type`,reason:{de:`[staffInput/unknownType] ${d.de}: Typ "${String(l.type)}" \u2014 erlaubt ist nur "boolean" (K\xE4stchen).`,en:`[staffInput/unknownType] ${d.en}: type "${String(l.type)}" \u2014 only "boolean" (checkbox) is allowed.`}});let c=Ft(l.label);c==="not-localized"?n.push({path:`${a}.label`,reason:{de:`[staffInput/shape] ${d.de}: label muss { de, en } sein.`,en:`[staffInput/shape] ${d.en}: label must be { de, en }.`}}):c.length>0&&n.push({path:`${a}.label`,reason:{de:`[i18n/missingTranslation] ${d.de}: Beschriftung fehlt in ${c.join(", ")}.`,en:`[i18n/missingTranslation] ${d.en}: label is missing in ${c.join(", ")}.`}})}),n}s(AN,"staffInputIssues");function Lt(e,t){if(e instanceof $e)return new $e(t(e.message),{cause:e});if(e instanceof g)return new g(t(e.message),{cause:e});let n=dr(e);if(n!==null&&(n.message.de!==""||n.message.en!=="")){let r=e.data,i=typeof r=="string"?t(r):{...r,message:{de:n.message.de===""?"":t(n.message.de),en:n.message.en===""?"":t(n.message.en)}},o=new Dt(i);return o.cause=e,o}return new Error(t(Zl(e)),{cause:e})}s(Lt,"withContext");var uk={required:!0,description:"Offer slug (its offerKey)"},tk=class extends P{static{s(this,"ApplicationsListCommand")}static paths=[["applications","list"]];static usage=E.Usage({category:"Admission",description:"List an offer's applications (id, status, board state, applicant, test)"});offer=f.String("--offer",uk);testOnly=f.Boolean("--test-only",!1,{description:"Only test applications"});async execute(){let t=await this.caller(),n=await t.query(S.admission.listForAngebot,{client:this.requireTenant(t),offerKey:this.offer}),r=rN(n).filter(i=>!this.testOnly||i.test==="test");return this.print(r,i=>i,["id","status","state","applicant","test"]),0}},nk=class extends P{static{s(this,"ApplicationsCountsCommand")}static paths=[["applications","counts"]];static usage=E.Usage({category:"Admission",description:"Count an offer's applications per list"});offer=f.String("--offer",uk);async execute(){let t=await this.caller(),n=await t.query(S.admission.getCountsByListForAngebot,{client:this.requireTenant(t),offerKey:this.offer});return this.print(n,r=>[...Object.entries(r.counts).map(([i,o])=>({list:i,count:String(o)})),{list:"total",count:String(r.total)}],["list","count"]),0}},rk=class extends P{static{s(this,"ApplicationsShowCommand")}static paths=[["applications","show"]];static usage=E.Usage({category:"Admission",description:"One application: status, test flag, offer, current workflow nodes"});application=f.String({required:!0});async execute(){let t=await this.caller(),n=ee(this.application,"application"),r=await t.query(S.admission.get,{applicationId:n});if(r===null)throw new g(`applications show: no application ${n} (or not visible to you)`);let i=await t.query(S.workflow.getInstance,{applicationId:n});return this.print({application:r,currentNodes:i?.instance.currentNodeIds??[]},o=>[{key:"id",value:n},{key:"status",value:o.application.status},{key:"test",value:o.application.testMode?"ja":"nein"},{key:"offer",value:o.application.offerId},{key:"current nodes",value:o.currentNodes.join(", ")}]),0}},ik=class extends P{static{s(this,"ApplicationsStoreCommand")}static paths=[["applications","store"]];static usage=E.Usage({category:"Admission",description:"One application's process store: every address of its pinned graph, resolved (present / pending / absent)",details:"Staff only (applications.manage). --json prints one object keyed by the canonical address ($node\u2026, $task\u2026, $env\u2026). Values are shown whatever their audience \u2014 never hand the output to the family. Recipe: playbooks/applications/inspect-process-store.md."});application=f.String({required:!0});async execute(){let n=await(await this.caller()).query(S.processStoreView.get,{applicationId:ee(this.application,"application")});return this.print(oN(n),()=>sN(n),["address","state","holds","producer","written"]),0}},ok=class extends P{static{s(this,"ApplicationsStartTestCommand")}static paths=[["applications","start-test"]];static usage=E.Usage({category:"Admission",description:"Start a TEST application for an applicant (school year and level by key or id) and show what test mode offers next",details:"Always test mode. --applicant names the account by its login address (on prod only the tenant's test account); --party names the applicant party directly. Without --version it runs on the live generation, like the cockpit."});offer=f.String("--offer",uk);run=f.String("--run",{required:!0,description:"School year: its bundle key as offer export shows it (program.runs[].key) or id \u2014 never its name"});stage=f.String("--stage",{required:!0,description:"Level: its bundle key as offer export shows it (program.stages[].key) or id \u2014 never its name"});party=f.String("--party",{description:"Applicant party id"});applicant=f.String("--applicant",{description:"Applicant account login address (e.g. the test account test@example.com)"});version=f.String("--version",{description:"Offer version id to test (default: the live generation)"});staffInput=f.Array("--staff-input",{description:"A staff input the offer declares, as key=true|false \u2014 repeat it once per input; a staff start must set every one"});proxy=f.Boolean("--proxy",{description:"Start in Stellvertretung (--proxy) or not (--no-proxy); left out, the tenant's default applies, as in the cockpit"});async execute(){let t=await this.caller();iN(this.resolvedTarget(),this.prodUrls(),this.party,this.applicant);let n=this.requireTenant(t),r=nN(await t.query(S.admission.listAdmissionTree,{client:n}),this.offer,this.run,this.stage),i=this.party===void 0?void 0:ee(this.party,"party");if(this.applicant!==void 0){let d=await t.query(S.applicants.partyByEmail,{client:n,email:this.applicant});if(d===null)throw new g(`applications start-test: no applicant account ${this.applicant} at this school (create it in the cockpit first)`);i=d}let o=await t.mutation(S.admission.staffStartApplicationForParty,{client:n,offerKey:this.offer,partyId:i,programRunId:r.programRunId,programStageId:r.programStageId,...this.proxy===void 0?{}:{startInProxy:this.proxy},staffInputs:RN(this.staffInput??[]),testMode:!0,...this.version===void 0?{}:{offerVersionId:ee(this.version,"offer version")}}),a,l;try{let d=await t.query(S.workflow.getInstance,{applicationId:o.applicationId});if(d===null)throw new Error("the started application has no workflow instance");a=d.instance.currentNodeIds,l=(await Dp(t,o.applicationId,a)).flatMap(c=>c.actions.map(u=>u.id))}catch(d){throw Lt(d,c=>`applications start-test: started ${o.applicationId}, but reading its state failed: ${c}`)}return this.print({applicationId:o.applicationId,currentNodes:a,testActions:l},d=>[{key:"application",value:d.applicationId},{key:"current nodes",value:d.currentNodes.join(", ")},{key:"test actions",value:d.testActions.join(", ")},{key:"next",value:`test-actions run --application ${d.applicationId} --action <id>`}]),0}},sk=class extends P{static{s(this,"ApplicationsDiscardTestCommand")}static paths=[["applications","discard-test"]];static usage=E.Usage({category:"Admission",description:"Discard a TEST application (the server refuses a real one), or with --all-test every expired one of the school",details:"With an id: discards that test application. With --all-test --older-than <N>d: lists the school's test applications whose last activity is older than N days (N \u2265 14) and that are not kept as a demo \u2014 a dry run unless --confirm; --confirm discards each expired one the server re-checks, the rest are reported with the reason. Recipe: playbooks/applications/expire-test-applications.md.",examples:[["Dry run","plexus-cli --env prod --tenant <t> applications discard-test --all-test --older-than 14d --dry-run"],["Discard","plexus-cli --env prod --tenant <t> --allow-prod applications discard-test --all-test --older-than 14d --confirm"]]});application=f.String({required:!1});allTest=f.Boolean("--all-test",!1,{description:"Every expired test application of the school instead of one id"});olderThan=f.String("--older-than",{description:"With --all-test: days without activity, as <N>d (N \u2265 14)"});dryRun=f.Boolean("--dry-run",!1,{description:"With --all-test: list only (the default)"});confirm=f.Boolean("--confirm",!1,{description:"With --all-test: discard (else the dry run)"});async execute(){if(!this.allTest){if(this.application===void 0)throw new g("applications discard-test: name an application id, or use --all-test --older-than <N>d");if(this.olderThan!==void 0||this.dryRun||this.confirm)throw new g("applications discard-test: --older-than, --dry-run and --confirm belong to --all-test");return await(await this.caller()).mutation(S.admission.discardTest,{applicationId:ee(this.application,"application")}),this.print({discarded:this.application},u=>[{key:"discarded",value:u.discarded}]),0}if(this.application!==void 0)throw new g("applications discard-test: --all-test takes no application id");if(this.olderThan===void 0)throw new g("applications discard-test --all-test: --older-than <N>d is required");if(this.dryRun&&this.confirm)throw new g("applications discard-test: --dry-run and --confirm exclude each other");let t=CH(this.olderThan),n=await this.caller(),r=this.requireTenant(n),i=[],o=null;for(;;){let c=await n.query(S.admission.testTtlPlan,{client:r,olderThanDays:t,cursor:o});if(i.push(...c.rows),c.isDone)break;o=c.continueCursor}let a=i.map(c=>({...c,result:c.verdict!=="expired"?"kept":c.block!==null?"blocked":this.confirm?"pending":"would discard"})),l=i.filter(c=>c.verdict==="expired"&&c.protectedDemo).map(c=>c.applicationId);if(this.confirm&&l.length>0)throw new g(`applications discard-test --all-test: protected demo application(s) in the discard set, nothing discarded: ${l.join(", ")}`);let d=0;if(this.confirm)for(let c of a.filter(u=>u.result==="pending"))try{await n.mutation(S.admission.discardExpiredTest,{applicationId:c.applicationId,olderThanDays:t}),c.result="discarded"}catch(u){d++,c.result=`failed: ${u instanceof Error?u.message:String(u)}`}return this.print({olderThanDays:t,confirm:this.confirm,rows:a},c=>c.rows.map(u=>({id:u.applicationId,lastActivity:new Date(u.lastActivityAt).toISOString().slice(0,10),verdict:u.verdict,block:u.block??"",result:u.result})),["id","lastActivity","verdict","block","result"]),d>0?1:0}};function CH(e){let t=/^(\d+)d$/.exec(e.trim());if(t===null)throw new g(`--older-than "${e}": expected <N>d, e.g. 14d`);return Number(t[1])}s(CH,"parseDays");var ak=class extends P{static{s(this,"ApplicationsSetKeepDemoCommand")}static paths=[["applications","set-keep-demo"]];static usage=E.Usage({category:"Admission",description:"Mark a TEST application \u201EDemo behalten\u201C (never expires, never discarded), or clear the mark with --off"});application=f.String({required:!0});off=f.Boolean("--off",!1,{description:"Clear the mark"});async execute(){return await(await this.caller()).mutation(S.admission.setKeepAsDemo,{applicationId:ee(this.application,"application"),keep:!this.off}),this.print({application:this.application,keepAsDemo:!this.off},n=>[{key:"application",value:n.application},{key:"keep as demo",value:n.keepAsDemo?"ja":"nein"}]),0}},lk=class extends P{static{s(this,"ApplicationsStaffInputListCommand")}static paths=[["applications","staff-input","list"]];static usage=E.Usage({category:"Admission",description:"An application's internal inputs (set at the start): value, and why one can no longer be corrected"});application=f.String({required:!0});async execute(){let n=await(await this.caller()).query(S.admission.staffInputsOfApplication,{applicationId:ee(this.application,"application")});return this.print(n,r=>r.map(i=>({key:i.key,label:i.label.de,value:String(i.value),correctable:i.block===null?"ja":i.block.de})),["key","label","value","correctable"]),0}},dk=class extends P{static{s(this,"ApplicationsStaffInputSetCommand")}static paths=[["applications","staff-input","set"]];static usage=E.Usage({category:"Admission",description:"Correct one internal input of an application, with a reason \u2014 refused once a node that reads it was entered",examples:[["Untick \u201EKind von Mitarbeitenden\u201C",'plexus-cli --env prod --tenant <t> --allow-prod applications staff-input set <id> --input staffApplication=false --reason "falsch angehakt"']]});application=f.String({required:!0});input=f.String("--input",{required:!0,description:"key=true|false"});reason=f.String("--reason",{required:!0,description:"Why \u2014 recorded on the application's activity feed"});async execute(){let t=await this.caller(),[{key:n,value:r}]=RN([this.input]);return await t.mutation(S.admission.correctStaffInput,{applicationId:ee(this.application,"application"),key:n,value:r,reason:this.reason}),this.print({application:this.application,key:n,value:r},i=>[{key:"application",value:i.application},{key:i.key,value:String(i.value)}]),0}},ck=class extends P{static{s(this,"ApplicationsPurgeCommand")}static paths=[["platform","applications","purge"]];static usage=E.Usage({category:"Admission",description:"Hard-delete one real application staff started for a colleague and already deleted (plan unless --confirm). Needs _platform.config.manage.",details:"Refused unless all hold: a real application (a test one goes with `applications discard-test`), soft-deleted by staff, started by staff, its applicant an internal staff member of the school (also a switched-off one) whose person existed before, no data about anyone else (only empty drafts the form opened), nothing committed yet, and no contract, signing process, payment or Engage push. Deletes the application and every row it created; the staff member's person stays. Afterwards the responsible person can be deactivated.",examples:[["Plan","plexus-cli --env prod --tenant <slug> platform applications purge <applicationId>"],["Apply","plexus-cli --env prod --tenant <slug> --allow-prod platform applications purge <applicationId> --confirm"]]});application=f.String({required:!0});confirm=f.Boolean("--confirm",!1,{description:"Delete for good (without it, only the checks run)."});async execute(){let t=await this.caller(),n=await t.mutation(S.admission.purgeDeletedStaffApplication,{tenantSlug:this.requireTenant(t),applicationId:ee(this.application,"application"),dryRun:!this.confirm});if(this.json)return this.print(n),0;let r=this.context.stdout;return r.write(`${n.applied?"Deleted":"Would delete"} application ${n.applicationId} `),r.write(`(applicant ${n.applicantPartyId}, soft-deleted ${new Date(n.deletedAt).toISOString()})
11507
11586
  `),n.applicantGone&&r.write(`The applicant's party no longer exists \u2014 the staff check was not run.
11508
11587
  `),n.applied?(r.write(`Rows deleted: ${n.deleted}${n.continuing?" so far \u2014 the purge goes on in scheduled steps":""}
11509
11588
  `),0):(r.write(`Dry run \u2014 every check passed; re-run with --confirm to delete.
@@ -12033,7 +12112,7 @@ ${n.length} unusable ${o}:
12033
12112
  `),r.length>0&&this.context.stdout.write(` ${r.length} linkable \u2014 plexus-cli platform users relink-auth <email>
12034
12113
  `),i.length>0&&this.context.stdout.write(` ${i.length} without any login account \u2014 plexus-cli platform users provision --tenant <slug> --email <email> --name <name>
12035
12114
  `)}else this.context.stdout.write(`No unusable identities.
12036
- `);return n.length>0?1:0}},WE=class extends Er{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=E.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=f.String({required:!0});async execute(){let n=await(await this.caller()).mutation(S.platformAdmin.relinkAuthAccount,{email:this.email}),r=n.changed?`Relinked ${this.email} to live auth account ${n.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(n,r),0}};function dW(e,t){if(e===t)throw new g("Pass exactly one of --on or --off.");return e}s(dW,"requireOnOff");var cW=[OE,_E,NE,PE,CE,DE,FE,LE,ME,qE,mf,KE,jE,VE,BE,UE,GE,zE,WE];function uW(e){return e.de??e.en??Object.values(e)[0]??""}s(uW,"titleDe");function Hte(e){return{id:e._id,kind:e.kind,status:e.status,title:uW(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(Hte,"row");var Jte=["id","kind","status","title","assignee","group","outcome"],JE=class extends P{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=E.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=f.Boolean("--mine",!1,{description:"Only items assigned to me."});application=f.String("--application",{description:"Filter by application id."});group=f.String("--group",{description:"Filter by team (permission-group) id."});assignee=f.String("--assignee",{description:"Filter by assignee users._id."});openOnly=f.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.list,{client:n,...this.mine?{mine:!0}:{},...this.application?{applicationId:ee(this.application,"application")}:{},...this.group?{queueGroupId:ee(this.group,"permission group")}:{},...this.assignee?{assigneeUserId:ee(this.assignee,"user")}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(Hte),Jte),0}},QE=class extends P{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=E.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.get,{client:n,workItemId:ee(this.workItemId,"work item")});if(r===null)throw new g(`work-item ${this.workItemId} not found in tenant ${n}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:uW(i.title)},{field:"assignee",value:i.assigneeUserId??""},{field:"group",value:i.queueGroupId??""},{field:"application",value:i.applicationId??""},{field:"node",value:i.nodeId??""},{field:"outcome",value:i.outcome??""}]),0}},ZE=class extends P{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=E.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=f.String("--title",{required:!0,description:"Task title."});description=f.String("--description",{description:"Task description."});application=f.String("--application",{description:"Link to an application id."});group=f.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=f.String("--assignee",{description:"Assignee users._id."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.createManual,{client:n,title:this.title,...this.description?{description:this.description}:{},...this.application?{applicationId:ee(this.application,"application")}:{},...this.group?{queueGroupId:ee(this.group,"permission group")}:{},...this.assignee?{assigneeUserId:ee(this.assignee,"user")}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},XE=class extends P{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=E.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=f.String({required:!0,name:"workItemId"});outcome=f.String("--outcome",{description:"Outcome id to record."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.complete,{client:n,workItemId:ee(this.workItemId,"work item"),...this.outcome?{outcome:this.outcome}:{}});return this.print({workItemId:r.workItemId,status:"done"},i=>[{field:"workItemId",value:i.workItemId},{field:"status",value:i.status}]),0}},eI=class extends P{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=E.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=f.String({required:!0,name:"workItemId"});user=f.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.assign,{client:n,workItemId:ee(this.workItemId,"work item"),...this.user?{userId:ee(this.user,"user")}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},fW=[JE,QE,ZE,XE,eI];var _l=[...H_,...xM,..._M,...Kq,...Uq,...qq,...gK,...SK,...xK,...aW,...cW,...sW,...jG,...WG,...ZG,...rM,...fK,...Yz,...z_,...TN,...V0,...RK,...TK,...IK,...NK,...cK,...Jq,...fW,...ZB,...jU,...qG,...VU,...Nz,...qz,...XG,...lz,...uz,...hz,...yz,...Vz,...Xz,...hN];for(let e of _l){let t=e.paths?.[0];t===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:lO(e.usage.category,t.join(" "))})}var pW="0.1.366";function tI(){return _l.flatMap(e=>(e.paths??[]).map(t=>{let n=t.join(" "),r=iO[Wo(n)];return{path:n,effect:Ai(n),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,t)=>e.path.localeCompare(t.path))}s(tI,"plexusCommandCatalog");import Gs from"node:path";function Qte(e){let t=gt()?.workspaceRoot??process.cwd(),n=Gs.resolve(t,e),r=Gs.relative(t,n);if(Gs.isAbsolute(e)||r===".."||r.startsWith(`..${Gs.sep}`))throw new g("plexus: use a relative path inside the current workspace.");return{absolute:n,relative:r}}s(Qte,"workspacePath");function Zte(e){let{absolute:t,relative:n}=Qte(e.path??".");if(e.operation==="list"){if(!Re(t))return{files:[]};let r=[],i=s(o=>{for(let a of Hr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new g("plexus: workspace symlinks are not supported.");let l=Gs.join(o,a.name);if(a.isDirectory()?i(l):r.push(Gs.relative(t,l)),r.length>200)throw new g("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(t),{files:r.sort()}}if(!n)throw new g("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=Ne(t);if(r.length>10*1024*1024)throw new g("plexus: the workspace file exceeds 10 MB.");let i=new TextDecoder("utf-8",{fatal:!0}).decode(r);if(e.operation==="read"){let l=e.offset??0,d=e.maxChars??8e3,c=i.slice(l,l+d);return{path:n,content:c,...l||c.length<i.length?{offset:l,nextOffset:l+c.length<i.length?l+c.length:null,totalCharacters:i.length}:{}}}if(e.operation==="search"){if(!e.query)throw new g("plexus: search needs a nonempty query.");let l=[],d=e.offset??0;for(;l.length<10;){let c=i.indexOf(e.query,d);if(c<0)break;l.push({offset:c,text:i.slice(Math.max(0,c-160),c+e.query.length+240)}),d=c+e.query.length}return{path:n,matches:l,nextOffset:l.length===10?d:null}}if(!e.oldText||typeof e.content!="string")throw new g("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new g("plexus: oldText must match exactly once. Read the current file and choose unique context.");let a=i.slice(0,o)+e.content+i.slice(o+e.oldText.length);if(Buffer.byteLength(a)>10*1024*1024)throw new g("plexus: the edited file exceeds 10 MB.");return Ze(t,a,"utf8"),{path:n,sizeBytes:Buffer.byteLength(a)}}if(e.operation==="write"){if(typeof e.content!="string"||Buffer.byteLength(e.content)>1e6)throw new g("plexus: file content is missing or too large.");return Gt(Gs.dirname(t),{recursive:!0}),Ze(t,e.content,"utf8"),{path:n,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return Hs(t),{path:n,removed:!0};throw new g("plexus: unknown workspace operation.")}s(Zte,"plexusWorkspace");function mW(e){return s(async function(n,r){if(!r||typeof r!="object"||Array.isArray(r))throw new g("plexus: tool input must be an object.");let i=r,o=ud[n];if(!o||!Object.hasOwn(ud,n))throw new g("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new g("plexus: unexpected tool argument.");if(n==="plexus"){if(!Array.isArray(i.argv)||i.argv.some(a=>typeof a!="string")||i.stdin!==void 0&&typeof i.stdin!="string")throw new g("plexus: invalid command input.");return e.inspectCommand(i.argv),e.executeCommand({argv:i.argv,...i.stdin===void 0?{}:{stdin:i.stdin}})}if(n==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(Bw,i.path))throw new g("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:Bw[i.path],skillHash:Tp}}if(typeof i.operation!="string"||!["list","read","search","edit","write","remove"].includes(i.operation)||i.path!==void 0&&(typeof i.path!="string"||i.path.length>500)||i.content!==void 0&&(typeof i.content!="string"||i.content.length>1e6)||i.oldText!==void 0&&(typeof i.oldText!="string"||i.oldText.length>1e6)||i.query!==void 0&&(typeof i.query!="string"||!i.query.length||i.query.length>1e3)||i.offset!==void 0&&(typeof i.offset!="number"||!Number.isSafeInteger(i.offset)||i.offset<0)||i.maxChars!==void 0&&(typeof i.maxChars!="number"||!Number.isSafeInteger(i.maxChars)||i.maxChars<1||i.maxChars>24e3))throw new g("plexus: invalid workspace input.");return Zte(i)},"executePlexusAgentTool")}s(mW,"createPlexusAgentToolExecutor");var Xte=["--env","--tenant"];function hW(e){let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i==="--"){t.push(...e.slice(r));break}let o=Xte.find(l=>i===l||i.startsWith(`${l}=`)),a=e[r+1];o===void 0?t.push(i):i!==o?n.push({name:o,value:i.slice(o.length+1)}):a!==void 0&&!a.startsWith("-")?(n.push({name:o,value:a}),r++):t.push(i)}return{rest:t,given:n}}s(hW,"splitGlobalOptions");function gW(e,t){let n=nw(e)==="offline";if(n&&Ai(e)==="read")return t.map(i=>`plexus-cli: ${i.name} ${i.value} has no effect: \`${e}\` runs offline (this CLI's own files, no deployment).
12115
+ `);return n.length>0?1:0}},WE=class extends Er{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=E.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=f.String({required:!0});async execute(){let n=await(await this.caller()).mutation(S.platformAdmin.relinkAuthAccount,{email:this.email}),r=n.changed?`Relinked ${this.email} to live auth account ${n.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(n,r),0}};function dW(e,t){if(e===t)throw new g("Pass exactly one of --on or --off.");return e}s(dW,"requireOnOff");var cW=[OE,_E,NE,PE,CE,DE,FE,LE,ME,qE,mf,KE,jE,VE,BE,UE,GE,zE,WE];function uW(e){return e.de??e.en??Object.values(e)[0]??""}s(uW,"titleDe");function Hte(e){return{id:e._id,kind:e.kind,status:e.status,title:uW(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(Hte,"row");var Jte=["id","kind","status","title","assignee","group","outcome"],JE=class extends P{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=E.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=f.Boolean("--mine",!1,{description:"Only items assigned to me."});application=f.String("--application",{description:"Filter by application id."});group=f.String("--group",{description:"Filter by team (permission-group) id."});assignee=f.String("--assignee",{description:"Filter by assignee users._id."});openOnly=f.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.list,{client:n,...this.mine?{mine:!0}:{},...this.application?{applicationId:ee(this.application,"application")}:{},...this.group?{queueGroupId:ee(this.group,"permission group")}:{},...this.assignee?{assigneeUserId:ee(this.assignee,"user")}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(Hte),Jte),0}},QE=class extends P{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=E.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.get,{client:n,workItemId:ee(this.workItemId,"work item")});if(r===null)throw new g(`work-item ${this.workItemId} not found in tenant ${n}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:uW(i.title)},{field:"assignee",value:i.assigneeUserId??""},{field:"group",value:i.queueGroupId??""},{field:"application",value:i.applicationId??""},{field:"node",value:i.nodeId??""},{field:"outcome",value:i.outcome??""}]),0}},ZE=class extends P{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=E.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=f.String("--title",{required:!0,description:"Task title."});description=f.String("--description",{description:"Task description."});application=f.String("--application",{description:"Link to an application id."});group=f.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=f.String("--assignee",{description:"Assignee users._id."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.createManual,{client:n,title:this.title,...this.description?{description:this.description}:{},...this.application?{applicationId:ee(this.application,"application")}:{},...this.group?{queueGroupId:ee(this.group,"permission group")}:{},...this.assignee?{assigneeUserId:ee(this.assignee,"user")}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},XE=class extends P{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=E.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=f.String({required:!0,name:"workItemId"});outcome=f.String("--outcome",{description:"Outcome id to record."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.complete,{client:n,workItemId:ee(this.workItemId,"work item"),...this.outcome?{outcome:this.outcome}:{}});return this.print({workItemId:r.workItemId,status:"done"},i=>[{field:"workItemId",value:i.workItemId},{field:"status",value:i.status}]),0}},eI=class extends P{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=E.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=f.String({required:!0,name:"workItemId"});user=f.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.assign,{client:n,workItemId:ee(this.workItemId,"work item"),...this.user?{userId:ee(this.user,"user")}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},fW=[JE,QE,ZE,XE,eI];var _l=[...H_,...xM,..._M,...Kq,...Uq,...qq,...gK,...SK,...xK,...aW,...cW,...sW,...jG,...WG,...ZG,...rM,...fK,...Yz,...z_,...TN,...V0,...RK,...TK,...IK,...NK,...cK,...Jq,...fW,...ZB,...jU,...qG,...VU,...Nz,...qz,...XG,...lz,...uz,...hz,...yz,...Vz,...Xz,...hN];for(let e of _l){let t=e.paths?.[0];t===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:lO(e.usage.category,t.join(" "))})}var pW="0.1.367";function tI(){return _l.flatMap(e=>(e.paths??[]).map(t=>{let n=t.join(" "),r=iO[Wo(n)];return{path:n,effect:Ai(n),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,t)=>e.path.localeCompare(t.path))}s(tI,"plexusCommandCatalog");import Gs from"node:path";function Qte(e){let t=gt()?.workspaceRoot??process.cwd(),n=Gs.resolve(t,e),r=Gs.relative(t,n);if(Gs.isAbsolute(e)||r===".."||r.startsWith(`..${Gs.sep}`))throw new g("plexus: use a relative path inside the current workspace.");return{absolute:n,relative:r}}s(Qte,"workspacePath");function Zte(e){let{absolute:t,relative:n}=Qte(e.path??".");if(e.operation==="list"){if(!Re(t))return{files:[]};let r=[],i=s(o=>{for(let a of Hr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new g("plexus: workspace symlinks are not supported.");let l=Gs.join(o,a.name);if(a.isDirectory()?i(l):r.push(Gs.relative(t,l)),r.length>200)throw new g("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(t),{files:r.sort()}}if(!n)throw new g("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=Ne(t);if(r.length>10*1024*1024)throw new g("plexus: the workspace file exceeds 10 MB.");let i=new TextDecoder("utf-8",{fatal:!0}).decode(r);if(e.operation==="read"){let l=e.offset??0,d=e.maxChars??8e3,c=i.slice(l,l+d);return{path:n,content:c,...l||c.length<i.length?{offset:l,nextOffset:l+c.length<i.length?l+c.length:null,totalCharacters:i.length}:{}}}if(e.operation==="search"){if(!e.query)throw new g("plexus: search needs a nonempty query.");let l=[],d=e.offset??0;for(;l.length<10;){let c=i.indexOf(e.query,d);if(c<0)break;l.push({offset:c,text:i.slice(Math.max(0,c-160),c+e.query.length+240)}),d=c+e.query.length}return{path:n,matches:l,nextOffset:l.length===10?d:null}}if(!e.oldText||typeof e.content!="string")throw new g("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new g("plexus: oldText must match exactly once. Read the current file and choose unique context.");let a=i.slice(0,o)+e.content+i.slice(o+e.oldText.length);if(Buffer.byteLength(a)>10*1024*1024)throw new g("plexus: the edited file exceeds 10 MB.");return Ze(t,a,"utf8"),{path:n,sizeBytes:Buffer.byteLength(a)}}if(e.operation==="write"){if(typeof e.content!="string"||Buffer.byteLength(e.content)>1e6)throw new g("plexus: file content is missing or too large.");return Gt(Gs.dirname(t),{recursive:!0}),Ze(t,e.content,"utf8"),{path:n,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return Hs(t),{path:n,removed:!0};throw new g("plexus: unknown workspace operation.")}s(Zte,"plexusWorkspace");function mW(e){return s(async function(n,r){if(!r||typeof r!="object"||Array.isArray(r))throw new g("plexus: tool input must be an object.");let i=r,o=ud[n];if(!o||!Object.hasOwn(ud,n))throw new g("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new g("plexus: unexpected tool argument.");if(n==="plexus"){if(!Array.isArray(i.argv)||i.argv.some(a=>typeof a!="string")||i.stdin!==void 0&&typeof i.stdin!="string")throw new g("plexus: invalid command input.");return e.inspectCommand(i.argv),e.executeCommand({argv:i.argv,...i.stdin===void 0?{}:{stdin:i.stdin}})}if(n==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(Bw,i.path))throw new g("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:Bw[i.path],skillHash:Tp}}if(typeof i.operation!="string"||!["list","read","search","edit","write","remove"].includes(i.operation)||i.path!==void 0&&(typeof i.path!="string"||i.path.length>500)||i.content!==void 0&&(typeof i.content!="string"||i.content.length>1e6)||i.oldText!==void 0&&(typeof i.oldText!="string"||i.oldText.length>1e6)||i.query!==void 0&&(typeof i.query!="string"||!i.query.length||i.query.length>1e3)||i.offset!==void 0&&(typeof i.offset!="number"||!Number.isSafeInteger(i.offset)||i.offset<0)||i.maxChars!==void 0&&(typeof i.maxChars!="number"||!Number.isSafeInteger(i.maxChars)||i.maxChars<1||i.maxChars>24e3))throw new g("plexus: invalid workspace input.");return Zte(i)},"executePlexusAgentTool")}s(mW,"createPlexusAgentToolExecutor");var Xte=["--env","--tenant"];function hW(e){let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i==="--"){t.push(...e.slice(r));break}let o=Xte.find(l=>i===l||i.startsWith(`${l}=`)),a=e[r+1];o===void 0?t.push(i):i!==o?n.push({name:o,value:i.slice(o.length+1)}):a!==void 0&&!a.startsWith("-")?(n.push({name:o,value:a}),r++):t.push(i)}return{rest:t,given:n}}s(hW,"splitGlobalOptions");function gW(e,t){let n=nw(e)==="offline";if(n&&Ai(e)==="read")return t.map(i=>`plexus-cli: ${i.name} ${i.value} has no effect: \`${e}\` runs offline (this CLI's own files, no deployment).
12037
12116
  `);let r=[...new Set(t.map(i=>i.name))].join(", ");throw new g(n?`\`${e}\` does not take ${r}: it never targets a chosen deployment \u2014 drop the option.`:`\`${e}\` does not take ${r}.`)}s(gW,"globalOptionNotes");var $y=mW({inspectCommand:wW,executeCommand:kW});function Ey(){let e=new Xs({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:pW});e.register(Bl.HelpCommand),e.register(Bl.VersionCommand);for(let r of _l)e.register(r);function t(r,i){try{return{command:e.process(r,i),notes:[]}}catch(o){let{rest:a,given:l}=hW(r);if(l.length===0)throw o;let d;try{d=e.process(a,i)}catch{throw o}if(!_l.some(u=>d instanceof u))return{command:d,notes:[]};let c=d.path.join(" ");if(!tI().some(u=>u.path===c))throw o;return{command:d,notes:gW(c,l)}}}s(t,"resolve");async function n(r,i){let o=i.stderr??process.stderr,a;try{a=t(r,i)}catch(l){return o.write(e.error(l,{colored:!1})),2}for(let l of a.notes)o.write(l);return nne(a.command,o),e.run(a.command,i)}return s(n,"run"),{process(r,i){return t(r,i).command},run:n,async runExit(r,i){process.exitCode=await n(r,i)}}}s(Ey,"createPlexusCli");function nne(e,t){let n=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&n!==r&&Jl[n]===r&&pt(t,n,r),n in Jl&&Ai(n)==="confirm"&&!Ql(e)&&t.write(`plexus-cli: \`${Jl[n]}\` only prints its plan without --confirm \u2014 nothing was changed.
12038
12117
  `)}s(nne,"noteRetiredPath");function wW(e){let t=Ey().process(Cl(e),{executePlexusAgentTool:$y}),n=t.path.join(" ");if(n.startsWith("agent "))throw new Error("plexus: nested agent transports are not allowed.");let r=tI().find(d=>d.path===n);if(!r){if(n===""||n==="--help"||n==="--version")return{path:n,writes:!1,host:"shared"};throw new Error(`plexus: command ${n} has no host classification.`)}let i="fn"in t&&typeof t.fn=="string"?t.fn:"",o="kind"in t&&typeof t.kind=="string"?t.kind:void 0,a=r.effect==="callKind"?Mh(fl(pl),i,o):void 0,l=Yf(n,{confirm:Ql(t),callKind:a});return{...r,writes:l}}s(wW,"inspectPlexusCommand");async function kW(e,t){if(t)return lI(t,()=>kW(e));if(!Array.isArray(e.argv)||e.argv.length===0||e.argv.length>128||e.argv.some(l=>typeof l!="string"||l.length>128e3)||(e.stdin?.length??0)>1e6)throw new Error("plexus: invalid command invocation.");let n="",r="",i=Ey();if(gt()){let l=wW(e.argv);if(l.host==="terminal")throw new Error(`plexus: this command requires a local machine. ${l.reason??""}`)}return{exitCode:await i.run(Cl(e.argv),{executePlexusAgentTool:$y,stdin:tne.from(e.stdin===void 0?[]:[e.stdin]),stdout:new yW({write(l,d,c){n+=String(l),c()}}),stderr:new yW({write(l,d,c){r+=String(l),c()}})}),stdout:n,stderr:r}}s(kW,"executePlexusCommand");sI();pI({source:rne.join(import.meta.dirname,"skill")});Ey().runExit(Cl(process.argv.slice(2)),{executePlexusAgentTool:$y});
12039
12118
  //# sourceMappingURL=cli.mjs.map