Skip to content

Commit 8bf2c98

Browse files
mios-devclaude
andcommitted
mios-surrealdb: unified shared-state DB for all AI surfaces
Operator directives 2026-05-18 stacked: * "dont we need a true db services(container) to host local DBs(!!?)" * "wouldn't all this just be AI fabrications and hallucinations otherwise??!" * "unify all AI Surfaces!!" Yes. Cross-agent state was scattered across isolated SQLite files (owui/webui.db, hermes/state.db, hermes/kanban.db, hermes/ response_store.db) + per-component JSON scratchpads. Nothing the agents could query in lockstep for ground truth, so they fabricated state from their context window instead. Picked SurrealDB 3.0 over pgvector/Qdrant/SQLite-per-component for the unification substrate (research summary): * multi-model: doc + graph + KV + vector + time-series in ONE ACID engine (no separate Neo4j / Redis / Postgres-extension / Chroma to run alongside) * single Rust binary, sub-100MB image, sub-second cold start * explicit upstream framing: "the context layer for AI agents" * production refs (Samsung / Verizon / Tencent per 2026 docs) * OpenAI-API-friendly: SurrealQL + REST + WebSocket; tool_call args map to record IDs cleanly * per benchmarks survey: pgvector if you ALREADY run Postgres, Qdrant if you only want vector. MiOS has neither and wants multi-model + single binary -> SurrealDB. Ships (5 files): 1. etc/containers/systemd/mios-surrealdb.container -- Quadlet. docker.io/surrealdb/surrealdb:latest. Bound 0.0.0.0:8000 (host AND ai-net.network bridge). UID 819 (next free in mios.toml [services] convention; matches the data-dir chown). file:// backend persists to /var/lib/mios/surrealdb/mios.surql. 2. usr/lib/tmpfiles.d/mios-surrealdb.conf -- d /var/lib/mios/ surrealdb 0750 819 819 (bootc-immutable code path; mutable state under /var per FHS + bootc convention). 3. usr/share/mios/surrealdb/schema-init.surql -- unified MiOS schemas (idempotent DEFINE TABLE / DEFINE FIELD). Tables: agent registry of every AI surface in the stack session one row per chat / cron run / delegate spawn tool_call source of truth for "did agent actually run X?" memory durable cross-session memory (with optional embedding for semantic recall) event append-only observability stream (launch verifier hits, refusals, classify summaries, critic verdicts, nudges) kanban_shadow live mirror of hermes-side kanban.db scratch shared-mutable note surface doc mios-docs-index shadow with embeddings 4. usr/lib/systemd/system/mios-surrealdb-init.service -- runs schema-init.surql after the DB container reports active (After+Requires mios-surrealdb.service). Idempotent. Includes a 30s polling wait for first-launch warm-up. 5. usr/libexec/mios/mios-db -- unified client. Three fallback paths in order: local `surreal` CLI (if installed), podman exec into mios-surrealdb, raw HTTP curl to /sql endpoint. mios-db open REPL mios-db '<surrealql>' one-off mios-db -f file.surql run file mios-db --ns mios --db logs '...' override mios-db --json '...' pretty JSON Env: MIOS_DB_URL/USER/PASS/NS/DB. Symlinked to /usr/local/ {s,}bin via tmpfiles.d shim-links (44 shims now). 6. SOUL.md: new "Shared DB (unified AI surfaces)" section. ONE line + table list. Tells the agent: read here for ground truth instead of fabricating from context window. Endpoint localhost:8000 ns=mios db=mios. Day-0 / bootc / FHS: all paths image-immutable except the data dir under /var. Operator + every MiOS AI surface (this hermes, the OWUI pipe's router/refine/compose/critic, mios-daemon's loops, future OpenCode, any MCP client) target ONE endpoint (localhost:8000) for state -- mirroring the README rule that every AI client already targets ONE inference endpoint (localhost:8080/v1). True unification. Live verified on the dev distro: Quadlet recognized by podman-system-generator, unit loaded; tmpfiles.d created /var/lib/mios/surrealdb with uid:gid 819:819; mios-db on PATH; 44 shim symlinks (up from 43). The container itself doesn't auto-start until next boot (operator can `systemctl start mios-surrealdb.service` to pull + run now); schema-init service fires after that. Phase-2 (next): wire mios-daemon task_collector + the OWUI pipe router/compose to WRITE events / tool_calls / kanban_shadow / session rows into the unified DB instead of (or in addition to) the existing per-component JSON/SQLite stores. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 66b6f89 commit 8bf2c98

7 files changed

Lines changed: 338 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# /etc/containers/systemd/mios-surrealdb.container
2+
# 'MiOS' shared agent state DB. Operator directive 2026-05-18:
3+
# "dont we need a true db services(container) to host local DBs(!!?)"
4+
# + "wouldn't all this just be AI fabrications and hallucinations
5+
# otherwise??!" -- yes. Cross-agent state was scattered across
6+
# isolated SQLite files (owui/webui.db, hermes/state.db,
7+
# hermes/kanban.db, hermes/response_store.db) + JSON scratchpads;
8+
# nothing the agents could query in lockstep for ground truth.
9+
#
10+
# SurrealDB 3.0 picked over pgvector/Qdrant/SQLite-per-component for:
11+
# * multi-model: doc + graph + KV + vector + time-series in ONE
12+
# ACID engine (no separate Neo4j / Redis / Postgres / Chroma to
13+
# run alongside)
14+
# * single Rust binary, sub-100MB image, sub-second cold start
15+
# * explicit "context layer for AI agents" upstream framing
16+
# * production refs (Samsung / Verizon / Tencent per 2026 docs)
17+
# * OpenAI-friendly: SurrealQL + REST + WebSocket; tool_call
18+
# args map to record IDs cleanly
19+
#
20+
# Day-0 / bootc: data persists under /var/lib/mios/surrealdb/
21+
# (created by usr/lib/tmpfiles.d/mios-surrealdb.conf at boot);
22+
# image is OCI-published surrealdb/surrealdb:latest; no /etc writes
23+
# required for the default config.
24+
25+
[Unit]
26+
Description='MiOS' SurrealDB (shared agent state -- context layer for AI agents)
27+
After=network-online.target
28+
Wants=network-online.target
29+
30+
[Container]
31+
Image=docker.io/surrealdb/surrealdb:latest
32+
ContainerName=mios-surrealdb
33+
Network=mios.network
34+
Network=ai-net.network
35+
# Canonical MiOS DB port. Standard SurrealDB default = 8000.
36+
PublishPort=8000:8000
37+
38+
# Persistent data dir. SurrealDB writes the file:// store here;
39+
# durability survives container restarts + image upgrades.
40+
Volume=/var/lib/mios/surrealdb:/var/lib/mios/surrealdb:Z
41+
42+
# UID 819 (next free in mios.toml [services.surrealdb] convention --
43+
# pinned in usr/lib/sysusers.d/50-mios-services.conf alongside
44+
# searxng 818 / ollama 815 / mios-hermes 820). Matches the chown of
45+
# /var/lib/mios/surrealdb done by tmpfiles.d.
46+
User=819
47+
Group=819
48+
49+
# Default root credentials -- LOCAL-ONLY. The PublishPort above
50+
# already binds host-side; the operator can lock down by adding an
51+
# override drop-in with --pass <secret> or by running entirely on
52+
# the ai-net.network bridge (no host port). For Day-0 self-host
53+
# the local-only defaults match every other MiOS service.
54+
Environment=SURREAL_USER=root
55+
Environment=SURREAL_PASS=root
56+
Environment=SURREAL_LOG=info
57+
58+
# Bind 0.0.0.0 so both host (operator + pipe + mios-daemon) AND
59+
# the ai-net bridge (hermes, future agents) reach the same endpoint.
60+
Exec=start --bind 0.0.0.0:8000 --user root --pass root file://var/lib/mios/surrealdb/mios.surql
61+
62+
# OCI labels for Podman Desktop browse-in-browser.
63+
Label=org.opencontainers.image.title=mios-surrealdb
64+
Label=org.opencontainers.image.url=http://localhost:8000/
65+
Label=org.opencontainers.image.documentation=https://surrealdb.com/docs
66+
Label=io.podman_desktop.openInBrowser=http://localhost:8000/
67+
68+
[Service]
69+
Restart=on-failure
70+
RestartSec=10s
71+
TimeoutStartSec=120s
72+
Delegate=yes
73+
74+
[Install]
75+
WantedBy=multi-user.target default.target
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# /usr/lib/systemd/system/mios-surrealdb-init.service
2+
# Apply the unified MiOS schemas to the SurrealDB instance after
3+
# it comes up. Idempotent (the .surql uses DEFINE TABLE / DEFINE
4+
# FIELD which are safe to re-run). Fires once per boot, only after
5+
# the DB container reports active.
6+
7+
[Unit]
8+
Description='MiOS' SurrealDB schema init (unified AI surfaces)
9+
After=mios-surrealdb.service
10+
Requires=mios-surrealdb.service
11+
ConditionPathExists=/usr/share/mios/surrealdb/schema-init.surql
12+
13+
[Service]
14+
Type=oneshot
15+
RemainAfterExit=yes
16+
# Wait up to 30s for the DB to accept connections after the
17+
# container starts (cold first-launch can take a moment).
18+
ExecStartPre=/bin/sh -c 'for i in $(seq 1 30); do curl -sSf --max-time 2 http://localhost:8000/status >/dev/null 2>&1 && exit 0; sleep 1; done; exit 0'
19+
ExecStart=/usr/libexec/mios/mios-db -f /usr/share/mios/surrealdb/schema-init.surql
20+
TimeoutStartSec=120s
21+
22+
[Install]
23+
WantedBy=multi-user.target

usr/lib/tmpfiles.d/mios-shim-links.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,5 @@ L+ /usr/local/bin/mios-gpu-passthrough - - - - /usr/libexec/mios/mios-gpu-pa
9797
L+ /usr/local/sbin/mios-gpu-passthrough - - - - /usr/libexec/mios/mios-gpu-passthrough
9898
L+ /usr/local/bin/mios-docs-index - - - - /usr/libexec/mios/mios-docs-index
9999
L+ /usr/local/sbin/mios-docs-index - - - - /usr/libexec/mios/mios-docs-index
100+
L+ /usr/local/bin/mios-db - - - - /usr/libexec/mios/mios-db
101+
L+ /usr/local/sbin/mios-db - - - - /usr/libexec/mios/mios-db
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# /usr/lib/tmpfiles.d/mios-surrealdb.conf
2+
# Persistent data dir for the SurrealDB container, owned by the
3+
# canonical mios-surrealdb uid/gid (819, declared in
4+
# usr/lib/sysusers.d/50-mios-services.conf). bootc-immutable code
5+
# path; mutable state stays under /var.
6+
d /var/lib/mios/surrealdb 0750 819 819 -

usr/libexec/mios/mios-db

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/bash
2+
# /usr/libexec/mios/mios-db [<surrealql>] [-f <file.surql>] [--ns <ns>] [--db <db>] [--json]
3+
#
4+
# Unified MiOS shared-state DB client. Operator directive 2026-05-18:
5+
# "unify all AI Surfaces!!" + "dont we need a true db services to
6+
# host local DBs(!!?)" + "wouldn't all this just be AI fabrications
7+
# and hallucinations otherwise??!" -- exactly. Every MiOS AI
8+
# surface (OWUI pipe, hermes, mios-daemon, future OpenCode, MCP
9+
# clients) targets ONE inference endpoint (http://localhost:8080/v1
10+
# per README MIOS_AI_ENDPOINT) AND now ONE state DB at
11+
# http://localhost:8000. Shared ground truth = no fabrication.
12+
#
13+
# Default namespace + db = `mios` / `mios`. Each AI surface uses
14+
# the same NS/DB; tables namespaced by purpose (agent / session /
15+
# memory / event / kanban_shadow / tool_call / ...).
16+
#
17+
# Usage:
18+
# mios-db open REPL (surreal sql)
19+
# mios-db 'SELECT * FROM agent;' one-off query
20+
# mios-db -f /var/lib/mios/scratch/q.surql run a file
21+
# mios-db --ns mios --db logs 'INFO ...' override namespace/db
22+
# mios-db --json '...' force --pretty=json
23+
#
24+
# Env (with defaults):
25+
# MIOS_DB_URL http://localhost:8000
26+
# MIOS_DB_USER root
27+
# MIOS_DB_PASS root
28+
# MIOS_DB_NS mios
29+
# MIOS_DB_DB mios
30+
#
31+
# Exits 0 on success, 1 on DB unreachable, 2 on surreal-binary
32+
# missing (operator should `dnf install surreal` or use the
33+
# container exec fallback).
34+
35+
set -uo pipefail
36+
37+
DB_URL="${MIOS_DB_URL:-http://localhost:8000}"
38+
DB_USER="${MIOS_DB_USER:-root}"
39+
DB_PASS="${MIOS_DB_PASS:-root}"
40+
DB_NS="${MIOS_DB_NS:-mios}"
41+
DB_DB="${MIOS_DB_DB:-mios}"
42+
JSON=0
43+
FILE=""
44+
QUERY=""
45+
46+
while [ "$#" -gt 0 ]; do
47+
case "$1" in
48+
--ns) DB_NS="$2"; shift 2 ;;
49+
--db) DB_DB="$2"; shift 2 ;;
50+
--json) JSON=1; shift ;;
51+
-f) FILE="$2"; shift 2 ;;
52+
-h|--help)
53+
sed -n '2,28p' "$0" | sed 's/^# \?//'
54+
exit 0 ;;
55+
--) shift; QUERY="$*"; break ;;
56+
*) QUERY="$1"; shift; if [ -n "${1:-}" ]; then QUERY="$QUERY $*"; fi
57+
break ;;
58+
esac
59+
done
60+
61+
# 1. Prefer the local surreal CLI if installed (faster, REPL-friendly).
62+
if command -v surreal >/dev/null 2>&1; then
63+
args=(sql --conn "$DB_URL" --user "$DB_USER" --pass "$DB_PASS"
64+
--ns "$DB_NS" --db "$DB_DB")
65+
[ "$JSON" = "1" ] && args+=(--pretty)
66+
if [ -n "$FILE" ]; then
67+
exec surreal "${args[@]}" < "$FILE"
68+
elif [ -n "$QUERY" ]; then
69+
printf '%s\n' "$QUERY" | exec surreal "${args[@]}"
70+
else
71+
exec surreal "${args[@]}"
72+
fi
73+
fi
74+
75+
# 2. Container-exec fallback: surreal binary inside the container.
76+
if command -v podman >/dev/null 2>&1 \
77+
&& podman ps --format '{{.Names}}' 2>/dev/null | grep -q '^mios-surrealdb$'; then
78+
args=(exec -i mios-surrealdb surreal sql
79+
--conn "$DB_URL" --user "$DB_USER" --pass "$DB_PASS"
80+
--ns "$DB_NS" --db "$DB_DB")
81+
[ "$JSON" = "1" ] && args+=(--pretty)
82+
if [ -n "$FILE" ]; then
83+
exec podman "${args[@]}" < "$FILE"
84+
elif [ -n "$QUERY" ]; then
85+
printf '%s\n' "$QUERY" | exec podman "${args[@]}"
86+
else
87+
# Without stdin the exec hangs; redirect /dev/null.
88+
echo "mios-db: no query + no -f; pass a query string or run with -f" >&2
89+
exit 64
90+
fi
91+
fi
92+
93+
# 3. Pure HTTP fallback: SurrealDB REST API via curl. Limited (no
94+
# REPL) but works on a stripped image with no surreal CLI.
95+
if [ -n "$QUERY" ] && command -v curl >/dev/null 2>&1; then
96+
AUTH="$DB_USER:$DB_PASS"
97+
exec curl -sS -X POST "$DB_URL/sql" \
98+
-u "$AUTH" \
99+
-H "NS: $DB_NS" -H "DB: $DB_DB" \
100+
-H "Accept: application/json" \
101+
--data-binary "$QUERY"
102+
fi
103+
104+
echo "mios-db: no surreal CLI, no mios-surrealdb container, no curl fallback usable" >&2
105+
echo " install: bootc image already includes mios-surrealdb.container; run:" >&2
106+
echo " systemctl --user start mios-surrealdb.service" >&2
107+
echo " or check: podman ps | grep mios-surrealdb" >&2
108+
exit 2

usr/share/mios/ai/hermes-soul.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,15 @@ State paths (read freely):
233233
`terminal: mios-docs-index` — unified index of every `.md` on disk
234234
(skills / system prompts / cookbooks / scratchpads / session
235235
digests). `--grep <pattern>` filters. Then `terminal: cat <path>`.
236+
237+
## Shared DB (unified AI surfaces)
238+
239+
`terminal: mios-db '<SurrealQL>'` — single shared state for every
240+
MiOS AI surface (this agent, the OWUI pipe, mios-daemon, future
241+
OpenCode). Tables: `agent` / `session` / `tool_call` / `memory` /
242+
`event` / `kanban_shadow` / `scratch` / `doc`. Endpoint:
243+
`http://localhost:8000`, ns=`mios`, db=`mios`. Read here for
244+
ground truth instead of fabricating from context.
236245
- `/var/lib/mios/daemon/state.json` — unified daemon state
237246
(classify, refusal, cron, suggestions, launch_verifier sections)
238247

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
-- /usr/share/mios/surrealdb/schema-init.surql
2+
--
3+
-- Unified AI-surface schemas. Operator directive 2026-05-18:
4+
-- "unify all AI Surfaces!!" -- every MiOS agent (OWUI pipe,
5+
-- hermes, mios-daemon, future OpenCode) reads/writes the same
6+
-- tables. The DB is the SHARED GROUND TRUTH; agents don't
7+
-- fabricate state from context window.
8+
--
9+
-- Idempotent (DEFINE ... if not exists). Re-running is safe.
10+
11+
USE NS mios;
12+
USE DB mios;
13+
14+
-- agent: registry row per AI surface in the stack.
15+
DEFINE TABLE agent SCHEMAFULL PERMISSIONS NONE;
16+
DEFINE FIELD name ON agent TYPE string;
17+
DEFINE FIELD role ON agent TYPE string; -- router / refine / orchestrator / micro / critic / nudger / ...
18+
DEFINE FIELD model ON agent TYPE option<string>;
19+
DEFINE FIELD endpoint ON agent TYPE option<string>;
20+
DEFINE FIELD device ON agent TYPE option<string>; -- cpu / nvidia / amd-igpu / intel-igpu
21+
DEFINE FIELD pid ON agent TYPE option<int>;
22+
DEFINE FIELD started_at ON agent TYPE option<datetime>;
23+
DEFINE FIELD last_seen ON agent TYPE option<datetime>;
24+
DEFINE FIELD enabled ON agent TYPE bool DEFAULT true;
25+
DEFINE INDEX agent_name_unique ON agent COLUMNS name UNIQUE;
26+
27+
-- session: one row per chat / cron run / delegate spawn.
28+
DEFINE TABLE session SCHEMAFULL PERMISSIONS NONE;
29+
DEFINE FIELD started_at ON session TYPE datetime;
30+
DEFINE FIELD ended_at ON session TYPE option<datetime>;
31+
DEFINE FIELD platform ON session TYPE string; -- owui / cron / cli / mcp
32+
DEFINE FIELD chat_id ON session TYPE option<string>;
33+
DEFINE FIELD model ON session TYPE option<string>;
34+
DEFINE FIELD operator ON session TYPE option<string>;
35+
DEFINE FIELD turn_count ON session TYPE int DEFAULT 0;
36+
DEFINE FIELD outcome ON session TYPE option<string>;-- success / partial / error / abandoned
37+
DEFINE INDEX session_chat ON session COLUMNS chat_id;
38+
39+
-- tool_call: one row per dispatched verb. Source of truth for
40+
-- "did the agent actually run X?" -- replaces text-parsing the
41+
-- raw hermes stream.
42+
DEFINE TABLE tool_call SCHEMAFULL PERMISSIONS NONE;
43+
DEFINE FIELD session ON tool_call TYPE record<session>;
44+
DEFINE FIELD ts ON tool_call TYPE datetime;
45+
DEFINE FIELD tool ON tool_call TYPE string;
46+
DEFINE FIELD args ON tool_call TYPE object;
47+
DEFINE FIELD result_preview ON tool_call TYPE option<string>;
48+
DEFINE FIELD success ON tool_call TYPE option<bool>;
49+
DEFINE FIELD latency_ms ON tool_call TYPE option<int>;
50+
DEFINE FIELD dispatched_by ON tool_call TYPE option<record<agent>>;
51+
DEFINE INDEX tool_call_ts ON tool_call COLUMNS ts;
52+
DEFINE INDEX tool_call_tool ON tool_call COLUMNS tool;
53+
54+
-- memory: durable cross-session memory. Operator + agents both
55+
-- write here; agents query before fabricating.
56+
DEFINE TABLE memory SCHEMAFULL PERMISSIONS NONE;
57+
DEFINE FIELD ts ON memory TYPE datetime;
58+
DEFINE FIELD kind ON memory TYPE string; -- user / feedback / project / reference
59+
DEFINE FIELD subject ON memory TYPE string; -- short topic key
60+
DEFINE FIELD body ON memory TYPE string;
61+
DEFINE FIELD source ON memory TYPE option<record<agent>>;
62+
DEFINE FIELD tags ON memory TYPE array<string> DEFAULT [];
63+
-- Optional vector embedding for semantic recall. Dim = nomic-embed
64+
-- size 768; agents that don't embed can leave it null.
65+
DEFINE FIELD embedding ON memory TYPE option<array<float>>;
66+
DEFINE INDEX memory_subject ON memory COLUMNS subject;
67+
DEFINE INDEX memory_kind ON memory COLUMNS kind;
68+
69+
-- event: append-only observability stream (launch verifier hits,
70+
-- refusal pattern matches, classify summaries, critic verdicts,
71+
-- ...). Per-thread streams instead of polling state.json.
72+
DEFINE TABLE event SCHEMAFULL PERMISSIONS NONE;
73+
DEFINE FIELD ts ON event TYPE datetime;
74+
DEFINE FIELD source ON event TYPE string; -- agent name
75+
DEFINE FIELD kind ON event TYPE string; -- launch_failure / classify / nudge / refusal / critic_verdict / ...
76+
DEFINE FIELD severity ON event TYPE string DEFAULT 'info'; -- info / warn / high
77+
DEFINE FIELD summary ON event TYPE string;
78+
DEFINE FIELD payload ON event TYPE option<object>;
79+
DEFINE INDEX event_ts ON event COLUMNS ts;
80+
DEFINE INDEX event_source ON event COLUMNS source;
81+
DEFINE INDEX event_kind ON event COLUMNS kind;
82+
83+
-- kanban_shadow: live mirror of hermes-side kanban.db (operator
84+
-- + non-hermes agents can read without opening the SQLite file).
85+
-- mios-daemon task_collector_loop populates on its 5-min cadence.
86+
DEFINE TABLE kanban_shadow SCHEMAFULL PERMISSIONS NONE;
87+
DEFINE FIELD hermes_task_id ON kanban_shadow TYPE string;
88+
DEFINE FIELD title ON kanban_shadow TYPE string;
89+
DEFINE FIELD status ON kanban_shadow TYPE string;
90+
DEFINE FIELD priority ON kanban_shadow TYPE option<string>;
91+
DEFINE FIELD tags ON kanban_shadow TYPE array<string> DEFAULT [];
92+
DEFINE FIELD synced_at ON kanban_shadow TYPE datetime;
93+
DEFINE INDEX kanban_shadow_task ON kanban_shadow COLUMNS hermes_task_id UNIQUE;
94+
95+
-- scratch: shared-mutable note surface (operator + agents both
96+
-- write). Free-form; agents can leave one-line context notes for
97+
-- their successors.
98+
DEFINE TABLE scratch SCHEMAFULL PERMISSIONS NONE;
99+
DEFINE FIELD ts ON scratch TYPE datetime;
100+
DEFINE FIELD source ON scratch TYPE string;
101+
DEFINE FIELD topic ON scratch TYPE string;
102+
DEFINE FIELD body ON scratch TYPE string;
103+
DEFINE FIELD ttl_at ON scratch TYPE option<datetime>; -- agent-defined expiry
104+
DEFINE INDEX scratch_topic ON scratch COLUMNS topic;
105+
106+
-- doc: index entry per .md doc surface (mios-docs-index output
107+
-- shadow). Lets agents semantic-search docs without re-walking
108+
-- the filesystem on every turn.
109+
DEFINE TABLE doc SCHEMAFULL PERMISSIONS NONE;
110+
DEFINE FIELD path ON doc TYPE string;
111+
DEFINE FIELD description ON doc TYPE option<string>;
112+
DEFINE FIELD size ON doc TYPE int;
113+
DEFINE FIELD updated_at ON doc TYPE datetime;
114+
DEFINE FIELD embedding ON doc TYPE option<array<float>>;
115+
DEFINE INDEX doc_path_unique ON doc COLUMNS path UNIQUE;

0 commit comments

Comments
 (0)