Spaces:
Running
Running
| """5-minute APIShift quickstart — runs in-process, no LLM, no training. | |
| Useful sanity check for new contributors and the first thing judges | |
| should run after `pip install -e .`. | |
| """ | |
| from models import APIShiftAction | |
| from server.environment import APIShiftEnvironment | |
| def main(): | |
| env = APIShiftEnvironment() | |
| obs = env.reset(task_id="github_pat_token_to_bearer") | |
| print(f"Reset: scenario={obs.scenario_id} difficulty={env.state.difficulty}") | |
| print(f" v1: {obs.v1_spec_summary}") | |
| print(f" v2: {obs.v2_spec_summary}") | |
| print(f" retrieved {len(obs.memory_hits)} memory hits") | |
| # An "optimal" sequence for this scenario: | |
| plan = [ | |
| APIShiftAction(command="dispatch_diff", | |
| rationale="discover changes between v1 and v2"), | |
| APIShiftAction(command="dispatch_patch", | |
| payload={"change_id": "ch_001", "file_path": "github_client.py"}, | |
| rationale="patch auth header swap"), | |
| APIShiftAction(command="dispatch_test", | |
| rationale="verify patch works"), | |
| APIShiftAction(command="dispatch_rollback", | |
| rationale="produce rollback for compliance"), | |
| APIShiftAction(command="submit", | |
| rationale="finalize"), | |
| ] | |
| for i, action in enumerate(plan, 1): | |
| obs = env.step(action) | |
| print( | |
| f"step {i}: {action.command:<22s} " | |
| f"reward={obs.reward if obs.reward is not None else 0:.4f} " | |
| f"quality={obs.quality_score:.4f} done={obs.done}" | |
| ) | |
| if obs.done: | |
| print("Component breakdown:") | |
| for k, v in env.state.component_rewards.items(): | |
| print(f" {k:<32s} {v:.4f}") | |
| break | |
| if __name__ == "__main__": | |
| main() | |