Skip to content

Latest commit

 

History

History
182 lines (141 loc) · 7.56 KB

CONTRIBUTING.md

File metadata and controls

182 lines (141 loc) · 7.56 KB

Contributing to BONE

This document is for people who want to read, modify, or extend the BONE codebase.

Reporting and patching

BONE uses its own conventions, on the project's own mailing list:

  • Bug report: email ~bzg/boneyard@lists.sr.ht with subject [BUG] bone: <short explicit description>.
  • Patch: email the same address with subject [PATCH] bone: <commit summary>. Attach a git format-patch file or include the diff inline; either works.
  • Feature request: subject [POLL] bone: <short description>.
  • General discussion: any other subject.

For private matters (security, personal context) you can write directly to bzg@bzg.fr.

Codebase

All database writes happen on the JVM side, in src/. The Babashka scripts in scripts/ only read the database, with one exception: bb maintenance --delete prunes orphan emails.

  • JVM daemon (clj -M:run) -- Connects to an IMAP server or a local Maildir, fetches new emails since the last run, digests them into reports, applies commands, expires stale reports, exits. With --watch, the process stays running and reacts to IMAP IDLE or Maildir filesystem events.

  • bb export -- Reads the database and produces JSON, RSS, Org, ICS (calendar) feeds plus the HTML site and stats pages.

  • bb notify -- Reads the database and sends notification emails to the configured subscribers via SMTP.

JVM namespaces (src/bone/)

Namespace Role
bone.main Entry point (batch by default, --watch to stay up)
bone.ingest Datalevin connection, email parsing and storage
bone.digest Single-email processing (classify, detect, thread)
bone.detect Report type detection from subject + attachments
bone.commands Commands (triggers, annotations) and votes
bone.commands.registry Static command registry (JVM + bb)
bone.relations Qualified relations between reports
bone.series Patch series tracking
bone.expire Periodic report expiry (runs inside the daemon)
bone.periods Per-source time-windowed config overrides (JVM + bb)
bone.tracking Database timestamps read by the scripts
bone.lookup Entity lookups by message-id hash
bone.common Shared utilities (JVM + Babashka)
bone.config config.edn loading, source map, DB path (JVM + bb)
bone.ics iCalendar detection, parsing and assembly (JVM + bb)
bone.export Pull patterns, scoring, mailmap, CLI parsing (bb)
bone.logging Log rotation and file appender

bone.common, bone.config, bone.ics, bone.periods, bone.export and bone.commands.registry carry no Datalevin dependency, so the Babashka scripts load them too. All other namespaces under src/bone/ are JVM-only.

Babashka scripts (scripts/)

Script Role
bone-export.clj Report export (JSON, RSS, Org, patches, events, text)
bone-notify.clj Notification emails
bone/index_bb.clj HTML index page, called by the export
bone/stats_bb.clj Statistics and data page, called by the export
bone/docs_bb.clj Documentation page, called by the export
bone/html_bb.clj HTML head, theme and footer shared by the pages
bone/common_bb.clj Datalevin pod loading and queries shared by scripts
bone-maintenance.clj Orphan email purge, command failure listing
bone-email-test.clj SMTP configuration test
validate-config.clj Config validation

bb build-jar generates bin/bone, a shell wrapper around the uberjar.

Apart from the orphan purge of bb maintenance --delete, these scripts must never write to the Datalevin database: any mutation goes through the JVM daemon.

Development setup

Dependencies:

  • Clojure 1.12+ on Java 17+ (the daemon needs --add-opens flags that are wired into deps.edn).
  • Babashka for the export, notify and maintenance scripts.
  • Datalevin: deps.edn pulls it in as a library; the bb scripts use it as a pod.

Clone the repository:

git clone https://codeberg.org/bzg/bone
cd bone

Run BONE locally:

cp config.edn.minimal config.edn      # or copy config.edn.example
$EDITOR config.edn                    # point :mailboxes at your IMAP or Maildir
clj -M:run                            # single pass
clj -M:run -- --watch                 # stay running

To wipe the database and replay from scratch (prompts for confirmation, destructive):

clj -M:run -- --fresh

Running tests

Run the suite with clj -M:test. Tests use clojure.test and live in test/bone/; add a file test/bone/<topic>_test.clj to extend it and the runner will pick it up.

Scenario tests in digest_test.clj keep their emails next to their assertions: digest-mails! takes a few [id from subject body & opts] vectors, digests them in order in a fresh database (with-db), and the assertions follow.

Debugging an ingest

When BONE does not digest an email as expected:

  • Run bb maintenance --failures to list the commands the daemon refused (denied actions, bad syntax).
  • Enable verbose logging by adding a :logging block to config.edn (see config.edn.example); the per-email trace lands in the file you point it at.
  • Reproduce the case as a test: write the emails and an assertion in test/bone/digest_test.clj (see digest-mails!). Faster than cycling through an IMAP fetch, and the case stays covered in CI.

Code conventions

  • Pure functions where possible. bone.common, bone.config, bone.ics, bone.periods, bone.export, bone.detect, bone.commands.registry and the tx-builders in bone.relations must stay pure (no datalevin.core import).
  • Side-effecting functions end with !. Predicates end with ?.
  • Comments explain why, not what. Add a short docstring to public functions whose intent is not obvious from the name.
  • ASCII punctuation in source and prose: -- for an em-dash, => for a logical arrow, never the Unicode glyphs.
  • Commit messages follow conventional commits and the 50/72 git rule: a ~50-character summary, a blank line, then a short rationale focused on the why.

Versioning

BONE follows Intentional Versioning. The three audiences considered for every release are:

  • Users -- end-users and sysadmins who operate BONE instances.
  • Integrators -- consumers of the exported JSON, RSS and Org feeds.
  • Maintainers -- maintainers of the codebase itself.

A version bump signals which audience is most affected by the change.

License

The Clojure code is distributed under the Eclipse Public License 2.0. The JavaScript code shipped with the HTML export is distributed under the Mozilla Public License 2.0.

By sending a patch, you agree to license your contribution under the same terms.