ADR-0006: Extension descriptor and KCL
Status: Accepted — 2026-09-23. The project owner approved this decision. Acceptance establishes the architectural contract; it does not establish a completed implementation or successful execution of outstanding checks.
English | Русский
Refinement — 2026-09-24: shared CLI/MCP and agent-use additions are accepted under ADR-0013 and ADR-0014–0016. The original acceptance date and historical evidence remain unchanged; the new requirements are not claimed implemented or verified.
Context and problem
Section titled “Context and problem”The core needs command routes, base help, execution requirements and requested rights before it can run an extension. Those facts must remain consistent across the loader, executor and Security Broker boundary. Authors use KCL, but installing a CLI extension must not require evaluating publisher-supplied configuration code on the user’s machine.
This ADR defines the descriptor’s logical schema and validation boundaries. The release container belongs to ADR-0007, environment resolution to ADR-0008. ADR-0005–0008 are accepted; their implementation evidence is recorded separately.
Decision drivers
Section titled “Decision drivers”- Inspect commands and requirements without extension code or runtime preparation.
- Preserve stable command identity, typed inputs and separate help permissions from ADR-0002.
- Keep author requests separate from CLI owner configuration and granted rights.
- Evolve the declaration without silently ignoring execution or security requirements.
Considered options
Section titled “Considered options”| Option | Benefit | Limitation |
|---|---|---|
| Execute an extension to discover its commands | Arbitrary author logic | Requires code execution before compatibility and access checks |
| Evaluate KCL on each client | One authoring format everywhere | Adds an evaluator and publisher-controlled build inputs to installation |
| Compile KCL into a validated static descriptor | No extension code for inspection; independent client validation | Requires a versioned exported schema and semantic validator |
Decision
Section titled “Decision”Authors write KCL; the publisher exports a bounded UTF-8 JSON descriptor. The core consumes and independently validates that descriptor. KCL is an authoring tool, not a runtime dependency or proof of trust. Schema types and checks assist authors; they do not replace client checks. KCL schemas.
Separate documents and authority
Section titled “Separate documents and authority”Catalogs, groups and access rules are owner-controlled configuration under ADR-0009, not part of an extension’s authority. They use separate schemas and may be authored directly as JSON or exported from KCL. Choosing KCL for extension authoring does not require KCL, sign-in or a permission service on the user’s machine.
| Document | Contents and authority |
|---|---|
| Extension descriptor | Publisher’s identity claim, command declarations, execution/runtime requirements and requested core operations; cannot register trusted providers or grant rights |
| CLI owner profile | Built-in commands, allowed mounts and sources, provider registrations, runtime catalog and access-domain bindings |
| Release envelope | Binds the exact descriptor bytes and target payloads to one verified release, under ADR-0007 |
| Local resolution record | Selected release, target and environment identities; machine-specific paths are separate from portable identity |
The publisher pins the KCL compiler, schema package, imports and build inputs and records them as provenance. Secret values and user-specific identity do not belong in published output. Reproducibility must be checked; using KCL alone does not guarantee identical bytes. The client does not fetch KCL imports, run configuration plugins or recompile a descriptor during installation.
This view separates authoring from client trust checks. Every failed check stops the path before command activation.
Descriptor schema
Section titled “Descriptor schema”The original accepted data profile is rukh.extension/1; the refinement below defines rukh.extension/2 for machine use. The names and variants below define its architectural contract; they are not a claim that a schema package or SDK has been released. A descriptor contains data, not callbacks, shell expressions, provider implementations or evaluated templates. Objects are closed except for the explicitly bounded annotations field.
| Field | Required meaning |
|---|---|
format, identity | Literal format identifier; identity contains authority, package, version, exactly matching the release envelope. The descriptor does not contain its enclosing releaseDigest |
compatibility | Supported core version bounds, exact supported interaction versions and required features; selected binding requirements. No assumption that package and protocol versions match |
startupRequirements | Shared startup features, operations and mandatory pre-launch access, applied to both invocation kinds |
commands | Array of unique id, relative path token array, direct alias paths, kind (group or command) and localized help references. Only command has execute; optional describe belongs to that command |
commands[].execute | mode (declared or passthrough), binding, executionMode, entryPoint, per-kind requirements; parameters exists only for declared inputs |
commands[].describe | Explicit managed binding, entry point and separate requirements; no execution parameters. Requires the structured-help feature and a ready environment |
entryPoints | ID-keyed records with kind (native or script) and platform targets. Each target has OS/architecture/ABI selectors, payloadRef, relative path, fixed arguments; script targets also identify runtimeRef and optional dependency artifact references |
runtimes | ID-keyed family/implementation/version-scheme requirements and explicit constraints under ADR-0008; no host installer or executable search expression |
requirements | Required/optional features and operations, each operation’s ID/version and resource constraint; preLaunchAccess explicitly marks access required before startup. An access domain identifies an owner binding, never an adapter implementation |
help | Default locale and bounded localized purpose, parameter descriptions, examples and static completion values; absent requested locale falls back to the declared default, never changes grammar |
annotations | Optional namespaced display/provenance metadata with scalar or scalar-list values. It cannot affect execution, access, routing or installation |
authority is a lowercase reverse-DNS-shaped namespace of at most 253 ASCII characters; its spelling does not prove DNS ownership or publisher trust. package and local IDs use [a-z][a-z0-9]*(?:[.-][a-z0-9]+)*, at most 64 characters. Their scope is the declaring package; command identity includes authority and package. Package versions use complete SemVer strings of at most 128 characters, while runtime versions retain their own scheme. Text labels do not participate in identity. Semantic Versioning.
Target selectors use registered exact values, not executable predicates. Each target names releaseTarget, the matching targets[].id in ADR-0007’s envelope, with consistent platform selectors. Its payloadRef must be an artifact ID admitted by that target’s payloads; dependency references must be admitted by its locks. The entry path resolves inside the selected payload’s installation root. The loader first selects one release target under ADR-0007; the core then considers only entry-point targets referring to that ID. It must find exactly one compatible binding there; zero is unsupported and two are ambiguous. Entry-point resolution cannot select another release target independently. Optional selectors constrain a target; absence does not establish an ABI guarantee. Paths use relative /-separated segments, without empty, . or .. segments, NUL or absolute/drive prefixes; the loader additionally enforces platform extraction rules. Fixed launch arguments are a bounded string array, not command-line text.
The initial mappings are process-only with passthrough and process-managed with declared inputs, both with executionMode=foreground. Managed describe is a separate invocation. A group cannot carry an entry point or parameters. A passthrough command cannot also supply a typed grammar; a managed command cannot publish a second raw-argv representation. A different executor or lifecycle mode requires a declared supported mapping rather than reinterpretation of these variants.
Version 2 and machine compatibility — 2026-09-24
Section titled “Version 2 and machine compatibility — 2026-09-24”ADR-0013 introduces rukh.extension/2. All version 1 identity, routing, scalar/list input, help, target and trust rules remain in force. Version 2 adds commands[].execute.result and commands[].machine with the exact variants, schema subset and finite limits in ADR-0013. Descriptors are still closed data: a version 1 document containing those fields is invalid, and an unsupported version 2 document cannot be downgraded by deleting requirements. Publisher-side KCL schemas must export the selected version explicitly. The release envelope binds the original exported bytes, never a client-upgraded descriptor.
Machine eligibility requires declared inputs, a managed mapping with command-result/1, foreground execution and compatible interaction requirements. Omitted machine metadata prevents automatic MCP exposure while preserving ordinary CLI use. Required task, effect and confinement contracts use existing exact feature/operation requirements; their semantics are defined by ADR-0014, ADR-0015 and ADR-0016. The descriptor never contains a live task grant, approval or enforcement implementation. Claims about harmlessness cannot bypass a trusted operation’s action/resource derivation.
MCP properties use stable parameter IDs and the same scalar/list types, defaults, bounds and explicitly supplied set. Generated JSON Schema is an interface projection, not another source of grammar. The core validates typed MCP data directly; it does not reinterpret flag names, coerce arbitrary JSON strings or parse a fabricated argv. Nested machine inputs remain outside this profile. Structured outputs have their separately bounded nested schema and do not widen input types. describe and help data cannot change the machine contract.
Activation validates the complete CLI and MCP projections. A descriptor’s eligible flag requests compatibility, while the owner chooses exposure and the caller’s current task and rights decide admission. Secret-marked inputs remain excluded from diagnostics and generated examples; marking a parameter sensitive does not provide a secret or authorize its disclosure to an agent.
Routing and parameter grammar
Section titled “Routing and parameter grammar”Route tokens use [a-z][a-z0-9-]*, at most 64 characters. A relative path contains 1–16 tokens. Aliases are complete direct paths to the same command ID; group aliases and alias chains are not part of this profile. Explicit parent groups may be shared, but an executable prefix is one declared command. The owner chooses mounts before validating the entire tree. The root help route is reserved. A duplicate effective path is invalid even if its two declarations would currently be hidden from different users.
The core consumes the longest matching contiguous command path before parsing that command’s input. Once the next token is not a child route, route selection ends; flags cannot appear between route tokens. An executable parent uses -- to pass a value that would otherwise select a child; a group without a handler reports an unknown/missing child only after help recognition. <group> --help and help <group> use visible metadata without requiring a child or handler. Core-global options occur before the command path and are not reinterpreted inside command data. Passthrough retains ADR-0002’s exact help form and explicit boundary.
| Parameter field | Rule |
|---|---|
id, source | Unique stable ID and either option or positional; the same parameter cannot be both |
names / position | Options have unique long names --[a-z][a-z0-9-]* and optional one-letter ASCII short names. Positionals have contiguous zero-based positions |
type, itemType | One scalar type below, or list of one scalar type. No nested lists or arbitrary objects |
required, default | Requiredness applies to an explicitly supplied value; a required parameter cannot have a default. An absent optional scalar without a default is omitted, not null; an optional list defaults to [] |
min, max, minLength, maxLength, choices | Only constraints applicable to the type; defaults satisfy the same constraints. List cardinality uses minItems/maxItems; arbitrary regular expressions and callbacks are excluded |
sensitive | Suppresses values from diagnostics, logging and stored invocation summaries; it does not make command-line arguments invisible to the OS or grant credential access |
Long options accept --name=value or --name value; valued short options accept -n value. Boolean options use a bare flag for true or a long =true/=false form. There are no short bundles, attached short values, implicit no- flags or counter flags. A value expected by an option consumes the next token even when it begins with -, including a negative number or --help; only a token in flag position can select help or terminate option parsing with --. Unknown options and repeated scalars are errors. Repeated list options append in arrival order. Positionals can follow options; required positionals precede optional ones, and only the last positional can be a list. Quoting, variable/glob expansion and response files are never performed by Rukh.
| Scalar type | Parsing and dispatched value |
|---|---|
string | Exact Unicode scalar sequence without normalization; empty values are valid unless constrained. NUL cannot cross a process argument mapping |
boolean | true or false, or the option shorthand above; JSON boolean |
integer | Signed base-10 integer, no leading +, redundant leading zeroes, fraction or exponent; range -(2^53-1)…2^53-1; JSON number |
number | JSON numeric grammar, converted once to finite binary64 using round-to-nearest/ties-to-even; overflow or non-finite values fail. It is explicitly an approximate numeric type |
exactInteger, exactDecimal | Explicit string encoding, up to 256 digits. Base-10 syntax without exponent; decimal permits a fractional part. Normalize redundant leading/trailing zeroes and negative zero once; dispatch the canonical string, never a binary64 approximation |
enum | Exact case-sensitive string from declared choices; JSON string |
Values supplied through a flag alias retain the same parameter ID. The typed record contains effective values plus the set of explicitly supplied parameter IDs; list order is preserved. Missing values, unsupported encodings or limits fail without a change of mode. A negative positional number uses -- when it would otherwise occupy flag position. An exact-decimal default is already a canonical string; numeric defaults cannot smuggle an out-of-range value into dispatch. Exact types accept -?[0-9]+ and -?[0-9]+(?:\.[0-9]+)? respectively, without whitespace or a leading +; integer trailing zeroes are significant, while only fractional trailing zeroes are removed. String-length constraints count Unicode scalar values; byte limits still apply independently. Bounds must be ordered, list cardinalities nonnegative and choices nonempty and unique. --help is reserved under ADR-0002; -h has no implicit help meaning in this profile.
Selected limits and error reporting
Section titled “Selected limits and error reporting”These are conservative design defaults, not measured optimal capacities. A tighter owner profile is permitted; larger limits require a separately declared, tested profile. Format limits are independent of ADR-0003’s smaller per-frame structure limits: the actual invocation must fit its selected binding, including envelope overhead, before startup.
| Resource | Baseline limit |
|---|---|
| Descriptor | 1 MiB of UTF-8; depth 32; 65,536 total object members and array elements; no BOM, duplicate keys or invalid Unicode scalars |
| Commands / aliases | 256 commands; 8 aliases per command; 16 route tokens per path |
| Parameters | 128 per command; 256 enum/completion values; 1,024 list items subject to the smaller invocation/binding budget |
| Entry points / targets / runtime requirements | 64 / 16 per entry point / 64 |
| Text and locale data | 64 KiB per text field; 16 locales; 4 KiB per completion value; total descriptor limit still applies |
| Prepared invocation data | 256 KiB of UTF-8 JSON before binding overhead; each text input at most 64 KiB; ADR-0003’s 4,096-member/element frame limit and platform launch limits also apply |
| Client validation | 2 seconds of elapsed work, at most 64 reported diagnostics; cancellation checked during traversal; timeout rejects this candidate |
Validation reports a stable category (invalid_descriptor, unsupported_requirement, route_conflict, limit_exceeded, invalid_input), an escaped JSON pointer or parameter ID and a safe explanation. It never emits sensitive values. A malformed package is a loader candidate error; a command input or selected requirement rejected before code runs maps to ADR-0002’s rejected. These are diagnostic categories, not extra invocation outcomes. Runtime/provider failures retain their own outcome mapping.
Input mode follows ADR-0002. Declared inputs are parsed once by the core; passthrough preserves the argument vector and cannot be silently substituted for typed inputs. Arbitrary passthrough requires authority for the whole target program. Argument prefixes are data passed without shell evaluation and cannot create a second command-dispatch source for managed invocations. A group has no handler; an executable parent, if present, is an explicitly declared command whose child routes remain unambiguous.
An alias changes spelling only: it cannot change inputs, defaults, permissions or execution mapping. The core checks the complete mounted tree, including built-ins, before activation. It rejects collisions rather than selecting by installation order or current user permissions. IDs are not reused for a different command meaning. A release update cannot retarget an already pinned invocation.
Execution kind, lifetime mode and language runtime remain independent. Descriptor data can identify another registered executor, but does not implement it or imply support. ADR-0004’s supported foreground mode remains the baseline; unsupported required modes/features prevent activation or invocation as appropriate. Native entry points do not acquire a language-runtime requirement by implication.
Validation and compatibility
Section titled “Validation and compatibility”| Check | Where enforced |
|---|---|
| Field types, required variants, duplicate keys, finite numeric values and bounded sizes/depth | Publisher and client; client acceptance is independent of author-side checks |
| References, command/parameter IDs, aliases, reserved help routes/flags and target ambiguity | Semantic validator, including the effective mounted tree |
| Version schemes and ranges, supported mappings and required features | Core against trusted provider/executor catalogs |
| Publisher authority, descriptor/payload binding and safe extraction paths | Loader under ADR-0007; display publisher text never proves authority |
| Runtime resolution and actual launch representation | Provider/executor under ADR-0002 and ADR-0008, without changing the selected command |
| Visibility, pre-launch access and actual core operations | Core authorization boundary, including ADR-0005 where required |
The schema package must encode the field variants, scalar rules and limits selected above. Defaults are literal data. Extension-specific validation can run only within an authorized invocation and cannot add commands or change the core grammar. The client checks static requirements and the effective tree independently of the publisher’s successful KCL compilation.
Base help and static completion are produced from the verified declaration without installation of a runtime or launch of an extension. Visibility still applies. --help, the -- boundary and contextual help retain ADR-0002 semantics; describe cannot rewrite routes, input schemas or access requirements.
The descriptor format, interaction contract, executor binding, core-service versions and runtime version scheme are independently versioned. A supported format does not imply supported features. Unknown fields outside annotations fail, as do unknown mandatory requirements; unsupported declared optional features may be omitted only under their known contract. Changing structural or parsing meaning requires another descriptor profile. Additive display metadata uses annotations, not an unknown security field labelled optional. Format migration occurs during publication, not by modifying verified descriptor bytes on the client.
Consequences
Section titled “Consequences”- Command inspection is independent of the extension language and runtime availability.
- KCL authors and the core share one exported contract, with semantic checks beyond KCL types.
- The existing KCL prototype is illustrative and incomplete: it does not implement typed inputs, aliases, separate
describerequirements or the broker composition. Its historical compilation checks do not validate this ADR.
Confirmation
Section titled “Confirmation”The 2026-09-24 refinement checks remain unrun. Verify the shared CLI/MCP path, unsupported result-feature rejection, current profile/task binding, bounded data, absence of replay and channel separation within this ADR’s responsibility. Historical results below do not cover these additions.
The project owner accepted this decision on 2026-09-23. The following list remains required implementation verification, not a claim that these checks passed at acceptance.
For implementation verification, implement a schema package and semantic validator for the selected rules, then check:
- Two KCL sources with the same exported meaning produce valid descriptors; the client rejects malformed or altered JSON independently of KCL.
- Route/alias collisions, wrong references, unknown requirements and ambiguous targets fail; aliases retain one command identity and access scope. Check executable parents,
--, negative values, repeated flags, empty inputs and exact numeric encodings at the selected limits. - Base help works without runtime preparation; typed/passthrough and contextual-help declarations preserve ADR-0002 behavior.
- Descriptor claims cannot register providers, remove an owner broker requirement or escape the release’s verified files.
These checks have not been run for ADR-0006. This record defines the contract; it does not claim a completed schema implementation.