Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

spec: batch eligible exact lookups by default (#6871)

Joey999527656389
diff --git a/docs/specs/AST-042-cli-command-admission/spec.md b/docs/specs/AST-042-cli-command-admission/spec.md
index 87372e3724..a67b1ade97 100644
--- a/docs/specs/AST-042-cli-command-admission/spec.md
+++ b/docs/specs/AST-042-cli-command-admission/spec.md
@@ -114,6 +114,16 @@ function, and the vocabulary that human-readable output may use.
into a new command, or promoting a subcommand to a top-level command is an
admission at the new tier and MUST pass that tier's test. Removal and renaming
also follow `spec:AST-017` FR1–FR8.
+- **FR7 — Exact-lookup admission classifies batching first.** Before code is written,
+ every new command or subcommand with an exact selector position MUST classify that
+ position against `spec:AST-053` FR11 E1-E5. An eligible surface MUST use AST-053's
+ batch contract in its first public release. An ineligible top-level command MUST cite
+ a current command-owning record that names the failed condition; a draft does not
+ admit the exclusion. An ineligible subcommand MUST name the condition in its
+ admitting pull request and still follows FR4's code-owner approval bar. After typed
+ admission metadata lands, its CommandDoc MUST retain the same classification.
+ Existing eligible commands follow AST-053's incremental migration rule. A hidden
+ option MUST NOT make batching opt-in or bypass this classification.
### Platform support
@@ -126,7 +136,9 @@ function, and the vocabulary that human-readable output may use.
`architecture:cli-surface` INV20–INV23 carry FR1–FR3 into the code: the layout of
an API subject, the adapter as a subject's only access to the environment, thin
command handlers, and the closed formatter kit. `contributing:cli-conventions`
-restates FR4 and FR5 for contributors.
+restates FR4 and FR5 for contributors. It does not yet restate FR7, and CommandDoc
+has no typed AST-053 eligibility field; projecting the rule there and adding the
+repository check are known enforcement gaps that land separately.
The CLI has 17 top-level commands. The command docs of 28 commands and
subcommands name the function they call. Known gaps, for which this record does
@@ -148,9 +160,9 @@ not assign migrations:
covered (FR2).
No mechanical check enforces FR1, the per-function part of FR2, FR3, FR4, FR5,
-`architecture:cli-surface` INV21, or most of INV22 and INV23 yet. Review applies
-them to every new change; until mechanical checks land, a new violation fails
-only in review. The checks and the closure of the gaps above land as separate
+FR7, `architecture:cli-surface` INV21, or most of INV22 and INV23 yet. Review
+applies them to every new change; until mechanical checks land, a new violation
+fails only in review. The checks and the closure of the gaps above land as separate
changes.
This specification change alters no runtime behavior or published package and
@@ -165,6 +177,7 @@ needs no Changeset.
| FR3 | Text-output snapshots per command; the help snapshot | each block kind; a list of items; a result shaped like a table | A command prints a layout outside the documented blocks, or a new block kind is missing from help |
| FR4, FR6 | The admitting pull request and the authority it cites | top-level command, subcommand, option, rename, promotion | A top-level command lands without a current specification, or a subcommand lands without its stated case and code-owner approval |
| FR5 | Option composition tests per command | each option pair; a boolean default; a shared option name | A pair has no decided result, a boolean defaults to on, or one name has two meanings |
+| FR7 | Admission review against AST-053 E1-E5 and the evidence for its tier | eligible new lookup; top-level and subcommand exclusions; draft | An eligible surface is single-only, or an exclusion lacks the evidence its tier requires |
## Decision log
@@ -208,6 +221,21 @@ top-level commands in too easily; and adding a top-level command to make behavio
easier to find, because help and docs make behavior discoverable under
`spec:AST-017` FR14.
+### DEC-4 — Exact lookups classify batching during admission
+
+**Reference:** `spec:AST-042/DEC-4`
+**Decider:** `josephfarina`, `2026-10-01`
+
+Batch shape is part of a lookup's public surface, so admission applies AST-053 E1-E5
+before implementation. The evidence still follows DEC-3's permanence tiers: a
+current record for a top-level command, and the pull request plus code-owner approval
+for a subcommand; CommandDoc retains the result after typed metadata lands.
+
+Rejected: letting each eligible command remain single-only or hide batching behind an
+option, which gives equivalent read-only lookups different automation contracts; and
+requiring a new system record for every subcommand exclusion, which defeats the tiered
+bar.
+
## Open questions
None.
diff --git a/docs/specs/AST-053-multi-selector-lookups/spec.md b/docs/specs/AST-053-multi-selector-lookups/spec.md
index 1803307b27..1292ce3c05 100644
--- a/docs/specs/AST-053-multi-selector-lookups/spec.md
+++ b/docs/specs/AST-053-multi-selector-lookups/spec.md
@@ -26,92 +26,196 @@ successful calls. A lookup that accepts several selectors returns one complete,
ordered receipt: every requested selector has one row, ambiguity stays visible, and
the exit status says whether every lookup resolved.
-This record owns the observable batch contract for any CLI lookup that elects to
-accept several exact selectors. The lookup's existing authority still owns what a
-selector means, how one selector resolves, and the data returned for one resolved
-subject.
+This record owns the observable batch contract and adoption rule for CLI lookups over
+independent exact selectors. FR11 E1-E5 are the only eligibility test. An eligible
+read-only lookup adopts batching by default; an ineligible command keeps its existing
+grammar. The lookup's existing authority still owns what a selector means, how one
+selector resolves, and the data returned for one resolved subject.
## Non-goals
- Turning free-text search into a batch. Words in one search query remain one query.
-- Requiring every lookup command to accept several selectors.
+- Applying this read-only lookup contract to mutations, streaming or watch sessions,
+ comparisons, ranges, or commands whose positional arguments form one expression or
+ ordered workflow.
- Changing existing CLI responses for zero or one positional selector, or existing
programmatic responses for omitted and string arguments.
- Ranking candidates or choosing among ambiguous identities.
- Adding a global option, configuration key, environment variable, or network source.
+- Changing a pre-existing batch response on a command that fails E1-E5. A `.batch`
+ suffix alone does not make that response an AST-053 receipt.
- Equivalent internal implementations remain valid when they satisfy this contract.
## Requirements
-- **FR1 — Batch selection is explicit and discoverable.** A command that accepts
- several exact selectors MUST document a variadic positional argument in generated
- help, its manifest entry, and its programmatic API. No hidden control enables the
+- **FR1 — Batch selection is explicit and discoverable.** An adopting command MUST
+ document its selector position as variadic in generated help and its manifest entry,
+ and as an accepted array in its programmatic API. No hidden control enables the
behavior.
-- **FR2 — Every selector gets one row.** A batch receipt MUST contain exactly one
- result row per supplied selector, in input order. Duplicate selectors remain
- duplicate rows. No limit, deduplication, or successful neighbor may remove a row.
+- **FR2 — Every accepted selector gets one row.** After invocation-level validation, a
+ batch receipt MUST contain exactly one result row per supplied selector, in input
+ order. Duplicate selectors remain duplicate rows. A command MAY reject the whole
+ request before resolution when its aggregate work would exceed a documented finite
+ bound; that rejection uses the ordinary top-level `ERR_INVALID_ARGUMENT` error
+ envelope, the CLI exits 1, and no batch is emitted. An accepted batch MUST NOT
+ truncate or deduplicate selectors.
- **FR3 — Every row states its outcome.** Each row MUST echo the selector exactly and
identify one state: `found`, `not_found`, `ambiguous`, or `error`.
-- **FR4 — Found rows preserve single-lookup meaning.** A `found` row MUST carry the
- same typed result that the command's programmatic API returns for that selector by
- itself with the same controls. A caller does not reconstruct the single result
- from batch-only fields.
+- **FR4 — Found rows preserve single-lookup meaning.** A `found` row MUST carry under
+ `result` the same typed response that the programmatic API returns for that selector
+ by itself with the same controls and response-base fields. `spec:AST-047` FR10 decides
+ whether a command has adopted navigable output, and its FR7 defines the `links` field
+ after adoption. Single-result links stay nested with their row. The outer receipt
+ carries links only when the command's own AST-047 adoption authority defines the
+ receipt as a node; AST-053 does not synthesize moves. A caller does not reconstruct
+ the single result from batch-only fields.
- **FR5 — Ambiguity is data, never a guess.** When several identities can satisfy a
selector, the row MUST be `ambiguous` and list every effective candidate with the
stable identity fields that the owning catalog exposes. The lookup MUST NOT choose
- the first candidate or silently prefer a package.
-- **FR6 — Failures stay complete and machine-readable.** A `not_found` or `error` row
- MUST carry the stable error code the same one-selector lookup uses, its
- human-readable error, and any structured suggestions. A batch MUST NOT print an
- error outside the receipt, drop the row, or turn the failed selector into an empty
- success.
-- **FR7 — Exact package versions do not fall through.** When a selector names a
- package version, it resolves only against that exact installed version. A different
- installed version is `not_found` and points the caller to the owning discovery
- command; it is never used as a plausible substitute.
-- **FR8 — The full receipt precedes failure.** The CLI MUST emit every row, then exit
- nonzero when any row is not `found`. Text and JSON modes use the same exit status.
- The programmatic API returns the complete typed receipt and leaves process exit
- policy to its caller.
-- **FR9 — Existing CLI cardinalities keep their contracts and API input is explicit.**
- In the CLI, zero positional selectors keep browse behavior and one keeps its
- existing success or error envelope; two or more use the batch discriminator. In
- the programmatic API, an omitted argument browses, a string requests one result,
- and an array requests a batch at every array length, including zero and one.
+ the first candidate or silently prefer one namespace, provider, or package.
+- **FR6 — Per-selector failures stay in the receipt.** A `not_found` or `error` row MUST
+ carry the stable error code the same one-selector lookup uses, its human-readable
+ error, and any structured suggestions. After a request is accepted as a batch, a
+ per-selector failure MUST NOT become a top-level error, disappear, or become an empty
+ success. Only validation or setup failures that apply to the invocation before any
+ selector can resolve use the ordinary top-level error envelope.
+- **FR7 — Exact qualifiers do not fall through.** When a selector carries an exact
+ qualifier owned by the lookup, such as a package version or revision, it resolves
+ only against that exact subject. A near identity with another qualifier is
+ `not_found`, may point to the owning discovery or next-action command, and is never
+ used as a plausible substitute.
+- **FR8 — The full receipt precedes failure.** The CLI MUST emit every row, then exit 1
+ when any row is not `found`. Text and JSON modes use the same exit status. The
+ programmatic API returns the complete typed receipt and leaves process exit policy
+ to its caller.
+- **FR9 — Existing cardinalities and positional meaning stay stable.** For an adopting
+ command, zero selectors preserve the command's existing zero-selector behavior,
+ whether browse or error; one selector preserves its existing success or error
+ response; and two or more selectors use the batch discriminator. Only the owned
+ selector position becomes variadic. Other positional arguments keep their existing
+ relationship and order. In the programmatic API, an omitted argument preserves its
+ existing behavior, a string requests one result, and an array requests a batch at
+ every array length, including zero and one.
- **FR10 — Text is a projection of the batch.** Human-readable output MUST expose the
- count and every row's selector, status, and state-specific fields through the
- shared formatter vocabulary. It MUST NOT invent a command-specific table or omit a
- failure that JSON carries.
+ count and every row's selector, status, and state-specific fields through the shared
+ formatter vocabulary. Outer response fields stay on the receipt, and fields from a
+ nested single result stay with that row; nested links MUST NOT be promoted to the
+ receipt. Text MUST NOT invent a command-specific table or omit a field that JSON
+ carries.
+- **FR11 — Eligibility has one test.** A command is eligible exactly when all five
+ conditions hold:
+ - **E1:** it is read-only and its selector position accepts one exact stable subject;
+ - **E2:** selectors resolve independently, without a relationship or order between
+ them, and the same options and other positional arguments apply to each;
+ - **E3:** each result is finite and the command can return the complete accepted
+ receipt before exit;
+ - **E4:** one documented aggregate work bound can safely accept at least two
+ selectors in every supported option and projection mode, and resolving the set adds
+ no side effect; and
+ - **E5:** the selector is the command's final positional argument, so making it
+ variadic does not reinterpret a following positional.
+ A command admitted after this record became current that satisfies E1-E5 MUST adopt
+ the contract before its first public release. An existing command that satisfies
+ E1-E5 SHOULD migrate without changing its zero- and one-selector contracts. If any
+ condition fails, the command is not eligible.
+- **FR12 — Every adopter uses one batch vocabulary.** The discriminator MUST be
+ `<subject>.batch`, where `<subject>` is the stable subject family used by the
+ command's single-result responses. Under `architecture:cli-surface` INV2, `type`
+ carries that discriminator and `{count, results}` is the `data` payload. The shared
+ CLI response foundation MUST own and publish `BatchResponse` and `BatchRow` for that
+ payload and the four row states; subject API modules specialize those types with
+ their candidate and single-result types. An adopter MUST NOT invent synonymous
+ discriminator, status, or row field names. A pre-existing batch response on an
+ ineligible command keeps its command-owned contract and does not claim AST-053
+ conformance merely because its discriminator ends in `.batch`.
+- **FR13 — Admission records the classification.** Command admission under AST-042 MUST
+ classify the selector position against E1-E5. A top-level command's exclusion MUST
+ name the failed condition in a current command-owning record; a draft does not count.
+ A subcommand's exclusion MUST name the condition in its admitting pull request under
+ AST-042's existing code-owner approval bar. After typed admission metadata lands, its
+ CommandDoc MUST retain the same classification. Until that metadata and a repository
+ check land, FR11 and this requirement are enforced in review rather than
+ mechanically.
### Platform support
- Supported feature/engine floor: every runtime already supported by the owning CLI
command.
-- Unsupported behavior: none. A command that does not opt in keeps its existing
- single-selector grammar.
+- Unsupported behavior: none. A command that is not eligible keeps its existing
+ grammar.
- Browser evidence: not applicable; this is a CLI and programmatic API contract.
+## Adoption and rollout
+
+FR11 E1-E5 govern eligibility. Typical adopters are `get`, `show`, `inspect`, and
+status-style reads over exact identities. The examples below illustrate a failed
+condition; they do not replace the E1-E5 test:
+
+- free-text search or discovery fails E1 because several words form one query;
+- create, update, delete, apply, or other mutations fail E1 and E4 because they need
+ separate transaction and partial-write semantics;
+- compare, diff, range, pipeline, or workflow commands fail E2 because argument
+ position defines a relationship rather than independent subjects;
+- watch, shell, stream, or interactive commands fail E3 because they do not return one
+ finite receipt;
+- commands whose selector is followed by another positional fail E5 in the current
+ grammar; and
+- lookups that cannot safely accept at least two selectors in every supported mode fail
+ E4.
+
+Adopt the contract one command at a time:
+
+1. Classify the owned selector position against E1-E5 during AST-042 admission. Record
+ any exclusion exactly as FR13 requires.
+2. Define and document the aggregate work bound, including selector count and any
+ command-specific cost dimension. It must safely accept at least two selectors in
+ every supported mode. Reject work beyond it before resolution with top-level
+ `ERR_INVALID_ARGUMENT` and CLI exit 1; never truncate an accepted batch.
+3. Preserve existing zero- and one-selector behavior and minimum cardinality. Make
+ only the owned selector position variadic; do not reinterpret another positional.
+4. Make programmatic batch intent explicit with an array at every array length. Use
+ the shared batch response and row types, the `<subject>.batch` discriminator, and
+ the existing one-selector response under each `found.result`.
+5. Preserve outer and nested response-base fields, then apply every existing read
+ projection and option to each `found` row. Do not ship a reduced batch-only detail
+ surface.
+6. Add generated help, manifest/API docs including `exitCodes`, a searchable guide,
+ real text and JSON receipts, and deterministic coverage for oversized rejection,
+ empty and one-item API arrays, order, duplicates, all-found, mixed, all-failed,
+ ambiguity, response-base fields, and every projection.
+
## Current-state impact
-The component lookup is the first adopter. Its variadic command argument and
-`component.batch` response apply FR1-FR10. CLI browse and single-selector response
-types remain unchanged. Programmatic callers choose the catalog with an omitted
-argument, one result with a string, and a batch with an array.
-`architecture:cli-surface` keeps ownership of the outer envelope, formatter
-vocabulary, generated help, and API to CLI parity.
+The component lookup remains the designated first adopter. Its runtime implementation
+lands separately from this specification amendment and MUST apply FR1-FR12 before it
+claims compliance. CLI browse and single-selector response types stay unchanged;
+programmatic callers choose the catalog with an omitted argument, one result with a
+string, and a batch with an array. `architecture:cli-surface` keeps ownership of the
+outer envelope, formatter vocabulary, generated help, and API to CLI parity.
+
+AST-042 projects the E1-E5 classification into command admission for FR13. The next
+rollout phase adds typed classification to CommandDoc and the generated manifest, then
+classifies every existing exact selector position. Those public command docs and the
+manifest become the canonical inventory. Later changes migrate each eligible command
+family. External scheduling is not authority and its references do not enter this
+public repository. Each command's own current authority continues to own selector
+grammar, single-result data, and any recorded exclusion.
## Verification
-| Contract | Verification | Representative states | Mutation or failure expectation |
-| -------- | ------------------------------------------------------------------ | --------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
-| FR1 | Generated help and manifest tests; FunctionDoc contract tests | zero, one, and several positional selectors | The variadic input exists in code but is absent from help, manifest, or API docs |
-| FR2, FR3 | Programmatic API and CLI batch tests | found rows, duplicate selectors, mixed outcomes | A selector is reordered, deduplicated, dropped, or has no state |
-| FR4 | Batch versus single-result comparison | detail and each supported focused projection | A found row differs from the same one-selector result |
-| FR5 | Ambiguous installed-identity fixture | two effective package owners for one name | One owner is chosen or a candidate is omitted |
-| FR6, FR7 | Missing, malformed, unknown-package, and version-mismatch fixtures | suggestions present and absent; another version installed | A failure becomes an empty success, loses its code, or falls through to another version |
-| FR8 | Text and JSON process tests | all found; one failure; several failures | Output stops at the first failure or an unresolved batch exits zero |
-| FR9 | CLI cardinality tests and API input-shape tests | CLI zero/one/many; omitted, string, empty array, one-item array | A CLI discriminator changes, or an explicit array does not return a batch |
-| FR10 | Text projection tests | every row state | Text omits a state field or draws an unregistered output format |
+| Contract | Verification | Representative states | Mutation or failure expectation |
+| -------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
+| FR1 | Generated help and manifest tests; FunctionDoc contract tests | one selector position becomes variadic | Batch input exists in code but is absent from help, manifest, or API docs |
+| FR2, FR3 | Programmatic API and CLI batch tests | minimum useful bound; oversized rejection; order; duplicates; mixed outcomes | An accepted selector is reordered, deduplicated, dropped, or has no state |
+| FR4 | Batch versus single-result and response-base comparison | detail, links, and each supported focused projection | A found row differs from the same one-selector result |
+| FR5 | Ambiguous installed-identity fixture | two effective package owners for one name | One owner is chosen or a candidate is omitted |
+| FR6, FR7 | Missing, malformed, unknown-package, and version-mismatch fixtures | suggestions present and absent; another version installed | A selector failure escapes the receipt, loses its code, or uses another qualifier |
+| FR8 | Text and JSON process tests | all found; one failure; several failures | Output stops at the first failure or an unresolved batch does not exit 1 |
+| FR9 | CLI cardinality, positional-meaning, and API input-shape tests | zero browse/error; one; many; empty and one-item arrays | Existing cardinality changes, another positional becomes a selector, or array shape drifts |
+| FR10 | Text projection and navigable-output tests | every row state; outer fields with and without links | Text omits a JSON field, moves a nested link, or draws an unregistered output format |
+| FR11 | AST-042 admission review | E1-E5 eligible adopter; top-level and subcommand exclusions | An eligible new command is single-only, or an exclusion does not name a failed condition |
+| FR12 | Shared JSON/type contract and manifest tests | `<subject>.batch`; every shared row state | An adopter invents a discriminator, status, or row field |
+| FR13 | Knowledge-reference, pull-request, and typed-metadata review | current top-level record; subcommand evidence; draft exclusion | Admission skips classification or uses the wrong evidence for its tier |
## Decision log
@@ -121,21 +225,25 @@ vocabulary, generated help, and API to CLI parity.
**Decider:** `josephfarina`, `2026-10-01`
Batch lookup exists to reduce repeated process work without hiding what happened to
-any request, so selectors remain one-for-one and in order, including duplicates.
+any accepted request, so accepted selectors remain one-for-one and in order, including
+duplicates. A work-bound rejection happens before batch resolution and returns no
+partial receipt.
-Rejected: fail the whole call on the first miss, which loses later answers; and drop
-failed selectors, which makes partial work look complete.
+Rejected: fail an accepted batch on the first miss, which loses later answers; drop
+failed selectors, which makes partial work look complete; or truncate an oversized
+request after resolution begins.
### DEC-2 — Ambiguity lists candidates
**Reference:** `spec:AST-053/DEC-2`
**Decider:** `josephfarina`, `2026-10-01`
-An unqualified identity can belong to several packages. The receipt exposes those
-candidates so the caller can make the next lookup exact.
+An unqualified identity can belong to several namespaces, providers, or packages. The
+receipt exposes every effective candidate so the caller can make the next lookup
+exact.
-Rejected: package precedence or first-match selection, which turns catalog order into
-an undocumented answer.
+Rejected: precedence or first-match selection, which turns catalog order into an
+undocumented answer.
### DEC-3 — An unresolved row makes the CLI fail after output
@@ -143,7 +251,8 @@ an undocumented answer.
**Decider:** `josephfarina`, `2026-10-01`
Automation needs the process status to say whether every requested lookup resolved,
-while the receipt is still useful for fixing all failures in one pass.
+while the receipt is still useful for fixing all failures in one pass, so any
+unresolved row exits 1 after output.
Rejected: exit zero because some rows succeeded, which reports incomplete work as
success; and emit no receipt on failure, which forces repeated calls.
@@ -153,15 +262,30 @@ success; and emit no receipt on failure, which forces repeated calls.
**Reference:** `spec:AST-053/DEC-4`
**Decider:** `josephfarina`, `2026-10-01`
-Existing CLI callers keep the browse and single-selector envelopes they already
-parse. Programmatic callers choose those paths with an omitted argument or a string,
-and choose a complete batch receipt with an array. Empty and one-item arrays remain
-batches, so `component([])` means "look up this empty set" rather than "browse all."
+Existing CLI callers keep the zero- and one-selector behavior they already parse.
+Programmatic callers choose those paths with an omitted argument or a string, and
+choose a complete batch receipt with an array. Empty and one-item arrays remain
+batches, so filtering a selector list never changes the response type.
Rejected: making an array's response depend on its length, which makes an explicit
batch call change shape as a caller filters selectors; and always returning a batch
for strings, which changes the stable JSON shape for existing callers.
+### DEC-5 — Independent read-only lookups batch by default
+
+**Reference:** `spec:AST-053/DEC-5`
+**Decider:** `josephfarina`, `2026-10-01`
+
+Repeated process setup and fragmented failures are common to every lookup that meets
+E1-E5, not only component docs. Commands admitted after this record became current
+adopt the shared batch vocabulary in their first public release. Existing eligible
+commands migrate one at a time without changing zero- and one-selector behavior.
+
+Rejected: leaving adoption entirely optional, which produces a different batching
+model for each command; and making every multi-argument command a batch, which breaks
+search queries, mutations, comparisons, workflows, and interactive sessions whose
+arguments are not independent read-only subjects.
+
## Open questions
None.