Discovery Precedence Flowchart
This diagram shows how commands are discovered and how command name collisions are handled across sources.
Discovery Flow
Conflict Resolution
When names collide, Invowk handles two different cases:
Resolution Rules
| Case | Behavior |
|---|---|
| Same full command name discovered in multiple sources | First discovered source wins (precedence order) |
| Same simple command name across different sources | Mark ambiguous; user must disambiguate (@source / --ivk-from) |
Discovery precedence order:
- Current directory invowkfile (
./invowkfile.cue) - Local modules (
./*.invowkmod) - Configured includes (module paths from
config.Includes) - Provisioned module entries supplied by the command adapter
- Provisioned global module entries supplied by the command adapter
- User commands directory (
~/.invowk/cmds/*.invowkmod, modules only, non-recursive)
Vendored modules (invowk_modules/) are scanned one level deep for each discovered module source.
The invowkfile of a module directory is always loaded as part of that module. When the current directory is itself a *.invowkmod directory, discovery loads it as that module at level 1, through the same checks as a local module, and skips level 2. A directory whose name ends in .invowkmod is only ever loaded as a module: one that does not load contributes nothing and is reported as a diagnostic. The name is judged as the parent directory stores it, and only the directory's own entry counts: a symbolic link or junction to a module directory is skipped, while a link in an ancestor directory does not matter.
One module directory reached through several sources (the current directory, a local module, an includes entry, a provisioned entry or the user commands directory) is one module. It is loaded once, at the highest-precedence source; it is global when one of its sources is the user commands directory, and it publishes under an includes alias that names it. Two different directories with the same module id still collide.
Module Discovery Details
Required Module Fields
// invowkmod.cue
module: "com.example.mymodule" // RDNS naming convention
version: "1.0.0" // Semantic version
// Optional
description: "My useful module"
requires: [
{
git_url: "https://github.com/org/repo.git"
version: "^1.0.0"
}
]
Dependency Resolution
Transitive Dependency Visibility
This visibility check applies to declared depends_on.cmds dependencies during static validation. It does not intercept arbitrary subprocess calls made at runtime.
| From | Can Access | Cannot Access |
|---|---|---|
| Module A | A's commands, globally installed modules, B's commands | C's commands (transitive) |
| Module B | B's commands, globally installed modules, C's commands | - |
| Root invowkfile | Discoverable commands | Scope restrictions are not applied; failures are discoverability or explicit dependency resolution issues |
Why this restriction?
- Prevents implicit coupling to transitive dependencies
- Makes dependencies explicit in each module
- Enables dependency upgrades without breaking consumers
Includes Configuration
Additional modules are configured in the resolved global config file:
includes: [
{path: "/opt/company-invowk-modules/tools.invowkmod"},
{path: "/home/shared/invowk/shared.invowkmod"},
]
Entry Processing Order
Discovery Caching
Common Discovery Issues
Problem: Command Not Found
Problem: Wrong Command Version
Debug Commands
# List all discovered commands with sources
invowk cmd --ivk-verbose
# Validate workspace discovery (reports all diagnostics)
invowk validate
# Validate a specific module
invowk validate ./mymodule.invowkmod
Related Diagrams
- Command Execution Sequence - What happens after discovery
- Runtime Selection Flowchart - How runtimes are chosen
- C4 Container Diagram - Discovery component context