Story-1010: implement MatterChat deterministic tools

Story 1010Epic 749๐Ÿ”— Chain of CustodyAgent Platform5 files ยท +842/โˆ’33

PR #24 ยท pramaan-io/pramaan-agents ยท merged 2026-06-03

How it flows

sequenceDiagram
  autonumber
  participant harness as Strands Harness
  participant ctx as Tool Context
  participant db as Database
  participant rec as Recorder
  harness->>ctx: bind firm/user/run
  ctx->>db: open connection
  db->>db: set RLS = firm_id
  db-->>ctx: rows
  ctx->>ctx: stamp duration
  ctx->>rec: log call
  ctx-->>harness: result

matter_chat_tools.py ยท +502 โ€” new methods

Methodin โ†’ outwhat it does
MatterChatToolContext(firm_id, user_id, run_id, tool_call_recorder, _tool_context)
matter_chat_tool_context(context) โ†’ Iterator[None]
_current_firm_id() โ†’ UUID

What changed, file by file

Holds the seven MatterChat read tools plus the run-scoped context class, RLS guard, and recorder decorator โ€” landing the deterministic toolset and firm/user/run binding this PR ships.

new classsignature
MatterChatToolContext(firm_id, user_id, run_id, tool_call_recorder, _tool_context)
matter_chat_tool_context(context) โ†’ Iterator[None]
_current_firm_id() โ†’ UUID
_get_engine() โ†’ Any
_set_rls(conn, firm_id) โ†’ None
_rows(statement, params) โ†’ list[Mapping[str, Any]]
_one(statement, params) โ†’ Mapping[str, Any] | None
_text(value, default) โ†’ Any
_uuid_text(value) โ†’ str
_string_list(value) โ†’ list[str]
_date_text(value) โ†’ str | None
_optional_int(value) โ†’ int | None
_citation(document_id, quote_id) โ†’ str
_run_tool(tool_name, input_json, body) โ†’ dict[str, Any]
_duration_ms(started) โ†’ int
_record_tool_calls(func) โ†’ F
wrapper() โ†’ dict[str, Any]

Gains a run id field so the tool context can carry a stable run identifier for the recorder and audit trail during MatterChat calls.

New fields: run_id : UUID | None

What must never ship

RLS set on every read
Recorder logs every call
Context bound per run
Watch nullable columns
Stub the recorder in tests
One missed line โ†’ cross-tenant leak

Files changed (5)

Fileยฑ
docs/walkthroughs/story-1010-walkthrough.html+61
src/pramaan_agents/runtime/app.py โ˜…+2
src/pramaan_agents/runtime/strands_harness.py โ˜…+13 โˆ’2
src/pramaan_agents/tools/matter_chat_tools.py โ˜…+502 โˆ’31
tests/test_matter_chat_tools.py+264