## Thinking Path
> - Paperclip manages work and authority for AI agents.
> - Grok Bot runs outside Paperclip and uses authenticated upload grants
for files.
> - Native completion requires a verified file publication receipt.
> - The upload saved the file but did not create that receipt. Real Grok
work could not finish.
> - A failed run also left an assignment that the Stop action could not
fence.
> - This pull request connects verified uploads to normal completion and
repairs that recovery action.
> - The result preserves file integrity and current work-session
authority.
## Linked Issues or Issue Description
Refs: #16219, #16274.
**What happened?**
A real Grok Bot saved a task document and CSV. Semantic completion
rejected the CSV because its upload had no verified publication receipt.
After the managed run failed, Stop rejected its remaining assignment as
a changed session. The driver also discarded the remote monitor's known
failure reason.
**Expected behavior**
An authenticated upload of the exact requested bytes can satisfy normal
completion. Stop can fence the remaining assignment of the selected
failed run. An old Stop action cannot stop newer work. Known remote
lease and reconnect errors remain visible without raw diagnostics or
credentials.
**Steps to reproduce**
1. Connect an experimental Grok Bot agent and verify its routine.
2. Assign a task that requires a document and a file.
3. Upload the file through its accepted assignment and cite the
attachment in semantic completion.
4. Observe the missing publication receipt error on the previous
implementation.
5. For recovery, select Stop after that run fails but its assignment
remains active.
**Paperclip version or commit**
The live defects were observed after #16274. The current candidate
merges master `739f9e40a4` and is
`26c5b9601d1cb2b8f5bb7fcf730f019523763f5b`.
## What Changed
- Record a server-owned publication receipt in the verified upload
transaction. Bind it to the real native Grok run and exact stored file
metadata.
- Validate external publication against the actual upload and admitted
assignment. Keep existing native and person upload rules.
- Recover the committed receipt after a lost response. Reverify the same
bytes when an older upload lacks proof.
- Hold assignment authority through publication with
grant-before-assignment and task-before-run lock order. Disconnect does
not wait for remote file storage.
- Allow Stop to fence the exact lingering assignment of a terminal run.
Reject stale Stop calls for successor work.
- Preserve only known lease/reconnect failure codes from the remote
monitor. Do not expose raw stderr.
- Extend real Rust, overlapping document/upload and disconnect/upload,
file retry, completion and Stop regressions. Document setup, files and
recovery.
## Verification
- The real Rust Grok regression requests a file, checks an overlapping
native document save, concurrent retries and lost-response recovery,
rejects missing delivery evidence, then uses normal semantic completion
and finalization.
- Focused tests cover person MCP, native file handoff, completion, Stop
and both external driver providers.
- Local repository typecheck and production build pass on the current
candidate. The five focused protocol suites pass (264 tests); all 17
external Runner driver tests pass, with the driver unchanged since the
master merge.
- Token gates and Storybook build pass. Nine existing Grok fixture
journeys pass their browser interaction assertions; the static probe
separately records five fixture API routes returning 404. This is UI
fixture evidence only.
- Full repository coverage passed in CI. The duplicate local `pnpm
test:run` was interrupted after CI completed; its partial log is
retained and is not reported as a local full-suite pass. The earlier
aggregate invocation was interrupted for the second review fix.
- All CI gates pass on `26c5b9601d1cb2b8f5bb7fcf730f019523763f5b`: 55
successful checks and two skipped Storybook jobs (no UI diff). This
includes the complete sharded repository suites, native Runner, release
checks, build and security scans.
- Current-head Greptile is 5/5 with zero unresolved findings. The PR has
no merge conflicts.
- The prior live attempt is failed acceptance evidence. Real Grok
requalification, proactive work, controller restart and active-session
Stop remain release gates. This PR does not claim those passed.
## Risks
- Upload and completion now share a durable run receipt. Lock order and
current assignment authority must remain consistent with native
mutations.
- Publication fails closed if the file, run or grant changes. A retry
must keep the same upload identity and bytes.
- Person connections gain no agent authority. No database migration is
required.
- Known exit diagnostics do not prove global Grok termination. Grok
spending remains unreported.
## Model Used
OpenAI GPT-6 through Codex, with reasoning, repository tools, code
execution and computer use. The exact deployment model ID 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
- [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>
Server tests that need a real PostgreSQL process must use
./helpers/embedded-postgres.ts instead of constructing embedded-postgres
directly.
The shared helper creates a throwaway data directory and a reserved-safe
loopback port for each test database. This protects the live Paperclip
control-plane Postgres from server vitest runs; see PAP-2033 for the incident
that introduced this guard.