refactor(appkit): add defineManifest to remove manifest casts#485
Draft
MarioCadenas wants to merge 1 commit into
Draft
refactor(appkit): add defineManifest to remove manifest casts#485MarioCadenas wants to merge 1 commit into
MarioCadenas wants to merge 1 commit into
Conversation
Every plugin declared `static manifest = manifest as PluginManifest` (agents needed `as unknown as`). The cast is unavoidable with a raw JSON import: TS widens JSON fields to `string`, but PluginManifest.resources[].type is the nominal ResourceType enum, so the structural shape never assigns — and multi-resource plugins infer a heterogeneous union that a plain `as` also rejects. Add defineManifest() in the registry: it parses the JSON through the canonical pluginManifestSchema (real runtime validation, which the loader did not do before) and returns the strict type via one audited internal assertion. All 9 plugins now use `static manifest = defineManifest<"name">(manifest)` with no local casts. Export pluginManifestSchema from shared for the parse. Adds tests covering valid pass-through and rejection of unknown resource type, invalid permission, and missing required fields. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
Contributor
|
Contributor
📦 Bundle size reportCompared against
|
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 757 KB (+29 KB) | 262 KB (+8.0 KB) |
| Type declarations | 275 KB (+98 B) | 94 KB (+12 B) |
| Source maps | 1.5 MB (+57 KB) | 488 KB (+14 KB) |
| Other | 11 KB | 3.7 KB |
| Total | 2.5 MB (+86 KB) | 848 KB (+22 KB) |
Per-entry composition (own code — deps external (as shipped))
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
. |
83 KB (+4.7 KB) | 2.5 KB | 86 KB (+4.7 KB) | external | 275 KB (+17 KB) |
./beta |
44 KB (+4.9 KB) | 230 B | 44 KB (+4.9 KB) | external | 135 KB (+18 KB) |
./type-generator |
19 KB | 0 B | 19 KB | external | 54 KB |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
. |
index.js |
initial | 79 KB |
. |
utils.js |
initial | 4.0 KB |
. |
remote-tunnel-manager.js |
lazy | 2.5 KB |
./beta |
beta.js |
initial | 35 KB |
./beta |
databricks.js |
initial | 5.7 KB |
./beta |
service-context.js |
initial | 3.2 KB |
./beta |
client-options.js |
initial | 220 B |
./beta |
databricks.js |
lazy | 127 B |
./beta |
index.js |
lazy | 103 B |
./type-generator |
index.js |
initial | 19 KB |
@databricks/appkit-ui
npm tarball (packed): 295 KB (+9 B) — gzipped download (dist + bin; excludes release-only docs/NOTICE).
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 350 KB | 116 KB |
| Type declarations | 201 KB (+32 B) | 72 KB (+9 B) |
| Source maps | 669 KB | 218 KB |
| CSS | 16 KB | 3.3 KB |
| Total | 1.2 MB (+32 B) | 410 KB (+9 B) |
Per-entry composition (consumer bundle — deps bundled, peerDeps external)
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
./js |
4.3 KB | 49 KB | 54 KB | 208 KB | 12 KB |
./js/beta |
20 B | 0 B | 20 B | 0 B | 0 B |
./react |
428 KB | 49 KB | 476 KB | 1.3 MB | 163 KB |
./react/beta |
20 B | 0 B | 20 B | 0 B | 0 B |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
./js |
index.js |
initial | 4.2 KB |
./js |
chunk |
initial | 120 B |
./js |
apache-arrow |
lazy | 49 KB |
./js/beta |
beta.js |
initial | 20 B |
./react |
index.js |
initial | 426 KB |
./react |
tslib |
initial | 2.1 KB |
./react |
apache-arrow |
lazy | 49 KB |
./react/beta |
beta.js |
initial | 20 B |
MarioCadenas
marked this pull request as draft
July 21, 2026 08:17
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
Introduces
defineManifest()in the registry so plugins stop hand-casting their JSON manifests. All 9 plugins now declare:instead of
static manifest = manifest as PluginManifest<...>(agents needed the uglieras unknown as PluginManifest).Why
The cast was unavoidable with a raw
.jsonimport:string, butPluginManifest.resources[].typeis the nominalResourceTypeenum — a structuralstringnever assigns to it.agentstoday) infer a heterogeneous union forresources, which a plainasalso rejects (hence agents'as unknown as).So the escape hatch wasn't a plugin bug — it was the JSON→type boundary being crossed by assertion in 9 places, with no runtime validation.
How
defineManifest()parses the manifest through the canonicalpluginManifestSchema(Zod) and returns the strict type via one audited internal assertion, after parse has confirmed the values are realResourceType/permission strings. This:<TName>(needed —toPluginderives the typed plugin key frommanifest.name; widening tostringwould collapse the typed registry).pluginManifestSchemais now exported fromsharedfor the parse.Verification
pnpm -r typecheck— clean across all projectsmanifest.jsonfiles through the schema — all OKbiome checkcleanSplit out of the MLflow-tracing PR (
pr/agent-evals-1-tracing), which is where this cast friction first surfaced.