Skip to content

feat(planner): SG3 — bind omitted secret ref dimensions from the job's scope - #807

Merged
vijayakrishnans merged 1 commit into
mainfrom
orun-sg3-contextual-binding
Nov 8, 2026
Merged

vijayakrishnans merged 1 commit into
mainfrom
orun-sg3-contextual-binding

Conversation

@vijayakrishnans

Copy link
Copy Markdown
Contributor

What

SG3 from specs/orun-scope-engine: the CLI fills in a secret reference's omitted workspace, project and env from the job's own scope when it builds the plan.

secretEnv:
  CLOUDFLARE_API_TOKEN: "secret://CLOUDFLARE_API_TOKEN"             # → secret://<ws>/project:<repo>/env:<this env>/CLOUDFLARE_API_TOKEN
  WIRING_CLOUDFLARE_KV_PROD: "secret://env:prod/WIRING_CLOUDFLARE_KV" # env stays prod

Why

The short form has parsed since SG1, but was sent unbound, and the server refuses any reference that doesn't pin workspace, project and env. So every baseline hard-codes its own name as the workspace (secret://agent-visibility/agent-visibility/...). Built into a workspace with any other name, it fails:

Ref workspace "agent-visibility" does not name this run's workspace (code: validation_failed)

That's what happened building agent-visibility into the makan workspace (vijayakrishnans/agent-visibility, run 42372324428). The console's secret pages already tell people to write secret://KEY, which until now didn't work in a run.

Nothing that works today changes

  • Fully pinned references keep their authored spelling, so their plan digest doesn't move. Planning vijayakrishnans/makan with main and with this branch gives identical jobs.
  • No scope to bind from (an unlinked repo planned offline): the reference is kept as authored instead of failing the plan.
  • An authored dimension is never overridden, and the server still verifies workspace and project against the run, so nothing widens.
  • The server, the stored secrets, and composition secretBindings are untouched. The component dimension is left to the lease.

Verified

  • go test ./... passes. New tests cover bindContext (fully contextual, env-pinned, workspace-wide, version, authored-workspace, already-pinned, no scope), secretEnv, optionalSecretEnv, and a contextual entry agreeing with a binding.
  • vijayakrishnans/agent-visibility, with its refs shortened, plans with every ref bound to org_5a63…/project:agent-visibility/env:<env>, including both WIRING_* cross-environment refs.

Not in this PR

  • The {{…}} reference-slot deprecation warning from the SG3 plan.
  • Baselines switching to the short form. That follows once this ships in a release, together with bumping each baseline's pinned orun version.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LBnxs7fMsmZeU9WRJwYtuj

…s scope

`secret://KEY` and `secret://env:prod/KEY` parsed since SG1 but were sent to
the server unbound, which refuses any reference that does not pin workspace,
project and env. Baselines therefore hard-coded their own name as the
workspace, so a baseline built into a workspace with a different name (for
example agent-visibility in makan) failed with "Ref workspace ... does not
name this run's workspace".

bindContext now fills the omitted workspace, project and env of every
secretEnv and optionalSecretEnv reference when the plan is built, from the
same scope the composition secretBindings already use. It never overrides
an authored dimension and never widens: the server still receives a fully
pinned reference and still checks it against the run.

Nothing that works today changes:
- a fully pinned reference keeps its authored spelling, so its plan digest
  is unchanged (makan's plan is byte-identical before and after);
- with no workspace or project to bind from, the reference is kept as
  authored instead of failing the plan;
- the server and stored secrets are untouched.

The reference-slot {{...}} deprecation warning from the SG3 plan is left
for a follow-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBnxs7fMsmZeU9WRJwYtuj
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T05:34:47.324812Z e6c3fc9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: e6c3fc932f

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

merged := make(map[string]string, len(secretEnv)+len(bindings))
for k, v := range secretEnv {
merged[k] = v
bound, ok, err := bindContext(v, workspace, project, env)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bind workflow grant refs with the job refs

When a workflow step’s connections grant and the job’s secretEnv declare the same contextual secret, this binds only the job ref; renderConnections leaves the grant as secret://KEY. The runner matches grants to job.SecretRefs by exact ref, so buildConnectionPayloads then fails with a grant-not-among-job-refs error. Bind the workflow grant through the same context too, or normalize it during lookup.

Useful? React with 👍 / 👎.

Comment on lines +225 to +226
if ref.Workspace == "" {
ref.Workspace = workspace

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bind from the effective CLI workspace context

When execution.state.workspace is omitted but the workspace comes from ORUN_WORKSPACE, a repo link, or orun workspace use, the CLI passes an empty workspace here: generatePlan initializes JobPlanner.Workspace from intentScope(intent) only. bindContext therefore leaves secret://KEY unbound, and the run still sends a ref missing the workspace that the backend requires. Pass the effective workspace and project scope into the planner before binding contextual refs.

Useful? React with 👍 / 👎.

@vijayakrishnans
vijayakrishnans merged commit 362b1d9 into main Nov 8, 2026
13 checks passed
pullely pushed a commit that referenced this pull request Dec 1, 2026
feat(planner): SG3 — bind omitted secret ref dimensions from the job's scope
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.

1 participant