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

chore: catalog the three new server/lib leaves in the barrel and README (#6818)

[._.]/ Adam Eivy7a15521420e9
diff --git a/server/lib/README.md b/server/lib/README.md
index 140e3028dc..d7d6f19068 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -155,6 +155,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `creativeDirectorPresets.js` | Locked-at-creation aspect ratio + quality presets for the Creative Director. |
| `creativeLatitude.js` | The IP-latitude clause every creative LLM request carries (`withCreativeLatitude`, `CREATIVE_LATITUDE_TOKENS`), plus the one creative-vs-operational table both stamp keys are matched against (`isCreativeStage` for stage names, `isCreativeRunSource` for run `source` tags). |
| `universeBibleCompleteness.js` | Is a universe bible entry actually described? The shared per-kind expand-field vocabulary (`BIBLE_EXPAND_FIELDS`, `BIBLE_CORE_FIELDS`) and the `core`/`full` completeness predicates the quota-burn describe job scans with. Pure. |
+| `universeBibleLimits.js` | Universe bible field size limits shared between server (sanitizer, pipeline) and client (form inputs). |
| `universeMarkdown.js` | Pure deterministic Universe Builder world-bible export: `universeToMarkdown(record)` plus safe Markdown download filename helpers. |
| `universePromptRenderers.js` | Renderers that turn a universe's `categories` map + canon into prompt context, including the authored character-engine block and the shared story canon digest. |
| `universeVisualStyle.js` | The style a universe contributes to an IMAGE prompt: `buildVisualStyleClause(universe, {override, mode})` (curated `influences.embrace` tokens + a series `stylePromptOverride`, NEVER the free-text `styleNotes`, which is writing-stage direction), `universeAestheticLine` (the labeled variant canon sheet/LoRA renders lead with), `universeVisualStyleTokens`, `splitPromptTokens`, `stripStyleClause(text, clause)` (removes the copy the browser already prefixed, so the compiler keeps the LEADING one — matched on the joined clause so a token with its own punctuation like `M.C. Escher` still matches) and `mergeNegativePromptTokens` (token-level union of comma-joined negatives). |
@@ -490,6 +491,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and
| `spacedRepetition.js` | The shared SM-2-inspired review scheduler, extracted from `services/meatspacePostMemory.js` when SongBook practice became its second consumer (#4102). One four-field schedule shape (`{ ease, intervalDays, nextReview, lastReviewed }`, no `repetitions` counter — the 0 → 1 → 6 → `round(prev * ease)` ladder derives from the previous interval, so a schedule round-trips through import/export/federation on those four fields alone). `advanceSchedule(schedule, ratio, now)` is the core (ease clamped to `MIN_EASE`..`MAX_EASE`, interval capped at `MAX_INTERVAL_DAYS` so `new Date(now + interval*DAY)` can't overflow into an Invalid Date; quality < 3 zeroes the interval to resurface the record but still applies the ease penalty). `mergeScheduleAdvance(prev, advanced, now)` gates interval GROWTH to once per review day (a shrink always applies) for UIs that submit per chunk/section; `isSameReviewDay` is that gate's own predicate, reusable by callers gating their own once-a-day progression. `scheduleOrDefault(record, schedule?)` is the read-path fallback — a record with no schedule derives one anchored to its `updatedAt`/`createdAt` (stable and in the past → due now), so "due" can't flap between two reads a millisecond apart. `ratioToQuality` / `qualityToRatio` are exact inverses over the integers, so a self-graded 0..5 review lands on the quality the user picked. `isScheduleDue` treats an absent/unparseable `nextReview` as due — a record we can't schedule is one to surface, never one to hide forever. Pure. |
| `songPractice.js` | SongBook repertoire practice scheduling (#4102) — the pure core behind `POST /api/brain/songbook/:id/practice`. `applySongPractice(song, quality, now)` → `{ stage, practice }`, the exact partial to hand `brainStorage.updateWith`: it advances the shared `spacedRepetition` schedule from a 0..5 self-grade and moves the song's `stage` along `SONG_STAGE_ORDER` (≥ `SONG_PROMOTE_MIN_QUALITY` promotes, ≤ `SONG_REGRESS_MAX_QUALITY` regresses, a 3 holds). Promotion is gated to once per practice day (regression never is), and a practiced song floors at `learning` — `new` means "never picked up", which stops being true after one session. `songPracticeOrDefault(song)` derives the schedule on READ for every song predating the feature (nothing is backfilled to disk: a migration would restamp `updatedAt` on every record and spray federation churn, and would break the `data.reference/` seeds' byte-identity). `nextSongStage` no-ops on a stage this install doesn't recognize, so a practice log can't rewrite a value synced from a newer peer. `isSongDue(song, now)` mirrors the client's `songDueAt` in `client/src/components/songbook/constants.js`. Pure. |
| `postTopics.js` | Pure POST practice-topic registry — `POST_TOPICS` (`{ id, label, module, surface, drillTypes }`) is the single source of truth for "what am I studying?", plus `resolveTopicForDrillType` / `isTopicEnabled` / `isMemoryItemEnabled`. Gates session composition and recommendations, including Memory's composed and dedicated practice routes plus standalone Morse. A pure leaf: the client's post `constants.js` re-exports it and layers the UI-only `TOPIC_UI` on top. |
+| `postScoring.js` | Scoring and accuracy helpers for post-training drill types shared between server (`services/meatspacePost.js`) and client (`components/meatspace/post/constants.js`) — `nBackBalancedAccuracy` (balanced signal-detection accuracy for n-back questions). |
| `postRotation.js` | Pure deterministic day-based rotation for POST practice selection — `shuffleForDay` supplies a stable pseudorandom daily mix; `orderByRecencyRotation` sorts candidates fresh-before-recently-practiced, then by priority, and rotates equivalent ones by local day so a tier never pins to one drill. Mirrored at `client/src/lib/postRotation.js`. |
| `postStreak.js` | Pure DST-safe POST practice-streak math — the single `computePostStreaks` implementation shared by scored sessions and the training log, plus `computeUnifiedStreak` (a day is active with EITHER a session or a practice entry), `normalizeYmd` (day-key prefix for a date that may be a full ISO timestamp), and `recordDayKey` / `withDerivedDayKeys` (re-derive a record's day key from its `startedAt`/`completedAt`/`timestamp` instant, so readers ignore a `date` frozen in a previously-configured timezone). |
| `activeDays.js` | Cross-domain "days active" set math (#4120) — `unionActiveDayKeys(sources, timezone)` unions several domains' stored date values into one sorted array of user-local `YYYY-MM-DD` keys (`.length` is the honest day count; summing per-domain counts would double-count any day logged in two domains), and `toUserDayKey(value, timezone)` is its per-value normalizer. Owns the day-boundary reconciliation between POST (stamps `userLocalToday()`) and the health logs (stamp the server-local `getDateString()`): a value carrying an INSTANT (the pre-#2681 full-ISO shape some legacy training entries still store) is re-keyed into the user's timezone rather than `split('T')[0]`'d to the UTC day, while a value that is already a bare day LABEL is taken as authored — there is no instant left to re-derive from, so retro-normalizing stored health keys is out of scope by construction, not by omission. Non-day values are dropped rather than coerced. Pure. |
@@ -632,6 +634,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and
| `providerTypes.js` | Pure shared `isCliProvider`, `isTuiProvider`, `isApiProvider`, `isProcessProvider`, and type-gated `isClaudeHarnessProvider` predicates. |
| `videoTimelineFades.js` | Browser-safe `fitFades()` proportionally fits a fade pair to its visible duration. Shared by timeline normalization/export and the editor preview/trim controls; legacy import paths re-export it. |
+| `voiceEcho.js` | Pure voice-echo detection helpers — tokenization, trigram building, thresholds shared by server and client echo gates. |
| `voiceEngines.js` | Shared TTS engine IDs, display metadata, supported-engine set, and persisted configuration keys. |
| `auditQuality.js` | Category discovery strategies, assessment prompt and strict schema, sentinel parsing, and freshness-aware app quality aggregation with deterministic latest-per-category selection across peers. |
diff --git a/server/lib/index.js b/server/lib/index.js
index 6805912f48..e1dbc31956 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -139,6 +139,7 @@ export * from './castIntegrityPrompt.js';
// back-compat — namespace it so the canonical scenePrompt export wins flat.
export * as storyBible from './storyBible.js';
export * from './universeBibleCompleteness.js';
+export * from './universeBibleLimits.js';
export * from './universeMarkdown.js';
export * from './universePromptRenderers.js';
export * from './universeVisualStyle.js';
@@ -472,6 +473,7 @@ export * from './postMultiplicationLadder.js';
export * from './postPowersLadder.js';
export * from './postProgression.js';
export * from './postRotation.js';
+export * from './postScoring.js';
export * from './postStreak.js';
export * from './activeDays.js';
export * from './postTopics.js';
@@ -614,6 +616,8 @@ export * from './creativeDirectorVideoCompiler.js';
export * from './providerTypes.js';
export * from './notificationTypes.js';
export * from './videoTimelineFades.js';
+// `tokenize` collides with `bm25.js`'s own tokenizer — namespaced like `runners`.
+export * as voiceEcho from './voiceEcho.js';
export * from './voiceEngines.js';
export * from './auditQuality.js';