Repository navigation
fix(cli): remap temporal subcommands onto the v0.7.0 engine APIs - #1987
Conversation
All five 'semantica temporal' subcommands crashed on v0.7.0 because the CLI wrappers called methods and constructors that no longer exist on the engine classes (issue #1809): - snapshot -> TemporalGraphQuery.reconstruct_at_time() on the persisted memory-backend graph (loaded via _load_context_graph().to_kg_dict()). - query -> TemporalGraphQuery.query_at_time(); new optional --at flag (defaults to now). Help text notes the query string is reserved for future query parsing, matching the engine. - history -> TemporalReasoningEngine.timeline_of() over the graph's facts, with the --since filter applied to event timestamps. - distance -> implemented as the absolute delta between the two timestamps via normalize_timestamp(); JSON output carries distance_seconds/distance_days. The --history flag is dropped since no behavior exists behind it. - allen -> parse each start/end spec with normalize_interval() and call TemporalReasoningEngine().relation() (no config kwarg, which is what raised 'TemporalReasoningEngine() takes no arguments'). Two engine-side spots still assumed the legacy source/target keys while ContextGraph.to_kg_dict() (the documented adapter for these consumers) emits source_id/target_id, which silently dropped every relationship from reconstruct_at_time() and timeline_of(); both now accept either key, matching the fallback already used elsewhere in temporal_query. Each subcommand gets a CliRunner smoke test against a small fixture graph (13 tests). Verified: 5/5 subcommands crash on main and succeed with this change; the CLI suites (434 passed) and the temporal suites (233 passed) stay green. Signed-off-by: Charan Rathore <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoRestore temporal CLI commands using v0.7.0 engine APIs
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
Review follow-ups on the temporal remap, each reproduced before fixing: - temporal allen parsed intervals through normalize_interval(..., "second"), which expands the end to the last microsecond of its second, so adjacent intervals reported overlaps instead of meets. Parse exact values and build the TemporalInterval directly. - temporal distance normalized both timestamps to whole seconds first, so distinct subsecond timestamps collapsed to distance_seconds 0. Parse exact values and subtract. - temporal history missed facts recorded without explicit validity dates: the export keeps recorded_at under properties/metadata while the engine reads it at the fact's top level. Lift it (normalized to UTC) when loading. - temporal snapshot/query/history read the memory-backend file regardless of the configured backend; with --store neo4j they returned empty memory-file data with exit 0. Raise an explicit not-wired error instead, matching the CLI's existing guard wording. Signed-off-by: Charan Rathore <[email protected]>
|
Addressing all four Qodo findings. I reproduced each one first, then fixed it; 7bbc154 contains the fixes and regression tests. 1. Temporal commands read the wrong graph (High) — confirmed, fixed. With 2. Recorded decisions have no history (High) — confirmed, fixed. Recorded a decision without 3. Adjacent intervals appear to overlap (Medium) — confirmed, fixed. 4. Subsecond distances become zero (Medium) — confirmed, fixed. Regression tests added for all four (adjacent-meets, subsecond distance, recording event in history, non-memory backend rejection). Full run: 18/18 temporal CLI tests, 27/27 tests/cli, 529 temporal-related tests green. |
pkupt
left a comment
There was a problem hiding this comment.
Verified the remap on the branch. It targets the APIs that actually exist on v0.7.0 (the TemporalGraphQuery / TemporalReasoningEngine signatures all match), and the two engine-side changes are load-bearing rather than cosmetic: ContextGraph.to_kg_dict() emits source_id/target_id (semantica/context/context_graph.py:3684), so without the fallback in reconstruct_at_time/timeline_of the entity lookup resolves to the string "None" and every relationship is silently dropped. The recorded_at lift is needed for the same reason, since add_node/add_edge keep extra fields in metadata/properties, which to_kg_dict() nests.
Two things to fix before merge.
-
semantica/cli.py:3971— the two blank lines betweentemporal_allenand@main.group(invoke_without_command=True)were dropped, so there are now zero. Every other@main.groupin the file has two, and pre-commit runs black 24.1.1 plus flake8 7.0.0 with onlyE203,W503ignored, soE305fires andpre-commit run --all-filesis red here. CI does not run pre-commit, which is why the checks stay green. -
temporal history --format jsonemits non-ISO timestamps ("2025-03-01 12:00:00+00:00", space-separated, from_jecho'sdefault=str), whiletemporal distance --jsonin the same group emits2025-01-01T00:00:00+00:00.tests/cli/test_cli_temporal.py:295pins the space form withstartswith("2025-03-01 12:00:00"), so the inconsistency becomes the contract. Please serialize throughserialize_temporal_value/relationship_to_json_ready, or at least drop that format assertion.
Minor, non-blocking.
-
parse_temporal_valueraisesTemporalValidationErroron bad input; it never returnsNone(semantica/kg/temporal_model.py:83-109). So the None guards atcli.py:3735,3740and3910are unreachable and their messages never appear; invalid input still exits non-zero through the generic Semantica error card. For the same reason the naive-timezone guards (cli.py:3743-3746, and the_awarehelper intemporal_history) are dead, sinceparse_temporal_valuealways returns an aware UTC datetime. -
temporal historynow serves atimeline_ofevent stream instead of version records, leavingTemporalVersionManager.list_versions()(suggested in the issue) unreachable from the CLI. Fine as a scope call, but worth confirming the intended semantics. -
Non-memory backends are gated with an explicit error rather than adapted. Reasonable for now, worth noting as a known limitation.
…ze temporal history JSON - Restore the two blank lines after temporal_allen's error-handling return so the provenance @main.group no longer trips flake8 E302/E305 (the pre-commit hook runs flake8 with --max-line-length=88 --extend-ignore=E203,W503). - Route temporal history --format json through temporal_structure_to_json_ready, which serializes every datetime via serialize_temporal_value, so timestamps come out ISO 8601 with Z, same as temporal distance --json. Repin the CLI test to the ISO form. Signed-off-by: Charan Rathore <[email protected]>
|
Thanks for the close read, @pkupt. Both items are fixed in 7220688: 1. Blank lines / E305. Restored the two blank lines before the provenance group decorator after temporal_allen's error-handling return. I checked locally with the exact pre-commit flake8 args ( 2. JSON timestamps. On the minor notes:
Tests run locally: tests/cli (27 passed), kg temporal tests (99 passed), temporal semantics/provenance suites (141 passed). |
pkupt
left a comment
There was a problem hiding this comment.
Re-checked 7220688. Both items are addressed: the provenance group has its two blank lines back, and temporal history --format json now serializes through temporal_structure_to_json_ready, so timestamps come out as ISO 8601 (2025-01-01T00:00:00Z), consistent with temporal distance --json; the test assertion was updated to match. I re-ran the new test file (18 passed) and all five subcommands on the branch (exit 0), and the merge against main is clean. One optional follow-up, not blocking: the non-JSON output of temporal history (its default --format table) still renders timestamps through _pprint's default=str, so that path shows the space-separated form while the JSON path is now ISO.
…a-agi#1970 semantica-agi#1987 semantica-agi#1990) 非回环 --host 的来源放行、IPv6 方括号写法、--port 0 行为、 create_app() 统一默认来源、SEMANTICA_CORS_ORIGINS 默认值扩充。
Description
All five
semantica temporalsubcommands crash on v0.7.0 because the CLI wrappers call methods and constructors that no longer exist on the engine classes. This re-maps each subcommand onto the APIs that actually exist, following the approach outlined in the issue thread.Type of Change
Related Issues
Fixes #1809
Changes Made
snapshot->TemporalGraphQuery.reconstruct_at_time()over the persisted memory-backend graph (_load_context_graph(...).to_kg_dict())query->TemporalGraphQuery.query_at_time(), with a new optional--atflag (defaults to the current time); the help text notes the query string is reserved for future query parsing, matching the enginehistory->TemporalReasoningEngine.timeline_of()over the graph's facts, with the--sincefilter applied to event timestampsdistance-> implemented as the absolute delta between the two timestamps vianormalize_timestamp(); JSON output carriesdistance_seconds/distance_days. The--historyflag is dropped since no behavior exists behind itallen-> eachstart/endspec parsed withnormalize_interval()and compared withTemporalReasoningEngine().relation()(the oldconfig=kwarg is what raisedTemporalReasoningEngine() takes no arguments)reconstruct_at_time()andtimeline_of()still read the legacysource/targetkeys whileContextGraph.to_kg_dict()(the documented adapter for these consumers) emitssource_id/target_id, silently dropping every relationship; both now accept either key, matching the fallback already used elsewhere intemporal_querytests/cli/test_cli_temporal.py: a CliRunner smoke test per subcommand against a small fixture graph (13 tests)Testing
python -m build)Test Commands
Documentation
Breaking Changes
Breaking Changes: No
(
temporal distanceloses its--historyflag, but the subcommand has never executed successfully on any v0.7.0 install, so no working invocation breaks.)Checklist
black==26.5.1-clean; unrelated pre-existing formatting in the touched files is left alone)