Skip to content

Commit 1c9eb3b

Browse files
committed
style(flowlens): satisfy repository format gates
1 parent c339f21 commit 1c9eb3b

34 files changed

Lines changed: 1247 additions & 213 deletions

backend/packages/harness/deerflow/mcp/tools.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ def _safe_mcp_tool_metadata(
4141
"""Return bounded MCP metadata without connection secrets."""
4242

4343
source = tool.metadata if isinstance(tool.metadata, dict) else {}
44-
safe = {
45-
key: redact_value(value, max_string_length=200)
46-
for key, value in source.items()
47-
if isinstance(key, str) and key.casefold() not in _SENSITIVE_METADATA_KEYS
48-
}
44+
safe = {key: redact_value(value, max_string_length=200) for key, value in source.items() if isinstance(key, str) and key.casefold() not in _SENSITIVE_METADATA_KEYS}
4945
prefix = f"{server_name}_"
5046
original_name = tool.name[len(prefix) :] if tool.name.startswith(prefix) else tool.name
5147
safe.update(

backend/packages/harness/deerflow/runtime/diagnostics/attribution.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ def attribute_failure(record: Any | None, timeline: list[dict[str, Any]]) -> dic
141141

142142
mcp_auth = _find(
143143
timeline,
144-
lambda item: item.get("phase") == "mcp"
145-
and item.get("status") == "error"
146-
and _contains(item, "auth", "oauth", "unauthorized", "401"),
144+
lambda item: item.get("phase") == "mcp" and item.get("status") == "error" and _contains(item, "auth", "oauth", "unauthorized", "401"),
147145
)
148146
if mcp_auth is not None:
149147
matches.append(
@@ -159,9 +157,7 @@ def attribute_failure(record: Any | None, timeline: list[dict[str, Any]]) -> dic
159157

160158
mcp_session = _find(
161159
timeline,
162-
lambda item: item.get("phase") == "mcp"
163-
and item.get("status") == "error"
164-
and _contains(item, "session", "transport", "connect"),
160+
lambda item: item.get("phase") == "mcp" and item.get("status") == "error" and _contains(item, "session", "transport", "connect"),
165161
)
166162
if mcp_session is not None:
167163
matches.append(
@@ -241,9 +237,7 @@ def attribute_failure(record: Any | None, timeline: list[dict[str, Any]]) -> dic
241237

242238
mcp_tool_error = _find(
243239
timeline,
244-
lambda item: item.get("phase") == "mcp"
245-
and item.get("status") == "error"
246-
and _contains(item, "tool"),
240+
lambda item: item.get("phase") == "mcp" and item.get("status") == "error" and _contains(item, "tool"),
247241
)
248242
if mcp_tool_error is not None:
249243
matches.append(

backend/packages/harness/deerflow/runtime/diagnostics/emitter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ def find_diagnostic_recorder(runtime: Any) -> DiagnosticRecorder | None:
4040
if not isinstance(callbacks, (list, tuple)):
4141
return None
4242
for callback in callbacks:
43-
if callable(getattr(callback, "record_diagnostic_event", None)) and callable(
44-
getattr(callback, "record_diagnostic_event_threadsafe", None)
45-
):
43+
if callable(getattr(callback, "record_diagnostic_event", None)) and callable(getattr(callback, "record_diagnostic_event_threadsafe", None)):
4644
return callback
4745
return None

backend/packages/harness/deerflow/runtime/diagnostics/explainer.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,7 @@ async def explain(
111111
payload = self._prompt_payload(diagnostics)
112112
messages = [
113113
SystemMessage(content=_SYSTEM_PROMPT),
114-
HumanMessage(
115-
content=(
116-
f"Explain this diagnosis in {'Chinese' if locale == 'zh' else 'English'}:\n"
117-
f"{json.dumps(payload, ensure_ascii=False, sort_keys=True)}"
118-
)
119-
),
114+
HumanMessage(content=(f"Explain this diagnosis in {'Chinese' if locale == 'zh' else 'English'}:\n{json.dumps(payload, ensure_ascii=False, sort_keys=True)}")),
120115
]
121116
try:
122117
async with self._semaphore:

backend/packages/harness/deerflow/runtime/diagnostics/metrics.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ def _span_key(item: dict[str, Any], index: int) -> str:
8585

8686

8787
def _unique_count(timeline: list[dict[str, Any]], predicate) -> int:
88-
keys = {
89-
_span_key(item, index)
90-
for index, item in enumerate(timeline)
91-
if predicate(item)
92-
}
88+
keys = {_span_key(item, index) for index, item in enumerate(timeline) if predicate(item)}
9389
return len(keys)
9490

9591

backend/packages/harness/deerflow/runtime/diagnostics/redaction.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ def redact_value(value: Any, *, max_string_length: int = 4000) -> Any:
3737
"""Return a recursively redacted copy while preserving container shapes."""
3838

3939
if isinstance(value, dict):
40-
return {
41-
key: _REDACTED
42-
if isinstance(key, str) and key.casefold() in _SENSITIVE_KEYS
43-
else redact_value(item, max_string_length=max_string_length)
44-
for key, item in value.items()
45-
}
40+
return {key: _REDACTED if isinstance(key, str) and key.casefold() in _SENSITIVE_KEYS else redact_value(item, max_string_length=max_string_length) for key, item in value.items()}
4641
if isinstance(value, list):
4742
return [redact_value(item, max_string_length=max_string_length) for item in value]
4843
if isinstance(value, tuple):

backend/packages/harness/deerflow/runtime/diagnostics/timeline.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,7 @@ def _duration_ms(metadata: dict[str, Any]) -> int | float | None:
112112

113113

114114
def _summary_for(event_type: str, content: Any, metadata: dict[str, Any]) -> str:
115-
return (
116-
_event_text(content)
117-
or _string_metadata(metadata, "reason")
118-
or _string_metadata(metadata, "error_type")
119-
or event_type
120-
)
115+
return _event_text(content) or _string_metadata(metadata, "reason") or _string_metadata(metadata, "error_type") or event_type
121116

122117

123118
def _string_metadata(metadata: dict[str, Any], key: str) -> str | None:

backend/packages/harness/deerflow/runtime/runs/store/memory.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ async def list_recent(
7979
results = [run for run in results if run["created_at"] < started_before]
8080
if cursor is not None:
8181
decoded = decode_run_cursor(cursor)
82-
results = [
83-
run
84-
for run in results
85-
if (run["created_at"], run["run_id"]) < (decoded.created_at, decoded.run_id)
86-
]
82+
results = [run for run in results if (run["created_at"], run["run_id"]) < (decoded.created_at, decoded.run_id)]
8783
results.sort(key=lambda run: (run["created_at"], run["run_id"]), reverse=True)
8884
return results[:limit]
8985

backend/scripts/benchmark_flowlens.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,3 @@ def main() -> int:
150150

151151
if __name__ == "__main__":
152152
raise SystemExit(main())
153-

backend/tests/test_flowlens_benchmark_contract.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,3 @@ def test_synthetic_events_are_deterministic_and_correlated():
3838
assert len(first) == 25
3939
assert [event["seq"] for event in first] == list(range(1, 26))
4040
assert all(event["metadata"]["span_id"] for event in first)
41-

0 commit comments

Comments
 (0)