Repository navigation
Resolve empty timeframe arguments consistently - #401
luisleo526 wants to merge 18 commits into
Conversation
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.
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.
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.
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.
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 3 advisory finding(s) below merit a look before merge.
Not checked: tests were not run; formal verification proved 0 of 16 changed function(s) (3 sampled, not proven, 13 not verified).
Formal verification. PR-changed functions: 3/16 verified (0 proven, 3 may-equivalent, 0 distinguished) · 13 not verified (3 vacuous, 10 unsupported).
Not verified on this run: \_operator\_operand\_type (unsupported), \_visit\_FuncCall (unsupported), \_visit\_MemberAccess (unsupported), \_check\_node (unsupported), \_emit\_constructor (unsupported), \_resolve\_func\_args (unsupported), \_visit\_func\_call (unsupported), \_visit\_strategy\_call (unsupported), \_visit\_member\_access (unsupported), \_visit\_stmt (unsupported), and 3 more.
Graphify review — findings
Fixes strategy sizing constants (strategy.fixed, strategy.cash, strategy.percent_of_equity) so they stay strings through expressions, aliases and helper calls, and converts to the host's numeric QtyType only at the order and risk setting boundary. A string-typed sizing constant now reaches strategy declarations, and the analyzer's v5 path for syminfo and timeframe.period inference was removed in the same move, so v5 scripts may lose that typing. Adds a v6 analyzer check, _check_timeframe_string_arguments, that refuses non-string arguments to timeframe.in_seconds and timeframe.change with PF-E2095 and a source location before C++ emission. It only fires when the receiver is recorded as the lexical timeframe namespace, which makes the check depend on the binding records being complete. Bare na is still accepted, and an evaluated empty string now resolves to the chart period. Escapes script identifiers shaped like integer-to-float conversion temporaries, including nested underscore suffixes, with the generator's reserved-name handling.
Worth a look
- Sizing constants now emit strings in strategy declarations —
pineforge_codegen/codegen/visit_expr.py:1000· Escalate · medium- unverified hypothesis — survived the adversarial refute pass; needs human review
- Pine v5 loses
syminfoandtimeframe.periodtype inference —pineforge_codegen/analyzer/base.py:7158· Escalate · medium- unverified hypothesis — survived the adversarial refute pass; needs human review
- Missing binding records are treated as the builtin
timeframenamespace —pineforge_codegen/analyzer/base.py:7463· 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 — 6091 functions depend on the 1555 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
Analyzer— 113 callers, 15 callees - worse:
_Fold— 4 callers, 8 callees - new:
get_variable_type_spec()— 4 callers, 3 callees - new:
argument_runs()— 0 callers, 8 callees - new:
test_open_numeric_domain_is_not_reported_as_a_guessed_float()— 0 callers, 8 callees - new:
test_numeric_timeframe_is_refused_during_analysis()— 0 callers, 7 callees - new:
test_non_string_timeframes_are_refused_by_semantic_type()— 0 callers, 7 callees
Verification — 6091 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: 5137 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
533 of 533 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, changed-test, full-run-safetytests/test_anchor_time.py— impact, full-run-safetytests/test_anchor_vwap.py— impact, changed-test, 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— 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_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, 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_closed_trade_fold.py— full-run-safetytests/test_closed_trade_fold_emission.py— impact, full-run-safetytests/test_closed_trade_text_equals.py— impact, full-run-safety- … and 483 more
non-code file(s) changed (
CHANGELOG.md,pineforge_codegen/diagnostics_catalog.json,tests/fixtures/diagnostic_codes_pin.json,tests/fixtures/diagnostic_notes/delta.json,tests/fixtures/empty_timeframe/arguments.pine…) → 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,pineforge_codegen/codegen/emit_top.py,pineforge_codegen/codegen/visit_stmt.py,scripts/gen_diagnostics_catalog.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.
Formal verification
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 \_visit\_FuncCall.
The verifier did not have enough to check \_visit\_FuncCall, 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 \_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)
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 \_emit\_constructor.
The verifier did not have enough to check \_emit\_constructor, 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 \_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 \_resolve\_func\_args.
The verifier did not have enough to check \_resolve\_func\_args, 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\_func\_call.
The verifier did not have enough to check \_visit\_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 \_visit\_strategy\_call.
The verifier did not have enough to check \_visit\_strategy\_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 \_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)
Could not verify: Could not verify \_visit\_stmt.
The verifier did not have enough to check \_visit\_stmt, 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 \_matchers.
The verifier did not have enough to check \_matchers, 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 1 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly NameError — names the real obstacle, not a sampling gap)
Could not verify: Could not verify classify.
The verifier did not have enough to check classify, 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 260 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly NameError — names the real obstacle, not a sampling gap)
No difference found (not proven): No behavior difference found in get\_variable\_type (not a proof).
The verifier ran both versions of get\_variable\_type 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 main.
The verifier did not have enough to check main, 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 54 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)
· 5 grounded finding(s) anchored inline below; 2 more finding(s) on lines outside this diff (see the check run).
| return STRATEGY_SIZING_CONSTANTS.get(f"{namespace}.{name}") | ||
|
|
||
|
|
||
| def get_variable_type_spec( |
There was a problem hiding this comment.
get_variable_type_spec()
high coupling complexity (Ca·Ce = 12).
Grounded coupling-delta finding (deterministic), not an LLM guess.
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def argument_runs(tmp_path_factory): |
There was a problem hiding this comment.
argument_runs()
fans out to 8 callees (efferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
| ("1.25", "float"), | ||
| ("-2.5", "float"), | ||
| ]) | ||
| def test_numeric_timeframe_is_refused_during_analysis(function, named, argument, pine_type): |
There was a problem hiding this comment.
test_numeric_timeframe_is_refused_during_analysis()
fans out to 7 callees (efferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
|
|
||
|
|
||
| @pytest.mark.parametrize("function", ("change", "in_seconds")) | ||
| def test_open_numeric_domain_is_not_reported_as_a_guessed_float(function): |
There was a problem hiding this comment.
test_open_numeric_domain_is_not_reported_as_a_guessed_float()
fans out to 8 callees (efferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
| ]) | ||
| @pytest.mark.parametrize("conversion", [False, True], ids=["alone", "bool-to-text"]) | ||
| @pytest.mark.parametrize("declarations,argument,pine_type", NON_STRINGS) | ||
| def test_non_string_timeframes_are_refused_by_semantic_type( |
There was a problem hiding this comment.
test_non_string_timeframes_are_refused_by_semantic_type()
fans out to 7 callees (efferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
Resolves empty timeframe string arguments as the chart timeframe across the timeframe functions:
timeframe.in_seconds("")now returns the chart's seconds andtimeframe.change("")fires when the chart period changes, matching the documented meaning of an empty timeframe. Also fixes a false refusal of valid namespace-qualified reads that the earlier version introduced, and keeps the existing integer codes for strategy risk type selections.This replaces #399: the same change, rebuilt on a corrected base, so #399's branch could not be updated by a fast-forward.
Tests: regression tests for each empty, explicit and omitted timeframe argument form, which fail on the base and pass with this change. One version-5 case uses a version-6 caller importing a version-5 library, which is the supported route for version-5 code.
Fixes #394