Files
agent-orchestrator-benchmark/calculators/builder-adversary-lean/run-05/machine-docs/REVIEW-parse.md

3.5 KiB

REVIEW — parse phase (Adversary)

Status

All six gates verified PASS. No defects found. No veto.

Gate verdicts

parse/D1: PASS @2026-06-15T06:13:00Z

Evidence (cold run):

BinOp('+', Num(1), BinOp('*', Num(2), Num(3)))    # 1+2*3
BinOp('+', BinOp('*', Num(2), Num(3)), Num(1))    # 2*3+1
BinOp('-', Num(5), BinOp('*', Num(2), Num(3)))    # 5-2*3
  • *// bind tighter than +/- in all three forms ✓
  • _term() loop handles STAR/SLASH before _expr() handles PLUS/MINUS

Adversarial probes (all correct):

  • 1+6/2BinOp('+', Num(1), BinOp('/', Num(6), Num(2)))
  • 2*3+4*5BinOp('+', BinOp('*', Num(2), Num(3)), BinOp('*', Num(4), Num(5)))
  • 10-2*3+1BinOp('+', BinOp('-', Num(10), BinOp('*', Num(2), Num(3))), Num(1))

parse/D2: PASS @2026-06-15T06:13:00Z

Evidence (cold run):

BinOp('-', BinOp('-', Num(8), Num(3)), Num(2))    # 8-3-2
BinOp('/', BinOp('/', Num(8), Num(4)), Num(2))    # 8/4/2
  • Both levels associate left via while loops in _expr() and _term()

Adversarial probes (all correct):

  • 1+2+3BinOp('+', BinOp('+', Num(1), Num(2)), Num(3))
  • 1-2+3BinOp('+', BinOp('-', Num(1), Num(2)), Num(3))

parse/D3: PASS @2026-06-15T06:13:00Z

Evidence (cold run):

BinOp('*', BinOp('+', Num(1), Num(2)), Num(3))    # (1+2)*3
BinOp('*', Num(1), BinOp('+', Num(2), Num(3)))    # 1*(2+3)
  • _primary() calls _expr() recursively on paren contents ✓

Adversarial probes (all correct):

  • ((1+2))*3BinOp('*', BinOp('+', Num(1), Num(2)), Num(3))
  • (2*(3+4))BinOp('*', Num(2), BinOp('+', Num(3), Num(4)))

parse/D4: PASS @2026-06-15T06:13:00Z

Evidence (cold run):

Unary('-', Num(5))                          # -5
Unary('-', BinOp('+', Num(1), Num(2)))     # -(1+2)
BinOp('*', Num(3), Unary('-', Num(2)))     # 3 * -2
  • _factor() recurses for unary minus; _term() calls _factor() so unary applies at factor level ✓

Adversarial probes (all correct):

  • --5Unary('-', Unary('-', Num(5))) ✓ (double unary via recursion)
  • -(2*3)Unary('-', BinOp('*', Num(2), Num(3)))
  • 1 - -2BinOp('-', Num(1), Unary('-', Num(2))) ✓ (binary then unary)
  • -1 + 2BinOp('+', Unary('-', Num(1)), Num(2))

parse/D5: PASS @2026-06-15T06:13:00Z

Evidence (cold run) — all five required cases raise ParseError, not LexError/IndexError/etc.:

OK: '1 +' -> ParseError: unexpected token 'EOF'
OK: '(1'  -> ParseError: unclosed parenthesis, got 'EOF'
OK: '1 2' -> ParseError: unexpected token 'NUMBER'
OK: ')('  -> ParseError: unexpected token 'RPAREN'
OK: ''    -> ParseError: empty input

Adversarial error probes (all raise ParseError cleanly):

  • '5 *' → ParseError: unexpected token 'EOF' ✓
  • '()' → ParseError: unexpected token 'RPAREN' ✓
  • '+5' → ParseError: unexpected token 'PLUS' ✓ (unary plus unsupported)
  • '1++2' → ParseError: unexpected token 'PLUS' ✓
  • '1 2 3' → ParseError: unexpected token 'NUMBER' ✓
  • '((1)' → ParseError: unclosed parenthesis, got 'EOF' ✓

parse/D6: PASS @2026-06-15T06:13:00Z

Evidence (cold run):

----------------------------------------------------------------------
Ran 48 tests in 0.001s

OK

python -m unittest -q — 48 tests (24 parser + 24 lexer), 0 failures, 0 errors ✓


Probes run (independent / adversarial)

All probes ran from cold start in Adversary's own clone (work-adv/).

No defects found. No veto.