mirror of
https://github.com/n8n-io/n8n.git
synced 2026-08-29 01:39:24 +08:00
test(core): Guard log streaming event names against known event groups (#35656)
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user