feat(task-012): orchestrate parallel section production jobs

This commit is contained in:
2026-05-21 23:10:34 +03:00
parent 7e1b05067c
commit 8ebb5ad623
15 changed files with 756 additions and 39 deletions
@@ -1413,6 +1413,7 @@ class AgentJobsRepository:
agent_profile: str,
status: AgentJobStatus,
input_files: list[JsonObject],
payload: JsonObject | None = None,
queued_at: datetime,
) -> AgentJobSummary:
job_id = uuid4()
@@ -1428,6 +1429,7 @@ class AgentJobsRepository:
agent_profile,
status,
input_files,
payload,
queued_at
)
VALUES (
@@ -1439,6 +1441,7 @@ class AgentJobsRepository:
{placeholder},
{placeholder},
{placeholder}{json_cast},
{placeholder}{json_cast},
{placeholder}
)
"""
@@ -1454,6 +1457,7 @@ class AgentJobsRepository:
agent_profile,
status.value,
_json_value(input_files),
_json_value(payload or {}),
_datetime_value(queued_at),
),
)
@@ -1472,6 +1476,21 @@ class AgentJobsRepository:
return [_agent_job_summary_from_row(row) for row in rows]
def list_for_article(self, article_id: UUID) -> list[AgentJobSummary]:
placeholder = self._repository.placeholder()
with self._repository.connection() as connection:
rows = connection.execute(
f"""
SELECT {self._select_columns()}
FROM agent_jobs
WHERE article_id = {placeholder}
ORDER BY queued_at DESC
""",
(str(article_id),),
).fetchall()
return [_agent_job_summary_from_row(row) for row in rows]
def get(self, job_id: UUID) -> AgentJobSummary:
placeholder = self._repository.placeholder()
with self._repository.connection() as connection:
@@ -1528,6 +1547,7 @@ class AgentJobsRepository:
status: AgentJobStatus,
workspace_path: str | None,
output_files: list[JsonObject],
payload: JsonObject | None,
error_category: AgentJobErrorCategory | None,
error_message: str | None,
stdout: str,
@@ -1550,6 +1570,7 @@ class AgentJobsRepository:
status = {placeholder},
workspace_path = {placeholder},
output_files = {placeholder}{json_cast},
payload = {placeholder}{json_cast},
error_category = {placeholder},
error_message = {placeholder},
stdout = {placeholder},
@@ -1563,6 +1584,7 @@ class AgentJobsRepository:
status.value,
workspace_path,
_json_value(output_files),
_json_value(payload or {}),
_agent_error_category_value(error_category),
error_message,
stdout,
@@ -1614,6 +1636,7 @@ class AgentJobsRepository:
workspace_path,
input_files,
output_files,
payload,
error_category,
error_message,
stdout,
@@ -2165,6 +2188,7 @@ def _agent_job_summary_from_row(row: Any) -> AgentJobSummary:
workspace_path=_row_value(row, "workspace_path"),
input_files=_json_from_row(row, "input_files"),
output_files=_json_from_row(row, "output_files"),
payload=_json_from_row(row, "payload"),
error_category=_row_value(row, "error_category"),
error_message=_row_value(row, "error_message"),
stdout=_row_value(row, "stdout"),