Dashboard › cli › Distillation
606140b3-7830-46fa-9ec9-c87357746672["lore_tm_v1_lIqKm6a0MV5xdnuIrjSrVgzaIBhrPv8K6N1gPJcIBms","lore_tm_v1_weH0TQWCHRmqdLWBC26OWkkEMSlVib84ilHAlKW0Ix0","lore_tm_v1_cI7pIYJH8TVQLALrVtlLHjgVoWXvvW3P2WHIfdceUpg"]
src/sources/github-release.ts defines the stable-channel githubReleaseSource: each GitHub release is expected to publish <binaryName>, <binaryName>.gz, and <binaryName>.patch; product details (releasesUrl, binaryName, userAgent, injectable fetch, and optional InstrumentHook) remain consumer-injected.SHA256_DIGEST_PATTERN = /^sha256:([0-9a-f]+)$/i; extractSha256() lowercases the captured digest, and getStableTargetSha256() reads it from the exact <binaryName> asset.extractStableChain() locates targetVersion and currentVersion in the fetched release window, slices releases in (current, target], caps them at MAX_STABLE_CHAIN_DEPTH, requires the target binary SHA-256 and every ${binaryName}.patch asset, rejects cumulative patch size above fullGzSize * SIZE_THRESHOLD_RATIO, reverses patch URLs into oldest-first apply order, and emits { fromVersion, toVersion } steps.no_patches, excessive depth as too_long, absent target SHA-256 or an absent in-range patch asset as malformed_chain, and excess cumulative size as over_budget.githubReleaseSource.fetchRecentReleases() requests ${releasesUrl}?per_page=${MAX_STABLE_CHAIN_DEPTH + 2} with Accept: application/vnd.github.v3+json, the injected User-Agent, optional AbortSignal, and instrumentation step "fetch-releases"; thrown fetch errors and non-OK responses return null.githubReleaseSource reports network and returns null.Promise.all, use instrumentation step "download-patch", convert response bodies to Uint8Array, and return a PatchChain containing downloaded patches, actual downloaded totalSize, expectedSha256, and version steps.no_patches; an existing target release lacking ${binaryName}.gz reports malformed_chain, identifying a malformed target publish for that platform.src/sources/ghcr.ts defines ghcrSource for nightly OCI chains. Patch manifests use annotation from-version=<prev>, annotation sha256-<binaryName>=<hex>, and a layer titled <binaryName>.patch; the target full-image manifest’s <binaryName>.gz layer supplies the size-ratio budget.filterAndSortChainTags() selects versions in (currentVersion, targetVersion] and sorts them with the injected compareVersions; safeCmp() catches comparator exceptions and returns 0, so one malformed/non-semver tag cannot crash chain discovery. A second sort-level try/catch is retained as a belt-and-braces guard, with an unsorted chain allowed to proceed to downstream malformed_chain validation.validateChainStep() requires an exact from-version === expectedFrom, an OCI layer whose org.opencontainers.image.title equals ${binaryName}.patch, and a layer size no greater than the remaining budget; failures are classified as malformed or over_budget.validateNightlyChain() walks manifests and tags in apply order, tracks cumulative size against fullGzSize * SIZE_THRESHOLD_RATIO, validates every back-pointer and patch layer, requires the final derived version to equal targetVersion, and reads the final sha256-${binaryName} annotation; structural failures become malformed_chain, while excess size becomes over_budget.no_patches for zero selected patch tags and too_long when tag count exceeds MAX_NIGHTLY_CHAIN_DEPTH; chain manifests are fetched concurrently under instrumentation step "fetch-chain-manifest".validateNightlyChain.network, so a transient fetch failure “never triggers a false malformed_chain poison alert.”"ghcr-token" step, using instrumentation steps "fetch-target-manifest" and "list-patch-tags"; absence of the target manifest’s ${binaryName}.gz layer reports malformed_chain."download-patch" and OciClient.downloadBlobBuffer(), converted to Uint8Array, and returned with actual downloaded totalSize, the validated target SHA-256, and ordered { fromVersion, toVersion } steps.unavailable, not as a system error.BinpatchError, reports network, and returns null; programming errors are deliberately rethrown rather than swallowed.src/discover.ts defines DeltaUnavailableReason as exactly "no_patches" | "malformed_chain" | "too_long" | "over_budget" | "network" and DeltaSource as "cache" | "network" | "offline_miss".null return is always a full-download fallback).”no_patches for a benign lack of published deltas; malformed_chain for a published-but-broken chain such as a missing patch layer, bad from-version, or missing target SHA-256; too_long for exceeding maximum depth; over_budget for exceeding the size-ratio gate; and network for transient resolution failures.resolveAndApply() is cache-first: it calls cache.load(currentVersion, targetVersion) through tryLoadCachedChain(), silently treats cache-load exceptions as misses, reports cached success through telemetry.onResolved({ source: "cache", chain }), and applies the cached chain without source resolution.ResolveAndApplyOpts.offline mode to “never touch the network — cache hit or bust.”resolveAndApply() calls telemetry.onOfflineMiss() and returns null; otherwise it emits the "resolve" phase, invokes source.resolveChain() with an UnavailableReporter, defaults an unclassified null to no_patches, and forwards the final reason to telemetry.onUnavailable().steps is saved asynchronously via cache.save(chain, chain.steps).catch(() => {}); save failures do not block application. Successful network resolution calls telemetry.onResolved({ source: "network", chain }).applyChain() computes apply-progress total as the sum of every patch header’s newSize, because progress counts output bytes for every in-memory intermediate hop and the final disk write; using only the final hop size was rejected because a multi-hop progress bar would reach 100% after the first hop and then freeze.parsePatchHeader() throws, progress total becomes null, while the corrupt patch remains subject to normal downstream rejection.applyChain() emits "apply" phase/byte/done events around applyPatchChainInMemory(), then "verify" phase/done events; it throws SHA-256 mismatch after patching: got ${sha256}, expected ${chain.expectedSha256} on integrity failure and otherwise returns { sha256, patchBytes: chain.totalSize, chainLength: chain.patches.length }.