test(core): Guard log streaming event names against known event groups (#35656)

This commit is contained in:
Ricardo Espinoza
2026-08-10 07:08:27 -04:00
committed by GitHub
parent 4493e5a8b8
commit e743620e88
2 changed files with 51 additions and 0 deletions
@@ -0,0 +1,36 @@
import { eventNamesAll } from '../index';
/**
* Every log-streaming event group in existence. The destination UI derives its
* group checkboxes from the first two segments of the event name, and external
* consumers (SIEM and compliance pipelines) filter the audit trail by the
* `n8n.audit.` prefix.
*/
const KNOWN_EVENT_GROUPS = [
'n8n.audit.',
'n8n.workflow.',
'n8n.node.',
'n8n.worker.',
'n8n.ai.',
'n8n.runner.',
'n8n.queue.',
'n8n.execution.',
];
describe('log streaming event names', () => {
it('should only contain names under a known event group prefix', () => {
const offenders = eventNamesAll.filter(
(eventName) => !KNOWN_EVENT_GROUPS.some((prefix) => eventName.startsWith(prefix)),
);
expect(
offenders,
'Event names are a public contract with log-streaming consumers and cannot be renamed once released. ' +
'Events that record a user action belong under the `n8n.audit.` prefix: SIEM pipelines filter the ' +
'audit trail by that prefix, and a new top-level prefix creates its own opt-in group in the ' +
'destination UI (see `eventNamesMcp` for a group with its own payload shape named under the audit ' +
'prefix). Only deliberately introduce a new operational group with sign-off from the owning team, ' +
'then add its prefix to KNOWN_EVENT_GROUPS.',
).toEqual([]);
});
});
@@ -8,6 +8,21 @@ import type { EventMessageQueue } from './event-message-queue';
import type { EventMessageRunner } from './event-message-runner';
import type { EventMessageWorkflow } from './event-message-workflow';
/**
* Naming rules for log streaming events:
*
* Event names are a public contract with log streaming consumers and cannot be
* renamed once released. Events that record a user action (logins, grants,
* tool calls, settings changes) must be named under `n8n.audit.`: external
* pipelines filter the audit trail by that prefix, and the destination UI
* groups events by the first two name segments, so a new top-level prefix
* creates its own opt-in group outside the audit trail. A group can keep its
* own name list and message class while living under the audit prefix (see
* `eventNamesMcp`). Introducing a new operational group (like `n8n.runner.`)
* is a taxonomy decision that needs sign-off from the owning team; the guard
* test in `__tests__/event-names.test.ts` enforces this.
*/
export const eventNamesAiNodes = [
'n8n.ai.memory.get.messages',
'n8n.ai.memory.added.message',