fix(reflect): preserve legacy null source fields
Keep source-less annotations while discarding malformed non-string paths. Refs #5019.
Co-Authored-By: OpenAI Codex <noreply@openai.com>
(cherry picked from commit 44a7ca59c1)
This commit is contained in:
1 parent
bf1e19dce9
commit
204b50854d
2 files changed
+4
-1
No files matched your search
+2
-1
@@ -860,7 +860,8 @@ def load_learning_overlay(graph_path: Path) -> dict[str, dict[str, Any]]:
|
||||
for nid, entry in nodes.items():
|
||||
if not isinstance(entry, dict):
|
||||
continue
|
||||
if not isinstance(entry.get("source_file", ""), str):
|
||||
source = entry.get("source_file")
|
||||
if source is not None and not isinstance(source, str):
|
||||
continue
|
||||
merged = dict(entry)
|
||||
try:
|
||||
|
||||
@@ -18,11 +18,13 @@ def test_learning_overlay_keeps_valid_entries_beside_malformed_source(tmp_path):
|
||||
payload = {"nodes": {
|
||||
"bad": {"source_file": ["app.py"], "status": "preferred"},
|
||||
"good": {"status": "preferred", "score": 2},
|
||||
"legacy": {"source_file": None, "status": "preferred"},
|
||||
"gone": {"source_file": "deleted.py", "status": "preferred"},
|
||||
}}
|
||||
(tmp_path / LEARNING_SIDECAR_NAME).write_text(json.dumps(payload), encoding="utf-8")
|
||||
|
||||
assert load_learning_overlay(tmp_path / "graph.json") == {
|
||||
"good": {"status": "preferred", "score": 2, "stale": False},
|
||||
"legacy": {"source_file": None, "status": "preferred", "stale": False},
|
||||
"gone": {"source_file": "deleted.py", "status": "preferred", "stale": True},
|
||||
}
|
||||
Reference in new issue
Block a user