abc_mine.manifest¶
WARNING
This documentation is almost entirely "vibe coded"; while a helpful resource for humans and agents to understand this codebase, it should not be considered a source of ground truth in the way documentation normally is, and the user is responsible for verifying that all instructions given here are safe.
abc_mine.manifest
¶
Run manifest: provenance, configuration locking, and drift detection.
At init a run writes <run_dir>/run.json: a strong record of what this
run is — the resolved configuration, the codebase's git identity, the container
image digest, tool versions, the model endpoint and model id, the rubric in
force, and any active prompt overrides. Every subsequent stage compares its own
resolved configuration against that record and refuses to continue on drift
unless explicitly allowed.
Why drift detection matters
A screening sweep over a large history is not atomic; it may span several Slurm allocations across days. Without a lock it is entirely possible to screen half a history at one set of rubric weights and the other half at another, then rank the union as though the scores were comparable. They would not be, and nothing in the output would say so. The lock makes that failure loud instead of silent.
Provenance is not reproducibility
This is worth stating plainly, because the two are easy to conflate. The manifest records what was used; it cannot make a run reproducible. Agents are nondeterministic, and a model id behind an endpoint can be repointed without the id changing. So:
- Re-running a completed run will not reproduce it byte-for-byte.
- Per-item records carry their own model id and timestamp, so a resumed run's provenance is auditable at item granularity — you can always tell which items were judged when, and under what settings.
Treat the manifest as an audit trail, not a guarantee of determinism.
Severity model
Not every change is equally dangerous, so drift is classified:
critical
Changes that invalidate comparisons between already-finished and future items
— the rubric, the codebase, commit selection, prompt content. Blocks.
warning
Changes that affect throughput or retention but not comparability —
parallelism, worker count, log retention. Recorded, never blocks.
exempt
Values that legitimately rotate between allocations — the endpoint URL, the
scratch directory. Noted only.
The model id is deliberately critical: screening half a history with a cheap model and half with a frontier model produces incomparable scores, which is exactly the failure the lock exists to prevent.
ManifestError
¶
Drift
dataclass
¶
One detected configuration difference.
Attributes:
| Name | Type | Description |
|---|---|---|
key |
str
|
Dotted config key. |
old, new |
Any
|
The locked value and the current value. |
severity |
str
|
|
Source code in abc_mine/manifest.py
Manifest
dataclass
¶
A loaded or freshly created run manifest.
Source code in abc_mine/manifest.py
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 395 396 | |
save
¶
Write the manifest atomically.
The temporary file name includes the pid so concurrent writers cannot
collide. A single shared run.json.tmp is not safe under a parallel
launcher: every rank would write the same path and then rename it, the first
rename would succeed, and the rest would fail with FileNotFoundError
because their temp file had already been moved out from under them.
Writers should normally be limited to rank 0 (see :meth:record_stage);
the per-pid name makes the operation safe regardless.
Source code in abc_mine/manifest.py
record_stage
¶
Append a stage-invocation record and persist immediately.
Every stage start is logged with its timestamp, host, Slurm job id, and the
resource environment it ran in (see :func:resource_environment), so a run
assembled from several allocations can be reconstructed after the fact.
Source code in abc_mine/manifest.py
Attempt
dataclass
¶
digest_container
¶
Return a cheap but change-sensitive identity for a container image.
A full hash of a multi-gigabyte SquashFS on every stage start would be
wasteful, so for regular files this records size:mtime_ns — enough to
notice a rebuilt or swapped image. Unpacked image directories are
summarized by their top-level entries. Small images (<64 MiB) get a real
SHA-256, since it is cheap enough to be worth the precision.
Source code in abc_mine/manifest.py
digest_prompt_pack
¶
digest_prompt_pack(pack: PromptPack) -> str
Return a content digest over every slot and override in a pack.
Content-based rather than path-based: editing a slot file in place must count
as drift, since it changes what every subsequent agent is told. Returns
"none" for an empty pack so a stock run has a stable marker.
Source code in abc_mine/manifest.py
git_identity
¶
Return the git identity of repo: HEAD, commit count, and remote.
Source code in abc_mine/manifest.py
tool_versions
¶
Return versions of the external tools whose behaviour affects a run.
Source code in abc_mine/manifest.py
config_fingerprint
¶
config_fingerprint(cfg: MineConfig, pack: PromptPack, model: Mapping[str, str]) -> dict[str, Any]
Build the flat, comparable fingerprint that drift detection operates on.
Flat dotted keys (rather than the nested config) keep comparison and
reporting simple, and make the severity tables above directly indexable.
Deliberately excluded: the API key (never recorded anywhere) and run.id /
data_root (identity of the run, not settings within it).
Source code in abc_mine/manifest.py
launcher_rank
¶
Return this process's rank under a parallel launcher, or 0 if not launched.
Read from the launcher's environment rather than by importing mpi4py: this is consulted on paths where MPI may be unavailable or broken, and it must work before MPI is initialized.
Source code in abc_mine/manifest.py
resource_environment
¶
Capture the compute resources a stage invocation was given.
Why this is recorded but not gated on
Resource settings -- how many CPUs, how many concurrent workers, how wide each
build may be -- change how fast a run goes, not what it decides. Screening
the same commit with BUILD_JOBS=8 or BUILD_JOBS=224 should produce the
same verdict, so treating a change as drift would block resumes for no reason:
you would be unable to continue a sweep on a differently-sized allocation, which
is precisely what resumability is for.
They are still worth recording, because they are not entirely inert. A build's
measured duration depends on its width, and that duration reaches the agents:
toolchain.full_build_seconds is rendered into every prompt, and the rubric's
verify_cost axis asks agents to weigh verification cost against it. So a
figure measured with the node's full core count and one measured under a modest
cgroup will bias that axis differently -- not by changing the rules, but by
changing what "expensive" looks like.
That makes resources a provenance concern rather than a correctness gate. The measured timings themselves already sit in the fingerprint at warning severity, so a changed measurement is reported; this records the conditions that produced it, so the report can be interpreted.
Only variables that are set are included, so the record stays honest about what was actually known rather than implying defaults.
Source code in abc_mine/manifest.py
create
¶
create(cfg: MineConfig, pack: PromptPack, model: Mapping[str, str], *, notes: str = '') -> Manifest
Create and write a fresh run manifest.
Raises:
| Type | Description |
|---|---|
ManifestError
|
If a manifest already exists for this run. Re-initializing would discard
the lock that makes existing outputs interpretable, so it must be an
explicit act (delete the run directory, or choose a new |
Source code in abc_mine/manifest.py
load
¶
load(cfg: MineConfig) -> Manifest
Load the run manifest for cfg.
Raises:
| Type | Description |
|---|---|
ManifestError
|
If it is missing (the run was never initialized) or unparseable. |
Source code in abc_mine/manifest.py
detect_drift
¶
detect_drift(manifest: Manifest, cfg: MineConfig, pack: PromptPack, model: Mapping[str, str]) -> list[Drift]
Compare the current configuration against the locked fingerprint.
Returns every difference found, each classified by severity. An empty list means the current invocation matches the run's lock exactly.
Source code in abc_mine/manifest.py
format_drift_report
¶
format_drift_report(drifts: Iterable[Drift], *, allowed: bool) -> str
Render a drift report for the terminal, grouped by severity.
Source code in abc_mine/manifest.py
enforce
¶
enforce(manifest: Manifest, cfg: MineConfig, pack: PromptPack, model: Mapping[str, str], *, allow_drift: bool = False) -> list[Drift]
Check for drift and raise on unapproved critical drift.
Also records approved critical drift into the manifest, so a mixed run carries permanent evidence of when it became mixed and what changed — which is the whole point of allowing the override at all.
Raises:
| Type | Description |
|---|---|
ManifestError
|
If critical drift is present and |
Source code in abc_mine/manifest.py
record_attempt
¶
record_attempt(path: Path, item_id: str, status: str, *, detail: str = '', model_id: str = '', **extra: Any) -> None
Append one attempt record to an append-only JSON-Lines log.
This closes a real gap in the original pipeline: a failed screen wrote
nothing at all, so "never attempted" and "attempted and failed five times"
were indistinguishable, retries were unbounded across resumes, and the
transcripts had already been deleted. Recording attempts makes failure
countable (so :func:attempt_counts can enforce max_attempts) and
diagnosable.
Concurrency: each call writes a single complete line in O_APPEND mode,
which POSIX makes atomic for small writes, so parallel workers on a shared
filesystem never interleave partial lines.
Source code in abc_mine/manifest.py
read_attempts
¶
Read every attempt record, skipping malformed lines.
Malformed lines are skipped rather than fatal: a log truncated by a killed job should not prevent the resume it exists to support.
Source code in abc_mine/manifest.py
attempt_counts
¶
Count attempts per item, optionally filtered to one status.
Source code in abc_mine/manifest.py
exhausted_items
¶
Return items whose failed-attempt count has reached max_attempts.
Used by the stages to skip items that keep failing, instead of burning the whole budget re-attempting one pathological commit on every resume.