What a semantic patch can honestly prove about WebAssembly output
What a semantic patch can honestly prove about WebAssembly output
语义补丁对 WebAssembly 输出的真实证明能力
When a coding agent changes a systems program, a source diff is only the beginning of the question. The more useful question is: what exact machine-facing artifacts would this semantic change produce, and can another process independently verify that relationship? 当编程智能体(coding agent)修改系统程序时,源代码差异(diff)仅仅是问题的开始。更有意义的问题是:这种语义变更究竟会产生哪些面向机器的产物?另一个进程能否独立验证这种关系?
That is one of the research problems we are exploring in SEMAPRAX, an Apache-2.0 agent-native systems programming language built at Wavect GmbH. SEMAPRAX is currently v0.2 pre-alpha experimental research software. It is not production-ready. The narrow mechanism described here is useful precisely because its claims are bounded. 这正是我们在 SEMAPRAX 中探索的研究课题之一。SEMAPRAX 是由 Wavect GmbH 开发的一种采用 Apache-2.0 协议的智能体原生系统编程语言。目前 SEMAPRAX 处于 v0.2 预 alpha 阶段的实验性研究软件,尚未达到生产就绪状态。此处描述的狭义机制之所以有用,恰恰是因为其声明范围是受限的。
From a patch to target projections SEMAPRAX has a read-only command: semaprax target-evidence <file> <patch.spatch> The command takes a verified source snapshot and a semantic patch. It independently rebuilds both the base program and the patched candidate, then derives several deterministic compiler-owned projections: semantic Graph JSON, an explicit capability manifest, Native C11 source, a structurally validated WebAssembly Core module.
从补丁到目标投影,SEMAPRAX 提供了一个只读命令:semaprax target-evidence <file> <patch.spatch>。该命令接收一个已验证的源代码快照和一个语义补丁。它会独立重建基础程序和打补丁后的候选程序,然后推导出几种确定性的编译器自有投影:语义图 JSON、显式能力清单、原生 C11 源代码以及结构化验证过的 WebAssembly 核心模块。
For every projection, the report records a domain-separated digest and byte length. It also classifies the projection as changed or unchanged. That sounds simple, but the distinction matters. A source edit can leave one projection unchanged while altering another. A documentation-level identity change, a capability change, and a runtime-behavior change should not all be flattened into the same “some bytes changed” signal. The target report therefore binds the proposed semantic change to the compiler artifacts it actually affects. 对于每一个投影,报告都会记录一个域隔离(domain-separated)的摘要和字节长度,并将其分类为“已更改”或“未更改”。这听起来很简单,但这种区分至关重要。源代码的编辑可能导致一个投影保持不变,而另一个发生改变。文档层面的标识变更、能力变更和运行时行为变更,不应被统一简化为相同的“某些字节已更改”信号。因此,目标报告将提议的语义变更与其真正影响的编译器产物绑定在一起。
Why deterministic output is the prerequisite
为什么确定性输出是先决条件
Evidence over compiler output is only useful when the output is reproducible. SEMAPRAX treats source formatting, semantic graph data, diagnostics, semantic patches, and target artifacts as deterministic projections. The same admitted input must produce the same bytes. Otherwise a digest says little: a second verifier could not distinguish a meaningful change from nondeterministic code generation. 只有当输出可复现时,关于编译器输出的证据才有意义。SEMAPRAX 将源代码格式、语义图数据、诊断信息、语义补丁和目标产物视为确定性投影。相同的输入必须产生相同的字节。否则,摘要就失去了意义:第二个验证者无法区分有意义的变更与非确定性的代码生成。
This is also why the report uses domain separation. A digest of a semantic graph should not be confused with a digest of a Wasm module, even if a contrived byte sequence happened to match. Each artifact is hashed in its own named domain. 这也是报告使用域隔离的原因。语义图的摘要不应与 Wasm 模块的摘要混淆,即使偶然匹配到了相同的字节序列。每个产物都在其各自的命名域中进行哈希处理。
The WebAssembly boundary
WebAssembly 的边界
The current WebAssembly lane uses the profile semaprax.wasm-core.v1. The emitted module is structurally checked using wasmparser 0.256.0 with its full feature set. Structural validation answers a real but limited question: is this byte sequence a structurally valid WebAssembly Core module under that validator configuration? It does not answer whether the program was executed correctly. It does not establish host compatibility, ABI correctness, safety, performance, provenance, policy approval, or conformance across runtimes.
当前的 WebAssembly 通道使用 semaprax.wasm-core.v1 配置文件。生成的模块使用 wasmparser 0.256.0 及其全功能集进行结构检查。结构验证回答了一个真实但有限的问题:在特定的验证器配置下,该字节序列是否为一个结构合法的 WebAssembly 核心模块?它无法回答程序是否执行正确,也无法确立宿主兼容性、ABI 正确性、安全性、性能、来源、策略批准或跨运行时的合规性。
SEMAPRAX’s public Wasm support is deliberately partial today. It covers bounded scalar exports and generated JavaScript/TypeScript bindings. It is not general WASI support, and it is not a broad WebAssembly Component Model implementation. Those nonclaims are part of the design. Evidence becomes dangerous when a convenient static fact is presented as a stronger runtime guarantee. 目前 SEMAPRAX 的公开 Wasm 支持是有意为之的局部支持。它涵盖了有界的标量导出和生成的 JavaScript/TypeScript 绑定。它不是通用的 WASI 支持,也不是广泛的 WebAssembly 组件模型实现。这些“非声明”是设计的一部分。当一个便捷的静态事实被呈现为更强的运行时保证时,证据就会变得危险。
Replay before authority
授权前的重放
A target report is still only evidence. By itself, it has no permission to modify source. SEMAPRAX can wrap the report in an additive Evidence v2 capsule tied to the semantic patch. The evidence-gated apply route acquires the ordinary single-file authority, independently replays the exact bounded change, reconstructs the target report, and checks the binding before committing.
目标报告仅仅是证据。它本身没有修改源代码的权限。SEMAPRAX 可以将报告封装在与语义补丁绑定的附加 Evidence v2 胶囊中。受证据约束的执行路径会获取常规的单文件权限,独立重放精确的受限变更,重建目标报告,并在提交前检查绑定关系。
Conceptually, the route is:
从概念上讲,该路径为:
verified source snapshot + semantic patch bytes | v independent replay | +--> candidate semantic graph +--> candidate capability manifest +--> candidate Native C11 source +--> candidate Wasm Core module | v exact evidence comparison | v commit or fail closed
If the source snapshot drifted, the patch bytes differ, replay fails, or any bound artifact differs, the evidence-gated route must not commit the change. This keeps three ideas separate: Meaning — the verified semantic change; Evidence — deterministic facts about its projections; Authority — the narrow operation allowed to publish it. 如果源代码快照发生偏移、补丁字节不同、重放失败或任何绑定的产物不一致,受证据约束的路径绝不能提交变更。这保持了三个概念的独立性:含义(已验证的语义变更)、证据(关于其投影的确定性事实)、权限(允许发布该变更的狭义操作)。
Why this may matter for agent-written systems code
为什么这对智能体编写的系统代码很重要
Text diffs are optimized for human review. Agents can consume them too, but they do not directly expose persistent semantic identity, resolved relationships, capability changes, or target consequences. An agent-oriented toolchain can make those facts first-class without pretending that agents are infallible. The goal is not to replace review with a digest. The goal is to give reviewers and automated policies a replayable statement that is narrower, more precise, and easier to falsify. 文本差异(diff)是为人类审查优化的。智能体也可以处理它们,但它们无法直接暴露持久的语义标识、已解析的关系、能力变更或目标后果。面向智能体的工具链可以将这些事实作为一等公民,而无需假装智能体不会犯错。目标不是用摘要取代审查,而是为审查者和自动化策略提供一种可重放的声明,使其更狭窄、更精确且更容易被证伪。
For WebAssembly toolchains, this raises practical questions we would value feedback on: 对于 WebAssembly 工具链,这引出了一些我们期待反馈的实际问题:
- Which compiler facts are useful to bind alongside Wasm bytes? (哪些编译器事实适合与 Wasm 字节绑定?)
- Which runtime observations belong in a separate evidence layer? (哪些运行时观察结果属于独立的证据层?)
- How should toolchains describe validator configuration so reports remain replayable years later? (工具链应如何描述验证器配置,以确保报告在多年后仍可重放?)
- Where should the boundary sit between a compiler-owned artifact and host-owned execution evidence? (编译器自有产物与宿主自有执行证据之间的边界应在哪里?)
You can inspect the research project at wavect.io/semaprax and the SEMAPRAX source repository. 您可以访问 wavect.io/semaprax 和 SEMAPRAX 源代码仓库查看该研究项目。
Disclosure: coding agents have been used extensively as development assistants on SEMAPRAX. Wavect GmbH retains human responsibility for the project and uses executable quality gates. The implementation remains experimental and not production-ready. 披露:在 SEMAPRAX 的开发过程中,编程智能体被广泛用作开发助手。Wavect GmbH 对该项目保留人类责任,并使用可执行的质量门禁。该实现仍处于实验阶段,尚未达到生产就绪状态。