mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 11:47:42 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Paperclip Runner protocol suite verifies ACPX sidecar provider-started turns using `packages/paperclip-runner/src/cli/acpx-runtime-sidecar.provider-turn.test.ts` and the test host `packages/paperclip-runner/src/test-support/acpx-provider-turn-host.mjs` > - `acpx-provider-turn-host.mjs` updated `observed.json` in place with `writeFileSync()`, which truncates the file to zero bytes before writing the JSON bytes > - When the parent test polls `observed()` concurrently during a write, `JSON.parse(readFileSync(...))` can observe the truncated empty file and throw `SyntaxError: Unexpected end of JSON input`, failing `Verify Paperclip Runner (protocol (1/4))` on `master` (for example, Cloud readiness run 46754145328) > - This pull request writes `observed.json` to a unique sibling temporary file and atomically replaces `observed.json` with `renameSync()` > - The benefit is atomic handoff between the sidecar test host and the polling test, eliminating this intermittent `master` CI failure ## Linked Issues or Issue Description **What happened?** `verify / Verify Paperclip Runner (protocol (1/4))` intermittently failed `ACPX sidecar provider-started Claude turns > leaves non-Claude agents without a provider-turn listener` on `master` (Cloud readiness run 46754145328) with `SyntaxError: Unexpected end of JSON input` at `src/cli/acpx-runtime-sidecar.provider-turn.test.ts:64`. **Expected behavior** Polling `observed.json` from the test process should always read a complete JSON document and never observe a truncated in-progress write. **Steps to reproduce** 1. Run `packages/paperclip-runner/src/cli/acpx-runtime-sidecar.provider-turn.test.ts`. 2. The child sidecar host calls `note()` in `packages/paperclip-runner/src/test-support/acpx-provider-turn-host.mjs`, which truncates and rewrites `observed.json` in place with `writeFileSync()`. 3. If the parent test reads `observed.json` during truncation, `JSON.parse()` throws `SyntaxError: Unexpected end of JSON input`. **Paperclip version or commit** `16614f4fdae31dbdd991cc41b879b4489561047a` / `3df59a1853752dea020524815737afec39882be2` **Deployment mode** Other (CI test suite) ## What Changed - Update `note()` in `packages/paperclip-runner/src/test-support/acpx-provider-turn-host.mjs` to write JSON to a unique sibling temp file and atomically replace `observed.json` via `renameSync()`. ## Verification - `pnpm --filter @paperclipai/paperclip-runner exec vitest run src/cli/acpx-runtime-sidecar.provider-turn.test.ts` — 14/14 passed. ## Risks - Low risk. Test-helper-only change scoped to `acpx-provider-turn-host.mjs`. ## Model Used - Google DeepMind Antigravity using Gemini 4 Neon (Medium) with reasoning, tool use, and local command execution. ## 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 - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge