Skip to content

describe: no eval hint on assignment results - #313

Merged
vito merged 1 commit into
mainfrom
assign-no-eval-hint
Nov 13, 2026
Merged

vito merged 1 commit into
mainfrom
assign-no-eval-hint

Conversation

@vito

@vito vito commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Problem

Agents run Dang snippets through the Dagger engine's DangEval tool, which calls Session.Check, Snippet.Eval, then dang.Describe on the result. For a lazy GraphQL handle, Describe adds:

(not evaluated; select a field such as .sync or .stdout to run it)

That hint is wrong when the snippet ends in an assignment the engine writes back, e.g. chat = editor.install(…) or ws = ws.withChanges(…). There the assignment is the whole point, and the engine applies it. While dogfooding, agents kept reading the hint as an instruction and adding .sync anyway.

Fix

The fix is in Dang only, with no engine change:

  • GraphQLValue gets an Assigned bool field, which Describe checks to skip the hint.
  • Snippet.Eval returns a copy of its result with Assigned set when the snippet's last form is a Reassignment whose root binding (x in x = … or x.f = …) existed before the snippet, i.e. the snippet didn't declare it. The binding the assignment stored stays unmarked, so reading x later still shows the hint.
  • The mark comes from the snippet's syntax. Reassignment.Eval is unchanged, so:
    • a function whose body ends in an assignment doesn't pass the mark to its callers;
    • a snippet that ends with let c = …; c = c.withExec(…) keeps the hint, since nothing ran and the local goes away with the snippet.
  • Selecting off a handle builds a fresh GraphQLValue, so the mark never spreads. Nothing else reads the mark: equality, IDs and forcing ignore it.

Tests in describe_test.go cover:

  • an assignment's result has no hint;
  • reading the variable back still has the hint;
  • a handle selected off the assignment still has the hint;
  • assigning a snippet-local still has the hint;
  • a function whose body ends in an assignment still has the hint;
  • the list-handle variant.

Caveat

"Binding from before the snippet" stands in for "a binding the caller writes back". These can differ: if a one-shot session assigns one of the module's own top-level bindings (ctr = ctr.withExec(…) with Module.Eval), the result also loses the hint, even though the write is thrown away with the session. Fixing that exactly would need the caller to say which names it writes back (e.g. a set of names on Session). That means an engine change, so this PR leaves it out. At worst the effect is a missing hint.

Agents run snippets through DangEval, which describes the snippet's result.
For a snippet ending in an assignment like `chat = editor.install(...)` or
`ws = ws.withChanges(...)`, that result is a lazy GraphQL handle, and
Describe said it was "not evaluated" and to select .sync. But the assignment
was the point, and the engine applies it; dogfooding showed agents adding
.sync anyway.

Snippet.Eval now returns a copy of the handle marked Assigned when the
snippet's last form assigns a binding from before the snippet, and Describe
leaves the hint out for it. The mark is decided from the snippet's syntax,
not set by Reassignment.Eval, so a function whose body ends in an assignment
doesn't pass it on to callers; and an assignment to the snippet's own local,
which runs nothing, keeps the hint. The stored binding stays unmarked.

Signed-off-by: Alex Suraci <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Deploying dang with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3ba0a1d
Status: ✅  Deploy successful!
Preview URL: https://0af3af81.dang-3kk.pages.dev
Branch Preview URL: https://assign-no-eval-hint.dang-3kk.pages.dev

View logs

@vito
vito force-pushed the assign-no-eval-hint branch from d6db8c8 to 3ba0a1d Compare November 13, 2026 21:37
@vito
vito merged commit 2918064 into main Nov 13, 2026
11 checks passed
vito added a commit to dagger/dagger that referenced this pull request Nov 13, 2026
v2.5.0 is the tagged release of what the stack pinned as a pseudo-version.
What matters here:

- Language version 2.5 (dang.CurrentVersion, so DangEval/DangCheck
  snippets in the default scope): "..." and """...""" interpolate ${...},
  """ strings take escapes and a language tag, '...' is verbatim, and text
  on the opening line of a multi-line string is an error.
- A snippet ending in an assignment to a binding from outside it (ws, a
  tool object, chat) no longer prints the "(not evaluated…)" hint
  (vito/dang#313); assert that in the unit and integration tests.
- Dang interfaces are structural, at every version.
- Tree-sitter runs as WebAssembly, so Dang needs no cgo: go mod tidy drops
  go-tree-sitter and its grammars.
- The embedded dang-language skill now documents 2.5.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit to dagger/dagger that referenced this pull request Nov 14, 2026
v2.5.0 is the tagged release of what the stack pinned as a pseudo-version.
What matters here:

- Language version 2.5 (dang.CurrentVersion, so DangEval/DangCheck
  snippets in the default scope): "..." and """...""" interpolate ${...},
  """ strings take escapes and a language tag, '...' is verbatim, and text
  on the opening line of a multi-line string is an error.
- A snippet ending in an assignment to a binding from outside it (ws, a
  tool object, chat) no longer prints the "(not evaluated…)" hint
  (vito/dang#313); assert that in the unit and integration tests.
- Dang interfaces are structural, at every version.
- Tree-sitter runs as WebAssembly, so Dang needs no cgo: go mod tidy drops
  go-tree-sitter and its grammars.
- The embedded dang-language skill now documents 2.5.

Signed-off-by: Alex Suraci <[email protected]>
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