← Back to Pull requests

DRA policy boundary #803

Merged
bart0sh merged 13 files (594 lines) on Oct 01, 2026 20:20 UTC
View on GitHub
bart0sh bart0sh commented on Sep 21, 2026 07:20 UTC
Author

Let the policy decide what the DRA driver publishes

Second PR of the DRA series, on top of #788. It gives policy.Backend and
policy.Policy the two claim methods of the DRA interface, gives all three
backends identical no-op implementations of them, and lets the active policy
push the devices the driver publishes, instead of the driver publishing a
fixed empty slice.

On a cluster this is still inert: no backend publishes any devices, so an
enabled driver registers and publishes an empty ResourceSlice, exactly as
after #788. What changes is who decides that.

The interface

A policy gets two methods, called by resmgr:

AllocateClaim(
    claim *resourceapi.ResourceClaim,
    results []resourceapi.DeviceRequestAllocationResult,
) ([]specs.ContainerEdits, error)
ReleaseClaim(uid types.UID) error

and one method it can call on resmgr, through the new BackendOptions.Owner:

// Owner is what a policy can ask of the resource manager running it.
type Owner interface {
    PublishDRADevices([]resourceapi.Device) error
}

That is the whole extension point for DRA, and it is deliberately narrow:

Upstream types only. No Claim, ClaimAllocation or CDIEdit type of our
own. resourceapi.ResourceClaim, resourceapi.DeviceRequestAllocationResult
and specs.ContainerEdits already carry everything the boundary needs,
including ShareID and ConsumedCapacity for devices with consumable
capacity, so the interface adds no vocabulary a reader has to learn. The only
new dependency is tags.cncf.io/container-device-interface/specs-go.

ReleaseClaim takes a UID and nothing else, because a UID is all the
unprepare path has: kubeletplugin hands UnprepareResourceClaims only
namespace, name and UID, with no allocation results. So the policy has to keep
whatever it needs to undo an allocation, keyed by claim UID. It wants that
anyway, since it also has to keep that state across a restart. Unlike its
container allocations, it cannot rebuild it from the running containers: a
claim may have no container yet.

The returned edits correspond to results positionally: edits[i] belongs
to results[i]. That is what lets the driver assemble a CDI spec from them
without knowing what any single edit means.

Publishing is a push

The policy calls PublishDRADevices whenever its devices change: typically
once from Start, and again from wherever it learns that they changed,
Reconfigure for instance. Each call replaces what was published before.

  • The policy does not need to know whether DRA is on. With DRA disabled, or

  • left off for lack of a node name or a kubernetes client, the call is a no-op.
  • Timing does not matter either. The driver is set up before the policy

  • starts, and devices pushed before the driver registers with the kubelet are
    published when it does.
  • The devices are copied, so the policy is free to change them afterwards.

  • No devices means an empty slice, not no slice. That states that the

  • driver is alive and offers nothing right now, and a policy which stops
    offering devices does not leave a stale slice behind.
  • Errors come straight back to the caller. The call only hands the devices

  • over to the kubeletplugin controller, which does the actual publishing
    asynchronously and retries failures itself, so an error means we could not
    even get that far. What to do about an unusable DRA configuration is up to the
    policy: it can fail Start or Reconfigure, or warn and publish nothing.

    An earlier revision had resmgr pull the devices with a DRADevices() method,
    once at start. The push replaces it, following the review discussion: it
    republishes for free when the devices change, and it keeps the error with the
    policy that caused it.

    Locking. A policy runs with resmgr's lock held, so PublishDRADevices
    must not and does not take it. Below that, the driver has a mutex of its own,
    guarding only its registration and the devices published last. Nothing is
    called back while that mutex is held, and no kubelet request takes it: those
    take resmgr's lock, and nothing else. The locks are therefore always taken in
    the same order, resmgr's first, and the call from the policy cannot deadlock
    against event processing or a kubelet request.

    Adding a device type later touches no driver code

    Say topology-aware wants to publish isolated cores alongside high-priority
    ones. It pushes more devices, with whatever attributes it wants them selected
    by, and teaches AllocateClaim what to do with a request for them.
    pkg/resmgr/dra is untouched: it never reads a device attribute, and there is
    a test asserting it passes devices through unchanged. A DeviceClass selects
    on device.driver plus whatever attributes the policy chose. Balloons gains
    DRA support the same way, by replacing two stubs and publishing its devices,
    all in its own package.

    Why the claim methods merge without a caller

    The claim dispatch path that calls AllocateClaim/ReleaseClaim is the next
    PR. Leaving the two methods out here would mean touching policy.go and all
    three backends twice for one interface, and would split the subtle parts of
    the contract (idempotency across repeated prepares, the positional edits, being
    the last line of defense against handing the same resources to two claims)
    away from the rest of the boundary. The interface is what is under review here,
    so it is reviewed as one piece.

    Deliberately left for later

  • claim dispatch: prepare/unprepare routed to AllocateClaim/

  • ReleaseClaim, plus the CDI spec store that turns the returned edits into
    something kubelet can inject. Next PR (#806).
  • real implementations: the template policy first (#817), as a worked

  • example for policy authors and as a second implementation of this interface
    written before the first one is finished, then topology-aware.
  • end-to-end coverage: arrives with the first policy that actually

  • allocates (#817).

    Worth a reviewer's attention

  • The signatures and the contract comments on them. Everything that

  • follows is built on them, and this is the cheapest point at which to move
    them.
  • pkg/resmgr/policy gained only resourceapi, specs and types

  • imports
    , and no dependency on pkg/resmgr/dra. resmgr implements
    policy.Owner and forwards to the driver, so neither package knows the other.
  • The driver publishes devices exactly as the policy described them, in one

  • pool named after the node, split into slices of at most
    ResourceSliceMaxDevices.
  • All three backends' claim stubs are identical: a shared

  • policy.ErrNoDRAClaims, not a "not implemented yet" placeholder. Each of
    these policies genuinely does not support DRA claims, and errors.Is works on
    that answer. None of them publishes any devices.

    Testing

    go test ./... passes, and golangci-lint finds no issues. New tests cover:

  • the AllocateClaim/ReleaseClaim forwarders on the policy struct, with

  • success and error propagation;
  • publishing no devices, devices pushed before the driver starts and devices

  • pushed after it started, each ending up as exactly one published slice;
  • the driver copying the devices it is given;

  • the slices built from the devices: none, attribute-less devices passed

  • through unchanged, attributes and capacity, and chunking at, one past and
    well past the per-slice limit;
  • PublishDRADevices being a no-op when resmgr runs without a driver.
  • The template DRA e2e test in #817 runs on top of this and passes on
    Kubernetes 1.37.

    Diff: 594 lines (+507 / -87) across 13 files Reviewer: klihub Review duration: 15180m
    All Vouch review confidence checks passed
    Residual risk 0.08 = Change Risk (0.59) × (1 − Review Confidence (0.87)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.59 · 594 lines diff across 13 files
    0.59
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.83 · 5 substantive comment(s)
    0.83
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    87%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.382
    Real PR Conversation Timeline
    22 items
    Copilot Copilot commented on code on Sep 21, 2026 07:25 UTC
    Code Review
    pkg/resmgr/dra/plugin.go:1
    @@ -230,16 +245,27 @@ func (p *Plugin) HandleError(_ context.Context, err error, msg string) {
     	p.owner.RequestShutdown(fmt.Sprintf("dra: %s: %v", msg, err))
     }
     
    -// driverResources returns the resources to publish for this driver. Publishing
    -// an empty slice, instead of no slice at all, states that the driver is alive
    -// and has no devices, which is what this driver has until a policy provides
    -// some.
    -func (p *Plugin) driverResources() resourceslice.DriverResources {
    +// driverResources returns the resources to publish for this driver: the devices
    +// of the active policy, in a single pool named after our node. The devices are
    +// passed on as the policy described them, attributes and all — what they mean
    +// is the policy's business, not ours.
    +//
    +// A policy with no devices gets an empty slice published, not no slice at all.
    +// That states that the driver is alive and currently offers nothing, and it
    +// replaces whatever we published before, so a policy which stops offering
    +// devices does not leave a stale slice behind.
    +func (p *Plugin) driverResources() (resourceslice.DriverResources, error) {
    +	devices, err := p.policy.DRADevices()
    +	if err != nil {
    +		return resourceslice.DriverResources{},
    +			fmt.Errorf("dra: policy failed to provide DRA devices: %w", err)
    +	}
    +
     	return resourceslice.DriverResources{
     		Pools: map[string]resourceslice.Pool{
     			p.nodeName: {
    -				Slices: []resourceslice.Slice{{}},
    +				Slices: []resourceslice.Slice{{Devices: devices}},

    A ResourceSlice may contain at most 128 devices (resourceapi.ResourceSliceMaxDevices). Putting the policy's entire list into one slice makes publication fail for larger CPU inventories. Split the list across multiple resourceslice.Slice values while retaining one empty slice for an empty policy; add a boundary test with 129 devices.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Sep 21, 2026 07:25 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    Copilot review overview

    🟡 Changes recommended

    Device lists exceeding Kubernetes’ 128-device ResourceSlice limit cannot currently be published.

    Get a fresh assessment by requesting another Copilot review.

    Review effort: Balanced
    Findings: 1 <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture>

    <details open>
    <summary><strong>Open (1)</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> [Split ResourceSlice device lists above the 128-device limit](#discussion_r4060026630) · New

  • </details>

    <details>
    <summary><strong>What changed in this PR</strong></summary>

    Adds a policy-controlled DRA boundary and publishes devices supplied by the active policy.

    Changes:

  • Adds DRA methods and forwarding to policy interfaces.

  • Publishes policy-provided devices and propagates validation errors.

  • Adds no-op backend implementations and tests.
  • | File | Description |
    | ---- | ----------- |
    | pkg/​resmgr/​policy/​policy.go | Defines and forwards DRA policy methods. |
    | pkg/​resmgr/​policy/​policy_test.go | Tests DRA forwarding. |
    | pkg/​resmgr/​policy/​error.go | Adds the unsupported-claims error. |
    | pkg/​resmgr/​dra/​plugin.go | Publishes policy-provided devices. |
    | pkg/​resmgr/​dra/​plugin_test.go | Tests publication and policy errors. |
    | pkg/​resmgr/​dra.go | Passes the active policy to the plugin. |
    | pkg/​resmgr/​dra_test.go | Updates resource-manager DRA tests. |
    | go.mod | Adds the CDI specifications dependency. |
    | go.sum | Records CDI dependency checksums. |
    | cmd/​plugins/​topology-aware/​policy/​dra.go | Adds topology-aware DRA stubs. |
    | cmd/​plugins/​template/​policy/​template-policy.go | Adds template-policy DRA stubs. |
    | cmd/​plugins/​balloons/​policy/​balloons-policy.go | Adds balloons-policy DRA stubs. |
    </details>

    ---

    💡 <a href="/containers/nri-plugins/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Sep 21, 2026 08:15 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    Copilot review overview

    🟢 Approval recommended

    The policy boundary, driver integration, backend stubs, and relevant edge cases are implemented consistently and adequately tested.

    Review effort: Balanced
    Findings: None

    <details>
    <summary><strong>Resolved since last review (1)</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> [Split ResourceSlice device lists above the 128-device limit](#discussion_r4060026630)

  • </details>

    klihub klihub commented on Sep 22, 2026 20:23 UTC
    Reviewer

    I skimmed through this once and it looks good to me. I'll give it another read tomorrow.

    klihub klihub commented on Sep 23, 2026 13:45 UTC
    Contributor

    @bart0sh There is a duplicated (test) function flagged by linting...

    klihub klihub approved these changes on Sep 23, 2026 13:55 UTC
    Approved Reviewer

    LGTM.

    askervin askervin commented on code on Sep 24, 2026 13:00 UTC
    Code Review
    pkg/resmgr/dra/plugin.go:1
    @@ -230,16 +250,40 @@ func (p *Plugin) HandleError(_ context.Context, err error, msg string) {
     	p.owner.RequestShutdown(fmt.Sprintf("dra: %s: %v", msg, err))
     }
     
    -// driverResources returns the resources to publish for this driver. Publishing
    -// an empty slice, instead of no slice at all, states that the driver is alive
    -// and has no devices, which is what this driver has until a policy provides
    -// some.
    -func (p *Plugin) driverResources() resourceslice.DriverResources {
    +// driverResources returns the resources to publish for this driver: the devices
    +// of the active policy, in a single pool named after our node. The devices are
    +// passed on as the policy described them, attributes and all — what they mean

    nit: let's stick with pure ASCII.

    askervin askervin commented on Sep 24, 2026 13:26 UTC
    Reviewer

    Just a nit on a non-ASCII character, otherwise LGTM.

    Looking forward to currently out-of-scope resource updates from policies...

    bart0sh bart0sh commented on code on Sep 24, 2026 15:14 UTC
    Code Review
    pkg/resmgr/dra/plugin.go:1
    @@ -230,16 +250,40 @@ func (p *Plugin) HandleError(_ context.Context, err error, msg string) {
     	p.owner.RequestShutdown(fmt.Sprintf("dra: %s: %v", msg, err))
     }
     
    -// driverResources returns the resources to publish for this driver. Publishing
    -// an empty slice, instead of no slice at all, states that the driver is alive
    -// and has no devices, which is what this driver has until a policy provides
    -// some.
    -func (p *Plugin) driverResources() resourceslice.DriverResources {
    +// driverResources returns the resources to publish for this driver: the devices
    +// of the active policy, in a single pool named after our node. The devices are
    +// passed on as the policy described them, attributes and all — what they mean

    @askervin Thank you for the review! Fixed.

    askervin askervin commented on Sep 25, 2026 06:21 UTC
    Contributor

    @bart0sh, @klihub, thinking of this series over night, especially in the perspective of updating resources.

    Would you see problems if a policy would publish DRA resource slices via cache, instead of resmgr asking it DRADevices()?

    That would enable the policy to push new "desired state" of what it wants to have published to the cache at any point of time. That would cover, not only resmgr-triggered actions (reconfigure, allocate/free resources for a container), but also unsolicited policy events, such as detecting hotplugging of CXL memory.

    resmgr's DRA subsystem could be wired to listen to these updates in cache and update published resource slices accordingly.

    klihub klihub commented on Sep 25, 2026 06:43 UTC
    Contributor

    @bart0sh, @klihub, thinking of this series over night, especially in the perspective of updating resources.

    > Would you see problems if a policy would publish DRA resource slices via cache, instead of resmgr asking it DRADevices()?

    > That would enable the policy to push new "desired state" of what it wants to have published to the cache at any point of time.

    That would cover, not only resmgr-triggered actions (reconfigure, allocate/free resources for a container), but also unsolicited policy events, such as detecting hotplugging of CXL memory.

    > resmgr's DRA subsystem could be wired to listen to these updates in cache and update published resource slices accordingly.

    Couldn't that also be accomplished by changing the resource publishing control flow to a push model, or allowing a push model as well ? So basically adding an interface (to the policy backend options) for pushing resources to be published to the resmgr-level DRA driver/logic. I think that's how it was in the prototype. But I don't know what kind of problems that could potentially cause in the new/real driver logic.

    bart0sh bart0sh commented on Sep 25, 2026 12:50 UTC
    Author

    > @bart0sh, @klihub, thinking of this series over night, especially in the perspective of updating resources.

    > Would you see problems if a policy would publish DRA resource slices via cache, instead of resmgr asking it DRADevices()?

    > That would enable the policy to push new "desired state" of what it wants to have published to the cache at any point of time.

    > > That would cover, not only resmgr-triggered actions (reconfigure, allocate/free resources for a container), but also unsolicited policy events, such as detecting hotplugging of CXL memory.

    > resmgr's DRA subsystem could be wired to listen to these updates in cache and update published resource slices accordingly.

    > Couldn't that also be accomplished by changing the resource publishing control flow to a push model, or allowing a push model as well ? So basically adding an interface (to the policy backend options) for pushing resources to be published to the resmgr-level DRA driver/logic. I think that's how it was in the prototype. But I don't know what kind of problems that could potentially cause in the new/real driver logic.

    Can we add push functionality using existing BackendOptions.SendEvent, so a policy would send an event to resource manager, telling it what kind of its data has changed, e.g. devices, topology zones, extended resources, etc. Resmgr then can handle it. Handling would call existing policy interfaces (DRADevices(), GetTopologyZones(), GetExtendedResources(), etc) to get the latest data from policy and do whatever is needed with it, e.g. if devices change, it would republish the resource slice(s).

    klihub klihub commented on Sep 25, 2026 13:18 UTC
    Contributor

    > > @bart0sh, @klihub, thinking of this series over night, especially in the perspective of updating resources.

    > > Would you see problems if a policy would publish DRA resource slices via cache, instead of resmgr asking it DRADevices()?

    > > That would enable the policy to push new "desired state" of what it wants to have published to the cache at any point of time.

    >

    >

    > > That would cover, not only resmgr-triggered actions (reconfigure, allocate/free resources for a container), but also unsolicited policy events, such as detecting hotplugging of CXL memory.

    > > resmgr's DRA subsystem could be wired to listen to these updates in cache and update published resource slices accordingly.

    >

    >

    > Couldn't that also be accomplished by changing the resource publishing control flow to a push model, or allowing a push model as well ? So basically adding an interface (to the policy backend options) for pushing resources to be published to the resmgr-level DRA driver/logic. I think that's how it was in the prototype. But I don't know what kind of problems that could potentially cause in the new/real driver logic.

    > Can we add push functionality using existing BackendOptions.SendEvent, so a policy would send an event to resource manager, telling it what kind of its data has changed, e.g. devices, topology zones, extended resources, etc. Resmgr then can handle it. Handling would call existing policy interfaces (DRADevices(), GetTopologyZones(), GetExtendedResources(), etc) to get the latest data from policy and do whatever is needed with it, e.g. if devices change, it would republish the resource slice(s).

    @bart0sh @askervin Maybe it could be done that way. If I understand correctly your suggestion, the event would essentially be a "request to poll me for this type or these types of data", then resmgr would use the corresponding policy interfaces to poll the data and do whatever needs to be done with it. One thing that is a bit difficult on that path is propagating errors back to the policy, if there is a need.

    askervin askervin commented on Sep 25, 2026 13:42 UTC
    Contributor

    Can we add push functionality using existing BackendOptions.SendEvent, so a policy would send an event to resource manager, telling it what kind of its data has changed...

    Indeed, using SendEvent and resmgr eventProcessing looks useful.

    I'd prefer a policy saying directly "these are the DRA devices I want to publish from this node from this point on", instead of two-phase "I want resmgr to ask me again what devices I want to publish in a new situation", and then share them only later when the question comes.

    Even in the two-phase case, most likely the policy would write the devices it wants to publish (or it has previously published, no difference due to async publishing) to cache because otherwise it might find it difficult to match claims in cache to devices it has published.

    In the direct case, when the policy writes []resourceapi.Devices to the cache, the cache could then SendEvent() to resmgr about DRA devices having changed in the cache, which would eventually trigger publishing them.

    That said, I'm not sure if wiring cache to publishing DRA takes too much control from a policy.

    askervin askervin commented on Sep 25, 2026 13:47 UTC
    Contributor

    Hmm... error propagation mentioned by @klihub would be lacking in the cache-based triggering, too.

    It might actually be the reason to have explicit PublishDRADevices([]resourceapi.Device) error in resmgr API that policies would call.

    klihub klihub commented on Sep 25, 2026 13:55 UTC
    Contributor

    Hmm... error propagation mentioned by @klihub would be lacking in the cache-based triggering, too.

    > It might actually be the reason to have explicit PublishDRADevices([]resourceapi.Device) error in resmgr API that policies would call.

    @askervin @bart0sh Yes, being able to propagate back an error is the pro in a direct call. A potential con would be that if there is locking on multiple layers, then this is an opposite control flow than normal event processing, so there is a danger of deadlock by inverted lock ordering.

    bart0sh bart0sh commented on Sep 25, 2026 16:27 UTC
    Author

    > Hmm... error propagation mentioned by @klihub would be lacking in the cache-based triggering, too.

    > It might actually be the reason to have explicit PublishDRADevices([]resourceapi.Device) error in resmgr API that policies would call.

    > @askervin @bart0sh Yes, being able to propagate back an error is the pro in a direct call. A potential con would be that if there is locking on multiple layers, then this is an opposite control flow than normal event processing, so there is a danger of deadlock by inverted lock ordering.

    @klihub I implemented the direct call and pushed it as a separate commit "dra: let the policy push its devices to the resource manager."

    It's implemented the following way: resmgr passes itself to the policy as BackendOptions.Owner, the policy calls it whenever its devices change, and gets any error back directly. There are only two locks on this path, and they are always taken in the same order: 1. outer resmgr lock: the policy runs when it's held and doesn't take it again. 2. inner driver's lock: nnothing is called back while it is held: PublishResources just hands the devices to the kubeletplugin controller, which publishes and retries asynchronously.

    I've also tested it with all related unit tests and dra e2e test for template policy from https://github.com/containers/nri-plugins/pull/817.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Sep 29, 2026 07:43 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    Copilot review overview

    🟢 Approval recommended

    The policy boundary, publication lifecycle, backend stubs, and associated tests are consistent and complete.

    Review effort: Balanced
    Findings: None

    klihub klihub commented on code on Oct 01, 2026 20:17 UTC
    Code Review
    pkg/resmgr/policy/policy.go:1
    @@ -66,6 +79,8 @@ type BackendOptions struct {
     	Cache cache.Cache
     	// SendEvent is the function for delivering events up to the resource manager.
     	SendEvent SendEventFn
    +	// Owner is the resource manager running the policy.
    +	Owner Owner

    nit: we now have two mechanisms for exposing direct callbacks to the remsgr layer: The old SendEvent and the new Owner. It would be cleaner to just have one, and Owner is a much cleaner, better and easy to extend one at that, so eventually we could/should fold SendEvent into it. But we can do that with a separate subsequent PR once this is merged.

    klihub klihub commented on code on Oct 01, 2026 20:19 UTC
    Code Review
    pkg/resmgr/resource-manager.go:1
    @@ -287,7 +289,10 @@ func (m *resmgr) setupPolicy(backend policy.Backend) error {
     		log.Warnf("failed to set active policy: %v", err)
     	}
     
    -	p, err := policy.NewPolicy(backend, m.cache, &policy.Options{SendEvent: m.SendEvent})
    +	p, err := policy.NewPolicy(backend, m.cache, &policy.Options{
    +		SendEvent: m.SendEvent,
    +		Owner:     m,

    nit: this makes it even more obvious, that we should fold SendEvent into Owner, as the latter is a much cleaner interface for exposing callbacks to policies.

    klihub klihub approved these changes on Oct 01, 2026 20:20 UTC
    Approved Reviewer

    LGTM.

    Reviewers
    Assignees
    bart0sh bart0sh
    Labels
    risk: low confidence: 87.1% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 58.8% (MEDIUM) · Higher = larger blast radius
    58.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 87.1% · Lower = rushed or shallow review
    87.1%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.6% · Safe to merge
    7.6%