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
1 change: 1 addition & 0 deletions .github/ci-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ never a state that persists by default.
| Workflow | Automatic venue | Manual |
| ------------------------- | --------------------- | ------ |
| workflow-lint | none | yes |
| pm-console-android | none | yes |
| proxy-port-fallbacks | none | yes |
| fleet-search-parity-guard | none | yes |
| fleet-rust-tests | nightly schedule | yes |
Expand Down
12 changes: 12 additions & 0 deletions .github/test-suite-registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,18 @@
},
"status": "mapped"
},
{
"id": "pm-stack.console",
"paths": ["pm-stack/console/test/*.test.ts", "pm-stack/console/scripts/test_expose.py"],
"invocation": "cd pm-stack/console && bun test && python3 -I -m unittest discover -s scripts -p 'test_*.py'",
"venue": {
"workflow": ".github/workflows/pm-stack-tests.yml",
"job_step": "Test console",
"state": "active",
"dispatchable": true
},
"status": "mapped"
},
{
"id": "pm-stack.dispatch",
"paths": ["pm-stack/dispatch/test/*.test.ts"],
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/pm-console-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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.
on:
workflow_dispatch:
inputs:
publish:
description: "Attach the signed APK to the release pm-console-android"
type: boolean
default: true

permissions:
contents: read

jobs:
build:
name: "build: signed APK"
runs-on: ubuntu-latest
timeout-minutes: 25
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- name: Build, sign and check the signing certificate
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
- uses: actions/upload-artifact@v7
with:
name: pm-console-apk
path: pm-stack/console/android/app/build/outputs/apk/release/pm-console.apk
if-no-files-found: error
- name: Attach to the release
if: inputs.publish
env:
GH_TOKEN: ${{ github.token }}
run: |
apk=pm-stack/console/android/app/build/outputs/apk/release/pm-console.apk
if ! gh release view pm-console-android >/dev/null 2>&1; then
gh release create pm-console-android --latest=false \
--title "PM console for Android" \
--notes "The PM stack's console as an Android app. It opens https://pm.security.cab/console/ and signs in the way the site does. Install pm-console.apk; later builds install over it."
fi
gh release upload pm-console-android "$apk" --clobber
10 changes: 10 additions & 0 deletions .github/workflows/pm-stack-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ jobs:
fi
bun test

- name: Test console
working-directory: pm-stack/console
run: |
if [ ! -d test ] || ! ls test/*.test.ts >/dev/null 2>&1; then
echo "::error::Missing console test suite — pm-stack/console/test has no *.test.ts files."
exit 1
fi
bun test
python3 -I -m unittest discover -s scripts -p 'test_*.py'

- name: Test seed and deploy/install scripts
run: |
bash pm-stack/scripts/seed-smoke.test.sh
Expand Down
23 changes: 12 additions & 11 deletions pm-stack/PORTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +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 |
| 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`; 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 |

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

Expand Down
1 change: 1 addition & 0 deletions pm-stack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ health gate):
| 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/` |

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
97 changes: 97 additions & 0 deletions pm-stack/console/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# 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/`.

| Section | What you can do | What runs |
| ------------- | ----------------------------------------------------------------------------------- | --------------------------------------- |
| Overview | Queue counts, ready pull requests, agents, failed units | the calls below, together |
| Queue | List queued, claimed, blocked and parked tasks; unblock or cancel one with a reason | the queue store (read), `fleet queue` |
| Priorities | Ranked issues, most urgent first; change a rank; comment; file new work | `fleet gh` |
| Agents | Send an idea, message or command to one agent, a group or everyone; recent messages | `fleet bridge` |
| Services | State of the stack's units; start, stop, restart; read logs | `systemctl --user`, `journalctl --user` |
| Pull requests | Open pull requests; check one; merge it | `fleet gh` |

Every operation is an argument vector, never a shell line, and text you
type travels on stdin or as one argument.

Each write leaves two lines in `~/.local/state/pm-console/audit.jsonl`
(who, what, when; message text is not copied): one before the action
runs, one with how it went. If the first cannot be written the action is
not taken. If the second cannot be written the action's own result still
comes back, so a merge that happened is never reported as failed.

Work filed from Priorities is created as an issue and enqueued as a
triage task in the same pass, so a worker picks it up without waiting for
the coverage reconciliation. The rank sets the task's place in the queue.
If the enqueue fails, the issue still exists and the page says it is not
queued.

## Sign-in

The console runs no sign-in of its own. A caller arrives with a signed
token from an issuer the deployment trusts; the console checks the
signature, issuer, audience and times, then asks whether the identity is
the owner (`PM_CONSOLE_OWNER_EMAILS`).

- **Today:** Cloudflare Access at the public edge runs the interactive
sign-in and issues the token. The sign-in methods are set on the Access
application, not here.
- **Google:** an Access sign-in method. It turns on when
`scripts/expose.py` finds the secrets `google.access-sso.client-id` and
`google.access-sso.client-secret` (an OAuth client whose redirect URI is
`https://<team>.cloudflareaccess.com/cdn-cgi/access/callback`).
- **The central OIDC provider (#9077):** either an Access sign-in method
(generic OIDC), or trusted directly: add
`{name, issuer, jwksUri, audience}` to the file named by
`PM_CONSOLE_ISSUERS_FILE` and its ID tokens are accepted as
`Authorization: Bearer`. RS256 and ES256.
- **Certificates from the central CA (#9155):** upload the CA to Access
mTLS; the token then carries the certificate's common name, and names
listed in `PM_CONSOLE_CERT_NAMES` are the owner.

A request is local, and treated as the owner, only when the connection
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).

## 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
cd pm-stack/console && bun test
```

`expose.py` is safe to run again: it changes only what is not already so
and refuses to touch DNS records or Access policies it did not write. It
puts the sign-in gate in place first and the route last, and stops before
the route if the console does not come up with its sign-in settings.

## Configuration

| Variable | Default | Meaning |
| --------------------------------------------------------- | ------------------------------------------------- | -------------------------------------------------- |
| `PM_CONSOLE_PORT`, `PM_CONSOLE_BIND` | `4872`, `127.0.0.1` | Listener; the address must be loopback |
| `PM_CONSOLE_OWNER_EMAILS` | none (nobody) | Comma-separated owner addresses |
| `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_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.

## Android

`pm-stack/console/android/` is a Trusted Web Activity: the same site in
Chrome without browser chrome, so sign-in is Chrome's own and nothing is
reimplemented. The signed APK is built by the `pm-console-android`
workflow and attached to the release of the same name. See its README.
5 changes: 5 additions & 0 deletions pm-stack/console/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build/
.gradle/
*.p12
*.apk
/gradle-dist/
38 changes: 38 additions & 0 deletions pm-stack/console/android/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# PM console for Android

A Trusted Web Activity: the app opens `https://pm.security.cab/console/`
in Chrome without browser chrome. It is the site, so it does everything
the site does, signs in the way the site does (Chrome's own session), and
never needs a release when the console changes. There is no code in the
module; the launcher activity comes from `androidbrowserhelper`.

## How the app and the site trust each other

- The app names the site in its manifest (`asset_statements`).
- The site names the app in `/.well-known/assetlinks.json`: package
`today.developing.pmconsole`, signed by the certificate in
[`signing-fingerprint.txt`](signing-fingerprint.txt). `pm-console`
serves that file from `PM_CONSOLE_ANDROID_SHA256`.

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
bash pm-stack/console/android/build.sh # locally: needs JAVA_HOME (17 or 21) and ANDROID_HOME
```

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.

## Install

Download `pm-console.apk` from the
[release](https://github.com/developing-today/code/releases/tag/pm-console-android)
on the phone and open it. Later builds install over it.
Loading