DEV-205665: Add detach_data_quality_rule_from_template tool - #144
Draft
regmimridul wants to merge 1 commit into
Draft
Conversation
regmimridul
marked this pull request as draft
September 14, 2026 00:08
DEV-205665. Soft-unlinks one deployed rule from its template, turning it into a
standalone rule. Nothing is deleted: the rule, its configuration and every
historical run result survive, and only the template link is cleared - so the
rule stops receiving cascades from update_/delete_data_quality_rule_template.
Wraps POST /rest/dq/1.0/ruleTemplates/{ruleTemplateName}/detach via a new
clients.DetachDQRuleFromTemplate. Registered behind the existing data-quality
experimental flag per TOOL_CONTRIBUTION_STANDARDS §3.2.
Carries the §5 confirm checkpoint, which the acceptance criteria do not mention
but the standards require of any write tool. confirm=false does more than echo
the payload: it reads the template's deployments and refuses when the rule is
not among them, so the API's opaque 400 becomes an answer the caller can act on
and nobody approves a no-op. confirm=true performs the detach.
Two deviations from the ticket, both forced by the API and both explained in
the PR. There is no rule_id: RuleTemplateDeployment is keyed by jobName plus
deployedRuleName and the endpoint additionally needs the template name in its
path, so the tool takes those three rather than the single identifier the
criteria describe. And the endpoint answers 204 with no body, so the "current
standalone definition" the criteria ask for is a follow-up read of the rule.
That read-back is best-effort: the write has already committed, so failing to
re-read reports success with a pointer at get_data_quality_rule rather than
implying the detach failed.
The 400 case deliberately reports two possibilities. RuleTemplatesBll.detach
raises the same RULE_NOT_FROM_TEMPLATE for a rule that is already standalone
and for one belonging to a different template, so the tool names both instead
of guessing.
The tool name spells out the domain per §4.1 rather than using the ticket's
dq_ prefix, matching its data-quality siblings.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
regmimridul
force-pushed
the
feat/DEV-205665-detach-rule-from-template
branch
from
September 14, 2026 17:11
8e6e96e to
b585877
Compare
regmimridul
force-pushed
the
feat/DEV-205664-list-rule-template-deployments
branch
from
September 14, 2026 17:11
c14ce8b to
7d0ced4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 What does this PR do?
DEV-205665. Adds
detach_data_quality_rule_from_template— soft-unlinks one deployed rule from its template, turning it into a standalone rule.This is not a delete. The rule, its configuration and every historical run result are preserved exactly as they are; only the link is cleared. What changes is the future: once detached, the rule stops receiving cascades, so an
update_data_quality_rule_templatethat rewrites the template's SQL, and adelete_data_quality_rule_templaterun withcascade, no longer touch it. It also stops appearing inlist_data_quality_rule_template_deploymentsfor that template.Wraps
POST /rest/dq/1.0/ruleTemplates/{ruleTemplateName}/detachthrough a newclients.DetachDQRuleFromTemplate. Gated behind the existingdata-qualityflag per §3.2.Stacked on #143 (DEV-205664), which it depends on conceptually — the preview path uses the same deployments endpoint. Merge order: #133 → #134 → #143 → this.
Confirm checkpoint
The ACs don't mention one, but §5 requires it of any tool that writes.
confirm=false(the default) does more than echo the payload: it reads the template's deployments and refuses when the rule isn't among them, so the API's opaque 400 becomes an answer the caller can act on, and nobody approves a no-op.confirm=trueperforms the detach.Worth noting for review: detaching is one-way. There is no re-link endpoint, and the only way back is redeploying the template onto the rule, which overwrites its SQL. The preview says so explicitly.
Two deviations from the acceptance criteria
Both forced by the API (§8.2: derive contracts from the producing service):
1. There is no
rule_id. The AC asks for a single identifier, butRuleTemplateDeploymentis keyed byjobName+deployedRuleName, and the endpoint additionally needs the template name in its path — which the ACs don't mention at all. So the tool takes three required inputs:template_name,job_name,deployed_rule_name. All three come fromlist_data_quality_rule_template_deployments, and the needs-input message says so. Same root cause as the missing rule id in #143.2. The endpoint answers
204 No Content. The AC asks for "the rule's current standalone definition" on success, so the tool does a follow-up read viaclients.GetDQRule. That read-back is best-effort: the write has already committed, so a failure to re-read returnssuccesswith a pointer atget_data_quality_rule, rather than implying the detach failed.DQRule.TemplateIDdoubles as a confirmation signal — if it's still set after a successful detach, the tool reports that rather than claiming a clean result.The 400 is ambiguous, and the tool says so
RuleTemplatesBll.detachraises the sameRULE_NOT_FROM_TEMPLATEfor a rule that is already standalone and for one that belongs to a different template. The API gives callers no way to tell them apart, so the error names both possibilities and points atlist_data_quality_rule_template_deploymentsrather than guessing. That satisfies the AC's "clear, descriptive error rather than a silent no-op" — it just can't be more specific than the service is.Tool name
The ticket specifies
dq_detach_rule_from_template; this ships asdetach_data_quality_rule_from_template, per §4.1 and consistent with its*_data_quality_rule_templatesiblings. Happy to rename.Impact Analysis
Low. Purely additive: one new tool, one new client function plus two error sentinels, one line in the gated block of
RegisterAll. No existing tool, client function or type is modified.Behind
data-quality(off by default), so no existing deployment's tool list changes.ReadOnlyHintis deliberately not set — this writes.DestructiveHint: falsebecause nothing is deleted and history survives.IdempotentHintis not set either: a second detach of the same rule fails, since it is no longer linked.The tool makes up to two calls on the confirm path (detach, then read-back) and one on the preview path (deployments). The read-back uses the internal v1 rule endpoint, the same one
get_data_quality_rulealready uses, while the detach itself is on the public API — flagging the mix in case you'd rather the read-back were dropped.Still open:
Permissions: []string{}(§9) — needs the real scope identifiers from the DQ team, as on #133 and #143.Verified with
gofmt -l,go build ./...,go vetandgo test ./pkg/tools/... ./cmd/chip/...— all passing, including 12 new tests covering preview-writes-nothing, preview-echoes-every-field (§5.2), preview refusal for an unlinked rule, the detach payload, the read-back, a surviving template link, read-back failure not masking success, the already-standalone error, unknown rule/template, the deploy-permission message, and 401/422/500 mapping.✅ Checklist
🤖 Generated with Claude Code