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
refactor: derive remaining client copies of server enums (#8445)
[._.]/ Adam Eivy1e6ce970ff72
diff --git a/client/src/components/apps/LayeredIntelligenceTab.jsx b/client/src/components/apps/LayeredIntelligenceTab.jsxindex 4c1a609db2..84c1267908 100644--- a/client/src/components/apps/LayeredIntelligenceTab.jsx+++ b/client/src/components/apps/LayeredIntelligenceTab.jsx@@ -13,8 +13,9 @@ import { cronFromIntervalMs } from '../../utils/cronHelpers';// and the effective-config accessor (server/services/layeredIntelligence.js).// Off by default — the loop is a user-enabled scheduled automation.-// The Layer-1 telemetry toggles the loop can gather. Keep in sync with the-// server `sources` object (custom[] file sources are handled separately below).+// The Layer-1 telemetry toggles the loop can gather — one per key in+// LAYERED_INTELLIGENCE_SOURCE_KEYS (a test enforces it); custom[] file sources+// are handled separately below.export const LI_SOURCE_FIELDS = [{ key: 'goals', label: 'Goals (GOALS.md)', hint: 'The app\'s inferred/authored product goals' },{ key: 'appMetrics', label: 'App metrics (METRICS.md)', hint: 'The app\'s own success metrics — user-success / KPIs / production telemetry it tracks about itself' },diff --git a/client/src/components/apps/LayeredIntelligenceTab.test.jsx b/client/src/components/apps/LayeredIntelligenceTab.test.jsxindex c9434740ef..d54345d539 100644--- a/client/src/components/apps/LayeredIntelligenceTab.test.jsx+++ b/client/src/components/apps/LayeredIntelligenceTab.test.jsx@@ -1,6 +1,7 @@import { describe, it, expect, vi } from 'vitest';import { render, screen, fireEvent } from '@testing-library/react';-import LayeredIntelligenceTab, { buildLayeredIntelligenceUpdate, buildLayeredIntelligenceScheduleUpdate, intervalFieldsFromMs, describeLastRun } from './LayeredIntelligenceTab';+import { LAYERED_INTELLIGENCE_SOURCE_KEYS } from '../../lib/layeredIntelligenceSources.js';+import LayeredIntelligenceTab, { LI_SOURCE_FIELDS, buildLayeredIntelligenceUpdate, buildLayeredIntelligenceScheduleUpdate, intervalFieldsFromMs, describeLastRun } from './LayeredIntelligenceTab';const baseline = {enabled: false,@@ -294,3 +295,9 @@ describe('LayeredIntelligenceTab (render)', () => {expect(onChange).toHaveBeenCalledWith({ sources: expect.objectContaining({ custom: [{ type: 'http', url: '', label: 'notes' }] }) });});});++describe('LI_SOURCE_FIELDS', () => {+ it('has exactly one toggle per server source key, in order', () => {+ expect(LI_SOURCE_FIELDS.map(f => f.key)).toEqual(LAYERED_INTELLIGENCE_SOURCE_KEYS);+ });+});diff --git a/client/src/components/writers-room/labels.js b/client/src/components/writers-room/labels.jsindex bf43a77b6c..054d92674c 100644--- a/client/src/components/writers-room/labels.js+++ b/client/src/components/writers-room/labels.js@@ -1,6 +1,5 @@-// Display labels for Writers Room enums. Keys mirror the canonical enum-// values in server/lib/writersRoomPresets.js — keep in sync when adding kinds-// or statuses there.+// Display labels for Writers Room enums, keyed by the server WORK_KINDS and+// WORK_STATUSES (server/lib/writersRoomPresets.js); labels.test.js enforces parity.export const KIND_LABELS = {novel: 'Novel',diff --git a/client/src/components/writers-room/labels.test.js b/client/src/components/writers-room/labels.test.jsnew file mode 100644index 0000000000..5167212824--- /dev/null+++ b/client/src/components/writers-room/labels.test.js@@ -0,0 +1,14 @@+import { describe, it, expect } from 'vitest';+import { WORK_KINDS, WORK_STATUSES } from '../../lib/writersRoomPresets.js';+import { KIND_LABELS, STATUS_LABELS } from './labels.js';++// A kind or status added server-side without a label here would render raw.+describe('Writers Room labels', () => {+ it('has exactly one label per server work kind', () => {+ expect(Object.keys(KIND_LABELS).sort()).toEqual([...WORK_KINDS].sort());+ });++ it('has exactly one label per server work status', () => {+ expect(Object.keys(STATUS_LABELS).sort()).toEqual([...WORK_STATUSES].sort());+ });+});diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex 4de88cb3b5..18fcda6f9c 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -242,7 +242,10 @@ grep -i "what you want to do" client/src/lib/README.md| `spriteRecordGroups.js` | Grouping + search for the Sprite Manager sidebar's record picker (#2932). `groupSpriteRecords(records)` → ordered `[{ key, label, records }]` under **Characters / Places / Objects** (`props` folded into Objects alongside `object`, no migration). `filterSpriteRecords(records, query, limit=8)` is the autocomplete filter — multi-term (AND) substring over `name`/`id`/`kind`, capped at `limit`. `groupKeyForKind(kind)` maps a kind to its group key (unknown → `objects`). `SPRITE_RECORD_GROUPS` / `NEW_SPRITE_KINDS` back the browse disclosure and the create-panel kind selector. Pure — no React, no I/O; the page owns the per-group icons. || `spriteTrimmer.js` | Pure geometry + source-list math behind the Sprite Manager's Loop Trimmer workspace (#2933). `buildTrimmerSources(walk, assets)` → the ordered animation sources the trimmer can load (every preview-strip run first, then saved trims read from the asset listing), each `{ id, kind: 'run'\|'trim', runId, direction, label, stripPath, frameCount, fps, trimmable }` — every packed-strip run is `trimmable` (layout-agnostic), while saved trims are preview-only, mirroring `spriteCollectionActions`' gate. `stripFrameGeometry(stripPreview)` → `{ frameCount, fps, cellWidth, cellHeight }` with the native 8-phase / 12fps fallback; `phaseLabelFor(index, frameCount)` names the 8 walk phases (bare `frame N` for any other length); `sanitizeTrimSlug(name)` → the server's `[a-z0-9-]+` output slug; `allColumns(n)` / `invertColumns(n, enabled)` for the frame-toggle set. `WALK_PHASES` is the shared phase-label constant (WalkWorkflow imports it here). Also holds the walk-cycle authoring knobs mirrored from `walkBounds.js` — `WALK_DEFAULT_FRAME_COUNT` / `WALK_DEFAULT_FPS`, the `WALK_FRAME_COUNT_OPTIONS` list and `walkFpsOptionsFor(fps)` (splices a current odd fps into the even-step list so the `<select>` never lies) — feeding the shared `CycleTarget` control used by both the walk workflow and the trimmer's re-derive panel (#2980). Pure — no React, no canvas, no I/O. || `spriteWalkUnlock.js` | The user-facing copy for a BLOCKED walk re-open (#3043/#3044), shared by the Walk Cycles header, per-direction cards, and Loop Trimmer so one server-stamped block can never be described two different ways. `walkUnlockCopy(unlock, { mode?, direction? })` → `{ text, action, prompt, acknowledgeNoClips, toast }` for a blocked scope (null when it is not blocked): a blocked-but-`acknowledgeable` scope gets the regeneration offer plus the `acknowledgeNoClips` consent flag its POST carries, a non-acknowledgeable one gets the dead-end explanation and no action. `WALK_UNLOCK_TOAST` is the ordinary unlock success message. Pure — no React, no I/O. |-| `tribe.js` | Pure Tribe domain helpers shared by the Tribe page and its `TribeCircleMap` visualization: `RINGS` (support→core→tribe→village Dunbar rings + the uncapped `external` "outside the tribe" classification — caps, cadence defaults, Tailwind tones + `hex`), `TRIBE_RINGS` (the four inner rings the care queue/capacity/overdue counts operate over, excluding `external`), `ENERGY` (energy tiers + `hex`), `STATUS_HEX` (cadence-status → SVG stroke color), `contactStatus(contact)` (presentation wrapper over the shared `cadenceStatus` — attaches label/tone to the missing/overdue/soon/steady/`external` state) / `daysBetween(date)` (alias of the shared `daysSinceDate`), `ringFor` / `energyFor` lookups, `tagsToArray` / `tagsToInput`, `initialsFor(name)` (node glyph), and the care-state filters shared by the summary tiles / roster / care queue (`STATUS_FILTERS`, `STATUS_FILTER_IDS`, `STATUS_FILTER_LABELS`, `matchesStatusFilter(contact, filter)` — unknown ids degrade to `all`). Ring `cadenceDays` mirror `DEFAULT_RING_CADENCE` in `server/services/tribe.js`; the cadence STATE MACHINE lives in `tribeCadence.js`. |+| `proseExportSettings.js` | Re-export of `server/lib/proseExportSettings.js` — `TRIM_SIZES`, `DEFAULT_TRIM_SIZE`, `INTERIOR_FONTS`, `DEFAULT_INTERIOR_FONT` for the Export page's selects. |+| `layeredIntelligenceSources.js` | Re-export of `server/lib/layeredIntelligenceSources.js` — `LAYERED_INTELLIGENCE_SOURCE_KEYS`, the ordered list of built-in Layer-1 telemetry sources the self-improvement loop can gather. A test requires one `LI_SOURCE_FIELDS` toggle per key. |+| `writersRoomPresets.js` | Re-export of `server/lib/writersRoomPresets.js` — `WORK_KINDS`, `WORK_STATUSES`, `EXERCISE_STATUSES`, `ANALYSIS_KINDS`; `writers-room/labels.test.js` requires a label per value. |+| `tribe.js` | Pure Tribe domain helpers shared by the Tribe page and its `TribeCircleMap` visualization: `RINGS` (support→core→tribe→village Dunbar rings + the uncapped `external` "outside the tribe" classification — caps, cadence defaults, Tailwind tones + `hex`), `TRIBE_RINGS` (the four inner rings the care queue/capacity/overdue counts operate over, excluding `external`), `ENERGY` (energy tiers + `hex`), `STATUS_HEX` (cadence-status → SVG stroke color), `contactStatus(contact)` (presentation wrapper over the shared `cadenceStatus` — attaches label/tone to the missing/overdue/soon/steady/`external` state) / `daysBetween(date)` (alias of the shared `daysSinceDate`), `ringFor` / `energyFor` lookups, `tagsToArray` / `tagsToInput`, `initialsFor(name)` (node glyph), and the care-state filters shared by the summary tiles / roster / care queue (`STATUS_FILTERS`, `STATUS_FILTER_IDS`, `STATUS_FILTER_LABELS`, `matchesStatusFilter(contact, filter)` — unknown ids degrade to `all`). Ring `cadenceDays` come from `DEFAULT_RING_CADENCE` (via `tribeCadence.js`); the cadence STATE MACHINE lives in `tribeCadence.js`. || `tribeCadence.js` | Re-export of `server/lib/tribeCadence.js` — the single authoritative Tribe care-cadence rules shared by the page, the Care dashboard widget, and the server. || `streakGlyph.js` | `streakGlyph(streak)` — the single POST streak emoji (✨ / ⚡ / 🔥 by day count) shared by the POST launcher, Morse trainer, daily widget, and dashboard streak widget. || `syncCounts.js` | Directional pending-sync counts for the Instances federation cards. `directionalCounts({ localMax, peerMax, ourCursor, peerCursorForUs })` → `{ toPull, toPush }` (each a non-negative Number, or `null` when unknown) from monotonic change-log seqs; `diffSeq(ahead, behind)` is the BigInt-safe clamp-at-zero subtraction (handles numeric strings past `MAX_SAFE_INTEGER`); `describeDirectional({ toPull, toPush })` renders the plain-language `{ state, text }` ("in sync" / "N to pull · M to push" / "checking…"). No React — `SyncStatusBadge` drives it. |diff --git a/client/src/lib/index.js b/client/src/lib/index.jsindex ad0ff74c79..7b82dc37c0 100644--- a/client/src/lib/index.js+++ b/client/src/lib/index.js@@ -220,6 +220,9 @@ export * from './threejsEnvironment.js';export * from './threejsExplode.js';export * from './threejsRig.js';export * from './threejsSculpt.js';+export * from './proseExportSettings.js';+export * from './writersRoomPresets.js';+export * from './layeredIntelligenceSources.js';export * from './tribe.js';export * from './quotaBurnPatch.js';export * from './quotaBurnTasks.js';diff --git a/client/src/lib/layeredIntelligenceSources.js b/client/src/lib/layeredIntelligenceSources.jsnew file mode 100644index 0000000000..3344ba80c4--- /dev/null+++ b/client/src/lib/layeredIntelligenceSources.js@@ -0,0 +1,8 @@+/**+ * Layered Intelligence source keys — re-export of server/lib/layeredIntelligenceSources.js.+ *+ * The client and server build their source lists from one canonical definition+ * so they cannot drift. The file stays so every `client/src/lib/layeredIntelligenceSources`+ * import path is unchanged.+ */+export { LAYERED_INTELLIGENCE_SOURCE_KEYS } from '../../../server/lib/layeredIntelligenceSources.js';diff --git a/client/src/lib/proseExportSettings.js b/client/src/lib/proseExportSettings.jsnew file mode 100644index 0000000000..8030d27448--- /dev/null+++ b/client/src/lib/proseExportSettings.js@@ -0,0 +1,12 @@+/**+ * Prose export settings — re-export of server/lib/proseExportSettings.js.+ *+ * The client and server share the trim-size and font enums so they cannot drift.+ * The file stays so every `client/src/lib/proseExportSettings` import path is unchanged.+ */+export {+ TRIM_SIZES,+ DEFAULT_TRIM_SIZE,+ INTERIOR_FONTS,+ DEFAULT_INTERIOR_FONT,+} from '../../../server/lib/proseExportSettings.js';diff --git a/client/src/lib/tribe.js b/client/src/lib/tribe.jsindex e17d2b298d..79ff7b416e 100644--- a/client/src/lib/tribe.js+++ b/client/src/lib/tribe.js@@ -1,14 +1,14 @@// Pure Tribe domain helpers shared by the Tribe page and its circle-map// visualization. Rings are Dunbar-inspired concentric circles (support is the// innermost / closest, village the outermost / weak ties). The ring `cadenceDays`-// defaults mirror DEFAULT_RING_CADENCE in server/services/tribe.js — keep in sync.+// defaults are DEFAULT_RING_CADENCE from the shared `tribeCadence.js`.//// The cadence STATE MACHINE (external/missing/overdue/soon/steady) lives in the// shared, authoritative `tribeCadence.js` (mirrored from server/lib/tribeCadence.js)// so the page, the Tribe Care dashboard widget, and the proactive-alert check all// route through one implementation. `contactStatus` below only layers presentation// (label/tone) on top of that shared `cadenceStatus` — do not re-implement the rules.-import { cadenceStatus, daysSinceDate } from './tribeCadence.js';+import { cadenceStatus, daysSinceDate, DEFAULT_RING_CADENCE } from './tribeCadence.js';// The four inner rings are the Dunbar tribe (capped, care-cadenced). `external` is// a fifth, uncapped classification OUTSIDE the tribe — people known or previously@@ -16,11 +16,11 @@ import { cadenceStatus, daysSinceDate } from './tribeCadence.js';// carries no care cadence (`cap: null`, and `contactStatus` returns an 'external'// state instead of overdue/soon), and the UI keeps it out of the care queue.export const RINGS = [- { id: 'support', label: 'Support', cap: 5, cadenceDays: 7, tone: 'text-rose-300', bg: 'bg-rose-500/10', border: 'border-rose-500/30', hex: '#fda4af' },- { id: 'core', label: 'Core', cap: 15, cadenceDays: 21, tone: 'text-amber-300', bg: 'bg-amber-500/10', border: 'border-amber-500/30', hex: '#fcd34d' },- { id: 'tribe', label: 'Tribe', cap: 50, cadenceDays: 45, tone: 'text-teal-300', bg: 'bg-teal-500/10', border: 'border-teal-500/30', hex: '#5eead4' },- { id: 'village', label: 'Village', cap: 150, cadenceDays: 90, tone: 'text-sky-300', bg: 'bg-sky-500/10', border: 'border-sky-500/30', hex: '#7dd3fc' },- { id: 'external', label: 'External', cap: null, cadenceDays: 365, tone: 'text-slate-400', bg: 'bg-slate-500/10', border: 'border-slate-500/30', hex: '#94a3b8' },+ { id: 'support', label: 'Support', cap: 5, cadenceDays: DEFAULT_RING_CADENCE.support, tone: 'text-rose-300', bg: 'bg-rose-500/10', border: 'border-rose-500/30', hex: '#fda4af' },+ { id: 'core', label: 'Core', cap: 15, cadenceDays: DEFAULT_RING_CADENCE.core, tone: 'text-amber-300', bg: 'bg-amber-500/10', border: 'border-amber-500/30', hex: '#fcd34d' },+ { id: 'tribe', label: 'Tribe', cap: 50, cadenceDays: DEFAULT_RING_CADENCE.tribe, tone: 'text-teal-300', bg: 'bg-teal-500/10', border: 'border-teal-500/30', hex: '#5eead4' },+ { id: 'village', label: 'Village', cap: 150, cadenceDays: DEFAULT_RING_CADENCE.village, tone: 'text-sky-300', bg: 'bg-sky-500/10', border: 'border-sky-500/30', hex: '#7dd3fc' },+ { id: 'external', label: 'External', cap: null, cadenceDays: DEFAULT_RING_CADENCE.external, tone: 'text-slate-400', bg: 'bg-slate-500/10', border: 'border-slate-500/30', hex: '#94a3b8' },];// Rings inside the active tribe (everything except `external`) — the set the carediff --git a/client/src/lib/tribeCadence.js b/client/src/lib/tribeCadence.jsindex 86ffd91307..943bed7dbc 100644--- a/client/src/lib/tribeCadence.js+++ b/client/src/lib/tribeCadence.js@@ -8,6 +8,7 @@export {DEFAULT_CADENCE_DAYS,SOON_WINDOW_DAYS,+ DEFAULT_RING_CADENCE,cadenceStatus,daysSinceDate,} from '../../../server/lib/tribeCadence.js';diff --git a/client/src/lib/writersRoomPresets.js b/client/src/lib/writersRoomPresets.jsnew file mode 100644index 0000000000..a0977297dc--- /dev/null+++ b/client/src/lib/writersRoomPresets.js@@ -0,0 +1,7 @@+/**+ * Writers Room presets — re-export of server/lib/writersRoomPresets.js.+ *+ * The client and server share the work kind and status enums so they cannot drift.+ * The file stays so every `client/src/lib/writersRoomPresets` import path is unchanged.+ */+export { WORK_KINDS, WORK_STATUSES, EXERCISE_STATUSES, ANALYSIS_KINDS } from '../../../server/lib/writersRoomPresets.js';diff --git a/client/src/pages/PipelineExport.jsx b/client/src/pages/PipelineExport.jsxindex 6247951800..7fbd9fccbe 100644--- a/client/src/pages/PipelineExport.jsx+++ b/client/src/pages/PipelineExport.jsx@@ -28,26 +28,38 @@ import {import { useAsyncAction } from '../hooks/useAsyncAction';import { normalizeImage, normalizeVideo } from '../components/media/normalize';import AttributionList from '../components/media/AttributionList';+import { TRIM_SIZES, DEFAULT_TRIM_SIZE, INTERIOR_FONTS, DEFAULT_INTERIOR_FONT } from '../lib/proseExportSettings.js';-// Kept in sync with server/lib/proseExportSettings.js (allow-lists + defaults).-const TRIM_SIZE_OPTIONS = [- { value: 'us-trade', label: 'US Trade (6" × 9")' },- { value: 'digest', label: 'Digest (5.5" × 8.5")' },- { value: 'mass-market', label: 'Mass Market (4.25" × 6.75")' },- { value: 'us-letter', label: 'US Letter (8.5" × 11")' },- { value: 'a5', label: 'A5' },-];-const FONT_OPTIONS = [- { value: 'times', label: 'Times (serif)' },- { value: 'helvetica', label: 'Helvetica (sans)' },- { value: 'courier', label: 'Courier (mono)' },-];-const DEFAULT_TRIM = 'us-trade';-const DEFAULT_FONT = 'times';+// Client labels for the server TRIM_SIZES and INTERIOR_FONTS (via+// lib/proseExportSettings.js); a test asserts every server value has a label.+export const TRIM_SIZE_LABELS = {+ 'us-trade': 'US Trade (6" × 9")',+ 'digest': 'Digest (5.5" × 8.5")',+ 'mass-market': 'Mass Market (4.25" × 6.75")',+ 'us-letter': 'US Letter (8.5" × 11")',+ 'a5': 'A5',+};++export const FONT_LABELS = {+ 'times': 'Times (serif)',+ 'helvetica': 'Helvetica (sans)',+ 'courier': 'Courier (mono)',+};++// Build select options from server enums with client labels+const TRIM_SIZE_OPTIONS = Object.entries(TRIM_SIZES).map(([value]) => ({+ value,+ label: TRIM_SIZE_LABELS[value],+}));++const FONT_OPTIONS = INTERIOR_FONTS.map((value) => ({+ value,+ label: FONT_LABELS[value],+}));const emptyForm = {- trimSize: DEFAULT_TRIM,- interiorFont: DEFAULT_FONT,+ trimSize: DEFAULT_TRIM_SIZE,+ interiorFont: DEFAULT_INTERIOR_FONT,titlePageTitle: '',titlePageSubtitle: '',titlePageAuthor: '',@@ -61,8 +73,8 @@ const emptyForm = {const formFromSeries = (series) => {const es = series?.exportSettings || {};return {- trimSize: es.trimSize || DEFAULT_TRIM,- interiorFont: es.interiorFont || DEFAULT_FONT,+ trimSize: es.trimSize || DEFAULT_TRIM_SIZE,+ interiorFont: es.interiorFont || DEFAULT_INTERIOR_FONT,titlePageTitle: es.titlePageTitle || series?.name || '',titlePageSubtitle: es.titlePageSubtitle || series?.logline || '',titlePageAuthor: es.titlePageAuthor || series?.author || '',diff --git a/client/src/pages/PipelineExport.test.jsx b/client/src/pages/PipelineExport.test.jsxnew file mode 100644index 0000000000..3c04fdce8f--- /dev/null+++ b/client/src/pages/PipelineExport.test.jsx@@ -0,0 +1,14 @@+import { describe, it, expect } from 'vitest';+import { TRIM_SIZES, INTERIOR_FONTS } from '../lib/proseExportSettings.js';+import { TRIM_SIZE_LABELS, FONT_LABELS } from './PipelineExport.jsx';++// A trim size or font added server-side without a label here would render a blank option.+describe('PipelineExport labels', () => {+ it('has exactly one label per server trim size', () => {+ expect(Object.keys(TRIM_SIZE_LABELS).sort()).toEqual(Object.keys(TRIM_SIZES).sort());+ });++ it('has exactly one label per server interior font', () => {+ expect(Object.keys(FONT_LABELS).sort()).toEqual([...INTERIOR_FONTS].sort());+ });+});diff --git a/server/lib/README.md b/server/lib/README.mdindex 966f8a3cc4..5c4850ea1a 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -743,6 +743,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `kilo.js` | Kilo Code command identity (`kilo`/`kilocode`), `run` headless argv, `--auto` approval posture, and TUI arguments. || `openchamber.js` | OpenChamber control-CLI identity, `session create` headless argv, `provider/model` gate, and `--dir`/`--prompt` spawn-time delivery. || `layaMlx.js` | Pinned Laya-MLX experiment model, request validation and probability normalization; entropy confidence stays distinct from entailment. |+| `layeredIntelligenceSources.js` | `LAYERED_INTELLIGENCE_SOURCE_KEYS` — the ordered list of built-in Layer-1 telemetry sources the self-improvement loop can gather. Used by server schema and client UI to build source lists from one canonical definition. Pure leaf: no Node built-in, nothing outside `server/lib`. Re-exported by `client/src/lib/layeredIntelligenceSources.js`. || `persistentMindMaintainer.js` | Machine-local maintainer intent, inference allowance schema, normalization and additive wake charter; never grants authority. |diff --git a/server/lib/index.js b/server/lib/index.jsindex 29cb200c6b..798c466c3f 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -724,6 +724,7 @@ export * from './kilo.js';export * from './openchamber.js';export * from './layaMlx.js';+export * from './layeredIntelligenceSources.js';export * from './persistentMindMaintainer.js';diff --git a/server/lib/layeredIntelligenceSources.js b/server/lib/layeredIntelligenceSources.jsnew file mode 100644index 0000000000..bf68a887c2--- /dev/null+++ b/server/lib/layeredIntelligenceSources.js@@ -0,0 +1,34 @@+/**+ * Layered Intelligence source keys — the built-in Layer-1 telemetry toggles the+ * self-improvement loop can gather, in the order the app config tab lists them.+ * Custom sources are a separate array (`sources.custom`, discriminated on type).+ *+ * `layeredIntelligenceConfigSchema` in validation.js builds its `sources` object+ * from this list, and `client/src/lib/layeredIntelligenceSources.js` re-exports+ * it so a client test can require one LI_SOURCE_FIELDS entry per key. Keep it+ * pure: no Node built-in, nothing outside `server/lib`.+ */+export const LAYERED_INTELLIGENCE_SOURCE_KEYS = [+ 'goals',+ // The app's own success/performance metrics doc (METRICS.md in the app repo).+ // Default on: the primary signal for judging a managed app against its goals.+ 'appMetrics',+ 'cosMetrics',+ 'healthReport',+ 'planMd',+ 'openIssues',+ // The committed backlog (#2698): `plan`-labeled tracker issues / the+ // prioritized Jira backlog / PLAN.md's unchecked items, fed in so the reasoner+ // can suppress a proposal that overlaps work already in scope. Default on.+ 'plannedWork',+ // PortOS-only product-success signals (POST engagement and creative+ // commission feedback). Managed apps use appMetrics/custom sources.+ 'productMetrics',+ // Feedback loop (#2428): feed past LI proposals + their tracker outcomes back+ // into the reasoning prompt. Default on for PortOS, off for managed apps.+ 'outcomes',+ // Self-evaluation (#2700): fold LI's own merge rate, already-filed proposal+ // count, and agent-run health back into the prompt so the loop can judge its+ // proposal quality before filing. Default on for PortOS, off for managed apps.+ 'selfEval',+];diff --git a/server/lib/tribeCadence.js b/server/lib/tribeCadence.jsindex 9b867c31e0..12650d3c64 100644--- a/server/lib/tribeCadence.js+++ b/server/lib/tribeCadence.js@@ -12,6 +12,22 @@ export const DEFAULT_CADENCE_DAYS = 45;// A member with <= this many days left before their next check-in is "soon".export const SOON_WINDOW_DAYS = 7;+// Default check-in cadence (days) per ring. Used by server/services/tribe.js+// to set default cadence_days when creating new people, and mirrored on the+// client in `client/src/lib/tribe.js` (the RINGS array's `cadenceDays`).+// The SQL column default is a flat 45 (`cadence_days` in db.js / init-db.sql)+// because the ring-aware default is resolved here before insert.+export const DEFAULT_RING_CADENCE = {+ support: 7,+ core: 21,+ tribe: 45,+ village: 90,+ // `external` is for people outside the active tribe (former contacts, a nemesis):+ // no care cadence is owed, so this default is a neutral yearly nudge and the UI+ // excludes external people from the care queue entirely.+ external: 365,+};+// Whole days from an ISO date (YYYY-MM-DD…) to today, or null when unparseable.export function daysSinceDate(dateStr) {if (!dateStr) return null;diff --git a/server/lib/validation.js b/server/lib/validation.jsindex da316679ff..802c2f8d7c 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -13,6 +13,7 @@ export const gitDeleteBranchBodySchema = z.object({import { ServerError } from './errorHandler.js';import { partialWithoutDefaults, emptyToUndefined, emptyToNull, optionalBooleanMap, presetProviderIdSchema, providerRefSchema } from './zodCompat.js';import { WORK_TRACKERS } from './workTracker.js';+import { LAYERED_INTELLIGENCE_SOURCE_KEYS } from './layeredIntelligenceSources.js';import { PROVIDER_FAMILY_IDS } from './providerFamilies.js';import { APP_FEATURE_IDS, INSTANCE_FEATURE_IDS, INSTANCE_FEATURE_GROUP_IDS } from './instanceFeatureRegistry.js';import { MAX_MONTHLY_COST } from './subscriptionSavings.js';@@ -166,28 +167,9 @@ export const layeredIntelligenceConfigSchema = z.object({providerId: providerRefSchema.nullable().optional(),model: z.string().nullable().optional(),sources: z.object({- goals: z.boolean().optional(),- // The app's own success/performance metrics doc (METRICS.md in the app repo).- // Default on: the primary signal for judging a managed app against its goals.- appMetrics: z.boolean().optional(),- cosMetrics: z.boolean().optional(),- healthReport: z.boolean().optional(),- planMd: z.boolean().optional(),- openIssues: z.boolean().optional(),- // The committed backlog (#2698): `plan`-labeled tracker issues / the- // prioritized Jira backlog / PLAN.md's unchecked items, fed in so the reasoner- // can suppress a proposal that overlaps work already in scope. Default on.- plannedWork: z.boolean().optional(),- // PortOS-only product-success signals (POST engagement and creative- // commission feedback). Managed apps use appMetrics/custom sources.- productMetrics: z.boolean().optional(),- // Feedback loop (#2428): feed past LI proposals + their tracker outcomes back- // into the reasoning prompt. Default on for PortOS, off for managed apps.- outcomes: z.boolean().optional(),- // Self-evaluation (#2700): fold LI's own merge rate, already-filed proposal- // count, and agent-run health back into the prompt so the loop can judge its- // proposal quality before filing. Default on for PortOS, off for managed apps.- selfEval: z.boolean().optional(),+ // One optional toggle per built-in Layer-1 source; the ordered key list (and+ // what each source means) lives in layeredIntelligenceSources.js.+ ...Object.fromEntries(LAYERED_INTELLIGENCE_SOURCE_KEYS.map(key => [key, z.boolean().optional()])),// Custom Layer-1 sources. Discriminated on `type`: a repo-relative `file`,// an `http`(s) URL, or a shell `cmd`. All three carry an optional display// `label`. gatherSources also re-enforces the file confinement + thediff --git a/server/services/tribe.js b/server/services/tribe.jsindex 6783daa98c..b97a54c3d7 100644--- a/server/services/tribe.js+++ b/server/services/tribe.js@@ -15,25 +15,10 @@import { v4 as uuidv4 } from '../lib/uuid.js';import { ensureSchema, query, withTransaction } from '../lib/db.js';import { ServerError } from '../lib/errorHandler.js';-import { cadenceStatus } from '../lib/tribeCadence.js';+import { cadenceStatus, DEFAULT_RING_CADENCE } from '../lib/tribeCadence.js';import { buildPersonMatchIndex, matchPeople, normalizeIdentifier, normalizePhone } from '../lib/tribeMatch.js';import * as calendarSync from './calendarSync.js';-// Default check-in cadence (days) per ring. Mirrored on the client in-// `client/src/pages/Tribe.jsx` (the RINGS array's `cadenceDays`); the SQL column-// default is a flat 45 (`cadence_days` in db.js / init-db.sql) because the-// ring-aware default is resolved here before insert. Keep all three in sync.-export const DEFAULT_RING_CADENCE = {- support: 7,- core: 21,- tribe: 45,- village: 90,- // `external` is for people outside the active tribe (former contacts, a nemesis):- // no care cadence is owed, so this default is a neutral yearly nudge and the UI- // excludes external people from the care queue entirely.- external: 365,-};-export function isoDate(value) {if (!value) return null;if (value instanceof Date) return value.toISOString().slice(0, 10);diff --git a/server/services/tribe.test.js b/server/services/tribe.test.jsindex ded07539a2..f10b871c98 100644--- a/server/services/tribe.test.js+++ b/server/services/tribe.test.js@@ -24,10 +24,10 @@ import {personCadenceStatus,getCareSummary,autoLogTouchpoints,- DEFAULT_RING_CADENCE,findDuplicateTribeIdentifiers,checkDuplicateTribeIdentifiers,} from './tribe.js';+import { DEFAULT_RING_CADENCE } from '../lib/tribeCadence.js';// ISO date (YYYY-MM-DD) `n` whole days before local today.function daysAgo(n) {