docs/ez-agent-ruby/internal/runtimepayload.md

Runtime payload contract

runtimepayload owns the release-specific manifest shared by an embedded Ruby runtime payload and an installed runtime’s completion marker. It defines identity, canonical form, limits, and strict JSON parsing—not ZIP creation or installation.

Go elsewhere: build a ZIP; run, install, verify, or prune a runtime; understand the wrapper; or extend EzAgent in Ruby. For add-on orientation, see EzAgent Ruby; generic transport contracts are in the JSONL API.

What does the manifest carry?

RoleContract
Current payload identitySchema 1; Ruby 3.4.11; runtime revision 6; target linux-amd64. Embedded payloads and their selected installations must match exactly.
File entryA relative path, lowercase 64-character SHA-256 sha256, permission mode, and byte size.
ManifestA nonempty, lexically sorted files array plus the identity fields. The manifest filename is .ez-agent-ruby-manifest.json.
LimitsAt most 10,000 files; 64 MiB per file; 512 MiB cumulative uncompressed file size.

The authoritative definitions are manifest.go. The revision is an enforced identity value; this package does not define its bump policy.

DecodeManifestStrict and ValidateManifest enforce the current release. DecodeInstalledManifestStrict and ValidateManifestStructure also accept historical schema-1 identities with canonical numeric version/revision strings and the supported target. This permits old runtimes to be checked before pruning without accepting them as the current payload. Both decoders retain the same strict JSON, path, metadata and size checks.

Which rules keep the payload canonical and safe?

  • Paths must be nonempty, relative, slash-separated, and already clean; they may not be ./.., begin with ../, or use the reserved manifest name. Entries are strictly lexically ordered, so duplicates and unsorted lists fail validation.
  • File sizes are within the limits. Modes have nonzero permission bits within 0777 and may not grant group or other write permission.
  • Checksums are exactly lowercase hexadecimal SHA-256 strings. The total declared size cannot exceed the manifest limit.
  • Strict decoding rejects duplicate JSON object keys at every nesting level, unknown fields, trailing JSON values or data, and a semantically invalid manifest. RejectDuplicateJSONKeys is also a shared parser helper, including for launcher state; it is not manifest-exclusive.

MaxFile and MaxTotal describe manifest entries, not the launcher's separate compressed-archive limit.

Who produces and consumes this contract?

package-runtime stages ordinary files, hashes and sorts them, validates this manifest, and writes it first in the ZIP. The wrapper embeds that generated ZIP only in runtime_payload builds.

The launcher parses the archive against the manifest, verifies extracted hashes, and validates installed runtimes before use or pruning. Archive layout, ZIP metadata, extraction, ownership, and installed-tree rules belong on those pages rather than here.

Manifest modes describe archive permissions. Installed files can have tighter permissions or be read-only, provided the owner can read them and execute the required binaries. The launcher separately rejects other-user write access and privilege-changing executable bits. It does not rewrite the manifest to reflect these filesystem permission changes.

Where does implementation detail live?