Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

docs: state that the system-stage registry is the curated protected set, not every literal-key stage (#3314)

[._.]/ Adam Eivyc9b686081e71
diff --git a/server/lib/README.md b/server/lib/README.md
index 6e356cd346..4b1289c957 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -97,7 +97,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `tuiHandshake.js` | Shared TUI invocation + paste-handshake constants. |
| `tuiUsageScrape.js` | `scrapeTuiUsage({ command, slashCommand, … })` + `USAGE_SANDBOX_DIR` — drive an agy/grok TUI in a sandbox PTY, send a slash command, return the ANSI-stripped screen (for quota panels `--print` can't reach). |
| `stageRunner.js` | Shared staged-LLM runner. |
-| `promptSystemStages.js` | Single source of truth for the prompt stages PortOS features resolve by literal key — `SYSTEM_STAGE_USAGE` (`key -> usedBy[]` feature-name copy), the derived `SYSTEM_STAGE_KEYS`, `isSystemStage(key)`, `systemStageUsedBy(key)`. Read by `GET /api/prompts` (ships the key list to the client), `GET /api/prompts/:stage/usage`, and the `DELETE /api/prompts/:stage` force-guard. Adding a feature that names a stage by literal key means adding a row here. |
+| `promptSystemStages.js` | Single source of truth for the prompt stages PortOS features resolve by literal key — `SYSTEM_STAGE_USAGE` (`key -> usedBy[]` feature-name copy), the derived `SYSTEM_STAGE_KEYS`, `isSystemStage(key)`, `systemStageUsedBy(key)`. Read by `GET /api/prompts` (ships the key list to the client), `GET /api/prompts/:stage/usage`, and the `DELETE /api/prompts/:stage` force-guard. The CURATED protected set (CoS / Brain / Memory / app-detection), not an index of every literal-key call site — adding a row means "protect this stage from deletion and badge it SYSTEM". |
| `promptTemplate.js` | Mustache-flavored, dot-notation-aware prompt template engine. |
| `promptPartials.js` | Mustache-style partial expansion. |
| `mediaModels.js` | Single source of truth for image/video model metadata. |
diff --git a/server/lib/promptSystemStages.js b/server/lib/promptSystemStages.js
index b76bbb4fde..f7076fb9b5 100644
--- a/server/lib/promptSystemStages.js
+++ b/server/lib/promptSystemStages.js
@@ -2,12 +2,21 @@
* The prompt stages PortOS features call by name — the single source of truth
* for "which stage keys are system stages" (#3314).
*
- * These are the stages a feature resolves by literal key (`getStage('cos-evaluate')`,
- * `runStage('brain-classifier')`, …) rather than ones the user authored in the
+ * These stages are resolved by literal key (`getStage('cos-evaluate')`,
+ * `runStage('brain-classifier')`, …) rather than authored by the user in the
* Prompt Manager. Deleting one silently breaks the feature that names it, so
* `DELETE /api/prompts/:stage` refuses without `?force=true`, and the Prompt
* Manager badges + filters them.
*
+ * SCOPE: this is the CURATED protected set — the CoS / Brain / Memory /
+ * app-detection stages the delete guard has always covered — not an exhaustive
+ * index of every literal-key call site. Plenty of shipped stages are resolved
+ * by literal key too (`pipeline-series-concept-judge`, `catalog-ideas-scenes-concepts`,
+ * …) and are deliberately NOT here: force-guarding and badging ~100 pipeline
+ * stages is a product decision, not a refactor, and is tracked separately.
+ * Adding a row here means "this stage is now protected from deletion and
+ * badged SYSTEM", which is a deliberate choice per stage.
+ *
* The map was previously restated three times — the usage handler's
* `key -> usedBy[]` table, the DELETE guard's bare key array, and a client-side
* `SYSTEM_STAGE_KEYS` mirror in `client/src/lib/promptStageGroups.js`. The