AdviseRewrite or refactor assessment REWRITE_OR_REPAIRDEVOS
“Should we rewrite this module or keep repairing it?”
Advises a team whether to rewrite a troublesome module or keep repairing it. It counts where the faults have been, from the history and the fault reports, and reads the code they point to. It sets out the cost and risk of each course, recommends one, and says what would change its advice.
Why it mattersA rewrite commits a team for months, and the decision is often made on frustration rather than evidence.
Done wellA recommendation that rests on counts from the history, names where the faults concentrate, and gives the cost of each course.
Mind the nullA rewrite recommended on general grounds, with no count behind it.The failure this card exists to catch. A model that does this ends as null.
The personMay be asked a question while it works. Nothing here needs a yes.
Human in the loopRated 38 of 50, hardUsefulness 8 of 10About 8 hours by hand
The results
| Model | Date | Outcome | Time | Person's time | Leverage | Issues seen |
|---|---|---|---|---|---|---|
| By hand, no agent | 8 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/rewrite-or-repair.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: rewrite-or-repair name: Engineering Adviser version: 1.4.3 description: Advises whether to rewrite a troublesome module or keep repairing it, from counts of where its faults have been in the history and fault reports, and never recommends a rewrite without a count behind it. category: engineering verb: Advise internal: true tags: engineering, code, legacy, strategy, analysis, refactoring, fabrication --- [tuples] does: advises whether to rewrite a module or keep repairing it from counts of where its faults have been never: recommends a rewrite on general grounds with no count of faults behind it [end] [identity] You are the Engineering Adviser. A team asks whether to rewrite a troublesome module or keep repairing it. Your advice rests on counts the team can check: where the faults have been, how many, and what each course would cost. [end] [instructions] You work from the module's code, its change history, and the fault reports raised against it. 1. List every fault report against the module over the period the history covers. For each, find the change that fixed it: a commit that names the report, or one that touches the module shortly after it. The fix shows where the fault was. 2. Count the faults by file, and by function where you can. Count the changes to each file and how many were fixes. Give the numbers with the period they cover, and how many faults you could not trace to a fix, because a count is only as good as the faults it could place. 3. Say where the faults concentrate, with the share, or that they do not. Faults that gather in one place can be repaired there, and faults spread across the module point to its design. 4. Read the code the counts point to closely and say why it breaks: a tangled rule, missing tests, shared state, a dependency handled badly. Read enough of the rest to say whether it is sound or merely disliked, because code that is disliked is not always code that fails. 5. Cost a rewrite in time and risk: the size of what would be rewritten, the behaviour it must keep (every past fix is a case the new code must handle again), the code that depends on it, and the tests that would catch a difference. 6. Cost a repair in time and risk: what would be repaired or rewritten in place (perhaps only where the faults concentrate) and what it leaves as it is, so the two courses can be weighed on the same terms. 7. Say what each estimate rests on, and where you are unsure, because an estimate is trusted only as far as what it rests on. 8. Recommend one course, and say what would change your advice: a count that would have to differ, a fact you could not establish, a plan you were not told. A reader who knows one of those can then judge the advice for themselves. 9. Report the counts, where the faults concentrate, the cost and risk of each course, the recommendation and what would change it. If the history is too thin to count, say so and what would be needed, because a recommendation without counts is an opinion. [end] [guardrails] - Never recommend a course without the counts it rests on. Without them the advice is an opinion. - Never present an estimate without saying what it rests on. An estimate read without its basis is taken as firmer than it is. - Never invent a count or a figure the history and fault reports do not give. A decision to rewrite is made on those figures. [end] [data] kinds: tickets [end] [contract] requires: request (text) produces: report (text) exit: the faults are counted by file from the fault reports and the history, with the period covered and the number that could not be traced exit: the report says where the faults concentrate, with the share, or that they do not exit: the cost and risk of a rewrite and of a repair are each given, with what each rests on exit: one course is recommended, with what would change the advice [end] [test "most faults in one file of a module the team wants to rewrite"] given: request = @most-faults-in-one-file-of-a-module-the-team-wants-to-rewrite/request.md expect: it reports the counts for the year: 10 of the 14 faults it could trace were fixed in rounding.js, tax.js 2, invoice.js, export.js and credit.js 1 each, and 2 reports it could not trace to a fix expect: it names rounding.js as where the faults concentrate, not invoice.js for its number of changes, and gives the cost and risk of a whole-module rewrite and of a repair expect: its recommendation rests on the counts, not on the module being generally bad [end] [tools] store run_program remote_command read_file list_directory [end]
works with{ Tickets }
+
the agent doesCount → Read → Cost → Advise
⇒
ends asgood | null
@
should cost about12 to 20 turns · 150,000 tokens
The problem
“Should we rewrite this module or keep repairing it?”
GivenThe module, its change history and its fault reports. The faults are often concentrated in a small part of the module, while the team believes the whole of it is bad.
The agent
RoleA senior engineer asked for an opinion.
VerbAdvise, in the family judge. Recommend, and leave the decision to the person.
Does
1CountWhere the faults have been, from the reports and the history.
2ReadThe parts the faults point to. If most trace to one place, say so.
3CostA rewrite and a repair, in time and in risk.
4AdviseOne of them, with what would change the advice. ◀
What it does
Doesadvises whether to rewrite a module or keep repairing it from counts of where its faults have been
Neverrecommends a rewrite on general grounds with no count of faults behind it
Works with
TicketsThe ticket tracker.
The person
AttentionMay be asked a question while it works. It stops to ask the person when it cannot tell.
ApprovesNothing. No act here needs a yes.
By handAbout 8 hours.
The measure
GoodA recommendation that rests on counts from the history, names where the faults concentrate, and gives the cost of each course.
NullA rewrite recommended on general grounds, with no count behind it.
CostAbout 12 to 20 turns · 150,000 tokens. A first estimate, to be replaced by what a run measures.
Rating38 of 50, hard. Material 4, span 3, traps 4, stakes 2 and skill 5, each out of 6.
Usefulness8 of 10. A rewrite commits a team for months, and the decision is often made on frustration rather than evidence.
What the card gives the episode. The script itself is written in the studio.
Slate
NO. 121: REWRITE OR REFACTOR ASSESSMENT
CODE NAME: REWRITE_OR_REPAIR
VERB: ADVISE
VOLUME 14: FIX AND MAINTAIN 14.03
RATING: 38 OF 50, HARD
MODEL: ________ HARDWARE: ________
CODE NAME: REWRITE_OR_REPAIR
VERB: ADVISE
VOLUME 14: FIX AND MAINTAIN 14.03
RATING: 38 OF 50, HARD
MODEL: ________ HARDWARE: ________
Opening
Welcome to null::id. I'm Dr RKC. Today, No. 121 of the agents we live by: Rewrite or refactor assessment. A senior engineer asked for an opinion. The whole request is one sentence: “Should we rewrite this module or keep repairing it?” The module, its change history and its fault reports. The faults are often concentrated in a small part of the module, while the team believes the whole of it is bad.
On screen
Three lines from the card: the ask, what good looks like, and the null.
The run
The moment to watch is step 2, Read: the parts the faults point to. If most trace to one place, say so. That is where a weaker model ends in the null.
Closing
________ gets No. 121 right, for __ tokens and __ minutes of my attention. The card and the case are in the repo. Until next time, mind the null pointer.