Skip to content

feat: pre built requirements#606

Open
akihikokuroda wants to merge 4 commits intogenerative-computing:mainfrom
akihikokuroda:pre-builtreq
Open

feat: pre built requirements#606
akihikokuroda wants to merge 4 commits intogenerative-computing:mainfrom
akihikokuroda:pre-builtreq

Conversation

@akihikokuroda
Copy link
Member

@akihikokuroda akihikokuroda commented Mar 9, 2026

Misc PR

Type of PR

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Description

Testing

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

@akihikokuroda akihikokuroda requested a review from a team as a code owner March 9, 2026 15:50
@akihikokuroda akihikokuroda marked this pull request as draft March 9, 2026 15:51
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

The PR description has been updated. Please fill out the template for your PR to be reviewed.

@mergify
Copy link

mergify bot commented Mar 9, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|release)(?:\(.+\))?:

Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
@akihikokuroda
Copy link
Member Author

akihikokuroda commented Mar 9, 2026

Remaining items:

Guardian intrinsics integration and
NLI-based factual grounding

are in the follow up PRs.

@akihikokuroda akihikokuroda marked this pull request as ready for review March 9, 2026 17:44
@akihikokuroda
Copy link
Member Author

Guardian intrinsics integration

It seems that already implemented.

@psschwei
Copy link
Member

@nrfulton would this go better here or in mellea-contribs?

Comment on lines +65 to +67
# Note: remove() uses identity (is), not equality (==)
# Since we're creating new instances, this won't find them
# This is expected behavior - remove by reference
Copy link
Member

Choose a reason for hiding this comment

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

does this mean that remove() doesn't work? not quite sure I follow what's going on here

Copy link
Member Author

Choose a reason for hiding this comment

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

This is related to the self.copy(). For the operation functions, a copy argument is added. Remove works without the copy.

Comment on lines +727 to +731
keywords = RISK_KEYWORDS[risk]
for keyword in keywords:
if keyword in text:
detected_risks.append(risk)
break
Copy link
Member

Choose a reason for hiding this comment

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

if I'm understanding right, this requirement basically checks to see if specific terms are used, and if they are then it flags them as a risk. There's a major risk of false positives here... we might want to reevaluate this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the keyword base implementation so there are limitations and it is added in the comment. "Guardian intrinsics integration" should improve it. We can add it in a separate PR.

or the deprecated GuardianCheck class with appropriate backends.
"""
# Define harmful keywords for each risk type
RISK_KEYWORDS = {
Copy link
Member

Choose a reason for hiding this comment

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

should we define this top level (rather than recreating each time we call this function)?


combined = safety + format
assert isinstance(combined, RequirementSet)
# Note: May have duplicates (e.g., no_pii appears in both)
Copy link
Member

Choose a reason for hiding this comment

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

would it be better to dedupe when composing profiles?

Copy link
Member Author

@akihikokuroda akihikokuroda Mar 10, 2026

Choose a reason for hiding this comment

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

To make it work, eq/hash have to be added to the base Requirement class. For now, a separate deduplicate method is added to deduplicate manually.

raise TypeError(
f"Expected Requirement instance, got {type(requirement).__name__}"
)
new_set = self.copy()
Copy link
Member

Choose a reason for hiding this comment

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

looks like all the functions here call self.copy(). do we need to make full copies each time? (that could get expensive)

Copy link
Member Author

Choose a reason for hiding this comment

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

immutability prevents bugs and makes behavior predictable so a copy argument is added to the operation method not to copy optionally.

Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
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.

Expand pre-built requirements library for common guardrail patterns

2 participants