Skip to content

Commit 14c55f9

Browse files
Changyi Yangclaude
andcommitted
ASPIRE: an audit that finds breaches, not ASPIRE's own words
From the second review of Infini-AI-Lab#74. The audit no longer flags a command for naming paths that ASPIRE's own text makes actors type (relative .claude/skills, .venv-robosuite, a file called *_fix_code.py), which voided clean sessions. It looks for evidence instead, heredoc bodies included: the ASPIRE checkout's absolute path, another workspace's name, a worked solution by name; runs on unassigned seeds, of programs from outside the workspace (the run's provenance), or of a worked solution's code (by hash); a verifier's third program; a missing session log. bin/sim counts a verifier's programs by content, single first-seed runs free. collect no longer fails when the sandbox refuses the scored program. bin/sim keeps the provider URLs the session's core environment drops. Docs state what the audit cannot see. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c232a02 commit 14c55f9

6 files changed

Lines changed: 137 additions & 47 deletions

File tree

‎docs/methods/aspire.md‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ agent:
1919
base: codex # the actor: ASPIRE's fix-loop subagent prompt, verbatim
2020
params: {prompt: ../utils/task.py:prompt, prepare: ../utils/task.py:prepare, answer: ../utils/task.py:answer,
2121
collect: ../utils/task.py:collect}
22-
codex: {isolation: none, codex_sandbox: danger-full-access, shell_env: all, web_search: false}
22+
codex: {isolation: none, codex_sandbox: danger-full-access, shell_env: core, web_search: false}
2323
evolver:
2424
name: aspire # the coordinator: a Codex session with ASPIRE's guide
2525
base: codex
@@ -105,7 +105,7 @@ The actor's settings are the example's (`agent.params`): `debug_seeds`, `unseen_
105105
| Verification | 5 seeds (the template's 51-55), 2 attempts, `verified` at ≥ 4/5; `void` never promoted | the same budget on 101-105 (two programs, held by `bin/sim`); the score counts only with the verifier's own `verified` and its selected program at ≥ 4/5 on rerun | the template's seeds are LIBERO's; ASPIRE says to change them for Robosuite |
106106
| Lint | `lint_skills.py` after every promotion | `check_spec` with the template's check (sandbox validity and privileged access in ```python snippets, the library's size) | the upstream linter imports ASPIRE |
107107
| Scene exploration | `skills/task-exploration.md` in the shipped library | the same file, given as `docs/task-exploration.md` (the procedure, not learned skills) | the empty library has no such file |
108-
| Stage 2 evidence | the coordinator runs it and keeps the failures out of development | `collect` runs it beside the workspace; the record carries only the pass count | ASPIRE's rule: evaluation failures are not development evidence |
108+
| Stage 2 evidence | the coordinator runs it and keeps the failures out of development | `collect` runs it beside the workspace; the record carries only the pass count, and the coordinator is told not to look further (the per-seed results are reachable from the record's workspace path) | ASPIRE's rule: evaluation failures are not development evidence |
109109
| Library history | `<file>-changelog.md` beside each file | `state/changelog.md` | the adapter holds only the library |
110110
| Phase 3 | rerun of tasks below 80% whose library changed | the test split reruns every task | the evaluation measures it per task |
111111
| Models | Claude Opus 4.6 (and others) | GLM 5.3 Flash in every role | the first-evaluation row of the framework |
@@ -121,8 +121,11 @@ The actor's settings are the example's (`agent.params`): `debug_seeds`, `unseen_
121121
A verified entry transmits (a fresh actor followed it to the fix on the task it came from); it is not shown to
122122
generalize. The reading rules (no worked solutions, no other task's directory, only the assigned seeds) are not
123123
isolation: the actor's commands run without a sandbox, because they drive a GPU simulator. They rest on the
124-
workspace's layout, `bin/sim` and the prompts, and the task's `collect` audits every session after the fact (the
125-
commands it ran, every run's seed), voiding one that broke them. The reruns score the held-out seeds the first pass
124+
workspace's layout, `bin/sim` and the prompts, and the task's `collect` audits every session after the fact, voiding
125+
one that broke them: commands naming the ASPIRE checkout, another workspace or a worked solution; runs on unassigned
126+
seeds, of programs from outside the workspace, or of a worked solution's code; a verifier's third program. A breach
127+
that leaves none of these traces (a path assembled at run time) goes undetected. The coordinator, also unsandboxed,
128+
is held to the same reading rules by its prompt only. The reruns score the held-out seeds the first pass
126129
was scored on (as ASPIRE's Phase 3 does).
127130

128131
## Example

‎examples/aspire_robosuite/README.md‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,13 @@ only if a fresh verifier re-solves the task from the library and the proposals a
9595

9696
The actor's commands run without a sandbox, because they drive a GPU simulator and local services. Its rules
9797
(ASPIRE's reading rules: no worked solution, no shipped library, no other task's directory; only its own seeds) are
98-
held three ways: the workspace holds only what it may read (the docs it is allowed, with the lines that name worked
99-
programs dropped; no repository path in its environment); `bin/sim` runs only its assigned seeds, the unseen check
100-
once, and a verifier's two programs; and `collect` audits the session after the fact (`utils/task.py:audit`: the
101-
commands it ran and every run's seed), voiding a session that broke them (score 0, its report not used). The
102-
audit is detection, not isolation: `bin/sim.json` names the ASPIRE checkout, and a determined session could reach
103-
it; it would be caught only by the commands it ran.
98+
held three ways. The workspace holds only what it may read: the docs it is allowed, with the lines that name worked
99+
programs dropped, and no repository path in its environment (`shell_env: core`). `bin/sim` runs only its assigned
100+
seeds, the unseen check once, and a verifier's two programs. `collect` audits the session after the fact
101+
(`utils/task.py:audit`) and voids one that broke them (score 0, its report not used): commands that name the ASPIRE
102+
checkout, another workspace or a worked solution; runs on unassigned seeds, of programs from outside the workspace,
103+
or of a worked solution's code; a verifier's third program; a session with no log to audit. This is detection, not
104+
isolation: `bin/sim.json` names the checkout, and a breach that leaves none of these traces goes undetected.
104105

105106
## Segmentation without SAM3
106107

‎examples/aspire_robosuite/utils/agent/sim_cli.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from __future__ import annotations
1515

1616
import argparse
17+
import hashlib
1718
import json
1819
import os
1920
from pathlib import Path
@@ -87,14 +88,16 @@ def main() -> None:
8788
refuse("the unseen-check seeds are run once, and they have been run")
8889
ledger.write_text(json.dumps({"seeds": unseen, "program": str(program)}))
8990

90-
if a.cmd == "run-batch" and CONFIG.get("max_programs"):
91-
# the verifier's attempt budget (ASPIRE: at most two programs on its seeds)
91+
if CONFIG.get("max_programs") and (a.cmd == "run-batch" or a.seed != min(CONFIG["dev_seeds"] or [a.seed])):
92+
# the verifier's attempt budget (ASPIRE: at most two programs on its seeds), by the program's content; a
93+
# single run on the first seed (the scene snapshot, a probe) is free
9294
attempts = HERE / "attempts.json"
9395
used = json.loads(attempts.read_text()) if attempts.exists() else []
94-
if str(program) not in used:
96+
digest = hashlib.sha256(program.read_bytes()).hexdigest()
97+
if digest not in used:
9598
if len(used) >= CONFIG["max_programs"]:
96-
refuse(f"the attempt budget is {CONFIG['max_programs']} programs, and it is spent: {used}")
97-
attempts.write_text(json.dumps(used + [str(program)]))
99+
refuse(f"the attempt budget is {CONFIG['max_programs']} programs, and it is spent")
100+
attempts.write_text(json.dumps(used + [digest]))
98101

99102
cli = str(root / ".venv-robosuite" / "bin" / "cap-harness")
100103
common = ["--benchmark", "robosuite", "--suite", CONFIG["suite"], "--task-id", str(CONFIG["task_id"]),

‎examples/aspire_robosuite/utils/task.py‎

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"""
1414
from __future__ import annotations
1515

16+
import hashlib
1617
import json
1718
import os
1819
from pathlib import Path
@@ -62,7 +63,8 @@ def prepare(task: dict, workspace: Path, params: dict, base: Path) -> list[dict]
6263
(bin_dir / "sim.json").write_text(json.dumps({
6364
"workspace": str(work.resolve()), "aspire_root": str(s["root"]), "suite": s["suite"], "task_id": s["task_id"],
6465
"dev_seeds": sim_seeds(s["dev"]), "unseen_seeds": sim_seeds(s["unseen"]), "dev_seeds_text": s["dev"],
65-
"unseen_seeds_text": s["unseen"], "env": s["env"], "workers": s["workers"], "max_steps": s["max_steps"],
66+
"unseen_seeds_text": s["unseen"], "env": {**service_env(), **s["env"]}, "workers": s["workers"],
67+
"max_steps": s["max_steps"],
6668
"max_programs": 2 if s["role"] == "verifier" else None},
6769
indent=1))
6870
wrapper = bin_dir / "sim"
@@ -87,6 +89,12 @@ def prepare(task: dict, workspace: Path, params: dict, base: Path) -> list[dict]
8789
return []
8890

8991

92+
def service_env() -> dict:
93+
"""The provider URLs set for this run (README, step 2): bin/sim gets them through sim.json, because the session's
94+
commands see only Codex's core variables (shell_env: core), and Stage 2 runs in this process with them."""
95+
return {k: os.environ[k] for k in ("CAP_HARNESS_SAM3_URL", "CAP_HARNESS_CUROBO_URL") if os.environ.get(k)}
96+
97+
9098
def task_dir(s: dict) -> str:
9199
"""The actor's $TASK_DIR as ASPIRE's template defines it, with $RUN_ROOT the workspace; the verifier's is `.`."""
92100
return f"robosuite/{s['suite']}/task_{s['task_id']}" if s["role"] == "actor" else "."
@@ -199,10 +207,12 @@ def collect(task: dict, workspace: Path, log: Path, params: dict) -> dict:
199207
engine = sim.Engine(s["root"], env=s["env"], workers=s["workers"], max_steps=s["max_steps"],
200208
timeout_s=float(params.get("sweep_timeout_s", 7200)))
201209
refused = engine.validate(program)
202-
out = Path(workspace).parent / "stage2" # beside the workspace, not in the log: the coordinator reads
203-
records = [] if refused else engine.run(program, suite=s["suite"], seeds=seeds, out=out, # the log, and
204-
task_id=s["task_id"]) # held-out
205-
(out / "stage2.json").write_text(json.dumps({"refused": refused, "records": records}, indent=1)) # stays out
210+
# Beside the workspace, not in the log: the coordinator reads the log, and held-out runs stay out of it.
211+
out = Path(workspace).parent / "stage2"
212+
out.mkdir(parents=True, exist_ok=True)
213+
records = [] if refused else engine.run(program, suite=s["suite"], seeds=seeds, out=out,
214+
task_id=s["task_id"])
215+
(out / "stage2.json").write_text(json.dumps({"refused": refused, "records": records}, indent=1))
206216
facts.update(scored_seeds=seeds, scored_passed=sum(r["task_success"] for r in records),
207217
scored_refused=refused)
208218
else:
@@ -211,40 +221,73 @@ def collect(task: dict, workspace: Path, log: Path, params: dict) -> dict:
211221
return facts
212222

213223

214-
# What a session must not touch (ASPIRE's reading rules), found in the commands it ran: the repository (its shipped
215-
# library, worked solutions, examples, the engine called past bin/sim) and other sessions' workspaces.
216-
FORBIDDEN = (r"\.claude/skills", r"\w+_fix_code\.py", r"examples/robosuite", r"SUCCESS_RATES", r"\.venv-robosuite")
224+
# ASPIRE's worked solutions by name: a command that names one has gone looking for it.
225+
SOLUTIONS = re.compile(r"\b(?:cube_lifting|cube_restack|cube_stack|nut_assembly|spill_wipe|two_arm_handover|"
226+
r"two_arm_lift)_fix_code\.py|SUCCESS_RATES\.md")
217227

218228

219229
def audit(s: dict, workspace: Path, log: Path) -> list[str]:
220-
"""The breaches of the session's rules, after the fact: commands that reach outside its workspace (the
221-
repository, another workspace) or past bin/sim, and runs on seeds it was not assigned. Empty when clean."""
230+
"""The breaches of the session's rules, found after the fact; empty when clean. Detection, not isolation:
231+
232+
- a command (heredoc bodies included) that names the ASPIRE checkout's absolute path, another session's
233+
workspace, or one of ASPIRE's worked solutions by name;
234+
- a run on a seed the session was not assigned, or of a program from outside its workspace (each run's
235+
provenance names its input file);
236+
- a run, or the scored program, whose code is byte-identical to one of ASPIRE's worked solutions or examples;
237+
- for a verifier, more than two programs run on several seeds (its attempt budget);
238+
- no session log to audit.
239+
Relative paths that merely repeat a name from ASPIRE's own text (`.claude/skills/...`) are not breaches: inside
240+
the workspace they name nothing."""
241+
workspace, root = Path(workspace), Path(s["root"])
222242
found = []
223-
others = re.escape(str(workspace.parent.parent)) # the directory that holds every session's workspace
224-
own = re.escape(workspace.parent.name)
225-
patterns = [re.compile(p) for p in FORBIDDEN] + [re.compile(re.escape(str(s["root"]))),
226-
re.compile(others + r"/(?!" + own + r")[^/\s'\"]+")]
227243
stream = log / "agent-codex.jsonl"
228-
for line in (stream.read_text(errors="replace").splitlines() if stream.is_file() else []):
244+
if not stream.is_file():
245+
return ["no session log to audit (agent-codex.jsonl)"]
246+
holder = workspace.parent.parent # the directory that holds every session's workspace
247+
others = [d.name for d in holder.iterdir() if d.is_dir() and d.name != workspace.parent.name]
248+
patterns = [re.compile(re.escape(str(root)) + r"\b"), SOLUTIONS]
249+
if others:
250+
patterns.append(re.compile("|".join(re.escape(name) for name in others)))
251+
for line in stream.read_text(errors="replace").splitlines():
229252
try:
230253
item = json.loads(line).get("item") or {}
231254
except ValueError:
232255
continue
233256
if item.get("type") != "command_execution":
234257
continue
235-
command = re.sub(r"<<'?(\w+)'?.*?\n\1", "", item.get("command", ""), flags=re.S) # not a heredoc's text
236258
for pattern in patterns:
237-
match = pattern.search(command)
259+
match = pattern.search(item.get("command", ""))
238260
if match:
239-
found.append(f"command reached {match.group(0)!r}")
261+
found.append(f"a command named {match.group(0)!r}")
262+
solutions = {_sha(p) for p in [*(root / SKILLS / "robosuite").glob("*.py"), *(root / "examples").rglob("*.py")]}
240263
allowed = set(sim_seeds(s["dev"])) | set(sim_seeds(s["unseen"]))
264+
programs: dict[str, set] = {}
241265
for run in workspace.rglob("run.json"):
242266
seed = (_json(run.read_text(errors="replace")) or {}).get("seed")
243267
if isinstance(seed, int) and seed not in allowed:
244268
found.append(f"a run on seed {seed}, not assigned")
269+
provenance = _json((run.parent / "source" / "provenance.json").read_text(errors="replace")) \
270+
if (run.parent / "source" / "provenance.json").is_file() else {}
271+
source = Path(str((provenance or {}).get("input_path") or workspace))
272+
if not source.resolve().is_relative_to(workspace.resolve()):
273+
found.append(f"a run of a program from outside the workspace ({source.name})")
274+
if (provenance or {}).get("sha256") in solutions:
275+
found.append(f"a run of one of ASPIRE's worked solutions ({source.name})")
276+
programs.setdefault((provenance or {}).get("sha256"), set()).add(seed)
277+
for scored in (workspace / task_dir(s) / "fix_code.py", workspace / evo_dir(s) / "evosearch_best_code.py"):
278+
if scored.is_file() and _sha(scored) in solutions:
279+
found.append(f"{scored.name} is one of ASPIRE's worked solutions")
280+
if s["role"] == "verifier":
281+
sweeps = [sha for sha, seeds in programs.items() if sha and len(seeds) > 1]
282+
if len(sweeps) > 2:
283+
found.append(f"{len(sweeps)} programs run on several seeds, past the verifier's two")
245284
return sorted(set(found))
246285

247286

287+
def _sha(path: Path) -> str:
288+
return hashlib.sha256(path.read_bytes()).hexdigest()
289+
290+
248291
def _json(text):
249292
try:
250293
return json.loads(text) if text else None

‎hermit/adapter/templates/aspire/.hermit/check.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
FENCE = re.compile(r"```(?:python|py)[ \t]*\n(.*?)```", re.S) # program snippets (other fences are prose)
2323
LIBRARY_MAX = 100_000 # bytes of ADAPTER.md, the index and every skill file: what the actor's context carries
2424
LINK = re.compile(r"\]\(([A-Za-z0-9_\-]+\.md)\)")
25-
# Privileged access a generated program must never use (ASPIRE's provenance rule), named in code or prose
25+
# Privileged access a generated program must never use (ASPIRE's provenance rule), looked for in ```python snippets
2626
PRIVILEGED = re.compile(r"\b(?:env\.sim|sim\.(?:data|model)|sim\.forward|check_success|get_reward|"
2727
r"native_env|handle\.env|parsed_problem|eval_predicate|obj_body_id|getattr|setattr)\b")
2828
FORBIDDEN = (ast.AsyncFunctionDef, ast.Await, ast.ClassDef, ast.Delete, ast.Global, ast.ImportFrom, ast.Nonlocal,

0 commit comments

Comments
 (0)