Skip to content

[alt] Suppress CHASM metric emission while re-applying transitions (node method)#10846

Closed
tekkaya wants to merge 1 commit into
mainfrom
gokhan/chasm-suppress-metrics-on-cherrypick-node-alt
Closed

[alt] Suppress CHASM metric emission while re-applying transitions (node method)#10846
tekkaya wants to merge 1 commit into
mainfrom
gokhan/chasm-suppress-metrics-on-cherrypick-node-alt

Conversation

@tekkaya

@tekkaya tekkaya commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What changed?

Alternative to #10845 (per review feedback: "have a method on the node to express Replaying"). Same goal — suppress CHASM caller-side metric emission during cherry-pick re-apply — but the replaying state lives on the node/tree instead of on a per-context flag.

  • nodeBase.replaying bool + Node.SetReplaying(bool) / Node.Replaying() bool.
  • Context.MetricsHandler() returns metrics.NoopMetricsHandler while the tree is in replay mode.

Why this shape

Because every context reads its handler from the root node, the reset/conflict-resolution re-apply path just flips the tree into replay mode around the cherry-pick — no special context constructor, no flag propagation through context derivation (withValue), and no way to accidentally create a live context during re-apply. "Replaying" is genuinely tree-wide state (the whole execution is being rebuilt), and the metrics handler already lives on the node, so this keeps it in one place.

Trade-off vs #10845: this introduces transient mutable state on the tree that must be paired (set true → restore false), whereas the context-flag version is immutable/explicit. CHASM execution is single-threaded under the workflow lock, so the mutation is safe; a scoped helper can be added if preferred.

Scope / not-yet-wired

Guardrail only — the CHASM cherry-pick dispatch isn't wired yet, so there's no production caller today. When it lands, it wraps the cherry-pick in node.SetReplaying(true) (restored after), and a functional reset/double-count test should land with that wiring.

How did you test it?

  • built
  • added new unit test(s)

chasm: SetReplaying(true) makes the same context's MetricsHandler() a no-op; restored after SetReplaying(false).
chasm/lib/nexusoperation: a real TransitionSucceeded.Apply with the tree in replay mode emits nothing; live mode emits nexus_operation_success (exercises the real emitOnSucceededMetrics path; existing transition tests use a mock context that bypasses the guard).

…thod)

Alternative to the context-flag approach (#10845): express "replaying" as
tree state on the node rather than on a per-context flag.

Add a replaying bool to nodeBase plus Node.SetReplaying / Node.Replaying. While
the tree is in replay mode, Context.MetricsHandler() returns
metrics.NoopMetricsHandler, so side-effect metrics emitted inside any
component's transition are not double-counted when the reset / conflict-
resolution re-apply (cherry-pick) path re-runs them.

Because every context reads its handler from the root node, the reset re-apply
path just flips the tree into replay mode around the cherry-pick (no special
context constructor, no flag propagation through context derivation, and no way
to accidentally create a live context during re-apply).

Guardrail only: the CHASM cherry-pick dispatch is not wired yet, so there is no
production caller today; a functional reset/double-count test should land with
that wiring.

Tests:
- chasm: SetReplaying(true) -> MetricsHandler is no-op on the same context;
  restored after SetReplaying(false).
- chasm/lib/nexusoperation: a real TransitionSucceeded under a tree in replay
  mode emits nothing, while live mode emits the success counter.
@tekkaya tekkaya closed this Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant