AtrisBench
Back to the leaderboard

GPT-5.6 Sol (Codex) on Rename an API without breaking callers

Passed in 45s. Attempt 2. Run 20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2.

Task

Rename the ledger API safely

Refactor this Node project so lib/ledger.js uses record and list instead of postEntry and getEntries.

Keep postEntry only as the deprecated compatibility shim marked // keep in lib/ledger.js; the shim must delegate to record. Remove getEntries. Update every project call site to the new names. Delete lib/legacy.js and its sole caller, src/legacy-report.js.

Do not add dependencies. The required output is the updated project, with this command green:

node --test test/*.test.js

Command

codex exec --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox -m gpt-5.6-sol -c model_reasoning_effort=high --output-last-message /tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/last-message.txt 'You are working in the current folder. Do the task in TASK.md and write the outputs to the exact paths it names.
Do not ask questions. When done, stop.

# Rename the ledger API safely

Refactor this Node project so `lib/ledger.js` uses `record` and `list` instead of `postEntry`
and `getEntries`.

Keep `postEntry` only as the deprecated compatibility shim marked `// keep` in
`lib/ledger.js`; the shim must delegate to `record`. Remove `getEntries`. Update every project
call site to the new names. Delete `lib/legacy.js` and its sole caller, `src/legacy-report.js`.

Do not add dependencies. The required output is the updated project, with this command green:

` ` `sh
node --test test/*.test.js
` ` `'

Output

Implemented the ledger API rename and removed legacy files.

- Added primary `record` and `list` APIs.
- Kept deprecated `postEntry` shim delegating to `record`.
- Removed `getEntries`.
- Updated all project call sites.
- Deleted `lib/legacy.js` and `src/legacy-report.js`.
- Tests pass: 2/2.


[stderr]
Reading additional input from stdin...
OpenAI Codex v0.153.0
--------
workdir: /private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work
model: gpt-5.6-sol
provider: openai
approval: never
sandbox: danger-full-access
reasoning effort: high
reasoning summaries: none
session id: 01a06c96-9317-76b1-995d-690e5b8d9626
--------
user
You are working in the current folder. Do the task in TASK.md and write the outputs to the exact paths it names.
Do not ask questions. When done, stop.

# Rename the ledger API safely

Refactor this Node project so `lib/ledger.js` uses `record` and `list` instead of `postEntry`
and `getEntries`.

Keep `postEntry` only as the deprecated compatibility shim marked `// keep` in
`lib/ledger.js`; the shim must delegate to `record`. Remove `getEntries`. Update every project
call site to the new names. Delete `lib/legacy.js` and its sole caller, `src/legacy-report.js`.

Do not add dependencies. The required output is the updated project, with this command green:

` ` `sh
node --test test/*.test.js
` ` `
codex
I’m using the Atris build workflow because this is a focused repo refactor. I’ll read the task and repository guidance, then update and verify the project.
exec
/bin/zsh -lc "sed -n '1,240p' /Users/keshavrao/.codex/skills/atris-build/SKILL.md && find .. -name AGENTS.md -print && sed -n '1,240p' TASK.md" in /private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work
 succeeded in 0ms:
---
name: atris-build
description: Build-phase execution policy for repos using the Atris workflow. Use for focused implementation work after plan is set (frontend/backend/task execution). Use when user asks for coding, refactors, UI tweaks, or explicit "build" context.
---

# Atris Build Skill

## Scope
- Use in repos where `atris/` is present.
- Apply when the user asks for implementation work: UI changes, feature edits, bug fixes, or task execution.
- If intent is unclear, ask one clarifying question before touching files.

## Operating rules
- Run only the build work approved by the user.
- Keep edits surgical and minimal.
- Avoid broad refactors unless explicitly requested.
- Do not run tests/validation unless explicitly asked.
- Do not run destructive commands or revert unrelated edits.

## Process
1. Confirm target behavior and acceptance criteria.
2. Map required files from `atris/MAP.md`.
3. Implement in small chunks with no speculative side work.
4. Preserve existing structure/patterns in the touched domain (`frontend`, `backend`, etc.).
5. Report exact file paths changed and why.

## Frontend notes
- Preserve established design direction in existing files.
- Prefer minimal DOM/CSS motion changes over full redesigns.
- Keep mobile-first space conservation in mind before adding new chrome.

## Closure
- Summarize changes and remaining open questions.
- If work is incomplete, capture next explicit step.
# Rename the ledger API safely

Refactor this Node project so `lib/ledger.js` uses `record` and `list` instead of `postEntry`
and `getEntries`.

Keep `postEntry` only as the deprecated compatibility shim marked `// keep` in
`lib/ledger.js`; the shim must delegate to `record`. Remove `getEntries`. Update every project
call site to the new names. Delete `lib/legacy.js` and its sole caller, `src/legacy-report.js`.

Do not add dependencies. The required output is the updated project, with this command green:

` ` `sh
node --test test/*.test.js
` ` `

exec
/bin/zsh -lc "pwd && rg --files -g '"'!node_modules'"' | sort && git status --short && if [ -f atris/MAP.md ]; then sed -n '1,240p' atris/MAP.md; fi" in /private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work
 exited 128 in 0ms:
/private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work
TASK.md
lib/ids.js
lib/ledger.js
lib/legacy.js
lib/validate.js
package.json
src/account-summary.js
src/audit.js
src/cli.js
src/import-invoices.js
src/index.js
src/legacy-report.js
src/month-close.js
src/refund.js
test/ledger.test.js
fatal: not a git repository (or any of the parent directories): .git

codex
The repository is small and has no Atris map or Git metadata, so I’ve mapped it directly. I’m now tracing all ledger imports and calls before making the minimal rename and deletions.
exec
/bin/zsh -lc "sed -n '1,240p' lib/ledger.js && for f in lib/legacy.js src/*.js test/*.test.js package.json; do echo \"### "'$f"; sed -n '"'1,240p' \""'$f"; done && rg -n "postEntry|getEntries|legacy|ledger" . -g '"'"'!TASK.md'"'" in /private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work
 succeeded in 0ms:
import { assertAccount, assertAmount } from "./validate.js";
import { makeId } from "./ids.js";

const entries = [];

// keep: this exported function must become the deprecated postEntry compatibility shim.
export function postEntry(account, amount, memo = "") {
  assertAccount(account);
  assertAmount(amount);
  const entry = { id: makeId(entries.length + 1), account, amount, memo };
  entries.push(entry);
  return { ...entry };
}

export function getEntries(account) {
  return entries.filter((entry) => entry.account === account).map((entry) => ({ ...entry }));
}

export function resetForTests() {
  entries.length = 0;
}
### lib/legacy.js
export function legacyBalance(rows) {
  return rows.reduce((total, row) => total + row.amount, 0);
}
### src/account-summary.js
import { getEntries } from "../lib/ledger.js";

export function accountSummary(account) {
  const rows = getEntries(account);
  return { account, count: rows.length, total: rows.reduce((sum, row) => sum + row.amount, 0) };
}
### src/audit.js
import { getEntries } from "../lib/ledger.js";

export function auditAccount(account) {
  return getEntries(account).map(({ id, memo }) => `${id}:${memo}`);
}
### src/cli.js
import { getEntries, postEntry } from "../lib/ledger.js";

export function runCommand(name, account, amount) {
  if (name === "record") return postEntry(account, amount, "cli");
  if (name === "list") return getEntries(account);
  throw new Error(`unknown command: ${name}`);
}
### src/import-invoices.js
import { postEntry } from "../lib/ledger.js";

export function importInvoices(invoices) {
  return invoices.map((invoice) => postEntry("receivable", invoice.total, invoice.id));
}
### src/index.js
export { accountSummary } from "./account-summary.js";
export { auditAccount } from "./audit.js";
export { importInvoices } from "./import-invoices.js";
export { monthClose } from "./month-close.js";
export { refund } from "./refund.js";
### src/legacy-report.js
import { getEntries } from "../lib/ledger.js";
import { legacyBalance } from "../lib/legacy.js";

export function legacyReport(account) {
  return legacyBalance(getEntries(account));
}
### src/month-close.js
import { getEntries } from "../lib/ledger.js";

export function monthClose(account) {
  const total = getEntries(account).reduce((sum, entry) => sum + entry.amount, 0);
  return Object.freeze({ account, total });
}
### src/refund.js
import { postEntry } from "../lib/ledger.js";

export function refund(amount, reference) {
  return postEntry("refunds", -amount, reference);
}
### test/ledger.test.js
import test from "node:test";
import assert from "node:assert/strict";

import { list, record, resetForTests } from "../lib/ledger.js";
import { accountSummary } from "../src/account-summary.js";

test.beforeEach(() => resetForTests());

test("record and list are the primary API", () => {
  const saved = record("cash", 42, "opening");
  assert.equal(saved.id, "entry-0001");
  assert.deepEqual(list("cash"), [saved]);
});

test("services use the renamed API", () => {
  record("cash", 30);
  record("cash", -5);
  assert.deepEqual(accountSummary("cash"), { account: "cash", count: 2, total: 25 });
});
### package.json
{
  "name": "ledger-api-refactor",
  "private": true,
  "type": "module",
  "scripts": {"test": "node --test test/"}
}
./src/import-invoices.js:1:import { postEntry } from "../lib/ledger.js";
./src/import-invoices.js:4:  return invoices.map((invoice) => postEntry("receivable", invoice.total, invoice.id));
./src/cli.js:1:import { getEntries, postEntry } from "../lib/ledger.js";
./src/cli.js:4:  if (name === "record") return postEntry(account, amount, "cli");
./src/cli.js:5:  if (name === "list") return getEntries(account);
./src/refund.js:1:import { postEntry } from "../lib/ledger.js";
./src/refund.js:4:  return postEntry("refunds", -amount, reference);
./src/account-summary.js:1:import { getEntries } from "../lib/ledger.js";
./src/account-summary.js:4:  const rows = getEntries(account);
./src/audit.js:1:import { getEntries } from "../lib/ledger.js";
./src/audit.js:4:  return getEntries(account).map(({ id, memo }) => `${id}:${memo}`);
./src/month-close.js:1:import { getEntries } from "../lib/ledger.js";
./src/month-close.js:4:  const total = getEntries(account).reduce((sum, entry) => sum + entry.amount, 0);
./src/legacy-report.js:1:import { getEntries } from "../lib/ledger.js";
./src/legacy-report.js:2:import { legacyBalance } from "../lib/legacy.js";
./src/legacy-report.js:4:export function legacyReport(account) {
./src/legacy-report.js:5:  return legacyBalance(getEntries(account));
./lib/legacy.js:1:export function legacyBalance(rows) {
./lib/ledger.js:6:// keep: this exported function must become the deprecated postEntry compatibility shim.
./lib/ledger.js:7:export function postEntry(account, amount, memo = "") {
./lib/ledger.js:15:export function getEntries(account) {
./package.json:2:  "name": "ledger-api-refactor",
./test/ledger.test.js:4:import { list, record, resetForTests } from "../lib/ledger.js";

apply patch
patch: completed
/private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work/lib/ledger.js
/private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work/lib/legacy.js
/private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work/src/account-summary.js
/private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work/src/audit.js
/private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work/src/cli.js
/private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work/src/import-invoices.js
/private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work/src/legacy-report.js
/private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work/src/month-close.js
/private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work/src/refund.js
diff --git a/lib/ledger.js b/lib/ledger.js
index f1ed99716f48e437e334d8c95a79bca28134546d..4772eaf469fc746ced1cf1bc1bffcf07f308b54d
--- a/lib/ledger.js
+++ b/lib/ledger.js
@@ -3,8 +3,7 @@
 
 const entries = [];
 
-// keep: this exported function must become the deprecated postEntry compatibility shim.
-export function postEntry(account, amount, memo = "") {
+export function record(account, amount, memo = "") {
   assertAccount(account);
   assertAmount(amount);
   const entry = { id: makeId(entries.length + 1), account, amount, memo };
@@ -12,7 +11,12 @@
   return { ...entry };
 }
 
-export function getEntries(account) {
+// keep: deprecated compatibility shim.
+export function postEntry(account, amount, memo = "") {
+  return record(account, amount, memo);
+}
+
+export function list(account) {
   return entries.filter((entry) => entry.account === account).map((entry) => ({ ...entry }));
 }
 
diff --git a/lib/legacy.js b/lib/legacy.js
deleted file mode 100644
index 515ea1b8959b87d6a8b9e014f5cf796999691d72..0000000000000000000000000000000000000000
--- a/lib/legacy.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export function legacyBalance(rows) {
-  return rows.reduce((total, row) => total + row.amount, 0);
-}
diff --git a/src/account-summary.js b/src/account-summary.js
index 23c31f40cac78c34dc760658335c2b86ebd38429..08a7a3013f3800f220e0496871ab3e858524f550
--- a/src/account-summary.js
+++ b/src/account-summary.js
@@ -1,6 +1,6 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function accountSummary(account) {
-  const rows = getEntries(account);
+  const rows = list(account);
   return { account, count: rows.length, total: rows.reduce((sum, row) => sum + row.amount, 0) };
 }
diff --git a/src/audit.js b/src/audit.js
index 72ce3377db7a3f726b29a01b115db40ae9350e78..8b63d5b69d8c9bd921ca18d030b54cdeee1ac426
--- a/src/audit.js
+++ b/src/audit.js
@@ -1,5 +1,5 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function auditAccount(account) {
-  return getEntries(account).map(({ id, memo }) => `${id}:${memo}`);
+  return list(account).map(({ id, memo }) => `${id}:${memo}`);
 }
diff --git a/src/cli.js b/src/cli.js
index 2485d863c82760b0863d33368825de6506e712cb..6c705eddf85e9e472d4779f56ca96c60959ab56a
--- a/src/cli.js
+++ b/src/cli.js
@@ -1,7 +1,7 @@
-import { getEntries, postEntry } from "../lib/ledger.js";
+import { list, record } from "../lib/ledger.js";
 
 export function runCommand(name, account, amount) {
-  if (name === "record") return postEntry(account, amount, "cli");
-  if (name === "list") return getEntries(account);
+  if (name === "record") return record(account, amount, "cli");
+  if (name === "list") return list(account);
   throw new Error(`unknown command: ${name}`);
 }
diff --git a/src/import-invoices.js b/src/import-invoices.js
index 64b5f6a5a1c8519051edd9395783a162b3179d77..0021038f29e97b75442fe3fa62fd30e888be480c
--- a/src/import-invoices.js
+++ b/src/import-invoices.js
@@ -1,5 +1,5 @@
-import { postEntry } from "../lib/ledger.js";
+import { record } from "../lib/ledger.js";
 
 export function importInvoices(invoices) {
-  return invoices.map((invoice) => postEntry("receivable", invoice.total, invoice.id));
+  return invoices.map((invoice) => record("receivable", invoice.total, invoice.id));
 }
diff --git a/src/legacy-report.js b/src/legacy-report.js
deleted file mode 100644
index 419f932c7acde30fe7798d62a3acb94c6cb26c16..0000000000000000000000000000000000000000
--- a/src/legacy-report.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import { getEntries } from "../lib/ledger.js";
-import { legacyBalance } from "../lib/legacy.js";
-
-export function legacyReport(account) {
-  return legacyBalance(getEntries(account));
-}
diff --git a/src/month-close.js b/src/month-close.js
index a822ba300cf0d8b7067c73b24b3e2ab08ff3a86a..f4adb7b513b7cefa0a6d49dd26bd35abb494bf8c
--- a/src/month-close.js
+++ b/src/month-close.js
@@ -1,6 +1,6 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function monthClose(account) {
-  const total = getEntries(account).reduce((sum, entry) => sum + entry.amount, 0);
+  const total = list(account).reduce((sum, entry) => sum + entry.amount, 0);
   return Object.freeze({ account, total });
 }
diff --git a/src/refund.js b/src/refund.js
index 2c378a52d83dbafd344815186b8ad65c048455cf..34a7637f505f4cc1fb05afca05e7d58397b77c0c
--- a/src/refund.js
+++ b/src/refund.js
@@ -1,5 +1,5 @@
-import { postEntry } from "../lib/ledger.js";
+import { record } from "../lib/ledger.js";
 
 export function refund(amount, reference) {
-  return postEntry("refunds", -amount, reference);
+  return record("refunds", -amount, reference);
 }

diff --git a/lib/ledger.js b/lib/ledger.js
index f1ed99716f48e437e334d8c95a79bca28134546d..4772eaf469fc746ced1cf1bc1bffcf07f308b54d
--- a/lib/ledger.js
+++ b/lib/ledger.js
@@ -3,8 +3,7 @@
 
 const entries = [];
 
-// keep: this exported function must become the deprecated postEntry compatibility shim.
-export function postEntry(account, amount, memo = "") {
+export function record(account, amount, memo = "") {
   assertAccount(account);
   assertAmount(amount);
   const entry = { id: makeId(entries.length + 1), account, amount, memo };
@@ -12,7 +11,12 @@
   return { ...entry };
 }
 
-export function getEntries(account) {
+// keep: deprecated compatibility shim.
+export function postEntry(account, amount, memo = "") {
+  return record(account, amount, memo);
+}
+
+export function list(account) {
   return entries.filter((entry) => entry.account === account).map((entry) => ({ ...entry }));
 }
 
diff --git a/lib/legacy.js b/lib/legacy.js
deleted file mode 100644
index 515ea1b8959b87d6a8b9e014f5cf796999691d72..0000000000000000000000000000000000000000
--- a/lib/legacy.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export function legacyBalance(rows) {
-  return rows.reduce((total, row) => total + row.amount, 0);
-}
diff --git a/src/account-summary.js b/src/account-summary.js
index 23c31f40cac78c34dc760658335c2b86ebd38429..08a7a3013f3800f220e0496871ab3e858524f550
--- a/src/account-summary.js
+++ b/src/account-summary.js
@@ -1,6 +1,6 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function accountSummary(account) {
-  const rows = getEntries(account);
+  const rows = list(account);
   return { account, count: rows.length, total: rows.reduce((sum, row) => sum + row.amount, 0) };
 }
diff --git a/src/audit.js b/src/audit.js
index 72ce3377db7a3f726b29a01b115db40ae9350e78..8b63d5b69d8c9bd921ca18d030b54cdeee1ac426
--- a/src/audit.js
+++ b/src/audit.js
@@ -1,5 +1,5 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function auditAccount(account) {
-  return getEntries(account).map(({ id, memo }) => `${id}:${memo}`);
+  return list(account).map(({ id, memo }) => `${id}:${memo}`);
 }
diff --git a/src/cli.js b/src/cli.js
index 2485d863c82760b0863d33368825de6506e712cb..6c705eddf85e9e472d4779f56ca96c60959ab56a
--- a/src/cli.js
+++ b/src/cli.js
@@ -1,7 +1,7 @@
-import { getEntries, postEntry } from "../lib/ledger.js";
+import { list, record } from "../lib/ledger.js";
 
 export function runCommand(name, account, amount) {
-  if (name === "record") return postEntry(account, amount, "cli");
-  if (name === "list") return getEntries(account);
+  if (name === "record") return record(account, amount, "cli");
+  if (name === "list") return list(account);
   throw new Error(`unknown command: ${name}`);
 }
diff --git a/src/import-invoices.js b/src/import-invoices.js
index 64b5f6a5a1c8519051edd9395783a162b3179d77..0021038f29e97b75442fe3fa62fd30e888be480c
--- a/src/import-invoices.js
+++ b/src/import-invoices.js
@@ -1,5 +1,5 @@
-import { postEntry } from "../lib/ledger.js";
+import { record } from "../lib/ledger.js";
 
 export function importInvoices(invoices) {
-  return invoices.map((invoice) => postEntry("receivable", invoice.total, invoice.id));
+  return invoices.map((invoice) => record("receivable", invoice.total, invoice.id));
 }
diff --git a/src/legacy-report.js b/src/legacy-report.js
deleted file mode 100644
index 419f932c7acde30fe7798d62a3acb94c6cb26c16..0000000000000000000000000000000000000000
--- a/src/legacy-report.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import { getEntries } from "../lib/ledger.js";
-import { legacyBalance } from "../lib/legacy.js";
-
-export function legacyReport(account) {
-  return legacyBalance(getEntries(account));
-}
diff --git a/src/month-close.js b/src/month-close.js
index a822ba300cf0d8b7067c73b24b3e2ab08ff3a86a..f4adb7b513b7cefa0a6d49dd26bd35abb494bf8c
--- a/src/month-close.js
+++ b/src/month-close.js
@@ -1,6 +1,6 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function monthClose(account) {
-  const total = getEntries(account).reduce((sum, entry) => sum + entry.amount, 0);
+  const total = list(account).reduce((sum, entry) => sum + entry.amount, 0);
   return Object.freeze({ account, total });
 }
diff --git a/src/refund.js b/src/refund.js
index 2c378a52d83dbafd344815186b8ad65c048455cf..34a7637f505f4cc1fb05afca05e7d58397b77c0c
--- a/src/refund.js
+++ b/src/refund.js
@@ -1,5 +1,5 @@
-import { postEntry } from "../lib/ledger.js";
+import { record } from "../lib/ledger.js";
 
 export function refund(amount, reference) {
-  return postEntry("refunds", -amount, reference);
+  return record("refunds", -amount, reference);
 }

codex
The API migration is applied: all active code now uses `record`/`list`, while `postEntry` remains only as the delegating compatibility shim. The two legacy files are removed; I’m checking for stale references and running the required test command now.
exec
/bin/zsh -lc "rg -n \"postEntry|getEntries|legacyBalance|legacyReport\" . -g '"'!TASK.md'"' || true
node --test test/*.test.js
node --input-type=module -e 'import { postEntry, list, resetForTests } from \"./lib/ledger.js\"; resetForTests(); const saved = postEntry(\"cash\", 7, \"compat\"); if (list(\"cash\")[0].id "'!== saved.id) throw new Error("compatibility shim failed")'"'
rg --files -g '"'!node_modules'"' | sort" in /private/tmp/atris-bench/20260904T132322Z-gpt-5-6-sol-refactor-rename-api-2/work
 succeeded in 70ms:
ℹ tests 2
ℹ suites 0
ℹ pass 2
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 67.720125
TASK.md
lib/ids.js
lib/ledger.js
lib/validate.js
package.json
src/account-summary.js
src/audit.js
src/cli.js
src/import-invoices.js
src/index.js
src/month-close.js
src/refund.js
test/ledger.test.js

diff --git a/lib/ledger.js b/lib/ledger.js
index f1ed99716f48e437e334d8c95a79bca28134546d..4772eaf469fc746ced1cf1bc1bffcf07f308b54d
--- a/lib/ledger.js
+++ b/lib/ledger.js
@@ -3,8 +3,7 @@
 
 const entries = [];
 
-// keep: this exported function must become the deprecated postEntry compatibility shim.
-export function postEntry(account, amount, memo = "") {
+export function record(account, amount, memo = "") {
   assertAccount(account);
   assertAmount(amount);
   const entry = { id: makeId(entries.length + 1), account, amount, memo };
@@ -12,7 +11,12 @@
   return { ...entry };
 }
 
-export function getEntries(account) {
+// keep: deprecated compatibility shim.
+export function postEntry(account, amount, memo = "") {
+  return record(account, amount, memo);
+}
+
+export function list(account) {
   return entries.filter((entry) => entry.account === account).map((entry) => ({ ...entry }));
 }
 
diff --git a/lib/legacy.js b/lib/legacy.js
deleted file mode 100644
index 515ea1b8959b87d6a8b9e014f5cf796999691d72..0000000000000000000000000000000000000000
--- a/lib/legacy.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export function legacyBalance(rows) {
-  return rows.reduce((total, row) => total + row.amount, 0);
-}
diff --git a/src/account-summary.js b/src/account-summary.js
index 23c31f40cac78c34dc760658335c2b86ebd38429..08a7a3013f3800f220e0496871ab3e858524f550
--- a/src/account-summary.js
+++ b/src/account-summary.js
@@ -1,6 +1,6 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function accountSummary(account) {
-  const rows = getEntries(account);
+  const rows = list(account);
   return { account, count: rows.length, total: rows.reduce((sum, row) => sum + row.amount, 0) };
 }
diff --git a/src/audit.js b/src/audit.js
index 72ce3377db7a3f726b29a01b115db40ae9350e78..8b63d5b69d8c9bd921ca18d030b54cdeee1ac426
--- a/src/audit.js
+++ b/src/audit.js
@@ -1,5 +1,5 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function auditAccount(account) {
-  return getEntries(account).map(({ id, memo }) => `${id}:${memo}`);
+  return list(account).map(({ id, memo }) => `${id}:${memo}`);
 }
diff --git a/src/cli.js b/src/cli.js
index 2485d863c82760b0863d33368825de6506e712cb..6c705eddf85e9e472d4779f56ca96c60959ab56a
--- a/src/cli.js
+++ b/src/cli.js
@@ -1,7 +1,7 @@
-import { getEntries, postEntry } from "../lib/ledger.js";
+import { list, record } from "../lib/ledger.js";
 
 export function runCommand(name, account, amount) {
-  if (name === "record") return postEntry(account, amount, "cli");
-  if (name === "list") return getEntries(account);
+  if (name === "record") return record(account, amount, "cli");
+  if (name === "list") return list(account);
   throw new Error(`unknown command: ${name}`);
 }
diff --git a/src/import-invoices.js b/src/import-invoices.js
index 64b5f6a5a1c8519051edd9395783a162b3179d77..0021038f29e97b75442fe3fa62fd30e888be480c
--- a/src/import-invoices.js
+++ b/src/import-invoices.js
@@ -1,5 +1,5 @@
-import { postEntry } from "../lib/ledger.js";
+import { record } from "../lib/ledger.js";
 
 export function importInvoices(invoices) {
-  return invoices.map((invoice) => postEntry("receivable", invoice.total, invoice.id));
+  return invoices.map((invoice) => record("receivable", invoice.total, invoice.id));
 }
diff --git a/src/legacy-report.js b/src/legacy-report.js
deleted file mode 100644
index 419f932c7acde30fe7798d62a3acb94c6cb26c16..0000000000000000000000000000000000000000
--- a/src/legacy-report.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import { getEntries } from "../lib/ledger.js";
-import { legacyBalance } from "../lib/legacy.js";
-
-export function legacyReport(account) {
-  return legacyBalance(getEntries(account));
-}
diff --git a/src/month-close.js b/src/month-close.js
index a822ba300cf0d8b7067c73b24b3e2ab08ff3a86a..f4adb7b513b7cefa0a6d49dd26bd35abb494bf8c
--- a/src/month-close.js
+++ b/src/month-close.js
@@ -1,6 +1,6 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function monthClose(account) {
-  const total = getEntries(account).reduce((sum, entry) => sum + entry.amount, 0);
+  const total = list(account).reduce((sum, entry) => sum + entry.amount, 0);
   return Object.freeze({ account, total });
 }
diff --git a/src/refund.js b/src/refund.js
index 2c378a52d83dbafd344815186b8ad65c048455cf..34a7637f505f4cc1fb05afca05e7d58397b77c0c
--- a/src/refund.js
+++ b/src/refund.js
@@ -1,5 +1,5 @@
-import { postEntry } from "../lib/ledger.js";
+import { record } from "../lib/ledger.js";
 
 export function refund(amount, reference) {
-  return postEntry("refunds", -amount, reference);
+  return record("refunds", -amount, reference);
 }

codex
Implemented the ledger API rename and removed legacy files.

- Added primary `record` and `list` APIs.
- Kept deprecated `postEntry` shim delegating to `record`.
- Removed `getEntries`.
- Updated all project call sites.
- Deleted `lib/legacy.js` and `src/legacy-report.js`.
- Tests pass: 2/2.
diff --git a/lib/ledger.js b/lib/ledger.js
index f1ed99716f48e437e334d8c95a79bca28134546d..4772eaf469fc746ced1cf1bc1bffcf07f308b54d
--- a/lib/ledger.js
+++ b/lib/ledger.js
@@ -3,8 +3,7 @@
 
 const entries = [];
 
-// keep: this exported function must become the deprecated postEntry compatibility shim.
-export function postEntry(account, amount, memo = "") {
+export function record(account, amount, memo = "") {
   assertAccount(account);
   assertAmount(amount);
   const entry = { id: makeId(entries.length + 1), account, amount, memo };
@@ -12,7 +11,12 @@
   return { ...entry };
 }
 
-export function getEntries(account) {
+// keep: deprecated compatibility shim.
+export function postEntry(account, amount, memo = "") {
+  return record(account, amount, memo);
+}
+
+export function list(account) {
   return entries.filter((entry) => entry.account === account).map((entry) => ({ ...entry }));
 }
 
diff --git a/lib/legacy.js b/lib/legacy.js
deleted file mode 100644
index 515ea1b8959b87d6a8b9e014f5cf796999691d72..0000000000000000000000000000000000000000
--- a/lib/legacy.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export function legacyBalance(rows) {
-  return rows.reduce((total, row) => total + row.amount, 0);
-}
diff --git a/src/account-summary.js b/src/account-summary.js
index 23c31f40cac78c34dc760658335c2b86ebd38429..08a7a3013f3800f220e0496871ab3e858524f550
--- a/src/account-summary.js
+++ b/src/account-summary.js
@@ -1,6 +1,6 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function accountSummary(account) {
-  const rows = getEntries(account);
+  const rows = list(account);
   return { account, count: rows.length, total: rows.reduce((sum, row) => sum + row.amount, 0) };
 }
diff --git a/src/audit.js b/src/audit.js
index 72ce3377db7a3f726b29a01b115db40ae9350e78..8b63d5b69d8c9bd921ca18d030b54cdeee1ac426
--- a/src/audit.js
+++ b/src/audit.js
@@ -1,5 +1,5 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function auditAccount(account) {
-  return getEntries(account).map(({ id, memo }) => `${id}:${memo}`);
+  return list(account).map(({ id, memo }) => `${id}:${memo}`);
 }
diff --git a/src/cli.js b/src/cli.js
index 2485d863c82760b0863d33368825de6506e712cb..6c705eddf85e9e472d4779f56ca96c60959ab56a
--- a/src/cli.js
+++ b/src/cli.js
@@ -1,7 +1,7 @@
-import { getEntries, postEntry } from "../lib/ledger.js";
+import { list, record } from "../lib/ledger.js";
 
 export function runCommand(name, account, amount) {
-  if (name === "record") return postEntry(account, amount, "cli");
-  if (name === "list") return getEntries(account);
+  if (name === "record") return record(account, amount, "cli");
+  if (name === "list") return list(account);
   throw new Error(`unknown command: ${name}`);
 }
diff --git a/src/import-invoices.js b/src/import-invoices.js
index 64b5f6a5a1c8519051edd9395783a162b3179d77..0021038f29e97b75442fe3fa62fd30e888be480c
--- a/src/import-invoices.js
+++ b/src/import-invoices.js
@@ -1,5 +1,5 @@
-import { postEntry } from "../lib/ledger.js";
+import { record } from "../lib/ledger.js";
 
 export function importInvoices(invoices) {
-  return invoices.map((invoice) => postEntry("receivable", invoice.total, invoice.id));
+  return invoices.map((invoice) => record("receivable", invoice.total, invoice.id));
 }
diff --git a/src/legacy-report.js b/src/legacy-report.js
deleted file mode 100644
index 419f932c7acde30fe7798d62a3acb94c6cb26c16..0000000000000000000000000000000000000000
--- a/src/legacy-report.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import { getEntries } from "../lib/ledger.js";
-import { legacyBalance } from "../lib/legacy.js";
-
-export function legacyReport(account) {
-  return legacyBalance(getEntries(account));
-}
diff --git a/src/month-close.js b/src/month-close.js
index a822ba300cf0d8b7067c73b24b3e2ab08ff3a86a..f4adb7b513b7cefa0a6d49dd26bd35abb494bf8c
--- a/src/month-close.js
+++ b/src/month-close.js
@@ -1,6 +1,6 @@
-import { getEntries } from "../lib/ledger.js";
+import { list } from "../lib/ledger.js";
 
 export function monthClose(account) {
-  const total = getEntries(account).reduce((sum, entry) => sum + entry.amount, 0);
+  const total = list(account).reduce((sum, entry) => sum + entry.amount, 0);
   return Object.freeze({ account, total });
 }
diff --git a/src/refund.js b/src/refund.js
index 2c378a52d83dbafd344815186b8ad65c048455cf..34a7637f505f4cc1fb05afca05e7d58397b77c0c
--- a/src/refund.js
+++ b/src/refund.js
@@ -1,5 +1,5 @@
-import { postEntry } from "../lib/ledger.js";
+import { record } from "../lib/ledger.js";
 
 export function refund(amount, reference) {
-  return postEntry("refunds", -amount, reference);
+  return record("refunds", -amount, reference);
 }

tokens used
15,832


[final message]
Implemented the ledger API rename and removed legacy files.

- Added primary `record` and `list` APIs.
- Kept deprecated `postEntry` shim delegating to `record`.
- Removed `getEntries`.
- Updated all project call sites.
- Deleted `lib/legacy.js` and `src/legacy-report.js`.
- Tests pass: 2/2.

Files produced

lib/ledger.js

import { assertAccount, assertAmount } from "./validate.js";
import { makeId } from "./ids.js";

const entries = [];

export function record(account, amount, memo = "") {
  assertAccount(account);
  assertAmount(amount);
  const entry = { id: makeId(entries.length + 1), account, amount, memo };
  entries.push(entry);
  return { ...entry };
}

// keep: deprecated compatibility shim.
export function postEntry(account, amount, memo = "") {
  return record(account, amount, memo);
}

export function list(account) {
  return entries.filter((entry) => entry.account === account).map((entry) => ({ ...entry }));
}

export function resetForTests() {
  entries.length = 0;
}

lib/legacy.js

[deleted]

src/account-summary.js

import { list } from "../lib/ledger.js";

export function accountSummary(account) {
  const rows = list(account);
  return { account, count: rows.length, total: rows.reduce((sum, row) => sum + row.amount, 0) };
}

src/audit.js

import { list } from "../lib/ledger.js";

export function auditAccount(account) {
  return list(account).map(({ id, memo }) => `${id}:${memo}`);
}

src/cli.js

import { list, record } from "../lib/ledger.js";

export function runCommand(name, account, amount) {
  if (name === "record") return record(account, amount, "cli");
  if (name === "list") return list(account);
  throw new Error(`unknown command: ${name}`);
}

src/import-invoices.js

import { record } from "../lib/ledger.js";

export function importInvoices(invoices) {
  return invoices.map((invoice) => record("receivable", invoice.total, invoice.id));
}

src/legacy-report.js

[deleted]

src/month-close.js

import { list } from "../lib/ledger.js";

export function monthClose(account) {
  const total = list(account).reduce((sum, entry) => sum + entry.amount, 0);
  return Object.freeze({ account, total });
}

src/refund.js

import { record } from "../lib/ledger.js";

export function refund(amount, reference) {
  return record("refunds", -amount, reference);
}

Checker

{"passed": true, "score": 1.0, "notes": "all refactor checks passed; node: \u2139 duration_ms 84.59275"}

Judge

Not used for this task.