moon_vcdiff

A pure MoonBit RFC 3284 VCDIFF encoder, decoder, inspector, and CLI

vcdiff
delta
binary
rfc3284
compression
moon add yangxixi00/moon_vcdiff@0.1.0
Download zip
Version
0.1.0
License
Apache-2.0
Last updated
6 hours ago
Downloads
3

Dependencies

README

#MoonVCDIFF

MoonVCDIFF is an original, pure MoonBit implementation of the VCDIFF binary delta format defined by RFC 3284. It provides deterministic encoding, defensive decoding, structural analysis, verification, and a native CLI without wrapping a C implementation.

#English

#What works in 0.1.0

  • Standard VCDIFF file and window headers, with canonical RFC varints.
  • ADD, RUN, COPY, the default 256-entry code table, and compound opcodes.
  • SELF, HERE, four NEAR modes, three SAME modes, and cache rotation.
  • VCD_SOURCE, VCD_TARGET, multiple windows, and overlapping target COPY.
  • Deterministic windowing, hash-chain matching, target matches, and RUN finding.
  • Inspect, trace, statistics, audit, index, canonicalize, and verify APIs.
  • Explicit output, window, window-count, and instruction-count limits.
  • Native CLI; library validation on native, JavaScript, Wasm, and WasmGC.

Secondary compression and custom code tables are deliberately unsupported in 0.1.0. Their header flags produce UnsupportedFeature with a byte offset.

#Install

moon add yangxixi00/moon_vcdiff@0.1.0

Import the package in moon.pkg:

///|
import {
"yangxixi00/moon_vcdiff" @vcdiff,
}

#Library example

let source = b"the original document"
let target = b"the revised document"
let delta = @vcdiff.encode(
source,
target,
@vcdiff.default_encode_options(),
)
let decoded = @vcdiff.decode(
source,
delta,
@vcdiff.default_decode_limits(),
)
assert_eq(decoded, target)
let summary = @vcdiff.inspect(delta)
println(summary.to_json())

The main APIs are:

  • encode(source, target, options) -> Bytes
  • decode(source, delta, limits) -> Bytes
  • inspect(delta) -> DeltaSummary
  • verify(source, delta, expected) -> VerifyReport
  • trace(delta), statistics(delta), and non-throwing audit(...)
  • index_delta(delta), canonicalize(delta), and decode_range(...)

Use named profiles when an application needs stable policy choices: Fast, Balanced, Compact, and SmallMemory for encoding; Embedded, Interactive, Service, and Archive for decoding.

#CLI

Build or run the native executable from this repository:

moon run cmd/main -- encode old.bin new.bin patch.vcdiff --profile balanced moon run cmd/main -- decode old.bin patch.vcdiff restored.bin --profile service moon run cmd/main -- inspect patch.vcdiff --format json moon run cmd/main -- trace patch.vcdiff --format text moon run cmd/main -- stats patch.vcdiff --format json moon run cmd/main -- audit old.bin patch.vcdiff --max-output 64MiB moon run cmd/main -- verify old.bin patch.vcdiff new.bin

Pass - as the source path for source-free compression. Successful commands return 0, file/usage failures return 1, and invalid deltas or verification mismatches return 2. Run moon run cmd/main -- --help for every option.

#Security and compatibility

Decode untrusted files with an explicit DecodeLimits or a named profile. MoonVCDIFF rejects non-canonical integers, truncated sections, conflicting window flags, integer overflow, invalid addresses, and declared-length mismatches. See SECURITY.md and SUPPORTED_FORMAT.md for the exact boundary.

Bidirectional compatibility was checked against Google open-vcdiff 0.8.4 as an external oracle; see INTEROPERABILITY.md. No oracle source is copied or shipped. Reproducible local benchmark results are in BENCHMARKS.md.

#中文

MoonVCDIFF 是依据 RFC 3284 独立编写的纯 MoonBit 二进制增量编解码库, 同时提供原生 CLI。它不封装 C/C++ 实现,核心库可在 native、JavaScript、 Wasm 与 WasmGC 后端编译和测试。

#安装与使用

moon add yangxixi00/moon_vcdiff@0.1.0

moon.pkg 中导入 "yangxixi00/moon_vcdiff" @vcdiff,随后调用 encode 生成增量,调用 decode 还原目标;inspect 可在不需要源文件的 情况下查看窗口和指令统计,verify 会执行还原并比较预期结果。

CLI 示例:

moon run cmd/main -- encode 旧文件.bin 新文件.bin 更新.vcdiff -p balanced moon run cmd/main -- decode 旧文件.bin 更新.vcdiff 还原文件.bin -p service moon run cmd/main -- inspect 更新.vcdiff -f json moon run cmd/main -- verify 旧文件.bin 更新.vcdiff 新文件.bin

无源压缩时把源文件参数写成 -。编码器对相同输入和配置产生字节稳定的 输出。解码不可信数据时建议使用 EmbeddedInteractiveService 或自定义 DecodeLimits,避免目标数据引发过量内存和指令消耗。

#项目状态

0.1.0 已覆盖默认代码表、全部标准地址模式、多窗口、源/目标字典、窗口内 重叠 COPY、确定性匹配、安全限制、结构检查和 JSON 报告。二级压缩器与 自定义代码表尚不支持,遇到相应标志会明确报错,不会静默误解码。

#Development

moon fmt --check moon check --target all --deny-warn moon build --target all --deny-warn moon test --target all --deny-warn pwsh ./scripts/count-production-lines.ps1 moon package --frozen

The CI runs the same matrix, coverage analysis, CLI acceptance tests, generated interface drift detection, a 4,000–4,700 production-line gate, and frozen Mooncakes packaging. The stable baseline is recorded in TOOLCHAIN.md.

#License

Apache-2.0. Copyright 2026 yangxixi00.

#
VcdiffError

pub(all) suberror VcdiffError {
InvalidMagic(offset~ : Int)
UnsupportedVersion(offset~ : Int, version~ : Int)
UnsupportedFeature(offset~ : Int, feature~ : String)
TruncatedInput(offset~ : Int, needed~ : Int, available~ : Int)
InvalidVarint(offset~ : Int, reason~ : String)
IntegerOverflow(offset~ : Int)
InvalidHeader(offset~ : Int, reason~ : String)
InvalidWindow(offset~ : Int, reason~ : String)
InvalidInstruction(offset~ : Int, reason~ : String)
InvalidAddress(offset~ : Int, address~ : Int, limit~ : Int)
MissingSource(offset~ : Int)
ResourceLimit(offset~ : Int, resource~ : String, limit~ : Int)
LengthMismatch(offset~ : Int, expected~ : Int, actual~ : Int)
VerificationMismatch(offset~ : Int, expected_size~ : Int, actual_size~ : Int)
InvalidOption(option~ : String, reason~ : String)
Io(path~ : String, reason~ : String)
} derive(Eq,
Debug
)

Checked failures raised while reading, writing, or verifying VCDIFF data. Every format failure carries the byte offset at which it was detected.

#
VcdiffError::code

fn VcdiffError::code(self : VcdiffError) -> String

Returns a stable machine-readable category for a VCDIFF error.

#
VcdiffError::message

fn VcdiffError::message(self : VcdiffError) -> String

Returns a concise human-readable explanation without losing the category.

#
VcdiffError::offset

fn VcdiffError::offset(self : VcdiffError) -> Int

Returns the most specific byte offset available for this error. Configuration and I/O failures do not refer to delta bytes and return -1.

#
VcdiffError::to_json

fn VcdiffError::to_json(self : VcdiffError) -> String

Renders a checked error as compact valid JSON for embedding in tools.

#
AuditDiagnostic

pub(all) struct AuditDiagnostic {
level : DiagnosticLevel
code : String
message : String
offset : Int
} derive(Eq,
Debug
)

A stable diagnostic produced without raising an exception.

#
AuditReport

pub(all) struct AuditReport {
structurally_valid : Bool
decodable : Bool
decoded_size : Int
summary : DeltaSummary?
resources : ResourceEstimate
diagnostics : Array[AuditDiagnostic]
} derive(Eq,
Debug
)

Non-throwing validation result for untrusted VCDIFF bytes.

#
AuditReport::to_json

fn AuditReport::to_json(self : AuditReport) -> String

Renders an audit result as compact valid JSON.

#
AuditReport::to_text

fn AuditReport::to_text(self : AuditReport) -> String

Renders a concise audit report for logs and command-line tools.

#
CodeInstruction

pub(all) struct CodeInstruction {
kind : InstructionKind
size : Int
mode : Int
} derive(Eq,
Debug
)

One instruction triple from a code-table entry.

A zero size means that the actual size follows the code byte as an RFC unsigned integer. The mode is meaningful only for COPY.

#
CodeInstruction::is_valid

fn CodeInstruction::is_valid(self : CodeInstruction) -> Bool

Returns whether a code triple is internally valid for the default format.

#
CodeTableEntry

pub(all) struct CodeTableEntry {
first : CodeInstruction
second : CodeInstruction
} derive(Eq,
Debug
)

A code-table entry containing one required instruction and an optional second instruction represented by NOOP.

#
CodeTableMetrics

pub(all) struct CodeTableMetrics {
entry_count : Int
compound_count : Int
variable_size_count : Int
noop_count : Int
add_count : Int
run_count : Int
copy_count : Int
highest_copy_mode : Int
serialized_size : Int
checksum : Int
} derive(Eq,
Debug
)

Aggregate facts about one 256-entry instruction code table.

#
DecodeLimits

pub(all) struct DecodeLimits {
max_output_size : Int
max_window_size : Int
max_windows : Int
max_instructions_per_window : Int
} derive(Eq,
Debug
)

Resource ceilings applied while decoding untrusted delta files.

All limits are strict upper bounds. A zero value permits only empty input for the corresponding resource.

#
DecodeLimits::accepts

fn DecodeLimits::accepts(self : DecodeLimits, summary : DeltaSummary) -> Bool

Returns true when every declared structural resource is within limits.

#
DecodeLimits::new

fn DecodeLimits::new(max_output_size~ : Int, max_window_size~ : Int, max_windows~ : Int, max_instructions_per_window~ : Int) -> DecodeLimits raise VcdiffError

Creates explicit decode limits after checking that no field is negative.

#
DecodeProfile

pub(all) enum DecodeProfile {
Embedded
Interactive
Service
Archive
} derive(Eq,
Debug
)

Named decoder policies for common deployment environments.

#
DecodeResult

pub(all) struct DecodeResult {
target : Bytes
summary : DeltaSummary
trace : DeltaTrace
} derive(Eq,
Debug
)

Decoded target paired with the metadata used to reconstruct it.

#
DeltaComparison

pub(all) struct DeltaComparison {
left_size : Int
right_size : Int
size_difference : Int
left_instructions : Int
right_instructions : Int
instruction_difference : Int
same_target_size : Bool
same_window_count : Bool
same_instruction_mix : Bool
} derive(Eq,
Debug
)

Stable comparison between two valid delta documents.

#
DeltaComparison::to_json

fn DeltaComparison::to_json(self : DeltaComparison) -> String

Renders a stable delta comparison as compact valid JSON.

#
DeltaComparison::to_text

fn DeltaComparison::to_text(self : DeltaComparison) -> String

Renders a stable comparison for regression reports.

#
DeltaIndex

pub(all) struct DeltaIndex {
file_size : Int
header_size : Int
target_size : Int
source_window_count : Int
target_window_count : Int
independent_window_count : Int
windows : Array[WindowIndexEntry]
} derive(Eq,
Debug
)

Random-access metadata for a parsed delta document.

#
DeltaIndex::window_for_file

fn DeltaIndex::window_for_file(self : DeltaIndex, file_offset : Int) -> WindowIndexEntry?

Finds the window whose encoded bytes contain a file byte offset.

#
DeltaIndex::window_for_target

fn DeltaIndex::window_for_target(self : DeltaIndex, target_offset : Int) -> WindowIndexEntry?

Finds the window containing a target byte offset.

#
DeltaStatistics

pub(all) struct DeltaStatistics {
file_size : Int
target_size : Int
window_count : Int
header_bytes : Int
window_header_bytes : Int
data_bytes : Int
instruction_bytes : Int
address_bytes : Int
operations : InstructionStatistics
windows : Array[WindowStatistics]
} derive(Eq,
Debug
)

Complete statistics report suitable for benchmark and tuning tools.

#
DeltaStatistics::encoded_per_mille

fn DeltaStatistics::encoded_per_mille(self : DeltaStatistics) -> Int

Encoded bytes per thousand target bytes, or zero for an empty target.

#
DeltaStatistics::to_json

fn DeltaStatistics::to_json(self : DeltaStatistics) -> String

Renders semantic and encoded-size statistics as compact valid JSON.

#
DeltaStatistics::to_text

fn DeltaStatistics::to_text(self : DeltaStatistics) -> String

Renders stable multi-line statistics for command-line inspection.

#
DeltaSummary

pub(all) struct DeltaSummary {
file_size : Int
header_size : Int
window_count : Int
target_size : Int
data_size : Int
instruction_size : Int
address_size : Int
add_count : Int
run_count : Int
copy_count : Int
uses_source : Bool
uses_target : Bool
windows : Array[WindowSummary]
} derive(Eq,
Debug
)

A complete structural summary returned by inspect.

#
DeltaSummary::to_json

fn DeltaSummary::to_json(self : DeltaSummary) -> String

Renders compact valid JSON without requiring a JSON dependency.

#
DeltaSummary::to_text

fn DeltaSummary::to_text(self : DeltaSummary) -> String

Renders a human-readable multi-line structural report.

#
DeltaTrace

pub(all) struct DeltaTrace {
file_size : Int
window_count : Int
target_size : Int
instruction_count : Int
add_count : Int
run_count : Int
copy_count : Int
instructions : Array[TraceInstruction]
} derive(Eq,
Debug
)

Expanded instruction trace for a complete delta file.

#
DeltaTrace::to_json

fn DeltaTrace::to_json(self : DeltaTrace) -> String

Renders the expanded instruction trace as compact valid JSON.

#
DeltaTrace::to_text

fn DeltaTrace::to_text(self : DeltaTrace) -> String

Renders an expanded trace as one operation per line.

#
DiagnosticLevel

pub(all) enum DiagnosticLevel {
Information
Warning
Failure
} derive(Eq,
Debug
)

Severity attached to one audit diagnostic.

#
EncodeOptions

pub(all) struct EncodeOptions {
window_size : Int
minimum_match : Int
max_candidate_chain : Int
run_threshold : Int
enable_target_matches : Bool
} derive(Eq,
Debug
)

Deterministic encoder configuration.

#
EncodeOptions::new

fn EncodeOptions::new(window_size~ : Int, minimum_match~ : Int, max_candidate_chain~ : Int, run_threshold~ : Int, enable_target_matches~ : Bool) -> EncodeOptions raise VcdiffError

Creates an explicit deterministic encoder configuration.

#
EncodeProfile

pub(all) enum EncodeProfile {
Fast
Balanced
Compact
SmallMemory
} derive(Eq,
Debug
)

Named deterministic encoder trade-offs.

#
EncodeResult

pub(all) struct EncodeResult {
delta : Bytes
summary : DeltaSummary
trace : DeltaTrace
} derive(Eq,
Debug
)

Encoding output paired with its parsed structural report.

#
InstructionKind

pub(all) enum InstructionKind {
Noop
Add
Run
Copy
} derive(Eq,
Debug
)

The instruction types stored in an RFC 3284 code-table entry.

#
InstructionKind::name

fn InstructionKind::name(self : InstructionKind) -> String

Returns one stable uppercase instruction name for diagnostics and reports.

#
InstructionStatistics

pub(all) struct InstructionStatistics {
instruction_count : Int
add_count : Int
run_count : Int
copy_count : Int
add_bytes : Int
run_bytes : Int
copy_bytes : Int
literal_bytes : Int
maximum_instruction_size : Int
tiny_instructions : Int
small_instructions : Int
medium_instructions : Int
large_instructions : Int
copy_mode_counts : Array[Int]
} derive(Eq,
Debug
)

Aggregated semantic instruction usage for one window or complete delta.

#
InstructionStatistics::copy_percentage

fn InstructionStatistics::copy_percentage(self : InstructionStatistics) -> Int

Percentage of target bytes reconstructed by COPY, rounded down.

#
InstructionStatistics::run_percentage

fn InstructionStatistics::run_percentage(self : InstructionStatistics) -> Int

Percentage of target bytes reconstructed by RUN, rounded down.

#
LimitKind

pub(all) enum LimitKind {
OutputBytes
WindowBytes
WindowCount
InstructionCount
} derive(Eq,
Debug
)

The resource category exceeded by a parsed delta.

#
LimitKind::name

fn LimitKind::name(self : LimitKind) -> String

Returns a stable command-line spelling for a limit category.

#
LimitViolation

pub(all) struct LimitViolation {
kind : LimitKind
offset : Int
window_index : Int
actual : Int
limit : Int
} derive(Eq,
Debug
)

One preflight limit violation tied to a file or window offset.

#
LimitViolation::to_text

fn LimitViolation::to_text(self : LimitViolation) -> String

Renders a preflight violation in one stable line.

#
ResourceEstimate

pub(all) struct ResourceEstimate {
input_size : Int
declared_output_size : Int
largest_window_size : Int
largest_dictionary_size : Int
total_instructions : Int
estimated_peak_bytes : Int
} derive(Eq,
Debug
)

Conservative resource figures derived from a parsed delta.

#
TraceInstruction

pub(all) struct TraceInstruction {
window_index : Int
ordinal : Int
code_index : Int
code_offset : Int
code_slot : Int
kind : InstructionKind
size : Int
mode : Int
target_offset : Int
data_offset : Int
data_size : Int
address_offset : Int
address : Int
} derive(Eq,
Debug
)

One fully expanded instruction from a VCDIFF instruction stream.

#
VerifyReport

pub(all) struct VerifyReport {
matches : Bool
expected_size : Int
actual_size : Int
first_mismatch : Int
} derive(Eq,
Debug
)

Result of decoding a delta and comparing it with expected target bytes.

#
VerifyReport::to_json

fn VerifyReport::to_json(self : VerifyReport) -> String

Renders a verification result as compact valid JSON.

#
VerifyReport::to_text

fn VerifyReport::to_text(self : VerifyReport) -> String

Renders one stable verification status line.

#
WindowIndexEntry

pub(all) struct WindowIndexEntry {
index : Int
file_offset : Int
encoded_size : Int
target_offset : Int
target_size : Int
source_kind : WindowSourceKind
source_position : Int
source_size : Int
data_offset : Int
instruction_offset : Int
address_offset : Int
} derive(Eq,
Debug
)

Byte and target ranges associated with one window.

#
WindowSourceKind

pub(all) enum WindowSourceKind {
NoDictionary
SourceDictionary
TargetDictionary
} derive(Eq,
Debug
)

The dictionary source selected by one encoded window.

#
WindowSourceKind::name

fn WindowSourceKind::name(self : WindowSourceKind) -> String

Returns a stable lowercase dictionary label for reports.

#
WindowStatistics

pub(all) struct WindowStatistics {
window_index : Int
target_size : Int
delta_size : Int
data_size : Int
instruction_size : Int
address_size : Int
operations : InstructionStatistics
} derive(Eq,
Debug
)

Statistics for one target window, including its encoded section costs.

#
WindowSummary

pub(all) struct WindowSummary {
index : Int
offset : Int
source_kind : WindowSourceKind
source_size : Int
source_position : Int
target_size : Int
delta_size : Int
data_size : Int
instruction_size : Int
address_size : Int
add_count : Int
run_count : Int
copy_count : Int
} derive(Eq,
Debug
)

Structural and instruction statistics for one target window.

#
DEFAULT_ADDRESS_MODE_COUNT

let DEFAULT_ADDRESS_MODE_COUNT : Int

Number of legal COPY address modes in the standard table.

#
DEFAULT_NEAR_CACHE_SIZE

let DEFAULT_NEAR_CACHE_SIZE : Int

Number of recent addresses in the standard near cache.

#
DEFAULT_SAME_CACHE_SIZE

let DEFAULT_SAME_CACHE_SIZE : Int

Number of 256-entry banks in the standard same cache.

#
FORMAT_NAME

let FORMAT_NAME : String

The binary delta format implemented by this package.

#
VERSION

let VERSION : String

The semantic version of MoonVCDIFF.

#
audit

fn audit(source : Bytes, delta : Bytes, limits : DecodeLimits) -> AuditReport

Audits untrusted delta bytes without raising VCDIFF errors.

Structural validity is reported separately from source-dependent decodability, and successful reports include conservative memory figures.

#
canonicalize

fn canonicalize(delta : Bytes) -> Bytes raise VcdiffError

Reframes a valid delta with canonical integers and exact section lengths.

Instruction, data, and address section bytes remain unchanged.

#
compare_deltas

fn compare_deltas(left : Bytes, right : Bytes) -> DeltaComparison raise VcdiffError

Compares structural cost without requiring source or target contents.

#
decode

fn decode(source : Bytes, delta : Bytes, limits : DecodeLimits) -> Bytes raise VcdiffError

Decodes an RFC 3284 delta using explicit resource limits.

ADD, RUN, and COPY instructions use the RFC default code table. COPY addresses may use SELF, HERE, NEAR, or SAME modes.

#
decode_code_table_data

fn decode_code_table_data(data : Bytes, near_size : Int, same_size : Int) -> Array[CodeTableEntry] raise VcdiffError

Parses an uncompressed 1536-byte code-table representation.

This utility does not enable custom tables in the file decoder; it exists for inspection, generation, and interoperability tooling.

#
decode_detailed

fn decode_detailed(source : Bytes, delta : Bytes, limits : DecodeLimits) -> DecodeResult raise VcdiffError

Decodes once and returns the target, summary, and expanded trace.

#
decode_limits_for_profile

fn decode_limits_for_profile(profile : DecodeProfile) -> DecodeLimits

Returns explicit limits for a named deployment profile.

#
decode_range

fn decode_range(source : Bytes, delta : Bytes, start : Int, end : Int, limits : DecodeLimits) -> Bytes raise VcdiffError

Decodes and returns a validated half-open target byte range.

#
decode_unsigned_integer

fn decode_unsigned_integer(data : Bytes) -> Int raise VcdiffError

Decodes exactly one canonical RFC 3284 unsigned integer.

Any bytes following the integer are rejected so callers cannot accidentally ignore malformed suffix data.

#
decode_windows

fn decode_windows(source : Bytes, delta : Bytes, limits : DecodeLimits) -> Array[Bytes] raise VcdiffError

Decodes a delta while preserving its target window boundaries.

#
default_code_entry

fn default_code_entry(index : Int) -> CodeTableEntry raise VcdiffError

Looks up a standard code byte while validating the byte-sized index.

#
default_code_table

fn default_code_table() -> Array[CodeTableEntry]

Builds the RFC 3284 default 256-entry instruction code table.

A fresh array is returned on every call so callers may inspect or transform it without mutating decoder state.

#
default_code_table_data

fn default_code_table_data() -> Bytes

Returns the canonical serialized form of the RFC default table.

#
default_decode_limits

fn default_decode_limits() -> DecodeLimits

Returns conservative defaults suitable for command-line and server use.

#
default_encode_options

fn default_encode_options() -> EncodeOptions

Returns the stable encoder defaults used by the CLI.

#
encode

fn encode(source : Bytes, target : Bytes, options : EncodeOptions) -> Bytes raise VcdiffError

Encodes target bytes into a deterministic RFC 3284 delta.

A bounded hash-chain planner selects source and target COPY matches, detects runs, and uses canonical ADD instructions for remaining bytes.

#
encode_code_table_data

fn encode_code_table_data(table : Array[CodeTableEntry], near_size : Int, same_size : Int) -> Bytes raise VcdiffError

Serializes a validated table using RFC 3284 section 7 field ordering.

#
encode_detailed

fn encode_detailed(source : Bytes, target : Bytes, options : EncodeOptions) -> EncodeResult raise VcdiffError

Encodes once and returns the delta, summary, and expanded trace.

#
encode_options_for_profile

fn encode_options_for_profile(profile : EncodeProfile) -> EncodeOptions

Returns deterministic options for a named encoder trade-off.

#
encode_unsigned_integer

fn encode_unsigned_integer(value : Int) -> Bytes raise VcdiffError

Encodes one non-negative integer in canonical RFC 3284 form.

#
evaluate_limits

fn evaluate_limits(summary : DeltaSummary, limits : DecodeLimits) -> Array[LimitViolation]

Evaluates declared structure against limits without decoding target bytes.

#
index_delta

fn index_delta(delta : Bytes) -> DeltaIndex raise VcdiffError

Builds target-to-file offset mappings without requiring source contents.

#
inspect

fn inspect(delta : Bytes) -> DeltaSummary raise VcdiffError

Parses a delta into a stable file-level and per-window summary.

Inspection validates code bytes and separately encoded instruction sizes, but does not require the external source file.

#
inspect_code_table

fn inspect_code_table(table : Array[CodeTableEntry], near_size : Int, same_size : Int) -> CodeTableMetrics raise VcdiffError

Validates a table and returns stable aggregate metrics.

#
is_canonical

fn is_canonical(delta : Bytes) -> Bool raise VcdiffError

Returns true when canonical reframing leaves the delta byte-identical.

#
product_name

fn product_name() -> String

Returns the stable product name used by the library and command line tool.

#
statistics

fn statistics(delta : Bytes) -> DeltaStatistics raise VcdiffError

Computes semantic and encoded-size statistics for a valid delta.

#
trace

fn trace(delta : Bytes) -> DeltaTrace raise VcdiffError

Expands every code byte into semantic ADD, RUN, and COPY operations.

COPY addresses are resolved through the standard caches. Source contents are not needed because source segment sizes are carried by window headers.

#
validate_structure

fn validate_structure(delta : Bytes) -> Int raise VcdiffError

Validates the RFC file and window framing without executing instructions.

The returned value is the number of target windows found.

#
verify

fn verify(source : Bytes, delta : Bytes, expected : Bytes) -> VerifyReport raise VcdiffError

Decodes a delta with standard limits and compares it to expected bytes.