fix(provider-gen): make the shared runtime app-independent#33
Draft
k08200 wants to merge 2 commits into
Draft
Conversation
The spike's shared runtime hardcoded Instagram's key types and stubbed the port check that consumes them, so the declared id types were decorative and a second app could not use the runtime at all. Key tags are app data, so they are generated: the module now publishes the Uhura package identity it was built for and derives `POST_ID_TYPE` and friends from it, leaving `helpers` as exactly the four app-independent functions. The identity is read from the client's own `uhura.toml` through `uhura_check::project_manifest`, never guessed from the app name. `keyText`, `textValue`, `boolValue`, and `requiredField` recover the checking semantics of the hand-written provider, so a key carrying the wrong Uhura type is refused at the port boundary instead of being coerced with `String(v)`. One `id_type_name` definition now feeds both the generated machine types and the provider key tags, so the two cannot drift apart. Verified: fmt, clippy -D warnings, `cargo test --locked --workspace` (405 passed), the node harness (`-- --ignored`, 3 passed), doc snippets (34), both `check` examples, and `spock gen provider --uhura` end to end against the real client manifest, whose output drives the runtime unchanged.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The harness carried `#[ignore = "requires node"]` on the premise that CI does not have node. That premise is false: the test job installs node from `.nvmrc` and runs `pnpm -C uhura/web build:provider` before cargo, and the workspace cannot go green without it — `spock-host` asserts on the Play artifacts that build produces. Node is already mandatory, so the harness was opt-out for no reason, and the two tests proving the runtime is app-independent never ran. Two of these tests also wrote the same `provider-tables.mjs` under one shared temp directory, which becomes a race once they run in the default suite. Each now writes its own file. Verified: `cargo test --locked -p spock-cli --test provider_gen` reports 14 passed, 0 ignored (was 11 passed, 3 ignored); fmt, clippy -D warnings, and `cargo test --locked --workspace` stay green.
4 tasks
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
Stacked on #29 (base
spike/gen-provider), closing the A1 gap found while reviewing that spike.The spike's "one generic hand-written runtime" was not generic.
runtime.mjshardcodedPOST_ID_TYPE: "post",USER_ID_TYPE: "user", andSTORY_ID_TYPE: "story", while the generated module destructured those names out ofhelpers— so a second app had no way to supply its own. The values were also wrong: the hand-written provider tags keys withapp.instagram@1::PostId, notpost. This went unnoticed becausekeyTextwas stubbed to(v) => String(v), which ignores the type argument entirely, and the harness fed plain strings instead of Uhura wire values. The declared id types were decorative.This change:
export const MODULE— the Uhura package identity it was generated for — and derivesconst POST_ID_TYPE = \${MODULE}::PostId`from it.helpers` is now exactly the four app-independent functions.read_module_identityloads the client's ownuhura.tomlthroughuhura_check::project_manifestand usespackage_id(), matching the file's existing rule of refusing unknown types rather than inferring them.spock gen providergains--uhura <project>.keyText,textValue,boolValue, andrequiredFieldrecover the hand-written provider's semantics, so a key carrying another app's type is refused instead of coerced.id_type_namenow feeds both the generated machine types and the provider key tags, so they cannot drift apart.Goldens are unchanged: only the generated module's wrapper moved, so the char-equality proofs against the hand-written provider still hold.
Type
fix
Checklist
Test plan
Run on the pinned toolchain (1.92.0) and node 24.18.0, after the CI prerequisite
pnpm -C uhura/web build:provider:cargo fmt --all --check— exit 0cargo clippy --locked --workspace --all-targets -- -D warnings— exit 0cargo test --locked --workspace— 405 passed, 0 failedcargo test --locked --workspace --all-targets— 0 failedcargo test --locked -p spock-cli --test provider_gen -- --ignored— 3 passed (runtime ok,genericity ok,second app ok)cargo run -p spock-cli -- check examples/instagram/v0.spock— exit 0cargo run -p spock-cli -- check uhura/examples/instagram— exit 0node scripts/check-doc-snippets.mjs— 34 snippets checked, 0 skippedcargo run -p spock-cli -- gen provider uhura/examples/instagram/backend/app.spock --app crates/spock-cli/tests/provider_fixtures/instagram.wire --uhura uhura/examples/instagram/client— emitsexport const MODULE = "app.instagram@1"read from the real client manifestruntime okandgenericity okBefore the fix, the new harness fails as expected: