avelino / avelino/dotagent

Add plugin: `sink-postgres`

Open
#22 0 comments 0 reactions 0 assignees View on GitHub
area: plugins type: feature
Dominant language
Rust
Stars
3
Forks
1
Avg merge
4h 50m
Merged PRs (30d)
1

Description

For agents that produce structured data (metrics, audit records, daily reports), sinking to a SQL database is more useful than sinking to a file. Today there is no plugin for that.

## Proposal

A new sink plugin `sink-postgres` that inserts a row into a Postgres table per agent run.

Manifest usage:

```toml
[[on_success]]
plugin = "sink-postgres"
dsn = "postgres://reports@host/agents?sslmode=require"
table = "agent_runs"
columns = ["agent", "schedule", "ran_at", "duration_seconds", "stdout"]
```

The plugin maps known agent-run fields onto the column list. If the user wants a custom shape, they can declare a SQL template:

```toml
[[on_success]]
plugin = "sink-postgres"
dsn = "postgres://..."
sql = """
INSERT INTO agent_runs (agent, ran_at, payload)
VALUES ($1, $2, $3::jsonb)
"""
bindings = ["{agent}", "{datetime}", "{stdout}"]
```

## Acceptance criteria

- [ ] New plugin crate under `plugins/sink-postgres/`.
- [ ] Speaks the standard plugin protocol.
- [ ] Connection pooling not required (one-shot, short-lived).
- [ ] TLS supported (`sslmode=require/verify-ca/verify-full`).
- [ ] DSN secrets never logged.
- [ ] Both "column list" and "raw SQL template" modes work.
- [ ] Doc page under `docs/plugins/sink-postgres.md` with an example schema.

## Where to start

- `plugins/sink-file/` and `plugins/sink-roam/` — convention.
- `tokio-postgres` or `sqlx` (evaluate trade-offs: sqlx is heavier but offers compile-time checks).

## Non-goals

- Migrations / DDL. The user provisions the table.
- Other databases (MySQL, SQLite). Separate plugins if there is demand.

Contributor guide

Open the contributing guide

Research direction

Start with plugins/sink-file/ and plugins/sink-roam/ to understand the standard plugin protocol and crate conventions. Evaluate tokio-postgres versus sqlx, then cover the manifest’s column-list and raw-SQL modes, TLS settings, and secret-safe logging. Done means the new plugin crate, documentation at docs/plugins/sink-postgres.md, and an example schema satisfy every acceptance criterion.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, rust
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.