Skip to content

#117 M2b: the native matrix, oracles and the native-mac suite; route 3 for key equivalents and element actions - #180

Merged
SSFSKIM merged 140 commits into
mainfrom
feat/117-m2b
Oct 22, 2026
Merged

SSFSKIM merged 140 commits into
mainfrom
feat/117-m2b

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 22, 2026

Copy link
Copy Markdown
Owner

M2b of docs/doperpowers/specs/2026-10-18-own-native-engine-design.md (refs #117):

  • the native method matrix, with its non-interference oracle and key guard;
  • the probe-driven cells;
  • the Korean and Unicode matrix;
  • the settle cell;
  • the native-mac parity suite;
  • M2a's residue as live cells.

All of it ran live in four holds on the mini. The full account is in docs/doperpowers/specs/2026-10-18-own-native-engine-m2b-report.md, and the decisions are in the spec's Decision Log ("M2b …" entries, and those dated 2026-10-21/22).

Model-facing changes

  • Renderer trailer. An element line drops the width rule's (showing …), as the vendor prints Finder's focused list view (3fd0d71).
  • Horizontal scroll sign swap. Left is +n and right is −n on wheel2 (a571489). Hold 2b's hscroll verdict was "opposite sign", against a vendor defect.
  • Focus probe. It connects to the WindowServer before reading focus (c5d0067). This is probe-only, but it is in the engine binary.
  • Re-enable after release. A process whose enablement attribute the engine wrote back gets it set again by its next observation, keyed by the process's generation (447bb20, 2442ead). Live in hold 3: native-mac's Electron texts are now identical to the vendor's.
  • Route 3 for ⌘ chords and element actions. It covers AXPress/AXPick click, set_value, select_text and perform_secondary_action, whenever the app does not believe it has focus (cc02709, d16ede6, cb4514b).
    • The activation is held across an interaction. It is released on connection close, on a request to another app, or after 120 s idle.
    • Per-action activations lease the hold.
    • A real activation cycle marks the hold stale, tracked by an epoch.
    • The activation click is posted only when a hit-test at AXActivationPoint answers an inert element. Otherwise the activation events alone run.
    • ⌘ chords match the vendor (F §6.1).
    • Element actions go beyond the vendor. Hold 3's A/B was meant to settle them and did not run (route-ab stopped four times at the Finder scene's bind). Under maws-3f's rule, element-action route 3 and the writes stay on route 3, and the Decision Log records them as unsettled.
    • Hold 3 evidence: background Chromium actions and TextEdit's background ⌘A now take effect, with interference clean.
  • Input-source probe. It reports layout beside id (3b856c7).
  • Keystroke probe. It gains a --keys mode, and every probe now reports exitStatus (353b67c, a0b7dd9, d00d2aa).

Non-model-facing changes

  • Harness-only spike-route forwarding, approved by the owner (Decision Log; a tech-debt row tracks it).
    • CUA_ENGINE_SPIKE_ROUTE=1 lets a click's spikeRoute reach a cua worker only through the native serve's prepareLaunch hook, and only for cell route-ab (48796e1, f28bbe5).
    • src/runtime/launch.mjs drops an ambient value, and cua serve, MCP and plugin launches never carry it.
  • cua/* _meta keys added. None of them appears in content the model reads:
    • cua/activationClick: "posted", or the reason the click was skipped (noPoint, outsideFrame, spared, control, hitTestFailed, actionsUnknown).
    • cua/observation: a bounded whitelist of the engine's observation diagnostics. The native matrix reads it.
  • Harness changes:
    • the matrix's live-hold fixes;
    • Korean established by layout after a refocus;
    • per-row diagnostics (Electron accessibility mode, engine meta, selection evidence);
    • the Finder finding viewport;
    • the route-ab cell;
    • native-mac frames and the pair refusal.

Validation Evidence

  • Hosted CI. Run 39741398510 on 9261815, hold 3's commit (the engine sources and harness at this head), is green on all 8 jobs, including engine-swift, which covers the real-engine tests. Commits after it are docs and evidence only.

  • Engine. swift test --package-path native/engine executed 491 tests with 0 failures, on the merged head. The whole-milestone reviewer-high reran it: 491/0.

  • Node. node --test test/native-matrix/*.test.mjs test/services-engine-service.test.mjs test/runtime-launch.test.mjs test/native-baseline/*.test.mjs test/repl-parity/*.test.mjs passed 1234/1234, with 0 failures.

  • Holds on the mini:

    • hold 1: b74949b3 (m2b/hold1/);
    • hold 2a: f804291e (m2b/hold2a/);
    • hold 2b: 1abea7b0 (m2b/hold2b/);
    • hold 3: 0c363f8f at 9261815 (m2b/hold3/).
  • Hold 3 verdict. As recorded, the verdict is FAIL (m2b/hold3/summary-as-recorded.md). With maws-3f's counting overrides (Decision Log "M2b hold 3"):

    • speed: cua beats the vendor by at least 10% on 50 of 58 ops;
    • non-interference: cua 96.9% (188/194), vendor 98% (97/99);
    • finding elements: 29 of 40 on both;
    • Korean and Unicode: 147 of 225.

    Still missing: the triple (only one paired run), the route A/B, 7 speed misses (owner's fork), and the blocking items listed in that entry.

  • Reviews. Every branch was reviewed to clean at its rung. Route 3 took three high rounds. The whole-milestone reviews at high came back correct on 885d7d8..9bf8103 (after fixes) and on 9bf8103..b94100b.

Unresolved Review Findings

  • Route 3's two epoch ordering windows (the third high review on m2b/route3, Minor; tech-debt-tracker.md).
    • A real activation notification can land between FakeActivation's subtype-1 post and its epoch snapshot (native/engine/Sources/Engine/Activation.swift ~262–264).
    • The notification's own delivery latency is a second window.
    • Neither moves the user's frontmost app. Left by maws-3f's last-round rule.
  • The goldens recorder's own put-back is not judged (tech-debt-tracker.md, the first whole-milestone review). It was left as minor.

Residue

  • Finder scene window growth. The native matrix's Finder scene window grows 28–56 pt per open (660 → 856 pt in hold 3). The bind and teardown checks then report "another process's window is on top" even with none on layer 0. This stopped the vendor lanes' teardown and all four route-ab attempts.
  • Front-app put-back. It keeps a front record left by a failed cleanup, then declines it as a scene app. This is how hold 3's cua run 2 ended.
  • The route A/B and the matrix triple are owed to a later hold. Element-action route 3 stays unsettled until then.
  • Per-context preference. Written with defaults write, it does not take effect live, so every perContext row is invalid. This needs a design call on how the matrix establishes the condition.
  • Findings for maws-3f to judge (model-facing; in the report):
    • midSwitch's cua/entered is one short at the stop (chrome, electron);
    • Chrome's background paste times out on the clipboard read;
    • Electron background typeText, pressKey.tab and paste fail their prepare on cua ("the field could not be given the focus").
  • native-mac frame mismatch. repl-parity's Finder scene height differs per lane (492 against 520), so the native-mac diff refuses the pair.
  • Expected-file questions:
    • r k under Korean composes 가 wherever the input method is engaged;
    • chrome selectText.notText's refusal sentence;
    • TextEdit's native-mac diff text (scroll bar value indicator).

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)

…lls, the first hold first

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…the HID composition row in two variants

The keystroke probe's arguments parse into KeystrokeRequest (KeystrokeProbe.swift), and --key-codes-only posts the
layout's same key codes and flags with no CGEventKeyboardSetUnicodeString on any event; a text the layout cannot key
is refused before anything is sent. The probe's JSON now names the layout it keyed through and each press (key code,
flags, string). The default posts what it posted before.

live.mjs paste's HID composition row runs twice under Korean 2-Set with the run's TextEdit frontmost and key: with
each key's string, then key codes only, each from an emptied document, recording the reading (가, rk, ㄱㅏ or other),
the probe's JSON, the source and layout, and whether the keys went unmodified; the log names both readings.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…esult.json per cell whoever implements it

scripts/native-matrix/cell-result.mjs defines the CellResult and Row shapes that
native-matrix.mjs summary and compare read, with the verdict rule, a validator,
a writer that refuses a non-conforming result and a reader that walks a
directory. M2b.1's live cells conform their result.json to it.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…e only; the probe header re-wrapped

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
sendIfFrontmost takes an optional userWindow ({pid, bounds}), the harness's own
user window of this run: a key may also be sent while that window, by owner pid
and bounds, is the frontmost process's top window, reported as via
'user-window'. Every other window refuses as strictly as before; a bundle-id
target cannot take one.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…ID composition row's third variant

--ansi-keys posts the physical keys whatever the layout: each character's code from press_key's fixed ANSI table
(r 15, k 40, a newline Return), no modifier flag and no string on any event, what the vendor's pressKey posted in
MAWS P4-B2; a character outside the table or keyed there only under a modifier is refused with nothing sent. The
probe's JSON names its mode (typed, keyCodesOnly, ansiKeys) in place of the keyCodesOnly boolean.

live.mjs paste's composition row runs three variants (unicode, keyCodesOnly, ansiKeys), each from an emptied,
read-back document, its commit Return posted the same way as its keys.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
… ansiKeys answers P4-B2

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…n's text

Self-contained helpers a cell embeds by source: element lines, a labelled
part, a multi-line value, the trailer, Finder's rows and visible range,
TextEdit's scroll bar, and the finding-elements scorer's target search and
line measures (titled or labelled share, ID count). Checked on both engines'
goldens from the mini, in English and Korean.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
… out the engine's debounce before each reset; incomplete variants labelled

The probe's keys are a user's to the resident engine, so each variant's posts
start TextEdit's 5 s intervention debounce, and the next variant's set_value
reset was refused (still interacting, then user changed until an observation
past the debounce cleared the re-query flag): a fast run skipped keyCodesOnly
and ansiKeys. Each reset after a post now waits COMPOSITION_QUIET_MS (the
debounce plus 750 ms) from the last post, takes a fresh observation, then
empties; detection stays on. A reset still refused keeps its error
(emptyError). A variant is complete only when its keys and its commit both
exited 0; compositionSummary labels the rest INCOMPLETE with each post's status.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…esult.json per cell whoever implements it

scripts/native-matrix/cell-result.mjs defines the CellResult and Row shapes that
native-matrix.mjs summary and compare read, with the verdict rule, a validator,
a writer that refuses a non-conforming result and a reader that walks a
directory. M2b.1's live cells conform their result.json to it.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…e, a darwin lane pinned and attested per result, the goldens' cells plus settle on four scenes, diff modulo renumbering with declared vendor and scene-state differences

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…utcomes read back, refusals and n/a stated

The 11 methods on the four scenes and TextEdit's Open panel as prepare/act/check cells (one facade call per act, so its
meta carries that call's route), the finding scorer's cell and the speed selection; judged in node against the goldens.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…prepare takes --commit in the Concrete Steps

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…-probe text-view reads a harness text view past the observation

ForegroundAssist reads the user's key window again after the restore's raise and
compares it by window number with the one read before the activation; the input
meta carries keyWindowRestored on route 4 (a restore failure included), closing
tech-debt-tracker's route-4 key-window read. `--probe text-view --pid <n>`
prints, per window of the process, AXMinimized and its first text area's
AXSelectedTextRange and scroll-bar values, plus the focused element's role and
whose text area it is: numbers and roles only. The minimized select_text cell
and the horizontal scroll cell read through it.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…atrix's device reads

Readings kept to the run's own pids, the user window for the key guard, activations charged to the row whose action
they fall in, route 4 and a launch's own activation declared for the owner; the launch path's app brought down.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…y cell's result read in one shape

Methods sample for sample in front and against ground truth behind, the 10% beat, the finding rule with parity for
the owner, non-interference with declared causes; the row id conventions named in the cell-result schema.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…n panel's and the launch path's cells

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…ting the matrix's CellResult

route4, minimized-select, enablement, menu and hscroll run on the hold harness
(live.mjs <cell>; runCell(name) is the one implementation the registry calls)
and write result.json as native-matrix-cell-1 through one adapter
(residue-checks.mjs asCellResult), the live fields kept for the runbook.

- route4: the approved engine launched under a prepared home (open --env HOME;
  Config.swift reads $HOME first) whose engine.json gives TextEdit route 4, the
  owner's file only read; status.routes must name it before anything is sent; a
  synthesized click into the run's TextEdit behind Finder judged by the
  selection collapsing, route 4, Finder frontmost and on top again, and
  keyWindowRestored; the engine stopped and the home removed after.
- minimized-select: select_text into the minimized window, the write read by
  --probe text-view (AXSelectedTextRange on the text area) apart from the
  engine's observation, both again after the restore; the decision follows.
- enablement: judged by the Electron fixture's own record of Chromium's mode
  (isAccessibilitySupportEnabled and its change event, read only), off/on/off
  over two connections; Chrome for Testing recorded as not judged, with why.
- menu: cua's held activation as built against the vendor's lane on the same
  scene state (the switch-on lane is gone), judged by enabled state and effect.
- hscroll: TextEdit on a page wider than its window (scenes-mac --layout
  wide-page), both lanes scroll right one page, read back by the horizontal
  scroll bar; a vendor scroll that moves nothing is declared its defect.

The route-4 key-window tech-debt row is closed (5f947e9 reads it).

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
… verdict

A row that is not ok but carries a declared cause (a vendor defect the cell exists to show) counts toward pass in
verdictOf, the one place the rule lives; the summary lists every such row. The oracle's own declarations move to
interference.declared and never excuse a row's outcome. Row id conventions for background and launch rows named.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…pared in its own form (a full-tree fallback line by line, unparsed lines reported); the goldens' comparator follows trailer indexes through the before texts and compares selected text whole; settled means the same window and trailer; a scene that will not come down is tried again and keeps the approved home held with its journal

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
… verdict

A row that is not ok but carries a declared cause (a vendor defect the cell exists to show) counts toward pass in
verdictOf, the one place the rule lives; the summary lists every such row. The oracle's own declarations move to
interference.declared and never excuse a row's outcome. Row id conventions for background and launch rows named.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
scripts/native-matrix.mjs run|cell|compare|summary|cleanup. One lane per run through the real facade with
CUA_NATIVE_ENGINE pinned and every result attested; the hold reuses the live harness's begin, watch and recover and the
baseline's admission; the registry calls external cells through their harness's runCell and cellIo.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…it activated

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…a whole run passes on

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
… and judges by direction; cellIo is the one io construction

The horizontal scroll cell could not tell the vendor's defect (a scroll that moves nothing) from an opposite sign, since
each lane started at the bar's left end where a scroll left shows as nothing. --probe text-view takes --set-horizontal
<0..1> and writes the horizontal scroll bar's AXValue through the harness's own AX path (neither lane's) before reading;
both lanes start at 0.5 and are read back before the scroll, a start outside 0.2..0.8 leaving the lane invalid. A lane
records its direction (right, left, none), and the verdict tells moved-as-cua (equivalent), moved-nothing (the vendor's
defect, its row declared so the cell passes) and moved-opposite (a sign difference, not declared, the cell fails).

checkPassed now counts rows by cell-result's own rule (counts), so a declared row passes there as in verdictOf. cellIo
(options, {log, interrupt, dryRun}) builds the io main runs with, for native-matrix.mjs's registry to call runCell with.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…howing …), as the vendor prints Finder's focused list view; finder/cua.txt re-pinned

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
… numbering (a fallback keeps surviving indexes); a trailer element's line compared beside its followed index

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…paration.json removed, only once every scene is confirmed down; exit 1 until then

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…aries (mandatory evidence, route 4's delivery, select_text's refusal, hscroll's comparable lanes)

- Every mandatory lane and item needs valid evidence (residueGaps): a cell missing any is incomplete, in the command and
  in the CellResult, its invalid rows kept; a vendor row no longer passes a cell whose cua counterpart said nothing.
- Route 4's delivery is the caret --probe text-view reads on the text area after the click, from a selection the probe
  read before it; the observation's empty selection (a failed focus read looks the same) never establishes it.
- select_text into a minimized window is "refused" only as windowMinimized with nothing posted; userIntervened and
  timeoutReached make the sample invalid; any other error is a failure.
- hscroll compares and declares only lanes whose scroll was carried out, with finite readings before and after. The
  probe sets both bars to 0.5 (--set-vertical beside --set-horizontal) and reports midpointShows, the condition under
  which an element scroll's positionElement does nothing, so the motion read is the wheel's. cua's own failed scroll
  is its failure; the vendor's, an intervention or a timeout say nothing.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…abbed line after the first, a line after a continuation) keeps its number, checked against the renumbering in force where it stands, never matched away

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…A_ENGINE_SPIKE_ROUTE=1, set only by the native matrix's route A/B serve (owner-approved narrowing of bd1136f)

The route A/B (cell route-ab) presses the Electron fixture's button by route 1 alone against the engine's own route 3,
and the matrix reaches the engine only through the product service, which drops every spike switch (bd1136f).

- src/services/engine/service.mjs: with the worker's CUA_ENGINE_SPIKE_ROUTE=1, read once when the service is made, a
  click's spikeRoute is forwarded (exactly 1, 2', 2 or 3; anything else refused before the engine is asked); no other
  method's switch, no other switch. Policy, forbidden list and approval unchanged.
- src/runtime/launch.mjs: copies the variable into the worker only with cua's engine selected and only when the
  caller's environment sets it to 1.
- scripts/native-baseline/remote.mjs, scripts/native-matrix/lane.mjs, run.mjs: only the route-ab lane's serve sets it.
- Tests: forwarded/refused/dropped in the service, copied only for cua's engine and the value 1 in the launch, the
  serve string only when asked, only the route-ab run's serve.
- Spec Decision Log entry (the narrowing, why, the spike service rejected); tech-debt row (keep as a documented test
  hook or remove after #117).

The auto-mode classifier refused this at the plan-executor as a security weakening; the owner approved it and it was
written in the coordinating session.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…e and never passes (review of 6c34c2b)

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…ch after the first begun with the previous hold released and the release shown by the fixture's counters, so every press runs route 3's activation; every row that acted records the activation click the engine reported (cua/activationClick: posted or why skipped, with cua/activationGuardMs; null when the act's meta carries none), read through engineMetaOf

Brought onto m2b/route-ab after 48796e1; natural only leaves CUA_ENGINE_SPIKE_ROUTE unset, since it forces nothing.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…process, unknown actions never inert, the intervention check under the registry's lock

- Findings 1-3: every real NSWorkspace activate/deactivate bumps the process's epoch, held or not; an activation
  reads it right after posting subtype 1 and is stale exactly when it has moved since. A cycle during a first
  activation's guard is no longer lost, one during a replacement's AX reads no longer invalidates it, and a stale
  replacement's failed guard posts no deactivation.
- Finding 4: a hit element whose action query failed is not inert; the activation click is skipped as
  actionsUnknown.
- Finding 5: synthesized clicks, drags, paste and forced keys run the intervention check inside acquire, under the
  registry's lock, and keep the later check.
- The reviewer's reproductions kept as ReviewRaceTests.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…eal-activation epoch, actionsUnknown, the intervention check under the registry's lock

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
… effect fails it in both modes; --natural-only refused for every other cell before dispatch, external cells included (review of 48796e1..d8f2a4b)

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
… element actions held across an interaction, the activation click only on an inert point, cua/activationClick meta; three high reviews (the last: one Minor, logged)

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
… and the env-gated spike route

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…ds CUA_ENGINE_SPIKE_ROUTE; the product launch drops an ambient value (review of 48796e1)

reviewer-medium on 48796e1 found that src/runtime/launch.mjs copied an ambient CUA_ENGINE_SPIKE_ROUTE=1 into any
launch of cua's engine, so an ordinary `cua serve` started with the variable exported would forward forced click
routes: wider than the owner approved (the route-ab harness only).

- src/runtime/launch.mjs: back to 6c34c2b; the variable is dropped with every other ambient value.
- scripts/native-baseline/spike-route.mjs (new): withSpikeRoute adds it to a launch of cua's engine (CUA_ENGINE_APP
  set) when the harness serve's own environment sets it to 1; scripts/native-baseline/serve.mjs applies it through
  the serve's existing prepareLaunch hook, after the provenance witness.
- Tests: an ambient value never reaches the worker on either host or engine; the hook adds it only for cua's engine
  and only for the value 1, without changing the given record.
- service.mjs comment, the Decision Log entry and the tech-debt row describe the hook.

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…l (forced route 1 against the natural route, natural-only fallback, bounded effect poll) and the owner-approved harness-only spike route (CUA_ENGINE_SPIKE_ROUTE through the native serve's launch hook)

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…k and cua/observation (_meta only); sky-behaviour's stale cua Text "focus first" line corrected to route 2' with route 3 for chords and element actions

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
…B, the verdict both ways), Surprises (AppKit layout, route 3 live, Finder growth), M2b.5 ticked, Outcomes & Retrospective, the report

Sminos-Session: cua_repl#1ea561bc (MAWS on macbook)
@SSFSKIM
SSFSKIM merged commit b1174fa into main Oct 22, 2026
6 checks passed
@SSFSKIM
SSFSKIM deleted the feat/117-m2b branch October 22, 2026 21:53
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