Skip to content

Add recursively productive imperative Mesopy synthesizer - #50

Draft
sileod wants to merge 5 commits into
mainfrom
chatgpt/imperative-mesopy
Draft

Add recursively productive imperative Mesopy synthesizer#50
sileod wants to merge 5 commits into
mainfrom
chatgpt/imperative-mesopy

Conversation

@sileod

@sileod sileod commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Replaces the initial finite phenomenon composer in this PR with a task-agnostic, recursively productive Python AST synthesizer under reasoning_core/resources.

Design:

  • recursive expression synthesis (binary, ternary, safe indexing, helper calls)
  • recursive statement/control-flow synthesis (if, for, while) under explicit depth budgets
  • helper call graphs whose depth scales with complexity
  • generated-program recursion with a decreasing ranking argument for runnable programs
  • input-controlled RecursionError using the same recursive helper for failing runnability cases
  • explicit multidimensional complexity control via MesopyComplexity: statements, expression depth, control depth, functions, call depth, dataflow depth, loop bound
  • structural features (ast_nodes, AST depth, control depth, call depth, loops, branches, calls, dataflow depth) for profiling/complexity tasks
  • opt-in dynamic line-step profiling so ordinary generation does not pay tracing overhead
  • all controlled-code-execution phenomena remain requestable, plus recursion/comprehension/mapping/helper/control-flow phenomena

Runnability anti-shortcut behavior:

  • paired samples use identical source with one successful and one failing call
  • supports IndexError, ZeroDivisionError, ValueError, KeyError, and RecursionError
  • the same hazard families also occur in successful execution samples via safe_hazard_rate, so suspicious syntax is not itself a label

Productivity tests compare complexity levels 0, 3, and 6 and require increasing median AST size plus increased AST/control/call/dataflow depth. The generator is therefore not just concatenating from a finite segment catalogue; expression and control-flow constructors recurse as budget increases.

Local stress/benchmark results on this implementation:

  • 1,000 executable samples: no generation failure
  • 500 paired-runnability samples: no generation failure
  • default executable generation: ~245 samples/s before the extra semantic relevance experiment; ~200+/s in the stricter local variant
  • default paired runnability: ~178 pairs/s before the extra semantic relevance experiment; ~130+/s in the stricter local variant
  • complexity level 6 executable generation: ~50 samples/s before the extra semantic relevance experiment
  • targeted regression suite: 7 passed locally

CI tests use deliberately loose performance limits (100 executable samples < 3 s, 50 paired samples < 3 s) to detect regressions without encoding machine-specific benchmark numbers.

This PR intentionally only adds the reusable resource and its tests. Migrating controlled_code_execution, code_execution, runnability, and profiling tasks can be reviewed separately against this common generator distribution.

@sileod sileod changed the title Add imperative Mesopy program synthesizer Add recursively productive imperative Mesopy synthesizer Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant