Skip to content

TestAccResourcePrebuiltRules/default fails on 8.14-8.16 when sharded with elastic_defend_integration_policy #5541

Done

Description

@tehbooom

Summary

TestAccResourcePrebuiltRules/default (internal/kibana/prebuilt_rules) fails deterministically on Elastic Stack 8.14.3, 8.15.5 and 8.16.6 whenever it runs in the same acceptance shard as internal/fleet/elastic_defend_integration_policy. It was first seen on #5489, which does not touch either package.

acc_test.go:119: Step 2/3 error: Expected a non-empty plan, but got an empty refresh plan

It fails on every re-run (initial attempt plus 5 re-runs) on all three versions. TestAccResourcePrebuiltRules/in_space passes, so the problem is specific to the default space.

Cause

  1. A PR that touches provider/ or internal/clients/ (both are in forceAllPrefixes in scripts/targeted-testacc/classifier.go) makes the targeted-testacc selector pick every acceptance package. Add the elasticstack_kibana_alerting_v2_rule resource #5489 hits this simply by registering a new resource in provider/plugin_framework.go.
  2. The selector builds its own 2-way split. In the Add the elasticstack_kibana_alerting_v2_rule resource #5489 run it put internal/fleet/elastic_defend_integration_policy and internal/kibana/prebuilt_rules in the same shard. With the full-suite split on main (go list ./... | sort | awk '(NR-1) % 2 == idx') they land in different shards (shard 0 and shard 1), which is why main doesn't see it.
  3. The Elastic Defend tests skip below 8.14. On 8.14+ they cause Fleet to install security_detection_engine from EPR into the default space. The job logs show two Endpoint Security (Elastic Defend) detection rules in default with different rule ids.
  4. deleteSingleDetectionRule (internal/kibana/prebuilt_rules/acc_test.go) calls FindRules with no filter and deletes Data[0]. If that is a duplicate or an EPR-installed rule rather than a bundled prebuilt one, the prepackaged _status still reports rules_not_installed == 0, so step 2 (ExpectNonEmptyPlan: true) gets an empty plan every time.

Step 4 is the best-supported explanation from the logs; I did not observe the deleted rule id directly.

Evidence

Impact

Any PR that triggers force-all selection can hit this depending on how the planner splits packages, so it can block unrelated PRs at the Provider Gate (re-running does not help). It is a latent isolation bug in the test, exposed by shard layout.

Suggested fix (any of)

  • Make deleteSingleDetectionRule deterministic: select a bundled, immutable prebuilt rule explicitly rather than Data[0], and assert rules_not_installed goes up by exactly 1 around the delete.
  • Run the default case in an isolated space, or skip it on versions where Defend can pollute default.
  • Optionally teach the shard planner to keep packages that mutate default-space detection rules (elastic_defend_integration_policy, prebuilt_rules, security_detection_rule, security_enable_rule) in separate shards.

Related

Activity

  1. added
    needs-reproduction
    triaged
    and removed on Dec 1, 2026
  2. github-actions commented on Dec 1, 2026

    @github-actions
    Contributor

    Thanks for the bug report! The needs-reproduction label has been added to this issue.

    This looks like a reproducible bug, so it has been queued for the reproducer-factory pipeline. Reproducer-factory will attempt to confirm the behaviour and create a minimal reproduction case. The detailed root-cause analysis, failing run links, and local reproduction steps included in this report should make that process much smoother. Thank you for the thoroughness!

    If this classification is wrong or there is additional context to add, please leave a comment so a maintainer can adjust the label manually.

  3. github-actions commented on Dec 1, 2026

    @github-actions
    Contributor

    ✅ Research Factory Issue Intake completed successfully!

    Generated by Research Factory Issue Intake for #5541

  4. github-actions commented on Dec 1, 2026

    @github-actions
    Contributor

    Implementation research

    Run: 2026-12-01 · Workflow run

    Edits inside this comment are read as input on the next run but are not preserved verbatim. For
    durable feedback, post a comment or edit the issue body.

    Problem framing

    TestAccResourcePrebuiltRules/default (internal/kibana/prebuilt_rules/acc_test.go) fails
    deterministically on Elastic Stack 8.14.3, 8.15.5, and 8.16.6 whenever a PR's targeted-testacc
    selector places it in the same shard as internal/fleet/elastic_defend_integration_policy.
    Step 2 of the test (PlanOnly: true, ExpectNonEmptyPlan: true, after
    deleteSingleDetectionRule runs as a PreConfig) gets an empty refresh plan instead of a
    non-empty one. TestAccResourcePrebuiltRules/in_space passes under the same conditions.

    Confirmed from the repo (internal/kibana/prebuilt_rules/acc_test.go:311-344):
    deleteSingleDetectionRule calls FindRulesWithResponse with empty
    kbapi.FindRulesParams{} — no filter, sort, or paging constraints — then unconditionally deletes
    resp.JSON200.Data[0]. Empty params mean Kibana's documented defaults apply: page=1,
    per_page=20 (generated/kbapi/oas.yaml:30363-30378), so only the first 20 rules in the space
    are ever visible to this call; with more rules present (e.g. Defend/EPR-installed ones alongside
    the bundled prebuilt set) Data[0] is not just "unfiltered", it is also "first of a truncated,
    arbitrarily-ordered page". Step 2 expects that deleting a bundled prebuilt rule drives the
    _status endpoint's rules_not_installed above zero, which the resource's refresh plan reflects.
    Confirmed in internal/kibana/prebuilt_rules/resource.go:60-101: ModifyPlan produces a plan
    diff when any of four counters is nonzero — rules_not_installed (76-80),
    rules_not_updated (82-85), timelines_not_installed (87-91), or timelines_not_updated
    (93-96) — each independently sets updated = true, and resp.Plan.Set only runs when updated
    is true (98-100). The model (models.go:29-40,56-63) and read path (read.go:34,40, via
    kibanaoapi.GetPrebuiltRulesStatus) carry only these aggregate _status counters — no individual
    rule IDs. So the empty-plan failure requires that deleting Data[0] leaves all four counters
    at zero, not just rules_not_installed: this holds if Data[0] is a rule the _status endpoint
    doesn't track as missing/outdated at all (e.g. a Fleet/EPR-installed rule outside the prepackaged
    set it audits), but would not hold if the deleted rule happened to also be "outdated" by some
    other measure. That nuance is why Approach A's regression outline below checks the counter delta
    directly rather than only "plan non-empty".

    Two facts anchor the "why sharding matters" half of the issue, both confirmed in-repo:

    • forceAllPrefixes in scripts/targeted-testacc/classifier.go:29-52 includes provider/ and
      internal/clients/; a change under either makes the targeted selector pick every acceptance
      package (scripts/targeted-testacc/selector.go:32-40), then round-robin shard it
      (selector.go:90-121) over the sorted list of acceptance-only packages.
    • The full-suite split used on main (Makefile:136) applies the same % shardCount rule but
      over sorted go list ./... (all packages, including generated/..., scripts/..., module
      root) — a different list. The same modulo over two different sorted lists can and does put
      internal/fleet/elastic_defend_integration_policy and internal/kibana/prebuilt_rules in the
      same PR shard while they land in different shards on main, matching the issue's observation
      that main doesn't reproduce this.

    The specific claim that installing the Elastic Defend integration causes Kibana/Fleet to install
    security_detection_engine prebuilt rules into the default space on 8.14–8.16 is not
    verifiable from the repo or current public docs
    (see Open questions). Nothing in
    internal/fleet/elastic_defend_integration_policy references security_detection_engine, and the
    Elastic Defend install docs don't mention rule installation as a side effect. The issue's own
    evidence for that causal chain — the two linked CI workflow runs
    (45441436993, 46664172867) showing two differently-id'd "Endpoint Security (Elastic Defend)"
    rules in default, and the issue's claimed local targeted-testacc --dry-run reproduction of the
    shard placement for #5489 — are the issue author's reports, not independently re-run or
    re-verified by this research
    (this research did not execute the selector locally or fetch those
    workflow logs). Treat this causal chain, and the version boundary at which prebuilt rules moved to
    a Fleet-package delivery model (the issue's 8.17+ claim), as the working theory, not a confirmed
    fact, through the rest of this writeup; both remain open questions below. Likewise, the theory that
    deleting a non-bundled rule leaves _status unchanged is plausible given the confirmed
    ModifyPlan/_status mechanics above, but the counterfactual — what _status actually reports
    after deleting a Fleet/EPR-installed rule on a real 8.14–8.16 stack — was not reproduced here
    either.

    A related, confirmed concurrency fact narrows how fully either fix below can eliminate the flake:
    TestAccResourcePrebuiltRules and TestAccResourcePrebuiltRulesDefaultSpaceID are sequential
    top-level tests in the same package (no t.Parallel() at the top level), so they don't race each
    other in-process. But elastic_defend_integration_policy and prebuilt_rules run as separate
    test binaries against the same shared Kibana instance
    , driven concurrently by gotestsum's
    -p/--parallel flags (Makefile:41-42,136,150) whenever both land in one shard — matching the
    issue's own description of the collision. Any Defend-side rule installs into default can
    therefore happen at any point during prebuilt_rules's 3-step flow, independent of which rule
    deleteSingleDetectionRule targets.

    Approaches considered

    Approach A: Make deleteSingleDetectionRule select a specific, known rule deterministically

    Instead of Data[0], delete a rule identified by a stable rule_id (or by a FindRules filter
    on a distinguishing attribute), so the deleted rule is always a bundled prebuilt rule tracked by
    the _status counts — regardless of what else exists in the space.

    • Kibana surface: FindRules (GET /api/detection_engine/rules/_find) only documents filtering
      on name, enabled, tags, createdBy, interval, updatedBy — not rule_id or
      immutable. There is no dedicated rule_id query param on FindRules. The generated client
      does expose ReadRule and DeleteRule (GET/DELETE /api/detection_engine/rules) with an
      id or rule_id query param, so a hard-coded, known bundled rule_id could be deleted
      directly via DeleteRuleWithResponse(..., &kbapi.DeleteRuleParams{RuleId: &ruleID}) without
      going through FindRules/Data[0] at all.
      (generated/kbapi/kibana.gen.go:84033-84076, oas.yaml:30337-30345, oas.yaml:27944-27974)
    • Every rule response also carries immutable (deprecated boolean) and a rule_source union
      (external/internal) that in principle distinguish bundled-prebuilt from custom rules — but
      whether Fleet/EPR-installed rules are distinguishable from CLI/UI-bundled prebuilt rules via
      these same fields is unverified from the spec (the spec's own comment suggests EPR-distributed
      rules are also "prebuilt"/external, so filtering on immutable/rule_source alone may not
      separate "safe to delete for this test" from "installed by the other test's Fleet package").
      (generated/kbapi/kibana.gen.go:62990-62992, :63121-63123, oas.yaml:197123-197141)
    • Terraform shape: no resource schema changes; this is purely an acceptance-test helper fix inside
      internal/kibana/prebuilt_rules/acc_test.go.
    • Concrete selection contract, resolved for the recommended isolated-space setting: once the
      "default" subtest runs in its own freshly-created space (Approach B), the install resource's
      prepackaged install is the only writer of rules into that space for the duration of the test —
      there is no concurrently-running Fleet/Defend policy targeting it, so the selection contract
      only needs to be correct relative to the bundled prepackaged set itself, not robust against
      arbitrary third-party rules. Given that, the simplest correct selector is: loop FindRules
      pages (using the always-present page/perPage/total response fields to know when to stop,
      since per_page defaults to 20 with no documented maximum) and pick the first rule with
      immutable == true, explicitly failing the test (not panicking on Data[0]) if zero such rules
      are found after exhausting all pages. This sidesteps the still-open question of whether
      immutable also matches EPR-installed rules, because in the isolated space there are no
      EPR-installed rules to confuse it with. A hard-coded rule_id (via ReadRule) remains a viable
      alternative but is not required once isolation removes the ambiguity driving the current bug.
    • Regression-test outline for this change (applies after Approach B's isolation is in place):
      • Read _status immediately before deleting Data[N], delete it, read _status again, and
        assert the deltas directly rather than only "plan is non-empty": rules_not_installed
        increases by exactly 1, rules_installed decreases by exactly 1, and the other three
        ModifyPlan-relevant counters (rules_not_updated, timelines_not_installed,
        timelines_not_updated) are unchanged — this is what actually proves the selected rule was a
        tracked prebuilt rule, not merely that some diff appeared.
      • Separately, after step 3's reinstall, assert all four counters return to their original
        pre-delete values (a distinct assertion from the immediate post-delete deltas above).
      • Add an explicit case asserting the zero-eligible-candidates path fails the test with a clear
        message, not an index-out-of-range panic.
      • Extract the page-looping selection logic into a small helper that takes a client interface
        (or closure) returning canned FindRules pages, so pagination can be exercised with a unit
        test independent of a live Kibana: assert it (a) skips a page-1 response containing no
        immutable == true rule and finds a qualifying rule on page 2, and (b) returns a clear error
        when every page is exhausted with no qualifying rule — both scenarios are not reliably
        reproducible by just installing >20 rules into a live test space, since the first immutable
        rule would typically appear well before page 2.
      • Add a case for unrelated/other prebuilt rules remaining untouched after the delete/reinstall
        cycle.
      • Run the combined fix (isolated space + deterministic selector) together with
        elastic_defend_integration_policy in one shard on 8.14.3, 8.15.5, and 8.16.6 to confirm the
        originally reported collision no longer reproduces.
    • Pros: fixes the root cause (a non-deterministic, unpaginated, unfiltered selection) rather than
      papering over the symptom; smallest code change if applied alone (test helper only).
    • Cons: applied alone (without Approach B's isolation), a correct selector still cannot fully
      insulate the test from a concurrently-running Defend test installing/reinstalling rules into the
      same shared default space mid-flow — per the concurrency fact above, both would still target
      default, and immutable may not distinguish EPR-installed rules from bundled ones (open
      question below) in that shared setting. This is why the recommendation pairs Approach A's
      selector with Approach B's isolation rather than proposing A standalone.

    Approach B: Isolate TestAccResourcePrebuiltRules/default in its own Kibana space

    Convert the default subtest to the same shape as the existing in_space subtest: create a
    random elasticstack_kibana_space, point the install resource at it, and run
    deleteSingleDetectionRule against that isolated space instead of the shared default space.

    • Repo precedent for this pattern already exists and passes under the same sharding conditions:
      TestAccResourcePrebuiltRules/in_space itself (testdata/TestAccResourcePrebuiltRules/in_space/create/main.tf,
      random space id via RandStringFromCharSet at acc_test.go:95), plus
      TestAccResourceSecurityDetectionRule_QueryMinimalWithSpace
      (internal/kibana/security_detection_rule/acc_test.go:2182-2303) and securitylistitem
      (internal/kibana/securitylistitem/acc_test.go:31-32,168-169).
    • Kibana surface: all detection-engine APIs (_find, prepackaged, prepackaged/_status, rule
      CRUD) are space-scoped — "if space_id is not provided in the URL, the default space is used" —
      so running the whole flow in an isolated space is a documented, supported pattern
      (https://www.elastic.co/docs/solutions/security/get-started/spaces-elastic-security:
      "detection rules ... are private to the space ... will run independently").
    • Caveat specific to this issue: documented Fleet/Elastic-Agent policy space-awareness (fine-
      tuning which Defend policies/artifacts are visible from a given space) is "Generally available
      since 9.1"; for deployments that existed before 9.1 it requires a one-time, irreversible, manual
      migration with an Enterprise subscription
      (https://www.elastic.co/docs/deploy-manage/manage-spaces-fleet,
      .../spaces-defend-faq). Nothing in those docs states this opt-in is available or meaningful on
      8.14–8.16 specifically — it is a 9.1+ migration path, not an 8.x feature. That said, this gates
      where Defend's policies/artifacts are scoped, not where this test's own install/status/find
      calls run: isolating prebuilt_rules's calls to a dedicated space is still expected to prevent
      this specific collision, because the rule-isolation guarantee above is a property of the
      detection-engine APIs this test calls directly, not of Fleet/Defend space-awareness. This also
      fully addresses the cross-process concurrency fact noted above: whatever Defend installs lands
      in default and the test's own calls would simply never touch default, regardless of timing.
    • Terraform shape: fixture-only change — add elasticstack_kibana_space.test to
      testdata/TestAccResourcePrebuiltRules/default/create/main.tf and update
      testAccResourcePrebuiltRules(t, spaceID) to use the new space id for the "default"-named
      subtest (keeping the subtest name "default" for continuity, or renaming — a scope decision left
      open below). Wire the install resource's space_id to elasticstack_kibana_space.test.space_id
      (an attribute reference), not independently to var.space_id as the existing in_space fixture
      does today — the existing in_space fixture has both resources read var.space_id
      independently with no depends_on or attribute reference, so Terraform has no explicit
      dependency edge between them and only works by same-value correlation. The repo's own
      convention for this exact pattern (space + dependent resource) is an attribute reference, e.g.
      security_detection_rule's ..._QueryMinimalWithSpace fixture
      (space_id = elasticstack_kibana_space.test.space_id,
      security_detection_rule.tf:13-17,20) and the APM source_map space fixture
      (main.tf:20-23,32); the new default fixture should follow that convention rather than
      copying in_space's looser var-correlation.
    • Version-constraint note: prebuiltRulesInSpaceConstraints (< 9.4.0 or >= 9.6.0-0,
      acc_test.go:46-49) exists because installing the full prepackaged rule set into a new,
      custom space
      fails on 9.4.x/9.5.x (comment cites elastic/kibana#285497,
      acc_test.go:43-45); it is currently applied only to the in_space table entry
      (acc_test.go:97), not to "default" (acc_test.go:90-93), because "default" doesn't use a
      custom space today. Converting "default" to an isolated-space fixture means it would hit the
      same known 9.4.x/9.5.x failure and needs the same constraint applied — this is a real scope item
      for Approach B, not a free rewrite, and is why TestAccResourcePrebuiltRulesDefaultSpaceID
      (which targets the real default space and carries no such constraint) should stay as-is rather
      than also being converted.
    • Pros: directly removes the default-space-sharing root cause; reuses an already-passing,
      in-package pattern; no dependency on guessing a stable rule_id.
    • Cons: the subtest would no longer actually exercise the literal Kibana default space, which
      may have been intentional (e.g. TestAccResourcePrebuiltRulesDefaultSpaceID already exists
      specifically to check default-space behavior at acc_test.go:197-219, so coverage of the literal
      default space would still exist elsewhere, just without a destructive delete/reinstall cycle
      against it in that other test either — so isolating default's delete/reinstall subtest would
      lose the one test that exercises that rebuild flow against the real default space).

    Recommendation

    Scope classification: this is a test-only fix. Neither approach touches the
    elasticstack_kibana_install_prebuilt_rules resource's schema, state model, or any migration
    path — models.go's six aggregate counters and resource.go's ModifyPlan logic are unchanged;
    only internal/kibana/prebuilt_rules/acc_test.go and its testdata/ fixtures change.

    Approach A (make deleteSingleDetectionRule deterministic) is necessary regardless — the current
    Data[0] selection is a real bug independent of sharding (it can panic on an empty page, and
    silently picks an arbitrary rule from a 20-row page) — but, per the confirmed cross-process
    concurrency fact above, it does not by itself fully close the collision with
    elastic_defend_integration_policy: both still operate against the shared default space, so a
    Defend install/update landing mid-flow could still perturb _status counts outside what the test
    expects. Approach B (isolate the delete/reinstall subtest into its own space) directly removes the
    shared-space dependency that makes this collision possible at all, and reuses an
    already-passing, in-package pattern (in_space). The recommended spine is Approach B, paired
    with Approach A's deterministic-selection fix applied inside the now-isolated test (so the helper
    is correct on its own merits, not just safe by virtue of isolation). This is a real, acknowledged
    trade-off rather than a free rewrite: TestAccResourcePrebuiltRulesDefaultSpaceID exercises
    default-space install behavior, but it is single-step and create-only (acc_test.go:197-219),
    so moving "default"'s destructive delete/reinstall cycle to an isolated space means no test in
    this package still exercises a prebuilt-rule delete-and-reinstall cycle against the literal
    default space
    after this change. That loss is accepted deliberately because reproducing the
    collision safely in the real default space (with Defend potentially present) is the exact problem
    the issue reports — it is called out explicitly here rather than glossed over.

    Open questions

    • Does installing elastic_defend_integration_policy on Stack 8.14–8.16 actually cause Kibana to
      install security_detection_engine/"Endpoint Security (Elastic Defend)" prebuilt rules into the
      default space? Neither the repo nor current elastic.co docs confirm this; it is inferred only
      from the issue author's CI log excerpt. Not blocking for Approach B (space isolation is correct
      regardless of the exact mechanism, since it removes shared-space exposure to any default-space
      side effect), but it does matter for Approach A alone, whose value is otherwise just "delete a
      better-chosen rule in a space something else might still be mutating."
    • Is there a bundled prebuilt rule_id guaranteed to exist across 8.14.3, 8.15.5, and 8.16.6 that
      Approach A could hard-code, or must the fix instead filter FindRules's Data client-side on
      immutable/rule_source? Not covered by the OpenAPI spec (data-dependent, not schema-defined).
    • Do immutable and rule_source reliably distinguish "bundled prebuilt" from "Fleet/EPR-package
      prebuilt" rules, or do EPR-delivered rules also report immutable: true / rule_source: external (same as CLI/UI-installed prebuilt rules)? The spec's prose suggests the latter, which
      would mean Approach A's filter-based variant still needs a rule_id- or tags-based
      distinguisher, not just immutable.
    • Is the rules_not_installed behavior of _status after deleting a non-bundled (e.g.
      EPR-installed) rule actually "unchanged" (producing the empty plan), as the issue theorizes, or
      could the empty plan instead stem from a different mechanism (e.g. Data[0] being a duplicate
      rule_id that the resource's refresh dedupes)? Not confirmed by docs or repo; would benefit from a
      reproduction against a real 8.14–8.16 stack with Defend installed.

    Out of scope

    • Changing the targeted-testacc shard planner to co-locate or separate specific packages (e.g.
      keeping elastic_defend_integration_policy and prebuilt_rules on different shards). This
      would mask the test's non-determinism rather than fix it, and the issue itself frames it as a
      secondary/optional mitigation.
    • Any change to how elastic_defend_integration_policy installs or configures the Elastic Defend
      Fleet package policy — the suspected side effect (installing detection rules) is Kibana-server
      behavior, not something the provider's Defend resource controls.
    • Reworking the prepackaged/_find API wrappers in internal/clients/kibanaoapi/prebuilt_rules.go
      — no evidence the wrappers themselves are wrong; the bug is confined to the acceptance-test
      helper.
    • Enabling Fleet/Defend policy space-awareness (the 9.1+ GA feature / pre-9.1 migration opt-in) to
      scope Defend's own side effects away from default — not available as a documented mechanism on
      8.14–8.16, and orthogonal to isolating prebuilt_rules's own test calls (Approach B).

    Quality gate

    Outcome: ready-for-change-factory - round 5 scored 95/85 with no actionable critic feedback; converged.

    Check Status
    Grounded pass
    Mapped pass
    Compatible pass
    Versioned pass
    Testable pass
    Idiomatic pass

    Score: 95/100 (threshold 85) · Rounds used: 5

    Unambiguous version-constraint contract for implementation: nothing in
    internal/kibana/prebuilt_rules behaves differently across 8.14.3, 8.15.5, 8.16.6, or later
    versions today (no 8.14/8.15/8.16 references in that package), so no new version floor is
    needed beyond what already exists. Concretely, the fix should: (1) keep the package's existing
    minVersionPrebuiltRules = 8.0.0 floor unchanged for all subtests; (2) apply the existing
    prebuiltRulesInSpaceConstraints (< 9.4.0 || >= 9.6.0-0, currently only on in_space) to
    both custom-space table entries once "default" is converted to use an isolated space under
    Approach B — i.e. the converted "default" entry is no longer exempt, because the 9.4.x/9.5.x
    custom-space install failure (elastic/kibana#285497) is a property of installing into any new
    custom space, not of the subtest's name; and (3) leave TestAccResourcePrebuiltRulesDefaultSpaceID
    untouched, with no custom-space constraint, since it continues to target the real default space.
    The 8.14.0 version gate that matters for the original issue (minVersionElasticDefend = 8.14.0)
    belongs to the other package and is unaffected by either fix. Named acceptance probe to confirm
    this gating strategy before merging: run the converted "default" entry (with the in_space-style
    constraint applied) plus the existing in_space entry on both a pre-9.4.0 and a 9.6.0+ stack to
    confirm neither regresses, and run it once in a shard alongside elastic_defend_integration_policy
    on 8.14.3, 8.15.5, and 8.16.6 per the regression outline above — this is the concrete check that
    would surface if any unknown version-specific behavior (e.g. an undiscovered 8.17 Fleet-package
    transition per the open question below) actually matters for this fix.

    References

    🤖 Pipeline metadata
    {
      "schema_version": "1.1",
      "recommendation": {
        "spine": "isolated-space-plus-deterministic-selection",
        "confidence": "medium",
        "approach_index": 1
      },
      "open_questions": [
        {
          "id": "defend-causes-epr-rules-in-default",
          "text": "Does installing elastic_defend_integration_policy on 8.14-8.16 actually install security_detection_engine prebuilt rules into the default space?",
          "blocking": false
        },
        {
          "id": "stable-bundled-rule-id",
          "text": "Is there a bundled prebuilt rule_id guaranteed present across 8.14.3/8.15.5/8.16.6 for Approach A to hard-code?",
          "blocking": false
        },
        {
          "id": "immutable-discriminates-epr-vs-bundled",
          "text": "Do immutable/rule_source distinguish bundled prebuilt rules from EPR/Fleet-package-installed prebuilt rules?",
          "blocking": false
        },
        {
          "id": "status-dedupe-mechanism",
          "text": "Does _status rules_not_installed truly stay unchanged when a non-bundled rule is deleted, confirming the proposed root cause?",
          "blocking": false
        }
      ],
      "affected_capabilities": [],
      "estimated_scope": "small",
      "references": [
        { "type": "repo-path", "path": "internal/kibana/prebuilt_rules/acc_test.go" },
        { "type": "repo-path", "path": "internal/clients/kibanaoapi/prebuilt_rules.go" },
        { "type": "repo-path", "path": "internal/clients/kibanautil/spaces.go" },
        { "type": "repo-path", "path": "internal/fleet/elastic_defend_integration_policy" },
        { "type": "repo-path", "path": "scripts/targeted-testacc/classifier.go" },
        { "type": "repo-path", "path": "scripts/targeted-testacc/selector.go" },
        { "type": "repo-path", "path": "Makefile" },
        { "type": "repo-path", "path": "internal/kibana/security_detection_rule/acc_test.go" },
        { "type": "repo-path", "path": "generated/kbapi/kibana.gen.go" },
        { "type": "repo-path", "path": "internal/kibana/prebuilt_rules/resource.go" },
        { "type": "repo-path", "path": "internal/clients/kibanaoapi/security_enable_rule.go" },
        { "type": "elastic-docs", "url": "https://www.elastic.co/docs/solutions/security/configure-elastic-defend/install-elastic-defend" },
        { "type": "elastic-docs", "url": "https://www.elastic.co/docs/api/kibana/operation/operation-installprebuiltrulesandtimelines" },
        { "type": "elastic-docs", "url": "https://www.elastic.co/docs/api/kibana/operation/operation-readprebuiltrulesandtimelinesstatus" },
        { "type": "elastic-docs", "url": "https://www.elastic.co/docs/solutions/security/get-started/spaces-elastic-security" },
        { "type": "elastic-docs", "url": "https://www.elastic.co/docs/deploy-manage/manage-spaces-fleet" },
        { "type": "issue", "url": "https://github.com/elastic/terraform-provider-elasticstack/issues/5541" }
      ],
      "gate": {
        "outcome": "ready-for-change-factory",
        "checklist": {
          "grounded": true,
          "mapped": true,
          "compatible": true,
          "versioned": true,
          "testable": true,
          "idiomatic": true
        },
        "score": 95,
        "scores": [69, 80, 88, 48, 95],
        "converged": true,
        "rounds": 5,
        "outstanding_feedback": [],
        "author_model": "anthropic/claude-sonnet-5",
        "critic": {
          "model": "openai/gpt-6.1-sol",
          "status": "ok"
        }
      }
    }
  5. added
    ready-for-change-factory
    on Dec 1, 2026
  6. tehbooom commented on Dec 1, 2026

    @tehbooom
    CollaboratorAuthor

    /change-factory go with approach a and b.

    Scope

    • Move default to an isolated space. In the fixture, wire space_id via elasticstack_kibana_space.test.space_id.
    • Apply prebuiltRulesInSpaceConstraints to it.
    • Leave TestAccResourcePrebuiltRulesDefaultSpaceID as is.
    • In deleteSingleDetectionRule, use a large perPage and pick the first immutable == true rule. Fail with require.NotEmpty instead of indexing Data[0].
    • Assert the _status delta: rules_not_installed +1, rules_installed −1, other counters unchanged.

    Out of scope: hard-coded rule_id, a paginated-selector helper and its unit test, and shard planner changes.

  7. added
    phase-specification
    and removed on Dec 1, 2026
  8. github-actions commented on Dec 1, 2026

    @github-actions
    Contributor

    ✅ Change Factory Issue Intake completed successfully!

    Pull request created: #5542

    Generated by Change Factory Issue Intake for #5541

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-reproductionphase-specificationready-for-change-factorytriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions