feat(generate): compose resource limits + multi-arch platform (spec 18) - #99
Merged
Merged
Conversation
Lower a per-service resources block and a platform selector into the typed
compose model (spec 18), for BOTH project and shared stacks.
- config: add Service/SharedSvc.Resources{cpus,memoryMB,memoryReserveMB,
pidsLimit} + Platform, with cpus/platform validators and Service/SharedSvc
EffectiveMemoryMB(). memoryMB stays the budget hint and is shorthand for
resources.memoryMB.
- generate: applyResources dual-writes limits from one canonical byte value
(deploy.resources.limits.* AND legacy top-level cpus/mem_limit/pids_limit)
so compose-go/v2 cross-field consistency passes; emits platform; a service
with no limits emits no deploy block (no spurious diff). Bytes rendered as
a fixed mebibyte->bytes string (768M -> 805306368) for determinism.
- profile: CheckBudget sums the effective memory limit.
- goldens regenerated; new table-driven tests in config + generate.
Tested: CGO_ENABLED=0 go build ./... + all four release cross-builds,
CGO_ENABLED=1 go test ./internal/..., gofmt -l clean, go vet, make determinism.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements the generation slice of spec 18 (resource limits + multi-arch): lower a per-service
resourcesblock and aplatform:selector into the typed compose model, for both project stacks and the shared stack.config (
internal/config)Service.Resources *Resources+Service.Platform, and the same onSharedSvc(shared limits declared inworkspace.yaml shared.<svc>.resources).Resources{ cpus, memoryMB, memoryReserveMB, pidsLimit }.cpus(positive float) andplatform(os/arch[/variant]) validators with file-scoped error messages.Service.EffectiveMemoryMB()/SharedSvc.EffectiveMemoryMB():memoryMBstays the budget hint and is treated as shorthand forresources.memoryMB.generate (
internal/generate)applyResourcesdual-writes limits from one canonical byte value:deploy.resources.limits.{cpus,memory,pids}+reservations.memoryand the legacy top-levelcpus/mem_limit/pids_limit, so both deploy-aware and non-deploy readers agree and compose-go/v2's cross-field consistency check passes.768M → 805306368) for byte-stable, deterministic output.platform:emitted verbatim (config overrides any template value).deployblock (no spurious diff).profile
CheckBudgetnow sums the effective memory limit.Why
Stops unbounded containers eating a laptop's RAM and makes the arch selector declarative — the thin generation layer of spec 18 over the existing deterministic compose pipeline.
How tested
CGO_ENABLED=0 go build ./...+ all four release cross-builds (darwin/linux × amd64/arm64) — CGO-free holds.CGO_ENABLED=1 go test ./internal/...(all pass), incl. new table-driven tests: dual-write block + agreeing bytes, platform passthrough, no-limits→no-deploy, shared limits,bytesFromMB, config parse/validation,EffectiveMemoryMB,CheckBudget.gofmt -lclean,go vet ./...,make determinismgreen (goldens regenerated and eyeballed).Scope note: the doctor
host.ram/host.vmsize/arch.emulationprobes andup --platform/emulation-warning plumbing are the "full ~1.5w" slice of spec 18 and are intentionally out of scope for this generation-focused PR.🤖 Generated with Claude Code