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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: client and server share tiling, sprite-direction, sync-mode, rounds-tempo, and quota-burn constants (#12970) (#13033)
[._.]/886af260349c
diff --git a/client/src/lib/index.js b/client/src/lib/index.jsindex 17aec8739b..4661b7d76b 100644--- a/client/src/lib/index.js+++ b/client/src/lib/index.js@@ -4,7 +4,7 @@ export * from './publicGuestRoutes.js';// See client/src/lib/README.md for the human-readable catalog and// AGENTS.md "Module organization" for the maintenance convention.-// === Prompt & rendering (mirror server/lib/ — keep byte-for-byte in sync) ===+// === Prompt & rendering (some re-export server/lib/, others are byte-for-byte mirrors; see client/src/lib/README.md) ===export * from './canonPrompt.js';export * from './cleanPlatePrompt.js';export * from './composeStyledPrompt.js';diff --git a/client/src/lib/messageSyncModes.js b/client/src/lib/messageSyncModes.jsindex c7c287f3f7..795f948af1 100644--- a/client/src/lib/messageSyncModes.js+++ b/client/src/lib/messageSyncModes.js@@ -3,7 +3,7 @@// account response); an account payload without the field (older server) is// treated as supporting every mode, so nothing is hidden by a missing field.-const ALL_MODES = ['unread', 'full'];+import { ALL_SYNC_MODES as ALL_MODES } from '../../../server/lib/messageTransport.js';export const accountSupportsSyncMode = (account, mode) =>(Array.isArray(account?.syncModes) ? account.syncModes : ALL_MODES).includes(mode);diff --git a/client/src/lib/metronome.js b/client/src/lib/metronome.jsindex 3921e81840..377536cb5d 100644--- a/client/src/lib/metronome.js+++ b/client/src/lib/metronome.js@@ -16,11 +16,12 @@import { parseScore } from './scoreNotation.js';import { getAudioContext as audioContext, resumeAudioContext } from './audioContext.js';+import { TEMPO_MIN, TEMPO_MAX } from '../../../server/lib/roundsBounds.js';-// BPM band — mirrors the server `tempo` validation (services/rounds.js-// TEMPO_MIN / TEMPO_MAX, also enforced by the Zod schema in routes/rounds.js).-export const METRONOME_BPM_MIN = 20;-export const METRONOME_BPM_MAX = 320;+// BPM band — the rounds tempo bounds (server/lib/roundsBounds.js), so the+// metronome and the server's `tempo` validation cannot drift.+export const METRONOME_BPM_MIN = TEMPO_MIN;+export const METRONOME_BPM_MAX = TEMPO_MAX;export const DEFAULT_BPM = 120;const DEFAULT_BEATS_PER_BAR = 4;diff --git a/client/src/lib/quotaBurnPatch.js b/client/src/lib/quotaBurnPatch.jsindex e6dd5f7ef7..5d49e4d6c7 100644--- a/client/src/lib/quotaBurnPatch.js+++ b/client/src/lib/quotaBurnPatch.js@@ -44,16 +44,10 @@ export function mergeQuotaBurnPatch(base, patch) {*/export const quotaBurnJobIsSpent = (job, ranAt) => Boolean(job?.runOnce && ranAt);-/**- * `QUOTA_BURN_UNLIMITED_DISPATCHES` in `server/lib/quotaBurnConfig.js`: the- * `maxDispatchesPerWindow` value that means the window is not counted at all,- * and the default. Mirrored (not imported) for the same reason the merge above- * is — the client cannot reach into `server/`.- */-export const UNLIMITED_DISPATCHES = -1;--/** Mirrors the server's `isUnlimitedDispatchCap`: any negative cap means no cap. */-export const isUnlimitedDispatchCap = (cap) => Number(cap) < 0;+import { QUOTA_BURN_UNLIMITED_DISPATCHES, isUnlimitedDispatchCap } from '../../../server/lib/quotaBurnDispatchCap.js';+export { isUnlimitedDispatchCap };+/** The `maxDispatchesPerWindow` "no cap" sentinel (the server default). */+export const UNLIMITED_DISPATCHES = QUOTA_BURN_UNLIMITED_DISPATCHES;/*** What to PUT for a dispatch cap the user just typed.diff --git a/client/src/lib/roundDraft.js b/client/src/lib/roundDraft.jsindex 6805f4f5ce..753ed11f24 100644--- a/client/src/lib/roundDraft.js+++ b/client/src/lib/roundDraft.js@@ -5,12 +5,12 @@// all read the same caps, id rules, and tempo band instead of re-declaring them.// Pure — no React, no API calls.-// Cap on partner songs — mirrors services/rounds.js PARTNERS_MAX. Used only to-// disable adding more in the editor; the server enforces the real bound.-export const PARTNERS_MAX = 12;-// Cap on harmony parts — mirrors services/rounds.js SCORE_PARTS_MAX. Used only-// to refuse applying an extracted part past the bound; the server enforces it.-export const SCORE_PARTS_MAX = 12;+// Part-count caps and the tempo band come from server/lib/roundsBounds.js (the+// server validator reads the same leaf). PARTNERS_MAX disables adding more+// partners in the editor; SCORE_PARTS_MAX refuses an extracted part past the+// bound. The server enforces the real bounds.+import { TEMPO_MIN, TEMPO_MAX, PARTNERS_MAX, SCORE_PARTS_MAX } from '../../../server/lib/roundsBounds.js';+export { TEMPO_MIN, TEMPO_MAX, PARTNERS_MAX, SCORE_PARTS_MAX };// In-session-only id for a freshly-added section/layer, used purely as a React// key until the row is saved. Counter-based (not Math.random, which is@@ -26,13 +26,10 @@ export const localId = (prefix) => `${prefix}-new-${localSeq++}`;// (preset ids like `lead`, server-assigned uuids) so dedup + matching survive.export const stripTempId = (row) => (TEMP_ID_RE.test(row.id) ? { ...row, id: '' } : row);-// Mirror the server tempo band (services/rounds.js TEMPO_MIN/MAX). We clamp on-// BLUR, not on every keystroke — clamping each keystroke would turn typing+// We clamp on BLUR, not on every keystroke — clamping each keystroke would turn typing// "68" into "208" (the lone "6" clamps up to 20 first). While editing we keep// the raw parsed number; clampTempo runs on blur so the saved value lands in// band without an opaque server 400. Empty input clears (null).-export const TEMPO_MIN = 20;-export const TEMPO_MAX = 320;// Parse a number input's value to a number or null, without clamping (used// on change so intermediate digits aren't mangled).export const parseTempo = (raw) => {diff --git a/client/src/lib/spriteFacets.js b/client/src/lib/spriteFacets.jsindex 7866586007..349a5c23fd 100644--- a/client/src/lib/spriteFacets.js+++ b/client/src/lib/spriteFacets.js@@ -24,12 +24,8 @@* atlas/<file> imported props atlas family*/-// Mirrors server/services/sprites/prompts.js SPRITE_DIRECTIONS (the client-// can't import server modules; WalkWorkflow mirrors WALK_PHASES the same way).-export const SPRITE_DIRECTIONS = [- 'south', 'south-east', 'east', 'north-east',- 'north', 'north-west', 'west', 'south-west',-];+import { SPRITE_DIRECTIONS } from '../../../server/lib/spriteVocabulary.js';+export { SPRITE_DIRECTIONS };/*** Every role. The first seven, in this order, are the groups the collectiondiff --git a/client/src/lib/videoTilingOptions.js b/client/src/lib/videoTilingOptions.jsindex 983c6cfb45..8ee67215df 100644--- a/client/src/lib/videoTilingOptions.js+++ b/client/src/lib/videoTilingOptions.js@@ -1,15 +1,16 @@-// Single source of truth for video tiling modes. Consumed by:-// - components/videoGen/AdvancedParamsPanel.jsx — the <select> options.-// - pages/VideoGen.jsx — the remix-prefill guard (VIDEO_TILING_ENUM_SET).-// - hooks/useMediaPreviewActions.js — the Remix URL builder.-// The server's z.enum in server/routes/videoGen.js must match these values;-// add a new mode here and to the server enum together.-export const VIDEO_TILING_OPTIONS = [- { value: 'auto', label: 'Auto (recommended)' },- { value: 'none', label: 'None (fastest, more VRAM)' },- { value: 'spatial', label: 'Spatial only' },- { value: 'temporal', label: 'Temporal only' },-];+// Video tiling options. The mode list is the server's (server/lib/videoTiling.js,+// also the video-gen route enums); this file only attaches labels. A new mode+// needs a label here — the labels test fails until it has one.+import { VIDEO_TILING_MODES } from '../../../server/lib/videoTiling.js';++const TILING_LABELS = {+ auto: 'Auto (recommended)',+ none: 'None (fastest, more VRAM)',+ spatial: 'Spatial only',+ temporal: 'Temporal only',+};++export const VIDEO_TILING_OPTIONS = VIDEO_TILING_MODES.map((value) => ({ value, label: TILING_LABELS[value] }));export const VIDEO_TILING_ENUM_SET = new Set(VIDEO_TILING_OPTIONS.map((o) => o.value));diff --git a/client/src/lib/videoTilingOptions.test.js b/client/src/lib/videoTilingOptions.test.jsnew file mode 100644index 0000000000..7ed886a187--- /dev/null+++ b/client/src/lib/videoTilingOptions.test.js@@ -0,0 +1,17 @@+import { describe, it, expect } from 'vitest';+import { VIDEO_TILING_OPTIONS, normalizeVideoTiling } from './videoTilingOptions';+import { VIDEO_TILING_MODES } from '../../../server/lib/videoTiling.js';++describe('video tiling options', () => {+ // Guards the labels map: a mode added to the server list without a label+ // would otherwise render as an unlabeled <option> the server accepts.+ it('offers a labeled option for every server tiling mode', () => {+ expect(VIDEO_TILING_OPTIONS.map((o) => o.value)).toEqual([...VIDEO_TILING_MODES]);+ for (const option of VIDEO_TILING_OPTIONS) expect(option.label).toBeTruthy();+ });++ it('rejects values the server would not accept', () => {+ expect(normalizeVideoTiling('spatial')).toBe('spatial');+ expect(normalizeVideoTiling('diagonal')).toBeUndefined();+ });+});diff --git a/server/lib/README.md b/server/lib/README.mdindex b511f3aa66..a4820a7c9f 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -119,6 +119,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `autonomousJobTask.js` | `generatedJobTaskFields` — (+ `isExpectedUnpersistedMiss`: a scheduled fire never persists its task, so the spawn/finalize status writes miss by design and stay quiet) flattens a `generateTaskFromJob` result into the top-level keys the non-raw `cos.addTask` path maps onto metadata. One allowlist shared by the manual "Run now" endpoint and the quota-burn lane, so a key added to the generator cannot reach one and not the other. Pure. || `qualitySchedulePlan.js` | Lays a managed app's schedulable quality audits out across a week. `planQualitySchedule({taskTypes, fileIssuesByType, busy, options})` → one weekly cron per check plus ONE daily cron for the issue-claim drain that follows each check by `claimOffsetHours` (placed forward-only, so a drain never precedes the audit it works for); `orderQualityChecks` topologically sorts the selection by `AUDIT_SUGGESTED_AFTER`; `buildBusySlots(occupancies, options)` turns expanded crons into the occupied `"<day>:<hour>"` cells the placement avoids (which is how a 03:30 release job keeps audits out of its window); `resolveQualityScheduleOptions` is the ONE default/window/claim-type resolver the planner and its service caller share. Which repo shape each audit needs is catalog-owned (`auditCapabilityRequirement`), not declared here. Pure: no schedule read, no repo read, no clock. || `quotaBurnConfig.js` | Quota-burn plan shape: the provider families, the burn-job type alphabet + catalog the config page renders its form from, `QUOTA_BURN_BOUNDS` (the one bounds table the normalizer clamps to, the Zod schemas reject against, and the catalog descriptors publish as min/max), and total normalization (`normalizeQuotaBurnConfig`). Owns the dispatch-cap sentinel too (`QUOTA_BURN_UNLIMITED_DISPATCHES` / `isUnlimitedDispatchCap`) — -1 means the window is not counted, and is the default. Also owns the retired executor's task-description parser (`QUOTA_BURN_TASK_PREFIX` / `quotaBurnFamilyOfDescription`), kept for migration 225, and the `run once` vocabulary (`quotaBurnJobKey` / `jobIsSpent`, plus the two family predicates `familyIsConfigured` and `familyHasRunnableJobs`). Pure — no storage, no provider I/O. |+| `quotaBurnDispatchCap.js` | Leaf (no imports) for the quota-burn dispatch-cap sentinel: `QUOTA_BURN_UNLIMITED_DISPATCHES` (-1) and `isUnlimitedDispatchCap`. Shared with the client quota-burn form; `quotaBurnConfig.js` re-exports both. || `quotaBurnLegacyConversion.js` | The ONE rule turning a LEGACY quota-burn step (copied prompt + quota-only `jobType`) into a scheduled-task reference, shared by migration 359 and the live compat path so the two cannot drift. `planQuotaBurnStepConversion` decides between three outcomes — a recognized unmodified shipped preset onto its scheduled audit counterpart with issues-only pinned explicitly (`AUDIT_TASK_TYPE_BY_PRESET_ID`, inverted from `auditCatalog.js`), the two programmatic types onto their scheduled handlers, and anything customized or targetless onto a `buildQuotaBurnCustomJob` on-demand custom task addressed by the deterministic `quotaBurnCustomJobId` (which is what makes a repeated or resumed conversion create no duplicate). `legacyAgentTaskMetadata` reproduces the retired executor's dispatch posture; `applyQuotaBurnStepConversion` rewrites the step, preserving id, label, enabled and run-once state. Recognition is `matchStoredAuditPreset`, never a label or a partial match. || `quotaBurnOrigin.js` | Quota-burn PROVENANCE on an on-demand scheduled-task request and on the task it produces. `normalizeQuotaBurnProvenance` reads the request block (burn-step id always required, plus an attribution — the family whose window is spent, OR the manual `maintenanceRunId` alone when the run is pinned outside every subscription family — the limiting-window reset and the provider/model/effort overrides); `QUOTA_BURN_PROVENANCE_FIELDS` is the ONE block definition every persistence and projection hop derives from, spread by `quotaBurnTaskMetadata` (flat task-metadata keys), `quotaBurnAgentMetadata` (the agent projection) and read back by `quotaBurnProvenance` / `hasQuotaBurnProvenance`, which accept both the flat keys and a nested `quotaBurn` block; `burnPlanOwnsTask` / `burnPlanOwnsAgent` are the ONE rule for whether the family plan (not a manual maintenance run) owns a burn-provenanced task. `isManualOnDemandRequest` distinguishes explicit runs from automated cadence gates. `onDemandRequestMetadata` is the single spread both on-demand engines apply. Import-light on purpose — `taskScheduleConstants.js` declares the origin string and must not drag the quota-burn config graph. || `quotaBurnPresets.js` | FROZEN compatibility-and-migration input (#6381). `QUOTA_BURN_PROMPT_PRESETS` — ready-made single-focus audit prompts for `agent-prompt` burn jobs (UX, a11y, mobile, failure paths, perf, test gaps, dead code, data safety, docs, security), each filing GitHub issues and changing no code. Templates: picking one COPIES its prompt into the job, so editing them never rewrites a configured job. `findQuotaBurnPreset(id)`; `matchStoredAuditPreset` is migration 305's recognition rule (match the MISSION half, gated on the shipped contract anchors + headings) and `upgradeStoredAuditPrompt` is the refresh built on it. |@@ -164,6 +165,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `postValidation.js` | MeatSpace POST (Power On Self Test) schemas — drill config (incl. adaptive toggle), drill generation/scoring, sessions, memory builder, training log. || `privacyValidation.js` | Privacy Center schemas — PII Vault (issue #2140): vault record create/update (partial PUT), list query, UUID params; the vault type/status vocabularies + the sensitive-type (`ssn`/`passport`/`drivers_license`/`financial_account`) `useForScans` hard-false rule and per-type scan defaults. Trusted Organizations registry (issue #2141): org create/update (partial PUT), list query, UUID params, and the replace-set holdings schema. Data-broker database + case ledger (issue #2144): broker list/case-list query filters, the scan-start + refresh action bodies, and the `PRIVACY_BROKER_CASE_STATES` vocabulary. || `roundsValidation.js` | Rounds workbench shape bounds + pure record sanitizers (sections, layers, recordings, pitch analysis, references, progress) — `sanitizeRound(raw, builtinIds)` and the length/count limits shared with routes/rounds.js. |+| `roundsBounds.js` | Leaf (no imports) for the rounds tempo band (`TEMPO_MIN` / `TEMPO_MAX`) and the partner / harmony-part caps (`PARTNERS_MAX` / `SCORE_PARTS_MAX`). Shared with the client rounds editor and metronome; `roundsValidation.js` re-exports them. || `socketPayloadLimits.js` | Shared 8 MiB media cap and transport ceiling accounting for polling base64 encoding plus 64 KiB framing headroom. || `socketValidation.js` | Socket event payload schemas. || `spriteValidation.js` | Sprite Manager Zod schemas — record import/create/update, reference generate/lock/unlock + fork, walk-cycle generate/approve/reopen/trim, per-track generate/approve schemas built from the animation-track registry, publish binding + runtime contract, atlas publish/compile, and user-defined animation-track create/update. Split out of `validation.js` (#3873), which re-exports it. |@@ -280,6 +282,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `videoModeProfiles.js` | The shipped `supportedModes` fact per video runtime (#3737), so "which modes does this model support?" has one answer on the registry entry instead of 25+ runtime comparisons. `VIDEO_RUNTIME_MODES` maps each runtime to the semantic modes its helper can actually render, including `minimax_h3_ref2va` as a2v-only; `VIDEO_BASE_MODES` remains the non-audio fallback for an unknown runtime. `resolveVideoSupportedModes(entry)` and `applyVideoSupportedModes(list)` provide the read-time decoration used by `mediaModels.js#getVideoModels`. || `videoDurationProfiles.js` | Pure pinned duration/frame contracts shared by model-registry upgrades and migrations. LTX-2.5 A2V follows the full uploaded audio, rounds up to its 8n+1 temporal grid, and tops out at 1017 frames under the API's single-pass boundary. || `videoReferenceModes.js` | The i2v reference-mode contract (#4874) — what a supplied conditioning image PROMISES. `I2V_REFERENCE_MODES` (`anchor` \| `inspire`) + `I2V_REFERENCE_MODE_OPTIONS` (the label + the promise sentence the UI prints), `I2V_REFERENCE_MODE_RUNTIMES` (only `ltx25` can honor `inspire` — it needs per-image conditioning strength), `INSPIRE_DEFAULT_IMAGE_STRENGTH`, plus `normalizeI2vReferenceMode` / `isDefaultI2vReferenceMode` / `isKnownI2vReferenceMode` / `runtimeSupportsI2vReferenceMode` / `i2vReferenceModeLabel` / `resolveI2vReferenceStrength` and the one rule `i2vReferenceModeViolation({ model, mode, referenceMode, hasFirstImage })` → `{ code, message }` or null. Pure (no `ServerError`) because it is MIRRORED to `client/src/lib/videoReferenceModes.js`; `videoGen/modeContract.js#videoReferenceModeError` wraps it for the route + render boundaries. |+| `videoTiling.js` | `VIDEO_TILING_MODES` — the one list of video tiling modes. The video-gen routes build their `z.enum` from it and the client renders its options from it (labels in `client/src/lib/videoTilingOptions.js`). Leaf, no imports. || `videoStreamingMode.js` | Block-streaming request vocabulary for LTX-2/2.5 MLX local video renders (#6499) — `VIDEO_STREAMING_MODES` (`auto` \| `resident` \| `stream`), `DEFAULT_VIDEO_STREAMING_MODE` (`'auto'`), `VIDEO_STREAMING_MODE_OPTIONS` (label + description for the picker), `isDefaultVideoStreamingMode` / `isKnownVideoStreamingMode` / `videoStreamingModeLabel` / `videoStreamingModeFromRecord`. This module carries only the REQUEST-side enum — `scripts/generate_ltx2.py#resolve_streaming_policy()` inspects the pinned pipeline's actual constructor and this machine's physical RAM to decide whether `auto` streams, and an explicit `stream` request the pinned pipeline cannot honor (Extend) is a refusal there, not a downgrade here. Pure, mirrored to `client/src/lib/videoStreamingMode.js`. || `videoTextEncoders.js` | Swappable prompt conditioners for local video runtimes. MiniMax H3 reads the *unnormalized* hidden state after Qwen3-VL language layer 49 (layers 50-63, the final norm and `lm_head` are never evaluated), so any checkpoint carrying the same embedding + layers 0-49 + vision tower is a drop-in conditioner — swapping it changes how the model reads a prompt without touching the diffusion weights. `TEXT_ENCODERS_BY_RUNTIME` declares the shipped options per runtime (pinned repo/revision plus an explicit `files` LIST — one repackaged safetensors, or just the shards of an upstream checkpoint that carry parameters the loader actually builds; in code rather than the media-models registry so a stale `data/media-models.json` can't name a file the runner can't map); `videoTextEncoderOptions(model)` returns the TRUE list stock-first (it deliberately does NOT collapse a one-entry runtime to `[]` — that is a presentation rule, and folding it in here would change what the server believes a model supports and empty the "offers …" list in the error; `TextEncoderPicker` owns the hide-when-there-is-no-real-choice check), `isStockTextEncoder(id)` makes absence and the `stock` sentinel the same request, `resolveVideoTextEncoder(model, id)` returns `null` for the stock choice or throws `VIDEO_TEXT_ENCODER_UNSUPPORTED` (with the non-throwing `supportsVideoTextEncoder` + `videoTextEncoderUnsupportedError` split out so the request path can reject before staging uploads), and `downloadableVideoTextEncoders()` (deduped by id — the table is keyed by RUNTIME, so one conditioner can be offered by two) / `downloadableVideoTextEncoder(id)` feed the `/api/video-gen/text-encoders/:id/(download\|repair)` lane. Two loader-mechanics fields exist because a ComfyUI-packaged conditioner is namespaced differently from the HF checkpoint the MLX port matches: `keyPrefixMap` (`model.` → `model.language_model.`, `visual.` → `model.visual.`) is applied to every checkpoint key by `scripts/generate_minimax_h3.py` BEFORE the pinned loader sees it — no fork of the pinned runtime — and `finalNormKey` names where the runner synthesizes a ones-filled `norm.weight` for a checkpoint published without one (correct upstream, since H3 reads the state *before* the norm, but the pinned loader refuses to load with any parameter missing). Both are absent for an UPSTREAM Qwen3-VL-32B checkpoint, which already uses the loader namespace and ships its own norm. A candidate must BE Qwen3-VL-32B (the shim reuses upstream's config/tokenizer/processor) — a different Qwen generation is not a substitute however close its conditioning width looks; see docs/features/video-text-encoders.md. `publicTextEncoderOption(entry)` is the client projection and deliberately drops both, so the UI can't reimplement the remap. The `ltx25` table (#4320) uses a third mechanic, `configOverrides`, because an LTX-2.5 pack's OWN Gemma 4 tower wins over `--gemma` inside the pinned fork: the substitution is a standalone shim directory whose generated `config.json` is the substitute's own with these keys merged over it (only ever the `model_type` label a unified checkpoint gets wrong — never `text_config`/`quantization`), and a candidate must BE Gemma 4 12B at 48 layers / hidden 3840 / vocab 262144 / `k_eq_v`. `verified` gates a substitute out of BOTH lanes (picker AND download) until it has been A/B-rendered against its runtime's stock conditioner — required on every non-built-in entry and fail-closed on absence, so a new entry is unreachable until someone states a verdict; both ltx25 substitutes are `verified: false` today. `declaredVideoTextEncoders()` is the UNFILTERED table for shape/invariant checks only — never the render or download path, and `videoTextEncoderRuntimes()` enumerates the table's runtime keys so parity/shape tests cover every runtime rather than the one that happened to exist when they were written. || `pi.js` | Pi command identity, headless/TUI arguments, and positional prompt delivery. |diff --git a/server/lib/index.js b/server/lib/index.jsindex f5ab5301bf..5e4ece4e94 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -81,6 +81,7 @@ export * as postRhetoric from './postRhetoric.js';export * as postValidation from './postValidation.js';export * as privacyValidation from './privacyValidation.js';export * as roundsValidation from './roundsValidation.js';+export * as roundsBounds from './roundsBounds.js';export * from './socketPayloadLimits.js';export * as socketValidation from './socketValidation.js';export * from './socketEventContracts.js';@@ -251,6 +252,7 @@ export * from './videoSpeedProfiles.js';export * from './videoModeProfiles.js';export * from './videoDurationProfiles.js';export * from './videoReferenceModes.js';+export * from './videoTiling.js';export * from './videoStreamingMode.js';export * from './videoTextEncoders.js';export * from './promptFencing.js';@@ -277,6 +279,7 @@ export * as reviewerHealth from './reviewerHealth.js';export * from './reviewerProviderMatchers.js';export * from './qualitySchedulePlan.js';export * from './quotaBurnConfig.js';+export * as quotaBurnDispatchCap from './quotaBurnDispatchCap.js';export * from './quotaBurnLegacyConversion.js';export * from './quotaBurnOrigin.js';export * from './quotaBurnPresets.js';diff --git a/server/lib/messageTransport.js b/server/lib/messageTransport.jsindex fab6a98314..e70d8ce01e 100644--- a/server/lib/messageTransport.js+++ b/server/lib/messageTransport.js@@ -15,7 +15,7 @@ export const MESSAGE_ACCOUNT_TRANSPORT = Object.freeze({teams: Object.freeze({ sendVia: 'playwright', email: false, syncModes: Object.freeze(['full']), readState: false })});-const ALL_SYNC_MODES = Object.freeze(['unread', 'full']);+export const ALL_SYNC_MODES = Object.freeze(['unread', 'full']);/** Sync modes an account type can honor; an unknown type keeps every mode (the provider dispatch rejects it). */export function syncModesForAccountType(type) {diff --git a/server/lib/quotaBurnConfig.js b/server/lib/quotaBurnConfig.jsindex f6185107fc..029a1f3e3a 100644--- a/server/lib/quotaBurnConfig.js+++ b/server/lib/quotaBurnConfig.js@@ -67,17 +67,10 @@ export function quotaBurnFamilyOfDescription(description) {*/export const quotaBurnJobKey = (familyId, jobId) => `${familyId}:${jobId}`;-/**- * `maxDispatchesPerWindow` sentinel for "no cap on how many burns this window- * may spend" — and the default. Why the cap is opt-in rather than a safety- * property is argued once, in `docs/QUOTA-BURN.md`.- *- * -1 rather than 0/null: it stays a number for the client's `<input- * type="number">` and the run log, and it can never be confused with "0 burns- * allowed" (which is what disabling the family already means). It sits BELOW- * the field's own minimum, which is what `clampDispatchCap` exists to handle.- */-export const QUOTA_BURN_UNLIMITED_DISPATCHES = -1;+// `maxDispatchesPerWindow` "no cap" sentinel (the default). Lives in a leaf+// module so the client shares it; see docs/QUOTA-BURN.md for why the cap is opt-in.+export { QUOTA_BURN_UNLIMITED_DISPATCHES, isUnlimitedDispatchCap } from './quotaBurnDispatchCap.js';+import { QUOTA_BURN_UNLIMITED_DISPATCHES, isUnlimitedDispatchCap } from './quotaBurnDispatchCap.js';/*** Every numeric/length bound in the plan, in ONE place.@@ -111,9 +104,6 @@ export const QUOTA_BURN_BOUNDS = Object.freeze({});const BOUNDS = QUOTA_BURN_BOUNDS;-/** Whether a family's dispatch cap means "no cap". Any negative value reads as unlimited. */-export const isUnlimitedDispatchCap = (cap) => Number(cap) < 0;-/*** LEGACY burn job types — a COMPATIBILITY INPUT, frozen.*diff --git a/server/lib/quotaBurnDispatchCap.js b/server/lib/quotaBurnDispatchCap.jsnew file mode 100644index 0000000000..8acb51fc2b--- /dev/null+++ b/server/lib/quotaBurnDispatchCap.js@@ -0,0 +1,13 @@+/**+ * Quota-burn dispatch-cap sentinel — the `maxDispatchesPerWindow` value meaning+ * the window is not counted at all. -1 rather than 0/null: it stays a number for+ * the client's `<input type="number">` and the run log, and it can never be+ * confused with "0 burns allowed" (which is what disabling the family means).+ * Any negative cap reads as unlimited.+ *+ * A leaf module (no imports) so the client's quota-burn form and the server+ * normalizer share one definition. `quotaBurnConfig.js` re-exports these.+ */+export const QUOTA_BURN_UNLIMITED_DISPATCHES = -1;++export const isUnlimitedDispatchCap = (cap) => Number(cap) < 0;diff --git a/server/lib/roundsBounds.js b/server/lib/roundsBounds.jsnew file mode 100644index 0000000000..9bec0ae374--- /dev/null+++ b/server/lib/roundsBounds.js@@ -0,0 +1,9 @@+/**+ * Rounds tempo and part-count bounds shared by the server validator and the+ * client editor/metronome. A leaf module (no imports) so the browser bundle can+ * import it; `roundsValidation.js` re-exports these.+ */+export const TEMPO_MIN = 20;+export const TEMPO_MAX = 320;+export const PARTNERS_MAX = 12; // partner-song ids (rounds sung together)+export const SCORE_PARTS_MAX = 12; // harmony variations of the sheet musicdiff --git a/server/lib/roundsValidation.js b/server/lib/roundsValidation.jsindex 198838f7a6..be9963ca66 100644--- a/server/lib/roundsValidation.js+++ b/server/lib/roundsValidation.js@@ -17,6 +17,10 @@import { randomUUID } from 'crypto';import { trimTo } from './textUtils.js';+import { TEMPO_MIN, TEMPO_MAX, PARTNERS_MAX, SCORE_PARTS_MAX } from './roundsBounds.js';++// Tempo and part-count bounds live in roundsBounds.js (a browser-safe leaf); re-exported here for the service and routes.+export { TEMPO_MIN, TEMPO_MAX, PARTNERS_MAX, SCORE_PARTS_MAX };// --- Shape bounds (shared with routes/rounds.js#roundInputSchema) -------------export const TITLE_MAX_LENGTH = 200;@@ -24,17 +28,13 @@ export const ARTIST_MAX_LENGTH = 200;export const KEY_MAX_LENGTH = 24;export const FIELD_MAX_LENGTH = 4000; // lyrics body / general notesexport const SCORE_MAX_LENGTH = 8000; // sheet-music notation (lead-sheet DSL)-export const SCORE_PARTS_MAX = 12; // harmony variations of the sheet musicexport const LABEL_MAX_LENGTH = 120; // section + layer labelsexport const PART_MAX_LENGTH = 60; // layer voice (e.g. "Bass")export const ID_MAX_LENGTH = 60; // rhythm-shape / layer ids-export const TEMPO_MIN = 20;-export const TEMPO_MAX = 320;export const SECTIONS_MAX = 60;export const LAYERS_MAX = 24;export const RECORDINGS_MAX = 64; // saved vocal takes for layered playbackexport const REFERENCES_MAX = 12; // reference links/videos (e.g. TikTok)-export const PARTNERS_MAX = 12; // partner-song ids (rounds sung together)export const URL_MAX_LENGTH = 512; // uploaded-file path/url// Reference-audio analysis (#2106): labeled time ranges on a reference's// attached audio ("0:00–0:14 melody alone"). Bounded so a hand-edited filediff --git a/server/lib/videoTiling.js b/server/lib/videoTiling.jsnew file mode 100644index 0000000000..507aeb08b7--- /dev/null+++ b/server/lib/videoTiling.js@@ -0,0 +1,7 @@+/**+ * Video tiling modes — the one list the video-gen routes validate against and+ * the client renders its options from (client/src/lib/videoTilingOptions.js).+ *+ * A leaf module (no imports) so the browser bundle can import it directly.+ */+export const VIDEO_TILING_MODES = Object.freeze(['auto', 'none', 'spatial', 'temporal']);diff --git a/server/routes/mediaJobs.js b/server/routes/mediaJobs.jsindex 883af17739..d95ae1cd67 100644--- a/server/routes/mediaJobs.js+++ b/server/routes/mediaJobs.js@@ -19,6 +19,7 @@ import { isRemoteMediaJob } from '../services/mediaJobQueue/remoteMediaJob.js';import { validateVideoRetryParams } from '../services/videoGen/prepareParams.js';import { hostedVideoRetryValidator } from '../services/videoGen/hostedSubmission.js';import { I2V_REFERENCE_MODES } from '../lib/videoReferenceModes.js';+import { VIDEO_TILING_MODES } from '../lib/videoTiling.js';import { DRAFT_DECODE_IDS, isFullDecode } from '../lib/videoDraftDecoders.js';import { VIDEO_STREAMING_MODES, isDefaultVideoStreamingMode } from '../lib/videoStreamingMode.js';@@ -270,7 +271,7 @@ const RETRY_OVERRIDE_SCHEMA = z.object({seed: z.number().int().min(0).nullable().optional(),numFrames: z.number().int().min(1).max(1024).optional(),fps: z.number().int().min(1).max(60).optional(),- tiling: z.enum(['auto', 'none', 'spatial', 'temporal']).optional(),+ tiling: z.enum(VIDEO_TILING_MODES).optional(),disableAudio: z.boolean().optional(),imageStrength: z.number().min(0).max(1).nullable().optional(),// What the conditioning image promises (#4874). `null` clears it back to thediff --git a/server/routes/videoGen.js b/server/routes/videoGen.jsindex d72207f37c..31f5750fdc 100644--- a/server/routes/videoGen.js+++ b/server/routes/videoGen.js@@ -96,6 +96,7 @@ import {import { detectSystemCapabilities, withHardwareCompatibility } from '../lib/systemCapabilities.js';import { isDisplaySleepEnabled } from '../services/videoGen/displayPower.js';import { promptAdditionsSchema } from '../lib/modelInput.js';+import { VIDEO_TILING_MODES } from '../lib/videoTiling.js';const router = Router();@@ -250,7 +251,7 @@ export const LOCAL_ONLY_VIDEO_PARAMS = Object.freeze({(v) => (v == null || v === '' ? undefined : v),z.enum(I2V_REFERENCE_MODES).optional(),),- [VIDEO_GEN_LOCAL_ONLY_FIELDS.TILING]: z.enum(['auto', 'none', 'spatial', 'temporal']).optional(),+ [VIDEO_GEN_LOCAL_ONLY_FIELDS.TILING]: z.enum(VIDEO_TILING_MODES).optional(),// Which prompt conditioner reads the prompt (lib/videoTextEncoders.js).// Validated loosely here and resolved against the MODEL's own option list in// the service — the set is per-runtime, so a route-level enum would either