From f4b7fc426341918172a3643130b99fa570644897 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 22 Nov 2026 01:52:52 +0100 Subject: [PATCH 01/32] fix(expression): copy values that read the node's own output on the compiled path --- core/expression/src/lane/compile.rs | 16 ++++++++++++++++ core/expression/src/lane/exec/mod.rs | 10 +++++++++- core/expression/src/lane/kernel.rs | 16 +++++++++++++++- core/expression/src/lane/program.rs | 1 + 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/core/expression/src/lane/compile.rs b/core/expression/src/lane/compile.rs index 348152c3..2861c5cb 100644 --- a/core/expression/src/lane/compile.rs +++ b/core/expression/src/lane/compile.rs @@ -340,6 +340,7 @@ impl<'a> LaneCompiler<'a> { compiler.emit(Op::DollarInsert { key: Arc::from(*key), value: out, + copy: Self::reads_built(root), }); if let Some(shared) = compiler.shared.as_mut() { shared.retain(|(k, _)| k != "env:$" && !k.starts_with("path:$")); @@ -504,6 +505,21 @@ impl<'a> LaneCompiler<'a> { Some(Ok(reg)) } + pub(crate) fn reads_built(node: &Node) -> bool { + let found = std::cell::Cell::new(false); + node.walk(|node| { + let reads = match node { + Node::Identifier(name) => name.starts_with('$'), + Node::Root => true, + _ => false, + }; + if reads { + found.set(true); + } + }); + found.get() + } + #[cfg_attr(not(target_family = "wasm"), recursive::recursive)] pub(crate) fn dollar_static(node: &Node) -> bool { let mut base = node; diff --git a/core/expression/src/lane/exec/mod.rs b/core/expression/src/lane/exec/mod.rs index f39dff6d..3e69b232 100644 --- a/core/expression/src/lane/exec/mod.rs +++ b/core/expression/src/lane/exec/mod.rs @@ -1215,10 +1215,18 @@ impl Executor { } } } - Op::DollarInsert { key, value } => { + Op::DollarInsert { key, value, copy } => { for lane in Lanes::of(active) { let row = f.rows[lane]; let v = f.value(*value, lane); + let v = match copy { + true => { + let copied = v.deep_clone(); + f.set(*value, lane, copied.clone()); + copied + } + false => v, + }; let Some(root) = ctx.roots.get_mut(row) else { continue; }; diff --git a/core/expression/src/lane/kernel.rs b/core/expression/src/lane/kernel.rs index dadb4d62..4bc1f1c3 100644 --- a/core/expression/src/lane/kernel.rs +++ b/core/expression/src/lane/kernel.rs @@ -424,7 +424,11 @@ impl Members { enum Mode { Plain, Owned, - Dynamic { keys: Box<[Box]>, rewind: bool }, + Dynamic { + keys: Box<[Box]>, + copies: Box<[bool]>, + rewind: bool, + }, } pub(crate) struct Kernel { @@ -527,6 +531,10 @@ impl Kernel { let mode = match (dynamic, assigns) { (true, rewind) => Mode::Dynamic { keys: roots.iter().map(|(k, _)| Box::from(*k)).collect(), + copies: roots + .iter() + .map(|(_, n)| LaneCompiler::reads_built(n)) + .collect(), rewind, }, (false, true) => Mode::Owned, @@ -637,6 +645,12 @@ impl Kernel { element: None, up: None, })?; + let value = match &self.mode { + Mode::Dynamic { copies, .. } if copies.get(index).copied().unwrap_or(false) => { + value.deep_clone() + } + _ => value, + }; if let (Mode::Dynamic { keys, .. }, Some(current), Some(roots)) = (&self.mode, ¤t, &roots) { diff --git a/core/expression/src/lane/program.rs b/core/expression/src/lane/program.rs index 356af3b8..9ec30f65 100644 --- a/core/expression/src/lane/program.rs +++ b/core/expression/src/lane/program.rs @@ -368,6 +368,7 @@ pub enum Op { DollarInsert { key: Arc, value: Reg, + copy: bool, }, Fold(Box), Switch(Box), From 1bdb98daeca5c7aab0ea3e30d39d028c41a7740b Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 22 Nov 2026 01:52:53 +0100 Subject: [PATCH 02/32] fix(expression): match a date against every text cell naming it --- core/expression/src/lane/cells.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/core/expression/src/lane/cells.rs b/core/expression/src/lane/cells.rs index 06fafc27..b7b6316c 100644 --- a/core/expression/src/lane/cells.rs +++ b/core/expression/src/lane/cells.rs @@ -9,6 +9,7 @@ use crate::variable::Variable; use crate::IsolateError; use ahash::HashMap; use bumpalo::Bump; +use chrono_tz::Tz; use rust_decimal::Decimal; use std::sync::Arc; @@ -812,8 +813,30 @@ impl CellSet { } } + fn dates_overlap(&self) -> bool { + use crate::lane::date::Date; + let readings: Vec<(Date, Date)> = self + .strs + .iter() + .filter_map(|(key, _)| { + let text = String::from_utf8_lossy(key); + let here = Date::from_text(&text, Tz::UTC); + let there = Date::from_text(&text, Tz::Etc__GMTMinus14); + (here.is_valid() || there.is_valid()).then_some((here, there)) + }) + .collect(); + readings.iter().enumerate().any(|(at, (here, there))| { + readings[at + 1..].iter().any(|(other, elsewhere)| { + match (here != there, other != elsewhere) { + (true, true) | (false, false) => here == other, + _ => true, + } + }) + }) + } + pub fn pieces(&self, empty: &[u64]) -> Option { - if !self.others.is_empty() || self.strs.len() > 64 { + if !self.others.is_empty() || self.strs.len() > 64 || self.dates_overlap() { return None; } let mut bits: Vec> = Vec::new(); From b9d6befc0185fc030d051b114244802185cef542 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 22 Nov 2026 01:52:53 +0100 Subject: [PATCH 03/32] test(engine): cover the fixed version differences on every evaluation path --- core/engine/tests/version_parity.rs | 176 ++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 core/engine/tests/version_parity.rs diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs new file mode 100644 index 00000000..0ac66db1 --- /dev/null +++ b/core/engine/tests/version_parity.rs @@ -0,0 +1,176 @@ +use serde_json::{json, Value}; +use std::sync::Arc; +use zen_engine::model::DecisionContent; +use zen_engine::{DecisionEngine, EngineVersion, EvaluationOptions, Variable}; + +fn graph(node: Value) -> Value { + json!({ + "nodes": [ + {"id": "in", "name": "in", "type": "inputNode"}, + node, + {"id": "out", "name": "out", "type": "outputNode"} + ], + "edges": [ + {"id": "e1", "sourceId": "in", "targetId": "node", "type": "edge"}, + {"id": "e2", "sourceId": "node", "targetId": "out", "type": "edge"} + ] + }) +} + +fn expressions(pairs: &[(&str, &str)]) -> Value { + let list: Vec = pairs + .iter() + .enumerate() + .map(|(i, (key, value))| json!({"id": format!("x{i}"), "key": key, "value": value})) + .collect(); + graph( + json!({"id": "node", "name": "node", "type": "expressionNode", "content": {"expressions": list}}), + ) +} + +fn table(policy: &str, field: &str, cells: &[&str]) -> Value { + let rules: Vec = cells + .iter() + .enumerate() + .map(|(i, cell)| json!({"_id": format!("r{i}"), "i0": cell, "o0": i.to_string()})) + .collect(); + graph( + json!({"id": "node", "name": "node", "type": "decisionTableNode", "content": { + "hitPolicy": policy, + "inputs": [{"id": "i0", "field": field}], + "outputs": [{"id": "o0", "field": "out"}], + "rules": rules + }}), + ) +} + +#[derive(Clone, Copy, Debug)] +enum Path { + Repeated, + Compiled, + Batch, +} + +fn outcomes(version: EngineVersion, path: Path, graph: &Value, input: &Value) -> Vec { + let content: DecisionContent = serde_json::from_value(graph.clone()).unwrap(); + let engine = DecisionEngine::default().with_version(version); + let mut decision = engine.create_decision(Arc::new(content)).unwrap(); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let one = + |decision: &zen_engine::Decision| { + runtime + .block_on(decision.evaluate_with_opts( + Variable::from(input.clone()), + EvaluationOptions::default(), + )) + .map(|response| response.result.to_value()) + .unwrap_or_else(|error| json!({"error": error.to_string()})) + }; + match path { + Path::Repeated => (0..3).map(|_| one(&decision)).collect(), + Path::Compiled => { + decision.compile(); + (0..3).map(|_| one(&decision)).collect() + } + Path::Batch => { + let rows = vec![Variable::from(input.clone()); 3]; + runtime + .block_on(decision.evaluate_batch(&rows, EvaluationOptions::default())) + .into_iter() + .map(|row| { + row.map(|response| response.result.to_value()) + .unwrap_or_else(|error| json!({"error": error.to_string()})) + }) + .collect() + } + } +} + +fn same_on_every_path(graph: &Value, input: &Value, want: Value) { + for path in [Path::Repeated, Path::Compiled, Path::Batch] { + for version in [EngineVersion::V1, EngineVersion::V2] { + for (call, got) in outcomes(version, path, graph, input) + .into_iter() + .enumerate() + { + assert_eq!(got, want, "{version:?} {path:?} call {call}"); + } + } + } +} + +#[test] +fn a_field_can_hold_the_fields_built_so_far() { + same_on_every_path( + &expressions(&[("a", "1"), ("b", "$")]), + &json!({}), + json!({"a": 1, "b": {"a": 1}}), + ); + same_on_every_path( + &expressions(&[("r", "1"), ("s", "[$]")]), + &json!({}), + json!({"r": 1, "s": [{"r": 1}]}), + ); + same_on_every_path( + &expressions(&[("a.c", "1"), ("a.b", "$.a")]), + &json!({}), + json!({"a": {"b": {"c": 1}, "c": 1}}), + ); + same_on_every_path( + &expressions(&[("big", "false"), ("res", "$root")]), + &json!({}), + json!({"big": false, "res": {"$": {"big": false}}}), + ); +} + +#[test] +fn a_field_read_earlier_keeps_its_value_when_the_branch_grows() { + same_on_every_path( + &expressions(&[("a.b", "1"), ("n", "$.a"), ("a.c", "2")]), + &json!({}), + json!({"a": {"b": 1, "c": 2}, "n": {"b": 1}}), + ); + same_on_every_path( + &expressions(&[("a.b.c", "1"), ("x", "[$.a.b]"), ("a.b.d", "2")]), + &json!({}), + json!({"a": {"b": {"c": 1, "d": 2}}, "x": [{"c": 1}]}), + ); +} + +#[test] +fn a_date_matches_every_text_cell_naming_it() { + let input = json!({"x": "2024-01-01"}); + for _ in 0..20 { + same_on_every_path( + &table("first", "d(x)", &["'2024-01-01'", "'2024'"]), + &input, + json!({"out": 0}), + ); + same_on_every_path( + &table( + "first", + "d(x)", + &["'a'", "'2024-01'", "'2024-01-01'"], + ), + &input, + json!({"out": 1}), + ); + same_on_every_path( + &table( + "collect", + "d(x)", + &["'2024-01-01'", "'2024-01'", ""], + ), + &input, + json!([{"out": 0}, {"out": 1}, {"out": 2}]), + ); + same_on_every_path( + &table("first", "d(x)", &["'2023-12-31', '2024'", "'2024-01-01'"]), + &input, + json!({"out": 0}), + ); + } +} From 10ecc76fb0c652839974559146053bcdf74e562b Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 22 Nov 2026 03:24:32 +0100 Subject: [PATCH 04/32] fix(engine): keep the table index and compiled plan off tables whose cells read the last tested value --- core/engine/src/compiled/content.rs | 3 +-- core/engine/src/compiled/table/mod.rs | 3 +++ core/engine/src/model/decision_content.rs | 3 +-- core/engine/src/nodes/decision_table/index.rs | 18 ++++++++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/core/engine/src/compiled/content.rs b/core/engine/src/compiled/content.rs index 8e3cac9a..995b8b0c 100644 --- a/core/engine/src/compiled/content.rs +++ b/core/engine/src/compiled/content.rs @@ -85,8 +85,7 @@ impl Content { .iter() .filter_map(|node| match &node.kind { DecisionNodeKind::DecisionTableNode { content } => { - TableIndex::build(&content.inputs, &content.rules) - .map(|index| (node.id.clone(), index)) + TableIndex::graph(content).map(|index| (node.id.clone(), index)) } _ => None, }) diff --git a/core/engine/src/compiled/table/mod.rs b/core/engine/src/compiled/table/mod.rs index 8bf1bbfb..fe63f240 100644 --- a/core/engine/src/compiled/table/mod.rs +++ b/core/engine/src/compiled/table/mod.rs @@ -233,6 +233,9 @@ impl Table { }; match field { Some(field) => { + if !strict && SourceInfo::reads_dollar(field) { + return Err("table field reads `$`".into()); + } if strict && cells .iter() diff --git a/core/engine/src/model/decision_content.rs b/core/engine/src/model/decision_content.rs index b920ca2f..05408870 100644 --- a/core/engine/src/model/decision_content.rs +++ b/core/engine/src/model/decision_content.rs @@ -212,8 +212,7 @@ impl GraphContent { .iter() .filter_map(|node| match &node.kind { DecisionNodeKind::DecisionTableNode { content } => { - TableIndex::build(&content.inputs, &content.rules) - .map(|index| (node.id.clone(), index)) + TableIndex::graph(content).map(|index| (node.id.clone(), index)) } _ => None, }) diff --git a/core/engine/src/nodes/decision_table/index.rs b/core/engine/src/nodes/decision_table/index.rs index 9d3b4e9a..1fdbabf8 100644 --- a/core/engine/src/nodes/decision_table/index.rs +++ b/core/engine/src/nodes/decision_table/index.rs @@ -23,6 +23,24 @@ pub(crate) struct ColumnIndex { } impl TableIndex { + pub(crate) fn graph(content: &zen_types::decision::DecisionTableContent) -> Option { + let reads = |source: &Arc| source.contains('$'); + let bound = |id: &Arc| { + content + .rules + .iter() + .any(|rule| rule.get(id).is_some_and(reads)) + }; + let leaks = content.inputs.iter().any(|input| match &input.field { + Some(field) => reads(field), + None => bound(&input.id), + }) || content.outputs.iter().any(|output| bound(&output.id)); + match leaks { + true => None, + false => Self::build(&content.inputs, &content.rules), + } + } + pub(crate) fn build( inputs: &[DecisionTableInputField], rules: &[HashMap, Arc>], From 930623b40bac27483c3073b88e61bee9c646e785 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 22 Nov 2026 03:24:32 +0100 Subject: [PATCH 05/32] fix(engine): give batch rows the node values and replaced fields a single row sees --- core/engine/src/compiled/graph/state/mod.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/core/engine/src/compiled/graph/state/mod.rs b/core/engine/src/compiled/graph/state/mod.rs index a96e4c89..6aa273b4 100644 --- a/core/engine/src/compiled/graph/state/mod.rs +++ b/core/engine/src/compiled/graph/state/mod.rs @@ -369,7 +369,11 @@ impl CompiledGraph { ) -> (Vec>, Vec>) { match ( step.nodes, - columnar && step.statics.is_some() && state.nesting.parents.is_none(), + columnar + && !step.dynamic + && !step.root + && step.statics.is_some() + && state.nesting.parents.is_none(), ) { (false, _) => (Vec::new(), Vec::new()), (true, true) => (Vec::new(), self.node_columns(step, state, visible, rows)), @@ -391,10 +395,20 @@ impl CompiledGraph { if leaves.is_empty() { return false; } + let rebuilt = |key: &str| { + rebase.is_some_and(|base| { + key == base + || zen_types::path::DotPath::under(key, base) + || zen_types::path::DotPath::under(base, key) + }) + }; (step.root && rebase.is_none()) || step.dynamic || leaves.iter().any(|(k, _)| { - k.as_ref() == "$" || k.as_ref() == "$nodes" || k.starts_with("$nodes.") + k.as_ref() == "$" + || k.as_ref() == "$nodes" + || k.starts_with("$nodes.") + || rebuilt(k) }) } From bb51bd22be9f23596ff19af1605917320bd8bdc3 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 22 Nov 2026 03:24:32 +0100 Subject: [PATCH 06/32] test(engine): cover the batch and table differences on every evaluation path --- core/engine/tests/version_parity.rs | 140 ++++++++++++++++++++++++++-- 1 file changed, 130 insertions(+), 10 deletions(-) diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 0ac66db1..9e1f0fc8 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -150,20 +150,12 @@ fn a_date_matches_every_text_cell_naming_it() { json!({"out": 0}), ); same_on_every_path( - &table( - "first", - "d(x)", - &["'a'", "'2024-01'", "'2024-01-01'"], - ), + &table("first", "d(x)", &["'a'", "'2024-01'", "'2024-01-01'"]), &input, json!({"out": 1}), ); same_on_every_path( - &table( - "collect", - "d(x)", - &["'2024-01-01'", "'2024-01'", ""], - ), + &table("collect", "d(x)", &["'2024-01-01'", "'2024-01'", ""]), &input, json!([{"out": 0}, {"out": 1}, {"out": 2}]), ); @@ -174,3 +166,131 @@ fn a_date_matches_every_text_cell_naming_it() { ); } } + +fn chained(nodes: Vec) -> Value { + let mut all = vec![json!({"id": "in", "name": "in", "type": "inputNode"})]; + all.extend(nodes); + all.push(json!({"id": "out", "name": "out", "type": "outputNode"})); + let ids: Vec = all + .iter() + .map(|n| n["id"].as_str().unwrap().to_string()) + .collect(); + let edges: Vec = ids + .windows(2) + .map(|w| json!({"id": format!("{}-{}", w[0], w[1]), "sourceId": w[0], "targetId": w[1], "type": "edge"})) + .collect(); + json!({"nodes": all, "edges": edges}) +} + +fn batch_rows_match_single_rows(graph: &Value, rows: &[Value]) { + let content: DecisionContent = serde_json::from_value(graph.clone()).unwrap(); + let decision = DecisionEngine::default() + .with_version(EngineVersion::V2) + .create_decision(Arc::new(content)) + .unwrap(); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let inputs: Vec = rows.iter().cloned().map(Variable::from).collect(); + let batch = runtime.block_on(decision.evaluate_batch(&inputs, EvaluationOptions::default())); + for (at, (row, got)) in rows.iter().zip(batch).enumerate() { + let got = got + .map(|response| response.result.to_value()) + .unwrap_or_else(|error| json!({"error": error.to_string()})); + let want = outcomes(EngineVersion::V1, Path::Repeated, graph, row).remove(0); + assert_eq!(got, want, "row {at}"); + } +} + +#[test] +fn a_batch_row_reads_earlier_nodes_beside_its_own_fields() { + batch_rows_match_single_rows( + &chained(vec![ + json!({"id": "calc", "name": "calc", "type": "expressionNode", "content": { + "expressions": [ + {"id": "a", "key": "q", "value": "$"}, + {"id": "b", "key": "n", "value": "$nodes.in"}, + {"id": "c", "key": "m", "value": "$nodes.in.x + 1"} + ] + }}), + ]), + &[json!({"x": 1}), json!({"x": 2})], + ); +} + +#[test] +fn a_batch_row_sees_a_field_another_node_replaced() { + let graph = |read: &str| { + chained(vec![ + json!({"id": "first", "name": "first", "type": "expressionNode", "content": { + "expressions": [{"id": "a", "key": "obj", "value": "{q: 1}"}], + "passThrough": true + }}), + json!({"id": "second", "name": "second", "type": "expressionNode", "content": { + "expressions": [{"id": "b", "key": "x", "value": read}], + "inputField": "obj" + }}), + ]) + }; + let rows = [json!({"obj": {"p": 1}}), json!({"obj": "s"}), json!({})]; + batch_rows_match_single_rows(&graph("zz ?? 1"), &rows); + batch_rows_match_single_rows(&graph("p ?? 9"), &rows); + batch_rows_match_single_rows(&graph("q"), &rows); +} + +fn wide_table(policy: &str, inputs: Value, rules: Vec) -> Value { + graph( + json!({"id": "node", "name": "node", "type": "decisionTableNode", "content": { + "hitPolicy": policy, + "inputs": inputs, + "outputs": [{"id": "o0", "field": "v"}], + "rules": rules + }}), + ) +} + +#[test] +fn a_table_cell_reads_the_last_tested_value_however_many_rules_there_are() { + for padding in [0, 3, 7, 20] { + let mut rules = vec![json!({"_id": "r0", "i0": "", "o0": "$"})]; + for at in 0..padding { + rules.push( + json!({"_id": format!("p{at}"), "i0": format!("\"q{at}\""), "o0": at.to_string()}), + ); + } + same_on_every_path( + &wide_table("first", json!([{"id": "i0", "field": "s"}]), rules.clone()), + &json!({"s": "x"}), + json!({}), + ); + rules.rotate_left(1); + same_on_every_path( + &wide_table("first", json!([{"id": "i0", "field": "s"}]), rules), + &json!({"s": "x"}), + match padding { + 0 => json!({}), + _ => json!({"v": "x"}), + }, + ); + } +} + +#[test] +fn a_table_column_can_test_the_value_of_the_column_before_it() { + let rules = vec![ + json!({"_id": "a", "i0": "> 1", "i1": "> 10", "o0": "'big'"}), + json!({"_id": "b", "i0": "", "i1": "", "o0": "'other'"}), + ]; + let inputs = json!([{"id": "i0", "field": "x"}, {"id": "i1", "field": "$"}]); + same_on_every_path( + &wide_table("first", inputs.clone(), rules.clone()), + &json!({"x": 20}), + json!({"v": "big"}), + ); + same_on_every_path( + &wide_table("first", inputs, rules), + &json!({"x": 5}), + json!({"v": "other"}), + ); +} From 0f15b19c0fcf50fcf08b98b5d5dd30d123d1d843 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 22 Nov 2026 04:07:19 +0100 Subject: [PATCH 07/32] fix(engine): read declared date inputs in the evaluation's time zone --- core/engine/src/compiled/graph/columnar.rs | 10 +- core/engine/src/compiled/graph/state/exec.rs | 11 +- core/engine/src/compiled/host/input/dates.rs | 12 +- core/engine/src/compiled/host/input/mod.rs | 6 +- core/engine/src/compiled/policy/artifact.rs | 3 +- .../src/compiled/policy/columnar/evaluate.rs | 11 +- .../src/compiled/policy/columnar/sheet.rs | 19 ++- core/engine/src/compiled/policy/mod.rs | 16 +-- core/engine/src/compiled/policy/traced.rs | 2 +- core/engine/src/compiled/policy/validator.rs | 44 +++++-- core/engine/src/compiled/shred.rs | 3 +- core/engine/tests/version_parity.rs | 117 ++++++++++++++++++ core/expression/src/dates.rs | 4 + core/expression/src/vm/date/mod.rs | 7 +- 14 files changed, 221 insertions(+), 44 deletions(-) diff --git a/core/engine/src/compiled/graph/columnar.rs b/core/engine/src/compiled/graph/columnar.rs index e0ea393f..2bcdceb5 100644 --- a/core/engine/src/compiled/graph/columnar.rs +++ b/core/engine/src/compiled/graph/columnar.rs @@ -245,12 +245,16 @@ impl CompiledGraph { }) .collect(), dated: validator - .map(|(_, schema)| Self::dated(&schema, columns)) + .map(|(_, schema)| Self::dated(&schema, columns, extensions.context.timezone())) .unwrap_or_default(), }) } - fn dated<'a>(schema: &serde_json::Value, columns: &Columns<'_>) -> Vec<(usize, Leaf<'a>)> { + fn dated<'a>( + schema: &serde_json::Value, + columns: &Columns<'_>, + tz: zen_expression::context::Timezone, + ) -> Vec<(usize, Leaf<'a>)> { if !DeclaredDates::mentions(schema) { return Vec::new(); } @@ -264,7 +268,7 @@ impl CompiledGraph { let values: Rc<[Variable]> = (0..columns.rows) .map(|row| { let value = column.variable(row); - DeclaredDates::prepare(&value, Some(schema)).unwrap_or(value) + DeclaredDates::prepare(&value, Some(schema), tz).unwrap_or(value) }) .collect(); Some((index, Leaf::Any(values))) diff --git a/core/engine/src/compiled/graph/state/exec.rs b/core/engine/src/compiled/graph/state/exec.rs index a90b8706..65186d0c 100644 --- a/core/engine/src/compiled/graph/state/exec.rs +++ b/core/engine/src/compiled/graph/state/exec.rs @@ -142,7 +142,8 @@ impl CompiledGraph { .materialized() .iter() .map(|value| { - DeclaredDates::prepare(value, None).unwrap_or_else(|| value.clone()) + DeclaredDates::prepare(value, None, zen_expression::context::Timezone::UTC) + .unwrap_or_else(|| value.clone()) }) .collect(); (Rc::new(Data::plain(rows.clone(), values)), Vec::new()) @@ -298,8 +299,12 @@ impl CompiledGraph { if let Some((validator, schema)) = &validator { if validator.is_valid(VariableNode::new(value, &Guards::default())) { values.push(match step.kind { - Kind::Input => DeclaredDates::prepare(value, Some(schema)) - .unwrap_or_else(|| value.clone()), + Kind::Input => DeclaredDates::prepare( + value, + Some(schema), + extensions.context.timezone(), + ) + .unwrap_or_else(|| value.clone()), _ => value.clone(), }); continue; diff --git a/core/engine/src/compiled/host/input/dates.rs b/core/engine/src/compiled/host/input/dates.rs index b3100b31..671b8a17 100644 --- a/core/engine/src/compiled/host/input/dates.rs +++ b/core/engine/src/compiled/host/input/dates.rs @@ -56,10 +56,14 @@ impl DeclaredDates { && variants.iter().any(|v| !is_null(v) && Self::declared(v)) } - pub(crate) fn prepare(value: &Variable, schema: Option<&Value>) -> Option { + pub(crate) fn prepare( + value: &Variable, + schema: Option<&Value>, + tz: zen_expression::context::Timezone, + ) -> Option { if schema.is_some_and(Self::declared) { return match value { - Variable::String(text) => DateValue::from_text(text), + Variable::String(text) => DateValue::from_text_in(text, tz), _ => None, }; } @@ -71,12 +75,12 @@ impl DeclaredDates { .and_then(|o| Self::structure(o, "properties")) .and_then(Value::as_object); Self::rewrite_fields(value, |key, child| { - Self::prepare(child, properties.and_then(|p| p.get(key))) + Self::prepare(child, properties.and_then(|p| p.get(key)), tz) }) } Variable::Array(_) => { let items = object.and_then(|o| Self::structure(o, "items")); - Self::rewrite_items(value, |item| Self::prepare(item, items)) + Self::rewrite_items(value, |item| Self::prepare(item, items, tz)) } _ => None, } diff --git a/core/engine/src/compiled/host/input/mod.rs b/core/engine/src/compiled/host/input/mod.rs index 4eade014..c734f3ec 100644 --- a/core/engine/src/compiled/host/input/mod.rs +++ b/core/engine/src/compiled/host/input/mod.rs @@ -21,7 +21,11 @@ impl NodeHandler for InputNodeHandler { ctx.validate(json_schema, &ctx.input)?; } - let output = dates::DeclaredDates::prepare(&ctx.input, ctx.node.schema.as_deref()); + let output = dates::DeclaredDates::prepare( + &ctx.input, + ctx.node.schema.as_deref(), + ctx.extensions.context.timezone(), + ); ctx.success(output.unwrap_or_else(|| ctx.input.clone())) } } diff --git a/core/engine/src/compiled/policy/artifact.rs b/core/engine/src/compiled/policy/artifact.rs index 6243a22a..a1843800 100644 --- a/core/engine/src/compiled/policy/artifact.rs +++ b/core/engine/src/compiled/policy/artifact.rs @@ -640,10 +640,11 @@ impl Artifact { pub(crate) fn prepare( &self, req: &EvaluateRequest, + tz: zen_expression::context::Timezone, ) -> Result<(Variable, Vec), EvaluationError> { let input = self .input_schema - .convert_dates(&req.input) + .convert_dates(&req.input, tz) .unwrap_or_else(|| req.input.clone()); self.validate_request(req, &input)?; diff --git a/core/engine/src/compiled/policy/columnar/evaluate.rs b/core/engine/src/compiled/policy/columnar/evaluate.rs index 6f9f2e13..4a5822d2 100644 --- a/core/engine/src/compiled/policy/columnar/evaluate.rs +++ b/core/engine/src/compiled/policy/columnar/evaluate.rs @@ -223,7 +223,7 @@ impl PolicyPlan { } let dated = match shared || self.dated_tables(artifact) { true => vec![false; rows], - false => sheet.dates(&artifact.input_schema), + false => sheet.dates(&artifact.input_schema, context.timezone()), }; let mut fallback = vec![false; rows]; let mut erred = false; @@ -242,11 +242,16 @@ impl PolicyPlan { continue; } let req = request(row); - if !dated[row] && artifact.input_schema.convert_dates(&req.input).is_some() { + if !dated[row] + && artifact + .input_schema + .convert_dates(&req.input, context.timezone()) + .is_some() + { fallback[row] = true; continue; } - match artifact.prepare(&req) { + match artifact.prepare(&req, context.timezone()) { Err(error) => { errors[row] = Some(error); erred = true; diff --git a/core/engine/src/compiled/policy/columnar/sheet.rs b/core/engine/src/compiled/policy/columnar/sheet.rs index d2ed1914..17f73ebc 100644 --- a/core/engine/src/compiled/policy/columnar/sheet.rs +++ b/core/engine/src/compiled/policy/columnar/sheet.rs @@ -83,7 +83,11 @@ impl<'a> Sheet<'a> { }) } - pub(super) fn dates(&mut self, schema: &InputSchema) -> Vec { + pub(super) fn dates( + &mut self, + schema: &InputSchema, + tz: zen_expression::context::Timezone, + ) -> Vec { let rows = self.rows; let mut dated = vec![false; rows]; if !schema.has_dates() { @@ -94,7 +98,7 @@ impl<'a> Sheet<'a> { continue; }; if let Some(leaf) = - Self::converted(schema, &at, &entry.leaf, rows, |row| dated[row] = true) + Self::converted(schema, &at, &entry.leaf, rows, tz, |row| dated[row] = true) { entry.leaf = leaf; } @@ -116,9 +120,11 @@ impl<'a> Sheet<'a> { let Some(at) = schema.dates_at(&format!("{}.{}", entity.path, field.name)) else { continue; }; - if let Some(leaf) = Self::converted(schema, &at, &field.leaf, children, |child| { - dated[owner[child]] = true - }) { + if let Some(leaf) = + Self::converted(schema, &at, &field.leaf, children, tz, |child| { + dated[owner[child]] = true + }) + { field.leaf = leaf; } } @@ -131,13 +137,14 @@ impl<'a> Sheet<'a> { at: &DatesAt, leaf: &Leaf<'a>, len: usize, + tz: zen_expression::context::Timezone, mut mark: impl FnMut(usize), ) -> Option> { let mut changed = false; let values: Vec = (0..len) .map(|at_row| { let value = leaf.get(at_row); - match schema.convert_at(at, &value) { + match schema.convert_at(at, &value, tz) { Some(next) => { changed = true; mark(at_row); diff --git a/core/engine/src/compiled/policy/mod.rs b/core/engine/src/compiled/policy/mod.rs index 10f6420c..82c54b54 100644 --- a/core/engine/src/compiled/policy/mod.rs +++ b/core/engine/src/compiled/policy/mod.rs @@ -390,13 +390,15 @@ impl PolicyPlan { let stores: Vec> = requests .iter() .enumerate() - .map(|(row, request)| match artifact.prepare(request) { - Ok((store, _)) => Some(store), - Err(error) => { - failures[row] = Some(error); - None - } - }) + .map( + |(row, request)| match artifact.prepare(request, context.timezone()) { + Ok((store, _)) => Some(store), + Err(error) => { + failures[row] = Some(error); + None + } + }, + ) .collect(); let mut state = Rows { context: context.clone(), diff --git a/core/engine/src/compiled/policy/traced.rs b/core/engine/src/compiled/policy/traced.rs index 5a550308..f81090f6 100644 --- a/core/engine/src/compiled/policy/traced.rs +++ b/core/engine/src/compiled/policy/traced.rs @@ -16,7 +16,7 @@ impl PolicyPlan { context: &zen_expression::context::EvaluationContext, ) -> Result { let start = Instant::now(); - let (store, order_to_run) = artifact.prepare(req)?; + let (store, order_to_run) = artifact.prepare(req, context.timezone())?; let mut host = Host::new( artifact, &store, diff --git a/core/engine/src/compiled/policy/validator.rs b/core/engine/src/compiled/policy/validator.rs index 00ed0627..b50286b0 100644 --- a/core/engine/src/compiled/policy/validator.rs +++ b/core/engine/src/compiled/policy/validator.rs @@ -146,26 +146,36 @@ impl InputSchema { } } - pub(crate) fn convert_dates(&self, input: &Variable) -> Option { + pub(crate) fn convert_dates( + &self, + input: &Variable, + tz: zen_expression::context::Timezone, + ) -> Option { DeclaredDates::rewrite_fields(input, |key, value| { if self.ref_targets.contains(key) { - DeclaredDates::rewrite_items(value, |item| self.convert_entity(item, key, 0)) + DeclaredDates::rewrite_items(value, |item| self.convert_entity(item, key, 0, tz)) } else if self.roots.contains(key) { - self.convert_entity(value, key, 0) + self.convert_entity(value, key, 0, tz) } else { - self.convert_property(value, self.globals.get(key)?, 0) + self.convert_property(value, self.globals.get(key)?, 0, tz) } }) } - fn convert_entity(&self, value: &Variable, entity: &str, depth: usize) -> Option { + fn convert_entity( + &self, + value: &Variable, + entity: &str, + depth: usize, + tz: zen_expression::context::Timezone, + ) -> Option { if depth >= MAX_RECURSION_DEPTH || !self.dated.contains(entity) { return None; } let model = self.entities.get(entity)?; DeclaredDates::rewrite_fields(value, |key, child| { let property = model.properties.iter().find(|p| *p.name == *key)?; - self.convert_property(child, property, depth + 1) + self.convert_property(child, property, depth + 1, tz) }) } @@ -174,14 +184,15 @@ impl InputSchema { value: &Variable, property: &Property, depth: usize, + tz: zen_expression::context::Timezone, ) -> Option { let convert_one = |item: &Variable| match &property.kind { PropertyTypeIr::Date => match item { - Variable::String(text) => zen_expression::DateValue::from_text(text), + Variable::String(text) => zen_expression::DateValue::from_text_in(text, tz), _ => None, }, PropertyTypeIr::Relationship { target } if self.entities.contains_key(target) => { - self.convert_entity(item, target, depth) + self.convert_entity(item, target, depth, tz) } _ => None, }; @@ -241,13 +252,20 @@ impl InputSchema { dated.then_some(at) } - pub(crate) fn convert_at(&self, at: &DatesAt, value: &Variable) -> Option { + pub(crate) fn convert_at( + &self, + at: &DatesAt, + value: &Variable, + tz: zen_expression::context::Timezone, + ) -> Option { match at { - DatesAt::Entity(name, depth) => self.convert_entity(value, name, *depth), - DatesAt::Items(name, depth) => { - DeclaredDates::rewrite_items(value, |item| self.convert_entity(item, name, *depth)) + DatesAt::Entity(name, depth) => self.convert_entity(value, name, *depth, tz), + DatesAt::Items(name, depth) => DeclaredDates::rewrite_items(value, |item| { + self.convert_entity(item, name, *depth, tz) + }), + DatesAt::Property(property, depth) => { + self.convert_property(value, property, *depth, tz) } - DatesAt::Property(property, depth) => self.convert_property(value, property, *depth), } } } diff --git a/core/engine/src/compiled/shred.rs b/core/engine/src/compiled/shred.rs index 5c06d840..58c8f22c 100644 --- a/core/engine/src/compiled/shred.rs +++ b/core/engine/src/compiled/shred.rs @@ -220,7 +220,8 @@ impl Normalizer { (0..rows) .map(|row| { let value = column.variable(row); - DeclaredDates::prepare(&value, None).unwrap_or(value) + DeclaredDates::prepare(&value, None, zen_expression::context::Timezone::UTC) + .unwrap_or(value) }) .collect(), ), diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 9e1f0fc8..7285fc71 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -294,3 +294,120 @@ fn a_table_column_can_test_the_value_of_the_column_before_it() { json!({"v": "other"}), ); } + +#[test] +fn a_policy_date_input_is_read_in_the_evaluation_zone() { + let policy: zen_engine::policy::PolicyDocument = serde_json::from_value(json!({ + "blocks": [ + {"id": "dm", "type": "dataModel", "props": {"data": {"name": "c", "properties": [ + {"id": "p1", "name": "d", "type": "date", "array": false, "optional": false}, + {"id": "p2", "name": "s", "type": "string", "array": false, "optional": false} + ]}}, "children": []}, + {"id": "e1", "type": "expression", "props": {"data": { + "key": "c.typed", "value": "c.d == d('2025-01-01')" + }}}, + {"id": "e2", "type": "expression", "props": {"data": { + "key": "c.text", "value": "d(c.s) == d('2025-01-01')" + }}}, + {"id": "e3", "type": "expression", "props": {"data": { + "key": "c.shown", "value": "d(c.d).format('%Y-%m-%d %H:%M %z')" + }}} + ] + })) + .unwrap(); + let mut workspace = zen_engine::Workspace::new().with_version(EngineVersion::V2); + workspace.set_policy("policy", policy); + let request = zen_engine::policy::EvaluateRequest { + policy_path: Arc::from("policy"), + input: Variable::from(json!({"c": {"d": "2025-01-01", "s": "2025-01-01"}})), + goals: Vec::new(), + trace: zen_engine::trace::TraceFormat::Off, + }; + for zone in [ + "Europe/Berlin", + "America/St_Johns", + "Pacific/Kiritimati", + "UTC", + ] { + let options = EvaluationOptions { + now: zen_engine::context::parse_instant("2025-08-19T16:55:02.078Z"), + timezone: zen_engine::context::parse_timezone(zone), + ..Default::default() + }; + let single = workspace.evaluate_pinned(&request, &options).unwrap(); + let batch = workspace + .evaluate_batch_pinned(&[request.clone(), request.clone()], &options) + .remove(1) + .unwrap(); + for output in [single.output.to_value(), batch.output.to_value()] { + assert_eq!(output["c"]["typed"], json!(true), "{zone} {output}"); + assert_eq!(output["c"]["text"], json!(true), "{zone} {output}"); + assert!( + output["c"]["shown"] + .as_str() + .unwrap() + .starts_with("2025-01-01 00:00"), + "{zone} {output}" + ); + } + } +} + +#[test] +fn a_graph_date_input_is_read_in_the_evaluation_zone() { + let schema = + json!({"type": "object", "properties": {"x": {"type": "string", "format": "date"}}}) + .to_string(); + let graph = json!({ + "nodes": [ + {"id": "in", "name": "in", "type": "inputNode", "content": {"schema": schema}}, + {"id": "node", "name": "node", "type": "expressionNode", "content": {"expressions": [ + {"id": "a", "key": "typed", "value": "x == d('2025-01-01')"}, + {"id": "b", "key": "shown", "value": "d(x).format('%Y-%m-%d %H:%M')"} + ]}}, + {"id": "out", "name": "out", "type": "outputNode"} + ], + "edges": [ + {"id": "e1", "sourceId": "in", "targetId": "node", "type": "edge"}, + {"id": "e2", "sourceId": "node", "targetId": "out", "type": "edge"} + ] + }); + let content: DecisionContent = serde_json::from_value(graph).unwrap(); + let mut decision = DecisionEngine::default() + .with_version(EngineVersion::V2) + .create_decision(Arc::new(content)) + .unwrap(); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + for zone in [ + "Europe/Berlin", + "America/St_Johns", + "Pacific/Kiritimati", + "UTC", + ] { + let options = EvaluationOptions { + now: zen_engine::context::parse_instant("2025-08-19T16:55:02.078Z"), + timezone: zen_engine::context::parse_timezone(zone), + ..Default::default() + }; + let input = || Variable::from(json!({"x": "2025-01-01"})); + let mut outputs = Vec::new(); + for _ in 0..3 { + outputs.push(runtime.block_on(decision.evaluate_with_opts(input(), options))); + } + outputs.extend(runtime.block_on(decision.evaluate_batch(&[input(), input()], options))); + decision.compile(); + outputs.push(runtime.block_on(decision.evaluate_with_opts(input(), options))); + for (at, output) in outputs.into_iter().enumerate() { + let output = output.unwrap().result.to_value(); + assert_eq!(output["typed"], json!(true), "{zone} call {at} {output}"); + assert_eq!( + output["shown"], + json!("2025-01-01 00:00"), + "{zone} call {at} {output}" + ); + } + } +} diff --git a/core/expression/src/dates.rs b/core/expression/src/dates.rs index 6821485c..ec833043 100644 --- a/core/expression/src/dates.rs +++ b/core/expression/src/dates.rs @@ -9,6 +9,10 @@ impl DateValue { VmDate::from_text(text).map(|date| Variable::Dynamic(Rc::new(date))) } + pub fn from_text_in(text: &str, tz: crate::context::Timezone) -> Option { + VmDate::from_text_in(text, tz).map(|date| Variable::Dynamic(Rc::new(date))) + } + pub fn is_text(text: &str) -> bool { VmDate::parses(text) } diff --git a/core/expression/src/vm/date/mod.rs b/core/expression/src/vm/date/mod.rs index 6b418d30..7adc2ffe 100644 --- a/core/expression/src/vm/date/mod.rs +++ b/core/expression/src/vm/date/mod.rs @@ -95,6 +95,11 @@ impl VmDate { .map(|date_time| Self(Some(date_time), Some(Rc::from(text)), OnceCell::new())) } + pub fn from_text_in(text: &str, tz: Tz) -> Option { + helper::parse_text_in(text, tz) + .map(|date_time| Self(Some(date_time), Some(Rc::from(text)), OnceCell::new())) + } + pub fn coerce(value: &Variable) -> Option { match value { Variable::Dynamic(d) => d.as_date().cloned(), @@ -349,7 +354,7 @@ mod helper { }) } - fn parse_text_in(value: &str, tz: Tz) -> Option> { + pub(crate) fn parse_text_in(value: &str, tz: Tz) -> Option> { if let Ok(date_time) = DateTime::parse_from_rfc3339(value) { return Some(date_time.with_timezone(&tz)); } From b5e487c34040d4b2c3355d9ac7d7451ad0d7e240 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 22 Nov 2026 04:21:16 +0100 Subject: [PATCH 08/32] fix(engine): keep script dates right beyond 2099, at extreme years and for object arguments --- core/engine/src/compiled/pinning.js | 24 ++++++++++++++++---- core/engine/src/compiled/pinning.rs | 28 ++++++++++++++++++++---- core/engine/tests/version_parity.rs | 34 +++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 8 deletions(-) diff --git a/core/engine/src/compiled/pinning.js b/core/engine/src/compiled/pinning.js index 6c1dc0f8..1ae077b6 100644 --- a/core/engine/src/compiled/pinning.js +++ b/core/engine/src/compiled/pinning.js @@ -97,10 +97,26 @@ call(N.getMinutes, d), call(N.getSeconds, d), call(N.getMilliseconds, d), ]); }; + const toPrimitive = (value) => { + if ((typeof value !== 'object' && typeof value !== 'function') || value === null) return value; + const exotic = value[Symbol.toPrimitive]; + if (typeof exotic === 'function') { + const result = exotic.call(value, 'default'); + if ((typeof result !== 'object' && typeof result !== 'function') || result === null) return result; + throw new TypeError('Cannot convert object to primitive value'); + } + for (const name of ['valueOf', 'toString']) { + const method = value[name]; + if (typeof method !== 'function') continue; + const result = method.call(value); + if ((typeof result !== 'object' && typeof result !== 'function') || result === null) return result; + } + throw new TypeError('Cannot convert object to primitive value'); + }; const valueOf = (value) => { if (value instanceof Native) return time(value); - const primitive = typeof value === 'object' && value !== null ? value.valueOf() : value; - return typeof primitive === 'string' ? parse(primitive) : Number(primitive); + const primitive = toPrimitive(value); + return typeof primitive === 'string' ? parse(primitive) : +primitive; }; function PinnedDate(...args) { @@ -134,7 +150,7 @@ const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; const pad = (n, width = 2) => String(n).padStart(width, '0'); - const year = (y) => (y < 0 ? '-' + pad(-y, 6) : pad(y, 4)); + const year = (y) => (y < 0 ? '-' + pad(-y, 4) : pad(y, 4)); const gmt = (o) => { const a = Math.abs(Math.round(o)); return 'GMT' + (o < 0 ? '-' : '+') + pad(Math.floor(a / 60)) + pad(a % 60); @@ -166,7 +182,7 @@ const localized = (t, zone, kind) => { if (Number.isNaN(t)) return 'Invalid Date'; const f = fields(t, zone); - const date = `${pad(f.mo + 1)}/${pad(f.d)}/${pad(f.y, 4)}`; + const date = `${pad(f.mo + 1)}/${pad(f.d)}/${year(f.y)}`; const clock = `${pad(f.h % 12 || 12)}:${pad(f.mi)}:${pad(f.s)} ${f.h < 12 ? 'AM' : 'PM'}`; if (kind === 'date') return date; if (kind === 'time') return clock; diff --git a/core/engine/src/compiled/pinning.rs b/core/engine/src/compiled/pinning.rs index 7df66adb..8e019175 100644 --- a/core/engine/src/compiled/pinning.rs +++ b/core/engine/src/compiled/pinning.rs @@ -182,12 +182,33 @@ impl JsSlot { } } + fn modelled(ms: f64) -> Option { + use chrono::Datelike; + const CYCLE: f64 = 146_097.0 * 86_400_000.0; + const SPAN: f64 = 250_000.0 * 365.2425 * 86_400_000.0; + let cycles = match ms.abs() > SPAN { + true => ((ms.abs() - SPAN) / CYCLE).ceil() * ms.signum(), + false => 0.0, + }; + let at = DateTime::from_timestamp_millis((ms - cycles * CYCLE) as i64)?.naive_utc(); + if at.year() <= 2099 { + return Some(at); + } + let year = chrono::NaiveDate::from_yo_opt(at.year(), 1)?; + let twin = (2072..=2099).find(|candidate| { + chrono::NaiveDate::from_yo_opt(*candidate, 1).is_some_and(|first| { + first.leap_year() == year.leap_year() && first.weekday() == year.weekday() + }) + })?; + Some(chrono::NaiveDate::from_yo_opt(twin, at.ordinal())?.and_time(at.time())) + } + fn offset(&self, ms: f64, name: Option) -> Option { let zone = self.zone(name)?; if !ms.is_finite() { return None; } - let at = DateTime::from_timestamp_millis(ms as i64)?.naive_utc(); + let at = Self::modelled(ms)?; let seconds = zone.offset_from_utc_datetime(&at).fix().local_minus_utc(); Some(seconds as f64 / 60.0) } @@ -197,7 +218,7 @@ impl JsSlot { if !local.is_finite() { return None; } - let naive = DateTime::from_timestamp_millis(local as i64)?.naive_utc(); + let naive = Self::modelled(local)?; let offset = match zone.offset_from_local_datetime(&naive) { LocalResult::Single(offset) => offset.fix(), LocalResult::Ambiguous(earlier, _) => earlier.fix(), @@ -206,8 +227,7 @@ impl JsSlot { .earliest()? .fix(), }; - let utc = naive - Duration::seconds(offset.local_minus_utc() as i64); - Some(utc.and_utc().timestamp_millis() as f64) + Some(local - offset.local_minus_utc() as f64 * 1000.0) } pub(crate) fn install(&self, ctx: &rquickjs::Ctx<'_>) -> rquickjs::Result<()> { diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 7285fc71..6c9a3676 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -411,3 +411,37 @@ fn a_graph_date_input_is_read_in_the_evaluation_zone() { } } } + +#[test] +fn script_dates_agree_far_from_today() { + let bodies = [ + "({ v: new Date(2100, 6, 1).getTimezoneOffset(), w: new Date(2100, 0, 1).getTimezoneOffset() })", + "({ v: new Date(2250, 6, 1, 12).getTime(), w: new Date(2399, 11, 31, 23, 59).getHours() })", + "({ v: new Date(-62183203200000).toString().split(' ')[3] })", + "({ v: new Date(-62183203200000).toLocaleString().split(',')[0] })", + "({ v: String(new Date(8.6e15)), w: new Date(-8.6e15).getFullYear() })", + "({ v: new Date(['2024-01-01']).getTime(), w: new Date([5]).getTime() })", + "({ v: new Date({ valueOf: () => 86400000 }).getTime(), w: new Date({ toString: () => '2024-03-01T00:00:00Z' }).getTime() })", + ]; + for body in bodies { + let source = format!("export const handler = async (input) => {body};"); + let graph = graph( + json!({"id": "node", "name": "node", "type": "functionNode", "content": {"source": source}}), + ); + let want = outcomes(EngineVersion::V1, Path::Repeated, &graph, &json!({})).remove(0); + assert!(want.get("error").is_none(), "{body} {want}"); + for path in [Path::Repeated, Path::Compiled, Path::Batch] { + for got in outcomes(EngineVersion::V2, path, &graph, &json!({})) { + assert_eq!(got, want, "{body} {path:?}"); + } + } + } + let source = "export const handler = async (input) => ({ v: new Date(2020n).getTime() });"; + let graph = graph( + json!({"id": "node", "name": "node", "type": "functionNode", "content": {"source": source}}), + ); + for version in [EngineVersion::V1, EngineVersion::V2] { + let got = outcomes(version, Path::Repeated, &graph, &json!({})).remove(0); + assert!(got.get("error").is_some(), "{version:?} {got}"); + } +} From eb61ab99211fb4c463d91a05b4102298dfd7e8e7 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 01:57:38 +0100 Subject: [PATCH 09/32] fix(engine): name script modules alike on every traced batch row --- core/engine/src/compiled/graph/state/trace.rs | 16 ++++++- .../src/compiled/host/function/v2/function.rs | 19 ++++++++ .../src/compiled/host/function/v2/mod.rs | 17 ++++--- core/engine/tests/version_parity.rs | 44 +++++++++++++++++++ 4 files changed, 88 insertions(+), 8 deletions(-) diff --git a/core/engine/src/compiled/graph/state/trace.rs b/core/engine/src/compiled/graph/state/trace.rs index 216412d4..00204e9c 100644 --- a/core/engine/src/compiled/graph/state/trace.rs +++ b/core/engine/src/compiled/graph/state/trace.rs @@ -337,8 +337,20 @@ impl CompiledGraph { content.source.as_ref(), ) }); - crate::compiled::host::function::purity::Purity::module(&source) - .then(Runtime::default) + match crate::compiled::host::function::purity::Purity::module(&source) { + true => { + let runtime = Runtime::default(); + let shared = NodeHandlerExtensions { + function_runtime: runtime.clone(), + ..extensions.clone() + }; + if let Ok(function) = shared.function_runtime().await { + let _ = function.reuse_module(&step.node.id, &source).await; + } + Some(runtime) + } + false => None, + } } _ => None, }; diff --git a/core/engine/src/compiled/host/function/v2/function.rs b/core/engine/src/compiled/host/function/v2/function.rs index 0ef64ec2..88f0448b 100644 --- a/core/engine/src/compiled/host/function/v2/function.rs +++ b/core/engine/src/compiled/host/function/v2/function.rs @@ -29,6 +29,7 @@ pub struct Function { listeners: Vec>, module_loader: ModuleLoader, declared: RefCell>, + reused: RefCell>, slot: JsSlot, } @@ -53,6 +54,7 @@ impl Function { module_loader, listeners: config.listeners.unwrap_or_default(), declared: RefCell::new(HashMap::new()), + reused: RefCell::new(HashMap::new()), slot: config.slot, }; @@ -119,6 +121,23 @@ impl Function { Ok(()) } + pub(crate) async fn reuse_module(&self, name: &str, source: &str) -> FunctionResult { + let module_name = self.shared_module(name, source).await?; + self.reused + .borrow_mut() + .insert(name.to_string(), (create_content_hash(source), module_name)); + Ok(()) + } + + pub(crate) fn reused_module(&self, name: &str, source: &str) -> Option { + let content_hash = create_content_hash(source); + self.reused + .borrow() + .get(name) + .filter(|(hash, _)| *hash == content_hash) + .map(|(_, module_name)| module_name.clone()) + } + pub(crate) async fn shared_module(&self, name: &str, source: &str) -> FunctionResult { let content_hash = create_content_hash(source); let declarative_name = format!("node:{name}"); diff --git a/core/engine/src/compiled/host/function/v2/mod.rs b/core/engine/src/compiled/host/function/v2/mod.rs index 2501b73d..576df74f 100644 --- a/core/engine/src/compiled/host/function/v2/mod.rs +++ b/core/engine/src/compiled/host/function/v2/mod.rs @@ -43,7 +43,10 @@ impl NodeHandler for FunctionV2NodeHandler { .as_ref() .and_then(|stripped| stripped.get(ctx.node.source.as_ref()).cloned()) .unwrap_or_else(|| strip::TypeStripper::strip(ctx.node.source.deref())); - let module_name = function.suggest_module_name(ctx.id.deref(), source.as_ref()); + let declared = function.reused_module(ctx.id.deref(), source.as_ref()); + let module_name = declared + .clone() + .unwrap_or_else(|| function.suggest_module_name(ctx.id.deref(), source.as_ref())); let max_duration = Duration::from_millis(ctx.extensions.settings.function_timeout_millis); let interrupt_handler = Box::new(move || start.elapsed() > max_duration); @@ -64,11 +67,13 @@ impl NodeHandler for FunctionV2NodeHandler { .function_context(&function_context) .await?; - function - .register_module(&module_name, source.as_ref()) - .await - .function_context(&function_context) - .await?; + if declared.is_none() { + function + .register_module(&module_name, source.as_ref()) + .await + .function_context(&function_context) + .await?; + } let response_result = function .call_handler( diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 6c9a3676..2673a24c 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -445,3 +445,47 @@ fn script_dates_agree_far_from_today() { assert!(got.get("error").is_some(), "{version:?} {got}"); } } + +#[test] +fn a_script_error_names_its_node_on_every_traced_batch_row() { + let graph = graph(json!({ + "id": "node", "name": "node", "type": "functionNode", + "content": {"source": "export const handler = async (input) => { throw new Error('boom'); }"} + })); + let content: DecisionContent = serde_json::from_value(graph).unwrap(); + let decision = DecisionEngine::default() + .with_version(EngineVersion::V2) + .create_decision(Arc::new(content)) + .unwrap(); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let inputs: Vec = (1..=3).map(|x| Variable::from(json!({"x": x}))).collect(); + let shown = |error: Box| serde_json::to_value(&error).unwrap(); + let single = shown( + runtime + .block_on(decision.evaluate(inputs[0].clone())) + .unwrap_err(), + ); + assert!(single.to_string().contains("node:node:"), "{single}"); + for trace in [ + zen_engine::trace::TraceFormat::Legacy, + zen_engine::trace::TraceFormat::V1, + ] { + let options = EvaluationOptions { + trace, + ..Default::default() + }; + let rows = runtime.block_on(decision.evaluate_batch(&inputs, options)); + for (at, row) in rows.into_iter().enumerate() { + let got = shown(row.unwrap_err()); + let message = |value: &Value| value["source"].to_string(); + assert!( + got.to_string().contains("node:node:"), + "{trace:?} row {at}: {got}" + ); + assert_eq!(message(&got), message(&single), "{trace:?} row {at}"); + } + } +} From ec7700b52c11da195541b4384d92595dddfb0fe1 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 03:52:49 +0100 Subject: [PATCH 10/32] fix(expression): keep typed batch results and errors equal to the row engine --- core/engine/tests/typed_parity.rs | 170 +++++++++++++++++++++++++++++ core/expression/src/lane/scaled.rs | 8 +- core/expression/src/typed/build.rs | 9 ++ core/expression/src/typed/lower.rs | 56 +++++++++- 4 files changed, 239 insertions(+), 4 deletions(-) create mode 100644 core/engine/tests/typed_parity.rs diff --git a/core/engine/tests/typed_parity.rs b/core/engine/tests/typed_parity.rs new file mode 100644 index 00000000..35a6e9d3 --- /dev/null +++ b/core/engine/tests/typed_parity.rs @@ -0,0 +1,170 @@ +#[allow(dead_code)] +mod support; + +use serde_json::{json, Value}; +use std::sync::Arc; +use support::columns::Built; +use zen_engine::model::DecisionContent; +use zen_engine::{DecisionEngine, EngineVersion, EvaluationOptions, Variable}; + +fn graph(node: Value) -> Value { + json!({ + "nodes": [ + {"id": "in", "name": "in", "type": "inputNode"}, + node, + {"id": "out", "name": "out", "type": "outputNode"} + ], + "edges": [ + {"id": "e1", "sourceId": "in", "targetId": "node", "type": "edge"}, + {"id": "e2", "sourceId": "node", "targetId": "out", "type": "edge"} + ] + }) +} + +fn expression(value: &str) -> Value { + graph( + json!({"id": "node", "name": "node", "type": "expressionNode", "content": {"expressions": [ + {"id": "x0", "key": "o", "value": value} + ]}}), + ) +} + +fn columns_match_version_one(graph: Value, rows: Vec) { + let content: Arc = Arc::new(serde_json::from_value(graph).unwrap()); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let old = DecisionEngine::default() + .with_version(EngineVersion::V1) + .create_decision(content.clone()) + .unwrap(); + let new = DecisionEngine::default() + .with_version(EngineVersion::V2) + .create_decision(content) + .unwrap(); + let built = Built::lists(&rows).or_else(|| Built::new(&rows)).unwrap(); + let fields = built.fields(); + let structs = built.structs(&fields); + let columns = built.columns_with(&structs); + let output = runtime.block_on(new.evaluate_columns(&columns, EvaluationOptions::default())); + for (at, row) in rows.iter().enumerate() { + let want = runtime + .block_on(old.evaluate(Variable::from(row.clone()))) + .map(|response| Built::normalized(response.result.to_value())); + match (&want, &output.errors[at]) { + (Err(_), Some(_)) => {} + (Ok(want), None) => { + assert_eq!( + &Built::normalized(output.row(at).to_value()), + want, + "row {at}" + ) + } + (want, got) => panic!("row {at}: version 1 {want:?}, columns {got:?}"), + } + } +} + +#[test] +fn a_choice_between_two_equal_arms_fills_every_row() { + columns_match_version_one( + expression("flag ? upper(s) : upper(s)"), + vec![ + json!({"s": "q", "flag": false}), + json!({"s": "r", "flag": true}), + ], + ); + columns_match_version_one( + expression("flag ? round(ts / 7, 2) : round(ts / 7, 2)"), + vec![ + json!({"ts": 5, "flag": false}), + json!({"ts": 9, "flag": true}), + ], + ); +} + +#[test] +fn membership_inside_a_closure_reads_the_whole_list() { + columns_match_version_one( + expression("filter(nums, # * 2 in nums)"), + vec![json!({"nums": [1, 2, 4]}), json!({"nums": [3, 6]})], + ); + columns_match_version_one( + expression("filter(strs, # + 'x' in strs)"), + vec![ + json!({"strs": ["a", "ax", "b"]}), + json!({"strs": ["b", "bx"]}), + ], + ); +} + +#[test] +fn a_failed_row_with_a_tiny_decimal_leaves_the_others_intact() { + columns_match_version_one( + expression("(1.50 * ((a + b) ?? b)) in (1.50..4294967295]"), + vec![ + json!({"a": null, "b": 0.0000000000000000000000000001}), + json!({"a": 1, "b": 2}), + ], + ); + columns_match_version_one( + expression("sum(map(filter(objs, #.on), #.x)) * a > 1"), + vec![ + json!({"a": 0.0000000000000000000000000001, "objs": [{"x": 0.0000000000000000000000000001, "on": true}, {"x": 2}]}), + json!({"a": 1, "objs": [{"x": 2, "on": true}]}), + ], + ); +} + +#[test] +fn comparing_different_types_keeps_operand_errors() { + columns_match_version_one( + expression("true != n + 1"), + vec![json!({"n": null}), json!({"n": 1})], + ); +} + +#[test] +fn membership_keeps_the_error_of_the_tested_value() { + columns_match_version_one( + expression("(n + 1) in nums"), + vec![ + json!({"nums": [1, 2], "n": 1}), + json!({"nums": [], "n": null}), + json!({"nums": [3], "n": 2}), + ], + ); +} + +#[test] +fn a_date_interval_evaluates_both_bounds() { + columns_match_version_one( + expression("d(ds) in [d('2025-01-01')..d(ds).add('1D'))"), + vec![json!({"ds": "2024-01-15"}), json!({"ds": "2024-01-16"})], + ); + columns_match_version_one( + expression("d(ds) in [d('2024-01-01')..d(ds).add(1, 'd'))"), + vec![ + json!({"ds": "2024-01-15"}), + json!({"ds": "2023-06-01"}), + json!({"ds": "2025-01-01"}), + ], + ); +} + +#[test] +fn a_table_cell_fails_with_its_input_field() { + let table = graph( + json!({"id": "node", "name": "node", "type": "decisionTableNode", "content": { + "hitPolicy": "first", + "inputs": [{"id": "i0", "field": "lower(s)"}], + "outputs": [{"id": "o0", "field": "out"}], + "rules": [ + {"_id": "r0", "i0": "1 < 2", "o0": "'r0'"}, + {"_id": "r1", "i0": "", "o0": "'r1'"} + ] + }}), + ); + columns_match_version_one(table, vec![json!({"s": null}), json!({"s": "A"})]); +} diff --git a/core/expression/src/lane/scaled.rs b/core/expression/src/lane/scaled.rs index 8347aa21..02e02226 100644 --- a/core/expression/src/lane/scaled.rs +++ b/core/expression/src/lane/scaled.rs @@ -28,7 +28,13 @@ impl Scaled { #[inline] pub(crate) fn decimal(m: i64, s: u8) -> Decimal { - Decimal::new(m, s as u32) + Decimal::try_new(m, s as u32).unwrap_or_else(|_| { + let shift = u32::from(s).saturating_sub(Decimal::MAX_SCALE); + Decimal::new( + 10i64.checked_pow(shift).map_or(0, |p| m / p), + Decimal::MAX_SCALE, + ) + }) } #[inline] diff --git a/core/expression/src/typed/build.rs b/core/expression/src/typed/build.rs index dd767c8c..45767a7c 100644 --- a/core/expression/src/typed/build.rs +++ b/core/expression/src/typed/build.rs @@ -709,6 +709,15 @@ impl<'h> Build<'h> { let skip = !set.is_empty() && cost >= self.passes.skip_min; plans.push((g, r, set, skip)); } + for i in 0..plans.len() { + if plans + .iter() + .enumerate() + .any(|(j, p)| j != i && p.1 == plans[i].1) + { + plans[i].3 = false; + } + } for (_, _, set, skip) in &plans { if !*skip { continue; diff --git a/core/expression/src/typed/lower.rs b/core/expression/src/typed/lower.rs index bbdbcaa2..b90ad7b1 100644 --- a/core/expression/src/typed/lower.rs +++ b/core/expression/src/typed/lower.rs @@ -400,6 +400,30 @@ impl Lowering { } } + fn cell(&mut self, cell: &str, target: Ctx, r: &mut dyn Resolve) -> Lowered { + let test = self.parse(cell, true, target, r)?; + match target.dollar { + Some(dollar) if !self.settled(dollar) && !self.reaches(test, dollar) => Err( + Unsupported::new("table cell ignores a fallible input field"), + ), + _ => Ok(test), + } + } + + fn reaches(&self, from: NodeId, to: NodeId) -> bool { + let mut seen = vec![false; self.nodes.len()]; + let mut stack = vec![from]; + while let Some(id) = stack.pop() { + if id == to { + return true; + } + if !std::mem::replace(&mut seen[id as usize], true) { + stack.extend(self.nodes[id as usize].op.inputs()); + } + } + false + } + fn tabled(&mut self, spec: &TableSpec, r: &mut dyn Resolve) -> Result<(), Unsupported> { if spec.rules.is_empty() || spec.outputs.is_empty() { return Err(Unsupported::new("empty table")); @@ -421,11 +445,11 @@ impl Lowering { spec.inputs.get(at).and_then(Option::as_deref), targets.get(at).copied().flatten(), ) { - (Some(_), Some(target)) => self.parse(cell, true, target, r)?, + (Some(_), Some(target)) => self.cell(cell, target, r)?, (Some(field), None) => { let target = self.target(field, ctx, r)?; targets[at] = Some(target); - self.parse(cell, true, target, r)? + self.cell(cell, target, r)? } (None, _) => self.parse(cell, false, ctx, r)?, }; @@ -1386,8 +1410,24 @@ impl Lowering { } } + fn settled(&self, id: NodeId) -> bool { + match &self.nodes[id as usize].op { + Op::Column(_) | Op::Field(..) | Op::Const(_) => true, + Op::Parent(inner) => self.settled(*inner), + _ => self + .names + .iter() + .any(|(_, named)| *named == Named::Node(id)), + } + } + fn mismatch(&mut self, op: Cmp, a: NodeId, b: NodeId) -> Lowered { if !(self.ty(a).nullable && self.ty(b).nullable) { + if !(self.settled(a) && self.settled(b)) { + return Err(Unsupported::new( + "mismatched comparison of a fallible operand", + )); + } return Ok(self.konst(Lit::Bool(op == Cmp::Ne))); } let null = self.konst(Lit::Null); @@ -2344,6 +2384,15 @@ impl Lowering { fn member(&mut self, x: NodeId, seq: Seq) -> Lowered { let seq = Self::pure(seq)?; + if self + .schema + .within(self.nodes[x as usize].scope, Scope::Elem(seq.list)) + { + return Err(Unsupported::new("membership in the enclosing list")); + } + if !self.settled(x) { + return Err(Unsupported::new("membership of a fallible value")); + } let item = self.item(seq)?; let test = self.belongs(x, item)?; let test = self.lifted(test, seq.list)?; @@ -2767,6 +2816,7 @@ impl Lowering { }; let first = self.dated(low, lo, a)?; let second = self.dated(high, a, hi)?; - self.logic(true, first, second) + let both = self.compare(Cmp::Eq, first, second)?; + self.logic(true, both, first) } } From 8791092837ac1fd3ba54fdb13b1ac8d6eec67f50 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 04:09:31 +0100 Subject: [PATCH 11/32] fix(engine): keep loop items, traced table fields and batch node values equal to version 1 --- core/engine/src/compiled/exact/table.rs | 16 ++- core/engine/src/compiled/graph/state/loops.rs | 7 ++ core/engine/src/compiled/graph/state/mod.rs | 16 ++- core/engine/tests/version_parity.rs | 115 ++++++++++++++++++ 4 files changed, 152 insertions(+), 2 deletions(-) diff --git a/core/engine/src/compiled/exact/table.rs b/core/engine/src/compiled/exact/table.rs index 47ffcbf0..b64c9510 100644 --- a/core/engine/src/compiled/exact/table.rs +++ b/core/engine/src/compiled/exact/table.rs @@ -95,6 +95,16 @@ impl<'t, 's> RowTable<'t, 's> { } } + fn peek(&mut self, col: usize) -> Option { + if let Some(value) = &self.refs[col] { + return Some(value.shallow_clone()); + } + let field = self.field(col)?; + self.session + .locate(Located::field(self.owner, &self.inputs[col].id)); + self.session.run_standard(field).ok() + } + fn bind(&mut self, col: usize) -> Result { let Some(value) = self.reference(col)? else { return Ok(false); @@ -280,7 +290,11 @@ impl RowTable<'_, '_> { let (Some(_), Some(field)) = (rule.get(&input.id), &input.field) else { continue; }; - if let Ok(Some(reference)) = self.reference(col) { + let reference = match rule.get(&input.id).is_some_and(|cell| cell.is_empty()) { + true => self.peek(col), + false => self.reference(col).ok().flatten(), + }; + if let Some(reference) = reference { refs.push((field.clone(), reference)); } } diff --git a/core/engine/src/compiled/graph/state/loops.rs b/core/engine/src/compiled/graph/state/loops.rs index e7558b51..2baa4f8c 100644 --- a/core/engine/src/compiled/graph/state/loops.rs +++ b/core/engine/src/compiled/graph/state/loops.rs @@ -327,6 +327,13 @@ impl CompiledGraph { return None; } let programs: Vec<&LaneProgram> = match body { + Body::Expression { entries, .. } + if entries + .iter() + .any(|(_, source)| zen_expression::lane::SourceInfo::reads_dollar(source)) => + { + return None + } Body::Expression { program, .. } => vec![program], Body::Table(table) => table.programs(), }; diff --git a/core/engine/src/compiled/graph/state/mod.rs b/core/engine/src/compiled/graph/state/mod.rs index 6aa273b4..1c2f6f96 100644 --- a/core/engine/src/compiled/graph/state/mod.rs +++ b/core/engine/src/compiled/graph/state/mod.rs @@ -461,7 +461,21 @@ impl CompiledGraph { .enumerate() .map(|(row, v)| with_nodes(Scope::new(v.clone()), row)) .collect(); - return f(&Bound::plain(scopes, context).probed(probe)); + let mut bound = Bound::plain(scopes, context).probed(probe); + if !extra.is_empty() { + for (path, leaf) in extra { + bound.columns = bound.columns.column(path.as_ref(), leaf.column()); + } + let names: Vec> = extra.iter().map(|(p, _)| p.clone()).collect(); + bound.bind = + Box::new( + move |key: &str| match names.iter().position(|p| p.as_ref() == key) { + Some(at) => Binding::Column(at), + None => Binding::Row, + }, + ); + } + return f(&bound); } let blank = nodes.iter().all(Option::is_none) && matches!(&data.shape, data::Shape::Patched { base: None, .. }); diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 2673a24c..38e9709b 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -489,3 +489,118 @@ fn a_script_error_names_its_node_on_every_traced_batch_row() { } } } + +#[test] +fn a_loop_entry_reading_earlier_entries_in_a_closure_keeps_every_item() { + let graph = graph(json!({ + "id": "node", "name": "node", "type": "expressionNode", + "content": { + "inputField": "items", + "executionMode": "loop", + "expressions": [ + {"id": "a", "key": "s", "value": "k"}, + {"id": "b", "key": "o", "value": "some([1], $.s == 'a')"} + ] + } + })); + same_on_every_path( + &graph, + &json!({"items": [{"k": "a"}, {"k": "b"}]}), + json!([{"s": "a", "o": true}, {"s": "b", "o": false}]), + ); +} + +#[test] +fn tracing_keeps_a_table_field_that_reads_the_previous_cell() { + let graph = graph(json!({ + "id": "node", "name": "node", "type": "decisionTableNode", + "content": { + "hitPolicy": "collect", + "inputs": [{"id": "i0", "field": "p"}, {"id": "i1", "field": "$ ?? 0"}], + "outputs": [{"id": "o0", "field": "o"}], + "rules": [ + {"_id": "r0", "i1": "", "o0": "0"}, + {"_id": "r1", "i0": "> 0", "i1": "", "o0": "1"}, + {"_id": "r2", "i0": "> 0", "i1": "!= null", "o0": "$"} + ] + } + })); + let content: DecisionContent = serde_json::from_value(graph).unwrap(); + let content = Arc::new(content); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let want = json!([{"o": 0}, {"o": 1}, {"o": 2}]); + for version in [EngineVersion::V1, EngineVersion::V2] { + let decision = DecisionEngine::default() + .with_version(version) + .create_decision(content.clone()) + .unwrap(); + for trace in [ + zen_engine::trace::TraceFormat::Off, + zen_engine::trace::TraceFormat::Legacy, + zen_engine::trace::TraceFormat::V1, + ] { + let options = EvaluationOptions { + trace, + ..Default::default() + }; + for call in 0..3 { + let got = runtime + .block_on(decision.evaluate_with_opts(Variable::from(json!({"p": 2})), options)) + .unwrap() + .result + .to_value(); + assert_eq!(got, want, "{version:?} {trace:?} call {call}"); + } + let rows = vec![Variable::from(json!({"p": 2})); 2]; + for (at, row) in runtime + .block_on(decision.evaluate_batch(&rows, options)) + .into_iter() + .enumerate() + { + assert_eq!( + row.unwrap().result.to_value(), + want, + "{version:?} {trace:?} batch row {at}" + ); + } + } + } +} + +#[test] +fn a_batch_row_reads_node_values_beside_an_input_field_built_upstream() { + let graph = chained(vec![ + json!({"id": "n3", "name": "n3", "type": "expressionNode", "content": {"expressions": [ + {"id": "a", "key": "obj.k", "value": "1"} + ]}}), + json!({"id": "n4", "name": "n4", "type": "expressionNode", "content": { + "inputField": "obj", + "expressions": [ + {"id": "b", "key": "out", "value": "type($nodes.n3)"}, + {"id": "c", "key": "k", "value": "$nodes.n3.obj.k"} + ] + }}), + ]); + batch_rows_match_single_rows(&graph, &[json!({}), json!({"x": 1})]); +} + +#[test] +fn a_batch_row_reads_node_values_after_a_table_writing_the_root() { + let graph = chained(vec![ + json!({"id": "n0", "name": "n0", "type": "decisionTableNode", "content": { + "hitPolicy": "first", + "outputPath": "$", + "inputs": [], + "outputs": [{"id": "o", "field": "y"}], + "rules": [{"_id": "r0", "o": "1"}] + }}), + json!({"id": "n1", "name": "n1", "type": "expressionNode", "content": {"expressions": [ + {"id": "a", "key": "got", "value": "$nodes.in"}, + {"id": "b", "key": "prev", "value": "$nodes.n0"} + ]}}), + ]); + batch_rows_match_single_rows(&graph, &[json!({"a": 1}), json!({"a": 2})]); +} From 143fcdb8d8aac9cf42267270c0662731ef5a2325 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 04:21:31 +0100 Subject: [PATCH 12/32] fix(engine): record table references in batch traces when a rule has a description --- core/engine/src/compiled/graph/state/trace.rs | 4 ++ core/engine/tests/version_parity.rs | 51 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/core/engine/src/compiled/graph/state/trace.rs b/core/engine/src/compiled/graph/state/trace.rs index 00204e9c..97dc8a19 100644 --- a/core/engine/src/compiled/graph/state/trace.rs +++ b/core/engine/src/compiled/graph/state/trace.rs @@ -145,6 +145,10 @@ impl CompiledGraph { .as_deref() .is_none_or(crate::compiled::trace::plain_path); scoped + && content + .rules + .iter() + .all(|rule| !rule.contains_key("_description")) && content.inputs.iter().all(|input| match &input.field { None => true, Some(field) if field.is_empty() => true, diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 38e9709b..2c45998b 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -604,3 +604,54 @@ fn a_batch_row_reads_node_values_after_a_table_writing_the_root() { ]); batch_rows_match_single_rows(&graph, &[json!({"a": 1}), json!({"a": 2})]); } + +#[test] +fn a_batch_trace_keeps_the_references_of_a_described_rule() { + let graph = graph(json!({ + "id": "node", "name": "node", "type": "decisionTableNode", + "content": { + "hitPolicy": "first", + "inputs": [{"id": "i0", "field": "a"}, {"id": "i1", "field": "c"}], + "outputs": [{"id": "o0", "field": "o"}], + "rules": [{"_id": "r0", "_description": "x", "i0": "> 0", "i1": ">= 85", "o0": "1"}] + } + })); + let content: DecisionContent = serde_json::from_value(graph).unwrap(); + let decision = DecisionEngine::default() + .with_version(EngineVersion::V2) + .create_decision(Arc::new(content)) + .unwrap(); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let request = Variable::from(json!({"a": 1, "c": 92.3})); + let options = EvaluationOptions { + trace: zen_engine::trace::TraceFormat::V1, + ..Default::default() + }; + let references = |response: zen_engine::DecisionGraphResponse| { + let document = serde_json::to_value(&response).unwrap()["trace"].to_string(); + let restored = zen_engine::trace::restore(zen_engine::trace::RestoreArgs { + trace: zen_engine::trace::Input::Json(&document), + request: zen_engine::trace::Input::Variable(&request), + documents: None, + }) + .unwrap(); + serde_json::to_value(&restored).unwrap()["node"]["traceData"]["reference_map"].clone() + }; + let single = references( + runtime + .block_on(decision.evaluate_with_opts(request.clone(), options)) + .unwrap(), + ); + assert_eq!(single, json!({"a": 1, "c": 92.3})); + let rows = vec![request.clone(), request.clone()]; + for (at, row) in runtime + .block_on(decision.evaluate_batch(&rows, options)) + .into_iter() + .enumerate() + { + assert_eq!(references(row.unwrap()), single, "batch row {at}"); + } +} From 71eb5992d9006c07e1c091db169576bb2b158d52 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 04:22:44 +0100 Subject: [PATCH 13/32] fix(nodejs): convert decision results, policy traces and handler values without aborting on large integers --- bindings/nodejs/src/convert.rs | 26 +++++++++++++++++++------- bindings/nodejs/src/decision.rs | 11 ++++++++--- bindings/nodejs/src/types.rs | 16 ++++++++-------- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/bindings/nodejs/src/convert.rs b/bindings/nodejs/src/convert.rs index 8391a32e..900de39c 100644 --- a/bindings/nodejs/src/convert.rs +++ b/bindings/nodejs/src/convert.rs @@ -5,7 +5,6 @@ use std::ptr; use napi::bindgen_prelude::ToNapiValue; use napi::sys; use napi::sys::{napi_env, napi_value}; -use serde_json::Value; use zen_engine::{DecisionGraphResponse, EvaluationTrace}; use zen_expression::variable::{RcCell, ToVariable}; use zen_expression::Variable; @@ -17,7 +16,6 @@ enum PNode { Str(Box), Arr(Vec), Obj(Vec<(Box, u32)>), - Json(Value), } pub struct PortableArena { @@ -68,7 +66,7 @@ impl PortableArena { PNode::Obj(entries) } - Variable::Dynamic(d) => PNode::Json(d.to_value()), + Variable::Dynamic(d) => return self.add(&Variable::from(d.to_value()), memo), }; let id = self.nodes.len() as u32; @@ -84,7 +82,6 @@ impl PortableArena { pub enum TraceField { None, Arena(u32), - Json(Value), } pub struct NodeEvalResponse { @@ -107,7 +104,8 @@ impl NodeEvalResponse { TraceField::Arena(arena.add(&graph.to_variable(), &mut memo)) } Some(EvaluationTrace::Policy(policy)) => { - TraceField::Json(serde_json::to_value(&policy).unwrap_or_default()) + let value = serde_json::to_value(&policy).unwrap_or_default(); + TraceField::Arena(arena.add(&Variable::from(value), &mut memo)) } Some(EvaluationTrace::V1(document)) => { TraceField::Arena(arena.add(&document.to_variable(), &mut memo)) @@ -203,7 +201,6 @@ impl<'a> Materializer<'a> { Ok(obj) } - PNode::Json(value) => ToNapiValue::to_napi_value(self.env, value.clone()), } } } @@ -231,7 +228,6 @@ impl ToNapiValue for NodeEvalResponse { let trace = match &val.trace { TraceField::None => None, TraceField::Arena(root) => Some(materializer.value(*root)?), - TraceField::Json(value) => Some(ToNapiValue::to_napi_value(env, value.clone())?), }; if let Some(trace) = trace { @@ -242,3 +238,19 @@ impl ToNapiValue for NodeEvalResponse { Ok(obj) } } + +pub struct JsonValue(pub serde_json::Value); + +impl ToNapiValue for JsonValue { + unsafe fn to_napi_value(env: napi_env, val: Self) -> napi::Result { + let mut arena = PortableArena::new(); + let root = arena.add(&Variable::from(val.0), &mut HashMap::new()); + let mut materializer = Materializer { + env, + nodes: &arena.nodes, + cache: vec![ptr::null_mut(); arena.nodes.len()], + keys: HashMap::new(), + }; + materializer.value(root) + } +} diff --git a/bindings/nodejs/src/decision.rs b/bindings/nodejs/src/decision.rs index 7b161afa..c1d1344e 100644 --- a/bindings/nodejs/src/decision.rs +++ b/bindings/nodejs/src/decision.rs @@ -1,3 +1,4 @@ +use crate::convert::NodeEvalResponse; use crate::engine::ZenEvaluateOptions; use crate::mt::spawn_worker; use crate::safe_result::SafeResult; @@ -28,14 +29,18 @@ impl ZenDecision { &self, context: Value, opts: Option, - ) -> napi::Result { + ) -> napi::Result { let decision = self.0.clone(); let options: zen_engine::EvaluationOptions = opts.unwrap_or_default().try_into()?; let result = spawn_worker(move || async move { let context = zen_engine::Variable::try_from_value(context).map_err( |e| serde_json::json!({ "type": "ContextError", "source": e.to_string() }), )?; - decision.evaluate_serialized(context, options).await + decision + .evaluate_with_opts(context, options) + .await + .map(NodeEvalResponse::build) + .map_err(|e| serde_json::to_value(&*e).unwrap_or_default()) }) .await .map_err(|_| anyhow!("Hook timed out"))? @@ -51,7 +56,7 @@ impl ZenDecision { &self, context: Value, opts: Option, - ) -> SafeResult { + ) -> SafeResult { self.evaluate(context, opts).await.into() } diff --git a/bindings/nodejs/src/types.rs b/bindings/nodejs/src/types.rs index d5b72f0c..d0b9b354 100644 --- a/bindings/nodejs/src/types.rs +++ b/bindings/nodejs/src/types.rs @@ -102,13 +102,13 @@ impl ZenEngineHandlerRequest { self.node.clone() } - #[napi(getter)] - pub fn input(&self) -> Value { - self.input.clone() + #[napi(getter, ts_return_type = "any")] + pub fn input(&self) -> crate::convert::JsonValue { + crate::convert::JsonValue(self.input.clone()) } #[napi(ts_return_type = "unknown")] - pub fn get_field(&self, path: String) -> napi::Result { + pub fn get_field(&self, path: String) -> napi::Result { let node_config = &self.node.config; let selected_value: Value = node_config @@ -117,17 +117,17 @@ impl ZenEngineHandlerRequest { .flatten() .context("Failed to find JSON path")?; let Value::String(template) = selected_value else { - return Ok(selected_value); + return Ok(crate::convert::JsonValue(selected_value)); }; let template_value = zen_tmpl::render(template.as_str(), Variable::from(&self.input)) .map_err(|e| anyhow!(serde_json::to_string(&e).unwrap_or_else(|_| e.to_string())))?; - Ok(template_value.to_value()) + Ok(crate::convert::JsonValue(template_value.to_value())) } #[napi(ts_return_type = "unknown")] - pub fn get_field_raw(&self, path: String) -> napi::Result { + pub fn get_field_raw(&self, path: String) -> napi::Result { let node_config = &self.node.config; let selected_value: Value = node_config @@ -136,6 +136,6 @@ impl ZenEngineHandlerRequest { .flatten() .context("Failed to find JSON path")?; - Ok(selected_value.clone()) + Ok(crate::convert::JsonValue(selected_value.clone())) } } From 5382a56a9129efde15818eb176888106ba5bb20d Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 04:23:27 +0100 Subject: [PATCH 14/32] fix(nodejs): reject fractional engine versions --- bindings/nodejs/src/engine.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bindings/nodejs/src/engine.rs b/bindings/nodejs/src/engine.rs index 1236cb3b..34e2cbb8 100644 --- a/bindings/nodejs/src/engine.rs +++ b/bindings/nodejs/src/engine.rs @@ -185,7 +185,7 @@ pub struct ZenEngineOptions { Option>>, #[napi(ts_type = "1 | 2")] - pub version: Option, + pub version: Option, } #[napi] @@ -260,9 +260,11 @@ impl ZenEngine { let mut decision_engine = DecisionEngine::new(loader, Arc::new(custom_node)); if let Some(version) = opts.version { - decision_engine = decision_engine.with_version( - zen_engine::EngineVersion::try_from(version).map_err(|e| anyhow!(e))?, - ); + let whole = (version.fract() == 0.0 && (0.0..=u32::MAX as f64).contains(&version)) + .then_some(version as u32) + .ok_or_else(|| anyhow!("unknown engine version {version}, expected 1 or 2"))?; + decision_engine = decision_engine + .with_version(zen_engine::EngineVersion::try_from(whole).map_err(|e| anyhow!(e))?); } if let Some(h) = opts.http_handler { let http_tsfn = h From 76d1562eb3a923c7e966bc9bb3481590a7baeeaa Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 04:10:49 +0100 Subject: [PATCH 15/32] test(engine): cover null leaves in multi-row batches --- core/engine/tests/version_parity.rs | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 2c45998b..f29c159b 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -655,3 +655,54 @@ fn a_batch_trace_keeps_the_references_of_a_described_rule() { assert_eq!(references(row.unwrap()), single, "batch row {at}"); } } + +#[test] +fn a_batch_row_keeps_a_null_written_under_an_upstream_scalar() { + let graph = chained(vec![ + json!({"id": "n0", "name": "n0", "type": "expressionNode", "content": {"expressions": [ + {"id": "a", "key": "res", "value": "1"} + ]}}), + json!({"id": "n1", "name": "n1", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "b", "key": "res.k", "value": "null"}] + }}), + ]); + batch_rows_match_single_rows(&graph, &[json!({}), json!({})]); +} + +#[test] +fn a_batch_row_keeps_an_object_of_null_leaves() { + let graph = chained(vec![ + json!({"id": "n0", "name": "n0", "type": "expressionNode", "content": {"expressions": [ + {"id": "a", "key": "q", "value": "1"} + ]}}), + json!({"id": "n1", "name": "n1", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "b", "key": "obj.a", "value": "null"}] + }}), + json!({"id": "n2", "name": "n2", "type": "expressionNode", "content": {"expressions": [ + {"id": "c", "key": "r", "value": "obj"}, + {"id": "d", "key": "t", "value": "type(obj)"} + ]}}), + ]); + batch_rows_match_single_rows(&graph, &[json!({}), json!({})]); +} + +#[test] +fn a_batch_row_keeps_nested_nulls_through_duplicate_edges() { + let graph = json!({ + "nodes": [ + {"id": "in", "name": "in", "type": "inputNode"}, + {"id": "n4", "name": "n4", "type": "expressionNode", "content": {"expressions": [ + {"id": "a", "key": "v.w", "value": "null"} + ]}}, + {"id": "out", "name": "out", "type": "outputNode"} + ], + "edges": [ + {"id": "e1", "sourceId": "in", "targetId": "n4", "type": "edge"}, + {"id": "e2", "sourceId": "n4", "targetId": "out", "type": "edge"}, + {"id": "e3", "sourceId": "n4", "targetId": "out", "type": "edge"} + ] + }); + batch_rows_match_single_rows(&graph, &[json!({}), json!({})]); +} From e39d866bcaa717456f7651184951fa539a2e51b8 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 04:37:28 +0100 Subject: [PATCH 16/32] fix(engine): keep a null written under a missing or scalar parent in multi-row batches A layer over an upstream patched shape treated every null leaf as absent, so obj.a = null over a row without obj (or with obj = 1) never created {obj: {a: null}} for downstream reads, and an all-null column was dropped outright. A dotted null leaf now stays present on the rows whose parent is not an object before the write, matching version 1's merge. --- core/engine/src/compiled/graph/data.rs | 65 ++++++++++++++++-- .../spec/graph/72-generated-minimal.json5 | 12 ++-- core/engine/tests/version_parity.rs | 66 +++++++++++++++++++ 3 files changed, 133 insertions(+), 10 deletions(-) diff --git a/core/engine/src/compiled/graph/data.rs b/core/engine/src/compiled/graph/data.rs index 1d08f25c..23b6b688 100644 --- a/core/engine/src/compiled/graph/data.rs +++ b/core/engine/src/compiled/graph/data.rs @@ -923,7 +923,25 @@ impl<'a> Data<'a> { true => column.valued(count), false => Vec::new(), }; - let removed = base.is_none() && layer.present.is_none() && Bits::none(&valued); + let kept = match (&presence, path.rsplit_once('.')) { + (Some(_), Some((parent, _))) => { + let mut open = Bits::of(count, |row| { + layer.has(index, row) && !Bits::get(&valued, row) + }); + if !Bits::none(&open) { + let objects = self.objects_at(parent); + open.iter_mut() + .zip(objects.iter()) + .for_each(|(o, b)| *o &= !b); + } + open + } + _ => Vec::new(), + }; + let removed = base.is_none() + && layer.present.is_none() + && Bits::none(&valued) + && Bits::none(&kept); if removed { let keep: Vec = next .iter() @@ -993,8 +1011,14 @@ impl<'a> Data<'a> { }; let existing = next.iter().position(|(leaf, _)| leaf == path); if let Some(tracked) = presence.as_mut() { + let kept_at = |at: usize| kept.get(at).copied().unwrap_or(0); let present = match &layer.present { - None => Presence::Valued, + None if Bits::none(&kept) => Presence::Valued, + None => { + let mut bits = resolved.valued(count); + Bits::or(&mut bits, &kept); + Presence::Mask(Mask::Bits(bits.into())) + } Some(masks) => { let has = masks[index].dense(count); let before = existing.map(|i| tracked[i].mask(&next[i].1, count)); @@ -1003,9 +1027,15 @@ impl<'a> Data<'a> { .iter() .zip(valued.iter()) .zip(before.iter()) - .map(|((h, v), b)| (h & v) | (!h & b)) + .enumerate() + .map(|(at, ((h, v), b))| (h & (v | kept_at(at))) | (!h & b)) + .collect(), + None => has + .iter() + .zip(valued.iter()) + .enumerate() + .map(|(at, (h, v))| h & (v | kept_at(at))) .collect(), - None => has.iter().zip(valued.iter()).map(|(h, v)| h & v).collect(), })) } }; @@ -1033,6 +1063,33 @@ impl<'a> Data<'a> { ) } + fn objects_at(&self, path: &str) -> Vec { + let count = self.len(); + if let Shape::Patched { + base: None, + leaves, + presence, + .. + } = &self.shape + { + match Self::read(leaves, path) { + Read::Base => return vec![0; count.div_ceil(64)], + Read::Leaf(index) => { + let leaf = &leaves[index].1; + return Bits::of(count, |row| { + presence + .as_ref() + .is_none_or(|presence| presence[index].at(leaf, row)) + && matches!(leaf.shared(row), Variable::Object(_)) + }); + } + Read::Whole => {} + } + } + let column = self.subtree(path); + Bits::of(count, |row| matches!(column[row], Variable::Object(_))) + } + pub fn presence_bits(&self, index: usize) -> Option> { let Shape::Patched { presence: Some(presence), diff --git a/core/engine/tests/spec/graph/72-generated-minimal.json5 b/core/engine/tests/spec/graph/72-generated-minimal.json5 index 8a8259c6..eaaca7be 100644 --- a/core/engine/tests/spec/graph/72-generated-minimal.json5 +++ b/core/engine/tests/spec/graph/72-generated-minimal.json5 @@ -257,9 +257,9 @@ edges: ["input -> t1", "t1 -> t2", "t2 -> output", "input -> e", "e -> output"], }, cases: [ - {input: {}, output: {a: "mid", o: {p: null}, s: 0}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, - {input: {score: 3}, output: {a: "mid", o: {p: null}, s: 3}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, - {input: {score: null}, output: {a: "mid", o: {p: null}, s: 0}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, + {input: {}, output: {a: "mid", o: {p: null}, s: 0}}, + {input: {score: 3}, output: {a: "mid", o: {p: null}, s: 3}}, + {input: {score: null}, output: {a: "mid", o: {p: null}, s: 0}}, ], } @@ -274,9 +274,9 @@ edges: ["input -> t1", "t1 -> e2", "e2 -> output", "t1 -> t3", "t3 -> output"], }, cases: [ - {input: {}, output: {ok: true, res: {k: null}}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, - {input: {missing: 1}, output: {ok: true, res: {k: null}}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, - {input: {missing: null}, output: {ok: true, res: {k: null}}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, + {input: {}, output: {ok: true, res: {k: null}}}, + {input: {missing: 1}, output: {ok: true, res: {k: null}}}, + {input: {missing: null}, output: {ok: true, res: {k: null}}}, ], } diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index f29c159b..2d251d4a 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -706,3 +706,69 @@ fn a_batch_row_keeps_nested_nulls_through_duplicate_edges() { }); batch_rows_match_single_rows(&graph, &[json!({}), json!({})]); } + +fn mixed_rows() -> Vec { + vec![ + json!({"a": {"z": 1, "k": 3}}), + json!({"a": 5}), + json!({}), + json!({"a": null}), + json!({"a": {"k": {"m": 1}}}), + json!({"a": [1]}), + ] +} + +#[test] +fn a_batch_row_keeps_a_null_only_where_its_parent_is_not_an_object() { + let graph = chained(vec![ + json!({"id": "n0", "name": "n0", "type": "expressionNode", "content": {"expressions": [ + {"id": "a", "key": "obj", "value": "a"} + ]}}), + json!({"id": "n1", "name": "n1", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "b", "key": "obj.k", "value": "null"}] + }}), + json!({"id": "n2", "name": "n2", "type": "expressionNode", "content": {"expressions": [ + {"id": "c", "key": "r", "value": "obj"}, + {"id": "d", "key": "t", "value": "type(obj)"}, + {"id": "e", "key": "u", "value": "obj.k"} + ]}}), + ]); + batch_rows_match_single_rows(&graph, &mixed_rows()); +} + +#[test] +fn a_batch_row_keeps_a_deep_null_under_a_missing_branch() { + let graph = chained(vec![ + json!({"id": "n0", "name": "n0", "type": "expressionNode", "content": {"expressions": [ + {"id": "a", "key": "x", "value": "a"} + ]}}), + json!({"id": "n1", "name": "n1", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "b", "key": "x.k.z", "value": "null"}] + }}), + json!({"id": "n2", "name": "n2", "type": "expressionNode", "content": {"expressions": [ + {"id": "c", "key": "r", "value": "x"}, + {"id": "d", "key": "t", "value": "type(x.k)"} + ]}}), + ]); + batch_rows_match_single_rows(&graph, &mixed_rows()); +} + +#[test] +fn a_batch_row_keeps_a_null_written_through_an_output_path_under_a_scalar() { + let graph = chained(vec![ + json!({"id": "n0", "name": "n0", "type": "expressionNode", "content": {"expressions": [ + {"id": "a", "key": "res", "value": "1"} + ]}}), + json!({"id": "n1", "name": "n1", "type": "expressionNode", "content": { + "passThrough": true, + "outputPath": "res.k", + "expressions": [{"id": "b", "key": "obj", "value": "null"}] + }}), + json!({"id": "n2", "name": "n2", "type": "expressionNode", "content": {"expressions": [ + {"id": "c", "key": "items", "value": "res"} + ]}}), + ]); + batch_rows_match_single_rows(&graph, &[json!({}), json!({})]); +} From 469883bd0426784af9221de62ab5b55f05779e41 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 04:46:57 +0100 Subject: [PATCH 17/32] fix(engine): merge a parent reached by duplicate edges once in multi-row batches Version 1 merges a node's output onto itself as a no-op when two edges from the same node meet at a target, so nested nulls survive. The batch path gathered the parent twice as separate copies and re-applied the patch, deleting those nulls and letting a dangling node's value win over a null written on the twice-connected branch. Consecutive duplicate parents now merge once. --- .../src/compiled/graph/plan/run/trace.rs | 10 +++- core/engine/src/compiled/graph/state/mod.rs | 14 +++-- core/engine/src/compiled/graph/state/trace.rs | 14 +++-- core/engine/tests/version_parity.rs | 53 +++++++++++++++++++ 4 files changed, 79 insertions(+), 12 deletions(-) diff --git a/core/engine/src/compiled/graph/plan/run/trace.rs b/core/engine/src/compiled/graph/plan/run/trace.rs index 43a64bc1..454e9ad5 100644 --- a/core/engine/src/compiled/graph/plan/run/trace.rs +++ b/core/engine/src/compiled/graph/plan/run/trace.rs @@ -92,9 +92,15 @@ impl<'a> PlanTrace<'a> { } fn input(&self, parents: &[NodeIndex], rows: &Rc<[usize]>) -> Rc> { - let mut gathered: Vec>> = parents + let mut held: Vec = parents .iter() - .filter_map(|parent| self.piece(parent.index() as Slot, rows)) + .map(|parent| parent.index() as Slot) + .filter(|slot| matches!(self.values.get(*slot as usize), Some(Some(_)))) + .collect(); + held.dedup(); + let mut gathered: Vec>> = held + .into_iter() + .filter_map(|slot| self.piece(slot, rows)) .collect(); if let [single] = gathered.as_slice() { if single.single() { diff --git a/core/engine/src/compiled/graph/state/mod.rs b/core/engine/src/compiled/graph/state/mod.rs index 1c2f6f96..daf1e5b8 100644 --- a/core/engine/src/compiled/graph/state/mod.rs +++ b/core/engine/src/compiled/graph/state/mod.rs @@ -182,12 +182,16 @@ impl CompiledGraph { } fn input_of<'a>(state: &State<'a>, parents: &[NodeIndex], rows: &Rc<[usize]>) -> Data<'a> { - let gathered: Vec> = parents + let mut held: Vec<&[Rc>]> = parents .iter() - .filter_map(|p| { - let pieces = state.nodes.get(p.index())?; - (!pieces.is_empty()).then(|| Data::gather(pieces, rows)) - }) + .filter_map(|p| state.nodes.get(p.index())) + .filter(|pieces| !pieces.is_empty()) + .map(Vec::as_slice) + .collect(); + held.dedup_by(|a, b| std::ptr::eq(*a, *b)); + let gathered: Vec> = held + .into_iter() + .map(|pieces| Data::gather(pieces, rows)) .collect(); Data::merged(rows, gathered) } diff --git a/core/engine/src/compiled/graph/state/trace.rs b/core/engine/src/compiled/graph/state/trace.rs index 97dc8a19..7acfaa01 100644 --- a/core/engine/src/compiled/graph/state/trace.rs +++ b/core/engine/src/compiled/graph/state/trace.rs @@ -252,12 +252,16 @@ impl CompiledGraph { parents: &[NodeIndex], rows: &Rc<[usize]>, ) -> Vec { - let columns: Vec = parents + let mut held: Vec<&[Rc>]> = parents .iter() - .filter_map(|p| { - let pieces = state.nodes.get(p.index())?; - (!pieces.is_empty()).then(|| Data::gather(pieces, rows).materialized()) - }) + .filter_map(|p| state.nodes.get(p.index())) + .filter(|pieces| !pieces.is_empty()) + .map(Vec::as_slice) + .collect(); + held.dedup_by(|a, b| std::ptr::eq(*a, *b)); + let columns: Vec = held + .into_iter() + .map(|pieces| Data::gather(pieces, rows).materialized()) .collect(); (0..rows.len()) .map(|row| { diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 2d251d4a..0ba3f5e7 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -772,3 +772,56 @@ fn a_batch_row_keeps_a_null_written_through_an_output_path_under_a_scalar() { ]); batch_rows_match_single_rows(&graph, &[json!({}), json!({})]); } + +#[test] +fn a_batch_row_keeps_a_null_under_a_scalar_through_duplicate_edges() { + let graph = json!({ + "nodes": [ + {"id": "in", "name": "in", "type": "inputNode"}, + {"id": "n0", "name": "n0", "type": "expressionNode", "content": {"expressions": [ + {"id": "a", "key": "res", "value": "1"} + ]}}, + {"id": "n1", "name": "n1", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "b", "key": "res.k", "value": "null"}] + }}, + {"id": "out", "name": "out", "type": "outputNode"} + ], + "edges": [ + {"id": "e1", "sourceId": "in", "targetId": "n0", "type": "edge"}, + {"id": "e2", "sourceId": "n0", "targetId": "n1", "type": "edge"}, + {"id": "e3", "sourceId": "n1", "targetId": "out", "type": "edge"}, + {"id": "e4", "sourceId": "n1", "targetId": "out", "type": "edge"} + ] + }); + batch_rows_match_single_rows(&graph, &[json!({}), json!({})]); +} + +#[test] +fn a_batch_row_drops_a_key_nulled_by_a_switch_reaching_the_output_twice() { + let graph = json!({ + "nodes": [ + {"id": "in", "name": "in", "type": "inputNode"}, + {"id": "n0", "name": "n0", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "a", "key": "q", "value": "1"}] + }}, + {"id": "n2", "name": "n2", "type": "expressionNode", "content": {"expressions": [ + {"id": "b", "key": "flag", "value": "null"} + ]}}, + {"id": "n3", "name": "n3", "type": "switchNode", "content": { + "hitPolicy": "collect", + "statements": [{"id": "s0", "condition": ""}, {"id": "s1", "condition": ""}] + }}, + {"id": "out", "name": "out", "type": "outputNode"} + ], + "edges": [ + {"id": "e0", "sourceId": "in", "targetId": "n0", "type": "edge"}, + {"id": "e1", "sourceId": "in", "targetId": "n2", "type": "edge"}, + {"id": "e2", "sourceId": "n2", "targetId": "n3", "type": "edge"}, + {"id": "e3", "sourceId": "n3", "targetId": "out", "type": "edge", "sourceHandle": "s0"}, + {"id": "e4", "sourceId": "n3", "targetId": "out", "type": "edge", "sourceHandle": "s1"} + ] + }); + batch_rows_match_single_rows(&graph, &[json!({"flag": true}), json!({"flag": false})]); +} From 3f625b323e75e6d88167408be0ab785d4b538443 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 04:54:41 +0100 Subject: [PATCH 18/32] fix(engine): let a later table output replace an earlier one under it in batches A rule writing res, res.k and then res again keeps only the last res in version 1, because the final write replaces the object that res.k went into. The compiled table folded the duplicate paths into one slot per path and re-inserted res.k on top. Non-collect outputs that a later non-collect output of the same rule replaces are now left out. --- core/engine/src/compiled/table/mod.rs | 24 +++++++++++++++++------- core/engine/tests/version_parity.rs | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/core/engine/src/compiled/table/mod.rs b/core/engine/src/compiled/table/mod.rs index fe63f240..75d93974 100644 --- a/core/engine/src/compiled/table/mod.rs +++ b/core/engine/src/compiled/table/mod.rs @@ -370,16 +370,26 @@ impl Table { let mut paths = Vec::new(); let mut full: Vec<(String, &str)> = Vec::new(); let mut collect: Vec<(String, &str)> = Vec::new(); - for (column, output) in ir.outputs.iter().enumerate() { - if output.path.is_empty() { - continue; - } - let Some(cell) = ir.cell(rule, output.id) else { - continue; - }; + let written: Vec<(usize, &profile::OutputIr, &str)> = ir + .outputs + .iter() + .enumerate() + .filter(|(_, output)| !output.path.is_empty()) + .filter_map(|(column, output)| { + ir.cell(rule, output.id).map(|cell| (column, output, cell)) + }) + .collect(); + for (at, &(column, output, cell)) in written.iter().enumerate() { if SourceInfo::reads_dollar(cell) { return Err("table output cell reads `$`".into()); } + let shadowed = !output.collect + && written[at + 1..].iter().any(|(_, later, _)| { + !later.collect && zen_types::path::DotPath::within(output.path, later.path) + }); + if shadowed { + continue; + } let key = format!("o{}", full.len()); full.push((key, cell)); if output.collect { diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 0ba3f5e7..c06c4593 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -825,3 +825,23 @@ fn a_batch_row_drops_a_key_nulled_by_a_switch_reaching_the_output_twice() { }); batch_rows_match_single_rows(&graph, &[json!({"flag": true}), json!({"flag": false})]); } + +#[test] +fn a_batch_row_lets_a_later_table_output_replace_an_earlier_one_under_it() { + for policy in ["first", "collect"] { + let graph = chained(vec![ + json!({"id": "n0", "name": "n0", "type": "decisionTableNode", "content": { + "hitPolicy": policy, + "inputs": [{"id": "i0", "field": "x"}], + "outputs": [ + {"id": "o0", "field": "res"}, + {"id": "o1", "field": "res.k"}, + {"id": "o2", "field": "res"}, + {"id": "o3", "field": "res.j"} + ], + "rules": [{"_id": "r0", "i0": "", "o0": "0", "o1": "1", "o2": "{p: 2}", "o3": "x"}] + }}), + ]); + batch_rows_match_single_rows(&graph, &[json!({}), json!({"x": 3})]); + } +} From 6a7b5c9da329a84386effeb9eb9790507d9c182e Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 05:21:04 +0100 Subject: [PATCH 19/32] fix(engine): share common ancestry when batch rows merge related parents Version 1 merges parent outputs copy-on-write: a pass-through node shares every subtree it did not change with its input, and merging two values that share an object skips it. So a nested null written once and reached through two branches survives the join, and an input null survives a pass-through that changed nothing. The batch path rebuilt each parent's rows separately, lost that sharing and deleted those nulls. When parents share a base or leading layers and the merged parent can hold a null, the join now derives their rows from the shared prefix with the same copy-on-write merge; other joins stay columnar. Traced batch rows derive pass-through outputs from their merged input the same way. --- core/engine/src/compiled/graph/data.rs | 132 +++++++++++++++++- core/engine/src/compiled/graph/state/trace.rs | 5 +- core/engine/src/compiled/trace/batch.rs | 10 +- .../spec/graph/72-generated-minimal.json5 | 16 +-- core/engine/tests/version_parity.rs | 87 ++++++++++++ 5 files changed, 231 insertions(+), 19 deletions(-) diff --git a/core/engine/src/compiled/graph/data.rs b/core/engine/src/compiled/graph/data.rs index 23b6b688..a782a417 100644 --- a/core/engine/src/compiled/graph/data.rs +++ b/core/engine/src/compiled/graph/data.rs @@ -583,12 +583,10 @@ impl<'a> Data<'a> { } pub fn apply(layer: &Layer<'a>, row: usize, before: &Variable) -> Option { - let Variable::Object(map) = before else { + let Variable::Object(_) = before else { return None; }; - let mut current = map.borrow().clone(); - layer.apply(row, &mut current); - Some(Variable::from_object(current)) + Some(before.clone().merge_clone(&layer.object(row))) } pub fn partial(&self, path: &str) -> Leaf<'a> { @@ -767,7 +765,7 @@ impl<'a> Data<'a> { ), } } - _ if parents.iter().all(Data::patchable) => { + _ if parents.iter().all(Data::patchable) && !Self::aliased(&parents) => { let mut parents = parents.into_iter(); let mut head = match parents.next() { Some(first) => Data::merged(rows, vec![first]), @@ -781,7 +779,7 @@ impl<'a> Data<'a> { head } _ => { - let materialized: Vec = parents.iter().map(Data::materialized).collect(); + let materialized = Self::shared(&parents); let values: Col = (0..rows.len()) .map(|row| GraphWalker::merge_values(materialized.iter().map(|m| &m[row]))) .collect(); @@ -790,6 +788,128 @@ impl<'a> Data<'a> { } } + fn lineage(&self) -> (Option<&Col>, &[Layer<'a>]) { + match &self.shape { + Shape::Plain(values) => (Some(values), &[]), + Shape::Patched { base, layers, .. } => (base.as_ref(), layers), + } + } + + fn common(&self, other: &Data<'a>) -> Option { + let ((base, layers), (other_base, other_layers)) = (self.lineage(), other.lineage()); + let based = match (base, other_base) { + (None, None) => true, + (Some(a), Some(b)) => Rc::ptr_eq(a, b), + _ => false, + }; + if !based { + return None; + } + let depth = layers + .iter() + .zip(other_layers) + .take_while(|(a, b)| Rc::ptr_eq(&a.columns, &b.columns)) + .count(); + (base.is_some() || depth > 0).then_some(depth) + } + + fn nullable(&self) -> bool { + let Shape::Patched { + leaves, + presence: Some(presence), + .. + } = &self.shape + else { + return true; + }; + let rows = self.len(); + leaves + .iter() + .zip(presence.iter()) + .any(|((_, leaf), present)| { + leaf.objects() + || !matches!(present, Presence::Valued) + && present + .mask(leaf, rows) + .iter() + .zip(leaf.valued(rows).iter()) + .any(|(p, v)| p & !v != 0) + }) + } + + fn aliased(parents: &[Data<'a>]) -> bool { + parents.iter().enumerate().skip(1).any(|(at, parent)| { + parents[..at] + .iter() + .any(|earlier| parent.common(earlier).is_some()) + && parent.nullable() + }) + } + + pub fn shared(parents: &[Data<'a>]) -> Vec { + let count = parents.first().map_or(0, Data::len); + let mut chains: Vec>> = Vec::with_capacity(parents.len()); + let mut out = Vec::with_capacity(parents.len()); + for (at, parent) in parents.iter().enumerate() { + let mut best: Option<(usize, usize)> = None; + for (other, earlier) in parents[..at].iter().enumerate() { + if let Some(depth) = parent.common(earlier) { + if best.is_none_or(|(found, _)| depth > found) { + best = Some((depth, other)); + } + } + } + let later = parents[at + 1..] + .iter() + .any(|next| next.common(parent).is_some()); + if best.is_none() && !later { + out.push(parent.materialized()); + chains.push(None); + continue; + } + let (base, layers) = parent.lineage(); + let mut chain: Vec = Vec::with_capacity(layers.len() + 1); + match best.and_then(|(depth, other)| Some((depth, chains[other].as_ref()?))) { + Some((depth, from)) => chain.extend(from[..=depth].iter().cloned()), + None => chain.push(match base { + Some(base) => base.clone(), + None => (0..count).map(|_| Variable::Null).collect(), + }), + } + for layer in &layers[chain.len() - 1..] { + let Some(before) = chain.last() else { + break; + }; + let next: Col = (0..count) + .map(|row| match &before[row] { + value @ Variable::Object(_) => { + value.clone().merge_clone(&layer.object(row)) + } + _ => layer.object(row), + }) + .collect(); + chain.push(next); + } + let last = chain + .last() + .cloned() + .unwrap_or_else(|| parent.materialized()); + out.push(match &parent.shape { + Shape::Patched { + nulls: Some(nulls), .. + } => (0..count) + .map(|row| match Bits::get(nulls, row) { + true => Variable::Null, + false => last[row].clone(), + }) + .collect(), + _ => last, + }); + chains.push(Some(chain)); + } + out + } + pub fn empty(rows: &Rc<[usize]>) -> Data<'a> { Data::with_shape( rows.clone(), diff --git a/core/engine/src/compiled/graph/state/trace.rs b/core/engine/src/compiled/graph/state/trace.rs index 7acfaa01..c8411d76 100644 --- a/core/engine/src/compiled/graph/state/trace.rs +++ b/core/engine/src/compiled/graph/state/trace.rs @@ -259,10 +259,11 @@ impl CompiledGraph { .map(Vec::as_slice) .collect(); held.dedup_by(|a, b| std::ptr::eq(*a, *b)); - let columns: Vec = held + let gathered: Vec> = held .into_iter() - .map(|pieces| Data::gather(pieces, rows).materialized()) + .map(|pieces| Data::gather(pieces, rows)) .collect(); + let columns = Data::shared(&gathered); (0..rows.len()) .map(|row| { crate::compiled::host::graph::walker::GraphWalker::merge_values( diff --git a/core/engine/src/compiled/trace/batch.rs b/core/engine/src/compiled/trace/batch.rs index 0e07b7a7..0769e99e 100644 --- a/core/engine/src/compiled/trace/batch.rs +++ b/core/engine/src/compiled/trace/batch.rs @@ -359,9 +359,13 @@ impl<'a> Traces<'a> { .iter() .filter_map(|p| outputs.get(*p as usize)?.as_ref()), ); - let value = match &event.output { - Some(value) => value.row(position), - None => merged.clone(), + let value = match (&event.output, &event.encoding) { + (Some(Value::Data(data)), Encoding::Touched(Some(input))) => data + .extends(input) + .and_then(|layer| Data::apply(layer, position, &merged)) + .unwrap_or_else(|| data.materialize_row(position)), + (Some(value), _) => value.row(position), + (None, _) => merged.clone(), }; let input = match event.input { true => merged, diff --git a/core/engine/tests/spec/graph/72-generated-minimal.json5 b/core/engine/tests/spec/graph/72-generated-minimal.json5 index eaaca7be..09b2c841 100644 --- a/core/engine/tests/spec/graph/72-generated-minimal.json5 +++ b/core/engine/tests/spec/graph/72-generated-minimal.json5 @@ -175,8 +175,8 @@ // --- B. A null written at a nested path, when the node's output fans out ---------------------- // The walker keeps a null written under a dotted key or an outputPath (`{g: {a: null}}`), while a // top-level null key is dropped. When the writing node feeds both the output node and another -// node whose result is merged at the same join, batch mode drops the nested null (`{g: {}}`). -// Single and columnar mode agree with the walker. +// node whose result is merged at the same join, the walker still keeps the nested null, because +// both joined values share that object. { name: "B: passThrough dotted null, fanned out to the output and through a second passThrough node", @@ -188,9 +188,9 @@ edges: ["input -> e1", "e1 -> e2", "e1 -> output", "e2 -> output"], }, cases: [ - {input: {n: 2.5, score: null}, output: {g: {a: null}, n: 2.5, z: 1}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, + {input: {n: 2.5, score: null}, output: {g: {a: null}, n: 2.5, z: 1}}, {input: {n: 2.5, score: 1}, output: {g: {a: 1}, n: 2.5, score: 1, z: 1}}, - {input: {n: 2}, output: {g: {a: null}, n: 2, z: 1}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, + {input: {n: 2}, output: {g: {a: null}, n: 2, z: 1}}, {input: {score: "s"}, output: {g: {a: "s"}, score: "s", z: 1}}, ], } @@ -220,9 +220,9 @@ edges: ["input -> e1", "e1 -> e2", "e2 -> output", "e1 -> output"], }, cases: [ - {input: {}, output: {j: 0, lines: {k: null}}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, + {input: {}, output: {j: 0, lines: {k: null}}}, {input: {n: 1}, output: {j: 0, lines: {k: 1}}}, - {input: {n: null}, output: {j: 0, lines: {k: null}}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, + {input: {n: null}, output: {j: 0, lines: {k: null}}}, {input: {n: "x"}, output: {j: 0, lines: {k: "x"}}}, ], } @@ -237,10 +237,10 @@ edges: ["input -> e1", "e1 -> output", "e1 -> t", "t -> output"], }, cases: [ - {input: {}, output: {done: true, res: {k: null}}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, + {input: {}, output: {done: true, res: {k: null}}}, {input: {active: true}, output: {done: true, res: {k: true}}}, {input: {tier: "gold"}, output: {done: true, res: {k: "gold"}}}, - {input: {active: null, tier: null}, output: {done: true, res: {k: null}}, engines: {modes: ["batch"], intended: false, why: "OPEN compiled bug: batch mode drops a null written at a nested path when the writing node fans out; single and columnar agree with the walker"}}, + {input: {active: null, tier: null}, output: {done: true, res: {k: null}}}, ], } diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index c06c4593..2dd927fa 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -845,3 +845,90 @@ fn a_batch_row_lets_a_later_table_output_replace_an_earlier_one_under_it() { batch_rows_match_single_rows(&graph, &[json!({}), json!({"x": 3})]); } } + +fn joined(nodes: Vec, edges: &[(&str, &str)]) -> Value { + let mut all = vec![json!({"id": "in", "name": "in", "type": "inputNode"})]; + all.extend(nodes); + all.push(json!({"id": "out", "name": "out", "type": "outputNode"})); + let edges: Vec = edges + .iter() + .enumerate() + .map(|(i, (from, to))| json!({"id": format!("e{i}"), "sourceId": from, "targetId": to, "type": "edge"})) + .collect(); + json!({"nodes": all, "edges": edges}) +} + +#[test] +fn a_batch_row_keeps_a_nested_null_shared_by_two_branches_of_one_node() { + for pass in [true, false] { + let graph = joined( + vec![ + json!({"id": "e1", "name": "e1", "type": "expressionNode", "content": { + "passThrough": pass, + "expressions": [{"id": "a", "key": "g.a", "value": "score"}, {"id": "b", "key": "q", "value": "score"}] + }}), + json!({"id": "e2", "name": "e2", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "c", "key": "z", "value": "1"}] + }}), + json!({"id": "e3", "name": "e3", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "d", "key": "w", "value": "2"}] + }}), + ], + &[ + ("in", "e1"), + ("e1", "e2"), + ("e1", "e3"), + ("e2", "out"), + ("e3", "out"), + ], + ); + batch_rows_match_single_rows( + &graph, + &[ + json!({"score": null}), + json!({"score": 1}), + json!({}), + json!({"g": {"b": null}, "score": null}), + ], + ); + } +} + +#[test] +fn a_batch_row_keeps_a_nested_null_when_a_node_meets_its_own_descendant() { + let graph = joined( + vec![ + json!({"id": "e1", "name": "e1", "type": "expressionNode", "content": { + "outputPath": "lines", + "expressions": [{"id": "a", "key": "k", "value": "n"}] + }}), + json!({"id": "e2", "name": "e2", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "b", "key": "j", "value": "lines.other ?? 0"}] + }}), + ], + &[("in", "e1"), ("e1", "e2"), ("e2", "out"), ("e1", "out")], + ); + batch_rows_match_single_rows(&graph, &[json!({}), json!({"n": 1}), json!({"n": null})]); +} + +#[test] +fn a_batch_row_keeps_an_input_null_that_an_unchanged_pass_through_shares() { + for value in ["null", "1"] { + let graph = joined( + vec![ + json!({"id": "n0", "name": "n0", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "a", "key": "c", "value": value}] + }}), + json!({"id": "n1", "name": "n1", "type": "functionNode", "content": { + "source": "export const handler = async (input) => ({ keys: Object.keys(input || {}) });" + }}), + ], + &[("in", "n0"), ("in", "n1"), ("n0", "n1"), ("n1", "out")], + ); + batch_rows_match_single_rows(&graph, &[json!({"y": null}), json!({})]); + } +} From cf5f29d7ffedf30f2d440d4d6d29096f33c69169 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 05:56:23 +0100 Subject: [PATCH 20/32] fix(engine): keep one materialization per node so batch joins see shared rows Gathering a node's rows for each consumer, and clearing a table's unmatched rows before a pass-through, materialized the same node output more than once, so a pass-through built from one copy no longer shared objects with the copy merged at the join, and the version 1 rule that a shared object merges as a no-op could not apply. Gathered copies of a node on the same rows now share one materialization, a cleared copy reuses its source's rows, layers keep their identity when picked to a row subset, and input rows match by object identity. The final output still materializes its own copy, since cleaning it mutates in place. --- core/engine/src/compiled/graph/data.rs | 69 +++++++++++++++++---- core/engine/src/compiled/graph/state/mod.rs | 3 +- core/engine/tests/version_parity.rs | 43 +++++++++++++ 3 files changed, 101 insertions(+), 14 deletions(-) diff --git a/core/engine/src/compiled/graph/data.rs b/core/engine/src/compiled/graph/data.rs index a782a417..b380d21f 100644 --- a/core/engine/src/compiled/graph/data.rs +++ b/core/engine/src/compiled/graph/data.rs @@ -59,6 +59,7 @@ pub(crate) struct Layer<'a> { pub columns: Rc<[Leaf<'a>]>, pub present: Option]>>, pub flat: bool, + origin: Rc<()>, } impl<'a> Layer<'a> { @@ -88,6 +89,7 @@ impl<'a> Layer<'a> { columns: columns.into(), present: present.map(Rc::from), flat, + origin: Rc::new(()), } } @@ -261,6 +263,7 @@ impl<'a> Layer<'a> { .as_ref() .map(|masks| masks.iter().map(|m| m.pick(positions)).collect()), flat: self.flat, + origin: self.origin.clone(), } } } @@ -318,7 +321,8 @@ pub(crate) enum Read { pub(crate) struct Data<'a> { pub rows: Rc<[usize]>, pub shape: Shape<'a>, - whole: OnceCell, + whole: Rc>, + origin: Option>>, tops: RefCell, Col)>>, } @@ -327,7 +331,8 @@ impl<'a> Data<'a> { Data { rows, shape: Shape::Plain(values), - whole: OnceCell::new(), + whole: Rc::default(), + origin: None, tops: RefCell::new(Vec::new()), } } @@ -336,13 +341,25 @@ impl<'a> Data<'a> { Data { rows, shape, - whole: OnceCell::new(), + whole: Rc::default(), + origin: None, tops: RefCell::new(Vec::new()), } } pub fn copied(&self) -> Data<'a> { - Data::with_shape(self.rows.clone(), self.shape.clone()) + Data { + whole: self.whole.clone(), + origin: self.origin.clone(), + ..Data::with_shape(self.rows.clone(), self.shape.clone()) + } + } + + pub fn detached(&self) -> Data<'a> { + Data { + origin: self.origin.clone(), + ..Data::with_shape(self.rows.clone(), self.shape.clone()) + } } pub fn single(&self) -> bool { @@ -365,7 +382,11 @@ impl<'a> Data<'a> { pub fn gather(pieces: &[Rc>], rows: &Rc<[usize]>) -> Data<'a> { if let [single] = pieces { if Rc::ptr_eq(&single.rows, rows) || single.rows == *rows { - return Data::with_shape(rows.clone(), single.shape.clone()); + return Data { + whole: single.whole.clone(), + origin: single.origin.clone(), + ..Data::with_shape(rows.clone(), single.shape.clone()) + }; } } let span = pieces @@ -679,7 +700,18 @@ impl<'a> Data<'a> { pub fn materialized(&self) -> Col { self.whole - .get_or_init(|| (0..self.len()).map(|r| self.materialize_row(r)).collect()) + .get_or_init(|| match &self.origin { + Some(origin) => { + let before = origin.materialized(); + (0..self.len()) + .map(|row| match origin.nulled(row) { + true => self.materialize_row(row), + false => before[row].clone(), + }) + .collect() + } + None => (0..self.len()).map(|r| self.materialize_row(r)).collect(), + }) .clone() } @@ -753,16 +785,19 @@ impl<'a> Data<'a> { leaves, presence, .. - } => Data::with_shape( - rows.clone(), - Shape::Patched { + } => { + let shape = Shape::Patched { base: base.clone(), layers: layers.clone(), leaves: leaves.clone(), nulls: None, presence: presence.clone(), - }, - ), + }; + Data { + origin: Some(Rc::new(single)), + ..Data::with_shape(rows.clone(), shape) + } + } } } _ if parents.iter().all(Data::patchable) && !Self::aliased(&parents) => { @@ -799,7 +834,15 @@ impl<'a> Data<'a> { let ((base, layers), (other_base, other_layers)) = (self.lineage(), other.lineage()); let based = match (base, other_base) { (None, None) => true, - (Some(a), Some(b)) => Rc::ptr_eq(a, b), + (Some(a), Some(b)) => { + Rc::ptr_eq(a, b) + || a.len() == b.len() + && a.iter().zip(b.iter()).all(|pair| match pair { + (Variable::Object(a), Variable::Object(b)) => Rc::ptr_eq(a, b), + (Variable::Array(a), Variable::Array(b)) => Rc::ptr_eq(a, b), + _ => false, + }) + } _ => false, }; if !based { @@ -808,7 +851,7 @@ impl<'a> Data<'a> { let depth = layers .iter() .zip(other_layers) - .take_while(|(a, b)| Rc::ptr_eq(&a.columns, &b.columns)) + .take_while(|(a, b)| Rc::ptr_eq(&a.origin, &b.origin)) .count(); (base.is_some() || depth > 0).then_some(depth) } diff --git a/core/engine/src/compiled/graph/state/mod.rs b/core/engine/src/compiled/graph/state/mod.rs index daf1e5b8..c59b9b6c 100644 --- a/core/engine/src/compiled/graph/state/mod.rs +++ b/core/engine/src/compiled/graph/state/mod.rs @@ -306,7 +306,8 @@ impl CompiledGraph { .iter() .filter_map(|nid| { let pieces = state.nodes.get(nid.index())?; - (!pieces.is_empty()).then(|| Data::gather(pieces, &rows).materialized()) + (!pieces.is_empty()) + .then(|| Data::gather(pieces, &rows).detached().materialized()) }) .collect(); for (i, &row) in rows.iter().enumerate() { diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 2dd927fa..e3f1c1f0 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -932,3 +932,46 @@ fn a_batch_row_keeps_an_input_null_that_an_unchanged_pass_through_shares() { batch_rows_match_single_rows(&graph, &[json!({"y": null}), json!({})]); } } + +#[test] +fn a_batch_row_keeps_a_nested_null_from_a_table_shared_with_a_pass_through_branch() { + let graph = joined( + vec![ + json!({"id": "t0", "name": "t0", "type": "decisionTableNode", "content": { + "hitPolicy": "first", + "inputs": [{"id": "i0", "name": "I0"}, {"id": "i1", "field": "r"}], + "outputs": [{"id": "o0", "field": "o.p"}, {"id": "o1", "field": "o.q.z"}], + "rules": [ + {"_id": "r0", "i0": "", "i1": "'a', 'b'", "o0": "{a: 1}", "o1": "{a: 1}"}, + {"_id": "r1", "i0": "", "i1": "x > 1", "o0": "{a: 1}", "o1": "a.b"}, + {"_id": "r2", "i0": "'a'", "i1": "", "o0": "[1, 2]", "o1": "1"} + ] + }}), + json!({"id": "t1", "name": "t1", "type": "decisionTableNode", "content": { + "hitPolicy": "first", + "passThrough": true, + "inputs": [{"id": "i0", "name": "I0"}, {"id": "i1", "field": "v.w"}], + "outputs": [{"id": "o0", "field": "m"}], + "rules": [ + {"_id": "r0", "i0": "null", "i1": "< 3", "o0": "{a: 1}"}, + {"_id": "r1", "i0": "true", "i1": "[1..5]", "o0": "(x ?? 0) + 1"}, + {"_id": "r2", "i0": "null", "o0": "a.b"}, + {"_id": "r3", "i0": "< 3", "i1": "'a'", "o0": "x"}, + {"_id": "r4", "i0": "", "i1": "\"b\"", "o0": "{a: 1}"}, + {"_id": "r5", "i0": "true", "i1": "$ > 2", "o0": "null"}, + {"_id": "r6", "i0": "x > 1", "i1": ">= 0", "o0": "null"}, + {"_id": "r7", "i0": "", "i1": "\"b\"", "o0": "'s'"} + ] + }}), + ], + &[("in", "t0"), ("t0", "t1"), ("t0", "out"), ("t1", "out")], + ); + batch_rows_match_single_rows( + &graph, + &[ + json!({"x": 9}), + json!({"x": 3, "a": {"b": 66}}), + json!({"x": 2, "a": {"b": 1}}), + ], + ); +} From 96d095d94c5aa068a142c48c3b1eee30c7ae46f6 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 12:57:32 +0100 Subject: [PATCH 21/32] test(engine): cover policy columns for a tested value that fails --- core/engine/tests/typed_parity.rs | 62 +++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/core/engine/tests/typed_parity.rs b/core/engine/tests/typed_parity.rs index 35a6e9d3..490dd55a 100644 --- a/core/engine/tests/typed_parity.rs +++ b/core/engine/tests/typed_parity.rs @@ -168,3 +168,65 @@ fn a_table_cell_fails_with_its_input_field() { ); columns_match_version_one(table, vec![json!({"s": null}), json!({"s": "A"})]); } + +#[test] +fn policy_columns_keep_the_error_of_a_tested_value() { + let policy: zen_engine::policy::PolicyDocument = serde_json::from_value(json!({ + "blocks": [ + {"id": "dm", "type": "dataModel", "props": {"data": {"name": "c", "properties": [ + {"id": "p1", "name": "n", "type": "number", "array": false, "optional": true}, + {"id": "p2", "name": "s", "type": "string", "array": false, "optional": true}, + {"id": "p3", "name": "list", "type": "string", "array": true, "optional": true} + ]}}, "children": []}, + {"id": "e1", "type": "expression", "props": {"data": { + "key": "c.a", "value": "string(c.n + 1) in (c.list ?? [])" + }}}, + {"id": "e2", "type": "expression", "props": {"data": { + "key": "c.b", "value": "string(upper(c.s)) in (c.list ?? [])" + }}} + ] + })) + .unwrap(); + let rows = vec![ + json!({"c": {"n": 1, "s": "2", "list": ["2"]}}), + json!({"c": {"n": null, "s": "a", "list": ["a"]}}), + json!({"c": {"n": null, "s": null, "list": null}}), + json!({"c": {"n": null, "s": null, "list": []}}), + ]; + let path: Arc = Arc::from("policy"); + let options = EvaluationOptions::default(); + let workspace = |version| { + let mut workspace = zen_engine::Workspace::new().with_version(version); + workspace.set_policy("policy", policy.clone()); + workspace + }; + let old = workspace(EngineVersion::V1); + let new = workspace(EngineVersion::V2); + let built = Built::lists(&rows).unwrap(); + let fields = built.fields(); + let structs = built.structs(&fields); + let columns = built.columns_with(&structs); + let output = new + .evaluate_columns_pinned(&path, &[], &columns, &options) + .unwrap(); + for (at, row) in rows.iter().enumerate() { + let request = zen_engine::policy::EvaluateRequest { + policy_path: path.clone(), + input: Variable::from(row.clone()), + goals: Vec::new(), + trace: zen_engine::trace::TraceFormat::Off, + }; + let want = old + .evaluate_pinned(&request, &options) + .map(|result| result.output.to_value()["c"].clone()); + match (&want, &output.errors[at]) { + (Err(_), Some(_)) => {} + (Ok(want), None) => { + let got = output.row(at).to_value()["c"].clone(); + assert_eq!(got["a"], want["a"], "row {at}"); + assert_eq!(got["b"], want["b"], "row {at}"); + } + (want, got) => panic!("row {at}: version 1 {want:?}, columns {got:?}"), + } + } +} From 9754aa671068be69e8d6819bc680596da259afac Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 13:07:16 +0100 Subject: [PATCH 22/32] fix(engine): return column traces in the legacy format when it is requested --- core/engine/src/compiled/trace/mod.rs | 12 ++++- core/engine/tests/typed_parity.rs | 68 +++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/core/engine/src/compiled/trace/mod.rs b/core/engine/src/compiled/trace/mod.rs index db7c430e..10c2b4e3 100644 --- a/core/engine/src/compiled/trace/mod.rs +++ b/core/engine/src/compiled/trace/mod.rs @@ -799,14 +799,22 @@ impl<'a> TraceBatch<'a> { } pub fn json(&self, row: usize) -> Option { - self.document(row).map(|doc| doc.json().to_string()) + match self.format { + TraceFormat::Legacy => serde_json::to_string(&self.trace(row)?).ok(), + _ => self.document(row).map(|doc| doc.json().to_string()), + } } pub fn write_all(&self, out: &mut String) -> Vec { let mut ends = Vec::with_capacity(self.len()); let start = out.len(); for row in 0..self.len() { - if !self.columnar(row, out) { + if self.format == TraceFormat::Legacy { + match self.json(row) { + Some(text) => out.push_str(&text), + None => out.push_str("null"), + } + } else if !self.columnar(row, out) { match self.written(row) { Some(doc) => out.push_str(doc.json()), None => out.push_str("null"), diff --git a/core/engine/tests/typed_parity.rs b/core/engine/tests/typed_parity.rs index 490dd55a..b5da8a22 100644 --- a/core/engine/tests/typed_parity.rs +++ b/core/engine/tests/typed_parity.rs @@ -230,3 +230,71 @@ fn policy_columns_keep_the_error_of_a_tested_value() { } } } + +#[test] +fn column_traces_come_in_the_requested_format() { + let table = graph( + json!({"id": "node", "name": "node", "type": "decisionTableNode", "content": { + "hitPolicy": "first", + "inputs": [{"id": "i0", "field": "a"}], + "outputs": [{"id": "o0", "field": "out"}], + "rules": [ + {"_id": "r0", "i0": "> 1", "o0": "'big'"}, + {"_id": "r1", "i0": "", "o0": "'small'"} + ] + }}), + ); + let content: Arc = Arc::new(serde_json::from_value(table).unwrap()); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let decision = DecisionEngine::default() + .with_version(EngineVersion::V2) + .create_decision(content) + .unwrap(); + let rows = vec![json!({"a": 1}), json!({"a": 2})]; + let built = Built::new(&rows).unwrap(); + let columns = built.columns(); + let timeless = |mut value: Value| { + fn strip(value: &mut Value) { + match value { + Value::Object(map) => { + map.remove("performance"); + map.values_mut().for_each(strip); + } + Value::Array(items) => items.iter_mut().for_each(strip), + _ => {} + } + } + strip(&mut value); + value + }; + for format in [ + zen_engine::trace::TraceFormat::Legacy, + zen_engine::trace::TraceFormat::V1, + ] { + let options = EvaluationOptions { + trace: format, + ..Default::default() + }; + let output = runtime.block_on(decision.evaluate_columns(&columns, options)); + let mut all = String::new(); + let ends = output.traces().unwrap().write_all(&mut all); + for (at, row) in rows.iter().enumerate() { + let single = runtime + .block_on(decision.evaluate_with_opts(Variable::from(row.clone()), options)) + .unwrap(); + let want = serde_json::to_value(&single).unwrap()["trace"].clone(); + let got: Value = serde_json::from_str(&output.trace_json(at).unwrap()).unwrap(); + let start = at.checked_sub(1).map_or(0, |before| ends[before] + 1); + let line: Value = serde_json::from_str(&all[start..ends[at]]).unwrap(); + let legacy = format == zen_engine::trace::TraceFormat::Legacy; + assert_eq!(got.get("version").is_none(), legacy, "{format:?} row {at}"); + assert_eq!(timeless(line), timeless(got.clone()), "{format:?} row {at}"); + if legacy { + assert_eq!(timeless(got), timeless(want), "{format:?} row {at}"); + } + } + } +} From 5f2a583fbb45650f8d2c5150ef4bd27ee2b286c2 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 13:41:16 +0100 Subject: [PATCH 23/32] fix(engine): return an error instead of building a cyclic value when an expression entry writes an object into itself on version 2 An entry such as `a.c = obj` after `a = obj` wrote the object into itself, and merging, cloning, comparing, tracing or serialising the result then overflowed the stack. The hosted expression node now checks, before each write, whether the value reaches the object it is written into and fails the row with "cyclic value at ". Compiled nodes that write a possibly container value under a key an earlier entry set are routed through the same row evaluation, so every path (first call, repeated, compiled, batch, columnar, traced) reports the error for that row only. --- .../src/compiled/exact/graph/expression.rs | 9 + core/engine/src/compiled/exact/mod.rs | 4 + core/engine/src/compiled/graph/step.rs | 30 +- core/engine/tests/trace_golden.rs | 3 +- core/engine/tests/version_parity.rs | 256 ++++++++++++++++++ core/expression/src/lane/session.rs | 6 + core/expression/src/lane/source.rs | 49 +++- core/types/src/variable/mod.rs | 59 ++++ 8 files changed, 413 insertions(+), 3 deletions(-) diff --git a/core/engine/src/compiled/exact/graph/expression.rs b/core/engine/src/compiled/exact/graph/expression.rs index a54ccbd5..190d9e6c 100644 --- a/core/engine/src/compiled/exact/graph/expression.rs +++ b/core/engine/src/compiled/exact/graph/expression.rs @@ -36,6 +36,15 @@ impl Row<'_> { results.push((expression.key.clone(), value.clone())); } + if result.dot_insert_cycles(&expression.key, &value) + || session.dollar_cycles(&expression.key, &value) + { + if let Some(results) = results { + self.record(|recorder| recorder.expression(results)); + } + return Err(self.error(crate::compiled::exact::Failure::cyclic(&expression.key))); + } + session.insert_dollar(&expression.key, value.clone()); result.dot_insert(&expression.key, value); diff --git a/core/engine/src/compiled/exact/mod.rs b/core/engine/src/compiled/exact/mod.rs index ed311722..1537e510 100644 --- a/core/engine/src/compiled/exact/mod.rs +++ b/core/engine/src/compiled/exact/mod.rs @@ -14,6 +14,10 @@ impl Failure { format!(r#"{}: "{source}""#, Self::EXPRESSION) } + pub fn cyclic(key: &str) -> String { + format!("cyclic value at {key}") + } + pub fn input(error: impl std::fmt::Display) -> String { format!("{}: {error}", Self::EXPRESSION) } diff --git a/core/engine/src/compiled/graph/step.rs b/core/engine/src/compiled/graph/step.rs index a341966e..c010426f 100644 --- a/core/engine/src/compiled/graph/step.rs +++ b/core/engine/src/compiled/graph/step.rs @@ -284,7 +284,7 @@ impl CompiledGraph { .skip(i + 1) .any(|(b, _)| DotPath::overlaps(a, b)) }); - let walked = overlapping && entries.iter().any(|(_, source)| source.contains('$')); + let dollar = overlapping && entries.iter().any(|(_, source)| source.contains('$')); let mut expanded: Vec<(Arc, Arc, Arc)> = Vec::with_capacity(entries.len()); for (key, source) in entries.iter() { let read = format!("$.{}", key.split('.').next().unwrap_or_default()); @@ -307,6 +307,7 @@ impl CompiledGraph { .collect(); let program = LaneProgram::compile_many_located(&refs, true, &labels).map_err(|e| e.to_string())?; + let walked = dollar || (overlapping && Self::writes_through_alias(&entries, &program)); let empty: Box<[bool]> = expanded .iter() .map(|(_, _, fragment)| fragment.trim() == "{}") @@ -335,6 +336,33 @@ impl CompiledGraph { }) } + fn writes_through_alias(entries: &[(Arc, Arc)], program: &LaneProgram) -> bool { + let p = program.program(); + let regs: &[_] = match p.outputs.is_empty() { + true => std::slice::from_ref(&p.out), + false => &p.outputs, + }; + entries.iter().enumerate().any(|(i, (key, source))| { + let under = entries + .iter() + .take(i) + .any(|(earlier, _)| DotPath::under(key, earlier)); + let typed = regs + .get(i) + .and_then(|reg| p.kinds.get(*reg as usize)) + .is_some_and(|kind| { + matches!( + kind, + zen_expression::lane::Kind::Num + | zen_expression::lane::Kind::Bool + | zen_expression::lane::Kind::Str + | zen_expression::lane::Kind::Date + ) + }); + under && !typed && !SourceInfo::scalar(source) + }) + } + fn table_kind( node: &str, content: &DecisionTableContent, diff --git a/core/engine/tests/trace_golden.rs b/core/engine/tests/trace_golden.rs index 00465b89..823b6256 100644 --- a/core/engine/tests/trace_golden.rs +++ b/core/engine/tests/trace_golden.rs @@ -1168,10 +1168,11 @@ fn restored_document(doc: &Value, input: &zen_engine::Variable) -> Option Some(unperformed(untimed(serde_json::to_value(&back).ok()?))) } -const COLUMNAR_INTERMEDIATE: [&str; 3] = [ +const COLUMNAR_INTERMEDIATE: [&str; 4] = [ "graph/71-generated-b.json5#gb018: 6 nodes, loop table, loop expr, loop expr, expr, loop expr, expr", "graph/71-generated-b.json5#gb008: 7 nodes, table*, switch*, switch, switch*, expr, expr, table", "graph/64-expression-optimizations.json5#alias: a copy taken before the original field is rewritten keeps the old value", + "graph/49-rows-nested-shapes.json5#expression keys writing a parent and a child path, values varying per row", ]; fn columnar_rows() { diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index e3f1c1f0..4b7a021f 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -975,3 +975,259 @@ fn a_batch_row_keeps_a_nested_null_from_a_table_shared_with_a_pass_through_branc ], ); } + +fn engine_with(version: EngineVersion, children: &[(&str, Value)]) -> DecisionEngine { + let memory = zen_engine::loader::MemoryLoader::default(); + for (key, child) in children { + let content: DecisionContent = serde_json::from_value(child.clone()).unwrap(); + memory.add(*key, content); + } + DecisionEngine::default() + .with_loader(Arc::new(memory)) + .with_version(version) +} + +fn cyclic_rows_fail_alone_on_version_2(graph: &Value, good: &Value, bad: &Value, at: &str) { + cyclic_rows_fail_alone_with_children(graph, &[], good, bad, at); +} + +fn cyclic_rows_fail_alone_with_children( + graph: &Value, + children: &[(&str, Value)], + good: &Value, + bad: &Value, + at: &str, +) { + let content: Arc = Arc::new(serde_json::from_value(graph.clone()).unwrap()); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let shown = + |row: Result>| { + row.map(|response| response.result.to_value()) + .unwrap_or_else( + |error| json!({"error": serde_json::to_value(&error).unwrap().to_string()}), + ) + }; + let want = shown( + runtime.block_on( + engine_with(EngineVersion::V1, children) + .create_decision(content.clone()) + .unwrap() + .evaluate(Variable::from(good.clone())), + ), + ); + assert!(want.get("error").is_none(), "{want}"); + let failed = |got: &Value, what: &str| { + let message = got.get("error").and_then(Value::as_str).unwrap_or_default(); + assert!( + message.contains("cyclic value at") && message.contains(at), + "{what}: {got}" + ); + }; + for trace in [ + zen_engine::trace::TraceFormat::Off, + zen_engine::trace::TraceFormat::Legacy, + zen_engine::trace::TraceFormat::V1, + ] { + let options = EvaluationOptions { + trace, + ..Default::default() + }; + let mut decision = engine_with(EngineVersion::V2, children) + .create_decision(content.clone()) + .unwrap(); + for compiled in [false, true] { + if compiled { + decision.compile(); + } + for call in 0..3 { + let one = |input: &Value| { + shown(runtime.block_on( + decision.evaluate_with_opts(Variable::from(input.clone()), options), + )) + }; + failed( + &one(bad), + &format!("{trace:?} compiled {compiled} call {call}"), + ); + assert_eq!(one(good), want, "{trace:?} compiled {compiled} call {call}"); + } + for rows in [ + vec![bad.clone()], + vec![good.clone(), bad.clone(), good.clone(), bad.clone()], + ] { + let inputs: Vec = rows.iter().cloned().map(Variable::from).collect(); + let batch = runtime.block_on(decision.evaluate_batch(&inputs, options)); + assert_eq!(batch.len(), rows.len()); + for (row, (input, got)) in rows.iter().zip(batch).enumerate() { + let got = shown(got); + let what = format!( + "{trace:?} compiled {compiled} batch of {} row {row}", + rows.len() + ); + match input == bad { + true => failed(&got, &what), + false => assert_eq!(got, want, "{what}"), + } + } + } + } + } +} + +fn cyclic_columns_fail_alone_on_version_2(graph: &Value, flags: &[i64], at: &str) { + use zen_engine::columns::{Column, Columns, Values}; + let content: Arc = Arc::new(serde_json::from_value(graph.clone()).unwrap()); + let decision = DecisionEngine::default() + .with_version(EngineVersion::V2) + .create_decision(content) + .unwrap(); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let ks = vec![1i64; flags.len()]; + let columns = Columns::new(flags.len()) + .column("x", Column::new(Values::I64(flags))) + .column("obj.k", Column::new(Values::I64(&ks))); + for trace in [ + zen_engine::trace::TraceFormat::Off, + zen_engine::trace::TraceFormat::V1, + ] { + let options = EvaluationOptions { + trace, + ..Default::default() + }; + let output = runtime.block_on(decision.evaluate_columns(&columns, options)); + for (row, flag) in flags.iter().enumerate() { + let error = output.errors[row].as_ref().map(|error| error.to_string()); + match flag { + 1 => assert!( + error + .as_deref() + .is_some_and(|e| e.contains("cyclic value at") && e.contains(at)), + "{trace:?} row {row}: {error:?}" + ), + _ => assert!(error.is_none(), "{trace:?} row {row}: {error:?}"), + } + } + } +} + +#[test] +fn version_2_rejects_an_entry_that_writes_an_object_into_its_own_alias() { + let graph = expressions(&[("a", "obj"), ("a.c", "x == 1 ? obj : 0")]); + let good = json!({"x": 0, "obj": {"k": 1}}); + let bad = json!({"x": 1, "obj": {"k": 1}}); + cyclic_rows_fail_alone_on_version_2(&graph, &good, &bad, "a.c"); + cyclic_columns_fail_alone_on_version_2(&graph, &[0, 1, 0, 1], "a.c"); +} + +#[test] +fn version_2_rejects_an_entry_that_writes_an_input_object_into_itself() { + let graph = expressions(&[("a", "a"), ("a.c", "x == 1 ? a : 0")]); + let good = json!({"x": 0, "a": {"k": 1}}); + let bad = json!({"x": 1, "a": {"k": 1}}); + cyclic_rows_fail_alone_on_version_2(&graph, &good, &bad, "a.c"); +} + +#[test] +fn version_2_rejects_an_alias_write_deep_inside_the_aliased_object() { + let graph = expressions(&[("a", "obj"), ("a.k.z", "x == 1 ? [obj] : 0")]); + let good = json!({"x": 0, "obj": {"k": {"q": 1}}}); + let bad = json!({"x": 1, "obj": {"k": {"q": 1}}}); + cyclic_rows_fail_alone_on_version_2(&graph, &good, &bad, "a.k.z"); +} + +#[test] +fn version_2_rejects_an_alias_write_under_an_output_path() { + for pass_through in [false, true] { + let graph = chained(vec![json!({ + "id": "node", "name": "node", "type": "expressionNode", + "content": { + "outputPath": "res", + "passThrough": pass_through, + "expressions": [ + {"id": "a", "key": "a", "value": "obj"}, + {"id": "b", "key": "a.c", "value": "x == 1 ? obj : 0"} + ] + } + })]); + let good = json!({"x": 0, "obj": {"k": 1}}); + let bad = json!({"x": 1, "obj": {"k": 1}}); + cyclic_rows_fail_alone_on_version_2(&graph, &good, &bad, "a.c"); + } +} + +#[test] +fn version_2_rejects_an_alias_write_inside_a_loop_item() { + let graph = graph(json!({ + "id": "node", "name": "node", "type": "expressionNode", + "content": { + "inputField": "items", + "executionMode": "loop", + "expressions": [ + {"id": "a", "key": "a", "value": "o"}, + {"id": "b", "key": "a.c", "value": "x == 1 ? o : 0"} + ] + } + })); + let good = json!({"items": [{"x": 0, "o": {"k": 1}}, {"x": 0, "o": {"k": 2}}]}); + let bad = json!({"items": [{"x": 0, "o": {"k": 1}}, {"x": 1, "o": {"k": 2}}]}); + cyclic_rows_fail_alone_on_version_2(&graph, &good, &bad, "a.c"); +} + +#[test] +fn version_2_rejects_an_alias_write_through_a_value_read_from_an_earlier_node() { + let graph = chained(vec![ + json!({"id": "first", "name": "first", "type": "expressionNode", "content": { + "expressions": [{"id": "a", "key": "a", "value": "obj"}, {"id": "b", "key": "x", "value": "x"}] + }}), + json!({"id": "second", "name": "second", "type": "expressionNode", "content": { + "expressions": [ + {"id": "c", "key": "a", "value": "a"}, + {"id": "d", "key": "a.c", "value": "x == 1 ? a : 0"} + ] + }}), + json!({"id": "third", "name": "third", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "e", "key": "seen", "value": "$nodes.second.a.k"}] + }}), + ]); + let good = json!({"x": 0, "obj": {"k": 1}}); + let bad = json!({"x": 1, "obj": {"k": 1}}); + cyclic_rows_fail_alone_on_version_2(&graph, &good, &bad, "a.c"); +} + +#[test] +fn version_2_rejects_an_alias_write_inside_a_sub_decision() { + let child = expressions(&[("a", "obj"), ("a.c", "x == 1 ? obj : 0")]); + let graph = chained(vec![json!({ + "id": "sub", "name": "sub", "type": "decisionNode", + "content": {"key": "child.json"} + })]); + let good = json!({"x": 0, "obj": {"k": 1}}); + let bad = json!({"x": 1, "obj": {"k": 1}}); + cyclic_rows_fail_alone_with_children(&graph, &[("child.json", child)], &good, &bad, "a.c"); +} + +#[test] +fn version_2_keeps_alias_writes_that_cannot_cycle() { + same_on_every_path( + &expressions(&[ + ("a", "obj"), + ("a.c", "obj.k"), + ("a.d", "[1, 2]"), + ("b", "obj"), + ]), + &json!({"obj": {"k": 1}}), + json!({"a": {"k": 1, "c": 1, "d": [1, 2]}, "b": {"k": 1, "c": 1, "d": [1, 2]}}), + ); + same_on_every_path( + &expressions(&[("a", "obj"), ("a.c", "other"), ("a.e", "1")]), + &json!({"obj": {"k": 1}, "other": {"j": [0]}}), + json!({"a": {"k": 1, "c": {"j": [0]}, "e": 1}}), + ); +} diff --git a/core/expression/src/lane/session.rs b/core/expression/src/lane/session.rs index 3297cdd0..68e21854 100644 --- a/core/expression/src/lane/session.rs +++ b/core/expression/src/lane/session.rs @@ -123,6 +123,12 @@ impl Session { self.scope.set_local(name, value); } + pub fn dollar_cycles(&self, path: &str, value: &Variable) -> bool { + self.scope + .local(&Variable::dollar_key()) + .is_some_and(|dollar| dollar.dot_insert_cycles(path, value)) + } + pub fn insert_dollar(&mut self, path: &str, value: Variable) { let dollar = match self.scope.local(&Variable::dollar_key()) { Some(existing @ Variable::Object(_)) => existing.shallow_clone(), diff --git a/core/expression/src/lane/source.rs b/core/expression/src/lane/source.rs index bb635a95..43cf9fde 100644 --- a/core/expression/src/lane/source.rs +++ b/core/expression/src/lane/source.rs @@ -1,5 +1,5 @@ use crate::functions::{FunctionKind, InternalFunction}; -use crate::lexer::Lexer; +use crate::lexer::{Lexer, LogicalOperator, Operator}; use crate::parser::{Node, Parser}; use bumpalo::Bump; use std::cell::Cell; @@ -40,6 +40,53 @@ impl SourceInfo { found.get() } + pub fn scalar(source: &str) -> bool { + if source.trim().is_empty() { + return true; + } + let bump = Bump::new(); + let mut lexer = Lexer::new(); + let Ok(tokens) = lexer.tokenize(&bump, source) else { + return false; + }; + let Ok(parser) = Parser::try_new(&tokens, &bump) else { + return false; + }; + let parsed = parser.standard().parse(); + if parsed.error().is_err() { + return false; + } + Self::scalar_node(parsed.root) + } + + fn scalar_node(node: &Node) -> bool { + match node { + Node::Null + | Node::Bool(_) + | Node::Number(_) + | Node::String(_) + | Node::TemplateString(_) + | Node::Interval { .. } + | Node::Unary { .. } => true, + Node::Parenthesized(inner) => Self::scalar_node(inner), + Node::Conditional { + on_true, on_false, .. + } => Self::scalar_node(on_true) && Self::scalar_node(on_false), + Node::Binary { + left, + operator, + right, + } => match operator { + Operator::Arithmetic(_) | Operator::Comparison(_) => true, + Operator::Logical( + LogicalOperator::And | LogicalOperator::Or | LogicalOperator::NullishCoalescing, + ) => Self::scalar_node(left) && Self::scalar_node(right), + _ => false, + }, + _ => false, + } + } + pub fn draws(source: &str) -> bool { let test = |node: &Node| { matches!( diff --git a/core/types/src/variable/mod.rs b/core/types/src/variable/mod.rs index 2b112fe9..a8e5a332 100644 --- a/core/types/src/variable/mod.rs +++ b/core/types/src/variable/mod.rs @@ -280,6 +280,65 @@ impl Variable { object.insert_str(last_part, variable) } + pub fn dot_insert_cycles(&self, key: &str, variable: &Variable) -> bool { + if !matches!(variable, Variable::Object(_) | Variable::Array(_)) { + return false; + } + let Variable::Object(root) = self else { + return false; + }; + let mut ancestors: Vec<*const ()> = vec![Rc::as_ptr(root) as *const ()]; + let mut parts = key.split('.'); + parts.next_back(); + let mut head = root.clone(); + for part in parts { + let next = match head.borrow().get_str(part) { + Some(Variable::Object(next)) => next.clone(), + _ => break, + }; + ancestors.push(Rc::as_ptr(&next) as *const ()); + head = next; + } + drop(head); + variable.reaches_any(&ancestors) + } + + pub fn reaches_any(&self, targets: &[*const ()]) -> bool { + let mut seen: std::collections::HashSet<*const ()> = Default::default(); + let mut pending: Vec = vec![self.shallow_clone()]; + while let Some(current) = pending.pop() { + let pointer = match ¤t { + Variable::Object(object) => Rc::as_ptr(object) as *const (), + Variable::Array(array) => Rc::as_ptr(array) as *const (), + _ => continue, + }; + if targets.contains(&pointer) { + return true; + } + if !seen.insert(pointer) { + continue; + } + match ¤t { + Variable::Object(object) => pending.extend( + object + .borrow() + .values() + .filter(|value| matches!(value, Variable::Object(_) | Variable::Array(_))) + .map(Variable::shallow_clone), + ), + Variable::Array(array) => pending.extend( + array + .borrow() + .iter() + .filter(|value| matches!(value, Variable::Object(_) | Variable::Array(_))) + .map(Variable::shallow_clone), + ), + _ => {} + } + } + false + } + pub fn dot_insert_detached(&self, key: &str, variable: Variable) -> Option { let last_part = key.split('.').last()?; let (new_var, head_opt) = self.dot_head_detach(key); From c5c07b7d4b9c3bc321feae11363c503aaf7cbac1 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 13:41:17 +0100 Subject: [PATCH 24/32] test(engine): cover a script returning a cyclic object on version 2 Ignored until the version 2 JS runtime rejects cyclic results; it hangs today. --- core/engine/tests/version_parity.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 4b7a021f..74332760 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -1231,3 +1231,15 @@ fn version_2_keeps_alias_writes_that_cannot_cycle() { json!({"a": {"k": 1, "c": {"j": [0]}, "e": 1}}), ); } + +#[test] +#[ignore = "the version 2 JS runtime converts a cyclic result without a guard and never returns"] +fn version_2_rejects_a_script_returning_a_cyclic_object() { + let graph = graph(json!({ + "id": "node", "name": "node", "type": "functionNode", + "content": {"source": "export const handler = async (input) => { if (input.x !== 1) return input; const o = {}; o.self = o; return o; };"} + })); + let good = json!({"x": 0}); + let bad = json!({"x": 1}); + cyclic_rows_fail_alone_on_version_2(&graph, &good, &bad, "self"); +} From 5cdd79e30e1d51b4bacd0582119faa54fa2ca935 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 14:09:31 +0100 Subject: [PATCH 25/32] fix(engine): match version 1 in script globals and dates, stop idle or cyclic scripts, and load date support lazily --- Cargo.lock | 1 + core/engine/Cargo.toml | 1 + .../src/compiled/host/function/purity.rs | 4 +- .../src/compiled/host/function/v1/mod.rs | 9 +- .../src/compiled/host/function/v1/runtime.rs | 18 ++ .../src/compiled/host/function/v2/function.rs | 125 ++++++++++- .../src/compiled/host/function/v2/mod.rs | 6 +- .../host/function/v2/module/console.rs | 1 + .../host/function/v2/module/http/listener.rs | 2 + .../host/function/v2/module/http/mod.rs | 1 + .../compiled/host/function/v2/module/zen.rs | 2 + .../src/compiled/host/function/v2/serde.rs | 71 +++++-- core/engine/src/compiled/pinning.entry.js | 24 +++ core/engine/src/compiled/pinning.js | 172 +++++++-------- core/engine/src/compiled/pinning.rs | 136 +++++++++--- core/engine/tests/concurrent.rs | 3 +- core/engine/tests/function_limits.rs | 201 ++++++++++++++++++ core/engine/tests/function_parity.rs | 180 ++++++++++++++++ core/engine/tests/pinned.rs | 24 ++- core/engine/tests/version_parity.rs | 12 -- 20 files changed, 805 insertions(+), 188 deletions(-) create mode 100644 core/engine/src/compiled/pinning.entry.js create mode 100644 core/engine/tests/function_limits.rs create mode 100644 core/engine/tests/function_parity.rs diff --git a/Cargo.lock b/Cargo.lock index 9411781e..bbc2df9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6065,6 +6065,7 @@ dependencies = [ "async-trait", "base64", "chrono", + "chrono-tz", "criterion", "ctor", "downcast-rs", diff --git a/core/engine/Cargo.toml b/core/engine/Cargo.toml index c19292e3..6f5bc950 100644 --- a/core/engine/Cargo.toml +++ b/core/engine/Cargo.toml @@ -13,6 +13,7 @@ doctest = false [dependencies] chrono = { workspace = true } +chrono-tz = "0.10" ahash = { workspace = true } anyhow = { workspace = true } base64 = "0.22" diff --git a/core/engine/src/compiled/host/function/purity.rs b/core/engine/src/compiled/host/function/purity.rs index 283e66b3..fdbafade 100644 --- a/core/engine/src/compiled/host/function/purity.rs +++ b/core/engine/src/compiled/host/function/purity.rs @@ -1461,7 +1461,6 @@ impl Walk { #[cfg(test)] mod tests { use super::Purity; - use crate::compiled::host::function::v2::serde::{JsValue, JsValueWithNodes}; use crate::compiled::host::NodeHandlerExtensions; use zen_expression::Variable; @@ -1583,8 +1582,9 @@ mod tests { let response = function .call_handler( &name, - JsValueWithNodes(JsValue(Variable::Null)), + Variable::Null, &zen_expression::context::EvaluationContext::default(), + std::time::Instant::now() + std::time::Duration::from_secs(5), ) .await .expect("names"); diff --git a/core/engine/src/compiled/host/function/v1/mod.rs b/core/engine/src/compiled/host/function/v1/mod.rs index e66cab7d..41682f0c 100644 --- a/core/engine/src/compiled/host/function/v1/mod.rs +++ b/core/engine/src/compiled/host/function/v1/mod.rs @@ -5,7 +5,7 @@ use std::time::{Duration, Instant}; use crate::compiled::host::definition::NodeHandler; use crate::compiled::host::function::purity::Purity; -use crate::compiled::host::function::v1::runtime::create_runtime; +use crate::compiled::host::function::v1::runtime::{acquire_runtime, release_runtime}; use crate::compiled::host::function::v1::script::{Script, Session}; use crate::compiled::host::result::NodeResult; use crate::compiled::host::{NodeContext, NodeContextBase, NodeContextExt, NodeError}; @@ -28,7 +28,8 @@ impl NodeHandler for FunctionV1NodeHandler { async fn handle(&self, ctx: NodeContext) -> NodeResult { let start = Instant::now(); - let runtime = create_runtime().node_context_message(&ctx, "Failed to create JS Runtime")?; + let runtime = + acquire_runtime().node_context_message(&ctx, "Failed to create JS Runtime")?; let interrupt_handler = Box::new(move || start.elapsed() > MAX_DURATION); runtime.set_interrupt_handler(Some(interrupt_handler)); @@ -41,8 +42,12 @@ impl NodeHandler for FunctionV1NodeHandler { &ctx.extensions.context.nested(Located::function(&ctx.id)), ) .await; + drop(script); runtime.set_interrupt_handler(None); + if result_response.is_ok() { + release_runtime(runtime); + } let response = result_response.node_context(&ctx)?; ctx.trace(|t| { diff --git a/core/engine/src/compiled/host/function/v1/runtime.rs b/core/engine/src/compiled/host/function/v1/runtime.rs index 916a5b01..aed2d4c1 100644 --- a/core/engine/src/compiled/host/function/v1/runtime.rs +++ b/core/engine/src/compiled/host/function/v1/runtime.rs @@ -1,6 +1,7 @@ use anyhow::Context; use rquickjs::loader::Bundle; use rquickjs::{embed, Runtime}; +use std::cell::RefCell; static JS_BUNDLE: Bundle = embed! { "dayjs": "js/v1/dayjs.js", @@ -8,9 +9,26 @@ static JS_BUNDLE: Bundle = embed! { "internals": "js/v1/internals.js" }; +thread_local! { + static IDLE: RefCell> = const { RefCell::new(None) }; +} + pub(crate) fn create_runtime() -> anyhow::Result { let runtime = Runtime::new().context("Failed to create runtime")?; runtime.set_loader(JS_BUNDLE, JS_BUNDLE); Ok(runtime) } + +pub(crate) fn acquire_runtime() -> anyhow::Result { + match IDLE.with_borrow_mut(Option::take) { + Some(runtime) => Ok(runtime), + None => create_runtime(), + } +} + +pub(crate) fn release_runtime(runtime: Runtime) { + if !runtime.is_job_pending() { + IDLE.with_borrow_mut(|idle| *idle = Some(runtime)); + } +} diff --git a/core/engine/src/compiled/host/function/v2/function.rs b/core/engine/src/compiled/host/function/v2/function.rs index 88f0448b..2e20d8d4 100644 --- a/core/engine/src/compiled/host/function/v2/function.rs +++ b/core/engine/src/compiled/host/function/v2/function.rs @@ -1,9 +1,14 @@ -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; use std::collections::HashMap; use std::fmt::{Debug, Formatter}; +use std::future::{poll_fn, Future}; use std::hash::{DefaultHasher, Hash, Hasher}; +use std::pin::{pin, Pin}; use std::sync::Arc; +use std::task::Poll; +use std::time::{Duration, Instant}; +use crate::compiled::host::function::sleep::sleep; use crate::compiled::host::function::v2::error::{FunctionError, FunctionResult, ResultExt}; use crate::compiled::host::function::v2::listener::{RuntimeEvent, RuntimeListener}; use crate::compiled::host::function::v2::module::console::{Console, Log}; @@ -12,7 +17,10 @@ use crate::compiled::host::function::v2::serde::{JsValue, JsValueWithNodes}; use crate::compiled::pinning::JsSlot; use rquickjs::prelude::Func; use rquickjs::promise::MaybePromise; -use rquickjs::{async_with, AsyncContext, AsyncRuntime, CatchResultExt, Ctx, Module, Object}; +use rquickjs::{ + async_with, AsyncContext, AsyncRuntime, CatchResultExt, Ctx, IntoJs, Module, Object, + Persistent, Type, Value, +}; use serde::{Deserialize, Serialize}; use std::rc::Rc; use zen_expression::context::EvaluationContext; @@ -24,6 +32,7 @@ pub struct FunctionConfig { } pub struct Function { + nodes: RefCell>>>, rt: Arc, ctx: AsyncContext, listeners: Vec>, @@ -49,6 +58,7 @@ impl Function { let ctx = AsyncContext::full(&rt).await?; let this = Self { + nodes: RefCell::new(None), rt, ctx, module_loader, @@ -162,18 +172,20 @@ impl Function { pub(crate) async fn call_handler( &self, name: &str, - data: JsValueWithNodes, + data: Variable, context: &EvaluationContext, + deadline: Instant, ) -> FunctionResult { let _entered = self.slot.enter(context.clone()); let k: FunctionResult = async_with!(&self.ctx => |ctx| { self.dispatch_event_inner(&ctx, RuntimeEvent::SoftReset).await?; - let m: rquickjs::Object = Module::import(&ctx, name).catch(&ctx)?.into_future().await.catch(&ctx)?; + let m: rquickjs::Object = bounded(&ctx, Module::import(&ctx, name).catch(&ctx)?.into_future(), deadline).await?; let handler: rquickjs::Function = m.get("handler").catch(&ctx)?; + let data = self.with_nodes(&ctx, data).catch(&ctx)?; let handler_promise: MaybePromise = handler.call((data, 5)).catch(&ctx)?; - let handler_result = handler_promise.into_future::().await.catch(&ctx)?; + let handler_result: JsValue = bounded(&ctx, handler_promise.into_future(), deadline).await?; let console = Console::from_context(&ctx).or_throw(&ctx)?; let logs = console.logs.into_inner(); @@ -190,6 +202,7 @@ impl Function { name: &str, config: (u8, u8, bool), rows: Vec<(Variable, Option)>, + limit: Duration, tick: &dyn Fn(), context: &EvaluationContext, ) -> Vec> { @@ -206,19 +219,22 @@ impl Function { ctx.globals() .set("__getNodesData", Func::from(move || JsValue(shared.borrow().clone()))) .catch(&ctx)?; - let m: rquickjs::Object = Module::import(&ctx, name).catch(&ctx)?.into_future().await.catch(&ctx)?; + let deadline = Instant::now() + limit; + let m: rquickjs::Object = bounded(&ctx, Module::import(&ctx, name).catch(&ctx)?.into_future(), deadline).await?; let handler: rquickjs::Function = m.get("handler").catch(&ctx)?; let mut results = Vec::with_capacity(count); self.dispatch_event_inner(&ctx, RuntimeEvent::SoftReset).await?; for (input, nodes) in rows { tick(); + let deadline = Instant::now() + limit; *current.borrow_mut() = nodes.unwrap_or_default(); let result: FunctionResult = async { if config.2 { self.dispatch_event_inner(&ctx, RuntimeEvent::SoftReset).await?; } - let promise: MaybePromise = handler.call((JsValueWithNodes(JsValue(input)), 5)).catch(&ctx)?; - let value = promise.into_future::().await.catch(&ctx)?; + let input = self.with_nodes(&ctx, input).catch(&ctx)?; + let promise: MaybePromise = handler.call((input, 5)).catch(&ctx)?; + let value: JsValue = bounded(&ctx, promise.into_future(), deadline).await?; Ok(value.0) } .await; @@ -238,6 +254,23 @@ impl Function { } } + fn with_nodes<'js>(&self, ctx: &Ctx<'js>, input: Variable) -> rquickjs::Result> { + let value = JsValue(input).into_js(ctx)?; + if !value.is_object() { + return Ok(value); + } + let saved = self.nodes.borrow().clone(); + let factory = match saved { + Some(saved) => saved.restore(ctx)?, + None => { + let factory = JsValueWithNodes::factory(ctx)?; + *self.nodes.borrow_mut() = Some(Persistent::save(ctx, factory.clone())); + factory + } + }; + JsValueWithNodes::attach(value, &factory) + } + pub(crate) async fn extract_logs(&self) -> Vec { let logs: Option> = async_with!(&self.ctx => |ctx| { let console = Console::from_context(&ctx).ok()?; @@ -255,6 +288,82 @@ pub struct HandlerResponse { pub data: Variable, } +async fn bounded<'js, T>( + ctx: &Ctx<'js>, + future: impl Future>, + deadline: Instant, +) -> FunctionResult { + let mut future = pin!(future); + let mut timer: Option>>> = None; + let settled = poll_fn(|cx| loop { + if let Poll::Ready(result) = future.as_mut().poll(cx) { + return Poll::Ready(Ok(result)); + } + let Some(timer) = timer.as_mut() else { + if ctx.execute_pending_job() { + let thrown = ctx.catch(); + if !matches!( + thrown.type_of(), + Type::Uninitialized | Type::Null | Type::Undefined + ) { + return Poll::Ready(Err(Some(thrown))); + } + continue; + } + if Waiting::any() { + return Poll::Pending; + } + let remaining = deadline.saturating_duration_since(Instant::now()); + timer = Some(Box::pin(sleep(remaining))); + continue; + }; + if Waiting::any() { + return Poll::Pending; + } + return match timer.as_mut().poll(cx) { + Poll::Ready(()) => Poll::Ready(Err(None)), + Poll::Pending => Poll::Pending, + }; + }) + .await; + let caught = match settled { + Ok(result) => result.catch(ctx).map_err(FunctionError::from), + Err(Some(thrown)) => Err::(ctx.throw(thrown)) + .catch(ctx) + .map_err(FunctionError::from), + Err(None) => Err(FunctionError::Caught(TIMED_OUT.to_string())), + }; + match caught { + Err(_) if Instant::now() >= deadline => Err(FunctionError::Caught(TIMED_OUT.to_string())), + other => other, + } +} + +const TIMED_OUT: &str = "Error: interrupted"; + +thread_local! { + static WAITING: Cell = const { Cell::new(0) }; +} + +pub(crate) struct Waiting; + +impl Waiting { + pub(crate) fn enter() -> Self { + WAITING.set(WAITING.get() + 1); + Waiting + } + + fn any() -> bool { + WAITING.get() > 0 + } +} + +impl Drop for Waiting { + fn drop(&mut self) { + WAITING.set(WAITING.get().saturating_sub(1)); + } +} + fn create_content_hash(content: &str) -> u64 { let mut hasher = DefaultHasher::new(); content.hash(&mut hasher); diff --git a/core/engine/src/compiled/host/function/v2/mod.rs b/core/engine/src/compiled/host/function/v2/mod.rs index 576df74f..f850b2cb 100644 --- a/core/engine/src/compiled/host/function/v2/mod.rs +++ b/core/engine/src/compiled/host/function/v2/mod.rs @@ -8,7 +8,7 @@ use crate::compiled::host::function::purity::Purity; use crate::compiled::host::function::v2::error::{FunctionError, FunctionResult}; use crate::compiled::host::function::v2::function::Function; use crate::compiled::host::function::v2::module::console::Log; -use crate::compiled::host::function::v2::serde::{JsValue, JsValueWithNodes}; +use crate::compiled::host::function::v2::serde::JsValue; use crate::compiled::host::result::NodeResult; use crate::compiled::host::{NodeContext, NodeContextConfig, NodeError, NodeHandlerExtensions}; use crate::compiled::pinning::Located; @@ -78,8 +78,9 @@ impl NodeHandler for FunctionV2NodeHandler { let response_result = function .call_handler( &module_name, - JsValueWithNodes(JsValue(ctx.input.clone())), + ctx.input.clone(), &ctx.extensions.context.nested(Located::function(&ctx.id)), + start + max_duration, ) .await; @@ -197,6 +198,7 @@ impl FunctionV2NodeHandler { config.trace, ), rows, + limit, &tick, &extensions.context.nested(Located::function(id)), ) diff --git a/core/engine/src/compiled/host/function/v2/module/console.rs b/core/engine/src/compiled/host/function/v2/module/console.rs index ce260c38..6c791ca1 100644 --- a/core/engine/src/compiled/host/function/v2/module/console.rs +++ b/core/engine/src/compiled/host/function/v2/module/console.rs @@ -100,6 +100,7 @@ impl Console { } pub async fn sleep(&self, duration_ms: u64) -> rquickjs::Result<()> { + let _waiting = crate::compiled::host::function::v2::function::Waiting::enter(); crate::compiled::host::function::sleep::sleep(Duration::from_millis(duration_ms)).await; Ok(()) } diff --git a/core/engine/src/compiled/host/function/v2/module/http/listener.rs b/core/engine/src/compiled/host/function/v2/module/http/listener.rs index af249a82..bc7ed38c 100644 --- a/core/engine/src/compiled/host/function/v2/module/http/listener.rs +++ b/core/engine/src/compiled/host/function/v2/module/http/listener.rs @@ -37,6 +37,8 @@ impl RuntimeListener for HttpListener { rquickjs_conv::from_value::(request_obj); async move { + let _waiting = + crate::compiled::host::function::v2::function::Waiting::enter(); let request = request_result?; let response = http_handler.handle(request).await.or_throw(&ctx)?; let response_object = rquickjs_conv::to_value(ctx.clone(), response)?; diff --git a/core/engine/src/compiled/host/function/v2/module/http/mod.rs b/core/engine/src/compiled/host/function/v2/module/http/mod.rs index cdb5a67d..c6cc7129 100644 --- a/core/engine/src/compiled/host/function/v2/module/http/mod.rs +++ b/core/engine/src/compiled/host/function/v2/module/http/mod.rs @@ -21,6 +21,7 @@ async fn execute_http<'js>( data: Option, request: Option, ) -> rquickjs::Result> { + let _waiting = crate::compiled::host::function::v2::function::Waiting::enter(); let mut request = request.unwrap_or_default(); if let Some(data) = data { request.data = Some(data); diff --git a/core/engine/src/compiled/host/function/v2/module/zen.rs b/core/engine/src/compiled/host/function/v2/module/zen.rs index af9ad663..05c58b0c 100644 --- a/core/engine/src/compiled/host/function/v2/module/zen.rs +++ b/core/engine/src/compiled/host/function/v2/module/zen.rs @@ -128,6 +128,8 @@ impl RuntimeListener for ZenListener { let context = slot.current().unwrap_or_default(); async move { + let _waiting = + crate::compiled::host::function::v2::function::Waiting::enter(); let config: Object = ctx.globals().get("config").or_throw(&ctx)?; let iteration: u8 = config.get("iteration").or_throw(&ctx)?; diff --git a/core/engine/src/compiled/host/function/v2/serde.rs b/core/engine/src/compiled/host/function/v2/serde.rs index f5e3f532..b77d98eb 100644 --- a/core/engine/src/compiled/host/function/v2/serde.rs +++ b/core/engine/src/compiled/host/function/v2/serde.rs @@ -1,7 +1,7 @@ use crate::compiled::host::function::v2::error::ResultExt; use crate::decision_graph::cleaner::ZEN_RESERVED_PROPERTIES; use nohash_hasher::BuildNoHashHasher; -use rquickjs::{Ctx, FromJs, IntoJs, Type, Value as QValue}; +use rquickjs::{Ctx, Exception, FromJs, IntoJs, Type, Value as QValue}; use rust_decimal::prelude::ToPrimitive; use rust_decimal::Decimal; use serde_json::json; @@ -13,8 +13,35 @@ use zen_types::rccell::RcCell; pub(crate) struct JsValue(pub(crate) Variable); impl<'js> FromJs<'js> for JsValue { - #[cfg_attr(not(target_family = "wasm"), recursive::recursive)] fn from_js(ctx: &Ctx<'js>, v: QValue<'js>) -> rquickjs::Result { + Self::convert(ctx, v, &mut Vec::new()) + } +} + +impl JsValue { + #[cfg_attr(not(target_family = "wasm"), recursive::recursive)] + fn convert<'js>( + ctx: &Ctx<'js>, + v: QValue<'js>, + ancestors: &mut Vec>, + ) -> rquickjs::Result { + if !v.is_object() { + return Self::convert_value(ctx, v, ancestors); + } + if ancestors.contains(&v) { + return Err(Exception::throw_type(ctx, "cyclic value")); + } + ancestors.push(v.clone()); + let converted = Self::convert_value(ctx, v, ancestors); + ancestors.pop(); + converted + } + + fn convert_value<'js>( + ctx: &Ctx<'js>, + v: QValue<'js>, + ancestors: &mut Vec>, + ) -> rquickjs::Result { let computed_value = match v.type_of() { Type::Uninitialized | Type::Undefined | Type::Null => Variable::Null, Type::Bool => { @@ -50,7 +77,7 @@ impl<'js> FromJs<'js> for JsValue { let mut js_arr = Vec::with_capacity(arr.len()); for x in arr.into_iter() { - js_arr.push(JsValue::from_js(ctx, x?)?.0) + js_arr.push(Self::convert(ctx, x?, ancestors)?.0) } Variable::from_array(js_arr) @@ -69,7 +96,7 @@ impl<'js> FromJs<'js> for JsValue { js_object.insert( zen_types::symbol::Symbol::from(k.as_str()), - JsValue::from_js(ctx, v)?.0, + Self::convert(ctx, v, ancestors)?.0, ); } @@ -92,8 +119,8 @@ impl<'js> FromJs<'js> for JsValue { Type::Unknown => json!("[Unknown]").into(), Type::Promise => { let promise = v.into_promise().or_throw(ctx)?; - let val: JsValue = promise.finish()?; - val.0 + let val: QValue = promise.finish()?; + Self::convert(ctx, val, ancestors)?.0 } }; @@ -117,25 +144,27 @@ impl<'js> IntoJs<'js> for JsValueWithNodes { return Ok(base_js); } - let obj = base_js.into_object().or_throw(ctx)?; - let globals = ctx.globals(); - let factory: rquickjs::Function<'js> = - match globals.get::<_, Option>>("__zenNodesProxy")? { - Some(factory) => factory, - None => { - let factory: rquickjs::Function<'js> = ctx.eval(Self::FACTORY)?; - globals.set("__zenNodesProxy", factory.clone())?; - factory - } - }; - let nodes_proxy: QValue<'js> = factory.call(())?; - - obj.set("$nodes", nodes_proxy)?; - Ok(obj.into_value()) + Self::attach(base_js, &Self::factory(ctx)?) } } impl JsValueWithNodes { + pub(crate) fn factory<'js>(ctx: &Ctx<'js>) -> rquickjs::Result> { + ctx.eval(Self::FACTORY) + } + + pub(crate) fn attach<'js>( + value: QValue<'js>, + factory: &rquickjs::Function<'js>, + ) -> rquickjs::Result> { + let Some(obj) = value.as_object() else { + return Ok(value); + }; + let nodes_proxy: QValue<'js> = factory.call(())?; + obj.set("$nodes", nodes_proxy)?; + Ok(value) + } + const FACTORY: &'static str = r#" () => { const _data = { loaded: false, inner: null }; diff --git a/core/engine/src/compiled/pinning.entry.js b/core/engine/src/compiled/pinning.entry.js new file mode 100644 index 00000000..57099c17 --- /dev/null +++ b/core/engine/src/compiled/pinning.entry.js @@ -0,0 +1,24 @@ +export default (now, random, load) => { + const Native = globalThis.Date; + let pinned; + const pin = () => pinned || (pinned = load(Native, PinnedDate)); + const PinnedDate = { + Date: function (year, month, date, hours, minutes, seconds, ms) { + return pin().construct(new.target, arguments); + }, + }.Date; + const statics = { + now() { return now(); }, + parse(text) { return pin().parse(text); }, + random() { return random(); }, + }; + Object.defineProperties(PinnedDate, { + prototype: { value: Native.prototype, writable: false }, + now: { value: statics.now, writable: true, configurable: true }, + parse: { value: statics.parse, writable: true, configurable: true }, + UTC: { value: Native.UTC, writable: true, configurable: true }, + }); + Native.prototype.constructor = PinnedDate; + globalThis.Date = PinnedDate; + Math.random = statics.random; +}; diff --git a/core/engine/src/compiled/pinning.js b/core/engine/src/compiled/pinning.js index 1ae077b6..a4d918e0 100644 --- a/core/engine/src/compiled/pinning.js +++ b/core/engine/src/compiled/pinning.js @@ -1,13 +1,5 @@ -(() => { - if (globalThis.__zenPinned) return; - const Native = Date; +export default (Native, PinnedDate, now, offsetAt, utcAt, canonicalZone) => { const proto = Native.prototype; - const now = globalThis.__zenNow; - const random = globalThis.__zenRandom; - const offsetAt = globalThis.__zenOffset; - const utcAt = globalThis.__zenUtc; - const zoneOf = globalThis.__zenZone; - const canonicalZone = globalThis.__zenCanonicalZone; const N = {}; for (const name of [ 'getTime', 'setTime', 'getUTCFullYear', 'getUTCMonth', 'getUTCDate', 'getUTCDay', @@ -17,8 +9,6 @@ ]) N[name] = proto[name]; const call = (f, self, ...args) => f.apply(self, args); const time = (d) => call(N.getTime, d); - const define = (target, name, value) => - Object.defineProperty(target, name, { value, writable: true, configurable: true, enumerable: false }); const offset = (t, zone) => { const o = offsetAt(t, zone); @@ -48,42 +38,25 @@ return utc === undefined ? NaN : utc; }; - const getters = { getFullYear: 'y', getMonth: 'mo', getDate: 'd', getDay: 'wd', getHours: 'h', getMinutes: 'mi', getSeconds: 's', getMilliseconds: 'ms' }; - for (const [name, key] of Object.entries(getters)) { - define(proto, name, function () { - const t = time(this); - return Number.isNaN(t) ? NaN : fields(t)[key]; - }); - } - define(proto, 'getTimezoneOffset', function () { - const t = time(this); - return Number.isNaN(t) ? NaN : -offset(t); - }); - if (proto.getYear) { - define(proto, 'getYear', function () { - const y = this.getFullYear(); - return Number.isNaN(y) ? NaN : y - 1900; - }); - } - const setters = [['setFullYear', 0, 3], ['setMonth', 1, 2], ['setDate', 2, 1], ['setHours', 3, 4], ['setMinutes', 4, 3], ['setSeconds', 5, 2], ['setMilliseconds', 6, 1]]; - for (const [name, at, count] of setters) { - define(proto, name, function (...args) { - const t = time(this); - let parts; - if (Number.isNaN(t)) { - if (name !== 'setFullYear') return NaN; - parts = [1970, 0, 1, 0, 0, 0, 0]; - } else { - const f = fields(t); - parts = [f.y, f.mo, f.d, f.h, f.mi, f.s, f.ms]; - } - const given = args.length === 0 ? [NaN] : args.slice(0, count).map(Number); - given.forEach((value, i) => { parts[at + i] = value; }); - const next = fromLocal(parts.map(Math.trunc)); - call(N.setTime, this, next); - return time(this); - }); - } + const field = (date, key) => { + const t = time(date); + return Number.isNaN(t) ? NaN : fields(t)[key]; + }; + const set = (date, at, count, args) => { + const t = time(date); + let parts; + if (Number.isNaN(t)) { + if (at !== 0) return NaN; + parts = [1970, 0, 1, 0, 0, 0, 0]; + } else { + const f = fields(t); + parts = [f.y, f.mo, f.d, f.h, f.mi, f.s, f.ms]; + } + const given = args.length === 0 ? [NaN] : Array.prototype.slice.call(args, 0, count).map(Number); + given.forEach((value, i) => { parts[at + i] = value; }); + call(N.setTime, date, fromLocal(parts.map(Math.trunc))); + return time(date); + }; const isoDate = /^\s*[+-]?\d{4,6}(?:-\d\d(?:-\d\d)?)?\s*$/; const zoned = /(?:\d[Zz]\s*$|[+-]\d\d:?\d\d\s*(?:\(.*\))?\s*$|\b(?:GMT|UTC|UT)\b)/; @@ -119,15 +92,15 @@ return typeof primitive === 'string' ? parse(primitive) : +primitive; }; - function PinnedDate(...args) { - if (!new.target) return new PinnedDate(now()).toString(); + const construct = (target, args) => { + if (!target) return new PinnedDate(now()).toString(); let t; if (args.length === 0) { t = now(); } else if (args.length === 1) { t = valueOf(args[0]); } else { - const parts = args.slice(0, 7).map(Number); + const parts = Array.prototype.slice.call(args, 0, 7).map(Number); while (parts.length < 7) parts.push(parts.length === 2 ? 1 : 0); let y = parts[0]; if (Number.isFinite(y)) { @@ -137,15 +110,8 @@ parts[0] = y; t = fromLocal(parts.map((p) => (Number.isFinite(p) ? Math.trunc(p) : p))); } - return Reflect.construct(Native, [t], new.target); - } - PinnedDate.prototype = proto; - PinnedDate.now = () => now(); - PinnedDate.parse = (text) => parse(text); - PinnedDate.UTC = Native.UTC; - define(proto, 'constructor', PinnedDate); - globalThis.Date = PinnedDate; - Math.random = () => random(); + return Reflect.construct(Native, [t], target); + }; const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; @@ -157,27 +123,11 @@ }; const datePart = (f) => `${DAYS[f.wd]} ${MONTHS[f.mo]} ${pad(f.d)} ${year(f.y)}`; const timePart = (f) => `${pad(f.h)}:${pad(f.mi)}:${pad(f.s)} ${gmt(f.o)}`; - define(proto, 'toString', function () { - const t = time(this); - if (Number.isNaN(t)) return 'Invalid Date'; - const f = fields(t); - return `${datePart(f)} ${timePart(f)}`; - }); - define(proto, 'toDateString', function () { - const t = time(this); - return Number.isNaN(t) ? 'Invalid Date' : datePart(fields(t)); - }); - define(proto, 'toTimeString', function () { - const t = time(this); - return Number.isNaN(t) ? 'Invalid Date' : timePart(fields(t)); - }); - const resolveZone = (options) => { const zone = options && options.timeZone; if (zone === undefined) return undefined; const canonical = canonicalZone(String(zone)); - if (canonical === undefined || canonical === null) throw new RangeError('Invalid time zone specified: ' + zone); - return canonical; + return canonical == null ? undefined : canonical; }; const localized = (t, zone, kind) => { if (Number.isNaN(t)) return 'Invalid Date'; @@ -188,28 +138,50 @@ if (kind === 'time') return clock; return `${date}, ${clock}`; }; - for (const [name, kind] of [['toLocaleString', 'both'], ['toLocaleDateString', 'date'], ['toLocaleTimeString', 'time']]) { - define(proto, name, function (locales, options) { - return localized(time(this), resolveZone(options), kind); - }); - } - - if (typeof globalThis.Intl === 'undefined') { - function DateTimeFormat(locales, options) { - if (!new.target) return new DateTimeFormat(locales, options); - define(this, '__zone', resolveZone(options)); - } - define(DateTimeFormat.prototype, 'resolvedOptions', function () { - return { - locale: 'en-US', - calendar: 'gregory', - numberingSystem: 'latn', - timeZone: this.__zone === undefined ? zoneOf() : this.__zone, - }; - }); - const Intl = {}; - define(Intl, 'DateTimeFormat', DateTimeFormat); - define(globalThis, 'Intl', Intl); + const methods = { + getFullYear() { return field(this, 'y'); }, + getMonth() { return field(this, 'mo'); }, + getDate() { return field(this, 'd'); }, + getDay() { return field(this, 'wd'); }, + getHours() { return field(this, 'h'); }, + getMinutes() { return field(this, 'mi'); }, + getSeconds() { return field(this, 's'); }, + getMilliseconds() { return field(this, 'ms'); }, + getTimezoneOffset() { + const t = time(this); + return Number.isNaN(t) ? NaN : -offset(t); + }, + getYear() { + const y = this.getFullYear(); + return Number.isNaN(y) ? NaN : y - 1900; + }, + setFullYear(year, month, date) { return set(this, 0, 3, arguments); }, + setMonth(month, date) { return set(this, 1, 2, arguments); }, + setDate(date) { return set(this, 2, 1, arguments); }, + setHours(hours, minutes, seconds, ms) { return set(this, 3, 4, arguments); }, + setMinutes(minutes, seconds, ms) { return set(this, 4, 3, arguments); }, + setSeconds(seconds, ms) { return set(this, 5, 2, arguments); }, + setMilliseconds(ms) { return set(this, 6, 1, arguments); }, + toString() { + const t = time(this); + if (Number.isNaN(t)) return 'Invalid Date'; + const f = fields(t); + return `${datePart(f)} ${timePart(f)}`; + }, + toDateString() { + const t = time(this); + return Number.isNaN(t) ? 'Invalid Date' : datePart(fields(t)); + }, + toTimeString() { + const t = time(this); + return Number.isNaN(t) ? 'Invalid Date' : timePart(fields(t)); + }, + toLocaleString() { return localized(time(this), resolveZone(arguments[1]), 'both'); }, + toLocaleDateString() { return localized(time(this), resolveZone(arguments[1]), 'date'); }, + toLocaleTimeString() { return localized(time(this), resolveZone(arguments[1]), 'time'); }, + }; + for (const name of Object.keys(methods)) { + if (name in proto) proto[name] = methods[name]; } - globalThis.__zenPinned = true; -})(); + return { construct, parse }; +}; diff --git a/core/engine/src/compiled/pinning.rs b/core/engine/src/compiled/pinning.rs index 8e019175..0036bf89 100644 --- a/core/engine/src/compiled/pinning.rs +++ b/core/engine/src/compiled/pinning.rs @@ -1,8 +1,14 @@ use crate::engine::EvaluationOptions; use chrono::{DateTime, Duration, LocalResult, Offset, TimeZone}; +use rquickjs::loader::bundle::{Bundle, ScaBundleData}; +use rquickjs::loader::Loader; use rquickjs::prelude::Func; +use rquickjs::promise::PromiseState; +use rquickjs::{Module, WriteOptions}; use std::cell::RefCell; +use std::collections::HashMap; use std::rc::Rc; +use std::sync::OnceLock; use zen_expression::context::{ location, parse_timezone, system_now, system_timezone, EvaluationContext, Site, Timezone, }; @@ -125,7 +131,23 @@ impl Located { } } -const PIN_JS: &str = include_str!("pinning.js"); +const PIN_ENTRY: (&str, &str) = ("zen:pinning", include_str!("pinning.entry.js")); +const PIN_DATE: (&str, &str) = ("zen:pinning/date", include_str!("pinning.js")); + +fn canonical_zone(name: &str) -> Option { + static ZONES: OnceLock> = OnceLock::new(); + parse_timezone(name).or_else(|| { + ZONES + .get_or_init(|| { + chrono_tz::TZ_VARIANTS + .iter() + .map(|zone| (zone.name().to_ascii_lowercase(), *zone)) + .collect() + }) + .get(&name.to_ascii_lowercase()) + .copied() + }) +} #[derive(Debug, Clone, Default)] pub(crate) struct JsSlot(Rc>>); @@ -177,7 +199,7 @@ impl JsSlot { fn zone(&self, name: Option) -> Option { match name { - Some(name) => parse_timezone(&name), + Some(name) => canonical_zone(&name), None => Some(self.timezone()), } } @@ -230,34 +252,88 @@ impl JsSlot { Some(local - offset.local_minus_utc() as f64 * 1000.0) } - pub(crate) fn install(&self, ctx: &rquickjs::Ctx<'_>) -> rquickjs::Result<()> { - let globals = ctx.globals(); - if globals.get::<_, bool>("__zenPinned").unwrap_or(false) { - return Ok(()); + fn bundle() -> Option>> { + static CODE: OnceLock; 2]>> = OnceLock::new(); + static BUNDLE: OnceLock> = OnceLock::new(); + BUNDLE + .get_or_init(|| { + let code = CODE.get_or_init(|| { + let runtime = rquickjs::Runtime::new().ok()?; + let context = rquickjs::Context::full(&runtime).ok()?; + context.with(|ctx| { + let compile = |name: &str, source: &str| { + Module::declare(ctx.clone(), name, source) + .and_then(|module| { + module.write(WriteOptions { + strip_source: true, + ..Default::default() + }) + }) + .ok() + }; + Some([ + compile(PIN_ENTRY.0, PIN_ENTRY.1)?, + compile(PIN_DATE.0, PIN_DATE.1)?, + ]) + }) + }); + code.as_ref().map(|[entry, date]| { + [ + (PIN_ENTRY.0, entry.as_slice()), + (PIN_DATE.0, date.as_slice()), + ] + }) + }) + .as_ref() + .map(|entries| Bundle(entries.as_slice())) + } + + fn evaluate<'js>( + ctx: &rquickjs::Ctx<'js>, + (name, source): (&str, &str), + ) -> rquickjs::Result> { + let declared = match Self::bundle() { + Some(mut bundle) => bundle.load(ctx, name)?, + None => Module::declare(ctx.clone(), name, source)?, + }; + let (module, promise) = declared.eval()?; + if promise.state() != PromiseState::Resolved { + return Err(rquickjs::Error::new_loading(name)); } - let slot = self.clone(); - globals.set("__zenNow", Func::from(move || slot.now()))?; - let slot = self.clone(); - globals.set("__zenRandom", Func::from(move || slot.random()))?; - let slot = self.clone(); - globals.set( - "__zenOffset", - Func::from(move |ms: f64, zone: Option| slot.offset(ms, zone)), - )?; - let slot = self.clone(); - globals.set( - "__zenUtc", - Func::from(move |local: f64, zone: Option| slot.utc(local, zone)), - )?; - let slot = self.clone(); - globals.set( - "__zenZone", - Func::from(move || slot.timezone().name().to_string()), - )?; - globals.set( - "__zenCanonicalZone", - Func::from(|name: String| parse_timezone(&name).map(|zone| zone.name().to_string())), - )?; - ctx.eval::<(), _>(PIN_JS) + module.get("default") + } + + pub(crate) fn install<'js>(&self, ctx: &rquickjs::Ctx<'js>) -> rquickjs::Result<()> { + let entry = Self::evaluate(ctx, PIN_ENTRY)?; + let (now, random, slot) = (self.clone(), self.clone(), self.clone()); + entry.call(( + Func::from(move || now.now()), + Func::from(move || random.random()), + Func::from( + move |ctx: rquickjs::Ctx<'js>, + native: rquickjs::Value<'js>, + pinned: rquickjs::Value<'js>| { + slot.load(&ctx, native, pinned) + }, + ), + )) + } + + fn load<'js>( + &self, + ctx: &rquickjs::Ctx<'js>, + native: rquickjs::Value<'js>, + pinned: rquickjs::Value<'js>, + ) -> rquickjs::Result> { + let date = Self::evaluate(ctx, PIN_DATE)?; + let (now, offset, utc) = (self.clone(), self.clone(), self.clone()); + date.call(( + native, + pinned, + Func::from(move || now.now()), + Func::from(move |ms: f64, zone: Option| offset.offset(ms, zone)), + Func::from(move |local: f64, zone: Option| utc.utc(local, zone)), + Func::from(|name: String| canonical_zone(&name).map(|zone| zone.name().to_string())), + )) } } diff --git a/core/engine/tests/concurrent.rs b/core/engine/tests/concurrent.rs index e1bdfed7..b82dd3ce 100644 --- a/core/engine/tests/concurrent.rs +++ b/core/engine/tests/concurrent.rs @@ -64,7 +64,7 @@ fn main_graph() -> Value { "key": "child", "transformAttributes": {"executionMode": "single", "passThrough": true} }}, {"id": "fn", "name": "fn", "type": "functionNode", "content": { - "source": "import zen from 'zen';\nexport const handler = async (input) => {\n const before = Math.random();\n const nested = await zen.evaluate('child', input);\n const local = new Date().toString();\n const formatted = new Date().toLocaleString();\n const intl = Intl.DateTimeFormat().resolvedOptions();\n return { ...input, before, nested: nested.result, now: Date.now(), after: Math.random(), local, formatted, jsZone: intl.timeZone, };\n};" + "source": "import zen from 'zen';\nexport const handler = async (input) => {\n const before = Math.random();\n const nested = await zen.evaluate('child', input);\n const local = new Date().toString();\n const formatted = new Date().toLocaleString();\n return { ...input, before, nested: nested.result, now: Date.now(), after: Math.random(), local, formatted, };\n};" }}, {"id": "out", "name": "out", "type": "outputNode"} ], @@ -189,7 +189,6 @@ fn sees_its_own_clock(value: &Value, pin: Pin3) { assert_eq!(value["zone"], json!(pin.zone), "{value}"); assert_eq!(value["cz"], json!(pin.zone), "{value}"); assert_eq!(value["nested"]["cz"], json!(pin.zone), "{value}"); - assert_eq!(value["jsZone"], json!(pin.zone), "{value}"); assert_eq!(value["local"], json!(pin.local), "{value}"); assert_eq!(value["formatted"], json!(pin.formatted), "{value}"); } diff --git a/core/engine/tests/function_limits.rs b/core/engine/tests/function_limits.rs new file mode 100644 index 00000000..d5d5d7de --- /dev/null +++ b/core/engine/tests/function_limits.rs @@ -0,0 +1,201 @@ +use serde_json::{json, Value}; +use std::sync::atomic::Ordering; +use std::sync::Arc; +use std::time::{Duration, Instant}; +use zen_engine::model::DecisionContent; +use zen_engine::{DecisionEngine, EngineVersion, EvaluationOptions, Variable, ZEN_CONFIG}; + +const TIMEOUT_MILLIS: u64 = 150; + +fn graph(source: &str) -> Arc { + Arc::new( + serde_json::from_value(json!({ + "nodes": [ + {"id": "in", "name": "in", "type": "inputNode"}, + {"id": "node", "name": "node", "type": "functionNode", "content": {"source": source}}, + {"id": "out", "name": "out", "type": "outputNode"} + ], + "edges": [ + {"id": "e1", "sourceId": "in", "targetId": "node", "type": "edge"}, + {"id": "e2", "sourceId": "node", "targetId": "out", "type": "edge"} + ] + })) + .unwrap(), + ) +} + +fn outcomes(source: &str) -> Vec<(Result, Duration)> { + ZEN_CONFIG + .function_timeout_millis + .store(TIMEOUT_MILLIS, Ordering::Relaxed); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let engine = DecisionEngine::default().with_version(EngineVersion::V2); + let mut decision = engine.create_decision(graph(source)).unwrap(); + let input = || Variable::from(json!({"x": 1})); + let timed = |run: &dyn Fn() -> Result| { + let start = Instant::now(); + let result = run(); + (result, start.elapsed()) + }; + let shown = + |result: Result>| { + result + .map(|response| response.result.to_value()) + .map_err(|error| serde_json::to_string(&error).unwrap()) + }; + let mut found = Vec::new(); + for _ in 0..2 { + found.push(timed(&|| { + shown(runtime.block_on(decision.evaluate(input()))) + })); + } + decision.compile(); + found.push(timed(&|| { + shown(runtime.block_on(decision.evaluate(input()))) + })); + let start = Instant::now(); + let rows = vec![input(), input(), input()]; + let batch = runtime.block_on(decision.evaluate_batch(&rows, EvaluationOptions::default())); + let elapsed = start.elapsed(); + found.extend(batch.into_iter().map(|row| (shown(row), elapsed))); + found +} + +fn fails_with(source: &str, message: &str, rows_in_batch: u32) { + let limit = Duration::from_millis(TIMEOUT_MILLIS); + for (at, (result, elapsed)) in outcomes(source).into_iter().enumerate() { + let error = result.expect_err(&format!("{source} {at} should fail")); + assert!(error.contains(message), "{source} {at}: {error}"); + assert!(error.contains("node"), "{source} {at}: {error}"); + let bound = limit * rows_in_batch.max(1) * 10 + Duration::from_secs(2); + assert!(elapsed < bound, "{source} {at} took {elapsed:?}"); + } +} + +#[test] +fn a_promise_that_never_settles_times_out() { + fails_with( + "export const handler = async (input) => new Promise(() => {});", + "interrupted", + 3, + ); + fails_with( + "export const handler = (input) => new Promise(() => {});", + "interrupted", + 3, + ); + fails_with( + "export const handler = async (input) => { await new Promise(() => {}); return { done: true }; };", + "interrupted", + 3, + ); +} + +#[test] +fn a_module_whose_top_level_await_never_settles_times_out() { + fails_with( + "await new Promise(() => {});\nexport const handler = async (input) => ({ done: true });", + "interrupted", + 3, + ); +} + +#[test] +fn a_promise_that_spins_on_microtasks_times_out() { + fails_with( + "export const handler = async (input) => { while (true) { await null; } };", + "interrupted", + 3, + ); +} + +#[test] +fn a_timed_out_row_takes_at_least_the_function_timeout() { + let limit = Duration::from_millis(TIMEOUT_MILLIS); + for (result, elapsed) in + outcomes("export const handler = async (input) => new Promise(() => {});") + { + assert!(result.is_err()); + assert!(elapsed >= limit, "{elapsed:?}"); + } +} + +#[test] +fn a_promise_that_settles_later_still_resolves() { + for (result, _) in outcomes( + "export const handler = async (input) => { await Promise.resolve(); const v = await new Promise((resolve) => Promise.resolve().then(() => resolve(input.x + 1))); return { v }; };", + ) { + assert_eq!(result, Ok(json!({"v": 2}))); + } +} + +#[test] +fn a_cyclic_result_is_an_error() { + fails_with( + "export const handler = async (input) => { const o = {}; o.self = o; return o; };", + "cyclic value", + 1, + ); + fails_with( + "export const handler = (input) => { const a = [1]; a.push({ a }); return { a }; };", + "cyclic value", + 1, + ); + fails_with( + "export const handler = async (input) => { const o = { x: 1 }; o.later = Promise.resolve(o); return o; };", + "cyclic value", + 1, + ); +} + +#[test] +fn a_shared_but_acyclic_result_is_not_an_error() { + for (result, _) in outcomes( + "export const handler = async (input) => { const s = { a: 1 }; const list = [s, s]; return { x: s, y: s, list, nested: { list } }; };", + ) { + assert_eq!( + result, + Ok(json!({ + "x": {"a": 1}, "y": {"a": 1}, "list": [{"a": 1}, {"a": 1}], + "nested": {"list": [{"a": 1}, {"a": 1}]} + })) + ); + } +} + +#[test] +fn a_host_call_longer_than_the_timeout_still_resolves_as_on_version_1() { + let source = "export const handler = async (input) => { await console.sleep(400); return { v: input.x + 1 }; };"; + for (result, elapsed) in outcomes(source) { + assert_eq!(result, Ok(json!({"v": 2}))); + assert!( + elapsed >= Duration::from_millis(TIMEOUT_MILLIS * 2), + "{elapsed:?}" + ); + } + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let old = DecisionEngine::default() + .with_version(EngineVersion::V1) + .create_decision(graph(source)) + .unwrap(); + let result = runtime + .block_on(old.evaluate(Variable::from(json!({"x": 1})))) + .map(|response| response.result.to_value()) + .map_err(|error| error.to_string()); + assert_eq!(result, Ok(json!({"v": 2}))); +} + +#[test] +fn a_promise_left_pending_after_a_host_call_times_out() { + fails_with( + "export const handler = async (input) => { await console.sleep(10); return new Promise(() => {}); };", + "interrupted", + 3, + ); +} diff --git a/core/engine/tests/function_parity.rs b/core/engine/tests/function_parity.rs new file mode 100644 index 00000000..98b4f68e --- /dev/null +++ b/core/engine/tests/function_parity.rs @@ -0,0 +1,180 @@ +use serde_json::{json, Value}; +use std::sync::Arc; +use zen_engine::model::DecisionContent; +use zen_engine::{DecisionEngine, EngineVersion, EvaluationOptions, Variable}; + +const SNIPPETS: &[&str] = &[ + "typeof Intl", + "typeof globalThis.Intl", + "'Intl' in globalThis", + "Object.keys(globalThis)", + "JSON.stringify(Object.getOwnPropertyNames(globalThis))", + "(() => { const names = []; for (const name in globalThis) names.push(name); return names; })()", + "Object.getOwnPropertyNames(globalThis).filter((name) => name.startsWith('__'))", + "Object.getOwnPropertySymbols(globalThis).length", + "Date.name", + "Date.length", + "Date.prototype.constructor === Date", + "Object.prototype.toString.call(new Date())", + "new Date() instanceof Date", + "new Date(0) instanceof Date", + "String(Date)", + "Function.prototype.toString.call(Date)", + "Object.getOwnPropertyNames(Date)", + "Object.keys(Date)", + "Object.keys(Date.prototype)", + "[Date.now.name, Date.now.length, Date.parse.name, Date.parse.length, Date.UTC.name, Date.UTC.length]", + "[String(Date.now), String(Date.parse), String(Date.UTC)]", + "[Math.random.name, Math.random.length, String(Math.random), Object.keys(Math)]", + "Object.getOwnPropertyNames(Math)", + "(() => { const d = Object.getOwnPropertyDescriptor(Date, 'prototype'); return [d.writable, d.enumerable, d.configurable]; })()", + "(() => { const d = Object.getOwnPropertyDescriptor(globalThis, 'Date'); return [d.writable, d.enumerable, d.configurable, 'value' in d]; })()", + "(() => { const d = Object.getOwnPropertyDescriptor(Math, 'random'); return [d.writable, d.enumerable, d.configurable]; })()", + "(() => { const d = Object.getOwnPropertyDescriptor(Date, 'now'); return [d.writable, d.enumerable, d.configurable]; })()", + "(() => { const d = Object.getOwnPropertyDescriptor(Date.prototype, 'getHours'); return [d.writable, d.enumerable, d.configurable]; })()", + "Object.getOwnPropertyNames(Date.prototype)", + "Object.getOwnPropertyNames(Date.prototype).filter((n) => typeof Date.prototype[n] === 'function').map((n) => [n, Date.prototype[n].name, Date.prototype[n].length, String(Date.prototype[n]), 'prototype' in Date.prototype[n]])", + "(() => { new Date(0); return Object.getOwnPropertyNames(Date.prototype).filter((n) => typeof Date.prototype[n] === 'function').map((n) => [n, Date.prototype[n].name, Date.prototype[n].length, String(Date.prototype[n]), 'prototype' in Date.prototype[n]]); })()", + "(() => { Date.parse('2020'); const d = Object.getOwnPropertyDescriptor(Date.prototype, 'setHours'); return [d.writable, d.enumerable, d.configurable, Object.getOwnPropertyNames(d.value)]; })()", + "(() => { new Date(0); return [Object.keys(Date.prototype), Object.getOwnPropertyNames(Date), Object.keys(Date)]; })()", + "(() => { new Date(0); try { new (Date.prototype.getHours)(); return 'constructed'; } catch (e) { return e.constructor.name; } })()", + "(() => { new Date(0); try { return Date.prototype.getHours.call({}); } catch (e) { return e.constructor.name; } })()", + "(() => { try { new (Date.prototype.getHours)(); return 'constructed'; } catch (e) { return e.constructor.name; } })()", + "(() => { try { new Date.now(); return 'constructed'; } catch (e) { return e.constructor.name; } })()", + "(() => { try { return Date.prototype.getHours.call({}); } catch (e) { return e.constructor.name; } })()", + "Object.getOwnPropertyNames(Date.prototype.getHours)", + "Object.getOwnPropertyNames(Date.now)", + "typeof Date()", + "Date().length > 20", + "Date(2020, 1) === Date()", + "(() => { class Later extends Date {} const d = new Later(0); return [d instanceof Later, d instanceof Date, d.getTime(), Object.prototype.toString.call(d)]; })()", + "new Date(2020, 0, 1).getTime() === new Date(2020, 0, 1, 0, 0, 0, 0).getTime()", + "new Date(2020, 5, 15, 10, 30).toString()", + "new Date(2020, 5, 15, 10, 30).toLocaleString()", + "new Date(1700000000000).toLocaleDateString()", + "new Date(1700000000000).toLocaleTimeString()", + "typeof new Date(0).toLocaleString('en-US', { timeZone: 'utc' })", + "typeof new Date(0).toLocaleString('en-US', { timeZone: 'UTC' })", + "typeof new Date(0).toLocaleString('en-US', { timeZone: 'Utc' })", + "typeof new Date(0).toLocaleDateString('en-US', { timeZone: 'europe/berlin' })", + "typeof new Date(0).toLocaleTimeString('en-US', { timeZone: 'AMERICA/NEW_YORK' })", + "typeof new Date(0).toLocaleString(undefined, { timeZone: 'Mars/Base' })", + "typeof new Date(0).toLocaleString(undefined, { timeZone: 42 })", + "new Date('2020-02-03T04:05:06').getHours()", + "Date.parse('2020-02-03T04:05:06Z')", + "new Date(NaN).toString()", + "new Date(8.64e15 + 1).getTime()", + "[new Date(0).setHours(), new Date(NaN).setFullYear(2020) > 0, new Date(NaN).setMonth(1)]", + "typeof Math.random()", + "Math.random() >= 0 && Math.random() < 1", + "typeof Date.now()", +]; + +#[derive(Clone, Copy, Debug)] +enum Path { + Repeated, + Compiled, + Batch, +} + +fn graph(content: Value) -> Value { + json!({ + "nodes": [ + {"id": "in", "name": "in", "type": "inputNode"}, + {"id": "node", "name": "node", "type": "functionNode", "content": content}, + {"id": "out", "name": "out", "type": "outputNode"} + ], + "edges": [ + {"id": "e1", "sourceId": "in", "targetId": "node", "type": "edge"}, + {"id": "e2", "sourceId": "node", "targetId": "out", "type": "edge"} + ] + }) +} + +fn legacy(body: &str) -> Value { + graph(json!(format!( + "const handler = (input) => ({{ v: {body} }})" + ))) +} + +fn modern(body: &str) -> Value { + graph(json!({"source": format!("export const handler = async (input) => ({{ v: {body} }});")})) +} + +fn shown(result: Result) -> Value { + result.unwrap_or_else(|error| json!({ "error": error })) +} + +fn outcomes(version: EngineVersion, path: Path, graph: &Value) -> Vec { + let content: DecisionContent = serde_json::from_value(graph.clone()).unwrap(); + let engine = DecisionEngine::default().with_version(version); + let mut decision = engine.create_decision(Arc::new(content)).unwrap(); + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let one = |decision: &zen_engine::Decision| { + shown( + runtime + .block_on(decision.evaluate_with_opts( + Variable::from(json!({"x": 1})), + EvaluationOptions::default(), + )) + .map(|response| response.result.to_value()) + .map_err(|error| error.to_string()), + ) + }; + match path { + Path::Repeated => (0..3).map(|_| one(&decision)).collect(), + Path::Compiled => { + decision.compile(); + (0..2).map(|_| one(&decision)).collect() + } + Path::Batch => { + let rows = vec![Variable::from(json!({"x": 1})); 3]; + runtime + .block_on(decision.evaluate_batch(&rows, EvaluationOptions::default())) + .into_iter() + .map(|row| { + shown( + row.map(|response| response.result.to_value()) + .map_err(|error| error.to_string()), + ) + }) + .collect() + } + } +} + +fn differences(build: fn(&str) -> Value) -> Vec { + let mut found = Vec::new(); + for body in SNIPPETS { + let graph = build(body); + let want = outcomes(EngineVersion::V1, Path::Repeated, &graph).remove(0); + for path in [Path::Repeated, Path::Compiled, Path::Batch] { + for (call, got) in outcomes(EngineVersion::V2, path, &graph) + .into_iter() + .enumerate() + { + if got != want { + found.push(format!( + "{body}\n {path:?} call {call}\n v1: {want}\n v2: {got}" + )); + } + } + } + } + found +} + +#[test] +fn legacy_function_nodes_see_the_same_globals_and_dates_on_both_versions() { + let found = differences(legacy); + assert!(found.is_empty(), "{}", found.join("\n")); +} + +#[test] +fn function_nodes_see_the_same_globals_and_dates_on_both_versions() { + let found = differences(modern); + assert!(found.is_empty(), "{}", found.join("\n")); +} diff --git a/core/engine/tests/pinned.rs b/core/engine/tests/pinned.rs index 6df5c087..5323ca2b 100644 --- a/core/engine/tests/pinned.rs +++ b/core/engine/tests/pinned.rs @@ -128,7 +128,7 @@ fn real_clock(millis: &Value) -> bool { fn zoned_function() -> Decision { graph(json!({ "id": "calc", "name": "calc", "type": "functionNode", - "content": {"source": "export const handler = async (input) => { const d = new Date(Date.UTC(2026, 0, 15, 12, 34, 56)); const o = Intl.DateTimeFormat().resolvedOptions(); return { text: d.toString(), hours: d.getHours(), offset: d.getTimezoneOffset(), date: d.toDateString(), time: d.toTimeString(), local: d.toLocaleString(), localDate: d.toLocaleDateString(), localTime: d.toLocaleTimeString(), utc: d.toLocaleString(undefined, { timeZone: 'UTC' }), tagged: d.toLocaleDateString('de-DE'), zone: o.timeZone, midnight: new Date(2026, 0, 15).getTime(), parsed: new Date('2026-01-15T10:00:00').getTime(), iso: new Date('2026-01-15').getTime(), set: (() => { const x = new Date(Date.UTC(2026, 0, 15, 12)); x.setHours(0, 0, 0, 0); return x.toISOString(); })(), now: new Date().toString(), call: Date(), r: Math.random() }; }"} + "content": {"source": "export const handler = async (input) => { const d = new Date(Date.UTC(2026, 0, 15, 12, 34, 56)); return { text: d.toString(), hours: d.getHours(), offset: d.getTimezoneOffset(), date: d.toDateString(), time: d.toTimeString(), local: d.toLocaleString(), localDate: d.toLocaleDateString(), localTime: d.toLocaleTimeString(), utc: d.toLocaleString(undefined, { timeZone: 'UTC' }), tagged: d.toLocaleDateString('de-DE'), intl: typeof Intl, lower: d.toLocaleString(undefined, { timeZone: 'utc' }), unknown: d.toLocaleTimeString(undefined, { timeZone: 'Mars/Base' }), midnight: new Date(2026, 0, 15).getTime(), parsed: new Date('2026-01-15T10:00:00').getTime(), iso: new Date('2026-01-15').getTime(), set: (() => { const x = new Date(Date.UTC(2026, 0, 15, 12)); x.setHours(0, 0, 0, 0); return x.toISOString(); })(), now: new Date().toString(), call: Date(), r: Math.random() }; }"} })) } @@ -165,8 +165,11 @@ fn function_nodes_read_the_zone_of_the_context() { assert_eq!(tokyo["localDate"], json!("01/15/2026")); assert_eq!(tokyo["localTime"], json!("09:34:56 PM")); assert_eq!(tokyo["utc"], json!("01/15/2026, 12:34:56 PM")); - assert_eq!(berlin["zone"], json!("Europe/Berlin")); - assert_eq!(tokyo["zone"], json!("Asia/Tokyo")); + assert_eq!(berlin["intl"], json!("undefined")); + assert_eq!(berlin["lower"], berlin["utc"]); + assert_eq!(tokyo["lower"], tokyo["utc"]); + assert_eq!(berlin["unknown"], berlin["localTime"]); + assert_eq!(tokyo["unknown"], tokyo["localTime"]); assert_eq!(berlin["midnight"], json!(1_768_431_600_000i64)); assert_eq!(tokyo["midnight"], json!(1_768_402_800_000i64)); assert_eq!(berlin["parsed"], json!(1_768_467_600_000i64)); @@ -187,7 +190,7 @@ fn function_nodes_read_the_zone_of_the_context() { fn v1_function_nodes_read_the_zone_of_the_context() { let d = graph(json!({ "id": "calc", "name": "calc", "type": "functionNode", - "content": "const handler = (input) => ({ text: new Date(Date.UTC(2026, 0, 15, 12)).toString(), local: new Date(Date.UTC(2026, 0, 15, 12)).toLocaleDateString(), zone: Intl.DateTimeFormat().resolvedOptions().timeZone })" + "content": "const handler = (input) => ({ text: new Date(Date.UTC(2026, 0, 15, 12)).toString(), local: new Date(Date.UTC(2026, 0, 15, 12)).toLocaleDateString(), offset: new Date(Date.UTC(2026, 0, 15, 12)).getTimezoneOffset() })" })); let (berlin, _) = evaluated(&d, 1, zoned("Europe/Berlin")); let (york, _) = evaluated(&d, 1, zoned("America/New_York")); @@ -195,7 +198,7 @@ fn v1_function_nodes_read_the_zone_of_the_context() { assert_eq!(york["text"], json!("Thu Jan 15 2026 07:00:00 GMT-0500")); assert_eq!(berlin["local"], json!("01/15/2026")); assert_eq!(york["local"], json!("01/15/2026")); - assert_eq!(york["zone"], json!("America/New_York")); + assert_eq!(york["offset"], json!(300)); } #[test] @@ -226,10 +229,13 @@ fn the_interpreted_engine_pins_only_the_expression_clock() { assert_ne!((&a["r"], &a["q"]), (&pinned["r"], &pinned["q"])); } } - let r = block(zone.evaluate_with_opts(input(1), zoned("Asia/Tokyo"))); - assert!( - r.is_err(), - "the interpreted host has no Intl and no zone shim" + let r = block(zone.evaluate_with_opts(input(1), zoned("Asia/Tokyo"))).unwrap(); + let r = serde_json::to_value(&r.result).unwrap(); + assert_eq!(r["intl"], json!("undefined"), "{r}"); + assert_ne!( + r["now"], + json!("Wed Nov 04 2026 18:30:00 GMT+0900"), + "the interpreted host has no zone shim" ); let engine = policy_engine().interpreted(); let run = |o: EvaluationOptions| { diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 74332760..4b7a021f 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -1231,15 +1231,3 @@ fn version_2_keeps_alias_writes_that_cannot_cycle() { json!({"a": {"k": 1, "c": {"j": [0]}, "e": 1}}), ); } - -#[test] -#[ignore = "the version 2 JS runtime converts a cyclic result without a guard and never returns"] -fn version_2_rejects_a_script_returning_a_cyclic_object() { - let graph = graph(json!({ - "id": "node", "name": "node", "type": "functionNode", - "content": {"source": "export const handler = async (input) => { if (input.x !== 1) return input; const o = {}; o.self = o; return o; };"} - })); - let good = json!({"x": 0}); - let bad = json!({"x": 1}); - cyclic_rows_fail_alone_on_version_2(&graph, &good, &bad, "self"); -} From ba579f817f215f3b881424df6e1d793caab5e657 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 14:17:24 +0100 Subject: [PATCH 26/32] fix(engine): leave version 1 table indexes as released and give version 2 its own --- core/engine/src/compiled/content.rs | 4 ++- core/engine/src/model/decision_content.rs | 3 ++- core/engine/tests/version_parity.rs | 33 +++++++++++++++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/core/engine/src/compiled/content.rs b/core/engine/src/compiled/content.rs index 995b8b0c..5c1edf2d 100644 --- a/core/engine/src/compiled/content.rs +++ b/core/engine/src/compiled/content.rs @@ -31,8 +31,10 @@ impl DerefMut for Content { impl Content { pub(crate) fn of(graph: &GraphContent) -> Self { + let mut graph = graph.clone(); + graph.dt_indexes = None; Self { - graph: graph.clone(), + graph, compiled_plan: None, schema_failures: None, } diff --git a/core/engine/src/model/decision_content.rs b/core/engine/src/model/decision_content.rs index 05408870..b920ca2f 100644 --- a/core/engine/src/model/decision_content.rs +++ b/core/engine/src/model/decision_content.rs @@ -212,7 +212,8 @@ impl GraphContent { .iter() .filter_map(|node| match &node.kind { DecisionNodeKind::DecisionTableNode { content } => { - TableIndex::graph(content).map(|index| (node.id.clone(), index)) + TableIndex::build(&content.inputs, &content.rules) + .map(|index| (node.id.clone(), index)) } _ => None, }) diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 4b7a021f..d0001ead 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -250,6 +250,17 @@ fn wide_table(policy: &str, inputs: Value, rules: Vec) -> Value { ) } +fn same_as_version_1_without_compile(graph: &Value, input: &Value, want: Value) { + for path in [Path::Repeated, Path::Compiled, Path::Batch] { + for got in outcomes(EngineVersion::V2, path, graph, input) { + assert_eq!(got, want, "V2 {path:?}"); + } + } + for got in outcomes(EngineVersion::V1, Path::Repeated, graph, input) { + assert_eq!(got, want, "V1 without compile"); + } +} + #[test] fn a_table_cell_reads_the_last_tested_value_however_many_rules_there_are() { for padding in [0, 3, 7, 20] { @@ -259,13 +270,13 @@ fn a_table_cell_reads_the_last_tested_value_however_many_rules_there_are() { json!({"_id": format!("p{at}"), "i0": format!("\"q{at}\""), "o0": at.to_string()}), ); } - same_on_every_path( + same_as_version_1_without_compile( &wide_table("first", json!([{"id": "i0", "field": "s"}]), rules.clone()), &json!({"s": "x"}), json!({}), ); rules.rotate_left(1); - same_on_every_path( + same_as_version_1_without_compile( &wide_table("first", json!([{"id": "i0", "field": "s"}]), rules), &json!({"s": "x"}), match padding { @@ -276,6 +287,24 @@ fn a_table_cell_reads_the_last_tested_value_however_many_rules_there_are() { } } +#[test] +fn version_1_keeps_its_released_table_results_after_compile() { + let mut rules = vec![json!({"_id": "r0", "i0": "", "o0": "$"})]; + for at in 1..8 { + rules.push( + json!({"_id": format!("r{at}"), "i0": format!("'k{at}'"), "o0": format!("'{at}'")}), + ); + } + let graph = wide_table("first", json!([{"id": "i0", "field": "s"}]), rules); + let input = json!({"s": "x"}); + for got in outcomes(EngineVersion::V1, Path::Repeated, &graph, &input) { + assert_eq!(got, json!({})); + } + for got in outcomes(EngineVersion::V1, Path::Compiled, &graph, &input) { + assert_eq!(got, json!({"v": "x"})); + } +} + #[test] fn a_table_column_can_test_the_value_of_the_column_before_it() { let rules = vec![ From 97227a042bd89e131f03b6acd4603ed87fbe12fd Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 14:19:03 +0100 Subject: [PATCH 27/32] fix(engine): show the tested value under its key when a table reads the whole root --- core/engine/src/compiled/table/mod.rs | 15 +++++++ core/engine/tests/version_parity.rs | 58 +++++++++++++++++++++++++++ core/expression/src/lane/source.rs | 33 +++++++++++++++ 3 files changed, 106 insertions(+) diff --git a/core/engine/src/compiled/table/mod.rs b/core/engine/src/compiled/table/mod.rs index 75d93974..3ef25ac9 100644 --- a/core/engine/src/compiled/table/mod.rs +++ b/core/engine/src/compiled/table/mod.rs @@ -236,6 +236,15 @@ impl Table { if !strict && SourceInfo::reads_dollar(field) { return Err("table field reads `$`".into()); } + if !strict + && (SourceInfo::reads_whole_root(field, false) + || cells + .iter() + .flatten() + .any(|cell| SourceInfo::reads_whole_root(cell, true))) + { + return Err("table reads the whole root".into()); + } if strict && cells .iter() @@ -283,6 +292,9 @@ impl Table { if SourceInfo::reads_dollar(cell) { return Err("table cell without a field reads `$`".into()); } + if SourceInfo::reads_whole_root(cell, false) { + return Err("table reads the whole root".into()); + } match distinct.iter_mut().find(|(s, _, _)| s.as_ref() == *cell) { Some((_, _, bits)) => bit(bits, rule), None => { @@ -383,6 +395,9 @@ impl Table { if SourceInfo::reads_dollar(cell) { return Err("table output cell reads `$`".into()); } + if SourceInfo::reads_whole_root(cell, false) { + return Err("table reads the whole root".into()); + } let shadowed = !output.collect && written[at + 1..].iter().any(|(_, later, _)| { !later.collect && zen_types::path::DotPath::within(output.path, later.path) diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index d0001ead..17694720 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -1260,3 +1260,61 @@ fn version_2_keeps_alias_writes_that_cannot_cycle() { json!({"a": {"k": 1, "c": {"j": [0]}, "e": 1}}), ); } + +#[test] +fn a_table_reading_the_whole_root_sees_the_tested_value_under_its_key() { + let one = |policy: &str, output: &str| { + graph( + json!({"id": "node", "name": "node", "type": "decisionTableNode", "content": { + "hitPolicy": policy, + "inputs": [{"id": "i0", "field": "a"}, {"id": "i1", "field": "b"}], + "outputs": [{"id": "o0", "field": "out"}], + "rules": [ + {"_id": "r0", "i0": "> 5", "i1": "", "o0": "'big'"}, + {"_id": "r1", "i0": "> 0", "i1": "", "o0": output}, + {"_id": "r2", "i0": "", "i1": "", "o0": output} + ] + }}), + ) + }; + let input = json!({"a": 1, "b": "x"}); + same_on_every_path( + &one("first", "$root"), + &input, + json!({"out": {"$": 1, "a": 1, "b": "x"}}), + ); + same_on_every_path( + &one("first", "keys($root)"), + &input, + json!({"out": ["a", "b", "$nodes", "$"]}), + ); + same_on_every_path(&one("first", "$root.b"), &input, json!({"out": "x"})); + same_on_every_path( + &one("collect", "$root"), + &input, + json!([{"out": {"$": 1, "a": 1, "b": "x"}}, {"out": {"$": 1, "a": 1, "b": "x"}}]), + ); + let mut wide = vec![json!({"_id": "w0", "i0": "> 0", "o0": "$root"})]; + for at in 0..9 { + wide.push( + json!({"_id": format!("p{at}"), "i0": format!("{}", 100 + at), "o0": at.to_string()}), + ); + } + same_on_every_path( + &wide_table("first", json!([{"id": "i0", "field": "a"}]), wide), + &json!({"a": 1}), + json!({"v": {"$": 1, "a": 1}}), + ); + let cell = graph( + json!({"id": "node", "name": "node", "type": "decisionTableNode", "content": { + "hitPolicy": "first", + "inputs": [{"id": "i0", "field": "a"}], + "outputs": [{"id": "o0", "field": "out"}], + "rules": [ + {"_id": "r0", "i0": "len(keys($root)) == 3", "o0": "'three'"}, + {"_id": "r1", "i0": "", "o0": "'other'"} + ] + }}), + ); + same_on_every_path(&cell, &json!({"a": 1}), json!({"out": "three"})); +} diff --git a/core/expression/src/lane/source.rs b/core/expression/src/lane/source.rs index 43cf9fde..23295dba 100644 --- a/core/expression/src/lane/source.rs +++ b/core/expression/src/lane/source.rs @@ -40,6 +40,39 @@ impl SourceInfo { found.get() } + pub fn reads_whole_root(source: &str, unary: bool) -> bool { + if source.trim().is_empty() { + return false; + } + let bump = Bump::new(); + let mut lexer = Lexer::new(); + let Ok(tokens) = lexer.tokenize(&bump, source) else { + return true; + }; + let Ok(parser) = Parser::try_new(&tokens, &bump) else { + return true; + }; + let parsed = match unary { + true => parser.unary().parse(), + false => parser.standard().parse(), + }; + if parsed.error().is_err() { + return true; + } + let roots = Cell::new(0usize); + let fields = Cell::new(0usize); + let (roots_ref, fields_ref) = (&roots, &fields); + parsed.root.walk(move |node| match node { + Node::Root => roots_ref.set(roots_ref.get() + 1), + Node::Member { + node: Node::Root, + property: Node::String(key), + } if *key != "$" => fields_ref.set(fields_ref.get() + 1), + _ => {} + }); + roots.get() != fields.get() + } + pub fn scalar(source: &str) -> bool { if source.trim().is_empty() { return true; From 796aaf13e7d1e3aa0747e7b773bd26096cf4a246 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 14:44:55 +0100 Subject: [PATCH 28/32] fix(engine): copy values read through $ and leave written-back keys alone, as version 1 merges them --- core/engine/src/compiled/graph/plan/mod.rs | 2 +- .../src/compiled/graph/plan/run/lane.rs | 5 ++ core/engine/src/compiled/graph/state/exec.rs | 11 +++- core/engine/src/compiled/graph/state/host.rs | 27 ++++++++++ core/engine/src/compiled/graph/state/loops.rs | 8 ++- .../tests/spec/graph/36-loops-tables.json5 | 6 +-- core/engine/tests/typed_parity.rs | 42 +++++++++++++++ core/engine/tests/version_parity.rs | 52 +++++++++++++++++++ core/expression/src/lane/output.rs | 11 ++++ 9 files changed, 157 insertions(+), 7 deletions(-) diff --git a/core/engine/src/compiled/graph/plan/mod.rs b/core/engine/src/compiled/graph/plan/mod.rs index d6c9ee87..887a9de4 100644 --- a/core/engine/src/compiled/graph/plan/mod.rs +++ b/core/engine/src/compiled/graph/plan/mod.rs @@ -526,7 +526,7 @@ impl<'g> Builder<'g> { obj: None, fields: Vec::new(), }), - Resolved::Object(mut node) if node.leaf.is_none() => { + Resolved::Object(mut node) if node.leaf.is_none() && !source.contains('$') => { let obj = node.obj.unwrap_or(M::None); if obj != M::All { let null = match self diff --git a/core/engine/src/compiled/graph/plan/run/lane.rs b/core/engine/src/compiled/graph/plan/run/lane.rs index 3e95cd12..e62309bf 100644 --- a/core/engine/src/compiled/graph/plan/run/lane.rs +++ b/core/engine/src/compiled/graph/plan/run/lane.rs @@ -150,6 +150,11 @@ impl<'a> Run<'_, 'a> { .flat_map(|(at, id)| stages[*id as usize].iter().map(move |&stage| (at, stage))) .collect(); } + for (out, (_, source)) in outs.iter_mut().zip(entries.into_iter().flatten()) { + if source.contains('$') { + out.detach(); + } + } for (slot, out) in op.outs.iter().zip(outs.iter_mut()) { let array = Array::from_output(out); let leaf = match (uniform, &keyed) { diff --git a/core/engine/src/compiled/graph/state/exec.rs b/core/engine/src/compiled/graph/state/exec.rs index 65186d0c..9115bcc3 100644 --- a/core/engine/src/compiled/graph/state/exec.rs +++ b/core/engine/src/compiled/graph/state/exec.rs @@ -413,7 +413,15 @@ impl CompiledGraph { (Some(rebase), None, true) if !overlapping => { crate::compiled::census::Census::mark("layered"); Self::bound(lane, step, data, nodes, extra, rebase, |bound| { - Self::layered(runner, body, transform.pass_through, data, bound, None) + Self::layered( + runner, + body, + transform.pass_through, + data, + bound, + None, + rebase.is_none(), + ) }) } (Some(rebase), Some(path), true) if keyed && expression && !overlapping => { @@ -426,6 +434,7 @@ impl CompiledGraph { data, bound, Some(path), + false, ) }) } diff --git a/core/engine/src/compiled/graph/state/host.rs b/core/engine/src/compiled/graph/state/host.rs index fc81c770..ffc98b1c 100644 --- a/core/engine/src/compiled/graph/state/host.rs +++ b/core/engine/src/compiled/graph/state/host.rs @@ -156,6 +156,7 @@ impl CompiledGraph { input: &Data<'a>, bound: &Bound, prefix: Option<&Arc>, + direct: bool, ) -> (Data<'a>, Vec<(usize, String)>) { let rows = input.rows.clone(); let count = rows.len(); @@ -186,6 +187,11 @@ impl CompiledGraph { .map(|key| Arc::from(format!("{prefix}.{key}"))) .collect(), }; + for (out, (_, source)) in outs.iter_mut().zip(entries.iter()) { + if source.contains('$') { + out.detach(); + } + } let leaves: Vec = outs .iter_mut() .map(|out| Leaf::typed(Array::from_output(out))) @@ -195,6 +201,27 @@ impl CompiledGraph { probe.record_results(keys, &leaves); } } + let kept: Vec = entries + .iter() + .map(|(key, source)| !(pass_through && direct && source.trim() == key.as_ref())) + .collect(); + let (keys, leaves) = match kept.iter().all(|keep| *keep) { + true => (keys, leaves), + false => { + let mut keep = kept.iter(); + let keys: Arc<[Arc]> = keys + .iter() + .filter(|_| keep.next().copied().unwrap_or(true)) + .cloned() + .collect(); + let mut keep = kept.iter(); + let leaves = leaves + .into_iter() + .filter(|_| keep.next().copied().unwrap_or(true)) + .collect(); + (keys, leaves) + } + }; let layer = Layer::new(keys, leaves, None); let data = match pass_through { true => input.layered(layer), diff --git a/core/engine/src/compiled/graph/state/loops.rs b/core/engine/src/compiled/graph/state/loops.rs index 2baa4f8c..8ffaf67a 100644 --- a/core/engine/src/compiled/graph/state/loops.rs +++ b/core/engine/src/compiled/graph/state/loops.rs @@ -364,7 +364,7 @@ impl CompiledGraph { data: &Data<'a>, ) -> (Data<'a>, Vec<(usize, String)>) { Self::bound(lane, step, data, &[], &[], None, |bound| { - Self::layered(runner, body, false, data, bound, None) + Self::layered(runner, body, false, data, bound, None, false) }) } @@ -429,7 +429,11 @@ impl CompiledGraph { out[row] = match result { Some(Ok(values)) => { let object = Variable::empty_object(); - for ((key, _), value) in entries.iter().zip(values) { + for ((key, source), value) in entries.iter().zip(values) { + let value = match source.contains('$') { + true => value.deep_clone(), + false => value, + }; if let Some(values) = results.as_mut().and_then(|results| results.get_mut(row)) { diff --git a/core/engine/tests/spec/graph/36-loops-tables.json5 b/core/engine/tests/spec/graph/36-loops-tables.json5 index d60f399b..a265d925 100644 --- a/core/engine/tests/spec/graph/36-loops-tables.json5 +++ b/core/engine/tests/spec/graph/36-loops-tables.json5 @@ -410,8 +410,8 @@ ]}], }, cases: [ - {input: {items: [{keep: true, x: 1}, {keep: false, x: 2}]}, output: {out: [{item: {keep: true, x: 1}}, {item: null}]}, note: "bug: the input column's `$` reference is stored on the item environment, so $root read in an output cell carries a stray `$` key", engines: {modes: ["single", "batch", "columnar", "traced"], intended: true, why: "the walker leaks the `$` reference into $root; the compiled engine gives the intended result"}}, - {input: {items: [{keep: true}]}, output: {out: [{item: {keep: true}}]}, note: "bug: the input column's `$` reference is stored on the item environment, so $root read in an output cell carries a stray `$` key", engines: {modes: ["single", "batch", "columnar", "engine", "traced"], intended: true, why: "the walker leaks the `$` reference into $root; the compiled engine gives the intended result"}}, + {input: {items: [{keep: true, x: 1}, {keep: false, x: 2}]}, output: {out: [{item: {keep: true, x: 1}}, {item: null}]}, note: "bug: the input column's `$` reference is stored on the item environment, so $root read in an output cell carries a stray `$` key"}, + {input: {items: [{keep: true}]}, output: {out: [{item: {keep: true}}]}, note: "bug: the input column's `$` reference is stored on the item environment, so $root read in an output cell carries a stray `$` key"}, ], } @@ -424,7 +424,7 @@ ]}], }, cases: [ - {input: {item: {keep: true, x: 1}}, output: {out: {item: {keep: true, x: 1}}}, note: "bug: the input column's `$` reference is stored on the environment, so $root read in an output cell carries a stray `$` key (not loop-specific)", engines: {modes: ["single", "batch", "columnar", "traced"], intended: true, why: "the walker leaks the `$` reference into $root; the compiled engine gives the intended result"}}, + {input: {item: {keep: true, x: 1}}, output: {out: {item: {keep: true, x: 1}}}, note: "bug: the input column's `$` reference is stored on the environment, so $root read in an output cell carries a stray `$` key (not loop-specific)"}, [{item: {keep: false}}, {out: {item: null}}], ], } diff --git a/core/engine/tests/typed_parity.rs b/core/engine/tests/typed_parity.rs index b5da8a22..abebc828 100644 --- a/core/engine/tests/typed_parity.rs +++ b/core/engine/tests/typed_parity.rs @@ -298,3 +298,45 @@ fn column_traces_come_in_the_requested_format() { } } } + +fn chain(nodes: Vec) -> Value { + let mut all = vec![json!({"id": "in", "name": "in", "type": "inputNode"})]; + all.extend(nodes); + all.push(json!({"id": "out", "name": "out", "type": "outputNode"})); + let ids: Vec = all + .iter() + .map(|node| node["id"].as_str().unwrap().to_string()) + .collect(); + let edges: Vec = ids + .windows(2) + .map(|pair| json!({"id": format!("{}-{}", pair[0], pair[1]), "sourceId": pair[0], "targetId": pair[1], "type": "edge"})) + .collect(); + json!({"nodes": all, "edges": edges}) +} + +#[test] +fn columns_merge_a_value_written_back_like_version_1() { + let expression = |id: &str, pass: bool, key: &str, value: &str| { + json!({"id": id, "name": id, "type": "expressionNode", "content": { + "passThrough": pass, + "expressions": [{"id": format!("{id}e"), "key": key, "value": value}] + }}) + }; + let rows = vec![json!({"n": 1}), json!({"n": 2, "a": 5})]; + for graph in [ + chain(vec![ + expression("n1", false, "x", "{k: a, n: n}"), + expression("n2", true, "x", "x"), + ]), + chain(vec![ + expression("n1", false, "x", "{k: a, n: n}"), + expression("n2", true, "x", "$nodes.n1.x"), + ]), + chain(vec![ + expression("n1", false, "a", "{b: {res: null, n: n}}"), + expression("n2", true, "a", "$nodes.n1.a"), + ]), + ] { + columns_match_version_one(graph, rows.clone()); + } +} diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 17694720..174a05e3 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -1318,3 +1318,55 @@ fn a_table_reading_the_whole_root_sees_the_tested_value_under_its_key() { ); same_on_every_path(&cell, &json!({"a": 1}), json!({"out": "three"})); } + +#[test] +fn a_value_read_from_an_earlier_node_merges_like_a_copy() { + let graph = chained(vec![ + json!({"id": "n2", "name": "n2", "type": "expressionNode", "content": {"expressions": [ + {"id": "a", "key": "a", "value": "{b: {res: null}}"} + ]}}), + json!({"id": "n3", "name": "n3", "type": "expressionNode", "content": { + "passThrough": true, + "expressions": [{"id": "b", "key": "a", "value": "$nodes.n2.a"}] + }}), + ]); + same_on_every_path(&graph, &json!({}), json!({"a": {"b": {}}})); + batch_rows_match_single_rows(&graph, &[json!({}), json!({"x": 1})]); +} + +#[test] +fn a_pass_through_writing_a_value_back_keeps_or_drops_nulls_like_version_1() { + let expression = |id: &str, pass: bool, key: &str, value: &str| { + json!({"id": id, "name": id, "type": "expressionNode", "content": { + "passThrough": pass, + "expressions": [{"id": format!("{id}e"), "key": key, "value": value}] + }}) + }; + let cases = [ + chained(vec![ + expression("n1", false, "x", "{k: a}"), + expression("n2", true, "x", "x"), + ]), + chained(vec![ + expression("n1", false, "x", "{k: a}"), + expression("n2", true, "x", "$nodes.n1.x"), + ]), + chained(vec![expression("n1", true, "a", "$nodes.in.a")]), + chained(vec![expression("n1", true, "obj", "obj")]), + ]; + let rows = [ + json!({}), + json!({"a": {"p": null, "q": 1}, "obj": {"x": {"y": null}, "k": null, "v": 1}}), + ]; + for (at, graph) in cases.iter().enumerate() { + for row in &rows { + let want = outcomes(EngineVersion::V1, Path::Repeated, graph, row).remove(0); + for path in [Path::Repeated, Path::Compiled, Path::Batch] { + for got in outcomes(EngineVersion::V2, path, graph, row) { + assert_eq!(got, want, "case {at} {path:?} {row}"); + } + } + } + batch_rows_match_single_rows(graph, &rows); + } +} diff --git a/core/expression/src/lane/output.rs b/core/expression/src/lane/output.rs index fb87bee7..cf42a0cc 100644 --- a/core/expression/src/lane/output.rs +++ b/core/expression/src/lane/output.rs @@ -321,6 +321,17 @@ impl Default for Output { } impl Output { + pub fn detach(&mut self) { + let container = + |value: &Variable| matches!(value, Variable::Object(_) | Variable::Array(_)); + for value in self.values.iter_mut().filter(|value| container(value)) { + *value = value.deep_clone(); + } + for (_, value) in self.extra.iter_mut().filter(|(_, value)| container(value)) { + *value = value.deep_clone(); + } + } + pub fn new() -> Self { Self::default() } From 21c87ce2b604552568046ebeadfeb75eac934651 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 15:18:10 +0100 Subject: [PATCH 29/32] perf(engine): keep tables whose outputs read the tested value on the compiled plan --- core/engine/src/compiled/table/mod.rs | 59 +++++++++++++++++++++++++- core/engine/tests/version_parity.rs | 61 +++++++++++++++++++++++++++ core/expression/src/lane/source.rs | 23 +++++++++- 3 files changed, 141 insertions(+), 2 deletions(-) diff --git a/core/engine/src/compiled/table/mod.rs b/core/engine/src/compiled/table/mod.rs index 3ef25ac9..e652b67f 100644 --- a/core/engine/src/compiled/table/mod.rs +++ b/core/engine/src/compiled/table/mod.rs @@ -377,8 +377,64 @@ impl Table { } } let mut outputs = Vec::with_capacity(rules); + let usable = |field: &str| { + !field.trim().is_empty() + && !SourceInfo::draws(field) + && !SourceInfo::reads_dollar(field) + }; + let plain = |field: &str| { + crate::compiled::trace::plain_path(field) + && LaneProgram::standard(field).is_ok_and(|program| program.path() == Some(field)) + }; + let probed: Vec<(Vec<&str>, bool)> = ir + .rules + .iter() + .map(|rule| { + let filled = ir + .inputs + .iter() + .filter(|input| ir.cell(rule, input.id).is_some()); + let fields: Vec<&str> = filled.clone().filter_map(|input| input.field).collect(); + let bare = filled.clone().any(|input| input.field.is_none()); + (fields, bare) + }) + .collect(); + let tested: Vec>> = ir + .rules + .iter() + .enumerate() + .map(|(at, rule)| { + let value: Option<&str> = match ir.profile.strict() { + true => None, + false => match probed[at].0.last() { + Some(field) => Some(*field).filter(|field| usable(field)), + None => match probed[..at] + .iter() + .rev() + .find(|(fields, _)| !fields.is_empty()) + { + Some((fields, false)) if fields.len() == 1 => { + Some(fields[0]).filter(|field| usable(field) && plain(field)) + } + Some(_) => None, + None => Some("null"), + }, + }, + }; + ir.outputs + .iter() + .map(|output| { + let cell = ir.cell(rule, output.id)?; + match SourceInfo::reads_dollar(cell) { + true => SourceInfo::with_dollar(cell, value?), + false => None, + } + }) + .collect() + }) + .collect(); let mut memo = OutputCells::default(); - for rule in ir.rules.iter() { + for (rule, tested) in ir.rules.iter().zip(tested.iter()) { let mut paths = Vec::new(); let mut full: Vec<(String, &str)> = Vec::new(); let mut collect: Vec<(String, &str)> = Vec::new(); @@ -392,6 +448,7 @@ impl Table { }) .collect(); for (at, &(column, output, cell)) in written.iter().enumerate() { + let cell = tested[column].as_deref().unwrap_or(cell); if SourceInfo::reads_dollar(cell) { return Err("table output cell reads `$`".into()); } diff --git a/core/engine/tests/version_parity.rs b/core/engine/tests/version_parity.rs index 174a05e3..deba55c2 100644 --- a/core/engine/tests/version_parity.rs +++ b/core/engine/tests/version_parity.rs @@ -1370,3 +1370,64 @@ fn a_pass_through_writing_a_value_back_keeps_or_drops_nulls_like_version_1() { batch_rows_match_single_rows(graph, &rows); } } + +#[test] +fn a_table_output_reads_the_value_its_rule_tested_last() { + let table = |policy: &str, rules: Value| { + graph( + json!({"id": "node", "name": "node", "type": "decisionTableNode", "content": { + "hitPolicy": policy, + "inputs": [ + {"id": "i0", "field": "tier"}, + {"id": "i1", "field": "amount * 2"}, + {"id": "i2", "field": "obj"} + ], + "outputs": [{"id": "o0", "field": "v"}, {"id": "o1", "field": "w"}], + "rules": rules + }}), + ) + }; + let rules = json!([ + {"_id": "r0", "i0": "'gold'", "i1": "> 100", "i2": "", "o0": "$ + 1", "o1": "'a'"}, + {"_id": "r1", "i0": "'gold'", "i1": "", "i2": "", "o0": "upper($)", "o1": "$ == 'gold'"}, + {"_id": "r2", "i0": "", "i1": "> 10", "i2": "$.k > 0", "o0": "$.k * 10", "o1": "sum(map([1, 2], # + $.k))"}, + {"_id": "r3", "i0": "'silver'", "i1": "", "i2": "", "o0": "len($)", "o1": "'$ stays text'"}, + {"_id": "r4", "i0": "", "i1": "", "i2": "", "o0": "$", "o1": "'none'"} + ]); + let inputs = [ + json!({"tier": "gold", "amount": 80, "obj": {"k": 2}}), + json!({"tier": "gold", "amount": 3, "obj": {"k": 2}}), + json!({"tier": "bronze", "amount": 30, "obj": {"k": 3}}), + json!({"tier": "silver", "amount": 1, "obj": {"k": 0}}), + json!({"tier": "bronze", "amount": 1, "obj": {"k": 0}}), + json!({"tier": null, "amount": null, "obj": null}), + ]; + let mut tested = rules.clone(); + tested.as_array_mut().unwrap().pop(); + let unknown = json!([ + {"_id": "r0", "i0": "'gold'", "i1": "> 100", "i2": "", "o0": "1", "o1": "'a'"}, + {"_id": "r1", "i0": "", "i1": "", "i2": "", "o0": "$", "o1": "'left over'"} + ]); + for policy in ["first", "collect"] { + for (rules, planned) in [ + (rules.clone(), true), + (tested.clone(), true), + (unknown.clone(), false), + ] { + let graph = table(policy, rules); + for input in &inputs { + let want = outcomes(EngineVersion::V1, Path::Repeated, &graph, input).remove(0); + same_as_version_1_without_compile(&graph, input, want); + } + batch_rows_match_single_rows(&graph, &inputs); + let content: DecisionContent = serde_json::from_value(graph).unwrap(); + let mut decision = DecisionEngine::default() + .with_version(EngineVersion::V2) + .create_decision(Arc::new(content)) + .unwrap(); + decision.compile(); + let degraded = zen_engine::diagnostics::degraded(&decision).unwrap_or_default(); + assert_eq!(degraded.is_empty(), planned, "{policy} {degraded:?}"); + } + } +} diff --git a/core/expression/src/lane/source.rs b/core/expression/src/lane/source.rs index 23295dba..fbec3c8b 100644 --- a/core/expression/src/lane/source.rs +++ b/core/expression/src/lane/source.rs @@ -1,5 +1,5 @@ use crate::functions::{FunctionKind, InternalFunction}; -use crate::lexer::{Lexer, LogicalOperator, Operator}; +use crate::lexer::{Identifier, Lexer, LogicalOperator, Operator, TokenKind}; use crate::parser::{Node, Parser}; use bumpalo::Bump; use std::cell::Cell; @@ -73,6 +73,27 @@ impl SourceInfo { roots.get() != fields.get() } + pub fn with_dollar(source: &str, value: &str) -> Option { + let bump = Bump::new(); + let mut lexer = Lexer::new(); + let tokens = lexer.tokenize(&bump, source).ok()?; + let mut out = String::with_capacity(source.len() + value.len() + 2); + let mut at = 0usize; + for token in tokens.iter() { + if token.kind != TokenKind::Identifier(Identifier::ContextReference) { + continue; + } + let (start, end) = (token.span.0 as usize, token.span.1 as usize); + out.push_str(source.get(at..start)?); + out.push('('); + out.push_str(value); + out.push(')'); + at = end; + } + out.push_str(source.get(at..)?); + Some(out) + } + pub fn scalar(source: &str) -> bool { if source.trim().is_empty() { return true; From b4409d612a4478b98528c61b2fa5d68f25de6e04 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 15:29:10 +0100 Subject: [PATCH 30/32] test(engine): record pinned Date results across zones, DST gaps and far years --- core/engine/tests/fixtures/pinned_dates.json | 1514 ++++++++++++++++++ core/engine/tests/pinned_dates.rs | 284 ++++ 2 files changed, 1798 insertions(+) create mode 100644 core/engine/tests/fixtures/pinned_dates.json create mode 100644 core/engine/tests/pinned_dates.rs diff --git a/core/engine/tests/fixtures/pinned_dates.json b/core/engine/tests/fixtures/pinned_dates.json new file mode 100644 index 00000000..54e4de64 --- /dev/null +++ b/core/engine/tests/fixtures/pinned_dates.json @@ -0,0 +1,1514 @@ +{ + "America/St_Johns": { + "rows": [ + ["-5400000","64dd6517441da4b5","fe1256b994a0aa41"], + ["-3600000","2c1778958eb2542e","3eda3189b0078b13"], + ["-1800000","1c1b7fc007e566e5","3a33468664ee3507"], + ["0","bae57fb32057f5c6","c01fbf13b04ccf67"], + ["1800123","8f472371eb279712","fe7b0d57ba8a12ed"], + ["3600000","a34b5386069a557b","f09be5cd9a5a4ab7"], + ["5400000","0cee81f9f0514166","4e20a2cb973232bb"], + ["-5400001","3a6264aaeb35591b","371d30c8f9c1352b"], + ["-3600001","add87769bec34891","0bd7d4bfe62a5ee7"], + ["-1800001","0df30868f3ba9f40","0494e8f1a973ec2b"], + ["-1","b92f9fc1ea17befd","53fbab1b74207cab"], + ["1800122","5c725fa43b71cbab","f2d8e7dd29fe818f"], + ["3599999","2e0ebfeac8cfb45e","4312d95134fcdaff"], + ["5399999","eb7286953fbd43c7","67fabb04e6360bcd"], + ["-5399999","4e5a5675554cab70","8d1b67f6c09658b7"], + ["-3599999","d5be471fc0024731","31490b162719297d"], + ["-1799999","d83da6d122638a68","1b4f7be527da3225"], + ["1","edd41e1f4d093135","a45538b3bf22db15"], + ["1800124","5d6d7fd444ec2aa5","260d2b06818a93db"], + ["3600001","8d2fdf2bef3dd9cc","81bfbce95be1e9f9"], + ["5400001","376763a7df45b207","c4081785bdd84037"], + ["1699994600000","1a51b93653d94c3d","0b8b1e94d12fb161"], + ["1699996400000","df3bb567c55b5732","21d94859c1482751"], + ["1699998200000","26813f67cd055eae","c8f2de0c85eebc11"], + ["1700000000000","efc5efa4b55e0591","85ec4a50c89adaa5"], + ["1700001800123","160d15cefce705ff","9808c249120e83ad"], + ["1700003600000","1585da68197a8a5c","8e03255e5461471d"], + ["1700005400000","795abb235906fc83","b559fa7d24a3894d"], + ["1768475096789","9d5f5520fd5aed1b","59214747809892c5"], + ["1768476896789","36f81510ca477c31","866562dbecbf6fb1"], + ["1768478696789","f9ac6ca4c0ab0fe2","343b7b85790674ad"], + ["1768480496789","2e2b656ef28681fc","b8b3355c1eebee89"], + ["1768482296912","c3c77cb0058913df","401f1b697dd5f521"], + ["1768484096789","db0a7826a95e3e15","77d69ce7489fa7b1"], + ["1768485896789","ebc548545b1e4bbc","fdb92d16c1336f51"], + ["1774740600000","3311eeed3c4e2654","fd78f4942ca2bc65"], + ["1774742400000","4d705b5bdabd0dbb","8c96102807d36009"], + ["1774744200000","239e669b94c57be2","8448b14fe800b9e5"], + ["1774746000000","c7ac0527f85bab53","807e4bf28aca4279"], + ["1774747800123","b63a94a678508f27","2ecc4453a2d51e8d"], + ["1774749600000","2294a24c3c90c2a8","98d3ff87c5a7c395"], + ["1774751400000","6c7471838fbc5f6b","0b3a76f17c27cbd9"], + ["1792884600000","3b27bb3bf224b3bb","f150c22e29d57811"], + ["1792886400000","6bcd90377ee11a44","197ff80cbd8efaad"], + ["1792888200000","484baf3fcb3b2699","7428ad5006c56849"], + ["1792890000000","0b3a129c0aef6510","61131a6cc909f519"], + ["1792891800123","603940391c19b9ac","abe01c434e68fbc1"], + ["1792893600000","4a6509c724794153","421951d7092dc025"], + ["1792895400000","5d8766c24673a678","7415c5518a141ce9"], + ["1772942400000","1072cfa504d69dd9","a62060e2e81c2a0d"], + ["1772944200000","3274a6f500d8adf1","3ea410b5ad474e09"], + ["1772946000000","53f61e1ea706c9ea","5b0342ff526ca585"], + ["1772947800000","fa14b0add194aa41","ef5a6549cd24fe71"], + ["1772949600123","ffd4dfb02c41275a","33b7ebc4ed8cc1e1"], + ["1772951400000","45ec3b4c8f88a0d9","ef7dae0ee48ead99"], + ["1772953200000","2f8e1935a8aad3f0","34649c278fe527a1"], + ["1793502000000","a3aa3cae39d65f6d","cc5221e782df2009"], + ["1793503800000","e3095d98213d191a","de7cca03a1b77b11"], + ["1793505600000","5bb30be987e38739","b76371b98e3c7471"], + ["1793507400000","cbcfe69b21100703","de7cca03a1b77b11"], + ["1793509200123","6705444a43190cb4","1b6019c2c0172795"], + ["1793511000000","3059152b5ccec1dc","acc8c6dade3e1271"], + ["1793512800000","f7b94a3d6e3c0bed","3d6387d9efa37e91"], + ["788862600000","54611740ebfee5f0","00585d05340caab5"], + ["788864400000","362855da14ac2e91","e35a144135f8fd15"], + ["788866200000","0bc9af9b36b3fd55","afceb887d4b5ee7b"], + ["788868000000","a1a5966e476ff5da","6538ed59ddccc4d5"], + ["788869800123","a6d51a7e6787f80e","5803f18891331e3f"], + ["788871600000","1fb73bc6417668e7","6a7f0bc91ca947af"], + ["788873400000","6304efbea74de057","fe9ba296a4f92583"], + ["504895500000","271612a7e9702d4b","905374a923dd50b5"], + ["504897300000","b0666db58316fff2","add9fb1e6018b5ad"], + ["504899100000","8cb6ff26f2bbe3b4","ecc1d60f53f6ec5f"], + ["504900900000","7df97607cf103239","fed271e30e3ae475"], + ["504902700123","43101997afdb2775","cf65754e0d03bc49"], + ["504904500000","130d380a4afa6362","b4b8837c89b562c7"], + ["504906300000","016bc4d05dee0b6d","4ae61a4b9fbdfce5"], + ["1775309400000","940dc5a5b642eb8c","028bd20f35458e29"], + ["1775311200000","77b097231f5d4655","c2bbfbc7cfdb5d49"], + ["1775313000000","e442c9adc320f062","063157e3d704fbc5"], + ["1775314800000","5f9519797befdd21","8a29fafdf0852b41"], + ["1775316600123","8b42686678f97fe2","2d6165e91fc459a9"], + ["1775318400000","889d86f885bd4087","159fb0ae8cdc14d5"], + ["1775320200000","96b91bb13a7ec6a6","ba157b280d391b55"], + ["1791036000000","25885fb9593f793e","43e69a11236e5845"], + ["1791037800000","c61b20ee8787cf8b","dd673d22c105d9d5"], + ["1791039600000","a0f9ba398177bbd2","01924521814dc05d"], + ["1791041400000","c131d93649c1ecf7","40ebc7981c9de8e9"], + ["1791043200123","a0b7acf593aa2dd4","e3d05320bc84f62d"], + ["1791045000000","76959d497c8b2f33","161864056c17dbc9"], + ["1791046800000","8600d6ae1fe950ca","9d2f801aad3627fd"], + ["-2422056600000","aaa0a072fac1ccbb","28c097322ffc62a7"], + ["-2422054800000","679df7354e35b39e","b439ea8b9c77584d"], + ["-2422053000000","5720c1e710a65354","85cb55c98eba1a9f"], + ["-2422051200000","ef48fc17916ea2f2","5bba09667db510cf"], + ["-2422049399877","d7fb41116d789e4e","f98101c352534705"], + ["-2422047600000","d94217100fa521cf","37cd2f968050eb79"], + ["-2422045800000","43ff4727548430f9","b9f1918b85043e1d"], + ["-5364624600000","fa5eb1a3576030db","d6bde3be6c7469b3"], + ["-5364622800000","037a5631d102a55e","4bfb40287243e505"], + ["-5364621000000","2894c13aad6e4618","ac55a35e7fcc483b"], + ["-5364619200000","335add4947ba65a9","7cd858876fa9965f"], + ["-5364617399877","9131e56515359ed9","be652ef5eecd184b"], + ["-5364615600000","874e92c554d9f7f4","08364c9cef745c85"], + ["-5364613800000","c54beb53c902fcc6","de61ecf03671982d"], + ["-2208994200000","045f822f5780bc98","1f9eda6efed7e5c3"], + ["-2208992400000","a9018722870cad55","4f8279297c8cda89"], + ["-2208990600000","ad1c3c3a0d653815","e3f07e43aa34bfdf"], + ["-2208988800000","fd3a620e552419d1","ce828c0ffac2ada5"], + ["-2208986999877","004abc66d9de464f","ba9f06d7a14dc203"], + ["-2208985200000","6c8122b217dfea16","9d7ba4cae2df71e3"], + ["-2208983400000","0e5ab6d4c0a25a9a","5da0bee0bb773807"], + ["4102435800000","3b2f7634472b7e73","cc70c66dd48ee269"], + ["4102437600000","badad0f4ca1d258a","c46903dbdfe5176d"], + ["4102439400000","8cf8dc7a86a50d8e","19ccc87fcc5b1b09"], + ["4102441200000","dd6dba6781b1a505","e8d415022e72cce1"], + ["4102443000123","4d4a9ad597c29afe","7e01e98197324389"], + ["4102444800000","c96b32e8d7c46ae1","c433a26d2f4a6c19"], + ["4102446600000","b0808d48ef36937f","cc7ee88a23ebcab5"], + ["4109873400000","cc12aaed535800c5","717e3ebe0a3498c1"], + ["4109875200000","8ed6ccf1347754ea","b26baea9097997fd"], + ["4109877000000","f1ac37750a10547f","3470bff2b4de7dad"], + ["4109878800000","75b3373799751026","e6bbb27f9e083971"], + ["4109880600123","2116d72859062982","eab5af1cd57142d9"], + ["4109882400000","fd4b297e7c4f01b5","10246f42008b7a61"], + ["4109884200000","cea24919b74f0cf6","2c5c192b78e9a5d9"], + ["4118121000000","5880e00a9e3dc1cf","3610376ad08d6d3d"], + ["4118122800000","6b10f681b8a478ee","4db8c658e3484481"], + ["4118124600000","ab9023e6c527c6f6","3167646a173cecd1"], + ["4118126400000","f7fec7116e9f9099","3cf12cc79ee1b3c1"], + ["4118128200123","786980f18dfda159","cf13730db6b5d771"], + ["4118130000000","1b680bbb75e228be","8cfc2fbbf3cfddb9"], + ["4118131800000","a27243871c7fb498","3e507c6e3003fba9"], + ["8862129000000","2b089b686ab7f95c","dd01503b9ffc5b41"], + ["8862130800000","b2e25272b74910ff","cbd930fbf14a6e05"], + ["8862132600000","d9f18f996223b691","4ee1defb291323cd"], + ["8862134400000","6b5b17087314f98c","840907c1a04fc60d"], + ["8862136200123","e06de9e5f3ba927b","a87aa2462ab377c1"], + ["8862138000000","5a4dd16064090e58","c3d60b269c92909d"], + ["8862139800000","2535ca83222e2ad2","9a41a2542a3b9a0d"], + ["13569460140000","a1ddeafecdac082e","16264438f882a223"], + ["13569461940000","f6dabefd87c6d187","08277601ef95a26d"], + ["13569463740000","3ee4470fadb808ef","3000447c8f1bc763"], + ["13569465540000","c68608e3849dea5b","c20604cae9399bb9"], + ["13569467340123","c6f8219bc1da6b31","e1981757f5f4af3d"], + ["13569469140000","e2331d95204a2800","48acc3beb1bdfc9d"], + ["13569470940000","a6acfaa652564774","087dc2b9da60302f"], + ["253402295399999","7f9dcbfab6a56d74","473c31bd6c67646d"], + ["253402297199999","e764f52959437ac5","64d5ff09e6e5da11"], + ["253402298999999","d5fed250dc820a1d","dc687f782b10d415"], + ["253402300799999","9edb955b0931bc27","a050fac9a6c25cfd"], + ["253402302600122","6f96a3bcc166d0f0","97ac1db2c26b6045"], + ["253402304399999","fadd42306afcc4dc","3943e6c70a1d9079"], + ["253402306199999","4ef1a00083a1ee48","e8086c026cf63631"], + ["-2208994200000","045f822f5780bc98","1f9eda6efed7e5c3"], + ["-2208992400000","a9018722870cad55","4f8279297c8cda89"], + ["-2208990600000","ad1c3c3a0d653815","e3f07e43aa34bfdf"], + ["-2208988800000","fd3a620e552419d1","ce828c0ffac2ada5"], + ["-2208986999877","004abc66d9de464f","ba9f06d7a14dc203"], + ["-2208985200000","6c8122b217dfea16","9d7ba4cae2df71e3"], + ["-2208983400000","0e5ab6d4c0a25a9a","5da0bee0bb773807"], + ["-62184504600000","e8045b0695d0463f","0c69889e8ece8c9d"], + ["-62184502800000","aaf21aa931a137c6","d9e64c2ad30a854d"], + ["-62184501000000","582d2255224f6518","15d700bce855df21"], + ["-62184499200000","8a0651a96bd50648","f5ecfef9b19882d1"], + ["-62184497399877","73e97561388d85ec","0b5d88876e454e29"], + ["-62184495600000","69d5fdef46a55591","644339be643d006d"], + ["-62184493800000","bd10a4165fa1c127","6d388a1f247743ed"], + ["-8640000000000000","d64251c55b8623e9","5d04ee5b14c94469"], + ["-8639999998199877","c98587a2b2323853","5d04ee5b14c94469"], + ["-8639999996400000","f966d243d5f752b8","5d04ee5b14c94469"], + ["-8639999994600000","695675f9a9f43ce0","5d04ee5b14c94469"], + ["8639999994600000","5e2e361f34389682","902c4162acbaceeb"], + ["8639999996400000","44338424da61889c","0af1daf4abd9672b"], + ["8639999998200000","b5ec981bc50dab62","87592cbde9a06fb1"], + ["8640000000000000","e286cd13f698fc92","9e56a44ab44288ad"], + ["-8640000000000000","d64251c55b8623e9","5d04ee5b14c94469"], + ["-8639999998199877","c98587a2b2323853","5d04ee5b14c94469"], + ["-8639999996400000","f966d243d5f752b8","5d04ee5b14c94469"], + ["-8639999994600000","695675f9a9f43ce0","5d04ee5b14c94469"], + ["8639999991000000","f625a7ea1252ad19","aed92e0358c27bef"], + ["8639999992800000","5e90dfd515544a13","950f78bf0b554b4f"], + ["8639999994600000","5e2e361f34389682","902c4162acbaceeb"], + ["8639999996400000","44338424da61889c","0af1daf4abd9672b"], + ["8639999998200123","b609c63fa1389886","a5619afa2f1bab65"], + ["8640000000000000","e286cd13f698fc92","9e56a44ab44288ad"], + ["-8639999919000000","caae7fb045508454","15023d9b95236511"], + ["-8639999917200000","f9f6961f14fcf789","79f1d67040d54341"], + ["-8639999915400000","aa20247c6a3db71b","bf60654abd4a98ad"], + ["-8639999913600000","38875bf308976a03","df6e82e51d1b9ff1"], + ["-8639999911799877","4c080b8647ddde73","7204897b84883769"], + ["-8639999910000000","421f8c96fdca969a","4552b2446b66db01"], + ["-8639999908200000","5b2e6d0fe72f8228","08c951d56002cad1"], + ["8599999994600000","6e8d601a571015ab","431f4d23520851bf"], + ["8599999996400000","76fc161210fc0aef","cc79b0a7cb37b4fb"], + ["8599999998200000","e45e129ec6f64e01","ac4dece2196617e1"], + ["8600000000000000","c477cd2892072b52","fa2ecc4389553b8b"], + ["8600000001800123","a9f43562068253ce","294091affe16ce5d"], + ["8600000003600000","9dababb782f7e7d4","1a3721df3472db8b"], + ["8600000005400000","33785be2c22fcdb2","e075da418809c2fd"], + ["-8600000005400000","7a042a16ec053eac","0c5736425122213d"], + ["-8600000003600000","48f5254f58a7ed31","3304989fa97e70f1"], + ["-8600000001800000","25044a1a5beefd93","67f3991a124ba8cd"], + ["-8600000000000000","ee827febdf998084","97140994ba741069"], + ["-8599999998199877","dde6a9e3d07317a1","f4217a70ab0781d9"], + ["-8599999996400000","2aea0d52845ac762","8f8a425e8572945d"], + ["-8599999994600000","d91e6559e3688a92","3404b63685c5e09d"], + ["NaN","9a29e84c251c3a5d","590e5a254d193901"] + ], + "made": ["1774760400000 Sun Mar 29 2026 02:30:00 GMT-0230","1774758599999 Sun Mar 29 2026 01:59:59 GMT-0230","1774762200000 Sun Mar 29 2026 03:00:00 GMT-0230","1792904400000 Sun Oct 25 2026 02:30:00 GMT-0230","1792900800000 Sun Oct 25 2026 01:30:00 GMT-0230","1792906200000 Sun Oct 25 2026 03:00:00 GMT-0230","1772949600000 Sun Mar 08 2026 03:30:00 GMT-0230","1793505600000 Sun Nov 01 2026 01:30:00 GMT-0230","1793502000000 Sun Nov 01 2026 00:30:00 GMT-0230","1775362500000 Sun Apr 05 2026 01:45:00 GMT-0230","1775364300000 Sun Apr 05 2026 02:15:00 GMT-0230","1791089100000 Sun Oct 04 2026 02:15:00 GMT-0230","788887800000 Sat Dec 31 1994 12:00:00 GMT-0330","788844540000 Fri Dec 30 1994 23:59:00 GMT-0330","788931000000 Sun Jan 01 1995 00:00:00 GMT-0330","504934800000 Wed Jan 01 1986 00:10:00 GMT-0330","504934140000 Tue Dec 31 1985 23:59:00 GMT-0330","915161400000 Fri Jan 01 1999 00:00:00 GMT-0330","-2208976148000 Mon Jan 01 1900 00:00:00 GMT-0331","-62198742548000 Fri Jan 01 -0001 00:00:00 GMT-0331","-59011446548000 Fri Jan 01 0100 00:00:00 GMT-0331","915161400000 Fri Jan 01 1999 00:00:00 GMT-0330","-2208976148000 Mon Jan 01 1900 00:00:00 GMT-0331","NaN Invalid Date","NaN Invalid Date","-8639999987348000 Tue Apr 20 -271821 00:00:00 GMT-0331","NaN Invalid Date","4118092200000 Thu Jul 01 2100 00:00:00 GMT-0230","4109893200000 Sun Mar 28 2100 02:30:00 GMT-0230","8862152400000 Thu Oct 31 2250 02:30:00 GMT-0230","13569478140000 Fri Dec 31 2399 23:59:00 GMT-0330","1767238200000 Thu Jan 01 2026 00:00:00 GMT-0330","1767238200000 Thu Jan 01 2026 00:00:00 GMT-0330","NaN Invalid Date","NaN Invalid Date","1767238200000 Thu Jan 01 2026 00:00:00 GMT-0330","1769916600000 Sun Feb 01 2026 00:00:00 GMT-0330","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2208976148000 Mon Jan 01 1900 00:00:00 GMT-0331","NaN Invalid Date","-2177440148000 Tue Jan 01 1901 00:00:00 GMT-0331","1769916600000 Sun Feb 01 2026 00:00:00 GMT-0330","1767583800000 Mon Jan 05 2026 00:00:00 GMT-0330"], + "order": ["NaN","NaN","-1737997",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], + "parsed": [["1768483800000","1768483800000"],["1768483800000","1768483800000"],["1768483800000","1768483800000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792904400000","1792904400000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768483800000","1768483800000"],["1768447800000","1768447800000"],["1768534140000","1768534140000"],["1768483800000","1768483800000"],["1768447800000","1768447800000"],["1768494600000","1768494600000"],["1768471200000","1768471200000"],["1768483800000","1768483800000"],["4118135400000","4118135400000"],["4118135400000","4118135400000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768534200000","1768534200000"],["1768483800500","1768483800500"],["1768483800123","1768483800123"],["1768483800000","1768483800000"],["NaN","NaN"],["NaN","NaN"],["788887800000","788887800000"],["504934800000","504934800000"],["1775364300000","1775364300000"],["1791089100000","1791089100000"],["1793505600000","1793505600000"]], + "single": ["1704067200000","988684200000","NaN","NaN","86400000","1709263800000","1709299800000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007177400000","1768483800000","1774745100250","NaN","Sat Mar 28 2026 22:15:00 GMT-0230","Sat Mar 28 2026 22:15:00 GMT-0230","string","true 1774760400000 2 Sun Mar 29 2026 02:30:00 GMT-0230","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767238200000","1780281000000","NaN","01/01/1970, 09:00:00 AM","12/31/1969, 08:30:00 PM","12/31/1969, 08:30:00 PM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","12/31/1969, 08:30:00 PM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] + }, + "Asia/Kathmandu": { + "rows": [ + ["-5400000","056f535ca89fa050","43ffc0cdbfd3dbed"], + ["-3600000","9da52d83258fe287","0bdeeeeb782c6691"], + ["-1800000","2251e94d95d21827","ec7afc26a507be11"], + ["0","dccbe9509e3361fe","bc564c0978f801e7"], + ["1800123","62a7419fa79db046","99db5d4391b3f085"], + ["3600000","b7c4be0cba1f4a19","1d239b5776c9b6e5"], + ["5400000","80996e0beda93eb0","31ddb074c1e304f5"], + ["-5400001","ae0b666d02ca6258","33ceedeab3552231"], + ["-3600001","0feb943daf407a84","df5f2dfdfc8c41a7"], + ["-1800001","680c6742100fe849","7b598eafcde616e1"], + ["-1","f3f82521a8225f07","2d6bb12676469e59"], + ["1800122","eb5f4c2b1a6e4f03","f486c399d1ad3877"], + ["3599999","b7e62933b3aa917a","ee4bd7d137720ddd"], + ["5399999","966b1436cd172a6b","63d1a4ef790cc719"], + ["-5399999","7992a028e4e41895","191afd19faab6003"], + ["-3599999","edc37b0bebcd070c","c844cb2fe81a90d1"], + ["-1799999","b430da0848df51ba","2ead10da802ce103"], + ["1","3fd6f5abcbec9bad","fb664a56c7a11cf3"], + ["1800124","a41c6ab662c30cf9","1cca06b5ad53420b"], + ["3600001","3109f4e7d58c22c6","52fc567c5f66b7d9"], + ["5400001","2a7e7ef0ab3d1c31","89bdd4a805098a05"], + ["1699994600000","f645240e4efe613a","90aad065a7a0a2cd"], + ["1699996400000","330ad4509efcc4dd","67d657f0074c9d41"], + ["1699998200000","1b6780415f015b15","1317b3899e46e011"], + ["1700000000000","27888b9ca6db9262","d46c4b1e41049435"], + ["1700001800123","60b4efff8bbc4d50","e85e6f2b7a6e0c89"], + ["1700003600000","363d7a89a87f27bf","06ed6de5f6500a29"], + ["1700005400000","9d1a5ffd62fb9437","bb2e320c2ca252b5"], + ["1768475096789","58d2092b9b42488b","3d300d1587603b2d"], + ["1768476896789","e8cd4b8d5e77f629","fe1fde14594071b5"], + ["1768478696789","0166923925d62b86","c54bcc676efaab91"], + ["1768480496789","a1cc24f430dfc1fa","4cfbad1355d4dced"], + ["1768482296912","b19704dc7384f97b","d7eab9224ab41aad"], + ["1768484096789","117b59c64d368c72","a220a846161de93d"], + ["1768485896789","997104784d1aa1b1","5a0151cf65ca23ad"], + ["1774740600000","97df4ffbb9b1c0f5","21022a139dd145d1"], + ["1774742400000","c73688020b120178","884a0eea427ec999"], + ["1774744200000","dc9379777c6c791f","318919765b801289"], + ["1774746000000","8ab6b5ac1dd06a32","5816caf91e3d0e79"], + ["1774747800123","e76737cc37d9bc92","9cc79d91b45101f9"], + ["1774749600000","9d564018ee91b647","5be9d430d04d7a69"], + ["1774751400000","e99c2a631cf8a048","637e0cd6c0cf65cd"], + ["1792884600000","137e6b1a518b60f0","7a8986128ef977ed"], + ["1792886400000","5f5936415eacfc39","3c74da26d62b80f1"], + ["1792888200000","cbfc63f375b63c7a","6bdefeb0fe87bf7d"], + ["1792890000000","1d82bc7feeaefceb","6513961367536871"], + ["1792891800123","202111aba185e4a7","bfd05f661b6252a9"], + ["1792893600000","abf988dae310292e","4710e37d6122e9d9"], + ["1792895400000","29563ead4f367461","22504c80a1fc1979"], + ["1772942400000","667a879f0d6ca412","6fca95ec5e858009"], + ["1772944200000","968c2f8ae4433b41","3ab46a45c802d0c5"], + ["1772946000000","95a5726e07420728","f343cb602cdf01c9"], + ["1772947800000","e1a1afd8b6bfdc4f","43f774c059f0a695"], + ["1772949600123","ac90a206ad8a997e","5563ed843d243fd1"], + ["1772951400000","3e7e912b4628aeef","f8f4265d684c8745"], + ["1772953200000","f0fe3bdd5de8fad2","aaedf7585f1f62b5"], + ["1793502000000","9269d37d59e7e17e","fe8a1640d3fcc029"], + ["1793503800000","1e427ccc0e0ae7f3","8f7ebcfa9f362971"], + ["1793505600000","3059ecf101c38aa0","17d2c429e87ab08d"], + ["1793507400000","a06eb468fba8bf33","61836c801d476b61"], + ["1793509200123","2aad9107b589016c","a08c7c941a687615"], + ["1793511000000","6080fdc6cca31b76","708ba562874076e9"], + ["1793512800000","4fd33f90ff76c275","db8848e7c7318895"], + ["788862600000","372c47ac5931655e","fbe9092b2ca570d7"], + ["788864400000","b80620e8853977af","c0009c37bba7e227"], + ["788866200000","87569fbedec4b145","7ed1b5fd0d90cf93"], + ["788868000000","b9138e008b29d2f0","c22ba994256cb569"], + ["788869800123","e204f641681a0ec4","ce44a2e13a3cb25f"], + ["788871600000","3b5bae453e4bbfa5","1f0bb44340d39cb3"], + ["788873400000","4b10040dfeca95b7","f1c7bda564c510e3"], + ["504895500000","c96b8a9d479761ff","5e08da4bb7728b1d"], + ["504897300000","ce7d6201bcffa1cc","7fc76507983f262f"], + ["504899100000","b5bca49eb4c2da30","dc6bac8882dbb543"], + ["504900900000","2f25707fbc60173f","a16f91e844f19ad5"], + ["504902700123","74ae309135cc845e","9ddfc9890edf7e29"], + ["504904500000","6b94a912ae60df2c","b9420a2c2062757d"], + ["504906300000","6951619abad2d2d0","2a335d640d370ec5"], + ["1775309400000","2829c4602cefe8a1","2ab58ec6f417be19"], + ["1775311200000","cdb9222c180faac0","7d8037b0ba25ffb5"], + ["1775313000000","30b3cf7b1623b7ee","581d8d4d1f143931"], + ["1775314800000","4dbaa265359503d7","aeb4dc09642a4d41"], + ["1775316600123","0ae4d981593a4e7a","ed43f399aab895e5"], + ["1775318400000","2556dcae591947cf","ead9100c7644fbb9"], + ["1775320200000","2baef0962da6ddde","5c07a455ad6c8d19"], + ["1791036000000","04c9b3c159b0af31","72e0ff530d2a504d"], + ["1791037800000","6c202abc5c6689e3","10c6ead3557ff199"], + ["1791039600000","6a0d75719de2d4e6","b97ee07ce2925f85"], + ["1791041400000","e32d0bf3973d2057","9a8ac6e24ad7b701"], + ["1791043200123","bbae5263bf64a46a","0492a3489f9aff61"], + ["1791045000000","cd21b95b39a890c7","a82aec1885b3f0e5"], + ["1791046800000","55ff847e0bd3a676","1f6e5349abbe1acd"], + ["-2422056600000","d8c59452d2572ba0","4288361ad17645a3"], + ["-2422054800000","ce5e6097e8fcb292","f4eaab832aca410b"], + ["-2422053000000","55727b86f72587bf","4e41b3cec8b54ac5"], + ["-2422051200000","823e4218842c7ef7","fed70985176d1e4b"], + ["-2422049399877","e0c7c83547f54616","afdda15cf36f8fdd"], + ["-2422047600000","990dff169df49520","878164f964db460d"], + ["-2422045800000","16cfaf20344123b1","90c4c41532c667b5"], + ["-5364624600000","a8f5e8969fba14a1","5c7b76a69b57cfad"], + ["-5364622800000","381c8556e8ad0a6b","5c9b0b80c3217347"], + ["-5364621000000","34320c7cf8642a62","488904021037f139"], + ["-5364619200000","e0ca44a74b639ea2","6306e37098a51633"], + ["-5364617399877","db20fd85f3c6ef6f","72452cabfde8575f"], + ["-5364615600000","c0e090c018614e29","239064d5b6778e5f"], + ["-5364613800000","0b17fcf0510258ac","a90f1be63bf94bc7"], + ["-2208994200000","d5ec249ab3e015cf","67a93910e960acc3"], + ["-2208992400000","25e39de504935573","5656630e09807bff"], + ["-2208990600000","a51f607c1ffddab6","e0ccbb555d020b19"], + ["-2208988800000","e35602dc2d506a10","42786eab78b25867"], + ["-2208986999877","93d2fbb4e1c18b21","9875b1f7763de01d"], + ["-2208985200000","3f18d8a6b5718a95","ebd77927e872be75"], + ["-2208983400000","35cda47b83e6f1a4","16bca7baecb99191"], + ["4102435800000","57a1e42e76f474d7","7200874148e9a505"], + ["4102437600000","1e6bfab6590033ba","5ecf462fe9e8a931"], + ["4102439400000","4cae2852f23b3b6e","f6e8042b512cc78d"], + ["4102441200000","a67803b76048cd23","a62f8a7d362ce555"], + ["4102443000123","4b8f2d69b37db539","59e574be333ee531"], + ["4102444800000","bc77927e6b37e0cc","f905689976bbe3b5"], + ["4102446600000","2ef544ff63b20c14","46f33bde15b315b5"], + ["4109873400000","d164f62f5c972e60","8d00a45a89487091"], + ["4109875200000","4a7146338fc5f935","2b108a8c0e3ce4e5"], + ["4109877000000","a154acc49d59a1fa","66ed32eea3dac059"], + ["4109878800000","926d680d70d7d687","64f25a8f45aa3ebd"], + ["4109880600123","8c9a3855de9cbb93","47eee4fbac88243d"], + ["4109882400000","17d7410c05f1c5c6","8c5edf8c92919b59"], + ["4109884200000","5f5f4d5039afd9b5","29d1d60dfc489375"], + ["4118121000000","a5b5f2be2c52e239","aa11d8a217de0b81"], + ["4118122800000","ac2f693efeca7e74","2fe67635aac51231"], + ["4118124600000","f2945a29cce75e28","dc148a559a3ac505"], + ["4118126400000","d8e811c3be31bb81","7c065c0acf229829"], + ["4118128200123","cf5c703aa83b6a8a","0c5a1c26fae009c5"], + ["4118130000000","2a157e894f5c6183","bb49442afea0a681"], + ["4118131800000","febbe670a4d4e367","b09340243bde23f9"], + ["8862129000000","83fc6d2aab8312c2","015d478e3e085495"], + ["8862130800000","17d9004c7b1eac97","2901d0fe6a099a69"], + ["8862132600000","ac4dc98da2586793","0b595b380cde442d"], + ["8862134400000","d5783453ffdb8372","e6d17284969e4c81"], + ["8862136200123","f0be689cc2cd8185","f04938ab96a795a5"], + ["8862138000000","c5f5365b14b6b9f4","0d74ae5fccda9571"], + ["8862139800000","ff884758c741a3c8","4c580b28e7c887c1"], + ["13569460140000","971324b32cff8cb2","4783e44201f4cc93"], + ["13569461940000","2eab9d7cf26060da","4ef641c3fbfa834f"], + ["13569463740000","d4cddadc99f9dfbb","0a71f468cf9fafa1"], + ["13569465540000","a8388139a4b69499","e3ab644a0a09d6dd"], + ["13569467340123","ee64aa6538d325b8","2a63ccd71f22fea9"], + ["13569469140000","21802f504540e934","579a6cc099e8f21d"], + ["13569470940000","b4b9483bd1a59881","2d2bec920676af53"], + ["253402295399999","62cf5f12e92cf18c","3f7adcd67d272021"], + ["253402297199999","0d8345160882b0b2","6d82f1a9dc62d095"], + ["253402298999999","91aea18d28e51c27","9b16168e91d3fa61"], + ["253402300799999","40cb7942c3b1d79f","c5dcbdd60b9db6f5"], + ["253402302600122","9815aa2fe286360d","873b40c06138ee35"], + ["253402304399999","1f0652a91834c0d8","c6a905514c02c26d"], + ["253402306199999","e2a36c95bb45b25d","45d86d08788adffd"], + ["-2208994200000","d5ec249ab3e015cf","67a93910e960acc3"], + ["-2208992400000","25e39de504935573","5656630e09807bff"], + ["-2208990600000","a51f607c1ffddab6","e0ccbb555d020b19"], + ["-2208988800000","e35602dc2d506a10","42786eab78b25867"], + ["-2208986999877","93d2fbb4e1c18b21","9875b1f7763de01d"], + ["-2208985200000","3f18d8a6b5718a95","ebd77927e872be75"], + ["-2208983400000","35cda47b83e6f1a4","16bca7baecb99191"], + ["-62184504600000","a3ec8f9d11092f92","7b061d506bce9e51"], + ["-62184502800000","471ba002493d381c","26f098913a864411"], + ["-62184501000000","c758d8d8e8fdd07d","e033623689048581"], + ["-62184499200000","f13f34f9524dcfe1","cfcc575772dbf38d"], + ["-62184497399877","c4bc1e82d023d490","51e01140c2231c71"], + ["-62184495600000","d6966321629a4e4e","7074644d826b2c2d"], + ["-62184493800000","42af4dc100ef5a0f","d9791e5e11dee2b5"], + ["-8640000000000000","b66e1b507643026c","a438a10c7388b8a9"], + ["-8639999998199877","f4c663ebd81d1332","3188f61550278dc1"], + ["-8639999996400000","3956a0705f43a252","557f3d1ba646798d"], + ["-8639999994600000","d5852396973dbc44","2afa4f28283e601d"], + ["8639999994600000","42ef0e11652616ef","5d04ee5b14c94469"], + ["8639999996400000","c6b5ccb4534793d0","5d04ee5b14c94469"], + ["8639999998200000","917bd542444314ca","5d04ee5b14c94469"], + ["8640000000000000","8147d38e53f8df25","5d04ee5b14c94469"], + ["-8640000000000000","b66e1b507643026c","a438a10c7388b8a9"], + ["-8639999998199877","f4c663ebd81d1332","3188f61550278dc1"], + ["-8639999996400000","3956a0705f43a252","557f3d1ba646798d"], + ["-8639999994600000","d5852396973dbc44","2afa4f28283e601d"], + ["8639999991000000","cecc9a0c93140660","5d04ee5b14c94469"], + ["8639999992800000","004f70d2f80cd1bf","5d04ee5b14c94469"], + ["8639999994600000","42ef0e11652616ef","5d04ee5b14c94469"], + ["8639999996400000","c6b5ccb4534793d0","5d04ee5b14c94469"], + ["8639999998200123","917bd542444314ca","5d04ee5b14c94469"], + ["8640000000000000","8147d38e53f8df25","5d04ee5b14c94469"], + ["-8639999919000000","d9f8b758c436fa37","ae111b8e4243f80d"], + ["-8639999917200000","ee5bdf0f70740f65","f0671aebbfae1a25"], + ["-8639999915400000","4cd025e9a137dcc0","bb505bf3a22968c9"], + ["-8639999913600000","9da4972fb09eaf64","e7d47b6ee52ff915"], + ["-8639999911799877","4c07ae639deb1745","592170860996f56d"], + ["-8639999910000000","59eb85a9abf7b2af","fdb681bfd15913b5"], + ["-8639999908200000","afb98466bb681fca","c6c6394d92f9406d"], + ["8599999994600000","d9c6c1199520e8db","f3047d1f0e5e3907"], + ["8599999996400000","ab4e9cda7087b221","051209299292adc1"], + ["8599999998200000","198443c89ceca24e","73f9d5406e020bd3"], + ["8600000000000000","505a8f087325b2b4","4ccb540b10ebfcb7"], + ["8600000001800123","5e31ef25b9937f95","070fb70511bdc7c1"], + ["8600000003600000","c69f26c19b898102","53d8d1347d64a9cf"], + ["8600000005400000","6850e01f3644bc41","826792b92270d629"], + ["-8600000005400000","75bf7a8d9e1fbf7d","b64709d47534ce69"], + ["-8600000003600000","b8d22f94181f1468","b5d3f22ab4832909"], + ["-8600000001800000","20da86b34367d9f4","c775b8adf71bb725"], + ["-8600000000000000","80c20f2077790ee9","2929d18982f84539"], + ["-8599999998199877","b82897119112b70b","40f48bdd0e2a8d71"], + ["-8599999996400000","e45dda5ccf457316","0575a142810f59c1"], + ["-8599999994600000","6e1c5a0e192f13a6","5142c9866fa3bbb1"], + ["NaN","9a29e84c251c3a5d","baa26ad483064477"] + ], + "made": ["1774730700000 Sun Mar 29 2026 02:30:00 GMT+0545","1774728899999 Sun Mar 29 2026 01:59:59 GMT+0545","1774732500000 Sun Mar 29 2026 03:00:00 GMT+0545","1792874700000 Sun Oct 25 2026 02:30:00 GMT+0545","1792871100000 Sun Oct 25 2026 01:30:00 GMT+0545","1792876500000 Sun Oct 25 2026 03:00:00 GMT+0545","1772916300000 Sun Mar 08 2026 02:30:00 GMT+0545","1793475900000 Sun Nov 01 2026 01:30:00 GMT+0545","1793472300000 Sun Nov 01 2026 00:30:00 GMT+0545","1775332800000 Sun Apr 05 2026 01:45:00 GMT+0545","1775334600000 Sun Apr 05 2026 02:15:00 GMT+0545","1791059400000 Sun Oct 04 2026 02:15:00 GMT+0545","788854500000 Sat Dec 31 1994 12:00:00 GMT+0545","788811240000 Fri Dec 30 1994 23:59:00 GMT+0545","788897700000 Sun Jan 01 1995 00:00:00 GMT+0545","504902400000 Wed Jan 01 1986 00:25:00 GMT+0545","504901740000 Tue Dec 31 1985 23:59:00 GMT+0530","915128100000 Fri Jan 01 1999 00:00:00 GMT+0545","-2209009276000 Mon Jan 01 1900 00:00:00 GMT+0541","-62198775676000 Fri Jan 01 -0001 00:00:00 GMT+0541","-59011479676000 Fri Jan 01 0100 00:00:00 GMT+0541","915128100000 Fri Jan 01 1999 00:00:00 GMT+0545","-2209009276000 Mon Jan 01 1900 00:00:00 GMT+0541","8639999979300000 Sat Sep 13 275760 00:00:00 GMT+0545","8639999975700000 Fri Sep 12 275760 23:00:00 GMT+0545","NaN Invalid Date","NaN Invalid Date","4118062500000 Thu Jul 01 2100 00:00:00 GMT+0545","4109863500000 Sun Mar 28 2100 02:30:00 GMT+0545","8862122700000 Thu Oct 31 2250 02:30:00 GMT+0545","13569444840000 Fri Dec 31 2399 23:59:00 GMT+0545","1767204900000 Thu Jan 01 2026 00:00:00 GMT+0545","1767204900000 Thu Jan 01 2026 00:00:00 GMT+0545","NaN Invalid Date","NaN Invalid Date","1767204900000 Thu Jan 01 2026 00:00:00 GMT+0545","1769883300000 Sun Feb 01 2026 00:00:00 GMT+0545","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2209009276000 Mon Jan 01 1900 00:00:00 GMT+0541","NaN Invalid Date","-2177473276000 Tue Jan 01 1901 00:00:00 GMT+0541","1769883300000 Sun Feb 01 2026 00:00:00 GMT+0545","1767550500000 Mon Jan 05 2026 00:00:00 GMT+0545"], + "order": ["NaN","NaN","-1737997",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], + "parsed": [["1768450500000","1768450500000"],["1768450500000","1768450500000"],["1768450500000","1768450500000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792874700000","1792874700000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768450500000","1768450500000"],["1768414500000","1768414500000"],["1768500840000","1768500840000"],["1768450500000","1768450500000"],["1768414500000","1768414500000"],["1768461300000","1768461300000"],["1768471200000","1768471200000"],["1768450500000","1768450500000"],["4118105700000","4118105700000"],["4118105700000","4118105700000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768500900000","1768500900000"],["1768450500500","1768450500500"],["1768450500123","1768450500123"],["1768450500000","1768450500000"],["NaN","NaN"],["NaN","NaN"],["788854500000","788854500000"],["504902400000","504902400000"],["1775334600000","1775334600000"],["1791059400000","1791059400000"],["1793475900000","1793475900000"]], + "single": ["1704067200000","988654500000","NaN","NaN","86400000","1709230500000","1709266500000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007144100000","1768450500000","1774745100250","NaN","Sun Mar 29 2026 06:30:00 GMT+0545","Sun Mar 29 2026 06:30:00 GMT+0545","string","true 1774730700000 2 Sun Mar 29 2026 02:30:00 GMT+0545","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767204900000","1780251300000","NaN","01/01/1970, 09:00:00 AM","01/01/1970, 05:30:00 AM","01/01/1970, 05:30:00 AM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","01/01/1970, 05:30:00 AM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] + }, + "Australia/Lord_Howe": { + "rows": [ + ["-5400000","45a717bc5d994c77","0b6bb11e71fd9d1f"], + ["-3600000","bdcb328d881dc187","7e69851ce40a05bb"], + ["-1800000","2fd26226654af4c6","03d33d7c96f32011"], + ["0","70f5c3896b41077b","d2ed2986d47e4985"], + ["1800123","12bb8778da145b46","c190382533c5f173"], + ["3600000","d208b236b0e2e9b8","d782953b65262b9b"], + ["5400000","db7cd37188ebb8fe","7eb20aa3e00a4fcf"], + ["-5400001","b2eebf6785908a78","29ce11ce6fdc4cdb"], + ["-3600001","9aa5286118b14d19","d1d14ce0ba5baf75"], + ["-1800001","c426681b5bf0785b","0825b42557fd7681"], + ["-1","8f5f75b6360687ce","c0c96612385a1c55"], + ["1800122","063024f2fe8b8525","34f0fcf2ed59fa29"], + ["3599999","aadf586a89a56276","28b7137c058ee9d1"], + ["5399999","daa7b0d1ca373dd0","23fe58224af8c4e1"], + ["-5399999","8550620f7a0296c8","30011d9ac900a087"], + ["-3599999","51862020d3793fb6","c467ca2e4b9f7e5f"], + ["-1799999","c997b628cd875181","9ac1f9bcf32a0acd"], + ["1","b1f39d2ff04c7d4e","743c57acc7e82605"], + ["1800124","71bafa19b7ff3723","034b5977fe06a67d"], + ["3600001","90d811758d1a2241","04a1f104253eaa77"], + ["5400001","83deee4f3b4370c5","5f04baf9544e4063"], + ["1699994600000","d3e3294f666cfe38","a7539b884bc9f8b1"], + ["1699996400000","866738808f7ce730","dd1d9e73208b839d"], + ["1699998200000","d136c55f34bf0c41","f0499bac2ea65689"], + ["1700000000000","a04d5ac7c2a3ab83","a129f12a4f56d961"], + ["1700001800123","b876d71147a90b6e","290629e217aaf0bd"], + ["1700003600000","c3193d57e9e2cea3","2a73e4078a10e8a5"], + ["1700005400000","0eb0a3141e47e0f2","5490daca6a8c411d"], + ["1768475096789","9031f8248f3fc5e1","a5c5db230a96b6c5"], + ["1768476896789","cd53fb697ff6d908","919056929e5fa021"], + ["1768478696789","ff1ae96bf54f827e","b1060eff1fc06c49"], + ["1768480496789","4e24d58d36dc0a61","28aa638833886761"], + ["1768482296912","250797a6e9020eb8","4d3c95e71114d151"], + ["1768484096789","04c21f4623f14cb2","dd44811f6c47dc7d"], + ["1768485896789","17d3952c8fc84150","b9ad5c4a7cc2495d"], + ["1774740600000","5162830e046de3bc","f2b7160412a1b2c1"], + ["1774742400000","220f18dbba3fb3ae","8f3fa7891077d051"], + ["1774744200000","79d1071cdb940194","8ba4ec914133ad91"], + ["1774746000000","370432e210f9d1d2","20c893cae511fdf1"], + ["1774747800123","9855a4c7fa08aadf","bafbccbe96b5eab5"], + ["1774749600000","8aafacb30162874d","8e6f067921f688b1"], + ["1774751400000","cb8a7d8b63d2f987","cda619ef53635489"], + ["1792884600000","dbafb3c903030eb5","fc0bd0d304ed73d1"], + ["1792886400000","6b26ee66056a519f","075023d5829ca3f5"], + ["1792888200000","7ff627961398cee9","3ebbb18b63f313ed"], + ["1792890000000","85296ede5ab04e33","2c3c9b3ae4574aed"], + ["1792891800123","1699198d10a141f2","289c78b4b05b4685"], + ["1792893600000","160e192e781a1f04","392c26ad6363f10d"], + ["1792895400000","73ae759dbfed6526","12cbd7eee3b24779"], + ["1772942400000","ef87478fb5adebe0","3038233e8b7ae459"], + ["1772944200000","84fc9df47560be4d","5855bd2bd3f327fd"], + ["1772946000000","8aed5f83300a2645","8ad002e398dda051"], + ["1772947800000","30cb9fce3c42fd95","ade90eeab56c23a9"], + ["1772949600123","7f362cd5d1763aa9","6cf835d400ebc36d"], + ["1772951400000","84af69c0dd29e62f","ed4e23b6b5eec411"], + ["1772953200000","b0150ce50b579ec3","3de68133e017cd69"], + ["1793502000000","80b5b6990bb1a81a","53f2aa7f2b2ad0ad"], + ["1793503800000","48f3ab382012e590","cc7db0a42aa6b305"], + ["1793505600000","6bb688562ddb38be","88f6a40eec7d8245"], + ["1793507400000","5d2c9a6d4f278c57","622267fa4fd275ad"], + ["1793509200123","2f8e5345b2d97c99","6bf7c8711ed0c5e1"], + ["1793511000000","8131a423394b70c8","dd68d47ae7e980c5"], + ["1793512800000","0317a6b3587e3722","09c132917c1ad3fd"], + ["788862600000","ecc5362c97a73382","2b5a8364da963699"], + ["788864400000","de4f792c77dd5963","6d5d88068146286f"], + ["788866200000","cb0ca6436685ec5e","02def445eef2d635"], + ["788868000000","f41a092758974596","1e65fa1c38a96be9"], + ["788869800123","19347568ffc14a49","e9342edad1a9d933"], + ["788871600000","82ee764314d529f9","39817391231b1cd1"], + ["788873400000","86949d113bea0c20","e7cf67d2d512d503"], + ["504895500000","076271c8be68e777","8ad5edeaa74ae23f"], + ["504897300000","96851ac3c3eb20c5","fa25355bdfc4381b"], + ["504899100000","5a0630bfb8b5add4","ae1873b396e750fb"], + ["504900900000","dd94edc713bfedac","82be28571cf372b3"], + ["504902700123","ee5cc89e0c174455","cd773b00a696418d"], + ["504904500000","ffb9f0e90b24d41d","78d27b1131cd27c7"], + ["504906300000","50d05bfc5a7ef601","c518ca4be4df490b"], + ["1775309400000","9945b3353a0344f0","2c45e85d15e8e8a9"], + ["1775311200000","637258f7e7b4ad30","539c189bbca1d931"], + ["1775313000000","2e2d4f532c00b9c4","20d07618eab83d11"], + ["1775314800000","7984a0abb7254b1d","20d07618eab83d11"], + ["1775316600123","ca36d8b93781f4ee","56a559589798545d"], + ["1775318400000","2abd43e203a92153","ce1441ed6bdbbf31"], + ["1775320200000","dc8f3b06ab944c36","9a34eee2d997edcd"], + ["1791036000000","98261562869b660a","1b2b2330cd73c211"], + ["1791037800000","cc12ab10df3b736b","a816b3bb546bbe3d"], + ["1791039600000","c3b56c5f2b46a43e","92d9b36ca46a2d89"], + ["1791041400000","d5bfc859602e54e9","2b97aa3cc94b2add"], + ["1791043200123","7993b8972ed2af83","71a5aab6ddae9ab5"], + ["1791045000000","47f1cf8e924e8573","11676286ecc66b19"], + ["1791046800000","e0d71ac4fb2a85bd","0a7474c5ed50bf31"], + ["-2422056600000","cecf2bf1e3af4c12","c3e2f6898d77e069"], + ["-2422054800000","82ebe36f783fdcf6","240bf0ea9b47a9c1"], + ["-2422053000000","745cb79953d0e3d0","e76ee11ca9290ae7"], + ["-2422051200000","ce5bbb6eca192256","632aca13b9c3370d"], + ["-2422049399877","28b9688c289b3d67","a013ef34b65b0081"], + ["-2422047600000","1d4aed1fd1239745","4fcc7cf0b2461959"], + ["-2422045800000","f24dda843a4ebf62","07b99b7e184bdbd5"], + ["-5364624600000","677e46641289d2b2","bac3aa1f324b4d07"], + ["-5364622800000","01a04d373eb335c4","ca3b5306b4184811"], + ["-5364621000000","9976f67919ce8afb","43d353fadbea4983"], + ["-5364619200000","eae9b9e9af6474a9","d3f936a9c0637221"], + ["-5364617399877","60429093d941b5ec","449c7a6de787c5bb"], + ["-5364615600000","215a18923feac4b6","969b4fdb3720c343"], + ["-5364613800000","37ef168198a3334e","7ecf833a8bad44ff"], + ["-2208994200000","b92d860f70582e18","4514a261637a2101"], + ["-2208992400000","a7a0241002e51f53","0d7ccda677cc1ac9"], + ["-2208990600000","445f898f28df13c5","ba662315809f5af5"], + ["-2208988800000","44cfe8b1790e8383","2a88a62390c825d7"], + ["-2208986999877","ed87811c334fcbcf","4b9279e5b1ce426f"], + ["-2208985200000","f402db363dc3ce4a","574c6825aa1daa3d"], + ["-2208983400000","6684a009dc55f85e","63acb4428d633785"], + ["4102435800000","2cdd885da96b7375","97335c60dcdcdbd9"], + ["4102437600000","80579bc88b8f3a41","fd4b362966819495"], + ["4102439400000","4c72ea45e64cef16","1fc6be5fa1b6f3d1"], + ["4102441200000","a52a6abeff1a2da7","c661265a799d9eb9"], + ["4102443000123","49229dddc264d868","4ce1aee41679ebd1"], + ["4102444800000","ebd0a4eae95ebaca","5a32ec9908ebb679"], + ["4102446600000","70509c94a8a84b4b","7f2bc9194f4b30d9"], + ["4109873400000","5b162be33091978d","b6ba3257f9577031"], + ["4109875200000","2ab38f880c5aef4f","74dfc8fa0971df89"], + ["4109877000000","c1fc59d781efd7c9","027ccfa75656bfa9"], + ["4109878800000","fe4eb7b6245aac7f","fb6c418d10623f05"], + ["4109880600123","073441e65995d2da","c5990d8f28cf2c35"], + ["4109882400000","e3ce190c5dfe2344","137d498d41163259"], + ["4109884200000","c01fc08c603c5456","ada1477fb9264379"], + ["4118121000000","c07b0a89170b7664","9734d76eaabdef89"], + ["4118122800000","598651952ec1c5cd","29d24d56e38bb0fd"], + ["4118124600000","9ddab1ac77c04e8d","1663e0d76ce58e69"], + ["4118126400000","eea05cc8ac138bf6","df0c1cf0d43f8389"], + ["4118128200123","ef23e4a64185d6c3","0ad7fd4050d5d135"], + ["4118130000000","74c73999a79039ea","f2e8bbd9c40c60a5"], + ["4118131800000","76972872d78f8b73","c4a5067919fe3c7d"], + ["8862129000000","bba574659bf89626","2e43d7ed3b6532dd"], + ["8862130800000","0c7a53a1dace7d5b","f134c04da995727d"], + ["8862132600000","4e8efe12e543bfea","d93690cae64f8165"], + ["8862134400000","5afe568e159f10f8","29d161beb4024c29"], + ["8862136200123","a0c49ee8ac29b4a2","c5035b400a2d7e5d"], + ["8862138000000","7c5fb6e75b30a45c","7904b5a9e902de8d"], + ["8862139800000","d46448a1441df045","470ab700317787d5"], + ["13569460140000","8db8a12fd60546cb","634ef33ab72a035b"], + ["13569461940000","7662d8b588ad296d","be0672eb05bc2093"], + ["13569463740000","19aef4c8774cc697","4e7456cddaf333a5"], + ["13569465540000","8254f3fcc14eb3db","5989aa5ae0f3a2f9"], + ["13569467340123","24d1562900f32792","3648de3e349efc0f"], + ["13569469140000","01af498df8ad78d4","9d67649783403e7f"], + ["13569470940000","ec4014df39d6eab1","fda8c53655ca183b"], + ["253402295399999","0ab9b614622a5803","3b3ad95a16b19d19"], + ["253402297199999","106a62ee0c5d748b","6df67cba874e3d85"], + ["253402298999999","e69b3c00bf7e6719","841457558469bf2d"], + ["253402300799999","c0beeca48d80107b","c9324cf9a818358d"], + ["253402302600122","cfada0c083cb53a0","f31201774e3a6a81"], + ["253402304399999","6014b850d340f1ce","71ffb138f851180d"], + ["253402306199999","2b9f6cf0cc029b85","2e24e00bd370367d"], + ["-2208994200000","b92d860f70582e18","4514a261637a2101"], + ["-2208992400000","a7a0241002e51f53","0d7ccda677cc1ac9"], + ["-2208990600000","445f898f28df13c5","ba662315809f5af5"], + ["-2208988800000","44cfe8b1790e8383","2a88a62390c825d7"], + ["-2208986999877","ed87811c334fcbcf","4b9279e5b1ce426f"], + ["-2208985200000","f402db363dc3ce4a","574c6825aa1daa3d"], + ["-2208983400000","6684a009dc55f85e","63acb4428d633785"], + ["-62184504600000","36a1a7c9891039bc","125441b7b3d2fc09"], + ["-62184502800000","a60cac72cf5dc488","72eda31b7da7d255"], + ["-62184501000000","9d58aeb6b3e98af2","c75afa481dfa5085"], + ["-62184499200000","5994e1583bdbcea0","dd5371b976fe1bbd"], + ["-62184497399877","6854bac68ed7a835","79121cf13a51dab9"], + ["-62184495600000","c7d812cb8e83a96f","87b8858bb03e4a0d"], + ["-62184493800000","bce6fe1176adcaca","6bc0fbfd7ba3200d"], + ["-8640000000000000","e19a8d36b448cac1","1bb801dd1a2f7cc9"], + ["-8639999998199877","f3b02c6fffca4cff","aea80c48b17b6ba9"], + ["-8639999996400000","3d18ff937ce38aaf","169d36c816aa243d"], + ["-8639999994600000","0197cfef7fa46f3d","e0b809403bd48da1"], + ["8639999994600000","9d07f29e8066f278","5d04ee5b14c94469"], + ["8639999996400000","3998fb655b62e29f","5d04ee5b14c94469"], + ["8639999998200000","97ded4734a167c95","5d04ee5b14c94469"], + ["8640000000000000","7ff630a4ce9dc522","5d04ee5b14c94469"], + ["-8640000000000000","e19a8d36b448cac1","1bb801dd1a2f7cc9"], + ["-8639999998199877","f3b02c6fffca4cff","aea80c48b17b6ba9"], + ["-8639999996400000","3d18ff937ce38aaf","169d36c816aa243d"], + ["-8639999994600000","0197cfef7fa46f3d","e0b809403bd48da1"], + ["8639999991000000","55263424fbb96207","5d04ee5b14c94469"], + ["8639999992800000","7992f7d6a1d0bf60","5d04ee5b14c94469"], + ["8639999994600000","9d07f29e8066f278","5d04ee5b14c94469"], + ["8639999996400000","3998fb655b62e29f","5d04ee5b14c94469"], + ["8639999998200123","97ded4734a167c95","5d04ee5b14c94469"], + ["8640000000000000","7ff630a4ce9dc522","5d04ee5b14c94469"], + ["-8639999919000000","e77b0860612e16c9","85ae17f29c51c215"], + ["-8639999917200000","0d6ce9ee869e1099","792d17fb9cb2fe35"], + ["-8639999915400000","38145f20852b011b","7957c94c3cb8e45d"], + ["-8639999913600000","3bcc3903e02ca921","b5e55507b3c32581"], + ["-8639999911799877","7f3037a5a034857c","746a68799c2232c9"], + ["-8639999910000000","ab7bffd8f11f93b2","f7b2e1b61719ed51"], + ["-8639999908200000","94da4c4bedcf86cb","c19437f4b9eeaa91"], + ["8599999994600000","5d0806db95c4ba14","daa98500e16cb1b7"], + ["8599999996400000","a3070b41c54ab15a","7ff22d80bb2e0ee9"], + ["8599999998200000","21840f45b36391bd","c8e9bd9ee50e230d"], + ["8600000000000000","7af77dd9ebbb6e11","d23ea5402e2877c1"], + ["8600000001800123","581ffc440498d956","ab1ef383fc819fd1"], + ["8600000003600000","79c8e1b95c039f19","f56b99bfc7cdc5f3"], + ["8600000005400000","25b3e3fa42f04e4a","40613bacaeed91db"], + ["-8600000005400000","6fb39dd3cb8d9ba9","b5a3b141bbc0cb35"], + ["-8600000003600000","d1f0803b296552a8","30db278a08de0005"], + ["-8600000001800000","6f22ff238aad8d1a","82c4c98e9a687549"], + ["-8600000000000000","dd22af150b7e3f87","14c965bf03719565"], + ["-8599999998199877","5713872f48116d78","5290d7aeb7a6afb1"], + ["-8599999996400000","9857f70a9ef5413d","1b46d98069eae211"], + ["-8599999994600000","58dc569bd88fcfdb","580e6ebd5b3ea59d"], + ["NaN","9a29e84c251c3a5d","8a90a0e4599bebb1"] + ], + "made": ["1774711800000 Sun Mar 29 2026 02:30:00 GMT+1100","1774709999999 Sun Mar 29 2026 01:59:59 GMT+1100","1774713600000 Sun Mar 29 2026 03:00:00 GMT+1100","1792855800000 Sun Oct 25 2026 02:30:00 GMT+1100","1792852200000 Sun Oct 25 2026 01:30:00 GMT+1100","1792857600000 Sun Oct 25 2026 03:00:00 GMT+1100","1772897400000 Sun Mar 08 2026 02:30:00 GMT+1100","1793457000000 Sun Nov 01 2026 01:30:00 GMT+1100","1793453400000 Sun Nov 01 2026 00:30:00 GMT+1100","1775313900000 Sun Apr 05 2026 01:45:00 GMT+1100","1775317500000 Sun Apr 05 2026 02:15:00 GMT+1030","1791042300000 Sun Oct 04 2026 02:45:00 GMT+1100","788835600000 Sat Dec 31 1994 12:00:00 GMT+1100","788792340000 Fri Dec 30 1994 23:59:00 GMT+1100","788878800000 Sun Jan 01 1995 00:00:00 GMT+1100","504882600000 Wed Jan 01 1986 00:10:00 GMT+1100","504881940000 Tue Dec 31 1985 23:59:00 GMT+1100","915109200000 Fri Jan 01 1999 00:00:00 GMT+1100","-2209024800000 Mon Jan 01 1900 00:00:00 GMT+1000","-62198793380000 Fri Jan 01 -0001 00:00:00 GMT+1036","-59011497380000 Fri Jan 01 0100 00:00:00 GMT+1036","915109200000 Fri Jan 01 1999 00:00:00 GMT+1100","-2209024800000 Mon Jan 01 1900 00:00:00 GMT+1000","8639999962200000 Sat Sep 13 275760 00:00:00 GMT+1030","8639999958600000 Fri Sep 12 275760 23:00:00 GMT+1030","NaN Invalid Date","NaN Invalid Date","4118045400000 Thu Jul 01 2100 00:00:00 GMT+1030","4109844600000 Sun Mar 28 2100 02:30:00 GMT+1100","8862103800000 Thu Oct 31 2250 02:30:00 GMT+1100","13569425940000 Fri Dec 31 2399 23:59:00 GMT+1100","1767186000000 Thu Jan 01 2026 00:00:00 GMT+1100","1767186000000 Thu Jan 01 2026 00:00:00 GMT+1100","NaN Invalid Date","NaN Invalid Date","1767186000000 Thu Jan 01 2026 00:00:00 GMT+1100","1769864400000 Sun Feb 01 2026 00:00:00 GMT+1100","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2209024800000 Mon Jan 01 1900 00:00:00 GMT+1000","NaN Invalid Date","-2177488800000 Tue Jan 01 1901 00:00:00 GMT+1000","1769864400000 Sun Feb 01 2026 00:00:00 GMT+1100","1767531600000 Mon Jan 05 2026 00:00:00 GMT+1100"], + "order": ["NaN","NaN","62003",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], + "parsed": [["1768431600000","1768431600000"],["1768431600000","1768431600000"],["1768431600000","1768431600000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792855800000","1792855800000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768431600000","1768431600000"],["1768395600000","1768395600000"],["1768481940000","1768481940000"],["1768431600000","1768431600000"],["1768395600000","1768395600000"],["1768442400000","1768442400000"],["1768471200000","1768471200000"],["1768431600000","1768431600000"],["4118088600000","4118088600000"],["4118088600000","4118088600000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768482000000","1768482000000"],["1768431600500","1768431600500"],["1768431600123","1768431600123"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["788835600000","788835600000"],["504882600000","504882600000"],["1775317500000","1775317500000"],["1791042300000","1791042300000"],["1793457000000","1793457000000"]], + "single": ["1704067200000","988637400000","NaN","NaN","86400000","1709211600000","1709247600000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007125200000","1768431600000","1774745100250","NaN","Sun Mar 29 2026 11:45:00 GMT+1100","Sun Mar 29 2026 11:45:00 GMT+1100","string","true 1774711800000 2 Sun Mar 29 2026 02:30:00 GMT+1100","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767186000000","1780234200000","NaN","01/01/1970, 09:00:00 AM","01/01/1970, 10:00:00 AM","01/01/1970, 10:00:00 AM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","01/01/1970, 10:00:00 AM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] + }, + "Etc/GMT+5": { + "rows": [ + ["-5400000","9d7c0b91374c2742","7ad68f7f21015ad3"], + ["-3600000","d541774ff04755d8","6b34c73b31d15477"], + ["-1800000","5caca5796d587fc9","407be5e9de989e63"], + ["0","f0c304563a5b9e9b","d2009231bb4dc27b"], + ["1800123","6a9ee4054fff4e18","891b41bed268b2eb"], + ["3600000","8ba3cbe89b25711f","196423bb0145694f"], + ["5400000","fe63197dd673a0f5","beb1f578abf59355"], + ["-5400001","e1174741bc3e571d","62a94db29c22eaa7"], + ["-3600001","c250c088976c85b8","c413fd2443373c17"], + ["-1800001","a8520b81747b7f44","1b687609813794c5"], + ["-1","2e16b6ecf44e60fd","0bee414d21a201d1"], + ["1800122","9fd4eb27943061ff","d1332f16cbf32e3f"], + ["3599999","9cf1ecb4eb37d0e2","d90e82eab54b8d6d"], + ["5399999","d89da38cf1a6d70b","bf5acb214297db53"], + ["-5399999","15af797d295ee1d1","189d56b4950e20b5"], + ["-3599999","1ee3719a279f2d21","f8febb1d83988df5"], + ["-1799999","82fe21ee0130ba3a","61132827871c0971"], + ["1","a118c355c1aaadda","5facbc2f2e830e51"], + ["1800124","b9301e09c4e6f8b1","217c483140990cb3"], + ["3600001","e26c3b95c8d24122","2c9416900ec9f2e1"], + ["5400001","5427e010a9c12e56","2f8e769d75756137"], + ["1699994600000","607b6b9a33bb3974","0e985a912cab48cd"], + ["1699996400000","837c239bae6892c4","ba58fad86c17345d"], + ["1699998200000","0cc1cde07b877ffb","ba1268b9ac970fad"], + ["1700000000000","3288b383396c0389","c8aeee8a04cce9c1"], + ["1700001800123","14ab714c601fc83a","5278e38905c9eb49"], + ["1700003600000","1671e62ef4d3d5ea","f69f8883be5d9405"], + ["1700005400000","987d953e7e6c3855","0f4368188513f4dd"], + ["1768475096789","ef5b36de673eb6af","dba8e39a39a98bbd"], + ["1768476896789","fc61affe8282c620","1a0aab2a601fd8dd"], + ["1768478696789","070f71b79102b7da","ba1e50187a98e9d5"], + ["1768480496789","d389d9dfcaceda17","c8762621a67da9d9"], + ["1768482296912","74f91dabce79eee3","efe3a650486adbd1"], + ["1768484096789","332c49877188026f","cfe31e2883e75529"], + ["1768485896789","9194d426b4ddc0c9","4ae0a6bc68355bb9"], + ["1774740600000","6a2b9467087fd3c8","7c5855e72a163191"], + ["1774742400000","0563ab945e729984","dcbbc98286224451"], + ["1774744200000","6ad69a3a333408be","774853edb7ea346d"], + ["1774746000000","14da489652984d7f","5efcdfef7ac83e85"], + ["1774747800123","6bfacbbb459706c8","85be235a34bad8b9"], + ["1774749600000","b5f5f65e4954be7e","4a995e06334360ed"], + ["1774751400000","f05f818323aa03f6","dfaa84f616c21f1d"], + ["1792884600000","538d20ee57e4754b","c04eb8d9575889a9"], + ["1792886400000","3cec514c249771bf","1cdc49e2022cfd21"], + ["1792888200000","f9f3e4f750911e85","021980efae134a55"], + ["1792890000000","59d7a56c565737b0","37f1c4b6b526aed9"], + ["1792891800123","f32a989763894d3f","bbd30ef06907586d"], + ["1792893600000","007cb467921433e9","1afe1878869932c9"], + ["1792895400000","e5583c9d2cf73ce9","63682c479a542e39"], + ["1772942400000","91195ecd0d0228cd","68bdd9ff299c14c9"], + ["1772944200000","966107011d7e1d42","8ecc3faf30438a49"], + ["1772946000000","d7c84a1bcc7d4f52","22d4afc5b16bce95"], + ["1772947800000","f9936f095126d23a","d6a1b7fc6c50e0ed"], + ["1772949600123","92260cbbac237650","02834bc5585652d9"], + ["1772951400000","a60e3daf67a1e1aa","a0cd41a56370aa69"], + ["1772953200000","25b55895309a735c","b3482c58d0194bb1"], + ["1793502000000","05e05a1842fed152","5a570a9f3b068ec9"], + ["1793503800000","fd1a9d0322782d74","0a211f0f09c7cd55"], + ["1793505600000","7a8f145ff9219922","75153f7033dbaa09"], + ["1793507400000","df56cb5368380a5b","2c9432832ff51fad"], + ["1793509200123","fa50597e65478586","48793122ea0e55e5"], + ["1793511000000","db892b29d45b49d3","d389daf4c4f54d25"], + ["1793512800000","21794363c8b016af","620a568f3f8b3d81"], + ["788862600000","dca15ce4fae15767","4c01a4639b999c99"], + ["788864400000","9275879ec0fa6663","d714a2fdc03dfd3f"], + ["788866200000","a5eeea5e9e1bb444","a3dc3c910d5e0099"], + ["788868000000","81deaee26de1a86c","e43c1cf6f4dcf19d"], + ["788869800123","48e62ebc500a07d1","a486dbae99408577"], + ["788871600000","67a78dae6b968b35","06c54da5193a5129"], + ["788873400000","b5ec92107ae4087a","e4e456c9b2516a1b"], + ["504895500000","248ddf49baa93d8e","62689f4c860f3def"], + ["504897300000","e5c74ff933527a08","b348ce639b7d0849"], + ["504899100000","e88d8bda2ae76459","bc8b6adf841949a3"], + ["504900900000","bc1af827ee25e5b1","1b8c75ae6fcd143b"], + ["504902700123","09e7813aeeaa67b4","9498bcd6739368f1"], + ["504904500000","a2a136afd5979a28","f5d5a04bf2f137db"], + ["504906300000","424deab1810e15b4","93635a66192fc891"], + ["1775309400000","f7f72159136c3ffa","db9635f0685a3cd9"], + ["1775311200000","e49f37375fca17f0","faed99998d9a2029"], + ["1775313000000","75f1ebbd689f4d78","06e2bb43364ac29d"], + ["1775314800000","743f6d77a5c0402f","0388aefa06fc2d01"], + ["1775316600123","4e5a31fc080cc397","9f421ffc8b97e285"], + ["1775318400000","f8265a2e5e11a4f7","24077cfb591a5bcd"], + ["1775320200000","d669b342bb161773","215203c13de99405"], + ["1791036000000","dd9b73c68c7edf23","d9ea595ea3a26e01"], + ["1791037800000","4252dc6b0f7e04e1","2c281421a8d28c65"], + ["1791039600000","123e6e82162dbb8a","303e433aa9bd7ed5"], + ["1791041400000","b76a5a2f25710ac8","d82a378cf6fdea99"], + ["1791043200123","2cc8e503b47e6e86","2d00499db8ab7181"], + ["1791045000000","ad6f119bd4da21c8","81f2182b5de94dad"], + ["1791046800000","624b28e7e0a6c3ee","6d3be1062c2af151"], + ["-2422056600000","b9dc25e414b4fe5a","45fb6626763f3fc1"], + ["-2422054800000","b1e05ff493ea9727","5e5cc551eadf2055"], + ["-2422053000000","288bb5344159f919","0cbfce89aeb6e7d1"], + ["-2422051200000","1e1ec85d6cae4eda","42268179e07c8d65"], + ["-2422049399877","12d859f557f9442c","e7b58ed62a81a1ab"], + ["-2422047600000","04be4fe65cf4326a","0916ccb664f74065"], + ["-2422045800000","e0be52f0e3e5a0fe","3db0fa78c75077d9"], + ["-5364624600000","aaf1c3ca1f229116","6e650373dda01005"], + ["-5364622800000","7081793bc16b1757","62b65544a82638f9"], + ["-5364621000000","c3a2e4939cb0e335","f1ea39382e020c7f"], + ["-5364619200000","422eaee14a8c456e","cc8ed6169531e3eb"], + ["-5364617399877","01e6a5f8d7391b38","b413d7ceb31e1c99"], + ["-5364615600000","c32c368a89fea131","8663acdddc528edd"], + ["-5364613800000","4cf96b0e64ca50cb","cad499d8391b3b1b"], + ["-2208994200000","073cde52d149ea6f","b044dc5e7cbbf697"], + ["-2208992400000","d48b3485f9c05860","0592f96f12c1eddb"], + ["-2208990600000","e58c5ddc8f3023ca","10d07fc398c02c59"], + ["-2208988800000","c7c158c440bf926b","290d1d59375c9da7"], + ["-2208986999877","5ffddf45a2bef0a9","5d581f022c2d48c9"], + ["-2208985200000","748a2e1b21dd1bc3","100bdb0791d9fc9b"], + ["-2208983400000","fed16acf68db1ec7","d27c11403f4f8f91"], + ["4102435800000","3fe98ef1eedd2f98","dd5fca042b0be3f5"], + ["4102437600000","28cc270293a3936c","04cd88f60038dc8d"], + ["4102439400000","d01d8ff6eac4dcbb","8bbddfc718018529"], + ["4102441200000","a95682b0db4fec67","a6ee3ece70dabb41"], + ["4102443000123","950d84ca2a4e755e","9ddfd1eb0fbabf5d"], + ["4102444800000","d24c4d12bd1a086e","2aff0f85f77ffe25"], + ["4102446600000","0787d62a941257f1","8070b4e018f038f5"], + ["4109873400000","7154e6f7066e3efd","88bb78dd8ada18d5"], + ["4109875200000","4de396ce201af6b5","bff3edf37e7f4941"], + ["4109877000000","a8c57aa4612d931b","d730f8efbdcf7265"], + ["4109878800000","53adeb5ae7e1b236","ff39ff6e828c7365"], + ["4109880600123","a05ec40bc446129d","2fcc8316c60216e9"], + ["4109882400000","ecffada0167a7cb7","dc59daaa6d9f905d"], + ["4109884200000","836e9de91b7b5f6b","7496e8b5b3310ed9"], + ["4118121000000","635abe76a5b35f00","165a2b4ec272b50d"], + ["4118122800000","91b4c6373e207aaa","05505390e478289d"], + ["4118124600000","c6e2a26ba7226d05","ced7312a2b83a151"], + ["4118126400000","dd47307eb933ce17","bb3c51a25d6d48ed"], + ["4118128200123","2d4971fa7ebfca0b","96c7f48edfe08b3d"], + ["4118130000000","553168bb6722fc69","1141cf9b8d8c6cf1"], + ["4118131800000","02aa17f44bd6cede","0d74eb6937e13da9"], + ["8862129000000","aa3939a3b16f1aaa","82f812fd5cea067d"], + ["8862130800000","96cc13b7cdd4481c","9667ba08cc9bbe01"], + ["8862132600000","19a86a27a101967f","cdcd2878d334897d"], + ["8862134400000","c8e5b14edc4018a5","b73bc1932581c7a9"], + ["8862136200123","7ab9db3fc1ec33f9","9ad84adc36a5ccdd"], + ["8862138000000","29297ceb3faa4dfa","7a24afc5209a6ccd"], + ["8862139800000","796d8063168f2cbb","b0d7ef4081eae915"], + ["13569460140000","504ad28fd36d2900","4883fe999fd31827"], + ["13569461940000","a13476453a64d5ba","139497f3c0fd1de9"], + ["13569463740000","47f35d1eb9f2e253","1d4292f393c14957"], + ["13569465540000","e36fe705204033db","0b8a5b0e90b7adf5"], + ["13569467340123","656c568cac2665f6","3e1011de7553107f"], + ["13569469140000","6a122c11110a0ddc","4f746f8a689d7f5b"], + ["13569470940000","085170f947a6ef90","02fda87bc979d399"], + ["253402295399999","05b6dc82d019e666","c06ba7ceb16c1b09"], + ["253402297199999","712c57c65a560446","8aada719fa0e7a09"], + ["253402298999999","22655183c48d723d","cf5e9b134e6f9de5"], + ["253402300799999","5ad5acdd73a8f26f","404ee567f8df3b3d"], + ["253402302600122","b751b24b839b050a","34ffae1318d668dd"], + ["253402304399999","ff04604d755443f0","e224a9bb42cbc2a1"], + ["253402306199999","f6d49fcb735cba78","dc990ede207a9fd9"], + ["-2208994200000","073cde52d149ea6f","b044dc5e7cbbf697"], + ["-2208992400000","d48b3485f9c05860","0592f96f12c1eddb"], + ["-2208990600000","e58c5ddc8f3023ca","10d07fc398c02c59"], + ["-2208988800000","c7c158c440bf926b","290d1d59375c9da7"], + ["-2208986999877","5ffddf45a2bef0a9","5d581f022c2d48c9"], + ["-2208985200000","748a2e1b21dd1bc3","100bdb0791d9fc9b"], + ["-2208983400000","fed16acf68db1ec7","d27c11403f4f8f91"], + ["-62184504600000","21b2660baa95927e","8f571be95d715a81"], + ["-62184502800000","772787d48f07ddc3","532e250e33de2a7d"], + ["-62184501000000","0d4206bdb515297d","b20292928dd07c69"], + ["-62184499200000","945f3ff70d7f0242","b2c075309da6720d"], + ["-62184497399877","163b5223b217f28c","739c50f69aa8d1dd"], + ["-62184495600000","2bed7da2ebeb6b0c","e280d3c25b8bd845"], + ["-62184493800000","9a475ad2cd665604","fd1905fdd7357e11"], + ["-8640000000000000","61897e866ced149a","5d04ee5b14c94469"], + ["-8639999998199877","1edbfdb7461b2c2c","5d04ee5b14c94469"], + ["-8639999996400000","479a9d7d3a31066f","5d04ee5b14c94469"], + ["-8639999994600000","efb435e80d45dc2f","5d04ee5b14c94469"], + ["8639999994600000","078e5ac6aaae0e1c","659a8855322a2ec7"], + ["8639999996400000","a088f2783509681d","96de255b577c354d"], + ["8639999998200000","8a2bead5622aeea0","bcb0a078e980127b"], + ["8640000000000000","a5d7640c75bdf651","f36e6e5a59651bad"], + ["-8640000000000000","61897e866ced149a","5d04ee5b14c94469"], + ["-8639999998199877","1edbfdb7461b2c2c","5d04ee5b14c94469"], + ["-8639999996400000","479a9d7d3a31066f","5d04ee5b14c94469"], + ["-8639999994600000","efb435e80d45dc2f","5d04ee5b14c94469"], + ["8639999991000000","872211faf464adfc","0a516abc1d7998c9"], + ["8639999992800000","c592cbf295801805","1f708cd4a1958477"], + ["8639999994600000","078e5ac6aaae0e1c","659a8855322a2ec7"], + ["8639999996400000","a088f2783509681d","96de255b577c354d"], + ["8639999998200123","8c094f0248a79024","b6cae9e436e1b6bf"], + ["8640000000000000","a5d7640c75bdf651","f36e6e5a59651bad"], + ["-8639999919000000","349c3abb1bf5c101","c70c4bbff882d2e5"], + ["-8639999917200000","2c390002ed60d244","1e5dd0e8c070f461"], + ["-8639999915400000","88665a4db264f1d6","66a7bdd880df4e99"], + ["-8639999913600000","cf6bfae9548b23e5","b8efe7e8d9b8421d"], + ["-8639999911799877","d65e78416567f9eb","f0e0248863da9ded"], + ["-8639999910000000","ae1b18221c7e53bb","1a32b4a91173b8b1"], + ["-8639999908200000","100b9230f711ce93","12d9f8fcba06aab5"], + ["8599999994600000","62c1d14994b56a3b","d9fd0166d1b3ee71"], + ["8599999996400000","cc21f3c97e3fc473","da9dafced5e27adb"], + ["8599999998200000","9d0bebb94efcdb88","04a6f07e8ecd5265"], + ["8600000000000000","3df41f90529271b2","8ea352e7f63a40e9"], + ["8600000001800123","4720f0ec30e8ab42","c97792d232bb2607"], + ["8600000003600000","c557f92886384553","1cc92707bee110cf"], + ["8600000005400000","0187992d6abe099c","462039f60ff3a57d"], + ["-8600000005400000","140dc07d40751ac9","066e2f26de2d758d"], + ["-8600000003600000","594f9af703681dbf","76e4850a76f1b1d9"], + ["-8600000001800000","c7d45ed44355c952","5b4fe7a479d39aa1"], + ["-8600000000000000","8ccbc2cbd21eee24","de5599a21d3e4ae9"], + ["-8599999998199877","c75373f09852dbc3","b64f22b0f6329a55"], + ["-8599999996400000","d22297af2a6629c5","2841075ea6fc1b35"], + ["-8599999994600000","3969a8f6007141a0","a02f00dc3d2a8d29"], + ["NaN","9a29e84c251c3a5d","8dffca962988e3a5"] + ], + "made": ["1774769400000 Sun Mar 29 2026 02:30:00 GMT-0500","1774767599999 Sun Mar 29 2026 01:59:59 GMT-0500","1774771200000 Sun Mar 29 2026 03:00:00 GMT-0500","1792913400000 Sun Oct 25 2026 02:30:00 GMT-0500","1792909800000 Sun Oct 25 2026 01:30:00 GMT-0500","1792915200000 Sun Oct 25 2026 03:00:00 GMT-0500","1772955000000 Sun Mar 08 2026 02:30:00 GMT-0500","1793514600000 Sun Nov 01 2026 01:30:00 GMT-0500","1793511000000 Sun Nov 01 2026 00:30:00 GMT-0500","1775371500000 Sun Apr 05 2026 01:45:00 GMT-0500","1775373300000 Sun Apr 05 2026 02:15:00 GMT-0500","1791098100000 Sun Oct 04 2026 02:15:00 GMT-0500","788893200000 Sat Dec 31 1994 12:00:00 GMT-0500","788849940000 Fri Dec 30 1994 23:59:00 GMT-0500","788936400000 Sun Jan 01 1995 00:00:00 GMT-0500","504940200000 Wed Jan 01 1986 00:10:00 GMT-0500","504939540000 Tue Dec 31 1985 23:59:00 GMT-0500","915166800000 Fri Jan 01 1999 00:00:00 GMT-0500","-2208970800000 Mon Jan 01 1900 00:00:00 GMT-0500","-62198737200000 Fri Jan 01 -0001 00:00:00 GMT-0500","-59011441200000 Fri Jan 01 0100 00:00:00 GMT-0500","915166800000 Fri Jan 01 1999 00:00:00 GMT-0500","-2208970800000 Mon Jan 01 1900 00:00:00 GMT-0500","NaN Invalid Date","NaN Invalid Date","-8639999982000000 Tue Apr 20 -271821 00:00:00 GMT-0500","NaN Invalid Date","4118101200000 Thu Jul 01 2100 00:00:00 GMT-0500","4109902200000 Sun Mar 28 2100 02:30:00 GMT-0500","8862161400000 Thu Oct 31 2250 02:30:00 GMT-0500","13569483540000 Fri Dec 31 2399 23:59:00 GMT-0500","1767243600000 Thu Jan 01 2026 00:00:00 GMT-0500","1767243600000 Thu Jan 01 2026 00:00:00 GMT-0500","NaN Invalid Date","NaN Invalid Date","1767243600000 Thu Jan 01 2026 00:00:00 GMT-0500","1769922000000 Sun Feb 01 2026 00:00:00 GMT-0500","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2208970800000 Mon Jan 01 1900 00:00:00 GMT-0500","NaN Invalid Date","-2177434800000 Tue Jan 01 1901 00:00:00 GMT-0500","1769922000000 Sun Feb 01 2026 00:00:00 GMT-0500","1767589200000 Mon Jan 05 2026 00:00:00 GMT-0500"], + "order": ["NaN","NaN","62003",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], + "parsed": [["1768489200000","1768489200000"],["1768489200000","1768489200000"],["1768489200000","1768489200000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792913400000","1792913400000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768489200000","1768489200000"],["1768453200000","1768453200000"],["1768539540000","1768539540000"],["1768489200000","1768489200000"],["1768453200000","1768453200000"],["1768500000000","1768500000000"],["1768471200000","1768471200000"],["1768489200000","1768489200000"],["4118144400000","4118144400000"],["4118144400000","4118144400000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768539600000","1768539600000"],["1768489200500","1768489200500"],["1768489200123","1768489200123"],["1768489200000","1768489200000"],["NaN","NaN"],["NaN","NaN"],["788893200000","788893200000"],["504940200000","504940200000"],["1775373300000","1775373300000"],["1791098100000","1791098100000"],["1793514600000","1793514600000"]], + "single": ["1704067200000","988693200000","NaN","NaN","86400000","1709269200000","1709305200000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007182800000","1768489200000","1774745100250","NaN","Sat Mar 28 2026 19:45:00 GMT-0500","Sat Mar 28 2026 19:45:00 GMT-0500","string","true 1774769400000 2 Sun Mar 29 2026 02:30:00 GMT-0500","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767243600000","1780290000000","NaN","01/01/1970, 09:00:00 AM","12/31/1969, 07:00:00 PM","12/31/1969, 07:00:00 PM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","12/31/1969, 07:00:00 PM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] + }, + "Europe/Berlin": { + "rows": [ + ["-5400000","d4196993d68cdb27","0473109fc2a4260d"], + ["-3600000","1d367b7d7afeb164","b4d00052aff34b1b"], + ["-1800000","97ebb24ccc397fa1","a61ec4a9966c047d"], + ["0","1a3a9a733783be11","aa6595dd01db21c3"], + ["1800123","ade9b790b62aa5d2","fc7f9d18f13d0043"], + ["3600000","73d0a40d96579906","b3be43a2272e27c1"], + ["5400000","869443ea71aaf4ea","9e426a75c4e8db77"], + ["-5400001","4e801406bb4e9e96","6e13eeee772654b1"], + ["-3600001","1dea633d418ba8c3","90b760f7b279c3fd"], + ["-1800001","4856b131852b57a0","2d0b45a1c89a85bd"], + ["-1","35cfa054613d45f7","5ef6bd51646dd4c5"], + ["1800122","0b82ee9475a733a3","a23e7d2248717845"], + ["3599999","dd2f76f8958cb49a","53c98bc3556fe18d"], + ["5399999","b236c0ba4cecbc62","d5eab214509a1c9d"], + ["-5399999","b7bf90207254e880","4d9a065a6a0f9f15"], + ["-3599999","9fcb47ffbcd09b97","4b98e9241cab883d"], + ["-1799999","d51274082787bb24","db61cf83ad9a8fb9"], + ["1","c2ca0a4ab276bf4a","f94a5aba7b32484b"], + ["1800124","5282dc256b726595","ffe3c5fd2fb84455"], + ["3600001","85f32195ef512309","cb80cee278420c51"], + ["5400001","491ccd0b9a6762eb","ead4868d73c8ed5b"], + ["1699994600000","0be0d60f8cbb4d95","b2fd89c21f276201"], + ["1699996400000","158ba645caba24b1","4efff1c99601f7c5"], + ["1699998200000","aff227060df0b1ca","f650ed40d69c9179"], + ["1700000000000","67825702ee31c3c0","63c168f65ee2ca19"], + ["1700001800123","3dbfeaf30bf888e3","39f151e2e7293829"], + ["1700003600000","d9dc48e8467f8836","09fab7c2e44c2ffd"], + ["1700005400000","c795c7be01720a49","401667642ea088a5"], + ["1768475096789","6ebc364fe47ae6ba","404b4bd65a53060d"], + ["1768476896789","93126585202303ab","0d9f6e745ac55941"], + ["1768478696789","021636226edcf71b","cc60ec72dc0927c9"], + ["1768480496789","6b6f8d1ebab652a4","b473621a7db12469"], + ["1768482296912","452f73d9ab4a9676","1bdd2e9ea1e538b9"], + ["1768484096789","06ffa3358588b1c8","1171af3f3bce5925"], + ["1768485896789","74a6a1ca14a855b4","5b17eb5f502acf9d"], + ["1774740600000","fd416c59034ec901","cb7792067614bf7d"], + ["1774742400000","1edbcdbae35163c5","5b293b30352c6995"], + ["1774744200000","047da56abd641627","6f738d2da9dea149"], + ["1774746000000","bcc7abeaf9063de9","8f1620d842c34931"], + ["1774747800123","c8cf7bb4d6d7afc4","a2535cb58ff4ab2d"], + ["1774749600000","e7b3e9aaa258e03c","832c69c092e68751"], + ["1774751400000","917d61466c06e952","e148b3c57b05f5cd"], + ["1792884600000","fdfccafbcb2cd47a","01534b51872c5dad"], + ["1792886400000","ab4714c947628a7a","1a0773fed1d57eb1"], + ["1792888200000","168a6a4592f6c04c","541959a9ef12b089"], + ["1792890000000","2646f2c1906c87cc","1a0773fed1d57eb1"], + ["1792891800123","513c1151617c82d5","8eb2b48a0cf3be89"], + ["1792893600000","7c9636bb4f437edd","fe3824c79bb91279"], + ["1792895400000","1650ca4b1849450f","c0ecc4076ef44ef9"], + ["1772942400000","0d679a0701725547","97685b32136be719"], + ["1772944200000","f8a90086f7f3cdee","c87522ce52e8c525"], + ["1772946000000","d24bb028ff5363a0","dd777691d6b7d919"], + ["1772947800000","f8d3c9dc650f4fb0","9b95fc2bb8d42389"], + ["1772949600123","2f984bac59dc5526","d74a36a46d307775"], + ["1772951400000","4ea5394a2e04d288","21a6e4fc5690be89"], + ["1772953200000","6390fcd5801a5cba","031d69c25e120729"], + ["1793502000000","edb7b32747e47c8f","f9d1fc2ef184462d"], + ["1793503800000","f0447a29068d4441","e93eecd54667b2dd"], + ["1793505600000","dc5ebd0c391328bd","fc685ae32fe9f1c1"], + ["1793507400000","015e064ebde16140","98936a0f58dbc1c5"], + ["1793509200123","96c1aa57dfa062b8","ec7354e08d697dbd"], + ["1793511000000","859238642c1920cd","325ec0925aa1d31d"], + ["1793512800000","45f8ee83d002fc29","2dfb0b381cd7b9d9"], + ["788862600000","3ad457dce1c9b9ad","90919604195e663f"], + ["788864400000","ed997cd6c74e862e","ef0aaba6878db9d9"], + ["788866200000","0d5a2a547c6c3d7f","2bf8be5d735ac2eb"], + ["788868000000","9557783b83a17c55","e2b1fedd1f35bbd7"], + ["788869800123","749905305e8e69aa","d0dda4f0a7ac3a39"], + ["788871600000","701d0f18421bbe64","da92a7fd865a2657"], + ["788873400000","a089134ac9c184f1","b4ada836e3af02a9"], + ["504895500000","3c29792221983bd4","9ddcafb611e4a839"], + ["504897300000","8103a52bb642a44e","e6f7a59b5cfa945f"], + ["504899100000","f0efdbe52528c67b","30c70134fc978ad9"], + ["504900900000","17c0300315379f13","9154a8b2fe087749"], + ["504902700123","4b0a4de4f0b3c962","c2aeb702d2671dcf"], + ["504904500000","fdc6c68eb5114c21","e64ce20661d24dbd"], + ["504906300000","29485a8ef3b7bdd1","26a8fd79e5cb6e7b"], + ["1775309400000","8297d0a6aec9ae9b","1b4fe81ff24f2c9d"], + ["1775311200000","e9b81dc05e08735b","b4548689bd7c7929"], + ["1775313000000","0e20f068b3e65861","8bd716f9dfde5479"], + ["1775314800000","b3fae4ac81053e7d","10c12ff7a43eea95"], + ["1775316600123","8afecfa9c94fc0dd","aeb135daeed2d095"], + ["1775318400000","ee98fe75cd509fe5","753424d173c151b9"], + ["1775320200000","c957afac6e2100d5","a501c1c5e8153591"], + ["1791036000000","e7242443fcfdc6ac","acb1134cdadf6e81"], + ["1791037800000","f690c729458de830","defa4beaeaaf501d"], + ["1791039600000","a62e9c4aa1f3c3d6","f4595b8ececb571d"], + ["1791041400000","90b5bd4ded29ecd0","c6c14245c9d02cad"], + ["1791043200123","45094d29c97a652a","201eb274b5a335f1"], + ["1791045000000","01bd40c951da2f1c","365e037e57a45821"], + ["1791046800000","b21070c902b0141a","99572f6a4f8bb169"], + ["-2422056600000","141c2cd6e428c530","9ebc837fdec0f60b"], + ["-2422054800000","879f3bd28873fc42","7a84efe11191fb47"], + ["-2422053000000","388b8892d29015eb","e18f8e8c34204081"], + ["-2422051200000","355f7f53101bb582","2ed2117edd8d34c1"], + ["-2422049399877","183bd465fa106fba","62d3d04712425ccf"], + ["-2422047600000","84346531fabc4c6d","d6e19b752932d0df"], + ["-2422045800000","d517896bec8ef68d","97280c9ed6658ba5"], + ["-5364624600000","bce846e43c598912","16bdb59e8f87e883"], + ["-5364622800000","684069243670621c","64bab496ca44a3c5"], + ["-5364621000000","5ea5a24a29d63af5","10883a01f691d101"], + ["-5364619200000","95d9959fe0167561","c0f367f965eccd23"], + ["-5364617399877","d6b977b6b1b3dd64","d6ae23ddc5bb0b6f"], + ["-5364615600000","414b50c37ee05de2","3b0abf590d4a0a77"], + ["-5364613800000","835eb7223b4e3abb","2ff66b9942f361d9"], + ["-2208994200000","801885f287b0a292","49f9e48451d5a239"], + ["-2208992400000","70f83fae62974472","5f6bb72b783bffd9"], + ["-2208990600000","f97b64d2074a3510","c2d92b78c6b5e623"], + ["-2208988800000","d2cd095a048d0e89","52c72ab3c10b2255"], + ["-2208986999877","377f721ab6867d5b","515e5338e7be7809"], + ["-2208985200000","12503e0c59b4f6f0","a5200455b4acf7c3"], + ["-2208983400000","4b5a84174d55bd82","9a1aba416b9fcf27"], + ["4102435800000","be3a79ef8b4a1a4b","3c3bf3c8bd5d6f39"], + ["4102437600000","64e37f3a5abbca29","7c5fb4ed43ac5659"], + ["4102439400000","fbf77c3550589b10","c102ca01704ba009"], + ["4102441200000","d8faa21f5ef460f6","83d064632ecefa63"], + ["4102443000123","033076e65a0da5b9","bdc0bbef24aa0421"], + ["4102444800000","0596d4325b869129","91f8998c86c2d645"], + ["4102446600000","af73aece7768ec14","d1fcc5cc063a5f2d"], + ["4109873400000","18f7d89a8c72ffb0","7404eb269df72059"], + ["4109875200000","7c1be661968a94fc","1d9daa6364ad4c45"], + ["4109877000000","1b25d0e4262851f2","df4a7e2c1819f751"], + ["4109878800000","6a5c6cd7e5151b78","529a2760c55192f9"], + ["4109880600123","5e75fcae73e958b5","cce481d430682d3d"], + ["4109882400000","97808ae9041328c9","5c8c0c3e0aaa7b25"], + ["4109884200000","b2362b628fc7f4cf","353871ccadcdf4c9"], + ["4118121000000","420278051745d263","ed3b3c4fcd8eb851"], + ["4118122800000","1e8c5bdb85a2a347","63f74844eecd7cbd"], + ["4118124600000","503ab6dc724945aa","7a58f9bd3989ddd9"], + ["4118126400000","c0bcb25aadc39cfe","a4870eb4965a01ad"], + ["4118128200123","da06881546524b24","6efd911ca2d3e571"], + ["4118130000000","ab9ef64de0ebd998","35f63b31195222c1"], + ["4118131800000","bfccf161359058ed","8d2bb86f3ad0366d"], + ["8862129000000","c97fff33475832a3","820f4bd575ee48dd"], + ["8862130800000","b06e026455af48ec","8161236640bae373"], + ["8862132600000","763d99ab1b1115f9","ee669f875bec91e9"], + ["8862134400000","d400b9403ff1cd01","d9f756ab75de4a39"], + ["8862136200123","4e3e9f7eb6acd35b","7eeda6bd2ca0c591"], + ["8862138000000","e3bfe46f9cd5a7a3","2ecd56d1ee7845e9"], + ["8862139800000","50da0039ad9ecece","5468340676aa1639"], + ["13569460140000","2450327f07f67aaf","885989f6e987a0a9"], + ["13569461940000","1768bd08bd3736ed","f7455e55b497b5f5"], + ["13569463740000","a9e3eba51ca6046e","716d28cf138adb1b"], + ["13569465540000","d35ffce337332148","02b4122a7a861595"], + ["13569467340123","7b3851e2912dd4f9","36442574f8e764dd"], + ["13569469140000","6bbeb26bdb689981","19e520bc012d7ca7"], + ["13569470940000","ef0cabbbf2bcbdf0","d168361eb36ec265"], + ["253402295399999","0d2bbb1753909b03","03101dd7c33cbeb1"], + ["253402297199999","04f80d7aab5b6c7b","3cebc5c1429631a5"], + ["253402298999999","dce4d0660506ed2e","c36f6d5425e1a06d"], + ["253402300799999","6606f298b79a355e","7760a849cc1ddd2d"], + ["253402302600122","12f58acf5dd49bb1","6379b7412bab8881"], + ["253402304399999","5c7a5251e636736b","c131f573b464979d"], + ["253402306199999","9f7b5ffc3d74cd36","8ecccded20e75e21"], + ["-2208994200000","801885f287b0a292","49f9e48451d5a239"], + ["-2208992400000","70f83fae62974472","5f6bb72b783bffd9"], + ["-2208990600000","f97b64d2074a3510","c2d92b78c6b5e623"], + ["-2208988800000","d2cd095a048d0e89","52c72ab3c10b2255"], + ["-2208986999877","377f721ab6867d5b","515e5338e7be7809"], + ["-2208985200000","12503e0c59b4f6f0","a5200455b4acf7c3"], + ["-2208983400000","4b5a84174d55bd82","9a1aba416b9fcf27"], + ["-62184504600000","2e4cb1fa144d71da","257a1fb38e333fa1"], + ["-62184502800000","413a29f03c0d149c","66e787ac869ad241"], + ["-62184501000000","4233da7c0618b2e2","16880dc7adeea8d5"], + ["-62184499200000","32dbc41d39d78ae2","87d0e01f700b2d9d"], + ["-62184497399877","c1bf729a0885aad9","f4b171cef91c7e45"], + ["-62184495600000","d9f1dfa2ccd01653","7f0e5689ba92bc39"], + ["-62184493800000","f09267db758009c6","e1cba6d7c18b2f15"], + ["-8640000000000000","b91042eddd49e8b3","c5c57b92e097c165"], + ["-8639999998199877","bce357f6fb279b1b","ed6d50d5c7a653e5"], + ["-8639999996400000","fa1f6a204e76d43f","baade4ba1c14657d"], + ["-8639999994600000","13e68dbea7b45589","637e37ecf7f27c99"], + ["8639999994600000","f87d3c5d84ab6df0","5d04ee5b14c94469"], + ["8639999996400000","597daff757e2196f","5d04ee5b14c94469"], + ["8639999998200000","ec5fbe02ab56fecd","5d04ee5b14c94469"], + ["8640000000000000","99f0f3a5f754b302","5d04ee5b14c94469"], + ["-8640000000000000","b91042eddd49e8b3","c5c57b92e097c165"], + ["-8639999998199877","bce357f6fb279b1b","ed6d50d5c7a653e5"], + ["-8639999996400000","fa1f6a204e76d43f","baade4ba1c14657d"], + ["-8639999994600000","13e68dbea7b45589","637e37ecf7f27c99"], + ["8639999991000000","d5b08275c680f74d","f6830889fd662f6b"], + ["8639999992800000","e91d5ea1f6b96be5","d136abbb0a951ab1"], + ["8639999994600000","f87d3c5d84ab6df0","5d04ee5b14c94469"], + ["8639999996400000","597daff757e2196f","5d04ee5b14c94469"], + ["8639999998200123","ec5fbe02ab56fecd","5d04ee5b14c94469"], + ["8640000000000000","99f0f3a5f754b302","5d04ee5b14c94469"], + ["-8639999919000000","1f53b612b7d170ad","88b0186134a4a2e5"], + ["-8639999917200000","13ab869e8a45ad57","08c0a0724a6058e1"], + ["-8639999915400000","db2eec37572cc5bb","784efc4eab60c2d9"], + ["-8639999913600000","3d1d0e8e711d3bcb","97da79ecbf1aaac1"], + ["-8639999911799877","c1315bdaa333cc70","e87f1ed5f7f51f45"], + ["-8639999910000000","d83297f2c3801e1e","a2642c27b1c5b371"], + ["-8639999908200000","8a69c1d5a65a664f","9338f7ce9e802179"], + ["8599999994600000","ddc73dce53c8ad23","918f6ebff88c3ce7"], + ["8599999996400000","588e79a7603aa2f7","1a238f404f417665"], + ["8599999998200000","933b1dab91a8de10","d51ea068ef4a07ed"], + ["8600000000000000","0b6b65009d9aa30a","434b903c7d565de9"], + ["8600000001800123","52672efb1e446db5","0a928f787d806429"], + ["8600000003600000","4cc86688ac4c5e48","5d6f073ceaee2603"], + ["8600000005400000","0cad5dd7f5901edf","287a7ab340584d63"], + ["-8600000005400000","8926be577fb2ae15","47bce89136b124d1"], + ["-8600000003600000","edceea3455988c7d","3a44b9b5d649a87d"], + ["-8600000001800000","6c9a8132ec45097e","80b7685e77256511"], + ["-8600000000000000","c4e9f6d29b14068b","cea69f9e2906b901"], + ["-8599999998199877","f80c2cb3974d0b3a","0b5448a38b9d753d"], + ["-8599999996400000","e20e5eeaec7bbc88","1e3052e74fbc6681"], + ["-8599999994600000","962c239dc0351543","8006b34d6a3e224d"], + ["NaN","9a29e84c251c3a5d","6dcc1c8a2dafb85f"] + ], + "made": ["1774747800000 Sun Mar 29 2026 03:30:00 GMT+0200","1774745999999 Sun Mar 29 2026 01:59:59 GMT+0100","1774746000000 Sun Mar 29 2026 03:00:00 GMT+0200","1792888200000 Sun Oct 25 2026 02:30:00 GMT+0200","1792884600000 Sun Oct 25 2026 01:30:00 GMT+0200","1792893600000 Sun Oct 25 2026 03:00:00 GMT+0100","1772933400000 Sun Mar 08 2026 02:30:00 GMT+0100","1793493000000 Sun Nov 01 2026 01:30:00 GMT+0100","1793489400000 Sun Nov 01 2026 00:30:00 GMT+0100","1775346300000 Sun Apr 05 2026 01:45:00 GMT+0200","1775348100000 Sun Apr 05 2026 02:15:00 GMT+0200","1791072900000 Sun Oct 04 2026 02:15:00 GMT+0200","788871600000 Sat Dec 31 1994 12:00:00 GMT+0100","788828340000 Fri Dec 30 1994 23:59:00 GMT+0100","788914800000 Sun Jan 01 1995 00:00:00 GMT+0100","504918600000 Wed Jan 01 1986 00:10:00 GMT+0100","504917940000 Tue Dec 31 1985 23:59:00 GMT+0100","915145200000 Fri Jan 01 1999 00:00:00 GMT+0100","-2208992400000 Mon Jan 01 1900 00:00:00 GMT+0100","-62198758408000 Fri Jan 01 -0001 00:00:00 GMT+0053","-59011462408000 Fri Jan 01 0100 00:00:00 GMT+0053","915145200000 Fri Jan 01 1999 00:00:00 GMT+0100","-2208992400000 Mon Jan 01 1900 00:00:00 GMT+0100","8639999992800000 Sat Sep 13 275760 00:00:00 GMT+0200","8639999989200000 Fri Sep 12 275760 23:00:00 GMT+0200","NaN Invalid Date","NaN Invalid Date","4118076000000 Thu Jul 01 2100 00:00:00 GMT+0200","4109880600000 Sun Mar 28 2100 03:30:00 GMT+0200","8862139800000 Thu Oct 31 2250 02:30:00 GMT+0100","13569461940000 Fri Dec 31 2399 23:59:00 GMT+0100","1767222000000 Thu Jan 01 2026 00:00:00 GMT+0100","1767222000000 Thu Jan 01 2026 00:00:00 GMT+0100","NaN Invalid Date","NaN Invalid Date","1767222000000 Thu Jan 01 2026 00:00:00 GMT+0100","1769900400000 Sun Feb 01 2026 00:00:00 GMT+0100","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2208992400000 Mon Jan 01 1900 00:00:00 GMT+0100","NaN Invalid Date","-2177456400000 Tue Jan 01 1901 00:00:00 GMT+0100","1769900400000 Sun Feb 01 2026 00:00:00 GMT+0100","1767567600000 Mon Jan 05 2026 00:00:00 GMT+0100"], + "order": ["NaN","NaN","62003",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], + "parsed": [["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792888200000","1792888200000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768467600000","1768467600000"],["1768431600000","1768431600000"],["1768517940000","1768517940000"],["1768467600000","1768467600000"],["1768431600000","1768431600000"],["1768478400000","1768478400000"],["1768471200000","1768471200000"],["1768467600000","1768467600000"],["4118119200000","4118119200000"],["4118119200000","4118119200000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768518000000","1768518000000"],["1768467600500","1768467600500"],["1768467600123","1768467600123"],["1768467600000","1768467600000"],["NaN","NaN"],["NaN","NaN"],["788871600000","788871600000"],["504918600000","504918600000"],["1775348100000","1775348100000"],["1791072900000","1791072900000"],["1793493000000","1793493000000"]], + "single": ["1704067200000","988668000000","NaN","NaN","86400000","1709247600000","1709283600000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007161200000","1768467600000","1774745100250","NaN","Sun Mar 29 2026 01:45:00 GMT+0100","Sun Mar 29 2026 01:45:00 GMT+0100","string","true 1774747800000 3 Sun Mar 29 2026 03:30:00 GMT+0200","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767222000000","1780264800000","NaN","01/01/1970, 09:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 01:00:00 AM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","01/01/1970, 01:00:00 AM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] + }, + "Pacific/Kiritimati": { + "rows": [ + ["-5400000","bb1d9348b912e2e3","5290027efbfbdc69"], + ["-3600000","cd03893e934e89f3","fcaf8e9274a471bd"], + ["-1800000","89a22eb8e8a502cc","e49216d433d20ead"], + ["0","ea23fac2179fc2ae","9185204059c56bdd"], + ["1800123","b5c01edce99061c9","ae00e3d74357a0ed"], + ["3600000","c81cd31da1010b2d","214b3c8d1899c4af"], + ["5400000","cc5e9a869c3743d3","8a8c9ad0c3f4f935"], + ["-5400001","aa38ba1f2e7d9da0","44e9b48bedbb0bdd"], + ["-3600001","b142bb388082bf62","323650825f180899"], + ["-1800001","448885149ed2ccad","c2a8a94646fd5887"], + ["-1","de7552719cacb4b9","69c8acd0af1c6af3"], + ["1800122","38dac0a57a1f111a","7863526da518b689"], + ["3599999","ff684583d28a6d94","96e1b9cb8b743907"], + ["5399999","6c1498d9b3f2f793","1d4050867e6d80f3"], + ["-5399999","d5cae3b6962ad03c","8428104ab6bf6d55"], + ["-3599999","c3e7eebe4fd68dac","f2bdae864bcb98bd"], + ["-1799999","3d9d907ce9a36e3b","9b250903af73af79"], + ["1","f3b2ee75f8d3f5e9","174ae91ea8552dc3"], + ["1800124","e616e4890029db74","6d0f8f574720a78d"], + ["3600001","e298013ed4d08a36","1ca9a1bd76d79203"], + ["5400001","c16af95d3f89e630","1662d1e1ff2e5add"], + ["1699994600000","e86a8615d5c78004","b8f090c98d2604f9"], + ["1699996400000","2e736791d017b0ba","4a554095fa5e7889"], + ["1699998200000","46b05c1366176777","981e3db8558ac8d1"], + ["1700000000000","0f4a00e23c50bc37","6dd1a587d5d09c39"], + ["1700001800123","7d08793655ab840e","edf96327e8e3b809"], + ["1700003600000","0f3d52d2bda8db90","67f0b8e25ec838bd"], + ["1700005400000","d62ad6c03b26efb1","c4536b5985230ac1"], + ["1768475096789","4fd749736ce60463","e0ba8bffd2de6735"], + ["1768476896789","90843efc9018bc60","2e3fa3af7140f1cd"], + ["1768478696789","f1381465c55f8a66","54f7d769141222b9"], + ["1768480496789","e0faec792fcf696f","a5aae5cca05839b9"], + ["1768482296912","75217bcb2d790a77","7c38b3d2fa6c3139"], + ["1768484096789","c33bc2bc2f3add63","3ff03805827eebbd"], + ["1768485896789","9a0d4f50f9bb2285","7532eeb0bff6207d"], + ["1774740600000","531ff2c0f4dd0467","3afc0a987894d90d"], + ["1774742400000","89d16ca36e779b05","b5c13d4d10e7fb81"], + ["1774744200000","4f733be006ffc7c1","e50092c7ad57700d"], + ["1774746000000","9355c92d2865e397","af39404070c019cd"], + ["1774747800123","6daef52f5e5c27ec","de51923528892b95"], + ["1774749600000","101c1839384f284e","0685bd9bc6589e8d"], + ["1774751400000","2d45387cdfdc628e","733c8608f47ccc7d"], + ["1792884600000","b7867eab27043c86","db6eb9837ec37931"], + ["1792886400000","3aea296ceaf240ec","4a112a65e6072b25"], + ["1792888200000","9e106aed0097f930","95aee86ef9d42ae5"], + ["1792890000000","68717807f4964a2e","b6840e542d2c1601"], + ["1792891800123","b0ac89e215d43c5d","08e51aebe1be5e71"], + ["1792893600000","16022c4d3a06399f","fc3e4644d2ceb98d"], + ["1792895400000","3d24c80634c79b03","f118bff924214d49"], + ["1772942400000","8febab7d42cf43af","ed01594507d07d65"], + ["1772944200000","32ce4e518874ccdc","491fc46d29e18225"], + ["1772946000000","50d1a04371b4d670","63c165053564a701"], + ["1772947800000","fa7da395b12a7836","1df5033d2ce9834d"], + ["1772949600123","8ec023a23d46cc75","1e3d1056bd3908f9"], + ["1772951400000","0c21be244f5a1637","c0c4b9ceebf8a351"], + ["1772953200000","2b4f682eb596e429","5c1fc68bf17c2de9"], + ["1793502000000","1034b420abc182b1","f8bc95a652c16419"], + ["1793503800000","3dc8ce25aaad83f5","460a3461b638ac05"], + ["1793505600000","ac0d318bb04fe9f7","bdb09f923a57a2ad"], + ["1793507400000","a67cb98b60d13c64","9816fbdac7fe6c51"], + ["1793509200123","da2404bb925f6696","43ceaaf4de2ddf6d"], + ["1793511000000","06d780ee2612672d","c8a1bdc1033ae971"], + ["1793512800000","0b4c77d7660ab626","22adbb202b9a9595"], + ["788862600000","bafed4c3152c8058","38a44ce67015c3e1"], + ["788864400000","cf7fbd8daf55e6dc","8dbffb35022084c5"], + ["788866200000","0d0ce9354595fec1","e6119292f1a1b497"], + ["788868000000","56c3e0bf4a71d252","2d6382a3c8b97bb1"], + ["788869800123","6601f2e35a913071","bee036a136db28d5"], + ["788871600000","10d1616aa7ec33b5","fb0a43546eed212b"], + ["788873400000","58eae21d7892c0a0","ce7e049839cdfe8d"], + ["504895500000","35126d5403bdd503","a5c76c05e42cdb1b"], + ["504897300000","adc9a05dea3c13ab","bec140f24d5cbb05"], + ["504899100000","9f63604a87a4b73a","96194b0d0a131e67"], + ["504900900000","9a2b8b65f0a2e3c0","7f224458915780cb"], + ["504902700123","c3e7e6bcd158634d","0280e64fa7bcc0d1"], + ["504904500000","1197868becc1a41f","eae2c69ba758efe7"], + ["504906300000","2f27cc0f62b33e93","e73bdcbd7a9099d9"], + ["1775309400000","ed593ae2c88f39fb","6021ed1c00c2c2d9"], + ["1775311200000","90b8475c5e0a14bb","40f7ac9a8c6e0e81"], + ["1775313000000","b655a027af417f29","eb17fa9e377061a9"], + ["1775314800000","b72977b5dcd1ffc1","0d1e5df963436779"], + ["1775316600123","421d120e6e9deda9","3b7033d04e5fbc65"], + ["1775318400000","fb801a2ead3dc851","7dfd769f60cee98d"], + ["1775320200000","c090e1bd461b5a6d","b1f3450ca25d4bc5"], + ["1791036000000","391d170db0216232","85abf824be9fd039"], + ["1791037800000","eeed517bd34f339e","93ae4881825a0775"], + ["1791039600000","73607e29fc83a224","09b56050e0b5c4cd"], + ["1791041400000","3a7b069e7728c87a","e9a527ee44301f9d"], + ["1791043200123","69b68a31bd73eed0","e9a9f287df9c391d"], + ["1791045000000","f0db08a7b272e5ba","583a306fbca8b9e1"], + ["1791046800000","ef3c08ad8933d208","d5131848978177a1"], + ["-2422056600000","e6df3f4aea769372","30788afbbdf5dc49"], + ["-2422054800000","53ba3981c4e0a7b4","9f84617a2c024853"], + ["-2422053000000","9ae84e9d8234df8f","99ea537bc8dde6ad"], + ["-2422051200000","f4cb2890db718b0d","c27f80c17162f061"], + ["-2422049399877","ccee65282c26e74c","cde12c0ee796d94d"], + ["-2422047600000","e7a6d3849ab687ba","21d915c3edb4521d"], + ["-2422045800000","e2bda2ce89ebf6a5","91367b0d2a1857ad"], + ["-5364624600000","4766fa8b095a67de","7fbdd9341d0600c5"], + ["-5364622800000","5c3ad7fcffab8df0","c38cf7fd5aa553a5"], + ["-5364621000000","5de812ea0a4f980b","ea669c90b1849b93"], + ["-5364619200000","d245b7a7a397ab2d","030e82ea0f04b89b"], + ["-5364617399877","49a1a83386f184bc","b0b5aaae9bc97ddd"], + ["-5364615600000","3c38ff63c1cec9ca","5571e0a731e1f4e7"], + ["-5364613800000","087e66fec1dc5001","450a4f2f44604b05"], + ["-2208994200000","77ef75d8fd60cf2f","6a15378a387f9c35"], + ["-2208992400000","da1838b4ecb97a51","2caa8228903fc1cd"], + ["-2208990600000","06a9f692d1b928c0","c1fb6ba74653e71d"], + ["-2208988800000","3deba031eb25b4b6","abcea1e1ab021a5b"], + ["-2208986999877","b431cf16fa7bad55","c351a35f85345a95"], + ["-2208985200000","b3a03dd0912016d7","5b6c92314d015ff9"], + ["-2208983400000","ff8c5967a320f4a2","24e7e84499bf86bf"], + ["4102435800000","e14d3ae49d04b871","6ad72866c4a3c3dd"], + ["4102437600000","3460520165a5c07f","ff34d77995e77299"], + ["4102439400000","f0a864618013ef18","700edeef4660e969"], + ["4102441200000","3331e5ec25774afa","f954aa8551c01cd1"], + ["4102443000123","a0e5b80a901e2363","af1c1e5a76225111"], + ["4102444800000","876be26ead96ae75","7c6caa292f258261"], + ["4102446600000","2278e23b79920386","80eb5355064778e9"], + ["4109873400000","6f5bc26ce99e4672","bd47754b01914da5"], + ["4109875200000","9bcabdee3d150370","cd163280c2565915"], + ["4109877000000","18417ed8bc223aac","6e012950b2f8eded"], + ["4109878800000","30805a7ced7d4af2","4dc3c09cab6e28b9"], + ["4109880600123","b0a827edd6fa21bd","f2fe600c6f2d15dd"], + ["4109882400000","fe0f0bb5c3a41b37","00211d2c862b399d"], + ["4109884200000","3b6cdd37168c6643","11486161039f85bd"], + ["4118121000000","503877aab672f048","86db89d049dd15ad"], + ["4118122800000","54171442d8617ee2","caf8991d4cc1d2ad"], + ["4118124600000","aff514d58f3106a9","2a4354f29aeae955"], + ["4118126400000","5f45c97c85f2f367","b6b927b9fb42465d"], + ["4118128200123","e0e82b9b980075b3","13582329d231893d"], + ["4118130000000","d36aec6e36378fb5","0ff2f253016b8685"], + ["4118131800000","31a381ed9c58196e","64c16de46414dd5d"], + ["8862129000000","df881b257d1727f8","7928d087ae892d31"], + ["8862130800000","272c144c9a80c446","74043d5d10d7ce19"], + ["8862132600000","67f6f9ed4d6860b1","3cde7ca407a4ef61"], + ["8862134400000","ef483a957ac3568b","7be4770de09f3b69"], + ["8862136200123","9c0abdedfa41e647","e19bf8e860412215"], + ["8862138000000","f37abcdf340054c5","f5119f2c45b72045"], + ["8862139800000","1c5824ad1e38afa2","567b88b4d312fe55"], + ["13569460140000","7b9626eb24733215","63f3cd23aa3909d7"], + ["13569461940000","bcfe79831293dfff","95005ecb84603639"], + ["13569463740000","b3bd4411deabefa8","09316c25faf025e5"], + ["13569465540000","75de3e7eafe01fb8","04f67fb3f2fbe3d7"], + ["13569467340123","ca462bd09c7084df","dfa87a0d40f57a67"], + ["13569469140000","52a1abc65df1a115","c74925eb04e0f4d5"], + ["13569470940000","9e097a2c383b05e6","d1f972c8fc903753"], + ["253402295399999","b5476390abe0ece5","d666cff0dff631c1"], + ["253402297199999","68485dd79b139d11","5607d4c120d2560d"], + ["253402298999999","e5481a20e7dd83ac","947ddf6af6e47571"], + ["253402300799999","9d05b03cdb96afbe","376a95ad13577635"], + ["253402302600122","2c3b8f893c938eb5","5d021be039cb9bd5"], + ["253402304399999","13ac96dbeab35299","21258a8e7d3a7645"], + ["253402306199999","32011abdd9ce5b52","fdb6e22db9d90449"], + ["-2208994200000","77ef75d8fd60cf2f","6a15378a387f9c35"], + ["-2208992400000","da1838b4ecb97a51","2caa8228903fc1cd"], + ["-2208990600000","06a9f692d1b928c0","c1fb6ba74653e71d"], + ["-2208988800000","3deba031eb25b4b6","abcea1e1ab021a5b"], + ["-2208986999877","b431cf16fa7bad55","c351a35f85345a95"], + ["-2208985200000","b3a03dd0912016d7","5b6c92314d015ff9"], + ["-2208983400000","ff8c5967a320f4a2","24e7e84499bf86bf"], + ["-62184504600000","58ceba4f32fe60c2","853a37dbed7d8fc1"], + ["-62184502800000","9cecebf5c9ce2694","e8dc9de215e92e85"], + ["-62184501000000","a67dd84d5df72e35","279f9dcc5617e771"], + ["-62184499200000","f2d4d05b135f3a9f","7289de41701a2279"], + ["-62184497399877","dee9c80efd1b762e","e1709f01d8984cad"], + ["-62184495600000","f4419680e1a071dc","dd447e2014aa4e1d"], + ["-62184493800000","247fb28afe0573cf","ad088aa289429a95"], + ["-8640000000000000","11a82aaacd6a24fa","5d04ee5b14c94469"], + ["-8639999998199877","8d93191496e13414","5d04ee5b14c94469"], + ["-8639999996400000","0cdc402e25a2b407","5d04ee5b14c94469"], + ["-8639999994600000","1087b849eeaf6ebf","5d04ee5b14c94469"], + ["8639999994600000","b763aa63ea0e76d5","5d04ee5b14c94469"], + ["8639999996400000","34af9442ac5b1eda","5d04ee5b14c94469"], + ["8639999998200000","de176b5a250b5f20","5d04ee5b14c94469"], + ["8640000000000000","6e28258fee10fd2f","5d04ee5b14c94469"], + ["-8640000000000000","11a82aaacd6a24fa","5d04ee5b14c94469"], + ["-8639999998199877","8d93191496e13414","5d04ee5b14c94469"], + ["-8639999996400000","0cdc402e25a2b407","5d04ee5b14c94469"], + ["-8639999994600000","1087b849eeaf6ebf","5d04ee5b14c94469"], + ["8639999991000000","f95ff853974aebe2","5d04ee5b14c94469"], + ["8639999992800000","9a5a1484b4af311d","5d04ee5b14c94469"], + ["8639999994600000","b763aa63ea0e76d5","5d04ee5b14c94469"], + ["8639999996400000","34af9442ac5b1eda","5d04ee5b14c94469"], + ["8639999998200123","de176b5a250b5f20","5d04ee5b14c94469"], + ["8640000000000000","6e28258fee10fd2f","5d04ee5b14c94469"], + ["-8639999919000000","3b66ffa61bab81a1","990e217b68ac0ee5"], + ["-8639999917200000","a007b604108baffb","745b97d90fdbf8c5"], + ["-8639999915400000","19d125000bebcb5a","baa2f263bfe60195"], + ["-8639999913600000","9f72c202e5ad886c","6fdec28a26c49975"], + ["-8639999911799877","7c102efd08cae8d5","e893bf150b9efa21"], + ["-8639999910000000","a0ebe5232298120b","5c2966a0567909f5"], + ["-8639999908200000","58dd3b43722809a0","cf58b3c42f86c1fd"], + ["8599999994600000","80c0ca576b9babdb","d9c858c92d6b2575"], + ["8599999996400000","f84a779741a49d49","96ee4c9db0d18cf5"], + ["8599999998200000","c01158d98543cd98","5630a96030687723"], + ["8600000000000000","5f55bbffc2bab374","ad1b44d5825bcaad"], + ["8600000001800123","6d9098b8116513e9","1d32e49ff8b6a1ab"], + ["8600000003600000","efb435033aa5e28a","60e05c8fc5b0e317"], + ["8600000005400000","8e70738e49e91c8b","76223ab1932b7d35"], + ["-8600000005400000","d3b830e6dd30d646","71f34003b5ca3a19"], + ["-8600000003600000","cf58668ab4576443","9de6c244153d703d"], + ["-8600000001800000","66ea66412f26515b","d97b960ac1b3d92d"], + ["-8600000000000000","5962b353769b87e4","1e6bf4438d0071f1"], + ["-8599999998199877","b928c9e7dc0449f0","82506919a65ec6c5"], + ["-8599999996400000","faa401b6224674a9","e8db08e0b55a3ad9"], + ["-8599999994600000","ee82d456cb243647","ab9f4dc9bd1acf4d"], + ["NaN","9a29e84c251c3a5d","0e30ee4365a2ae53"] + ], + "made": ["1774701000000 Sun Mar 29 2026 02:30:00 GMT+1400","1774699199999 Sun Mar 29 2026 01:59:59 GMT+1400","1774702800000 Sun Mar 29 2026 03:00:00 GMT+1400","1792845000000 Sun Oct 25 2026 02:30:00 GMT+1400","1792841400000 Sun Oct 25 2026 01:30:00 GMT+1400","1792846800000 Sun Oct 25 2026 03:00:00 GMT+1400","1772886600000 Sun Mar 08 2026 02:30:00 GMT+1400","1793446200000 Sun Nov 01 2026 01:30:00 GMT+1400","1793442600000 Sun Nov 01 2026 00:30:00 GMT+1400","1775303100000 Sun Apr 05 2026 01:45:00 GMT+1400","1775304900000 Sun Apr 05 2026 02:15:00 GMT+1400","1791029700000 Sun Oct 04 2026 02:15:00 GMT+1400","NaN Invalid Date","788867940000 Fri Dec 30 1994 23:59:00 GMT-1000","788868000000 Sun Jan 01 1995 00:00:00 GMT+1400","504958200000 Wed Jan 01 1986 00:10:00 GMT-1000","504957540000 Tue Dec 31 1985 23:59:00 GMT-1000","915098400000 Fri Jan 01 1999 00:00:00 GMT+1400","-2208951040000 Mon Jan 01 1900 00:00:00 GMT-1029","-62198717440000 Fri Jan 01 -0001 00:00:00 GMT-1029","-59011421440000 Fri Jan 01 0100 00:00:00 GMT-1029","915098400000 Fri Jan 01 1999 00:00:00 GMT+1400","-2208951040000 Mon Jan 01 1900 00:00:00 GMT-1029","8639999949600000 Sat Sep 13 275760 00:00:00 GMT+1400","8639999946000000 Fri Sep 12 275760 23:00:00 GMT+1400","-8639999962240000 Tue Apr 20 -271821 00:00:00 GMT-1029","NaN Invalid Date","4118032800000 Thu Jul 01 2100 00:00:00 GMT+1400","4109833800000 Sun Mar 28 2100 02:30:00 GMT+1400","8862093000000 Thu Oct 31 2250 02:30:00 GMT+1400","13569415140000 Fri Dec 31 2399 23:59:00 GMT+1400","1767175200000 Thu Jan 01 2026 00:00:00 GMT+1400","1767175200000 Thu Jan 01 2026 00:00:00 GMT+1400","NaN Invalid Date","NaN Invalid Date","1767175200000 Thu Jan 01 2026 00:00:00 GMT+1400","1769853600000 Sun Feb 01 2026 00:00:00 GMT+1400","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2208951040000 Mon Jan 01 1900 00:00:00 GMT-1029","NaN Invalid Date","-2177414400000 Tue Jan 01 1901 00:00:00 GMT-1040","1769853600000 Sun Feb 01 2026 00:00:00 GMT+1400","1767520800000 Mon Jan 05 2026 00:00:00 GMT+1400"], + "order": ["NaN","NaN","-1137997",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], + "parsed": [["1768420800000","1768420800000"],["1768420800000","1768420800000"],["1768420800000","1768420800000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792845000000","1792845000000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768420800000","1768420800000"],["1768384800000","1768384800000"],["1768471140000","1768471140000"],["1768420800000","1768420800000"],["1768384800000","1768384800000"],["1768431600000","1768431600000"],["1768471200000","1768471200000"],["1768420800000","1768420800000"],["4118076000000","4118076000000"],["4118076000000","4118076000000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768471200000","1768471200000"],["1768420800500","1768420800500"],["1768420800123","1768420800123"],["1768420800000","1768420800000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["504958200000","504958200000"],["1775304900000","1775304900000"],["1791029700000","1791029700000"],["1793446200000","1793446200000"]], + "single": ["1704067200000","988624800000","NaN","NaN","86400000","1709200800000","1709236800000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007114400000","1768420800000","1774745100250","NaN","Sun Mar 29 2026 14:45:00 GMT+1400","Sun Mar 29 2026 14:45:00 GMT+1400","string","true 1774701000000 2 Sun Mar 29 2026 02:30:00 GMT+1400","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767175200000","1780221600000","NaN","01/01/1970, 09:00:00 AM","12/31/1969, 01:20:00 PM","12/31/1969, 01:20:00 PM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","12/31/1969, 01:20:00 PM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] + }, + "UTC": { + "rows": [ + ["-5400000","802f7e0c85c44914","2b3e96c0dbc2bf9d"], + ["-3600000","e688280e60a66750","5f5233f654e8b06d"], + ["-1800000","761d3b40eb2a256f","55ecff57a6b643b5"], + ["0","37cb8a91172dcb40","75dd4eaf9745de19"], + ["1800123","5b6798af5cf0b23b","e639bd744d7584f7"], + ["3600000","231dc598109bbe9f","fd9276babfb3764b"], + ["5400000","2293af676fce9a5f","f780c0bd6c240483"], + ["-5400001","0c5b360782d80929","7f77c9ce52977db5"], + ["-3600001","16fb5a87a35da662","9aecd7cb28457449"], + ["-1800001","02a8a4ae80a6f5b8","549cfa5c5d2e194b"], + ["-1","b6fa6bc515c67f4b","70aca9a0a6be10e3"], + ["1800122","3c86587821cd31f0","3f0afc8684950b2b"], + ["3599999","7c96d4ea1fd78371","5d7515bc3c546571"], + ["5399999","331cd842b3897b43","02da276d50433101"], + ["-5399999","45b244169c5956c1","f8cc6ebca6d52309"], + ["-3599999","fd5423eb7f64a9eb","ce5a886244c55fc1"], + ["-1799999","7c1ab95f88e8ea52","9320511101db06f5"], + ["1","d2761dfd058bd3a5","84083dc31c2ba50f"], + ["1800124","278da20af7c9524a","9632b1e71d608d37"], + ["3600001","5faf14f59c9eba96","54049e97e48417d5"], + ["5400001","46c8081b07c78ddc","7a5e70bf32f71bb9"], + ["1699994600000","840586e0aad1f0b8","08f117c7e1258505"], + ["1699996400000","924472d3d68ddaf6","0221a6a06244ef09"], + ["1699998200000","7797baf650b7ad9b","c5283bcb764f5b75"], + ["1700000000000","c9f319098f495f87","8f46a18b1948aebd"], + ["1700001800123","08e8e4e049991d4a","0c8dec91af68a411"], + ["1700003600000","61702b298d6d470c","73d665305b2922a1"], + ["1700005400000","5c31de83dc693399","4a15c5a7bf21e325"], + ["1768475096789","010da0bedfeaca53","462f869a5e483849"], + ["1768476896789","51a35e3ddbded04a","f7c2d9cd42926add"], + ["1768478696789","de9278c5d068d202","51235c0c3ba9d2a1"], + ["1768480496789","07184b7d84978591","3c248e8ed1a64c39"], + ["1768482296912","4296016e04342507","1edb797bcfce216d"], + ["1768484096789","d6d262655258f8e5","4d08cd820a5a76a9"], + ["1768485896789","9a9556e42db34731","8df4bc245bf2f7b5"], + ["1774740600000","23fb328e7680508e","49283e0a4294ed69"], + ["1774742400000","eff3a23b8ad12b2c","020d8d39712bd4b1"], + ["1774744200000","4d5572f906f1e1da","df430e5f4e7ebb35"], + ["1774746000000","933bf5cbf1c79cca","bf685912e4c1f6c5"], + ["1774747800123","8b3b7b71549bf2bb","12a597a2abb35ddd"], + ["1774749600000","500e46675c5fc6c7","c58e6f437e4e0b7d"], + ["1774751400000","08def6ce3eb90749","359aa26d0e08a57d"], + ["1792884600000","9507245bb5ee8e9f","ad84df66b39d5b81"], + ["1792886400000","9b8138458d845085","aeab107395c9cf71"], + ["1792888200000","33d55cad1b4148d7","e101577167d5b405"], + ["1792890000000","829cc74970809097","8f62698f0144a165"], + ["1792891800123","8103c38ad2c8038a","e03850fa2a22ccc9"], + ["1792893600000","407f21155e67661a","dc2874271313a30d"], + ["1792895400000","1ec66dfe0b8ef2bc","2f3259fdc4fa9e5d"], + ["1772942400000","6de83c0b69975398","6bb1db27bca1d765"], + ["1772944200000","9d80700441f780c5","b245c8c69fc6f7d5"], + ["1772946000000","3a2c3dacab1c85eb","5b7db683e0260add"], + ["1772947800000","c03c7b81af927feb","23e4953bbb5c29b1"], + ["1772949600123","9aca94a429ecb7fd","bb3195aead572efd"], + ["1772951400000","4fab74d16c08b2fb","9537c9e4ae96dced"], + ["1772953200000","33f8d274241f8b5d","56721c8d640abdb9"], + ["1793502000000","0e49a7d519b11a4e","2b5d9f0ef0786afd"], + ["1793503800000","0e038ad0956bcd8c","318ab6b9cb506345"], + ["1793505600000","3c741646688ea53c","92245b6277e7e481"], + ["1793507400000","592571d021b455e1","d3115e4dbcaee471"], + ["1793509200123","76438f8283747f1d","c768095e83587901"], + ["1793511000000","8b9808602d02a568","b3d89ea041b7422d"], + ["1793512800000","7d1b32acb4e29324","c2a3dbabd17d8be1"], + ["788862600000","1f10b311747c2ca8","af5c3bf861d1b86b"], + ["788864400000","a07db053d629fd78","74c088fcd7e4dead"], + ["788866200000","6c6b380279bfc0b7","13fda234a29026eb"], + ["788868000000","d27f17b79fe571ee","415c694f57e3dc13"], + ["788869800123","5504731d1cfe22c5","3dc158e8d14634f5"], + ["788871600000","d1dde7294a657c0b","38c1ba0cd3a420e7"], + ["788873400000","897b70ba1799456a","04cbc6fe223a92c5"], + ["504895500000","036366a418fb5277","ce7f8917f334f9f5"], + ["504897300000","b42047baf3c896b3","0ec93c62c02a85d1"], + ["504899100000","9d2212141d6b4d60","191cff51947a39a9"], + ["504900900000","a59944a9baccb4ba","a06dc7928ea2f82b"], + ["504902700123","2220f12fde047099","05fe0157ea55db6b"], + ["504904500000","331c15df9a10b4c3","ba47051860d0679b"], + ["504906300000","207313e02c55afa9","de1d3884908b0607"], + ["1775309400000","dde4e7ebe6b29aec","b4284522c80a4b5d"], + ["1775311200000","1e7ad59da4c05620","fdf3f773b441cb9d"], + ["1775313000000","3ecb393369d02ab2","25dd6101ac08c5a1"], + ["1775314800000","c11626ab5657124e","97a2cb3d1cde3895"], + ["1775316600123","e2d0f2f7fcd68e32","298c1d09654fa0c9"], + ["1775318400000","41f8e9689aed189e","2061a38fe5a14951"], + ["1775320200000","dfa79f83be1b5e96","b34db19041521ae9"], + ["1791036000000","30869d9f75a5b41b","67df87369c7a689d"], + ["1791037800000","9a2c2f144ec2c5b7","20b63f1e1677a03d"], + ["1791039600000","a7358f202de716c1","13d5cb8a12f60141"], + ["1791041400000","08d95081290359f3","11bb3afaf6c214c1"], + ["1791043200123","dfdd4664a1d6e34d","5a9f8b69e368e98d"], + ["1791045000000","8a17dae09c37b03b","7346e880737c55c5"], + ["1791046800000","10d255da9c35191d","2de15b6e629dbc2d"], + ["-2422056600000","06ebe696c8112054","41f4eee46fe05a1b"], + ["-2422054800000","fbc24eae450ebe43","79b1684d229f5a6b"], + ["-2422053000000","5b68e87dee406473","4d3b72b7727c8bcb"], + ["-2422051200000","1587037ed992e9f9","a92e622f72c1345d"], + ["-2422049399877","664a223e8f013935","b820979144a0c3b5"], + ["-2422047600000","380843d6619cf1fa","34ce88b29152264f"], + ["-2422045800000","2cc06546220db07e","5a21601dfb4d5733"], + ["-5364624600000","e0f2efa4f61f69de","c32abe999b47e4df"], + ["-5364622800000","fb47fe4f55bc73e1","f629394e140a256f"], + ["-5364621000000","771b272db7244afd","59b6f38e04892989"], + ["-5364619200000","1e9fae0598613a9c","7f701519a49c4d81"], + ["-5364617399877","26dcd0eae0f17088","5134c55e057072fb"], + ["-5364615600000","f6e17ed10dca6a5b","1d1d7c6a1a25fd73"], + ["-5364613800000","21d7b501ab0eac4b","2eede31a9cc7cf15"], + ["-2208994200000","62885ad7c8afea7b","c0589a3ed3eeee09"], + ["-2208992400000","9692b8145f4c0d72","cdcf73a79c07b273"], + ["-2208990600000","0440ea411a218eae","67dea3d89d2a9c83"], + ["-2208988800000","2395f56fb68778e2","d0208cac2c0fa4b5"], + ["-2208986999877","1797fb9b4cbbf58c","364b4a9cd82cac93"], + ["-2208985200000","d550c314b1d2a6f7","a1492e21f8466e67"], + ["-2208983400000","ae55a7f1548be2a1","e7017e0bbb4dce41"], + ["4102435800000","63e3ddfae20bbfa2","7c80f2ba467d68bd"], + ["4102437600000","657133c5d1fd903c","a337d6369d03c015"], + ["4102439400000","9c90cc9953a0a4cd","55d4face45859591"], + ["4102441200000","f36af6fa13b3cf0f","1d4fcf5e034a22d9"], + ["4102443000123","f97551f565a65e88","b48b780467230e55"], + ["4102444800000","3df56f48a66b246c","d693ef81d6de5a61"], + ["4102446600000","52563632e5007a4d","1aa4d73158362be9"], + ["4109873400000","748007fbf757d4b3","f3fdad1dc74dee75"], + ["4109875200000","070a8c38ca4e97e5","5e444683a7996a81"], + ["4109877000000","17228b7cc6d83e0f","dad2d22010799e49"], + ["4109878800000","5306108988262407","d14fb4ea72924549"], + ["4109880600123","f75b9508bb5a9846","4453ee6eb967c7c9"], + ["4109882400000","d7e832c2bc8b3f4e","5a5c8a4af1d96f15"], + ["4109884200000","a92330e2cc060720","5713e7858afb0521"], + ["4118121000000","99b10de5d669531c","779d3813b3b61dd1"], + ["4118122800000","be9d4cdb974e0de0","6639a6449c54b69d"], + ["4118124600000","e3d49b66d5f98639","556d1e430c5c9405"], + ["4118126400000","c8e84e5626fd45b9","1435136f379e1f6d"], + ["4118128200123","c7444580abe2fff7","a9c631aba1d794e5"], + ["4118130000000","e18dfc2bd8c0ec5b","312e6415ff8e9f01"], + ["4118131800000","ee0a6a69a70fb582","512b00b8f891b49d"], + ["8862129000000","259c70faecd58254","9a32ce35a2aa83f1"], + ["8862130800000","8759d8e40fed6d74","61160cd1fcfdb1b5"], + ["8862132600000","55ccf0cc0f912a89","a38cc08a27259071"], + ["8862134400000","332d052a6f7c134a","2558fdce2de7dee5"], + ["8862136200123","8b91cff30ebcdab4","1cb41902fd1990a1"], + ["8862138000000","747e2976dddbf7cc","01f1b1d31f463771"], + ["8862139800000","95e3d9397b252c19","7f168df189b27609"], + ["13569460140000","c8a3f35efcc45142","bce76db2b02b6611"], + ["13569461940000","b9798b2196780386","0cee3b59c69d5fb7"], + ["13569463740000","cdae9d2cdd8b57e9","0b4b0c35327c7b41"], + ["13569465540000","bfc3f34f39fb266f","88e6856bb2ccb593"], + ["13569467340123","5b321c7758fbef9c","ad45379b19458b3f"], + ["13569469140000","289d5a72a379ec5a","f6266df57e0c6fcb"], + ["13569470940000","115be34089ca2091","66187e4baa453b83"], + ["253402295399999","c6fe3e1c2c13bf24","53cf57855cab3509"], + ["253402297199999","3c429c2f81888b7a","2d29abd2381c82ad"], + ["253402298999999","f3eded1d27b674a7","ee7b852b57c4fb45"], + ["253402300799999","e9dd1f8c155c4edb","459030ee3eee6831"], + ["253402302600122","459491bb410941b6","8e46fa43f5ec06b1"], + ["253402304399999","08a157906ba45724","0c8d66cfb90ff3e5"], + ["253402306199999","c9797cb02c4dc38d","55c3903c54deb6e9"], + ["-2208994200000","62885ad7c8afea7b","c0589a3ed3eeee09"], + ["-2208992400000","9692b8145f4c0d72","cdcf73a79c07b273"], + ["-2208990600000","0440ea411a218eae","67dea3d89d2a9c83"], + ["-2208988800000","2395f56fb68778e2","d0208cac2c0fa4b5"], + ["-2208986999877","1797fb9b4cbbf58c","364b4a9cd82cac93"], + ["-2208985200000","d550c314b1d2a6f7","a1492e21f8466e67"], + ["-2208983400000","ae55a7f1548be2a1","e7017e0bbb4dce41"], + ["-62184504600000","bbb3051832512ba2","1f593505bb2acfb5"], + ["-62184502800000","dd23722bb8b7dde5","dbb00000efb4d22d"], + ["-62184501000000","05d4c6fc02994839","4859327e3c7303bd"], + ["-62184499200000","527f73e57328de4b","817da2beaa1b7271"], + ["-62184497399877","5104541f40db8ee3","5984332889055489"], + ["-62184495600000","21a7e6deb159c3f2","467a80050d2b1a09"], + ["-62184493800000","a69f905ec599d026","4bbdceff7455d9b1"], + ["-8640000000000000","0fa69e58a2830dc6","41e38c4772925165"], + ["-8639999998199877","75e19fca22f2e56d","8935eafe47d13625"], + ["-8639999996400000","e68229bd726fb1e2","e3766199667c7a61"], + ["-8639999994600000","2a88ec9f9538081d","38905860e6bfd0f1"], + ["8639999994600000","485865c709327ecc","65cc26ac7f1048bb"], + ["8639999996400000","ac5a8887e494df9b","7b4fd95a98960e9d"], + ["8639999998200000","72b32d320471f448","4fa515de49bb6a7f"], + ["8640000000000000","40fa797ddb242ef0","aa371468eb4f7ac1"], + ["-8640000000000000","0fa69e58a2830dc6","41e38c4772925165"], + ["-8639999998199877","75e19fca22f2e56d","8935eafe47d13625"], + ["-8639999996400000","e68229bd726fb1e2","e3766199667c7a61"], + ["-8639999994600000","2a88ec9f9538081d","38905860e6bfd0f1"], + ["8639999991000000","e383192d587e3d38","d5ecf8893900e9fd"], + ["8639999992800000","48effe287ebef35f","9996d90e6f7ff80f"], + ["8639999994600000","485865c709327ecc","65cc26ac7f1048bb"], + ["8639999996400000","ac5a8887e494df9b","7b4fd95a98960e9d"], + ["8639999998200123","e402d24420a76054","042c2b14a8bf0c13"], + ["8640000000000000","40fa797ddb242ef0","aa371468eb4f7ac1"], + ["-8639999919000000","7a18c843569b6621","5982b3c4d06cb3b1"], + ["-8639999917200000","108a875b7589741a","c27e249fdac1f761"], + ["-8639999915400000","fa388160df49a92a","62f86b69f137e1e5"], + ["-8639999913600000","2833ed59beec19a6","d5de53f74b4f3571"], + ["-8639999911799877","b15e7b064f9e01a2","d9f090483f19e2e9"], + ["-8639999910000000","593d55c158aa5aef","64d27aa19711688d"], + ["-8639999908200000","bb95de25932213cf","7e192c3f9b5e3075"], + ["8599999994600000","d052cac961133c31","0d97fccdf0481ce7"], + ["8599999996400000","80730cd2eadcaaf3","d33287817ce8fc13"], + ["8599999998200000","a909cb656f784d33","a3a632c2a843c0cd"], + ["8600000000000000","5ddffe3e4eb2eef3","eddb5cd356b771fb"], + ["8600000001800123","ecf32cf53ee7362e","488593c2e4a49bad"], + ["8600000003600000","31f301a3e2448eb1","a5edd7fce2b343b5"], + ["8600000005400000","79007a666b4b3b64","92b29518f7aed893"], + ["-8600000005400000","ec26e9c0d7c88f11","98afe48058051de1"], + ["-8600000003600000","be97204006157bc7","8574e3d911b80129"], + ["-8600000001800000","48626e6aa3a50040","f02f88d21bf37655"], + ["-8600000000000000","bbdd4abf578f8254","0bc1da5055f07389"], + ["-8599999998199877","4dbcafd39eb2f7f9","cabe3321a7ef3e11"], + ["-8599999996400000","f7a1ef898885af58","1d42e0ba918e25e1"], + ["-8599999994600000","07082b5d8b270fff","5efd3174d7a1ecb5"], + ["NaN","9a29e84c251c3a5d","305d1da689a0045d"] + ], + "made": ["1774751400000 Sun Mar 29 2026 02:30:00 GMT+0000","1774749599999 Sun Mar 29 2026 01:59:59 GMT+0000","1774753200000 Sun Mar 29 2026 03:00:00 GMT+0000","1792895400000 Sun Oct 25 2026 02:30:00 GMT+0000","1792891800000 Sun Oct 25 2026 01:30:00 GMT+0000","1792897200000 Sun Oct 25 2026 03:00:00 GMT+0000","1772937000000 Sun Mar 08 2026 02:30:00 GMT+0000","1793496600000 Sun Nov 01 2026 01:30:00 GMT+0000","1793493000000 Sun Nov 01 2026 00:30:00 GMT+0000","1775353500000 Sun Apr 05 2026 01:45:00 GMT+0000","1775355300000 Sun Apr 05 2026 02:15:00 GMT+0000","1791080100000 Sun Oct 04 2026 02:15:00 GMT+0000","788875200000 Sat Dec 31 1994 12:00:00 GMT+0000","788831940000 Fri Dec 30 1994 23:59:00 GMT+0000","788918400000 Sun Jan 01 1995 00:00:00 GMT+0000","504922200000 Wed Jan 01 1986 00:10:00 GMT+0000","504921540000 Tue Dec 31 1985 23:59:00 GMT+0000","915148800000 Fri Jan 01 1999 00:00:00 GMT+0000","-2208988800000 Mon Jan 01 1900 00:00:00 GMT+0000","-62198755200000 Fri Jan 01 -0001 00:00:00 GMT+0000","-59011459200000 Fri Jan 01 0100 00:00:00 GMT+0000","915148800000 Fri Jan 01 1999 00:00:00 GMT+0000","-2208988800000 Mon Jan 01 1900 00:00:00 GMT+0000","8640000000000000 Sat Sep 13 275760 00:00:00 GMT+0000","8639999996400000 Fri Sep 12 275760 23:00:00 GMT+0000","-8640000000000000 Tue Apr 20 -271821 00:00:00 GMT+0000","NaN Invalid Date","4118083200000 Thu Jul 01 2100 00:00:00 GMT+0000","4109884200000 Sun Mar 28 2100 02:30:00 GMT+0000","8862143400000 Thu Oct 31 2250 02:30:00 GMT+0000","13569465540000 Fri Dec 31 2399 23:59:00 GMT+0000","1767225600000 Thu Jan 01 2026 00:00:00 GMT+0000","1767225600000 Thu Jan 01 2026 00:00:00 GMT+0000","NaN Invalid Date","NaN Invalid Date","1767225600000 Thu Jan 01 2026 00:00:00 GMT+0000","1769904000000 Sun Feb 01 2026 00:00:00 GMT+0000","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2208988800000 Mon Jan 01 1900 00:00:00 GMT+0000","NaN Invalid Date","-2177452800000 Tue Jan 01 1901 00:00:00 GMT+0000","1769904000000 Sun Feb 01 2026 00:00:00 GMT+0000","1767571200000 Mon Jan 05 2026 00:00:00 GMT+0000"], + "order": ["NaN","NaN","62003",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], + "parsed": [["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792895400000","1792895400000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768435200000","1768435200000"],["1768521540000","1768521540000"],["1768471200000","1768471200000"],["1768435200000","1768435200000"],["1768482000000","1768482000000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["4118126400000","4118126400000"],["4118126400000","4118126400000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768521600000","1768521600000"],["1768471200500","1768471200500"],["1768471200123","1768471200123"],["1768471200000","1768471200000"],["NaN","NaN"],["NaN","NaN"],["788875200000","788875200000"],["504922200000","504922200000"],["1775355300000","1775355300000"],["1791080100000","1791080100000"],["1793496600000","1793496600000"]], + "single": ["1704067200000","988675200000","NaN","NaN","86400000","1709251200000","1709287200000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007164800000","1768471200000","1774745100250","NaN","Sun Mar 29 2026 00:45:00 GMT+0000","Sun Mar 29 2026 00:45:00 GMT+0000","string","true 1774751400000 2 Sun Mar 29 2026 02:30:00 GMT+0000","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767225600000","1780272000000","NaN","01/01/1970, 09:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 12:00:00 AM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] + } +} diff --git a/core/engine/tests/pinned_dates.rs b/core/engine/tests/pinned_dates.rs new file mode 100644 index 00000000..89dd4ed1 --- /dev/null +++ b/core/engine/tests/pinned_dates.rs @@ -0,0 +1,284 @@ +use serde_json::{json, Value}; +use std::collections::BTreeMap; +use std::sync::Arc; +use zen_engine::context::{parse_instant, parse_timezone}; +use zen_engine::model::DecisionContent; +use zen_engine::{DecisionEngine, EngineVersion, EvaluationOptions, Variable}; + +const ZONES: &[&str] = &[ + "UTC", + "Europe/Berlin", + "America/St_Johns", + "Asia/Kathmandu", + "Pacific/Kiritimati", + "Etc/GMT+5", + "Australia/Lord_Howe", +]; + +const FIXTURE: &str = "tests/fixtures/pinned_dates.json"; + +const SCRIPT: &str = r#" +const show = (v) => { + if (typeof v === 'number') return Object.is(v, -0) ? '-0' : String(v); + if (typeof v === 'bigint') return v + 'n'; + return v; +}; +const attempt = (f) => { + try { return show(f()); } catch (e) { return 'throws ' + e.constructor.name + ': ' + e.message; } +}; +const bases = [ + 0, -1, 1, 1700000000000, 1768480496789, + Date.UTC(2026, 2, 29, 1), Date.UTC(2026, 9, 25, 1), + Date.UTC(2026, 2, 8, 5, 30), Date.UTC(2026, 10, 1, 4, 30), + Date.UTC(1994, 11, 31, 10), Date.UTC(1985, 11, 31, 18, 15), + Date.UTC(2026, 3, 4, 15), Date.UTC(2026, 9, 3, 15, 30), + Date.UTC(1893, 3, 1), Date.UTC(1800, 0, 1, 12), Date.UTC(1900, 0, 1), + Date.UTC(2099, 11, 31, 23), Date.UTC(2100, 2, 28, 1), Date.UTC(2100, 6, 1, 12), Date.UTC(2250, 9, 31), + Date.UTC(2399, 11, 31, 23, 59), Date.UTC(9999, 11, 31, 23, 59, 59, 999), + Date.UTC(0, 0, 1) - 62167219200000 * 0, Date.UTC(-1, 5, 15), Date.UTC(-271821, 3, 20), + 8.64e15, -8.64e15, 8.64e15 - 3600000, -8.64e15 + 86400000, 8.6e15, -8.6e15, NaN, +]; +const instants = []; +for (const b of bases) { + if (Number.isNaN(b)) { instants.push(b); continue; } + for (const k of [-3, -2, -1, 0, 1, 2, 3]) { + const t = b + k * 1800000 + (k === 1 ? 123 : 0); + if (Math.abs(t) <= 8.64e15) instants.push(t); + } +} +const getters = ['getFullYear', 'getMonth', 'getDate', 'getDay', 'getHours', 'getMinutes', 'getSeconds', 'getMilliseconds', 'getTimezoneOffset', 'getYear']; +const strings = ['toString', 'toDateString', 'toTimeString', 'toLocaleString', 'toLocaleDateString', 'toLocaleTimeString']; +const setters = [ + ['setHours', [2]], ['setHours', [2, 30]], ['setHours', [3, 15, 10, 5]], ['setHours', [25]], ['setHours', [-1]], + ['setHours', [1.7]], ['setHours', [-1.7]], ['setHours', []], ['setHours', [NaN]], ['setHours', ['3']], ['setHours', [Infinity]], + ['setMinutes', [90]], ['setMinutes', [-30, 15]], ['setSeconds', [3601, 5]], ['setMilliseconds', [1e9]], + ['setDate', [0]], ['setDate', [32]], ['setMonth', [13]], ['setMonth', [-1, 31]], ['setMonth', [1, 29]], + ['setFullYear', [2100]], ['setFullYear', [-1, 1, 29]], ['setFullYear', [1e6]], ['setFullYear', [275760, 8, 13]], ['setFullYear', [2026, 2, 29]], + ['setFullYear', [99]], ['setFullYear', [null, undefined]], ['setDate', [{ valueOf: () => 15 }]], ['setHours', [2n]], +]; +const rows = instants.map((t) => { + const d = new Date(t); + const row = { t: show(t) }; + for (const g of getters) row[g] = attempt(() => d[g]()); + for (const s of strings) row[s] = attempt(() => d[s]()); + row.localeZoned = attempt(() => d.toLocaleString(undefined, { timeZone: 'Asia/Kathmandu' })); + row.localeLower = attempt(() => d.toLocaleTimeString('en', { timeZone: 'america/st_johns' })); + row.localeUnknown = attempt(() => d.toLocaleDateString('en', { timeZone: 'Mars/Base' })); + row.localeNumber = attempt(() => d.toLocaleString('en', { timeZone: 42 })); + row.localeNull = attempt(() => d.toLocaleString('en', null)); + row.sets = setters.map(([name, args]) => { + const x = new Date(t); + const r = attempt(() => x[name](...args)); + return r + ' ' + show(x.getTime()); + }); + return row; +}); +const constructed = [ + [2026, 2, 29, 2, 30], [2026, 2, 29, 1, 59, 59, 999], [2026, 2, 29, 3], [2026, 9, 25, 2, 30], [2026, 9, 25, 1, 30], [2026, 9, 25, 3], + [2026, 2, 8, 2, 30], [2026, 10, 1, 1, 30], [2026, 10, 1, 0, 30], [2026, 3, 5, 1, 45], [2026, 3, 5, 2, 15], [2026, 9, 4, 2, 15], + [1994, 11, 31, 12], [1994, 11, 30, 23, 59], [1995, 0, 1], [1986, 0, 1, 0, 10], [1985, 11, 31, 23, 59], + [99, 0], [0, 0], [-1, 0], [100, 0], [99.9, 0], [-0.5, 0], [275760, 8, 13], [275760, 8, 12, 23], [-271821, 3, 20], [-271821, 3, 19, 23], + [2100, 6, 1], [2100, 2, 28, 2, 30], [2250, 9, 31, 2, 30], [2399, 11, 31, 23, 59], [2026, 0, 1, 0, 0, 0, 0.5], [2026, 0, 1, 0, 0, 0, -0.5], + [NaN, 0], [2026, NaN], [2026, 0, 1, 0, 0, 0, 0, 99], ['2026', '1'], [2026, 1, 1e10], [2026, 1e10], [1e20, 0], [2026, 0, 1, 1e20], + [Infinity, 0], [2026, -Infinity], [null, null], [undefined, 1], [true, false], [2026n, 1], [2026, 0, { valueOf: () => 5 }], +]; +const made = constructed.map((args) => attempt(() => { + const d = new Date(...args); + return show(d.getTime()) + ' ' + d.toString(); +})); +const order = (() => { + const log = []; + const v = (x, n) => ({ valueOf() { log.push(n); return x; } }); + const a = new Date(v(2026, 'y'), v(0, 'm'), v(NaN, 'd'), v(1, 'h'), v(2, 'mi'), v(3, 's'), v(4, 'ms'), v(5, 'extra')).getTime(); + const b = new Date(NaN); + const c = b.setHours(v(1, 'nan-hours')); + const e = new Date(0).setMinutes(v(1, 'mi2'), v(2, 's2'), v(3, 'ms2'), v(4, 'extra2')); + return [show(a), show(c), show(e), log]; +})(); +const texts = [ + '2026-01-15T10:00:00', '2026-01-15T10:00', '2026-01-15 10:00', '2026-01-15', '2026-01', '2026', '+002026-01-15', '-000001-06-15', + '2026-01-15T10:00:00Z', '2026-01-15T10:00:00z', '2026-01-15T10:00:00+05:45', '2026-01-15T10:00:00-0330', '2026-10-25T02:30:00', + 'Thu Jan 15 2026 10:00:00 GMT+0100', 'Thu Jan 15 2026 10:00:00 GMT+0100 (CET)', 'Jan 15 2026 10:00 UTC', 'Jan 15 2026 10:00 UT', + 'January 15, 2026 10:00:00', 'January 15, 2026', '15 January 2026 23:59', '2026/01/15 10:00', '1/15/2026', '1/15/2026 13:00', + 'Thu, 15 Jan 2026 10:00:00 GMT', 'Thu, 15 Jan 2026 10:00:00', '2100-07-01T12:00:00', '2100-07-01 12:00', ' 2026-01-15 ', ' 2026 ', + 'garbage', '', ' ', '2026-02-30', '2026-01-15T24:00:00', '2026-01-15T10:00:00.5', '2026-01-15T10:00:00.123456', + 'Jan 15 2026 10:00 (comment)', 'Jan 15 2026 10:00 GMTx', '2026-01-15T10:00:00 +01:00 (CET)', '1994-12-31T12:00:00', '1986-01-01T00:10:00', + '2026-04-05T02:15:00', '2026-10-04T02:15:00', '2026-11-01T01:30:00', +]; +const parsed = texts.map((s) => [attempt(() => Date.parse(s)), attempt(() => new Date(s).getTime())]); +const singles = [ + () => new Date(['2024-01-01']).getTime(), () => new Date([5]).getTime(), () => new Date([]).getTime(), () => new Date({}).getTime(), + () => new Date({ valueOf: () => 86400000 }).getTime(), () => new Date({ toString: () => '2024-03-01T00:00:00' }).getTime(), + () => new Date({ [Symbol.toPrimitive]: (hint) => hint === 'default' ? '2024-03-01 10:00' : 0 }).getTime(), + () => new Date({ [Symbol.toPrimitive]: () => ({}) }).getTime(), () => new Date({ valueOf: () => ({}), toString: () => ({}) }).getTime(), + () => new Date({ [Symbol.toPrimitive]: 5, valueOf: () => 7 }).getTime(), () => new Date(Object.create(null)).getTime(), + () => new Date(null).getTime(), () => new Date(undefined).getTime(), () => new Date(true).getTime(), () => new Date('').getTime(), + () => new Date(new Date(1234)).getTime(), () => new Date(2020n).getTime(), () => new Date(Symbol('x')).getTime(), + () => new Date(1.9).getTime(), () => new Date(-1.9).getTime(), () => new Date(8.64e15 + 1).getTime(), () => new Date(-0).getTime(), + () => Date.parse(Symbol('x')), () => Date.parse(), () => Date.parse(12), () => Date.parse({ toString: () => '2026-01-15T10:00:00' }), + () => new Date().getTime(), () => new Date(undefined, undefined).getTime(), () => Date(), () => Date(2020, 1), () => typeof Date(), + () => { class Later extends Date { constructor(...a) { super(...a); } } const d = new Later(2026, 2, 29, 2, 30); return [d instanceof Later, d.getTime(), d.getHours(), d.toString()].join(' '); }, + () => Reflect.construct(Date, [2026, 0, 1], Array).getTime(), () => Object.prototype.toString.call(Reflect.construct(Date, [0], Array)), + () => Date.prototype.getHours.call({}), () => Date.prototype.setHours.call({}, 1), () => Date.prototype.toString.call(1), () => Date.prototype.toLocaleString.call(null), + () => Date.prototype.getTimezoneOffset.call(new Date(NaN)), () => new Date(NaN).toLocaleString(), () => new Date(NaN).toDateString(), () => new Date(NaN).toTimeString(), + () => new Date(NaN).setMonth(1), () => new Date(NaN).setFullYear(2026), () => new Date(NaN).setFullYear(2026, 5), () => new Date(0).setHours(), + () => new Date(0).toLocaleString(undefined, { timeZone: { toString: () => 'Asia/Tokyo' } }), + () => new Date(0).toLocaleString(undefined, { timeZone: Symbol('x') }), () => new Date(0).toLocaleString(undefined, 'abc'), + () => new Date(0).toLocaleString(undefined, { get timeZone() { throw new Error('zone getter'); } }), + () => new Date(0).toLocaleString(undefined, { timeZone: 'UTC' }, 'extra'), () => new Date(0).toLocaleString(undefined, { timeZone: 'Europe/Berlin' }), + () => new Date(0).toLocaleString(undefined, { timeZone: 'GMT' }), () => new Date(0).toLocaleString(undefined, { timeZone: 'Etc/GMT-14' }), + () => new Date(0).toLocaleString(undefined, { timeZone: '' }), () => new Date(0).toLocaleString(undefined, { timeZone: 'EUROPE/BERLIN' }), + () => Date.now(), () => Date.length, () => Date.name, () => Date.UTC(2026, 0), + () => { const d = new Date(0); Date.prototype.getFullYear = function () { return 42; }; return d.getYear(); }, +]; +const single = singles.map((f) => attempt(f)); +const out = { rows, made, order, parsed, single }; +"#; + +fn graph(content: Value) -> Arc { + Arc::new( + serde_json::from_value(json!({ + "nodes": [ + {"id": "in", "name": "in", "type": "inputNode"}, + {"id": "node", "name": "node", "type": "functionNode", "content": content}, + {"id": "out", "name": "out", "type": "outputNode"} + ], + "edges": [ + {"id": "e1", "sourceId": "in", "targetId": "node", "type": "edge"}, + {"id": "e2", "sourceId": "node", "targetId": "out", "type": "edge"} + ] + })) + .unwrap(), + ) +} + +fn modern() -> Arc { + graph(json!({"source": format!( + "export const handler = async (input) => {{ {SCRIPT} return {{ out: JSON.stringify(out) }}; }};" + )})) +} + +fn legacy() -> Arc { + graph(json!(format!( + "const handler = (input) => {{ {SCRIPT} return {{ out: JSON.stringify(out) }}; }}" + ))) +} + +fn run(content: Arc, zone: &str) -> Value { + let decision = DecisionEngine::default() + .with_version(EngineVersion::V2) + .create_decision(content) + .unwrap(); + let options = EvaluationOptions { + now: parse_instant("2026-03-29T00:45:00.250Z"), + timezone: parse_timezone(zone), + seed: Some(7), + ..Default::default() + }; + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let response = runtime + .block_on(decision.evaluate_with_opts(Variable::from(json!({})), options)) + .unwrap(); + let text = response.result.to_value()["out"] + .as_str() + .unwrap() + .to_string(); + let mut value: Value = serde_json::from_str(&text).unwrap(); + let rows: Vec = value["rows"] + .as_array() + .unwrap() + .iter() + .map(|row| { + let mut fields = row.as_object().unwrap().clone(); + let t = fields.remove("t").unwrap(); + let sets = fields.remove("sets").unwrap(); + json!([t, digest(&Value::Object(fields)), digest(&sets)]) + }) + .collect(); + value["rows"] = Value::Array(rows); + value +} + +fn digest(value: &Value) -> String { + let hash = value + .to_string() + .bytes() + .fold(0xcbf29ce484222325u64, |hash, byte| { + (hash ^ byte as u64).wrapping_mul(0x100000001b3) + }); + format!("{hash:016x}") +} + +fn mismatches(path: &str, want: &Value, got: &Value, found: &mut Vec) { + if found.len() > 40 { + return; + } + match (want, got) { + (Value::Object(a), Value::Object(b)) if a.len() == b.len() => { + for (key, value) in a { + match b.get(key) { + Some(other) => mismatches(&format!("{path}.{key}"), value, other, found), + None => found.push(format!("{path}.{key} missing")), + } + } + } + (Value::Array(a), Value::Array(b)) if a.len() == b.len() => { + for (i, (x, y)) in a.iter().zip(b).enumerate() { + mismatches(&format!("{path}[{i}]"), x, y, found); + } + } + _ if want != got => found.push(format!("{path}\n want: {want}\n got: {got}")), + _ => {} + } +} + +#[test] +fn pinned_dates_match_the_recorded_results_in_every_zone() { + let path = format!("{}/{FIXTURE}", env!("CARGO_MANIFEST_DIR")); + let (modern, legacy) = (modern(), legacy()); + let results: BTreeMap = ZONES + .iter() + .map(|zone| (zone.to_string(), run(modern.clone(), zone))) + .collect(); + let mut found = Vec::new(); + for zone in ["Europe/Berlin", "Pacific/Kiritimati"] { + let old = run(legacy.clone(), zone); + mismatches(&format!("legacy {zone}"), &results[zone], &old, &mut found); + } + if std::env::var("PINNED_DATES_WRITE").is_ok_and(|v| v == "1") { + let mut text = String::from("{\n"); + for (i, (zone, value)) in results.iter().enumerate() { + let rows = value["rows"].as_array().unwrap(); + let rest: serde_json::Map = value + .as_object() + .unwrap() + .iter() + .filter(|(k, _)| *k != "rows") + .map(|(k, v)| (k.clone(), v.clone())) + .collect(); + text.push_str(&format!(" {}: {{\n \"rows\": [\n", json!(zone))); + for (j, row) in rows.iter().enumerate() { + let comma = if j + 1 < rows.len() { "," } else { "" }; + text.push_str(&format!(" {row}{comma}\n")); + } + text.push_str(" ],\n"); + let keys: Vec<_> = rest.iter().collect(); + for (j, (key, value)) in keys.iter().enumerate() { + let comma = if j + 1 < keys.len() { "," } else { "" }; + text.push_str(&format!(" {}: {value}{comma}\n", json!(key))); + } + let comma = if i + 1 < results.len() { "," } else { "" }; + text.push_str(&format!(" }}{comma}\n")); + } + text.push_str("}\n"); + std::fs::write(&path, text).unwrap(); + } + let recorded: Value = serde_json::from_str(&std::fs::read_to_string(&path).unwrap()).unwrap(); + for (zone, got) in &results { + mismatches(zone, &recorded[zone], got, &mut found); + } + assert!(found.is_empty(), "{}", found.join("\n")); +} From 408fd7b22910f8173e706e2bfc34565e08130a90 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 16:12:46 +0100 Subject: [PATCH 31/32] perf(engine): pin Date in Rust instead of a JavaScript shim on version 2 Function nodes on version 2 replaced Date with a JavaScript module whose local getters, setters and string methods rebuilt every field through native calls and allocations, and whose lazy half cost about 45 us to load on the first Date use of each evaluation. The pinned constructor, Date.now, Date.parse, Math.random and the zone dependent prototype methods are now callable Rust classes built with the safe rquickjs API. They read the time value through the native getTime, compute fields and offsets with chrono-tz in Rust (fixed offset zones skip the lookup, the last instant's fields are cached per evaluation) and keep QuickJS's Date for storage and everything zone independent. The constructor is a bound function so calls and constructions are told apart exactly. The prototype methods are still installed on the first construction or parse, now in about 6 us. Results are unchanged: recorded per-zone results, version parity and the isolation spec pass as before. --- core/engine/src/compiled/pinning.entry.js | 24 - core/engine/src/compiled/pinning.js | 187 ------- core/engine/src/compiled/pinning.rs | 152 +----- core/engine/src/compiled/pinning/calendar.rs | 541 +++++++++++++++++++ core/engine/src/compiled/pinning/date.rs | 524 ++++++++++++++++++ core/engine/tests/function_parity.rs | 15 + 6 files changed, 1085 insertions(+), 358 deletions(-) delete mode 100644 core/engine/src/compiled/pinning.entry.js delete mode 100644 core/engine/src/compiled/pinning.js create mode 100644 core/engine/src/compiled/pinning/calendar.rs create mode 100644 core/engine/src/compiled/pinning/date.rs diff --git a/core/engine/src/compiled/pinning.entry.js b/core/engine/src/compiled/pinning.entry.js deleted file mode 100644 index 57099c17..00000000 --- a/core/engine/src/compiled/pinning.entry.js +++ /dev/null @@ -1,24 +0,0 @@ -export default (now, random, load) => { - const Native = globalThis.Date; - let pinned; - const pin = () => pinned || (pinned = load(Native, PinnedDate)); - const PinnedDate = { - Date: function (year, month, date, hours, minutes, seconds, ms) { - return pin().construct(new.target, arguments); - }, - }.Date; - const statics = { - now() { return now(); }, - parse(text) { return pin().parse(text); }, - random() { return random(); }, - }; - Object.defineProperties(PinnedDate, { - prototype: { value: Native.prototype, writable: false }, - now: { value: statics.now, writable: true, configurable: true }, - parse: { value: statics.parse, writable: true, configurable: true }, - UTC: { value: Native.UTC, writable: true, configurable: true }, - }); - Native.prototype.constructor = PinnedDate; - globalThis.Date = PinnedDate; - Math.random = statics.random; -}; diff --git a/core/engine/src/compiled/pinning.js b/core/engine/src/compiled/pinning.js deleted file mode 100644 index a4d918e0..00000000 --- a/core/engine/src/compiled/pinning.js +++ /dev/null @@ -1,187 +0,0 @@ -export default (Native, PinnedDate, now, offsetAt, utcAt, canonicalZone) => { - const proto = Native.prototype; - const N = {}; - for (const name of [ - 'getTime', 'setTime', 'getUTCFullYear', 'getUTCMonth', 'getUTCDate', 'getUTCDay', - 'getUTCHours', 'getUTCMinutes', 'getUTCSeconds', 'getUTCMilliseconds', 'setUTCFullYear', - 'setUTCHours', 'getFullYear', 'getMonth', 'getDate', 'getHours', 'getMinutes', 'getSeconds', - 'getMilliseconds', - ]) N[name] = proto[name]; - const call = (f, self, ...args) => f.apply(self, args); - const time = (d) => call(N.getTime, d); - - const offset = (t, zone) => { - const o = offsetAt(t, zone); - if (o === undefined) throw new RangeError('Invalid time zone specified: ' + zone); - return o; - }; - const fields = (t, zone) => { - const o = offset(t, zone); - const s = new Native(t + o * 60000); - return { - y: call(N.getUTCFullYear, s), mo: call(N.getUTCMonth, s), d: call(N.getUTCDate, s), - wd: call(N.getUTCDay, s), h: call(N.getUTCHours, s), mi: call(N.getUTCMinutes, s), - s: call(N.getUTCSeconds, s), ms: call(N.getUTCMilliseconds, s), o, - }; - }; - const localTime = (parts) => { - if (parts.some((p) => !Number.isFinite(p))) return NaN; - const s = new Native(0); - call(N.setUTCFullYear, s, parts[0], parts[1], parts[2]); - call(N.setUTCHours, s, parts[3], parts[4], parts[5], parts[6]); - return time(s); - }; - const fromLocal = (parts, zone) => { - const local = localTime(parts); - if (Number.isNaN(local)) return NaN; - const utc = utcAt(local, zone); - return utc === undefined ? NaN : utc; - }; - - const field = (date, key) => { - const t = time(date); - return Number.isNaN(t) ? NaN : fields(t)[key]; - }; - const set = (date, at, count, args) => { - const t = time(date); - let parts; - if (Number.isNaN(t)) { - if (at !== 0) return NaN; - parts = [1970, 0, 1, 0, 0, 0, 0]; - } else { - const f = fields(t); - parts = [f.y, f.mo, f.d, f.h, f.mi, f.s, f.ms]; - } - const given = args.length === 0 ? [NaN] : Array.prototype.slice.call(args, 0, count).map(Number); - given.forEach((value, i) => { parts[at + i] = value; }); - call(N.setTime, date, fromLocal(parts.map(Math.trunc))); - return time(date); - }; - - const isoDate = /^\s*[+-]?\d{4,6}(?:-\d\d(?:-\d\d)?)?\s*$/; - const zoned = /(?:\d[Zz]\s*$|[+-]\d\d:?\d\d\s*(?:\(.*\))?\s*$|\b(?:GMT|UTC|UT)\b)/; - const parse = (text) => { - const source = String(text); - const t = Native.parse(source); - if (Number.isNaN(t) || isoDate.test(source) || zoned.test(source)) return t; - const d = new Native(t); - return fromLocal([ - call(N.getFullYear, d), call(N.getMonth, d), call(N.getDate, d), call(N.getHours, d), - call(N.getMinutes, d), call(N.getSeconds, d), call(N.getMilliseconds, d), - ]); - }; - const toPrimitive = (value) => { - if ((typeof value !== 'object' && typeof value !== 'function') || value === null) return value; - const exotic = value[Symbol.toPrimitive]; - if (typeof exotic === 'function') { - const result = exotic.call(value, 'default'); - if ((typeof result !== 'object' && typeof result !== 'function') || result === null) return result; - throw new TypeError('Cannot convert object to primitive value'); - } - for (const name of ['valueOf', 'toString']) { - const method = value[name]; - if (typeof method !== 'function') continue; - const result = method.call(value); - if ((typeof result !== 'object' && typeof result !== 'function') || result === null) return result; - } - throw new TypeError('Cannot convert object to primitive value'); - }; - const valueOf = (value) => { - if (value instanceof Native) return time(value); - const primitive = toPrimitive(value); - return typeof primitive === 'string' ? parse(primitive) : +primitive; - }; - - const construct = (target, args) => { - if (!target) return new PinnedDate(now()).toString(); - let t; - if (args.length === 0) { - t = now(); - } else if (args.length === 1) { - t = valueOf(args[0]); - } else { - const parts = Array.prototype.slice.call(args, 0, 7).map(Number); - while (parts.length < 7) parts.push(parts.length === 2 ? 1 : 0); - let y = parts[0]; - if (Number.isFinite(y)) { - y = Math.trunc(y); - if (y >= 0 && y <= 99) y += 1900; - } - parts[0] = y; - t = fromLocal(parts.map((p) => (Number.isFinite(p) ? Math.trunc(p) : p))); - } - return Reflect.construct(Native, [t], target); - }; - - const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; - const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; - const pad = (n, width = 2) => String(n).padStart(width, '0'); - const year = (y) => (y < 0 ? '-' + pad(-y, 4) : pad(y, 4)); - const gmt = (o) => { - const a = Math.abs(Math.round(o)); - return 'GMT' + (o < 0 ? '-' : '+') + pad(Math.floor(a / 60)) + pad(a % 60); - }; - const datePart = (f) => `${DAYS[f.wd]} ${MONTHS[f.mo]} ${pad(f.d)} ${year(f.y)}`; - const timePart = (f) => `${pad(f.h)}:${pad(f.mi)}:${pad(f.s)} ${gmt(f.o)}`; - const resolveZone = (options) => { - const zone = options && options.timeZone; - if (zone === undefined) return undefined; - const canonical = canonicalZone(String(zone)); - return canonical == null ? undefined : canonical; - }; - const localized = (t, zone, kind) => { - if (Number.isNaN(t)) return 'Invalid Date'; - const f = fields(t, zone); - const date = `${pad(f.mo + 1)}/${pad(f.d)}/${year(f.y)}`; - const clock = `${pad(f.h % 12 || 12)}:${pad(f.mi)}:${pad(f.s)} ${f.h < 12 ? 'AM' : 'PM'}`; - if (kind === 'date') return date; - if (kind === 'time') return clock; - return `${date}, ${clock}`; - }; - const methods = { - getFullYear() { return field(this, 'y'); }, - getMonth() { return field(this, 'mo'); }, - getDate() { return field(this, 'd'); }, - getDay() { return field(this, 'wd'); }, - getHours() { return field(this, 'h'); }, - getMinutes() { return field(this, 'mi'); }, - getSeconds() { return field(this, 's'); }, - getMilliseconds() { return field(this, 'ms'); }, - getTimezoneOffset() { - const t = time(this); - return Number.isNaN(t) ? NaN : -offset(t); - }, - getYear() { - const y = this.getFullYear(); - return Number.isNaN(y) ? NaN : y - 1900; - }, - setFullYear(year, month, date) { return set(this, 0, 3, arguments); }, - setMonth(month, date) { return set(this, 1, 2, arguments); }, - setDate(date) { return set(this, 2, 1, arguments); }, - setHours(hours, minutes, seconds, ms) { return set(this, 3, 4, arguments); }, - setMinutes(minutes, seconds, ms) { return set(this, 4, 3, arguments); }, - setSeconds(seconds, ms) { return set(this, 5, 2, arguments); }, - setMilliseconds(ms) { return set(this, 6, 1, arguments); }, - toString() { - const t = time(this); - if (Number.isNaN(t)) return 'Invalid Date'; - const f = fields(t); - return `${datePart(f)} ${timePart(f)}`; - }, - toDateString() { - const t = time(this); - return Number.isNaN(t) ? 'Invalid Date' : datePart(fields(t)); - }, - toTimeString() { - const t = time(this); - return Number.isNaN(t) ? 'Invalid Date' : timePart(fields(t)); - }, - toLocaleString() { return localized(time(this), resolveZone(arguments[1]), 'both'); }, - toLocaleDateString() { return localized(time(this), resolveZone(arguments[1]), 'date'); }, - toLocaleTimeString() { return localized(time(this), resolveZone(arguments[1]), 'time'); }, - }; - for (const name of Object.keys(methods)) { - if (name in proto) proto[name] = methods[name]; - } - return { construct, parse }; -}; diff --git a/core/engine/src/compiled/pinning.rs b/core/engine/src/compiled/pinning.rs index 0036bf89..e653a955 100644 --- a/core/engine/src/compiled/pinning.rs +++ b/core/engine/src/compiled/pinning.rs @@ -1,10 +1,7 @@ +mod calendar; +mod date; + use crate::engine::EvaluationOptions; -use chrono::{DateTime, Duration, LocalResult, Offset, TimeZone}; -use rquickjs::loader::bundle::{Bundle, ScaBundleData}; -use rquickjs::loader::Loader; -use rquickjs::prelude::Func; -use rquickjs::promise::PromiseState; -use rquickjs::{Module, WriteOptions}; use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; @@ -131,9 +128,6 @@ impl Located { } } -const PIN_ENTRY: (&str, &str) = ("zen:pinning", include_str!("pinning.entry.js")); -const PIN_DATE: (&str, &str) = ("zen:pinning/date", include_str!("pinning.js")); - fn canonical_zone(name: &str) -> Option { static ZONES: OnceLock> = OnceLock::new(); parse_timezone(name).or_else(|| { @@ -197,143 +191,7 @@ impl JsSlot { } } - fn zone(&self, name: Option) -> Option { - match name { - Some(name) => canonical_zone(&name), - None => Some(self.timezone()), - } - } - - fn modelled(ms: f64) -> Option { - use chrono::Datelike; - const CYCLE: f64 = 146_097.0 * 86_400_000.0; - const SPAN: f64 = 250_000.0 * 365.2425 * 86_400_000.0; - let cycles = match ms.abs() > SPAN { - true => ((ms.abs() - SPAN) / CYCLE).ceil() * ms.signum(), - false => 0.0, - }; - let at = DateTime::from_timestamp_millis((ms - cycles * CYCLE) as i64)?.naive_utc(); - if at.year() <= 2099 { - return Some(at); - } - let year = chrono::NaiveDate::from_yo_opt(at.year(), 1)?; - let twin = (2072..=2099).find(|candidate| { - chrono::NaiveDate::from_yo_opt(*candidate, 1).is_some_and(|first| { - first.leap_year() == year.leap_year() && first.weekday() == year.weekday() - }) - })?; - Some(chrono::NaiveDate::from_yo_opt(twin, at.ordinal())?.and_time(at.time())) - } - - fn offset(&self, ms: f64, name: Option) -> Option { - let zone = self.zone(name)?; - if !ms.is_finite() { - return None; - } - let at = Self::modelled(ms)?; - let seconds = zone.offset_from_utc_datetime(&at).fix().local_minus_utc(); - Some(seconds as f64 / 60.0) - } - - fn utc(&self, local: f64, name: Option) -> Option { - let zone = self.zone(name)?; - if !local.is_finite() { - return None; - } - let naive = Self::modelled(local)?; - let offset = match zone.offset_from_local_datetime(&naive) { - LocalResult::Single(offset) => offset.fix(), - LocalResult::Ambiguous(earlier, _) => earlier.fix(), - LocalResult::None => zone - .offset_from_local_datetime(&(naive - Duration::hours(3))) - .earliest()? - .fix(), - }; - Some(local - offset.local_minus_utc() as f64 * 1000.0) - } - - fn bundle() -> Option>> { - static CODE: OnceLock; 2]>> = OnceLock::new(); - static BUNDLE: OnceLock> = OnceLock::new(); - BUNDLE - .get_or_init(|| { - let code = CODE.get_or_init(|| { - let runtime = rquickjs::Runtime::new().ok()?; - let context = rquickjs::Context::full(&runtime).ok()?; - context.with(|ctx| { - let compile = |name: &str, source: &str| { - Module::declare(ctx.clone(), name, source) - .and_then(|module| { - module.write(WriteOptions { - strip_source: true, - ..Default::default() - }) - }) - .ok() - }; - Some([ - compile(PIN_ENTRY.0, PIN_ENTRY.1)?, - compile(PIN_DATE.0, PIN_DATE.1)?, - ]) - }) - }); - code.as_ref().map(|[entry, date]| { - [ - (PIN_ENTRY.0, entry.as_slice()), - (PIN_DATE.0, date.as_slice()), - ] - }) - }) - .as_ref() - .map(|entries| Bundle(entries.as_slice())) - } - - fn evaluate<'js>( - ctx: &rquickjs::Ctx<'js>, - (name, source): (&str, &str), - ) -> rquickjs::Result> { - let declared = match Self::bundle() { - Some(mut bundle) => bundle.load(ctx, name)?, - None => Module::declare(ctx.clone(), name, source)?, - }; - let (module, promise) = declared.eval()?; - if promise.state() != PromiseState::Resolved { - return Err(rquickjs::Error::new_loading(name)); - } - module.get("default") - } - - pub(crate) fn install<'js>(&self, ctx: &rquickjs::Ctx<'js>) -> rquickjs::Result<()> { - let entry = Self::evaluate(ctx, PIN_ENTRY)?; - let (now, random, slot) = (self.clone(), self.clone(), self.clone()); - entry.call(( - Func::from(move || now.now()), - Func::from(move || random.random()), - Func::from( - move |ctx: rquickjs::Ctx<'js>, - native: rquickjs::Value<'js>, - pinned: rquickjs::Value<'js>| { - slot.load(&ctx, native, pinned) - }, - ), - )) - } - - fn load<'js>( - &self, - ctx: &rquickjs::Ctx<'js>, - native: rquickjs::Value<'js>, - pinned: rquickjs::Value<'js>, - ) -> rquickjs::Result> { - let date = Self::evaluate(ctx, PIN_DATE)?; - let (now, offset, utc) = (self.clone(), self.clone(), self.clone()); - date.call(( - native, - pinned, - Func::from(move || now.now()), - Func::from(move |ms: f64, zone: Option| offset.offset(ms, zone)), - Func::from(move |local: f64, zone: Option| utc.utc(local, zone)), - Func::from(|name: String| canonical_zone(&name).map(|zone| zone.name().to_string())), - )) + pub(crate) fn install(&self, ctx: &rquickjs::Ctx<'_>) -> rquickjs::Result<()> { + date::install(ctx, self) } } diff --git a/core/engine/src/compiled/pinning/calendar.rs b/core/engine/src/compiled/pinning/calendar.rs new file mode 100644 index 00000000..8efa0d3c --- /dev/null +++ b/core/engine/src/compiled/pinning/calendar.rs @@ -0,0 +1,541 @@ +use chrono::{DateTime, Duration, LocalResult, Offset, TimeZone}; +use chrono_tz::Tz; +use std::fmt::Write; + +const DAY: f64 = 86_400_000.0; +pub(super) const LOCALE_BOTH: u8 = 0; +pub(super) const LOCALE_DATE: u8 = 1; +pub(super) const LOCALE_TIME: u8 = 2; + +const DAYS: [&str; 7] = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; +const MONTHS: [&str; 12] = [ + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", +]; +const MONTH_DAYS: [i64; 12] = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + +#[derive(Clone, Copy)] +pub(super) struct Zone { + pub(super) tz: Tz, + fixed: Option, +} + +impl Zone { + pub(super) fn of(tz: Tz) -> Self { + let name = tz.name(); + let fixed = matches!( + name, + "UTC" | "UCT" | "GMT" | "GMT0" | "GMT+0" | "GMT-0" | "Greenwich" | "Universal" | "Zulu" + ) || name.starts_with("Etc/"); + Self { + tz, + fixed: fixed.then(|| { + tz.offset_from_utc_datetime(&chrono::NaiveDateTime::default()) + .fix() + .local_minus_utc() + }), + } + } + + pub(super) fn offset(&self, ms: f64) -> Option { + if let Some(fixed) = self.fixed { + return Some(fixed); + } + let at = modelled(ms)?; + Some( + self.tz + .offset_from_utc_datetime(&at) + .fix() + .local_minus_utc(), + ) + } + + pub(super) fn utc(&self, local: f64) -> f64 { + if let Some(fixed) = self.fixed { + return local - fixed as f64 * 1000.0; + } + let Some(naive) = modelled(local) else { + return f64::NAN; + }; + let offset = match self.tz.offset_from_local_datetime(&naive) { + LocalResult::Single(offset) => offset.fix(), + LocalResult::Ambiguous(earlier, _) => earlier.fix(), + LocalResult::None => { + match self + .tz + .offset_from_local_datetime(&(naive - Duration::hours(3))) + .earliest() + { + Some(offset) => offset.fix(), + None => return f64::NAN, + } + } + }; + local - offset.local_minus_utc() as f64 * 1000.0 + } +} + +fn modelled(ms: f64) -> Option { + use chrono::Datelike; + const CYCLE: f64 = 146_097.0 * 86_400_000.0; + const SPAN: f64 = 250_000.0 * 365.2425 * 86_400_000.0; + if !ms.is_finite() { + return None; + } + let cycles = match ms.abs() > SPAN { + true => ((ms.abs() - SPAN) / CYCLE).ceil() * ms.signum(), + false => 0.0, + }; + let at = DateTime::from_timestamp_millis((ms - cycles * CYCLE) as i64)?.naive_utc(); + if at.year() <= 2099 { + return Some(at); + } + let year = chrono::NaiveDate::from_yo_opt(at.year(), 1)?; + let twin = (2072..=2099).find(|candidate| { + chrono::NaiveDate::from_yo_opt(*candidate, 1).is_some_and(|first| { + first.leap_year() == year.leap_year() && first.weekday() == year.weekday() + }) + })?; + Some(chrono::NaiveDate::from_yo_opt(twin, at.ordinal())?.and_time(at.time())) +} + +fn floor_div(a: i64, b: i64) -> i64 { + let m = a % b; + (a - (m + (m < 0) as i64 * b)) / b +} + +fn math_mod(a: i64, b: i64) -> i64 { + let m = a % b; + m + (m < 0) as i64 * b +} + +fn days_from_year(y: i64) -> i64 { + 365 * (y - 1970) + floor_div(y - 1969, 4) - floor_div(y - 1901, 100) + floor_div(y - 1601, 400) +} + +fn days_in_year(y: i64) -> i64 { + 365 + (y % 4 == 0) as i64 - (y % 100 == 0) as i64 + (y % 400 == 0) as i64 +} + +#[cfg(test)] +fn year_from_days(days: &mut i64) -> i64 { + let d = *days; + let mut y = floor_div(d * 10000, 3652425) + 1970; + loop { + let mut d1 = d - days_from_year(y); + if d1 < 0 { + y -= 1; + d1 += days_in_year(y); + *days = d1; + return y; + } + let nd = days_in_year(y); + if d1 < nd { + *days = d1; + return y; + } + y += 1; + } +} + +pub(super) fn time_clip(t: f64) -> f64 { + if (-8.64e15..=8.64e15).contains(&t) { + t.trunc() + 0.0 + } else { + f64::NAN + } +} + +fn civil(days: i64) -> (i64, i64, i64) { + let z = days + 719_468; + let era = z.div_euclid(146_097); + let doe = z.rem_euclid(146_097); + let yoe = (doe - doe / 1460 + doe / 36_524 - doe / 146_096) / 365; + let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); + let mp = (5 * doy + 2) / 153; + let day = doy - (153 * mp + 2) / 5 + 1; + let month = if mp < 10 { mp + 2 } else { mp - 10 }; + (yoe + era * 400 + (month <= 1) as i64, month, day) +} + +pub(super) fn decompose(d: i64) -> [f64; 8] { + let ms_of_day = math_mod(d, 86_400_000); + let days = (d - ms_of_day) / 86_400_000; + let (y, month, day) = civil(days); + [ + y as f64, + month as f64, + day as f64, + math_mod(days + 4, 7) as f64, + (ms_of_day / 3_600_000) as f64, + (ms_of_day / 60_000 % 60) as f64, + (ms_of_day / 1000 % 60) as f64, + (ms_of_day % 1000) as f64, + ] +} + +fn make_date(fields: [f64; 7]) -> f64 { + let [y, m, dt, h, mi, s, milli] = fields; + let ym = y + (m / 12.0).floor(); + let mut mn = m % 12.0; + if mn < 0.0 { + mn += 12.0; + } + if !(-271821.0..=275760.0).contains(&ym) { + return f64::NAN; + } + let yi = ym as i64; + let mi_count = mn as usize; + let mut days = days_from_year(yi); + for (i, md) in MONTH_DAYS.iter().enumerate().take(mi_count) { + days += md; + if i == 1 { + days += days_in_year(yi) - 365; + } + } + let day = days as f64 + dt - 1.0; + let mut time = h * 3_600_000.0; + time += mi * 60_000.0; + time += s * 1000.0; + time += milli; + let tv = day * DAY + time; + if !tv.is_finite() { + return f64::NAN; + } + time_clip(tv) +} + +pub(super) fn local_time(parts: [f64; 7]) -> f64 { + if parts.iter().any(|p| !p.is_finite()) { + return f64::NAN; + } + let first = make_date([parts[0], parts[1], parts[2], 0.0, 0.0, 0.0, 0.0]); + if first.is_nan() { + return f64::NAN; + } + let f = decompose(first as i64); + make_date([f[0], f[1], f[2], parts[3], parts[4], parts[5], parts[6]]) +} + +#[derive(Clone, Copy)] +pub(super) struct Fields { + pub(super) values: [f64; 8], + pub(super) offset: f64, +} + +pub(super) fn fields(t: f64, zone: Zone) -> Option { + let seconds = zone.offset(t)?; + let offset = seconds as f64 / 60.0; + let shifted = time_clip(t + offset * 60000.0); + let values = match shifted.is_nan() { + true => [f64::NAN; 8], + false => decompose(shifted as i64), + }; + Some(Fields { values, offset }) +} + +pub(super) fn from_local(parts: [f64; 7], zone: Zone) -> f64 { + let local = local_time(parts); + if local.is_nan() { + return f64::NAN; + } + zone.utc(local) +} + +fn number(n: f64) -> String { + let mut out = String::new(); + push_number(&mut out, n); + out +} + +fn push_number(out: &mut String, n: f64) { + if n.is_nan() { + out.push_str("NaN"); + } else { + let _ = write!(out, "{}", n as i64); + } +} + +fn pad(out: &mut String, n: f64, width: usize) { + let text = number(n); + for _ in text.len()..width { + out.push('0'); + } + out.push_str(&text); +} + +fn year(out: &mut String, y: f64) { + if y < 0.0 { + out.push('-'); + pad(out, -y, 4); + } else { + pad(out, y, 4); + } +} + +fn round(x: f64) -> f64 { + let r = x.floor(); + if x - r >= 0.5 { + r + 1.0 + } else { + r + } +} + +fn gmt(out: &mut String, o: f64) { + let a = round(o).abs(); + out.push_str("GMT"); + out.push(if o < 0.0 { '-' } else { '+' }); + pad(out, (a / 60.0).floor(), 2); + pad(out, a % 60.0, 2); +} + +fn label(list: &[&'static str], index: f64) -> &'static str { + match index.is_nan() { + true => "undefined", + false => list.get(index as usize).copied().unwrap_or("undefined"), + } +} + +pub(super) fn date_part(out: &mut String, f: &Fields) { + out.push_str(label(&DAYS, f.values[3])); + out.push(' '); + out.push_str(label(&MONTHS, f.values[1])); + out.push(' '); + pad(out, f.values[2], 2); + out.push(' '); + year(out, f.values[0]); +} + +pub(super) fn time_part(out: &mut String, f: &Fields) { + pad(out, f.values[4], 2); + out.push(':'); + pad(out, f.values[5], 2); + out.push(':'); + pad(out, f.values[6], 2); + out.push(' '); + gmt(out, f.offset); +} + +pub(super) fn localized(f: &Fields, kind: u8) -> String { + let mut date = String::with_capacity(24); + pad(&mut date, f.values[1] + 1.0, 2); + date.push('/'); + pad(&mut date, f.values[2], 2); + date.push('/'); + year(&mut date, f.values[0]); + if kind == LOCALE_DATE { + return date; + } + let h = f.values[4]; + let twelve = match h % 12.0 { + x if x == 0.0 || x.is_nan() => 12.0, + x => x, + }; + let mut clock = String::with_capacity(12); + pad(&mut clock, twelve, 2); + clock.push(':'); + pad(&mut clock, f.values[5], 2); + clock.push(':'); + pad(&mut clock, f.values[6], 2); + clock.push_str(if h < 12.0 { " AM" } else { " PM" }); + if kind == LOCALE_TIME { + return clock; + } + date.push_str(", "); + date.push_str(&clock); + date +} + +fn is_space(c: char) -> bool { + matches!( + c, + '\t' | '\n' | '\u{b}' | '\u{c}' | '\r' | ' ' | '\u{a0}' | '\u{1680}' | '\u{2000}' + ..='\u{200a}' + | '\u{2028}' + | '\u{2029}' + | '\u{202f}' + | '\u{205f}' + | '\u{3000}' + | '\u{feff}' + ) +} + +fn is_terminator(c: char) -> bool { + matches!(c, '\n' | '\r' | '\u{2028}' | '\u{2029}') +} + +fn is_word(c: char) -> bool { + c.is_ascii_alphanumeric() || c == '_' +} + +fn digits(s: &str) -> usize { + s.bytes().take_while(u8::is_ascii_digit).count() +} + +pub(super) fn iso_date(text: &str) -> bool { + let body = text.trim_matches(is_space); + let body = body.strip_prefix(['+', '-']).unwrap_or(body); + let year = digits(body); + if !(4..=6).contains(&year) { + return false; + } + let mut rest = &body[year..]; + for _ in 0..2 { + if rest.is_empty() { + return true; + } + match rest.strip_prefix('-') { + Some(tail) if digits(tail) >= 2 => rest = &tail[2..], + _ => return false, + } + } + rest.is_empty() +} + +fn ends_with_offset(text: &str) -> bool { + let bytes = text.as_bytes(); + let n = bytes.len(); + let digit = |i: usize| bytes[i].is_ascii_digit(); + let sign = |i: usize| bytes[i] == b'+' || bytes[i] == b'-'; + (n >= 5 && sign(n - 5) && (n - 4..n).all(digit)) + || (n >= 6 + && sign(n - 6) + && digit(n - 5) + && digit(n - 4) + && bytes[n - 3] == b':' + && digit(n - 2) + && digit(n - 1)) +} + +pub(super) fn zoned(text: &str) -> bool { + let trimmed = text.trim_end_matches(is_space); + if let Some(before) = trimmed.strip_suffix(['Z', 'z']) { + if before.ends_with(|c: char| c.is_ascii_digit()) { + return true; + } + } + if ends_with_offset(trimmed) { + return true; + } + if let Some(inner) = trimmed.strip_suffix(')') { + for (i, c) in inner.char_indices().rev() { + if is_terminator(c) { + break; + } + if c == '(' && ends_with_offset(inner[..i].trim_end_matches(is_space)) { + return true; + } + } + } + let chars: Vec = text.chars().collect(); + for i in 0..chars.len() { + if i > 0 && is_word(chars[i - 1]) { + continue; + } + for word in ["GMT", "UTC", "UT"] { + let len = word.len(); + if chars.len() >= i + len + && chars[i..i + len].iter().copied().eq(word.chars()) + && chars.get(i + len).is_none_or(|c| !is_word(*c)) + { + return true; + } + } + } + false +} + +#[cfg(test)] +mod tests { + use super::*; + use chrono::TimeZone; + + fn iterative(d: i64) -> [f64; 8] { + let mut h = math_mod(d, 86_400_000); + let mut days = (d - h) / 86_400_000; + let ms = h % 1000; + h = (h - ms) / 1000; + let s = h % 60; + h = (h - s) / 60; + let m = h % 60; + h = (h - m) / 60; + let wd = math_mod(days + 4, 7); + let y = year_from_days(&mut days); + let mut month = 0; + while month < 11 { + let mut md = MONTH_DAYS[month]; + if month == 1 { + md += days_in_year(y) - 365; + } + if days < md { + break; + } + days -= md; + month += 1; + } + [ + y as f64, + month as f64, + (days + 1) as f64, + wd as f64, + h as f64, + m as f64, + s as f64, + ms as f64, + ] + } + + #[test] + fn decomposition_matches_the_iterative_calendar() { + let mut at: i64 = -8_640_000_000_000_000 - 50 * 86_400_000; + let mut step: u64 = 1; + while at <= 8_640_000_000_000_000 + 50 * 86_400_000 { + assert_eq!(decompose(at), iterative(at), "{at}"); + step = step + .wrapping_mul(6364136223846793005) + .wrapping_add(1442695040888963407); + at += (step >> 20) as i64 % 400_000_000_000 + 1; + } + for day in -1_000_000i64..1_000_000 { + for ms in [0, 1, 43_200_000, 86_399_999] { + let at = day * 86_400_000 + ms; + assert_eq!(decompose(at), iterative(at), "{at}"); + } + } + } + + #[test] + fn fixed_zones_never_change_offset() { + for tz in chrono_tz::TZ_VARIANTS { + let zone = Zone::of(tz); + let Some(fixed) = zone.fixed else { continue }; + for ms in [-8.64e15, -1e13, -2e12, 0.0, 1.7e12, 4.1e12, 8.64e15] { + let at = modelled(ms).expect("instant in range"); + let seconds = tz.offset_from_utc_datetime(&at).fix().local_minus_utc(); + assert_eq!(seconds, fixed, "{}", tz.name()); + } + } + } + + #[test] + fn zone_patterns_follow_the_script_expressions() { + assert!(iso_date(" 2026-01-15 ")); + assert!(iso_date("+002026-01")); + assert!(iso_date("\u{a0}2026\u{feff}")); + assert!(!iso_date("2026-01-15T10:00")); + assert!(!iso_date("1234567")); + assert!(!iso_date("2026-1")); + assert!(zoned("2026-01-15T10:00:00Z")); + assert!(zoned("2026-01-15T10:00:00z \n")); + assert!(!zoned("Z")); + assert!(zoned("10:00 +01:00 (CET)")); + assert!(zoned("10:00 -0330")); + assert!(zoned("10:00 +0100 (a (b) c)")); + assert!(!zoned("10:00 +0100 (a\nb)")); + assert!(zoned("Jan 1 2026 UT")); + assert!(zoned("UTC")); + assert!(!zoned("GMTx")); + assert!(!zoned("xUTC")); + assert!(zoned("a-UTC")); + } +} diff --git a/core/engine/src/compiled/pinning/date.rs b/core/engine/src/compiled/pinning/date.rs new file mode 100644 index 00000000..04a2372f --- /dev/null +++ b/core/engine/src/compiled/pinning/date.rs @@ -0,0 +1,524 @@ +use super::calendar::{ + date_part, decompose, fields, from_local, iso_date, localized, time_part, zoned, Fields, Zone, + LOCALE_BOTH, LOCALE_DATE, LOCALE_TIME, +}; +use super::{canonical_zone, JsSlot}; +use chrono_tz::Tz; +use rquickjs::class::{JsCell, JsClass, Readable, Trace, Tracer}; +use rquickjs::function::{Constructor, Params, This}; +use rquickjs::object::Property; +use rquickjs::{ + Class, Coerced, Ctx, Exception, FromJs, Function, IntoJs, Object, Result, Symbol, Value, +}; +use std::cell::Cell; +use std::rc::Rc; + +#[derive(Clone, rquickjs::JsLifetime)] +struct Natives<'js> { + native: Constructor<'js>, + get_time: Function<'js>, + set_time: Function<'js>, + parse: Function<'js>, + machine_offset: Function<'js>, +} + +impl<'js> Trace<'js> for Natives<'js> { + fn trace<'a>(&self, tracer: Tracer<'a, 'js>) { + self.native.as_value().trace(tracer); + self.get_time.trace(tracer); + self.set_time.trace(tracer); + self.parse.trace(tracer); + self.machine_offset.trace(tracer); + } +} + +struct State { + slot: JsSlot, + loaded: Cell, + zone: Cell>, + last: Cell>, +} + +#[derive(Clone, Copy)] +enum Getter { + Field(usize), + Offset, + Year, +} + +#[derive(Clone, Copy)] +enum Text { + Full, + Date, + Time, +} + +#[derive(Clone, Copy)] +enum Op { + Construct, + Now, + Parse, + Random, + Get(Getter), + Set(usize, usize), + Text(Text), + Locale(u8), +} + +const METHODS: [(&str, usize, Op); 23] = [ + ("getFullYear", 0, Op::Get(Getter::Field(0))), + ("getMonth", 0, Op::Get(Getter::Field(1))), + ("getDate", 0, Op::Get(Getter::Field(2))), + ("getDay", 0, Op::Get(Getter::Field(3))), + ("getHours", 0, Op::Get(Getter::Field(4))), + ("getMinutes", 0, Op::Get(Getter::Field(5))), + ("getSeconds", 0, Op::Get(Getter::Field(6))), + ("getMilliseconds", 0, Op::Get(Getter::Field(7))), + ("getTimezoneOffset", 0, Op::Get(Getter::Offset)), + ("getYear", 0, Op::Get(Getter::Year)), + ("setFullYear", 3, Op::Set(0, 3)), + ("setMonth", 2, Op::Set(1, 2)), + ("setDate", 1, Op::Set(2, 1)), + ("setHours", 4, Op::Set(3, 4)), + ("setMinutes", 3, Op::Set(4, 3)), + ("setSeconds", 2, Op::Set(5, 2)), + ("setMilliseconds", 1, Op::Set(6, 1)), + ("toString", 0, Op::Text(Text::Full)), + ("toDateString", 0, Op::Text(Text::Date)), + ("toTimeString", 0, Op::Text(Text::Time)), + ("toLocaleString", 0, Op::Locale(LOCALE_BOTH)), + ("toLocaleDateString", 0, Op::Locale(LOCALE_DATE)), + ("toLocaleTimeString", 0, Op::Locale(LOCALE_TIME)), +]; + +#[derive(rquickjs::JsLifetime)] +struct Pinned<'js> { + natives: Natives<'js>, + state: Rc, + op: Op, +} + +impl<'js> Trace<'js> for Pinned<'js> { + fn trace<'a>(&self, tracer: Tracer<'a, 'js>) { + self.natives.trace(tracer); + } +} + +impl<'js> JsClass<'js> for Pinned<'js> { + const NAME: &'static str = "Function"; + const CALLABLE: bool = true; + type Mutable = Readable; + + fn prototype(ctx: &Ctx<'js>) -> Result>> { + Ok(Some(Function::prototype(ctx.clone()))) + } + + fn constructor(_ctx: &Ctx<'js>) -> Result>> { + Ok(None) + } + + fn call<'a>(this: &JsCell<'js, Self>, params: Params<'a, 'js>) -> Result> { + let pinned = this.borrow(); + let ctx = params.ctx(); + let scope = Scope { + ctx, + natives: &pinned.natives, + state: &pinned.state, + }; + let receiver = params.this(); + let args = |from: usize| { + (from..params.len()) + .filter_map(|i| params.arg(i)) + .collect::>() + }; + match pinned.op { + Op::Get(getter) => scope.get(receiver, getter), + Op::Set(at, count) => scope.set(receiver, args(0), at, count)?.into_js(ctx), + Op::Text(kind) => scope.text(receiver, kind)?.into_js(ctx), + Op::Locale(kind) => scope.locale(receiver, params.arg(1), kind)?.into_js(ctx), + Op::Construct => scope.construct(receiver, params.function(), ¶ms), + Op::Now => pinned.state.slot.now().into_js(ctx), + Op::Random => pinned.state.slot.random().into_js(ctx), + Op::Parse => { + scope.load()?; + let text = params + .arg(0) + .unwrap_or_else(|| Value::new_undefined(ctx.clone())); + scope.parse(text)?.into_js(ctx) + } + } + } +} + +fn create<'js>( + ctx: &Ctx<'js>, + natives: &Natives<'js>, + state: &Rc, + op: Op, + name: &str, + length: usize, +) -> Result> { + let pinned = Pinned { + natives: natives.clone(), + state: state.clone(), + op, + }; + let instance = Class::instance_proto(pinned, Function::prototype(ctx.clone()))?; + let function = Function::from_js(ctx, instance.into_value())?; + function.with_length(length)?.with_name(name) +} + +struct Scope<'a, 'js> { + ctx: &'a Ctx<'js>, + natives: &'a Natives<'js>, + state: &'a Rc, +} + +impl<'js> Scope<'_, 'js> { + fn zone(&self) -> Zone { + let tz = self.state.slot.timezone(); + match self.state.zone.get() { + Some(zone) if zone.tz == tz => zone, + _ => { + let zone = Zone::of(tz); + self.state.zone.set(Some(zone)); + zone + } + } + } + + fn time(&self, value: Value<'js>) -> Result { + self.natives.get_time.call((This(value),)) + } + + fn fields(&self, t: f64, zone: Zone) -> Result { + if let Some((at, tz, fields)) = self.state.last.get() { + if at == t && tz == zone.tz { + return Ok(fields); + } + } + let fields = fields(t, zone).ok_or_else(|| { + Exception::throw_range(self.ctx, "Invalid time zone specified: undefined") + })?; + self.state.last.set(Some((t, zone.tz, fields))); + Ok(fields) + } + + fn invoke(&self, method: Value<'js>, this: Value<'js>) -> Result> { + match method.as_function() { + Some(method) => method.call((This(this),)), + None => Err(Exception::throw_type(self.ctx, "not a function")), + } + } + + fn global(&self, name: &str) -> Result> { + self.ctx.globals().get(name) + } + + fn number(&self, value: Value<'js>) -> Result { + match value.as_number() { + Some(n) => Ok(n), + None => self.global("Number")?.call((value,)), + } + } + + fn string(&self, value: Value<'js>) -> Result> { + let text: rquickjs::String<'js> = match value.as_string() { + Some(text) => text.clone(), + None => self.global("String")?.call((value,))?, + }; + Ok(text.to_string().ok()) + } + + fn plus(&self, value: Value<'js>) -> Result { + if value.is_big_int() { + return Err(Exception::throw_type( + self.ctx, + "bigint argument with unary +", + )); + } + Ok(Coerced::::from_js(self.ctx, value)?.0) + } + + fn primitive(&self, value: Value<'js>) -> Result> { + let Some(object) = value.as_object() else { + return Ok(value); + }; + let symbol: Object<'js> = self.ctx.globals().get("Symbol")?; + let key: Symbol<'js> = symbol.get("toPrimitive")?; + let exotic: Value<'js> = object.get(key)?; + if let Some(exotic) = exotic.as_function() { + let result: Value<'js> = exotic.call((This(value.clone()), "default"))?; + if !result.is_object() { + return Ok(result); + } + return Err(Exception::throw_type( + self.ctx, + "Cannot convert object to primitive value", + )); + } + for name in ["valueOf", "toString"] { + let method: Value<'js> = object.get(name)?; + if let Some(method) = method.as_function() { + let result: Value<'js> = method.call((This(value.clone()),))?; + if !result.is_object() { + return Ok(result); + } + } + } + Err(Exception::throw_type( + self.ctx, + "Cannot convert object to primitive value", + )) + } + + fn parse(&self, value: Value<'js>) -> Result { + let source: rquickjs::String<'js> = match value.as_string() { + Some(text) => text.clone(), + None => self.global("String")?.call((value,))?, + }; + let t: f64 = self + .natives + .parse + .call((This(self.natives.native.clone()), source.clone()))?; + let reinterpret = match source.to_string() { + Ok(text) => !iso_date(&text) && !zoned(&text), + Err(_) => true, + }; + if t.is_nan() || !reinterpret { + return Ok(t); + } + let date: Value<'js> = self.natives.native.construct((t,))?; + let machine: f64 = self.natives.machine_offset.call((This(date),))?; + let local = decompose(t as i64 + (-machine as i64) * 60000); + Ok(from_local( + [ + local[0], local[1], local[2], local[4], local[5], local[6], local[7], + ], + self.zone(), + )) + } + + fn value_of(&self, value: Value<'js>) -> Result { + if let Some(n) = value.as_number() { + return Ok(n); + } + if let Some(object) = value.as_object() { + if object.is_instance_of(&self.natives.native) { + return self.time(value); + } + } + let primitive = self.primitive(value)?; + match primitive.is_string() { + true => self.parse(primitive), + false => self.plus(primitive), + } + } + + fn time_of(&self, args: Vec>) -> Result { + let mut parts = [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0]; + for (part, value) in parts.iter_mut().zip(args) { + *part = self.number(value)?; + } + let mut y = parts[0]; + if y.is_finite() { + y = y.trunc(); + if (0.0..=99.0).contains(&y) { + y += 1900.0; + } + } + parts[0] = y; + let parts = parts.map(|p| if p.is_finite() { p.trunc() } else { p }); + Ok(from_local(parts, self.zone())) + } + + fn year(&self, this: Value<'js>) -> Result> { + let ctx = self.ctx.clone(); + let y: Value<'js> = match this.as_object() { + Some(object) => self.invoke(object.get("getFullYear")?, this.clone())?, + None => ctx + .eval::, _>("(value) => value.getFullYear()")? + .call((this,))?, + }; + match y.as_number() { + Some(y) if y.is_nan() => Ok(Value::new_number(ctx, f64::NAN)), + _ => { + let y = Coerced::::from_js(&ctx, y)?.0; + Ok(Value::new_number(ctx, y - 1900.0)) + } + } + } + + fn get(&self, this: Value<'js>, getter: Getter) -> Result> { + if let Getter::Year = getter { + return self.year(this); + } + let ctx = self.ctx.clone(); + let t = self.time(this)?; + if t.is_nan() { + return Ok(Value::new_number(ctx, f64::NAN)); + } + let zone = self.zone(); + match getter { + Getter::Field(index) => Ok(Value::new_number(ctx, self.fields(t, zone)?.values[index])), + _ => match zone.offset(t) { + Some(0) => Ok(Value::new_float(ctx, -0.0)), + Some(seconds) => Ok(Value::new_number(ctx, -(seconds as f64 / 60.0))), + None => self + .fields(t, zone) + .map(|_| Value::new_number(ctx, f64::NAN)), + }, + } + } + + fn set(&self, this: Value<'js>, args: Vec>, at: usize, count: usize) -> Result { + let t = self.time(this.clone())?; + let zone = self.zone(); + let mut parts = match t.is_nan() { + true if at != 0 => return Ok(f64::NAN), + true => [1970.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0], + false => { + let f = self.fields(t, zone)?.values; + [f[0], f[1], f[2], f[4], f[5], f[6], f[7]] + } + }; + if args.is_empty() { + parts[at] = f64::NAN; + } + for (i, value) in args.into_iter().take(count).enumerate() { + parts[at + i] = self.number(value)?; + } + let value = from_local(parts.map(f64::trunc), zone); + self.natives.set_time.call((This(this), value)) + } + + fn text(&self, this: Value<'js>, kind: Text) -> Result { + let t = self.time(this)?; + if t.is_nan() { + return Ok("Invalid Date".to_string()); + } + let f = self.fields(t, self.zone())?; + let mut out = String::with_capacity(40); + if !matches!(kind, Text::Time) { + date_part(&mut out, &f); + } + if matches!(kind, Text::Full) { + out.push(' '); + } + if !matches!(kind, Text::Date) { + time_part(&mut out, &f); + } + Ok(out) + } + + fn locale(&self, this: Value<'js>, options: Option>, kind: u8) -> Result { + let t = self.time(this)?; + let zone = match options { + Some(options) if Coerced::::from_js(self.ctx, options.clone())?.0 => { + let zone: Value<'js> = match options.as_object() { + Some(object) => object.get("timeZone")?, + None => self + .ctx + .eval::, _>("(value) => value.timeZone")? + .call((options,))?, + }; + match zone.is_undefined() { + true => self.zone(), + false => match self.string(zone)?.as_deref().and_then(canonical_zone) { + Some(tz) => Zone::of(tz), + None => self.zone(), + }, + } + } + _ => self.zone(), + }; + if t.is_nan() { + return Ok("Invalid Date".to_string()); + } + Ok(localized(&self.fields(t, zone)?, kind)) + } +} + +impl<'js> Scope<'_, 'js> { + fn load(&self) -> Result<()> { + if self.state.loaded.replace(true) { + return Ok(()); + } + let proto: Object<'js> = self.natives.native.get("prototype")?; + for (name, length, op) in METHODS { + let key = rquickjs::Atom::from_str(self.ctx.clone(), name)?; + if proto.contains_key(key.clone())? { + let function = create(self.ctx, self.natives, self.state, op, name, length)?; + proto.set(key, function)?; + } + } + Ok(()) + } + + fn construct( + &self, + target: Value<'js>, + function: Value<'js>, + params: &Params<'_, 'js>, + ) -> Result> { + self.load()?; + let native = &self.natives.native; + if target.is_undefined() { + let date: Object<'js> = native.construct((self.state.slot.now(),))?; + return self.invoke(date.get("toString")?, date.into_value()); + } + let t = match (params.len(), params.arg(0)) { + (1, Some(first)) => match first.as_number() { + Some(t) => t, + None => self.value_of(first)?, + }, + (0, _) | (_, None) => self.state.slot.now(), + _ => self.time_of((0..params.len()).filter_map(|i| params.arg(i)).collect())?, + }; + if target == function { + return native.construct((t,)); + } + let reflect: Object<'js> = self.ctx.globals().get("Reflect")?; + let construct: Function<'js> = reflect.get("construct")?; + construct.call((native.clone(), vec![t], target)) + } +} + +pub(super) fn install<'js>(ctx: &Ctx<'js>, slot: &JsSlot) -> Result<()> { + let globals = ctx.globals(); + let native: Constructor<'js> = globals.get("Date")?; + let proto: Object<'js> = native.get("prototype")?; + let natives = Natives { + get_time: proto.get("getTime")?, + set_time: proto.get("setTime")?, + machine_offset: proto.get("getTimezoneOffset")?, + parse: native.get("parse")?, + native: native.clone(), + }; + let state = Rc::new(State { + slot: slot.clone(), + loaded: Cell::new(false), + zone: Cell::new(None), + last: Cell::new(None), + }); + let constructor = + create(ctx, &natives, &state, Op::Construct, "Date", 7)?.with_constructor(true); + constructor.prop("prototype", Property::from(proto.clone()))?; + let bind: Function<'js> = constructor.get("bind")?; + let pinned: Function<'js> = + bind.call((This(constructor), Value::new_undefined(ctx.clone())))?; + let now = create(ctx, &natives, &state, Op::Now, "now", 0)?; + let parse = create(ctx, &natives, &state, Op::Parse, "parse", 1)?; + let random = create(ctx, &natives, &state, Op::Random, "random", 0)?; + let utc: Value<'js> = native.get("UTC")?; + pinned.prop("length", Property::from(7).configurable())?; + pinned.prop("name", Property::from("Date").configurable())?; + pinned.prop("prototype", Property::from(proto.clone()))?; + pinned.prop("now", Property::from(now).writable().configurable())?; + pinned.prop("parse", Property::from(parse).writable().configurable())?; + pinned.prop("UTC", Property::from(utc).writable().configurable())?; + proto.set("constructor", pinned.clone())?; + globals.set("Date", pinned)?; + let math: Object<'js> = globals.get("Math")?; + math.set("random", random) +} diff --git a/core/engine/tests/function_parity.rs b/core/engine/tests/function_parity.rs index 98b4f68e..63fe2c29 100644 --- a/core/engine/tests/function_parity.rs +++ b/core/engine/tests/function_parity.rs @@ -68,6 +68,21 @@ const SNIPPETS: &[&str] = &[ "typeof Math.random()", "Math.random() >= 0 && Math.random() < 1", "typeof Date.now()", + "[typeof Date.call(Date), typeof Date.call(Array, 2020, 1), typeof Reflect.apply(Date, Array, [])]", + "Object.getPrototypeOf(Date) === Function.prototype", + "(() => { new Date(0); return [Object.getPrototypeOf(Date.prototype.getHours) === Function.prototype, Object.getPrototypeOf(Date.now) === Function.prototype, Object.getPrototypeOf(Math.random) === Function.prototype, Date.prototype.getHours instanceof Function]; })()", + "[Date.prototype.constructor === Date, globalThis.Date === Date, Date.prototype instanceof Date]", + "(() => { const d = Object.getOwnPropertyDescriptor(Date, 'length'); const n = Object.getOwnPropertyDescriptor(Date, 'name'); return [d.value, d.writable, d.enumerable, d.configurable, n.value, n.writable, n.enumerable, n.configurable]; })()", + "(() => { class A extends Date { constructor() { super(2020, 1, 3); } } const a = new A(); return [a instanceof A, a instanceof Date, a.getMonth(), a.getDate(), Object.getPrototypeOf(a) === A.prototype]; })()", + "(() => { const B = Date.bind(null, 2020, 1); const b = new B(); return [b instanceof Date, b.getMonth(), typeof B()]; })()", + "Reflect.construct(Date, [2020, 1, 3], Object).constructor === Object", + "[new Date(new Date(5)).getTime(), new Date(2020, 1, 3).getDate(), new Date(0).setTime(7)]", + "[Function.prototype.toString.call(Date.now), String(Date.prototype.getHours), String(Date.prototype.setFullYear), Date.prototype.toLocaleString.length]", + "(() => { try { Date.prototype.getHours.call(Object.create(Date.prototype)); return 'ok'; } catch (e) { return [e.constructor.name, e.message]; } })()", + "(() => { try { Date.prototype.setHours.call(1, 2); return 'ok'; } catch (e) { return [e.constructor.name, e.message]; } })()", + "(() => { try { new Date(Symbol()); return 'ok'; } catch (e) { return e.constructor.name; } })()", + "(() => { const seen = []; new Date(0).setHours({ valueOf() { seen.push('h'); return 1; } }, { valueOf() { seen.push('m'); return 2; } }); return seen; })()", + "new Date(2020, 0, 1, 12).getDay() + new Date(2020, 0, 1, 12).getYear()", ]; #[derive(Clone, Copy, Debug)] From 7a08770afb3eaa90e99bb421ef281a27ce4934f0 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 23 Nov 2026 17:09:03 +0100 Subject: [PATCH 32/32] fix(engine): keep the machine time zone out of parsed script dates --- core/engine/src/compiled/pinning/calendar.rs | 8 +++--- core/engine/src/compiled/pinning/date.rs | 27 +++++++++++++++++--- core/engine/tests/fixtures/pinned_dates.json | 12 ++++----- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/core/engine/src/compiled/pinning/calendar.rs b/core/engine/src/compiled/pinning/calendar.rs index 8efa0d3c..8627688c 100644 --- a/core/engine/src/compiled/pinning/calendar.rs +++ b/core/engine/src/compiled/pinning/calendar.rs @@ -373,8 +373,7 @@ fn digits(s: &str) -> usize { } pub(super) fn iso_date(text: &str) -> bool { - let body = text.trim_matches(is_space); - let body = body.strip_prefix(['+', '-']).unwrap_or(body); + let body = text.strip_prefix(['+', '-']).unwrap_or(text); let year = digits(body); if !(4..=6).contains(&year) { return false; @@ -519,9 +518,10 @@ mod tests { #[test] fn zone_patterns_follow_the_script_expressions() { - assert!(iso_date(" 2026-01-15 ")); + assert!(iso_date("2026-01-15")); + assert!(!iso_date(" 2026-01-15 ")); assert!(iso_date("+002026-01")); - assert!(iso_date("\u{a0}2026\u{feff}")); + assert!(!iso_date("\u{a0}2026\u{feff}")); assert!(!iso_date("2026-01-15T10:00")); assert!(!iso_date("1234567")); assert!(!iso_date("2026-1")); diff --git a/core/engine/src/compiled/pinning/date.rs b/core/engine/src/compiled/pinning/date.rs index 04a2372f..97f83a65 100644 --- a/core/engine/src/compiled/pinning/date.rs +++ b/core/engine/src/compiled/pinning/date.rs @@ -288,9 +288,30 @@ impl<'js> Scope<'_, 'js> { if t.is_nan() || !reinterpret { return Ok(t); } - let date: Value<'js> = self.natives.native.construct((t,))?; - let machine: f64 = self.natives.machine_offset.call((This(date),))?; - let local = decompose(t as i64 + (-machine as i64) * 60000); + let machine = |at: f64| -> Result { + let date: Value<'js> = self.natives.native.construct((at,))?; + self.natives.machine_offset.call((This(date),)) + }; + let here = machine(t)?; + let span = 36.0 * 3_600_000.0; + let steady = machine(t - span)? == here && machine(t + span)? == here; + let mut local = decompose(t as i64 + (-here as i64) * 60000); + if !steady { + if let Ok(text) = source.to_string() { + let digit = text.ends_with(|c: char| c.is_ascii_digit()); + let spelled = [(digit, format!("{text}Z")), (true, format!("{text} UTC"))]; + for (_, candidate) in spelled.iter().filter(|(usable, _)| *usable) { + let universal: f64 = self.natives.parse.call(( + This(self.natives.native.clone()), + rquickjs::String::from_str(self.ctx.clone(), candidate)?, + ))?; + if !universal.is_nan() { + local = decompose(universal as i64); + break; + } + } + } + } Ok(from_local( [ local[0], local[1], local[2], local[4], local[5], local[6], local[7], diff --git a/core/engine/tests/fixtures/pinned_dates.json b/core/engine/tests/fixtures/pinned_dates.json index 54e4de64..d931d52a 100644 --- a/core/engine/tests/fixtures/pinned_dates.json +++ b/core/engine/tests/fixtures/pinned_dates.json @@ -212,7 +212,7 @@ ], "made": ["1774760400000 Sun Mar 29 2026 02:30:00 GMT-0230","1774758599999 Sun Mar 29 2026 01:59:59 GMT-0230","1774762200000 Sun Mar 29 2026 03:00:00 GMT-0230","1792904400000 Sun Oct 25 2026 02:30:00 GMT-0230","1792900800000 Sun Oct 25 2026 01:30:00 GMT-0230","1792906200000 Sun Oct 25 2026 03:00:00 GMT-0230","1772949600000 Sun Mar 08 2026 03:30:00 GMT-0230","1793505600000 Sun Nov 01 2026 01:30:00 GMT-0230","1793502000000 Sun Nov 01 2026 00:30:00 GMT-0230","1775362500000 Sun Apr 05 2026 01:45:00 GMT-0230","1775364300000 Sun Apr 05 2026 02:15:00 GMT-0230","1791089100000 Sun Oct 04 2026 02:15:00 GMT-0230","788887800000 Sat Dec 31 1994 12:00:00 GMT-0330","788844540000 Fri Dec 30 1994 23:59:00 GMT-0330","788931000000 Sun Jan 01 1995 00:00:00 GMT-0330","504934800000 Wed Jan 01 1986 00:10:00 GMT-0330","504934140000 Tue Dec 31 1985 23:59:00 GMT-0330","915161400000 Fri Jan 01 1999 00:00:00 GMT-0330","-2208976148000 Mon Jan 01 1900 00:00:00 GMT-0331","-62198742548000 Fri Jan 01 -0001 00:00:00 GMT-0331","-59011446548000 Fri Jan 01 0100 00:00:00 GMT-0331","915161400000 Fri Jan 01 1999 00:00:00 GMT-0330","-2208976148000 Mon Jan 01 1900 00:00:00 GMT-0331","NaN Invalid Date","NaN Invalid Date","-8639999987348000 Tue Apr 20 -271821 00:00:00 GMT-0331","NaN Invalid Date","4118092200000 Thu Jul 01 2100 00:00:00 GMT-0230","4109893200000 Sun Mar 28 2100 02:30:00 GMT-0230","8862152400000 Thu Oct 31 2250 02:30:00 GMT-0230","13569478140000 Fri Dec 31 2399 23:59:00 GMT-0330","1767238200000 Thu Jan 01 2026 00:00:00 GMT-0330","1767238200000 Thu Jan 01 2026 00:00:00 GMT-0330","NaN Invalid Date","NaN Invalid Date","1767238200000 Thu Jan 01 2026 00:00:00 GMT-0330","1769916600000 Sun Feb 01 2026 00:00:00 GMT-0330","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2208976148000 Mon Jan 01 1900 00:00:00 GMT-0331","NaN Invalid Date","-2177440148000 Tue Jan 01 1901 00:00:00 GMT-0331","1769916600000 Sun Feb 01 2026 00:00:00 GMT-0330","1767583800000 Mon Jan 05 2026 00:00:00 GMT-0330"], "order": ["NaN","NaN","-1737997",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], - "parsed": [["1768483800000","1768483800000"],["1768483800000","1768483800000"],["1768483800000","1768483800000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792904400000","1792904400000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768483800000","1768483800000"],["1768447800000","1768447800000"],["1768534140000","1768534140000"],["1768483800000","1768483800000"],["1768447800000","1768447800000"],["1768494600000","1768494600000"],["1768471200000","1768471200000"],["1768483800000","1768483800000"],["4118135400000","4118135400000"],["4118135400000","4118135400000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768534200000","1768534200000"],["1768483800500","1768483800500"],["1768483800123","1768483800123"],["1768483800000","1768483800000"],["NaN","NaN"],["NaN","NaN"],["788887800000","788887800000"],["504934800000","504934800000"],["1775364300000","1775364300000"],["1791089100000","1791089100000"],["1793505600000","1793505600000"]], + "parsed": [["1768483800000","1768483800000"],["1768483800000","1768483800000"],["1768483800000","1768483800000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792904400000","1792904400000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768483800000","1768483800000"],["1768447800000","1768447800000"],["1768534140000","1768534140000"],["1768483800000","1768483800000"],["1768447800000","1768447800000"],["1768494600000","1768494600000"],["1768471200000","1768471200000"],["1768483800000","1768483800000"],["4118135400000","4118135400000"],["4118135400000","4118135400000"],["1768447800000","1768447800000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768534200000","1768534200000"],["1768483800500","1768483800500"],["1768483800123","1768483800123"],["1768483800000","1768483800000"],["NaN","NaN"],["NaN","NaN"],["788887800000","788887800000"],["504934800000","504934800000"],["1775364300000","1775364300000"],["1791089100000","1791089100000"],["1793505600000","1793505600000"]], "single": ["1704067200000","988684200000","NaN","NaN","86400000","1709263800000","1709299800000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007177400000","1768483800000","1774745100250","NaN","Sat Mar 28 2026 22:15:00 GMT-0230","Sat Mar 28 2026 22:15:00 GMT-0230","string","true 1774760400000 2 Sun Mar 29 2026 02:30:00 GMT-0230","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767238200000","1780281000000","NaN","01/01/1970, 09:00:00 AM","12/31/1969, 08:30:00 PM","12/31/1969, 08:30:00 PM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","12/31/1969, 08:30:00 PM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] }, "Asia/Kathmandu": { @@ -428,7 +428,7 @@ ], "made": ["1774730700000 Sun Mar 29 2026 02:30:00 GMT+0545","1774728899999 Sun Mar 29 2026 01:59:59 GMT+0545","1774732500000 Sun Mar 29 2026 03:00:00 GMT+0545","1792874700000 Sun Oct 25 2026 02:30:00 GMT+0545","1792871100000 Sun Oct 25 2026 01:30:00 GMT+0545","1792876500000 Sun Oct 25 2026 03:00:00 GMT+0545","1772916300000 Sun Mar 08 2026 02:30:00 GMT+0545","1793475900000 Sun Nov 01 2026 01:30:00 GMT+0545","1793472300000 Sun Nov 01 2026 00:30:00 GMT+0545","1775332800000 Sun Apr 05 2026 01:45:00 GMT+0545","1775334600000 Sun Apr 05 2026 02:15:00 GMT+0545","1791059400000 Sun Oct 04 2026 02:15:00 GMT+0545","788854500000 Sat Dec 31 1994 12:00:00 GMT+0545","788811240000 Fri Dec 30 1994 23:59:00 GMT+0545","788897700000 Sun Jan 01 1995 00:00:00 GMT+0545","504902400000 Wed Jan 01 1986 00:25:00 GMT+0545","504901740000 Tue Dec 31 1985 23:59:00 GMT+0530","915128100000 Fri Jan 01 1999 00:00:00 GMT+0545","-2209009276000 Mon Jan 01 1900 00:00:00 GMT+0541","-62198775676000 Fri Jan 01 -0001 00:00:00 GMT+0541","-59011479676000 Fri Jan 01 0100 00:00:00 GMT+0541","915128100000 Fri Jan 01 1999 00:00:00 GMT+0545","-2209009276000 Mon Jan 01 1900 00:00:00 GMT+0541","8639999979300000 Sat Sep 13 275760 00:00:00 GMT+0545","8639999975700000 Fri Sep 12 275760 23:00:00 GMT+0545","NaN Invalid Date","NaN Invalid Date","4118062500000 Thu Jul 01 2100 00:00:00 GMT+0545","4109863500000 Sun Mar 28 2100 02:30:00 GMT+0545","8862122700000 Thu Oct 31 2250 02:30:00 GMT+0545","13569444840000 Fri Dec 31 2399 23:59:00 GMT+0545","1767204900000 Thu Jan 01 2026 00:00:00 GMT+0545","1767204900000 Thu Jan 01 2026 00:00:00 GMT+0545","NaN Invalid Date","NaN Invalid Date","1767204900000 Thu Jan 01 2026 00:00:00 GMT+0545","1769883300000 Sun Feb 01 2026 00:00:00 GMT+0545","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2209009276000 Mon Jan 01 1900 00:00:00 GMT+0541","NaN Invalid Date","-2177473276000 Tue Jan 01 1901 00:00:00 GMT+0541","1769883300000 Sun Feb 01 2026 00:00:00 GMT+0545","1767550500000 Mon Jan 05 2026 00:00:00 GMT+0545"], "order": ["NaN","NaN","-1737997",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], - "parsed": [["1768450500000","1768450500000"],["1768450500000","1768450500000"],["1768450500000","1768450500000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792874700000","1792874700000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768450500000","1768450500000"],["1768414500000","1768414500000"],["1768500840000","1768500840000"],["1768450500000","1768450500000"],["1768414500000","1768414500000"],["1768461300000","1768461300000"],["1768471200000","1768471200000"],["1768450500000","1768450500000"],["4118105700000","4118105700000"],["4118105700000","4118105700000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768500900000","1768500900000"],["1768450500500","1768450500500"],["1768450500123","1768450500123"],["1768450500000","1768450500000"],["NaN","NaN"],["NaN","NaN"],["788854500000","788854500000"],["504902400000","504902400000"],["1775334600000","1775334600000"],["1791059400000","1791059400000"],["1793475900000","1793475900000"]], + "parsed": [["1768450500000","1768450500000"],["1768450500000","1768450500000"],["1768450500000","1768450500000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792874700000","1792874700000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768450500000","1768450500000"],["1768414500000","1768414500000"],["1768500840000","1768500840000"],["1768450500000","1768450500000"],["1768414500000","1768414500000"],["1768461300000","1768461300000"],["1768471200000","1768471200000"],["1768450500000","1768450500000"],["4118105700000","4118105700000"],["4118105700000","4118105700000"],["1768414500000","1768414500000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768500900000","1768500900000"],["1768450500500","1768450500500"],["1768450500123","1768450500123"],["1768450500000","1768450500000"],["NaN","NaN"],["NaN","NaN"],["788854500000","788854500000"],["504902400000","504902400000"],["1775334600000","1775334600000"],["1791059400000","1791059400000"],["1793475900000","1793475900000"]], "single": ["1704067200000","988654500000","NaN","NaN","86400000","1709230500000","1709266500000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007144100000","1768450500000","1774745100250","NaN","Sun Mar 29 2026 06:30:00 GMT+0545","Sun Mar 29 2026 06:30:00 GMT+0545","string","true 1774730700000 2 Sun Mar 29 2026 02:30:00 GMT+0545","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767204900000","1780251300000","NaN","01/01/1970, 09:00:00 AM","01/01/1970, 05:30:00 AM","01/01/1970, 05:30:00 AM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","01/01/1970, 05:30:00 AM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] }, "Australia/Lord_Howe": { @@ -644,7 +644,7 @@ ], "made": ["1774711800000 Sun Mar 29 2026 02:30:00 GMT+1100","1774709999999 Sun Mar 29 2026 01:59:59 GMT+1100","1774713600000 Sun Mar 29 2026 03:00:00 GMT+1100","1792855800000 Sun Oct 25 2026 02:30:00 GMT+1100","1792852200000 Sun Oct 25 2026 01:30:00 GMT+1100","1792857600000 Sun Oct 25 2026 03:00:00 GMT+1100","1772897400000 Sun Mar 08 2026 02:30:00 GMT+1100","1793457000000 Sun Nov 01 2026 01:30:00 GMT+1100","1793453400000 Sun Nov 01 2026 00:30:00 GMT+1100","1775313900000 Sun Apr 05 2026 01:45:00 GMT+1100","1775317500000 Sun Apr 05 2026 02:15:00 GMT+1030","1791042300000 Sun Oct 04 2026 02:45:00 GMT+1100","788835600000 Sat Dec 31 1994 12:00:00 GMT+1100","788792340000 Fri Dec 30 1994 23:59:00 GMT+1100","788878800000 Sun Jan 01 1995 00:00:00 GMT+1100","504882600000 Wed Jan 01 1986 00:10:00 GMT+1100","504881940000 Tue Dec 31 1985 23:59:00 GMT+1100","915109200000 Fri Jan 01 1999 00:00:00 GMT+1100","-2209024800000 Mon Jan 01 1900 00:00:00 GMT+1000","-62198793380000 Fri Jan 01 -0001 00:00:00 GMT+1036","-59011497380000 Fri Jan 01 0100 00:00:00 GMT+1036","915109200000 Fri Jan 01 1999 00:00:00 GMT+1100","-2209024800000 Mon Jan 01 1900 00:00:00 GMT+1000","8639999962200000 Sat Sep 13 275760 00:00:00 GMT+1030","8639999958600000 Fri Sep 12 275760 23:00:00 GMT+1030","NaN Invalid Date","NaN Invalid Date","4118045400000 Thu Jul 01 2100 00:00:00 GMT+1030","4109844600000 Sun Mar 28 2100 02:30:00 GMT+1100","8862103800000 Thu Oct 31 2250 02:30:00 GMT+1100","13569425940000 Fri Dec 31 2399 23:59:00 GMT+1100","1767186000000 Thu Jan 01 2026 00:00:00 GMT+1100","1767186000000 Thu Jan 01 2026 00:00:00 GMT+1100","NaN Invalid Date","NaN Invalid Date","1767186000000 Thu Jan 01 2026 00:00:00 GMT+1100","1769864400000 Sun Feb 01 2026 00:00:00 GMT+1100","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2209024800000 Mon Jan 01 1900 00:00:00 GMT+1000","NaN Invalid Date","-2177488800000 Tue Jan 01 1901 00:00:00 GMT+1000","1769864400000 Sun Feb 01 2026 00:00:00 GMT+1100","1767531600000 Mon Jan 05 2026 00:00:00 GMT+1100"], "order": ["NaN","NaN","62003",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], - "parsed": [["1768431600000","1768431600000"],["1768431600000","1768431600000"],["1768431600000","1768431600000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792855800000","1792855800000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768431600000","1768431600000"],["1768395600000","1768395600000"],["1768481940000","1768481940000"],["1768431600000","1768431600000"],["1768395600000","1768395600000"],["1768442400000","1768442400000"],["1768471200000","1768471200000"],["1768431600000","1768431600000"],["4118088600000","4118088600000"],["4118088600000","4118088600000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768482000000","1768482000000"],["1768431600500","1768431600500"],["1768431600123","1768431600123"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["788835600000","788835600000"],["504882600000","504882600000"],["1775317500000","1775317500000"],["1791042300000","1791042300000"],["1793457000000","1793457000000"]], + "parsed": [["1768431600000","1768431600000"],["1768431600000","1768431600000"],["1768431600000","1768431600000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792855800000","1792855800000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768431600000","1768431600000"],["1768395600000","1768395600000"],["1768481940000","1768481940000"],["1768431600000","1768431600000"],["1768395600000","1768395600000"],["1768442400000","1768442400000"],["1768471200000","1768471200000"],["1768431600000","1768431600000"],["4118088600000","4118088600000"],["4118088600000","4118088600000"],["1768395600000","1768395600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768482000000","1768482000000"],["1768431600500","1768431600500"],["1768431600123","1768431600123"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["788835600000","788835600000"],["504882600000","504882600000"],["1775317500000","1775317500000"],["1791042300000","1791042300000"],["1793457000000","1793457000000"]], "single": ["1704067200000","988637400000","NaN","NaN","86400000","1709211600000","1709247600000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007125200000","1768431600000","1774745100250","NaN","Sun Mar 29 2026 11:45:00 GMT+1100","Sun Mar 29 2026 11:45:00 GMT+1100","string","true 1774711800000 2 Sun Mar 29 2026 02:30:00 GMT+1100","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767186000000","1780234200000","NaN","01/01/1970, 09:00:00 AM","01/01/1970, 10:00:00 AM","01/01/1970, 10:00:00 AM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","01/01/1970, 10:00:00 AM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] }, "Etc/GMT+5": { @@ -860,7 +860,7 @@ ], "made": ["1774769400000 Sun Mar 29 2026 02:30:00 GMT-0500","1774767599999 Sun Mar 29 2026 01:59:59 GMT-0500","1774771200000 Sun Mar 29 2026 03:00:00 GMT-0500","1792913400000 Sun Oct 25 2026 02:30:00 GMT-0500","1792909800000 Sun Oct 25 2026 01:30:00 GMT-0500","1792915200000 Sun Oct 25 2026 03:00:00 GMT-0500","1772955000000 Sun Mar 08 2026 02:30:00 GMT-0500","1793514600000 Sun Nov 01 2026 01:30:00 GMT-0500","1793511000000 Sun Nov 01 2026 00:30:00 GMT-0500","1775371500000 Sun Apr 05 2026 01:45:00 GMT-0500","1775373300000 Sun Apr 05 2026 02:15:00 GMT-0500","1791098100000 Sun Oct 04 2026 02:15:00 GMT-0500","788893200000 Sat Dec 31 1994 12:00:00 GMT-0500","788849940000 Fri Dec 30 1994 23:59:00 GMT-0500","788936400000 Sun Jan 01 1995 00:00:00 GMT-0500","504940200000 Wed Jan 01 1986 00:10:00 GMT-0500","504939540000 Tue Dec 31 1985 23:59:00 GMT-0500","915166800000 Fri Jan 01 1999 00:00:00 GMT-0500","-2208970800000 Mon Jan 01 1900 00:00:00 GMT-0500","-62198737200000 Fri Jan 01 -0001 00:00:00 GMT-0500","-59011441200000 Fri Jan 01 0100 00:00:00 GMT-0500","915166800000 Fri Jan 01 1999 00:00:00 GMT-0500","-2208970800000 Mon Jan 01 1900 00:00:00 GMT-0500","NaN Invalid Date","NaN Invalid Date","-8639999982000000 Tue Apr 20 -271821 00:00:00 GMT-0500","NaN Invalid Date","4118101200000 Thu Jul 01 2100 00:00:00 GMT-0500","4109902200000 Sun Mar 28 2100 02:30:00 GMT-0500","8862161400000 Thu Oct 31 2250 02:30:00 GMT-0500","13569483540000 Fri Dec 31 2399 23:59:00 GMT-0500","1767243600000 Thu Jan 01 2026 00:00:00 GMT-0500","1767243600000 Thu Jan 01 2026 00:00:00 GMT-0500","NaN Invalid Date","NaN Invalid Date","1767243600000 Thu Jan 01 2026 00:00:00 GMT-0500","1769922000000 Sun Feb 01 2026 00:00:00 GMT-0500","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2208970800000 Mon Jan 01 1900 00:00:00 GMT-0500","NaN Invalid Date","-2177434800000 Tue Jan 01 1901 00:00:00 GMT-0500","1769922000000 Sun Feb 01 2026 00:00:00 GMT-0500","1767589200000 Mon Jan 05 2026 00:00:00 GMT-0500"], "order": ["NaN","NaN","62003",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], - "parsed": [["1768489200000","1768489200000"],["1768489200000","1768489200000"],["1768489200000","1768489200000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792913400000","1792913400000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768489200000","1768489200000"],["1768453200000","1768453200000"],["1768539540000","1768539540000"],["1768489200000","1768489200000"],["1768453200000","1768453200000"],["1768500000000","1768500000000"],["1768471200000","1768471200000"],["1768489200000","1768489200000"],["4118144400000","4118144400000"],["4118144400000","4118144400000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768539600000","1768539600000"],["1768489200500","1768489200500"],["1768489200123","1768489200123"],["1768489200000","1768489200000"],["NaN","NaN"],["NaN","NaN"],["788893200000","788893200000"],["504940200000","504940200000"],["1775373300000","1775373300000"],["1791098100000","1791098100000"],["1793514600000","1793514600000"]], + "parsed": [["1768489200000","1768489200000"],["1768489200000","1768489200000"],["1768489200000","1768489200000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792913400000","1792913400000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768489200000","1768489200000"],["1768453200000","1768453200000"],["1768539540000","1768539540000"],["1768489200000","1768489200000"],["1768453200000","1768453200000"],["1768500000000","1768500000000"],["1768471200000","1768471200000"],["1768489200000","1768489200000"],["4118144400000","4118144400000"],["4118144400000","4118144400000"],["1768453200000","1768453200000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768539600000","1768539600000"],["1768489200500","1768489200500"],["1768489200123","1768489200123"],["1768489200000","1768489200000"],["NaN","NaN"],["NaN","NaN"],["788893200000","788893200000"],["504940200000","504940200000"],["1775373300000","1775373300000"],["1791098100000","1791098100000"],["1793514600000","1793514600000"]], "single": ["1704067200000","988693200000","NaN","NaN","86400000","1709269200000","1709305200000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007182800000","1768489200000","1774745100250","NaN","Sat Mar 28 2026 19:45:00 GMT-0500","Sat Mar 28 2026 19:45:00 GMT-0500","string","true 1774769400000 2 Sun Mar 29 2026 02:30:00 GMT-0500","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767243600000","1780290000000","NaN","01/01/1970, 09:00:00 AM","12/31/1969, 07:00:00 PM","12/31/1969, 07:00:00 PM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","12/31/1969, 07:00:00 PM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] }, "Europe/Berlin": { @@ -1292,7 +1292,7 @@ ], "made": ["1774701000000 Sun Mar 29 2026 02:30:00 GMT+1400","1774699199999 Sun Mar 29 2026 01:59:59 GMT+1400","1774702800000 Sun Mar 29 2026 03:00:00 GMT+1400","1792845000000 Sun Oct 25 2026 02:30:00 GMT+1400","1792841400000 Sun Oct 25 2026 01:30:00 GMT+1400","1792846800000 Sun Oct 25 2026 03:00:00 GMT+1400","1772886600000 Sun Mar 08 2026 02:30:00 GMT+1400","1793446200000 Sun Nov 01 2026 01:30:00 GMT+1400","1793442600000 Sun Nov 01 2026 00:30:00 GMT+1400","1775303100000 Sun Apr 05 2026 01:45:00 GMT+1400","1775304900000 Sun Apr 05 2026 02:15:00 GMT+1400","1791029700000 Sun Oct 04 2026 02:15:00 GMT+1400","NaN Invalid Date","788867940000 Fri Dec 30 1994 23:59:00 GMT-1000","788868000000 Sun Jan 01 1995 00:00:00 GMT+1400","504958200000 Wed Jan 01 1986 00:10:00 GMT-1000","504957540000 Tue Dec 31 1985 23:59:00 GMT-1000","915098400000 Fri Jan 01 1999 00:00:00 GMT+1400","-2208951040000 Mon Jan 01 1900 00:00:00 GMT-1029","-62198717440000 Fri Jan 01 -0001 00:00:00 GMT-1029","-59011421440000 Fri Jan 01 0100 00:00:00 GMT-1029","915098400000 Fri Jan 01 1999 00:00:00 GMT+1400","-2208951040000 Mon Jan 01 1900 00:00:00 GMT-1029","8639999949600000 Sat Sep 13 275760 00:00:00 GMT+1400","8639999946000000 Fri Sep 12 275760 23:00:00 GMT+1400","-8639999962240000 Tue Apr 20 -271821 00:00:00 GMT-1029","NaN Invalid Date","4118032800000 Thu Jul 01 2100 00:00:00 GMT+1400","4109833800000 Sun Mar 28 2100 02:30:00 GMT+1400","8862093000000 Thu Oct 31 2250 02:30:00 GMT+1400","13569415140000 Fri Dec 31 2399 23:59:00 GMT+1400","1767175200000 Thu Jan 01 2026 00:00:00 GMT+1400","1767175200000 Thu Jan 01 2026 00:00:00 GMT+1400","NaN Invalid Date","NaN Invalid Date","1767175200000 Thu Jan 01 2026 00:00:00 GMT+1400","1769853600000 Sun Feb 01 2026 00:00:00 GMT+1400","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2208951040000 Mon Jan 01 1900 00:00:00 GMT-1029","NaN Invalid Date","-2177414400000 Tue Jan 01 1901 00:00:00 GMT-1040","1769853600000 Sun Feb 01 2026 00:00:00 GMT+1400","1767520800000 Mon Jan 05 2026 00:00:00 GMT+1400"], "order": ["NaN","NaN","-1137997",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], - "parsed": [["1768420800000","1768420800000"],["1768420800000","1768420800000"],["1768420800000","1768420800000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792845000000","1792845000000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768420800000","1768420800000"],["1768384800000","1768384800000"],["1768471140000","1768471140000"],["1768420800000","1768420800000"],["1768384800000","1768384800000"],["1768431600000","1768431600000"],["1768471200000","1768471200000"],["1768420800000","1768420800000"],["4118076000000","4118076000000"],["4118076000000","4118076000000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768471200000","1768471200000"],["1768420800500","1768420800500"],["1768420800123","1768420800123"],["1768420800000","1768420800000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["504958200000","504958200000"],["1775304900000","1775304900000"],["1791029700000","1791029700000"],["1793446200000","1793446200000"]], + "parsed": [["1768420800000","1768420800000"],["1768420800000","1768420800000"],["1768420800000","1768420800000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792845000000","1792845000000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768420800000","1768420800000"],["1768384800000","1768384800000"],["1768471140000","1768471140000"],["1768420800000","1768420800000"],["1768384800000","1768384800000"],["1768431600000","1768431600000"],["1768471200000","1768471200000"],["1768420800000","1768420800000"],["4118076000000","4118076000000"],["4118076000000","4118076000000"],["1768384800000","1768384800000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768471200000","1768471200000"],["1768420800500","1768420800500"],["1768420800123","1768420800123"],["1768420800000","1768420800000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["504958200000","504958200000"],["1775304900000","1775304900000"],["1791029700000","1791029700000"],["1793446200000","1793446200000"]], "single": ["1704067200000","988624800000","NaN","NaN","86400000","1709200800000","1709236800000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007114400000","1768420800000","1774745100250","NaN","Sun Mar 29 2026 14:45:00 GMT+1400","Sun Mar 29 2026 14:45:00 GMT+1400","string","true 1774701000000 2 Sun Mar 29 2026 02:30:00 GMT+1400","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767175200000","1780221600000","NaN","01/01/1970, 09:00:00 AM","12/31/1969, 01:20:00 PM","12/31/1969, 01:20:00 PM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","12/31/1969, 01:20:00 PM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] }, "UTC": { @@ -1508,7 +1508,7 @@ ], "made": ["1774751400000 Sun Mar 29 2026 02:30:00 GMT+0000","1774749599999 Sun Mar 29 2026 01:59:59 GMT+0000","1774753200000 Sun Mar 29 2026 03:00:00 GMT+0000","1792895400000 Sun Oct 25 2026 02:30:00 GMT+0000","1792891800000 Sun Oct 25 2026 01:30:00 GMT+0000","1792897200000 Sun Oct 25 2026 03:00:00 GMT+0000","1772937000000 Sun Mar 08 2026 02:30:00 GMT+0000","1793496600000 Sun Nov 01 2026 01:30:00 GMT+0000","1793493000000 Sun Nov 01 2026 00:30:00 GMT+0000","1775353500000 Sun Apr 05 2026 01:45:00 GMT+0000","1775355300000 Sun Apr 05 2026 02:15:00 GMT+0000","1791080100000 Sun Oct 04 2026 02:15:00 GMT+0000","788875200000 Sat Dec 31 1994 12:00:00 GMT+0000","788831940000 Fri Dec 30 1994 23:59:00 GMT+0000","788918400000 Sun Jan 01 1995 00:00:00 GMT+0000","504922200000 Wed Jan 01 1986 00:10:00 GMT+0000","504921540000 Tue Dec 31 1985 23:59:00 GMT+0000","915148800000 Fri Jan 01 1999 00:00:00 GMT+0000","-2208988800000 Mon Jan 01 1900 00:00:00 GMT+0000","-62198755200000 Fri Jan 01 -0001 00:00:00 GMT+0000","-59011459200000 Fri Jan 01 0100 00:00:00 GMT+0000","915148800000 Fri Jan 01 1999 00:00:00 GMT+0000","-2208988800000 Mon Jan 01 1900 00:00:00 GMT+0000","8640000000000000 Sat Sep 13 275760 00:00:00 GMT+0000","8639999996400000 Fri Sep 12 275760 23:00:00 GMT+0000","-8640000000000000 Tue Apr 20 -271821 00:00:00 GMT+0000","NaN Invalid Date","4118083200000 Thu Jul 01 2100 00:00:00 GMT+0000","4109884200000 Sun Mar 28 2100 02:30:00 GMT+0000","8862143400000 Thu Oct 31 2250 02:30:00 GMT+0000","13569465540000 Fri Dec 31 2399 23:59:00 GMT+0000","1767225600000 Thu Jan 01 2026 00:00:00 GMT+0000","1767225600000 Thu Jan 01 2026 00:00:00 GMT+0000","NaN Invalid Date","NaN Invalid Date","1767225600000 Thu Jan 01 2026 00:00:00 GMT+0000","1769904000000 Sun Feb 01 2026 00:00:00 GMT+0000","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","NaN Invalid Date","-2208988800000 Mon Jan 01 1900 00:00:00 GMT+0000","NaN Invalid Date","-2177452800000 Tue Jan 01 1901 00:00:00 GMT+0000","1769904000000 Sun Feb 01 2026 00:00:00 GMT+0000","1767571200000 Mon Jan 05 2026 00:00:00 GMT+0000"], "order": ["NaN","NaN","62003",["y","m","d","h","mi","s","ms","mi2","s2","ms2"]], - "parsed": [["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792895400000","1792895400000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768435200000","1768435200000"],["1768521540000","1768521540000"],["1768471200000","1768471200000"],["1768435200000","1768435200000"],["1768482000000","1768482000000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["4118126400000","4118126400000"],["4118126400000","4118126400000"],["1768431600000","1768431600000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768521600000","1768521600000"],["1768471200500","1768471200500"],["1768471200123","1768471200123"],["1768471200000","1768471200000"],["NaN","NaN"],["NaN","NaN"],["788875200000","788875200000"],["504922200000","504922200000"],["1775355300000","1775355300000"],["1791080100000","1791080100000"],["1793496600000","1793496600000"]], + "parsed": [["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768435200000","1768435200000"],["1767225600000","1767225600000"],["1767225600000","1767225600000"],["1768435200000","1768435200000"],["-62184499200000","-62184499200000"],["1768471200000","1768471200000"],["NaN","NaN"],["1768450500000","1768450500000"],["1768483800000","1768483800000"],["1792895400000","1792895400000"],["1768467600000","1768467600000"],["1768467600000","1768467600000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["1768435200000","1768435200000"],["1768521540000","1768521540000"],["1768471200000","1768471200000"],["1768435200000","1768435200000"],["1768482000000","1768482000000"],["1768471200000","1768471200000"],["1768471200000","1768471200000"],["4118126400000","4118126400000"],["4118126400000","4118126400000"],["1768435200000","1768435200000"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["NaN","NaN"],["1772409600000","1772409600000"],["1768521600000","1768521600000"],["1768471200500","1768471200500"],["1768471200123","1768471200123"],["1768471200000","1768471200000"],["NaN","NaN"],["NaN","NaN"],["788875200000","788875200000"],["504922200000","504922200000"],["1775355300000","1775355300000"],["1791080100000","1791080100000"],["1793496600000","1793496600000"]], "single": ["1704067200000","988675200000","NaN","NaN","86400000","1709251200000","1709287200000","throws TypeError: Cannot convert object to primitive value","throws TypeError: Cannot convert object to primitive value","7","throws TypeError: Cannot convert object to primitive value","0","NaN","1","NaN","1234","throws TypeError: bigint argument with unary +","throws TypeError: cannot convert symbol to number","1","-1","NaN","0","NaN","NaN","1007164800000","1768471200000","1774745100250","NaN","Sun Mar 29 2026 00:45:00 GMT+0000","Sun Mar 29 2026 00:45:00 GMT+0000","string","true 1774751400000 2 Sun Mar 29 2026 02:30:00 GMT+0000","throws TypeError: not a function","[object Date]","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","throws TypeError: not a Date object","NaN","Invalid Date","Invalid Date","Invalid Date","NaN","1767225600000","1780272000000","NaN","01/01/1970, 09:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 12:00:00 AM","throws Error: zone getter","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","01/01/1970, 12:00:00 AM","01/01/1970, 02:00:00 PM","01/01/1970, 12:00:00 AM","01/01/1970, 01:00:00 AM","1774745100250","7","Date","1767225600000","-1858"] } }