Dashboard › cli › Distillation
ac3474c8-8374-4187-b7f2-8890a427cd4f["lore_tm_v1_USAmQDYChS4gnTRax_09_dl7CrtJPMqpJQUXs6cdPFA"]
Date: September 9, 2026
SourceStrategy.resolveChain(currentVersion, targetVersion, signal?, report?) returns Promise<PatchChain | null> containing an ordered oldest-hop-first patch chain and expected final SHA-256; null means no usable chain and always falls back to a full download.UnavailableReporter classification is telemetry-only and never changes control flow: a null return always triggers full-download fallback, whether the absence is benign or caused by a poisoned publish.DeltaUnavailableReason values and meanings: "no_patches" means no patch tags/assets exist in range; "malformed_chain" means published patches form an unusable chain due to issues such as a missing <binaryName> patch layer, bad from-version back-pointer, missing target SHA-256 annotation, or other validation failure; "too_long" means chain depth exceeds the maximum; "over_budget" means cumulative patch size exceeds the size-ratio gate; "network" means a transient network failure prevented resolution.DeltaSource is the exact union "cache" | "network" | "offline_miss" and DeltaTelemetry provides optional onResolved({ source, chain }), onOfflineMiss(), and onUnavailable(reason) hooks; the library remains telemetry-agnostic.ResolveAndApplyOpts.offline means βnever touch the network β cache hit or bust.βResolveAndApplyOpts.onProgress receives phase/bytes/done progress events that are never rendered by the library.resolveAndApply() orchestration order: 1. safely wrap onProgress with safeProgress(), 2. try cache.load(currentVersion, targetVersion) first, 3. on a cache hit emit telemetry.onResolved({ source: "cache", chain }) and apply it, 4. if offline after a miss emit telemetry.onOfflineMiss() and return null, 5. otherwise emit resolve phase and call source.resolveChain(), 6. on no chain emit telemetry.onUnavailable(reason) and return null, 7. asynchronously persist a network chain when cache && chain.steps, 8. emit telemetry.onResolved({ source: "network", chain }), then apply.resolveAndApply() defaults unavailableReason to "no_patches"; the source can replace it through the report callback with a more specific reason such as "malformed_chain".tryLoadCachedChain() catches any cache.load() failure and returns null, while cache.save(chain, chain.steps).catch(() => {}) is fire-and-forget and suppresses persistence errors.resolveAndApply() returns DeltaResult | null; null means no usable chain, while genuine application or verification failures such as corrupt patches or SHA mismatch throw so the caller can fall back to a full download.applyChain(): total is the sum of parsePatchHeader(patch.data).newSize across every patch because byte callbacks include every in-memory intermediate output and the final disk write; using only the final hop size causes the bar to reach 100% after the first hop and then freeze.parsePatchHeader() call throws, total becomes null, while the corrupt patch remains subject to rejection downstream.applyChain() emits "apply" phase, accumulates callback bytes into written, emits { type: "bytes", phase: "apply", written, total }, then emits apply done; it subsequently emits "verify" phase, compares the returned SHA-256 with chain.expectedSha256, and emits verify done only after a successful match.SHA-256 mismatch after patching: got ${sha256}, expected ${chain.expectedSha256}.applyChain() returns { sha256, patchBytes: chain.totalSize, chainLength: chain.patches.length }.