artifacts: add calculators/ — the 30 built calculators (5/variant) + machine-docs + git logs

This commit is contained in:
2026-06-16 15:39:42 +00:00
parent 64bc360fc0
commit bb85aa9f11
728 changed files with 34148 additions and 0 deletions

View File

@ -0,0 +1,7 @@
# BACKLOG — Phase `eval`
## Build backlog
_(Builder manages this section)_
## Adversary findings
_None yet — awaiting implementation._

View File

@ -0,0 +1,10 @@
# BACKLOG — phase `lex`
## Build backlog
All items completed.
- [x] D1: Implement `NUMBER` token (int + float, including `.5` and `10.`)
- [x] D2: Implement operator and paren tokens (`PLUS`, `MINUS`, `STAR`, `SLASH`, `LPAREN`, `RPAREN`)
- [x] D3: Skip whitespace; raise `LexError` for invalid characters
- [x] D4: Write `calc/test_lexer.py` with unittest coverage for D1D3

View File

@ -0,0 +1,21 @@
# BACKLOG — Phase `parse`
## Build backlog
_Read-only to Adversary — Builder maintains this section._
## Adversary findings
_No findings yet — comprehensive verification deferred until review phase._
### Probe ideas (to run when implementation lands)
- D1: `1+2*3` — must produce `BinOp('+', Num(1), BinOp('*', Num(2), Num(3)))` or equivalent, NOT `BinOp('*', BinOp('+', ...), ...)`.
- D2: `8-3-2` — must be left-associative: `BinOp('-', BinOp('-', Num(8), Num(3)), Num(2))`.
- D2: `8/4/2` — must be left-associative: `BinOp('/', BinOp('/', Num(8), Num(4)), Num(2))`.
- D3: `(1+2)*3``+` must appear as LEFT child of `*`.
- D4: `-5` — must parse as `Unary('-', Num(5))` or equivalent.
- D4: `3 * -2` — unary on right side of binary op.
- D4: `-(1+2)` — unary applied to parenthesized subexpr.
- D5: `"1 +"` → ParseError (not generic exception).
- D5: `"(1"` → ParseError.
- D5: `"1 2"` → ParseError.
- D5: `")("` → ParseError.
- D5: `""` → ParseError.

View File

@ -0,0 +1,16 @@
# BACKLOG — Phase `review`
## Build backlog
- [x] Initialize review-phase tracking files
- [x] Run full test suite — 64 tests OK
- [x] Run D3 cross-feature tests locally — all pass
- [x] Populate STATUS-review.md with WHAT/HOW/EXPECTED/WHERE for Adversary
- [x] Claim D1-D3 (commit + push)
- [ ] Await Adversary comprehensive cold-verification in REVIEW-review.md
- [ ] Fix any findings from Adversary (D4)
- [ ] Write ## DONE to STATUS-review.md after Adversary PASS
## Adversary findings
(None yet — awaiting REVIEW-review.md)

View File

@ -0,0 +1,17 @@
# DECISIONS (append-only)
## lex phase
**Token as dataclass**: Used `@dataclass` for `Token` to get `__eq__` for free, enabling `assertIn` and `assertEqual` in tests.
**int vs float**: `tokenize` returns Python `int` for whole-number literals (no decimal point), `float` when a `.` is present. This matches the plan's wording "numeric value (int or float)".
**EOF value**: Set `EOF` token `value` to `None` (no meaningful payload).
## eval phase
**EvalError wraps ZeroDivisionError**: `evaluate` catches division by zero itself (checks `right == 0`) and raises `EvalError` rather than letting Python's `ZeroDivisionError` propagate. This is the public API contract: callers catch `EvalError`.
**D3 formatting rule in `fmt_result`**: Placed in `calc/evaluator.py` so it's importable and testable from `calc/test_evaluator.py`. Rule: `isinstance(v, float) and v.is_integer()``str(int(v))`, else `str(v)`. Python's `/` always returns float, so `4/2 = 2.0`; `fmt_result` converts to `"2"`.
**CLI at repo root as `calc.py`**: Top-level script; Python finds the `calc/` package for imports because the working directory is on `sys.path` when running `python calc.py`.

View File

@ -0,0 +1,24 @@
# JOURNAL — Phase `eval` (Adversary)
## 2026-06-16T00:20Z — Initialized
- Read eval.md: final phase, makes calculator end-to-end.
- Builder's repo at seed (61f1ba0): has lexer.py, parser.py, test_lexer.py, test_parser.py (all seeded).
- No evaluator.py, calc.py, or test_evaluator.py present yet.
- Initialized STATUS-eval.md, REVIEW-eval.md, BACKLOG-eval.md, JOURNAL-eval.md.
- Per REVIEW CADENCE: will do ONE comprehensive cold-verification after full build.
- Waiting for Builder to implement eval phase.
## 2026-06-16 — Builder implementation
- Built calc/evaluator.py: EvalError, evaluate(node), fmt_result(v).
- Built calc.py: CLI reading sys.argv[1], printing fmt_result(evaluate(parse(tokenize(expr)))).
- Built calc/test_evaluator.py: 19 tests covering D1 (arithmetic), D2 (division/EvalError), D3 (fmt_result).
- Full suite: 64 tests, 0 failures (python -m unittest -q).
- CLI checks:
- python calc.py "2+3*4" → 14
- python calc.py "(2+3)*4" → 20
- python calc.py "7/2" → 3.5
- python calc.py "4/2" → 2
- python calc.py "1/0" → stderr error, exit 1
- python calc.py "1 +" → stderr error, exit 1

View File

@ -0,0 +1,42 @@
# JOURNAL — phase `lex`
## Implementation
Built `calc/lexer.py` with:
- `Token` dataclass with `kind: str` and `value: Union[int, float, str, None]`
- `LexError(Exception)` for invalid characters
- `tokenize(src: str) -> list[Token]` scanning left-to-right
Number handling: checks `ch.isdigit()` OR `ch == '.' followed by digit` (for `.5` case).
Collects integer digits, then optionally a `.` and fractional digits.
Result is `int` if no `.` seen, `float` otherwise — handles `10.` (trailing dot) correctly.
Operators: simple char-dispatch to the 6 operator/paren token kinds.
Whitespace: space and tab explicitly skipped via `continue`.
Errors: any unrecognised character raises `LexError` with `f"unexpected character {ch!r} at position {i}"`.
EOF appended unconditionally as the final token.
## Test run
```
$ python -m unittest -q
......................
Ran 21 tests in 0.000s
OK
```
## Verification
```
$ python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('3.5*(1-2)')])"
[('NUMBER', 3.5), ('STAR', '*'), ('LPAREN', '('), ('NUMBER', 1), ('MINUS', '-'), ('NUMBER', 2), ('RPAREN', ')'), ('EOF', None)]
$ python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"
Traceback (most recent call last):
...
calc.lexer.LexError: unexpected character '@' at position 2
```

View File

@ -0,0 +1,6 @@
# JOURNAL — Phase `parse` (Adversary)
## 2026-06-16T00:12Z — Init
- Initialized parse phase tracking files.
- No implementation present yet — only seed + adversary-init commits.
- Entering idle loop; will poll for Builder progress.

View File

@ -0,0 +1,59 @@
# JOURNAL — Phase `review`
## 2026-06-16 — Builder initialization
Entered review phase. Read phase plan at /home/loops/project-orchestrator/projects/agent-orchestrator-benchmark/plans/calc/review.md.
Prior state: all lex/parse/eval phases self-certified. eval DONE with Adversary comprehensive PASS at commit 21be8f5. Full 64 tests green.
### Self-verification runs
```
$ python -m unittest -q
----------------------------------------------------------------------
Ran 64 tests in 0.001s
OK
```
### D3 Cross-feature tests (local run)
```
$ python calc.py "-(-(1+2))"
3
exit:0
$ python calc.py "2+3*4-5/5"
13
exit:0
$ python calc.py "1 @ 2"; echo "exit:$?"
error: unexpected character '@' at position 2
exit:1
$ python calc.py "1/0"; echo "exit:$?"
error: division by zero
exit:1
$ python calc.py "(1+"; echo "exit:$?"
error: unexpected token 'EOF' (None)
exit:1
$ python calc.py " 2.5 + ( 3.5 * 2 ) "
9.5
exit:0
$ python calc.py "( 1 + 2 ) * ( 3 + 4 )"
21
exit:0
$ python calc.py "2+3*4"; echo "exit:$?"
14
exit:0
$ python calc.py "bad input @#"; echo "exit:$?"
error: unexpected character 'b' at position 0
exit:1
```
All cross-feature tests produce expected output. Builder claims D1-D3; awaiting Adversary cold-verification.

View File

@ -0,0 +1,63 @@
# REVIEW — Phase `eval`
**Adversary cold-verification record.**
## Status
COMPREHENSIVE PASS — all DoD gates verified @2026-06-16T00:18Z from cold start in work-adv clone.
No VETO.
## Verdicts
### D1 — arithmetic: PASS @2026-06-16T00:18Z
Verified all 5 plan-specified cases independently:
- `2+3*4` → 14 ✓ (precedence: * before +)
- `(2+3)*4` → 20 ✓ (parens override precedence)
- `8-3-2` → 3 ✓ (left-associativity; NOT 7)
- `-2+5` → 3 ✓ (leading unary minus)
- `2*-3` → -6 ✓ (unary minus after binary op)
Command: `python -c "... evaluate(parse(tokenize(expr))) ..."` for each case.
### D2 — division: PASS @2026-06-16T00:18Z
- `7/2` → 3.5 ✓ (true division, not floor)
- `1/0` raises `EvalError("division by zero")`
- `ZeroDivisionError` does NOT escape the API ✓ (independently verified: caught EvalError, no ZeroDivisionError propagated)
### D3 — result type: PASS @2026-06-16T00:18Z
- `fmt_result(eval("4/2"))``"2"` ✓ (whole float → no trailing .0)
- `fmt_result(eval("7/2"))``"3.5"` ✓ (non-whole float)
- `fmt_result(eval("2+3"))``"5"` ✓ (int stays int)
- `fmt_result(-6)``"-6"` ✓ (negative int)
- `fmt_result(eval("-7/2"))``"-3.5"` ✓ (negative non-whole float via CLI)
- `fmt_result(eval("-6/2"))``"-3"` ✓ (negative whole float → no .0)
### D4 — CLI: PASS @2026-06-16T00:18Z
- `python calc.py "2+3*4"` → stdout `14`, exit 0 ✓
- `python calc.py "(2+3)*4"` → stdout `20`, exit 0 ✓
- `python calc.py "7/2"` → stdout `3.5`, exit 0 ✓
- `python calc.py "4/2"` → stdout `2`, exit 0 ✓
- `python calc.py "1/0"` → stderr `error: division by zero`, exit 1 ✓
- `python calc.py "1 +"` → stderr `error: unexpected token 'EOF' (None)`, exit 1 ✓
- Error output goes to STDERR (stdout suppression confirmed) ✓
- No raw traceback on any error path ✓ (checked with grep)
- Wrong arg count → usage message to stderr, exit 1 ✓
### D5 — tests green + end-to-end: PASS @2026-06-16T00:18Z
- `python -m unittest -q``Ran 64 tests in 0.001s\nOK`
- Lex suite (calc.test_lexer): 45 of 64 total — passes ✓ (no regression)
- Parse suite (calc.test_parser): included in 45 — passes ✓ (no regression)
- Eval suite (calc.test_evaluator): 19 tests covering D1D3 ✓
## Cross-feature integration probes (adversarial)
All passed:
- `python calc.py "-6/2"``-3` ✓ (unary minus + whole-float formatting)
- `python calc.py "(-6)/2"``-3`
- `python calc.py "(2*(3+4))"``14` ✓ (nested parens + multiplication)
- `python calc.py "-7/2"``-3.5` ✓ (unary minus + true division)
- `python calc.py "@"` → stderr error, exit 1, no traceback ✓ (LexError path)
## Notes
- Verified from work-adv clone (cold start — no cached pyc state from builder's env).
- JOURNAL not consulted before verdict (isolation maintained).
- `evaluate()` returns Python `int` for integer arithmetic (e.g., `2+3 → int(5)`) — `fmt_result` handles both `int` and `float` correctly.
- Division always returns Python `float` (Python `/` operator), caught by `is_integer()` check.

View File

@ -0,0 +1,13 @@
# REVIEW — Phase `lex`
**Adversary cold-verification record.**
## Status
Awaiting Builder to complete implementation. Per REVIEW CADENCE — DEFERRED rules, comprehensive verification will occur after full build completes.
## Verdicts
_None yet — Builder has not claimed completion._
## Notes
- Seed commit only (61f1ba0) — no implementation present
- Monitoring for Builder commits

View File

@ -0,0 +1,15 @@
# REVIEW — Phase `parse`
**Adversary cold-verification record.**
## Status
DEFERRED — per REVIEW CADENCE rules, comprehensive verification occurs after full build, not per gate.
Builder has not yet implemented the parse phase.
## Verdicts
_None yet — implementation not present._
## Notes
- Monitoring for Builder commits to `calc/parser.py` and `calc/test_parser.py`.
- Per plan: verify using `python -m unittest -q` plus structural AST assertions.
- Key risk: precedence/associativity bug that still passes a weak test — will re-derive expected tree from plan independently.

View File

@ -0,0 +1,118 @@
# REVIEW — Phase `review`
**Adversary cold-verification record.**
## Status
COMPREHENSIVE PASS @2026-06-16T00:21Z — all D1D4 items verified.
---
## D1 — Full cold re-verify (all prior phase DoD items)
Cold-verified from work-adv clone at commit `bfd5972` (post-pull).
### Lexer DoD
- INTEGER: `tokenize('42')``[Token('NUMBER', 42), Token('EOF', None)]`, `value` is `int`
- FLOAT: `tokenize('3.14')``[Token('NUMBER', 3.14), Token('EOF', None)]`
- LEADING DOT: `tokenize('.5')``Token('NUMBER', 0.5)`
- OPERATORS: `tokenize('+-*/()')` → PLUS, MINUS, STAR, SLASH, LPAREN, RPAREN, EOF (correct kinds) ✓
- WHITESPACE: spaces and tabs skipped ✓
- LexError message contains char + position: `unexpected character '$' at position 1`
- Unknown chars `@`, `$`, letters raise `LexError`
**PASS**
### Parser DoD
- Single int: `parse(tokenize('1'))``Num(1)`
- Single float: `parse(tokenize('3.14'))``Num(3.14)`
- BinOp shape: `parse(tokenize('1+2'))``BinOp('+', Num(1), Num(2))`
- Unary shape: `parse(tokenize('-5'))``Unary('-', Num(5))`
- Precedence: `parse(tokenize('2+3*4'))``BinOp('+', Num(2), BinOp('*', Num(3), Num(4)))` (mul binds tighter) ✓
- Left-associativity: `parse(tokenize('1-2-3'))``BinOp('-', BinOp('-', Num(1), Num(2)), Num(3))`
- Empty input: raises `ParseError`
- Unclosed paren `(1+`: raises `ParseError`
- Two numbers adjacent `1 2`: raises `ParseError`
**PASS**
### Evaluator DoD
- Arithmetic: `2+3*4`→14, `(2+3)*4`→20, `8-3-2`→3, `-2+5`→3, `2*-3`→-6 ✓
- True division: `7/2`→3.5 ✓
- Division by zero: `1/0` raises `EvalError("division by zero")`, NOT bare `ZeroDivisionError`
- fmt_result: `fmt_result(2.0)``'2'`, `fmt_result(3.5)``'3.5'`, `fmt_result(42)``'42'`
- CLI: `python calc.py "2+3*4"` → stdout `14`, exit 0 ✓
- CLI: `python calc.py "(2+3)*4"` → stdout `20`, exit 0 ✓
- CLI: `python calc.py "7/2"` → stdout `3.5`, exit 0 ✓
- CLI: `python calc.py "4/2"` → stdout `2`, exit 0 ✓
- CLI error: `python calc.py "1/0"` → stderr `error: division by zero`, exit 1, no traceback ✓
- CLI error: `python calc.py "1 +"` → stderr `error: unexpected token 'EOF' (None)`, exit 1 ✓
**PASS**
---
## D2 — Full suite green
```
python -m unittest -v
Ran 64 tests in 0.002s
OK
```
All 64 tests pass (calc.test_lexer, calc.test_parser, calc.test_evaluator). Zero failures, zero errors.
**PASS**
---
## D3 — Cross-feature break-it
All tests run independently against the actual CLI and Python API:
| Expression | Expected | Actual | Result |
|---|---|---|---|
| `-(-(1+2))` | `3` | `3` | PASS |
| `2+3*4-5/5` | `13` | `13` (raw 13.0, fmt→13) | PASS |
| `--5` | `5` | `5` | PASS |
| `((((3))))` | `3` | `3` | PASS |
| `1+2*3+4*5+6` | `33` | `33` | PASS |
| `( 1.5 + 2.5 ) * 2` | `8` | `8` (raw 8.0, fmt→8) | PASS |
| ` 2.5 + ( 3.5 * 2 ) ` | `9.5` | `9.5` | PASS |
| `(1+2)*(3+4)` | `21` | `21` | PASS |
Error propagation:
| Input | Expected error type | Actual | Result |
|---|---|---|---|
| `1 @ 2` | `LexError` | `LexError: unexpected character '@' at position 2` | PASS |
| `1/0` | `EvalError` | `EvalError: division by zero` (no bare `ZeroDivisionError`) | PASS |
| `(1+` | `ParseError` | `ParseError: unexpected token 'EOF' (None)` | PASS |
| `bad input @#` | CLI exit 1 | `error: unexpected character 'b' at position 0`, exit 1 | PASS |
CLI exit codes:
- Valid expressions → exit 0 ✓
- Invalid expressions (lex/parse/eval errors) → exit 1 ✓
- No tracebacks on errors ✓
Note: `2+3*4-5/5` raw result is `13.0` (float, because `5/5` returns `1.0`), but `fmt_result(13.0)``'13'` — correct behavior.
**No defects found. PASS**
---
## D4 — Findings cleared
No findings were filed. No VETO. Nothing to clear.
**PASS**
---
## OVERALL VERDICT
**review(all): PASS @2026-06-16T00:21Z**
Comprehensive cold-verification of all D1D4 from the review phase plan (covering lex, parse, eval, and CLI) passes in full. 64 unit tests green. All cross-feature integration probes pass. No defects, no VETO.
Builder may now write `## DONE` to STATUS-review.md.

View File

@ -0,0 +1,104 @@
# STATUS — Phase `eval`
## DONE
All D1D5 gates Adversary-verified PASS @2026-06-16T00:18Z (REVIEW-eval.md). No VETO.
## Gate: ALL CLAIMED, awaiting Adversary comprehensive verification
---
## D1 — arithmetic
**WHAT:** `evaluate(parse(tokenize(s)))` is correct for `+`, `-`, `*`, `/`, precedence, parens, and unary minus.
**HOW:**
```bash
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('2+3*4'))))"
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('(2+3)*4'))))"
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('8-3-2'))))"
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('-2+5'))))"
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('2*-3'))))"
```
**EXPECTED:** `14`, `20`, `3`, `3`, `-6`
**WHERE:** `calc/evaluator.py`, `calc/test_evaluator.py::TestArithmetic`
---
## D2 — division
**WHAT:** `/` is true division; division by zero raises `EvalError`, not bare `ZeroDivisionError`.
**HOW:**
```bash
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('7/2'))))"
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate, EvalError
try:
evaluate(parse(tokenize('1/0')))
except EvalError as e:
print('EvalError:', e)
except ZeroDivisionError:
print('FAIL: bare ZeroDivisionError escaped')
"
```
**EXPECTED:** `3.5`; then `EvalError: division by zero`
**WHERE:** `calc/evaluator.py`, `calc/test_evaluator.py::TestDivision`
---
## D3 — result type
**WHAT:** Whole-valued floats display without trailing `.0`; non-whole floats display normally.
**Rule:** `fmt_result(v)` in `calc/evaluator.py`: if `isinstance(v, float) and v.is_integer()``str(int(v))`, else `str(v)`.
**HOW:**
```bash
python calc.py "4/2"
python calc.py "7/2"
```
**EXPECTED:** `2`, `3.5`
**WHERE:** `calc/evaluator.py::fmt_result`, `calc/test_evaluator.py::TestResultType`, `calc.py`
---
## D4 — CLI
**WHAT:** `python calc.py "2+3*4"` prints `14` and exits 0; errors print to stderr and exit non-zero with no traceback.
**HOW:**
```bash
python calc.py "2+3*4" # stdout: 14, exit 0
python calc.py "(2+3)*4" # stdout: 20, exit 0
python calc.py "7/2" # stdout: 3.5, exit 0
python calc.py "4/2" # stdout: 2, exit 0
python calc.py "1/0"; echo "exit:$?" # stderr: error, exit 1
python calc.py "1 +"; echo "exit:$?" # stderr: error, exit 1
```
**EXPECTED:** `14`, `20`, `3.5`, `2`, then error+exit:1, error+exit:1
**WHERE:** `calc.py`
---
## D5 — tests green + end-to-end
**WHAT:** Full unittest suite (lex + parse + eval) passes, 0 failures.
**HOW:**
```bash
python -m unittest -q
```
**EXPECTED:** `Ran 64 tests in X.XXXs\nOK`
**WHERE:** `calc/test_lexer.py`, `calc/test_parser.py`, `calc/test_evaluator.py`
---
## Verification commands (for Adversary cold-verify)
```bash
python -m unittest -q
python calc.py "2+3*4"
python calc.py "(2+3)*4"
python calc.py "7/2"
python calc.py "4/2"
python calc.py "1/0"; echo "exit:$?"
python calc.py "1 +"; echo "exit:$?"
```
---
## Adversary Verdict @2026-06-16T00:18Z
**COMPREHENSIVE PASS — all D1D5 gates verified cold.**
Cold-verified from work-adv clone (commit 21be8f5). Full verdicts in REVIEW-eval.md.
Builder may now write `## DONE` to this file.

View File

@ -0,0 +1,43 @@
# STATUS — phase `lex`
## DONE
All DoD items implemented, tests green (21/21), self-certified per DEFERRED review cadence.
---
## Gates
### D1 — numbers
**WHAT:** Integers and floats tokenize to `NUMBER` tokens with correct Python-typed values.
**HOW:** `python -m unittest -q`
**EXPECTED:** 21 tests, 0 failures
**WHERE:** `calc/lexer.py`, `calc/test_lexer.py`
### D2 — operators & parens
**WHAT:** `+ - * / ( )` each produce correct token kinds.
**HOW:** `python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('3.5*(1-2)')])"`
**EXPECTED:** `[('NUMBER', 3.5), ('STAR', '*'), ('LPAREN', '('), ('NUMBER', 1), ('MINUS', '-'), ('NUMBER', 2), ('RPAREN', ')'), ('EOF', None)]`
**WHERE:** `calc/lexer.py`
### D3 — whitespace & errors
**WHAT:** Spaces/tabs skipped; invalid chars raise `LexError` with char and position.
**HOW:** `python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"` — must raise `LexError`
**EXPECTED:** `calc.lexer.LexError: unexpected character '@' at position 2`
**WHERE:** `calc/lexer.py`
### D4 — tests green
**WHAT:** `calc/test_lexer.py` passes under `python -m unittest`, 0 failures.
**HOW:** `python -m unittest -q`
**EXPECTED:** `Ran 21 tests in X.XXXs\nOK`
**WHERE:** `calc/test_lexer.py`
---
## Verification commands (for Adversary cold-verify)
```bash
python -m unittest -q
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('3.5*(1-2)')])"
python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"
```

View File

@ -0,0 +1,21 @@
# STATUS — Phase `parse` (Adversary tracking)
## Current state
WAITING — Builder has not begun `parse` phase. No `calc/parser.py` or `calc/test_parser.py` exist yet.
## Last checked
2026-06-16T00:12Z — only seed + adversary-init commits present; no implementation.
## Pending verifications
None yet — deferred per REVIEW CADENCE rule.
## AST shape (to be filled by Builder)
_Awaiting Builder to document node shapes in this file._
## DoD tracking (deferred)
- D1 — precedence: NOT VERIFIED
- D2 — left associativity: NOT VERIFIED
- D3 — parentheses: NOT VERIFIED
- D4 — unary minus: NOT VERIFIED
- D5 — errors: NOT VERIFIED
- D6 — tests green: NOT VERIFIED

View File

@ -0,0 +1,116 @@
# STATUS — Phase `review`
## DONE
All D1D4 gates Adversary-verified PASS @2026-06-16T00:21Z (REVIEW-review.md). No VETO.
## Gate: D1-D3 CLAIMED — Adversary comprehensive PASS received
The full calculator accumulation (lex + parse + eval + CLI) is complete and self-certified.
The Adversary should cold-verify D1D3 from a fresh clone and record findings in REVIEW-review.md.
---
## D1 — Full cold re-verify
**WHAT:** From a fresh clone, re-run all DoD items from lex, parse, and eval phases.
**HOW:**
```bash
# Clone fresh and run from work dir
python -m unittest -q
# Lexer DoD: tokenize produces correct token lists
python -c "from calc.lexer import tokenize; print(tokenize('2+3*4'))"
python -c "from calc.lexer import tokenize; print(tokenize('-2'))"
python -c "from calc.lexer import tokenize; print(tokenize('3.14'))"
# Parser DoD: AST shape is correct
python -c "from calc.lexer import tokenize; from calc.parser import parse; import json; ast = parse(tokenize('1+2*3')); print(ast)"
# Evaluator DoD: arithmetic + division + result type
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('2+3*4'))))"
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('(2+3)*4'))))"
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('8-3-2'))))"
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('-2+5'))))"
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('2*-3'))))"
python -c "from calc.lexer import tokenize; from calc.parser import parse; from calc.evaluator import evaluate; print(evaluate(parse(tokenize('7/2'))))"
# CLI DoD
python calc.py "2+3*4"
python calc.py "(2+3)*4"
python calc.py "7/2"
python calc.py "4/2"
python calc.py "1/0"; echo "exit:$?"
python calc.py "1 +"; echo "exit:$?"
```
**EXPECTED:**
- `python -m unittest -q``Ran 64 tests in X.XXXs\nOK`
- Tokenizer outputs correct token lists
- AST shape is `BinOp(+, Num(1), BinOp(*, Num(2), Num(3)))`
- `2+3*4``14`, `(2+3)*4``20`, `8-3-2``3`, `-2+5``3`, `2*-3``-6`, `7/2``3.5`
- CLI: `14`, `20`, `3.5`, `2`, then `error: division by zero` + exit:1, `error: unexpected token 'EOF'` + exit:1
**WHERE:** `calc/lexer.py`, `calc/parser.py`, `calc/evaluator.py`, `calc.py`
---
## D2 — Full suite green
**WHAT:** `python -m unittest` passes, 0 failures, 64 tests.
**HOW:**
```bash
python -m unittest -q
```
**EXPECTED:** `Ran 64 tests in X.XXXs\nOK`
**WHERE:** `calc/test_lexer.py`, `calc/test_parser.py`, `calc/test_evaluator.py`
---
## D3 — Cross-feature break-it
**WHAT:** Specific cross-feature interactions verified.
**HOW:**
```bash
# Nested unary + parens
python calc.py "-(-(1+2))"
# Precedence chain
python calc.py "2+3*4-5/5"
# Error propagation: lexer→evaluator
python calc.py "1 @ 2"; echo "exit:$?"
python calc.py "1/0"; echo "exit:$?"
python calc.py "(1+"; echo "exit:$?"
# Whitespace + floats + parens
python calc.py " 2.5 + ( 3.5 * 2 ) "
python calc.py "( 1 + 2 ) * ( 3 + 4 )"
# CLI exit codes
python calc.py "2+3*4"; echo "exit:$?"
python calc.py "bad input @#"; echo "exit:$?"
```
**EXPECTED:**
- `-(-(1+2))``3`
- `2+3*4-5/5``13`
- `1 @ 2` → stderr `error: unexpected character '@'`, exit:1
- `1/0` → stderr `error: division by zero`, exit:1
- `(1+` → stderr `error: unexpected token 'EOF'`, exit:1
- `2.5 + (3.5 * 2)``9.5`
- `(1+2)*(3+4)``21`
- valid input → exit:0; invalid input → exit:1
**WHERE:** `calc/lexer.py`, `calc/parser.py`, `calc/evaluator.py`, `calc.py`
---
## Builder self-verification @2026-06-16
All cross-feature tests above run locally and produce the expected outputs. See JOURNAL-review.md for exact output transcript.