feat(mentor): native deslop lint as fix cards (#6)
CI / ci (push) Canceled after 0s

PRD S3.4: the deslop doctrine's deterministic findings — banned-vocab
tiers and em-dash density — are now computed in Swift at pass
invocation, one line after the #31 stats capture, with no engine
round-trip. Findings land as real fix cards (emitter lint) through
FixCardStore, so they render in the existing palette with ask-before
Apply on mechanical mapping cards; mapped phrases (the skill's verb
swaps + #31, e.g. utilize→use) case-match their anchor per ADR-0006,
everything else closes Done/Skip. One card per phrase over its tier
allowance, whole-word case-insensitive matching (delved never fires
delve), em-dash density card first when over budget; emit dedups
against OPEN cards so re-runs make progress and the engine never
re-cards a live lint finding.

The tiers ship as data (Resources/deslop-lint.json mirroring the
deslop skill verbatim — key/landscape/highlight/bare-underscore
omitted as POS-ambiguous) with a <home>/deslop-lint.json override
that wins whenever it exists and decodes: trivially editable without
a recompile.

Finish-audit fixes folded in: whitespace-only override phrases can
no longer silently kill a whole submit (the guard mirrors the
store's trimmed validation), and submit now refuses a symlinked
cards/ dir (promote's posture — the lint auto-fires it every Run
Pass). Suite 489; one EditorSession load-flake cleared in isolation
and on the idle re-run.

Closes #6
This commit is contained in:
AlexKucera committed 2026-10-30 12:05:30 +01:00
1 parent 22bca36857
commit 4724e00b73
13 files changed
+687 -7

No files matched your search

@@ -0,0 +1,68 @@
# 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:)` (`<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 + `<home>/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.*
+1
View File
@@ -5,6 +5,7 @@ Complete history of session logs in this directory, newest first. One-line summa
<!-- write-log: full-index -->
| Date | Type | File | Summary |
|------|------|------|---------|
| 2026-10-30 | issue | [20261030-issue6-native-deslop-lint-swift-banned-vocab-em-dash-fix-cards_log.md](20261030-issue6-native-deslop-lint-swift-banned-vocab-em-dash-fix-cards_log.md) | #6 native deslop lint: banned-vocab tiers + em-dash budget as data, emitter-lint cards at pass invocation; audit fixes — 489 tests |
| 2026-10-30 | issue | [20261030-issue1-verify-style-constraints-prompt-end_log.md](20261030-issue1-verify-style-constraints-prompt-end_log.md) | #1 prompt-end constraints: ACP audit, draft-first-rules-last persona pin, layout factsheet, real-run verify |
| 2026-10-28 | issue | [20261028-issue137-profiles-s4-engine-lifecycle-model-switch-ux_log.md](20261028-issue137-profiles-s4-engine-lifecycle-model-switch-ux_log.md) | Pass engines on-demand per profile, transient transcripts, chat restart deferred mid-turn, missing-key Run Pass — 2 race fixes |
| 2026-10-27 | issue | [20261027-issue136-profiles-s3-settings-write-path-test-connection_log.md](20261027-issue136-profiles-s3-settings-write-path-test-connection_log.md) | Profiles S3: settings write path (config set + .env), Test Connection probe, three dogfood rounds, three-reviewer audit |