Files
SkillFactory/scripts/functional_followup_launch_v3.py
T
chenlin c528dd268f feat: checkpoint Go2 FL simulation performance v0.4.2
Include callable skill and live-GUI prerequisites, epoch sensor reads, packed snapshots, sampled bit-exact kinematics, and verified-tick rendering without changing the physical/control schedule.

Record bounded analytic S1 GUI/headless qualification, original failures and CPU evidence (1557 passed, 6 skipped). Preserve accepted_skill=false and sub-real-time limitations. Exclude native authorities, caches, large media and local delivery copies; retain sealed artifact digest.
2026-10-16 15:46:01 +08:00

117 lines
6.0 KiB
Python

"""Fresh authorization and pairing for the single followup + six finite pairs.
Imports are CPU-only. No grant generator, simulator, retry, training or weakening
of GPUOwnership lives here. Old approvals cannot admit this plan.
"""
import importlib
import importlib.util
import json
import sys
from pathlib import Path
import functional_flow_launch_v2 as old
FORMAT = 'skillfactory.functional-followup-parent-approval.v3'
PLAN = 'configs/contact_cycle/functional_followup_v3.json'
EXTRA_SOURCES = (PLAN, 'scripts/functional_followup_launch_v3.py', 'scripts/functional_gpu_watch_v3.py',
'source/SkillFactory/SkillFactory/legs/contact_cycle_sim/functional_followup_v3.py',
'source/SkillFactory/SkillFactory/legs/contact_cycle_sim/functional_followup_binding_v3.py')
def api():
real = 'SkillFactory.legs.contact_cycle_sim.functional_followup_v3'
if real in sys.modules:
return sys.modules[real]
# Pure stdlib private namespace ONLY in the non-Kit parent/planner.
name = '_functional_followup_cpu'
directory = old.ROOT / 'source/SkillFactory/SkillFactory/legs/contact_cycle_sim'
if name not in sys.modules:
spec = importlib.util.spec_from_file_location(name, directory / '__init__.py',
submodule_search_locations=[str(directory)])
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
return importlib.import_module(name + '.functional_followup_v3')
def plan():
value = api().load_plan(old.ROOT / PLAN)
if old.b.digest(old.ROOT / old.CONFIG) != value['base_contract_sha256']:
raise ValueError('Base functional contract drift')
return value
def sources():
return {p: old.b.digest(old.ROOT / p) for p in (*old.SOURCE_PATHS, *EXTRA_SOURCES,
'scripts/audit_cycle_functional_flow.py')}
def approval(path, digest, root):
grant = old.read(path, digest)
p = plan()
expected_order = [r['slot'] for r in api().slots(p)]
if (grant.get('format') != FORMAT or grant.get('artifact_root') != str(root)
or json.dumps(grant.get('limits'), sort_keys=True) != json.dumps(p['limits'], sort_keys=True)
or grant.get('sources') != sources()
or grant.get('plan_sha256') != old.b.digest(old.ROOT / PLAN)
or grant.get('boot_id') != old.b.boot_id() or grant.get('user_approval') != '批准'
or not isinstance(grant.get('authority'), str) or not grant['authority'].strip()
or not old.b.boottime() < grant.get('admit_before_boottime', 0)
or grant.get('slot_order') != expected_order):
raise PermissionError('Fresh exact followup approval required; no old grants')
root = Path(root)
if root != root.resolve() or not root.is_absolute() or root.is_relative_to(old.ROOT) or root.exists():
raise ValueError('New canonical external root required; never retry')
return grant
def initial_pair_record(recorder, s, observation, command_id):
from dataclasses import asdict
from SkillFactory.tasks.manager_based.contact_cycle_sim.functional_flow_recording_v2 import carry_snapshot, tensor_identity
return {'command_id': command_id, 'seed': s.trial.seed,
'command': asdict(s.protocol_command()), 'anchors': asdict(s.anchors),
'state': {k: tensor_identity(v) for k, v in recorder.initial.items()},
'carried': carry_snapshot(s), 'ik': tensor_identity(s.controller.q_ik),
'controller_action': tensor_identity(s.controller.action),
'controller_refreshes': tensor_identity(s.controller.refreshes),
'observation': tensor_identity(observation),
'scope': 'Enumerated initial state/RNG/IK/command, not complete native backend equality'}
def require_pair(actual, expected):
# No coercion/tolerance, reanchoring, state restoration or mismatch repair.
if json.dumps(actual, sort_keys=True, allow_nan=False) != json.dumps(expected, sort_keys=True, allow_nan=False):
raise RuntimeError('identity_pair_initial_state_mismatch_before_rollout')
return True
def complete_receipt(receipt, slot):
c = receipt.get('physics_counts') or {}
stop = receipt.get('runtime_stop') or {}
if slot['cycles'] == 0:
return (receipt.get('success') is True and receipt.get('environment_constructed') is False
and c.get('completed_steps') == c.get('attempted_steps') == 0)
return (receipt.get('success') is True and receipt.get('runtime_continuity_verified') is True
and receipt.get('preclose_identity_verified') is True
and receipt.get('controller_kind') == slot['controller_kind']
and receipt.get('command_id') == slot['command_id'] and receipt.get('cycles_requested') == 3
and c.get('rollout_steps') == 13500
and type(c.get('initialization_steps')) is int and 0 <= c['initialization_steps'] <= 250
and c.get('attempted_steps') == c.get('completed_steps') == 13500 + c['initialization_steps']
and stop.get('reason') == 'protocol_complete' and stop.get('causes') == []
and stop.get('clock', {}).get('global_tick') == 13500
and not receipt.get('hook_violations'))
def paired_comparison(reference, learned):
"""Result publication requires complete physics AND supervision on BOTH rows."""
if not reference.get('success') or not learned.get('success'):
return {'eligible': False, 'reason': 'both_supervised_rows_required'}
a, b = reference['worker'], learned['worker']
if not b.get('initial_pair_matched') or a.get('initial_pair_sha256') != b.get('initial_pair_sha256'):
return {'eligible': False, 'reason': 'exact_initial_pair_required'}
if a.get('command_id') != b.get('command_id'):
return {'eligible': False, 'reason': 'same_command_required'}
return {'eligible': True, 'claim': 'finite_single_seed_functional_comparison_only',
'learning_superiority_claim': False}