Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
3.3 KiB
3.3 KiB
id, title, kind, expected_rounds
| id | title | kind | expected_rounds |
|---|---|---|---|
| refactor-shop | Refactor a legacy order-processing package (pricing, config, dates, dead code, docs) | refactor | 30-60 |
refactor-shop
Notes for the orchestrator (not sent to Codex).
- Seed: package
shop/(22 modules, about 1.2k lines), 119 visible unit tests (all green on the seed),REFACTOR.md(the 8-step spec),docs/ARCHITECTURE.md(old layout). Reading the whole code base plus the tests is about 25-35k tokens; with the edits and test runs the context grows to roughly 60-100k tokens. - The work: one new pricing module replacing 4 copies of the price calculation, a frozen
Config(25 fields, about 15 modules lose constants and gain aconfig=Nonekeyword), renameCust->Customer(code, tests, docs), 5 report functions return strings andcli.pyprints them, oneparse_datereplaces 4 hand-written parsers, 5 dead functions removed, type hints/docstrings for the new modules, docs update. - Acceptance (
accept.py): runs a pristine copy of the visible tests fromhidden/tests/with\bCust\b->Customerapplied (the tests inside the workspace are ignored, so edits to them cannot help), then AST/regex checks for every step (pricing/config/dates modules and their shape, removed names, no numeric UPPER_CASE constants outside config.py/sample.py, noquantize/print/strptime/date(...)where forbidden, hints and docstrings, ARCHITECTURE.md content) and 12 hidden behaviour checks (hidden/behaviour.py): the default values ofConfig,price_ordergolden numbers, edge cases, 400 random orders x random configs against an independent oracle,config=keyword on every function listed in REFACTOR.md step 2, reports returning text without printing,parse_dateformat matrix. - Typical failure modes of a weak agent: forgetting some modules when moving constants (the constants check names the module), leaving
.quantizecopies behind,reportsstill printing,Custleft in docs/tests,config=keyword missing on a function from the list (behaviour checks),parse_datenot accepting one of the formats. - Python: written for 3.9 .. 3.14, standard library only, deterministic (the random checks use a fixed seed).
- The reference solution (
reference/overlay/) is a complete refactor; it passesaccept.pyon Python 3.9 and 3.12.
Prompt
This repository is a small order-processing library (shop/) with a unit test suite in tests/. I want it cleaned up, and the plan is written down in REFACTOR.md in the repository root. Please read that file first and carry out all 8 steps.
Some things to keep in mind:
- Behaviour must not change. Every number, report line and CLI output has to stay exactly the same. The existing tests are the reference; run them with
python3 -m unittest discover -s testsafter each step and keep them green. You may edit the tests only for theCust->Customerrename. - There is no pytest and no network here, only the Python 3 standard library.
- Work through the whole code base (
grepis your friend for finding every place that computes a total, defines a rate or threshold, or parses a date), and remove imports that become unused. - Update
docs/ARCHITECTURE.mdat the end so it matches the new layout.
When you are done, reply with a short summary: which modules you added, what you removed, and the final result of the test run.