{
  "repo": "tidbcloud/escalation-base",
  "binary": "autoshift-server",
  "binary_path": "support-autoshift/cmd/autoshift-server/main.go",
  "notes": [
    "Fresh codex rescan rebuilt autoshift-server as a background worker binary. There is no network ingress; the important runtime surface is the periodic Jira role-sync loop and its config-derived conditions."
  ],
  "dependencies": {
    "AutoshiftLifecycle.LoadConfig": {
      "infrastructure": {
        "filesystem": {
          "conditions": [
            "Always"
          ],
          "operations": [
            {
              "operation": "READ CONFIG",
              "paths": [
                "--config supplied root config path"
              ],
              "conditions": [
                "Always"
              ],
              "implementation": "config.InitConfig(flagConfig)"
            }
          ]
        }
      },
      "services": []
    },
    "AutoshiftLifecycle.SetupDeps": {
      "infrastructure": {},
      "services": [
        {
          "name": "jira",
          "target_interface": "Instantiate Jira client per configured project",
          "operation_type": "client_init",
          "conditions": [
            "For each configured jiraProjects entry"
          ],
          "implementation": "jiracli_manager.NewJiraCliManager"
        },
        {
          "name": "local:AutoshiftService",
          "target_interface": "Parse shifts, roles, timezone",
          "operation_type": "local_call",
          "conditions": [
            "Always"
          ],
          "implementation": "shift_manager.NewShiftManager + autoshift.NewService"
        }
      ]
    },
    "AutoshiftLifecycle.RunServices": {
      "infrastructure": {},
      "services": [
        {
          "name": "local:AutoshiftService",
          "target_interface": "AutoshiftService.Run",
          "operation_type": "local_call",
          "conditions": [
            "Always"
          ],
          "implementation": "service.Manager.RunServices"
        }
      ]
    },
    "AutoshiftLifecycle.StopServices": {
      "infrastructure": {},
      "services": []
    },
    "AutoshiftService.Run": {
      "infrastructure": {
        "time": {
          "conditions": [
            "Always"
          ],
          "operations": [
            {
              "operation": "WAIT",
              "duration": "SyncIntervalMinutes",
              "conditions": [
                "Between each sync cycle"
              ],
              "implementation": "time.NewTimer + Reset"
            }
          ]
        }
      },
      "services": [
        {
          "name": "local:AutoshiftService",
          "target_interface": "AutoshiftService.SyncShifts",
          "operation_type": "local_call",
          "conditions": [
            "Every SyncIntervalMinutes tick"
          ],
          "implementation": "autoshift_service.Run"
        }
      ]
    },
    "AutoshiftService.SyncShifts": {
      "infrastructure": {
        "time": {
          "conditions": [
            "Always"
          ],
          "operations": [
            {
              "operation": "SLEEP",
              "duration": "1s",
              "conditions": [
                "After GetRoleActors succeeds"
              ],
              "implementation": "time.Sleep(time.Second)"
            },
            {
              "operation": "SLEEP",
              "duration": "1s",
              "conditions": [
                "After UpdateRoleActors succeeds"
              ],
              "implementation": "time.Sleep(time.Second)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "local:shift-manager",
          "target_interface": "GetInUseRoles, GetShiftsAtSpecificTime, GetShiftsByEmail",
          "operation_type": "local_call",
          "conditions": [
            "Always"
          ],
          "implementation": "autoshift_service.syncShifts"
        },
        {
          "name": "jira",
          "target_interface": "GetRoleActors",
          "operation_type": "http_get",
          "conditions": [
            "For each configured role returned by GetInUseRoles"
          ],
          "implementation": "jiracli.GetRoleActors"
        },
        {
          "name": "jira",
          "target_interface": "UpdateRoleActors",
          "operation_type": "http_put",
          "conditions": [
            "For each configured role after newEmails has been rebuilt",
            "Existing emails outside the managed shift scope are preserved",
            "Current shift emails are appended only when shift.RoleUniqueIDs contains role.RoleUniqueID"
          ],
          "implementation": "jiracli.UpdateRoleActors"
        }
      ]
    }
  }
}
