Skip to content

Commit 9bacc6c

Browse files
MarcoDotIOclaude
andcommitted
fix(server): a policy that manages observability endpoints is refused instead of ignored
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 9e85538 commit 9bacc6c

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎apps/server/src/policy/ManagedPolicy.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,19 @@ it.layer(NodeServices.layer)("ManagedPolicy.load", (it) => {
142142
},
143143
},
144144
}),
145+
// Startup reads OTLP endpoints before the policy, and environment variables outrank them.
146+
JSON.stringify({
147+
...base,
148+
settings: { "observability.otlpTracesUrl": { value: "", locked: true } },
149+
}),
145150
],
146151
(contents) =>
147152
loadFrom(contents).pipe(
148153
Effect.flip,
149154
Effect.map((error) => error.reason),
150155
),
151156
);
152-
assert.lengthOf(reasons, 13);
157+
assert.lengthOf(reasons, 14);
153158
assert.include(reasons[3], "storageCleanup.logsAfterDayz");
154159
assert.include(reasons[6], "adds entries users could not remove");
155160
assert.include(reasons[7], "adds entries users could not remove");
@@ -158,6 +163,7 @@ it.layer(NodeServices.layer)("ManagedPolicy.load", (it) => {
158163
assert.include(reasons[10], 'lock "worktreeCleanup" too');
159164
assert.include(reasons[11], 'lock "providerInstances.codex" as a whole');
160165
assert.include(reasons[12], "holds a credential");
166+
assert.include(reasons[13], "a policy cannot override");
161167
}),
162168
);
163169

‎apps/server/src/policy/managedSettings.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ const UNMANAGEABLE_KEYS: ReadonlySet<string> = new Set([
2828
"projectScriptOverrides",
2929
]);
3030

31+
/**
32+
* Startup reads OTLP endpoints from the settings file before the policy loads, and the user's
33+
* OTLP environment variables outrank them, so a managed value would look enforced without being.
34+
*/
35+
const ENVIRONMENT_OVERRIDDEN_KEYS: ReadonlySet<string> = new Set(["observability"]);
36+
3137
/** Legacy settings the server derives from another on every write; manage that one instead. */
3238
const DERIVED_FROM: ReadonlyMap<string, string> = new Map([
3339
["compactIdleThreads", "idleCompaction"],
@@ -253,6 +259,12 @@ export function makeManagedSettings(
253259
if (!(head in ServerSettings.fields) || UNMANAGEABLE_KEYS.has(head)) {
254260
return { _tag: "Invalid", reason: `"${path}" is not a setting this version can manage` };
255261
}
262+
if (ENVIRONMENT_OVERRIDDEN_KEYS.has(head)) {
263+
return {
264+
_tag: "Invalid",
265+
reason: `"${path}" comes from each user's environment and settings file at startup, which a policy cannot override`,
266+
};
267+
}
256268
const source = DERIVED_FROM.get(head);
257269
if (source !== undefined) {
258270
return {

‎docs/user/managed-policy.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ A few settings need care:
146146
- `worktreeCleanup`, which projects can also set, overrides the `worktree` rules in
147147
`storageCleanup`. Lock it along with those rules; T3 Code refuses a policy that locks only the
148148
rules.
149+
- `observability` cannot be managed. Its OTLP endpoints come from each user's environment
150+
variables and settings file, which a policy cannot override.
149151
- Manage `idleCompaction`, not the older `compactIdleThreads`. A Claude instance's own idle
150152
compaction choice still wins over `idleCompaction`.
151153
- A provider instance's fields override each other, so lock `providerInstances.<id>` as a whole,

0 commit comments

Comments
 (0)