Resolve input-derived security timeframes before evaluator setup#56
Merged
Conversation
request.security / request.security_lower_tf timeframe expressions are emitted into configure_security_evaluators(), which runs once before the first on_bar(). A timeframe expression whose input-derived variable sat inside a BinOp, UnaryOp, FuncCall, or ternary CONDITION was rendered as the raw class member — still its C++ default at that point — so the conditional took the wrong branch and registered the security at the wrong timeframe. Directly-assigned input variables already resolved; the leaf-inside-subtree case did not. The same defect made the ctx_*_in override condition read the member, silently ignoring non-default overrides. The timeframe renderer now substitutes input-derived leaves anywhere in the expression tree with their input getter calls (known strings fold to literals; timeframe.period folds to the script timeframe; unchanged subtrees return the same object, keeping unaffected output byte-identical). Genuinely per-bar series-derived timeframe leaves are intentionally left as members — a documented residual pending an engine-side input-init prologue. Exemplar: an MTF confluence strategy registered its direction gates one timeframe level too fast (15/60/1 instead of 60/240/5), firing 266 phantom entries; fixed it converges to an exact 307/307 TV match (weak 69.5 -> excellent 100). Differential transpile: 0 of 23 corpus and 140 of 143 private security strategies byte-identical; the other two changed strategies are behavior-neutral at default inputs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Security timeframe expressions are emitted into
configure_security_evaluators(), which runs before the firston_bar(). An input-derived variable sitting inside a BinOp/UnaryOp/FuncCall/ternary condition was rendered as the raw member — still its C++ default at setup — so conditionals likemode=="15" ? "240" : "60"took the wrong branch and registered the wrong timeframe (directly-assigned input vars already resolved; subtree leaves did not). The same defect silently ignored non-defaultctx_*_inoverrides.Fix: the timeframe renderer substitutes input-derived leaves anywhere in the tree with their input getter calls; unchanged subtrees return the same object (unaffected output byte-identical). Series-derived timeframe leaves intentionally untouched (documented residual pending an engine-side input-init prologue).
Impact
Exemplar MTF-confluence strategy: gates registered ÷4 too fast → 266 phantom entries; fixed → 307/307 exact TV match (weak 69.5 → excellent 100%), tier-verified in the private sweeps.
Gates (author + independent fresh-context R7, both green)
🤖 Generated with Claude Code