Awesome Reviewers

Reviewer · Code Style

Minimal exports, no duplication

Keep the module's public surface as small as possible: only `export` a function, type, interface, or constant when it is actually consumed from another file. If a helper, re-export, or constant (e.g. `MAX_ACTIVE_DESCENDANT_EXECUTIONS`, a route handler, a service function) is only used within the file that defines it, declare it with a plain...

Instruction

Keep the module’s public surface as small as possible: only export a function, type, interface, or constant when it is actually consumed from another file. If a helper, re-export, or constant (e.g. MAX_ACTIVE_DESCENDANT_EXECUTIONS, a route handler, a service function) is only used within the file that defines it, declare it with a plain const/function and drop the export keyword. Likewise, remove re-exports/barrel entries that nothing imports anymore, and have each schema/type live at a single canonical import path rather than being re-exported from multiple places.

At the same time, avoid duplicating literals, regexes, and lookup tables across the codebase. If the same regex, magic string, or allow-list (e.g. a secret-reference pattern, a connector type id, an index-privilege allow list) appears more than once—whether in the same file or across files—hoist it into a single named constant or shared module and reuse it everywhere. This keeps a single source of truth, makes future changes (bug fixes, renames) land in one place, and reduces the risk of the copies drifting out of sync.

Example:

// Bad: regex and allow-list duplicated
const first = /\$co\.elastic\.secret\{([^}]+)\}/.test(a);
// ...later in the same file
for (const m of value.matchAll(/\$co\.elastic\.secret\{([^}]+)\}/g)) { ... }

// Good: single shared definition, reused
const SECRET_REF_RE = /\$co\.elastic\.secret\{([^}]+)\}/g;
...
for (const m of value.matchAll(SECRET_REF_RE)) { ... }

Before adding export, ask whether the symbol is actually imported elsewhere; before copying a literal or constant, check whether it already exists and should be imported instead.