mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 06:30:03 +00:00
fix(cli,studio): close the five R4 blocking gaps
P1 — the required Test lane was red, and it was my test. The
hostile-Host SPA case asserted a 200, which only holds when
packages/studio/dist is built: true on a dev box, false in CI, so it
passed locally and failed there. The Host split moved into a pure
buildStudioHeadScriptsForHost() and is asserted directly; the route test
no longer depends on build state. Verified by running the CLI suite with
the bundle moved aside — 2330 pass.
P1 — studio:* still bypassed most privacy controls. It honoured two
localStorage keys but not navigator.doNotTrack,
VITE_HYPERFRAMES_NO_TELEMETRY, Vite dev mode or API-key eligibility, and
canary enrolment honoured a different single control. New
telemetry/policy.ts is the one answer to "may this profile be measured",
consumed by both transports and by enrolment. It imports only ./config,
so no cycle with the modules that import it. Each control is asserted
individually.
P1 — LAN/remote preview lost the authoritative decisions. Withholding
the whole head script for any non-loopback Host also dropped the safe
{enabled, forced} map, sending a supported HYPERFRAMES_PREVIEW_HOST=
0.0.0.0 Studio back to re-deriving. Identity injection is now gated
separately from decision injection: identity is loopback-only, decisions
always publish.
P1 — the breaker latch was neither authoritative nor truthfully
persisted. syncInstallState swallowed its own failures so
writeConfigWithResult always reported ok, and reads took the flag only
from config.json. The latch is now merged into every effective read,
which makes install-state authoritative and closes both the failed-mirror
and stale-concurrent-writer paths; the write additionally reports
mirrored: false rather than swallowing.
P2 — public contracts. canary-rollouts.mdx said a config wipe loses the
breaker (it does not) and documented the superseded {name: boolean} map
with unconditional CLI precedence; both corrected, with the precedence
ladder written out and the override exception stated explicitly. PR body
rewritten — it still named ~/.local/state, claimed state survives
deleting ~/.hyperframes, and carried stale counts.
Tests: 2330 CLI (bundle absent), 3151 Studio, 24 core. Fault injection:
reverting each fix alone fails 5 CLI / 5 Studio.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
f81ab0162e
commit
5e2a9432f1
@@ -6,6 +6,14 @@ import { evaluateCanary } from "@hyperframes/core/canary";
|
||||
// Pin the registry: real entries move as rollouts ramp, and these tests are
|
||||
// about the BINDING (does the browser supply the right three inputs?), not
|
||||
// about whichever canaries happen to be live today.
|
||||
// The policy reads import.meta.env.DEV, which vitest sets true — without
|
||||
// this every case would resolve to telemetry_opt_out. Controlled explicitly
|
||||
// so each test states the privacy posture it is exercising.
|
||||
const policyState = { allowed: true };
|
||||
vi.mock("./policy", () => ({
|
||||
browserTelemetryAllowed: () => policyState.allowed,
|
||||
}));
|
||||
|
||||
vi.mock("@hyperframes/core/canary-registry", async () => {
|
||||
const actual = await vi.importActual<typeof import("@hyperframes/core/canary-registry")>(
|
||||
"@hyperframes/core/canary-registry",
|
||||
@@ -43,6 +51,7 @@ function setSearch(search: string): void {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
policyState.allowed = true;
|
||||
localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
setSearch("");
|
||||
@@ -198,6 +207,7 @@ describe("telemetry opt-out is canary opt-out", () => {
|
||||
const OPT_OUT_KEY = "hyperframes-studio:telemetryDisabled";
|
||||
|
||||
it("does not enrol an opted-out browser profile", () => {
|
||||
policyState.allowed = false;
|
||||
localStorage.setItem(OPT_OUT_KEY, "1");
|
||||
// on-everywhere is at 100% — it would be on for everyone otherwise.
|
||||
expect(resolveCanary("on-everywhere")).toEqual({
|
||||
@@ -207,17 +217,20 @@ describe("telemetry opt-out is canary opt-out", () => {
|
||||
});
|
||||
|
||||
it("never buckets an opted-out profile — no cohort is assigned at all", () => {
|
||||
policyState.allowed = false;
|
||||
localStorage.setItem(OPT_OUT_KEY, "1");
|
||||
expect(resolveCanary("on-everywhere").bucket).toBeUndefined();
|
||||
});
|
||||
|
||||
it("still honours an explicit URL override", () => {
|
||||
policyState.allowed = false;
|
||||
localStorage.setItem(OPT_OUT_KEY, "1");
|
||||
setSearch("?hf_canary_off_everywhere=on");
|
||||
expect(resolveCanary("off-everywhere")).toEqual({ enabled: true, reason: "forced_on" });
|
||||
});
|
||||
|
||||
it("reports every canary as false when opted out", () => {
|
||||
policyState.allowed = false;
|
||||
localStorage.setItem(OPT_OUT_KEY, "1");
|
||||
expect(canaryEventProperties()).toEqual({
|
||||
"$feature/canary-on-everywhere": "false",
|
||||
@@ -281,6 +294,7 @@ describe("CLI-launched Studio adopts the CLI's decisions", () => {
|
||||
// opt-outs, and CLI telemetry being on says nothing about this profile.
|
||||
describe("precedence against Studio's own opt-out", () => {
|
||||
beforeEach(() => {
|
||||
policyState.allowed = false;
|
||||
localStorage.setItem(OPT_OUT_KEY, "1");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user