Skip to content

feat(temporal): variable-tracing, const-to-const & exact-name signature dispatch - #98

Merged
zzet merged 3 commits into
zzet:mainfrom
avfirsov:pr/temporal-vartrace
Jun 15, 2026
Merged

feat(temporal): variable-tracing, const-to-const & exact-name signature dispatch#98
zzet merged 3 commits into
zzet:mainfrom
avfirsov:pr/temporal-vartrace

Conversation

@avfirsov

Copy link
Copy Markdown
Contributor

What

Three additional Go Temporal dispatch fallbacks, for dispatch names that aren't a direct string literal:

  1. Variable tracingact := "ChargeActivity"; workflow.ExecuteActivity(ctx, act) traces a local var back to its assigned value: a string literal, a package-level const reference, or a no-arg func returning a single literal/const (goTemporalVarTrace, goTemporalFuncReturnName).
  2. Const-to-const aliasconst ALIAS = RealName chains are followed (bounded fixpoint over the constant_values sidecar) so dispatch via an alias resolves to the underlying name.
  3. Exact-name signature-match fallback — an unregistered PascalCase dispatch name that exactly matches an exported func whose signature matches the kind (activity → context.Context, workflow → workflow.Context), and is unique, lands at the hidden speculative tier (OriginSpeculative 0.45, var_trace/exact-sig tagged) so it's available on opt-in without polluting default queries.

Why

Real Temporal code frequently names activities/workflows through a local var, a const alias, or a convention-named function rather than an inline literal — these previously stayed broken_dispatch.

Porting notes (onto post-#82/#85/#86 main)

Main rewrote the const/func resolution machinery this feature was built on, so it was re-implemented against main's current structure (not mechanically cherry-picked):

  • const handling moved to the constant_values sidecar (ConstantValueReader / buildConstDerefMap); the var-trace const case emits the traced const name and lets buildConstDerefMap dereference it; the alias case extends buildConstDerefMap to chase const_ref hops.
  • lookupExactSig is a sibling of main's 4-arg lookup, gated on signatureMatchesKind + a cross-repo _test.go drop.
  • The removed func-returning-name channel was not revived; the var-trace func case resolves the callee's single returned literal/const in-parser instead.

Two precision guards were added to respect main's existing invariants (both verified against main-side tests): var-trace fires only on a single-assignment var (EnvDefaultOverwrittenNotFlagged), and the bare-identifier case admits only package-level file consts (PlainVarNotEnvDefault).

Tests

New: temporal_vartrace_test.go, temporal_allcaps_test.go, temporal_pascalcase_test.go (literal/const/func trace, alias chains, exact-sig with signature/kind-mismatch abstention) — all #85/#86 tests kept. go build ./..., go vet, resolver/parser/indexer suites pass. (Pre-existing unrelated internal/hooks deny-path failures need a live daemon; reproduce on main.)

…, exact-name signature match

Implements the three resolver categories assigned to the external agent in docs/design/05 §9, reducing broken_dispatch beyond the worker-runner work.

Cat 2 (variable tracing, meta_vars): goTemporalVarTrace traces a bare-variable dispatch name (name := <value>; ExecuteActivity(ctx, name)) to its last intra-procedural assignment — string literal, const reference, or no-arg const-returning func — feeding the existing temporal_name / temporal_default_const / temporal_name_func channels (resolver validates via constVal, so precision-safe). Const-default emission is ungated from the env-default block. A no-arg guard keeps env-helper-style calls (with args) out of the const-getter path.

Cat 3 (ALL_CAPS const): adds const-to-const alias resolution (const ALIAS = RealName) — parser records Meta["const_ref"] (goConstRefName), buildTemporalIndex resolves aliases against constVal by bounded fixpoint. Direct/block-form consts already resolved.

Cat 4 (PascalCase exact-name): lookupExactSig resolves a PascalCase dispatch onto a same-named, unregistered, non-suffixed function ONLY when its signature matches the kind (activity->context.Context / workflow->workflow.Context) and the candidate is unique; speculative + hidden. Fuzzy precision deliberately not loosened.

Tests: temporal_vartrace_test.go, temporal_allcaps_test.go, temporal_pascalcase_test.go (incl. precision/abstention guards). Full temporal suites + build + vet green under -race; no regression. Corpus re-measurement is the corp agent's (no corpus access externally).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@avfirsov
avfirsov force-pushed the pr/temporal-vartrace branch from de82f4a to 38c8f1a Compare June 15, 2026 06:30
zzet added 2 commits June 15, 2026 20:45
goAssignRHSExpr returned the first RHS expression regardless of which LHS
target matched, so a parallel assignment like `x, name := "foo", "Charge"`
traced "foo" for a dispatch via name. Match the RHS position to the target
position; refuse multi-value calls (`a, b := f()`) that have no per-target
literal.
Reconcile var-trace / const-alias / exact-name signature dispatch (zzet#98) with
the convention (zzet#89) and env-helper (zzet#90) tiers now on main:
- resolution ladder keeps exactSig (speculative) after the cross-language
  join; the env-default tier-override now also covers var_trace origins and
  preserves zzet#90's source-tiering (allowlist/os_getenv/const_ref stay visible)
- single temporal_resolution_via stamp (exact_sig | convention) instead of two
  blocks that clobbered each other
- fold the funcExact (zzet#98) and funcByName (zzet#89) indexes into one node sweep
- goConstLiteralValue: keep main's grouped-const selection (drop zzet#98's
  equivalent duplicate)
- lookupConvention drops cross-repo *_test.go stubs (matches main's fix)
- regression test for parallel-assignment var-trace (x, act := _, "Name")
@zzet
zzet merged commit 758226b into zzet:main Jun 15, 2026
8 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