Skip to content

feat(temporal): resolve func-returning-constant dispatch names#87

Open
avfirsov wants to merge 1 commit into
zzet:mainfrom
avfirsov:feat/temporal-funcconst-dispatch
Open

feat(temporal): resolve func-returning-constant dispatch names#87
avfirsov wants to merge 1 commit into
zzet:mainfrom
avfirsov:feat/temporal-funcconst-dispatch

Conversation

@avfirsov

Copy link
Copy Markdown
Contributor

What

Resolves Temporal dispatch where the activity/workflow name comes from a function that returns a string constant:

func GetChargeActivityName() string { return "ChargeActivity" }
workflow.ExecuteActivity(ctx, constants.GetChargeActivityName())

Today the call-expression argument yields no name and the dispatch stays unresolved. This resolves it to the registered ChargeActivity.

How — reuse the existing const-deref machinery

No new resolver pass and no new meta keys. It plugs into the constant-value sidecar + const-deref step that already resolves const X = "Y" dispatch names:

  • extractor records any func/method whose body is a single return "<literal>" into result.ConstValues (the same sidecar already used for string consts), keyed by the func node id;
  • goTemporalNameFromExpr learns call_expression: a call-expr dispatch arg yields the callee function name (pkg.GetX() / GetX()"GetX");
  • buildConstDerefMap now also considers KindFunction / KindMethod candidates, so the existing deref step maps "GetX""ChargeActivity" → registered handler.

Scope

  • Only func-returning-constant resolution. Wrapper-following / executor-field / cross-language / env-default are untouched.

Tests

  • extractor unit (ConstValue emitted for the const-returning func; call-expr dispatch arg → temporal_name == "GetX", incl. pkg.Get…()),
  • resolver unit (deref of a function node's sidecar value → resolved edge),
  • end-to-end index→resolve test on real Go source.

go build ./... and go test -race ./internal/resolver/... ./internal/parser/languages/... ./internal/indexer/... pass.

🤖 Generated with Claude Code

Resolve Temporal dispatch where the activity/workflow name comes from a
function that returns a string constant:

    func GetChargeActivityName() string { return "ChargeActivity" }
    workflow.ExecuteActivity(ctx, constants.GetChargeActivityName())

Reuses the existing constant-value sidecar + const-deref path rather than
adding a new resolver pass or meta keys:

- extractor records any func/method whose body is a single `return "lit"`
  into `result.ConstValues` (the same sidecar already used for string
  consts), keyed by the func node id;
- `goTemporalNameFromExpr` learns `call_expression`: a call-expr dispatch
  arg yields the callee func name (`pkg.GetX()` / `GetX()` -> "GetX");
- `buildConstDerefMap` now also considers KindFunction / KindMethod
  candidates, so the existing deref step maps "GetX" -> "ChargeActivity"
  -> registered handler.

Wrapper-following / executor-field / cross-language / env-default untouched.

Tests: extractor (ConstValue emission + call-expr name), resolver deref,
and an end-to-end index→resolve test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@avfirsov avfirsov marked this pull request as ready for review June 14, 2026 08:44
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