Skip to content

A leased adapter comes back: the origin pulls it by verified ranges into its own job directory, and both ends advertise training_lease_return (card 92cd2251, S3-2) - #5419

Merged
joelteply merged 4 commits into
canaryfrom
92cd2251/lease-artifact-pull
Oct 25, 2026
Merged

joelteply merged 4 commits into
canaryfrom
92cd2251/lease-artifact-pull

Conversation

@joelteply

@joelteply joelteply commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What this serves

This is path step 3 (Learning) across the grid: a resident on a weak node gets an adapter trained on a stronger peer, and it comes back into her own genome, where the examiner sits it on held-out work. It completes the cross-grid training lease's return (S3 of card 6f05b89d) after #5418, and is the change that turns leasing on.

Change

Receiver: genome/lease/artifact {attempt, file, offset, len}.

  • It serves one range of a recorded artifact file, resolved through the caller's own lease key and the manifest recorded at first completed poll (A leased job's adapter is reported by its files' digests and its base's fingerprint, never the trainer's path (card 3fd98325, S3-1) #5418).
  • The file is found by name only, never by a caller path.
  • A file whose size differs from the record is refused.
  • MAX_ARTIFACT_CHUNK is 8 KiB. The narrowest airc route caps a whole frame at 16 KiB (WebRTC, airc 0763991ac webrtc_datachannel/adapter.rs:15, per Codex). Base64 brings 8 KiB to about 10.9 KiB, and the 4 KiB reserve is more than 5× the largest airc envelope measured here (706 B over 32 events, 2026-10-25T13:46Z, airc 0.1.0). A test pins the encoded size of a full chunk.

Origin: LeasePull, behind an ArtifactSource seam. A stream transport later is an adapter swap.

  • The request first. create_bound writes request.json durably into default_job_dir(persona, trait, attempt) before the lease is sent (new job_dir::write_job_request). If that write fails, nothing is sent (TrainerUnavailable).
  • Pull off the poll, one per attempt. The base's content digest must equal this node's served base (WeightsStamp::read_verified). Ranges append to a private partial file beside the request, the whole file is hashed against the manifest, and then it's placed with continuum_host::durable::replace.
  • What poll reads: Running with progress, then a local Completed{GgufLora}. From there the completion sentinel, the adoption, and the examiner (trained_from = that directory, which holds request.json) run unchanged.
  • Failure handling:
    • A refused range, a wrong digest or a wrong base is final Failed.
    • A transient error ends the pull, and the next poll resumes from the partial file.
    • After a restart, a placed and verified file is found again without pulling.
  • Lookup by id. job_dir::find_job_dir_under finds a job's directory from its id, because a lease handle names only the attempt.

Capability. training_lease_return is now emitted: the receiver's return and the origin's import and acceptance consumers are both wired, which was Codex's condition.

Tests (what this catches on each)

  • a_leased_adapter_comes_back_verified_into_the_origins_own_job_dir: the return end to end over the real receiver commands. It covers:
    • the request is recorded before sending;
    • three ranges, the bytes placed whole and verified;
    • a lost range reply is resumed, not restarted (offset 0 asked exactly once);
    • a restarted origin doesn't pull again;
    • a base whose content isn't this node's is final.
  • an_artifact_range_is_served_only_from_the_record_and_fits_the_narrowest_route: nothing is served before the artifact is reported. It also covers bounds, a forged origin, a local caller, a ../ name, a changed file, the encoded size under the budget, and a short tail.
  • a_leased_jobs_request_is_written_whole_and_found_by_its_id (genome).
  • The existing grid tests now give each origin a genome root, since create_bound records the request first.

Measured

Nothing live yet. Live acceptance, owner Cormac, after deploy: one real lease from enrico (the weak node) to a peer that serves the same base. Receipts:

  • the pull probes, and the placed file's SHA-256 against the peer's manifest;
  • the sentinel's genome.trial.opened with provenance=true;
  • then the examiner's GeneExamReceipt (held-out, gene off versus on), and the restart re-run.

Until that receipt, this is source plus unit tests. CI is the compile, since no cargo runs on enrico while it serves.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…nto its own job directory, and both ends advertise training_lease_return (card 92cd2251, S3-2)

After S3-1 a peer reported a completed lease by its recorded manifest, but nothing could fetch
the bytes and the origin's poll held a finished job as pending forever.

Receiver: genome/lease/artifact {attempt, file, offset, len} serves one range of a recorded
artifact file, resolved through the caller's own lease key and the manifest recorded when the
job was first reported, by file NAME only (never a caller path). A file whose size no longer
matches the record is refused. A range is at most MAX_ARTIFACT_CHUNK (8 KiB): the narrowest
airc route caps a whole frame at 16 KiB (WebRTC, airc 0763991ac per Codex), base64 brings 8 KiB
to ~10.9 KiB, and the 4 KiB reserve is >5x the largest envelope measured on this mesh (706
bytes over 32 events, 13:46Z). A test pins a full chunk's encoded answer under the budget.

Origin (LeasePull, behind an ArtifactSource seam so a stream transport is an adapter swap):
- create_bound records the request durably in default_job_dir(persona, trait, attempt) BEFORE
  the lease is sent (job_dir::write_job_request: written, synced, placed whole); a failed
  record sends nothing (TrainerUnavailable).
- On a peer's Completed it starts one pull per attempt, off the poll: the base's content
  digest must equal this node's served base's (by verified handle); each range is appended to
  a private partial file beside the request; the whole file is hashed against the manifest;
  then it is placed with continuum_host::durable::replace. Poll reads Running with progress
  until then, and a local Completed{GgufLora} afterwards, so the completion sentinel, the
  adoption and the examiner (trained_from = that directory, request.json present) run
  unchanged. A refused range, wrong digest or wrong base is final Failed; a transient error
  ends the pull and the next poll resumes from the partial file; a placed, verified file is
  found again after a restart without pulling.
- job_dir::find_job_dir_under finds a job's directory by id (a lease handle names only the
  attempt).

training_lease_return is now emitted: both the receiver's return and the origin's import and
acceptance consumers are wired (Codex's condition).

Fixtures: the return end to end over the real receiver (three ranges, a lost range reply
resumed not restarted, a restart that does not re-pull, a base whose content is not this
node's refused); the range verb's bounds, forged origin, caller path, changed file and frame
budget; the request written whole and found by id.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply and others added 3 commits October 25, 2026 09:03
…me, and it keeps the manifest it pinned (Codex on #5419)

1. create_bound wrote request.json unconditionally: a retry of the same attempt with another
   payload rewrote the accepted request, and another persona opened a second directory that
   the lookup picked by enumeration order. The lease is now recorded once: a binding (peer,
   attempt, request digest) and the request, each published write-once (job_dir::
   publish_job_file over durable::publish_new); a retry is compared before anything is written
   or sent and refused when its payload, base, peer, persona or trait differs.
   find_job_dir_under takes its anchor file and refuses two directories of one id.
2. The peer's file name was joined into local paths: the adapter now lands at the fixed
   returned/adapter.gguf (partial .adapter.gguf.partial); a peer's name only names the range
   it is asked for.
3. status read then inserted: two polls could start two writers. The start is decided under
   the map's entry lock. The manifest is pinned once per attempt (manifest.json, write-once);
   a later report or a restarted origin offered another manifest is final, and the local
   artifact is built from the pinned manifest the bytes were verified against.

Fixtures: changed dataset/base/peer/persona refused and the original kept across a restart;
a manifest naming ../../evil lands only at the fixed name; two barrier-released polls start
one pull; a restarted origin refuses a changed manifest; a changed retry sends nothing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…ts request digest checked, and a pull checks its binding before pinning (Codex on #5419)

(a) The life test's changed-persona retry now asserts the origin's refusal ('nothing sent').
(b) An existing request.json is compared against the binding's digest on a retry; one that is
    not the bound request fails closed.
(c) Pull::run reads the directory's lease binding before pinning or pulling: bound to this peer
    and attempt, its request.json the one the binding names, and the request's base the base the
    manifest names. Anything else is final.
(d) record_request's scan for an existing directory and its publishes run under one lock per
    attempt (one core per node), so two first records under different personas cannot both win.

Fixtures: two thread-raced changed-persona records, exactly one wins; a manifest naming another
base than the request, a pull for another peer than the binding, and a tampered request.json
are each final; the tampered request also fails the retry.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…documents its one-writer-per-root invariant (Codex on #5419)

CI at f4babf3 compiled and failed only the two inventory assertions (10 -> 11 command objects,
13 -> 14 module commands): both now count the artifact verb and assert it by name. LeasePull's
doc states the lifecycle invariant Codex named: one instance writes a genome root (built once at
boot), so its per-attempt lock and single-flight map cover every writer.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply merged commit e9537c6 into canary Oct 25, 2026
25 checks passed
@joelteply
joelteply deleted the 92cd2251/lease-artifact-pull branch October 25, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant