Files
tasks/pkg/sdk/workflow/channel_sealed_test.go
zeekay ad7af646a6 fix(workflow): seal Channel / ReceiveChannel interfaces (R2.3)
Both interfaces now carry an unexported sentinel method sealed() so
external packages cannot implement them. A fork that shadows the
workflow package will fail to satisfy the interface at compile
time, preventing silent divergence in selector / coroutine-scheduler
semantics.

The worker package's signalChan wrapper had to go — it lived
outside the workflow package and so cannot satisfy sealed().
Replaced with workflow.NewSignalChannel(name, buffer), which
returns the canonical sealed chanImpl directly. The name is
carried on the channel itself, so the wrapper was cosmetic.

Added pkg/sdk/workflow/channel_sealed_test.go asserting the
canonical impl satisfies the sealed interfaces.
2026-04-23 20:33:00 -07:00

29 lines
1.0 KiB
Go

// Copyright (c) Hanzo AI Inc 2026.
package workflow
import "testing"
// TestChannelSealed is a compile-time / runtime proof that the
// ReceiveChannel interface is sealed: only types in this package can
// satisfy it. Any external type that attempts to implement the
// interface will fail to compile because the unexported sealed()
// method is not reachable.
//
// This test asserts the positive case — the canonical chanImpl
// satisfies it — and documents the sealing invariant for reviewers.
// A negative-case "forked type should not satisfy" check would live
// in an _external_test.go that imports workflow as a different
// package; that file would fail to compile by design and so is not
// checked in.
func TestChannelSealed(t *testing.T) {
var _ ReceiveChannel = (*chanImpl)(nil)
var _ Channel = (*chanImpl)(nil)
var _ Channel = NewSignalChannel("s", 1)
// Seal enforcement is a compile-time property; assert the method
// is callable on the impl so the coverage counter lights up.
c := newChan("x", 1)
c.sealed()
}