# yaml-language-server: $schema=/Users/george/Documents/GitHub/archon-reference-environment/engine-app/src/ingestor/ArchonYamlSchema.json
general:
  # The name that will show in the dashboard UI
  name: Chat App
  # The identifier from the dashboard, used to identify your code package.
  # This is NOT an API key. You will still need to authenticate with your password and second factor.
  id: 6658066b-eec9-429c-bef3-8f2d368aeb13
policy:
  # These are types of resources your system creates. A resource is anything a user can take an action on.
  resource-types:
    # this is the resource type name
    - resource-type: conversations
      # Will create exactly one of this resource type. You can access singleton resources by
      # using the resource type name and the getResourceType method.
      singleton: true
      # Descriptions are for your (and Archon's) reference. Make sure they are clear and concise.
      description: Collection of all conversations
      intents:
        - intent: list-conversations
          description: List all conversations
        - intent: create-conversation
          description: Create a new conversation
    - resource-type: conversation
      # Conversations must have a parent resource of type conversations
      parent: conversations
      description: A conversation between two or more users
      intents:
        - intent: send-message
          description: Send a message to a conversation
        - intent: read-conversation
          description: Read all messages in a conversation
        - intent: delete-conversation
          description: Delete a conversation
    - resource-type: control-panel
      singleton: true
      description: The control panel for the app
      intents:
        - intent: view-control-panel
          description: View the control panel
  roles:
    - role: conversation-manager
      # If a role is privileged, it requires a user to reauthenticate before taking any actions.
      # Otherwise, the user can take any permitted actions without reauthenticating.
      privileged: true
      description: Can create, read, and delete conversations
      permissions:
        - resource-type: conversation
          intents:
            - send-message
            - delete-conversation
          effect: allow
          conditions:
            # This condition uses the matches operator to compare the user's ID
            # to the creator of the conversation.
            - condition: matches
              first: "{{user.id}}"
              second: "{{resource.metadata.creator}}"

        - resource-type: conversations
          intents:
            - list-conversations
            - create-conversation
          effect: allow

    - role: conversation-reader
      description: Can read conversations
      permissions:
        - resource-type: conversation
          intents:
            - read-conversation
          effect: allow

    - role: application
      description: The role for the monolith app. Grants access to secrets
      permissions:
        - resource-type: archon/configurator/secret
          intents:
            - read-secret
          conditions:
            # gives access to the postgres-one secrets
            - condition: matches
              first: "{{resource.metadata.component-name}}"
              second: postgres-one
          effect: allow
orchestrator:
  components:
    # This is a component that will be created by the orchestrator.
    # The first one here is your app component!
    - component: app
      name: chat-monolith
      roles:
        - application
      options:
        # This is the entrypoint for the app. It will be the first file that is run.
        entrypoint: app.js
        # This is the command to execute tests for the app.
        test: npm test
    # This one is of type database, which means it will be created as a database.
    - component: database
      # The name of the component. This will be used to reference the component in the code.
      name: postgres-one
      # these options are specific to the database component
      options:
        # for instance, the type of database for this component
        type: postgres
    # this component would be an LLM API endpoint
    - component: llm-services
      name: llm-services
      options:
        # in this case, you can choose a model as part of the options
        default-model: claude-3.5-sonnet
