interplane.Get Omega
Read in your language

agent-archive

aien-dev/agent-archive

Brought by drakestapleton

GitHub aien-dev/agent-archive#7 (code only)

closed derived ad0116e5b9474100 #7

Imported from GitHub aien-dev/agent-archive#7 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 87b32d9930f4c64e4cd06659ef8beda1412c8fc4 · Head f8764e4962d53799616ea0e0a2a750f1c192d7a7

Fetch it

A git bundle of the pull request's head, 8342 bytes.

curl -fsSL https://interplane.io/drakestapleton/agent-archive/patches/ad0116e5b9474100.bundle -o ad0116e5b9474100.bundle
git fetch ad0116e5b9474100.bundle refs/pull/7/head

Raw bundle · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/agent-archive
7
f8764e4962d53799616ea0e0a2a750f1c192d7a7
{"kind":"github-import","owner":"aien-dev","repo":"agent-archive","number":7,"url":"https://github.com/aien-dev/agent-archive/pull/7","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:56Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 5952068..0bb2a4b 100644
--- a/.crumb
+++ b/.crumb
@@ -3,14 +3,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-28T22:34:16Z",
+      "compiled_at": "2026-11-04T20:52:31Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:94b08750645ee85eb6f546ad261ae6a7724edbf2b24c9a8613c86d4366e6a719",
+      "digest": "sha256:2a8d8ac15890a0fb8c1c83793e938ab24e5ae2cbec99f19aa8c9802462734434",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 14,
-      "generated_at_commit": "3d0e3a186f6a18d309eb037d959c051f757a803f",
-      "source_tree": "sha256:553463bd0f7f5ec5862ccb363ee4f6db55bf38f9b7156ac13ee808ebf05af711"
+      "files": 18,
+      "generated_at_commit": "1e77622eac9d707c87463e52259b1fa501a07e6a",
+      "source_tree": "sha256:a4aaf505b6e69b08b707be743ad7931648bff3ab5a2017f82008cb1adc8dc0e8"
     }
   },
   "layer": "tooling",
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..c0337ff
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,14 @@
+# Dependabot: monthly version updates for the pinned GitHub Actions and the Cargo lockfile.
+# Pull requests only; nothing merges itself. Security advisories are handled by GitHub
+# Dependabot security updates on the repository settings.
+version: 2
+updates:
+  - package-ecosystem: github-actions
+    directory: /
+    schedule:
+      interval: monthly
+  - package-ecosystem: cargo
+    directory: /
+    schedule:
+      interval: monthly
+    versioning-strategy: lockfile-only
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..3af3eb5
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,37 @@
+# CI: build and test with the committed Cargo.lock (--locked refuses any silent dependency
+# drift) on a GitHub-hosted runner, with pinned actions and read-only token permissions.
+# A second job writes an SPDX SBOM of the tree so auditors can diff what a commit contains.
+name: CI
+on:
+  pull_request:
+  push:
+    branches: [main]
+permissions:
+  contents: read
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    timeout-minutes: 30
+    steps:
+      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+        with:
+          persist-credentials: false
+      - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
+      - name: Toolchain record
+        run: rustc --version && cargo --version
+      - name: Build
+        run: cargo build --locked --all-targets
+      - name: Test
+        run: cargo test --locked
+  sbom:
+    runs-on: ubuntu-latest
+    timeout-minutes: 10
+    steps:
+      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+        with:
+          persist-credentials: false
+      - uses: anchore/sbom-action@66cbf4bc1f1c0d2edc94016e65bc221b6bb0ad6c # v0.24.3
+        with:
+          path: .
+          format: spdx-json
+          artifact-name: sbom-${{ github.sha }}.spdx.json
diff --git a/AUDIT_SCOPE.md b/AUDIT_SCOPE.md
new file mode 100644
index 0000000..6391dc2
--- /dev/null
+++ b/AUDIT_SCOPE.md
@@ -0,0 +1,116 @@
+# Audit scope
+
+Written for an outside, independent security audit. Revision described:
+`e102eb6bf3434b0f510c595cbaad097c9e29a1ca` on `main`, 2026-10-26. Everything below is taken from the repository's own files at
+that revision; items marked NOT_RUN were not executed while writing this document.
+
+## What this repository is
+
+A single Rust binary that collects AI agent chats (Claude Code, Codex, OpenCode, Gemini or
+Antigravity, Muse) on one host into plain JSONL records plus a verbatim raw mirror of the source
+files. The only network access is a read-only `ssh` and `scp` pull from a second machine reached
+through an ssh host alias. The repository holds the collector (`src/main.rs` 492 lines,
+`src/collectors.rs` 351, `src/core.rs` 370, `src/pb.rs` 86) and three small fixtures
+(`tests/fixtures/{claude,codex,muse}.jsonl`). The archive itself is outside the repository. Status:
+in use. Licence AGPL-3.0-or-later.
+
+## What to review, in priority order
+
+1. `src/core.rs` private-file layer: `private_check`, `private_metadata`, `private_dir`,
+   `private_existing_dir`, `private_open`, `private_read_to_string`, `private_file`,
+   `private_append`, `private_copy`, `atomic_write`. README: archive directories `0700`, files
+   `0600`; symlinks, foreign owners and group or other access are refused on reads and writes.
+   Check for time-of-check to time-of-use gaps between the metadata check and the open, and that
+   every write path goes through these helpers. `libc` is used only for the effective user ID.
+2. `pull_macbook` in `src/collectors.rs`. Runs `ssh` with `BatchMode=yes`, `ConnectTimeout=5`,
+   and a ControlMaster socket at `/tmp/agent-archive-mac-%C`, executes a fixed remote `find ... stat`
+   script, then parses each output line by splitting on spaces into four fields (subdirectory,
+   path, size, mtime). The first field and the file name from the remote path are joined into the
+   local destination under `raw/gemini/macbook/`, and the remote path is passed to
+   `scp macbook:{path}`. Check: whether a hostile or compromised remote can choose a destination
+   outside the mirror (for example a first field containing `..`), whether remote paths are
+   interpreted by the remote shell during `scp`, and the use of a shared `/tmp` control socket path.
+3. Parsers: `parse_<agent>` in `src/collectors.rs`; protobuf decoding `fields` in `src/pb.rs`
+   (Gemini step blobs, field numbers inferred, not from a schema). Check bounds on varints and
+   length-delimited fields and behaviour on truncated input.
+4. SQLite access (OpenCode database, Gemini per-conversation `.db`): opened read-only per AGENTS.md.
+   Check the open flags and that copies are made before parsing live files.
+5. `Store` in `src/core.rs`: de-duplication on `(agent, host, session, role, src.path, src.pos)`,
+   state cursors in `state/<agent>.json`, `latest/` views rewritten with temp file plus rename.
+   `Record::date` slices `ts[..10]`; check that every `ts` reaching it is normalised.
+6. `query` in `src/main.rs`: takes a user regex (`--grep`) over archive records; check regex
+   resource limits.
+7. `tests/fixtures/`: confirm no secrets, host names, home paths or private conversation content
+   (AGENTS.md rule).
+
+`.github/workflows/ci.yml` (added by the audit-readiness change) runs `cargo build --locked
+--all-targets` and `cargo test --locked` on a GitHub-hosted runner and publishes an SPDX SBOM
+artifact; actions pinned by commit sha, read-only token.
+
+## Trust boundaries
+
+- Untrusted input: the contents of agent chat stores (JSONL, SQLite, protobuf blobs), which hold
+  model and user text; the remote listing and files returned by the ssh pull.
+- Trusted: the local user account that owns the archive root, the local ssh configuration and its
+  keys (not in the repository), OpenSSH and the bundled SQLite.
+- Sensitive output: the archive holds full chat transcripts. README: raw chat never goes into
+  Cortex; only short digests and a pointer.
+
+## Threat model summary
+
+- Assets: confidentiality of the archived transcripts; integrity of source chat stores.
+- Attackers considered: another local user who tries to read the archive or swap a path with a
+  symlink; malformed source files; the remote machine in the pull.
+- Defended: private modes and ownership checks on every archive path, with refusal instead of
+  silent fallback; read-only opens of source stores; `BatchMode=yes` ssh.
+- Not defended / explicitly out of scope: a compromised local account that owns the archive;
+  the protobuf format is inferred and may mis-parse; README notes Mac `-shm` files are not pulled,
+  so uncommitted remote data may be missed. No encryption at rest is implemented.
+
+## Build from source at a pin
+
+Needs a Rust toolchain (version not pinned; no `rust-toolchain.toml`). `rusqlite` 0.32 builds its
+bundled SQLite, so no system SQLite is needed (AGENTS.md). `Cargo.lock` is committed (63 packages).
+
+```sh
+cargo build --release
+```
+
+## Run every test
+
+NOT_RUN while writing this document.
+
+```sh
+cargo test --release
+```
+
+The unit tests live in the `tests` module of `src/main.rs` (15 `#[test]` functions), including
+parser tests on the fixtures, a synthetic Gemini step, an OpenCode database the test builds itself,
+incremental passes and de-duplication after state loss, the capped `latest` window, private modes
+under a permissive umask, and refusal of unsafe roots, descendants, state files, duplicate records,
+history records, and `query` or `status` on unsafe paths. Expected: `test result: ok`.
+
+`collect`, `once`, `status`, `query` and `debug-pb` read real chat stores and write the archive;
+AGENTS.md says to run them only on the machine the archive belongs to. NOT_RUN on a plain host.
+`once --no-mac` skips the ssh pull.
+
+## Known limitations and NOT_RUN
+
+- Gemini protobuf field numbers are UNVERIFIED (README).
+- The ssh pull path has no unit test.
+- Deployed binary and on-disk permissions are not established by this repository (README).
+- Existing archives created before the permission checks need a manual repair (README gives
+  `find` and `chmod` commands).
+
+## Dependencies and provenance
+
+- `Cargo.lock` present. Direct dependencies: `serde_json` 1, `rusqlite` 0.32 (bundled SQLite),
+  `chrono` 0.4, `regex` 1, `libc` 0.2 (README: locked at 0.2.190).
+- Fetched from crates.io at build time.
+- At run time: `ssh` and `scp` for the optional pull.
+- No GitHub Actions. No vendored code beyond the SQLite bundled by `rusqlite`.
+
+## Evidence
+
+No receipts are stored in this repository. Archive records are append-only by design (AGENTS.md:
+"Records are append-only ... Losing state may cause re-reads but never duplicates").
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000..020c4b7
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,60 @@
+# Security policy
+
+## Reporting a vulnerability
+
+Report privately. Do not open a public issue, pull request or discussion about it.
+
+1. GitHub: open this repository's Security tab and choose "Report a vulnerability". This
+   creates a private advisory that only the maintainers can see. If that option is not shown,
+   private vulnerability reporting has not been enabled for this repository yet; use email.
+2. Email: drake@aienos.com with the subject `[agent-archive] security report`.
+
+Include the commit or release you tested, the component (path), steps to reproduce, and what an
+attacker gains. If the report involves a secret, say where it was exposed and do not send the
+secret itself. Encrypted mail is not required; do not post proof-of-concept payloads publicly.
+
+## Response targets
+
+This project has one maintainer; the targets below are best effort and stated honestly.
+
+- Acknowledgement: within 3 working days.
+- Triage and severity: within 7 days of acknowledgement.
+- Fix or mitigation for confirmed issues: aim for 30 days for high and critical, 90 days
+  otherwise, with a status update at least every 14 days until closed.
+- Disclosure: coordinated. An advisory is published with credit (unless you ask otherwise)
+  once the fix is on the default branch. Default embargo 90 days, negotiable.
+
+## Scope
+
+`agent-archive` is a Rust binary that collects AI agent chat stores on one host into an archive of
+JSONL records plus a verbatim raw mirror. The archive data lives outside the repository.
+
+In scope:
+
+- Parsers in `src/collectors.rs` and `src/pb.rs` that panic, loop, or write outside the archive
+  root on malformed chat files, SQLite databases or protobuf blobs.
+- The private-file checks in `src/core.rs`: any path where a symlink, a foreign owner, or group or
+  other access is not refused, or where a file is created with a mode wider than `0600` (or `0700`
+  for directories), as README states.
+- The read-only ssh and scp pull from a second machine (`pull_macbook` in `src/collectors.rs`):
+  remote listing output that can steer a write outside `raw/gemini/macbook/`, or a remote path that
+  is interpreted by a shell.
+- A write to an agent's own source chat files or database, which AGENTS.md says are opened
+  read-only.
+- Archive data, real transcripts, tokens, host names or home paths committed to the repository,
+  including inside `tests/fixtures/`.
+
+Out of scope:
+
+- The agents whose chat stores are read, OpenSSH, SQLite (bundled via `rusqlite`), and the host
+  operating system.
+
+## Supported versions
+
+Only the default branch `main`; there is no release (Cargo version `0.1.0`). Reports against older commits are welcome but fixes land on the default branch only.
+
+## Status
+
+README: the collector is in use; this repository documents the source behaviour and does not
+establish which binary or on-disk permissions are currently deployed. The Gemini protobuf format is
+UNVERIFIED (field numbers inferred from sampling). No certification, no bug bounty. See AUDIT_SCOPE.md for what to review and how to build and test it.