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(changelog): note the commission pin fire-time guard

Adam Eivyc5d89e6ba6ec
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index aefc953392..ab63c8b412 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -155,5 +155,5 @@
- **Fix Element Flash: pressing Enter/Return after answering now advances to the next question.** In the Element Flash recall test (`ElementsSong.jsx`), the Enter-to-submit handler lived only on the answer `<input>`, which unmounts once the result is shown — so a second Enter did nothing and the user had to click "Next" to continue. `ElementFlashMode` now binds a window `keydown` listener while a result is showing (input unmounted) that advances on Enter/Return, mirroring the "Next" button; the `next()` handler was hoisted above the completion early-return so the effect can reference it without breaking hook order. The listener ignores auto-repeat (`e.repeat`) and any Enter that a focused control or open overlay already owns (`e.target.closest('button, a, input, textarea, select, [role="dialog"], [role="menu"], [contenteditable]')`) — so a keyboard user tabbed to the Back/Next button doesn't double-advance, and an Enter meant for the command palette doesn't leak through to the quiz. Tests drive answer → Enter (submit) → Enter (advance) asserting the counter increments, and pin that an Enter fired from the focused Next button is not hijacked by the window listener.
- **[issue-2657] Autonomous Creation Engine (Phase 1) — schedule the Creative Director with a recurring, feedback-ready creative brief.** New first-class `CreativeCommission` entity: a standing brief (`{ name, enabled, targetAbility, brief, schedule, generation }`) that fires on a cron cadence and drives the existing Creative Director *directive* pipeline unattended — "every night at 2am, make me something surreal." Commissions are `db-primary` (per `docs/STORAGE.md`): one row per commission in the machine-local `creative_commissions` PostgreSQL table (full record in `data` JSONB, adapter `server/services/creativeCommissions/db.js`, selected pg-vs-file exactly like universeBuilder so a `NODE_ENV=test`/`MEMORY_BACKEND=file` install keeps a file escape hatch). No `sync_sequence`/tombstone — deletes are hard deletes, mirroring `tribe`. They are deliberately **not** federated in Phase 1 — the same rationale as `seriesAutopilotScheduler`'s settings-based schedules, since a schedule that synced across peers would double-run on every machine (federation with a per-peer "home" gate is Phase 2). A new `commissionScheduler.js` (modeled on `seriesAutopilotScheduler`) arms one `eventScheduler` cron per enabled commission; on fire it re-reads the commission + creative-autonomy config, builds a CD directive from the brief via the pure `buildCommissionDirective` (which already folds a last-N feedback digest so Phase 2 only needs the rate surface), mints a directive-driven CD video project, and nudges `advanceAfterPlanStepSettled` so each plan step runs through the gated `dispatchCreativeTool`. Cold-bootstrap compliant per the AI Provider Usage Policy: boot only *arms* crons (nothing fires until a cadence elapses), and every fire gates on creative autonomy `execute` **and** the daily `cos` budget before spawning anything — an `off`/`dry-run` or over-budget install records a `skipped` run and generates nothing. Full REST CRUD at `/api/creative-commission` (Zod-validated create/update, DAILY/WEEKLY/CUSTOM schedules composed to cron with an authoritative `isValidCron` check in the service, `generation` schema with no object-level default so an empty PATCH still 400s the "at least one field" refine), a scheduler re-sync after every mutation, and a new `/creative-commission` Create-suite page: list + deep-linked create/edit Drawer (`/creative-commission/:id`, `/new`) with pause/resume, inline-confirm delete, and per-run history — registered in `NAV_COMMANDS` (⌘K + voice) and the sidebar. Phase 1 restricts `targetAbility` to `video` (the enum widens with the ability adapter in Phase 3/4) so a user can't create a commission that silently never runs. Refs #2657 — Phases 2–5 (feedback loop, all-ability adapter, music tool, genre taxonomy) remain. New unit + route + PG-adapter tests cover cron composition, the feedback digest, the store CRUD/sanitizer, the autonomy/budget gates, the no-boot-generation guarantee, the route contract, and the `creative_commissions` row round-trip (verbatim readback / upsert with created_at preserved / list order / hard delete). Scheduler-vs-request writes serialize on the facade's shared per-id write queue (`createRecordWriteQueue`), identical to universeBuilder/storyBuilder.
- **[issue-2657] Autonomous Creation Engine (Phase 2) — the taste feedback loop closes.** Each commission run's output is now rateable, and your reactions steer the next run. A new per-run **rate/annotate control** in the Creative Commissions run history (👍/👎 + an optional note like "less horror, more Magritte", keyboard-accessible, mobile-responsive, reactive) records a `CommissionFeedback` reaction against that specific run; the next scheduled fire's `buildCommissionDirective` folds the last **N** reactions (a configurable **feedback window**, now editable in the drawer — 0 disables conditioning) into the directive's goal as a "Recent likes / Recent dislikes — steer toward the likes, away from the dislikes" digest, so the run visibly drifts toward what you actually like (the digest shows up in the run's `promptUsed`). Feedback lives inline on the commission record — Phase 1 reserved `feedback[]` for exactly this, so no schema/table change was needed; reactions are deep-sanitized (a 👍/👎 or non-zero score is required, numeric ratings preserved verbatim, capped at 100) and **upserted by run** (re-rating a run replaces its prior reaction rather than stacking a contradictory second one) on the same shared per-id write queue as run-recording so a rating submitted mid-fire can't clobber a run append. The composed directive goal is length-clamped (per-note + overall) so a large feedback window can't push it past the Creative Director's 5000-char goal limit on the scheduler path (which skips the route's input validation). New `POST /api/creative-commission/:id/feedback` (Zod-validated `commissionFeedbackSchema` — `runId` required and verified against the record's runs, a zero rating rejected as meaningless, → 400/404 on bad input/unknown id) returns the full updated commission for reactive state; the edit drawer preserves unsaved field edits when a rating lands (the form re-syncs only on a genuine target change, not on every in-place record update). When a commission fires it also **surfaces** the run as a low-priority, machine-local notification (new `creative_commission` type, deep-linked to the commission) worded to reflect that the piece is *being created* — "rate the result once it lands." Surfacing stays notification-only for now: the brain inbox is federated (`inbox` ∈ `BRAIN_ENTITY_TYPES`), so a reminder there would propagate a peer-useless `needs_review` item pointing at a machine-local commission — brain-inbox surfacing (and completion-triggered surfacing) rejoin once commissions themselves federate. Commissions stay machine-local as in Phase 1 — since feedback lives on the never-federated commission it is also machine-local; the split-record federation the epic sketches (feedback federates, `schedule` stays per-machine to avoid double-runs) is genuinely larger and tracked as follow-up. Refs #2657 — Phases 3–5 (all-ability adapter, music tool, genre taxonomy) remain. New/updated unit + route tests cover the feedback sanitizer, `submitCommissionFeedback` (upsert-by-run / runId verification / NOT_FOUND / the full loop where a reaction folds into the next directive), the goal clamp, the feedback route contract, the notification-only surfacing helper (deep link + no federated-inbox write + best-effort resilience), and the scheduler surfacing a successful fire but not a skipped one.
-- **[issue-2657] Creative Commissions now show — and let you choose — which AI processes them.** A commission used to silently inherit the install's default Creative Director AI Assignment, so it wasn't clear what provider/model would write each run's treatment and production plan. The edit drawer gains an **AI provider & model** picker (the shared `ProviderModelSelector`, filtered to agent-harness CLI/TUI providers since an API-type provider injected into a CoS agent task trips the harness-boundary guard), and the list card shows the chosen processor at a glance (an unset pin reads "Install default AI"; the picker's default option names the actual active provider so "default" is never opaque). The choice is stored as a new `assignment: { providerId, model }` on the commission record (additive; `providerId: null` = inherit the default, preserving prior behavior); at fire time the scheduler fans that single pin onto **both** CD cognitive stages (`modelOverrides.{treatment,plan}`) so the run is processed by the provider/model you picked. Evaluation is deliberately left inheriting the default — it's a vision API call, not a CoS agent, and pinning it to a CLI/TUI provider would trip the same harness boundary. A provider-less model is dropped by the sanitizer (the runtime keys on the provider first) so the stored pin can never dangle, and a PATCH that omits `assignment` preserves it while an explicit `{ providerId: null, model: null }` clears it back to the default. Zod-validated on create/update via the new `creativeCommissionAssignmentSchema`. New unit tests cover the sanitizer normalization/trim/provider-less-drop, the update replace-and-clear + preserve-on-omit semantics, and the scheduler fanning the pin onto both stages (and omitting the model when only a provider is chosen).
+- **[issue-2657] Creative Commissions now show — and let you choose — which AI processes them.** A commission used to silently inherit the install's default Creative Director AI Assignment, so it wasn't clear what provider/model would write each run's treatment and production plan. The edit drawer gains an **AI provider & model** picker (the shared `ProviderModelSelector`, filtered to agent-harness CLI/TUI providers since an API-type provider injected into a CoS agent task trips the harness-boundary guard), and the list card shows the chosen processor at a glance (an unset pin reads "Install default AI"; the picker's default option names the actual active provider so "default" is never opaque). The choice is stored as a new `assignment: { providerId, model }` on the commission record (additive; `providerId: null` = inherit the default, preserving prior behavior); at fire time the scheduler fans that single pin onto **both** CD cognitive stages (`modelOverrides.{treatment,plan}`) so the run is processed by the provider/model you picked. Evaluation is deliberately left inheriting the default — it's a vision API call, not a CoS agent, and pinning it to a CLI/TUI provider would trip the same harness boundary. A provider-less model is dropped by the sanitizer (the runtime keys on the provider first) so the stored pin can never dangle, and a PATCH that omits `assignment` preserves it while an explicit `{ providerId: null, model: null }` clears it back to the default. Zod-validated on create/update via the new `creativeCommissionAssignmentSchema`. The scheduler also **guards the pin at fire time**: treatment/plan run as CoS agent tasks that only accept an *enabled* agent-harness (cli/tui) provider, so a pin slipped past the UI (a direct REST write, or a provider whose type later changed to `api` or that the user disabled after pinning) is dropped and the run falls back to the default CD assignment instead of stalling at the harness boundary or launching through a disabled provider. New unit tests cover the sanitizer normalization/trim/provider-less-drop, the update replace-and-clear + preserve-on-omit semantics, the scheduler fanning the pin onto both stages (and omitting the model when only a provider is chosen), and the fire-time guard dropping api/removed/disabled pins.
- **Fix the Dev-UI "Vite host will be blocked" warning firing for apps whose vite config lives in an unlisted subdir.** `findViteConfig` only probed a hardcoded subdir allowlist (`client/`, `frontend/`, `web/`, …) plus each managed process's `cwd`. Apps that keep their Vite client elsewhere — e.g. an `admin/` dir — and whose stored process records carry no `cwd` produced a false "no vite.config was found" banner even though the config already set `allowedHosts: true` and the Dev UI opened fine over Tailscale. `findViteConfig` now falls back to a bounded breadth-first scan of the repo (depth ≤3, skipping `node_modules`/`.git`/build/vendor dirs, shallowest match wins) when the fast-path subdirs miss, so a config in any reasonable location is detected and the host-allow check reflects reality. `admin` also added to the fast-path list. New tests cover root, unlisted-subdir (`admin/`), nested, `node_modules`-ignore, and the end-to-end host-allowed status.