Skip to content

Splitting $10.00 three ways loses a cent (#52) - #58

Closed
Param-Harrison wants to merge 3 commits into
mainfrom
factory/issue-52
Closed

Param-Harrison wants to merge 3 commits into
mainfrom
factory/issue-52

Conversation

@Param-Harrison

Copy link
Copy Markdown
Contributor

Closes #52

Summary

splitCents now gives the leftover cents to the first members, following the handling-money remainder rule, so shares always add up to the total. For example, 1000 split three ways is now 334/333/333, not 333/333/333. Only src/money/cents.ts and tests/money.test.ts changed.

Acceptance criteria

AC Evidence (command / test) Result
AC-1: splitCents(1000, ["a","b","c"]) → {a:334, b:333, c:333} bun test tests/money.test.ts -t "gives the remainder cents to the first members" pass: 1 pass, 0 fail
AC-2: uneven splits sum exactly to the total, with the +1 shares going to the first members bun test tests/money.test.ts -t "shares always sum to the total" (1000/3, 101/5, 1/3, 2/3, 999/7, 1003/4) pass: 1 pass, 0 fail
AC-3: existing splitCents tests unchanged and passing bun test tests/money.test.ts; git diff --numstat on the test file shows 30 insertions, 0 deletions pass: 9 pass, 0 fail
AC-4: the handling-money sum check is all ok bun run .claude/skills/handling-money/scripts/check-cents.ts pass: all 4 cases [ok ]
AC-5: full gate green make check pass: tsc clean, 29 pass, 0 fail, 9 skills valid

Non-goals respected

  • NG-1 (only src/money/cents.ts and tests/money.test.ts change): git diff --name-only 934ab00 HEAD lists just those two files.
  • NG-2 (no signature or other function changes): the splitCents signature and return type are unchanged. formatCents, parseCents and sumCents are byte-identical.
  • NG-3 (no floats): only Math.floor and integer arithmetic are used.
  • NG-4 (no migration or backfill): none added. Existing stored shares are left as they are.
  • NG-5 (no new validation for negative or non-integer totals): the remainder is forced to 0 for these, so they floor exactly as before. The new test leaves negative and non-integer totals floored as before covers this.

The test that bites

  • Test: tests/money.test.ts › splitCents › gives the remainder cents to the first members (also shares always sum to the total)
  • Fails on main: with the pre-fix src/money/cents.ts (git checkout 934ab00 -- src/money/cents.ts), bun test tests/money.test.ts fails with Expected: {a:334,...} Received: {a:333,...} and Expected: 1000, Received: 999
  • Passes here: bun test tests/money.test.ts -t "gives the remainder cents to the first members" → 1 pass, 0 fail

Gate line

FACTORY_GATES: status=GREEN passed=3 failed=0 skipped=1 failed_gates=audit

The optional audit gate fails on hono advisories that were already there before this change. They are out of scope for this issue.

Protected paths touched

none

Reviewer findings addressed

  • The reviewer saw a staged revert of src/money/cents.ts in the working tree. This was transient: the verifier was running at the same time and its revert-and-restore step staged the old file on purpose, then restored it. After both finished, git status --short was empty, bun test tests/money.test.ts gave 9 pass and 0 fail, and make check was green. The committed diff was not affected. There were no other findings. Full details are in the verdict comment on Splitting $10.00 three ways loses a cent #52.

Human checklist

  • AC table has real evidence, not placeholders
  • Non-goals respected
  • Gate line is GREEN
  • Protected paths are "none", or the change to them is expected and reviewed
  • I ran the test that bites myself

🤖 Generated with Claude Code

@Param-Harrison
Param-Harrison marked this pull request as ready for review September 24, 2026 07:43
@Param-Harrison
Param-Harrison deleted the factory/issue-52 branch September 24, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Splitting $10.00 three ways loses a cent

1 participant