Calculation history #11

Closed
opened 2026-11-21 01:41:56 +00:00 by lab-admin · 15 comments
Owner

Keep a short history of successful calculations.

Requirements

  • The server keeps the last 10 successful calculations in memory (newest first).
  • GET /api/history returns 200 {"items": [{"a": <number>, "b": <number or null>, "op": "<op>", "result": <number>}]}.
  • DELETE /api/history clears it and returns 204.
  • Failed calculations are not recorded.
  • UI: a "History" list under the calculator that refreshes after each = (and after √), and a "Clear history" button.
  • Tests for the history module/API (ordering, limit of 10, clearing, errors not recorded) and the page.

Acceptance criteria

  1. After 2+3 and 6*7, GET /api/history lists 6*7=42 first and 2+3=5 second.
  2. After 12 calculations only the newest 10 are returned.
  3. A failed calculation (division by zero) is not in the history.
  4. DELETE /api/history returns 204 and the history is empty afterwards.
  5. The page shows the history list and a Clear history button.
Keep a short history of successful calculations. ## Requirements - The server keeps the last 10 successful calculations in memory (newest first). - `GET /api/history` returns `200 {"items": [{"a": <number>, "b": <number or null>, "op": "<op>", "result": <number>}]}`. - `DELETE /api/history` clears it and returns `204`. - Failed calculations are not recorded. - UI: a "History" list under the calculator that refreshes after each `=` (and after `√`), and a "Clear history" button. - Tests for the history module/API (ordering, limit of 10, clearing, errors not recorded) and the page. ## Acceptance criteria 1. After `2+3` and `6*7`, `GET /api/history` lists `6*7=42` first and `2+3=5` second. 2. After 12 calculations only the newest 10 are returned. 3. A failed calculation (division by zero) is not in the history. 4. `DELETE /api/history` returns 204 and the history is empty afterwards. 5. The page shows the history list and a Clear history button.
Collaborator

Aira · queued

Aira picked up this task. Branch aira/11-calculation-history.

**Aira · queued** Aira picked up this task. Branch `aira/11-calculation-history`.
Collaborator

Aira · planning

Orchestrator thread started (composer-2.5). Planning on aira/11-calculation-history.

T3 thread: mcp:launch:ebc85b07ef5a22b98bde5c4de63e7e28d9edb12037cbff6180a9364b4e35b3d2

**Aira · planning** Orchestrator thread started (composer-2.5). Planning on `aira/11-calculation-history`. T3 thread: `mcp:launch:ebc85b07ef5a22b98bde5c4de63e7e28d9edb12037cbff6180a9364b4e35b3d2`
Collaborator

Aira · Plan (round 1) at a470846e

Wrote docs/plans/issue-11.md for in-memory calculation history (lib/history.js, GET/DELETE /api/history, UI list + clear), committed and pushed branch aira/11-calculation-history.

docs/plans/issue-11.md

Issue #11: Calculation history

Goal

Keep a short in-memory history of successful calculations on the server, expose it via GET /api/history and DELETE /api/history, and show a refreshable History list with a Clear history control on the calculator page. History entries preserve operands, operation name, and result; failed calculations are never stored.

Acceptance criteria

  1. After 2+3 and 6*7, GET /api/history lists 6*7=42 first and 2+3=5 second (newest first).
  2. After 12 successful calculations only the newest 10 are returned.
  3. A failed calculation (division by zero) is not in the history.
  4. DELETE /api/history returns 204 and the history is empty afterwards.
  5. The page shows the history list and a Clear history button; the list refreshes after each = and after √.

Design

History module (lib/history.js)

  • In-memory store: array of entries, newest first (prepend on record).
  • Constant MAX_ENTRIES = 10; when length exceeds 10, drop oldest (end of array).
  • Entry shape: { a: number, b: number | null, op: string, result: number }.
    • Unary sqrt: b is null (matches API contract).
    • Binary ops: b is the numeric second operand.
  • Exported functions (pure store logic, no HTTP):
    • record(entry) — validate/shallow-copy fields, unshift, trim to 10.
    • getItems() — return a shallow copy of the array (defensive for callers).
    • clear() — reset to empty array.
  • Export MAX_ENTRIES for unit tests if useful.

HTTP layer (server.js)

  • Import history helpers.
  • GET /api/calculate (existing path): on 200 only, after calculate() succeeds, call history.record() with:
    • op from query string (as returned/stored by API, e.g. add, multiply, sqrt).
    • a / b as numbers from query params (b → null when op === 'sqrt').
    • result from calculation.
    • On 400 (CalculatorError), do not record.
  • GET /api/history: 200 and body {"items": [...]} where items is history.getItems().
  • DELETE /api/history: history.clear(), respond 204 with empty body (no JSON).
  • Preserve /health, /, /api/calculate contract, and 404 handling unchanged.

UI (public/index.html)

  • Add a History section below the keypad:
    • Heading (e.g. “History”).
    • <ul id="history-list"> (or similar) for entries; empty state when no items.
    • Clear history button.
  • Minimal styling consistent with existing page (no external assets).
  • refreshHistory(): GET /api/history, render each item (e.g. a op b = result or √a = result when b is null).
  • Call refreshHistory() on load, after successful evaluate() (=), and after successful applyUnary() (√).
  • Clear button: DELETE /api/history, then refreshHistory() (list empty).

Test layout

File Purpose
test/history.test.js Unit tests: ordering, cap at 10, clear, entry shape (b null for sqrt).
test/server.test.js HTTP: AC1–4 via calculate + history + DELETE; failures not recorded.
test/ui.test.js Page contains history list container, Clear history control, and script hooks to fetch history after calculate/sqrt and on clear.

Files to change

File Action
lib/history.js Create — in-memory store, record/get/clear, limit 10.
server.js Modify — record on successful calculate; GET/DELETE /api/history.
public/index.html Modify — History UI, refreshHistory, wire = / √ / clear.
test/history.test.js Create — module unit tests.
test/server.test.js Modify — history API acceptance tests; DELETE at test start where isolation needed.
test/ui.test.js Modify — history list and Clear history assertions.
docs/plans/issue-11.md Create — this plan.

No changes to lib/calculator.js (calculation logic unchanged), package.json, or CI workflows.

Test plan

Unit (test/history.test.js)

Case Assert
Ordering Record A then B; getItems()[0] is B, [1] is A.
Limit (AC2) Record 12 distinct entries; length 10; oldest two absent; newest preserved.
Clear After clear(), getItems() is [].
Sqrt shape Record { a: 9, b: null, op: 'sqrt', result: 3 }; item matches.
Idempotent clear clear() on empty store stays empty.

Each test calls clear() in setup to avoid cross-test leakage.

HTTP (test/server.test.js)

Use withServer; start history-sensitive tests with DELETE /api/history (or assert empty GET) for isolation.

Case Steps Expect
AC1 DELETE; calculate?a=2&b=3&op=add; calculate?a=6&b=7&op=multiply; GET /api/history 200; items[0] multiply 42; items[1] add 5
AC2 DELETE; 12× successful add with distinct results; GET /api/history items.length === 10; first item is 12th calculation
AC3 DELETE; success add; divide?a=1&b=0&op=divide (400); GET /api/history only one item (the add); no divide entry
AC4 Seed history; DELETE /api/history 204, empty body; GET /api/history → { items: [] }
Sqrt recorded sqrt success item has b: null, op: 'sqrt'
Regression Existing calculate/health/index tests unchanged

UI / page (test/ui.test.js)

Case Assert
AC5 (markup) HTML includes history list element (e.g. #history-list) and a Clear history button (text or id).
AC5 (refresh) Script defines refreshHistory (or equivalent) calling /api/history; invoked after successful paths in evaluate / applyUnary (regex or string match).
AC5 (clear) Script uses DELETE on /api/history from clear control and refreshes list.
Regression Existing button and API tests unchanged.

Pre-push

  • Run npm test locally; all tests green before git push origin aira/11-calculation-history.

Risks

Risk Mitigation
Module-level history leaks state across node --test cases in one process clear() in unit test setup; HTTP tests use DELETE or empty assert before seeding.
Recording on failed calculate Only call record in the 200 branch after calculate() returns.
UI forgets refresh on √ Explicit requirement in plan; UI test checks both evaluate and applyUnary paths.
Display format ambiguity for history rows Use simple text (e.g. ${a} ${op} ${b} = ${result} or special-case sqrt); tests focus on presence/wiring, not exact formatting unless needed for AC5.
DELETE response body Use res.end() with no body and status 204; test asserts status and subsequent empty items.

Attachment: plan-11-r1.md

**Aira · Plan (round 1) at `a470846e`** Wrote docs/plans/issue-11.md for in-memory calculation history (lib/history.js, GET/DELETE /api/history, UI list + clear), committed and pushed branch aira/11-calculation-history. <details><summary>docs/plans/issue-11.md</summary> # Issue #11: Calculation history ## Goal Keep a short in-memory history of **successful** calculations on the server, expose it via `GET /api/history` and `DELETE /api/history`, and show a refreshable History list with a Clear history control on the calculator page. History entries preserve operands, operation name, and result; failed calculations are never stored. ## Acceptance criteria 1. After `2+3` and `6*7`, `GET /api/history` lists `6*7=42` first and `2+3=5` second (newest first). 2. After 12 successful calculations only the newest 10 are returned. 3. A failed calculation (division by zero) is not in the history. 4. `DELETE /api/history` returns 204 and the history is empty afterwards. 5. The page shows the history list and a Clear history button; the list refreshes after each `=` and after `√`. ## Design ### History module (`lib/history.js`) - In-memory store: array of entries, **newest first** (prepend on record). - Constant `MAX_ENTRIES = 10`; when length exceeds 10, drop oldest (end of array). - Entry shape: `{ a: number, b: number | null, op: string, result: number }`. - Unary `sqrt`: `b` is `null` (matches API contract). - Binary ops: `b` is the numeric second operand. - Exported functions (pure store logic, no HTTP): - `record(entry)` — validate/shallow-copy fields, unshift, trim to 10. - `getItems()` — return a shallow copy of the array (defensive for callers). - `clear()` — reset to empty array. - Export `MAX_ENTRIES` for unit tests if useful. ### HTTP layer (`server.js`) - Import history helpers. - **`GET /api/calculate`** (existing path): on **200** only, after `calculate()` succeeds, call `history.record()` with: - `op` from query string (as returned/stored by API, e.g. `add`, `multiply`, `sqrt`). - `a` / `b` as numbers from query params (`b` → `null` when `op === 'sqrt'`). - `result` from calculation. - On **400** (`CalculatorError`), do **not** record. - **`GET /api/history`**: `200` and body `{"items": [...]}` where `items` is `history.getItems()`. - **`DELETE /api/history`**: `history.clear()`, respond `204` with empty body (no JSON). - Preserve `/health`, `/`, `/api/calculate` contract, and 404 handling unchanged. ### UI (`public/index.html`) - Add a **History** section below the keypad: - Heading (e.g. “History”). - `<ul id="history-list">` (or similar) for entries; empty state when no items. - **Clear history** button. - Minimal styling consistent with existing page (no external assets). - **`refreshHistory()`**: `GET /api/history`, render each item (e.g. `a op b = result` or `√a = result` when `b` is null). - Call `refreshHistory()` on load, after successful `evaluate()` (`=`), and after successful `applyUnary()` (`√`). - Clear button: `DELETE /api/history`, then `refreshHistory()` (list empty). ### Test layout | File | Purpose | |------|---------| | `test/history.test.js` | Unit tests: ordering, cap at 10, clear, entry shape (`b` null for sqrt). | | `test/server.test.js` | HTTP: AC1–4 via calculate + history + DELETE; failures not recorded. | | `test/ui.test.js` | Page contains history list container, Clear history control, and script hooks to fetch history after calculate/sqrt and on clear. | ## Files to change | File | Action | |------|--------| | `lib/history.js` | **Create** — in-memory store, record/get/clear, limit 10. | | `server.js` | **Modify** — record on successful calculate; `GET/DELETE /api/history`. | | `public/index.html` | **Modify** — History UI, `refreshHistory`, wire `=` / `√` / clear. | | `test/history.test.js` | **Create** — module unit tests. | | `test/server.test.js` | **Modify** — history API acceptance tests; `DELETE` at test start where isolation needed. | | `test/ui.test.js` | **Modify** — history list and Clear history assertions. | | `docs/plans/issue-11.md` | **Create** — this plan. | No changes to `lib/calculator.js` (calculation logic unchanged), `package.json`, or CI workflows. ## Test plan ### Unit (`test/history.test.js`) | Case | Assert | |------|--------| | Ordering | Record A then B; `getItems()[0]` is B, `[1]` is A. | | Limit (AC2) | Record 12 distinct entries; length 10; oldest two absent; newest preserved. | | Clear | After `clear()`, `getItems()` is `[]`. | | Sqrt shape | Record `{ a: 9, b: null, op: 'sqrt', result: 3 }`; item matches. | | Idempotent clear | `clear()` on empty store stays empty. | Each test calls `clear()` in setup to avoid cross-test leakage. ### HTTP (`test/server.test.js`) Use `withServer`; start history-sensitive tests with `DELETE /api/history` (or assert empty `GET`) for isolation. | Case | Steps | Expect | |------|--------|--------| | AC1 | `DELETE`; `calculate?a=2&b=3&op=add`; `calculate?a=6&b=7&op=multiply`; `GET /api/history` | 200; `items[0]` multiply 42; `items[1]` add 5 | | AC2 | `DELETE`; 12× successful `add` with distinct results; `GET /api/history` | `items.length === 10`; first item is 12th calculation | | AC3 | `DELETE`; success `add`; `divide?a=1&b=0&op=divide` (400); `GET /api/history` | only one item (the add); no divide entry | | AC4 | Seed history; `DELETE /api/history` | 204, empty body; `GET /api/history` → `{ items: [] }` | | Sqrt recorded | `sqrt` success | item has `b: null`, `op: 'sqrt'` | | Regression | Existing calculate/health/index tests | unchanged | ### UI / page (`test/ui.test.js`) | Case | Assert | |------|--------| | AC5 (markup) | HTML includes history list element (e.g. `#history-list`) and a Clear history button (text or `id`). | | AC5 (refresh) | Script defines `refreshHistory` (or equivalent) calling `/api/history`; invoked after successful paths in `evaluate` / `applyUnary` (regex or string match). | | AC5 (clear) | Script uses `DELETE` on `/api/history` from clear control and refreshes list. | | Regression | Existing button and API tests unchanged. | ### Pre-push - Run `npm test` locally; all tests green before `git push origin aira/11-calculation-history`. ## Risks | Risk | Mitigation | |------|------------| | Module-level history leaks state across `node --test` cases in one process | `clear()` in unit test setup; HTTP tests use `DELETE` or empty assert before seeding. | | Recording on failed calculate | Only call `record` in the `200` branch after `calculate()` returns. | | UI forgets refresh on `√` | Explicit requirement in plan; UI test checks both `evaluate` and `applyUnary` paths. | | Display format ambiguity for history rows | Use simple text (e.g. `${a} ${op} ${b} = ${result}` or special-case `sqrt`); tests focus on presence/wiring, not exact formatting unless needed for AC5. | | `DELETE` response body | Use `res.end()` with no body and status 204; test asserts status and subsequent empty `items`. | </details> Attachment: [plan-11-r1.md](https://aira-lab.cluster-dev.spkey.co/attachments/11de97b9-f5d0-4cb4-a532-5f1cfa5acd68)
Collaborator

Aira · plan review

Plan pushed at a470846e; independent Dodik plan review started.

**Aira · plan review** Plan pushed at `a470846e`; independent Dodik plan review started.
Collaborator

Aira · dodik-plan PASS on a470846e

The issue #11 plan maps each requirement to a numbered, testable acceptance criterion, and the design matches the current code: calculate() returns only a number and reports failures as CalculatorError (including division by zero), sqrt is unary and ignores b, and the page already has evaluate() for = and applyUnary() for √. The test plan proves ordering, the cap of 10, clearing, failed calculations not recorded, the unary b: null shape, and the history list plus Clear history wiring, without changing calculator logic, dependencies, or CI.

Checks performed
  • Requirements map to AC1–AC5, including newest-first order, limit of 10, division by zero omitted, DELETE 204, and the history list refreshing after = and √.
  • Design matches server.js, lib/calculator.js, and public/index.html: record only after a 200 from calculate(), store API op names, set b to null for sqrt, and hook refreshHistory on the existing success paths.
  • Unit, HTTP, and page tests cover ordering, the 10-item cap, clear, errors not recorded, sqrt entry shape, and history markup plus clear/refresh wiring, using withServer and the existing static UI test style.
  • Scope stays on lib/history.js, server.js, public/index.html, and tests; lib/calculator.js, package.json, and CI are unchanged.

Attachment: dodik-plan-a470846e.json

**Aira · dodik-plan PASS on `a470846e`** The issue #11 plan maps each requirement to a numbered, testable acceptance criterion, and the design matches the current code: calculate() returns only a number and reports failures as CalculatorError (including division by zero), sqrt is unary and ignores b, and the page already has evaluate() for = and applyUnary() for √. The test plan proves ordering, the cap of 10, clearing, failed calculations not recorded, the unary b: null shape, and the history list plus Clear history wiring, without changing calculator logic, dependencies, or CI. <details><summary>Checks performed</summary> - Requirements map to AC1–AC5, including newest-first order, limit of 10, division by zero omitted, DELETE 204, and the history list refreshing after = and √. - Design matches server.js, lib/calculator.js, and public/index.html: record only after a 200 from calculate(), store API op names, set b to null for sqrt, and hook refreshHistory on the existing success paths. - Unit, HTTP, and page tests cover ordering, the 10-item cap, clear, errors not recorded, sqrt entry shape, and history markup plus clear/refresh wiring, using withServer and the existing static UI test style. - Scope stays on lib/history.js, server.js, public/index.html, and tests; lib/calculator.js, package.json, and CI are unchanged. </details> Attachment: [dodik-plan-a470846e.json](https://aira-lab.cluster-dev.spkey.co/attachments/3792925b-b03c-4b4f-9893-c2606965ed57)
Collaborator

Aira · implementing

Plan approved by Dodik at a470846e. Implementation started.

**Aira · implementing** Plan approved by Dodik at `a470846e`. Implementation started.
Collaborator

Aira · ci

Ready for review at 028c5920 (PR #15). Waiting for CI.

Implemented in-memory calculation history (lib/history.js, GET/DELETE /api/history, UI refresh/clear), added history unit/server/UI tests; npm test passes (70/70); pushed feat commit to aira/11-calculation-history.

**Aira · ci** Ready for review at `028c5920` (PR #15). Waiting for CI. Implemented in-memory calculation history (lib/history.js, GET/DELETE /api/history, UI refresh/clear), added history unit/server/UI tests; npm test passes (70/70); pushed feat commit to aira/11-calculation-history.
Collaborator

Aira · CI passed on 028c5920

  • ci / test (pull_request): success
**Aira · CI passed on `028c5920`** - ci / test (pull_request): success
Collaborator

Aira · review

CI is green on 028c5920. Independent Dodik and code review started.

**Aira · review** CI is green on `028c5920`. Independent Dodik and code review started.
Collaborator

Aira · dodik PASS on 028c5920

Calculation history matches the approved plan and all five acceptance criteria. The in-memory store keeps the newest 10 successful calculations, GET /api/history returns them newest-first, DELETE /api/history returns 204 and clears the list, failures such as division by zero are omitted, and the page shows a History list and Clear history button that refresh after = and √. The suite passed 70 tests with no skips, and the diff contains only the planned files.

Checks performed
  • Diff against origin/main is limited to lib/history.js, server.js, public/index.html, test/history.test.js, test/server.test.js, test/ui.test.js, and docs/plans/issue-11.md
  • AC1: after add 2+3 and multiply 6*7, GET /api/history returns multiply 42 then add 5; covered by test/server.test.js and an independent request
  • AC2: 12 successful adds return exactly the newest 10 (a=11 down to a=2); covered by unit and HTTP tests and an independent request
  • AC3: division by zero, negative square root, and an invalid operand return 400 and are not stored; covered by the failed-calculation test and an independent request
  • AC4: DELETE /api/history returns 204 with an empty body and a following GET returns {items: []}
  • AC5: public/index.html has #history-list and Clear history under the keypad; refreshHistory runs on load and after successful evaluate and applyUnary; clear sends DELETE then refreshes
  • npm test: 70 passed, 0 failed, 0 skipped; existing assertions were not weakened and no debug leftovers were added
  • README still describes start, test, and the unchanged calculate contract; the plan did not require an endpoint catalogue

Attachment: dodik-028c5920.json

**Aira · dodik PASS on `028c5920`** Calculation history matches the approved plan and all five acceptance criteria. The in-memory store keeps the newest 10 successful calculations, GET /api/history returns them newest-first, DELETE /api/history returns 204 and clears the list, failures such as division by zero are omitted, and the page shows a History list and Clear history button that refresh after = and √. The suite passed 70 tests with no skips, and the diff contains only the planned files. <details><summary>Checks performed</summary> - Diff against origin/main is limited to lib/history.js, server.js, public/index.html, test/history.test.js, test/server.test.js, test/ui.test.js, and docs/plans/issue-11.md - AC1: after add 2+3 and multiply 6*7, GET /api/history returns multiply 42 then add 5; covered by test/server.test.js and an independent request - AC2: 12 successful adds return exactly the newest 10 (a=11 down to a=2); covered by unit and HTTP tests and an independent request - AC3: division by zero, negative square root, and an invalid operand return 400 and are not stored; covered by the failed-calculation test and an independent request - AC4: DELETE /api/history returns 204 with an empty body and a following GET returns {items: []} - AC5: public/index.html has #history-list and Clear history under the keypad; refreshHistory runs on load and after successful evaluate and applyUnary; clear sends DELETE then refreshes - npm test: 70 passed, 0 failed, 0 skipped; existing assertions were not weakened and no debug leftovers were added - README still describes start, test, and the unchanged calculate contract; the plan did not require an endpoint catalogue </details> Attachment: [dodik-028c5920.json](https://aira-lab.cluster-dev.spkey.co/attachments/00837700-a83b-4b85-b49a-ad5f1b0996a0)
Collaborator

Aira · reviewer PASS on 028c5920

The calculation-history feature is implemented consistently with the plan and acceptance criteria: history is recorded only on successful calculate responses, capped at ten newest-first entries, exposed via GET/DELETE /api/history, and wired in the UI with refresh on load, after = and √, and after clear. All 70 tests passed (including multiple runs and --test-concurrency=32); manual HTTP checks confirmed failed overflow and division-by-zero calls do not append history. Existing /health, /, and /api/calculate behaviour remains covered by the suite.

Checks performed
  • Reviewed git diff origin/main...HEAD at 028c592
  • Ran npm test (70/70 pass) and stress reruns with --test-concurrency=32
  • Verified server only calls history.record after successful calculate(); 400 paths do not record
  • Verified acceptance scenarios: ordering, 10-entry cap, failed divide omitted, DELETE 204 clears, sqrt stores b:null
  • Manual runtime check: overflow 400 and div-by-zero 400 leave history unchanged
  • Reviewed lib/history.js getItems defensive copy and MAX_ENTRIES trim
  • Reviewed UI refreshHistory wiring for evaluate, applyUnary, clear, and initial load

Attachment: reviewer-028c5920.json

**Aira · reviewer PASS on `028c5920`** The calculation-history feature is implemented consistently with the plan and acceptance criteria: history is recorded only on successful calculate responses, capped at ten newest-first entries, exposed via GET/DELETE /api/history, and wired in the UI with refresh on load, after = and √, and after clear. All 70 tests passed (including multiple runs and --test-concurrency=32); manual HTTP checks confirmed failed overflow and division-by-zero calls do not append history. Existing /health, /, and /api/calculate behaviour remains covered by the suite. <details><summary>Checks performed</summary> - Reviewed git diff origin/main...HEAD at 028c592 - Ran npm test (70/70 pass) and stress reruns with --test-concurrency=32 - Verified server only calls history.record after successful calculate(); 400 paths do not record - Verified acceptance scenarios: ordering, 10-entry cap, failed divide omitted, DELETE 204 clears, sqrt stores b:null - Manual runtime check: overflow 400 and div-by-zero 400 leave history unchanged - Reviewed lib/history.js getItems defensive copy and MAX_ENTRIES trim - Reviewed UI refreshHistory wiring for evaluate, applyUnary, clear, and initial load </details> Attachment: [reviewer-028c5920.json](https://aira-lab.cluster-dev.spkey.co/attachments/54073934-4681-4bea-a923-9dc460e2cac1)
Collaborator

Aira · qa

Dodik and the reviewer passed on 028c5920. Preview deployed at http://127.0.0.1:38027; QA started.

**Aira · qa** Dodik and the reviewer passed on `028c5920`. Preview deployed at http://127.0.0.1:38027; QA started.
Collaborator

Aira · qa PASS on 028c5920

Commit 028c592089 serves GET /health with that sha. GET /api/history returns newest-first successful calculations, keeps only the latest 10 after 12 adds, omits division by zero and other 400s, and DELETE /api/history returns 204 with an empty list afterwards. The page contains a History list and a Clear history button and refreshes history after a successful equals and after square root. npm test passed 70 tests, including history ordering, the limit of 10, clearing, errors not recorded, and the page controls.

Checks performed
  • GET /health -> 200 {"ok":true,"sha":"028c592089e1427eddd7c6d0453b4abbd38455cd"}
  • GET / -> 200 text/html with h2 History, ul#history-list, button#clear-history "Clear history", and client script that refreshHistory() after successful = and after √
  • DELETE /api/history -> 204 empty body
  • GET /api/history -> 200 {"items":[]}
  • GET /api/calculate?a=2&b=3&op=add -> 200 {"result":5}
  • GET /api/calculate?a=6&b=7&op=multiply -> 200 {"result":42}
  • GET /api/history -> 200 items [6 multiply 7 = 42, 2 add 3 = 5]
  • GET /api/calculate?a=1&b=0&op=divide -> 400 {"error":"division by zero"}; following GET /api/history unchanged
  • GET /api/calculate?a=foo&b=1&op=add, a=&b=1&op=add, missing a, b=bar, op=nope, missing op, and a=-1&op=sqrt -> 400; GET /api/history still only the two successes
  • GET /api/calculate?a=9&op=sqrt -> 200 {"result":3}; history item {"a":9,"b":null,"op":"sqrt","result":3} newest
  • GET /api/calculate?a=50&b=10&op=percent -> 5; a=10&b=4&op=subtract -> 6; a=8&b=2&op=divide -> 4; all recorded newest first
  • DELETE /api/history -> 204; GET /api/history -> {"items":[]}; then GET /api/calculate?a=1..12&b=1&op=add -> results 2..13
  • GET /api/history after 10 adds -> 10 items results 11..2; after 11 -> 12..3 (1+1 dropped); after 12 -> 13..4 (2+1 dropped)
  • GET /api/calculate?a=9&b=0&op=divide -> 400 division by zero; GET /api/history unchanged (still 10)
  • GET /api/calculate?a=1e308&b=1e308&op=add -> 400 {"error":"Result out of range"}; GET /api/history unchanged
  • DELETE /api/history on a full list -> 204 empty body; GET /api/history -> 200 {"items":[]}
  • GET /health again -> same sha 028c592089
  • npm test -> 70 pass, 0 fail, including history newest-first, ten-item cap, omit failed, DELETE, sqrt null b, and page history controls

Attachment: qa-028c5920.json

**Aira · qa PASS on `028c5920`** Commit 028c592089e1427eddd7c6d0453b4abbd38455cd serves GET /health with that sha. GET /api/history returns newest-first successful calculations, keeps only the latest 10 after 12 adds, omits division by zero and other 400s, and DELETE /api/history returns 204 with an empty list afterwards. The page contains a History list and a Clear history button and refreshes history after a successful equals and after square root. npm test passed 70 tests, including history ordering, the limit of 10, clearing, errors not recorded, and the page controls. <details><summary>Checks performed</summary> - GET /health -> 200 {"ok":true,"sha":"028c592089e1427eddd7c6d0453b4abbd38455cd"} - GET / -> 200 text/html with h2 History, ul#history-list, button#clear-history "Clear history", and client script that refreshHistory() after successful = and after √ - DELETE /api/history -> 204 empty body - GET /api/history -> 200 {"items":[]} - GET /api/calculate?a=2&b=3&op=add -> 200 {"result":5} - GET /api/calculate?a=6&b=7&op=multiply -> 200 {"result":42} - GET /api/history -> 200 items [6 multiply 7 = 42, 2 add 3 = 5] - GET /api/calculate?a=1&b=0&op=divide -> 400 {"error":"division by zero"}; following GET /api/history unchanged - GET /api/calculate?a=foo&b=1&op=add, a=&b=1&op=add, missing a, b=bar, op=nope, missing op, and a=-1&op=sqrt -> 400; GET /api/history still only the two successes - GET /api/calculate?a=9&op=sqrt -> 200 {"result":3}; history item {"a":9,"b":null,"op":"sqrt","result":3} newest - GET /api/calculate?a=50&b=10&op=percent -> 5; a=10&b=4&op=subtract -> 6; a=8&b=2&op=divide -> 4; all recorded newest first - DELETE /api/history -> 204; GET /api/history -> {"items":[]}; then GET /api/calculate?a=1..12&b=1&op=add -> results 2..13 - GET /api/history after 10 adds -> 10 items results 11..2; after 11 -> 12..3 (1+1 dropped); after 12 -> 13..4 (2+1 dropped) - GET /api/calculate?a=9&b=0&op=divide -> 400 division by zero; GET /api/history unchanged (still 10) - GET /api/calculate?a=1e308&b=1e308&op=add -> 400 {"error":"Result out of range"}; GET /api/history unchanged - DELETE /api/history on a full list -> 204 empty body; GET /api/history -> 200 {"items":[]} - GET /health again -> same sha 028c592089e1427eddd7c6d0453b4abbd38455cd - npm test -> 70 pass, 0 fail, including history newest-first, ten-item cap, omit failed, DELETE, sqrt null b, and page history controls </details> Attachment: [qa-028c5920.json](https://aira-lab.cluster-dev.spkey.co/attachments/c5dbda42-9a98-4123-a61d-59f3b8b3f803)
Collaborator

Aira · merging

QA passed on 028c5920. Merging.

**Aira · merging** QA passed on `028c5920`. Merging.
Collaborator

Aira · Merged PR #15

Merge commit 20c34e99b16019e64a5444f4a65af54fd343d9f7 from reviewed head 028c592089e1427eddd7c6d0453b4abbd38455cd.

Gate Verdict Summary
ci pass ci / test (pull_request)
dodik pass Calculation history matches the approved plan and all five acceptance criteria. The in-memory store keeps the newest 10 successful calculations, GET /api/histor
reviewer pass The calculation-history feature is implemented consistently with the plan and acceptance criteria: history is recorded only on successful calculate responses, c
qa pass Commit 028c592089 serves GET /health with that sha. GET /api/history returns newest-first successful calculations, keeps only the
**Aira · Merged PR #15** Merge commit `20c34e99b16019e64a5444f4a65af54fd343d9f7` from reviewed head `028c592089e1427eddd7c6d0453b4abbd38455cd`. | Gate | Verdict | Summary | |---|---|---| | ci | pass | ci / test (pull_request) | | dodik | pass | Calculation history matches the approved plan and all five acceptance criteria. The in-memory store keeps the newest 10 successful calculations, GET /api/histor | | reviewer | pass | The calculation-history feature is implemented consistently with the plan and acceptance criteria: history is recorded only on successful calculate responses, c | | qa | pass | Commit 028c592089e1427eddd7c6d0453b4abbd38455cd serves GET /health with that sha. GET /api/history returns newest-first successful calculations, keeps only the |
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/web-calculator#11
No description provided.