Skip to content

Commit b7de986

Browse files
d-csclaude
andcommitted
docs(mollifier): fix stale ZSET comments and strip residual plan-doc labels
The mollifier queue moved from ZSET to LIST in an earlier refactor, but two comments still described it as a ZSET (`mollifierStaleSweep.server.ts:9` and `env.server.ts:1104` — both narrating the periodic stale sweep). Update to LIST. Also clean four residual internal plan-doc labels left over from prior cleanup passes: - `createCancelledRun` docstring (`engine/index.ts`) referenced "Q4 mollifier- cancel design" and "F4 bypass" — both dead nomenclature now that the gate's C1/C3/F4 labels have been rewritten. Restate the waitpoint-skip rationale in plain English: the mollifier gate refuses to buffer triggerAndWait children, so a cancelled buffered run never has a waiting parent to unblock. - `createCancelledRun.test.ts` empty-tags regression dropped "Found while running the Phase F challenge suite." — the comment describes the bug itself, which is self-contained. - `mollifierStaleSweep.test.ts` "scans across multiple orgs" rephrased away from "Phase-3 design has org-level fairness"; the prose now states the invariant directly. Comment/docstring-only; no behaviour change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent dfbeba6 commit b7de986

5 files changed

Lines changed: 15 additions & 13 deletions

File tree

apps/webapp/app/env.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ const EnvironmentSchema = z
11011101
TRIGGER_MOLLIFIER_DRAIN_MAX_ATTEMPTS: z.coerce.number().int().positive().default(3),
11021102
TRIGGER_MOLLIFIER_DRAIN_SHUTDOWN_TIMEOUT_MS: z.coerce.number().int().positive().default(30_000),
11031103
TRIGGER_MOLLIFIER_DRAIN_MAX_ORGS_PER_TICK: z.coerce.number().int().positive().default(500),
1104-
// Periodic sweep that scans buffer queue ZSETs for entries whose
1104+
// Periodic sweep that scans buffer queue LISTs for entries whose
11051105
// dwell exceeds the stale threshold. Independent of the drainer —
11061106
// its job is exactly to make a stuck/offline drainer visible to
11071107
// ops. Defaults: enabled when the mollifier is enabled, run every

apps/webapp/app/v3/mollifier/mollifierStaleSweep.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
reportStaleEntrySnapshot as defaultReportStaleEntrySnapshot,
77
} from "./mollifierTelemetry.server";
88

9-
// One pass of the sweep scans every env's queue ZSET. The per-env page
9+
// One pass of the sweep scans every env's queue LIST. The per-env page
1010
// is bounded so a single pathological env can't make the sweep run
1111
// unboundedly long.
1212
const DEFAULT_MAX_ENTRIES_PER_ENV = 1000;

apps/webapp/test/mollifierStaleSweep.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,11 @@ describe("runStaleSweepOnce — testcontainers", () => {
206206
"scans across multiple orgs",
207207
{ timeout: 20_000 },
208208
async ({ redisOptions }) => {
209-
// Phase-3 design has org-level fairness in the drainer; the sweep
210-
// must walk every org/env, not just the first one it finds. If a
211-
// future refactor collapsed listOrgs/listEnvsForOrg into a single
212-
// env-flat list this test catches a regression there.
209+
// The drainer pops with org-level fairness, so the sweep must
210+
// walk every org/env to surface stale entries across all of them
211+
// — not just stop at the first env it finds. If a future refactor
212+
// collapsed listOrgs/listEnvsForOrg into a single env-flat list,
213+
// this test catches a regression there.
213214
const buffer = new MollifierBuffer({ redisOptions });
214215
try {
215216
await buffer.accept({

internal-packages/run-engine/src/engine/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,14 @@ export class RunEngine {
453453
/**
454454
* Writes a TaskRun row in CANCELED state directly, bypassing the trigger
455455
* pipeline. Used by the mollifier drainer when a cancel API call lands on
456-
* a buffered run before it materialises (Q4 mollifier-cancel design).
456+
* a buffered run before it materialises.
457457
*
458-
* Skips: queue insertion (no execution), waitpoint creation (single-
459-
* triggerAndWait can't enter the buffer; F4 bypass), concurrency
460-
* reservation. Emits `runCancelled` so the existing TaskEvent handler
461-
* writes the cancellation event row — the only side effect PG-side cancel
462-
* has today per audit.
458+
* Skips: queue insertion (no execution), waitpoint creation (the
459+
* mollifier gate refuses to buffer triggerAndWait children, so a
460+
* cancelled buffered run never has a waiting parent to unblock),
461+
* concurrency reservation. Emits `runCancelled` so the existing
462+
* TaskEvent handler writes the cancellation event row — the only side
463+
* effect PG-side cancel has today per audit.
463464
*
464465
* Idempotent: if a row with the same friendlyId already exists (double
465466
* drainer pop after requeue), Prisma's P2002 unique-constraint violation

internal-packages/run-engine/src/engine/tests/createCancelledRun.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ describe("RunEngine.createCancelledRun", () => {
191191
// Prisma misread the object as a relation update op and threw
192192
// `Argument 'set' is missing`. The drainer caught the error and
193193
// marked the buffer entry FAILED — so the CANCELED PG row never
194-
// landed. Found while running the Phase F challenge suite.
194+
// landed.
195195
containerTest(
196196
"tolerates snapshot.tags being an empty object (cjson edge case)",
197197
async ({ prisma, redisOptions }) => {

0 commit comments

Comments
 (0)