## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - People also ask agents for work in their existing chat tools. > - Each external conversation needs one task and a current authorized source. > - Retries, Stop, and provider failures must not duplicate work or expose private data. > - The first chat PR establishes the opt-in provider and data contracts. > - This PR adds experimental channel integration and its durable control plane. > - Users can request work from connected channels and inspect delivery in Paperclip. ## Linked Issues or Issue Description Refs #13100 and #13092. This is the second of exactly two chat PRs. Foundation #13100 is merged and changed 143 files. Runner prerequisite #13092 is also merged. This PR changes 400 files against master, below the 500-file review limit. It contains no wireframe images or HTML galleries. ## What Changed - Add native Slack, GitHub, Microsoft Teams, Telegram, and Discord chat connections. Keep chat disabled unless the operator enables experimental chat connectors. Preserve the production GitHub tool connection and its normal setup path. - Bind each provider bot identity to one immutable Paperclip agent. Bind each admitted external conversation to one task. Paperclip owns tasks, runs, permissions, and audit records. - Add durable admission, per-conversation queues, questions, task controls, progress, final replies, images, files, and delivery receipts. Board comments remain internal unless explicitly sent to the channel. - Check current identity, provider reach, resource access, credentials, runtime generation, and exact source before provider effects. Keep private responses private. Never send raw reasoning, private logs, credentials, or tool arguments. - Hold uncertain sends for explicit audited resolution. Make Board Send-to-channel atomic and idempotent. Keep reconnect and setup credentials in Paperclip secret storage. - Preserve current native-runner authority across retries, lost acknowledgements, and recovery. Keep immutable input and completion contracts separate from newer user input. Receipt reconciliation cannot launch a provider. - Reconcile chat close/new ordering and provider-effect lock order. Audit resource access changes in the same transaction. Submit only the selected resource from each UI toggle so stale pages cannot undo unrelated access changes. - Drain Codex stdout before certifying process exit. Bound the drain with the existing shutdown grace. Preserve observed terminal authority without treating an undrained process as successful or reusable. - Incorporate master `018ca5da` with its ACP Stop, mobile task layout, runner packaging, and official lock changes. Preserve dedicated chat-answer continuations in both directions when ordinary queued comments are adopted after Stop. - Fence late adapter readiness behind an earlier Stop for the same run. Preserve verified cleanup for registered adapters. Handle single Stop, agent pause, duplicate Stops, and failure release without creating a false cancellation receipt. - Incorporate master's `6dd48cad4` wake-queue extraction. Preserve exact failed-chat retry authorization and lineage, retired question-source suppression, and the block on generic recovery that would discard the admitted source. Fresh deferred input retains its separate promotion path. - Incorporate master `2a05b5ed3` and its queue-admission extraction, simplified transaction ports, and separate runner CI job. Preserve exact durable receipts, actor separation, and dedicated-answer isolation through the new module. A failed receipt insert rolls back the accompanying deferred-wake merge. ## Verification Current head: `afe19299d06253cb628eb398e91d1200ea9f412a`, incorporating master `2a05b5ed3457ea33efd6895520447d1d97fe98d8`. The conflicts are resolved. This successor fixes two test-harness boundaries exposed by CI: per-case route-module preparation and actual durable-save completion before intentional runner termination. Production code and all existing test/turn deadlines are unchanged. [Exact-head Greptile review](https://github.com/paperclipai/paperclip/pull/13038#issuecomment-5587250594) is **5/5**, completed September 10 at 13:20:55 UTC, with no actionable findings or open review threads. [Fresh exact-head CI](https://github.com/paperclipai/paperclip/actions/runs/34481724341) passes **all 24 jobs**, including Build and both required aggregates. Normal exact-head guarded merge was attempted and rejected by the remaining branch approval policy: CODEOWNER review is required and no human approval is present. Normal **squash auto-merge is enabled** as of September 10 at 13:36:26 UTC. Requested CODEOWNERS have been notified; no approval bypass or self-approval was used. Earlier-head results below remain historical evidence, not qualification of this successor. - Final exact-head Linux evidence: 995/995 chat integration cases; 36/36 agent-skills routes; 35/35 runner live-session cases, including real process kill/resume; 1948 runner Vitest cases with three existing benchmark/platform guards; 870/870 API-authority cases; and 104 browser cases with four existing optional skips. Rust, conformance/replay, full repository build, typecheck, canary, all server/workspace shards, and both required aggregates pass with normal CI concurrency. Earlier failed attempts remain recorded below. - Latest test-only qualification: 141/141 route/permissions/authentication cases pass in separate cold forks, with plain server types and independent review clear. The real-runner suite passes 35/35, with plain runner types and independent review clear. A controlled premature-save acknowledgement fails as expected; matching ownership/effect/process evidence, rejected saves, real turn outcome, test abort, and pre-kill liveness are covered. No local reproduction of the original CI scheduling failure is claimed. The preceding [CI run](https://github.com/paperclipai/paperclip/actions/runs/34479680858) passes 21/24 jobs, including all 995 Linux chat cases and browser aggregate (104 passed, four existing optional skips); only Build, the skills serialized shard, and the required verification aggregate fail. Its exact-head Greptile review was 5/5. Both failed job logs are retained. - Final fixture qualification: all eight focused Discord cases and all 995 chat integration cases pass. The exact modal statement/PID is observed before taking the real connection lock; the test then proves its actual blocking relationship before mutation. Original SQL execution, provider behavior, negative assertions, and 1s/15s timeouts remain unchanged. Independent review is clear and test/production hashes remain frozen. The preceding [CI attempt](https://github.com/paperclipai/paperclip/actions/runs/34477184777) passed 22 jobs, including Build/runner, typecheck, canary, all other test shards, and browser aggregate (104 passed, four existing optional skips); the two fixture failures and failed verification aggregate remain recorded, not relabeled as a pass. - Current queue-module composition: 308/308 recovery/batching/queue/Stop tests; 995/995 full chat integration; 89/89 module tests, including real PostgreSQL receipt-insert rollback; 24/24 workflow/module-boundary tests; plain server and UI types. All four actual local process/ACP browser paths pass in 1.4 minutes. Fresh databases, no skips or retries, stable reviewed source hashes. The initial boundary failure is retained; its no-op service wrapper was removed without changing recovery context or weakening the check. An exploratory standalone test-directory typecheck fails because its new upstream transformation config is not a standalone typechecking project; standard CI/build does not invoke it, and no configuration was weakened to suppress those diagnostics. - The preceding head `e02a63d462ce5d47433b0aeb632bb6fd20aab1ba` passed [all 24 CI jobs](https://github.com/paperclipai/paperclip/actions/runs/34436462958) and exact-head Greptile review at 5/5. Required CODEOWNER review prevented its normal merge before master advanced again. - Final extracted-module composition: 307/307 recovery, batching, queue and Stop-control tests; 995/995 full chat integration; 49/49 module tests including eight PostgreSQL adapter cases; and 19/19 issue-update tests. Plain server types pass. All four actual local process/ACP browser paths pass in 1.3 minutes. Fresh databases, no skips or retries in these cohorts, frozen source hashes, and independent review clear. - The preceding head `3e4e1c1c` passes [all PR CI jobs](https://github.com/paperclipai/paperclip/actions/runs/34415826820), including Build and required `ci / verify` and `ci / e2e`. Both the original Rust failure and the previously load-sensitive lineage fixture pass with unchanged Linux concurrency. Master advanced afterward and required this reconciliation. - Final master composition: 448/448 focused UI tests, 186/186 adapter tests, 24/24 queue/control tests, and 11/11 packaging tests. Plain UI, server, shared, and adapter types pass. Token gates and diff checks pass. Independent server and UI reviews are clear. - Stop-registration regression: both real-service cases fail against exact `a95` source and pass with the fix. The full corrected recovery/control suite passes 265/265. Duplicate-owner and failed-Stop controls also pass. Plain server types pass. The readiness barrier prevents provider startup without adding an acknowledgment to an already terminal run. - Final qualification strengthens terminal-field equality and repeats both affected cases successfully on a fresh database. All four actual local process/ACP browser paths pass again in 1.3 minutes, without skips or retries. The final screenshot shows Cancelled, a paused subtree, retained input, and no error toast. - Two new actual-service regressions fail before the merge fix. They prove that queued-comment adoption could consume a dedicated chat answer or add unrelated input to that answer. The fixed four-case cohort passes, including ordinary upstream continuation and adapter Stop controls. Full recovery passes 257/257. All four actual local process/ACP Stop browser flows pass in 1.4 minutes, without skips or retries, on a fresh database. - The unchanged runner artifact was qualified with 171/171 transport tests, 870/870 API-authority tests, conformance 1/1, and replay 11/11. Six controlled reader tests prove the exit/drain repair. Its local serial Rust workspace passed 546 top-level cases plus two invoked helpers; the later passing Linux CI supplies default-concurrency evidence. - Prior exact-source full chat integration passes 995/995. Settings regressions cover concurrent stale pages, 501 destinations, pending state, rejected updates, and explicit retry. These deterministic tests do not prove live provider behavior. - Retained failed attempts and their causes are in the [qualification log](https://github.com/paperclipai/paperclip/blob/afe19299d06253cb628eb398e91d1200ea9f412a/doc/plans/chat-adapters/2026-09-08-chat-queue-and-webhook-repair.md). The first merge adapter run timed out while macOS slept for 290 seconds. Its unchanged repeat passed with a temporary sleep guard. No assertion, deadline, or CI gate was weakened. Review commands include `pnpm --filter @paperclipai/server exec vitest run src/__tests__/heartbeat-process-recovery.test.ts src/__tests__/issue-queued-comments-routes.test.ts` and `pnpm exec playwright test --config tests/e2e/playwright.config.ts tests/e2e/acp-stop-continuation.spec.ts`. Database suites require fresh disposable databases. See the [browser runbook](https://github.com/paperclipai/paperclip/blob/afe19299d06253cb628eb398e91d1200ea9f412a/doc/plans/chat-adapters/2026-09-04-chat-adapters-browser-e2e-runbook.md) for provider setup and separate live acceptance steps. ## Risks - This remains experimental. Deterministic tests and bounded live evidence do not establish every provider feature, tenant, permission layout, or media shape. Teams work-tenant qualification is still open. - Failed and uncertain provider effects remain visible and can require operator action. A transport receipt does not prove recipient visibility. - Native controller and runner artifacts must remain compatible. Preserve lease ownership, terminal authority, source binding, and quarantine during future changes. - Access and audit rows commit together, but activity notifications remain best-effort. This is not a new durable event outbox. - The PR operation does not deploy a live server, replace its runner, or change provider permissions. Remaining live qualification is documented in the [temporary handoff](https://github.com/paperclipai/paperclip/blob/afe19299d06253cb628eb398e91d1200ea9f412a/doc/plans/chat-adapters/2026-09-08-open-qualification-followups.md). ## Model Used OpenAI Codex assisted with implementation, tool execution, testing, and review. The work records `gpt-6-astra` assistance. The environment does not report a context-window size. No private reasoning traces are included. ## 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 - [x] 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>
13 KiB
GitHub private attachment authority
This records the bounded implementation and qualification boundary, not a claim that arbitrary private GitHub files are downloadable by an installation App.
Supported authority
GitHub documents installation access tokens for the exact
issue-comment GET
with existing Issues or Pull requests read permission. Its
application/vnd.github.full+json representation includes both the original
body and rendered HTML. The corresponding
review-comment GET
requires Pull requests read and uses
application/vnd.github-commitcomment.full+json.
Those are legitimate fixed-repository comment reads. They do not document a general private-attachment download API. GitHub's attachment documentation distinguishes anonymous public uploads from repository-gated private uploads; its private attachment change explains why knowing the original private URL is insufficient.
Narrow implementation
- Only attachment references from an admitted, exact provider comment receive a version-2 locator with the original body SHA-256. Existing four-field locators remain anonymous-only; replay does not invent missing provenance.
- An anonymous 401/403/404 may trigger one exact-comment GET using the existing
installation App, fixed
api.github.com, no query, and no redirects. PAT, cookie, user-token, unbound-installation, and custom-host fallbacks are absent. - The authenticated response must match comment ID, repository, issue/PR,
review-root when applicable, and the original body hash. Exactly one anchor
must contain one image targeting the same asset UUID on
private-user-images.githubusercontent.com, with a sole JWT query absent from the original body. Its link must be either the original asset URL or exactly its image URL. Both forms share one candidate count; duplicate, mixed, or conflicting same-asset renderings fail closed. HTML parsing is inert and bounded. - The signed image target is ephemeral. Download requests never receive App credentials or cookies. Existing HTTPS/public-address pinning, redirect allowlisting, byte/MIME validation, 20-second file and 60-second download-batch budgets remain. The batch budget is not a hard total admission deadline.
- Current principal, runtime credential generation, destination, conversation, issue, and original input authority are checked before network access, after download, and under locks with attachment registration. Storage I/O is outside governance transactions; explicit revocation after storage removes the new, unregistered blob. No provider response HTML or signed query enters the delivery ledger, model context, or logs.
Remaining gap and truthful UX
The real private text fixture under /user-attachments/files/31948982/ remained
unavailable to anonymous intake; its provider browser anchor remained the
original file URL. The image-specific canonical mapping above does not invent
a signed generic-file endpoint. Such files remain a current-input
download_unavailable omission: no imported bytes, no claim of inspection, and
no substitution of an older task file. Activity currently shows that closed
omission rather than asserting that every 404 specifically means “private.”
Outbound is separate: the official GitHub CLI uploader allows OAuth, personal-access, and fine-grained personal-access tokens, not App installation tokens. Paperclip keeps the private-task output-file fallback and does not acquire extra repository permissions or impersonate the browser user.
Qualification gate
Contract tests prove the real SDK's installation-token exchange and fixed guarded comment GET, exact body/source binding, old-locator compatibility, restart reconstruction, credential-free bytes, malformed/ambiguous rendering denial, and revocation during download/storage. They are not live provider proof.
On the signed-in provider browser, upload a new private image to the existing authorized test issue/PR comment, ask Maya to inspect that exact image, and compare the stored hash/bytes with the fixture. Verify that no signed URL or HTML is persisted. Repeat with a private text file; unless GitHub actually provides a separately reviewed supported representation, it must still report unavailable without substituting another attachment. Then test a review-comment image and a changed/deleted source. Do not make the repository public to obtain a passing result.
Closed diagnostics for provider qualification
A first live private review-comment image was not imported; a signed anchor in
the browser is not evidence of the App REST response. The product now emits
only a closed attachmentDiagnosticCode beside the endpoint, issue, and
delivery IDs in the existing rejection log. Codes distinguish App authority or
request failure, exact source/body mismatch, missing rendering, unsupported
generic files, ambiguous/denied mapping, and a valid same-UUID signed-image
shape without the required original source anchor. In particular,
github_attachment_canonical_signed_anchor_only detected and denied an exact
signed anchor/image pair in the diagnostic-only deployment.
No response HTML, URL, JWT query, token, or provider error details enter these
diagnostics. SDK-wrapped errors retain only exact whitelisted codes with bounded
cause traversal; unknown errors collapse to a closed request-failed code.
Durable current-input omissions and agent prompts still use only
download_unavailable.
At 09:57:09 UTC on September 8, the actual App path emitted that signed-anchor diagnostic for the newly admitted private review-comment image. This proved the shape behind the unchanged source/body/repository/review-thread fences. The bounded follow-up accepts exactly one such pair, with identical link/image URLs and the same private-host/path/UUID/JWT checks. No additional host or credential authority was added. Contract and PostgreSQL restart tests cover both accepted forms, credential-free bytes, mixed/duplicate rejection, and unchanged current-access/revocation checks. Successful live byte intake and agent inspection were still unqualified at that diagnostic checkpoint.
Live main-conversation image and generic-file check
At 17:12:44.815 UTC, root used the signed-in GitHub browser to upload a
new image into the existing authorized test PR's main conversation. The
repository was visually confirmed Private and its visibility and App
permissions were not changed. PRIVATE-IMAGE-LANDING-0908 asked the agent to
inspect only that newly attached image, without suggesting its visual content.
The current-input attachment imported as PNG, 2,111,878 bytes, SHA-256
7693966f6c2b4aaebf9e46359f715fdaede021346bcd926078bb331b1dddc3c1.
An independent read-only audit rehashed the stored blob and verified the exact
comment/body/asset locator and wake-comment binding. The source-body hash
matches GitHub's CRLF normalization, not a rendered-page reconstruction.
The native gpt-5.6-luna run took 20.846 seconds and recorded two artifact
view events. The final response accurately described the orange tabby, pale
green eyes, and indoor background; root inspected the rendered reply and image.
The final arrived 26.303 seconds after submission. Working and final
operations each used one attempt and updated the same provider comment.
At 17:14:02.540 UTC, PRIVATE-FILE-LANDING-0908 uploaded a fresh synthetic
private text file. The prompt did not reveal its shape, color, or count.
The current-input action recorded exactly one download_unavailable omission,
zero imported or generated attachments, and no image-view event. Luna
truthfully reported that this exact new file was unavailable and did not
invent or reuse values. Its final arrived in 21.116 seconds.
Scoped delivery, action, wake, run, event, result, comment and publication
checks found no persisted signed URL/JWT query or provider-rendered HTML.
Original query-free author <img> syntax is not provider-rendered HTML.
This is a scoped persistence audit, not a whole-database or browser-log claim.
These checks used server 48 and qualify the private main-conversation image path and honest generic-file omission. Generic private files and native outbound uploads remain unsupported.
Live review-comment image after restart
On server 49, root replied to the existing authorized inline review thread,
uploaded the fixture again as a new provider asset, and submitted
PRIVATE-REVIEW-IMAGE-LANDING-0908 at 17:25:14.894 UTC. The final reply
arrived in that same review thread at 17:25:45.922 UTC, 31.028 seconds
later. The native Luna run used 23.822 seconds and correctly described
the cat, pale green eyes, pink chair and plant. The rendered response persisted
after a normal browser refresh; the task and conversation remained open.
Independent diagnostics verified the exact new review comment, original review root, current Paperclip comment, source-body digest, and new asset UUID. The stored attachment again rehashed to the 2,111,878-byte fixture SHA above. The supplied source matches the locator digest after GitHub CRLF normalization. There was one wake-associated run, no omission, two artifact-view events, and one attempt per working/final publication, both targeting the same provider review comment. Scoped persistence checks again found no signed-target/JWT or provider-rendered response HTML, and no internal identifier in the final text.
This extends live proof to new private images in both main conversations and review threads on the deployed authority implementation. It is not a changed/deleted-source test or an interrupted-download/revocation stress test.
Live changed-source rejection
Root uploaded a fresh private image in the authorized PR conversation and
submitted PRIVATE-SOURCE-CHANGE-0908 at 17:38:59.379 UTC. Paperclip was
deliberately offline after a zero-active-run shutdown, so the original created
delivery failed without entering the local delivery ledger. Root edited only
that synthetic source comment at 17:39:33.981 UTC, preserving its new image
URL and appending a revision marker. The edit delivery also failed while the
server was offline. Neither delivery had been admitted before restart.
After server 50 became ready, root used the existing App identity and GitHub's
supported App webhook redelivery API
to redeliver only the original created event, once. The new signed
delivery reached Paperclip and retained the original source digest
1ac24a2833edef198dd4d6dfa6155414f93dff5d6e01902f9ef65b6e7902244b.
The current canonical comment instead hashed to
6c47240d26bf98e6561479a9c01ac6c5e111766a46ba01182397aea4845c5514.
The unchanged new asset did not override this mismatch.
The closed diagnostic was github_attachment_canonical_body_mismatch, before
signed-target selection. The original ingress action was processed and its
retained body was redacted. No edited ingress action existed. The exact
current input had one download_unavailable omission, zero imported or
generated files, and no artifact-view event. One native Luna run took
14.881 seconds. Its final publication used one attempt and arrived
17.755 seconds after ingress: “The exact new image is unavailable because
it could not be imported.” Root verified that visible answer in the provider
conversation; the task remained open. The deliberate outage is not counted as
ordinary response latency.
An independent scoped audit of 52 run events and the associated delivery, action, source, wake, run, result and publication found no signed-target/JWT or provider-rendered-HTML markers, and no internal UUID in the final output. This proves rejection of a changed body for a real redelivered event. It does not prove deleted-source or in-flight download revocation behavior.
Separately, the bot-created reply callback received a 502 before reaching the instrumented local proxy or Paperclip. GitHub reported the exact configured destination, a 0.1-second duration, no response headers and an empty body. Adjacent original-redelivery and bot-edit callbacks used that same destination and received 202. The bot-edit was correctly filtered as outbound/self; the missing created callback was not. The pre-proxy transport cause is unconfirmed and must not be described as harmless self-event filtering or a repaired bug.