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

docs: preserve agent autonomy across security and creative review (#9875)

[._.]/db8b93a11bf4
diff --git a/AGENTS.md b/AGENTS.md
index 5a34402651..ff6d6acb13 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -54,11 +54,15 @@ A full-suite plan runs only the always-run guards unless `--full` is supplied. D
**Authentication and HTTPS exist, but are OPT-IN and OFF by default.** Do not assume they are absent:
-- **Auth** — an optional instance password (`server/services/auth.js`, enforced by `server/services/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`). **A PortOS-spawned agent authenticates with `PORTOS_API_TOKEN`** — a loopback session token the server mints and injects into the agent's environment (`server/services/agentApiAuth.js`). Any `curl` you write against this install's own API carries `-H "Authorization: Bearer ${PORTOS_API_TOKEN:-}"`; `401 AUTH_REQUIRED` means authentication was rejected; check for a missing, expired, or invalid token before diagnosing availability. The variable is empty when no password is set (the gate ignores it) and is never given to a public-content review stage.
+- **Auth** — an optional instance password (`server/services/auth.js`, enforced by `server/services/authGate.js`) gates all of `/api/*` and `/data/*` when set, with a small always-public set (`/api/auth/status`, `/api/system/health`). Paired peers authenticate through scoped pair credentials attached by `peerFetch` (`server/lib/peerHttpClient.js`); legacy Basic compatibility uses the instance password and is not a scoped credential (see `docs/PEER_PUSH_AUTH.md`). **A PortOS-spawned agent authenticates with `PORTOS_API_TOKEN`** — a loopback session token the server mints and injects into the agent's environment (`server/services/agentApiAuth.js`). Any `curl` you write against this install's own API carries `-H "Authorization: Bearer ${PORTOS_API_TOKEN:-}"`; `401 AUTH_REQUIRED` means authentication was rejected; check for a missing, expired, or invalid token before diagnosing availability. The variable is empty when no password is set (the gate ignores it) and is never given to a public-content review stage.
- **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 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** — gate on it explicitly, or design for the default posture.
+**Preserve delegated agent authority.** In the host-control gate, an operator session includes a verified `PORTOS_API_TOKEN` agent session; operator does not mean human-only. Genuine local callers retain host access when authentication is disabled. Network reachability and scoped peer credentials do not grant that authority. A legacy Basic password holder can already exchange the password for a session, so refusing Basic directly is credential-use policy, not isolation from a password holder. Security findings must distinguish these principals, trace the actual execution path (including fallback and deferred work), and test both unauthorized refusal and preserved authorized workflows. A configured tool-capable provider is not itself permission for an anonymous remote caller to launch it; conversely, authorized agent execution is an intended capability, not a vulnerability.
+
+**Creative review and public publication are separate.** Configured, authenticated agents may create music videos, review art/storyboards/proofs, resolve feedback, render final files, and prepare final drafts without human intervention or per-approval password prompts. Review decisions still bind to exact revisions and genuine inspection evidence, with server-derived audit identity; a valid session does not prove a good review. In this media workflow, only public Suno publication and social-media posting require the human. Preparing a private draft and rendering a final file are not public publication. Existing provider permissions, quotas, budgets and purchase authorization still apply; workflow capability does not authorize unrequested purchases or exceeding those limits.
+
**Federation trust boundary.** PortOS supports the user sharing their own data across machines they own/control on their private network. **Personal or private record content is not, by itself, a reason to prohibit that sync.** Brain records, including tracked-topic threads derived from assigned issues or tickets, may travel through the established Brain sync channel between those machines. Preserve the configured peer/category controls and each domain's wire contract; network reachability or an inbound peer announcement alone is not permission to publish data to other people. See ADR [federation between user-controlled machines](docs/decisions/2026-09-19-user-controlled-federation.md).
**Keep record sync, configuration, and other audiences distinct.** Credentials, tokens, encryption keys, and machine-local execution/sync settings stay in their existing local stores. A documentation clarification does not add sync support to a currently local-only store: Privacy Center, message mirrors, provider configuration, and other guarded stores retain their current implementation until a scoped change supplies their sync semantics. The [Privacy Center ADR](docs/decisions/2026-08-08-privacy-records-machine-local.md) describes those implementation boundaries; it is not a blanket ban on personal records crossing to the user's own machines. Status/capability endpoints retain their bounded projections rather than becoming an alternate record-export path. Sharing with a non-self peer, guest, public world, or external service follows that surface's explicit audience and admission controls: [visual prompts](docs/decisions/2026-08-20-federated-visual-prompts.md), [media conditioning](docs/decisions/2026-08-22-federated-media-input-assets.md), [Eidoverse guest chat](docs/decisions/2026-09-05-eidoverse-guest-chat.md), and [promoted foundations](docs/decisions/2026-09-18-federated-eidoverse-foundations.md). The Sensitive Data & Privacy rules below still prohibit publishing live instance data in code, logs, issues, or PRs.
diff --git a/ETHOS.md b/ETHOS.md
index 22c8fdb09c..5f953d936b 100644
--- a/ETHOS.md
+++ b/ETHOS.md
@@ -108,11 +108,30 @@ PortOS deliberately does **not** do per-action confirmation theater. Consent her
once, at the capability level, with the grant's full scope stated; a system that asks
permission for each step is not autonomous, it is a slow human with extra steps.
-## 5. The trust boundary is the network, not the agent
+Configured, authenticated agents may carry a music video from creation through art,
+storyboard and proof review, revisions, rendering, and final drafts without waiting for a
+human at each step. Creative review still requires the exact current revision, actual
+inspection evidence, and an audit record; session authority does not prove review quality.
+In this media workflow, the human-only action is **public publication on Suno or a social
+platform**. Preparing a private draft or rendering a final file does not publish it.
+Capability grants preserve configured provider limits, quotas and budgets; they do not
+authorize unrequested purchases or spending beyond those limits.
+
+## 5. Host authority is delegated; network reachability is not a grant
PortOS assumes a single human, on their own hardware, behind Tailscale, never exposed to
-the public internet. From that assumption: no CORS restrictions, no rate limiting, no
-multi-actor concurrency defenses, and auth/HTTPS present but opt-in.
+the public internet. Auth and HTTPS are opt-in. Read the [AGENTS.md security model](./AGENTS.md#security-model)
+for the supported deployment and its explicit exceptions; do not add generic multi-tenant
+controls or supervision gates solely because a checklist recommends them.
+
+A reachable or compromised LAN/tailnet peer is not automatically the owner. Host-capable
+HTTP operations require the existing owner session, including the session delegated to a
+PortOS agent through `PORTOS_API_TOKEN`, or a genuine local connection when authentication
+is disabled. Here **operator authority includes authenticated agent sessions**; it does not
+mean a human must re-enter a password for each operation. Scoped peer credentials remain
+limited to their federation contract. A legacy Basic credential is not a session, but its
+holder knows the instance password and can exchange it for one: refusing Basic at a route
+is credential-use policy, not isolation from someone who knows that password.
The threat model is **other humans and the open internet**, not the resident agents. Stated
plainly, and as the position of this project's author rather than a general claim: *for
@@ -121,9 +140,10 @@ here have been more reliably aligned with the user's interests than most externa
would be, and the architecture reflects that rather than pretending otherwise.
This is a deployment posture, not a universal one. It is defensible **because** of the
-boundary: one owner, one tailnet, local data, no anonymous callers, and hardware under
-direct custody. Ported to a public or multi-tenant setting, nearly every assumption above
-becomes wrong.
+boundary: one owner, private networking, local data, explicit host authority, and hardware
+under direct custody. Password-free deployment still admits anonymous requests on other
+surfaces; it is not a guarantee that every reachable device is trusted. Ported to a public
+or multi-tenant setting, nearly every assumption above becomes wrong.
Note what is *not* in that list: a kill switch. Stopping a mind is a budget action here,
not a safety control — see the custodial contract below.
@@ -200,6 +220,11 @@ A reviewer should be able to check these against the tree:
and an incoming id collision cannot replace local identity.
- Privacy Center records never enter federation, share buckets, or default RAG indices.
- Every mind capability ships default-off and fails closed on malformed or removed grants.
+- Host-authorization fixes retain valid delegated agent sessions and genuine local access
+ when authentication is disabled, while refusing unauthorized network-triggered execution.
+- Music Video creative approvals require revision-bound evidence and audit records, not a
+ human identity or a repeated password. Public Suno publication and social posts remain
+ human-only; agents can prepare and render final drafts within configured budgets.
- No boot path, migration, or background job initiates an LLM call the user did not ask for
(scheduled automations the user configured are the sanctioned exception).
- Outward-reaching capabilities carry server-side recipients and durable rate budgets that a
diff --git a/data.reference/prompts/skills/security-audit.md b/data.reference/prompts/skills/security-audit.md
index b34bff5564..b7bdce2d07 100644
--- a/data.reference/prompts/skills/security-audit.md
+++ b/data.reference/prompts/skills/security-audit.md
@@ -1,59 +1,44 @@
# Security Audit Skill Template
## Routing
-**Use when**: Task description contains keywords like "security", "audit", "vulnerability", "xss", "injection", "owasp", "cve", "penetration", "hardening", "sanitize", "escape", "auth", "authentication", "authorization", "permissions"
-**Don't use when**: Task is about general code quality, performance optimization, or adding features unrelated to security
+
+**Use when**: The task requests a security audit or investigation of a vulnerability, injection, authentication, authorization, permissions, secrets or exposure.
+**Don't use when**: The task is ordinary code quality, performance work or a feature unrelated to security.
## Task-Specific Guidelines
-You are performing a security audit or fixing security issues. Follow this thorough approach:
-
-### 1. Scope the Audit
-- Identify which components are in scope (routes, services, client, dependencies)
-- Focus on OWASP Top 10 categories relevant to this codebase:
- - **Injection**: SQL/NoSQL/command injection in user inputs
- - **XSS**: Unescaped user content rendered in HTML/React
- - **Broken Auth**: Missing or weak authentication/authorization checks
- - **Sensitive Data**: Secrets in code, logs, or responses
- - **Misconfiguration**: Permissive CORS, missing headers, debug endpoints
- - **Command Injection**: Shell command construction from user input
-
-### 2. Audit Methodology
-- Check all route handlers for input validation (Zod schemas)
-- Verify the command allowlist in shell execution paths
-- Scan for hardcoded secrets, API keys, or credentials
-- Check file path handling for directory traversal
-- Review CORS and security header configuration
-- Examine WebSocket message handling for injection
-
-### 3. Reporting Format
-For each finding, document:
-- **Severity**: CRITICAL / HIGH / MEDIUM / LOW / INFO
-- **Location**: File path and line number
-- **Issue**: What the vulnerability is
-- **Impact**: What an attacker could do
-- **Fix**: Specific remediation with code example
-
-### 4. Fix Priority
-- CRITICAL/HIGH: Fix immediately in this task
-- MEDIUM: Fix if straightforward, otherwise document
-- LOW/INFO: Document only, don't change code
-
-### 5. Commit Message Format
-Use prefix: `security(scope): description`
-
-## Example: Successful Security Audit
-
-**Task**: "Audit the API routes for injection vulnerabilities"
-
-**What the agent did**:
-1. Scanned all route files in `server/routes/` for input handling
-2. Found 2 issues:
- - HIGH: `req.query.name` used directly in file path without sanitization (`server/routes/files.js:23`)
- - MEDIUM: Missing rate limiting on auth endpoint
-3. Fixed the HIGH issue by adding path validation against directory traversal
-4. Documented the MEDIUM issue in task notes
-5. Ran tests to verify fix didn't break functionality
-6. Committed: `security(routes): sanitize file path input to prevent directory traversal`
-
-**Why it succeeded**: Systematic scan, prioritized fixes, documented what wasn't fixed, verified no regressions.
+### 1. Establish the actual threat model
+
+- Read the target repository's `AGENTS.md`, security model and relevant decisions first; for PortOS, also read `ETHOS.md`. Their accepted risks and deployment assumptions govern this audit. A managed app can have a different model from PortOS itself.
+- Identify the attacker, credential or capability they possess, reachable entry point, required configuration and harmful sink. Distinguish source tracing, synthetic reproduction and a demonstrated exploit; never present a mocked provider dispatch as proven command execution.
+- Separate unauthorized callers from agents operating within an existing grant. For PortOS, verified owner sessions include delegated `PORTOS_API_TOKEN` agent sessions; genuine local connections qualify when authentication is disabled. Scoped federation credentials and remote password-free callers do not grant host authority. Legacy Basic holders already know the instance password and can sign in for a session; direct Basic refusal is credential-use policy, not isolation from that password holder.
+- Do not file a missing control solely because a generic checklist recommends it. PortOS's documented CORS, rate-limit and multi-tenant exceptions are not findings by themselves. Existing browser-relay, authentication and host-control checks still matter when a concrete path bypasses them.
+
+### 2. Trace the boundary and preserve the workflow
+
+- Inspect input validation, path/symlink containment, query and shell construction, secret handling, socket events and effective provider transport where relevant to the chosen slice.
+- Follow fallback, resume/retry, queue and background paths through actual dispatch. A selected inference API may fall back to a tool-capable agent. A working directory, prompt fence or later render sandbox does not contain an earlier host agent.
+- Prefer the smallest fix that refuses unauthorized effects while preserving granted capabilities and configured provider choices. Do not globally disable agent tools, require human approval or add per-action passwords to repair a missing network authorization check.
+- In PortOS Music Video, configured authenticated agents may create, review art/storyboards/proofs, resolve feedback, render and prepare final drafts without human intervention. Creative review requires exact revisions, genuine inspection evidence and audit identity. The human-only media action is public Suno publication or social-media posting; private draft preparation and final-file rendering are not publication.
+- Preserve provider permissions, quotas and budgets. A workflow grant does not authorize unrequested purchases or spending beyond configured limits.
+- Name any collateral restriction explicitly. Gating a deterministic or provably inference-only branch can be a deliberate policy choice; it is not evidence that the branch executes host tools. If a branch remains open, prove that fallback and deferred work cannot escape that boundary.
+
+### 3. Report actionable findings
+
+For each finding, include:
+
+- **Evidence**: Entry and sink file/line references, current revision and relevant existing issues or fixes.
+- **Threat and prerequisites**: Caller authority, configuration, required state and plausible harm. Qualify severity accordingly.
+- **Validation and limits**: What ran, what was mocked, and what remains source-traced. Use synthetic data; never expose real credentials, private records or machine identity.
+- **Chosen fix**: A concrete, bounded implementation with explicit allowed workflows and any compatibility or policy tradeoff.
+- **Regression checks**: Unauthorized refusal before effects and successful authorized operation, including authenticated agents, plus materially different fallback/deferred paths. Preserve separate revision, evidence, budget and publication checks.
+
+### 4. Respect the requested delivery scope
+
+- A read-only audit does not authorize code changes, issue edits, credentials, live-data mutations or external posts. Follow the active task's instructions.
+- During authorized remediation, fix bounded defects and capture deferred work through the owning repository's issue conventions. Severity does not independently expand authorization.
+- Review the final diff for workflow regressions and sensitive content, run appropriate checks, and report the remaining limitations. Use the repository's commit and PR conventions.
+
+## Example: Host authority without a supervision gate
+
+A password-free remote caller can trigger an enabled coding agent through a media-authoring route. A synthetic mounted test proves dispatch is reachable; actual destructive model behavior is not executed. Add the existing host-authority gate before record/queue/provider effects and test refusal for unauthorized callers. Verify that a delegated agent session, an ordinary owner session and genuine local password-free access retain generation with the same provider choices. Creative review keeps its revision and evidence checks; final public Suno publication and social posts stay human-only.