Skip to content

fix: installed Chrome fallback, logging and candidate order (#169) - #183

Open
chaodu-agent wants to merge 3 commits into
mainfrom
fix/followup-169
Open

chaodu-agent wants to merge 3 commits into
mainfrom
fix/followup-169

Conversation

@chaodu-agent

@chaodu-agent chaodu-agent commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Refs #169

Change

Four follow-up items from the #165 review that are still valid on main:

  • Call-time logging (M2). When the installed Chrome check fails during browser use, PlaywrightBackend now logs browser: chrome_check_failed class=<class>. Only the class is logged, never a path. Before, only the consent step logged this. The line is written on each failing status, tools or call, so a persistent Chrome problem repeats the line. Log volume is an owner decision and is not changed here.
  • Candidate order (M3). InstalledChromeChecker.check() walks /Applications and then ~/Applications and returns the first copy that passes. If no copy passes, it returns the problem of the first existing copy, so the error class does not change. The protocol doc comment now says this.
  • Test fixture default (L1). FakeInstallFixture now defaults to a Chrome checker over no directories, so no test reads the real /Applications.
  • Remove copy (L3). The Remove confirmation says the installed Chrome choice is removed only when install.json is removed, which matches R7.7.

Review fixes on this head (review pass 1 on ff99d8c): the doc comment on check() was stale (fixed); the candidate-order test now gives the two copies different failure classes and pins which class is reported (fixed); the wiring test uses /home/example as the home path (fixed).

Tests

Failing before the change, passing after. "Before" ran the new tests against the base sources:

  • testChromeProblemDuringBrowserUseIsLoggedWithItsClass: fails before (no log line), passes after.
  • testAValidCopyInHomeApplicationsIsUsedWhenTheSystemCopyFails: fails before (returns invalidSignature from the /Applications copy), passes after. The same test also pins that a failing system copy's class is reported when both copies fail.
  • testFixtureDefaultCheckerNeverReadsRealApplications: caveat. It only fails before the change on a host that has a Chrome-named bundle in /Applications. The Swift test host has no Chrome, so the before run placed a temporary stand-in unsigned bundle there, and removed it afterward. Before: invalidSignature. After: notFound. It is a regression guard for this fixture only, not a general guard.
  • testRemoveCopySaysTheChoiceGoesOnlyWhenInstallJSONIsRemoved: fails before (old copy text), passes after.

Verification for head 6c26ea4

  • Swift: swift build passed. swift test: 856 executed, 5 skipped (environment-gated, also skipped on main), 0 failures.
  • Rust: the repo has no Cargo.toml at its root. The only crate is poc/reverse-attach-linux, and this diff does not touch it. cargo test there: 604 passed, 0 failed, 17 ignored.

CI note

The first run on ff99d8c failed one test in the Rust crate (probe::tests::a_tree_that_listens_is_reported_by_kind_and_a_silent_one_as_none) in the arm64 hands-node job. The same workflow passed on main, and the crate passed on a second host with this diff, so the failure looks environment-dependent. This diff changes no Rust file.

Not in this PR

  • Skipped as invalid on main: none. Every implemented item still matched main.
  • M4 (swap window between signature check and launch): accepted risk in the issue. No action asked for, none taken.
  • Open product decisions, left on follow-up from #165: installed Chrome fallback, check cost, logging and candidate order #169:
    • M1, check cost: reword the docs to say the check runs on every browser call, or cache the result behind an identity check. Caching would change R7.3.1.5 and the code comment, which both say the result is never reused. Latency still needs measuring.
    • L2, displayed version: omit the version when the check fails, or label it as not verified.

…#169)

Follow-up items from the #165 review that are still valid on main:

- M2: a Chrome check that fails during browser use is now logged as
  `browser: chrome_check_failed class=<class>` (class only, no path).
  Before, only the consent step logged it.
- M3: InstalledChromeChecker.check() walks /Applications then
  ~/Applications and returns the first copy that passes. If none passes,
  it returns the problem of the first existing copy, as before.
- L1: the FakeInstallFixture default chrome checker reads no directories,
  so no test reads the real /Applications.
- L3: the Remove copy says the installed Chrome choice is removed only
  when install.json is removed, matching R7.7.

Tests (failing before, passing after):
- testChromeProblemDuringBrowserUseIsLoggedWithItsClass
- testAValidCopyInHomeApplicationsIsUsedWhenTheSystemCopyFails
- testFixtureDefaultCheckerNeverReadsRealApplications (failed before on a
  Mac with a Chrome-named bundle in /Applications, passes after)
- testRemoveCopySaysTheChoiceGoesOnlyWhenInstallJSONIsRemoved

Verification on the final tree:
- Swift: swift build passed. swift test: 856 executed, 5 skipped
  (environment-gated), 0 failures.
- Rust: the repo has no root Cargo.toml. The crate under poc/ was tested
  with cargo test: 604 passed, 0 failed, 17 ignored.

Not changed: M1 (check cost) and L2 (version shown when the check fails)
are open product decisions, tracked on the issue.
@chaodu-agent

Copy link
Copy Markdown
Contributor Author

Important

CHANGES REQUESTED ⚠️ - The code change is correct and small; the only open item is the red Linux hands node (arm64) check on this head, which needs a green re-run before merge.

What This PR Does

Fixes three follow-ups from #169: Chrome discovery refused a valid ~/Applications copy when the /Applications copy failed its check, call-time Chrome failures were not logged, and the test fixture's default checker read the host's real /Applications. It also corrects the removal confirmation copy.

How It Works

  • InstalledChromeChecker.check() now walks every existing candidate in priority order, returns the first copy that passes, and otherwise returns the first existing copy's problem (.notFound only when no copy exists). The error-class contract is unchanged.
  • PlaywrightBackend logs browser: chrome_check_failed class=<class> when locate() fails with a class from the InstalledChromeProblem.classes allowlist. Only the class is logged, never a path.
  • FakeInstallFixture defaults to InstalledChromeChecker(directories: []), so tests no longer depend on what is installed on the CI host.
  • The removal copy now says the stored Chrome choice is removed "when install.json is removed", matching the installer's ownership rules.

Findings

# Severity Finding Location
1 🟡 Linux hands node (arm64) failed on this head (1 of 604 Rust tests); needs a green re-run CI
2 🟢 Candidate loop picks the first passing copy and keeps the first failure class InstalledChrome.swift:123-132
3 🟢 Call-time failure log is class-only and allowlisted, with a test asserting no path leaks PlaywrightBackend.swift:94
4 🟢 Fixture default no longer reads the real /Applications, with a regression test FakeInstallFixture.swift:182
5 🟢 Removal copy matches the installer's ownership behavior, with a test BrowserWizardCopy.swift:82
Finding Details

🟡 F1: arm64 Rust test failure on the reviewed head

Linux hands node (arm64) failed in Unit + conformance tests: probe::tests::a_tree_that_listens_is_reported_by_kind_and_a_silent_one_as_none (src/probe_tests.rs:111) expected listeners: "none" and got "unknown"; 603 passed, 1 failed, 17 ignored. The same job passed on amd64, the merge base passed CI on main, and this PR touches only Swift files, so this looks like a flaky probe test rather than a regression from this change. Please re-run the job and confirm it is green; if it fails again, the flake is worth its own issue.

🟢 F2: Candidate order

The old code took the first existing bundle and stopped there. The new loop matches the intended priority semantics without changing the public API. The new test covers both branches: a valid home copy is used when the system copy fails, and with no valid copy the class from the first existing copy (invalidSignature) is preserved.

Two notes, not blocking:

  • When /Applications has a copy that fails and ~/Applications also has a copy, check() now runs the full signature validation twice per call. This only happens on the failure path, but it adds to the per-call validation cost still open as M1 in follow-up from #165: installed Chrome fallback, check cost, logging and candidate order #169. Worth mentioning when M1 is decided (cache vs. rewording the docs).
  • When both copies fail for different reasons, only the first copy's class is reported. This keeps the error-class contract stable; just don't describe it as a combined diagnosis.

🟢 F3: Call-time logging

The errorClass is checked against InstalledChromeProblem.classes before logging, so no path or user-controlled value reaches the log. testChromeProblemDuringBrowserUseIsLoggedWithItsClass asserts both the line and the absence of the path. A Chrome install that keeps failing logs one line per browser call, with no throttling; that is acceptable for diagnostics.

🟢 F4: Fixture isolation

testFixtureDefaultCheckerNeverReadsRealApplications asserts isInstalled() == false and .notFound. This removes behavior that depended on the host. The PR body mentions a manual stand-in bundle at /Applications used once to demonstrate the old behavior; nothing like that ships in the diff (tests use FakeChromeBundle temp dirs only).

🟢 F5: Removal copy

The test asserts the new wording is present and the old wording is gone.

Baseline Check
  • PR opened: 2026-11-24
  • Base: main, merge base a717a28d21b21d3d98c8dbb0db576c01975a2a94
  • Reviewed head: ff99d8c5c3c5b4b6e43641379aa66af90260db7a, 7 files, +56/-4
  • Main already has: the installed-Chrome checker and call-time check from follow-up from #165: installed Chrome fallback, check cost, logging and candidate order #169
  • Net-new value: fallback to a valid ~/Applications copy, class-only call-time logging, fixture isolation, copy fix
  • CI on this head: Swift build & test pass, Linux hands node (amd64) pass, all other checks pass except Linux hands node (arm64)

Three Reasons We Might Not Need This PR

  1. Narrow edge case - most Macs have one Chrome copy, so the fallback changes nothing for them.
  2. M1 may reshape check() anyway - if per-call validation moves behind an identity cache, this loop is likely to be reworked again.
  3. Half of the diff has no runtime effect - the fixture and copy changes are hygiene and could ship separately.

None of these outweighs fixing a real refusal of a valid Chrome copy.

What's Good (🟢)
  • Small, local changes with a test for each behavior
  • Log privacy is enforced by an allowlist and a test
  • Tests no longer depend on the CI host's installed apps

chaodu-agent and others added 2 commits November 24, 2026 07:56
- InstalledChromeChecking.check() doc comment now describes the rule:
  the first allowed copy that passes, else the first existing copy's problem.
- testAValidCopyInHomeApplicationsIsUsedWhenTheSystemCopyFails gives the two
  copies different failure classes (system copy too old, ~/Applications copy
  bad signature) and asserts the system copy's class is reported, so the
  priority order is pinned.
- BrowserWizardWiringTests uses /home/example as the home path.

Failing before, passing after (base sources with the new tests):
- testChromeProblemDuringBrowserUseIsLoggedWithItsClass: fails, no log line.
- testAValidCopyInHomeApplicationsIsUsedWhenTheSystemCopyFails: fails, returns invalidSignature.
- testFixtureDefaultCheckerNeverReadsRealApplications: fails on the test host
  only when a Chrome-named bundle is present in /Applications. A temporary
  stand-in bundle reproduced that, and it was removed afterward.
- testRemoveCopySaysTheChoiceGoesOnlyWhenInstallJSONIsRemoved: fails, old copy text.

Verification on this head:
- Swift: swift build passed. swift test: 856 executed, 5 skipped
  (environment-gated), 0 failures.
- Rust: the repo has no Cargo.toml at its root. The crate at
  poc/reverse-attach-linux: cargo test gave 604 passed, 0 failed, 17 ignored.
…ners=none

The arm64 run failed a_tree_that_listens_is_reported_by_kind_and_a_silent_one_as_none
with listeners=unknown. spawn returns right after exec while the loader may still
open and close library fds, and a vanished fd is unknown by design. Poll gather for
up to 5s; a tree that stays unknown still fails.

This branch has not been deployed

No deployments
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