- M7.1-M7.10: Extensible SourceConnector trait, Obsidian/paperless/git/S3 connectors, sync framework, CLI, HTTP endpoints, health monitoring, gate - M3.5.10: Auth integration with Authentik OIDC → Vault token validation - DESIGN.md: Add source connectors architecture, update auth to Authentik/Vault (Kong removed from cluster) - INDEX.md: 75 tasks, 11 gates - Fix all Kong references in M3.5.1 task
4.2 KiB
4.2 KiB
M7.7 — mem source CLI
| Field | Value |
|---|---|
| Phase | M7 — Source connectors |
| Size | M — 1–3 days |
| Status | ⬜ Not started |
| Flags | — |
| Spec | inlined below |
| Blocks | M7.8, M7.10 |
| Depends | M7.6 |
Goal
Provide CLI commands to manage source connectors: sync documents, check status, list connectors, add/remove connectors.
Facts (inlined — no spec read needed)
mem source list # all registered connectors + health
mem source status # drift report per connector, no mutations
mem source sync --all # sync all connectors
mem source sync --name homelab-vault # sync one connector
mem source sync --name homelab-vault --dry-run # show plan, no mutations
mem source add --kind paperless --name docs --config '{"base_url":"...","token":"..."}'
mem source rm --name old-source # deregister + tombstone all chunks
mem source health # connectivity check per connector
Output format. CLI outputs human-readable tables by default, --json for
machine consumption. Example:
$ mem source list
NAME KIND DOCS LAST SYNC HEALTH
homelab-vault obsidian 42 2026-08-26T10:00:00Z ✅ reachable
homelab-paperless paperless 127 2026-08-26T09:00:00Z ✅ reachable
infra-docs git_repo 18 2026-08-25T20:00:00Z ⚠️ pull failed
$ mem source status
NAME NEW CHANGED UNCHANGED REMOVED
homelab-vault 0 2 40 0
homelab-paperless 3 0 124 0
infra-docs 1 1 16 0
Steps
- Add
Sourcesubcommand group to clap CLI inmem-cli/src/main.rs. - Implement
cmd_source_list()— load registry, health check each, tabulate. - Implement
cmd_source_status()— load registry, run drift report per connector, tabulate. - Implement
cmd_source_sync()— load registry, run sync engine for selected connector(s), report results. - Implement
cmd_source_add()— validate kind, parse config, register inconnectors.yaml, run initial health check. - Implement
cmd_source_rm()— tombstone all chunks from connector, remove fromconnectors.yaml. - Implement
cmd_source_health()— connectivity check per connector. - Add
--dry-runto sync (show plan only). - Add
--jsonflag for machine-readable output.
Acceptance
- All subcommands execute without panic.
sync --dry-runshows plan without mutations.addvalidates kind exists in registry before writing config.rmtombstones chunks and removes config entry.statusshows drift without mutations.- Exit codes: 0 on success, non-zero on failure.
Verify
Harness: VecConnector registered in registry, temp connectors.yaml.
Integration test — tests/it_source_cli.rs:
a1_list_shows_connectors— register two connectors; assert list output contains both names and kinds.a2_status_shows_drift— modify connector docs; assert status shows correct new/changed/unchanged/removed counts.a3_sync_processes_changes— sync with changes; assert documents processed.a4_sync_dry_run_no_mutations— sync --dry-run; assert no log entries written.a5_add_registers_connector— add a new connector; assert it appears in list.a6_add_bad_kind_fails— add with unknown kind; assert non-zero exit.a7_rm_tombstones_and_deregisters— rm a connector; assert tombstone records written and connector removed from list.a8_health_reports_status— assert health output includes reachable/unreachable.a9_json_output— assert --json flag produces valid JSON.
Command: cargo test --test it_source_cli
False pass:
- Testing
listwithout checking that connectors are actually registered (not just config parsed).
Traps
sync --allwith a broken connector should not halt all syncs. Sync each independently, report failures per connector at the end.rmwithout--yesshould prompt for confirmation (destructive operation).- Don't write
connectors.yamlatomically — a crash mid-write corrupts config. Write to temp file, then rename.
Background: DESIGN.md — source connectors, CLI commands