Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions pkg/cli/mcp_logs_guardrail.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ type MCPLogsGuardrailResponse struct {
FilePath string `json:"file_path,omitempty"`
}

// estimateTokens estimates the number of tokens in a string
// Using the approximation: ~4 characters per token
func estimateTokens(text string) int {
return len(text) / CharsPerToken
}

// buildLogsFileResponse writes the logs JSON output to a content-addressed cache
// file and returns a JSON response containing the file path.
// The file is named by the SHA256 hash of its content so that identical results
Expand Down
21 changes: 0 additions & 21 deletions pkg/cli/mcp_logs_guardrail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,3 @@ func TestBuildLogsFileResponse_ResponseStructure(t *testing.T) {
// Cleanup
_ = os.Remove(response.FilePath)
}

func TestEstimateTokens(t *testing.T) {
// Test token estimation
tests := []struct {
text string
expectedTokens int
}{
{"", 0},
{"x", 0}, // 1 char / 4 = 0
{"xxxx", 1}, // 4 chars / 4 = 1
{"xxxxxxxx", 2}, // 8 chars / 4 = 2
{strings.Repeat("x", 400), 100}, // 400 chars / 4 = 100
}

for _, tt := range tests {
got := estimateTokens(tt.text)
if got != tt.expectedTokens {
t.Errorf("estimateTokens(%q) = %d, want %d", tt.text, got, tt.expectedTokens)
}
}
}
31 changes: 0 additions & 31 deletions pkg/workflow/compiler_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,6 @@ func WithNoEmit(noEmit bool) CompilerOption {
return func(c *Compiler) { c.noEmit = noEmit }
}

// WithSafeUpdate configures whether to enforce safe update mode (reject newly introduced secrets
// and unapproved action additions/removals relative to the previously recorded manifest).
func WithSafeUpdate(safeUpdate bool) CompilerOption {
return func(c *Compiler) { c.safeUpdate = safeUpdate }
}

// WithPriorManifest registers a pre-cached manifest for a specific lock file.
// When set, the compiler uses this manifest as the trusted baseline for safe update
// enforcement instead of reading from git HEAD or the filesystem. This is intended for
// use by the MCP server, which collects manifests at startup before any agent interaction.
func WithPriorManifest(lockFile string, manifest *GHAWManifest) CompilerOption {
return func(c *Compiler) {
if c.priorManifests == nil {
c.priorManifests = make(map[string]*GHAWManifest)
}
c.priorManifests[lockFile] = manifest
}
}

// WithFailFast configures whether to stop at first validation error
func WithFailFast(failFast bool) CompilerOption {
return func(c *Compiler) { c.failFast = failFast }
Expand Down Expand Up @@ -305,19 +286,7 @@ func (c *Compiler) GetSafeUpdateWarnings() []string {
return c.safeUpdateWarnings
}

// SetPriorManifest registers a pre-cached manifest for a specific lock file path.
// When set, the compiler uses this as the trusted baseline for safe update enforcement
// instead of reading from git HEAD or the filesystem. Intended for use by the MCP
// server, which pre-captures manifests at startup before any agent can tamper with them.
func (c *Compiler) SetPriorManifest(lockFile string, manifest *GHAWManifest) {
if c.priorManifests == nil {
c.priorManifests = make(map[string]*GHAWManifest)
}
c.priorManifests[lockFile] = manifest
}

// SetPriorManifests replaces the entire pre-cached manifest map.
// Equivalent to calling SetPriorManifest for every entry in the map.
func (c *Compiler) SetPriorManifests(manifests map[string]*GHAWManifest) {
c.priorManifests = manifests
}
Expand Down
12 changes: 0 additions & 12 deletions pkg/workflow/publish_artifacts.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package workflow

import (
"encoding/json"
"fmt"
"strings"

Expand Down Expand Up @@ -188,14 +187,3 @@ func generateSafeOutputsArtifactStagingUpload(builder *strings.Builder, data *Wo
builder.WriteString(" retention-days: 1\n")
builder.WriteString(" if-no-files-found: ignore\n")
}

// marshalStringSliceJSON serialises a []string to a compact JSON array string.
// This is used to pass multi-value config fields as environment variables.
func marshalStringSliceJSON(values []string) string {
data, err := json.Marshal(values)
if err != nil {
// Should never happen for plain string slices.
return "[]"
}
return string(data)
}
18 changes: 0 additions & 18 deletions pkg/workflow/publish_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,3 @@ func TestGenerateSafeOutputsArtifactStagingUpload(t *testing.T) {
assert.Empty(t, b.String(), "should generate nothing when SafeOutputs is nil")
})
}

func TestMarshalStringSliceJSON(t *testing.T) {
tests := []struct {
name string
input []string
expected string
}{
{"empty slice", []string{}, "[]"},
{"single value", []string{"dist/**"}, `["dist/**"]`},
{"multiple values", []string{"dist/**", "reports/**/*.json"}, `["dist/**","reports/**/*.json"]`},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := marshalStringSliceJSON(tt.input)
assert.Equal(t, tt.expected, result, "JSON output mismatch")
})
}
}
Loading