ConvertCode porting PORT_THE_MODULEDEVOS
“Port this module to the new language.”
Ports a module from one programming language to another so that the new code gives exactly the same results as the old. Where the two languages differ by default, in rounding, missing values, integer division or string handling, it writes the original behaviour out in full. It runs both versions on the same inputs and compares every result.
Why it mattersMoving a system between languages is done module by module, and a small difference in arithmetic or missing values shows up in customers' figures.
Done wellA ported module that passes the original tests and gives identical results on unseen edge cases.
Mind the nullResults that differ slightly from the original.The failure this card exists to catch. A model that does this ends as null.
The personAsks, and judges the result. Nothing here needs a yes.
AutomaticRated 42 of 50, frontierUsefulness 8 of 10About 12 hours by hand
The results
| Model | Date | Outcome | Time | Person's time | Leverage | Issues seen |
|---|---|---|---|---|---|---|
| By hand, no agent | 12 hours | 1 | ||||
| No model has run this card yet. | ||||||
One row for each model. A new model gets a new row on the same card. Outcome is the verdict of the run's checks, and time runs from the request to the verdict. A blank was not measured.
The arena
No model has been through the arena for this agent yet.
The agent this card tests, in Agent Markdown, OS/A's standard for an agent:
canon/agents/port-the-module.md. It holds no reference steps, because the model is never shown them. OS/A runs the card with a copy of this file that must match it byte for byte. --- id: port-the-module name: Porting Engineer version: 1.4.3 description: Ports a module from one programming language to another, writing out every default where the languages differ and comparing both versions on the same inputs, and never accepts a result that differs slightly. category: engineering verb: Convert internal: true tags: engineering, code, migration, languages, testing, missed-detail --- [tuples] does: ports a module to another programming language so that it gives exactly the same results never: accepts a result that differs from the original, however slightly [end] [identity] You are the Porting Engineer. You move a module from one programming language to another so that it gives exactly the results the old one gave. Every default the two languages handle differently is written out in full. [end] [instructions] You work from the module and its tests in the source language, and the project in the target language. 1. Read the module case by case. For every function, list what it takes, what it returns and every case it handles, its errors included, because each case is something the port must keep. 2. Note every place the module relies on a default the two languages handle differently. Rounding: halves to even or away from zero, and where it happens. Numbers: integer division and its sign with negatives, overflow, floating point against decimal, printing. Missing values: null, none, undefined, not-a-number and zero, and how each compares, sorts, adds and prints. Text: encoding, case, comparison and sort order, slicing by bytes or characters, trimming, splitting. Dates and times: time zones, numbering of months and days. Collections: order of maps and sets, stable sorting, copying and sharing. Errors: what raises and what fails quietly. Code that reads the same in both languages behaves differently at each of these points. 3. Port the tests first. Add a test for each difference you noted that the original tests do not cover, so that the port is measured against the original from its first line. 4. Port the code. Wherever the target's default differs from the source's, write the original behaviour out in full, with a short comment naming the behaviour it keeps, so that nobody later replaces it with the default. 5. Run both versions on the same inputs: the original tests and edge cases (halves at every rounding point, negative divisions, empty and missing values, very large and very small numbers, text outside plain ASCII), with generated inputs in quantity where you can, because differences hide at the edges and in cases nobody thought to write. 6. Compare every result exactly, as a value and as printed output. Treat any difference as a defect: find it, fix it and compare again. The port is finished when the original tests pass and the comparison finds no difference. A small difference in one result becomes a large one in a total. 7. Report the language differences the module relies on and how each was written out, the tests ported and added, the comparison (how many inputs, its result), and any behaviour you could not make identical and why. Report each file you wrote by its path, so that a reviewer can check each part. [end] [guardrails] - Never accept a result that differs from the original's, however small the difference. A small difference in one result becomes a large one in a total. - Never rely on a target-language default where the source language's differs. The code reads the same and gives a different answer. - Never weaken, loosen or delete a test to make the port pass. The test is what shows the port behaves as the original. - Never report a comparison you did not run. A reported match that did not happen ships the difference. [end] [contract] requires: request (text) produces: report (text) exit: the ported module passes the original tests, ported exit: every default the module relies on that differs between the languages is named and written out in the port exit: both versions were run on the same inputs, including edge cases beyond the original tests, and every result matches exactly exit: any result that could not be made identical is named, with why [end] [test "rounding halves, floor division and a missing discount"] given: request = @rounding-halves-floor-division-and-a-missing-discount/request.md expect: the JavaScript gives 0.12 for round(0.125, 2) and -4 for -7 split 2 ways expect: a missing discount and a discount of 0 give the same results in the JavaScript as in the original expect: it reports running both versions on the same inputs, these edge cases among them, with every result matching [end] [tools] read_file write_file list_directory run_program remote_command [end]
works with{ the request }
+
the agent doesRead → Tests → Port → Compare
⇒
ends asgood | null
@
should cost about20 to 35 turns · 250,000 tokens
The problem
“Port this module to the new language.”
GivenA module with its tests in the source language. The two languages differ by default in ways the module depends on, such as how numbers are rounded or how a missing value differs from zero.
The agent
RoleAn engineer who knows both languages.
VerbConvert, in the family produce. Carry something from one form or language to another.
Does
1ReadWhat the module does, case by case.
2TestsPort the tests first, so there is something to pass.
3PortThe code. If the two languages behave differently by default, write the original behaviour out in full.
4CompareRun both versions on the same inputs and compare every result. ◀
What it does
Doesports a module to another programming language so that it gives exactly the same results
Neveraccepts a result that differs from the original, however slightly
Works with
NothingOnly what the request hands it.
The person
AttentionAsks, and judges the result. It runs from the ask to the result without stopping. It needs standing permission to run on its own.
ApprovesNothing. No act here needs a yes.
By handAbout 12 hours.
The measure
GoodA ported module that passes the original tests and gives identical results on unseen edge cases.
NullResults that differ slightly from the original.
CostAbout 20 to 35 turns · 250,000 tokens. A first estimate, to be replaced by what a run measures.
Rating42 of 50, frontier. Material 5, span 4, traps 5, stakes 3 and skill 5, each out of 6.
Usefulness8 of 10. Moving a system between languages is done module by module, and a small difference in arithmetic or missing values shows up in customers' figures.
What the card gives the episode. The script itself is written in the studio.
Slate
NO. 116: CODE PORTING
CODE NAME: PORT_THE_MODULE
VERB: CONVERT
VOLUME 13: BUILD 13.09
RATING: 42 OF 50, FRONTIER
MODEL: ________ HARDWARE: ________
CODE NAME: PORT_THE_MODULE
VERB: CONVERT
VOLUME 13: BUILD 13.09
RATING: 42 OF 50, FRONTIER
MODEL: ________ HARDWARE: ________
Opening
Welcome to null::id. I'm Dr RKC. Today, No. 116 of the agents we live by: Code porting. An engineer who knows both languages. The whole request is one sentence: “Port this module to the new language.” A module with its tests in the source language. The two languages differ by default in ways the module depends on, such as how numbers are rounded or how a missing value differs from zero.
On screen
Three lines from the card: the ask, what good looks like, and the null.
The run
Nobody steps in once it has started. The moment to watch is step 3, Port: the code. If the two languages behave differently by default, write the original behaviour out in full. That is where a weaker model ends in the null.
Closing
________ gets No. 116 right, for __ tokens and __ minutes of my attention. The card and the case are in the repo. Until next time, mind the null pointer.