File size: 121,731 Bytes
e8598c4
056d99b
 
 
 
 
 
 
 
 
 
 
 
 
 
e8598c4
056d99b
 
cb32d35
056d99b
 
 
 
 
 
 
 
 
 
 
 
 
e8598c4
a6f7c10
056d99b
 
 
 
 
a6f7c10
056d99b
 
 
 
 
 
 
 
 
 
 
 
 
 
e8598c4
056d99b
 
a6f7c10
e8598c4
 
056d99b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a6f7c10
056d99b
a6f7c10
056d99b
 
 
 
 
cb32d35
056d99b
 
2a76e2c
 
 
e8598c4
a6f7c10
2a76e2c
 
 
e8598c4
89c6aca
 
e8598c4
89c6aca
 
 
 
 
 
 
e8598c4
89c6aca
 
 
 
 
 
 
 
 
e8598c4
89c6aca
 
e8598c4
89c6aca
 
cb32d35
 
 
 
 
 
e8598c4
 
cb32d35
 
 
 
 
 
 
 
 
e8598c4
cb32d35
 
 
 
e8598c4
cb32d35
 
a6f7c10
cb32d35
 
 
 
e8598c4
cb32d35
 
 
e8598c4
cb32d35
 
 
 
 
 
e8598c4
cb32d35
 
e8598c4
cb32d35
 
 
 
 
 
 
253d356
 
e8598c4
 
253d356
 
 
 
 
 
 
 
12599ab
 
e8598c4
 
12599ab
 
 
e8598c4
12599ab
 
 
 
 
 
 
 
 
 
 
 
e8598c4
12599ab
 
 
3fecce7
 
 
e8598c4
3fecce7
 
 
e8598c4
3fecce7
 
 
 
 
 
e8598c4
3fecce7
 
 
056d99b
1a3e907
e8598c4
1a3e907
 
 
e8598c4
1a3e907
 
 
e8598c4
5ef9243
 
 
 
 
e8598c4
5ef9243
 
 
 
 
 
 
 
 
 
 
 
 
e8598c4
5ef9243
 
 
e8598c4
5ef9243
 
e8598c4
5ef9243
 
 
 
 
 
 
 
 
 
 
 
 
fe22177
 
 
a6f7c10
e8598c4
 
fe22177
 
 
 
 
e8598c4
fe22177
 
 
 
 
 
 
e8598c4
fe22177
 
 
 
 
 
e8598c4
fe22177
 
d2f0ef7
e8598c4
d2f0ef7
 
 
 
 
 
 
e8598c4
d2f0ef7
 
 
 
 
 
 
 
 
 
e8598c4
d2f0ef7
 
 
e8598c4
d2f0ef7
 
 
 
 
 
e8598c4
aeb71e5
 
 
 
 
e8598c4
aeb71e5
 
 
 
 
 
 
 
 
 
 
 
 
e8598c4
aeb71e5
 
 
e8598c4
aeb71e5
 
 
 
 
 
 
4e6b123
 
 
 
e8598c4
4e6b123
 
 
 
 
 
e8598c4
4e6b123
 
 
 
 
 
e8598c4
4e6b123
 
e8598c4
4e6b123
 
 
 
 
 
 
 
e8598c4
4e6b123
e8598c4
4e6b123
 
9fad338
 
 
 
e8598c4
9fad338
 
 
e8598c4
9fad338
 
e8598c4
9fad338
 
e8598c4
9fad338
 
 
 
 
e8598c4
9fad338
 
e8598c4
9fad338
 
 
 
 
 
 
 
e8598c4
9fad338
6617bd4
 
 
 
 
 
 
e8598c4
6617bd4
 
 
 
 
 
 
e8598c4
6617bd4
 
 
e8598c4
6617bd4
 
 
 
 
e8598c4
6617bd4
 
e8598c4
6617bd4
844c535
 
 
 
e8598c4
844c535
 
 
 
 
 
e8598c4
67c6627
 
e8598c4
67c6627
e8598c4
67c6627
 
 
 
 
 
 
 
 
 
 
 
e8598c4
 
67c6627
 
 
 
e8598c4
67c6627
 
 
844c535
 
e8598c4
67c6627
 
 
 
 
1a3e907
8981e37
 
 
 
 
 
e8598c4
8981e37
 
 
 
e8598c4
8981e37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8598c4
8981e37
 
 
 
 
 
 
e8598c4
8981e37
 
 
 
e8598c4
8981e37
 
 
 
e8598c4
 
8981e37
 
 
 
e8598c4
8981e37
 
 
 
 
e8598c4
8981e37
 
e8598c4
8981e37
 
e8598c4
8981e37
 
 
e8598c4
8981e37
e8598c4
8981e37
 
 
e8598c4
8981e37
 
e8598c4
8981e37
 
 
e8598c4
8981e37
 
 
 
e8598c4
8981e37
 
 
 
e8598c4
8981e37
e8598c4
8981e37
 
 
bf22a94
8981e37
 
 
 
 
 
 
 
 
 
 
 
e8598c4
8981e37
 
 
e8598c4
e48a0db
 
 
 
 
 
 
 
e8598c4
e48a0db
 
 
 
 
 
 
e8598c4
e48a0db
 
 
 
 
 
 
 
 
 
 
144ca1d
 
 
 
 
bf22a94
144ca1d
 
bf22a94
144ca1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4dbd738
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144ca1d
bf22a94
144ca1d
 
bf22a94
144ca1d
 
dfa60db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8598c4
1b202fd
 
 
 
e8598c4
 
1b202fd
 
 
 
 
 
e8598c4
1b202fd
 
 
e8598c4
1b202fd
 
 
 
e8598c4
1b202fd
 
 
 
e8598c4
1b202fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4546034
 
 
 
 
 
 
 
 
 
 
 
 
bf22a94
4546034
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8598c4
ae1081d
 
 
 
 
 
 
e8598c4
ae1081d
e8598c4
ae1081d
 
 
 
 
e8598c4
ae1081d
 
 
 
 
 
e8598c4
ae1081d
 
 
 
e8598c4
ae1081d
 
 
 
 
 
 
e8598c4
ae1081d
 
 
 
98d6d4e
 
 
 
e8598c4
98d6d4e
 
 
e8598c4
98d6d4e
 
 
 
 
 
 
 
 
e8598c4
98d6d4e
 
e8598c4
98d6d4e
 
e8598c4
98d6d4e
 
 
 
 
 
 
 
 
e8598c4
98d6d4e
 
ae1081d
bf3553f
 
 
 
 
 
 
 
 
e8598c4
bf3553f
 
 
 
 
 
 
 
 
 
e8598c4
bf3553f
 
e8598c4
bf3553f
 
 
 
e8598c4
bf3553f
 
 
 
15ebeb5
e8598c4
15ebeb5
 
e8598c4
 
15ebeb5
 
 
 
 
e8598c4
15ebeb5
 
 
 
e8598c4
15ebeb5
 
 
 
e8598c4
15ebeb5
 
 
e8598c4
15ebeb5
 
 
e8598c4
15ebeb5
 
 
 
 
 
e8598c4
15ebeb5
 
 
e8598c4
15ebeb5
e8598c4
15ebeb5
 
 
 
 
 
e8598c4
15ebeb5
e8598c4
a152862
 
 
 
 
 
 
 
 
 
e8598c4
a152862
 
 
e8598c4
a152862
 
 
 
e8598c4
d25974f
 
 
 
 
 
 
e8598c4
d25974f
 
 
 
 
 
 
 
 
e8598c4
d25974f
 
 
 
 
 
e8598c4
d25974f
 
cabb4a3
e8598c4
cabb4a3
 
 
 
e8598c4
cabb4a3
e8598c4
 
cabb4a3
 
 
e8598c4
df66332
 
 
e8598c4
df66332
 
e8598c4
df66332
 
 
 
 
 
 
 
 
 
e8598c4
df66332
 
 
e8598c4
df66332
 
 
 
 
e8598c4
 
df66332
 
 
 
 
e8598c4
df66332
 
 
e8598c4
df66332
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1e046ce
e8598c4
1e046ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8598c4
1e046ce
 
 
 
 
 
 
 
 
e8598c4
1e046ce
 
 
bc7a228
e8598c4
bc7a228
 
 
 
 
 
e8598c4
bc7a228
 
e8598c4
bc7a228
 
 
 
 
 
cb32d35
e8598c4
1b202fd
e8598c4
1b202fd
 
e8598c4
1b202fd
 
 
 
 
 
 
 
 
 
a6f7c10
e8598c4
1b202fd
6617bd4
 
 
e8598c4
6617bd4
8981e37
 
e8598c4
844c535
4e6b123
8981e37
 
e8598c4
8981e37
 
 
 
 
 
e8598c4
8981e37
e8598c4
8981e37
 
e8598c4
12599ab
 
 
8981e37
 
e8598c4
5ef9243
 
 
 
 
 
 
cb32d35
 
739cdfb
 
 
e8598c4
739cdfb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a6f7c10
739cdfb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf22a94
 
 
e8598c4
bf22a94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5567807
e8598c4
5567807
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6fe78ac
e8598c4
6fe78ac
 
 
 
 
 
 
 
 
 
 
 
a6f7c10
6fe78ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a6f7c10
 
 
e8598c4
a6f7c10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8598c4
a6f7c10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
# TreasureHuntForTwo, Project Log

A running record of **what this project is, the decisions made and why, the rules/conventions
to follow, and the major changes**. Keep appending as the project evolves. (For the data
column definitions see **CODEBOOK.md**; for how to run/deploy see **README.md**.)

---

## 1. What it is
A child-friendly (ages ~10–17), Minecraft-styled web game that re-implements a **social
reinforcement-learning task** (originally PsychoPy/Pavlovia: `task_sl-cu`). The player
explores a world, enters houses, and opens treasure chests. Each chest pays coins to **both
the player and a "partner"** (an anonymous stranger who does **not** play but earns a real
bonus from the player's choices). Used in research on **callous–unemotional (CU) traits**.

- **Framework:** [NiceWebRL](https://github.com/KempnerInstitute/nicewebrl), runs a JAX env
  as an online experiment via NiceGUI (server-rendered images streamed to the browser).
- **Task structure:** 4 reward profiles A/B/C/D (self×partner good/bad); 6 option-pairs × 2 =
  12 houses; 16 trials/house; exact 12-gain / 2-loss / 2-neutral per option per recipient.

## 2. Where everything lives (3 platforms, distinct jobs)
| Place | Job | URL |
|---|---|---|
| **Hugging Face Space** (`hf` remote) | the **running game** (deploy: `git push hf main`) | huggingface.co/spaces/princessamygdala/TreasureHuntForTwo |
| **GitHub** (`origin` remote, private) | **code backup** (`git push origin main`) | github.com/princessamygdala/TreasureHuntForTwo |
| **GitLab** | **participant data** + `randomization_log.csv` (written automatically) | gitlab.com/princessamygdala/treasurehuntfortwo |

The **local folder** is still `task_sl-cu-nicewebrl` (cosmetic; not renamed to avoid breaking paths).

## 3. Rules & conventions (follow these)
- **Secrets:** `GITLAB_TOKEN` etc. live in `.env` (git-ignored) locally and as **HF Space
  Secrets** in production. **Never commit tokens.** A token was once exposed in pasted logs
  and rotated, be careful.
- **Freeze `orders.py` once real data collection starts.** Randomization is derived from the
  PID, so changing it changes every participant's design. (The CSV also derives box/house
  assignment from the *logged* data, so trial rows stay correct regardless.)
- **Two pushes after a change:** `git push hf main` (deploy) + `git push origin main` (backup).
  GitLab is never pushed to manually (it receives data automatically).
- **Dev/pilot runs are flagged:** `?dev=1` sets `dev_mode=1` in the data; `quality_flags.py`
  marks them `DEV(exclude)`. Never analyze dev sessions.
- **Provenance:** every session records `git_commit` so you can reproduce exactly what a
  participant saw.
- **Verify after building:** `smoke_test.py` (env), `orders.py` self-tests, `make_demo_data.py`
  + `export_csv.py` (data pipeline), and a clean server boot before deploying.

## 4. Participant IDs
- Format `<group><number>`, e.g. `0003` = control #3, `1007` = CU #7. **Group 0 = control,
  1 = CU.** Target 55/group. `next_id.py` reports the next ID to assign.
- **Same browser reused for a new kid:** opening `?pid=<new>` auto-wipes the old session
  (new seed → new file). Bulletproof habit for lab use: a fresh **incognito window** per kid.
- Same PID across two real sessions → **two separate data files** (no overwrite); each is
  timestamped in its `summary` row.

## 5. Key decisions (and why)
- **Procedural art, no asset files** (PIL), keeps deploy simple, HF rejects loose binaries.
- **Deterministic per-PID counterbalancing** (`orders.py`) = the original "one order file per
  ID" model, reproducible.
- **24 box stimuli** (color × material × lid); each participant gets **4 distinct-colored**
  ones assigned to A/B/C/D, the look is an arbitrary randomized label (like the OG fractals).
- **GitLab is the guaranteed data sink** (not Google) with **per-house checkpoint saves**,
  fixed a real data-loss bug where the final save was gated behind Google creds.
- **Outcome timing:** the chest holds for a **minimum 2 s** (keys locked, arrows blocked so
  they can't reset it), then a **"Press SPACE"** prompt appears and the player self-paces.
- **Cover story:** "matched with an **anonymous stranger** your age… you're playing for two."
  We still call them **"partner"** in-game.
- **10-coin scale:** outcomes shown as **+10 / 0 / −10** (underlying ±1 for analysis); money =
  coins ÷ 100, capped $6.
- **Sound** is **synthesised in the browser** (Web Audio, no files), off by default, one toggle.

## 6. Major changes (high-level changelog)
Earliest → latest (see `git log` for commits):
1. Built the JAX env + procedural rendering + stages (overworld → houses → choices → ratings).
2. Human-like avatars, bigger explorable world, treasure boxes + keys + floating coins.
3. Counterbalancing, cover story, instructions, quiz, practice, end-of-house rating, OG-style CSV.
4. Deployment to **HF Spaces** with **GitLab** data sink; incremental + per-house checkpoint saves.
5. Rich data CSV: ±1 + shown outcomes, A_self…D_other, "better option", verbal chest labels,
   block/visit order, quiz text, RTs, timestamps, technical info, slide/click events.
6. Distinct-color box guarantee; per-participant practice randomization.
7. **Take-a-break** button; **kid-friendly Pause**; outcome **auto-hold then Space**.
8. **Randomization log** rewritten to a self-describing schema (`pair_by_place`, `house_by_place`,
   stim descriptions, progress) + migration.
9. Reference-image exporter; **CODEBOOK**; README rewrite.
10. **Renamed** Duo Treasure Hunt → **TreasureHuntForTwo** (display, Space, GitHub, GitLab).
11. Anonymous **partner ID** + matching reveal on the cover.
12. More **avatars** (10, incl. robot/cat/plant/fox); **desktop/keyboard gate** + fullscreen.
13. **quality_flags.py** (post-hoc data-quality review).
14. **Dev/pilot mode** (`?dev=1&start=…&trials=…`), **git-commit provenance**, **Prolific** capture.
15. **Synthesised sound** with toggle; **10-coin scale**; fresh-session-on-PID-change.
16. **Practice rewritten as a fixed 6-step guided tutorial** (enforced directed choices): each
    step tells the player which named/textured chest to open (only it opens, it glows + swaps
    sides), with one red-blinking sentence per step. Covers all social outcome types in a fixed
    order, mutual benefit, consistency (same chest again), mutual loss, instrumental harm,
    altruism, zero. No per-participant randomization. New env fields `trial_pairs` + `directed`
    generalise per-trial pairs and the choice lock (main task = free choice). Script split:
    `orders.PRACTICE_PLAN` (numbers) + `experiment_structure.PRACTICE_SCRIPT` (text), synced by
    an assert; four practice chests in `sprites.PRACTICE_STIM_DESIGN`.
17. **Chest side-swap animation**, when the two chests trade sides they physically slide (~0.6 s):
    server ships a cached chest-less backdrop + one transparent layer per chest, client `playSwap`
    slides them. Fires on every real same-pair side-swap (main ≈ half of trials; one practice step).
    It is **purely cosmetic**, must NOT touch `window.accept_keys` (a key-lock race with the
    outcome timer once froze the game); fires **at most once per CHOICE trial** (a wrong/blocked box
    press used to replay it); **no swoosh** on swap.
18. **Practice feedback is PIL-rendered** (`_render_feedback_overlay`) so it exactly matches the
    in-game red directions (browsers lack DejaVu, so HTML fell back to a modern font). One flowing
    paragraph, **YOU / YOUR PARTNER capitalised**, tense consistent (past = the outcome, present =
    the lesson). `.thpfb` is now an `<img>` overlay, blinked.
19. **Practice → quiz transition**: after the preference/rating a clean end card ("Great, practice
    done!" + bottom "Press the space bar to continue."), SPACE advances. The framework's "press any
    arrow key to continue" toast is actively removed (sweep `.q-notification` when the end card
    shows + clear again at quiz start; env `msg_display_time=1500`). No auto-advance (it made the
    toast linger; reverted).
20. **Coins/feedback cleared on the SPACE press** (client-side) so they can't bleed onto the next
    screen (fixed a split-second overlap onto the rating screen).
21. **Text pass**: cover story reworded ("the world", "playing for two!", reordered bullets, "paid
    to both you and your partner"); **you/your partner bolded** throughout instructions + quiz;
    money is **$1 per 100 coins** (was wrongly "1000"); goal says **"figure out"** (never "learn");
    quiz intro = "Let's see if everything's clear!"; removed a duplicate quiz question and fixed a
    wrong-answer bug that showed "✗ Incorrect. Correct, …"; "You're all set" mentions the PAUSE
    button; partner reveal = "You were matched with your partner (#NNNN from our community
    database)" with only the ✓ green.
22. **COIN VISUAL, active TRIAL** (kept revertible): ONE golden coin showing "10"; on the chest two
    side-by-side boxed chips "+10 YOU" / "0 YOUR PARTNER"; +10 → coin box→pocket, −10 → coin
    pocket→box, 0 → nothing. Old two-coin helpers left in place → clean `git revert` if unwanted.
23. **16-trial variant** (`16-trials-redesign` branch, merged 2026-09-25): 16 trials/house (was
    20), exact 12-gain / 2-loss / 2-neutral per option per recipient (was 15/3/2). Removed the
    in-game attention check end to end (order generation, the `M_ATTENTION` env mode + renderer,
    the export row type + its four columns, the `quality_flags.py` `attn_fail` heuristic, and the
    docs). Removed all participant-facing progress indicators ("Houses cleared: n/12", "Try n/N").
24. **Reviewer overview doc** (`docs/make_overview_doc.py`): generates a plain-language walkthrough
    of the 16-trial build, task description, 5 rendered figures (world/practice/choice/
    outcome/rating), the verbatim instruction + quiz text, and every post-task measure, all
    pulled live from `experiment_structure.py`/`orders.py` at build time so the document can't
    drift from the running code. Re-run it after any instructions/quiz/questionnaire wording
    change. Also fixed a stale practice-trial count in `CODEBOOK.md` (6, not 5 →
    198 trial rows/session, not 197).
25. **`?dyad_mode=yes|no` URL flag** (default `no`): the parent/child hypothetical block and the
    experimenter's parent/child role picker only make sense when a participant has a study
    counterpart. The SONA pilot has none, so these 14 questionnaire items + the role picker are
    now opt-in instead of always-on; `?role=` is ignored unless dyad mode is on.
26. **24-unique-chest redesign** (2026-09-26): each reward profile used to have ONE chest look
    reused across every house all session, an unintended deviation from the original PsychoPy
    task (fresh stimuli each block) that pilot testers found exploitable ("I always pick red
    because it's the best"). `orders.py`'s `stim_map` is now `(12,4)` block×letter-indexed, filled
    by a single `permutation(24)` per participant so all 24 chests (12 houses × 2) are each used
    exactly once, never repeating. Practice keeps its own separate, letter-persistent
    `prac_stim_map` (the tutorial intentionally reuses 4 named chests by design, not the exploit).
    Threaded through `experiment_structure.py` (render + `custom_data_fn`), `export_csv.py`
    (`stim_by_block` replaces the now-invalid letter-keyed `stim_A..D`), `next_id.py` and
    `randomization.ipynb` (color-vs-valence balance across the sample, replacing the per-letter
    usage tally that no longer applies), `CODEBOOK.md`, `RANDOMIZATION.md`.
27. **Block order: i.i.d. shuffle → cyclic Latin square over `number`.** A per-ID random
    permutation only balances entry-position in expectation as N grows; real-world SONA
    attrition (no-shows, quits) can leave whatever *did* complete skewed. Mirrors `house_pos`'s
    existing `number % 5` rotation, extended to block order, verified in `orders.py`'s
    self-test (every pair-slot lands at every position exactly once per 12 consecutive IDs).
28. **Materialized per-participant order files** (`make_order_files.py`, new): writes a real,
    human-readable `orders/order_<pid>.csv` per participant (one row per block×trial: side,
    stim, outcome), the OG task had a per-subject order file; this port never did, until now.
    `--verify` re-derives from live `orders.py` and diffs against the file on disk, so drift
    would be caught. 120 files generated for a 60/group target sample.
29. **Two confirmed pilot bugs fixed** (found by re-reading the actual key-handling code against
    tester reports, not just the commit history): holding SPACE through the outcome's minimum-
    view lock let the browser's native key-repeat satisfy `accept_keys` with no fresh press,
    skipping feedback entirely for anyone holding before the unlock (now swallowed at capture
    phase); the true final screen never showed a coin/bonus summary at all, only the pre-
    questionnaire bridge screen did, so anyone who reached the real end (or quit before the
    bridge) never saw their totals (now shown on both).
30. **`smoke_test.py` / `make_demo_data.py` restored**, both were silently broken independent of
    (and predating) all of the above: `smoke_test.py` crashed on `_partner_pal`'s unguarded
    `app.storage.user` access outside a page context (missing the same try/except `_player_pal`
    already had); both scripts pressed Left/Right immediately on entering a house without first
    pressing Space to clear `awaiting_start`, so the simulated choice never resolved and the
    drive loop silently stalled for its full step budget. `smoke_test.py` now runs clean end to
    end (12/12 houses, 192 main trials + 6 practice trials); `export_csv.py` and `pyem_data.py`
    verified against the resulting demo export.
31. **3 more bugs found by actually playing the redeployed build** (browser + a local dev
    server, not just reading code): `HOW_TO_PLAY_IDENTITY` and its `draw_identity_icon()`
    illustration still taught the OLD design, "each chest keeps its value... wherever you see
    it again... for the whole game", the exact opposite of item 26's redesign. Rewrote both to
    teach the real mechanic (stable within one house, brand-new every new house); tightened a
    quiz-feedback line with the same "wherever it shows up" ambiguity. Found and fixed a genuine
    keyboard freeze matching an old pilot report marked "unclear" during triage: the sound-style
    button kept keyboard focus after being clicked, so the next Space/arrow press re-triggered
    it instead of reaching the game (fixed by blurring the active element after the button's
    click and after each menu selection; reproduced then re-verified fixed via a local dev
    server run). Also dropped a leftover "select their role" phrase from the PID-entry
    instructions when `?dyad_mode` is off (nothing to select in that case).
32. **Fixed the chest side-swap "rubberband" glitch** a pilot tester reported ("it would
    rubberband when I pressed my keyboard too fast"). Root cause: `step_and_send_timestep` runs
    on *every* keypress/step, including ones that don't change anything (a stray press while
    `awaiting_start` still blocks input, or the same trial re-stepped), and was unconditionally
    telling the client to `clearSwap()` whenever mode wasn't OUTCOME. Since `_maybe_swap` only
    starts the slide once per trial, any such extra step during that same trial called
    `clearSwap()` again mid-transition, ripping out the sliding overlay before its own
    320ms/360ms animation/timeout finished, visible as a snap-back. Fix: only clear the swap
    overlay when actually leaving CHOICE mode (to OVERWORLD/RATING); `playSwap()` already clears
    any previous swap itself before drawing and self-cleans via its own timeout, so it never
    needed the redundant server-side clear while still in CHOICE. Verified via a local dev
    server: a real swap transition (practice steps 1→2, guaranteed same-pair side-flip)
    completes cleanly; heavy zero-delay key-mashing through several main-task trials produces
    no console errors and no visible corruption.
33. **Separately identified (not fixed): "inputs seemed to drop often" is inherent to vendored
    NiceWebRL, not this repo's code.** `basics.js`'s keydown handler only calls `emitEvent` (i.e.
    only sends anything to the server) when `window.next_states !== null`; `next_states` is set
    to `null` the instant a key is accepted and only repopulated after the *next*
    `step_and_send_timestep` round-trip (server computes+renders all 5 possible next-state
    preview images, then pushes them over the websocket). Any keypress arriving before that
    round-trip completes is silently dropped client-side, never even sent to the server, no
    visual feedback. This reproduces easily under literal zero-delay key-mashing and would get
    worse on a slow connection/render, matching both pilot reports (one guessed "WiFi issue" for
    a freeze). Not patched: this is vendored third-party framework code (pinned via `uv.lock`),
    not something safe to hand-edit in place. Traced through the actual data-logging path to
    confirm this can't corrupt or double-record a choice, though: the same client-side gate means
    only one action is ever "in flight" to the server at a time, and separately, the env's own
    step function ignores non-Space actions once a trial has resolved into OUTCOME, so rapid/
    repeated pressing can only ever produce no visible effect, never a wrong or duplicate row in
    the exported data. Added one line to `HOW_TO_PLAY_WALK` ("one press = one step") so
    participants don't expect holding a key down to move continuously.
34. **Chest-color balance is now a systematic guarantee, not just an expectation**, the same
    treatment as item 27, applied to stimulus assignment. `_place_stim_map` no longer draws a
    fresh `rng.permutation(24)` per participant; each letter (A-D) owns a fixed baseline of 6
    stimulus "slots" out of 24, and every slot is rotated by the same `number`-derived shift.
    A rotated permutation is still a permutation (still exactly 24 unique chests per session),
    but because one shared rotation drives every slot, every one of the 24 chests is now
    guaranteed to land under every letter exactly 6 times per complete 24-ID cycle (within a
    group), not just in expectation, so a partial/attrited sample can't end up with a color
    skewed toward a particular reward profile. `orders.py`'s self-test checks this directly;
    `RANDOMIZATION.md` updated; `orders/order_<pid>.csv` regenerated to match (old files were
    from the previous random-draw scheme and no longer match live computation).

35. **`TreasureHuntForTwo_Method_and_Decisions.docx`** (2026-09-26): mirrors `pe-cu-nicewebrl`'s
    `ProsocialEffortTask_Method_and_Decisions.docx` structure, numbered sections, each design
    choice framed as old approach → problem found → fix, closing on a "Decisions still open"
    list. Also caught and fixed a stale module docstring in `experiment_structure.py` while
    writing it: the header comment still described outcomes as an i.i.d. per-round draw
    (P(+1)=0.75/P(-1)=0.15/P(0)=0.10, which doesn't even match 2/16=12.5%), when the actual
    generation (`orders._exact_sequence`, since the 16-trial redesign, item 23) is an exact
    12/2/2 count shuffled once per block. States plainly (not fabricated) that RL parameter/
    model recovery for this task's exact 16-trial/12-house design (`rl_hp.py`/`rl_hp.ipynb`)
    has not yet been run, listed under "Decisions still open" rather than invented.
36. **SONA multi-task study infra, phase 1: task-order handoff + consent/demographics/TriPM +
    pid pseudonymisation** (2026-09-26). Built to match `task_pe-cu-nicewebrl`'s existing
    single-task SONA plumbing (`%SURVEY_CODE%`/`_clean_pid`/`_sona_return_url`/`?sona=`,
    ported verbatim) rather than inventing a second, incompatible version.
    - **`order_link.py`** (new; duplicated with roles swapped in `task_pe-cu-nicewebrl`):
      `first_task(survey_code)`, a keyless CRC32 hash, so both tasks independently agree on
      which one a given participant sees first, with no shared server or lookup table (a
      pre-registered table isn't possible: SONA participants bring their own identifier,
      unknown in advance). `?study=sona` (new, independent of the existing `?dyad_mode`) marks
      a session as part of the combined study. Whichever task runs first hands off to the
      other's URL at its own ending instead of returning to SONA; whichever runs second runs
      the general measures (below) then returns to SONA.
    - **Consent, demographics, TriPM ported from `task_pe-cu-nicewebrl`** (`content/consent.md`,
      `demographics.txt`, `tripm.txt`, `tripm_key.csv`, `content_items.py`, and
      `questionnaires.consent_screen`/`demographics_screen`/`tripm_screen`, adapted from
      Stage-wrapped to plain async functions callable directly from `web_app.py` rather than
      the fixed per-task stage list). Per explicit instruction: each task's OWN post-task
      questionnaire stays attached to that task and runs once, right after it; consent runs
      once, on whichever task is first; demographics + TriPM run once, on whichever task is
      second, general self-report measures belong to the combined study, not to either task.
    - **Pid pseudonymisation**: a second Claude session working `task_pe-cu-nicewebrl` in
      parallel found that the actual SONA consent form (a newer `09-19-2026` version than the
      `08-25-2026` one already in this repo) still promises "[the SONA code is] not stored
      alongside your survey responses", which both tasks' PRE-existing plumbing violated,
      storing the raw code as the pid in every filename/CSV row/randomization-log entry. Fixed:
      the STORED pid for a `?study=sona` session is now `_pid_pseudonym()`, an HMAC-SHA256 of
      the raw code keyed by `SONA_PID_HASH_KEY` (an env var / HF secret, never committed), not
      a plain hash, because SONA codes are short/low-entropy enough that an unkeyed hash could
      be reversed by brute force. The raw code lives only in `app.storage.user["survey_code"]`,
      which `save_data()` explicitly excludes from the saved metadata, kept just long enough in
      memory to build the SONA return URL and to compute `order_link`'s hash (both tasks must
      derive their order from the SAME raw input). `SONA_PID_HASH_KEY` must be the SAME value in
      both tasks' `.env`, so a researcher can still join both tasks' records for the same
      participant. Verified end to end via a local dev server: stored pid is a stable 16-hex-
      char pseudonym reproducible from the same code, `survey_code` never appears in saved
      metadata, and the SONA return URL / cross-task handoff URL both correctly carry the RAW
      code (verified against a fake `https://example-sona.edu/credit?survey_code=...` and a
      fake other-task URL).
    - **Not yet built** (see open items below): the payment-collection screen + its separate
      store, the `sona` GitLab repo itself, and the RL model-fitting/recovery notebooks.
37. **Task order made genuinely predetermined and exactly alternating, not a hash split**
    (2026-09-26, same day). The user flagged that a per-code hash (item 36's original
    `first_task`) is only balanced in expectation, not the "systematic guarantee" this study's
    other counterbalancing already promises (block order, chest color). A hash can't be a
    pre-registered table either, SONA participants bring their own identifier, unknown in
    advance, so instead: **`gitlab_save.assign_task_order`**, a small shared log
    (`task_order_log.csv`) in a THIRD GitLab project (`SONA_GITLAB_*`, separate from either
    task's own data repo, shared with `task_pe-cu-nicewebrl`) that hands out "sl"/"pe" by
    arrival position and is idempotent (a survey_code already logged returns its existing
    assignment rather than reassigning). Race-safe via GitLab's per-file compare-and-swap
    (`last_commit_id` on update; create-only semantics on the very first write) with up to 5
    retries, unlike the bulk-commit approach `append_to_log` already uses elsewhere, which has
    no such check and would let two near-simultaneous arrivals silently overwrite each other.
    Verified with a mocked GitLab (alternation, idempotency, a simulated write conflict
    correctly detected and retried, and exhausted-retries correctly returning `None` rather
    than a possibly-wrong guess) before ever touching a real repo.
    - **A parallel session working `task_pe-cu-nicewebrl` caught a real bug in the first cut**:
      resolving order independently on both tasks (log-then-hash on each) means they can
      DISAGREE the moment one reaches the shared log and the other doesn't (e.g. a transient
      network hiccup on just one side), one task believes it's first and defers the general
      measures to "the other task", which has already finished and never collects them (or the
      mirror case: both collect them). Fixed: whichever task resolves order first (because the
      participant is actually visiting it first) carries that answer forward explicitly in the
      handoff URL (`&first=sl|pe&fsig=<hmac[:8]>`, signed with the same `SONA_PID_HASH_KEY`
      already shared for pid pseudonymisation) instead of letting the second task re-resolve.
      The second task only falls back to resolving on its own if the parameter is absent or
      fails signature verification (e.g. someone opens its link directly), verified end to
      end via a local dev server, including a deliberately-tampered signature being rejected
      and correctly falling back to independent resolution rather than being trusted.
    - **Every session now records its own `task_first` / `task_position` (1 or 2) /
      `task_order_source`** (`"shared_log"`, `"hash"`, or `"handoff"`) in the saved metadata,
      per the same reviewer's point: without this, reconstructing which counterbalancing scheme
      a given participant's session actually used (exact vs. approximate, and which task
      resolved it) is only possible by re-deriving it later, which after the fallback-
      disagreement bug above is exactly the thing that can't be reconstructed from outside the
      session. Field names (and the `"hash"` string, not `"hash_fallback"`) settled jointly with
      `task_pe-cu-nicewebrl`, which records the same fields, so a combined-analysis script never
      needs per-task column renaming.
    - **The `bear-sona` GitLab project was created** (2026-09-26, same day, with the user),
      `princessamygdala/bear-sona` on `gitlab.com`, private, a Developer-role project access
      token (needed `main`'s branch protection widened from "Maintainers" to "Developers +
      Maintainers" for "allowed to push", since the token's writes were otherwise silently
      rejected with 403). `SONA_GITLAB_PROJECT`/`SONA_GITLAB_TOKEN` written directly to both
      tasks' `.env` from the clipboard (never displayed in chat); `OTHER_TASK_BASE_URL` (cross-
      referenced: each task's `.env` points at the OTHER task's real HF Space) and a freshly
      generated `SONA_PID_HASH_KEY` (identical in both) written the same way.
    - **A real bug, found only by testing against the live `bear-sona` repo, not the mock**:
      `assign_task_order`'s POST/PUT bodies never set `"encoding": "base64"`. GitLab's single-
      file API defaults to `encoding: "text"` when it's omitted, so the base64 string this code
      sends as `content` was stored LITERALLY instead of being decoded, every write silently
      corrupted the log into double-base64-encoded gibberish, which then parsed as nonsense CSV
      and threw the alternation count off. The mocked test from the CAS work above didn't catch
      this because the mock always decoded `content` as base64 regardless of the `encoding`
      field. It was faithful to what the code SHOULD do, not to what GitLab ACTUALLY does
      without that field. Fixed both: `assign_task_order` now sends `encoding: "base64"`
      explicitly, and the mock was corrected to only decode when that field is present (so this
      class of bug fails the mock too, next time). Re-verified end to end against the real repo:
      clean alternation over several real writes, correct idempotent re-lookup, and a session's
      saved data showing `task_order_source: shared_log` (not the hash fallback) for the first
      time. Lesson: a mock that encodes the same assumption the code under test makes will pass
      even when that assumption is wrong. This one needed a real API round-trip to surface.
38. **Fixed a real "wrong entry" gap, and synced consent.md to the actual current approved
    text** (2026-09-26, same day, prompted by the user asking whether a pilot could actually go
    out). Two separate, real findings, not decisions:
    - **The redirect gap**: item 36/37's design gates CONSENT and the general measures on
      `task_first`, but nothing stopped this task's own MAIN GAME from running when a
      participant lands here directly and isn't assigned to see it first, i.e. every design so
      far assumed some other mechanism (two separate SONA links?) would route people to their
      correct first task, and neither app actually built that mechanism. With one shared SONA
      entry link (the realistic setup), roughly half of participants would have hit whichever
      task's link exists, and that task would have just run its own consent + game anyway,
      never routing them to the other task at all. Fixed: right after `task_first` resolves in
      `index()` (from the shared log/hash, not a trusted handoff) and this task isn't the
      assigned first task, redirect immediately to `order_link.other_task_url(...)` before
      rendering anything, guarded on `not experiment_started` so an in-progress session can
      never be stranded by this check. Verified against the REAL, now-live HarvestForTwo Space
      (secrets from item 37 made this possible for the first time): a "pe-first" test code
      hitting sl-cu directly correctly redirected, carrying a valid signed handoff, to the real
      pe-cu Space, which correctly showed consent as the genuine first task. Also checked the
      mirror case directly against pe-cu's live Space with a "sl-first" test code and confirmed
      **`task_pe-cu-nicewebrl` has the identical gap, still open as of this writing**, flagged
      to that session with the exact fix; not yet resolved on their side.
    - **Stale consent text**: `content/consent.md` (ported into this task from `pe-cu` under
      item 36, before the 09-19-2026 consent form was even found) was missing the current
      risk-disclosure paragraph, both apps still said "there are no risks to participating,"
      when the actual approved text discloses that some questions may be upsetting/sensitive
      and that data, while stored on secure servers, cannot be guaranteed safe from a breach.
      `pe-cu`'s copy additionally had the payment-mechanism sentence this task's copy lacked.
      Checked programmatically against every substantial paragraph of the actual `.docx`, not
      just spot-checked; fixed both files identically (verified byte-for-byte identical after).
    - Test data (`PILOTTEST0001`/`0002`) cleared from the shared allocation log afterward so it
      doesn't skew real counterbalancing once recruitment starts.
39. **Hardened the combined-study gate: `study == "sona"` alone is not a safe signal**
    (2026-09-26, same day). `task_pe-cu-nicewebrl` shipped their own entry-redirect fix
    (matching item 38's) and their test suite immediately caught a real bug: their `study` flag
    *defaults* to `"sona"` (this task's defaults to `""`), so `study == "sona"` was true for
    literally every one of their sessions the moment `OTHER_TASK_BASE_URL` existed, silently
    redirecting ordinary lab participants into the other task and deferring their general
    measures. This task was not affected today only because of the different default, which
    the same session correctly called out as fragile ("one default change away from silently
    redirecting your own lab participants").
    - **Fix, matched to `task_pe-cu-nicewebrl`'s own (`_in_combined_study()`, same name)**: the
      combined-study gate now additionally requires `sona_url` (the SONA completion URL from
      `?sona=`) to be set. Every genuine SONA link carries one, it's how credit gets granted,
      and no lab/dev/direct-test session ever has one, regardless of what `study` happens to be
      set to. `index()` reordered so `sona_url` resolves before this gate is first used; `study`/
      `sona_url` resolution consolidated to one place (was duplicated). `run_intro()` and
      `finish_experiment()` now call the same shared `_in_combined_study()` rather than each
      recomputing a slightly different local expression, so an ordinary lab session and a
      genuine SONA session diverge at exactly one decision point. pid pseudonymisation was
      deliberately left on the looser `study == "sona"` check alone, over-applying it is
      harmless (an extra layer of protection on a session that didn't strictly need it), unlike
      over-triggering the redirect/consent-skip, which actively harms a real lab participant.
    - Also logs a loud warning if a session has `study == "sona"` but no `sona_url`, such a
      session cannot grant SONA credit and (by design) is no longer treated as combined-study
      either, so a misconfigured real link fails loudly instead of quietly.
    - Verified via a local dev server: `?study=sona` with no `?sona=` no longer shows consent or
      redirects (confirmed the warning fires); the same participant code WITH a real `?sona=`
      correctly redirects to the true first task. Smoke test still passes. Test rows cleared
      from the shared log afterward.
    - `task_pe-cu-nicewebrl`'s `content/consent_dyad.md` (their OWN parent/child study consent,
      unrelated to this task's own `?dyad_mode`) still has the same stale risk-disclosure text
      this task's `consent.md` had. They are not fixing it themselves because the only source
      for the actually-approved parent-consent wording is a missing/orphaned file on that
      machine, not something to invent. This task has no `consent_dyad.md` (never ported one,
      SONA participants are solo, and this task's own separate `?dyad_mode` is the unrelated
      child-study flag), so nothing to check on this task's side.
40. **A `/health` deployment self-check, and the browser-testing episode that motivated it**
    (2026-09-26, same day). After item 39 shipped, live re-testing produced a real scare:
    browser-driven checks of the deployed Spaces from two separate sessions reached opposite
    conclusions about whether `task_pe-cu-nicewebrl`'s secrets were actually live, and neither
    session could falsify the other from outside, a stale frame or a still-loading cold start
    looks identical to a missing secret when all you have is "did the page redirect." (On this
    task's own side, browser automation independently got stuck showing a stale page across
    several fresh tabs/tab-groups, confirmed via direct `window.location` reads bypassing the
    tool's own reporting, a genuine tooling malfunction, not app behavior, but it made the
    point concretely: black-box browser verification of deployed secrets is not reliable enough
    to build a "pilot ready" conclusion on.) The actual root cause on pe-cu's side turned out to
    be a stale verification (a grep that matched an unrelated comment, so it could not fail),
    but the fix that matters is not re-litigating who was right, it's not needing a browser to
    find out. `task_pe-cu-nicewebrl` built a `GET /health` endpoint reporting secret PRESENCE
    only (never a value, prefix, or length, length is a real hint for a short secret), a
    build fingerprint (a hash of the actual running source, so "is the fix deployed" is a fact
    rather than an inference), and a `key_fingerprint` (`sha256(SONA_PID_HASH_KEY)[:8]`) letting
    both apps confirm they hold the identical shared secret without either ever revealing it.
    Ported verbatim per their instructions (own file list for the build hash; added
    `SONA_GITLAB_PROJECT`/`SONA_GITLAB_TOKEN` to `secrets_present`, since this task owns the
    shared allocation and pe-cu only consumes the signed answer, the dict keys legitimately
    differ between the two apps' copies, not drift). `test_health.py` ported alongside it
    (asserts no value/prefix/length ever leaks, including that output is unchanged when only
    the key LENGTH changes), all 7 pass.
    - **Found and fixed a real, independent bug while porting**: this task's `web_app.py` called
      `ui.run()` unconditionally at module level, unlike `task_pe-cu-nicewebrl`'s, which already
      guards it with `if __name__ in {"__main__", "__mp_main__"}:`. A bare `import web_app` (what
      the health-endpoint tests need to do) tried to actually start the real server and hung
      indefinitely. Fixed to match pe-cu's guard.
    - **The two apps' `SONA_PID_HASH_KEY` values were confirmed cryptographically identical**:
      this task's local `/health`-equivalent reports `key_fingerprint: bac6c5f6`, matching
      `task_pe-cu-nicewebrl`'s reported `bac6c5f6` exactly (both locally and in their
      production), settling, without either side ever transmitting the actual key, that every
      signed handoff between the two apps has in fact been verifiable all along.
    - **Both directions confirmed clean in the live production Spaces** (not just locally):
      `curl .../health` on each Space independently, from both sides, confirmed matching
      `key_fingerprint`s and correct `other_task_host`s; a "pe-first" test code hitting sl-cu
      directly redirected to the real pe-cu Space with a valid signature (pe-cu's consent
      rendered, confirmed by that session); a "sl-first" test code hitting pe-cu directly
      redirected to the real sl-cu Space with a valid signature (this task's consent rendered,
      including the updated risk text, confirmed here via direct `window.location` reads, not
      just the automation tool's own, possibly stale, reporting). Test rows cleared from the
      shared log afterward.
41. **A real, serious security gap `/health` surfaced on its first joint use: no
    `STORAGE_SECRET` was set on this task's live Space** (2026-09-26, same day).
    `task_pe-cu-nicewebrl` caught it by curling both `/health` endpoints independently rather
    than trusting either side's report, and noticed `secrets_present.STORAGE_SECRET: false` on
    this task's Space. `web_app.py`'s `ui.run(storage_secret=os.getenv("STORAGE_SECRET",
    "private key to secure the browser session cookie"))` silently falls back to that literal
    string when the env var is unset, and `web_app.py` is tracked in the public
    `princessamygdala/TreasureHuntForTwo` GitHub repo, so every session cookie was being signed
    with a string anyone could read. This is not just hygiene: NiceGUI signs `app.storage.user`
    with this key, and that dict holds `pid`, `survey_code`, `task_first`/`task_position`, and
    the running point totals the bonus is computed from, a forged cookie is a forged session
    (arbitrary pid, arbitrary order position, arbitrary earnings), and nothing downstream would
    flag it, because a forged session is internally consistent by construction. Fixed: generated
    a fresh 44-character random value (`secrets.token_urlsafe(32)`), set as `STORAGE_SECRET` on
    this task's Space AND in the local `.env` (neither had one before), confirmed via `curl
    .../health` that it now reads `true`. Deliberately NOT shared with `task_pe-cu-nicewebrl`'s
    own `STORAGE_SECRET`, unlike `SONA_PID_HASH_KEY`, each app must sign its own cookies
    independently; sharing this one would let a session forged against one app be presented to
    the other. Setting it invalidated any existing sessions, harmless pre-pilot, would not be
    mid-pilot. This is exactly the kind of thing to check BEFORE real recruitment, not after.
    Add "`STORAGE_SECRET` set, and not the repo-visible default" to the pre-pilot checklist.

42. **A latent (not realised) data-loss risk `task_pe-cu-nicewebrl` found while auditing every
    `os.getenv` call with a literal default: `GITLAB_URL`'s own fallback is the wrong host**
    (2026-09-26, same day). `gitlab_save.py` and `download_data.py` both default `GITLAB_URL` to
    `"https://gitlab.pavlovia.org"`, inherited from the task this repo was forked from, while
    this task's actual data repo has always lived on `gitlab.com`. `secrets_present.GITLAB_TOKEN`/
    `GITLAB_PROJECT` reading `true` says nothing about this: an unset `GITLAB_URL` still
    authenticates, just against the wrong GitLab instance, gets refused, and is swallowed by
    `push_to_gitlab`'s deliberately non-raising error handling (by design, so a save hiccup can't
    interrupt a participant). On a HuggingFace Space the local filesystem doesn't survive a
    restart, so this specific failure mode isn't degraded saving, it's silent, unrecoverable data
    loss, and item 40/41's presence-only `/health` checks could not have caught it.
    - **First move: added `gitlab_host` to `/health`**, mirroring the exact fallback the real
      code uses (rather than reporting `None` when unset, which would hide exactly the dangerous
      case), so an unset `GITLAB_URL` on a live Space would show up as `"gitlab.pavlovia.org"`,
      the true host it would actually hit, not "unknown." Checked the live Space and found it
      already correct (`"gitlab_host":"gitlab.com"`), `GITLAB_URL` was set as an HF secret in
      production, so this was a real latent bug that never actually caused data loss on this
      task's side, but visibility alone leaves the landmine for the next Space, duplicate, or
      migration where the secret isn't set.
    - **Fixed at the source, prompted by `task_pe-cu-nicewebrl` making the same call on their own
      copy**: `GITLAB_URL_DEFAULT = "https://gitlab.com"` (module constant in `gitlab_save.py`),
      replacing the wrong literal in all 4 spots (`gitlab_save.py` ×3, `download_data.py` ×1);
      `/health`'s `gitlab_host` now imports and mirrors that constant instead of duplicating the
      literal, so the two can't drift apart again. `test_no_pavlovia_fallback_survives` added
      (regex on the actual `os.getenv(..., "...")` default pattern, not a bare substring check,
      since this file's own comments legitimately still mention the word while explaining the
      bug's history).
    - **The worse half, found by the same audit**: the failure this default caused would have been
      completely inaudible. `push_to_gitlab` returned `False` on any failure, wrong host, expired
      token, branch-protection 403, all identical, and `web_app.py`'s caller only logged a bare
      `"skipped/failed"` with no host/status/reason; `append_to_log`'s return value was discarded
      by its caller entirely, so a failure there left literally no trace at all. Added a `_loud()`
      helper (prints flushed, for HF's log capture, and logs via the `"main"` logger) called
      unconditionally on failure in both functions and on the missing-token path, reporting
      host/project/branch/status/response text, matching the identical fix
      `task_pe-cu-nicewebrl` made to their own copy of this file, for the same reason: a save
      hiccup must never interrupt a participant (so the functions still can't raise), but that
      design choice is exactly why the failure needs to be loud somewhere else.
    - Lesson, same shape as item 41: "a secret is present" and "a secret's value is correct" are
      different questions, and a presence-only check can mask either a public-default security
      hole (item 41) or a wrong-but-plausible-looking default (this item), and even a correct
      default doesn't help if a real failure (a 403, an expired token) then fails silently too.
      Add "`GITLAB_URL` resolves to `gitlab.com` (checked via `/health`'s `gitlab_host`, not
      assumed from `GITLAB_TOKEN`/`GITLAB_PROJECT` presence alone), and the Space's own logs are
      checked at least once after any secret rotation for a `[gitlab] ... FAILED` line" to the
      pre-pilot checklist.

43. **The SONA-side study listing was actually created** (2026-09-27), and along the way
    surfaced two more real findings and one dead end:
    - **`SONA_RETURN_URL`, a new env var / Space secret**: SONA's own "Study URL" field turns
      out to be capped at 200 characters (a `maxlength` on the real ASP.NET textbox, not just a
      display limit). This task's URL (`.../?pid=%SURVEY_CODE%&study=sona`) plus SONA's own
      completion/credit-granting URL (which embeds a `credit_token`) as a `&sona=` query
      parameter together exceed that, and the field silently truncates on paste, which would
      have produced a broken, partially-truncated return URL that granted nobody credit,
      discovered only by actually filling in the real form, not by reading SONA's docs. Fixed
      by adding `SONA_RETURN_URL` (`web_app.py`'s `index()`, right after the existing `?sona=`
      handling): when `?sona=` is absent, falls back to this env var, which holds the same
      completion URL server-side instead, never has to fit in SONA's field, and the
      `credit_token` never sits in a participant's browser history/referrers either. Added to
      `/health`'s `secrets_present`; `test_sona_return_url_is_tracked` added to `test_health.py`
      (10 tests now pass). This shortened the actual Study URL back down to just
      `.../?pid=%SURVEY_CODE%&study=sona`, well under the limit.
    - **Attempting to move the Space off the personal `princessamygdala` HF username was a dead
      end, not a bug**: tried both duplicating and transferring `TreasureHuntForTwo` into a new
      free HF organization (`lsan-georgetown`, created this session) to get a more official-
      looking URL. Both are blocked by an actual Hugging Face platform rule, confirmed via the
      real error messages (not assumed): a new org needs a paid Team/Enterprise plan to host a
      Docker/Gradio Space on free `cpu-basic` hardware, and a personal account needs PRO for a
      *second* free `cpu-basic` Space. Neither transfer nor duplicate touched or broke the live
      Space (HF rejects both server-side before changing anything, confirmed by re-checking the
      Space was still `Running` under `princessamygdala` throughout). Decision: keep the current
      URL for the pilot; revisit branding only if it becomes a real problem later, since SONA
      participants reach it via the SONA study link, not by typing the URL themselves.
    - **A real, separate SONA platform bug found and worked around**: SONA's own deadline
      validation ("You may not add a timeslot that ends after the December 8, 2026 11:59 PM
      study schedule deadline") rejects *any* timeslot landing on that exact deadline day
      itself, regardless of the time set (`11:59 PM`, `11:00 PM` were both rejected; a date one
      day earlier or a date months earlier both succeeded immediately), looks like an
      off-by-one/timezone rounding bug on SONA's side, not anything under this repo's control.
      Worked around by setting the timeslot's final participation date to **December 7, 2026,
      3:00 PM** instead (one day of margin, negligible against a Sept–Dec recruitment window),
      not the 8th.
    - **A second, unrelated UI quirk on SONA's edit-timeslot page**: changing only the date on
      an *existing* timeslot via `modify_slot_info.aspx` silently failed to persist (no error
      shown) across several attempts, while changing only the Max Participants field on the
      same page persisted correctly, isolated by testing one field change at a time. Whatever
      the cause, deleting and re-adding the timeslot (via `add_slot.aspx`, which does show
      validation errors) worked reliably instead.
    - Created study "Social Decision Making Game (2 CREDITS + REAL BONUS MONEY)"
      (`experiment_id=457`): Online External Study, "identified only by a random, unique ID
      code" = Yes (this is literally what generates `%SURVEY_CODE%`, confirmed it defaults to
      No and must be explicitly set, and that SONA locks it permanently once saved), 60 min,
      2 credits, IRB code `STUDY00010492`, eligibility/abstract/description drawn from the
      lab's own recruitment-text and consent docs. Timeslot: through Dec 7, 2026, 300 max
      participants (target of 150 completed / ~180 invited per the OSF prereg, rounded up by
      the user for margin). Left `Inactive`/`Not Approved` (default), safe, invisible to
      participants, pending the user's own review and IRB-admin approval request.

44. **Payment-collection screen + separate payment store built (2026-09-28)**, and a real
    privacy gap `task_pe-cu-nicewebrl` found in the shared allocation log while reviewing it,
    fixed the same day.
    - **`order_link.py`**: `other_task_url()` gained `own_bonus_usd`, the first task to finish
      signs its own already-capped dollar bonus (HMAC, same key as `first=`/`fsig=`, namespaced
      with a `"bonus:"` prefix so it can't collide with the task-order signature) and carries it
      as `bonus1=`/`bsig=`. New `verify_signed_bonus()` checks it on arrival, fails closed on
      anything missing/malformed/tampered/unkeyed.
    - **`web_app.py`**: whichever task the participant finishes SECOND sums both tasks' self
      bonus (capped at $12 total, matching consent) and shows the new payment screen, inserted
      after the final bonus summary but BEFORE the "Return to SONA" button, since that button's
      4s auto-navigate timer would otherwise skip past it.
    - **`questionnaires.py`**: new `payment_screen()`, email + Venmo/Amazon Gift Card/PayPal
      choice, matching the consent form's exact wording. Collects and validates only; writing is
      the caller's job.
    - **`gitlab_save.py`**: new `submit_payment()`, writes to `payment_log.csv` in the shared
      `bear-sona` project (same one `assign_task_order` uses), same CAS-retry race-safety,
      idempotent by payment code (a resubmission updates in place; a human-set `status` like
      `"paid"` survives that update rather than resetting to `"pending"`). Nothing here executes
      a real payment, `status` starts `"pending"`; a human updates it by hand once actually
      disbursed. Deliberately does NOT carry a per-task self/partner points-or-dollar breakdown
      next to the email, that data is already recorded per-task in each task's own research
      CSV (`total_self`/`total_partner`/`money_self`/`money_partner`, pre-existing, unchanged)
      under the RESEARCH pseudonym, a separate identity from the payment code below.
    - **Payment identity**: `payment_code = web_app._pid_pseudonym(code, "SONA_PAYMENT_HASH_KEY",
      "payment")`, a DIFFERENT secret from `SONA_PID_HASH_KEY`, so nobody holding only one of
      the two keys can join email <-> research data. New Space secret needed on both tasks
      before real use; `/health`'s `secrets_present` now tracks it.
    - **The "partner" bonus is real money, not a cover story**, confirmed directly with the
      user after `orders.py`'s "COVER STORY ONLY" docstring (about the fictional in-game
      partner IDENTITY only) was misread as meaning the money wasn't real either. The partner
      bonus is disbursed manually by the research team to random real-world strangers, in bulk,
      after the study concludes, entirely outside this flow. `payment_log.csv` correctly holds
      only each participant's own self bonus; the aggregate stranger-bonus pool to disburse is
      already fully computable from existing research data (`money_partner`, summed across all
      participants' both-task CSVs) without any new code.
    - **The privacy gap**: `task_order_log.csv` (the shared log `assign_task_order` reads/
      writes) was keyed on the RAW survey code, not the research pseudonym, found by
      `task_pe-cu-nicewebrl` while checking what the new payment log would sit alongside in the
      same repo. A raw code persisted there, combined with `SONA_PID_HASH_KEY`, would let
      anyone holding both re-identify every participant's research data, undoing the point of
      pseudonymising it. Fixed: `order_link.first_task()` now takes the raw code and the
      pseudonym SEPARATELY, the raw code still feeds ONLY the local hash fallback (unpersisted,
      and both tasks must still derive it from the same raw input or their fallbacks can
      disagree, see the function's own docstring), while the pseudonym is what's now written as
      the log's row key. `gitlab_save.assign_task_order`'s docstring/param renamed to match; the
      CSV column itself stays named `survey_code` (shared schema with `task_pe-cu-nicewebrl`;
      renaming it needs a coordinated two-sided change, decided separately from this fix). A
      stale test row this surfaced (`99001`, confirmed by the user as their own single test
      click, no data collected either side) was dropped from the log by hand once it was
      rekeyed, so the log starts clean under the new scheme.
    - **Tests**: `test_payment.py` (new, 15 tests) covers the bonus-signature
      genuine/tampered/missing-key/collision-with-`first=` cases, `other_task_url` carrying/
      omitting the bonus, and a `FakeGitLab`-backed suite for `submit_payment` (create/update/
      status-preservation/simultaneous-submission-retry/missing-config). Plus one new
      `test_health.py` test for `SONA_PAYMENT_HASH_KEY` tracking. All passing.
    - **Not built, and deliberately so**: any automated disbursement (Venmo/PayPal API payouts).
      Recommended to the user and agreed: keep this a human-worked queue (the `status` column),
      both because IRB protocols for cash-equivalent payment typically expect a human in the
      loop, and because there's no clean compliant API for arbitrary-recipient research payouts.
    - **Coordination**: `task_pe-cu-nicewebrl` was sent the full design so they can mirror it
      (their own user's call, not built on their side by this session), same split used for the
      earlier consent-gate fix. Their `first_task` call site has the same bug shape if/when it
      resolves order directly rather than via a trusted handoff.

45. **Item 44's payment store WITHDRAWN the same day it deployed**, ruled out by the actual
    approved IRB protocol, found by `task_pe-cu-nicewebrl` while comparing the `09-19` and
    `09-22` BEAR protocol revisions.
    - **What changed in the protocol (2026-09-22)**: the SONA compensation section gained "we
      will be collecting contact information (name and email addresses) for these payment
      purposes. We will store names and email addresses in a password-protected contact/payment
      spreadsheet that is separate from other data in the study" and lost "For the SONA pilot
      study, no identifiable information will be collected from subjects." So the protocol
      authorises name + email, but commits to a password-protected spreadsheet SEPARATE from
      study data (matching this lab's existing Box-based arrangement for the adolescent arm),
      not a GitLab-hosted CSV written via a Space API token, and not email alone without a name.
      `content/consent.md` updated to match, by `task_pe-cu-nicewebrl` at the user's explicit
      instruction (byte-identical to `task_pe-cu-nicewebrl`'s own copy).
    - **What this ruled out**: `payment_log.csv`, `questionnaires.payment_screen()`,
      `gitlab_save.submit_payment()`, and `SONA_PAYMENT_HASH_KEY` as item 44 built them. Pulled
      from `finish_experiment()` the same day, confirmed via `/health` that this was live
      (`SONA_GITLAB_PROJECT`/`SONA_GITLAB_TOKEN` were both set, so a real submission would have
      actually written to the non-compliant store had anyone reached that screen, no real
      participant had; the SONA study is still `Inactive`). Replaced with a display-only
      screen: total bonus earned, no collection, nothing written. `payment_screen()`/
      `submit_payment()` left in the codebase, UNUSED, as a possible starting point.
    - **What's actually left to build, smaller than item 44**: the final screen shows the
      participant their payment reference and what they earned; an RA manually enters name,
      email, and amount into the lab's existing Box payment spreadsheet. Two open questions,
      with the user (as of 2026-09-28, not yet answered): (1) should the on-screen payment
      reference be the HMAC pseudonym, or something a person can read aloud and retype without
      error; (2) should the RA reconcile the amount from the task's own records rather than the
      participant stating it. Nothing further should be built here until those are answered.

46. **Both of item 45's open questions settled (2026-10-03), and a third one surfaced and
    settled with it**, after the user logged into the live SONA admin panel directly (first
    firsthand look either session has had, rather than reading the project log or inferring
    from `/health`).
    - **Confirmed firsthand, not just documented**: the Study URL ("View Study Website")
      genuinely opens `.../treasurehuntfortwo.hf.space/?pid=99001&study=sona` -- this task
      really is the sole entry point, settling the open question from item 45's sibling
      discussion with `task_pe-cu-nicewebrl` about their hash-only `order_link.py` being safe.
      (Also explains the earlier `99001` row this session investigated and dropped: SONA's own
      "Sample Link with Embedded ID Code" preview uses that exact value -- it was never a real
      or test participant, just the study page rendering its own example.) Study status is
      still `Inactive`/`Not Approved`, confirmed directly -- deliberately not yet requested by
      the user, who wants the task fully ready first.
    - **SONA's "Contact Participants" is bulk/templated, not 1:1**: one message per recipient
      GROUP (filterable by status, e.g. "granted credit", and date range), with `%FIRST_NAME%`/
      `%USERNAME%` merge fields -- not a thread where you type something unique per person in
      one action. This is the actual mechanism now adopted for payment contact: an RA
      periodically sends one bulk email to everyone granted credit, asking them to reply with
      name + Venmo/Amazon/PayPal preference.
    - **The third, previously-unasked question this surfaced**: SONA's "granted credit" list
      shows participants by their real SONA identity, never by anything this app saves -- so
      without something to correlate a bulk-email reply back to a specific saved bonus record,
      an RA receiving "Jane Doe replied with her Venmo handle" would have no way to find Jane's
      actual earned amount. Settled by showing the participant their RESEARCH PSEUDONYM itself
      (not a separate scheme) as an on-screen "reference code" on the final combined-bonus
      screen, with instructions to include it when replying to the bulk email -- since it's
      already the literal GitLab data-folder name, an RA can look it up directly with no new
      lookup tool, secret, or stored mapping required. This also settles item 45's two questions
      at once: the code format is "reuse the existing pseudonym" (not a new HMAC or
      human-readable scheme), and the amount is always read from the task's own saved
      `money_self`/`money_partner` (item 44's pre-existing, unchanged columns), never taken on
      the participant's word.
    - **Implementation (revised same day)**: the on-screen code isn't the bare pseudonym after
      all -- `order_link.signed_reference_code(pseudonym, amount_usd)` bakes the combined bonus
      total IN, as integer cents, and HMAC-signs the pair (same `SONA_PID_HASH_KEY`), format
      `"<pseudonym>-<cents>-<sig>"`. An RA reads the dollar figure straight off a reported code
      with no lookup at all, and a participant editing the digits before reporting it back
      breaks the signature (`order_link.verify_reference_code`, not required for the normal
      flow but there if a reported code ever looks suspicious). Falls back to the bare
      pseudonym if `SONA_PID_HASH_KEY` is unset. `gitlab_save.submit_payment()`/
      `Q.payment_screen()` remain in the codebase, UNUSED and not reconsidered -- this design
      needs neither. 6 new tests in `test_payment.py` (genuine/tampered-amount/tampered-
      pseudonym/malformed/no-key), 21 total, all passing.
    - **A correction surfaced while building this**: the earlier assumption (from
      `task_pe-cu-nicewebrl`'s own message) that the final combined-bonus screen "is always"
      this task's to show was WRONG for this display-only design -- re-traced the entry-redirect
      logic and confirmed the task that ends up SECOND alternates with `task_first` (`sl` first
      -> `pe` ends up second and must show its own version of this screen; `pe` first -> `sl`
      does). That claim held only for the OLD write-based design (item 44), where only this
      task had `SONA_GITLAB_*` credentials to write with -- a display-only reference code needs
      no credentials, so `task_pe-cu-nicewebrl` needs the matching screen on their side too, for
      when they're the one who ends up second. Flagged to them directly.
    - **Consent updated the same day, at the user's explicit instruction**: "To send it, we will
      ask for your name and an email address at the end of the study" (written assuming in-app
      collection, item 45) now reads "the research team will contact you through SONA after the
      study to ask for your name and an email address" in both places in `content/consent.md` --
      matches the actual mechanism (a later bulk SONA email, not an in-app form). `SONA_GITLAB_*`/
      password-protected-spreadsheet/separate-from-study-data language is unchanged; this is a
      "when/how we ask" correction only, not a new protocol claim. `task_pe-cu-nicewebrl` notified
      to keep their copy in sync, same coordination as item 45's edit.
    - **Cleanup from this session's own verification**: clicking "View Study Website" to
      confirm the URL re-triggered `assign_task_order` for `pid=99001` -- correctly wrote the
      PSEUDONYM this time (`cd8e48fa51523ad4`, confirming item 45's privacy fix holds in
      production), not the raw code, but still needed clearing from `task_order_log.csv` same
      as before. Blocked by the same browser-automation permission gate as the first `99001`
      cleanup; left for the user.

47. **`task_pe-cu-nicewebrl` built the matching screen (2026-10-04)** -- the gap item 46 flagged
    (they end up the second-finishing task roughly half the time, and had nothing to show when
    they did) is closed. Confirmed live on their side (`/health` build `79eac1b8705c`), their
    `signed_reference_code`/`verify_reference_code`/`verify_bonus` (their naming for
    `verify_signed_bonus`)/`own_bonus_usd=` all match this task's construction.
    - **Cross-repo byte-compatibility actually verified, not assumed**: they loaded both
      repos' `order_link.py` under one shared key and confirmed IDENTICAL signed codes at
      $0.00/$3.33/$8.50/$12.00, each module accepting the other's signatures, and a tampered
      amount rejected by both. This is now a COMMITTED TEST on their side that imports this
      repo's module by path (skips if not checked out) -- will catch future drift on either
      side automatically, not just at build time.
    - **Wording aligned**: this task's final screen said "email you separately"; their copy
      matched consent.md's own "contact you through SONA" phrasing instead. Changed this task's
      copy to match (cosmetic -- a participant only ever sees one of the two screens -- but
      keeps the promise consistent with what consent actually says). Deployed, confirmed live.
    - **The filed consent document was behind the served one**: the user had the 09-28 docx
      (the version actually on file with the IRB) updated to match -- `SONA Pilot Consent
      10-03-2026.docx`, now on the Desktop, both payment sentences revised. The 09-28 docx had
      still said "at the end of the study" even after item 46's consent.md edit went live,
      meaning the served form had moved ahead of the filed one until this. Not yet submitted to
      the IRB as far as this session knows -- that's part of "getting ready", not done.
    - **Nothing outstanding on payment, from either session, as of this item.**

48. **A real, serious bug found via an actual live two-task playthrough (2026-10-08)**, "nothing
    outstanding" (item 47) was about payment specifically; the combined-study HANDOFF itself was
    broken for roughly half of all participants, undetected until this session finally ran the
    full flow live instead of trusting unit tests and deploy checks alone.
    - **Symptom, reproduced twice, deterministically, via a background agent's live playthrough**:
      a participant whose first task is `pe` (Harvest), i.e. anyone whose single SONA link
      redirects them away from this task before they see anything, finishes Harvest, is handed
      back here with a genuine, correctly signed `first=pe&fsig=...`, and instead of playing this
      task, gets silently bounced straight back to Harvest. The mirror case (`task_pe-cu-nicewebrl`
      finding, logged there) showed Harvest re-displaying consent to a legitimate signed
      second-task arrival. Both are the SAME class of failure: a verified handoff not being
      trusted.
    - **Root cause, found by tracing (not guessing)**: this task is the fixed entry point, so a
      participant whose first task is `pe` touches THIS task's session TWICE, once on arrival
      (resolves `task_first="pe"`, caches it, redirects away before `experiment_started`) and
      once on return (the genuine handoff from Harvest, in the SAME browser session). The old
      "resolve once" guard (`"task_first" not in app.storage.user`) saw it was already cached
      from the FIRST visit and skipped verifying the handoff entirely on the second, leaving
      `task_order_source` stuck at its stale pre-redirect value (`"shared_log"`/`"hash"`, never
      `"handoff"`). The entry-redirect check immediately below then fired AGAIN on that stale
      value, bouncing the participant right back to Harvest instead of ever letting them play.
    - **Fix**: a genuinely verified handoff (`verify_signed_first` returns True) is now trusted
      and applied on EVERY request that carries one, not gated behind "nothing cached yet", a
      cryptographically verified handoff is always more authoritative than an earlier
      self-resolved guess from this same session, so it's now allowed to UPGRADE
      `task_order_source` to `"handoff"` even when something else was already cached. Falling
      through to independent resolution (shared-log-then-hash) still only happens when nothing
      is cached AND no verifiable handoff is present on this request, so an ordinary reload
      still doesn't trigger a redundant shared-log call. `web_app.py`'s `index()`, the block
      right after `combined_study_active` is computed.
    - **Not yet done**: a live re-test confirming the fix actually resolves the bounce-back (the
      diagnosis is from careful code tracing, matched precisely against the live-observed
      symptom, but hasn't been re-verified live yet); `task_pe-cu-nicewebrl`'s mirror symptom
      (consent reappearing) has a DIFFERENT shape -- their task has no prior-visit state in that
      scenario (Harvest is never the entry point), so the stale-cache mechanism above does not
      by itself explain their case, and needs their own tracing. Flagged to them directly, along
      with this fix as a reference pattern.
    - **Process note**: every previous "deployed and confirmed live" claim this session was true
      at the level it was checked (build-hash matches, unit tests pass, `/health` secrets
      present) but NONE of that exercises the actual cross-task handoff end to end. This bug
      could only ever surface by actually playing both tasks in sequence, which nothing before
      this item had done since the reference-code redesign (items 46-47) landed.

49. **`task_pe-cu-nicewebrl` found and fixed their own mirror of item 48 (2026-10-13)** --
    root cause: their consent-skip was gated on their `_in_combined_study()` equivalent, which
    requires `sona_url`. This task supplies its own `sona_url` from `SONA_RETURN_URL` (a Space
    secret) rather than the query string, and a participant arriving at a SECOND task with no
    `sona_url` in that session's own storage made `_in_combined_study()` false there even on a
    genuinely verified handoff, so their consent-skip never fired. Their fix trusts a verified
    handoff directly, regardless of `sona_url`.
    - **Checked, not assumed, whether this task's own handoff could do the same thing**:
      `order_link.other_task_url()` carries `sona=` across the handoff whenever
      `app.storage.user["sona_url"]` is already resolved, and that resolution (including the
      `SONA_RETURN_URL` fallback) runs on every request before `finish_experiment()` can build
      the handoff -- confirmed by reading the code and by calling `other_task_url()` directly
      with a realistic `sona_url` and reading the output. So this task's handoff is not
      currently missing `sona=` in production, and item 48's `99001`/Oct-8 observation this
      traced back to does not reproduce via the mechanism `task_pe-cu-nicewebrl` found for
      their own side.
    - **This task's consent gate does not share the same shape**: it defaults to NOT showing
      consent unless `_in_combined_study()` is active (the opposite default from their side,
      which shows consent unless explicitly skipped), so the specific "shown again" failure
      mode they found cannot occur here the same way -- confirmed by reading `run_intro()`.
    - **The general-measures (demographics/TriPM) deferral has the same shape of dependency on
      `_in_combined_study()` theirs had, hardened anyway**: `finish_experiment()` now also
      trusts a directly verified handoff (`task_order_source == "handoff"` and
      `task_position == 2`) alongside `_in_combined_study()`, rather than depending solely on
      `sona_url` having reached this session. Not currently exposed given `SONA_RETURN_URL` is
      configured, but the failure direction here would have been the measures never running
      (a gap) rather than running twice, since this task's own default (unlike their consent
      default) already fails toward "skip", not "show". Fixed for the same reason their fix
      was worth having: nothing participant-facing should depend on a Space secret staying
      configured when the actual proof -- the verified handoff -- is already in hand.
    - **Still open**: a fresh session on the effort task (`task-pe-cu-nicewebrl-f9`, distinct
      from the one that reported the above) is running a live combined-study playthrough right
      now, specifically to exercise both this item's fix and item 48's together for the first
      time. Neither fix has a live confirmation yet; this is that test.

50. **A short, deterministic pilot path for the user's own live run (2026-10-13)**, the user
    wants to personally play the combined session end to end, kept to one house here and one
    self/one other trial per day/night block on the effort task's side, rather than the full
    12-house/48-trial design.
    - **`task_pe-cu-nicewebrl` found and fixed two things on their own first**: `trials=2` used
      to truncate a shuffled block, so it could land as two self trials or two other trials
      depending on the pid; they made the truncation balanced on beneficiary instead. Their
      cross-task handoff was also dropping the night block entirely (`?watch=1` only turns it
      on, and `other_task_url()` never carried it), a verified handoff now defaults the night
      block on.
    - **This task had no equivalent short-house path at all**, `?dev=1&trials=N` already
      shortened trials per house, but every dev run still played all 12 houses. Added
      `?houses=N` (new `dev_houses`, read in `web_app.py`'s existing dev block): `OrderedEnvStage.
      activate()` now builds `env_params` from `experiment_structure.dev_active_mask(k)` instead
      of the fixed `_MAIN_ACTIVE` when set. Inactive houses start pre-marked `consumed` (`reset()`
      already does `consumed=~active`), so the existing `done = is_confirm & jnp.all(new_consumed)`
      check needed no change. It was already written to finish as soon as every ACTIVE house is
      cleared, the same mechanism practice already relies on with its own single-house mask.
    - **Mirrored `task_pe-cu-nicewebrl`'s dev-passthrough fix, which this task was missing
      entirely**: `order_link.other_task_url()` gained `dev=`/`dev_trials=` params that append
      `&dev=1&trials=N` to the handoff URL, and `finish_experiment()`'s real handoff call now
      passes `dev=app.storage.user.get("dev_mode")` and `dev_trials=app.storage.user.get(
      "dev_trials")`. Without this, a shortened run on one task handed over to a full-length run
      on the other, exactly the gap their side already had and fixed. `houses=` is NOT carried
      across the handoff (the other task has no concept of it, and the test plan below only
      needs it on the leg where this task runs first, where the user's own link already sets it
      directly).
    - **The entry-order redirect now skips itself when `?dev=1` is present**: a dev link is a
      statement about what to run right now, not something the real allocation should override, mirrors `task_pe-cu-nicewebrl`'s own `not dev_q` guard on their equivalent redirect.
      Computed a `dev_q` from the raw query string early in `index()`, before this redirect, since
      `app.storage.user["dev_mode"]` isn't set yet at that point on a first visit.
    - **Verified, not assumed**: import check on `experiment_structure`/`web_app`/`order_link`
      passes; `test_payment.py`'s 21 tests still pass; a direct call to the new `other_task_url(
      ..., dev=True, dev_trials=2)` produces `...&dev=1&trials=2` in the URL; `dev_active_mask(1)`
      returns `[1,0,0,0,0,0,0,0,0,0,0,0]`.
    - **Test plan agreed with `task-pe-cu-nicewebrl-f9`**: two pids picked so `first_task`'s crc32
      lands deliberately rather than by chance, `TEST_pilot1` resolves `pe` first, `TEST_pilot4`
      resolves `sl` first. `TEST_pilot4` is the one for the user's own full run, opened directly
      on this task with `?dev=1&start=main&houses=1&trials=<N>`, so the houses= override is set
      explicitly before the handoff carries `dev=`/`trials=` on to the effort task. Each session
      reports what it sees on its own side as it happens rather than one triaging the other's
      screens. Not yet deployed or run live as of this item. (Since superseded: item 50's
      `?houses=` override now also crosses the handoff when the other task sends it, item 51.)

51. **Three consent-text corrections, found by `task_pe-cu-nicewebrl` on their own served form
    and confirmed present on this task's too (2026-10-13/14)**, the user approved mirroring all
    three, since whichever task runs first is the one that shows consent, and both forms had the
    same errors.
    - **Venmo**: `content/consent.md` said "Venmo Gift card, Amazon Gift card, or PayPal", but
      Venmo was never set up, only an Amazon gift card and PayPal exist. Changed to "an Amazon
      gift card or PayPal" in both places the sentence appears.
    - **Task order was hardcoded and wrong for half the sample**: the form said "The first task
      is a treasure hunt... The second task is a corn harvest," true only for participants who
      get this task first. Replaced with a task-neutral description plus a `{TASK_ORDER}` slot,
      filled by a new `content_items.consent_text(first_task=...)` from
      `TASK_ORDER_SENTENCES = {"pe": "...corn harvest first...", "sl": "...treasure hunt
      first..."}`, with `TASK_ORDER_UNKNOWN` ("decided at random") for the `first_task=None` case
      (every single-task run). Byte-identical sentences to their copy, so a participant reading
      either form sees the same order described the same way. `questionnaires.consent_screen()`
      now passes `app.storage.user.get("task_first")` through, already resolved before this
      screen runs, since the screen itself is gated on `task_first == THIS_TASK`.
    - **Payment-ask wording named only name + email**, omitting the reference code shown on the
      final screen, the thing that actually says which session to pay and how much. Both
      mentions (`content/consent.md`'s compensation paragraph and its data-handling paragraph)
      now name all three and add that the code "holds nothing about you."
    - **Not touched**: `questionnaires._PAYMENT_METHODS`/`payment_screen()` still say "Venmo",
      dead code left over from the withdrawn in-app payment store (item 45), not called from
      `web_app.py` anywhere. Left alone rather than fixed, since touching unused code wasn't part
      of what was approved and it shows nothing to a participant.
    - **Verified**: `consent_text(first_task="pe")`/`"sl"`/`None` each produce the correct
      sentence with no leftover `{TASK_ORDER}` brace and no "Venmo" anywhere in the output;
      `web_app` imports cleanly; `test_payment.py`'s 21 tests still pass.
    - **Flagging, not resolving**: this is the second time this session the served consent text
      has changed (first was item 46/47's payment-sentence rewrite). The filed IRB docx (`SONA
      Pilot Consent 10-03-2026.docx` per item 47) was already being tracked as needing
      submission before this edit, now further behind the served text. Whether/when to update
      and (re)submit the filed document is the user's call, same as item 47 left it; not decided
      here.

52. **Two more corrections found on `task_pe-cu-nicewebrl`'s side, one applying here, one not
    (2026-10-14)**.
    - **Checked, not assumed, whether this task's comprehension quiz has the same "correct
      answer always first" artifact their multiple-choice quiz had**: it doesn't, structurally.
      `quiz_items()` is six TRUE/FALSE statements with a mixed pattern of correct values
      (False, True, False, True, True, True) rather than a multi-option list with a fixed
      correct position, and `quiz_display()` already randomises question ORDER per participant
      (`random.shuffle(order)`, pre-existing, not new). A fixed-position shortcut can't ace this
      format since which button is correct varies item to item. Also confirmed no exclusion
      criterion is tied to this quiz, missed items are just re-asked until correct.
    - **The TriPM did have both problems they found on their own copy**, confirmed by reading
      `content_items.tripm_items()` (plain file order, no shuffle) and `questionnaires.
      tripm_screen()` (`submit()` returned early and blocked `done.set()` while any item was
      unanswered). Both fixed, mirroring their already-live fix:
      - `tripm_items(order_seed=None)` shuffles with `random.Random(zlib.crc32(f"tripm|
        {order_seed}"...))` when a seed is given, keeping each key attached to its own item so
        `tripm_key.csv` still scores what it was written against. `tripm_screen()` now passes
        `order_seed=app.storage.user.get("pid") or "anon"` and returns `item_order` alongside
        the answers, so the presented order is recoverable afterward.
      - `tripm_screen()`'s `submit()` now warns and calls `_confirm_skip()` instead of just
        refusing to proceed, request, not force, matching consent's "you can choose not to
        answer any question you do not wish to answer" and every other page in this battery.
    - **Also fixed `_confirm_skip()` itself**, the shared dialog this task already had (their
      copy's docstring says it was ported FROM here), their side separately found and fixed a
      bug in their ported copy: the dialog had no `persistent` prop, so dismissing it by Escape
      or a backdrop click set neither button's event, stranding the awaiting coroutine and
      leaving the dialog's DOM node behind on every such dismissal. That bug was latent in THIS
      task's original too (already used by `_nav_row`'s `is_complete` path, not just the new
      TriPM use), fixed here by porting their fix back: `.props("persistent")` plus a
      `dialog.delete()` cleanup after the event fires.
    - **Verified**: `tripm_items(order_seed=X)` is stable for the same seed and differs across
      seeds (58 items both times); `web_app` imports cleanly; `test_payment.py`'s 21 tests pass.

53. **A real review list from the user's own pilot playthrough, relayed by `task-pe-cu-
    nicewebrl-f9` (2026-10-14)**, items 1-4 were this task's alone; 5, 6, 8 were already
    decided by the user and applied here to match; 7 needed a new signed cross-task field.
    1. **Removed the "A couple more things before you're done." interstitial** in
       `finish_experiment()`, straight into TriPM now, no click-through.
    2. **Demographics now runs AFTER TriPM**, not before, matches `task_pe-cu-nicewebrl`'s
       order, reversing this task's own.
    3. **The "Questions about the future" scale is now shuffled per participant**, same
       `random.Random(zlib.crc32(...))` construction as item 52's TriPM fix, key traveling
       with its item, recorded as `future_item_order` in the saved dict.
    4. **A handoff arrival under `?dev=1` now still runs the front matter** (title screen,
       explorer choice) instead of the dev shortcut's usual skip, `start_experiment()` gained
       a `handoff_arrival` check (`task_order_source == "handoff" and task_position == 2`)
       mirroring `task_pe-cu-nicewebrl`'s identical fix; consent itself is still skipped, via
       `run_intro()`'s own `task_first` gate, not by this change.
    5. **The belief/suspicion check (`_belief_page`) is asked last, after TriPM and
       demographics**, not mid-battery, revealing a manipulation check early colors every
       self-report answer that follows it, the user's stated reason, matching
       `task_pe-cu-nicewebrl`'s identical move. Extracted into a standalone
       `questionnaires.belief_check_screen()`; `post_game_questionnaire_stage()` now defers it
       (`app.storage.user["_belief_check_deferred"]`) whenever `task_position == 2`, since for
       that participant TriPM/demographics run later still, in `finish_experiment()`, asking
       it there, right after demographics, is what makes it actually last instead of just
       reordered within this task's own page list.
    6. **Post-task page headings replaced with TriPM-style instruction lines**: "Motivation",
       "Effort", "About the task" no longer render as `## Title` headers, each now opens with
       a plain instruction sentence matched to its own response scale ("Please indicate how
       motivated you were...", "...how much effort...", "...how each statement...applies"),
       dropping the heading entirely, same register TriPM already used. Hypothetical (dyad-only)
       pages were left as-is, unused in the current SONA pilot, out of scope for this pass.
    7. **New signed handoff field for partner totals, agreed with `task_pe-cu-nicewebrl`**: the
       first task's own partner is never shown to the participant (its final screen is skipped
       under a verified handoff), so the task finished SECOND had no way to report it.
       `order_link.other_task_url()` gained `partner_bonus_usd=`/`partner_lost_usd=0.0` →
       `pbonus1=`/`plost1=`/`psig=` (signed over `"partners:<earned>:<lost>"`), verified on
       arrival by new `verify_signed_partners()`, stored as
       `other_task_partner_bonus_usd`/`_lost_usd`. `plost1` always sends `0.00` from this task, the chest mechanic has no one-sided loss the way their night harvest does; the shared
       construction still carries both so one signature covers either direction.
       `finish_experiment()`'s final screen now reports this task's own partner (already known
       locally) AND the other task's partner(s) (shown only when the handoff actually carried
       one, a missing figure is not shown as zero).
    8. **A "new adventurer and partner" note on `cover_part1`** when `task_position == 2`, so a
       second-task participant doesn't carry an assumption from the task just finished, mirrors
       `task_pe-cu-nicewebrl`'s equivalent note on their own cover story.
    - **Verified**: `web_app`/`questionnaires`/`order_link` import cleanly; `test_payment.py`'s
      21 tests pass; a direct `other_task_url(..., partner_bonus_usd=4.5)` call round-trips
      through `verify_signed_partners` correctly and a tampered amount is rejected.
    - **Not done**: the three items under `task-pe-cu-nicewebrl-f9`'s own "MINE" heading (night
      slide wording, their day quiz, their final-screen auto-forward) are their own repo's work,
      not mirrored here, nothing on this list depended on them.

54. **Quiz re-ask loop had no attempt cap at all (2026-10-14)**, `task-pe-cu-nicewebrl-f9`
    mentioned their day quiz caps at four attempts, matching their night quiz, and asked
    whether this task's own re-ask loop had an equivalent cap. It didn't: `while wrong: ...`
    had no exit condition besides answering correctly, so a participant unable to pass a given
    item for any reason (confusion, a device issue) had no way through it within the task's own
    flow. Also found and fixed in passing: the loop's `attempt` counter was global across every
    wrong item combined, not per item, so it never actually tracked how many times a given
    item itself had been retried.
    - **Fix**: new `MAX_QUIZ_ATTEMPTS = 4` (counts the first pass, so 3 retries beyond it,
      matching their cap), and a per-item `tries` dict replacing the global counter. A still-
      wrong item at the cap is let through and flagged `forced=True` in its response record,
      rather than being asked again, visible in the data as "never actually answered this
      correctly," not silently passed as if it had been.
    - **Also confirmed, not just assumed**: item 53's `pbonus1=` naming already matched their
      corrected version (they had written `pearn1` in code against their own `pbonus1`
      proposal, caught and fixed on their side), nothing to change here. This task used
      `pbonus1` from the start.
    - **Verified**: `experiment_structure`/`web_app` import cleanly; `test_payment.py`'s 21
      tests still pass.

55. **The final screen needed each partner named, not just a combined total (2026-10-14)**,
    the user's actual clarification of item 53.7: "tell on the final screen for each you, your
    partner (1), your partner (2) your partner 3 what each got." A total can't say what any
    one of them walked away with, which is what the participant decided.
    - **New handoff fields, ported byte-for-byte from `task_pe-cu-nicewebrl`'s copy**:
      `order_link._ROW_ID_OK`, `encode_partner_rows()` ("<id>:<earned>:<lost>|..."),
      `partner_list_signature()`, `verify_partner_rows()`. `other_task_url()` gained
      `partner_rows=` → `pparts1=`/`ppsig=` (signed over `"partnerlist:<rows_str>"`), carried
      ALONGSIDE the existing `pbonus1=`/`plost1=`/`psig=` total, not instead of it, either
      side may be running a version that only knows the total.
    - **Ids are filtered through `_ROW_ID_OK` both before signing and after verifying** (same
      as their copy): a value that gets rendered on a screen is checked before it's rendered,
      not just HMAC-verified.
    - **This task sends one entry** (it has exactly one partner): `partner_rows=[{"id": f"your
      partner (#{partner})", "earned": to_money(partner_pts), "lost": 0.0}]`, built in
      `finish_experiment()`'s handoff call alongside the existing `partner_bonus_usd=`.
    - **The final screen now lists one line per person**: this task's own partner (known
      locally) plus `other_task_partner_rows` (verified on arrival) if the handoff carried
      one, in the order met, the other task's rows first, since reaching this branch
      (`not sona_first`) already means the other task ran first. Falls back to the old
      combined-total sentence (item 53) when no itemised list arrived, so an older deploy on
      either side still shows something rather than nothing.
    - **Verified against their actual file, not just this task's own round-trip**: imported
      `task_pe-cu-nicewebrl/order_link.py` directly and confirmed `encode_partner_rows()` and
      `partner_list_signature()` produce byte-identical output to this task's new copy for the
      same input, not merely "looks the same," actually checked. Also: `web_app`/`order_link`
      import cleanly; `test_payment.py`'s 21 tests pass; a tampered row amount is rejected.

56. **Item 55's `id` field carried a baked-in label, which doubled up once the receiving
    screen added its own wording (2026-10-14)**, `task-pe-cu-nicewebrl-f9` caught this: this
    task sent `id="your partner (#12345)"`, which `_ROW_ID_OK` reduces to `"your partner
    12345"` (parens and `#` aren't in the allowed set), and their screen then wrapped ITS OWN
    label around that, reading "YOUR PARTNER 1 (your partner 12345) earned...".
    - **Fix, both directions**: this task's `partner_rows` now sends the bare identifier
      (`str(partner)`, just the partner number) instead of a sentence, matches their own id
      format (`"P2-63540"`, also bare). `_row_line()` on the receiving side now adds "your
      partner **{id}**" wording around EITHER side's bare id. This task's own row (already
      bare now) and theirs, so a bare id renders correctly from either direction regardless
      of which side sent it.
    - **Verified**: `web_app` imports cleanly; `test_payment.py`'s 21 tests still pass.

57. **Third review list, the structural restructuring plus four smaller fixes
    (2026-10-14)**: "All belief questions about partners need to be at the end not just at
    the end of the harvest for both," one belief question and one 0-100 liking slider per
    partner, "before tripm," covering all three partners across both tasks, asked ONCE by
    whichever task finishes second, not per task. A single-task session asks the same thing
    about just its own partner.
    - **`order_link`'s partner-row format gained a 4th field, `kind`** (`"hunt"` for this
      task; `task_pe-cu-nicewebrl` sends `"day"`/`"night"`), the belief question's verb
      depends on it: earned-for partners are asked if they'd really RECEIVE it, loss-only
      partners (their night harvest) if they'd really LOSE it. `verify_partner_rows` accepts
      both the old 3-field format and the new 4-field one, so the two tasks' deploys can land
      in either order without either breaking.
    - **`_belief_page` (one partner, no kind-awareness) replaced entirely** by
      `_belief_multi_page(rows)` (one Yes/No per partner, verb picked by `_belief_verb`,
      falling back to comparing earned/lost when `kind` is empty) and
      `partner_checks_screen(container, rows)`, which runs belief then liking
      (`_slider_page`, reused as-is) for the given list and returns `belief_p#`/`liking_p#`
      plus `partner_order` (the raw ids, position traceable to person afterward). The old
      `belief_check_screen` (single-partner, item 53) is gone, superseded one turn after it
      was added.
    - **Deferral widened from "task_position == 2" to "in a combined study at all"**:
      `post_game_questionnaire_stage()` now defers whenever `task_position in (1, 2)`, not
      only 2, position 1 never consumes the flag locally (the participant leaves for the
      other task first), but the flag being set is harmless there and correct for position 2.
      A standalone/non-combined session (the flag never set) asks immediately, own partner
      only, via the same `partner_checks_screen` with a one-row list.
    - **`finish_experiment()`'s general-measures block now asks partner checks FIRST, before
      TriPM and demographics** (previously TriPM/demographics ran with belief deferred to
      AFTER them, item 53. This reverses that given the user's explicit order), built from
      `other_task_partner_rows + [own_row]` (own `kind="hunt"`), the other task ran first in
      this branch, so its rows lead.
    - **Three smaller items from the same list, same pass**:
      - *(3) No id-entry screen between the two task halves*: found a REAL bug while checking
        this, not assuming it was already fine. `run_intro()`'s pid-screen gate required BOTH
        `pid` and `role` to skip the experimenter setup screen, but `role` is only ever set in
        dyad mode, every non-dyad session (every SONA/combined-study run) left `role` unset
        forever, so this screen was showing on EVERY such session's first visit, handoff
        arrivals included. Fixed: role is now only required when `dyad_mode` is actually on.
      - *(4) Partner numbering at the match reveal*: a second-task participant's "Meet your
        partner" screen now says "This is your {ordinal} partner in the study, a new one"
        when the count is known (`other_task_partner_rows`'s length + 1); says nothing extra
        when it isn't, rather than guessing a number.
      - *(5) Quiz feedback states the answer, not just an explanation of it*: a wrong answer's
        feedback now opens with "**The statement is TRUE/FALSE.**" before the explanation
        text, so the question (already shown above, unchanged) and the stated answer are both
        plainly on screen, not just the question plus a paraphrase.
    - **Deliberately not done this pass** (scope triage, flagged rather than silently
      dropped): (1) practice house hard to find, (2) the "press any arrow key" toast wording,
      (6) TriPM's inconsistent above/left-aligned layout, (7) per-block points screens naming
      only that block's partner, (8) partner avatars on those screens. All four remain open.
    - **Verified**: `encode_partner_rows`/`verify_partner_rows` round-trip with `kind` and
      reject a tampered amount; the legacy 3-field format still verifies, reading `kind` as
      `""`; `_belief_verb` picks the right verb for `"night"`, for any other non-empty kind,
      and for the empty-kind earned/lost fallback; `web_app`/`questionnaires`/`order_link`/
      `experiment_structure` import cleanly; `test_payment.py`'s 21 tests pass.

58. **`desktop_gate()` was showing a click-through screen on every cross-task handoff arrival
    (2026-10-14)**, `task-pe-cu-nicewebrl-f9` played their own side end to end and found four
    defects, three of them generic bug shapes (a canvas/widget drawn one round trip after
    being placed, `str.capitalize()` mangling an id's casing, a markdown block defaulting to
    full width inside a flex row, bold nested inside an already-bold prompt showing literal
    asterisks) and asked me to check each shape and separately confirm this task shows nothing
    between their "Continue to Part 2" button and this task's own title screen, calling it "the
    one seam neither of us can see from our own end."
    - **None of the three generic shapes exist here, checked rather than assumed**: no
      `ui.canvas` anywhere (this task renders fully-composed PNGs server-side via
      `base64_npimage`, so there's no place-then-draw-later step to have the gap bug at all);
      no `str.capitalize()` anywhere in the codebase; every `ui.row()` was grepped for a
      co-located `ui.markdown()` + `ui.image()` and none combine the two (the one row that
      mixes an image with text, the partner-match reveal, uses `ui.html`, not `ui.markdown`);
      this task's slider/belief prompts never embed a partner id inside the bolded prompt
      text (they use "Partner N", not the id), so there's nothing to double-bold.
    - **The seam question surfaced a real bug**: `desktop_gate()` (the "make sure you're on a
      computer, click to enter fullscreen" screen) ran UNCONDITIONALLY at the top of
      `run_intro()`, with no check for whether this was a second-task arrival, so even after
      item 57's pid-screen fix, a handoff participant still hit this screen, requiring a click,
      before ever reaching the title screen. Fixed: skipped entirely (no screen, no click) on
      a genuine handoff arrival (`task_order_source == "handoff" and task_position == 2`),
      attempting fullscreen silently via the same JS call instead. Noted honestly, not papered
      over: a browser may decline a fullscreen request that isn't triggered by a direct click,
      so the second leg may end up playing not-fullscreen -- accepted trade for "nothing in
      between," which is what was actually asked for.
    - **Traced the full handoff path end to end to confirm nothing else remains**: consent
      (skipped, `task_first` gate), `desktop_gate` (skipped, this fix), `pid_screen` (skipped,
      item 57's role-gate fix), straight into the "welcome" title page. Nothing else sits
      between those three checks and the title screen in `run_intro()`.
    - **Verified**: `web_app` imports cleanly; `test_payment.py`'s 21 tests pass.

59. **Item 58's "attempt fullscreen silently" doesn't work, found by `task-pe-cu-nicewebrl-f9`
    asking their user directly whether the second leg was actually windowed (2026-10-14)**. It was, for everyone. Document fullscreen ends on navigation, and the new document can't
    re-enter it without a user gesture OF ITS OWN; the click on the other task's "Continue to
    Part 2" happened on a different document and doesn't count, so a `requestFullscreen()`
    call made on load with no click behind it is a rejected promise every time, caught and
    silently swallowed by the `except Exception: pass` that made it look like it might be
    working.
    - **Fix, same shape as theirs**: `desktop_gate()` no longer attempts fullscreen on load at
      all on a handoff arrival. It queues `app.storage.user["_pending_fullscreen"] = True`
      instead. The welcome page's Next button (`_intro_page`'s `go_next()`, "welcome" is
      always `INTRO_PAGES[0]`, so this fires once, on the actual first click) now checks and
      pops that flag and makes the fullscreen request from inside the click handler, a real
      user gesture, which browsers do honor.
    - **User's call, confirmed by both sessions so neither reopens it**: the device/fullscreen
      check stays on the first task only; they said windowed would have been acceptable, but
      this fix means it shouldn't come to that in practice.
    - **Verified**: `web_app` imports cleanly; `test_payment.py`'s 21 tests pass.

## 7. In progress / open items
- **Is a pilot actually ready to go out? NOT YET, item 48 found a real handoff bug the
  first actual live two-task playthrough surfaced.** The SONA study listing exists (item 43)
  with the correct Study URL, credit-granting wired via `SONA_RETURN_URL`, and a valid timeslot, but is still `Inactive`/`Not Approved`, deliberately held by the user until everything else
  is confirmed ready (not an oversight). Payment: item 44's store was built then withdrawn
  (item 45) for not matching the approved protocol; the replacement (item 46, extended item 47)
  is built and deployed on both tasks, do not revive `SONA_PAYMENT_HASH_KEY`/`payment_log.csv`,
  that design is permanently superseded, not just on hold. But item 48 means the pilot is NOT
  actually ready despite everything above looking done: roughly half of participants (whoever's
  first task is `pe`) would currently be bounced in a loop between the two tasks instead of ever
  completing their second one. What's actually left: (1) this task's fix (item 48) needs a live
  re-test to confirm it resolves the bounce-back, not just code tracing; (2) `task_pe-cu-
  nicewebrl`'s mirror symptom (consent reappearing) needs its own root-cause fix, not yet found;
  (3) the stale test rows both sessions' live testing has left in `bear-sona/task_order_log.csv`
  need clearing (same browser-automation permission gate as before, left for the user); (4) the
  updated filed consent docx (item 47) isn't yet submitted to the IRB; (5) the user's own review
  + IRB-admin approval request to flip the SONA listing `Active`. Both tasks' entry-redirect
  gaps were previously described as fixed, hardened, and behaviorally confirmed clean in BOTH
  directions against the real live production Spaces (not just locally), verified via a
  curl-checkable `/health` self-check (item 40) on both
  sides, which also caught and got a fix for a real security gap (item 41: this task's session
  cookies were being signed with a publicly-visible default string). **Pre-pilot checklist,
  going forward for any secret rotation: after changing/adding a Space secret, `curl
  .../health` on the affected Space(s) rather than trusting a browser-driven check, item 40's
  whole reason for existing was that browser-based verification of deployed secrets proved
  unreliable for both sessions in different ways.**
- **Deploy status (2026-09-28): items 1-35, 37-44 pushed to `origin`/`hf`; item 36 landed as
  part of that same history**, see the commit history for exactly what's landed by the time you
  read this.
  `SONA_GITLAB_PROJECT`/`SONA_GITLAB_TOKEN`/`OTHER_TASK_BASE_URL`/`SONA_PID_HASH_KEY` are
  set as HF Space secrets on BOTH live Spaces (not just local `.env`), so the combined flow
  is live in production on this task's side. `SONA_PAYMENT_HASH_KEY` (item 44) is NOT yet set
  as a Space secret on either side, until it is, `submit_payment` logs loudly and the payment
  screen's answers are simply not saved (see item 44; nothing crashes, but real submissions
  would be silently lost, so set this before real participants reach the payment screen). Every
  piece still degrades independently rather than breaking if a secret were ever removed:
  `OTHER_TASK_BASE_URL` unset -> no next-task link shown (this task behaves exactly as it did
  before this feature existed); `SONA_PID_HASH_KEY` unset -> pid falls back to the raw code
  with a loud warning (NOT safe for real data collection); `SONA_GITLAB_PROJECT` unset -> task
  order falls back to the local hash (works, just only approximately balanced), recorded as
  such via `task_order_source`.
- **`princessamygdala/bear-sona` (item 37) exists**, private, on `gitlab.com`, holding the
  task-order allocation log (now keyed on the pseudonym, item 44) and the payment store
  (`payment_log.csv`, item 44).
- **Input-drop limitation (item 33) is unresolved and out of this repo's control**, flagging
  for awareness, not a to-do: if it becomes a real problem in the lab, the options are asking kids
  to pace their presses, or forking/patching the vendored `nicewebrl` package (bigger undertaking,
  affects the whole framework, not attempted here).
- **SONA payment-collection screen + separate payment store**: built, item 44.
- **New `sona` GitLab repo**: for the combined RL notebooks below (the allocation record and the
  combined RL notebooks below. Not created, needs the user (or an already-authorized token) to
  create the empty project; this session's GitLab helper only pushes to an EXISTING project.
- **RL model-fitting/recovery notebooks matching the `PSL2025_HP` reference**
  (`modeling/release_rlhp_.../` there: `environment.yml`, `code/01_model_fitting.ipynb`,
  `02_model_comparison.ipynb`, `03_model_identifiability.ipynb`, `rl_hp.py`, `data/`, `pyem/`,
  `results/`, `README.md`). This task already has its own `rl_hp.py`/`rl_hp.ipynb`
  (item 14/pre-existing) implementing the model family, but recovery has not been run against
  this task's actual design (also noted under item 35's "Decisions still open"). Not started.
- Prior "within-house redesign" (Splits A–C, item 22 and earlier) is complete; no known open
  items from that work.

---

## 20 October 2026, changes made from the other task's session

Written here because the session that was working in this repository ended
before these landed, and whoever picks it up next needs to know what moved.
Everything below is committed, pushed to GitHub, and deployed.

**The work already in the working tree was committed.** Six files sat modified
and unpushed: the partner-face route, the avatar index on the handoff row, the
BEAR ID field, the group-9 fallback in `orders.parse_pid`, the `next_id.py`
group filter, and the GitLab push fix. None of it had reached the Space, so
the deployed build was serving 404s for every partner face while the code to
serve them sat on disk.

**The GitLab push fix is the one that was losing data.** A commit is atomic,
and a session pushes its msgpack and CSV every couple of minutes while writing
its metadata JSON only at the end. One "create" list was refused for the two
files that already existed and one "update" list for the one that did not, so
the final push of every session was discarded silently, and that is the push
carrying the post-task questionnaires. Each file's verb now comes from its own
state, with a per-file retry.

**The belief question wording was fixed to match the other task's.** It named
every partner's game "that game", which on a page listing three or four people
from two games leaves the participant guessing, and it asked the night-harvest
partner whether they would "receive the credits you earned for them" when that
partner could only ever lose credits. See `_WHERE_BY_KIND` and
`_belief_question` in `questionnaires.py`.

**Partner faces go through one frame.** This task draws a whole standing
explorer occupying about a third of the width of its square render, and the
other task draws a head-and-shoulders portrait that fills its frame. Side by
side they read as two people of very different sizes. `sprites
.draw_partner_avatar_framed` crops to what is drawn and centers it in 144x176,
and all three callers use it: the `/static/partner_face_<idx>.png` route, the
deferred end-of-study screen, and the standalone session's own row. The
matching reveal keeps the raw render, since nothing sits beside it there.

**New tests.** `test_partner_checks.py`, 11 of them, covering the wording, the
framing, the face route and the handoff round trip. Run the suite with
`./.venv/bin/python -m pytest -q test_partner_checks.py test_health.py
test_payment.py`, which needs `uv pip install pytest -p .venv/bin/python`
once. 43 pass.

### Two things about this repository that cost an hour to work out

**This checkout is the live one**, despite living in a folder called `not in
use currently`. It holds the `hf` and GitHub remotes. The checkout named
`task_sl-cu-nicewebrl-16trials` is a stale orphan: its `origin` points at a
path that is no longer a git repository, it has no `hf` remote, and it has no
`order_link.py`, so none of the handoff work is in it. Both set
`N_TRIALS = 16`, so the trial count cannot tell them apart.

**The Space's history is a separate line from GitHub's**, differing only by
two docx files. `git push hf main` is rejected as a non-fast-forward. Deploy by
cherry-picking onto the local `hf-deploy` branch, which tracks the Space:

    git push origin main
    git checkout hf-deploy && git cherry-pick <sha>
    git push hf hf-deploy:main && git checkout main

### A bug this exposed in the other task, now fixed there

A participant allocated to this task first touches the other app twice: once on
the advertised SONA link, which resolves the order and bounces them here, and
once at the end, when this task hands back. That return is the only request
that ever carries `bonus1`, `pbonus1`/`plost1` and `pparts1`, and over there
all of it sat inside `"task_first" not in storage`, false on exactly that
request. For half the sample this task's bonus was dropped from the combined
total and its partner went unnamed on the final screens. This repository
already had the right shape: it reads the payload whenever a verifiable handoff
arrives and only resolves the order when none does.

Both directions were then walked end to end on the live Spaces and both work.
The procedure is written up in the other repository at
`docs/TESTING_THE_HANDOFF.md`, along with `test_handoff_contract.py`, which
runs each app's copy of `order_link.py` against the other's in both directions.
Run that test after any change to this file's copy.

---

## 2 November 2026, participant ID codes were public, and the check that missed it

### What was exposed

Five SONA participant ID codes were committed to this repository and to
`task_pe-cu-nicewebrl`, both of which are served publicly as Hugging Face Spaces and both
of which are public on GitHub. They sat in test fixtures and in the incident comments that
explain why three patches exist.

| repo | file | how it appeared |
|---|---|---|
| sl-cu | `savequeue_fix.py`, `test_savequeue_fix.py`, `test_reload_freeze.py` | named in the docstring explaining who the patch was written for |
| sl-cu | `test_partner_checks.py` | a fixture value passed to the handoff signing helper |
| sl-cu | `PROJECT_LOG.md` | six mentions in the October entries |
| pe-cu | `effort_stages.py`, `test_calibration_timeout.py` | named in a comment explaining a timeout bound |
| pe-cu | `test_handoff_contract.py`, `test_sona_url.py` | fixture values |
| pe-cu | `docs/SESSION_LOG.md`, `docs/TESTING_THE_HANDOFF.md` | worked examples |

### How bad, measured rather than assumed

The first write-up of this entry called it an exposure that "maps a published pseudonym
back to a named person". That overstated it, and the measurement is worth keeping.

What is actually public: the two Hugging Face Spaces, which serve their source to anyone.
Both GitHub repositories are **private**. All four GitLab data projects are **private**,
anonymous read returns 404. So no participant data is public, and no pseudonym is public
either.

Turning a SONA code into a person needs a login to Georgetown's SONA. That audience is
Georgetown SONA users, not the public. What such a reader learns, from the worst of these,
is the Hunt's own commit message: that a particular student did this study and hit a bug
that cost them their session. No responses, no scores, no data.

That is a minor confidentiality slip. It is not a breach, and the entry should not have
been written as though it were.

### What was done

Replaced with `99xxx` stand-ins, which is outside any SONA range, so a fixture can never
collide with a real participant. The prose now says "a participant" and points at the Box
admin folder for who.

`test_no_participant_codes.py`, in both repos, reads `~/bin/bear_sona/codes.json`, which is
in no repository, and fails if any of its codes appears in a tracked file. A second test
checks the other direction: every five-digit code a fixture hands the signing or URL
helpers has to be one no participant holds. Both skip where the roster is absent, so a
checkout elsewhere still runs green.

### The history: decided, 2 November, not to rewrite it

The codes remain in the two Spaces' git history, and three commit MESSAGES name a
participant outright (one here, two in pe-cu). A message cannot be edited; reaching it
means rebuilding the commit and force-pushing over a live Space's history.

**Decision: no force push.** Weighed against what the exposure actually is, the fix carries
more risk than the thing it fixes: a rewrite of a running Space mid-study can leave it
unable to rebuild, which takes the study down. The deploy ships the cleaned files, which
removes the codes from everything a reader would land on, and the three old messages stay.

Revisit only if the study's own records ever become public, which would change the
audience from "Georgetown SONA users" to "anyone".

### The check that missed it, which is the part worth keeping

The first scan for this used `git grep -lE "<codes>" origin/main -- '*.py' '*.md'` and came
back empty on both remotes. On that basis the finding was reported as "the codes are not on
origin or hf, nothing leaked". That was wrong. Reading the same files directly with
`git show origin/main:savequeue_fix.py | grep -c` found them immediately.

The lesson is not about `git grep`'s argument order. It is that a negative result from a
search was treated as evidence of absence without a positive control. A grep that finds
nothing looks identical whether the thing is absent or the query is malformed, which is the
same failure mode as the jammed-text one in the review skill and the same one that let the
throttled data mirror report success while writing a third of the files.

**Rule:** before reporting that a search found nothing, run it against a case where it must
succeed. Here that was one line: grep the working tree, which was known to contain the
codes, with the identical command.

## 9 November 2026, a parent and child met the same stranger

The first real BEAR family played on 7 November: two children and their parent, three
complete sessions. Reading the data back showed the parent (pid 2002, rando 105) and the
first child (pid 2002, rando 2) had both been matched to partner **#4846**, with the same
avatar, in the same house, an hour apart.

`orders.partner_id_for(pid)` seeded off the pid alone. A parent plays under their first
child's pid on purpose, so the family keeps one row in the link sheet, which made the
collision certain for every family rather than unlucky for this one. All three answered
"No" when asked whether their partner would really receive the coins they earned.

`rando` is unique per session by construction, so `partner_id_for` and `partner_avatar_for`
now take `role` and `rando` and pass them to `_seed`, which already knew how to use them.
With no `rando` the seed is untouched, so every SONA and lab session keeps the partner it
was shown. Across all 103 dyads in the pool, no parent and child now share a partner code.

Four avatar looks means two people in one household still draw the same face about a
quarter of the time. That is the rate any two unrelated participants draw it, and their
partner codes differ, so it reads as coincidence instead of a repeat.

### What the fix would have broken on its own

`export_csv.py` re-derived `partner_id` from the pid every time it ran. That was harmless
while the number was a function of the pid. After this change, re-exporting any of the
three sessions already collected would have printed a stranger that participant never met,
silently, with no error.

So the match reveal now logs a `partner` event carrying the code and avatar it showed, and
the export prefers it. A session with no such event predates 9 November and was seeded off
the pid, so the old derivation is exactly right for it and stays as the fallback.
`test_export_partner.py` covers both directions and was checked against the pre-change
file, where it fails with `assert '4846' == '9501'`.

## 9 November 2026, the modeling could not be run at all

Asked to fit the first BEAR family, three things stopped it before any model ran.

`rl_hp.py` opens `from ..utils.math import ...`. That resolves only inside the pyem
package, as `pyem/models/rl_hp.py`, and the file is not installed there: the only copy is
this one, in the repo. So `import rl_hp` was an ImportError and nothing in the file could
be reached without first copying it into site-packages. Now an absolute
`from pyem.utils.math import ...`, which works from both places.

`pyem_data.to_all_data` returned a dict per subject. pyEM calls `objfunc(x, *all_data[i])`,
so a dict unpacks to its KEYS: every fit received the four strings "choices",
"outcomes_self", "outcomes_other", "option_pairs" in place of its arrays and died inside
joblib with `int() argument must be ... not NoneType`, from vectorizing a letter lookup
over the characters of the word "choices". It returns a tuple in FIT_KEYS order now, which
is the fit functions' parameter order after `params`; a test asserts those two agree by
reading the signature.

`fit_bear.py` is the driver: it pulls `bear/` from the data repo, loads the sessions and
fits rw2q1a1b, rw2q2a1b and rw2q2a2b. It says out loud when there are fewer than fifteen
sessions, because pyEM estimates the group prior from the subjects it is given and three
of them produce a prior made of themselves. On this family rw2q1a1b returned beta 1.385,
1.383, 1.384 across three different people, which is that collapse and not a finding.

### 14 of the 24 functions in rl_hp.py are defined twice

Lines 855-2800 hold the seven two-Q models, `_sim` and `_fit` each. Lines 2802 to the end
hold the same seven in the same order, with character-identical banners. Python keeps the
later definition. Checked on real data over 20 random parameter draws per model: NLL and
every shared numeric output agree exactly, so no result depends on which copy runs.

One thing does differ. The first copy of the two-alpha models also returns `pe_self_pos`,
`pe_self_neg`, `pe_other_pos` and `pe_other_neg`; the second drops them, so those arrays
are currently unreachable. The four-alpha models, where the sign split is the model rather
than a diagnostic, keep them in both copies. Not resolved here: deleting the second block
is a call for whoever owns the modeling.


## 9 November 2026, what targetIndex actually is

Recorded because I got it wrong out loud first. Asked whether the web task records what
the PsychoPy task did, I reported that `targetIndex` indexes position within the
beneficiary stream, 0-9 for the ten self trials and ten other trials of a 20-trial block.
That was a guess dressed as a finding, and testing it is one line: build the running count
within (blockIndex, displayedtarget) and compare. It does not match.

What it is: side. Across 7,200 rows of 30 order files, with no exceptions, `targetIndex`
under 5 means the pair's FIRST letter sits on the left and 5 or over means its SECOND
does. The remainder mod 5 is a repetition index, each of the five used 1,440 times. Two
levels of side crossed with five repetitions is the ten cells.

Still not added here, now for the right reason. Side is recorded directly as
`option_left`, `option_right` and `chosen_side`, and the repetition index falls out of
`trialIndex` within a block, so the column would carry nothing new.

## 9 November 2026, side is recorded three ways and counterbalanced none

Asked whether the stimulus side is recorded, since targetIndex turned out to encode it.

It is, three times over. `option_left` and `option_right` give the letter on each side,
`left_stim` and `right_stim` give the chest image, and `chosen_side` with `chosen_option`
gives which one was taken. Checked across 2,179 trials of 13 sessions, three BEAR and ten
SONA: `chosen_option` equals the letter on `chosen_side` on every single one.

What targetIndex also did, and nothing here does, is ENFORCE a side balance. In the
PsychoPy order files every 20-trial block is exactly 10 trials with the pair's first
letter on the left and 10 with its second. Here `orders.py:337` draws it:

    side_schedule = rng.integers(0, 2, size=(N_PLACES, N_TRIALS))

Over 132 blocks of real sessions that gives a median 9 of 16 on the commoner side, a
worst block of 13 of 16, and exactly 8/8 in 16% of blocks. It is the only part of the
design drawn this way. Four lines down, `outcomes` is built by `_exact_sequence` with
exactly 12/2/2 per block, and `float_order` is "6 you-first + 6 partner-first,
counterbalanced". Side is the one that got a coin flip.

Changed the same day, on Marla's call, for both arms: each block is now eight and eight,
shuffled, matching the PsychoPy scheme. Over the whole pool that is 2,472 blocks, every
one exactly 8/8, across 2,253 distinct sequences, and it holds for pid-only SONA designs
as well as pool entries.

The trap in making that change: everything after `side_schedule` in make_order is drawn
from the same rng in order, so deleting its 192-value draw moved the outcomes, the float
order, the house types and the house positions of every participant. export_csv
re-derives house positions from make_order for sessions already collected, so a re-export
would have stopped matching what was played. The old draw therefore still runs and its
result is discarded, purely to leave the stream where the rest of the function expects
it, and the schedule itself comes from its own stream. test_side_balance.py fingerprints
nine other quantities for the four designs the first family played plus two pid-only
ones, and those fingerprints were taken before the change and still hold after it.

What this does mean: the first family played under the coin-flip scheme and everyone
after them plays under the counterbalanced one. Their own per-trial sides are recorded,
so their data stays readable.

The outcome has its own side, the YOU and PARTNER panels, observed fixed at YOU on the
left through a full live block. `float_order` counterbalances which coin floats in first,
which is temporal and already recorded per block.