Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
- [x] Require `get` for named selections and `list` for label/all-of-kind selections in the RP namespace.
- [x] Authorize creates and spec-changing updates; preserve existing validation and deletion cleanup behavior.
- [x] Add RP constructor, scope, selector, overlapping-review, identity, denial, and failure tests.
- **Success criterion:** RP authorization is independently testable, fails closed, and does not require live object or informer dependencies.
- **Success criterion:** RP authorization is independently testable, fails closed, and derives get/list checks without fetching source objects.

### Phase 2b: ClusterResourcePlacement authorization (follow-up slice)

- [ ] Add direct cluster-scoped resource authorization.
- [ ] Resolve selected Namespaces using live hub API reads.
- [ ] Add NamespaceOnly, NamespaceWithResourceSelectors, and NamespaceWithResources authorization.
- [ ] Add CRP webhook tests for namespace modes, scope, overlapping selectors, and failure cases.
- [x] Add direct cluster-scoped resource authorization.
- [x] Resolve selected Namespaces using live hub API reads.
- [x] Add NamespaceOnly, NamespaceWithResourceSelectors, and NamespaceWithResources authorization.
- [x] Add focused CRP authorizer unit tests for namespace modes, scope, overlapping selectors, eligibility, fresh reads, and failures.
- **Success criterion:** CRP authorization follows the agreed get/list policy without expanding the RP-only review scope.

### Phase 3: Override authorization
Expand All @@ -64,7 +64,7 @@

- [ ] Run formatting and focused authorization, webhook, and option tests.
- [ ] Run the smallest relevant integration tests using real Kubernetes RBAC authorization.
- [ ] Add focused RP webhook authorization wiring and update-gating coverage.
- [ ] Add focused RP/CRP webhook authorization wiring and update-gating coverage.
- [ ] Run `make reviewable` before submission.
- [ ] Update this breadcrumb with implementation details, changed files, and validation results.
- **Success criterion:** Focused and repository-required checks pass with no authorization bypass or unrelated behavior regression.
Expand All @@ -89,17 +89,21 @@
## Status

Plan approved by the user. Phase 1 and the Phase 2a RP-only slice are complete on
`feat/selected-resource-authorization-phase-2`. Phase 2b and Phases 3-5 remain.
`feat/selected-resource-authorization-phase-2`. Phase 2b authorizer logic and unit
tests are complete on `feat/selected-resource-authorization-crp`; Phases 3-5 remain.
On October 19, the user requested a smaller review scope. The full implementation
is preserved in pushed commit `e640d9b2`; the follow-up slice retains RP only.

Phase 2a merged as kubefleet-dev/kubefleet#988. Phase 2b is based on that merged RP
implementation. Production webhook wiring, SAR RBAC, and the default-on flag
remain Phase 4.

## Phase 2a implementation details

- Added `ResourcePlacementAuthorizer` and `NewResourcePlacementAuthorizer` in
`pkg/utils/authorization/placement.go`, with private mapper, reviewer, and
eligibility-checker dependencies. No reader, informer, or Namespace resolution
is needed. An explicit RP/CRP type switch routes RP to its typed resolver;
the CRP branch returns a clear not-implemented error for the follow-up slice.
- Added the RP authorizer in `pkg/utils/authorization/placement.go`. Phase 2b
generalizes its type and construction for both placement APIs. RP requests
still need no Namespace resolution or ordinary object reads. The explicit
RP/CRP type switch initially deferred CRP; Phase 2b fills in that branch.
- Build get checks for named selectors and list checks for label/all-of-kind
selectors in the RP namespace. No source objects are fetched. Reuse the Phase 1
reviewer's identity preservation, deduplication, and bounded concurrency.
Expand All @@ -112,12 +116,69 @@ is preserved in pushed commit `e640d9b2`; the follow-up slice retains RP only.
shared validator tests cover admission decision mapping. The dedicated RP
webhook authorization test file was removed at the user's request; its wiring
and update-gating coverage is deferred.
- Defer CRP authorization and its tests. Its handler passes nil to the shared
- Defer CRP production wiring and webhook tests. Its handler passes nil to the shared
authorization parameter, preserving existing behavior. The controller's resource
selector resolver is unchanged.
- Production registration still does not inject the RP authorizer. Default-on
enforcement, rollout wiring, and SAR RBAC remain Phase 4.

## Phase 2b implementation details

- A single `NewPlacementAuthorizer` creates the shared `PlacementAuthorizer` for
both RP and CRP. It validates the mapper, reviewer, eligibility checker,
uncached Namespace reader, and resource-type inventory up front. All five are
required even though RP requests do not use the Namespace dependencies.
The RP/CRP-specific constructors and RP-specific type alias were removed.
One fully configured instance can later be injected into both webhooks.
- CRP resolution composes two helpers: Namespace selection returns checks and a
`namespaceScope` value; non-Namespace selection consumes that scope and returns
its own checks. The outer method only validates the CRP and combines results,
without sharing mutable state between the two passes.
NamespaceOnly, NamespaceWithResources (including default), and
NamespaceWithResourceSelectors have explicit separate cases. Selective mode
requires exactly one named active Namespace and cannot mix Namespace selectors.
- NamespaceOnly builds get/list checks without any Namespace reader calls or
existence checks. Mapping, kind eligibility, and selector validation still run.
Expansion and selective modes resolve Namespaces live, filter deleting objects,
and enforce content-namespace eligibility; NamespaceOnly does not apply those
content exclusions, matching the controller.
- Before any CRP Namespace reads, authorize all Namespace get/list checks derived
from selector metadata. Denied, no-opinion, and indeterminate Namespace reviews
stop resolution immediately, so responses cannot disclose discovered Namespace
names or existence through lookup errors or expanded denial reasons. After an
allowed preflight, resolve expansion and authorize the full batch. Namespace
checks are intentionally repeated in that batch to keep the implementation
simple; no cross-phase filtering or deduplication optimization is used.
- Expansion builds list checks for each eligible tracked namespaced resource type
in each active selected Namespace. Ordinary resource checks remain metadata-only:
get by name or list for label/all-of-kind, with no per-object get checks.
- Namespace expansion skips inventory entries whose kinds no longer map
(`NoMatch`), with a debug log, matching the controller's removed-CRD handling.
Other mapper/eligibility failures and explicit unknown selectors still fail
closed. Tests retain valid checks before and after a stale inventory entry.
- Added focused tests for exact attributes, all modes, multiple Namespaces,
ordering, overlaps, exclusions, missing/deleting Namespaces, malformed selectors,
mapping/inventory/API failures, denials, and fresh Namespace reads using the
current requester. Tests fail on any non-Namespace reader operation.
NamespaceOnly tests additionally require exactly zero reader calls for named,
label, all-of-kind, and nonexistent named selections. Namespace read failures
are tested in expansion modes, and non-NoMatch inventory mapper errors remain
explicit failures.
Preflight regressions assert zero Namespace reads and no expanded reviews on
Namespace denial, no opinion, API failure, or evaluation error, including named
missing Namespaces, label/all selections, and selective mode. Label/all failure
responses must not contain discovered Namespace names.
- No controller resolver, shared validation, or webhook code changed. No new
webhook test scaffold or production enforcement wiring is included.

## Phase 2b validation

- Focused uncached race tests and `go vet` passed for authorization, validator, and
both placement webhook packages.
- `go build ./cmd/hubagent/...`, new-code lint, repository `make lint` using the
installed v2.13.2 linter, and `git diff --check` passed.
- Go commands use `MS_GOTOOLCHAIN_ALLOW_NON_LOCAL=1 GOTOOLCHAIN=auto`.

## Phase 2a validation

- Focused race tests passed for `pkg/utils/authorization`, `pkg/utils/validator`,
Expand Down
10 changes: 5 additions & 5 deletions .github/skills/tiered-memory/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source: design proposal

# Skill: Tiered Agent Memory

> **Status (v0.10.0):** This skill describes a **design proposal**, not a shipped runtime. Skill files install via `squad init`/`upgrade`, but the underlying tier scaffolding (`.squad/memory/hot/`, `cold/`, `wiki/`), Scribe promotion logic, and spawn-template tier-aware reads are tracked in [bradygaster/squad#1264](https://github.com/bradygaster/squad/issues/1264). Until those land, agents continue to load full `history.md` + `decisions.md` on every spawn.
> **Status (v0.10.0):** This skill describes a **design proposal**, not a shipped runtime. Skill files install via `squad init`/`upgrade`, but the underlying tier scaffolding (`.squad/memory/hot/`, `cold/`, `wiki/`), Scribe promotion logic, and spawn-template tier-aware reads are tracked in [github/squad#1264](https://github.com/github/squad/issues/1264). Until those land, agents continue to load full `history.md` + `decisions.md` on every spawn.

## Overview

Expand Down Expand Up @@ -116,9 +116,9 @@ Until then, see the Scribe charter for current behavior: `.squad/agents/scribe/c

## References

- Tracking issue: [bradygaster/squad#1264](https://github.com/bradygaster/squad/issues/1264) — installation gap + runtime status
- Original design spike: [bradygaster/squad#686](https://github.com/bradygaster/squad/issues/686) — tiered memory implementation plan
- Related: [bradygaster/squad#600](https://github.com/bradygaster/squad/issues/600) — context payload growth
- Tracking issue: [github/squad#1264](https://github.com/github/squad/issues/1264) — installation gap + runtime status
- Original design spike: [github/squad#686](https://github.com/github/squad/issues/686) — tiered memory implementation plan
- Related: [github/squad#600](https://github.com/github/squad/issues/600) — context payload growth

---

Expand Down Expand Up @@ -217,5 +217,5 @@ If blocked or uncertain:
- Hot tier is always included; keep it focused
- Cold adds a summary; only include when history is relevant
- Wiki adds variable size; only include specific relevant docs
- Runtime backing is tracked in [bradygaster/squad#1264](https://github.com/bradygaster/squad/issues/1264) — until those changes land, this skill is design-only and agents continue to load full history.md + decisions.md on every spawn
- Runtime backing is tracked in [github/squad#1264](https://github.com/github/squad/issues/1264) — until those changes land, this skill is design-only and agents continue to load full history.md + decisions.md on every spawn

7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Set up Ginkgo CLI
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@v2.23.4
go install github.com/onsi/ginkgo/v2/ginkgo

- name: Prepare necessary environment variables
run: |
Expand Down Expand Up @@ -170,7 +170,10 @@ jobs:

- name: Install Ginkgo CLI
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@v2.23.4
go install github.com/onsi/ginkgo/v2/ginkgo

- name: Increase inotify limits for multi-node Kind clusters
run: sudo sysctl -w fs.inotify.max_user_instances=1024 fs.inotify.max_user_watches=1048576

- name: Install Kind
# Before updating the kind version to use, verify that the current kind image
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Helm
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5
uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e # v5
with:
version: v3.17.0

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -56,7 +56,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
uses: github/codeql-action/autobuild@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -69,4 +69,4 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
uses: github/codeql-action/analyze@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
ref: ${{ needs.setup.outputs.tag }}

- name: Login to ghcr.io
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
ref: ${{ needs.setup.outputs.tag }}

- name: Login to GitHub Container Registry
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -197,7 +197,7 @@ jobs:
# version that packages a release is the same one code-lint.yml lints the
# charts with.
- name: Set up Helm
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5
uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e # v5
with:
version: v3.17.0

Expand Down Expand Up @@ -252,7 +252,7 @@ jobs:
# follow-up issue). Auditing egress at least records what it reaches out
# to until that action is replaced.
- name: Harden Runner
uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Login to ${{ env.REGISTRY }}
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ jobs:
echo "=== Docker moved to /mnt, verifying ==="
docker info | grep "Docker Root Dir" || true

- name: Increase inotify limits for Kind clusters
run: sudo sysctl -w fs.inotify.max_user_instances=1024 fs.inotify.max_user_watches=1048576

- name: Set up Ginkgo CLI
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@v2.23.4
go install github.com/onsi/ginkgo/v2/ginkgo

- name: Travel back in time to the before upgrade version
run: |
Expand Down Expand Up @@ -171,9 +174,12 @@ jobs:
echo "=== Docker moved to /mnt, verifying ==="
docker info | grep "Docker Root Dir" || true

- name: Increase inotify limits for Kind clusters
run: sudo sysctl -w fs.inotify.max_user_instances=1024 fs.inotify.max_user_watches=1048576

- name: Set up Ginkgo CLI
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@v2.23.4
go install github.com/onsi/ginkgo/v2/ginkgo

- name: Travel back in time to the before upgrade version
run: |
Expand Down Expand Up @@ -273,9 +279,12 @@ jobs:
echo "=== Docker moved to /mnt, verifying ==="
docker info | grep "Docker Root Dir" || true

- name: Increase inotify limits for Kind clusters
run: sudo sysctl -w fs.inotify.max_user_instances=1024 fs.inotify.max_user_watches=1048576

- name: Set up Ginkgo CLI
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@v2.23.4
go install github.com/onsi/ginkgo/v2/ginkgo

- name: Travel back in time to the before upgrade version
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
timeout-minutes: 10
steps:
- name: Harden Runner
uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion apis/placement/v1/clusterresourceplacement_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ type RollingUpdateConfig struct {
// We have a built-in resource state detector to determine the availability status of following well-known Kubernetes
// native resources: Deployment, StatefulSet, DaemonSet, Service, Namespace, ConfigMap, Secret,
// ClusterRole, ClusterRoleBinding, Role, RoleBinding.
// Please see [SafeRollout](https://github.com/Azure/fleet/tree/main/docs/concepts/SafeRollout/README.md) for more details.
// Please see [SafeRollout](https://kubefleet.dev/docs/concepts/safe-rollout/) for more details.
// For other types of resources, we consider them as available after `UnavailablePeriodSeconds` seconds
// have passed since they were successfully applied to the target cluster.
// Default is 60.
Expand Down
2 changes: 1 addition & 1 deletion apis/placement/v1beta1/clusterresourceplacement_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ type RollingUpdateConfig struct {
// We have a built-in resource state detector to determine the availability status of following well-known Kubernetes
// native resources: Deployment, StatefulSet, DaemonSet, Service, Namespace, ConfigMap, Secret,
// ClusterRole, ClusterRoleBinding, Role, RoleBinding.
// Please see [SafeRollout](https://github.com/Azure/fleet/tree/main/docs/concepts/SafeRollout/README.md) for more details.
// Please see [SafeRollout](https://kubefleet.dev/docs/concepts/safe-rollout/) for more details.
// For other types of resources, we consider them as available after `UnavailablePeriodSeconds` seconds
// have passed since they were successfully applied to the target cluster.
// Default is 60.
Expand Down
Loading
Loading