Repository navigation
Commit fbb3513
committed
feat(rust): port ownership analysis with exact (line,code) parity (#214 checkpoint 2b)
The ownership half of #214's analysis heart, on top of the generic solver.
Exact port of ownlang/analysis.py, gated by the frozen diagnostics oracle.
own-analysis::ownership:
- {OWNED,MOVED,RELEASED,ESCAPED} u8-bit lattice State (per-RID bitset, loans,
handle->RID aliasing, move/acquire provenance); join with the Python merge
invariants (block-scoped loans equal; 1:1 handle->RID). RID = SymId (u32),
the deterministic replacement for Python id(sym).
- full step() transfer over every Instr; two-phase run (silent fixpoint via
the generic solver, then emitting pass + end-of-function leak checks).
Parity (tests/parity.rs, replaying tests/fixtures/diag_parity.json):
- 66 covered cases asserted, all pass EXACTLY on the full ordered (line,code)
list — no field weakened;
- 3 deferred to checkpoint 3 by name (2x OWN014 escape, 1x OWN019 buffer
policy). The partition is sound: a case is covered iff none of its codes come
from an unported pass (check_lifetimes / validate_policies), so d1+d2 equals
Python's full output for every covered case.
Mandated tests:
- ownership lattice laws EXHAUSTIVE over the finite per-RID state (idempotent/
commutative/associative join, x<=join, bottom identity, the read-OWNED vs
join-empty default split);
- metamorphic: rename-invariance, repeated-analysis determinism, unreachable
code never removes a finding, serde round-trip.
Preserved Python behaviors (matched, not fixed): OWN020-for-parse-errors; the
OWN003 "twice"/"maybe" and OWN002 "consumed"/"released" splits are message-only
(same code+line), merged since only (line,code) is compared at this step.
own-cfg: expose BufferMode/BufferInfo::stack_backed (the ownership analysis
needs it for the OWN015/OWN016 escaping-stack-buffer checks).
Integration gate unchanged: final semantic-port merge stays gated on the
separate post-batch OSS remeasure.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZjB2ggU9qm8vmuTQRtZXR1 parent f0ca1cf commit fbb3513
8 files changed
Lines changed: 1058 additions & 2 deletions
File tree
- docs/notes
- rust
- crates
- own-analysis
- src
- tests
- own-cfg/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
0 commit comments