Stage
Record a rule add, change, or removal before it goes live.
What it is
Staging records a rule change without making it live. operation is ADD, CHANGE, or REMOVE, and ruleIri
names the rule to change or remove. Check the result with Validate, then
commit it, or ask the agent to do the same steps in chat.
useClearStagedRulesMutation discards staged changes. Pass ruleIris to discard a subset. See Rules for
how a rule is written.
Import
import { GQLRuleOperation, useStageRuleOperationMutation } from "@manta-eu/client";
import { useMantaClient } from "@manta-eu/react/providers";
Example
const { mantaClient } = useMantaClient();
const stage = useStageRuleOperationMutation(mantaClient);
const result = await stage.mutateAsync({
input: {
humanIntent: "Derive the cost per click of every ad",
operation: GQLRuleOperation.Add,
newRule:
":cpc[?ad, ?cpc] :- :Ad[?ad], :spend[?ad, ?spend], :clicks[?ad, ?clicks], FILTER(?clicks > 0), BIND(?spend / ?clicks AS ?cpc) .",
},
});
Request
A backend sends the same step as a GraphQL mutation. See calling Manta from a backend for the endpoint and authentication.
mutation StageRule($input: StageRuleOperationInput!) {
stageRuleOperation(input: $input) {
success
ruleIri
operation
error
}
}
{
"input": {
"humanIntent": "Derive the cost per click of every ad",
"operation": "ADD",
"newRule": ":cpc[?ad, ?cpc] :- :Ad[?ad], :spend[?ad, ?spend], :clicks[?ad, ?clicks], FILTER(?clicks > 0), BIND(?spend / ?clicks AS ?cpc) ."
}
}
Response
result.stageRuleOperation returns success, ruleIri, operation, and error. ruleIri names the staged rule.
operation is the operation that was staged. error is set when staging fails.