feat(ecs): surface base-plugin computeds inside derived computed factories#124
Merged
Conversation
…thout Omit hack bump: 0.9.68 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ories FullDBForPlugin hardcoded the computed-factory db's CV slot to `unknown`, which erased the extends/imports base's already-resolved computeds — not just the current plugin's in-progress ones. A derived plugin's computed factory therefore could not compose on a base plugin's computed. Set CV to FromComputedFactories<XP['computed']>. XP is AmbientPlugin<XP, IP> at the call sites, so this surfaces the base + imports computeds (all fully constructed — no circularity). The current plugin's own CVF is never a parameter to this type, so in-progress siblings stay hidden, matching the rule actions/systems already follow. Adds type-tests for both directions (base composition works; sibling stays hidden) and corrects the ToComputedDb doc now that factories see base computeds rather than `unknown`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
With computed factories now seeing the base plugin's resolved computeds, the computed-erased alias no longer mirrors the factory context — the db a factory receives is no longer `computed: unknown`. Its only residual use (strip computed to break a type cycle) is speculative, has no consumer, and is a near-duplicate of ToDatabase; the rare call site can write `Omit<ToDatabase<P>, 'computed'>` inline. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
`pnpm run lint` / `pnpm run typecheck` now work from the repo root (recursive, matching the existing `build`/`test` pattern) — no need to know which package to cd into. Removed the phantom `lint` scripts from data-sync and data-persistence: they had no eslint config or dependency and always errored, which would otherwise break the recursive root lint. CI already lints only @adobe/data, so nothing relied on them. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…cleanly
Adds a compile-time test for a common app pattern: computed factories
authored as standalone functions (annotated with the exported
`Database.Plugin.ToDatabase<typeof basePlugin>`) aggregated into one
`computed: {}` block in a createPlugin call. Covers a plain resource read, a
factory composing on a base computed, and a parameterized computed; asserts
the aggregated result types exactly, with no `Omit` and no cast.
Verified load-bearing: reverting the FullDBForPlugin CV slot to `unknown`
breaks this exact assignment with TS2322 (`unknown` not assignable to the
factory's `computed`), which is the contravariance failure that forced the
old `Omit<ToDatabase<...>, 'computed'>` workaround.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6d6f466 to
8734bbf
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.
Description
FullDBForPluginhardcoded the computed-factorydb's computed slot (CV) tounknown, which erased theextends/importsbase's already-resolved computeds — not just the current plugin's in-progress ones. As a result, a derived plugin's computed factory could not compose on a base plugin's computed.This PR sets that slot to
FromComputedFactories<XP['computed']>.XPisAmbientPlugin<XP, IP>at the call sites, so it surfaces the base + imports computeds (all fully constructed — no circularity). The current plugin's ownCVFis never a parameter to the type, so in-progress siblings stay hidden — the same rule actions/systems already follow.Also
Database.Plugin.ToComputedDb(introduced earlier in this branch). It was acomputed: unknownmirror of the old factory context; now that factories see the base's resolved computeds it no longer mirrors anything, and its residual "strip computed" use is a near-duplicate ofToDatabase. The rare call site can useOmit<ToDatabase<P>, 'computed'>inline.Verification
tsc -bclean (incl.@ts-expect-errorassertions in the new tests)pnpm lintclean@adobe/datasuite: 2584 passed