/gitlab-auto-sync

GitLab L2+ Production medium usage

/gitlab-auto-sync

Overview

/gitlab-auto-sync is a production command in the GitLab category of the Prismatic Platform that provides automatic bidirectional synchronization between the platform's AIAD workflow system and GitLab project management. When enabled, this command ensures that every AIAD workflow action -- agent deployments, command executions, quality gate results, and evolution cycles -- is automatically reflected in GitLab issues, milestones, labels, and merge requests without manual intervention.

This command operates under the L2+ authority level and is executed by the gitlab-auto-sync-orchestrator agent. It is part of the platform's 216-command slash command registry, built on the AIAD (Autonomous Intelligence Agent Design) standard. The automatic synchronization eliminates the manual overhead of updating GitLab project state to reflect development activities, ensuring that the GitLab project always accurately represents the current state of platform development.

The synchronization is bidirectional: changes in GitLab (new issues, label changes, milestone updates) can trigger AIAD workflow actions, and AIAD workflow events automatically create or update GitLab resources. This tight coupling ensures that the GitLab project serves as a reliable single source of truth for project status, even when most development activities are driven by AIAD agents and slash commands.

Architecture

The auto-sync system operates as a continuous synchronization engine with event-driven triggers and conflict resolution.

Synchronization Architecture

AIAD Events ----+                              +---- GitLab Webhooks
                |                              |
                v                              v
        Event Collector <-- Conflict Resolver --> Event Collector
                |                |                    |
                v                v                    v
        Transform Engine    State Store         Transform Engine
                |           (ETS + Disk)              |
                v                                     v
        GitLab API Client                    AIAD Command Dispatcher
                |                                     |
                v                                     v
        GitLab Project                         AIAD Workflows

Event Types

DirectionEventAIAD TriggerGitLab Action
AIAD -> GitLabSession startSession lifecycle hookCreate/update issue
AIAD -> GitLabQuality gate resultQuality gate executionUpdate issue labels
AIAD -> GitLabEvolution cycleAutoevolve completionUpdate milestone progress
AIAD -> GitLabAgent deploymentAgent specification changeCreate merge request
AIAD -> GitLabCommand executionSlash command invocationAdd issue comment
GitLab -> AIADIssue createdNew GitLab issueCreate AIAD task
GitLab -> AIADLabel changedIssue label modificationTrigger workflow
GitLab -> AIADMilestone updatedMilestone due date changeUpdate priority

Sync State Management

The synchronization state is maintained in an ETS table with disk persistence to ensure consistency across sessions and recover from interruptions.

State ComponentStoragePurpose
Sync cursorETS + diskLast synced event timestamp per direction
Resource mappingETS + diskAIAD entity to GitLab resource ID mappings
Conflict logDiskRecord of detected and resolved conflicts
QueueETSPending sync events awaiting processing

Usage

# Enable automatic synchronization
/gitlab-auto-sync enable

# Disable automatic synchronization
/gitlab-auto-sync disable

# Check synchronization status
/gitlab-auto-sync status

# Force full synchronization
/gitlab-auto-sync force-sync

# Sync specific entity type
/gitlab-auto-sync sync --type=issues
/gitlab-auto-sync sync --type=milestones
/gitlab-auto-sync sync --type=labels

# View sync history
/gitlab-auto-sync history --limit=20

# Resolve sync conflicts
/gitlab-auto-sync conflicts --resolve

# Configure sync rules
/gitlab-auto-sync configure --auto-issue=true --auto-label=true

# Test sync connectivity
/gitlab-auto-sync test

# Reset sync state (caution: re-syncs everything)
/gitlab-auto-sync reset

Options

OptionTypeDefaultDescription
actionstringstatusAction: enable, disable, status, force-sync, sync, history, conflicts, configure, test, reset
--typestringallEntity type filter: issues, milestones, labels, mrs, all
--limitinteger10Number of history entries to display
--resolveflagfalseAuto-resolve detected conflicts
--auto-issuebooleantrueAutomatically create issues for sessions
--auto-labelbooleantrueAutomatically sync labels from AIAD
--auto-milestonebooleantrueSync milestones with AIAD phases
--auto-commentbooleanfalseAdd comments for command executions
--formatstringtextOutput format: text, json
--dry-runflagfalseShow what would be synced without executing
--verboseflagfalseShow detailed sync operation logs

Execution Flow

  1. Configuration Loading: Sync configuration is loaded from .aiad/config/gitlab-sync.yaml and environment variables (GITLAB_TOKEN, GITLAB_PROJECT_ID).

  2. Connectivity Verification: The GitLab API connection is verified and the project access level is confirmed. The command requires at least Developer access for full sync functionality.

  3. State Recovery: The sync state is loaded from ETS/disk. If no previous state exists (first run or after reset), a full initial sync is performed.

  4. Event Collection: Pending events from both AIAD and GitLab are collected. AIAD events are gathered from the telemetry event stream; GitLab events are fetched via the API since the last sync cursor.

  5. Conflict Detection: Events that modify the same resource from both directions are identified as potential conflicts. The conflict resolver applies configurable rules (last-write-wins, AIAD-priority, or manual resolution).

  6. Transform and Apply: Non-conflicting events are transformed into their target format and applied. AIAD events become GitLab API calls; GitLab events become AIAD command dispatches.

  7. State Update: Successful sync operations update the sync cursor and resource mappings. Failed operations are queued for retry.

  8. Status Report: A summary of the sync operation is displayed, including events processed, conflicts detected, and any failures requiring attention.

Integration Points

ComponentRelationshipDetails
Prismatic AgentsExecuted by gitlab-auto-sync-orchestratorManages bidirectional sync
/gitlab-apiAPI backendAll GitLab operations go through the API client
/gitlab-ciPipeline syncPipeline status reflected in sync state
/gitlab-enforceComplianceEnforcement actions synced to GitLab
Session LifecycleSession trackingSession start/end creates/updates issues
Quality GatesQuality syncGate results synced as issue labels
TelemetryEvent sourceAIAD events collected from telemetry stream
AIAD RegistryEntity mappingAIAD entities mapped to GitLab resources

Best Practices

Enable auto-sync from the start. Enabling synchronization at the beginning of a project ensures complete traceability from day one. Retroactive synchronization is possible but produces a flood of catch-up events.

Configure comment verbosity carefully. Setting --auto-comment=true provides detailed command-level tracking but can generate high volumes of issue comments. Enable it for critical issues and milestones, disable it for routine development.

Review conflicts promptly. Sync conflicts indicate that the same resource was modified independently in both AIAD and GitLab. Unresolved conflicts can cause state divergence that becomes increasingly difficult to reconcile.

Use dry-run for major operations. Before running force-sync or reset, use --dry-run to preview what would happen. Force-sync on a large project can generate hundreds of API calls.

Monitor sync lag. The status action shows the time since the last successful sync. If sync lag exceeds a few minutes during active development, investigate potential connectivity or rate limit issues.

Error Handling

ErrorCauseResolution
gitlab_auth_failureInvalid or expired GITLAB_TOKENRegenerate token with appropriate scopes
project_access_deniedInsufficient project permissionsRequest Developer or Maintainer access
sync_conflictSame resource modified in both directionsUse conflicts --resolve or resolve manually
rate_limit_exceededToo many API calls in short periodSync will auto-retry after rate limit reset
state_corruptionETS table or disk state inconsistentUse reset to rebuild sync state from scratch
webhook_delivery_failedGitLab webhook cannot reach platformVerify webhook URL and network connectivity
transform_errorEvent cannot be mapped to target formatCheck sync configuration and entity mappings

Advanced Usage

Custom Sync Rules

Define custom synchronization rules for specific event types.

# .aiad/config/gitlab-sync.yaml
rules:
  - event: quality_gate_failed
    action: create_issue
    labels: ["quality-regression", "P1"]
    assignee: "quality-lead"
    milestone: "current"

  - event: agent_deployed
    action: add_comment
    template: "Agent {{agent_name}} deployed at {{timestamp}}"

  - event: evolution_cycle_complete
    action: update_milestone
    progress_field: "evolution_fitness"

Webhook Configuration

Set up GitLab webhooks for real-time bidirectional sync.

# Configure webhook for instant sync (vs polling)
/gitlab-auto-sync configure --webhook-url="https://platform.example.com/webhooks/gitlab"
/gitlab-auto-sync configure --webhook-events="issues,merge_requests,pipelines"

Selective Sync

Sync only specific milestones or label groups.

# Sync only P0 issues
/gitlab-auto-sync sync --type=issues --filter="labels:P0"

# Sync only active milestones
/gitlab-auto-sync sync --type=milestones --filter="state:active"

Doctrine Compliance

All commands operate under the NO MERCY, NO DOUBTS doctrine:

  • NO MERCY: Zero tolerance for incomplete execution or quality violations. Every AIAD action is reflected in GitLab; no development activity goes untracked.
  • NO DOUBTS: Full investigation before action, evidence-based results. Sync state is verified before every operation. Conflicts are detected and resolved rather than silently ignored.
  • /gitlab-api - GitLab API operations for project and repository management
  • /gitlab-ci - GitLab CI/CD pipeline management and configuration
  • /gitlab-enforce - GitLab enforcement for compliance and workflow standards
  • /cicd-unified - Unified CI/CD workflow actions for pipeline management
  • /commit - Smart commit with quality gates and conventional format
  • /agents - List and manage agent ecosystem with status monitoring

Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL