Skip to content

fix: initialize persistent runtime scalars deterministically#65

Merged
luisleo526 merged 1 commit into
mainfrom
fix/runtime-var-initialization
Jul 17, 2026
Merged

fix: initialize persistent runtime scalars deterministically#65
luisleo526 merged 1 commit into
mainfrom
fix/runtime-var-initialization

Conversation

@luisleo526

Copy link
Copy Markdown
Contributor

Outcome

Initialize non-series persistent primitive var state at the Pine declaration site when the declaration first executes.

  • preserves source-order dependencies on inputs, ordinary globals, and TA results
  • observes runtime input overrides instead of constructor-folded defaults
  • preserves lazy first-entry semantics inside if / else and every switch case/default
  • assigns exact declaration-specific member names and distinct branch storage
  • snapshots the per-declaration once flags for calc-on-order-fill rollback
  • reserves user member names before minting generated flags
  • leaves Series, collections, UDTs, drawings, and function/method-local state on their existing specialized paths

Root cause

var float macroBearLow = low in Vasanth VBS previously emitted a bare, uninitialized C++ member. Allocator residue selected one of two trade tapes, and the verifier's offset ladder could therefore change the winning barIndexOffset even when neither the Pine source nor the engine changed.

With this patch, five independent forced-no-cache verifier processes all produced:

  • 408 trades
  • canonical tier excellent
  • canonical match / PnL P90: 100.0 / 0.0
  • offset 0
  • trade SHA-256 981022391f58ce82d02f5ff7aa15614440d7e565645d5b053d14e060a8f2be6f

Regression gates

  • focused engine-linked runtime-initialization suite: 12/12
  • full pytest suite: 1,360 collected, 1,358 passed, 2 existing skips
  • full codegen fixture gate: 262/262
  • gate self-test: 8 comparator + 10 verdict cases
  • independent branch/case, expression-form, callable-exclusion, input-order, collision, and rollback review: GO
  • exact Vasanth transpile/compile plus five-process determinism probe: PASS
  • scraper sweep: 412/412 accounted (404 ok + 1 no-trades + 6 transpile + 1 existing run error)
  • generated C++ impact: 45/406 transpiled strategies, 134 runtime persistent scalars
  • tracked trade artifacts: 497/497 byte-identical
  • board: 346 Excellent / 47 Strong / 4 Moderate / 5 Weak
  • tier movement: 0 UP / 0 DOWN
  • tier report SHA-256: e7cc1def70eadf2d6872cfe0446166195cb732b8736ccdcf6cd3374361cd739f
  • git diff --check: PASS

The score does not move because the committed Vasanth trade tape already happened to be the correct allocator outcome. This patch removes the undefined behavior and makes that result deterministic without changing any tracked trade tape.

@luisleo526
luisleo526 merged commit 00b0fbe into main Jul 17, 2026
9 checks passed
@luisleo526
luisleo526 deleted the fix/runtime-var-initialization branch July 17, 2026 10:12
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