Skip to content

Commit db73b59

Browse files
authored
refactor: burn wrapper shadowing baseline entries (#122040)
* refactor: burn wrapper shadowing entries * chore: refresh wrapper shadowing baselines * test: update secrets runtime state mocks * fix(ci): absorb Control UI build identity variance
1 parent b30e0dc commit db73b59

172 files changed

Lines changed: 769 additions & 943 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/.generated/plugin-sdk-api-baseline.jsonl‎

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎scripts/check-control-ui-performance.mts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ const DEFAULT_STARTUP_BUDGET_BASELINE_PATH = path.resolve(
2323
// fixed JS ceiling bounds cumulative creep.
2424
export const CONTROL_UI_STARTUP_JS_GZIP_TOLERANCE_BYTES = 1024;
2525

26+
// The startup bundle embeds commit SHA and timestamp identity. Those fixed-length,
27+
// high-entropy values move Linux gzip output by tens of bytes between identical builds.
28+
export const CONTROL_UI_STARTUP_JS_GZIP_IDENTITY_VARIANCE_BYTES = 64;
29+
2630
// Small, explicit headroom over the optimized baseline. Budget changes should
2731
// accompany an intentional loading or chunking decision.
2832
const controlUiPerformanceBudgets = {
@@ -146,10 +150,13 @@ export function evaluateControlUiPerformanceBudgets(
146150
startupBudgetBaseline: Readonly<ControlUiStartupBudgetBaseline> | null = null,
147151
startupJsTolerance = CONTROL_UI_STARTUP_JS_GZIP_TOLERANCE_BYTES,
148152
) {
153+
const startupJsFixedLimit =
154+
budgets.startupJsGzipBytes +
155+
(startupBudgetBaseline ? CONTROL_UI_STARTUP_JS_GZIP_IDENTITY_VARIANCE_BYTES : 0);
149156
const checks: Array<[string, number, number, "count" | "bytes"]> = [
150157
["startup JS requests", metrics.startup.js.requests, budgets.startupJsRequests, "count"],
151158
["startup CSS requests", metrics.startup.css.requests, budgets.startupCssRequests, "count"],
152-
["startup JS gzip", metrics.startup.js.gzipBytes, budgets.startupJsGzipBytes, "bytes"],
159+
["startup JS gzip", metrics.startup.js.gzipBytes, startupJsFixedLimit, "bytes"],
153160
["startup CSS gzip", metrics.startup.css.gzipBytes, budgets.startupCssGzipBytes, "bytes"],
154161
["largest JS gzip", metrics.largest.js.gzipBytes, budgets.largestJsGzipBytes, "bytes"],
155162
["largest CSS gzip", metrics.largest.css.gzipBytes, budgets.largestCssGzipBytes, "bytes"],
@@ -226,7 +233,7 @@ export function formatControlUiPerformanceReport(
226233
];
227234
if (startupBudgetBaseline) {
228235
lines.push(
229-
` startup JS gzip vs baseline: ${metrics.startup.js.gzipBytes} B (baseline ${startupBudgetBaseline.startupJsGzipBytes} B + tolerance ${startupJsTolerance} B, ceiling ${budgets.startupJsGzipBytes} B)`,
236+
` startup JS gzip vs baseline: ${metrics.startup.js.gzipBytes} B (baseline ${startupBudgetBaseline.startupJsGzipBytes} B + tolerance ${startupJsTolerance} B, ceiling ${budgets.startupJsGzipBytes} B + build-identity variance ${CONTROL_UI_STARTUP_JS_GZIP_IDENTITY_VARIANCE_BYTES} B)`,
230237
);
231238
}
232239
lines.push(

‎scripts/lib/export-name-collision-baseline.json‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
],
88
"sdk": true
99
},
10-
{
11-
"name": "clearSecretsRuntimeSnapshot",
12-
"files": [
13-
"src/secrets/runtime-state.ts",
14-
"src/secrets/runtime.ts"
15-
]
16-
},
1710
{
1811
"name": "createPluginLoaderLogger",
1912
"files": [

‎scripts/lib/wrapper-shadowing-baseline.json‎

Lines changed: 0 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,4 @@
11
[
2-
{
3-
"name": "buildConfigSchema",
4-
"wrapped": "src/config/schema.ts",
5-
"wrapper": "src/config/doc-baseline.runtime.ts"
6-
},
7-
{
8-
"name": "buildShouldSuppressBuiltInModel",
9-
"wrapped": "src/agents/model-suppression.ts",
10-
"wrapper": "src/agents/model-suppression.runtime.ts"
11-
},
12-
{
13-
"name": "clearRuntimeAuthProfileStoreSnapshot",
14-
"wrapped": "src/agents/auth-profiles/runtime-snapshots.ts",
15-
"wrapper": "src/agents/auth-profiles/store.ts"
16-
},
17-
{
18-
"name": "clearSecretsRuntimeSnapshot",
19-
"wrapped": "src/secrets/runtime-state.ts",
20-
"wrapper": "src/secrets/runtime.ts"
21-
},
22-
{
23-
"name": "collectBundledChannelConfigs",
24-
"wrapped": "src/plugins/bundled-channel-config-metadata.ts",
25-
"wrapper": "src/config/doc-baseline.runtime.ts"
26-
},
27-
{
28-
"name": "collectChannelSchemaMetadata",
29-
"wrapped": "src/config/channel-config-metadata.ts",
30-
"wrapper": "src/config/doc-baseline.runtime.ts"
31-
},
32-
{
33-
"name": "collectChannelSecurityFindings",
34-
"wrapped": "src/security/audit-channel.ts",
35-
"wrapper": "src/security/audit-channel.collect.runtime.ts"
36-
},
37-
{
38-
"name": "collectPluginSchemaMetadata",
39-
"wrapped": "src/config/channel-config-metadata.ts",
40-
"wrapper": "src/config/doc-baseline.runtime.ts"
41-
},
42-
{
43-
"name": "createAgentHarnessToolSurfaceRuntime",
44-
"wrapped": "src/agents/harness/tool-surface-bridge.ts",
45-
"wrapper": "src/plugin-sdk/agent-harness-tool-runtime.ts"
46-
},
47-
{
48-
"name": "createChannelPluginBase",
49-
"wrapped": "src/plugin-sdk/core.ts",
50-
"wrapper": "src/plugin-sdk/channel-core.ts"
51-
},
52-
{
53-
"name": "createDeferred",
54-
"wrapped": "src/shared/deferred.ts",
55-
"wrapper": "src/plugin-sdk/extension-shared.ts"
56-
},
57-
{
58-
"name": "DEFAULT_PROGRESS_DRAFT_LABELS",
59-
"wrapped": "src/shared/progress-labels.ts",
60-
"wrapper": "src/channels/streaming.ts"
61-
},
62-
{
63-
"name": "getActivePluginRegistryWorkspaceDirFromState",
64-
"wrapped": "src/plugins/runtime-workspace-state.ts",
65-
"wrapper": "src/plugins/runtime-state.ts"
66-
},
67-
{
68-
"name": "getActiveRuntimeWebToolsMetadata",
69-
"wrapped": "src/secrets/runtime-web-tools-state.ts",
70-
"wrapper": "src/secrets/runtime.ts"
71-
},
72-
{
73-
"name": "getActiveSecretsRuntimeEnv",
74-
"wrapped": "src/secrets/runtime-state.ts",
75-
"wrapper": "src/secrets/runtime.ts"
76-
},
77-
{
78-
"name": "getActiveSecretsRuntimeSnapshotRevision",
79-
"wrapped": "src/secrets/runtime-state.ts",
80-
"wrapper": "src/secrets/runtime.ts"
81-
},
82-
{
83-
"name": "getActiveSecretsRuntimeSnapshot",
84-
"wrapped": "src/secrets/runtime-state.ts",
85-
"wrapper": "src/secrets/runtime.ts"
86-
},
87-
{
88-
"name": "getActiveSkillEnvKeys",
89-
"wrapped": "src/skills/runtime/env-overrides.ts",
90-
"wrapper": "src/skills/runtime/env-overrides.runtime.ts"
91-
},
92-
{
93-
"name": "getApiKeyForModel",
94-
"wrapped": "src/agents/model-auth-model.ts",
95-
"wrapper": "src/plugins/runtime/runtime-model-auth.runtime.ts",
96-
"via": "src/agents/model-auth.ts"
97-
},
98-
{
99-
"name": "getCoreCliCommandNames",
100-
"wrapped": "src/cli/program/core-command-descriptors.ts",
101-
"wrapper": "src/cli/program/command-registry-core.ts"
102-
},
103-
{
104-
"name": "getDefaultLocalRoots",
105-
"wrapped": "src/media/local-media-access.ts",
106-
"wrapper": "src/plugins/runtime/runtime-web-channel-plugin.ts",
107-
"via": "src/media/web-media.ts"
108-
},
109-
{
110-
"name": "getDiagnosticSessionStateCountForTest",
111-
"wrapped": "src/logging/diagnostic-session-state.ts",
112-
"wrapper": "src/logging/diagnostic.ts"
113-
},
114-
{
115-
"name": "getPreparedRuntimeAuthProfileStoreSnapshot",
116-
"wrapped": "src/agents/auth-profiles/runtime-snapshots.ts",
117-
"wrapper": "src/agents/auth-profiles/store.ts"
118-
},
119-
{
120-
"name": "getRuntimeAuthProfileStoreSnapshot",
121-
"wrapped": "src/agents/auth-profiles/runtime-snapshots.ts",
122-
"wrapper": "src/agents/auth-profiles/store.ts"
123-
},
124-
{
125-
"name": "getSubCliEntries",
126-
"wrapped": "src/cli/program/subcli-descriptors.ts",
127-
"wrapper": "src/cli/program/register.subclis-core.ts"
128-
},
129-
{
130-
"name": "hasExplicitPluginConfig",
131-
"wrapped": "src/plugins/config-normalization-shared.ts",
132-
"wrapper": "src/plugins/config-state.ts"
133-
},
134-
{
135-
"name": "isAllowedParsedChatSender",
136-
"wrapped": "src/channels/plugins/chat-target-prefixes.ts",
137-
"wrapper": "src/plugin-sdk/allow-from.ts"
138-
},
139-
{
140-
"name": "isBundledChannelEnabledByChannelConfig",
141-
"wrapped": "src/plugins/config-normalization-shared.ts",
142-
"wrapper": "src/plugins/config-state.ts"
143-
},
144-
{
145-
"name": "isMissingPathError",
146-
"wrapped": "src/infra/errno.ts",
147-
"wrapper": "src/plugin-sdk/memory-host-event-export.ts",
148-
"via": "src/infra/errors.ts"
149-
},
150-
{
151-
"name": "listAuthProfileStoreAgentDirs",
152-
"wrapped": "src/secrets/auth-store-paths.ts",
153-
"wrapper": "src/secrets/storage-scan.ts"
154-
},
1552
{
1563
"name": "loadBundledPluginPublicSurfaceModuleSync",
1574
"wrapped": "src/plugin-sdk/facade-loader.ts",

‎src/agents/anthropic.setup-token.live.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
saveAuthProfileStore,
1919
} from "./auth-profiles.js";
2020
import { isLiveTestEnabled, readLiveTestConfig } from "./live-test-helpers.js";
21-
import { getApiKeyForModel, requireApiKey } from "./model-auth.js";
21+
import { getApiKeyForModelCore, requireApiKey } from "./model-auth.js";
2222
import { normalizeProviderId, parseModelRef } from "./model-selection.js";
2323
import { ensureOpenClawModelsJson } from "./models-config.js";
2424

@@ -205,7 +205,7 @@ describeLive("live anthropic setup-token", () => {
205205
);
206206
}
207207

208-
const apiKeyInfo = await getApiKeyForModel({
208+
const apiKeyInfo = await getApiKeyForModelCore({
209209
model,
210210
cfg,
211211
profileId: tokenSource.profileId,

‎src/agents/auth-profiles/oauth.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { assertNoOAuthSecretRefPolicyViolations } from "./policy.js";
4040
import { clearLastGoodProfileWithLock } from "./profiles.js";
4141
import { suggestOAuthProfileIdForLegacyDefault } from "./repair.js";
4242
import {
43-
getRuntimeAuthProfileStoreSnapshot,
43+
getRuntimeAuthProfileStoreSnapshotCore,
4444
hasRuntimeAuthProfileStoreSnapshot,
4545
setRuntimeAuthProfileStoreSnapshot,
4646
} from "./runtime-snapshots.js";
@@ -311,7 +311,7 @@ function resolveRuntimeAuthProfile(params: {
311311
profile: AuthProfileCredential;
312312
defaults: SecretDefaults | undefined;
313313
}): { profile: AuthProfileCredential; published: boolean } {
314-
const runtimeProfile = getRuntimeAuthProfileStoreSnapshot(params.agentDir)?.profiles[
314+
const runtimeProfile = getRuntimeAuthProfileStoreSnapshotCore(params.agentDir)?.profiles[
315315
params.profileId
316316
];
317317
const inputRefKey = authProfileSecretRefKey(params.profile, params.defaults);
@@ -514,7 +514,7 @@ export async function resolveApiKeyForProfile(
514514
params.agentDir !== ownerAgentDir &&
515515
hasRuntimeAuthProfileStoreSnapshot(params.agentDir)
516516
) {
517-
const snapshot = getRuntimeAuthProfileStoreSnapshot(params.agentDir);
517+
const snapshot = getRuntimeAuthProfileStoreSnapshotCore(params.agentDir);
518518
const providerKey = resolveProviderIdForAuth(cred.provider);
519519
if (snapshot?.lastGood?.[providerKey] === profileId) {
520520
delete snapshot.lastGood[providerKey];

‎src/agents/auth-profiles/profiles.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
} from "./profiles.js";
3030
import {
3131
clearRuntimeAuthProfileStoreSnapshots,
32-
getRuntimeAuthProfileStoreSnapshot as getInternalRuntimeAuthProfileStoreSnapshot,
32+
getRuntimeAuthProfileStoreSnapshotCore as getInternalRuntimeAuthProfileStoreSnapshot,
3333
getRuntimeAuthProfileStoreCredentialMutationToken,
3434
getRuntimeAuthProfileStoreCredentialsRevision,
3535
getRuntimeAuthProfileStoreStateMutationToken,

‎src/agents/auth-profiles/runtime-snapshots.test.ts‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import {
1212
revokeRuntimeAuthMaterializations,
1313
} from "./runtime-materializations.js";
1414
import {
15-
clearRuntimeAuthProfileStoreSnapshot,
15+
clearRuntimeAuthProfileStoreSnapshotCore,
1616
clearRuntimeAuthProfileStoreSnapshots,
17-
getPreparedRuntimeAuthProfileStoreSnapshot,
18-
getRuntimeAuthProfileStoreSnapshot,
17+
getPreparedRuntimeAuthProfileStoreSnapshotCore,
18+
getRuntimeAuthProfileStoreSnapshotCore,
1919
getRuntimeAuthProfileStoreCredentialsRevision,
2020
noteRuntimeAuthProfileStorePersistedMutation,
2121
registerRuntimeAuthProfileStoreMutationListener,
@@ -171,7 +171,7 @@ describe("runtime auth profile snapshots", () => {
171171
},
172172
agentDir,
173173
);
174-
clearRuntimeAuthProfileStoreSnapshot(agentDir);
174+
clearRuntimeAuthProfileStoreSnapshotCore(agentDir);
175175

176176
expect(listener).toHaveBeenCalledTimes(2);
177177
expect(listener).toHaveBeenNthCalledWith(1, {
@@ -223,7 +223,7 @@ describe("runtime auth profile snapshots", () => {
223223
try {
224224
setRuntimeAuthProfileStoreSnapshot(emptyStore, agentDir);
225225
setRuntimeAuthProfileStoreSnapshot(emptyStore, agentDir);
226-
clearRuntimeAuthProfileStoreSnapshot(agentDir);
226+
clearRuntimeAuthProfileStoreSnapshotCore(agentDir);
227227

228228
expect(listener).toHaveBeenCalledTimes(2);
229229
expect(listener).toHaveBeenNthCalledWith(1, {
@@ -268,7 +268,7 @@ describe("runtime auth profile snapshots", () => {
268268
).provider = "mutated";
269269
expectDefined(stored.order?.openai, "stored OpenAI profile order").push("mutated");
270270

271-
const first = getRuntimeAuthProfileStoreSnapshot(agentDir);
271+
const first = getRuntimeAuthProfileStoreSnapshotCore(agentDir);
272272
expectOpenAICodexSnapshotCredential(first, { access: "access-1" });
273273
expect(first?.order?.["openai"]).toEqual(["openai:default"]);
274274

@@ -280,7 +280,7 @@ describe("runtime auth profile snapshots", () => {
280280
"first OpenAI usage stats",
281281
).lastUsed = 99;
282282

283-
const second = getRuntimeAuthProfileStoreSnapshot(agentDir);
283+
const second = getRuntimeAuthProfileStoreSnapshotCore(agentDir);
284284
expectOpenAICodexSnapshotCredential(second, { access: "access-1" });
285285
expect(second?.usageStats?.["openai:default"]?.lastUsed).toBe(1);
286286

@@ -292,7 +292,7 @@ describe("runtime auth profile snapshots", () => {
292292
replacementCredential.access = "mutated-replacement";
293293
}
294294

295-
const replaced = getRuntimeAuthProfileStoreSnapshot(agentDir);
295+
const replaced = getRuntimeAuthProfileStoreSnapshotCore(agentDir);
296296
expectOpenAICodexSnapshotCredential(replaced, {
297297
access: "access-2",
298298
refresh: "refresh-access-2",
@@ -324,7 +324,7 @@ describe("runtime auth profile snapshots", () => {
324324
);
325325
setRuntimeAuthProfileStoreSnapshot(createStore("agent"), agentDir);
326326

327-
const prepared = getPreparedRuntimeAuthProfileStoreSnapshot(agentDir, inheritedAuthDir);
327+
const prepared = getPreparedRuntimeAuthProfileStoreSnapshotCore(agentDir, inheritedAuthDir);
328328

329329
expectOpenAICodexSnapshotCredential(prepared, { access: "agent" });
330330
expect(prepared?.profiles["anthropic:default"]).toMatchObject({
@@ -333,7 +333,7 @@ describe("runtime auth profile snapshots", () => {
333333
key: "inherited-key",
334334
});
335335
expect(
336-
getPreparedRuntimeAuthProfileStoreSnapshot(
336+
getPreparedRuntimeAuthProfileStoreSnapshotCore(
337337
"/tmp/openclaw-auth-runtime-missing",
338338
"/tmp/openclaw-auth-runtime-also-missing",
339339
),
@@ -351,13 +351,15 @@ describe("runtime auth profile snapshots", () => {
351351
setRuntimeAuthProfileStoreSnapshot(createStore("first"), firstAgentDir);
352352
setRuntimeAuthProfileStoreSnapshot(createStore("second"), secondAgentDir);
353353

354-
expect(clearRuntimeAuthProfileStoreSnapshot(firstAgentDir)).toBe(true);
355-
expect(getRuntimeAuthProfileStoreSnapshot(firstAgentDir)).toBeUndefined();
356-
expectOpenAICodexSnapshotCredential(getRuntimeAuthProfileStoreSnapshot(), { access: "main" });
357-
expectOpenAICodexSnapshotCredential(getRuntimeAuthProfileStoreSnapshot(secondAgentDir), {
354+
expect(clearRuntimeAuthProfileStoreSnapshotCore(firstAgentDir)).toBe(true);
355+
expect(getRuntimeAuthProfileStoreSnapshotCore(firstAgentDir)).toBeUndefined();
356+
expectOpenAICodexSnapshotCredential(getRuntimeAuthProfileStoreSnapshotCore(), {
357+
access: "main",
358+
});
359+
expectOpenAICodexSnapshotCredential(getRuntimeAuthProfileStoreSnapshotCore(secondAgentDir), {
358360
access: "second",
359361
});
360-
expect(clearRuntimeAuthProfileStoreSnapshot(firstAgentDir)).toBe(false);
362+
expect(clearRuntimeAuthProfileStoreSnapshotCore(firstAgentDir)).toBe(false);
361363
} finally {
362364
clearRuntimeAuthProfileStoreSnapshots();
363365
}

0 commit comments

Comments
 (0)