126 lines
6.5 KiB
Gherkin
126 lines
6.5 KiB
Gherkin
@phase1 @domain @tool_binding
|
|
Feature: Tool Resource Binding Resolution
|
|
As a system activating a tool within a plan
|
|
I want resource slots to be resolved to concrete resources
|
|
So that the tool has access to the correct resources at runtime
|
|
|
|
Background:
|
|
Given a mock resource registry
|
|
And a binding resolution service using the registry
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Contextual binding -- single match (auto-bind)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@contextual @single_match
|
|
Scenario: Contextual binding with single matching resource
|
|
Given a project "local/my-project" with a linked resource:
|
|
| resource_id | type_name | alias |
|
|
| 01HGZ6FE0AQDYTR4BX00000001 | git-checkout | repo |
|
|
And a tool "local/reader" with a contextual slot "repo" of type "git-checkout"
|
|
When the bindings are resolved
|
|
Then the binding for slot "repo" should have mode "contextual"
|
|
And the binding for slot "repo" should have resource_id "01HGZ6FE0AQDYTR4BX00000001"
|
|
And the binding for slot "repo" should not be deferred
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Contextual binding -- multiple matches with alias hint
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@contextual @alias_hint
|
|
Scenario: Contextual binding with multiple matches uses alias hint
|
|
Given a project "local/multi" with linked resources:
|
|
| resource_id | type_name | alias |
|
|
| 01HGZ6FE0AQDYTR4BX00000010 | git-checkout | repo |
|
|
| 01HGZ6FE0AQDYTR4BX00000011 | git-checkout | backup |
|
|
And a tool "local/reader" with a contextual slot "repo" of type "git-checkout"
|
|
When the bindings are resolved
|
|
Then the binding for slot "repo" should have resource_id "01HGZ6FE0AQDYTR4BX00000010"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Contextual binding -- no match (error)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@contextual @no_match @error_handling
|
|
Scenario: Contextual binding with no matching resource raises error
|
|
Given a project "local/empty" with no linked resources
|
|
And a tool "local/reader" with a contextual slot "repo" of type "git-checkout"
|
|
When the binding resolution is attempted
|
|
Then a binding ValidationError should be raised mentioning "No resource of type"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Static binding resolution
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@static
|
|
Scenario: Static binding resolves named resource
|
|
Given a resource "local/shared-config" of type "fs-directory" in the registry
|
|
And a tool "local/deployer" with a static slot "config_dir" bound to "local/shared-config" of type "fs-directory"
|
|
And a project "local/proj" with no linked resources
|
|
When the bindings are resolved
|
|
Then the binding for slot "config_dir" should have mode "static"
|
|
And the binding for slot "config_dir" should have resource_id "01HGZ6FE0AQDYTR4BX00000020"
|
|
And the binding for slot "config_dir" should not be deferred
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Parameter binding (deferred)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@parameter @deferred
|
|
Scenario: Parameter binding is deferred when no invocation params given
|
|
Given a tool "local/builder" with a parameter slot "target" of type "fs-directory"
|
|
And a project "local/proj" with no linked resources
|
|
When the bindings are resolved
|
|
Then the binding for slot "target" should have mode "parameter"
|
|
And the binding for slot "target" should be deferred
|
|
And the binding for slot "target" should have no resource_id
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Type compatibility -- pass (sub-type)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@type_compat @pass
|
|
Scenario: Type compatibility passes for sub-type via parent_types
|
|
Given a project "local/typed" with a linked resource:
|
|
| resource_id | type_name | alias |
|
|
| 01HGZ6FE0AQDYTR4BX00000030 | fs-directory | repo |
|
|
And the resource type "fs-directory" has parent_types including "git-checkout"
|
|
And a tool "local/compat" with a contextual slot "repo" of type "git-checkout"
|
|
When the bindings are resolved
|
|
Then the binding for slot "repo" should have resource_id "01HGZ6FE0AQDYTR4BX00000030"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Type compatibility -- fail
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@type_compat @fail @error_handling
|
|
Scenario: Type compatibility fails for incompatible types
|
|
Given a resource "local/wrong-type" of type "fs-file" in the registry
|
|
And the resource type "fs-file" has no parent_types
|
|
And a tool "local/strict" with a static slot "data" bound to "local/wrong-type" of type "git-checkout"
|
|
And a project "local/proj" with no linked resources
|
|
When the binding resolution is attempted
|
|
Then a binding ValidationError should be raised mentioning "Type mismatch"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Mixed bindings on same tool
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@mixed
|
|
Scenario: Mixed bindings on same tool resolve correctly
|
|
Given a project "local/mixed" with a linked resource:
|
|
| resource_id | type_name | alias |
|
|
| 01HGZ6FE0AQDYTR4BX00000040 | git-checkout | repo |
|
|
And a resource "local/shared-config" of type "fs-directory" in the registry
|
|
And a tool "local/multi-bind" with mixed slots:
|
|
| name | resource_type | binding | static_resource |
|
|
| repo | git-checkout | contextual | |
|
|
| config | fs-directory | static | local/shared-config |
|
|
| output | fs-directory | parameter | |
|
|
When the bindings are resolved
|
|
Then there should be 3 binding results
|
|
And the binding for slot "repo" should have mode "contextual"
|
|
And the binding for slot "config" should have mode "static"
|
|
And the binding for slot "output" should have mode "parameter"
|
|
And the binding for slot "output" should be deferred
|