| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def test_job_passes_hf_token_secret_aliases_for_pi_and_hf_tools(): | |
| jobs = (ROOT / "src" / "jobs.py").read_text(encoding="utf-8") | |
| assert 'secrets={"HF_TOKEN": token, "HUGGING_FACE_HUB_TOKEN": token}' in jobs | |
| assert "not regular env metadata" in jobs | |
| def test_worker_verifies_and_redacts_token_context(): | |
| worker = (ROOT / "src" / "worker_payload.py").read_text(encoding="utf-8") | |
| assert "def ensure_hf_token_context" in worker | |
| assert "token_context.json" in worker | |
| assert '"token_value": "[REDACTED]"' in worker | |
| assert "os.environ.setdefault(\"HUGGING_FACE_HUB_TOKEN\", token)" in worker | |
| assert "Verified HF token context for Pi/HF operations" in worker | |
| def test_pi_prompts_include_tooling_context_and_continue_same_run_instruction(): | |
| worker = (ROOT / "src" / "worker_payload.py").read_text(encoding="utf-8") | |
| assert "def pi_tooling_context_note" in worker | |
| assert "HF_TOKEN and HUGGING_FACE_HUB_TOKEN aliases" in worker | |
| assert "Never print, write, echo, or commit token values" in worker | |
| assert "You are continuing the same build run, not starting a separate project" in worker | |
| assert "{pi_tooling_context_note()}" in worker | |
| def test_incident_and_repair_briefs_include_redacted_token_context(): | |
| worker = (ROOT / "src" / "worker_payload.py").read_text(encoding="utf-8") | |
| assert "## HF tooling/token context" in worker | |
| assert 'load_json_if_exists(run_dir / "token_context.json")' in worker | |