Files
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

77 lines
4.5 KiB
Python

"""Readiness for genuine source posture changes through original client input.
Tortoise batches stand requests for200ms. Reuse a known standing ACK; otherwise
use original client input and a fresh server acknowledgment. An immediate
second X can be ignored while the first sitting transition remains active.
Native readiness also requires the real self UNIT_FIELD_BYTES_1 word: a stand
ACK can precede the object update. This observes source receipt, not proof that
the renderer/main-thread object manager has already applied the update.
"""
import client_ui as ui
def establish_standing(controller, session, *, self_guid, require_source_field=True):
if type(self_guid) is not int or not 0<self_guid<2**64:raise ValueError('Require the guarded authenticated character GUID')
if type(require_source_field) is not bool:raise ValueError('Require explicit source-field readiness policy')
def inspect():
p=controller.rpc('inspect-engine-pipe',unit_fields_only=True)
if p['error'] or p['closed']:raise RuntimeError('Native session lost during posture readiness')
if require_source_field and 'source_unit_fields' not in p:raise RuntimeError('Source posture field unavailable; native readiness is unverified')
return p
def coherent(p):return p if not p.get('source_unit_fields',{}).get('retryable') else None
initial=inspect()
if not coherent(initial):initial=controller.wait(lambda:coherent(inspect()),4)
current=initial;before=current['cast_result']['stand_received'];steps=[]
def latest(p):
rows=p.get('source_unit_fields',{}).get('rows',[])
return next((r for r in reversed(rows) if r['legacy_guid']==str(self_guid) and r['field']==138),None)
def gate(p,expected,after):
if p['cast_result']['stand_state']!=expected:return None
fields=p.get('source_unit_fields')
if fields is None:return dict(pipe=p,row=None) # Explicit legacy opt-out only.
if fields.get('retryable'):return None
row=latest(p)
if row and row['value']&255==expected and (after is None or row['sequence']>after):return dict(pipe=p,row=row)
return None
def field_ready(p,expected,after,step):
result=gate(p,expected,after)
if result is None:result=controller.wait(lambda:gate(inspect(),expected,after),4)
step.update(source_field_verified=result['row'] is not None,source_field=result['row'],source_field_baseline=after)
if result['row'] is None:step['source_field_limit']='Explicit legacy opt-out: engine/object posture unverified'
return result['pipe']
known=current['cast_result']['stand_state']
if before and known not in (0,1):raise RuntimeError('Unexpected source posture; preserve state without extra input')
toggle=not before
if before and known==0:
row=latest(current)
if row is not None or 'source_unit_fields' not in current:
step=dict(ack=before,state=0,reused=True);steps.append(step)
field_ready(current,0,None,step)
return steps
# An old standing word may have fallen out of the bounded ring.
# Establish a fresh real cycle instead of treating absence as proof.
toggle=True
def fresh(required=None):
p=inspect();result=p['cast_result']
if result['stand_received']<=before:return None
if result['stand_state'] not in (0,1):raise RuntimeError('Unexpected source posture; preserve state without extra input')
return p if required is None or result['stand_state']==required else None
baseline=current.get('source_unit_fields',{}).get('total')
if toggle:
# Unknown initial posture: one original toggle establishes a genuine
# source state. Do not immediately toggle again after a sitting ACK.
ui.key(session.d,'x')
current=controller.wait(fresh,4);result=current['cast_result']
step=dict(ack=result['stand_received'],state=result['stand_state']);steps.append(step)
current=field_ready(current,result['stand_state'],baseline,step)
if result['stand_state']==0:return steps
before=result['stand_received']
baseline=current.get('source_unit_fields',{}).get('total')
# /stand is the verified original explicit action, not an engine callback
# or a synthetic packet. A stale ACK or another seated ACK cannot pass.
session.macro('/stand')
current=controller.wait(lambda:fresh(0),4);result=current['cast_result']
step=dict(ack=result['stand_received'],state=0);steps.append(step)
field_ready(current,0,baseline,step)
return steps