Principle:777genius Agent teams ai Runtime Staging
| Knowledge Sources | |
|---|---|
| Domains | Release, Build |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
Pattern for downloading, verifying, and staging external runtime binaries from GitHub releases into an Electron app's resources directory with checksum verification.
Description
Runtime Staging is the process of downloading a pinned runtime binary from a GitHub release, verifying its checksum, extracting it, and placing it in `resources/runtime/` for the packaged app. The staging script reads `runtime.lock.json` for the pinned version and platform mapping.
Key mechanisms:
- Lock file pinning: `runtime.lock.json` pins the runtime version and maps platform keys to download URLs.
- Platform targeting: `--platform <key>` selects the target platform; defaults to the current platform.
- Release tag override: `--release-tag <tag>` overrides the lock file's release tag.
- Checksum verification: `verifyRuntimeArchiveChecksum()` verifies the downloaded archive against an expected checksum.
- Payload cache: A runtime payload cache (`runtime-payload-cache.mjs`) avoids re-downloading unchanged archives.
- Clean mode: `--clean` removes staged runtime files, keeping `resources/runtime/.gitkeep`.
- Error formatting: `formatGitHubReleaseDownloadError()` provides user-friendly download error messages.
Usage
Use this principle when staging external runtime binaries for a packaged desktop application, especially when checksum verification and platform-specific downloads are needed.
Theoretical Basis
# Abstract algorithm (NOT real implementation)
def stage_runtime(platform, release_tag, clean):
if clean:
remove_files('resources/runtime/')
keep('.gitkeep')
return
lock = read_json('runtime.lock.json')
version = lock.version
tag = release_tag or lock.release_tag
url = resolve_download_url(tag, platform, lock)
archive_path = download(url)
if not verify_checksum(archive_path, expected_checksum):
raise ChecksumError()
extract_archive(archive_path, 'resources/runtime/')