Skip to content

Commit aa2b9f0

Browse files
Gemini CLIclaude
andcommitted
feat(std-platform): register SynonymStrategy in derivation runner
Wave 6+ to_synonym T4: to_synonym moves from coming_soon -> active. The runner now lights up 3 strategies (semantic_hint / value_semantics / synonym) and 3 remain coming_soon (qc_rule / defect_code / data_model). version_released event fanout triggers all three. Updates runner / derive-handler tests for the 3-active layout. The 'handlers routes version_released' test relaxes from n_links==1 to n_links>=1 since to_synonym contributes an additional link when the seeded element resolves to a real semantic_source row. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1abb56b commit aa2b9f0

3 files changed

Lines changed: 24 additions & 16 deletions

File tree

data_agent/standards_platform/derivation/runner.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
from typing import Optional
99

1010
from .strategies.semantic_hint import SemanticHintStrategy
11+
from .strategies.synonym import SynonymStrategy
1112
from .strategies.value_domain import ValueDomainStrategy
1213
from .strategy_base import DerivationStrategy
1314

1415

1516
_REGISTRY: dict[str, Optional[DerivationStrategy]] = {
1617
"to_semantic_hint": SemanticHintStrategy(),
17-
"to_synonym": None,
18+
"to_synonym": SynonymStrategy(),
1819
"to_value_semantics": ValueDomainStrategy(),
1920
"to_qc_rule": None,
2021
"to_defect_code": None,
@@ -24,7 +25,7 @@
2425
# Friendly descriptions for UI
2526
_DESCRIPTIONS: dict[str, str] = {
2627
"to_semantic_hint": "派生标准 data_element 到 agent_semantic_hints (column-scope hint)",
27-
"to_synonym": "(Wave 6+) 派生术语别名到 sources.synonyms",
28+
"to_synonym": "派生标准 data_element/term 名称别名到 agent_semantic_sources.derived_synonyms",
2829
"to_value_semantics": "派生标准值域 (enumeration/range/pattern) 到 agent_semantic_hints",
2930
"to_qc_rule": "(Wave 6+) 派生质检规则",
3031
"to_defect_code": "(Wave 6+) 派生缺陷分类编码",

data_agent/standards_platform/tests/test_derivation_runner.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ def test_get_strategy_status_lists_six(engine):
4949
assert "to_synonym" in names
5050
active_names = {s["name"] for s in statuses if s["status"] == "active"}
5151
coming_names = {s["name"] for s in statuses if s["status"] == "coming_soon"}
52-
# Wave 6-eng: to_value_semantics moved from coming_soon → active
53-
assert active_names == {"to_semantic_hint", "to_value_semantics"}
54-
assert len(coming_names) == 4
52+
# Wave 6+ to_synonym: 3 active strategies, 3 coming_soon (to_qc_rule,
53+
# to_defect_code, to_data_model).
54+
assert active_names == {
55+
"to_semantic_hint", "to_value_semantics", "to_synonym",
56+
}
57+
assert len(coming_names) == 3
5558

5659

5760
def test_dispatch_runs_active_strategy(engine, fresh_clause):
@@ -62,13 +65,16 @@ def test_dispatch_runs_active_strategy(engine, fresh_clause):
6265
assert "to_semantic_hint" in results
6366
assert results["to_semantic_hint"]["ok"] is True
6467
assert results["to_semantic_hint"]["new"] == 1
65-
# Wave 6-eng: to_value_semantics is now active too. The seeded element
66-
# has no value_domain → strategy succeeds with 0 new links.
68+
# to_value_semantics: no value_domain seeded → 0 new
6769
assert "to_value_semantics" in results
6870
assert results["to_value_semantics"]["ok"] is True
6971
assert results["to_value_semantics"]["new"] == 0
72+
# to_synonym: bound_table='cq_dltb' resolves to a real semantic_source
73+
# row (seeded by 4-27 production data), so 1 link is produced.
74+
assert "to_synonym" in results
75+
assert results["to_synonym"]["ok"] is True
7076
# Coming-soon strategies aren't run
71-
assert "to_synonym" not in results
77+
assert "to_qc_rule" not in results
7278
finally:
7379
_cleanup(engine, ver_id)
7480

@@ -78,9 +84,9 @@ def test_dispatch_with_strategies_filter(engine, fresh_clause):
7884
_seed_bound_element(engine, ver_id)
7985
try:
8086
results = runner.dispatch(
81-
version_id=ver_id, strategies=["to_synonym"]
87+
version_id=ver_id, strategies=["to_qc_rule"]
8288
)
83-
# to_synonym is coming_soon → not in active, results empty
89+
# to_qc_rule is coming_soon → not in active, results empty
8490
assert results == {}
8591
finally:
8692
_cleanup(engine, ver_id)
@@ -118,12 +124,13 @@ def test_handlers_dispatch_routes_version_released(engine, fresh_clause):
118124
"id": "test-evt",
119125
"attempts": 0,
120126
})
121-
# Should have produced a derived link
127+
# Should have produced at least 1 derived link (to_semantic_hint +
128+
# to_synonym may each contribute; assert >= 1 rather than == 1).
122129
with engine.connect() as c:
123130
n_links = c.execute(text(
124131
"SELECT count(*) FROM std_derived_link "
125132
"WHERE source_version_id=:v AND status='active'"
126133
), {"v": ver_id}).scalar()
127-
assert n_links == 1
134+
assert n_links >= 1
128135
finally:
129136
_cleanup(engine, ver_id)

data_agent/standards_platform/tests/test_derive_handler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ def test_list_strategies(monkeypatch):
5252
assert "to_semantic_hint" in names
5353
active = [s for s in strats if s["status"] == "active"]
5454
coming = [s for s in strats if s["status"] == "coming_soon"]
55-
# Wave 6-eng: to_value_semantics activated alongside to_semantic_hint.
56-
assert len(active) == 2
57-
assert len(coming) == 4
55+
# Wave 6+: to_synonym activated (3 active, 3 coming_soon).
56+
assert len(active) == 3
57+
assert len(coming) == 3
5858
assert {s["name"] for s in active} == {
59-
"to_semantic_hint", "to_value_semantics",
59+
"to_semantic_hint", "to_value_semantics", "to_synonym",
6060
}
6161

6262

0 commit comments

Comments
 (0)