Files
ss-tools/backend/src/api/routes/health.py
busya 8e8a3c3235 feat: attention-optimized semantic protocol v2.7
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
2026-06-08 16:30:59 +03:00

69 lines
2.9 KiB
Python

# #region health_router [C:3] [TYPE Module] [SEMANTICS fastapi, health, api, search, dashboard]
# @defgroup Api Module group.
# @BRIEF API endpoints for dashboard health monitoring and status aggregation.
# @LAYER UI
# @RELATION DEPENDS_ON -> [health_service]
from fastapi import APIRouter, Depends, HTTPException, Query, status
from sqlalchemy.orm import Session
from ...core.database import get_db
from ...dependencies import get_config_manager, get_task_manager, has_permission
from ...schemas.health import HealthSummaryResponse
from ...services.health_service import HealthService
router = APIRouter(prefix="/api/health", tags=["Health"])
# #region get_health_summary [TYPE Function]
# @ingroup Api
# @BRIEF Get aggregated health status for all dashboards.
# @PRE Caller has read permission for dashboard health view.
# @POST Returns HealthSummaryResponse.
# @RELATION CALLS -> [HealthService]
@router.get("/summary", response_model=HealthSummaryResponse)
async def get_health_summary(
environment_id: str | None = Query(None),
db: Session = Depends(get_db),
config_manager = Depends(get_config_manager),
_ = Depends(has_permission("plugin:migration", "READ"))
):
"""
@PURPOSE: Get aggregated health status for all dashboards.
@POST: Returns HealthSummaryResponse
"""
if not config_manager.get_config().settings.features.health_monitor:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Health monitor feature is disabled")
service = HealthService(db, config_manager=config_manager)
return await service.get_health_summary(environment_id=environment_id)
# #endregion get_health_summary
# #region delete_health_report [TYPE Function]
# @ingroup Api
# @BRIEF Delete one persisted dashboard validation report from health summary.
# @PRE Caller has write permission for tasks/report maintenance.
# @POST Validation record is removed; linked task/logs are cleaned when available.
# @RELATION CALLS -> [HealthService]
@router.delete("/summary/{record_id}", status_code=status.HTTP_204_NO_CONTENT)
async def delete_health_report(
record_id: str,
db: Session = Depends(get_db),
config_manager = Depends(get_config_manager),
task_manager = Depends(get_task_manager),
_ = Depends(has_permission("tasks", "WRITE")),
):
"""
@PURPOSE: Delete a persisted dashboard validation report from health summary.
@POST: Validation record is removed; linked task/logs are deleted when present.
"""
if not config_manager.get_config().settings.features.health_monitor:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Health monitor feature is disabled")
service = HealthService(db, config_manager=config_manager)
if not service.delete_validation_report(record_id, task_manager=task_manager):
raise HTTPException(status_code=404, detail="Health report not found")
return
# #endregion delete_health_report
# #endregion health_router