Skip to content

[codex] fix EasySession input buffer lifetime#111

Merged
justinjoy merged 1 commit into
mainfrom
codex/fix-easy-buffer-lifetime-863
May 21, 2026
Merged

[codex] fix EasySession input buffer lifetime#111
justinjoy merged 1 commit into
mainfrom
codex/fix-easy-buffer-lifetime-863

Conversation

@justinjoy
Copy link
Copy Markdown
Contributor

Summary

Fixes a PyreWire FFI lifetime bug exposed by wirelog#863. EasySession.insert() and remove() were passing temporary Python-owned bytes and ctypes.c_int64[] buffers into the wirelog easy facade, then allowing those objects to be reclaimed before the next evaluating call. If Python bookkeeping or other allocations happened before step(), the C incremental path could consume stale row pointers and emit missing deltas.

This keeps easy-facade input buffers alive on the session until step() or snapshot() has consumed them, and clears the keepalive list afterward. The same keepalive treatment is applied to the variadic insert_sym/remove_sym path.

Validation

  • .venv/bin/ruff check src tests passed
  • WIRELOG_LIB=/home/joykim/git/semantic-reasoning/wirelog/builddir-861/libwirelog.so.1 PYTHONPATH=src .venv/bin/pytest -q -o addopts='' tests/test_easy_session.py tests/test_easy_step_snapshot.py tests/test_easy_deltas.py tests/test_easy_insert_sym.py tests/test_async.py passed: 48 passed
  • Full WIRELOG_LIB=/home/joykim/git/semantic-reasoning/wirelog/builddir-861/libwirelog.so.1 PYTHONPATH=src .venv/bin/pytest -q reached 93.20% coverage but failed one existing metadata test: tests/test_changelog_format.py::test_topmost_released_section_matches_pyproject because CHANGELOG.md topmost released section is 0.41.0 while pyproject.toml is 0.41.99.

Notes

Raw ctypes calls into wirelog_easy_set_delta_cb/wirelog_easy_step with a manually retained row buffer produced the expected reachability deltas, confirming the C easy facade was not the failing layer in this reproduction.

s.insert("edge", [2, 3])
# Force Python allocations in the same window where step() also
# performs mode/callback bookkeeping.
_junk = [b"edge" for _ in range(32)]
}

s.insert("edge", [3, 4])
_junk = [b"edge" for _ in range(32)]
@justinjoy justinjoy marked this pull request as ready for review May 21, 2026 12:43
@justinjoy justinjoy merged commit 570822c into main May 21, 2026
4 checks passed
@justinjoy justinjoy deleted the codex/fix-easy-buffer-lifetime-863 branch May 21, 2026 12:44
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.

1 participant