diff --git a/src/artifacts/deno/DenoStandaloneArtifactReader.test.ts b/src/artifacts/deno/DenoStandaloneArtifactReader.test.ts index 976f703c83..c4f3787da3 100644 --- a/src/artifacts/deno/DenoStandaloneArtifactReader.test.ts +++ b/src/artifacts/deno/DenoStandaloneArtifactReader.test.ts @@ -1121,6 +1121,46 @@ it("keeps a native Intel host whose __DATA segment stores an Intel Deno executab expect(snapshot.manifest.root_format).not.toBe("deno-standalone"); }); +it("ignores embedded Intel sentinels in out-of-order overlapping segments and accepts a trailer at their end", async () => { + const section = buildDenoSection(); + const trailer = denoIntelTrailer(section).subarray(-section.length - 24); + const segmentSize = 72; + const header = Buffer.alloc(32 + 3 * segmentSize); + header.writeUInt32LE(0xfeedfacf, 0); + header.writeUInt32LE(0x01000007, 4); + header.writeUInt32LE(2, 12); + header.writeUInt32LE(3, 16); + header.writeUInt32LE(3 * segmentSize, 20); + const start = header.length; + const middle = start + trailer.length; + const end = middle + trailer.length; + const segments = [ + [middle, end], + [start, middle], + [start + 1, middle + 1], + ] as const; + for (const [index, [from, to]] of segments.entries()) { + const at = 32 + index * segmentSize; + header.writeUInt32LE(0x19, at); + header.writeUInt32LE(segmentSize, at + 4); + header.write("__DATA", at + 8, "ascii"); + header.writeBigUInt64LE(BigInt(to - from), at + 32); + header.writeBigUInt64LE(BigInt(from), at + 40); + header.writeBigUInt64LE(BigInt(to - from), at + 48); + } + const native = Buffer.concat([header, trailer, trailer]); + await expect( + locateDenoStandalone(bytesHandle(native), native.length), + ).resolves.toEqual({ status: "absent" }); + const application = Buffer.concat([native, trailer]); + await expect( + locateDenoStandalone(bytesHandle(application), application.length), + ).resolves.toMatchObject({ + status: "present", + location: { offset: end + 24, length: section.length }, + }); +}); + it("reads an Intel trailer that __LINKEDIT extends over", async () => { const section = buildDenoSection(); const trailer = denoIntelTrailer(section); diff --git a/src/browser/PlaywrightBrowserScenarioProvider.ts b/src/browser/PlaywrightBrowserScenarioProvider.ts index b1004ec1d5..b075057db1 100644 --- a/src/browser/PlaywrightBrowserScenarioProvider.ts +++ b/src/browser/PlaywrightBrowserScenarioProvider.ts @@ -28,8 +28,6 @@ import { } from "../domain/browserScenarioCapture.js"; import { classifyBrowserScenarioCompleteness, - browserScenarioStepSchema, - browserStepArtifactsSchema, type BrowserScenarioCompleteness, type BrowserScenarioCompletenessSection, type BrowserScenarioStep, @@ -94,14 +92,14 @@ const unavailableArtifacts = ( requested.has(kind) ? { state: "missing" as const, reason } : { state: "not_requested" as const }; - return browserStepArtifactsSchema.parse({ + return { screenshot: state("screenshot"), dom: state("dom"), accessibility: state("accessibility"), url: state("url"), history: state("history"), storage: state("storage"), - }); + }; }; const stepCompleteness = ( @@ -130,21 +128,23 @@ const createStep = ( readonly eventEnd: number; readonly artifacts: BrowserStepArtifacts; } & BrowserScenarioStepOutcome, -): BrowserScenarioStep => - browserScenarioStepSchema.parse({ +): BrowserScenarioStep => { + const base = { step_index: input.stepIndex, step_id: input.stepId, action: input.action, - status: input.status, elapsed_ms: input.elapsedMs, before_url: input.beforeUrl, after_url: input.afterUrl, - error: input.error, event_sequence_start: input.eventStart, event_sequence_end: input.eventEnd, artifacts: input.artifacts, completeness: stepCompleteness(input.artifacts, input.status), - }); + }; + return input.status === "completed" + ? { ...base, status: "completed", error: null } + : { ...base, status: input.status, error: input.error }; +}; const initialStep = async (input: { readonly session: BrowserScenarioSessionPort; diff --git a/src/contracts/advertisedDialectProjection.ts b/src/contracts/advertisedDialectProjection.ts index 47e8515b1c..2953cd5f50 100644 --- a/src/contracts/advertisedDialectProjection.ts +++ b/src/contracts/advertisedDialectProjection.ts @@ -335,9 +335,12 @@ const nullableForm = (out: Schema): Schema => { /** One projection: guidance sentences accumulate while the schema is built. */ class DialectProjection { readonly notes: string[] = []; + readonly #seenNotes = new Set(); note(sentence: string): void { - if (!this.notes.includes(sentence)) this.notes.push(sentence); + if (this.#seenNotes.has(sentence)) return; + this.#seenNotes.add(sentence); + this.notes.push(sentence); } project(value: unknown, path: string): unknown { diff --git a/src/contracts/inputSchemaPresentation.ts b/src/contracts/inputSchemaPresentation.ts index 43e9afb33d..42ceea9682 100644 --- a/src/contracts/inputSchemaPresentation.ts +++ b/src/contracts/inputSchemaPresentation.ts @@ -137,13 +137,16 @@ const sharedRequiredProperties = ( branches: readonly Readonly>[], ): readonly string[] => { const [first = [], ...others] = branches.map(requiredProperties); - return first.filter((name) => others.every((names) => names.includes(name))); + if (first.length === 0 || others.length === 0) return first; + const otherSets = others.map((names) => new Set(names)); + return first.filter((name) => otherSets.every((names) => names.has(name))); }; const inputGroup = (branch: Readonly>): string => { const required = requiredProperties(branch); + const requiredSet = new Set(required); const optional = Object.keys(branch.properties ?? {}) - .filter((name) => !required.includes(name)) + .filter((name) => !requiredSet.has(name)) .map((name) => `[${name}]`); return [...required, ...optional].join(" + "); }; diff --git a/src/dotnet/ManagedMemberInspector.ts b/src/dotnet/ManagedMemberInspector.ts index 68c775d436..abd3c02686 100644 --- a/src/dotnet/ManagedMemberInspector.ts +++ b/src/dotnet/ManagedMemberInspector.ts @@ -435,14 +435,15 @@ export const inspectManagedMembersBytes = ( ); appendManagedParseIssues(issues, targets.issues); const incompleteMembers = - [...fields.fields, ...memberRefs.refs].some( + fields.fields.some( + (member) => member.signature.parse_status !== "decoded", + ) || + memberRefs.refs.some( (member) => member.signature.parse_status !== "decoded", ) || - resolvedMethods.some( - (method) => method.signature.parse_status !== "decoded", - ) || resolvedMethods.some( (method) => + method.signature.parse_status !== "decoded" || method.body.status === "partial" || method.body.status === "malformed", );