Generated output under .ruler is recursively re-consumed and grows exponentially
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:
- reject or warn on an
output_paththat resolves within the active.ruler/source directory, or - 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