Repository navigation
Preserve built-in constant values and fix qualified declarations and request helpers - #411
Conversation
Built-in size, position, line/label style and shape constants keep their string values in variables, selections, function arguments and returns, and in string input defaults and options. Sort-order constants keep their nominal type; using one as a string input default or option element is refused at its Pine location (PF-E2093). array.sort_indices honors a supplied sort direction, and scalar function overloads no longer crash during type checking. Fixes #389
Accept persistent typed qualifiers, complete mixed indentation levels, lower tuple-valued lower-timeframe requests to independently typed arrays, and retain helper bindings and tuple histories on the requested evaluator. Uncalled forwarding helpers no longer allocate unresolved TA instances. Resolvable variants of a reachable helper keep their TA state even when registered through an uncalled caller, requested builtin tuples reuse their existing sampled results, and mixed-clock tuple history uses the registered history diagnostic. Fixes #372
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.
Not checked: tests were not run; no formal proof of the changed code.
Graphify review — findings
Adds typed string values for inventoried size.*, position.*, line.style_*, label.style_* and shape.* constants through a shared builtin_constants module. Assignments, selections, function arguments and string input defaults keep those values instead of producing ambiguous C++ or a 0 placeholder. order.ascending and order.descending stay nominal sort_order types that the analyzer checks at typed slots, parameter defaults and call arguments, so they never convert to strings. Also parses a type qualifier after var/varip, returns one independently typed array per tuple element from request.security_lower_tf, and samples global tuples once per requested evaluator. Mixed tab/space nested indentation is accepted, and uncalled forwarding helpers no longer allocate unresolved TA buffers for unreachable variants.
Worth a look
- User-defined function arguments bypass nominal enum checks —
pineforge_codegen/analyzer/base.py:5136· Escalate · medium- unverified hypothesis — survived the adversarial refute pass; needs human review
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 — 7024 functions depend on the 2695 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
Parser— 229 callers, 42 callees - worse:
Analyzer— 117 callers, 15 callees - worse:
Lexer— 257 callers, 6 callees - worse:
CodeGen— 71 callers, 14 callees - worse:
resolve_operator()— 16 callers, 4 callees - new:
builtin_constant()— 11 callers, 3 callees - worse:
_Fold— 4 callers, 8 callees - new:
analyze()— 4 callers, 5 callees - …and 2 more — each is listed as a finding
Verification — 7024 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: 6340 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
543 of 543 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-safetytests/test_allow_entry_in_qualifier.py— impact, full-run-safetytests/test_allow_entry_in_request_const.py— impact, full-run-safetytests/test_analyzer.py— impact, full-run-safetytests/test_analyzer_matrix_inference.py— impact, full-run-safetytests/test_analyzer_ta_return_types.py— impact, full-run-safetytests/test_anchor_tf_change.py— impact, full-run-safetytests/test_anchor_time.py— impact, full-run-safetytests/test_anchor_vwap.py— impact, full-run-safetytests/test_array_bounds_insert_fill_slice.py— impact, full-run-safetytests/test_array_checked_access.py— impact, full-run-safetytests/test_array_empty_aggregates.py— impact, full-run-safetytests/test_array_history.py— impact, full-run-safetytests/test_array_missing_integer_index.py— impact, full-run-safetytests/test_array_new_color_fill_and_na_size.py— impact, full-run-safetytests/test_array_new_defaults_and_order.py— impact, full-run-safetytests/test_array_reference_semantics.py— impact, full-run-safetytests/test_array_retained_alias.py— impact, full-run-safetytests/test_array_slice_view.py— impact, full-run-safetytests/test_array_sort_indices.py— impact, full-run-safetytests/test_array_terminal_returns.py— impact, full-run-safetytests/test_arrseg_coded_run_stops.py— impact, full-run-safetytests/test_arrseg_review_fixes.py— impact, full-run-safetytests/test_binop_operand_order.py— impact, full-run-safetytests/test_block_shadow_primitive_types.py— impact, full-run-safetytests/test_block_var_plain_siblings.py— impact, full-run-safetytests/test_bool_na_refusal.py— impact, full-run-safetytests/test_bool_na_refusals_2.py— impact, full-run-safetytests/test_bool_na_values.py— impact, full-run-safetytests/test_bool_string_inference.py— impact, full-run-safetytests/test_builtin_name_shadow.py— impact, full-run-safetytests/test_builtin_named_locals_compile.py— impact, full-run-safetytests/test_builtin_named_locals_price_refusal.py— impact, full-run-safetytests/test_builtin_named_locals_receipt.py— impact, full-run-safetytests/test_builtin_named_locals_scope.py— impact, full-run-safetytests/test_builtin_named_parameters.py— impact, full-run-safetytests/test_builtin_named_parameters_reference.py— impact, full-run-safetytests/test_builtin_style_values.py— impact, changed-test, full-run-safetytests/test_calc_on_order_fills_codegen.py— impact, full-run-safetytests/test_calendar_lambda_locals.py— impact, full-run-safetytests/test_call_argument_order.py— impact, full-run-safetytests/test_callable_compound_type_flow.py— impact, full-run-safetytests/test_callable_local_histories.py— impact, full-run-safetytests/test_callable_series_param_types.py— impact, full-run-safetytests/test_callable_string_series_type.py— impact, full-run-safetytests/test_callable_ta_forwarded_length.py— impact, changed-test, full-run-safetytests/test_callable_var_first_reach.py— impact, full-run-safetytests/test_checked_settings.py— impact, full-run-safetytests/test_ci_engine_main_touched.py— full-run-safetytests/test_clone_name_allocation.py— impact, full-run-safety- … and 493 more
non-code file(s) changed (
CHANGELOG.md,docs/codegen-coverage-gaps.md,docs/reference/file-map.md,docs/reference/support-contracts.md,pineforge_codegen/diagnostics_catalog.json…) → 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/codegen-coverage-gaps.md,docs/reference/file-map.md,docs/reference/support-contracts.md,pineforge_codegen/analyzer/call_handlers.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)
README.md§ Advanced: run the pipeline stages directly (lines 458-484): references changed symbolsanalyzedocs/reference/pipeline.md§ Pipeline (lines 1-74): references changed symbolsanalyze
· 4 grounded finding(s) anchored inline below; 6 more finding(s) on lines outside this diff (see the check run).
| return PineType.STRING | ||
|
|
||
|
|
||
| def builtin_constant(namespace: str, member: str) -> BuiltinConstant | None: |
There was a problem hiding this comment.
builtin_constant()
11 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
| HEADER = '//@version=6\nstrategy("builtin constant values")\n' | ||
|
|
||
|
|
||
| def analyze(body): |
There was a problem hiding this comment.
analyze()
high coupling complexity (Ca·Ce = 20).
Grounded coupling-delta finding (deterministic), not an LLM guess.
| ("label", "style_label_up", "lup"), | ||
| ("shape", "circle", "shape_circle"), ("shape", "cross", "shape_cross"), | ||
| ]) | ||
| def test_constant_member_has_one_string_type_and_value(namespace, member, value): |
There was a problem hiding this comment.
test_constant_member_has_one_string_type_and_value()
fans out to 6 callees (efferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
|
|
||
| @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): |
There was a problem hiding this comment.
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.
`s = shape.triangleup` compiles in TradingView, where shape constants are const strings, so its fixture moves to the ok corpus. The input metadata fixture passes order.ascending, a const sort_order, as a string input default, which TradingView refuses, so it moves to the err corpus, matching the handling of tests/fixtures/input_metadata.pine. Both files are unchanged. Refs #389
This pull request combines two fixes, one commit each, so that they are verified together.
Built-in constant values and string input options (#389)
Built-in
size.*,position.*,line.style_*,label.style_*andshape.*constants keep their string values in variables, selections, function arguments and returns, and in string input defaults and options. This fixes the ambiguous C++ assignments, the one-character NUL strings, the unsupported size inputs and the null-pointer string construction in the report.order.ascendingandorder.descendingkeep their nominal sort-order type. Using one as a string input default or option element is refused at its Pine location before any C++ is emitted (new diagnostic PF-E2093).array.sort_indicesnow honors a supplied sort direction.Validation: all seven forms from the report fail on main and pass with this change, and every control passes. TradingView accepts the reported "Text size" input and reports the default
smallwith the optionstiny,smallandnormal.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, and retains helper bindings and tuple histories on the requested evaluator. Uncalled forwarding helpers no longer allocate unresolved TA instances. Resolvable variants of a reachable helper keep their TA state even when registered through an uncalled caller, and requested builtin tuples reuse their existing sampled results, so the generated C++ of programs outside the reported forms is unchanged.
Validation: the regressions in
tests/test_v6_declaration_request_compilation.pyreproduce 14 parser, code generation and C++ compilation failures on main while 26 controls pass; with this change all 40 cases pass. The affected test files pass in full (1359 cases), including the diagnostic catalog, TA clone and reference C++ tests. No test was changed. TradingView compiles the reportedvar constdeclaration form without diagnostics.Supersedes #410 and #409.
Fixes #389
Fixes #372