|
| 1 | +# Architecture |
| 2 | + |
| 3 | +Status: active |
| 4 | + |
| 5 | +`fincrawl` is a local-first support conversation archive CLI. The reusable repo |
| 6 | +owns generic crawling, storage, search, artifact, guardrail, release, and |
| 7 | +agent-facing mechanics. Tenant credentials, tenant config, runtime state, |
| 8 | +generated artifacts, logs, reports, screenshots, and transcript-derived examples |
| 9 | +stay outside this repo. |
| 10 | + |
| 11 | +## Current Surface |
| 12 | + |
| 13 | +Core commands: |
| 14 | + |
| 15 | +```bash |
| 16 | +fincrawl doctor --offline |
| 17 | +fincrawl metadata --json |
| 18 | +fincrawl status --json |
| 19 | +fincrawl sync --fixture testdata/synthetic |
| 20 | +fincrawl sync --entities |
| 21 | +fincrawl sync --updated-since 2h --limit 50 |
| 22 | +fincrawl sync --resume |
| 23 | +fincrawl sync --conversation <id> |
| 24 | +fincrawl search "billing refund" --json |
| 25 | +fincrawl archive --fixture testdata/synthetic --recipient <age-recipient> --out tmp/archive.jsonl.zst.age |
| 26 | +fincrawl publish --recipient <age-recipient> --out snapshots/local.jsonl.zst.age |
| 27 | +fincrawl import --identity <age-identity> --in snapshots/local.jsonl.zst.age |
| 28 | +fincrawl guard --json |
| 29 | +``` |
| 30 | + |
| 31 | +The CLI defaults to JSON output for agent use. Human text output is explicit. |
| 32 | +Live provider credentials are optional and local; deterministic verification |
| 33 | +uses synthetic fixtures. |
| 34 | + |
| 35 | +## Package Shape |
| 36 | + |
| 37 | +```text |
| 38 | +cmd/fincrawl/ CLI entrypoint |
| 39 | +internal/cli/ command parsing, JSON output, errors, Agent DX metadata |
| 40 | +internal/config/ env and local config loading with redaction |
| 41 | +internal/control/ machine-readable command descriptions and safe examples |
| 42 | +internal/intercom/ provider API client boundary |
| 43 | +internal/syncer/ fixture, entity, exact, and tail sync orchestration |
| 44 | +internal/store/ SQLite schema, migrations, export, search, sync state |
| 45 | +internal/archive/ canonical JSONL, zstd compression, age encryption |
| 46 | +internal/guard/ preflight repository leak checks |
| 47 | +internal/lock/ local write lock |
| 48 | +``` |
| 49 | + |
| 50 | +`openclaw/crawlkit` is used where it fits local crawler mechanics. Provider API |
| 51 | +shape, privacy rules, archive format, and support-search semantics stay in |
| 52 | +`fincrawl`. |
| 53 | + |
| 54 | +## Store |
| 55 | + |
| 56 | +SQLite is the local archive source of truth. The schema stays migration-friendly |
| 57 | +and small: |
| 58 | + |
| 59 | +- `workspaces` |
| 60 | +- `conversations` |
| 61 | +- `conversation_parts` |
| 62 | +- `contacts` |
| 63 | +- `admins` |
| 64 | +- `teams` |
| 65 | +- `tags` |
| 66 | +- `conversation_tags` |
| 67 | +- `sync_state` |
| 68 | +- `raw_blobs` |
| 69 | +- `conversation_fts` |
| 70 | + |
| 71 | +Search uses FTS with sanitized queries and a fallback path where needed. Raw |
| 72 | +provider JSON is retained locally for replay and migration debugging, but it is |
| 73 | +tenant data and must not be committed to this repo. |
| 74 | + |
| 75 | +## Sync |
| 76 | + |
| 77 | +Sync paths are deliberately separate: |
| 78 | + |
| 79 | +- Fixture sync imports synthetic test data and exercises the real store/search |
| 80 | + path without credentials. |
| 81 | +- Entity sync hydrates read-only provider metadata such as admins, teams, tags, |
| 82 | + and capped contacts when scopes allow. |
| 83 | +- Exact sync hydrates one conversation by ID. |
| 84 | +- Tail sync searches recently updated conversations, stores resumable sync |
| 85 | + state, then hydrates exact conversations. |
| 86 | + |
| 87 | +Provider access must use supported APIs or official export paths only. Browser |
| 88 | +scraping, undocumented endpoint crawling, credential-sharing workarounds, and |
| 89 | +rate-limit bypasses are out of scope. |
| 90 | + |
| 91 | +## Artifacts |
| 92 | + |
| 93 | +Archive output is canonical JSONL streamed through zstd compression and explicit |
| 94 | +age encryption. Supported artifact shape: |
| 95 | + |
| 96 | +```text |
| 97 | +*.jsonl.zst.age |
| 98 | +``` |
| 99 | + |
| 100 | +Plaintext archives, databases, logs, snapshots, screenshots, reports, and |
| 101 | +transcripts are ignored and blocked by `fincrawl guard`. Encrypted tenant |
| 102 | +snapshots are still tenant data and belong outside this repo. |
| 103 | + |
| 104 | +## Agent Use |
| 105 | + |
| 106 | +Agents should load [the repo skill](../skills/fincrawl/SKILL.md) before using a |
| 107 | +local archive. It describes binary discovery, read-only search, live sync |
| 108 | +boundaries, portable store expectations, and current Agent DX conventions. |
0 commit comments