fix(kilnd,component): reject arg-arity mismatch instead of zero-filling + reporting wrong result as success (SR-53, closes #443) - #460
Merged
Conversation
avrabe
force-pushed
the
fix/sr-53-arg-arity-fabricated-success-443
branch
from
July 21, 2026 21:09
e18dcc5 to
8c8e7b5
Compare
🔍 Build Diagnostics ReportSummary
🎯 Impact AnalysisIssues in Files You Modified
Cascading Issues (Your Changes Breaking Other Files)
✅ No Issues DetectedPerfect! Your changes don't introduce any new errors or warnings, and don't break any existing code. 📊 Full diagnostic data available in workflow artifacts 🔧 To reproduce locally: # Install cargo-kiln
cargo install --path cargo-kiln
# Analyze your changes
cargo-kiln build --output json --filter-severity error
cargo-kiln check --output json --filter-severity warning |
…ng params (SR-53, #443) kilnd invoked a param-taking export with ZERO-FILLED arguments whenever params could not be supplied and reported the resulting wrong value as SUCCESS (exit 0) — `kilnd mod.wasm --function addone` printed `✓ returned I32(1)` (= addone(0)) where wasmtime computes addone(5)=6. The #412 fabricated-reporting family on the function-invocation surface. Fail-loud fixes, per CLAUDE.md (zero-filling missing params is exactly a banned masking fallback): - kiln-runtime stackless engine (execute_function_body locals init): remove the "pad with default values" zero-fill and the silent truncation of extra args; an argument count that does not match the function's declared parameter count is now an Err. - kilnd execute_traditional_module: check the target export's declared param count BEFORE engine.execute and error with an actionable message ("function 'X' expects N argument(s) but none were supplied; kilnd cannot yet pass wasm function parameters"). No CLI arg-passing flag added — the primary fix is the fail-loud rejection. Zero-param entry points still run. - kiln-component direct hosting: resolve the canon lift's REAL param types into DirectExportTarget.params and the export's registered FunctionSignature.params (previously always empty), so the existing validate_function_args arity check actually fires; call_direct_export additionally checks param arity alongside its existing result-arity check. - Load-time validation: a spec-invalid component whose canon lift declares a different param arity than the backing core function is now REJECTED at instantiation (validated against the live instantiated core module's signature), matching wasm-tools validate and wasmtime, instead of accepted and run. New RED->GREEN tests: kilnd/tests/arg_arity_tests.rs (4) and kiln-component/tests/direct_export_arity_tests.rs (3), including correct-answer assertions (dbl(5)=10, add(5,3)=8) and zero-param still-runs coverage. Closes #443 Implements: SR-53 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FcTUZgts331Z1TK3q8YBQj
avrabe
force-pushed
the
fix/sr-53-arg-arity-fabricated-success-443
branch
from
July 21, 2026 21:41
8c8e7b5 to
d7f537e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
The bug (#443, #412 fabricated-reporting family)
kilnd invoked a param-taking export with zero-filled arguments when params couldn't be supplied and reported the wrong value as SUCCESS:
Second manifestation: a spec-invalid component whose
canon liftdeclares a different param arity than its backing core function was ACCEPTED and run, thoughwasm-tools validateand wasmtime reject it. Only result arity was ever checked.The fix (fail-loud on every surface)
execute_function_bodylocals init): removed the "pad with default values" zero-fill and silent truncation of extra args — arg count ≠ declared param count is now anErr(runtime_type_mismatch).execute_traditional_module: checks the export's declared param count beforeengine.executeand errors withfunction 'X' expects N argument(s) but none were supplied; kilnd cannot yet pass wasm function parameters. No CLI arg-passing flag added (kept minimal per the issue); zero-param entry points (_start, result-only exports) still run.DirectExportTarget.paramsand the export's registeredFunctionSignature.params(previously always empty), so the existingvalidate_function_argsarity check fires;call_direct_exportalso checks param arity alongside its existing result-arity check.from_parsed_internal— the mismatched component is rejected at load (exit 1), matching wasm-tools/wasmtime.Tests (TDD, RED confirmed first)
kilnd/tests/arg_arity_tests.rs: no-args on 1-param export → Err;_start/zero-param exports still run; engine-level — missing arg Err, extra arg Err,dbl(5) = 10correct.kiln-component/tests/direct_export_arity_tests.rs:addwith 0 args → Err;add(5,3) = 8(this direction was ALSO broken before — correct args were rejected against the empty registered params); mismatched lift rejected at load.Real-binary repro re-run:
--function addoneexits 1 with the actionable message;--invoke add pc.wasm(invalid lift) rejected at load, exit 1; valid component + correct args works.rivet: SR-53 created (status: implemented, release v0.4.3).
rivet validate: 0 errors (afterrivet sync --localfor the known stale gust cache).Note: full
cargo test -p kiln-component/-p kiln-runtimetarget sets have pre-existing bit rot on main (identical error counts on clean main, verified side by side); working invocation used:cargo test -p kiln-component --features std,kiln-execution --test direct_export_arity_testsplus the compilable maintained targets. No new clippy warnings (--no-depscounts identical to main for all three crates).Closes #443
🤖 Generated with Claude Code
https://claude.ai/code/session_01FcTUZgts331Z1TK3q8YBQj