Skip to content

Commit 39adc46

Browse files
committed
chore(logs): tighten log-noise changes after a line-by-line audit
- Drop the blockId option threaded through getEffectiveBlockOutputs; it only labeled a debug log. - Name the log-dedupe windows and cache ceilings. - Build the sandbox catalog route set by converting contract paths to the route table's pattern syntax; the route-table test guards drift.
1 parent e4659a4 commit 39adc46

7 files changed

Lines changed: 37 additions & 34 deletions

File tree

‎apps/sim/executor/utils/block-data.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ function getRegistrySchema(block: SerializedBlock): OutputSchema | undefined {
4545
triggerMode,
4646
preferToolOutputs: !triggerMode,
4747
includeHidden: true,
48-
blockId: block.id,
4948
}) as OutputSchema
5049

5150
if (!outputs || Object.keys(outputs).length === 0) {

‎apps/sim/lib/core/utils/response-format.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ export function parseResponseFormatSafely(
7878
}
7979
return responseFormatValue
8080
} catch (error) {
81-
// An unparseable response format is user input that falls back to the block's default
82-
// outputs; it is re-read on every output-schema derivation, so it is not warning-worthy.
81+
// User configuration that falls back to the block's default outputs (the editor's lint
82+
// reports it); every output-schema derivation re-reads it, so it is not warning-worthy.
8383
logger.debug('Failed to parse response format', { blockId, message: getErrorMessage(error) })
8484
return null
8585
}

‎apps/sim/lib/mothership/tools/sandbox-catalog-routes.ts‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,23 @@ import {
55
v2ListConnectorTypesContract,
66
v2ListToolsContract,
77
} from '@/lib/api/contracts/v2/catalog'
8-
import { matchV2Route } from '@/lib/api/server/routes/in-process-transport'
98

10-
let catalogRoutePatterns: ReadonlySet<string> | undefined
9+
/** Catalog contract paths in the generated route table's `{param}` pattern syntax. */
10+
const CATALOG_ROUTE_PATTERNS: ReadonlySet<string> = new Set(
11+
[
12+
v2ListBlocksContract,
13+
v2GetBlockContract,
14+
v2ListToolsContract,
15+
v2GetToolContract,
16+
v2ListConnectorTypesContract,
17+
].map((contract) => contract.path.replace(/\[([^\]]+)\]/g, '{$1}'))
18+
)
1119

1220
/**
1321
* Whether a sandbox API request reads the producer-owned catalog (blocks, tools, connector
1422
* types): no execution output, file content, or row values, so no producer records secret
15-
* provenance for it and none is expected. Each contract resolves through the generated route
16-
* table, so a renamed path parameter cannot drift from the pattern `matchV2Route` reports.
23+
* provenance for it and none is expected.
1724
*/
1825
export function isCatalogRoute(method: string, routePattern: string): boolean {
19-
if (method !== 'GET') return false
20-
catalogRoutePatterns ??= new Set(
21-
[
22-
v2ListBlocksContract,
23-
v2GetBlockContract,
24-
v2ListToolsContract,
25-
v2GetToolContract,
26-
v2ListConnectorTypesContract,
27-
].flatMap((contract) => {
28-
const pattern = matchV2Route(contract.path.replace(/\[[^\]]+\]/g, 'catalog-id'))?.pattern
29-
return pattern ? [pattern] : []
30-
})
31-
)
32-
return catalogRoutePatterns.has(routePattern)
26+
return method === 'GET' && CATALOG_ROUTE_PATTERNS.has(routePattern)
3327
}

‎apps/sim/lib/mothership/tools/sandbox-resource-transport.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ import { observeWorkspaceFileDelivery } from '@/lib/workspace-files/application/
3030

3131
const logger = createLogger('MothershipSandboxResourceTransport')
3232

33+
/** How long one route's missing-provenance report suppresses repeats for that route. */
34+
const UNRECORDED_PROVENANCE_LOG_WINDOW_MS = 60 * 60 * 1000
35+
/** Memory backstop above the number of `method route` pairs the v2 route table can produce. */
36+
const UNRECORDED_PROVENANCE_LOG_MAX_ROUTES = 1_000
37+
3338
/**
3439
* Data-bearing routes already reported as lacking a provenance producer. The gap is a
3540
* property of the route, not the request, so it is reported once per route per window.
3641
*/
3742
const unrecordedProvenanceRoutesLogged = new LRUCache<string, true>({
38-
max: 1_000,
39-
ttl: 60 * 60 * 1000,
43+
max: UNRECORDED_PROVENANCE_LOG_MAX_ROUTES,
44+
ttl: UNRECORDED_PROVENANCE_LOG_WINDOW_MS,
4045
})
4146

4247
/** Private callback observes the real authenticated v2 request without changing its body or API contract. */

‎apps/sim/lib/tokenization/accurate.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ const logger = createLogger('TokenizationAccurate')
2525
/** Keyed by encoding, not model: each instance holds a full rank table, so models share one. */
2626
const encodingCache = new Map<TiktokenEncoding, Tiktoken>()
2727

28+
/** Memory backstop for {@link encodingNameByModel}; model ids are caller-supplied strings. */
29+
const ENCODING_NAME_CACHE_MAX_MODELS = 1_000
30+
2831
/**
2932
* Model id → encoding name, so a non-OpenAI model does not throw and catch inside
30-
* `getEncodingNameForModel` on every count. Model ids are caller-supplied, hence the ceiling.
33+
* `getEncodingNameForModel` on every count.
3134
*/
32-
const encodingNameByModel = new LRUCache<string, TiktokenEncoding>({ max: 1_000 })
35+
const encodingNameByModel = new LRUCache<string, TiktokenEncoding>({
36+
max: ENCODING_NAME_CACHE_MAX_MODELS,
37+
})
3338

3439
/** OpenAI families tokenized with `o200k_base` that `js-tiktoken`'s exact-name table may not list yet. */
3540
const O200K_MODEL_FAMILY = /^(?:gpt-(?:4o|4\.1|4\.5|5|6|oss)|chatgpt-4o|o\d)/

‎apps/sim/lib/webhooks/providers/slack.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,20 @@ async function downloadSlackFiles(
408408
return downloaded
409409
}
410410

411+
/** How long a webhook's `missing_scope` report suppresses repeats of the same log line. */
412+
const MISSING_SCOPE_LOG_WINDOW_MS = 60 * 60 * 1000
413+
/** Memory backstop for {@link reactionsMissingScopeLogged}, far above live Slack webhooks. */
414+
const MISSING_SCOPE_LOG_MAX_WEBHOOKS = 10_000
415+
411416
/**
412417
* Webhooks whose bot already reported `missing_scope` on `reactions.get`. A bot without
413418
* `reactions:read` fails every reaction event identically until it is reinstalled, so the
414419
* configuration problem is logged once per webhook per window rather than per event. The call
415420
* itself still runs, so a reinstalled bot gets message text back immediately.
416421
*/
417422
const reactionsMissingScopeLogged = new LRUCache<string, true>({
418-
max: 10_000,
419-
ttl: 60 * 60 * 1000,
423+
max: MISSING_SCOPE_LOG_MAX_WEBHOOKS,
424+
ttl: MISSING_SCOPE_LOG_WINDOW_MS,
420425
})
421426

422427
async function fetchSlackMessageText(

‎apps/sim/lib/workflows/blocks/block-outputs.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ interface EffectiveOutputOptions {
3838
triggerMode?: boolean
3939
preferToolOutputs?: boolean
4040
includeHidden?: boolean
41-
/** The block instance id, used only to attribute an unparseable response format. */
42-
blockId?: string
4341
}
4442

4543
type ConditionValue = string | number | boolean
@@ -434,7 +432,6 @@ export function getEffectiveBlockOutputs(
434432
const includeHidden = options?.includeHidden ?? false
435433

436434
if (blockType === 'agent') {
437-
const responseFormatBlockId = options?.blockId ?? blockType
438435
const model = subBlocks?.model?.value
439436
const mayEvaluate =
440437
typeof model === 'string' && (isEvaluationModel(model) || containsReference(model))
@@ -443,13 +440,11 @@ export function getEffectiveBlockOutputs(
443440
const answers = getJevAnswerOutput(subBlocks?.evaluationQuestions?.value)
444441
return {
445442
...outputs,
446-
...(containsReference(model)
447-
? getResponseFormatOutputs(subBlocks, responseFormatBlockId)
448-
: undefined),
443+
...(containsReference(model) ? getResponseFormatOutputs(subBlocks, 'agent') : undefined),
449444
...(answers ? { answers } : undefined),
450445
}
451446
}
452-
const responseFormatOutputs = getResponseFormatOutputs(subBlocks, responseFormatBlockId)
447+
const responseFormatOutputs = getResponseFormatOutputs(subBlocks, 'agent')
453448
if (responseFormatOutputs) return responseFormatOutputs
454449
}
455450

0 commit comments

Comments
 (0)