Repository navigation
Fixes #38796: Let a workflow list the bots whose changes start it - #38797
Conversation
Since 2.1 a bot's change never starts a governance workflow and is never held for approval. That keeps ingestion out of review queues, but blocks automation that exists to propose content for people to review. An eventBasedEntity trigger now lists, in triggeringBots, the bots whose changes start it: - WorkflowEventConsumer drops a bot's change before Flowable unless a workflow on the entity type lists the bot, and tags the change with the bot (triggeringBot variable). - FilterEntityImpl starts the run only for the workflows that list that bot. - ApprovalGate holds a listed bot's edit for the Enforce workflows that list it. - GovernanceApprovalRegistry's snapshot carries the lists, resolved to the users the bots write as. - Saving a workflow refuses an unknown bot, a system bot and an application's bot; only newly listed bots are checked. governance-bot never starts a workflow. - Workflow builder: a bot picker on the start node, listing only bots an admin created. The list is empty by default, so no stored workflow changes behaviour.
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
- A bot left behind by an uninstalled application keeps its "<AppName>Bot" name but loses the application's link, so it looked admin-created. Saving a workflow now also refuses a bot named for a marketplace or installed application, and the Triggering Bots picker hides it. - The picker kept showing a saved bot's raw name after the bot list loaded: useSyncedListData now relabels the selection when its label function changes.
…gering-bots # Conflicts: # docs/decisions/2026-10-22-agent-glossary-proposals-are-decided-through-the-approval-workflow.md
…llel - The decision record now states how an application's bot is recognised: the installed application's link, or its "<application name>Bot" name for an installed or marketplace application, and why a leftover bot of an uninstalled application must be refused too. - The Triggering Bots picker fetches installed and marketplace applications concurrently.
- A workflow lists several bots; a change has one author. The process variable that carries that author is now changedByBot (was triggeringBot), and the comments say so. - WorkflowTriggeringBotsIT: one Enforce workflow listing two bots holds both bots' edits as separate change requests.
ShaileshParmar11
left a comment
There was a problem hiding this comment.
Review at 57ad210. I found one 🔴, inline below. manerow's threads cover the other gaps, so I have not repeated them.
| List<GatingRule> rules, String user, String impersonatedBy) { | ||
| return rules.isEmpty() || !isBotChange(user, impersonatedBy) | ||
| ? rules | ||
| : rules.stream().filter(rule -> rule.triggeringBotUsers().contains(user)).toList(); |
There was a problem hiding this comment.
🔴 The gate now holds workflow automation's own writes when a listed bot is the requester.
Trigger:
- An Enforce workflow on an entity type lists bot X, and it gates a field that a workflow sets. Examples: the stage/status (
STRUCTURAL_FIELDSnotes that "a stage change gates like any other field"), or the certification. - A workflow run whose requester is X writes that field. Two runs do this:
- A Default workflow on the type that also lists X. Its global
updatedByisevent.getUserName(), which is X. - The Enforce workflow's own run for X's held change.
ChangeRequestDeliverysetsupdatedBytorequest.getRequestedBy(), which is X.
- A Default workflow on the type that also lists X. Its global
Result:
SetEntityAttribute,SetEntityCertificationandSetGlossaryTermStatuswrite as X, withgovernance-botas impersonator. The call goes throughEntityFieldUtils.setEntityField, thenrepository.patch(..., X, ..., "governance-bot"), thenadmitOrVerify(no approval), thenApprovalGate.admit.- Here,
isBotChange(X, "governance-bot")is true, so this line keeps every rule that lists X. The automation's write is then staged as a new change request instead of being published. - In the second case, approving that request starts another run of the same workflow, so the cycle can repeat.
- Before this PR,
!isBotChange(...)let every write impersonated as governance-bot through. - The javadoc above ("workflow automation's own writes by none") and the ADR ("Workflow automation … never starts a workflow, whatever a list says") both still claim the old behaviour.
WorkflowEventConsumer.botAuthorOfalready excludes these writes withisWorkflowAutomation. Only the gate misses it.
I traced this through the code but did not run it end to end.
Fix: return List.of() when GOVERNANCE_BOT equals user or impersonatedBy, the same check isWorkflowAutomation makes. Add a unit case that (listedBot, "governance-bot") is not held.
There was a problem hiding this comment.
Fixed in 2b0c069: ApprovalGate.rulesForActor returns no rules for workflow automation (governance-bot as the user or as the impersonator) before any bot-list filtering, so the workflow's own writes are never held, whichever bot made the change. aaf752f adds the exact case: workflowAutomationWritingForAListedBotIsNotHeld writes as listed bot scraperbot impersonated by governance-bot, and no rule holds it. mayHold, gatedAssets and admitRelations go through the same rulesForActor.
| const fetchNamesSafely = async ( | ||
| fetchPage: ( | ||
| after?: string | ||
| ) => Promise<{ data: { name: string }[]; paging: Paging }> | ||
| ): Promise<string[]> => { | ||
| try { | ||
| return (await fetchAllPages(fetchPage)).map((app) => app.name); | ||
| } catch { | ||
| return []; | ||
| } | ||
| }; | ||
|
|
||
| // The server refuses an application's bot anyway; a user who cannot list applications still | ||
| // gets the picker, without that filter. | ||
| const fetchInstalledApplications = async (): Promise<App[]> => { | ||
| try { | ||
| return await fetchAllPages<App>((after) => | ||
| getApplicationList({ fields: 'bot', limit: PAGE_SIZE, after }) | ||
| ); | ||
| } catch { | ||
| return []; | ||
| } | ||
| }; |
There was a problem hiding this comment.
🟡 fetchNamesSafely and fetchInstalledApplications are the same wrapper written twice.
Both run fetchAllPages inside a try and return [] on failure. The only difference is that fetchNamesSafely also maps each item to its name. One generic helper can replace both:
// The server refuses an application's bot anyway; a user who cannot list applications still
// gets the picker, without that filter.
const fetchAllPagesOrEmpty = async <T,>(
fetchPage: (after?: string) => Promise<{ data: T[]; paging: Paging }>
): Promise<T[]> => fetchAllPages(fetchPage).catch(() => []);fetchApplicationBots would then call fetchAllPagesOrEmpty for both lists, and map the marketplace result to names inline: marketplace.map((app) => app.name).
There was a problem hiding this comment.
Done in aaf752f: both wrappers are now one generic fetchAllPagesOrEmpty, used for the installed and the marketplace application lists.
… cover the create flow - The registry snapshot's epoch now also fingerprints bot_entity, so a listed bot deleted and recreated with another bot user (or reassigned) is resolved again within the 5-second recheck, instead of only after a workflow definition is written. - ApprovalGate.rulesForActor returns no rules for workflow automation (governance-bot, or a user it impersonates), as the consumer already does, whatever a bot list holds. - Unit tests for the registry's bot lists (listing, suspended, Enforce, deleted bot, epoch), the trigger filter's bot check, and gate admission for listed bots and workflow automation. - IT for the flow the feature exists for: a bot listed on the seeded glossary term approval workflow creates a term, which goes to review; the asset link it adds is held and released when the term is approved.
… fetch wrappers Covers the exact case from review: a listed bot impersonated by governance-bot is never held by the approval gate. The picker's two swallow-and-return-empty fetch helpers become one generic fetchAllPagesOrEmpty.
Code Review ✅ Approved 🔴 High risk 3 closed / 3 findingsAdding triggeringBots changes approval-gate eligibility for bot-authored edits; misconfiguration could let governed changes publish without review or unnecessarily hold edits. Adds a ✅ 3 closed✅ Bug: Selected bots keep raw names after the bot list finishes loading
✅ Quality: Name-based application-bot rule is not in the new ADR
✅ Performance: Installed and marketplace app lists are fetched one after the other
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Not backported to
|
…it (#39005) * Fixes #38796: Let a workflow list the bots whose changes start it (#38797) * Let a workflow list the bots whose changes start it Since 2.1 a bot's change never starts a governance workflow and is never held for approval. That keeps ingestion out of review queues, but blocks automation that exists to propose content for people to review. An eventBasedEntity trigger now lists, in triggeringBots, the bots whose changes start it: - WorkflowEventConsumer drops a bot's change before Flowable unless a workflow on the entity type lists the bot, and tags the change with the bot (triggeringBot variable). - FilterEntityImpl starts the run only for the workflows that list that bot. - ApprovalGate holds a listed bot's edit for the Enforce workflows that list it. - GovernanceApprovalRegistry's snapshot carries the lists, resolved to the users the bots write as. - Saving a workflow refuses an unknown bot, a system bot and an application's bot; only newly listed bots are checked. governance-bot never starts a workflow. - Workflow builder: a bot picker on the start node, listing only bots an admin created. The list is empty by default, so no stored workflow changes behaviour. * Refuse leftover application bots; show bot display names once loaded - A bot left behind by an uninstalled application keeps its "<AppName>Bot" name but loses the application's link, so it looked admin-created. Saving a workflow now also refuses a bot named for a marketplace or installed application, and the Triggering Bots picker hides it. - The picker kept showing a saved bot's raw name after the bot list loaded: useSyncedListData now relabels the selection when its label function changes. * Document the name-based application-bot rule; fetch app lists in parallel - The decision record now states how an application's bot is recognised: the installed application's link, or its "<application name>Bot" name for an installed or marketplace application, and why a leftover bot of an uninstalled application must be refused too. - The Triggering Bots picker fetches installed and marketplace applications concurrently. * Name the change's bot changedByBot; test a workflow listing two bots - A workflow lists several bots; a change has one author. The process variable that carries that author is now changedByBot (was triggeringBot), and the comments say so. - WorkflowTriggeringBotsIT: one Enforce workflow listing two bots holds both bots' edits as separate change requests. * Refresh listed bots when bots change; never gate workflow automation; cover the create flow - The registry snapshot's epoch now also fingerprints bot_entity, so a listed bot deleted and recreated with another bot user (or reassigned) is resolved again within the 5-second recheck, instead of only after a workflow definition is written. - ApprovalGate.rulesForActor returns no rules for workflow automation (governance-bot, or a user it impersonates), as the consumer already does, whatever a bot list holds. - Unit tests for the registry's bot lists (listing, suspended, Enforce, deleted bot, epoch), the trigger filter's bot check, and gate admission for listed bots and workflow automation. - IT for the flow the feature exists for: a bot listed on the seeded glossary term approval workflow creates a term, which goes to review; the asset link it adds is held and released when the term is approved. * Test workflow automation writing for a listed bot; merge the picker's fetch wrappers Covers the exact case from review: a listed bot impersonated by governance-bot is never held by the approval gate. The picker's two swallow-and-return-empty fetch helpers become one generic fetchAllPagesOrEmpty. (cherry picked from commit c6ee3a8) * Create bot_entity in the ontology test database The approval registry snapshot now fingerprints bot_entity, so repository tests that build a partial schema need the table or every governed write reports the approval rules as unavailable. --------- Co-authored-by: Ram Narayan Balaji <[email protected]> Co-authored-by: Ram Narayan Balaji <[email protected]>
…schema, stale and slow ITs (#39394) * fix(sdk): remove fields cleared on a server-returned entity in update() #39164 pruned the no-snapshot baseline to the fields the caller sent, so a field nulled on an entity returned by create() or update() was never removed. Prune only hand-built partial entities, which carry no version or updatedAt. * test(ontology): create bot_entity in OntologyEntityDAOIT's scratch schema Approval rules read bot_entity since #38797. Without it the gate refused every write with "Approval rules are unavailable". * test(context-memory): align ContextMemoryAnchorIT with memory-only search #38011 lets a memory-only search return anchored memories a reader may read, but left one assertion on the old rule. The "all" assertions counted fuzzy-matched tables and queried the question, which "all" does not search; count memories only and carry the query in the display name. * fix(glossary): retry the pending-label drop of a bulk asset removal on deadlock The chunked DELETE on tag_usage commits on its own and is idempotent, so DeadlockRetry can rerun it. * test: tolerate slow runners in OntologyGovernanceIT and ConceptContextIT Retry a SPARQL request the single worker turns away with 429, and give the approval workflow the 5 minutes MetricResourceIT already allows. * test(informix): drop the clear() of per-source stored procedure state PerSourceState is owned by each source instance, so a second run starts empty and the object has no clear(). * chore(airflow-apis): refresh uv.lock for the ingestion mcp extra * test: honour the SPARQL Retry-After and explain the workflow wait The bounded worker answers saturation with 429 and Retry-After by design, so the client waits as told. The approval workflow starts only when the serial WorkflowEventConsumer reaches the create event, which lags under parallel load. * test: poll the SPARQL retry with Awaitility; guard untouched fields in update() Replace the sleep loop with Awaitility at the server's Retry-After interval. Add a test that a server-returned entity with one changed field emits no remove ops.
Describe your changes:
Fixes #38796
Since 2.1 a bot's change never starts a governance workflow and is never held for approval. That keeps ingestion out of review queues, but it blocks automation that exists to propose governed content for people to review. This lets each workflow list, in
triggeringBots, the bots whose changes start it. The list is empty by default, so no stored workflow changes behaviour.Type of change:
High-level design:
Contract: new
triggeringBots(bot names, unique) on theeventBasedEntitytrigger config.Who may be listed: only a bot an admin created. Saving a workflow returns 400 for an unknown bot, a system bot (
provider: system: ingestion-bot, governance-bot, ...), and an application's bot (the app CONTAINS it; these are stored withprovider: user, so the relationship is the only marker). Only names newly added on an update are checked, so a listed bot deleted later never blocks another edit or a migration; it just starts nothing.Runtime:
GovernanceApprovalRegistry: its existing snapshot (epoch-checked every 5 s, invalidated on workflow writes, so cluster-safe) now also carries the lists, resolved to the users the bots write as, by workflow FQN and by entity type. Enforce rules (GatingRule) carry their own list. No new cache.WorkflowEventConsumer: a bot's change is still dropped before Flowable unless some workflow on that entity type lists the bot, so ingestion and unlisted bots cost no process instance. A listed bot's change carries the bot in thetriggeringBotprocess variable. governance-bot (or impersonating as it) never starts a workflow. The automation-proposal exception is unchanged.FilterEntityImpl: a run tagged with a bot starts only if this workflow lists the bot, so listing a bot on workflow A does not leak its changes into workflow B on the same type. No BPMN change, so already-deployed workflows need no redeploy.ApprovalGate(4 call sites): for a bot actor, only the Enforce rules that list the bot gate the edit; otherwise it publishes as before.UI: a bot picker on the start node next to Approval Mode (core
Autocomplete). It lists every bot page and hides system bots and applications' bots. The field round-trips throughNodeUtils(load) andWorkflowValidationService(save; a cleared list is saved as cleared).useSyncedListDatamoved tohooks/soTriggerConfigSectionand the new section share it.Alternatives rejected:
Decision record: ADR:2026-11-26-a-workflow-lists-the-bots-whose-changes-start-it, plus an amendment to ADR:2026-10-22-agent-glossary-proposals-are-decided-through-the-approval-workflow.
Backport: needed on 2.1 (bots are excluded from 2.1 on). 2.0 never excluded bots (only governance-bot), so no 2.0 port.
Tests:
Use cases covered
Unit tests
WorkflowTriggeringBotsTest(new, 7: incl. a bot left behind by an uninstalled app),WorkflowEventConsumerTest(+3), withGovernanceApprovalRegistryTest,FilterEntityImplTest,ApprovalGate*Test,ChangeRequest*Test,WorkflowDefinitionRepository*Test: 230 run, 0 failures, plus 82/0 on the rerun.Review round 2:
GovernanceApprovalRegistryTest60/0 (+8: bot lists, suspended/Enforce/deleted bot, bot epoch, gate admission for listed bots and workflow automation),FilterEntityImplTest33/0 (+3),WorkflowEventConsumerTest77/0,WorkflowTriggeringBotsTest7/0.Integration tests (local, MySQL + Elasticsearch, parallel lane)
WorkflowTriggeringBotsIT(new) 8/0: incl. one workflow listing two bots (both edits held) and the customer flow (a listed bot creates a glossary term → In Review via the seededGlossaryTermApprovalWorkflow→ its held asset link is released on approval),ChangeRequestAdmissionIT23/0,GlossaryTermAutomationDraftIT13/0: 42 run, 0 failures.UI tests
TriggeringBotsSection.test.tsx(new, 4),WorkflowValidationService.test.ts(+3 round-trip cases), with the WorkflowBuilder form suites andWorkflowOssRestrictions.test.tsx: 172 passed, 17 suites.TriggeringBotsSection.test.tsxextended: hides a bot left behind by an uninstalled app (fails without the fix), shows a saved bot's display name once loaded. WorkflowBuilder form suites: 134 passed.Manual test steps
scraper-bot).scraper-bot, save.scraper-bot's token: the workflow runs (the term goes to review).ingestion-bot's token: nothing runs.ingestion-botlisted (via API): 400 "is a system bot".Live verification
How bots reach workflows on
maintoday (DevRel, currentmain, done the way users do it):updatedBy/impersonatedBy)autoclassification-bot/ —aiautomationapplicationbotMcpApplicationBotWhoever the request runs as decides it: a person, or a bot impersonating one, triggers workflows; a bot writing as itself never does. This PR changes only the last row, and only for bots a workflow lists.
This PR on a local Collate stack (latest
main+ this PR, MySQL + Elasticsearch, existing DB frommain, no data migration):Start → RanCheck → EndTruevs none)autoClassification-bot/ingestion-boteditsgovernance-bot,AIAutomationApplicationBotlistedMcpApplicationBot) listedautomationglossary term (proposal)Migration: none needed.
triggeringBotsis an optional field in the stored trigger JSON; a workflow without it lists no bots, which is the current behaviour. No BPMN change, so no redeploy.Screenshots (local build):
Start node configuration: the new Triggering Bots field is a multi-select; here the workflow lists two bots,
ScraperBotandSyncBot:The picker lists only bots an admin created; system bots and application bots (including a leftover bot of an uninstalled application) are hidden:
🤖 Generated with Claude Code