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#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:61d3cc7501cb150bbb00a0a929db78e3b1c69a9630533db41937d668607393b1Aira · Plan (round 1) at
e238db58Added docs/plans/issue-3.md (goal, AC, design, files, test plan, risks), committed and pushed to aira/3-multiply-numbers after green npm test.
docs/plans/issue-3.md
Issue #3: Multiply numbers
Goal
Add multiplication alongside addition and subtraction: a pure
multiplyfunction in the library,op=multiplyonGET /api/calculate, and a×(multiplication sign) button on the calculator UI that follows the same operand / equals flow as+and−. Preserve existing add and subtract behaviour, error handling,/health, and/static serving.Acceptance criteria
/api/calculate?a=6&b=7&op=multiplyreturns{"result":42}./api/calculate?a=-2&b=0.5&op=multiplyreturns{"result":-1}.op=addandop=subtractstill work; invalid operands and unknownopstill return HTTP 400 with{"error": "<message>"}.×) button and shows products returned by the API (example flow:6,×,7,=displays42).Design
Calculation module (
lib/calculator.js)multiply(a, b)— pure numeric multiplication (a * b); same IEEE double semantics asaddandsubtract.calculate(rawA, rawB, op):op === 'add',op === 'subtract'(existing), andop === 'multiply'.opwithCalculatorError('Unknown operation')(unchanged message contract).multiplyalongside existing exports.parseOperandand finite-result check for multiply results (including overflow edge cases analogous to add/subtract).HTTP layer (
server.js)/api/calculatealready delegates tocalculate(). Multiplication is picked up automatically once the module supportsop=multiply.400 {"error": ...}viaCalculatorError.UI (
public/index.html)×button on the keypad (Unicode multiplication sign U+00D7), placed on the keypad grid alongside+and−(adjust grid layout if needed).pendingOppattern from issue #2):×: callcommitOperand('multiply')and commit first operand the same way as+/−.=:fetch('/api/calculate?...')withopequal topendingOp(add,subtract, ormultiply).resulton success; show error text on 400 as today.6→×→7→=→ display42.Test layout
test/calculator.test.jsmultiply,calculatewithop=multiply, regressions foradd,subtract, and unknownop.test/server.test.jstest/ui.test.jsdata-keyfor×) and that client script passesmultiplyvia/api/calculate.Files to change
lib/calculator.jsmultiply, extendcalculatedispatch.server.jspublic/index.html×button,commitOperand('multiply')in click handler.test/calculator.test.jstest/server.test.jstest/ui.test.jsmultiplyop in page script.docs/plans/issue-3.mdNo changes to
package.json, CI workflows, or dependencies (Node built-ins only).Test plan
Unit (
test/calculator.test.js)multiply(6, 7) === 42;calculate('6', '7', 'multiply') === 42.multiply(-2, 0.5) === -1;calculate('-2', '0.5', 'multiply') === -1.calculate(..., 'add')andcalculate(..., 'subtract')tests unchanged; unknownopstill throwsCalculatorError.multiplymirror add/subtract; non-finite result (e.g. extreme magnitudes) throwsCalculatorError('Result out of range').HTTP (
test/server.test.js)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 }(existing)a=2&b=5&op=subtract{ result: -3 }(existing)a=x&b=2&op=add{ error: string }(existing)a=1&b=2&op=pow{ error: string }(existing)Re-run all existing health, index, 404, and add/subtract error tests unchanged.
UI / page (
test/ui.test.js)×; HTML includesdata-key="×"./api/calculate, includescommitOperand('multiply'), and usesop: pendingOpfor evaluate.Optional manual check: keypad
6,×,7,=shows42when the server is running.Pre-push
npm testlocally; all tests green beforegit push origin aira/3-multiply-numbers.Risks
×(U+00D7) with ASCIIxor*indata-key/ click handlingdata-keyand JSelse if; UI test matches×.multiplyincalculatedispatchcommitOperand('multiply'); API query already usespendingOp.×breaks digit/+/−/=layout; keep touch targets usable.resultas returned (String(body.result))./healthor/Attachment: plan-3-r1.md
Aira · plan review
Plan pushed at
e238db58; independent Dodik plan review started.Aira · dodik-plan PASS on
e238db58The issue #3 plan maps every multiplication requirement to a numbered acceptance criterion, and the design matches the current calculator: multiply joins the existing calculate dispatch, the HTTP layer already delegates to it, and the page already commits an operator and sends pendingOp. The test plan covers 67 and -20.5 at unit and HTTP level, keeps add, subtract, and 400 error coverage, and checks the × button and multiply wiring on the page, with no out-of-scope work.
Checks performed
Attachment: dodik-plan-e238db58.json
Aira · implementing
Plan approved by Dodik at
e238db58. Implementation started.Aira · ci
Ready for review at
ce54593e(PR #7). Waiting for CI.Implemented multiply in lib/calculator.js, × button and commitOperand('multiply') in public/index.html, and tests in calculator/server/ui suites; npm test 32/32 pass; pushed feat commit
ce54593.Aira · CI passed on
ce54593eAira · review
CI is green on
ce54593e. Independent Dodik and code review started.Aira · dodik PASS on
ce54593eMultiplication is implemented end to end and matches the approved plan. op=multiply returns 42 for 6 and 7 and -1 for -2 and 0.5, add and subtract and 400 error handling remain, and the page has a × button wired to commitOperand('multiply'). The suite of 32 tests passed with no skips, and the diff contains only the planned calculator, UI, test, and plan changes.
Checks performed
ce54593against origin/main and docs/plans/issue-3.mdAttachment: dodik-ce54593e.json
Aira · reviewer PASS on
ce54593eMultiplication is implemented consistently with existing add/subtract:
lib/calculator.jsdispatchesop=multiplythrough shared parsing and finite-result validation,server.jsrequires no changes and continues to mapCalculatorErrorto HTTP 400, andpublic/index.htmladds a×key that callscommitOperand('multiply')before evaluate usespendingOp. All 32 tests pass vianpm test, including acceptance cases 6×7=42 and −2×0.5=−1, multiply overflow (1e200×1e200), invalid operands withmultiply, and UI presence ofdata-key="×"withcommitOperand('multiply'). No correctness, input-handling, security, or behavioural regressions were found in the diff againstorigin/main.Checks performed
ce54593Attachment: reviewer-ce54593e.json
Aira · qa
Dodik and the reviewer passed on
ce54593e. Preview deployed at http://127.0.0.1:36589; QA started.Aira · qa PASS on
ce54593eCommit
ce54593e1cserves a healthy calculator: GET /api/calculate with op=multiply returns 42 for 6 and 7 and -1 for -2 and 0.5, add and subtract still return correct results, and missing, empty, non-numeric, or unknown inputs return HTTP 400 with an error object. The index page includes a × button whose handler sets op=multiply and evaluates through that API, and the module, API, and page test suite (32 tests) passed on this commit.Checks performed
ce54593e1c→ 32 pass, 0 fail, including multiply returns product, calculate multiply (product and negatives/decimals), and index page supports multiplyAttachment: qa-ce54593e.json
Aira · merging
QA passed on
ce54593e. Merging.Aira · Merged PR #7
Merge commit
fe428582167c43e43754691ca51474f870b88a56from reviewed headce54593e1c17020c2e0b031f87f64999c813910d.lib/calculator.jsdispatchesop=multiplythrough shared parsing and finite-result valce54593e1cserves a healthy calculator: GET /api/calculate with op=multiply returns 42 for 6 and 7 and -1 for -2 and 0.5, a