Graph-Native Infrastructure for Context and Accountable AI Systems
Python agent-memoryaiai-governanceai-infrastructureartificial-intelligencecontext-engineeringcontext-graphsdata-engineeringdecision-intelligencedeveloper-toolsexplainable-aigenerative-aigraph-ragknowledge-graphllmontologyprovenancepythonreasoningsemantic-search
fix(cli): render temporal history timestamps as ISO 8601 in table output (#1997)
Tamur Tariq6aae7f20fd15
diff --git a/semantica/cli.py b/semantica/cli.pyindex 62a97d75..e82bf8de 100644--- a/semantica/cli.py+++ b/semantica/cli.py@@ -3880,17 +3880,16 @@ def temporal_history(events = [event for event in events if _aware(event["timestamp"]) >= since_dt]+ # Serialize through the kg temporal helpers so timestamps are ISO 8601+ # in every output mode, consistent with `temporal distance`, instead of+ # the space-separated str() form json.dumps(default=str) produces.+ ready = temporal_structure_to_json_ready(+ events if isinstance(events, list) else []+ )if _is_json(cli_ctx, local_json) or fmt == "json":- # Serialize through the kg temporal helpers so timestamps are ISO- # 8601, consistent with `temporal distance --json`, instead of the- # space-separated str() form _jecho's default=str produces.- _jecho(- temporal_structure_to_json_ready(- events if isinstance(events, list) else []- )- )+ _jecho(ready)else:- _pprint(cli_ctx, events)+ _pprint(cli_ctx, ready)_run_with_error_handling(_action)diff --git a/tests/cli/test_cli_temporal.py b/tests/cli/test_cli_temporal.pyindex bc675d33..0e453dff 100644--- a/tests/cli/test_cli_temporal.py+++ b/tests/cli/test_cli_temporal.py@@ -7,6 +7,7 @@ drift fails loudly."""import json+import refrom click.testing import CliRunnerimport pytest@@ -101,6 +102,15 @@ class TestTemporalHistory:change_types = {event["change_type"] for event in events}assert "added" in change_types+ def test_history_default_output_uses_iso_timestamps(self, runner, fixture_graph):+ result = runner.invoke(+ cli_module.main, ["temporal", "history", "entity_alice"]+ )+ assert result.exit_code == 0+ # str(datetime) renders "2025-01-01 00:00:00+00:00"; ISO 8601 uses "T".+ assert re.search(r'"timestamp": "\d{4}-\d{2}-\d{2}T', result.output)+ assert not re.search(r'"timestamp": "\d{4}-\d{2}-\d{2} ', result.output)+def test_history_since_filter(self, runner, fixture_graph):result = runner.invoke(cli_module.main,