File size: 1,809 Bytes
3040bf7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""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()