Repository navigation
fix(Group, Assemble, ResourceHandlers): type a flat group's include surface end to end (#595) - #599
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 10bc700 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
#595) `Group.flat` / `flatReadOnly` inferred the documents' `Included` from `options.include?.included` while `Surface` was still generic, which widened it to `Schema.Top`: every endpoint's decoding services became `unknown`, and so did a typed client's. Pass the surface's `included` as an explicit type argument. `test/include-services.types.ts` pins it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y5G6PMempKsgjiV1NDcCJY
…cluded (#595) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y5G6PMempKsgjiV1NDcCJY
…stry (#595) Assemble's documents gain a trailing `I` (the `included` members' type, default `ResourceLike`); `resource` / `collection` / `unpaginatedCollection` set it from `targets` through the new `Assemble.TargetsIncluded` (what the loaders return; `never` with no registry), and `ResourceHandlers` uses it for `list` / `get` (`never` for the writes). A family's handlers then satisfy a flat group whose `included` is its surface's precise union, without a cast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y5G6PMempKsgjiV1NDcCJY
thomasfosterau
force-pushed
the
issue-595-flat-included-services
branch
from
November 12, 2026 03:55
6fc15c6 to
10bc700
Compare
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.
Summary
Closes #595 (from preferenceflow#382 phase 2), including the orchestrator's 03:30Z addendum.
1.
Group.flat/flatReadOnlykeptunknownservicesRoot cause. The documents were built with
Endpoint.ResourceDocument(options.resource, { included }), whereincluded = options.include?.included. InferringIncludedfrom that expression whileSurfacewas still generic widened it toSchema.Top, whoseDecodingServicesareunknown. Every endpoint's success, and every typedClient.makemethod, then requiredunknown.lazyTargetback-references aren't the cause: probed in preferenceflow at 779268c, the resources andInclude.make(...).includedall haveneverservices.Fix.
flatWirepasses the surface'sincludedas an explicit type argument (SurfaceIncluded<Surface>). With no surface that isnever, whichEndpoint.ResourceDocument/FlatCollectionDocumentread asSchema.Top(IncludedOrNone), so a surface-less group's types are unchanged.2. Handlers couldn't satisfy the precise
included(the addendum)With a precise success schema,
ResourceHandlers.readOnly/makeoutput (included?: ReadonlyArray<WireResource<ResourceLike>>) no longer fit: TS2322, as preferenceflow saw in 11 AEC groups.Assemble.ResourceDocument/CollectionDocument/UnpaginatedCollectionDocumentgain a trailingI(theincludedmembers' type, defaultResourceLike).Assemble.resource/collection/unpaginatedCollectionsetIfromtargetsthrough the newAssemble.TargetsIncluded<Targets>: what the registry's loaders return (Handlers.IncludeTargetResource), orneverwith no registry, since nothing can be included then. A registry whose loaders' types aren't visible (annotated, notsatisfies) keepsResourceLike.CollectionOptions/UnpaginatedCollectionOptionsgain a trailingXfor caller-resolved extras.ResourceHandlers'list/getuseTargetsIncluded<Targets>.create/updateusenever, because a write assembles with no walk.Assemblealready asserts its built document asDat one seam, and only the type it names changed.Tests
test/include-services.types.tscovers the following; on trunk, all of these fail.flat,flatReadOnlyandhiddenWritessuccess schemas withneverservices.Client.makeprogram typedEffect<void, unknown, HttpClient>.ResourceHandlers.readOnly(...)over aflatReadOnlywith a surface, andResourceHandlers.make(...)over aflatwith a surface, eachsatisfies Registry.FamilyFor<group>.test/assemble-collection.types.ts's exact-type assertions now nameI = neverfor calls without a registry.Verification
pnpm install --frozen-lockfile: passvp run build: passvp check: pass, 0 errors (4347 warnings, the trunk baseline)vp run check(--concurrency-limit 1): passvp run -r test:unit: passvp run docgen: passvp run test:coverage, thenvp exec fallow audit --base origin/trunk: pass. These ran before the final rebase; gates 1–6 were re-run after it.Changeset
.changeset/flat-included-services.md, minor: narrower, correct published types and a new export (Assemble.TargetsIncluded). It includes a migration note: drop theCodec<…, never, never>/ handler-output casts, and declare registries withsatisfies Handlers.IncludeTargets.Notes
packages/api/src/resource.tsmust stop erasing throughInclude.SurfaceFor<R>. Make it generic over the surface, or move it ontoGroup.flat. The registry must be declared withsatisfies Handlers.IncludeTargetsfor the handlers'includedto be precise.included?: ReadonlyArray<never>, which is still assignable to the oldReadonlyArray<WireResource<ResourceLike>>.🤖 Generated with Claude Code
https://claude.ai/code/session_01Y5G6PMempKsgjiV1NDcCJY