Thank you for your interest in contributing to WiredSwift / wired3. This document covers setup, conventions, and the PR workflow.
- Prerequisites
- Getting started
- Code style
- Commit conventions
- Pull request workflow
- Architecture overview
- Evolving the Wired protocol
| Tool | Version | Install |
|---|---|---|
| Swift | 5.9+ | swift.org |
| SwiftLint | 0.63+ | brew install swiftlint |
| Git | any | system |
SwiftLint is also installed automatically in CI (GitHub Actions).
git clone https://github.com/nark/WiredSwift.git
cd WiredSwift
# Install the pre-commit hook (runs SwiftLint before each commit)
bash Scripts/install-hooks.sh
# Build the server
swift build --product wired3
# Run the test suite
swift testThis project uses SwiftLint to enforce a consistent code style.
Configuration is in .swiftlint.yml at the project root.
| Convention | Rule |
|---|---|
| Indentation | 4 spaces (no tabs) |
| Line length | 160 chars soft / 200 hard |
| Identifiers | camelCase; GRDB column properties may use snake_case |
| Short names | db, t, c are allowed in GRDB closures; single-char vars generate a warning |
force_try |
Avoid — produces a warning; justify with a comment if unavoidable |
# Check for violations
swiftlint lint
# Auto-fix stylistic violations
swiftlint --fix# Validate DocC generation for the WiredSwift module
swift package generate-documentation --target WiredSwift
# Build static output for hosting (for example GitHub Pages)
swift package --allow-writing-to-directory ./docs \
generate-documentation \
--target WiredSwift \
--output-path ./docs \
--transform-for-static-hosting \
--hosting-base-path WiredSwiftCI fails if any error-level violation is introduced. Warnings are reported as annotations on pull requests but do not block merges.
Several large types (ServerController, BoardsController, P7Socket, …) carry
a // swiftlint:disable annotation with a // TODO: note. These are pre-existing
structural issues tracked for future refactoring — do not add new swiftlint:disable
lines without a corresponding issue or TODO comment explaining why.
This project follows Conventional Commits:
<type>(<scope>): <short summary>
Common types: feat, fix, test, refactor, chore, docs, perf.
Scope examples: p7, auth, chat, files, lint, ci.
Examples:
feat(chat): add rate limiting for public chat creation
fix(p7): reject messages with field length > 16 MB
test(auth): cover brute-force lockout path
chore(lint): suppress type_body_length in FilesController
- Fork the repository and create a branch from
master:git checkout -b feat/my-feature master
- Make your changes and ensure the pre-commit hook passes.
- Run the full test suite:
swift test - Open a PR against
master. CI runs lint → build → tests. - Address review comments; the PR is merged once CI is green.
Branch protection: never commit directly to
mainormaster.
| Target | Role |
|---|---|
WiredSwift |
Reusable library — P7 protocol parser, crypto, connection abstractions |
wired3 |
Server daemon — auth, chat, files, boards, transfers |
WiredServerApp |
macOS GUI wrapper around wired3 |
Key directories inside WiredSwift:
Sources/WiredSwift/
├── P7/ Protocol parser and socket (P7Message, P7Socket, P7Spec)
├── Crypto/ ECDSA, ECDH, ciphers, digests
├── Network/ Connection, BlockConnection, URL helpers
└── Core/ Logger, Config, errors, server events
The binary protocol format is defined in Sources/WiredSwift/Resources/wired.xml.
wired.xml is not frozen — but every change must follow the rules in
COMPATIBILITY.md. In short:
- Every new
<p7:field>,<p7:message>or<p7:enum>carries aversion="X.Y"attribute matching the next minor version of the protocol. - Prefer length-prefixed types (
string,data,list) for new optional fields so older peers can ignore them without aborting the decode of the rest of the message. - Bump the
version=""attribute on the<p7:protocol>root in the same PR that adds new items. - Field and message IDs are permanent within a major. Removing or repurposing an ID is a major version break.
- Removing or renaming spec items is a major bump. Deprecate first.
Any PR that touches wired.xml must:
- Update the
versionattribute on every modified or added entry. - Bump the protocol version on the root element when adding items.
- Add or update tests under
Tests/WiredSwiftTests/CompatibilityTests.swiftcovering the new behaviour cross-version. - Reference COMPATIBILITY.md in the PR description.