Skip to content

Add generic x-deprecation-message schema walker; emit warning when deprecated frontmatter fields are set#33362

Merged
pelikhan merged 6 commits into
mainfrom
copilot/deep-report-add-x-deprecation-message-walker
May 19, 2026
Merged

Add generic x-deprecation-message schema walker; emit warning when deprecated frontmatter fields are set#33362
pelikhan merged 6 commits into
mainfrom
copilot/deep-report-add-x-deprecation-message-walker

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

Deprecated fields marked in the JSON schema (e.g. tools.grep) were silently accepted at compile time — no warning reached the user. The only exception was a hand-coded warning for tools.github.repos, meaning every new deprecation required manual plumbing.

Approach

Replace per-field hard-coding with a schema-driven walker that runs once per compilation and emits x-deprecation-message (falling back to description) for every deprecated field present in the frontmatter.

pkg/parser/schema_deprecation.go

  • Extended DeprecatedField with Path (dot-notation path, e.g. tools.grep) and DeprecationMessage (x-deprecation-message value)
  • collectDeprecatedDeep() — recursive walker over properties, flattening oneOf/anyOf/allOf variants so nested fields like tools.github.repos (buried in oneOf[3]) are discovered automatically
  • GetMainWorkflowDeprecatedFieldsDeep() — cached entry point
  • FindDeprecatedFieldsInFrontmatterDeep() — navigates nested frontmatter maps by dot-separated path

pkg/parser/schemas/main_workflow_schema.json

  • Added x-deprecation-message to tools.github.repos (preserving the gh aw fix migration hint), tools.github.toolset, and tools.serena — schema is now the single source of truth for all deprecation messages

pkg/workflow/compiler_orchestrator_tools.go

  • warnDeprecatedFrontmatterFields() calls the deep walker and emits FormatWarningMessage for every hit; wired into processToolsAndMarkdown

pkg/workflow/tools_parser.go

  • Removed the now-redundant hand-coded tools.github.repos warning (and its unused console/os imports)

Result

A workflow using tools.grep: true now produces at compile time:

⚠ grep is always available as part of default bash tools (echo, ls, pwd, cat, head, tail, grep, wc, sort, uniq, date, yq). Remove this field and use bash tool instead.

Future schema deprecations self-document without any parser changes.

Copilot AI and others added 2 commits May 19, 2026 17:12
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…hen deprecated fields are set

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add generic x-deprecation-message walker to emit warning for tools.grep Add generic x-deprecation-message schema walker; emit warning when deprecated frontmatter fields are set May 19, 2026
Copilot AI requested a review from pelikhan May 19, 2026 17:25
@pelikhan pelikhan marked this pull request as ready for review May 19, 2026 18:33
Copilot AI review requested due to automatic review settings May 19, 2026 18:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds schema-driven detection of deprecated frontmatter fields so the compiler emits user-visible warnings whenever deprecated fields are present, using x-deprecation-message (fallback to description) from the JSON schema.

Changes:

  • Implemented a deep JSON-schema walker to collect deprecated fields (with dot-paths) and find them in nested frontmatter.
  • Wired compiler warnings to emit one warning per deprecated field found during compilation.
  • Updated schema to include x-deprecation-message for additional deprecated fields and added tests covering the new warning behavior.
Show a summary per file
File Description
pkg/parser/schema_deprecation.go Adds deep deprecated-field collection and nested frontmatter lookup by dot-path.
pkg/workflow/compiler_orchestrator_tools.go Emits schema-driven deprecation warnings during tools/markdown processing.
pkg/workflow/tools_parser.go Removes the hard-coded tools.github.repos deprecation warning (now handled generically).
pkg/workflow/compiler_orchestrator_tools_test.go Adds tests capturing stderr to verify deprecation warnings are emitted.
pkg/parser/schemas/main_workflow_schema.json Adds x-deprecation-message to selected deprecated fields (schema as source of truth).
pkg/parser/schema_deprecated_test.go Adds unit tests for the deep schema walker and deep frontmatter matching.
pkg/parser/README.md Documents the new deep deprecated-field APIs.
.github/workflows/mcp-inspector.lock.yml Updates the Datadog header env var reference (DD_APPLICATION_KEY value source).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 8/8 changed files
  • Comments generated: 4

Comment on lines +183 to +187
func collectDeprecatedDeep(schemaNode map[string]any, parentPath string, results *[]DeprecatedField) {
properties, ok := schemaNode["properties"].(map[string]any)
if !ok {
return
}
Replacement string // The recommended replacement field name
Description string // Description from the schema
Name string // The deprecated field name (leaf key only)
Path string // Full dot-separated path, e.g. "tools.grep" (empty for top-level fields)
Comment on lines +725 to +736
// captureStderr redirects os.Stderr to a pipe and returns the captured output
// after calling fn. The original os.Stderr is always restored.
func captureStderr(fn func()) string {
oldStderr := os.Stderr
r, w, _ := os.Pipe()
os.Stderr = w
fn()
w.Close()
os.Stderr = oldStderr
var buf bytes.Buffer
buf.ReadFrom(r)
return buf.String()
compiler.warnDeprecatedFrontmatterFields(frontmatter)
})

assert.Empty(t, strings.TrimSpace(stderr), "no warning should be emitted for non-deprecated fields")
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

Copilot AI and others added 2 commits May 19, 2026 19:26
…dd-x-deprecation-message-walker

# Conflicts:
#	pkg/parser/schemas/main_workflow_schema.json

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 19, 2026

@copilot resolve the merge conflicts in this pull request

Resolved in the latest commit. The only conflict was in pkg/parser/schemas/main_workflow_schema.json — our branch had added x-deprecation-message to the toolset (singular) deprecated field, while origin/main had removed that field entirely as an orphan (#33360). Accepted the origin/main removal. All deprecation warning tests continue to pass.

@pelikhan pelikhan merged commit 17d1405 into main May 19, 2026
14 of 15 checks passed
@pelikhan pelikhan deleted the copilot/deep-report-add-x-deprecation-message-walker branch May 19, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[deep-report] Add generic x-deprecation-message walker; emit warning when tools.grep is set

3 participants