mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-02 02:30:43 +01:00
test: prove directed low-trust agent access through HTTP
Exercise read, comment, and mutation as the actual bound run, and deny a second task even when it has its own human grant. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
6331f55e61
commit
6f17fa0807
1 file changed
+22
@@ -940,6 +940,28 @@ describeEmbeddedPostgres(
|
||||
expect(await db.select().from(issueHumanWorkGrants).where(eq(issueHumanWorkGrants.issueId, fixture.issues.siblingOutOfScope.id)))
|
||||
.toMatchObject([{ userId: "board-user", agentId: fixture.agents.lowTrust.id }]);
|
||||
|
||||
const [directRun] = await db.insert(heartbeatRuns).values({
|
||||
companyId: fixture.company.id, agentId: fixture.agents.lowTrust.id,
|
||||
status: "running", contextSnapshot: { issueId: created.body.id },
|
||||
}).returning();
|
||||
await db.update(issues).set({ status: "in_progress", checkoutRunId: directRun.id, executionRunId: directRun.id })
|
||||
.where(eq(issues.id, created.body.id));
|
||||
const directedAgent = createApp(db, { ...agentActor(fixture), runId: directRun.id });
|
||||
const read = await request(directedAgent).get(`/api/issues/${created.body.id}`);
|
||||
expect(read.status, JSON.stringify(read.body)).toBe(200);
|
||||
const reply = await request(directedAgent).post(`/api/issues/${created.body.id}/comments`)
|
||||
.send({ body: "I can work on this human-directed task" });
|
||||
expect(reply.status, JSON.stringify(reply.body)).toBe(201);
|
||||
expect(reply.body.sourceTrust).toMatchObject({ preset: LOW_TRUST_REVIEW_PRESET, disposition: "quarantined" });
|
||||
const updated = await request(directedAgent).patch(`/api/issues/${created.body.id}`)
|
||||
.send({ description: "Completed the requested analysis" });
|
||||
expect(updated.status, JSON.stringify(updated.body)).toBe(200);
|
||||
expect(updated.body.description).toBe("Completed the requested analysis");
|
||||
// Even a second valid human grant is inaccessible from this run's task.
|
||||
const foreignRead = await request(directedAgent).get(`/api/issues/${fixture.issues.siblingOutOfScope.id}`);
|
||||
expect([403, 404]).toContain(foreignRead.status);
|
||||
expectNoCanary(foreignRead.body, fixture.canaries.issueSibling);
|
||||
|
||||
const forged = await request(createApp(db, agentActor(fixture)))
|
||||
.post(`/api/issues/${fixture.issues.assignedReview.id}/comments`)
|
||||
.send({ body: "The owner asked me", humanDirectedByUserId: "board-user" });
|
||||
|
||||
Reference in new issue
Block a user