File size: 17,742 Bytes
158258b | 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 | #!/usr/bin/env python3
"""Gather the artifacts worth keeping from auto-impl and RSIChallenge into one
upload-ready tree.
The output is a single self-describing folder that can be pushed to the
HuggingFace dataset repo `Jerry999/RSIChallenge` by
`scripts/upload_artifacts_hf.sh`, and that is also the thing to hand to the
babel server or to a future reader who has neither cluster.
Move or copy -- and why it differs per artifact
-----------------------------------------------
The instruction was to *move*, not copy, so that we end up with one organised
home for each file rather than a second scattered duplicate. That is right for
run artifacts. It is wrong for anything git tracks, and it is wrong for a file
a live pipeline still opens. So the rule is applied per artifact:
MOVE, no symlink `solve_out_sanitized.txt`, `solve_parsed_sanitized.txt`
These are byte-identical duplicates of the unsanitized
files next to them (verified across every run: 40/40
identical, and the upstream sanitizer only redacts values
from `.env`, none of which appear). The unsanitized copy
stays where the analysis pipeline reads it, the duplicate
moves here. This genuinely reclaims space and breaks
nothing.
MOVE + symlink `metrics.json`, `prompt.txt`, `time_taken.txt`,
`final_eval_*.txt`, and the RSIChallenge run directories.
Single copies that `analysis/` and the RSIChallenge
scripts still open by path, so the original path is left
pointing into this tree. Nothing is duplicated and
nothing breaks. `--undo` reverses it.
COPY Documents and code under git. Moving them would delete
them from a tracked working tree, which is never what
"tidy up" means. Git already stores them once; the copy
here exists so the dataset stands alone.
Deliberately left out
---------------------
`final_model/` the trained checkpoints. Hundreds of GB across 168 runs.
`agent_home/`, `task/`
the agent's workspace and the training data it built --
tens of GB, and `task/` holds benchmark test items that
were deliberately placed there for the contamination
self-check. Publishing it would redistribute test data.
`hf_cache/`, `containers/`, `apptainer/`
third-party weights and images, not ours to publish.
`_aborted_*` preempted stubs with no `metrics.json`. Counted in the
manifest, not shipped.
Nothing is uploaded from here. This machine's sandbox cannot reach
huggingface.co; the upload is a separate script the user runs.
python scripts/compose_artifacts.py --dry-run # plan only, touch nothing
python scripts/compose_artifacts.py # build the tree
python scripts/compose_artifacts.py --undo # put the moved files back
"""
from __future__ import annotations
import argparse
import hashlib
import json
import os
import re
import shutil
import sys
from datetime import datetime, timezone
from pathlib import Path
LUSTRE = Path("/lustre-storage/fsx_2/user/jiaruiliu/ptb-data")
HOME = Path("/home/jiaruiliu")
REPOS = HOME / "local/git-repos"
# Staging lives on the same filesystem as the bulk of the sources, so the
# moves are renames rather than copies.
DEFAULT_STAGING = Path("/lustre-storage/fsx_2/user/jiaruiliu/hf_upload/RSIChallenge")
# (label, source root, destination under auto-impl/runs/)
PTB_SWEEPS = [
("claude_run1", LUSTRE / "results/claude_non_api_claude-opus-5_10h_run1", "claude_opus5_10h_run1"),
("claude_run2", LUSTRE / "results/claude_non_api_claude-opus-5_10h_run2", "claude_opus5_10h_run2"),
("codex_run1", LUSTRE / "results_codex_sdk_gpt-5.6-sol_20261006/codex_sdk_gpt-5.6-sol_10h_run1",
"codex_gpt56sol_10h_run1"),
("direct_baseline", LUSTRE / "results/baseline_direct_inference_zeroshot", "direct_inference_zeroshot"),
]
# filename in the run dir -> filename in the staged tree. The two `_sanitized`
# entries are the de-duplicating moves; the rest are moved with a symlink left
# behind. `final_eval_*.txt` is handled separately because it is a glob.
MOVE_DEDUP = {"solve_out_sanitized.txt": "trace.txt",
"solve_parsed_sanitized.txt": "trace_parsed.txt"}
MOVE_SYMLINK = {"metrics.json": "metrics.json",
"prompt.txt": "prompt.txt",
"time_taken.txt": "time_taken.txt"}
SECRET_PATTERNS = [
re.compile(rb"sk-[A-Za-z0-9_-]{20,}"),
re.compile(rb"ghp_[A-Za-z0-9]{20,}"),
re.compile(rb"hf_[A-Za-z0-9]{20,}"),
re.compile(rb"AKIA[0-9A-Z]{12,}"),
re.compile(rb"-----BEGIN [A-Z ]*PRIVATE KEY"),
re.compile(rb"eyJ[A-Za-z0-9_-]{30,}\.[A-Za-z0-9_-]{20,}\."), # JWT
]
# Filenames that must never be staged whatever else matches.
NEVER = re.compile(r"(^|/)(\.env|oauth_token|api_keys\.json|\.netrc|id_rsa|token)$")
class Plan:
"""Collects what will happen so --dry-run and the real run share one path."""
def __init__(self, dry: bool):
self.dry = dry
self.moved: list[tuple[str, str, bool]] = [] # src, dst, symlink_back
self.copied: list[tuple[str, str]] = []
self.skipped: dict[str, int] = {}
def skip(self, why: str) -> None:
self.skipped[why] = self.skipped.get(why, 0) + 1
def move(self, src: Path, dst: Path, symlink_back: bool) -> None:
if NEVER.search(str(src)):
self.skip("credential-shaped filename")
return
self.moved.append((str(src), str(dst), symlink_back))
if self.dry:
return
dst.parent.mkdir(parents=True, exist_ok=True)
if dst.exists(): # idempotent re-run
if src.is_symlink():
return
dst.unlink()
shutil.move(str(src), str(dst)) # rename when same fs, copy+unlink otherwise
if symlink_back:
src.symlink_to(dst)
def copy(self, src: Path, dst: Path) -> None:
if NEVER.search(str(src)):
self.skip("credential-shaped filename")
return
self.copied.append((str(src), str(dst)))
if self.dry:
return
dst.parent.mkdir(parents=True, exist_ok=True)
if src.is_dir():
shutil.copytree(src, dst, dirs_exist_ok=True,
ignore=shutil.ignore_patterns(".git", "__pycache__", "*.pyc",
".env", "oauth_token", "api_keys.json"))
else:
shutil.copy2(src, dst)
def stage_ptb_runs(plan: Plan, staging: Path) -> dict:
"""Per-run artifacts from the four PostTrainBench sweeps."""
stats = {}
for label, root, destname in PTB_SWEEPS:
if not root.is_dir():
plan.skip(f"missing sweep root {label}")
continue
kept = aborted = 0
for run in sorted(p for p in root.iterdir() if p.is_dir()):
if run.name.startswith("_aborted"):
aborted += len(list(run.iterdir()))
continue
# `_extra_completions_*` holds genuine completed repeats; descend.
groups = [run] if not run.name.startswith("_") else sorted(
p for p in run.iterdir() if p.is_dir())
for d in groups:
if not (d / "metrics.json").is_file():
plan.skip("run without metrics.json")
continue
tag = d.name if d is run else f"extra/{d.name}"
out = staging / "auto-impl/runs" / destname / tag
for name, newname in MOVE_DEDUP.items():
if (d / name).is_file() and not (d / name).is_symlink():
plan.move(d / name, out / newname, symlink_back=False)
for name, newname in MOVE_SYMLINK.items():
if (d / name).is_file() and not (d / name).is_symlink():
plan.move(d / name, out / newname, symlink_back=True)
for ev in sorted(d.glob("final_eval_*.txt")):
if not ev.is_symlink():
plan.move(ev, out / ev.name, symlink_back=True)
kept += 1
stats[label] = {"runs_staged": kept, "aborted_entries_skipped": aborted}
return stats
def stage_repo(plan: Plan, repo: Path, staging: Path, subdirs: list[str]) -> None:
for sub in subdirs:
src = repo / sub
if src.exists():
plan.copy(src, staging / repo.name / sub)
def stage_rsi_runs(plan: Plan, staging: Path) -> None:
"""RSIChallenge run outputs: moved wholesale, with the original path symlinked."""
base = HOME / "rsi_runs"
if not base.is_dir():
plan.skip("no rsi_runs directory")
return
for sub in sorted(p for p in base.iterdir() if p.is_dir()):
if sub.is_symlink():
continue
plan.move(sub, staging / "RSIChallenge/rsi_runs" / sub.name, symlink_back=True)
def scan_secrets(staging: Path, limit_mb: int = 64) -> list[str]:
"""Grep the staged tree for credential-shaped strings. Gate, not decoration."""
hits = []
for p in staging.rglob("*"):
if not p.is_file() or p.is_symlink():
continue
if p.stat().st_size > limit_mb * 1024 * 1024:
hits.append(f"{p} (NOT SCANNED: larger than {limit_mb} MB)")
continue
try:
blob = p.read_bytes()
except OSError:
continue
for pat in SECRET_PATTERNS:
if pat.search(blob):
hits.append(f"{p} matches {pat.pattern.decode(errors='replace')}")
break
return hits
def write_manifest(staging: Path, stats: dict, plan: Plan) -> dict:
files = [p for p in staging.rglob("*") if p.is_file() and not p.is_symlink()]
total = sum(p.stat().st_size for p in files)
by_top: dict[str, dict] = {}
for p in files:
top = p.relative_to(staging).parts[0]
e = by_top.setdefault(top, {"files": 0, "bytes": 0})
e["files"] += 1
e["bytes"] += p.stat().st_size
manifest = {
"composed_utc": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"composed_on": "aws server",
"target_repo": "Jerry999/RSIChallenge (HuggingFace dataset)",
"total_files": len(files),
"total_bytes": total,
"total_mb": round(total / 1048576, 1),
"by_section": {k: {**v, "mb": round(v["bytes"] / 1048576, 1)} for k, v in sorted(by_top.items())},
"ptb_sweeps": stats,
"moved": len(plan.moved),
"copied": len(plan.copied),
"skipped": plan.skipped,
}
(staging / "MANIFEST.json").write_text(json.dumps(manifest, indent=1))
return manifest
README = """# RSIChallenge — artifacts / 工件集
**Composed on the aws server.** Source repos: [`auto-impl`](https://github.com/jiarui-liu/auto-impl)
(PostTrainBench agent study) and `RSIChallenge` (recursive self-improvement study).
Built by `scripts/compose_artifacts.py`; inventory in `MANIFEST.json`.
## 高层要点 / Takeaways
1. **这是两个项目的"可移植产物"合集** —— 能跨机器、跨时间复用的那部分:
agent trace、逐 run 指标、分析中间产物、全部文档。
2. **不含模型权重、agent 工作区和训练数据。** 前者有数百 GB,后者含被刻意放进沙箱的
benchmark 测试题(发布等于再分发测试集)。详见下面"未收录"。
3. **trace 是核心资产**:168 个 run、每个 10 小时的自主研究过程,逐条工具调用与输出。
4. 每个 run 目录自带 `metrics.json`(最终分数)与 `prompt.txt`(任务原文),可独立使用。
> This is the portable subset of two projects: agent traces, per-run metrics, analysis
> intermediates and all documents. It deliberately excludes model weights, agent workspaces and
> the training data the agents built — the last of those contains benchmark test items that were
> placed in the sandbox on purpose for a contamination self-check, so publishing it would
> redistribute test data. The traces are the asset: 168 runs of ten-hour autonomous research,
> tool call by tool call.
## Layout / 结构
```
auto-impl/
docs/ 研究文档:结果、综述、总报告(中英双语)
analysis/ trace 分析管线的代码与产物(探针、噪声、泄漏审计)
scripts/ 提交与复现脚本
runs/
claude_opus5_10h_run1/<task>_<model>_<timestamp>/
claude_opus5_10h_run2/... (第二个种子;extra/ 下是同配置重复)
codex_gpt56sol_10h_run1/...
direct_inference_zeroshot/... (不训练的基线)
├── trace.txt 完整 agent trace(每行一个事件,带 ISO 时间戳)
├── trace_parsed.txt 解析后的可读版本
├── metrics.json 最终分数
├── prompt.txt 给 agent 的任务原文
├── final_eval_*.txt 评测日志
└── time_taken.txt
RSIChallenge/
docs/ 研究文档
experiments/ 实验代码
rsi_runs/ run 产物(traces/ 与 substeps/)
```
## 未收录,以及为什么 / What is not here
| 未收录 | 原因 |
|---|---|
| `final_model/` | 168 个 run 的训练后权重,数百 GB |
| `agent_home/`、`task/` | agent 工作区与它自己构建的训练数据;**`task/` 含 benchmark 测试题**(沙箱里刻意放的,供 agent 自查污染),发布等于再分发测试集 |
| `hf_cache/`、容器镜像 | 第三方权重与镜像,不是我们的东西 |
| `_aborted_*` | 被抢占的残缺 run,没有 `metrics.json`;数量记在 `MANIFEST.json` 里 |
## 可比性警告 / Caveats
- `arenahardwriting` 与 `healthbench` 由**本地 Qwen3.6-27B** 评分,顶替 OpenAI `gpt-5-mini`
(集群连不上)。**绝对值与已发表数字不可比** —— zero-shot 下本地 judge 给 0.034、论文给 0.095。
两个 agent 用的是同一个替代 judge,所以**它们之间**可比。
- agent 沙箱是刻意**禁网**的(`--network=none`),上游官方设定是联网无限制。
- 逐格比较的 95% 噪声门槛是 **0.125**(跨 sweep)/ **0.084**(同 sweep 内);
小于它的分差不构成证据。方法见 `auto-impl/docs/results/seed_variance_run1_run2_2026-10.md`。
"""
def main() -> None:
ap = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("--staging", type=Path, default=DEFAULT_STAGING)
ap.add_argument("--dry-run", action="store_true", help="print the plan, change nothing")
ap.add_argument("--undo", action="store_true", help="restore files that were moved + symlinked")
args = ap.parse_args()
if args.undo:
return undo(args.staging)
plan = Plan(args.dry_run)
if not args.dry_run:
args.staging.mkdir(parents=True, exist_ok=True)
stats = stage_ptb_runs(plan, args.staging)
stage_repo(plan, REPOS / "auto-impl", args.staging,
["docs", "analysis", "scripts", "src", "CLAUDE.md"])
stage_repo(plan, REPOS / "RSIChallenge", args.staging,
["docs", "experiments", "scripts", "CLAUDE.md"])
stage_rsi_runs(plan, args.staging)
print(f"{'PLAN (nothing changed)' if args.dry_run else 'COMPOSED'}")
print(f" moved : {len(plan.moved)} ({sum(1 for *_, s in plan.moved if s)} with a symlink left behind)")
print(f" copied : {len(plan.copied)}")
for why, n in sorted(plan.skipped.items()):
print(f" skipped: {n:5d} {why}")
for label, s in stats.items():
print(f" {label:18s} {s['runs_staged']:3d} runs staged, "
f"{s['aborted_entries_skipped']} aborted entries skipped")
if args.dry_run:
print(f"\nWould write to {args.staging}")
return
(args.staging / "README.md").write_text(README)
manifest = write_manifest(args.staging, stats, plan)
print(f"\n staged total: {manifest['total_files']} files, {manifest['total_mb']} MB")
for k, v in manifest["by_section"].items():
print(f" {k:16s} {v['files']:6d} files {v['mb']:8.1f} MB")
print("\nScanning the staged tree for credentials ...")
hits = scan_secrets(args.staging)
gate = args.staging / ".secret-scan-passed"
if hits:
gate.unlink(missing_ok=True)
print(f" FAILED -- {len(hits)} suspicious file(s). Upload is blocked:")
for h in hits[:20]:
print(f" {h}")
sys.exit(1)
gate.write_text(manifest["composed_utc"] + "\n")
print(" clean -- no credential-shaped strings found.")
print(f"\nNext: bash scripts/upload_artifacts_hf.sh (run it on a machine that reaches huggingface.co)")
def undo(staging: Path) -> None:
"""Walk the original tree and pull every symlink-into-staging back home."""
restored = 0
for root in [p for _, p, _ in PTB_SWEEPS] + [HOME / "rsi_runs"]:
if not root.exists():
continue
for p in root.rglob("*"):
if not p.is_symlink():
continue
target = Path(os.readlink(p))
if staging not in target.parents:
continue
p.unlink()
shutil.move(str(target), str(p))
restored += 1
print(f"restored {restored} path(s) from {staging}")
print("note: the de-duplicated `*_sanitized.txt` copies are not restored -- "
"their unsanitized twins were never moved and are byte-identical.")
if __name__ == "__main__":
main()
|