Skip to content

v0.1.0

Latest

Choose a tag to compare

@github-actions github-actions released this 29 Oct 07:43
· 4 commits to main since this release

The first real evaluator: P1 slice 1, the pricing set. Verified against
fancy-conformance 0.39.0's Google Sheets goldens: all 482 rows in scope pass,
and 205 rows for slice-2 functions are skipped, each with a stated reason.
Coming from 0.0.1: StubEngine is unchanged; construct Engine instead for
real results (new Engine() works with defaults). A function outside the slice
reports FORMULA_UNKNOWN_FUNCTION at check; it is never silently wrong.

Added

  • Formula::parse($source, $maxBytes = 8192, $maxDepth = 64) with
    ->normalized(), ->ast(), ->references() and ->spans(). The full
    grammar of SPEC.md section 3: references with and without sheets, quoted
    sheets, open ranges (B:B, 1:1), array literals (references allowed
    inside, H-21), empty arguments (INDEX(r,,1)), postfix % once, and LET,
    LAMBDA and an immediate LAMBDA invocation as syntax nodes. Malformed input
    throws FormulaError with FORMULA_SYNTAX, FORMULA_TOO_LONG (UTF-8 bytes,
    before lexing) or FORMULA_TOO_DEEP (fancy-expr's depth definition, checked
    on the way down and up) and a byte offset.
  • Confirmed by the partial first capture and pinned: unary minus binds before
    ^ (=-2^0.5 is #NUM!), and =10%% is FORMULA_SYNTAX.
  • #NULL! and #ERROR! are error literals (the capture decided H-16).
  • FancyFormula\Engine: the first real evaluator (SPEC.md section 15 lists
    slice 1). check() returns a CheckReport, evaluate() an Evaluation;
    both have toArray(), and json_encode() of either is the schema-valid JSON.
    Engine::ENGINE is fancy-formula 0.1.0.
    • Typed, value-only inputs bound to names or cells; constraint validation of
      the supplied values BEFORE any formula runs, in the canonical order with
      the caps; topological evaluation with lazy IF, IFS, SWITCH, IFERROR, IFNA,
      LET and CHOOSE; the step, range, text, cell and wall-clock budgets with
      typed aborts; the float policy (one comparator, 15-digit decimal rounding,
      half away from zero); date serials; traces at none, lookups and full
      with the lookup bracket and probes; the fingerprint;
      Engine::functions().
    • check() diagnostics: unknown function (naming a later slice when it is
      one) or name, circular references with the cycle path, arity, type,
      refused, needs clock, needs seed, input invalid, dynamic reference, and
      the declared shape of every constraint.
  • Host construction, the contract Prism codes against (SPEC.md 1.1):
    new Engine(new Options(limits:, clock:, random:, providers:, functions:)),
    every argument optional. New Clock interface with FixedClock, Seed,
    FunctionPolicy (all(), only(), ->deny()), ExternalProvider with
    ProviderContext, CheckReport, Evaluation. Provider calls are recorded in
    the trace's external list and folded into the fingerprint.
  • StubEngine is kept, unchanged, for hosts built against 0.0.1.
  • The Google Sheets goldens run in CI. Dev dependency
    particle-academy/fancy-conformance pinned EXACTLY at 0.39.0 (first party),
    asserted by a test as in fancy-expr. All 13 formula/* suites run: 482 rows
    in slice 1 pass; 205 are skipped, each with a reason naming slice 2, decided
    from the formula text and never from the engine's output. Four rows whose
    golden is lossier than its declared tolerance (two 10-digit values, two tiny
    values exported as 0) are still asserted, at the precision the export kept.

Changed

  • SPEC.md section 13 records the capture's verdict on every hypothesis:
    CONFIRMED, REFUTED, or OPEN (only where its rows need a slice-2 function).
    Refuted, and the engine now follows Sheets: ^ is right-associative
    (=2^3^2 is 512); there is no near-zero snap in + and -; INDEX and
    CHOOSE out of range are #NUM! (MOIC's case F is #NUM!, not #REF!); an
    omitted IFERROR fallback is EMPTY; open ranges span the 1000 x 26 grid;
    numbers from 1E+15 convert to text in full decimal, truncated past the 15th
    digit; approximate lookups order raw doubles. SPEC.md section 2 names the two
    deliberate divergences: a Sheets #ERROR! parse error is our
    FORMULA_SYNTAX, a Sheets #N/A wrong argument count our FORMULA_ARITY.

Fixed

  • The trace schema's VLOOKUP and SUMIF examples had a span ending one byte
    past the end of their own formula ([1, 37] on a 36-byte formula). They are
    now [1, 36] and [1, 29], and a test holds every example's spans inside
    its formula. Examples only; no shape changed.