Skip to content

Commit fec33f9

Browse files
sametbasbugclaude
andcommitted
Let a suspension reach the page before the cache expires
The public directory is cached at the edge for five minutes and the agent profile JSON for thirty seconds. Suspension changed neither, so a moderator could stop an agent and then watch the site keep presenting it as active for the rest of that window. The write path closed immediately, which is the part that protects anyone; but what the site showed was false, and a moderator refreshing to confirm their own decision would have seen it not take effect. Both directions now invalidate the public cache epoch, alongside the record deletions and moderation reversals that already did. A test takes the directory to a cache HIT, suspends an agent, and requires the next read to miss and to carry the new status. Removing the rule makes it fail. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 8bb4d65 commit fec33f9

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎scripts/orbit-slice4-tests.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,26 @@ describe('Orbit V6 Slice 4 publication and backup core', { concurrency: false },
13131313
assert.equal((await undone.json() as { error: { code: string } }).error.code, 'agent_not_suspended');
13141314
});
13151315

1316+
test('suspending an agent drops the cached public view of it', async () => {
1317+
const url = `${baseUrl}/v1/agents?limit=50`;
1318+
assert.equal((await fetch(url)).headers.get('x-orbit-cache'), 'MISS');
1319+
assert.equal((await fetch(url)).headers.get('x-orbit-cache'), 'HIT');
1320+
assert.equal((await moderatorRequest('/v1/manage/agents/slice4-hourly/suspend', 'POST', {
1321+
reason: 'Önbellek tazeliği için askı.',
1322+
})).status, 200);
1323+
/* Dizin beş dakika önbellekleniyor. Bu satır olmasaydı moderatör ajanı
1324+
* durdurduktan sonra site onu dakikalarca aktif göstermeye devam
1325+
* ederdi — yazma yolu kapalı olsa bile gösterilen şey yanlış olurdu. */
1326+
assert.equal((await fetch(url)).headers.get('x-orbit-cache'), 'MISS');
1327+
const listed = (await fetch(url).then((response) => response.json()) as {
1328+
agents: Array<{ handle: string; status: string }>;
1329+
}).agents.find((agent) => agent.handle === 'slice4-hourly');
1330+
assert.equal(listed?.status, 'suspended');
1331+
assert.equal((await moderatorRequest('/v1/manage/agents/slice4-hourly/reinstate', 'POST', {
1332+
reason: 'Geri alındı.',
1333+
})).status, 200);
1334+
});
1335+
13161336
test('a retired agent is out of moderation reach in both directions', async () => {
13171337
for (const action of ['suspend', 'reinstate'] as const) {
13181338
const response = await moderatorRequest(`/v1/manage/agents/slice4-retired/${action}`, 'POST', {

‎src/server/cache/public-cache.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ export function mutationInvalidatesPublicCache(request: Request, response: Respo
5151
|| /^\/v1\/records\/[^/]+\/withdraw$/u.test(path)
5252
|| /^\/v1\/approvals\/[^/]+\/(?:approve|reject)$/u.test(path)
5353
|| /^\/v1\/manage\/records\/[^/]+\/delete$/u.test(path)
54+
// Askı, ajanın public yüzeydeki görünümünü değiştiriyor: dizin kartında
55+
// durumu, profilinde uyarısı. Dizin beş dakika önbellekleniyor, yani
56+
// buraya yazılmazsa moderatör ajanı durdurduktan sonra site onu
57+
// dakikalarca hiçbir şey olmamış gibi göstermeye devam eder. Yazma
58+
// yolu anında kapanıyor, ama gösterilen şeyin de doğru olması gerek.
59+
|| /^\/v1\/manage\/agents\/[^/]+\/(?:suspend|reinstate)$/u.test(path)
5460
|| /^\/v1\/admin\/moderation\/[^/]+\/reverse$/u.test(path)
5561
|| path === '/v1/agents'
5662
|| path === '/v1/agent/profile'

0 commit comments

Comments
 (0)