Skip to content

[P1] Bound compiler nesting and return stable resource-limit diagnostics #64

Closed

Description

@AetherAI3

Reproduced defect

At main d740bb530262c1c76a2b18c8a8aa47476f8b6b96, a roughly 256-character program with 100 parenthesis levels raises RecursionError in both compile_to_dict() and editor diagnostics(); 25 and 50 levels compile in the same environment.

source = ("strategy Deep { every 1m { if " + "(" * 100
          + "RSI < 30" + ")" * 100 + " { observe() } } }")

Sources: recursive parser, compiler errors, editor diagnostic contract. This is independent of #55's version-selection fix.

Work packet

Introduce explicit deterministic parser resource limits, starting with nesting depth and a positioned resource-limit error. Specify whether budgets also cover source bytes, token count and emitted nodes, using clear defaults and documented host configuration where appropriate.

Do not mutate Python's process-global recursion limit or hide arbitrary internal exceptions under a generic syntax error. Reject over-budget programs before exhausting the call stack; use iterative parsing where it materially simplifies the bound.

Acceptance

  • Exact-limit and one-over tests for parentheses, unary expressions, nested conditionals and long boolean chains.
  • Stable error code, actual source position and actionable limit diagnostic; CLI and editor agree.
  • No RecursionError for bounded adversarial/generated fixtures.
  • Valid corpus semantics, canonical bytes and existing error positions remain unchanged.
  • Benchmark worst-case admitted parse time/memory and publish the tested limits; no speculative performance claims.
  • Extend existing compiler fuzzing with these boundary cases.

Delivery

One focused main-based parser/error PR first; expand other budgets in separate PRs if necessary. #65-style machine-readable diagnostics can consume the error later, but this fix must not wait for an entire new frontend. No model/hardware use.

Activity

  1. AetherAI3 commented on Nov 1, 2026

    @AetherAI3
    OwnerAuthor

    Implementation is reviewable in #73 (main-based, head 643cf5f698c5f95609bc84374e055dd2b8656c68). This issue remains open pending review and merge under #67.

    Evidence:

    • Frozen-tree Python 3.11.9 reference suite: 1510 passed, 7 skipped (py -3.11 -m pytest -q, 300.47s).
    • 59 dedicated limit tests cover exact/one-over parentheses, unary forms, conditionals and boolean chains; calls/index/member/arithmetic and 10,000-level adversaries; compiler/CLI/editor position agreement.
    • scripts/compiler_fuzz.py --refs HEAD --cases 256: five hash-seed workers, zero defects, stable corpus/semantic digests. Each worker also ran 30 resource-boundary cases / 156 adapter checks.
    • Existing valid compiler/library/editor/conformance corpus remains compatible; contribution checker reports 55 entries ready for review.
    • Independent review and 61 mixed-depth probes found no unexpected exceptions. Measured parse time and peak traced allocations are published with scripts/compiler_limits_benchmark.py in docs/compiler-limits.md.

    Contract for dependent lanes: stable RESOURCE_LIMIT, exact 1-based source position, resource name and configured limit; default/tested maximum nesting 32; hosts may lower it with explicit frozen CompilerLimits. Source bytes, total tokens and emitted nodes are not budgeted in this focused PR. No recursion-limit mutation, model/provider execution or hardware use.

    Hosted CI did not run: check annotations report that the GitHub account is locked due to a billing issue. The cross-version CI matrix is therefore unverified; the PR does not claim it passed. #65 is being built as a separate reviewable stack on this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions