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

feat(reference-watch): write slug-tagged PLAN.md items instead of REFERENCE_REVIEW.md; drop top-level nav

Adam Eivyf13ee1fe3905
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 1d4bc7dac8..debe646edb 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -8,10 +8,12 @@
- Foundation for federated peer sync of Universes, Series, and Issues (Stage 1 of 5). Soft-delete (`deleted` + `deletedAt` tombstone fields) is now part of the on-disk record for universes, series, and issues — so a delete propagates to other PortOS instances via the existing LWW snapshot merge instead of vanishing locally and resurrecting from a peer. `listUniverses` / `listSeries` / `listIssues` (and their per-id getters) filter tombstones by default; pass `{ includeDeleted: true }` to see them. `mergeUniversesFromSync` / `mergeSeriesFromSync` / `mergeIssuesFromSync` detect delete-transitions and fire the same orphan-cleanup cascades as a local delete (media-collection unlink, slot-map clear, issue renumber). New `server/lib/syncWire.js` is the single source of truth for what fields cross the peer wire (today it strips `runs[]` from universe state — shared by the 60s snapshot loop and the upcoming per-record push). New `server/lib/assetHash.js` persists SHA-256 hashes in each `data/images/{uuid}.metadata.json` sidecar so both the share-bucket exporter and the upcoming peer-sync push pipeline reuse the same value (no per-bucket recomputation, no per-transport cache). `insertUniverseWithId` / `insertSeriesWithId` / `insertIssueWithId` now overwrite a tombstoned record (re-import undeletes) but still reject DUPLICATE on a live record.
## Changed
+- `reference-watch` task now appends slug-tagged `[ref-watch-…]` checklist items directly to PLAN.md instead of writing a standalone `REFERENCE_REVIEW.md` proposal file. Adopt-worthy commits become actionable PLAN items that `/claim` / `plan-task` can pick up; Maybe items get the same shape with a `**Decision needed:**` clause; security-flagged commits get no PLAN entry and are mentioned only in the final assistant summary. Prompt version bumped to `v2`; non-customized v1 prompts auto-upgrade on next schedule load.
+
+## Removed
+- Top-level `/reference-repos` global summary page and sidebar entry. Reference repos are now exclusively app-scoped — manage them via each app's "References" tab. Removed `client/src/pages/ReferenceRepos.jsx`, the route + lazy import from `client/src/App.jsx`, the sidebar entry from `client/src/components/Layout.jsx`, and the `nav.reference-repos` entry from `server/lib/navManifest.js` (the manifest's shape-invariant tests cover the deletion automatically). The `compact` / `initialRefs` props on `ReferenceReposPanel` are gone since the global summary was their only consumer.
## Fixed
- Federated peer-sync category toggles for **Universe** and **Pipeline** silently no-op'd. The Zod `syncCategoriesSchema` in `server/routes/instances.js` was missing both keys; Zod's default object parsing strips unknown keys, so the PATCH validated as an empty `syncCategories` object, the service-side merge became a no-op, and the checkbox stayed unchecked with no server-side error. Added `universe` and `pipeline` to the schema to restore parity with `DEFAULT_SYNC_CATEGORIES` and the UI's `SYNC_CATEGORY_META`.
- Auto-run the world → universe data rename on server boot. The conversion previously shipped as a manual CLI script (`server/scripts/migrateWorldToUniverse.js`) that nobody knew to invoke, so installs upgrading from the World Builder era kept stale `data/world-builder.json` files and never saw their worlds appear as universes. The new migration `031-world-to-universe-data-rename.js` does the file rename, top-level key rename (`worlds`→`universes`), `worldId`→`universeId` rewrite in `pipeline-series.json`, `worldRun`→`universeRun` rewrite in `media-jobs.json`, and also relinks any `"World: <name>"` render collections in `media-collections.json` to their universe by canonical-name match.
- Universe Builder picker dropdown rendered beneath the tab subnav and downstream section cards in Lumen Glass / Blueprint Ops themes. Those themes ship a non-`none` `--port-backdrop-filter`, and the global rule in `index.css` applies it to every `.bg-port-card.border.rounded*` — which turns each such card into its own stacking context. The picker's `absolute z-30` dropdown was trapped inside the header card's context and couldn't paint over later sibling cards. Adding `relative z-30` to the picker's `<header>` lets that stacking context win against subsequent siblings so the dropdown overlays them as intended.
-
-## Removed
diff --git a/PLAN.md b/PLAN.md
index 592b443986..05b7f503fb 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -20,6 +20,10 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changel
- [ ] [voice-cos-tool-expansion-calendar-today-calendar] **Voice CoS tool expansion** — `calendar_today` / `calendar_next` (existing Google Calendar MCP), `meatspace_log_workout` (wraps `meatspaceHealth.js`), `weather_now` (pick API: OpenWeather / WeatherKit / NWS), `timer_set` (reuses `agentActionExecutor.js`).
- [ ] [voice-agent-vision-fallback-ui-describe-visually] **Voice agent vision fallback** — `ui_describe_visually`: screenshot tab and send to a vision-capable model so "what's on this chart?" works on CyberCity / graph views.
- [ ] [apple-health-integration-live-sync] **Apple Health integration for MeatSpace.** iOS live sync (HealthKit Shortcut → `POST /api/meatspace/apple-health` endpoint) plus a bulk historical import path for an exported `export.xml`. Wire into existing MeatSpace tabs so steps / sleep / heart rate / VO2 max / resting HR show alongside the alcohol / blood / body / epigenetic tracks already shipped. GOALS.md flags this as a documented Secondary Goal ("Apple Health integration planned") but no implementation tracking existed until this entry.
+- [ ] [ref-watch-phosphene-mlx-post-decode-os-exit] **Bypass MLX post-decode deallocator hang via `os._exit(0)`.** From `reference-watch` review of phosphene (commits `adc1cd25` + `94bd6965`, 2026-05-22). At PortOS's current `LTX2_PIN=f8f20c83` the bug isn't reachable, but the moment a user updates `ltx-2-mlx` or PortOS bumps the pin past the May 9 refactor, every Distilled / Extend / two-stage render stalls 5–15 min after the upstream "Decoding done in X.Xs" log while Metal command-buffer completion handlers hold the GIL through frame teardown. Fix: in `scripts/generate_ltx2.py` `main()`, after `print(json.dumps(...))`, call `os._exit(0)` instead of returning normally — mp4 is on disk, stdout was flushed, skipping deallocator teardown saves up to 15 min. Document why in the file's docstring. Subsumes any in-helper watchdog approach.
+- [ ] [ref-watch-phosphene-broaden-negative-prompt-override] **Broaden `DEFAULT_NEGATIVE_PROMPT` override to every module that defines it.** From `reference-watch` review of phosphene (commit `4e6129b7`, 2026-05-22). `scripts/generate_ltx2.py:55-70` `configure_negative_prompt()` only patches `ti2vid_one_stage.DEFAULT_NEGATIVE_PROMPT`. At PortOS's current pin this happens to cover every pipeline (the constant resolves against `ti2vid_one_stage` for the base class), but post-May-9 the constant moves to `ltx_pipelines_mlx._base` and `utils.constants` — and the PortOS override silently no-ops on Q8 / two-stage / HQ paths with no error for the user to chase. Fix: rewrite `configure_negative_prompt()` to probe `ti2vid_one_stage`, `_base`, and `utils.constants`, monkey-patch every module that has the constant. Keep PortOS's *replace* semantics (don't switch to phosphene's append-with-comma). No contextmanager needed — the helper is short-lived.
+- [ ] [ref-watch-phosphene-lazy-eval-env-bootstrap] **Lazy-eval env bootstrap for M-series perf.** From `reference-watch` review of phosphene (commit `a6e4573f`, context from `ec1437fe`, 2026-05-22). Phosphene measured ~15–25× perf loss on M4 Max with the upstream default `LTX2_DIT_EVAL_EVERY=8` vs `=0`/`=1`, caused by per-block Metal command-buffer churn. The env vars only exist post-May-9 upstream, so this is a "land it with the pin bump" item. Fix: at the very top of `scripts/generate_ltx2.py` (BEFORE any `ltx_*` import, because `ltx_core_mlx.model.transformer.model` reads `LTX2_DIT_EVAL_EVERY` at import time), add `os.environ.setdefault("LTX2_DIT_EVAL_EVERY", "0")` and `os.environ.setdefault("LTX2_GEMMA_EVAL_EVERY", "0")`. User-supplied env still wins via `setdefault`. Phosphene's matrix suggests `=1` is a slightly safer middle if `=0` produces a post-decode hang; use `=0` and revisit if regressions appear.
+
## Deferred Architecture (human-led planning)
God-file decomposition candidates — none are bugs; pick up when touching the file for unrelated reasons.
@@ -90,6 +94,9 @@ Items here need a research / design pass, an explicit decision, or a preconditio
- [ ] [setup-data-import-drift-tables-from-migrations] **`setup-data.js` should import drift tables from each migration file.** `SHIPPED_PROMPT_OLD_MD5` + `SHIPPED_PROMPT_NEW_MD5` in `scripts/setup-data.js:139-196` manually mirror the `ACCEPTED_OLD_MD5` + `NEW_SHIPPED_MD5` exports each migration file already maintains. The mirror is hand-edited every time a migration ships and is the most likely place to drift. After `[backport-pre-023-migrations-to-_lib]` lands, every prompt-replace migration will export those constants — `setup-data.js` can build `SHIPPED_PROMPT_OLD_MD5` / `SHIPPED_PROMPT_NEW_MD5` by `import * as m025 from './migrations/025-idea-stage-character-detail.js'`-style sweep (or by glob+dynamic import) and removing the mirror entirely. Single source of truth, no hand sync. Surfaced by /simplify during `[pipeline-idea-stage-character-detail-plumbing]`.
- [ ] [parallelize-applypromptreplacemigration-files] **Parallelize `applyPromptReplaceMigration` per-file scan.** Today every prompt-replace migration covers exactly one file, so the serial `for (await readFile…)` loop in `scripts/migrations/_lib.js` costs nothing. When the first multi-file migration lands, fold the loop into `Promise.all(Object.keys(accepted).map(async filename => …))` and accumulate the `{ updated, alreadyCurrent, skipped }` counters post-flight. Theoretical until needed.
- [ ] [shots-aware-scene-output-contract-partial-split] **Shots-aware scene-output-contract partial.** Split into `_partials/scene-fields-core.md` + `_partials/scene-fields-shots.md` when a third shots-using stage appears.
+- [ ] [ref-watch-phosphene-bump-ltx2-pin-v0148] **Bump `LTX2_PIN` from `f8f20c83` to v0.14.8 + adopt phosphene's frame_rate / class-rename / a2v / lora-fusion patches together.** From `reference-watch` review of phosphene (2026-05-22). Concrete upstream wins between PortOS's pin and current dgrauet HEAD: VAE auto-tiling that caps peak Metal memory on HD / long runs (#25), `_pending_loras` honored across every pipeline's `load()` override (#22, #23 — fixes silent character-LoRA-drops on Extend/HQ), `--lora` on `--low-ram` flow (#30), accurate transformer load-time markers for progress UI. Cost: in v0.14.x, `TextToVideoPipeline` / `ImageToVideoPipeline` / `ExtendPipeline` / `TwoStagePipeline` / `AudioToVideoPipeline` are all renamed (public surface becomes `TI2VidOneStagePipeline`, `RetakePipeline`, `TI2VidTwoStagesPipeline`, `A2VidPipelineTwoStage`, etc.). `generate_ltx2.py` would fail at import. Source commits: `2166d138` / `770ed0bd` (defensive imports v2), `94ae3430` (method-presence dispatch instead of class assumption), `aa235aa0` (`fps=` → `frame_rate=` shim), `681f429a` (a2v missing `frame_rate=` runtime patch), plus `[ref-watch-phosphene-lazy-eval-env-bootstrap]`. Scope: large (100–200 lines of careful Python touching every pipeline path, plus smoke test of every mode — text/image/fflf/extend/a2v — at the new pin). **Decision needed:** ship as one PR vs split per-mode; do this before or after the post-decode `os._exit(0)` lands.
+- [ ] [ref-watch-phosphene-sigkill-watchdog-videogen-local] **Panel-side SIGKILL watchdog (Node layer) in `videoGen/local.js`.** From `reference-watch` review of phosphene (commit `94bd6965`, 2026-05-22). Even with helper-side `os._exit(0)` adopted (see `[ref-watch-phosphene-mlx-post-decode-os-exit]`), defense-in-depth at the Node layer is cheap insurance: watch stdout for the upstream "[Decoding video + audio + muxing] done in X.Xs" line (or the final `{"video_path": ...}` JSON), then arm a 30–45s grace timer that SIGKILLs the child if it doesn't exit. PortOS already has SIGTERM→SIGKILL escalation in `cancel()` (`server/services/videoGen/local.js:71-79`); reuse that path. **Trigger:** only do this if real users hit the hang after the pin bump and `os._exit(0)` proves insufficient (it shouldn't, in PortOS's short-lived-helper model). Scope: small/medium.
+- [ ] [ref-watch-phosphene-long-clip-temporal-boost-12fps] **"Long Clip Temporal Boost" (render at 12fps, interpolate to 24fps).** From `reference-watch` review of phosphene (commit `53585fc`, 2026-05-22). Phosphene added a 12fps render path that uses ffmpeg's `minterpolate` / RIFE downstream to fill back to 24fps, doubling the effective clip length per memory budget. PortOS doesn't have an interpolation post-step in `server/services/videoGen/local.js` — adding one is a feature decision, not a bug fix. The math helpers (`_duration_to_8k_frames`, LTX `8k+1` frame-count snapping) are useful regardless; PortOS's `DEFAULT_NUM_FRAMES = 121` is already 8k+1-aligned but UI-side validation could borrow this pattern. **Decision needed:** is this worth a feature surface? No clear user pain motivating it today.
## Future Ideas
diff --git a/client/src/App.jsx b/client/src/App.jsx
index 582e65fef3..bb5e669baf 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -21,7 +21,6 @@ const DataDog = lazyWithReload(() => import('./pages/DataDog'));
const GitHub = lazyWithReload(() => import('./pages/GitHub'));
const CyberCity = lazyWithReload(() => import('./pages/CyberCity'));
const AppDetail = lazyWithReload(() => import('./pages/AppDetail'));
-const ReferenceRepos = lazyWithReload(() => import('./pages/ReferenceRepos'));
const FeatureAgents = lazyWithReload(() => import('./pages/FeatureAgents'));
const FeatureAgentDetail = lazyWithReload(() => import('./pages/FeatureAgentDetail'));
const CalendarPage = lazyWithReload(() => import('./pages/Calendar'));
@@ -146,7 +145,6 @@ export default function App() {
<Route path="/" element={<Layout />}>
<Route index element={<Dashboard />} />
<Route path="apps" element={<Apps />} />
- <Route path="reference-repos" element={<ReferenceRepos />} />
<Route path="devtools" element={<Navigate to="/devtools/runs" replace />} />
<Route path="devtools/datadog" element={<DataDog />} />
<Route path="devtools/github" element={<GitHub />} />
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index ebe11fccf6..0b130241a9 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -275,7 +275,6 @@ const navItems = [
{ to: '/post/wordplay', label: 'Wordplay', icon: MessageCircle },
]
},
- { to: '/reference-repos', label: 'Reference Repos', icon: GitBranch, single: true },
{
label: 'Settings',
icon: Settings,
diff --git a/client/src/components/apps/ReferenceReposPanel.jsx b/client/src/components/apps/ReferenceReposPanel.jsx
index daa85db4ed..9c4acb3eb0 100644
--- a/client/src/components/apps/ReferenceReposPanel.jsx
+++ b/client/src/components/apps/ReferenceReposPanel.jsx
@@ -4,13 +4,11 @@ import toast from '../ui/Toast';
import * as api from '../../services/api';
/**
- * Per-app reference-repos manager. Embedded inside the app detail page
- * (Tasks tab) and reused on the global /reference-repos page in
- * read-only-ish mode (`compact={true}` hides the "Add" form so the
- * global summary stays a summary).
+ * Per-app reference-repos manager. Embedded inside the app detail page's
+ * "References" tab — the only surface for managing reference repos.
*/
-export default function ReferenceReposPanel({ appId, appName, compact = false, initialRefs = null }) {
- const [refs, setRefs] = useState(initialRefs || []);
+export default function ReferenceReposPanel({ appId, appName }) {
+ const [refs, setRefs] = useState([]);
// Two distinct loading states:
// - `initialLoading` is true only on the very first fetch (mount); the
// panel renders a placeholder while it's true. Stays false after
@@ -20,7 +18,7 @@ export default function ReferenceReposPanel({ appId, appName, compact = false, i
// unsaved notes draft, an expanded commit list <details>) doesn't
// get unmounted and lost every time the user clicks Check or
// Mark-reviewed.
- const [initialLoading, setInitialLoading] = useState(initialRefs == null);
+ const [initialLoading, setInitialLoading] = useState(true);
const [refreshing, setRefreshing] = useState(false);
const [showAdd, setShowAdd] = useState(false);
// Per-ref UI state — keyed by ref id. Holds the in-progress check snapshot
@@ -49,13 +47,9 @@ export default function ReferenceReposPanel({ appId, appName, compact = false, i
setInitialLoading(false);
}, [appId]);
- // Fetch on mount unless the parent seeded us with initialRefs. After
- // any local mutation we re-fetch unconditionally to pick up server-side
- // status updates (lastCheckedAt, lastError).
- const initialRefsProvided = initialRefs != null;
useEffect(() => {
- if (!initialRefsProvided) fetch();
- }, [fetch, initialRefsProvided]);
+ fetch();
+ }, [fetch]);
const handleAdd = async (form) => {
const created = await api.addReferenceRepo(appId, form).catch((e) => { toast.error(e.message || 'Add failed'); return null; });
@@ -159,27 +153,25 @@ export default function ReferenceReposPanel({ appId, appName, compact = false, i
return (
<div className="space-y-3">
- {!compact && (
- <div className="flex items-center justify-between">
- <div>
- <h3 className="text-sm font-semibold text-white flex items-center gap-2">
- <GitBranch size={14} /> Reference Repos
- {refreshing && <RefreshCw size={11} className="animate-spin text-gray-500" />}
- </h3>
- <p className="text-xs text-gray-500 mt-0.5">
- Upstream repos {appName} watches for clean-room reimplementation. The <code className="text-port-accent">reference-watch</code> task fetches each weekly and proposes features/fixes worth re-building in our own code via <code>REFERENCE_REVIEW.md</code>.
- </p>
- </div>
- <button
- onClick={() => setShowAdd(true)}
- className="px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded text-xs inline-flex items-center gap-1 shrink-0"
- >
- <Plus size={14} /> Add reference
- </button>
+ <div className="flex items-center justify-between">
+ <div>
+ <h3 className="text-sm font-semibold text-white flex items-center gap-2">
+ <GitBranch size={14} /> Reference Repos
+ {refreshing && <RefreshCw size={11} className="animate-spin text-gray-500" />}
+ </h3>
+ <p className="text-xs text-gray-500 mt-0.5">
+ Upstream repos {appName} watches for clean-room reimplementation. The <code className="text-port-accent">reference-watch</code> task fetches each weekly, runs a security screen, and — for adoption-worthy commits — appends slug-tagged <code>[ref-watch-…]</code> checklist items to <code>PLAN.md</code> for <code>/claim</code> / <code>plan-task</code> to pick up. No source-code edits, no separate review file.
+ </p>
</div>
- )}
+ <button
+ onClick={() => setShowAdd(true)}
+ className="px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded text-xs inline-flex items-center gap-1 shrink-0"
+ >
+ <Plus size={14} /> Add reference
+ </button>
+ </div>
- {showAdd && !compact && (
+ {showAdd && (
<AddRefForm onSubmit={handleAdd} onCancel={() => setShowAdd(false)} />
)}
@@ -208,7 +200,6 @@ export default function ReferenceReposPanel({ appId, appName, compact = false, i
onEditNotes={() => setEditingNotesId(ref.id)}
onCancelNotes={() => setEditingNotesId(null)}
onSaveNotes={(notes) => handleSaveNotes(ref, notes)}
- compact={compact}
/>
))}
</div>
@@ -235,7 +226,7 @@ function StatusBadge({ status, lastError }) {
);
}
-function RefRow({ reference, snapshot, checking, editingNotes, onCheck, onMarkReviewed, onDelete, onEditNotes, onCancelNotes, onSaveNotes, compact }) {
+function RefRow({ reference, snapshot, checking, editingNotes, onCheck, onMarkReviewed, onDelete, onEditNotes, onCancelNotes, onSaveNotes }) {
// Seed the draft when the user enters edit mode. Don't depend on
// `reference.notes` — a parent re-fetch produces a new ref object every
// poll and would clobber whatever the user is mid-typing.
@@ -288,24 +279,20 @@ function RefRow({ reference, snapshot, checking, editingNotes, onCheck, onMarkRe
Mark reviewed
</button>
)}
- {!compact && (
- <>
- <button
- onClick={onEditNotes}
- className="px-2 py-1 text-gray-400 hover:text-white rounded"
- title="Edit notes"
- >
- <Edit3 size={12} />
- </button>
- <button
- onClick={onDelete}
- className="px-2 py-1 text-gray-400 hover:text-port-error rounded"
- title="Remove this reference"
- >
- <Trash2 size={12} />
- </button>
- </>
- )}
+ <button
+ onClick={onEditNotes}
+ className="px-2 py-1 text-gray-400 hover:text-white rounded"
+ title="Edit notes"
+ >
+ <Edit3 size={12} />
+ </button>
+ <button
+ onClick={onDelete}
+ className="px-2 py-1 text-gray-400 hover:text-port-error rounded"
+ title="Remove this reference"
+ >
+ <Trash2 size={12} />
+ </button>
</div>
</div>
diff --git a/client/src/components/apps/tabs/ReferencesTab.jsx b/client/src/components/apps/tabs/ReferencesTab.jsx
index 27a6d255a1..d42499f3f6 100644
--- a/client/src/components/apps/tabs/ReferencesTab.jsx
+++ b/client/src/components/apps/tabs/ReferencesTab.jsx
@@ -1,10 +1,9 @@
import ReferenceReposPanel from '../ReferenceReposPanel';
/**
- * App-detail "References" tab — full CRUD over the app's reference repos.
- * The global summary at /reference-repos uses the same panel in `compact`
- * mode (read-and-check, no add/delete). Add/edit/remove always happens
- * here so the per-app context is unambiguous.
+ * App-detail "References" tab — the single surface for managing the
+ * app's reference repos. Reference repos are app-scoped only; there
+ * is no global summary page.
*/
export default function ReferencesTab({ appId, appName }) {
return (
diff --git a/client/src/pages/ReferenceRepos.jsx b/client/src/pages/ReferenceRepos.jsx
deleted file mode 100644
index bc8eea6509..0000000000
--- a/client/src/pages/ReferenceRepos.jsx
+++ /dev/null
@@ -1,97 +0,0 @@
-import { useEffect, useState } from 'react';
-import { Link } from 'react-router-dom';
-import { GitBranch, ExternalLink } from 'lucide-react';
-import * as api from '../services/api';
-import { PORTOS_APP_ID } from '../services/apiCore';
-import ReferenceReposPanel from '../components/apps/ReferenceReposPanel';
-
-/**
- * Global summary of every reference repo configured across every app.
- *
- * This page is intentionally a *summary* — to add, edit, or delete a ref
- * the user clicks through to the per-app References tab. That keeps the
- * "which app does this ref belong to" decision visible at edit time.
- *
- * What you CAN do here: see status across all refs at a glance, run a
- * "Check now" per ref, mark-as-reviewed, and click into the app for
- * full management.
- */
-export default function ReferenceRepos() {
- const [apps, setApps] = useState([]);
- const [loading, setLoading] = useState(true);
- // Distinguish "fetch failed" from "no apps configured" — without this
- // the empty-state message ("No apps have reference repos configured")
- // shows up on every transient server hiccup, which is misleading and
- // sends users hunting for a configuration mistake that doesn't exist.
- const [fetchError, setFetchError] = useState(null);
-
- useEffect(() => {
- let cancelled = false;
- (async () => {
- const all = await api.getApps().catch((e) => ({ __error: e?.message || 'Failed to load apps' }));
- if (cancelled) return;
- if (all && all.__error) {
- setFetchError(all.__error);
- setLoading(false);
- return;
- }
- const withRefs = (all || []).filter((a) => Array.isArray(a.referenceRepos) && a.referenceRepos.length > 0);
- withRefs.sort((a, b) => {
- if (a.id === PORTOS_APP_ID) return -1;
- if (b.id === PORTOS_APP_ID) return 1;
- return (a.name || '').localeCompare(b.name || '');
- });
- setApps(withRefs);
- setLoading(false);
- })();
- return () => { cancelled = true; };
- }, []);
-
- if (loading) {
- return <div className="p-6 text-gray-400">Loading reference repos…</div>;
- }
-
- return (
- <div className="p-4 sm:p-6 max-w-5xl space-y-4">
- <div>
- <h1 className="text-2xl font-bold text-white flex items-center gap-2">
- <GitBranch size={22} /> Reference Repos
- </h1>
- <p className="text-sm text-gray-400 mt-1">
- Upstream repos each app watches for clean-room reimplementation. The <code className="text-port-accent">reference-watch</code> task in CoS scans them on a schedule and writes <code>REFERENCE_REVIEW.md</code> proposals describing features and fixes worth re-building in our own code. We track upstream commits — we don't copy upstream code. Add/remove from each app's References tab.
- </p>
- </div>
-
- {fetchError ? (
- <div className="bg-port-error/10 border border-port-error/40 rounded-lg p-4 text-port-error text-sm">
- Failed to load apps: {fetchError}. Refresh to retry.
- </div>
- ) : apps.length === 0 ? (
- <div className="bg-port-card border border-port-border rounded-lg p-8 text-center text-gray-400">
- <p className="mb-2">No apps have reference repos configured yet.</p>
- <p className="text-sm text-gray-500">
- Open any app from <Link to="/apps" className="text-port-accent hover:underline">Apps</Link> and use its <span className="text-white">References</span> tab to add one.
- </p>
- </div>
- ) : (
- apps.map((app) => (
- <div key={app.id} className="bg-port-bg border border-port-border rounded-lg p-4 space-y-3">
- <div className="flex items-center justify-between">
- <div className="flex items-baseline gap-2">
- <h2 className="text-lg font-semibold text-white">{app.name}</h2>
- <span className="text-xs text-gray-500">{app.referenceRepos.length} ref{app.referenceRepos.length === 1 ? '' : 's'}</span>
- </div>
- <Link
- to={`/apps/${app.id}/references`}
- className="text-xs text-port-accent hover:underline inline-flex items-center gap-1"
- >
- Manage <ExternalLink size={12} />
- </Link>
- </div>
- <ReferenceReposPanel appId={app.id} appName={app.name} compact initialRefs={app.referenceRepos} />
- </div>
- ))
- )}
- </div>
- );
-}
diff --git a/server/lib/navManifest.js b/server/lib/navManifest.js
index 4c891f2422..d47c256a97 100644
--- a/server/lib/navManifest.js
+++ b/server/lib/navManifest.js
@@ -9,7 +9,6 @@ export const NAV_COMMANDS = [
{ id: 'nav.cybercity', path: '/city', label: 'CyberCity', section: 'Main', aliases: ['city', 'cybercity'], keywords: ['3d', 'visualization'] },
{ id: 'nav.cybercity.settings', path: '/city/settings', label: 'CyberCity Settings', section: 'Main', aliases: ['city settings', 'cybercity settings', 'city-settings', 'cybercity-config'], keywords: ['cybercity', 'settings', '3d', 'configure'] },
{ id: 'nav.apps', path: '/apps', label: 'Apps', section: 'Main', aliases: ['apps'] },
- { id: 'nav.reference-repos', path: '/reference-repos', label: 'Reference Repos', section: 'Main', aliases: ['reference-repos', 'references', 'reference', 'upstream', 'watch'], keywords: ['upstream', 'reference code', 'borrowed code', 'fork', 'git watch', 'commit watch', 'phosphene'] },
{ id: 'nav.media', path: '/media/image', label: 'Media Gen', section: 'Create', aliases: ['media', 'media-gen', 'mediagen', 'generate'], keywords: ['image', 'video', 'render', 'art', 'movie'] },
{ id: 'nav.media.image', path: '/media/image', label: 'Image', section: 'Create', aliases: ['image-gen', 'imagegen', 'generate-image', 'sd', 'stable-diffusion'], keywords: ['stable diffusion', 'render', 'art', 'picture', 'photo', 'draw', 'flux', 'mflux'] },
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 7a2e68d14e..d89c094aed 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -204,10 +204,10 @@ export const datadogConfigSchema = z.object({
// Reference-repo entry. Each app can list upstream repos it watches for
// clean-room reimplementation;
// the `reference-watch` scheduled task fetches each one, finds commits since
-// `lastReviewedSha`, and produces a REFERENCE_REVIEW.md proposal in the app's
-// repo. `notes` is the free-text "what we use from this repo" field — fed
-// into the review prompt so the agent knows which features in our app are
-// load-bearing for the watch.
+// `lastReviewedSha`, and appends slug-tagged `[ref-watch-…]` checklist items
+// to the app's PLAN.md for `/claim` / `plan-task` to pick up. `notes` is the
+// free-text "what we use from this repo" field — fed into the review prompt
+// so the agent knows which features in our app are load-bearing for the watch.
export const referenceRepoSchema = z.object({
id: z.string().min(1).max(64),
name: z.string().min(1).max(120),
diff --git a/server/routes/referenceRepos.js b/server/routes/referenceRepos.js
index ca88e8cef7..ba557ae523 100644
--- a/server/routes/referenceRepos.js
+++ b/server/routes/referenceRepos.js
@@ -4,7 +4,8 @@
* Per-app management of upstream repos we borrow code from. The
* `reference-watch` scheduled task uses `checkReferenceRepo` to find
* commits since each ref's `lastReviewedSha`, then dispatches a CoS
- * sub-agent to write REFERENCE_REVIEW.md to the app's repo.
+ * sub-agent that appends slug-tagged `[ref-watch-…]` checklist items
+ * to the app's PLAN.md for `/claim` / `plan-task` to pick up.
*
* Mounted at /api/apps/:appId/reference-repos so it sits next to the
* existing apps API surface.
diff --git a/server/services/referenceRepos.js b/server/services/referenceRepos.js
index 0ac4863eb1..35dd8543ca 100644
--- a/server/services/referenceRepos.js
+++ b/server/services/referenceRepos.js
@@ -8,7 +8,8 @@
* (e.g., PortOS itself watches `phosphene` for video-gen ideas). The
* `reference-watch` scheduled task asks this service to fetch each ref
* and find commits since `lastReviewedSha`. The CoS sub-agent then
- * produces a REFERENCE_REVIEW.md proposal in the target app's repo.
+ * appends slug-tagged `[ref-watch-…]` checklist items to PLAN.md in the
+ * target app's repo, which `/claim` / `plan-task` picks up later.
*
* Storage: refs live inline on each app in data/apps.json under the
* `referenceRepos` array — fits the existing per-app config model and
@@ -504,8 +505,8 @@ export async function checkReferenceRepo(appId, refId) {
/**
* Mark a ref as reviewed up to the given SHA — called after a CoS
- * sub-agent finishes producing REFERENCE_REVIEW.md, or by the UI's
- * "mark as reviewed" button. SHA must match a real commit visible from
+ * sub-agent finishes appending PLAN.md items for the new commits, or by
+ * the UI's "mark as reviewed" button. SHA must match a real commit visible from
* the ref's working tree (verified via `git cat-file -e <sha>^{commit}`
* against the managed clone or the user-supplied local path).
*/
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index 6184220ea7..82202e42b3 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -1097,11 +1097,13 @@ You are reviewing upstream commits from one or more reference repositories that
{appName} watches for clean-room reimplementation — meaning {appName} maintains
its OWN implementation of similar features and may benefit from re-building
the bug fixes or new capabilities those upstream commits introduce. Your job
-is to PROPOSE which commits are worth re-implementing, NOT to copy upstream
-code. Read-only mode — do NOT modify {appName}'s source. **Never paste
+is to PROPOSE which commits are worth re-implementing as slug-tagged checklist
+items appended to PLAN.md — NOT to copy upstream code. Read-only mode for
+{appName}'s source; the ONLY file you edit is PLAN.md. **Never paste
upstream code verbatim into recommendations**: describe what to change in our
own architecture, naming the files and functions in {appName} that need
-edits. The user owns the actual implementation.
+edits. The user owns the actual implementation; \`/claim\`-style task runners
+pick the items up later.
Repository: {repoPath}
@@ -1111,15 +1113,20 @@ Repository: {repoPath}
## What to do
-For each reference above:
+1. **Read PLAN.md** from {repoPath} so you know which slugs already exist.
+ Every existing checkbox carries a \`[<slug>]\` ID — collect them so you
+ don't duplicate. If PLAN.md does not exist, create it with a single
+ top-level heading (\`# {appName} — Development Plan\`) and a \`## Next Up\`
+ section before appending.
-1. For every commit in the "Commits to review" list, read its diff via
- \`git -C <source clone path> show <sha>\` (the path is in the reference's
- block above). For commits with many files, focus on diffs that match the
- user-supplied "Context" block — that's the load-bearing intersection
- between this app and upstream, and the user has flagged what matters.
+2. For each reference above, for every commit in the "Commits to review"
+ list, read its diff via \`git -C <source clone path> show <sha>\` (the
+ path is in the reference's block above). For commits with many files,
+ focus on diffs that match the user-supplied "Context" block — that's
+ the load-bearing intersection between this app and upstream, and the
+ user has flagged what matters.
-2. **SECURITY SCREEN — do this BEFORE deciding whether the commit is worth
+3. **SECURITY SCREEN — do this BEFORE deciding whether the commit is worth
adopting.** Reference repos are third-party code we don't control; an
upstream maintainer's account compromise, a malicious PR merge, or a
typo-squatting branch name could ship malware or new vulnerabilities
@@ -1145,13 +1152,13 @@ For each reference above:
ranges, lockfile-only changes that pull a different version than
the manifest claims.
- If a commit shows ANY of these, classify it as **Skip — security
- concern** in REFERENCE_REVIEW.md (see template below) with a one-line
- note describing exactly what tripped the screen. Do NOT recommend
- adoption even if the surface feature looks attractive.
+ If a commit shows ANY of these, **do NOT add a PLAN.md item for it** —
+ security-flagged commits are not adoption candidates, period. Note them
+ only in the final assistant summary so the user sees what tripped the
+ screen.
-3. Decide whether the change is worth REIMPLEMENTING in {appName}. Use these
- criteria, in priority order:
+4. Decide whether each (security-clean) commit is worth REIMPLEMENTING in
+ {appName}. Use these criteria, in priority order:
- Does it fix a bug we'd hit too? (high priority — re-implement the fix
in our equivalent code path)
- Does it expose a capability we artificially restrict? (e.g. our wrapper
@@ -1161,56 +1168,43 @@ For each reference above:
- Is it a docs / install / packaging fix specific to upstream's distribution
model? (skip — those rarely apply)
-4. Write a single \`REFERENCE_REVIEW.md\` at the root of {repoPath} with this
- structure:
+5. **For each Adopt-worthy commit (or coherent group of commits), append a
+ slug-tagged checklist item to PLAN.md.** Format:
\`\`\`markdown
- # Reference Review — <today's date>
-
- ## Summary
-
- <1-3 sentences: what's the gist across all refs? Mention if any
- commits were flagged as a security concern.>
-
- ## Skip — security concern
-
- <commits flagged by the security screen. List FIRST so the user sees
- these before any "adopt" recommendations. For each:>
- - **<short title>** — \`<sha>\` from <ref name>
- - What tripped the screen: <one sentence — malware indicator,
- new vuln, or suspicious dep change>
- - Detail: <specific file:line(s) + the pattern that concerned you>
-
- ## Adopt — high value
-
- For each commit you'd recommend pulling in (security-clean only):
- - **<short title>** — \`<sha>\` from <ref name>
- - Why it matters for {appName}: <1-2 sentences tied to our notes>
- - What to change: <specific files + functions in {appName}, e.g.
- server/services/foo.js buildArgs() — accept new arg, plumb to
- subprocess. Describe the BEHAVIOR to add, not upstream's exact
- code — clean-room reimplementation.>
- - Estimated scope: <small / medium / large>
-
- ## Maybe — needs human call
-
- <commits where the value is real but the fit is unclear; what to ask>
-
- ## Skip — not for us
-
- <commits we should explicitly NOT adopt + one-line reason each>
-
- ## Per-reference SHA pointers
-
- - <ref name>: latest reviewed in this report = \`<head sha>\`
+ - [ ] [ref-watch-<ref-name-slug>-<short-title-slug>] **<Short title.>** From \`reference-watch\` review of <ref name> (commit(s) \`<sha>\` [+ \`<sha>\` …], <today's date>). <1–2 sentences: what bug/capability the commit addresses, and why it matters for {appName} tied to our notes.> Fix: <specific files + functions in {appName} — e.g. \`server/services/foo.js#buildArgs()\` — describe the BEHAVIOR to add, not upstream's exact code (clean-room reimplementation).> <Estimated scope: small / medium / large.>
\`\`\`
-5. Do NOT create branches, commits, PRs, or any code edits. The user reviews
- REFERENCE_REVIEW.md and decides what to implement.
-
-6. Once REFERENCE_REVIEW.md is written, your final assistant message must be a
- 2-3 sentence summary of how many commits you reviewed, how many security
- flags you raised, and how many you marked Adopt vs. Maybe vs. Skip.`
+ Slug rules:
+ - Lowercase kebab-case; start with \`ref-watch-\` so the user can grep
+ them in bulk.
+ - Include a short reference of the upstream repo so multiple watched
+ refs don't collide (e.g. \`ref-watch-phosphene-lazy-eval-env-bootstrap\`).
+ - ≤80 chars total, unique against every existing \`[<slug>]\` in PLAN.md
+ (re-check before each append).
+ - Place items in the \`## Next Up\` section (create the section if absent).
+
+ For **Maybe — needs human call** items (real value but unclear fit, or
+ gated on a decision/precondition), append the same slug-tagged line but
+ add a final sentence stating the decision needed, and place the line in
+ a \`### Trigger-gated (waiting for a precondition)\` subsection if one
+ exists; otherwise append under \`## Next Up\` and end the description
+ with \`**Decision needed:** <one sentence>.\`
+
+ **Skip — not for us** items get no PLAN.md entry. Mention them only in
+ the final summary.
+
+6. Commit the PLAN.md edit. The commit message should be:
+ \`docs(reference-watch): propose <N> item(s) from <ref names>\`
+ Do NOT create branches, PRs, or any source-code edits — PLAN.md is the
+ only file you touch. \`/claim\` (or the \`plan-task\` agent) picks the
+ slugs up later.
+
+7. Your final assistant message must be a 2–3 sentence summary of:
+ - How many commits you reviewed (across all refs).
+ - How many security flags you raised (with one-line reasons + SHAs).
+ - How many slug-tagged PLAN.md items you appended (Adopt + Maybe) vs
+ how many commits you skipped as not-for-us.`
};
// Prompt versions — bump when a default prompt changes so existing instances auto-upgrade.
@@ -1221,7 +1215,7 @@ const PROMPT_VERSIONS = {
'pr-reviewer': 3, // v3: multi-stage pipeline (security scan → code review + merge)
'code-reviewer-a': 1, // v1: 2-stage pipeline (codebase review → triage & implement)
'code-reviewer-b': 1, // v1: 2-stage pipeline (codebase review → triage & implement)
- 'reference-watch': 1 // v1: clean-room reimplementation framing + mandatory security screen (malware / new vuln / suspicious deps) before adoption decisions
+ 'reference-watch': 2 // v2: append slug-tagged checklist items to PLAN.md (Adopt + Maybe) instead of writing REFERENCE_REVIEW.md; security-flagged commits get no PLAN entry (mentioned only in final summary)
};
// Known previous default prompts for legacy migration.
@@ -1957,6 +1951,132 @@ Before reviewing code quality, scan each PR for malicious content:
## Review Checklist
{reviewChecklist}`
+ ],
+
+ 'reference-watch': [
+ // v1 default prompt — wrote a single REFERENCE_REVIEW.md proposal to the
+ // app's repo root. Superseded by v2 which appends slug-tagged checklist
+ // items directly to PLAN.md (no separate review file).
+ `[Improvement: {appName}] Reference Repo Review
+
+You are reviewing upstream commits from one or more reference repositories that
+{appName} watches for clean-room reimplementation — meaning {appName} maintains
+its OWN implementation of similar features and may benefit from re-building
+the bug fixes or new capabilities those upstream commits introduce. Your job
+is to PROPOSE which commits are worth re-implementing, NOT to copy upstream
+code. Read-only mode — do NOT modify {appName}'s source. **Never paste
+upstream code verbatim into recommendations**: describe what to change in our
+own architecture, naming the files and functions in {appName} that need
+edits. The user owns the actual implementation.
+
+Repository: {repoPath}
+
+## References
+
+{referenceData}
+
+## What to do
+
+For each reference above:
+
+1. For every commit in the "Commits to review" list, read its diff via
+ \`git -C <source clone path> show <sha>\` (the path is in the reference's
+ block above). For commits with many files, focus on diffs that match the
+ user-supplied "Context" block — that's the load-bearing intersection
+ between this app and upstream, and the user has flagged what matters.
+
+2. **SECURITY SCREEN — do this BEFORE deciding whether the commit is worth
+ adopting.** Reference repos are third-party code we don't control; an
+ upstream maintainer's account compromise, a malicious PR merge, or a
+ typo-squatting branch name could ship malware or new vulnerabilities
+ into a commit that *looks* useful. For every commit, scan the diff for:
+
+ - **Malware indicators**: obfuscated/minified strings in source files,
+ base64/hex blobs being decoded then \`eval\`'d / \`exec\`'d / piped to
+ a shell, network calls to non-obvious hosts (anything that isn't the
+ upstream's own infra or a well-known package registry), exfil of
+ env vars / \`~/.ssh/\` / \`~/.aws/\` / browser cookie stores, new
+ post-install / pre-publish hooks, dynamic-import patterns that
+ fetch-then-execute remote code, suspicious file writes outside the
+ repo root.
+ - **New vulnerabilities introduced**: SQL/NoSQL/command injection on
+ newly-added user-input paths, path traversal in newly-added file
+ I/O, prototype pollution via unvalidated object merges, unsafe
+ deserialization (eval, vm, pickle, Marshal, YAML.load without
+ SafeLoader), deactivated security headers / CSP relaxations,
+ authentication or authorization checks removed or weakened, secrets
+ committed (tokens, keys, .env contents).
+ - **Suspicious dependency changes**: newly added deps from publishers
+ with no track record, dep-version downgrades to known-vulnerable
+ ranges, lockfile-only changes that pull a different version than
+ the manifest claims.
+
+ If a commit shows ANY of these, classify it as **Skip — security
+ concern** in REFERENCE_REVIEW.md (see template below) with a one-line
+ note describing exactly what tripped the screen. Do NOT recommend
+ adoption even if the surface feature looks attractive.
+
+3. Decide whether the change is worth REIMPLEMENTING in {appName}. Use these
+ criteria, in priority order:
+ - Does it fix a bug we'd hit too? (high priority — re-implement the fix
+ in our equivalent code path)
+ - Does it expose a capability we artificially restrict? (e.g. our wrapper
+ around a shared library uses a constrained subset of an API the upstream
+ just opened up — we can do the same in our wrapper)
+ - Does it improve performance / correctness on a code path we share?
+ - Is it a docs / install / packaging fix specific to upstream's distribution
+ model? (skip — those rarely apply)
+
+4. Write a single \`REFERENCE_REVIEW.md\` at the root of {repoPath} with this
+ structure:
+
+ \`\`\`markdown
+ # Reference Review — <today's date>
+
+ ## Summary
+
+ <1-3 sentences: what's the gist across all refs? Mention if any
+ commits were flagged as a security concern.>
+
+ ## Skip — security concern
+
+ <commits flagged by the security screen. List FIRST so the user sees
+ these before any "adopt" recommendations. For each:>
+ - **<short title>** — \`<sha>\` from <ref name>
+ - What tripped the screen: <one sentence — malware indicator,
+ new vuln, or suspicious dep change>
+ - Detail: <specific file:line(s) + the pattern that concerned you>
+
+ ## Adopt — high value
+
+ For each commit you'd recommend pulling in (security-clean only):
+ - **<short title>** — \`<sha>\` from <ref name>
+ - Why it matters for {appName}: <1-2 sentences tied to our notes>
+ - What to change: <specific files + functions in {appName}, e.g.
+ server/services/foo.js buildArgs() — accept new arg, plumb to
+ subprocess. Describe the BEHAVIOR to add, not upstream's exact
+ code — clean-room reimplementation.>
+ - Estimated scope: <small / medium / large>
+
+ ## Maybe — needs human call
+
+ <commits where the value is real but the fit is unclear; what to ask>
+
+ ## Skip — not for us
+
+ <commits we should explicitly NOT adopt + one-line reason each>
+
+ ## Per-reference SHA pointers
+
+ - <ref name>: latest reviewed in this report = \`<head sha>\`
+ \`\`\`
+
+5. Do NOT create branches, commits, PRs, or any code edits. The user reviews
+ REFERENCE_REVIEW.md and decides what to implement.
+
+6. Once REFERENCE_REVIEW.md is written, your final assistant message must be a
+ 2-3 sentence summary of how many commits you reviewed, how many security
+ flags you raised, and how many you marked Adopt vs. Maybe vs. Skip.`
]
};
@@ -1968,8 +2088,9 @@ export const SELF_IMPROVEMENT_TASK_TYPES = [
'typing', 'release-check', 'pr-reviewer', 'code-reviewer-a', 'code-reviewer-b',
'jira-sprint-manager', 'jira-status-report', 'do-replan',
// Watches `referenceRepos` configured on the app — fetches each upstream
- // repo, finds commits since lastReviewedSha, and writes a propose-only
- // REFERENCE_REVIEW.md with adoption recommendations to the app's repo.
+ // repo, finds commits since lastReviewedSha, and appends slug-tagged
+ // `[ref-watch-…]` checklist items to the app's PLAN.md for `/claim` /
+ // `plan-task` to pick up. No source-code edits, no separate review file.
'reference-watch'
];