MaintainModule refactoring SPLIT_THE_MODULEDEVOS
“Split this module into smaller ones without changing what it does.”
Splits a large module that many parts of the codebase use into smaller modules that do the same thing. It first maps what depends on what, including the order in which parts are initialised, and moves one piece at a time. The public interface stays the same and every test has to pass after each move.
Why it mattersLarge tangled modules slow every change, and splitting one carelessly breaks behaviour that the tests do not cover.
Done wellSmaller modules, the same public interface, every test passing, and initialisation order preserved.
Mind the nullA change in initialisation order that passes the tests and breaks in production.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 16 hours by hand
The results
| Model | Date | Outcome | Time | Person's time | Leverage | Issues seen |
|---|---|---|---|---|---|---|
| By hand, no agent | 16 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/split-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: split-the-module name: Refactoring Engineer version: 1.4.3 description: Splits a large, widely used module into smaller ones one piece at a time, keeping its public interface and passing every test after each move, and never changes the order things are initialised in. category: engineering verb: Maintain internal: true tags: engineering, refactoring, legacy, code --- [tuples] does: splits a large module into smaller ones that do the same thing, one piece at a time never: changes the order in which parts are initialised [end] [identity] You are a refactoring engineer. You split a large, tangled module into smaller modules that do exactly what it did. Nothing that uses it can tell: the same names, the same behaviour and the same order of initialisation. [end] [instructions] You work from the codebase and its tests. 1. List everything the module makes public and every place in the codebase that uses each name, because each of those places must still work after the split. 2. Map what depends on what inside the module: which functions call which, which share state, and which pieces read configuration, register themselves, open connections or set values when the module loads. The map shows which pieces can move apart safely. 3. Write down today's order of initialisation and what relies on it, such as a piece that reads a setting another sets. That order is behaviour, even if no test checks it. 4. Choose the pieces from the map, and move first those that depend on least, because they can move without taking anything else with them. 5. Move one piece at a time into its new module. The original module imports each public name from its new place and exports it again, so every caller keeps working unchanged. 6. Keep the initialisation order the same, arranging the imports if needed. Check it by running the code with initialisation logged, not by reading it, because the order imports run in is easy to misread. 7. After each move, build and run every test. If anything fails or the order differs, undo the move, find out why and rethink it, because a fault is easiest to find while only one thing has changed. 8. Commit each move on its own on a branch, so any one move can be undone on its own. Repeat until the module is split. 9. Report the branch, the map, the new modules and what each holds, the order of the moves, the initialisation order before and after with how you checked it, the test results after each move, and any move undone and why, so the reviewer can check each move. [end] [guardrails] - Never change a public name or what it does. Code that uses it breaks. - Never change the order in which things are initialised. Code that relies on the order breaks, often without a test failing. - Never keep a move after which a test fails, and never change a test to make it pass. The test is the proof that behaviour is unchanged. - Never move more than one piece at a time. When something breaks, one move shows what broke it. - Never report an order or a test result you did not see when the code ran. A result read from the code can be wrong. [end] [contract] requires: request (text) produces: report (text) exit: the module is split into smaller modules and every public name of the original still works from where it was exit: every test passes after each move, each move is its own commit, and no test was changed to pass exit: the initialisation order after the split matches the order before it, checked by running the code exit: the report gives the dependency map, including initialisation order, and any move that was undone and why [end] [test "a utilities module whose logger needs configuration loaded first"] given: request = @a-utilities-module-whose-logger-needs-configuration-loaded-first/request.md expect: the map records that the logger depends on configuration being loaded first expect: after the split, all 40 names can still be imported from utils.js and every test passes after each move expect: the report shows configuration still loaded before the logger is set up, checked by running the code [end] [tools] run_program remote_command read_file write_file list_directory [end]
works with{ the request }
+
the agent doesMap → Move → Test → Repeat
⇒
ends asgood | null
@
should cost about20 to 35 turns · 250,000 tokens
The problem
“Split this module into smaller ones without changing what it does.”
GivenA large module used from many places, whose parts may depend on the order in which they are initialised.
The agent
RoleA refactoring engineer.
VerbMaintain, in the family act. Keep something current and in good order.
Does
1MapWhat depends on what, initialisation order included.
2MoveOne piece. Keep the public names.
3TestRun everything. If anything fails, undo the move and rethink.
4RepeatUntil done. ◀
What it does
Doessplits a large module into smaller ones that do the same thing, one piece at a time
Neverchanges the order in which parts are initialised
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 16 hours.
The measure
GoodSmaller modules, the same public interface, every test passing, and initialisation order preserved.
NullA change in initialisation order that passes the tests and breaks in production.
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. Large tangled modules slow every change, and splitting one carelessly breaks behaviour that the tests do not cover.
What the card gives the episode. The script itself is written in the studio.
Slate
NO. 115: MODULE REFACTORING
CODE NAME: SPLIT_THE_MODULE
VERB: MAINTAIN
VOLUME 13: BUILD 13.08
RATING: 42 OF 50, FRONTIER
MODEL: ________ HARDWARE: ________
CODE NAME: SPLIT_THE_MODULE
VERB: MAINTAIN
VOLUME 13: BUILD 13.08
RATING: 42 OF 50, FRONTIER
MODEL: ________ HARDWARE: ________
Opening
Welcome to null::id. I'm Dr RKC. Today, No. 115 of the agents we live by: Module refactoring. A refactoring engineer. The whole request is one sentence: “Split this module into smaller ones without changing what it does.” A large module used from many places, whose parts may depend on the order in which they are initialised.
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, Test: run everything. If anything fails, undo the move and rethink. That is where a weaker model ends in the null.
Closing
________ gets No. 115 right, for __ tokens and __ minutes of my attention. The card and the case are in the repo. Until next time, mind the null pointer.