Skip to content

Hosted bridge stops itself when idle or at a daily hour (#1059, phases 1–2) - #1063

Merged
NiKrause merged 1 commit into
mainfrom
feat/hosted-auto-stop
Nov 29, 2026
Merged

NiKrause merged 1 commit into
mainfrom
feat/hosted-auto-stop

Conversation

@NiKrause

@NiKrause NiKrause commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Phases 1 and 2 of #1059: a hosted bridge (Aleph confidential VM) that ends itself after a quiet time or at a daily hour, by sending a FORGET that the owner's browser pre-signed for exactly this VM. Off by default until the paid round trip (phase 3) has passed.

Builds on the concept merged in #1060: docs/hosted-auto-stop.md is updated here to what was built.

Step 0: checked before building

Run-time state that lives only in the tmpfs

  • The bridge's key of the books (bridge_auth) is derived again at every unlock. Its peer key is kept in the sealed settings. A hosted bridge has no handover: it starts armed. Nothing to keep.
  • Device grants (device-grants.json) come back with the device list handed over at the unlock, with each device's initial scopes. On a hosted bridge no device holds the pairing scope, so nothing narrows scopes at run time. Nothing to keep.
  • Enable Banking: a bank linked or unlinked on a hosted bridge changed only the sealed file in its tmpfs, and was lost at the next stop. settings.export cannot take it back, because a hosted bridge has no holder. Decision: written back to the books.
    • A new stream-only command enablebanking.sealed (hosted bridge only, scope bridge:bank:link) answers the sealed file as it is.
    • After a link or an unlink, an owner's device keeps it in the books' kept settings. It is sealed with the enablebanking key the books already hold.
    • The next unlock hands it over again.

The FORGET's time and the delegation (read in pyaleph main ee62fc9; no message sent)

  • Paperless fix(backup): the backup card calls the product "Le Space Belege" #434's finding holds:
    • check_time only parses time; there is no bound either way.
    • ForgetMessageHandler.check_permissions checks the sender with is_sender_authorized_for_owner against the owner's current security aggregate, at processing.
  • For the bridge's payers:
    • When the books' key pays, it is sender and owner: always allowed.
    • When Le Space pays (sub-account, books' key as delegate), the delegation must still stand when the VM sends the FORGET. pyaleph evaluates the right "as if creating the target", so for an INSTANCE that means the delegate's INSTANCE right. If it was taken back, Aleph rejects the FORGET and the VM runs on until stopped in the app.
  • A pre-signed FORGET's time is its signing time. The app therefore takes the stop's time from reception_time, which every pyaleph message status carries.

Phase 1: guest (image sources; nothing published)

  • bridge/src/activity.js. With --hosted, the bridge writes activity.json beside its config, in the VM's tmpfs (0700). It holds the last command's time and how many commands run. It is a file, not a listener, so nothing new faces the network and belege-bridge-check is unchanged.
    • Counted: every command of the table a device calls over the stream (by name or request), from the moment it is authorized until it ends.
    • Not counted: bridge.health, backup.status, llm.status, lanRelay.status, the node's own UCEP commands, relay pings and reservations, and /attest.
  • belege-bridge-auto-stop runs once a minute as a systemd loop unit, like the others.
    • It moves auto_stop out of /tmp/secrets into a root-only directory in /run and zeroes the copy.
    • A stop is due after the idle minutes, or at the daily hour (IANA zone via zoneinfo, tzdata added to the image) after ten quiet minutes.
    • Never while a command runs (a running command counts only while the activity file is fresh, and for at most 3 h). Never before postponeUntil.
    • The FORGET is checked before it is sent: exactly one VM, no aggregates, an https API. It is sent once, then followed until processed. "Rejected" keeps the VM running; "unreachable" is tried again after 5 minutes.
    • Never logged; the log line says only the reason.
  • /bridge/status.json gets capabilities.autoStop: 1 and autoStop: { reason, at, stopping }: the reason and one time, nothing else.
  • Tests in bridge/test/auto-stop.test.js, with a fake clock against the fake Aleph using real signatures. The fake now answers reception_time, has revoke(), and checks the right when the FORGET comes. bridge/test/node.test.js checks that a command counts and a status read does not.

Phase 2: app

  • Setting. "Selbst beenden" on the "Gehostete Bridge" card: never / 30 min / 1 h / 2 h / another value (15–1440), a daily time, the browser's time zone, and "postponed until". It is kept in the sealed settings (bridge/hosted-auto-stop), off by default and owner-only.
  • At the unlock, after the attestation and in the same signed injection, the browser hands over auto_stop: the setting plus a FORGET of this VM, signed by the books' key for the INSTANCE's payer, with the fixed reason belege: hosted bridge stopped itself. It goes only while it fits the agent's 16-secret limit.
  • At each change or postponement, the browser checks the INSTANCE against the published image and pins again, attests again through the relay's /attest (attestGuest + injectSecrets, no passphrase), and hands over auto_stop alone with a new FORGET.
  • Warning. On every page while the app is open, ten minutes before a stop (HostedAutoStopWarning.svelte, polling the VM's status page once a minute only while a setting is kept), with "1 Stunde später".
  • Next opening. reconcileHostedVm recognises the VM's own FORGET (reason + this VM). It records the stop at that FORGET's reception_time with stoppedItself, the card says "Hat sich … selbst beendet", and the bridge leaves the device list.
  • Texts. All in de.js / en.js.
  • Consent screen. The hosted-bridge text now says that the VM itself sends the pre-signed FORGET to Aleph's API, and that the setting and FORGET go to the VM. The host is the same (api2.aleph.im), so there is no version bump.
  • E2E (app/e2e/hosted-auto-stop.spec.js), against the fake Aleph, a fake attestation agent and a stand-in status page:
    • setting → start with auto_stop and a correct FORGET
    • warning → "1 Stunde später" re-attests and hands over a later time with a new FORGET
    • the VM's FORGET sent → the next opening shows "selbst beendet" and the bridge is off the devices
    • Run locally once on 4421–4423: passed (1.8 min).

Security

  • The pre-signed FORGET can only forget this one VM. It is handed over only after attestation and kept in a root-only tmpfs.
  • No new host and no new listener.
  • Test hooks: the status-page URL override (belege.e2e.hostedStatusUrl) works only behind VITE_E2E. BELEGE_AUTO_STOP_TEST_API is an env var the unit never sets (as in Paperless).

Not in this PR (needs Nico's word)

  • The image round (bridge-image.yml). Running VMs ignore the setting until then.
  • The paid round trip (bridge-try.yml): an idle VM sends its FORGET on api2, the CRN drops it, and the next opening sees it.
  • No release, no merge.

🤖 Generated with Claude Code

… daily hour (#1059)

Phases 1 and 2 of #1059, off by default until the paid round trip.

Guest (image sources): with --hosted the bridge writes when a device last
called a command and how many run to activity.json in its tmpfs (no
listener). belege-bridge-auto-stop checks once a minute whether the quiet
time or the daily hour (IANA zone, tzdata) is due, never while a command
runs or before "postponed until", and then sends the FORGET of this VM that
the owner's browser pre-signed (secret auto_stop, moved to a root-only
tmpfs, never logged). status.json says capabilities.autoStop and only the
reason and a time.

App: "Selbst beenden" under Gehostete Bridge, kept in the sealed settings;
auto_stop with a FORGET signed for the VM's payer goes with the unlock and,
after a fresh attestation, at each change; a warning ten minutes before with
"1 Stunde später"; the next opening recognises the VM's own FORGET, records
the stop at its reception_time and takes the bridge off the devices.

A bank linked on a hosted bridge lived only in its tmpfs: the new stream-only
enablebanking.sealed lets an owner's device keep the sealed file in the books.

Carries docs/hosted-auto-stop.md over from #1060, updated to what was built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NiKrause
NiKrause force-pushed the feat/hosted-auto-stop branch from 4080105 to 6f03f32 Compare November 28, 2026 15:41
@NiKrause
NiKrause marked this pull request as ready for review November 29, 2026 08:42
@NiKrause
NiKrause merged commit 47d8ae5 into main Nov 29, 2026
17 checks passed
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.

1 participant