feat(publish): Micropub draft → publish (#33)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Two-step publish to Micro.blog over Micropub: Send as Draft (JSON h=entry create — name = the Title, markdown content verbatim, post-status draft), review via the preview link, then Publish (the action=update post-status flip). The piece remembers its draft URL as a frontmatter micropub_url stamp — in-place, body and foreign keys byte-identical — so a draft survives a reopen; Send Again re-drafts after edits. The app token lives in the Keychain (login keychain; entered once in the sheet, re-offered only on auth failure — ADR-0014's no-Keychain rule covers only provider keys hermes reads from .env). Frontmatter category: is permitted but never sent in v1 — pinned on the wire. The draft URL is trust-boundary data landing in frontmatter, so every URL passes a format gate (https + host, no line/control characters) at BOTH ends: the response decode (Location header → body url; the preview link is display-only, never the publish target) and Post.scan's read-back — imported frontmatter rides verbatim, and a newline--- rider would otherwise close the block and reparse as attacker markdown in the writer's piece. Twenty tests pin the wire contract, decode matrix, own-slot keychain round-trip, stamp/scan, and the model flow (flush-first, refusal guards, the category AC); all four audit guards are flip-verified. Full suite 529 passed / 0 failed. Live end-to-end on a real post (needs the owner's app token) remains open on the ticket.
This commit is contained in:
1 parent
3ee6756467
commit
414f1392ef
15 files changed
+1106
-7
No files matched your search
@@ -28,6 +28,10 @@ nonisolated struct Post: Identifiable, Equatable {
|
||||
var project: String
|
||||
/// True when the piece lives under archive/ (#107).
|
||||
var isArchived: Bool
|
||||
/// #33 (S6.1): the remembered Micro.blog draft URL (frontmatter
|
||||
/// `micropub_url`) — set when a draft was sent, the target the
|
||||
/// publish step updates. Inert to everything else.
|
||||
var micropubURL: String?
|
||||
/// #32 (S5.2): the captured first-draft stats — present ONLY when
|
||||
/// `captureFirstDraftStats` stamped the piece at a pass invocation
|
||||
/// (writer origin, First Draft, post type, decided there against the
|
||||
@@ -154,6 +158,15 @@ nonisolated struct Post: Identifiable, Equatable {
|
||||
type: type,
|
||||
project: projectDir.lastPathComponent,
|
||||
isArchived: isArchived,
|
||||
// #33: the remembered Micro.blog draft URL —
|
||||
// one flat key, read leniently like the rest.
|
||||
// #33 audit: imported frontmatter rides
|
||||
// verbatim, so the read-back gates on the same
|
||||
// format guard the decode applies — a hostile
|
||||
// value never pre-arms the publish sheet.
|
||||
micropubURL: frontmatter["micropub_url"].flatMap {
|
||||
Micropub.trustworthyURL($0) ? $0 : nil
|
||||
},
|
||||
// #32 read-back gate: the capture gate's immutable
|
||||
// pair (origin writer, type post) — NOT pass_state,
|
||||
// which legitimately advances after the capture.
|
||||
|
||||
Reference in new issue
Block a user