Skip to content

feat(box): Let a runtime's box.version choose among the box releases this CLI supports - #2895

Open
mquang-amazon wants to merge 2 commits into
box-integrationfrom
box/supported-box-releases
Open

mquang-amazon wants to merge 2 commits into
box-integrationfrom
box/supported-box-releases

Conversation

@mquang-amazon

Copy link
Copy Markdown
Contributor

Description

A runtime's box.version now 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.version to 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.json lists the supported releases. box is the default, which agentcore create writes. supported lists 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.version picks a release. With no version ("box": {}), a runtime runs the default. Build and deploy ship the release that box.version names: they download its Linux build into a CodeZip zip, or stage it in box-release.env for a container image. Container dev does the same.
  • An unsupported version stops early. validateBoxRuntimes refuses it before build or deploy writes anything, and the message names the supported versions:

    runtime "agent" names box 0.1.11-linux-preview.6 under box.version in agentcore.json, but this CLI supports box 0.1.11-preview.10. Set box.version to one of them, or remove it to run 0.1.11-preview.10, then retry.

  • Build no longer rewrites box.version. The user's choice stays. boxVersionWriter is removed.
  • scripts/bump-box-release.ts gains --add <version> and --remove <version> for the supported list, and --keep-previous to keep the old default supported when --box moves 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.txt together, so a check against the release's own checksum file would pass a swapped box. The CLI trusts only the checksums in boxRelease.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.md and docs/box-local-testing.md describe the supported list, how box.version chooses 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

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

  • I ran bun test (6082 pass, 7 skip, 0 fail, with no box on PATH)
  • I ran the relevant end-to-end tests with 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.
  • I ran bun run typecheck
  • I ran bun run lint:check
  • I ran bun run format:check
  • I ran bun run audit
  • I ran bun run secrets:check
  • I ran bun run build
  • If I modified src/assets/, I updated affected snapshots with bun test <test-file> --update-snapshots and committed them: not applicable
  • If I re-recorded fixtures or golden files, every change beyond account identifiers is explained by this PR: not applicable
  • This PR does not change command.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.ts and container.test.ts: a non-default supported release reaches box-release.env.
  • manager.boxNetwork.test.ts: build refuses an unsupported version without writing agentcore.json, and keeps box.version as 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.10 leaves the file unchanged, and --add 0.1.11-mquang.preview.9 followed by --remove restores it.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published: stacked on fix(box): Address the open review of the merged Box PRs #2886

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…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.
Base automatically changed from box/address-tejas-review to box-integration November 23, 2026 22:11
@mquang-amazon
mquang-amazon requested a review from a team November 23, 2026 22:11

@leo237 leo237 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Merge conflict with box-integration. GitHub shows the PR as CONFLICTING/DIRTY. The PR is based on the #2886 head (dced1411), and since then #2878 merged into the base and added assertBoxRegionSupported and new imports to src/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.
  2. No CI has run. gh pr checks reports 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 dev ignores box.version. It still runs whatever box is 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_BOX in boxProfileResolver.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 because supported is empty.
  • Upgrade behavior changed. When --box moves the default without --keep-previous, every project created by the previous CLI (with box.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 in supported must 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 same validateBoxRuntimes, or for container dev refusing an unsupported version (ContainerDevRunner → boxReleaseOfRuntime throws). 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-previous list handling) has no tests. That matches how the script was before, but its list logic is now non-trivial.
  • Comment and message accuracy. box.version is 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 when box itself is missing), the "(it has box.version in agentcore.json)" messages in boxValidation.ts, dev/box.ts, dev/container.ts and boxNetworkSource.ts, and the local-testing doc line "A runtime with box.version in a project without projectType box…". Consider "has box" or "has a box entry".
  • New exports and types. boxReleaseFor / boxReleaseOfRuntime / BOX_RELEASES are a clean split: one lookup, one that throws. boxReleaseOfRuntime uses releases[0]!, which turns an empty releases (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 redeclares Release locally (it imports nothing from src/, as intended), so it will drift if the schema changes. #2893 adds darwin.version, for example.
  • FYI: overlap with #2893. #2893 (pin to public strands-agents/box v0.3.0) conflicts with this PR in README.md, docs/box-local-testing.md, scripts/bump-box-release.ts, boxRelease.ts, boxRelease.test.ts and boxProfileResolver(.test).ts. Some of it is semantic as well as textual. #2893 renames the assets to box-cli-v<version>-<target>.tar.gz and adds an optional darwin.version. The new release() helper here hard-codes box-v${version}-${target}.tar.gz and builds darwin without a version, so whichever PR lands second needs to carry the other's asset naming and the darwin.version field 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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)!;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 leo237 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Merge conflict: resolved. The conflict in src/core/project/boxValidation.ts was resolved the way I suggested. Both import sets are kept (RegionUnsupportedFeatureError, supportsRuntimeV2, boxReleaseOfRuntime), and assertBoxVersionsSupported and assertBoxRegionSupported both sit after validateBoxRuntimes. No other file in the merge differs from either parent. GitHub now reports the PR as MERGEABLE, and the merge base is the current box-integration head. I also checked how the merged code fits together. Deploy still calls assertBoxRegionSupported before validateBoxRuntimes, so both refusals happen before anything is written. The #2878 deploy tests use FakeBoxProfileResolver and don't set an unsupported box.version, so this PR's version check shouldn't affect them. boxRelease.json didn't change, so the pins I checked last time still apply.
  2. CI: running, not finished. verify / Linux, verify / Windows, verify / macOS and Analyze were all still pending when I posted this (e2e is 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants