Repository navigation
fix(box): Address the review of the host map and the gateway targets - #2877
SaiAbhishek98 wants to merge 34 commits into
Conversation
…d on one path The host map decides each host on sample requests. A sample path comes from one path test at a time. A permit with two path tests, such as `path like "/v1/*"` and `path like "*/items"`, got no sample that passes both. The host was then unreachable, with no failure, and build gave it no gateway target, but Box allows GET /v1/items. When no sample request is allowed, the host map now searches for a path that the path tests of a permit allow together and that no forbid surely denies (pathSolver.ts). The search is exact for `like`, `==`, and `!=`. When the search is too large (more than 4096 states), the host stays reachable, the permit goes in `uncheckedBy` and `enforcedByBox`, and build gives a warning that names the rule. Tests: hostMap.test.ts "finds a host reachable when two path patterns of one permit hold on one path", "finds a path of a permit that a forbid of one path leaves open", "finds no path when the path patterns of a permit never hold together", "keeps a host reachable, and names the permit, when its path tests are too many to check"; network.test.ts "names a permit whose path tests build cannot check together, and keeps its host". The random-rule property test still passes. Mutations: no search, a search that ignores the forbids, and no state limit each make a test fail.
Box reads a rule as Cedar types it: it does not read the right operand
of `||` after an action test that holds, the right operand of `&&`
after one that does not, the other branch of `if`, or a later `when`
after an action test that is false. So box 0.1.11-preview.10 accepts
`permit (principal, action == Box::Action::"net:connect", resource)
when { context.input.host == "a" && (action == Box::Action::"net:connect"
|| context.input.method == "GET") }`. The host map read every operand,
refused the rule with UNKNOWN_ATTRIBUTE, and build stopped.
checkAttributes now skips each operand that an action test keeps from
the action (actionValue), and clausesFor stops at a condition that an
action test makes false. A field that no action test keeps from the
action is still refused.
The review's own example puts http:request and net:connect in one rule.
Box 0.1.11-preview.10 refuses that rule for another cause (it reads
context.input under two action families), so the tests use the forms
that box accepts.
Tests: hostMap.test.ts "an attribute that an action test keeps from the
action, as Box reads it" (6 tests: `||`, `&&` with `!=`, `if`, a request
rule that reads ip4, a later `when`, and the refusal of an unguarded
field). Mutations: no `&&`/`||` stop, both `if` branches read, and every
condition read each make a test fail.
…rules Box applies A host's enforcedByBox named the request permits that limit a host and the forbids, but no connection permit. A permit that allows connections to a host only at some addresses (`context.input.ip4 like "10.*"`) is a limit that Box applies and the gateway does not. Build gave no warning for it. The host map now names each connection permit of a reachable host whose every clause there limits the address or has a condition build cannot read. A connection permit with a clause that allows any address is not named. The review's example used `ip(context.input.ip4).isInRange(...)`. Box 0.1.11-preview.10 refuses that form (ip() takes only a literal, and ip4 is a string), so the test uses the form that Box writes itself. Tests: hostMap.test.ts "names a connection permit that limits the address, and not one that allows any". Mutations: no connection permits named, and every connection permit named, each make a test fail.
The host map took the port that a rule fixes (`context.input.port == 65536`, `== 0`, or `== -1`) with no check. Box accepts such a rule, which never holds, but build made a host of `host:65536` and wrote a gateway target for an endpoint that is not a URL. The host map now refuses each rule that fixes a port that is not an integer from 1 to 65535, with the new failure code INVALID_PORT, at the rule's line. A destination of an [egress] entry already had this check (parseDestination). Tests: network.test.ts "fails each rule that names port %d, which is not a port" (65536, 0, and -1, for a connection and a request rule). Mutations: an upper bound of 65536 and a lower bound of 0 each make a test fail.
…asts of the profile parser Box 0.1.11-preview.10 wraps its error at 80 columns. It wraps at a space or inside a word, and starts each next line with 12 spaces. The uv sync hint took the venv path from one line, up to the last space. For a project path with a space, or a path that Box wrapped, the hint named a wrong folder, such as "Run 'uv sync' in agent" or "in /agent". The hint now joins the lines of each Box error in each way (a space or no space at each wrap, up to 8 wraps). It names the folder only when one way gives a folder that is on disk. It quotes a folder that has a space. When no way, or more than one way, gives a folder, the error says "Fix what Box reports". The profile parser and the telemetry reader now use the shared Date-aware isTable of runtimeProfile/projectPaths.ts, TomlError for the place of a TOML syntax error, and type predicates in place of casts. The section banner comments of hostMap.ts and dogwood.ts are removed. Tests: boxProfileResolver.test.ts "the uv sync hint, when Box refuses a missing .venv under a write grant" (5 tests: one line, a wrap at a space in "my agent", a wrap before "/agent", a wrap inside a word, and a path of no folder). A run of box 0.1.11-preview.10 on a project in "/tmp/rf/venv test/proj with space" and on a long path gave the right folder. profileParser.test.ts "places a TOML syntax error at its line and column" pins the TomlError place. Mutations: no space at a wrap, no check on disk, and no quotes each make a test fail.
…has its route rule's @id Box adds the rules route_<name>_connect and route_<name>_request for each [egress.<name>] route, and refuses a profile in which another rule has one of those @ids. The AgentCore Runtime profile names some routes after their gateway target: each other host of an entry (`egress-models-two`), a host that only a rule names, and an entry whose name a target of another host has (`egress-api`). A rule of the user's policy with the @id `route_egress-api_request` is valid locally, but box 0.1.11-preview.10 refused the Runtime profile: "box writes a rule with the id ... so give your rule another id". The gateway rule now gives each such route the first free name of `<name>`, `<name>-2`, `<name>-3`, and so on: a name for which no rule of the local policy, other than the route rules that Box adds itself, has the @id route_<name>_connect or route_<name>_request, and that no other route has. The Box network model gives the derivation these @ids (RuntimeProfileContext.ruleIds). The route still sends its calls to the same gateway target. Tests: gateway.test.ts "names no route so that box adds a rule with the @id of a rule of the policy" (an entry whose route takes the name of its target, and another host of an entry past a name that another route has), and "give a route a free name when a rule of the policy has the @id of its route rule" through buildBoxNetwork. Box 0.1.11-preview.10 refused [egress.egress-api-b-example-com] beside the rule route_egress-api-b-example-com_request (exit 1), and accepts [egress.egress-api-b-example-com-2] beside it (exit 0). Mutations: no check of the rule ids, no check of the other routes' names, and no rule ids from the model each make a test fail.
…her variable `env://GITHUB_TOKEN` and `env://AGENTCORE_CREDENTIAL_GITHUB` both resolve to the API key credential `github`. The Box network model compared the two variable names, found them different, and failed the build and the deploy with API_KEY_CREDENTIAL_SHARED. The same comparison across two runtimes (sharedKeyFailures) failed in the same way. But the two names give one key: build copies the key of `GITHUB_TOKEN` to `AGENTCORE_CREDENTIAL_GITHUB`, the credential's own variable (`seed` in planBoxProfileCredentials), and deploy reads it from there. Both checks now skip an entry that reads the credential's own variable. Two entries that read two other variables for one credential still fail, because the credential can hold only one of the two keys. Not changed: on the first build, before the credential `github` is in agentcore.json, an entry that reads AGENTCORE_CREDENTIAL_GITHUB names the credential after its own entry. Its target is then not written until the next build. Tests: network.test.ts "takes one credential for its own variable and for one other variable, which build copies to it" (in both orders; it replaces the test that pinned the failure); boxNetworkSource.test.ts "takes the credential of another runtime for the credential's own variable". network.test.ts "fails a server that takes the API key credential of an [egress] entry for another variable" still pins the real conflict. Mutations: raw names in the model, raw names across runtimes, and no conflict at all each make a test fail.
…el-provider route its credential
A host whose target sends an API key that no credential of
agentcore.json holds got no gateway target. Build said so only as a
step ("not adding gateway target ..."), not as a warning, and the agent
could not reach the host on AgentCore Runtime. For a model-provider
route that `agentcore create` writes with no key ([egress.openai] with
env://OPENAI_API_KEY, and the same for Anthropic and Gemini), the
credential planner skipped the route with no message. Thus "set the
key and build again" did not work for these routes: build never added
their credential, so their target never came.
This change ports the rule of box-integration-development: a
model-provider route is a route like any other. On AgentCore Runtime its
gateway target sends the key of its credential, so the planner declares
the credential `openai` and stores the key of OPENAI_API_KEY under
AGENTCORE_CREDENTIAL_OPENAI, when that key is set. The planner also
records, for each route that gets no credential, why and what to do
(BoxCredentialPlan.unprovisioned). Build gives a warning for each host
with no target (unsentTargetWarnings): the host, the entry, that the
agent cannot reach it on AgentCore Runtime, and the planner's cause and
fix. The step stays only when build removes a target that agentcore.json
had.
Tests: manager.boxNetwork.test.ts "writes no target for an env:// route
whose key build cannot find, and says what to set", "stages no Runtime
[mcp] server for an HTTP MCP server whose key build cannot find", and
"writes the target of a model-provider route once its key is set, as
the warning says" (the fix of the warning works for OpenAI);
boxNetworkWriters.test.ts "unsentTargetWarnings" (3 tests);
boxProfileCredentials.test.ts "adds a credential for a model-provider
route create writes, from the provider's variable" and "adds a
credential for a route that uses a model-provider name or variable in
another way" (these replace the two tests that pinned the skip).
Mutations: the provider skip put back, no warnings, and no cause for an
unset key each make a test fail.
…nd remove casts and copies
Four smaller items of the review of the Box gateway targets:
- Two box runtimes that stage box in one folder (two CodeZip runtimes
with one code folder, or a container runtime whose build context is
the code folder of another) made staging stop with a programmer error:
"Box network writers 'runtime profile' and 'runtime profile' both
write {...}/.box-dist/profile.toml". ProjectSpecSchema now refuses
them, with the two runtimes and the folder, however the path is
written (`./app/agent` and `app/agent/`).
- network.ts imported boxGatewayAgentCoreHost from
src/handlers/project/shortcuts.ts. The function is now in
boxNetwork/egress.ts, beside the other AWS endpoint names, and
shortcuts.ts imports it from there.
- boxNetworkSource.ts read an IAM policy document through `as` casts.
It now parses the document and each Allow statement with zod, and
uses the shared isTable. The other casts there are gone.
- boxCodeZip.ts and boxContainer.ts each had a copy of the step that
writes the Runtime profile into the staged folder and into
.box/<name>/aws/. Both now use stagedRuntimeProfiles in
boxStaging.ts, in the same order as before.
Not done here: the box model is still on the generic ProjectBackend
input (backends/types.ts `boxNetworks`), and boxNetworkSource.ts still
imports DEFAULT_EGRESS_BEDROCK_REGION from src/handlers/. Both need the
Box gateway constants out of shortcuts.ts, which is an item of
[aws#2789](aws#2789).
Tests: project.test.ts "Box runtimes and the folder build stages box
in" (3 tests); boxNetworkSource.test.ts "counts the actions of an Allow
statement in each form IAM takes, and of no other". The staging,
network, and manager suites pass with no change. Mutations: no folder
rule, no path normalization, and any Effect counted each make a test
fail.
…a user's egress- target Build took each gateway target whose name starts with `egress-` as its own, by the name alone (isManagedTarget, writeGatewayTargets, and the gateway rule of the Runtime profile). So it changed or removed a target that a user added with that name, and stopped on one with another shape (MANAGED_TARGET_CHANGED). Build now records, in agentcore/box-gateway-targets.json, the targets that it writes for each Box gateway, by the gateway's name. It owns only the targets in that record: it adds, rewrites, and removes them, and it keeps each other target, whatever its name. MANAGED_TARGET_CHANGED now applies only to a recorded target, and it says to remove the name from the record to keep the target. The Box network model gives the writers and the Runtime profile one set of the targets build owns (BoxNetwork.managedTargets). A project that an older CLI built has no record of its gateway. For such a gateway, build takes as its own each `egress-` target that has exactly the shape build writes (a CUSTOM passthrough target to an https:// host, with one of the outbound auths build writes), once, and then writes the record. It keeps an `egress-` target of another shape as the user's. A target that build wrote and the user then changed is thus the user's. The record is a file beside agentcore.json and not a field in it: the L3 schema of agentcore.json is strict, so a new field stops synth until the L3 takes it. A malformed record stops build, names the file, and says to remove it. Tests: network.test.ts "the targets build owns" (4 tests); boxNetworkWriters.test.ts "keeps a user's egress- target that the record does not name, and records the targets it writes" and "records no file for a project with no box runtime"; boxNetworkSource.test.ts "the record of the targets build writes" (3 tests); manager.boxNetwork.test.ts "owns only the targets it records, after it takes its old egress- targets once", which also checks the route of the Runtime profile. manager.test.ts expects the new step "writing agentcore/box-gateway-targets.json". docs/box-local-testing.md says the new rule. Mutations: the record not read, every egress- target taken in an old project, and no owned set for the Runtime profile each make a test fail.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## box-integration #2877 +/- ##
===================================================
+ Coverage 96.80% 96.83% +0.02%
===================================================
Files 766 768 +2
Lines 66928 67466 +538
===================================================
+ Hits 64790 65330 +540
+ Misses 2138 2136 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
leo237
left a comment
There was a problem hiding this comment.
Thanks for this — careful work. Each fix is its own commit with a test that fails first, and the PR body says what you checked against Box 0.1.11-preview.10. I read all 11 commits against box-integration (the branch is up to date with base).
Blocking: none. The one CI failure on 8942a80 (CodeQL js/incomplete-url-substring-sanitization at manager.boxNetwork.test.ts:394) is fixed by c065a0a, which compares the host exactly. The bot's thread is now outdated but still unresolved, and the ruleset requires every thread to be resolved, so please resolve it once Analyze/CodeQL pass again on the new head.
What I checked, and found correct
pathSolver.ts: the BFS over the product of thelikeautomata is correct for Cedarlike.*matches any run of characters, including none, and matching is case-sensitive. One stand-in character for every character the patterns do not name is enough. The visited set makes the search finish. At the 4096 bound, the search stops undecided and lets the host through, not drops it.decidethen keeps the host reachable, and puts the permit inuncheckedByandenforcedByBox.buildBoxNetworkwarns with the rule's place. Tests exist for the 13-pattern case and for that warning (network.test.ts:1069). A path that a forbid has unreadable conditions for is still taken as reachable. That matches how sample requests worked before. Each path the solver finds is run throughconsider()again, so the solver cannot add a request that the policy does not allow.conditions.ts: the short-circuit incheckAttributes/actionValue(and||/&&/if, and stopping at a laterwhenthat an action test makes false) matches Cedar's evaluation order. The tests cover each form, and one negative case.INVALID_PORT, thelimitsConnectionIP case, the free-2route names (routeKeysskips both a policy@idand the key of another route), the reserved-variable alias (in the model and insharedKeyFailures), the warnings for a host with no target, and the move ofstagedRuntimeProfiles: each looks correct and has a test. TheboxCodeZip/boxContainersteps keep the same order.- Target record: a missing file uses the old
egress-+ build-shape rule once. A file that is not valid JSON, or does not match the schema, stops with aProjectStateErrorthat names the file and says to remove it, and a test covers this. Build rewrites the record from all box runtimes each time, so a gateway that has gone falls out of it. - All the must-survive fixes I checked are still in place (
ENV_LOCAL_RELATIVE_PATH,writesBedrockRoute/tomlKey,runtimeRunsInBox/assertBoxRuntimesHaveBoxVersion,boxStartFolder,.venv/bin/python,upsert,publishInstall,BOX_OTHER_MACHINE_HINT, the0.1.11-preview.10pin,--no-same-owner,--containment,enableApplicationLogs/enableTraces).verifypasses on Linux and Windows. The new tests use temp folders and no unsafe patterns.
Non-blocking
- Back-merge to
box-integration-development. None of these fixes are on dev yet (findPath,BOX_GATEWAY_TARGETS_FILE,INVALID_PORT,routeKeys,unsentTargetWarnings,boxFolderOf, the alias rule). Only d0f9523's planner rule was already there. Dev still takes ownership from theegress-prefix, so the record design has to land on dev too, or the next phased squash brings the old behavior back. - Item 9 design (you asked). The record file seems right to me, given that the L3 schema is strict. Two suggestions, inline: (a) on the one-time migration, a target named
egress-*whose shape differs is now kept as the user's with no message. Before, it was aMANAGED_TARGET_CHANGEDfailure. A one-time step such as "keeping 'egress-x' as your target: its shape is not one build writes" would make that visible. (b) The docs should say to commitagentcore/box-gateway-targets.json. A clone without it falls back to the heuristic. - pathSolver has no direct unit tests. It is tested only through
hostMap, which coverslikein a permit and==in a forbid. Small table tests forfindPath/pathTestwould pin!=, negatedlike,present,==in a permit, and thefreeCharfallback when§is a literal. - Schema refinement (
project.ts): it is correct, and the error message is clear. Note that it now stops every command for a project that already has two box runtimes in one folder. That project could not stage anyway, so it is fine. On a case-insensitive file system,Appandappstill pass. - Follow-ups / "2 items stay". The PR lists the follow-ups (first-build
AGENTCORE_CREDENTIAL_*naming; the box model onProjectBackendplus theDEFAULT_EGRESS_BEDROCK_REGIONimport, which depend on #2789; the release repository text in the docs), but there is no issue for them. Please file one or link it, so they are not lost. None of them blocks this PR. - CI: I posted while
verify(Linux/Windows/macOS) andAnalyzewere still running on c065a0a. The only change since 8942a80 is that one test line. On 8942a80, Linux, Windows, Analyze, and CodeBuild e2e passed, and macOS was still pending. Please merge only after they pass. Nit: c065a0a usesw.split(":", 1)[0]. That works for this host, but it would fail for ahost:portauthority.w.startsWith("api.openai.com:")would hold for both.
…t on pathSolver.ts
…eps as the user's, for the review comment on network.ts
…review comment on box-local-testing.md
tejaskash
left a comment
There was a problem hiding this comment.
Thanks for the thorough pass, the per-item commits with a failing test each made this easy to check. Twelve of the items are fixed and each test fails when its fix is reverted. Requesting changes for the regression in conditions.ts and the egress- first-build case (inline), plus a few smaller ones.
Also still open and not claimed here, fine as follow-ups: Dockerfile text matching (backends/boxStaging.ts:38, backends/boxContainer.ts:26, :30, :38), the box model on the generic ProjectBackend interface (backends/types.ts:14), boxNetworkSource.ts:17 importing DEFAULT_EGRESS_BEDROCK_REGION from handlers, and build and deploy rewriting files on every run, which now includes agentcore/box-gateway-targets.json.
…n, for the review comment on conditions.ts line 130
leo237
left a comment
There was a problem hiding this comment.
Re-review of the three commits since my approval at c065a0a (2d3ef4a, 40116bd, 0628b15). The new code looks right. I'm leaving a comment rather than approving again only because of the merge state.
Blocking (merge state, not code)
- The branch is one commit behind
box-integration(e2ac9d7, #2870), and that commit conflicts with this PR indocs/box-local-testing.md. While the PR conflicts, no checks run on 0628b15 (0 check runs, status pending), so none ofverify,Analyze, or CodeQL has run on the new head. Please rebase or mergebox-integration, fix the conflict in the doc, and merge once CI is green.
Addressed
- pathSolver tests (2d3ef4a).
pathTesthas a table forlike,!(like),==,!(==),!=,!(!=),has, and!(has).findPathhas tests for!=and a negatedlikein a permit, a forbid, no path, the 4096-state bound, and the free character. The free-character test is useful:never("/§*")andnever("//*")make the expected result/\uE000, so a solver that fell back to§would fail it. On the non-string!=: your reply (Box rejectspath != 5at load, and the condition reader makes no path test from a number) is enough for me. - Migration warning (40116bd). It fires only when the record does not name the gateway (
recorded === undefined), the target is namedegress-*, andunmanagedShapereturns a reason. That is exactly the set thatisManagedTargetleaves to the user. A target whose shape matches gets no warning and build adopts it. The writer records every Box gateway, with an empty list if it has no targets, so the next build has a record and the warning does not repeat. The message says what to do, and both the positive and the negative case are tested. - Docs (0628b15). The path matches
BOX_GATEWAY_TARGETS_FILE, and the doc says what a clone without the file does. This text is the hunk that now conflicts with #2870, so please keep it when you resolve the conflict. - The CodeQL bot thread is now resolved.
Still open (non-blocking, from my earlier review)
- Back-merge to
box-integration-development. Dev still has nopathSolver.tsand noBOX_GATEWAY_TARGETS_FILE, and it still takes ownership from theegress-prefix. - The listed follow-ups ("2 items stay") still have no issue. Please file one or link it.
- Nit:
w.split(":", 1)[0]vsw.startsWith("api.openai.com:")inmanager.boxNetwork.test.ts.
Other
- tejaskash's 7 review threads are still unresolved. The ruleset requires every thread to be resolved, and the
conditions.ts:130thread (a temporal or guardrailswhenbefore a hostwhen) is a correctness claim, so it should be answered before merge.
…ate and add runtime, for the review comment on network.ts line 304
…times read, for the review comment on boxNetworkSource.ts line 168
…is build adds, for the review comment on boxNetworkWriters.ts line 341
…nd the warnings from the written spec, for the review comment on boxNetworkWriters.ts line 214
…for the review comment on conditions.ts line 307
…he review comment on network.ts line 377
…he review comment on hostMap.test.ts
…view comment on boxNetworkWriters.test.ts
…review nit on split in manager.boxNetwork.test.ts
|
The nit on |
leo237
left a comment
There was a problem hiding this comment.
Re-review of 8550a46..25a3faa. These three commits change only tests (hostMap.test.ts, boxNetworkWriters.test.ts, manager.boxNetwork.test.ts), and each one answers one of my nits:
hostMap.test.ts: thetest.eachnow covers aguardrailsbody as well astemporal. That is the other branch ofdogwood.ts/conditions.ts, so a regression in either one now fails the test.boxNetworkWriters.test.ts: the unused"first"column is gone. The title now reads "... with %s first", and the assertions are the same.manager.boxNetwork.test.ts:authorityOfcompares the wholehost/host:portbefore the first": ", so it no longer cuts off at a port. The new first-build check (exactly oneapi.openai.comwarning) means the second-buildtoEqual([])cannot pass trivially.
The tests are CI-safe: no host paths, no splitting on :, no file modes, no spawned processes, no network. There are no unresolved threads.
Still open (non-blocking): the back-merge to box-integration-development, issues for the follow-ups, and the CHANGES_REQUESTED review from @tejaskash at c065a0a, which needs a re-review or dismissal. The branch is 2 commits behind box-integration with no conflict. FYI, open #2886 touches some of the same files.
CI at posting: CodeQL, Analyze, macOS and CodeBuild e2e pass; verify / Linux and verify / Windows are still pending. Please merge only after they pass.
…w-fixes-host-map # Conflicts: # src/core/project/boxNetwork/network.ts # src/handlers/project/shortcuts.ts
|
I merged box-integration into this branch, as merge commit 33ca2035, after aws/agentcore-cli#2883 merged. Two files had different text: |
leo237
left a comment
There was a problem hiding this comment.
Re-review of the merge commit 33ca203, which brings in box-integration with #2883 and #2884. I looked only at how the merge was resolved.
- The net diff matches the one I approved at 25a3faa. Nothing the PR added is gone: the
box-gateway-targets.jsonrecord ownership, the migration warning, pathSolver, the review fixes, and the test nits are all still there. - Nothing from #2883 was reverted.
boxGatewayBedrockHostnow lives inboxNetwork/egress.tsnext toboxGatewayAgentCoreHost. Both usepartition(region).dnsSuffix.shortcuts.tsstill exports both through egress, and thenetwork.tsIAM-warning host checks call them. The partition ARNs inboxMemory.tsand the amazonaws.com.cn China tests are intact. - No conflict markers. The branch contains the current base tip 57c7c52.
CI: Windows, macOS, CodeBuild e2e and CodeQL pass. verify / Linux is still pending, so please merge only after it passes. Back-merging to box-integration-development is still open.
…horus note on PR 2887
…me or remove all deletes, for the Chorus note on manager.tsx line 1270
…ell, for the Chorus note on item 10
|
This comment answers the four items in the Chorus document.
|
leo237
left a comment
There was a problem hiding this comment.
Re-review of 33ca203..006f4ba. The four new commits look right to me. The one blocker is that the branch now conflicts with box-integration, so no CI can run. Please merge or rebase onto box-integration (3df8eab). After that, and once CI is green, I expect to approve again.
Conflict (found with a trial git merge-tree): one file, src/core/project/backends/cdk.test.ts, at the Box network build test near L475. Base now builds warned/quiet with boxNetwork(plain)/boxNetwork(started). This branch adds an inline boxNetworks literal that has managedTargets. The resolution probably keeps base's version and passes managedTargets through the boxNetwork(...) helper if it needs it. Every other file auto-merges, including manager.tsx, network.ts, boxNetworkWriters.ts and the docs.
New commits
- 854efbd refactor:
managedTargetsOfandrecordOfare verbatim extractions. The set of owned targets is the same and no test changed. Behavior is the same. - adad22d record cleanup:
remove runtimedrops only the gateways bound to that runtime (removedGateways), andremove alldrops every gateway. That is correct becauseremove gatewayalready refuses a bound gateway. A missing file is a no-op, and a malformed file is left alone for build'sProjectStateErrorto report, which matchesaddBoxGatewaysToRecord. The format matchesboxGatewayTargetsText. The tests cover remove followed by add for both paths. One non-blocking nit is inline. - 298dac8 docs: these match
planBoxProfileCredentials. The key comes from the shell first, then.env.local, the credential is named after the route (openai), and deploy provisions it. - 006f4ba pathSolver:
patternKeyis injective over the machine's item sequence (literal char vs wildcard, with*and\escaped), so only patterns that give identical machines share one.machineOfcompares characters exactly, so/Aand/astay apart, which is correct. The test covers a literal*against a wildcard.**and*would get separate machines, which costs a little speed but stays correct.
Still open (FYI)
- tejaskash's CHANGES_REQUESTED review (at c065a0a) still sets
reviewDecision. It needs a re-review or dismissal before merge. - #2864 refuses user targets named
bedrock/agentcore/egress-*on any Box gateway throughisManagedTarget. With this PR's record, build owns only the recorded targets, and theegress-rule applies only to a gateway with no record entry. So the two PRs disagree about whether a user may ownegress-*on a new gateway. Whichever merges second should line up with the record: refuse only the names build actually owns, or keep the stricter rule on purpose and say so. - After merge,
box-integration-developmentstill needs a back-merge (it is 163 commits behindbox-integration). The follow-ups named in the commit messages have no issues filed yet.
…w-fixes-host-map # Conflicts: # src/core/project/backends/cdk.test.ts
|
I merged box-integration into this branch again, as merge commit e6b17cb0, after aws/agentcore-cli#2885 merged. One test file had different text: |
leo237
left a comment
There was a problem hiding this comment.
Re-reviewed the merge of box-integration (e6b17cb). The merge is clean and CI is green, so I approve.
cdk.test.ts: you kept the base'sboxNetwork(plain)/boxNetwork(started)test, andmanagedTargets: new Set<string>()is now in the sharedboxNetworkhelper. That was the only change this PR made in that file, so no assertion is lost.git show --remerge-diffshows only that conflict. Every other file merged automatically. There are no conflict markers.- The net diff against the base is the same as before the merge (45 files, +1990/-323). Comparing the diff before and after the merge, only unchanged context lines from #2885 differ, so no base change is reverted. The #2885 OTEL code is intact.
- CI: Linux, macOS, Windows, CodeQL and CodeBuild e2e all pass.
Still open, none blocking:
- The
manager.tsxnit is not addressed yet. The record is still written aftercommitSpec, so a failed write leaves a stale entry. A follow-up is fine. - @tejaskash still has CHANGES_REQUESTED on c065a0a. Please re-review or dismiss that before merge.
- #2864 is still open. Its ownership rules and this PR's need aligning, and whichever lands second should do it.
- After this lands, it needs a back-merge to
box-integration-development. The deferred follow-ups also need issues.
…te fails, for the review nit on manager.tsx
|
This comment answers the
New tests in |
leo237
left a comment
There was a problem hiding this comment.
Re-review of f43a55a (the record and agentcore.json staying in sync).
The approach works. The record is written first and then agentcore.json, and changeRecord returns a function that restores the record if the spec write fails. create now writes the record before agentcore.json. Add runtime, remove runtime and remove all are covered. A failed rollback is logged at warn level, and the original error is still thrown, the same way discardStaged and the env rollback work. The tests on the spec-write side use the injected refusingSpecWrites, which is good.
Why this is COMMENT and not APPROVE: verify / macOS failed in bun test at this head. Linux was still pending when I posted. The logs are not available until the run finishes, so I could not see which test failed. macOS is the only CI platform where the new chmod tests run (Linux CI runs as root and Windows is skipped), so please check whether they caused it. If it is the known screen-test timeout flake, a re-run is enough and I'm fine to approve.
Nits (non-blocking):
removeAllResources: the record is now changed beforeenvFile.removeKeys, which is outside the try. If that call throws, the record has lost its entries but agentcore.json still has the gateways.removeResourcedoes the env step first, so move this to match it (inline comment).- The record-write-failure tests force the failure with
chmod 0o444, so they are skipped on root and Windows. Linux CI therefore never runs them. An injected writer for the record (the same idea asrefusingSpecWrites) would make them run on every platform.
leo237
left a comment
There was a problem hiding this comment.
Follow-up to my earlier review: I've now checked the verify / macOS job log. The only failure is project add runtime-endpoint wizard > the version must be a whole number of at least 1 ("this test timed out after 5000ms"). That's the known macOS screen-test timeout flake. It isn't related to this change and it isn't one of the new chmod-based record-write tests. verify / Linux and verify / Windows both pass at this head, so I'm approving.
The two non-blocking inline items from my previous review still stand:
- remove-all
.env.localordering inmanager.tsx(around L1360) - the chmod-based record-write tests don't exercise anything on Linux CI (root bypasses the permission bits), so they only give coverage on macOS
Note: tejaskash's CHANGES_REQUESTED review still needs a re-review or dismissal before this can merge.
…ts keys, for the review nit on manager.tsx line 1360
…very OS, for the review nit on manager.box.test.ts line 1015
leo237
left a comment
There was a problem hiding this comment.
Re-reviewed f43a55a..eb8673a. Both nits are fixed.
- 6596b31:
remove allandremove runtimenow change the record insidecommitSpec. This happens after the.env.localkey removal and after the schema parse, right before the spec write. If the spec write fails, the record and.env.localare both rolled back. If the key removal fails, nothing has changed yet. The new test (a folder in place of.env.local) covers that case. Add runtime keeps the same order inside its own try. Create still writes the record with write-new through the network writers, so it is unaffected. - eb8673a: the
RecordFileswriter is injected throughFsProjectManagerconfig and passed to both add and remove. The record-write-failure tests now use a writer that refuses writes, with nochmodand noskipIf, so they run on Linux, root, and Windows CI.
Optional nit: the old // Validates and writes an updated spec... line comment is still there above the new JSDoc on commitSpec. It can go.
CI: macOS, CodeQL, Analyze, and CodeBuild e2e pass. verify / Linux and verify / Windows were still pending when I posted, so please merge only after they pass.
Description
The report "Box integration: review of merged PRs" (2026-11-19) found defects in
aws/agentcore-cli#2847, which reads a box profile
and finds its hosts, and in aws/agentcore-cli#2849,
which writes the Box gateway targets from those hosts. The reviewer examined
box-integrationat1f3ae974. This PR examines each item again at f98cfd68, after
aws/agentcore-cli#2866 and the PRs that came
after it.
The defects have three effects on the user:
build: a rule that Box accepts, two names of one key, and a user rulewhose
@idBox also writes.buildremoves a user target whose name starts withegress-.Each correction is in a different commit, with a test that gives an error before the correction, and a
mutation proof. The table gives each item.
hostMap.test.ts"finds a host reachable when two path patterns of one permit hold on one path" (and 3 more)hostMap.test.ts"an attribute that an action test keeps from the action, as Box reads it" (6 tests)enforcedByBoxhostMap.test.ts"names a connection permit that limits the address, and not one that allows any"buildaccepts port 65536network.test.ts"fails each rule that names port %d, which is not a port" (65536, 0, -1)mquang-amazon/box-releasesBOX_RELEASE.repofromboxRelease.jsonisTable, theuv synchint, and bannersboxProfileResolver.test.ts"the uv sync hint, when Box refuses a missing .venv under a write grant" (5 tests)@idof a user rulegateway.test.ts"names no route so that box adds a rule with the @id of a rule of the policy" (2 tests), and one test throughbuildBoxNetworknetwork.test.ts"takes one credential for its own variable and for one other variable, which build copies to it";boxNetworkSource.test.ts"takes the credential of another runtime for the credential's own variable"buildremoves a useregress-*targetmanager.boxNetwork.test.ts"owns only the targets it records, after it takes its old egress- targets once" (and 9 more)box-integration-development)manager.boxNetwork.test.ts"writes the target of a model-provider route once its key is set, as the warning says" (and 6 more)project.test.ts"Box runtimes and the folder build stages box in" (3 tests)Decisions that the diff does not show
through, the host map finds a path that the path tests of a permit let through together, and
that no forbid denies when
buildcan read all of its conditions. The result is accurate forlike,==, and!=. After 4096 searchsteps, the search stops, and the host stays reachable. Then
buildgives a warning that namesthe rule.
causes. Box rejects a rule that reads
context.inputin two action families, andip()acceptsonly a literal. The tests use the shapes that Box accepts: an action test in one family, and
context.input.ip4 like "10.*".[egress.egress-api-b-example-com]adjacent to theuser rule
route_egress-api-b-example-com_request, with exit 1. Box accepts the new nameegress-api-b-example-com-2adjacent to that rule, with exit 0.buildrecords its targets inagentcore/box-gateway-targets.json, and not in afield of
agentcore.json. The L3 schema ofagentcore.jsonis strict. Thus a new field stopssynth until the L3 accepts the field.
buildchanges and removes only the targets in the record.buildrecords eachegress-target with the same shape thatbuildwrites. It does thisone time.
buildkeeps anegress-target of a different shape as a target of the user. Thus a targetthat
buildwrote and the user then changed is a target of the user.aws/agentcore-cli#2845 did not add a
credential for a model-provider route that
agentcore createwrites with no key, such as[egress.openai]withenv://OPENAI_API_KEY. On AgentCore Runtime, the gateway target of thatroute sends the key of its credential. Thus the OpenAI, Anthropic, and Gemini routes did not
get a target. Now the planner adds the credential
openaiwhenOPENAI_API_KEYhas a value.This is the rule of
box-integration-development. This change replaces two tests of aws/agentcore-cli#2845. Varun, examine this item, because it changes your planner.Checks that continuous integration cannot do
SHA256SUMS.txt) accepted or rejectedeach policy shape that the tests of items 2, 3, 4, and 7 use.
uv synchint gave the correct folder for two errors from Box: a project path with spaces,and a long path that Box breaks in a word.
Follow-ups that this PR does not do
build, an entry that readsAGENTCORE_CREDENTIAL_GITHUBcan get a differentcredential name, before the credential
githubis inagentcore.json. The nextbuildwritesits target. For this correction, the model must use the planner. Thus it is a different change.
ProjectBackendinput of all backends, andboxNetworkSource.tsimportsDEFAULT_EGRESS_BEDROCK_REGIONfromsrc/handlers/. For the two changes, the Box gateway namesmust move out of
shortcuts.ts, which is an item ofaws/agentcore-cli#2789.
README.mdanddocs/box-local-testing.mdgive the release repository as text. The move of thereleases changes them.
Related Issue
The report on the merged Box PRs. There is no issue for it.
None.
Documentation PR
This PR changes one paragraph of
docs/box-local-testing.md: which gateway targetsbuildchanges.Type of Change
Testing
How have you tested the change?
bun test: 5869 pass, 7 skip, 0 fail, in 5876 tests. Before this change: 5829 pass, 7 skip, 0 fail, in 5836 tests.bun run test:e2e, or explained why they are not applicable(CI does not run them for you). I did not do the end-to-end tests. No change is in deploy,
and each changed path has unit tests and command-flow tests.
bun run typecheckbun run lint:checkbun run format:checkbun run auditbun run secrets:checkbun run build, andbun run test:packagesrc/assets/, I updated affected snapshots withbun test <test-file> --update-snapshotsand committed themby this PR
command.md(the release workflow regenerates 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.