Codex r1 on #380: iter(source) only mapped TypeError, so an __iter__
raising OSError, csv.Error or StopIteration (directly or as a PEP 479
RuntimeError) still leaked. Apply the same narrow provider-error and
cause-checked RuntimeError mapping at initialization; normal exhaustion
in next() is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow-ups from the #379 review:
- A StopIteration raised inside the live discovery generator (for
example from distribution.metadata["Name"]) became a RuntimeError under
PEP 479 and escaped the contract mapping. Only the converted form is
mapped; unrelated RuntimeErrors still surface.
- OSError and other provider errors raised while iterating a caller
supplied distribution source now map to ContractError.
- An OSError from os.close in _regular_file_digest no longer escapes the
finally block raw; a failed close never reports a digest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
installed_package_set_digest() normalized csv/Key/Type/Unicode errors from a
distribution's metadata, version and METADATA/RECORD reads, but an unreadable
metadata file (OSError, e.g. PermissionError) or a provider whose lookup
exhausts an iterator (StopIteration) escaped the contract instead of
surfacing as LMS_DEPENDENCY_DRIFT. Catch both.
Tests: a provider raising PermissionError/OSError from METADATA/RECORD reads
and StopIteration from .version and .metadata maps to ContractError.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r2:
- The exempt checkout egg-info path was fully resolved, so a symlink to
another checkout's or a user-site egg-info resolved to that install and
exempted it. Canonicalize only the checkout root and append
obliteratus.egg-info unresolved; a symlinked egg-info, or one resolving
outside the checkout, raises ContractError.
- A RECORD field over csv.field_size_limit made distribution.files raise
csv.Error outside the normalization. Catch it wherever RECORDs are
parsed, so it maps to LMS_DEPENDENCY_DRIFT.
Tests: a symlinked checkout egg-info pointing at an external install that
is also visible (and one pointing back inside the checkout); an oversized
RECORD field for obliteratus and a third-party distribution, directly and
through both GPU candidate tiers; the site-containment guard on its own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r1: the exemption dropped any obliteratus.egg-info outside the
prefix sites, so a user-site, system-site or other-checkout install could
hide behind an approved digest. Exempt only the canonical
<checkout>/obliteratus.egg-info of the source tree this module runs from
(model_identity.py parents[2]); from an installed wheel that path is
inside a site dir and nothing is exempt. Every other visible obliteratus
distribution fails closed again.
A malformed RECORD made distribution.files raise ValueError outside the
normalization; it is now ContractError, so model_session reports
LMS_DEPENDENCY_DRIFT.
Tests: conflicting external egg-info (dir and file, before and after the
wheel on sys.path), symlinked checkout paths, prefix egg-info from a wheel,
malformed RECORD -> LMS_DEPENDENCY_DRIFT on both GPU candidate tiers, and
PEP 660 / .egg-link editable layouts failing closed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A non-editable install from a checkout leaves an untracked, gitignored
obliteratus.egg-info in the source root. The llama-tp gate and its TP
workers run with the checkout on sys.path, so importlib.metadata also
discovered that egg-info. installed_package_set_digest() enumerates every
visible distribution, so the stale build artifact broke the live package
identity (LMS_DEPENDENCY_DRIFT) before any hardware evidence was written.
model_identity now locates exactly one .dist-info for obliteratus under
the active prefix's purelib/platlib, requires its RECORD to own the
package that PathFinder finds there, and fails closed otherwise (no
wheel, egg-only, duplicate or disagreeing installs, ownership mismatch).
A setuptools source-tree obliteratus.egg-info outside the site dirs is
excluded from the inventory only after that wheel is found. All other
metadata/RECORD and duplicate checks are unchanged; a clean install keeps
the same digest.
run_conditional_gate.py refuses llama-tp-local-gpu up front (not_run,
exit 2, actionable message) when the checkout root holds an
obliteratus.egg-info, before any probe or GPU time; --allow-missing does
not bypass it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of 5a4835e: with no manifest global shape, a sharded head fell back
to mutable config.vocab_size, so 16-row shards with config vocab 16 passed
on both ranks. A vocab-sharded head now needs the manifest global row
extent corroborated by the live local weight shape and a complete even
shard layout (local rows x world size, per-rank start/end and rank
shards); config alone never establishes it, and anything else fails closed
with LMS_VERIFY_FORWARD_CONTRACT in baseline and post-edit revalidation.
Docs state the exact rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of 579125a:
- For a vocab-sharded head the observed logits width was accepted as the
vocabulary, so identical shard-width outputs passed. The width must now
match the manifest global row extent (config as fallback); without a
trusted extent VERIFY fails closed with LMS_VERIFY_FORWARD_CONTRACT.
- Refusal decisions took argmax over the full padded width, so a model-only
column could win and hide a refusal. Selection is restricted to tokenizer
ids; full-width log_softmax and finiteness checks are unchanged.
- Adds real 2-process gloo cases (padded vocab, shard-width mismatch, rank
width disagreement) asserting identical exact codes and rollback, and
tightens the gloo code-agreement test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VERIFY's batch forward vote required logits.shape[2] == plan.vocab_size,
where plan.vocab_size is the tokenizer vocabulary. Models commonly pad
their output vocabulary beyond the tokenizer (the TP2 fixture: 32 vs 9;
also Llama-3, Qwen), so VERIFY rejected them, and any contract or
forward failure was reported as LMS_VERIFY_NONFINITE. Found on 2x A100
(llama-tp-local-gpu baseline: logits (2,2,32), tokenizer vocab 9, all
finite).
- New closed codes LMS_VERIFY_FORWARD_FAILED (forward raised) and
LMS_VERIFY_FORWARD_CONTRACT (logits type/layout/shape/vocab/device/
dtype or rank disagreement); NONFINITE is finiteness-only. Votes run in a
fixed order so every rank raises the same code.
- Output width must equal the model's own vocabulary (replicated head
weight, out_features or config; observed and rank-agreed width for a
sharded head), be >= the tokenizer vocabulary, and match between the
pristine and post-edit evaluations. Token ids stay tokenizer-bounded.
Memory admission accounts for the full output width.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of 91227c3: toggling Transformers progress bars also flips
huggingface_hub global and per-group progress state, and the disable ran
outside the restore boundary. The guard now captures the Transformers
flag and the Hub global and group state, disables inside try/finally, and
restores each piece exactly (best effort per piece, never masking the
original exception). Only the resource tracker is pre-started; forkserver
is not claimed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Native TP load set ParameterManifestEntry.local_value_digest and
replicated_value_digest with model._tensor_digest (sha256 of raw bytes),
while EXCISE (_build_operation_plan) and VERIFY (_logical_state_roots with
require_manifest_values) compare probe_contracts.tensor_digest (dtype +
shape + bytes). The pristine-digest check could therefore never pass on
the native TP path: both ranks of llama-tp-local-gpu on 2x A100 failed
EXCISE with "mutable parameter storage or pristine digest changed".
Load now uses probe_contracts.tensor_digest and the raw-bytes helper is
deleted; hashing failures keep LMS_RUNTIME_PROFILE_MISMATCH. A CPU
contract test builds the manifest through the real load-validation path
and feeds it to the real EXCISE admission and VERIFY value checks
(accept unchanged, reject one-element mutation), plus BF16/FP32 digest
identity.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On 2x A100 the native TP2 session failed in two ways inside the fd
redirect containment:
- a multiprocessing.resource_tracker started lazily during the redirect
inherited the sink pipe as stdout, so the reader never saw EOF and
teardown hard-exited 70;
- transformers' "Loading weights" progress bar wrote to stderr and
tripped LMS_DIAGNOSTIC_REDACTION_FAILED.
Start the resource tracker before redirecting, and disable transformers
progress bars while either guard is active (restored afterwards). Real
output still fails closed; a hung reader still exits 70.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes eight reported defects in the native tensor-parallel path:
- #278 VERIFY admits host memory in a symmetric vote before allocating
and broadcasting baseline input tensors.
- #280 require_record_consensus canonicalizes inside the poison-protected
exchange and compares canonical payloads.
- #282 EXCISE votes on fallible digest preparation before the next
collective.
- #285 preflight, model session, PROBE and EXCISE vote on rank-local
preparation failures before the next collective, including the
evidence-directory preparation that previously allocated before its
all_reduce.
- #275 postcondition and VERIFY digest sets stream the full declared
operation range (up to MAX_EXCISE_OPERATIONS) while preserving
existing identities.
- #281 preflight source identity digests stream inventory records
instead of using one 64 KiB control record.
- #286 the evidence checker requires an integer schema_version and
checkout/source inventories are bounded and streamed.
- #276 standalone operation planning uses bounded chunked finite checks.
Each fix has CPU/Gloo regression tests, including one-rank fault cases.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Private records are published by linking a fully written temporary file to
the target name and then unlinking the temporary name. A peer polling for
terminal evidence (or the coordinator polling receipts/acknowledgements)
can open the target inside that window, see st_nlink == 2, and get a raw
ContractError. _wait_for_evidence only retried FileNotFoundError, so the
non-coordinator rank escaped execute_preflight with an uncoded error (CI
saw {'LMS_RESOURCE_ADMISSION_DENIED', None}); on the success path the same
race made one rank fail while the coordinator published "preflighted".
Readers now raise PrivateRecordPending (a ContractError) for an extra link,
bounded pollers retry it like an absent record until their deadline, and
_wait_for_evidence converts any other read failure to the stable
LMS_EVIDENCE_UNAVAILABLE code so no rank leaves without a code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If the layout gather or record comparison raised, the exception skipped
AgreedTopologyRefusal, and execute_preflight then ran filesystem recovery.
Every layout-admission exception now becomes the terminal
AgreedTopologyRefusal. A local construction failure enters the gather with
an invalid record, so its peer is poisoned in the same exchange. Ordinary
failure evidence still runs only after successful admission. The docs now
place layout admission before lifecycle identity consensus.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two-host refusal used local config fields, but lifecycle consensus binds
only the stored config digest, which a dataclasses.replace does not
recompute. One rank could refuse while its peer entered staging.
Every rank now gathers a fixed-size record of its actual layout (backend,
device kind, world and local sizes, observed launcher geometry) through the
poison-protected record gather before lifecycle consensus and staging. If
any rank refuses or the records differ, every rank raises the terminal
AgreedTopologyRefusal with no storage side effects. run_preflight,
execute_preflight and the live session share this single admission point.
Regressions cover the stale-digest counterexample, two-host refusal, and
unchanged one-host and CPU success and failure paths.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
execute_preflight caught the agreed two-host refusal as an ordinary failure
and then ran its filesystem recovery: the rank-0 attempt directory,
terminal receipts and shared evidence. On independent host storage that
produced asymmetric CLEANUP_INCOMPLETE and EVIDENCE_UNAVAILABLE outcomes.
A dedicated AgreedTopologyRefusal (LMS_TOPOLOGY_UNSUPPORTED) now passes
through execute_preflight, the CLI and the live model session without
touching attempt, receipt, evidence or cleanup storage. One-host and
CPU-protocol failure handling is unchanged. Tests drive both mocked ranks
through every wrapper, forbid the storage helpers, and keep the one-host
receipt and evidence path as a must-not-regress check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The archived topology commits predate the merged EXCISE, VERIFY and
EXPORT stages. A cross-stage audit for the one-GPU-per-host layout found:
- Live preflight and LOADED evidence use attempt storage shared by the
ranks (rank-0 directory, nonce file, file receipts). They now refuse the
two-host GPU layout after configuration consensus and before any
staging access (LMS_TOPOLOGY_UNSUPPORTED; the model session reports
LMS_TP_PLAN_UNSUPPORTED).
- Canonical EXPORT assumes one shared destination tree across writer
ranks. It now refuses the layout with a voted
LMS_EXPORT_TOPOLOGY_UNSUPPORTED before any resource or filesystem work.
- PROBE admitted host memory only on rank 0. Each rank now admits its own
working set through the existing unanimous vote.
- The evidence checker reconstructs each attempt's topology from
fixed-size redacted records. EXPORT's attempt hash binds the VERIFY
binding set, and part 5's per-attempt hardware and mount checks are kept.
EXCISE, rank journals, VERIFY and the launcher are code-level compatible
and are covered by new mocked tests. Docs describe the refusals.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2f164f69b0772db27e878905b26ff3eeb8478f2b)
Ported for #244 (part 6/6).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 37f407850916ebe76575d73112c4d26fe08bf421)
Ported for #244 (part 6/6). Internal-only content from the archived
commit was dropped: .aiwg records and the internal security-docs test.
Doc and test conflicts keep upstream wording and add only the topology
references; internal tracker numbers were replaced with upstream framing.
Marked experimental in user docs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings the ported canonical export up to the rules from parts 3 and 4:
- Every rank-local step that can raise is followed by a unanimous control
vote before the next collective. This covers reconstruction, file I/O,
safetensors write and reload, digests, validation, fault hooks and record
construction. EXPORT votes use [17_000_000, 24_000_000).
- Tensor, file and index aggregates use streamed, domain-separated,
length-prefixed digests (streamed_contract_digest), so every advertised
limit works. Oversized HF indexes are refused before any write.
- One combined, voted host admission covers reconstructed tensors, gather
buffers, serialization and reload copies, chunked digest and finite
checks, metadata and the still-live VERIFY state.
- VERIFIED revalidation uses the guarded #274 helpers and logical roots, and
requires the released journal.
- Cancellation and the deadline are rechecked before promotion and before
return. Files are rehashed at the final gate. Cleanup or confirmation
failure quarantines as LMS_EXPORT_STATE_UNCERTAIN, and strict backup
cleanup never restores a partially deleted backup.
- Single-tensor output uses indexed naming. The HF index payload helper
is shared with checkpoint_writer, with identical output.
- Docs use the upstream #244 framing and are marked EXPERIMENTAL.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit de990f633e151f329ef5e844ed55f60a9a0b247c)
Ported for #244 (part 5/6). Internal-only content from the archived
commit was dropped: .aiwg records and the internal security-docs test.
Doc and policy conflicts keep upstream wording and add only the export
references. The new Gloo test file carries the gloo marker and a
duration entry. Marked experimental in user docs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The whole-model parameter-root, corpus-metadata, sample-id and snapshot
aggregates were each a single bounded control record, so baseline
preparation failed past about 418 parameters even though larger models
are admitted. They are now streamed SHA-256 aggregates: a versioned
prefix, distinct domains, and length-prefixed canonical per-item records.
Only the 32-byte digest is exchanged through the symmetric consensus
primitives. Every advertised sample and parameter limit now works.
PROBE and EXCISE digests are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Whole-parameter and snapshot finite checks on VERIFY paths now walk the
same bounded C-order chunks as tensor_digest, staying within the reserved
8 MiB working term. VERIFY's combined admission also counts EXCISE's CPU
projection storage when tensors live on the host. Standalone EXCISE
planning is unchanged. Digest regressions now cover rank-3/4 permuted
views, stepped slices and non-contiguous leading singleton and zero
dimensions, checked against the previous whole-tensor algorithm.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tensor_digest streams the canonical bytes through 4 MiB CPU chunks in
C order. Digests are byte-identical to the previous whole-tensor
serialization for every dtype (BF16 included), shape and stride, and
numerical._tensor_digest reuses it. VERIFY reserves the bounded 8 MiB
digest working set explicitly.
- The live VERIFY wrapper performs one unanimous combined host admission
before EXCISE starts: retained baseline + EXCISE's own journal and
restoration working set + VERIFY's peak + margin, against a single
memory observation. It denies with LMS_EXCISE_RESOURCE_DENIED before
any mutation. Rollback releases post-edit snapshots before loading the
journal.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Quality metrics are reduced in bounded 16-row chunks with float64
accumulators, so the KL intermediates no longer scale with the whole
snapshot. Padded log-probability batches are released inside the existing
voted steps. Host admission now budgets an explicit peak:
inputs + two retained snapshots + max(forward/log-prob batch, metric chunk)
+ margin. Tests cover the analytic peak, live allocation sizes, batch
lifetimes and numerical equivalence with the unchunked metrics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Rollback after a VERIFY failure now proves the whole model against the
pristine baseline (voted, with consensus) before lifecycle emission or
journal deletion. EXCISE alone proves only its edited operations. A
failed proof keeps the journals, quarantines and reports
LMS_VERIFY_STATE_UNCERTAIN instead of a clean rollback.
- Inference-mode setup moved inside the preparation vote, so nothing
fallible sits between the vote and the TP forward. Failures inside
the forward are documented as the bounded timeout / rank-loss boundary
and tested with a real internal all_reduce.
- Retained logit rows are cloned out of the padded batch, so retained
storage equals the admitted bytes.
- The hardware evidence checker validates each attempt against its own
mount attestation while still requiring the same physical host and GPUs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adapt the ported VERIFY stage to the symmetric-failure consensus model
from part 3. Every rank-local step that can raise outside the consensus
primitives (plan/record preparation, tensor broadcasts and copies, forward
inputs, metrics, digests, evidence, summary and result construction) is
followed by a unanimous control-group vote before the next collective, and
raw records go straight into the symmetric primitives. VERIFY votes use a
dedicated sequence range disjoint from EXCISE.
Rollback now requires unanimous committed eligibility and goes through the
hardened EXCISE restoration. Journal cleanup or lifecycle failure after
acceptance quarantines with LMS_VERIFY_STATE_UNCERTAIN, and cancellation
and the deadline are rechecked before the journal is deleted and before
VERIFIED is returned. Docs use the upstream #244 framing and are marked
EXPERIMENTAL.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2fbc38cd512f1130b4931ba5a7ffaf2e666d3008)
Ported for #244 (part 4/6). Internal-only content from the archived
commit was dropped: .aiwg records and the internal security-docs test.
Doc conflicts keep upstream wording and add only the VERIFY references.
The new Gloo test file carries the gloo marker and a duration entry.
Marked experimental in user docs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A rank-local preparation failure in gloo_all_gather_records,
require_consensus_digest or unanimous_vote now still joins the same
fixed-shape all_gather with a poison payload; the failing rank re-raises its
own error and every peer raises ContractError, so no rank can leave for a
different collective. The fixed-buffer/identical-bytes boundary is documented
as the process-fault limit handled by the bounded timeout and rank-loss path.
EXCISE now checks cancellation and the deadline after the final operation
before returning COMMITTED, and public rollback's ABORTING/ABORTED lifecycle
emissions are covered by quarantine handling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every rank-local step that can raise inside distributed_project_weight
(validation, FP32 promotion, digests, reduction buffers) and the EXCISE
pre-update, prepared-update and rollback digests is now followed by a
unanimous control-group vote, so a one-rank failure cannot leave its peer
in a different data collective. Callers without a control group keep their
previous exceptions.
RankJournal.create() keeps ownership until both directory descriptors close;
every finalizer is attempted, and close failures surface as
LMS_EXCISE_STATE_UNCERTAIN instead of masking an earlier cleanup failure.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Vote after each rank-local preparation step (clone, direction copy,
finite projection result) so a local failure cannot desynchronize the
projection collectives.
- Bind directions to the stored DISTILLED summary digests instead of
re-hashing the current tensors.
- Clean up a journal whose creation failed after entries were written,
surface cleanup failures as LMS_EXCISE_STATE_UNCERTAIN, close
descriptors on rejected opens, and fsync the parent directory on
journal creation and removal.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9dcae3a30aac5c74c0eaa567d9682b1aadba3003)
Ported for #244 (part 3/6).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ba6e1bb45a964dd0980b2e1440debd93cf94da45)
Ported for #244 (part 3/6). Internal-only content from the archived
commit was dropped: .aiwg records and the internal security-docs test.
The new Gloo test file carries the gloo marker and a duration entry.
Marked experimental in user docs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f9a289e267889c297cefcdc67eea92c4b8eb8d4d)
Ported for #244 (part 2/6). Internal-only content from the archived
commit was dropped: .aiwg records and the internal security-docs test.
Marked experimental in user docs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rank 0 evidence-directory creation now feeds a collective vote so a
mkdir failure fails every rank promptly instead of leaving the peer
blocked in a barrier. The public API fingerprint helper accepts only the
reviewed critical-module allowlist. Declare the TP runner labels for
actionlint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4caf45b04a8faa55f191b22c069f58714236689b)
Ported for #244 (part 1/6). Internal-only content from the archived
commit was dropped: .aiwg records, internal runner-policy routing, and the
internal security-docs test. Marked experimental in user docs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>