refactor(agent-client): move polymorphic linkage read into the lib [PRD-493]#1654
Merged
Merged
Conversation
…RD-493]
The workflow-executor adapter hand-rolled a fetch (URL building, token, query
params) to read a polymorphic relation's raw JSON:API linkage. That's exactly
what agent-client exists to centralise. Move it into the lib:
- HttpRequester.query gains a `raw` option to return the undeserialized body
(the deserializer drops relationship `type`, the polymorphic discriminator).
- Collection.getRelationLinkage(id, relation) reads the linkage { type, id }
via a `<relation>@@@id` projection, reusing QuerySerializer + auth.
- AgentClientAgentPort.resolvePolymorphicType now just delegates to it — no
more hand-rolled fetch/URL/token.
Tests updated on both sides (agent-client + executor adapter).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ic-linkage-in-agent-client
…ic-linkage-in-agent-client
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (2)
🤖 Increase coverage with AI coding...🚦 See full report on Qlty Cloud » 🛟 Help
|
…method [PRD-493]
Review feedback:
- reuse getOne (add a `raw` option) rather than a dedicated getRelationLinkage;
- keep agent-client generic — return the raw JSON:API body and let the consumer
extract the polymorphic linkage, instead of baking { type, id } parsing into the lib;
- serialization stays in QuerySerializer (getOne -> serialize -> formatFields).
The executor adapter reads the raw body via getOne(..., { raw: true }) and parses
data.relationships.<rel>.data itself. Validated e2e (Image -> User / Product).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Scra3
reviewed
Jun 11, 2026
Scra3
reviewed
Jun 11, 2026
…-493] Review feedback (Scra3): rename the `raw` query/getOne option to the more explicit `skipDeserialization`, and drop the now-redundant comment on getOne. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Scra3
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Follow-up to #1647 (merged). Review feedback: the polymorphic linkage read belongs in agent-client (the lib that centralises agent calls), not hand-rolled in the workflow-executor adapter.
Before
AgentClientAgentPort.resolvePolymorphicTypedid a manualfetch— rebuilding the URL, minting the token, serialising the projection query by hand — bypassing agent-client.After
HttpRequester.querygains arawoption returning the undeserialized JSON:API body (the deserializer drops relationshiptype, the polymorphic discriminator).Collection.getRelationLinkage(id, relation)reads a to-one relation's raw linkage{ type, id }via a<relation>@@@idprojection, reusingQuerySerializer, the by-id route and the client's auth. Returnsnullwhen there is no linked record.AgentClientAgentPort.resolvePolymorphicTypenow delegates to it — no hand-rolled fetch/URL/token.Tests
collection.test.ts: newgetRelationLinkagecases (raw projection, composite ids, null). 70 pass.agent-client-agent-port.test.ts:resolvePolymorphicTypeasserts delegation (no fetch spy). 131 pass.Refs PRD-493
Note
Move polymorphic linkage resolution into agent-client library
rawoption toHttpRequester.queryandCollection.getOnein agent-client that returns the undeserialized JSON:API body, preserving relationshiptypefields.AgentClientAgentPort.resolvePolymorphicTypein agent-client-agent-port.ts to usegetOne({ raw: true })instead of constructing a manualfetchcall to the agent URL.body.data.relationships[relation].dataand returns{ type, id }ornull.Changes since #1654 opened
rawoption toskipDeserializationacrossagent-clientpackage [9bbb98d]AgentClientAgentPort.resolvePolymorphicTypeto use the renamed option [9bbb98d]Macroscope summarized c2a0cdf.