Skip to content

Commit e8553d1

Browse files
chore: remove dead functions — 4 functions removed (#30167)
1 parent aa2531e commit e8553d1

7 files changed

Lines changed: 2 additions & 486 deletions

File tree

pkg/cli/commands_utils_test.go

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -113,113 +113,6 @@ func TestExtractWorkflowNameFromFile_NonExistentFile(t *testing.T) {
113113
}
114114
}
115115

116-
func TestFastParseTitle(t *testing.T) {
117-
tests := []struct {
118-
name string
119-
content string
120-
expected string
121-
expectError bool
122-
}{
123-
{
124-
name: "H1 after frontmatter",
125-
content: `---
126-
title: Test
127-
---
128-
129-
# My Workflow Title
130-
131-
Some content.`,
132-
expected: "My Workflow Title",
133-
},
134-
{
135-
name: "H1 with trailing spaces",
136-
content: `---
137-
engine: copilot
138-
---
139-
140-
# Weekly Research
141-
142-
Content here.`,
143-
expected: "Weekly Research",
144-
},
145-
{
146-
name: "H1 without frontmatter",
147-
content: `# Simple Title
148-
149-
No frontmatter here.`,
150-
expected: "Simple Title",
151-
},
152-
{
153-
name: "H1 is first line (no frontmatter)",
154-
content: `# Inline Title`,
155-
expected: "Inline Title",
156-
},
157-
{
158-
name: "no H1 header",
159-
content: "Just some text without headers.",
160-
expected: "",
161-
},
162-
{
163-
name: "only H2 headers",
164-
content: `---
165-
engine: copilot
166-
---
167-
168-
## Not an H1`,
169-
expected: "",
170-
},
171-
{
172-
name: "empty content",
173-
content: "",
174-
expected: "",
175-
},
176-
{
177-
name: "unclosed frontmatter returns error",
178-
content: `---
179-
title: Oops
180-
`,
181-
expectError: true,
182-
},
183-
{
184-
name: "dash in middle of content is not frontmatter",
185-
content: `Some text
186-
187-
---
188-
189-
# Not Skipped`,
190-
expected: "Not Skipped",
191-
},
192-
{
193-
name: "H1 inside frontmatter is ignored",
194-
content: `---
195-
# not a header
196-
---
197-
198-
# Real Title`,
199-
expected: "Real Title",
200-
},
201-
}
202-
203-
for _, tt := range tests {
204-
t.Run(tt.name, func(t *testing.T) {
205-
got, err := fastParseTitle(tt.content)
206-
if tt.expectError {
207-
if err == nil {
208-
t.Errorf("fastParseTitle(%q) expected error, got nil", tt.content)
209-
}
210-
return
211-
}
212-
if err != nil {
213-
t.Errorf("fastParseTitle(%q) unexpected error: %v", tt.content, err)
214-
return
215-
}
216-
if got != tt.expected {
217-
t.Errorf("fastParseTitle(%q) = %q, want %q", tt.content, got, tt.expected)
218-
}
219-
})
220-
}
221-
}
222-
223116
func TestIsGitRepo(t *testing.T) {
224117
// Test in current directory (should be a git repo based on project setup)
225118
result := isGitRepo()

pkg/cli/workflows.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -325,43 +325,6 @@ func filterMarkdownFilesWithFrontmatter(mdFiles []string) ([]string, error) {
325325
return workflowFiles, nil
326326
}
327327

328-
// fastParseTitle scans markdown content for the first H1 header, skipping an
329-
// optional frontmatter block, without performing a full YAML parse.
330-
//
331-
// Frontmatter is recognised only when "---" appears on the very first line
332-
// (matching the behaviour of ExtractFrontmatterFromContent). Returns the H1
333-
// title text, or ("", nil) when no H1 header is present. Returns an error if
334-
// frontmatter is opened but never closed.
335-
func fastParseTitle(content string) (string, error) {
336-
firstLine := true
337-
inFrontmatter := false
338-
for line := range strings.SplitSeq(content, "\n") {
339-
trimmed := strings.TrimSpace(line)
340-
if firstLine {
341-
firstLine = false
342-
if trimmed == "---" {
343-
inFrontmatter = true
344-
continue
345-
}
346-
} else if inFrontmatter {
347-
if trimmed == "---" {
348-
inFrontmatter = false
349-
}
350-
continue
351-
}
352-
if strings.HasPrefix(trimmed, "# ") {
353-
return strings.TrimSpace(trimmed[2:]), nil
354-
}
355-
}
356-
357-
// Unclosed frontmatter is an error (consistent with ExtractFrontmatterFromContent).
358-
if inFrontmatter {
359-
return "", errors.New("frontmatter not properly closed")
360-
}
361-
362-
return "", nil
363-
}
364-
365328
// fastParseTitleFromReader scans lines from r for the first H1 header, skipping
366329
// an optional frontmatter block, without reading the entire file into memory.
367330
// This is more efficient than fastParseTitle for file-based callers because it

pkg/workflow/model_aliases.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,3 @@ func MergeImportedModelAliases(importedModels []map[string][]string, frontmatter
170170
modelAliasesLog.Printf("Final alias map has %d entries", len(merged))
171171
return merged
172172
}
173-
174-
// MergeModelAliases merges the frontmatter-defined model aliases on top of the
175-
// builtin aliases and returns the combined map. Frontmatter entries always take
176-
// precedence: if the same key exists in both the builtins and the frontmatter
177-
// definition, the frontmatter value replaces the builtin value entirely.
178-
//
179-
// If frontmatterModels is nil or empty, the builtin aliases are returned as-is.
180-
//
181-
// For the full three-layer merge that also incorporates imported workflow aliases,
182-
// use MergeImportedModelAliases.
183-
func MergeModelAliases(frontmatterModels map[string][]string) map[string][]string {
184-
return MergeImportedModelAliases(nil, frontmatterModels)
185-
}

pkg/workflow/model_aliases_test.go

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -53,56 +53,6 @@ func TestBuiltinModelAliases(t *testing.T) {
5353
assert.NotEqual(t, aliases["sonnet"], aliases2["sonnet"], "BuiltinModelAliases should return a fresh copy each time")
5454
}
5555

56-
// TestMergeModelAliases verifies that frontmatter-defined aliases are merged on top
57-
// of the builtins.
58-
func TestMergeModelAliases(t *testing.T) {
59-
t.Run("nil frontmatter returns all builtins", func(t *testing.T) {
60-
merged := MergeModelAliases(nil)
61-
builtins := BuiltinModelAliases()
62-
assert.Len(t, merged, len(builtins), "nil frontmatter should return exactly the builtins")
63-
for k, v := range builtins {
64-
assert.Equal(t, v, merged[k], "builtin alias %q should be present unchanged", k)
65-
}
66-
})
67-
68-
t.Run("empty frontmatter returns all builtins", func(t *testing.T) {
69-
merged := MergeModelAliases(map[string][]string{})
70-
builtins := BuiltinModelAliases()
71-
assert.Len(t, merged, len(builtins), "empty frontmatter should return exactly the builtins")
72-
})
73-
74-
t.Run("frontmatter override replaces builtin entry", func(t *testing.T) {
75-
custom := map[string][]string{
76-
"sonnet": {"myvendor/sonnet-custom"},
77-
}
78-
merged := MergeModelAliases(custom)
79-
assert.Equal(t, []string{"myvendor/sonnet-custom"}, merged["sonnet"],
80-
"frontmatter override should replace the builtin sonnet alias")
81-
// Other builtins should be unaffected.
82-
assert.NotEmpty(t, merged["haiku"], "haiku builtin should still be present")
83-
})
84-
85-
t.Run("frontmatter adds new alias", func(t *testing.T) {
86-
custom := map[string][]string{
87-
"my-alias": {"copilot/my-model"},
88-
}
89-
merged := MergeModelAliases(custom)
90-
assert.Equal(t, []string{"copilot/my-model"}, merged["my-alias"],
91-
"new frontmatter alias should be present in merged map")
92-
// Builtins should still be present.
93-
assert.NotEmpty(t, merged["sonnet"], "sonnet builtin should still be present")
94-
})
95-
96-
t.Run("default policy key is supported", func(t *testing.T) {
97-
custom := map[string][]string{
98-
"": {"sonnet", "gpt-5-codex"},
99-
}
100-
merged := MergeModelAliases(custom)
101-
assert.Equal(t, []string{"sonnet", "gpt-5-codex"}, merged[""],
102-
"default policy (empty key) should be stored and returned")
103-
})
104-
}
105-
10656
// TestBuildAWFConfigJSON_ModelsSection verifies model alias behaviour in BuildAWFConfigJSON.
10757
//
10858
// NOTE: The "models" field is intentionally excluded from the AWF config JSON until the
@@ -120,7 +70,7 @@ func TestBuildAWFConfigJSON_ModelsSection(t *testing.T) {
12070
NetworkPermissions: &NetworkPermissions{
12171
Firewall: &FirewallConfig{Enabled: true},
12272
},
123-
ModelMappings: MergeModelAliases(nil),
73+
ModelMappings: MergeImportedModelAliases(nil, nil),
12474
},
12575
}
12676

@@ -153,7 +103,7 @@ func TestBuildAWFConfigJSON_ModelsSection(t *testing.T) {
153103
NetworkPermissions: &NetworkPermissions{
154104
Firewall: &FirewallConfig{Enabled: true},
155105
},
156-
ModelMappings: MergeModelAliases(custom),
106+
ModelMappings: MergeImportedModelAliases(nil, custom),
157107
},
158108
}
159109

pkg/workflow/model_identifier.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ type ParsedModelIdentifier struct {
7373
Params map[string]string
7474
}
7575

76-
// IsBare reports whether the identifier is a bare name (no provider prefix).
77-
func (p *ParsedModelIdentifier) IsBare() bool { return p.Provider == "" }
78-
7976
// Defined parameter keys recognised by the spec (Section 6).
8077
const (
8178
modelParamEffort = "effort"

pkg/workflow/observability_otlp.go

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -138,68 +138,6 @@ func generateOTLPHeadersMaskStep() string {
138138
return sb.String()
139139
}
140140

141-
// extractOTLPConfigFromRaw reads the first OTLP endpoint and its headers directly
142-
// from the raw frontmatter map[string]any. The `endpoint` field may be:
143-
//
144-
// - a string: backward-compat URL + optional top-level `headers` field
145-
// - an object: {url: "...", headers: {...}} — the object's own headers are used
146-
// - an array: [{url: ..., headers: ...}, ...] — only the first element is returned
147-
//
148-
// The third return value is true when the deprecated string form was used for headers,
149-
// so the caller can emit a deprecation warning.
150-
func extractOTLPConfigFromRaw(frontmatter map[string]any) (endpoint, headers string, deprecated bool) {
151-
obs, ok := frontmatter["observability"]
152-
if !ok {
153-
return
154-
}
155-
obsMap, ok := obs.(map[string]any)
156-
if !ok {
157-
return
158-
}
159-
otlp, ok := obsMap["otlp"]
160-
if !ok {
161-
return
162-
}
163-
otlpMap, ok := otlp.(map[string]any)
164-
if !ok {
165-
return
166-
}
167-
168-
endpointRaw := otlpMap["endpoint"]
169-
switch ep := endpointRaw.(type) {
170-
case string:
171-
if ep == "" {
172-
return
173-
}
174-
endpoint = ep
175-
if raw, ok := otlpMap["headers"]; ok {
176-
headers, deprecated = normalizeOTLPHeaders(raw)
177-
}
178-
case map[string]any:
179-
// Object form: endpoint: {url: "...", headers: {...}}
180-
if url, _ := ep["url"].(string); url != "" {
181-
endpoint = url
182-
if h, ok := ep["headers"]; ok {
183-
headers, deprecated = normalizeOTLPHeaders(h)
184-
}
185-
}
186-
case []any:
187-
// Array form: return only the first element (callers needing all entries
188-
// should use collectAllOTLPEndpoints instead).
189-
if len(ep) > 0 {
190-
if firstItem, ok := ep[0].(map[string]any); ok {
191-
if url, _ := firstItem["url"].(string); url != "" {
192-
endpoint = url
193-
if h, ok := firstItem["headers"]; ok {
194-
headers, deprecated = normalizeOTLPHeaders(h)
195-
}
196-
}
197-
}
198-
}
199-
}
200-
return
201-
}
202-
203141
// otlpEndpointEntry is the wire format used when encoding the GH_AW_OTLP_ENDPOINTS
204142
// environment variable as a JSON array. Each entry carries the endpoint URL and
205143
// its optional normalized (comma-separated key=value) headers string.

0 commit comments

Comments
 (0)