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
docs: record the federated visual-prompt privacy boundary as an ADR (#4682)
[._.]/ Adam Eivy524271fb156f
diff --git a/CLAUDE.md b/CLAUDE.mdindex 05d96df9b5..d5b01e1040 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -28,7 +28,7 @@ npm run test:db # DB-backed suites → portos_test ONLY (see Se- **Auth** — an optional instance password (`server/services/auth.js`, enforced by `server/lib/authGate.js`) gates all of `/api/*` and `/data/*` when set, with a small always-public set (`/api/auth/status`, `/api/system/health`). Peers reach a password-gated instance via a per-peer Basic credential on the peer record, attached to every outbound hop by `peerFetch` (`server/lib/peerHttpClient.js`).- **HTTPS** — provisioned by `npm run setup:cert`; `:5555` flips to TLS with a loopback-only HTTP mirror on `:5553`. Peer hops set `rejectUnauthorized: false` ("Tailnet is the trust boundary") — between two tailnet nodes WireGuard already supplies mutual auth, but a non-tailnet peer (plain LAN IP / non-`.ts.net` host, see `peerRequiresTailscale()`) gets no server authentication.-Because both are off by default, **never treat "the password is set" as an available guarantee** when designing a feature — gate on it explicitly, or design for the default posture. **PII must not ride the federation layer at all** — see ADR [privacy records machine-local](docs/decisions/2026-08-08-privacy-records-machine-local.md).+Because both are off by default, **never treat "the password is set" as an available guarantee** when designing a feature — gate on it explicitly, or design for the default posture. **PII must not ride the federation layer at all** — see ADR [privacy records machine-local](docs/decisions/2026-08-08-privacy-records-machine-local.md). That rule governs *records* and *status/capability payloads*; its one scoped carve-out — a submitted image/video job body carrying the prompt an enrolled peer is being asked to render — is ADR [federated visual prompts](docs/decisions/2026-08-20-federated-visual-prompts.md).**Distribution model (across installs).** PortOS is distributed software: many independent people each run their own install, on their own machine(s), each upgrading on their own schedule — and a single user commonly runs **several machines federated as sync peers**. Backward/forward compatibility across installs and versions is first-class, NOT optional:diff --git a/docs/FEDERATED_MEDIA_PROVIDERS.md b/docs/FEDERATED_MEDIA_PROVIDERS.mdindex baedbd4241..a001d1a296 100644--- a/docs/FEDERATED_MEDIA_PROVIDERS.md+++ b/docs/FEDERATED_MEDIA_PROVIDERS.md@@ -113,6 +113,12 @@ the same user's other machine. The privacy line this project draws is that*status and capability payloads* never carry prompt or record content; asubmitted 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.+## Authentication and identityEvery request requires both:diff --git a/docs/README.md b/docs/README.mdindex 743fcd36e1..fd07d5a82d 100644--- a/docs/README.md+++ b/docs/README.md@@ -47,7 +47,7 @@ Comms & voice: [openclaw-operator-chat](./features/openclaw-operator-chat.md) ([## Point-in-time records- **[plans/](./plans/README.md)** — dated design plans (`YYYY-MM-DD-<slug>.md`), archived on approval before implementation. Historical records, not living docs.-- **decisions/** — ADRs (`YYYY-MM-DD-<slug>.md`), e.g. the [Postgres-as-primary-datastore decision](./decisions/2026-06-07-postgres-as-primary-datastore.md).+- **decisions/** — ADRs (`YYYY-MM-DD-<slug>.md`), e.g. the [Postgres-as-primary-datastore decision](./decisions/2026-06-07-postgres-as-primary-datastore.md) and what may cross the federation layer ([privacy records machine-local](./decisions/2026-08-08-privacy-records-machine-local.md), [federated visual prompts](./decisions/2026-08-20-federated-visual-prompts.md)).- **research/** — dated investigation and incident write-ups (e.g. the [mflux GPU-watchdog panic](./research/2026-06-13-mflux-training-watchdog-panic.md)).- **superpowers/** — plan/spec pairs from superpowers-driven builds: `specs/<date>-<slug>-design.md` (design) + `plans/<date>-<slug>.md` (implementation plan).diff --git a/docs/decisions/2026-08-08-privacy-records-machine-local.md b/docs/decisions/2026-08-08-privacy-records-machine-local.mdindex d7161930c3..1c7fcee584 100644--- a/docs/decisions/2026-08-08-privacy-records-machine-local.md+++ b/docs/decisions/2026-08-08-privacy-records-machine-local.md@@ -8,7 +8,8 @@[`server/lib/vaultCrypto.js`](../../server/lib/vaultCrypto.js),[`server/services/sharing/peerSync.js`](../../server/services/sharing/peerSync.js),[`docs/STORAGE.md`](../STORAGE.md),- ADR [tribe + universe-runs local](./2026-06-26-tribe-and-universe-runs-local.md) (#1724).+ ADR [tribe + universe-runs local](./2026-06-26-tribe-and-universe-runs-local.md) (#1724),+ ADR [federated visual prompts](./2026-08-20-federated-visual-prompts.md) (#4682).## Context@@ -81,6 +82,22 @@ Concretely, and permanently unless this ADR is superseded:A guard test (`server/services/sharing/privacyNeverFederates.test.js`) enforcesthe first two so the boundary fails loudly rather than eroding.+### Scope of the rule this ADR states++`CLAUDE.md` summarizes this decision as the flat rule that **PII must not ride+the federation layer at all**, and for Privacy Center records that is exact and+unconditional. 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 an+explicitly enrolled peer — 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.+### Why not "federate, but gate it on HTTPS + the instance password"This was seriously considered, and the machinery for it already exists: thediff --git a/docs/decisions/2026-08-20-federated-visual-prompts.md b/docs/decisions/2026-08-20-federated-visual-prompts.mdnew file mode 100644index 0000000000..5ae64b1b02--- /dev/null+++ b/docs/decisions/2026-08-20-federated-visual-prompts.md@@ -0,0 +1,151 @@+# ADR: Federated Image/Video Prompts May Cross to a Peer; Status Payloads Never May++- **Date:** 2026-08-20+- **Status:** Accepted+- **Related:** issue #4682 (this record), epic #4348 (federated media providers),+ PRs #4674 / #4676 (the image/video wire and peer-routed renders),+ [`server/lib/validation.js`](../../server/lib/validation.js)+ (`federatedMediaImageJobSubmissionSchema`, `federatedMediaVideoJobSubmissionSchema`),+ [`docs/FEDERATED_MEDIA_PROVIDERS.md`](../FEDERATED_MEDIA_PROVIDERS.md),+ ADR [privacy records machine-local](./2026-08-08-privacy-records-machine-local.md) (#2148).++## Context++`CLAUDE.md` states flatly that **PII must not ride the federation layer at all**,+pointing at the privacy-records ADR. Read literally against the federated media+wire, that rule looks violated: a federated image or video job carries its+`prompt` to the peer as submitted, and a Creative Director / Creative Commission+prompt is generated from project records — it can embed universe canon, character+names, and other personal app data.++Audio is the exception in the other direction. A federated audio submission is+rejected unless its prompt is a canonical string rendered from a fixed+style/mood/instrument profile (`isFederatedMediaAudioPrompt`), and lyrics are+refused outright. That asymmetry is deliberate, but until now it was justified+only by a comment on the schema — so every reviewer who reads the flat rule+against the visual path re-raises the same contradiction, and every answer is+reconstructed from scratch.++This ADR writes the boundary down so the rule and its one scoped carve-out are+readable together.++## Decision++**A submitted job body may carry the prompt the user (or their project) asked to+render. A status or capability payload may never carry prompt or record content.+Those are two different payload classes, and the "no PII on federation" rule+governs the second.**++Concretely:++1. **Image and video prompts cross as submitted.**+ `federatedMediaImageJobSubmissionSchema` and+ `federatedMediaVideoJobSubmissionSchema` accept the prompt (and negative+ prompt) verbatim, bounded only by length. There is no fixed-vocabulary+ re-rendering, because there is no closed taxonomy for arbitrary visual or+ motion content the way audio has a finite style/mood/instrument alphabet. A+ render is *defined by* its prompt; a peer that cannot read the prompt cannot+ do the work at all, so "render this remotely" and "the prompt stays home" are+ mutually exclusive for this kind.++2. **Audio stays fixed-vocabulary.** Music prompts and lyrics are free-form+ natural language whose whole purpose is to carry words, and a finite profile+ alphabet *does* exist for instrumental style. Where a privacy-safe canonical+ form is available at no expressive cost, it is required. Remote lyrical+ conditioning stays unsolved and unshipped (see #4348).++3. **Status and capability payloads stay absolutely prompt-free.**+ `GET /api/federation/media/v1/status` returns allowlisted engine/model pairs,+ readiness signals, queue depth and staleness — never a prompt, a job body, a+ record excerpt, or a filename derived from one. The owner-scoped job+ projection is likewise a sanitized status view. This is the line that must not+ move, and it is the line `CLAUDE.md`'s rule is protecting.++4. **The counterparty is not an anonymous third party.** A federation peer is an+ explicitly registered instance the local user added by hand, authenticated by+ a per-peer Basic credential, and reachable only on a private network —+ typically the same user's own other machine. This is what makes the carve-out+ scoped rather than general: it authorizes sending a prompt to *a machine the+ user enrolled*, not to the internet, and not to a cloud provider's account.++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 enrolled 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 the user enrolled. 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.++### Local input assets are out of scope, and stay out++Init/reference images, keyframes, clips to extend and LoRA weights do not cross+the wire at all: a federated request carrying any of them is rejected with+`400 MEDIA_PROVIDER_INPUT_UNSUPPORTED`. That is a capability limit today rather+than a privacy decision, but the privacy consequence is real — a reference photo+is a far denser personal payload than a text prompt. Input-asset transfer is a+later slice of #4348 and must revisit this ADR before shipping.++## Alternatives considered++- **Render visual prompts from a fixed vocabulary, like audio.** Rejected:+ there is no such vocabulary. Any enum expressive enough to describe an+ arbitrary shot is a natural language, and any enum small enough to be+ privacy-safe cannot express what the user asked for. It would not protect the+ prompt so much as discard it.++- **Strip or redact names before submitting.** Rejected: it makes renders+ silently wrong. A universe's character names are frequently the *subject* of+ the image, so redaction produces a plausible render of the wrong thing —+ the same failure mode the wire already refuses to accept for dropped init+ images.++- **Require the instance password before any prompt crosses.** Rejected as a+ gate, kept as good practice. Authentication is opt-in and off by default+ (`CLAUDE.md`, Security Model), so making it a precondition would either block+ the feature for most installs or, worse, invite an "if unset, send anyway"+ fallback. The tailnet requirement in rule 6 is the narrower gate that actually+ binds the risk unattended routing adds.++- **Forbid federated visual rendering entirely.** Rejected: it deletes the+ feature to protect data from the user's own second machine, which is where the+ data already lives — the peer is enrolled precisely because it is trusted with+ this project's work.++## 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.+- Any future federated kind must be classified against rules 1–3 before it+ ships: 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+ canonical form should adopt audio's pattern rather than the visual one.++## Revisiting++This carve-out is scoped to submitted image/video job bodies travelling to an+enrolled peer on a private network. Widening it — input-asset transfer, routing+to peers the user did not enroll, relaying through a non-PortOS service, or any+path where the counterparty is not the user's own registered instance — requires+a new ADR, not a reading of this one.diff --git a/server/lib/validation.js b/server/lib/validation.jsindex 1aa090df2b..8120553953 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -760,6 +760,8 @@ 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),@@ -781,15 +783,13 @@ const federatedMediaAudioJobSubmissionSchema = federatedMediaJobRoutingSchema.ex}});-// Image/video prompts get no fixed-vocabulary rendering like audio's lyrics-// ban: there is no closed taxonomy for arbitrary visual/motion 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 own other machine) rather than an anonymous third party. The-// PII line this project actually draws is status/capability payloads never-// carrying prompt or record content (see the acceptance criteria on #4348) —-// a submitted job body is not a status payload. Local input assets (init/-// reference images, LoRAs) stay out of scope for this slice; see the PR body.+// 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+// (init/reference images, LoRAs) are refused by the routes, not here.export const federatedMediaImageJobSubmissionSchema = federatedMediaJobRoutingSchema.omit({durationSec: true, durationMode: true,}).extend({diff --git a/server/routes/imageGen.js b/server/routes/imageGen.jsindex 74d83f9e54..46623d40c3 100644--- a/server/routes/imageGen.js+++ b/server/routes/imageGen.js@@ -184,6 +184,9 @@ 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.mediaProviderPeerId: 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/videoGen.js b/server/routes/videoGen.jsindex 3c52bd7716..b4c4c5b199 100644--- a/server/routes/videoGen.js+++ b/server/routes/videoGen.js@@ -326,6 +326,9 @@ 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.mediaProviderPeerId: 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 459403ad24..143dc52b90 100644--- a/server/services/federatedMediaProvider.test.js+++ b/server/services/federatedMediaProvider.test.js@@ -517,4 +517,46 @@ describe('federated media provider — image/video kinds', () => {expect(described.kind).toBe('image');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']);+ const created = await submitFederatedMediaJob({+ callerId: 'peer-example',+ config: imageConfig(),+ input: { ...imageInput(), prompt: PROMPT_SENTINEL },+ idempotencyKey: 'commission-image-privacy',+ });+ 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 job = state.jobs.find((candidate) => candidate.id === created.job.id);+ const filename = `${job.id}.png`;+ writeFileSync(join(tempImagesPath, filename), Buffer.from('fake-png-bytes'));+ Object.assign(job, {+ status: 'completed',+ completedAt: '2026-08-16T00:02:00.000Z',+ result: { filename, engine: 'local', modelId: 'flux-dev' },+ });+ expect(carriesPrompt(await describeFederatedMediaJob('peer-example', job.id))).toBe(false);+ });});