CI / ci (push) Canceled after 0s
PostsModel.swift had outgrown its lint ceilings — 1127 lines against the 1000 file-length error, class body 361 against 350; both pre-dated the week and #143 deepened them while naming this split as the follow-up. The six domain extensions after the class move to their own files, domain-grouped: PostsModelOutline.swift (mixed-content guard #111 + Convert to Post #114), PostsModelPasses.swift (pass orchestration #24 + Blind Read #122), PostsModelCards.swift (stored cards #23 + apply/skip/done #25 + promote #26, with their support types). The watcher section (startWatching + rescan) moves to a file-scope extension so the class body drops to 323 — #111's precedent: same-file extensions keep private state file-scoped while type_body_length only counts the class body. Pure moves, mechanically verified line-for-line: the only edits are the 18 private->internal widenings the cross-file moves force (13 private(set) setters + rescan/dismissExternal/wireSession/ isGuardedOutline/openUnguarded, each doc-noted) and the two wrapped-condition guards unwrapped per the #142 learning, clause order preserved. The error ceilings and both opening_brace warnings are gone; the residual default WARNING-tier notices (708/400 file, 323/250 type-body) match the repo's standing posture — the ticket's own ~700-line landing zone makes the 400 tier unreachable. Full suite 574/574 by xcresult executed count (573 unit + 1 UI smoke). Closes #146
6.7 KiB
6.7 KiB
#146: PostsModel.swift back under the lint ceilings — extensions split + class-body move
Date: 2026-11-03 Type: issue Reference: git.babylondreams.de/AlexKucera/museion#146
Goal
PostsModel.swift back under the swiftlint error ceilings (file 1127→≤1000 lines, class body 361→≤350) with both opening_brace warnings gone, as a pure move — zero behavior change, no edits beyond the ticket-sanctioned private→internal widenings.
What Was Done
- Split PostsModel.swift (1127 → 708 lines; class body 361 → 323) into three domain files, all moves verbatim (mechanically verified line-for-line with a
commdiff against HEAD — every lost line is a declared edit):Museion/PostsModelOutline.swift— mixed-content outline guard (#111) + Convert to Post (#114) +PendingConversionMuseion/PostsModelPasses.swift— pass orchestration (#24) + Blind Read (#122)Museion/PostsModelCards.swift— stored cards (#23) + apply/skip/done (#25) + promote (#26) +FixCardApplyOutcome/FixCardPromoteOutcome
- Moved
startWatching+rescanout of the class body into a file-scopeextension PostsModelin PostsModel.swift (the #111 precedent) — class body 323 < 350;startWatchingstays private (same-file extension),postsstaysprivate(set)(rescan writes it same-file). - 18 widenings private→internal, each doc-noted
#146: 13private(set)setters → plain internal vars (selectedPostID,draft,session,pendingProject,lastDraftWasOutline,outlineGuardPieceID,proseOverridePostID,pendingConversion,runningPass,runningBlindRead,openPieceHasSnapshot,openPieceCards,lastError) + 5 funcs (rescan,dismissExternal,wireSession,isGuardedOutline,openUnguarded) — every one required by a verified cross-file caller. - Unwrapped both
opening_braceguards per #142: rescan's stale-scan guard joined to one 137-char condition line (clause order preserved:watchedHome == homestill short-circuits before thePostStore.folderdisk probe); convertToPost's answer-time consent recheck as nested ifs. - DOX pass: Museion/AGENTS.md PostsModel bullet — #146 lead-in added; all four "file-scope/same-file extension" mentions now name the new files.
Decisions & Rationale
| Decision | Rationale |
|---|---|
| Three domain files, not one | Ticket: "domain-grouped at the implementer's discretion"; outline/passes/cards are the natural domains, each ~150 lines, all cross-extension private access stays file-scoped per file |
| "Zero violations" AC read as the four ticket-named violations | swiftlint DEFAULT warning tiers (400 file / 250 type-body) fire at 708/323, but the ticket's own "lands around 700 lines" makes the 400 tier unreachable; 14 repo files carry the same tier, #144's commit records 289 violations repo-wide at HEAD — the house bar is the ERROR tier |
| 573-at-filing vs 574 executed | The scheme runs MuseionTests + the 1 UI smoke test — 573 unit + 1 UI = 574; not a count regression |
Declined: move title(of:) to PostsModel.swift core |
Its doc names three consumers spanning passes AND the cards palette — cross-cutting before the split too; reshuffling beyond the ticket breaks the pure-move fence |
| Declined: dedup promoteCard's repeated error string | Pre-existing inside a verbatim-moved body — the fence forbids fixing it here; follow-up |
Gotchas & Fixes
| Problem | Root Cause | Fix |
|---|---|---|
| swiftlint "zero violations" AC is self-contradictory at filing size | When a value exceeds the ERROR tier, swiftlint reports only the error — the WARNING tiers (400/250) were invisible at 1127/361 and surfaced the moment the errors cleared | Read the AC as the four named violations; flagged the two residual warnings explicitly in the report and to the reviewers (all three audit reviewers ruled it a spec-internal conflict, not a defect) |
| 13 setters silently needed widening beyond the obvious 5 funcs | private(set) setter access is same-FILE for extensions — every moved extension that sets model state needs the internal setter |
Pre-swept all moved bodies for private/setter writesites before writing (the subagent-delegation skill's move checklist); each widened member carries a #146 doc note as the tripwire |
{PIPESTATUS[0]} empty in background shell |
zsh spells it pipestatus |
Pinned -resultBundlePath and read the xcresult instead of trusting exit banners (house learning #31/#33 anyway) |
Files Changed
| File | Change Summary |
|---|---|
Museion/PostsModel.swift |
1127→708; watcher section to file-scope extension; 18 widenings; guard #1 unwrapped; header note |
Museion/PostsModelOutline.swift |
NEW — guard #111 + Convert #114 extensions + PendingConversion (code unchanged save the #114 guard unwrap) |
Museion/PostsModelPasses.swift |
NEW — pass #24 + Blind Read #122 extensions, code unchanged |
Museion/PostsModelCards.swift |
NEW — cards #23/#25/#26 extensions + both outcome enums, code unchanged |
Museion/AGENTS.md |
DOX: PostsModel bullet — #146 lead-in + four extension-location mentions updated |
AGENTS.md |
GitNexus stats-bump line (auto-churn from analyze) |
Verification
- swiftlint on the four Swift files: 0 errors, 0 named-warning violations (file_length 1127/1000 and type_body 361/350 errors gone; both opening_brace warnings gone). Residual: default warning-tier notices 708/400 + 323/250 — accepted posture (see Decisions).
- swiftformat
. --lint: 0/113 files require formatting. - Build + full suite via pinned xcresult: 574 executed, 574 passed, 0 failed (573 unit + 1 UI smoke).
- Reviews: implement-close Standards+Spec both Approve (no hard violations); finish-audit ponytail/security/general fanout — 0 deletable code, 0 runtime-exploitable delta, 0 crit/high/medium; one comment-word fix applied (Outline header "code unchanged save the #114 guard unwrap").
- GitNexus: impact (CRITICAL = fan-out, 113 direct callers — pure-move diff), detect-changes (line-shift noise + docs), analyze re-indexed.
Open Items & Next Steps
- Follow-up fodder (declined under the pure-move fence): dedup promoteCard's error string; consider
title(of:)'s home; #137 stale-scan guard has no direct test (pre-existing gap) - If literal warning-zero is ever wanted: further split (projects ops + PostsWatcher out) to get under 400/250 — or configure the tiers in .swiftlint.yml
- Security-review note:
openUnguardedis now module-callable (latent #111 bypass, zero unsanctioned callers) — re-privatize by folding select's tail into the Outline file if the fence is ever wanted back
Log written by write-log skill