ybelkada HF Staff commited on
Commit
3e15f5d
·
verified ·
1 Parent(s): 8a451f2

Harbor format: 210 business_automation tasks (part 3)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. tasks/autom-field-service-rebooking-008-v2/tests/test.sh +4 -0
  2. tasks/autom-field-service-rebooking-008-v2/tests/world.json +358 -0
  3. tasks/autom-field-service-rebooking-008-v2/tests/world_check.py +26 -0
  4. tasks/autom-field-service-rebooking-008-v2/validation/openenv.json +28 -0
  5. tasks/autom-field-service-rebooking-009-v2/environment/inputs/apps.py +68 -0
  6. tasks/autom-field-service-rebooking-009-v2/environment/inputs/world.json +329 -0
  7. tasks/autom-field-service-rebooking-009-v2/instruction.md +19 -0
  8. tasks/autom-field-service-rebooking-009-v2/solution/files/actions.jsonl +14 -0
  9. tasks/autom-field-service-rebooking-009-v2/solution/solve.sh +4 -0
  10. tasks/autom-field-service-rebooking-009-v2/task.toml +46 -0
  11. tasks/autom-field-service-rebooking-009-v2/tests/expected.json +9 -0
  12. tasks/autom-field-service-rebooking-009-v2/tests/grade.py +330 -0
  13. tasks/autom-field-service-rebooking-009-v2/tests/replay.py +68 -0
  14. tasks/autom-field-service-rebooking-009-v2/tests/target.json +343 -0
  15. tasks/autom-field-service-rebooking-009-v2/tests/test.sh +4 -0
  16. tasks/autom-field-service-rebooking-009-v2/tests/world.json +329 -0
  17. tasks/autom-field-service-rebooking-009-v2/tests/world_check.py +26 -0
  18. tasks/autom-field-service-rebooking-009-v2/validation/openenv.json +28 -0
  19. tasks/autom-field-service-rebooking-010-v2/environment/inputs/apps.py +68 -0
  20. tasks/autom-field-service-rebooking-010-v2/environment/inputs/world.json +343 -0
  21. tasks/autom-field-service-rebooking-010-v2/instruction.md +19 -0
  22. tasks/autom-field-service-rebooking-010-v2/solution/files/actions.jsonl +12 -0
  23. tasks/autom-field-service-rebooking-010-v2/solution/solve.sh +4 -0
  24. tasks/autom-field-service-rebooking-010-v2/task.toml +46 -0
  25. tasks/autom-field-service-rebooking-010-v2/tests/expected.json +9 -0
  26. tasks/autom-field-service-rebooking-010-v2/tests/grade.py +330 -0
  27. tasks/autom-field-service-rebooking-010-v2/tests/replay.py +68 -0
  28. tasks/autom-field-service-rebooking-010-v2/tests/target.json +358 -0
  29. tasks/autom-field-service-rebooking-010-v2/tests/test.sh +4 -0
  30. tasks/autom-field-service-rebooking-010-v2/tests/world.json +343 -0
  31. tasks/autom-field-service-rebooking-010-v2/tests/world_check.py +26 -0
  32. tasks/autom-field-service-rebooking-010-v2/validation/openenv.json +28 -0
  33. tasks/autom-field-service-rebooking-011-v2/environment/inputs/apps.py +68 -0
  34. tasks/autom-field-service-rebooking-011-v2/environment/inputs/world.json +340 -0
  35. tasks/autom-field-service-rebooking-011-v2/instruction.md +19 -0
  36. tasks/autom-field-service-rebooking-011-v2/solution/files/actions.jsonl +12 -0
  37. tasks/autom-field-service-rebooking-011-v2/solution/solve.sh +4 -0
  38. tasks/autom-field-service-rebooking-011-v2/task.toml +46 -0
  39. tasks/autom-field-service-rebooking-011-v2/tests/expected.json +9 -0
  40. tasks/autom-field-service-rebooking-011-v2/tests/grade.py +330 -0
  41. tasks/autom-field-service-rebooking-011-v2/tests/replay.py +68 -0
  42. tasks/autom-field-service-rebooking-011-v2/tests/target.json +355 -0
  43. tasks/autom-field-service-rebooking-011-v2/tests/test.sh +4 -0
  44. tasks/autom-field-service-rebooking-011-v2/tests/world.json +340 -0
  45. tasks/autom-field-service-rebooking-011-v2/tests/world_check.py +26 -0
  46. tasks/autom-field-service-rebooking-011-v2/validation/openenv.json +28 -0
  47. tasks/autom-field-service-rebooking-012-v2/environment/inputs/apps.py +68 -0
  48. tasks/autom-field-service-rebooking-012-v2/environment/inputs/world.json +302 -0
  49. tasks/autom-field-service-rebooking-012-v2/instruction.md +19 -0
  50. tasks/autom-field-service-rebooking-012-v2/solution/files/actions.jsonl +12 -0
tasks/autom-field-service-rebooking-008-v2/tests/test.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -eu
3
+ mkdir -p /logs/verifier /workspace/outputs
4
+ exec python3 -B -I /tests/grade.py
tasks/autom-field-service-rebooking-008-v2/tests/world.json ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accounts": {
3
+ "CL-0": {
4
+ "allow_remote": true,
5
+ "tier": "standard"
6
+ },
7
+ "CL-1": {
8
+ "allow_remote": false,
9
+ "tier": "standard"
10
+ },
11
+ "CL-10": {
12
+ "allow_remote": true,
13
+ "tier": "standard"
14
+ },
15
+ "CL-11": {
16
+ "allow_remote": true,
17
+ "tier": "standard"
18
+ },
19
+ "CL-2": {
20
+ "allow_remote": true,
21
+ "tier": "priority"
22
+ },
23
+ "CL-3": {
24
+ "allow_remote": false,
25
+ "tier": "standard"
26
+ },
27
+ "CL-4": {
28
+ "allow_remote": false,
29
+ "tier": "standard"
30
+ },
31
+ "CL-5": {
32
+ "allow_remote": false,
33
+ "tier": "standard"
34
+ },
35
+ "CL-6": {
36
+ "allow_remote": true,
37
+ "tier": "standard"
38
+ },
39
+ "CL-7": {
40
+ "allow_remote": false,
41
+ "tier": "standard"
42
+ },
43
+ "CL-8": {
44
+ "allow_remote": true,
45
+ "tier": "priority"
46
+ },
47
+ "CL-9": {
48
+ "allow_remote": false,
49
+ "tier": "standard"
50
+ }
51
+ },
52
+ "calendar": {
53
+ "S00": {
54
+ "crew": "T0",
55
+ "day": "2025-08-01",
56
+ "mode": "onsite",
57
+ "start": "10:00",
58
+ "state": "available"
59
+ },
60
+ "S01": {
61
+ "crew": "T6",
62
+ "day": "2025-08-05",
63
+ "mode": "onsite",
64
+ "start": "15:00",
65
+ "state": "available"
66
+ },
67
+ "S02": {
68
+ "crew": "T2",
69
+ "day": "2025-08-02",
70
+ "mode": "remote",
71
+ "start": "13:00",
72
+ "state": "available"
73
+ },
74
+ "S03": {
75
+ "crew": "T2",
76
+ "day": "2025-08-04",
77
+ "mode": "remote",
78
+ "start": "10:00",
79
+ "state": "available"
80
+ },
81
+ "S04": {
82
+ "crew": "T5",
83
+ "day": "2025-08-02",
84
+ "mode": "onsite",
85
+ "start": "10:00",
86
+ "state": "available"
87
+ },
88
+ "S05": {
89
+ "crew": "T6",
90
+ "day": "2025-08-06",
91
+ "mode": "remote",
92
+ "start": "13:00",
93
+ "state": "available"
94
+ },
95
+ "S06": {
96
+ "crew": "T0",
97
+ "day": "2025-08-04",
98
+ "mode": "remote",
99
+ "start": "08:00",
100
+ "state": "available"
101
+ },
102
+ "S07": {
103
+ "crew": "T4",
104
+ "day": "2025-08-05",
105
+ "mode": "remote",
106
+ "start": "15:00",
107
+ "state": "available"
108
+ },
109
+ "S08": {
110
+ "crew": "T2",
111
+ "day": "2025-08-05",
112
+ "mode": "onsite",
113
+ "start": "13:00",
114
+ "state": "available"
115
+ },
116
+ "S09": {
117
+ "crew": "T0",
118
+ "day": "2025-08-01",
119
+ "mode": "remote",
120
+ "start": "08:00",
121
+ "state": "available"
122
+ },
123
+ "S10": {
124
+ "crew": "T3",
125
+ "day": "2025-08-04",
126
+ "mode": "onsite",
127
+ "start": "15:00",
128
+ "state": "available"
129
+ },
130
+ "S11": {
131
+ "crew": "T4",
132
+ "day": "2025-08-05",
133
+ "mode": "onsite",
134
+ "start": "08:00",
135
+ "state": "available"
136
+ },
137
+ "S12": {
138
+ "crew": "T1",
139
+ "day": "2025-08-04",
140
+ "mode": "onsite",
141
+ "start": "13:00",
142
+ "state": "available"
143
+ },
144
+ "S13": {
145
+ "crew": "T2",
146
+ "day": "2025-08-03",
147
+ "mode": "onsite",
148
+ "start": "10:00",
149
+ "state": "available"
150
+ },
151
+ "S14": {
152
+ "crew": "T4",
153
+ "day": "2025-08-05",
154
+ "mode": "remote",
155
+ "start": "10:00",
156
+ "state": "available"
157
+ },
158
+ "S15": {
159
+ "crew": "T1",
160
+ "day": "2025-08-04",
161
+ "mode": "onsite",
162
+ "start": "08:00",
163
+ "state": "occupied"
164
+ },
165
+ "S16": {
166
+ "crew": "T1",
167
+ "day": "2025-08-01",
168
+ "mode": "remote",
169
+ "start": "10:00",
170
+ "state": "occupied"
171
+ },
172
+ "S17": {
173
+ "crew": "T3",
174
+ "day": "2025-08-01",
175
+ "mode": "remote",
176
+ "start": "10:00",
177
+ "state": "available"
178
+ },
179
+ "S18": {
180
+ "crew": "T2",
181
+ "day": "2025-08-03",
182
+ "mode": "remote",
183
+ "start": "13:00",
184
+ "state": "available"
185
+ },
186
+ "S19": {
187
+ "crew": "T2",
188
+ "day": "2025-08-02",
189
+ "mode": "remote",
190
+ "start": "10:00",
191
+ "state": "available"
192
+ }
193
+ },
194
+ "dispatch": {
195
+ "DISPATCH-OLD": {
196
+ "status": "closed",
197
+ "work_order": "archived"
198
+ }
199
+ },
200
+ "technicians": {
201
+ "T0": {
202
+ "active": true,
203
+ "home": "West",
204
+ "skills": [
205
+ "network",
206
+ "safety",
207
+ "controls"
208
+ ]
209
+ },
210
+ "T1": {
211
+ "active": true,
212
+ "home": "West",
213
+ "skills": [
214
+ "safety",
215
+ "controls",
216
+ "network"
217
+ ]
218
+ },
219
+ "T2": {
220
+ "active": true,
221
+ "home": "West",
222
+ "skills": [
223
+ "controls",
224
+ "network"
225
+ ]
226
+ },
227
+ "T3": {
228
+ "active": true,
229
+ "home": "West",
230
+ "skills": [
231
+ "safety",
232
+ "network",
233
+ "controls"
234
+ ]
235
+ },
236
+ "T4": {
237
+ "active": true,
238
+ "home": "West",
239
+ "skills": [
240
+ "network",
241
+ "controls"
242
+ ]
243
+ },
244
+ "T5": {
245
+ "active": true,
246
+ "home": "North",
247
+ "skills": [
248
+ "controls",
249
+ "network"
250
+ ]
251
+ },
252
+ "T6": {
253
+ "active": false,
254
+ "home": "North",
255
+ "skills": [
256
+ "network"
257
+ ]
258
+ }
259
+ },
260
+ "work_orders": {
261
+ "J-1111-4": {
262
+ "client": "CL-4",
263
+ "day": "2025-07-31",
264
+ "hub": "West",
265
+ "service": "safety",
266
+ "start": "15:00",
267
+ "state": "confirmed"
268
+ },
269
+ "J-1664-5": {
270
+ "client": "CL-5",
271
+ "day": "2025-07-31",
272
+ "hub": "West",
273
+ "service": "network",
274
+ "start": "08:00",
275
+ "state": "confirmed"
276
+ },
277
+ "J-2179-11": {
278
+ "client": "CL-11",
279
+ "day": "2025-07-30",
280
+ "hub": "North",
281
+ "service": "safety",
282
+ "start": "10:00",
283
+ "state": "cancelled"
284
+ },
285
+ "J-2518-1": {
286
+ "client": "CL-1",
287
+ "day": "2025-07-31",
288
+ "hub": "West",
289
+ "service": "safety",
290
+ "start": "15:00",
291
+ "state": "confirmed"
292
+ },
293
+ "J-2787-0": {
294
+ "client": "CL-0",
295
+ "day": "2025-07-31",
296
+ "hub": "West",
297
+ "service": "safety",
298
+ "start": "08:00",
299
+ "state": "confirmed"
300
+ },
301
+ "J-2886-9": {
302
+ "client": "CL-9",
303
+ "day": "2025-08-02",
304
+ "hub": "West",
305
+ "service": "controls",
306
+ "start": "08:00",
307
+ "state": "confirmed"
308
+ },
309
+ "J-3686-10": {
310
+ "client": "CL-10",
311
+ "day": "2025-08-02",
312
+ "hub": "North",
313
+ "service": "safety",
314
+ "start": "15:00",
315
+ "state": "confirmed"
316
+ },
317
+ "J-4416-2": {
318
+ "client": "CL-2",
319
+ "day": "2025-07-31",
320
+ "hub": "West",
321
+ "service": "controls",
322
+ "start": "08:00",
323
+ "state": "confirmed"
324
+ },
325
+ "J-5659-8": {
326
+ "client": "CL-8",
327
+ "day": "2025-07-30",
328
+ "hub": "North",
329
+ "service": "network",
330
+ "start": "15:00",
331
+ "state": "confirmed"
332
+ },
333
+ "J-8434-7": {
334
+ "client": "CL-7",
335
+ "day": "2025-08-02",
336
+ "hub": "North",
337
+ "service": "network",
338
+ "start": "15:00",
339
+ "state": "cancelled"
340
+ },
341
+ "J-9065-3": {
342
+ "client": "CL-3",
343
+ "day": "2025-07-31",
344
+ "hub": "West",
345
+ "service": "network",
346
+ "start": "13:00",
347
+ "state": "confirmed"
348
+ },
349
+ "J-9143-6": {
350
+ "client": "CL-6",
351
+ "day": "2025-07-30",
352
+ "hub": "West",
353
+ "service": "safety",
354
+ "start": "10:00",
355
+ "state": "cancelled"
356
+ }
357
+ }
358
+ }
tasks/autom-field-service-rebooking-008-v2/tests/world_check.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Replay submitted mutations from the private verifier's initial state."""
2
+ from types import ModuleType
3
+ import json
4
+
5
+
6
+ def check(spec, outputs, tests):
7
+ replay = ModuleType('workflow_replay')
8
+ exec(compile((tests/'replay.py').read_bytes(), 'replay.py', 'exec'), replay.__dict__)
9
+ world = json.loads((tests/'world.json').read_text())
10
+ target = json.loads((tests/'target.json').read_text())
11
+ # Only fields whose starting and expected values differ may be changed. Attempts
12
+ # to temporarily alter a protected field fail even when a later write restores it.
13
+ allowed = {
14
+ (app,key): {field for field,value in doc.items()
15
+ if field not in world[app].get(key,{}) or not replay.same(world[app][key][field],value)}
16
+ for app,records in target.items() for key,doc in records.items()
17
+ }
18
+ actions = replay.load_actions(outputs/'actions.jsonl')
19
+ for event in actions:
20
+ replay.apply(world,event)
21
+ touched = set(event['fields'])
22
+ if not touched <= allowed.get((event['app'],event['id']),set()):
23
+ return False,'protected field or record write'
24
+ if not replay.same(world,target):
25
+ return False,'required business outcomes incomplete'
26
+ return True,''
tasks/autom-field-service-rebooking-008-v2/validation/openenv.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "profile": "harbor-semantic-v1",
3
+ "reward_key": "reward",
4
+ "reward": {
5
+ "range": [
6
+ 0,
7
+ 1
8
+ ],
9
+ "oracle_tolerance": 0,
10
+ "floor_margin": 0.1
11
+ },
12
+ "resources": {
13
+ "cpu": 1,
14
+ "memory_mb": 4096,
15
+ "disk_mb": 10240,
16
+ "episode_timeout_s": 1800
17
+ },
18
+ "types": {
19
+ "tags": [
20
+ "knowledge-work",
21
+ "cross-app-workflows",
22
+ "conditional-execution",
23
+ "protected-state",
24
+ "operations"
25
+ ]
26
+ },
27
+ "requires_credentials": false
28
+ }
tasks/autom-field-service-rebooking-009-v2/environment/inputs/apps.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Offline business-app client. Print usage with --help."""
2
+ import argparse
3
+ import copy
4
+ import fcntl
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+
9
+
10
+ def same(left, right):
11
+ return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
12
+
13
+
14
+ def apply(world, action):
15
+ if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}:
16
+ raise ValueError('expected op, app, id, fields')
17
+ op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields'))
18
+ if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields:
19
+ raise ValueError('unknown app, invalid id or empty fields')
20
+ collection = world[app]
21
+ if op == 'update' and key in collection:
22
+ collection[key].update(copy.deepcopy(fields))
23
+ elif op == 'create' and key not in collection:
24
+ collection[key] = copy.deepcopy(fields)
25
+ else:
26
+ raise ValueError(f'invalid {op} for {app}/{key}')
27
+
28
+
29
+ def load_actions(path):
30
+ if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000):
31
+ raise ValueError('invalid action log')
32
+ if not path.exists():
33
+ return []
34
+ return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
35
+
36
+
37
+ def main():
38
+ parser = argparse.ArgumentParser(description=__doc__)
39
+ parser.add_argument('op', choices=('apps','list','get','update','create'))
40
+ parser.add_argument('app', nargs='?')
41
+ parser.add_argument('id', nargs='?')
42
+ parser.add_argument('fields', nargs='?', type=json.loads)
43
+ args = parser.parse_args()
44
+ world = json.loads(Path(__file__).with_name('world.json').read_text())
45
+ out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs'))
46
+ out.mkdir(parents=True, exist_ok=True)
47
+ log = out/'actions.jsonl'
48
+ with (out/'.actions.lock').open('a') as lock:
49
+ fcntl.flock(lock.fileno(), fcntl.LOCK_EX)
50
+ for event in load_actions(log):
51
+ apply(world,event)
52
+ if args.op=='apps':
53
+ value=sorted(world)
54
+ elif args.op=='list':
55
+ value=world[args.app]
56
+ elif args.op=='get':
57
+ value=world[args.app][args.id]
58
+ else:
59
+ event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields}
60
+ apply(world,event)
61
+ with log.open('a') as handle:
62
+ handle.write(json.dumps(event,allow_nan=False)+'\n')
63
+ value=world[args.app][args.id]
64
+ print(json.dumps(value,sort_keys=True,allow_nan=False))
65
+
66
+
67
+ if __name__=='__main__':
68
+ main()
tasks/autom-field-service-rebooking-009-v2/environment/inputs/world.json ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accounts": {
3
+ "CL-0": {
4
+ "allow_remote": true,
5
+ "tier": "standard"
6
+ },
7
+ "CL-1": {
8
+ "allow_remote": true,
9
+ "tier": "standard"
10
+ },
11
+ "CL-10": {
12
+ "allow_remote": false,
13
+ "tier": "priority"
14
+ },
15
+ "CL-11": {
16
+ "allow_remote": false,
17
+ "tier": "standard"
18
+ },
19
+ "CL-2": {
20
+ "allow_remote": false,
21
+ "tier": "priority"
22
+ },
23
+ "CL-3": {
24
+ "allow_remote": false,
25
+ "tier": "priority"
26
+ },
27
+ "CL-4": {
28
+ "allow_remote": true,
29
+ "tier": "priority"
30
+ },
31
+ "CL-5": {
32
+ "allow_remote": false,
33
+ "tier": "standard"
34
+ },
35
+ "CL-6": {
36
+ "allow_remote": false,
37
+ "tier": "priority"
38
+ },
39
+ "CL-7": {
40
+ "allow_remote": false,
41
+ "tier": "standard"
42
+ },
43
+ "CL-8": {
44
+ "allow_remote": true,
45
+ "tier": "priority"
46
+ },
47
+ "CL-9": {
48
+ "allow_remote": false,
49
+ "tier": "priority"
50
+ }
51
+ },
52
+ "calendar": {
53
+ "S00": {
54
+ "crew": "T0",
55
+ "day": "2025-08-24",
56
+ "mode": "onsite",
57
+ "start": "13:00",
58
+ "state": "available"
59
+ },
60
+ "S01": {
61
+ "crew": "T5",
62
+ "day": "2025-08-26",
63
+ "mode": "onsite",
64
+ "start": "08:00",
65
+ "state": "available"
66
+ },
67
+ "S02": {
68
+ "crew": "T3",
69
+ "day": "2025-08-26",
70
+ "mode": "onsite",
71
+ "start": "15:00",
72
+ "state": "available"
73
+ },
74
+ "S03": {
75
+ "crew": "T2",
76
+ "day": "2025-08-28",
77
+ "mode": "remote",
78
+ "start": "08:00",
79
+ "state": "available"
80
+ },
81
+ "S04": {
82
+ "crew": "T6",
83
+ "day": "2025-08-27",
84
+ "mode": "onsite",
85
+ "start": "10:00",
86
+ "state": "available"
87
+ },
88
+ "S05": {
89
+ "crew": "T0",
90
+ "day": "2025-08-24",
91
+ "mode": "onsite",
92
+ "start": "15:00",
93
+ "state": "available"
94
+ },
95
+ "S06": {
96
+ "crew": "T0",
97
+ "day": "2025-08-28",
98
+ "mode": "onsite",
99
+ "start": "15:00",
100
+ "state": "available"
101
+ },
102
+ "S07": {
103
+ "crew": "T2",
104
+ "day": "2025-08-25",
105
+ "mode": "remote",
106
+ "start": "10:00",
107
+ "state": "available"
108
+ },
109
+ "S08": {
110
+ "crew": "T6",
111
+ "day": "2025-08-27",
112
+ "mode": "onsite",
113
+ "start": "13:00",
114
+ "state": "occupied"
115
+ },
116
+ "S09": {
117
+ "crew": "T2",
118
+ "day": "2025-08-24",
119
+ "mode": "onsite",
120
+ "start": "10:00",
121
+ "state": "available"
122
+ },
123
+ "S10": {
124
+ "crew": "T2",
125
+ "day": "2025-08-30",
126
+ "mode": "remote",
127
+ "start": "15:00",
128
+ "state": "available"
129
+ },
130
+ "S11": {
131
+ "crew": "T6",
132
+ "day": "2025-08-29",
133
+ "mode": "onsite",
134
+ "start": "08:00",
135
+ "state": "available"
136
+ },
137
+ "S12": {
138
+ "crew": "T4",
139
+ "day": "2025-08-28",
140
+ "mode": "remote",
141
+ "start": "10:00",
142
+ "state": "available"
143
+ },
144
+ "S13": {
145
+ "crew": "T4",
146
+ "day": "2025-08-24",
147
+ "mode": "onsite",
148
+ "start": "10:00",
149
+ "state": "available"
150
+ },
151
+ "S14": {
152
+ "crew": "T2",
153
+ "day": "2025-08-24",
154
+ "mode": "onsite",
155
+ "start": "13:00",
156
+ "state": "available"
157
+ },
158
+ "S15": {
159
+ "crew": "T0",
160
+ "day": "2025-08-29",
161
+ "mode": "onsite",
162
+ "start": "08:00",
163
+ "state": "available"
164
+ }
165
+ },
166
+ "dispatch": {
167
+ "DISPATCH-OLD": {
168
+ "status": "closed",
169
+ "work_order": "archived"
170
+ }
171
+ },
172
+ "technicians": {
173
+ "T0": {
174
+ "active": true,
175
+ "home": "North",
176
+ "skills": [
177
+ "network",
178
+ "safety",
179
+ "controls"
180
+ ]
181
+ },
182
+ "T1": {
183
+ "active": true,
184
+ "home": "North",
185
+ "skills": [
186
+ "controls"
187
+ ]
188
+ },
189
+ "T2": {
190
+ "active": true,
191
+ "home": "North",
192
+ "skills": [
193
+ "controls",
194
+ "network",
195
+ "safety"
196
+ ]
197
+ },
198
+ "T3": {
199
+ "active": true,
200
+ "home": "North",
201
+ "skills": [
202
+ "network"
203
+ ]
204
+ },
205
+ "T4": {
206
+ "active": true,
207
+ "home": "North",
208
+ "skills": [
209
+ "safety",
210
+ "network",
211
+ "controls"
212
+ ]
213
+ },
214
+ "T5": {
215
+ "active": true,
216
+ "home": "South",
217
+ "skills": [
218
+ "safety",
219
+ "network"
220
+ ]
221
+ },
222
+ "T6": {
223
+ "active": false,
224
+ "home": "South",
225
+ "skills": [
226
+ "network",
227
+ "safety"
228
+ ]
229
+ }
230
+ },
231
+ "work_orders": {
232
+ "J-1706-3": {
233
+ "client": "CL-3",
234
+ "day": "2025-08-23",
235
+ "hub": "North",
236
+ "service": "safety",
237
+ "start": "13:00",
238
+ "state": "confirmed"
239
+ },
240
+ "J-2384-7": {
241
+ "client": "CL-7",
242
+ "day": "2025-08-23",
243
+ "hub": "South",
244
+ "service": "controls",
245
+ "start": "10:00",
246
+ "state": "cancelled"
247
+ },
248
+ "J-2447-4": {
249
+ "client": "CL-4",
250
+ "day": "2025-08-23",
251
+ "hub": "North",
252
+ "service": "controls",
253
+ "start": "10:00",
254
+ "state": "confirmed"
255
+ },
256
+ "J-2899-9": {
257
+ "client": "CL-9",
258
+ "day": "2025-08-24",
259
+ "hub": "South",
260
+ "service": "controls",
261
+ "start": "13:00",
262
+ "state": "cancelled"
263
+ },
264
+ "J-2907-6": {
265
+ "client": "CL-6",
266
+ "day": "2025-08-23",
267
+ "hub": "North",
268
+ "service": "network",
269
+ "start": "15:00",
270
+ "state": "confirmed"
271
+ },
272
+ "J-3409-11": {
273
+ "client": "CL-11",
274
+ "day": "2025-08-21",
275
+ "hub": "South",
276
+ "service": "safety",
277
+ "start": "13:00",
278
+ "state": "confirmed"
279
+ },
280
+ "J-7516-1": {
281
+ "client": "CL-1",
282
+ "day": "2025-08-23",
283
+ "hub": "North",
284
+ "service": "safety",
285
+ "start": "15:00",
286
+ "state": "confirmed"
287
+ },
288
+ "J-7560-8": {
289
+ "client": "CL-8",
290
+ "day": "2025-08-25",
291
+ "hub": "North",
292
+ "service": "network",
293
+ "start": "15:00",
294
+ "state": "cancelled"
295
+ },
296
+ "J-8037-5": {
297
+ "client": "CL-5",
298
+ "day": "2025-08-23",
299
+ "hub": "North",
300
+ "service": "network",
301
+ "start": "15:00",
302
+ "state": "confirmed"
303
+ },
304
+ "J-9220-2": {
305
+ "client": "CL-2",
306
+ "day": "2025-08-23",
307
+ "hub": "North",
308
+ "service": "network",
309
+ "start": "13:00",
310
+ "state": "confirmed"
311
+ },
312
+ "J-9532-10": {
313
+ "client": "CL-10",
314
+ "day": "2025-08-21",
315
+ "hub": "North",
316
+ "service": "network",
317
+ "start": "10:00",
318
+ "state": "confirmed"
319
+ },
320
+ "J-9563-0": {
321
+ "client": "CL-0",
322
+ "day": "2025-08-23",
323
+ "hub": "North",
324
+ "service": "network",
325
+ "start": "15:00",
326
+ "state": "confirmed"
327
+ }
328
+ }
329
+ }
tasks/autom-field-service-rebooking-009-v2/instruction.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ A 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.
2
+
3
+ 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.
4
+
5
+ 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.
6
+
7
+ 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.
8
+
9
+ Use the offline app client at `/workspace/inputs/apps.py`. Call it with python3. Run
10
+ `apps` to discover apps, `list APP` to see its records, or `get APP ID` for one record.
11
+ Write with `update APP ID '{"field":"value"}'` or `create APP ID '{"field":"value"}'`.
12
+ The client records successful writes in `/workspace/outputs/actions.jsonl`.
13
+ Apply exactly the required changes. Other records and fields must remain untouched,
14
+ including temporary changes. Actions take effect in the local simulation only.
15
+
16
+ ## Deliverable
17
+
18
+ Work in `/workspace`. Input files are under `/workspace/inputs/`. Put every deliverable in
19
+ `/workspace/outputs/`; only that directory is graded. Leave the app action log in the outputs directory.
tasks/autom-field-service-rebooking-009-v2/solution/files/actions.jsonl ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-9220-2"}, "id": "S00", "op": "update"}
2
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-8037-5"}, "id": "S02", "op": "update"}
3
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-7516-1"}, "id": "S05", "op": "update"}
4
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-9563-0"}, "id": "S07", "op": "update"}
5
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-2447-4"}, "id": "S09", "op": "update"}
6
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-1706-3"}, "id": "S13", "op": "update"}
7
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-2907-6"}, "id": "S14", "op": "update"}
8
+ {"app": "work_orders", "fields": {"new_slot": "S13", "state": "rebooked"}, "id": "J-1706-3", "op": "update"}
9
+ {"app": "work_orders", "fields": {"new_slot": "S09", "state": "rebooked"}, "id": "J-2447-4", "op": "update"}
10
+ {"app": "work_orders", "fields": {"new_slot": "S14", "state": "rebooked"}, "id": "J-2907-6", "op": "update"}
11
+ {"app": "work_orders", "fields": {"new_slot": "S05", "state": "rebooked"}, "id": "J-7516-1", "op": "update"}
12
+ {"app": "work_orders", "fields": {"new_slot": "S02", "state": "rebooked"}, "id": "J-8037-5", "op": "update"}
13
+ {"app": "work_orders", "fields": {"new_slot": "S00", "state": "rebooked"}, "id": "J-9220-2", "op": "update"}
14
+ {"app": "work_orders", "fields": {"new_slot": "S07", "state": "rebooked"}, "id": "J-9563-0", "op": "update"}
tasks/autom-field-service-rebooking-009-v2/solution/solve.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -eu
3
+ mkdir -p /workspace/outputs
4
+ cp -R /solution/files/. /workspace/outputs/
tasks/autom-field-service-rebooking-009-v2/task.toml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ schema_version = "1.3"
2
+
3
+ [task]
4
+ name = "apex-gap/autom-field-service-rebooking-009-v2"
5
+
6
+ [metadata.apex_gap]
7
+ capability_tags = ["cross-app-workflows", "conditional-execution", "protected-state", "operations"]
8
+ dataset = "Original simulated workflows"
9
+ job = "operations"
10
+ seed = 9
11
+ source = "local/original-automation-workflows"
12
+ source_revision = "2"
13
+ source_split = "synthetic"
14
+ source_task_id = "autom-field-service-rebooking-009"
15
+ template_family = "automation:field-service-rebooking"
16
+ workflow_template = "field-service-rebooking"
17
+
18
+ [metadata.openenv_hf_sandbox]
19
+ variant = "apex-gap-hfsandbox-v1"
20
+ task_modified_for_hf_sandbox = true
21
+ network_enabled = true
22
+
23
+ [environment]
24
+ docker_image = "ghcr.io/younesbelkada/apex@sha256:24969c952247033023872f87161a16e067003469506be63783bbaa5d96926bdf"
25
+ workdir = "/workspace"
26
+ cpus = 1
27
+ memory_mb = 4096
28
+ build_timeout_sec = 600
29
+ network_mode = "public"
30
+
31
+ [agent]
32
+ timeout_sec = 1800
33
+ network_mode = "public"
34
+
35
+ [verifier]
36
+ timeout_sec = 600
37
+ network_mode = "public"
38
+ environment_mode = "separate"
39
+
40
+ [verifier.environment]
41
+ network_mode = "public"
42
+ cpus = 1
43
+ memory_mb = 4096
44
+
45
+ [[artifacts]]
46
+ source = "/workspace/outputs"
tasks/autom-field-service-rebooking-009-v2/tests/expected.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "checks": [
3
+ {
4
+ "id": "business-outcomes",
5
+ "type": "custom",
6
+ "module": "world_check"
7
+ }
8
+ ]
9
+ }
tasks/autom-field-service-rebooking-009-v2/tests/grade.py ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Deterministic grader shared by converted knowledge-work tasks.
2
+
3
+ Runs inside the separate verifier sandbox. Reads /tests/expected.json, inspects the
4
+ submitted /workspace/outputs tree and writes a binary reward plus per-check details.
5
+ No model calls and no network.
6
+
7
+ expected.json: {"checks": [{"id": ..., "type": ..., ...}, ...]}
8
+ Check types:
9
+ answer field of outputs/answer.json; kind = number|text|choice|date|bool|list
10
+ xlsx_range recalculated outputs/<file> vs tests/<target> over sheet!range (SpreadsheetBench rules)
11
+ xlsx_cell recalculated outputs/<file> sheet!cell vs value with tolerance (optional alt_values)
12
+ file_contains outputs/<file> text (docx/pdf/ics/eml/txt) must contain every needle
13
+ custom tests/<module>.py defines check(spec, outputs_dir, tests_dir) -> (bool, str)
14
+ """
15
+
16
+ import datetime as dt
17
+ import json
18
+ import re
19
+ import shutil
20
+ import subprocess
21
+ import sys
22
+ import tempfile
23
+ import unicodedata
24
+ from pathlib import Path
25
+
26
+ OUT = Path("/workspace/outputs")
27
+ TESTS = Path("/tests")
28
+ LOGS = Path("/logs/verifier")
29
+
30
+
31
+ def norm_text(v):
32
+ v = unicodedata.normalize("NFKC", str(v)).casefold()
33
+ v = re.sub(r"[‘’“”]", "'", v)
34
+ v = re.sub(r"[^\w%.$/-]+", " ", v)
35
+ return " ".join(v.split()).strip(" .")
36
+
37
+
38
+ def to_number(v):
39
+ if isinstance(v, bool):
40
+ raise ValueError("bool")
41
+ if isinstance(v, (int, float)):
42
+ return float(v)
43
+ s = str(v).strip().replace(",", "").replace("$", "").replace("−", "-")
44
+ neg = s.startswith("(") and s.endswith(")")
45
+ s = s.strip("()").strip()
46
+ pct = s.endswith("%")
47
+ s = s.rstrip("%").strip()
48
+ s = re.sub(r"\s*(usd|dollars|million|billion|thousand|m|bn|k)$", "", s, flags=re.I)
49
+ x = float(s)
50
+ x = -x if neg else x
51
+ return x / 100 if pct else x
52
+
53
+
54
+ def number_ok(got, want, rel, abs_):
55
+ try:
56
+ g = to_number(got)
57
+ except (TypeError, ValueError):
58
+ return False
59
+ w = float(want)
60
+ tol = max(abs_, rel * abs(w))
61
+ # "12.5%" may mean the ratio 0.125 or the percent number 12.5; the gold fixes which.
62
+ candidates = [g, g * 100] if isinstance(got, str) and got.strip().endswith("%") else [g]
63
+ return any(abs(c - w) <= tol for c in candidates)
64
+
65
+
66
+ def parse_date(v):
67
+ if isinstance(v, (dt.date, dt.datetime)):
68
+ return v if isinstance(v, dt.date) else v.date()
69
+ s = str(v).strip()
70
+ for fmt in ("%Y-%m-%d", "%m/%d/%Y", "%m/%d/%y", "%d %B %Y", "%B %d, %Y", "%b %d, %Y", "%Y/%m/%d"):
71
+ try:
72
+ return dt.datetime.strptime(s, fmt).date()
73
+ except ValueError:
74
+ continue
75
+ raise ValueError(s)
76
+
77
+
78
+ def check_answer(check, answers):
79
+ key = check["field"]
80
+ if key not in answers:
81
+ return False, f"missing field {key!r}"
82
+ got, want, kind = answers[key], check["value"], check.get("kind", "text")
83
+ if kind == "number":
84
+ ok = number_ok(got, want, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01))
85
+ if not ok and check.get("percent_either"):
86
+ ok = number_ok(got, want * 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) * 100) or (
87
+ number_ok(got, want / 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) / 100)
88
+ )
89
+ elif kind == "date":
90
+ try:
91
+ ok = parse_date(got) == parse_date(want)
92
+ except ValueError:
93
+ ok = False
94
+ elif kind == "bool":
95
+ g = norm_text(got)
96
+ ok = g in {"yes", "true"} if want else g in {"no", "false"}
97
+ elif kind == "choice":
98
+ ok = norm_text(got) == norm_text(want)
99
+ elif kind == "list":
100
+ if not isinstance(got, list):
101
+ return False, f"{key}: expected a JSON list"
102
+ # Filenames may be given with a directory prefix; compare base names.
103
+ base = lambda x: norm_text(str(x).replace("\\", "/").rsplit("/", 1)[-1])
104
+ ok = sorted(base(x) for x in got) == sorted(base(x) for x in want)
105
+ else:
106
+ accepted = check.get("accept", [want])
107
+ ok = norm_text(got) in {norm_text(a) for a in accepted}
108
+ return ok, "" if ok else f"{key}: got {got!r}"
109
+
110
+
111
+ # LibreOffice keeps cached formula values on load unless told otherwise; force a full recalculation.
112
+ RECALC_PROFILE = """<?xml version="1.0" encoding="UTF-8"?>
113
+ <oor:items xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
114
+ <item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="OOXMLRecalcMode" oor:op="fuse"><value>0</value></prop></item>
115
+ <item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="ODFRecalcMode" oor:op="fuse"><value>0</value></prop></item>
116
+ </oor:items>
117
+ """
118
+
119
+
120
+ def recalc(path, tmp):
121
+ dest = Path(tmp) / f"recalc-{len(list(Path(tmp).glob('recalc-*')))}"
122
+ dest.mkdir()
123
+ profile = Path(tmp) / "lo-profile"
124
+ if not profile.exists():
125
+ (profile / "user").mkdir(parents=True)
126
+ (profile / "user" / "registrymodifications.xcu").write_text(RECALC_PROFILE)
127
+ subprocess.run(
128
+ ["soffice", f"-env:UserInstallation=file://{profile}", "--headless", "--calc", "--convert-to",
129
+ "xlsx:Calc MS Excel 2007 XML", "--outdir", str(dest), str(path)],
130
+ stdout=subprocess.DEVNULL,
131
+ stderr=subprocess.DEVNULL,
132
+ timeout=180,
133
+ check=False,
134
+ )
135
+ out = dest / (Path(path).stem + ".xlsx")
136
+ return out if out.exists() else Path(path)
137
+
138
+
139
+ def cell_value(v):
140
+ if isinstance(v, (int, float)) and not isinstance(v, bool):
141
+ return round(float(v), 2)
142
+ if isinstance(v, dt.datetime):
143
+ return round((v - dt.datetime(1899, 12, 30)).total_seconds() / 86400.0, 0)
144
+ if isinstance(v, dt.time):
145
+ return v.strftime("%H:%M")
146
+ if isinstance(v, str):
147
+ try:
148
+ return round(float(v), 2)
149
+ except ValueError:
150
+ return v.strip()
151
+ return v
152
+
153
+
154
+ def time_of(v):
155
+ """A time or a day fraction in [0, 1) as HH:MM, rounded to the nearest second first. Calc and
156
+ Excel store a time as that fraction; openpyxl returns a time only for time-formatted cells."""
157
+ if isinstance(v, dt.time):
158
+ v = (v.hour * 3600 + v.minute * 60 + v.second + v.microsecond / 1e6) / 86400
159
+ if isinstance(v, (int, float)) and not isinstance(v, bool) and 0 <= v < 1:
160
+ return (dt.datetime(1899, 12, 30) + dt.timedelta(seconds=round(v * 86400))).strftime("%H:%M")
161
+ return None
162
+
163
+
164
+ def same_cell(a, b):
165
+ if isinstance(a, dt.time) is not isinstance(b, dt.time):
166
+ n = b if isinstance(a, dt.time) else a
167
+ if time_of(n) is not None: # a time against a plain day fraction
168
+ return time_of(a) == time_of(b)
169
+ a, b = cell_value(a), cell_value(b)
170
+ if a in (None, "") and b in (None, ""):
171
+ return True
172
+ return type(a) is type(b) and a == b
173
+
174
+
175
+ ERRORS = {"#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A"}
176
+
177
+
178
+ def is_error(v):
179
+ return isinstance(v, str) and (v in ERRORS or v.startswith("Err:"))
180
+
181
+
182
+ def cells(rng):
183
+ if ":" not in rng:
184
+ return [rng]
185
+ from openpyxl.utils import range_boundaries, get_column_letter
186
+
187
+ c1, r1, c2, r2 = range_boundaries(rng)
188
+ return [f"{get_column_letter(c)}{r}" for r in range(r1, r2 + 1) for c in range(c1, c2 + 1)]
189
+
190
+
191
+ def load(path, tmp):
192
+ import openpyxl
193
+
194
+ return openpyxl.load_workbook(recalc(path, tmp), data_only=True)
195
+
196
+
197
+ def check_xlsx_range(check, tmp, cache):
198
+ sub = OUT / check["file"]
199
+ if not sub.is_file():
200
+ return False, f"missing output {check['file']}"
201
+ if sub not in cache:
202
+ cache[sub] = load(sub, tmp)
203
+ tgt = TESTS / check["target"]
204
+ if tgt not in cache:
205
+ cache[tgt] = load(tgt, tmp)
206
+ got, want = cache[sub], cache[tgt]
207
+ cached = None # the target's stored (Excel-computed) values, read only when Calc errs
208
+ for sheet, rng in check["ranges"]:
209
+ sheet = sheet or want.sheetnames[0]
210
+ if sheet not in got.sheetnames:
211
+ return False, f"sheet {sheet!r} missing"
212
+ for name in cells(rng):
213
+ w = want[sheet][name].value
214
+ if is_error(w):
215
+ # LibreOffice could not evaluate the gold formula (e.g. XLOOKUP, FILTER in Calc 7.4).
216
+ # The value Excel stored is the intended answer.
217
+ if cached is None:
218
+ import openpyxl
219
+
220
+ cached = openpyxl.load_workbook(tgt, data_only=True)
221
+ c = cached[sheet][name].value if sheet in cached.sheetnames else None
222
+ if c is not None and not is_error(c):
223
+ w = c
224
+ if not same_cell(w, got[sheet][name].value):
225
+ return False, f"{sheet}!{name}: want {w!r} got {got[sheet][name].value!r}"
226
+ return True, ""
227
+
228
+
229
+ def check_xlsx_cell(check, tmp, cache):
230
+ sub = OUT / check["file"]
231
+ if not sub.is_file():
232
+ return False, f"missing output {check['file']}"
233
+ if sub not in cache:
234
+ cache[sub] = load(sub, tmp)
235
+ wb = cache[sub]
236
+ if check["sheet"] not in wb.sheetnames:
237
+ return False, f"sheet {check['sheet']!r} missing"
238
+ got = wb[check["sheet"]][check["cell"]].value
239
+ want = check["value"]
240
+ if isinstance(want, (int, float)):
241
+ # alt_values: other accepted golds where the source admits more than one reading.
242
+ ok = got is not None and any(number_ok(got, w, check.get("rel_tol", 0.0), check.get("abs_tol", 0.01))
243
+ for w in [want, *check.get("alt_values", [])])
244
+ else:
245
+ ok = norm_text(got) == norm_text(want)
246
+ return ok, "" if ok else f"{check['sheet']}!{check['cell']}: want {want!r} got {got!r}"
247
+
248
+
249
+ def text_of(path):
250
+ suffix = path.suffix.lower()
251
+ if suffix == ".docx":
252
+ import docx
253
+
254
+ d = docx.Document(path)
255
+ parts = [p.text for p in d.paragraphs]
256
+ for t in d.tables:
257
+ parts += [c.text for row in t.rows for c in row.cells]
258
+ return "\n".join(parts)
259
+ if suffix == ".pdf":
260
+ import pdfplumber
261
+
262
+ with pdfplumber.open(path) as pdf:
263
+ return "\n".join(page.extract_text() or "" for page in pdf.pages)
264
+ return path.read_text(errors="replace")
265
+
266
+
267
+ def check_file_contains(check, tmp, cache):
268
+ sub = OUT / check["file"]
269
+ if not sub.is_file():
270
+ return False, f"missing output {check['file']}"
271
+ text = text_of(sub)
272
+ hay = text if check.get("case_sensitive") else text.casefold()
273
+ for needle in check["needles"]:
274
+ n = needle if check.get("case_sensitive") else needle.casefold()
275
+ if n not in hay:
276
+ return False, f"{check['file']} lacks {needle!r}"
277
+ return True, ""
278
+
279
+
280
+ def main():
281
+ LOGS.mkdir(parents=True, exist_ok=True)
282
+ reward_path = LOGS / "reward.txt"
283
+ reward_path.write_text("0\n")
284
+ spec = json.loads((TESTS / "expected.json").read_text())
285
+ answers, details = {}, []
286
+ answer_file = OUT / "answer.json"
287
+ if answer_file.is_file():
288
+ try:
289
+ answers = json.loads(answer_file.read_text())
290
+ if not isinstance(answers, dict):
291
+ answers = {}
292
+ except json.JSONDecodeError:
293
+ answers = {}
294
+ tmp = tempfile.mkdtemp()
295
+ cache = {}
296
+ try:
297
+ for check in spec["checks"]:
298
+ try:
299
+ if check["type"] == "answer":
300
+ ok, why = check_answer(check, answers)
301
+ elif check["type"] == "xlsx_range":
302
+ ok, why = check_xlsx_range(check, tmp, cache)
303
+ elif check["type"] == "xlsx_cell":
304
+ ok, why = check_xlsx_cell(check, tmp, cache)
305
+ elif check["type"] == "file_contains":
306
+ ok, why = check_file_contains(check, tmp, cache)
307
+ elif check["type"] == "custom":
308
+ import importlib.util
309
+
310
+ spec_ = importlib.util.spec_from_file_location("custom_check", TESTS / f"{check['module']}.py")
311
+ mod = importlib.util.module_from_spec(spec_)
312
+ spec_.loader.exec_module(mod)
313
+ ok, why = mod.check(check, OUT, TESTS)
314
+ else:
315
+ ok, why = False, f"unknown check type {check['type']}"
316
+ except Exception as exc: # a malformed submission fails the check, not the grader
317
+ ok, why = False, f"{type(exc).__name__}: {exc}"
318
+ details.append({"id": check["id"], "passed": ok, "detail": why})
319
+ finally:
320
+ shutil.rmtree(tmp, ignore_errors=True)
321
+ passed = sum(d["passed"] for d in details)
322
+ total = len(details)
323
+ reward = 1 if total and passed == total else 0
324
+ (LOGS / "details.json").write_text(json.dumps({"passed": passed, "total": total, "checks": details}, indent=1))
325
+ reward_path.write_text(f"{reward}\n")
326
+ print(f"{passed}/{total} checks passed; reward {reward}")
327
+
328
+
329
+ if __name__ == "__main__":
330
+ sys.exit(main())
tasks/autom-field-service-rebooking-009-v2/tests/replay.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Offline business-app client. Print usage with --help."""
2
+ import argparse
3
+ import copy
4
+ import fcntl
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+
9
+
10
+ def same(left, right):
11
+ return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
12
+
13
+
14
+ def apply(world, action):
15
+ if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}:
16
+ raise ValueError('expected op, app, id, fields')
17
+ op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields'))
18
+ if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields:
19
+ raise ValueError('unknown app, invalid id or empty fields')
20
+ collection = world[app]
21
+ if op == 'update' and key in collection:
22
+ collection[key].update(copy.deepcopy(fields))
23
+ elif op == 'create' and key not in collection:
24
+ collection[key] = copy.deepcopy(fields)
25
+ else:
26
+ raise ValueError(f'invalid {op} for {app}/{key}')
27
+
28
+
29
+ def load_actions(path):
30
+ if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000):
31
+ raise ValueError('invalid action log')
32
+ if not path.exists():
33
+ return []
34
+ return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
35
+
36
+
37
+ def main():
38
+ parser = argparse.ArgumentParser(description=__doc__)
39
+ parser.add_argument('op', choices=('apps','list','get','update','create'))
40
+ parser.add_argument('app', nargs='?')
41
+ parser.add_argument('id', nargs='?')
42
+ parser.add_argument('fields', nargs='?', type=json.loads)
43
+ args = parser.parse_args()
44
+ world = json.loads(Path(__file__).with_name('world.json').read_text())
45
+ out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs'))
46
+ out.mkdir(parents=True, exist_ok=True)
47
+ log = out/'actions.jsonl'
48
+ with (out/'.actions.lock').open('a') as lock:
49
+ fcntl.flock(lock.fileno(), fcntl.LOCK_EX)
50
+ for event in load_actions(log):
51
+ apply(world,event)
52
+ if args.op=='apps':
53
+ value=sorted(world)
54
+ elif args.op=='list':
55
+ value=world[args.app]
56
+ elif args.op=='get':
57
+ value=world[args.app][args.id]
58
+ else:
59
+ event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields}
60
+ apply(world,event)
61
+ with log.open('a') as handle:
62
+ handle.write(json.dumps(event,allow_nan=False)+'\n')
63
+ value=world[args.app][args.id]
64
+ print(json.dumps(value,sort_keys=True,allow_nan=False))
65
+
66
+
67
+ if __name__=='__main__':
68
+ main()
tasks/autom-field-service-rebooking-009-v2/tests/target.json ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accounts": {
3
+ "CL-0": {
4
+ "allow_remote": true,
5
+ "tier": "standard"
6
+ },
7
+ "CL-1": {
8
+ "allow_remote": true,
9
+ "tier": "standard"
10
+ },
11
+ "CL-10": {
12
+ "allow_remote": false,
13
+ "tier": "priority"
14
+ },
15
+ "CL-11": {
16
+ "allow_remote": false,
17
+ "tier": "standard"
18
+ },
19
+ "CL-2": {
20
+ "allow_remote": false,
21
+ "tier": "priority"
22
+ },
23
+ "CL-3": {
24
+ "allow_remote": false,
25
+ "tier": "priority"
26
+ },
27
+ "CL-4": {
28
+ "allow_remote": true,
29
+ "tier": "priority"
30
+ },
31
+ "CL-5": {
32
+ "allow_remote": false,
33
+ "tier": "standard"
34
+ },
35
+ "CL-6": {
36
+ "allow_remote": false,
37
+ "tier": "priority"
38
+ },
39
+ "CL-7": {
40
+ "allow_remote": false,
41
+ "tier": "standard"
42
+ },
43
+ "CL-8": {
44
+ "allow_remote": true,
45
+ "tier": "priority"
46
+ },
47
+ "CL-9": {
48
+ "allow_remote": false,
49
+ "tier": "priority"
50
+ }
51
+ },
52
+ "calendar": {
53
+ "S00": {
54
+ "crew": "T0",
55
+ "day": "2025-08-24",
56
+ "mode": "onsite",
57
+ "start": "13:00",
58
+ "state": "reserved",
59
+ "work_order": "J-9220-2"
60
+ },
61
+ "S01": {
62
+ "crew": "T5",
63
+ "day": "2025-08-26",
64
+ "mode": "onsite",
65
+ "start": "08:00",
66
+ "state": "available"
67
+ },
68
+ "S02": {
69
+ "crew": "T3",
70
+ "day": "2025-08-26",
71
+ "mode": "onsite",
72
+ "start": "15:00",
73
+ "state": "reserved",
74
+ "work_order": "J-8037-5"
75
+ },
76
+ "S03": {
77
+ "crew": "T2",
78
+ "day": "2025-08-28",
79
+ "mode": "remote",
80
+ "start": "08:00",
81
+ "state": "available"
82
+ },
83
+ "S04": {
84
+ "crew": "T6",
85
+ "day": "2025-08-27",
86
+ "mode": "onsite",
87
+ "start": "10:00",
88
+ "state": "available"
89
+ },
90
+ "S05": {
91
+ "crew": "T0",
92
+ "day": "2025-08-24",
93
+ "mode": "onsite",
94
+ "start": "15:00",
95
+ "state": "reserved",
96
+ "work_order": "J-7516-1"
97
+ },
98
+ "S06": {
99
+ "crew": "T0",
100
+ "day": "2025-08-28",
101
+ "mode": "onsite",
102
+ "start": "15:00",
103
+ "state": "available"
104
+ },
105
+ "S07": {
106
+ "crew": "T2",
107
+ "day": "2025-08-25",
108
+ "mode": "remote",
109
+ "start": "10:00",
110
+ "state": "reserved",
111
+ "work_order": "J-9563-0"
112
+ },
113
+ "S08": {
114
+ "crew": "T6",
115
+ "day": "2025-08-27",
116
+ "mode": "onsite",
117
+ "start": "13:00",
118
+ "state": "occupied"
119
+ },
120
+ "S09": {
121
+ "crew": "T2",
122
+ "day": "2025-08-24",
123
+ "mode": "onsite",
124
+ "start": "10:00",
125
+ "state": "reserved",
126
+ "work_order": "J-2447-4"
127
+ },
128
+ "S10": {
129
+ "crew": "T2",
130
+ "day": "2025-08-30",
131
+ "mode": "remote",
132
+ "start": "15:00",
133
+ "state": "available"
134
+ },
135
+ "S11": {
136
+ "crew": "T6",
137
+ "day": "2025-08-29",
138
+ "mode": "onsite",
139
+ "start": "08:00",
140
+ "state": "available"
141
+ },
142
+ "S12": {
143
+ "crew": "T4",
144
+ "day": "2025-08-28",
145
+ "mode": "remote",
146
+ "start": "10:00",
147
+ "state": "available"
148
+ },
149
+ "S13": {
150
+ "crew": "T4",
151
+ "day": "2025-08-24",
152
+ "mode": "onsite",
153
+ "start": "10:00",
154
+ "state": "reserved",
155
+ "work_order": "J-1706-3"
156
+ },
157
+ "S14": {
158
+ "crew": "T2",
159
+ "day": "2025-08-24",
160
+ "mode": "onsite",
161
+ "start": "13:00",
162
+ "state": "reserved",
163
+ "work_order": "J-2907-6"
164
+ },
165
+ "S15": {
166
+ "crew": "T0",
167
+ "day": "2025-08-29",
168
+ "mode": "onsite",
169
+ "start": "08:00",
170
+ "state": "available"
171
+ }
172
+ },
173
+ "dispatch": {
174
+ "DISPATCH-OLD": {
175
+ "status": "closed",
176
+ "work_order": "archived"
177
+ }
178
+ },
179
+ "technicians": {
180
+ "T0": {
181
+ "active": true,
182
+ "home": "North",
183
+ "skills": [
184
+ "network",
185
+ "safety",
186
+ "controls"
187
+ ]
188
+ },
189
+ "T1": {
190
+ "active": true,
191
+ "home": "North",
192
+ "skills": [
193
+ "controls"
194
+ ]
195
+ },
196
+ "T2": {
197
+ "active": true,
198
+ "home": "North",
199
+ "skills": [
200
+ "controls",
201
+ "network",
202
+ "safety"
203
+ ]
204
+ },
205
+ "T3": {
206
+ "active": true,
207
+ "home": "North",
208
+ "skills": [
209
+ "network"
210
+ ]
211
+ },
212
+ "T4": {
213
+ "active": true,
214
+ "home": "North",
215
+ "skills": [
216
+ "safety",
217
+ "network",
218
+ "controls"
219
+ ]
220
+ },
221
+ "T5": {
222
+ "active": true,
223
+ "home": "South",
224
+ "skills": [
225
+ "safety",
226
+ "network"
227
+ ]
228
+ },
229
+ "T6": {
230
+ "active": false,
231
+ "home": "South",
232
+ "skills": [
233
+ "network",
234
+ "safety"
235
+ ]
236
+ }
237
+ },
238
+ "work_orders": {
239
+ "J-1706-3": {
240
+ "client": "CL-3",
241
+ "day": "2025-08-23",
242
+ "hub": "North",
243
+ "new_slot": "S13",
244
+ "service": "safety",
245
+ "start": "13:00",
246
+ "state": "rebooked"
247
+ },
248
+ "J-2384-7": {
249
+ "client": "CL-7",
250
+ "day": "2025-08-23",
251
+ "hub": "South",
252
+ "service": "controls",
253
+ "start": "10:00",
254
+ "state": "cancelled"
255
+ },
256
+ "J-2447-4": {
257
+ "client": "CL-4",
258
+ "day": "2025-08-23",
259
+ "hub": "North",
260
+ "new_slot": "S09",
261
+ "service": "controls",
262
+ "start": "10:00",
263
+ "state": "rebooked"
264
+ },
265
+ "J-2899-9": {
266
+ "client": "CL-9",
267
+ "day": "2025-08-24",
268
+ "hub": "South",
269
+ "service": "controls",
270
+ "start": "13:00",
271
+ "state": "cancelled"
272
+ },
273
+ "J-2907-6": {
274
+ "client": "CL-6",
275
+ "day": "2025-08-23",
276
+ "hub": "North",
277
+ "new_slot": "S14",
278
+ "service": "network",
279
+ "start": "15:00",
280
+ "state": "rebooked"
281
+ },
282
+ "J-3409-11": {
283
+ "client": "CL-11",
284
+ "day": "2025-08-21",
285
+ "hub": "South",
286
+ "service": "safety",
287
+ "start": "13:00",
288
+ "state": "confirmed"
289
+ },
290
+ "J-7516-1": {
291
+ "client": "CL-1",
292
+ "day": "2025-08-23",
293
+ "hub": "North",
294
+ "new_slot": "S05",
295
+ "service": "safety",
296
+ "start": "15:00",
297
+ "state": "rebooked"
298
+ },
299
+ "J-7560-8": {
300
+ "client": "CL-8",
301
+ "day": "2025-08-25",
302
+ "hub": "North",
303
+ "service": "network",
304
+ "start": "15:00",
305
+ "state": "cancelled"
306
+ },
307
+ "J-8037-5": {
308
+ "client": "CL-5",
309
+ "day": "2025-08-23",
310
+ "hub": "North",
311
+ "new_slot": "S02",
312
+ "service": "network",
313
+ "start": "15:00",
314
+ "state": "rebooked"
315
+ },
316
+ "J-9220-2": {
317
+ "client": "CL-2",
318
+ "day": "2025-08-23",
319
+ "hub": "North",
320
+ "new_slot": "S00",
321
+ "service": "network",
322
+ "start": "13:00",
323
+ "state": "rebooked"
324
+ },
325
+ "J-9532-10": {
326
+ "client": "CL-10",
327
+ "day": "2025-08-21",
328
+ "hub": "North",
329
+ "service": "network",
330
+ "start": "10:00",
331
+ "state": "confirmed"
332
+ },
333
+ "J-9563-0": {
334
+ "client": "CL-0",
335
+ "day": "2025-08-23",
336
+ "hub": "North",
337
+ "new_slot": "S07",
338
+ "service": "network",
339
+ "start": "15:00",
340
+ "state": "rebooked"
341
+ }
342
+ }
343
+ }
tasks/autom-field-service-rebooking-009-v2/tests/test.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -eu
3
+ mkdir -p /logs/verifier /workspace/outputs
4
+ exec python3 -B -I /tests/grade.py
tasks/autom-field-service-rebooking-009-v2/tests/world.json ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accounts": {
3
+ "CL-0": {
4
+ "allow_remote": true,
5
+ "tier": "standard"
6
+ },
7
+ "CL-1": {
8
+ "allow_remote": true,
9
+ "tier": "standard"
10
+ },
11
+ "CL-10": {
12
+ "allow_remote": false,
13
+ "tier": "priority"
14
+ },
15
+ "CL-11": {
16
+ "allow_remote": false,
17
+ "tier": "standard"
18
+ },
19
+ "CL-2": {
20
+ "allow_remote": false,
21
+ "tier": "priority"
22
+ },
23
+ "CL-3": {
24
+ "allow_remote": false,
25
+ "tier": "priority"
26
+ },
27
+ "CL-4": {
28
+ "allow_remote": true,
29
+ "tier": "priority"
30
+ },
31
+ "CL-5": {
32
+ "allow_remote": false,
33
+ "tier": "standard"
34
+ },
35
+ "CL-6": {
36
+ "allow_remote": false,
37
+ "tier": "priority"
38
+ },
39
+ "CL-7": {
40
+ "allow_remote": false,
41
+ "tier": "standard"
42
+ },
43
+ "CL-8": {
44
+ "allow_remote": true,
45
+ "tier": "priority"
46
+ },
47
+ "CL-9": {
48
+ "allow_remote": false,
49
+ "tier": "priority"
50
+ }
51
+ },
52
+ "calendar": {
53
+ "S00": {
54
+ "crew": "T0",
55
+ "day": "2025-08-24",
56
+ "mode": "onsite",
57
+ "start": "13:00",
58
+ "state": "available"
59
+ },
60
+ "S01": {
61
+ "crew": "T5",
62
+ "day": "2025-08-26",
63
+ "mode": "onsite",
64
+ "start": "08:00",
65
+ "state": "available"
66
+ },
67
+ "S02": {
68
+ "crew": "T3",
69
+ "day": "2025-08-26",
70
+ "mode": "onsite",
71
+ "start": "15:00",
72
+ "state": "available"
73
+ },
74
+ "S03": {
75
+ "crew": "T2",
76
+ "day": "2025-08-28",
77
+ "mode": "remote",
78
+ "start": "08:00",
79
+ "state": "available"
80
+ },
81
+ "S04": {
82
+ "crew": "T6",
83
+ "day": "2025-08-27",
84
+ "mode": "onsite",
85
+ "start": "10:00",
86
+ "state": "available"
87
+ },
88
+ "S05": {
89
+ "crew": "T0",
90
+ "day": "2025-08-24",
91
+ "mode": "onsite",
92
+ "start": "15:00",
93
+ "state": "available"
94
+ },
95
+ "S06": {
96
+ "crew": "T0",
97
+ "day": "2025-08-28",
98
+ "mode": "onsite",
99
+ "start": "15:00",
100
+ "state": "available"
101
+ },
102
+ "S07": {
103
+ "crew": "T2",
104
+ "day": "2025-08-25",
105
+ "mode": "remote",
106
+ "start": "10:00",
107
+ "state": "available"
108
+ },
109
+ "S08": {
110
+ "crew": "T6",
111
+ "day": "2025-08-27",
112
+ "mode": "onsite",
113
+ "start": "13:00",
114
+ "state": "occupied"
115
+ },
116
+ "S09": {
117
+ "crew": "T2",
118
+ "day": "2025-08-24",
119
+ "mode": "onsite",
120
+ "start": "10:00",
121
+ "state": "available"
122
+ },
123
+ "S10": {
124
+ "crew": "T2",
125
+ "day": "2025-08-30",
126
+ "mode": "remote",
127
+ "start": "15:00",
128
+ "state": "available"
129
+ },
130
+ "S11": {
131
+ "crew": "T6",
132
+ "day": "2025-08-29",
133
+ "mode": "onsite",
134
+ "start": "08:00",
135
+ "state": "available"
136
+ },
137
+ "S12": {
138
+ "crew": "T4",
139
+ "day": "2025-08-28",
140
+ "mode": "remote",
141
+ "start": "10:00",
142
+ "state": "available"
143
+ },
144
+ "S13": {
145
+ "crew": "T4",
146
+ "day": "2025-08-24",
147
+ "mode": "onsite",
148
+ "start": "10:00",
149
+ "state": "available"
150
+ },
151
+ "S14": {
152
+ "crew": "T2",
153
+ "day": "2025-08-24",
154
+ "mode": "onsite",
155
+ "start": "13:00",
156
+ "state": "available"
157
+ },
158
+ "S15": {
159
+ "crew": "T0",
160
+ "day": "2025-08-29",
161
+ "mode": "onsite",
162
+ "start": "08:00",
163
+ "state": "available"
164
+ }
165
+ },
166
+ "dispatch": {
167
+ "DISPATCH-OLD": {
168
+ "status": "closed",
169
+ "work_order": "archived"
170
+ }
171
+ },
172
+ "technicians": {
173
+ "T0": {
174
+ "active": true,
175
+ "home": "North",
176
+ "skills": [
177
+ "network",
178
+ "safety",
179
+ "controls"
180
+ ]
181
+ },
182
+ "T1": {
183
+ "active": true,
184
+ "home": "North",
185
+ "skills": [
186
+ "controls"
187
+ ]
188
+ },
189
+ "T2": {
190
+ "active": true,
191
+ "home": "North",
192
+ "skills": [
193
+ "controls",
194
+ "network",
195
+ "safety"
196
+ ]
197
+ },
198
+ "T3": {
199
+ "active": true,
200
+ "home": "North",
201
+ "skills": [
202
+ "network"
203
+ ]
204
+ },
205
+ "T4": {
206
+ "active": true,
207
+ "home": "North",
208
+ "skills": [
209
+ "safety",
210
+ "network",
211
+ "controls"
212
+ ]
213
+ },
214
+ "T5": {
215
+ "active": true,
216
+ "home": "South",
217
+ "skills": [
218
+ "safety",
219
+ "network"
220
+ ]
221
+ },
222
+ "T6": {
223
+ "active": false,
224
+ "home": "South",
225
+ "skills": [
226
+ "network",
227
+ "safety"
228
+ ]
229
+ }
230
+ },
231
+ "work_orders": {
232
+ "J-1706-3": {
233
+ "client": "CL-3",
234
+ "day": "2025-08-23",
235
+ "hub": "North",
236
+ "service": "safety",
237
+ "start": "13:00",
238
+ "state": "confirmed"
239
+ },
240
+ "J-2384-7": {
241
+ "client": "CL-7",
242
+ "day": "2025-08-23",
243
+ "hub": "South",
244
+ "service": "controls",
245
+ "start": "10:00",
246
+ "state": "cancelled"
247
+ },
248
+ "J-2447-4": {
249
+ "client": "CL-4",
250
+ "day": "2025-08-23",
251
+ "hub": "North",
252
+ "service": "controls",
253
+ "start": "10:00",
254
+ "state": "confirmed"
255
+ },
256
+ "J-2899-9": {
257
+ "client": "CL-9",
258
+ "day": "2025-08-24",
259
+ "hub": "South",
260
+ "service": "controls",
261
+ "start": "13:00",
262
+ "state": "cancelled"
263
+ },
264
+ "J-2907-6": {
265
+ "client": "CL-6",
266
+ "day": "2025-08-23",
267
+ "hub": "North",
268
+ "service": "network",
269
+ "start": "15:00",
270
+ "state": "confirmed"
271
+ },
272
+ "J-3409-11": {
273
+ "client": "CL-11",
274
+ "day": "2025-08-21",
275
+ "hub": "South",
276
+ "service": "safety",
277
+ "start": "13:00",
278
+ "state": "confirmed"
279
+ },
280
+ "J-7516-1": {
281
+ "client": "CL-1",
282
+ "day": "2025-08-23",
283
+ "hub": "North",
284
+ "service": "safety",
285
+ "start": "15:00",
286
+ "state": "confirmed"
287
+ },
288
+ "J-7560-8": {
289
+ "client": "CL-8",
290
+ "day": "2025-08-25",
291
+ "hub": "North",
292
+ "service": "network",
293
+ "start": "15:00",
294
+ "state": "cancelled"
295
+ },
296
+ "J-8037-5": {
297
+ "client": "CL-5",
298
+ "day": "2025-08-23",
299
+ "hub": "North",
300
+ "service": "network",
301
+ "start": "15:00",
302
+ "state": "confirmed"
303
+ },
304
+ "J-9220-2": {
305
+ "client": "CL-2",
306
+ "day": "2025-08-23",
307
+ "hub": "North",
308
+ "service": "network",
309
+ "start": "13:00",
310
+ "state": "confirmed"
311
+ },
312
+ "J-9532-10": {
313
+ "client": "CL-10",
314
+ "day": "2025-08-21",
315
+ "hub": "North",
316
+ "service": "network",
317
+ "start": "10:00",
318
+ "state": "confirmed"
319
+ },
320
+ "J-9563-0": {
321
+ "client": "CL-0",
322
+ "day": "2025-08-23",
323
+ "hub": "North",
324
+ "service": "network",
325
+ "start": "15:00",
326
+ "state": "confirmed"
327
+ }
328
+ }
329
+ }
tasks/autom-field-service-rebooking-009-v2/tests/world_check.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Replay submitted mutations from the private verifier's initial state."""
2
+ from types import ModuleType
3
+ import json
4
+
5
+
6
+ def check(spec, outputs, tests):
7
+ replay = ModuleType('workflow_replay')
8
+ exec(compile((tests/'replay.py').read_bytes(), 'replay.py', 'exec'), replay.__dict__)
9
+ world = json.loads((tests/'world.json').read_text())
10
+ target = json.loads((tests/'target.json').read_text())
11
+ # Only fields whose starting and expected values differ may be changed. Attempts
12
+ # to temporarily alter a protected field fail even when a later write restores it.
13
+ allowed = {
14
+ (app,key): {field for field,value in doc.items()
15
+ if field not in world[app].get(key,{}) or not replay.same(world[app][key][field],value)}
16
+ for app,records in target.items() for key,doc in records.items()
17
+ }
18
+ actions = replay.load_actions(outputs/'actions.jsonl')
19
+ for event in actions:
20
+ replay.apply(world,event)
21
+ touched = set(event['fields'])
22
+ if not touched <= allowed.get((event['app'],event['id']),set()):
23
+ return False,'protected field or record write'
24
+ if not replay.same(world,target):
25
+ return False,'required business outcomes incomplete'
26
+ return True,''
tasks/autom-field-service-rebooking-009-v2/validation/openenv.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "profile": "harbor-semantic-v1",
3
+ "reward_key": "reward",
4
+ "reward": {
5
+ "range": [
6
+ 0,
7
+ 1
8
+ ],
9
+ "oracle_tolerance": 0,
10
+ "floor_margin": 0.1
11
+ },
12
+ "resources": {
13
+ "cpu": 1,
14
+ "memory_mb": 4096,
15
+ "disk_mb": 10240,
16
+ "episode_timeout_s": 1800
17
+ },
18
+ "types": {
19
+ "tags": [
20
+ "knowledge-work",
21
+ "cross-app-workflows",
22
+ "conditional-execution",
23
+ "protected-state",
24
+ "operations"
25
+ ]
26
+ },
27
+ "requires_credentials": false
28
+ }
tasks/autom-field-service-rebooking-010-v2/environment/inputs/apps.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Offline business-app client. Print usage with --help."""
2
+ import argparse
3
+ import copy
4
+ import fcntl
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+
9
+
10
+ def same(left, right):
11
+ return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
12
+
13
+
14
+ def apply(world, action):
15
+ if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}:
16
+ raise ValueError('expected op, app, id, fields')
17
+ op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields'))
18
+ if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields:
19
+ raise ValueError('unknown app, invalid id or empty fields')
20
+ collection = world[app]
21
+ if op == 'update' and key in collection:
22
+ collection[key].update(copy.deepcopy(fields))
23
+ elif op == 'create' and key not in collection:
24
+ collection[key] = copy.deepcopy(fields)
25
+ else:
26
+ raise ValueError(f'invalid {op} for {app}/{key}')
27
+
28
+
29
+ def load_actions(path):
30
+ if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000):
31
+ raise ValueError('invalid action log')
32
+ if not path.exists():
33
+ return []
34
+ return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
35
+
36
+
37
+ def main():
38
+ parser = argparse.ArgumentParser(description=__doc__)
39
+ parser.add_argument('op', choices=('apps','list','get','update','create'))
40
+ parser.add_argument('app', nargs='?')
41
+ parser.add_argument('id', nargs='?')
42
+ parser.add_argument('fields', nargs='?', type=json.loads)
43
+ args = parser.parse_args()
44
+ world = json.loads(Path(__file__).with_name('world.json').read_text())
45
+ out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs'))
46
+ out.mkdir(parents=True, exist_ok=True)
47
+ log = out/'actions.jsonl'
48
+ with (out/'.actions.lock').open('a') as lock:
49
+ fcntl.flock(lock.fileno(), fcntl.LOCK_EX)
50
+ for event in load_actions(log):
51
+ apply(world,event)
52
+ if args.op=='apps':
53
+ value=sorted(world)
54
+ elif args.op=='list':
55
+ value=world[args.app]
56
+ elif args.op=='get':
57
+ value=world[args.app][args.id]
58
+ else:
59
+ event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields}
60
+ apply(world,event)
61
+ with log.open('a') as handle:
62
+ handle.write(json.dumps(event,allow_nan=False)+'\n')
63
+ value=world[args.app][args.id]
64
+ print(json.dumps(value,sort_keys=True,allow_nan=False))
65
+
66
+
67
+ if __name__=='__main__':
68
+ main()
tasks/autom-field-service-rebooking-010-v2/environment/inputs/world.json ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accounts": {
3
+ "CL-0": {
4
+ "allow_remote": true,
5
+ "tier": "priority"
6
+ },
7
+ "CL-1": {
8
+ "allow_remote": false,
9
+ "tier": "standard"
10
+ },
11
+ "CL-10": {
12
+ "allow_remote": false,
13
+ "tier": "standard"
14
+ },
15
+ "CL-11": {
16
+ "allow_remote": true,
17
+ "tier": "priority"
18
+ },
19
+ "CL-12": {
20
+ "allow_remote": false,
21
+ "tier": "priority"
22
+ },
23
+ "CL-2": {
24
+ "allow_remote": false,
25
+ "tier": "standard"
26
+ },
27
+ "CL-3": {
28
+ "allow_remote": true,
29
+ "tier": "standard"
30
+ },
31
+ "CL-4": {
32
+ "allow_remote": false,
33
+ "tier": "priority"
34
+ },
35
+ "CL-5": {
36
+ "allow_remote": true,
37
+ "tier": "standard"
38
+ },
39
+ "CL-6": {
40
+ "allow_remote": true,
41
+ "tier": "priority"
42
+ },
43
+ "CL-7": {
44
+ "allow_remote": false,
45
+ "tier": "priority"
46
+ },
47
+ "CL-8": {
48
+ "allow_remote": false,
49
+ "tier": "priority"
50
+ },
51
+ "CL-9": {
52
+ "allow_remote": false,
53
+ "tier": "priority"
54
+ }
55
+ },
56
+ "calendar": {
57
+ "S00": {
58
+ "crew": "T0",
59
+ "day": "2025-09-16",
60
+ "mode": "onsite",
61
+ "start": "08:00",
62
+ "state": "available"
63
+ },
64
+ "S01": {
65
+ "crew": "T3",
66
+ "day": "2025-09-17",
67
+ "mode": "onsite",
68
+ "start": "08:00",
69
+ "state": "occupied"
70
+ },
71
+ "S02": {
72
+ "crew": "T2",
73
+ "day": "2025-09-19",
74
+ "mode": "remote",
75
+ "start": "15:00",
76
+ "state": "available"
77
+ },
78
+ "S03": {
79
+ "crew": "T3",
80
+ "day": "2025-09-16",
81
+ "mode": "onsite",
82
+ "start": "15:00",
83
+ "state": "available"
84
+ },
85
+ "S04": {
86
+ "crew": "T0",
87
+ "day": "2025-09-19",
88
+ "mode": "remote",
89
+ "start": "13:00",
90
+ "state": "available"
91
+ },
92
+ "S05": {
93
+ "crew": "T3",
94
+ "day": "2025-09-21",
95
+ "mode": "onsite",
96
+ "start": "08:00",
97
+ "state": "occupied"
98
+ },
99
+ "S06": {
100
+ "crew": "T2",
101
+ "day": "2025-09-18",
102
+ "mode": "onsite",
103
+ "start": "10:00",
104
+ "state": "available"
105
+ },
106
+ "S07": {
107
+ "crew": "T1",
108
+ "day": "2025-09-21",
109
+ "mode": "remote",
110
+ "start": "15:00",
111
+ "state": "available"
112
+ },
113
+ "S08": {
114
+ "crew": "T6",
115
+ "day": "2025-09-20",
116
+ "mode": "remote",
117
+ "start": "08:00",
118
+ "state": "occupied"
119
+ },
120
+ "S09": {
121
+ "crew": "T1",
122
+ "day": "2025-09-22",
123
+ "mode": "onsite",
124
+ "start": "10:00",
125
+ "state": "occupied"
126
+ },
127
+ "S10": {
128
+ "crew": "T5",
129
+ "day": "2025-09-17",
130
+ "mode": "onsite",
131
+ "start": "10:00",
132
+ "state": "available"
133
+ },
134
+ "S11": {
135
+ "crew": "T4",
136
+ "day": "2025-09-22",
137
+ "mode": "remote",
138
+ "start": "15:00",
139
+ "state": "available"
140
+ },
141
+ "S12": {
142
+ "crew": "T0",
143
+ "day": "2025-09-21",
144
+ "mode": "onsite",
145
+ "start": "08:00",
146
+ "state": "occupied"
147
+ },
148
+ "S13": {
149
+ "crew": "T1",
150
+ "day": "2025-09-19",
151
+ "mode": "remote",
152
+ "start": "15:00",
153
+ "state": "available"
154
+ },
155
+ "S14": {
156
+ "crew": "T2",
157
+ "day": "2025-09-18",
158
+ "mode": "remote",
159
+ "start": "08:00",
160
+ "state": "available"
161
+ },
162
+ "S15": {
163
+ "crew": "T1",
164
+ "day": "2025-09-17",
165
+ "mode": "remote",
166
+ "start": "15:00",
167
+ "state": "available"
168
+ }
169
+ },
170
+ "dispatch": {
171
+ "DISPATCH-OLD": {
172
+ "status": "closed",
173
+ "work_order": "archived"
174
+ }
175
+ },
176
+ "technicians": {
177
+ "T0": {
178
+ "active": true,
179
+ "home": "Central",
180
+ "skills": [
181
+ "network",
182
+ "safety",
183
+ "controls"
184
+ ]
185
+ },
186
+ "T1": {
187
+ "active": true,
188
+ "home": "Central",
189
+ "skills": [
190
+ "safety",
191
+ "network",
192
+ "controls"
193
+ ]
194
+ },
195
+ "T2": {
196
+ "active": true,
197
+ "home": "Central",
198
+ "skills": [
199
+ "network"
200
+ ]
201
+ },
202
+ "T3": {
203
+ "active": true,
204
+ "home": "Central",
205
+ "skills": [
206
+ "network",
207
+ "controls"
208
+ ]
209
+ },
210
+ "T4": {
211
+ "active": true,
212
+ "home": "Central",
213
+ "skills": [
214
+ "safety",
215
+ "network",
216
+ "controls"
217
+ ]
218
+ },
219
+ "T5": {
220
+ "active": true,
221
+ "home": "North",
222
+ "skills": [
223
+ "safety",
224
+ "network"
225
+ ]
226
+ },
227
+ "T6": {
228
+ "active": false,
229
+ "home": "North",
230
+ "skills": [
231
+ "controls",
232
+ "network",
233
+ "safety"
234
+ ]
235
+ }
236
+ },
237
+ "work_orders": {
238
+ "J-1186-6": {
239
+ "client": "CL-6",
240
+ "day": "2025-09-14",
241
+ "hub": "Central",
242
+ "service": "network",
243
+ "start": "10:00",
244
+ "state": "cancelled"
245
+ },
246
+ "J-1706-1": {
247
+ "client": "CL-1",
248
+ "day": "2025-09-15",
249
+ "hub": "Central",
250
+ "service": "network",
251
+ "start": "15:00",
252
+ "state": "confirmed"
253
+ },
254
+ "J-1883-8": {
255
+ "client": "CL-8",
256
+ "day": "2025-09-14",
257
+ "hub": "Central",
258
+ "service": "controls",
259
+ "start": "13:00",
260
+ "state": "confirmed"
261
+ },
262
+ "J-2427-3": {
263
+ "client": "CL-3",
264
+ "day": "2025-09-15",
265
+ "hub": "Central",
266
+ "service": "safety",
267
+ "start": "10:00",
268
+ "state": "confirmed"
269
+ },
270
+ "J-4289-11": {
271
+ "client": "CL-11",
272
+ "day": "2025-09-15",
273
+ "hub": "North",
274
+ "service": "controls",
275
+ "start": "08:00",
276
+ "state": "confirmed"
277
+ },
278
+ "J-4894-4": {
279
+ "client": "CL-4",
280
+ "day": "2025-09-15",
281
+ "hub": "Central",
282
+ "service": "safety",
283
+ "start": "10:00",
284
+ "state": "confirmed"
285
+ },
286
+ "J-4909-12": {
287
+ "client": "CL-12",
288
+ "day": "2025-09-13",
289
+ "hub": "Central",
290
+ "service": "safety",
291
+ "start": "15:00",
292
+ "state": "cancelled"
293
+ },
294
+ "J-7391-5": {
295
+ "client": "CL-5",
296
+ "day": "2025-09-15",
297
+ "hub": "Central",
298
+ "service": "network",
299
+ "start": "15:00",
300
+ "state": "confirmed"
301
+ },
302
+ "J-8143-7": {
303
+ "client": "CL-7",
304
+ "day": "2025-09-16",
305
+ "hub": "North",
306
+ "service": "controls",
307
+ "start": "15:00",
308
+ "state": "cancelled"
309
+ },
310
+ "J-8611-0": {
311
+ "client": "CL-0",
312
+ "day": "2025-09-15",
313
+ "hub": "Central",
314
+ "service": "safety",
315
+ "start": "08:00",
316
+ "state": "confirmed"
317
+ },
318
+ "J-8942-9": {
319
+ "client": "CL-9",
320
+ "day": "2025-09-13",
321
+ "hub": "Central",
322
+ "service": "safety",
323
+ "start": "10:00",
324
+ "state": "confirmed"
325
+ },
326
+ "J-9688-10": {
327
+ "client": "CL-10",
328
+ "day": "2025-09-15",
329
+ "hub": "North",
330
+ "service": "network",
331
+ "start": "08:00",
332
+ "state": "confirmed"
333
+ },
334
+ "J-9806-2": {
335
+ "client": "CL-2",
336
+ "day": "2025-09-15",
337
+ "hub": "Central",
338
+ "service": "network",
339
+ "start": "08:00",
340
+ "state": "confirmed"
341
+ }
342
+ }
343
+ }
tasks/autom-field-service-rebooking-010-v2/instruction.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ A 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.
2
+
3
+ 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.
4
+
5
+ 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.
6
+
7
+ 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.
8
+
9
+ Use the offline app client at `/workspace/inputs/apps.py`. Call it with python3. Run
10
+ `apps` to discover apps, `list APP` to see its records, or `get APP ID` for one record.
11
+ Write with `update APP ID '{"field":"value"}'` or `create APP ID '{"field":"value"}'`.
12
+ The client records successful writes in `/workspace/outputs/actions.jsonl`.
13
+ Apply exactly the required changes. Other records and fields must remain untouched,
14
+ including temporary changes. Actions take effect in the local simulation only.
15
+
16
+ ## Deliverable
17
+
18
+ Work in `/workspace`. Input files are under `/workspace/inputs/`. Put every deliverable in
19
+ `/workspace/outputs/`; only that directory is graded. Leave the app action log in the outputs directory.
tasks/autom-field-service-rebooking-010-v2/solution/files/actions.jsonl ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-8611-0"}, "id": "S00", "op": "update"}
2
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-9806-2"}, "id": "S03", "op": "update"}
3
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-1706-1"}, "id": "S06", "op": "update"}
4
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-7391-5"}, "id": "S14", "op": "update"}
5
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-2427-3"}, "id": "S15", "op": "update"}
6
+ {"app": "dispatch", "fields": {"client": "CL-4", "status": "needs_slot", "work_order": "J-4894-4"}, "id": "follow-J-4894-4", "op": "create"}
7
+ {"app": "work_orders", "fields": {"new_slot": "S06", "state": "rebooked"}, "id": "J-1706-1", "op": "update"}
8
+ {"app": "work_orders", "fields": {"new_slot": "S15", "state": "rebooked"}, "id": "J-2427-3", "op": "update"}
9
+ {"app": "work_orders", "fields": {"state": "manual"}, "id": "J-4894-4", "op": "update"}
10
+ {"app": "work_orders", "fields": {"new_slot": "S14", "state": "rebooked"}, "id": "J-7391-5", "op": "update"}
11
+ {"app": "work_orders", "fields": {"new_slot": "S00", "state": "rebooked"}, "id": "J-8611-0", "op": "update"}
12
+ {"app": "work_orders", "fields": {"new_slot": "S03", "state": "rebooked"}, "id": "J-9806-2", "op": "update"}
tasks/autom-field-service-rebooking-010-v2/solution/solve.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -eu
3
+ mkdir -p /workspace/outputs
4
+ cp -R /solution/files/. /workspace/outputs/
tasks/autom-field-service-rebooking-010-v2/task.toml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ schema_version = "1.3"
2
+
3
+ [task]
4
+ name = "apex-gap/autom-field-service-rebooking-010-v2"
5
+
6
+ [metadata.apex_gap]
7
+ capability_tags = ["cross-app-workflows", "conditional-execution", "protected-state", "operations"]
8
+ dataset = "Original simulated workflows"
9
+ job = "operations"
10
+ seed = 10
11
+ source = "local/original-automation-workflows"
12
+ source_revision = "2"
13
+ source_split = "synthetic"
14
+ source_task_id = "autom-field-service-rebooking-010"
15
+ template_family = "automation:field-service-rebooking"
16
+ workflow_template = "field-service-rebooking"
17
+
18
+ [metadata.openenv_hf_sandbox]
19
+ variant = "apex-gap-hfsandbox-v1"
20
+ task_modified_for_hf_sandbox = true
21
+ network_enabled = true
22
+
23
+ [environment]
24
+ docker_image = "ghcr.io/younesbelkada/apex@sha256:24969c952247033023872f87161a16e067003469506be63783bbaa5d96926bdf"
25
+ workdir = "/workspace"
26
+ cpus = 1
27
+ memory_mb = 4096
28
+ build_timeout_sec = 600
29
+ network_mode = "public"
30
+
31
+ [agent]
32
+ timeout_sec = 1800
33
+ network_mode = "public"
34
+
35
+ [verifier]
36
+ timeout_sec = 600
37
+ network_mode = "public"
38
+ environment_mode = "separate"
39
+
40
+ [verifier.environment]
41
+ network_mode = "public"
42
+ cpus = 1
43
+ memory_mb = 4096
44
+
45
+ [[artifacts]]
46
+ source = "/workspace/outputs"
tasks/autom-field-service-rebooking-010-v2/tests/expected.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "checks": [
3
+ {
4
+ "id": "business-outcomes",
5
+ "type": "custom",
6
+ "module": "world_check"
7
+ }
8
+ ]
9
+ }
tasks/autom-field-service-rebooking-010-v2/tests/grade.py ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Deterministic grader shared by converted knowledge-work tasks.
2
+
3
+ Runs inside the separate verifier sandbox. Reads /tests/expected.json, inspects the
4
+ submitted /workspace/outputs tree and writes a binary reward plus per-check details.
5
+ No model calls and no network.
6
+
7
+ expected.json: {"checks": [{"id": ..., "type": ..., ...}, ...]}
8
+ Check types:
9
+ answer field of outputs/answer.json; kind = number|text|choice|date|bool|list
10
+ xlsx_range recalculated outputs/<file> vs tests/<target> over sheet!range (SpreadsheetBench rules)
11
+ xlsx_cell recalculated outputs/<file> sheet!cell vs value with tolerance (optional alt_values)
12
+ file_contains outputs/<file> text (docx/pdf/ics/eml/txt) must contain every needle
13
+ custom tests/<module>.py defines check(spec, outputs_dir, tests_dir) -> (bool, str)
14
+ """
15
+
16
+ import datetime as dt
17
+ import json
18
+ import re
19
+ import shutil
20
+ import subprocess
21
+ import sys
22
+ import tempfile
23
+ import unicodedata
24
+ from pathlib import Path
25
+
26
+ OUT = Path("/workspace/outputs")
27
+ TESTS = Path("/tests")
28
+ LOGS = Path("/logs/verifier")
29
+
30
+
31
+ def norm_text(v):
32
+ v = unicodedata.normalize("NFKC", str(v)).casefold()
33
+ v = re.sub(r"[‘’“”]", "'", v)
34
+ v = re.sub(r"[^\w%.$/-]+", " ", v)
35
+ return " ".join(v.split()).strip(" .")
36
+
37
+
38
+ def to_number(v):
39
+ if isinstance(v, bool):
40
+ raise ValueError("bool")
41
+ if isinstance(v, (int, float)):
42
+ return float(v)
43
+ s = str(v).strip().replace(",", "").replace("$", "").replace("−", "-")
44
+ neg = s.startswith("(") and s.endswith(")")
45
+ s = s.strip("()").strip()
46
+ pct = s.endswith("%")
47
+ s = s.rstrip("%").strip()
48
+ s = re.sub(r"\s*(usd|dollars|million|billion|thousand|m|bn|k)$", "", s, flags=re.I)
49
+ x = float(s)
50
+ x = -x if neg else x
51
+ return x / 100 if pct else x
52
+
53
+
54
+ def number_ok(got, want, rel, abs_):
55
+ try:
56
+ g = to_number(got)
57
+ except (TypeError, ValueError):
58
+ return False
59
+ w = float(want)
60
+ tol = max(abs_, rel * abs(w))
61
+ # "12.5%" may mean the ratio 0.125 or the percent number 12.5; the gold fixes which.
62
+ candidates = [g, g * 100] if isinstance(got, str) and got.strip().endswith("%") else [g]
63
+ return any(abs(c - w) <= tol for c in candidates)
64
+
65
+
66
+ def parse_date(v):
67
+ if isinstance(v, (dt.date, dt.datetime)):
68
+ return v if isinstance(v, dt.date) else v.date()
69
+ s = str(v).strip()
70
+ for fmt in ("%Y-%m-%d", "%m/%d/%Y", "%m/%d/%y", "%d %B %Y", "%B %d, %Y", "%b %d, %Y", "%Y/%m/%d"):
71
+ try:
72
+ return dt.datetime.strptime(s, fmt).date()
73
+ except ValueError:
74
+ continue
75
+ raise ValueError(s)
76
+
77
+
78
+ def check_answer(check, answers):
79
+ key = check["field"]
80
+ if key not in answers:
81
+ return False, f"missing field {key!r}"
82
+ got, want, kind = answers[key], check["value"], check.get("kind", "text")
83
+ if kind == "number":
84
+ ok = number_ok(got, want, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01))
85
+ if not ok and check.get("percent_either"):
86
+ ok = number_ok(got, want * 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) * 100) or (
87
+ number_ok(got, want / 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) / 100)
88
+ )
89
+ elif kind == "date":
90
+ try:
91
+ ok = parse_date(got) == parse_date(want)
92
+ except ValueError:
93
+ ok = False
94
+ elif kind == "bool":
95
+ g = norm_text(got)
96
+ ok = g in {"yes", "true"} if want else g in {"no", "false"}
97
+ elif kind == "choice":
98
+ ok = norm_text(got) == norm_text(want)
99
+ elif kind == "list":
100
+ if not isinstance(got, list):
101
+ return False, f"{key}: expected a JSON list"
102
+ # Filenames may be given with a directory prefix; compare base names.
103
+ base = lambda x: norm_text(str(x).replace("\\", "/").rsplit("/", 1)[-1])
104
+ ok = sorted(base(x) for x in got) == sorted(base(x) for x in want)
105
+ else:
106
+ accepted = check.get("accept", [want])
107
+ ok = norm_text(got) in {norm_text(a) for a in accepted}
108
+ return ok, "" if ok else f"{key}: got {got!r}"
109
+
110
+
111
+ # LibreOffice keeps cached formula values on load unless told otherwise; force a full recalculation.
112
+ RECALC_PROFILE = """<?xml version="1.0" encoding="UTF-8"?>
113
+ <oor:items xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
114
+ <item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="OOXMLRecalcMode" oor:op="fuse"><value>0</value></prop></item>
115
+ <item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="ODFRecalcMode" oor:op="fuse"><value>0</value></prop></item>
116
+ </oor:items>
117
+ """
118
+
119
+
120
+ def recalc(path, tmp):
121
+ dest = Path(tmp) / f"recalc-{len(list(Path(tmp).glob('recalc-*')))}"
122
+ dest.mkdir()
123
+ profile = Path(tmp) / "lo-profile"
124
+ if not profile.exists():
125
+ (profile / "user").mkdir(parents=True)
126
+ (profile / "user" / "registrymodifications.xcu").write_text(RECALC_PROFILE)
127
+ subprocess.run(
128
+ ["soffice", f"-env:UserInstallation=file://{profile}", "--headless", "--calc", "--convert-to",
129
+ "xlsx:Calc MS Excel 2007 XML", "--outdir", str(dest), str(path)],
130
+ stdout=subprocess.DEVNULL,
131
+ stderr=subprocess.DEVNULL,
132
+ timeout=180,
133
+ check=False,
134
+ )
135
+ out = dest / (Path(path).stem + ".xlsx")
136
+ return out if out.exists() else Path(path)
137
+
138
+
139
+ def cell_value(v):
140
+ if isinstance(v, (int, float)) and not isinstance(v, bool):
141
+ return round(float(v), 2)
142
+ if isinstance(v, dt.datetime):
143
+ return round((v - dt.datetime(1899, 12, 30)).total_seconds() / 86400.0, 0)
144
+ if isinstance(v, dt.time):
145
+ return v.strftime("%H:%M")
146
+ if isinstance(v, str):
147
+ try:
148
+ return round(float(v), 2)
149
+ except ValueError:
150
+ return v.strip()
151
+ return v
152
+
153
+
154
+ def time_of(v):
155
+ """A time or a day fraction in [0, 1) as HH:MM, rounded to the nearest second first. Calc and
156
+ Excel store a time as that fraction; openpyxl returns a time only for time-formatted cells."""
157
+ if isinstance(v, dt.time):
158
+ v = (v.hour * 3600 + v.minute * 60 + v.second + v.microsecond / 1e6) / 86400
159
+ if isinstance(v, (int, float)) and not isinstance(v, bool) and 0 <= v < 1:
160
+ return (dt.datetime(1899, 12, 30) + dt.timedelta(seconds=round(v * 86400))).strftime("%H:%M")
161
+ return None
162
+
163
+
164
+ def same_cell(a, b):
165
+ if isinstance(a, dt.time) is not isinstance(b, dt.time):
166
+ n = b if isinstance(a, dt.time) else a
167
+ if time_of(n) is not None: # a time against a plain day fraction
168
+ return time_of(a) == time_of(b)
169
+ a, b = cell_value(a), cell_value(b)
170
+ if a in (None, "") and b in (None, ""):
171
+ return True
172
+ return type(a) is type(b) and a == b
173
+
174
+
175
+ ERRORS = {"#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A"}
176
+
177
+
178
+ def is_error(v):
179
+ return isinstance(v, str) and (v in ERRORS or v.startswith("Err:"))
180
+
181
+
182
+ def cells(rng):
183
+ if ":" not in rng:
184
+ return [rng]
185
+ from openpyxl.utils import range_boundaries, get_column_letter
186
+
187
+ c1, r1, c2, r2 = range_boundaries(rng)
188
+ return [f"{get_column_letter(c)}{r}" for r in range(r1, r2 + 1) for c in range(c1, c2 + 1)]
189
+
190
+
191
+ def load(path, tmp):
192
+ import openpyxl
193
+
194
+ return openpyxl.load_workbook(recalc(path, tmp), data_only=True)
195
+
196
+
197
+ def check_xlsx_range(check, tmp, cache):
198
+ sub = OUT / check["file"]
199
+ if not sub.is_file():
200
+ return False, f"missing output {check['file']}"
201
+ if sub not in cache:
202
+ cache[sub] = load(sub, tmp)
203
+ tgt = TESTS / check["target"]
204
+ if tgt not in cache:
205
+ cache[tgt] = load(tgt, tmp)
206
+ got, want = cache[sub], cache[tgt]
207
+ cached = None # the target's stored (Excel-computed) values, read only when Calc errs
208
+ for sheet, rng in check["ranges"]:
209
+ sheet = sheet or want.sheetnames[0]
210
+ if sheet not in got.sheetnames:
211
+ return False, f"sheet {sheet!r} missing"
212
+ for name in cells(rng):
213
+ w = want[sheet][name].value
214
+ if is_error(w):
215
+ # LibreOffice could not evaluate the gold formula (e.g. XLOOKUP, FILTER in Calc 7.4).
216
+ # The value Excel stored is the intended answer.
217
+ if cached is None:
218
+ import openpyxl
219
+
220
+ cached = openpyxl.load_workbook(tgt, data_only=True)
221
+ c = cached[sheet][name].value if sheet in cached.sheetnames else None
222
+ if c is not None and not is_error(c):
223
+ w = c
224
+ if not same_cell(w, got[sheet][name].value):
225
+ return False, f"{sheet}!{name}: want {w!r} got {got[sheet][name].value!r}"
226
+ return True, ""
227
+
228
+
229
+ def check_xlsx_cell(check, tmp, cache):
230
+ sub = OUT / check["file"]
231
+ if not sub.is_file():
232
+ return False, f"missing output {check['file']}"
233
+ if sub not in cache:
234
+ cache[sub] = load(sub, tmp)
235
+ wb = cache[sub]
236
+ if check["sheet"] not in wb.sheetnames:
237
+ return False, f"sheet {check['sheet']!r} missing"
238
+ got = wb[check["sheet"]][check["cell"]].value
239
+ want = check["value"]
240
+ if isinstance(want, (int, float)):
241
+ # alt_values: other accepted golds where the source admits more than one reading.
242
+ ok = got is not None and any(number_ok(got, w, check.get("rel_tol", 0.0), check.get("abs_tol", 0.01))
243
+ for w in [want, *check.get("alt_values", [])])
244
+ else:
245
+ ok = norm_text(got) == norm_text(want)
246
+ return ok, "" if ok else f"{check['sheet']}!{check['cell']}: want {want!r} got {got!r}"
247
+
248
+
249
+ def text_of(path):
250
+ suffix = path.suffix.lower()
251
+ if suffix == ".docx":
252
+ import docx
253
+
254
+ d = docx.Document(path)
255
+ parts = [p.text for p in d.paragraphs]
256
+ for t in d.tables:
257
+ parts += [c.text for row in t.rows for c in row.cells]
258
+ return "\n".join(parts)
259
+ if suffix == ".pdf":
260
+ import pdfplumber
261
+
262
+ with pdfplumber.open(path) as pdf:
263
+ return "\n".join(page.extract_text() or "" for page in pdf.pages)
264
+ return path.read_text(errors="replace")
265
+
266
+
267
+ def check_file_contains(check, tmp, cache):
268
+ sub = OUT / check["file"]
269
+ if not sub.is_file():
270
+ return False, f"missing output {check['file']}"
271
+ text = text_of(sub)
272
+ hay = text if check.get("case_sensitive") else text.casefold()
273
+ for needle in check["needles"]:
274
+ n = needle if check.get("case_sensitive") else needle.casefold()
275
+ if n not in hay:
276
+ return False, f"{check['file']} lacks {needle!r}"
277
+ return True, ""
278
+
279
+
280
+ def main():
281
+ LOGS.mkdir(parents=True, exist_ok=True)
282
+ reward_path = LOGS / "reward.txt"
283
+ reward_path.write_text("0\n")
284
+ spec = json.loads((TESTS / "expected.json").read_text())
285
+ answers, details = {}, []
286
+ answer_file = OUT / "answer.json"
287
+ if answer_file.is_file():
288
+ try:
289
+ answers = json.loads(answer_file.read_text())
290
+ if not isinstance(answers, dict):
291
+ answers = {}
292
+ except json.JSONDecodeError:
293
+ answers = {}
294
+ tmp = tempfile.mkdtemp()
295
+ cache = {}
296
+ try:
297
+ for check in spec["checks"]:
298
+ try:
299
+ if check["type"] == "answer":
300
+ ok, why = check_answer(check, answers)
301
+ elif check["type"] == "xlsx_range":
302
+ ok, why = check_xlsx_range(check, tmp, cache)
303
+ elif check["type"] == "xlsx_cell":
304
+ ok, why = check_xlsx_cell(check, tmp, cache)
305
+ elif check["type"] == "file_contains":
306
+ ok, why = check_file_contains(check, tmp, cache)
307
+ elif check["type"] == "custom":
308
+ import importlib.util
309
+
310
+ spec_ = importlib.util.spec_from_file_location("custom_check", TESTS / f"{check['module']}.py")
311
+ mod = importlib.util.module_from_spec(spec_)
312
+ spec_.loader.exec_module(mod)
313
+ ok, why = mod.check(check, OUT, TESTS)
314
+ else:
315
+ ok, why = False, f"unknown check type {check['type']}"
316
+ except Exception as exc: # a malformed submission fails the check, not the grader
317
+ ok, why = False, f"{type(exc).__name__}: {exc}"
318
+ details.append({"id": check["id"], "passed": ok, "detail": why})
319
+ finally:
320
+ shutil.rmtree(tmp, ignore_errors=True)
321
+ passed = sum(d["passed"] for d in details)
322
+ total = len(details)
323
+ reward = 1 if total and passed == total else 0
324
+ (LOGS / "details.json").write_text(json.dumps({"passed": passed, "total": total, "checks": details}, indent=1))
325
+ reward_path.write_text(f"{reward}\n")
326
+ print(f"{passed}/{total} checks passed; reward {reward}")
327
+
328
+
329
+ if __name__ == "__main__":
330
+ sys.exit(main())
tasks/autom-field-service-rebooking-010-v2/tests/replay.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Offline business-app client. Print usage with --help."""
2
+ import argparse
3
+ import copy
4
+ import fcntl
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+
9
+
10
+ def same(left, right):
11
+ return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
12
+
13
+
14
+ def apply(world, action):
15
+ if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}:
16
+ raise ValueError('expected op, app, id, fields')
17
+ op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields'))
18
+ if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields:
19
+ raise ValueError('unknown app, invalid id or empty fields')
20
+ collection = world[app]
21
+ if op == 'update' and key in collection:
22
+ collection[key].update(copy.deepcopy(fields))
23
+ elif op == 'create' and key not in collection:
24
+ collection[key] = copy.deepcopy(fields)
25
+ else:
26
+ raise ValueError(f'invalid {op} for {app}/{key}')
27
+
28
+
29
+ def load_actions(path):
30
+ if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000):
31
+ raise ValueError('invalid action log')
32
+ if not path.exists():
33
+ return []
34
+ return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
35
+
36
+
37
+ def main():
38
+ parser = argparse.ArgumentParser(description=__doc__)
39
+ parser.add_argument('op', choices=('apps','list','get','update','create'))
40
+ parser.add_argument('app', nargs='?')
41
+ parser.add_argument('id', nargs='?')
42
+ parser.add_argument('fields', nargs='?', type=json.loads)
43
+ args = parser.parse_args()
44
+ world = json.loads(Path(__file__).with_name('world.json').read_text())
45
+ out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs'))
46
+ out.mkdir(parents=True, exist_ok=True)
47
+ log = out/'actions.jsonl'
48
+ with (out/'.actions.lock').open('a') as lock:
49
+ fcntl.flock(lock.fileno(), fcntl.LOCK_EX)
50
+ for event in load_actions(log):
51
+ apply(world,event)
52
+ if args.op=='apps':
53
+ value=sorted(world)
54
+ elif args.op=='list':
55
+ value=world[args.app]
56
+ elif args.op=='get':
57
+ value=world[args.app][args.id]
58
+ else:
59
+ event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields}
60
+ apply(world,event)
61
+ with log.open('a') as handle:
62
+ handle.write(json.dumps(event,allow_nan=False)+'\n')
63
+ value=world[args.app][args.id]
64
+ print(json.dumps(value,sort_keys=True,allow_nan=False))
65
+
66
+
67
+ if __name__=='__main__':
68
+ main()
tasks/autom-field-service-rebooking-010-v2/tests/target.json ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accounts": {
3
+ "CL-0": {
4
+ "allow_remote": true,
5
+ "tier": "priority"
6
+ },
7
+ "CL-1": {
8
+ "allow_remote": false,
9
+ "tier": "standard"
10
+ },
11
+ "CL-10": {
12
+ "allow_remote": false,
13
+ "tier": "standard"
14
+ },
15
+ "CL-11": {
16
+ "allow_remote": true,
17
+ "tier": "priority"
18
+ },
19
+ "CL-12": {
20
+ "allow_remote": false,
21
+ "tier": "priority"
22
+ },
23
+ "CL-2": {
24
+ "allow_remote": false,
25
+ "tier": "standard"
26
+ },
27
+ "CL-3": {
28
+ "allow_remote": true,
29
+ "tier": "standard"
30
+ },
31
+ "CL-4": {
32
+ "allow_remote": false,
33
+ "tier": "priority"
34
+ },
35
+ "CL-5": {
36
+ "allow_remote": true,
37
+ "tier": "standard"
38
+ },
39
+ "CL-6": {
40
+ "allow_remote": true,
41
+ "tier": "priority"
42
+ },
43
+ "CL-7": {
44
+ "allow_remote": false,
45
+ "tier": "priority"
46
+ },
47
+ "CL-8": {
48
+ "allow_remote": false,
49
+ "tier": "priority"
50
+ },
51
+ "CL-9": {
52
+ "allow_remote": false,
53
+ "tier": "priority"
54
+ }
55
+ },
56
+ "calendar": {
57
+ "S00": {
58
+ "crew": "T0",
59
+ "day": "2025-09-16",
60
+ "mode": "onsite",
61
+ "start": "08:00",
62
+ "state": "reserved",
63
+ "work_order": "J-8611-0"
64
+ },
65
+ "S01": {
66
+ "crew": "T3",
67
+ "day": "2025-09-17",
68
+ "mode": "onsite",
69
+ "start": "08:00",
70
+ "state": "occupied"
71
+ },
72
+ "S02": {
73
+ "crew": "T2",
74
+ "day": "2025-09-19",
75
+ "mode": "remote",
76
+ "start": "15:00",
77
+ "state": "available"
78
+ },
79
+ "S03": {
80
+ "crew": "T3",
81
+ "day": "2025-09-16",
82
+ "mode": "onsite",
83
+ "start": "15:00",
84
+ "state": "reserved",
85
+ "work_order": "J-9806-2"
86
+ },
87
+ "S04": {
88
+ "crew": "T0",
89
+ "day": "2025-09-19",
90
+ "mode": "remote",
91
+ "start": "13:00",
92
+ "state": "available"
93
+ },
94
+ "S05": {
95
+ "crew": "T3",
96
+ "day": "2025-09-21",
97
+ "mode": "onsite",
98
+ "start": "08:00",
99
+ "state": "occupied"
100
+ },
101
+ "S06": {
102
+ "crew": "T2",
103
+ "day": "2025-09-18",
104
+ "mode": "onsite",
105
+ "start": "10:00",
106
+ "state": "reserved",
107
+ "work_order": "J-1706-1"
108
+ },
109
+ "S07": {
110
+ "crew": "T1",
111
+ "day": "2025-09-21",
112
+ "mode": "remote",
113
+ "start": "15:00",
114
+ "state": "available"
115
+ },
116
+ "S08": {
117
+ "crew": "T6",
118
+ "day": "2025-09-20",
119
+ "mode": "remote",
120
+ "start": "08:00",
121
+ "state": "occupied"
122
+ },
123
+ "S09": {
124
+ "crew": "T1",
125
+ "day": "2025-09-22",
126
+ "mode": "onsite",
127
+ "start": "10:00",
128
+ "state": "occupied"
129
+ },
130
+ "S10": {
131
+ "crew": "T5",
132
+ "day": "2025-09-17",
133
+ "mode": "onsite",
134
+ "start": "10:00",
135
+ "state": "available"
136
+ },
137
+ "S11": {
138
+ "crew": "T4",
139
+ "day": "2025-09-22",
140
+ "mode": "remote",
141
+ "start": "15:00",
142
+ "state": "available"
143
+ },
144
+ "S12": {
145
+ "crew": "T0",
146
+ "day": "2025-09-21",
147
+ "mode": "onsite",
148
+ "start": "08:00",
149
+ "state": "occupied"
150
+ },
151
+ "S13": {
152
+ "crew": "T1",
153
+ "day": "2025-09-19",
154
+ "mode": "remote",
155
+ "start": "15:00",
156
+ "state": "available"
157
+ },
158
+ "S14": {
159
+ "crew": "T2",
160
+ "day": "2025-09-18",
161
+ "mode": "remote",
162
+ "start": "08:00",
163
+ "state": "reserved",
164
+ "work_order": "J-7391-5"
165
+ },
166
+ "S15": {
167
+ "crew": "T1",
168
+ "day": "2025-09-17",
169
+ "mode": "remote",
170
+ "start": "15:00",
171
+ "state": "reserved",
172
+ "work_order": "J-2427-3"
173
+ }
174
+ },
175
+ "dispatch": {
176
+ "DISPATCH-OLD": {
177
+ "status": "closed",
178
+ "work_order": "archived"
179
+ },
180
+ "follow-J-4894-4": {
181
+ "client": "CL-4",
182
+ "status": "needs_slot",
183
+ "work_order": "J-4894-4"
184
+ }
185
+ },
186
+ "technicians": {
187
+ "T0": {
188
+ "active": true,
189
+ "home": "Central",
190
+ "skills": [
191
+ "network",
192
+ "safety",
193
+ "controls"
194
+ ]
195
+ },
196
+ "T1": {
197
+ "active": true,
198
+ "home": "Central",
199
+ "skills": [
200
+ "safety",
201
+ "network",
202
+ "controls"
203
+ ]
204
+ },
205
+ "T2": {
206
+ "active": true,
207
+ "home": "Central",
208
+ "skills": [
209
+ "network"
210
+ ]
211
+ },
212
+ "T3": {
213
+ "active": true,
214
+ "home": "Central",
215
+ "skills": [
216
+ "network",
217
+ "controls"
218
+ ]
219
+ },
220
+ "T4": {
221
+ "active": true,
222
+ "home": "Central",
223
+ "skills": [
224
+ "safety",
225
+ "network",
226
+ "controls"
227
+ ]
228
+ },
229
+ "T5": {
230
+ "active": true,
231
+ "home": "North",
232
+ "skills": [
233
+ "safety",
234
+ "network"
235
+ ]
236
+ },
237
+ "T6": {
238
+ "active": false,
239
+ "home": "North",
240
+ "skills": [
241
+ "controls",
242
+ "network",
243
+ "safety"
244
+ ]
245
+ }
246
+ },
247
+ "work_orders": {
248
+ "J-1186-6": {
249
+ "client": "CL-6",
250
+ "day": "2025-09-14",
251
+ "hub": "Central",
252
+ "service": "network",
253
+ "start": "10:00",
254
+ "state": "cancelled"
255
+ },
256
+ "J-1706-1": {
257
+ "client": "CL-1",
258
+ "day": "2025-09-15",
259
+ "hub": "Central",
260
+ "new_slot": "S06",
261
+ "service": "network",
262
+ "start": "15:00",
263
+ "state": "rebooked"
264
+ },
265
+ "J-1883-8": {
266
+ "client": "CL-8",
267
+ "day": "2025-09-14",
268
+ "hub": "Central",
269
+ "service": "controls",
270
+ "start": "13:00",
271
+ "state": "confirmed"
272
+ },
273
+ "J-2427-3": {
274
+ "client": "CL-3",
275
+ "day": "2025-09-15",
276
+ "hub": "Central",
277
+ "new_slot": "S15",
278
+ "service": "safety",
279
+ "start": "10:00",
280
+ "state": "rebooked"
281
+ },
282
+ "J-4289-11": {
283
+ "client": "CL-11",
284
+ "day": "2025-09-15",
285
+ "hub": "North",
286
+ "service": "controls",
287
+ "start": "08:00",
288
+ "state": "confirmed"
289
+ },
290
+ "J-4894-4": {
291
+ "client": "CL-4",
292
+ "day": "2025-09-15",
293
+ "hub": "Central",
294
+ "service": "safety",
295
+ "start": "10:00",
296
+ "state": "manual"
297
+ },
298
+ "J-4909-12": {
299
+ "client": "CL-12",
300
+ "day": "2025-09-13",
301
+ "hub": "Central",
302
+ "service": "safety",
303
+ "start": "15:00",
304
+ "state": "cancelled"
305
+ },
306
+ "J-7391-5": {
307
+ "client": "CL-5",
308
+ "day": "2025-09-15",
309
+ "hub": "Central",
310
+ "new_slot": "S14",
311
+ "service": "network",
312
+ "start": "15:00",
313
+ "state": "rebooked"
314
+ },
315
+ "J-8143-7": {
316
+ "client": "CL-7",
317
+ "day": "2025-09-16",
318
+ "hub": "North",
319
+ "service": "controls",
320
+ "start": "15:00",
321
+ "state": "cancelled"
322
+ },
323
+ "J-8611-0": {
324
+ "client": "CL-0",
325
+ "day": "2025-09-15",
326
+ "hub": "Central",
327
+ "new_slot": "S00",
328
+ "service": "safety",
329
+ "start": "08:00",
330
+ "state": "rebooked"
331
+ },
332
+ "J-8942-9": {
333
+ "client": "CL-9",
334
+ "day": "2025-09-13",
335
+ "hub": "Central",
336
+ "service": "safety",
337
+ "start": "10:00",
338
+ "state": "confirmed"
339
+ },
340
+ "J-9688-10": {
341
+ "client": "CL-10",
342
+ "day": "2025-09-15",
343
+ "hub": "North",
344
+ "service": "network",
345
+ "start": "08:00",
346
+ "state": "confirmed"
347
+ },
348
+ "J-9806-2": {
349
+ "client": "CL-2",
350
+ "day": "2025-09-15",
351
+ "hub": "Central",
352
+ "new_slot": "S03",
353
+ "service": "network",
354
+ "start": "08:00",
355
+ "state": "rebooked"
356
+ }
357
+ }
358
+ }
tasks/autom-field-service-rebooking-010-v2/tests/test.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -eu
3
+ mkdir -p /logs/verifier /workspace/outputs
4
+ exec python3 -B -I /tests/grade.py
tasks/autom-field-service-rebooking-010-v2/tests/world.json ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accounts": {
3
+ "CL-0": {
4
+ "allow_remote": true,
5
+ "tier": "priority"
6
+ },
7
+ "CL-1": {
8
+ "allow_remote": false,
9
+ "tier": "standard"
10
+ },
11
+ "CL-10": {
12
+ "allow_remote": false,
13
+ "tier": "standard"
14
+ },
15
+ "CL-11": {
16
+ "allow_remote": true,
17
+ "tier": "priority"
18
+ },
19
+ "CL-12": {
20
+ "allow_remote": false,
21
+ "tier": "priority"
22
+ },
23
+ "CL-2": {
24
+ "allow_remote": false,
25
+ "tier": "standard"
26
+ },
27
+ "CL-3": {
28
+ "allow_remote": true,
29
+ "tier": "standard"
30
+ },
31
+ "CL-4": {
32
+ "allow_remote": false,
33
+ "tier": "priority"
34
+ },
35
+ "CL-5": {
36
+ "allow_remote": true,
37
+ "tier": "standard"
38
+ },
39
+ "CL-6": {
40
+ "allow_remote": true,
41
+ "tier": "priority"
42
+ },
43
+ "CL-7": {
44
+ "allow_remote": false,
45
+ "tier": "priority"
46
+ },
47
+ "CL-8": {
48
+ "allow_remote": false,
49
+ "tier": "priority"
50
+ },
51
+ "CL-9": {
52
+ "allow_remote": false,
53
+ "tier": "priority"
54
+ }
55
+ },
56
+ "calendar": {
57
+ "S00": {
58
+ "crew": "T0",
59
+ "day": "2025-09-16",
60
+ "mode": "onsite",
61
+ "start": "08:00",
62
+ "state": "available"
63
+ },
64
+ "S01": {
65
+ "crew": "T3",
66
+ "day": "2025-09-17",
67
+ "mode": "onsite",
68
+ "start": "08:00",
69
+ "state": "occupied"
70
+ },
71
+ "S02": {
72
+ "crew": "T2",
73
+ "day": "2025-09-19",
74
+ "mode": "remote",
75
+ "start": "15:00",
76
+ "state": "available"
77
+ },
78
+ "S03": {
79
+ "crew": "T3",
80
+ "day": "2025-09-16",
81
+ "mode": "onsite",
82
+ "start": "15:00",
83
+ "state": "available"
84
+ },
85
+ "S04": {
86
+ "crew": "T0",
87
+ "day": "2025-09-19",
88
+ "mode": "remote",
89
+ "start": "13:00",
90
+ "state": "available"
91
+ },
92
+ "S05": {
93
+ "crew": "T3",
94
+ "day": "2025-09-21",
95
+ "mode": "onsite",
96
+ "start": "08:00",
97
+ "state": "occupied"
98
+ },
99
+ "S06": {
100
+ "crew": "T2",
101
+ "day": "2025-09-18",
102
+ "mode": "onsite",
103
+ "start": "10:00",
104
+ "state": "available"
105
+ },
106
+ "S07": {
107
+ "crew": "T1",
108
+ "day": "2025-09-21",
109
+ "mode": "remote",
110
+ "start": "15:00",
111
+ "state": "available"
112
+ },
113
+ "S08": {
114
+ "crew": "T6",
115
+ "day": "2025-09-20",
116
+ "mode": "remote",
117
+ "start": "08:00",
118
+ "state": "occupied"
119
+ },
120
+ "S09": {
121
+ "crew": "T1",
122
+ "day": "2025-09-22",
123
+ "mode": "onsite",
124
+ "start": "10:00",
125
+ "state": "occupied"
126
+ },
127
+ "S10": {
128
+ "crew": "T5",
129
+ "day": "2025-09-17",
130
+ "mode": "onsite",
131
+ "start": "10:00",
132
+ "state": "available"
133
+ },
134
+ "S11": {
135
+ "crew": "T4",
136
+ "day": "2025-09-22",
137
+ "mode": "remote",
138
+ "start": "15:00",
139
+ "state": "available"
140
+ },
141
+ "S12": {
142
+ "crew": "T0",
143
+ "day": "2025-09-21",
144
+ "mode": "onsite",
145
+ "start": "08:00",
146
+ "state": "occupied"
147
+ },
148
+ "S13": {
149
+ "crew": "T1",
150
+ "day": "2025-09-19",
151
+ "mode": "remote",
152
+ "start": "15:00",
153
+ "state": "available"
154
+ },
155
+ "S14": {
156
+ "crew": "T2",
157
+ "day": "2025-09-18",
158
+ "mode": "remote",
159
+ "start": "08:00",
160
+ "state": "available"
161
+ },
162
+ "S15": {
163
+ "crew": "T1",
164
+ "day": "2025-09-17",
165
+ "mode": "remote",
166
+ "start": "15:00",
167
+ "state": "available"
168
+ }
169
+ },
170
+ "dispatch": {
171
+ "DISPATCH-OLD": {
172
+ "status": "closed",
173
+ "work_order": "archived"
174
+ }
175
+ },
176
+ "technicians": {
177
+ "T0": {
178
+ "active": true,
179
+ "home": "Central",
180
+ "skills": [
181
+ "network",
182
+ "safety",
183
+ "controls"
184
+ ]
185
+ },
186
+ "T1": {
187
+ "active": true,
188
+ "home": "Central",
189
+ "skills": [
190
+ "safety",
191
+ "network",
192
+ "controls"
193
+ ]
194
+ },
195
+ "T2": {
196
+ "active": true,
197
+ "home": "Central",
198
+ "skills": [
199
+ "network"
200
+ ]
201
+ },
202
+ "T3": {
203
+ "active": true,
204
+ "home": "Central",
205
+ "skills": [
206
+ "network",
207
+ "controls"
208
+ ]
209
+ },
210
+ "T4": {
211
+ "active": true,
212
+ "home": "Central",
213
+ "skills": [
214
+ "safety",
215
+ "network",
216
+ "controls"
217
+ ]
218
+ },
219
+ "T5": {
220
+ "active": true,
221
+ "home": "North",
222
+ "skills": [
223
+ "safety",
224
+ "network"
225
+ ]
226
+ },
227
+ "T6": {
228
+ "active": false,
229
+ "home": "North",
230
+ "skills": [
231
+ "controls",
232
+ "network",
233
+ "safety"
234
+ ]
235
+ }
236
+ },
237
+ "work_orders": {
238
+ "J-1186-6": {
239
+ "client": "CL-6",
240
+ "day": "2025-09-14",
241
+ "hub": "Central",
242
+ "service": "network",
243
+ "start": "10:00",
244
+ "state": "cancelled"
245
+ },
246
+ "J-1706-1": {
247
+ "client": "CL-1",
248
+ "day": "2025-09-15",
249
+ "hub": "Central",
250
+ "service": "network",
251
+ "start": "15:00",
252
+ "state": "confirmed"
253
+ },
254
+ "J-1883-8": {
255
+ "client": "CL-8",
256
+ "day": "2025-09-14",
257
+ "hub": "Central",
258
+ "service": "controls",
259
+ "start": "13:00",
260
+ "state": "confirmed"
261
+ },
262
+ "J-2427-3": {
263
+ "client": "CL-3",
264
+ "day": "2025-09-15",
265
+ "hub": "Central",
266
+ "service": "safety",
267
+ "start": "10:00",
268
+ "state": "confirmed"
269
+ },
270
+ "J-4289-11": {
271
+ "client": "CL-11",
272
+ "day": "2025-09-15",
273
+ "hub": "North",
274
+ "service": "controls",
275
+ "start": "08:00",
276
+ "state": "confirmed"
277
+ },
278
+ "J-4894-4": {
279
+ "client": "CL-4",
280
+ "day": "2025-09-15",
281
+ "hub": "Central",
282
+ "service": "safety",
283
+ "start": "10:00",
284
+ "state": "confirmed"
285
+ },
286
+ "J-4909-12": {
287
+ "client": "CL-12",
288
+ "day": "2025-09-13",
289
+ "hub": "Central",
290
+ "service": "safety",
291
+ "start": "15:00",
292
+ "state": "cancelled"
293
+ },
294
+ "J-7391-5": {
295
+ "client": "CL-5",
296
+ "day": "2025-09-15",
297
+ "hub": "Central",
298
+ "service": "network",
299
+ "start": "15:00",
300
+ "state": "confirmed"
301
+ },
302
+ "J-8143-7": {
303
+ "client": "CL-7",
304
+ "day": "2025-09-16",
305
+ "hub": "North",
306
+ "service": "controls",
307
+ "start": "15:00",
308
+ "state": "cancelled"
309
+ },
310
+ "J-8611-0": {
311
+ "client": "CL-0",
312
+ "day": "2025-09-15",
313
+ "hub": "Central",
314
+ "service": "safety",
315
+ "start": "08:00",
316
+ "state": "confirmed"
317
+ },
318
+ "J-8942-9": {
319
+ "client": "CL-9",
320
+ "day": "2025-09-13",
321
+ "hub": "Central",
322
+ "service": "safety",
323
+ "start": "10:00",
324
+ "state": "confirmed"
325
+ },
326
+ "J-9688-10": {
327
+ "client": "CL-10",
328
+ "day": "2025-09-15",
329
+ "hub": "North",
330
+ "service": "network",
331
+ "start": "08:00",
332
+ "state": "confirmed"
333
+ },
334
+ "J-9806-2": {
335
+ "client": "CL-2",
336
+ "day": "2025-09-15",
337
+ "hub": "Central",
338
+ "service": "network",
339
+ "start": "08:00",
340
+ "state": "confirmed"
341
+ }
342
+ }
343
+ }
tasks/autom-field-service-rebooking-010-v2/tests/world_check.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Replay submitted mutations from the private verifier's initial state."""
2
+ from types import ModuleType
3
+ import json
4
+
5
+
6
+ def check(spec, outputs, tests):
7
+ replay = ModuleType('workflow_replay')
8
+ exec(compile((tests/'replay.py').read_bytes(), 'replay.py', 'exec'), replay.__dict__)
9
+ world = json.loads((tests/'world.json').read_text())
10
+ target = json.loads((tests/'target.json').read_text())
11
+ # Only fields whose starting and expected values differ may be changed. Attempts
12
+ # to temporarily alter a protected field fail even when a later write restores it.
13
+ allowed = {
14
+ (app,key): {field for field,value in doc.items()
15
+ if field not in world[app].get(key,{}) or not replay.same(world[app][key][field],value)}
16
+ for app,records in target.items() for key,doc in records.items()
17
+ }
18
+ actions = replay.load_actions(outputs/'actions.jsonl')
19
+ for event in actions:
20
+ replay.apply(world,event)
21
+ touched = set(event['fields'])
22
+ if not touched <= allowed.get((event['app'],event['id']),set()):
23
+ return False,'protected field or record write'
24
+ if not replay.same(world,target):
25
+ return False,'required business outcomes incomplete'
26
+ return True,''
tasks/autom-field-service-rebooking-010-v2/validation/openenv.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "profile": "harbor-semantic-v1",
3
+ "reward_key": "reward",
4
+ "reward": {
5
+ "range": [
6
+ 0,
7
+ 1
8
+ ],
9
+ "oracle_tolerance": 0,
10
+ "floor_margin": 0.1
11
+ },
12
+ "resources": {
13
+ "cpu": 1,
14
+ "memory_mb": 4096,
15
+ "disk_mb": 10240,
16
+ "episode_timeout_s": 1800
17
+ },
18
+ "types": {
19
+ "tags": [
20
+ "knowledge-work",
21
+ "cross-app-workflows",
22
+ "conditional-execution",
23
+ "protected-state",
24
+ "operations"
25
+ ]
26
+ },
27
+ "requires_credentials": false
28
+ }
tasks/autom-field-service-rebooking-011-v2/environment/inputs/apps.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Offline business-app client. Print usage with --help."""
2
+ import argparse
3
+ import copy
4
+ import fcntl
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+
9
+
10
+ def same(left, right):
11
+ return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
12
+
13
+
14
+ def apply(world, action):
15
+ if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}:
16
+ raise ValueError('expected op, app, id, fields')
17
+ op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields'))
18
+ if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields:
19
+ raise ValueError('unknown app, invalid id or empty fields')
20
+ collection = world[app]
21
+ if op == 'update' and key in collection:
22
+ collection[key].update(copy.deepcopy(fields))
23
+ elif op == 'create' and key not in collection:
24
+ collection[key] = copy.deepcopy(fields)
25
+ else:
26
+ raise ValueError(f'invalid {op} for {app}/{key}')
27
+
28
+
29
+ def load_actions(path):
30
+ if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000):
31
+ raise ValueError('invalid action log')
32
+ if not path.exists():
33
+ return []
34
+ return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
35
+
36
+
37
+ def main():
38
+ parser = argparse.ArgumentParser(description=__doc__)
39
+ parser.add_argument('op', choices=('apps','list','get','update','create'))
40
+ parser.add_argument('app', nargs='?')
41
+ parser.add_argument('id', nargs='?')
42
+ parser.add_argument('fields', nargs='?', type=json.loads)
43
+ args = parser.parse_args()
44
+ world = json.loads(Path(__file__).with_name('world.json').read_text())
45
+ out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs'))
46
+ out.mkdir(parents=True, exist_ok=True)
47
+ log = out/'actions.jsonl'
48
+ with (out/'.actions.lock').open('a') as lock:
49
+ fcntl.flock(lock.fileno(), fcntl.LOCK_EX)
50
+ for event in load_actions(log):
51
+ apply(world,event)
52
+ if args.op=='apps':
53
+ value=sorted(world)
54
+ elif args.op=='list':
55
+ value=world[args.app]
56
+ elif args.op=='get':
57
+ value=world[args.app][args.id]
58
+ else:
59
+ event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields}
60
+ apply(world,event)
61
+ with log.open('a') as handle:
62
+ handle.write(json.dumps(event,allow_nan=False)+'\n')
63
+ value=world[args.app][args.id]
64
+ print(json.dumps(value,sort_keys=True,allow_nan=False))
65
+
66
+
67
+ if __name__=='__main__':
68
+ main()
tasks/autom-field-service-rebooking-011-v2/environment/inputs/world.json ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accounts": {
3
+ "CL-0": {
4
+ "allow_remote": true,
5
+ "tier": "priority"
6
+ },
7
+ "CL-1": {
8
+ "allow_remote": false,
9
+ "tier": "priority"
10
+ },
11
+ "CL-2": {
12
+ "allow_remote": false,
13
+ "tier": "standard"
14
+ },
15
+ "CL-3": {
16
+ "allow_remote": true,
17
+ "tier": "standard"
18
+ },
19
+ "CL-4": {
20
+ "allow_remote": false,
21
+ "tier": "priority"
22
+ },
23
+ "CL-5": {
24
+ "allow_remote": false,
25
+ "tier": "standard"
26
+ },
27
+ "CL-6": {
28
+ "allow_remote": false,
29
+ "tier": "standard"
30
+ },
31
+ "CL-7": {
32
+ "allow_remote": false,
33
+ "tier": "priority"
34
+ },
35
+ "CL-8": {
36
+ "allow_remote": true,
37
+ "tier": "priority"
38
+ },
39
+ "CL-9": {
40
+ "allow_remote": false,
41
+ "tier": "priority"
42
+ }
43
+ },
44
+ "calendar": {
45
+ "S00": {
46
+ "crew": "T0",
47
+ "day": "2025-10-09",
48
+ "mode": "onsite",
49
+ "start": "08:00",
50
+ "state": "available"
51
+ },
52
+ "S01": {
53
+ "crew": "T0",
54
+ "day": "2025-10-14",
55
+ "mode": "remote",
56
+ "start": "15:00",
57
+ "state": "occupied"
58
+ },
59
+ "S02": {
60
+ "crew": "T2",
61
+ "day": "2025-10-11",
62
+ "mode": "remote",
63
+ "start": "13:00",
64
+ "state": "available"
65
+ },
66
+ "S03": {
67
+ "crew": "T5",
68
+ "day": "2025-10-12",
69
+ "mode": "onsite",
70
+ "start": "15:00",
71
+ "state": "available"
72
+ },
73
+ "S04": {
74
+ "crew": "T3",
75
+ "day": "2025-10-10",
76
+ "mode": "remote",
77
+ "start": "15:00",
78
+ "state": "available"
79
+ },
80
+ "S05": {
81
+ "crew": "T1",
82
+ "day": "2025-10-14",
83
+ "mode": "onsite",
84
+ "start": "10:00",
85
+ "state": "available"
86
+ },
87
+ "S06": {
88
+ "crew": "T3",
89
+ "day": "2025-10-11",
90
+ "mode": "remote",
91
+ "start": "13:00",
92
+ "state": "occupied"
93
+ },
94
+ "S07": {
95
+ "crew": "T1",
96
+ "day": "2025-10-11",
97
+ "mode": "onsite",
98
+ "start": "15:00",
99
+ "state": "available"
100
+ },
101
+ "S08": {
102
+ "crew": "T1",
103
+ "day": "2025-10-14",
104
+ "mode": "remote",
105
+ "start": "08:00",
106
+ "state": "available"
107
+ },
108
+ "S09": {
109
+ "crew": "T4",
110
+ "day": "2025-10-14",
111
+ "mode": "onsite",
112
+ "start": "08:00",
113
+ "state": "available"
114
+ },
115
+ "S10": {
116
+ "crew": "T4",
117
+ "day": "2025-10-12",
118
+ "mode": "remote",
119
+ "start": "10:00",
120
+ "state": "occupied"
121
+ },
122
+ "S11": {
123
+ "crew": "T2",
124
+ "day": "2025-10-11",
125
+ "mode": "remote",
126
+ "start": "08:00",
127
+ "state": "available"
128
+ },
129
+ "S12": {
130
+ "crew": "T5",
131
+ "day": "2025-10-11",
132
+ "mode": "onsite",
133
+ "start": "08:00",
134
+ "state": "available"
135
+ },
136
+ "S13": {
137
+ "crew": "T4",
138
+ "day": "2025-10-11",
139
+ "mode": "onsite",
140
+ "start": "10:00",
141
+ "state": "occupied"
142
+ },
143
+ "S14": {
144
+ "crew": "T0",
145
+ "day": "2025-10-09",
146
+ "mode": "remote",
147
+ "start": "13:00",
148
+ "state": "available"
149
+ },
150
+ "S15": {
151
+ "crew": "T2",
152
+ "day": "2025-10-09",
153
+ "mode": "onsite",
154
+ "start": "13:00",
155
+ "state": "available"
156
+ },
157
+ "S16": {
158
+ "crew": "T3",
159
+ "day": "2025-10-10",
160
+ "mode": "remote",
161
+ "start": "10:00",
162
+ "state": "available"
163
+ },
164
+ "S17": {
165
+ "crew": "T0",
166
+ "day": "2025-10-12",
167
+ "mode": "remote",
168
+ "start": "10:00",
169
+ "state": "available"
170
+ },
171
+ "S18": {
172
+ "crew": "T5",
173
+ "day": "2025-10-13",
174
+ "mode": "onsite",
175
+ "start": "10:00",
176
+ "state": "available"
177
+ },
178
+ "S19": {
179
+ "crew": "T5",
180
+ "day": "2025-10-14",
181
+ "mode": "remote",
182
+ "start": "10:00",
183
+ "state": "available"
184
+ },
185
+ "S20": {
186
+ "crew": "T3",
187
+ "day": "2025-10-11",
188
+ "mode": "onsite",
189
+ "start": "15:00",
190
+ "state": "available"
191
+ }
192
+ },
193
+ "dispatch": {
194
+ "DISPATCH-OLD": {
195
+ "status": "closed",
196
+ "work_order": "archived"
197
+ }
198
+ },
199
+ "technicians": {
200
+ "T0": {
201
+ "active": true,
202
+ "home": "South",
203
+ "skills": [
204
+ "network",
205
+ "safety",
206
+ "controls"
207
+ ]
208
+ },
209
+ "T1": {
210
+ "active": true,
211
+ "home": "South",
212
+ "skills": [
213
+ "safety",
214
+ "network"
215
+ ]
216
+ },
217
+ "T2": {
218
+ "active": true,
219
+ "home": "South",
220
+ "skills": [
221
+ "safety",
222
+ "controls"
223
+ ]
224
+ },
225
+ "T3": {
226
+ "active": true,
227
+ "home": "South",
228
+ "skills": [
229
+ "network"
230
+ ]
231
+ },
232
+ "T4": {
233
+ "active": true,
234
+ "home": "South",
235
+ "skills": [
236
+ "network",
237
+ "controls",
238
+ "safety"
239
+ ]
240
+ },
241
+ "T5": {
242
+ "active": true,
243
+ "home": "Central",
244
+ "skills": [
245
+ "network",
246
+ "controls"
247
+ ]
248
+ },
249
+ "T6": {
250
+ "active": false,
251
+ "home": "Central",
252
+ "skills": [
253
+ "safety",
254
+ "network"
255
+ ]
256
+ }
257
+ },
258
+ "work_orders": {
259
+ "J-2564-0": {
260
+ "client": "CL-0",
261
+ "day": "2025-10-08",
262
+ "hub": "South",
263
+ "service": "controls",
264
+ "start": "13:00",
265
+ "state": "confirmed"
266
+ },
267
+ "J-3625-4": {
268
+ "client": "CL-4",
269
+ "day": "2025-10-08",
270
+ "hub": "South",
271
+ "service": "controls",
272
+ "start": "10:00",
273
+ "state": "confirmed"
274
+ },
275
+ "J-4083-3": {
276
+ "client": "CL-3",
277
+ "day": "2025-10-08",
278
+ "hub": "South",
279
+ "service": "safety",
280
+ "start": "13:00",
281
+ "state": "confirmed"
282
+ },
283
+ "J-5742-6": {
284
+ "client": "CL-6",
285
+ "day": "2025-10-10",
286
+ "hub": "South",
287
+ "service": "safety",
288
+ "start": "08:00",
289
+ "state": "confirmed"
290
+ },
291
+ "J-5760-5": {
292
+ "client": "CL-5",
293
+ "day": "2025-10-08",
294
+ "hub": "South",
295
+ "service": "network",
296
+ "start": "15:00",
297
+ "state": "confirmed"
298
+ },
299
+ "J-5872-1": {
300
+ "client": "CL-1",
301
+ "day": "2025-10-08",
302
+ "hub": "South",
303
+ "service": "controls",
304
+ "start": "08:00",
305
+ "state": "confirmed"
306
+ },
307
+ "J-6802-7": {
308
+ "client": "CL-7",
309
+ "day": "2025-10-08",
310
+ "hub": "Central",
311
+ "service": "network",
312
+ "start": "13:00",
313
+ "state": "confirmed"
314
+ },
315
+ "J-9105-9": {
316
+ "client": "CL-9",
317
+ "day": "2025-10-06",
318
+ "hub": "South",
319
+ "service": "controls",
320
+ "start": "08:00",
321
+ "state": "cancelled"
322
+ },
323
+ "J-9264-2": {
324
+ "client": "CL-2",
325
+ "day": "2025-10-08",
326
+ "hub": "South",
327
+ "service": "controls",
328
+ "start": "13:00",
329
+ "state": "confirmed"
330
+ },
331
+ "J-9575-8": {
332
+ "client": "CL-8",
333
+ "day": "2025-10-07",
334
+ "hub": "Central",
335
+ "service": "network",
336
+ "start": "15:00",
337
+ "state": "cancelled"
338
+ }
339
+ }
340
+ }
tasks/autom-field-service-rebooking-011-v2/instruction.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ A 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.
2
+
3
+ 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.
4
+
5
+ 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.
6
+
7
+ 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.
8
+
9
+ Use the offline app client at `/workspace/inputs/apps.py`. Call it with python3. Run
10
+ `apps` to discover apps, `list APP` to see its records, or `get APP ID` for one record.
11
+ Write with `update APP ID '{"field":"value"}'` or `create APP ID '{"field":"value"}'`.
12
+ The client records successful writes in `/workspace/outputs/actions.jsonl`.
13
+ Apply exactly the required changes. Other records and fields must remain untouched,
14
+ including temporary changes. Actions take effect in the local simulation only.
15
+
16
+ ## Deliverable
17
+
18
+ Work in `/workspace`. Input files are under `/workspace/inputs/`. Put every deliverable in
19
+ `/workspace/outputs/`; only that directory is graded. Leave the app action log in the outputs directory.
tasks/autom-field-service-rebooking-011-v2/solution/files/actions.jsonl ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-5872-1"}, "id": "S00", "op": "update"}
2
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-5760-5"}, "id": "S07", "op": "update"}
3
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-4083-3"}, "id": "S11", "op": "update"}
4
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-2564-0"}, "id": "S14", "op": "update"}
5
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-3625-4"}, "id": "S15", "op": "update"}
6
+ {"app": "dispatch", "fields": {"client": "CL-2", "status": "needs_slot", "work_order": "J-9264-2"}, "id": "follow-J-9264-2", "op": "create"}
7
+ {"app": "work_orders", "fields": {"new_slot": "S14", "state": "rebooked"}, "id": "J-2564-0", "op": "update"}
8
+ {"app": "work_orders", "fields": {"new_slot": "S15", "state": "rebooked"}, "id": "J-3625-4", "op": "update"}
9
+ {"app": "work_orders", "fields": {"new_slot": "S11", "state": "rebooked"}, "id": "J-4083-3", "op": "update"}
10
+ {"app": "work_orders", "fields": {"new_slot": "S07", "state": "rebooked"}, "id": "J-5760-5", "op": "update"}
11
+ {"app": "work_orders", "fields": {"new_slot": "S00", "state": "rebooked"}, "id": "J-5872-1", "op": "update"}
12
+ {"app": "work_orders", "fields": {"state": "manual"}, "id": "J-9264-2", "op": "update"}
tasks/autom-field-service-rebooking-011-v2/solution/solve.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -eu
3
+ mkdir -p /workspace/outputs
4
+ cp -R /solution/files/. /workspace/outputs/
tasks/autom-field-service-rebooking-011-v2/task.toml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ schema_version = "1.3"
2
+
3
+ [task]
4
+ name = "apex-gap/autom-field-service-rebooking-011-v2"
5
+
6
+ [metadata.apex_gap]
7
+ capability_tags = ["cross-app-workflows", "conditional-execution", "protected-state", "operations"]
8
+ dataset = "Original simulated workflows"
9
+ job = "operations"
10
+ seed = 11
11
+ source = "local/original-automation-workflows"
12
+ source_revision = "2"
13
+ source_split = "synthetic"
14
+ source_task_id = "autom-field-service-rebooking-011"
15
+ template_family = "automation:field-service-rebooking"
16
+ workflow_template = "field-service-rebooking"
17
+
18
+ [metadata.openenv_hf_sandbox]
19
+ variant = "apex-gap-hfsandbox-v1"
20
+ task_modified_for_hf_sandbox = true
21
+ network_enabled = true
22
+
23
+ [environment]
24
+ docker_image = "ghcr.io/younesbelkada/apex@sha256:24969c952247033023872f87161a16e067003469506be63783bbaa5d96926bdf"
25
+ workdir = "/workspace"
26
+ cpus = 1
27
+ memory_mb = 4096
28
+ build_timeout_sec = 600
29
+ network_mode = "public"
30
+
31
+ [agent]
32
+ timeout_sec = 1800
33
+ network_mode = "public"
34
+
35
+ [verifier]
36
+ timeout_sec = 600
37
+ network_mode = "public"
38
+ environment_mode = "separate"
39
+
40
+ [verifier.environment]
41
+ network_mode = "public"
42
+ cpus = 1
43
+ memory_mb = 4096
44
+
45
+ [[artifacts]]
46
+ source = "/workspace/outputs"
tasks/autom-field-service-rebooking-011-v2/tests/expected.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "checks": [
3
+ {
4
+ "id": "business-outcomes",
5
+ "type": "custom",
6
+ "module": "world_check"
7
+ }
8
+ ]
9
+ }
tasks/autom-field-service-rebooking-011-v2/tests/grade.py ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Deterministic grader shared by converted knowledge-work tasks.
2
+
3
+ Runs inside the separate verifier sandbox. Reads /tests/expected.json, inspects the
4
+ submitted /workspace/outputs tree and writes a binary reward plus per-check details.
5
+ No model calls and no network.
6
+
7
+ expected.json: {"checks": [{"id": ..., "type": ..., ...}, ...]}
8
+ Check types:
9
+ answer field of outputs/answer.json; kind = number|text|choice|date|bool|list
10
+ xlsx_range recalculated outputs/<file> vs tests/<target> over sheet!range (SpreadsheetBench rules)
11
+ xlsx_cell recalculated outputs/<file> sheet!cell vs value with tolerance (optional alt_values)
12
+ file_contains outputs/<file> text (docx/pdf/ics/eml/txt) must contain every needle
13
+ custom tests/<module>.py defines check(spec, outputs_dir, tests_dir) -> (bool, str)
14
+ """
15
+
16
+ import datetime as dt
17
+ import json
18
+ import re
19
+ import shutil
20
+ import subprocess
21
+ import sys
22
+ import tempfile
23
+ import unicodedata
24
+ from pathlib import Path
25
+
26
+ OUT = Path("/workspace/outputs")
27
+ TESTS = Path("/tests")
28
+ LOGS = Path("/logs/verifier")
29
+
30
+
31
+ def norm_text(v):
32
+ v = unicodedata.normalize("NFKC", str(v)).casefold()
33
+ v = re.sub(r"[‘’“”]", "'", v)
34
+ v = re.sub(r"[^\w%.$/-]+", " ", v)
35
+ return " ".join(v.split()).strip(" .")
36
+
37
+
38
+ def to_number(v):
39
+ if isinstance(v, bool):
40
+ raise ValueError("bool")
41
+ if isinstance(v, (int, float)):
42
+ return float(v)
43
+ s = str(v).strip().replace(",", "").replace("$", "").replace("−", "-")
44
+ neg = s.startswith("(") and s.endswith(")")
45
+ s = s.strip("()").strip()
46
+ pct = s.endswith("%")
47
+ s = s.rstrip("%").strip()
48
+ s = re.sub(r"\s*(usd|dollars|million|billion|thousand|m|bn|k)$", "", s, flags=re.I)
49
+ x = float(s)
50
+ x = -x if neg else x
51
+ return x / 100 if pct else x
52
+
53
+
54
+ def number_ok(got, want, rel, abs_):
55
+ try:
56
+ g = to_number(got)
57
+ except (TypeError, ValueError):
58
+ return False
59
+ w = float(want)
60
+ tol = max(abs_, rel * abs(w))
61
+ # "12.5%" may mean the ratio 0.125 or the percent number 12.5; the gold fixes which.
62
+ candidates = [g, g * 100] if isinstance(got, str) and got.strip().endswith("%") else [g]
63
+ return any(abs(c - w) <= tol for c in candidates)
64
+
65
+
66
+ def parse_date(v):
67
+ if isinstance(v, (dt.date, dt.datetime)):
68
+ return v if isinstance(v, dt.date) else v.date()
69
+ s = str(v).strip()
70
+ for fmt in ("%Y-%m-%d", "%m/%d/%Y", "%m/%d/%y", "%d %B %Y", "%B %d, %Y", "%b %d, %Y", "%Y/%m/%d"):
71
+ try:
72
+ return dt.datetime.strptime(s, fmt).date()
73
+ except ValueError:
74
+ continue
75
+ raise ValueError(s)
76
+
77
+
78
+ def check_answer(check, answers):
79
+ key = check["field"]
80
+ if key not in answers:
81
+ return False, f"missing field {key!r}"
82
+ got, want, kind = answers[key], check["value"], check.get("kind", "text")
83
+ if kind == "number":
84
+ ok = number_ok(got, want, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01))
85
+ if not ok and check.get("percent_either"):
86
+ ok = number_ok(got, want * 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) * 100) or (
87
+ number_ok(got, want / 100, check.get("rel_tol", 0.005), check.get("abs_tol", 0.01) / 100)
88
+ )
89
+ elif kind == "date":
90
+ try:
91
+ ok = parse_date(got) == parse_date(want)
92
+ except ValueError:
93
+ ok = False
94
+ elif kind == "bool":
95
+ g = norm_text(got)
96
+ ok = g in {"yes", "true"} if want else g in {"no", "false"}
97
+ elif kind == "choice":
98
+ ok = norm_text(got) == norm_text(want)
99
+ elif kind == "list":
100
+ if not isinstance(got, list):
101
+ return False, f"{key}: expected a JSON list"
102
+ # Filenames may be given with a directory prefix; compare base names.
103
+ base = lambda x: norm_text(str(x).replace("\\", "/").rsplit("/", 1)[-1])
104
+ ok = sorted(base(x) for x in got) == sorted(base(x) for x in want)
105
+ else:
106
+ accepted = check.get("accept", [want])
107
+ ok = norm_text(got) in {norm_text(a) for a in accepted}
108
+ return ok, "" if ok else f"{key}: got {got!r}"
109
+
110
+
111
+ # LibreOffice keeps cached formula values on load unless told otherwise; force a full recalculation.
112
+ RECALC_PROFILE = """<?xml version="1.0" encoding="UTF-8"?>
113
+ <oor:items xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
114
+ <item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="OOXMLRecalcMode" oor:op="fuse"><value>0</value></prop></item>
115
+ <item oor:path="/org.openoffice.Office.Calc/Formula/Load"><prop oor:name="ODFRecalcMode" oor:op="fuse"><value>0</value></prop></item>
116
+ </oor:items>
117
+ """
118
+
119
+
120
+ def recalc(path, tmp):
121
+ dest = Path(tmp) / f"recalc-{len(list(Path(tmp).glob('recalc-*')))}"
122
+ dest.mkdir()
123
+ profile = Path(tmp) / "lo-profile"
124
+ if not profile.exists():
125
+ (profile / "user").mkdir(parents=True)
126
+ (profile / "user" / "registrymodifications.xcu").write_text(RECALC_PROFILE)
127
+ subprocess.run(
128
+ ["soffice", f"-env:UserInstallation=file://{profile}", "--headless", "--calc", "--convert-to",
129
+ "xlsx:Calc MS Excel 2007 XML", "--outdir", str(dest), str(path)],
130
+ stdout=subprocess.DEVNULL,
131
+ stderr=subprocess.DEVNULL,
132
+ timeout=180,
133
+ check=False,
134
+ )
135
+ out = dest / (Path(path).stem + ".xlsx")
136
+ return out if out.exists() else Path(path)
137
+
138
+
139
+ def cell_value(v):
140
+ if isinstance(v, (int, float)) and not isinstance(v, bool):
141
+ return round(float(v), 2)
142
+ if isinstance(v, dt.datetime):
143
+ return round((v - dt.datetime(1899, 12, 30)).total_seconds() / 86400.0, 0)
144
+ if isinstance(v, dt.time):
145
+ return v.strftime("%H:%M")
146
+ if isinstance(v, str):
147
+ try:
148
+ return round(float(v), 2)
149
+ except ValueError:
150
+ return v.strip()
151
+ return v
152
+
153
+
154
+ def time_of(v):
155
+ """A time or a day fraction in [0, 1) as HH:MM, rounded to the nearest second first. Calc and
156
+ Excel store a time as that fraction; openpyxl returns a time only for time-formatted cells."""
157
+ if isinstance(v, dt.time):
158
+ v = (v.hour * 3600 + v.minute * 60 + v.second + v.microsecond / 1e6) / 86400
159
+ if isinstance(v, (int, float)) and not isinstance(v, bool) and 0 <= v < 1:
160
+ return (dt.datetime(1899, 12, 30) + dt.timedelta(seconds=round(v * 86400))).strftime("%H:%M")
161
+ return None
162
+
163
+
164
+ def same_cell(a, b):
165
+ if isinstance(a, dt.time) is not isinstance(b, dt.time):
166
+ n = b if isinstance(a, dt.time) else a
167
+ if time_of(n) is not None: # a time against a plain day fraction
168
+ return time_of(a) == time_of(b)
169
+ a, b = cell_value(a), cell_value(b)
170
+ if a in (None, "") and b in (None, ""):
171
+ return True
172
+ return type(a) is type(b) and a == b
173
+
174
+
175
+ ERRORS = {"#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A"}
176
+
177
+
178
+ def is_error(v):
179
+ return isinstance(v, str) and (v in ERRORS or v.startswith("Err:"))
180
+
181
+
182
+ def cells(rng):
183
+ if ":" not in rng:
184
+ return [rng]
185
+ from openpyxl.utils import range_boundaries, get_column_letter
186
+
187
+ c1, r1, c2, r2 = range_boundaries(rng)
188
+ return [f"{get_column_letter(c)}{r}" for r in range(r1, r2 + 1) for c in range(c1, c2 + 1)]
189
+
190
+
191
+ def load(path, tmp):
192
+ import openpyxl
193
+
194
+ return openpyxl.load_workbook(recalc(path, tmp), data_only=True)
195
+
196
+
197
+ def check_xlsx_range(check, tmp, cache):
198
+ sub = OUT / check["file"]
199
+ if not sub.is_file():
200
+ return False, f"missing output {check['file']}"
201
+ if sub not in cache:
202
+ cache[sub] = load(sub, tmp)
203
+ tgt = TESTS / check["target"]
204
+ if tgt not in cache:
205
+ cache[tgt] = load(tgt, tmp)
206
+ got, want = cache[sub], cache[tgt]
207
+ cached = None # the target's stored (Excel-computed) values, read only when Calc errs
208
+ for sheet, rng in check["ranges"]:
209
+ sheet = sheet or want.sheetnames[0]
210
+ if sheet not in got.sheetnames:
211
+ return False, f"sheet {sheet!r} missing"
212
+ for name in cells(rng):
213
+ w = want[sheet][name].value
214
+ if is_error(w):
215
+ # LibreOffice could not evaluate the gold formula (e.g. XLOOKUP, FILTER in Calc 7.4).
216
+ # The value Excel stored is the intended answer.
217
+ if cached is None:
218
+ import openpyxl
219
+
220
+ cached = openpyxl.load_workbook(tgt, data_only=True)
221
+ c = cached[sheet][name].value if sheet in cached.sheetnames else None
222
+ if c is not None and not is_error(c):
223
+ w = c
224
+ if not same_cell(w, got[sheet][name].value):
225
+ return False, f"{sheet}!{name}: want {w!r} got {got[sheet][name].value!r}"
226
+ return True, ""
227
+
228
+
229
+ def check_xlsx_cell(check, tmp, cache):
230
+ sub = OUT / check["file"]
231
+ if not sub.is_file():
232
+ return False, f"missing output {check['file']}"
233
+ if sub not in cache:
234
+ cache[sub] = load(sub, tmp)
235
+ wb = cache[sub]
236
+ if check["sheet"] not in wb.sheetnames:
237
+ return False, f"sheet {check['sheet']!r} missing"
238
+ got = wb[check["sheet"]][check["cell"]].value
239
+ want = check["value"]
240
+ if isinstance(want, (int, float)):
241
+ # alt_values: other accepted golds where the source admits more than one reading.
242
+ ok = got is not None and any(number_ok(got, w, check.get("rel_tol", 0.0), check.get("abs_tol", 0.01))
243
+ for w in [want, *check.get("alt_values", [])])
244
+ else:
245
+ ok = norm_text(got) == norm_text(want)
246
+ return ok, "" if ok else f"{check['sheet']}!{check['cell']}: want {want!r} got {got!r}"
247
+
248
+
249
+ def text_of(path):
250
+ suffix = path.suffix.lower()
251
+ if suffix == ".docx":
252
+ import docx
253
+
254
+ d = docx.Document(path)
255
+ parts = [p.text for p in d.paragraphs]
256
+ for t in d.tables:
257
+ parts += [c.text for row in t.rows for c in row.cells]
258
+ return "\n".join(parts)
259
+ if suffix == ".pdf":
260
+ import pdfplumber
261
+
262
+ with pdfplumber.open(path) as pdf:
263
+ return "\n".join(page.extract_text() or "" for page in pdf.pages)
264
+ return path.read_text(errors="replace")
265
+
266
+
267
+ def check_file_contains(check, tmp, cache):
268
+ sub = OUT / check["file"]
269
+ if not sub.is_file():
270
+ return False, f"missing output {check['file']}"
271
+ text = text_of(sub)
272
+ hay = text if check.get("case_sensitive") else text.casefold()
273
+ for needle in check["needles"]:
274
+ n = needle if check.get("case_sensitive") else needle.casefold()
275
+ if n not in hay:
276
+ return False, f"{check['file']} lacks {needle!r}"
277
+ return True, ""
278
+
279
+
280
+ def main():
281
+ LOGS.mkdir(parents=True, exist_ok=True)
282
+ reward_path = LOGS / "reward.txt"
283
+ reward_path.write_text("0\n")
284
+ spec = json.loads((TESTS / "expected.json").read_text())
285
+ answers, details = {}, []
286
+ answer_file = OUT / "answer.json"
287
+ if answer_file.is_file():
288
+ try:
289
+ answers = json.loads(answer_file.read_text())
290
+ if not isinstance(answers, dict):
291
+ answers = {}
292
+ except json.JSONDecodeError:
293
+ answers = {}
294
+ tmp = tempfile.mkdtemp()
295
+ cache = {}
296
+ try:
297
+ for check in spec["checks"]:
298
+ try:
299
+ if check["type"] == "answer":
300
+ ok, why = check_answer(check, answers)
301
+ elif check["type"] == "xlsx_range":
302
+ ok, why = check_xlsx_range(check, tmp, cache)
303
+ elif check["type"] == "xlsx_cell":
304
+ ok, why = check_xlsx_cell(check, tmp, cache)
305
+ elif check["type"] == "file_contains":
306
+ ok, why = check_file_contains(check, tmp, cache)
307
+ elif check["type"] == "custom":
308
+ import importlib.util
309
+
310
+ spec_ = importlib.util.spec_from_file_location("custom_check", TESTS / f"{check['module']}.py")
311
+ mod = importlib.util.module_from_spec(spec_)
312
+ spec_.loader.exec_module(mod)
313
+ ok, why = mod.check(check, OUT, TESTS)
314
+ else:
315
+ ok, why = False, f"unknown check type {check['type']}"
316
+ except Exception as exc: # a malformed submission fails the check, not the grader
317
+ ok, why = False, f"{type(exc).__name__}: {exc}"
318
+ details.append({"id": check["id"], "passed": ok, "detail": why})
319
+ finally:
320
+ shutil.rmtree(tmp, ignore_errors=True)
321
+ passed = sum(d["passed"] for d in details)
322
+ total = len(details)
323
+ reward = 1 if total and passed == total else 0
324
+ (LOGS / "details.json").write_text(json.dumps({"passed": passed, "total": total, "checks": details}, indent=1))
325
+ reward_path.write_text(f"{reward}\n")
326
+ print(f"{passed}/{total} checks passed; reward {reward}")
327
+
328
+
329
+ if __name__ == "__main__":
330
+ sys.exit(main())
tasks/autom-field-service-rebooking-011-v2/tests/replay.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Offline business-app client. Print usage with --help."""
2
+ import argparse
3
+ import copy
4
+ import fcntl
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+
9
+
10
+ def same(left, right):
11
+ return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
12
+
13
+
14
+ def apply(world, action):
15
+ if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}:
16
+ raise ValueError('expected op, app, id, fields')
17
+ op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields'))
18
+ if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields:
19
+ raise ValueError('unknown app, invalid id or empty fields')
20
+ collection = world[app]
21
+ if op == 'update' and key in collection:
22
+ collection[key].update(copy.deepcopy(fields))
23
+ elif op == 'create' and key not in collection:
24
+ collection[key] = copy.deepcopy(fields)
25
+ else:
26
+ raise ValueError(f'invalid {op} for {app}/{key}')
27
+
28
+
29
+ def load_actions(path):
30
+ if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000):
31
+ raise ValueError('invalid action log')
32
+ if not path.exists():
33
+ return []
34
+ return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
35
+
36
+
37
+ def main():
38
+ parser = argparse.ArgumentParser(description=__doc__)
39
+ parser.add_argument('op', choices=('apps','list','get','update','create'))
40
+ parser.add_argument('app', nargs='?')
41
+ parser.add_argument('id', nargs='?')
42
+ parser.add_argument('fields', nargs='?', type=json.loads)
43
+ args = parser.parse_args()
44
+ world = json.loads(Path(__file__).with_name('world.json').read_text())
45
+ out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs'))
46
+ out.mkdir(parents=True, exist_ok=True)
47
+ log = out/'actions.jsonl'
48
+ with (out/'.actions.lock').open('a') as lock:
49
+ fcntl.flock(lock.fileno(), fcntl.LOCK_EX)
50
+ for event in load_actions(log):
51
+ apply(world,event)
52
+ if args.op=='apps':
53
+ value=sorted(world)
54
+ elif args.op=='list':
55
+ value=world[args.app]
56
+ elif args.op=='get':
57
+ value=world[args.app][args.id]
58
+ else:
59
+ event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields}
60
+ apply(world,event)
61
+ with log.open('a') as handle:
62
+ handle.write(json.dumps(event,allow_nan=False)+'\n')
63
+ value=world[args.app][args.id]
64
+ print(json.dumps(value,sort_keys=True,allow_nan=False))
65
+
66
+
67
+ if __name__=='__main__':
68
+ main()
tasks/autom-field-service-rebooking-011-v2/tests/target.json ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accounts": {
3
+ "CL-0": {
4
+ "allow_remote": true,
5
+ "tier": "priority"
6
+ },
7
+ "CL-1": {
8
+ "allow_remote": false,
9
+ "tier": "priority"
10
+ },
11
+ "CL-2": {
12
+ "allow_remote": false,
13
+ "tier": "standard"
14
+ },
15
+ "CL-3": {
16
+ "allow_remote": true,
17
+ "tier": "standard"
18
+ },
19
+ "CL-4": {
20
+ "allow_remote": false,
21
+ "tier": "priority"
22
+ },
23
+ "CL-5": {
24
+ "allow_remote": false,
25
+ "tier": "standard"
26
+ },
27
+ "CL-6": {
28
+ "allow_remote": false,
29
+ "tier": "standard"
30
+ },
31
+ "CL-7": {
32
+ "allow_remote": false,
33
+ "tier": "priority"
34
+ },
35
+ "CL-8": {
36
+ "allow_remote": true,
37
+ "tier": "priority"
38
+ },
39
+ "CL-9": {
40
+ "allow_remote": false,
41
+ "tier": "priority"
42
+ }
43
+ },
44
+ "calendar": {
45
+ "S00": {
46
+ "crew": "T0",
47
+ "day": "2025-10-09",
48
+ "mode": "onsite",
49
+ "start": "08:00",
50
+ "state": "reserved",
51
+ "work_order": "J-5872-1"
52
+ },
53
+ "S01": {
54
+ "crew": "T0",
55
+ "day": "2025-10-14",
56
+ "mode": "remote",
57
+ "start": "15:00",
58
+ "state": "occupied"
59
+ },
60
+ "S02": {
61
+ "crew": "T2",
62
+ "day": "2025-10-11",
63
+ "mode": "remote",
64
+ "start": "13:00",
65
+ "state": "available"
66
+ },
67
+ "S03": {
68
+ "crew": "T5",
69
+ "day": "2025-10-12",
70
+ "mode": "onsite",
71
+ "start": "15:00",
72
+ "state": "available"
73
+ },
74
+ "S04": {
75
+ "crew": "T3",
76
+ "day": "2025-10-10",
77
+ "mode": "remote",
78
+ "start": "15:00",
79
+ "state": "available"
80
+ },
81
+ "S05": {
82
+ "crew": "T1",
83
+ "day": "2025-10-14",
84
+ "mode": "onsite",
85
+ "start": "10:00",
86
+ "state": "available"
87
+ },
88
+ "S06": {
89
+ "crew": "T3",
90
+ "day": "2025-10-11",
91
+ "mode": "remote",
92
+ "start": "13:00",
93
+ "state": "occupied"
94
+ },
95
+ "S07": {
96
+ "crew": "T1",
97
+ "day": "2025-10-11",
98
+ "mode": "onsite",
99
+ "start": "15:00",
100
+ "state": "reserved",
101
+ "work_order": "J-5760-5"
102
+ },
103
+ "S08": {
104
+ "crew": "T1",
105
+ "day": "2025-10-14",
106
+ "mode": "remote",
107
+ "start": "08:00",
108
+ "state": "available"
109
+ },
110
+ "S09": {
111
+ "crew": "T4",
112
+ "day": "2025-10-14",
113
+ "mode": "onsite",
114
+ "start": "08:00",
115
+ "state": "available"
116
+ },
117
+ "S10": {
118
+ "crew": "T4",
119
+ "day": "2025-10-12",
120
+ "mode": "remote",
121
+ "start": "10:00",
122
+ "state": "occupied"
123
+ },
124
+ "S11": {
125
+ "crew": "T2",
126
+ "day": "2025-10-11",
127
+ "mode": "remote",
128
+ "start": "08:00",
129
+ "state": "reserved",
130
+ "work_order": "J-4083-3"
131
+ },
132
+ "S12": {
133
+ "crew": "T5",
134
+ "day": "2025-10-11",
135
+ "mode": "onsite",
136
+ "start": "08:00",
137
+ "state": "available"
138
+ },
139
+ "S13": {
140
+ "crew": "T4",
141
+ "day": "2025-10-11",
142
+ "mode": "onsite",
143
+ "start": "10:00",
144
+ "state": "occupied"
145
+ },
146
+ "S14": {
147
+ "crew": "T0",
148
+ "day": "2025-10-09",
149
+ "mode": "remote",
150
+ "start": "13:00",
151
+ "state": "reserved",
152
+ "work_order": "J-2564-0"
153
+ },
154
+ "S15": {
155
+ "crew": "T2",
156
+ "day": "2025-10-09",
157
+ "mode": "onsite",
158
+ "start": "13:00",
159
+ "state": "reserved",
160
+ "work_order": "J-3625-4"
161
+ },
162
+ "S16": {
163
+ "crew": "T3",
164
+ "day": "2025-10-10",
165
+ "mode": "remote",
166
+ "start": "10:00",
167
+ "state": "available"
168
+ },
169
+ "S17": {
170
+ "crew": "T0",
171
+ "day": "2025-10-12",
172
+ "mode": "remote",
173
+ "start": "10:00",
174
+ "state": "available"
175
+ },
176
+ "S18": {
177
+ "crew": "T5",
178
+ "day": "2025-10-13",
179
+ "mode": "onsite",
180
+ "start": "10:00",
181
+ "state": "available"
182
+ },
183
+ "S19": {
184
+ "crew": "T5",
185
+ "day": "2025-10-14",
186
+ "mode": "remote",
187
+ "start": "10:00",
188
+ "state": "available"
189
+ },
190
+ "S20": {
191
+ "crew": "T3",
192
+ "day": "2025-10-11",
193
+ "mode": "onsite",
194
+ "start": "15:00",
195
+ "state": "available"
196
+ }
197
+ },
198
+ "dispatch": {
199
+ "DISPATCH-OLD": {
200
+ "status": "closed",
201
+ "work_order": "archived"
202
+ },
203
+ "follow-J-9264-2": {
204
+ "client": "CL-2",
205
+ "status": "needs_slot",
206
+ "work_order": "J-9264-2"
207
+ }
208
+ },
209
+ "technicians": {
210
+ "T0": {
211
+ "active": true,
212
+ "home": "South",
213
+ "skills": [
214
+ "network",
215
+ "safety",
216
+ "controls"
217
+ ]
218
+ },
219
+ "T1": {
220
+ "active": true,
221
+ "home": "South",
222
+ "skills": [
223
+ "safety",
224
+ "network"
225
+ ]
226
+ },
227
+ "T2": {
228
+ "active": true,
229
+ "home": "South",
230
+ "skills": [
231
+ "safety",
232
+ "controls"
233
+ ]
234
+ },
235
+ "T3": {
236
+ "active": true,
237
+ "home": "South",
238
+ "skills": [
239
+ "network"
240
+ ]
241
+ },
242
+ "T4": {
243
+ "active": true,
244
+ "home": "South",
245
+ "skills": [
246
+ "network",
247
+ "controls",
248
+ "safety"
249
+ ]
250
+ },
251
+ "T5": {
252
+ "active": true,
253
+ "home": "Central",
254
+ "skills": [
255
+ "network",
256
+ "controls"
257
+ ]
258
+ },
259
+ "T6": {
260
+ "active": false,
261
+ "home": "Central",
262
+ "skills": [
263
+ "safety",
264
+ "network"
265
+ ]
266
+ }
267
+ },
268
+ "work_orders": {
269
+ "J-2564-0": {
270
+ "client": "CL-0",
271
+ "day": "2025-10-08",
272
+ "hub": "South",
273
+ "new_slot": "S14",
274
+ "service": "controls",
275
+ "start": "13:00",
276
+ "state": "rebooked"
277
+ },
278
+ "J-3625-4": {
279
+ "client": "CL-4",
280
+ "day": "2025-10-08",
281
+ "hub": "South",
282
+ "new_slot": "S15",
283
+ "service": "controls",
284
+ "start": "10:00",
285
+ "state": "rebooked"
286
+ },
287
+ "J-4083-3": {
288
+ "client": "CL-3",
289
+ "day": "2025-10-08",
290
+ "hub": "South",
291
+ "new_slot": "S11",
292
+ "service": "safety",
293
+ "start": "13:00",
294
+ "state": "rebooked"
295
+ },
296
+ "J-5742-6": {
297
+ "client": "CL-6",
298
+ "day": "2025-10-10",
299
+ "hub": "South",
300
+ "service": "safety",
301
+ "start": "08:00",
302
+ "state": "confirmed"
303
+ },
304
+ "J-5760-5": {
305
+ "client": "CL-5",
306
+ "day": "2025-10-08",
307
+ "hub": "South",
308
+ "new_slot": "S07",
309
+ "service": "network",
310
+ "start": "15:00",
311
+ "state": "rebooked"
312
+ },
313
+ "J-5872-1": {
314
+ "client": "CL-1",
315
+ "day": "2025-10-08",
316
+ "hub": "South",
317
+ "new_slot": "S00",
318
+ "service": "controls",
319
+ "start": "08:00",
320
+ "state": "rebooked"
321
+ },
322
+ "J-6802-7": {
323
+ "client": "CL-7",
324
+ "day": "2025-10-08",
325
+ "hub": "Central",
326
+ "service": "network",
327
+ "start": "13:00",
328
+ "state": "confirmed"
329
+ },
330
+ "J-9105-9": {
331
+ "client": "CL-9",
332
+ "day": "2025-10-06",
333
+ "hub": "South",
334
+ "service": "controls",
335
+ "start": "08:00",
336
+ "state": "cancelled"
337
+ },
338
+ "J-9264-2": {
339
+ "client": "CL-2",
340
+ "day": "2025-10-08",
341
+ "hub": "South",
342
+ "service": "controls",
343
+ "start": "13:00",
344
+ "state": "manual"
345
+ },
346
+ "J-9575-8": {
347
+ "client": "CL-8",
348
+ "day": "2025-10-07",
349
+ "hub": "Central",
350
+ "service": "network",
351
+ "start": "15:00",
352
+ "state": "cancelled"
353
+ }
354
+ }
355
+ }
tasks/autom-field-service-rebooking-011-v2/tests/test.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -eu
3
+ mkdir -p /logs/verifier /workspace/outputs
4
+ exec python3 -B -I /tests/grade.py
tasks/autom-field-service-rebooking-011-v2/tests/world.json ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accounts": {
3
+ "CL-0": {
4
+ "allow_remote": true,
5
+ "tier": "priority"
6
+ },
7
+ "CL-1": {
8
+ "allow_remote": false,
9
+ "tier": "priority"
10
+ },
11
+ "CL-2": {
12
+ "allow_remote": false,
13
+ "tier": "standard"
14
+ },
15
+ "CL-3": {
16
+ "allow_remote": true,
17
+ "tier": "standard"
18
+ },
19
+ "CL-4": {
20
+ "allow_remote": false,
21
+ "tier": "priority"
22
+ },
23
+ "CL-5": {
24
+ "allow_remote": false,
25
+ "tier": "standard"
26
+ },
27
+ "CL-6": {
28
+ "allow_remote": false,
29
+ "tier": "standard"
30
+ },
31
+ "CL-7": {
32
+ "allow_remote": false,
33
+ "tier": "priority"
34
+ },
35
+ "CL-8": {
36
+ "allow_remote": true,
37
+ "tier": "priority"
38
+ },
39
+ "CL-9": {
40
+ "allow_remote": false,
41
+ "tier": "priority"
42
+ }
43
+ },
44
+ "calendar": {
45
+ "S00": {
46
+ "crew": "T0",
47
+ "day": "2025-10-09",
48
+ "mode": "onsite",
49
+ "start": "08:00",
50
+ "state": "available"
51
+ },
52
+ "S01": {
53
+ "crew": "T0",
54
+ "day": "2025-10-14",
55
+ "mode": "remote",
56
+ "start": "15:00",
57
+ "state": "occupied"
58
+ },
59
+ "S02": {
60
+ "crew": "T2",
61
+ "day": "2025-10-11",
62
+ "mode": "remote",
63
+ "start": "13:00",
64
+ "state": "available"
65
+ },
66
+ "S03": {
67
+ "crew": "T5",
68
+ "day": "2025-10-12",
69
+ "mode": "onsite",
70
+ "start": "15:00",
71
+ "state": "available"
72
+ },
73
+ "S04": {
74
+ "crew": "T3",
75
+ "day": "2025-10-10",
76
+ "mode": "remote",
77
+ "start": "15:00",
78
+ "state": "available"
79
+ },
80
+ "S05": {
81
+ "crew": "T1",
82
+ "day": "2025-10-14",
83
+ "mode": "onsite",
84
+ "start": "10:00",
85
+ "state": "available"
86
+ },
87
+ "S06": {
88
+ "crew": "T3",
89
+ "day": "2025-10-11",
90
+ "mode": "remote",
91
+ "start": "13:00",
92
+ "state": "occupied"
93
+ },
94
+ "S07": {
95
+ "crew": "T1",
96
+ "day": "2025-10-11",
97
+ "mode": "onsite",
98
+ "start": "15:00",
99
+ "state": "available"
100
+ },
101
+ "S08": {
102
+ "crew": "T1",
103
+ "day": "2025-10-14",
104
+ "mode": "remote",
105
+ "start": "08:00",
106
+ "state": "available"
107
+ },
108
+ "S09": {
109
+ "crew": "T4",
110
+ "day": "2025-10-14",
111
+ "mode": "onsite",
112
+ "start": "08:00",
113
+ "state": "available"
114
+ },
115
+ "S10": {
116
+ "crew": "T4",
117
+ "day": "2025-10-12",
118
+ "mode": "remote",
119
+ "start": "10:00",
120
+ "state": "occupied"
121
+ },
122
+ "S11": {
123
+ "crew": "T2",
124
+ "day": "2025-10-11",
125
+ "mode": "remote",
126
+ "start": "08:00",
127
+ "state": "available"
128
+ },
129
+ "S12": {
130
+ "crew": "T5",
131
+ "day": "2025-10-11",
132
+ "mode": "onsite",
133
+ "start": "08:00",
134
+ "state": "available"
135
+ },
136
+ "S13": {
137
+ "crew": "T4",
138
+ "day": "2025-10-11",
139
+ "mode": "onsite",
140
+ "start": "10:00",
141
+ "state": "occupied"
142
+ },
143
+ "S14": {
144
+ "crew": "T0",
145
+ "day": "2025-10-09",
146
+ "mode": "remote",
147
+ "start": "13:00",
148
+ "state": "available"
149
+ },
150
+ "S15": {
151
+ "crew": "T2",
152
+ "day": "2025-10-09",
153
+ "mode": "onsite",
154
+ "start": "13:00",
155
+ "state": "available"
156
+ },
157
+ "S16": {
158
+ "crew": "T3",
159
+ "day": "2025-10-10",
160
+ "mode": "remote",
161
+ "start": "10:00",
162
+ "state": "available"
163
+ },
164
+ "S17": {
165
+ "crew": "T0",
166
+ "day": "2025-10-12",
167
+ "mode": "remote",
168
+ "start": "10:00",
169
+ "state": "available"
170
+ },
171
+ "S18": {
172
+ "crew": "T5",
173
+ "day": "2025-10-13",
174
+ "mode": "onsite",
175
+ "start": "10:00",
176
+ "state": "available"
177
+ },
178
+ "S19": {
179
+ "crew": "T5",
180
+ "day": "2025-10-14",
181
+ "mode": "remote",
182
+ "start": "10:00",
183
+ "state": "available"
184
+ },
185
+ "S20": {
186
+ "crew": "T3",
187
+ "day": "2025-10-11",
188
+ "mode": "onsite",
189
+ "start": "15:00",
190
+ "state": "available"
191
+ }
192
+ },
193
+ "dispatch": {
194
+ "DISPATCH-OLD": {
195
+ "status": "closed",
196
+ "work_order": "archived"
197
+ }
198
+ },
199
+ "technicians": {
200
+ "T0": {
201
+ "active": true,
202
+ "home": "South",
203
+ "skills": [
204
+ "network",
205
+ "safety",
206
+ "controls"
207
+ ]
208
+ },
209
+ "T1": {
210
+ "active": true,
211
+ "home": "South",
212
+ "skills": [
213
+ "safety",
214
+ "network"
215
+ ]
216
+ },
217
+ "T2": {
218
+ "active": true,
219
+ "home": "South",
220
+ "skills": [
221
+ "safety",
222
+ "controls"
223
+ ]
224
+ },
225
+ "T3": {
226
+ "active": true,
227
+ "home": "South",
228
+ "skills": [
229
+ "network"
230
+ ]
231
+ },
232
+ "T4": {
233
+ "active": true,
234
+ "home": "South",
235
+ "skills": [
236
+ "network",
237
+ "controls",
238
+ "safety"
239
+ ]
240
+ },
241
+ "T5": {
242
+ "active": true,
243
+ "home": "Central",
244
+ "skills": [
245
+ "network",
246
+ "controls"
247
+ ]
248
+ },
249
+ "T6": {
250
+ "active": false,
251
+ "home": "Central",
252
+ "skills": [
253
+ "safety",
254
+ "network"
255
+ ]
256
+ }
257
+ },
258
+ "work_orders": {
259
+ "J-2564-0": {
260
+ "client": "CL-0",
261
+ "day": "2025-10-08",
262
+ "hub": "South",
263
+ "service": "controls",
264
+ "start": "13:00",
265
+ "state": "confirmed"
266
+ },
267
+ "J-3625-4": {
268
+ "client": "CL-4",
269
+ "day": "2025-10-08",
270
+ "hub": "South",
271
+ "service": "controls",
272
+ "start": "10:00",
273
+ "state": "confirmed"
274
+ },
275
+ "J-4083-3": {
276
+ "client": "CL-3",
277
+ "day": "2025-10-08",
278
+ "hub": "South",
279
+ "service": "safety",
280
+ "start": "13:00",
281
+ "state": "confirmed"
282
+ },
283
+ "J-5742-6": {
284
+ "client": "CL-6",
285
+ "day": "2025-10-10",
286
+ "hub": "South",
287
+ "service": "safety",
288
+ "start": "08:00",
289
+ "state": "confirmed"
290
+ },
291
+ "J-5760-5": {
292
+ "client": "CL-5",
293
+ "day": "2025-10-08",
294
+ "hub": "South",
295
+ "service": "network",
296
+ "start": "15:00",
297
+ "state": "confirmed"
298
+ },
299
+ "J-5872-1": {
300
+ "client": "CL-1",
301
+ "day": "2025-10-08",
302
+ "hub": "South",
303
+ "service": "controls",
304
+ "start": "08:00",
305
+ "state": "confirmed"
306
+ },
307
+ "J-6802-7": {
308
+ "client": "CL-7",
309
+ "day": "2025-10-08",
310
+ "hub": "Central",
311
+ "service": "network",
312
+ "start": "13:00",
313
+ "state": "confirmed"
314
+ },
315
+ "J-9105-9": {
316
+ "client": "CL-9",
317
+ "day": "2025-10-06",
318
+ "hub": "South",
319
+ "service": "controls",
320
+ "start": "08:00",
321
+ "state": "cancelled"
322
+ },
323
+ "J-9264-2": {
324
+ "client": "CL-2",
325
+ "day": "2025-10-08",
326
+ "hub": "South",
327
+ "service": "controls",
328
+ "start": "13:00",
329
+ "state": "confirmed"
330
+ },
331
+ "J-9575-8": {
332
+ "client": "CL-8",
333
+ "day": "2025-10-07",
334
+ "hub": "Central",
335
+ "service": "network",
336
+ "start": "15:00",
337
+ "state": "cancelled"
338
+ }
339
+ }
340
+ }
tasks/autom-field-service-rebooking-011-v2/tests/world_check.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Replay submitted mutations from the private verifier's initial state."""
2
+ from types import ModuleType
3
+ import json
4
+
5
+
6
+ def check(spec, outputs, tests):
7
+ replay = ModuleType('workflow_replay')
8
+ exec(compile((tests/'replay.py').read_bytes(), 'replay.py', 'exec'), replay.__dict__)
9
+ world = json.loads((tests/'world.json').read_text())
10
+ target = json.loads((tests/'target.json').read_text())
11
+ # Only fields whose starting and expected values differ may be changed. Attempts
12
+ # to temporarily alter a protected field fail even when a later write restores it.
13
+ allowed = {
14
+ (app,key): {field for field,value in doc.items()
15
+ if field not in world[app].get(key,{}) or not replay.same(world[app][key][field],value)}
16
+ for app,records in target.items() for key,doc in records.items()
17
+ }
18
+ actions = replay.load_actions(outputs/'actions.jsonl')
19
+ for event in actions:
20
+ replay.apply(world,event)
21
+ touched = set(event['fields'])
22
+ if not touched <= allowed.get((event['app'],event['id']),set()):
23
+ return False,'protected field or record write'
24
+ if not replay.same(world,target):
25
+ return False,'required business outcomes incomplete'
26
+ return True,''
tasks/autom-field-service-rebooking-011-v2/validation/openenv.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "profile": "harbor-semantic-v1",
3
+ "reward_key": "reward",
4
+ "reward": {
5
+ "range": [
6
+ 0,
7
+ 1
8
+ ],
9
+ "oracle_tolerance": 0,
10
+ "floor_margin": 0.1
11
+ },
12
+ "resources": {
13
+ "cpu": 1,
14
+ "memory_mb": 4096,
15
+ "disk_mb": 10240,
16
+ "episode_timeout_s": 1800
17
+ },
18
+ "types": {
19
+ "tags": [
20
+ "knowledge-work",
21
+ "cross-app-workflows",
22
+ "conditional-execution",
23
+ "protected-state",
24
+ "operations"
25
+ ]
26
+ },
27
+ "requires_credentials": false
28
+ }
tasks/autom-field-service-rebooking-012-v2/environment/inputs/apps.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Offline business-app client. Print usage with --help."""
2
+ import argparse
3
+ import copy
4
+ import fcntl
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+
9
+
10
+ def same(left, right):
11
+ return json.dumps(left, sort_keys=True, allow_nan=False) == json.dumps(right, sort_keys=True, allow_nan=False)
12
+
13
+
14
+ def apply(world, action):
15
+ if not isinstance(action, dict) or action.keys() != {'op', 'app', 'id', 'fields'}:
16
+ raise ValueError('expected op, app, id, fields')
17
+ op, app, key, fields = (action[k] for k in ('op', 'app', 'id', 'fields'))
18
+ if app not in world or not isinstance(key, str) or not key or not isinstance(fields, dict) or not fields:
19
+ raise ValueError('unknown app, invalid id or empty fields')
20
+ collection = world[app]
21
+ if op == 'update' and key in collection:
22
+ collection[key].update(copy.deepcopy(fields))
23
+ elif op == 'create' and key not in collection:
24
+ collection[key] = copy.deepcopy(fields)
25
+ else:
26
+ raise ValueError(f'invalid {op} for {app}/{key}')
27
+
28
+
29
+ def load_actions(path):
30
+ if path.is_symlink() or (path.is_file() and path.stat().st_size > 2_000_000):
31
+ raise ValueError('invalid action log')
32
+ if not path.exists():
33
+ return []
34
+ return [json.loads(s) for s in path.read_text().splitlines() if s.strip()]
35
+
36
+
37
+ def main():
38
+ parser = argparse.ArgumentParser(description=__doc__)
39
+ parser.add_argument('op', choices=('apps','list','get','update','create'))
40
+ parser.add_argument('app', nargs='?')
41
+ parser.add_argument('id', nargs='?')
42
+ parser.add_argument('fields', nargs='?', type=json.loads)
43
+ args = parser.parse_args()
44
+ world = json.loads(Path(__file__).with_name('world.json').read_text())
45
+ out = Path(os.environ.get('WORKFLOW_OUTPUT_DIR', '/workspace/outputs'))
46
+ out.mkdir(parents=True, exist_ok=True)
47
+ log = out/'actions.jsonl'
48
+ with (out/'.actions.lock').open('a') as lock:
49
+ fcntl.flock(lock.fileno(), fcntl.LOCK_EX)
50
+ for event in load_actions(log):
51
+ apply(world,event)
52
+ if args.op=='apps':
53
+ value=sorted(world)
54
+ elif args.op=='list':
55
+ value=world[args.app]
56
+ elif args.op=='get':
57
+ value=world[args.app][args.id]
58
+ else:
59
+ event={'op':args.op, 'app':args.app, 'id':args.id, 'fields':args.fields}
60
+ apply(world,event)
61
+ with log.open('a') as handle:
62
+ handle.write(json.dumps(event,allow_nan=False)+'\n')
63
+ value=world[args.app][args.id]
64
+ print(json.dumps(value,sort_keys=True,allow_nan=False))
65
+
66
+
67
+ if __name__=='__main__':
68
+ main()
tasks/autom-field-service-rebooking-012-v2/environment/inputs/world.json ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accounts": {
3
+ "CL-0": {
4
+ "allow_remote": false,
5
+ "tier": "standard"
6
+ },
7
+ "CL-1": {
8
+ "allow_remote": false,
9
+ "tier": "priority"
10
+ },
11
+ "CL-2": {
12
+ "allow_remote": false,
13
+ "tier": "standard"
14
+ },
15
+ "CL-3": {
16
+ "allow_remote": false,
17
+ "tier": "priority"
18
+ },
19
+ "CL-4": {
20
+ "allow_remote": false,
21
+ "tier": "standard"
22
+ },
23
+ "CL-5": {
24
+ "allow_remote": false,
25
+ "tier": "priority"
26
+ },
27
+ "CL-6": {
28
+ "allow_remote": true,
29
+ "tier": "priority"
30
+ },
31
+ "CL-7": {
32
+ "allow_remote": false,
33
+ "tier": "standard"
34
+ },
35
+ "CL-8": {
36
+ "allow_remote": false,
37
+ "tier": "priority"
38
+ }
39
+ },
40
+ "calendar": {
41
+ "S00": {
42
+ "crew": "T0",
43
+ "day": "2025-11-01",
44
+ "mode": "onsite",
45
+ "start": "15:00",
46
+ "state": "available"
47
+ },
48
+ "S01": {
49
+ "crew": "T2",
50
+ "day": "2025-11-04",
51
+ "mode": "remote",
52
+ "start": "10:00",
53
+ "state": "available"
54
+ },
55
+ "S02": {
56
+ "crew": "T1",
57
+ "day": "2025-11-03",
58
+ "mode": "remote",
59
+ "start": "10:00",
60
+ "state": "available"
61
+ },
62
+ "S03": {
63
+ "crew": "T2",
64
+ "day": "2025-11-06",
65
+ "mode": "onsite",
66
+ "start": "13:00",
67
+ "state": "available"
68
+ },
69
+ "S04": {
70
+ "crew": "T6",
71
+ "day": "2025-11-05",
72
+ "mode": "onsite",
73
+ "start": "13:00",
74
+ "state": "available"
75
+ },
76
+ "S05": {
77
+ "crew": "T4",
78
+ "day": "2025-11-02",
79
+ "mode": "onsite",
80
+ "start": "08:00",
81
+ "state": "available"
82
+ },
83
+ "S07": {
84
+ "crew": "T5",
85
+ "day": "2025-11-03",
86
+ "mode": "remote",
87
+ "start": "10:00",
88
+ "state": "available"
89
+ },
90
+ "S08": {
91
+ "crew": "T1",
92
+ "day": "2025-11-02",
93
+ "mode": "remote",
94
+ "start": "13:00",
95
+ "state": "available"
96
+ },
97
+ "S09": {
98
+ "crew": "T2",
99
+ "day": "2025-11-05",
100
+ "mode": "remote",
101
+ "start": "10:00",
102
+ "state": "occupied"
103
+ },
104
+ "S10": {
105
+ "crew": "T3",
106
+ "day": "2025-11-02",
107
+ "mode": "onsite",
108
+ "start": "08:00",
109
+ "state": "occupied"
110
+ },
111
+ "S11": {
112
+ "crew": "T5",
113
+ "day": "2025-11-01",
114
+ "mode": "remote",
115
+ "start": "10:00",
116
+ "state": "available"
117
+ },
118
+ "S12": {
119
+ "crew": "T3",
120
+ "day": "2025-11-04",
121
+ "mode": "remote",
122
+ "start": "15:00",
123
+ "state": "available"
124
+ },
125
+ "S13": {
126
+ "crew": "T6",
127
+ "day": "2025-11-05",
128
+ "mode": "remote",
129
+ "start": "08:00",
130
+ "state": "available"
131
+ },
132
+ "S15": {
133
+ "crew": "T3",
134
+ "day": "2025-11-06",
135
+ "mode": "onsite",
136
+ "start": "15:00",
137
+ "state": "available"
138
+ },
139
+ "S16": {
140
+ "crew": "T1",
141
+ "day": "2025-11-04",
142
+ "mode": "onsite",
143
+ "start": "10:00",
144
+ "state": "available"
145
+ },
146
+ "S17": {
147
+ "crew": "T4",
148
+ "day": "2025-11-02",
149
+ "mode": "onsite",
150
+ "start": "15:00",
151
+ "state": "available"
152
+ },
153
+ "S18": {
154
+ "crew": "T5",
155
+ "day": "2025-11-06",
156
+ "mode": "onsite",
157
+ "start": "08:00",
158
+ "state": "available"
159
+ }
160
+ },
161
+ "dispatch": {
162
+ "DISPATCH-OLD": {
163
+ "status": "closed",
164
+ "work_order": "archived"
165
+ }
166
+ },
167
+ "technicians": {
168
+ "T0": {
169
+ "active": true,
170
+ "home": "East",
171
+ "skills": [
172
+ "network",
173
+ "safety",
174
+ "controls"
175
+ ]
176
+ },
177
+ "T1": {
178
+ "active": true,
179
+ "home": "East",
180
+ "skills": [
181
+ "safety"
182
+ ]
183
+ },
184
+ "T2": {
185
+ "active": true,
186
+ "home": "East",
187
+ "skills": [
188
+ "controls",
189
+ "network",
190
+ "safety"
191
+ ]
192
+ },
193
+ "T3": {
194
+ "active": true,
195
+ "home": "East",
196
+ "skills": [
197
+ "safety",
198
+ "controls"
199
+ ]
200
+ },
201
+ "T4": {
202
+ "active": true,
203
+ "home": "East",
204
+ "skills": [
205
+ "controls",
206
+ "network",
207
+ "safety"
208
+ ]
209
+ },
210
+ "T5": {
211
+ "active": true,
212
+ "home": "Central",
213
+ "skills": [
214
+ "network",
215
+ "controls"
216
+ ]
217
+ },
218
+ "T6": {
219
+ "active": false,
220
+ "home": "Central",
221
+ "skills": [
222
+ "safety",
223
+ "controls",
224
+ "network"
225
+ ]
226
+ }
227
+ },
228
+ "work_orders": {
229
+ "J-1357-5": {
230
+ "client": "CL-5",
231
+ "day": "2025-10-31",
232
+ "hub": "East",
233
+ "service": "controls",
234
+ "start": "15:00",
235
+ "state": "confirmed"
236
+ },
237
+ "J-3081-8": {
238
+ "client": "CL-8",
239
+ "day": "2025-10-31",
240
+ "hub": "Central",
241
+ "service": "network",
242
+ "start": "15:00",
243
+ "state": "confirmed"
244
+ },
245
+ "J-3357-7": {
246
+ "client": "CL-7",
247
+ "day": "2025-10-29",
248
+ "hub": "Central",
249
+ "service": "controls",
250
+ "start": "13:00",
251
+ "state": "cancelled"
252
+ },
253
+ "J-3915-6": {
254
+ "client": "CL-6",
255
+ "day": "2025-11-01",
256
+ "hub": "Central",
257
+ "service": "safety",
258
+ "start": "08:00",
259
+ "state": "cancelled"
260
+ },
261
+ "J-6809-1": {
262
+ "client": "CL-1",
263
+ "day": "2025-10-31",
264
+ "hub": "East",
265
+ "service": "network",
266
+ "start": "08:00",
267
+ "state": "confirmed"
268
+ },
269
+ "J-7595-2": {
270
+ "client": "CL-2",
271
+ "day": "2025-10-31",
272
+ "hub": "East",
273
+ "service": "safety",
274
+ "start": "15:00",
275
+ "state": "confirmed"
276
+ },
277
+ "J-8597-4": {
278
+ "client": "CL-4",
279
+ "day": "2025-10-31",
280
+ "hub": "East",
281
+ "service": "network",
282
+ "start": "15:00",
283
+ "state": "confirmed"
284
+ },
285
+ "J-8959-3": {
286
+ "client": "CL-3",
287
+ "day": "2025-10-31",
288
+ "hub": "East",
289
+ "service": "controls",
290
+ "start": "13:00",
291
+ "state": "confirmed"
292
+ },
293
+ "J-9820-0": {
294
+ "client": "CL-0",
295
+ "day": "2025-10-31",
296
+ "hub": "East",
297
+ "service": "controls",
298
+ "start": "10:00",
299
+ "state": "confirmed"
300
+ }
301
+ }
302
+ }
tasks/autom-field-service-rebooking-012-v2/instruction.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ A 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.
2
+
3
+ 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.
4
+
5
+ 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.
6
+
7
+ 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.
8
+
9
+ Use the offline app client at `/workspace/inputs/apps.py`. Call it with python3. Run
10
+ `apps` to discover apps, `list APP` to see its records, or `get APP ID` for one record.
11
+ Write with `update APP ID '{"field":"value"}'` or `create APP ID '{"field":"value"}'`.
12
+ The client records successful writes in `/workspace/outputs/actions.jsonl`.
13
+ Apply exactly the required changes. Other records and fields must remain untouched,
14
+ including temporary changes. Actions take effect in the local simulation only.
15
+
16
+ ## Deliverable
17
+
18
+ Work in `/workspace`. Input files are under `/workspace/inputs/`. Put every deliverable in
19
+ `/workspace/outputs/`; only that directory is graded. Leave the app action log in the outputs directory.
tasks/autom-field-service-rebooking-012-v2/solution/files/actions.jsonl ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-6809-1"}, "id": "S00", "op": "update"}
2
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-8959-3"}, "id": "S05", "op": "update"}
3
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-7595-2"}, "id": "S16", "op": "update"}
4
+ {"app": "calendar", "fields": {"state": "reserved", "work_order": "J-1357-5"}, "id": "S17", "op": "update"}
5
+ {"app": "dispatch", "fields": {"client": "CL-0", "status": "needs_slot", "work_order": "J-9820-0"}, "id": "follow-J-9820-0", "op": "create"}
6
+ {"app": "dispatch", "fields": {"client": "CL-4", "status": "needs_slot", "work_order": "J-8597-4"}, "id": "follow-J-8597-4", "op": "create"}
7
+ {"app": "work_orders", "fields": {"new_slot": "S17", "state": "rebooked"}, "id": "J-1357-5", "op": "update"}
8
+ {"app": "work_orders", "fields": {"new_slot": "S00", "state": "rebooked"}, "id": "J-6809-1", "op": "update"}
9
+ {"app": "work_orders", "fields": {"new_slot": "S16", "state": "rebooked"}, "id": "J-7595-2", "op": "update"}
10
+ {"app": "work_orders", "fields": {"state": "manual"}, "id": "J-8597-4", "op": "update"}
11
+ {"app": "work_orders", "fields": {"new_slot": "S05", "state": "rebooked"}, "id": "J-8959-3", "op": "update"}
12
+ {"app": "work_orders", "fields": {"state": "manual"}, "id": "J-9820-0", "op": "update"}