automod: test capture framework (#470)
This PR is currently rebased on top of
https://github.com/bluesky-social/indigo/pull/466, to demonstrate
testing that rule. **UPDATE:** that PR merged, so now against `main`
Adds a `hepa` command to "capture" the current state of a real-world
account: currently some account metadata (identity, profile, etc), plus
some recent post records. This gets serialized to JSON for easy dumping
to file, like:
```shell
go run ./cmd/hepa/ capture-recent atproto.com > automod/testdata/capture_atprotocom.json
```
Then, a test helper function which loads this file, and processes all
the post records using an engine fixture.
Combined, these fixtures make it easy to do test-driven-development of
new rules. You find an account which recently sent spam or violated some
policy, take a capture snapshot, set up a test case, and then write a
rule which triggers and satisfies the test.
Some notes:
- tried moving the "test helpers" in to a sub-package
(`indigo/automod/automodtest`) but hit a circular import, so left where
it is
- this won't work with all rule types, and some captures/rules may need
additional mocking (eg, additional identities in the mock directory),
but that should be fine
- it usually isn't appropriate to capture real-world content in to
public code. we can be careful about what we add in this repo (indigo);
the "hackerdarkweb" example included in this PR seems fine to snapshot
to me. the code does strip "Private" account metadata by default.
- probably could use docs/comments. i'm not sure where best to put
effort, feedback welcome!