Repository navigation
fix(box): Address the open review of the merged Box PRs - #2886
mquang-amazon wants to merge 9 commits into
Conversation
…p BOX_MINIMUM_VERSION Addresses the review of #2850: - agentcore build --region ignored the flag: the handler passed no region and boxBuildRegion read only the environment. build takes the region now, and resolveRegion takes an environment, so boxBuildRegion goes. - The box download notice waited until staging ended; eventsWhile yields it when the download starts. - BOX_MINIMUM_VERSION goes: the box features and the profiles the CLI writes change together, so only the pinned box is supported.
…ith static imports Addresses the review of #2852: the tests now give AWS_CONFIG_FILE, AWS_PROFILE, and both home variables through env, check that process.env is not read and that HOME comes before USERPROFILE, and cover the order resolveRegion takes.
- Revert the trailing newline five non-box gitignore.template files gained, so their output matches v1.x. - agent-python-strands-box keeps only the two files that differ (its Dockerfile and .gitignore); the resolver lays them over agent-python-strands. - Each box shortcut is a spread of its twin, so a change to one reaches both. - The empty .venv is part of the box CodeZip files (boxCodeZipFiles), which create and add runtime both write, not a --skip-install branch of create. - The LangChain README says traces are not collected when the agent runs in a box. - renderBoxProfile takes its region; the unused us-west-2 fallback goes, and its JSDoc says where box starts for a CodeZip agent. - Two tests use test.each.
…s, and when build fills a blank one Addresses the review of #2862: - With the credential's reserved variable (AGENTCORE_CREDENTIAL_<NAME>) set in the environment, deploy provisions it while dev hands box the route's variable. Build now says so when the two hold different keys. - Build filled a blank stored key in .env.local with no message; it says so now, as it does for a different key.
- Add the egress test on AgentCore Runtime: the egress agent deployed in a box reaches the profile's host through the Box gateway, and box refuses any other. It shares its agent and checks with the dev test. - Install the AGENTCORE_E2E_BOX_CDK build only in projects that deploy; the dev and dev-egress cases have no use for it. - Drop the README sentence that the per-Python cases wait for #2867, which has merged.
…version plumbing Addresses the review of #2867: - A pin bump stopped every existing Box project: build refused any box.version but the pin, and nothing rewrote the field. Build and deploy now set each box runtime's box.version to the pinned box (boxVersionWriter) and say so, since the box features and the profiles the CLI writes change together. The late stop in staging goes with it. - boxReleaseFor, the per-version build Map, and the release getters of the staging functions and the container dev runner go: each stages BOX_RELEASE. Tests no longer stage 1.0.0 and 2.0.0 through fakes, and a build test covers the update. - The testing guide is rewrapped to 100 columns and says how to publish an unreleased box; the pinned-release test title matches its assertions.
Addresses the review of #2850: the role could invoke any Bedrock model in any region. It may now invoke an inference profile of its own account in the region build builds for, a foundation model there, and a foundation model in another region only through an inference profile in that region, which is how a cross-region (us., global.) profile reaches it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## box-integration #2886 +/- ##
================================================
Coverage 96.79% 96.80%
================================================
Files 766 766
Lines 66803 66820 +17
================================================
+ Hits 64665 64682 +17
Misses 2138 2138 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
leo237
left a comment
There was a problem hiding this comment.
Review of #2886 at 6072b2c1 (first review)
Decision: APPROVE. I found nothing blocking. The branch is up to date with box-integration, and it reverts none of the earlier fixes I checked. Linux, Windows, CodeQL and Analyze pass. verify / macOS was still pending when I posted. One thing needs coordination before merge: the Bedrock grant in 6072b2c1 duplicates #2883, and the two conflict (see below).
I reviewed the PR one commit at a time. I did not run anything (no build, no tests).
#2850: 24d7002a (build --region, download notice, BOX_MINIMUM_VERSION)
- Region order.
resolveRegion(flag, env)takes--region, thenAWS_REGION, thenAWS_DEFAULT_REGION, then the config file, thenDEFAULT_REGION. This is the same orderboxBuildRegionused, now with the flag first. Thebuildhandler passesctx.value(RegionKey), whichwithRegionhas already resolved.applyBoxNetworktakes that region, so the gateway targets, the Runtime profiles, the Memory policy and the Bedrock policy all use the same region. Create's fallback goes throughresolveRegiontoo.region.test.tscovers the full order and the fallback, andbuild/index.test.tscovers the handler. - Nit, not in the diff: the TUI build screen (
src/handlers/project/build/screen.tsx:42) still callsprojectManager.build(project)with no region. With no region, build resolves it from the environment, so a global--regionis ignored on that path. Passingctx.value(RegionKey)would make the two entry points match. eventsWhile. I traced it. Each event is yielded as soon as it is emitted. A failure is thrown after the events emitted before it.running.then(finish, finish)stops an unhandled rejection when the consumer returns early.BOX_MINIMUM_VERSION. I grep'd the PR head: no reference toBOX_MINIMUM_VERSION,BOX_MINIMUM_RELEASE_PAGEorBOX_OTHER_MACHINE_HINTremains, and no code compares versions.BOX_OTHER_MACHINE_HINTwas the hint for machines the pinned release had no build for. Dropping it looks fine, because the testing guide now lists anaarch64-apple-darwinbuild in the pinnedpreview.10release. I could not open that release page from here to confirm it.assertBoxRuntimesHaveBoxVersionis unchanged.
#2850: 6072b2c1 (Bedrock grant scoped to the build region). This overlaps #2883
The IAM looks correct. It follows the same pattern as #2883, which I approved:
- Statement 1: inference profiles in
region, withaws:ResourceAccount == ${aws:PrincipalAccount}. System-definedus.andglobal.profiles carry the caller's account in their ARN (inference-profiles-prereq), so they match. - Statement 2: foundation models in
region. - Statement 3:
arn:aws:bedrock:*::foundation-model/*, only whenbedrock:InferenceProfileArnmatches the in-region profile, usingStringLike. The*region also covers the region-lessarn:aws:bedrock:::foundation-model/*thatglobal.profiles are checked against (global cross-Region inference). So cross-region inference keeps working.
Compared with #2883 (555f19c6): both PRs have the same three statements and the same region === undefined guard in defaultTargetsWriter. #2883 is a strict superset:
- It takes the partition from
partition(region).name. This PR hard-codesarn:aws, so the grant would match nothing inaws-cnoraws-us-gov. - It pins the account inside the
bedrock:InferenceProfileArncondition (...:${region}:${aws:PrincipalAccount}:inference-profile/*). This PR uses*there. Statement 1 already limits the profile to the caller's account, so the gap is defense in depth only. - It has more tests:
boxNetworkWriters.test.tsandnetwork.test.ts.
A trial merge shows the two PRs conflict in boxMemory.ts and boxMemory.test.ts. I recommend landing #2883's version and dropping 6072b2c1 from this PR (or rebasing it away once #2883 merges). Keep this PR's manager.boxNetwork.test.ts case, which checks the policy file for the build region, if #2883 does not already cover it.
#2852: e485dcbd (region tests)
The tests use static imports and pass every input through env. The test that touches process.env restores AWS_CONFIG_FILE, AWS_PROFILE and HOME afterwards. The HOME-before-USERPROFILE and AWS_PROFILE cases are there. I saw no unsafe test patterns: no hard-coded host paths, POSIX modes or spawned processes.
#2857: 08fb9432 (template dedupe)
- The resolved box template has the same files as before. I compared each file the base
agent-python-strands-boxhad withagent-python-strandsat the PR head.README.md,dockerignore.template,main.py,memory/__init__.py,memory/session.py,model/__init__.py,model/load.py,parse.pyandpyproject.tomlare all byte-identical. OnlyDockerfile.templateandgitignore.templateare box-specific, and they stay.replaceChildrenreplaces only top-level children, which is all these two files need. Both trees use the sameoptions, so the renamedDockerfileand.gitignorematch by name, and the CodeZip filter drops the Dockerfile from both. The newruntime.test.tscase checks that the two trees are equal apart from those two files. - The shortcut spreads give the same values for all seven box twins. I checked each one by hand.
- gitignore bytes: the five non-box files are back to the v1.x bytes, with no trailing newline. That is harmless, because they are rendered as they are.
.venv:boxCodeZipFileswritesstart.pyand an empty.venv.add runtimewrites them withskipExisting..venvis recorded inscaffoldedPathsby hand, becausewritereports only files. Create now writes the empty.venvwith or without--skip-install, anduv syncfills it. Thetest.eachcovers the CodeZip, container and plain cases.- The LangChain README
{{#if box}}branch matchesenableOtel: falsefor box runtimes, and a test covers it.renderBoxProfilenow requires a region, and both callers pass one.
#2862: 0a84859c (credential messages)
The logic is right. When the shell exports the reserved variable, build stores nothing, and it names the mismatch only when the route's key is set and different. A blank or whitespace-only stored key gets the new "setting ... which is blank there" message. The three new tests cover a mismatch, a match, and a blank key. The wording is clear.
#2865: 89b4acff (e2e)
- The new deployed
box-egresstest is gated onBOX_DEPLOYS, which needs bothAGENTCORE_E2E_BOX_CDKandboxon PATH. Itsfinallyblock runsremove alland thendeploy, and a cleanup error does not hide the primary failure. - It reaches only
checkip.amazonaws.comandexample.com, which is expected for this opt-in test. deploys: falsekeeps the opt-in CDK install out of the dev cases.- As the PR says, nobody has run it against AWS yet. Please record one run (the 403 from the denied host on Runtime is the part I could not check).
#2867: 9e09dcff (only the pinned box)
- Staging now always uses
BOX_RELEASE, with pinned checksums, so only the pinned box can ship. This keeps the goal of vvargu's request on #2867. - Design change: vvargu asked on #2867 for build and deploy to stop on a
box.versionother than the pin. This PR instead rewritesbox.versioninagentcore.jsonand prints a message. I think that is reasonable after a pin bump, but it reverses a reviewer request that was merged, so please confirm vvargu agrees. boxVersionWriterupdates only runtimes that appear innetworks. That is fine, because staging uses the pin anyway. A build test covers the update.- Nit (inline): the
BOX_NETWORK_WRITERSJSDoc is now orphaned aboveboxVersionWriter's doc block.
Earlier fixes that must survive
Present at the PR head: assertBoxRuntimesHaveBoxVersion, runtimeRunsInBox, ENV_LOCAL_RELATIVE_PATH, EnvLocalFile.upsert, writesBedrockRoute / tomlKey, Dockerfile curl --retry 3 and tar --no-same-owner, the xray grants, ${{ inputs.gateway.url }} and ${{ inputs.aws.region }}, boxStartFolder, .venv/bin/python, publishInstall, --containment, the enableApplicationLogs notice, and the pin 0.1.11-preview.10. There is no SHA256SUMS.txt lookup in code and no refuseOldShippedNames. The only removal is BOX_OTHER_MACHINE_HINT, which is intentional (see above).
Hygiene
- The diff and commit messages add no account IDs and no internal URLs. The docs rewrap carries over a sentence that names internal credential tooling. That sentence is already on the base branch, so it is not new here, but consider making it generic in a follow-up.
- On the "Not changed here" list: the 0644 dev credentials reasoning holds. The host folder is 0700, and inside the container only uid 1000 and root exist, so 0600 would let in the same processes.
Conflicts with other open PRs (trial git merge-tree, non-blocking)
- #2883: conflicts in
boxMemory.tsandboxMemory.test.ts. This is the duplicate Bedrock grant above. - #2877: conflicts in
docs/box-local-testing.md,backends/boxCodeZip.tsandmanager.boxNetwork.test.ts. - #2885: conflicts in
docs/box-local-testing.mdandbackends/cdk.ts. - #2878, #2879 and #2882 merge cleanly.
Most of the doc conflicts come from rewrapping docs/box-local-testing.md to 100 columns.
This is an off-plan follow-up, and it is not on box-integration-development yet, so it will need a back-merge (non-blocking).
| region: string, | ||
| ): Record<string, unknown> | undefined { | ||
| if (boxedRuntimesCallingBedrock(spec).length === 0) return undefined; | ||
| const profiles = `arn:aws:bedrock:${region}:*:inference-profile/*`; |
There was a problem hiding this comment.
#2883 (555f19c6) changes this same function, and the two PRs conflict here. #2883 is a superset: it takes the partition from partition(region).name instead of arn:aws, and it pins ${aws:PrincipalAccount} in the bedrock:InferenceProfileArn condition on statement 3 (line 151). The IAM here is otherwise equivalent and correct. I suggest landing #2883's version and dropping this commit.
| @@ -482,7 +487,34 @@ function withoutUnsentRoutes( | |||
| } | |||
|
|
|||
| /** The writers that build and deploy run before synth, in order. */ | |||
There was a problem hiding this comment.
Nit: this JSDoc belonged to BOX_NETWORK_WRITERS. With the new block inserted below it, it is orphaned, and BOX_NETWORK_WRITERS has no doc. Moving it down to sit above export const BOX_NETWORK_WRITERS fixes that.
There was a problem hiding this comment.
Done in ba28e29: the JSDoc is back above BOX_NETWORK_WRITERS.
| networks.flatMap(({ runtime: name }) => { | ||
| const runtime = copy.runtimes.find((candidate) => candidate.name === name); | ||
| const version = runtime?.box?.version; | ||
| if (!runtime?.box || version === BOX_RELEASE.version) return []; |
There was a problem hiding this comment.
On #2867, vvargu asked for build and deploy to stop on a non-pinned box.version. This rewrites the field instead, and only the pinned box is staged, so the goal of that request still holds. Since this reverses a merged reviewer request, it is worth confirming they are fine with rewriting. Non-blocking.
There was a problem hiding this comment.
Agreed, it reverses the letter of that request while keeping its goal: only the pinned box ships, and the field now says which one, instead of a pin bump stopping every existing Box project. I will confirm with vvargu before merge.
There was a problem hiding this comment.
Tejas asked for this in his review of #2867: "A pin bump breaks every existing Box project. boxRelease.ts:299-306 refuses any box.version other than the pin, nothing rewrites the field, and the bump in #2871 is already merged… Since only one value is legal, always stage BOX_RELEASE and let build update the field." Only the pinned box still ships, so the goal of the original request holds.
…' JSDoc on BOX_NETWORK_WRITERS Addresses the review of #2886: the build screen called build with no region, so a global --region was ignored there; it passes the region withRegion resolved, as the command does.
leo237
left a comment
There was a problem hiding this comment.
Re-reviewed 6072b2c..9b179c8. Approving again.
- ba28e29: the build screen now passes
ctx.value(RegionKey)tobuild, the same way thebuildcommand does, so--regionapplies in the TUI too. The JSDoc sits aboveBOX_NETWORK_WRITERSagain. - 9b179c8: after the revert,
boxMemory.tsandboxMemory.test.tsmatch the merge-base, and thebox-bedrock-policy.jsontest is gone. A trial merge withbox-integration(which has #2883) is clean. The branch is 6 commits behind base, with no conflicts. - CI is green on 9b179c8.
Still open, none blocking:
box.versionrewrite: you said you'll confirm with the requester before merging.- The deployed
box-egresse2e hasn't been run against AWS yet. - Back-merge to
box-integration-development. - FYI, trial merges still conflict with open PRs: #2877 (
docs/box-local-testing.md,backends/boxCodeZip.ts,manager.boxNetwork.test.ts), #2885 (docs/box-local-testing.md,backends/cdk.ts) and #2887 (docs/box-local-testing.md,manager.boxNetwork.test.ts). Whichever PR lands second will need a rebase.
| error={null} | ||
| action={async function* () { | ||
| yield* core.projectManager.build(project); | ||
| yield* core.projectManager.build(project, { region }); |
There was a problem hiding this comment.
Nit, not blocking: the CLI path has builds for the region --region names in index.test.ts, but nothing covers this screen passing the region. A small screen test asserting that build gets { region } from RegionKey would keep the two paths from drifting apart.
Description
Follow-ups to the review of six merged
box-integrationPRs (#2850, #2852, #2857, #2862, #2865, #2867), from the open feedback on merged PRs. Each commit addresses one PR, so it can be reviewed on its own.#2850: Bedrock through the Box gateway (
24d7002a,ba28e29e)agentcore build --regionignored the flag. The handler passed no region, andboxBuildRegionread only the environment, so the Box gateway targets and the Runtime profiles were built forAWS_REGION.buildnow takes the--regionvalue.resolveRegion(flag, env)takes an environment, soboxBuildRegiongoes, and build,add runtime, and--regionresolve the region the same way.eventsWhileyields it when the download starts.BOX_MINIMUM_VERSIONgoes. The box features and the profiles the CLI writes change together, so only the pinned box is supported. The install hints name only the pinned release. The README and the testing guide say that the CLI does not check the local box version yet, which is a possible later feature.--regionthatwithRegionresolved, as the command does.Not changed here:
The gateway role's Bedrock grant: fix(build): Keep the Bedrock grant of the Box gateway in its region and account #2883 scopes it to the build region and account, and this PR's version (
6072b2c1) is reverted in9b179c8fso the two do not conflict.Region-specific targets written into
agentcore.jsonon every build: a larger design change, punted.The 0644 dev credentials file: the folder is 0700 on the host, and inside the container the only users are the image's user (uid 1000) and root, so a 0600 file owned by uid 1000 lets in the same processes.
The
boxfield in the L3 schema: needs an@aws/agentcore-cdkrelease.#2852: regionFromConfigFile test (
e485dcbd)The tests pass
AWS_CONFIG_FILE,AWS_PROFILE,HOME, andUSERPROFILEthroughenv, with static imports. They check thatprocess.envis not read and thatHOMEcomes beforeUSERPROFILE, and they cover the orderresolveRegiontakes.#2857: a box template for each Python agent (
08fb9432)gitignore.templatefiles are back to theirv1.xbytes (no trailing newline).agent-python-strands-boxkeeps only the two files that differ, itsDockerfile.templateandgitignore.template. The resolver lays them overagent-python-strands(FsTreeNode.replaceChildren)..venvis part ofboxCodeZipFiles, withstart.py, whichcreateandadd runtimeboth write, instead of a--skip-installbranch increateand a copy inadd runtime.renderBoxProfiletakes its region: the unusedus-west-2fallback goes, and its JSDoc says where box starts for a CodeZip agent.test.each.#2862: dev hands box the profile's env:// keys (
0a84859c)AGENTCORE_CREDENTIAL_<NAME>) and the route's variable holds a different key, build says so: dev uses the route's variable, and deploy provisions the reserved one..env.localwith no message. It says so now.#2865: e2e (
89b4acff)box-egresstest on AgentCore Runtime: the egress agent, deployed in a box, reaches the profile's host through the Box gateway, and box refuses any other. It shares its agent and its checks with the dev test, and needsAGENTCORE_E2E_BOX_CDK.AGENTCORE_E2E_BOX_CDKbuild.#2867: ship only the pinned box (
9e09dcff)box.versionbut the pin, and nothing rewrote it. Build and deploy now set each box runtime'sbox.versionto the pinned box and say so (boxVersionWriter), and the late stop in staging goes.boxReleaseFor, the per-version build map, and the release getters of the staging functions and the container dev runner go: each stagesBOX_RELEASE. Tests no longer stage1.0.0and2.0.0through fakes, and a build test covers the update.Related Issue
Closes #
Documentation PR
Not applicable:
README.md,docs/box-local-testing.md, ande2eTest/README.mdare updated in this PR.Type of Change
Testing
bun test(5858 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 new deployed
box-egresstest, the 4 per-Python cases, the 7 dev cases, and the dev egress test need AWS credentials,boxon PATH, andAGENTCORE_E2E_BOX_CDK.vitest listcollects both egress tests.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: no snapshot covers the changed templatescommand.md(the release workflow regenerates it)These new tests fail when their fix is reverted (checked by reverting it):
--regionin the handler and in the manager,box.versionin the writer, the blank-key message, and the region test's home order andAWS_PROFILE.Not tested: a real deploy. The deployed egress test, and the
box.versionupdate need an AWS run.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.