Skip to content

Preserve built-in constant values and string input options - #410

Closed
luisleo526 wants to merge 1 commit into
mainfrom
fix/issue-389-builtin-constant-values
Closed

luisleo526 wants to merge 1 commit into
mainfrom
fix/issue-389-builtin-constant-values

Conversation

@luisleo526

Copy link
Copy Markdown
Contributor

Built-in size.*, position.*, line.style_*, label.style_* and shape.* 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.ascending and order.descending keep 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_indices now honors a supplied sort direction.

Validation: all seven forms from the report fail on main and pass with this change, and every control passes. The focused selection has 865 passes, zero failures and 67 native skips. TradingView accepts the reported "Text size" input and reports the default small with the options tiny, small and normal.

Fixes #389

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

@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 26 changed function(s) (6 sampled, not proven, 20 not verified).

Formal verification. PR-changed functions: 6/26 verified (0 proven, 6 may-equivalent, 0 distinguished) · 20 not verified (2 vacuous, 17 unsupported, 1 over cap).

Not verified on this run: \_certain\_scalar\_type (unsupported), \_check\_typed\_parameter\_mismatches (unsupported), \_operator\_operand\_type\_uncached (unsupported), \_primitive\_pine\_type\_from\_spec (vacuous: never exercised), \_record\_parameter\_default\_scalar\_types (unsupported), \_visit (unsupported), \_visit\_Assignment (unsupported), \_visit\_FuncDef (unsupported), \_visit\_MemberAccess (unsupported), \_visit\_MethodDef (unsupported), and 9 more; 1 changed function(s) beyond the cap and 0 skipped when the time budget ran out.


Graphify review — findings

Adds typed string values for built-in size, position, line/label style and shape constants, so they keep their string identity through variables, selections, function arguments/returns, and string input defaults/options. This fixes the ambiguous C++ assignments, NUL strings, unsupported size inputs and null-pointer string construction from #389. A new builtin_constants.py supplies each constant's value and semantic type to analysis, emission and input proofs, and the legacy "0" fallbacks only apply to members it doesn't inventory. Sort-order constants (order.ascending/order.descending) now carry a nominal sort_order TypeSpec instead of decaying to their storage type. The analyzer rejects them in string slots, typed parameters/defaults, UDT fields, casts and operators, and reports invalid string conversions at the Pine location, including individual elements of string input options. Also makes array.sort_indices honor a supplied sort direction and fixes a crash in type checking of scalar function overloads. Existing strategies need their C++ regenerated and relinked.

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 — 5866 functions depend on the 1602 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: Analyzer — 115 callers, 15 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
  • new: test_constant_member_has_one_string_type_and_value() — 0 callers, 6 callees

Verification — 5866 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: 5095 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

537 of 537 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 — full-run-safety
  • tests/test_builtin_style_values.py — impact, changed-test, 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, 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, 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
  • … and 487 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)

Formal verification

Could not verify: Could not verify \_certain\_scalar\_type.

The verifier did not have enough to check \_certain\_scalar\_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 \_check\_typed\_parameter\_mismatches.

The verifier did not have enough to check \_check\_typed\_parameter\_mismatches, 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\_uncached.

The verifier did not have enough to check \_operator\_operand\_type\_uncached, 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 \_primitive\_pine\_type\_from\_spec.

The verifier did not have enough to check \_primitive\_pine\_type\_from\_spec, 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: not verified: a runtime divergence was observed, but the two versions' package snapshots loaded differently in the sandbox (old: {'fallback': {'pineforge_codegen': 'ImportError', 'pineforge_codegen.analyzer.types': 'ModuleNotFoundError', 'pineforge_codegen.builtin_keywords': 'ModuleNotFoundError', 'pineforge_codegen.codegen': 'ImportError', 'pineforge_codegen.codegen.base': 'ModuleNotFoundError', 'pineforge_codegen.codegen.constant_values': 'ModuleNotFoundError', 'pineforge_codegen.codegen.strategy_declaration': 'ModuleNotFoundError', 'pineforge_codegen.library_inline': 'ModuleNotFoundError', 'pineforge_codegen.support_checker': 'ModuleNotFoundError'}, 'missing': ['pineforge_codegen.array_binding', 'pineforge_codegen.codegen.ascii', 'pineforge_codegen.codegen.collection_history', 'pineforge_codegen.codegen.color_constants', 'pineforge_codegen.codegen.constant_fold', 'pineforge_codegen.codegen.drawing', 'pineforge_codegen.codegen.e…

Could not verify: Could not verify \_record\_parameter\_default\_scalar\_types.

The verifier did not have enough to check \_record\_parameter\_default\_scalar\_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 \_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 \_visit\_Assignment.

The verifier did not have enough to check \_visit\_Assignment, 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\_MemberAccess.

The verifier did not have enough to check \_visit\_MemberAccess, 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\_MethodDef.

The verifier did not have enough to check \_visit\_MethodDef, 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\_VarDecl.

The verifier did not have enough to check \_visit\_VarDecl, 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 \_callsite\_primitive\_expr\_type.

The verifier did not have enough to check \_callsite\_primitive\_expr\_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 resolve\_operator.

The verifier did not have enough to check resolve\_operator, 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: not verifiable: all 202 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)

Could not verify: Could not verify \_check\_node.

The verifier did not have enough to check \_check\_node, 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 \_param\_type\_specs\_from\_def.

The verifier did not have enough to check \_param\_type\_specs\_from\_def, 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.

No difference found (not proven): No behavior difference found in \_string\_setting\_arg (not a proof).

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

Guarantee: Empirical: differential testing (both versions run on many generated inputs). 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 \_scalar.

The verifier did not have enough to check \_scalar, 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 expression.

The verifier did not have enough to check expression, 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 \_infer\_type (not a proof).

The verifier ran both versions of \_infer\_type 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 \_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\_raw (not a proof).

The verifier ran both versions of \_type\_spec\_from\_expr\_raw 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 \_type\_spec\_to\_cpp.

The verifier did not have enough to check \_type\_spec\_to\_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 \_visit\_member\_access.

The verifier did not have enough to check \_visit\_member\_access, 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)

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

return PineType.STRING


def builtin_constant(namespace: str, member: str) -> BuiltinConstant | None:

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 — 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):

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 — 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):

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_constant_member_has_one_string_type_and_value()

fans out to 6 callees (efferent coupling).

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

@luisleo526

Copy link
Copy Markdown
Contributor Author

Closing in favor of #411, which carries this change unchanged as part of a combined pull request.

@luisleo526 luisleo526 closed this Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant