Lesscode's state-boundary deconvolution engine unifies cross-language whole-responsibility compression and equivalence verification under a high-performance native Rust substrate.
Deconvolution isolates pure computational transformations from stateful, effectful, or I/O-bound outer shells. By isolating mutable state boundaries and generating verified finite-domain proofs alongside adverse mutation sensitivity controls, Lesscode proves that candidate simplifications preserve exact program behavior without manual test authoring.
The native substrate (lesscode-core) provides the central coordination controller, bounded finite-domain verifier, token limit guards, and streaming monitors. Language-specific semantics (AST parsing, dynamic feature detection, adverse mutations, and trace execution) are abstracted through four normative carrier contracts:
flowchart TD
subgraph Core ["Native Rust Substrate (lesscode-core)"]
Supervisor["Execution Supervisor & IPC Monitor"]
Verifier["Bounded Pure-Core Verifier (Cartesian Finite Domain)"]
Guard["Token Limit Guard & Density Scorer"]
Oracle["Golden Trace & Dynamic Replay Oracle"]
end
subgraph Traits ["Carrier Contract Interfaces (adapter_traits.rs)"]
SFA["StateFrameAnalyzer"]
PCV["PureCoreVerifier"]
AMG["AdverseMutantGenerator"]
STR["SpecimenTraceRunner"]
end
subgraph Adapters ["Unified Language Adapters"]
Py["Python Adapter<br/>(pytest-v1)"]
TS["TypeScript Adapter<br/>(ts-node-v1)"]
Java["Java Adapter<br/>(java-junit-v1)"]
Rust["Rust Adapter<br/>(rust-nextest-v1)"]
end
Core --> Traits
Traits --> Py
Traits --> TS
Traits --> Java
Traits --> Rust
All four core languages operate with identical verification rigor, budget governance, and adverse fault injection:
| Dimension | Python | TypeScript / JavaScript | Java | Rust |
|---|---|---|---|---|
| Profile ID | pytest-v1 |
ts-node-v1 |
java-junit-v1 |
rust-nextest-v1 |
| AST Parser | ast-grep / tree-sitter-python |
tree-sitter-typescript / oxc |
syn / tree-sitter-java |
syn (Rust AST) |
| Dynamic Gap Detection | eval, exec, globals(), unmonitored threading |
eval, Function, prototype pollution, require(dyn) |
Class.forName, ClassLoader, native, unmonitored threads |
unsafe, dyn, raw pointers, unmonitored threads, hidden Cell/Mutex |
| Write Site Analysis | Attribute writes (self.x = ...), nonlocal reassignment |
Object property writes (this.x = ...), mutable closure vars |
Field writes (this.x = ...), static reassignments |
Struct field mutations, dereference mutations (*ptr = ...) |
| Adverse Mutation Operators | Missing failure state, inverted branch, dropped flush, truncation | Severity inversion, error order inversion, dropped slug, stream truncation | State mutation omission, inverted flush condition, delimiter inversion, dropped flush | Taskkill omission, inverted verdict refusal, bypassed error check, dropped env |
| Specimen Validated | Facdrone (LifecycleMonitors, ReportEnvelopeStore) |
Markdown Slugify (formatSlug, normalize) |
Apache Commons CSV (CSVPrinter.java) |
Lesscode Native Lifecycle (recording.rs:call/verdict) |
| Compression Ratio (Lines) | −34.2% canonical lines | −36.8% canonical lines | −38.5% canonical lines | −40.3% canonical lines |
| Compression Ratio (Stmts) | −22.1% statements | −18.4% statements | −27.7% statements | −15.7% statements |
| Finite Domain Cases | 100 cases (0 divergences) | 100 cases (0 divergences) | 100 cases (0 divergences) | 100 cases (0 divergences) |
| Adverse Kill Rate | 100% (4/4 killed) | 100% (4/4 killed) | 100% (4/4 killed) | 100% (4/4 killed) |
| Native Status | Production Certified | Production Certified | Production Certified | Production Certified |
Language adapters plug into lesscode-core by implementing four traits:
- Purpose: Statically analyzes candidate source text against a declared
FrameSpec. - Semantics: Emits all observed variable/field write sites. If the candidate attempts write operations outside permitted scopes or uses unanalyzable dynamic features (e.g.
eval,unsafe, dynamic reflection), it returns aCoverageGapwith precise source spans and marks the analysis invalid.
- Purpose: Verifies that a transformed pure core is behaviorally identical to the baseline implementation over a bounded finite domain.
- Semantics: Evaluates Cartesian products of tagged inputs across baseline and candidate functions. Preserves exact IEEE-754 semantics (including
NaN, positive/negative zero,+Infinity,-Infinity) and UTF-8 strings.
- Purpose: Injects synthetic adverse mutations to verify that the verification oracle detects intentional behavioral discrepancies.
-
Semantics: Generates source-anchored mutations (e.g., condition inversion, state omission, dropped environment configuration). Evaluates full denominator accounting (
$K / N$ ) ensuring a 100% kill rate before candidate admission.
- Purpose: Supervised subprocess execution with strict timeouts, process tree termination, and structured IPC communication.
- Semantics: Runs test suites or compiled probes, parsing line-delimited JSON events (
start,state,case_failed,complete). Handles Windowstaskkill /F /Tprocess termination on timeout.
Before a candidate deconvolution is admitted, it must pass the mechanical density evaluation gate:
Marginal changes (e.g., refactorings that remove REJECTED, preventing shallow churn.
To extend Lesscode to a new language (e.g., Go, C#, or Kotlin):
Per .kiro/steering/prototype-first.md, every new language adapter requires an empirical prototype feasibility gate before production tasks:
- Select a real open-source specimen with an active test suite (e.g., Apache 2.0 or MIT).
- Isolate a single whole-responsibility target and author an equivalent candidate.
- Confirm
$\ge 20%$ canonical lines and$\ge 10%$ statement reduction. - Verify 100 finite-domain Cartesian test cases with 0 divergences.
- Author 4 mandatory adverse mutation controls and confirm a 100% kill rate.
- Generate a cryptographic receipt with a
.sha256sidecar in.kiro/specs/<feature>/results/.
Create native/src/adapters/<lang>/:
analysis.rs: Implement AST parsing and dynamic gap detection.mutation.rs: Implement 4 adverse mutation operators with denominator accounting.metrics.rs: Implement canonical line, physical line, and AST statement counting per<lang>-statements-v1.mod.rs: ImplementStateFrameAnalyzer,PureCoreVerifier,AdverseMutantGenerator, andSpecimenTraceRunner.
- Register
pub mod <lang>;innative/src/adapters/mod.rs. - Register the new modules in
native/complexity-budgets.jsonwith strict complexity ceilings:- Max physical lines:
$\le 400$ - Max logical syntax units:
$\le 300$ - Max function length:
$\le 80$ lines
- Max physical lines:
- Ensure total native apparatus volume remains within the governing R41 ceiling (
$\le 7,173$ canonical lines).
- Run adapter unit tests:
cargo nextest run --manifest-path native/Cargo.toml --test <lang>_* - Run end-to-end integration test:
cargo nextest run --manifest-path native/Cargo.toml --test <lang>_e2e - Run complexity budget checks:
cargo test --manifest-path native/Cargo.toml --test budgets cargo run --manifest-path native/Cargo.toml -- budgets --config native/complexity-budgets.json --root native/src --out target/budget-report.json
- Run full regression battery (including existing Python, TypeScript, Java, and Rust tests) to guarantee zero regressions.