Skip to content

refactor(project): merge DeployedProjectResource into ResolvedDeployedResource - #2160

Merged
jariy17 merged 3 commits into
refactorfrom
chore/merge-resolved-deployed-resource-types
Sep 1, 2026
Merged

refactor(project): merge DeployedProjectResource into ResolvedDeployedResource#2160
jariy17 merged 3 commits into
refactorfrom
chore/merge-resolved-deployed-resource-types

Conversation

@jariy17

@jariy17 jariy17 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

DeployedProjectResource and ResolvedDeployedResource share the same responsibility which is described the state of the deployed resource. Therefore, I have merged them. No behavior change should occur.

Verification

  • tsc --noEmit — 0 errors
  • bun test2598 pass / 0 fail (188 files)
  • oxlint — clean

…dResource

`DeployedProjectResource` ({resourceType, name, id}) and
`ResolvedDeployedResource` ({id, target}) described the same thing at
different levels of completeness: the singular was a projection of a
plural list item plus the shared target, and `resolveDeployedResource`
is literally the plural plus `.find()` plus a throw.

Collapse them into one `ResolvedDeployedResource` carrying all four
fields, so a resolved resource is self-describing: a caller holding one
knows what it is, its physical ID, and which region to address it in.
The singular now returns the found item directly instead of rebuilding
`{id, target}`.

`ResolvedDeployedResources` is retained deliberately. Its target is
resolved independently of resource discovery, so an undeployed target
yields zero resources while callers still need to report which target
and region they read.

Pure refactor: same resolved IDs, same target resolution, same
ProjectStateError text, same throw-vs-omit semantics.
@github-actions github-actions Bot added the size/s PR size: S label Sep 1, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Sep 1, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 1, 2026

@agentcore-devx-automation agentcore-devx-automation Bot 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.

AgentCore Harness Review

Verdict: Looks good

This is a clean, purely refactor-level type change:

  • Merges the old DeployedProjectResource ({ resourceType, name, id }) and the previous ResolvedDeployedResource ({ id, target }) into a single self-describing ResolvedDeployedResource = { resourceType, name, id, target }.
  • Updates the CDK backend to attach target to each resource, the manager to return the resource as-is from resolveDeployedResource, and adjusts tests to match.

I verified that:

  • No references to DeployedProjectResource remain (grep is empty).
  • Both consumers of resolveDeployedResource (runtime.tsx, harness.tsx) still access deployed.id and deployed.target.region, which the new shape supplies.
  • screen.tsx still uses ResolvedDeployedResources (the envelope), which continues to expose deployed.target.region and deployed.resources[].id.
  • The envelope's target and each resource's target are guaranteed to agree because both come from the same target value the manager passes into the backend; the doc comments call out the deliberate duplication.
  • No new I/O, features, or user-visible behavior — no telemetry gap introduced.
  • Tests were adjusted to the new type without additional mocking.

Nothing blocking; safe to merge.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Sep 1, 2026
@codecov-commenter

codecov-commenter commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.25%. Comparing base (27e3250) to head (e1f44c2).
⚠️ Report is 4 commits behind head on refactor.

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #2160   +/-   ##
=========================================
  Coverage     97.25%   97.25%           
=========================================
  Files           508      508           
  Lines         33902    33902           
=========================================
  Hits          32972    32972           
  Misses          930      930           

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

@github-actions github-actions Bot added size/s PR size: S and removed size/s PR size: S labels Sep 1, 2026
…lookup

Merging DeployedProjectResource into ResolvedDeployedResource moved the target
on the singular path from the manager (which resolves it from aws-targets.json)
to whatever the backend stamped on the item. Both invoke handlers pin RegionKey
off that value, so a backend echoing a stale target could redirect an invoke to
the wrong region -- not possible before the merge.

resolveDeployedResource now overrides the item's copy with the resolved target,
and manager.test.ts gains the coverage the two methods never had: a divergence
guard, resourceType/name identity, the empty-stack envelope, the undeployed
throw path, and the item/envelope target invariant.

Also drops three doc comments that misstated ownership: two restated what the
types already show, and the cdk.ts one credited the backend with resolving a
target the manager had passed in.
@github-actions github-actions Bot added size/m PR size: M and removed size/s PR size: S labels Sep 1, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 1, 2026
@jariy17

jariy17 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Bug bash: one real defect found and fixed (2998f2f8)

Two independent planners — a devil's-advocate pass and a Munger-inversion pass — were run over this diff. They converged on the same single defect (filed as INV-1 / B1 respectively). Everything else they raised was either already correct, inert, or a note for later.

The defect: target authority silently moved from the manager to the backend

The merge changed resolveDeployedResource from

return { id: resource.id, target: resolved.target };   // manager-authoritative

to return resource; — which hands back whatever target the backend stamped on the item. That is not a no-op: resolveExistingTarget resolves the target from aws-targets.json, and both invoke handlers pin the AWS region off this value (invoke/runtime.tsx, invoke/harness.tsx: ctx.withValue(RegionKey, deployed.target.region)). A backend echoing a stale or wrong target could therefore redirect a customer's invoke to the wrong region — impossible before this PR, because the manager's own resolved target always won.

Latent rather than live today (CdkBackend stamps the same object it was handed), but the merge created the degree of freedom, and neither the compiler nor the suite checked it.

Fix — the declared target overrides the item's copy:

if (resource) return { ...resource, target: resolved.target };

Doc comments deleted rather than reworded

Three comments misstated ownership and have been removed:

  • the two blocks above ResolvedDeployedResource / ResolvedDeployedResources — one claimed a caller holding a single item needs no envelope, but the envelope still exists and invoke/screen.tsx is what actually reads it; the other restated what the types already show;
  • the cdk.ts comment claiming "The backend already resolved target" — the manager resolved it and passed it in.

New test coverage

manager.test.ts had no describe for either method — the changed line was covered only transitively. Added FsProjectManager.resolveDeployedResource(s) with five cases:

Case Asserts
divergence guard backend claims us-east-1 while aws-targets.json declares eu-west-1 → singular returns eu-west-1
identity a runtime and a harness sharing one name resolve to their own ids; resourceType/name echo the request
empty stack zero resources still yields { resources: [], target }
throw path ProjectStateError matching /is not deployed to target 'default'.*project deploy --target default/
invariant every item's target is the same reference the envelope reports

The divergence guard was verified in both directions: it FAILS on 42138bcb and PASSES with the fix.

Mutation checks (each reverted)

# Mutation Result
M1 manager.tsxreturn resolved.resources[0]! 🔴 RED (2 fail)
M2 cdk.ts → drop target from the item 🔴 RED — tsc TS2322 and tests; proves target is structurally required
M3 cdk.ts → stamp region: "eu-central-1" 🔴 RED (cdk.test.ts)
M4 invoke/index.test.tsx stub → drop target: input.target 🔴 tsc TS2322

M3 is worth a note: my first attempt mutated to us-east-1, which is exactly cdk.test.ts's TARGET.region, so the mutant object was identical to the original and the suite stayed green. That was an invalid mutation, not a coverage gap — re-running with eu-central-1 turns it red. Flagging it because a fixture whose value collides with a mutant is an easy way to fool yourself into trusting a green run.

Gates

tsc --noEmit clean · bun test 2603 pass / 0 fail · oxlint clean · prettier --check clean.

Still outstanding

Live-AWS (agentcore project deploy) and TUI-picker evidence are being produced separately against this commit and will be posted in a follow-up comment. Staying in draft until then.

@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 1, 2026
@jariy17
jariy17 marked this pull request as ready for review September 1, 2026 19:41
The type merge is verified by tsc; these covered pre-existing behavior on
methods the refactor did not change, inflating a 22-line refactor's diff.
@github-actions github-actions Bot added size/s PR size: S and removed size/m PR size: M labels Sep 1, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 1, 2026

@Hweinstock Hweinstock 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 cleaning this up!

@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 1, 2026
@jariy17
jariy17 merged commit 8dc1051 into refactor Sep 1, 2026
21 checks passed
@jariy17
jariy17 deleted the chore/merge-resolved-deployed-resource-types branch September 1, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants