Harbor format: 210 business_automation tasks (part 3)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- tasks/autom-field-service-rebooking-008-v2/tests/test.shAdded+4
- tasks/autom-field-service-rebooking-008-v2/tests/world.jsonAdded+358
- tasks/autom-field-service-rebooking-008-v2/tests/world_check.pyAdded+26
- tasks/autom-field-service-rebooking-008-v2/validation/openenv.jsonAdded+28
- tasks/autom-field-service-rebooking-009-v2/environment/inputs/apps.pyAdded+68
- tasks/autom-field-service-rebooking-009-v2/environment/inputs/world.jsonAdded+329
- tasks/autom-field-service-rebooking-009-v2/instruction.mdAdded+19
- tasks/autom-field-service-rebooking-009-v2/solution/files/actions.jsonlAdded+14
- tasks/autom-field-service-rebooking-009-v2/solution/solve.shAdded+4
- tasks/autom-field-service-rebooking-009-v2/task.tomlAdded+46
- tasks/autom-field-service-rebooking-009-v2/tests/expected.jsonAdded+9
- tasks/autom-field-service-rebooking-009-v2/tests/grade.pyAdded+330
- tasks/autom-field-service-rebooking-009-v2/tests/replay.pyAdded+68
- tasks/autom-field-service-rebooking-009-v2/tests/target.jsonAdded+343
- tasks/autom-field-service-rebooking-009-v2/tests/test.shAdded+4
- tasks/autom-field-service-rebooking-009-v2/tests/world.jsonAdded+329
- tasks/autom-field-service-rebooking-009-v2/tests/world_check.pyAdded+26
- tasks/autom-field-service-rebooking-009-v2/validation/openenv.jsonAdded+28
- tasks/autom-field-service-rebooking-010-v2/environment/inputs/apps.pyAdded+68
- tasks/autom-field-service-rebooking-010-v2/environment/inputs/world.jsonAdded+343
- tasks/autom-field-service-rebooking-010-v2/instruction.mdAdded+19
- tasks/autom-field-service-rebooking-010-v2/solution/files/actions.jsonlAdded+12
- tasks/autom-field-service-rebooking-010-v2/solution/solve.shAdded+4
- tasks/autom-field-service-rebooking-010-v2/task.tomlAdded+46
- tasks/autom-field-service-rebooking-010-v2/tests/expected.jsonAdded+9
- tasks/autom-field-service-rebooking-010-v2/tests/grade.pyAdded+330
- tasks/autom-field-service-rebooking-010-v2/tests/replay.pyAdded+68
- tasks/autom-field-service-rebooking-010-v2/tests/target.jsonAdded+358
- tasks/autom-field-service-rebooking-010-v2/tests/test.shAdded+4
- tasks/autom-field-service-rebooking-010-v2/tests/world.jsonAdded+343
- tasks/autom-field-service-rebooking-010-v2/tests/world_check.pyAdded+26
- tasks/autom-field-service-rebooking-010-v2/validation/openenv.jsonAdded+28
- tasks/autom-field-service-rebooking-011-v2/environment/inputs/apps.pyAdded+68
- tasks/autom-field-service-rebooking-011-v2/environment/inputs/world.jsonAdded+340
- tasks/autom-field-service-rebooking-011-v2/instruction.mdAdded+19
- tasks/autom-field-service-rebooking-011-v2/solution/files/actions.jsonlAdded+12
- tasks/autom-field-service-rebooking-011-v2/solution/solve.shAdded+4
- tasks/autom-field-service-rebooking-011-v2/task.tomlAdded+46
- tasks/autom-field-service-rebooking-011-v2/tests/expected.jsonAdded+9
- tasks/autom-field-service-rebooking-011-v2/tests/grade.pyAdded+330
- tasks/autom-field-service-rebooking-011-v2/tests/replay.pyAdded+68
- tasks/autom-field-service-rebooking-011-v2/tests/target.jsonAdded+355
- tasks/autom-field-service-rebooking-011-v2/tests/test.shAdded+4
- tasks/autom-field-service-rebooking-011-v2/tests/world.jsonAdded+340
- tasks/autom-field-service-rebooking-011-v2/tests/world_check.pyAdded+26
- tasks/autom-field-service-rebooking-011-v2/validation/openenv.jsonAdded+28
- tasks/autom-field-service-rebooking-012-v2/environment/inputs/apps.pyAdded+68
- tasks/autom-field-service-rebooking-012-v2/environment/inputs/world.jsonAdded+302
- tasks/autom-field-service-rebooking-012-v2/instruction.mdAdded+19
- tasks/autom-field-service-rebooking-012-v2/solution/files/actions.jsonlAdded+12
1234#!/bin/shset -eumkdir -p /logs/verifier /workspace/outputsexec python3 -B -I /tests/grade.py123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358{ "accounts": { "CL-0": { "allow_remote": true, "tier": "standard" }, "CL-1": { "allow_remote": false, "tier": "standard" }, "CL-10": { "allow_remote": true, "tier": "standard" }, "CL-11": { "allow_remote": true, "tier": "standard" }, "CL-2": { "allow_remote": true, "tier": "priority" }, "CL-3": { "allow_remote": false, "tier": "standard" }, "CL-4": { "allow_remote": false, "tier": "standard" }, "CL-5": { "allow_remote": false, "tier": "standard" }, "CL-6": { "allow_remote": true, "tier": "standard" }, "CL-7": { "allow_remote": false, "tier": "standard" }, "CL-8": { "allow_remote": true, "tier": "priority" }, "CL-9": { "allow_remote": false, "tier": "standard" } }, "calendar": { "S00": { "crew": "T0", "day": "2025-08-01", "mode": "onsite", "start": "10:00", "state": "available" }, "S01": { "crew": "T6", "day": "2025-08-05", "mode": "onsite", "start": "15:00", "state": "available" }, "S02": { "crew": "T2", "day": "2025-08-02", "mode": "remote", "start": "13:00", "state": "available" }, "S03": { "crew": "T2", "day": "2025-08-04", "mode": "remote", "start": "10:00", "state": "available" }, "S04": { "crew": "T5", "day": "2025-08-02", "mode": "onsite", "start": "10:00", "state": "available" }, "S05": { "crew": "T6", "day": "2025-08-06", "mode": "remote", "start": "13:00", "state": "available" }, "S06": { "crew": "T0", "day": "2025-08-04", "mode": "remote", "start": "08:00", "state": "available" }, "S07": { "crew": "T4", "day": "2025-08-05", "mode": "remote", "start": "15:00", "state": "available" }, "S08": { "crew": "T2", "day": "2025-08-05", "mode": "onsite", "start": "13:00", "state": "available" }, "S09": { "crew": "T0", "day": "2025-08-01", "mode": "remote", "start": "08:00", "state": "available" }, "S10": { "crew": "T3", "day": "2025-08-04", "mode": "onsite", "start": "15:00", "state": "available" }, "S11": { "crew": "T4", "day": "2025-08-05", "mode": "onsite", "start": "08:00", "state": "available" }, "S12": { "crew": "T1", "day": "2025-08-04", "mode": "onsite", "start": "13:00", "state": "available" }, "S13": { "crew": "T2", "day": "2025-08-03", "mode": "onsite", "start": "10:00", "state": "available" }, "S14": { "crew": "T4", "day": "2025-08-05", "mode": "remote", "start": "10:00", "state": "available" }, "S15": { "crew": "T1", "day": "2025-08-04", "mode": "onsite", "start": "08:00", "state": "occupied" }, "S16": { "crew": "T1", "day": "2025-08-01", "mode": "remote", "start": "10:00", "state": "occupied" }, "S17": { "crew": "T3", "day": "2025-08-01", "mode": "remote", "start": "10:00", "state": "available" }, "S18": { "crew": "T2", "day": "2025-08-03", "mode": "remote", "start": "13:00", "state": "available" }, "S19": { "crew": "T2", "day": "2025-08-02", "mode": "remote", "start": "10:00", "state": "available" } }, "dispatch": { "DISPATCH-OLD": { "status": "closed", "work_order": "archived" } }, "technicians": { "T0": { "active": true, "home": "West", "skills": [ "network", "safety", "controls" ] }, "T1": { "active": true, "home": "West", "skills": [ "safety", "controls", "network" ] }, "T2": { "active": true, "home": "West", "skills": [ "controls", "network" ] }, "T3": { "active": true, "home": "West", "skills": [ "safety", "network", "controls" ] }, "T4": { "active": true, "home": "West", "skills": [ "network", "controls" ] }, "T5": { "active": true, "home": "North", "skills": [ "controls", "network" ] }, "T6": { "active": false, "home": "North", "skills": [ "network" ] } }, "work_orders": { "J-1111-4": { "client": "CL-4", "day": "2025-07-31", "hub": "West", "service": "safety", "start": "15:00", "state": "confirmed" }, "J-1664-5": { "client": "CL-5", "day": "2025-07-31", "hub": "West", "service": "network", "start": "08:00", "state": "confirmed" }, "J-2179-11": { "client": "CL-11", "day": "2025-07-30", "hub": "North", "service": "safety", "start": "10:00", "state": "cancelled" }, "J-2518-1": { "client": "CL-1", "day": "2025-07-31", "hub": "West", "service": "safety", "start": "15:00", "state": "confirmed" }, "J-2787-0": { "client": "CL-0", "day": "2025-07-31", "hub": "West", "service": "safety", "start": "08:00", "state": "confirmed" }, "J-2886-9": { "client": "CL-9", "day": "2025-08-02", "hub": "West", "service": "controls", "start": "08:00", "state": "confirmed" }, "J-3686-10": { "client": "CL-10", "day": "2025-08-02", "hub": "North", "service": "safety", "start": "15:00", "state": "confirmed" }, "J-4416-2": { "client": "CL-2", "day": "2025-07-31", "hub": "West", "service": "controls", "start": "08:00", "state": "confirmed" }, "J-5659-8": { "client": "CL-8", "day": "2025-07-30", "hub": "North", "service": "network", "start": "15:00", "state": "confirmed" }, "J-8434-7": { "client": "CL-7", "day": "2025-08-02", "hub": "North", "service": "network", "start": "15:00", "state": "cancelled" }, "J-9065-3": { "client": "CL-3", "day": "2025-07-31", "hub": "West", "service": "network", "start": "13:00", "state": "confirmed" }, "J-9143-6": { "client": "CL-6", "day": "2025-07-30", "hub": "West", "service": "safety", "start": "10:00", "state": "cancelled" } }}1234567891011121314151617181920212223242526"""Replay submitted mutations from the private verifier's initial state."""from types import ModuleTypeimport json
def check(spec, outputs, tests): replay = ModuleType('workflow_replay') exec(compile((tests/'replay.py').read_bytes(), 'replay.py', 'exec'), replay.__dict__) world = json.loads((tests/'world.json').read_text()) target = json.loads((tests/'target.json').read_text()) # Only fields whose starting and expected values differ may be changed. Attempts # to temporarily alter a protected field fail even when a later write restores it. allowed = { (app,key): {field for field,value in doc.items() if field not in world[app].get(key,{}) or not replay.same(world[app][key][field],value)} for app,records in target.items() for key,doc in records.items() } actions = replay.load_actions(outputs/'actions.jsonl') for event in actions: replay.apply(world,event) touched = set(event['fields']) if not touched <= allowed.get((event['app'],event['id']),set()): return False,'protected field or record write' if not replay.same(world,target): return False,'required business outcomes incomplete' return True,''12345678910111213141516171819202122232425262728{ "profile": "harbor-semantic-v1", "reward_key": "reward", "reward": { "range": [ 0, 1 ], "oracle_tolerance": 0, "floor_margin": 0.1 }, "resources": { "cpu": 1, "memory_mb": 4096, "disk_mb": 10240, "episode_timeout_s": 1800 }, "types": { "tags": [ "knowledge-work", "cross-app-workflows", "conditional-execution", "protected-state", "operations" ] }, "requires_credentials": false}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768"""Offline business-app client. Print usage with --help."""import argparseimport copyimport fcntlimport jsonimport osfrom pathlib import Path
def same(left, right): return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
def apply(world, action): if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}: raise ValueError('expected op, app, id, fields') op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields')) if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields: raise ValueError('unknown app, invalid id or empty fields') collection = world[app] if op == 'update' and key in collection: collection[key].update(copy.deepcopy(fields)) elif op == 'create' and key not in collection: collection[key] = copy.deepcopy(fields) else: raise ValueError(f'invalid {op} for {app}/{key}')
def load_actions(path): if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000): raise ValueError('invalid action log') if not path.exists(): return [] return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('op', choices=('apps','list','get','update','create')) parser.add_argument('app', nargs='?') parser.add_argument('id', nargs='?') parser.add_argument('fields', nargs='?', type=json.loads) args = parser.parse_args() world = json.loads(Path(__file__).with_name('world.json').read_text()) out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs')) out.mkdir(parents=True, exist_ok=True) log = out/'actions.jsonl' with (out/'.actions.lock').open('a') as lock: fcntl.flock(lock.fileno(), fcntl.LOCK_EX) for event in load_actions(log): apply(world,event) if args.op=='apps': value=sorted(world) elif args.op=='list': value=world[args.app] elif args.op=='get': value=world[args.app][args.id] else: event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields} apply(world,event) with log.open('a') as handle: handle.write(json.dumps(event,allow_nan=False)+'\n') value=world[args.app][args.id] print(json.dumps(value,sort_keys=True,allow_nan=False))
if __name__=='__main__': main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329{ "accounts": { "CL-0": { "allow_remote": true, "tier": "standard" }, "CL-1": { "allow_remote": true, "tier": "standard" }, "CL-10": { "allow_remote": false, "tier": "priority" }, "CL-11": { "allow_remote": false, "tier": "standard" }, "CL-2": { "allow_remote": false, "tier": "priority" }, "CL-3": { "allow_remote": false, "tier": "priority" }, "CL-4": { "allow_remote": true, "tier": "priority" }, "CL-5": { "allow_remote": false, "tier": "standard" }, "CL-6": { "allow_remote": false, "tier": "priority" }, "CL-7": { "allow_remote": false, "tier": "standard" }, "CL-8": { "allow_remote": true, "tier": "priority" }, "CL-9": { "allow_remote": false, "tier": "priority" } }, "calendar": { "S00": { "crew": "T0", "day": "2025-08-24", "mode": "onsite", "start": "13:00", "state": "available" }, "S01": { "crew": "T5", "day": "2025-08-26", "mode": "onsite", "start": "08:00", "state": "available" }, "S02": { "crew": "T3", "day": "2025-08-26", "mode": "onsite", "start": "15:00", "state": "available" }, "S03": { "crew": "T2", "day": "2025-08-28", "mode": "remote", "start": "08:00", "state": "available" }, "S04": { "crew": "T6", "day": "2025-08-27", "mode": "onsite", "start": "10:00", "state": "available" }, "S05": { "crew": "T0", "day": "2025-08-24", "mode": "onsite", "start": "15:00", "state": "available" }, "S06": { "crew": "T0", "day": "2025-08-28", "mode": "onsite", "start": "15:00", "state": "available" }, "S07": { "crew": "T2", "day": "2025-08-25", "mode": "remote", "start": "10:00", "state": "available" }, "S08": { "crew": "T6", "day": "2025-08-27", "mode": "onsite", "start": "13:00", "state": "occupied" }, "S09": { "crew": "T2", "day": "2025-08-24", "mode": "onsite", "start": "10:00", "state": "available" }, "S10": { "crew": "T2", "day": "2025-08-30", "mode": "remote", "start": "15:00", "state": "available" }, "S11": { "crew": "T6", "day": "2025-08-29", "mode": "onsite", "start": "08:00", "state": "available" }, "S12": { "crew": "T4", "day": "2025-08-28", "mode": "remote", "start": "10:00", "state": "available" }, "S13": { "crew": "T4", "day": "2025-08-24", "mode": "onsite", "start": "10:00", "state": "available" }, "S14": { "crew": "T2", "day": "2025-08-24", "mode": "onsite", "start": "13:00", "state": "available" }, "S15": { "crew": "T0", "day": "2025-08-29", "mode": "onsite", "start": "08:00", "state": "available" } }, "dispatch": { "DISPATCH-OLD": { "status": "closed", "work_order": "archived" } }, "technicians": { "T0": { "active": true, "home": "North", "skills": [ "network", "safety", "controls" ] }, "T1": { "active": true, "home": "North", "skills": [ "controls" ] }, "T2": { "active": true, "home": "North", "skills": [ "controls", "network", "safety" ] }, "T3": { "active": true, "home": "North", "skills": [ "network" ] }, "T4": { "active": true, "home": "North", "skills": [ "safety", "network", "controls" ] }, "T5": { "active": true, "home": "South", "skills": [ "safety", "network" ] }, "T6": { "active": false, "home": "South", "skills": [ "network", "safety" ] } }, "work_orders": { "J-1706-3": { "client": "CL-3", "day": "2025-08-23", "hub": "North", "service": "safety", "start": "13:00", "state": "confirmed" }, "J-2384-7": { "client": "CL-7", "day": "2025-08-23", "hub": "South", "service": "controls", "start": "10:00", "state": "cancelled" }, "J-2447-4": { "client": "CL-4", "day": "2025-08-23", "hub": "North", "service": "controls", "start": "10:00", "state": "confirmed" }, "J-2899-9": { "client": "CL-9", "day": "2025-08-24", "hub": "South", "service": "controls", "start": "13:00", "state": "cancelled" }, "J-2907-6": { "client": "CL-6", "day": "2025-08-23", "hub": "North", "service": "network", "start": "15:00", "state": "confirmed" }, "J-3409-11": { "client": "CL-11", "day": "2025-08-21", "hub": "South", "service": "safety", "start": "13:00", "state": "confirmed" }, "J-7516-1": { "client": "CL-1", "day": "2025-08-23", "hub": "North", "service": "safety", "start": "15:00", "state": "confirmed" }, "J-7560-8": { "client": "CL-8", "day": "2025-08-25", "hub": "North", "service": "network", "start": "15:00", "state": "cancelled" }, "J-8037-5": { "client": "CL-5", "day": "2025-08-23", "hub": "North", "service": "network", "start": "15:00", "state": "confirmed" }, "J-9220-2": { "client": "CL-2", "day": "2025-08-23", "hub": "North", "service": "network", "start": "13:00", "state": "confirmed" }, "J-9532-10": { "client": "CL-10", "day": "2025-08-21", "hub": "North", "service": "network", "start": "10:00", "state": "confirmed" }, "J-9563-0": { "client": "CL-0", "day": "2025-08-23", "hub": "North", "service": "network", "start": "15:00", "state": "confirmed" } }}12345678910111213141516171819A field-service closure affects confirmed work orders at North on 2025-08-23. Reschedule those orders only. Serve priority-tier accounts first, then standard. Within each tier sort by original start time and then work-order ID ascending. Each appointment needs one full slot for a technician active and skilled in the order's service.
Search available calendar slots from 2025-08-24 through 2025-08-28, inclusive. Onsite slots require the technician to be based at North. Remote slots can use any home hub if the account allows remote service. Choose earliest day, then earliest start, then onsite before remote, then smallest slot ID in lexical order. Allocate one slot at a time in queue order. Remove each allocated slot from consideration for subsequent orders.
For a match update the calendar slot to `state=reserved` with `work_order` equal to the order ID. Set the work order `state=rebooked` and `new_slot` to the chosen slot ID; retain its original day and time. If no slot remains set only its `state=manual`, then create dispatch record `follow-<order ID>` with `work_order`, `client`, and `status=needs_slot`. Preserve all other fields and records.
Calculate the plan in the stated queue order using all earlier decisions. Once calculated, you may apply the resulting changes in any order or combine updates to the same record. The action log is checked for the final business state and for any write to a protected record or field.
Use the offline app client at `/workspace/inputs/apps.py`. Call it with python3. Run`apps` to discover apps, `list APP` to see its records, or `get APP ID` for one record.Write with `update APP ID '{"field":"value"}'` or `create APP ID '{"field":"value"}'`.The client records successful writes in `/workspace/outputs/actions.jsonl`.Apply exactly the required changes. Other records and fields must remain untouched,including temporary changes. Actions take effect in the local simulation only.
## Deliverable
Work in `/workspace`. Input files are under `/workspace/inputs/`. Put every deliverable in`/workspace/outputs/`; only that directory is graded. Leave the app action log in the outputs directory.1234567891011121314{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-9220-2"}, "id": "S00", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-8037-5"}, "id": "S02", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-7516-1"}, "id": "S05", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-9563-0"}, "id": "S07", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-2447-4"}, "id": "S09", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-1706-3"}, "id": "S13", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-2907-6"}, "id": "S14", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S13", "state": "rebooked"}, "id": "J-1706-3", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S09", "state": "rebooked"}, "id": "J-2447-4", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S14", "state": "rebooked"}, "id": "J-2907-6", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S05", "state": "rebooked"}, "id": "J-7516-1", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S02", "state": "rebooked"}, "id": "J-8037-5", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S00", "state": "rebooked"}, "id": "J-9220-2", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S07", "state": "rebooked"}, "id": "J-9563-0", "op": "update"}1234#!/bin/shset -eumkdir -p /workspace/outputscp -R /solution/files/. /workspace/outputs/12345678910111213141516171819202122232425262728293031323334353637383940414243444546schema_version = "1.3"
[task]name = "apex-gap/autom-field-service-rebooking-009-v2"
[metadata.apex_gap]capability_tags = ["cross-app-workflows", "conditional-execution", "protected-state", "operations"]dataset = "Original simulated workflows"job = "operations"seed = 9source = "local/original-automation-workflows"source_revision = "2"source_split = "synthetic"source_task_id = "autom-field-service-rebooking-009"template_family = "automation:field-service-rebooking"workflow_template = "field-service-rebooking"
[metadata.openenv_hf_sandbox]variant = "apex-gap-hfsandbox-v1"task_modified_for_hf_sandbox = truenetwork_enabled = true
[environment]docker_image = "ghcr.io/younesbelkada/apex@sha256:24969c952247033023872f87161a16e067003469506be63783bbaa5d96926bdf"workdir = "/workspace"cpus = 1memory_mb = 4096build_timeout_sec = 600network_mode = "public"
[agent]timeout_sec = 1800network_mode = "public"
[verifier]timeout_sec = 600network_mode = "public"environment_mode = "separate"
[verifier.environment]network_mode = "public"cpus = 1memory_mb = 4096
[[artifacts]]source = "/workspace/outputs"123456789{ "checks": [ { "id": "business-outcomes", "type": "custom", "module": "world_check" } ]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330"""Deterministic grader shared by converted knowledge-work tasks.
Runs inside the separate verifier sandbox. Reads /tests/expected.json, inspects thesubmitted /workspace/outputs tree and writes a binary reward plus per-check details.No model calls and no network.
expected.json: {"checks": [{"id": ..., "type": ..., ...}, ...]}Check types: answer field of outputs/answer.json; kind = number|text|choice|date|bool|list xlsx_range recalculated outputs/<file> vs tests/<target> over sheet!range (SpreadsheetBench rules) xlsx_cell recalculated outputs/<file> sheet!cell vs value with tolerance (optional alt_values) file_contains outputs/<file> text (docx/pdf/ics/eml/txt) must contain every needle custom tests/<module>.py defines check(spec, outputs_dir, tests_dir) -> (bool, str)"""
import datetime as dtimport jsonimport reimport shutilimport subprocessimport sysimport tempfileimport unicodedatafrom pathlib import Path
OUT = Path("/workspace/outputs")TESTS = Path("/tests")LOGS = Path("/logs/verifier")
def norm_text(v): v = unicodedata.normalize("NFKC", str(v)).casefold() v = re.sub(r"[‘’“”]", "'", v) v = re.sub(r"[^\w%.$/-]+", " ", v) return " ".join(v.split()).strip(" .")
def to_number(v): if isinstance(v, bool): raise ValueError("bool") if isinstance(v, (int, float)): return float(v) s = str(v).strip().replace(",", "").replace("$", "").replace("−", "-") neg = s.startswith("(") and s.endswith(")") s = s.strip("()").strip() pct = s.endswith("%") s = s.rstrip("%").strip() s = re.sub(r"\s*(usd|dollars|million|billion|thousand|m|bn|k)$", "", s, flags=re.I) x = float(s) x = -x if neg else x return x / 100 if pct else x
def number_ok(got, want, rel, abs_): try: g = to_number(got) except (TypeError, ValueError): return False w = float(want) tol = max(abs_, rel * abs(w)) # "12.5%" may mean the ratio 0.125 or the percent number 12.5; the gold fixes which. candidates = [g, g * 100] if isinstance(got, str) and got.strip().endswith("%") else [g] return any(abs(c - w) <= tol for c in candidates)
def parse_date(v): if isinstance(v, (dt.date, dt.datetime)): return v if isinstance(v, dt.date) else v.date() s = str(v).strip() for fmt in ("%Y-%m-%d", "%m/%d/%Y", "%m/%d/%y", "%d %B %Y", "%B %d, %Y", "%b %d, %Y", "%Y/%m/%d"): try: return dt.datetime.strptime(s, fmt).date() except ValueError: continue raise ValueError(s)
def check_answer(check, answers): key = check["field"] if key not in answers: return False, f"missing field {key!r}" got, want, kind = answers[key], check["value"], check.get("kind", "text") if kind == "number": ok = number_ok(got, want, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01)) if not ok and check.get("percent_either"): ok = number_ok(got, want * 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) * 100) or ( number_ok(got, want / 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) / 100) ) elif kind == "date": try: ok = parse_date(got) == parse_date(want) except ValueError: ok = False elif kind == "bool": g = norm_text(got) ok = g in {"yes", "true"} if want else g in {"no", "false"} elif kind == "choice": ok = norm_text(got) == norm_text(want) elif kind == "list": if not isinstance(got, list): return False, f"{key}: expected a JSON list" # Filenames may be given with a directory prefix; compare base names. base = lambda x: norm_text(str(x).replace("\\", "/").rsplit("/", 1)[-1]) ok = sorted(base(x) for x in got) == sorted(base(x) for x in want) else: accepted = check.get("accept", [want]) ok = norm_text(got) in {norm_text(a) for a in accepted} return ok, "" if ok else f"{key}: got {got!r}"
# LibreOffice keeps cached formula values on load unless told otherwise; force a full recalculation.RECALC_PROFILE = """<?xml version="1.0" encoding="UTF-8"?><oor:items xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema"><item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="OOXMLRecalcMode" oor:op="fuse"><value>0</value></prop></item><item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="ODFRecalcMode" oor:op="fuse"><value>0</value></prop></item></oor:items>"""
def recalc(path, tmp): dest = Path(tmp) / f"recalc-{len(list(Path(tmp).glob('recalc-*')))}" dest.mkdir() profile = Path(tmp) / "lo-profile" if not profile.exists(): (profile / "user").mkdir(parents=True) (profile / "user" / "registrymodifications.xcu").write_text(RECALC_PROFILE) subprocess.run( ["soffice", f"-env:UserInstallation=file://{profile}", "--headless", "--calc", "--convert-to", "xlsx:Calc MS Excel 2007 XML", "--outdir", str(dest), str(path)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=180, check=False, ) out = dest / (Path(path).stem + ".xlsx") return out if out.exists() else Path(path)
def cell_value(v): if isinstance(v, (int, float)) and not isinstance(v, bool): return round(float(v), 2) if isinstance(v, dt.datetime): return round((v - dt.datetime(1899, 12, 30)).total_seconds() / 86400.0, 0) if isinstance(v, dt.time): return v.strftime("%H:%M") if isinstance(v, str): try: return round(float(v), 2) except ValueError: return v.strip() return v
def time_of(v): """A time or a day fraction in [0, 1) as HH:MM, rounded to the nearest second first. Calc and Excel store a time as that fraction; openpyxl returns a time only for time-formatted cells.""" if isinstance(v, dt.time): v = (v.hour * 3600 + v.minute * 60 + v.second + v.microsecond / 1e6) / 86400 if isinstance(v, (int, float)) and not isinstance(v, bool) and 0 <= v < 1: return (dt.datetime(1899, 12, 30) + dt.timedelta(seconds=round(v * 86400))).strftime("%H:%M") return None
def same_cell(a, b): if isinstance(a, dt.time) is not isinstance(b, dt.time): n = b if isinstance(a, dt.time) else a if time_of(n) is not None: # a time against a plain day fraction return time_of(a) == time_of(b) a, b = cell_value(a), cell_value(b) if a in (None, "") and b in (None, ""): return True return type(a) is type(b) and a == b
ERRORS = {"#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A"}
def is_error(v): return isinstance(v, str) and (v in ERRORS or v.startswith("Err:"))
def cells(rng): if ":" not in rng: return [rng] from openpyxl.utils import range_boundaries, get_column_letter
c1, r1, c2, r2 = range_boundaries(rng) return [f"{get_column_letter(c)}{r}" for r in range(r1, r2 + 1) for c in range(c1, c2 + 1)]
def load(path, tmp): import openpyxl
return openpyxl.load_workbook(recalc(path, tmp), data_only=True)
def check_xlsx_range(check, tmp, cache): sub = OUT / check["file"] if not sub.is_file(): return False, f"missing output {check['file']}" if sub not in cache: cache[sub] = load(sub, tmp) tgt = TESTS / check["target"] if tgt not in cache: cache[tgt] = load(tgt, tmp) got, want = cache[sub], cache[tgt] cached = None # the target's stored (Excel-computed) values, read only when Calc errs for sheet, rng in check["ranges"]: sheet = sheet or want.sheetnames[0] if sheet not in got.sheetnames: return False, f"sheet {sheet!r} missing" for name in cells(rng): w = want[sheet][name].value if is_error(w): # LibreOffice could not evaluate the gold formula (e.g. XLOOKUP, FILTER in Calc 7.4). # The value Excel stored is the intended answer. if cached is None: import openpyxl
cached = openpyxl.load_workbook(tgt, data_only=True) c = cached[sheet][name].value if sheet in cached.sheetnames else None if c is not None and not is_error(c): w = c if not same_cell(w, got[sheet][name].value): return False, f"{sheet}!{name}: want {w!r} got {got[sheet][name].value!r}" return True, ""
def check_xlsx_cell(check, tmp, cache): sub = OUT / check["file"] if not sub.is_file(): return False, f"missing output {check['file']}" if sub not in cache: cache[sub] = load(sub, tmp) wb = cache[sub] if check["sheet"] not in wb.sheetnames: return False, f"sheet {check['sheet']!r} missing" got = wb[check["sheet"]][check["cell"]].value want = check["value"] if isinstance(want, (int, float)): # alt_values: other accepted golds where the source admits more than one reading. ok = got is not None and any(number_ok(got, w, check.get("rel_tol", 0.0), check.get("abs_tol", 0.01)) for w in [want, *check.get("alt_values", [])]) else: ok = norm_text(got) == norm_text(want) return ok, "" if ok else f"{check['sheet']}!{check['cell']}: want {want!r} got {got!r}"
def text_of(path): suffix = path.suffix.lower() if suffix == ".docx": import docx
d = docx.Document(path) parts = [p.text for p in d.paragraphs] for t in d.tables: parts += [c.text for row in t.rows for c in row.cells] return "\n".join(parts) if suffix == ".pdf": import pdfplumber
with pdfplumber.open(path) as pdf: return "\n".join(page.extract_text() or "" for page in pdf.pages) return path.read_text(errors="replace")
def check_file_contains(check, tmp, cache): sub = OUT / check["file"] if not sub.is_file(): return False, f"missing output {check['file']}" text = text_of(sub) hay = text if check.get("case_sensitive") else text.casefold() for needle in check["needles"]: n = needle if check.get("case_sensitive") else needle.casefold() if n not in hay: return False, f"{check['file']} lacks {needle!r}" return True, ""
def main(): LOGS.mkdir(parents=True, exist_ok=True) reward_path = LOGS / "reward.txt" reward_path.write_text("0\n") spec = json.loads((TESTS / "expected.json").read_text()) answers, details = {}, [] answer_file = OUT / "answer.json" if answer_file.is_file(): try: answers = json.loads(answer_file.read_text()) if not isinstance(answers, dict): answers = {} except json.JSONDecodeError: answers = {} tmp = tempfile.mkdtemp() cache = {} try: for check in spec["checks"]: try: if check["type"] == "answer": ok, why = check_answer(check, answers) elif check["type"] == "xlsx_range": ok, why = check_xlsx_range(check, tmp, cache) elif check["type"] == "xlsx_cell": ok, why = check_xlsx_cell(check, tmp, cache) elif check["type"] == "file_contains": ok, why = check_file_contains(check, tmp, cache) elif check["type"] == "custom": import importlib.util
spec_ = importlib.util.spec_from_file_location("custom_check", TESTS / f"{check['module']}.py") mod = importlib.util.module_from_spec(spec_) spec_.loader.exec_module(mod) ok, why = mod.check(check, OUT, TESTS) else: ok, why = False, f"unknown check type {check['type']}" except Exception as exc: # a malformed submission fails the check, not the grader ok, why = False, f"{type(exc).__name__}: {exc}" details.append({"id": check["id"], "passed": ok, "detail": why}) finally: shutil.rmtree(tmp, ignore_errors=True) passed = sum(d["passed"] for d in details) total = len(details) reward = 1 if total and passed == total else 0 (LOGS / "details.json").write_text(json.dumps({"passed": passed, "total": total, "checks": details}, indent=1)) reward_path.write_text(f"{reward}\n") print(f"{passed}/{total} checks passed; reward {reward}")
if __name__ == "__main__": sys.exit(main())1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768"""Offline business-app client. Print usage with --help."""import argparseimport copyimport fcntlimport jsonimport osfrom pathlib import Path
def same(left, right): return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
def apply(world, action): if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}: raise ValueError('expected op, app, id, fields') op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields')) if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields: raise ValueError('unknown app, invalid id or empty fields') collection = world[app] if op == 'update' and key in collection: collection[key].update(copy.deepcopy(fields)) elif op == 'create' and key not in collection: collection[key] = copy.deepcopy(fields) else: raise ValueError(f'invalid {op} for {app}/{key}')
def load_actions(path): if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000): raise ValueError('invalid action log') if not path.exists(): return [] return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('op', choices=('apps','list','get','update','create')) parser.add_argument('app', nargs='?') parser.add_argument('id', nargs='?') parser.add_argument('fields', nargs='?', type=json.loads) args = parser.parse_args() world = json.loads(Path(__file__).with_name('world.json').read_text()) out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs')) out.mkdir(parents=True, exist_ok=True) log = out/'actions.jsonl' with (out/'.actions.lock').open('a') as lock: fcntl.flock(lock.fileno(), fcntl.LOCK_EX) for event in load_actions(log): apply(world,event) if args.op=='apps': value=sorted(world) elif args.op=='list': value=world[args.app] elif args.op=='get': value=world[args.app][args.id] else: event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields} apply(world,event) with log.open('a') as handle: handle.write(json.dumps(event,allow_nan=False)+'\n') value=world[args.app][args.id] print(json.dumps(value,sort_keys=True,allow_nan=False))
if __name__=='__main__': main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343{ "accounts": { "CL-0": { "allow_remote": true, "tier": "standard" }, "CL-1": { "allow_remote": true, "tier": "standard" }, "CL-10": { "allow_remote": false, "tier": "priority" }, "CL-11": { "allow_remote": false, "tier": "standard" }, "CL-2": { "allow_remote": false, "tier": "priority" }, "CL-3": { "allow_remote": false, "tier": "priority" }, "CL-4": { "allow_remote": true, "tier": "priority" }, "CL-5": { "allow_remote": false, "tier": "standard" }, "CL-6": { "allow_remote": false, "tier": "priority" }, "CL-7": { "allow_remote": false, "tier": "standard" }, "CL-8": { "allow_remote": true, "tier": "priority" }, "CL-9": { "allow_remote": false, "tier": "priority" } }, "calendar": { "S00": { "crew": "T0", "day": "2025-08-24", "mode": "onsite", "start": "13:00", "state": "reserved", "work_order": "J-9220-2" }, "S01": { "crew": "T5", "day": "2025-08-26", "mode": "onsite", "start": "08:00", "state": "available" }, "S02": { "crew": "T3", "day": "2025-08-26", "mode": "onsite", "start": "15:00", "state": "reserved", "work_order": "J-8037-5" }, "S03": { "crew": "T2", "day": "2025-08-28", "mode": "remote", "start": "08:00", "state": "available" }, "S04": { "crew": "T6", "day": "2025-08-27", "mode": "onsite", "start": "10:00", "state": "available" }, "S05": { "crew": "T0", "day": "2025-08-24", "mode": "onsite", "start": "15:00", "state": "reserved", "work_order": "J-7516-1" }, "S06": { "crew": "T0", "day": "2025-08-28", "mode": "onsite", "start": "15:00", "state": "available" }, "S07": { "crew": "T2", "day": "2025-08-25", "mode": "remote", "start": "10:00", "state": "reserved", "work_order": "J-9563-0" }, "S08": { "crew": "T6", "day": "2025-08-27", "mode": "onsite", "start": "13:00", "state": "occupied" }, "S09": { "crew": "T2", "day": "2025-08-24", "mode": "onsite", "start": "10:00", "state": "reserved", "work_order": "J-2447-4" }, "S10": { "crew": "T2", "day": "2025-08-30", "mode": "remote", "start": "15:00", "state": "available" }, "S11": { "crew": "T6", "day": "2025-08-29", "mode": "onsite", "start": "08:00", "state": "available" }, "S12": { "crew": "T4", "day": "2025-08-28", "mode": "remote", "start": "10:00", "state": "available" }, "S13": { "crew": "T4", "day": "2025-08-24", "mode": "onsite", "start": "10:00", "state": "reserved", "work_order": "J-1706-3" }, "S14": { "crew": "T2", "day": "2025-08-24", "mode": "onsite", "start": "13:00", "state": "reserved", "work_order": "J-2907-6" }, "S15": { "crew": "T0", "day": "2025-08-29", "mode": "onsite", "start": "08:00", "state": "available" } }, "dispatch": { "DISPATCH-OLD": { "status": "closed", "work_order": "archived" } }, "technicians": { "T0": { "active": true, "home": "North", "skills": [ "network", "safety", "controls" ] }, "T1": { "active": true, "home": "North", "skills": [ "controls" ] }, "T2": { "active": true, "home": "North", "skills": [ "controls", "network", "safety" ] }, "T3": { "active": true, "home": "North", "skills": [ "network" ] }, "T4": { "active": true, "home": "North", "skills": [ "safety", "network", "controls" ] }, "T5": { "active": true, "home": "South", "skills": [ "safety", "network" ] }, "T6": { "active": false, "home": "South", "skills": [ "network", "safety" ] } }, "work_orders": { "J-1706-3": { "client": "CL-3", "day": "2025-08-23", "hub": "North", "new_slot": "S13", "service": "safety", "start": "13:00", "state": "rebooked" }, "J-2384-7": { "client": "CL-7", "day": "2025-08-23", "hub": "South", "service": "controls", "start": "10:00", "state": "cancelled" }, "J-2447-4": { "client": "CL-4", "day": "2025-08-23", "hub": "North", "new_slot": "S09", "service": "controls", "start": "10:00", "state": "rebooked" }, "J-2899-9": { "client": "CL-9", "day": "2025-08-24", "hub": "South", "service": "controls", "start": "13:00", "state": "cancelled" }, "J-2907-6": { "client": "CL-6", "day": "2025-08-23", "hub": "North", "new_slot": "S14", "service": "network", "start": "15:00", "state": "rebooked" }, "J-3409-11": { "client": "CL-11", "day": "2025-08-21", "hub": "South", "service": "safety", "start": "13:00", "state": "confirmed" }, "J-7516-1": { "client": "CL-1", "day": "2025-08-23", "hub": "North", "new_slot": "S05", "service": "safety", "start": "15:00", "state": "rebooked" }, "J-7560-8": { "client": "CL-8", "day": "2025-08-25", "hub": "North", "service": "network", "start": "15:00", "state": "cancelled" }, "J-8037-5": { "client": "CL-5", "day": "2025-08-23", "hub": "North", "new_slot": "S02", "service": "network", "start": "15:00", "state": "rebooked" }, "J-9220-2": { "client": "CL-2", "day": "2025-08-23", "hub": "North", "new_slot": "S00", "service": "network", "start": "13:00", "state": "rebooked" }, "J-9532-10": { "client": "CL-10", "day": "2025-08-21", "hub": "North", "service": "network", "start": "10:00", "state": "confirmed" }, "J-9563-0": { "client": "CL-0", "day": "2025-08-23", "hub": "North", "new_slot": "S07", "service": "network", "start": "15:00", "state": "rebooked" } }}1234#!/bin/shset -eumkdir -p /logs/verifier /workspace/outputsexec python3 -B -I /tests/grade.py123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329{ "accounts": { "CL-0": { "allow_remote": true, "tier": "standard" }, "CL-1": { "allow_remote": true, "tier": "standard" }, "CL-10": { "allow_remote": false, "tier": "priority" }, "CL-11": { "allow_remote": false, "tier": "standard" }, "CL-2": { "allow_remote": false, "tier": "priority" }, "CL-3": { "allow_remote": false, "tier": "priority" }, "CL-4": { "allow_remote": true, "tier": "priority" }, "CL-5": { "allow_remote": false, "tier": "standard" }, "CL-6": { "allow_remote": false, "tier": "priority" }, "CL-7": { "allow_remote": false, "tier": "standard" }, "CL-8": { "allow_remote": true, "tier": "priority" }, "CL-9": { "allow_remote": false, "tier": "priority" } }, "calendar": { "S00": { "crew": "T0", "day": "2025-08-24", "mode": "onsite", "start": "13:00", "state": "available" }, "S01": { "crew": "T5", "day": "2025-08-26", "mode": "onsite", "start": "08:00", "state": "available" }, "S02": { "crew": "T3", "day": "2025-08-26", "mode": "onsite", "start": "15:00", "state": "available" }, "S03": { "crew": "T2", "day": "2025-08-28", "mode": "remote", "start": "08:00", "state": "available" }, "S04": { "crew": "T6", "day": "2025-08-27", "mode": "onsite", "start": "10:00", "state": "available" }, "S05": { "crew": "T0", "day": "2025-08-24", "mode": "onsite", "start": "15:00", "state": "available" }, "S06": { "crew": "T0", "day": "2025-08-28", "mode": "onsite", "start": "15:00", "state": "available" }, "S07": { "crew": "T2", "day": "2025-08-25", "mode": "remote", "start": "10:00", "state": "available" }, "S08": { "crew": "T6", "day": "2025-08-27", "mode": "onsite", "start": "13:00", "state": "occupied" }, "S09": { "crew": "T2", "day": "2025-08-24", "mode": "onsite", "start": "10:00", "state": "available" }, "S10": { "crew": "T2", "day": "2025-08-30", "mode": "remote", "start": "15:00", "state": "available" }, "S11": { "crew": "T6", "day": "2025-08-29", "mode": "onsite", "start": "08:00", "state": "available" }, "S12": { "crew": "T4", "day": "2025-08-28", "mode": "remote", "start": "10:00", "state": "available" }, "S13": { "crew": "T4", "day": "2025-08-24", "mode": "onsite", "start": "10:00", "state": "available" }, "S14": { "crew": "T2", "day": "2025-08-24", "mode": "onsite", "start": "13:00", "state": "available" }, "S15": { "crew": "T0", "day": "2025-08-29", "mode": "onsite", "start": "08:00", "state": "available" } }, "dispatch": { "DISPATCH-OLD": { "status": "closed", "work_order": "archived" } }, "technicians": { "T0": { "active": true, "home": "North", "skills": [ "network", "safety", "controls" ] }, "T1": { "active": true, "home": "North", "skills": [ "controls" ] }, "T2": { "active": true, "home": "North", "skills": [ "controls", "network", "safety" ] }, "T3": { "active": true, "home": "North", "skills": [ "network" ] }, "T4": { "active": true, "home": "North", "skills": [ "safety", "network", "controls" ] }, "T5": { "active": true, "home": "South", "skills": [ "safety", "network" ] }, "T6": { "active": false, "home": "South", "skills": [ "network", "safety" ] } }, "work_orders": { "J-1706-3": { "client": "CL-3", "day": "2025-08-23", "hub": "North", "service": "safety", "start": "13:00", "state": "confirmed" }, "J-2384-7": { "client": "CL-7", "day": "2025-08-23", "hub": "South", "service": "controls", "start": "10:00", "state": "cancelled" }, "J-2447-4": { "client": "CL-4", "day": "2025-08-23", "hub": "North", "service": "controls", "start": "10:00", "state": "confirmed" }, "J-2899-9": { "client": "CL-9", "day": "2025-08-24", "hub": "South", "service": "controls", "start": "13:00", "state": "cancelled" }, "J-2907-6": { "client": "CL-6", "day": "2025-08-23", "hub": "North", "service": "network", "start": "15:00", "state": "confirmed" }, "J-3409-11": { "client": "CL-11", "day": "2025-08-21", "hub": "South", "service": "safety", "start": "13:00", "state": "confirmed" }, "J-7516-1": { "client": "CL-1", "day": "2025-08-23", "hub": "North", "service": "safety", "start": "15:00", "state": "confirmed" }, "J-7560-8": { "client": "CL-8", "day": "2025-08-25", "hub": "North", "service": "network", "start": "15:00", "state": "cancelled" }, "J-8037-5": { "client": "CL-5", "day": "2025-08-23", "hub": "North", "service": "network", "start": "15:00", "state": "confirmed" }, "J-9220-2": { "client": "CL-2", "day": "2025-08-23", "hub": "North", "service": "network", "start": "13:00", "state": "confirmed" }, "J-9532-10": { "client": "CL-10", "day": "2025-08-21", "hub": "North", "service": "network", "start": "10:00", "state": "confirmed" }, "J-9563-0": { "client": "CL-0", "day": "2025-08-23", "hub": "North", "service": "network", "start": "15:00", "state": "confirmed" } }}1234567891011121314151617181920212223242526"""Replay submitted mutations from the private verifier's initial state."""from types import ModuleTypeimport json
def check(spec, outputs, tests): replay = ModuleType('workflow_replay') exec(compile((tests/'replay.py').read_bytes(), 'replay.py', 'exec'), replay.__dict__) world = json.loads((tests/'world.json').read_text()) target = json.loads((tests/'target.json').read_text()) # Only fields whose starting and expected values differ may be changed. Attempts # to temporarily alter a protected field fail even when a later write restores it. allowed = { (app,key): {field for field,value in doc.items() if field not in world[app].get(key,{}) or not replay.same(world[app][key][field],value)} for app,records in target.items() for key,doc in records.items() } actions = replay.load_actions(outputs/'actions.jsonl') for event in actions: replay.apply(world,event) touched = set(event['fields']) if not touched <= allowed.get((event['app'],event['id']),set()): return False,'protected field or record write' if not replay.same(world,target): return False,'required business outcomes incomplete' return True,''12345678910111213141516171819202122232425262728{ "profile": "harbor-semantic-v1", "reward_key": "reward", "reward": { "range": [ 0, 1 ], "oracle_tolerance": 0, "floor_margin": 0.1 }, "resources": { "cpu": 1, "memory_mb": 4096, "disk_mb": 10240, "episode_timeout_s": 1800 }, "types": { "tags": [ "knowledge-work", "cross-app-workflows", "conditional-execution", "protected-state", "operations" ] }, "requires_credentials": false}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768"""Offline business-app client. Print usage with --help."""import argparseimport copyimport fcntlimport jsonimport osfrom pathlib import Path
def same(left, right): return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
def apply(world, action): if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}: raise ValueError('expected op, app, id, fields') op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields')) if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields: raise ValueError('unknown app, invalid id or empty fields') collection = world[app] if op == 'update' and key in collection: collection[key].update(copy.deepcopy(fields)) elif op == 'create' and key not in collection: collection[key] = copy.deepcopy(fields) else: raise ValueError(f'invalid {op} for {app}/{key}')
def load_actions(path): if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000): raise ValueError('invalid action log') if not path.exists(): return [] return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('op', choices=('apps','list','get','update','create')) parser.add_argument('app', nargs='?') parser.add_argument('id', nargs='?') parser.add_argument('fields', nargs='?', type=json.loads) args = parser.parse_args() world = json.loads(Path(__file__).with_name('world.json').read_text()) out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs')) out.mkdir(parents=True, exist_ok=True) log = out/'actions.jsonl' with (out/'.actions.lock').open('a') as lock: fcntl.flock(lock.fileno(), fcntl.LOCK_EX) for event in load_actions(log): apply(world,event) if args.op=='apps': value=sorted(world) elif args.op=='list': value=world[args.app] elif args.op=='get': value=world[args.app][args.id] else: event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields} apply(world,event) with log.open('a') as handle: handle.write(json.dumps(event,allow_nan=False)+'\n') value=world[args.app][args.id] print(json.dumps(value,sort_keys=True,allow_nan=False))
if __name__=='__main__': main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343{ "accounts": { "CL-0": { "allow_remote": true, "tier": "priority" }, "CL-1": { "allow_remote": false, "tier": "standard" }, "CL-10": { "allow_remote": false, "tier": "standard" }, "CL-11": { "allow_remote": true, "tier": "priority" }, "CL-12": { "allow_remote": false, "tier": "priority" }, "CL-2": { "allow_remote": false, "tier": "standard" }, "CL-3": { "allow_remote": true, "tier": "standard" }, "CL-4": { "allow_remote": false, "tier": "priority" }, "CL-5": { "allow_remote": true, "tier": "standard" }, "CL-6": { "allow_remote": true, "tier": "priority" }, "CL-7": { "allow_remote": false, "tier": "priority" }, "CL-8": { "allow_remote": false, "tier": "priority" }, "CL-9": { "allow_remote": false, "tier": "priority" } }, "calendar": { "S00": { "crew": "T0", "day": "2025-09-16", "mode": "onsite", "start": "08:00", "state": "available" }, "S01": { "crew": "T3", "day": "2025-09-17", "mode": "onsite", "start": "08:00", "state": "occupied" }, "S02": { "crew": "T2", "day": "2025-09-19", "mode": "remote", "start": "15:00", "state": "available" }, "S03": { "crew": "T3", "day": "2025-09-16", "mode": "onsite", "start": "15:00", "state": "available" }, "S04": { "crew": "T0", "day": "2025-09-19", "mode": "remote", "start": "13:00", "state": "available" }, "S05": { "crew": "T3", "day": "2025-09-21", "mode": "onsite", "start": "08:00", "state": "occupied" }, "S06": { "crew": "T2", "day": "2025-09-18", "mode": "onsite", "start": "10:00", "state": "available" }, "S07": { "crew": "T1", "day": "2025-09-21", "mode": "remote", "start": "15:00", "state": "available" }, "S08": { "crew": "T6", "day": "2025-09-20", "mode": "remote", "start": "08:00", "state": "occupied" }, "S09": { "crew": "T1", "day": "2025-09-22", "mode": "onsite", "start": "10:00", "state": "occupied" }, "S10": { "crew": "T5", "day": "2025-09-17", "mode": "onsite", "start": "10:00", "state": "available" }, "S11": { "crew": "T4", "day": "2025-09-22", "mode": "remote", "start": "15:00", "state": "available" }, "S12": { "crew": "T0", "day": "2025-09-21", "mode": "onsite", "start": "08:00", "state": "occupied" }, "S13": { "crew": "T1", "day": "2025-09-19", "mode": "remote", "start": "15:00", "state": "available" }, "S14": { "crew": "T2", "day": "2025-09-18", "mode": "remote", "start": "08:00", "state": "available" }, "S15": { "crew": "T1", "day": "2025-09-17", "mode": "remote", "start": "15:00", "state": "available" } }, "dispatch": { "DISPATCH-OLD": { "status": "closed", "work_order": "archived" } }, "technicians": { "T0": { "active": true, "home": "Central", "skills": [ "network", "safety", "controls" ] }, "T1": { "active": true, "home": "Central", "skills": [ "safety", "network", "controls" ] }, "T2": { "active": true, "home": "Central", "skills": [ "network" ] }, "T3": { "active": true, "home": "Central", "skills": [ "network", "controls" ] }, "T4": { "active": true, "home": "Central", "skills": [ "safety", "network", "controls" ] }, "T5": { "active": true, "home": "North", "skills": [ "safety", "network" ] }, "T6": { "active": false, "home": "North", "skills": [ "controls", "network", "safety" ] } }, "work_orders": { "J-1186-6": { "client": "CL-6", "day": "2025-09-14", "hub": "Central", "service": "network", "start": "10:00", "state": "cancelled" }, "J-1706-1": { "client": "CL-1", "day": "2025-09-15", "hub": "Central", "service": "network", "start": "15:00", "state": "confirmed" }, "J-1883-8": { "client": "CL-8", "day": "2025-09-14", "hub": "Central", "service": "controls", "start": "13:00", "state": "confirmed" }, "J-2427-3": { "client": "CL-3", "day": "2025-09-15", "hub": "Central", "service": "safety", "start": "10:00", "state": "confirmed" }, "J-4289-11": { "client": "CL-11", "day": "2025-09-15", "hub": "North", "service": "controls", "start": "08:00", "state": "confirmed" }, "J-4894-4": { "client": "CL-4", "day": "2025-09-15", "hub": "Central", "service": "safety", "start": "10:00", "state": "confirmed" }, "J-4909-12": { "client": "CL-12", "day": "2025-09-13", "hub": "Central", "service": "safety", "start": "15:00", "state": "cancelled" }, "J-7391-5": { "client": "CL-5", "day": "2025-09-15", "hub": "Central", "service": "network", "start": "15:00", "state": "confirmed" }, "J-8143-7": { "client": "CL-7", "day": "2025-09-16", "hub": "North", "service": "controls", "start": "15:00", "state": "cancelled" }, "J-8611-0": { "client": "CL-0", "day": "2025-09-15", "hub": "Central", "service": "safety", "start": "08:00", "state": "confirmed" }, "J-8942-9": { "client": "CL-9", "day": "2025-09-13", "hub": "Central", "service": "safety", "start": "10:00", "state": "confirmed" }, "J-9688-10": { "client": "CL-10", "day": "2025-09-15", "hub": "North", "service": "network", "start": "08:00", "state": "confirmed" }, "J-9806-2": { "client": "CL-2", "day": "2025-09-15", "hub": "Central", "service": "network", "start": "08:00", "state": "confirmed" } }}12345678910111213141516171819A field-service closure affects confirmed work orders at Central on 2025-09-15. Reschedule those orders only. Serve priority-tier accounts first, then standard. Within each tier sort by original start time and then work-order ID ascending. Each appointment needs one full slot for a technician active and skilled in the order's service.
Search available calendar slots from 2025-09-16 through 2025-09-20, inclusive. Onsite slots require the technician to be based at Central. Remote slots can use any home hub if the account allows remote service. Choose earliest day, then earliest start, then onsite before remote, then smallest slot ID in lexical order. Allocate one slot at a time in queue order. Remove each allocated slot from consideration for subsequent orders.
For a match update the calendar slot to `state=reserved` with `work_order` equal to the order ID. Set the work order `state=rebooked` and `new_slot` to the chosen slot ID; retain its original day and time. If no slot remains set only its `state=manual`, then create dispatch record `follow-<order ID>` with `work_order`, `client`, and `status=needs_slot`. Preserve all other fields and records.
Calculate the plan in the stated queue order using all earlier decisions. Once calculated, you may apply the resulting changes in any order or combine updates to the same record. The action log is checked for the final business state and for any write to a protected record or field.
Use the offline app client at `/workspace/inputs/apps.py`. Call it with python3. Run`apps` to discover apps, `list APP` to see its records, or `get APP ID` for one record.Write with `update APP ID '{"field":"value"}'` or `create APP ID '{"field":"value"}'`.The client records successful writes in `/workspace/outputs/actions.jsonl`.Apply exactly the required changes. Other records and fields must remain untouched,including temporary changes. Actions take effect in the local simulation only.
## Deliverable
Work in `/workspace`. Input files are under `/workspace/inputs/`. Put every deliverable in`/workspace/outputs/`; only that directory is graded. Leave the app action log in the outputs directory.123456789101112{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-8611-0"}, "id": "S00", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-9806-2"}, "id": "S03", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-1706-1"}, "id": "S06", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-7391-5"}, "id": "S14", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-2427-3"}, "id": "S15", "op": "update"}{"app": "dispatch", "fields": {"client": "CL-4", "status": "needs_slot", "work_order": "J-4894-4"}, "id": "follow-J-4894-4", "op": "create"}{"app": "work_orders", "fields": {"new_slot": "S06", "state": "rebooked"}, "id": "J-1706-1", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S15", "state": "rebooked"}, "id": "J-2427-3", "op": "update"}{"app": "work_orders", "fields": {"state": "manual"}, "id": "J-4894-4", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S14", "state": "rebooked"}, "id": "J-7391-5", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S00", "state": "rebooked"}, "id": "J-8611-0", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S03", "state": "rebooked"}, "id": "J-9806-2", "op": "update"}1234#!/bin/shset -eumkdir -p /workspace/outputscp -R /solution/files/. /workspace/outputs/12345678910111213141516171819202122232425262728293031323334353637383940414243444546schema_version = "1.3"
[task]name = "apex-gap/autom-field-service-rebooking-010-v2"
[metadata.apex_gap]capability_tags = ["cross-app-workflows", "conditional-execution", "protected-state", "operations"]dataset = "Original simulated workflows"job = "operations"seed = 10source = "local/original-automation-workflows"source_revision = "2"source_split = "synthetic"source_task_id = "autom-field-service-rebooking-010"template_family = "automation:field-service-rebooking"workflow_template = "field-service-rebooking"
[metadata.openenv_hf_sandbox]variant = "apex-gap-hfsandbox-v1"task_modified_for_hf_sandbox = truenetwork_enabled = true
[environment]docker_image = "ghcr.io/younesbelkada/apex@sha256:24969c952247033023872f87161a16e067003469506be63783bbaa5d96926bdf"workdir = "/workspace"cpus = 1memory_mb = 4096build_timeout_sec = 600network_mode = "public"
[agent]timeout_sec = 1800network_mode = "public"
[verifier]timeout_sec = 600network_mode = "public"environment_mode = "separate"
[verifier.environment]network_mode = "public"cpus = 1memory_mb = 4096
[[artifacts]]source = "/workspace/outputs"123456789{ "checks": [ { "id": "business-outcomes", "type": "custom", "module": "world_check" } ]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330"""Deterministic grader shared by converted knowledge-work tasks.
Runs inside the separate verifier sandbox. Reads /tests/expected.json, inspects thesubmitted /workspace/outputs tree and writes a binary reward plus per-check details.No model calls and no network.
expected.json: {"checks": [{"id": ..., "type": ..., ...}, ...]}Check types: answer field of outputs/answer.json; kind = number|text|choice|date|bool|list xlsx_range recalculated outputs/<file> vs tests/<target> over sheet!range (SpreadsheetBench rules) xlsx_cell recalculated outputs/<file> sheet!cell vs value with tolerance (optional alt_values) file_contains outputs/<file> text (docx/pdf/ics/eml/txt) must contain every needle custom tests/<module>.py defines check(spec, outputs_dir, tests_dir) -> (bool, str)"""
import datetime as dtimport jsonimport reimport shutilimport subprocessimport sysimport tempfileimport unicodedatafrom pathlib import Path
OUT = Path("/workspace/outputs")TESTS = Path("/tests")LOGS = Path("/logs/verifier")
def norm_text(v): v = unicodedata.normalize("NFKC", str(v)).casefold() v = re.sub(r"[‘’“”]", "'", v) v = re.sub(r"[^\w%.$/-]+", " ", v) return " ".join(v.split()).strip(" .")
def to_number(v): if isinstance(v, bool): raise ValueError("bool") if isinstance(v, (int, float)): return float(v) s = str(v).strip().replace(",", "").replace("$", "").replace("−", "-") neg = s.startswith("(") and s.endswith(")") s = s.strip("()").strip() pct = s.endswith("%") s = s.rstrip("%").strip() s = re.sub(r"\s*(usd|dollars|million|billion|thousand|m|bn|k)$", "", s, flags=re.I) x = float(s) x = -x if neg else x return x / 100 if pct else x
def number_ok(got, want, rel, abs_): try: g = to_number(got) except (TypeError, ValueError): return False w = float(want) tol = max(abs_, rel * abs(w)) # "12.5%" may mean the ratio 0.125 or the percent number 12.5; the gold fixes which. candidates = [g, g * 100] if isinstance(got, str) and got.strip().endswith("%") else [g] return any(abs(c - w) <= tol for c in candidates)
def parse_date(v): if isinstance(v, (dt.date, dt.datetime)): return v if isinstance(v, dt.date) else v.date() s = str(v).strip() for fmt in ("%Y-%m-%d", "%m/%d/%Y", "%m/%d/%y", "%d %B %Y", "%B %d, %Y", "%b %d, %Y", "%Y/%m/%d"): try: return dt.datetime.strptime(s, fmt).date() except ValueError: continue raise ValueError(s)
def check_answer(check, answers): key = check["field"] if key not in answers: return False, f"missing field {key!r}" got, want, kind = answers[key], check["value"], check.get("kind", "text") if kind == "number": ok = number_ok(got, want, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01)) if not ok and check.get("percent_either"): ok = number_ok(got, want * 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) * 100) or ( number_ok(got, want / 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) / 100) ) elif kind == "date": try: ok = parse_date(got) == parse_date(want) except ValueError: ok = False elif kind == "bool": g = norm_text(got) ok = g in {"yes", "true"} if want else g in {"no", "false"} elif kind == "choice": ok = norm_text(got) == norm_text(want) elif kind == "list": if not isinstance(got, list): return False, f"{key}: expected a JSON list" # Filenames may be given with a directory prefix; compare base names. base = lambda x: norm_text(str(x).replace("\\", "/").rsplit("/", 1)[-1]) ok = sorted(base(x) for x in got) == sorted(base(x) for x in want) else: accepted = check.get("accept", [want]) ok = norm_text(got) in {norm_text(a) for a in accepted} return ok, "" if ok else f"{key}: got {got!r}"
# LibreOffice keeps cached formula values on load unless told otherwise; force a full recalculation.RECALC_PROFILE = """<?xml version="1.0" encoding="UTF-8"?><oor:items xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema"><item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="OOXMLRecalcMode" oor:op="fuse"><value>0</value></prop></item><item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="ODFRecalcMode" oor:op="fuse"><value>0</value></prop></item></oor:items>"""
def recalc(path, tmp): dest = Path(tmp) / f"recalc-{len(list(Path(tmp).glob('recalc-*')))}" dest.mkdir() profile = Path(tmp) / "lo-profile" if not profile.exists(): (profile / "user").mkdir(parents=True) (profile / "user" / "registrymodifications.xcu").write_text(RECALC_PROFILE) subprocess.run( ["soffice", f"-env:UserInstallation=file://{profile}", "--headless", "--calc", "--convert-to", "xlsx:Calc MS Excel 2007 XML", "--outdir", str(dest), str(path)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=180, check=False, ) out = dest / (Path(path).stem + ".xlsx") return out if out.exists() else Path(path)
def cell_value(v): if isinstance(v, (int, float)) and not isinstance(v, bool): return round(float(v), 2) if isinstance(v, dt.datetime): return round((v - dt.datetime(1899, 12, 30)).total_seconds() / 86400.0, 0) if isinstance(v, dt.time): return v.strftime("%H:%M") if isinstance(v, str): try: return round(float(v), 2) except ValueError: return v.strip() return v
def time_of(v): """A time or a day fraction in [0, 1) as HH:MM, rounded to the nearest second first. Calc and Excel store a time as that fraction; openpyxl returns a time only for time-formatted cells.""" if isinstance(v, dt.time): v = (v.hour * 3600 + v.minute * 60 + v.second + v.microsecond / 1e6) / 86400 if isinstance(v, (int, float)) and not isinstance(v, bool) and 0 <= v < 1: return (dt.datetime(1899, 12, 30) + dt.timedelta(seconds=round(v * 86400))).strftime("%H:%M") return None
def same_cell(a, b): if isinstance(a, dt.time) is not isinstance(b, dt.time): n = b if isinstance(a, dt.time) else a if time_of(n) is not None: # a time against a plain day fraction return time_of(a) == time_of(b) a, b = cell_value(a), cell_value(b) if a in (None, "") and b in (None, ""): return True return type(a) is type(b) and a == b
ERRORS = {"#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A"}
def is_error(v): return isinstance(v, str) and (v in ERRORS or v.startswith("Err:"))
def cells(rng): if ":" not in rng: return [rng] from openpyxl.utils import range_boundaries, get_column_letter
c1, r1, c2, r2 = range_boundaries(rng) return [f"{get_column_letter(c)}{r}" for r in range(r1, r2 + 1) for c in range(c1, c2 + 1)]
def load(path, tmp): import openpyxl
return openpyxl.load_workbook(recalc(path, tmp), data_only=True)
def check_xlsx_range(check, tmp, cache): sub = OUT / check["file"] if not sub.is_file(): return False, f"missing output {check['file']}" if sub not in cache: cache[sub] = load(sub, tmp) tgt = TESTS / check["target"] if tgt not in cache: cache[tgt] = load(tgt, tmp) got, want = cache[sub], cache[tgt] cached = None # the target's stored (Excel-computed) values, read only when Calc errs for sheet, rng in check["ranges"]: sheet = sheet or want.sheetnames[0] if sheet not in got.sheetnames: return False, f"sheet {sheet!r} missing" for name in cells(rng): w = want[sheet][name].value if is_error(w): # LibreOffice could not evaluate the gold formula (e.g. XLOOKUP, FILTER in Calc 7.4). # The value Excel stored is the intended answer. if cached is None: import openpyxl
cached = openpyxl.load_workbook(tgt, data_only=True) c = cached[sheet][name].value if sheet in cached.sheetnames else None if c is not None and not is_error(c): w = c if not same_cell(w, got[sheet][name].value): return False, f"{sheet}!{name}: want {w!r} got {got[sheet][name].value!r}" return True, ""
def check_xlsx_cell(check, tmp, cache): sub = OUT / check["file"] if not sub.is_file(): return False, f"missing output {check['file']}" if sub not in cache: cache[sub] = load(sub, tmp) wb = cache[sub] if check["sheet"] not in wb.sheetnames: return False, f"sheet {check['sheet']!r} missing" got = wb[check["sheet"]][check["cell"]].value want = check["value"] if isinstance(want, (int, float)): # alt_values: other accepted golds where the source admits more than one reading. ok = got is not None and any(number_ok(got, w, check.get("rel_tol", 0.0), check.get("abs_tol", 0.01)) for w in [want, *check.get("alt_values", [])]) else: ok = norm_text(got) == norm_text(want) return ok, "" if ok else f"{check['sheet']}!{check['cell']}: want {want!r} got {got!r}"
def text_of(path): suffix = path.suffix.lower() if suffix == ".docx": import docx
d = docx.Document(path) parts = [p.text for p in d.paragraphs] for t in d.tables: parts += [c.text for row in t.rows for c in row.cells] return "\n".join(parts) if suffix == ".pdf": import pdfplumber
with pdfplumber.open(path) as pdf: return "\n".join(page.extract_text() or "" for page in pdf.pages) return path.read_text(errors="replace")
def check_file_contains(check, tmp, cache): sub = OUT / check["file"] if not sub.is_file(): return False, f"missing output {check['file']}" text = text_of(sub) hay = text if check.get("case_sensitive") else text.casefold() for needle in check["needles"]: n = needle if check.get("case_sensitive") else needle.casefold() if n not in hay: return False, f"{check['file']} lacks {needle!r}" return True, ""
def main(): LOGS.mkdir(parents=True, exist_ok=True) reward_path = LOGS / "reward.txt" reward_path.write_text("0\n") spec = json.loads((TESTS / "expected.json").read_text()) answers, details = {}, [] answer_file = OUT / "answer.json" if answer_file.is_file(): try: answers = json.loads(answer_file.read_text()) if not isinstance(answers, dict): answers = {} except json.JSONDecodeError: answers = {} tmp = tempfile.mkdtemp() cache = {} try: for check in spec["checks"]: try: if check["type"] == "answer": ok, why = check_answer(check, answers) elif check["type"] == "xlsx_range": ok, why = check_xlsx_range(check, tmp, cache) elif check["type"] == "xlsx_cell": ok, why = check_xlsx_cell(check, tmp, cache) elif check["type"] == "file_contains": ok, why = check_file_contains(check, tmp, cache) elif check["type"] == "custom": import importlib.util
spec_ = importlib.util.spec_from_file_location("custom_check", TESTS / f"{check['module']}.py") mod = importlib.util.module_from_spec(spec_) spec_.loader.exec_module(mod) ok, why = mod.check(check, OUT, TESTS) else: ok, why = False, f"unknown check type {check['type']}" except Exception as exc: # a malformed submission fails the check, not the grader ok, why = False, f"{type(exc).__name__}: {exc}" details.append({"id": check["id"], "passed": ok, "detail": why}) finally: shutil.rmtree(tmp, ignore_errors=True) passed = sum(d["passed"] for d in details) total = len(details) reward = 1 if total and passed == total else 0 (LOGS / "details.json").write_text(json.dumps({"passed": passed, "total": total, "checks": details}, indent=1)) reward_path.write_text(f"{reward}\n") print(f"{passed}/{total} checks passed; reward {reward}")
if __name__ == "__main__": sys.exit(main())1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768"""Offline business-app client. Print usage with --help."""import argparseimport copyimport fcntlimport jsonimport osfrom pathlib import Path
def same(left, right): return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
def apply(world, action): if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}: raise ValueError('expected op, app, id, fields') op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields')) if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields: raise ValueError('unknown app, invalid id or empty fields') collection = world[app] if op == 'update' and key in collection: collection[key].update(copy.deepcopy(fields)) elif op == 'create' and key not in collection: collection[key] = copy.deepcopy(fields) else: raise ValueError(f'invalid {op} for {app}/{key}')
def load_actions(path): if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000): raise ValueError('invalid action log') if not path.exists(): return [] return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('op', choices=('apps','list','get','update','create')) parser.add_argument('app', nargs='?') parser.add_argument('id', nargs='?') parser.add_argument('fields', nargs='?', type=json.loads) args = parser.parse_args() world = json.loads(Path(__file__).with_name('world.json').read_text()) out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs')) out.mkdir(parents=True, exist_ok=True) log = out/'actions.jsonl' with (out/'.actions.lock').open('a') as lock: fcntl.flock(lock.fileno(), fcntl.LOCK_EX) for event in load_actions(log): apply(world,event) if args.op=='apps': value=sorted(world) elif args.op=='list': value=world[args.app] elif args.op=='get': value=world[args.app][args.id] else: event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields} apply(world,event) with log.open('a') as handle: handle.write(json.dumps(event,allow_nan=False)+'\n') value=world[args.app][args.id] print(json.dumps(value,sort_keys=True,allow_nan=False))
if __name__=='__main__': main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358{ "accounts": { "CL-0": { "allow_remote": true, "tier": "priority" }, "CL-1": { "allow_remote": false, "tier": "standard" }, "CL-10": { "allow_remote": false, "tier": "standard" }, "CL-11": { "allow_remote": true, "tier": "priority" }, "CL-12": { "allow_remote": false, "tier": "priority" }, "CL-2": { "allow_remote": false, "tier": "standard" }, "CL-3": { "allow_remote": true, "tier": "standard" }, "CL-4": { "allow_remote": false, "tier": "priority" }, "CL-5": { "allow_remote": true, "tier": "standard" }, "CL-6": { "allow_remote": true, "tier": "priority" }, "CL-7": { "allow_remote": false, "tier": "priority" }, "CL-8": { "allow_remote": false, "tier": "priority" }, "CL-9": { "allow_remote": false, "tier": "priority" } }, "calendar": { "S00": { "crew": "T0", "day": "2025-09-16", "mode": "onsite", "start": "08:00", "state": "reserved", "work_order": "J-8611-0" }, "S01": { "crew": "T3", "day": "2025-09-17", "mode": "onsite", "start": "08:00", "state": "occupied" }, "S02": { "crew": "T2", "day": "2025-09-19", "mode": "remote", "start": "15:00", "state": "available" }, "S03": { "crew": "T3", "day": "2025-09-16", "mode": "onsite", "start": "15:00", "state": "reserved", "work_order": "J-9806-2" }, "S04": { "crew": "T0", "day": "2025-09-19", "mode": "remote", "start": "13:00", "state": "available" }, "S05": { "crew": "T3", "day": "2025-09-21", "mode": "onsite", "start": "08:00", "state": "occupied" }, "S06": { "crew": "T2", "day": "2025-09-18", "mode": "onsite", "start": "10:00", "state": "reserved", "work_order": "J-1706-1" }, "S07": { "crew": "T1", "day": "2025-09-21", "mode": "remote", "start": "15:00", "state": "available" }, "S08": { "crew": "T6", "day": "2025-09-20", "mode": "remote", "start": "08:00", "state": "occupied" }, "S09": { "crew": "T1", "day": "2025-09-22", "mode": "onsite", "start": "10:00", "state": "occupied" }, "S10": { "crew": "T5", "day": "2025-09-17", "mode": "onsite", "start": "10:00", "state": "available" }, "S11": { "crew": "T4", "day": "2025-09-22", "mode": "remote", "start": "15:00", "state": "available" }, "S12": { "crew": "T0", "day": "2025-09-21", "mode": "onsite", "start": "08:00", "state": "occupied" }, "S13": { "crew": "T1", "day": "2025-09-19", "mode": "remote", "start": "15:00", "state": "available" }, "S14": { "crew": "T2", "day": "2025-09-18", "mode": "remote", "start": "08:00", "state": "reserved", "work_order": "J-7391-5" }, "S15": { "crew": "T1", "day": "2025-09-17", "mode": "remote", "start": "15:00", "state": "reserved", "work_order": "J-2427-3" } }, "dispatch": { "DISPATCH-OLD": { "status": "closed", "work_order": "archived" }, "follow-J-4894-4": { "client": "CL-4", "status": "needs_slot", "work_order": "J-4894-4" } }, "technicians": { "T0": { "active": true, "home": "Central", "skills": [ "network", "safety", "controls" ] }, "T1": { "active": true, "home": "Central", "skills": [ "safety", "network", "controls" ] }, "T2": { "active": true, "home": "Central", "skills": [ "network" ] }, "T3": { "active": true, "home": "Central", "skills": [ "network", "controls" ] }, "T4": { "active": true, "home": "Central", "skills": [ "safety", "network", "controls" ] }, "T5": { "active": true, "home": "North", "skills": [ "safety", "network" ] }, "T6": { "active": false, "home": "North", "skills": [ "controls", "network", "safety" ] } }, "work_orders": { "J-1186-6": { "client": "CL-6", "day": "2025-09-14", "hub": "Central", "service": "network", "start": "10:00", "state": "cancelled" }, "J-1706-1": { "client": "CL-1", "day": "2025-09-15", "hub": "Central", "new_slot": "S06", "service": "network", "start": "15:00", "state": "rebooked" }, "J-1883-8": { "client": "CL-8", "day": "2025-09-14", "hub": "Central", "service": "controls", "start": "13:00", "state": "confirmed" }, "J-2427-3": { "client": "CL-3", "day": "2025-09-15", "hub": "Central", "new_slot": "S15", "service": "safety", "start": "10:00", "state": "rebooked" }, "J-4289-11": { "client": "CL-11", "day": "2025-09-15", "hub": "North", "service": "controls", "start": "08:00", "state": "confirmed" }, "J-4894-4": { "client": "CL-4", "day": "2025-09-15", "hub": "Central", "service": "safety", "start": "10:00", "state": "manual" }, "J-4909-12": { "client": "CL-12", "day": "2025-09-13", "hub": "Central", "service": "safety", "start": "15:00", "state": "cancelled" }, "J-7391-5": { "client": "CL-5", "day": "2025-09-15", "hub": "Central", "new_slot": "S14", "service": "network", "start": "15:00", "state": "rebooked" }, "J-8143-7": { "client": "CL-7", "day": "2025-09-16", "hub": "North", "service": "controls", "start": "15:00", "state": "cancelled" }, "J-8611-0": { "client": "CL-0", "day": "2025-09-15", "hub": "Central", "new_slot": "S00", "service": "safety", "start": "08:00", "state": "rebooked" }, "J-8942-9": { "client": "CL-9", "day": "2025-09-13", "hub": "Central", "service": "safety", "start": "10:00", "state": "confirmed" }, "J-9688-10": { "client": "CL-10", "day": "2025-09-15", "hub": "North", "service": "network", "start": "08:00", "state": "confirmed" }, "J-9806-2": { "client": "CL-2", "day": "2025-09-15", "hub": "Central", "new_slot": "S03", "service": "network", "start": "08:00", "state": "rebooked" } }}1234#!/bin/shset -eumkdir -p /logs/verifier /workspace/outputsexec python3 -B -I /tests/grade.py123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343{ "accounts": { "CL-0": { "allow_remote": true, "tier": "priority" }, "CL-1": { "allow_remote": false, "tier": "standard" }, "CL-10": { "allow_remote": false, "tier": "standard" }, "CL-11": { "allow_remote": true, "tier": "priority" }, "CL-12": { "allow_remote": false, "tier": "priority" }, "CL-2": { "allow_remote": false, "tier": "standard" }, "CL-3": { "allow_remote": true, "tier": "standard" }, "CL-4": { "allow_remote": false, "tier": "priority" }, "CL-5": { "allow_remote": true, "tier": "standard" }, "CL-6": { "allow_remote": true, "tier": "priority" }, "CL-7": { "allow_remote": false, "tier": "priority" }, "CL-8": { "allow_remote": false, "tier": "priority" }, "CL-9": { "allow_remote": false, "tier": "priority" } }, "calendar": { "S00": { "crew": "T0", "day": "2025-09-16", "mode": "onsite", "start": "08:00", "state": "available" }, "S01": { "crew": "T3", "day": "2025-09-17", "mode": "onsite", "start": "08:00", "state": "occupied" }, "S02": { "crew": "T2", "day": "2025-09-19", "mode": "remote", "start": "15:00", "state": "available" }, "S03": { "crew": "T3", "day": "2025-09-16", "mode": "onsite", "start": "15:00", "state": "available" }, "S04": { "crew": "T0", "day": "2025-09-19", "mode": "remote", "start": "13:00", "state": "available" }, "S05": { "crew": "T3", "day": "2025-09-21", "mode": "onsite", "start": "08:00", "state": "occupied" }, "S06": { "crew": "T2", "day": "2025-09-18", "mode": "onsite", "start": "10:00", "state": "available" }, "S07": { "crew": "T1", "day": "2025-09-21", "mode": "remote", "start": "15:00", "state": "available" }, "S08": { "crew": "T6", "day": "2025-09-20", "mode": "remote", "start": "08:00", "state": "occupied" }, "S09": { "crew": "T1", "day": "2025-09-22", "mode": "onsite", "start": "10:00", "state": "occupied" }, "S10": { "crew": "T5", "day": "2025-09-17", "mode": "onsite", "start": "10:00", "state": "available" }, "S11": { "crew": "T4", "day": "2025-09-22", "mode": "remote", "start": "15:00", "state": "available" }, "S12": { "crew": "T0", "day": "2025-09-21", "mode": "onsite", "start": "08:00", "state": "occupied" }, "S13": { "crew": "T1", "day": "2025-09-19", "mode": "remote", "start": "15:00", "state": "available" }, "S14": { "crew": "T2", "day": "2025-09-18", "mode": "remote", "start": "08:00", "state": "available" }, "S15": { "crew": "T1", "day": "2025-09-17", "mode": "remote", "start": "15:00", "state": "available" } }, "dispatch": { "DISPATCH-OLD": { "status": "closed", "work_order": "archived" } }, "technicians": { "T0": { "active": true, "home": "Central", "skills": [ "network", "safety", "controls" ] }, "T1": { "active": true, "home": "Central", "skills": [ "safety", "network", "controls" ] }, "T2": { "active": true, "home": "Central", "skills": [ "network" ] }, "T3": { "active": true, "home": "Central", "skills": [ "network", "controls" ] }, "T4": { "active": true, "home": "Central", "skills": [ "safety", "network", "controls" ] }, "T5": { "active": true, "home": "North", "skills": [ "safety", "network" ] }, "T6": { "active": false, "home": "North", "skills": [ "controls", "network", "safety" ] } }, "work_orders": { "J-1186-6": { "client": "CL-6", "day": "2025-09-14", "hub": "Central", "service": "network", "start": "10:00", "state": "cancelled" }, "J-1706-1": { "client": "CL-1", "day": "2025-09-15", "hub": "Central", "service": "network", "start": "15:00", "state": "confirmed" }, "J-1883-8": { "client": "CL-8", "day": "2025-09-14", "hub": "Central", "service": "controls", "start": "13:00", "state": "confirmed" }, "J-2427-3": { "client": "CL-3", "day": "2025-09-15", "hub": "Central", "service": "safety", "start": "10:00", "state": "confirmed" }, "J-4289-11": { "client": "CL-11", "day": "2025-09-15", "hub": "North", "service": "controls", "start": "08:00", "state": "confirmed" }, "J-4894-4": { "client": "CL-4", "day": "2025-09-15", "hub": "Central", "service": "safety", "start": "10:00", "state": "confirmed" }, "J-4909-12": { "client": "CL-12", "day": "2025-09-13", "hub": "Central", "service": "safety", "start": "15:00", "state": "cancelled" }, "J-7391-5": { "client": "CL-5", "day": "2025-09-15", "hub": "Central", "service": "network", "start": "15:00", "state": "confirmed" }, "J-8143-7": { "client": "CL-7", "day": "2025-09-16", "hub": "North", "service": "controls", "start": "15:00", "state": "cancelled" }, "J-8611-0": { "client": "CL-0", "day": "2025-09-15", "hub": "Central", "service": "safety", "start": "08:00", "state": "confirmed" }, "J-8942-9": { "client": "CL-9", "day": "2025-09-13", "hub": "Central", "service": "safety", "start": "10:00", "state": "confirmed" }, "J-9688-10": { "client": "CL-10", "day": "2025-09-15", "hub": "North", "service": "network", "start": "08:00", "state": "confirmed" }, "J-9806-2": { "client": "CL-2", "day": "2025-09-15", "hub": "Central", "service": "network", "start": "08:00", "state": "confirmed" } }}1234567891011121314151617181920212223242526"""Replay submitted mutations from the private verifier's initial state."""from types import ModuleTypeimport json
def check(spec, outputs, tests): replay = ModuleType('workflow_replay') exec(compile((tests/'replay.py').read_bytes(), 'replay.py', 'exec'), replay.__dict__) world = json.loads((tests/'world.json').read_text()) target = json.loads((tests/'target.json').read_text()) # Only fields whose starting and expected values differ may be changed. Attempts # to temporarily alter a protected field fail even when a later write restores it. allowed = { (app,key): {field for field,value in doc.items() if field not in world[app].get(key,{}) or not replay.same(world[app][key][field],value)} for app,records in target.items() for key,doc in records.items() } actions = replay.load_actions(outputs/'actions.jsonl') for event in actions: replay.apply(world,event) touched = set(event['fields']) if not touched <= allowed.get((event['app'],event['id']),set()): return False,'protected field or record write' if not replay.same(world,target): return False,'required business outcomes incomplete' return True,''12345678910111213141516171819202122232425262728{ "profile": "harbor-semantic-v1", "reward_key": "reward", "reward": { "range": [ 0, 1 ], "oracle_tolerance": 0, "floor_margin": 0.1 }, "resources": { "cpu": 1, "memory_mb": 4096, "disk_mb": 10240, "episode_timeout_s": 1800 }, "types": { "tags": [ "knowledge-work", "cross-app-workflows", "conditional-execution", "protected-state", "operations" ] }, "requires_credentials": false}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768"""Offline business-app client. Print usage with --help."""import argparseimport copyimport fcntlimport jsonimport osfrom pathlib import Path
def same(left, right): return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
def apply(world, action): if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}: raise ValueError('expected op, app, id, fields') op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields')) if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields: raise ValueError('unknown app, invalid id or empty fields') collection = world[app] if op == 'update' and key in collection: collection[key].update(copy.deepcopy(fields)) elif op == 'create' and key not in collection: collection[key] = copy.deepcopy(fields) else: raise ValueError(f'invalid {op} for {app}/{key}')
def load_actions(path): if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000): raise ValueError('invalid action log') if not path.exists(): return [] return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('op', choices=('apps','list','get','update','create')) parser.add_argument('app', nargs='?') parser.add_argument('id', nargs='?') parser.add_argument('fields', nargs='?', type=json.loads) args = parser.parse_args() world = json.loads(Path(__file__).with_name('world.json').read_text()) out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs')) out.mkdir(parents=True, exist_ok=True) log = out/'actions.jsonl' with (out/'.actions.lock').open('a') as lock: fcntl.flock(lock.fileno(), fcntl.LOCK_EX) for event in load_actions(log): apply(world,event) if args.op=='apps': value=sorted(world) elif args.op=='list': value=world[args.app] elif args.op=='get': value=world[args.app][args.id] else: event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields} apply(world,event) with log.open('a') as handle: handle.write(json.dumps(event,allow_nan=False)+'\n') value=world[args.app][args.id] print(json.dumps(value,sort_keys=True,allow_nan=False))
if __name__=='__main__': main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340{ "accounts": { "CL-0": { "allow_remote": true, "tier": "priority" }, "CL-1": { "allow_remote": false, "tier": "priority" }, "CL-2": { "allow_remote": false, "tier": "standard" }, "CL-3": { "allow_remote": true, "tier": "standard" }, "CL-4": { "allow_remote": false, "tier": "priority" }, "CL-5": { "allow_remote": false, "tier": "standard" }, "CL-6": { "allow_remote": false, "tier": "standard" }, "CL-7": { "allow_remote": false, "tier": "priority" }, "CL-8": { "allow_remote": true, "tier": "priority" }, "CL-9": { "allow_remote": false, "tier": "priority" } }, "calendar": { "S00": { "crew": "T0", "day": "2025-10-09", "mode": "onsite", "start": "08:00", "state": "available" }, "S01": { "crew": "T0", "day": "2025-10-14", "mode": "remote", "start": "15:00", "state": "occupied" }, "S02": { "crew": "T2", "day": "2025-10-11", "mode": "remote", "start": "13:00", "state": "available" }, "S03": { "crew": "T5", "day": "2025-10-12", "mode": "onsite", "start": "15:00", "state": "available" }, "S04": { "crew": "T3", "day": "2025-10-10", "mode": "remote", "start": "15:00", "state": "available" }, "S05": { "crew": "T1", "day": "2025-10-14", "mode": "onsite", "start": "10:00", "state": "available" }, "S06": { "crew": "T3", "day": "2025-10-11", "mode": "remote", "start": "13:00", "state": "occupied" }, "S07": { "crew": "T1", "day": "2025-10-11", "mode": "onsite", "start": "15:00", "state": "available" }, "S08": { "crew": "T1", "day": "2025-10-14", "mode": "remote", "start": "08:00", "state": "available" }, "S09": { "crew": "T4", "day": "2025-10-14", "mode": "onsite", "start": "08:00", "state": "available" }, "S10": { "crew": "T4", "day": "2025-10-12", "mode": "remote", "start": "10:00", "state": "occupied" }, "S11": { "crew": "T2", "day": "2025-10-11", "mode": "remote", "start": "08:00", "state": "available" }, "S12": { "crew": "T5", "day": "2025-10-11", "mode": "onsite", "start": "08:00", "state": "available" }, "S13": { "crew": "T4", "day": "2025-10-11", "mode": "onsite", "start": "10:00", "state": "occupied" }, "S14": { "crew": "T0", "day": "2025-10-09", "mode": "remote", "start": "13:00", "state": "available" }, "S15": { "crew": "T2", "day": "2025-10-09", "mode": "onsite", "start": "13:00", "state": "available" }, "S16": { "crew": "T3", "day": "2025-10-10", "mode": "remote", "start": "10:00", "state": "available" }, "S17": { "crew": "T0", "day": "2025-10-12", "mode": "remote", "start": "10:00", "state": "available" }, "S18": { "crew": "T5", "day": "2025-10-13", "mode": "onsite", "start": "10:00", "state": "available" }, "S19": { "crew": "T5", "day": "2025-10-14", "mode": "remote", "start": "10:00", "state": "available" }, "S20": { "crew": "T3", "day": "2025-10-11", "mode": "onsite", "start": "15:00", "state": "available" } }, "dispatch": { "DISPATCH-OLD": { "status": "closed", "work_order": "archived" } }, "technicians": { "T0": { "active": true, "home": "South", "skills": [ "network", "safety", "controls" ] }, "T1": { "active": true, "home": "South", "skills": [ "safety", "network" ] }, "T2": { "active": true, "home": "South", "skills": [ "safety", "controls" ] }, "T3": { "active": true, "home": "South", "skills": [ "network" ] }, "T4": { "active": true, "home": "South", "skills": [ "network", "controls", "safety" ] }, "T5": { "active": true, "home": "Central", "skills": [ "network", "controls" ] }, "T6": { "active": false, "home": "Central", "skills": [ "safety", "network" ] } }, "work_orders": { "J-2564-0": { "client": "CL-0", "day": "2025-10-08", "hub": "South", "service": "controls", "start": "13:00", "state": "confirmed" }, "J-3625-4": { "client": "CL-4", "day": "2025-10-08", "hub": "South", "service": "controls", "start": "10:00", "state": "confirmed" }, "J-4083-3": { "client": "CL-3", "day": "2025-10-08", "hub": "South", "service": "safety", "start": "13:00", "state": "confirmed" }, "J-5742-6": { "client": "CL-6", "day": "2025-10-10", "hub": "South", "service": "safety", "start": "08:00", "state": "confirmed" }, "J-5760-5": { "client": "CL-5", "day": "2025-10-08", "hub": "South", "service": "network", "start": "15:00", "state": "confirmed" }, "J-5872-1": { "client": "CL-1", "day": "2025-10-08", "hub": "South", "service": "controls", "start": "08:00", "state": "confirmed" }, "J-6802-7": { "client": "CL-7", "day": "2025-10-08", "hub": "Central", "service": "network", "start": "13:00", "state": "confirmed" }, "J-9105-9": { "client": "CL-9", "day": "2025-10-06", "hub": "South", "service": "controls", "start": "08:00", "state": "cancelled" }, "J-9264-2": { "client": "CL-2", "day": "2025-10-08", "hub": "South", "service": "controls", "start": "13:00", "state": "confirmed" }, "J-9575-8": { "client": "CL-8", "day": "2025-10-07", "hub": "Central", "service": "network", "start": "15:00", "state": "cancelled" } }}12345678910111213141516171819A field-service closure affects confirmed work orders at South on 2025-10-08. Reschedule those orders only. Serve priority-tier accounts first, then standard. Within each tier sort by original start time and then work-order ID ascending. Each appointment needs one full slot for a technician active and skilled in the order's service.
Search available calendar slots from 2025-10-09 through 2025-10-12, inclusive. Onsite slots require the technician to be based at South. Remote slots can use any home hub if the account allows remote service. Choose earliest day, then earliest start, then onsite before remote, then smallest slot ID in lexical order. Allocate one slot at a time in queue order. Remove each allocated slot from consideration for subsequent orders.
For a match update the calendar slot to `state=reserved` with `work_order` equal to the order ID. Set the work order `state=rebooked` and `new_slot` to the chosen slot ID; retain its original day and time. If no slot remains set only its `state=manual`, then create dispatch record `follow-<order ID>` with `work_order`, `client`, and `status=needs_slot`. Preserve all other fields and records.
Calculate the plan in the stated queue order using all earlier decisions. Once calculated, you may apply the resulting changes in any order or combine updates to the same record. The action log is checked for the final business state and for any write to a protected record or field.
Use the offline app client at `/workspace/inputs/apps.py`. Call it with python3. Run`apps` to discover apps, `list APP` to see its records, or `get APP ID` for one record.Write with `update APP ID '{"field":"value"}'` or `create APP ID '{"field":"value"}'`.The client records successful writes in `/workspace/outputs/actions.jsonl`.Apply exactly the required changes. Other records and fields must remain untouched,including temporary changes. Actions take effect in the local simulation only.
## Deliverable
Work in `/workspace`. Input files are under `/workspace/inputs/`. Put every deliverable in`/workspace/outputs/`; only that directory is graded. Leave the app action log in the outputs directory.123456789101112{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-5872-1"}, "id": "S00", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-5760-5"}, "id": "S07", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-4083-3"}, "id": "S11", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-2564-0"}, "id": "S14", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-3625-4"}, "id": "S15", "op": "update"}{"app": "dispatch", "fields": {"client": "CL-2", "status": "needs_slot", "work_order": "J-9264-2"}, "id": "follow-J-9264-2", "op": "create"}{"app": "work_orders", "fields": {"new_slot": "S14", "state": "rebooked"}, "id": "J-2564-0", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S15", "state": "rebooked"}, "id": "J-3625-4", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S11", "state": "rebooked"}, "id": "J-4083-3", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S07", "state": "rebooked"}, "id": "J-5760-5", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S00", "state": "rebooked"}, "id": "J-5872-1", "op": "update"}{"app": "work_orders", "fields": {"state": "manual"}, "id": "J-9264-2", "op": "update"}1234#!/bin/shset -eumkdir -p /workspace/outputscp -R /solution/files/. /workspace/outputs/12345678910111213141516171819202122232425262728293031323334353637383940414243444546schema_version = "1.3"
[task]name = "apex-gap/autom-field-service-rebooking-011-v2"
[metadata.apex_gap]capability_tags = ["cross-app-workflows", "conditional-execution", "protected-state", "operations"]dataset = "Original simulated workflows"job = "operations"seed = 11source = "local/original-automation-workflows"source_revision = "2"source_split = "synthetic"source_task_id = "autom-field-service-rebooking-011"template_family = "automation:field-service-rebooking"workflow_template = "field-service-rebooking"
[metadata.openenv_hf_sandbox]variant = "apex-gap-hfsandbox-v1"task_modified_for_hf_sandbox = truenetwork_enabled = true
[environment]docker_image = "ghcr.io/younesbelkada/apex@sha256:24969c952247033023872f87161a16e067003469506be63783bbaa5d96926bdf"workdir = "/workspace"cpus = 1memory_mb = 4096build_timeout_sec = 600network_mode = "public"
[agent]timeout_sec = 1800network_mode = "public"
[verifier]timeout_sec = 600network_mode = "public"environment_mode = "separate"
[verifier.environment]network_mode = "public"cpus = 1memory_mb = 4096
[[artifacts]]source = "/workspace/outputs"123456789{ "checks": [ { "id": "business-outcomes", "type": "custom", "module": "world_check" } ]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330"""Deterministic grader shared by converted knowledge-work tasks.
Runs inside the separate verifier sandbox. Reads /tests/expected.json, inspects thesubmitted /workspace/outputs tree and writes a binary reward plus per-check details.No model calls and no network.
expected.json: {"checks": [{"id": ..., "type": ..., ...}, ...]}Check types: answer field of outputs/answer.json; kind = number|text|choice|date|bool|list xlsx_range recalculated outputs/<file> vs tests/<target> over sheet!range (SpreadsheetBench rules) xlsx_cell recalculated outputs/<file> sheet!cell vs value with tolerance (optional alt_values) file_contains outputs/<file> text (docx/pdf/ics/eml/txt) must contain every needle custom tests/<module>.py defines check(spec, outputs_dir, tests_dir) -> (bool, str)"""
import datetime as dtimport jsonimport reimport shutilimport subprocessimport sysimport tempfileimport unicodedatafrom pathlib import Path
OUT = Path("/workspace/outputs")TESTS = Path("/tests")LOGS = Path("/logs/verifier")
def norm_text(v): v = unicodedata.normalize("NFKC", str(v)).casefold() v = re.sub(r"[‘’“”]", "'", v) v = re.sub(r"[^\w%.$/-]+", " ", v) return " ".join(v.split()).strip(" .")
def to_number(v): if isinstance(v, bool): raise ValueError("bool") if isinstance(v, (int, float)): return float(v) s = str(v).strip().replace(",", "").replace("$", "").replace("−", "-") neg = s.startswith("(") and s.endswith(")") s = s.strip("()").strip() pct = s.endswith("%") s = s.rstrip("%").strip() s = re.sub(r"\s*(usd|dollars|million|billion|thousand|m|bn|k)$", "", s, flags=re.I) x = float(s) x = -x if neg else x return x / 100 if pct else x
def number_ok(got, want, rel, abs_): try: g = to_number(got) except (TypeError, ValueError): return False w = float(want) tol = max(abs_, rel * abs(w)) # "12.5%" may mean the ratio 0.125 or the percent number 12.5; the gold fixes which. candidates = [g, g * 100] if isinstance(got, str) and got.strip().endswith("%") else [g] return any(abs(c - w) <= tol for c in candidates)
def parse_date(v): if isinstance(v, (dt.date, dt.datetime)): return v if isinstance(v, dt.date) else v.date() s = str(v).strip() for fmt in ("%Y-%m-%d", "%m/%d/%Y", "%m/%d/%y", "%d %B %Y", "%B %d, %Y", "%b %d, %Y", "%Y/%m/%d"): try: return dt.datetime.strptime(s, fmt).date() except ValueError: continue raise ValueError(s)
def check_answer(check, answers): key = check["field"] if key not in answers: return False, f"missing field {key!r}" got, want, kind = answers[key], check["value"], check.get("kind", "text") if kind == "number": ok = number_ok(got, want, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01)) if not ok and check.get("percent_either"): ok = number_ok(got, want * 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) * 100) or ( number_ok(got, want / 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) / 100) ) elif kind == "date": try: ok = parse_date(got) == parse_date(want) except ValueError: ok = False elif kind == "bool": g = norm_text(got) ok = g in {"yes", "true"} if want else g in {"no", "false"} elif kind == "choice": ok = norm_text(got) == norm_text(want) elif kind == "list": if not isinstance(got, list): return False, f"{key}: expected a JSON list" # Filenames may be given with a directory prefix; compare base names. base = lambda x: norm_text(str(x).replace("\\", "/").rsplit("/", 1)[-1]) ok = sorted(base(x) for x in got) == sorted(base(x) for x in want) else: accepted = check.get("accept", [want]) ok = norm_text(got) in {norm_text(a) for a in accepted} return ok, "" if ok else f"{key}: got {got!r}"
# LibreOffice keeps cached formula values on load unless told otherwise; force a full recalculation.RECALC_PROFILE = """<?xml version="1.0" encoding="UTF-8"?><oor:items xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema"><item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="OOXMLRecalcMode" oor:op="fuse"><value>0</value></prop></item><item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="ODFRecalcMode" oor:op="fuse"><value>0</value></prop></item></oor:items>"""
def recalc(path, tmp): dest = Path(tmp) / f"recalc-{len(list(Path(tmp).glob('recalc-*')))}" dest.mkdir() profile = Path(tmp) / "lo-profile" if not profile.exists(): (profile / "user").mkdir(parents=True) (profile / "user" / "registrymodifications.xcu").write_text(RECALC_PROFILE) subprocess.run( ["soffice", f"-env:UserInstallation=file://{profile}", "--headless", "--calc", "--convert-to", "xlsx:Calc MS Excel 2007 XML", "--outdir", str(dest), str(path)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=180, check=False, ) out = dest / (Path(path).stem + ".xlsx") return out if out.exists() else Path(path)
def cell_value(v): if isinstance(v, (int, float)) and not isinstance(v, bool): return round(float(v), 2) if isinstance(v, dt.datetime): return round((v - dt.datetime(1899, 12, 30)).total_seconds() / 86400.0, 0) if isinstance(v, dt.time): return v.strftime("%H:%M") if isinstance(v, str): try: return round(float(v), 2) except ValueError: return v.strip() return v
def time_of(v): """A time or a day fraction in [0, 1) as HH:MM, rounded to the nearest second first. Calc and Excel store a time as that fraction; openpyxl returns a time only for time-formatted cells.""" if isinstance(v, dt.time): v = (v.hour * 3600 + v.minute * 60 + v.second + v.microsecond / 1e6) / 86400 if isinstance(v, (int, float)) and not isinstance(v, bool) and 0 <= v < 1: return (dt.datetime(1899, 12, 30) + dt.timedelta(seconds=round(v * 86400))).strftime("%H:%M") return None
def same_cell(a, b): if isinstance(a, dt.time) is not isinstance(b, dt.time): n = b if isinstance(a, dt.time) else a if time_of(n) is not None: # a time against a plain day fraction return time_of(a) == time_of(b) a, b = cell_value(a), cell_value(b) if a in (None, "") and b in (None, ""): return True return type(a) is type(b) and a == b
ERRORS = {"#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A"}
def is_error(v): return isinstance(v, str) and (v in ERRORS or v.startswith("Err:"))
def cells(rng): if ":" not in rng: return [rng] from openpyxl.utils import range_boundaries, get_column_letter
c1, r1, c2, r2 = range_boundaries(rng) return [f"{get_column_letter(c)}{r}" for r in range(r1, r2 + 1) for c in range(c1, c2 + 1)]
def load(path, tmp): import openpyxl
return openpyxl.load_workbook(recalc(path, tmp), data_only=True)
def check_xlsx_range(check, tmp, cache): sub = OUT / check["file"] if not sub.is_file(): return False, f"missing output {check['file']}" if sub not in cache: cache[sub] = load(sub, tmp) tgt = TESTS / check["target"] if tgt not in cache: cache[tgt] = load(tgt, tmp) got, want = cache[sub], cache[tgt] cached = None # the target's stored (Excel-computed) values, read only when Calc errs for sheet, rng in check["ranges"]: sheet = sheet or want.sheetnames[0] if sheet not in got.sheetnames: return False, f"sheet {sheet!r} missing" for name in cells(rng): w = want[sheet][name].value if is_error(w): # LibreOffice could not evaluate the gold formula (e.g. XLOOKUP, FILTER in Calc 7.4). # The value Excel stored is the intended answer. if cached is None: import openpyxl
cached = openpyxl.load_workbook(tgt, data_only=True) c = cached[sheet][name].value if sheet in cached.sheetnames else None if c is not None and not is_error(c): w = c if not same_cell(w, got[sheet][name].value): return False, f"{sheet}!{name}: want {w!r} got {got[sheet][name].value!r}" return True, ""
def check_xlsx_cell(check, tmp, cache): sub = OUT / check["file"] if not sub.is_file(): return False, f"missing output {check['file']}" if sub not in cache: cache[sub] = load(sub, tmp) wb = cache[sub] if check["sheet"] not in wb.sheetnames: return False, f"sheet {check['sheet']!r} missing" got = wb[check["sheet"]][check["cell"]].value want = check["value"] if isinstance(want, (int, float)): # alt_values: other accepted golds where the source admits more than one reading. ok = got is not None and any(number_ok(got, w, check.get("rel_tol", 0.0), check.get("abs_tol", 0.01)) for w in [want, *check.get("alt_values", [])]) else: ok = norm_text(got) == norm_text(want) return ok, "" if ok else f"{check['sheet']}!{check['cell']}: want {want!r} got {got!r}"
def text_of(path): suffix = path.suffix.lower() if suffix == ".docx": import docx
d = docx.Document(path) parts = [p.text for p in d.paragraphs] for t in d.tables: parts += [c.text for row in t.rows for c in row.cells] return "\n".join(parts) if suffix == ".pdf": import pdfplumber
with pdfplumber.open(path) as pdf: return "\n".join(page.extract_text() or "" for page in pdf.pages) return path.read_text(errors="replace")
def check_file_contains(check, tmp, cache): sub = OUT / check["file"] if not sub.is_file(): return False, f"missing output {check['file']}" text = text_of(sub) hay = text if check.get("case_sensitive") else text.casefold() for needle in check["needles"]: n = needle if check.get("case_sensitive") else needle.casefold() if n not in hay: return False, f"{check['file']} lacks {needle!r}" return True, ""
def main(): LOGS.mkdir(parents=True, exist_ok=True) reward_path = LOGS / "reward.txt" reward_path.write_text("0\n") spec = json.loads((TESTS / "expected.json").read_text()) answers, details = {}, [] answer_file = OUT / "answer.json" if answer_file.is_file(): try: answers = json.loads(answer_file.read_text()) if not isinstance(answers, dict): answers = {} except json.JSONDecodeError: answers = {} tmp = tempfile.mkdtemp() cache = {} try: for check in spec["checks"]: try: if check["type"] == "answer": ok, why = check_answer(check, answers) elif check["type"] == "xlsx_range": ok, why = check_xlsx_range(check, tmp, cache) elif check["type"] == "xlsx_cell": ok, why = check_xlsx_cell(check, tmp, cache) elif check["type"] == "file_contains": ok, why = check_file_contains(check, tmp, cache) elif check["type"] == "custom": import importlib.util
spec_ = importlib.util.spec_from_file_location("custom_check", TESTS / f"{check['module']}.py") mod = importlib.util.module_from_spec(spec_) spec_.loader.exec_module(mod) ok, why = mod.check(check, OUT, TESTS) else: ok, why = False, f"unknown check type {check['type']}" except Exception as exc: # a malformed submission fails the check, not the grader ok, why = False, f"{type(exc).__name__}: {exc}" details.append({"id": check["id"], "passed": ok, "detail": why}) finally: shutil.rmtree(tmp, ignore_errors=True) passed = sum(d["passed"] for d in details) total = len(details) reward = 1 if total and passed == total else 0 (LOGS / "details.json").write_text(json.dumps({"passed": passed, "total": total, "checks": details}, indent=1)) reward_path.write_text(f"{reward}\n") print(f"{passed}/{total} checks passed; reward {reward}")
if __name__ == "__main__": sys.exit(main())1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768"""Offline business-app client. Print usage with --help."""import argparseimport copyimport fcntlimport jsonimport osfrom pathlib import Path
def same(left, right): return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
def apply(world, action): if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}: raise ValueError('expected op, app, id, fields') op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields')) if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields: raise ValueError('unknown app, invalid id or empty fields') collection = world[app] if op == 'update' and key in collection: collection[key].update(copy.deepcopy(fields)) elif op == 'create' and key not in collection: collection[key] = copy.deepcopy(fields) else: raise ValueError(f'invalid {op} for {app}/{key}')
def load_actions(path): if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000): raise ValueError('invalid action log') if not path.exists(): return [] return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('op', choices=('apps','list','get','update','create')) parser.add_argument('app', nargs='?') parser.add_argument('id', nargs='?') parser.add_argument('fields', nargs='?', type=json.loads) args = parser.parse_args() world = json.loads(Path(__file__).with_name('world.json').read_text()) out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs')) out.mkdir(parents=True, exist_ok=True) log = out/'actions.jsonl' with (out/'.actions.lock').open('a') as lock: fcntl.flock(lock.fileno(), fcntl.LOCK_EX) for event in load_actions(log): apply(world,event) if args.op=='apps': value=sorted(world) elif args.op=='list': value=world[args.app] elif args.op=='get': value=world[args.app][args.id] else: event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields} apply(world,event) with log.open('a') as handle: handle.write(json.dumps(event,allow_nan=False)+'\n') value=world[args.app][args.id] print(json.dumps(value,sort_keys=True,allow_nan=False))
if __name__=='__main__': main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355{ "accounts": { "CL-0": { "allow_remote": true, "tier": "priority" }, "CL-1": { "allow_remote": false, "tier": "priority" }, "CL-2": { "allow_remote": false, "tier": "standard" }, "CL-3": { "allow_remote": true, "tier": "standard" }, "CL-4": { "allow_remote": false, "tier": "priority" }, "CL-5": { "allow_remote": false, "tier": "standard" }, "CL-6": { "allow_remote": false, "tier": "standard" }, "CL-7": { "allow_remote": false, "tier": "priority" }, "CL-8": { "allow_remote": true, "tier": "priority" }, "CL-9": { "allow_remote": false, "tier": "priority" } }, "calendar": { "S00": { "crew": "T0", "day": "2025-10-09", "mode": "onsite", "start": "08:00", "state": "reserved", "work_order": "J-5872-1" }, "S01": { "crew": "T0", "day": "2025-10-14", "mode": "remote", "start": "15:00", "state": "occupied" }, "S02": { "crew": "T2", "day": "2025-10-11", "mode": "remote", "start": "13:00", "state": "available" }, "S03": { "crew": "T5", "day": "2025-10-12", "mode": "onsite", "start": "15:00", "state": "available" }, "S04": { "crew": "T3", "day": "2025-10-10", "mode": "remote", "start": "15:00", "state": "available" }, "S05": { "crew": "T1", "day": "2025-10-14", "mode": "onsite", "start": "10:00", "state": "available" }, "S06": { "crew": "T3", "day": "2025-10-11", "mode": "remote", "start": "13:00", "state": "occupied" }, "S07": { "crew": "T1", "day": "2025-10-11", "mode": "onsite", "start": "15:00", "state": "reserved", "work_order": "J-5760-5" }, "S08": { "crew": "T1", "day": "2025-10-14", "mode": "remote", "start": "08:00", "state": "available" }, "S09": { "crew": "T4", "day": "2025-10-14", "mode": "onsite", "start": "08:00", "state": "available" }, "S10": { "crew": "T4", "day": "2025-10-12", "mode": "remote", "start": "10:00", "state": "occupied" }, "S11": { "crew": "T2", "day": "2025-10-11", "mode": "remote", "start": "08:00", "state": "reserved", "work_order": "J-4083-3" }, "S12": { "crew": "T5", "day": "2025-10-11", "mode": "onsite", "start": "08:00", "state": "available" }, "S13": { "crew": "T4", "day": "2025-10-11", "mode": "onsite", "start": "10:00", "state": "occupied" }, "S14": { "crew": "T0", "day": "2025-10-09", "mode": "remote", "start": "13:00", "state": "reserved", "work_order": "J-2564-0" }, "S15": { "crew": "T2", "day": "2025-10-09", "mode": "onsite", "start": "13:00", "state": "reserved", "work_order": "J-3625-4" }, "S16": { "crew": "T3", "day": "2025-10-10", "mode": "remote", "start": "10:00", "state": "available" }, "S17": { "crew": "T0", "day": "2025-10-12", "mode": "remote", "start": "10:00", "state": "available" }, "S18": { "crew": "T5", "day": "2025-10-13", "mode": "onsite", "start": "10:00", "state": "available" }, "S19": { "crew": "T5", "day": "2025-10-14", "mode": "remote", "start": "10:00", "state": "available" }, "S20": { "crew": "T3", "day": "2025-10-11", "mode": "onsite", "start": "15:00", "state": "available" } }, "dispatch": { "DISPATCH-OLD": { "status": "closed", "work_order": "archived" }, "follow-J-9264-2": { "client": "CL-2", "status": "needs_slot", "work_order": "J-9264-2" } }, "technicians": { "T0": { "active": true, "home": "South", "skills": [ "network", "safety", "controls" ] }, "T1": { "active": true, "home": "South", "skills": [ "safety", "network" ] }, "T2": { "active": true, "home": "South", "skills": [ "safety", "controls" ] }, "T3": { "active": true, "home": "South", "skills": [ "network" ] }, "T4": { "active": true, "home": "South", "skills": [ "network", "controls", "safety" ] }, "T5": { "active": true, "home": "Central", "skills": [ "network", "controls" ] }, "T6": { "active": false, "home": "Central", "skills": [ "safety", "network" ] } }, "work_orders": { "J-2564-0": { "client": "CL-0", "day": "2025-10-08", "hub": "South", "new_slot": "S14", "service": "controls", "start": "13:00", "state": "rebooked" }, "J-3625-4": { "client": "CL-4", "day": "2025-10-08", "hub": "South", "new_slot": "S15", "service": "controls", "start": "10:00", "state": "rebooked" }, "J-4083-3": { "client": "CL-3", "day": "2025-10-08", "hub": "South", "new_slot": "S11", "service": "safety", "start": "13:00", "state": "rebooked" }, "J-5742-6": { "client": "CL-6", "day": "2025-10-10", "hub": "South", "service": "safety", "start": "08:00", "state": "confirmed" }, "J-5760-5": { "client": "CL-5", "day": "2025-10-08", "hub": "South", "new_slot": "S07", "service": "network", "start": "15:00", "state": "rebooked" }, "J-5872-1": { "client": "CL-1", "day": "2025-10-08", "hub": "South", "new_slot": "S00", "service": "controls", "start": "08:00", "state": "rebooked" }, "J-6802-7": { "client": "CL-7", "day": "2025-10-08", "hub": "Central", "service": "network", "start": "13:00", "state": "confirmed" }, "J-9105-9": { "client": "CL-9", "day": "2025-10-06", "hub": "South", "service": "controls", "start": "08:00", "state": "cancelled" }, "J-9264-2": { "client": "CL-2", "day": "2025-10-08", "hub": "South", "service": "controls", "start": "13:00", "state": "manual" }, "J-9575-8": { "client": "CL-8", "day": "2025-10-07", "hub": "Central", "service": "network", "start": "15:00", "state": "cancelled" } }}1234#!/bin/shset -eumkdir -p /logs/verifier /workspace/outputsexec python3 -B -I /tests/grade.py123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340{ "accounts": { "CL-0": { "allow_remote": true, "tier": "priority" }, "CL-1": { "allow_remote": false, "tier": "priority" }, "CL-2": { "allow_remote": false, "tier": "standard" }, "CL-3": { "allow_remote": true, "tier": "standard" }, "CL-4": { "allow_remote": false, "tier": "priority" }, "CL-5": { "allow_remote": false, "tier": "standard" }, "CL-6": { "allow_remote": false, "tier": "standard" }, "CL-7": { "allow_remote": false, "tier": "priority" }, "CL-8": { "allow_remote": true, "tier": "priority" }, "CL-9": { "allow_remote": false, "tier": "priority" } }, "calendar": { "S00": { "crew": "T0", "day": "2025-10-09", "mode": "onsite", "start": "08:00", "state": "available" }, "S01": { "crew": "T0", "day": "2025-10-14", "mode": "remote", "start": "15:00", "state": "occupied" }, "S02": { "crew": "T2", "day": "2025-10-11", "mode": "remote", "start": "13:00", "state": "available" }, "S03": { "crew": "T5", "day": "2025-10-12", "mode": "onsite", "start": "15:00", "state": "available" }, "S04": { "crew": "T3", "day": "2025-10-10", "mode": "remote", "start": "15:00", "state": "available" }, "S05": { "crew": "T1", "day": "2025-10-14", "mode": "onsite", "start": "10:00", "state": "available" }, "S06": { "crew": "T3", "day": "2025-10-11", "mode": "remote", "start": "13:00", "state": "occupied" }, "S07": { "crew": "T1", "day": "2025-10-11", "mode": "onsite", "start": "15:00", "state": "available" }, "S08": { "crew": "T1", "day": "2025-10-14", "mode": "remote", "start": "08:00", "state": "available" }, "S09": { "crew": "T4", "day": "2025-10-14", "mode": "onsite", "start": "08:00", "state": "available" }, "S10": { "crew": "T4", "day": "2025-10-12", "mode": "remote", "start": "10:00", "state": "occupied" }, "S11": { "crew": "T2", "day": "2025-10-11", "mode": "remote", "start": "08:00", "state": "available" }, "S12": { "crew": "T5", "day": "2025-10-11", "mode": "onsite", "start": "08:00", "state": "available" }, "S13": { "crew": "T4", "day": "2025-10-11", "mode": "onsite", "start": "10:00", "state": "occupied" }, "S14": { "crew": "T0", "day": "2025-10-09", "mode": "remote", "start": "13:00", "state": "available" }, "S15": { "crew": "T2", "day": "2025-10-09", "mode": "onsite", "start": "13:00", "state": "available" }, "S16": { "crew": "T3", "day": "2025-10-10", "mode": "remote", "start": "10:00", "state": "available" }, "S17": { "crew": "T0", "day": "2025-10-12", "mode": "remote", "start": "10:00", "state": "available" }, "S18": { "crew": "T5", "day": "2025-10-13", "mode": "onsite", "start": "10:00", "state": "available" }, "S19": { "crew": "T5", "day": "2025-10-14", "mode": "remote", "start": "10:00", "state": "available" }, "S20": { "crew": "T3", "day": "2025-10-11", "mode": "onsite", "start": "15:00", "state": "available" } }, "dispatch": { "DISPATCH-OLD": { "status": "closed", "work_order": "archived" } }, "technicians": { "T0": { "active": true, "home": "South", "skills": [ "network", "safety", "controls" ] }, "T1": { "active": true, "home": "South", "skills": [ "safety", "network" ] }, "T2": { "active": true, "home": "South", "skills": [ "safety", "controls" ] }, "T3": { "active": true, "home": "South", "skills": [ "network" ] }, "T4": { "active": true, "home": "South", "skills": [ "network", "controls", "safety" ] }, "T5": { "active": true, "home": "Central", "skills": [ "network", "controls" ] }, "T6": { "active": false, "home": "Central", "skills": [ "safety", "network" ] } }, "work_orders": { "J-2564-0": { "client": "CL-0", "day": "2025-10-08", "hub": "South", "service": "controls", "start": "13:00", "state": "confirmed" }, "J-3625-4": { "client": "CL-4", "day": "2025-10-08", "hub": "South", "service": "controls", "start": "10:00", "state": "confirmed" }, "J-4083-3": { "client": "CL-3", "day": "2025-10-08", "hub": "South", "service": "safety", "start": "13:00", "state": "confirmed" }, "J-5742-6": { "client": "CL-6", "day": "2025-10-10", "hub": "South", "service": "safety", "start": "08:00", "state": "confirmed" }, "J-5760-5": { "client": "CL-5", "day": "2025-10-08", "hub": "South", "service": "network", "start": "15:00", "state": "confirmed" }, "J-5872-1": { "client": "CL-1", "day": "2025-10-08", "hub": "South", "service": "controls", "start": "08:00", "state": "confirmed" }, "J-6802-7": { "client": "CL-7", "day": "2025-10-08", "hub": "Central", "service": "network", "start": "13:00", "state": "confirmed" }, "J-9105-9": { "client": "CL-9", "day": "2025-10-06", "hub": "South", "service": "controls", "start": "08:00", "state": "cancelled" }, "J-9264-2": { "client": "CL-2", "day": "2025-10-08", "hub": "South", "service": "controls", "start": "13:00", "state": "confirmed" }, "J-9575-8": { "client": "CL-8", "day": "2025-10-07", "hub": "Central", "service": "network", "start": "15:00", "state": "cancelled" } }}1234567891011121314151617181920212223242526"""Replay submitted mutations from the private verifier's initial state."""from types import ModuleTypeimport json
def check(spec, outputs, tests): replay = ModuleType('workflow_replay') exec(compile((tests/'replay.py').read_bytes(), 'replay.py', 'exec'), replay.__dict__) world = json.loads((tests/'world.json').read_text()) target = json.loads((tests/'target.json').read_text()) # Only fields whose starting and expected values differ may be changed. Attempts # to temporarily alter a protected field fail even when a later write restores it. allowed = { (app,key): {field for field,value in doc.items() if field not in world[app].get(key,{}) or not replay.same(world[app][key][field],value)} for app,records in target.items() for key,doc in records.items() } actions = replay.load_actions(outputs/'actions.jsonl') for event in actions: replay.apply(world,event) touched = set(event['fields']) if not touched <= allowed.get((event['app'],event['id']),set()): return False,'protected field or record write' if not replay.same(world,target): return False,'required business outcomes incomplete' return True,''12345678910111213141516171819202122232425262728{ "profile": "harbor-semantic-v1", "reward_key": "reward", "reward": { "range": [ 0, 1 ], "oracle_tolerance": 0, "floor_margin": 0.1 }, "resources": { "cpu": 1, "memory_mb": 4096, "disk_mb": 10240, "episode_timeout_s": 1800 }, "types": { "tags": [ "knowledge-work", "cross-app-workflows", "conditional-execution", "protected-state", "operations" ] }, "requires_credentials": false}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768"""Offline business-app client. Print usage with --help."""import argparseimport copyimport fcntlimport jsonimport osfrom pathlib import Path
def same(left, right): return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
def apply(world, action): if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}: raise ValueError('expected op, app, id, fields') op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields')) if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields: raise ValueError('unknown app, invalid id or empty fields') collection = world[app] if op == 'update' and key in collection: collection[key].update(copy.deepcopy(fields)) elif op == 'create' and key not in collection: collection[key] = copy.deepcopy(fields) else: raise ValueError(f'invalid {op} for {app}/{key}')
def load_actions(path): if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000): raise ValueError('invalid action log') if not path.exists(): return [] return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('op', choices=('apps','list','get','update','create')) parser.add_argument('app', nargs='?') parser.add_argument('id', nargs='?') parser.add_argument('fields', nargs='?', type=json.loads) args = parser.parse_args() world = json.loads(Path(__file__).with_name('world.json').read_text()) out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs')) out.mkdir(parents=True, exist_ok=True) log = out/'actions.jsonl' with (out/'.actions.lock').open('a') as lock: fcntl.flock(lock.fileno(), fcntl.LOCK_EX) for event in load_actions(log): apply(world,event) if args.op=='apps': value=sorted(world) elif args.op=='list': value=world[args.app] elif args.op=='get': value=world[args.app][args.id] else: event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields} apply(world,event) with log.open('a') as handle: handle.write(json.dumps(event,allow_nan=False)+'\n') value=world[args.app][args.id] print(json.dumps(value,sort_keys=True,allow_nan=False))
if __name__=='__main__': main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302{ "accounts": { "CL-0": { "allow_remote": false, "tier": "standard" }, "CL-1": { "allow_remote": false, "tier": "priority" }, "CL-2": { "allow_remote": false, "tier": "standard" }, "CL-3": { "allow_remote": false, "tier": "priority" }, "CL-4": { "allow_remote": false, "tier": "standard" }, "CL-5": { "allow_remote": false, "tier": "priority" }, "CL-6": { "allow_remote": true, "tier": "priority" }, "CL-7": { "allow_remote": false, "tier": "standard" }, "CL-8": { "allow_remote": false, "tier": "priority" } }, "calendar": { "S00": { "crew": "T0", "day": "2025-11-01", "mode": "onsite", "start": "15:00", "state": "available" }, "S01": { "crew": "T2", "day": "2025-11-04", "mode": "remote", "start": "10:00", "state": "available" }, "S02": { "crew": "T1", "day": "2025-11-03", "mode": "remote", "start": "10:00", "state": "available" }, "S03": { "crew": "T2", "day": "2025-11-06", "mode": "onsite", "start": "13:00", "state": "available" }, "S04": { "crew": "T6", "day": "2025-11-05", "mode": "onsite", "start": "13:00", "state": "available" }, "S05": { "crew": "T4", "day": "2025-11-02", "mode": "onsite", "start": "08:00", "state": "available" }, "S07": { "crew": "T5", "day": "2025-11-03", "mode": "remote", "start": "10:00", "state": "available" }, "S08": { "crew": "T1", "day": "2025-11-02", "mode": "remote", "start": "13:00", "state": "available" }, "S09": { "crew": "T2", "day": "2025-11-05", "mode": "remote", "start": "10:00", "state": "occupied" }, "S10": { "crew": "T3", "day": "2025-11-02", "mode": "onsite", "start": "08:00", "state": "occupied" }, "S11": { "crew": "T5", "day": "2025-11-01", "mode": "remote", "start": "10:00", "state": "available" }, "S12": { "crew": "T3", "day": "2025-11-04", "mode": "remote", "start": "15:00", "state": "available" }, "S13": { "crew": "T6", "day": "2025-11-05", "mode": "remote", "start": "08:00", "state": "available" }, "S15": { "crew": "T3", "day": "2025-11-06", "mode": "onsite", "start": "15:00", "state": "available" }, "S16": { "crew": "T1", "day": "2025-11-04", "mode": "onsite", "start": "10:00", "state": "available" }, "S17": { "crew": "T4", "day": "2025-11-02", "mode": "onsite", "start": "15:00", "state": "available" }, "S18": { "crew": "T5", "day": "2025-11-06", "mode": "onsite", "start": "08:00", "state": "available" } }, "dispatch": { "DISPATCH-OLD": { "status": "closed", "work_order": "archived" } }, "technicians": { "T0": { "active": true, "home": "East", "skills": [ "network", "safety", "controls" ] }, "T1": { "active": true, "home": "East", "skills": [ "safety" ] }, "T2": { "active": true, "home": "East", "skills": [ "controls", "network", "safety" ] }, "T3": { "active": true, "home": "East", "skills": [ "safety", "controls" ] }, "T4": { "active": true, "home": "East", "skills": [ "controls", "network", "safety" ] }, "T5": { "active": true, "home": "Central", "skills": [ "network", "controls" ] }, "T6": { "active": false, "home": "Central", "skills": [ "safety", "controls", "network" ] } }, "work_orders": { "J-1357-5": { "client": "CL-5", "day": "2025-10-31", "hub": "East", "service": "controls", "start": "15:00", "state": "confirmed" }, "J-3081-8": { "client": "CL-8", "day": "2025-10-31", "hub": "Central", "service": "network", "start": "15:00", "state": "confirmed" }, "J-3357-7": { "client": "CL-7", "day": "2025-10-29", "hub": "Central", "service": "controls", "start": "13:00", "state": "cancelled" }, "J-3915-6": { "client": "CL-6", "day": "2025-11-01", "hub": "Central", "service": "safety", "start": "08:00", "state": "cancelled" }, "J-6809-1": { "client": "CL-1", "day": "2025-10-31", "hub": "East", "service": "network", "start": "08:00", "state": "confirmed" }, "J-7595-2": { "client": "CL-2", "day": "2025-10-31", "hub": "East", "service": "safety", "start": "15:00", "state": "confirmed" }, "J-8597-4": { "client": "CL-4", "day": "2025-10-31", "hub": "East", "service": "network", "start": "15:00", "state": "confirmed" }, "J-8959-3": { "client": "CL-3", "day": "2025-10-31", "hub": "East", "service": "controls", "start": "13:00", "state": "confirmed" }, "J-9820-0": { "client": "CL-0", "day": "2025-10-31", "hub": "East", "service": "controls", "start": "10:00", "state": "confirmed" } }}12345678910111213141516171819A field-service closure affects confirmed work orders at East on 2025-10-31. Reschedule those orders only. Serve priority-tier accounts first, then standard. Within each tier sort by original start time and then work-order ID ascending. Each appointment needs one full slot for a technician active and skilled in the order's service.
Search available calendar slots from 2025-11-01 through 2025-11-04, inclusive. Onsite slots require the technician to be based at East. Remote slots can use any home hub if the account allows remote service. Choose earliest day, then earliest start, then onsite before remote, then smallest slot ID in lexical order. Allocate one slot at a time in queue order. Remove each allocated slot from consideration for subsequent orders.
For a match update the calendar slot to `state=reserved` with `work_order` equal to the order ID. Set the work order `state=rebooked` and `new_slot` to the chosen slot ID; retain its original day and time. If no slot remains set only its `state=manual`, then create dispatch record `follow-<order ID>` with `work_order`, `client`, and `status=needs_slot`. Preserve all other fields and records.
Calculate the plan in the stated queue order using all earlier decisions. Once calculated, you may apply the resulting changes in any order or combine updates to the same record. The action log is checked for the final business state and for any write to a protected record or field.
Use the offline app client at `/workspace/inputs/apps.py`. Call it with python3. Run`apps` to discover apps, `list APP` to see its records, or `get APP ID` for one record.Write with `update APP ID '{"field":"value"}'` or `create APP ID '{"field":"value"}'`.The client records successful writes in `/workspace/outputs/actions.jsonl`.Apply exactly the required changes. Other records and fields must remain untouched,including temporary changes. Actions take effect in the local simulation only.
## Deliverable
Work in `/workspace`. Input files are under `/workspace/inputs/`. Put every deliverable in`/workspace/outputs/`; only that directory is graded. Leave the app action log in the outputs directory.123456789101112{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-6809-1"}, "id": "S00", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-8959-3"}, "id": "S05", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-7595-2"}, "id": "S16", "op": "update"}{"app": "calendar", "fields": {"state": "reserved", "work_order": "J-1357-5"}, "id": "S17", "op": "update"}{"app": "dispatch", "fields": {"client": "CL-0", "status": "needs_slot", "work_order": "J-9820-0"}, "id": "follow-J-9820-0", "op": "create"}{"app": "dispatch", "fields": {"client": "CL-4", "status": "needs_slot", "work_order": "J-8597-4"}, "id": "follow-J-8597-4", "op": "create"}{"app": "work_orders", "fields": {"new_slot": "S17", "state": "rebooked"}, "id": "J-1357-5", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S00", "state": "rebooked"}, "id": "J-6809-1", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S16", "state": "rebooked"}, "id": "J-7595-2", "op": "update"}{"app": "work_orders", "fields": {"state": "manual"}, "id": "J-8597-4", "op": "update"}{"app": "work_orders", "fields": {"new_slot": "S05", "state": "rebooked"}, "id": "J-8959-3", "op": "update"}{"app": "work_orders", "fields": {"state": "manual"}, "id": "J-9820-0", "op": "update"}tasks/autom-field-service-rebooking-008-v2/tests/test.shAdded+4
tasks/autom-field-service-rebooking-008-v2/tests/world.jsonAdded+358
tasks/autom-field-service-rebooking-008-v2/tests/world_check.pyAdded+26
tasks/autom-field-service-rebooking-008-v2/validation/openenv.jsonAdded+28
tasks/autom-field-service-rebooking-009-v2/environment/inputs/apps.pyAdded+68
tasks/autom-field-service-rebooking-009-v2/environment/inputs/world.jsonAdded+329
tasks/autom-field-service-rebooking-009-v2/instruction.mdAdded+19
tasks/autom-field-service-rebooking-009-v2/solution/files/actions.jsonlAdded+14
tasks/autom-field-service-rebooking-009-v2/solution/solve.shAdded+4
tasks/autom-field-service-rebooking-009-v2/task.tomlAdded+46
tasks/autom-field-service-rebooking-009-v2/tests/expected.jsonAdded+9
tasks/autom-field-service-rebooking-009-v2/tests/grade.pyAdded+330
tasks/autom-field-service-rebooking-009-v2/tests/replay.pyAdded+68
tasks/autom-field-service-rebooking-009-v2/tests/target.jsonAdded+343
tasks/autom-field-service-rebooking-009-v2/tests/test.shAdded+4
tasks/autom-field-service-rebooking-009-v2/tests/world.jsonAdded+329
tasks/autom-field-service-rebooking-009-v2/tests/world_check.pyAdded+26
tasks/autom-field-service-rebooking-009-v2/validation/openenv.jsonAdded+28
tasks/autom-field-service-rebooking-010-v2/environment/inputs/apps.pyAdded+68
tasks/autom-field-service-rebooking-010-v2/environment/inputs/world.jsonAdded+343
tasks/autom-field-service-rebooking-010-v2/instruction.mdAdded+19
tasks/autom-field-service-rebooking-010-v2/solution/files/actions.jsonlAdded+12
tasks/autom-field-service-rebooking-010-v2/solution/solve.shAdded+4
tasks/autom-field-service-rebooking-010-v2/task.tomlAdded+46
tasks/autom-field-service-rebooking-010-v2/tests/expected.jsonAdded+9
tasks/autom-field-service-rebooking-010-v2/tests/grade.pyAdded+330
tasks/autom-field-service-rebooking-010-v2/tests/replay.pyAdded+68
tasks/autom-field-service-rebooking-010-v2/tests/target.jsonAdded+358
tasks/autom-field-service-rebooking-010-v2/tests/test.shAdded+4
tasks/autom-field-service-rebooking-010-v2/tests/world.jsonAdded+343
tasks/autom-field-service-rebooking-010-v2/tests/world_check.pyAdded+26
tasks/autom-field-service-rebooking-010-v2/validation/openenv.jsonAdded+28
tasks/autom-field-service-rebooking-011-v2/environment/inputs/apps.pyAdded+68
tasks/autom-field-service-rebooking-011-v2/environment/inputs/world.jsonAdded+340
tasks/autom-field-service-rebooking-011-v2/instruction.mdAdded+19
tasks/autom-field-service-rebooking-011-v2/solution/files/actions.jsonlAdded+12
tasks/autom-field-service-rebooking-011-v2/solution/solve.shAdded+4
tasks/autom-field-service-rebooking-011-v2/task.tomlAdded+46
tasks/autom-field-service-rebooking-011-v2/tests/expected.jsonAdded+9
tasks/autom-field-service-rebooking-011-v2/tests/grade.pyAdded+330
tasks/autom-field-service-rebooking-011-v2/tests/replay.pyAdded+68
tasks/autom-field-service-rebooking-011-v2/tests/target.jsonAdded+355
tasks/autom-field-service-rebooking-011-v2/tests/test.shAdded+4
tasks/autom-field-service-rebooking-011-v2/tests/world.jsonAdded+340
tasks/autom-field-service-rebooking-011-v2/tests/world_check.pyAdded+26
tasks/autom-field-service-rebooking-011-v2/validation/openenv.jsonAdded+28
tasks/autom-field-service-rebooking-012-v2/environment/inputs/apps.pyAdded+68
tasks/autom-field-service-rebooking-012-v2/environment/inputs/world.jsonAdded+302
tasks/autom-field-service-rebooking-012-v2/instruction.mdAdded+19
tasks/autom-field-service-rebooking-012-v2/solution/files/actions.jsonlAdded+12