Section 6: Capabilities System
Goal: Effect tracking (moved earlier to unblock Section 8 cache and Section 11 FFI)
SPEC:
spec/20-capabilities.mdDESIGN:design/14-capabilities/index.md
Status: In-progress — Core evaluator working (6.1, 6.4 verified; 6.2, 6.3 WRONG TEST; 6.5 partial; 6.9 partial, was incorrectly marked not-started; 6.10 partial); composition (6.11), resolution (6.12), intrinsics (6.14), stateful handlers (6.16) pending. LLVM tests missing. Zero #compile_fail negative tests. Verified 2026-03-29.
6.1 Capability Declaration
-
Implement:
usesclause [done] (verified 2026-03-29) WEAK TESTS- Rust Tests:
ori_parse/src/tests/parser.rs— uses clause parsing (4 tests: single, multiple, with where, no uses) (verified 2026-03-29) - Ori Tests:
tests/spec/capabilities/declaration.ori(3 tests: pure function, with capability, generic with capability) (verified 2026-03-29) - Negative Tests: No
#compile_failtests for missing capabilities (S06-06) - LLVM Support: ARC lowering treats
WithCapabilityas transparent passthrough; no dedicated LLVM/AOT tests verify this path - LLVM Rust Tests:
ori_llvm/tests/capability_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Multiple capabilities [done] (verified 2026-03-29) WEAK TESTS
- Rust Tests:
ori_parse/src/tests/parser.rs—test_uses_clause_multiple_capabilities(verified 2026-03-29) - Ori Tests:
tests/spec/capabilities/propagation.ori—fetch_and_logwithuses Http, Logger(verified 2026-03-29) - LLVM Support: LLVM codegen for multiple capabilities in function signatures
- LLVM Rust Tests:
ori_llvm/tests/capability_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.1) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.1 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.1: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.2 Capability Traits
-
Implement: Capability traits WRONG TEST — reopened (was [done] 2026-02-10, failed verification 2026-03-29, S06-01)
- Rust Tests: WRONG TEST — roadmap claimed “7 tests for capability trait validation” in
ori_types/src/check/tests.rs; these tests DO NOT EXIST.module_checker_function_scopetestshas_capability()but is not a capability trait validation test. - Ori Tests: WRONG TEST —
tests/spec/capabilities/traits.oriis 126 lines ALL COMMENTED OUT (TODO: “Type checker needs capability support”). Zero active tests. Violates impl-hygiene.md: “No commented-out code ever.” (S06-09) - Fix: Delete or uncomment
traits.ori— commented-out code is a hygiene violation - Fix: Write actual capability trait validation tests (Rust + Ori)
- LLVM Support: LLVM codegen for capability trait dispatch
- LLVM Rust Tests:
ori_llvm/tests/capability_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests: WRONG TEST — roadmap claimed “7 tests for capability trait validation” in
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.2) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.2 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.2: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.3 Suspend Capability
Note: Renamed from
AsynctoSuspendperproposals/approved/rename-async-to-suspend-proposal.md
-
Implement: Explicit suspension declaration STALE TEST — reopened (was [done] 2026-02-10, failed verification 2026-03-29, S06-02)
- Rust Tests: WRONG TEST — roadmap claimed “4 tests (marker trait, signature storage, combined capabilities, sync function)” in
ori_types/src/check/tests.rs; ZERO such tests exist. - Ori Tests: STALE TEST —
tests/spec/capabilities/async.oriis 7 lines with only a comment: “This file is intentionally empty - async is not a language feature.” Zero executable tests. - BUG: Prelude defines
pub trait Async {}(line 250) but spec section 20.3 and approvedrename-async-to-suspend-proposal.mdsay it should beSuspend. Rename not applied. (S06-04) - Fix: Rename
AsynctoSuspendin prelude - Fix: Write actual suspension declaration tests (Rust + Ori)
- LLVM Support: LLVM codegen for explicit suspension declaration
- LLVM Rust Tests:
ori_llvm/tests/capability_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests: WRONG TEST — roadmap claimed “4 tests (marker trait, signature storage, combined capabilities, sync function)” in
-
Implement: Sync vs suspending behavior STALE TEST — reopened (was [done] 2026-02-10, failed verification 2026-03-29)
- Rust Tests: WRONG TEST —
test_sync_function_no_suspend_capabilitydoes not exist inori_types/src/check/tests.rs - Ori Tests: STALE TEST —
tests/spec/capabilities/async.orihas zero executable tests
- Rust Tests: WRONG TEST —
-
Implement: No
asynctype modifier [done] (verified 2026-03-29)- Rust Tests:
ori_parse/src/tests/parser.rs— 3 tests pass:test_no_async_type_modifier,test_async_as_identifier,test_uses_async_capability_parses(verified 2026-03-29) - Ori Tests: Design notes document this (verified 2026-03-29)
- Note: Roadmap previously cited
test_async_keyword_reservedwhich does not exist — actual test istest_async_as_identifier(opposite semantics:asyncis NOT reserved)
- Rust Tests:
-
Implement: No
awaitexpression STALE TEST — reopened (was [done] 2026-02-10, failed verification 2026-03-29)- Rust Tests: WRONG TEST —
test_await_syntax_not_supporteddoes not exist inori_types/src/check/tests.rs. Evaluator does haveCanExpr::Await(_) => await_not_supported()but no test verifies this. - Fix: Write test for await rejection
- Rust Tests: WRONG TEST —
-
Implement: Concurrency with
parallel— spec/20-capabilities.md § Suspend Capability- Deferred to Section 8:
parallelpattern evaluation - Ori Tests:
tests/spec/patterns/parallel.ori(Section 8) - Note: Evaluator has a loud stub for parallel in
can_eval.rs— replace when Suspend capability is implemented
- Deferred to Section 8:
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.3) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.3 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.3: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.4 Providing Capabilities
-
Implement:
with...inexpression [done] (verified 2026-03-29)- Rust Tests:
ori_parse/src/tests/parser.rs— with expression parsing (3 tests: expression, struct provider, nested) (verified 2026-03-29) - Rust Tests:
ori_eval/src/interpreter/mod.rs—CanExpr::WithCapabilityuseswith_binding()atcan_eval/mod.rs:350(verified 2026-03-29) - Ori Tests:
tests/spec/capabilities/providing.ori— 17 tests, all pass (basic provision, struct provider, scoping, nested, shadowing, different types, conditionals, method calls, capability through function) (verified 2026-03-29) - Ori Tests:
tests/spec/expressions/with_expr.ori— 14 tests (11 pass, 3 skipped) (verified 2026-03-29) - Negative Tests: No
#compile_failnegative tests forwith...in(S06-06) - LLVM Support: LLVM codegen for
with...incapability binding - LLVM Rust Tests:
ori_llvm/tests/capability_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Scoping [done] (verified 2026-03-29)
- Ori Tests:
tests/spec/capabilities/providing.ori— scoping, shadowing, three-level nesting, closure interaction (verified 2026-03-29) - LLVM Support: LLVM codegen for capability scoping (push/pop)
- LLVM Rust Tests:
ori_llvm/tests/capability_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Ori Tests:
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.4) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.4 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.4: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.5 Capability Propagation
-
Implement: Runtime capability propagation [partial] (verified 2026-03-29)
- Changes:
prepare_call_env()ininterpreter/function_call.rs:149-156passes capabilities from calling scope to called function (verified 2026-03-29) - Ori Tests:
tests/spec/capabilities/traits.ori— ALL COMMENTED OUT, zero active tests (S06-01, S06-09) - Ori Tests:
tests/spec/capabilities/providing.ori::test_capability_through_function— passes via scope-based name lookup (verified 2026-03-29) - Implement:
with...incapability provision propagates to called functions —with Cap = impl in callee()should makeCapavailable insidecallee() - Ori Tests:
tests/spec/expressions/with_expr.ori— 2 tests skipped:test_basic_withandtest_multiple_capabilities(“capability provision to called functions not implemented”) - Investigate: Skip reason says “not implemented” but
prepare_call_envDOES pass capabilities — skipped tests may pass now (issue may be trait method dispatch vs simple name lookup) - LLVM Support: LLVM codegen for runtime capability propagation through calls
- LLVM Rust Tests:
ori_llvm/tests/capability_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Changes:
-
Implement: Static transitive requirements WEAK TESTS — reopened (was [done] 2026-02-10, failed verification 2026-03-29, S06-03)
- Rust Tests: WRONG TEST — roadmap claimed “7 tests for E2014 propagation errors” in
ori_types/src/check/tests.rs; ZERO such tests exist. E2014 error code IS implemented and registered. - Ori Tests:
tests/spec/capabilities/propagation.ori— 7 tests, all pass (valid propagation patterns) (verified 2026-03-29) - Negative Pin: No
#compile_fail("E2014")test exists anywhere — need negative test verifying E2014 fires on missing capability - Fix: Write Rust tests and
#compile_fail("E2014")negative pins
- Rust Tests: WRONG TEST — roadmap claimed “7 tests for E2014 propagation errors” in
-
Implement: Providing vs requiring [done] (verified 2026-03-29)
- Rust Tests:
ori_types/src/infer/expr/calls/constraints.rs—check_capability_propagationfunction exists (verified 2026-03-29) - Ori Tests:
tests/spec/capabilities/propagation.ori— tests with…in providing capabilities (verified 2026-03-29)
- Rust Tests:
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.5) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.5 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.5: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.6 Standard Capabilities
STATUS: 9 of 13 standard capability traits defined in
library/std/prelude.ori(INCOMPLETE MATRIX, S06-07) Real implementations deferred to Section 7 (Stdlib).
-
Define: Trait interfaces [partial] (verified 2026-03-29) INCOMPLETE MATRIX
- Location:
library/std/prelude.ori— trait definitions (verified 2026-03-29) - Traits defined: Http, FileSystem, Cache, Clock, Random, Logger, Env, Async (should be Suspend), Unsafe — 9 traits in prelude (verified 2026-03-29)
- Missing from prelude (spec section 20.8 lists 13):
Crypto(spec 20.8.3 has full trait),Print(spec lists it),Intrinsics(spec 20.8.4 has detailed trait),FFI(spec lists it) (S06-07) - DRIFT:
Cachesignature uses(key: str) -> Option<str>but spec uses generics<K: Hashable + Eq, V: Clone>(S06-08) - DRIFT:
Clocksignature uses@now () -> int, @today () -> strbut spec uses@now () -> Instant, @local_timezone () -> Timezone(S06-08) - BUG: Prelude has
pub trait Async {}but should bepub trait Suspend {}per approved rename proposal (S06-04)
- Location:
-
Implement (Section 7): Real capability implementations
-
std.net.http— Http capability impl -
std.fs— FileSystem capability impl -
std.time— Clock capability impl -
std.math.rand— Random capability impl -
std.cache— Cache capability impl (new module) -
std.log— Logger capability impl -
std.env— Env capability impl -
std.crypto— Crypto capability impl (missing from prelude) -
std.io— Print capability impl (missing from prelude)
-
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.6) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.6 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.6: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.7 Testing with Capabilities
STATUS: Complete — mocking works via trait implementations, demonstrated in propagation.ori
-
Implement: Mock implementations [done] (verified 2026-03-29) WEAK TESTS
- Ori Tests:
tests/spec/capabilities/propagation.ori— MockHttp and MockLogger demonstratewith...inmocking pattern (verified 2026-03-29) - Note: Uses string mocks, not trait-implementing structs — weak demonstration of real mocking
- LLVM Support: LLVM codegen for mock capability implementations
- LLVM Rust Tests:
ori_llvm/tests/capability_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Ori Tests:
-
Implement: Test example [done] (verified 2026-03-29)
- Ori Tests:
tests/spec/capabilities/propagation.ori— shows test patterns withwith...in(verified 2026-03-29)
- Ori Tests:
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.7) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.7 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.7: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.8 Capability Constraints
STATUS: Partially implemented — E2014 code exists but NEEDS PIN (S06-03, S06-06)
-
Implement: Compile-time enforcement NEEDS PIN — reopened (was [done] 2026-02-10, failed verification 2026-03-29, S06-03)
- Rust Tests: WRONG TEST — roadmap claimed “7 tests for E2014 propagation errors” in
ori_types/src/check/tests.rs; ZERO such tests exist. - Implementation:
check_capability_propagationexists inconstraints.rs, emits E2014 (verified 2026-03-29) - Ori Tests:
tests/spec/capabilities/propagation.ori— positive tests pass (verified 2026-03-29) - Negative Pin: No
#compile_fail("E2014")test exists anywhere — completely untested with negative pins (S06-06) - Fix: Write
#compile_fail("E2014")test verifying error fires when capability is missing - GAP: Error codes E1200-E1207 from spec not implemented (only E2014 exists) (S06-10)
- Rust Tests: WRONG TEST — roadmap claimed “7 tests for E2014 propagation errors” in
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.8) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.8 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.8: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.9 Unsafe Capability (FFI Prep)
Proposal: proposals/approved/unsafe-semantics-proposal.md
PREREQUISITE FOR: Section 11 (FFI) The Unsafe capability is required for FFI. Implement this before starting FFI work. STALE STATUS: Was marked “not-started” but basic
unsafe { }IS implemented and tested (S06-05). Updated to in-progress.
-
Implement:
Unsafemarker capability (compiler intrinsic, likeSuspend)- Add
Unsafeto standard capabilities list in type checker - Prelude:
pub trait Unsafe {}defined (line 254) (verified 2026-03-29) -
Unsafenot treated as marker capability (no E1203 forwith Unsafe = ... in) - No
UnsafeContexttracking in type checker - No E1250 diagnostic
- No enforcement that unsafe operations require
unsafe { } - Generalize E1203 to cover all marker capabilities (not just
Suspend) - Ori Tests:
tests/spec/capabilities/unsafe/— basic tests, E1203 binding error - LLVM Support: LLVM codegen for
unsafe { }blocks (transparent — same as inner expr) - LLVM Rust Tests:
ori_llvm/tests/capability_tests.rs— unsafe block codegen - AOT Tests: No AOT coverage yet
- Add
-
Implement:
unsafe { }block expression (basic parsing + eval) [partial] (verified 2026-03-29)-
ExprKind::Unsafe(ExprId)in IR (ori_ir/src/ast/expr.rs:306) (verified 2026-03-29) - Parser:
parse_unsafe_expr()inori_parse/src/grammar/expr/primary/specials.rs:111(verified 2026-03-29) - Type checker: transparent pass-through (
ori_types/src/infer/expr/mod.rs:216) (verified 2026-03-29) - Evaluator: transparent pass-through (
ori_eval/src/interpreter/can_eval/mod.rs:337) (verified 2026-03-29) - ARC lowering: transparent (
ori_arc/src/lower/expr/mod.rs:298) (verified 2026-03-29) - Visitor: supported in
ori_ir/src/visitor/walk_expr.rs(verified 2026-03-29) - Ori Tests:
tests/spec/capabilities/unsafe_block.ori— 6 passing tests: single expr, multi stmt, nested, in block, type, bool (verified 2026-03-29) - Not implemented:
UnsafeContexttracking in type checker, E1250 diagnostic - Not implemented: Enforcement that unsafe operations require
unsafe { } - LLVM Tests: No LLVM codegen tests
-
-
Implement: Unsafe capability requirements (deferred to Section 11)
- Required for: raw pointer operations (future)
- Required for: C variadic function calls (future)
- Required for: transmute operations (future)
- Tests added when FFI implemented
Note:
Unsafeis a marker capability — it cannot be bound viawith...in. There is noAllowUnsafeprovider type. Unsafe code is tested by testing safe wrappers.
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. - Subsection close-out (6.9) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.9 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.9: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. - Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.10 Default Implementations (def impl)
Proposal: proposals/approved/default-impl-proposal.md
Status: Partially implemented — parser + evaluator registration work, type checking + name resolution + end-to-end NOT working (verified 2026-03-29)
Introduce def impl syntax to declare a default implementation for a trait. Importing a trait with a def impl automatically binds the default.
Implementation
-
Implement: Add
defkeyword to lexer — grammar.ebnf § DECLARATIONS (verified 2026-03-29)- Rust Tests: Lexer has
TokenKind::Def(verified 2026-03-29) - Ori Tests:
tests/spec/capabilities/default-impl.ori— ENTIRELY COMMENTED OUT (S06-09, violates hygiene rules)
- Rust Tests: Lexer has
-
Implement: Parse
def impl Trait { ... }— grammar.ebnf § DECLARATIONS (verified 2026-03-29)- Rust Tests:
ori_parse/src/grammar/item/impl_def/— 5 parser tests (basic, public, multiple methods, empty, multiple def impls) (verified 2026-03-29) - Ori Tests:
tests/spec/capabilities/default-impl.ori— ENTIRELY COMMENTED OUT (S06-09)
- Rust Tests:
-
Implement: IR representation for DefImpl (verified 2026-03-29)
-
DefImplDeftype exists, tracked inModule.def_impls(verified 2026-03-29)
-
-
Implement: Type checking for
def impl- Rust Tests:
ori_types/src/check/registration/— register_def_impls - Verify trait exists
- Method signatures converted to ImplMethodDef
- Methods are associated (no self parameter)
- One
def implper trait per module (coherence check)
- Rust Tests:
-
Implement: Evaluator registration for def impl (verified 2026-03-29)
- Rust Tests:
ori_eval/src/module_registration.rs—collect_def_impl_methods(2 tests) (verified 2026-03-29) - Methods registered under trait name for
TraitName.method()calls — end-to-end dispatch NOT working
- Rust Tests:
-
Implement: Module export with default — 12-modules.md
- Mark exports as “has default” when
def implexists - Bind default when importing trait
- Mark exports as “has default” when
-
Implement: Name resolution — 14-capabilities.md
- Check
with...inbinding first - Check imported default second
- Check module-local
def implthird - Ori Tests:
tests/spec/capabilities/default-impl.ori
- Check
-
Implement: Evaluator dispatch for
def impl— route method calls through default impl resolution inori_eval- Dispatch method calls to bound default
- Override via
with...inworks - Ori Tests:
tests/spec/capabilities/default-impl.ori
-
Fix: Delete or uncomment
tests/spec/capabilities/default-impl.ori— entirely commented out, hygiene violation (S06-09) -
Implement: LLVM backend support
- LLVM Rust Tests:
ori_llvm/tests/default_impl_tests.rs - AOT Tests: No AOT coverage yet
- Codegen for
def implmethods
- LLVM Rust Tests:
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.10) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.10 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.10: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.11 Capability Composition
Proposal: proposals/approved/capability-composition-proposal.md
Specifies how capabilities compose: partial provision, nested binding semantics, capability variance, and resolution priority order.
Implementation
-
Implement: Multi-binding
withsyntax — grammar.ebnf § EXPRESSIONS- Parser: Extend
with_exprto support comma-separated bindings - Rust Tests:
ori_parse/src/lib.rs— multi-binding with expression parsing - Ori Tests:
tests/spec/capabilities/composition.ori
- Parser: Extend
-
Implement: Partial provision — providing some capabilities while others use defaults
- Rust Tests:
ori_types/src/check/tests.rs— partial capability provision - Ori Tests:
tests/spec/capabilities/composition.ori
- Rust Tests:
-
Implement: Nested
with...inshadowing — inner bindings shadow outer- Rust Tests:
ori_types/src/check/tests.rs— capability shadowing - Ori Tests:
tests/spec/capabilities/composition.ori
- Rust Tests:
-
Implement: Capability variance — more caps can call fewer, not reverse
- Rust Tests:
ori_types/src/check/tests.rs— variance checking - Ori Tests:
tests/spec/capabilities/composition.ori
- Rust Tests:
-
Implement: Resolution priority order — inner with → outer with → imported def impl → local def impl → error
- Rust Tests:
ori_types/src/check/tests.rs— resolution priority - Ori Tests:
tests/spec/capabilities/composition.ori
- Rust Tests:
-
Implement: Suspend binding prohibition —
with Suspend = ...is compile error- Rust Tests:
ori_types/src/check/tests.rs— suspend prohibition (E1203) - Ori Tests:
tests/spec/capabilities/composition.ori
- Rust Tests:
-
Implement: Error codes E1200-E1203
- E1200: missing capability
- E1201: unbound capability
- E1202: type doesn’t implement capability trait
- E1203: Suspend cannot be explicitly bound
-
Implement: LLVM backend support
- LLVM Rust Tests:
ori_llvm/tests/capability_composition_tests.rs - AOT Tests: No AOT coverage yet
- LLVM Rust Tests:
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.11) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.11 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.11: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.12 Default Implementation Resolution
Proposal: proposals/approved/default-impl-resolution-proposal.md
Specifies resolution rules for def impl: conflict handling, without def import syntax, re-export behavior, and resolution order.
Implementation
-
Implement:
without defimport syntax — grammar.ebnf § IMPORTS- Parse
use "module" { Trait without def }to import trait without its default - Rust Tests:
ori_parse/src/lib.rs—without defimport modifier parsing - Ori Tests:
tests/spec/capabilities/def-impl-resolution.ori
- Parse
-
Implement: Import conflict detection — one
def implper trait per scope- Error E1000: conflicting default implementations when two imports bring same trait’s
def impl - Rust Tests:
ori_types/src/check/tests.rs— import conflict detection - Ori Tests:
tests/spec/capabilities/def-impl-resolution.ori
- Error E1000: conflicting default implementations when two imports bring same trait’s
-
Implement: Duplicate
def impldetection — one per trait per module- Error E1001: duplicate default implementation in same module
- Rust Tests:
ori_types/src/check/tests.rs— duplicate def impl detection - Ori Tests:
tests/spec/capabilities/def-impl-resolution.ori
-
Implement: Resolution order — with…in > imported def > module-local def
- Innermost
with...inbinding takes precedence - Imported
def imploverrides module-local - Rust Tests:
ori_types/src/check/tests.rs— resolution priority - Ori Tests:
tests/spec/capabilities/def-impl-resolution.ori
- Innermost
-
Implement: Re-export with
without def— permanently strips default from export path-
pub use "module" { Trait without def }re-exports trait without default - Rust Tests:
ori_eval/src/interpreter/module/import.rs— re-export stripping - Ori Tests:
tests/spec/capabilities/def-impl-resolution.ori
-
-
Implement: Error messages with help text
- E1000: “use
Logger without defto import trait without default” - E1001: show location of first definition
- E1002: “
def implmethods cannot haveselfparameter” - Rust Tests:
ori_diagnostic/src/— error formatting tests
- E1000: “use
-
Implement: LLVM backend support
- LLVM Rust Tests:
ori_llvm/tests/def_impl_resolution_tests.rs - AOT Tests: No AOT coverage yet
- LLVM Rust Tests:
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.12) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.12 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.12: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.13 Named Capability Sets (capset)
Proposal: proposals/approved/capset-proposal.md
Transparent aliases for capability sets. Expanded during name resolution before type checking. Reduces signature noise and creates stable dependency surfaces.
Implementation
-
Implement: Add
capsetkeyword to lexer — grammar.ebnf § DECLARATIONS- Rust Tests:
ori_lexer/src/lib.rs—capsettoken recognition - Ori Tests:
tests/spec/capabilities/capset.ori
- Rust Tests:
-
Implement: Parse
capset_decl— grammar.ebnf § DECLARATIONS- Rust Tests:
ori_parse/src/grammar/item/capset.rs— CapsetDecl AST node parsing - Ori Tests:
tests/spec/capabilities/capset.ori
- Rust Tests:
-
Implement: Name resolution expansion
- Expand capset names in
usesclauses to constituent capabilities - Transitive expansion (capsets containing capsets)
- Deduplication (set semantics)
- Rust Tests:
ori_types/src/check/— capset expansion tests
- Expand capset names in
-
Implement: Capset cycle detection — topological sort in
ori_typesduring capset expansion- Topological sort of capset definitions
- Error E1220 for cyclic definitions
- Ori Tests:
tests/spec/capabilities/capset-errors.ori
-
Implement: Capset validation rules — error reporting in
ori_types/src/check/- Error E1221: empty capset
- Error E1222: name collision with trait
- Error E1223: member is not capability or capset
- Warning W1220: redundant capability in
uses - Ori Tests:
tests/spec/capabilities/capset-errors.ori
-
Implement: Capset visibility checking —
pubcapset members must be accessible-
pubcapset must not reference non-accessible capabilities - Ori Tests:
tests/spec/capabilities/capset-visibility.ori
-
-
Implement: Enhanced E1200 error messages
- Show capset expansion context in “missing capability” errors
- Rust Tests:
ori_diagnostic/src/— error formatting tests
-
Implement: LSP support
- Show capset expansion on hover
- Autocomplete capset names in
usesclauses
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.13) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.13 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.13: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.14 Intrinsics Capability
Proposal: proposals/approved/intrinsics-capability-proposal.md (v1)
Proposal: proposals/approved/intrinsics-v2-byte-simd-proposal.md (v2 — generic API, byte SIMD, Mask type)
Generic SIMD API, byte-level SIMD, Mask<$N> type, bit manipulation, and hardware feature detection. Atomics deferred to separate proposal.
Implementation
-
Implement: Generic SIMD type validation — spec/20-capabilities.md
- Validate T x N combinations (byte: 16/32/64, int: 2/4/8, float: 2/4/8)
- Validate operation availability by lane type (div/sqrt/abs float-only, shuffle byte-only)
- Error E1063 for invalid T x N combinations
- Error E1064 for operation not available for lane type
- Rust Tests:
ori_types/src/check/— SIMD type validation tests - Ori Tests:
tests/spec/capabilities/intrinsics-type-validation.ori
-
Implement:
Mask<$N>type — spec/20-capabilities.md- Add
Maskas compiler-known type with const-generic parameter - Methods:
bits,any,all,count,first_set - Implement
BitAnd,BitOr,BitNotforMask<$N> - Valid N values: 2, 4, 8, 16, 32, 64
- Rust Tests:
ori_types/src/check/— Mask type tests - Ori Tests:
tests/spec/capabilities/intrinsics-mask.ori
- Add
-
Implement: Add
Intrinsicstrait to prelude — spec/20-capabilities.md- Generic SIMD operations (
simd_add<T, $N>, etc.) - Comparison operations returning
Mask<N> - Byte-specific:
simd_shuffle<$N> - Aligned loads:
simd_load_aligned<T, $N> - Select:
simd_select<T, $N>(mask-driven) - Ori Tests:
tests/spec/capabilities/intrinsics.ori
- Generic SIMD operations (
-
Implement: Generic SIMD operations — float (128/256/512-bit)
-
simd_add,simd_sub,simd_mul,simd_div,simd_sqrt,simd_abs -
simd_cmpeq,simd_cmplt,simd_cmpgt(returnMask<N>) -
simd_min,simd_max,simd_sum,simd_splat - Ori Tests:
tests/spec/capabilities/intrinsics-simd-float.ori
-
-
Implement: Generic SIMD operations — int (128/256/512-bit)
-
simd_add,simd_sub,simd_mul -
simd_cmpeq,simd_cmplt,simd_cmpgt(returnMask<N>) -
simd_min,simd_max,simd_sum,simd_splat -
simd_and,simd_or,simd_xor,simd_andnot - Ori Tests:
tests/spec/capabilities/intrinsics-simd-int.ori
-
-
Implement: Generic SIMD operations — byte (128/256/512-bit)
-
simd_load,simd_load_aligned,simd_add,simd_sub,simd_mul -
simd_cmpeq,simd_cmplt,simd_cmpgt(returnMask<N>) -
simd_min,simd_max,simd_sum,simd_splat -
simd_and,simd_or,simd_xor,simd_andnot -
simd_shuffle(byte-only),simd_select - Ori Tests:
tests/spec/capabilities/intrinsics-simd-byte.ori
-
-
Implement: V1 deprecated aliases
- Map
simd_add_f32x4→simd_add<float, 2>, etc. - Emit deprecation warning for v1 names
- Ori Tests:
tests/spec/capabilities/intrinsics-v1-compat.ori
- Map
-
Implement: Bit manipulation operations
-
count_leading_zeros,count_trailing_zeros,count_ones -
rotate_left,rotate_right - Ori Tests:
tests/spec/capabilities/intrinsics-bits.ori
-
-
Implement: Hardware feature detection
-
cpu_has_featurewith valid feature strings (addssse3,avx512bw) - Error E1062 for unknown features
- Ori Tests:
tests/spec/capabilities/intrinsics-feature-detect.ori
-
-
Implement:
def impl Intrinsics(NativeWithFallback)- Native SIMD when platform supports
- Scalar emulation fallback
- Ori Tests:
tests/spec/capabilities/intrinsics-fallback.ori
-
Implement:
EmulatedIntrinsicsprovider- Always uses scalar operations
- For testing and portability
- Ori Tests:
tests/spec/capabilities/intrinsics-emulated.ori
-
Implement: Intrinsics error diagnostics
- E1060: requires Intrinsics capability
- E1062: unknown CPU feature
- E1063: invalid SIMD type x width combination
- E1064: operation not available for lane type
- Rust Tests:
ori_diagnostic/src/— error formatting tests
-
Implement: LLVM backend SIMD codegen
- Generic dispatch: monomorphize to platform vector intrinsics
-
Mask<$N>codegen:<N x i1>in LLVM IR - Byte SIMD:
<16 x i8>,<32 x i8>,<64 x i8> - Float SIMD:
<2 x double>,<4 x double>,<8 x double> - Int SIMD:
<2 x i64>,<4 x i64>,<8 x i64> -
count_ones→llvm.ctpop.i64 -
count_leading_zeros→llvm.ctlz.i64 - Runtime CPUID for feature detection
- LLVM Rust Tests:
ori_llvm/tests/intrinsics_tests.rs - AOT Tests: No AOT coverage yet
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.14) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.14 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.14: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.16 Stateful Handlers
Proposal: proposals/approved/stateful-mock-testing-proposal.md
Extend with...in to support stateful effect handlers. The handler(state: expr) { ... } construct threads local mutable state through handler operations, enabling stateful capability mocking while preserving value semantics.
Implementation
-
Implement: Add
handleras context-sensitive keyword — grammar.ebnf § EXPRESSIONS- Rust Tests:
ori_lexer/src/lib.rs—handlertoken recognition (context-sensitive) - Ori Tests:
tests/spec/capabilities/stateful-handlers.ori
- Rust Tests:
-
Implement: Parse
handler(state: expr) { op: expr, ... }— grammar.ebnf § EXPRESSIONS- Rust Tests:
ori_parse/src/grammar/expr/with_expr.rs— handler expression parsing - Ori Tests:
tests/spec/capabilities/stateful-handlers.ori
- Rust Tests:
-
Implement: IR representation for handler expressions
- Add
HandlerExprto expression AST (state initializer, operation map) - Rust Tests:
ori_ir/src/ast/expr/tests.rs— handler AST node
- Add
-
Implement: Type checker — verify handler operations match trait signature
- State replaces
selfin operation signatures - Operations return
(S, R)where S is state type, R is trait return type - State type inferred from initializer, consistent across all operations
- All required trait methods must have handler operations
- Default trait methods used if not overridden
- Rust Tests:
ori_types/src/check/tests.rs— handler type checking - Ori Tests:
tests/spec/capabilities/stateful-handlers.ori
- State replaces
-
Implement: Error codes E1204-E1207
- E1204: handler missing required operation
- E1205: handler operation signature mismatch
- E1206: handler state type inconsistency
- E1207: handler operation for non-existent trait method
- Rust Tests:
ori_diagnostic/src/— handler error formatting - Ori Tests:
tests/spec/capabilities/stateful-handler-errors.ori
-
Implement: Evaluator — handler frame state threading
- Create handler frame with initial state on
with...inentry - Thread state through capability dispatch calls
- Independent state per handler (nested handlers)
-
with...inreturns body result only (state is internal) - Rust Tests:
ori_eval/src/interpreter/with_expr.rs— handler evaluation - Ori Tests:
tests/spec/capabilities/stateful-handlers.ori
- Create handler frame with initial state on
-
Implement: LLVM codegen for stateful handlers
- Handler frame state allocation
- State threading through operation calls
- LLVM Rust Tests:
ori_llvm/tests/stateful_handler_tests.rs - AOT Tests: No AOT coverage yet
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.16) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.16 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.16: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
6.17 Section Completion Checklist
- 6.1 declaration —
usesclause verified WEAK TESTS, needs negative pins and LLVM tests (reopened, verified 2026-03-29) - 6.2 traits — WRONG TEST, zero active tests, traits.ori all commented out (reopened, verified 2026-03-29)
- 6.3 suspend — STALE TEST (explicit suspension, sync vs suspending, await rejection have zero tests),
No async modifierverified (reopened, verified 2026-03-29) - 6.4 providing —
with...inand scoping verified with 31+ passing tests (verified 2026-03-29) - 6.5 propagation — partial: providing vs requiring verified, static transitive WRONG TEST (needs negative pins), runtime partial (reopened, verified 2026-03-29)
- 6.6 trait definitions — 9 of 13 defined, 4 missing (Crypto, Print, Intrinsics, FFI), signature drift vs spec (verified 2026-03-29)
- 6.7 testing/mocking — mock pattern verified WEAK TESTS (verified 2026-03-29)
- 6.8 compile-time enforcement — implementation exists but WRONG TEST (zero Rust tests) and no negative pins (reopened, verified 2026-03-29)
- 6.9 Unsafe — basic
unsafe { }block IS implemented (6 passing tests), but marker capability enforcement NOT implemented (was not-started, now in-progress, verified 2026-03-29) - 6.10 Default implementations (
def impl) — parser + IR + eval registration work, type checking + name resolution + end-to-end NOT working, test files all commented out (verified 2026-03-29) - 6.11 Capability Composition — not started (verified 2026-03-29)
- 6.12 Default Implementation Resolution — not started (verified 2026-03-29)
- 6.13 Named Capability Sets (
capset) — not started (verified 2026-03-29) - 6.14 Intrinsics Capability (Generic SIMD, Byte Ops, Mask Type) — not started (verified 2026-03-29)
- 6.16 Stateful Handlers — not started (verified 2026-03-29)
- LLVM codegen for capabilities — zero LLVM/AOT test files exist
-
#compile_failnegative pins — zero exist for any capability feature (S06-06) - Prelude
Async->Suspendrename (S06-04) - Fix commented-out test files: traits.ori, default-impl.ori (S06-09)
- Implement error codes E1200-E1207 from spec (only E2014 exists) (S06-10)
- Full test suite:
./test-all.sh -
/tpr-reviewpassed — independent Codex review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — implementation hygiene review clean (phase boundaries, SSOT, algorithmic DRY, naming). MUST run AFTER/tpr-reviewis clean. -
/improve-toolingretrospective completed — MANDATORY at section close, after both reviews are clean. Reflect on the section’s debugging journey (whichdiagnostics/scripts you ran, which command sequences you repeated, where you added ad-hocdbg!/tracingcalls, where output was hard to interpret) and identify any tool/log/diagnostic improvement that would have made this section materially easier OR that would help the next section touching this area. Implement every accepted improvement NOW (zero deferral) and commit each via SEPARATE/commit-push. The retrospective is mandatory even when nothing felt painful — that is exactly when blind spots accumulate. See.claude/skills/improve-tooling/SKILL.md“Retrospective Mode” for the full protocol.
Exit Criteria: Effect tracking works per spec (6.1-6.8 evaluator complete, 6.9-6.14, 6.16 pending) Status: Verified 2026-03-29. Significant accuracy problems found: phantom Rust tests cited in 6.2/6.3/6.5/6.8, stale status on 6.9, commented-out test files.
Remaining for Section 7 (Stdlib):
- Real capability implementations (Http, FileSystem, etc.)
- Add missing standard capabilities to prelude (Crypto, Print, Intrinsics, FFI)
- Fix signature drift (Cache generics, Clock types)
- Integration with stdlib modules
Remaining for Section 11 (FFI):
-
Unsafe capability enforcement for extern functions
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (6.17) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-6.17 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 6.17: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.