Skip to content

Raise emitter runtime recursion depth - #22

Merged
chris-dare-dev merged 3 commits into
mainfrom
agent/emitter-max-rec-depth
Sep 20, 2026
Merged

chris-dare-dev merged 3 commits into
mainfrom
agent/emitter-max-rec-depth

Conversation

@chris-dare-dev

@chris-dare-dev chris-dare-dev commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • remove the recursion ceiling only inside the emitter's fresh runtime context
  • keep elaboration options and emitted option claims unchanged
  • allow finite deeply nested categorical declaration values to be traversed and pretty-printed completely
  • document that the no-limit sentinel removes Lean's logical recursion guard and can still exhaust the native stack

Verification

  • LEAN_NUM_THREADS=2 lake build MathFormalContract.Emit

Motivation

The downstream derived-alg-geo-lean environment builds successfully, but three combined-emission CI runs exited with maximum recursion depth has been reached after the previous finite increase to 10000. Any finite emitter depth becomes an input-size completeness ceiling: on failure no artifact is written, so the downstream vacuous-pass guard cannot evaluate the build at all.

This override belongs only to the emitter's fresh process. A process failure remains possible and explicit; no partial artifact is accepted.

Setting `maxRecDepth := 0` on the emitter's `Core.Context` was correct in
intent and had no effect. `emitOne` renders every type and every def body
inside `withOptions (fun _ => ppOpts)`, and `Core.withOptions` rebuilds the
context field from the options it is handed:

    maxRecDepth := maxRecDepth.get options

`ppOpts` deliberately discards ambient options, so that recomputation restored
the option default for exactly the `PrettyPrinter.ppExpr` call that overflows.
Measured rather than assumed: `maxRecDepth.get ({} : Options)` is 512, while
the `Core.Context` field it replaces defaults to 1000 -- entering the block did
not merely fail to raise the depth, it lowered it.

The evidence that the previous commit did not work is direct: a
derived-alg-geo-lean CI run whose log shows `MathFormalContract: checking out
revision 'b90d0d97'`, built fresh, still died with `mfc-emit: maximum
recursion depth has been reached`.

Set through the registered option's own `set` rather than a quoted key, so it
uses the same accessor `Core.withOptions` reads it back with. The context-level
setting stays: it covers the traversal outside the pretty-printing block.

`ppOptsJson` gains the matching entry, because that record exists so the
artifact cannot claim a setting the emitter did not use. The emission schema
already admits integer `pp_options` values, so no schema change is needed.
@chris-dare-dev
chris-dare-dev force-pushed the agent/emitter-max-rec-depth branch from ed71fbb to fb4de1b Compare September 20, 2026 02:12
@chris-dare-dev
chris-dare-dev merged commit bda0e61 into main Sep 20, 2026
5 checks passed
@chris-dare-dev
chris-dare-dev deleted the agent/emitter-max-rec-depth branch September 20, 2026 02:16
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