Skip to content

Bind native keyboard input to one-shot focus leases - #2313

Merged
abrichr merged 10 commits into
mainfrom
agent/2309
Nov 21, 2026
Merged

abrichr merged 10 commits into
mainfrom
agent/2309

Conversation

@abrichr

@abrichr abrichr commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Native TYPE, KEY and HOTKEY actions need evidence for the live control and exact frame that authorized input. A later keyboard failure must not inherit the focusing gesture's positive receipt. This implements one bounded keyboard phase and an independently checked complete-value observation contract. Closes #2309; component prerequisite for held #2301.

  • Record actual unique UIA focus and compile keyboard anchors from the event's own before frame and operator-selected identity crop.
  • Consume an authenticated 15-second lease over the live runtime target, context and exact PNG bytes. Keep uniqueness checks at issuance/final handoff and identity, focus, geometry/hit-test, context and deadline checks at every physical edge. Uncertainty releases held keys and creates no keyboard receipt or retry.
  • Require v2 editable observations with exact agreement between two identity-bound native Unicode extent/full reads and two UIA reads. Empty can be complete. Missing, password, read-only, oversized, unstable or disagreeing observations refuse; no Name/MSAA fallback, normalization, truncation or silent native override. Clients require the closed completeness proof.
  • Allow at most two keyboard-only reacquisitions after an authenticated zero-keyboard-input frame refusal, with full revalidation and an unchanged complete TYPE baseline. Never repeat the focusing action or retry uncertain/effectful/irreversible input. Retain the actual authorized attempt frame. Clear the current-action receipt on entering the shared phase, preserve prior delivery-attempt accounting, and retain genuine focus acknowledgement separately in raw transport evidence.

Original reviewed component source: 861dd92f5856af0282baf4783686c96f0cf22acc. The shared value helper is unchanged from separate commit 824069bc7c8202ba436121872b1e38d68ba5fb0b; the phase correction is unchanged from 0f9b592387cc5b1cc1a6b38a60978ec792c91cd9. The ordinary main merge preserves accepted binary-descriptor tests and every native guard.

Actual Windows run 44676783198 passed nine guard cases, eight value observations and two compiled TYPE controls. Independent raw-artifact checks verify real stored 8,196-unit disagreement refusal, empty/short completeness proofs, valid authorized PNG hashes/CRCs, unchanged SQLite and terminated processes. Each runtime case has one separate genuine focus ACK, one zero-input stale-frame refusal and one actual keyboard input. Success retains its actual typing receipt; lost ACK has no current-action receipt, explicit physical typing uncertainty and no retry. Normal replay updated only the target; the sibling case halted without writing.

The governed approval campaign did not pass. Its existing non-gating test failed in the approved phase on form_changed_after_approval, safely halted before effect and left every row unchanged. Held/resumed phases never ran. Its safety gate passed, explaining the green overall workflow. This is retained prominently beside the successful component proof. The older c20 green run and failed stronger receipt assertion also remain unchanged; before the correction, six lost-ACK controls failed across the three keyboard entry points while six success controls held.

Validation: 138 combined phase/value/client/binary cases pass after integration; neighboring delivery/uncertainty and exact-checkpoint controls also pass. Pinned Ruff 0.17, typed affected source, source boundary, size ratchet, generality and workflow checks pass. Counts overlap and are not summed. Local native skips are collection only. The draft CI results belong to that original head. Grok approved its component scope.

The PR is ready for component review and normal CI at cf32fa5b52bf76954d15570c2a196cdfd0791e5d, after merging main d10f0a2b. The IR module retains its job-authoring imports and re-exports the keyboard evidence model. The two affected line budgets match the merged source. All 139 focused keyboard, job-authoring schema and consumer tests passed. The IR lint and size checks passed. These tests ran on macOS. Windows evidence above belongs to the previously reviewed head. Full Windows qualification, qualification admission, hosted image attestation and release remain separate. The stricter approval/structural stack is separate and held: Name/MSAA captions exposed as preview text cannot become business identity authority. A future combination needs an independently qualified complete identity source or remains unqualified; the older short-note run does not qualify it.

  1. No per-app engine code: native API/value/phase contracts; app knowledge stays in synthetic fixtures.
  2. Fix the class: one model covers TYPE/KEY/HOTKEY, receipt ownership, frame attribution and complete editable observations; approval/structural consumers reuse the canonical helper separately.
  3. Held-out evidence: synthetic replacement, consumed-token and lost-ACK cases; another real application and the strict combined stack have not been shown.

Durability: independently verifiable action receipts, explicit incompleteness and correct temporal attribution. Author vendor: OpenAI/Codex. Keep all full-stack, #2301, image and release holds.

@abrichr abrichr added the review-needed Needs an independent review from another vendor's agent label Nov 20, 2026
@abrichr

abrichr commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

From: Codex
Reviewed-Head: 861dd92

@abrichr

abrichr commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 861dd92

Component scope only. This accepts the one-shot native keyboard lease and the TYPE, KEY, and HOTKEY edges that this macOS process actually exercised, plus an independent reading of the public Windows artifact already stored for run 44676783198. It does not accept the governed approval campaign, and it does not accept whole-stack, application, image, qualification-admission, or release success. Those broader holds in the public pull request stay in place.

What this process ran

Identity checked again before writing: the frozen public checkout, HEAD 861dd92f5856af0282baf4783686c96f0cf22acc, status only untracked review-output/.

A bare import of openadapt_flow on this machine resolves outside this checkout. That discovery was discarded. It is not a test of this head. Every local pytest and probe below set PYTHONPATH to the source-relative packages/flow directory of the frozen public checkout. The recorded import root is packages/flow/openadapt_flow/__init__.py under that checkout.

Focused pytest, serial, through the shared CPU-slot wrapper, cwd packages/flow, -p no:cacheprovider -o addopts=. JUnit review-output/pytest-focused.junit.xml: host class macOS, not Windows, timestamp 2026-11-20T01:10:23.826133-05:00, time 11.295s. Recorded tests 195, failures 0, errors 0, skipped 2. The two skips are test_native_keyboard_lease_actual_delivery_and_refusal and test_native_editable_values_and_runtime_type_retry, both "opt-in hosted Windows e2e". Skips are not native execution. Hypothesis example counts inside those tests are not extra passes. This host is not Windows.

Eight adverse records were then written to review-output/probes/adverse-results.json. An earlier probe attempt printed a line and then died while serializing ValueProof dataclass fields. That crash wrote no results file. It is a probe failure, not a product failure. The counts below are only the persisted rerun.

Disappeared focus is not a blocking defect

disappeared_focus_before_callback_is_a_zero_input_refusal has boolean ok: false. The probe required KeyboardLeaseRefused / stale_focus and a client StructuralResolutionRefused. That expectation is stronger than the contract.

What the rerun measured, with the input callback not invoked:

  • Controller type KeyboardLeaseError, message focused_target_unavailable, not a refusal, input_callbacks empty.
  • HTTP 409, code keyboard_lease_unavailable, body keys only code, error, status. No no_keyboard_input_delivered. http_input_callbacks 0. Three focus reads: two for issue, one before the callback.
  • The same 409 body, fed to the public client, became ActionDeliveryUncertain for physical_press, cause KeyboardLeaseAcknowledgementInvalid.
  • Contrast in the same probe: a different well-formed fingerprint is stale_focus with no_keyboard_input_delivered: true and no callback.

That split is what the source says. KeyboardLeaseError is "a bounded observation failure, with no delivery assertion" (packages/flow/openadapt_flow/backends/win_agent/keyboard_lease.py:23-24). A missing target fails _target at lines 71-80, before the input callback. A different fingerprint is the typed stale_focus refusal at lines 285-287, after the lease is consumed at line 262. The server maps the parent KeyboardLeaseError to a generic 409 without a zero-input flag (server.py:3400-3408). Typed refusals are a different handler just above that. The client accepts a 409 as zero-input only for the closed refusal schema; any other 409 is ActionDeliveryUncertain (windows_keyboard_lease.py:184-279).

The design says replayed leases, changed focus, invalid frames, and changed context refuse, and that lost or malformed acknowledgements are uncertain and are never retried (packages/flow/docs/design/NATIVE_KEYBOARD_LEASE.md:29-30). "Changed focus" here is the positive mismatch the contrast reproduced. An unreadable census is an observation failure. The generic 409 is also the consumed-lease body. The consumed-lease control passed: first press HTTP 200 with one press, replay HTTP 409 keyboard_lease_unavailable, and no second input. Treating every such 409 as zero-input would let a lost success acknowledgement be retried. Unknown failures do not enter the keyboard reacquisition path (keyboard_delivery.py:4). Reacquisition remains the authenticated stale-frame path only.

I do not count this record as a product pass, and I do not count it as a product test failure. It is one boolean failure of an over-strong probe expectation. Measured effect: no keys, no receipt, no zero-input attestation, no retry. Uncertainty can later be reconciled only when both the postcondition and the independent effect already confirm (replayer.py:9029-9041 and 9216-9227). This process did not execute that reconciliation into a false success.

Other local controls

Boolean ok: true, excluding the import-root bootstrap record:

  • Consumed lease replay: one press, then 409, no zero-input flag, no second input.
  • Non-ASCII prepare, then stale focus: reason stale_focus, prepare ran, key callback did not.
  • Second character of a two-character type after focus loss: down and up of the first character, held keys empty, second character not pressed, no receipt.
  • Lost keyboard acknowledgement: prior focus receipt cleared, delivery_attempted stayed true, one keyboard attempt, exception ActionDeliveryUncertain, no retry.
  • Stable baseline reacquisition: attempts ["before","before"], phase keyboard, zero focus clicks. A changed baseline and an irreversible step each stopped after one input attempt.

complete_value_requires_two_source_agreement_and_closed_proof printed PASS because its ok value was truthy. The stored ok is not a boolean. It is ValueProof.__dataclass_fields__ serialized as Field metadata. Do not read that object as a pass bit. The stored measurements that are usable are: disagreement reason provider_native_value_disagreement, empty proof utf16_units 0, password reason password_or_password_status_unavailable, legacy complete: true rejected, and a proof with native_reads 1 rejected. The focused pytest file test_native_value_completeness.py is the boolean coverage for the rest of that contract. This probe record is not counted as one of the boolean passes.

Persisted records: 8. Boolean true: 6, of which 1 is import root and 5 are product controls. Boolean false: 1, the over-strong focus expectation. Non-boolean ok: 1, the value probe.

Public Windows artifact, read not rerun

Inspected review-output/windows-artifact from workflow run 44676783198. Both nkl/source.log and nkl-editable/source.log contain this head and run=44676783198. This was not a Windows or native run by this reviewer. Author junit files in that artifact are one test each, zero failures. Those are author records. They are not added to the local 195.

Lease proof schema openadapt.native-keyboard-lease-proof/v1, platform Windows-2025Server-10.0.26100-SP0, nine cases. Positive attempts carry physical_type_text or physical_press, native: false, outcome_verified: false, and a 64-character fingerprint: type, key, hotkey, and fresh_after_zero_input. stale_frame, stale_focus, and replaced_target store exception_type and refusal with no attempt receipt. uncertain_ack stores actual_response_discarded and has_receipt: false. Stored patients.db notes are 10 of 10 empty (empty-string sha256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855). The same database hash is on the editable copy. UI field hashes changed across lease cases; row notes did not. No note text is copied here.

Ten PNGs under the current lease case: PNG magic, chunk CRCs, and IHDR 1024 by 768, 8-bit RGB. All seven frame_sha256 values in that evidence are bytes of those PNGs. None missing. The act0 and actcurrent trees match file-for-file, as do the editable, replay, and governed duplicate trees. Identical copies are not a second campaign.

Editable evidence schema is openadapt.native-editable-runtime-proof/v1. Its observations carry value_sha256, complete, and a completeness proof with method, native_reads, uia_reads, utf16_units, and sha256_utf16le. This inspection recorded that key shape. It did not recount observation rows or treat the author's passed flag as this reviewer's measurement.

Replay evidence: none success true, model calls 0; siblings success false with a stop present and no changed ids. Governed evidence: phases ["approved"] only, approved exit 1, outcome HALTED_BEFORE_EFFECT, decision stop_before_saving, one halt at step_006 category governed_refusal, one approve answer, 10 of 10 row notes empty, environment unchanged before and after. Held and resumed phases are absent. The green desktop workflow does not wash out that halt. The governed failure remains a separate hold.

Limits

Not executed here: hosted Windows e2e, any new native or GUI lab, whole-stack replay, application qualification, image qualification, qualification admission, release. Local tests used synthetic in-process fakes, including a stubbed pyautogui inside the probe process only. No tracked source was edited. Nothing in this pass was published.

@abrichr abrichr removed the review-needed Needs an independent review from another vendor's agent label Nov 20, 2026
@abrichr
abrichr marked this pull request as ready for review November 21, 2026 01:24
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

From: Codex
Reviewed-Head: cf32fa5

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: cf32fa5

This is a re-review of my component APPROVE at 861dd92f. cf32fa5b is a merge of current main (d10f0a2b) into that head. Combined conflict hunks are only ir.py (job-authoring imports kept together with the FreshActuationEvent re-export) and the DECOMPOSITION.md size ratchet. ir.py is 6830 lines and the resolved budget is 6830; the other ratchet rows I checked match the merged tree. Unique compile/replayer hooks (anchor_native_keyboard, _native_keyboard_lease_required) are still present versus main. Other unique files auto-merged with no --cc hunks.

Windows qualification evidence still belongs to the earlier head, as the PR says. The governed approval campaign still did not pass. I am not merging: the public OpenAdapt merge HOLD (openadapt-internal#211, 7055094893 / 7055145886) stands until the privacy-floor PR merges.

Logged on openadapt-internal#211.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

The first ready-for-review CI run on cf32fa5b failed two tests in Flow shard 3. Both tests passed on the exact main parent d10f0a2b. PR failure · Main results

  • The browser test found zero queued clicks after yielding to Playwright for zero milliseconds. It expected one. The existing sibling test waits for the recorder callback before inspecting the queue. Earlier callback fix
  • The pagination test started a background writer before counting its starting rows. That count included one of the 75 new rows. It observed 2,075 rows and expected 2,076.

The PR leaves both fixtures unchanged. The coordinator approved one retry of failed jobs on the same head. If either test fails again, its synchronization needs correction while preserving the ownership and row-count assertions.

@abrichr
abrichr merged commit 4d9dc90 into main Nov 21, 2026
113 of 124 checks passed
@abrichr
abrichr deleted the agent/2309 branch November 21, 2026 04:04
abrichr added a commit that referenced this pull request Nov 21, 2026
abrichr added a commit that referenced this pull request Nov 21, 2026
yunusarda-sudo pushed a commit to yunusarda-sudo/OpenAdapt that referenced this pull request Nov 22, 2026
Raise the privacy extra's floor to openadapt-privacy[presidio]>=1.1.4, which
has sanitization_config(); restore the dated v3.4.0 heading; note the Flow
changes merged since the cut (OpenAdaptAI#2379, OpenAdaptAI#2392, OpenAdaptAI#2313, OpenAdaptAI#2369).
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.

Bind native keyboard delivery to recorded focus and a one-shot lease

1 participant