feat(server): rfc0020 green pt1 — env-substitution resolver - #322
Conversation
The pure substitution resolver (config::env_subst) for the RFC 0020 config
file: resolve(scalar, lookup) following the OTel Config WG model on one
scalar value — ${env:NAME}/${NAME}, ${NAME:-default} (default on unset OR
empty), $$ escape, undefined-no-default → empty, values inserted verbatim
(non-recursive, no structure injection), malformed ${…} refs → a
MalformedReference naming the reference only (never a value; §3.4 hygiene).
The optional env: prefix backtracks per the WG grammar (${env:-x} = name
env, default x). Unterminated ${ is literal.
Tested: the OTel WG worked-example vector table (string-level rows) +
proptest invariants (no-panic, $-free identity, verbatim/non-recursive
value insertion, $$→$ escaping). Lives in the lib so it's unit-testable.
Foundational — additive only; the rfc0020 stubs stay ignored. RFC0020.2
closes in the next slice (the YAML walk: scalar-only, keys verbatim, type
after substitution). OTEL_* stays out of scope (§3.8).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 38 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds a new ChangesConfig environment substitution
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds the first “green slice” of RFC 0020 config-file support to ourios-server by introducing a unit-testable environment-variable substitution resolver (config::env_subst) and wiring a new config module into the server library.
Changes:
- Introduces
config::env_subst::resolvewith RFC/OTel Config WG-style${…}substitution semantics plus aMalformedReferenceerror type. - Adds a comprehensive conformance + property-test suite for the resolver using
proptest. - Exposes the new
configmodule fromourios-server’s library crate and updates dev-dependencies/lockfile.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/ourios-server/src/lib.rs | Exposes config from the server library and updates crate-level docs to mention RFC 0020 config pieces. |
| crates/ourios-server/src/config.rs | Adds the new config module root and documents intended RFC 0020 scope. |
| crates/ourios-server/src/config/env_subst.rs | Implements the env-substitution resolver + MalformedReference, with unit and property tests. |
| crates/ourios-server/Cargo.toml | Adds proptest dev-dependency for resolver property tests. |
| Cargo.lock | Records the new proptest dependency in the lockfile. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Review raised that the `$$` split could "break" a `${…}` whose default
contains `$$`. That is the WG algorithm by design — it is escape-first
("match the content since the prior escape against SUBSTITUTION-REF"), so a
`$$` inside a would-be reference breaks it; the normative table already
covers this (`${X:-$${Y}}` → `${X:-${Y}}`, a passing case). Add explicit
tests pinning `${NAME:-foo$$bar}` → `${NAME:-foo$bar}`, `${A$$B}` →
`${A$B}` (not a malformed-ref error), and `${A:-foo$bar}` → `foo$bar`
(a single `$` is part of a default), and clarify the resolve/segment docs.
No resolver-logic change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two review fixes: format the malformed reference with {:?} so one
containing whitespace/newlines stays delimited and legible in logs, and
correct the "brace-free" comment — a reference body has no `}` but may
contain `{` (the nested-default case).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rust regex `.` excludes `\n`, so `.*` / `.{0,32}` did not generate
newlines — yet config scalars / env values can be multi-line (the WG's
own INVALID_MAP_VALUE is). Switch never_panics + value_inserted_verbatim
to `(?s)` so the generators truly cover arbitrary, multi-line input.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
What
RFC 0020 green slice 1 — the environment-variable substitution resolver (
config::env_subst), the pure, gnarly core of the config-file mechanism.resolve(scalar, lookup) -> Result<String, MalformedReference>operates on a single scalar value following the OTel Config WG data model:${env:NAME}/${NAME}(equivalent);${NAME:-default}with default on unset or empty; undefined-no-default → empty.$$escapes a literal$; resolved values are inserted verbatim and never re-scanned (non-recursive — no structure injection, the §3.3 security boundary).${…}→MalformedReferencenaming the reference only, never a value (RFC 0019 §3.4 hygiene).env:prefix backtracks per the WG grammar (${env:-x}= nameenv, defaultx); unterminated${is literal.Tests
proptestinvariants: never panics,$-free identity, verbatim/non-recursive value insertion,$$→$escaping.Scope
Foundational + additive — lives in the lib (unit-testable), no binary behaviour change; the
rfc0020_config_filestubs stay ignored (6).RFC0020.2fully closes in the next slice (the YAML walk: scalar-only, keys verbatim, type-after-substitution).OTEL_*stays out of scope (§3.8).fmt/clippy --all-targets -D warnings/cargo doc/ tests clean locally.🤖 Generated with Claude Code
Summary by CodeRabbit