Files
ShadowsocksX-NG/docs/adr/0025-single-rule-conversion-path.md
T

2.9 KiB

ADR-0025: One rule conversion path

Status: Accepted

The three explicit maintainer updates already generate snapshots through Python. The Swift converters had only test callers and duplicated parsing, normalization, absorption and update guards. In particular, the Swift geolocation converter read source text and resolved includes, while the shipped path reads the upstream's already filtered geosite protobuf release. Those tests did not exercise the artifact generator.

Python remains the sole upstream conversion implementation. Remove the Swift converters, their dedicated parsers and conversion-only CN absorption helper. Swift retains RuleMatch validation, snapshot loading, collection analysis, offline matching and ACL generation; these are product responsibilities.

Test conversion behavior directly in Python, including protobuf selection, typed entries, GFW classification and shadowing, CIDR normalization, duplicate handling, rejection and scale guards, and CLI failure preserving an existing output. Source-text include expansion and inherited attribute filtering are removed with the unused source-text input path; the published geosite release remains upstream-filtered.

Deterministic fixtures generated by those same Python entry points are committed and checked byte for byte by the Python test suite. Hostless Swift tests load the fixtures from their test bundle, then verify collection, offline disablement, ACL and snapshot-store behavior. No conversion algorithm is duplicated in Swift tests.

This change does not alter the Python algorithms, pinned snapshots, schema or converter version. The geolocation Python domain validator still accepts some Unicode letters that Swift RuleMatch rejects; tightening that input contract is a separate behavior change requiring artifact and version review. This consolidation does not claim to resolve that pre-existing discrepancy.

ADR-0024's snapshot slimming contract and explicit-update/offline-build boundary remain in force. The earlier exclusion of converter consolidation applied to that change's scope; this decision handles it separately. A Swift generation CLI or general conversion framework adds build and migration cost without a current product requirement.

The GFWList path now also extracts literal domain hosts from URL prefixes with an empty or root (/) path and no query, fragment or user information; other paths remain unsupported. It emits exact-domain matches and preserves the proxy/direct action, deliberately discarding scheme and any valid port. Wildcard hosts, IP literals, invalid URLs and remaining URL conditions stay in the urlPrefix loss category. Exact proxy matches only shadow equal exact exceptions; suffix proxy matches can cover either match kind. This extends conversion behavior without changing the schema 2 / converter 2.0.0 artifact contract or regenerating the pinned distribution snapshots. Generated consumer fixtures cover the new match kind.