Skip to content

macOS engine: an inputSourceChanged stop states no count it can't stand behind (#616) - #619

Merged
SSFSKIM merged 24 commits into
mainfrom
fix/616-midswitch-count
Nov 29, 2026
Merged

SSFSKIM merged 24 commits into
mainfrom
fix/616-midswitch-count

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 29, 2026

Copy link
Copy Markdown
Owner

Closes #616.

When the input source changed mid-way through a keyed type_text, the macOS engine stopped with inputSourceChanged and reported a count of characters entered. That count came from what had been posted, not from the field. A unit whose key down (which carries its text) went out before the check that saw the switch was in the field but not in the count, and keys posted before that check can land after it. In the hosted run the engine answered 67 while TextEdit held 70.

Review also showed that reading the field back can't settle the count reliably. A stale read can equal the posted prefix while the field holds more; for example, a field that expands "a" to "ab" before taking the next "b". A password field that ignored the input still confirmed by its length and caret. So the stop now states no number.

What changes (rulings 1291, 1299, 1300):

  • Once any text-bearing key down has gone out, an inputSourceChanged stop reads nothing and answers "The input source changed part-way, so cua could not confirm how much was entered; read the field before continuing." Meta enteredRange: {low: 0, high: total} replaces entered.
  • A stop before any key down went out answers "The input source changed after 0 of N characters were entered." with entered: 0, plus beforeInput: true when no event at all went out.
  • Concealed requests carry no count or range, as before. Their sentence is "The input source changed while the text was typed, so some or all of it may have been entered." plus the concealed remedy, with no advice to observe the app (ruling 1247 d). Before any key down: "nothing was entered".
  • The secret wrapper now says "some or all of it may have been entered" instead of "it may have been partly entered" on every failure after substitution, on macOS and Linux. A stop at the final source check posts the whole secret, so "partly" said fewer than may have been entered. sky.mjs renders this sentence for sky_linux, and browser.mjs renders it on every platform. #604: a failed secret on Linux says "nothing was entered" when the verified engine shows none went out (cua 0.31.1, linux-engine 0.4.8) #617's trust gate is kept: "nothing was entered" still requires the beforeInput record from a trusted engine, macOS or Linux.
  • The service carries cua/enteredRange and cua/beforeInput.
  • The native matrix's mid-switch cell, in the live judge and the offline re-judge:
    • after a key down, it passes on no number with {0, total} and the field holding a prefix of the text;
    • before any key down, it passes on 0 with beforeInput and the field unchanged;
    • any other number fails it, so the hosted 67-against-70 case now answers with no number;
    • a range must satisfy 0 <= low < high <= total, which here always means {0, total}.

Withdrawn during review: countAtStop and the exact form ("as the field reads back; type the rest from there"), 1294 (2)'s readbackAbovePosted diagnostic, and 1294 (3)'s per-engine rangeOnReadable tally.

Ordinary confirm is unchanged. git diff origin/main -- native/engine/Sources/Engine/TypeReadback.swift native/engine/Sources/Engine/TypeReadbackLength.swift is empty: both files are byte-equal to main's, so nothing of #616 remains in them. #618 tracks a separate, pre-existing ambiguity in ordinary confirm's placeholder-line handling.

Meta compatibility: entered keeps its shape. On an inputSourceChanged stop it is present only as 0, before any key down. enteredRange and cua/beforeInput are new.

Versions: engine 0.2.5, plugin 0.31.2 (main is 0.31.1 after #617; the final number is set at merge).

Tests:

  • swift test: 1848 passed, 2 skipped. InputSourceStopTests (6) covers the hosted case, every stop after a key down (late, lost, over-delivered, ending in a Return or a Tab, the whole text, a unit boundary), a password field, stops before any key down, keyText alone, and concealed requests. None of these reads the field after the stop.
  • Focused Node suites pass: services-sky (and its trust, linux and linux-record suites), services-browser, services-engine-service, services-engine-linux, doctor-engine, doctor-engine-linux, linux-secrets, linux-engine, repl-host/linux-native, native-matrix, native-engine-assemble, cli-engine, and #604: a failed secret on Linux says "nothing was entered" when the verified engine shows none went out (cua 0.31.1, linux-engine 0.4.8) #617's runtime and accept-linux suites.

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

… reads back, else a range (refs #616)

Ruling 1291. The count came from the units whose every event had gone out when the
source check before an event saw the switch: a unit whose key down (which carries its
text) went out before that check is in the field but not in the count, and keys posted
before the check can still land after it.

Now the source check throws InputSourceChange, and keyText answers it:
- the field read back by the read-back's own machinery (TypeReadback.countAtStop: R1's
  readbackClassify, readbackPoll with ReadbackRetry, the focus check, a password field's
  length batch, never its value), a reading counting only once it held for the quiet
  window: "after 70 of 1079 characters were entered, as the field reads back";
- unread with a unit part-way: "after between 67 and 70 of 1079 characters were entered;
  the field could not be read back, so read it before continuing", meta enteredRange
  {low, high} and no entered;
- unread with no unit part-way: the posted count, with the same remedy;
- a concealed request: no count, no range, no read-back after the stop, and no advice to
  observe the app once anything may have gone in (ruling 1247, d).

Sminos-Session: cursor235#b93055dd (cua on macbook)
…may have been entered" (refs #616)

The engine service carries an inputSourceChanged stop's range as cua/enteredRange
({low, high}), reset with every call like cua/entered.

The secret wrapper withholds the engine's sentence and never tells a count; its own
sentence after a key may have posted said "it may have been partly entered", fewer than
may have been when the stop came after the last key (the final source check). It now says
"some or all of it may have been entered", on every failure after substitution. "Nothing
was entered" still rests on the engine's beforeInput record alone, and no sentence once
entry is possible advises observing the app (ruling 1247, d).

Sminos-Session: cursor235#b93055dd (cua on macbook)
…it brackets (refs #616)

The inputSourceChanged pattern takes the range's form ("after between <low> and <high>
of <n> characters"); the lane keeps cua/enteredRange; a row answered with a range passes
when the field holds exactly the text's first <length> units with <length> inside it
(outcome.inRange), and the offline re-judge reads the same.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…stop's meta (refs #616)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…rvention sentences remain (refs #616)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…d reads everything posted (refs #616)

Rulings 1294 and 1295, on the review of bf594e1..68165aa.

- P1-1: the range's low end is the last prefix the field was confirmed to hold (the stop
  poll's last such reading, else the last checkpoint's, else 0), never the units sent
  whole; exact 0 only for a stop before any key down went out.
- P1-2: a reading below what was posted is not settled however long it holds; the poll
  goes to the 1 s budget and then answers the range, with no place to resume from. Exact
  only when the field reads equal to everything posted (or more) for the quiet window, or
  its confirmed prefix already reaches what was posted. The length poll takes the same
  rule.
- P2: where the caret must tell (a value that is the snapshot's own, an ending Return's
  placeholder line), only a value read after the caret read, still the same, counts.
- P2: "x\n\n" with the caret at 2 after a stop past the first Return of "x\n\ny" is one
  Return, not two.
- P2: a prefix ending inside a Unicode-string event's run maps to the request's units.
- 1294 (2): a count above what was posted is accepted and marked readbackAbovePosted on
  the record.

Range sentence: "...after between 67 and 70 of 1079 characters were entered; read the
field before continuing."

Sminos-Session: cursor235#b93055dd (cua on macbook)
…tures take the range's wording (refs #616)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…ge, and tallies range answers (refs #616)

The sentence's count, or its range endpoints and total, must agree with cua/entered or
cua/enteredRange and with the field's length, the field holding exactly that prefix, in
the live judge and the offline re-judge (midSwitchAnswer). The section's
midSwitchAnswers counts exact and range answers per engine and names every range on a
readable field (every mid-switch field is one) for design (ruling 1294, 3).

Sminos-Session: cursor235#b93055dd (cua on macbook)
Sminos-Session: cursor235#b93055dd (cua on macbook)
…it may have been entered" (refs #616)

The merge of main (b3b778e, #617) kept engineRecordTrusted: "nothing was entered" still
needs the beforeInput record from a trusted engine, macOS's or Linux's. Every other
failure after substitution, on either platform, now says "some or all of it may have been
entered"; #617's Linux record test and its sky case assert that wording.

Sminos-Session: cursor235#b93055dd (cua on macbook)
Sminos-Session: cursor235#b93055dd (cua on macbook)
…against the posted prefix (refs #616)

Ruling 1297, on the review of 68165aa..ad6c9c4 (an unsettled reading promoted to an
exact count, and four rules the ordinary read-back already keeps).

The stop's own poll is deleted: stopOffset, stopByValue and stopByLength with their dwell,
caret, placeholder and Unicode-run rules. TypeReadback.countAtStop now runs confirm, the poll
a finished type_text ends with, through the units posted, its budget from now:
- confirmed, and no key that can leave the field posted: exact at the posted count;
- otherwise the range, no resume offset: low the last checkpoint that read back (else 0),
  high the larger of what was posted and the furthest one classified reading of the field
  can stand for (its length beyond what the snapshot kept, mapped to the largest request
  offset putting no more in, a Unicode run unit for unit, capped at the whole request);
- a reading past what was posted marks readbackAbovePosted on the record.

Sminos-Session: cursor235#b93055dd (cua on macbook)
… total (refs #616)

Sminos-Session: cursor235#b93055dd (cua on macbook)
… the ordinary read-back (refs #616)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…, only the least cua confirmed (refs #616)

Ruling 1298, on the review of ad0630c..b15c556 (six of seven findings from the fallback
read after confirm failed).

- The fallback read is deleted: stopReading, stopReach, stopInserted.
- Only an exact read-back carries a count and "type the rest from there" (P1-1); any other
  stop is unconfirmed, meta enteredRange {low, high: total}, no entered. Low: the last
  checkpoint that read back, unless confirm's own readings at the stop contradict it (a
  plain field's first difference inside the checkpoint's text, recorded as mismatchAt; a
  password field's length or caret mismatch), else 0.
- "The input source changed part-way, so cua could not confirm how much was entered: at
  least 2 of 5 characters; read the field before continuing.", or without the "at least"
  when nothing is confirmed.
- P1-3: a posted prefix ending in a Return is exact only with the caret read after it (a
  password field: only where its snapshot read a range). Stop-only; ordinary confirm's
  placeholder handling is unchanged.
- readbackAbovePosted marks confirm's own readings of more than was posted (a longer value
  mismatch; a length poll's overshoot, recorded as lengthOvershot).

Sminos-Session: cursor235#b93055dd (cua on macbook)
…l}, 0 <= low < total (refs #616)

Sminos-Session: cursor235#b93055dd (cua on macbook)
Sminos-Session: cursor235#b93055dd (cua on macbook)
…umber (refs #616)

Ruling 1299, on the review of b15c556..9dd0e30 (every finding a positive claim on an
unconfirmed stop).

- Exact only when ordinary confirm confirms the posted prefix and that prefix holds no key
  that can leave the field and does not end in a Return; a password field the same, on the
  length path's confirm. Such a prefix is not read back at all.
- Every other stop: "The input source changed part-way, so cua could not confirm how much
  was entered; read the field before continuing.", meta enteredRange {0, total}, no entered.
- Deleted: stopCaretAfterReturn, stopContradicts and the checkpoint low end (confirmed,
  confirmedUnits), the "at least" sentence, mismatchAt and ReadbackExcerpt.firstDifference.
- readbackAbovePosted marks any reading confirm took that showed more than was posted, on
  every exit, the length poll's held match left for more included (readbackLengthPast); a
  diagnostic from reads confirm already makes, deciding nothing.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…} (refs #616)

Sminos-Session: cursor235#b93055dd (cua on macbook)
Sminos-Session: cursor235#b93055dd (cua on macbook)
…umber (refs #616)

Ruling 1299's pre-decided fallback, on the review of 9dd0e30..479030f, which reproduced a
wrong exact count (a field expanding "a" to "ab" before taking "b": one stale read equal to
the posted prefix confirmed 2 with 3 in the field; a password field that ignored the input
confirmed by length and caret).

- Every stop after a text-bearing key down reads nothing: "The input source changed part-way,
  so cua could not confirm how much was entered; read the field before continuing.", meta
  enteredRange {0, total}, no entered. Before any key down: "after 0 of N", entered 0.
  Concealed requests as before.
- Deleted: countAtStop and the stop's confirm, the countStop plumbing, the exact sentence,
  readbackAbovePosted and its two setters in confirm, readbackLengthPast, and every test of
  the exact form. TypeReadback.swift and TypeReadbackLength.swift are byte-equal to main's.

Sminos-Session: cursor235#b93055dd (cua on macbook)
… with beforeInput (refs #616)

Ruling 1300. The service carries cua/beforeInput. After a key down the cell passes on no
number with cua/enteredRange {0, total} and the field a prefix of the text; before any, on
"after 0 of N" with cua/entered 0, cua/beforeInput and the field unchanged; any other number
fails it, in the live judge and the offline re-judge. The hosted 67-against-70 case answers
no number. 1294 (3)'s per-engine tally and rangeOnReadable are withdrawn.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…s gone out (refs #616)

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

chatgpt-codex-connector Bot commented Nov 29, 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-29T16:02:38.042001Z 1da39e9 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 enabled auto-merge (squash) November 29, 2026 16:01
@SSFSKIM
SSFSKIM merged commit 1326898 into main Nov 29, 2026
10 checks passed
SSFSKIM added a commit that referenced this pull request Nov 29, 2026
…(cua 0.31.2) (refs #506)

Versions: engineVersion 0.3.4, above feat's 0.3.3 and main's 0.2.5. The plugin is main's 0.31.2.

Resolved by hand:
- Input.swift: InputMeta keeps feat's concealedRefusal and main's enteredRange, and the wire sends both. keyText's
  doc and loop are #616's (downPosted; no number once a key down has gone out). The file differs from main only by
  feat's own M5 changes. TypeReadback.swift and TypeReadbackLength.swift equal main's.
- InterventionTests.swift: feat's #186 every-boundary test (8198c50) asserted the withdrawn count at the key down,
  and it threw a plain EngineError, which #616's keyText answers as a generic error. It is rewritten to #616's rule
  at every event boundary: 0 and no range before any key down; otherwise no entered, the range the whole text, and
  the unconfirmed sentence.
- secret-input.mjs and sky.mjs: #616's "some or all of it may have been entered" wording everywhere, feat's #212
  account sentences included. droppedCharacter now reads "cua never types part of a secret or pastes it". No
  "partly" remains in src/services. #617's engineRecordTrusted is kept beside feat's concealedRefusal sentence.
- The matrix: unicode-run.mjs and unicode-plan.mjs judge midSwitch with #616's midSwitchAnswer (none, zero or count;
  a count always fails). Feat's judgeMidSwitch is removed. lane.mjs's engine meta adds enteredRange and beforeInput.
- Tests: services-sky.test.mjs and services-engine-service.test.mjs keep both sides, and feat's "partly"
  expectations take the new wording. unicode-run.test.mjs is main's.
- The design spec's Text paragraph is feat's, with #616's three edits and the droppedCharacter wording. The wave-1
  spec's #186 oracle line names midSwitchAnswer.
- tech-debt-tracker.md keeps both sides, and drops feat's lastJudgedOf entry, which 275f3bc and ca52dbc fixed.

Sminos-Session: cursor235#b93055dd (cua on macbook)
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 inputSourceChanged stop reports fewer characters than the field holds (67 reported, 70 landed)

1 participant