Skip to content

Keep a message sent right after an invite join from being lost - #449

Merged
Birfy merged 1 commit into
ThinkFlowLab:mainfrom
Birfy:fix/442-invite-grant-before-join
Oct 19, 2026
Merged

Birfy merged 1 commit into
ThinkFlowLab:mainfrom
Birfy:fix/442-invite-grant-before-join

Conversation

@Birfy

@Birfy Birfy commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #442

Server half: Birfy/bot-social#31 (Fixes Birfy/bot-social#30; owner decision option b: write the grant first, then confirm the join). Not deployed; production deploy needs the owner's yes. This PR works against the current production server too (see Compatibility).

What was wrong

Right after an invite join, the inviter's home had not yet synced the new friend's grant (syncOutgoingGrants ran only on a roster fetch). The friend's first message hit the core owner policy (reach(), by: 'owner-policy'), was refused, logged and dropped, and the sender saw nothing.

Fix (plugins/social only; no core change)

  • Join event records the grant. pollOnce now reads relationship.changed (status: "active") and grant.changed (status: "granted") in a Bot's queue and runs syncOutgoingGrants({ only }) for that Bot before the next event. Bot Social ci: slim Test matrix to ubuntu Node 24 + DSH 0.2.0-rc.2 #31 commits the join's grants before announcing it and always queues that event before the friend's first message, so the message is judged with the grant.
  • One sync-and-retry on a refusal. If an inbound message is still refused by the owner policy (a server without ci: slim Test matrix to ubuntu Node 24 + DSH 0.2.0-rc.2 #31, a lost event), the plugin syncs that Bot's grants once and judges the message again. Delivered at most once.
  • The sender is told. Still refused: the plugin calls report_not_delivered { message_id, reason: "not_shared_yet" }. On the sender's home, the message.not_delivered event writes "Not sent: Coder (Bob) was not ready to talk with you yet, so it did not get your message. Send it again." into the owner's chat with that Bot, in the same place a failed send shows its Not sent line.

Decisions (minor, made here)

  • The plugin syncs that Bot's grants through the existing list_bot_grants path and does not build grant records from the event's grants field. That keeps one mapping (talk-through classification, canonical handles). The event only triggers the sync.
  • One retry only, with no timer or held queue (simplicity). A message that is still refused is reported, not held.
  • The Not sent line goes only into the owner's own friend chat (settings.via). When a Bot sent the message with message_friend_bot, the plugin only logs it and does not wake the Bot.
  • Grants stay per Bot. Nothing is published, granted or approved on this path. There is no typed-reply approval and no turn limit.

Compatibility

Tests

Four new tests in plugins/social/test/social.test.js (#442: …):

  • The join event alone syncs the grant. The next "Hi" is then delivered with no refusal, no second sync and no report. Join and message in the same poll also work.
  • With no join event (older server), a refused first message triggers one sync and is delivered once.
  • A sender with no grant at all: nothing is delivered and report_not_delivered is called once per message. An older server that lacks the tool only logs it.
  • message.not_delivered writes the Not sent line once into the owner's chat with that Bot, never shown as the friend typing it. No chat line when no owner chat goes through that Bot.

Verify at tip b7e0b27: ARCH_DOCS_BASE=upstream/main TZ=UTC npm run verify: pass (core 1011, social 273, tree 56, timeline 80, scripts 88, interop 37, live-e2e 16; lint, plugin lint, client bundle check and ds-bot patches check green). I did not run the smoke test (no core/ or src/host/ change), a live two-home test or a test against production Bot Social.

Docs: docs/subsystems/social.md item 11. Changelog: changelog.d/442-message-after-invite-join.fixed.md.

Risk tier: T3 (risk-gate report at b7e0b27: path plugins/social/src/social.js)

…FlowLab#442)

A friend typed Hi seconds after joining an invite; this home had not
synced the new grant yet, so the owner policy refused it and the sender
saw nothing.

- Read Bot Social's relationship.changed (active) / grant.changed
  (granted) and sync that Bot's grants before the next event in its
  queue: Bot Social #30 queues the join, with its grants written, before
  the first message.
- On an owner-policy refusal of an inbound message, sync that Bot's
  grants once and judge it again (servers without #30, a lost event).
- Still refused: call report_not_delivered so the sender is told; on the
  sender's home a message.not_delivered event writes a Not sent line
  into the owner's chat with that Bot.
@Birfy Birfy added the agent-pr Pull request opened by an agent label Oct 19, 2026
@Birfy Birfy self-assigned this Oct 19, 2026
@Birfy Birfy added bug Something isn't working area:social Friends, invites, grants, Bot Social labels Oct 19, 2026
@Birfy

Birfy commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

Self-review (Bot) — verdict: PASS

Tip SHA: b7e0b27
Ran: read the full diff at this head against the owner's design rules; CI at this head is green (package, plugins social/timeline/tree, Node 24 · DSH, tests-ok); the author's local ARCH_DOCS_BASE=upstream/main TZ=UTC npm run verify passed at this head.
Not run: smoke bench, DSH Desktop, real-model run, live two-home test.

Notes: grants are synced on relationship.changed/grant.changed before the next queued message, plus one sync-and-retry on an owner-policy deny; no grant is built from event payloads; approvals untouched; English UI. Minor: the "Not sent" notice is also sent for a sender with no grant at all (not only a just-joined one); the wording "was not ready to talk with you yet" is acceptable there. The sender notice needs Birfy/bot-social#31 deployed; without it the call is only logged.

Risk tier: T3 (per the risk tier check), so this needs the maintainer's approval on GitHub. Any new commit voids this PASS.

@Birfy Birfy added the awaiting-approval PR is green and waits for the maintainer's approval (T2/T3) or a review PASS at its tip label Oct 19, 2026
@Birfy
Birfy added this pull request to the merge queue Oct 19, 2026
Merged via the queue into ThinkFlowLab:main with commit 58f7a52 Oct 19, 2026
8 checks passed
@Birfy
Birfy deleted the fix/442-invite-grant-before-join branch October 19, 2026 13:29
@Birfy Birfy removed awaiting-approval PR is green and waits for the maintainer's approval (T2/T3) or a review PASS at its tip agent-pr Pull request opened by an agent labels Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:social Friends, invites, grants, Bot Social bug Something isn't working

Projects

None yet

1 participant