docs/ez-agent-ruby/cmd/package-runtime.md

package-runtime: create the embedded Ruby runtime payload

This release-build utility turns a stable staged Ruby runtime directory into the ZIP embedded by the production ez-agent-ruby launcher. It does not build, install, run, verify, or prune a runtime; for those tasks see ez-agent-ruby.

What does it take and produce?

package-runtime requires all five flags: -root (staged directory), -out (destination ZIP), -version, -revision, and -target; the last three are manifest identity fields.

1package-runtime -root staged/ -out payload.zip \
2 -version 3.4.11 -revision 6 -target linux-amd64

The identity values must match the canonical constants exactly; for example, 3.4.011 is rejected. The ZIP has one root .ez-agent-ruby-manifest.json member followed by sorted staged regular files; directory entries are not emitted.

RoleLocation
CLI, traversal, hashing, and ZIP publicationcmd/package-runtime/main.go
Manifest identity, schema, and validationinternal/runtimepayload/manifest.go
Payload parser and extractorinternal/launcher/launcher.go
Production embedding boundarycmd/ez-agent-ruby/payload_embedded.go

Which staged trees are accepted?

  • -root must be an existing real directory; the output parent must already exist. Use a stable tree: packaging does not promise a snapshot of files that change while it runs.
  • Entries must be regular files beneath directories—no symlinks or other file types. Stored modes use nonzero ordinary 0777 permission bits and grant no group/other write access; special bits are not retained.
  • Paths are canonical, slash-separated, relative, unique, and strictly sorted. The manifest name is reserved.
  • The tree contains 1–10,000 files. A file is at most 64 MiB and total uncompressed content is at most 512 MiB.

What identity and invariants must the payload preserve?

Identity is exact: Ruby 3.4.11, runtime revision 6, and target linux-amd64. Manifest entries carry lowercase SHA-256 checksums, size, and safe mode metadata; the shared runtimepayload validator is authoritative—do not introduce another interpretation in this command.

The producer preserves ordinary staged-file permission bits, gives the manifest mode 0644, fixes ZIP-member timestamps to the Unix epoch, and publishes through a unique 0600 temporary file before rename. Keep the unique temporary-file publication: concurrent packaging and stale fixed-name symlinks must not affect an output.

The launcher independently checks archive names, manifest/member agreement, metadata, target, and extracted checksums. Its archive-size admission limit is a separate consumer constraint; do not treat the producer's 512 MiB uncompressed-content limit as a guarantee that every produced ZIP is accepted.

How does the payload reach users?

The Ruby build pipeline—delegated by the root justfile to ez-agent-ruby/runtime/build.sh, which is not covered here—stages the runtime and uses this command to create cmd/ez-agent-ruby/payload.zip. Production builds selected with the runtime_payload build tag embed that file; ordinary builds carry an empty stub payload. The launcher parses, extracts, and later validates the installed tree. See launcher for installation semantics rather than documenting them here.

Where is detailed behavior checked?