Skip to content

Commit f352561

Browse files
committed
refactor(daemon): satisfy daemonapi.Daemon via adapter; alias contract types
Wraps *Daemon with a daemonAPIAdapter that satisfies daemonapi.Daemon without changing the daemon engine's internal *Connection-typed signatures. cmd/daemon passes d.DaemonAPI() to daemonapi.LoadAll; plugins receive the adapter and never see the concrete daemon types. Why an adapter rather than touching every internal signature: the daemon's own code does dozens of calls like 'conn, err := d.DialConnection(...)' where the returned *Connection is then passed back through other typed methods. Coercing those onto daemonapi.Connection (which is interface{}) would have meant type-assertions at every call site inside pkg/daemon. The adapter contains the type-assertions in one file, keeps the daemon engine's internal typing intact, and presents the daemonapi shape externally. Also done in this commit: - pkg/daemon/contract.go: rewritten as type aliases to daemonapi (TrustChecker, HandshakeService, PolicyManager, PolicyRunner, WebhookManager, plus the *Record / WebhookStats structs). The aliases preserve daemon-local short names so existing pkg/daemon code keeps compiling unchanged. - pkg/daemon/eventbus_impl.go: Event is now a type alias to daemonapi.Event so Bus().Subscribe() returns the channel type daemonapi.EventBus requires. - pkg/daemon/zz_daemonapi_conformance.go: defines the adapter + Compile-time 'var _ daemonapi.Daemon = daemonAPIAdapter{}' assertion. When the interface grows or a method signature changes, this assertion fails with a precise error. - pkg/daemon/daemon.go: Bus() return type changed to daemonapi.EventBus. Includes the import sweep + duplicate-package deletion that was on the parallel web4-cleanup-after-common-extraction branch (PR #152): - All TeoSlayer/pilotprotocol/pkg/X imports → pilot-protocol/common/X - pkg/{coreapi,protocol,driver,config,logging,urlvalidate,secure, registry/client,registry/wire} and internal/ipcutil DELETED. - go.mod gains replace directives for every sibling so dev builds resolve against local checkouts. Builds: go build ./... passes for the entire web4 module. Plugins (handshake/runtime/libpilot) still build against the old pkg/daemon API in their current branches — Phase 3 of this refactor migrates them off.
1 parent ad6ed06 commit f352561

274 files changed

Lines changed: 472 additions & 17374 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/daemon/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import (
1515
"syscall"
1616
"time"
1717

18-
"github.com/TeoSlayer/pilotprotocol/pkg/config"
1918
"github.com/TeoSlayer/pilotprotocol/pkg/daemon"
20-
"github.com/TeoSlayer/pilotprotocol/pkg/driver"
21-
"github.com/TeoSlayer/pilotprotocol/pkg/logging"
19+
"github.com/pilot-protocol/common/config"
20+
"github.com/pilot-protocol/common/driver"
21+
"github.com/pilot-protocol/common/logging"
2222

2323
// L11 plugin imports — cmd/daemon (L12) is the only place these
2424
// are allowed. The daemon proper imports only pkg/coreapi

cmd/pilotctl/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import (
2121
"syscall"
2222
"time"
2323

24-
"github.com/TeoSlayer/pilotprotocol/pkg/driver"
25-
"github.com/TeoSlayer/pilotprotocol/pkg/protocol"
26-
registry "github.com/TeoSlayer/pilotprotocol/pkg/registry/client"
24+
"github.com/pilot-protocol/common/driver"
25+
"github.com/pilot-protocol/common/protocol"
26+
registry "github.com/pilot-protocol/common/registry/client"
2727
"github.com/pilot-protocol/dataexchange"
2828
"github.com/pilot-protocol/eventstream"
2929
"github.com/pilot-protocol/policy/policylang"

cmd/pilotctl/zz_fake_daemon_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"testing"
1313
"time"
1414

15-
"github.com/TeoSlayer/pilotprotocol/internal/ipcutil"
15+
"github.com/pilot-protocol/common/ipcutil"
1616
)
1717

1818
// IPC cmd codes — must match pkg/driver/ipc.go and cmd/daemon/ipc.go.

cmd/pilotctl/zz_lifecycle_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"testing"
1111

12-
"github.com/TeoSlayer/pilotprotocol/pkg/protocol"
12+
"github.com/pilot-protocol/common/protocol"
1313
)
1414

1515
// withTempHomeFull isolates HOME so config/socket/registry helpers don't

cmd/pilotctl/zz_stream_daemon_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"testing"
1414
"time"
1515

16-
"github.com/TeoSlayer/pilotprotocol/internal/ipcutil"
17-
"github.com/TeoSlayer/pilotprotocol/pkg/protocol"
16+
"github.com/pilot-protocol/common/ipcutil"
17+
"github.com/pilot-protocol/common/protocol"
1818
)
1919

2020
// Round-3 coverage push: drive cmdConnect/cmdSend/cmdRecv/cmdDgram/

go.mod

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ require (
66
github.com/coder/websocket v1.8.14
77
github.com/pilot-protocol/app-store v0.1.0
88
github.com/pilot-protocol/beacon v0.1.0
9-
github.com/pilot-protocol/common v0.4.0
9+
github.com/pilot-protocol/common v0.4.4
1010
github.com/pilot-protocol/dataexchange v0.1.0
1111
github.com/pilot-protocol/eventstream v0.1.0
12-
github.com/pilot-protocol/gateway v0.1.0
1312
github.com/pilot-protocol/handshake v0.1.0
1413
github.com/pilot-protocol/nameserver v0.1.0
1514
github.com/pilot-protocol/policy v0.1.0
@@ -22,7 +21,38 @@ require (
2221

2322
require (
2423
github.com/expr-lang/expr v1.17.8 // indirect
25-
github.com/pilot-protocol/updater v0.2.2-0.20260529065627-220ed5b8383f // indirect
2624
golang.org/x/net v0.55.0 // indirect
2725
golang.org/x/sys v0.45.0 // indirect
2826
)
27+
28+
replace github.com/pilot-protocol/beacon => ../beacon
29+
30+
replace github.com/pilot-protocol/dataexchange => ../dataexchange
31+
32+
replace github.com/pilot-protocol/eventstream => ../eventstream
33+
34+
replace github.com/pilot-protocol/gateway => ../gateway
35+
36+
replace github.com/pilot-protocol/nameserver => ../nameserver
37+
38+
replace github.com/pilot-protocol/policy => ../policy
39+
40+
replace github.com/pilot-protocol/rendezvous => ../rendezvous
41+
42+
replace github.com/pilot-protocol/skillinject => ../skillinject
43+
44+
replace github.com/pilot-protocol/trustedagents => ../trustedagents
45+
46+
replace github.com/pilot-protocol/webhook => ../webhook
47+
48+
replace github.com/pilot-protocol/app-store => ../app-store
49+
50+
replace github.com/pilot-protocol/updater => ../updater
51+
52+
replace github.com/pilot-protocol/common => ../common
53+
54+
replace github.com/pilot-protocol/handshake => ../handshake
55+
56+
replace github.com/pilot-protocol/runtime => ../runtime
57+
58+
replace github.com/pilot-protocol/libpilot => ../libpilot

go.sum

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,6 @@ github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9
22
github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
33
github.com/expr-lang/expr v1.17.8 h1:W1loDTT+0PQf5YteHSTpju2qfUfNoBt4yw9+wOEU9VM=
44
github.com/expr-lang/expr v1.17.8/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
5-
github.com/pilot-protocol/app-store v0.1.0 h1:mMEbr04GURXWuFd4kQBONZZK+AMrXxdVt+IujeySfo8=
6-
github.com/pilot-protocol/app-store v0.1.0/go.mod h1:0fo1XjzzLHmRMGuTc22aOLAseQzms7qM4QXfGilmMWY=
7-
github.com/pilot-protocol/beacon v0.1.0 h1:jXO8duAzzpB8K+9It0QwR9BRupgKZ8IQhuwqy7rqtmk=
8-
github.com/pilot-protocol/beacon v0.1.0/go.mod h1:PejZP5sZ4s5Lrtc0wdYHSEJVc7cn6E8yqo0R4CV+iUo=
9-
github.com/pilot-protocol/common v0.1.0 h1:m8mZZATgeBiFoqhWXPnskw2u0lNkWxHp0IagZK35V1g=
10-
github.com/pilot-protocol/common v0.1.0/go.mod h1:4YZWHK5nhM+4RLmYTspLxxAFbyBII7yzQDAHq3Ul2ck=
11-
github.com/pilot-protocol/common v0.4.0 h1:lH1WdQBU5Zan1rAqF/kYpcJO6vBoYVWXrWUNwMX10jA=
12-
github.com/pilot-protocol/common v0.4.0/go.mod h1:yrAwPXGVMbXU+SADvOCmbdXjK/wJ3uA0KshyLvRlej4=
13-
github.com/pilot-protocol/dataexchange v0.1.0 h1:JJ29lL/LxDd1+szKFoEVxakzT93Tid3zoaAUBVGNKV4=
14-
github.com/pilot-protocol/dataexchange v0.1.0/go.mod h1:mXD17Vh0Eup+M//YhCm4j6D/DyFaZM7JzN5xexBdfLs=
15-
github.com/pilot-protocol/eventstream v0.1.0 h1:uHNTNTMA9MasBBpi2nCRkvFmFvTxbKCk7azPfuILkvY=
16-
github.com/pilot-protocol/eventstream v0.1.0/go.mod h1:sFhEh/YP76Sjhn8kNz7SOvqgk0vaJEIFkXMXAKlPqnY=
17-
github.com/pilot-protocol/gateway v0.1.0 h1:mCbMMO4N7hkkuFELHCaBKGwmGXIeWW6fR8YMS9aEBgk=
18-
github.com/pilot-protocol/gateway v0.1.0/go.mod h1:NvzDHFgPDno8ftTMDeFUnU7yZxXEx/3ds1cX3IN5YV0=
19-
github.com/pilot-protocol/handshake v0.1.0 h1:TmqIglsimTynKtE5hLpCt/SZmmBYs8OCn4qn755fmew=
20-
github.com/pilot-protocol/handshake v0.1.0/go.mod h1:FIIMTgRcMIMEim/1d7F5f6YenJC+3xl53QMEmnnJY+0=
21-
github.com/pilot-protocol/nameserver v0.1.0 h1:91R7g36eIXMKX7Ld1YObtNsDh72smw+eD1rIVxvutQM=
22-
github.com/pilot-protocol/nameserver v0.1.0/go.mod h1:6o01gsjvw4LqYIAxI5sD8OHfaiWv78jC8aPtoxV7nJA=
23-
github.com/pilot-protocol/policy v0.1.0 h1:Eh0CfCZDEX8UCkMPi2MrNrhCe8c15a/Bqf4eaKUhyis=
24-
github.com/pilot-protocol/policy v0.1.0/go.mod h1:IMVm7IQhgLtH/iXow2AWFuLl+sKrxJ4mGs4EKLoHop8=
25-
github.com/pilot-protocol/rendezvous v0.1.0 h1:vOBD7CnRY8uU8vma0Vfcr0aPSQ54qNuxppNUiljzk9Y=
26-
github.com/pilot-protocol/rendezvous v0.1.0/go.mod h1:g3/IYBykbU5m9jeprSCrmuoDpaqROO4Lu/+ecKVIF3A=
27-
github.com/pilot-protocol/runtime v0.1.0 h1:TyerRWKVN38WM2RAPR5bhCdY5cR7d3UYg5neUK0pdZk=
28-
github.com/pilot-protocol/runtime v0.1.0/go.mod h1:X1sImTG8xu6HkvKimu8Eq91HmDKQt6GHEWju7HxofEQ=
29-
github.com/pilot-protocol/skillinject v0.1.0 h1:gs912gqmxl0ifIvswefjx8BzPCmoBWS77mSp/RC1YEY=
30-
github.com/pilot-protocol/skillinject v0.1.0/go.mod h1:303GIB6j95ZhnoYeTlYzlBDhUbO01PB/6KGohm4DcJs=
31-
github.com/pilot-protocol/trustedagents v0.1.0 h1:rCX0IQxfZ84Q4dSgw01WJgjHUODRnI3iAon1t+NuFGE=
32-
github.com/pilot-protocol/trustedagents v0.1.0/go.mod h1:uVySmuMPb6N7AOCnvLHN2I9C9ggqEpfBmAZwVuP5Xaw=
33-
github.com/pilot-protocol/updater v0.2.2-0.20260529065627-220ed5b8383f h1:1dyunPeEOriqTv1xbt0fuDwieA5V5NLU1nVSC2714jU=
34-
github.com/pilot-protocol/updater v0.2.2-0.20260529065627-220ed5b8383f/go.mod h1:/I0uhVk1SljAOEYmjTdI/6CP7UmemmV4WB22ai1FxUw=
35-
github.com/pilot-protocol/webhook v0.1.0 h1:SnIcn+IdHvzoJt+OFzGJbkBHurjNBD0xSc6HAUvExAg=
36-
github.com/pilot-protocol/webhook v0.1.0/go.mod h1:c0du05MMy8FYnlc2YGqUWxRgTP8pRWTrtIdNuRhf6uk=
375
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
386
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
397
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=

internal/ipcutil/ipcutil.go

Lines changed: 0 additions & 40 deletions
This file was deleted.

internal/ipcutil/zz_test.go

Lines changed: 0 additions & 137 deletions
This file was deleted.

pkg/config/config.go

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)