Repository navigation
Expand file tree
/
Copy pathcrossings.py
More file actions
164 lines (149 loc) · 8.43 KB
/
Copy pathcrossings.py
File metadata and controls
164 lines (149 loc) · 8.43 KB
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
#!/usr/bin/env python3
"""crossings.py: a record format for level transitions, and a checker for it.
Teaching example for "After Chat" (Appendix C, listing C5). MIT licence. A research instrument, not
an application: it defines what a record of one person's attempt at one transition must contain, and
refuses records that would let an installation be counted as use.
The rules follow the measures published in the preregistration the paper describes (OSF, DOI
10.17605/OSF.IO/X4EGQ): a transition counts as crossed only when an artefact produced by the agent is
supplied; installing is an attempt; assisted and unaided crossings are kept apart; a stop is recorded
with the point where it happened and the person's own words. The record format is also published as
a JSON Schema (crossings.schema.json); this checker accepts exactly what the schema accepts and adds
the rules a schema cannot state.
What the checker enforces for a level-4 crossing: at least two tools named as asked and as answered.
What it leaves to the researcher: that the tools are different model families, and that the
arrangement was rerun in a later week (a second record).
Usage:
python3 crossings.py records.jsonl # one JSON object per line
python3 crossings.py --demo
"""
import datetime
import json
import re
import sys
LEVELS = ("chat", "safe_agentic_environment", "agent_on_own_computer", "orchestrated_work")
ARTEFACTS = ("file", "folder", "screenshot", "pasted_output", "none")
DECISIONS = ("accept", "revise", "escalate", "discard")
REQUIRED = ("record_id", "person", "level_from", "level_to", "materials_sent", "completed", "assisted")
# Every key a record may carry; the same set as the properties of crossings.schema.json.
ALLOWED = REQUIRED + ("skipped", "intervention", "artefact", "stop_point", "stop_reason_own_words",
"stop_reason_code", "multi_model", "interface_version", "operating_system",
"network_access", "permission_mode", "policy_constraint", "acceptance_decision")
PERSON = re.compile(r"^P[0-9]+$")
def parse_date(value):
try:
return datetime.date.fromisoformat(value)
except (TypeError, ValueError):
return None
def check(rec):
problems = []
if not isinstance(rec, dict):
return ["record must be a JSON object"]
for key in REQUIRED:
if key not in rec:
problems.append(f"missing field '{key}'")
unknown = sorted(set(rec) - set(ALLOWED))
if unknown:
problems.append("unknown fields (the schema forbids them): " + ", ".join(unknown))
if problems:
return problems
if not isinstance(rec["person"], str) or not PERSON.match(rec["person"]):
problems.append("person must be a pseudonymous label such as P07, never a name")
for key in ("completed", "assisted"):
if not isinstance(rec[key], bool):
problems.append(f"{key} must be true or false, not {rec[key]!r}")
if rec["level_from"] not in LEVELS or rec["level_to"] not in LEVELS:
problems.append("level must be one of " + ", ".join(LEVELS))
else:
i_from, i_to = LEVELS.index(rec["level_from"]), LEVELS.index(rec["level_to"])
if i_to <= i_from:
problems.append("level_to must be above level_from")
else:
# Levels are ordered, not compulsory: a route may go from chat straight to an agent on the
# person's own computer. A skip is allowed, but it is recorded, never silent, and exactly.
expected = list(LEVELS[i_from + 1:i_to])
if expected and rec.get("skipped") != expected:
problems.append("a move over more than one level must list exactly the levels it "
"skipped in 'skipped': " + ", ".join(expected))
if not expected and rec.get("skipped"):
problems.append("'skipped' must be empty or absent for a move of one level")
sent = parse_date(rec["materials_sent"])
if sent is None:
problems.append("materials_sent must be an ISO date (YYYY-MM-DD)")
art = rec.get("artefact", {"type": "none"})
if not isinstance(art, dict) or art.get("type") not in ARTEFACTS:
problems.append("artefact.type must be one of " + ", ".join(ARTEFACTS))
art = {"type": "none"}
if "produced_by_agent" in art and not isinstance(art["produced_by_agent"], bool):
problems.append("artefact.produced_by_agent must be true or false")
if "date" in art:
art_date = parse_date(art["date"])
if art_date is None:
problems.append("artefact.date must be an ISO date (YYYY-MM-DD)")
elif sent and art_date < sent:
problems.append("artefact dated before the materials were sent")
if rec["completed"] is True:
# Installation is an attempt; only something the agent produced counts as a crossing.
if art.get("type") == "none" or art.get("produced_by_agent") is not True:
problems.append("completed=true needs an artefact with produced_by_agent=true")
if rec["level_to"] == "orchestrated_work":
mm = rec.get("multi_model") or {}
asked = mm.get("asked") if isinstance(mm, dict) else None
answered = mm.get("answered") if isinstance(mm, dict) else None
if not isinstance(asked, list) or len(set(asked)) < 2 or \
not isinstance(answered, list) or len(set(answered)) < 2:
problems.append("a level-4 crossing needs multi_model.asked and multi_model.answered "
"with at least two tools each (Table 1: two model families)")
elif rec["completed"] is False:
if not rec.get("stop_point") or not rec.get("stop_reason_own_words"):
problems.append("a non-completion records stop_point and stop_reason_own_words")
if rec["assisted"] is True and not rec.get("intervention"):
problems.append("assisted=true needs a description of the intervention")
if "acceptance_decision" in rec and rec["acceptance_decision"] not in DECISIONS:
problems.append("acceptance_decision must be one of " + ", ".join(DECISIONS))
if "network_access" in rec and not isinstance(rec["network_access"], bool):
problems.append("network_access must be true or false")
return problems
DEMO = [
{"record_id": "r1", "person": "P01", "level_from": "chat", "level_to": "safe_agentic_environment",
"materials_sent": "2026-09-08", "completed": True, "assisted": False,
"artefact": {"type": "folder", "date": "2026-09-09", "produced_by_agent": True}},
{"record_id": "r2", "person": "P02", "level_from": "chat", "level_to": "safe_agentic_environment",
"materials_sent": "2026-09-08", "completed": True, "assisted": False,
"artefact": {"type": "screenshot", "produced_by_agent": False}},
{"record_id": "r3", "person": "P03", "level_from": "chat", "level_to": "agent_on_own_computer",
"skipped": ["safe_agentic_environment"], "materials_sent": "2026-09-08", "completed": False,
"assisted": False, "stop_point": "(invented) download page",
"stop_reason_own_words": "(invented) the page offered four versions and I did not know which"},
{"record_id": "r4", "person": "Jane", "level_from": "chat", "level_to": "orchestrated_work",
"materials_sent": "2026-09-08", "completed": False, "assisted": True},
]
def main():
if len(sys.argv) > 1 and sys.argv[1] != "--demo":
records = []
for n, line in enumerate(open(sys.argv[1]), 1):
if line.strip():
try:
records.append(json.loads(line))
except json.JSONDecodeError as exc:
records.append({"_malformed": f"line {n}: {exc}"})
else:
records = DEMO
print("(demo: four invented records, two of them deliberately wrong)\n")
bad = 0
for rec in records:
try:
if isinstance(rec, dict) and "_malformed" in rec:
problems = ["not valid JSON: " + rec["_malformed"]]
else:
problems = check(rec)
except Exception as exc: # a malformed record is rejected, never a crash
problems = [f"malformed record: {exc!r}"]
bad += bool(problems)
rid = rec.get("record_id", "?") if isinstance(rec, dict) else "?"
print(f"{str(rid):6s} {'OK' if not problems else 'REJECTED'}")
for p in problems:
print(f" - {p}")
print(f"\n{len(records) - bad} of {len(records)} records accepted")
sys.exit(1 if bad else 0)
if __name__ == "__main__":
main()