fix: do not emit annotations before unsupported-action comments#307
Conversation
AI Code ReviewWhat Looks Good
RecommendationApprove the PR. The fix is minimal, well-tested, and resolves the reported issue without introducing side effects or violating project conventions. No changes are needed. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
AI Code ReviewCritical IssuesNone found. Moderate IssuesNone found. Minor IssuesNone found. What Looks Good
RecommendationApprove. The PR correctly fixes the bug with appropriate tests, follows contribution guidelines, and maintains all project standards. No changes needed. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
ako
left a comment
There was a problem hiding this comment.
Code Review — PR #307
Overview: One-guard fix in emitActivityStatement to suppress annotations before unsupported-activity comments. Clean and well-motivated.
Fix correctness
if strings.HasPrefix(strings.TrimSpace(stmt), "--") {
*lines = append(*lines, indentStr+stmt)
return
}- Correctly intercepts before
emitObjectAnnotations, which unconditionally emits@position(x, y)for every object (no nil check, no condition) — so without this guard, every unsupported activity would produce orphaned annotations --is exclusively a comment marker in MDL; no valid statement starts with--, so the prefix check is unambiguousstrings.TrimSpaceis defensive —stmtat this point doesn't carry leading whitespace (indent is prepended separately) — harmless but could be dropped
Test correctness
TestTraverseFlow_UnsupportedActivitySkipsAnnotations is valid and would fail without the fix. mkObj("soap") produces a zero-valued BaseMicroflowObject, and emitObjectAnnotations calls:
pos := obj.GetPosition()
*lines = append(*lines, indentStr+fmt.Sprintf("@position(%d, %d)", pos.X, pos.Y))unconditionally — so @position(0, 0) would be emitted before the comment without the guard. The test correctly catches this.
The check for @position specifically is sufficient: emitObjectAnnotations is a single call that emits all annotation types atomically — if @position is absent, the rest are absent too.
Bug test script
The honest note that pure MDL can't reproduce the unsupported-activity path (requires an .mpr with an unknown action type) is appreciated. The positive control (annotated microflow that must still parse correctly after DESCRIBE) is the right substitute — it confirms the annotation-emission path for supported activities is unaffected.
Minor
- The fix is general: any new unsupported action type that returns a
-- ...statement automatically benefits without any additional changes - Adding
@anchorand@captionto the negative assertions alongside@positionwould make the test stricter, but since all come from the sameemitObjectAnnotationscall, the current single check is adequate
Overall: Approve. Minimal, correct fix with a meaningful test that would fail without it.
|
@hjotha can you rebase to fix the conflict? |
When the describer falls back to a placeholder comment for an activity it does not know how to render, preceding `@position(...)`, `@anchor(...)`, or similar annotations become orphaned on re-execution. The grammar accepts annotations only as a prefix of a real microflow statement. A comment placeholder is intentionally not a statement target, so annotation-prefixed comments can fail to parse. Skip object annotations when the formatted statement begins with `--`. The unsupported placeholder remains visible in describe output, but the generated MDL stays parseable. Tests cover unsupported/comment activity output with preceding activity metadata.
Adds an MDL script under mdl-examples/bug-tests/ documenting the unsupported-activity comment regression and providing a positive-control microflow that exercises annotated supported activities. Pure MDL cannot create unsupported activities; the negative case is covered by the existing Go test TestTraverseFlow_UnsupportedActivitySkipsAnnotations. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
bf04456 to
b68092a
Compare
AI Code ReviewWhat Looks Good
RecommendationApprove the PR. The fix is correct, well-tested, and maintains full-stack consistency for the existing Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
Part of #332.
Fixes #306.
Summary
Unsupported microflow activities are represented as comments in
DESCRIBE MICROFLOWoutput. This PR prevents activity annotations from being emitted before those comments, so the generated MDL remains parseable.Root cause
The describer emitted object annotations before every formatted activity result. For unsupported activity placeholders the formatted result starts with
--, leaving annotations orphaned because comments are not validmicroflowStatementtargets.Fix
When a formatted statement begins with a comment marker, emit only the comment and skip
emitObjectAnnotations.Tests
Added traversal coverage for unsupported/comment activity output with preceding activity metadata.
Validation
make buildmake testmake lint-gomake test-integrationAgentic Code Testing
Test plan