Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions .github/workflows/pm-console-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ name: pm-console android
# Builds the PM console's Android app (pm-stack/console/android): a
# Trusted Web Activity over https://pm.security.cab. Manual only: it is
# run when the app changes, which is rarely, since the app is the site.
#
# With the signing secrets set, the APK is signed here and attached to
# the release. Without them the build is unsigned and kept as an
# artifact, to be signed by pm-stack/console/android/sign.sh on the
# machine that holds the key.
on:
workflow_dispatch:
inputs:
publish:
description: "Attach the signed APK to the release pm-console-android"
description: "Attach the APK to the release pm-console-android (signed builds only)"
type: boolean
default: true

Expand All @@ -16,30 +21,33 @@ permissions:

jobs:
build:
name: "build: signed APK"
name: "build: APK"
runs-on: ubuntu-latest
timeout-minutes: 25
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- name: Build, sign and check the signing certificate
- name: Build, and sign when the signing secrets are set
id: build
env:
KEYSTORE_B64: ${{ secrets.PM_CONSOLE_ANDROID_KEYSTORE_B64 }}
PM_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.PM_CONSOLE_ANDROID_KEYSTORE_PASSWORD }}
run: |
if [ -z "$KEYSTORE_B64" ] || [ -z "$PM_ANDROID_KEYSTORE_PASSWORD" ]; then
echo "::error::The signing secrets PM_CONSOLE_ANDROID_KEYSTORE_B64 and PM_CONSOLE_ANDROID_KEYSTORE_PASSWORD are not set."
exit 1
fi
bash pm-stack/console/android/build.sh
if [ -f pm-stack/console/android/app/build/outputs/apk/release/pm-console.apk ]; then
echo "signed=true" >>"$GITHUB_OUTPUT"
else
echo "signed=false" >>"$GITHUB_OUTPUT"
echo "::notice::Built unsigned: the signing secrets are not set. Sign the artifact with pm-stack/console/android/sign.sh on the machine that holds the key."
fi
- uses: actions/upload-artifact@v7
with:
name: pm-console-apk
path: pm-stack/console/android/app/build/outputs/apk/release/pm-console.apk
name: ${{ steps.build.outputs.signed == 'true' && 'pm-console-apk' || 'pm-console-apk-unsigned' }}
path: pm-stack/console/android/app/build/outputs/apk/release/*.apk
if-no-files-found: error
- name: Attach to the release
if: inputs.publish
if: inputs.publish && steps.build.outputs.signed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
Expand Down
24 changes: 12 additions & 12 deletions pm-stack/PORTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ fleet-config default (see the CONNECT-UDP rows).

## pm-stack

| Port | Service | Bind | Source of truth | Status |
| ---- | ---------------------------------------- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
| 4870 | pm-aggregator (dashboard HTTP) | loopback + tailnet | `pm-stack/aggregator/src/config.ts` (`PM_AGG_PORT` default 4870); `nixos/services/pm-stack/default.nix` | live |
| 4871 | pm-aggregator freshness IPC (`/publish`) | loopback | `pm-stack/aggregator/src/config.ts:148` (`PM_AGG_FRESHNESS_PORT` default 4871); `nixos/services/pm-stack/default.nix:163` | live |
| 4872 | pm-console (operations) | loopback | `pm-stack/console/src/config.ts` (`PM_CONSOLE_PORT` default 4872); `pm-stack/systemd/pm-console.service`; public as `pm.security.cab/console` through the tunnel |
| 4879 | pm-dispatch (intake) | loopback + tailnet | `pm-stack/dispatch/src/config.ts:73` (`DISPATCH_PORT` default 4879); `pkgs/fleet/crates/fleet-config/src/lib.rs` `PORT_DISPATCH` | live |
| 5173 | Kaneo (Docker, `pm-stack-kaneo-1`) | loopback | `pm-stack/compose.yml:35` | live |
| 5432 | Kaneo Postgres (Docker) | container-internal only (no host bind) | `pm-stack/compose.yml`; `pm-stack/aggregator/src/topology.ts` | live (internal) |
| 6056 | ready-for-agent (UI + GraphQL) | loopback + tailnet via socket proxy | `pm-stack/aggregator/src/config.ts:209` (`PM_AGG_RFA_URL` default); `nixos/services/pm-apps/default.nix:148-166` | live |
| 7777 | Pad (Docker, `pm-pad`, v0.18.1) | loopback + tailnet | `pm-stack/pad/compose.yml:26-31` (`PAD_PORT 7777`); `nixos/services/pm-apps/default.nix:103-108` | live |
| 7801 | pm-projector (+ link registry) | loopback | `pm-stack/projector/src/config.ts:1` (`DEFAULT_PORT 7801`); `nixos/services/pm-stack/default.nix:100` | live |
| 8484 | Grist (Docker, `pm-grist`) | loopback + tailnet | `pm-stack/grist/compose.yml:30-31`; `nixos/services/pm-apps/default.nix:92-93` | live |
| Port | Service | Bind | Source of truth | Status |
| ---- | ---------------------------------------- | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
| 4870 | pm-aggregator (dashboard HTTP) | loopback + tailnet | `pm-stack/aggregator/src/config.ts` (`PM_AGG_PORT` default 4870); `nixos/services/pm-stack/default.nix` | live |
| 4871 | pm-aggregator freshness IPC (`/publish`) | loopback | `pm-stack/aggregator/src/config.ts:148` (`PM_AGG_FRESHNESS_PORT` default 4871); `nixos/services/pm-stack/default.nix:163` | live |
| 4872 | pm-console (operations) | loopback | `pm-stack/console/src/config.ts` (`PM_CONSOLE_PORT` default 4872); `pm-stack/systemd/pm-console.service`; the tunnel sends all of `pm.security.cab` here, and it passes the dashboard's paths to 4870 for a signed-in owner |
| 4879 | pm-dispatch (intake) | loopback + tailnet | `pm-stack/dispatch/src/config.ts:73` (`DISPATCH_PORT` default 4879); `pkgs/fleet/crates/fleet-config/src/lib.rs` `PORT_DISPATCH` | live |
| 5173 | Kaneo (Docker, `pm-stack-kaneo-1`) | loopback | `pm-stack/compose.yml:35` | live |
| 5432 | Kaneo Postgres (Docker) | container-internal only (no host bind) | `pm-stack/compose.yml`; `pm-stack/aggregator/src/topology.ts` | live (internal) |
| 6056 | ready-for-agent (UI + GraphQL) | loopback + tailnet via socket proxy | `pm-stack/aggregator/src/config.ts:209` (`PM_AGG_RFA_URL` default); `nixos/services/pm-apps/default.nix:148-166` | live |
| 7777 | Pad (Docker, `pm-pad`, v0.18.1) | loopback + tailnet | `pm-stack/pad/compose.yml:26-31` (`PAD_PORT 7777`); `nixos/services/pm-apps/default.nix:103-108` | live |
| 7801 | pm-projector (+ link registry) | loopback | `pm-stack/projector/src/config.ts:1` (`DEFAULT_PORT 7801`); `nixos/services/pm-stack/default.nix:100` | live |
| 8484 | Grist (Docker, `pm-grist`) | loopback + tailnet | `pm-stack/grist/compose.yml:30-31`; `nixos/services/pm-apps/default.nix:92-93` | live |

## Fleet (brokers, laptop-agent, CONNECT-UDP)

Expand Down
16 changes: 8 additions & 8 deletions pm-stack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ Phase 2 (2026-10-24) added three layers, each in its own subdirectory
with the same deploy shape (SOPS → mode-600 env → compose/unit →
health gate):

| Layer | Piece | Version / pin | Reach | Deployment definition |
| --------- | --------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | --------------------- |
| Dispatch | ready-for-agent | npm `ready-for-agent@1.1.0` (no container image exists upstream) | UI + GraphQL on `6056`, loopback + tailnet (app loopback-only; tailnet via socket proxy, #1181) | `ready-for-agent/` |
| Planning | Pad | `ghcr.io/perpetualsoftware/pad:0.18.1`, pinned by digest | `127.0.0.1:7777` + host tailnet address (`PM_STACK_TAILNET_IP`):7777; no tunnel hostname | `pad/` |
| Tables | Grist | `gristlabs/grist-oss:v1.7.21`, pinned by digest | `127.0.0.1:8484` + host tailnet address (`PM_STACK_TAILNET_IP`):8484; no tunnel hostname | `grist/` |
| Dashboard | Aggregator | this repo (Bun app, user unit `pm-aggregator`) | `127.0.0.1:4870` + tailnet `amd-6.raptor-pumpkinseed.ts.net:4870`; no public route | `aggregator/` |
| Intake | pm-dispatch | this repo (Bun app, user unit `pm-dispatch`) | `127.0.0.1:4879` + tailnet; public via tunnel as `dispatch.security.cab` | `dispatch/` |
| Console | pm-console | this repo (Bun app, user unit `pm-console`) | `127.0.0.1:4872`; public behind sign-in as `pm.security.cab/console` (dashboard at `/`) | `console/` |
| Layer | Piece | Version / pin | Reach | Deployment definition |
| --------- | --------------- | ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
| Dispatch | ready-for-agent | npm `ready-for-agent@1.1.0` (no container image exists upstream) | UI + GraphQL on `6056`, loopback + tailnet (app loopback-only; tailnet via socket proxy, #1181) | `ready-for-agent/` |
| Planning | Pad | `ghcr.io/perpetualsoftware/pad:0.18.1`, pinned by digest | `127.0.0.1:7777` + host tailnet address (`PM_STACK_TAILNET_IP`):7777; no tunnel hostname | `pad/` |
| Tables | Grist | `gristlabs/grist-oss:v1.7.21`, pinned by digest | `127.0.0.1:8484` + host tailnet address (`PM_STACK_TAILNET_IP`):8484; no tunnel hostname | `grist/` |
| Dashboard | Aggregator | this repo (Bun app, user unit `pm-aggregator`) | `127.0.0.1:4870` + tailnet `amd-6.raptor-pumpkinseed.ts.net:4870`; no public route | `aggregator/` |
| Intake | pm-dispatch | this repo (Bun app, user unit `pm-dispatch`) | `127.0.0.1:4879` + tailnet; public via tunnel as `dispatch.security.cab` | `dispatch/` |
| Console | pm-console | this repo (Bun app, user unit `pm-console`) | `127.0.0.1:4872`; public behind sign-in as `pm.security.cab` (console at `/console`, dashboard at `/` through the console's gate) | `console/` |

ready-for-agent runs as a systemd **user unit** (like `pm-tunnel`)
because upstream ships only an npm package; Pad and Grist run as
Expand Down
28 changes: 20 additions & 8 deletions pm-stack/console/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# pm-console

The write side of the PM stack. The dashboard (`pm-aggregator`) shows the
fleet; the console acts on it, from a phone or a browser, at
`https://pm.security.cab/console/`.
The write side of the PM stack, and the gate in front of it. The
dashboard (`pm-aggregator`) shows the fleet; the console acts on it, from
a phone or a browser, at `https://pm.security.cab/console/`.

The whole public hostname is routed here. `/console` is this service.
Every other path is the dashboard's, and the console passes it through
only for a verified owner: the dashboard has no sign-in of its own, so
the check is made at this origin as well as at the edge, and does not
depend on how the edge reads a path. Writes from another site are
refused. Five files a phone fetches before anyone has signed in are
public, matched exactly: `/manifest.webmanifest` and the four icons under
`/icons/`.

| Section | What you can do | What runs |
| ------------- | ----------------------------------------------------------------------------------- | --------------------------------------- |
Expand Down Expand Up @@ -56,15 +65,16 @@ itself comes from this machine and it crossed no proxy (loopback Host, no
forwarding headers). The connection's address is the test, since headers
are the caller's to write; for the same reason the console only listens
on loopback and refuses to start on any other address. Everything else
needs a token. Two paths answer without one: `/console/health` and
`/.well-known/assetlinks.json` (the Android app's link to this origin).
needs a token. Outside the install files above, two paths answer without
one: `/console/health` and `/.well-known/assetlinks.json` (the Android
app's link to this origin).

## Run

```bash
bash pm-stack/console/install.sh # user unit pm-console, port 4872, loopback only
python3 pm-stack/console/scripts/expose.py --check # what public exposure would change
python3 pm-stack/console/scripts/expose.py # tunnel routes, DNS, Access, console env
python3 pm-stack/console/scripts/expose.py # Access, console env, tunnel route, DNS
cd pm-stack/console && bun test
```

Expand All @@ -82,12 +92,14 @@ the route if the console does not come up with its sign-in settings.
| `PM_CONSOLE_ACCESS_TEAM_DOMAIN`, `PM_CONSOLE_ACCESS_AUD` | unset | The Access issuer; set together |
| `PM_CONSOLE_ISSUERS_FILE` | unset | JSON list of further issuers |
| `PM_CONSOLE_CERT_NAMES` | none | Certificate common names that are the owner |
| `PM_CONSOLE_DASHBOARD_URL` | `http://127.0.0.1:4870` | The dashboard behind the gate; loopback, or empty |
| `PM_CONSOLE_UNITS`, `PM_CONSOLE_PROTECTED_UNITS` | the stack's units | Units the console manages; units it will not stop |
| `PM_CONSOLE_ANDROID_PACKAGE`, `PM_CONSOLE_ANDROID_SHA256` | `today.developing.pmconsole`, none | The Android app's identity in the asset-links file |
| `PM_CONSOLE_REPO`, `PM_CONSOLE_QUEUE` | `developing-today/code`, `repo-health-code-pilot` | What it operates on |

A malformed port, a listen address that is not loopback, or a malformed
issuer stops the process at boot and names the variable.
A malformed port, a listen address or dashboard address that is not
loopback, or a malformed issuer stops the process at boot and names the
variable.

## Android

Expand Down
28 changes: 20 additions & 8 deletions pm-stack/console/android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,29 @@ If the two disagree the app still works, with a browser bar at the top.
## Build

```bash
gh workflow run pm-console-android.yml # signed APK, attached to the release pm-console-android
gh workflow run pm-console-android.yml # builds the APK in CI
bash pm-stack/console/android/build.sh # locally: needs JAVA_HOME (17 or 21) and ANDROID_HOME
bash pm-stack/console/android/sign.sh app-release-unsigned.apk # sign a CI build with the key on this machine
```

The workflow signs with the repository secrets
`PM_CONSOLE_ANDROID_KEYSTORE_B64` and
`PM_CONSOLE_ANDROID_KEYSTORE_PASSWORD`, and fails unless the APK's
certificate matches `signing-fingerprint.txt`. The keystore itself is on
the pm-stack host at `~/.local/state/pm-console/android/release.p12`.
Losing it means a new key, a new fingerprint and a reinstall; nothing
else depends on it.
The signing key is on the pm-stack host at
`~/.local/state/pm-console/android/release.p12`, and it stays there. The
workflow builds an unsigned APK and keeps it as the artifact
`pm-console-apk-unsigned`; `sign.sh` on the host signs it, checks the
certificate against `signing-fingerprint.txt`, and the signed
`pm-console.apk` is uploaded to the release:

```bash
gh run download <run-id> -n pm-console-apk-unsigned -D /tmp/pm-apk
nix shell nixpkgs#apksigner -c bash pm-stack/console/android/sign.sh /tmp/pm-apk/app-release-unsigned.apk
gh release upload pm-console-android /tmp/pm-apk/pm-console.apk --clobber
```

If the repository secrets `PM_CONSOLE_ANDROID_KEYSTORE_B64` and
`PM_CONSOLE_ANDROID_KEYSTORE_PASSWORD` are ever set, the workflow signs
and publishes by itself instead, and fails unless the certificate
matches. Losing the key means a new key, a new fingerprint and a
reinstall; nothing else depends on it.

## Install

Expand Down
Loading