FFFF refactor(sandbox,settings): drop dead options; one inspect for drift state by geminixiang · Pull Request #200 · geminixiang/mikan · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/adapters/slack/update-diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,23 @@ export function recordSlackUpdate(
} else {
failures?.delete(key);
}
recordDiagnosticEvent("error" in outcome ? "slack.update.rejected" : "slack.update.recovered", {
operation: "chat.update",
channelId: channel,
responseMessageId: ts,
failedAttempts: attempts,
...shape(source, payload),
...("error" in outcome ? validation(outcome.error) : {}),
});
const rejected = "error" in outcome;
recordDiagnosticEvent(
rejected ? "slack.update.rejected" : "slack.update.recovered",
{
operation: "chat.update",
channelId: channel,
responseMessageId: ts,
failedAttempts: attempts,
...shape(source, payload),
...(rejected ? validation(outcome.error) : {}),
},
{
message: rejected ? "Slack update rejected" : "Slack update recovered",
category: "slack.update",
level: rejected ? "warning" : "info",
log: !rejected,
},
);
} catch {}
}
11 changes: 4 additions & 7 deletions src/env-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,16 @@ function platformRecipe(group: EnvGroup): string {
return `${group.title}: ${required.join(" + ")}`;
}

export function noPlatformsMessage(): string {
const recipes = ENV_MANIFEST.filter((group) => group.kind === "platform")
.map((group) => ` ${platformRecipe(group)}`)
.join("\n");
return `No platform tokens found. Set one of:\n${recipes}`;
}

export function envSummaryLines(): string[] {
return ENV_MANIFEST.filter((group) => group.kind === "platform").map(
(group) => ` ${platformRecipe(group)}`,
);
}

export function noPlatformsMessage(): string {
return `No platform tokens found. Set one of:\n${envSummaryLines().join("\n")}`;
}

export function envReport(env: EnvLookup = readEnv): string {
const lines: string[] = [];
for (const group of ENV_MANIFEST) {
Expand Down
12 changes: 2 additions & 10 deletions src/harness/execution-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,8 @@ export class ActorExecutionResolver {
}

return async () => {
const expected = plan.sandboxConfig.type === "container" ? plan.sandboxConfig.container : "";
let actual: string | undefined;
try {
actual = await this.provisioner?.provision(plan.resourceKey, {
containerName: expected,
await this.provisioner?.provision(plan.resourceKey, {
mounts: plan.mounts,
conversationId,
});
Expand All @@ -131,17 +128,12 @@ export class ActorExecutionResolver {
conversationId,
credentialKey: plan.credentialKey,
resourceKey: plan.resourceKey,
expectedContainer: expected,
expectedContainer: DockerContainerManager.containerName(plan.resourceKey),
hasVault: Boolean(plan.env || plan.mounts.length > 0),
},
});
throw err;
}
if (actual && actual !== expected) {
throw new Error(
`Provisioner returned container "${actual}" for resource key "${plan.resourceKey}", expected "${expected}"`,
);
}
};
}

Expand Down
22 changes: 7 additions & 15 deletions src/observability/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "./sentry.js";
import { isOpenTelemetryMetricsEnabled, shutdownOpenTelemetry } from "./otel.js";
import type {
DiagnosticBreadcrumb,
JevOutcomeReport,
ObservabilityAttributes,
ReportUserFacingErrorOptions,
Expand Down Expand Up @@ -168,7 +169,11 @@ export function addLifecycleEvent(
addSentryBreadcrumb(name, safeAttributes);
}

export function recordDiagnosticEvent(name: string, data: Record<string, unknown>): void {
export function recordDiagnosticEvent(
name: string,
data: Record<string, unknown>,
breadcrumb: DiagnosticBreadcrumb,
): void {
const spanAttributes = metricAttributes(
Object.fromEntries(
Object.entries(data).filter((entry): entry is [string, string | number | boolean] => {
Expand All @@ -178,20 +183,7 @@ export function recordDiagnosticEvent(name: string, data: Record<string, unknown
),
);
trace.getActiveSpan()?.addEvent(name, spanAttributes as Attributes);
const recovered = name === "slack.update.recovered";
addSentryBreadcrumb(
recovered
? "Slack update recovered"
: name === "slack.update.rejected"
? "Slack update rejected"
: name,
data,
{
category: name.startsWith("slack.update.") ? "slack.update" : "diagnostic",
level: name.endsWith(".rejected") ? "warning" : "info",
log: recovered,
},
);
addSentryBreadcrumb(breadcrumb.message, data, breadcrumb);
}

export function reportUserFacingError(
Expand Down
7 changes: 7 additions & 0 deletions src/observability/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ export interface RunScopeContext {
model?: string;
}

export interface DiagnosticBreadcrumb {
message: string;
category: string;
level: "info" | "warning";
log: boolean;
}

export type ObservabilityAttributes = Record<string, SentryPrimitive>;

export type SentryAttributionAttributes = ObservabilityAttributes;
Expand Down
Loading
Loading
0