host: P0 review — fix edit-submit ordering bug + record carried-forward debt

REVIEW at the P0-complete milestone found one live bug and several forward prerequisites.

FIX (was live): edit-submit ran maybe-publish! BEFORE set-field-values!, so an edit that set a
category and published in one submit fired the publish activity on the STALE category (wrong branch).
Reordered — fields land before the transition fires. Regression test added (fields-first →
newsletter→digest, not stale→notify). blog 210/210.

Recorded carried-forward debt in the plan: activity identity (DEBT #1, blocks P2 — :id=CID false-
dedups relation events), capability bind not wired into the live engine (DEBT #2, P1), synchronous-
in-request dispatch (DEBT #3, RA needs the async boundary + background pump), the 'urgent' default
smell (DEBT #4). Sequencing note: P1's runner-derivation is vacuous until RA adds a 2nd runner, and
RA is the load-bearing risk — recommend a narrow RA spike next to de-risk the durable/federated half.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-02 15:17:48 +00:00
parent 77e89a9965
commit a5d43246e0
3 changed files with 46 additions and 3 deletions

View File

@@ -2659,14 +2659,16 @@
(if (= (len issues) 0)
(begin
(host/blog-put! slug title sx-content status)
;; P0.3: a draft→published transition fires the publish flow through the seam.
(host/blog--maybe-publish! slug (get r :status) status)
;; store the typed field values from the generic, type-driven form (Slice 8b)
;; store the typed field values FIRST — the publish activity reads :category from
;; them, so field-writes must land before the transition fires (else it branches on
;; the stale category on an edit that both sets a category and publishes).
(host/blog--set-field-values! slug
(reduce (fn (acc f)
(assoc acc (get f :name)
(or (host/field req (str "field-" (get f :name))) "")))
{} post-fields))
;; P0.3: a draft→published transition fires the publish flow through the seam.
(host/blog--maybe-publish! slug (get r :status) status)
(dream-redirect (str "/" slug "/")))
(let ((issue-items (map (fn (i) (quasiquote (li (unquote i)))) issues)))
(host/blog--resp req 400

View File

@@ -1191,6 +1191,17 @@
(list (get e :type) (get (get e :object) :type)
(get (get e :object) :slug) (get (get e :object) :category))))
(list "create" "article" "pub4" "newsletter"))
;; P0 review regression: field-writes must PRECEDE the transition, else the publish activity
;; branches on the stale category. (edit-submit now sets fields before maybe-publish!.)
(host-bl-test "publish reads the FRESH category (fields set before the transition fires)"
(begin
(set! host/blog--flow-log (list))
(persist/backend-kv-put host/blog-store host/blog--flowlog-key (list))
(host/blog-put! "p04r" "R" "(article (h1 \"r\"))" "draft") ;; a draft, no category yet
(host/blog--set-field-values! "p04r" {"category" "newsletter"}) ;; fields FIRST (the fix order)
(host/blog--maybe-publish! "p04r" "draft" "published") ;; then the transition
(map (fn (e) (get e "verb")) host/blog--flow-log))
(list "validate" "digest")) ;; newsletter→digest, not stale→notify
;; P0.2: the publish WORKFLOW as an execute-fold DAG — branches on category, needs {effect,branch},
;; binds to the synchronous execute-fold runner (derived, not chosen).
(host-bl-test "publish-DAG: category branch (newsletter→digest) via the execute-fold"