Skip to content

v0.1.3 — serialize LocalIngestClient.handle (closes #2)

Choose a tag to compare

@oabolade oabolade released this 25 Jun 01:36
· 95 commits to main since this release

Patch release. Closes #2.

📦 PyPI: https://pypi.org/project/rootsign/0.1.3/

What changed

LocalIngestClient.handle() now holds a per-client asyncio.Lock that serializes concurrent ingest calls against the shared AsyncSession. Under LangGraph's ToolNode and create_react_agent, tool calls interleave on the event loop and each await client.handle(envelope) walks the same session through SELECT FOR UPDATE → add → flush. Before v0.1.3, a second db.add() could land during a prior call's flush and fire:

SAWarning: Usage of the 'Session.add()' operation is not currently
supported within the execution stage of the flush process.
rootsign ingest failed for tool <name>: Session is already flushing

Postgres's per-session FOR UPDATE serialized the actual writes so chains still verified VALID, but the ORM-side races were a real hazard for any future code path relying on identity-map consistency mid-flush.

Why per-client (not class-level / global)

Two LocalIngestClient instances on independent AsyncSessions don't share state — the only resource that needs serialization is the one session held by a single client. A global lock would force unrelated clients to wait on each other for no semantic gain. A dedicated unit test (test_lock_is_per_client_not_global) pins this contract.

Tests

tests/unit/test_ingest_client.py adds three cases:

  • test_concurrent_handle_calls_do_not_overlap — asyncio.gather's 8 handle() calls against an overlap-detecting stub handler; asserts max_concurrent==1 and FIFO completion. Fails loudly the moment the lock is removed.
  • test_handle_lock_attribute_exists — catches an accidental rename/removal in a refactor.
  • test_lock_is_per_client_not_global — two clients on independent sessions must NOT block each other.

Full unit suite 246/246 green. Show HN hard gate + HiTL CLI integration + test_ingest integration green across 4 consecutive suite runs.

Compatibility

Pure addition. No API surface change, no payload shape change, no hash chain change. pip install -U rootsign[langgraph] picks v0.1.3 automatically. Existing chains continue to verify unchanged.

Examples re-pinned to rootsign[langgraph]>=0.1.3 so a fresh install in examples/langgraph-invoice-agent/ picks up the fix.

Who should upgrade

Anyone running LangGraph through ToolNode or create_react_agent, or any other agent that issues concurrent tool calls under a single LocalIngestClient.