Skip to content

Fix combined-facets plugin action inference; add BlobRef namespace - #172

Merged
krisnye merged 2 commits into
mainfrom
krisnye/plugin-type-inference-probe
Aug 15, 2026
Merged

Fix combined-facets plugin action inference; add BlobRef namespace#172
krisnye merged 2 commits into
mainfrom
krisnye/plugin-type-inference-probe

Conversation

@krisnye

@krisnye krisnye commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two plugin type-inference fixes plus a BlobRef ergonomics addition, each backed by compile-time type tests. All additive/non-breaking. Version bumped 0.9.98 → 0.9.99.

1. Fix: combined-facets action inference collapse

Database.Plugin.create({ components, computed, actions }) in a single call collapsed db.actions to ToActionFunctions<{}> (TS2339 on every action), forcing consumers to split every plugin into one-facet-per-create layers.

Root cause: in create-plugin.ts, the computed-factory db built its actions slot from the local AD type param (inferred from the sibling actions property). Referencing AD in the computed contextual type made it un-inferable whenever a computed shared the call, so it fell back to {}. The action-factory db already excluded local AD — that asymmetry was the bug. It's also a forward reference (actions are declared after computed in the enforced order; a computed reading a same-call action never actually worked).

Fix: drop local AD from both computed-db sites (XP['actions'] & IP['actions'] only). No as casts.

Red test: combined-facets-action-inference.type-test.ts — positive Assert<Equal>, @ts-expect-error negatives, a layered-create control, and semantics guards (a computed CAN read a base action; a same-create sibling action is correctly absent). Confirmed genuinely red without the fix, green with it, across TS 5.8.3 / 6.0.2 / tsgo 7.0.2.

2. Regression guard: services thread to the computed-factory boundary

computed-factory-services.type-test.ts pins that db.services.X is correctly typed inside a computed factory (already true via FullDBForPlugin; this locks it against regression, and documents that a consumer manufacturing unknown via a hand-typed param is unnecessary).

3. BlobRef namespace

Merged a namespaced BlobRef (export namespace BlobRef { schema = BlobRefSchema; is = isBlobRef }) mirroring BlobHandle, re-exported from cache/index.ts. Consumers can write BlobRef.schema / BlobRef.is instead of the standalone symbols. Standalone BlobRefSchema/isBlobRef kept. An ECS component storing a BlobRef should use { ...Nullable(BlobRef.schema), default: null } (no cast) — proven in blob-ref-namespace.type-test.ts.

Verification

  • packages/data typecheck (build-assembly + tsc -b): clean. Lint: clean.
  • Node test suite: 1466 pass (pre-existing assembly.test.ts needs the WASM build, unrelated).
  • No public-type weakening: all consumer samples (data-lit, data-lit-todo, data-lit-tictactoe, data-lit-space-rock-game, data-persistence, data-sync) rebuild clean.

🤖 Generated with Claude Code

krisnye and others added 2 commits August 14, 2026 21:58
…type tests

Failure B: a computed factory declared alongside actions in one
Database.Plugin.create collapsed action inference to ToActionFunctions<{}>.
The computed-factory db type referenced this call's own AD (inferred from the
sibling actions property), making AD un-inferable. Drop local AD from the
computed db (base actions only), matching the action factory db and property
order. Zero as casts.

Also: additive namespaced BlobRef (BlobRef.schema / BlobRef.is) mirroring
BlobHandle/BlobMeta, plus red/green type tests for both plugin failures and a
BlobRef namespace proof.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@krisnye
krisnye merged commit 45df69a into main Aug 15, 2026
3 checks passed
@krisnye
krisnye deleted the krisnye/plugin-type-inference-probe branch August 15, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant