Skip to content

API Reference parrot.eval.sandbox.fakes

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.eval.sandbox.fakes

View source

Fake driver implementations for the Generic Agent Evaluation Harness.

FEAT-217 — These fakes translate toolkit method calls into DictStateBackend operations with NO real network/database/HTTP calls.

Provided fakes

FakeTableMetadata Minimal dataclass stub returned by DatabaseToolkitBinder._fake_resolve_table to avoid importing parrot.bots.database.models (which has broken optional deps in the test venv).

FakeRawConnection Implements the raw asyncpg connection surface (execute, fetchrow, fetch, close) by routing simple INSERT/UPDATE/DELETE/SELECT SQL to DictStateBackend operations. Only the SQL shape produced by PostgresToolkit's CRUD methods is handled — this is NOT a SQL engine.

FakeJiraClient Implements the subset of the pycontribs.jira.JIRA API exercised by the Jira triage benchmark: search_issues, assign_issue, transition_issue. State lives in a DictStateBackend.

StaticResolver Trivial credential resolver that always returns the same pre-built FakeJiraClient without any network I/O.

Class FakeJiraClient

In-memory Jira client backed by a DictStateBackend.

Implements the subset of the pycontribs.jira.JIRA API that the Jira triage benchmark exercises. State is stored in the "issues" collection of backend.

Parameter Type Default Description
backend Any DictStateBackend holding the issue store.

Method FakeJiraClient.search_issues

Search issues using a simple JQL-like filter.

Only the project = X and assignee is EMPTY / is not EMPTY conditions are recognized. All other conditions are ignored and all issues are returned.

search_issues(jql_str: str, maxResults: int = 50, fields: str = '*all', **kwargs: Any) -> list[_FakeIssue]

Parameter Type Default Description
jql_str str JQL query string.
maxResults int 50 Maximum number of results.
fields str '*all' Comma-separated field names (ignored — all fields returned).
**kwargs Any {}

Returns: list[_FakeIssue] — List of _FakeIssue objects.

Method FakeJiraClient.assign_issue

Assign issue to assignee.

assign_issue(issue: Any, assignee: str | None) -> None

Parameter Type Default Description
issue Any Issue key string or object with .key.
assignee str | None Assignee account id / username, or None to unassign.

Method FakeJiraClient.transition_issue

Transition issue to a new status.

transition_issue(issue: Any, transition: str, **kwargs: Any) -> None

Parameter Type Default Description
issue Any Issue key string or object with .key.
transition str Transition name / id (stored as status).
**kwargs Any {}

Method FakeJiraClient.issue

Fetch a single issue by key.

issue(key: str) -> _FakeIssue | None

Parameter Type Default Description
key str Issue key (e.g. "PROJ-1").

Returns: _FakeIssue | None — _FakeIssue or None.

Method FakeJiraClient.create_issue

Create a new issue.

create_issue(fields: dict[str, Any], **kwargs: Any) -> _FakeIssue

Parameter Type Default Description
fields dict[str, Any] Issue fields dict; must contain "project" and "summary".
**kwargs Any {}

Returns: _FakeIssue — The created _FakeIssue.

Method FakeJiraClient.update_issue_field

Update fields of an existing issue.

update_issue_field(key: str, fields: dict[str, Any]) -> None

Parameter Type Default Description
key str Issue key.
fields dict[str, Any] Fields to update (merged).

Class FakeRawConnection

Fake asyncpg connection that routes CRUD SQL to a DictStateBackend.

PostgresToolkit._run_on_conn calls three methods on the raw connection:

  • await conn.execute(sql, *args) — no return value needed
  • await conn.fetchrow(sql, *args) — returns a dict-like or None
  • await conn.fetch(sql, *args) — returns a list of dict-likes

This fake parses the table name from the SQL text (the SQL templates produced by PostgresToolkit are well-structured) and delegates to DictStateBackend CRUD operations. It is intentionally not a general-purpose SQL engine.

Parameter Type Default Description
backend Any The DictStateBackend instance holding world state.

Method FakeRawConnection.execute

Execute a DML statement (INSERT / UPDATE / DELETE).

execute(sql: str, *args: Any) -> None

Parameter Type Default Description
sql str SQL template with $N placeholders.
*args Any () Positional parameter values.

Method FakeRawConnection.fetchrow

Execute a query returning at most one row.

fetchrow(sql: str, *args: Any) -> dict[str, Any] | None

Parameter Type Default Description
sql str SQL template with $N placeholders.
*args Any () Positional parameter values.

Returns: dict[str, Any] | None — Dict of the row or None.

Method FakeRawConnection.fetch

Execute a query returning multiple rows.

fetch(sql: str, *args: Any) -> list[dict[str, Any]]

Parameter Type Default Description
sql str SQL template with $N placeholders.
*args Any () Positional parameter values.

Returns: list[dict[str, Any]] — List of row dicts.

Method FakeRawConnection.close

No-op close.

close() -> None

Class FakeTableMetadata

Minimal table metadata stub used by DatabaseToolkitBinder.

Provides the attributes read by PostgresToolkit internals (schema, tablename, full_name, columns, primary_keys) without importing parrot.bots.database.models.

Parameter Type Default Description
schema str
tablename str
full_name str ''
table_type str 'BASE TABLE'
columns list list()
primary_keys list list()

Fields:

Field Type Default Description
schema str Schema name.
tablename str Table name.
full_name str field(default='') schema.tablename composite.
table_type str 'BASE TABLE' Always "BASE TABLE" for the fake.
columns list field(default_factory=list) Empty list (CRUD pipeline skips unknown columns).
primary_keys list field(default_factory=list) Empty list.

Class StaticResolver

Credential resolver that always returns a pre-built FakeJiraClient.

Satisfies the credential_resolver.resolve(channel, user_id) contract used by JiraToolkit._pre_execute when auth_type == "oauth2_3lo", but without any network call.

Parameter Type Default Description
fake_client FakeJiraClient The FakeJiraClient to always return.
access_token str 'fake-token-00000000' Fake access token string (used to fill token_hash).

Method StaticResolver.resolve

Return a fake token set with the pre-built client embedded.

resolve(channel: str, user_id: str) -> Any

Parameter Type Default Description
channel str Channel identifier (ignored).
user_id str User identifier (ignored).

Returns: Any — An object with .access_token set to the fake token string (so JiraToolkit._pre_execute builds the token fingerprint and looks up self._client_cache).

Method StaticResolver.get_auth_url

Return a placeholder auth URL (never called in eval context).

get_auth_url(channel: str, user_id: str) -> str

Parameter Type Default Description
channel str Channel identifier.
user_id str User identifier.

Returns: str — Placeholder URL string.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally