Skip to content

officers: an officer asks its bound plugin to read a post back (officer_post_readback) - #1236

Draft
ZacxDev wants to merge 3 commits into
mainfrom
officer-post-readback
Draft

ZacxDev wants to merge 3 commits into
mainfrom
officer-post-readback

Conversation

@ZacxDev

@ZacxDev ZacxDev commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Why

A builtin marketing officer had no way to settle "did the post for draft N go out, and on which account is the plugin's session?" by itself: it escalated those questions to its owner, who then had to check by hand. The plugin that posts already reads posts back after posting; this gives the officer a read-only way to ask it.

What

  • Tool officer_post_readback{plugin, venue, draft_id | post_ref | text, parent_ref?, account?, project?} — offered with officer_post_draft (builtin officer, type grants outbound_drafts). Files a read-back for the plugin bound to the officer. Sends nothing. At most 20/day and 5 unanswered per officer.
  • Plugin routes (capability messages):
    • POST /plugin/v1/readbacks/claim {"limit":1-5} → 200 {"readbacks":[{readback_id, venue, account, project, post_ref, text, parent_ref, draft:{draft_id, body, target_kind, target_ref, external_ref, status}|null, attempts, lease_until}]}; leased 15 min, re-handed out after a lapse.
    • POST /plugin/v1/readbacks/{id}/answer {status: found|absent|unknown, post_ref?, url?, account_seen?, detail} → 200 {readback_id, status, item_id}; first answer wins; 404 not this plugin's; 400 bad field; 409 officer gone.
  • Delivery: the answer becomes ONE plugin.readback item in the officer's queue (subject readback:<id>), same transaction, with the request as filed and account_matches when both accounts are known.
  • Never silent: a read-back handed out 3 times with no answer, or unanswered for 6 h, is answered unknown by muster (answered_by: "muster").
  • Migration 0210 plugin_readbacks (owned, forced RLS, personal share class; rls_off/RLSOn wired; every DB ledger test updated). 🔴 Renumber at merge if main moved (another officer PR may also add a migration).
  • Docs: docs/plugins.md "Read-backs: is a post live?".

Authz

Only the owner's officer and the owner's plugin bound to that officer: the tool refuses another owner's plugin, an unbound plugin and one bound to another officer; draft_id must be the officer's own draft on that plugin; claim/answer touch only the presenting plugin's rows (and RLS besides). The isolation walk now seeds a read-back of A's and checks B's plugin cannot tell it from a ghost.

Alternatives rejected

  • Answer through POST /plugin/v1/messages as a note: no new answer route, but the answer would be unstructured fenced text and not bound to the request (any message could claim to answer it).
  • A new draft target kind (readback): reuses the claim channel but drags in approval, expiry and at-most-once semantics meant for posting — exactly what a read must never touch.

Tests (red/green)

New internal/api/plugin_readbacks_pg_test.go (4 tests). Red at origin/main: does not compile (officers.ToolPostReadback and the routes do not exist). Green at HEAD: 4/4 against a local Postgres. Mutation matrix (each restored after, positive control re-run green):

mutant killed by
tool ignores the outbound_drafts grant TestReadbacksAreTheOwnersOfficerAndPluginOnly
filing ignores which officer the plugin is bound to TestReadbacksAreTheOwnersOfficerAndPluginOnly (plugin bound elsewhere)
claim not scoped to the plugin TestReadbacksAreTheOwnersOfficerAndPluginOnly
answer not scoped to the plugin TestReadbacksAreTheOwnersOfficerAndPluginOnly (RLS still holds across owners: the isolation walk stays green, as it should)
draft_id not scoped to the officer TestAReadbackNamingADraftCarriesItsTextAndSendsNothing
answer enqueues no item 3 tests
no give-up sweep TestAReadbackThePluginNeverAnswersIsAnsweredUnknown

Also run locally (scoped -run): route golden, plugin capability/door/server/team ledgers, isolation + principal walks, step-up and team-host tool ledgers, officer tool listings, and the internal/db migration/RLS/share ledgers. make leakscan clean.

🤖 Generated with Claude Code

ZacxDev and others added 3 commits December 4, 2026 08:32
…er_post_readback)

A builtin officer that files outbound drafts had no way to learn, on its own,
whether a post it asked for is live upstream, or which account its plugin's
venue session is signed in to: it escalated those questions to its owner.

officer_post_readback{plugin, venue, draft_id | post_ref | text, parent_ref?,
account?, project?} files a read-back for the plugin bound to the officer. The
plugin collects it (POST /plugin/v1/readbacks/claim, leased 15 minutes) and
answers found / absent / unknown with the post's ref and URL and the account it
saw (POST /plugin/v1/readbacks/{id}/answer). The answer becomes ONE
plugin.readback item in the officer's queue, in the answer's transaction, with
account_matches when both accounts are known. A read-back the plugin never
answers (3 hand-outs, or 6 hours) is answered unknown by muster itself.

A read-back sends nothing: it files, approves, retries and re-files no draft.
Only the owner's officer (outbound_drafts grant, as officer_post_draft) and the
owner's plugin bound to THAT officer; a draft_id must be the officer's own on
that plugin; the plugin routes see only the presenting plugin's rows, under the
owner's row-level security besides.

Migration 0210 adds plugin_readbacks (owned, forced RLS, personal share class;
renumber at merge if main moved).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…and pre-allow ledgers

CI found three ledgers the first commit missed: the read-back routes are
bearer-only plugin routes (csrf_ledger.golden), AnswerReadback reads the
plugin's owner and is never reached by a server app (owner-read sites), and
a builtin officer's session pre-allows officer_post_readback beside
officer_post_draft.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
plugin_readbacks references plugins, so the fixture's TRUNCATE of plugins
must name it too (CI shard 0: cannot truncate a table referenced in a
foreign key constraint).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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