interplane.Get Omega
Read in your language

agent-archive

aien-dev/agent-archive

Brought by drakestapleton

branch main Branches Tags History

agent-archive / README.md

119 lines · 8399 bytes Raw Blame History Rendered
1# agent-archive
2
3One central, long-term archive of every AI agent chat on the DGX Spark: OMP, Claude Code, Codex, OpenCode,
4Gemini/Antigravity (Spark and MacBook) and Muse. Plain JSONL files, one common record per message,
5plus a verbatim mirror of the original source files. Single Rust binary, no Python, no network except a
6read-only `ssh`/`scp` pull from the MacBook.
7
8Supports [Sovereign Intelligence (SI)](https://github.com/aien-dev/sovereign-intelligence), the whole system. It is a tool for the people and agents
9building AIEN: it keeps their chats so past work can be searched later.
10
11**Status:** the collector is in use. This repository documents the source behavior; it does not
12establish which binary or on-disk permissions are currently deployed.
13
14## Layout
15
16Archive root: `~/archive/agent-chats/` (override with `AGENT_ARCHIVE_ROOT`).
17
18The collector creates the archive root and every archive subdirectory with mode `0700`, and new
19records, raw copies, latest views, state files, and temporary files with mode `0600`. It rejects
20unsafe roots and top-level directories, and checks each descendant directory or file before use:
21symlinks, foreign owners, and group or other access are refused. This covers reads as well as
22writes: state cursors, the de-duplication scan, the history behind the latest views, pulled
23MacBook copies, and `status` and `query` refuse an unsafe path with an error (exit 1 for the
24commands) instead of treating it as absent. Use an owner-controlled parent for a custom root; do
25not put it under a directory another local user can replace.
26
27Before upgrading an existing archive, stop its collector and inspect its ownership and symlinks
28without printing transcript contents. With `root` set to the archive path, resolve any foreign
29ownership or symlink intentionally, then restrict existing entries:
30
31```sh
32find "$root" \( -type l -o ! -user "$(id -un)" \) -print
33find "$root" -type d -exec chmod 700 {} +
34find "$root" -type f -exec chmod 600 {} +
35```
36
37Do not run the mode repair on a path you do not own or on a live collector. The first command
38should print no entries before restarting. Existing files are not silently changed at startup.
39
40The lockfile pins `libc` 0.2.190, used here only for the effective user ID check. At an Omega
41cutover, replace this host call with an explicit owner-identity host interface; retain the
42mode and ownership refusal behavior.
43
44| Path | What |
45|---|---|
46| `records/<agent>/<YYYY-MM-DD>.jsonl` | common records, append-only, date = message timestamp (UTC) |
47| `raw/<agent>/<host>/<original relative path>` | verbatim copies of the source files (JSONL appended byte for byte as they grow; sqlite files copied when they change) |
48| `latest/<agent>.txt`, `latest/<agent>.jsonl` | rolling window, last 20000 records, rewritten atomically (temp file + rename). `.txt` lines look like `[ts session8 role] text` with newlines shown as `\n`; text is cut at 8000 characters (`...[truncated]`) |
49| `state/<agent>.json` | per-source cursors (byte offsets, row cursors, file signatures) |
50
51State loss only causes re-reads: records are de-duplicated on `(agent, host, session, role, src.path, src.pos)`
52and the raw mirror never writes bytes it already has.
53
54## Record schema
55
56```json
57{"ts":"2026-10-04T20:00:00.000Z","agent":"claude|codex|opencode|gemini|muse|omp","host":"spark|macbook",
58 "session":"<id>","role":"user|assistant|system","text":"...","model":null,"cwd":null,
59 "src":{"path":"...","pos":123}}
60```
61
62`src.pos` is the byte offset of the source line (JSONL sources), the step index (Gemini) or a stable hash of the
63part id (OpenCode). Only conversational text is turned into records; tool calls and results stay in `raw/`.
64
65## Commands
66
67```
68agent-archive collect # loop every 10 s (run detached)
69agent-archive once [--no-mac] # one pass, prints per-agent counts and duration
70agent-archive status # per agent: last record, today/total, sources, preview
71agent-archive query [--agent claude] --since 2026-10-04T00:00:00Z --grep 'regex' --limit 50 [--json]
72agent-archive debug-pb FILE # dump a raw protobuf blob (for Gemini format work)
73```
74
75## Sources and parsers
76
77| Agent | Source | Status |
78|---|---|---|
79| claude | `~/.claude/projects/**/*.jsonl`, lines `type` user/assistant, text blocks only | unit-tested on `tests/fixtures/claude.jsonl` |
80| codex | `~/.codex/sessions/**/*.jsonl`, `response_item` messages (`developer` becomes `system`) | unit-tested on `tests/fixtures/codex.jsonl` |
81| opencode | `~/.local/share/opencode/opencode.db` (opened read-only), `text` parts; raw mirror is `raw/opencode/spark/opencode-rows.jsonl` (one JSON line per text part, with its message JSON) because the database is live | unit-tested against a small database the test builds with the tables and columns the query reads; no sample of the live database is stored in this repo |
82| gemini | per-conversation sqlite `.db` in `~/.gemini/antigravity{,-cli,-ide}/conversations` (Spark) and, via `ssh` + `scp` to the host alias `macbook` (an entry in the local ssh config), `~/.gemini/antigravity{,-cli,-ide}/conversations` on the Mac into `raw/gemini/macbook/` | UNVERIFIED format: step blobs are protobuf with no schema available; field numbers (user text 19.3.1, reply 20.1, time 5.1) were inferred from sampling. Reply "thinking" text (20.3) is not turned into records. Mac WAL files are pulled but a `-shm` is not, so uncommitted Mac data may be missed |
83| muse | `~/.local/share/muse/sessions/**/session.jsonl`; user text from `runtime.user_intent.accepted`, replies from `assistant_message_committed` | partly verified (unit-tested on `tests/fixtures/muse.jsonl`): the original design note named `turn.input.user` / `run.output.delta`, but those did not occur in the 81 sessions on disk when this parser was written, so the events above are used instead. Framed `retained_frame` lines are only kept in raw |
84| omp | `~/.omp/agent/sessions/**/*.jsonl` (profile `default`) and `~/.omp/profiles/<name>/agent/sessions/**/*.jsonl`, subagent transcripts nested in session directories included; raw mirror is `raw/omp/<host>/<profile>/<path under sessions/>`. `message` lines with role user/assistant/developer (`developer` becomes `system`), text blocks only; session id and cwd from the `session` line, model from the message (`provider/model`) or the last `model_change` | unit-tested on `tests/fixtures/omp.jsonl` (synthetic, in the real format). The first line of a session file is a space-padded `title` record, apparently so the title can be rewritten in place; the raw mirror only appends, so it keeps that line as first read |
85
86A source whose directory or database does not exist (for example a retired harness) is skipped without
87an error.
88
89The Mac pull is skipped (with a log line) if the ssh connection fails, and runs at most every 5 minutes.
90`~/.gemini/antigravity-cli/history.jsonl` is command history only and is mirrored raw.
91
92## Adding a collector
93
941. Add `parse_<agent>(line, path, pos, host) -> Vec<Record>` in `src/collectors.rs` (pure function).
952. For JSONL sources call `drive_jsonl(...)` from a `collect_<agent>` function; for databases keep a cursor with
96 `store.cursor/set_cursor` and call `store.emit(record, check_dup)`.
973. Register it in `pass()` in `src/main.rs`, add the name to `AGENTS` in `src/core.rs`.
984. Cut a small fixture from a real sample (no secrets) into `tests/fixtures/` and add a unit test in the `tests` module of `src/main.rs`.
99
100## Cortex rule
101
102Raw chat never goes into Cortex (house rule). Cortex gets only short digests plus a pointer to this archive, later.
103
104## License
105
106AGPL-3.0-or-later.
107
108## Human-Directed Agentic Engineering
109
110Development follows Human-Directed Agentic Engineering (HDAE): humans define goals,
111architecture, constraints, acceptance criteria, and stopping points; agents implement,
112execute checks, diagnose failures, and revise within those boundaries. Human review
113retains responsibility for claims, acceptance, and release decisions. This describes
114the development method, not a change to runtime autonomy or historical evidence.
115
116For the documented method and a systems-software case study, see Gregory M. Kurtzer
117(2026), *Ginux: Building an Independent Kernel That Runs Linux Userspace through
118Human-Directed Agentic Engineering*, technical report, v1, Zenodo,
119<https://doi.org/10.5281/zenodo.23682548>.