-
Notifications
You must be signed in to change notification settings - Fork 16
feat(landmine): port prod hotpatch landmines into main #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fef7077
d6aafe0
442553e
4cabde6
ca86419
4cbe66b
7442dbb
ae45ab2
9d5563f
a4bc4ed
9f63b9d
334e041
9c11248
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |
|
|
||
| from .checkpoints import resolve_checkpoint_artifact_path | ||
|
|
||
| DEFAULT_CHECKPOINT_REPO_ID = "baseintelligence/prism-checkpoints" | ||
| DEFAULT_CHECKPOINT_REPO_ID = "BaseIntelligence/top-prism-architecture" | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
|
|
@@ -115,6 +115,53 @@ def call_count(self) -> int: | |
| return len(self.uploads) | ||
|
|
||
|
|
||
| @dataclass | ||
| class DisabledCheckpointPublisher: | ||
| """No-op publisher: Prism HF checkpoint upload is intentionally OFF on this host. | ||
|
|
||
| publish() records the call but never contacts HuggingFace. download() raises so | ||
| resume-from-public-checkpoint is unavailable while upload is disabled. | ||
| """ | ||
|
|
||
| repo_id: str = DEFAULT_CHECKPOINT_REPO_ID | ||
| uploads: list = field(default_factory=list) | ||
| published: list = field(default_factory=list) | ||
|
|
||
| def publish(self, upload: CheckpointUpload) -> PublishedCheckpoint: | ||
| self.uploads.append(upload) | ||
| result = PublishedCheckpoint( | ||
| checkpoint_ref=checkpoint_ref_for(self.repo_id, upload.revision), | ||
| repo_id=self.repo_id, | ||
| revision=upload.revision, | ||
| files=tuple(upload.files), | ||
| ) | ||
| self.published.append(result) | ||
| return result | ||
|
|
||
| def download(self, checkpoint_ref: str, dest_dir: Path) -> Path: | ||
| raise RuntimeError( | ||
| "prism_checkpoint_upload_disabled: download unavailable while " | ||
| "PRISM_CHECKPOINT_UPLOAD_ENABLED is false" | ||
| ) | ||
|
Comment on lines
+120
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Locate resume-on-reassignment call sites that use checkpoint_ref/download()
rg -n -C3 'resume_checkpoint_ref|checkpoint_ref' --type=py -g '!**/tests/**' packages/challenges/prism/src/prism_challengeRepository: BaseIntelligence/base Length of output: 50377 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== checkpoint_publisher relevant sections =="
sed -n '1,240p' packages/challenges/prism/src/prism_challenge/evaluator/checkpoint_publisher.py
echo
echo "== container resume checkpoint code =="
sed -n '320,365p' packages/challenges/prism/src/prism_challenge/evaluator/container.py
sed -n '640,685p' packages/challenges/prism/src/prism_challenge/queue.py
sed -n '365,390p' packages/challenges/prism/src/prism_challenge/queue.py
echo
echo "== call sites that resolve checkpoint publisher =="
rg -n -C4 '_resolve_checkpoint_publisher|PrismCheckpoint|PrismCheckpointPublisher|HF_CHECKPOINT|CHECKPOINT_UPLOAD' packages/challenges/prism/src/prism_challenge -g '*.py'Repository: BaseIntelligence/base Length of output: 21704 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== checkpoint_intake publish handling =="
sed -n '100,195p' packages/challenges/prism/src/prism_challenge/evaluator/checkpoint_intake.py
echo
echo "== app/v2 checkpoint intake endpoint handling =="
sed -n '260,320p' packages/challenges/prism/src/prism_challenge/app.py
echo
echo "== repository record/latest checkpoint reference error handling =="
sed -n '330,370p' packages/challenges/prism/src/prism_challenge/repository.py
sed -n '1040,1100p' packages/challenges/prism/src/prism_challenge/repository.py
echo
echo "== all publish calls with exception handling =="
rg -n -C4 '\.publish\(|publisher_from_env|CheckpointPublishError|last_checkpoint_ref|record.*checkpoint' packages/challenges/prism/src/prism_challenge packages/challenges/prism -g '*.py' | head -n 220Repository: BaseIntelligence/base Length of output: 33927 Make the disabled checkpoint ref unusable for resume instead of resolvable.
🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| def publisher_from_env( | ||
| *, | ||
| repo_id: str | None = None, | ||
| token: str | None = None, | ||
| ) -> CheckpointPublisher: | ||
| """Return HF publisher only when upload is explicitly enabled; else disabled no-op.""" | ||
| import os | ||
|
|
||
| enabled = (os.environ.get("PRISM_CHECKPOINT_UPLOAD_ENABLED") or "false").strip().lower() | ||
| if enabled in ("1", "true", "yes", "on"): | ||
| return HuggingFaceCheckpointPublisher( | ||
| repo_id=repo_id or DEFAULT_CHECKPOINT_REPO_ID, | ||
| token=token, | ||
| ) | ||
| return DisabledCheckpointPublisher(repo_id=repo_id or DEFAULT_CHECKPOINT_REPO_ID) | ||
|
|
||
|
|
||
| class HuggingFaceCheckpointPublisher: | ||
| """Deploy-time publisher backed by ``huggingface_hub`` (imported lazily; mocked in tests). | ||
|
|
||
|
|
@@ -143,9 +190,17 @@ def _hf_api(self) -> Any: | |
| return self._api | ||
|
|
||
| def publish(self, upload: CheckpointUpload) -> PublishedCheckpoint: | ||
| import os | ||
|
|
||
| enabled = (os.environ.get("PRISM_CHECKPOINT_UPLOAD_ENABLED") or "false").strip().lower() | ||
| if enabled not in ("1", "true", "yes", "on"): | ||
| raise RuntimeError( | ||
| "prism_checkpoint_upload_disabled: refusing HuggingFace upload " | ||
| "(set PRISM_CHECKPOINT_UPLOAD_ENABLED=true to re-enable)" | ||
| ) | ||
| files = _read_checkpoint_files(upload) | ||
| api = self._hf_api() | ||
| api.create_repo(repo_id=self.repo_id, repo_type="model", exist_ok=True, private=True) | ||
| api.create_repo(repo_id=self.repo_id, repo_type="model", exist_ok=True, private=False) | ||
| for name in files: | ||
| source = resolve_checkpoint_artifact_path(upload.checkpoint_dir, name) | ||
| api.upload_file( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
_safe_error_messageredaction is heuristic-only and untested for the redaction branch itself.Redaction only fires when the raw exception text contains one of a handful of literal markers (
hf_token,authorization:,bearer,api_key=,token=). A bare secret value embedded without one of these markers (e.g., a raw HF token or key surfaced by a library error) passes straight through into the logged/HTTP-502 error message. Since this function has no access to the actual configured token value, it can't scrub an exact match either. Per coding guidelines, secrets/full token values must never be logged.Consider passing the known secret value(s) (e.g., the publisher's token) into this function so it can scrub exact matches, in addition to (or instead of) the marker heuristic. Also, none of the added tests actually construct an exception whose message contains one of these markers to verify the redaction path triggers.
As per coding guidelines, "Never log, document, or include evidence containing private keys, wallet mnemonics, API tokens, or full secret values; only names, digests, and SHAs are permitted."
🛡️ Proposed direction
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines