Skip to content

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

Merged
zzet merged 1 commit into
zzet:mainfrom
avfirsov:feat/temporal-funcconst-dispatch
Jun 15, 2026
Merged

feat(temporal): resolve func-returning-constant dispatch names#87
zzet merged 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

@avfirsov
avfirsov marked this pull request as ready for review June 14, 2026 08:44
@avfirsov
avfirsov force-pushed the feat/temporal-funcconst-dispatch branch from c73279a to 49c40f0 Compare June 14, 2026 16:46
@zzet

zzet commented Jun 14, 2026

Copy link
Copy Markdown
Owner

@avfirsov needed a rebase against the main branch

@avfirsov
avfirsov force-pushed the feat/temporal-funcconst-dispatch branch from 49c40f0 to 12e43b5 Compare June 14, 2026 20:01
@avfirsov

Copy link
Copy Markdown
Contributor Author

@zzet rebased onto current main. The only conflicts were in the two temporal test files (overlap with #85's added tests) — resolved by keeping both suites. Code files merged cleanly. go build ./... + temporal tests (resolver / parser / indexer) green locally. mergeable: MERGEABLE.

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 force-pushed the feat/temporal-funcconst-dispatch branch from 12e43b5 to 9884c0c Compare June 15, 2026 04:31
@zzet
zzet merged commit 5353164 into zzet:main Jun 15, 2026
9 checks passed
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.

2 participants