Skip to content

Divergence: py 0.2.x parser accept/reject boundary differs from ruby/ts/rs in both directions (fuzz, ~130 cases) #293

Closed

Description

@ronaldtse

Summary

The py runtime's .isc parser (origin/main 0.2.x rewrite) diverges from ruby/ts/rs on the parse accept/reject boundary in BOTH directions — it accepts constructs the other three reject, and rejects constructs the other three accept. Found by the WO20 differential fuzz campaign (#284): ~130 of 1600 cases across these families.

A. py accepts what ruby/ts/rs reject (~88 cases)

  1. Nested parallel inside sequence — the docs/parity pinned negative probe (rejected 4/4 on the audited trees):
system "T:fz-em7:1" {
  stage main {
    sequence {
      sub "a" "b"
      parallel {
        sub "c" "d"
      }
    }
  }
}

py: accepts (and executes ab->bb); ruby/ts/rs: parse-reject.

  1. Unknown/misplaced keywords and malformed escapes in rule position: ruby rejects with "expected one of ['n','r','t','"','\','u'...]" (escape grammar) or "expected 'sequence'/'parallel'/'run'/'before'/'after'..." (keyword position) — py accepts and continues. 30 of the 88 cases carry no WF-1 token at all; they are pure grammar-strictness drift.

  2. ruleset inside metadata { }: py rejects, ruby/ts/rs accept — py is the strict one here, but note the other three ACCEPTING a ruleset inside metadata is itself suspect (three-way laxness vs py).

B. py rejects what ruby/ts/rs accept (~43 cases)

  1. Zero-width primitives in compound from expressions:
system "T:350509:1" {
  stage main {
    sequence {
      sub {
        from word_boundary + capture(some("z")) + word_boundary
        to "W" + ref(1)
        not_before "j"
        not_after "k"
      }
    }
  }
}

py: parse-reject UnsupportedConstruct: primitive word_boundary; ruby/ts/rs: parse-accept (then fail at execution with named logic errors — its own parse/exec boundary question, see docs/parity G-rows).

  1. run stage.<x> recursion: py rejects with a NAMED UnsupportedConstruct: cyclic run stage.main (the only runtime that guards it); ruby/ts/rs crash — split into the dedicated self-run divergence issue.

Behavior matrix (representatives)

case ruby ts py rs
nested par-in-seq reject reject accept reject
ruleset in metadata accept accept reject accept
unknown keyword in item position reject reject accept reject
malformed escape in rule string reject reject accept (or crash, separate issue) reject
zero-width prim in from expr accept accept reject (UnsupportedConstruct) accept

Classification

Divergence, py side. The parse boundary (what is ISC and what is not) should be one grammar; today py's rewrite accepts a different language than the other three in both directions. Canonical reference: the ruby concern grammar / vendored isc.parg (docs/parity audit method), with the pinned negative probe (nested blocks rejected 4/4 at audit time).

Related py-side issues: escape crash (#44), parse hang (#43).

Activity

  1. added
    divergence
    on Nov 16, 2026
  2. ronaldtse commented on Nov 21, 2026

    @ronaldtse
    ContributorAuthor

    Fix state: py leg in review — interscript/interscript-py#46

    Re-probed every family against fresh origin/main trees of all four runtimes today (2026-11-21) before writing any code. Correction to the earlier "re-verified closed" claim that circulated for this issue: py origin/main was still divergent on every family below — the grammar-sync work that was believed to have closed them had not landed in the py repo (the claimed regression pins, e.g. tests/test_isc_parser.py::TestParseBoundaryFuzzFamilies, do not exist on any py branch). The only post-campaign py fixes that did land are #43 (truncated-map termination) and #44 (named \u escape errors) via #45.

    Aligned in interscript/interscript-py#46 (each family as a class, pinned in tests/test_isc.py; probes through the campaign drivers land in the same bucket as ruby/ts/rs after the fix):

    # family fuzz-time py trio (fresh mains today) py after #46
    A nested parallel inside sequence accepts (absorbs the block's rules) reject (pinned negative probe) reject
    B unknown keyword in stage-item/rule position silently drops reject reject
    C malformed simple escapes ("a\q") accepts (letter passes through) reject reject
    D zero-width primitive in compound from rejects at conversion parse-accept, named exec error parse-accept, named exec error
    E ruleset inside metadata was: reject — inverted since: py's generic-field fallback swallowed the line as a string value; the trio reject reject reject
    F content after the system block (found while probing A: a mis-scoped metadata block made the trio reject where py silently truncated) silently truncates reject reject

    Also pinned in #46: the maps#294 self-run repro (py's cycle guard predates the campaign; the pin joins the existing mutual-cycle test).

    Corpus safety: full 457-map parse sweep on a pristine py origin/main worktree vs the fix branch — identical failure sets (419 OK / 38 pre-existing failures, zero diff); full suite 110 passed.

    Observed, not touched (owner-facing): py 0.2.x has no WF-1 use/ruleset expansion at all (document-level ruleset blocks reject "Unexpected keyword: ruleset"; stage/block-level use lines are skipped) — a larger gap than the filed families, kept at prior behavior in #46. The 38 pre-existing corpus failures (funcall stage items, %-escape note text) are unchanged.

    The issue closes when #46 merges (py is the only divergent runtime, so that merge completes the fix set).

  3. ronaldtse commented on Nov 21, 2026

    @ronaldtse
    ContributorAuthor

    Complete — py#46 merged, py was the only divergent runtime. Fixed as classes against the vendored grammar: nested-block-in-rule absorption (the in-loop 'Parslet drops tokens' parity claim was false — ruby rejects), unknown keywords now named errors, malformed escapes rejected at position, zero-width-from deferred to the named unsupported-op path, ruleset-in-metadata aligned to the trio's reject (issue premise inverted — py was the lax one), plus a NEW class found while probing: isc_source not anchored at end-of-input (silent truncation). Pins per family; suite 110/0; corpus sweep zero-diff.

  4. ronaldtse commented on Nov 23, 2026

    @ronaldtse
    ContributorAuthor

    parity-G7 contract record: duplicate ruleset declaration is a load error — all four runtimes now agree

    Closing the loop on the G7 case class from the WO20 fuzz campaign (classifier: scripts/fuzz/classify.mjs duplicateRuleset — ruleset <ident> declared more than once in one document). The contract was ruled in the WO18 G7 round; this comment records the ruling and its final four-runtime state, probed today (2026-11-23) on fresh origin/main clones of all four runtimes with the parity probes docs/parity/probes/maps/tst-rsdupdef.isc (P6c: use inside a sequence block) and tst-rsdup2.isc (P6d: stage-level use).

    Contract

    A ruleset declared more than once in a document is a named load error — not keep-first, not last-wins, not merge.

    Rationale (consistency with the nearest analogous case, never invented semantics):

    • Spec §3.2 / §6 item 4 already make use cycles a load-time named error. A duplicate declaration is the same ruleset-table integrity violation one step milder; the parity audit (maps#275, G7 section) proposed extending it.
    • Keep-first (ruby/ts pre-fix) silently hides map bugs: the executed body depends on declaration order that the map author cannot see.
    • Last-wins/merge (rs pre-fix; py 0.2.x's {r["name"]: r["body"]} table overwrite) makes expansion order-dependent — the P6c probe executed content from both definitions under the old rs merge (1yz).
    • The spec nowhere defines first-wins/last-wins/merge semantics for duplicate declarations, so no majority-behavior contract is available — fail-loud is the only semantics consistent with the document's intent.

    Four-runtime state (measured today, fresh mains)

    runtime behavior message where
    ruby rejects at build, both probes Interscript::MapLogicError: ruleset "a" declared more than once in … lib/interscript/isc/document_builder.rb (ruby#854)
    ts rejects at expansion, both probes ISC load error: ruleset "a" declared more than once in T:tst-rsdupdef:1 src/isc/expand.ts (ts#138)
    rs rejects at builder, both probes map logic error: ruleset "a" declared more than once in … src/builder.rs (rs#19)
    py was the sole outlier: accepted with last-def-wins (xz → x3 on P6c/P6d) — the 0.2.x parser rewrite lost the 0.1.0 check that the WO18 round cites as canon now rejects: UnsupportedConstruct: ruleset "a" declared more than once in T:tst-rsdupdef:1 (py's named-load-error family, same class as its cycle/unknown-ruleset rejections) restored in interscript/interscript-py#51 at the ruleset-table build in src/interscript/isc.py, dep documents checked in _owner_rulesets

    Regression pins: ruby spec/interscript/isc/wf1_semantics_spec.rb, ts test/isc/wf1.test.ts, rs tests/wf1.rs::duplicate_ruleset_is_a_load_error, py tests/test_wf1.py::test_duplicate_ruleset_declaration_is_a_named_load_error (both block-use and stage-level-use forms).

    Scope notes

    • The case class is ruleset declarations only. Duplicate sub rows inside a parallel block are a different, already-agreed case: last-wins, pinned in rs tests/corpus/rs-parallel-tree.isc ("duplicate from keys are LAST-WINS").
    • docs/parity/README.md's G7 section describes the 2026-11-13 audit state ("only py rejects") — both halves are now stale: all four runtimes reject, and the divergent runtime of record today was py. The canonical line in that section (py's fail-loud) is confirmed as the contract.
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

    divergence

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions