Skip to content

Commit 892ff56

Browse files
committed
plan(vm): consolidate architecture remediation roadmap
1 parent 4c91eb0 commit 892ff56

12 files changed

Lines changed: 1506 additions & 51 deletions

plans/2026-08-06_review-findings-host-http.md

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# RustScript Architecture Plan Index
2+
3+
**Goal:** Classify the current VM/compiler/runtime findings into independent implementation plans with explicit dependency order.
4+
5+
**Architecture:** Correctness fixes are separated from structural refactors. Each plan owns one architectural surface and defines its own boundary and target criteria. Agent-owned behavior remains in `rustscript-agent` plans.
6+
7+
**Tech Stack:** RustScript compiler, VM, host runtime, interpreter/JIT/AOT/no-std, agent integration contracts.
8+
9+
---
10+
11+
## Classification
12+
13+
| Category | Problem surface | Independent plan | Depends on |
14+
| --- | --- | --- | --- |
15+
| Wire/ABI | Count-derived builtin indices change existing call IDs | `2026-08-09_static-builtin-id.md` | none |
16+
| Compiler correctness | UTF-8 rewrite, parent-path normalization, nested source diagnostics, public entry-point parity | `2026-08-09_nested-module-correctness.md` | none |
17+
| Compiler architecture | Text rewrite, synthetic preludes, flat global symbols, basename identity, source ownership | `2026-08-09_semantic-module-system.md` | nested correctness |
18+
| VM ownership | Monolithic VM mixes engine/program/instance/run/host state | `2026-08-09_vm-runtime-decomposition.md` | static IDs |
19+
| Host lifecycle | Generic resource/operation code unused; IO/HTTP/SQLite duplicate lifecycle/cancellation | `2026-08-09_unified-host-lifecycle.md` | VM decomposition |
20+
| Execution contract | Return/event ambiguity, buffered-only events, string errors, fragmented terminal state | `2026-08-09_run-outcome-event-error-contract.md` | RunContext; host lifecycle for final cancellation integration |
21+
| Authorization | Builtin fast-path bypass, mutable identity/cache complexity, Edge macro leakage | `2026-08-09_capability-profile-host-binding.md` | static IDs |
22+
| Async host transport | Core macro contains Edge scope knowledge; HTTP owns a synchronous scheduler; IO lacks feature-selected blocking/async bindings | `2026-08-09_http-transport-security-executor.md` | capability profile and host lifecycle |
23+
| Structured concurrency | One waiting slot, no generic multi-operation/child-program supervisor | `2026-08-09_structured-task-supervisor.md` | VM decomposition, host lifecycle, capability profile |
24+
| Backend architecture | Repeated semantics across interpreter/JIT/AOT/native/no-std | `2026-08-09_backend-semantic-convergence.md` | static IDs, VM decomposition |
25+
26+
## Agent-owned plans
27+
28+
| Category | Plan |
29+
| --- | --- |
30+
| Canonical product/framework roadmap | `rustscript-agent/plans/2026-07-30_rustscript-agent-gateway-api.md` |
31+
| Run admission, structured input, result/events, timeout/cancellation, live delivery | `rustscript-agent/plans/2026-08-09_agent-run-lifecycle-events.md` |
32+
| Transactional RSS storage, retention, restart, replay, idempotency | `rustscript-agent/plans/2026-08-09_agent-durable-state.md` |
33+
34+
## Implementation route
35+
36+
### Wave 0: Immediate correctness and identity
37+
38+
Can run independently:
39+
40+
1. Static builtin IDs.
41+
2. Nested module correctness.
42+
43+
Exit gate: static IDs no longer depend on catalog length; nested UTF-8/path/diagnostic regressions have executable coverage.
44+
45+
### Wave 1: Foundational ownership and authorization
46+
47+
Can run in parallel after relevant Wave 0 gates:
48+
49+
1. VM runtime decomposition after static IDs.
50+
2. Capability profile/host binding after static IDs.
51+
3. Semantic module system after nested correctness.
52+
53+
Exit gate: module semantics have explicit identities; VM has explicit ownership layers; every privileged call uses one authorization path.
54+
55+
### Wave 2: Unified execution lifecycle
56+
57+
1. Unified host resource/operation/cancellation lifecycle after VM ownership exists.
58+
2. RunOutcome/event/error implementation on RunContext, integrating lifecycle cancellation as it becomes available.
59+
60+
Exit gate: production host subsystems use one lifecycle, and every run has one structured terminal outcome with live bounded events.
61+
62+
### Wave 3: Specialized consumers
63+
64+
Can run in parallel after their dependencies:
65+
66+
1. Generic host-driven async ABI, IO dual implementation, and async-only HTTP transport security.
67+
2. Structured task supervisor.
68+
3. Backend semantic convergence.
69+
4. Agent run lifecycle and durable state integration.
70+
71+
## Scope boundary
72+
73+
- No plan adds compatibility decoding for pre-static-ID VMBC.
74+
- No plan adds agent/provider/platform policy to `rustscript`.
75+
- No agent plan defines VM internal implementation.
76+
- Correctness plans do not wait for structural refactors.
77+
- Structural plans remove superseded transitional paths after migration; they do not retain dual long-term architectures.
78+
- New generic host functions require their own implementation plans; this index covers the architecture findings already identified.
79+
- Async host futures are driven by the embedding host. VM, HTTP, and IO do not own a private executor or synchronous polling scheduler.
80+
- Core host macros contain no pd-edge scopes, context types, registry generation, or downstream module paths.
81+
82+
## Target criteria
83+
84+
- Every finding from the architecture/current-worktree review maps to one owning plan.
85+
- Cross-plan dependencies are explicit and acyclic.
86+
- Each plan has implementation route, scope boundary, and target criteria.
87+
- Core and agent ownership do not overlap.
88+
- Obsolete review-finding and mixed historical plans are removed after their live requirements are represented here.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Backend Semantic Convergence Plan
2+
3+
**Goal:** Reduce semantic duplication across interpreter, Trace JIT, AOT, native bridge, and no-std execution by introducing one canonical instruction/operation contract and differential verification.
4+
5+
**Architecture:** Bytecode semantics, builtin signatures, ownership rules, traps, and deoptimization outcomes are defined once. Each backend lowers or interprets the same contract. Generated coverage tables and differential fixtures detect missing or divergent implementations.
6+
7+
**Tech Stack:** Rust 2024, interpreter, Trace JIT, Cranelift AOT, native bridge, `pd-vm-nostd`, property/differential tests.
8+
9+
---
10+
11+
## Independence and dependency
12+
13+
- Independent of agent framework and module loading.
14+
- Static builtin IDs should land first.
15+
- VM decomposition should define Engine/Program ownership before large backend file moves.
16+
- This plan does not block immediate correctness plans.
17+
18+
## Scope boundary
19+
20+
### In scope
21+
22+
- One canonical semantic description for opcodes and builtins.
23+
- Generated backend coverage checks.
24+
- Shared ownership/trap/helper contracts.
25+
- Differential interpreter/JIT/AOT/no-std tests.
26+
- Incremental removal of duplicated lowering logic.
27+
28+
### Out of scope
29+
30+
- New optimization targets or benchmark promises.
31+
- New bytecode opcodes solely to simplify one backend.
32+
- A complete JIT rewrite in one milestone.
33+
- Agent, HTTP, SQLite, or gateway behavior.
34+
35+
## Implementation route
36+
37+
### Milestone 1: Build a backend coverage inventory
38+
39+
**Files:**
40+
- Create backend coverage tests/tools under `tests/` or `src/backend/`
41+
- Read interpreter, JIT recorder/lowerer, AOT IR/lowerer, no-std dispatch
42+
43+
Generate a matrix for every opcode/builtin:
44+
45+
```text
46+
semantic definition
47+
interpreter
48+
trace recorder
49+
JIT lowering
50+
AOT lowering
51+
no-std
52+
fallback/deopt rule
53+
```
54+
55+
Fail CI when a newly added operation lacks an explicit backend disposition.
56+
57+
### Milestone 2: Define canonical operation semantics
58+
59+
**Files:**
60+
- Create: `src/semantics/` or equivalent
61+
- Modify opcode/builtin metadata generation
62+
63+
Represent:
64+
65+
- operand/result types and stack effect;
66+
- ownership/borrow/clone/drop behavior;
67+
- trap/error conditions;
68+
- side-effect and suspension classification;
69+
- interpreter helper and native helper ABI;
70+
- deopt/fallback permission.
71+
72+
Keep explicit Rust implementation hooks where declarative metadata is insufficient.
73+
74+
### Milestone 3: Generate shared dispatch metadata
75+
76+
1. Generate interpreter validation/stack-effect tables.
77+
2. Generate JIT/AOT eligibility and helper IDs.
78+
3. Generate no-std support/fallback declarations.
79+
4. Key builtins by static ID.
80+
5. Reject mismatched arity/type/ownership metadata at build time.
81+
82+
### Milestone 4: Consolidate native helper contracts
83+
84+
**Files:**
85+
- Modify native bridge/helper modules
86+
- Modify JIT/AOT lowerers
87+
88+
1. Define one helper ABI for tagged/scalar/heap operands.
89+
2. Centralize owned temporary and Arc/raw-pointer rules.
90+
3. Centralize trap/status routing.
91+
4. Remove backend-specific reinterpretation of the same helper payload.
92+
93+
### Milestone 5: Add differential execution harness
94+
95+
For generated and curated programs, compare:
96+
97+
- return value and structured error;
98+
- side-effect/event sequence;
99+
- ownership/drop counters where observable;
100+
- fuel/deadline behavior;
101+
- interpreter, JIT, AOT, and no-std supported subsets.
102+
103+
Include arrays/maps/bytes, calls/closures, branches/loops, host-call boundaries, traps, and deopt cases.
104+
105+
### Milestone 6: Migrate one semantic family at a time
106+
107+
Recommended order:
108+
109+
1. scalar arithmetic/comparison;
110+
2. stack/local/frame operations;
111+
3. collection access/mutation;
112+
4. calls/closures;
113+
5. builtin/native helper calls;
114+
6. suspension/deopt/terminal outcomes.
115+
116+
Each family removes superseded duplicate tables after differential parity passes.
117+
118+
### Milestone 7: Verification
119+
120+
```bash
121+
cargo fmt --all -- --check
122+
cargo test --locked --workspace --all-features
123+
cargo test --locked -p pd-vm-nostd
124+
cargo clippy --locked --workspace --all-targets --all-features -- -D warnings
125+
git diff --check
126+
```
127+
128+
## Target criteria
129+
130+
- Every opcode and builtin has one canonical semantic entry.
131+
- Every backend declares implement/fallback/unsupported explicitly.
132+
- New operations cannot compile without a complete backend disposition.
133+
- Interpreter/JIT/AOT/no-std differential fixtures agree on the supported subset.
134+
- Native ownership and trap ABI is shared by JIT and AOT.
135+
- Backend-specific large files lose duplicated semantic policy over incremental milestones.
136+
- Performance changes are measured separately from semantic convergence.

0 commit comments

Comments
 (0)