feat(microblog): post summary for Micro.blog
A piece's `summary:` frontmatter line now travels to Micro.blog beside `category:`. A first send carries the summary when it is not empty; a re-send replaces the post's summary only when the piece has the line (opt-in by key; an empty value clears it; no line leaves the blog's). The same rule as categories, so a piece that never gained the line cannot blank a summary set on Micro.blog itself. The publish sheet gains a Summary field and an AI summary button. The button drafts a first-person teaser from the open piece on a fresh one-shot engine on the chat profile (the Blind Read's rail — the resident session is never touched); the reply fills the field for the writer to edit, and nothing is written until the send stamps the line. The sheet is modal, so while its own turn runs the button is the Stop; a Pass or Blind Read that owns the rail disables the button with the reason on hover and refuses from behind it. The summary is read off the RAW frontmatter line, never through the lenient decode — which trims every edge quote — and the read walks the block the way the lenient reader does. A `split`-based read finds no block in a mixed-ending file while the lenient reader still sees the key, and the empty value it answers would have been sent over a live post's summary. Reviewed twice (two-axis during the build, three-reviewer finish-audit after): the mixed-ending read, an unfenced body line claiming the key, the uncancellable modal turn, and the wrapper rule eating a teaser's edge quotes were found and fixed before this commit. Every guard was watched fail on its own pin. Rail 814/814; SwiftFormat and SwiftLint clean. Docs: AGENTS.md bullets and learnings, the GLOSSARY term, CHANGELOG [Unreleased], PRD S6.1, and the devlog. Closes #208
This commit is contained in:
1 parent
6db4cf8cf1
commit
36393a9e8e
22 files changed
+1096
-36
No files matched your search
@@ -0,0 +1,82 @@
|
||||
# Post Summary for Micro.blog (#208)
|
||||
|
||||
> **Date:** 2026-12-05
|
||||
> **Type:** issue
|
||||
> **Reference:** https://git.babylondreams.de/alex/Museion/issues/208
|
||||
|
||||
## Goal
|
||||
|
||||
Give the publish dialog a post-summary field plus an "AI summary" button. The summary is first-person, entices the reader to read the full piece, and travels to Micro.blog with the send.
|
||||
|
||||
## What Was Done
|
||||
|
||||
- **Wire** (`Micropub.swift`): `makeDraftRequest`/`makeUpdateRequest`/`update`/`sendDraft` carry a `summary:` parameter. A create adds `properties.summary` only when non-empty; an update carries `summary` in `replace` only when the piece has the line (opt-in by key — `nil` leaves the post's summary alone, `""` clears it). One read (`updateRememberedOrCreate`) serves the wire fields, the categories, the summary, and the remembered URL.
|
||||
- **Codec** (`PostFrontmatter.swift`): `summaryValue(_:)` renders one line (whitespace runs — newlines included — collapse to one space, control characters drop; a value holding a quote or backslash renders QUOTED with the category codec's own escapes — one grammar for both keys). `summary(inText:)` reads it back off the RAW line: a parse-style block walk (past the opening fence to the next `---`) with a fused `\r\n---` tail strip, never through the lenient `parse` (which trims every edge quote) and never via `split` (whose closing-fence check a mixed-ending file defeats). `summary(in:)` — the lossy decoded read — was deleted (zero production consumers).
|
||||
- **Model** (`PostsModelMicropubSummary.swift`, `PostsModel.swift`, `PostsModelPasses.swift`): `summarize(mentor:)` = the shared open-piece guard rail → flush → ONE disk read feeds the prompt → `mentor.runSummary` on a fresh one-shot chat-profile engine → `SummaryPrompt.cleaned`. Writes nothing. `PostsModel.summarizing` is the one-shot rail's third rider; `oneShotRailBusy` is the ONE predicate the sheet, the pass bar's Cancel, `cancelPass`, and `guardOpenPieceRun` all consult. `micropubSend(categories:summary:)` stamps a pending summary edit at the send (write-before-wire — a failed stamp refuses with nothing on the wire); `micropubPublish` applies a pending edit first.
|
||||
- **Engine** (`MentorSessionModel.swift`): `runSummary(prompt:pieceTitle:)` rides `runOneShot` (label `Summary · <piece>`, reply read through `draftCandidateText`); exclusivity unchanged — a summary refuses while a Pass or Blind Read runs, and vice versa.
|
||||
- **Prompt** (`SummaryPrompt.swift`): `prompt(title:body:)` asks for a first-person teaser that entices the reader, reply = summary text only. `cleaned(_:)` trims, drops ONE leading `Summary:` label (colon required), strips ONE pair of surrounding quotes only when the inner text holds no other `"` (a wrapper, not a teaser that opens on a quoted word), then round-trips through the codec so the field shows exactly the text the wire will carry.
|
||||
- **Sheet** (`MicropubPublishSheet.swift`, `PostsPaneView.swift`): a Summary `TextEditor` (mono-11, 72pt) with the `AI summary` button in the label row; the reply fills the field for the writer to edit. The sheet holds `let mentor: MentorSessionModel` (PostsPaneView passes its own — the one construction site). Sync points mirror the Categories field: disk on open and after a forget, canonical one-line text after a successful send/publish, baseline only after a failed step. `MicropubSummaryField.pendingSummary` is a trimmed-STRING compare (whitespace alone is not an edit; equal empties stay nil — a piece without the line never gains an empty key).
|
||||
- **Cancel** (`MentorPaneView.swift`, `PostsModelPasses.swift`): the sheet is modal, so while its own summary turn runs the AI button IS the Stop (click → `cancelPass`); the pass bar's Cancel shows on `oneShotRailBusy`.
|
||||
- **Tests**: `MicropubSummaryTests.swift` (16 pins) + `SummaryGenerationTests.swift` (7 pins), plus `ScriptedEngine` mode `summaryOnPrompt` (a two-chunk summary-shaped reply, normal end, no fix-card call). 814 total (791 before).
|
||||
- **Docs**: `Museion/AGENTS.md` (SummaryPrompt, PostsModelMicropubSummary, the Micropub bullet, PostFrontmatter, PostStore, MentorSessionModel), `MuseionTests/AGENTS.md`, `GLOSSARY.md` Summary term, `PRD.md` S6.1, `CHANGELOG.md` [Unreleased].
|
||||
|
||||
## Decisions & Rationale
|
||||
|
||||
| Decision | Rationale |
|
||||
|----------|-----------|
|
||||
| The summary lives in a frontmatter `summary:` line, stamped at the send like `category:` (owner ruling) | Survives reopen, rides every re-send, visible in the file — the same discipline the category line established in #207. A sheet-only value would be lost on every reopen and could never be re-sent. |
|
||||
| The AI summary runs on the one-shot engine on the chat profile, never the resident session (owner ruling) | The resident session is the writer's conversation; a drafting side-quest would pollute its transcript. The one-shot rail (ADR-0014) spawns, drafts, and tears down — the Blind Read's proven shape. |
|
||||
| Create carries `summary` only when non-empty; update carries it in `replace` only when the line exists (opt-in by key); `""` clears | Mirrors #207 exactly. Without the opt-in, every re-send of a piece without a line would wipe a summary set on Micro.blog itself. |
|
||||
| The reader walks the RAW line, never `parse` | The lenient decode trims every edge quote — a teaser ending in `"why"` would lose its quotes through that door. Raw-line read + codec unescape keeps the writer's text exact. |
|
||||
| `summary(in:)` deleted rather than kept beside `summary(inText:)` | Zero production consumers and lossy by design. Two readers for one key invite the wrong one at a new call site. |
|
||||
| `oneShotRailBusy` as ONE computed predicate over three riders | The sheet, both Cancels, the guard, and `cancelPass` all need the same answer. One predicate: a fourth rider joins here and every site follows. |
|
||||
| `lastError` for refusals (not a `Result` return) | House posture — `blindRead` and `runPass` report through `lastError`; the sheet already renders the strip. A typed result would be the only one of its kind. |
|
||||
| Refusals keep the field's text | The writer may have typed a summary by hand before clicking AI; a refusal must not eat it. |
|
||||
| The AI button is the Stop during its own turn | The sheet is modal — the pass bar's Cancel is unreachable behind it. Without this, a hung turn would wedge the sheet with no way out. |
|
||||
| `cleaned` strips edge quotes only when no `"` remains inside | A reply opening and closing on quoted words is a teaser; its edge quotes are the writer's. Only a true wrapper (nothing quoted inside) strips. |
|
||||
|
||||
## Gotchas & Fixes
|
||||
|
||||
| Problem | Root Cause | Fix |
|
||||
|---|---|---|
|
||||
| A mixed-ending `post.md` (a stray `\r` on the last block line) fused the closing fence; the lenient reader still saw the key → re-send path, a `split`-based reader found no block → `""` → `replace summary [""]` would wipe a LIVE post's summary | Two readers of one file disagreed on where the block ends | `summary(inText:)` walks the block the way `parse` does and strips a fused `\r\n---` tail; the mixed-ending wire pin went red on exactly this guard (FLIP-A) |
|
||||
| An unfenced body line named `summary:` was read as the summary | The reader did not require a fence | The parse-style walk requires an opening fence; body prose never claims the key |
|
||||
| A hung summary turn could not be cancelled from the modal sheet | The AI button had no Stop behavior and the pass bar's Cancel was behind the sheet | Model `summarizing` flag + `oneShotRailBusy`; the AI button doubles as Stop; `cancelPass` and `guardOpenPieceRun` consult the predicate. Flip: disabling `cancelPass`'s guard hangs the cancel pin (the timeout is the red). |
|
||||
| The first cancel pin's observable was wrong — asserting `runningPass == nil` held through the host's own one-shot lock, so the flip reddened nothing | A third belt masked the guard under test | The pin asserts `lastError == "A summary is already running."` instead; the flip then reddened exactly that pin |
|
||||
| `cleaned`'s wrapper rule stripped the edge quotes of prose bracketed by quoted words | The rule matched any string starting and ending with `"` | Strip only when the inner text holds no further `"`; pinned, flip-verified (FLIP-B) |
|
||||
| The audit round's own edits left 3 lint regressions (a missing blank line after a computed property; a lone `{` under a wrapped condition; a 144-char test line) | Hand edits after the last lint run | Fixed; the lone-brace was the house trap (#142/#179) — hoisted an `isQuotedWrapper` predicate |
|
||||
|
||||
## Files Changed
|
||||
|
||||
| File | Change Summary |
|
||||
|------|---------------|
|
||||
| `Museion/Micropub.swift` | `summary:` on the draft/update builders; create carries when non-empty, update in `replace` by key; one read serves wire fields + categories + summary + URL |
|
||||
| `Museion/PostFrontmatter.swift` | `summaryValue` (one-line render, quote-aware) + `summary(inText:)` (raw-line read, parse-style walk, fused-fence strip); `summary(in:)` deleted |
|
||||
| `Museion/PostsModelMicropubSummary.swift` | new — `summarize(mentor:)`: guard rail → flush → one disk read → `runSummary` → `cleaned`; nil + `lastError` on refusal |
|
||||
| `Museion/SummaryPrompt.swift` | new — the prompt + `cleaned` (label drop, wrapper-only quote strip, codec round-trip) |
|
||||
| `Museion/PostsModel.swift` | `summarizing` flag; `oneShotRailBusy` predicate; `micropubSend(categories:summary:)`; `micropubPublish` applies a pending edit first |
|
||||
| `Museion/PostsModelPasses.swift` + `Museion/MentorPaneView.swift` | `cancelPass` + `guardOpenPieceRun` honor `oneShotRailBusy`; the pass bar's Cancel shows on it |
|
||||
| `Museion/MicropubPublishSheet.swift` | Summary field + AI summary button (doubles as Stop); sync mirrors the Categories field |
|
||||
| `Museion/PostsPaneView.swift` | the sheet takes the pane's own `mentor` |
|
||||
| `Museion/MentorSessionModel.swift` | `runSummary` over `runOneShot` |
|
||||
| `Museion/PostStore.swift` | `stampMicropub` carries the `summary:` line |
|
||||
| `MuseionTests/ScriptedEngine.swift` | `summaryOnPrompt` mode |
|
||||
| `MuseionTests/MicropubSummaryTests.swift` | new — 16 pins |
|
||||
| `MuseionTests/SummaryGenerationTests.swift` | new — 7 pins |
|
||||
| `GLOSSARY.md`, `PRD.md`, `CHANGELOG.md`, `Museion/AGENTS.md`, `MuseionTests/AGENTS.md` | Summary term, S6.1 clause, [Unreleased] entry, DOX rows |
|
||||
|
||||
## Verification
|
||||
|
||||
- Finish-audit gates (final tree): `swiftformat --lint .` 0/161 · `swiftlint --strict .` 0 violations · `full-test.sh` **814/814** (run `20261205T095042Z-Museion`; 791 → 814, +23). The three files edited during the audit compiled in that run (SwiftCompile lines present).
|
||||
- Flips: fused-fence strip → exactly the 2 mixed-ending pins red; `cleaned` wrapper rule → exactly the bracketed-prose pin; `guardOpenPieceRun` summarizing refusal → exactly the reverse-exclusivity pin; `cancelPass` guard → the cancel pin hangs. All restored byte-exact (`cmp` + sha256).
|
||||
- Baseline before the audit: 809/809 on the pre-audit tree.
|
||||
|
||||
## Open Items & Next Steps
|
||||
|
||||
- [ ] Owner to try the live sheet: the AI button's Stop behavior and the one-shot rail refusal are SwiftUI wiring, not host-testable.
|
||||
- [ ] Ticket candidate: Convert to Post rebuilds frontmatter and drops a piece's `summary:` line (#114 posture — same as `category:`).
|
||||
- [ ] Ticket candidate: a malformed frontmatter block lets a stamp land in the wrong place — pre-existing for every stamp, not #208's seam.
|
||||
|
||||
---
|
||||
|
||||
*Log written by write-log skill*
|
||||
@@ -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-12-05 | issue | [20261205-issue208-post-summary-for-micro-blog_log.md](20261205-issue208-post-summary-for-micro-blog_log.md) | Micro.blog summary travels with the piece; publish sheet Summary field + AI summary button on the one-shot rail (rail 814/814) |
|
||||
| 2026-12-04 | issue | [20261204-issue207-allow-setting-and-creating-micro-blog-categories_log.md](20261204-issue207-allow-setting-and-creating-micro-blog-categories_log.md) | Micro.blog categories travel with the piece; comma field with native completion; publish targets the post the send touched (rail 791/791) |
|
||||
| 2026-12-04 | issue | [20261204-issue206-display-micro-blog-published-status_log.md](20261204-issue206-display-micro-blog-published-status_log.md) | Micro.blog publish is remembered and shown: row status, in-place re-send, upload memo, 404 forget; Import drops micropub keys (rail 752/752) |
|
||||
| 2026-12-04 | generic | [20261204-microblog-5xx-wording-token-settings-page_log.md](20261204-microblog-5xx-wording-token-settings-page_log.md) | Micro.blog publish: a 5xx names their outage instead of `HTTP 503`, and the app token gains a Settings page (rail 736/736) |
|
||||
|
||||
Reference in new issue
Block a user