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 pull request #2272 from atomantic/claim/issue-2262

[._.]/ Adam Eivy6ce4306b6c56
diff --cc .changelog/NEXT.md
index d2ee67e669,f0d3f3071c..94d9a7c3a1
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@@ -152,6 -152,6 +152,8 @@@
- **[issue-2175] Generation-side character framework + structure doctrine (CWQE Phase 10 remainder).** Following the worldbuilding-doctrine slice (#2219), the character-generation and structure-planning prompts now teach the craft up front. The character bible gains the Ghost → Wound → Lie → Want → Need chain (with interlock checks: state the Lie in one sentence; the Need/Truth is its direct opposite; the Ghost causally explains the Lie), a declared arc type (positive/negative/flat), the Three Sliders (proactivity/likability/competence 1–10, rule: HIGH on ≥2 or one-with-growth; all-low = boring, all-high = Mary Sue), and a secrets list — all OPTIONAL so pre-#2175 records round-trip unchanged (`server/lib/storyBible.js` sanitizer + Zod-shape parity via the existing `canonArrayField` sanitize-on-write, client mirror in `client/src/lib/bibleLimits.js`, character-sheet UI in `CharacterDetailEditor.jsx` with `htmlFor`/`id` pairing, and no-clobber merge in `universeCharacterExpand.js` for the AI-expand path). The `character.consistency` / `arc.*` editorial checks now receive the authored Lie/Want/Need/arc-type when present (via `canonCharacterTraitsSummary`) so they reconcile plan-vs-delivery instead of inferring both. Structure prompts gain lean doctrine: `pipeline-season-episodes.md` a try-fail mandate (60%+ of middle episodes end "Yes, but"/"No, and"), beat rules (Catalyst external; Break Into Two a protagonist choice; All Is Lost includes a death — literal or of a hope/relationship/identity) and an active-climax rule; `pipeline-arc-overview.md` MICE-style thread nesting (threads close in reverse order of opening; name the opening/closing thread per season). Shipped-template edits ship to existing installs via hash-keyed migrations 171/172/173 (with the drift-cross-sync of prior owners 003/005/019/027/166). Remaining Phase 10 items (Le Guin style doctrine into the style-guide flow) stay tracked on #2175.
+- **[issue-2160] Bulk-history importer for Google Takeout Location History → `place.visit` events, on the shared import seam.** The `/timeline` page gains a collapsible "Import Google location history" panel alongside the Spotify one: upload the Takeout "Location History (Timeline)" ZIP (or a single `Semantic Location History` JSON) → preview parsed visit/place counts + date-range + top places → confirm, and every place visit lands as an idempotent `place.visit` event (source `location`) via the existing `recordEvents()` infra (dedupe on place identity + visit start, so re-imports and overlapping exports never double-count). Both export vintages parse: classic server-side Timeline (`timelineObjects[].placeVisit` with E7 coords and ISO or epoch-ms durations) and the 2024+ on-device export (`semanticSegments[].visit.topCandidate` with `latLng` strings). Travel/activity segments carry no "where was I" signal and are dropped; the raw `Records.json` GPS dump is deliberately skipped. The two importers now share ONE seam: a generic `ActivityImportPanel` (pick → preview → confirm, stale-response-guarded) that Spotify + location wrap thinly, one `importHandler` route factory on `/api/timeline`, and one `importFile` client wrapper — so the remaining sources are small follow-ups. (`server/services/takeoutLocationImport.js`, `server/routes/timeline.js`, `client/src/services/apiTimeline.js`, `client/src/components/timeline/{ActivityImportPanel,TakeoutLocationImportPanel,SpotifyImportPanel}.jsx`, `client/src/pages/Timeline.jsx`)
+
- **[issue-2160] Bulk-history importer for Spotify extended streaming history + shared import seam.** The `/timeline` page gains a collapsible "Import Spotify history" panel: upload the privacy-download ZIP (or a single `Streaming_History_Audio_*.json`) → preview parsed counts/date-range/top-artists → confirm, and every play lands as an idempotent `media.listen` event via the existing `recordEvents()` infra (dedupe on track-uri + played-at, so re-imports and overlapping exports never double-count). Both the modern extended-history shape (`ts`/`ms_played`/`master_metadata_*`) and the legacy `StreamingHistory*.json` shape (`endTime`/`artistName`/`trackName`/`msPlayed`) are parsed; legacy offset-less UTC timestamps are anchored to UTC so a server west of UTC can't shift the listen into the wrong day. The route reuses the streaming `multipart.js` parser + `zipStream.js` (no new deps; the JSON parser is hand-written), Zod-validates the `preview` flag, and always unlinks the temp upload. This is one slice of the larger backfill issue. (`server/services/spotifyImport.js`, `server/routes/timeline.js`, `client/src/services/apiTimeline.js`, `client/src/components/timeline/SpotifyImportPanel.jsx`, `client/src/pages/Timeline.jsx`)
+
+ - **[issue-2262] Layered Intelligence Loop — deterministic backbone (server slice).** A perpetual, per-managed-app self-improvement loop that runs as an Engine-B autonomous script job (`job-layered-intelligence`, off by default). On its schedule the handler sweeps `getActiveApps()` and, for each app whose `layeredIntelligence.enabled === true` and whose per-app interval has elapsed, runs four layers: GATHER (reads enabled sources — GOALS.md, CoS `learning.json` metrics, HEALTH_REPORT.md, PLAN.md, open tracker issues, plus app-declared `file` custom sources), REASON (`callProviderAISimple` against the active/overridden provider with a JSON-only prompt), DECIDE (deterministic scope-gate + slug/label dedup against live tracker state), and ACT (files exactly ONE issue via the app's resolved work tracker, and optionally pauses the app on a blocking issue). The reasoning model never touches code — it returns structured JSON and every side effect is deterministic handler code, so the "model must not make direct code changes" contract holds by construction. Dedup and pause are fully tracker-derived (a `<!-- lil-slug: … -->` marker + `layered-intelligence` / `layered-intelligence:blocking` labels; closed-issue suppression pinned at 30 days) — the only local state is per-app `lastRunAt` bookkeeping. Meta/self proposal scopes (`loop-meta` / `portos-self`) are double-enforced to PortOS-only so a hallucinated or hand-edited scope can't file against the loop from someone else's app. GitHub (`gh`) and GitLab (`glab`) forge filing + `plan`-tracker PLAN.md append are implemented; ships via the `DEFAULT_JOBS` catalog (merged into existing installs on boot by `applyAdditiveFields`) and the per-app config accessor's default (all sources on; PortOS gets the meta/self scopes) — so no seed file or migration is needed. Off by default; only runs as a user-enabled scheduled automation (no cold-bootstrap LLM calls). (`server/services/layeredIntelligence.js`, `server/services/autonomousJobs/layeredIntelligenceHandler.js`, `server/services/autonomousJobs/scriptHandlers.js`, `server/services/autonomousJobs/defaults.js`, `server/services/apps.js`, `server/lib/validation.js`)