verifiers 0.4.2.dev26__py3-none-any.whl → 0.4.2.dev28__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -410,7 +410,10 @@ class HarborTask(Task[HarborData, State, HarborTaskConfig]):
410
410
  "mkdir -p /tests && tar -xzf /tmp/tests.tgz -C /tests"
411
411
  )
412
412
  # Verifier subprocesses can use different users; opening their log directory
413
- # requires its owner or root, even when it is already writable.
413
+ # requires its owner or root, even when it is already writable. A grading box
414
+ # of its own starts with an empty log directory: anything already there came
415
+ # from the image or from the agent's restored artifacts, not from this grader.
416
+ isolated = wipe or self.scoring.mode == "isolated"
414
417
  setup = (
415
418
  runtime.with_user("root")
416
419
  if runtime.backend.SUPPORTS_USER_SWITCHING
@@ -420,6 +423,7 @@ class HarborTask(Task[HarborData, State, HarborTaskConfig]):
420
423
  (
421
424
  setup,
422
425
  (
426
+ f"{'rm -rf /logs/verifier && ' if isolated else ''}"
423
427
  f"mkdir -p /logs/verifier {ARTIFACTS_DIR} && "
424
428
  f"chmod 777 /logs/verifier {ARTIFACTS_DIR}"
425
429
  ),
@@ -341,6 +341,10 @@ async def restore(runtime: Runtime, collected: dict[str, bytes | None]) -> None:
341
341
  )
342
342
  for root, archive in collected.items():
343
343
  _validate_restore(root, archive)
344
+ collected = {
345
+ root: None if archive is None else _rebuild(archive)
346
+ for root, archive in collected.items()
347
+ }
344
348
  # Clear every root up front, not per entry: a later nested root would otherwise
345
349
  # delete content an earlier one just restored. Clearing also drops any file or
346
350
  # symlink the image left at the target.
@@ -425,6 +429,45 @@ def _drop_special_files(archive: bytes) -> tuple[bytes, list[str]]:
425
429
  return out.getvalue(), dropped
426
430
 
427
431
 
432
+ def _rebuild(archive: bytes) -> bytes:
433
+ """Write a fresh archive holding exactly the members Python's tarfile reads.
434
+
435
+ Validation reads archives with Python's tarfile, but the grading box extracts
436
+ them with its own tar. An agent controls the archive bytes, and two tar parsers
437
+ can disagree about the same bytes, so the box only ever extracts an archive
438
+ written here from the members validation saw. Owners and permission bits are
439
+ kept (tasks rely on ownership, e.g. git's safe.directory check); setuid,
440
+ setgid and sticky bits are not.
441
+ """
442
+ out = io.BytesIO()
443
+ with (
444
+ tarfile.open(fileobj=io.BytesIO(archive), mode="r:") as source,
445
+ tarfile.open(fileobj=out, mode="w:", format=tarfile.PAX_FORMAT) as target,
446
+ ):
447
+ for member in source:
448
+ info = tarfile.TarInfo(member.name)
449
+ info.mode = member.mode & 0o777
450
+ info.uid, info.gid = member.uid, member.gid
451
+ info.uname, info.gname = member.uname, member.gname
452
+ info.mtime = member.mtime
453
+ content = None
454
+ if member.isfile():
455
+ info.type = tarfile.REGTYPE
456
+ info.size = member.size
457
+ content = source.extractfile(member)
458
+ elif member.isdir():
459
+ info.type = tarfile.DIRTYPE
460
+ elif member.issym() or member.islnk():
461
+ info.type = tarfile.SYMTYPE if member.issym() else tarfile.LNKTYPE
462
+ info.linkname = member.linkname
463
+ else:
464
+ raise RuntimeError(
465
+ f"artifact member {member.name!r} is a link or special file"
466
+ )
467
+ target.addfile(info, content)
468
+ return out.getvalue()
469
+
470
+
428
471
  def _validate_restore(root: str, archive: bytes | None) -> None:
429
472
  """Reject archive content that could restore outside its declared root."""
430
473
  root_path = PurePosixPath(root)
@@ -482,6 +525,15 @@ def _validate_restore(root: str, archive: bytes | None) -> None:
482
525
  raise RuntimeError(
483
526
  f"artifact member {member.name!r} is a link or special file"
484
527
  )
528
+ if member.issparse():
529
+ # A sparse member declares its full size in a few header bytes,
530
+ # and rebuilding the archive on the host would write every hole
531
+ # out as zeros. GNU tar only writes these with --sparse; bsdtar
532
+ # writes them for any file with holes.
533
+ raise RuntimeError(
534
+ f"artifact member {member.name!r} is a sparse file, which "
535
+ "cannot be restored"
536
+ )
485
537
  if member.isfile():
486
538
  regular_files.add(member_path)
487
539
  # Check after reading the whole archive, so a later symlink cannot
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: verifiers
3
- Version: 0.4.2.dev26
3
+ Version: 0.4.2.dev28
4
4
  Summary: Verifiers: Environments for LLM Reinforcement Learning
5
5
  Project-URL: Homepage, https://github.com/primeintellect-ai/verifiers
6
6
  Project-URL: Documentation, https://github.com/primeintellect-ai/verifiers
@@ -159,7 +159,7 @@ verifiers/v1/runtimes/backends/prime.py,sha256=qTTIrmMbEluKIwHQ4kwRnKXn6RIT-P3mZ
159
159
  verifiers/v1/runtimes/backends/subprocess.py,sha256=naOWJGmcaOlu2ZdRbUwhJicJdxASDRAUhDT0jzDff3w,8591
160
160
  verifiers/v1/tasksets/__init__.py,sha256=2ijE3qIlLoUA02g6iysOwWQylyBBQL1GhSpjv8_bp0w,521
161
161
  verifiers/v1/tasksets/harbor/__init__.py,sha256=FjW4tM3rgGALMK-8p7ux26G4-d4ZFVmaAmO6Fni6e_g,214
162
- verifiers/v1/tasksets/harbor/taskset.py,sha256=5b5zUcZF61uHUfuc7Vr-XztKhFNc7tq0pe-BjwXncMk,43368
162
+ verifiers/v1/tasksets/harbor/taskset.py,sha256=g9uLfSclESw5XV56T9h0TXD9dm9W2FrkpVgegbokctU,43686
163
163
  verifiers/v1/tasksets/harbor/toolset.py,sha256=_7HXu-uuvqzhmJ1EX6c3KWLg0g0eRrLjCq1kBsZhIwo,3159
164
164
  verifiers/v1/tasksets/nemo_gym/__init__.py,sha256=654gAvG3Wd_Z_nh6mypeKn4s_IIQ0Ge6vcZvxTHC2_E,306
165
165
  verifiers/v1/tasksets/nemo_gym/response.py,sha256=EhrsquEP8g0bjzAThGfE6Ypgy86_nVX235NiFYtVDVM,4463
@@ -172,7 +172,7 @@ verifiers/v1/tasksets/textarena/__init__.py,sha256=Os2OlBY_pSH0B1DP32RitumgSLpq2
172
172
  verifiers/v1/tasksets/textarena/taskset.py,sha256=zGslerxmH2ZT7FJdP-72R6a9p71kr2pNS3r5_xnq1lQ,4406
173
173
  verifiers/v1/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
174
174
  verifiers/v1/utils/aio.py,sha256=0yNFOqB2oO6Qktc6NI_ZSAGuo1aHsIK_wuT1BtmoZ3I,1532
175
- verifiers/v1/utils/artifacts.py,sha256=6vnd1lUddNy0tfAYkubyWqEv961_Dr1d6MS6nRUwdtA,22827
175
+ verifiers/v1/utils/artifacts.py,sha256=QWquQli7wfPxPOaKvP4Nn2anQyozrh-DOJwLpZhK_ak,25222
176
176
  verifiers/v1/utils/compile.py,sha256=J5PzohCTCj9UQ1d6rmQB-pTJKLYa_f6-0YMZ9y3yWoA,5308
177
177
  verifiers/v1/utils/decorators.py,sha256=LbHW0bPkFy-l_TNp48HDDB_PZVr7wvJuVfuo3Qctcbo,5608
178
178
  verifiers/v1/utils/env.py,sha256=tMqfwFNRcJPijzrjkbE2VYvBH8eONRtYCWVkXHKpGZQ,1023
@@ -193,8 +193,8 @@ verifiers/v1/utils/scope.py,sha256=zbs4pj6AVk4jywlAJ3AX0Q0_kzB9dBB02nY-9H4ELdQ,8
193
193
  verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
194
194
  verifiers/v1/utils/trace_store.py,sha256=Qo9qvsJAl8PoRUavjQAfUB2VNxmUtYQtU2ejLKPzY9c,3382
195
195
  verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
196
- verifiers-0.4.2.dev26.dist-info/METADATA,sha256=a3MMc1sU-BFIGN0xfCo9TL6KpxjR8wgHOCWDc39KYy4,5142
197
- verifiers-0.4.2.dev26.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
198
- verifiers-0.4.2.dev26.dist-info/entry_points.txt,sha256=3M8Wr0w1cUKiB-fJ6YHB6eK5WuKYg-Y3OC4wCuUje_c,174
199
- verifiers-0.4.2.dev26.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
200
- verifiers-0.4.2.dev26.dist-info/RECORD,,
196
+ verifiers-0.4.2.dev28.dist-info/METADATA,sha256=_IrZBtOKwCdUNW8pZxOcC--V48LwcZTugf8J3vLgc3E,5142
197
+ verifiers-0.4.2.dev28.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
198
+ verifiers-0.4.2.dev28.dist-info/entry_points.txt,sha256=3M8Wr0w1cUKiB-fJ6YHB6eK5WuKYg-Y3OC4wCuUje_c,174
199
+ verifiers-0.4.2.dev28.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
200
+ verifiers-0.4.2.dev28.dist-info/RECORD,,