Docs
GuidesWebsite GitHub
OverviewGetting StartedTry the Demo DatabaseApprove a Database WriteTerminal and CLIBackground Host
AgentConversationsConfigurationAuthenticationLLM ProvidersToolsPython Analysis
Data SourcesSQLitePostgreSQLFiles and FoldersHTTP APIsQueryingCatalogDatabase WritesRemote MCP ToolsPrivate Database
Work BoardArtifactsJobsRoutines
Memory and LearningSemanticsSkills
Observation EventsError HandlingEvaluation
Daita / Docs
OverviewGetting StartedTry the Demo DatabaseApprove a Database WriteTerminal and CLIBackground Host
AgentConversationsConfigurationAuthenticationLLM ProvidersToolsPython Analysis
Data SourcesSQLitePostgreSQLFiles and FoldersHTTP APIsQueryingCatalogDatabase WritesRemote MCP ToolsPrivate Database
Work BoardArtifactsJobsRoutines
Memory and LearningSemanticsSkills
Observation EventsError HandlingEvaluation

Daita Agents ยท Guide

Database Writes

Let the agent change rows in named PostgreSQL tables, one approved statement at a time, with a receipt and a recovery path.

By default Daita only reads. You can separately allow it to insert, update or delete rows in named PostgreSQL tables. The agent proposes one SQL statement with data_write. Daita shows exactly what it will change. You approve, and Daita applies it once and records a receipt.

PostgreSQL is the only source that can be written. SQLite, files and folders cannot.

Receipts are evidence, not a backup. Before you enable writes on a database you care about, verify that you can restore it.

#What a write can be

One statement on one table:

  • INSERT with a column list, including INSERT ... SELECT and ON CONFLICT (columns) DO UPDATE or DO NOTHING
  • UPDATE, including UPDATE ... FROM
  • DELETE, including DELETE ... USING

A batch upsert is INSERT ... VALUES ... ON CONFLICT with $1, $2, ... parameters: at most 1,000 rows and 64 KiB. A statement cannot contain RETURNING. Daita adds its own, so read generated values with data_query afterwards.

Daita refuses anything else: DDL, TRUNCATE, COPY, MERGE, two statements, a data-changing CTE, an INSERT with no column list, a table with no write scope, a view, a statement over 64 KiB or over the scope's row limit, and any statement PostgreSQL cannot preview.

#Four checks

A write needs all of these.

  1. PostgreSQL privileges. The attached role holds the native grants.
  2. A Daita write scope. A person enabled that table, those operations and those columns. Delete is enabled separately.
  3. Live checks. The table and role pass Daita's non-mutating checks.
  4. Approval now. Each write is one call that a person approves. Scheduled routines and jobs ask the same way.

The model cannot enable permissions or approve its own write.

#Set up

Use a dedicated role that you manage in PostgreSQL. It must not be a superuser or owner, and must not have BYPASSRLS, role creation, database creation or replication.

sql
CREATE ROLE daita_writer LOGIN
    NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOREPLICATION NOBYPASSRLS;
GRANT CONNECT ON DATABASE application_db TO daita_writer;
GRANT USAGE ON SCHEMA support TO daita_writer;
GRANT SELECT ON TABLE support.tickets TO daita_writer;
GRANT UPDATE (priority) ON TABLE support.tickets TO daita_writer;

The role needs SELECT because Daita previews and rechecks rows. Daita refuses views, partitioned and inherited tables, and tables with row-level security or rewrite rules. Triggers and cascading foreign keys are allowed, and the approval card names them.

#Enable a table

Attaching a source grants no write access. In the terminal app, open /source permissions, choose the source and the maximum rows per call, then Edit table write access. Pick a table, its operations and its columns. Review the before and after, then apply. Applying runs no write.

From Python, pass relational_write_scopes:

python
preview = await agent.preview_source_permissions(
    source_id=source.id,
    read_mode="all",
    read_resource_ids=(),
    relational_write_scopes={"public.companies": {
        "allowed_operations": ("insert", "update"),
        "allowed_insert_columns": ("domain", "name", "evidence_url"),
        "allowed_update_columns": ("name", "evidence_url"),
        "max_rows": 100,
    }},
)
await agent.apply_source_permissions(
    source_id=source.id,
    confirmation_fingerprint=preview.confirmation_fingerprint,
)

max_rows is 1 to 10,000. Insert columns go with insert and update columns with update. Editing one table keeps the others. Replacing the source connection clears every scope.

To disable a table, apply a scope with no operations. This does not revoke PostgreSQL grants. In an incident, remove the Daita scope first, then revoke or rotate the credential in PostgreSQL.

#Readiness check

Check a table without changing anything:

python
readiness = await agent.relational_write_readiness(source.id, "public.companies")
print(readiness.ready_for_preview, readiness.rejection_codes)
bash
daita relational-write-readiness atlas <source-id> public.companies

Readiness never proves that a future write will succeed.

#Preview and approval

By default data_write previews, asks for approval and writes. mode=preview shows the same facts and changes nothing.

Daita asks PostgreSQL what the statement targets, then runs a derived SELECT in a read-only transaction. No trigger fires and no row lock is taken. The approval card shows:

  • the exact SQL
  • the row counts and up to five sample rows
  • the columns changed
  • warnings, such as no WHERE, time or randomness, or triggers
  • how far Daita can verify the result
VerificationMeaning
rowsThe touched rows are compared before commit. Used for DELETE, and for tables with a usable primary or unique not-null key
countOnly the row count is compared. Used for tables without such a key

Approving is for that exact SQL, parameters, table structure and rows, and cannot be reused. A statement that changes nothing cannot be approved. A statement over the scope's max_rows is refused. Denying writes nothing.

#What happens after approval

Daita opens one transaction, re-reads the table, locks the target rows and reruns the preview. If anything changed, it refuses with write_state_changed. Otherwise it runs the statement once and compares what PostgreSQL reports with the locked rows. A mismatch rolls back with write_affected_rows_mismatch.

A write is never retried or replayed.

OutcomeMeaning
committedPostgreSQL acknowledged the commit and the rows matched the card
Refused before commitNothing was applied. Fix the cause and ask again for a new preview
write_outcome_unknownA commit was attempted and the result is unknown. This does not mean zero rows changed

For an unknown outcome: remove write access for the table, keep the receipt ID, do not retry, read the rows and compare them with what you intended, review PostgreSQL logs, then record your decision as described below.

#Effect receipts

Daita reserves a receipt before it dispatches a PostgreSQL write or an approved MCP action. The receipt binds the run, the call and the normalized operation, so an uncertain result can be investigated without repeating the action.

StatusMeaning
SUCCEEDED / ADAPTER_VERIFIEDA native transaction was verified, as with data_write
SUCCEEDED / SERVER_REPORTEDA remote MCP tool returned normally. Downstream completion is not verified
NOT_APPLIEDPositive evidence of rollback or that nothing was sent
UNCERTAINThe effect may have happened. A lost response is never proof of failure

A receipt left started by an interruption becomes UNCERTAIN when the agent reopens. Unresolved receipts survive clearing a conversation and block new foreground effects. Reading and inspecting stay available. An uncertain routine pauses. An uncertain job moves to Needs you on the Work board.

#Inspect and resolve

python
from daita import EffectResolutionDecision
 
pending = await agent.list_effects(unresolved_only=True, limit=20, offset=0)
receipt = await agent.inspect_effect(pending[0].receipt_id)
 
await agent.resolve_effect(
    receipt.receipt_id,
    expected_digest=receipt.receipt_digest,
    decision=EffectResolutionDecision.ALLOW_FUTURE_WORK,
    note="Checked the remote system and accept possible duplication.",
)
bash
daita effects list atlas --unresolved --limit 20 --offset 0
daita effects inspect atlas <receipt-id>
daita effects resolve atlas <receipt-id> \
  --expected-digest <receipt-digest> \
  --decision close_without_retry \
  --note "Investigated; close without repeating."

resolve_effect records a human decision and does nothing else. It never retries, never proves success or failure, and the original uncertain observation stays on the receipt. A person approves the exact decision first. Denial or a changed digest leaves the receipt untouched. The CLI has no --yes shortcut.

DecisionResult
close_without_retryDisables the routine that produced the effect
allow_future_workLeaves the routine paused. You still resume it and approve its next write

Repeat --evidence <id> to cite exact receipts or artifacts of this agent. Models and scheduled instructions cannot resolve a receipt. A corrective write needs its own preview and approval.

#Routines and jobs

A routine or job run writes the same way as a chat. It pauses, the host shows the card naming the routine or job and sends a notification, and you approve or deny. There is no standing permission to write without asking. If nobody answers in 24 hours the run is interrupted and shows as Needs you. A run with no approval path refuses the write.

The request's sensitivity must fit the source's classification. Related: Data Sources, Routines, Jobs.

PreviousCatalog
NextRemote MCP Tools

On this page

What a write can beFour checksSet upEnable a tableReadiness checkPreview and approvalWhat happens after approvalEffect receiptsInspect and resolveRoutines and jobs