Repository navigation
Conversation
add gateway-target (CLI and TUI) and add gateway-connector now refuse the names 'bedrock', 'agentcore' and 'egress-*' on a Box gateway. Build writes targets with these names. A user target with one of these names took the agent's Bedrock or Memory route, or build changed or removed it. The check is in ProjectManager.addResource, which both paths use. The same names stay valid on a gateway that is not a Box gateway, and the targets that build writes stay valid in agentcore.json.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## box-integration #2864 +/- ##
================================================
Coverage 96.79% 96.80%
================================================
Files 766 766
Lines 66803 66856 +53
================================================
+ Hits 64665 64719 +54
+ Misses 2138 2137 -1 ☔ 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 #2864: refuse build-owned target names on a Box gateway
Decision: APPROVE. All findings below are non-blocking.
Plan mapping. This PR is not one of the plan PRs. It is a standalone follow-up on box-integration that fixes a blocking item from the #2839 review. box-integration-development has no equivalent commit (I checked git log --grep and git grep for reservedBoxTargetName and the refusal text). So there is no commit list to check against the plan, and nothing is ported twice. The plan doc (https://pippin.amazon.dev/docs/XFRmP1pP9L90nl/box-integration-squash-and-pr-plan-v2) returned 401, so I checked against the branches directly.
Base and conflicts. The base is box-integration and GitHub reports the PR as MERGEABLE. The branch forks at dd36f7b2 (#2853), so #2857 is not in it. The diff is additive: five files, +135/-3, and the only lines removed are import lines. None of the box-integration-only fixes from #2845, #2848/#2849, #2850, #2851, #2852, #2853 or #2857 are touched or reverted. A trial merge of this branch with each of #2859, #2860, #2862 and #2863 is clean, with no textual conflicts.
CI. All checks are green: verify on Linux, Windows and macOS, Analyze, CodeQL, and CodeBuild agentcore-e2e. The GitHub e2e job was skipped, as usual.
What I checked
- Test coverage. It is good. The CLI test refuses
bedrock,agentcoreandegress-*on a Box gateway and checks that the gateway stays empty. It also checks the same names are accepted on a non-Box gateway. Another test checks that build's own targets still passProjectSpecSchemaand that a new target can still be added. The TUI test covers the wizard error and confirms no target is written. There are no Windows-unsafe patterns: no paths, nosh, no file modes.- Nit: the PR body says
add gateway-connectoris covered, and it is, becausetoAddGatewayConnectorInputgoes throughaddResource. No test pins it, though. Oneadd gateway-connector --name bedrockcase on the Box gateway would.
- Nit: the PR body says
- Silent failures. The new check throws
InputValidationErrorand nothing is swallowed. Projects that already have a userbedrockoragentcoretarget on a Box gateway, from before this PR or from a hand edit, still go through silently.placeTargettreats such a target as the user's and leaves it, so the agent's route goes to it with no warning. The PR body explains why the schema can't refuse these names. A build-time warning for a non-build-shapedbedrock/agentcoretarget on a Box gateway would close that gap. Optional, for a follow-up. - Comment accuracy. The comments are accurate. For
bedrock/agentcore,placeTargetkeeps a same-named user target, so that target takes the route. Foregress-*,boxNetworkdrops unmanaged-claimed targets, so build rewrites or removes them. Both doc comments match that behavior. - New types. None.
reservedBoxTargetNameProblemreturnsstring | undefined, like the existing*Problemhelpers (targetHostProblem,policyFileProblem). It reuses the existing constants andisManagedTargetinstead of copying the strings. - General. See the inline comments. The main point is about
agentcore/bedrockon a non-Box gateway in a Box project. It is non-blocking because the later failure is loud, and the cross-gateway duplicate-name case is covered by #2860.
Open items from earlier reviews (this PR does not address them, and doesn't need to)
None of these are in scope for this PR, and all stay open for later PRs: the network?.region ?? DEFAULT_EGRESS_BEDROCK_REGION fallback, the empty .venv getting past dev's Python check, the unreported credential refresh failure and the misspelled AWS_PROFILE, dev not applying the box.version rule, the "before anything is written" comment, the wrong refusal message after remove, the seven duplicated template files, the missing start.py test, 29d283d6's skipped telemetry targets, the missing local-profile tests for A2A/AG-UI/MCP, and #2859's silently empty profile.
Known flaky CI on the base is non-blocking: the Windows transactionSearch EFAULT test, and the occasional 5 s macOS screen-test timeouts.
| `and egress calls. Choose another name.`, | ||
| InputValidationError, | ||
| ); | ||
| // The same name is the user's on a gateway that is not a Box gateway. |
There was a problem hiding this comment.
Non-blocking. This test asserts that agentcore is accepted on the non-Box gateway tools in a Box project. Build then refuses that same project if a boxed runtime has the default Memory: addBoxMemoryTarget calls refuseTargetNameOutsideBoxGateways(spec, "agentcore", ...), which says "gateway 'tools' has a target named 'agentcore' ... Rename that target." So add accepts a name that the next build rejects. The failure is loud, not silent, but the PR body's line "On other gateways, these names stay available" doesn't hold for agentcore in a Box project.
Two options:
- In
addResource, also refuseagentcoreon a non-Box gateway whenprojectType === "box", soaddmatches build's rule. - Keep the current behavior and say in the PR body or comment that build enforces the name project-wide.
bedrock on a non-Box gateway is a related case. Build then writes a second bedrock target on the Box gateway, and today's L3 output keys don't include the gateway name. #2860 (identifierOf, with L3 #470) already handles that case, so it isn't an issue for this PR.
| const parent = projectSpec.agentCoreGateways.find( | ||
| (candidate) => candidate.name === input.gatewayName, | ||
| ); | ||
| const reserved = |
There was a problem hiding this comment.
Non-blocking nit. This only covers add. If a project already has a user bedrock/agentcore target on a Box gateway, from before this PR or a hand edit, placeTarget keeps it as "the user's", and the agent's model or Memory route goes to it with no message. A one-line build warning when the existing target is not the build shape would make that visible. Fine as a follow-up.
tejaskash
left a comment
There was a problem hiding this comment.
Thanks, the refusal of build-owned names works for add gateway-target, --target-configuration, add gateway-connector and the TUI, and it fails the CLI and TUI tests when removed. Requesting changes because this is the follow-up for the #2839 review, and two of its three items aren't in here yet:
- MCP, connector and Lambda targets on a Box gateway still get no Runtime route, so the boxed agent can't call them. Routing still keeps only passthrough targets (
boxProfile.ts:627-629, andruntimeProfile/rules/gateway.ts:118-119onbox-integration). Either add a route for the gateway host and prove it with one e2e call, or bring back a passthrough-only check until then. boundRuntimeNotestill checksboundRuntimedirectly (handlers/project/add/shared.ts:114-115) instead ofisBoundGateway, and the two line builders inremove/notice.ts(removedGatewayLinesandboundGatewayWarningLines) are still separate.
If you'd rather keep this PR to the name check, that's fine, just point at the follow-up that takes these two. A couple of things on the check itself inline.
| (candidate) => candidate.name === input.gatewayName, | ||
| ); | ||
| const reserved = | ||
| parent && isBoundGateway(parent) |
There was a problem hiding this comment.
This gates on isBoundGateway, but build only writes bedrock, agentcore and egress-* targets for runtimes that runtimeRunsInBox accepts (boxMemory.ts:60-62, boxNetworkSource.ts:51). So a Box project runtime with no box.version, or a bound gateway outside a Box project, gets refused with "build writes the targets", which isn't true there. Could this gate on runtimeRunsInBox(projectSpec, boundRuntime)? The new tests run against a runtime from agent-typescript-vercel with no box.version, so they'd need one too.
There was a problem hiding this comment.
Fixed in 929cbe2. The check now refuses these names only on the Box gateway of a runtime that runtimeRunsInBox accepts. The tests give the runtime a box.version. A new test adds each name on a bound gateway whose runtime has no box.version, and it accepts them.
| * rewrite or remove it. | ||
| */ | ||
| export function reservedBoxTargetNameProblem(name: string, gateway: string): string | undefined { | ||
| if (!BOX_DEFAULT_TARGET_NAMES.includes(name) && !isManagedTarget({ name })) return undefined; |
There was a problem hiding this comment.
Heads up, this conflicts with #2877, which changes isManagedTarget to take a full target and require build's shape, so isManagedTarget({ name }) won't compile after it. #2877 also stops build removing a user's egress- target, so half of the reason in the comment above goes away. Whichever merges second needs a plain check like name.startsWith(BOX_EGRESS_TARGET_PREFIX). Also small: boxMemory.ts already owns two of these three names and imports isBoundGateway, so this helper would sit better there than in the network model.
There was a problem hiding this comment.
| ).toEqual(["bedrock", "agentcore", "egress-api-example-com"]); | ||
| }); | ||
|
|
||
| test("keeps the targets build writes on a Box gateway valid", async () => { |
There was a problem hiding this comment.
This one passes with the new check removed, so it doesn't test this PR. It guards a schema rule the PR didn't take. If it's wanted, it belongs in project.test.ts.
There was a problem hiding this comment.
Fixed in 5461f2f. No schema test covered these targets, so I moved the test to project.test.ts as a schema test. I removed it from index.test.ts.
| await writeProjectSpec(projectRoot, { ...spec, projectType: "box", agentCoreGateways: [box] }); | ||
| await addGateway(); | ||
|
|
||
| for (const name of ["bedrock", "agentcore", "egress-api-example-com"]) { |
There was a problem hiding this comment.
Small one: three names in one loop share the tools gateway's state across iterations. A test.each over the names would match the rest of the file and say which name failed.
There was a problem hiding this comment.
Fixed in 1a231a0. The tests now use test.each over the three names, with a new project for each name.
# Conflicts: # src/core/project/boxNetwork/network.ts
The check now tests the egress- prefix with a plain startsWith, so it does not depend on the signature of isManagedTarget. boxMemory already owns the bedrock and agentcore names and imports isBoundGateway. The import of BOX_EGRESS_TARGET_PREFIX from boxNetwork/egress makes no runtime import cycle. The comment now gives only the reason that stays true: a user target of such a name takes the agent's Bedrock or Memory route, or the name of an egress target that build writes.
…s in a box Build writes the bedrock, agentcore and egress- targets only on the Box gateway of a runtime that runtimeRunsInBox accepts. The check gated on isBoundGateway, so it also refused these names on a bound gateway whose runtime does not run in a box, with a reason that is not true there. The tests give the runtime a box.version, and a new test adds the three names on a bound gateway whose runtime has no box.version.
The refusal and acceptance tests now use test.each over the three names, with a new project for each name, so a failure names the target name and no state carries over from another name.
The test that build's bedrock, agentcore and egress- targets stay valid on a Box gateway tests ProjectSpecSchema, not add gateway-target: it passed with the name check removed. It is now a schema test in project.test.ts, where no test covered these targets before.
The wizard note now asks isBoundGateway whether a gateway is bound, as the rest of the code does, and does not check boundRuntime itself.
… function removedGatewayLines and boundGatewayWarningLines were near copies. One function, boundGatewayLines, now makes both: the lines before the removal name each bound gateway and its targets, and the lines after it name each removed gateway and its target count. The text does not change. A new unit test pins each form for zero, one and more targets.
|
Item 2 is fixed in 7cb96da and cb5bee7. Item 1 is by design. By default, box creates and routes only passthrough targets. A user can add any target type to the Box gateway, which is why #2839 removed the limits. Since #2866, build derives the Runtime box profile from the local box profile of each runtime. Thus the user sets the routes of the boxed agent there. This branch also merges the current |
leo237
left a comment
There was a problem hiding this comment.
Re-review of #2864 at cb5bee7
Decision: APPROVE. Everything below is non-blocking.
Scope. I approved this PR at 1661e23. This review covers the new commits 65b494f..cb5bee7. I left out the base content that the merge 65b494f brings in. To do that, I compared the net diff box-integration...pr (10 files, +229/-40) with the diff at 1661e23.
Base and CI. The branch now includes #2883. It is 6 commits behind box-integration, at #2885, and has no conflicts, so that is not blocking. All checks pass: verify on Linux, Windows and macOS, Analyze, CodeQL, and CodeBuild agentcore-e2e. The GitHub e2e job was skipped, as usual.
Review comments that are now addressed
- Gate on
runtimeRunsInBox(929cbe2).reservedBoxTargetNameProblemnow refuses a name only when the gateway is bound and itsboundRuntimeis one ofboxedRuntimes(spec). That is the same set of runtimes that build writesbedrock,agentcoreandegress-*targets for. A gateway binds to only one runtime. So in a project that has both boxed and non-boxed runtimes, each gateway goes by its own runtime, and there is nothing to break a tie between. An unbound gateway is never refused. A newtest.eachchecks that the names are accepted on a bound gateway whose runtime has nobox.version. - Dependency on
isManagedTarget(e6376c9). The check now lives inboxMemory.tsand usesname.startsWith(BOX_EGRESS_TARGET_PREFIX), so #2877's change to theisManagedTargetsignature no longer breaks it.boxNetwork/egress.tsimports onlyzodand types, so the new import creates no cycle. - A test that passed without the check (5461f2f). That test is now a schema test in
project.test.ts. It checks that thebedrock,agentcoreand anegress-passthrough target that build writes all passProjectSpecSchemaon a Box gateway, so build's own output is not refused. The refusal itself is inadd(FsProjectManager), not in the schema, so a hand-editedagentcore.jsonstill validates. - State shared across names (1a231a0). The tests now use
test.eachover the three names, with a new project for each one. - TUI refactors (7cb96da, cb5bee7). Both keep the old behavior.
isBoundGatewayisboundRuntime !== undefined, which is the same as the old inline check.boundGatewayLinestells the two inputs apart with"targetCount" in gateway. It keeps the oldremovedGatewayLinesbehavior: no filter, and the target count. It also keeps the oldboundGatewayWarningLinesbehavior: a filter onboundRuntime, and the target names. The text is the same, and the newnotice.test.tschecks both forms with zero, one and several targets.
Merge 65b494f and fixes that must survive
The PR's net diff against the base only adds lines in boxMemory.ts (an import plus the new helper) and in manager.tsx (the import plus the check in addResource). #2883's partition-aware Memory and Bedrock ARNs and its DNS suffixes are unchanged. The PR does not touch boxNetworkWriters, boxProfileCredentials, ENV_LOCAL_RELATIVE_PATH, writesBedrockRoute/tomlKey, the X-Ray grants, runtimeRunsInBox, the per-runtime profiles, --containment, enableApplicationLogs or the #2885 OTEL changes. No fix is lost.
Consistency with #2877 (still open, so this is about merge order and does not block)
- The reserved names are
bedrock,agentcoreand every name that starts withegress-. #2887'segress-gateway-<name>targets fall under that prefix. - #2877 records build's targets in
agentcore/box-gateway-targets.json, and build then keeps a user'segress-*target as the user's. That does not contradict this PR. #2877 makes build safe for anegress-*target that already exists or was edited by hand. This PR stopsaddfrom creating a new one, so a user target cannot take the name of a target that build writes. Once #2877 merges, the reason in the doc comment ("the name of an egress target that build writes") is still true. - With #2877 merged, the refusal is a policy choice: it is stricter than build needs. A one-line note in the PR body or the doc comment would help readers. It would say that hand-written
egress-*targets still work under #2877, and thataddrefuses the prefix only to avoid name collisions.
Trial merges (FYI)
- With #2877 and with #2886: clean.
- With #2887: one textual conflict, in the
manager.tsximport block. This PR addsimport { reservedBoxTargetNameProblem } from "./boxMemory"and #2887 addsisManagedTargetto the./boxNetworkimport. Keep both lines.
Still open, non-blocking (from my earlier review)
- No test pins
add gateway-connector --name bedrockon the Box gateway. - If a project already has a user
bedrockoragentcoretarget on a Box gateway, from before this PR or from a hand edit, build still uses it silently. A build warning would fix this, in a follow-up. - In a Box project with a boxed runtime that has the default Memory,
addacceptsagentcoreon a non-Box gateway, but build later refuses it, with a clear error. See the inline comment. - Small point: the check refuses
bedrockeven for a runtime that does not call Bedrock (MCP), andagentcorefor a runtime with no default Memory. Build would write neither target there. Being conservative keeps the rule simple, so this is fine. - The open items from earlier box reviews that I listed at 1661e23 are still out of scope.
Other checks. The new tests have no Windows-unsafe patterns: no host paths, no splitting on :, no file modes, no sh or python3, and no network. The diff and the PR's own commit messages contain no internal references or account IDs. The Co-authored-by lines in the range come from base commits brought in by the merge. box-integration-development does not have this change yet. A back-merge is needed there, but that does not block this PR. The squash-plan doc returned 401, so I checked against the branches directly.
Known flaky CI on the base does not block: the Windows transactionSearch EFAULT test, and the occasional macOS screen-test timeouts.
| ): string | undefined { | ||
| const boxed = boxedRuntimes(spec).some((runtime) => runtime.name === gateway.boundRuntime); | ||
| if (!isBoundGateway(gateway) || !boxed) return undefined; | ||
| if (!BOX_DEFAULT_TARGET_NAMES.includes(name) && !name.startsWith(BOX_EGRESS_TARGET_PREFIX)) { |
There was a problem hiding this comment.
Non-blocking, about merge order with #2877. After #2877, build keeps a user's egress-* target as the user's, by its record in agentcore/box-gateway-targets.json. So this prefix check stays only as a guard against name collisions with the targets build writes, and #2887's egress-gateway-<name> targets are covered. The two PRs are consistent. A short note here, or in the PR body, would help readers: it would say that hand-written egress-* targets still work after #2877, and that add refuses the prefix only for new targets.
| `and egress calls. Choose another name.`, | ||
| InputValidationError, | ||
| ); | ||
| // The same name is the user's on a gateway that is not a Box gateway. |
There was a problem hiding this comment.
Non-blocking, carried over from my last review. Here add accepts agentcore on tools in a Box project whose runtime is boxed. If that runtime has the default Memory, build later refuses the project through refuseTargetNameOutsideBoxGateways. The error is clear, so this is fine. Making add and build agree on this would be good in a follow-up.
Description
This PR fixes a blocking item from the review of #2839 ("Box integration: review of merged PRs"):
add gateway-targetandadd gateway-connectornow refuse these names on a Box gateway:ProjectManager.addResource, so the CLI and the TUI both get it.isBoundGatewayaccepts. On other gateways, these names stay available.reservedBoxTargetNameProblem(boxNetwork/network.ts) uses the existing constantsBOX_GATEWAY_BEDROCK_TARGET_NAME,BOX_GATEWAY_AGENTCORE_TARGET_NAMEandisManagedTarget. It does not copy the strings.The error:
The check is not in
ProjectSpecSchema.superRefine. Build writes targets with these names into agentcore.json, so a name-only schema check would reject build's own targets.This PR does not limit target types on a Box gateway. Box creates and routes only passthrough targets. A user can add any target type to the gateway, as #2839 allows.
Related Issue
None.
Documentation PR
Not applicable.
Type of Change
Testing
bun test: 5335 pass, 6 skip, 1 fail. The failure isthe box on PATH > resolves a profile into the rules the tests fake. It also fails onbox-integrationwithout this change, because the localboxbinary has nometadata_hostsrule.bun run test:e2e, or explained why they are not applicable(CI does not run them for you). Not run: the change is a local input check, and the unit tests cover it.
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 themby this PR
New tests:
bedrock,agentcoreandegress-api-example-comare refused on a Box gateway, and the gateway stays empty.ProjectSpecSchema, and a new target can still be added.bedrockon a Box gateway and writes no target.