Repository navigation
ci(ratchet): size budgets never rise; dropping the row of an existing file fails - #2430
Conversation
Independent adversarial review: REQUEST CHANGESFrom: Grok First review of this PR. Author is GitHub The path-keyed part of the founder rule is implemented and tested. With A rename can still raise a limit. Budgets and the raise check are keyed only by path. |
Independent adversarial review: APPROVEFrom: Grok Delta review after my REQUEST CHANGES at
|
Budgets no longer rise (#2430). The environment-secret lookup for a secret TYPE step moves from the replayer into secret_inputs.step_secret_text, so the one-time code branch adds no lines. ir.Step's serializer drops unset optional fields in one loop, and the one_time validator is bound beside its field. The replayer imports runtime_value itself rather than the second_factor module, so runtime/__init__'s lazy Replayer export is no new import-layer debt site. replayer.py budget lowered to 19224.
* feat(flow): wait for a person at a sign-in's second factor A step marked one_time (code or approval) asks the configured source when it runs: the runner's control plane (the code sealed in the person's browser to a one-step P-256 key) or a local command. The code is typed once and kept nowhere. No source, no answer in time, a decline or a malformed answer stops the step before typing with a closed second_factor_* code. The wrap recorder turns an autocomplete=one-time-code field into such a step. * test(flow): pin the dashboard seal vector shared with Cloud * refactor(flow): keep second-factor shape checks out of the budgeted modules Raises the replayer budget by 7 lines and ir.py by 3 for the two hooks and the Step field; lowers playwright_backend.py to its new size. * fix(flow): give a cached run's MCP child the run token with the control-plane URL * refactor(flow): keep ir.py and replayer.py within their size budgets Budgets no longer rise (#2430). The environment-secret lookup for a secret TYPE step moves from the replayer into secret_inputs.step_secret_text, so the one-time code branch adds no lines. ir.Step's serializer drops unset optional fields in one loop, and the one_time validator is bound beside its field. The replayer imports runtime_value itself rather than the second_factor module, so runtime/__init__'s lazy Replayer export is no new import-layer debt site. replayer.py budget lowered to 19224. * fix(flow): bind, mask and type a second factor once, as its own action The Codex review at fddab5f found ten ways the one-time-code path could leak a code, type it twice, type it into the wrong field or be skipped. They share causes, so this replaces the per-path hooks with one handoff that the recorder and the replayer both run (openadapt_flow/runtime/second_factor_step.py): - claim the step for this run before asking (a retry or loop never asks or types again); - bind the focused element, which must be an empty autocomplete="one-time-code" input, and make the page draw it as dots (openadapt_flow/backends/one_time_field.py), so no screenshot, gate frame, transition frame or model image shows the code; - ask the source, with the deadline checked again when the answer arrives, for every source; - re-check, just before typing, that the same element still has focus, is empty and is masked; - type once through the bound element handle, never retried; - read back the length only, and halt as second_factor_unverified when it does not match. The step is now its own action, ActionKind.SECOND_FACTOR, with one_time naming code or approval. An older runtime refuses the bundle (checked against origin/main's ir.py for both kinds) instead of skipping an approval or typing an environment value. The step validator refuses any field outside a short allow-list, so an API binding, effects, an anchor, text or a param cannot route around the person. Also: - the compile agent's page listing withholds the value of one-time-code and password fields; - a code-only form's submit counts as a sign-in only right after a username-and-password sign-in; - normalize_code refuses an answer with an internal line break; - source_env forwards the run token only with the control-plane URL; - _call_skill passes the current stderr to the MCP stdio client, whose default can be a stream closed since mcp was imported (the cause of the order-dependent cached_tool_result failure in the wrap e2e); - the changelog entry moves under Unreleased, the ir schema snapshot is regenerated, and replayer.py's budget is lowered to 19219. * fix(flow): fill a code only into a field that holds it, and arm the code-only sign-in once - The code is filled into the bound element instead of typed key by key, so no character can reach another field (a dialog that took focus, or the next box of an auto-advancing field). - A field that takes fewer than 4 characters is refused before anyone is asked, and one shorter than the code is refused before typing: one box per character would spill the code into unbound, unmasked boxes. - Only text, tel, password and search inputs count as code fields, since only they draw -webkit-text-security; number, date and email inputs are refused. The headless pixel test now runs for each allowed type. - A code-only form's submit is exempt from the submit escalation once, right after a username-and-password sign-in, with at most the focusing click between them. A second code page, or browsing first, keeps the escalation. - docs/SECOND_FACTOR.md states the limits: only the local browser backend takes a code, split-box fields are refused, and a self-submitting code page is completed, not VERIFIED, under strict evidence. * fix(flow): keep the heartbeat going while a second-factor command waits CommandSource ran the command with subprocess.run, which blocked for the whole timeout after one heartbeat, so a supervisor that ends silent runs could end one waiting for a person (Gemini at 907fba3). The command now runs under Popen and is waited for in heartbeat-sized slices; on the deadline it is killed and the step stops before typing, as before.
…al (#2368) * feat(flow): wait for a person at a sign-in's second factor A step marked one_time (code or approval) asks the configured source when it runs: the runner's control plane (the code sealed in the person's browser to a one-step P-256 key) or a local command. The code is typed once and kept nowhere. No source, no answer in time, a decline or a malformed answer stops the step before typing with a closed second_factor_* code. The wrap recorder turns an autocomplete=one-time-code field into such a step. * test(flow): pin the dashboard seal vector shared with Cloud * refactor(flow): keep second-factor shape checks out of the budgeted modules Raises the replayer budget by 7 lines and ir.py by 3 for the two hooks and the Step field; lowers playwright_backend.py to its new size. * fix(flow): give a cached run's MCP child the run token with the control-plane URL * feat(flow): ask for a sign-in's second factor at the run's own terminal An interactive run with no other source asks at its terminal (no echo for a code, the same timeout). A run without a terminal never prompts and stops before typing, as before. * refactor(flow): keep ir.py and replayer.py within their size budgets Budgets no longer rise (#2430). The environment-secret lookup for a secret TYPE step moves from the replayer into secret_inputs.step_secret_text, so the one-time code branch adds no lines. ir.Step's serializer drops unset optional fields in one loop, and the one_time validator is bound beside its field. The replayer imports runtime_value itself rather than the second_factor module, so runtime/__init__'s lazy Replayer export is no new import-layer debt site. replayer.py budget lowered to 19224. * fix(flow): bind, mask and type a second factor once, as its own action The Codex review at fddab5f found ten ways the one-time-code path could leak a code, type it twice, type it into the wrong field or be skipped. They share causes, so this replaces the per-path hooks with one handoff that the recorder and the replayer both run (openadapt_flow/runtime/second_factor_step.py): - claim the step for this run before asking (a retry or loop never asks or types again); - bind the focused element, which must be an empty autocomplete="one-time-code" input, and make the page draw it as dots (openadapt_flow/backends/one_time_field.py), so no screenshot, gate frame, transition frame or model image shows the code; - ask the source, with the deadline checked again when the answer arrives, for every source; - re-check, just before typing, that the same element still has focus, is empty and is masked; - type once through the bound element handle, never retried; - read back the length only, and halt as second_factor_unverified when it does not match. The step is now its own action, ActionKind.SECOND_FACTOR, with one_time naming code or approval. An older runtime refuses the bundle (checked against origin/main's ir.py for both kinds) instead of skipping an approval or typing an environment value. The step validator refuses any field outside a short allow-list, so an API binding, effects, an anchor, text or a param cannot route around the person. Also: - the compile agent's page listing withholds the value of one-time-code and password fields; - a code-only form's submit counts as a sign-in only right after a username-and-password sign-in; - normalize_code refuses an answer with an internal line break; - source_env forwards the run token only with the control-plane URL; - _call_skill passes the current stderr to the MCP stdio client, whose default can be a stream closed since mcp was imported (the cause of the order-dependent cached_tool_result failure in the wrap e2e); - the changelog entry moves under Unreleased, the ir schema snapshot is regenerated, and replayer.py's budget is lowered to 19219. * fix(flow): fill a code only into a field that holds it, and arm the code-only sign-in once - The code is filled into the bound element instead of typed key by key, so no character can reach another field (a dialog that took focus, or the next box of an auto-advancing field). - A field that takes fewer than 4 characters is refused before anyone is asked, and one shorter than the code is refused before typing: one box per character would spill the code into unbound, unmasked boxes. - Only text, tel, password and search inputs count as code fields, since only they draw -webkit-text-security; number, date and email inputs are refused. The headless pixel test now runs for each allowed type. - A code-only form's submit is exempt from the submit escalation once, right after a username-and-password sign-in, with at most the focusing click between them. A second code page, or browsing first, keeps the escalation. - docs/SECOND_FACTOR.md states the limits: only the local browser backend takes a code, split-box fields are refused, and a self-submitting code page is completed, not VERIFIED, under strict evidence. * fix(flow): keep the heartbeat going while a second-factor command waits CommandSource ran the command with subprocess.run, which blocked for the whole timeout after one heartbeat, so a supervisor that ends silent runs could end one waiting for a person (Gemini at 907fba3). The command now runs under Popen and is waited for in heartbeat-sized slices; on the deadline it is killed and the step stops before typing, as before. * fix(flow): discard input the terminal read did not take A timeout, an over-long answer or an interrupt left the person's partial input in the terminal queue; with echo back on, the shell would read and show it after the run (Gemini at 4374127). The read now flushes pending input in finally, before echo is restored. A pty test types part of a code, lets the prompt time out and checks nothing is left to read. * feat(flow): ask for the second factor at a Windows console too The terminal prompt was POSIX-only, so a Windows laptop with no control plane or command source stopped at the code step. One line reader now serves both platforms over a small Console interface: - PosixConsole: echo off for a code, select on the descriptor (as before). - WindowsConsole: msvcrt.getwch reads one key at a time and never echoes; kbhit is polled in short slices under the step's deadline. Either way the read runs in the calling thread, keys typed before the prompt are discarded, and in finally the keys the read did not take are discarded and normal input restored, whatever ended the read (an answer, the deadline, Ctrl-C, an over-long answer or a failed read). Function and arrow keys are skipped; backspace edits the line. tests/test_second_factor_console.py drives WindowsConsole with an injected kbhit, getwch and sleep on a fake clock, so the deadline and discard logic runs on every platform; one test uses the real msvcrt and runs only on Windows. * fix(flow): keep the Windows console reader on the clock and off POSIX input Gemini at eb05728: - The \x00/\xe0 function-key prefix is skipped only on the Windows console (Console.prefixed_keys). A POSIX terminal keeps U+00E0 and the character after it; a pty test reads "àn" whole. - WindowsConsole.wait measures on a monotonic clock, so a sleep that oversleeps can't stretch the deadline; a test oversleeps threefold. - Ending a Windows read drops keys for up to half a second instead of 1,024 keys, so a long paste is dropped whole; a test pastes 5,000. - PosixConsole decodes with an incremental UTF-8 decoder, so a character split across two reads stays whole.
This PR enforces the founder's decision on the monorepo refactor plan (openadapt-internal#277, decision 3, approved 2026-11-21): feature PRs never raise size budgets, and new code goes into new modules.
What changes
scripts/check_file_size_ratchet.py, with--base(the PR and merge-queue mode), now fails when a change:packages/flow/docs/design/DECOMPOSITION.md; orThese still work as before:
The over-budget message now says to put the new code in a new module and keep only the call site. The
DECOMPOSITION.mdsection 6 rule is updated to match; the notes about earlier raises stay as history.Four new tests cover raising, lowering, dropping a row of an existing file, and dropping the row of a removed file. All 26 ratchet tests pass, and the check passes on main.
Effect on open PRs
I merged each open PR that edits the budget table onto this branch (
git merge-tree) and ran the check:__main__.pyfrom 14,331 to 14,348, so it would now fail. It needs to move those 17 lines into a module.replayer.pyandir.py. They already conflict with main on the table, and will hit this rule when they resolve the conflict.__main__.py, so they are unaffected apart from their existing conflicts with main.