Swift

Fix Swift bugs with Codna

Codna maps your Swift package for zero tokens, fixes from evidence, and runs swift test until it passes.

The problem

A force-unwrap crash after an async refactor is an await away from its cause.

Codna builds a dependency and blast-radius graph of the repository from its import patterns. No model call, zero tokens. Imports are the edges, so the agent follows the call chain from the failing test to the optional that is no longer set when it is read.

How Codna fixes it

How Codna fixes it

1

Map the Swift repository

Codna builds a dependency and blast-radius graph of the repository from its import patterns. No model call, zero tokens.

2

Fix from evidence

The agent receives an evidence bundle scoped to the issue: the suspect files, the call paths, the failing test. Codna prints the raw-to-bundle token size on every run. Every fix reports root cause, confidence, blast radius and regression risk, and passes a risk gate before it is applied or a pull request opens.

3

Verify with swift test

Run codna fix --tests --apply and Codna runs your tests in a sandbox and re-fixes until they pass, up to the iteration limit you set. Set fix.test_command in codna.yaml, or pass --test-cmd, when your runner is not pytest. With --open-pr, or through the GitHub App, the pull request states the issue, the root cause, the symbols touched and a confidence score, and asks for review before merging. Codna never merges.

pip install codna
codna fix . --issue "force-unwrap crash in CheckoutCoordinator after async refactor" --tests --apply --test-cmd "swift test --xunit-output $CODNA_JUNIT"

What you get

Built for Swift

swift test as the oracle

--xunit-output writes the report Codna reads. Set fix.test_command or pass --test-cmd.

Map from imports

The repository map does not depend on a per-language grammar, so Swift is in the graph.

Recall note

On-device recall does not yet index Swift. The map and the fix loop do not depend on it.

The proof

Fewer tokens. Faster. Verified.

Codna16K
Cursor81K
Average tokens per fix on 87 matched bug-fix cases: Codna and Cursor.

Frequently asked

Codna builds a dependency and blast-radius graph of the repository from its import patterns. No model call, zero tokens. The agent receives an evidence bundle scoped to the issue: the suspect files, the call paths, the failing test. Codna prints the raw-to-bundle token size on every run.

The map follows imports and the bundle carries call paths. Protocol dispatch is a lower bound; your tests verify the behaviour.

Yes. The map is built from imports and the oracle is your swift test command. Runs on macOS or Linux.

Either, as long as the command writes a JUnit-style report to $CODNA_JUNIT.

Codna ships as a CLI, an MCP server for Cursor and Claude, a GitHub Action (thyn-ai/codna-action@v1) and a GitHub App that reviews every pull request and opens fix PRs from a label, a comment or a red check.

Understanding runs on your machine and spends no tokens. Only the evidence bundle or the diff reaches your model provider, with your key from the OS keychain. Set privacy.egress to fail-closed in codna.yaml and Codna runs your tests only under kernel-level network denial. Secret redaction is always on.

Understand. Fix. Evolve.