Skip to content

refactor: strip no_std from kiln-runtime (phase 1: prelude + lib.rs)#168

Merged
avrabe merged 7 commits intomainfrom
refactor/strip-nostd-interpreter
Mar 18, 2026
Merged

refactor: strip no_std from kiln-runtime (phase 1: prelude + lib.rs)#168
avrabe merged 7 commits intomainfrom
refactor/strip-nostd-interpreter

Conversation

@avrabe
Copy link
Collaborator

@avrabe avrabe commented Mar 18, 2026

Summary

First phase of stripping no_std conditional compilation from the interpreter per RFC #46 architecture decision.

  • Remove 414 lines of cfg-gated no_std code from prelude.rs and lib.rs
  • Eliminate BoundedHashMap/HashSet polyfills, custom vec!/format! macros, Arc/Mutex polyfills
  • Remove all cfg gates on module declarations

This is phase 1 — 369 cfg blocks remain across 15 files (module.rs, memory.rs, module_instance.rs, etc.)

Trace: skip

🤖 Generated with Claude Code

Remove 414 lines of cfg-gated no_std code from prelude.rs and lib.rs.
The interpreter is std-only per RFC #46 architecture. Removed:
- All #[cfg(not(feature = "std"))] blocks and no_std alternatives
- BoundedHashMap/BoundedHashSet/BoundedString type aliases
- Custom vec!/format! macros for no_std
- Arc/Mutex/RwLock polyfills for no_std
- option_value_as_* helper functions
- All cfg gates on module declarations in lib.rs

Trace: skip

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 18, 2026

🔍 Build Diagnostics Report

Summary

Metric Base Branch This PR Change
Errors 0 0 0
Warnings 2 2 0

🎯 Impact Analysis

Issues in Files You Modified

  • 0 new errors introduced by your changes
  • 0 new warnings introduced by your changes
  • 0 total errors in modified files
  • 0 total warnings in modified files
  • 0 files you modified

Cascading Issues (Your Changes Breaking Other Files)

  • 0 new errors in unchanged files
  • 0 new warnings in unchanged files
  • 0 unchanged files now affected

Note: "Cascading issues" are errors in files you didn't modify, caused by your changes (e.g., breaking API changes, dependency issues).

✅ No Issues Detected

Perfect! 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

avrabe and others added 6 commits March 18, 2026 06:47
…rity

STPA hazards (H-13 sub-hazards):
- H-13.1: Thread intrinsic ABI mismatch
- H-13.2: Stream/future buffer overrun
- H-13.3: Resource handle confusion
- H-13.4: Waitable set deadlock on single-threaded runtime
- H-13.5: Task status/event code misinterpretation

UCAs for CTRL-BUILTINS controller:
- UCA-BI-2 through UCA-BI-6 covering invalid indices, buffer overflow,
  double-free, deadlock, and double-completion

STPA-SEC:
- SH-9: Resource handle forgery (high exploitability)
- SH-10: Stream buffer overflow (high exploitability)
- V-9, V-10: Vulnerability mappings with 6 mitigations

Requirements:
- FR-RFC46-THREAD, FR-RFC46-STREAM, FR-RFC46-RESOURCE, FR-RFC46-WAITABLE

Implements: H-13

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…acking

Interface design document for the complete RFC #46 host intrinsic API:
- Thread management → gale RTOS tasks with cooperative scheduling
- Waitable sets → kiln async executor polling gale event groups
- Streams → gale shared-memory ring buffers with backpressure
- Resources → bounded generation-counted handle table
- cabi_realloc → pre-assigned memory pool allocation

STPA hazards:
- H-14: Executor starvation (cooperative monopolization)
- H-15: Gale task slot exhaustion from unbounded thread_new
- H-16: Stream backpressure deadlock on bounded channels
- H-17: Cross-component resource handle aliasing via generation wrap
- H-18: Executor-scheduler priority inversion

STPA-SEC:
- SH-11: Thread sandbox escape via cross-component thread_switch_to
- SH-12: Stream data exfiltration via handle confusion

Control structure: CTRL-EXECUTOR with 5 control actions, 4 feedback loops,
PROC-THREAD and PROC-WAITABLE controlled processes.

Implements: H-14, H-15, H-16, H-17, H-18

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove 1,316 lines of cfg-gated no_std code from module.rs:
- All struct fields simplified to Vec (was dual Vec/BoundedVec)
- Delete from_kiln_module_nostd (~215 lines)
- Delete from_kiln_foundation_module (~270 lines)
- Simplify all GlobalWrapper/MemoryWrapper methods
- Remove cfg gates from all public methods
- Fix Module construction in module_builder.rs, module_instance.rs,
  component_instantiation.rs

Trace: skip

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Complete C function signatures, types, and constants from
bytecodealliance/rfcs#46 (lower-component.md as of 2026-03-18).

Covers: guest→host intrinsics, non-intrinsic imports, host→guest
exports, embedder bindings API, fiber management.

Trace: skip

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fully stripped: memory.rs, bounded_runtime_infra.rs, func.rs,
instruction_parser.rs, bulk_memory.rs, engine_factory.rs,
memory_adapter.rs, memory_helpers.rs, module_builder.rs,
simd_additional_ops.rs, simd_runtime.rs, atomic_runtime.rs,
atomic_memory_model.rs, atomic_execution.rs, component_impl.rs,
wasip2_host.rs, platform_runtime.rs, shared_memory.rs,
engine/capability_engine.rs, multi_memory.rs, module_instance.rs (partial).

153 cfg blocks remain in 7 files: module_instance.rs (38), types.rs (26),
memory_partial.rs (26), stackless/engine.rs (22), table.rs (20),
thread_manager.rs (10), resources/handle_table.rs (10).

Trace: skip

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Stripped: module_instance.rs (38), types.rs (26), memory_partial.rs (26),
stackless/engine.rs (22), table.rs (20), thread_manager.rs (10),
resources/handle_table.rs (10).

kiln-runtime now has ZERO active #[cfg(not(feature = "std"))] blocks.
The interpreter is fully std-only per RFC #46 architecture.

Trace: skip

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@avrabe avrabe merged commit 779d6ff into main Mar 18, 2026
14 checks passed
@avrabe avrabe deleted the refactor/strip-nostd-interpreter branch March 18, 2026 22:02
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