Skip to content

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

TypeScript

fix(test): align GFS gateway limit contract (R1-M1)

Josué572010d64f1e
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 94317002b..45c93ac23 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.470",
+ "version": "0.1.471",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.470",
+ "version": "0.1.471",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/image-policy": "file:../packages/image-policy",
diff --git a/control-api/package.json b/control-api/package.json
index 32f95cd2f..d4f9cf5ff 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.470",
+ "version": "0.1.471",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/test/network.gateway.intent.test.ts b/control-api/test/network.gateway.intent.test.ts
index a3a77802e..f2b4b85fd 100644
--- a/control-api/test/network.gateway.intent.test.ts
+++ b/control-api/test/network.gateway.intent.test.ts
@@ -344,15 +344,45 @@ describe('network/gateway intent (manifest-level)', () => {
})
it('keeps the GFS v2 part cap chain below the gateway request cap', () => {
- // Upload v2 is indexed binary streaming: the 200 MiB product boundary is
- // aggregate session metadata, while every request remains <=16 MiB. The
- // old base64 ×4/3 invariant belongs only to the legacy JSON path and must not
- // constrain the v2 product limit.
- const GFSC_WRITE_CAP = 25165824 // 24 MiB — the funnel + gfsc authoritative cap
-
- // 1. gfsc's write cap is actually plumbed to the pod. Without this env gfsc
- // falls back to its 16 MiB in-code default and a 16 MB file (22.4 MB body)
- // hard-413s while the client-side cap says it should have worked.
+ // Upload v2 is indexed binary streaming: product policy is writer-advertised
+ // session metadata, while protocol and per-request safety remain compiled.
+ // Do not compare the runtime product policy with a single-request body cap.
+ const evaluateStaticBytes = (expression: string, label: string): number => {
+ const value = expression
+ .split('*')
+ .reduce((acc, factor) => acc * Number(factor.trim().replaceAll('_', '')), 1)
+ expect(Number.isSafeInteger(value), `${label} must be a safe integer`).toBe(true)
+ return value
+ }
+ const staticBytes = (relPath: string, symbol: string): number => {
+ const source = read(relPath)
+ const match = source.match(
+ new RegExp(`(?:export\\s+)?const\\s+${symbol}\\s*=\\s*([0-9_*\\s]+)`)
+ )
+ expect(match, `${symbol} not found in ${relPath}`).not.toBeNull()
+ return evaluateStaticBytes(match![1], `${relPath}:${symbol}`)
+ }
+ const boundedEnvBytes = (
+ relPath: string,
+ property: string,
+ envName: string
+ ): { fallback: number; ceiling: number } => {
+ const source = read(relPath)
+ const match = source.match(
+ new RegExp(
+ `${property}\\s*:\\s*boundedIntegerFromEnv\\(\\s*['"]${envName}['"]\\s*,` +
+ `\\s*([0-9_*\\s]+?),\\s*([0-9_*\\s]+?)\\s*\\)`
+ )
+ )
+ expect(match, `${envName} bounded config not found in ${relPath}`).not.toBeNull()
+ return {
+ fallback: evaluateStaticBytes(match![1], `${relPath}:${envName}:fallback`),
+ ceiling: evaluateStaticBytes(match![2], `${relPath}:${envName}:ceiling`),
+ }
+ }
+
+ // The legacy JSON/base64 path still requires the HCC-owned gfsc body cap to
+ // agree with the profile funnel. It is not the Upload v2 product authority.
const hccDeployment = read(`${BASE}/control-plane/host-context-controller.yaml`)
const gfscCapMatch = hccDeployment.match(
/GFS_MAX_WRITE_BODY_BYTES[\s\S]{0,80}?value:\s*"?(\d+)"?/
@@ -361,29 +391,74 @@ describe('network/gateway intent (manifest-level)', () => {
gfscCapMatch,
'GFS_MAX_WRITE_BODY_BYTES env must be set on the HCC deployment'
).not.toBeNull()
- expect(Number(gfscCapMatch![1])).toBe(GFSC_WRITE_CAP)
-
- // 2. Both clients advertise the same hard binary part cap and product cap.
- const parseClientCaps = (relPath: string): { product: number; part: number } => {
- const src = read(relPath)
- const productMatch = src.match(/GFS_FILE_UPLOAD_MAX_BYTES\s*=\s*([0-9*\s]+)/)
- const partMatch = src.match(/GFS_FILE_UPLOAD_MAX_PART_BYTES\s*=\s*([0-9*\s]+)/)
- expect(productMatch, `GFS_FILE_UPLOAD_MAX_BYTES not found in ${relPath}`).not.toBeNull()
- expect(partMatch, `GFS_FILE_UPLOAD_MAX_PART_BYTES not found in ${relPath}`).not.toBeNull()
- // Only digits/`*`/spaces are matched, so evaluating the arithmetic is safe.
- const evaluate = (value: string): number =>
- Number(value.split('*').reduce((acc, n) => acc * Number(n.trim()), 1))
- return { product: evaluate(productMatch![1]), part: evaluate(partMatch![1]) }
- }
- const webCaps = parseClientCaps('../../control-ui/app/constants/gfsFileUpload.ts')
- const desktopCaps = parseClientCaps('../../desktop-app/ui/src/constants/gfsFileUpload.ts')
- expect(webCaps).toEqual(desktopCaps)
- expect(webCaps.product).toBe(209715200)
- expect(webCaps.part).toBe(16777216)
-
- // 3. A v2 binary request fits below the internal 24 MiB cap with headroom;
- // the aggregate 200 MiB value never becomes a single request body.
- expect(webCaps.part).toBeLessThan(GFSC_WRITE_CAP)
+ const legacyGfscWriteCap = Number(gfscCapMatch![1])
+ const funnelConf = docContaining(
+ yamlDocs(read(`${BASE}/profiles/configmaps.yaml`)),
+ 'name: profile-control-funnel-nginx'
+ )
+ const funnelCapMatch = funnelConf.match(/client_max_body_size\s+(\d+);/)
+ expect(funnelCapMatch, 'profile-control-funnel body cap not found').not.toBeNull()
+ const profileFunnelCap = Number(funnelCapMatch![1])
+ expect(profileFunnelCap).toBe(legacyGfscWriteCap)
+
+ // The writer defines the absolute protocol and part bounds. Both packaged
+ // Desktop layers and Control UI mirror those wire limits, not product policy.
+ const writerProtocol = staticBytes(
+ '../../gfs-controller/src/upload/protocol.ts',
+ 'GFS_UPLOAD_V2_PROTOCOL_MAX_BYTES'
+ )
+ const writerPart = staticBytes(
+ '../../gfs-controller/src/upload/protocol.ts',
+ 'GFS_UPLOAD_V2_MAX_PART_BYTES'
+ )
+ expect(writerProtocol).toBe(1024 * 1024 * 1024)
+ expect(writerPart).toBe(16 * 1024 * 1024)
+ expect(writerPart).toBeLessThan(writerProtocol)
+
+ const protocolMirrors = [
+ staticBytes(
+ '../../control-ui/app/constants/gfsFileUpload.ts',
+ 'GFS_FILE_UPLOAD_PROTOCOL_MAX_BYTES'
+ ),
+ staticBytes(
+ '../../desktop-app/ui/src/constants/gfsFileUpload.ts',
+ 'GFS_FILE_UPLOAD_PROTOCOL_MAX_BYTES'
+ ),
+ staticBytes('../../desktop-app/src/gfs/upload.ts', 'GFS_UPLOAD_V2_PROTOCOL_MAX_BYTES'),
+ ]
+ const partMirrors = [
+ staticBytes(
+ '../../control-ui/app/constants/gfsFileUpload.ts',
+ 'GFS_FILE_UPLOAD_MAX_PART_BYTES'
+ ),
+ staticBytes(
+ '../../desktop-app/ui/src/constants/gfsFileUpload.ts',
+ 'GFS_FILE_UPLOAD_MAX_PART_BYTES'
+ ),
+ staticBytes('../../desktop-app/src/gfs/upload.ts', 'GFS_UPLOAD_V2_MAX_PART_BYTES'),
+ staticBytes(
+ '../../control-ui/app/control-api/[...path]/route.ts',
+ 'GFS_UPLOAD_MAX_PART_BYTES'
+ ),
+ ]
+ expect(protocolMirrors).toEqual(protocolMirrors.map(() => writerProtocol))
+ expect(partMirrors).toEqual(partMirrors.map(() => writerPart))
+
+ // Every relay defaults to the writer part maximum and refuses configuration
+ // above it. A part must also fit through the profile gateway with headroom.
+ const controlApiRelay = boundedEnvBytes(
+ '../src/config.ts',
+ 'gfsUploadMaxPartBytes',
+ 'CONTROL_API_GFS_UPLOAD_MAX_PART_BYTES'
+ )
+ const externalRestRelay = boundedEnvBytes(
+ '../../external-rest-api/src/config.ts',
+ 'gfsUploadMaxPartBytes',
+ 'EXTERNAL_REST_API_GFS_UPLOAD_MAX_PART_BYTES'
+ )
+ expect(controlApiRelay).toEqual({ fallback: writerPart, ceiling: writerPart })
+ expect(externalRestRelay).toEqual({ fallback: writerPart, ceiling: writerPart })
+ expect(writerPart).toBeLessThan(profileFunnelCap)
})
it('keeps control-api memory at >=768Mi in base AND the minikube overlay (RC3 OOM guard)', () => {