Skip to content

feat(server): rfc0020 green pt1 — env-substitution resolver - #322

Merged
jensholdgaard merged 4 commits into
mainfrom
feat/rfc0020-green-env-subst
Jun 30, 2026
Merged

feat(server): rfc0020 green pt1 — env-substitution resolver#322
jensholdgaard merged 4 commits into
mainfrom
feat/rfc0020-green-env-subst

Conversation

@jensholdgaard

@jensholdgaard jensholdgaard commented Jun 30, 2026

Copy link
Copy Markdown
Owner

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).
  • Malformed ${…}MalformedReference naming the reference only, never a value (RFC 0019 §3.4 hygiene).
  • Optional env: prefix backtracks per the WG grammar (${env:-x} = name env, default x); unterminated ${ is literal.

Tests

  • The OTel Config WG worked-example vector table (string-level rows) — the normative conformance set.
  • proptest invariants: never panics, $-free identity, verbatim/non-recursive value insertion, $$$ escaping.
  • Plus targeted unit tests (default unset/empty, env-prefix equivalence + backtrack, malformed naming, unterminated literal).

Scope

Foundational + additive — lives in the lib (unit-testable), no binary behaviour change; the rfc0020_config_file stubs stay ignored (6). RFC0020.2 fully 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

  • New Features
    • Added support for environment-variable substitution in server configuration values, including default fallbacks and escaped dollar signs.
    • Improved configuration handling so unresolved or malformed references are reported clearly instead of failing unexpectedly.
    • Expanded test coverage for configuration substitution behavior and edge cases.

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>
@jensholdgaard
jensholdgaard requested a review from Copilot June 30, 2026 19:23
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jensholdgaard, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 10722a45-bdf1-4c4f-b216-404f5f436f7a

📥 Commits

Reviewing files that changed from the base of the PR and between a2623e1 and b29db83.

📒 Files selected for processing (1)
  • crates/ourios-server/src/config/env_subst.rs
📝 Walkthrough

Walkthrough

This PR adds a new config module to ourios-server implementing RFC 0020 ${...} environment-variable substitution. It introduces a resolve function and MalformedReference error type, wires the module into the crate's public surface, and adds a pinned proptest dev-dependency along with unit and property-based tests.

Changes

Config environment substitution

Layer / File(s) Summary
Config module entrypoint and crate wiring
crates/ourios-server/src/config.rs, crates/ourios-server/src/lib.rs
Adds module documentation for the RFC 0020 config work, re-exports env_subst, and registers pub mod config; in the crate root.
Substitution resolver implementation
crates/ourios-server/src/config/env_subst.rs
Implements MalformedReference and resolve, performing left-to-right scanning with $$ escaping, env: prefix and :-default handling, identifier grammar validation, and non-recursive substitution.
Unit and property tests for resolver
crates/ourios-server/src/config/env_subst.rs, crates/ourios-server/Cargo.toml
Adds unit and proptest-based tests covering worked examples, default/empty semantics, escape and backtracking behavior, and panic-free resolution, supported by a pinned proptest dev-dependency.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A dollar sign hopped down the trail,
With curly braces for a tail,
"env:" whispered soft and low,
Defaults bloom where values don't grow,
Tests hop wild through proptest's den,
No panics found — hooray, again! 🐇🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately highlights the main change: the RFC 0020 environment-variable substitution resolver.
Description check ✅ Passed The description covers summary, tests, and scope, but it omits the template's Related section and checklist items.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rfc0020-green-env-subst

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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::resolve with RFC/OTel Config WG-style ${…} substitution semantics plus a MalformedReference error type.
  • Adds a comprehensive conformance + property-test suite for the resolver using proptest.
  • Exposes the new config module from ourios-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.

Comment thread crates/ourios-server/src/config/env_subst.rs Outdated
Comment thread crates/ourios-server/src/config/env_subst.rs
Comment thread crates/ourios-server/src/config/env_subst.rs
Comment thread crates/ourios-server/src/config/env_subst.rs
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Comment thread crates/ourios-server/src/config/env_subst.rs Outdated
Comment thread crates/ourios-server/src/config/env_subst.rs
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Comment thread crates/ourios-server/src/config/env_subst.rs Outdated
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

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