Core changes: - Add @defgroup/@ingroup to 1791 C2+ contracts (555 files) for HCA 128× pre-training DSA grouping - Add §0.1 Pre-Training Frequency matrix to semantics-core - Add §VIII Attention Architecture rules (ATTN_1-4) with MLA/CSA/HCA/DSA mechanics - Add @defgroup/@ingroup to canonical syntax (§II) and all contract examples Agent prompts (5 files): - Add ZERO-STATE RATIONALE with MLA/CSA/HCA/DSA compression mechanics - Add pre-training note: @RATIONALE/@REJECTED are in-context learned tags - svelte-coder: add missing #region contract, fix Svelte rule violations - python-coder/fullstack-coder: honor function contracts from speckit plan - qa-tester: add attention compliance audit (P3 ATTN_1-4 checks) Skills (6 files): - Translate all axiom_config descriptions to English - Fix doc_dirs to index .opencode/ and .specify/ - Deduplicate 5× complexity_rules → single global_tags catalog - Reduce semantics-svelte 591→485 lines (remove duplicate code blocks) - Fix semantics-testing: 'Short IDs' → 'Short hierarchical IDs' - Fix all examples: flat IDs → hierarchical Domain.Name format - Fix Svelte examples: replace raw Tailwind + <button> with semantic tokens + /ui Speckit workflow (commands + templates): - speckit.plan: add Function-Level Contracts for C3+ with @PRE/@POST/@TEST_EDGE - speckit.plan: add Attention Compliance Gate (ATTN_1-4 before contract generation) - speckit.tasks: add function contract inlining format (constraints in task description) - speckit.specify: load semantics-core for spec density rules - spec-template: add #region contract, @SEMANTICS grouping, hierarchical IDs - ux-reference-template: add #region wrapper - plan-template: add attention gate, @defgroup/@ingroup guidance - tasks-template: add attention audit + rebuild + orphan check tasks - constitution.md: translate to English, add Principle VIII (attention-optimized contracts) Reference modules rewritten (hierarchical IDs + full contracts): - Auth.Jwt: 6 child contracts with @RATIONALE/@REJECTED/@TEST_EDGE - Api.Auth: 5 endpoints with @TEST_EDGE + molecular CoT markers - Migration.Model: @defgroup Migration with 18 @ACTION + 6 @INVARIANT Scripts: - add_defgroup_ingroup.py: zero-risk additive @ingroup migration (1791 insertions) - migrate_hierarchical.py: flat→hierarchical ID dry-run analysis (792 contracts) - merge_prompts.py: merge all prompts/skills/commands into one review file Config: - axiom_config.yaml: 749→395 lines (-47%), English, doc_dirs include prompts - Fix test_datasets.py import collision (rename → test_datasets_routes.py) - Fix test_preview.py: SupersetClient→get_superset_client, AsyncMock, logger f-string
82 lines
3.1 KiB
Python
82 lines
3.1 KiB
Python
# #region AssistantToolTaskStatus [C:3] [TYPE Module] [SEMANTICS assistant, tool, status, task]
|
||
# @defgroup AssistantApi Module group.
|
||
# @BRIEF Handler for the "get_task_status" tool — retrieve task status by id or latest user task.
|
||
# @LAYER API
|
||
# @RELATION DEPENDS_ON -> [AssistantToolRegistry]
|
||
# @RELATION DEPENDS_ON -> [TaskManager]
|
||
|
||
from __future__ import annotations
|
||
|
||
from typing import Any
|
||
|
||
from fastapi import HTTPException
|
||
from sqlalchemy.orm import Session
|
||
|
||
from src.core.config_manager import ConfigManager
|
||
from src.core.logger import belief_scope, logger
|
||
from src.core.task_manager import TaskManager
|
||
from src.schemas.auth import User
|
||
|
||
from ._resolvers import _build_task_observability_summary, _extract_result_deep_links
|
||
from ._schemas import AssistantAction
|
||
from ._tool_registry import _check_any_permission, assistant_tool
|
||
|
||
|
||
# #region handle_get_task_status [C:3] [TYPE Function]
|
||
# @ingroup AssistantApi
|
||
@assistant_tool(
|
||
operation="get_task_status",
|
||
domain="status",
|
||
description="Get task status by task_id or latest user task",
|
||
optional_entities=["task_id"],
|
||
risk_level="safe",
|
||
requires_confirmation=False,
|
||
permission_checks=[("tasks", "READ")],
|
||
)
|
||
@belief_scope("get_task_status")
|
||
async def handle_get_task_status(
|
||
intent: dict[str, Any],
|
||
current_user: User,
|
||
task_manager: TaskManager,
|
||
config_manager: ConfigManager,
|
||
db: Session,
|
||
) -> tuple[str, str | None, list[AssistantAction]]:
|
||
"""Get task status by task_id or latest user task."""
|
||
_check_any_permission(current_user, [("tasks", "READ")])
|
||
entities = intent.get("entities", {})
|
||
task_id = entities.get("task_id")
|
||
if not task_id:
|
||
recent = [
|
||
t
|
||
for t in task_manager.get_tasks(limit=20, offset=0)
|
||
if t.user_id == current_user.id
|
||
]
|
||
if not recent:
|
||
return ("У вас пока нет задач в истории.", None, [])
|
||
task = recent[0]
|
||
actions = [AssistantAction(type="open_task", label="Open Task", target=task.id)]
|
||
if str(task.status).upper() in {"SUCCESS", "FAILED"}:
|
||
actions.extend(_extract_result_deep_links(task, config_manager))
|
||
summary_line = _build_task_observability_summary(task, config_manager)
|
||
text = (
|
||
f"Последняя задача: {task.id}, статус: {task.status}."
|
||
+ (f"\n{summary_line}" if summary_line else "")
|
||
)
|
||
return (text, task.id, actions)
|
||
task = task_manager.get_task(task_id)
|
||
if not task:
|
||
raise HTTPException(status_code=404, detail=f"Task {task_id} not found")
|
||
actions = [AssistantAction(type="open_task", label="Open Task", target=task.id)]
|
||
if str(task.status).upper() in {"SUCCESS", "FAILED"}:
|
||
actions.extend(_extract_result_deep_links(task, config_manager))
|
||
summary_line = _build_task_observability_summary(task, config_manager)
|
||
text = (
|
||
f"Статус задачи {task.id}: {task.status}."
|
||
+ (f"\n{summary_line}" if summary_line else "")
|
||
)
|
||
return (text, task.id, actions)
|
||
|
||
|
||
# #endregion handle_get_task_status
|
||
# #endregion AssistantToolTaskStatus
|