diff --git a/doc/2026-11-23T06-50-00Z_architecture_pm_platform_cloudflare_core/2026-11-23T06-50-00Z_architecture_pm_platform_cloudflare_core.md b/doc/2026-11-23T06-50-00Z_architecture_pm_platform_cloudflare_core/2026-11-23T06-50-00Z_architecture_pm_platform_cloudflare_core.md index 303e56852e..9733143e3d 100644 --- a/doc/2026-11-23T06-50-00Z_architecture_pm_platform_cloudflare_core/2026-11-23T06-50-00Z_architecture_pm_platform_cloudflare_core.md +++ b/doc/2026-11-23T06-50-00Z_architecture_pm_platform_cloudflare_core/2026-11-23T06-50-00Z_architecture_pm_platform_cloudflare_core.md @@ -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. diff --git a/planning/roadmaps/pm-stack.md b/planning/roadmaps/pm-stack.md index 13ef95fb18..e3b376356d 100644 --- a/planning/roadmaps/pm-stack.md +++ b/planning/roadmaps/pm-stack.md @@ -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 diff --git a/pm-stack/console/edge/README.md b/pm-stack/console/edge/README.md index a2a19df43a..914b8199cb 100644 --- a/pm-stack/console/edge/README.md +++ b/pm-stack/console/edge/README.md @@ -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 diff --git a/pm-stack/console/edge/src/edge.ts b/pm-stack/console/edge/src/edge.ts index 284e2fb57d..147875a813 100644 --- a/pm-stack/console/edge/src/edge.ts +++ b/pm-stack/console/edge/src/edge.ts @@ -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"; @@ -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(), diff --git a/pm-stack/console/scripts/edge-smoke.ts b/pm-stack/console/scripts/edge-smoke.ts index a6d91835d0..49f98c02d9 100644 --- a/pm-stack/console/scripts/edge-smoke.ts +++ b/pm-stack/console/scripts/edge-smoke.ts @@ -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", diff --git a/pm-stack/console/src/config.ts b/pm-stack/console/src/config.ts index 0651846f11..1e72402963 100644 --- a/pm-stack/console/src/config.ts +++ b/pm-stack/console/src/config.ts @@ -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 { @@ -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-*", @@ -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`, @@ -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), }; } diff --git a/pm-stack/console/src/settings.ts b/pm-stack/console/src/settings.ts new file mode 100644 index 0000000000..b27f25a2e5 --- /dev/null +++ b/pm-stack/console/src/settings.ts @@ -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>, + platform: PlatformSettings = platformSettings(), +): (keyof PlatformSettings)[] { + return PLATFORM_SETTING_NAMES.filter((name) => !same(told[name], platform[name])); +} diff --git a/pm-stack/console/test/edge.test.ts b/pm-stack/console/test/edge.test.ts index 67893918f1..1890c0504f 100644 --- a/pm-stack/console/test/edge.test.ts +++ b/pm-stack/console/test/edge.test.ts @@ -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"; @@ -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, @@ -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) + .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(); diff --git a/pm-stack/console/test/settings.test.ts b/pm-stack/console/test/settings.test.ts new file mode 100644 index 0000000000..731fa3fe06 --- /dev/null +++ b/pm-stack/console/test/settings.test.ts @@ -0,0 +1,116 @@ +// The platform's own settings: one definition, carried by the console +// on a machine and by the Worker, and how a machine that says other +// settings is told apart. +import { describe, expect, test } from "bun:test"; +import { readConfig } from "../src/config.ts"; +import { + PLATFORM_SETTING_NAMES, + type PlatformSettings, + platformSettings, + settingsThatDiffer, +} from "../src/settings.ts"; + +describe("the platform's settings", () => { + // The oracle is the one definition: a console whose environment says + // nothing runs with exactly it, so a machine and Cloudflare that both + // follow main agree. A default written out a second time in the + // console's configuration, and changed in one place only, fails here. + test("a console whose environment says nothing runs with them", () => { + const cfg = readConfig({ HOME: "/h" }); + const platform = platformSettings(); + expect(Object.fromEntries(PLATFORM_SETTING_NAMES.map((name) => [name, cfg[name]]))).toEqual({ ...platform }); + expect(settingsThatDiffer(cfg)).toEqual([]); + }); + + test("every setting has a name it is said by, and no name is of anything else", () => { + expect([...PLATFORM_SETTING_NAMES].map(String).sort()).toEqual(Object.keys(platformSettings()).sort()); + }); + + test("whoever is handed them may change theirs without changing anyone else's", () => { + const mine = platformSettings(); + mine.needsRepos.push("someone/else"); + mine.repo = "someone/else"; + const fresh = platformSettings(); + expect(fresh.needsRepos).not.toContain("someone/else"); + expect(fresh.repo).not.toBe("someone/else"); + }); + + // Where the queue's token is sent is one of them: it must be a place + // reached over TLS, or the Worker would refuse the configuration. + test("where the queue's store answers is an https address", () => { + expect(new URL(platformSettings().queueDbUrl).protocol).toBe("https:"); + }); +}); + +describe("telling a machine on other settings apart", () => { + const other: PlatformSettings = { + repo: "o/other", + queue: "another-queue", + queueDbUrl: "https://elsewhere.example", + queueTokenName: "another.name", + androidPackage: "another.package", + promptLabel: "another/label", + needsRepos: ["o/other"], + }; + + test("the same settings differ in nothing", () => { + expect(settingsThatDiffer(platformSettings())).toEqual([]); + // What else a machine says (who may sign in, its own files) is not compared. + expect(settingsThatDiffer({ ...readConfig({ HOME: "/h", PM_CONSOLE_OWNER_EMAILS: "a@b.example" }) })).toEqual([]); + }); + + test("each setting that is another is named, and only it", () => { + for (const name of PLATFORM_SETTING_NAMES) { + expect(settingsThatDiffer({ ...platformSettings(), [name]: other[name] })).toEqual([name]); + } + }); + + test("several are named in the order they are said in, whatever order they were told in", () => { + // Told last-first. + const told = Object.fromEntries( + [...PLATFORM_SETTING_NAMES] + .reverse() + .map((name) => [ + name, + name === "repo" || name === "queue" || name === "needsRepos" ? other[name] : platformSettings()[name], + ]), + ); + expect(Object.keys(told)[0]).toBe("needsRepos"); + expect(settingsThatDiffer(told)).toEqual(["repo", "queue", "needsRepos"]); + expect(settingsThatDiffer(other)).toEqual([...PLATFORM_SETTING_NAMES]); + }); + + test("a list of the same repositories in another order is another list", () => { + const platform = platformSettings(); + expect(settingsThatDiffer({ ...platform, needsRepos: [...platform.needsRepos].reverse() })).toEqual(["needsRepos"]); + // One fewer, one more, and a list that only begins the same. + expect(settingsThatDiffer({ ...platform, needsRepos: platform.needsRepos.slice(0, -1) })).toEqual(["needsRepos"]); + expect(settingsThatDiffer({ ...platform, needsRepos: [...platform.needsRepos, "o/more"] })).toEqual(["needsRepos"]); + expect(settingsThatDiffer({ ...platform, needsRepos: [] })).toEqual(["needsRepos"]); + // A copy of the same list is the same list. + expect(settingsThatDiffer({ ...platform, needsRepos: [...platform.needsRepos] })).toEqual([]); + }); + + test("a setting a machine does not say at all differs, and so does one of another kind", () => { + const { promptLabel: _unsaid, ...rest } = platformSettings(); + expect(settingsThatDiffer(rest)).toEqual(["promptLabel"]); + expect(settingsThatDiffer({})).toEqual([...PLATFORM_SETTING_NAMES]); + // A console from before it said where the queue is says "" and no repositories. + expect( + settingsThatDiffer({ + ...platformSettings(), + queueDbUrl: "", + queueTokenName: "", + promptLabel: "", + needsRepos: [], + }), + ).toEqual(["queueDbUrl", "queueTokenName", "promptLabel", "needsRepos"]); + expect(settingsThatDiffer({ ...platformSettings(), needsRepos: "developing-today/code" })).toEqual(["needsRepos"]); + expect(settingsThatDiffer({ ...platformSettings(), repo: ["developing-today/code"] })).toEqual(["repo"]); + }); + + test("it is told apart from the settings given, when others than the repository's are", () => { + expect(settingsThatDiffer(other, other)).toEqual([]); + expect(settingsThatDiffer(platformSettings(), other)).toEqual([...PLATFORM_SETTING_NAMES]); + }); +});