# Contributing

How to set up the repository, how changes are made, and what a pull request needs.

Source: https://clipmux.com/docs/resources/contributing

Thanks for helping. ClipMux is one Go binary (`cmd/clipmux`) with a
Postgres job queue, immutable encrypted outputs and filesystem-first
storage. Before you change anything, read
[docs/architecture.md](https://github.com/visheshgubrani/clipmux/blob/main/docs/architecture.md),
the specification, and
[AGENTS.md](https://github.com/visheshgubrani/clipmux/blob/main/AGENTS.md),
the working rules for people and coding agents alike.

By taking part you agree to the
[Code of Conduct](https://github.com/visheshgubrani/clipmux/blob/main/CODE_OF_CONDUCT.md).
Report a security problem privately, never in an issue; see the
[security policy](/docs/resources/security-policy).

## Licence and sign-off [#licence-and-sign-off]

- The repository is AGPL-3.0. `packages/node`, `packages/player`,
  `packages/uploader` and `worker/` are MIT, each with its own `LICENSE`, so
  apps embed them freely.
- Contributions are accepted under the licence of the directory they touch,
  certified with the
  [Developer Certificate of Origin](https://developercertificate.org/). There
  is no CLA. Sign off every commit:

  ```bash
  git commit -s -m "Explain the change"
  ```

  This adds `Signed-off-by: Your Name <you@example.com>`, which certifies
  that you wrote the change or have the right to submit it under the
  project's licence. A pull request whose commits aren't all signed off
  can't be merged; `git rebase --signoff main` fixes an existing branch.

## Set up [#set-up]

You need Go (the version in `go.mod`), Docker with Compose, Node 24 and
pnpm (`corepack enable`).

```bash
make db-up        # dev Postgres on :5444
make test         # go vet ./... && go test ./...
make test-db      # the same, with the *_db_test.go tests against dev Postgres
make lint         # gofmt, vet, staticcheck -checks all, govulncheck
make run          # clipmux serve; it prints a setup token for the dashboard
pnpm install && pnpm -r run build   # dashboard, packages, Worker
```

The media tests need FFmpeg, ffprobe and Shaka Packager 3.9.1 or later
(`toolchain/install_packager.sh`); they skip without them. The whisper.cpp
tests need `toolchain/build_whisper.sh` and its models
(`toolchain/fetch_speech_models.sh`).

## How changes are made [#how-changes-are-made]

- **Tests first, at the seams.** A failing test, then the code that passes
  it, one vertical slice at a time. Expected values come from literals or
  worked examples, never from the code under test.
- **Database behaviour is tested against real Postgres** with
  `dbtest.New(t)`, in files named `*_db_test.go`, never with SQL-substring
  checks.
- **Schema changes are new goose migrations** in `internal/db/migrations`,
  each with a working Down. Never edit an applied migration. Queries live in
  `internal/db/queries` and are generated with `make sqlc`.
- **Keep it lean.** No package before its code, interfaces belong to their
  consumer, the standard library first, and duplicate once before
  abstracting. AGENTS.md has the rest.
- **The invariants aren't negotiable.** Executors hold no storage
  credentials; outputs are immutable and only `current_output_id` moves; one
  mutating job per asset; side effects outside Postgres run from outbox rows;
  route records default-deny; worker file names are untrusted; FFmpeg runs
  sandboxed.
- **Never commit secrets.** No `.env*` except `.env.example`. Never log
  Authorization headers, tokens, presigned URLs, content keys or secrets.
- **The delivery contract** is `internal/delivery/testdata/vectors.json`,
  shared by the Go handler and the Cloudflare Worker. Change it first, and
  both sides together.
- **Media tool versions** are written only in `toolchain/versions.env`.
- **Docs change with behaviour.** A change in behaviour updates its page in
  `site/content/docs` in the same pull request.

## Pull requests [#pull-requests]

- One change per pull request, with the reasoning it rests on.
- `make lint` and `make test-db` pass locally; for TypeScript, `pnpm lint`,
  `pnpm typecheck` and `pnpm test`.
- A change to playback, delivery, the player or the dashboard also runs the
  end-to-end suites, which a maintainer starts.
- A limitation you introduce or find goes in
  [docs/known-gaps.md](https://github.com/visheshgubrani/clipmux/blob/main/docs/known-gaps.md).

## Next [#next]

- [Architecture overview](/docs/resources/architecture)
- [Security policy](/docs/resources/security-policy)
- [FAQ](/docs/resources/faq)
