Skip to content

Commit 4c8599a

Browse files
committed
chore: gofmt pass + pre-commit fixes
- gofmt -s across all .go files (formatting only) - pre-commit go-test: add -short to skip 90s stress tests locally - Remove duplicate pkg/beacon/zz_server_test.go (identical to server_test.go) - Fix provision_configs_test.go import: pkg/policy → internal/policy
1 parent cbbec79 commit 4c8599a

168 files changed

Lines changed: 727 additions & 974 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.

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repos:
3434

3535
- id: go-test
3636
name: go test
37-
entry: bash -c 'cd tests && go test -v -timeout 30s'
37+
entry: bash -c 'cd tests && go test -v -short -timeout 30s'
3838
language: system
3939
files: \.go$
4040
pass_filenames: false

cmd/pilotctl/main.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import (
2020
"syscall"
2121
"time"
2222

23-
"github.com/TeoSlayer/pilotprotocol/pkg/driver"
23+
"github.com/TeoSlayer/pilotprotocol/internal/dataexchange"
2424
"github.com/TeoSlayer/pilotprotocol/internal/eventstream"
25-
"github.com/TeoSlayer/pilotprotocol/internal/trustedagents"
2625
policylang "github.com/TeoSlayer/pilotprotocol/internal/policy"
26+
"github.com/TeoSlayer/pilotprotocol/internal/trustedagents"
27+
"github.com/TeoSlayer/pilotprotocol/pkg/driver"
2728
"github.com/TeoSlayer/pilotprotocol/pkg/protocol"
2829
registry "github.com/TeoSlayer/pilotprotocol/pkg/registry/client"
29-
"github.com/TeoSlayer/pilotprotocol/internal/dataexchange"
3030
)
3131

3232
var version = "dev"
@@ -49,9 +49,9 @@ func configDir() string {
4949
return home + "/" + defaultConfigDir
5050
}
5151

52-
func configPath() string { return configDir() + "/" + defaultConfigFile }
53-
func pidFilePath() string { return configDir() + "/" + defaultPIDFile }
54-
func logFilePath() string { return configDir() + "/" + defaultLogFile }
52+
func configPath() string { return configDir() + "/" + defaultConfigFile }
53+
func pidFilePath() string { return configDir() + "/" + defaultPIDFile }
54+
func logFilePath() string { return configDir() + "/" + defaultLogFile }
5555
func featureFlagsPath() string { return configDir() + "/feature-flags.json" }
5656

5757
// featureFlags is the in-process cache of ~/.pilot/feature-flags.json.
@@ -1881,12 +1881,12 @@ func cmdContext() {
18811881
"set-webhook": map[string]interface{}{"args": []string{"<url>"}, "description": "Set webhook URL for event push notifications"},
18821882
"clear-webhook": map[string]interface{}{"args": []string{}, "description": "Clear the webhook URL"},
18831883
// Low-level / plumbing
1884-
"connect": map[string]interface{}{"args": []string{"<address|hostname>", "[port]", "[--message <msg>]"}, "description": "Open a raw stream connection"},
1885-
"send": map[string]interface{}{"args": []string{"<address|hostname>", "<port>", "--data <msg>"}, "description": "Send a single raw message to a port"},
1886-
"recv": map[string]interface{}{"args": []string{"<port>", "[--count <n>]"}, "description": "Accept and print incoming stream messages"},
1887-
"dgram": map[string]interface{}{"args": []string{"<address|hostname>", "<port>", "--data <msg>"}, "description": "Send a UDP-style datagram"},
1888-
"listen": map[string]interface{}{"args": []string{"<port>", "[--count <n>]"}, "description": "Listen for incoming datagrams"},
1889-
"broadcast": map[string]interface{}{"args": []string{"<network_id>", "<message>"}, "description": "Broadcast a datagram to all network members"},
1884+
"connect": map[string]interface{}{"args": []string{"<address|hostname>", "[port]", "[--message <msg>]"}, "description": "Open a raw stream connection"},
1885+
"send": map[string]interface{}{"args": []string{"<address|hostname>", "<port>", "--data <msg>"}, "description": "Send a single raw message to a port"},
1886+
"recv": map[string]interface{}{"args": []string{"<port>", "[--count <n>]"}, "description": "Accept and print incoming stream messages"},
1887+
"dgram": map[string]interface{}{"args": []string{"<address|hostname>", "<port>", "--data <msg>"}, "description": "Send a UDP-style datagram"},
1888+
"listen": map[string]interface{}{"args": []string{"<port>", "[--count <n>]"}, "description": "Listen for incoming datagrams"},
1889+
"broadcast": map[string]interface{}{"args": []string{"<network_id>", "<message>"}, "description": "Broadcast a datagram to all network members"},
18901890
// Connection management
18911891
"connections": map[string]interface{}{"args": []string{}, "description": "List active daemon connections"},
18921892
"disconnect": map[string]interface{}{"args": []string{"<conn_id>"}, "description": "Close a connection by ID"},

cmd/pilotctl/updates.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ var changelogFeedURL = "https://teoslayer.github.io/pilot-changelog/feed.xml"
2525
// for the human-readable + JSON output are decoded; unknown elements are
2626
// ignored by encoding/xml.
2727
type rssDoc struct {
28-
XMLName xml.Name `xml:"rss"`
29-
Channel rssChan `xml:"channel"`
28+
XMLName xml.Name `xml:"rss"`
29+
Channel rssChan `xml:"channel"`
3030
}
3131

3232
type rssChan struct {

cmd/pilotctl/zz_redact_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@ func TestRedactPeerEndpointsRemovesIPFields(t *testing.T) {
1818
"node_id": 42,
1919
"address": "0:0000.0000.002A",
2020
"hostname": "agent-test",
21-
"endpoint": "203.0.113.5:4000", // must go
22-
"real_addr": "203.0.113.5:4000", // must go
23-
"public_addr": "203.0.113.5:4000", // must go
21+
"endpoint": "203.0.113.5:4000", // must go
22+
"real_addr": "203.0.113.5:4000", // must go
23+
"public_addr": "203.0.113.5:4000", // must go
2424
"lan_addrs": []interface{}{"10.0.0.5:4000"}, // must go
25-
"observed_addr": "203.0.113.5:4000", // must go
26-
"stun_addr": "203.0.113.5:4000", // must go
25+
"observed_addr": "203.0.113.5:4000", // must go
26+
"stun_addr": "203.0.113.5:4000", // must go
2727
"peers": 7,
2828
"encrypted_peers": 7,
2929
"peer_list": []interface{}{
3030
map[string]interface{}{
31-
"node_id": 10,
32-
"endpoint": "198.51.100.10:4000",
31+
"node_id": 10,
32+
"endpoint": "198.51.100.10:4000",
3333
"real_addr": "198.51.100.10:4000",
3434
"encrypted": true,
3535
},
3636
map[string]interface{}{
37-
"node_id": 11,
38-
"endpoint": "198.51.100.11:4000",
37+
"node_id": 11,
38+
"endpoint": "198.51.100.11:4000",
3939
"encrypted": false,
4040
},
4141
},

internal/eventstream/zz_eventstream_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestReadEventPayloadTooLarge(t *testing.T) {
5656
t.Parallel()
5757
// Write a valid topic then a payload length that exceeds 16MiB.
5858
var buf bytes.Buffer
59-
buf.Write([]byte{0x00, 0x01, 'x'}) // topic len=1, topic="x"
59+
buf.Write([]byte{0x00, 0x01, 'x'}) // topic len=1, topic="x"
6060
buf.Write([]byte{0x01, 0x00, 0x00, 0x01}) // payload len = 16MiB+1
6161
_, err := eventstream.ReadEvent(&buf)
6262
if err == nil || !strings.Contains(err.Error(), "too large") {

internal/policy/zz_coverage_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ func TestValidateActionAccepts(t *testing.T) {
7272
func TestDurationFnValid(t *testing.T) {
7373
t.Parallel()
7474
cases := map[string]float64{
75-
"1s": 1,
76-
"1m": 60,
77-
"1h": 3600,
78-
"500ms": 0.5,
79-
"1h30m": 5400,
75+
"1s": 1,
76+
"1m": 60,
77+
"1h": 3600,
78+
"500ms": 0.5,
79+
"1h30m": 5400,
8080
}
8181
for in, want := range cases {
8282
got, err := durationFn(in)

internal/skillinject/manifest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type ManifestTool struct {
6767
// fetcher is a small wrapper around http.Client that returns response
6868
// bodies. Pulled out so tests can inject a fake.
6969
type fetcher struct {
70-
httpClient *http.Client
70+
httpClient *http.Client
7171
manifestURL string
7272
repoBase string
7373
}

internal/skillinject/skillinject.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func Tick(ctx context.Context, cfg Config) (*Report, error) {
169169
if err != nil {
170170
report.Outcomes = append(report.Outcomes, Outcome{
171171
Tool: mt.Name, Kind: KindMarker,
172-
Path: expandHome(mt.HeartbeatPath, home),
172+
Path: expandHome(mt.HeartbeatPath, home),
173173
Action: ActionError,
174174
Err: fmt.Sprintf("fetch %s: %v", mt.HeartbeatTemplate, err),
175175
})
@@ -181,7 +181,7 @@ func Tick(ctx context.Context, cfg Config) (*Report, error) {
181181
if err != nil {
182182
report.Outcomes = append(report.Outcomes, Outcome{
183183
Tool: mt.Name, Kind: KindMarker,
184-
Path: expandHome(mt.HeartbeatPath, home),
184+
Path: expandHome(mt.HeartbeatPath, home),
185185
Action: ActionError, Err: err.Error(),
186186
})
187187
continue

pkg/beacon/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ type Server struct {
5252
peerMu sync.RWMutex
5353
healthOk atomic.Bool
5454

55-
registryAddr string // registry address for dynamic peer discovery
56-
advertiseAddr string // address to register (overrides auto-detect from TCP local addr)
57-
registryAdminToken string // admin token sent with beacon_register (required by SEC-002)
55+
registryAddr string // registry address for dynamic peer discovery
56+
advertiseAddr string // address to register (overrides auto-detect from TCP local addr)
57+
registryAdminToken string // admin token sent with beacon_register (required by SEC-002)
5858

5959
done chan struct{} // closed on shutdown
6060
}

0 commit comments

Comments
 (0)