refactor(project): merge DeployedProjectResource into ResolvedDeployedResource - #2160
Conversation
…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.
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
This is a clean, purely refactor-level type change:
- Merges the old
DeployedProjectResource({ resourceType, name, id }) and the previousResolvedDeployedResource({ id, target }) into a single self-describingResolvedDeployedResource = { resourceType, name, id, target }. - Updates the CDK backend to attach
targetto each resource, the manager to return the resource as-is fromresolveDeployedResource, and adjusts tests to match.
I verified that:
- No references to
DeployedProjectResourceremain (grepis empty). - Both consumers of
resolveDeployedResource(runtime.tsx,harness.tsx) still accessdeployed.idanddeployed.target.region, which the new shape supplies. screen.tsxstill usesResolvedDeployedResources(the envelope), which continues to exposedeployed.target.regionanddeployed.resources[].id.- The envelope's
targetand each resource'stargetare guaranteed to agree because both come from the sametargetvalue 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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
…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.
Bug bash: one real defect found and fixed (
|
| 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.tsx → return 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.
|
Claude Security Review: no high-confidence findings. (run) |
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.
Hweinstock
left a comment
There was a problem hiding this comment.
thanks for cleaning this up!
|
Claude Security Review: no high-confidence findings. (run) |
Summary
DeployedProjectResourceandResolvedDeployedResourceshare 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 errorsbun test— 2598 pass / 0 fail (188 files)oxlint— clean