Skip to content

test(desktop): E2E config canary/rollback through Pages-compatible origin into Electron [CODE-545] - #411

Open
AprilNEA wants to merge 1 commit into
xuan/code-544from
xuan/code-545
Open

test(desktop): E2E config canary/rollback through Pages-compatible origin into Electron [CODE-545]#411
AprilNEA wants to merge 1 commit into
xuan/code-544from
xuan/code-545

Conversation

@AprilNEA

@AprilNEA AprilNEA commented Aug 3, 2026

Copy link
Copy Markdown
Member

Implements the executable client half of CODE-545: an end-to-end canary/rollback E2E that drives the real built Electron app against a Pages-compatible local origin serving publisher-produced artifacts.

Stacked on #410 (xuan/code-544, Electron config adapters), which is stacked on #404 (xuan/code-543). Sibling HQ PR: arcboxlabs/linkcodehq#36 (xuan/code-545-e2e, stacked on linkcodehq#26 / xuan/code-542) — it adds the pilot publication harness that generates the deterministic fixture consumed verbatim here (apps/desktop/e2e/fixtures/pilot-e2e-v1.json, byte-identical to the HQ-generated packages/config-publisher/fixtures/pilot-e2e-v1.json).

What this adds

  • apps/desktop/e2e/config-canary.e2e.mts — E2E harness:
    • builds desktop with a baked MAIN_VITE_CONFIG_BOOTSTRAP, starts a local HTTPS server (temp OpenSSL cert, trusted via NODE_EXTRA_CA_CERTS) serving the publisher fixture bytes verbatim with Pages-compatible paths and cache headers,
    • launches the real built Electron via Playwright _electron (under Xvfb), and exercises renderer → preload IPC → main DesktopConfigService, asserting snapshotInfo and effective values throughout.
  • e2e:config-canary script in apps/desktop/package.json.
  • Fixture apps/desktop/e2e/fixtures/pilot-e2e-v1.json (consumed verbatim from HQ; no publisher/render semantics copied into the client).

Scenarios covered (16 assertions, all passing)

embedded defaults before first fetch; offline defaults; baseline publication (activationVersion 1); ETag pointer revalidation; structural canary activation (activationVersion 2); tampered pointer retained current canary; tampered snapshot retained current canary; rollback allocating NEW activationVersion 3 pointing at old baseline snapshot content; replayed pointer refused, rollback retained; roll-forward (activationVersion 4); restart activating staged canary from valid LKG while offline; replay refused after restart; corrupt LKG falling back to embedded defaults; offline refresh with corrupt LKG keeping defaults; recovery via republication.

Verification (Linux orb)

  • devenv shell -- sh -c 'cd apps/desktop && xvfb-run -a pnpm run e2e:config-canary' — exit 0, 16 PASS lines, real Electron renderer runtime under Xvfb.
  • pnpm exec tsc --build --noEmit apps/desktop — pass; root pnpm typecheck — pass.
  • Root ESLint — pass (needed elevated heap: NODE_OPTIONS=--max-old-space-size=12288 pnpm exec eslint --concurrency=2 …; default pnpm lint OOMs in this environment).
  • pnpm format:check — pass.
  • pnpm test — 308 files passed, 1 skipped; 2482 tests passed, 1 skipped.
  • Focused: pnpm exec vitest run apps/desktop/src/main/__tests__/config.test.ts packages/foundation/common/src/config — 43 tests passed.

Boundaries / caveats

  • The origin is a Pages-compatible local HTTPS adapter serving publisher artifacts with matching paths/headers — no live Cloudflare Pages deployment occurred and no shared infrastructure was touched.
  • Runtime evidence is Linux + Xvfb only; no macOS/Windows/device coverage is claimed.
  • Pilot brand is acme/desktop/canary (test-only); no production special cases.

Closes CODE-545 (client half).

@linear-code

linear-code Bot commented Aug 3, 2026

Copy link
Copy Markdown

CODE-545

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b37f468f83

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +161 to +164
const RE_SNAPSHOT_PATH = /^\/v1\/acme\/desktop\/canary\/s\/([0-9a-f]{64})\.json$/;

function startDistServer(tls: { cert: string; key: string }): Promise<Server> {
const pointerPath = baseline.pointerPath;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Serve artifacts from the fixture's published paths

When the publisher emits an incorrect or changed artifact path, this E2E still passes because it ignores each step's snapshotPath, uses only the baseline pointerPath, and synthesizes the client-expected snapshot route with this hard-coded regex. That makes the claimed publisher-dist/Pages boundary false-green for path drift; build the served artifact map from every fixture pointerPath and snapshotPath so invalid publisher output fails the test.

Useful? React with 👍 / 👎.

writeFileSync(statePath, '{"lkg":"corrupted', 'utf8');
}

async function main(): Promise<void> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Split the E2E before exceeding the hard change limit

This new executable alone adds 497 lines, excluding the generated fixture, so the commit exceeds the repository's hard 400-line change limit. Split the server, fixture access, and launch helpers into focused modules and keep the commit within the mandated bound.

AGENTS.md reference: AGENTS.md:L48-L48

Useful? React with 👍 / 👎.

Comment on lines +1 to +5
/**
* CODE-545 E2E: publisher dist tree → Pages-compatible local HTTPS origin → real Electron
* activation, snapshotInfo, rollback (new activationVersion over old content), tampered
* pointer/snapshot, replay, corrupt LKG, and offline embedded-defaults fallback.
*

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reduce the banner to a constraint-only comment

This ten-line banner includes an issue identifier and narrates the test scenarios and history rather than limiting itself to the non-obvious standalone-build constraint. Remove the CODE-545 reference and retain at most a one- or two-line warning about rebuilding with the bootstrap.

AGENTS.md reference: AGENTS.md:L42-L43

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant