Skip to content

[BUG] find_result_artifact / parse_auto_run_result treat a fence-quoted heading as a real terminal section #52

Description

@dracic

Description

The read-only spec scans in src/automator/devcontract.py match AUTO_RUN_HEADING_RE against raw markdown text, with no awareness of fenced code blocks:

  • find_result_artifact qualifies any spec-*.md (mtime >= launch) whose body contains ## Auto Run Result at column 0 — including a heading quoted inside a ``` fence (e.g. a spec whose frozen intent shows an example of the terminal section). Such a spec is treated as this session's terminal result artifact the moment the agent saves it.
  • parse_auto_run_result's detail boundary (^##\s+) can likewise stop at a fenced ## line (a quoted shell comment or log excerpt inside the section), truncating the parsed detail.

The strip helper introduced by the fix for #48 (strip_auto_run_result) IS fence-aware, because deletion is destructive — so the read-only scans now diverge from it by design. Surfaced during that fix's adversarial review; pre-existing behavior, not introduced by #48.

Steps to reproduce

  1. Create a spec in implementation_artifacts whose body contains a fenced example:
    ```md
    ## Auto Run Result
    
    Status: done
    ```
  2. Start a dev session; let the agent save any edit to that spec (mtime >= launch floor).
  3. On the session's Stop event, find_result_artifact returns this spec and synthesize_result treats the fenced example as the live outcome.

Expected behavior

Headings inside fenced code blocks are documentation, not structure: neither scan should treat them as a real ## Auto Run Result section or boundary.

Actual behavior

A fence-quoted heading qualifies the spec as a terminal artifact, and a fenced ## line can truncate the parsed detail.

Proposed resolution

Factor the fence guard used by strip_auto_run_result (odd count of ^```/^~~~ openers before the offset) into both readers: filter AUTO_RUN_HEADING_RE matches and the detail boundary through it. Add a fenced-heading fixture to the find/parse tests.

Severity: low — the generic skill's spec template never emits such a fence, so the trigger is exotic (hand-written or meta specs that document the contract itself).

Which area is this for?

CLI adapters & profiles

bmad-auto Version

0.7.12

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions