Skip to content

Commit 242bb11

Browse files
authored
fix(ci): resolve pre-existing lint + several CI test failures (#3628)
Clears the lint job and several Test/Integration failures that had been accumulating on main: - internal/cmd/sling_formula.go: fix 'ect' → 'etc' misspelling (misspell) - internal/git/git.go: silence unparam on runWithTimeout (string kept for consistency with Run()) - internal/beads/beads_rig.go: call EnsureCustomTypes() before bd create --type=rig, matching CreateAgentBead (fixes TestIsRigParked_WhenOnlyBeadLabelPresent) - internal/beads/beads_agent_test.go: drop stale bd slot assertion (slot removed in bd v0.62; hook_bead authority is now work-bead status=hooked + assignee) - internal/util/diskspace.go: split into unix/windows variants with build constraints (fixes Windows Smoke Test) - internal/web/fetcher.go: strip "[1m]" context-window suffix from model display labels Remaining integration failures (4 scheduler tests) are tracked separately — they fail at sling-context creation, a different root cause than the rig-type validation this PR addresses. Co-authored-by: Mike Akers <mikeakers@users.noreply.github.com>
1 parent 9490fb1 commit 242bb11

8 files changed

Lines changed: 107 additions & 42 deletions

File tree

internal/beads/beads_agent_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,8 @@ func TestCreateAgentBead_UsesTownRootForCrossRigRoutes(t *testing.T) {
448448
if !strings.Contains(logOutput, "create --json --id=pt-imported-polecat-shiny") {
449449
t.Fatalf("mock bd log missing create call:\n%s", logOutput)
450450
}
451-
if !strings.Contains(logOutput, "slot set pt-imported-polecat-shiny hook pt-task-1") {
452-
t.Fatalf("mock bd log missing slot set call:\n%s", logOutput)
453-
}
451+
// Note: hook_bead slot is no longer set — bd slot removed in v0.62 (hq-l6mm5).
452+
// Work bead status=hooked and assignee=<agent> is now the authoritative source.
454453
}
455454

456455
func TestCreateAgentBead_ParsesMockCreateOutput(t *testing.T) {

internal/beads/beads_rig.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ func (b *Beads) CreateRigBead(name string, fields *RigFields) (*Issue, error) {
144144
id := RigBeadIDWithPrefix(prefix, name)
145145
description := FormatRigDescription(name, fields)
146146

147+
// Ensure target database has custom types configured (including "rig").
148+
// This matches what CreateAgentBead does — without it, bd rejects
149+
// --type=rig on databases that haven't registered custom types yet.
150+
_ = EnsureCustomTypes(b.getResolvedBeadsDir())
151+
147152
args := []string{"create", "--json",
148153
"--id=" + id,
149154
"--title=" + name,

internal/cmd/sling_formula.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func runSlingFormula(ctx context.Context, args []string) error {
268268
// Dog sessions need a nudge sent to their session (not to the bare pane ID
269269
// from StartDelayedSession, which is ambiguous on platforms where tmux pane
270270
// IDs are not globally unique). Use NudgeSession which qualifies the target
271-
// with the session name. (gt-ect)
271+
// with the session name. (gt-etc)
272272
if delayedDogInfo != nil {
273273
dogSession := fmt.Sprintf("hq-dog-%s", delayedDogInfo.DogName)
274274
if err := t.NudgeSession(dogSession, prompt); err != nil {

internal/git/git.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const pushTimeout = 60 * time.Second
120120

121121
// runWithTimeout executes a git command with a deadline. If the command does
122122
// not finish within the timeout, the process is killed and an error is returned.
123-
func (g *Git) runWithTimeout(timeout time.Duration, args ...string) (string, error) {
123+
func (g *Git) runWithTimeout(timeout time.Duration, args ...string) (_ string, _ error) { //nolint:unparam // string return kept for consistency with Run()
124124
if g.gitDir != "" {
125125
args = append([]string{"--git-dir=" + g.gitDir}, args...)
126126
}
@@ -449,9 +449,9 @@ func configureRefspec(repoPath string, singleBranch bool) error {
449449
}
450450
return nil
451451
}
452-
headRef := strings.TrimSpace(headOut.String()) // e.g. "refs/heads/main"
453-
branch := strings.TrimPrefix(headRef, "refs/heads/") // e.g. "main"
454-
refspec := branch + ":refs/remotes/origin/" + branch // e.g. "main:refs/remotes/origin/main"
452+
headRef := strings.TrimSpace(headOut.String()) // e.g. "refs/heads/main"
453+
branch := strings.TrimPrefix(headRef, "refs/heads/") // e.g. "main"
454+
refspec := branch + ":refs/remotes/origin/" + branch // e.g. "main:refs/remotes/origin/main"
455455

456456
fetchCmd := exec.Command("git", "--git-dir", gitDir, "fetch", "--depth", "1", "origin", refspec)
457457
util.SetDetachedProcessGroup(fetchCmd)
@@ -661,10 +661,10 @@ func (g *Git) DiffNameOnly(base, head string) ([]string, error) {
661661

662662
// GitStatus represents the status of the working directory.
663663
type GitStatus struct {
664-
Clean bool
665-
Modified []string
666-
Added []string
667-
Deleted []string
664+
Clean bool
665+
Modified []string
666+
Added []string
667+
Deleted []string
668668
Untracked []string
669669
}
670670

@@ -1853,8 +1853,8 @@ type UncommittedWorkStatus struct {
18531853
StashCount int
18541854
UnpushedCommits int
18551855
// Details for error messages
1856-
ModifiedFiles []string
1857-
UntrackedFiles []string
1856+
ModifiedFiles []string
1857+
UntrackedFiles []string
18581858
}
18591859

18601860
// Clean returns true if there is no uncommitted work.

internal/util/diskspace.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package util
22

33
import (
44
"fmt"
5-
"syscall"
65
)
76

87
// DiskSpaceInfo contains filesystem space information.
@@ -57,30 +56,6 @@ func FormatBytesHuman(bytes uint64) string {
5756
}
5857
}
5958

60-
// GetDiskSpace returns filesystem space information for the given path.
61-
func GetDiskSpace(path string) (*DiskSpaceInfo, error) {
62-
var stat syscall.Statfs_t
63-
if err := syscall.Statfs(path, &stat); err != nil {
64-
return nil, fmt.Errorf("statfs %s: %w", path, err)
65-
}
66-
67-
total := stat.Blocks * uint64(stat.Bsize)
68-
free := stat.Bavail * uint64(stat.Bsize) // Bavail = available to non-root
69-
used := total - (stat.Bfree * uint64(stat.Bsize))
70-
71-
var usedPct float64
72-
if total > 0 {
73-
usedPct = float64(used) / float64(total) * 100
74-
}
75-
76-
return &DiskSpaceInfo{
77-
AvailableBytes: free,
78-
TotalBytes: total,
79-
UsedBytes: used,
80-
UsedPercent: usedPct,
81-
}, nil
82-
}
83-
8459
// Default thresholds for disk space checks.
8560
const (
8661
// DiskSpaceMinimumMB is the absolute minimum free space (in MB) below which

internal/util/diskspace_unix.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//go:build !windows
2+
3+
package util
4+
5+
import (
6+
"fmt"
7+
"syscall"
8+
)
9+
10+
// GetDiskSpace returns filesystem space information for the given path.
11+
func GetDiskSpace(path string) (*DiskSpaceInfo, error) {
12+
var stat syscall.Statfs_t
13+
if err := syscall.Statfs(path, &stat); err != nil {
14+
return nil, fmt.Errorf("statfs %s: %w", path, err)
15+
}
16+
17+
total := stat.Blocks * uint64(stat.Bsize)
18+
free := stat.Bavail * uint64(stat.Bsize) // Bavail = available to non-root
19+
used := total - (stat.Bfree * uint64(stat.Bsize))
20+
21+
var usedPct float64
22+
if total > 0 {
23+
usedPct = float64(used) / float64(total) * 100
24+
}
25+
26+
return &DiskSpaceInfo{
27+
AvailableBytes: free,
28+
TotalBytes: total,
29+
UsedBytes: used,
30+
UsedPercent: usedPct,
31+
}, nil
32+
}

internal/util/diskspace_windows.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//go:build windows
2+
3+
package util
4+
5+
import (
6+
"fmt"
7+
"syscall"
8+
"unsafe"
9+
)
10+
11+
// GetDiskSpace returns filesystem space information for the given path.
12+
func GetDiskSpace(path string) (*DiskSpaceInfo, error) {
13+
kernel32 := syscall.NewLazyDLL("kernel32.dll")
14+
getDiskFreeSpaceEx := kernel32.NewProc("GetDiskFreeSpaceExW")
15+
16+
pathPtr, err := syscall.UTF16PtrFromString(path)
17+
if err != nil {
18+
return nil, fmt.Errorf("invalid path %s: %w", path, err)
19+
}
20+
21+
var freeBytesAvailable, totalBytes, totalFreeBytes uint64
22+
ret, _, callErr := getDiskFreeSpaceEx.Call(
23+
uintptr(unsafe.Pointer(pathPtr)),
24+
uintptr(unsafe.Pointer(&freeBytesAvailable)),
25+
uintptr(unsafe.Pointer(&totalBytes)),
26+
uintptr(unsafe.Pointer(&totalFreeBytes)),
27+
)
28+
if ret == 0 {
29+
return nil, fmt.Errorf("GetDiskFreeSpaceExW %s: %w", path, callErr)
30+
}
31+
32+
used := totalBytes - totalFreeBytes
33+
var usedPct float64
34+
if totalBytes > 0 {
35+
usedPct = float64(used) / float64(totalBytes) * 100
36+
}
37+
38+
return &DiskSpaceInfo{
39+
AvailableBytes: freeBytesAvailable,
40+
TotalBytes: totalBytes,
41+
UsedBytes: used,
42+
UsedPercent: usedPct,
43+
}, nil
44+
}

internal/web/fetcher.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,23 +1622,33 @@ func runtimeLabelFromConfig(command string, args []string, fallback string) stri
16221622
for i := 0; i < len(args); i++ {
16231623
arg := args[i]
16241624
if (arg == "--model" || arg == "-m") && i+1 < len(args) && strings.TrimSpace(args[i+1]) != "" {
1625-
return cmd + "/" + strings.TrimSpace(args[i+1])
1625+
return cmd + "/" + stripModelSuffix(strings.TrimSpace(args[i+1]))
16261626
}
16271627
if strings.HasPrefix(arg, "--model=") {
16281628
if v := strings.TrimSpace(strings.TrimPrefix(arg, "--model=")); v != "" {
1629-
return cmd + "/" + v
1629+
return cmd + "/" + stripModelSuffix(v)
16301630
}
16311631
}
16321632
if strings.HasPrefix(arg, "-m=") {
16331633
if v := strings.TrimSpace(strings.TrimPrefix(arg, "-m=")); v != "" {
1634-
return cmd + "/" + v
1634+
return cmd + "/" + stripModelSuffix(v)
16351635
}
16361636
}
16371637
}
16381638

16391639
return cmd
16401640
}
16411641

1642+
// stripModelSuffix removes bracketed context-window hints (e.g. "[1m]")
1643+
// from model names so the dashboard label stays human-readable.
1644+
// "sonnet[1m]" → "sonnet", "opus" → "opus".
1645+
func stripModelSuffix(model string) string {
1646+
if idx := strings.Index(model, "["); idx > 0 {
1647+
return model[:idx]
1648+
}
1649+
return model
1650+
}
1651+
16421652
// FetchIssues returns open issues (the backlog).
16431653
func (f *LiveConvoyFetcher) FetchIssues() ([]IssueRow, error) {
16441654
// Query both open AND hooked issues for the Work panel

0 commit comments

Comments
 (0)