Multiply numbers #3
Labels
No labels
aira:blocked
aira:cancelled
aira:ci
aira:done
aira:implementing
aira:merging
aira:plan-review
aira:planning
aira:qa
aira:queued
aira:ready
aira:review
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lab/web-calculator-2#3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add multiplication.
Requirements
op=multiplyreturnsa * b.×button. Pressing6,×,7,=shows42.Acceptance criteria
/api/calculate?a=6&b=7&op=multiplyreturns{"result":42}./api/calculate?a=-2&b=0.5&op=multiplyreturns{"result":-1}.addandsubtractstill work; bad input still returns 400.Aira · queued
Aira picked up this task. Branch
aira/3-multiply-numbers.Aira · planning
Orchestrator thread started (composer-2.5). Planning on
aira/3-multiply-numbers.T3 thread:
mcp:launch:5ee375152f54867ecd089332b783c4607c8d5ff44fba25269555a2ba12c01cb8Aira · Plan (round 1) at
2806a463Wrote docs/plans/issue-3.md (goal, acceptance criteria, design, files, test plan, risks, implementation order), committed, and pushed to aira/3-multiply-numbers.
docs/plans/issue-3.md
Issue #3: Multiply numbers
Goal
Add multiplication end to end: a pure
multiplyfunction inlib/calculator.js,GET /api/calculatesupport forop=multiply, and a×button in the UI that behaves like+and−but invokes multiplication on=. The example flow6,×,7,=must show42. Addition, subtraction, and existing error handling remain unchanged.Acceptance criteria
GET /api/calculate?a=6&b=7&op=multiplyreturns HTTP 200 with body{"result":42}.GET /api/calculate?a=-2&b=0.5&op=multiplyreturns HTTP 200 with body{"result":-1}.op=addandop=subtractstill work (e.g. existing success cases) and an unknownopstill returns HTTP 400 with{"error":"<message>"}; bad input fora/bstill returns 400./has a multiply button and displays products returned by the API (including6×7=→42via the client calling the API withop=multiply).Design
Calculator module (
lib/calculator.js)multiply(a, b)— returnsa * bfor finite numbers (caller supplies parsed numbers).calculate(op, a, b):op === 'multiply'in the allowed-operation check (alongsideaddandsubtract).multiplywhenop === 'multiply'; keep existing branches foraddandsubtract.opstill returns{ error: 'unknown operation' }.multiplyfrommodule.exportsalongside existing exports.parseNumberand non-finite result checks (overflow /Infinityon multiply should mirror add/subtract behaviour).HTTP layer (
server.js)/api/calculatealready delegates tocalculate(op, a, b).UI (
public/index.html)×key (Unicode multiplication sign U+00D7) to the button grid inlabels, consistent with how−was added for subtraction.onKey/pressOperatorso×setspendingOpto'multiply'(samewaitingForSecondflow as+and−).=continues to buildURLSearchParamswithop: pendingOp(already dynamic from issue #2).=, resetpendingOpto'add'(unchanged).labelsorder so the 4-column grid still fits all digits, operators (+,−,×),C,=, and.without removing existing keys.Files to change
lib/calculator.jsmultiply; extendcalculateforop=multiply; exportmultiply.server.jspublic/index.html×) button; wirepressOperator('multiply')on×.test/calculator.test.jsmultiplyandcalculate('multiply', ...).test/server.test.jstest/ui.test.jsmultiplyorpendingOpwiring.Test plan
Unit tests (
test/calculator.test.js)multiply(6, 7) === 42multiply(-2, 0.5) === -1calculate('multiply', '6', '7')→{ result: 42 }calculate('multiply', '-2', '0.5')→{ result: -1 }calculate('add', ...)andcalculate('subtract', ...)still succeedcalculate('pow', ...)still unknown errorHTTP tests (
test/server.test.js)Use existing
withServer+fetchpattern:?a=6&b=7&op=multiply{ result: 42 }?a=-2&b=0.5&op=multiply{ result: -1 }?a=2&b=3&op=add{ result: 5 }(regression)?a=2&b=5&op=subtract{ result: -3 }(regression)?a=1&b=2&op=powerrorstring?a=x&b=2&op=multiplyerrorstring (bad input)UI / page tests (
test/ui.test.js)labels(or equivalent) includes multiply ('×'or documented label)+,−,=,C, andfetchto/api/calculatemultiplyviapressOperator('multiply')or equivalentRun
npm testlocally before every push; all tests must pass.Risks
xvs Unicode×in UI vs APIop=multiply)op=multiply; UI label is display-only; tests assert HTML contains the×label used in code.pendingOpon×+/−handler; test that script referencesmultiply.6 * 7and-2 * 0.5non-finite resultguard incalculate; add unit test if parity with add overflow tests is desired.labelsto keep 4-column grid; verify all prior buttons still present in UI test.calculateonly; run full existing test suite.Implementation order (for later steps)
lib/calculator.js+test/calculator.test.jstest/server.test.js(server unchanged)public/index.htmlUI +test/ui.test.jsnpm test, then push branchaira/3-multiply-numbersAttachment: plan-3-r1.md
Aira · plan review
Plan pushed at
2806a463; independent Dodik plan review started.Aira · dodik-plan PASS on
2806a463The issue #3 plan maps every requirement to a numbered, testable acceptance criterion and matches the current code. Multiplication belongs in lib/calculator.js (new multiply, allow-list and dispatch beside add/subtract, same parseNumber and non-finite checks, export multiply). server.js already forwards /api/calculate to calculate, so no route change is required. The UI already sends pendingOp on = and resets it to add; the plan only adds a × key wired through pressOperator('multiply'), consistent with + and −. Unit tests cover 67 and -20.5 plus calculate dispatch, add/subtract, and unknown op; HTTP tests cover both acceptance responses, add/subtract regression, unknown op, and bad input on multiply; page tests cover the × button and multiply wiring. Existing error handling stays covered by the current suite (34 tests passing). Nothing extra is in scope and nothing required is missing.
Checks performed
Attachment: dodik-plan-2806a463.json
Aira · implementing
Plan approved by Dodik at
2806a463. Implementation started.Aira · ci
Ready for review at
131baca5(PR #11). Waiting for CI.Added multiply to lib/calculator.js, × button and pressOperator wiring in public/index.html, and unit/HTTP/UI tests; npm test 40/40 pass; pushed feat commit to aira/3-multiply-numbers.
Aira · CI passed on
131baca5Aira · review
CI is green on
131baca5. Independent Dodik and code review started.Aira · dodik PASS on
131baca5Commit
131bacaadds multiplication end to end as specified in docs/plans/issue-3.md. The module, API, and page implement op=multiply and a × button; acceptance cases 6×7=42 and -2×0.5=-1 succeed, and add, subtract, and 400 error handling still work. npm test passed 40/40 with no skips, and the diff contains only the planned calculator, UI, test, and plan changes.Checks performed
131baca545with docs/plans/issue-3.mdAttachment: dodik-131baca5.json
Aira · reviewer PASS on
131baca5The branch correctly adds
multiplyinlib/calculator.js, allowsop=multiplythrough the existing/api/calculatepath, and wires a × key in the UI viapressOperator('multiply')using the same two-operand flow as + and −. Acceptance cases (6×7→42, −2×0.5→−1), invalid-input 400s, unknown-op rejection, and add/subtract regression paths behave as specified; large products that overflow to Infinity returnnon-finite resultvia the shared guard. All 40npm testcases pass at HEAD131baca.Checks performed
Attachment: reviewer-131baca5.json
Aira · qa
Dodik and the reviewer passed on
131baca5. Preview deployed at http://127.0.0.1:40469; QA started.Aira · qa PASS on
131baca5Preview commit
131baca545serves a working multiply API and a page whose × button calls op=multiply. Acceptance cases return {"result":42} and {"result":-1}; add, subtract, and invalid input still behave correctly; npm test passed 40/40 including multiply module, API, and page tests.Checks performed
Attachment: qa-131baca5.json
Aira · merging
QA passed on
131baca5. Merging.Aira · Merged PR #11
Merge commit
d9f4ba8452621f19cd2bcb06057cfd6093248d81from reviewed head131baca545d83213b521ca5dd08a50a407b6276e.131bacaadds multiplication end to end as specified in docs/plans/issue-3.md. The module, API, and page implement op=multiply and a × button; acceptancemultiplyinlib/calculator.js, allowsop=multiplythrough the existing/api/calculatepath, and wires a × key in the UI via `p131baca545serves a working multiply API and a page whose × button calls op=multiply. Acceptance cases return {"res