Files
museion/docs/devlog/20261204-issue206-display-micro-blog-published-status_log.md
T
AlexKucera 6aa31a419a feat(microblog): show Micro.blog publish status
The publish sheet flipped a draft live and remembered nothing, so
nothing on disk said a piece was out and the library could not show
it. A successful Publish now stamps `micropub_published` in the
piece's frontmatter; the row and the sheet read `published <date>`
or `draft on Micro.blog`, and a published piece's menu opens the
live post.

Sending a piece again no longer creates a second post: a piece that
remembers its post updates it in place (name and content only, so
categories set on Micro.blog survive). An image whose bytes are
unchanged rides its earlier upload through a per-piece memo. When
Micro.blog answers 404 the piece forgets both keys and the sheet
offers a fresh draft; a clear that cannot land says so instead of
claiming the link is gone.

Museion's micropub keys are dropped at the import boundary. An
imported `micropub_url` passes the format gate and would aim the
in-place update at one of the writer's own posts under their token,
so the keys are treated like `origin`: ours to set, never a foreign
file's to carry in. Publish is model-owned and trust-gates its URL
before anything is stamped.

Tests read recorded requests through an optional accessor: an
out-of-range subscript after a failed count expectation trapped the
hosted runner and reported every queued test as crashed.

+16 tests net (17 new pins in MicropubStatusTests, one retired whose
premise the in-place design voids); every new pin was watched fail
on its own guard. Rail 752/752; SwiftFormat and SwiftLint clean.
Reviews: standards + spec during the build, then a three-reviewer
finish audit. Docs: AGENTS.md bullets and learnings, GLOSSARY
terms, CHANGELOG [Unreleased], README, and the devlog.

Closes #206
2026-12-04 17:45:35 +01:00

13 KiB
Raw Blame History

Micro.blog: the publish is remembered and shown (#206)

Date: 2026-12-04 Type: issue Reference: #206 — Display Micro.blog published status ("Right now it is unclear when a post was published.")

Goal

Make the library say where each piece stands on Micro.blog. The publish sheet flipped a draft live and remembered nothing, so nothing on disk ever said a piece was out — the row could not show it, and sending a piece again created a second post.

What Was Done

  • Grilling first (13 questions, every one owner-answered in session). The agreed design, built as one cohesive slice: a local publish record, the row label, the in-place re-send, the upload memo, a model-owned Publish, 404 recovery, the sheet's three open-states, the row-menu item.
  • PostLibrary.swift — Post.micropubPublished (frontmatter micropub_published, the stats_captured stamp shape) and the pure row label micropubStatus (published <MMM d, yyyy> / draft on Micro.blog / nil). parseStamp now serves both stamps; Micropub.rememberedURL moved to the client as the one trust-gate read.
  • Micropub.swift — Outcome.updated(url:) and .forgotten(String); jsonPost (the one JSON request builder); makeUpdateRequest + Micropub.update (action=update + replace name/content against the remembered URL — never a status flip, so Micro.blog-side categories stay untouched); micropubSend (was micropubSendDraft: no remembered URL → create + stamp micropub_url; a remembered one → the in-place update; a 404 → the piece forgets); micropubPublish (model-owned now: trust-gates its URL, flips the status, stamps the publish record, and heals micropub_url in the same write should the send's stamp have failed); micropubPostGone (a clear that cannot land refuses with the by-hand instruction); the illustration rail split into uploadIllustrations (floor + pre-flight) and uploadRemembered (memo-aware upload).
  • MicropubMedia.swift — the upload memo: .museion-uploads.json in the piece folder maps sha256(bytes) → uploaded URL. Read back through the trust gate; a symlinked memo never reads; written as each upload lands.
  • PostFrontmatter.swift — stampFormat (the one home for the stamp shape); micropubKeys; updating(dropping:) removes named keys' lines; mergingImport drops the micropub keys.
  • PostStore.swift — stampMicropub(_:home:_:dropping:) (was stampMicropubURL); forgetMicropub throws, and removes both lines rather than emptying them.
  • UI — LibraryPostRow: the mono-11 micro-label shows the status in origin's place on a sent piece (VoiceOver reads both; origin stays in the tooltip). WorkspaceChrome: MicroblogHandOffButton (Open on Micro.blog, published pieces only) mounted in the library and Archive menus. MicropubPublishSheet rewritten around the piece's record: Send as Draft → Publish / Update Draft / Update Live Post (status line + the live link).
  • Tests — new MicropubStatusTests (17 pins); MicropubTests/MicropubModelTests follow the renames; the old "re-drafting overwrites the url" pin is retired (its premise is void under the in-place design); MicropubRequestLog.request(_:) replaces 11 index-after-count subscripts (4 new, 7 pre-existing).
  • Owner sign-off in session: origin hidden on sent rows; drafts get no link and no menu item (he tested it — a draft's URL answers "Not Found" until published); the stamp is Museion's publish-click time in local time. His one legacy published post was hand-stamped from the blog's feed (micropub_published: 2026-12-04T14:08:11 — one frontmatter line, +40 bytes, nothing sent to Micro.blog).
  • Reviews — two-axis during the build (standards + spec: 0 hard violations, 7 of 8 judgement calls fixed, 1 rejected), then finish-audit (ponytail + security + general; see Decisions).
  • DOX: CHANGELOG.md [Unreleased], the README publishing paragraph, root AGENTS.md (three learnings), Museion/AGENTS.md, MuseionTests/AGENTS.md.

Verification (finish-up gates, each decided by its own exit code): swiftformat --lint . — 0/154 files require formatting, exit 0. swiftlint lint --strict --quiet — 0 violations, exit 0. ./scripts/full-test.sh — 752 executed / 752 passed / 0 failed (run dir _build/full-test/20261204T163814Z-Museion; 736 at session start → +17 new pins, −1 retired).

Flip cycle: six assert-anchored batches on the uncommitted tree (pristine copies + cmp on restore, byte-exact every time). All 17 new pins were watched fail — each on its own guard, nothing else red except where predicted: update branch, publish stamp, publish identity guard, row label (10 red — the update branch's flip also reddens the three pins whose third request becomes a create); memo lookup + both 404 sites (4); memo trust gate + the honest-forget catch (2); the link heal (1); import drop + publish URL gate + memo symlink guard (3); stamp-on-failure + the update request's literal + the bytes-keyed memo (4 — the literal's flip also reddens the re-send pin that asserts the same action).

Decisions & Rationale

Decision Rationale
The publish is a local frontmatter stamp (micropub_published, local time), not a live query The ticket asks what the writer published from here. A live status query needs a token on every list render and still cannot say "from this machine". Owner-approved, including that the date is Museion's publish-click time.
The row's micro-label shows the status in origin's place on a sent piece 178pt of row content cannot hold both. Origin stays in the accessibility label and the tooltip. Owner-approved.
A re-send updates the remembered post in place (action=update + replace name/content) Before: a second post every time. replace names only those two properties, so categories and everything else set on Micro.blog survive (the owner's explicit worry).
Publish stays a status flip and becomes model-owned No content travels on publish. The sheet used to call the client directly, which is exactly why nothing was ever remembered.
An unchanged image rides its earlier upload via a per-piece memo keyed by sha256(bytes) Micro.blog's media listing carries no content hash to match against, so the memory has to be local. Ceilings are ponytail comments: no liveness probe (a deleted upload stays memoized), memo URLs pass the format gate only (blogs use custom domains).
A 404 means the post is gone there: the piece forgets both keys, and a clear that cannot land refuses Before: the piece failed forever against a dead URL. Emptying the keys left a dangling micropub_published: line — the lines are removed instead. A swallowed write must not be reported as "cleared".
Drafts show no link and no Open on Micro.blog item Owner-verified: a draft's final URL answers "Not Found" until the post is published.
No typed status enum Two consumers (row, sheet) of a computed label. Rejected as speculative by the standards review.
The import boundary drops micropub_url and micropub_published Finish-audit security finding. An imported micropub_url passes the format gate, and since the in-place update it would aim a content replace — under the writer's token — at any post on their blog; a crafted guest post would open the sheet reading "Published" with one Update Live Post button. These keys are Museion's bookkeeping, so they are treated like origin: ours to set, never a foreign file's to carry in. One codec parameter (updating(dropping:)) serves the import and the forget. Side effect: re-importing one's own exported piece loses the link (next send = a new draft); moving the library is a Home repoint, not an import.
micropubPublish trust-gates its URL before anything travels Security and general reviewers converged. Every current caller passes a gated value, but the URL lands in frontmatter on the heal, and the repo's rule is to gate at the sink.
Pins read recorded requests through MicropubRequestLog.request(_:) An out-of-range subscript traps the hosted runner (first Gotcha). A nil from the accessor fails the pin's own expectation.
Ponytail cuts accepted statusHome() duplicated the shared storeHome(); illustratedPiece duplicated plantIllustratedPiece line for line; Micropub.update's empty-URL guard was unreachable (its only caller passes the trust gate's output).

Gotchas & Fixes

Problem Root Cause Fix
A flip run reported 9 failures with no assertion text anywhere The test host had trapped: log.requests[2] after a failed #expect(log.requests.count == 3). An out-of-range subscript kills the hosted runner, and every queued test reports Crash: beside it (the crash report: Array._checkSubscript under Runner._applyScopingTraits). A real regression of the memo gate would have turned one red pin into nine MicropubRequestLog.request(_:) at all 11 sites, #require where the value feeds a non-optional parameter. Read summary.json testFailures for a shared Crash: signature before reading a red count as a verdict.
micropubStatus compiled in the app but read "no member" from a fresh test file Spelling drift between targets (microblogStatus in the test), not a stale binary Grep the exact name across app AND tests before hunting binaries.
The patch tool re-indented ArchivePaneView's closing braces A replaced region that starts on a closing-brace run is re-indented to the anchor's scope Restored from HEAD by a scripted splice; recorded as the code-editing skill's rule 9.
A scripted flip's anchor missed twice (count 0) I typed the do/try/catch lines one tab short of the file The assert fired before anything flipped. Anchors are now written from repr() of the real bytes.
swiftformat reflowed the multi-line updating(...) call after the edits A formatter pass between edit and flip Read anchors back after formatting; file-mutating tools run before the suite, never after.
The terminal's grep wrapper returned 0 matches for a parenthesised pattern that exists in the file The wrapper's regex dialect search_files for source reads; the terminal only for build logs.
The xcresult summary's passedTests reads total + 1 on green runs Pre-existing rail quirk Counts come from the rail's own line, never from the summary's passed figure.
"Update Live Post" on a stamp with no remembered link would have created a second post (audit) The sheet branched on the stamp alone The button reads "Send as Draft" when nothing is remembered — there is no post to update.

Files Changed

File Change Summary
Museion/Micropub.swift Update request + client step; micropubSend (create-or-update, 404 forget), model-owned micropubPublish with the URL gate, micropubPostGone, the memo-aware upload rail, rememberedURL, shortDate
Museion/MicropubMedia.swift The upload memo: key, trust-gated read, symlink refusal, atomic write
Museion/MicropubPublishSheet.swift Opens on the piece's record; the three open-states; honest button labels
Museion/PostLibrary.swift micropubPublished, micropubStatus, the shared parseStamp
Museion/PostFrontmatter.swift stampFormat, micropubKeys, updating(dropping:), import drops the micropub keys
Museion/PostStore.swift stampMicropub(dropping:), forgetMicropub throws and removes the lines
Museion/LibraryPostRow.swift Status in the micro-label, composite accessibility label, origin tooltip
Museion/WorkspaceChrome.swift MicroblogHandOffButton
Museion/PostsLibraryColumn.swift, Museion/ArchivePaneView.swift Mount the menu item
MuseionTests/MicropubStatusTests.swift New — 17 pins: the record, the heal, the import drop, the URL gate, the in-place re-send, the memo, the 404 forget
MuseionTests/MicropubTests.swift MicropubRequestLog.request(_:); renames
MuseionTests/MicropubModelTests.swift Renames; safe request reads; plantIllustratedPiece shared
AGENTS.md, Museion/AGENTS.md, MuseionTests/AGENTS.md DOX pass: contracts, suite map, three learnings
CHANGELOG.md, README.md The feature, the import rule, the by-hand legacy key
docs/devlog/ This log; INDEX.md row; the AGENTS.md window

Open Items & Next Steps

  • Owner to confirm the audit default: Import drops a file's Micro.blog memory (re-importing one's own exported piece loses the link; the next send creates a new draft).
  • Ticket candidate: the preview URL from Micro.blog feeds a Link without the URL gate — the same posture at HEAD, outside this diff.
  • Ticket candidate: Convert to Post rebuilds the frontmatter block and drops every foreign key, the micropub memory included (#114 posture; reachable only for a sent outline).
  • Named ceiling, no action: a TLS-intercepting proxy answering 404 would clear a live post's record.
  • Pieces published before this build read as drafts until Publish is clicked once (or the key is added by hand — one was).

Log written by write-log skill