Skip to content

Harden Chrome shutdown/write safety, fix flag sync bugs, add test coverage - #26

Merged
itamaker merged 3 commits into
mainfrom
feat/safety-hardening-and-tests
Aug 20, 2026
Merged

Harden Chrome shutdown/write safety, fix flag sync bugs, add test coverage#26
itamaker merged 3 commits into
mainfrom
feat/safety-hardening-and-tests

Conversation

@itamaker

Copy link
Copy Markdown
Owner

Summary

  • Local State is now written atomically (temp file + fsync + rename) with a one-time pristine backup (Local State.go-chrome-ai.bak) before the first modification.
  • Chrome is stopped with a graceful terminate → wait → escalate-to-kill sequence instead of a bare kill; Run aborts before touching any files if a process can't be confirmed stopped, instead of racing a Chrome process that could overwrite the patch on its own exit.
  • Fixed real bugs in syncManagedFlags (duplicate/unmanaged flag names written verbatim, a no-op path that could inject an empty browser map).
  • Fixed macOS helper-process misidentification during shutdown/restart (Google Chrome Helper* was being matched and "restarted" as if it were the browser).
  • CLI now returns a non-zero exit code when any installation/policy action fails, instead of always reporting success.
  • AvailableAIDownloadFlags is now empty: live-verified against Chrome 151 that both previously-listed chrome://flags entries are stale (one removed outright, the other renamed with unverified option-index semantics that would have silently enabled the wrong mode). The GenAILocalFoundationalModelSettings Enterprise policy is independently verified reliable and remains the default mechanism.
  • GUI gained dry-run/no-restart checkboxes (previously its only path had no preview option), fixed an O(n²) log-rendering pattern and a startup dialog that could never render.
  • The three per-platform policy apply/remove implementations were collapsed into one shared skeleton (policy.go); added policy_other.go so the package compiles on any OS.
  • CI now runs on macOS/Linux/Windows with go vet, golangci-lint, -race, and coverage.

Test plan

  • go build ./..., go vet ./..., golangci-lint run ./... (0 issues), go test ./... -race all pass
  • Cross-compiled for linux/windows/freebsd (amd64+arm64 where applicable)
  • make build + make release-check (goreleaser) pass with a version-stamped binary
  • Real end-to-end run against a live Chrome install (not dry-run): graceful shutdown confirmed, atomic write + backup confirmed (MD5-verified against pristine original), Chrome restart confirmed, Enterprise policy confirmed applied via chrome://policy
  • GUI launched and screenshotted: new checkboxes render, empty flags list renders cleanly, no crash
  • Coverage: internal/chrome 15%→76%, internal/app 0%→89%

🤖 Generated with Claude Code

itamaker and others added 3 commits August 20, 2026 16:27
…st coverage

Local State is now written atomically (temp file + fsync + rename) with a
one-time pristine backup before the first modification, and Chrome is
stopped with a graceful terminate-then-wait-then-kill sequence instead of
a bare kill, so patching can never race a Chrome process that's still
alive and about to overwrite the file on its own exit. Fixes several real
bugs in syncManagedFlags (duplicate/unmanaged flag names, a no-op path
that could inject an empty browser map), macOS helper-process
misidentification during shutdown/restart, and CLI exit codes that
previously reported success even when every installation failed to patch.

AvailableAIDownloadFlags is now empty: live verification against Chrome
151 confirmed both previously-listed chrome://flags entries are stale
(one removed outright, the other renamed with different, unverified
option-index semantics that would silently enable the wrong mode rather
than disable anything) — the GenAILocalFoundationalModelSettings
Enterprise policy remains fully verified reliable and is what's actually
doing the blocking by default.

Also: GUI gained dry-run/no-restart checkboxes (previously its only path
had no preview option at all), CI now runs on macOS/Linux/Windows with
vet/lint/race/coverage, and the three per-platform policy
apply/remove implementations were collapsed into one shared skeleton.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Windows CI checked out .go files with CRLF (no .gitattributes to force
LF), which golangci-lint's gofmt check then flagged as "not properly
formatted" on every file — not a real formatting issue, just a
Windows-checkout artifact.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Both are test-only issues, not production bugs:
- TestExpandUserPath used a hardcoded POSIX absolute path ("/etc/opt/chrome")
  to test "no ~/ prefix" passthrough; filepath.Abs on Windows treats that as
  relative to the current drive rather than absolute. Now builds a
  platform-native absolute path via filepath.Abs(t.TempDir()) instead.
- TestMacAppBundlePath exercises macAppBundlePath, which is only ever
  called from launch() when runtime.GOOS == "darwin" and parses
  forward-slash macOS paths — filepath.Dir/Base on Windows use backslash
  semantics instead, so the test isn't meaningful (or reachable in
  production) on non-darwin. Skipped there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@itamaker
itamaker merged commit 5e3d8ce into main Aug 20, 2026
3 checks passed
@itamaker
itamaker deleted the feat/safety-hardening-and-tests branch August 20, 2026 08:41
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