Skip to content

Implement standardized temporal workflow naming system with namespace support#89

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-73
Draft

Implement standardized temporal workflow naming system with namespace support#89
Copilot wants to merge 3 commits intomainfrom
copilot/fix-73

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 31, 2025

This PR establishes clear standards for temporal workflow naming that supports multiple applications, environments, and namespaces while maintaining backward compatibility.

Problem

The existing temporal workflow naming was hardcoded and inflexible:

def get_id(self, app_env) -> str:
    return f"fcm-{app_env}-{self.__class__.__name__}"

This approach had several limitations:

  • No separation of concerns (org, app, environment, workflow type)
  • Limited flexibility for different applications within the same system
  • No namespace support for logical grouping
  • Hardcoded prefixes with no customization options
  • No clear guidelines or documentation

Solution

Standardized Naming Patterns

  • Workflow ID: {org}-{app}-{env}-{namespace}-{workflow_name}
  • Schedule ID: schedule-{org}-{app}-{env}-{namespace}-{workflow_name}
  • Queue Name: {org}-{app}-{env}-{queue_name}

Key Features

1. Flexible Configuration

# Initialize naming system
init_naming_config(org="whale-net", app="slack-bot", env="prod")

# Create workflow with namespace
class SlackUserInfoWorkflow(AbstractScheduleWorkflow):
    def __init__(self):
        super().__init__(namespace="slack")
    
    # Results in ID: whale-net-slack-bot-prod-slack-slack-user-info

2. Auto-generated Workflow Names

  • SlackUserInfoWorkflowslack-user-info
  • AIGeminiResponseWorkflowai-gemini-response
  • DataMigrationWorkflowdata-migration

3. Custom Naming Support

class NotificationWorkflow(AbstractScheduleWorkflow):
    def get_workflow_name(self) -> str:
        return "email-notifications"  # Custom name

4. Namespace-based Organization

# Different namespaces for logical grouping
slack_workflow = SlackUserInfoWorkflow()  # namespace="slack"
ai_workflow = GeminiWorkflow()            # namespace="ai" 
db_workflow = MigrationWorkflow()         # namespace="db"

5. Comprehensive Validation

  • Validates temporal naming rules (alphanumeric + hyphens/underscores)
  • Clear error messages for invalid configurations
  • Environment requirement enforcement

Backward Compatibility

The system gracefully falls back to legacy naming when the new configuration isn't initialized:

def get_id(self, app_env: str) -> str:
    try:
        # Try new naming system
        naming = self.get_naming()
        return naming.get_workflow_id(self.get_workflow_name())
    except RuntimeError:
        # Fall back to legacy naming with warning
        return f"fcm-{app_env}-{self.__class__.__name__}"

Documentation and Examples

  • Comprehensive guidelines: docs/temporal-workflow-naming.md
  • Working examples: examples/temporal_naming_example.py
  • Migration guide from legacy system
  • Best practices and troubleshooting

CLI Integration

Enhanced temporal setup with naming parameters:

# Environment variables
TEMPORAL_ORG=whale-net
TEMPORAL_APP=slack-bot
APP_ENV=prod

Testing

  • Complete unit test suite covering all functionality
  • Validation tests for edge cases and error conditions
  • Integration tests with workflow base classes
  • Verified working examples and documentation

Migration Path

  1. Initialize naming configuration during application startup
  2. Update workflow constructors to specify namespaces (optional)
  3. Customize workflow names if needed (optional)
  4. Existing workflows continue working with legacy fallback

This implementation provides the standardized, flexible naming system requested while ensuring no breaking changes to existing functionality.

Fixes #73.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2025

Codecov Report

Attention: Patch coverage is 77.77778% with 32 lines in your changes missing coverage. Please review.

Project coverage is 38.37%. Comparing base (10de6eb) to head (678e6ed).

Files with missing lines Patch % Lines
src/friendly_computing_machine/temporal/base.py 62.50% 11 Missing and 1 partial ⚠️
src/friendly_computing_machine/temporal/util.py 41.17% 10 Missing ⚠️
src/friendly_computing_machine/temporal/naming.py 95.00% 2 Missing and 2 partials ⚠️
...endly_computing_machine/temporal/slack/workflow.py 50.00% 4 Missing ⚠️
...friendly_computing_machine/cli/context/temporal.py 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #89      +/-   ##
==========================================
+ Coverage   36.20%   38.37%   +2.16%     
==========================================
  Files          66       67       +1     
  Lines        2563     2692     +129     
  Branches      167      182      +15     
==========================================
+ Hits          928     1033     +105     
- Misses       1624     1645      +21     
- Partials       11       14       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI and others added 2 commits May 31, 2025 21:14
Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Copilot AI changed the title [WIP] improve temporal workflow naming and such Implement standardized temporal workflow naming system with namespace support May 31, 2025
Copilot AI requested a review from QMasterMoo May 31, 2025 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

improve temporal workflow naming and such

2 participants