Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(control-api): auto-curate cluster org + official evenfire; env is additive only

Andy Pavia1e38f6ccfbb2
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 9bb4e2174..4f27babd1 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.434",
+ "version": "0.1.435",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.434",
+ "version": "0.1.435",
"dependencies": {
"@clerum/image-policy": "file:../packages/image-policy",
"@clerum/llm-providers": "file:../packages/llm-providers",
diff --git a/control-api/package.json b/control-api/package.json
index 87c5b1e45..1c47faa52 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.434",
+ "version": "0.1.435",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/src/config.ts b/control-api/src/config.ts
index fcd379e5a..add91948d 100644
--- a/control-api/src/config.ts
+++ b/control-api/src/config.ts
@@ -840,10 +840,13 @@ export const config: Config = {
process.env.CONTROL_API_ENFORCE_IMAGE_ALLOWLIST === '1',
// Guardrails install-hook trust policy (spec §8.4 / registry gap #1). The
// registry's entries.trust_level is publisher-influenced, so the saga only
- // honors it for platform-CURATED orgs listed here; every other org's hook is
- // capped at `defaultHookTrustCap` regardless of the column. Case-sensitive
- // (org scopes carry '@'); NOT parseCsvList (which lowercases).
- curatedHookOrgs: (process.env.CONTROL_API_CURATED_HOOK_ORGS ?? '@clerum,@evenfire')
+ // honors it for CURATED orgs; every other org's hook is capped at
+ // `defaultHookTrustCap` regardless of the column. The cluster's OWN org (from
+ // resolvePublishScope) and official evenfire (`@clerum`/`@evenfire`) are ALWAYS
+ // curated — not listed here — so this env is purely ADDITIVE, for extra
+ // third-party orgs the operator chooses to trust. Empty by default. Case-
+ // sensitive (org scopes carry '@'); NOT parseCsvList (which lowercases).
+ curatedHookOrgs: (process.env.CONTROL_API_CURATED_HOOK_ORGS ?? '')
.split(',')
.map(s => s.trim())
.filter(Boolean),
diff --git a/control-api/src/routes/admin/__tests__/installHookTrust.test.ts b/control-api/src/routes/admin/__tests__/installHookTrust.test.ts
index 2fa65c0eb..a6074a54b 100644
--- a/control-api/src/routes/admin/__tests__/installHookTrust.test.ts
+++ b/control-api/src/routes/admin/__tests__/installHookTrust.test.ts
@@ -2,8 +2,10 @@
* install-hook trust policy (guardrails spec §8.4 / registry gap #1).
*
* entries.trust_level is publisher-influenced, so the saga honors it only for a
- * platform-curated org and caps every other org. Uses the default config
- * (curated: @clerum,@evenfire; cap: mid).
+ * CURATED org: the cluster's OWN org (from resolvePublishScope) and official
+ * evenfire (@clerum/@evenfire) are auto-curated; CONTROL_API_CURATED_HOOK_ORGS
+ * is a purely additive allowlist for OTHER third-party orgs (empty by default).
+ * Every non-curated org is capped at the default cap (mid).
*/
import { describe, expect, it } from 'vitest'
import { resolveHookTrustLevel } from '../registry.js'
@@ -11,26 +13,32 @@ import { resolveHookTrustLevel } from '../registry.js'
const entry = (name: string, trust_level: string) => ({ name, trust_level })
describe('resolveHookTrustLevel', () => {
- it('honors the column for a curated org', () => {
- expect(resolveHookTrustLevel(entry('@clerum/pii-redact', 'high'))).toBe('high')
- expect(resolveHookTrustLevel(entry('@evenfire/scan', 'mid'))).toBe('mid')
+ it('official evenfire (@clerum/@evenfire) is auto-curated regardless of cluster org', () => {
+ expect(resolveHookTrustLevel(entry('@clerum/x', 'high'), null)).toBe('high')
+ expect(resolveHookTrustLevel(entry('@evenfire/scan', 'high'), '@acme')).toBe('high')
})
- it('caps a non-curated org at the default cap (mid) — a self-published high is NOT honored', () => {
- // The exact §8.4 gap: @acme self-tagged its way to trust_level high.
- expect(resolveHookTrustLevel(entry('@acme/pii-redact', 'high'))).toBe('mid')
+ it("the cluster's OWN org is auto-curated (no env entry needed)", () => {
+ // @acme is this deployment's publish scope → honor its trust_level.
+ expect(resolveHookTrustLevel(entry('@acme/pii-redact', 'high'), '@acme')).toBe('high')
})
- it('a non-curated org below the cap keeps its lower level (min of column and cap)', () => {
- expect(resolveHookTrustLevel(entry('@acme/scan', 'low'))).toBe('low')
- expect(resolveHookTrustLevel(entry('@acme/scan', 'mid'))).toBe('mid')
+ it('a third-party org (not cluster, not evenfire, not in the env) is capped at mid', () => {
+ // @acme's self-tagged high is NOT honored when it is not the cluster org.
+ expect(resolveHookTrustLevel(entry('@acme/pii-redact', 'high'), '@othercorp')).toBe('mid')
+ expect(resolveHookTrustLevel(entry('@acme/pii-redact', 'high'), null)).toBe('mid')
})
- it('an unscoped name (no @org/) is treated as non-curated and capped', () => {
- expect(resolveHookTrustLevel(entry('pii-redact', 'high'))).toBe('mid')
+ it('a capped org keeps a level below the cap (min of column and cap)', () => {
+ expect(resolveHookTrustLevel(entry('@acme/scan', 'low'), null)).toBe('low')
+ expect(resolveHookTrustLevel(entry('@acme/scan', 'mid'), null)).toBe('mid')
+ })
+
+ it('an unscoped name is treated as non-curated and capped', () => {
+ expect(resolveHookTrustLevel(entry('pii-redact', 'high'), '@acme')).toBe('mid')
})
it('a missing/blank trust_level defaults to low', () => {
- expect(resolveHookTrustLevel(entry('@clerum/x', ''))).toBe('low')
+ expect(resolveHookTrustLevel(entry('@clerum/x', ''), null)).toBe('low')
})
})
diff --git a/control-api/src/routes/admin/registry.ts b/control-api/src/routes/admin/registry.ts
index c3ec20ea2..50b998b7b 100644
--- a/control-api/src/routes/admin/registry.ts
+++ b/control-api/src/routes/admin/registry.ts
@@ -160,18 +160,39 @@ function hookOrgScope(entryName: string): string | null {
return m ? `@${m[1]}` : null
}
+/**
+ * Official evenfire scopes — always curated (the platform's own reserved orgs).
+ * Hardcoded so a misconfigured `CONTROL_API_CURATED_HOOK_ORGS` can never drop
+ * platform trust, and so the env list is reserved for extra THIRD-PARTY orgs.
+ */
+const OFFICIAL_EVENFIRE_HOOK_ORGS = ['@clerum', '@evenfire']
+
/**
* Authoritative trust level for an installed hook (§8.4 / registry gap #1).
* `entries.trust_level` is publisher-influenced (trigger-computed from
- * author-supplied creator tags), so it is honored ONLY for a platform-curated
- * org; every other org's hook is capped at `config.defaultHookTrustCap` — a
- * self-published hook can clear a `mid` floor but never reach `high` (and so can
- * never unlock the content+egress combination §8.4 reserves for `high`).
+ * author-supplied creator tags), so it is honored ONLY for a CURATED org; every
+ * other org's hook is capped at `config.defaultHookTrustCap` — a self-published
+ * hook can clear a `mid` floor but never reach `high` (and so can never unlock
+ * the content+egress combination §8.4 reserves for `high`).
+ *
+ * Curated = the cluster's OWN org (`clusterOrgScope`, from resolvePublishScope) ∪
+ * official evenfire (`@clerum`/`@evenfire`) ∪ the additive
+ * `CONTROL_API_CURATED_HOOK_ORGS` allowlist (other third-party orgs). The first
+ * two are trusted automatically — they are the operator's own org and the
+ * platform — so the env is only consulted for orgs that are NEITHER.
*/
-export function resolveHookTrustLevel(entry: Pick<RegistryEntry, 'name' | 'trust_level'>): string {
+export function resolveHookTrustLevel(
+ entry: Pick<RegistryEntry, 'name' | 'trust_level'>,
+ clusterOrgScope: string | null
+): string {
const column = (entry.trust_level || 'low').toLowerCase()
const org = hookOrgScope(entry.name)
- if (org && config.curatedHookOrgs.includes(org)) return column
+ const curated =
+ !!org &&
+ (org === clusterOrgScope ||
+ OFFICIAL_EVENFIRE_HOOK_ORGS.includes(org) ||
+ config.curatedHookOrgs.includes(org))
+ if (curated) return column
const cap = config.defaultHookTrustCap
return (HOOK_TRUST_ORDER[column] ?? 0) <= (HOOK_TRUST_ORDER[cap] ?? 1) ? column : cap
}
@@ -1663,8 +1684,14 @@ export function createAdminRegistryRouter(gateway?: K8sGateway): Router {
return
}
- // Step 2 — authoritative trust level (§8.4; never face-value for a self-published hook).
- const trustLevel = resolveHookTrustLevel(entry)
+ // Step 2 — authoritative trust level (§8.4; never face-value for a
+ // self-published hook). The cluster's OWN org (this deployment's publish
+ // scope) and official evenfire are auto-curated; other orgs are capped
+ // unless in the additive CONTROL_API_CURATED_HOOK_ORGS allowlist.
+ const clusterOrgScope = await resolvePublishScope()
+ .then(s => s.scope)
+ .catch(() => null)
+ const trustLevel = resolveHookTrustLevel(entry, clusterOrgScope)
// Step 3 — load target Host + its guardrails policy.
let host: HostShape