Commit graph

1 commit

Author SHA1 Message Date
Brian Caswell
d52c51d60b
function_parser: derive fake_return is_outside from cmsg.blocks membership (defense-in-depth for #6414) (#6417)
* function_parser: derive fake_return outside flag from cmsg.blocks

parse_from_cmessage's call-edge handler called
  obj._call_to(..., return_to_outside=fake_ret_edge is None)
which only checked whether a matching fake_return edge exists, not
whether its destination was external at save time. _call_to then
called _register_node(is_local=True, ret_node) and added the
destination to _local_block_addrs even when it was serialized as an
external_block.

This is a defense-in-depth follow-up to #6416. With that fix landed,
no newly-saved record should contain a fake_return edge with
is_outside=False whose dst is in cmsg.external_blocks. But:
  * legacy LMDB records written before #6416 still have this shape
  * other call sites (notably _add_fakeret_to(confirmed=None)) can
    create the same in-memory inconsistency, which then makes the
    parser inflate the block set on every roundtrip

Fix: derive return_to_outside / to_outside from cmsg.blocks
membership (the authoritative 'was local at save' signal) rather
than from the edge attribute. The same logic applies to the
subsequent obj._fakeret_to call, which previously used the edge
attribute directly.

Adds tests/knowledge_plugins/functions/test_function_parser_fakeret.py
which round-trips a function with the inconsistent edge shape and
asserts _local_block_addrs is preserved.

* test_function_parser_fakeret: assert func is not None for pyright

* test_function_parser_fakeret: drop __package__ override
2026-05-20 02:49:54 -07:00