Chris Troutner dd11964174 Refactor topic metadata: cut CRAP, share test doubles, harden property tests
- Replace the ternary follower delta in recordTopicFollow with
  Number(isActive) - Number(wasActive), dropping its cyclomatic complexity
  from 8 to 6 (CRAP 8.0 -> 6.0). No behavior change.
- Extend the indexer topic property test to conserve lastSeen (newest post
  time) and followerCount (each address's final active follow state)
  alongside postCount/lastHeight, with varying post seen times.
- Extend the DB backfill and topic-query property tests to conserve lastSeen
  and followerCount; generated follows now include unfollows.
- Add a client topic-metadata property test covering relativeTime bucket
  classification, pluralization, monotonicity, and getLastSeenLabel
  consistency, and cover ensureTopicRoom's existing-summary path plus
  recordTopicFollow's legacy-follower-count fallback.
- Share one in-memory DB double per component (indexer test/support/
  memory-db.js, DB test/support/level-double.js) and table-drive the
  parallel topic-follow/topic-message/topic-query cases, clearing every
  dry4javascript candidate in the changed files.

Verification: indexer 113 unit / 12 property / 7 acceptance; db 387 unit /
57 property / 16 acceptance; client 441 unit / 90 property / 33 acceptance
+ build; lint clean. CRAP max 6.0; mutation scans under 100 sites/file.

By refactorer.
2026-09-18 06:02:13 -07:00
2026-09-18 05:38:41 -07:00
2026-08-26 09:30:44 -07:00
2026-08-26 09:10:39 -07:00
2026-08-26 12:05:01 -07:00
2026-08-26 09:10:39 -07:00

psf-memo

Memo.cash is a social media site that uses the Bitcoin Cash (BCH) blockchain to store the messages and send other social media signals, as per the memo protocol.

This is a vibe-coded mono-repo that replicates the memo infrastructure:

  • psf-memo-client - React web app using Bootstrap for styling. It provides a client for interacting with the BCH blockchain and social media network.
  • psf-memo-indexer - node.js JavaScript indexer that interfaces with the RPC port of a BCHN full node and crawls the blockchain, indexing transaction that conform to the memo protocol.
  • psf-memo-db - A Level database with a REST API for reading and writing to the database. The indexer writes data, the client reads it.

In addition to the three core pieces of infrastructure above, this repository integrates Uncle Bob's Swarm Forge idea for vibe-coded development by a team of four AI agents.

Repository layout

psf-memo-client/    React SPA for reading/writing Memo actions
psf-memo-indexer/   BCH block + mempool indexer for the Memo protocol
psf-memo-db/        LevelDB REST API (indexer writes, client reads)
specs/              Cross-component backlog and specification notes
swarmforge/         SwarmForge constitution, roles, scripts, and config

Development

Running the stack locally

# 1. Database
cd psf-memo-db && npm install && cp .env-example .env && npm start

# 2. Indexer (two processes, separate terminals)
cd psf-memo-indexer && npm install && cp .env-example .env
npm run block-indexer
npm run tx-indexer

# 3. Client
cd psf-memo-client && npm install && cp .env.example .env.development.local
npm start

See each component's README.md and dev-docs/ for architecture details.

Production (Docker)

Compose under psf-memo-indexer/production/docker builds all four services from this monorepo (no separate GitHub clones):

cd psf-memo-indexer/production/docker
cp memo-db/.env-example memo-db/.env
cp block-indexer/.env-example block-indexer/.env
cp tx-indexer/.env-example tx-indexer/.env
cp memo-client/.env-example memo-client/.env
docker compose build
docker compose up -d

Full ops notes: psf-memo-indexer/README.md.

SwarmForge development

This project is configured for SwarmForge with four pi-backed agents:

Role Worktree / branch Responsibility
specifier master Writes Gherkin specs and acceptance criteria
coder .worktrees/coder (swarmforge-coder) TDD implementation
refactorer .worktrees/refactorer (swarmforge-refactorer) Cleanup, coverage, structure
architect .worktrees/architect (swarmforge-architect) Architecture, mutation hardening

Start the swarm:

./swarm

Handoff helpers are on PATH via swarmforge/scripts/ when an agent launches.

Standing briefing for the specifier: specifier-prompt.md. Prioritized feature backlog: specs/feature-backlog.md.

Languages
JavaScript 80.8%
Gherkin 11.4%
Clojure 4.8%
CSS 1.5%
Shell 1.2%
Other 0.3%