Repository navigation
feat(box): Let a runtime's box.version choose among the box releases this CLI supports - #2895
mquang-amazon wants to merge 2 commits into
Conversation
…this CLI supports boxRelease.json pins the releases this CLI supports: box, the default that create writes, and supported, the others, each with the checksums of its Linux and macOS builds. A runtime's box.version picks one of them, and no version means the default. Build, deploy and container dev ship that release; build and deploy refuse any other version before they write anything, naming the supported ones. Build no longer rewrites box.version, so the choice stays. Checksums come only from boxRelease.json, which changes by a reviewed PR, not from a release's SHA256SUMS.txt, which anyone who can edit the release could replace. scripts/bump-box-release.ts gains --add, --remove and --keep-previous to manage the list.
leo237
left a comment
There was a problem hiding this comment.
First review, at efe601d. This answers the question left open on #2886 (what box.version should mean when two CLIs pin different releases). After this PR, box.version selects one of the releases pinned in boxRelease.json, and build stops rewriting it. I think that's the right model. The refusal is loud and happens early: validateBoxRuntimes runs before any write in both build and deploy. The message names the supported versions, and the build test checks that agentcore.json is left byte-identical. I found no silent fallback. A malformed version fails BoxVersionSchema, an unlisted version is refused, and only a missing version falls back to the default, which is documented. I checked the pinned default against mquang-amazon/box-releases v0.1.11-preview.10: the tag, both assets and SHA256SUMS.txt exist, and both pinned SHA-256s match.
Blocking
- Merge conflict with
box-integration. GitHub shows the PR asCONFLICTING/DIRTY. The PR is based on the #2886 head (dced1411), and since then #2878 merged into the base and addedassertBoxRegionSupportedand new imports tosrc/core/project/boxValidation.ts. The conflict is in that file only. It should be easy to fix: keep both import sets and both appended functions. - No CI has run.
gh pr checksreports no checks on the branch, probably because GitHub can't build the merge commit while the conflict stands. Please rebase or merge the base and let CI run.
Non-blocking
- CodeZip
agentcore devignoresbox.version. It still runs whateverboxis on PATH. Before this PR every runtime ran the single pin, so that didn't matter. Now a runtime can name a non-default supported release, and a local run can silently use a different box from the one that deploys. The install hint also always names the default release (INSTALL_BOXinboxProfileResolver.ts). Options: a status line when the PATH box's version differs from the runtime's release, or at least a sentence in the README/local-testing doc. This doesn't bite today becausesupportedis empty. - Upgrade behavior changed. When
--boxmoves the default without--keep-previous, every project created by the previous CLI (withbox.version= the old default) now stops at build. Before, build rewrote the field with a message. The error says how to fix it, so nothing is silent. Still, the README/bump-script doc could say when to use--keep-previous, and that a release kept insupportedmust still read the profiles this CLI writes. Nothing enforces that. - Test gaps (small). The refusal is tested for build (
manager.boxNetwork.test.ts) and for the staging functions. There's no test for the deploy path, which calls the samevalidateBoxRuntimes, or for containerdevrefusing an unsupported version (ContainerDevRunner→boxReleaseOfRuntimethrows). A deploy case alongside the build one would guard the "before anything is written" claim for deploy as well.scripts/bump-box-release.ts(--add/--remove/--keep-previouslist handling) has no tests. That matches how the script was before, but its list logic is now non-trivial. - Comment and message accuracy.
box.versionis now optional, so"box": {}runs in a box, but several messages still say a runtime runs in a box "because it has box.version". Examples:assertBoxRuntimesHaveBoxVersion("has no box.version", which really fires whenboxitself is missing), the "(it has box.version in agentcore.json)" messages inboxValidation.ts,dev/box.ts,dev/container.tsandboxNetworkSource.ts, and the local-testing doc line "A runtime withbox.versionin a project without projectType box…". Consider "hasbox" or "has aboxentry". - New exports and types.
boxReleaseFor/boxReleaseOfRuntime/BOX_RELEASESare a clean split: one lookup, one that throws.boxReleaseOfRuntimeusesreleases[0]!, which turns an emptyreleases(tests only) into a TypeError rather than the intended message. A guard or a non-empty tuple type would make that invariant explicit. The bump script redeclaresReleaselocally (it imports nothing fromsrc/, as intended), so it will drift if the schema changes. #2893 addsdarwin.version, for example. - FYI: overlap with #2893. #2893 (pin to public
strands-agents/boxv0.3.0) conflicts with this PR inREADME.md,docs/box-local-testing.md,scripts/bump-box-release.ts,boxRelease.ts,boxRelease.test.tsandboxProfileResolver(.test).ts. Some of it is semantic as well as textual. #2893 renames the assets tobox-cli-v<version>-<target>.tar.gzand adds an optionaldarwin.version. The newrelease()helper here hard-codesbox-v${version}-${target}.tar.gzand buildsdarwinwithout a version, so whichever PR lands second needs to carry the other's asset naming and thedarwin.versionfield into--add/--keep-previous. Not blocking for this PR.
Not in the squash plan (https://pippin.amazon.dev/docs/XFRmP1pP9L90nl/box-integration-squash-and-pr-plan-v2). I treated it as a follow-up to #2886, and I found no matching commit on box-integration-development. Once the conflict is resolved and CI is green, I'd expect to approve with the items above as non-blocking.
| * Throws, naming the supported versions, for a box runtime whose `box.version` names a release this | ||
| * CLI does not support: only a release whose checksums the CLI pins can ship. | ||
| */ | ||
| export function assertBoxVersionsSupported(spec: ProjectSpec): void { |
There was a problem hiding this comment.
This is the hunk that conflicts with box-integration: #2878 appended assertBoxRegionSupported below validateBoxRuntimes and added RegionUnsupportedFeatureError / supportsRuntimeV2 imports. Keep both. (Blocking only because of the conflict. The check itself looks right and runs before any write.)
| } | ||
|
|
||
| for (const { runtime, dist } of staged) { | ||
| const entry = runtimes.find(({ name }) => name === runtime)!; |
There was a problem hiding this comment.
Nit: this resolves each runtime's release twice (in the loop above and again here, along with the find(...)! / get(...)! assertions). A Map<runtimeName, BoxLinuxBuild> filled in the first loop would avoid both non-null assertions.
| console.log(`box: supporting ${repo} ${values.add} beside the default ${box.version}`); | ||
| supported = [ | ||
| ...supported.filter(({ version }) => version !== values.add), | ||
| await release(repo, values.add), |
There was a problem hiding this comment.
FYI vs #2893: release() hard-codes box-v${version}-${target}.tar.gz and builds darwin without the optional version that #2893 adds (its assets are box-cli-v...). Whichever PR lands second needs to reconcile this, or --add 0.3.x will throw "lists no box-v...". Also, --keep-previous is silently ignored with --add/--remove. You could reject that combination.
| * CodeZip agent with the `box` on your PATH instead. | ||
| */ | ||
| box: z.object({ version: BoxVersionSchema }).optional(), | ||
| box: z.object({ version: BoxVersionSchema.optional() }).optional(), |
There was a problem hiding this comment.
Making version optional looks right to me: no version means the current CLI's default, so two CLIs never rewrite each other. One follow-up: CodeZip agentcore dev still runs the box on PATH whatever version says. Worth a note in the docs, or a status line when they differ, once supported is non-empty.
…ted-box-releases # Conflicts: # src/core/project/boxValidation.ts
leo237
left a comment
There was a problem hiding this comment.
Re-review at 6fed3d9. The only change since my last review (at efe601d) is a merge of box-integration (2f9422d, which brings in #2878 and #2886) into the branch.
Earlier blockers
- Merge conflict: resolved. The conflict in
src/core/project/boxValidation.tswas resolved the way I suggested. Both import sets are kept (RegionUnsupportedFeatureError,supportsRuntimeV2,boxReleaseOfRuntime), andassertBoxVersionsSupportedandassertBoxRegionSupportedboth sit aftervalidateBoxRuntimes. No other file in the merge differs from either parent. GitHub now reports the PR asMERGEABLE, and the merge base is the currentbox-integrationhead. I also checked how the merged code fits together. Deploy still callsassertBoxRegionSupportedbeforevalidateBoxRuntimes, so both refusals happen before anything is written. The #2878 deploy tests useFakeBoxProfileResolverand don't set an unsupportedbox.version, so this PR's version check shouldn't affect them.boxRelease.jsondidn't change, so the pins I checked last time still apply. - CI: running, not finished.
verify / Linux,verify / Windows,verify / macOSandAnalyzewere all still pending when I posted this (e2eis skipped). I'm leaving this as COMMENT only because those checks haven't finished. Once they are green I'm happy to approve. Nothing else is blocking.
Non-blocking (still open, from my last review; not repeated in full)
The merge didn't change any of these, so the earlier points still stand. Briefly: CodeZip agentcore dev still runs the box on PATH whatever box.version says. Moving the default without --keep-previous stops builds of projects made by the previous CLI. Three tests are still missing: deploy refusing an unsupported version, container dev refusing one, and the bump script's list logic. The "has box.version" wording is out of date now that "box": {} is valid. Type nits: releases[0]!, the double lookup in boxCodeZip.ts, and the duplicated Release type. The #2893 asset-name and darwin.version overlap is FYI only. None of these block this PR.
Still not in the squash plan (https://pippin.amazon.dev/docs/XFRmP1pP9L90nl/box-integration-squash-and-pr-plan-v2), and box-integration-development has no commit that covers this change, so the items above stay as follow-ups.
Description
A runtime's
box.versionnow chooses which box release it runs, among the releases this CLI supports.Before this PR, build shipped only the one pinned box and rewrote
box.versionto it (#2886), so the field recorded the pin but chose nothing. Tejas noted on #2886 that two CLIs with different pins then rewrite it back and forth.What changes
boxRelease.jsonlists the supported releases.boxis the default, whichagentcore createwrites.supportedlists the others. Each release pins the SHA-256 of its Linux build (shipped to AgentCore Runtime) and its macOS build (installed by the e2e workflow). The list is empty today, so only the default is supported.box.versionpicks a release. With no version ("box": {}), a runtime runs the default. Build and deploy ship the release thatbox.versionnames: they download its Linux build into a CodeZip zip, or stage it inbox-release.envfor a container image. Containerdevdoes the same.validateBoxRuntimesrefuses it before build or deploy writes anything, and the message names the supported versions:box.version. The user's choice stays.boxVersionWriteris removed.scripts/bump-box-release.tsgains--add <version>and--remove <version>for the supported list, and--keep-previousto keep the old default supported when--boxmoves the default.Why the checksums stay in the repo
A GitHub release is not reviewed code: anyone with write access to the release repository can replace an asset and its
SHA256SUMS.txttogether, so a check against the release's own checksum file would pass a swapped box. The CLI trusts only the checksums inboxRelease.json, which change through a reviewed PR. The list also keeps a project on box releases that are known to read the profiles this CLI writes.Docs
README.mdanddocs/box-local-testing.mddescribe the supported list, howbox.versionchooses a release, and the bump script's new options.Related Issue
Closes #
Documentation PR
Not applicable: the docs are updated in this PR.
Type of Change
Testing
bun test(6082 pass, 7 skip, 0 fail, with noboxon PATH)bun run test:e2e, or explained why they are not applicable(CI does not run them for you): not run. The default release ships as before; only the default is supported today.
bun run typecheckbun run lint:checkbun run format:checkbun run auditbun run secrets:checkbun run buildsrc/assets/, I updated affected snapshots withbun test <test-file> --update-snapshotsand committed them: not applicablecommand.md(the release workflow regenerates it)New tests:
boxRelease.test.ts: the default comes first; a version picks its release, and no version picks the default; an unsupported version is refused with the supported versions named.boxCodeZip.test.ts: each supported release that the runtimes name is downloaded once, and an unsupported version is refused.boxContainer.test.tsandcontainer.test.ts: a non-default supported release reachesbox-release.env.manager.boxNetwork.test.ts: build refuses an unsupported version without writingagentcore.json, and keepsbox.versionas written. Removing the validation call makes the refusal test fail.The staging functions and the container dev runner take the release list as an optional parameter that defaults to
boxRelease.json's, so tests can supply a second release.I ran the bump script against the published releases:
--box 0.1.11-preview.10leaves the file unchanged, and--add 0.1.11-mquang.preview.9followed by--removerestores it.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.