Skip to main content
Version: 0.18.0

Discovery Precedence Flowchart

This diagram shows how commands are discovered and how command name collisions are handled across sources.

Discovery Flow​

Diagram: architecture/discovery-flow

Conflict Resolution​

When names collide, Invowk handles two different cases:

Diagram: architecture/discovery-conflict

Resolution Rules​

CaseBehavior
Same full command name discovered in multiple sourcesFirst discovered source wins (precedence order)
Same simple command name across different sourcesMark ambiguous; user must disambiguate (@source / --ivk-from)

Discovery precedence order:

  1. Current directory invowkfile (./invowkfile.cue)
  2. Local modules (./*.invowkmod)
  3. Configured includes (module paths from config.Includes)
  4. Provisioned module entries supplied by the command adapter
  5. Provisioned global module entries supplied by the command adapter
  6. 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​

Diagram: architecture/discovery-module-structure

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​

Diagram: architecture/discovery-deps

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.

FromCan AccessCannot Access
Module AA's commands, globally installed modules, B's commandsC's commands (transitive)
Module BB's commands, globally installed modules, C's commands-
Root invowkfileDiscoverable commandsScope 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​

Diagram: architecture/discovery-includes

Discovery Caching​

Diagram: architecture/discovery-cache

Common Discovery Issues​

Problem: Command Not Found​

Diagram: architecture/discovery-not-found

Problem: Wrong Command Version​

Diagram: architecture/discovery-wrong-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