mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 05:32:44 +00:00
refactor(process): build provider captured output through one owner (#11330)
* refactor(process): build provider captured output through one owner * fix(process): report only declared diagnostics on successful provider results
This commit is contained in:
1 parent
264dcd5fee
commit
0d35ea065d
25 files changed
+198
-147
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { capturedProviderOutput } from "./capturedProviderOutput.js";
|
||||
import {
|
||||
AnalysisCleanupLease,
|
||||
AnalysisCleanupLeaseGroup,
|
||||
@@ -91,16 +92,6 @@ export type ArtifactResourceClassifier = (
|
||||
context: ArtifactResourceFailureContext,
|
||||
) => AnalysisError;
|
||||
|
||||
export const artifactCommandOutput = (
|
||||
snapshot: ProviderProcessSnapshot,
|
||||
): AnalysisCapturedOutput => ({
|
||||
stdout: snapshot.stdout.text,
|
||||
stderr: snapshot.stderr.text,
|
||||
truncated: snapshot.diagnosticTruncated ?? false,
|
||||
exit_code: snapshot.exitCode ?? null,
|
||||
signal: snapshot.signal ?? null,
|
||||
});
|
||||
|
||||
/** Own admission, artifact descriptors, producer cleanup and private workspaces together. */
|
||||
export class ArtifactAnalysisResources {
|
||||
readonly #artifacts: {
|
||||
@@ -479,7 +470,7 @@ export class ArtifactAnalysisResources {
|
||||
): ProviderOutcomeContext {
|
||||
return {
|
||||
operation,
|
||||
capturedOutput: artifactCommandOutput,
|
||||
capturedOutput: capturedProviderOutput,
|
||||
timeout: {
|
||||
ms: limits.command_timeout_ms,
|
||||
userMessage: `The owned producer command reached its ${String(limits.command_timeout_ms)} ms deadline. This is not a client-side timeout; extending only the MCP client's deadline does not change this budget.`,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
capturedProviderOutput,
|
||||
providerResultDiagnostics,
|
||||
} from "./capturedProviderOutput.js";
|
||||
import type { ProviderProcessSnapshot } from "./ProviderProcess.js";
|
||||
|
||||
const snapshot = (
|
||||
overrides: Partial<ProviderProcessSnapshot> = {},
|
||||
): ProviderProcessSnapshot => ({
|
||||
stdout: { text: "head", bytes: 4, observedBytes: 4096 },
|
||||
stderr: { text: "", bytes: 0, observedBytes: 0 },
|
||||
exitCode: undefined,
|
||||
signal: undefined,
|
||||
...overrides,
|
||||
});
|
||||
|
||||
it("keeps the retained text beside the bytes the process wrote", () => {
|
||||
expect(
|
||||
capturedProviderOutput(snapshot({ diagnosticTruncated: true })),
|
||||
).toEqual({
|
||||
stdout: "head",
|
||||
stderr: "",
|
||||
stdout_bytes: 4096,
|
||||
stderr_bytes: 0,
|
||||
exit_code: null,
|
||||
signal: null,
|
||||
truncated: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("narrows to the three fields a successful result declares", () => {
|
||||
expect(
|
||||
providerResultDiagnostics(
|
||||
capturedProviderOutput(snapshot({ exitCode: 0, signal: null })),
|
||||
),
|
||||
).toStrictEqual({ stdout: "head", stderr: "", truncated: false });
|
||||
});
|
||||
|
||||
it("reports exit facts and an untruncated capture as observed", () => {
|
||||
expect(
|
||||
capturedProviderOutput(snapshot({ exitCode: 2, signal: null })),
|
||||
).toMatchObject({ exit_code: 2, signal: null, truncated: false });
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { AnalysisCapturedOutput } from "../domain/analysisErrorBase.js";
|
||||
import type { ProviderProcessSnapshot } from "./ProviderProcess.js";
|
||||
|
||||
/**
|
||||
* The diagnostic a failure carries for one supervised provider process.
|
||||
*
|
||||
* Text is what the supervisor retained; the byte counts are what the process
|
||||
* wrote, so a consumer can tell how much the retained text omits. `truncated`
|
||||
* is the supervisor's own flag, which already includes provider output loss.
|
||||
*/
|
||||
export const capturedProviderOutput = (
|
||||
snapshot: ProviderProcessSnapshot,
|
||||
): AnalysisCapturedOutput => ({
|
||||
stdout: snapshot.stdout.text,
|
||||
stderr: snapshot.stderr.text,
|
||||
stdout_bytes: snapshot.stdout.observedBytes,
|
||||
stderr_bytes: snapshot.stderr.observedBytes,
|
||||
exit_code: snapshot.exitCode ?? null,
|
||||
signal: snapshot.signal ?? null,
|
||||
truncated: snapshot.diagnosticTruncated === true,
|
||||
});
|
||||
|
||||
/** The retained text and truncation flag a successful result reports as its diagnostics. */
|
||||
export interface ProviderResultDiagnostics {
|
||||
readonly stdout: string;
|
||||
readonly stderr: string;
|
||||
readonly truncated: boolean;
|
||||
}
|
||||
|
||||
/** Narrow a captured output to the diagnostics a successful result declares. */
|
||||
export const providerResultDiagnostics = ({
|
||||
stdout,
|
||||
stderr,
|
||||
truncated,
|
||||
}: AnalysisCapturedOutput): ProviderResultDiagnostics => ({
|
||||
stdout,
|
||||
stderr,
|
||||
truncated,
|
||||
});
|
||||
Reference in new issue
Block a user