Repository navigation
Analyze cross-package orchestration helpers with orchestratorvet - #197
andystaples wants to merge 3 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the changes extending replay-hazard detection across packages.
No open issues 🎉
What changed in this PR
Extends orchestratorvet to detect replay hazards in statically resolved orchestrators and helpers across packages within the same Go module, addressing #178 while keeping diagnostics rooted in orchestrator registrations.
Changes:
- Adds analysis facts that propagate hazard summaries and representative call paths across imports.
- Supports imported handlers and concrete methods while preserving conservative behavior for unresolved calls.
- Adds cross-package integration coverage, updates benchmarks, and documents the expanded scope and limitations.
| File | Description |
|---|---|
cmd/orchestratorvet/README.md |
Documents cross-package analysis and its limits. |
cmd/orchestratorvet/analysis/orchestratorgo/registration.go |
Records imported orchestrator registration roots. |
cmd/orchestratorvet/analysis/orchestratorgo/reach.go |
Enumerates local and imported call targets. |
cmd/orchestratorvet/analysis/orchestratorgo/index.go |
Resolves imported functions and handles ambiguous function values conservatively. |
cmd/orchestratorvet/analysis/orchestratorgo/facts.go |
Builds and propagates same-module hazard summaries. |
cmd/orchestratorvet/analysis/orchestratorgo/facts_test.go |
Tests cross-package diagnostics and excluded call paths. |
cmd/orchestratorvet/analysis/orchestratorgo/checks.go |
Adds hazard collection without local fixes or registry-dependent checks. |
cmd/orchestratorvet/analysis/orchestratorgo/bench_test.go |
Updates benchmarks to exercise summary construction. |
cmd/orchestratorvet/analysis/orchestratorgo/analyzer.go |
Integrates fact export and imported-hazard reporting. |
Review effort: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Importer reassignment of exported package variables only matters for cross-package summaries. Restrict that exclusion to fact construction so same-package registrations and calls through exported variables are still analyzed as before. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Bernd Verst (berndverst)
left a comment
There was a problem hiding this comment.
The fact-based approach works for direct imports and transitive helpers, including when vet only targets the registration package. I would fix the false positive below before merging: a seed set to a constant before orchestration still causes go vet to fail. The range-over-function case is separate and non-blocking; please either follow statically known iterators or document the limit.
| if node.Op == token.AND { | ||
| if id, ok := ast.Unparen(node.X).(*ast.Ident); ok { | ||
| if variable, ok := pass.TypesInfo.ObjectOf(id).(*types.Var); ok { | ||
| if mayHoldFunction(variable.Type()) { |
There was a problem hiding this comment.
The address-taken check only invalidates function values, but exported facts also use singleValue to prove a random seed. A helper can expose the seed through a pointer:
var seed = time.Now().UnixNano()
var Seed = &seed
func Roll() int {
r := rand.New(rand.NewSource(seed))
return r.Int()
}If the registration package sets *helper.Seed = 123 in init, each orchestration call to helper.Roll() creates a fresh RNG with the same seed. I reproduced a nondeterministic-seed diagnostic and a failing go vet on this revision. Can we treat address-taken seed values as unknown when exporting summaries and cover this in the integration fixture?
| } | ||
|
|
||
| func (index *packageIndex) forEachTarget(node ast.Node, visit func(token.Pos, functionTarget)) { | ||
| forEachOwnedCall(node, func(call *ast.CallExpr) { |
There was a problem hiding this comment.
Non-blocking: forEachOwnedCall only sees explicit calls. A registered orchestrator using for range helper.Iter {} still invokes that statically known iterator, but vet misses a time.Now() inside it. Calling the same helper explicitly with helper.Iter(func(int) bool { return true }) is covered. Could we follow statically resolved iterators in range expressions, or document this limitation in the README?
orchestratorvetnow follows statically resolved calls into other packages in the same Go module, including orchestrator handlers passed directly to a registry from an import. Go analysis facts carry replay-hazard summaries through imports. Diagnostics stay rooted in orchestrator registrations and show a representative call path at the local registration or call site; code used only by activities does not produce a diagnostic.The analyzer does not follow dynamic dispatch or cross-module calls, offer fixes for imported code, or expand its registry-name or loop-progress checks.
Closes #178.