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
address review: relax addItem ref validator + re-run cert after brew install
Adam Eivy273e664dc06c
diff --git a/PLAN.md b/PLAN.mdindex 83bfb8bcd6..68e95a39db 100644--- a/PLAN.md+++ b/PLAN.md@@ -23,6 +23,7 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changel- [ ] [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.- [ ] [tombstone-gc-manual-trigger-ui] **Wire a manual "GC tombstones now" button on the Instances page.** Today `sharing/tombstoneGc.js#sweepTombstones` only fires from the 60s `syncOrchestrator` interval and uses a hard-coded `GRACE_MS = 24 * 60 * 60 * 1000`, so a user who just mass-deleted records has to wait 24h for them to disappear from `data/universe-builder.json` / `data/pipeline-series.json` / `data/pipeline-issues.json` (even when every subscribed peer has already acked them). Wiring goals: (1) parameterize `sweepTombstones({ now, graceMs })` so callers can override the 24h buffer — keep the 24h default so the orchestrator path is unchanged. (2) Expose `POST /api/sync/tombstones/sweep` with optional `{ graceMs }` body (Zod-validated; clamp to `[0, 24*60*60*1000]` so the button can only shrink the grace, never bypass the ack horizon). The route still calls `cutoffForKind` for each kind so the existing safety checks (peer-ack horizon, refuse-when-snapshot-peer-uncovered) keep firing. (3) Add a "GC tombstones now" button under the Instances page's Sync Status section that POSTs with `graceMs: 0`. Disabled when any enabled peer has snapshot-mode coverage for a kind it isn't subscribed to (mirror the route's null-cutoff refusal). Surfaces the per-kind prune count in a toast (`pruned N universes / M series / K issues` — quiet when zero). (4) One-shot CLI script in `scripts/gc-tombstones-now.js` for headless cleanups (the inline-Node prune we ran 2026-05-23 for the post-Echoes-cleanup batch is the seed). Use `scripts/cleanup-test-data.js`'s pm2-stop-required wording in the header — the prune helpers serialize through per-file write tails that don't cross processes. Surfaced 2026-05-23 during the media-collections sync PR: peer null had acked 82 universe + 192 series tombstones from a same-day mass-delete and the user wanted them off-disk early.+- [ ] [peer-sync-ephemeralize-then-delete-stalls-tombstone] **A previously-shared universe/series that's marked ephemeral, then deleted, never propagates the tombstone when the peer still has other subscriptions of that kind.** Codex iter-8 in v2.7.0 release review (P2). The ephemeralize step's `unsubscribeAllForRecord` removes the per-record sub for that record; the subsequent delete fires `recordEvents.deleted` but there's no sub to push it. The snapshot path in `syncOrchestrator.categoriesCoveredByPeerSync` then suppresses the whole-category snapshot for that peer (because ANY other per-record sub for that kind exists), so the tombstone has no fallback transport either. The peer keeps the old live copy indefinitely. Same root cause as `[peer-sync-snapshot-skip-too-coarse-for-partial-subscriptions]` — the snapshot-skip fix needs to either send the snapshot with subscribed records excluded (so tombstones for unsubscribed-but-previously-known records can still ride it), or detect the ephemeralize-then-delete sequence and proactively push the tombstone before tearing down the sub.- [ ] [peer-sync-per-record-tombstone-ack-cursor] **Tombstone ack cursor is per-peer but should be per-(peer,record).** Codex iter-6 in v2.7.0 release review (P2). Today `ackDeletesUpTo(peerId, deletedAt)` writes a single high-water-mark per peer. If push for record-A fails and a later push for record-B succeeds, the receiver returns `ackedDeletesUpTo = B.deletedAt > A.deletedAt`; the sender then advances the cursor past A's deletedAt even though A was never confirmed delivered. After grace, `tombstoneGc` treats A as acked, prunes it, and A's stale live copy on the receiver resurrects on the next sync that lands. Fix options: (a) per-`(peer, kind, recordId)` cursor (storage proliferation; needs cleanup on record GC); (b) per-(peer, kind) cursor advanced only when the push response cumulatively confirms every-tombstone-up-to-that-deletedAt was delivered (requires receiver to track-and-respond with "I have all your tombstones up to T"); (c) keep current cursor but also persist a per-record `lastConfirmedPushedAt` on each subscription row, and let GC's `cutoffForKind` use `min(min-of-lastConfirmedPushedAt-across-all-records-of-this-kind)`. Option (c) is the smallest behavioral change. Defer because under the dominant single-writer/single-reader pattern in PortOS, push failures are rare and re-tried on the next event tick.- [ ] [peer-sync-medialightbox-use-mediaimage-for-syncing-assets] **`MediaLightbox.jsx` uses a raw `<img src=...>` for the main media element — peer-synced images that haven't been pulled yet show a broken image and don't get the `peerSync:asset-arrived` placeholder/live-swap.** Codex iter-6 in v2.7.0 release review (P2). The `MediaImage` component was added specifically to handle this, but only thumbnail/card paths use it. Replace the lightbox's `<img>` with `MediaImage` so opening an image during the sync window shows the "Syncing" placeholder and atomically swaps to bytes when they land. Cross-check every `<img>` in `MediaPreview.jsx`, `MediaCollectionDetail.jsx`, `UniverseBuilder.jsx` for the same gap. Defer because the lightbox is reached after the user clicks a thumbnail — by then the thumbnail's MediaImage has likely already swapped to live bytes, so the lightbox typically sees the same.- [ ] [peer-sync-snapshot-skip-too-coarse-for-partial-subscriptions] **`syncOrchestrator.categoriesCoveredByPeerSync` skips the entire `universe`/`pipeline` snapshot for any peer with ANY per-record subscription in that category — but partial subscriptions leave the un-subscribed records with no active transport.** Codex iter-4 in v2.7.0 release review (P2). Today: if peer-A has 3 subs for universes A/B/C but the user has 10 universes total, the snapshot for peer-A is fully suppressed. Universes D-J never get edits to peer-A. Two fix options: (a) only suppress the snapshot when the per-record subscription set COVERS every record of that kind for that peer (refresh on subscribe/unsubscribe); (b) send the snapshot but filter out the records that ARE subscribed, so snapshot covers the gap and push covers explicit subs. Option (b) is cleaner — snapshot fills the gap. Scope: `syncOrchestrator.js` skip-decision + `dataSync.getUniverseSnapshot` + `getPipelineSnapshot` accept an exclude-set keyed by record id. Defer because the snapshot-skip works correctly for the common case (peer subscribes to ALL universes or NONE); the partial case requires a thoughtful refactor.diff --git a/server/services/mediaCollections.js b/server/services/mediaCollections.jsindex 832f56b9ff..495b9ab220 100644--- a/server/services/mediaCollections.js+++ b/server/services/mediaCollections.js@@ -563,8 +563,15 @@ const validateItemInput = (item) => {// Mirror sanitizeItem's path-traversal rejection so the write path can't// persist a ref that the next listCollections() read would silently drop// (which would also churn coverKey/updatedAt for the dangling-cover guard).- if (ref.includes('/') || ref.includes('\\') || ref.includes('..')) {- throw makeErr('item.ref invalid (contains path separators or "..")', ERR_VALIDATION);+ // Reject separators and exact `.`/`..` segments only — `..` inside a+ // basename (`my..render.png`) is a legitimate gallery filename. Must+ // mirror sanitizeItem exactly or local addItem rejects refs that peer+ // sync would accept (and vice versa).+ if (ref.includes('/') || ref.includes('\\')) {+ throw makeErr('item.ref invalid (contains path separators)', ERR_VALIDATION);+ }+ if (ref === '.' || ref === '..') {+ throw makeErr('item.ref invalid (parent-directory segment)', ERR_VALIDATION);}return { kind: item.kind, ref };};diff --git a/server/services/mediaCollections.test.js b/server/services/mediaCollections.test.jsindex 96bfdb2bf6..dd1abe491f 100644--- a/server/services/mediaCollections.test.js+++ b/server/services/mediaCollections.test.js@@ -45,16 +45,20 @@ describe('mediaCollections service', () => {.rejects.toMatchObject({ code: svc.ERR_DUPLICATE });});- it('addItem rejects refs with path-traversal tokens up-front', async () => {+ it('addItem rejects refs with true path-traversal segments (but allows .. inside a basename)', async () => {// Mirrors sanitizeItem's path-traversal rejection on the write boundary.- // Without this, an API call could persist an unsafe ref that- // listCollections() would then silently drop on the next read- // (churning coverKey / updatedAt and making items disappear).+ // Reject path SEPARATORS and exact `.`/`..` path segments — NOT every+ // ref containing the substring `..`. Legitimate gallery filenames like+ // `my..render.png` round-trip through reads + peer sync and must be+ // addable through the API too.const c = await svc.createCollection({ name: 'A' });- for (const ref of ['../etc/passwd', 'subdir/file.png', 'a\\b.png', 'foo..bar.png']) {+ for (const ref of ['../etc/passwd', 'subdir/file.png', 'a\\b.png', '..', '.']) {await expect(svc.addItem(c.id, { kind: 'image', ref })).rejects.toMatchObject({ code: svc.ERR_VALIDATION });}+ // And the inverse: refs with `..` in the basename SHOULD succeed.+ await expect(svc.addItem(c.id, { kind: 'image', ref: 'foo..bar.png' }))+ .resolves.toBeTruthy();});it('bulkUpdateCollectionItems rejects path-traversal refs up-front', async () => {diff --git a/setup.sh b/setup.shindex 01161f0012..31e51c4de4 100755--- a/setup.sh+++ b/setup.sh@@ -42,14 +42,25 @@ echo ""if node -e "import('./server/lib/tailscale.js').then(m => process.exit(m.hasOnlySandboxedTailscale() ? 0 : 1)).catch(() => process.exit(1))" 2>/dev/null; thenecho "Detected Tailscale.app without the unsandboxed CLI."echo "Installing tailscale via Homebrew so 'tailscale cert' can write to data/certs/..."+ brewInstalled=0if command -v brew &> /dev/null; then- if ! brew install tailscale; then+ if brew install tailscale; then+ brewInstalled=1+ elseecho "⚠️ brew install tailscale failed — HTTPS via Tailscale won't work until you install it manually."fielseecho "⚠️ Homebrew not found. Install brew (https://brew.sh) then run: brew install tailscale"echo " Without it, the 'Enable HTTPS' button on the Instances page will fail with EPERM."fi+ # Re-run cert setup now that the unsandboxed CLI is available. `npm run+ # setup` already ran setup-cert.js with only the sandboxed CLI, falling+ # back to self-signed; without this re-run the instance stays on the+ # fallback cert until the user manually invokes `npm run setup:cert`.+ if [ "$brewInstalled" = "1" ]; then+ echo "Re-running cert provisioning with the freshly-installed Tailscale CLI..."+ npm run setup:cert || echo "⚠️ setup:cert failed — re-run manually if needed."+ fiecho ""fi