# Contributing

> Development prerequisites, core architectural invariants, verification checklist, and conflict-free changelog workflow.

Thank you for contributing! This monorepo maintains the shared open wire specification (`spec/`), the TypeScript reactive workspace (`ts/`, `@zwire/*`), and the native zero-dependency Rust workspace (`rust/`, `zwire*`).

## Prerequisites

Runtime versions are pinned in [`mise.toml`](https://github.com/kjmin-dev/zwire/blob/main/mise.toml) and [`rust/rust-toolchain.toml`](https://github.com/kjmin-dev/zwire/blob/main/rust/rust-toolchain.toml):

```bash
mise install
pnpm install
```

Running `pnpm install` at the repository root automatically configures Git hooks in [`.githooks/`](https://github.com/kjmin-dev/zwire/blob/main/.githooks) (`pre-commit` and `pre-push`).

## Core Architectural Invariants

1. **Strict 2-Tier Star Topology:** Core (`ts/packages/core/src/core/`, `rust/crates/zwire-core/`) must never import companion subpaths, adapters, or crates, and companions must never import each other. Cross-feature integration goes strictly through the 5 lazy extension slots (`ts/packages/core/src/core/internal.ts`, `zwire_core::internal`).
2. **Zero-Global Scopes:** Never introduce module-level mutable reactive state. All state must remain isolated per `ReactiveScope` / `Scope` / `SyncScope`.
3. **Zero External Runtime Dependencies:** Both `@zwire/core` and all `zwire*` crates must ship with zero external runtime dependencies. Rust crates enforce `#![forbid(unsafe_code)]` and `#![no_std]` (`alloc`).
4. **Re-entrancy & Deadlock Freedom (Rust):** Release `RefCell` borrows and `MutexGuard` locks before invoking any user callback, and store `WeakScope` / `WeakSyncScope` (never strong clones) in scope-owned closures.
5. **Cross-Language Parity:** Any change to optimistic rebase semantics, STM drafts, Top-K collection semantics, or wire JSON formats must update [`spec/conformance.json`](/spec/v3/conformance.json), run `mise run sync:spec` to update `rust/crates/zwire/tests/conformance.json`, and pass TypeScript, Rust, and `examples/rust-ts-sync` verification.

## Verification Checklist

```bash
# Run all spec, changelog, TypeScript, and Rust static checks
mise run check

# Typecheck benchmarks and verify Rolldown tree-shaken bundle budgets
(cd ts && pnpm run typecheck:bench && node ./bench/run_precision_bench.ts --check-bundles && bun ./bench/run_precision_bench.ts --check-bundles)

# Build TypeScript ESM + declarations and verify dist exports (Node + Bun)
mise run build:ts

# Verify documentation site build, links, SEO, and unit tests
mise run check:site

# Run TypeScript (Node + Bun), Rust, and cross-language sync demo tests
mise run test
```

## Commits, Pull Requests & Changelog

- **Language & Format:** All commit messages, PR titles, and PR bodies must be written in English using [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`, `perf:`, `refactor:`, `test:`, `docs:`, `chore:`).
- **Conflict-Free Changelog Entries:** Never edit `CHANGELOG.md` directly in feature or fix PRs. Instead, add a dedicated fragment file under `changes/<short-kebab-name>.md` (one file per PR so concurrent PRs never conflict on the changelog). Release tooling (`mise run release:changelog`) aggregates all fragments into `CHANGELOG.md` at release time.
