Files
PaperClipAI/server
DottaandPaperclip e43af9770a refactor(server): isolate publication recovery and Board sends (#16192)
## Thinking Path

> - Paperclip publishes task messages through several chat providers.
> - Operator recovery must keep durable receipts and task authority
consistent.
> - The service combines shared publication transactions with provider
recovery details.
> - Provider-specific recovery belongs beside its transport
implementation.
> - This pull request extracts publication requests and resolution
workflows.
> - Shared workflows keep transaction ownership and delegate provider
operations.

## Linked Issues or Issue Description

Depends on #16187. Refs #16185, #16183, and #16180. Review against the
parent branch.

**What existing behavior does this improve?**
The structure of publication requests, Board sends, and operator
recovery.

**Current behavior**
Six public publication methods live in the main service and include
provider-specific transfer and receipt operations.

**Proposed behavior**
Move shared requests and resolution to publications modules. Move Teams
file resolution and Board preparation, Slack file receipts and Board
staging, and Photon retry records to their provider folders.

**Reason and benefit**
Provider recovery is easier to locate without moving transaction and
idempotency ownership into providers.

## What Changed

- Extract six public publication methods into two shared workflow
factories (629 and 467 lines).
- Reduce chat-channels.ts from 5,337 to 4,078 lines. The full stack
reduces it from 7,919 lines.
- Extract Teams transfer resolution and cold-runtime Board preparation.
- Extract Slack upload receipt resolution and Board send staging.
- Extract Photon operator retry records.
- Preserve the same public service API and keep provider operations in
the original transactions.

## Verification

- Merge preparation: replayed this stack onto current master after
#16180 landed. Preserve master's new Telegram scheduling methods and
connection-scoped Photon notifications. Server typecheck, callback
syntax audit, and module-boundary check passed. Fresh local integration
and wiring checks passed (1,318 tests). The dedicated Photon suite
passed 18 before and 18 after the conflict resolution. This final slice
was replayed onto merged #16187 with all chat-channel source unchanged.
Current-head CI and review are running. Earlier verification below
describes previous stack commits.

- Publication, attachment, Board send, and operator recovery baseline:
261 passed before and 261 passed after; 1,034 other cases excluded.
- Server typecheck, module-boundary check, and git diff --check passed.
- Syntax audit reconstructs all six public method bodies from the
provider helpers and matches the original AST. Unrelated service
functions and the public API match too.
- Final repository typecheck passed. Build passed. The broad local test
run encountered heartbeat fixture setup failures under the macOS
PostgreSQL shared-memory limit and was interrupted after 868 seconds
(exit 130). Four confirmed abandoned guard slots were reclaimed without
stopping active databases. The complete chat integration suite and
source-wiring checks passed separately (1,309 tests).
- Greptile rates current head 55417debfe 5/5 with zero inline findings.
All 55 CI checks pass on that head. Tests use local PostgreSQL and
fixture transports, not live provider execution.

- Previous stack validation on #16192 (55417debfe): repository typecheck
and build passed; all 1,295 chat integration cases plus 14 source-wiring
checks passed locally (1,309 total). All five PRs have current-head 5/5
reviews and 55 passing CI checks. The broad local pnpm test:run hit
PostgreSQL shared-memory fixture failures and was interrupted after 868
seconds (exit 130); it is not a local full-suite pass.

## Risks

Operator recovery can duplicate a send if receipt updates move out of
their transaction. The extracted helpers use the caller transaction.
Teams preparation remains outside Board locks, and repeated send
identities retain their existing receipt. Public method names and return
values stay the same.

## Model Used

OpenAI GPT-6 via Codex, with code execution and repository tools. The
precise serving variant and context-window size are not exposed in this
session.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-10-13 11:48:07 -05:00
..