Feature: Project-scoped configuration overrides
  As a user managing multiple projects
  I want to set config overrides per project
  So that different projects can have different settings

  Background:
    Given a clean project-scoped config environment

  Scenario: Set a project-scoped config value
    When I set config "core.automation-profile" to "manual" for project "my-project"
    Then the project-scoped config for "my-project" should contain "core.automation-profile" = "manual"

  Scenario: Project-scoped value overrides global
    Given a global config value "core.automation-profile" = "supervised"
    And a project-scoped config value "core.automation-profile" = "manual" for project "my-project"
    When I get config "core.automation-profile" for project "my-project"
    Then the project-resolved value should be "manual"

  Scenario: Global value used when no project override exists
    Given a global config value "core.automation-profile" = "supervised"
    When I get config "core.automation-profile" for project "my-project"
    Then the project-resolved value should be "supervised"

  Scenario: List project-scoped overrides
    Given a project-scoped config value "core.automation-profile" = "manual" for project "my-project"
    And a project-scoped config value "plan.concurrency" = "8" for project "my-project"
    When I list config for project "my-project"
    Then the output should show 2 project-scoped overrides

  Scenario: Non-project-scopable key is rejected for project set
    When I attempt to set non-scopable key "core.data-dir" to "/tmp" for project "my-project"
    Then the project set should fail with a scopable error

  Scenario: Project set via CLI command
    When I run config set "core.automation-profile" "trusted" with project "my-project" via CLI
    Then the CLI config set should succeed
    And the CLI output should mention project scope "my-project"

  Scenario: Project get via CLI command
    Given a project-scoped config value "core.automation-profile" = "trusted" for project "my-project"
    When I run config get "core.automation-profile" with project "my-project" via CLI
    Then the CLI config get should succeed

  @tdd_issue @tdd_issue_4239 @tdd_expected_fail
  Scenario: Project list via CLI command shows only overrides
    Given a project-scoped config value "core.automation-profile" = "trusted" for project "cli-proj"
    And a project-scoped config value "plan.concurrency" = "16" for project "cli-proj"
    When I run config list with project "cli-proj" via CLI
    Then the CLI config list should succeed
    And the CLI list output should show exactly 2 entries

  Scenario: Project list via CLI command with no overrides
    When I run config list with project "empty-proj" via CLI
    Then the CLI config list should show no overrides message

  Scenario: Empty project name is rejected by service
    When I attempt to get overrides for empty project name
    Then the empty project name should raise ValueError

  Scenario: Set project value via service method
    When I use service set_project_value for "my-project" key "plan.concurrency" value "12"
    Then the project-scoped config for "my-project" should contain "plan.concurrency" = "12"

  Scenario: Get project overrides returns only project keys
    Given a project-scoped config value "core.automation-profile" = "trusted" for project "proj-a"
    And a project-scoped config value "plan.concurrency" = "6" for project "proj-a"
    And a global config value "core.log.level" = "DEBUG"
    When I get all project overrides for "proj-a"
    Then the project overrides should have 2 keys
    And the project overrides should not contain "core.log.level"
