Skip to content

docs(#49): name and document the 20-loop hard cap (MAX_LOOPS)#234

Open
obanai9 wants to merge 1 commit into
Dgetsylver:mainfrom
obanai9:feat/49-loop-cap-docs
Open

docs(#49): name and document the 20-loop hard cap (MAX_LOOPS)#234
obanai9 wants to merge 1 commit into
Dgetsylver:mainfrom
obanai9:feat/49-loop-cap-docs

Conversation

@obanai9

@obanai9 obanai9 commented Jun 1, 2026

Copy link
Copy Markdown

Summary

Implements issue #49 — D8: Document (and name) the 20-loop hard cap.

  • constants.rs: new MAX_LOOPS: u32 = 20 with a full rationale comment (Soroban instruction budget, diminishing returns, safety-ceiling vs. operator knob).
  • leverage.rs: loop_step_count uses MAX_LOOPS + 1 instead of bare 21; doc-comment references all three reasons.
  • README.md (new): module-level strategy documentation including a loop-progression table, full loop-cap rationale, init-arg reference, and key-invariants summary.

Test plan

  • cargo test -p blend_leverage_strategy — existing unit tests pass with the renamed constant.
  • Confirm loop_step_count behaviour is unchanged (same numeric result, now via MAX_LOOPS + 1).

Closes #49

🤖 Generated with Claude Code

Introduces `MAX_LOOPS: u32 = 20` in constants.rs with a full rationale
comment (instruction budget, diminishing returns, safety ceiling). Updates
`loop_step_count` to reference the constant instead of bare 21. Adds a
module-level README with a loop-progression table and init-arg reference.

Closes Dgetsylver#49

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Dgetsylver

Copy link
Copy Markdown
Owner

Good write-up — the rationale and the math in the README check out, and the loop_step_count refactor is behavior-identical. One blocker:

  • The docs claim validation that doesn't exist. The doc comment says target_loops is "validated at init, must be ≤ MAX_LOOPS" and the README repeats it, but __constructor performs no bounds check — oversized values are only silently clamped at loop time. Preferred fix: actually add the init-time assertion (target_loops <= MAX_LOOPS), which is also closer to the issue's intent. Otherwise correct the wording.

Also note: the README documents the [8] admin init arg and pause API from #232, which isn't merged. Either gate this on #232 or split those sections out so the README never documents nonexistent features.

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.

D8: Document (or parameterize) the 20-loop hard cap

2 participants