Schema: - Add agent runtime tables: conversations, messages, runs, run_states, state_transitions, checkpoints, tool_results (all BLOB PKs, CASCADE) - Add jobs queue table with dedupe_key unique partial index - Add conversation graph tables: forks, links, threads, thread_messages, mentions, message_revisions sqlc config: - emit_db_tags: true — all generated structs carry db:"col" tags - Fix stale comment: "TEXT storage" → "BLOB storage" for UUID overrides - Add column overrides for all new agent runtime + conversation graph tables - Add CEL vet rules: no-unbounded-delete, one-select-requires-limit-1 Query hardening: - Add LIMIT 1 to 5 :one queries (recall, archival, working_context, docs, kv) - Bound 12 unbounded :many queries with LIMIT sqlc.arg(lim) - Add new query files for all agent runtime + jobs + conversation graph tables Delegate: - Add agentID param to GetRecallItem, DeleteRecallItem, GetArchivalChunk, ListArchivalChunks, ListAllArchivalChunks, CountArchivalChunks - Pass Lim param to ListDocumentsByCategory, ListAllDocuments (default 1000) - Pass Lim:10000 to ListArchivalChunks (bounded but practically unlimited) CI / Makefile: - Add sqlc-vet Makefile target (sqlc vet -f sqlc.yaml) - Add sqlc-vet step to sqlc-check CI job - Integrate sqlc-vet into check meta-target Tests: - Fix integration_test: add SetAgentID(testAgent), fix ListArchivalChunks/ GetArchivalChunk calls to pass agentID - Add benchmark suite for delegate ops
21 lines
No EOL
580 B
SQL
21 lines
No EOL
580 B
SQL
-- Working Context queries
|
|
-- name: GetWorkingContext :one
|
|
SELECT agent_id,
|
|
session_key,
|
|
content,
|
|
updated_at
|
|
FROM working_context
|
|
WHERE agent_id = sqlc.arg(agent_id)
|
|
AND session_key = sqlc.arg(session_key)
|
|
LIMIT 1;
|
|
-- name: UpsertWorkingContext :exec
|
|
INSERT INTO working_context (agent_id, session_key, content, updated_at)
|
|
VALUES (
|
|
sqlc.arg(agent_id),
|
|
sqlc.arg(session_key),
|
|
sqlc.arg(content),
|
|
datetime('now')
|
|
) ON CONFLICT (agent_id, session_key) DO
|
|
UPDATE
|
|
SET content = excluded.content,
|
|
updated_at = excluded.updated_at; |