Changes for 0.6.0#193
Merged
Merged
Conversation
another set of solid changes based on production user feedback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements two upstream feedback items (WG-006 and WG-007) as Weavegraph 0.6.0.
WG-006 — Invocation-scoped state lifecycle + normalization profiles
Adds a
StateLifecycleannotation toStateKey<T>so callers can declare which slots are per-invocation scratch versus durable.NodePartial::clear_typed_extra_key/clear_extra_keysdelete those slots viaMapMerge's new JSON Merge Patch (RFC 7396) semantics.StateNormalizeProfilelets replay assertions ignore volatile keys without touching event comparison logic.WG-007 — Runtime observability hooks + metrics adapter
Adds a
RuntimeObservertrait with six lifecycle hook methods (invocation start/finish, node finish, checkpoint load/save, event bus emit). An observer is attached viaAppRunnerBuilder::observer(Arc<dyn RuntimeObserver>)with zero overhead when unset. Observer panics are caught and logged as warnings. AMetricsObserverimplementation is provided under themetricsfeature flag, emitting standard counters and histograms via themetricscrate facade.Also fixes
MapMergeto treat incomingnullas a key deletion (RFC 7396), which is a prerequisite for the clear methods to work correctly, and marks five public error enums#[non_exhaustive]to allow future variants without breaking changes.Related Issues
Closes #
Type of Change
Changes Made
src/state.rs—StateLifecycleenum;StateKey<T>gainslifecyclefield +invocation_scoped()const builder +lifecycle()getter; manualPartialEq/Hash/Eqimpls that exclude the lifecycle fieldsrc/node.rs—NodePartial::clear_extra_keysandclear_typed_extra_keymethodssrc/reducers/map_merge.rs—MapMergenow treats incomingnullas a key deletion (JSON Merge Patch / RFC 7396)src/runtimes/observer.rs(new) —RuntimeObservertrait, six metadata structs, two outcome enums (all#[non_exhaustive])src/runtimes/metrics_observer.rs(new,metricsfeature) —MetricsObserverwith 5 counters and 3 histogramssrc/runtimes/runner.rs—observerfield onAppRunner/AppRunnerBuilder;ObservingEmitterprivate struct;call_observer_hookwithcatch_unwind; hook callsites at invocation start/finish, node finish, checkpoint load/save, and event bus emitsrc/runtimes/replay.rs—StateNormalizeProfile,normalize_state_with,compare_final_state_with,compare_replay_runs_with_profilesrc/runtimes/mod.rs—pub mod observer,pub mod metrics_observer(feature-gated), re-exports for all new public typessrc/runtimes/checkpointer.rs—#[non_exhaustive]onCheckpointerErrorCargo.toml— version0.6.0;metrics = { version = "0.24", optional = true }dep;metrics = ["dep:metrics"]featureCHANGELOG.md/docs/MIGRATION.md— 0.6.0 section with full API inventory and migration guidanceTesting
cargo test)make lint(rustfmt + clippy--all-targets --all-features -D warnings) andmake test(cargo-nextest + doctests) both pass cleanly: 337 integration/unit tests, 161 doctests, 0 failures.The
metricsfeature was separately verified withcargo build --features metricsandcargo clippy --features metrics -- -D warnings.Test environment:
Checklist
cargo fmt)cargo clippy)Breaking Changes
MapMergenull-deletion (RFC 7396):MapMergepreviously storedserde_json::Value::Nullverbatim inVersionedState.extra. It now removes the key when the incoming value isnull. Any code that deliberately storedValue::Nullas a meaningful state value must switch to an explicit sentinel (e.g.{"absent": true}). This change is required forclear_extra_keys/clear_typed_extra_keyto function correctly.#[non_exhaustive]error enums:RunnerError,NodeError,CheckpointerError,StateSlotError, andReplayConformanceErrorare now#[non_exhaustive]. Exhaustivematchexpressions on these types must add a_wildcard arm. Seedocs/MIGRATION.mdfor the exact before/after pattern.Additional Notes
The
RuntimeObservertrait is always compiled (no feature gate) so downstream crates can implement it without opting into any feature. Themetricsfeature only gates the ready-madeMetricsObserverimpl and themetricscrate dependency.session_idand other high-cardinality fields are intentionally excluded from metric labels inMetricsObserverto avoid unbounded label cardinality in long-running services.