Skip to content

docs: add Configliere specification draft#14

Open
taras wants to merge 3 commits into
mainfrom
tm/building-specs
Open

docs: add Configliere specification draft#14
taras wants to merge 3 commits into
mainfrom
tm/building-specs

Conversation

@taras
Copy link
Copy Markdown
Member

@taras taras commented Apr 3, 2026

Motivation

Add a repository spec that captures Configliere's current architecture and behavioral contract in one place. The draft gives the project a shared reference for parser composition, source precedence, provenance, command/env scoping, phased parsing, and future contract tests.

Approach

Add specs/configliere-spec.md, a normative draft that documents the library's purpose, design philosophy, core abstractions, parsing and precedence models, command behavior, help and introspection model, error model, explicit non-goals, open questions, and a normative test agenda.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 3, 2026

Open in StackBlitz

npm i https://pkg.pr.new/configliere@14

commit: 6a5a97e

taras added 2 commits April 3, 2026 10:50
Formatting-only: line wrapping, trailing-space line breaks to backslash
continuations, asterisk-italics to underscore-italics. No content changes.
Copy link
Copy Markdown
Member

@cowboyd cowboyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ambiguity around env vars makes me feel as though there is something missing.

Comment thread specs/configliere-spec.md

Within the supported field model, every field SHOULD be configurable through
every source channel, and every source MUST be validated by the same schema.
Where a source cannot naturally represent a field's value (e.g., an env var for
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ENV vars can represent a nested value.

Comment thread specs/configliere-spec.md

- Command _selection_ is CLI-only (§9.1). This is an explicit asymmetry, not a
gap.
- Env vars undergo string coercion that CLI and config values do not require.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLI values undergo coercion: string -> T but it is a different transform than the one of ENV With config values T no conversion is necessary because it is already what it is.

Comment thread specs/configliere-spec.md
Comment on lines +60 to +61
- Env vars have no natural representation for nested objects or arrays beyond
simple conventions (e.g., comma-separated lists).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not true. It might be awkward, but it is possible, configliere attempts it.

Comment thread specs/configliere-spec.md
Comment on lines +62 to +63
- Not every structural concept (e.g., a command map, a nested object tree) has a
direct env-var equivalent.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically true, but the two examples are categorically false.

Comment thread specs/configliere-spec.md
Comment on lines +98 to +100
the resulting types MUST be inferred without explicit annotation. Inference
failures in the library's generic signatures are treated as bugs with blocking
priority.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Comment thread specs/configliere-spec.md
> hierarchy. The exact implementation (closure capture vs. explicit context
> parameter) is implementation-defined. What the spec requires is the behavioral
> invariant: the resolved parser behaves as if it has the original context.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AI LOVES the term "baking." I've tried to get it not to use it and it keeps creeping back in.

Comment thread specs/configliere-spec.md
Comment on lines +871 to +893
The current observed set of helpers includes:

- `ConfigType<P>` — extracts `T` from `Parser<T>`.
- `CommandsType<P>` — extracts the command union.
- `CommandType<P, N>` — extracts a single command member by name, prettified.
- `ProgramType<P>` — unwraps `Program<T>` to get `T`.

What is normative:

- The convention that extraction helpers operate on parser types, not on
extracted value types. [Directly stated by the project lead.]
- Any provided extraction helper MUST produce correct types for the supported
composition patterns.

What is the current intended direction but may evolve:

- The exact set and naming of helpers listed above is the current observed
roster. Future versions may add, rename, or restructure these helpers as the
type-level architecture matures.

> **Open.** Whether this set is complete — and in particular whether a
> `ConfigFileType` or similar helper for config-file authoring shapes is needed
> — is an unresolved question (see §13.7 and §17).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

general note: type inference helpers are a mess now and there are some refactors that need to happen around command. On the timeline of iterations it's like not even at step 1, so take anything that is there with a grain of salt

Comment thread specs/configliere-spec.md
union, which collapses to `{}`).

### 13.5 Computed maps and annotation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"command maps" mess WRT the type-system and needs to be revisited. It was an attempt to have a more user friendly command construction, but it looks terrible from the perspective of the type system.

Comment thread specs/configliere-spec.md
Comment on lines +972 to +974
When `program()` detects `--help`, it MUST produce help text even if the
underlying parse would fail. The help/version screening occurs before config
parsing.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true of any parser

Comment thread specs/configliere-spec.md
Comment on lines +1064 to +1067
1. **Provenance preservation of original env keys after scoping.** After
`scope()` transforms env keys, the original key (e.g., `SERVE_PORT`) is lost.
This conflicts with the project's inspectability emphasis. Whether to track
pre-scoping identity is an open design question.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants