Skip to content

fix(box): Address the review of the host map and the gateway targets - #2877

Open
SaiAbhishek98 wants to merge 34 commits into
aws:box-integrationfrom
SaiAbhishek98:sa/review-fixes-host-map
Open

SaiAbhishek98 wants to merge 34 commits into
aws:box-integrationfrom
SaiAbhishek98:sa/review-fixes-host-map

Conversation

@SaiAbhishek98

Copy link
Copy Markdown

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-integration at
1f3ae974. 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:

  • Some stop a correct build: a rule that Box accepts, two names of one key, and a user rule
    whose @id Box also writes.
  • One removes a host and gives no failure: two path conditions in one permit.
  • One changes a target of the user: build removes a user target whose name starts with
    egress-.

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.

Review item Status Commit Test
aws/agentcore-cli#2847: two path conditions make a host unreachable Corrected c6bb00b7 Keep a host reachable when two path tests of one permit hold on one path hostMap.test.ts "finds a host reachable when two path patterns of one permit hold on one path" (and 3 more)
aws/agentcore-cli#2847: an action test gives UNKNOWN_ATTRIBUTE Corrected acd14196 Accept a field that an action test keeps from the action hostMap.test.ts "an attribute that an action test keeps from the action, as Box reads it" (6 tests)
aws/agentcore-cli#2847: an IP limit on a connection is not in enforcedByBox Corrected daeec2ad Name a connection permit that limits the address among the rules Box applies hostMap.test.ts "names a connection permit that limits the address, and not one that allows any"
aws/agentcore-cli#2847: build accepts port 65536 Corrected ec299b77 Refuse a rule that names a port out of the range 1 to 65535 network.test.ts "fails each rule that names port %d, which is not a port" (65536, 0, -1)
aws/agentcore-cli#2847: error text gives mquang-amazon/box-releases Corrected before the report, by 26f1a2dc none Each message reads BOX_RELEASE.repo from boxRelease.json
aws/agentcore-cli#2847: casts, a second isTable, the uv sync hint, and banners Corrected f93f4e74 Name the right folder in the uv sync hint, and remove the casts of the profile parser boxProfileResolver.test.ts "the uv sync hint, when Box refuses a missing .venv under a write grant" (5 tests)
aws/agentcore-cli#2849: a Runtime route has the @id of a user rule Corrected ddd14081 Give a Runtime route a free name when a rule of the policy has its route rule's @id gateway.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 through buildBoxNetwork
aws/agentcore-cli#2849: a reserved variable and its alias are two keys Corrected 47acc2f6 Take one API key credential for its own variable and one other variable network.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"
aws/agentcore-cli#2849: build removes a user egress-* target Corrected 8942a802 Own only the gateway targets that build recorded, and keep a user's egress- target manager.boxNetwork.test.ts "owns only the targets it records, after it takes its old egress- targets once" (and 9 more)
aws/agentcore-cli#2849: a host with no credential gets no target, and only a step Corrected (from box-integration-development) d0f95235 Warn for a host that gets no gateway target, and give a model-provider route its credential manager.boxNetwork.test.ts "writes the target of a model-provider route once its key is set, as the warning says" (and 6 more)
aws/agentcore-cli#2849: small items Corrected, but 2 items stay 662b2eaa Refuse two box runtimes in one folder in the schema, and remove casts and copies project.test.ts "Box runtimes and the folder build stages box in" (3 tests)

Decisions that the diff does not show

  • Item 1. The host map keeps its sample requests. When the policy lets no sample request
    through, the host map finds a path that the path tests of a permit let through together, and
    that no forbid denies when build can read all of its conditions. The result is accurate for like, ==, and !=. After 4096 search
    steps, the search stops, and the host stays reachable. Then build gives a warning that names
    the rule.
  • Items 2 and 3. Box 0.1.11-preview.10 rejects the two examples of the report for different
    causes. Box rejects a rule that reads context.input in two action families, and ip() accepts
    only a literal. The tests use the shapes that Box accepts: an action test in one family, and
    context.input.ip4 like "10.*".
  • Item 7. Box 0.1.11-preview.10 rejected [egress.egress-api-b-example-com] adjacent to the
    user rule route_egress-api-b-example-com_request, with exit 1. Box accepts the new name
    egress-api-b-example-com-2 adjacent to that rule, with exit 0.
  • Item 9. build records its targets in agentcore/box-gateway-targets.json, and not in a
    field of agentcore.json. The L3 schema of agentcore.json is strict. Thus a new field stops
    synth until the L3 accepts the field. build changes and removes only the targets in the record.
    • The record has no gateway that a CLI from before this change built. For such a gateway,
      build records each egress- target with the same shape that build writes. It does this
      one time.
    • build keeps an egress- target of a different shape as a target of the user. Thus a target
      that build wrote and the user then changed is a target of the user.
    • This is a design decision. Tell me if it is correct, or which different design to use.
  • Item 10. The credential planner of
    aws/agentcore-cli#2845 did not add a
    credential for a model-provider route that agentcore create writes with no key, such as
    [egress.openai] with env://OPENAI_API_KEY. On AgentCore Runtime, the gateway target of that
    route sends the key of its credential. Thus the OpenAI, Anthropic, and Gemini routes did not
    get a target. Now the planner adds the credential openai when OPENAI_API_KEY has 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

  • Box 0.1.11-preview.10 for macOS (SHA-256 examined against SHA256SUMS.txt) accepted or rejected
    each policy shape that the tests of items 2, 3, 4, and 7 use.
  • The uv sync hint 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

  • On the first build, an entry that reads AGENTCORE_CREDENTIAL_GITHUB can get a different
    credential name, before the credential github is in agentcore.json. The next build writes
    its target. For this correction, the model must use the planner. Thus it is a different change.
  • The box model is on the ProjectBackend input of all backends, and boxNetworkSource.ts imports
    DEFAULT_EGRESS_BEDROCK_REGION from src/handlers/. For the two changes, the Box gateway names
    must move out of shortcuts.ts, which is an item of
    aws/agentcore-cli#2789.
  • README.md and docs/box-local-testing.md give the release repository as text. The move of the
    releases 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 targets build changes.

Type of Change

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

Testing

How have you tested the change?

  • I ran bun test: 5869 pass, 7 skip, 0 fail, in 5876 tests. Before this change: 5829 pass, 7 skip, 0 fail, in 5836 tests.
  • 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). 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.
  • 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, and bun run test:package
  • If I modified src/assets/, I updated affected snapshots with bun test <test-file> --update-snapshots and committed them
  • If I re-recorded fixtures or golden files, every change beyond account identifiers is explained
    by this PR
  • This PR does not change command.md (the release workflow regenerates 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

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

Sai Abhishek added 10 commits November 20, 2026 11:20
…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.
@SaiAbhishek98
SaiAbhishek98 requested review from a team, leo237 and vvargu November 20, 2026 20:37
@codecov-commenter

codecov-commenter commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.42693% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.83%. Comparing base (3df8eab) to head (eb8673a).

Files with missing lines Patch % Lines
src/core/project/boxGatewayTargets.ts 95.45% 3 Missing ⚠️
src/core/project/boxNetwork/pathSolver.ts 99.12% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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.

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 the like automata is correct for Cedar like. * 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. decide then keeps the host reachable, and puts the permit in uncheckedBy and enforcedByBox. buildBoxNetwork warns 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 through consider() again, so the solver cannot add a request that the policy does not allow.
  • conditions.ts: the short-circuit in checkAttributes/actionValue (and || / && / if, and stopping at a later when that an action test makes false) matches Cedar's evaluation order. The tests cover each form, and one negative case.
  • INVALID_PORT, the limitsConnection IP case, the free -2 route names (routeKeys skips both a policy @id and the key of another route), the reserved-variable alias (in the model and in sharedKeyFailures), the warnings for a host with no target, and the move of stagedRuntimeProfiles: each looks correct and has a test. The boxCodeZip/boxContainer steps 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 a ProjectStateError that 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, the 0.1.11-preview.10 pin, --no-same-owner, --containment, enableApplicationLogs/enableTraces). verify passes 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 the egress- 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 a MANAGED_TARGET_CHANGED failure. 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 commit agentcore/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 covers like in a permit and == in a forbid. Small table tests for findPath/pathTest would pin !=, negated like, present, == in a permit, and the freeChar fallback 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, App and app still pass.
  • Follow-ups / "2 items stay". The PR lists the follow-ups (first-build AGENTCORE_CREDENTIAL_* naming; the box model on ProjectBackend plus the DEFAULT_EGRESS_BEDROCK_REGION import, 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) and Analyze were 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 uses w.split(":", 1)[0]. That works for this host, but it would fail for a host:port authority. w.startsWith("api.openai.com:") would hold for both.

Comment thread src/core/project/boxNetwork/network.ts Resolved
Comment thread docs/box-local-testing.md Resolved

@tejaskash tejaskash left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread src/core/project/boxNetwork/network.ts Resolved
Comment thread src/core/project/boxNetworkSource.ts Resolved
Comment thread src/core/project/boxNetworkWriters.ts Resolved
Comment thread src/core/project/boxNetworkWriters.ts Resolved
Comment thread src/core/project/boxNetwork/network.ts Resolved
…n, for the review comment on conditions.ts line 130

@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 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 in docs/box-local-testing.md. While the PR conflicts, no checks run on 0628b15 (0 check runs, status pending), so none of verify, Analyze, or CodeQL has run on the new head. Please rebase or merge box-integration, fix the conflict in the doc, and merge once CI is green.

Addressed

  • pathSolver tests (2d3ef4a). pathTest has a table for like, !(like), ==, !(==), !=, !(!=), has, and !(has). findPath has tests for != and a negated like in a permit, a forbid, no path, the 4096-state bound, and the free character. The free-character test is useful: never("/§*") and never("//*") make the expected result /\uE000, so a solver that fell back to § would fail it. On the non-string !=: your reply (Box rejects path != 5 at 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 named egress-*, and unmanagedShape returns a reason. That is exactly the set that isManagedTarget leaves 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 no pathSolver.ts and no BOX_GATEWAY_TARGETS_FILE, and it still takes ownership from the egress- prefix.
  • The listed follow-ups ("2 items stay") still have no issue. Please file one or link it.
  • Nit: w.split(":", 1)[0] vs w.startsWith("api.openai.com:") in manager.boxNetwork.test.ts.

Other

  • tejaskash's 7 review threads are still unresolved. The ruleset requires every thread to be resolved, and the conditions.ts:130 thread (a temporal or guardrails when before a host when) is a correctness claim, so it should be answered before merge.

Sai Abhishek added 6 commits November 20, 2026 13:49
…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
Sai Abhishek added 3 commits November 20, 2026 16:14
@SaiAbhishek98

Copy link
Copy Markdown
Author

The nit on split(":", 1)[0] in manager.boxNetwork.test.ts: 25a3faaa compares all of the host or host:port text before the first ": " of a warning. Thus it also finds a warning for a host:port. The test also makes sure that the first build gives the OpenAI warning. Thus the check of the second build cannot be correct by accident.

@SaiAbhishek98
SaiAbhishek98 requested a review from leo237 November 21, 2026 00:18

@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 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: the test.each now covers a guardrails body as well as temporal. That is the other branch of dogwood.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: authorityOf compares the whole host/host:port before the first ": ", so it no longer cuts off at a port. The new first-build check (exactly one api.openai.com warning) means the second-build toEqual([]) 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
@SaiAbhishek98

Copy link
Copy Markdown
Author

I merged box-integration into this branch, as merge commit 33ca2035, after aws/agentcore-cli#2883 merged. Two files had different text: shortcuts.ts and network.ts. This PR moves boxGatewayAgentCoreHost to boxNetwork/egress.ts, and PR 2883 gives the hosts the DNS suffix of the partition. Thus egress.ts now has both boxGatewayBedrockHost and boxGatewayAgentCoreHost, each with the DNS suffix of the partition, and shortcuts.ts and network.ts import them from there. bun test: 5901 pass, 0 fail.

@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 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.json record ownership, the migration warning, pathSolver, the review fixes, and the test nits are all still there.
  • Nothing from #2883 was reverted. boxGatewayBedrockHost now lives in boxNetwork/egress.ts next to boxGatewayAgentCoreHost. Both use partition(region).dnsSuffix. shortcuts.ts still exports both through egress, and the network.ts IAM-warning host checks call them. The partition ARNs in boxMemory.ts and 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.

@SaiAbhishek98

Copy link
Copy Markdown
Author

This comment answers the four items in the Chorus document.

  1. The note on aws/agentcore-cli#2887. 854efbd9 puts the targets that build owns in one function, managedTargetsOf in network.ts. The record (recordOf in boxNetworkWriters.ts) shows only the targets in that set. Thus add the egress-gateway-<name> targets to managedTargetsOf. Then the record shows them too. The behavior does not change.
  2. manager.tsx:1270. adad22d4 removes the record entry of each Box gateway that remove runtime deletes. remove all had the same problem, so it also removes the entries of the gateways that it deletes. Two tests do remove and then add runtime, and examine that the record has a new empty entry.
  3. Item 10, docs. 298dac84 adds two sentences to docs/box-local-testing.md and one sentence to README.md. When OPENAI_API_KEY (or the key of a different model provider) is set in the shell or in agentcore/.env.local, build adds a credential such as openai. Then deploy provisions the key in AgentCore Identity.
  4. The nit on pathSolver.ts. 006f4baa gives equal patterns one machine. The key of a pattern is its text, with a \ before each literal * and \. Thus a literal * does not share the machine of a wildcard. Two tests count the machines: equal patterns from different atoms share one, and a literal * and a wildcard do not.

@SaiAbhishek98
SaiAbhishek98 requested a review from leo237 November 21, 2026 01:36

@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 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: managedTargetsOf and recordOf are verbatim extractions. The set of owned targets is the same and no test changed. Behavior is the same.
  • adad22d record cleanup: remove runtime drops only the gateways bound to that runtime (removedGateways), and remove all drops every gateway. That is correct because remove gateway already refuses a bound gateway. A missing file is a no-op, and a malformed file is left alone for build's ProjectStateError to report, which matches addBoxGatewaysToRecord. The format matches boxGatewayTargetsText. 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: patternKey is injective over the machine's item sequence (literal char vs wildcard, with * and \ escaped), so only patterns that give identical machines share one. machineOf compares characters exactly, so /A and /a stay 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 through isManagedTarget. With this PR's record, build owns only the recorded targets, and the egress- rule applies only to a gateway with no record entry. So the two PRs disagree about whether a user may own egress-* 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-development still needs a back-merge (it is 163 commits behind box-integration). The follow-ups named in the commit messages have no issues filed yet.

Comment thread src/core/project/manager.tsx Resolved
…w-fixes-host-map

# Conflicts:
#	src/core/project/backends/cdk.test.ts
@SaiAbhishek98

Copy link
Copy Markdown
Author

I merged box-integration into this branch again, as merge commit e6b17cb0, after aws/agentcore-cli#2885 merged. One test file had different text: backends/cdk.test.ts. It keeps the OTEL warning test of PR 2885, and its boxNetwork test model now has the managedTargets field that this PR adds. bun test: 6084 pass, 0 fail.

@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-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's boxNetwork(plain)/boxNetwork(started) test, and managedTargets: new Set<string>() is now in the shared boxNetwork helper. That was the only change this PR made in that file, so no assertion is lost.
  • git show --remerge-diff shows 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.tsx nit is not addressed yet. The record is still written after commitSpec, 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
@SaiAbhishek98

Copy link
Copy Markdown
Author

This comment answers the manager.tsx nit: "The record is still written after commitSpec, so a failed write leaves a stale entry." f43a55a8 corrects it.

  • add runtime, remove runtime and remove all change the record before they write agentcore.json. When they cannot write agentcore.json, they put the record back as it was.
  • When they cannot write the record, they do not write agentcore.json.
  • create writes the record before agentcore.json. Thus, if the write of one file stops with an error, no project has only one of the two files.

New tests in manager.box.test.ts make each write stop with an error, for each flow, and examine the two files.

@SaiAbhishek98
SaiAbhishek98 requested a review from leo237 November 21, 2026 01:59

@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 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 before envFile.removeKeys, which is outside the try. If that call throws, the record has lost its entries but agentcore.json still has the gateways. removeResource does 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 as refusingSpecWrites) would make them run on every platform.

Comment thread src/core/project/manager.tsx Resolved
Comment thread src/core/project/manager.box.test.ts Resolved

@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.

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.local ordering in manager.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.

Sai Abhishek added 2 commits November 20, 2026 18:11
…ts keys, for the review nit on manager.tsx line 1360
…very OS, for the review nit on manager.box.test.ts line 1015
@SaiAbhishek98
SaiAbhishek98 requested a review from leo237 November 21, 2026 02:17

@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-reviewed f43a55a..eb8673a. Both nits are fixed.

  • 6596b31: remove all and remove runtime now change the record inside commitSpec. This happens after the .env.local key removal and after the schema parse, right before the spec write. If the spec write fails, the record and .env.local are 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 RecordFiles writer is injected through FsProjectManager config and passed to both add and remove. The record-write-failure tests now use a writer that refuses writes, with no chmod and no skipIf, 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.

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.

5 participants