deploy: bundle truffle into the web-API Lambda so /api/propose can price#67
Merged
Merged
Conversation
The web-API Lambda's brain prices each rung by shelling out to truffle (the spore 'call the tool, don't reimplement' rule). truffle is a local CLI, absent from the stock Lambda PATH, so /api/propose could not price in the deployed control plane — the pricing half of the deploy gap documented in PR #64. Cross-compile truffle (linux/arm64, CGO_ENABLED=0, stripped) from a spore.host/truffle checkout (TRUFFLE_SRC, default ../spore-host/truffle) into the foray-web zip under bin/, and prepend /var/task/bin to the Lambda PATH so the spore exec runner's LookPath resolves it — no Go-adapter change. The foray-gateway zip never prices, so it stays truffle-free. Stays ~$0: a non-VPC Lambda keeps default internet egress, so truffle's read-only EC2/Price-List calls reach AWS with no VPC, no endpoints, no NAT. The webapi IAM role gains exactly those read-only pricing actions. gateway->worker reachability (the other half of the gap) remains a documented follow-on; README captures the two candidate shapes (public-IP+token vs full VPC) for a later, GPU-validated decision. Offline gate untouched and green (make demo-fake, go test ./...); make lambdas verified to bundle a stripped arm64 truffle (17MB compressed web zip, under the 50MB direct-upload limit).
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 & why
The deployed web-API Lambda's brain prices each rung by shelling out to truffle (the spore.host "call the tool, don't reimplement" rule —
internal/spore). truffle is a local CLI, absent from the stock LambdaPATH, so/api/proposecould not price in the deployed control plane — the pricing half of the deploy gap documented in PR #64.This bundles truffle into the
foray-webLambda:make lambdascross-compiles truffle (linux/arm64,CGO_ENABLED=0, stripped) from a spore.host/truffle checkout (TRUFFLE_SRC, default../spore-host/truffle) into the zip underbin/.lambda.tfprepends/var/task/binto the LambdaPATHso the spore exec runner'sLookPath("truffle")resolves it — no Go-adapter change (the exec seam already doesLookPath).spot-path actions:ec2:DescribeSpotPriceHistory,DescribeInstanceTypes,DescribeInstanceTypeOfferings,DescribeRegions,pricing:GetProducts.foray-gatewayzip never prices, so it stays truffle-free.Stays ~$0: a non-VPC Lambda keeps default internet egress, so truffle's read-only calls reach AWS with no VPC, no endpoints, no NAT.
The other half of the #64 gap — gateway→worker reachability — is filed as #66 with the two candidate shapes (public-IP+token vs full VPC) for a later, GPU-validated decision. Not in this PR.
Verification
make demo-fake,go test ./...,golangci-lint run ./...,make license-check— all green (no Go changed; offline gate untouched).terraform fmt -check+terraform validate+make deploy-check— green.make lambdas— bundles a stripped arm64 truffle; web zip is 17 MB compressed (under Lambda's 50 MB direct-upload limit),bin/trufflepath preserved; forayd zip stays truffle-free. Missing-TRUFFLE_SRCguard produces a clear error.make deploy(hand-validation-pending, per the step-9 precedent — not CI).Checklist
make lintandmake testpassCHANGELOG.mdupdated under[Unreleased].tf/Makefile edits keep existing headers)Invariant check (see CLAUDE.md)
Refs #66 (follow-on). Closes the pricing half of the PR #64 deploy gap.