Skip to content

feat: add log-parser support for behavior-defined engines - #50991

Merged
pelikhan merged 10 commits into
mainfrom
copilot/add-log-parsing-support
Aug 7, 2026
Merged

feat: add log-parser support for behavior-defined engines#50991
pelikhan merged 10 commits into
mainfrom
copilot/add-log-parsing-support

Conversation

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Behavior-defined engines (crush, opencode, goose, aider) had no way to produce normalized event files from their logs. Built-in engines each have a hardcoded JS parser, but the declarative engine path had no equivalent hook.

Changes

  • EngineBehaviorDefinition: new log-parser YAML field (inline JS) alongside the existing harness-script and config-adapter patterns
  • BehaviorDefinedEngine: override GetLogParserScriptId() → returns <engine-id>_log_parser when set; buildLogParserWriteStep() writes the script to ${RUNNER_TEMP}/gh-aw/actions/ via heredoc with the same delimiter safety checks as harness-script
  • Auto-wrapping: the raw parseLog(logContent) function is wrapped with createEngineLogParser from log_parser_shared.cjs, so the author only provides the parse function and gets the full bootstrap (file reading, events enrichment, step summary) for free
  • JSON schema: log-parser added to behaviors with additionalProperties: false compliance

Usage

engine:
  id: goose
  display-name: Goose
  behaviors:
    log-parser: |
      function parseLog(logContent) {
        const lines = logContent.split("\n").filter(l => l.trim());
        return {
          markdown: "### Parsed " + lines.length + " lines",
          logEntries: lines.map((l, i) => ({ type: "message", index: i, text: l })),
          mcpFailures: [],
          maxTurnsHit: false,
        };
      }

The compiler emits a write step before execution and generateLogParsing() picks up the script ID automatically — no changes needed in the compilation pipeline.


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 33.6 AIC · ⊞ 8.3K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.85 AIC · ⊞ 5.9K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 17.1 AIC · ⊞ 8.3K ·
Comment /souschef to run again

Add a `log-parser` field to `EngineBehaviorDefinition` that allows
behavior-defined engines (crush, opencode, goose, aider) to declare
inline JavaScript log parsers. The parser code is written to disk
via heredoc and wrapped with `createEngineLogParser` from
`log_parser_shared.cjs` to produce normalized events files matching
the contract of built-in engine parsers.

Changes:
- Add `LogParser` field to `EngineBehaviorDefinition` struct
- Add `log-parser` property to JSON schema for behaviors
- Implement `GetLogParserScriptId()` on `BehaviorDefinedEngine`
- Add `buildLogParserWriteStep()` with heredoc safety checks
- Wire log-parser write step into `buildBehaviorDefinedSetupSteps()`
- Add comprehensive unit tests

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan

pelikhan commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot implement log parser for opencode/goose/crush based on workflow run data.

Copilot AI and others added 2 commits August 7, 2026 04:24
Implement engine-specific log parsers using the new log-parser behavior
field for each behavior-defined engine:

- Goose: parses plain-text streaming output with tool call markers
- OpenCode: parses JSON-structured log lines from --print-logs output
- Crush: parses plain-text output with tool invocation patterns

Each parser extracts conversation blocks, tool calls, MCP failures,
and max-turns detection, producing formatted step summaries.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot implement log parser for opencode/goose/crush based on workflow run data.

Implemented log parsers for all three engines in 91d96e4:

  • Goose (.github/workflows/shared/goose.md): Parses plain-text streaming output, detecting tool call markers, assistant/user blocks, MCP failures, and max-turns
  • OpenCode (.github/workflows/shared/opencode.md): Parses JSON-structured log lines from --print-logs output, extracting level/service/type fields, token counts, and tool calls
  • Crush (.github/workflows/shared/crush.md): Parses text output with tool invocation patterns (view/edit/bash/grep etc.)

Each parser produces formatted markdown step summaries with metrics tables and collapsible conversation details.

@pelikhan

pelikhan commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot the parser should not render anything, it should return the normalized agent event datastructure that will be renderered by code in agents/setup/js function. Refactor code so that all agents use the same rendering helper functions.

…ng markdown

Goose, OpenCode, and Crush parsers now return logEntries in the
normalized agent event format (type: assistant/user/system/result with
message.content arrays). The shared rendering helpers in
log_parser_bootstrap.cjs handle all markdown generation.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the parser should not render anything, it should return the normalized agent event datastructure that will be renderered by code in agents/setup/js function. Refactor code so that all agents ...

Refactored in the latest commit. All three parsers (goose, opencode, crush) now return normalized agent event entries (type: "assistant"/"user"/"system"/"result" with message.content arrays) and no longer render markdown. The shared rendering helpers in log_parser_bootstrap.cjs (generateCopilotCliStyleSummary, generatePlainTextSummary, wrapAgentLogInSection) handle all rendering uniformly across all engines.

@pelikhan
pelikhan marked this pull request as ready for review August 7, 2026 04:54
Copilot AI balanced review requested due to automatic review settings August 7, 2026 04:54
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for Test Quality Sentinel. Review the logs for details.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for Design Decision Gate 🏗️. Review the logs for details.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for Matt Pocock Skills Reviewer. Review the logs for details.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for PR Code Quality Reviewer. Review the logs for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds declarative log-parser support for behavior-defined engines.

Changes:

  • Adds the log-parser behavior and runtime wrapper.
  • Adds parsers for OpenCode, Goose, and Crush.
  • Regenerates affected workflows and adds Go tests.
Show a summary per file
File Description
pkg/workflow/engine_definition.go Defines the new behavior field.
pkg/workflow/behavior_defined_engine.go Generates and registers parser scripts.
pkg/workflow/behavior_defined_engine_log_parser_test.go Tests parser-step generation.
pkg/parser/schemas/main_workflow_schema.json Exposes log-parser in the schema.
.github/workflows/shared/opencode.md Adds the OpenCode parser.
.github/workflows/shared/goose.md Adds the Goose parser.
.github/workflows/shared/crush.md Adds the Crush parser.
.github/workflows/smoke-opencode.lock.yml Regenerates the OpenCode smoke workflow.
.github/workflows/smoke-goose.lock.yml Regenerates the Goose smoke workflow.
.github/workflows/smoke-crush.lock.yml Regenerates the Crush smoke workflow.
.github/workflows/daily-token-consumption-report.lock.yml Includes the Goose parser.
.github/workflows/daily-team-evolution-insights.lock.yml Includes the Goose parser.
.github/workflows/daily-security-red-team.lock.yml Includes the OpenCode parser.
.github/workflows/daily-reliability-review.lock.yml Includes the OpenCode parser.
.github/workflows/daily-code-metrics.lock.yml Includes the Crush parser.
.github/workflows/daily-arxiv-researcher.lock.yml Includes the Crush parser.

Review details

Tip

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

  • Files reviewed: 16/16 changed files
  • Comments generated: 5
  • Review effort level: Balanced

Comment thread pkg/workflow/behavior_defined_engine.go Outdated
Comment thread pkg/parser/schemas/main_workflow_schema.json Outdated
Comment thread pkg/workflow/behavior_defined_engine.go
Comment thread pkg/parser/schemas/main_workflow_schema.json Outdated
Comment thread pkg/workflow/engine_definition.go Outdated
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 82/100 — Excellent

Analyzed 4 test(s): 4 design, 0 implementation, 0 violation(s).

📊 Metrics (4 tests)
Metric Value
Analyzed 4 (Go: 4, JS: 0)
✅ Design 4 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 3 (75%)
Duplicate clusters 0
Inflation YES (174 test lines / 70 prod lines ≈ 2.49:1)
🚨 Violations 0
Test File Classification Issues
TestBehaviorDefinedEngineLogParser_GetLogParserScriptId behavior_defined_engine_log_parser_test.go design_test / behavioral_contract / high_value Assertions lack descriptive failure context (minor)
TestBehaviorDefinedEngineLogParser_WriteStep behavior_defined_engine_log_parser_test.go design_test / behavioral_contract / high_value Assertions lack descriptive failure context (minor)
TestBehaviorDefinedEngineLogParser_WithHarnessAndLogParser behavior_defined_engine_log_parser_test.go design_test / behavioral_contract / high_value Happy-path only; no error assertions
TestBehaviorDefinedEngineLogParser_HeredocDelimiterSafety behavior_defined_engine_log_parser_test.go design_test / behavioral_contract / high_value
⚠️ Flagged Tests (1 minor)

All 4 tests — Go assert.* / require.* calls lack descriptive failure context messages (e.g. assert.Equal(t, expected, actual, "msg")). This is a style advisory, not a hard violation, but improves debuggability when assertions fail.

TestBehaviorDefinedEngineLogParser_WithHarnessAndLogParser — happy-path only; exercises correct step count and content with valid inputs. No error-path subtest (e.g., what happens if HarnessScript is empty but LogParser is set). Low risk given the other tests cover the empty cases.

Test inflation: test file adds 174 lines vs. 70 production lines (≈2.49:1 ratio, threshold 2:1). Inflation is modest and the extra lines are meaningful setup helpers and subtests, not padding.

Verdict

passed. 0% implementation tests (threshold: 30%). Score 82/100 — Excellent. Minor advisory: add failure messages to assertions for easier debugging.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 29 AIC · ⊞ 7.7K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Test Quality Sentinel: 82/100. 0% implementation tests (threshold: 30%).

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (257 new lines exceeding the 100-line threshold) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/50991-add-log-parser-support-for-behavior-defined-engines.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — add context the AI couldn’t infer, refine the decision rationale, and list real alternatives you considered
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-50991: Add Log-Parser Support for Behavior-Defined Engines

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

“AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say ‘I’ll deal with this later.’ Deferring decisions corroded my ability to think clearly.”

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 50991-add-log-parser-support-for-behavior-defined-engines.md for PR #50991).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · sonnet46 · 49.9 AIC · ⊞ 9.6K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: feat: add log-parser support for behavior-defined engines

The implementation is well-structured and follows existing patterns (harness-script, config-adapter). The heredoc delimiter safety check, auto-wrapping via createEngineLogParser, and test coverage are all solid.

One non-blocking issue found across all three engine log parsers: goose.md, crush.md, and opencode.md each return markdown: "parsed" as a placeholder. In the normal path this field is ignored (the bootstrap generates rich Copilot CLI-style markdown from logEntries), but on the fallback path (empty or missing logEntries) this placeholder appears verbatim in the GitHub Actions step summary.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 68.3 AIC · ⊞ 5.3K

Comment thread .github/workflows/shared/goose.md Outdated
Comment thread .github/workflows/shared/crush.md Outdated
Comment thread .github/workflows/shared/opencode.md Outdated
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please address the outstanding review feedback, refresh the branch if needed, and run the pr-finisher skill before handing back to maintainers.

Open review items to address:

  • github-actions (Design Decision Gate): complete the draft ADR at docs/adr/50991-add-log-parser-support-for-behavior-defined-engines.md and link it from the PR body.
  • github-actions (PR Code Quality Reviewer): fix the heredoc-delimiter safety mismatch so the log parser script ID is not emitted when the write step is skipped.
  • github-actions / reviewers: replace the markdown: "parsed" placeholder fallback with useful summary output or remove the placeholder path.

Branch refresh was requested.

Run context: https://github.com/github/gh-aw/actions/runs/31150518831

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 33.6 AIC · ⊞ 8.3K ·
Comment /souschef to run again

Copilot AI and others added 2 commits August 7, 2026 06:03
…, comments, changeset)

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
…comment

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the parser should not render anything, it should return the normalized agent event datastructure that will be renderered by code in agents/setup/js function. Refactor code so that all agents ...

Done. All three parsers (goose, opencode, crush) now return the normalized agent event data structure (entries with type, index, message.content arrays, etc.) and produce no rendered markdown themselves. Rendering is handled entirely by the shared helpers in log_parser_bootstrap.cjs.

@copilot Please address the outstanding review feedback, refresh the branch if needed, and run the pr-finisher skill before handing back to maintainers.

Open review items to address:...

Addressed in the latest commits:

  • Heredoc-delimiter safety: GetLogParserScriptId() now returns "" when the delimiter collision check fails, so generateLogParsing() never emits a parse step for an unwritten file.
  • if: always() on write step: The log-parser write step now always emits if: always(), ensuring file materialization even when execution fails. The if: drop guards in threat_detection_inline_engine.go and evals_steps.go were tightened to match if: always() specifically.
  • UseSamples suppression: generateLogParsing() now skips the parse step for behavior-defined engines when UseSamples is true.
  • Comments and schema: Updated "must export" → "must define" in both engine_definition.go and the JSON schema.
  • Changeset: Added .changeset/minor-add-behavior-defined-engine-log-parser.md.
  • The parsers return normalized event data structures (no inline rendering) — handled by the shared bootstrap helpers.

Copilot AI requested a review from gh-aw-bot August 7, 2026 06:10
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please address the outstanding review feedback, refresh the branch if needed, and run the pr-finisher skill before handing back to maintainers.

Open review items to address:

  • github-actions (Design Decision Gate): complete the draft ADR at docs/adr/50991-add-log-parser-support-for-behavior-defined-engines.md and link it from the PR body.
  • github-actions / reviewers: replace the markdown: "parsed" placeholder fallback with useful summary output or remove the placeholder path.
  • reviewers: confirm all previously raised parser-wrapper issues are addressed on the latest head and hand back a maintainer-ready summary.

Branch refresh was requested.

Run context: https://github.com/github/gh-aw/actions/runs/31154408939

Generated by 👨🍳 PR Sous Chef
Comment /souschef to run again

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.85 AIC · ⊞ 5.9K ·
Comment /souschef to run again

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

PR Triage

Category: feature (log-parser support for behavior-defined engines) · Risk: high · Score: 82/100 (impact 42, urgency 22, quality 18)

Recommendation: fast_track

Large feature PR (21 files, +2390/-11) adding log-parser support across crush/goose/opencode engines, schema, ADR, and 6 regenerated .lock.yml workflows. AI reviewer approved (Test Quality Sentinel 82/100), CI status pending in check-runs API but PR is active with 12 comments. High impact given breadth of touched engine/compiler code — recommend human review before merge given size and behavior-defining scope.

Generated by 🔧 PR Triage Agent · auto · 55.6 AIC · ⌖ 2.45 AIC · ⊞ 7.9K ·

Copilot AI and others added 2 commits August 7, 2026 06:50
…e ADR-50991

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please address the outstanding review feedback, refresh the branch if needed, and run the pr-finisher skill before handing back to maintainers.

Open review items to address:...

Addressed in the latest commits:

  • markdown: "parsed" placeholder — replaced in all three parsers (goose, opencode, crush) with a computed summary string built from actual parse metrics (turns, tool calls, token count for opencode, MCP failures, max-turns flag). This string serves as a meaningful fallback if logEntries is ever empty, and as a truthy gate for the bootstrap summary path.
  • ADR-50991 — status updated from Draft to Accepted; draft footer removed.
  • Parser-wrapper issues — all previously raised items (delimiter-safety/script-ID consistency, if: always() on write step, UseSamples suppression, comment/schema wording) were addressed in prior commits and remain in place on HEAD.

ADR is at docs/adr/50991-add-log-parser-support-for-behavior-defined-engines.md.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please address the remaining review feedback and run the pr-finisher skill before handing back to maintainers.

Open review items to address:

  • github-actions (Design Decision Gate): complete the draft ADR at docs/adr/50991-add-log-parser-support-for-behavior-defined-engines.md and link it from the PR body if that has not already been done everywhere required.
  • reviewers: resolve the still-open review threads only after confirming the latest head fully addresses the parser-wrapper, placeholder-summary, and contract/documentation feedback.
  • reviewers: hand back a concise maintainer-ready summary on the latest head.

Branch refresh was requested.
Run context: https://github.com/github/gh-aw/actions/runs/31158432963

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 17.1 AIC · ⊞ 8.3K ·
Comment /souschef to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please address the remaining review feedback and run the pr-finisher skill before handing back to maintainers.

Open review items to address:

  • github-actions (Design Decision Gate): complete the draft ADR at docs/adr/50991-add-log-parser-support-for-behavior-defined-engines.md and link it from the PR body if that has not already been done everywhere required.
  • reviewers: resolve the still-open review threads only after confirming the latest head fully addresses the parser-wrapper, placeholder-summary, and contract/documentation feedback.
  • reviewers: hand back a concise maintainer-ready summary on the latest head.

Branch refresh was requested.
Run context: https://github.com/github/gh-aw/actions/runs/31161191787

Generated by 👨🍳 PR Sous Chef · gpt54
Comment /souschef to run again

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 16.3 AIC · ⊞ 8.3K ·
Comment /souschef to run again

@pelikhan
pelikhan merged commit 51a8b34 into main Aug 7, 2026
30 checks passed
@pelikhan
pelikhan deleted the copilot/add-log-parsing-support branch August 7, 2026 13:38
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.86.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants