feat(app): drop production outbox and approval hook registration
Durable notify/advance/projection are live on shared dev, so composition roots must not assign OnOutbox or AddOnApprovedHook. Bind helpers remain for tests and a rollback window. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+3
-9
@@ -201,22 +201,16 @@ func (r *Runtime) bindDocumentNotify() {
|
||||
if r == nil || r.notifyBound {
|
||||
return
|
||||
}
|
||||
if r.Biz != nil && r.Rev != nil {
|
||||
if docnotify.Bind(r.Rev, r.DocNotify) {
|
||||
r.subscribers++
|
||||
}
|
||||
}
|
||||
// Durable notify is live; do not assign OnOutbox in production.
|
||||
r.notifyBound = true
|
||||
}
|
||||
|
||||
func (r *Runtime) bindWorkflowApprovalHook() {
|
||||
if r == nil || r.hookBound || r.Gov == nil || r.Inst == nil || !r.Inst.Available() {
|
||||
r.hookBound = true
|
||||
if r == nil || r.hookBound {
|
||||
return
|
||||
}
|
||||
r.Gov.AddOnApprovedHook(r.onWorkflowDocumentApproved)
|
||||
// Durable workflow_advance is live; do not register AddOnApprovedHook in production.
|
||||
r.hookBound = true
|
||||
r.subscribers++
|
||||
}
|
||||
|
||||
// WriterLive reports whether the durable consumer already owns the visible write.
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestProductionCompositionHasNoHookRegistration(t *testing.T) {
|
||||
root := findGoMod(t)
|
||||
files := []string{
|
||||
filepath.Join(root, "internal", "app", "app.go"),
|
||||
filepath.Join(root, "internal", "server", "workflow_approval_hook.go"),
|
||||
filepath.Join(root, "internal", "server", "server.go"),
|
||||
}
|
||||
for _, f := range files {
|
||||
b, err := os.ReadFile(f)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
src := string(b)
|
||||
if strings.Contains(src, "OnOutbox =") {
|
||||
t.Fatalf("%s still assigns OnOutbox", f)
|
||||
}
|
||||
if strings.Contains(src, "AddOnApprovedHook(") {
|
||||
t.Fatalf("%s still registers AddOnApprovedHook", f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func findGoMod(t *testing.T) string {
|
||||
t.Helper()
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for {
|
||||
if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil {
|
||||
return dir
|
||||
}
|
||||
parent := filepath.Dir(dir)
|
||||
if parent == dir {
|
||||
t.Fatal("go.mod not found")
|
||||
}
|
||||
dir = parent
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,9 @@ import (
|
||||
)
|
||||
|
||||
func (s *Server) registerWorkflowApprovalHook() {
|
||||
if s == nil || s.gov == nil || s.instSvc == nil || !s.instSvc.Available() {
|
||||
return
|
||||
}
|
||||
s.gov.AddOnApprovedHook(s.onWorkflowDocumentApproved)
|
||||
// Durable workflow_advance is the unique writer. Keep the method for one
|
||||
// rollback window; do not register AddOnApprovedHook in production.
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Server) onWorkflowDocumentApproved(ctx context.Context, doc *docgov.DocumentRecord) {
|
||||
|
||||
Reference in New Issue
Block a user