Pi.Quack (pi_bridge v0.6.22)

Copy Markdown View Source

Eval-friendly analytical API for the pi-elixir QuackDB session mirror.

This module is intentionally thin: it gives eval users short aliases, Ecto schemas, QuackDB Ecto DSL helpers, and a runner against the built-in mirror. Prefer composing normal Ecto queries with use QuackDB.Ecto and run them with Pi.Quack.all/1, Pi.Quack.one/1, or Pi.Quack.table/1.

import Ecto.Query
use QuackDB.Ecto
alias Pi.Quack, as: Q
require Q
alias Pi.Quack.Event, as: E

from(e in Q.errors(),
  where: Q.matches(e.id, ^"function_clause"),
  order_by: [desc: Q.score(e.id, ^"function_clause")],
  limit: 20,
  select: %{score: Q.score(e.id, ^"function_clause"), tool: e.tool_name, payload: e.payload_json}
)
|> Q.table()

Summary

Functions

Runs an Ecto query or raw SQL and returns row maps with string keys.

Returns the named QuackDB client used by the built-in mirror.

Ensures the built-in QuackDB mirror plugin is loaded and reachable.

Base Ecto query for imported session JSONL entries.

Base Ecto query for rows marked as errors.

Base Ecto query for mirrored events.

Base Ecto query for synced session file metadata.

The generated DuckDB FTS schema for pi_events.

DuckDB JSON extraction expression.

DuckDB JSON scalar text extraction expression.

DuckDB FTS boolean match expression for pi_events.

Returns the first row map from an Ecto query or raw SQL.

Runs an Ecto query or raw SQL and returns a QuackDB.Result.

Rebuilds the FTS index for the mirror events table.

DuckDB FTS BM25 score expression for pi_events.

Returns code for token-efficient eval aliases/imports.

Runs raw SQL with parameters and returns a QuackDB.Result.

Returns compact status for the QuackDB mirror.

Runs a query and renders the result as a structured eval table.

Base Ecto query for mirrored tool calls.

Base Ecto query for mirrored tool results.

Functions

all(queryable, opts \\ [])

Runs an Ecto query or raw SQL and returns row maps with string keys.

conn()

Returns the named QuackDB client used by the built-in mirror.

ensure!()

Ensures the built-in QuackDB mirror plugin is loaded and reachable.

entries()

Base Ecto query for imported session JSONL entries.

errors()

Base Ecto query for rows marked as errors.

events()

Base Ecto query for mirrored events.

files()

Base Ecto query for synced session file metadata.

fts_schema()

The generated DuckDB FTS schema for pi_events.

json(payload_expression, path)

(macro)

DuckDB JSON extraction expression.

json_text(payload_expression, path)

(macro)

DuckDB JSON scalar text extraction expression.

matches(id_expression, query)

(macro)

DuckDB FTS boolean match expression for pi_events.

one(queryable, opts \\ [])

Returns the first row map from an Ecto query or raw SQL.

query!(queryable, opts \\ [])

Runs an Ecto query or raw SQL and returns a QuackDB.Result.

rebuild_fts!()

Rebuilds the FTS index for the mirror events table.

score(id_expression, query)

(macro)

DuckDB FTS BM25 score expression for pi_events.

setup()

Returns code for token-efficient eval aliases/imports.

sql!(sql, params \\ [], opts \\ [])

Runs raw SQL with parameters and returns a QuackDB.Result.

status()

Returns compact status for the QuackDB mirror.

table(queryable, opts \\ [])

Runs a query and renders the result as a structured eval table.

tool_calls()

Base Ecto query for mirrored tool calls.

tool_results()

Base Ecto query for mirrored tool results.