moonstdf

    Bounded STDF V4 decoding and semiconductor test-data analysis in MoonBit

    stdf
    semiconductor
    yield
    Download zip
    Author
    Version
    0.1.0
    License
    MIT
    Last updated
    9 hours ago
    Downloads
    4

    No dependencies

    #基于MoonBit的通用STDF V4解析库 MoonSTDF

    CI

    MoonBit 实现的通用 STDF V4 二进制解码库与离线数据工具链。完整支持基础 STDF V4 的 25 种在用记录及全部标准字段解析,把文件转换为可复用的命名字段、原始记录和诊断,供数据转换、归档、文件审计及测试分析使用。Node CLI 与浏览器工作台共用 MoonBit 核心。

    支持 CPU_TYPE 0/1/2(VAX F/D、IEEE 大端/小端)、可选尾部与 GDR 全部数据类型;提供文件顺序、跨记录引用和生命周期检查。完整解析的接口、逐记录矩阵及可复现证据见 支持范围。通用性体现在对不同 ATE 来源和上层应用复用同一套格式 API;实际厂商兼容性需用各自文件验证。V4-2007 为独立扩展,不属于本版本的基础 V4 解析承诺。

    #项目范围说明

    已实现完整支持 STDF V4 基础标准的全部 25 种在用记录类型及全部标准字段解析。 本项目面向半导体测试数据通用分析场景,可适配多类型测试机台,不局限单一垂直产线;适配依据是标准格式,不包含未经验证的厂商私有扩展。解析终点为:文件读取 → 记录解析 → 结构化校验 → 导出 JSON/JSONL,输出可用于测试数据分析、可视化、数据库入库及长期归档。

    分类已支持记录(REC_TYP/REC_SUB)状态
    文件与审计FAR 0/10、ATR 0/20已支持
    批次与汇总MIR 1/10、MRR 1/20、PCR 1/30、HBR 1/40、SBR 1/50已支持
    引脚、复测与站点PMR 1/60、PGR 1/62、PLR 1/63、RDR 1/70、SDR 1/80已支持
    晶圆WIR 2/10、WRR 2/20、WCR 2/30已支持
    芯片PIR 5/10、PRR 5/20已支持
    测试汇总TSR 10/30已支持
    测试结果PTR 15/10、MPR 15/15、FTR 15/20已支持
    程序段BPS 20/10、EPS 20/20已支持
    通用数据与文本GDR 50/10、DTR 50/30已支持

    逐记录状态、字段数和验证入口见根目录 SUPPORT.md。完整字段解析不等于穷尽全部业务规则的符合性认证;V4-2007 扩展、压缩封装和 STDF 写回不在本期范围。

    开源价值:为 MoonBit 应用提供可复用的半导体 STDF 格式组件,减少各工具重复实现二进制解析。2026-11-18 在 Mooncakes 以 stdf 检索未发现同类包;该检索范围不代表全网唯一。

    #评审快速验证与输出截图

    已上传原创合成 样例 STDF V4 文件:1,149 字节、27 条记录,覆盖全部 25 种类型和全部字段;无需真实产线数据。可下载 完整记录 JSONL、结构化校验 JSON 和 完整 PTR 记录 JSON。

    moon build --target js --deny-warn python tools/generate_demo.py

    该脚本先调用真实 CLI 校验样例,通过后导出所有记录,并重建以上 JSON 和 本地输出预览。预期结果:valid: true、record_count: 27、25 种类型、无诊断。截图来自该预览对真实 CLI JSON 的展示,上方为完整校验结果,下方为 PTR 全部字段:

    样例 STDF V4 的真实校验与结构化 JSON 输出

    只验证 MoonBit 库、不需要 Python 或 Node 时:moon run examples/demo --target wasm-gc。源码见 最小 Demo,内嵌完整最小文件,演示分帧、命名字段访问、校验和 JSON 输出。

    #快速开始

    安装 MoonBit 官方工具链;本项目验证版本为 moonc v0.10.20+65efd5b93、moon 0.1.20261104。CLI 需要 Node.js 22+,辅助脚本需要 Python 3.10+。核心库无第三方运行时依赖。无需 Python 包安装。

    git clone https://github.com/0607272/MoonSTDF.git cd MoonSTDF moon check --target all --deny-warn moon test --target wasm-gc --deny-warn moon run examples/demo --target wasm-gc moon build --target js --deny-warn node _build/js/debug/build/cmd/main/main.js analyze fixtures/lot-a-le.stdf

    业务样本产生 27 条记录、2 个芯片观测、1 通过 / 1 失败、良率 0.5;PTR 100 均值 2.5 V。PMR 等已识别记录在 JSON 的 ancillary_records 中输出;便携示例另用内嵌的完整最小文件,6 条记录、1 颗通过,并演示跨块分帧、命名字段访问及文件校验。

    #文件分析、比较与复测

    完整字段转换与文件审计:

    node _build/js/debug/build/cmd/main/main.js dump fixtures/v4-all-records-le.stdf --output records.jsonl node _build/js/debug/build/cmd/main/main.js validate fixtures/v4-all-records-vax.stdf

    dump 的每行包含全部标准字段、明确的缺失标记、原始记录体和源偏移,适合接入数据库或独立分析系统。validate 返回各类型计数和带偏移诊断,有问题时退出 2。流式导出失败时可能留下有效前缀,调用方必须检查退出码。应用统计使用以下入口:

    node _build/js/debug/build/cmd/main/main.js analyze fixtures/lot-a-le.stdf --format html --output lot.html node _build/js/debug/build/cmd/main/main.js analyze fixtures/lot-a-le.stdf --format csv --output parts.csv node _build/js/debug/build/cmd/main/main.js analyze fixtures/lot-a-le.stdf --policy last --identity coordinates node _build/js/debug/build/cmd/main/main.js compare fixtures/lot-a-le.stdf fixtures/lot-b-le.stdf node _build/js/debug/build/cmd/main/main.js retest fixtures/lot-a-le.stdf fixtures/retest-le.stdf --identity coordinates

    比较样本的 PTR 均值差为 +1 V;复测样本匹配 2 颗、恢复 1 颗、退化 0 颗。比较要求测试种类、编号、单位、上下限及等号策略一致;差异或缺失条件产生诊断。跨文件复测要求配对唯一;重复、缺失和冲突身份会报告,不能据此自动判定量产放行。

    分析 CLI 默认输出 JSON,可用 --output PATH 保存;父目录须已存在,输出不得覆盖任何输入。结构错误返回退出码 2;分析层诊断保留在报告中,compare / retest 的源诊断标注 before/after。--help 查看参数。文件每次读取 64 KiB,默认每文件上限 256 MiB / 1,000,000 条记录。解析有界,但分析保留芯片观测与未投影记录,内存不恒定。

    #可复现使用场景

    • 数据接入与归档:数据平台开发者将不同 ATE 的未压缩基础 V4 文件交给 dump,获得命名字段 JSONL、原始字节和偏移,接入数据库或归档系统;示例 dump fixtures/v4-all-records-le.stdf 覆盖 25 种记录。
    • 文件质量审计:实验室或工具维护者在批量入库前运行 validate,检查记录顺序、必需记录、引脚引用及芯片/晶圆配对,获得可定位的诊断和退出码,决定是否隔离异常文件;validate fixtures/malformed-truncated.stdf 返回 2。
    • 工程分析与复测:测试/工艺工程师使用 analyze 查看芯片、良率、分布与坐标,使用 retest fixtures/lot-a-le.stdf fixtures/retest-le.stdf 获得 2 颗配对、1 颗恢复,或以 compare 比较批次;样例 PTR 均值差为 +1 V。

    #浏览器本地分析

    moon build --target js --deny-warn python tools/build_web.py

    直接在浏览器打开 web/index.html,选择合成样本或自己的未压缩 STDF V4 文件,可查看测试项分布、SVG 晶圆坐标图并下载 JSON/HTML。页面不上传文件、不请求 CDN。编译产物 web/moonstdf.js 由以上命令生成,不纳入源码。页面在主线程分析,接近资源上限的文件可能短暂阻塞界面;浏览器入口目前提供单文件观测分析,复测与比较使用 CLI。

    #MoonBit API

    在 MoonBit 工程的 moon.pkg 中导入 "0607272/moonstdf",并使用本地路径依赖或源码检出;当前尚未发布 Mooncakes 包。

    fn inspect_file(data : Bytes) -> String raise @moonstdf.StdfError {
    let analysis = @moonstdf.analyze(data)
    @moonstdf.report_json(analysis)
    }

    大文件可用 Framer::new().feed(chunk) 获得 Frame,逐条传给 Analyzer::accept,在 EOF 依次调用两者的 finish()。遇到错误后对象关闭,不可继续使用;直接传 Frame 也校验 FAR、字节序、体长及预算。Analyzer::new(max_bytes=..., max_records=...) 可配置小于默认值的预算。完整 API 见 生成接口 与 便携示例。

    需要全部字段时,对每条帧调用 decode_v4_record(frame)(返回 V4Record?),通过 record.fields 或 record.field("字段名") 读取,原始字节位于 record.frame。v4_record_json(frame) 生成完整导出,validate_v4(data) 或增量 V4Validator 提供校验;分析报告只投影统计需要的字段。

    #统计口径

    • 默认保留所有完成的芯片观测;良率 = 正常通过 /(正常通过 + 正常失败)。未知、异常结束单列且不进分母,空分母为 null。
    • PTR/MPR 数值已经是基本单位;显示缩放不参与数值计算。按首条同类同号记录建立不可变基线,后续覆盖只影响当前记录。
    • 分布只纳入有限且质量有效的数值;失败但数值有效的样本仍可参与分布。MPR 多个值增加样本数,不增加执行数;标准差采用总体口径。
    • first / last 必须显式选择,并指定 coordinates 或 part-id 身份。坐标键含 lot/wafer;缺失和冲突不会被静默合并。选择后停用与全文件汇总的直接比较。
    • 晶圆图采用原始逻辑坐标,不转换物理方向;重复坐标按后观测覆盖并显式提示。坐标不等于全球唯一芯片标识。

    #验证与持续集成

    moon fmt --check moon info git diff --exit-code -- '*.mbti' moon check --target all --deny-warn moon build --target wasm --deny-warn moon test --target wasm --deny-warn moon build --target wasm-gc --deny-warn moon test --target wasm-gc --deny-warn moon build --target js --deny-warn moon test --target js --deny-warn python tools/generate_fixtures.py --check python tools/generate_v4_coverage.py --check python tools/test_cli.py python tools/test_v4_coverage.py python tools/generate_demo.py --check python tools/build_web.py python tools/test_web.py

    CI 覆盖 JS / Wasm / WasmGC 的 check、build、test 和运行示例,另校验格式、接口漂移、样本可复现性与 CLI/浏览器共享核心一致性。Native 尚未列为支持目标;Windows 本地缺少 MSVC Build Tools,未完成 Native 运行验证。浏览器核心已在 Node 下验证,实际浏览器布局和文件选择流程仍需交互验证。

    所有二进制样本均为原创合成数据,见 fixtures。全字段样本覆盖 25 种记录及 LE/BE/VAX,使用独立 Python 编码器与已知值核对;另有 5 个业务样本以 MIT 解码器 Semi-ATE-STDF 0.1.28 对照部分字段。两类证据均不等于覆盖所有厂商文件。见 来源与许可证。

    #限制与后续方向

    不支持 STDF V4-2007 扩展、压缩封装、ATDF、写回 STDF、硬件采集、SPC 显著性检验或完整标准符合性认证。汇总记录的一致性检查也不能证明输入文件完整。后续可扩展厂商样本验证、PMR 引脚投影和 Worker 分析入口。

    源码与原创合成样本采用 MIT 许可证。

    StdfError

    pub suberror StdfError {
    StdfError(Int, String)
    } derive(
    Debug
    )

    Errors always identify the absolute byte offset of the failed input.

    Analysis

    pub(all) struct Analysis {
    parts : Array[Part]
    diagnostics : Array[Diagnostic]
    summaries : Array[Summary]
    ancillary_records : Array[AncillaryRecord]
    unknown : Array[Frame]
    record_count : Int
    } derive(
    Debug
    )

    Analysis::to_repr

    Analyzer

    pub struct Analyzer {
    lot : String
    have_mir : Bool
    have_mrr : Bool
    have_pcr : Bool
    count : Int
    received : Int
    order : ByteOrder?
    max_records : Int
    max_bytes : Int
    closed : Bool
    parts : Array[Part]
    diagnostics : Array[Diagnostic]
    summaries : Array[Summary]
    ancillary_records : Array[AncillaryRecord]
    unknown : Array[Frame]
    groups : Map[String, Int]
    wafers : Map[String, String]
    pending : Map[String, PendingPart]
    defaults : Map[String, TestDefaults]
    validator : V4Validator
    }

    but does not retain raw bytes for recognized records. Single use after EOF.

    Analyzer::accept

    fn Analyzer::accept(self : Analyzer, frame : Frame) -> Unit raise StdfError

    Analyzer::finish

    fn Analyzer::finish(self : Analyzer) -> Analysis raise StdfError

    EOF closes the analyzer and reports unfinished structures.

    Analyzer::new

    fn Analyzer::new(max_records? : Int, max_bytes? : Int) -> Analyzer

    AncillaryRecord

    pub(all) enum AncillaryRecord {
    Atr(UInt, String)
    Pmr(UInt, Int, String, String, String, Int, Int)
    Pgr(UInt, String, Array[Int])
    Plr(Array[Int], Array[Int], Array[Int], Array[Array[String]])
    Rdr(Array[Int])
    Bps(String)
    Eps
    Gdr(Array[GenericValue])
    Dtr(String)
    } derive(
    Debug
    )

    Typed records not consumed by current yield/statistics projections.

    BatchComparison

    pub(all) struct BatchComparison {
    before_yield : YieldSummary
    after_yield : YieldSummary
    tests : Array[TestComparison]
    diagnostics : Array[Diagnostic]
    } derive(
    Debug
    )

    BinTransition

    pub(all) struct BinTransition {
    before_bin : Int
    after_bin : Int
    count : Int
    } derive(
    Debug
    )

    ByteOrder

    pub(all) enum ByteOrder {
    Little
    Big
    Vax
    } derive(Eq,
    Debug
    )

    Representation established by FAR: VAX F/D or IEEE big/little endian.

    ByteOrder::equal

    fn ByteOrder::equal(ByteOrder, ByteOrder) -> Bool

    ByteOrder::not_equal

    fn ByteOrder::not_equal(x : ByteOrder, y : ByteOrder) -> Bool

    Diagnostic

    pub(all) struct Diagnostic {
    offset : Int
    code : String
    message : String
    } derive(
    Debug
    )

    A diagnostic describes incomplete context without inventing a measurement.

    Frame

    pub(all) struct Frame {
    offset : Int
    typ : Int
    sub : Int
    order : ByteOrder
    body : Bytes
    } derive(Eq,
    Debug
    )

    Raw record body is retained even for unrecognized record types.

    Frame::equal

    fn Frame::equal(Frame, Frame) -> Bool

    Frame::not_equal

    fn Frame::not_equal(x : Frame, y : Frame) -> Bool

    Frame::to_repr

    Framer

    pub struct Framer {
    pending : Array[Byte]
    target : Int
    offset : Int
    received : Int
    count : Int
    order : ByteOrder?
    closed : Bool
    max_bytes : Int
    max_records : Int
    }

    Stateful, single-use bounded incremental decoder. Errors poison the decoder.

    Framer::feed

    fn Framer::feed(self : Framer, chunk : Bytes) -> Array[Frame] raise StdfError

    Framer::finish

    fn Framer::finish(self : Framer) -> Unit raise StdfError

    Call at EOF: a truncated final record is an error, not a successful prefix.

    Framer::new

    fn Framer::new(max_bytes? : Int, max_records? : Int) -> Framer

    GenericValue

    pub(all) enum GenericValue {
    Padding
    U1(Int)
    U2(Int)
    U4(UInt)
    I1(Int)
    I2(Int)
    I4(Int)
    R4(Double)
    R8(Double)
    Text(String)
    Binary(Bytes)
    Bits(Int, Bytes)
    Nibble(Int)
    } derive(
    Debug
    )

    Variable-length generic value in a V4 GDR. Bytes stay binary; D*n retains both its declared bit count and packed representation.

    LotInfo

    pub(all) struct LotInfo {
    setup : UInt
    start : UInt
    station : Int
    lot : String
    product : String
    node : String
    tester : String
    job : String
    } derive(
    Debug
    )

    Relevant identity fields from MIR. Remaining optional text is validated.

    LotInfo::to_repr

    Measurement

    pub(all) struct Measurement {
    kind : String
    number : UInt
    text : String
    values : Array[Double]
    units : String?
    low : Double?
    high : Double?
    low_equal : Bool
    high_equal : Bool
    flags : Int
    param_flags : Int
    offset : Int
    } derive(
    Debug
    )

    Resolved base-unit numeric observations or a functional execution.

    Metadata

    pub(all) enum Metadata {
    Far(Int, Int)
    Mir(LotInfo)
    Mrr(UInt)
    Sdr(Int, Int, Array[Int])
    Wir(Int, Int, UInt, String)
    Wrr(Int, Int, UInt, UInt, UInt?, String)
    Wcr(WaferGeometry)
    } derive(
    Debug
    )

    Typed analysis projections, not a lossless replacement for Frame.

    Metadata::to_repr

    Outcome

    pub(all) enum Outcome {
    Pass
    Fail
    Unknown
    } derive(Eq,
    Debug
    )

    Reported pass/fail indication; abnormal completion is a separate flag.

    Outcome::equal

    fn Outcome::equal(Outcome, Outcome) -> Bool

    Outcome::not_equal

    fn Outcome::not_equal(x : Outcome, y : Outcome) -> Bool

    Outcome::to_repr

    Part

    pub(all) struct Part {
    lot : String
    wafer : String?
    result : PartResult
    tests : Array[Measurement]
    offset : Int
    } derive(
    Debug
    )

    Completed part; source offset and all reported flags remain available.

    Part::to_repr

    PartRecord

    pub(all) enum PartRecord {
    Pir(Int, Int)
    Prr(PartResult)
    } derive(Eq,
    Debug
    )

    PartRecord::equal

    fn PartRecord::equal(PartRecord, PartRecord) -> Bool

    PartRecord::not_equal

    fn PartRecord::not_equal(x : PartRecord, y : PartRecord) -> Bool

    PartResult

    pub(all) struct PartResult {
    head : Int
    site : Int
    flags : Int
    num_tests : Int
    hard_bin : Int
    soft_bin : Int?
    x : Int?
    y : Int?
    test_ms : UInt
    part_id : String
    part_text : String
    outcome : Outcome
    abnormal : Bool
    } derive(Eq,
    Debug
    )

    PartResult::equal

    fn PartResult::equal(PartResult, PartResult) -> Bool

    PartResult::not_equal

    fn PartResult::not_equal(x : PartResult, y : PartResult) -> Bool

    PendingPart

    pub struct PendingPart {
    lot : String
    wafer : String?
    tests : Array[Measurement]
    offset : Int
    }

    Reader

    pub struct Reader {
    data : Bytes
    order : ByteOrder
    base : Int
    pos : Int
    }

    A checked cursor; offsets refer to the original file, including its header.

    Reader::cn

    fn Reader::cn(self : Reader) -> String raise StdfError

    C*n byte strings are mapped losslessly as Latin-1, never guessed as UTF-8.

    Reader::end

    fn Reader::end(self : Reader) -> Unit raise StdfError

    Reader::i1

    fn Reader::i1(self : Reader) -> Int raise StdfError

    Reader::i2

    fn Reader::i2(self : Reader) -> Int raise StdfError

    Reader::new

    fn Reader::new(data : Bytes, order : ByteOrder, base : Int) -> Reader

    Reader::optional

    fn[T] Reader::optional(self : Reader, read : (Reader) -> T raise StdfError) -> T? raise StdfError

    Absence at a legal optional suffix boundary differs from a partial field.

    Reader::r4

    fn Reader::r4(self : Reader) -> Double raise StdfError

    Reader::r8

    fn Reader::r8(self : Reader) -> Double raise StdfError

    Reader::remaining

    fn Reader::remaining(self : Reader) -> Int

    Reader::take

    fn Reader::take(self : Reader, n : Int) -> Bytes raise StdfError

    Reader::u1

    fn Reader::u1(self : Reader) -> Int raise StdfError

    Reader::u2

    fn Reader::u2(self : Reader) -> Int raise StdfError

    Reader::u4

    fn Reader::u4(self : Reader) -> UInt raise StdfError

    RetestIdentity

    pub(all) enum RetestIdentity {
    WaferCoordinates
    PartId
    } derive(Eq,
    Debug
    )

    Explicit identity policy; wafer coordinates require known lot AND wafer.

    RetestIdentity::equal

    RetestIdentity::not_equal

    fn RetestIdentity::not_equal(x : RetestIdentity, y : RetestIdentity) -> Bool

    RetestPolicy

    pub(all) enum RetestPolicy {
    First
    Last
    } derive(Eq,
    Debug
    )

    First/last use source observation order, never timestamps or sorted site.

    RetestPolicy::equal

    RetestPolicy::not_equal

    fn RetestPolicy::not_equal(x : RetestPolicy, y : RetestPolicy) -> Bool

    RetestReport

    pub(all) struct RetestReport {
    matched : Int
    recovered : Int
    still_failed : Int
    regressed : Int
    unknown : Int
    ambiguous : Int
    unmatched_before : Int
    unmatched_after : Int
    transitions : Array[BinTransition]
    diagnostics : Array[Diagnostic]
    } derive(
    Debug
    )

    RetestSelection

    pub(all) struct RetestSelection {
    parts : Array[Part]
    diagnostics : Array[Diagnostic]
    duplicates : Int
    } derive(
    Debug
    )

    Summary

    pub(all) struct Summary {
    kind : String
    head : Int
    site : Int
    number : UInt?
    count : UInt?
    good : UInt?
    fails : UInt?
    label : String
    } derive(Eq,
    Debug
    )

    Counts reported by the file, kept separate from recomputed analysis counts. Label is a bin name or TSR TEST_NAM. Unprojected counters remain in Frame.

    Summary::equal

    fn Summary::equal(Summary, Summary) -> Bool

    Summary::not_equal

    fn Summary::not_equal(x : Summary, y : Summary) -> Bool

    Summary::to_repr

    TestComparison

    pub(all) struct TestComparison {
    signature : TestSignature
    before : TestStatistics
    after : TestStatistics
    mean_delta : Double?
    failure_rate_delta : Double?
    } derive(
    Debug
    )

    TestDefaults

    pub(all) struct TestDefaults {
    flags : Int?
    res_scale : Int?
    low_scale : Int?
    high_scale : Int?
    low : Double?
    high : Double?
    units : String?
    } derive(
    Debug
    )

    Physically present optional metadata. Omitted fields remain absent so that the file assembler can apply the first record's immutable test defaults.

    TestRecord

    pub(all) struct TestRecord {
    kind : String
    number : UInt
    head : Int
    site : Int
    flags : Int
    param_flags : Int
    values : Array[Double]
    states : Array[Int]
    indexes : Array[Int]
    text : String
    defaults : TestDefaults
    } derive(
    Debug
    )

    Values and limits are already expressed in base UNITS. STDF scale fields affect display only; they must never change statistical input values.

    TestSignature

    pub(all) struct TestSignature {
    kind : String
    number : UInt
    units : String?
    low : Double?
    high : Double?
    low_equal : Bool
    high_equal : Bool
    } derive(Eq, Hash,
    Debug
    )

    Exact base-unit context. Text is descriptive, not a grouping key. None units stays distinct from an empty or explicit unit; comparisons must treat such a context as unresolved. Analyzer resolves finite limits.

    TestSignature::equal

    TestSignature::hash

    fn TestSignature::hash(self : TestSignature) -> Int

    TestSignature::hash_combine

    fn TestSignature::hash_combine(TestSignature, Hasher) -> Unit

    TestSignature::not_equal

    fn TestSignature::not_equal(x : TestSignature, y : TestSignature) -> Bool

    TestStatistics

    pub(all) struct TestStatistics {
    signature : TestSignature
    text : String
    executions : Int
    passed : Int
    failed : Int
    unknown : Int
    usable_samples : Int
    excluded_samples : Int
    mean : Double?
    stddev : Double?
    minimum : Double?
    maximum : Double?
    below_limit : Int
    above_limit : Int
    failure_rate : Double?
    } derive(
    Debug
    )

    Execution outcomes and numeric sample quality are independent. Standard deviation uses population variance. Failure rate uses known outcomes only.

    V4Field

    pub(all) struct V4Field {
    name : String
    value : V4Value
    } derive(
    Debug
    )

    V4Field::to_repr

    V4Record

    pub(all) struct V4Record {
    name : String
    fields : Array[V4Field]
    frame : Frame
    } derive(
    Debug
    )

    All standard fields in wire order, including explicitly missing suffixes.

    V4Record::field

    fn V4Record::field(self : V4Record, name : String) -> V4Value?

    V4Record::to_repr

    V4Validator

    pub struct V4Validator {
    closed : Bool
    count : Int
    received : Int
    phase : Int
    previous : String
    order : ByteOrder?
    max_records : Int
    max_bytes : Int
    counts : Map[String, Int]
    diagnostics : Array[Diagnostic]
    pins : Map[Int, Bool]
    pin_groups : Map[Int, Bool]
    sections : Array[Int]
    parts : Map[String, Int]
    wafers : Map[String, String]
    }

    Streaming structural and file-level checks; retains indexes, not payloads.

    V4Validator::accept

    fn V4Validator::accept(self : V4Validator, frame : Frame) -> Unit raise StdfError

    V4Validator::finish

    V4Validator::new

    fn V4Validator::new(max_records? : Int, max_bytes? : Int) -> V4Validator

    V4Value

    pub(all) enum V4Value {
    MissingField
    UnsignedField(UInt)
    SignedField(Int)
    RealField(Double)
    TextField(String)
    BytesField(Bytes)
    BitsField(Int, Bytes)
    ArrayField(Array[V4Value])
    GenericField(Array[GenericValue])
    } derive(
    Debug
    )

    Physical values, before sentinels/defaults are interpreted by analysis.

    V4Value::to_repr

    ValidationReport

    pub(all) struct ValidationReport {
    valid : Bool
    record_count : Int
    record_counts : Map[String, Int]
    diagnostics : Array[Diagnostic]
    } derive(
    Debug
    )

    WaferGeometry

    pub(all) struct WaferGeometry {
    diameter : Double?
    die_height : Double?
    die_width : Double?
    units : Int
    flat : Int
    center_x : Int?
    center_y : Int?
    positive_x : Int
    positive_y : Int
    } derive(
    Debug
    )

    Missing WCR fields remain absent; coordinates use the STDF sentinel.

    YieldGroup

    pub(all) struct YieldGroup {
    dimension : String
    key : String
    summary : YieldSummary
    } derive(
    Debug
    )

    YieldSummary

    pub(all) struct YieldSummary {
    total : Int
    passed : Int
    failed : Int
    unknown : Int
    abnormal : Int
    denominator : Int
    yield_rate : Double?
    } derive(
    Debug
    )

    Mutually exclusive categories. Abnormal completion takes precedence over reported outcome; unknown and abnormal parts never enter the denominator.

    analyze

    fn analyze(data : Bytes) -> Analysis raise StdfError

    compare_batches

    fn compare_batches(left : Array[Part], right : Array[Part]) -> BatchComparison

    Compare raw batch statistics in left first-seen context order. Exact signatures are required, independently of text. PTR/MPR with missing units are unresolved, even if both sides have the same missing context. FTR can match without units because it supplies execution status, not numeric data. Every unmatched signature on either side produces a diagnostic; matched variants do not hide additional changed variants. Diagnostics use offset 0 because a signature can aggregate observations at multiple source offsets. Deltas are after minus before, absent if either metric or the delta is nonfinite. No significance or causal claim is inferred from a difference.

    compare_retests

    fn compare_retests(before : Array[Part], after : Array[Part], identity : RetestIdentity) -> RetestReport

    identities require explicit prior first/last selection; they are not guessed.

    comparison_json

    fn comparison_json(c : BatchComparison) -> String

    No delta is emitted for incompatible contexts or missing units.

    decode_ancillary

    fn decode_ancillary(frame : Frame) -> AncillaryRecord? raise StdfError

    Decode and validate the nine base-V4 record types not used by yield analysis.

    decode_frames

    fn decode_frames(data : Bytes) -> Array[Frame] raise StdfError

    decode_functional

    fn decode_functional(frame : Frame) -> TestRecord? raise StdfError

    FTR projects identity, TEST_FLG, returned RTN_INDX/RTN_STAT and TEST_TXT. Values are empty: cycle/address data, programmed pin arrays, bitmaps, other strings and PATG_NUM remain in the original Frame after structural checks. PATG_NUM/SPIN_MAP defaults are not resolved because neither is analyzed or projected here. All TestDefaults fields are absent; TEST_TXT never inherits.

    decode_metadata

    fn decode_metadata(frame : Frame) -> Metadata? raise StdfError

    V4 metadata projections. Unknown record types are left to the caller.

    decode_parametric

    fn decode_parametric(frame : Frame) -> TestRecord? raise StdfError

    Decode STDF V4 PTR and MPR, retaining flags without deciding result validity. Optional fields may stop at any field boundary, but may not be partial.

    decode_part

    fn decode_part(frame : Frame) -> PartRecord? raise StdfError

    Decode PIR/PRR without changing the source frame. Omitted suffixes use the specification's missing values; present fields must be complete. PART_FIX is checked as B*n; its application-specific bytes remain in Frame.body. Conflicting supersession flags and nonzero reserved bits are fatal errors. PART_FLG bit 2 is independent of outcome: yield policy must explicitly exclude abnormal parts when counting successful completions.

    decode_summary

    fn decode_summary(frame : Frame) -> Summary? raise StdfError

    PCR/HBR/SBR/TSR analysis projections. All present fields are checked even when not projected; legal omitted suffixes do not invent zero counts.

    decode_v4_record

    fn decode_v4_record(frame : Frame) -> V4Record? raise StdfError

    Complete named-field reader for all 25 base V4 record IDs. Unknown records return None and remain available as raw Frame values. No source bytes lost.

    grouped_yield

    fn grouped_yield(parts : Array[Part]) -> Array[YieldGroup]

    Dimension order is lot, wafer, site, hard_bin, soft_bin. Within a dimension, groups follow first occurrence in input. Keys use length-prefixed identity strings and explicit option tags, so delimiters and literal missing labels cannot merge groups. Site/bin groups retain lot, wafer and head/site scope.

    parts_csv

    fn parts_csv(parts : Array[Part]) -> String

    One row per completed part. Missing coordinates/bins are empty fields.

    report_html

    fn report_html(a : Analysis) -> String

    Self-contained offline HTML; no scripts, external assets, or embedded raw JSON.

    report_json

    fn report_json(a : Analysis) -> String

    Stable schema tag; null denotes missing/nonfinite, never a fabricated zero.

    retest_json

    fn retest_json(r : RetestReport) -> String

    JSON for cross-file retest matching. Selection policy belongs to caller.

    select_retests

    fn select_retests(parts : Array[Part], policy : RetestPolicy, identity : RetestIdentity) -> RetestSelection

    with diagnostics; PART_FLG supersession is preserved but not automatically applied.

    summary_diagnostics

    fn summary_diagnostics(analysis : Analysis) -> Array[Diagnostic]

    Compare reported counters with retained raw PRR/observation records, never with retest-selected parts or the yield-policy denominator. The current Summary projection has no source offset, so these diagnostics use offset 0. PCR good counts are compared only with complete, known part outcomes. TSR counts are compared only for observed supported test numbers, with no unknown test record types or incomplete/orphan part/test contexts. A result array is one execution; not-executed/default-only records do not count.

    test_signature

    fn test_signature(m : Measurement) -> TestSignature

    test_statistics

    fn test_statistics(parts : Array[Part]) -> Array[TestStatistics]

    Deterministic first-seen signature order; each observation record is one execution, including MPR records with multiple values. Useful numeric samples require clear TEST_FLG bits 0..5, clear PARM_FLG bits 0..2, and a finite value. A finite failed sample still contributes. Geometric limit counts honor equality policy and never replace reported pass/fail, including alternate-limit passes. FTR contributes status only, without numeric data. Welford accumulation is normalized by a running magnitude scale so finite opposite-sign Doubles cannot overflow the difference or squared deviation.

    v4_record_json

    fn v4_record_json(frame : Frame) -> String raise StdfError

    One lossless-source record per JSON line; missing fields stay explicit.

    validate_v4

    fn validate_v4(data : Bytes) -> ValidationReport raise StdfError

    validation_json

    fn validation_json(report : ValidationReport) -> String

    yield_summary

    fn yield_summary(parts : Array[Part]) -> YieldSummary