Skip to content

feat(apps): apps are owned by the account key: deploy, secrets and logs from any machine (#375) - #495

Merged
ralyodio merged 1 commit into
masterfrom
feat/375-apps-account-owner
Nov 25, 2026
Merged

ralyodio merged 1 commit into
masterfrom
feat/375-apps-account-owner

Conversation

@ralyodio

Copy link
Copy Markdown
Collaborator

Closes #375.

Apps were signed by the deploying machine's buyer key, so only that machine could redeploy an app, read its logs or delete it. Like hosting sites since v0.3.73, an app is now owned by the account key derived from the producer's c0mpute identity (chat.key), so --name api is the same app from every machine that holds the identity.

The three blockers

  1. Signer. AppRecord (and the image site) are signed with hosting::account_keypair (HKDF c0mpute-hosting-owner-v1, the helper hosting already uses), so app_id_for(owner, name) is the same everywhere. New apps::owner module picks the key: --key auto|account|machine on apps deploy, logs, destroy. auto keeps the owner of an app deployed from this machine, else the account key, else (no identity, or no way to unlock it) this machine's key with a note. An app is never silently forked under a second key.
  2. Owner-only calls. For an account-owned app the CLI boots its swarm with the account keypair as its libp2p identity (NetworkConfig::with_keypair, Supervisor::boot_with_keypair; the key is never written to disk). The holder checks (open_seal, LogsHandler: connecting peer == rec.owner_peer()) are untouched and now pass from any machine.
  3. Owner state. The app key is derived from the identity per app name (ChatKey::derive_subkey, HKDF info c0mpute-apps-app-key-v1 + \n + name), so any machine rebuilds it. Secret env values stay on the machine they were set on (<data_dir>/apps/owner/<name>.json) and sealed on the holders; they are set again wherever you deploy from. destroy and logs work on a machine that never deployed the app: the id comes from the name, and destroy fetches the record to tombstone from the network.

Compatibility

  • No wire change. The record format, the gossip messages and the RPCs are unchanged. Holders on older versions accept account-signed records and owner calls as they are: to them the owner is just another ed25519 key whose peer id matches.
  • Existing apps need no action. An app deployed under a machine key keeps its id, domains and state. auto sees the machine-owned record in the owner file and signs with the machine key (no identity asked for); logs and destroy join as the machine's buyer identity as before.
  • apps deploy --move (on the machine that owns the app) deploys it under the account key and carries the secret env over. The id comes from the owner key, so the app id changes once (repoint TXT _c0mpute-app.<domain>, and [apps] owners allowlists need the new owner key, which the move prints). An app without state is replaced: the old one is tombstoned once the new one answers. State does not move (snapshots belong to an app id and its key): a stateful app starts empty under the new id and the old one is left running, to be removed with apps destroy <name> --key machine --yes once the data is copied. Its owner file is kept as <name>.machine.json until then.

Things a reviewer or operator should know

  • New flags: apps deploy --key, apps deploy --move, apps logs --key, apps destroy --key; MCP apps_deploy takes key and move, apps_destroy takes key.
  • The identity opens with a password prompt on a terminal, C0MPUTE_DM_PASSWORD without one (git push deploys, c0mpute apps mcp, CI). With an identity present but locked and no app deployed from the machine yet, auto falls back to the machine key with a note, as hosting does.
  • A first deploy of an account-owned app from a machine with no secret env set, when the live app runs with some, is refused instead of dropping them (secret values cannot be read back from the network).
  • Derived keys are never stored: the owner key and app key are recomputed from the identity. The account-identity swarm keeps only its job secret in <data_dir>/apps/account-node.
  • Two processes on one peer id disturb each other's connections, so run one owner command per identity at a time (documented).
  • apps status <name> on a machine that never deployed the app resolves the id through the account key (asks for the identity password).
  • c0mpute-net: NetworkConfig gained an optional keypair field (default None: unchanged behaviour).

Out of scope

The last paragraph of the issue (the c0mpute.com cloud node signs every account's pushes with one shared key, apps/web/src/lib/chat/push.ts) is custodial by nature and is not changed here; docs/apps.md says so.

Tests

  • apps::owner: derivation determinism (owner, app id, peer id, app key the same for one identity; distinct per identity and per app name; app key label distinct from the account and storage labels), the owner-peer check (an account-signed record names the account peer, not the machine's or another identity's), legacy id retention (a machine-owned app keeps its id and needs no identity), the move path, no forking under another key, owner calls from a machine that never deployed.
  • apps::deploy: same sealed secrets on every machine for an account app, a machine-owned app keeps its stored key, a move carries the secret env under the derived key, a first deploy from another machine never drops live secrets.
  • tests/apps_account_owner_e2e.rs (loopback libp2p, fake docker): a record signed with the account key on "machine A" and carried by another node; "machine B" with the same identity and no app state joins as the account key, the unchanged holders accept its sealed secrets and answer its log request, and a machine-key peer is refused the logs.
  • docs/apps.md: "Who owns an app".

🤖 Generated with Claude Code

…oy from any machine (#375)

Apps were signed by the deploying machine's buyer key, so only that machine
could redeploy, read logs or delete. Like hosting sites since 0.3.73, an app
is now owned by the account key derived from the producer's c0mpute identity.

- Signer: AppRecord / the image site are signed with hosting::account_keypair,
  so app_id_for(owner, name) is the same on every machine. `--key
  auto|account|machine` picks the key; an app already deployed under a machine
  key keeps its id and that machine's control until `apps deploy --move`.
- Owner-only calls: the CLI joins the network as the account key
  (NetworkConfig::with_keypair, Supervisor::boot_with_keypair), so a holder's
  `peer == owner_peer()` check for sealed secrets and logs holds from any
  machine. Nothing changes on holders or on the wire.
- Owner state: the app key is derived from the identity per app name (HKDF
  `c0mpute-apps-app-key-v1` + name) instead of living in one machine's file.
  Secret env stays per machine and sealed on holders; a first deploy from a
  machine with none set, of an app running with some, is refused.
- destroy and logs resolve the app id from the name and fetch the record from
  the network when this machine never deployed the app.
- --move deploys under the account key (new app id), carries the secret env,
  deletes the machine-owned app once the new one answers, and leaves a
  stateful one running (state does not move between app ids).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

26 finding(s)

HIGH/CRITICAL: 2 | MEDIUM: 20 | LOW: 4

Severity Rule Location
HIGH js-ssrf-outbound-request apps/web/public/sw.js:24
HIGH sh-remote-script-execution scripts/install.sh:618
MEDIUM gha-ssh-key-secret .github/workflows/deploy-dev2.yml:180
MEDIUM js-unescaped-html-sink apps/web/src/app/blog/[slug]/page.tsx:53
MEDIUM js-unescaped-html-sink apps/web/src/app/layout.tsx:111
MEDIUM js-open-redirect apps/web/src/components/sign-in-options.tsx:16
MEDIUM sql-template-interpolation apps/web/src/lib/accounts/alerts.ts:458
MEDIUM sql-template-interpolation apps/web/src/lib/accounts/fleet.ts:386
MEDIUM sql-template-interpolation apps/web/src/lib/chat/convo-store.ts:116
MEDIUM sql-template-interpolation apps/web/src/lib/chat/convo-store.ts:117
MEDIUM sql-template-interpolation apps/web/src/lib/chat/push.ts:489
MEDIUM sql-template-interpolation apps/web/src/lib/chat/share-store.ts:171
MEDIUM sql-template-interpolation apps/web/src/lib/disk/apps.ts:194
MEDIUM sql-template-interpolation apps/web/src/lib/disk/store.ts:237
MEDIUM sql-template-interpolation apps/web/src/lib/earnings/store.ts:216
MEDIUM sql-template-interpolation apps/web/src/lib/earnings/store.ts:319
MEDIUM sql-template-interpolation apps/web/src/lib/gallery/store.ts:284
MEDIUM js-dynamic-code-execution apps/web/src/lib/router/verify.ts:91
MEDIUM py-stack-trace-returned docker/worker/status_ui.py:35
MEDIUM sh-remote-script-execution scripts/dev-setup.sh:25
MEDIUM sh-eval-expansion scripts/dev-setup.sh:35
MEDIUM redos-nested-quantifier scripts/dev2-dns-recovery.py:31
LOW py-ssrf-outbound-request examples/business-strategist-agent/chat.py:37
LOW py-ssrf-outbound-request examples/business-strategist-agent/train.py:54
LOW secret-generic-credential node/crates/c0mpute-core/src/webhook.rs:1171
LOW py-path-traversal node/crates/c0mpute-core/tests/fixtures/fake-infernet-text:29

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio merged commit 5fe2925 into master Nov 25, 2026
ralyodio added a commit that referenced this pull request Nov 25, 2026
…ke and relay table (#494), stale app error fix

scripts/bump-version.sh 0.3.113, plus the workspace crate versions in
Cargo.lock.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
ralyodio added a commit that referenced this pull request Nov 25, 2026
…again; bump v0.3.113 (#498)

* fix(apps): clear the "stopped for disk" error once the app runs again (#394)

stop_for_disk records why a node stopped an app in Local.error, which is
persisted and returned by /apps/v1/apps. Nothing ever cleared it, so after
the disk recovered and the app restarted the status API kept saying
"stopped at ...: this node's docker disk is down to 18 GiB free" next to
healthy: true. Seen live on gateway.c0mpute.com on 2026-11-25: four apps
up and answering 200, all four still carrying the error from the previous
evening.

Clear it when the container starts successfully as primary.

Refs #394 (product surface must reflect verified live state).

Co-Authored-By: Claude Fable 5.2 <[email protected]>

* bump v0.3.113: apps owned by the account key (#495), Scallion handshake and relay table (#494), stale app error fix

scripts/bump-version.sh 0.3.113, plus the workspace crate versions in
Cargo.lock.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

---------

Co-authored-by: Claude Fable 5.2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apps: owned by the account key, deploy/secrets/logs from any machine

1 participant