Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
root = true

[*.cs]
indent_style = space
indent_size = 4
end_of_line = lf
dotnet_diagnostic.IDE0005.severity = warning
# IDE0059 (value assigned to a local is never read) ships at suggestion severity, below the
# threshold TreatWarningsAsErrors acts on, so dead assignments accumulated silently until
# CodeQL's cs/useless-assignment-to-local flagged seven of them. Raise it into the build.
dotnet_diagnostic.IDE0059.severity = warning
csharp_style_namespace_declarations = file_scoped:warning

# Desktop Avalonia app: awaited continuations must keep the UI Dispatcher context, so
# CA2007 (missing ConfigureAwait) is not actionable here — suppress app-wide.
dotnet_diagnostic.CA2007.severity = none

# CA1716 is a cross-language (VB/C# interop) naming rule with no value for this C#-only app:
# interface members and parameters such as Get/Stop/set/to are idiomatic here.
# Suppress app-wide.
dotnet_diagnostic.CA1716.severity = none

# StyleCop.Analyzers: curated for this codebase. Rules disabled below either
# conflict with an established convention or don't fit a project that doesn't
# mandate XML documentation (CS1591 is already suppressed above). Everything
# else keeps StyleCop's shipped default severity, which becomes a build error
# via TreatWarningsAsErrors.

# SA1101: this. prefix required on every member access - fights the _camelCase
# private-field convention already used throughout (see below).
dotnet_diagnostic.SA1101.severity = none

# SA1201/SA1202/SA1204: member-kind/access/static ordering. No code-fix
# support exists for any of these - every violation needs manual reordering.
# The codebase organizes members by domain/lifecycle grouping (e.g. a
# registration factory next to the validation it calls) rather than by kind
# or access level, and there's no functional benefit to forcing the churn.
dotnet_diagnostic.SA1201.severity = none
dotnet_diagnostic.SA1202.severity = none
dotnet_diagnostic.SA1204.severity = none

# SA1402: one type per file. Several files (SyncCommand.cs, IncidentSnapshot.cs,
# MasterDataSet.cs, ...) deliberately group a closed set of small related
# record types together (a DU-style command/DTO set) so the whole set reads
# in one place - splitting each into its own file would scatter that and add
# dozens of one-line files for no benefit.
dotnet_diagnostic.SA1402.severity = none

# SA1312: local variables must begin with a lower-case letter. Its walker doesn't recognize
# `using var _ = ...` / `await using var _ = ...` as the discard idiom it is - the test suite
# uses this pattern throughout for scope-based disposal without a named variable.
dotnet_diagnostic.SA1312.severity = none

# SA1309: private fields must not begin with an underscore - the whole
# codebase already uses _camelCase for private fields.
dotnet_diagnostic.SA1309.severity = none

# SA1600-SA1649: "documentation rules" family (elements/parameters/return
# values/generic type params must be documented, file headers, etc.).
# Documentation is optional here, not mandated - keep SA1649
# (FileNameMustMatchTypeName) enabled, it's an unrelated naming check.
dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1601.severity = none
dotnet_diagnostic.SA1602.severity = none
dotnet_diagnostic.SA1604.severity = none
dotnet_diagnostic.SA1605.severity = none
dotnet_diagnostic.SA1606.severity = none
dotnet_diagnostic.SA1607.severity = none
dotnet_diagnostic.SA1608.severity = none
dotnet_diagnostic.SA1609.severity = none
dotnet_diagnostic.SA1610.severity = none
dotnet_diagnostic.SA1611.severity = none
dotnet_diagnostic.SA1612.severity = none
dotnet_diagnostic.SA1613.severity = none
dotnet_diagnostic.SA1614.severity = none
dotnet_diagnostic.SA1615.severity = none
dotnet_diagnostic.SA1616.severity = none
dotnet_diagnostic.SA1617.severity = none
dotnet_diagnostic.SA1618.severity = none
dotnet_diagnostic.SA1619.severity = none
dotnet_diagnostic.SA1620.severity = none
dotnet_diagnostic.SA1621.severity = none
dotnet_diagnostic.SA1622.severity = none
dotnet_diagnostic.SA1623.severity = none
dotnet_diagnostic.SA1624.severity = none
dotnet_diagnostic.SA1625.severity = none
dotnet_diagnostic.SA1627.severity = none
dotnet_diagnostic.SA1629.severity = none
dotnet_diagnostic.SA1633.severity = none
dotnet_diagnostic.SA1634.severity = none
dotnet_diagnostic.SA1635.severity = none
dotnet_diagnostic.SA1636.severity = none
dotnet_diagnostic.SA1637.severity = none
dotnet_diagnostic.SA1638.severity = none
dotnet_diagnostic.SA1639.severity = none
dotnet_diagnostic.SA1640.severity = none
dotnet_diagnostic.SA1641.severity = none
dotnet_diagnostic.SA1642.severity = none
dotnet_diagnostic.SA1643.severity = none
dotnet_diagnostic.SA1648.severity = none

[tests/**/*.cs]
# xUnit method names with underscores are idiomatic.
dotnet_diagnostic.CA1707.severity = none

# Perf/impl-noise rules — they add churn to test code without catching real bugs.
dotnet_diagnostic.CA1861.severity = none
dotnet_diagnostic.CA2000.severity = none
dotnet_diagnostic.CA1063.severity = none
dotnet_diagnostic.CA1816.severity = none
dotnet_diagnostic.CA1826.severity = none
dotnet_diagnostic.CA2008.severity = none
dotnet_diagnostic.CA1829.severity = none
dotnet_diagnostic.CA2213.severity = none
dotnet_diagnostic.CA2025.severity = none

33 changes: 33 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 2
# Every ecosystem waits seven days before proposing a new release (`cooldown`), so a compromised
# version that is caught and yanked in its first days never reaches a pull request. Security
# updates ignore the cooldown.
updates:
# Keeps the SHA-pinned GitHub Actions current.
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 10
cooldown:
default-days: 7

# NuGet packages; Avalonia moves in lockstep, so its packages arrive as one pull request.
# Dependabot rewrites only the lock file of the project that references a package directly:
# run `dotnet restore Waehlhilfe.slnx --force-evaluate` on its branch and push the result.
- package-ecosystem: nuget
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 10
cooldown:
default-days: 7
groups:
avalonia:
patterns:
- "Avalonia*"
# Avalonia.Headless.XUnit 12.1.4 is built against xunit.v3 3.2.2; 4.x removed an overload it
# calls (AvaloniaUI/Avalonia#22072). Drop this once Avalonia ships a compatible package.
ignore:
- dependency-name: "xunit.v3"
update-types: ["version-update:semver-major"]
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened

# Builds and tests untrusted pull request code; the token only needs to read the repository.
permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
build-test:
name: build-test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
# Windows and macOS are the platforms Wählhilfe ships for; Linux is where the
# DL500A is tested by hand today and where the format check runs.
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: '10.0.x'

- name: Restore
run: dotnet restore Waehlhilfe.slnx --locked-mode

- name: Build
run: dotnet build Waehlhilfe.slnx -c Release --no-restore

- name: Test
run: dotnet test Waehlhilfe.slnx -c Release --no-build

- name: Format check
if: matrix.os == 'ubuntu-latest'
run: dotnet format Waehlhilfe.slnx --verify-no-changes --no-restore
39 changes: 39 additions & 0 deletions .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: zizmor

# Static analysis for the workflows themselves: template injection, persisted credentials,
# over-broad permissions, dangerous triggers. A finding accepted on purpose carries an inline
# `# zizmor: ignore[<audit>]` with the reason next to it.

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
# Weekly, so a new audit or a new advisory against a pinned action finds a quiet repository.
- cron: '41 4 * * 1'

permissions: {}

concurrency:
group: zizmor-${{ github.ref }}
cancel-in-progress: true

jobs:
zizmor:
name: zizmor
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

# advanced-security: false — a private personal repository has no code scanning to take the
# SARIF, so findings fail the job and print in the log instead.
- name: Run zizmor
uses: zizmorcore/zizmor-action@53290badfa369cb0bf7ad16342cb62c2fa47ac7b # v0.8.0
with:
advanced-security: false
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Build output
bin/
obj/
*.user
.vs/
.idea/
TestResults/
coverage/
*.trx
artifacts/
publish/
dist/
out/

# Signing material — never in the tree.
*.p12
*.pfx
*.pass

# Local tooling artefacts
docs/superpowers/
.superpowers/
.claude/
122 changes: 122 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Agent instructions

Wählhilfe registers as the operating system's `tel:` handler and dials the number on a Gigaset
DL500A over Bluetooth. It exists so that Lagebuch (CodeForFire/lagebuch) and every other program
in the ELW can keep emitting plain `tel:` links; see CodeForFire/lagebuch#617 for how the
protocol was found.

## The protocol

The DL500A offers a Serial Port Profile (SPP) on RFCOMM channel 1 and accepts AT commands on it:

```
AT → OK
AT+CGMI → Gigaset Communications GmbH
ATD <number> → OK, CLIP:EXTERN, CONNECT
```

The call stays up on the base after the link is closed, so a dial is: open the port, `AT`,
`ATD`, close. The OS exposes SPP as a serial port — an outgoing COM port on Windows,
`/dev/cu.*` on macOS, `/dev/rfcomm0` (after `rfcomm bind`) on Linux.

**The trap:** while the PC also holds the base's *audio* (Hands-Free) connection, every SPP
connection hangs until it times out instead of being refused. A timeout is therefore reported
with that hint, never as a generic error.

## Language

Issues, pull requests, commit messages, code and comments are **English**. The UI is **German**
and inline — no `.resx`. German terms of art stay German (Amtsholung, Ländervorwahl,
Einsatzkraft). Keep UI wording short and imperative; it is read in a command vehicle.

## Git

- Conventional Commits (`feat:`, `fix:`, `docs:`, `test:`, `build:`, `ci:`, `chore:`, …), English.
- DCO sign-off (`git commit -s`) and a cryptographic signature on every commit.
- SSH signing needs the key the command sandbox blocks: commit with the sandbox disabled and
check `git cat-file commit HEAD | grep gpgsig` before pushing.
- Never push to `main`. Feature branch and pull request, always. Stack a pull request on another
only when it needs that one's code; the body then says "Stacked on #N, review only the last
commit".
- A pull request that touches a view carries before/after PNGs rendered with the headless Skia
harness in `tests/Waehlhilfe.App.Tests`, attached with `gh pr create --attach`.

## GitHub Actions

- Third-party actions are pinned to a full commit SHA of their latest release:
`uses: owner/action@<sha> # vX.Y.Z`, resolved with
`gh api repos/<owner>/<action>/releases/latest --jq .tag_name` and
`gh api repos/<owner>/<action>/git/refs/tags/<tag> --jq .object.sha`.
- `.github/dependabot.yml` keeps the pins and the NuGet packages current.
- `zizmor` audits every workflow (`pipx run zizmor .` locally). Values from `inputs`, `needs` or
`github.event` reach a `run:` through `env:`, never as `${{ }}` inside the script. Checkouts
set `persist-credentials: false` unless the job pushes.

## Architecture

Dependencies point one way:

- `Domain` references nothing: `tel:` parsing, number normalisation, settings.
- `Modem` references `Domain`: the AT dial session over an `IAtChannel`, and the serial port.
- `AppLogic` references both and holds the view models. It has **no Avalonia reference**.
- `App` holds the views, `Program`, the composition root and the per-OS glue.

- View models are `sealed partial` classes over CommunityToolkit.Mvvm's `ObservableObject`, with
`[ObservableProperty]` and `[RelayCommand]`.
- No DI container; wiring is by hand in the composition root. An optional dependency is a
nullable constructor parameter with a default.
- Time is injected as a `TimeProvider`; tests use `FakeTimeProvider`. Never `DateTime.Now`.
- Non-view classes are `sealed`; domain values are `sealed record`s.
- Smallest change that fits; an interface only when there is a second implementation (a test
double counts).

## C# and .NET

- Nullability is real: no `#nullable disable`, no `!` to silence a warning. Public entry points
start with `ArgumentNullException.ThrowIfNull`.
- Failure has three shapes: `bool TryX(..., out T)` with `[MaybeNullWhen(false)]`, a documented
nullable return, or a typed exception. No `Result<T>` library.
- Failures surface as a bound German status string on the view model; there is no logging
framework. Every `catch (Exception)` carries a `[SuppressMessage("Design", "CA1031",
Justification = "...")]` naming where the failure surfaces.
- Async: no `async void` outside event handlers, no `.Result`/`.Wait()`, no
`ConfigureAwait(false)`. I/O APIs take `CancellationToken cancellationToken = default`.
- Culture: anything persisted uses `InvariantCulture`; identifiers compare `Ordinal`.
- `using`/`await using` for every disposable you own, never a manual `Dispose()` in `finally`.
- `Path.Join`, never `Path.Combine`.
- Package versions live in `Directory.Packages.props`; every project commits a
`packages.lock.json` and CI restores with `--locked-mode`.

## Avalonia

Avalonia 12. Use the `avalonia-docs` MCP before reaching for an API from memory.

- Every `.axaml` declares `x:DataType`; compiled bindings stay on.
- App types are `internal` (CA1515): a view sets `x:ClassModifier="internal"` to match.
- Code-behind is view-only: focus and forwarding events to commands.
- Every text-less control gets an `AutomationProperties.Name`.

## Security

The number arrives from a `tel:` link, which any web page or document can produce: it is
**hostile input**. It reaches the phone only after `TelUri` has reduced it to `0-9 * #` and a
length cap — never a `;`, `\r`, `\n` or letter, which would let a link append its own AT
commands. A security fix gets a test that replays the attack. Dialling always goes through the
confirm window; nothing dials silently.

## Tests

- xUnit (v3) with plain `Assert` and handwritten test doubles. No mocking library, no
FluentAssertions.
- A test's name is a sentence in snake_case: `Rejects_a_semicolon_command`.
- Bug fixes: the failing test first. Headless UI tests use `[AvaloniaFact]`.
- No real `Task.Delay` or sleep in a test — drive time with `FakeTimeProvider`.

## Before you call it done

Run `make clean ci`, read the output (search for `Test Run Failed`), and review the diff for
dependency direction, hostile-input handling, German UI wording and automation names.

## Repository hygiene

Never commit `docs/superpowers/`.
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
Loading
Loading