Skip to content

Engine: the next engine restores the Chrome EUI a SIGKILLed or crashed engine left on, from a record kept beside its socket (#293) - #333

Merged
SSFSKIM merged 5 commits into
mainfrom
fix/293-eui-restore
Nov 8, 2026

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Summary

An engine killed with SIGKILL, or one that crashes, used to leave Chrome in complete accessibility mode (AXEnhancedUserInterface, "EUI") for the life of that Chrome. Window moves stayed animated, and Chrome stayed in screen-reader mode. Now every enablement the engine owns is recorded beside its socket, and the next engine's start writes back what a dead engine left on, before it serves.

Closes #293

The rules (the spec's #293 Decision Log entry)

  1. A record, not a watchdog. The record is one JSON file per target process: enablement/<pid>-<start>.json, in the engine's state directory beside engine.sock. Each file holds {pid, start, attribute, ownerPid, ownerStart}. The start times are the kernel's, in microseconds.
  2. When an entry is written. Only when the write will be owned under A3, never for a process whose EUI read true first. The entry names the process that was observed, by its start time at the first observation. If the pid now runs a different process, nothing is filed and nothing is written. The entry is written before the attribute.
  3. When an entry is removed. When the release writes the attribute back, or when the process has ended.
    • The write did not take: the entry is removed at once. Here "did not take" means EUI read back false; Electron's AXManualAccessibility getter can't confirm a write, so it never counts.
    • The outcome is uncertain: the write is rolled back, and the entry is removed only once the rollback succeeds. If the rollback fails, the entry and the ownership stay, so the release or the next start writes it back.
  4. The restore runs in Server.start, after takeLock and before bindSocket. For each entry:
    • The owner is alive (its pid and start time match): the entry is left alone.
    • The target is gone, or its pid now runs a different process: the entry is dropped and nothing is written.
    • Otherwise: the attribute is written false and the entry dropped.
  5. Bounds. Each AX write has a 0.5 s timeout, and the whole restore has a 2 s budget. An entry it doesn't reach is kept for the next start. A malformed entry is skipped with a log line and is never fatal. Each file is written atomically, by a temporary name and a rename.
  6. After a restore. The process is remembered as written back, but only while it still matches the entry's start time. So the next observation sets EUI again and owns it.

Plugin 0.27.10.

Live proof (GitHub-hosted macOS 26.7.2, Chrome for Testing 156; main 81a4309 against 1feda4a; n=6 per cell per head)

The evidence is in docs/evidence/2026-11-08-eui-restore/. Run: https://github.com/SSFSKIM/cua/actions/runs/42520338893.

Step Branch Main (the control)
A observes, then is SIGKILLed entry naming A; EUI stays true; moves animate (3–7 frames) EUI stays true
B starts EUI false 6/6. No read begun after B's socket listened read true. Entry gone, write-back logged; moves take 2 frames 12/12 EUI true 6/6, moves animated
B observes and shuts down B owns it again with a new entry; shutdown writes it false and removes the entry B doesn't own it (prior true), so EUI stays on after B's shutdown
A3: EUI true before any engine starts no entry ever, EUI untouched the same
B's start to listen, median 81 ms 82 ms

Limits

Tests and review

  • Engine: 1,015 tests, 1 skipped as before; EnablementRecordTests holds 17. node --test test/native-engine.test.mjs: 21 of 21 pass, including a start test that seeds 4,001 dead entries and requires all of them gone before the socket first answers.
    • A mutation script removes each of 41 rule parts in turn, and each removal fails a test.
    • One existing expectation changed: BackgroundPointerTests now counts 2 writes for a failed AXManualAccessibility write, the attempt and its rollback.
  • reviewer-high: three bounded rounds over 81a4309..1feda4a.
    • Round 1, three P2s:

      • the entry wasn't tied to the process that was observed;
      • a pid reused during a restore could inherit the write-back;
      • an uncertain write dropped its entry.

      All fixed.

    • Round 2, one P2: AXManualAccessibility's getter can't confirm a write. Fixed.

    • Round 3: CORRECT.

  • CI: ci-gate on 1feda4a, all gates including parity-browser: GREEN, https://github.com/SSFSKIM/cua/actions/runs/42520359301. The head adds only the evidence folder.

Sminos-Session: cursor235#b93055dd (cua on macbook)

… next start writes back what a SIGKILLed or crashed engine left on, before it serves (refs #293)

The record is enablement/<pid>-<start>.json in the engine's 0700 directory: the target's pid and kernel start time (us), the attribute written, and the owning engine's pid and start time. It is filed before an owned write (A3 settles ownership there) and removed once the write back is done or the process ended; a failed write back keeps it. Each file is written whole and renamed into place, one per process.

At start, after engine.lock and before the socket is bound: a dead owner's entry whose target still runs at the recorded start time is written false (0.5 s messaging timeout, 2 s budget) and dropped, and the process is remembered as written back; a gone target or a reused pid is dropped with nothing written; a live owner's entry is left; a malformed entry is skipped with a log line. EnablementRecordTests (12) and the engine's start test in native-engine.test.mjs; 30 mutations, each fails a test.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…ugin 0.27.10 (refs #293)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…marks a restore's write-back only for the entry's own process, and keeps an uncertain write owned unless rolled back (refs #293)

The review of 81a4309..bc44b12, three P2s. (1) The start time is captured with the process's first observation and the entry filed only while the pid still runs that process; otherwise nothing is filed or written. (2) A restored process is remembered as written back under its generation only when the pid still runs the entry's process after the read (currentGeneration), so a pid reused during the restore keeps A3. (3) A write that did not take removes its entry only when it reads back false or a rollback (a write of false) succeeds; a failed rollback keeps the entry and the ownership for the release or the next start. Four new EnablementRecordTests; 39 mutations, each fails a test.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…ce Electron's computed getter reads false after enabling, so it is rolled back or kept owned and recorded (refs #293)

The re-review of a32d029: a false read back proved that a failed write did not take only where the getter can confirm it (enablementReadBackConfirms: not AXManualAccessibility, #244). A new EnablementRecordTests case; BackgroundPointerTests' failed write now counts its rollback; 41 mutations, each fails a test.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…he next start against main's control (refs #293)

Sminos-Session: cursor235#b93055dd (cua on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T20:46:58.939587Z 358b105 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SSFSKIM
SSFSKIM merged commit f859ce6 into main Nov 8, 2026
5 checks passed
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.

macOS engine: an engine killed with SIGKILL or crashed leaves Chrome's AXEnhancedUserInterface on; the next engine restores it

1 participant