Download sample/tasks/inspect/prompt.py from zero-trust-physics/zero-trust-physics-sample-group-5: direct link, hf CLI and curl.
- Browser
- Download file 13.7 kB
-
https://huggingface.co/datasets/zero-trust-physics/zero-trust-physics-sample-group-5/resolve/main/sample/tasks/inspect/prompt.py
- Command line
-
hf download hf://datasets/zero-trust-physics/zero-trust-physics-sample-group-5/sample/tasks/inspect/prompt.py
-
curl -L -o prompt.py https://huggingface.co/datasets/zero-trust-physics/zero-trust-physics-sample-group-5/resolve/main/sample/tasks/inspect/prompt.py
13.7 kB
| """Print exactly the text an agent is given for one environment: the task, then its family's footer. | |
| python3 prompt.py --environments F ENVIRONMENT_ID the text for one environment | |
| python3 prompt.py --environments F --list every environment id, one a line | |
| python3 prompt.py --environments F --all FOLDER write FOLDER/<id>.txt for every environment | |
| Any runner for any model gives the agent this text and nothing else, with the verifier as its | |
| tool server. | |
| Licence: Apache-2.0. | |
| """ | |
| import json | |
| import os | |
| import sys | |
| HERE = os.path.dirname(os.path.abspath(__file__)) | |
| COMMON = """You have one tool server, the verifier. Answer from what its tools give you and from nothing else. Every number you are judged on is computed again from the requests on your card. | |
| End your reply with your answer card: one JSON object on its own last line, with no code fence and nothing after it. A request on the card is {"tool": "<the tool's name as the verifier names it, without any prefix your own program adds>", "arguments": {<the arguments exactly as you sent them>}}, and a proof is the run_seal or solution_seal the verifier gave for that request.""" | |
| FOOTERS = { | |
| "tradeoff": COMMON + """ | |
| The card: | |
| {"passing": {"run": {"request": ..., "proof": ...}, "solve": {"request": ..., "proof": ...}}, "failing": {"run": {"request": ..., "proof": ...}, "solve": {"request": ..., "proof": ...}}, "binding": "<constraint id>"} | |
| passing: the design that keeps every constraint, nearest the boundary you were asked for. failing: the design just past it, which breaks at least one constraint, no further from passing than the task's tolerance. binding: the id of the constraint that the failing design breaks and that sets the boundary. Leave out "solve" when the task has no solve. A solve is the one handed its own design's sealed run through the coupling the task names.""", | |
| "chain_design": COMMON + """ | |
| The card: | |
| {"passing": {"run": {"request": ..., "proof": ...}, "solve": {"request": ..., "proof": ...}}, "failing": {"run": {"request": ..., "proof": ...}, "solve": {"request": ..., "proof": ...}}, "binding": "<constraint id>"} | |
| passing: the design that keeps the constraint, nearest the boundary you were asked for. failing: the design just past it, which breaks the constraint, no further from passing than the task's tolerance. binding: the id of the constraint. Each solve is the one handed its own design's sealed run through the coupling the task names.""", | |
| "budget": COMMON + """ | |
| The card: | |
| {"holds": {"request": ..., "proof": ...}, "stops": {"request": ..., "proof": ..., "stopped": "<the stop's name exactly as the verifier gives it>"}} | |
| holds: a request, the task's request with only the open input set, whose run completes. stops: the same request with another value of that input, whose run stops with the stop the task names. The two values are no further apart than the task's width, and both requests are among the calls you made. Your calls are counted: the budget is in the task, and the tools it rules out may not be called at all.""", | |
| "forensics": COMMON + """ | |
| The card: | |
| {"false_rows": {"<row>": "<reason>", ...}} | |
| Name every false row, each with its one reason from value_altered, seal_wrong, flag_omitted, retired_model, stop_hidden. Leave the genuine rows out. {"false_rows": {}} says every row is genuine.""", | |
| } | |
| def load_environments(path): | |
| with open(path, encoding="utf-8") as f: | |
| return [json.loads(line) for line in f if line.strip()] | |
| STOP_BINDS = """ Where one constraint is that the run completes (it names a stop) and that constraint binds, binding is its id and the failing design also carries "stopped": the stop's name exactly as the verifier gives it, and "step": the last step its run is sealed to (steps_landed), a whole number: {"run": {...}, "stopped": "<name>", "step": <steps_landed>}.""" | |
| # The design shapes of the 29 Oct 2026 groups, each footer as its group built it (score.design_shape). | |
| CONTINUED_CARRIED = COMMON + """ | |
| The card: | |
| {"passing": {"run": {"request": ..., "proof": ...}, "next": {"request": ..., "proof": ...}}, "failing": {"run": {"request": ..., "proof": ...}, "next": {"request": ..., "proof": ...}}, "binding": "<constraint id>"} | |
| passing: the design that keeps every constraint, nearest the boundary you were asked for. failing: the design just past it, which breaks at least one constraint, no further from passing than the task's tolerance. binding: the id of the constraint that the failing design breaks and that sets the boundary. Each design is two runs: "run" is the first run, and "next" is the run that continues that same sealed run, with "from": {"request": <the first run's request>, "run_seal": <its proof>} and its initial state equal to the first run's final_state, value for value, bit for bit.""" | |
| CONTINUED_HANDED = COMMON + """ | |
| The card: | |
| {"passing": {"run": {"request": ..., "proof": ...}, "next": {"request": ..., "proof": ...}}, "failing": {"run": {"request": ..., "proof": ...}, "next": {"request": ..., "proof": ...}}, "binding": "<constraint id>"} | |
| passing: the design that keeps every constraint, nearest the boundary you were asked for. failing: the design just past it, which breaks at least one constraint, no further from passing than the task's tolerance. binding: the id of the constraint that the failing design breaks and that sets the boundary. run is the design's first run; next is the run that continues that same sealed run through from: its from holds the first run's request and run_seal, and its start fields are the first run's final state exactly as the verifier returned it.""" | |
| CONTINUED_CARRY = COMMON + """ | |
| The card: | |
| {"passing": {"run": {"request": ..., "proof": ...}, "next": {"request": ..., "proof": ...}}, "failing": {"run": {"request": ..., "proof": ...}, "next": {"request": ..., "proof": ...}}, "binding": "<constraint id>"} | |
| Each design is two runs: run, and next, which continues that design's own sealed run through from (from.request is the run's request, from.run_seal its proof) and starts from its final state. passing: the design that keeps every constraint, nearest the boundary you were asked for. failing: the design just past it, which breaks at least one constraint, no further from passing than the task's tolerance. binding: the id of the constraint that the failing design breaks and that sets the boundary.""" | |
| SOLVE_DESIGN = COMMON + """ | |
| The card: | |
| {"passing": {"solve": {"request": ..., "proof": ...}}, "failing": {"solve": {"request": ..., "proof": ...}}, "binding": "<constraint id>"} | |
| passing: the design that keeps every constraint, nearest the boundary you were asked for. failing: the design just past it, which breaks at least one constraint, no further from passing than the task's tolerance. binding: the id of the constraint that the failing design breaks and that sets the boundary. Each design is one solve and no run.""" | |
| SOLVE_ONLY = COMMON + """ | |
| The card: | |
| {"passing": {"solve": {"request": ..., "proof": ...}}, "failing": {"solve": {"request": ..., "proof": ...}}, "binding": "<constraint id>"} | |
| Each design is one solve: leave out "run". passing: the design that keeps every constraint, nearest the boundary you were asked for. failing: the design just past it, which breaks at least one constraint, no further from passing than the task's tolerance. binding: the id of the constraint that the failing design breaks and that sets the boundary.""" | |
| STAGED = COMMON + """ | |
| The card: | |
| {"passing": {%s}, "failing": {%s}, "binding": "<constraint id>"} | |
| Each design is the requests the task names, one entry each, under the names the task gives them (%s), each with the proof the verifier gave for it. passing: the design that keeps every constraint, nearest the boundary you were asked for. failing: the design just past it, which breaks at least one constraint, no further from passing than the task's tolerance. binding: the id of the constraint that the failing design breaks and that sets the boundary. A later request that carries an earlier one's answer carries it bit for bit, from that design's own answer.""" | |
| STAGED_STOP = """ Where one constraint is that a request is not stopped by a named stop and that constraint binds, binding is its id and the failing design also carries "stopped": the stop's name exactly as the verifier gives it%s.""" | |
| STOP_BINDS_SOLVE = """ Where one constraint is that the solve is not refused by a named stop and that constraint binds, binding is its id and the failing design also carries "stopped": the stop's name exactly as the verifier gives it: {"solve": {...}, "stopped": "<name>"}.""" | |
| SOLVE_STOP_G4 = """ Where one constraint is that the solve converges (it names a refusal) and that constraint binds, binding is its id and the failing design also carries "stopped": the refusal's name exactly as the verifier gives it: {"solve": {...}, "stopped": "<name>"}.""" | |
| CARRY_STOP_G5 = (" Where one constraint is that the second run completes (it names a stop) and that constraint binds, binding is its id and the failing design also carries" | |
| " \"stopped\": the stop's name exactly as the verifier gives it, and \"step\": the last step the second run (next) is sealed to (its steps_landed), a whole number:" | |
| " {\"run\": {...}, \"next\": {...}, \"stopped\": \"<name>\", \"step\": <steps_landed>}.") | |
| BUDGET_WORDS = " Your calls are counted: the budget is in the task, and the tools it rules out may not be called at all." | |
| def shaped_footer(environment): | |
| """The footer of a design of one of the added shapes, or None for a run or a coupled solve (FOOTERS).""" | |
| family = environment["family"] | |
| check = environment.get("check") or {} | |
| design = check.get("design") or {} | |
| if family not in ("tradeoff", "chain_design"): | |
| return None | |
| chain = design.get("chain") or {} | |
| stops = [c for c in check.get("constraints") or [] if c.get("on") == "outcome"] | |
| if design.get("stages"): # group 3 | |
| stages = design["stages"] | |
| shape = ", ".join('"%s": {"request": ..., "proof": ...}' % st["key"] for st in stages) | |
| footer = STAGED % (shape, shape, ", ".join(st["key"] for st in stages)) | |
| if stops: | |
| runs = any(st["key"] == c.get("stage") and st["tool"] == "run_trajectory" for c in stops for st in stages) | |
| footer += STAGED_STOP % (', and, for a run, "step": the last step its run is sealed to (steps_landed), a whole number' if runs else "") | |
| elif design.get("tool") == "solve": # group 4 | |
| footer = SOLVE_DESIGN + (SOLVE_STOP_G4 if stops else "") | |
| elif design.get("kind") == "solve": # group 5 | |
| footer = SOLVE_ONLY + (STOP_BINDS_SOLVE if stops else "") | |
| elif chain.get("kind") == "continuation" and "carried" in chain: # group 1 | |
| footer = CONTINUED_CARRIED | |
| if stops: | |
| footer += STOP_BINDS + " In a chain the stop and the step are those of the failing design's next run." | |
| elif chain.get("kind") == "continuation": # group 4 | |
| footer = CONTINUED_HANDED | |
| if stops: | |
| footer += STOP_BINDS.replace("the run completes", "the second run completes").replace( | |
| "the last step its run is sealed to", "the last step its next run is sealed to") | |
| elif (chain.get("layout") or {}).get("kind") == "continue": # group 5 | |
| footer = CONTINUED_CARRY + (CARRY_STOP_G5 if stops else "") | |
| else: | |
| return None | |
| if check.get("budget"): | |
| footer += BUDGET_WORDS | |
| return footer | |
| def prompt(environment): | |
| """The whole text an agent is given for one environment.""" | |
| family = environment["family"] | |
| shaped = shaped_footer(environment) | |
| if shaped is not None: | |
| return environment["task"] + "\n\n" + shaped | |
| footer = FOOTERS[family] | |
| check = environment.get("check") or {} | |
| if family in ("tradeoff", "chain_design") and any(c.get("on") == "outcome" for c in check.get("constraints") or []): | |
| footer += STOP_BINDS | |
| if family in ("tradeoff", "chain_design", "forensics") and check.get("budget"): | |
| footer += " Your calls are counted: the budget is in the task, and the tools it rules out may not be called at all." | |
| if family == "forensics" and check.get("reasons"): | |
| footer = footer.replace("Name every false row, each with its one reason from value_altered, seal_wrong, flag_omitted, retired_model, stop_hidden.", | |
| "Name every false row, each with its one reason from %s (the first of them, in that order, that is true of the row)." % ", ".join(check["reasons"])) | |
| return environment["task"] + "\n\n" + footer | |
| def main(): | |
| argv = sys.argv[1:] | |
| if len(argv) < 3 or argv[0] != "--environments": | |
| sys.exit(__doc__) | |
| environments = load_environments(argv[1]) | |
| argv = argv[2:] | |
| if argv[0] == "--list": | |
| print("\n".join(e["id"] for e in environments)) | |
| elif argv[0] == "--all": | |
| if len(argv) < 2: | |
| sys.exit("give the folder to write into") | |
| os.makedirs(argv[1], exist_ok=True) | |
| for e in environments: | |
| with open(os.path.join(argv[1], e["id"] + ".txt"), "w", encoding="utf-8") as f: | |
| f.write(prompt(e) + "\n") | |
| print("wrote %d prompts to %s" % (len(environments), argv[1])) | |
| else: | |
| found = [e for e in environments if e["id"] == argv[0]] | |
| if not found: | |
| sys.exit("no environment with the id %s; --list names them" % argv[0]) | |
| print(prompt(found[0])) | |
| if __name__ == "__main__": | |
| main() | |