# Issue #6 — Native deslop lint in Swift (banned vocab + em-dash density as fix cards) > **Date:** 2026-10-30 > **Type:** issue > **Reference:** https://git.babylondreams.de/AlexKucera/museion/issues/6 (PRD S3.4, ships with M2) ## Goal Deterministic style findings as fix cards without an engine round-trip: banned-vocab tiers and em-dash density computed in Swift at pass invocation, after First-Draft stats capture (S5.1); findings use the fix-card schema (ADR-0006) and render/play like any card (ask-before apply); the vocab tiers and em-dash budget ship as data, trivially editable without a recompile. ## What Was Done - `Museion/DeslopLint.swift` (new, nonisolated): `Config`/`Tier`/`Phrase` Codable shape, `bundledConfig()` (bundled `Resources/deslop-lint.json`, missing/undecodable → silent no-op), `config(home:)` (`/deslop-lint.json` wins when it exists AND decodes), `compute(body:config:)` (pure: one finding per phrase over its tier allowance, case-insensitive whole-word ICU match, anchor = first match case-preserved with exact-substring occurrence, em-dash density finding first when over budget, tiers by first-match position; mechanical lane for mapped replacements — case-matched to the anchor per ADR-0006 — demonstration otherwise), `emit(...)` (dedup vs OPEN cards → `FixCardStore.submit`, swallows every error — the stats-capture posture). - `Museion/Resources/deslop-lint.json` (new): the deslop doctrine as data — Tier 1 ×68 / Tier 2 ×6 / budget 4, 13 mechanical mappings (the skill's verb swaps + #31). `key`/`landscape`/`highlight`/bare `underscore` deliberately omitted (POS-ambiguous / character-name collision; add via Home override). - `Museion/PostsModel.swift`: one hook in `runPass`, immediately after `captureFirstDraftStats`, before `runningPass = kind`. - `MuseionTests/DeslopLintTests.swift` (new, @Suite, scenario header): exact finding set/order/copy over a known-sloppy draft, word boundaries, em-dash budget edges, config override/fallback/bundled-decode, store-level emit→dedup→close→re-emit loop incl. asserted pass-2 provenance, empty AND whitespace-phrase trust-boundary pin (the `— —` body is space-phrase bait — a plain body passes vacuously). - `MuseionTests/PassRunTests.swift`: `DeslopLintWiringTests` — a pass invocation seeds lint cards AND `stats_*` keys at the one seam. - `Museion/FixCardStore.swift` (audit fix): `submit` refuses a symlinked `cards/` dir before any write (promote's learnings posture; the lint auto-fires submit every Run Pass); pin in `MCPToolsTests`. - DOX: `Museion/AGENTS.md` (DeslopLint entry, runPass seam, submit symlink guard), `MuseionTests/AGENTS.md` (test entries), `CHANGELOG.md`. ## Decisions & Rationale | Decision | Rationale | |----------|-----------| | Bundled default + `/deslop-lint.json` override (override REPLACES, no merge) | PRD: "trivially editable without a recompile". Replace-not-merge is predictable; a malformed override falls back to bundled, never fatal (lenient config posture). | | One finding per phrase (not per occurrence), anchored at first match | N cards for N instances of the same word is palette noise; the count rides the problem string; re-runs re-card remaining instances after Apply/Skip closes the prior card. | | Dedup vs OPEN cards only (pattern + quote + occurrence) | GLOSSARY Emitter contract (engine never re-cards a live lint finding); closed cards don't block → re-runs make progress. | | Mapped replacements → mechanical lane (fix case-matches the anchor); unmapped → demonstration | ADR-0006: mechanical = pure function of anchor + fixed tables (mappings are the skill's own verb swaps/#31); case named among mechanical transforms. | | Em-dash budget 4, anchor = first `—`, demonstration lane | Skill: "3-4 per article is plenty, 1-2 fine"; density is judgment (comma vs period vs restructure), never auto-applied. | | Rank order: em-dash density, then Tier 1, then Tier 2 (by first-match position) | The em-dash habit is the issue's flagship prompt-resistant tell; deterministic order under the 10-card submit ceiling keeps the ranked head. | | Lint the raw body (no fence/heading stripping) | ponytail-marked: the engine does context judgment; strip contexts if false positives bite. | | Omitted `key`/`landscape`/`highlight`/bare `underscore` from default data | POS-ambiguous / collides with the character name — a word-boundary regex false-positives; engine-side judgment, add via override. | | Deferred: >500-phrase override bound, negative-budget clamp | Same-privilege self-inflicted lows; `ponytail:` ceiling comment on `config(home:)` names the fix if a hand-edit ever bites. | ## Gotchas & Fixes | Problem | Root Cause | Fix | |---------|------------|-----| | A hand-edited `{"phrase": ""}` override would kill the ENTIRE lint silently | Empty regex matches everywhere → empty-quote anchor → submit's whole-call validation throws → `try?` swallows → zero cards every pass | Empty-phrase guard in `scan()` (first review round) | | Whitespace-only phrase (`" "`) still killed the whole lint | My guard checked `isEmpty`; submit's validation TRIMS — the two definitions of "empty" disagreed | Guard widened to trimmed-emptiness; pin's body carries `— —` so the space-phrase actually matches (a plain body passes vacuously) | | `Utilize` at sentence start would Apply to lowercase `use` | Mechanical fix was the raw replacement; ADR-0006 names case among mechanical transforms | Fix case-matches the anchor's first letter | | Pre-planted `cards/` symlink = arbitrary-directory JSON drop, auto-triggered every Run Pass | `submit` created/wrote through `cards/` without a symlink check — theoretical when only the engine's MCP call reached it, practical once the lint auto-fired it | Promote's 5-line symlink refusal copied onto submit; pinned | | Flip-cycle restore dropped the `pass:` argument label | Python restore anchored on the ternary expression, marker check matched the expression without the label | One-label patch; caught by the suite's compile error (never a silent green) | | One full-suite run failed `EditorSessionTests/debounce flushes after idle` | Documented #30 load flake — passes in isolation, passes on the idle definitive run, zero diff overlap | No fix needed; re-ran per the learning's protocol | ## Files Changed | File | Change Summary | |------|---------------| | `Museion/DeslopLint.swift` | new — the lint (config load, compute, dedup+emit) | | `Museion/Resources/deslop-lint.json` | new — the tier/budget data (bundled default) | | `Museion/PostsModel.swift` | +6 — the runPass hook after stats capture | | `Museion/FixCardStore.swift` | +8 — submit refuses a symlinked cards/ dir | | `MuseionTests/DeslopLintTests.swift` | new — 7 pins (compute, config, emit loop) | | `MuseionTests/PassRunTests.swift` | +32 — the invocation wiring pin | | `MuseionTests/MCPToolsTests.swift` | +14 — the symlinked-cards submit pin | | `Museion/AGENTS.md`, `MuseionTests/AGENTS.md`, `CHANGELOG.md` | DOX pass | ## Open Items & Next Steps - [ ] Deferred visibly: >500-phrase override bound + negative `emDashBudget` clamp (`ponytail:` comment on `config(home:)`) — add if a hand-edit ever bites - [ ] Accepted-cosmetic: intra-batch duplicate phrases in one hand-edited tier yield duplicate cards from one emit (next re-run dedups) - [ ] Accepted-cosmetic: em-dash card anchors the first `—` — a still-over-budget re-run is deduped while that card stays open (demonstration lane, no apply risk) - [ ] S3.4 is complete; M2 continues with the remaining map items --- *Log written by write-log skill. Verification cited: full suite 489/489 passed (xcresult-verified), swiftformat 0/98, swiftlint no new violation class.*