Skip to content

[Request]: Runtime override for declared env values #258

Closed

Description

@jimhoyd

Tried: point the app at a data file per environment/test.
Expected: a declared env binding with a host override.
Got: env values are fixed literals. Run 2 copied the whole project to a temp dir per test; run 1 read process.env inside the function instead, bypassing the declared-binding model the docs recommend.
Suggestion: env: {NAME: {value: default, from: host}} (default with runtime override), and a documented data-directory pattern.
Evidence: an A/B benchmark on URLCode 0.4.1 with Sonnet 5 agents building the same Todo app from the repo docs. Run 1 (benchmark Agent B, no authoring skill, no browser check) and run 2 (session "Todo application with URLCode", authoring skill loaded, tightened prompt) hit this independently. n=1 each; single small app, so treat frequency as anecdotal. The Agent A control (no URLCode) needed 2 shell calls and 0 dependencies for the same app.

Activity

  1. added
    enhancement
    on Sep 20, 2026
  2. added
    needs-decision
    ai-first
    on Sep 20, 2026
  3. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Decision: do not add {value: default, from: host}.

    • A default that a host can silently replace changes what a reviewed urlcode.yaml means, and readiness/audit currently treats literals as reviewable.
    • Preferred shape if evidence holds: an optional default on the existing operator-resolved {env: NAME} reference. The override stays an operator-policy grant, is listed by audit, and a missing policy still fails closed unless a default is declared.
    • Now, docs only: document a data-directory pattern (an {env: DATA_DIR} binding read by the function) that needs no new semantics.
    • Evidence is anecdotal (n=1 each), so the default change waits for more runs.
  4. added
    in-progress
    and removed
    needs-decision
    on Sep 20, 2026
  5. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Progress: implementation started by an agent against the maintainer decision on this issue; a PR will be linked here when it opens.

  6. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Progress: PR #300 opened: examples/data-dir and guide note for the {env: DATA_DIR} pattern; the deferred default stays on the decisions list.

  7. removed
    in-progress
    on Sep 20, 2026
  8. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Docs part shipped in #300 (examples/data-dir and the guide note). The optional default on {env: NAME} stays deferred pending more evidence, so this issue stays open.

  9. jimhoyd commented on Sep 22, 2026

    @jimhoyd
    CollaboratorAuthor

    Checked the current implementation before proposing a shape: env already supports two shapes today — {value: "literal"} and {env: "HOST_VAR_NAME"} (host pass-through), resolved at compile time, with host pass-through gated by an explicit per-route operator allowlist (permissions.routes[pattern].env). So the "secrets leaking" concern is already handled by that existing gate — no new trust boundary needs designing.

    Proposed schema: extend the existing env field instead of introducing new vocabulary (like a from key). Let value and env both be optional on the same object, with at least one required:

    env:
      NAME:
        value: "default-literal"   # optional fallback
        env: "HOST_VAR_NAME"       # optional: prefer this host var when set

    Resolution: if the named host var is set, use it; otherwise fall back to value. The existing per-route permission check still applies only when env is set — unchanged.

    Code to touch: the env schema (merge the two current mutually-exclusive branches into one object with anyOf requiring ≥1 of value/env), the corresponding TS type, and the small resolution block in router.ts. Small, contained change — no new security surface.

    Data-directory-per-environment: this part needs no code at all — startServer({dataDir}) / URLCODE_DATA_DIR auto-grant / the env: {DIR: {env: 'URLCODE_DATA_DIR'}} pattern already exist and are documented in docs/READINESS.md. It just isn't surfaced anywhere an author would think to look — recommend a short callout in the YAML reference or recipes doc pointing at that section, rather than new capability.

  10. added 2 commits that reference this issue on Sep 22, 2026
  11. added a commit that references this issue on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-firstenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions