feat(oracle): align annual and shadbala closure boards
This commit is contained in:
@@ -49,6 +49,9 @@ def _front_from_status(name: str, status: dict[str, Any], task_key: str, verifie
|
||||
"packet_path": first["packet_path"],
|
||||
"missing_field_count": len(missing_fields),
|
||||
"missing_fields": missing_fields,
|
||||
"missing_groups": first.get("missing_groups", {}),
|
||||
"prefilled_fields": first.get("prefilled_fields", {}),
|
||||
"manual_fill_plan": first.get("manual_fill_plan", {}),
|
||||
"apply_command": first.get("apply_command", ""),
|
||||
"validate_command": first.get("validate_command", ""),
|
||||
},
|
||||
@@ -113,6 +116,7 @@ def build_dashboard(dasha_oracle_file: str, tajika_oracle_file: str) -> dict[str
|
||||
"case_id": front["first_priority"]["case_id"],
|
||||
"capture_id": front["first_priority"]["capture_id"],
|
||||
"missing_field_count": front["first_priority"]["missing_field_count"],
|
||||
"manual_entry_count": int(front["first_priority"].get("manual_fill_plan", {}).get("manual_entry_count", front["first_priority"]["missing_field_count"])),
|
||||
"apply_command": front["first_priority"]["apply_command"],
|
||||
}
|
||||
for front in fronts.values()
|
||||
@@ -157,14 +161,18 @@ def render_markdown(report: dict[str, Any]) -> str:
|
||||
"",
|
||||
"## Fronts",
|
||||
"",
|
||||
"| front | tasks | verified | first priority | missing fields |",
|
||||
"|---|---:|---:|---|---:|",
|
||||
"| front | tasks | verified | first priority | missing fields | manual entries | metadata missing | target missing |",
|
||||
"|---|---:|---:|---|---:|---:|---:|---:|",
|
||||
]
|
||||
for key in ["dasha", "tajika_sahams", "shadbala"]:
|
||||
front = report["fronts"][key]
|
||||
first = front["first_priority"]
|
||||
missing_groups = first.get("missing_groups", {})
|
||||
manual_fill_plan = first.get("manual_fill_plan", {})
|
||||
lines.append(
|
||||
f"| `{key}` | {front['task_count']} | {front['external_verified_tasks']} | `{first['case_id']}` | {first['missing_field_count']} |"
|
||||
f"| `{key}` | {front['task_count']} | {front['external_verified_tasks']} | `{first['case_id']}` | "
|
||||
f"{first['missing_field_count']} | {manual_fill_plan.get('manual_entry_count', first['missing_field_count'])} | "
|
||||
f"{missing_groups.get('metadata', {}).get('count', 0)} | {missing_groups.get('target', {}).get('count', 0)} |"
|
||||
)
|
||||
lines.extend(["", "## Next Action Order", ""])
|
||||
for item in report["next_action_order"]:
|
||||
@@ -175,6 +183,7 @@ def render_markdown(report: dict[str, Any]) -> str:
|
||||
f"- case_id: `{item['case_id']}`",
|
||||
f"- capture_id: `{item['capture_id']}`",
|
||||
f"- missing_field_count: `{item['missing_field_count']}`",
|
||||
f"- manual_entry_count: `{item['manual_entry_count']}`",
|
||||
"",
|
||||
"```bash",
|
||||
item["apply_command"],
|
||||
|
||||
@@ -14,6 +14,7 @@ from typing import Any
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
PYTHON = sys.executable
|
||||
FIRST_PRIORITY_CASE_ID = "template_redacted_place_shadbala_raman"
|
||||
FIRST_PRIORITY_TEMPLATE_PATH = "references/oracle/evidence_packet_templates/shadbala_redacted_place_raman_first_packet.json"
|
||||
SHADBALA_TARGET_FIELD = "target.shadbala_components"
|
||||
SUPPORTING_TARGET_FIELDS = ["target.moon_sidereal_longitude_deg"]
|
||||
REQUIRED_PLANETS = ["Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn"]
|
||||
@@ -82,6 +83,67 @@ def _supporting_missing(packet: dict[str, Any], target_fields: list[str]) -> lis
|
||||
return missing
|
||||
|
||||
|
||||
def _group_missing_fields(missing_fields: list[str]) -> dict[str, Any]:
|
||||
metadata_fields = [field for field in missing_fields if field.startswith("metadata.")]
|
||||
target_fields = [field for field in missing_fields if field.startswith("target.")]
|
||||
body_groups: dict[str, list[str]] = {}
|
||||
prefix = f"{SHADBALA_TARGET_FIELD}."
|
||||
for field in target_fields:
|
||||
if not field.startswith(prefix):
|
||||
continue
|
||||
remainder = field[len(prefix):]
|
||||
body, _, component = remainder.partition(".")
|
||||
if not body or not component:
|
||||
continue
|
||||
body_groups.setdefault(body, []).append(field)
|
||||
grouped_bodies = {
|
||||
body: {
|
||||
"count": len(fields),
|
||||
"fields": fields,
|
||||
}
|
||||
for body, fields in sorted(body_groups.items())
|
||||
}
|
||||
return {
|
||||
"metadata": {
|
||||
"count": len(metadata_fields),
|
||||
"fields": metadata_fields,
|
||||
},
|
||||
"target": {
|
||||
"count": len(target_fields),
|
||||
"fields": target_fields,
|
||||
},
|
||||
"bodies": grouped_bodies,
|
||||
}
|
||||
|
||||
|
||||
def _prefilled_fields(packet: dict[str, Any], missing_fields: list[str]) -> dict[str, Any]:
|
||||
missing = set(missing_fields)
|
||||
metadata = {
|
||||
key: value
|
||||
for key, value in packet.get("metadata", {}).items()
|
||||
if f"metadata.{key}" not in missing and value not in ("", None, [], {})
|
||||
}
|
||||
settings = {
|
||||
key: value
|
||||
for key, value in packet.get("settings", {}).items()
|
||||
if value not in ("", None, [], {})
|
||||
}
|
||||
return {
|
||||
"status": packet.get("status"),
|
||||
"promotion_status_after_fill": packet.get("promotion_status_after_fill"),
|
||||
"metadata": metadata,
|
||||
"settings": settings,
|
||||
}
|
||||
|
||||
|
||||
def _manual_fill_plan(packet: dict[str, Any], missing_fields: list[str]) -> dict[str, Any]:
|
||||
return {
|
||||
"status_value": packet.get("promotion_status_after_fill", "external_verified"),
|
||||
"manual_entry_count": len(missing_fields),
|
||||
"remaining_manual_fields": missing_fields,
|
||||
}
|
||||
|
||||
|
||||
def _apply_command(packet_path: str, oracle_file: str) -> str:
|
||||
return (
|
||||
"python3 scripts/oracle_collection_queue.py "
|
||||
@@ -111,12 +173,15 @@ def build_status(oracle_file: str) -> dict[str, Any]:
|
||||
if priority is None:
|
||||
raise RuntimeError("No Shadbala target task found")
|
||||
|
||||
packet = priority["evidence_packet"]
|
||||
capture_id = packet["capture_id"]
|
||||
queue_packet = priority["evidence_packet"]
|
||||
capture_id = queue_packet["capture_id"]
|
||||
packet_path = f"references/oracle/artifacts/pending_packets/{capture_id}.json"
|
||||
template_path = FIRST_PRIORITY_TEMPLATE_PATH if priority["case_id"] == FIRST_PRIORITY_CASE_ID else packet_path
|
||||
packet = json.loads((ROOT / template_path).read_text(encoding="utf-8"))
|
||||
target_fields = priority.get("target_fields", [])
|
||||
supporting_target_fields = [field for field in SUPPORTING_TARGET_FIELDS if field in target_fields]
|
||||
missing_fields = _metadata_missing(packet) + _supporting_missing(packet, target_fields) + _shadbala_missing(packet)
|
||||
missing_groups = _group_missing_fields(missing_fields)
|
||||
external_verified = [
|
||||
task for task in shadbala_tasks
|
||||
if (
|
||||
@@ -145,6 +210,9 @@ def build_status(oracle_file: str) -> dict[str, Any]:
|
||||
"settings": priority.get("settings", {}),
|
||||
"required_target_fields": supporting_target_fields + [SHADBALA_TARGET_FIELD],
|
||||
"missing_fields": missing_fields,
|
||||
"missing_groups": missing_groups,
|
||||
"prefilled_fields": _prefilled_fields(packet, missing_fields),
|
||||
"manual_fill_plan": _manual_fill_plan(packet, missing_fields),
|
||||
"external_sources": [
|
||||
"JHora Shadbala component table screenshot",
|
||||
"PyJHora black-box shadbala output",
|
||||
@@ -186,9 +254,59 @@ def render_markdown(report: dict[str, Any]) -> str:
|
||||
f"- capture_id: `{first['capture_id']}`",
|
||||
f"- packet_path: `{first['packet_path']}`",
|
||||
f"- required_target_fields: `{', '.join(first['required_target_fields'])}`",
|
||||
f"- missing_fields: `{', '.join(first['missing_fields'])}`",
|
||||
f"- reject_global_scaling: `{str(first['reject_global_scaling']).lower()}`",
|
||||
"",
|
||||
"## Missing Summary",
|
||||
"",
|
||||
f"- metadata: `{first['missing_groups']['metadata']['count']}`",
|
||||
f"- target: `{first['missing_groups']['target']['count']}`",
|
||||
]
|
||||
if first["missing_groups"]["bodies"]:
|
||||
lines.extend(["- bodies:", ""])
|
||||
lines.extend(
|
||||
f" - {body}: `{payload['count']}`"
|
||||
for body, payload in first["missing_groups"]["bodies"].items()
|
||||
)
|
||||
lines.extend(
|
||||
[
|
||||
"",
|
||||
"## Prefilled Fields",
|
||||
"",
|
||||
f"- status: `{first['prefilled_fields']['status']}`",
|
||||
f"- promotion_status_after_fill: `{first['prefilled_fields']['promotion_status_after_fill']}`",
|
||||
"",
|
||||
]
|
||||
)
|
||||
if first["prefilled_fields"]["metadata"]:
|
||||
lines.append("- metadata:")
|
||||
lines.append("")
|
||||
lines.extend(
|
||||
f" - {key}: `{value}`"
|
||||
for key, value in first["prefilled_fields"]["metadata"].items()
|
||||
)
|
||||
lines.append("")
|
||||
if first["prefilled_fields"]["settings"]:
|
||||
lines.append("- settings:")
|
||||
lines.append("")
|
||||
lines.extend(
|
||||
f" - {key}: `{value}`"
|
||||
for key, value in first["prefilled_fields"]["settings"].items()
|
||||
)
|
||||
lines.append("")
|
||||
lines.extend(
|
||||
[
|
||||
"## Manual Fill Plan",
|
||||
"",
|
||||
f"- status_value: `{first['manual_fill_plan']['status_value']}`",
|
||||
f"- manual_entry_count: `{first['manual_fill_plan']['manual_entry_count']}`",
|
||||
"",
|
||||
"## Missing Fields",
|
||||
"",
|
||||
]
|
||||
)
|
||||
lines.extend(f"- `{field}`" for field in first["missing_fields"])
|
||||
lines.extend(
|
||||
[
|
||||
"## Required Matrix",
|
||||
"",
|
||||
f"- planets: `{', '.join(summary['required_planets'])}`",
|
||||
@@ -206,7 +324,8 @@ def render_markdown(report: dict[str, Any]) -> str:
|
||||
"",
|
||||
"## Next Actions",
|
||||
"",
|
||||
]
|
||||
]
|
||||
)
|
||||
lines.extend(f"- {item}" for item in report["next_actions"])
|
||||
lines.extend(["", "## Boundary", "", report["boundary"], ""])
|
||||
return "\n".join(lines)
|
||||
|
||||
@@ -14,6 +14,7 @@ from typing import Any
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
PYTHON = sys.executable
|
||||
FIRST_PRIORITY_CASE_ID = "template_steve_jobs_varshaphala_1984_lahiri"
|
||||
FIRST_PRIORITY_TEMPLATE_PATH = "references/oracle/evidence_packet_templates/tajika_steve_jobs_1984_first_packet.json"
|
||||
REQUIRED_TARGET_FIELDS = [
|
||||
"target.solar_return_datetime",
|
||||
"target.varsha_lagna_deg",
|
||||
@@ -66,6 +67,49 @@ def _target_missing(packet: dict[str, Any]) -> list[str]:
|
||||
return missing
|
||||
|
||||
|
||||
def _group_missing_fields(missing_fields: list[str]) -> dict[str, Any]:
|
||||
metadata_fields = [field for field in missing_fields if field.startswith("metadata.")]
|
||||
target_fields = [field for field in missing_fields if field.startswith("target.")]
|
||||
return {
|
||||
"metadata": {
|
||||
"count": len(metadata_fields),
|
||||
"fields": metadata_fields,
|
||||
},
|
||||
"target": {
|
||||
"count": len(target_fields),
|
||||
"fields": target_fields,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def _prefilled_fields(packet: dict[str, Any], missing_fields: list[str]) -> dict[str, Any]:
|
||||
missing = set(missing_fields)
|
||||
metadata = {
|
||||
key: value
|
||||
for key, value in packet.get("metadata", {}).items()
|
||||
if f"metadata.{key}" not in missing and value not in ("", None, [], {})
|
||||
}
|
||||
settings = {
|
||||
key: value
|
||||
for key, value in packet.get("settings", {}).items()
|
||||
if value not in ("", None, [], {})
|
||||
}
|
||||
return {
|
||||
"status": packet.get("status"),
|
||||
"promotion_status_after_fill": packet.get("promotion_status_after_fill"),
|
||||
"metadata": metadata,
|
||||
"settings": settings,
|
||||
}
|
||||
|
||||
|
||||
def _manual_fill_plan(packet: dict[str, Any], missing_fields: list[str]) -> dict[str, Any]:
|
||||
return {
|
||||
"status_value": packet.get("promotion_status_after_fill", "external_verified"),
|
||||
"manual_entry_count": len(missing_fields),
|
||||
"remaining_manual_fields": missing_fields,
|
||||
}
|
||||
|
||||
|
||||
def _apply_command(packet_path: str, oracle_file: str) -> str:
|
||||
return (
|
||||
"python3 scripts/tajika_annual_oracle_queue.py "
|
||||
@@ -93,10 +137,13 @@ def build_status(oracle_file: str) -> dict[str, Any]:
|
||||
if priority is None:
|
||||
raise RuntimeError("No Tajika annual task found")
|
||||
|
||||
packet = priority["evidence_packet"]
|
||||
capture_id = packet["capture_id"]
|
||||
queue_packet = priority["evidence_packet"]
|
||||
capture_id = queue_packet["capture_id"]
|
||||
packet_path = f"references/oracle/artifacts/pending_packets/{capture_id}.json"
|
||||
template_path = FIRST_PRIORITY_TEMPLATE_PATH if priority["case_id"] == FIRST_PRIORITY_CASE_ID else packet_path
|
||||
packet = json.loads((ROOT / template_path).read_text(encoding="utf-8"))
|
||||
missing_fields = _metadata_missing(packet) + _target_missing(packet)
|
||||
missing_groups = _group_missing_fields(missing_fields)
|
||||
external_verified = [
|
||||
task for task in annual_tasks
|
||||
if task.get("status") == "external_verified" and not _target_missing(task.get("evidence_packet", {}))
|
||||
@@ -119,6 +166,9 @@ def build_status(oracle_file: str) -> dict[str, Any]:
|
||||
"settings": priority.get("settings", {}),
|
||||
"required_target_fields": REQUIRED_TARGET_FIELDS,
|
||||
"missing_fields": missing_fields,
|
||||
"missing_groups": missing_groups,
|
||||
"prefilled_fields": _prefilled_fields(packet, missing_fields),
|
||||
"manual_fill_plan": _manual_fill_plan(packet, missing_fields),
|
||||
"external_sources": [
|
||||
"JHora Varshaphala screenshot",
|
||||
"PyJHora black-box annual output",
|
||||
@@ -158,8 +208,48 @@ def render_markdown(report: dict[str, Any]) -> str:
|
||||
f"- capture_id: `{first['capture_id']}`",
|
||||
f"- packet_path: `{first['packet_path']}`",
|
||||
f"- required_target_fields: `{', '.join(first['required_target_fields'])}`",
|
||||
f"- missing_fields: `{', '.join(first['missing_fields'])}`",
|
||||
"",
|
||||
"## Missing Summary",
|
||||
"",
|
||||
f"- metadata: `{first['missing_groups']['metadata']['count']}`",
|
||||
f"- target: `{first['missing_groups']['target']['count']}`",
|
||||
"",
|
||||
"## Prefilled Fields",
|
||||
"",
|
||||
f"- status: `{first['prefilled_fields']['status']}`",
|
||||
f"- promotion_status_after_fill: `{first['prefilled_fields']['promotion_status_after_fill']}`",
|
||||
"",
|
||||
]
|
||||
if first["prefilled_fields"]["metadata"]:
|
||||
lines.append("- metadata:")
|
||||
lines.append("")
|
||||
lines.extend(
|
||||
f" - {key}: `{value}`"
|
||||
for key, value in first["prefilled_fields"]["metadata"].items()
|
||||
)
|
||||
lines.append("")
|
||||
if first["prefilled_fields"]["settings"]:
|
||||
lines.append("- settings:")
|
||||
lines.append("")
|
||||
lines.extend(
|
||||
f" - {key}: `{value}`"
|
||||
for key, value in first["prefilled_fields"]["settings"].items()
|
||||
)
|
||||
lines.append("")
|
||||
lines.extend(
|
||||
[
|
||||
"## Manual Fill Plan",
|
||||
"",
|
||||
f"- status_value: `{first['manual_fill_plan']['status_value']}`",
|
||||
f"- manual_entry_count: `{first['manual_fill_plan']['manual_entry_count']}`",
|
||||
"",
|
||||
"## Missing Fields",
|
||||
"",
|
||||
]
|
||||
)
|
||||
lines.extend(f"- `{field}`" for field in first["missing_fields"])
|
||||
lines.extend(
|
||||
[
|
||||
"## Commands",
|
||||
"",
|
||||
"```bash",
|
||||
@@ -172,7 +262,8 @@ def render_markdown(report: dict[str, Any]) -> str:
|
||||
"",
|
||||
"## Next Actions",
|
||||
"",
|
||||
]
|
||||
]
|
||||
)
|
||||
lines.extend(f"- {item}" for item in report["next_actions"])
|
||||
lines.extend(["", "## Boundary", "", report["boundary"], ""])
|
||||
return "\n".join(lines)
|
||||
|
||||
Reference in New Issue
Block a user