H4: P2 restored — cinema/poll mutations emit activities (TDD)
Failing tests first (6 red: no cinema/poll handler emitted anything — films/showings/votes were invisible to federation and other peers' behaviors). Now: new-film→create(film), new-showing→schedule(showing), offering-add→offer, offering-update→update (id carries new values so distinct changes federate, replays dedup), offering-remove→retract, add-poll→create(poll), new-event→schedule(event), vote→vote(poll) — voter kept OFF the wire (seat number makes the id unique; pinned by test). All through host/blog--emit! (engine + durable activity log + outbox). buy-ticket's sell emission lands with H5's injectable mint. blog suite 244/244 (+6). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1412,6 +1412,57 @@
|
||||
(contains? (host/blog--out-raw "h3-opt-b" "voted") "v2@x.com"))
|
||||
false)
|
||||
|
||||
;; ── HARDENING H4: P2 restored — cinema/poll state changes EMIT activities ─────────────────
|
||||
;; Every mutation goes through host/blog--emit! (engine + durable activity log + outbox), so
|
||||
;; federation followers + other peers' behaviors can react. Votes emit voter-ANONYMOUSLY.
|
||||
(host/blog-use-store! (persist/open))
|
||||
(define host-bl-h4-verbs
|
||||
(fn () (map (fn (e) (get e "verb")) host/blog--activity-log)))
|
||||
(define host-bl-h4-admin
|
||||
(fn (target body)
|
||||
(host-bl-h2-app (host-bl-send "POST" target "Bearer good" "application/x-www-form-urlencoded" body))))
|
||||
|
||||
(host-bl-test "H4: new-film emits create(film)"
|
||||
(begin
|
||||
(set! host/blog--activity-log (list))
|
||||
(host-bl-h4-admin "/new-film" "title=Emit Film")
|
||||
(map (fn (e) (list (get e "verb") (get e "object") (get e "type"))) host/blog--activity-log))
|
||||
(list (list "create" "emit-film" "film")))
|
||||
(host-bl-test "H4: new-showing emits schedule(showing)"
|
||||
(begin
|
||||
(set! host/blog--activity-log (list))
|
||||
(host-bl-h4-admin "/new-showing" "film=emit-film&calendar=h4cal&time=t1")
|
||||
(contains? (host-bl-h4-verbs) "schedule"))
|
||||
true)
|
||||
(host-bl-test "H4: offering-add emits offer(offering)"
|
||||
(begin
|
||||
(set! host/blog--activity-log (list))
|
||||
(host-bl-h4-admin "/offering-add?showing=emit-film-h4cal-t1" "tickettype=h4-vip&price=9")
|
||||
(contains? (host-bl-h4-verbs) "offer"))
|
||||
true)
|
||||
(host-bl-test "H4: offering-update emits update(offering)"
|
||||
(begin
|
||||
(set! host/blog--activity-log (list))
|
||||
(host-bl-h4-admin "/offering-update?offering=emit-film-h4cal-t1--h4-vip" "price=12&cap=5")
|
||||
(contains? (host-bl-h4-verbs) "update"))
|
||||
true)
|
||||
(host-bl-test "H4: add-poll emits create(poll)"
|
||||
(begin
|
||||
(set! host/blog--activity-log (list))
|
||||
(host-bl-h4-admin "/add-poll?post=emit-film" "question=Q&options=a,b")
|
||||
(contains? (host-bl-h4-verbs) "create"))
|
||||
true)
|
||||
(host-bl-test "H4: vote emits vote — voter NOT in the logged activity"
|
||||
(begin
|
||||
(set! host/blog--activity-log (list))
|
||||
(let ((poll (first (host/blog--out-raw "emit-film" "has-poll"))))
|
||||
(begin
|
||||
(host-bl-h2-app (dream-request "POST" (str "/vote?poll=" poll "&option=" poll "-a")
|
||||
{:content-type "application/x-www-form-urlencoded"} "voter=secret@x.com"))
|
||||
(list (contains? (host-bl-h4-verbs) "vote")
|
||||
(some (fn (e) (contains? (str e) "secret@x.com")) host/blog--activity-log)))))
|
||||
(list true false))
|
||||
|
||||
(define
|
||||
host-bl-tests-run!
|
||||
(fn ()
|
||||
|
||||
Reference in New Issue
Block a user