Skip to content
This repository was archived by the owner on Jul 2, 2026. It is now read-only.
/ docs Public archive

Document package constants - #413

Merged
jachris merged 1 commit into
mainfrom
topic/document-package-constants
Jun 29, 2026
Merged

Document package constants#413
jachris merged 1 commit into
mainfrom
topic/document-package-constants

Conversation

@jachris

@jachris jachris commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🔍 Problem

Package constants (constants.tql / pkg::$name) are undocumented.

🛠️ Solution

Add a guide, guides/packages/add-constants, and wire the feature into the
existing package documentation.

  • The guide is ordered the way an author adopts the feature: define → reference
    (from the package's own operators, then external pipelines) → build on
    earlier bindings → binding rules → a constants-vs-inputs comparison table.
  • Registered in the sidebar before Configure inputs, since constants and
    inputs are the two parameterization mechanisms.
  • Package anatomy explanation, plus reciprocal See-also links from the
    operators, inputs, and create-a-package guides.

💬 Review

  • markdownlint (the enforced .mdx check) and biome are clean; all
    <Guide>/<Explanation> cross-reference slugs verified against existing use.
  • Documents an unreleased feature; land with or after the engine PR.
📎 Related: tenzir/tenzir#6363, tenzir/library#163

Add a guide for the package-level `let` bindings defined in `constants.tql`
and referenced as `pkg::$name`. It covers defining constants, referencing
them from the package's own operators and from external pipelines, building
one binding on another, the deterministic-constant rules the loader enforces,
and how constants differ from inputs.

Wire the feature into the package anatomy explanation (file tree, a Constants
component section, and the lifecycle), register the page in the sidebar before
Configure inputs, and add reciprocal See also links from the operators, inputs,
and create-a-package guides.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

📦 Preview  ·  View →  ·  ⚪ Removed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d6e50468c1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/content/docs/guides/packages/add-constants.mdx

@mavam mavam left a comment

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.

Reads well.

jachris added a commit to tenzir/tenzir that referenced this pull request Jun 26, 2026
## 🔍 Problem

Packages bundle operators, pipelines, and contexts, but offered no way
to
define shared named constants. Authors had to repeat literal values
across a
package's operators and pipelines.

## 🛠️ Solution

A package can define `let` bindings in a `lets.tql` file at its root.
Each
binding is a compile-time constant, referenceable as `pkg::$name` — from
the
package's own operators and pipelines, and from any external pipeline
that uses
the package. Later bindings may reference earlier ones.

```tql
// acme/lets.tql
let $high_severity = 8
let $threshold = $high_severity + 1
```

```tql
where severity >= acme::$threshold
```

References are resolved and const-evaluated lazily at each use site,
where the
full registry is available — mirroring how user-defined operators
resolve. A
binding must be a deterministic constant; `let $r = random()` is
rejected,
since per-reference evaluation would otherwise yield differing values.

## 💬 Review

- New `pkg_dollar_var` AST node and `let` entity namespace; references
resolve
  against the `packages` domain and cache their constant on the node.
- Bindings are stored unevaluated at load and const-evaluated lazily on
first
reference, so sibling and cross-package references resolve against a
complete
  registry.
- Operators and lets register through a shared `build_package_module`.
- `expression::is_deterministic` is made exact and exhaustive so
composite
constants (lists, records, …) are no longer misclassified; it gates the
  determinism check.
- Tests cover internal and external references, sibling references, and
the
error paths (unknown binding, unknown package, forward reference,
non-`let`
statement in `lets.tql`, reference cycle, non-constant and
non-deterministic
  bindings).

<sub>
📎 Plugins PR: tenzir/tenzir-plugins#568<br>
📚 Docs PR: tenzir/docs#413<br>
📎 Related: tenzir/library#163
</sub>
@jachris
jachris merged commit e16e27d into main Jun 29, 2026
5 checks passed
@jachris
jachris deleted the topic/document-package-constants branch June 29, 2026 19:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

explanation Explanations guide How-to guides site Site infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants