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
Original file line number Diff line number Diff line change
Expand Up @@ -1285,3 +1285,71 @@ the last machine to connect was running (#14163).

**Not seen.** The laptop's dashboard itself: it gets this when its
checkout follows main again (#13833).

## 2026-11-24T07:45Z Plan: the platform's settings are its own (#14163)

**What is so.** The Worker holds no settings of its own. Every report
from the laptop carries the laptop console's whole configuration, and
the Worker stores what it is sent and acts by it: who may sign in, which
repository and queue, where the queue's store answers (which is where
the queue's token is sent), which repositories are looked in for what
needs the owner. So the platform runs by the environment and the
defaults of whatever the laptop's console was started from.

That is `~/git/code` on the laptop, which agents use as a working tree
(the lanes that looked report in #13833 that it had edits nobody had
committed on 2026-11-23, and was on a lane's branch the day after; the
console has run `f86b52989c31`, hours of commits behind main, since).
Two things follow. A correction to a setting that is
merged and deployed to Cloudflare changes nothing in service until the
laptop runs it: today's correction of the repositories' names
(#14165) is the case in hand. And a default changed on a branch nobody
merged is told to the Worker as readily as main's: for where the
queue's token is sent, that is a wider door than main.

**Whose each setting is.**

- _The repository's_: the repository and the queue, where the queue's
store answers and what its token is called, the Android app's
package, the label that marks an instruction, and the repositories
looked in for what needs the owner. Nothing on the laptop sets any of
them; they are defaults in the console's code.
- _The deployment's_: who may sign in (the owners, the sign-in issuers,
the certificate names) and the fingerprints of the Android signing
certificate. The script that sets the hostname up writes them into
the laptop console's environment, and the laptop tells them.
- _A machine's own_: its name, whether it has a signed build to hand
out, what it can do. These are facts it reports, not settings.

**The plan, in order.**

1. _One definition, and see first._ The repository's settings are
written once (`pm-stack/console/src/settings.ts`), and both the
console and the Worker carry them. The Worker says in its health
answer in which of them the machine told it otherwise, by name and
never by value (`machineSettingsDiffer`). It still acts by what it
was told. What that shows in service decides step 3: the console
that tells them is behind main, and whether any of them was set by
hand on the laptop cannot be known from here any other way.
2. _The last action about these repositories that only a machine does._
"Done" on something that needed the owner's hands is a comment and a
label taken off, and is sent to the machine, which takes it only for
a repository on its own list. Once the Worker goes by its own list a
machine on another would refuse an item the app shows. The Worker
does it itself, as it does a reply.
3. _The switch._ The Worker acts by the repository's settings, as its
own deploy carries them. What a machine tells for them is compared
and shown (Machines, with both values, to the owner signed in) and
is not taken. Where the queue's token is sent is then decided by
main alone.
4. _With #13495._ The deployment's settings are applied from Actions,
and a machine's report stops changing who may sign in. Not before:
the script on the laptop is the only thing that sets sign-in up
today, and a Worker that stopped listening to it would keep the old
sign-in the next time it is set up again, and lock the owner out.
5. _Settings changed from the app._ Which repositories are looked in is
the first: kept at the edge, told to machines. After 3.

**Kept true on the way.** Sign-in never opens wider: steps 1 to 3 do
not touch who may sign in or how it is checked. No value of any
setting is said to anyone not signed in.
1 change: 1 addition & 0 deletions planning/roadmaps/pm-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The roadmap of record is this file and its siblings in `planning/roadmaps/`. The
| Questions, what needs you and sessions with no machine | in-progress | The last sections that are only as fresh as a machine's last report. What is labelled as needing you is read by Cloudflare from each repository's own list (done); questions and sessions are still a machine's. | #13491 |
| What waits for a machine, done from Cloudflare once it can be | shipped | With GitHub answering again and no machine there, what the owner did is done by the edge itself and not kept waiting; never twice. | #13831 |
| The laptop's console follows main | proposed | The console on the laptop runs the build main is at, and it is seen from outside when it does not. | #13833 |
| The platform's settings are its own, not the last machine's | in-progress | Which repository, queue and repositories the platform works by come from main, carried by each deploy; a machine that says otherwise is shown, not obeyed. First: the Worker says in which settings the laptop differs. Who may sign in follows with the hostname's settings (#13495). | #14163 |

## Next

Expand Down
11 changes: 11 additions & 0 deletions pm-stack/console/edge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,17 @@ it (the laptop's, the sign-in issuer's).
says when it answers again and which of the two it was. Health has
the times as `github.quiet.core` and `github.quiet.search`. "Try
again now" lifts both.
- **The repository's settings are written once, and both sides carry
them.** Which repository and queue, where the queue's store answers,
the label that marks an instruction, and the repositories looked in
for what needs the owner are in `src/settings.ts`: the console on a
machine uses them where its environment says nothing else, and the
Worker's bundle has them. The Worker still acts by what the machine
tells it (#14163 is to end that), and says in its health answer in
which of them the machine told it otherwise (`machineSettingsDiffer`):
names only, never a value, and `null` while no machine has said
anything. A machine on other code than main, or with an environment
of its own, shows there.
- **What is labelled as needing the owner is read from each
repository's own list.** Two labels say that something waits on him,
`user/review` and `user/escalated`. The edge asks each repository
Expand Down
7 changes: 7 additions & 0 deletions pm-stack/console/edge/src/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import type { Later } from "../../src/plan.ts";
import { platformRead } from "../../src/reads.ts";
import { Notifier, WATCHED as NOTIFIED } from "../../src/notify.ts";
import { contact, Push } from "../../src/push.ts";
import { settingsThatDiffer } from "../../src/settings.ts";
import type { Store } from "../../src/store.ts";
import { timed, unread } from "../../src/timed.ts";

Expand Down Expand Up @@ -2186,6 +2187,12 @@ export class Edge {
hostSeen: this.hostSeen || null,
// The commit the host's console is running, as it last said.
hostVersion: this.hostVersion,
// In which of the platform's own settings (the repository's:
// src/settings.ts) the machine said it runs with others, by
// name and never by value; null while no machine has said any.
// A machine on other code than this, or with an environment of
// its own, shows here.
machineSettingsDiffer: cfg === null ? null : settingsThatDiffer(cfg),
// The copy of the Android build kept here: when it was built,
// and whether it is the host's newest. Null if there is none.
androidBuild: await this.apkState(),
Expand Down
10 changes: 10 additions & 0 deletions pm-stack/console/scripts/edge-smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ try {
after.configured === true && typeof after.hostSeen === "number",
JSON.stringify(after),
);
// The Worker carries the repository's settings in its own bundle, and
// the host here runs the same code with nothing set otherwise: the two
// must agree, in the bundle as it is deployed.
check(
"the Worker says the host runs with the platform's own settings: none differs",
before.machineSettingsDiffer === null &&
Array.isArray(after.machineSettingsDiffer) &&
after.machineSettingsDiffer.length === 0,
JSON.stringify({ before: before.machineSettingsDiffer, after: after.machineSettingsDiffer }),
);
const second = await link.once();
check(
"a second report is accepted and nothing is asked for again",
Expand Down
30 changes: 11 additions & 19 deletions pm-stack/console/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// at boot naming the variable.
import { readFileSync } from "node:fs";
import { machineName } from "./edge-proto.ts";
import { platformSettings } from "./settings.ts";

/** A token issuer whose signed tokens identify a caller. */
export interface Issuer {
Expand Down Expand Up @@ -231,16 +232,19 @@ export function readConfig(
edgeUrl = parsed.origin;
}

// What the repository decides (src/settings.ts) is what is used
// where the environment says nothing else.
const platform = platformSettings();
return {
port: port(env, "PM_CONSOLE_PORT", 4872),
bind,
owners: list(env, "PM_CONSOLE_OWNER_EMAILS").map((e) => e.toLowerCase()),
certNames: list(env, "PM_CONSOLE_CERT_NAMES"),
issuers,
repo: env.PM_CONSOLE_REPO ?? "developing-today/code",
queue: env.PM_CONSOLE_QUEUE ?? "repo-health-code-pilot",
queueDbUrl: env.PM_CONSOLE_QUEUE_DB_URL ?? "https://fleet-queue-dezren39.aws-us-east-1.turso.io",
queueTokenName: env.PM_CONSOLE_QUEUE_TOKEN_NAME ?? "turso.fleet-queue-rw-token",
repo: env.PM_CONSOLE_REPO ?? platform.repo,
queue: env.PM_CONSOLE_QUEUE ?? platform.queue,
queueDbUrl: env.PM_CONSOLE_QUEUE_DB_URL ?? platform.queueDbUrl,
queueTokenName: env.PM_CONSOLE_QUEUE_TOKEN_NAME ?? platform.queueTokenName,
fleetBin: env.PM_CONSOLE_FLEET_BIN ?? "fleet",
unitPatterns: list(env, "PM_CONSOLE_UNITS", [
"pm-*",
Expand All @@ -253,7 +257,7 @@ export function readConfig(
protectedUnits: list(env, "PM_CONSOLE_PROTECTED_UNITS", ["pm-tunnel.service", "pm-console.service"]),
auditFile: env.PM_CONSOLE_AUDIT_FILE ?? `${home}/.local/state/pm-console/audit.jsonl`,
dashboardUrl,
androidPackage: env.PM_CONSOLE_ANDROID_PACKAGE ?? "today.developing.pmconsole",
androidPackage: env.PM_CONSOLE_ANDROID_PACKAGE ?? platform.androidPackage,
androidFingerprints: fingerprints,
androidApk: env.PM_CONSOLE_ANDROID_APK ?? `${home}/.local/state/pm-console/android/pm-console.apk`,
devicesFile: env.PM_CONSOLE_DEVICES_FILE ?? `${home}/.local/state/pm-console/devices.json`,
Expand All @@ -262,19 +266,7 @@ export function readConfig(
edgeDoneFile: env.PM_CONSOLE_EDGE_DONE_FILE ?? `${home}/.local/state/pm-console/edge-done.json`,
machineName: machineName(env.PM_CONSOLE_MACHINE),
decisionsFile: env.PM_CONSOLE_DECISIONS_FILE ?? `${home}/.local/state/pm-aggregator/decisions.json`,
promptLabel: env.PM_CONSOLE_PROMPT_LABEL ?? "owner/prompt",
// The repositories the dashboard's census covers (REPOS in
// pm-stack/aggregator/src/model.ts; a test holds the two lists to
// each other). By their present names: the two forks moved to
// another organisation and the third was renamed. GitHub still
// answers the old names with the present repositories, but an item
// named by an old name is not the item the dashboard names, and a
// reply is taken only for an item in a repository on this list.
needsRepos: list(env, "PM_CONSOLE_NEEDS_REPOS", [
"developing-today/code",
"developing-today-forks/opencode",
"developing-today-forks/openchamber",
"dezren39/darwin-nix",
]),
promptLabel: env.PM_CONSOLE_PROMPT_LABEL ?? platform.promptLabel,
needsRepos: list(env, "PM_CONSOLE_NEEDS_REPOS", platform.needsRepos),
};
}
85 changes: 85 additions & 0 deletions pm-stack/console/src/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// The platform's own settings: the ones the repository decides.
//
// They are written here once, and both sides carry them: the console on
// a machine (as what it uses when its environment says nothing else),
// and the Worker (bundled into every deploy from main). A machine and
// Cloudflare that both follow main therefore agree, and one that does
// not is found out by comparing what it says with this.
//
// Not here: who may sign in (the owners and the sign-in issuers are set
// when the hostname is, and are the deployment's), and nothing about a
// single machine (its name, its files, its units).

export interface PlatformSettings {
/** The repository the work is in. */
repo: string;
/** The queue the board shows. */
queue: string;
/** Where the queue's store answers. */
queueDbUrl: string;
/** What the queue store's token is called where secrets are kept: a
* name, never the token. */
queueTokenName: string;
/** The Android app's package. */
androidPackage: string;
/** Label on an issue that is an instruction from the owner. */
promptLabel: string;
/** Repositories looked in for what is labelled as needing the owner,
* and whose items may be answered from "Needs me". The ones the
* dashboard's census covers (REPOS in pm-stack/aggregator/src/model.ts;
* a test holds the two lists to each other). By their present names:
* two forks moved to another organisation and a third was renamed.
* GitHub still answers the old names with the present repositories,
* but an item named by an old name is not the item the dashboard
* names, and a reply is taken only for an item in a repository on
* this list. */
needsRepos: string[];
}

/** The names, in the order they are said in. */
export const PLATFORM_SETTING_NAMES = [
"repo",
"queue",
"queueDbUrl",
"queueTokenName",
"androidPackage",
"promptLabel",
"needsRepos",
] as const satisfies readonly (keyof PlatformSettings)[];

/** The settings as the repository has them. A new object each time:
* whoever is handed one may change it without changing anyone else's. */
export function platformSettings(): PlatformSettings {
return {
repo: "developing-today/code",
queue: "repo-health-code-pilot",
queueDbUrl: "https://fleet-queue-dezren39.aws-us-east-1.turso.io",
queueTokenName: "turso.fleet-queue-rw-token",
androidPackage: "today.developing.pmconsole",
promptLabel: "owner/prompt",
needsRepos: [
"developing-today/code",
"developing-today-forks/opencode",
"developing-today-forks/openchamber",
"dezren39/darwin-nix",
],
};
}

function same(a: unknown, b: unknown): boolean {
if (Array.isArray(a) || Array.isArray(b)) {
return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, i) => item === b[i]);
}
return a === b;
}

/** The names of the settings in which `told` is not what the platform
* has, in the order they are said in. A list in another order is
* another list: what is shown follows its order. A setting `told` does
* not carry at all differs like any other. */
export function settingsThatDiffer(
told: Partial<Record<keyof PlatformSettings, unknown>>,
platform: PlatformSettings = platformSettings(),
): (keyof PlatformSettings)[] {
return PLATFORM_SETTING_NAMES.filter((name) => !same(told[name], platform[name]));
}
39 changes: 39 additions & 0 deletions pm-stack/console/test/edge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { forgetPoke, type Io, route } from "../edge/src/entry.ts";
import type { Action } from "../src/actions.ts";
import { clearJwksCache, identify } from "../src/auth.ts";
import { readConfig } from "../src/config.ts";
import { platformSettings } from "../src/settings.ts";
import { Devices, Limiter } from "../src/devices.ts";
import { Docs } from "../src/docs.ts";
import { NEEDS_LABELS } from "../src/needs.ts";
Expand Down Expand Up @@ -1150,6 +1151,7 @@ describe("before the host's first report", () => {
github: { answers: 0, unchanged: 0, since: w.now.t, kept: 0, quiet: { core: null, search: null } },
hostSeen: null,
hostVersion: null,
machineSettingsDiffer: null,
androidBuild: null,
androidRelease: null,
androidReleaseTrouble: null,
Expand Down Expand Up @@ -1211,6 +1213,43 @@ describe("before the host's first report", () => {
expect((await health()).hostVersion).toBeNull();
});

// The platform's own settings are the repository's (src/settings.ts),
// and the Worker carries them. A machine tells the ones it runs with
// in every report; one on other code, or with another environment,
// tells others. Which those are is said to anyone who asks, by name
// only: no value of any setting is public.
test("the edge says in which of the platform's settings the machine runs with others, by name only", async () => {
const w = await setup();
const differ = async () =>
((await (await w.browse("/console/health", { token: null })).json()) as Record<string, unknown>)
.machineSettingsDiffer;
// No machine has said anything yet: nothing to compare.
expect(await differ()).toBeNull();
await w.hostReads();
await w.link.now.once();
// The machine runs main's console with nothing set otherwise.
expect(await differ()).toEqual([]);
// A machine on older code: its list of repositories is the one main had then.
const mains = [...w.edgeConfig.needsRepos];
w.edgeConfig.needsRepos = ["developing-today/code", "developing-today/opencode"];
w.edgeConfig.queue = "a-queue-of-its-own";
w.now.t += 5_000;
await w.link.now.once();
expect(await differ()).toEqual(["queue", "needsRepos"]);
const page = await (await w.browse("/console/health", { token: null })).text();
expect(page).not.toContain("a-queue-of-its-own");
expect(page).not.toContain("developing-today/opencode");
// It is kept with the settings, across the edge's own restarts.
w.edge.now = w.makeEdge();
expect(await differ()).toEqual(["queue", "needsRepos"]);
// The machine follows main again.
w.edgeConfig.needsRepos = mains;
w.edgeConfig.queue = platformSettings().queue;
w.now.t += 5_000;
await w.link.now.once();
expect(await differ()).toEqual([]);
});

test("the first report teaches the edge the host's key and who the owner is", async () => {
const w = await setup();
await w.hostReads();
Expand Down
Loading