Skip to content

fix(generator): Handle object types in qualityStandards section - #28

Merged
ldangelo merged 2 commits into
mainfrom
fix/quality-standards-object-rendering
Feb 4, 2026
Merged

fix(generator): Handle object types in qualityStandards section#28
ldangelo merged 2 commits into
mainfrom
fix/quality-standards-object-rendering

Conversation

@ldangelo

@ldangelo ldangelo commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixed a bug where the qualityStandards section in agent YAML files was rendering as [object Object] in generated markdown.

What was broken

The agent-transformer.js was treating qualityStandards.codeQuality, qualityStandards.testing, and qualityStandards.performance as simple string arrays. However, the YAML schema allows these to be arrays of objects with properties like:

  • name
  • description
  • enforcement (required/recommended)
  • target
  • minimum

Before (broken):

### Code Quality
- [object Object]
- [object Object]
- [object Object]

Why it was broken

When the generator encountered these objects, it interpolated them as strings using template literals:

for (const item of agentData.qualityStandards.codeQuality) {
  parts.push(`- ${item}`);  // item is an object, not a string!
}

JavaScript converts objects to [object Object] when coerced to strings.

How it was fixed

Updated the transformer to:

  1. Check if items are objects vs strings
  2. Properly extract name, description, enforcement, target, and minimum properties
  3. Handle both array and object formats for testing section
  4. Add support for performance section
  5. Maintain backward compatibility with simple string arrays

After (fixed):

### Code Quality
- **PRD File Management Compliance** (required): 100% of PRDs must be saved directly to @docs/PRD/...
- **User Research Validation** (required): All feature proposals must be validated...

### Testing
- **userValidation** (target: 80%): Percentage of features validated with users...
- **stakeholderAlignment** (target: 90%): Stakeholder satisfaction score...

### Performance
- **PRD Creation Time** (target: ≤3 days): Time from discovery kickoff to completed PRD...

Affected agents

12 agents with qualityStandards sections:

  • product-management-orchestrator
  • code-reviewer
  • tech-lead-orchestrator
  • deep-debugger
  • test-runner
  • frontend-developer
  • infrastructure-developer
  • ensemble-orchestrator
  • file-creator
  • documentation-specialist
  • api-documentation-specialist
  • release-agent

Testing

  • npm run generate completes successfully
  • ✅ All 42 files regenerated
  • ✅ Verified affected agents render correctly
  • ✅ Existing tests pass (pre-existing WezTerm/pytest failures unrelated)

The agent-transformer.js was treating qualityStandards.codeQuality,
qualityStandards.testing, and qualityStandards.performance as simple
string arrays. However, the YAML schema allows these to be arrays of
objects with properties like name, description, enforcement, target,
and minimum.

When the generator encountered these objects, it would interpolate them
as strings, resulting in '[object Object]' appearing in the generated
markdown.

Changes:
- Handle codeQuality items as objects with name, description, enforcement
- Handle testing as either array or object format with nested properties
- Add support for performance metrics with name, target, and description
- Maintain backward compatibility with simple string arrays

Affected agents:
- product-management-orchestrator
- code-reviewer
- tech-lead-orchestrator
- and 9 other agents with qualityStandards
@claude

claude Bot commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Code Review for PR #28

Summary

This PR successfully fixes a critical bug where qualityStandards sections in agent YAML files were rendering as [object Object] in generated markdown. The fix properly handles object types in codeQuality, testing, and performance sections.


✅ Strengths

  1. Root Cause Analysis: Excellent identification of the problem - JavaScript's string coercion of objects to [object Object]

  2. Backward Compatibility: The implementation correctly handles both legacy string arrays and new object formats with proper type checking

  3. Comprehensive Coverage: Handles three different data structures:

    • Simple string arrays (legacy)
    • Object arrays with name/description/enforcement (codeQuality, performance)
    • Object maps with nested properties (testing section)
  4. Null Safety: Proper null checks before processing (item && typeof item === 'object')

  5. Clear Documentation: The PR description is excellent - clear before/after examples, affected agents listed, testing completed


⚠️ Issues & Recommendations

1. Code Duplication (Medium Priority)

Location: scripts/lib/agent-transformer.js:233-269

The string vs object handling logic is duplicated across codeQuality, documentation, and the array branch of testing. Consider extracting this to a helper function in a follow-up PR to reduce maintenance burden and ensure consistency.

2. Inconsistent Null Handling (Low Priority)

Location: scripts/lib/agent-transformer.js:296-304

The testing object branch at line 302 has parts.push(\- ${key}: ${value}`)which could render null/undefined values. Consider adding a guard:} else if (value !== null && value !== undefined) {`

3. Missing Test Coverage (High Priority)

Issue: No unit tests exist for agent-transformer.js

Recommendation: Add test file scripts/lib/__tests__/agent-transformer.test.js with test cases for:

  • String arrays (legacy format)
  • Object arrays with name/description/enforcement
  • Testing as object map with minimum/description
  • Performance with target values
  • Null/undefined handling
  • Empty objects
  • Mixed formats

This is critical for preventing regressions and documenting expected behavior.

4. Edge Case: Empty Objects (Low Priority)

Issue: Empty objects {} in arrays would silently skip rendering with no warning

Recommendation: Add debug logging for malformed items to help troubleshoot YAML issues during development

5. Documentation Gap (Medium Priority)

Issue: The YAML schema documentation may need updates

Recommendation: Verify if schemas/agent-schema.json or similar exists and update it to formally document the object structures for codeQuality, testing, and performance


🔒 Security Considerations

✅ No security concerns - this is a build-time code generation script with no runtime impact or user input processing


⚡ Performance Considerations

✅ No performance concerns - the additional type checks are trivial and only run during npm run generate


🧪 Test Coverage Assessment

Current State: ❌ No unit tests for transformer
Manual Testing: ✅ Verified via npm run generate on 12 affected agents
Impact: Medium risk - future changes could break without test coverage

Recommendation: Add tests before next release


📋 Checklist for Merge

  • ✅ Code quality: Good, with minor refactoring opportunities
  • ⚠️ Test coverage: Manual testing done, automated tests recommended
  • ✅ Documentation: Excellent PR description
  • ✅ Backward compatibility: Maintained
  • ✅ Follows repo conventions: Uses conventional commits (fix(generator):)
  • ⚠️ Schema updates: Should verify YAML schema documentation

🎯 Recommendation: APPROVE WITH SUGGESTIONS

This PR successfully fixes a critical bug and is safe to merge. The suggested improvements (especially unit tests and refactoring) can be addressed in follow-up PRs.

Optional follow-up tasks:

  1. Add unit tests for agent-transformer.js
  2. Extract duplicate formatting logic to helper function
  3. Update YAML schema documentation if it exists
  4. Add warning logs for malformed quality standard items

Great work on the detailed analysis and backward-compatible implementation! 🚀

ldangelo added a commit that referenced this pull request Feb 4, 2026
The command-transformer.js was treating step.mcp_tool as an implicit field
that was ignored during markdown generation. However, the YAML allows mcp_tool
objects with properties like name, usage, and fallback.

When the generator encountered these objects, they were not rendered at all
in the generated markdown, losing important MCP tool configuration information.

Changes:
- Handle mcp_tool as an object with name, usage, and fallback properties
- Maintain backward compatibility with string-only mcp_tool values
- Format usage as multi-line content, fallback as inline description
- Similar pattern to delegation object handling

Affected commands:
- create-trd (3 MCP tool steps now properly documented)

This follows the same pattern as PR #28 which fixed object rendering in
the agent-transformer.js for qualityStandards sections.
@ldangelo
ldangelo merged commit 6c9f1c0 into main Feb 4, 2026
4 checks passed
@ldangelo
ldangelo deleted the fix/quality-standards-object-rendering branch February 4, 2026 04:29
ldangelo added a commit that referenced this pull request Feb 4, 2026
Version bump for generator fixes.

Changes included:
- fix(generator): Handle object types in qualityStandards section (PR #28)
- fix(generator): Handle mcp_tool objects in command transformer (PR #29)

Affected packages:
- ensemble-plugins: 5.0.0 -> 5.2.3
- @fortium/ensemble-core: 5.2.1 -> 5.2.3
- @fortium/ensemble-development: 5.2.1 -> 5.2.3
- @fortium/ensemble-quality: 5.2.1 -> 5.2.3
- @fortium/ensemble-infrastructure: 5.2.1 -> 5.2.3
- @fortium/ensemble-product: 5.2.1 -> 5.2.3
- @fortium/ensemble-full: 5.2.2 -> 5.2.3
ldangelo added a commit that referenced this pull request Jun 18, 2026
…ect-rendering

fix(generator): Handle object types in qualityStandards section
ldangelo added a commit that referenced this pull request Jun 18, 2026
The command-transformer.js was treating step.mcp_tool as an implicit field
that was ignored during markdown generation. However, the YAML allows mcp_tool
objects with properties like name, usage, and fallback.

When the generator encountered these objects, they were not rendered at all
in the generated markdown, losing important MCP tool configuration information.

Changes:
- Handle mcp_tool as an object with name, usage, and fallback properties
- Maintain backward compatibility with string-only mcp_tool values
- Format usage as multi-line content, fallback as inline description
- Similar pattern to delegation object handling

Affected commands:
- create-trd (3 MCP tool steps now properly documented)

This follows the same pattern as PR #28 which fixed object rendering in
the agent-transformer.js for qualityStandards sections.
ldangelo added a commit that referenced this pull request Jun 18, 2026
Version bump for generator fixes.

Changes included:
- fix(generator): Handle object types in qualityStandards section (PR #28)
- fix(generator): Handle mcp_tool objects in command transformer (PR #29)

Affected packages:
- ensemble-plugins: 5.0.0 -> 5.2.3
- @fortium/ensemble-core: 5.2.1 -> 5.2.3
- @fortium/ensemble-development: 5.2.1 -> 5.2.3
- @fortium/ensemble-quality: 5.2.1 -> 5.2.3
- @fortium/ensemble-infrastructure: 5.2.1 -> 5.2.3
- @fortium/ensemble-product: 5.2.1 -> 5.2.3
- @fortium/ensemble-full: 5.2.2 -> 5.2.3
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.

1 participant