Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(cli): keep the canary bucket seed inside the config dir
Vance Ingalls9f2b892a7137
diff --git a/docs/contributing/canary-rollouts.mdx b/docs/contributing/canary-rollouts.mdxindex 4b7344dac0..0124f89a19 100644--- a/docs/contributing/canary-rollouts.mdx+++ b/docs/contributing/canary-rollouts.mdx@@ -167,24 +167,30 @@ experiment, and it survives uninstall), and account identity covers onlyaccepted limit — but its worst consequence is mitigated, and its size is nowdirectly measurable rather than inferred:-- **Cohorts survive the wipe.** Canaries bucket on a dedicated `bucketSeed` —- not the telemetry id — and the seed is inherited across config wipes via a- machine-local state file (write-once: the first install's seed is the- lineage's seed forever). A wipe re-rolls the telemetry id, never the canary- assignment. The seed is never emitted, so it does not link the old id to- the new one.-- **A re-rolled install cannot re-enter a path that already failed on that+- **Cohorts survive a config re-mint.** Canaries bucket on a dedicated+ `bucketSeed` — not the telemetry id — held in `install-state.json` beside+ `config.json` and write-once (the first install's seed wins forever). This+ matters because `config.json` is rewritten on every command and every+ render, and any parse/permission/IO failure makes the CLI mint a fresh+ identity. The seed is never emitted, so it does not link the old id to the+ new one.+- **Deleting `~/.hyperframes` clears the cohort too, deliberately.** The seed+ does not live outside the config directory, so the user's reset is a real+ reset. A seed that outlived it would be a persistent identifier defeating+ the only lever they have — see [the removal path](#removing-your-canary-state).+- **A re-minted install cannot re-enter a path that already failed on thatmachine.** The circuit breaker's tripped state is mirrored to the samestate file.- **`install_predecessor_found`** on every event says whether this install's- mint found a previous install's state marker. Its true-share splits check- 2's drift into the recoverable part (config wiped, machine persisted) and- the part no local mechanism can link (fresh machine, container, new user).+ mint found a previous install's state marker — i.e. `config.json` was lost+ while `install-state.json` survived. Its true-share is the re-mint rate+ directly; drift from a deliberate reset, a fresh machine, a container, or a+ new user is not linkable by any local mechanism and is not counted.With the seed carryover, check 2's residual drift comes from the-unrecoverable buckets only — fresh machines, containers, and genuinely new-users — and canary window lengths get picked from that residual, not the raw-turnover.+unrecoverable buckets only — deliberate resets, fresh machines, containers,+and genuinely new users — and canary window lengths get picked from that+residual, not the raw turnover.## Behaviour worth knowing@@ -197,10 +203,22 @@ not the seed alone — two canaries at 10% select two different 10%s. Ifthey shared a slice, one unlucky cohort would receive every experiment atonce and no two rollouts could be read apart.-**Cohorts are keyed to the machine, not the config.** The bucketing unit is a-dedicated seed inherited across config wipes (see the calibration section) —-distinct from the telemetry id, never emitted, and shared with a CLI-launched-Studio so both surfaces agree.+**Cohorts are keyed to the install directory, not to `config.json`.** The+bucketing unit is a dedicated seed in `install-state.json`, inherited across+`config.json` re-mints (see the calibration section) — distinct from the+telemetry id, never emitted, and shared with a CLI-launched Studio so both+surfaces agree. It does not outlive `~/.hyperframes`.++## Removing your canary state++Both `config.json` and `install-state.json` live in `~/.hyperframes`, so:++```bash+rm -rf ~/.hyperframes # clears telemetry id, canary cohorts, and breaker state+```++`hyperframes telemetry status` prints both paths if you want to inspect or+delete them individually. Nothing canary-related is stored anywhere else.**It fails closed.** No install id, an unregistered name, or a CI machine allresolve to *not enrolled*. A canary exists to bound blast radius, so "wediff --git a/packages/cli/src/telemetry/canary.ts b/packages/cli/src/telemetry/canary.tsindex 49d86918ef..f1d0d95c5a 100644--- a/packages/cli/src/telemetry/canary.ts+++ b/packages/cli/src/telemetry/canary.ts@@ -60,9 +60,10 @@ export function resolveCanary(name: string): CanaryDecision {? evaluateCanary({feature: definition.name,// The bucket seed, NOT the anonymousId: the seed is inherited across- // config wipes via the install-state file, so the machine keeps its- // cohorts when the telemetry id re-rolls. Fallback covers only a- // failed backfill write on a legacy config.+ // config.json re-mints via the install-state file, so cohorts hold+ // when the telemetry id re-rolls. Both files live in ~/.hyperframes,+ // so deleting that directory clears the cohort too — intentional.+ // Fallback covers only a failed backfill write on a legacy config.unitId: config.bucketSeed ?? config.anonymousId,percentage: definition.percentage,override: parseCanaryOverride(process.env[canaryEnvVar(definition.name)]),diff --git a/packages/cli/src/telemetry/config.test.ts b/packages/cli/src/telemetry/config.test.tsindex 646284eda6..2881f9778c 100644--- a/packages/cli/src/telemetry/config.test.ts+++ b/packages/cli/src/telemetry/config.test.ts@@ -36,6 +36,11 @@ vi.mock("node:fs", () => ({}),}));+// Derived here rather than exported from config.ts: the pre-move path is+// frozen history, so pinning the literal is the point — an export would just+// let a rename pass silently, and it has no non-test consumer.+const LEGACY_STATE_PATH = join(homedir(), ".local", "state", "hyperframes", "install-state.json");+describe("config.ts — readConfig / readConfigFresh / writeConfig (real module, faked fs)", () => {let readConfig: typeof import("./config.js").readConfig;let readConfigFresh: typeof import("./config.js").readConfigFresh;@@ -143,11 +148,6 @@ describe("install-state rollover (breaker survives a config re-mint)", () => {let CONFIG_PATH: typeof import("./config.js").CONFIG_PATH;let STATE_PATH: typeof import("./config.js").STATE_PATH;- // Derived here rather than exported from config.ts: the pre-move path is- // frozen history, so pinning the literal is the point — an export would- // just let a rename pass silently, and it has no non-test consumer.- const LEGACY_STATE_PATH = join(homedir(), ".local", "state", "hyperframes", "install-state.json");-beforeEach(async () => {fsState.files.clear();vi.resetModules();@@ -322,7 +322,7 @@ describe("bucket-seed carryover (cohorts survive a config wipe)", () => {expect(state.bucketSeed).toBe(config.bucketSeed);});- it("the seed survives a config wipe — the machine keeps its cohorts, only the id re-rolls", () => {+ it("the seed survives a config.json re-mint — cohorts hold, only the id re-rolls", () => {const first = readConfig();fsState.files.delete(CONFIG_PATH);const second = readConfigFresh();@@ -330,6 +330,28 @@ describe("bucket-seed carryover (cohorts survive a config wipe)", () => {expect(second.anonymousId).not.toBe(first.anonymousId);});+ // The counterpart, and the reason install-state shares CONFIG_DIR: a seed+ // that outlived `rm -rf ~/.hyperframes` would be a persistent identifier+ // defeating the only reset the user has.+ it("the seed does NOT survive deleting the config dir — that reset is real", () => {+ const first = readConfig();+ fsState.files.delete(CONFIG_PATH);+ fsState.files.delete(STATE_PATH);+ const reborn = readConfigFresh();+ expect(reborn.bucketSeed).toBeTruthy();+ expect(reborn.bucketSeed).not.toBe(first.bucketSeed);+ expect(reborn.predecessorFound).toBe(false);+ });++ it("adopts a pre-move seed so the migration does not reshuffle a live cohort", () => {+ fsState.files.set(+ LEGACY_STATE_PATH,+ JSON.stringify({ markerAt: "2026-07-28T00:00:00.000Z", bucketSeed: "seed-from-old-path" }),+ );+ expect(readConfig().bucketSeed).toBe("seed-from-old-path");+ expect(fsState.files.has(LEGACY_STATE_PATH), "legacy copy removed").toBe(false);+ });+it("the seed survives config corruption via the same mint path", () => {const first = readConfig();fsState.files.set(CONFIG_PATH, "{not valid json");diff --git a/packages/cli/src/telemetry/config.ts b/packages/cli/src/telemetry/config.tsindex 23c254268e..6482c563dc 100644--- a/packages/cli/src/telemetry/config.ts+++ b/packages/cli/src/telemetry/config.ts@@ -29,8 +29,8 @@ const CONFIG_FILE = join(CONFIG_DIR, "config.json");// that churn: no shared schema to migrate on upgrade, and one write at first// mint instead of one per command.//-// It carries exactly two facts, and no identity — no anonymousId, no-// counters, nothing linking the old install to the new one:+// It carries exactly three facts, and no telemetry identity — no anonymousId,+// no counters, nothing emitted that links the old install to the new one://// 1. `markerAt` — "a hyperframes install existed on this machine". Now that// it shares CONFIG_DIR, `predecessorFound` measures the churn we care@@ -39,6 +39,10 @@ const CONFIG_FILE = join(CONFIG_DIR, "config.json");// 2. `deParallelRouterTrialFired` — the DE parallel-router circuit// breaker's tripped state, so a config re-mint does not re-enrol an// install into an experimental path that already FAILED on this machine.+// 3. `bucketSeed` — the canary bucketing unit, so a re-mint does not+// reshuffle cohorts mid-rollout. Never transmitted; only the resulting+// true/false assignments are. Sharing CONFIG_DIR is what keeps it from+// being a persistent identifier that outlives the user's reset.//// Removal path: delete ~/.hyperframes (or just this file). `hyperframes// telemetry status` prints its exact location.@@ -57,9 +61,10 @@ interface InstallState {/** Rolled-over circuit-breaker state — see HyperframesConfig's field. */deParallelRouterTrialFired?: boolean;/**- * The machine's canary bucketing seed — see HyperframesConfig's field.- * Write-once: the first install's seed is the lineage's seed forever, so a- * config wipe re-mints the telemetry id but NOT the canary cohorts.+ * The canary bucketing seed — see HyperframesConfig's field. Write-once+ * within this config dir: the first install's seed wins forever, so a+ * config.json re-mint re-rolls the telemetry id but NOT the canary cohorts.+ * Deleting ~/.hyperframes takes the seed with it, by design.*/bucketSeed?: string;}@@ -152,7 +157,7 @@ function sameInstallState(a: InstallState, b: InstallState): boolean {);}-/** Latching: once tripped (by any install in this machine's lineage), stays tripped. */+/** Latching: once tripped (by any install in this config dir), stays tripped. */function latchedFired(state: InstallState | null, config: HyperframesConfig): true | undefined {return (state?.deParallelRouterTrialFired === true ||@@ -169,7 +174,7 @@ function nextInstallState(const next: InstallState = {markerAt: state?.markerAt ?? new Date().toISOString(),deParallelRouterTrialFired: latchedFired(state, config),- // Write-once: an existing lineage seed always wins, so cohorts stay+ // Write-once: an existing seed always wins, so cohorts stay// anchored to the FIRST install in this config dir, not the latest one.bucketSeed: state?.bucketSeed ?? config.bucketSeed,};@@ -289,7 +294,8 @@ export interface HyperframesConfig {/*** Whether a previous install's state marker existed on this machine when* this config was minted. Attached to telemetry so the fraction of fresh- * installs that are RECOVERABLE churn (config wiped, machine persisted) is+ * installs that are RECOVERABLE churn (config.json re-minted, install-state+ * survived) is* measurable directly. `undefined` on configs minted before this field* existed — a different fact from `false` (minted fresh, no predecessor).*/@@ -297,12 +303,20 @@ export interface HyperframesConfig {/*** The unit canary percentages bucket on — deliberately NOT the anonymousId.* A fresh random UUID, mirrored write-once into the install-state file and- * inherited at mint, so a config wipe re-rolls the telemetry id but keeps- * the machine's canary cohorts: no cumulative-exposure drift from wipes,- * and before/after comparisons survive a reinstall. It is never emitted in- * telemetry (only the resulting true/false assignments are), so it does not- * link the old id to the new one server-side. Backfilled once for configs- * predating the field.+ * inherited at mint, so a config.json RE-MINT re-rolls the telemetry id but+ * keeps this install's canary cohorts: no cumulative-exposure drift from+ * corruption, and before/after comparisons survive one.+ *+ * A re-mint is the churn that actually happens — config.json is rewritten on+ * every command and every render, and readConfig recovers from any+ * parse/permission/IO failure by minting fresh. Deleting ~/.hyperframes+ * deliberately does NOT survive: install-state lives in that same directory+ * precisely so the user's reset is a real reset. A seed that outlived it+ * would be a persistent identifier defeating the only lever they have.+ *+ * Never emitted in telemetry (only the resulting true/false assignments+ * are), so it does not link the old id to the new one server-side.+ * Backfilled once for configs predating the field.*/bucketSeed?: string;/**@@ -422,7 +436,7 @@ export function readConfig(): HyperframesConfig {};// One-time backfill for configs predating the bucket seed: prefer the- // lineage seed if a previous install already recorded one, else mint.+ // recorded seed if a previous install already wrote one, else mint.// Persisted immediately — an unpersisted seed would re-roll every process.if (config.bucketSeed === undefined) {config.bucketSeed = readInstallState()?.bucketSeed ?? randomUUID();