---
title: Contributing
description: How to send a change, what CI checks, and the privacy rule every change has to keep.
sidebar:
  order: 6
---

Hindsight is AGPL-3.0-only, and the code is at [github.com/MIXIDtheSilly/Hindsight](https://github.com/MIXIDtheSilly/Hindsight). Changes go in as pull requests against `main`.

## The workflow

1. **Branch off main**

    Don't commit to `main`. Make a branch for your change.

2. **Get it running**

    [Run it locally](/docs/developers/run-locally) so you can see the change work, not just compile.

3. **Run the checks**

    The same three commands CI runs, from the repository root:

    ```bash
    cargo fmt --all --check
    cargo clippy --workspace --all-targets -- -D warnings
    cargo test --workspace
    ```

    Use `cargo fmt --all` to fix formatting. If you changed the desktop app's frontend:

    ```bash
    cd apps/desktop
    npm ci
    npm run check
    npm run build
    ```

4. **Open a pull request**

    CI runs on every pull request and on every push to `main`. Fix what it flags and push again. A newer push cancels the older run.

Clippy and the compiler are strict here: CI sets `RUSTFLAGS=-D warnings`, the workspace forbids `unsafe` code, and clippy's default lints are on. rustfmt wraps at 100 columns. `.editorconfig` asks for UTF-8, LF line endings, 4-space indents (2 for TOML, YAML, JSON, Svelte, TypeScript, JavaScript, CSS, HTML and Markdown), and a final newline. Clippy's `msrv` is 1.85 and it allows up to 8 arguments per function.

One catch: clippy and the tests compile the desktop app too, and Tauri embeds the built frontend at compile time. Run `npm ci && npm run build` in `apps/desktop` once before `cargo clippy --workspace` or `cargo test --workspace`, or the build fails on the missing frontend. CI does the same.

## What CI runs

There are four workflows.

| Workflow | Runs on | What it does |
|---|---|---|
| CI (`ci.yml`) | pull requests, pushes to `main` | **fmt + clippy**, **tests** against a Postgres 17 service (`DATABASE_URL` set, so the server's integration tests run), and the **desktop frontend** (`npm run check`, `npm run build`). |
| Build (`build.yml`) | pull requests, Mondays at 04:00 UTC, by hand | Builds the daemon, the VS Code extension and the installer on Windows x64, macOS Apple Silicon, macOS Intel, Linux x64 and Linux ARM. Each installer is kept as a run artifact for 14 days, so you can download one from any pull request and try it. It skips pull requests that only touch Markdown, `docs/`, `img/`, `website/`, `deploy/`, the server crate, or the Docker files. |
| Server image (`server-image.yml`) | pushes to `main` that touch the server, core, `website/`, `Cargo.toml`, `Cargo.lock` or the Dockerfile | Publishes the server image to `ghcr.io`. |
| Downstream builds (`downstream.yml`) | the same pushes | Starts a build in another repository, if the maintainers configured one. Does nothing otherwise. |

## The privacy rule

This is the rule that matters most, and it's built into the types so it's hard to break by accident.

**Events never carry prompt text, code, file contents, file paths or anything captured from the screen.** `EventMeta` in `crates/hindsight-core/src/event.rs` is a closed struct with `deny_unknown_fields`, so a field nobody declared can't sneak in. Raw text goes in one end and a length, a ratio or a keyed hash comes out the other, through `hindsight_core::privacy::Hasher`.

When you change something that touches events, keep these in mind:

- **Don't add a field that can hold free text.** A new signal is a count, a length, a ratio, a yes or no, or a keyed hash. If a short string is truly needed (the branch name is the existing case), say where it may appear in `Event::check_text` and cap its length.
- **Hash with `Hasher`, never a plain hash.** It's blake3 keyed with a random per-device key, so a short or guessable prompt or path can't be brute-forced from a leaked hash.
- **Read and drop.** A hook may read a prompt, a path or tool output to measure it or hash it. It must not store it, log it or put it in an error message. A failed tool call's `error` isn't even a field of the payload struct, so it can't be read.
- **Presence asks yes or no.** It asks the OS which app has focus and how long ago the last input was. It never records which keys. The app's name is compared against a fixed list in `hindsight_core::app` and only a name from that list is ever stored.
- **The only free text is what you deliberately write to Byte** (an answer or a note), and only on check-in events. Everything else goes through `check_text`, which both the daemon (before storing) and the server (before accepting) run.
- **Local-only stays local.** Keyed hashes of the lines an agent or you wrote live in a local table for working out who wrote a commit's lines. Only the counts travel.

Add a test next to the change. The ones to copy are `prompt_text_never_serialized` in `privacy.rs`, `meta_rejects_unknown_fields` and `only_byte_answers_and_notes_may_carry_text` in `event.rs`.

### Two version numbers

- `SCHEMA_VERSION` in `event.rs`. Bump it when the serialized shape of an event changes. The server refuses events with a different version.
- `RULES_VERSION` in `crates/hindsight-core/src/attention.rs`. The comment on it says to bump it whenever a change can credit the same events differently. The server stores the version with its windows and redoes everyone's stored time when it changes.

## The docs site

This site lives in `docs/` and is built with Blume. To preview it while you write:

```bash
cd docs
npm install
npm run docs:dev
```

`npm run docs:build` makes the static site. Pages are `.mdx` files under `docs/content/`, and each folder has a `meta.ts` that sets its title, icon and order.
