feat(provider): emit workshop-rs/mapped-text-v1 from opy-provider - #368
Conversation
Serve LPP 1.3 and 1.4. In a 1.4 session lpp/compile honors acceptedArtifactFormats and returns the first listed format it can produce, mapped-text-v1 or text-v1; sessions before 1.4 reject the field with -32602 and requests without it keep the text-v1 output. The mapping is the workshop-rs SourceMap extracted from the lowered program, proven against the re-parsed Workshop text, with file table entries rewritten to document URIs. Macro-expanded code now maps to the invocation site instead of the macro definition. Fixes #362
Teakowa
left a comment
There was a problem hiding this comment.
Three blocking findings:
-
crates/opy-provider/src/main.rs— unsupported artifact negotiation is only refused while building a successful artifact. IfacceptedArtifactFormatscontains no producible format and compilation fails,artifact_jsonis never called, so the request returns ordinary diagnostics instead ofcompile.artifactFormatUnsupported. This contradicts the PR's documented 1.4 behavior and makes negotiation depend on source validity. Reject the unsupported selection before loading/compiling, and cover the failing-source case. -
crates/opy-rs/src/compiler/backend.rs— relocating every span in macro-expanded HIR changes the shared diagnostic spans, not just the new Workshop source map. #362 explicitly lists changes to OPY diagnostics as a non-goal, while this PR states that diagnostics inside macro expansions move to the invocation site. Keep the invocation-site policy confined to mapped-artifact attribution so existing diagnostic behavior remains unchanged. -
crates/opy-rs/src/compiler/mod.rs— adding publicmapped: Option<MappedText>to exhaustive publicCompileResultis a Rust API break (the crate is currently 0.1.54, so downstream struct construction/patterns within the 0.1 compatible range can break), even though the field isserde(skip)and is not part of the versioned report wire contract. #362 only requires provider mapped output. Remove this breaking field and carry the provider-only mapping through a non-breaking path/API.
Attribute macro-expanded spans to the invocation site in a separate lowering used only for the mapped artifact, so diagnostics and lowering keep their definition spans. Return the mapped text beside the compile report instead of adding a public CompileResult field. Refs #362
|
Pushed 8e0a31d addressing findings 2 and 3.
|
Fixes #362
Summary
opy-providerserves LPP 1.3 and 1.4. In a 1.4 sessionlpp/compilehonorsacceptedArtifactFormatsand returns the first listed format it can produce (workshop-rs/mapped-text-v1orworkshop-rs/text-v1). Earlier sessions reject the field with-32602; requests without it are unchanged.SourceMap, checked against the re-parsed Workshop text; file table entries are rewritten to document URIs.CompileReportby a new method; no public struct changes.Verification
cargo test --workspace,cargo fmt,cargo clippypass.c010e1apasses viaOPY_BASTION_MAIN=<src/main.opy> cargo test -p opy-provider pinned_bastion(skipped when unset).Notes