Skip to content

Commit 3e31c26

Browse files
Elon Muskclaude
andauthored
test(runtime): both swallow-family members in runtime are OUT — pin the delivery, record the census false positive (#13451)
* test(runtime): pin that a refused API-key insert is delivered, not swallowed The swallow-family census reports `domains/keys.ts` as tier-1 DARK on three mechanical conjuncts and deliberately leaves the fourth -- "and the caller still reports success" -- to a person. The answer at this site is no: every path out of the catch hands the caller a 500 envelope and returns no key material, which is AGENTS.md's third legal answer and puts the site OUT of the repair programme rather than in it. That ruling had nothing holding it up. Pin the delivery instead: the error envelope (500 / INTERNAL_ERROR), the absence of any key material, and the non-echo of the driver error the catch discards on purpose. Record the ruling at the site, including why the FAILURE_PROPAGATION_SITES declaration belongs to the programme's last step rather than to this one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012WkdHQwHr2KQmaX7P1BHzi * test(runtime): type the objectql slot lookup by inference, not `any` check:slot-lookup flagged the new helper's `const ql: any = kernel.getService(...)` as a NEW service-lookup erasure (#4251). The annotation bought nothing — the fake kernel is already untyped — so the inferred form satisfies the ratchet and the population returns to its baseline 107 with none new. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012WkdHQwHr2KQmaX7P1BHzi --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 71627f7 commit 3e31c26

2 files changed

Lines changed: 92 additions & 0 deletions

File tree

packages/runtime/src/domains/keys.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,34 @@ export async function handleKeysRequest(
190190
inserted = await ql.insert('sys_api_key', row, { context: { isSystem: true } });
191191
} catch {
192192
// Never surface the underlying error (could echo row contents).
193+
//
194+
// [#12981] This catch is silent BY DESIGN and it is NOT a durability
195+
// swallow. `scripts/measure-durability-swallow-family.mjs` reports this
196+
// site as tier-1 DARK because membership is decided on three mechanical
197+
// conjuncts -- silent catch, no rethrow, an awaited write in the `try`
198+
// -- and the census deliberately leaves the fourth, "and the caller
199+
// still reports success", to a person. Here the answer is NO: every
200+
// path out of this catch hands the failure to the caller as a 500
201+
// envelope and no key material is returned, so nothing claims to have
202+
// persisted and the request does not look normal from the outside.
203+
//
204+
// AGENTS.md "Degradation log levels" names that the third legal answer
205+
// and forbids bolting a `logger.error` onto it: this branch's common
206+
// case is a rejected request, and one durability `error` per rejected
207+
// request is the mirror-image failure that made the founding incident's
208+
// `warn` unreadable in the first place.
209+
//
210+
// Do NOT "repair" this site by adding a log. The correct declaration is
211+
// an entry in check-durability-degradation-log-level.mjs's
212+
// FAILURE_PROPAGATION_SITES, keyed `keys.ts::handleKeysRequest`, and it
213+
// belongs to the LAST step of the #12981 programme -- the one that
214+
// widens DURABILITY_CRITICAL_CALLEES. Declared before that step it would
215+
// go red as a STALE entry, because that vocabulary has no `insert` and
216+
// so matches no seam in this function today.
217+
//
218+
// The delivery this ruling rests on is pinned in
219+
// `http-dispatcher.keys.test.ts`; if you change what this catch
220+
// returns, that pin is what will stop you.
193221
return { handled: true, response: deps.error('Failed to create API key', 500) };
194222
}
195223
const id = inserted?.id ?? (Array.isArray(inserted) ? inserted[0]?.id : undefined);

packages/runtime/src/http-dispatcher.keys.test.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,67 @@ describe('HttpDispatcher.handleKeys — organization inheritance (#8287)', () =>
330330
expect(res.body.data.active_organization_id).toBeUndefined();
331331
});
332332
});
333+
334+
/**
335+
* [#12981] The mint path's `ql.insert` catch is SILENT, and that is the correct
336+
* shape -- every path out of it hands the failure to the caller. The swallow-
337+
* family census (`scripts/measure-durability-swallow-family.mjs`) reports the
338+
* site as tier-1 DARK because it decides membership on three mechanical
339+
* conjuncts and leaves "and the caller still reports success" to a person; the
340+
* answer here is no, which is what puts the site OUT of the repair programme
341+
* under AGENTS.md's third legal answer ("a failure handed to the CALLER is not
342+
* a degradation at all").
343+
*
344+
* These pins exist because that ruling is otherwise a JUDGEMENT with nothing
345+
* holding it up. The census will keep listing this site as DARK until the
346+
* programme's last step, so the next reader arrives at a file the worklist
347+
* accuses and a comment that says "not guilty". What makes the difference
348+
* measurable is that the delivery is pinned: turn this catch into a real
349+
* swallow and these go red, which is precisely the transition -- from
350+
* delivering to silent-success -- that the census cannot see and this card
351+
* exists to prevent.
352+
*/
353+
describe('HttpDispatcher.handleKeys — a refused insert is DELIVERED, never swallowed (#12981)', () => {
354+
/** The mint path with a storage layer that refuses every write. */
355+
function kernelRefusingInsert(driverMessage: string) {
356+
const { kernel, rows } = makeKernel();
357+
const ql = kernel.getService('objectql');
358+
ql.insert = async () => { throw new Error(driverMessage); };
359+
return { kernel, rows };
360+
}
361+
362+
it('answers the ADR-0112 error envelope (500 / INTERNAL_ERROR) rather than reporting success', async () => {
363+
const { kernel, rows } = kernelRefusingInsert('connection refused');
364+
const res = responseOf(await dispatcher(kernel).handleKeys('POST', { name: 'CI token' }, ctx()));
365+
366+
// The whole point: the requester was TOLD. Nothing here looks normal from
367+
// the outside, so there is no durability degradation to escalate.
368+
expect(res.status).toBe(500);
369+
expect(res.body.success).toBe(false);
370+
expect(res.body.error.code).toBe('INTERNAL_ERROR');
371+
expect(res.body.error.httpStatus).toBe(500);
372+
expect(rows).toHaveLength(0);
373+
});
374+
375+
it('returns no key material — a caller never holds a credential that was never stored', async () => {
376+
const { kernel } = kernelRefusingInsert('connection refused');
377+
const res = responseOf(await dispatcher(kernel).handleKeys('POST', { name: 'CI token' }, ctx()));
378+
379+
// A 201 carrying `data.key` after a refused insert would be the exact
380+
// "claims to persist, did not persist" shape #12981 is about.
381+
expect(res.body.data).toBeUndefined();
382+
expect(JSON.stringify(res.body)).not.toMatch(/osk_/);
383+
});
384+
385+
it('does not echo the driver error — row contents cannot leak through the envelope', async () => {
386+
// The reason this catch discards the caught value at all, stated at the
387+
// site: a driver error can quote the offending row.
388+
const { kernel } = kernelRefusingInsert(
389+
'duplicate key value violates unique constraint, row: sentinel-row-content',
390+
);
391+
const res = responseOf(await dispatcher(kernel).handleKeys('POST', { name: 'CI token' }, ctx()));
392+
393+
expect(JSON.stringify(res.body)).not.toMatch(/sentinel-row-content/);
394+
expect(res.body.error.message).not.toMatch(/duplicate key/);
395+
});
396+
});

0 commit comments

Comments
 (0)