refactor(daemon): consolidate post-gesture surface-evidence helpers and their rationale - #1615
refactor(daemon): consolidate post-gesture surface-evidence helpers and their rationale#1615thymikee wants to merge 1 commit into
Conversation
Size Report
Startup median (7 runs, lower is better):
Top changed chunks:
|
|
Code review is clean on |
2401d28 to
d20d2da
Compare
|
Live evidence attempt at rebased head I could not produce the warning, and I do not think that is a reproduction problem. Reporting the mechanism rather than presenting a near-miss as evidence. Tried five no-effect gestures across two screens:
Every one reported Two things in that output each independently veto the claim, both by design:
So the gate is working exactly as #1601 specified — silence as the safe failure mode. The consequence is the uncomfortable part: the warning appears unreachable on precisely the screen class #1600 was built for. #1600's motivating case was element-18 burning ~40 tool calls re-issuing scrolls on a Bluesky feed, and a Bluesky feed is hostile enough to capture that the corroboration can never be satisfied. I did not isolate which of the two vetoes dominates — that needs the per-capture backend and signature sets, not just the rendered warning. Filing separately rather than expanding this PR. What this means for this PR: nothing in it changes when the warning fires. It consolidates helpers, types 🤖 Addressed by Claude Code |
|
Re-review at |
|
Status update for |
Thermo-nuclear code-quality review @
|
…e code Review on #1615, all non-blocking; applied rather than deferred because three of the four remove lines. 1. Named the capture-strategy union. `SnapshotCaptureBackend` now lives in kernel/snapshot beside `SnapshotBackend`, and `SnapshotQualityVerdict` uses it. The two docblocks whose only job was saying what the type is NOT (11 lines in types.ts, 4 on CapturedSurface) collapse to the load-bearing #1569 comparability warning. 2. Trimmed comment mass. The key-vs-identity rationale said one thing three times over 20 lines; it says it once. `rectsWithinTolerance` no longer names its callers — that roster drifts the first time a fourth lands. The test comment restating the (now deleted) docblock is gone; the test name carries it. That also fixes a drift already present: the removed docblock claimed `gesture <subtype> …` reaches the warning by default, when `isPostGestureStabilizingAction` only admits `gesture swipe`. 3. Deleted the scroll exception, the numeric heuristic's last vestige. `describeGesturePositionals` and its 17-line docblock existed to suppress one token (`scroll down 0.6` -> "scroll down"). Positionals now echo verbatim: the warning names the gesture the agent issued, and `scroll down 0.6` is what they issued. Helper, docblock and exception all go; one test assertion updates. 4. `PostGestureStabilization.positionals` is required. Its only writer always sets it, so `pending.positionals ?? []` guarded an impossible state. Tightening it caught five test fixtures constructing the state without the field — the type doing its job. 93 files / 733 tests green; typecheck, lint, format, check:layering clean.
d20d2da to
5731692
Compare
|
All four findings applied at 1. Named the union. 2. Comment mass — and the drift was real. Key-vs-identity now states its point once. 3. Deleted the scroll exception. Took the deletion. Your framing settled it: the warning names the gesture the agent issued, and 4. Measured effect on your headline concern: net diff went from +42 to +4 lines. Also rebased onto Gates: 93 files / 733 tests on the touched suites, typecheck / lint / format / Still draft, still blocked on the same live capture, which #1622 is upstream of. 🤖 Addressed by Claude Code |
|
Re-reviewed exact head Readiness remains blocked by the previously requested live proof. #1622 is the behavioral prerequisite (not a compile dependency): it rebases corroboration onto a comparable fallback baseline for the hostile screen where current backend flips/truncation correctly silence the no-effect claim. Merge #1622 first, rebase #1615 onto it—both touch |
|
Correcting my earlier comment on this PR. I wrote that the no-effect warning "appears unreachable on precisely the screen class #1600 was built for", and named a backend flip breaking corroboration as one of two causes. That reading was wrong.
Nothing in this PR depends on that reading — it consolidates helpers, types the capture-strategy union, relocates a docblock and deletes the numeric-token heuristic. But the comment is on this thread and was steering the live-evidence discussion, so it should not stand uncorrected. Rebase status: this branch is now behind Re-deriving now. 🤖 Addressed by Claude Code |
…rding heuristic Re-derived onto #1633's split (`post-gesture-stabilization.ts` became `post-gesture-stability.ts` + `deferred-interaction-outcome.ts` + `gesture-no-effect.ts`). None of this had been subsumed by that refactor — it relocated the code and carried every one of these forward untouched. - Three copies of the four-field rect comparison in `interaction-outcome-policy.ts` become one `rectsWithinTolerance`. - `identifiedContent` returns the entry instead of `{ entry }`, dropping the `.entry` indirection at every call site. - `haveIdenticalDiscriminatingSurfaces` records why it keys on `key` while `classifyBaselineSurfaceEvidence` keys on `identity` — opposite choices, once, at the function that makes the stricter one. - `SnapshotCaptureBackend` names the capture-strategy union in kernel/snapshot beside `SnapshotBackend`, and `PostGestureStabilization.baselineBackend` uses it instead of `string`, closing the silent-typo gap on the comparison the field exists for. Deliberately NOT applied to `post-gesture-stability.ts`: #1633 made that module generic over the surface type, and `backend: string` is right for an interface that must not know about iOS capture strategies. - `formatGestureNoEffectWarning` echoes positionals verbatim. The `/^[\d.-]+$/` filter it replaces ate all four coordinates of `swipe <x1> <y1> <x2> <y2>` and emitted a contentless bare "swipe"; the warning names the gesture the agent issued, and `scroll down 1` is what they issued. - `PostGestureStabilization.positionals` is required — its only writer always sets it, so the `?? []` at the read site guarded an impossible state. Tightening it caught six test fixtures building the state directly. Red evidence: restoring the numeric filter fails the wording test ("scroll down 1 produced no visible change"); 95 files / 757 tests green with it deleted.
5731692 to
9b902d4
Compare
|
Re-derived onto #1633 subsumed none of it. It relocated One finding deliberately narrowed in the move. #1633 made Net is +23 rather than the +4 I reported pre-rebase: the comment trimming was against text that no longer exists, and shrinking #1633's prose is not this PR's business.
Red evidence re-established on the new layout: restoring the numeric filter fails the wording test ( Gate disclosure. 🤖 Addressed by Claude Code |
|
Enumerating the heuristic deletion's full output delta, since "the test pins the new wording" is not the same as "nothing else changed". The concern worth checking is whether the old filter ever rewrote a token rather than merely dropping one — deletion would then change more outputs than the single case the test covers. It cannot: the two expressions are identical but for Enumerated over every shape The 15 additions are exactly what the filter used to eat: Every one is a token appearing where it previously vanished; none is a token changed. So the deletion's blast radius is fully characterised, and the flag-forced actions — which nobody had enumerated, since they only reach the warning via 🤖 Addressed by Claude Code |
|
Re-reviewed exact head Not ready yet: exact-head live evidence for the changed device-facing warning path is absent. Show a proven no-effect coordinate swipe whose next response includes the full gesture and then a successful subsequent command. Also refresh the PR body: it still describes the old file layout, two-commit sequence/test count, and a fallback the current one-commit head removes. Completed checks are green; Swift Runner Unit Compile remains queued. No code blocker or conflict found. |
refactor(daemon): drop the numeric-token heuristic instead of wrapping it
The previous commit replaced
formatGestureNoEffectWarning's"drop numeric-looking positionals" regex with a per-action builder table —
but kept the regex as the table's fallback. That is two mechanisms where
there was one, and the heuristic this finding exists to remove is still
in the file.
Only
scroll,swipeandgesture <subtype> …reach the warning bydefault (
isPostGestureStabilizingAction), and across all three exactlyone positional is not part of the gesture's identity:
scroll's optionaltrailing amount. Echoing everything else verbatim is simpler than either
version and strictly more truthful than the original, which ate all four
coordinates of
swipe <x1> <y1> <x2> <y2>and reported a contentlessbare "swipe".
scroll down 0.6 -> "scroll down"
scroll up -> "scroll up"
swipe 10 20 30 40 -> "swipe 10 20 30 40" (was: "swipe")
swipe -> "swipe"
gesture swipe left -> "gesture swipe left"
gesture fling down 100 200 -> "gesture fling down 100 200"
35 lines of table, dispatch and regex become 4 lines with one named
exception.
--postGestureStabilizationcan still force an arbitraryaction through; echoing its positionals is the honest answer for one
warning string, and reconstructing each gesture subtype's layout would
fork a grammar that lives in GestureSemanticInput, downstream of the raw
positionals this function receives.
refactor(daemon): consolidate post-gesture surface-evidence helpers and their rationale
Six findings against interaction-outcome-policy.ts and post-gesture-stabilization.ts,
all behavior-preserving except the gesture-warning wording:
classifyBaselineSurfaceEvidence, and haveIdenticalDiscriminatingSurfaces instead
of three copies of the same four-field comparison.
.entry indirection at every call site.
key(not
identity, the opposite of interactionSurfaceIdentity's own conclusion):it runs only after classifyBaselineSurfaceEvidence already accepted
'unchanged', exists solely to gate an agent-facing no-effect claim, and a
stricter key trades recall for precision — the safe direction for a veto.
(intersection rect-deltas) to a short pointer at classifyBaselineSurfaceEvidence,
which already owns the current (post-fix(daemon): judge post-gesture movement by identity, not by the intersection #1573) evidence rule.
SnapshotQualityVerdict['backend'] instead of bare string, closing the silent-typo
gap in the backend-rebase equality check.
fixed positional grammar for scroll/swipe; gesture keeps a narrower fallback
since its per-subtype shape isn't uniform.
Gates: typecheck / lint / format /
check:layeringgreen; 30 unit tests in the touched files pass.Reviewer note: the second commit reworks the first. The initial pass replaced
formatGestureNoEffectWarning's numeric-token regex with a per-action builder table but kept the regex as that table's fallback — two mechanisms where there was one, with the heuristic still present. It is now one named exception (scroll's trailing amount) and no heuristic, which also fixes the real defect the table found: the old rule ate all four coordinates ofswipe <x1> <y1> <x2> <y2>and emitted a contentless bare "swipe".Local gate note.
pnpm check:affected --runis flaky on a loaded dev host. Across six runs on three branches — plus a reproduction on unmodifiedorigin/mainby a parallel agent — failures came only from the poolandroid-lifecycle/android-recording/doctor/input-actions/daemon-client, always as timeouts, with a different subset each run. All pass in isolation (verified for this branch). Please treat the CI Integration Tests job on this head as authoritative forprovider-integration, per AGENTS.md ("GitHub remains authoritative for reported device/toolchain lanes").