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: derive job cadence pickers from the server registry
[._.]/ Adam Eivy6aa306c75f20
diff --git a/client/src/components/instances/BrainParitySchedule.test.jsx b/client/src/components/instances/BrainParitySchedule.test.jsxindex 1dee9c39af..b6b0e3dd9d 100644--- a/client/src/components/instances/BrainParitySchedule.test.jsx+++ b/client/src/components/instances/BrainParitySchedule.test.jsx@@ -1,6 +1,7 @@import { describe, it, expect, vi, beforeEach } from 'vitest';import { render, screen, waitFor } from '@testing-library/react';import userEvent from '@testing-library/user-event';+import { INTERVAL_OPTIONS } from '../../../../server/lib/autonomousJobIntervals.js';vi.mock('../../services/api', () => ({getCosJob: vi.fn(),@@ -82,6 +83,9 @@ describe('BrainParitySchedule', () => {render(<BrainParitySchedule />);const select = await screen.findByLabelText('Parity sweep interval');+ // Every server-supported picker cadence is visible with its canonical label.+ expect(Array.from(select.options, ({ value, textContent }) => ({ value, label: textContent })))+ .toEqual(INTERVAL_OPTIONS.map(({ value, label }) => ({ value, label })));await userEvent.selectOptions(select, 'daily');expect(updateCosJob).toHaveBeenCalledWith(PARITY_SWEEP_JOB_ID, { interval: 'daily' }, { silent: true });diff --git a/client/src/utils/README.md b/client/src/utils/README.mdindex 7b65094038..b2ecd4e2e2 100644--- a/client/src/utils/README.md+++ b/client/src/utils/README.md@@ -23,7 +23,7 @@ grep -i "what you want to do" client/src/utils/README.md| Module | Purpose ||---|---|| `formatters` | Date/time/duration/byte formatters (`clamp`, `formatBytes`, `formatDownloadGb` (decimal-GB model download size, "~29 GB"), `formatCompactCount`, `formatCompactCountOrDash` (same, but an ABSENT count renders "—" rather than "0"), `timeAgo`, `formatAgeDays` (age in whole DAYS — "412 days ago" — where `timeAgo` would collapse to "1y ago"; model-download lists), `localDateKey` (browser-local `YYYY-MM-DD`), `shiftISODate` (DST-safe calendar-day shifts), `formatTimecode`, `formatDurationMs`, `formatDateShort`, `formatContextTokens` (suffix-less context length, "4K"), `throughputLabel` (a measured model's speed as one label — tok/s where the runtime reported token counts, `~` prefixed when frame-counted, else chars/s; never both), `parseTimeoutMs`, `formatCooldown`, `recommendedRamGb`, `nameFromImageFilename`, `formatUsd` — one USD renderer (`signed` puts the minus outside the `$`; `trimWhole` drops `.00` on a typed round price) — `formatWeight` / `formatPercent` — round unit-converted floats (`170.35000000000002` → `170.4 lbs`) so raw binary precision never reaches a tile — `middleTruncate` — clip a long string from the MIDDLE so its distinguishing tail survives, where CSS `line-clamp`/`text-overflow` always eats the end — …) plus timeout-input bounds and `getAppName`. Do not re-define formatters inside components. **Never write `new Date(x).toLocaleDateString()` inline** — pick the helper for the shape you want: `formatDateNumeric` ("3/5/2026", compact cells), `formatDateShort` ("Mar 5, 2026"), `formatDate` ("March 5, 2026"), `formatDateFull` ("Saturday, March 5, 2026"), `formatWeekdayDate` ("Monday, Mar 5", `{ weekday, year }`), `formatMonthDay` ("Mar 5"), `formatMonthYear` ("March 2026"), `formatWeekdayShort` ("Mon"), `formatWeekdayTime` ("Mon, 7:00 AM"), `formatTimeOfDay` ("1:30 PM"), `formatTimeOfDaySeconds` ("1:30:45 PM", log/queue rows), `formatClockTime` ("02:30:45 PM"; `{ seconds, hour12, timeZone }`), `formatDateTime`. `formatHourOfDay` renders a bare hour-of-day number (0-23) as a 12-hour label in one of four styles (`long` "3 PM", `compact` "3PM", `tiny` "3p", `lower` "3pm") — the canonical home for what five components each hand-rolled, so the same 3pm no longer renders four ways across screens. Date display helpers anchor a bare `YYYY-MM-DD` at LOCAL midnight (a naive `new Date('2026-03-05')` is UTC midnight and renders as the previous day west of Greenwich) and take a fallback instead of rendering the literal "Invalid Date". |-| `cronHelpers` | Cron preset list, friendly cron parsing/building, anchored recurrence parsing/building/description, `isCronExpression` detection, `describeCron` human-readable rendering, `cronFromIntervalMs` numeric-interval → expression conversion (mirrors the server helper), and `JOB_INTERVAL_OPTIONS` / `ON_DEMAND_INTERVAL` — the interval-mode cadences for autonomous jobs, mirroring the server's `INTERVAL_OPTIONS` (`on-demand` = stays enabled and manually runnable, but arms no timer). Import it rather than re-declaring the list in a scheduling component. |+| `cronHelpers` | Cron preset list, friendly cron parsing/building, anchored recurrence parsing/building/description, `isCronExpression` detection, `describeCron` human-readable rendering, `cronFromIntervalMs` numeric-interval → expression conversion (mirrors the server helper), and `JOB_INTERVAL_OPTIONS` / `ON_DEMAND_INTERVAL` — the interval-mode cadences for autonomous jobs, derived from the server's `INTERVAL_OPTIONS` (`on-demand` = stays enabled and manually runnable, but arms no timer). Import it rather than re-declaring the list in a scheduling component. || `markdownText` | `markdownToPlainText(md)` — flatten markdown source to one plain-text string for a clamped preview: strips heading/list/blockquote/fence markers, unwraps emphasis, inline code and links, images → `[alt]`, collapses blank-line runs. Use whenever a card previews arbitrary agent-authored markdown — `line-clamp-N` does not clamp a subtree of block elements, and foreign `##` headings would otherwise join the page's heading outline. Underscore emphasis is word-boundary gated and `__…__` needs interior whitespace, so stack frames and user-agent strings (`10_15_7`, `__init__`) are never silently rewritten. `dropsMarkupWhenFlattened(md)` — did the flatten lose actual markup, as opposed to only normalizing whitespace? Gates a "Show more" disclosure so a short-but-lossy body stays reachable without putting a toggle on every body that merely lost a trailing newline. || `timeWindow` | Time-of-day window math (`isInTimeWindow`, `timeStringToMinutes`) and morning-layout auto-switch helpers (`pickActiveLayoutId`, `recordManualLayoutPick`). || `timezone` | Timezone day-key helpers (`dayKeyInTimezone`, `todayKeyInTimezone`) — browser mirror of the server's `todayInTimezone`, so date-scoped POST surfaces derive "today" in the user's configured timezone and agree with the server (#2681). |diff --git a/client/src/utils/cronHelpers.js b/client/src/utils/cronHelpers.jsindex b69106a63c..bab8fa2881 100644--- a/client/src/utils/cronHelpers.js+++ b/client/src/utils/cronHelpers.js@@ -1,3 +1,6 @@+import { INTERVAL_OPTIONS } from '../../../server/lib/autonomousJobIntervals.js';+export { ON_DEMAND_INTERVAL } from '../../../server/lib/autonomousJobIntervals.js';+export const CRON_PRESETS = [{ value: '*/15 * * * *', label: 'Every 15 min' },{ value: '0 * * * *', label: 'Every hour' },@@ -278,24 +281,6 @@ export function describeCron(expr) {return segments.join(' ');}-// Interval-mode cadences for autonomous jobs — the client mirror of-// `INTERVAL_OPTIONS` in `server/lib/autonomousJobIntervals.js`. Values-// must stay in lockstep with `resolveIntervalMs` there, since the server-// recomputes `intervalMs` from whichever value a picker submits. Lives here-// rather than in a component so a second job-scheduling surface doesn't fork-// its own copy of the list. `on-demand` is the no-recurrence cadence: the job-// stays enabled and manually runnable, but no timer is ever armed for it.-// `server/lib/autonomousJobIntervals.mirror.test.js` fails when the two lists drift.-export const ON_DEMAND_INTERVAL = 'on-demand';--export const JOB_INTERVAL_OPTIONS = [- { value: 'hourly', label: 'Every Hour' },- { value: 'every-2-hours', label: 'Every 2 Hours' },- { value: 'every-4-hours', label: 'Every 4 Hours' },- { value: 'every-8-hours', label: 'Every 8 Hours' },- { value: 'daily', label: 'Daily' },- { value: 'weekly', label: 'Weekly' },- { value: 'biweekly', label: 'Every 2 Weeks' },- { value: 'monthly', label: 'Monthly' },- { value: ON_DEMAND_INTERVAL, label: 'On Demand' }-];+// Both autonomous-job pickers use the same vocabulary as server validation and+// duration resolution. Keep the client projection's existing value/label shape.+export const JOB_INTERVAL_OPTIONS = INTERVAL_OPTIONS.map(({ value, label }) => ({ value, label }));diff --git a/server/lib/README.md b/server/lib/README.mdindex 2eada33019..2c516933a1 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -578,7 +578,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and|---|---|| `dbTestGate.js` | `requireDbOrSkip(label, dbReady, reason)` keeps a missing local test database as a visible skipped suite, but throws when `PORTOS_REQUIRE_DB` is set so CI cannot pass after DB-backed suites disappear. || `gitTestRepo.js` | Shared real-git sandbox for integration tests (#4394): one initialized template (working tree + bare origin) per worker, then `fs.cp` into a fresh temp dir. `makeGitSandbox({ origin })`, `attachBareOrigin(scratch, repo)`, `materializeGitRepo(dest)`, `destroyGitSandbox`, plus `SKIP_HEAVY_INTEGRATION` (`VITEST_FAST=1`). `resetGitSandbox({ scratch, repo, initialHead })` / `resetGitWorktreeSandbox(repo, initialHead)` restore a sandbox in place (branches, worktrees, remote) so a `describe` can build one sandbox in `beforeAll` and reset between tests instead of paying the fs.cp/rm cycle per test (#5902). Every entry point runs `assertTempPath` first, so a path outside `os.tmpdir()` throws instead of `git init`-ing or `rm -rf`-ing a real checkout (#4554). Still real git — just not rebuilt from `init`+`commit`+`push` in every `beforeEach`. |-| `mirrorParity.js` | Source-extraction and comparison primitives for declaration-level contract tests: the vendored `aiToolkit/` copy of `TOOL_USE_RE` (`localModelHeuristics.mirror.test.js`), the client cadence table `autonomousJobIntervals.test.js` pins, and the bootstrap sequence's body assertions (`bootstrap*.test.js`). A pure module the browser needs is imported by the client rather than mirrored, so no client↔server copy test should need these: `stripCommentsAndNormalize` (so per-side commentary may diverge but logic may not), `extractDeclaration(src, name)` (balanced `{}`/`()`/`[]` walk over `function` / `async function` / `const`), and `compareDeclaration(serverSrc, clientSrc, name)`. Use these instead of hand-rolling a brace-walker per mirror. Pure — no `vitest` import — so callers own the assertions. |+| `mirrorParity.js` | Source-extraction and comparison primitives for declaration-level contract tests: the vendored `aiToolkit/` copy of `TOOL_USE_RE` (`localModelHeuristics.mirror.test.js`), and the bootstrap sequence's body assertions (`bootstrap*.test.js`). A pure module the browser needs is imported by the client rather than mirrored, so no client↔server copy test should need these: `stripCommentsAndNormalize` (so per-side commentary may diverge but logic may not), `extractDeclaration(src, name)` (balanced `{}`/`()`/`[]` walk over `function` / `async function` / `const`), and `compareDeclaration(serverSrc, clientSrc, name)`. Use these instead of hand-rolling a brace-walker per mirror. Pure — no `vitest` import — so callers own the assertions. || `mockPathsDataRoot.js` | Shared Vitest helpers for `PATHS.data → temp dir` and no-peer record creation guards. || `settingsTestUtil.js` | `bindSettingsFile(dataRoot)` → `writeSettingsFile`/`mergeSettingsFile`: direct settings.json disk writes that also drop the `getSettings()` read cache (dynamic-import reset) so a stale cache can't survive a bypass-`save()` write. || `runtimeEnv.js` | `isTestRunner()` — NODE_ENV=test **or** the VITEST env var, so a run that dropped NODE_ENV is still armed. Dependency-free and deliberately apart from `db.js`, which used to own it: the lowest-level file primitives need the same answer and must not pull in `pg`, and the many suites spelling `vi.mock('../lib/db.js', () => ({ query }))` used to strip it out of the graph for every other consumer. |diff --git a/server/lib/autonomousJobIntervals.js b/server/lib/autonomousJobIntervals.jsindex b772bc17c3..9ddcbea453 100644--- a/server/lib/autonomousJobIntervals.js+++ b/server/lib/autonomousJobIntervals.js@@ -32,9 +32,8 @@ export const ON_DEMAND_INTERVAL = 'on-demand';/*** Available interval options for UI pickers. `ms: null` marks a cadence with no- * recurrence. Mirrored (value/label only) by `JOB_INTERVAL_OPTIONS` in- * `client/src/utils/cronHelpers.js`; the mirror describe in- * `autonomousJobIntervals.test.js` fails when the two drift.+ * recurrence. `JOB_INTERVAL_OPTIONS` in `client/src/utils/cronHelpers.js`+ * imports this registry and projects its value/label fields for both pickers.*/export const INTERVAL_OPTIONS = [{ value: 'hourly', label: 'Every Hour', ms: HOUR },diff --git a/server/lib/autonomousJobIntervals.test.js b/server/lib/autonomousJobIntervals.test.jsindex a4217461ac..a0bc581251 100644--- a/server/lib/autonomousJobIntervals.test.js+++ b/server/lib/autonomousJobIntervals.test.js@@ -1,22 +1,6 @@-/**- * Autonomous-job cadence vocabulary (#6375).- *- * Two contracts that a higher-level test can't pin cheaply:- * - `resolveIntervalMs` must return an explicit no-interval sentinel rather- * than falling through to `DAY`. The fall-through was silent, so only a- * direct assertion catches its return.- * - the client mirror in `client/src/utils/cronHelpers.js` is hand-maintained.- * A row added on one side only would leave a cadence the server accepts- * invisible in the picker (or a picker row the Zod enum rejects), so the- * mirror is compared by reading the client source rather than importing it- * (a server test that imports a client module breaks CI dependency-wise).- */+/** Autonomous-job cadence resolution and no-clock compatibility contracts. */import { describe, it, expect } from 'vitest';-import { readFileSync } from 'node:fs';-import { resolve, dirname } from 'node:path';-import { fileURLToPath } from 'node:url';-import { extractDeclaration } from './mirrorParity.js';// Declared here rather than imported from fileUtils: this suite's whole point is// that autonomousJobIntervals.js stays import-free, and pulling fileUtils in@@ -31,9 +15,6 @@ import {resolveIntervalMs} from './autonomousJobIntervals.js';-const HERE = dirname(fileURLToPath(import.meta.url));-const CLIENT_PATH = resolve(HERE, '../../client/src/utils/cronHelpers.js');-describe('resolveIntervalMs', () => {it('returns the no-interval sentinel for the on-demand cadence — not DAY, not NaN', () => {const resolved = resolveIntervalMs(ON_DEMAND_INTERVAL);@@ -82,29 +63,3 @@ describe('isOnDemandJob', () => {expect(isOnDemandJob({ interval: ON_DEMAND_INTERVAL, intervalMs: null, cronSchedule: { kind: 'DAILY' } })).toBe(false);});});--describe('client JOB_INTERVAL_OPTIONS mirror', () => {- const clientSrc = readFileSync(CLIENT_PATH, 'utf8');- const clientDecl = extractDeclaration(clientSrc, 'JOB_INTERVAL_OPTIONS');-- // Parses `{ value: X, label: 'Y' }` rows — X is a quoted literal for most- // rows and the ON_DEMAND_INTERVAL identifier for the on-demand one.- const ROW_RE = /\{\s*value:\s*(?:'([^']+)'|([A-Z_][A-Z0-9_]*))\s*,\s*label:\s*'([^']+)'\s*\}/g;- const clientRows = [...(clientDecl ?? '').matchAll(ROW_RE)].map(m => ({- value: m[1] ?? (m[2] === 'ON_DEMAND_INTERVAL' ? ON_DEMAND_INTERVAL : m[2]),- label: m[3]- }));-- it('finds the client declaration and parses every row', () => {- expect(clientDecl, 'client cronHelpers.js is missing JOB_INTERVAL_OPTIONS').not.toBeNull();- expect(clientRows.length).toBe(INTERVAL_OPTIONS.length);- });-- it('carries the same values and labels, in the same order, as the server list', () => {- expect(clientRows).toEqual(INTERVAL_OPTIONS.map(({ value, label }) => ({ value, label })));- });-- it('declares the on-demand cadence with the same string the server validates', () => {- expect(clientSrc).toContain(`export const ON_DEMAND_INTERVAL = '${ON_DEMAND_INTERVAL}';`);- });-});