Skip to content

GOL-1268: Teach ctx.caller in the docs, skills and templates - #4691

Open
Aditya1404Sal wants to merge 21 commits into
mainfrom
aditya/gol-1268-sdk-docs-and-skills-for-ctxcaller
Open

Aditya1404Sal wants to merge 21 commits into
mainfrom
aditya/gol-1268-sdk-docs-and-skills-for-ctxcaller

Conversation

@Aditya1404Sal

@Aditya1404Sal Aditya1404Sal commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Part of GOL-1268: the docs, skills, templates and SDK readmes. The home page snippets follow in a second PR.

On a request to add HTTP auth to a TypeScript agent, a coding agent that loads the skill golem-add-http-auth-ts was told to read the caller with s.principal() and this.getPrincipal(). The 2.0 SDKs have neither, so the code did not build, and no docs page or skill showed ctx.caller.

What changes

Every page, skill and template that a user or a coding agent reads now teaches the 2.0 API: a handler reads ctx.caller in the form of its SDK, and stores ctx.caller.original.ref, a PrincipalRef, when it must remember who called. The forms come from each SDK's own build error for a principal in a signature.

SDK         before (1.6)                                  now (2.0)
TypeScript  input { caller: s.principal() }, getPrincipal  handler (input, ctx): ctx.caller
Effect      Principal.PrincipalSchema, Principal.Principal  (yield* InvocationContext.InvocationContext).caller
Rust        fn f(&self, principal: Principal)              fn f(&self, ctx: InvocationContext): ctx.caller()
Scala       def f(principal: Principal)                    def f(context: InvocationContext): context.caller
MoonBit     principal : Principal                          ctx : @agents.InvocationContext: ctx.caller()
Go          Principal golem.Principal field, ctx.Principal  ctx.Caller()

Two rules were also wrong, not only the names:

  • Read-only caching. The pages said "no Principal parameter: one shared cache entry and Cache-Control: public". The executor keys every read-only result on the full caller, and an authenticated request always gets a private response. The pages now say so, and a read-only handler reads ctx.caller like any other handler.
  • Snapshots. The pages said the restore context holds "the restored principal" and the envelope is {version: 1, principal, state}. 2.0 writes {version: 2, state} and drops the principal of a 1.6 envelope on read.

Files

  • docs/src/content/next/: 8 hand-written pages (authentication, custom APIs, read-only methods, CLI invocation, snapshotting, reflection, artifacts, router semantics).
  • golem-skills/skills/: 54 skills, and the 54 how-to pages generated from them with cargo make generate-docs-skills. The Rust and Scala auth skills had no section on the caller; they now have one.
  • cli/golem-cli/templates/ts/common/AGENTS.md (copied into every new TypeScript app) and its two copies in test-components/fault-matrix-ts and sdks/effect/integration-test/cross-sdk.
  • SDK readmes: a "Caller identity" section for Rust, Scala and MoonBit; corrections in the TypeScript readme (getPrincipal is no longer a reserved state field), the Effect AGENTS.md and the Scala snapshot doc.
  • .agents/skills/migrate-ts-decorator-sdk and test-data/snapshot-multipart/README.md.

Tests

  • docs/snippets/removed-caller-apis.test.ts (new) fails when docs/src/content/next/, golem-skills/skills/ or cli/golem-cli/templates/ shows a removed 1.6 API: getPrincipal, s.principal(), PrincipalSchema, Principal.Principal, a principal parameter or field, uses_principal, "per-principal" caching. A second test checks the patterns against 1.6 and 2.0 lines.
  • docs/snippets/public-examples.test.ts now type-checks the TypeScript and Effect samples of authentication.mdx and read-only-methods.mdx against the in-tree SDKs. A wrong new sample, for example ctx.caller() in TypeScript (a property, not a method), fails there.
  • Both tests failed before the changes.

Checks

Local, on macOS. The first two checks ran at 3cbd8ceeab, the merge of main 663d3034c7. The sample checks below them ran at earlier commits of this PR, and the sample code has not changed since:

  • bun run build:check in docs/ (lint, format, tsc, link check, tooling tests): green.
  • cargo make check-docs-skills: the how-to pages match the skills.
  • The Rust samples compile against golem-rust (cargo test --no-run with export_golem_agentic). A Principal parameter put in their place fails with the SDK's build error.
  • The Go samples pass go vet for wasip1 against sdks/go/golem.
  • The TypeScript and Effect samples of the skills type-check against the in-tree SDKs.
  • The Scala and MoonBit samples are not compiled here. They follow each SDK's sources and its own examples.

Note: those older sample checks ran against the SDKs of their time. Main has since changed the SDKs, but not in the caller APIs that the samples use.

🤖 Generated with Claude Code

@netlify

netlify Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for golemcloud canceled.

Name Link
🔨 Latest commit 3cbd8ce
🔍 Latest deploy log https://app.netlify.com/projects/golemcloud/deploys/6b0cfc5c4863d3ccffb4ba02

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

📖 Docs preview: https://docs-cn4wj1mmm-golem-cloud.vercel.app

Built from commit 3cbd8ceeab1caf4351958f3b9498b5d396e561f1 by docs.yaml.

@Aditya1404Sal
Aditya1404Sal marked this pull request as ready for review November 29, 2026 21:24
@Aditya1404Sal
Aditya1404Sal requested a review from a team November 29, 2026 21:24

This branch has not been deployed

No deployments
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