Skip to content

Conversation

@ukint-vs
Copy link
Member

@ukint-vs ukint-vs commented Nov 17, 2025

Emission Pipeline

  1. Build scripts invoke sails_build::emit_interface_consts which runs the host-only sails_meta_dump binary and writes INTERFACE_ID, ENTRY_META, and CANONICAL_INTERFACE_JSON to OUT_DIR.
  2. The #[service] macro includes those consts whenever the sails-canonical feature is enabled (and emits an all-zero stub otherwise), so every crate exposes the same API regardless of build mode.
  3. Clients and runtimes read the consts at compile time and construct Sails headers without running canonicalization on-chain or at runtime.

Program new structure

The program/service now keeps its canonicalization targets in sails_services.in. Both the build script and the
sails_meta_dump helper include that manifest by first defining a local sails_services_manifest! macro (that expands to either
sails_build::service_paths! or sails_build::service_manifest!) and then include!-ing the file. Adding or removing services only
requires editing that single file. The file stores the bare services: [ ... ] payload (optionally wrapped in braces) and may declare
witness aliases before the services block if a generic service needs to be instantiated with a concrete client type.

build.rs drives canonicalization exclusively at compile time via the sails_build::BuildScript helper:

BuildScript::new(SERVICE_PATHS)
    .manifest_path("sails_services.in")
    .meta_dump_features(&["sails-canonical", "sails-meta-dump"])
    .wasm_build(WasmBuildConfig::new("CARGO_FEATURE_WASM_BUILDER", || {
        let _ = sails_rs::build_wasm();
    }))
    .run()
    .expect("generate canonical interface constants");

When the sails-canonical feature is enabled (default), the #[service] macro includes the generated INTERFACE_ID, ENTRY_META, and canonical JSON constants. When building the host-only sails_meta_dump binary or running with SAILS_CANONICAL_DUMP, the macros fall back to zeroed stubs so compile times stay minimal; no runtime canonicalization path exists. Diagnostic metadata (type_bindings, display names) is emitted in $OUT_DIR/sails_interface_consts/manifest.json, keeping the hashed JSON purely structural while still providing human-readable names for tooling.

@ukint-vs ukint-vs requested a review from vobradovich November 17, 2025 11:19
@ukint-vs ukint-vs self-assigned this Nov 17, 2025
@ukint-vs ukint-vs changed the title feat: Service canonicalization, build-system, canincal data embedding feat: Service canonicalization, build-system, data embedding Nov 17, 2025
Base automatically changed from vo/idl-v2-spec-ast to master-idl-v2 November 17, 2025 12:39
@techraed
Copy link
Contributor

techraed commented Dec 3, 2025

closed in favor of #1114

@techraed techraed closed this Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants