Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.
Language plugins, part 2: Ruby, Kotlin, PHP, PowerShell, C#, Swift (audit id A6b)
Scope and coverage ledger
Read in full, every line, in chunks of at most 620 lines:
| File | Lines | Read |
|---|---|---|
src/lang/ruby.rs |
1246 | 1-1246 |
src/lang/kotlin.rs |
1205 | 1-1205 |
src/lang/php.rs |
1202 | 1-1202 |
src/lang/powershell.rs |
1134 | 1-1134 |
src/lang/csharp.rs |
1092 | 1-1092 |
src/lang/swift.rs |
952 | 1-952 |
tests/ruby_recording.rs |
109 | 1-109 |
tests/powershell.rs |
403 | 1-403 |
tests/swift.rs |
263 | 1-263 |
Read for context (not in scope, partial): src/lang/mod.rs 1-430 (all), src/lang/syntax.rs 1-260 of 519
(parse, walk, loc/code_lines, powershell_outside), src/bridge.rs 205-355 (js_only_reason,
state_through_calls), src/codegen_php.rs 1-135, src/codegen_ruby.rs 1-75 and 150-240,
src/codegen_java.rs 670-740 (reflection driver), DECISIONS.md, docs/STATUS.md 1-60, docs/pitfalls.md
(given). Not read: the input generators, harness_*, the rest of codegen_*, syntax.rs 260-519
(manifest helpers).
Experiments (scratch folder .../scratchpad/A6b/, nothing written in the repository except this report). I
copied the prebuilt target/debug/rust-anything to the scratch folder and ran analyze, bridge and (Ruby,
PHP, which only need ruby and php) record on small fixtures I wrote: rb, rb2, rb3, ph, kt,
kt2/kt3, cs, cs2, sw, sw2, ps. kotlinc, dotnet, swiftc and pwsh are not installed, so for
Kotlin, C#, Swift and PowerShell I confirmed what analyze/bridge claim (exports, blockers, risks, generated
wrapper text), not the replay verdicts. No cargo was run in the repository.
Summary
- No plugin in this group knows that an export reads or writes state outside its arguments. Mutation of an
argument in place, module/object/global state, clock, environment and file reads are not blockers, and (except
PowerShell
Get-Date/Get-Random, SwiftDate()/.random) not even risks. Such units come outreadywith readiness 86-98 and every export "bridgeable". Becauserecordstores only the return value, a function that mutates its argument and returns nothing is "matched" by an empty port (A6b-01, CONFIRMED on Ruby, same shape traced for Kotlin, C#, PowerShell). - Zero-argument functions (state, clock, env) get one recorded case, so a constant passes;
env_namerecorded"/root"into the file the workflow says to commit (A6b-03, CONFIRMED Ruby and PHP). - Type narrowing that hides behaviour from recordings: Ruby
Symbolis generated asStringalthough the codec has a$symmarker (A6b-04); Kotlin@JvmOverloadsfunctions are driven through whichever overloadgetMethods()returns last, which changed between two JVM runs (A6b-05). - A tree-sitter parse error silently shortens the export list: Kotlin
context(...)made 3 of 4 functions vanish andbridgestill said "Created ... for before" (A6b-06). PowerShellExport-ModuleMember -Function $namesand PHPif (!function_exists(..)) { function .. }also yield no exports with no explanation (A6b-07). - Risk scans have holes that make the "Risks" column look cleaner than it is (Ruby flags
<<, not*; SwiftSwiftTrapsnever fires for+/-/subscript; PHP$f()unflagged), but recordings with emoji and extreme integers catch most of those, so they are advice-level (A6b-08, A6b-12).
Findings
A6b-01 [H1] [HIGH] [CONFIRMED] A function that mutates its argument in place and returns nothing passes with an empty port
- Where:
src/lang/ruby.rs:802-923(method_fn: blockers only for=/!names, splat, block, yield),src/lang/kotlin.rs:639-766(IntArray,Array<T>,MutableList,MutableMapmap toint[]/string[]/Record withnative_typeList<String>etc.),src/lang/csharp.rs:752-797(onlyref/out/in/paramsblocked;int[],List<T>allowed),src/lang/powershell.rs:526-560(ps_to_ts:collections.arraylist,array,hashtable,int[]are plain JSON types,parameter_blockeronly for scriptblock/[ref]/unknown .NET types). PHP is fine (&$xblocked,reference_modifier); Swift is fine (inoutblocked). - What happens: the bridge copies the argument into Rust. The driver records
{"ok": <return value>}only (codegen_ruby.rscall:{ "ok" => enc(value) }; Java reflection drivercodegen_java.rs:~720:out.put("ok", ... result); PowerShell compares$Expected['ok'] -ceq $Got['ok']), and the arguments are not re-read after the call. The mutation, which callers rely on, is never compared. - Failing scenario (Ruby, run):
def self.sort_in_place(xs); xs.sort!; nil; endwith@param xs [Array<Integer>].bridgelists it as exported;recordwrites{"fn":"sort_in_place","args":[[100,7,-2147483648]],"ok":null}(7 cases, allok:null). Aport.rsbody ofOk(())passesdiff7/7, and callers of the wrapper see an unsorted array. Same formark(s)(s << "!"; nil): 20 cases, allok:null. Bridge outputs of the same shape: Kotlinfun sortInPlace(xs: IntArray)andfun appendAll(xs: MutableList<String>, ..)->pub fn sort_in_place(xs: Vec<i64>) -> Result<(), String>; C#SortInPlace(int[]),AddAll(List<string>, ..); PowerShellAdd-Item([System.Collections.ArrayList]$List, ..)->unknown[],Sort-InPlace([int[]]$Xs). Only the Ruby case was replayed; the others stop atbridgebecause the runtimes are missing, but the driver code paths are the ones quoted above. (Ruby'sappend!was blocked only because of the!in its name.) - Fix / verification improvement: (1) mechanical blocker in each plugin: an export whose return type is
void/undefined/nil/Unitand that takes an array/list/map/string (Ruby)/ArrayList/hashtable parameter stays in the original, reason "mutates its argument in place?". (2) Better, in the shared record/diff drivers: record aargs_aftersnapshot for each case (encode the arguments again after the call) and compare it indiff; the wrapper must then write mutated values back, or the export is kept. (3) Mutation self-test intests/: fixture withsort_in_place, assert thatdifffails againstOk(()).
A6b-02 [H3] [MEDIUM] [CONFIRMED] State, clock, environment and I/O are neither blockers nor risks in Ruby, Kotlin, PHP, C#; thin in Swift and PowerShell
- Where:
ruby.rs:477-599,kotlin.rs:162-258,php.rs:261-419,csharp.rs:268-400have noRisk::ClockAndRandomat all (grep: it is used only byts,python,powershell(get-date,get-random,new-guidonly) andswift(.random,Date(),UUID()only)). No plugin has an I/O or environment risk (theRiskenum has none). Module/object/global state is never a blocker;calls/state_through_callsonly chaseuses_class(Ruby, PHP, C#, PowerShell do not even fillcalls). - Failing scenarios (all run through
analyze --jsonandbridge): every function below is listed as an export with no blocker, and the unit isready:- Ruby (readiness 86):
@count += 1,n + Time.now.year,ENV.fetch("HOME"),File.read(path). Only risk shown: "Dynamic typing", "Null references". - PHP (readiness 93):
static $n; return ++$n;,date('Y'),getenv('HOME'),$fname($x). - Kotlin (readiness 98):
object Counter { private var n = 0; @JvmStatic fun next() },java.time.Year.now(). - C# (readiness 91):
static int _n; _n++,DateTime.Now.Year,x.ToString("N2"),s.ToUpper(),a.StartsWith(b),string.Compare. - Swift (readiness 88): global
var counter,Date.now,xs.randomElement(),xs.shuffled(). Not flagged:randomElement/shuffled/Date.now(scan matches only a nav suffix named exactlyrandomand the callDate()). - PowerShell (87):
$script:count++,$Prefixread from module scope,[DateTime]::Now,$env:HOME,Get-Content.$script:/$global:count as "Dynamic typing".
- Ruby (readiness 86):
- Why it matters: A8/A7 readiness and "Start here" treat these as safe first ports, an agent reads "ready" as "pure". The port then must reproduce hidden state or a different year/host; what is recorded is one machine's moment. Several of these are exactly the categories the brief lists (globals, environment, culture).
- Fix: add a shared
Risk::ReadsEnvironment/ReadsState(ENV/getenv/$env:/System.getenv/File.read, module-level mutable@ivar/static/global/top-levelvar) and clock/random calls per language; make "unit-level mutable state read by an export" a blocker likeuses_class. Cheap test: one fixture per language holding the listed snippets, assert the risk appears (tests/analyze.rsstyle).
A6b-03 [H1/H5] [MEDIUM] [CONFIRMED] Zero-argument exports get one recorded case; environment values are recorded into the committed file
- Where: input generation (outside my files) plus the plugins marking such functions bridgeable
(
ruby.rs:802,php.rs:696,kotlin.rs:639, ...). The secret filter inrecordonly looks at variable names that say secret (pitfall "A recording held a secret from the environment"). - Failing scenario (run): Ruby
def self.bump; @count += 1; end-> 1 case{"fn":"bump","args":[],"ok":1}; a portOk(1)passes and gate's literal check needs three or more literals. PHPcounter()same ({"fn":"counter","args":[],"ok":1}).ENV.fetch("HOME")and(string) getenv('HOME')recorded{"fn":"env_name","args":[],"ok":"/root"}and{"fn":"env_home","args":[],"ok":"/root"}intocases.jsonl: a local path in the file the workflow tells people to commit (cf. pitfall "A local path reached a committed manifest").today_plus(n)recorded the year 2026 in 17 cases; a portn + 2026passes today and gate sees 17 different outputs, not 3 identical literals. - Fix:
recordshould warn when a case has no arguments and the function has no blocker ("one case; a constant satisfies it; is it state or clock?"), flag recorded string values that equal$HOME,$USER, the cwd or hostname (extend the secret filter to the values of well-known env vars, not only names), and--pin-clockshould exist for Ruby/PHP/Kotlin (STATUS lists it only for TS/Python). Mutation test: portbumpasOk(1), assertgateorrecordreports a warning.
A6b-04 [H1/H3] [MEDIUM] [CONFIRMED] Ruby Symbol parameters are typed string, so the original is only ever called with Strings
- Where:
ruby.rs:741("Symbol" => "string", also asHashkey,:742). The codec has$sym(codegen_ruby.rs:25,45) anddecwould build a Symbol, but nothing generates one for astringparameter. - Failing scenario (run):
@param mode [Symbol],case mode when :a then "A" when :b then "B" else "other" end. All 27 recordedkindcases are"other"(inputs are strings like"hello";"a"as a string also yields"other"in the original). A port that implements only"other", or the faithful port for real symbol callers ("a"->"A"), is judged by behaviour of a never-matching comparison. A wrong port passes; a correct one fails if the generator hits"a". - Fix: map
Symbolto a distinct dialect type (symbol) so the generator emits{"$sym": ..}(and Hash keys likewise); mutation self-test: fixture withcase sym when :a, break the port's:abranch, assertdifffails.
A6b-05 [H5/H1] [MEDIUM] [CONFIRMED mechanism, not replayed (no kotlinc)] Kotlin @JvmOverloads is driven through an arbitrary overload
- Where:
kotlin.rs:639-766never looks at@JvmOverloads(theJvmNamecheck at:668is the only annotation check); the reflection drivercodegen_java.rs:696doesfor (Method m : c.getMethods()) if name matches METHODS.put(key, m)(last one wins) and then reads onlytypes.lengtharguments (values[i]loop at~:718); extra recorded arguments are dropped without error. - Failing scenario:
@JvmOverloads fun pad(s: String, width: Int = 10, fill: String = " ")is exported as the 3-argument function (bridge output:acme.UtilKt.pad(String s, Int width, String fill)), but the class has threepadmethods. I ran the same loop on a Java class with three overloads: the chosen method waspad(String,int)on the default run,pad(String)with-Xshare:off,pad(String,int)with-XX:+UseSerialGC. So the recorded results are those of a shorter overload, differ between runs, and ignore later arguments; the 3-argument port then fails (or, with defaults that coincide, passes for the wrong reason). - Fix: in
kotlin::collectset blocker "@JvmOverloadsgenerates overloads" (the same waykotlin::exportsblocks repeated names at:899), or make the driver select the method by parameter count of the prototype and fail on ambiguity. Test: Kotlin fixture with@JvmOverloads, assertbridgekeeps it (runs withoutkotlinc).
A6b-06 [H6] [MEDIUM] [CONFIRMED] A parse error silently shortens the export list; bridge says nothing
- Where: all plugins use
syntax::parse(returns a tree even with errors) andexportsignoreshas_error.analyzesetsparse_errors(kotlin.rs:171) and marks the unitcaution, butbridgedoes not mention it. - Failing scenario (run): Kotlin file with
fun before(..),context(ctx: String) fun ctxFun(..),fun after(..),fun last(..):analyze --json->exports 1, statuscaution, note "1 parse error: results for this unit are partial.";bridge-> "Created ... for before". Three functions are not reported as "kept" or as "not seen". An agent readingbridgeable 1/1believes the unit has one function. (The same file without thecontextline: 3 of 3 exports; avalue classis fine.) Ruby with a real syntax error still listed all three functions, so the damage depends on grammar recovery; newer syntax of any of the six languages is the realistic trigger (Kotlin 2.2 context parameters here). - Fix:
bridgeandanalyze --jsonshould refuse (or warn loudly with the count) whenparse_errors > 0for a unit that is bridged, and list byte ranges of ERROR nodes; addexports_incomplete: trueto the JSON. Test: the Kotlin snippet above must makebridgefail without--force.
A6b-07 [H6] [LOW] [CONFIRMED] Exports silently missing for conditional/computed definitions
- PowerShell
powershell.rs:618-644:Export-ModuleMember -Function $namesputs the literal$nameson the list,wildcard("$names", f)matches nothing, so every function is dropped (run:analyzesaid "No unit exports anything a bridge can carry yet: the units below expose constants, types or nothing a port could call", andbridgesaid "exports no functions"). Wrong cause, fails closed. AlsoFunctionsToExportin the.psd1is never read (helpers the manifest hides are listed as exports) and functions insideif (...) { function .. }are skipped. - PHP
php.rs:879-927: only top-level and namespace-levelfunction_definition;if (!function_exists('x')) { function x() {} }(the usual shape for polyfills and helper files) is dropped (run:guardedmissing, no mention). Methods of enums/interfaces/traits and nested classes are also dropped; C#record/structstatics and nested public classes (csharp.rs:841) and Ruby top-leveldeflikewise. - Fix: report "N function definitions not seen (conditional, nested)" in
analyze; for PowerShell treat a non-literalExport-ModuleMemberargument as "unknown export list" with a note.
A6b-08 [H3] [LOW] [CONFIRMED] Risk scans mislabel or miss the operations their risk text names
- Ruby
ruby.rs:577-585:IntegerSemanticsis flagged for**and<<(string/array append, common) and not for*,+. Run:s << "x"flagged ("Integer width and overflow x1") whilen * n * nwas not; recordedcube(9223372036854775807)is a 57-digit bignum, which the recording does capture, so a port must use a bignum. Advice-level only. - Swift
swift.rs:282-289: the arm matchesmultiplicative_expression | additive_expressionbut the op test is"*" | "/" | "%", so+and-(the documented M14 example:a + btraps on overflow) are never flagged; array subscripts (xs[0]) andtry!/as!are not either, though the risk label says "overflow,!, index out of range". Run:add,sub,first(xs[0])unflagged,Int(s)flagged. Recordings withInt.maxdo catch overflow (seetests/swift.rs). - Kotlin
kotlin.rs:228-253matches substrings of the whole call text, soprintln("indexOf")is flagged (StringOffsets) whiles.length,s[0],take,dropare not; C# flagsSubstring,IndexOf, not.Lengthor indexers. The recording corpus includes emoji and combining marks ("a😀b"appears in every Ruby/PHP run), which is what really protects the UTF-16 versus UTF-8 distinction.
A6b-09 [H3] [LOW] [CONFIRMED text, not compiled (no swiftc)] Swift typed throws throws(E) is not seen as throws
swift.rs:597-605reads only athrowschild; withfunc typed(_ a: Int) throws(E) -> Intthe signature hasthrows == false, and the generated wrapper for it isreturn raTrap { try raDecode(raCall(..).get()) }where the plain-throwswrapper rethrows. A port error becomesfatalError(a trap) while the original throwsE:difffails a correct port. Fails closed, no blocker or note.- Fix: detect
throws(in the declaration text and either support or block with a reason; fixture test intests/swift.rsthat does not needswiftc(bridgeonly).
A6b-10 [H5] [MEDIUM] [PLAUSIBLE] Locale, culture and time zone are neither pinned nor flagged (C#, Ruby, PHP, Kotlin, Swift)
- No harness sets
LANG,LC_ALL,TZ,DOTNET_SYSTEM_GLOBALIZATION_INVARIANT(grep of.env(inharness_*.rs: only .NET telemetry,RUST_ANYTHING_*). C#ToUpper(),StartsWith(string),string.Compare,ToString("N2"),SortedDictionary<string,..>(mapped toRecord<string, ..>atcsharp.rs:691) andOrderByare culture-sensitive and the plugin has no risk for them (csharp.rs:384-392lists onlySubstring/IndexOf/...); PowerShell has the pitfall text forİbut a-f/.ToString()format uses the current culture. The recording stores whatever the recording machine did and the port is judged against that; recording on another machine gives differentcases.jsonl. - Fix: run drivers with
TZ=UTC,LC_ALL=C.UTF-8,DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1(and say so in the report), add a C# risk for culture-sensitive string/number APIs, and record the environment incases.jsonl's header sodiffcan warn when it differs.
A6b-11 [H3] [LOW] [CONFIRMED] Ruby module_function :name / private_class_method :name match by substring
ruby.rs:1019-1029usescall.contains(":clamp"), somodule_function :clamp_allalso exports a methodclampthat is not a module function, and:1060hidden.contains(":foo")hidesfoowhenprivate_class_method :foobaris written. Run (rb2):clampwas exported and its 9 recorded cases areNoMethodError: undefined methodclamp' for module M2; the generated wrapper definesclampanyway (ruby/m2_rs.rb:19`). Fails closed (the port would have to raise NoMethodError) but adds an API method the original does not have.- Fix: parse the symbols of the call's argument list instead of
contains.
A6b-12 [H3] [LOW] [CONFIRMED] Obfuscated dynamic calls are not flagged in PHP, PowerShell, Kotlin
- PHP
php.rs:317-368:$fname($x),$obj->$method(),new $classare notDynamicCode/Reflection(onlycall_user_func*and named reflection functions are); shell and process calls (shell_exec,exec,system, backticks) are unflagged (proc_openonly). Run:call_by_name($fname, $x)-> no risk at line 18 (only thefunction_existsat line 39 appeared). - PowerShell
powershell.rs:347:invoke-expression/iex/invoke-commandflagged, buticm,[scriptblock]::Create(...),$ExecutionContext.InvokeCommand.InvokeScript,& $cmd(onlyCallbacks) are not. - Note: the scan is AST based, so comments and strings are not flagged (good); the exception is Kotlin's substring match (A6b-08).
A6b-13 [H3] [WEAK] Type mappings that drop distinctions
- PHP
array<int, V>->V[](php.rs:561): sparse integer keys never generated;array->unknown[] | Record<..>is fine. C#HashSet/ISet->T[](csharp.rs:682), Kotlin refusesSet: inconsistent; the original dedupes a list given as input, the port sees duplicates. PowerShell[char]->string,[decimal]->number(f64). RubyFloat, Numeric->numberconflatesInteger/Floatresults (the5versus5.0comparison is exact in the Ruby/PHP codecs, so recordings catch this).
A6b-14 [H2] [LOW] [CONFIRMED] Doc understates, and LOC edge cases
docs/STATUS.md:39says calls are followed for Java and Kotlin, "other languages do not list calls yet"; Swift fillscallstoo (swift.rs:748). Harmless understatement.- LOC (
lang/mod.rs:229-237,syntax.rs): PHP#[Attribute]lines count as comments (#prefix); lines inside Kotlin/Swift raw strings that begin with//,*or#and Ruby text after__END__are miscounted. Only affects size/priority numbers.
Verification improvements for this area (ranked)
- Record
args_afterfor every case and compare it indiff; until then block void-returning exports with mutable parameters (A6b-01). Mutation self-test: fixture with an in-place function per language, assertdifffails against an empty port. - Shared "reads state / environment / clock / random" detection per plugin, as risk and (for module-level mutable
state) blocker; fixture per language with the snippets of A6b-02 (all runnable with
analyzeonly). bridge/analyze --jsonmust fail or warn loudly whenparse_errors > 0for the unit and exposeexports_incomplete(A6b-06); regression test with the Kotlincontext(...)snippet.record: warn for zero-argument exports (one case) and redact/flag recorded values equal to$HOME,$USER, cwd, hostname (A6b-03); pinTZ, locale and .NET invariant globalization in all drivers (A6b-10).- Ruby
Symbolas its own dialect type; Kotlin@JvmOverloadsblocker; Swift typed-throws detection; Rubymodule_functionargument parsing (A6b-04, 05, 09, 11), each with abridge-only test. - Fix the dead
additive_expressionarm in Swift's scan and Ruby's<</*split (A6b-08).
Things checked and found sound (so nobody re-checks them)
- PHP: by-reference parameters (
&$x,reference_modifier), variadics, callables/Closure, object types and object returns, magic methods,yieldare all blockers (php.rs:725-804); output is captured (ob_start) and compared; results are compared as JSON text, so5versus5.0and[]versus{}differ as PHP would see them (codegen_php.rs:10-64).declare(strict_types=1)files recorded fine in my run. - Ruby codec: Symbols, NaN/Infinity/-0 and non-string-key hashes have markers;
pitfallsentry about unencodable results is covered bytests/ruby_recording.rs(it asserts the recording file is kept on failure). - Kotlin: tree-sitter supertype pitfall is handled (
collectreadsfunction_declarationdirectly underclass_body);@JvmStatic/companion/@file:JvmName/private/internal/extension/suspend/inline/generic and repeated names are blocked or placed on the right JVM owner (kotlin.rs:604-918); unknown types fail closed touses the class(typealiases and(Int)->Intwithout spaces are blocked, not guessed). - C#:
decimal,ulong,char,object, delegates,Task, tuples, unknown types,ref/out/in/params, generics and overloaded names are blocked; records/POCOs are resolved only when plain. - Swift: closures,
inout,Set,Character,Decimal,Date, optionalsome/any, generics, async,rethrows, variadics,@objcand overloads are blocked with reasons; theInttrap is recorded astrapand matched (tests/swift.rsmutates the port withwrapping_addand withchars().count()and expectsdiffto fail). - PowerShell:
filter,workflow,begin/processblocks,$input,$PSCmdlet/$args, pipeline-bound parameters, script blocks,[ref]and unknown .NET types are blockers; the wrapper reuses the originalparam()block so defaults and validation attributes stay in PowerShell (tests/powershell.rschecks it and mutates the port). tests/powershell.rs,tests/swift.rs,tests/ruby_recording.rsskip with a printedskipped: ...when the runtime is missing, andRUST_ANYTHING_REQUIREturns that into a failure (tests/common/mod.rs:3,39); the first test of each of the PowerShell and Swift files (bridge only) runs without the runtime. STATUS marks all of them "Tested", not "Verified".- Comments and string contents do not produce AST-based risks (Ruby, PHP, C#, Swift, PowerShell); only Kotlin's substring heuristics can (A6b-08).