mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-28 04:41:52 +01:00
refactor(observability): stop writing detailed per-step timing to the run log (#10776)
## Thinking Path > - Paperclip tracks agent work for the team. > - The startup timing path already emits detailed spans. > - The run log repeats the same detailed timing. > - That makes the event larger than it needs to be. > - This pull request removes the redundant per-step timing fields from the run-log payload. > - The benefit is a smaller log with the same detail still available in traces. ## Linked Issues or Issue Description No public GitHub issue or open pull request matches this change. I described the enhancement below. **What existing behavior does this improve?** `run.startup.step` event output. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** `run.startup.step` writes `roundTrips`, `providerExecMs`, `providerGetMs`, `createRuntimeMs`, and `ensureSessionMs`. The same detail already exists in the spans. **Proposed behavior** `run.startup.step` keeps only `step`, `durationMs`, and `outcome`. The heartbeat lifecycle timestamps stay unchanged. **Reason and benefit** This change removes redundant data from the run log. It keeps the useful detail in trace spans. It also makes the payload smaller and easier to read. The revert path stays clear because the removed data has one producer chain. **Breaking changes** Yes. Consumers that read the removed fields must switch to span data or the remaining event fields. The heartbeat lifecycle timestamps do not change. **Additional context** I searched GitHub for related open PRs and issues. I found no match. ## What Changed - Removed the redundant per-step timing fields from the run-log payload. - Removed the now-dead producer chain that fed those fields. - Kept the span-level timing data and the heartbeat lifecycle timestamps. ## Verification - `adapter-utils` typecheck clean - `server` typecheck clean - `startup-timing` suite: 30 passed - `adapter-utils` `execute` suite: 99 passed - `server` `environment-execution-target` suite: 21 passed ## Risks - Consumers that still read the removed fields will need a code change. - This is a one-way-door data removal for the run log. ## Model Used OpenAI Codex, GPT-5, tool use enabled. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs: #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
18f391ef02
commit
6a69a3d6b0
8 files changed
+86
-416
No files matched your search
@@ -367,7 +367,7 @@ describe("resolveEnvironmentExecutionTarget", () => {
|
||||
expect(target).not.toHaveProperty("paperclipApiUrl");
|
||||
});
|
||||
|
||||
it("exposes a sandbox runner that counts round-trips and accumulates provider durations", async () => {
|
||||
it("exposes a sandbox runner with single-stream stdin upload disabled", async () => {
|
||||
mockResolveEnvironmentDriverConfigForRuntime.mockResolvedValue({
|
||||
driver: "sandbox",
|
||||
config: {
|
||||
@@ -377,8 +377,6 @@ describe("resolveEnvironmentExecutionTarget", () => {
|
||||
},
|
||||
});
|
||||
|
||||
// Each exec reports its provider-boundary durations on the free-form result
|
||||
// metadata (the Daytona plugin does this); the runner accumulates them.
|
||||
const environmentRuntime = {
|
||||
execute: vi.fn().mockResolvedValue({
|
||||
exitCode: 0,
|
||||
@@ -404,66 +402,18 @@ describe("resolveEnvironmentExecutionTarget", () => {
|
||||
|
||||
const runner = (target as { runner?: {
|
||||
supportsSingleStreamStdinProgress?: boolean;
|
||||
execCount(): number;
|
||||
providerExecMs(): number;
|
||||
providerGetMs(): number;
|
||||
execute(input: { command: string; args?: string[] }): Promise<unknown>;
|
||||
} }).runner;
|
||||
expect(runner).toBeTruthy();
|
||||
// Single-stream stdin upload is enabled (research A1 / PAP-3159 #2): a
|
||||
// ≤96 MiB writeFile collapses to one round-trip.
|
||||
// Provider-backed sandbox RPCs do not surface bounded mid-stream progress
|
||||
// for a single stdin upload, so the runner leaves the capability disabled.
|
||||
expect(runner!.supportsSingleStreamStdinProgress).toBe(false);
|
||||
expect(runner!.execCount()).toBe(0);
|
||||
expect(runner!.providerExecMs()).toBe(0);
|
||||
expect(runner!.providerGetMs()).toBe(0);
|
||||
|
||||
// The exec seam still runs each command; the run-log no longer carries the
|
||||
// detailed per-step round-trip or provider-duration counts.
|
||||
await runner!.execute({ command: "echo", args: ["a"] });
|
||||
await runner!.execute({ command: "echo", args: ["b"] });
|
||||
|
||||
expect(runner!.execCount()).toBe(2);
|
||||
expect(runner!.providerExecMs()).toBe(1200);
|
||||
expect(runner!.providerGetMs()).toBe(30);
|
||||
});
|
||||
|
||||
it("tolerates a provider result with no timing metadata (counts the round-trip, accumulates nothing)", async () => {
|
||||
mockResolveEnvironmentDriverConfigForRuntime.mockResolvedValue({
|
||||
driver: "sandbox",
|
||||
config: { provider: "fake-plugin", reuseLease: false, timeoutMs: 30_000 },
|
||||
});
|
||||
|
||||
const environmentRuntime = {
|
||||
execute: vi.fn().mockResolvedValue({
|
||||
exitCode: 0,
|
||||
signal: null,
|
||||
timedOut: false,
|
||||
stdout: "",
|
||||
stderr: "",
|
||||
}),
|
||||
supportsSync: vi.fn().mockReturnValue(false),
|
||||
};
|
||||
|
||||
const target = await resolveEnvironmentExecutionTarget({
|
||||
db: {} as never,
|
||||
companyId: "company-1",
|
||||
adapterType: "codex_local",
|
||||
environment: { id: "env-1", driver: "sandbox", config: { provider: "fake-plugin" } },
|
||||
leaseId: "lease-1",
|
||||
leaseMetadata: { remoteCwd: "/workspace" },
|
||||
lease: { id: "lease-1" } as never,
|
||||
environmentRuntime: environmentRuntime as never,
|
||||
});
|
||||
|
||||
const runner = (target as { runner?: {
|
||||
execCount(): number;
|
||||
providerExecMs(): number;
|
||||
providerGetMs(): number;
|
||||
execute(input: { command: string }): Promise<unknown>;
|
||||
} }).runner;
|
||||
await runner!.execute({ command: "echo" });
|
||||
|
||||
expect(runner!.execCount()).toBe(1);
|
||||
expect(runner!.providerExecMs()).toBe(0);
|
||||
expect(runner!.providerGetMs()).toBe(0);
|
||||
expect(environmentRuntime.execute).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
// A recording tracer that captures each provider-exec span's name, attribute
|
||||
|
||||
@@ -214,20 +214,6 @@ export async function resolveEnvironmentExecutionTarget(input: {
|
||||
? input.leaseMetadata.shellCommand
|
||||
: null;
|
||||
|
||||
// Per-lease-runner cumulative counters for startup-step attribution (Open
|
||||
// Q1). Closed over by the `runner.execute` seam below and read back as
|
||||
// deltas by `measureStartupStep`.
|
||||
let execCount = 0;
|
||||
let providerExecMs = 0;
|
||||
let providerGetMs = 0;
|
||||
const accumulateProviderDurations = (metadata: Record<string, unknown> | undefined): void => {
|
||||
if (!metadata) return;
|
||||
const exec = metadata.durationMs;
|
||||
const get = metadata.getDurationMs;
|
||||
if (typeof exec === "number" && Number.isFinite(exec)) providerExecMs += exec;
|
||||
if (typeof get === "number" && Number.isFinite(get)) providerGetMs += get;
|
||||
};
|
||||
|
||||
// The low-cardinality public provider family. A plugin-backed / operator-
|
||||
// defined key maps to `plugin`, so a raw unbounded key never rides a span.
|
||||
const providerFamily = normalizeProviderFamily(parsed.config.provider);
|
||||
@@ -255,17 +241,7 @@ export async function resolveEnvironmentExecutionTarget(input: {
|
||||
// here. The client falls back to the chunked upload path when this is
|
||||
// false.
|
||||
supportsSingleStreamStdinProgress: false,
|
||||
// Round-trip counter + provider-duration accumulators on the single
|
||||
// host→sandbox exec seam (Open Q1). `measureStartupStep` reads the
|
||||
// per-step delta of each via the `() => number` closures below. The
|
||||
// provider durations ride the exec result's free-form `metadata`
|
||||
// (set by the Daytona plugin), so no protocol/schema change is
|
||||
// needed and providers that omit them simply accumulate nothing.
|
||||
execCount: () => execCount,
|
||||
providerExecMs: () => providerExecMs,
|
||||
providerGetMs: () => providerGetMs,
|
||||
execute: async (commandInput) => {
|
||||
execCount += 1;
|
||||
// Record true start and stop timestamps around the provider await,
|
||||
// so the exec span and the result carry a real wall time.
|
||||
const startedAtMs = Date.now();
|
||||
@@ -324,7 +300,6 @@ export async function resolveEnvironmentExecutionTarget(input: {
|
||||
const finishedAtMs = Date.now();
|
||||
const finishedAt = new Date(finishedAtMs).toISOString();
|
||||
const durationMs = finishedAtMs - startedAtMs;
|
||||
accumulateProviderDurations(result.metadata);
|
||||
// `setSandboxExecSpanAttributes` sets ONLY the closed
|
||||
// `paperclip.sandbox.startup.exec.*` allowlist: the normalized
|
||||
// provider family, the clamped command label, the numeric exit
|
||||
|
||||
Reference in new issue
Block a user