Skip to content

pbs rules engine module - #6044

Open
bretg wants to merge 6 commits into
masterfrom
pbs-rules-engine
Open

bretg wants to merge 6 commits into
masterfrom
pbs-rules-engine

Conversation

@bretg

@bretg bretg commented May 22, 2025

Copy link
Copy Markdown
Contributor

🏷 Type of documentation

  • new bid adapter
  • update bid adapter
  • new feature
  • text edit only (wording, typos)
  • bugfix (code examples)
  • new examples

Documentation for the PBS Rules Engine module. See prebid/prebid-server#2541

@netlify

netlify Bot commented May 22, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for prebid-docs-preview ready!

Name Link
🔨 Latest commit 9fda8fc
🔍 Latest deploy log https://app.netlify.com/projects/prebid-docs-preview/deploys/68628b977fd16700086b05e8
😎 Deploy Preview https://deploy-preview-6044--prebid-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@bretg
bretg marked this pull request as draft May 22, 2025 14:57
@bretg
bretg marked this pull request as ready for review June 30, 2025 13:05
@ChrisHuie
ChrisHuie self-requested a review July 2, 2025 20:06

- Runs only at the Processed-Auction stage.
- Only delivers functions for including and excluding bidders.
- Does not necessarily reload config periodically like the Floors feature, making integration with a backend machine learning system more challenging.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Go can reload config periodically assuming the host is somehow taking the machine learning system data and using it to update the account with new rules and the account fetcher is configured to be periodically fetched. Is this an example of how you envision it integrating with a backend machine learning system?

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.

The Floors feature takes a URL and polls it periodically for updates. i.e. there's no work for the Host Company to update data.

How about to make this clear we say something like "Unlike the Floors feature, the rules module does not fetch data on an external URL. To update the rules, the Host Company needs to merge updated data into the account system."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI assistant reply, posted on behalf of Patrick McCann (not written personally by Patrick):

The updated docs clarify this: unlike Floors, the Rules Engine does not poll a separate rules URL. A host can update the account config, with the account fetcher periodically refreshing it. PBS-Go hashes the received config and rebuilds its tree when changed. This is the host-mediated ML feedback loop, not a direct optimizer integration.

Comment on lines +59 to +60
"hooks": {
"modules": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I thought the hooks.enabled flag needs to be set:

"hooks": {
    "enabled": true

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.

@And1sS - is this the same for PBS-Java?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI assistant reply, posted on behalf of Patrick McCann (not written personally by Patrick):

Agreed. The updated PBS-Go examples explicitly set hooks.enabled: true; the Go hooks configuration exposes enabled at the hooks level.

{
"hooks": {
"modules": {
"pb-rules-engine": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should be modules.vendor.module:

"modules": {
    "prebid": {
        "rules-engine": {

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.

@And1sS - same for PBS-J?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI assistant reply, posted on behalf of Patrick McCann (not written personally by Patrick):

Agreed for PBS-Go: the module lives under hooks.modules.prebid.rulesengine (vendor prebid, module rulesengine). Java differs: its module code is pb-rule-engine. The docs now distinguish them.

"modules": {
"pb-rules-engine": {
"enabled": true,
"timestamp": "20250314 00:00:00",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is not currently implemented in Go but I think we should leave it in the docs and we will support it. Right now Go is hashing the fetched config and comparing it against a cached hash to determine if there is a change but we will add timestamp support.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI assistant reply, posted on behalf of Patrick McCann (not written personally by Patrick):

Go's current configuration struct has a top-level timestamp, but the cache currently compares a hash of account config rather than using this timestamp as the recompile trigger. The docs now say so; timestamp-based invalidation should not be promised until implemented.

"results": [{
"function": "excludeBidders",
"args": [{
"bidders": [],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As mentioned earlier, Go is considering it an error when bidders is empty. Couldn't you just omit this set of conditions in which case the default would be executed? I guess perhaps this has value in case you want to specify defaults but then not apply those defaults in certain instances like this. What do you think?

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.

Right - the default might be to remove bidderA, and one of the leaves says not to remove anything.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI assistant reply, posted on behalf of Patrick McCann (not written personally by Patrick):

Agree an empty bidders list is not valid for Go. The leaf was meant to represent 'do nothing, rather than execute the default'. A valid alternative would be a logATag result for that leaf or a different explicit default, not excludeBidders with bidders: []. This is an example behavior issue, not just a lint issue.

}
```

And here's how these scenarios would play out in various runtime conditions:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"And here's how these scenarios would play out in various runtime conditions given the following request:"

Then we need to add the request here with the two imps as that is missing.

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.

The test request in the PRD is quite large. How about we make a copy of a test JSON file available, link to it, and then note that it's just a template for these test requests?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI assistant reply, posted on behalf of Patrick McCann (not written personally by Patrick):

Agreed—the original sample lacks a concrete two-imp request, so exact per-imp removal statements are not independently reproducible. A minimal checked-in request JSON showing the two impressions and their bidder arrays would make those examples testable. I haven't added such a fixture yet.

We recommend placing the execution plan at the host level so all accounts have the module enabled.

```json5
"execution-plan": {

@bsardo bsardo Sep 19, 2025 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this called host-execution-plan in Java? It is host_execution_plan in Go.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI assistant reply, posted on behalf of Patrick McCann (not written personally by Patrick):

Yes—this is implementation-specific. PBS-Go uses hooks.host_execution_plan (snake_case), as defined in config/hooks.go. PBS-Java uses hooks.host-execution-plan (kebab-case), as documented in its docs/config-app.md and sample module configurations. The revised installation section intentionally shows a Go example and warns that Java has different configuration names.

"groups": [{
"timeout": 10,
"hook-sequence": [{
"module-code": "rules-engine",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Isn't this supposed to be of the format vendor.module_name in which case "prebid.rules-engine"?

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI assistant reply, posted on behalf of Patrick McCann (not written personally by Patrick):

For PBS-Go the module code is prebid.rulesengine (without a hyphen): the module registry exposes rulesengine under vendor prebid, and its hook execution plan uses the {vendor}.{module} form. PBS-Java is different: its PbRuleEngineModule.CODE is pb-rule-engine, and the hook implementation code is pb-rule-engine-processed-auction-request-hook. The revised Go installation example uses prebid.rulesengine.

@bsardo bsardo self-assigned this Sep 19, 2025
@netlify

netlify Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for prebid-docs-preview ready!

Name Link
🔨 Latest commit 65f48b8
🔍 Latest deploy log https://app.netlify.com/projects/prebid-docs-preview/deploys/6ae2996b55643ceebc0a00b5
😎 Deploy Preview https://deploy-preview-6044--prebid-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@patmmccann
patmmccann requested a review from bsardo October 30, 2026 20:32

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants