fffiloni commited on
Commit
b70a83b
·
verified ·
1 Parent(s): f667ce6

Upload 130 files

Browse files
tests/test_v175_anonymous_eval_archive.py CHANGED
@@ -22,25 +22,25 @@ def eval_settings() -> Settings:
22
  )
23
 
24
 
25
- def test_eval_bucket_env_is_passed_when_enabled(monkeypatch):
26
  monkeypatch.setattr(jobs, "settings", eval_settings())
27
  env = jobs._base_env(run_id="universal-20260606-000000-abcd1234", username="alice", bucket_source="alice/space-factory-runs", worker_script_path="/output/runs/x/_worker.py")
28
- assert env["ASF_EVAL_ENABLED"] == "true"
29
- assert env["ASF_EVAL_BUCKET_SOURCE"] == "huggingface/agentic-space-factory-evals"
30
- assert env["ASF_EVAL_BUCKET_PATH"] == "evals"
31
- assert env["ASF_EVAL_BUCKET_MOUNT"] == "/evals"
32
  assert env["ASF_EVAL_SALT"] == "test-salt"
 
 
33
 
34
 
35
- def test_eval_bucket_is_mounted_as_separate_job_volume(monkeypatch):
36
  monkeypatch.setattr(jobs, "settings", eval_settings())
37
  volumes = jobs._job_volumes("alice/space-factory-runs")
38
  rendered = [vars(v) if hasattr(v, "__dict__") else v for v in volumes]
39
  text = repr(rendered)
40
  assert "alice/space-factory-runs" in text
41
- assert "huggingface/agentic-space-factory-evals" in text
42
- assert "evals" in text
43
- assert "/evals" in text
44
 
45
 
46
  def test_workers_publish_anonymized_eval_records_without_raw_code_or_prompts():
 
22
  )
23
 
24
 
25
+ def test_eval_record_env_is_passed_without_operator_bucket_mount(monkeypatch):
26
  monkeypatch.setattr(jobs, "settings", eval_settings())
27
  env = jobs._base_env(run_id="universal-20260606-000000-abcd1234", username="alice", bucket_source="alice/space-factory-runs", worker_script_path="/output/runs/x/_worker.py")
28
+ assert env["ASF_EVAL_RECORD_ENABLED"] == "true"
29
+ assert env["ASF_EVAL_PUBLISH_MODE"] == "backend"
 
 
30
  assert env["ASF_EVAL_SALT"] == "test-salt"
31
+ assert "ASF_EVAL_BUCKET_SOURCE" not in env
32
+ assert "ASF_EVAL_BUCKET_MOUNT" not in env
33
 
34
 
35
+ def test_eval_bucket_is_not_mounted_as_user_job_volume(monkeypatch):
36
  monkeypatch.setattr(jobs, "settings", eval_settings())
37
  volumes = jobs._job_volumes("alice/space-factory-runs")
38
  rendered = [vars(v) if hasattr(v, "__dict__") else v for v in volumes]
39
  text = repr(rendered)
40
  assert "alice/space-factory-runs" in text
41
+ assert "huggingface/agentic-space-factory-evals" not in text
42
+ assert "/evals" not in text
43
+ assert len(volumes) == 1
44
 
45
 
46
  def test_workers_publish_anonymized_eval_records_without_raw_code_or_prompts():
tests/test_v178_run_storage_eval_status_polish.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+
3
+ ROOT = Path(__file__).resolve().parents[1]
4
+
5
+
6
+ def test_run_storage_eval_disabled_copy_is_compact():
7
+ js = (ROOT / 'web/static/app.js').read_text()
8
+ assert "'Eval archive off · set env vars'" in js
9
+ assert 'Anonymous project eval archive disabled for this instance.' not in js
10
+
11
+
12
+ def test_run_storage_eval_enabled_copy_is_compact_with_tooltip():
13
+ js = (ROOT / 'web/static/app.js').read_text()
14
+ assert 'Eval archive on ·' in js
15
+ assert 'ASF backend publishes anonymized eval records there after user Jobs write local run evals.' in js
16
+ assert 'Anonymous project eval archive enabled:' in js
17
+
18
+
19
+ def test_eval_feedback_is_a_small_pill_not_long_wrapping_copy():
20
+ css = (ROOT / 'web/static/app.css').read_text()
21
+ assert '.eval-feedback{display:inline-flex' in css
22
+ assert 'border-radius:999px' in css
23
+ assert '.eval-feedback.off' in css
tests/test_v179_eval_activation_prescan_polish.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+
3
+ ROOT = Path(__file__).resolve().parents[1]
4
+
5
+
6
+ def test_eval_archive_off_message_is_actionable():
7
+ js = (ROOT / "web/static/app.js").read_text()
8
+ assert "Eval archive off · set env vars" in js
9
+ assert "ASF_EVAL_ENABLED=true" in js
10
+ assert "ASF_EVAL_BUCKET_SOURCE=<namespace>/<bucket>" in js
11
+
12
+
13
+ def test_prescan_no_heavy_top_accent_bar():
14
+ css = (ROOT / "web/static/app.css").read_text()
15
+ assert ".model-prescan-card:before{display:none!important;content:none!important}" in css
16
+ assert "v179: calmer pre-scan surface" in css
17
+
18
+
19
+ def test_readme_documents_eval_activation_and_keeps_metadata_first():
20
+ readme = (ROOT / "README.md").read_text()
21
+ assert readme.startswith("---\ntitle: Agentic Space Factory")
22
+ assert "## Anonymous eval archive activation" in readme
23
+ assert "ASF_EVAL_BUCKET_MOUNT=/evals" in readme
24
+ assert "Bucket path: evals" in readme
tests/test_v181_backend_eval_archive_publish.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from pathlib import Path
5
+ from types import SimpleNamespace
6
+
7
+ from src import eval_archive, eval_config, jobs
8
+
9
+
10
+ def test_user_jobs_do_not_mount_private_operator_eval_bucket(monkeypatch):
11
+ monkeypatch.setattr(jobs, "settings", SimpleNamespace(
12
+ bucket_mount="/output",
13
+ bucket_runs_prefix="runs",
14
+ eval_enabled=True,
15
+ eval_bucket_source="fffiloni/agentic-space-factory-evals",
16
+ eval_bucket_path="evals",
17
+ eval_bucket_mount="/evals",
18
+ eval_salt="salt",
19
+ eval_include_redacted_tails=False,
20
+ ))
21
+ env = jobs._base_env(run_id="universal-20260606-000000-abcd1234", username="someone", bucket_source="someone/space-factory-runs", worker_script_path="/output/runs/x/_worker.py")
22
+ assert env["ASF_EVAL_RECORD_ENABLED"] == "true"
23
+ assert env["ASF_EVAL_PUBLISH_MODE"] == "backend"
24
+ assert "ASF_EVAL_BUCKET_SOURCE" not in env
25
+ assert "ASF_EVAL_BUCKET_MOUNT" not in env
26
+ volumes = jobs._job_volumes("someone/space-factory-runs")
27
+ assert len(volumes) == 1
28
+ assert "fffiloni/agentic-space-factory-evals" not in repr([vars(v) for v in volumes])
29
+
30
+
31
+ def test_backend_publishes_user_bucket_eval_record_to_mounted_operator_archive(tmp_path, monkeypatch):
32
+ user_bucket_files: dict[str, str] = {}
33
+ root = "hf://buckets/alice/space-factory-runs/runs/universal-20260606-000000-abcd1234"
34
+ user_bucket_files[f"{root}/eval_record.json"] = json.dumps({
35
+ "schema_version": "1.0",
36
+ "phase": "final",
37
+ "anonymous_run_id": "run_abc123",
38
+ "finished_at": "2026-06-06T16:00:00+00:00",
39
+ "outcome": {"status": "success"},
40
+ "privacy": {"tokens_stored": False, "raw_prompts_stored": False, "generated_code_stored": False},
41
+ "timeline": [{"stage": "start", "status": "success"}],
42
+ })
43
+ user_bucket_files[f"{root}/events_compact.jsonl"] = '{"stage":"start","status":"success"}\n'
44
+
45
+ def fake_read_json(path, token=None):
46
+ text = user_bucket_files.get(path)
47
+ return json.loads(text) if text else None
48
+
49
+ def fake_read_text(path, token=None):
50
+ return user_bucket_files.get(path)
51
+
52
+ def fake_write_json(path, payload, token=None):
53
+ user_bucket_files[path] = json.dumps(payload)
54
+
55
+ monkeypatch.setattr(eval_archive, "read_json", fake_read_json)
56
+ monkeypatch.setattr(eval_archive, "read_text", fake_read_text)
57
+ monkeypatch.setattr(eval_archive, "write_json", fake_write_json)
58
+ monkeypatch.setattr(eval_archive, "effective_eval_config", lambda: {
59
+ "enabled": True,
60
+ "bucket_source": "fffiloni/agentic-space-factory-evals",
61
+ "bucket_path": "evals",
62
+ "job_mount_path": str(tmp_path),
63
+ })
64
+
65
+ result = eval_archive.maybe_publish_eval_record(
66
+ "universal-20260606-000000-abcd1234",
67
+ bucket_source="alice/space-factory-runs",
68
+ token="fake",
69
+ state={"status": "success"},
70
+ )
71
+ assert result["published"] is True
72
+ dest = tmp_path / "2026" / "06" / "06" / "run_abc123" / "eval_record.json"
73
+ assert dest.exists()
74
+ assert json.loads(dest.read_text())["anonymous_run_id"] == "run_abc123"
75
+ status_path = f"{root}/eval_publish_status.json"
76
+ assert status_path in user_bucket_files
77
+ assert json.loads(user_bucket_files[status_path])["publish_mode"] == "backend"