LearnNewsExamplesConnect
Frontmatter
assigneesneo-gpt-euclid
createdAtAug 27, 2026, 11:12 PM
updatedAtAug 30, 2026, 12:09 AM
githubUrlhttps://github.com/neomjs/neo/issues/17821
authorneo-gpt-euclid
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[x] 204 Expose a verified drag gesture through Neural Link
closedAtAug 30, 2026, 12:09 AM

Add atomic drag execution to the Neural Link client

Closed v13.2.0/archive-v13-2-0-chunk-16 enhancementaitestingcore
neo-gpt-euclid
neo-gpt-euclid commented on Aug 27, 2026, 11:12 PM

Context

A live Neural Link attempt to exercise a Neo splitter exposed a tooling gap: the raw event channel can dispatch the necessary mouse events, but the caller must reconstruct Neo's complete drag-arming recipe and cannot tell whether the gesture actually armed.

Live source verification on Engine dev found:

  • src/ai/client/InteractionService.mjs#simulateEvent() preserves event order and delays, but discards every Boolean returned by dispatch() and returns true after the loop.
  • src/main/addon/EventSimulator.mjs#dispatch() returns false when the DOM target is absent or event construction/dispatch fails.
  • src/main/draggable/sensor/Mouse.mjs owns the physical gesture contract: the live delay and minimum-distance thresholds, drag:start, drag:move, drag:end, and lost-release cleanup.
  • Four tracked Engine consumers currently spell out mousedown / delayed mousemove / mouseup recipes themselves: Workstation, the cross-window dashboard example, and two whitebox journeys.

The history is consistent. Engine issue 12884 explicitly left a simulateDrag convenience primitive out of scope. Engine issue 12807 established the raw Mouse-sensor recipe without adding that primitive. Engine issue 14772 later proved a real cross-window gesture through simulateEvent, but embedded the choreography in a product consumer. Engine issue 16365 demonstrated why event arrival is not equivalent to an armed drag.

The Problem

simulate_event is a useful low-level escape hatch, not a gesture transaction:

  1. callers duplicate sensor timing, movement thresholds, coordinate conversion, and cleanup;
  2. a successful RPC can mean only that the loop completed—even when one event returned false;
  3. dispatch success does not prove that Neo emitted drag:start, processed movement, or reached drag:end;
  4. putting those browser and sensor semantics into the Brain-side MCP service would reverse the repository boundary and make the server duplicate Engine truth.

The missing Engine capability is one atomic, truthful drag execution primitive that the Brain can expose without knowing DOM or sensor internals.

The Architectural Reality

  • Engine owns both execution realms, with a strict split inside the Body: App-worker InteractionService owns JSON-contract validation plus live cross-window geometry; source-window Main EventSimulator owns the one atomic native transaction.
  • Every synthetic event dispatches in the source Main realm. Destination/waypoint windows provide geometry only. App resolves target-local BCR anchors through each target window, converts them to global screen points through WindowManager.innerRect, then derives the source-event clientX/Y separately.
  • DragDrop already creates the one live Mouse sensor per Main realm but discards its handle. It must retain/expose that exact instance so execution reads current per-instance delay / minDistance values; class defaults are not runtime authority.
  • Mouse remains the gesture state machine. The executor drives mousedown / mousemove / mouseup; it never calls startDrag() or endGesture() on the success path.
  • Lifecycle proof belongs in source Main: document listeners correlate drag:start, drag:move, and drag:end to the exact native MouseEvent objects constructed by this transaction. Counting an unrelated concurrent drag is forbidden.
  • The JSON-RPC contract returns a typed success/failure result envelope. Current Engine and Brain error paths discard custom error data, so a thrown Error cannot honestly carry a partial receipt. Brain #204 owns conversion of success:false into an MCP tool error.
  • Existing simulate_event remains the raw escape hatch. It executes the full caller-supplied sequence and accumulates dispatch success; it must never return early and skip a later cleanup event.
  • No new production .mjs placement is required: extend the existing Client, InteractionService, EventSimulator, DragDrop, and existing test surfaces.

The Fix

Add InteractionService#driveDrag(), register Engine RPC drive_drag, and extend the existing Main-thread owners without creating a second drag engine.

The request is JSON-first:

{
    source: {
        targetId: 'required DOM id',
        windowId: 'required source window id',
        anchor  : {x: 0.5, y: 0.5} // optional normalized point, each axis in [0,1]
    },
    destination: {
        // Exactly one mode:
        targetId: 'target DOM id', windowId: 'target window id', anchor: {x: 0.5, y: 0.5}
        // OR target-local point; screen coordinates are derived, never caller-competed:
        windowId: 'target window id', clientX: 240, clientY: 180
        // OR source-relative delta:
        deltaX: 120, deltaY: 0
    },
    waypoints : [], // optional node or target-local point descriptors; no delta waypoints
    steps     : 8,  // post-arm traversal moves across the WHOLE polyline; integer 1..120
    durationMs: 160 // post-arm traversal duration; >= steps * 16 and <= 30000
}

When durationMs is omitted, Engine derives max(160, steps * 20). This duration begins after arming. Source Main always waits the live Mouse-sensor delay, then dispatches one separate arming move beyond the live minimum distance. The requested path must itself reach that threshold; a short path fails at arming rather than silently overshooting into another drop zone. The threshold-crossing move emits drag:start; steps counts later post-arm moves, so at least one observed drag:move remains possible.

InteractionService resolves every node/point immediately before the call:

  1. node anchors use DomAccess#getBoundingClientRect in that node's own window;
  2. target-local client coordinates plus that window's live innerRect produce the canonical screen point;
  3. screen point minus the source window's innerRect produces the MouseEvent's source-realm clientX/Y;
  4. absent live windows, inner rects, zero/non-finite BCRs, ambiguous modes, and inconsistent values fail at resolution.

It then sends one remote EventSimulator.driveDrag() call to source.windowId. Mousedown targets the source node. Every later move, terminal up, and best-effort cleanup up dispatches on document.body in the source window so source-node replacement cannot strand the Mouse sensor.

Main refuses a second executor while one transaction is active or the live Mouse sensor is already engaged. It correlates lifecycle events by event.detail.originalEvent identity against the native events this transaction constructed.

Every RPC returns one envelope. Success:

{
    success: true,
    phase  : 'complete',
    sensor : {delayMs, minDistance},
    dispatch: {down: true, moveCount: 9, up: true},
    observed: {started: true, moveCount: 8, ended: true},
    released: true, // means correlated drag:end observed
    cleanup : {attempted: false, succeeded: true},
    source,
    destination
}

Failure returns the same receipt fields with success:false, one exact phase (resolution|busy|arming|dispatch|movement|release|cleanup), and error:{code,message}. dispatch.moveCount counts raw synthetic moves; observed.moveCount counts correlated drag:move lifecycle events. Cleanup cannot turn a failed phase into green.

simulateEvent() keeps its Boolean API but executes every event in order, including delays and cleanup events, and returns true only when every delegated dispatch returned true.

The Engine test fixture gains a test-only app.driveDrag(request) wrapper which calls the raw Engine RPC through the existing Neural Link connection. It does not wait for Brain #204's public MCP service. The public Whitebox E2E guide gains the narrow distinction: simulateEvent remains raw sequence control, driveDrag owns complete atomic gestures, and page.mouse remains the right tool when a test must hold or intervene mid-gesture.

Contract Ledger

Target Surface Source of Authority Proposed Behavior Fallback / Edge Case Docs Evidence
New Engine RPC drive_drag This ticket Route one validated request to existing InteractionService; return typed success/failure envelope Unknown before this Engine change; no compatibility alias Client + service JSDoc Client routing unit
InteractionService#driveDrag() This ticket; owning Main realm live Neo.Main.getWindowData; WindowManager.calculateGeometry; DomAccess#getBoundingClientRect Validate discriminated request, resolve node/point/delta geometry, derive target-local/global/source-event coordinates, issue one source-window Main call resolution failure envelope for ambiguity, absent geometry, non-finite/zero BCR, invalid anchor/bounds JSDoc Pure geometry/mode units + same/cross-window witness
EventSimulator#driveDrag() Existing EventSimulator + Mouse lifecycle Source-Main atomic pacing, correlated lifecycle observation, stable body dispatch after down, exact cleanup `busy arming dispatch
Live Mouse sensor authority DragDrop creates the instance; Mouse reactive configs DragDrop retains/exposes the exact instance; drive reads live delay / minDistance Fail busy/unavailable; never copy current literals JSDoc Changed-threshold positive control
Coordinate spaces Owning Main realm live Neo.Main.getWindowData + WindowManager.calculateGeometry + BCR Destination node/point is target-local; Engine derives screen point and source-event client point; all events route to source Main Missing target/source window geometry fails; caller supplies no competing screen authority JSDoc Same-window + cross-window coordinates
Gesture receipt Correlated source-document drag:* events Separate dispatch and observed counts; released means correlated drag:end; no semantic app outcome Typed success:false result with partial receipt and cleanup status JSDoc Never-arm, missing-target, foreign-event, missing-terminal controls
Existing simulateEvent() Existing Boolean/raw-sequence contract Preserve full ordered sequence; aggregate all dispatch results Return false after the sequence if any dispatch failed; never skip later cleanup Existing JSDoc Mixed-success sequence including terminal mouseup
Engine whitebox fixture test/playwright/fixtures.mjs existing raw-call wrapper Add test-only app.driveDrag(request) over Engine RPC before Brain #204 lands Missing Engine method fails; no hand-built fallback Fixture JSDoc Same-window + cross-window whitebox
Whitebox guide learn/guides/testing/WhiteboxE2E.md current drag guidance Distinguish raw sequence, atomic whole gesture, and held/mid-gesture page.mouse use cases No claim that atomic drive replaces physical held controls Guide Link + source review
Brain consumer neo-agent-brain#204 Brain forwards request and converts Engine success:false into an MCP tool error without reimplementing gesture semantics Missing method fails clearly; no raw-event fallback Brain OpenAPI/JSDoc Cross-repo integration after Engine merge

Decision Record impact

aligned-with ADR 0020 §3 — Neural Link remains the Brain/Body bridge; browser interaction semantics stay Engine-side.

Acceptance Criteria

  • drive_drag is registered in the Engine client and accepts the exact source plus discriminated node / target-local-point / source-delta contract above; anchors, bounds, finite coordinates, and one-mode-only rules fail closed.
  • InteractionService resolves BCR/window geometry immediately before execution, derives target-local → screen → source-event coordinates, and sends one atomic call to source Main. Destination window ids never route events.
  • DragDrop retains/exposes the exact live Mouse sensor instance; the executor reads its current delay/minDistance, and a changed-threshold positive control proves no copied literals.
  • Source Main dispatches mousedown on the source node, a separate live-threshold arming move, all post-arm moves and release on document.body, with steps total across the whole polyline and duration applying only post-arm.
  • Success requires correlated drag:start, at least one correlated drag:move, and correlated drag:end; unrelated document drags cannot satisfy the receipt.
  • Receipt separates raw dispatch counts from observed lifecycle counts, includes live sensor values and resolved coordinate spaces, and claims no splitter/grid/dock semantic result.
  • Missing target/geometry, busy sensor, short path, failed dispatch, never-armed sensor, absent move, missing terminal, or failed cleanup returns success:false with the exact phase, partial receipt, and cleanup status.
  • A source node removed after arming does not block later moves/release because the stable document-body carrier owns them.
  • simulateEvent() preserves its Boolean surface, runs the full supplied sequence, and returns false when any dispatch failed; a mixed-success test proves a later mouseup still runs.
  • Focused units cover request modes/geometry, sensor authority, lifecycle correlation, concurrency, path scheduling, cleanup, and Client routing.
  • The Engine whitebox fixture exposes raw app.driveDrag(request) routing without depending on Brain #204 or duplicating the gesture recipe.
  • A live same-window Splitter witness proves physical actuation and a separate width/commit postcondition; a two-window Neural Link witness proves target-local → screen → source-event coordinate routing without coupling to dock-transfer semantics.
  • learn/guides/testing/WhiteboxE2E.md documents simulateEvent (raw), driveDrag (whole atomic gesture), and page.mouse (held/mid-gesture intervention) without claiming one replaces the others.
  • Brain #204 remains blocked until this Engine contract merges; it consumes the typed failure envelope and owns MCP error conversion.

Out of Scope

  • The Brain MCP/OpenAPI tool; that is a separate neo-agent-brain ticket blocked on this Engine capability.
  • DockLayouts architecture, reducer changes, splitter feature work, grid behavior, or any semantic drag outcome.
  • Migrating every existing manual recipe in the same PR; one reference witness is enough. Follow-up consumer cleanup must be independently justified.
  • Touch/pen gestures, arbitrary pointer-device abstraction, replay ledgers, new diagnostics, or a second drag engine.
  • Removing or deprecating simulate_event.

Avoided Traps

  • App-worker event loop called atomic: rejected; App resolves geometry, source Main executes/observes the one transaction.
  • Destination-window dispatch: rejected; the source Mouse sensor owns the whole gesture. Destination windows are geometry authorities only.
  • Competing client/screen inputs: rejected; target-local coordinates derive one screen point and one source-event client point.
  • Brain-side timing constants: rejected; the retained live Mouse instance owns arming thresholds.
  • Arming move counted as drag:move: rejected; threshold crossing installs the move listener only afterward.
  • Fail-fast simulateEvent: rejected; it can skip a caller-supplied mouseup and wedge the sensor.
  • Thrown custom Error receipt: rejected; current cross-worker/JSON-RPC layers drop custom data. Engine returns a typed failure envelope; Brain converts it.
  • Semantic-operation substitution: rejected because reducers cannot falsify pointer arming, movement, hit-testing, or release.
  • Bulk caller refactor: rejected to keep this one Engine primitive and one reference witness.

Related

Live latest-open sweep: checked the latest 20 open issues in both Engine and Brain plus exact drive_drag / verified-drag / simulateDrag / drag-gesture searches at 2026-08-27T21:12:11Z; no equivalent found. A2A all-status recency sweep: 30 messages; no competing Neural Link drag claim.

Origin Session ID: db682c7c-7b7a-4e42-8374-71944a42db40

Retrieval Hint: "Neural Link drive_drag atomic Engine InteractionService truthful drag receipt Mouse sensor arming"

tobiu referenced in commit 0661b02 - "feat(neural-link): add atomic drag transactions (#17821)" on Aug 29, 2026, 10:51 PM
tobiu referenced in commit c385f35 - "feat(neural-link): add atomic drag transactions (#17821) (#17862)" on Aug 30, 2026, 12:09 AM
tobiu closed this issue on Aug 30, 2026, 12:09 AM