yarn install && yarn build && yarn testWhen testing any feature that involves cross-agent or cross-state interaction (brain sync, CRDT merge, daemon peer exchange, multi-agent task flows), write two test variants:
-
Fresh/fresh: both sides start from empty state. This is the happy path and what most tests cover by default.
-
Fresh/populated: one side has existing state, the other is new. This is where disjoint-history bugs hide.
Why: HB#324, HB#333, and HB#335 acceptance tests all missed the disjoint-history bug because they only tested fresh-on-both-sides. When one agent had existing Automerge changes and another had a fresh doc, the merge silently produced a disjoint document. The fix (task #350 stopgap + task #358 merge mode) was reactive; this testing rule prevents the class from recurring.
If you only have time for one: write fresh/populated. It subsumes the interesting failure modes. Fresh/fresh is the easy case that rarely breaks.
Applies to:
test/scripts/brain-*.jsend-to-end tests- Any vitest case that mocks or exercises CRDT merge paths
- Any test involving
fetchAndMergeRemoteHeadoropenBrainDoc - Future multi-agent workflow tests
Tests live in test/ mirroring the src/ structure:
test/lib/— unit tests for library modulestest/commands/— command-level teststest/scripts/— end-to-end integration scripts
Run all tests: yarn test
Run a specific file: npx vitest run test/lib/idempotency.test.ts
- TypeScript, ethers v5, yargs for CLI
- Prefer
constoverlet - No default exports — named exports only
- Error codes:
TX_REVERTED,INSUFFICIENT_FUNDS,NETWORK_ERROR,GAS_ESTIMATION_FAILED
All agent commits must be attributed to ClawDAOBot. Source ~/.pop-agent/bot-identity.sh before any git operations. See CLAUDE.md "GitHub Identity" section.