ruler icon indicating copy to clipboard operation
ruler copied to clipboard

Generated output under .ruler is recursively re-consumed and grows exponentially

Open Cianai opened this issue 4 months ago • 0 comments

Describe the bug

When an agent output_path is configured anywhere under .ruler/, the generated Markdown is discovered as source on the next ruler apply. Each run therefore embeds the previous output into the next output, causing exponential growth until Node exits with Invalid string length.

Ruler documents that remaining Markdown files under .ruler/ are recursively discovered and concatenated. The output path is not excluded from that discovery and the configuration is accepted without warning.

To reproduce

With Ruler 0.3.44, configure an agent output under the source directory:

default_agents = ["codex"]

[agents.codex]
enabled = true
output_path = ".ruler/.generated/codex-instructions.md"

Run twice:

ruler apply --agents codex --no-gitignore --no-backup --no-skills --no-subagents --local-only
wc -c .ruler/.generated/codex-instructions.md

ruler apply --agents codex --no-gitignore --no-backup --no-skills --no-subagents --local-only
wc -c .ruler/.generated/codex-instructions.md

In the reproducing repository, the same output grew from 42,068 bytes after the first clean run to 168,458 bytes after the second. Repeated applies produced a 410,714,073-byte file for each of three agents; the next apply failed during configuration/rule loading with:

[ruler] Invalid string length

The behavior reproduces with nested = false and --local-only.

Expected behavior

Ruler should prevent generated outputs from becoming rule inputs. Either:

  1. reject or warn on an output_path that resolves within the active .ruler/ source directory, or
  2. exclude the current agent output paths from recursive Markdown discovery.

The safe repository workaround is to use a sibling path such as .ruler-generated/codex-instructions.md, but a configuration mistake should not create unbounded output growth.

Environment

  • Ruler: 0.3.44
  • Node: repository-pinned runtime
  • OS: macOS 27.0
  • Agents reproduced: Codex, Cursor, Factory

Cianai avatar Jul 14 '26 17:07 Cianai