Skip to content

feat: first pass at guardian io contract subclasses#1357

Merged
AngeloDanducci merged 4 commits into
generative-computing:mainfrom
AngeloDanducci:ad-1332
Jul 1, 2026
Merged

feat: first pass at guardian io contract subclasses#1357
AngeloDanducci merged 4 commits into
generative-computing:mainfrom
AngeloDanducci:ad-1332

Conversation

@AngeloDanducci

Copy link
Copy Markdown
Contributor

Pull Request

Issue

Fixes #1332

Description

Adds io contract subclasses, adapter constants, and utilizes these via existing call sites in guardian.py

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code was added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Attribution

  • AI coding assistants used

Adding a new component, requirement, sampling strategy, or tool?

If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.

  • Component
  • Requirement
  • Sampling Strategy
  • Tool

NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.

@AngeloDanducci
AngeloDanducci requested a review from a team as a code owner June 29, 2026 15:37
@github-actions github-actions Bot added the enhancement New feature or request label Jun 29, 2026
Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>
Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>
Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>

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.

if this is deprecated, do we need to update or should we just leave alone?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, even though we're testing deprecation since we updated the signature on in guardian.py we will fail 6/8 tests with TypeErrors unless we update the def fake_call_intrinsic function.

@ajbozarth ajbozarth 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.

Some feedback from Claude — follow-ups inline.

One non-blocking flag on the PR description (transient, so just checking intent): the "100% coverage" checkbox and the issue's "19 tests unchanged" criterion don't match the final state — guardian.py is at 98.51%, and test_guardian_documents.py is 17 tests after the XOR cases moved into the contract tests. Did you mean to leave those as-is?

Comment thread mellea/stdlib/components/intrinsic/guardian.py
Comment thread mellea/stdlib/components/intrinsic/guardian.py Outdated
Comment thread mellea/stdlib/components/intrinsic/guardian.py
Comment thread mellea/stdlib/components/intrinsic/guardian.py Outdated
Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>
@AngeloDanducci
AngeloDanducci requested a review from ajbozarth June 30, 2026 18:49

@ajbozarth ajbozarth 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.

LGTM, but I'd defer final approval to others who've spent more time in the guardian code

@AngeloDanducci

Copy link
Copy Markdown
Contributor Author

I'll give Jake a day to add his 2C, otherwise can merge and iterate later if need be.

@psschwei psschwei 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.

I assume this is true:

matching the output schema documented in the HF README for each adapter

but would be confirm in the PR body

# ---------------------------------------------------------------------------


class _PolicyGuardrailsContract(IOContract):

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.

General comment / observation : in this PR we're implementing one contract class per intrinsic, whereas in #1321 they were more generic (for dict and list return types). My gut instinct is that it's probably better to be a little more generic if possible, but I'll also tag in @jakelorocco for his opinion.

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.

Yeah; I'm not quite certain how I feel about the super specific ones. I'm fine starting out this way but we may need to relax things in the future. Ultimately, we do have to specify this somewhere.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(intrinsics): guardian.py IOContract subclasses + Adapter constants (Epic #929 Phase 1 follow-up)

4 participants