Skip to content

Preserve value-copy history in request.security - #412

Open
luisleo526 wants to merge 2 commits into
mainfrom
fix/issue-393-copy-history
Open

luisleo526 wants to merge 2 commits into
mainfrom
fix/issue-393-copy-history

Conversation

@luisleo526

Copy link
Copy Markdown
Contributor

request.security now keeps a copied persistent value's own requested-bar history and replays the copy where it was declared. Copy chains keep their declaration-time value when the source changes later, and a declared float copy preserves an integer source's missing value. Helper reads resolve by lexical binding, so a parameter or local no longer reads a same-named global.

Integer-tail cases have moved to a separate follow-up.

Validation: the reported script fails to compile on main and compiles with this change, while its direct and outside-request controls compile on both. All 50 focused tests pass with native execution, including the two new test files and the unchanged compound-modulo composition control, with no skips or errors. No existing assertion was changed.

Fixes #393

Track mutable dependencies at each request and replay scalar copies at
their original declaration boundary. Resolve helper reads by lexical
binding and recover global dependencies from declaration initializers
when a same-named parameter has history.

Integer-tail cases have moved to a separate follow-up.

Fixes #393

@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 8 changed function(s) (8 not verified).

Formal verification. PR-changed functions: 0/8 verified (0 proven, 0 may-equivalent, 0 distinguished) · 8 not verified (8 unsupported).

Not verified on this run: \_\_init\_\_ (unsupported), \_analyze (unsupported), \_collect\_security\_mutable\_globals (unsupported), \_handle\_request\_call (unsupported), \_handle\_request\_security\_lower\_tf (unsupported), \_emit\_security\_expr\_hist\_members (unsupported), \_emit\_security\_rebind\_var\_decl (unsupported), \_security\_reads\_bar\_index (unsupported).


Graphify review — findings

Fixes request.security so top-level scalar copies of persistent or reassigned globals (including copy chains) keep their requested-bar history and their declaration-time value. A new analyzer pass, _retain_security_value_copies, marks those copies as mutable globals so each request replays them at their original position, only when a request reads them and only widening that request's replay set by the newly retained copies. A declared float copy preserves an integer source's missing value, and replayed updates use the requested bar_index. Also tightens global-read detection so a parameter or local that shares a global's name no longer counts as a read of that global, and falls back to the declaration's value when the expression map omits a global.

No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 5032 functions depend on the 974 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: Analyzer — 121 callers, 15 callees
  • new: test_copy_capture_does_not_add_a_source_first_reassigned_after_the_call() — 0 callers, 8 callees
  • new: test_copy_capture_adds_only_its_sources_to_requests_that_read_it() — 0 callers, 6 callees
  • new: test_copy_capture_preserves_the_call_time_boundary_of_source_updates() — 0 callers, 6 callees
  • new: test_alias_history_native_values() — 0 callers, 6 callees

Verification — 5032 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: 3960 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

545 of 545 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, 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 495 more

non-code file(s) changed (CHANGELOG.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, 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 \_\_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 \_collect\_security\_mutable\_globals.

The verifier did not have enough to check \_collect\_security\_mutable\_globals, 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\_call.

The verifier did not have enough to check \_handle\_request\_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 \_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 \_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 \_emit\_security\_rebind\_var\_decl.

The verifier did not have enough to check \_emit\_security\_rebind\_var\_decl, 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\_reads\_bar\_index.

The verifier did not have enough to check \_security\_reads\_bar\_index, 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)

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

"""


def test_copy_capture_adds_only_its_sources_to_requests_that_read_it():

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

fans out to 6 callees (efferent coupling).

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

assert context.security_calls[1].mutable_globals == ()


def test_copy_capture_preserves_the_call_time_boundary_of_source_updates():

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

fans out to 6 callees (efferent coupling).

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



@pytest.mark.parametrize("chain", [False, True], ids=["copy", "chain"])
def test_copy_capture_does_not_add_a_source_first_reassigned_after_the_call(chain):

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

fans out to 8 callees (efferent coupling).

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


@pytest.mark.parametrize("source, mode, scale, override", CASES)
@pytest.mark.parametrize("opt", ["-O0", "-O2"])
def test_alias_history_native_values(source, mode, scale, override, opt):

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

fans out to 6 callees (efferent coupling).

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

Resolve identifier assignment targets through the existing identifier
visitor while their lexical scope is live. Requested selections then
retain persistent var and varip dependencies for compound writes.

Keep the existing outer-write validation and test expectations intact.

This branch has not been deployed

No deployments
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.

In a request.security expression, history of a plain alias of a var (alias[1]) emits [] on a scalar: the C++ does not compile

1 participant