Skip to content

Report status changes of CiteCue posts to CiteCue (1.5.0) - #21

Merged
henry-mosh merged 15 commits into
mainfrom
feat/status-callback
Dec 2, 2026
Merged

henry-mosh merged 15 commits into
mainfrom
feat/status-callback

Conversation

@henry-mosh

Copy link
Copy Markdown
Collaborator

What

Plugin 1.5.0 tells CiteCue when a post or page CiteCue pushed changes in WordPress: published, unpublished, trashed, restored, permanently deleted, its address changed, or its text edited. CiteCue then shows what is really on the site instead of what it last sent.

  • New Citecue_Status_Reporter: per-post pending marks with a generation token (a change made while a report is in flight is never lost), delete reports built at before_delete_post (the post's meta is about to vanish), a per-post report counter allocated with a portable compare-and-swap, and a WP-Cron drain (citecue_report_drain): at most 20 reports per run, one request at a time, a 30 s budget, retries honouring Retry-After, and a site-wide hold after an outage reply.
  • Sends POST /api/delivery/v2/content-status (Bearer key, X-Citecue-Channel: wordpress, no redirects, 5 s timeout). Only CiteCue posts, only on a connected site that accepts pushes, only while the site address is https. CiteCue's own pushes are never reported back (suspend()/resume() around ingest).
  • The drain re-arms itself from activation, the daily sync and the settings save, so an interrupted run can't strand reports.
  • /content replies add seq. Settings → CiteCue shows how many reports were given up (expires after 30 days).
  • Disconnect, deactivate and uninstall clean up the marks, delete reports and options. readme.txt's External services section names the new outbound reports.

Version

1.5.0, because #20 (language versions of answer pages) takes 1.4.0 and is older. Whichever merges second needs a merge of citecue.php, readme.txt and README.

Release order

Release only after the CiteCue app deploys the endpoint (henry-mosh/citecue_app, the status-callback PR stacked on #1198 and #1206). Until then an older app answers 404, which the plugin treats as final for that report.

Tests

  • composer lint, composer phpcs: clean.
  • composer test: core, WooCommerce stub and multisite, 509 tests each, all pass (96 in the new reporter suite).
  • Not run locally: the product-push test in tests/cases/test-ingest-products.php needs a real WooCommerce; this repo's CI WooCommerce job covers it.
  • End to end against Docker WordPress with this branch: the app's pnpm e2e:wordpress status-callback scenarios (publish, trash, permanent delete, edit, no self-report, foreign site) pass.

🤖 Generated with Claude Code

henry-idingo and others added 15 commits November 30, 2026 20:59
A new status reporter marks CiteCue posts when they are published,
unpublished, trashed, restored, deleted, re-addressed or edited while live,
and a WP-Cron drain sends the reports to POST /api/delivery/v2/content-status
off the editor's request: up to 20 per run, one at a time, with bounded
jittered retries, Retry-After, sequence catch-up and a generation fence so a
change made while a report is in flight is never lost. Permanent deletes are
built at hook time and kept in their own option. Nothing is marked or sent
until the site is connected, accepts pushes and reports an https address.

Disconnecting clears pending reports; uninstall removes the bookkeeping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The content endpoint suspends the status reporter around its own insert or
update (released in a finally), shares the "edited" hash test with the
reporter, clears the post's pending report and resets what was last reported
after a successful push, and returns the post's report counter as seq. A push
it refuses changes nothing.

Settings shows how many reports were given up beside the connection status.
Version 1.4.0, changelog, upgrade notice, the external-services disclosure for
the new status reports, and README documentation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ngs save

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…thing without one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ge stuck entries, fences, per-entry seq backoff, delete reports kept without a seq

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ase)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Compare a live post on wp_after_insert_post instead of post_updated: the
  block editor's REST save writes categories after post_updated, so a new
  category under a %category% permalink was never reported.
- Also mark when a save changes the post compared with before it, so an edit
  or slug change undone while its report is in flight still goes out.
- Bump the generation before checking the pending mark, so a drain finishing
  between the two steps can't clear the mark of a newer change.
- Pull a drain left a day out by a paused run forward when content pushes
  are switched back on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An undo was caught by comparing the post with its state before the save,
but a post's earlier address can't be rebuilt: get_permalink() uses the
terms as they are now, so a category changed back while the new address was
in flight matched both ways and the reply recorded the wrong address.

Every save of a live CiteCue post now bumps the generation before reading
what was last reported, so a report in flight during any change is never
taken as the last word.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The REST controller stores the text before it saves terms, meta and extra
fields, and returns early if one of those fails, so wp_after_insert_post
never fires for a save whose text already landed. Look on post_updated as
well; wp_after_insert_post still checks the address once the categories are
in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A run loads its posts up front and took each report's number last. A post
CiteCue pushed while an earlier report was in flight went out with its old
status and a number above the push's baseline, with nothing left pending
to correct it. Take the number first, then read the post, its meta and its
terms from the database again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
About an hour holds only without a Retry-After; with one, the four waits
can add up to several hours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clean_object_term_cache() leaves them alone on WordPress 5.9, so a post
whose category a push changed mid-run could be reported at its old address.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Requests class has another name there, so the mock fell back to a plain
array and the Retry-After tests never saw their header on 5.9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@henry-mosh
henry-mosh merged commit 181cc40 into main Dec 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant