fix(native): own matching source validation and admission

Separate source corruption and selected-role errors from unexpected derivation failures. Normalize coordinates before body membership and conflict checks, reuse parsed requests, and account for outer observation arrays before validation copies.
This commit is contained in:
morluto committed 2026-10-23 07:27:15 +08:00
1 parent 0281d10130
commit 6b7aa124ed
12 files changed
+947 -282

No files matched your search

+3 -4
View File
@@ -3,7 +3,6 @@ import type { z } from "zod";
import type { functionBodySchema } from "../hopperValues.js";
import type { nativeByteReadSchema } from "./nativeByteRead.js";
import { addressCoordinate } from "./addressCoordinate.js";
import { parseNativeAddress } from "./nativeAddress.js";
export type NativeMatchingCheckpoint = (bytes?: number) => Promise<void>;
interface Interval {
@@ -94,7 +93,7 @@ export class FunctionByteCoverage {
"Cannot append byte observations after fingerprinting",
);
if (read.returned_bytes === 0) return;
const coordinate = addressCoordinate(parseNativeAddress(read.address))!;
const coordinate = addressCoordinate(read.address)!;
let group = this.#pieces.get(coordinate.space);
if (group === undefined) this.#pieces.set(coordinate.space, (group = []));
await this.checkpoint(192 + read.bytes_hex.length * 2);
@@ -162,8 +161,8 @@ export class FunctionByteCoverage {
lengths: string[] = [],
links = new Set<string>();
for (const range of body.ranges) {
const start = addressCoordinate(parseNativeAddress(range.start))!,
end = addressCoordinate(parseNativeAddress(range.end))!;
const start = addressCoordinate(range.start)!,
end = addressCoordinate(range.end)!;
const pieces = this.#pieces.get(start.space) ?? [];
lengths.push(String(end.offset - start.offset + 1n));
let index = firstOverlapping(pieces, start.offset),