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

Merge remote-tracking branch 'origin/main' into claim/issue-2176

Adam Eivy649945f34d7f
diff --cc .changelog/NEXT.md
index 4e3c7e6240,29d6f058f4..5c60928ba3
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@@ -1,6 -1,6 +1,7 @@@
# Unreleased Changes
+- **[issue-2176] Foundation-quality gate in Series Autopilot (CWQE Phase 11) — judge the world/characters/arc BEFORE drafting.** Autopilot previously verified only arc *structure* (`verifyArc`) and then drafted against a completely unscored universe and cast, so a thin magic system or a flat-Lie protagonist sailed into the expensive text stages and the editorial phase paid to detect problems that were cheap to fix up front. A new `foundationGate` step now runs after arc/episode generation + arc verify and BEFORE beat sheets: a calibrated LLM judge (`pipeline-judge-foundation`, writer/judge split off `pipeline-arc-overview` via `resolveJudgeForStage`) scores the whole foundation against a weighted rubric mirroring the Phase 10 doctrine — **worldbuilding 40%, character 30%, structure 20%, craft 10%** — naming a gap AND a fix per dimension under an anti-inflation calibration ladder. A bounded improve loop (mirrors `verifyArc`/`arcVerify`: `MAX_FOUNDATION_ROUNDS`=3, divergence guard, per-round cos-budget charge) targets the highest-leverage weakest dimension and applies the fix through the OWNING service — universe world refine (`expandWorldTemplate`→`updateUniverse`, echoing locked entries) for worldbuilding/craft, `expandUniverseCharacter` on the thinnest unlocked character for character, arc resolve (`resolveVerifyIssues`) for structure — never a raw write, `force:false` everywhere so human-locked canon is a constraint, not a fix target. The run proceeds to `beatSheet` once the weighted score clears a configurable threshold (default 7.5); on non-convergence (ran out of rounds, stopped improving, or the weakest dimension can't be auto-fixed) it pauses with the residual per-dimension findings for human review — the same failure contract as the arc/editorial gates. The judged inputs (universe canon + character records + arc) are content-hash-pinned on the snapshot, so an already-clean foundation re-reached after unrelated steps returns the cached verdict with no LLM call and can't loop. Config surface (enable flag default ON, threshold, max rounds) is per-run and persisted (`pipelineEditorialChecks`), overridable from the Autopilot Options drawer, and Zod-validated on both the settings and start-run paths. (`server/services/pipeline/foundationJudge.js`, `server/services/pipeline/seriesAutopilot.js`, `data.reference/prompts/stages/pipeline-judge-foundation.md`, `data.reference/prompts/stage-config.json`, `server/lib/pipelineValidation.js`, `server/routes/pipeline/autopilot.js`, `client/src/components/pipeline/AutopilotPanel.jsx`)
+ - **[issue-2156] Digital-twin enrichment from observed behavior — taste + chronotype evidence (Human Activity Tracking Phase 7).** The second federated output of the activity timeline: the Digital Twin now learns from what you actually listen to, watch, and when you're active — LLM-free — instead of only from questionnaires. A new `server/services/twinEnrichment.js` rolls up `media.listen`/`media.watch` events into a **taste-profile evidence record** (`data/digital-twin/taste-observed.json`): top artists, genres, channels, and topics per week + month, with a novelty-vs-repeat ratio (distinct plays ÷ total). An hourly activity histogram (outbound messages, meetings, media by **local** hour — received messages are excluded as they reflect others' timing) produces a **chronotype evidence record** (`chronotype-observed.json`) with per-category peak hours and an observed morning/intermediate/evening classification derived from a circular-mean center-of-mass (so a midnight-wrapping night owl isn't averaged to noon). Every evidence record carries `source: 'observed'` provenance and lives beside — never overwrites — the stated questionnaire/genome records; the two are kept in separate files and the Taste tab surfaces both, flagging stated-vs-observed chronotype divergence as **signal, not error** (an underived default chronotype is treated as "no stated value" so it can't fake a divergence). Both evidence files federate via `digital-twin-sync.js` as LWW-on-`derivedAt` (newest observation wins wholesale; a peer that sends none can't blank the local record). Aggregation is deterministic and provider-free, so it runs with no consent — incrementally after each Spotify/YouTube sync (a self-guarded `refreshTwinEvidenceAfterSync()` hook fired only when new events landed) and on a daily backstop rollup (`twinEnrichmentScheduler.js`, started from `server/index.js`). The ONLY provider call is an explicit **"What does this say about me?"** button on the Taste tab that names the provider before running (per the AI policy — no cold-bootstrap LLM calls) and persists the narrative onto the evidence record without touching the numbers. New Zod-validated routes: `GET /twin-evidence`, `POST /twin-evidence/recompute` (LLM-free), `POST /twin-evidence/interpret` (explicit). (`server/services/twinEnrichment.js`, `server/services/twinEnrichmentScheduler.js`, `server/services/digital-twin-sync.js`, `server/services/{spotifySync,youtubeSync}.js`, `server/routes/digital-twin.js`, `server/lib/digitalTwinValidation.js`, `server/index.js`, `client/src/components/digital-twin/ObservedTasteEvidence.jsx`, `client/src/components/digital-twin/tabs/TasteTab.jsx`, `client/src/services/apiDigitalTwin.js`)
- **[issue-2155] Daily-log auto-drafts from the activity timeline (Human Activity Tracking Phase 6).** An evening scheduled job drafts a "what actually happened today" section into that day's Brain daily log — the first federated output of the activity timeline. `server/services/activityDigest.js` summarizes a day's `human_activity_events` (conversations grouped with sent/received tallies, meetings with attendee names, media consumed — tribe-person names resolved from participants + the tribe registry) into a deterministic structured bullet list. That list is useful on its own AND is the template fed to an LLM: when the user has configured a provider/model, an opt-in narrative is generated on top of the bullets; otherwise the structured summary ships with **zero provider calls**. Per the AI policy the feature is silent until enabled — a dedicated scheduler (`activityDigestScheduler.js`, patterned on `brainScheduler.js` with an evening time-of-day trigger + missed-day catch-up, started from `server/index.js`, NOT `taskSchedule.js`) no-ops entirely when disabled and never fires a cold-bootstrap LLM call. The draft is spliced into the journal as a clearly-marked, marker-delimited section via a new `brainJournal.upsertAutoSection()` (rides `brainStorage.upsertWithId` so it federates + re-embeds through `brainMemoryBridge`); user-typed/dictated content and segment history are never touched, and a re-run replaces only the auto section (stable HTML-comment markers via the pure, unit-tested `server/lib/markedSection.js`). A "Draft" button on the Daily Log tab runs it on demand (direct user action — names the provider, no extra consent modal), and the tab's settings drawer gains the enable toggle + provider/model/run-time config. (`server/services/activityDigest.js`, `server/services/activityDigestScheduler.js`, `server/services/brainJournal.js`, `server/lib/markedSection.js`, `server/lib/brainValidation.js`, `server/routes/brainDailyLog.js`, `client/src/components/brain/tabs/DailyLogTab.jsx`, `client/src/services/apiBrain.js`)