π Issue Type
Documentation / Architecture
π― Objective
Create comprehensive STATEDIAGRAM.md documenting state transitions, lifecycles, and state management for riksdagsmonitor's workflows, articles, and dashboards.
π Current State
β STATEDIAGRAM.md does not exist
β οΈ Article lifecycle states undocumented
β οΈ Workflow state transitions implicit
β οΈ Dashboard states not formally defined
β οΈ PR review states scattered
Existing Related Docs:
β
ARCHITECTURE.md (system architecture)
β
WORKFLOWS.md (GitHub Actions)
β
THREAT_MODEL.md (security states)
π Desired State
Comprehensive STATEDIAGRAM.md including:
1. News Article Lifecycle States
DRAFT β TRANSLATION β VALIDATION β REVIEW β APPROVED β PUBLISHED
β β β β β β
ERROR β TRANSLATION_FAILED β VALIDATION_FAILED β REJECTED β ROLLBACK
States:
DRAFT - Article generated by Copilot agent, Swedish content only
TRANSLATION - Multi-language translation in progress (12 additional languages)
VALIDATION - scripts/validate-news-translations.js checking data-translate markers
REVIEW - Human review in pull request
APPROVED - PR approved, awaiting merge
PUBLISHED - Merged to main, deployed to production
ERROR - Failure state requiring intervention
2. Agentic Workflow States
GitHub Actions Workflow:
QUEUED β RUNNING β GENERATING β TRANSLATING β VALIDATING β
SUCCESS/FAILURE β PR_CREATED β PR_REVIEW β MERGED/CLOSED
States:
QUEUED - Workflow scheduled, awaiting runner
RUNNING - Copilot agent active
GENERATING - Article content generation from riksdag-regering-mcp
TRANSLATING - Multi-language translation (14 languages)
VALIDATING - Playwright validation, translation checks
SUCCESS - All checks passed
FAILURE - Workflow failed (hallucination, translation error, validation failure)
PR_CREATED - Pull request opened
PR_REVIEW - Human review in progress
MERGED - Changes deployed
CLOSED - PR rejected or cancelled
3. Dashboard Data States
LocalStorage Caching:
EMPTY β FETCHING β CACHED β STALE β REFRESHING β CACHED
β β β β β β
ERROR β FETCH_FAILED β βββ β βββ β REFRESH_FAILED β βββ
States:
EMPTY - No cached data, initial load
FETCHING - Requesting data from GitHub CDN
CACHED - Valid cached data (< freshness threshold)
STALE - Cached data expired (> freshness threshold)
REFRESHING - Background refresh in progress
ERROR - Fetch/refresh failed, fallback to stale cache
Freshness Thresholds:
Production stats: 24 hours
Seasonal patterns: 7 days
Politician data: 24 hours
Party performance: 7 days
4. Pull Request Review States
OPEN β CI_RUNNING β CI_PASSED β REVIEW_REQUESTED β
APPROVED β MERGE_READY β MERGED β DEPLOYED
β β β β β
DRAFT β CI_FAILED β CHANGES_REQUESTED β REVIEW_DISMISSED β CLOSED
States:
OPEN - PR created, awaiting CI
DRAFT - Work-in-progress, not ready for review
CI_RUNNING - Quality checks executing
CI_PASSED - All checks passed
CI_FAILED - Quality gate failed (HTML validation, link check, tests)
REVIEW_REQUESTED - Assigned to reviewer
CHANGES_REQUESTED - Feedback provided, changes needed
APPROVED - Approved by reviewer
REVIEW_DISMISSED - Previous approval dismissed
MERGE_READY - All requirements met
MERGED - Changes merged to main
CLOSED - PR closed without merge
DEPLOYED - Changes live in production
5. CI/CD Pipeline States
Deployment Pipeline:
COMMIT β BUILD β TEST β SCAN β DEPLOY_STAGING β
HEALTH_CHECK β DEPLOY_PRODUCTION β MONITOR
β β β β β β
ROLLBACK β βββ β FAILED β VULNERABLE β UNHEALTHY β ERRORS_DETECTED
States:
COMMIT - Code pushed to repository
BUILD - Vite build executing
TEST - Unit tests (Vitest) and E2E tests (Cypress)
SCAN - Security scanning (CodeQL, Dependabot, Secret Scanning)
FAILED - Build/test/scan failure
VULNERABLE - Security vulnerability detected
DEPLOY_STAGING - Deploying to preview environment
HEALTH_CHECK - Smoke tests on staging
UNHEALTHY - Health check failed
DEPLOY_PRODUCTION - Deploying to GitHub Pages + AWS CloudFront
MONITOR - Production monitoring active
ERRORS_DETECTED - Production errors detected
ROLLBACK - Reverting to previous version
6. Translation Validation States
UNTRANSLATED β MARKED β TRANSLATING β TRANSLATED β VALIDATED β PUBLISHED
β β β β β β
SKIP β ββββββββ β FAILED β RETRYING β INVALID β ββββββββ β ROLLBACK
States:
UNTRANSLATED - Swedish API content not yet translated
MARKED - data-translate="true" lang="sv" markers added
TRANSLATING - Agentic translation in progress
TRANSLATED - All languages completed
VALIDATED - scripts/validate-news-translations.js passed (exit 0)
INVALID - Validation failed (remaining markers detected, exit 1)
FAILED - Translation error (hallucination, context loss)
RETRYING - Retry translation attempt
PUBLISHED - Clean translated content live
ROLLBACK - Revert to previous version
π€ AI Policy Compliance Context
Per Hack23 AI Policy:
Agentic Workflow States must include AI-specific states (GENERATING, HALLUCINATION_DETECTED)
Error States must capture AI failures (prompt injection, data poisoning)
Human Oversight States required for Limited Risk AI systems (REVIEW, APPROVED)
Audit States for compliance (LOGGED, MONITORED)
π§ Implementation Approach
1. Mermaid State Diagrams
Create detailed Mermaid state diagrams:
stateDiagram-v2
[*] --> Draft
Draft --> Translation
Translation --> Validation
Translation --> TranslationFailed
Validation --> Review
Validation --> ValidationFailed
Review --> Approved
Review --> Rejected
Approved --> Published
Published --> [*]
TranslationFailed --> Draft
ValidationFailed --> Draft
Rejected --> Draft
Loading
2. State Transition Tables
For each state diagram:
From State | Event | To State | Conditions | Actions
Example: DRAFT | translate_complete | TRANSLATION | all_languages_done | validate()
3. State Invariants
Document state invariants:
PUBLISHED β Cannot transition back to DRAFT (immutable)
CI_FAILED β Cannot transition to DEPLOY (must fix first)
UNTRANSLATED β Cannot transition to PUBLISHED (blocking)
4. Error State Handling
For each error state:
Detection - How error is detected
Recovery - Automatic or manual recovery
Retry Logic - Exponential backoff, max attempts
Notification - GitHub issue, Slack alert, email
5. State Metrics
Time in State - Average duration
State Transitions - Frequency matrix
Error Rates - Failed transitions percentage
Bottlenecks - States with long durations
π References
Repository:
CIA References:
ISMS Policies:
β
Acceptance Criteria
π€ Recommended Agent
documentation-architect - Specialized in Mermaid state diagrams, lifecycle documentation, and workflow state management
π·οΈ Labels
type:documentation, priority:high, component:architecture, component:workflow, component:ai-workflows, isms, agent:documentation-architect
π Issue Type
Documentation / Architecture
π― Objective
Create comprehensive STATEDIAGRAM.md documenting state transitions, lifecycles, and state management for riksdagsmonitor's workflows, articles, and dashboards.
π Current State
Existing Related Docs:
π Desired State
Comprehensive STATEDIAGRAM.md including:
1. News Article Lifecycle States
States:
2. Agentic Workflow States
GitHub Actions Workflow:
States:
3. Dashboard Data States
LocalStorage Caching:
States:
Freshness Thresholds:
4. Pull Request Review States
States:
5. CI/CD Pipeline States
Deployment Pipeline:
States:
6. Translation Validation States
States:
π€ AI Policy Compliance Context
Per Hack23 AI Policy:
π§ Implementation Approach
1. Mermaid State Diagrams
Create detailed Mermaid state diagrams:
stateDiagram-v2 [*] --> Draft Draft --> Translation Translation --> Validation Translation --> TranslationFailed Validation --> Review Validation --> ValidationFailed Review --> Approved Review --> Rejected Approved --> Published Published --> [*] TranslationFailed --> Draft ValidationFailed --> Draft Rejected --> Draft2. State Transition Tables
For each state diagram:
3. State Invariants
Document state invariants:
4. Error State Handling
For each error state:
5. State Metrics
π References
Repository:
CIA References:
ISMS Policies:
β Acceptance Criteria
π€ Recommended Agent
documentation-architect - Specialized in Mermaid state diagrams, lifecycle documentation, and workflow state management
π·οΈ Labels
type:documentation,priority:high,component:architecture,component:workflow,component:ai-workflows,isms,agent:documentation-architect