Skip to content

SAO-17698: Address review comments - #271

Open
adityamehra wants to merge 2 commits into
agent-simulation-pocfrom
feat/sim-run-id-follow-up
Open

adityamehra wants to merge 2 commits into
agent-simulation-pocfrom
feat/sim-run-id-follow-up

Conversation

@adityamehra

@adityamehra adityamehra commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Jira: SAO-18670

  • Run IDs are now trimmed by validate_simulation_run_id(), keeping caller and downstream span grouping consistent. Added coverage for whitespace in both public context APIs.
  • Moved SPLUNK_AO_SIMULATION_RUN_ID into the dependency-light simulation_run_context.py module and updated the source imports to remove the converter import cycle.

@fercor-cisco fercor-cisco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving SPLUNK_AO_SIMULATION_RUN_ID into simulation_run_context.py makes sense. One blocking issue: the leftover re-export in attribute_mapping.py fails Ruff F401, and the pre-commit hook deletes it automatically, which breaks five test modules. There is also a small test gap on the converter path. Details are inline.

from galileo_core.schemas.logging.span import AgentSpan, LlmSpan, RetrieverSpan, ToolSpan, WorkflowSpan
from galileo_core.schemas.logging.step import BaseStep, StepType
from splunk_ao.logger.control import ControlSpan
from splunk_ao.simulation_run_context import SPLUNK_AO_SIMULATION_RUN_ID

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing in this module uses this import any more. It only keeps the old splunk_ao.converter.attribute_mapping import path working. Ruff 0.15.22, the version pinned in pre-commit, flags it:

$ ruff check --no-fix src/splunk_ao/converter/attribute_mapping.py
F401 [*] `splunk_ao.simulation_run_context.SPLUNK_AO_SIMULATION_RUN_ID` imported but unused
  --> src/splunk_ao/converter/attribute_mapping.py:16:46

Ruff marks it auto-fixable, and the ruff hook in .pre-commit-config.yaml runs with --fix. The next commit that touches this file deletes the line silently. Five test modules still import the constant from here and would then fail at collection with ImportError:

  • tests/test_tracing.py:9
  • tests/test_span_converter.py:16
  • tests/test_otel_native_paths.py:17
  • tests/test_logger_otel_egress.py:10
  • tests/test_http_instrumentation.py:35

Suggested fix: point those five imports at splunk_ao.simulation_run_context and delete this line. The old path only exists on agent-simulation-poc and was never released, so there are no outside callers to keep working. If you would rather keep the alias, make the re-export explicit so Ruff accepts it:

Suggested change
from splunk_ao.simulation_run_context import SPLUNK_AO_SIMULATION_RUN_ID
from splunk_ao.simulation_run_context import SPLUNK_AO_SIMULATION_RUN_ID as SPLUNK_AO_SIMULATION_RUN_ID

Comment on lines +87 to +94
def test_simulation_run_id_is_normalized_at_public_context_boundaries(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(splunk_ao_context, "get_logger_instance", Mock())

with splunk_ao_context.simulation_run(" run-1\n"):
assert _simulation_run_id_context.get() == "run-1"

with splunk_ao_context(simulation_run_id="\trun-2 "):
assert _simulation_run_id_context.get() == "run-2"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This covers trimming at the public context entry points, but only checks the context variable. SpanConverter.convert_span trims separately with validate_simulation_run_id (span_converter.py:96), and tests/test_span_converter.py only tests IDs that get rejected ("", " ", 123) and an already-clean "run-1". Could you add one converter case showing that simulation_run_id=" run-1 " is exported as splunk_ao.simulation.run_id == "run-1"? Without it, nothing tests the claim that trimming keeps span grouping consistent downstream.

This branch has not been deployed

No deployments
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.

2 participants