Skip to content

feat(#4129): add agent field validation to AIResource extensions processor - #4246

Open
fullsend-ai-coder[bot] wants to merge 2 commits into
mainfrom
agent/4129-agent-processor-validation
Open

feat(#4129): add agent field validation to AIResource extensions processor#4246
fullsend-ai-coder[bot] wants to merge 2 commits into
mainfrom
agent/4129-agent-processor-validation

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Extend AIResourceExtensionsProcessor to validate agent-specific fields when spec.type is 'agent'. Add collectAgentErrors helper (following the collectOciErrors pattern) that checks:

  • spec.instructions: required, non-empty string
  • spec.handoffs / spec.tools: must be arrays if present (opaque strings
    accepted without entity-ref format enforcement)
  • spec.resetToolChoice: must be boolean if present
  • spec.modelSettings: must be plain object if present
  • spec.toolUseBehavior: must be string or string array if present
  • spec.outputSchema: must be string or object if present
  • spec.handoffDescription / spec.model: must be strings if present

All errors are collected and reported together. Non-agent AiResource entities (skill, rule, model) are unaffected. Error messages name the field path and problem without exposing internal class names.


Closes #4129

Post-script verification

  • Branch is not main/master (agent/4129-agent-processor-validation)
  • Secret scan passed (gitleaks — 258cfc701b040f64cb74cb7316d749f029d09617..HEAD)
  • Pre-commit hooks passed (authoritative run on runner)
  • Tests ran inside sandbox

…essor

Extend AIResourceExtensionsProcessor to validate agent-specific fields
when spec.type is 'agent'. Add collectAgentErrors helper (following the
collectOciErrors pattern) that checks:

- spec.instructions: required, non-empty string
- spec.handoffs / spec.tools: must be arrays if present (opaque strings
  accepted without entity-ref format enforcement)
- spec.resetToolChoice: must be boolean if present
- spec.modelSettings: must be plain object if present
- spec.toolUseBehavior: must be string or string array if present
- spec.outputSchema: must be string or object if present
- spec.handoffDescription / spec.model: must be strings if present

All errors are collected and reported together. Non-agent AiResource
entities (skill, rule, model) are unaffected. Error messages name the
field path and problem without exposing internal class names.

Closes #4129
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Agent PR ready for human review label Aug 10, 2026
@rhdh-gh-app

rhdh-gh-app Bot commented Aug 10, 2026

Copy link
Copy Markdown

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @red-hat-developer-hub/backstage-plugin-catalog-backend-module-ai-resource-agent

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-catalog-backend-module-ai-resource-agent workspaces/ai-integrations/plugins/catalog-backend-module-ai-resource-agent none v0.2.0

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.96970% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.54%. Comparing base (258cfc7) to head (bdc0eb9).
⚠️ Report is 20 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4246      +/-   ##
==========================================
+ Coverage   58.52%   58.54%   +0.02%     
==========================================
  Files        2447     2449       +2     
  Lines       97252    97317      +65     
  Branches    26994    27025      +31     
==========================================
+ Hits        56913    56977      +64     
+ Misses      40146    40140       -6     
- Partials      193      200       +7     
Flag Coverage Δ *Carryforward flag
adoption-insights 84.55% <ø> (ø) Carriedforward from 8ab4eee
ai-integrations 72.46% <96.96%> (+2.70%) ⬆️
app-defaults 69.79% <ø> (ø) Carriedforward from 8ab4eee
augment 46.67% <ø> (ø) Carriedforward from 8ab4eee
boost 77.63% <ø> (ø) Carriedforward from 8ab4eee
bulk-import 72.79% <ø> (ø) Carriedforward from 8ab4eee
cost-management 13.55% <ø> (ø) Carriedforward from 8ab4eee
dcm 67.21% <ø> (ø) Carriedforward from 8ab4eee
extensions 56.59% <ø> (ø) Carriedforward from 8ab4eee
global-floating-action-button 71.18% <ø> (ø) Carriedforward from 8ab4eee
global-header 66.50% <ø> (ø) Carriedforward from 8ab4eee
homepage 47.59% <ø> (ø) Carriedforward from 8ab4eee
install-dynamic-plugins 59.95% <ø> (ø) Carriedforward from 8ab4eee
intelligent-assistant 75.24% <ø> (ø) Carriedforward from 8ab4eee
konflux 91.98% <ø> (ø) Carriedforward from 8ab4eee
lightspeed 69.02% <ø> (ø) Carriedforward from 8ab4eee
mcp-integrations 83.40% <ø> (ø) Carriedforward from 8ab4eee
orchestrator 68.10% <ø> (ø) Carriedforward from 8ab4eee
quickstart 63.74% <ø> (ø) Carriedforward from 8ab4eee
sandbox 79.56% <ø> (ø) Carriedforward from 8ab4eee
scorecard 86.23% <ø> (ø) Carriedforward from 8ab4eee
theme 88.77% <ø> (ø) Carriedforward from 8ab4eee
translations 5.12% <ø> (ø) Carriedforward from 8ab4eee
x2a 79.20% <ø> (ø) Carriedforward from 8ab4eee

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 258cfc7...bdc0eb9. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@johnmcollier johnmcollier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Request changes

Agent field validation landed in the wrong place relative to #4128 / #4164. Please rework this PR rather than polishing the current AIResourceExtensionsProcessor approach.

1) Follow the previous PR’s packaging approach

#4128 put agent typing in dedicated packages:

  • catalog-model-ai-resource-agent (types / JSON schema / KindValidator)
  • catalog-backend-module-ai-resource-agent (catalog model registration for kind: AiResource)

Do not extend AIResourceExtensionsProcessor with agent-specific field rules. That processor should stay focused on shared RHDH extensions (spec.scope, OCI source-location).

If RHIDP-15868 still needs catalog-processor coverage beyond the existing agent KindValidator, put it in the agent backend module (matching AiResource), not in catalog-backend-module-ai-resource-extensions.

Also align kind casing with #4128 (AiResource), not AIResource.

2) Update OpenSpec to match that architecture

The current OpenSpec steered this PR incorrectly (notably D10 / tasks §5 / proposal “extend the AiResource extensions processor path”). Update the OpenSpec change materials under workspaces/ai-integrations/openspec/changes/airesource-agent-typed-schema/ so they reflect:

  • Agent schema + agent ingestion validation live with the agent packages / module
  • AIResourceExtensionsProcessor remains scope/OCI only
  • Kind spelling AiResource consistent with examples and the agent model

Please amend design.md, tasks.md, proposal.md, and the ai-resource-agent-ingestion spec as needed so the next coding pass cannot re-learn the wrong home.

Out of scope for this fix round

Fullsend workflow/skill changes for OpenSpec drift feedback loops — track separately.

@johnmcollier

Copy link
Copy Markdown
Member

/fs-fix

@fullsend-ai-coder

fullsend-ai-coder Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 8:28 PM UTC · Completed 8:46 PM UTC

Commit: 8ab4eee · View workflow run →

Move collectAgentErrors and agent field validation out of
AIResourceExtensionsProcessor into catalog-backend-module-ai-resource-agent
as AiResourceAgentProcessor, matching the packaging approach from #4128.

- Remove agent-specific code from AIResourceExtensionsProcessor (scope/OCI only)
- Add AiResourceAgentProcessor to catalog-backend-module-ai-resource-agent
- Register processor alongside model source in the agent backend module
- Update OpenSpec design.md, tasks.md, proposal.md to reflect architecture
- Align kind casing with AiResource (matching #4128)

Addresses review feedback on #4246

Assisted-by: Claude Code
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 1 (human-triggered)

Addressed all 4 review findings. Moved agent field validation from AIResourceExtensionsProcessor to a new AiResourceAgentProcessor in catalog-backend-module-ai-resource-agent. Updated OpenSpec documents (design.md, tasks.md, proposal.md) to reflect the correct architecture. All tests pass (102 tests across both packages).

Fixed (4):

  1. Follow the previous PR's packaging approach — move agent validation to agent backend module (workspaces/ai-integrations/plugins/catalog-backend-module-ai-resource-agent/src/AiResourceAgentProcessor.ts): Moved collectAgentErrors and agent field validation out of AIResourceExtensionsProcessor into catalog-backend-module-ai-resource-agent as AiResourceAgentProcessor. The extensions processor now only handles scope and OCI validation.
  2. Do not extend AIResourceExtensionsProcessor with agent-specific field rules (workspaces/ai-integrations/plugins/catalog-backend-module-ai-resource-extensions/src/AIResourceExtensionsProcessor.ts): Removed collectAgentErrors import, usage, and agent-specific JSDoc from AIResourceExtensionsProcessor. Deleted collectAgentErrors.ts and collectAgentErrors.test.ts from the extensions package. Removed agent test block from processor integration tests.
  3. Align kind casing with ai-integrations: AiResource agent typed schema (catalog-model validator + examples) #4128 (AiResource, not AIResource) (workspaces/ai-integrations/plugins/catalog-backend-module-ai-resource-agent/src/AiResourceAgentProcessor.ts): New AiResourceAgentProcessor uses AiResource kind casing consistent with ai-integrations: AiResource agent typed schema (catalog-model validator + examples) #4128 and the agent model packages. The processor checks entity.kind === 'AiResource'.
  4. Update OpenSpec to match that architecture (workspaces/ai-integrations/openspec/changes/airesource-agent-typed-schema/design.md): Updated D5 and D10 in design.md, task 5 in tasks.md, and proposal.md to reflect that agent validation lives in catalog-backend-module-ai-resource-agent as AiResourceAgentProcessor, not in AIResourceExtensionsProcessor. Clarified kind spelling is AiResource.

Tests: passed

Decision points
  • Chose to create AiResourceAgentProcessor as a CatalogProcessor registered alongside the model source in the same backend module (alternatives: Extend the existing KindValidator with runtime checks, Create a separate backend module for the processor; rationale: Matches the existing module pattern — the agent backend module already registers the model source, so co-locating the processor keeps all agent-specific catalog behavior in one module)

Updated by fullsend fix agent

@sonarqubecloud

Copy link
Copy Markdown

@johnmcollier

Copy link
Copy Markdown
Member

/fs-review

1 similar comment
@johnmcollier

Copy link
Copy Markdown
Member

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Aug 11, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 9:53 PM UTC · Completed 10:10 PM UTC

Commit: bdc0eb9 · View workflow run →

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Medium

  • [scope-deviation] workspaces/ai-integrations/plugins/catalog-backend-module-ai-resource-agent/src/AiResourceAgentProcessor.ts — Issue ai-integrations: catalog processor validation for AiResource agent type #4129 says "Prefer extending the existing ... extensions processor ... rather than inventing a parallel validation path." The PR instead creates a separate AiResourceAgentProcessor. The parenthetical "or equivalent registered processor path" in the issue's first task partially authorizes alternatives, and the kind spelling difference ('AIResource' vs 'AiResource') provides genuine technical justification — extending AIResourceExtensionsProcessor would require changing its kind check, potentially breaking existing scope/OCI validation. Consider calling out this architectural deviation in the PR description and getting maintainer acknowledgment.

  • [misleading-title] — The PR title says "add agent field validation to AIResource extensions processor" but the PR does NOT modify AIResourceExtensionsProcessor. It creates an entirely separate AiResourceAgentProcessor in catalog-backend-module-ai-resource-agent. Consider updating the title to accurately reflect the change, e.g., "feat(ai-integrations: catalog processor validation for AiResource agent type #4129): add AiResourceAgentProcessor for agent field validation."

  • [missing-documentation] workspaces/ai-integrations/plugins/catalog-backend-module-ai-resource-agent/README.md — The package now exports a new public class AiResourceAgentProcessor but has no README. The sibling package catalog-backend-module-ai-resource-extensions has a comprehensive README documenting its processor, validated fields, and registration instructions. Consider adding a README following that pattern.

Low

  • [self-authorization] workspaces/ai-integrations/openspec/changes/airesource-agent-typed-schema/design.md — The design doc (D5, D10), proposal.md, and tasks.md are modified in this PR to justify the separate-processor approach. While the changes are visible in the diff and reflect a genuine technical constraint (kind spelling), calling them out in the PR description would improve reviewability.

  • [edge-case] workspaces/ai-integrations/plugins/catalog-backend-module-ai-resource-agent/src/collectAgentErrors.ts — Whitespace-only spec.instructions (e.g., ' ') passes validation since the check uses instructions === ''. The JSON schema also does not reject whitespace, so this is consistent — but a whitespace-only system prompt is functionally empty.

  • [validation-gap] workspaces/ai-integrations/plugins/catalog-backend-module-ai-resource-agent/src/collectAgentErrors.tshandoffs and tools validators check Array.isArray() but do not verify elements are strings. This is consistent with the design intent (processor validates structural shape; schema handles element types) and the issue requirement to "accept opaque string[] without entity-ref format enforcement."

@fullsend-ai-review fullsend-ai-review Bot added the requires-manual-review Review requires human judgment label Aug 11, 2026

@johnmcollier johnmcollier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Second review pass

Architecture move looks right: agent field validation now lives in catalog-backend-module-ai-resource-agent as AiResourceAgentProcessor (alongside the agent model), and AIResourceExtensionsProcessor stays scope/OCI-only. That packaging split is intentional — not a problem to reverse.

Please address the remaining actionable items from the bot review (and stale PR metadata):

1) Update PR title

Current title still says “add agent field validation to AIResource extensions processor.” Update to something accurate, e.g.:
feat(#4129): add AiResourceAgentProcessor for agent field validation

2) Add package README

Add workspaces/ai-integrations/plugins/catalog-backend-module-ai-resource-agent/README.md documenting:

  • what the module registers (agent catalog model + AiResourceAgentProcessor)
  • that it targets kind: AiResource / spec.type: agent
  • which agent fields are validated (mirror the processor JSDoc / sibling extensions README style)
  • that shared RHDH extensions (scope / OCI) remain in catalog-backend-module-ai-resource-extensions

3) Refresh PR description

Replace the body that still describes extending AIResourceExtensionsProcessor. Briefly note:

  • validation lives in the agent backend module (same packaging approach as #4128)
  • OpenSpec (airesource-agent-typed-schema) was updated to match
  • extensions processor is unchanged for agent fields

Do not change

  • Whitespace-only instructions / array element-type checks — leave as intentional schema/processor layering
  • Do not move validation back into AIResourceExtensionsProcessor

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

Labels

ready-for-review Agent PR ready for human review requires-manual-review Review requires human judgment workspace/ai-integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ai-integrations: catalog processor validation for AiResource agent type

1 participant