Skip to content

Fix qualified declarations and request helper compilation - #407

Closed
luisleo526 wants to merge 39 commits into
mainfrom
fix/issue-372-stacked-h4
Closed

luisleo526 wants to merge 39 commits into
mainfrom
fix/issue-372-stacked-h4

Conversation

@luisleo526

@luisleo526 luisleo526 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

This pull request adds the qualified declaration and request helper fix (#372) on top of #406, which it contains unchanged. Once #406 has merged, the remaining change here is #372's.

Qualified declarations and request helper compilation (#372)

This change:

  • accepts persistent typed qualifiers;
  • completes mixed indentation levels;
  • lowers tuple-valued lower-timeframe requests to independently typed arrays;
  • retains helper bindings and tuple histories on the requested evaluator.

Uncalled forwarding helpers no longer allocate unresolved TA instances. The existing accepted controls remain covered.

Validation: the normal repository regressions in tests/test_v6_declaration_request_compilation.py reproduce 14 parser, code generation and C++ compilation failures on main, while 26 controls pass. With this change all 40 cases pass, along with 214 related focused tests.

Fixes #372

Resolve dotted builtin signatures consistently and preserve explicit strings,
chart-period fallback and single evaluation. Reserve generated conversion names.
The existing symbol-clock anchor tests now check both calls in the emitted
empty-argument conditional. Add pure-Python checks of branch direction and
single evaluation, and make the temporary-name sweep reach the argument lambda.

Product code is unchanged by this test update.
Lower missing reference values to their destination storage and retain drawing
handle types through user functions and tuple returns. Support declared
polyline types, fields and deletion arguments.
Read optional function metadata safely when inferring reference casts, so bare
emitters retain matrix element types without raising an AttributeError.
Use the established integer storage and matrix alias in type-flow assertions.
Check array specializations, mutations, matrix values and copy independence.
Share operand and value inference while an expression query is active, then
release cached results before bindings can change. Preserve ordinary matrix
member initialization when the declaration expression is still available.
Use the chart period for a generic missing timeframe argument and refuse
numeric values for string parameters during analysis. Cover named arguments,
helper calls, source locations and generated translation units.
Include only the stock-generated PF-E2095 definition and pin. Preserve all
prior catalog entry bytes and their existing order.
Merge the current main while retaining the feature correction.
Merge the current main while retaining the feature correction.
Merge the current main while retaining the feature correction.
Use recognized Pine types in declared type slots to resolve equally literal
diagnostic templates. Keep stable code order for other ties and preserve
qualifier identities, raw arguments and rendering. Pin the timeframe type
diagnostic and its named arguments with direct regression controls.
Reject non-string timeframe arguments through the intrinsic signature before
C++ lowering, including helper parameters and boolean values. Preserve valid
string calls and exercise complete native controls at distinct optimization
levels. Declare the new diagnostic in the existing catalog delta fixture.
Keep generated state and callable clone identities distinct from authored
members and use the same allocated identities at declarations and calls.
Preserve noncolliding names and duplicate-state assertions.
Carry the generated argument-type entry and its pin into the member while
preserving all other catalog bytes and order. Use the grammatical message
and exact approved user presentation with the existing argument kinds.
Retain the same numeric refusal cases and qualifier controls.
Use the argument occurrence within the call instead of an identically
named helper parameter. Keep the exact line and column assertions and
all source inputs, diagnostic identities and test rows unchanged.
Carry registered namespace types through the semantic query used for written
helper calls while respecting lexical shadowing and version boundaries.
Reuse the existing expression-start locator for timeframe type refusals.
Allocate composed callable and persistent-storage identities outside reserved
helper families, and reserve all authored spellings before sibling-block
qualification. Keep declarations, calls and history consumers on the same
allocated identity. Exercise collision cases through the public pipeline.
Keep raw typed-method names on the function channel when they collide with
authored data members. Continue allocating encoded names and collisions with
generated storage so method definitions, calls and state stay distinct.
Sizing constants keep their Pine string type for the string consumers this
change fixes, so a reassigned sizing variable reaches the risk host boundary
as a string and is converted to its integer code there. Keeping the integer
comparison would need integer storage for these variables, which the string
consumers cannot use. The test still requires the call to read t after its
write, never its initializer, and now also checks the code chosen for the
assigned value.
Merge the empty timeframe argument fix (#394) with the reference type fix for
fields and function calls (#390). Both changelog entries are kept.
Merge the generated clone and storage name fix (#350) into the combined
#394 and #390 fixes. All changelog entries are kept.
Keep the established admission policy for non-nullable script selections while
retaining exact compound value joins inside functions and methods. This avoids
introducing collection history for previously unresolved global selections.
Resolve the analyzer type-query conflict by retaining both lexical namespace
typing and callable compound return profiles. Preserve the corrected script
selection history admission and both changelog entries. No test expectation
or additional product behavior is changed in this merge resolution.
Merge the compound value type fix for user function calls (#391) onto the
combined #394, #390 and #350 fixes. All changelog entries are kept.
Separate persistence from type qualifiers, retain mixed complete indentation
levels, and preserve independently typed lower-timeframe tuple arrays.
Keep helper bindings and tuple histories on the requested evaluator and omit
unreachable forwarded TA instances. Add complete reported-case compilation
regressions while preserving existing accepted controls.
Bring the branch up to date with main after #405 merged. No conflicts.
…the stacked fixes

Merge the qualified declaration and request helper compilation fix (#372)
onto the compound value type fix (#391). All changelog entries are kept.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.

Not checked: tests were not run; formal verification proved 0 of 32 changed function(s) (3 sampled, not proven, 29 not verified).

Formal verification. PR-changed functions: 3/32 verified (0 proven, 3 may-equivalent, 0 distinguished) · 29 not verified (22 unsupported, 7 over cap).

Not verified on this run: \_\_init\_\_ (unsupported), \_analyze (unsupported), \_operator\_operand\_type (unsupported), \_propagate\_call\_site\_counts (unsupported), \_untyped\_param\_family\_conflicts (unsupported), \_visit\_FuncDef (unsupported), \_visit\_TupleAssign (unsupported), \_handle\_request\_security\_lower\_tf (unsupported), \_handle\_user\_func\_call (unsupported), \_\_init\_\_ (unsupported), and 12 more; 7 changed function(s) beyond the cap and 0 skipped when the time budget ran out.


Graphify review — findings

Adds a batch of Pine-to-C++ codegen fixes around typed persistent declarations, tuple payloads in request.security/security_lower_tf, and user-function type inference. var/varip now accept a type qualifier (var const float, varip const int), request.security_lower_tf returns one independently typed array per tuple element (evaluated once per intrabar), and a global tuple declaration read by request.security is sampled once per requested bar with scalar and history reads sharing it. User-function inference now carries exact array/object/string/matrix result types through branch returns, history clones, nested calls and tuple bindings, with per-callsite param/return specs resolved to the variants the emitter uses. When a structured argument type conflicts with a shared parameter type (e.g. vector<int>& vs vector<double>), the callee is marked conflicted, and deeply nested calls share inference work within an expression query. The lexer accepts complete mixed tab/space nested indentation (four columns per tab plus spaces) while incomplete mixed prefixes, skipped first-body widths and pending continuations keep their old handling, and uncalled forwarding helpers no longer allocate unresolved TA buffers (#372). Changelog and support-contracts docs are updated; regenerate C++ and relink affected strategies.

Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 6366 functions depend on the 2015 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: Parser — 227 callers, 42 callees
  • worse: Analyzer — 115 callers, 15 callees
  • worse: Lexer — 255 callers, 6 callees
  • new: test_lower_timeframe_tuple_collection_types_are_per_element() — 0 callers, 10 callees

Verification — 6366 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 5547 function(s) in the blast radius were not formally verified this run

Cross-repo impact

Cross-repo impact

This change impacts 2 symbol(s) across 1 peer repo(s) — blast radius over derived cross-repo edges:

  • pineforge-4pass/pineforge-hpo — python/pineforge_hpo/transpile.py (via import_moniker, heuristic), tests/python/test_transpile.py (via import_moniker, heuristic)

1 peer repo(s) in this group are not yet indexed — cross-repo impact may be incomplete.

Cross-repo linkage is derived (SCIP-moniker matches are sound; name/contract matches are heuristic) and ADVISORY — it never affects this check's conclusion.

Test selection

Test selection

542 of 542 test file(s) selected (100%) via static blast radius.

Escalated to a full run for safety (noncode-change, uncovered-code) — the selection is not trustworthy on its own (see below). CI should run the whole suite.

  • tests/test_action_pins.py — full-run-safety
  • tests/test_allow_entry_in_qualifier.py — impact, full-run-safety
  • tests/test_allow_entry_in_request_const.py — impact, full-run-safety
  • tests/test_analyzer.py — impact, full-run-safety
  • tests/test_analyzer_matrix_inference.py — impact, full-run-safety
  • tests/test_analyzer_ta_return_types.py — impact, full-run-safety
  • tests/test_anchor_tf_change.py — impact, full-run-safety
  • tests/test_anchor_time.py — impact, full-run-safety
  • tests/test_anchor_vwap.py — impact, full-run-safety
  • tests/test_array_bounds_insert_fill_slice.py — impact, full-run-safety
  • tests/test_array_checked_access.py — impact, full-run-safety
  • tests/test_array_empty_aggregates.py — impact, full-run-safety
  • tests/test_array_history.py — impact, full-run-safety
  • tests/test_array_missing_integer_index.py — impact, full-run-safety
  • tests/test_array_new_color_fill_and_na_size.py — impact, full-run-safety
  • tests/test_array_new_defaults_and_order.py — impact, full-run-safety
  • tests/test_array_reference_semantics.py — impact, full-run-safety
  • tests/test_array_retained_alias.py — impact, full-run-safety
  • tests/test_array_slice_view.py — impact, full-run-safety
  • tests/test_array_sort_indices.py — impact, full-run-safety
  • tests/test_array_terminal_returns.py — impact, full-run-safety
  • tests/test_arrseg_coded_run_stops.py — impact, full-run-safety
  • tests/test_arrseg_review_fixes.py — impact, full-run-safety
  • tests/test_binop_operand_order.py — impact, full-run-safety
  • tests/test_block_shadow_primitive_types.py — impact, full-run-safety
  • tests/test_block_var_plain_siblings.py — impact, full-run-safety
  • tests/test_bool_na_refusal.py — impact, full-run-safety
  • tests/test_bool_na_refusals_2.py — impact, full-run-safety
  • tests/test_bool_na_values.py — impact, full-run-safety
  • tests/test_bool_string_inference.py — impact, full-run-safety
  • tests/test_builtin_name_shadow.py — impact, full-run-safety
  • tests/test_builtin_named_locals_compile.py — impact, full-run-safety
  • tests/test_builtin_named_locals_price_refusal.py — impact, full-run-safety
  • tests/test_builtin_named_locals_receipt.py — impact, full-run-safety
  • tests/test_builtin_named_locals_scope.py — impact, full-run-safety
  • tests/test_builtin_named_parameters.py — impact, full-run-safety
  • tests/test_builtin_named_parameters_reference.py — impact, full-run-safety
  • tests/test_calc_on_order_fills_codegen.py — impact, full-run-safety
  • tests/test_calendar_lambda_locals.py — impact, full-run-safety
  • tests/test_call_argument_order.py — impact, full-run-safety
  • tests/test_callable_compound_type_flow.py — impact, changed-test, full-run-safety
  • tests/test_callable_local_histories.py — impact, full-run-safety
  • tests/test_callable_series_param_types.py — impact, full-run-safety
  • tests/test_callable_string_series_type.py — impact, full-run-safety
  • tests/test_callable_ta_forwarded_length.py — impact, changed-test, full-run-safety
  • tests/test_callable_var_first_reach.py — impact, full-run-safety
  • tests/test_checked_settings.py — impact, full-run-safety
  • tests/test_ci_engine_main_touched.py — full-run-safety
  • tests/test_clone_name_allocation.py — impact, full-run-safety
  • tests/test_closed_trade_fold.py — impact, full-run-safety
  • … and 492 more

non-code file(s) changed (CHANGELOG.md, docs/reference/support-contracts.md) → running the full suite for safety (a code graph can't see config/fixture/data deps)

changed code file(s) with no mapped test (CHANGELOG.md, docs/reference/support-contracts.md, pineforge_codegen/analyzer/call_handlers.py, pineforge_codegen/codegen/emit_top.py, pineforge_codegen/codegen/visit_stmt.py) — a coverage gap or a missing link — running the full suite rather than only the selected tests

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

Docs that may be stale (advisory)

Formal verification

Could not verify: Could not verify \_\_init\_\_.

The verifier did not have enough to check \_\_init\_\_, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_analyze.

The verifier did not have enough to check \_analyze, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_operator\_operand\_type.

The verifier did not have enough to check \_operator\_operand\_type, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_propagate\_call\_site\_counts.

The verifier did not have enough to check \_propagate\_call\_site\_counts, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_untyped\_param\_family\_conflicts.

The verifier did not have enough to check \_untyped\_param\_family\_conflicts, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_visit\_FuncDef.

The verifier did not have enough to check \_visit\_FuncDef, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_visit\_TupleAssign.

The verifier did not have enough to check \_visit\_TupleAssign, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_handle\_request\_security\_lower\_tf.

The verifier did not have enough to check \_handle\_request\_security\_lower\_tf, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_handle\_user\_func\_call.

The verifier did not have enough to check \_handle\_user\_func\_call, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_\_init\_\_.

The verifier did not have enough to check \_\_init\_\_, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

No difference found (not proven): No behavior difference found in \_selection\_type\_spec (not a proof).

The verifier ran both versions of \_selection\_type\_spec on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: the synth_receiver tier. A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

No difference found (not proven): No behavior difference found in \_type\_spec\_from\_expr (not a proof).

The verifier ran both versions of \_type\_spec\_from\_expr on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: the synth_receiver tier. A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

Could not verify: Could not verify \_visit.

The verifier did not have enough to check \_visit, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_\_init\_\_.

The verifier did not have enough to check \_\_init\_\_, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_build\_func\_instances.

The verifier did not have enough to check \_build\_func\_instances, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_generate\_cpp.

The verifier did not have enough to check \_generate\_cpp, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_register\_global\_aggregate\_member\_types.

The verifier did not have enough to check \_register\_global\_aggregate\_member\_types, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_emit\_func\_def\_body.

The verifier did not have enough to check \_emit\_func\_def\_body, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_build\_security\_expr.

The verifier did not have enough to check \_build\_security\_expr, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

No difference found (not proven): No behavior difference found in \_collect\_security\_expr\_hist\_subscripts (not a proof).

The verifier ran both versions of \_collect\_security\_expr\_hist\_subscripts on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: the synth_receiver tier. A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

Could not verify: Could not verify \_emit\_security\_evaluator\_body.

The verifier did not have enough to check \_emit\_security\_evaluator\_body, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_emit\_security\_evaluators.

The verifier did not have enough to check \_emit\_security\_evaluators, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_emit\_security\_expr\_hist\_members.

The verifier did not have enough to check \_emit\_security\_expr\_hist\_members, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_security\_check\_tuple\_element\_history.

The verifier did not have enough to check \_security\_check\_tuple\_element\_history, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

Could not verify: Could not verify \_security\_fallback\_owns.

The verifier did not have enough to check \_security\_fallback\_owns, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: method — first parameter is `self`, which needs a constructed instance (not synthesizable)

· 1 grounded finding(s) anchored inline below; 3 more finding(s) on lines outside this diff (see the check run).


@pytest.mark.parametrize("helper", [False, True], ids=["inline", "helper"])
@pytest.mark.parametrize("named", [False, True], ids=["positional", "named"])
def test_lower_timeframe_tuple_collection_types_are_per_element(helper, named):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — test_lower_timeframe_tuple_collection_types_are_per_element()

fans out to 10 callees (efferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

@luisleo526

Copy link
Copy Markdown
Contributor Author

Closing this pull request without merging. The #372 change will be rebuilt on the current main (b7379dd), so that the tests added for #350 and #391 keep passing alongside it, and it will come back as a new pull request that references #372.

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.

Seven valid v6 forms that TradingView runs and Codegen refuses or mishandles

1 participant