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
apply /simplify findings: dedupe the rationale and widen the guard to all kinds
[._.]/ Adam Eivy150e9cd10697
diff --git a/docs/FEDERATED_MEDIA_PROVIDERS.md b/docs/FEDERATED_MEDIA_PROVIDERS.mdindex a001d1a296..a99a229f17 100644--- a/docs/FEDERATED_MEDIA_PROVIDERS.md+++ b/docs/FEDERATED_MEDIA_PROVIDERS.md@@ -106,18 +106,10 @@ return a plausible render of the wrong thing. Input-asset transfer is a laterslice.Unlike audio, image and video prompts cross as submitted rather than being-re-rendered from a fixed vocabulary. There is no closed taxonomy for arbitrary-visual content the way audio has a finite style/mood/instrument alphabet, and a-federation peer is an authenticated, explicitly registered instance — typically-the same user's other machine. The privacy line this project draws is that-*status and capability payloads* never carry prompt or record content; a-submitted job body is not a status payload.--That boundary is recorded as ADR-[federated visual prompts](./decisions/2026-08-20-federated-visual-prompts.md),-which also states what a future standing (unattended) route may not do: fan out-beyond the peer the operator named, fall back to a different peer on failure, or-route to a peer that is not a tailnet host.+re-rendered from a fixed vocabulary. Why that is not a hole in the "no PII on+federation" rule, what stays absolutely prompt-free, and what a future standing+(unattended) route may not do are all decided in ADR+[federated visual prompts](./decisions/2026-08-20-federated-visual-prompts.md).## Authentication and identitydiff --git a/docs/decisions/2026-08-08-privacy-records-machine-local.md b/docs/decisions/2026-08-08-privacy-records-machine-local.mdindex 6600ac5db3..a0f251bd73 100644--- a/docs/decisions/2026-08-08-privacy-records-machine-local.md+++ b/docs/decisions/2026-08-08-privacy-records-machine-local.md@@ -87,16 +87,10 @@ the first two so the boundary fails loudly rather than eroding.`CLAUDE.md` summarizes this decision as the flat rule that **PII must not ridethe federation layer at all**, and for Privacy Center records that is exact andunconditional. The rule governs *records* — what one instance replicates to-another, and what a status or capability payload may disclose about the data-this machine holds. It is not a rule that no user-authored text may ever be-addressed to a peer: a federated media job body carries the prompt the user-asked to render, because the render is not possible otherwise. That single-scoped carve-out — submitted image/video job bodies travelling to a peer this-install has allowlisted for that work — is recorded in ADR-[federated visual prompts](./2026-08-20-federated-visual-prompts.md) (#4682),-which also fixes what stays absolutely prompt-free (status and capability-payloads) and why audio is restricted to a fixed vocabulary instead. Read the-two together; neither weakens the other.+another, and what a status or capability payload may disclose. It is not a rule+that no user-authored text may ever be addressed to a peer: its one scoped+carve-out, submitted image/video job bodies, is decided in ADR+[federated visual prompts](./2026-08-20-federated-visual-prompts.md) (#4682).### Why not "federate, but gate it on HTTPS + the instance password"diff --git a/docs/decisions/2026-08-20-federated-visual-prompts.md b/docs/decisions/2026-08-20-federated-visual-prompts.mdindex bab0590d6d..b96ddb2414 100644--- a/docs/decisions/2026-08-20-federated-visual-prompts.md+++ b/docs/decisions/2026-08-20-federated-visual-prompts.md@@ -89,28 +89,23 @@ Concretely:benefits every federated surface and is tracked with the transport work, nothere.-5. **Unattended routing does not widen this boundary.** A configured route names- one peer, one kind and one model; the operator opts in per kind, exactly as- they opt in per job today. What changes is review cadence, not audience — the- same prompts go to the same allowlisted machine. An unattended route may never- fan out to peers the user did not name, may never fall back to a different- peer on failure, and may never relax rules 1–3.--6. **Unattended routes require a tailnet peer.** Where an interactive render is- routed by a human who picked that peer for that job, a standing route exports- every future prompt of its kind without review, so a misconfigured- counterparty is a permanent leak rather than a one-time one. `peerFetch` sets- `rejectUnauthorized: false` ("Tailnet is the trust boundary"): between two- tailnet nodes WireGuard already supplies mutual authentication, but a- plain-LAN or non-`.ts.net` peer gets **no server authentication** — nothing- proves the far end is the machine whose record the user allowlisted.- Authentication does not save this: the prompt rides the request body, so an- impostor holding the connection reads it before it fails to answer. That is- an acceptable risk for a per-job human decision and not for a standing one.- When unattended- routing ships, configuring a route to a peer that- `peerRequiresTailscale()`-style detection does not recognize as a tailnet host- must be refused, naming the reason. Interactive routing is unchanged.+5. **Unattended routing does not widen the audience, but it must be gated on a+ tailnet peer.** A configured route names one peer, one kind and one model, so+ the same prompts reach the same allowlisted machine — what changes is review+ cadence. It may never fan out to peers the allowlist does not cover, never+ fall back to a different peer on failure, and never relax rules 1–3.++ One thing does change enough to need its own gate. A standing route exports+ every future prompt of its kind without a human looking, so a misconfigured+ counterparty is a permanent leak where an interactive mistake is a one-time+ one — and `peerFetch`'s `rejectUnauthorized: false` posture leaves a plain-LAN+ or non-`.ts.net` peer with no server authentication at all (see the HTTPS+ bullet in `CLAUDE.md`). Authentication does not save this: the prompt rides+ the request body, so an impostor holding the connection reads it before it+ fails to answer. When unattended routing ships, a route whose peer is not+ recognized as a tailnet host must be refused, naming the reason (see+ Consequences for why that check needs its own predicate rather than a+ re-export of the probe-deferral one). Interactive routing is unchanged.### Local input assets are out of scope, and stay out@@ -141,11 +136,9 @@ later slice of #4348 and must revisit this ADR before shipping.produces that after verifying the instance password, so a provider running thedefault passwordless posture rejects every federated job with`MEDIA_PROVIDER_PEER_AUTH_REQUIRED`. No prompt crosses to an unauthenticated- install today, and this ADR does not relax that. What it deliberately does- *not* do is make a stronger per-peer cryptographic binding a precondition for- the visual carve-out: that gap applies equally to audio and to every other- federated surface, so blocking this decision on it would fix nothing specific- to prompts.+ install today, and this ADR does not relax that. It also does not make the+ stronger per-peer binding described in rule 4 a precondition — that gap is not+ prompt-specific, so blocking this decision on it would fix nothing here.- **Forbid federated visual rendering entirely.** Rejected: it deletes thefeature to protect data from the user's own second machine, which is where the@@ -154,18 +147,20 @@ later slice of #4348 and must revisit this ADR before shipping.## Consequences-- The flat "no PII on federation" rule in `CLAUDE.md` now reads with one scoped- carve-out attached: *submitted job bodies for image/video rendering*. The- privacy-records ADR cross-references this record so the two are read together.- Privacy Center records remain machine-local and unaffected — nothing here adds- a federated kind, a sync category, or a wire version.-- The schemas and route branches stop restating the rationale inline and point- at this ADR instead, so the argument lives in one place and a reviewer's- objection has a citable answer.-- Implementing rule 6 means `peerRequiresTailscale()` (currently module-private- in `server/services/instances.js`) has to become reachable from wherever an- unattended route is validated. That is left to the slice that ships unattended- routing rather than exported ahead of a consumer.+- Privacy Center records are unaffected: nothing here adds a federated kind, a+ sync category, or a wire version. `CLAUDE.md` and the privacy-records ADR link+ here rather than re-arguing the carve-out, and the schemas and route fields+ stop restating the rationale inline, so a reviewer's objection has one citable+ answer instead of four paraphrases.+- Rule 5's tailnet gate needs a predicate of its own. `peerRequiresTailscale()`+ (`server/services/instances.js`) is the right *shape*, but it is module-private+ and its job is probe deferral — an availability heuristic that a future+ polling-noise fix is free to loosen. Re-exporting it as a security gate would+ let that loosening silently widen this boundary, so the slice shipping+ unattended routing owns a deliberate predicate rather than a borrowed one.+- Rule 3 is enforced, not just asserted: a guard in+ `server/services/federatedMediaProvider.test.js` submits a job per kind and+ fails if its prompt reaches the status payload or either job projection.- Any future federated kind must be classified against rules 1–3 before itships: is its payload a *submission* (may carry what the work is) or a *status*(may not carry anything)? A kind whose free-form content has a privacy-safe@@ -173,9 +168,6 @@ later slice of #4348 and must revisit this ADR before shipping.## Revisiting-This carve-out is scoped to submitted image/video job bodies travelling to an-peer this install has enabled and allowlisted for that kind, on a private-network. Widening it — input-asset transfer, routing to peers the local-allowlist does not cover, relaying through a non-PortOS service, or any path-where the counterparty is not one of the user's own registered instances —-requires a new ADR, not a reading of this one.+Widening the carve-out requires a new ADR, not a reading of this one — in+particular input-asset transfer, or relaying through anything that is not a+PortOS instance this install has allowlisted for that kind of work.diff --git a/server/lib/validation.js b/server/lib/validation.jsindex 8120553953..df8f3825d5 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -760,8 +760,6 @@ export const federatedMediaJobRoutingSchema = z.object({// canonical fixed-vocabulary instrumental prompt. Free-form prompt/lyrics can// contain PII and must remain on the consumer; URLs, paths, commands, provider// credentials, and unknown fields are excluded by the strict object as before.-// Why audio is restricted here where image/video below is not:-// docs/decisions/2026-08-20-federated-visual-prompts.mdconst federatedMediaAudioJobSubmissionSchema = federatedMediaJobRoutingSchema.extend({kind: z.literal('audio'),prompt: z.string().trim().min(1).max(8000),@@ -784,11 +782,11 @@ const federatedMediaAudioJobSubmissionSchema = federatedMediaJobRoutingSchema.ex});// Image/video prompts cross as submitted, with no fixed-vocabulary rendering-// like audio's. That boundary — a submitted job body is not a status payload,-// status/capability payloads stay absolutely prompt-free, and unattended-// routing does not widen either — is recorded in-// docs/decisions/2026-08-20-federated-visual-prompts.md. Read it before-// loosening or tightening what these two schemas accept. Local input assets+// like audio's: there is no closed taxonomy for arbitrary visual/motion content+// the way audio has a finite style/mood/instrument alphabet. Why that does not+// breach the "no PII on federation" rule — a submitted job body is not a status+// payload, and status/capability payloads stay absolutely prompt-free — is+// ADR docs/decisions/2026-08-20-federated-visual-prompts.md. Local input assets// (init/reference images, LoRAs) are refused by the routes, not here.export const federatedMediaImageJobSubmissionSchema = federatedMediaJobRoutingSchema.omit({durationSec: true, durationMode: true,@@ -803,6 +801,7 @@ export const federatedMediaImageJobSubmissionSchema = federatedMediaJobRoutingScseed: z.number().int().min(0).optional(),}).strict().refine(refineImagePixelCap, { message: PIXEL_CAP_MESSAGE, path: ['width'] });+// Same boundary as the image schema above — see the ADR named there.export const federatedMediaVideoJobSubmissionSchema = federatedMediaJobRoutingSchema.omit({durationSec: true, durationMode: true,}).extend({diff --git a/server/routes/imageGen.js b/server/routes/imageGen.jsindex 46623d40c3..38418c5db2 100644--- a/server/routes/imageGen.js+++ b/server/routes/imageGen.js@@ -184,9 +184,8 @@ const generateSchema = z.object({// peer by naming one here. mediaProviderEngine names the provider-side// engine within that allowlist; local image/video generation registers as// 'local', which is the only engine a provider can currently advertise.- // Naming a peer here sends this prompt to it; what may and may not cross is- // ADR docs/decisions/2026-08-20-federated-visual-prompts.md, which also fixes- // the extra constraint a future standing/unattended route has to satisfy.+ // What may cross to a peer, and what may not:+ // docs/decisions/2026-08-20-federated-visual-prompts.mdmediaProviderPeerId: z.string().uuid().optional(),mediaProviderEngine: z.string().trim().min(1).max(80).optional(),}).refine(refineImagePixelCap, { message: PIXEL_CAP_MESSAGE, path: ['width'] });diff --git a/server/routes/music.js b/server/routes/music.jsindex 3c6caf0ecd..bd9f773c05 100644--- a/server/routes/music.js+++ b/server/routes/music.js@@ -350,6 +350,8 @@ const generateSchema = z.object({// The peer record id is machine-local routing intent. It never crosses the// provider boundary. Free-form text stays local too: remote execution uses a// fixed-vocabulary instrumental profile rendered by the worker.+ // Why audio alone is restricted that way:+ // docs/decisions/2026-08-20-federated-visual-prompts.mdmediaProviderPeerId: z.string().uuid().optional(),remoteMusicProfile: federatedMediaAudioProfileSchema.optional(),durationSec: z.number().positive().max(600).optional(),diff --git a/server/routes/videoGen.js b/server/routes/videoGen.jsindex b4c4c5b199..d77a282754 100644--- a/server/routes/videoGen.js+++ b/server/routes/videoGen.js@@ -326,9 +326,8 @@ const generateBodySchema = z.object({// the per-peer allowlist, so naming a peer here cannot route work to one the// local user never opted into. `mediaProviderEngine` names the provider-side// engine inside that allowlist (local generation registers as 'local').- // Naming a peer here sends this prompt to it; what may and may not cross is- // ADR docs/decisions/2026-08-20-federated-visual-prompts.md, which also fixes- // the extra constraint a future standing/unattended route has to satisfy.+ // What may cross to a peer, and what may not:+ // docs/decisions/2026-08-20-federated-visual-prompts.mdmediaProviderPeerId: z.string().guid().optional(),mediaProviderEngine: z.string().trim().min(1).max(80).optional(),});diff --git a/server/services/federatedMediaProvider.test.js b/server/services/federatedMediaProvider.test.jsindex 143dc52b90..8eb79cd66b 100644--- a/server/services/federatedMediaProvider.test.js+++ b/server/services/federatedMediaProvider.test.js@@ -518,45 +518,126 @@ describe('federated media provider — image/video kinds', () => {expect(described.result).toMatchObject({ available: true, mimeType: 'image/png', sizeBytes: bytes.length });});- // ADR docs/decisions/2026-08-20-federated-visual-prompts.md draws the line at- // payload class, not at the prompt: a submitted job body may carry the prompt- // the peer is being asked to render, but a status/capability payload and the- // read-back job projection must never carry prompt or record content. A- // visual prompt is generated from project records, so a leak here would put- // universe canon and character names into a payload the ADR says is- // absolutely prompt-free.- it('keeps the prompt out of the status payload and the job projection', async () => {- const PROMPT_SENTINEL = 'a lighthouse at dawn over Example Bay';- state.settings = {- federation: { mediaProvider: imageConfig() },- imageGen: { local: { pythonPath: '/usr/bin/python3' } },- };- state.cachedRepos = new Set(['black-forest-labs/FLUX.1-dev']);+});++// ADR docs/decisions/2026-08-20-federated-visual-prompts.md draws the privacy+// line at payload *class*, not at the prompt: a submitted job body may carry+// the prompt the peer is being asked to render, but a status/capability payload+// and the read-back job projection must never carry prompt or record content.+// A prompt is generated from project records, so a leak here would put universe+// canon and character names into a payload the ADR says is absolutely+// prompt-free. Both guarded paths (getFederatedMediaProviderStatus,+// describeFederatedMediaJob) are kind-agnostic allowlists, so every kind is+// exercised — a per-kind field added to either is exactly the regression.+describe('federated media provider — prompt-free status and projection payloads', () => {+ const IMAGE_PROMPT = 'a lighthouse at dawn over Example Bay';+ const VIDEO_PROMPT = 'a tram climbing a hill in Example City';++ const kinds = [+ {+ kind: 'audio',+ // Audio prompts are already restricted to a canonical profile string, so+ // the sentinel is a fragment of that rather than free text.+ sentinel: 'dreamy',+ resultDir: () => tempMusicPath,+ resultName: (id) => `music-gen-${id}.wav`,+ setup: () => {+ state.settings = { federation: { mediaProvider: config() } };+ },+ config: () => config(),+ input: () => input(),+ },+ {+ kind: 'image',+ sentinel: IMAGE_PROMPT,+ resultDir: () => tempImagesPath,+ resultName: (id) => `${id}.png`,+ setup: () => {+ state.imageModels = [{ id: 'flux-dev', name: 'FLUX.1 dev', repo: 'black-forest-labs/FLUX.1-dev' }];+ state.cachedRepos = new Set(['black-forest-labs/FLUX.1-dev']);+ state.settings = {+ federation: { mediaProvider: imagePrivacyConfig() },+ imageGen: { local: { pythonPath: '/usr/bin/python3' } },+ };+ },+ config: () => imagePrivacyConfig(),+ input: () => ({+ engine: 'local', modelId: 'flux-dev', kind: 'image',+ prompt: IMAGE_PROMPT, width: 1024, height: 1024,+ }),+ },+ {+ kind: 'video',+ sentinel: VIDEO_PROMPT,+ resultDir: () => tempVideosPath,+ resultName: (id) => `${id}.mp4`,+ setup: () => {+ state.videoModels = [{+ id: 'ltx2', name: 'LTX2', runtime: 'ltx2', repo: 'example/ltx2', supportedModes: ['text'],+ }];+ state.cachedRepos = new Set(['example/ltx2']);+ state.settings = { federation: { mediaProvider: videoPrivacyConfig() } };+ },+ config: () => videoPrivacyConfig(),+ input: () => ({ engine: 'local', modelId: 'ltx2', kind: 'video', prompt: VIDEO_PROMPT }),+ },+ ];++ const imagePrivacyConfig = () => ({+ enabled: true, maxQueuedJobs: 2, audioModels: [],+ imageModels: [{ engine: 'local', modelId: 'flux-dev' }], videoModels: [],+ });+ const videoPrivacyConfig = () => ({+ enabled: true, maxQueuedJobs: 2, audioModels: [], imageModels: [],+ videoModels: [{ engine: 'local', modelId: 'ltx2' }],+ });++ it.each(kinds)('keeps the $kind prompt out of the status payload and both job projections', async (scenario) => {+ scenario.setup();const created = await submitFederatedMediaJob({callerId: 'peer-example',- config: imageConfig(),- input: { ...imageInput(), prompt: PROMPT_SENTINEL },- idempotencyKey: 'commission-image-privacy',+ config: scenario.config(),+ input: scenario.input(),+ idempotencyKey: `privacy-${scenario.kind}`,});- const carriesPrompt = (payload) => JSON.stringify(payload ?? null).includes(PROMPT_SENTINEL);-- // Bypass probe: the detector only means something if it fires on a payload- // that genuinely does carry the prompt. The queued job params legitimately- // do — that is the local render input, not a wire payload.- expect(carriesPrompt(enqueueJob.mock.calls.at(-1)[0].params)).toBe(true);-- expect(carriesPrompt(created.job)).toBe(false);- expect(carriesPrompt(await getFederatedMediaProviderStatus(imageConfig(), { kinds: ['image'] }))).toBe(false);- expect(carriesPrompt(await describeFederatedMediaJob('peer-example', created.job.id))).toBe(false);-+ const payload = (value) => JSON.stringify(value ?? null);++ // Bypass probe: these assertions only mean something if the sentinel is+ // findable at all. The queued job params legitimately carry it — that is+ // the local render input, not a wire payload.+ expect(payload(enqueueJob.mock.calls.at(-1)[0].params)).toContain(scenario.sentinel);++ // submitFederatedMediaJob returns describeFederatedMediaJob's projection,+ // so this is both the submit response and the queued poll response.+ expect(payload(created.job)).not.toContain(scenario.sentinel);++ const status = await getFederatedMediaProviderStatus(scenario.config(), { kinds: [scenario.kind] });+ expect(payload(status)).not.toContain(scenario.sentinel);+ // The underscore-prefixed internals publicCapability strips are not prompts,+ // but _pythonPath is an absolute local interpreter path — record content by+ // the same rule, and the one field this payload could realistically regress+ // into leaking if that map is ever dropped.+ expect(status.capabilities[0]).not.toHaveProperty('_pythonPath');+ expect(status.capabilities[0]).not.toHaveProperty('_model');++ // The completed projection is the third payload class: it gains a result+ // block built per kind from the rendered file, which must not reintroduce+ // the prompt.const job = state.jobs.find((candidate) => candidate.id === created.job.id);- const filename = `${job.id}.png`;- writeFileSync(join(tempImagesPath, filename), Buffer.from('fake-png-bytes'));+ const filename = scenario.resultName(job.id);+ const resultPath = join(scenario.resultDir(), filename);+ // Job ids restart at 1 per test while the temp dirs live for the whole+ // file, so an earlier test's render can already sit at this path — drop it,+ // or this case would still pass with its own write removed.+ rmSync(resultPath, { force: true });+ writeFileSync(resultPath, Buffer.from('fake-media-bytes'));Object.assign(job, {status: 'completed',completedAt: '2026-08-16T00:02:00.000Z',- result: { filename, engine: 'local', modelId: 'flux-dev' },+ result: { filename, engine: scenario.input().engine, modelId: scenario.input().modelId },});- expect(carriesPrompt(await describeFederatedMediaJob('peer-example', job.id))).toBe(false);+ const completed = await describeFederatedMediaJob('peer-example', job.id);+ expect(completed.result).toMatchObject({ available: true });+ expect(payload(completed)).not.toContain(scenario.sentinel);});});