Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion intelligence/company/mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _loom_runtime_agent_ids() -> set[str]:
except Exception:
return set()
agent_ids: set[str] = set()
for record in list(payload.get('agents') or []):
for record in payload.get('agents') or []:
if not isinstance(record, dict):
continue
agent_id = str(record.get('agent_id') or '').strip().lower()
Expand Down
2 changes: 1 addition & 1 deletion intelligence/company/meridian_platform/agent_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def normalize_agent_record(agent, context_source='agent_registry'):
def _backfill_runtime_bindings(data, context_source='agent_registry'):
changed = False
agents = data.get('agents') or {}
for agent_id, agent in list(agents.items()):
for agent_id, agent in agents.items():
normalized = normalize_agent_record(agent, context_source=context_source)
if normalized != agent:
agents[agent_id] = normalized
Expand Down
2 changes: 1 addition & 1 deletion intelligence/company/meridian_platform/brain_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _policy_route_to_plan(route: dict[str, Any], policy: dict[str, Any], *, mode
auth_profiles = dict(policy.get("auth_profiles") or {})
auth_profile_name = ""
auth_profile: dict[str, Any] = {}
for item in list(route.get("auth_profile_order") or []):
for item in route.get("auth_profile_order") or []:
candidate = str(item or "").strip()
if not candidate:
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _ensure_route_registry_bindings(policy: dict[str, Any]) -> dict[str, Any]:
model_registry = dict(policy.get('model_registry') or {})
routes: list[dict[str, Any]] = []

for route in list(policy.get('routes') or []):
for route in policy.get('routes') or []:
current = dict(route)
provider_ref = str(current.get('provider_ref') or current.get('provider_profile') or '').strip()
model_name = str(current.get('model') or '').strip()
Expand Down Expand Up @@ -273,7 +273,7 @@ def resolve_profile_defaults(policy: dict[str, Any], provider_profile: str) -> d
provider_registry = dict(policy.get('provider_registry') or {})
auth_profiles = dict(policy.get('auth_profiles') or {})
primary_route_id = str(policy.get('primary_route_id') or '').strip()
routes = [dict(item) for item in list(policy.get('routes') or []) if isinstance(item, dict)]
routes = [dict(item) for item in policy.get('routes') or [] if isinstance(item, dict)]
matched_routes = [
route for route in routes
if str(route.get('provider_ref') or route.get('provider_profile') or '').strip() == provider_profile
Expand All @@ -290,7 +290,7 @@ def resolve_profile_defaults(policy: dict[str, Any], provider_profile: str) -> d
if provider_profile and isinstance(auth_profiles.get(provider_profile), dict):
auth_profile_name = provider_profile
elif preferred_route:
for candidate in list(preferred_route.get('auth_profile_order') or []):
for candidate in preferred_route.get('auth_profile_order') or []:
token = str(candidate or '').strip()
if token and isinstance(auth_profiles.get(token), dict):
auth_profile_name = token
Expand Down Expand Up @@ -454,7 +454,7 @@ def _prune_unreferenced_entries(policy: dict[str, Any]) -> dict[str, Any]:
used_provider_ids.add(provider_id)
if model_id:
used_model_ids.add(model_id)
for auth_name in list(route.get('auth_profile_order') or []):
for auth_name in route.get('auth_profile_order') or []:
auth_name = str(auth_name or '').strip()
if auth_name:
used_auth_profile_names.add(auth_name)
Expand Down Expand Up @@ -483,7 +483,7 @@ def _prune_unreferenced_entries(policy: dict[str, Any]) -> dict[str, Any]:
def route_map(policy: dict[str, Any]) -> dict[str, dict[str, Any]]:
return {
str(route.get('route_id') or '').strip(): route
for route in list(policy.get('routes') or [])
for route in policy.get('routes') or []
if str(route.get('route_id') or '').strip()
}

Expand All @@ -499,7 +499,7 @@ def resolve_route_chain(policy: dict[str, Any]) -> list[dict[str, Any]]:
if not primary:
return []
chain = [primary]
for route_id in list(primary.get('fallback_route_ids') or []):
for route_id in primary.get('fallback_route_ids') or []:
route = routes.get(str(route_id or '').strip())
if route:
chain.append(route)
Expand Down Expand Up @@ -584,7 +584,7 @@ def update_route_health(
) -> dict[str, Any]:
policy = load_policy(org_id)
routes = []
for route in list(policy.get('routes') or []):
for route in policy.get('routes') or []:
current = dict(route)
if str(current.get('route_id') or '') == str(route_id or ''):
current['last_health'] = health
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _normalize_store(data, org_id):
record['preview_id'] = record.get('preview_id') or preview_id
previews[record['preview_id']] = record

for preview_id, record in list(previews.items()):
for preview_id, record in previews.items():
previews[preview_id] = _normalize_preview(record, org_id, existing=record)
store['subscription_previews'] = previews
if 'states' not in store or not store['states']:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def _normalize_subscriptions(data, org_id=None):
record = dict(item)
record['draft_id'] = record.get('draft_id') or draft_id
drafts[record['draft_id']] = record
for draft_id, record in list(drafts.items()):
for draft_id, record in drafts.items():
drafts[draft_id] = _normalize_draft_subscription(record, org_id, existing=record)
payload['draft_subscriptions'] = drafts

Expand Down
44 changes: 22 additions & 22 deletions intelligence/meridian_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def _loom_runtime_agent_ids() -> set[str]:
except Exception:
return set()
agent_ids: set[str] = set()
for record in list(payload.get("agents") or []):
for record in payload.get("agents") or []:
if not isinstance(record, dict):
continue
agent_id = str(record.get("agent_id") or "").strip().lower()
Expand Down Expand Up @@ -3853,7 +3853,7 @@ def _full_session_history_context(session_key: str, *, limit: int = 24) -> str:
imported = imported_history_context(session_key, loom_root=LOOM_ROOT, limit=limit)
live_doc = load_session_events(session_key, loom_root=LOOM_ROOT) or {}
live_events = [
e for e in list(live_doc.get("events") or [])
e for e in live_doc.get("events") or []
if e.get("history_type") in {"manager_plan", "manager_response", "worker_receipt"}
and str(e.get("text") or "").strip()
]
Expand Down Expand Up @@ -4687,7 +4687,7 @@ def _manager_synthesis(
manager_meta = _manager_exec_metadata(manager_defaults.get("model", ""))
skill_names = [
str(item.get("name") or "").strip()
for item in list((plan or {}).get("skills") or [])
for item in (plan or {}).get("skills") or []
if isinstance(item, dict) and str(item.get("name") or "").strip()
]
fastpath_artifact, fastpath_warning = _manager_fastpath_artifact(goal, steps, skill_names)
Expand Down Expand Up @@ -5115,12 +5115,12 @@ def _run_team_route(text: str, session_key: str, runtime: AgentRuntime) -> tuple
"questionnaire_id": str(dict(questionnaire_outcome or {}).get("questionnaire", {}).get("questionnaire_id") or "").strip(),
"questionnaire_items": [
dict(item)
for item in list(dict(questionnaire_outcome or {}).get("questionnaire", {}).get("questions") or [])
for item in dict(questionnaire_outcome or {}).get("questionnaire", {}).get("questions") or []
if isinstance(item, dict)
],
"approval_queue_entries": [
dict(item)
for item in list(dict(questionnaire_outcome or {}).get("approval_queue_entries") or [])
for item in dict(questionnaire_outcome or {}).get("approval_queue_entries") or []
if isinstance(item, dict)
],
"approval_gate_status": str(dict(questionnaire_outcome or {}).get("approval_gate_status") or "").strip(),
Expand Down Expand Up @@ -7382,7 +7382,7 @@ def _upsert_memory_entry(state: dict[str, Any], entry: dict[str, Any]) -> tuple[
category = str(entry.get("category") or "").strip()
source_skill_names = [
str(item or "").strip().lower()
for item in list(entry.get("source_skill_names") or record.get("source_skill_names") or [])
for item in entry.get("source_skill_names") or record.get("source_skill_names") or []
if str(item or "").strip()
]
record["source_skill_names"] = source_skill_names
Expand Down Expand Up @@ -8333,7 +8333,7 @@ def _trust_evidence_packet_delivery_entries(trust_packet: dict[str, Any] | None)
def _trust_evidence_packet_keys(trust_packet: dict[str, Any] | None) -> list[str]:
return [
str(item.get("key") or "").strip()
for item in list(dict(trust_packet or {}).get("entries") or [])
for item in dict(trust_packet or {}).get("entries") or []
if isinstance(item, dict) and str(item.get("key") or "").strip()
]

Expand Down Expand Up @@ -8512,12 +8512,12 @@ def _upsert_trust_evidence_entry(state: dict[str, Any], entry: dict[str, Any]) -
record["approval_status"] = str(entry.get("approval_status") or record.get("approval_status") or "draft").strip().lower()
record["topic_tags"] = [
str(tag).strip().lower()
for tag in list(entry.get("topic_tags") or record.get("topic_tags") or [])
for tag in entry.get("topic_tags") or record.get("topic_tags") or []
if str(tag).strip()
]
record["source_skill_names"] = [
str(skill).strip().lower()
for skill in list(entry.get("source_skill_names") or record.get("source_skill_names") or [])
for skill in entry.get("source_skill_names") or record.get("source_skill_names") or []
if str(skill).strip()
]
record["source_session_key"] = str(entry.get("source_session_key") or record.get("source_session_key") or "").strip()
Expand Down Expand Up @@ -8835,7 +8835,7 @@ def _questionnaire_support_snapshot(
question_topics.intersection(
{
str(tag).strip().lower()
for tag in list(dict(entry).get("topic_tags") or [])
for tag in dict(entry).get("topic_tags") or []
if str(tag).strip()
}
)
Expand All @@ -8848,7 +8848,7 @@ def _questionnaire_support_snapshot(
and not question_topics.intersection(
{
str(tag).strip().lower()
for tag in list(dict(entry).get("topic_tags") or [])
for tag in dict(entry).get("topic_tags") or []
if str(tag).strip()
}
)
Expand Down Expand Up @@ -9010,7 +9010,7 @@ def _build_questionnaire_state(
evidence_state = _load_trust_evidence_state()
evidence_entries = [
dict(item)
for item in list((evidence_state.get("entries") or {}).values())
for item in (evidence_state.get("entries") or {}).values()
if isinstance(item, dict) and str(item.get("content") or "").strip()
]
questions = _extract_questionnaire_items(request_text)
Expand Down Expand Up @@ -9121,7 +9121,7 @@ def _build_trust_assurance_summary(state: dict[str, Any] | None = None) -> dict[
questionnaires = [dict(item) for item in list((payload.get("questionnaires") or {}).values()) if isinstance(item, dict)]
pending_queue = [item for item in queue_entries if bool(item.get("approval_required"))]
evidence_counts = {"approved": 0, "draft": 0, "stale": 0, "revoked": 0}
for entry in list((evidence_state.get("entries") or {}).values()):
for entry in (evidence_state.get("entries") or {}).values():
if not isinstance(entry, dict):
continue
status = _trust_evidence_effective_status(entry)
Expand Down Expand Up @@ -9670,7 +9670,7 @@ def _atlas_memory_research_block(
request: str,
skill_names: list[str] | None = None,
) -> str:
entries = [dict(item) for item in list(dict(memory_packet or {}).get("entries") or []) if isinstance(item, dict)]
entries = [dict(item) for item in dict(memory_packet or {}).get("entries") or [] if isinstance(item, dict)]
if not entries:
return ""
lowered_skills = {str(item or "").strip().lower() for item in (skill_names or []) if str(item or "").strip()}
Expand Down Expand Up @@ -9713,7 +9713,7 @@ def _atlas_memory_research_block(
def _memory_packet_keys(memory_packet: dict[str, Any] | None) -> list[str]:
return [
str(item.get("key") or "").strip()
for item in list(dict(memory_packet or {}).get("entries") or [])
for item in dict(memory_packet or {}).get("entries") or []
if isinstance(item, dict) and str(item.get("key") or "").strip()
]

Expand Down Expand Up @@ -10898,7 +10898,7 @@ def _step_has_usable_artifact(step: dict[str, Any]) -> bool:


def _latest_usable_step_artifact(steps: list[dict[str, Any]]) -> str:
for step in reversed(list(steps or [])):
for step in reversed(steps or []):
if _step_has_usable_artifact(step):
return _step_result_text(step).strip()
return ""
Expand Down Expand Up @@ -13284,7 +13284,7 @@ def _salvage_user_artifact(request: str, skills_used: list[str]) -> str:
def _manager_response_shape(goal: str, plan: dict[str, Any] | None = None) -> str:
skill_names = {
str(item.get("name") or "").strip().lower()
for item in list((plan or {}).get("skills") or [])
for item in (plan or {}).get("skills") or []
if isinstance(item, dict) and str(item.get("name") or "").strip()
}
if _request_wants_protocol_artifact(goal):
Expand Down Expand Up @@ -13412,10 +13412,10 @@ def _flatten_external_channel_messages(channel: str, payload: dict[str, Any]) ->
channel = str(channel or "").strip().lower()
if channel == "messenger":
messages: list[dict[str, Any]] = []
for entry in list(payload.get("entry") or []):
for entry in payload.get("entry") or []:
if not isinstance(entry, dict):
continue
for event in list(entry.get("messaging") or []):
for event in entry.get("messaging") or []:
if not isinstance(event, dict):
continue
sender_id = str(dict(event.get("sender") or {}).get("id") or "").strip()
Expand All @@ -13427,14 +13427,14 @@ def _flatten_external_channel_messages(channel: str, payload: dict[str, Any]) ->
return messages
if channel == "whatsapp":
messages = []
for entry in list(payload.get("entry") or []):
for entry in payload.get("entry") or []:
if not isinstance(entry, dict):
continue
for change in list(entry.get("changes") or []):
for change in entry.get("changes") or []:
if not isinstance(change, dict):
continue
value = dict(change.get("value") or {})
for message in list(value.get("messages") or []):
for message in value.get("messages") or []:
if not isinstance(message, dict):
continue
sender_id = str(message.get("from") or "").strip()
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/federated_execution_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def _normalize_store(data, org_id):
record = dict(item)
record['job_id'] = record.get('job_id') or job_id
jobs[record['job_id']] = record
for job_id, record in list(jobs.items()):
for job_id, record in jobs.items():
record = dict(record or {})
record['request'] = _execution_request_snapshot(record)
record['gap'] = _execution_gap_snapshot(record, record['request'])
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/federation_handoff_dispatch_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def _normalize_store(data, org_id):
record = dict(item)
record['dispatch_id'] = record.get('dispatch_id') or dispatch_id
records[record['dispatch_id']] = record
for dispatch_id, record in list(records.items()):
for dispatch_id, record in records.items():
record = dict(record or {})
record['state'] = _normalize_state(record.get('state') or record.get('dispatch_state') or '')
record['dispatch_state'] = record.get('dispatch_state') or record['state']
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/federation_handoff_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _normalize_store(data, org_id):
record = dict(item)
record['handoff_id'] = record.get('handoff_id') or handoff_id
previews[record['handoff_id']] = record
for handoff_id, record in list(previews.items()):
for handoff_id, record in previews.items():
record = dict(record or {})
record['state'] = _normalize_state(record.get('state') or record.get('handoff_state') or '')
record['handoff_state'] = record.get('handoff_state') or record['state']
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/payout_execution_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _normalize_store(data, org_id):
record = dict(item)
record['execution_id'] = record.get('execution_id') or execution_id
records[record['execution_id']] = record
for execution_id, record in list(records.items()):
for execution_id, record in records.items():
record = dict(record or {})
record['state'] = _normalize_state(record.get('state') or record.get('execution_state') or '')
record['execution_state'] = record.get('execution_state') or record['state']
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/payout_plan_approval_candidate_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _normalize_store(data, org_id):
record = dict(item)
record['candidate_id'] = record.get('candidate_id') or candidate_id
candidates[record['candidate_id']] = record
for candidate_id, record in list(candidates.items()):
for candidate_id, record in candidates.items():
record = dict(record or {})
record['state'] = _normalize_state(record.get('state') or record.get('candidate_state') or '')
record['candidate_state'] = record.get('candidate_state') or record['state']
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/payout_plan_preview_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _normalize_store(data, org_id):
record = dict(item)
record['preview_id'] = record.get('preview_id') or preview_id
previews[record['preview_id']] = record
for preview_id, record in list(previews.items()):
for preview_id, record in previews.items():
record = dict(record or {})
record['state'] = _normalize_state(record.get('state') or record.get('preview_state') or '')
record['preview_state'] = record.get('preview_state') or record['state']
Expand Down
4 changes: 2 additions & 2 deletions kernel/kernel/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -2948,7 +2948,7 @@ def _sender_execution_delivery_ref_for_court_notice(bound_org_id, sender_warrant
commitment = None
if claims.commitment_id:
commitment = get_commitment(claims.commitment_id, org_id=bound_org_id)
for ref in reversed(list((commitment or {}).get('delivery_refs') or [])):
for ref in reversed((commitment or {}).get('delivery_refs') or []):
ref = dict(ref or {})
if (ref.get('message_type') or '').strip() != 'execution_request':
continue
Expand Down Expand Up @@ -5592,7 +5592,7 @@ def _maybe_restore_peer_for_case(case_record, actor_id, *, org_id, session_id=No
def _sender_warrant_delivery_ref_for_settlement_notice(commitment, claims, *, payload=None):
payload = payload if isinstance(payload, dict) else {}
execution_envelope_id = (payload.get('envelope_id') or '').strip()
for ref in reversed(list((commitment or {}).get('delivery_refs') or [])):
for ref in reversed((commitment or {}).get('delivery_refs') or []):
ref = dict(ref or {})
if (ref.get('message_type') or '').strip() != 'execution_request':
continue
Expand Down
Loading