Text: add bounded diff APIs #42

Open
opened 2026-12-03 10:24:26 +00:00 by faumaray · 0 comments
Owner

Context: Forge runs selected engines in browser Wasm workers, where inputs are attacker-controlled. Forge tracks this as VL-WASM-01.

Current behavior: Diff.hpp narrows sizes to int, computes combined sizes and retains frontier snapshots for backtracking; line_diff copies lines. No limit or cancellation contract appears in these APIs.

Need: checked arithmetic and limits before expensive allocation: input bytes/elements, trace memory, output size and work. Budget exhaustion must return an explicit incomplete/unavailable result, never a misleading complete diff.

Proposed API: DiffLimits, DiffFailure and diff_bounded/line_diff_bounded overloads, with cancellation checkpoints that do not require reflection or shared browser memory. Additive bounded APIs preserve existing callers.

Tests/gate: empty/equal inputs, unrelated sequences, repetitive lines, arithmetic boundaries, exhausted budgets, cancellation, reconstruction properties and native/Wasm agreement, with measured peak memory in the browser build. Forge gates M09 on this.

Context: Forge runs selected engines in browser Wasm workers, where inputs are attacker-controlled. Forge tracks this as VL-WASM-01. Current behavior: Diff.hpp narrows sizes to int, computes combined sizes and retains frontier snapshots for backtracking; line_diff copies lines. No limit or cancellation contract appears in these APIs. Need: checked arithmetic and limits before expensive allocation: input bytes/elements, trace memory, output size and work. Budget exhaustion must return an explicit incomplete/unavailable result, never a misleading complete diff. Proposed API: DiffLimits, DiffFailure and diff_bounded/line_diff_bounded overloads, with cancellation checkpoints that do not require reflection or shared browser memory. Additive bounded APIs preserve existing callers. Tests/gate: empty/equal inputs, unrelated sequences, repetitive lines, arithmetic boundaries, exhausted budgets, cancellation, reconstruction properties and native/Wasm agreement, with measured peak memory in the browser build. Forge gates M09 on this.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Void/Library#42