From 17c7b2318d89926458ec92e1b223dbf58ff36f1f Mon Sep 17 00:00:00 2001 From: Kinflou Date: Wed, 2 Sep 2026 16:05:26 +0800 Subject: [PATCH 1/2] feat(rust): emit the canonical IR_HASH from comline-core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop the local FNV-over-Debug `ir_hash` and emit `comline_core::schema::ir::frozen::schema_ir_hash(units)` instead — the canonical BLAKE3-over-bincode digest, identical across generators and target languages. The generated `IR_HASH` const changes value (a better identity); no test pins the old hex. Bumps comline-core to 50c17cc. The comline-codegen pin follows in a fixup once generation bumps its core pin to match. --- codegen/Cargo.toml | 2 +- codegen/src/generator.rs | 21 ++++----------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 073b56b..822f1f9 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -10,7 +10,7 @@ license = "GPL-3.0-only" # same generation rev `comline-typescript` uses, so a CLI build has one # `comline-codegen`. Local iteration: add a `[patch]` onto a sibling checkout. comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "c70336dcc9485cea2c99b0f1db3789e420deaeda" } -comline-core = { git = "https://github.com/ComlineProject/core", rev = "47ac5f10a36b587d14d1b9672fba65d8f3712962" } +comline-core = { git = "https://github.com/ComlineProject/core", rev = "50c17cc740676416e945582dd6e2547e8535ac03" } eyre = "0.6.8" diff --git a/codegen/src/generator.rs b/codegen/src/generator.rs index 732cc40..646d265 100644 --- a/codegen/src/generator.rs +++ b/codegen/src/generator.rs @@ -11,6 +11,7 @@ use std::collections::HashMap; use std::path::PathBuf; use comline_core::schema::ir::compiler::interpreted::kind_search::KindValue; +use comline_core::schema::ir::frozen::schema_ir_hash; use comline_core::schema::ir::frozen::unit::{FrozenArgument, FrozenUnit}; use eyre::{bail, Result}; @@ -173,10 +174,10 @@ fn schema_source(units: &[FrozenUnit], default_framing: Option<&str>) -> String if has_protocol { output.push_str(&format!( - "/// Fingerprint of the frozen IR this file was generated from — the two\n\ - /// ends of a connection [`Handshake`] must agree on it.\n\ + "/// Canonical digest of the frozen IR this file was generated from — the\n\ + /// two ends of a connection [`Handshake`] must agree on it.\n\ pub const IR_HASH: u64 = {:#018x};\n\n", - ir_hash(units) + schema_ir_hash(units) )); } @@ -212,20 +213,6 @@ fn schema_source(units: &[FrozenUnit], default_framing: Option<&str>) -> String output } -/// A deterministic fingerprint of the schema's frozen units — FNV-1a over their -/// `Debug` form. Stable for a given generator version; a generator bump changes -/// it, which is correct (different codegen ⇒ a new handshake identity). A -/// canonical cross-language hash from `core`'s CAS, threaded through -/// `GenRequest`, is the eventual form. -fn ir_hash(units: &[FrozenUnit]) -> u64 { - let mut h: u64 = 0xcbf2_9ce4_8422_2325; - for b in format!("{units:?}").as_bytes() { - h ^= u64::from(*b); - h = h.wrapping_mul(0x0000_0100_0000_01b3); - } - h -} - // ── data types ───────────────────────────────────────────────────────────── fn field_lines(fields: &[FrozenUnit]) -> String { From f29f6517b9c70f488e7539219be890ef2c4151e4 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Wed, 2 Sep 2026 16:06:48 +0800 Subject: [PATCH 2/2] chore: bump comline-codegen to generation d901db4 (matches core 50c17cc) --- codegen/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 822f1f9..f3a6ac3 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-only" # repository structure — no crates.io publishing at this stage). Pinned to the # same generation rev `comline-typescript` uses, so a CLI build has one # `comline-codegen`. Local iteration: add a `[patch]` onto a sibling checkout. -comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "c70336dcc9485cea2c99b0f1db3789e420deaeda" } +comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "d901db42d094ea9e2f59a310e6e885767abcae6b" } comline-core = { git = "https://github.com/ComlineProject/core", rev = "50c17cc740676416e945582dd6e2547e8535ac03" } eyre = "0.6.8"