Add typed field-flight prototype and preserve native qualification failures

This commit is contained in:
2026-09-19 21:01:20 +02:00
parent 83ea247e62
commit 61e165ef5b
91 changed files with 40570 additions and 85 deletions
+12 -9
View File
@@ -16,7 +16,8 @@ Adapter contract (all records must be parsed from the same pinned console/nonce)
* guard.check() is the existing full private ownership/focus guard. keyboard has
require_idle()/send('W', bool). mouse.move(dx,0,guard) must use the same guarded
connection and current/projected clipped pointer checks, explicitly permitting
this variant's <=128px cap. Existing two-motion helper remains unchanged.
the explicitly selected standard128px or coarse384px cap. Existing two-motion
helper remains unchanged; profile choice never changes the observation clocks.
* notify receives the existing press-pending/release-confirmed events, plus
approach-pending (absolute monotonic deadline)/approach-finished. The wiring
MUST hard-supervise that deadline and the unchanged 1.5-second key lease.
@@ -91,8 +92,10 @@ def inside(position, center):
return abs(position[0]-center[0]) <= 5.25 and abs(position[2]-center[2]) <= 5.25
def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, report, *, clock, sleep, notify, key_state_busy):
def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, report, *, clock, sleep, notify, key_state_busy, profile="standard"):
"""Run one bounded route through explicit adapters; retain partial failure evidence."""
require(profile in ('standard', 'coarse') and type(profile) is str, 'Unknown approach profile')
max_pixels, max_angle, desired_angle, max_pulses = (384, 35, 25, 16) if profile == 'coarse' else (128, 15, 10, 12)
require('approach_proof' not in report, 'Approach attempt already exists')
pinned = copy.deepcopy(geometry)
target, center = target_for(pinned)
@@ -105,7 +108,7 @@ def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, rep
require(0 <= ready_at <= clock(), 'Invalid original READY monotonic time')
deadline = ready_at+35
require(clock() < deadline, 'Insufficient original approach time')
state = {'requested': True, 'completed': False, 'nonce': pinned['nonce'], 'geometry': pinned,
state = {'profile': profile, 'requested': True, 'completed': False, 'nonce': pinned['nonce'], 'geometry': pinned,
'target': list(target), 'deadline_monotonic': deadline, 'started_monotonic': clock(),
'finished_monotonic': None, 'motions': [], 'events': [], 'stops': [],
'samples': [], 'cumulative_horizontal_m': 0., 'unconfirmed_held_key': None,
@@ -132,7 +135,7 @@ def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, rep
if active_turn is not None:
turn_yaw, turn_origin, turn_sign = active_turn
change = delta(yaw(s['direction']), turn_yaw)
require(abs(change) <= 15, 'Relative turn exceeded native angle bound')
require(abs(change) <= max_angle, 'Relative turn exceeded native angle bound')
require(horizontal(s['origin'], turn_origin) <= .05, 'Body translated during stationary heading')
if abs(change) >= .05:
require(change*turn_sign > 0, 'Native heading turned opposite to proposal')
@@ -173,7 +176,7 @@ def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, rep
moved = moved_from is None or horizontal(s['origin'], moved_from) >= .05
if angle is not None:
change = delta(yaw(s['direction']), angle)
require(abs(change) <= 15, 'Relative turn exceeded native angle bound')
require(abs(change) <= max_angle, 'Relative turn exceeded native angle bound')
if abs(change) >= .05:
require(change*turn_sign > 0, 'Native heading turned opposite to proposal')
moved = moved and abs(change) >= .05
@@ -183,7 +186,7 @@ def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, rep
elif s['real_ms']-first['real_ms'] >= 100:
if abs(delta(yaw(s['direction']), yaw(first['direction']))) <= .2 and horizontal(s['origin'], first['origin']) <= .02:
if angle is not None:
require(abs(delta(yaw(s['direction']), angle)) <= 15, 'Relative turn exceeded native angle bound')
require(abs(delta(yaw(s['direction']), angle)) <= max_angle, 'Relative turn exceeded native angle bound')
require(clock() <= end, 'Settling exceeded original stage deadline')
return s
first = s
@@ -202,8 +205,8 @@ def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, rep
if abs(error) <= 3:
return s
require(clock() < end and turn_count < 16, 'Heading request budget exceeded')
desired = max(-10., min(10., .75*error))
dx = int(round(desired/gain)); dx = max(-128, min(128, dx))
desired = max(-desired_angle, min(desired_angle, .75*error))
dx = int(round(desired/gain)); dx = max(-max_pixels, min(max_pixels, dx))
if dx == 0: dx = 1 if desired/gain > 0 else -1
require(pixels+abs(dx) <= 2048, 'Relative pixel budget exceeded')
before = read(); require(neutral(before), 'Body moved before turn')
@@ -278,7 +281,7 @@ def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, rep
require(.75 < initial_distance <= 6, 'Initial approach distance outside route scope')
while horizontal(current['origin'], target) > .75:
current = heading(current)
require(pulse_count < 12, 'Forward pulse budget exceeded')
require(pulse_count < max_pulses, 'Forward pulse budget exceeded')
remaining = horizontal(current['origin'], target)
reserve = (largest_stop if largest_stop is not None else 1.25)+.25
require(remaining > reserve, 'Insufficient distance for measured stopping reserve')