Skip to content
Merged
2 changes: 1 addition & 1 deletion docs/kuna-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The background export belongs to the session. `close_binary`, or the end of a CL

The assembly label index is scanned once per export reader. Cancelling a request stops its wait without interrupting other readers; closing the session aborts and drains the shared scan before releasing its files.

Regex procedure and string search uses ECMAScript Unicode matching in a cancellable worker with a five-second matching deadline and a 128 MiB worker heap. Literal matching remains the default. Cancellation or a matching deadline leaves the session available. This release has no runtime override for that deadline or heap.
Regex procedure and string search uses ECMAScript Unicode matching in a cancellable worker with a five-second matching deadline and a worker old-generation heap. Literal matching remains the default. Cancellation or a matching deadline leaves the session available. This release has no runtime override for that deadline. The worker requests 128 MiB. A positive Node.js `--max-old-space-size` on the process that starts REA, including `NODE_OPTIONS`, overrides that request and sets the effective heap. `--max-old-space-size-percentage` takes precedence over that flag in either order. REA does not turn the percentage into a MiB, so the effective heap stays unestablished instead of the 128 MiB request or the absolute flag.

Single-function subprocess output and each cached source facet share a 16 MiB buffered-text capacity. Cached spans are checked before allocation; larger text remains in the local export and the error identifies the file and range. `analyze_function` initially returns the complete dossier, which can still be large; later retained views do not remove that first transfer. Prefer the individual text tools for a focused question.

Expand Down
11 changes: 8 additions & 3 deletions docs/native-investigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,15 @@ Function dossiers retain this same string evidence. Native call edges retain
Hopper's partial `CallReference` classification and exact endpoints; detailed
reference flags remain unavailable rather than being invented.
Regex searches use ECMAScript Unicode syntax in a cancellable worker with a
five-second matching deadline and a 128 MiB worker heap. Deadline or
five-second matching deadline and a worker old-generation heap. Deadline or
cancellation stops matching while leaving the Hopper API available. This
release has no runtime override for that deadline or heap. Literal mode
retains Unicode casefold matching.
release has no runtime override for that deadline. The worker requests 128
MiB. A positive Node.js `--max-old-space-size` on the process that starts
REA, including `NODE_OPTIONS`, overrides that request and sets the effective
heap. `--max-old-space-size-percentage` takes precedence over that flag in
either order. REA does not turn the percentage into a MiB, so the effective
heap stays unestablished instead of the 128 MiB request or the absolute flag.
Literal mode retains Unicode casefold matching.

## Bounded static traces

Expand Down
49 changes: 49 additions & 0 deletions src/process/ArtifactAnalysisResources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,13 @@ it("says REA retains the tighter inherited limit when a producer signal fires",
expect(projected.remediation.action).toContain(
"This release has no runtime override",
);
expect(projected.remediation.action).toContain(
"an unchanged retry may succeed or may fail the same way",
);
expect(projected.remediation.action).not.toContain(
"Repeating the unchanged request fails the same way.",
);
expect(projected.retryable).toBe(true);
expect(projected.details).toMatchObject({
reported_limits: { cpu_seconds: 30 },
});
Expand All @@ -562,6 +569,48 @@ it("says REA retains the tighter inherited limit when a producer signal fires",
}
});

it("keeps an unchanged SIGXFSZ retry uncertain when the inherited limit was not reported", async () => {
const resources = new ArtifactAnalysisResources(
"fixture",
"inspect_packet_fields",
readStableArtifact,
readLinuxResourceLimits,
{ message: "busy", details: {} },
);
const empty = { text: "", bytes: 0, observedBytes: 0 };
const failure = new OwnedCommandFailure("process", "producer signal", {
stdout: empty,
stderr: empty,
exitCode: null,
signal: "SIGXFSZ",
});
try {
const projected = projectAnalysisError(
resources.commandFailure(
failure,
{ command_timeout_ms: 30_000, output_bytes: 4_194_304 },
undefined,
),
);
expect(projected.remediation.action).toContain(
"The effective inherited limit was not reported.",
);
expect(projected.remediation.action).toContain(
"an unchanged retry may succeed or may fail the same way",
);
expect(projected.remediation.action).not.toContain(
"Repeating the unchanged request fails the same way.",
);
expect(projected.retryable).toBe(true);
expect(projected.details).toMatchObject({
resource: "file-size",
reported_limits: null,
});
} finally {
await resources.close();
}
});

it("treats a fixed command-output cap as a non-retryable capture allowance", async () => {
const resources = new ArtifactAnalysisResources(
"fixture",
Expand Down
5 changes: 4 additions & 1 deletion src/process/ArtifactAnalysisResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,17 @@ export class ArtifactAnalysisResources {
effectiveLimits === undefined
? "The effective inherited limit was not reported."
: `The effective inherited limits are ${String(effectiveLimits.address_space_bytes)} bytes of address space, ${String(effectiveLimits.file_bytes)} bytes per file, and ${String(effectiveLimits.cpu_seconds)} CPU seconds.`;
// A producer can raise SIGXCPU/SIGXFSZ without exhausting the retained
// rlimit, so an unchanged retry is not a proven failure.
return new AnalysisResourceConstraintError(
operation,
signal === "SIGXFSZ" ? "file-size" : "cpu",
`Producer terminated with ${signal}; the signal's exact cause is not independently established.`,
effectiveLimits === undefined ? null : { ...effectiveLimits },
{
...detail,
remediationAction: `${reported} REA retains the tighter inherited limit. This release has no runtime override for that ceiling. A smaller artifact may finish inside the retained limit. Repeating the unchanged request fails the same way.`,
retryable: true,
remediationAction: `${reported} REA retains the tighter inherited limit. This release has no runtime override for that ceiling. A smaller artifact may finish inside the retained limit. The signal does not prove that ceiling was exhausted, so an unchanged retry may succeed or may fail the same way.`,
},
);
}
Expand Down
202 changes: 202 additions & 0 deletions src/process/RegexMatcher.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
import { expect, it } from "vitest";

import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
import {
regexMatchingLimitation,
regexWorkerHeapError,
resolveRegexWorkerHeap,
type RegexWorkerHeapLimit,
} from "./RegexMatcher.js";

const effective = (mib: number, overridden: boolean): RegexWorkerHeapLimit => ({
kind: "effective",
mib,
overridden,
});

it.each([
{
name: "uses the 128 MiB request when no flag is set",
execArgv: [],
nodeOptions: undefined,
heap: effective(128, false),
},
{
name: "lets a smaller execArgv flag override the request",
execArgv: ["--max-old-space-size=64"],
nodeOptions: undefined,
heap: effective(64, true),
},
{
name: "lets a larger execArgv flag override the request",
execArgv: ["--require", "./preload.js", "--max_old_space_size=256"],
nodeOptions: undefined,
heap: effective(256, true),
},
{
name: "reads a positive NODE_OPTIONS flag that is absent from execArgv",
execArgv: [],
nodeOptions: "--no-warnings --max-old-space-size=192",
heap: effective(192, true),
},
{
name: "lets the last execArgv flag win over NODE_OPTIONS",
execArgv: ["--max-old-space-size=256"],
nodeOptions: "--max-old-space-size=96",
heap: effective(256, true),
},
{
name: "treats a final zero flag as leaving the 128 MiB request in effect",
execArgv: ["--max-old-space-size=0"],
nodeOptions: "--max-old-space-size=256",
heap: effective(128, false),
},
{
name: "accepts quoted NODE_OPTIONS and a leading plus or zeros",
execArgv: ["--max-old-space-size=+0256"],
nodeOptions: '"--max-old-space-size=144"',
heap: effective(256, true),
},
{
name: "uses the last positive flag",
execArgv: ["--max-old-space-size=256", "--max-old-space-size=96"],
nodeOptions: undefined,
heap: effective(96, true),
},
{
name: "leaves the effective heap unknown for an unparsed flag",
execArgv: ["--max-old-space-size=256.5"],
nodeOptions: undefined,
heap: { kind: "unknown" } as const,
},
{
name: "keeps a later positive flag after an unparsed one",
execArgv: ["--max-old-space-size=256.5", "--max-old-space-size=80"],
nodeOptions: undefined,
heap: effective(80, true),
},
{
name: "leaves an untokenizable NODE_OPTIONS value unknown until execArgv decides",
execArgv: [],
nodeOptions: '"--max-old-space-size=256',
heap: { kind: "unknown" } as const,
},
{
name: "lets execArgv decide when NODE_OPTIONS cannot be tokenized",
execArgv: ["--max-old-space-size=80"],
nodeOptions: '"--max-old-space-size=256',
heap: effective(80, true),
},
{
name: "leaves a percentage flag unestablished instead of the 128 MiB request",
execArgv: ["--max-old-space-size-percentage=50"],
nodeOptions: undefined,
heap: { kind: "unknown" } as const,
},
{
name: "lets a percentage flag win over a later absolute flag",
execArgv: ["--max-old-space-size-percentage=50", "--max-old-space-size=64"],
nodeOptions: undefined,
heap: { kind: "unknown" } as const,
},
{
name: "lets a percentage flag win over an earlier absolute flag",
execArgv: ["--max-old-space-size=64", "--max-old-space-size-percentage=50"],
nodeOptions: undefined,
heap: { kind: "unknown" } as const,
},
{
name: "lets a NODE_OPTIONS percentage win over an execArgv absolute flag",
execArgv: ["--max-old-space-size=64"],
nodeOptions: "--max-old-space-size-percentage=50",
heap: { kind: "unknown" } as const,
},
{
name: "lets an execArgv percentage win over a NODE_OPTIONS absolute flag",
execArgv: ["--max-old-space-size-percentage=50"],
nodeOptions: "--max-old-space-size=64",
heap: { kind: "unknown" } as const,
},
{
name: "recognizes an underscore percentage flag",
execArgv: ["--max_old_space_size_percentage=50"],
nodeOptions: undefined,
heap: { kind: "unknown" } as const,
},
{
name: "recognizes a percentage flag split from its value",
execArgv: [
"--max-old-space-size=64",
"--max-old-space-size-percentage",
"50",
],
nodeOptions: undefined,
heap: { kind: "unknown" } as const,
},
{
name: "does not let a later absolute flag replace an invalid percentage",
execArgv: ["--max-old-space-size-percentage=0", "--max-old-space-size=64"],
nodeOptions: undefined,
heap: { kind: "unknown" } as const,
},
{
name: "leaves a fractional percentage unestablished",
execArgv: ["--max-old-space-size-percentage=50.5"],
nodeOptions: undefined,
heap: { kind: "unknown" } as const,
},
{
name: "does not treat a final zero absolute flag as 128 MiB after a percentage",
execArgv: ["--max-old-space-size-percentage=50", "--max-old-space-size=0"],
nodeOptions: undefined,
heap: { kind: "unknown" } as const,
},
] as const)(
"resolveRegexWorkerHeap $name",
({ execArgv, nodeOptions, heap }) => {
expect(resolveRegexWorkerHeap(execArgv, nodeOptions)).toEqual(heap);
},
);

it("describes the effective heap and keeps the deadline fixed", () => {
for (const heap of [
effective(128, false),
effective(256, true),
{ kind: "unknown" } as const,
]) {
const limitation = regexMatchingLimitation(heap);
expect(limitation).toContain(
"This release has no runtime override for the deadline.",
);
expect(limitation).not.toContain("either cap");
expect(limitation).not.toContain("no runtime override for the heap");
const projected = projectAnalysisError(
regexWorkerHeapError("search_procedures", new Error("heap"), heap),
);
expect(projected.remediation.action).not.toContain("no runtime override");
expect(projected.remediation.action).toContain("--max-old-space-size");
expect(projected.remediation.action).toContain(
"--max-old-space-size-percentage",
);
if (heap.kind === "unknown") {
expect(limitation).toContain("was not established");
expect(limitation).toContain("--max-old-space-size-percentage");
expect(projected.message).toContain("was not established");
expect(projected.details).toMatchObject({
reported_limits: { requested_worker_heap_mib: 128 },
});
expect(projected.details?.reported_limits).toEqual({
requested_worker_heap_mib: 128,
});
} else {
expect(limitation).toContain(`effective ${String(heap.mib)} MiB`);
expect(projected.message).toContain(`effective ${String(heap.mib)} MiB`);
expect(projected.details).toMatchObject({
reported_limits: {
worker_heap_mib: heap.mib,
requested_worker_heap_mib: 128,
},
});
}
}
});
Loading
Loading