Files
PaperClipAI/server
DottaandClaude Fable 5.2 5d298b1b48 test(server): judge the Linux real-process boundary cases only by the processes they start (#21284)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - In `local_trusted` mode, the operator's local processes get implicit
board access. The local board boundary refuses that access to processes
of an agent run
> - #21209 added a Linux rule for a connection whose owner the server
cannot inspect. The server keeps board access only if every same-user
process it cannot inspect belongs to the operator
> - The real-process test "keeps board access for an operator process
the server cannot inspect" used that rule on the whole CI host. Other
processes of the same user on the host can be uninspectable and not the
operator's
> - Since #21209 merged, this test failed in about one in four `PR`
runs, on PRs that did not touch it. 22 failed server-test jobs between
2026-11-12 23:05Z and 2026-11-13 03:06Z
> - This pull request makes the real-process cases judge only the
processes that each case starts. It adds a case that pins the host-wide
rule with a known uninspectable agent-run process
> - The benefit is that the test is stable on shared CI hosts, and the
product rule stays tested

## Linked Issues or Issue Description

Refs #21209

**What happened?**
`server/src/__tests__/local-agent-process-boundary.test.ts` failed in
the "General tests (server)" lane of unrelated PRs. Both cases "keeps
board access for an operator process the server cannot inspect"
(127.0.0.1 and ::1) received `{ type: "none", source: "none" }`. They
expected `{ type: "board", source: "local_implicit" }`. The failures
started with the first runs that included #21209 (merged 22:52Z). They
continued until at least 03:06Z. Two runner image versions failed in the
same way.

**Expected behavior**
The test passes on a CI host that runs other processes.

**Actual behavior**
The boundary looks at every same-user process on the host that it cannot
inspect. When the owner of a connection is hidden, one uninspectable
process that is not clearly the operator's makes the boundary refuse.
Examples are a process of another agent run, a process whose parent is
PID 1, or a process that exits before the server reads its parent chain.
The test did not control which processes were on the host.

**Steps to reproduce**
On Linux, as a non-root user, run `python3 -c 'import ctypes,time;
ctypes.CDLL(None).prctl(4,0,0,0,0); time.sleep(60)' &`. Then make the
operator request from the test. The boundary refuses it.

## What Changed

- The Linux real-process cases use an inspector that wraps the real
Linux inspector. For a hidden owner, it keeps only the candidate
processes that descend from the process that the case started. All other
parts are the real Linux inspector: the TCP table reads, the fd scan,
the recheck, and the ancestry reads.
- Each Linux block starts an idle, uninspectable process with
`PAPERCLIP_RUN_ID`. This process stands for another agent run on the
host.
- A new case, "refuses board access to an operator process the server
cannot inspect while another agent run's process it cannot inspect is
running", uses the unwrapped inspector. It pins the host-wide rule in a
real-process test.
- If the test runner can inspect every process (for example, as root or
with `CAP_SYS_PTRACE`), the idle process is not uninspectable. The
host-wide case then skips. The other cases run as before.
- No product code changed.

## Verification

- Red, Linux (Docker `node:24-bookworm`, non-root user): a script runs
the product module
`server/src/middleware/local-agent-process-boundary.ts` from master with
the same operator request as the test. With no other process, the
operator gets board access 10/10. With one idle uninspectable agent-run
process, it gets 0/10. With one uninspectable process whose parent is
PID 1, it gets 0/10. With short-lived uninspectable processes, it gets
8/10. Agent-run requests are refused 5/5 in all cases.
- Red, CI Linux: in this PR's run, the new host-wide case passes. It
shows that the earlier assertion fails when one uninspectable agent-run
process is on the host.
- Green, CI Linux: in the same run, with that process on the host, both
"keeps board access for an operator process the server cannot inspect"
cases pass. Result: 27 tests passed in the shard that ran the file.
- macOS: `pnpm --dir server exec vitest run
src/__tests__/local-agent-process-boundary.test.ts` gives 15 passed, 12
skipped (Linux-only).
- Not verified: the specific process that was on the CI host in each
failed run. One fresh CI run with a temporary diagnostic found no other
uninspectable process. That run passed. The diagnostic is not in the
final commit.

## Risks

- Low risk. The change is test-only.
- Product note for a maintainer, not changed here: on Linux, an operator
process that the server cannot inspect loses implicit board access when
any other uninspectable same-user process on the machine is not clearly
the operator's. A process of another agent run is an example. This is
the rule from #21209, and the new case pins it. If this is too strict
for operators, that needs a product decision.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Anthropic Claude (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, Docker on Linux, GitHub CLI) and extended reasoning.

## 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
- [ ] I have updated relevant documentation to reflect my changes (not
applicable: test-only)
- [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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 22:48:46 -06:00
..