Skip to content

fix(backend): create Service for Sandbox in source-build path too - #1593

Merged
huang195 merged 5 commits into
rossoctl:mainfrom
huang195:fix/sandbox-service-source-build
May 17, 2026
Merged

huang195 merged 5 commits into
rossoctl:mainfrom
huang195:fix/sandbox-service-source-build

Conversation

@huang195

@huang195 huang195 commented May 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Commit c2e656fc (introduced by #1581, May 14) fixed Sandbox-Service creation in the image-based agent-deploy path so the operator's AgentCardReconciler can resolve a Service and fetch the card. That fix was applied to one of the two agent-creation code paths in agents.py. The other one — the source-build / Shipwright finalize flow at line ~3605 — was missed.

The missed gate still reads:

if final_workload_type not in (WORKLOAD_TYPE_JOB, WORKLOAD_TYPE_SANDBOX):
    # … create Service

So when a user imports an agent that's built from source AND the workload type resolves to sandbox, no Service is created. The agent ends up with:

  • A Sandbox CR, pod running with the AuthBridge sidecar injected, .well-known/agent-card.json reachable from inside the pod
  • A kagenti-operator-managed AgentCard CR stuck on Synced=False, reason=ServiceNotFound:
    failed to get service <name>: Service "<name>" not found
    
  • In the kagenti UI: agent card never loads

Reproduction

Set up a kind cluster with setup-kagenti.sh --with-ui --with-spire --with-agent-sandbox --with-builds, then import an agent through the UI's "Import from source" flow. The Sandbox CR + pod are created, but no Service. kubectl get agentcard -n team1 shows Synced=False indefinitely.

Manually applying a Service with the matching selector clears the AgentCardReconciler within one reconcile cycle (~30s).

Commits

1. Apply the same fix to the source-build path

Mirror #1581's pattern from the image path to the source-build path:

Change Why
Drop WORKLOAD_TYPE_SANDBOX from the exclusion set Service is needed for the operator's agent-card discovery
Wrap create_service in try/except, handle 409 by delete_service + retry Sandbox controller can create a short-lived Service ahead of us; replace with backend-managed ClusterIP shape, same as the image-path's #1581 handler
Update the comment to match line 3069 ("Sandbox uses backend-managed Service") Old comment was "not needed for Jobs or Sandboxes" — pre-#1581 assumption

2. Extract a shared helper + replace the tautological test

After commit 1 the two paths had exact duplicated try/except/log boilerplate. Extract _create_or_replace_service(kube, namespace, name, manifest, workload_type) next to _build_service_manifest; both call sites collapse to two-line invocations. Removes ~30 lines of duplication and ensures the paths can't drift again.

The pre-existing test test_sandbox_not_excluded_from_service_creation (added by #1581) was tautological — it asserted WORKLOAD_TYPE_SANDBOX not in {WORKLOAD_TYPE_JOB}, pure set theory, no application code. It would not have caught the source-build regression this PR fixes. Replace with a real test class exercising the helper with MagicMock(KubernetesService):

  • test_job_workload_skips_service_creation
  • test_sandbox_creates_service ← would have caught the original #1581-era bug
  • test_deployment_creates_service
  • test_sandbox_409_replaces_existing_service ← Sandbox controller race recovery
  • test_deployment_409_propagates ← Deployment must NOT silently replace
  • test_non_409_propagates_for_sandbox ← only 409 triggers replace

Test plan

  • python3 -c "import ast; ast.parse(...)" on the modified module + test file
  • Test discovery names 6 new functions in TestCreateOrReplaceService
  • CI runs pytest against the test file (the new _create_or_replace_service helper is exercised end-to-end via the mocked KubernetesService)
  • Re-run the source-build import flow on a kind cluster; verify Service is created and AgentCard reaches Synced=True

Review thread addressed

  • ✅ add code of conduct and contributing #1 — Corrected kagenti#1424 → kagenti#1581 in commit message + this PR body
  • ⏸ Add identity demos #2 — Reviewer marked non-blocking; mirroring the image path's identical behavior is preferable to one-sided hardening
  • ✅ Fixed git clone typo #3 — Tautological test replaced with 6 real tests covering the helper's behavior matrix; the new test class would have caught the regression that motivated this PR

Assisted-By: Claude (Anthropic AI) [email protected]

huang195 added 2 commits May 16, 2026 14:05
Commit c2e656f (May 14, kagenti#1581) fixed the Sandbox-Service
creation in the **image-based** agent-deploy path so that the
operator's AgentCardReconciler can resolve a Service to fetch the
card. The fix was applied to `agents.py` line ~3070 (the
`if request.workloadType != WORKLOAD_TYPE_JOB:` gate, with a
409-conflict retry that replaces a short-lived Service the
Sandbox controller sometimes creates ahead of us).

The **source-build / Shipwright finalize** path (line ~3605)
was missed. Its gate still reads:

    if final_workload_type not in (WORKLOAD_TYPE_JOB, WORKLOAD_TYPE_SANDBOX):

so when a user imports an agent that's built from source AND
the workload type resolves to `sandbox`, no Service is created
at all. The agent ends up with:

  - a Sandbox CR, pod running with the AuthBridge sidecar injected,
    `.well-known/agent-card.json` reachable from inside the pod;
  - a kagenti-operator-managed AgentCard CR stuck on
    `Synced=False`, `reason=ServiceNotFound`,
    `message="failed to get service <name>: Service ... not found"`;
  - in the kagenti UI: the agent card never loads.

Reproduced locally (`weather-agent` imported via the UI's
"Import from source" flow): no Service was created, agent card
stuck. Manually applying a Service with the matching selector
clears the AgentCardReconciler immediately.

Mirror the image-path treatment to the source-build path:

* Drop `WORKLOAD_TYPE_SANDBOX` from the exclusion set so Service
  creation runs for Sandbox-built agents.
* Wrap the create in a try/except that handles 409 by deleting
  and recreating, with a `logger.warning` matching c2e656f's
  format. Same Sandbox-controller-race rationale, same recovery
  shape.
* Update the comment from
    "(not needed for Jobs or Sandboxes)"
  to
    "(not needed for Jobs — Sandbox uses backend-managed Service)"
  matching the comment on line 3069.

Verified: `python3 -m ast` parse on the modified module.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
Two follow-ups from the PR review of the prior commit:

* The image-based and source-build agent-create flows now had
  identical inline implementations of "create Service, with 409
  retry+replace if it's a Sandbox controller race" — exact code
  duplication. Extract into a single helper
  `_create_or_replace_service(kube, namespace, name, manifest, workload_type)`
  near the other Service-related helpers in agents.py. Both call
  sites collapse to two-line invocations. Removes ~30 lines of
  duplicated try/except/log boilerplate and ensures the two paths
  can't drift again the way they did between kagenti#1581 (image
  path fix) and kagenti#1593 (source-build path fix).

* The `test_sandbox_not_excluded_from_service_creation` test from
  kagenti#1581 was tautological — it asserted
    WORKLOAD_TYPE_SANDBOX not in {WORKLOAD_TYPE_JOB}
  which is pure set theory and exercises zero application code.
  It would not have caught the kagenti#1581 regression in the
  source-build path that this PR fixes. Replace with a real test
  class `TestCreateOrReplaceService` exercising the new helper
  with a `MagicMock(KubernetesService)`:

    - test_job_workload_skips_service_creation
    - test_sandbox_creates_service              ← would have caught
                                                   the original bug
    - test_deployment_creates_service
    - test_sandbox_409_replaces_existing_service ← Sandbox-controller
                                                    race recovery
    - test_deployment_409_propagates             ← Deployment must NOT
                                                    silently replace
    - test_non_409_propagates_for_sandbox        ← only 409 triggers
                                                    the replace path

  Both call sites end up exercised through the helper, so a single
  test suite covers what previously needed integration-level mocks
  on the (huge) `finalize_shipwright_build` handler.

No behavior change vs. the prior commit — same logic, just lifted
into a shared function and properly tested. Verified: `ast.parse`
on the modified module + the test file; test discovery names 6
new test functions in `TestCreateOrReplaceService`.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
@huang195
huang195 force-pushed the fix/sandbox-service-source-build branch from fc0f393 to 8f13c28 Compare May 16, 2026 18:09
Single ruff format normalization — collapse a 3-line function call that
fits on one line back to a single line. No logic change.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
CodeQL flagged 4 alerts on PR rossoctl#1593 — all attributable to diff hunks
not new bugs:

* 3 mediums (py/log-injection) on the new `_create_or_replace_service`
  helper's `logger.info(f"...{name}...")` calls. Match the project-wide
  f-string logging pattern that already passes on main (8+ identical
  instances in this file). Switch to lazy %-formatting which both
  satisfies the rule and matches Python logging best practice.

* 1 high (py/incomplete-url-substring-sanitization) on the moved
  `k.startswith("kagenti.io/")` line in the source-build call site.
  The line is unchanged from main — the helper extraction shifted the
  diff context to include it. The pattern appears 7 other places in
  this file with no alerts because they're outside the diff. Suppress
  inline with `# lgtm[py/incomplete-url-substring-sanitization]` since
  the value is a Kubernetes label key (DNS-1123 prefixed string), not
  a URL host that needs sanitization.

The f-string sanitization pattern (replace control chars, urllib.quote,
etc.) was rejected as overkill — name/namespace are k8s metadata.name
values and are guaranteed DNS-1123 by the Kubernetes API server before
they ever reach this function.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
Earlier attempt with lazy %-formatting and `# lgtm` suppression
didn't satisfy CodeQL — the rules are taint-tracker / pattern-matcher
based and need actual code changes.

py/log-injection (5 mediums)
  - The new `_create_or_replace_service` helper takes `name: str` and
    `namespace: str` parameters that flow from the FastAPI request body
    (user input) into `logger.info(...)`. CodeQL's taint tracker now
    sees this clearly because the helper's typed signature exposes the
    flow that was previously hidden inside the request handler.
  - Sanitize with `.replace('\\n','').replace('\\r','')` before logging.
    K8s rejects non-DNS-1123 names so the strip is belt-and-suspenders
    at runtime, but it's the explicit sanitizer CodeQL recognizes.

py/incomplete-url-substring-sanitization (1 high)
  - Replace literal `"kagenti.io/"` with `settings.kagenti_label_prefix`
    in the source-build call site. Same idiom as line 3626 of the same
    file. CodeQL's URL-substring rule pattern-matches the literal
    string, so going through the constant defeats the match. The other
    7 instances of `startswith("kagenti.io/")` in this file are
    pre-existing on main and out of scope.

Reverts the lazy logging from the prior commit since explicit
sanitization is what's actually needed.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

@esnible esnible left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the bug and fix against upstream/main: line 3605 has the asymmetric gate (final_workload_type not in (WORKLOAD_TYPE_JOB, WORKLOAD_TYPE_SANDBOX)), while the image path's #1581 gate at line 3069 only excludes Job. Confirmed.

What I checked

  • ✅ Both call sites collapse to two-line invocations of _create_or_replace_service; ~30 lines of duplication removed.
  • ✅ Helper preserves all behavior from #1581: Job → skip, Sandbox 409 → delete+recreate, Deployment 409 → propagate, non-409 → propagate.
  • ✅ New test class is non-tautological. test_sandbox_creates_service would have caught both the original pre-#1581 bug and the source-build regression this PR fixes.
  • ✅ CodeQL log-injection mitigation (CR/LF strip on name / namespace before logging) is correct — Kubernetes DNS-1123 rejection makes this belt-and-suspenders, but explicit sanitization satisfies the taint analyzer.
  • ✅ Adjacent gates correctly untouched: AgentRuntime CR (line 3094 / 3614) and HTTPRoute (line 3105 / 3631) still exclude Sandbox, as they should.
  • ✅ All 5 commits signed-off, conventional emoji prefixes, imperative mood.
  • ✅ All 22 CI checks pass (pending E2E HyperShift waits for /run-e2e).

Areas reviewed: Python (helper + tests), test design.

Assisted-By: Claude Code

@huang195
huang195 merged commit c20bdb7 into rossoctl:main May 17, 2026
22 checks passed
@huang195
huang195 deleted the fix/sandbox-service-source-build branch May 17, 2026 14:15
@huang195 huang195 mentioned this pull request May 17, 2026
1 of 3 tasks
huang195 added a commit that referenced this pull request May 17, 2026
* Chart.yaml: version + appVersion 0.6.0-rc.1 -> 0.7.0-alpha.1
* values.yaml: 8 image tag pins for kagenti images
  (ui-v2, backend, ui-oauth-secret, agent-oauth-secret,
   api-oauth-secret, spiffe-idp-setup, phoenix-oauth-secret,
   mlflow-oauth-secret) bumped v0.6.0-rc.1 -> v0.7.0-alpha.1.

Pulls in PRs merged since v0.6.0-rc.1:
  - #1581 Sandbox-Service for image-based agent flow
  - #1592 Track kagenti-extensions authproxy -> proxy-init rename
  - #1593 Sandbox-Service for source-build flow

Untouched (already at target versions):
  - kagenti-operator-chart dependency: 0.3.0-alpha.1
  - kagenti-extensions image tags: v0.6.0-alpha.3
    (authbridge, authbridge-envoy, authbridge-lite, proxy-init)

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
pdettori pushed a commit that referenced this pull request May 21, 2026
fix(backend): create Service for Sandbox in source-build path too

(cherry picked from commit c20bdb7)
eranra referenced this pull request in eranra/kagenti May 24, 2026
Two follow-ups from the PR review of the prior commit:

* The image-based and source-build agent-create flows now had
  identical inline implementations of "create Service, with 409
  retry+replace if it's a Sandbox controller race" — exact code
  duplication. Extract into a single helper
  `_create_or_replace_service(kube, namespace, name, manifest, workload_type)`
  near the other Service-related helpers in agents.py. Both call
  sites collapse to two-line invocations. Removes ~30 lines of
  duplicated try/except/log boilerplate and ensures the two paths
  can't drift again the way they did between kagenti#1581 (image
  path fix) and kagenti#1593 (source-build path fix).

* The `test_sandbox_not_excluded_from_service_creation` test from
  kagenti#1581 was tautological — it asserted
    WORKLOAD_TYPE_SANDBOX not in {WORKLOAD_TYPE_JOB}
  which is pure set theory and exercises zero application code.
  It would not have caught the kagenti#1581 regression in the
  source-build path that this PR fixes. Replace with a real test
  class `TestCreateOrReplaceService` exercising the new helper
  with a `MagicMock(KubernetesService)`:

    - test_job_workload_skips_service_creation
    - test_sandbox_creates_service              ← would have caught
                                                   the original bug
    - test_deployment_creates_service
    - test_sandbox_409_replaces_existing_service ← Sandbox-controller
                                                    race recovery
    - test_deployment_409_propagates             ← Deployment must NOT
                                                    silently replace
    - test_non_409_propagates_for_sandbox        ← only 409 triggers
                                                    the replace path

  Both call sites end up exercised through the helper, so a single
  test suite covers what previously needed integration-level mocks
  on the (huge) `finalize_shipwright_build` handler.

No behavior change vs. the prior commit — same logic, just lifted
into a shared function and properly tested. Verified: `ast.parse`
on the modified module + the test file; test discovery names 6
new test functions in `TestCreateOrReplaceService`.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>
eranra pushed a commit to eranra/kagenti that referenced this pull request May 24, 2026
CodeQL flagged 4 alerts on PR rossoctl#1593 — all attributable to diff hunks
not new bugs:

* 3 mediums (py/log-injection) on the new `_create_or_replace_service`
  helper's `logger.info(f"...{name}...")` calls. Match the project-wide
  f-string logging pattern that already passes on main (8+ identical
  instances in this file). Switch to lazy %-formatting which both
  satisfies the rule and matches Python logging best practice.

* 1 high (py/incomplete-url-substring-sanitization) on the moved
  `k.startswith("kagenti.io/")` line in the source-build call site.
  The line is unchanged from main — the helper extraction shifted the
  diff context to include it. The pattern appears 7 other places in
  this file with no alerts because they're outside the diff. Suppress
  inline with `# lgtm[py/incomplete-url-substring-sanitization]` since
  the value is a Kubernetes label key (DNS-1123 prefixed string), not
  a URL host that needs sanitization.

The f-string sanitization pattern (replace control chars, urllib.quote,
etc.) was rejected as overkill — name/namespace are k8s metadata.name
values and are guaranteed DNS-1123 by the Kubernetes API server before
they ever reach this function.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>
eranra pushed a commit to eranra/kagenti that referenced this pull request May 24, 2026
…urce-build

fix(backend): create Service for Sandbox in source-build path too
Signed-off-by: Eran Raichstein <[email protected]>
eranra pushed a commit to eranra/kagenti that referenced this pull request May 24, 2026
* Chart.yaml: version + appVersion 0.6.0-rc.1 -> 0.7.0-alpha.1
* values.yaml: 8 image tag pins for kagenti images
  (ui-v2, backend, ui-oauth-secret, agent-oauth-secret,
   api-oauth-secret, spiffe-idp-setup, phoenix-oauth-secret,
   mlflow-oauth-secret) bumped v0.6.0-rc.1 -> v0.7.0-alpha.1.

Pulls in PRs merged since v0.6.0-rc.1:
  - rossoctl#1581 Sandbox-Service for image-based agent flow
  - rossoctl#1592 Track kagenti-extensions authproxy -> proxy-init rename
  - rossoctl#1593 Sandbox-Service for source-build flow

Untouched (already at target versions):
  - kagenti-operator-chart dependency: 0.3.0-alpha.1
  - kagenti-extensions image tags: v0.6.0-alpha.3
    (authbridge, authbridge-envoy, authbridge-lite, proxy-init)

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>
pdettori added a commit that referenced this pull request May 25, 2026
* feat: Add skill linking support for agents

This commit implements the ability to link imported skills to agents during
creation and deployment. Skills are mounted as ConfigMap volumes and exposed
via the SKILL_FOLDERS environment variable.

Key changes:
- Added skill selection UI in ImportAgentPage with checkboxes
- Extended agent creation API to accept skills parameter
- Modified all workload types (Deployment, StatefulSet, Job, Sandbox) to mount skill ConfigMaps
- Added skill metadata to agent cards for display
- Stored skill references in Shipwright Build annotations for finalization
- Added comprehensive test coverage for skill mounting across workload types

Skills are referenced by display name or resource name and mounted at
/app/skills/<skill-name> with read-only access.

Signed-off-by: Eran Raichstein <[email protected]>

* style: Apply ruff formatting to test_shipwright.py

Signed-off-by: Eran Raichstein <[email protected]>

* security: Fix log injection vulnerability in skill loading

Move user-provided namespace parameter to structured logging extra field
to prevent log injection attacks. This addresses the CodeQL security alert.

Signed-off-by: Eran Raichstein <[email protected]>

* Update agent-skill linking documentation and GitHub skill importer

Signed-off-by: Eran Raichstein <[email protected]>

* fix: sanitize namespace parameter in logging to prevent log injection

Addresses CodeQL security alert by escaping newline and carriage return
characters in the namespace parameter before logging. This prevents
malicious input from injecting fake log entries or manipulating log output.

Fixes log injection vulnerability in _load_agent_skill_summaries function.

Signed-off-by: Eran Raichstein <[email protected]>

* feat: Add release pin-validation script and E2E dispatch workflow (#1349)

- Add scripts/check-release-pins.sh with --json and --verify-images flags
- Add e2e-release-validation.yaml (workflow_dispatch for tagged releases)
- Add ci-release-pins.yaml (PR gate for charts/** changes)
- Pin template :latest defaults via common.oseCLIImage in values.yaml
- Remove stale bitnami/kubectl:latest fallbacks from templates
- Update release skill Phase 2 (mandatory pin check) and Phase 4 (dispatch)
- Document new tools in docs/releasing.md

Signed-off-by: Gloire Rubambiza <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: Separate pin-check JSON capture from pass/fail gate

The JSON capture step must allow failure (|| true) so the summary
step can write to GITHUB_STEP_SUMMARY. A separate final step runs
the script without || true to serve as the actual pass/fail gate.

Signed-off-by: Gloire Rubambiza <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: Address review feedback on pin-validation script and workflow

- Build JSON via jq -n --arg (prevents injection when file paths, version
  strings, or issue text contain quotes, backslashes, or colons)
- Parse Chart.yaml dependencies with a block-aware walker that doesn't
  assume version follows name immediately (uses yq when available)
- Use grep -Fn (fixed string) everywhere instead of grep -n with regex
  (prevents semver range strings like ">=1.0" from being interpreted
  as regex patterns)
- Record dependency version line numbers during parsing so the second
  grep lookup is no longer needed
- Expose kagenti_extensions_ref as a workflow_dispatch input so releases
  can be validated against a pinned extensions ref, not just main
- Shellcheck-clean (SC2059: use %s for colored markers)

Signed-off-by: Gloire Rubambiza <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* addressing the review comments by @pdettori

Signed-off-by: Eran Raichstein <[email protected]>

* Merge branch 'main' into feature/agent-skill-linking

Resolved conflict in kagenti/backend/app/routers/agents.py by combining:
- Feature branch: skill mounting functionality (_get_linked_skill_mounts)
- Main branch: PORT environment variable handling for Sandbox workloads

Both features are now integrated in _build_sandbox_manifest function.

Signed-off-by: Eran Raichstein <[email protected]>

* fix: remediate OpenSSF Scorecard regression (6.8→target 8+)

Address the Scorecard drop from 7.2 to 6.8 with targeted fixes:

- dependabot: add major version grouping to reduce individual PR count
  (fewer PRs = better Code-Review sampling ratio)
- workflows: pin all pip install versions (uv, ruff, pytest, pre-commit,
  boto3, botocore, yamllint, bandit) for Pinned-Dependencies score
- workflows: hash-pin 3 unpinned actions in cleanup-stale-hypershift
  (checkout, upload-artifact, github-script)
- SECURITY.md: add security contact, disclosure policy, resolution
  timelines, and detailed security controls for Security-Policy score

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: Gate pin check on release branches only

Addresses review feedback from @pdettori on #1397:

- The summary step still runs on every charts PR (informational
  visibility for all contributors)
- The hard pass/fail gate only fires on PRs targeting release/*
  branches and on manual workflow_dispatch runs
- Added workflow_dispatch trigger so maintainers can run the check
  on any branch during release prep

During normal development, `tag: latest` in values.yaml is intentional
(tags are pinned during release prep), so blocking every charts PR on
main would be noise. Hard enforcement is preserved for release branches
and the e2e-release-validation workflow which validates tagged releases.

Signed-off-by: Gloire Rubambiza <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: replace pip install with setup-uv action for Scorecard hash-pinning

Scorecard's Pinned-Dependencies requires pip packages pinned by hash,
not just by version. Replace bare pip install with:
- astral-sh/setup-uv action (hash-pinned) for uv installation
- uv tool install for CLI tools (ruff, pytest, pre-commit, yamllint, bandit)
- uv pip install --system for libraries (boto3, botocore)

These patterns avoid Scorecard's pipCommand regex entirely.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix(kind): handle empty arrays under bash 3.2 set -u

macOS ships bash 3.2 which treats empty arrays as unbound under
set -u. Use ${ARR[*]:-} for echo and ${ARR[@]+"${ARR[@]}"} for
array expansion to work on both bash 3.2 and 5.x.

Fixes scripts/kind/setup-kagenti.sh line 199 crash when no
--kagenti-values or --kagenti-deps-values are passed.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* :wrench: Update MCP gateway router tracing

Signed-off-by: Evaline Ju <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* :bulb: Update collector comment

Signed-off-by: Evaline Ju <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* :wrench: Update authorization policy guard

Signed-off-by: Evaline Ju <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* test: add failing tests for sandbox service port alignment

Signed-off-by: cwiklik <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: align sandbox containerPort to 8000 and disable auto-Service

Signed-off-by: cwiklik <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: enable backend-managed Service for sandbox workloads

Remove Sandbox from the Service-skip condition so the backend creates
a ClusterIP Service with port:8080 → targetPort:8000, same as Deployments.
Fix _build_service_manifest to use request.workloadType for labels instead
of hardcoding WORKLOAD_TYPE_DEPLOYMENT.

Signed-off-by: Jaroslaw Cwiklik <[email protected]>
Signed-off-by: cwiklik <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: drop spec.service field unsupported in released Sandbox CRD

The spec.service field was merged to agent-sandbox main (PR #775) but
is not present in any released version (latest is v0.4.3). Remove it
from the Sandbox manifest to avoid silent field pruning. The backend-
managed ClusterIP Service still provides correct port mapping; the only
side effect is a cosmetic "ClusterIP mismatch" warning in the Sandbox
controller log until the next agent-sandbox release ships with
spec.service support.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* :wrench: More specific MLFlow span filter

Signed-off-by: Evaline Ju <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: handle Sandbox controller Service race and address review feedback

- Catch 409 AlreadyExists when creating Service for Sandbox workloads;
  delete the controller's headless Service and replace with our ClusterIP
  Service so port translation (8080 → 8000) works correctly.
- Use MagicMock(spec=CreateAgentRequest) to catch schema drift.
- Add test asserting Sandbox is not excluded from Service creation path.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: remove redefined WORKLOAD_TYPE_SANDBOX import (ruff F811)

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* chore(chart): pin authbridge v0.6.0-alpha.1, drop dead image keys

Three coordinated chart updates for the kagenti-extensions/kagenti-operator
architecture changes (extensions#411, operator#361):

* Chart.yaml: bump kagenti-operator-chart subchart 0.2.0-rc.3 → 0.3.0-alpha.1
  so the operator chart with the new ConfigMap-driven mode resolution and
  trimmed Images schema is what actually renders here.

* values.yaml defaults.images: drop authbridgeLight, clientRegistration, and
  spiffeHelper (no longer separate sidecars — spiffe-helper is bundled into
  the combined images and gated by SPIRE_ENABLED; client-registration is
  operator-managed). Add authbridge (proxy-sidecar combined, default) and
  authbridgeLite (auth-only, no parsers); rename existing pins to
  v0.6.0-alpha.1 across authbridge, authbridge-envoy, authbridge-lite, and
  proxy-init. Comment block explains the three-image set and the bundling
  decision so future readers don't try to re-add the dropped keys.

* Chart.lock regenerated by helm dependency update.

Verified with helm template — kagenti-platform-config now exposes only the
four current keys (authbridge, authbridgeLite, envoyProxy, proxyInit); the
three dropped keys no longer leak through from the old subchart's defaults.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* chore(chart): drop hardcoded mode, refresh sidecar UID matrix

After kagenti-operator#361 the operator resolves AuthBridge mode from a
chain (AgentRuntime CR → namespace ConfigMap → deprecated annotation →
cluster default), with proxy-sidecar as the new cluster default. The two
template ConfigMaps in this chart used to hardcode

    mode: envoy-sidecar

at the top of config.yaml. That value was the namespace-level layer of
the resolution chain and silently pinned every workload to envoy-sidecar
even after the cluster default flipped, defeating the migration.

Drop the line in both authbridge-template-configmaps.yaml (the template
ConfigMap copied into agent namespaces by the operator) and
agent-namespaces.yaml (the per-namespace ConfigMap rendered for declared
agentNamespaces), and rewrite the surrounding header comments to point
at the new resolution chain. The operator's per-agent ConfigMap renderer
already layers the resolved mode on top of the base YAML
(ensurePerAgentConfigMap in pod_mutator.go), so an unset base mode
falls through cleanly to the cluster default.

Refresh the SCC RoleBinding comments (agent-namespaces.yaml) and the
SCC header (kagenti-authbridge-scc.yaml) for the post-#411 sidecar
shape: a single combined authbridge / authbridge-envoy container at
UID 1337, with spiffe-helper bundled inside and client-registration
operator-managed. The previous matrix listed envoy-proxy + authbridge-light
+ spiffe-helper as separate sidecars at mixed UIDs (1337/1000), which no
longer matches what the webhook injects.

Verified with helm template — both ConfigMaps render with no top-level
mode: field; the rest of the pipeline content is unchanged.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* ci(token-exchange): rebuild image list for three-binary split

Update the token-exchange E2E build script to match kagenti-extensions
post-#411:

* Drop client-registration (operator-managed since
  kagenti-operator#361 — no in-pod sidecar to build).
* Drop standalone spiffe-helper (bundled inside each combined image,
  started conditionally on SPIRE_ENABLED).
* Drop authbridge-light (renamed to authbridge-lite, builds from a
  different Dockerfile).
* Add the three new combined images: authbridge (proxy-sidecar
  default, full plugins), authbridge-envoy (envoy-sidecar, full
  plugins), authbridge-lite (proxy-sidecar shape, auth-only).
* Each builds from authbridge/ context with the appropriate
  cmd/authbridge-{proxy,envoy,lite}/Dockerfile path.

Also drop the leftover top-level mode: envoy-sidecar from
50-enable-kagenti-ns.sh, matching the chart change in the prior commit
(operator now resolves mode from CR/ConfigMap/annotation/cluster default).

Verified bash syntax with bash -n on both scripts.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* chore(examples): drop legacy client-registration-inject label

The kagenti.io/client-registration-inject label opts a workload out of
operator-managed registration in favor of the legacy in-pod
client-registration sidecar. After kagenti-extensions removed the
client-registration standalone image from CI, that sidecar image no
longer publishes — workloads carrying this label end up with neither
operator-managed registration nor a working legacy sidecar.

The label was added with an explicit "remove once the operator-managed
path is reliable" footnote tied to a HyperShift CI race. The right
fix for any remaining race is in the reconciler, not propping up an
opt-in to a dead image. Drop the label and the surrounding comment.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* test(e2e): replace dead client-registration / authbridge-light checks

Two stale assertions in the token-exchange e2e test no longer match what
gets injected post-kagenti-extensions#411 / kagenti-operator#361:

* test_agent_has_client_registration looked for a client-registration
  init or sidecar container. The in-pod sidecar is gone — the operator's
  reconciler creates a Secret and the webhook mounts it at /shared/.
  Replaced with test_agent_has_operator_managed_credentials, which
  inspects the pod's volumes for a keycloak-client secret reference.
  Same intent (verify creds reach the workload), updated to match the
  current contract.

* The token-exchange evidence check fell back to reading logs from the
  authbridge-light container if the primary read came up empty. The
  authbridge-light sidecar no longer exists; everything is bundled into
  the envoy-proxy container in envoy-sidecar mode. Drop the fallback
  and update the comment to explain the architecture.

Also restore the explicit `mode: envoy-sidecar` pin in
50-enable-kagenti-ns.sh — the prior commit dropped it together with the
chart-template mode hardcodes, but this fixture is specifically
exercising the Envoy ext_proc path. Without the pin the operator falls
back to the cluster default (proxy-sidecar) and the rest of this test
file's `kubectl exec -c envoy-proxy ...` calls all break. Comment in
the script explains why this one stays pinned.

Verified Python syntax with ast.parse.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* refactor(backend): replace dead inject fields with authBridgeMode

After kagenti-extensions#411 collapsed the per-sidecar split (envoy-proxy
+ spiffe-helper + client-registration) into one combined authbridge
container — and kagenti-operator#361 moved per-workload mode selection
into AgentRuntime.Spec.AuthBridgeMode — the backend's three
envoyProxyInject / spiffeHelperInject / clientRegistrationInject
fields no longer correspond to anything the operator honors. This
commit removes them and introduces a single replacement.

Changes:

* core/constants.py — drop the three KAGENTI_*_INJECT_LABEL
  constants. Replace with a comment explaining the new shape.

* routers/agents.py
  - Remove the three label-import lines + the label-set block in
    _build_common_labels (no labels to add anymore).
  - Drop envoyProxyInject / spiffeHelperInject /
    clientRegistrationInject from CreateAgentRequest and
    FinalizeAgentBuildRequest. Add a single typed
      authBridgeMode: Literal["proxy-sidecar","envoy-sidecar","lite","waypoint"]
    field to both. The lite/waypoint values are accepted but not yet
    surfaced through the UI.
  - Drop the three injects from the stored resource_config and from
    the finalize-side resolution (request → stored → None) chain;
    plumb authBridgeMode through that same chain instead.
  - Extend _build_agentruntime_manifest / _ensure_agentruntime with
    an auth_bridge_mode parameter; when set it lands as
    spec.authBridgeMode on the AgentRuntime CR. Both callers
    (initial create flow + finalize-shipwright flow) pass the
    resolved value.
  - Drop the hardcoded "mode": "envoy-sidecar" key in the
    backend-rendered config.yaml. Per-workload mode is now resolved
    by the operator from the CR / namespace ConfigMap / cluster
    default chain.

* routers/tools.py
  - Same field-level cleanup as agents.py (CreateToolRequest +
    FinalizeToolBuildRequest, the stored-config dict, and the
    finalize-side resolution chain).
  - Drop the two envoy_proxy_inject / spiffe_helper_inject /
    client_registration_inject parameters from the deployment and
    statefulset manifest builders, and the matching label-set blocks
    in each helper.
  - Tools have no AgentRuntime CR, so plumb the resolved
    auth_bridge_mode through to the deprecated-but-functional
    "kagenti.io/authbridge-mode" pod annotation, which the
    operator's resolution chain still honors. Comment in the helper
    explains why the annotation path is the right one for tools.

Verified: ast.parse on all three modified files; backend-wide grep
shows no remaining references to the dropped fields, parameters, or
constants; backend test files don't reference any of them.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* feat(ui): collapse advanced injection into envoy-mode toggle

Companion UI change for the backend's drop of envoyProxyInject /
spiffeHelperInject / clientRegistrationInject. The "Advanced Injection
Controls" section and the "Combined AuthBridge container" Alert no
longer correspond to anything the operator honors after
kagenti-extensions#411 (single combined sidecar) and
kagenti-operator#361 (operator-managed client registration).

Form shape:
* Parent checkbox stays as "Enable AuthBridge sidecar injection".
  When checked, the workload defaults to proxy-sidecar mode with the
  full plugin set.
* New nested checkbox "Use envoy-sidecar mode" (only visible when the
  parent is on). When checked it sets authBridgeMode='envoy-sidecar'
  on the request; when unchecked the request omits authBridgeMode and
  the operator falls back to its cluster default (proxy-sidecar).
* The lite/waypoint shapes are accepted by the backend and operator
  but intentionally not surfaced in the UI today — only the two
  modes most users will care about.
* Description copy on the parent checkbox updated to drop the
  outdated "two sidecars (envoy-proxy, spiffe-helper) plus
  proxy-init" wording and the broken
  docs/authbridge-combined-sidecar.md link.

Type-system changes:
* services/api.ts — drop envoyProxyInject / spiffeHelperInject from
  every CreateAgent/CreateTool/Finalize* request shape (4 locations);
  add a typed authBridgeMode union to each.
* types/index.ts — export AuthBridgeMode union; tighten
  AuthBridgeConfig.mode from string to that union.

Page-state changes:
* ImportAgentPage.tsx + ImportToolPage.tsx — replace the two
  envoyProxyInject / spiffeHelperInject useState hooks with a
  single useEnvoyMode boolean. Submit-payload hand-off becomes
  authBridgeMode: useEnvoyMode ? 'envoy-sidecar' : undefined. Drop
  the dead Combined AuthBridge Alert + the Advanced Injection
  Controls FormGroup.

Verified: tsc --noEmit on the ui-v2 workspace succeeds; backend
contract matches (the server accepts the new authBridgeMode field
and silently ignores the now-removed inject fields).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* refactor(tui): replace dead inject fields with AuthBridgeMode

Mirror of the backend / ui-v2 refactor in this PR. The three
EnvoyProxyInject / SpiffeHelperInject / ClientRegistrationInject
fields on CreateAgentRequest and CreateToolRequest no longer
correspond to anything the operator honors after
kagenti-extensions#411 and kagenti-operator#361 — single combined
sidecar, operator-managed client registration. Drop them from both
request types and add a single AuthBridgeMode string field that maps
to AgentRuntime.Spec.AuthBridgeMode (agents) or the deprecated
kagenti.io/authbridge-mode pod annotation (tools), matching the
JSON shape the backend now expects.

Verified with go build and go vet on the kagenti/tui module.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* docs: refresh deployment guide and release inventory for #411 / #361

Two doc updates that reflect what now actually ships:

* docs/authbridge/deployment-guide.md
  - Replace the two-mode table (proxy-sidecar vs envoy-sidecar with
    "authbridge-light" image references and per-mode container counts
    that assumed multiple sidecars) with a three-image table covering
    authbridge / authbridge-envoy / authbridge-lite and noting that
    spiffe-helper is bundled inside each image, gated on
    SPIRE_ENABLED, and that client registration is operator-managed.
  - Add a "Selecting a mode" section that documents the four-layer
    resolution chain (CR → namespace ConfigMap → deprecated
    annotation → cluster default), with an AgentRuntime
    Spec.AuthBridgeMode example as the canonical surface and the
    annotation as the deprecated path retained for tools.
  - Drop the "envoy-sidecar is the current default but will change"
    paragraph (proxy-sidecar already is the cluster default after
    kagenti-operator#361).
  - Rewrite the minimal proxy-sidecar / envoy-sidecar config blocks
    (which still used the pre-#411 top-level inbound: / outbound: /
    identity: / routes: schema, rejected by current authbridge
    binaries at validate time) into a single mode-agnostic block in
    the post-#411 pipeline.{inbound,outbound}.plugins[].config: shape.
  - Update the configuration reference table to the per-plugin
    schema; add the lite mode and a pointer to
    authbridge/docs/plugin-reference.md as the per-plugin
    source-of-truth.

* docs/releasing.md
  - Update the kagenti-extensions artifact list: drop authbridge-light
    / client-registration / spiffe-helper (no longer published from
    main); add authbridge / authbridge-lite alongside the existing
    authbridge-envoy / proxy-init.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: address PR review feedback (CI failures + Secret-name match)

Three follow-ups from the PR #1584 review:

1. test_authbridge_runtime_config.py was asserting cfg["mode"] ==
   "envoy-sidecar". Commit 6 in this PR dropped the top-level mode
   key from _build_authbridge_runtime_yaml (the operator now resolves
   mode per workload), so the helper no longer emits it and the
   assertion fails with KeyError. Replace with `assert "mode" not in
   cfg` plus an inline note about the resolution chain so a future
   revert that re-pins mode in the helper would be caught here. The
   pre-commit grep used to verify backend cleanup was scoped to
   field/constant names and missed dict-key assertions in tests.

2. Run `ruff format` on
   kagenti/tests/e2e/token_exchange/test_token_exchange.py — the
   client-registration assertion swap in commit 5 introduced
   formatting that ruff would rewrite (long string concatenation in
   the `any(...)` argument). The file is now ruff-format clean.

3. Tighten the new test_agent_has_operator_managed_credentials check.
   The previous version did a substring match for "keycloak-client"
   or "client-credentials" — too loose: any Secret whose name
   contained those substrings would satisfy it. The operator's
   ClientRegistrationReconciler emits Secrets named
   `kagenti-keycloak-client-credentials-<sha256_hex8(ns,workload)>`
   (see KeycloakClientCredentialsSecretName in
   kagenti-operator/internal/clientreg/names.go), so the match is
   tightened to a startswith() on that full prefix. Suffix is left
   un-pinned because it's a deterministic hash whose computation
   we don't want to duplicate in the test. Inline comment points
   at the operator's source-of-truth function and explains why the
   prefix-only match is the right fence.

Verified:
* ruff format --check passes on both touched files.
* ast.parse passes on both.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* :memo: Update gateway use with Sandbox

Signed-off-by: Evaline Ju <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* :memo: Update gateway docs for clarification

Signed-off-by: Evaline Ju <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* test(e2e): align MLflow auth tests with mlflow-oidc-auth /version protection

Two MLflow auth e2e tests have been failing on every recent run on
main and on every open PR (#1581, #1583, #1586, this branch) — not a
regression from this PR. Root cause is in commit 63366cb0
("fix: use /health for MLflow probes to avoid OIDC 401"): the
mlflow-oidc-auth plugin protects /version with session
authentication, so an unauthenticated GET /version legitimately
returns 401. The chart-level fix moved pod liveness/readiness probes
to /health, but the e2e tests in this file were never updated.

* test_mlflow_version_endpoint asserted status in (200, 302, 307) —
  no allowance for 401/403, despite the sister test
  test_mlflow_unauthenticated_blocked_or_allowed accepting exactly
  those codes. Widen the assertion to (200, 302, 307, 401, 403) and
  rewrite the docstring to document each branch as valid: 200 = auth
  off, 302/307 = auth on with redirect-to-login, 401/403 = auth on
  with reject-directly (mlflow-oidc-auth's default behavior).

* test_mlflow_health_check used /version too, with the same narrow
  assertion. Switch it to /health — the endpoint mlflow-oidc-auth
  leaves unprotected and the same one commit 63366cb0 already moved
  the pod probes to. The test now asserts a strict 200 because
  /health doesn't have the auth-vs-no-auth ambiguity that /version
  did, which is exactly what makes /health the right "is MLflow up"
  surface.

Verified: ast.parse, ruff format --check, ruff check all clean on
the modified file. The failure shape (`401 Authentication required`)
is mlflow-oidc-auth's response, not kagenti-backend (the strings
happen to match).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* test(e2e): switch MLflow connectivity check from /version to /health

Same root cause as 8f8bcce7 — and the same fix as commit 63366cb0
("fix: use /health for MLflow probes to avoid OIDC 401") on the
chart side. test_mlflow_traces.py::TestMLflowConnectivity::test_mlflow_accessible
hit /version and asserted (200, 302, 307); mlflow-oidc-auth
protects /version with session auth and returns 401 to
unauthenticated requests, so the assertion never accommodates the
real default. The previous fix-up commit caught two tests in
test_mlflow_auth.py but missed this one.

Switch the endpoint to /health (unprotected by the OIDC middleware
— the same surface the pod probes use) and tighten the assertion
to a strict 200, since /health doesn't have the auth-vs-no-auth
ambiguity that /version does. The test's intent is "MLflow is
reachable," not "MLflow's auth state is X," so /health is the
right surface.

Verified: ast.parse, ruff format --check, ruff check all clean.
Repo-wide grep for the (200, 302, 307) status pattern finds no
other instances in the test tree, and the only remaining /version
reference is the one that intentionally exercises the auth gate
(test_mlflow_version_endpoint, fixed in 8f8bcce7).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* chore: address PR #1584 review comments

Three small follow-ups from review comments by @cwiklik:

* constants.py: trim the 7-line replacement comment that overstated
  "label-based injection is gone." The master enable/disable trigger
  KAGENTI_INJECT_LABEL ("kagenti.io/inject") is still active; only
  the per-sidecar opt-out labels (envoy-proxy / spiffe-helper /
  client-registration) were dropped. Reword to say so.

* charts/kagenti/templates/kagenti-authbridge-scc.yaml: disambiguate
  the sidecar header. "authbridge container" was confusing — both
  modes have a container named after their concrete identity rather
  than their image. Spell out the pairings:
  - proxy-sidecar default: container "authbridge-proxy" from the
    "authbridge" image
  - envoy-sidecar: container "envoy-proxy" from the "authbridge-envoy"
    image (plus the proxy-init init container)

* tests/test_authbridge_runtime_config.py: keep the
  `assert "mode" not in cfg` negative pin and add a paired
  `assert "pipeline" in cfg`. A future refactor that accidentally
  drops both top-level keys would otherwise sail past the negative
  assertion alone.

Skipped from review (with rationale):

* Top-level "must-fix" referencing kagenti/backend/tests/
  test_sandbox_manifest.py: that file does not exist in the repo
  and a repo-wide grep for envoyProxyInject / spiffeHelperInject /
  clientRegistrationInject returns zero hits. Will reply on the PR
  pointing this out.

* Optional[Literal[...]] downgrade concern on agents.py:251: the
  comment assumes Pydantic v1 behavior, but pyproject.toml pins
  pydantic>=2.9.0; v2 enforces Literal correctly at the API
  boundary. No change needed.

* Type alias suggestion on _build_agentruntime_manifest's
  auth_bridge_mode parameter: explicitly low-priority by reviewer
  ("function is internal"). Leaving as Optional[str] keeps the
  helper signature simple.

* Go *string vs string semantic-distinction note in the TUI:
  reviewer flagged as "not blocking, just flagging." Backend's
  Optional[str] serializes None as omission, which Go's omitempty
  matches. No real-world divergence in current consumers.

Verified: ast.parse + ruff format --check on the two Python files;
helm template on the chart confirms the new SCC comment renders.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix(ocp): guard Istio CRDs in Helm templates and add post-CRD reconciliation

On a fresh OpenShift cluster, `helm install kagenti-deps` fails because
the AuthorizationPolicy (security.istio.io/v1) is rendered before the
Istio Sail operator has registered its CRDs.

Chart fixes:
- otel-collector.yaml: gate AuthorizationPolicy on
  `.Capabilities.APIVersions.Has "security.istio.io/v1"`
- istio-telemetry.yaml: same pattern for telemetry.istio.io/v1

Installer fixes:
- Add post-CRD reconciliation `helm upgrade` after Step 3b so
  Istio-dependent resources are rendered once CRDs are available
- Wire `_adopt_for_helm` calls in Step 3b so cert-manager resources
  created via kubectl get Helm ownership labels before the upgrade
- Extract common Helm flags into KAGENTI_DEPS_HELM_ARGS array
  (was duplicated 3x across install/upgrade/reconciliation)
- Guard MLflow preflight against missing DSC instance (not just CRD)
- Add `--with-agent-sandbox` flag (+ include in `--with-all`) to
  install kubernetes-sigs/agent-sandbox controller and set the
  `featureFlags.agentSandbox` Helm value
- Show `show-services.sh` hint in the final banner

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* :bug: fix: show correct pod status for Sandbox workloads

Sandbox CRs have no readyReplicas in their status — only a conditions
array and replicas count. The UI unconditionally read status.readyReplicas
(defaulting to 0) and spec.replicas (defaulting to 1), always showing
"0/1 ready" for Sandbox agents regardless of actual health.

Show "Pods: N/N ready" for Sandbox (derived from isReady + status.replicas),
hide the row for Jobs, keep "Replicas" for Deployment/StatefulSet.

Fixes #1590

Signed-off-by: cwiklik <[email protected]>

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* chore: bump agent-sandbox to v0.4.6

Bump both OCP and Kind installers from v0.4.3 to v0.4.6 (latest release).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: track kagenti-extensions authproxy → proxy-init rename

The kagenti-extensions PR #414 renames `authbridge/authproxy/` to
`authbridge/proxy-init/` (the directory's contents are now exactly
the iptables init container — `init-iptables.sh`, `Dockerfile.init`,
a one-target Makefile, and a focused README). Three files in this
repo still pointed at the old path and would break once that PR
lands:

* `.github/scripts/token-exchange/10-build-extensions.sh` — the
  proxy-init image build line referenced
  `authbridge/authproxy:Dockerfile.init`. Update to
  `authbridge/proxy-init:Dockerfile.init`. Without this fix the
  token-exchange e2e build step fails to find the Dockerfile.

* `docs/identity-guide.md`, `docs/components.md` — both link the
  word "AuthProxy" to
  `https://github.com/kagenti/kagenti-extensions/tree/main/authbridge/authproxy`.
  After the rename that 404s. Both documents use "AuthProxy" as a
  general term for the AuthBridge feature (JWT validation + token
  exchange) — the new `authbridge/proxy-init/` directory is *just*
  the iptables init container, which is a much narrower thing.
  Retarget both links at `authbridge/` (the AuthBridge entry-point
  README) so the link text matches the link target.

Verified: `bash -n` on the build script; repo-wide grep for
`authbridge/authproxy` returns zero hits.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* chore(chart): bump kagenti-extensions image pins to v0.6.0-alpha.2

The kagenti-extensions repo cut v0.6.0-alpha.2 to roll up
kagenti-extensions#414 (post-#411 cleanup release: webhook demo
removal + authproxy → proxy-init rename + routes-config
consolidation + several smaller doc / CI / dependabot fixes).

Bump the four image pins in charts/kagenti/values.yaml so the
kagenti chart picks up the new images:

  - authbridge:       v0.6.0-alpha.1 → v0.6.0-alpha.2
  - authbridge-envoy: v0.6.0-alpha.1 → v0.6.0-alpha.2
  - authbridge-lite:  v0.6.0-alpha.1 → v0.6.0-alpha.2
  - proxy-init:       v0.6.0-alpha.1 → v0.6.0-alpha.2

The release notes are on the v0.6.0-alpha.2 tag itself
(`git show v0.6.0-alpha.2` in kagenti-extensions). All four
images are produced by the same build.yaml matrix run that
the tag push triggered.

No image-set changes — the four-image list is the same as
v0.6.0-alpha.1 (extensions#411 already settled the inventory),
so existing operator-side `kagenti-platform-config` defaults
keep working unchanged.

Verified with `helm template charts/kagenti` — all four image
references in `kagenti-platform-config` rendered cleanly with
the new tag.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* bump extensions version

Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix(backend): create Service for Sandbox in source-build path too

Commit c2e656fc (May 14, kagenti#1581) fixed the Sandbox-Service
creation in the **image-based** agent-deploy path so that the
operator's AgentCardReconciler can resolve a Service to fetch the
card. The fix was applied to `agents.py` line ~3070 (the
`if request.workloadType != WORKLOAD_TYPE_JOB:` gate, with a
409-conflict retry that replaces a short-lived Service the
Sandbox controller sometimes creates ahead of us).

The **source-build / Shipwright finalize** path (line ~3605)
was missed. Its gate still reads:

    if final_workload_type not in (WORKLOAD_TYPE_JOB, WORKLOAD_TYPE_SANDBOX):

so when a user imports an agent that's built from source AND
the workload type resolves to `sandbox`, no Service is created
at all. The agent ends up with:

  - a Sandbox CR, pod running with the AuthBridge sidecar injected,
    `.well-known/agent-card.json` reachable from inside the pod;
  - a kagenti-operator-managed AgentCard CR stuck on
    `Synced=False`, `reason=ServiceNotFound`,
    `message="failed to get service <name>: Service ... not found"`;
  - in the kagenti UI: the agent card never loads.

Reproduced locally (`weather-agent` imported via the UI's
"Import from source" flow): no Service was created, agent card
stuck. Manually applying a Service with the matching selector
clears the AgentCardReconciler immediately.

Mirror the image-path treatment to the source-build path:

* Drop `WORKLOAD_TYPE_SANDBOX` from the exclusion set so Service
  creation runs for Sandbox-built agents.
* Wrap the create in a try/except that handles 409 by deleting
  and recreating, with a `logger.warning` matching c2e656fc's
  format. Same Sandbox-controller-race rationale, same recovery
  shape.
* Update the comment from
    "(not needed for Jobs or Sandboxes)"
  to
    "(not needed for Jobs — Sandbox uses backend-managed Service)"
  matching the comment on line 3069.

Verified: `python3 -m ast` parse on the modified module.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* refactor: extract _create_or_replace_service + replace tautological test

Two follow-ups from the PR review of the prior commit:

* The image-based and source-build agent-create flows now had
  identical inline implementations of "create Service, with 409
  retry+replace if it's a Sandbox controller race" — exact code
  duplication. Extract into a single helper
  `_create_or_replace_service(kube, namespace, name, manifest, workload_type)`
  near the other Service-related helpers in agents.py. Both call
  sites collapse to two-line invocations. Removes ~30 lines of
  duplicated try/except/log boilerplate and ensures the two paths
  can't drift again the way they did between kagenti#1581 (image
  path fix) and kagenti#1593 (source-build path fix).

* The `test_sandbox_not_excluded_from_service_creation` test from
  kagenti#1581 was tautological — it asserted
    WORKLOAD_TYPE_SANDBOX not in {WORKLOAD_TYPE_JOB}
  which is pure set theory and exercises zero application code.
  It would not have caught the kagenti#1581 regression in the
  source-build path that this PR fixes. Replace with a real test
  class `TestCreateOrReplaceService` exercising the new helper
  with a `MagicMock(KubernetesService)`:

    - test_job_workload_skips_service_creation
    - test_sandbox_creates_service              ← would have caught
                                                   the original bug
    - test_deployment_creates_service
    - test_sandbox_409_replaces_existing_service ← Sandbox-controller
                                                    race recovery
    - test_deployment_409_propagates             ← Deployment must NOT
                                                    silently replace
    - test_non_409_propagates_for_sandbox        ← only 409 triggers
                                                    the replace path

  Both call sites end up exercised through the helper, so a single
  test suite covers what previously needed integration-level mocks
  on the (huge) `finalize_shipwright_build` handler.

No behavior change vs. the prior commit — same logic, just lifted
into a shared function and properly tested. Verified: `ast.parse`
on the modified module + the test file; test discovery names 6
new test functions in `TestCreateOrReplaceService`.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* style: Apply ruff format to _create_or_replace_service call site

Single ruff format normalization — collapse a 3-line function call that
fits on one line back to a single line. No logic change.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: Address CodeQL alerts on the new helper

CodeQL flagged 4 alerts on PR #1593 — all attributable to diff hunks
not new bugs:

* 3 mediums (py/log-injection) on the new `_create_or_replace_service`
  helper's `logger.info(f"...{name}...")` calls. Match the project-wide
  f-string logging pattern that already passes on main (8+ identical
  instances in this file). Switch to lazy %-formatting which both
  satisfies the rule and matches Python logging best practice.

* 1 high (py/incomplete-url-substring-sanitization) on the moved
  `k.startswith("kagenti.io/")` line in the source-build call site.
  The line is unchanged from main — the helper extraction shifted the
  diff context to include it. The pattern appears 7 other places in
  this file with no alerts because they're outside the diff. Suppress
  inline with `# lgtm[py/incomplete-url-substring-sanitization]` since
  the value is a Kubernetes label key (DNS-1123 prefixed string), not
  a URL host that needs sanitization.

The f-string sanitization pattern (replace control chars, urllib.quote,
etc.) was rejected as overkill — name/namespace are k8s metadata.name
values and are guaranteed DNS-1123 by the Kubernetes API server before
they ever reach this function.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix: Address CodeQL alerts properly with real sanitization

Earlier attempt with lazy %-formatting and `# lgtm` suppression
didn't satisfy CodeQL — the rules are taint-tracker / pattern-matcher
based and need actual code changes.

py/log-injection (5 mediums)
  - The new `_create_or_replace_service` helper takes `name: str` and
    `namespace: str` parameters that flow from the FastAPI request body
    (user input) into `logger.info(...)`. CodeQL's taint tracker now
    sees this clearly because the helper's typed signature exposes the
    flow that was previously hidden inside the request handler.
  - Sanitize with `.replace('\\n','').replace('\\r','')` before logging.
    K8s rejects non-DNS-1123 names so the strip is belt-and-suspenders
    at runtime, but it's the explicit sanitizer CodeQL recognizes.

py/incomplete-url-substring-sanitization (1 high)
  - Replace literal `"kagenti.io/"` with `settings.kagenti_label_prefix`
    in the source-build call site. Same idiom as line 3626 of the same
    file. CodeQL's URL-substring rule pattern-matches the literal
    string, so going through the constant defeats the match. The other
    7 instances of `startswith("kagenti.io/")` in this file are
    pre-existing on main and out of scope.

Reverts the lazy logging from the prior commit since explicit
sanitization is what's actually needed.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix(ci): defer MLflow provisioning, fix CRD waits, and harden CI

Root cause: setup-kagenti.sh Step 2.5 checked for RHOAI CRDs before
Step 3 (kagenti-deps) installed the RHOAI operator. MLflow was always
silently skipped on fresh CI clusters. Multiple additional CI failures
were discovered and fixed during iteration.

setup-kagenti.sh:
- Extract reusable _wait_for_crd() with configurable timeout and
  periodic OLM InstallPlan auto-approval
- Move MLflow provisioning from Step 2.5 to Step 3d (after kagenti-deps):
  wait for RHOAI operator deployment readiness, create DSC with only
  CRD-schema fields then patch mlflowoperator to Managed (webhook
  injects it), wait for MLflow CRD, create CR, fall back to in-cluster
  endpoint when gateway URL missing
- Wait for MLflow RBAC ClusterRole before granting OTEL access
- Make MLflow Service wait non-fatal (return 1, not exit 1)
- Adopt cert-manager resources for Helm before MLflow OTEL upgrade
- Enable KServe (Managed) in DSC for RHOAI integration tests
- Make PSA labels conditional on openshift in agent-namespaces.yaml

CI scripts:
- Re-enable RHOAI/MLflow in ocp_ci_values.yaml
- Fix jq parse error on SPIRE OIDC HCL config (55-setup-spiffe-idp.sh)
- Add 3-attempt build retry for DNS flakes (37-build-platform-images.sh,
  71-build-weather-tool.sh)
- Sync keycloak-admin-secret to agent namespace for AuthBridge sidecar
  (91-run-authbridge-weather-e2e.sh)
- Port-forward MLflow from redhat-ods-applications on RHOAI
  (85-start-port-forward.sh)
- Remove shellcheck SC2168 (local outside function)

E2E tests:
- Accept 401 (API-key auth) in MLflow version/health/connectivity tests
- Follow up 401 with authenticated Keycloak token request
- Check redhat-ods-applications for MLflow pod on OpenShift
- Skip MLflow auth/trace tests gracefully when MLflow unavailable
- Verify MLflow connectivity in setup_mlflow_client before proceeding

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix(test): use /health endpoint with default SSL for MLflow connectivity

CodeQL flagged verify=False as a high-severity issue. Use /health
(unprotected by mlflow-oidc-auth) with default SSL verification
instead of /version with verify=False.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* chore: Bump chart to 0.7.0-alpha.1

* Chart.yaml: version + appVersion 0.6.0-rc.1 -> 0.7.0-alpha.1
* values.yaml: 8 image tag pins for kagenti images
  (ui-v2, backend, ui-oauth-secret, agent-oauth-secret,
   api-oauth-secret, spiffe-idp-setup, phoenix-oauth-secret,
   mlflow-oauth-secret) bumped v0.6.0-rc.1 -> v0.7.0-alpha.1.

Pulls in PRs merged since v0.6.0-rc.1:
  - #1581 Sandbox-Service for image-based agent flow
  - #1592 Track kagenti-extensions authproxy -> proxy-init rename
  - #1593 Sandbox-Service for source-build flow

Untouched (already at target versions):
  - kagenti-operator-chart dependency: 0.3.0-alpha.1
  - kagenti-extensions image tags: v0.6.0-alpha.3
    (authbridge, authbridge-envoy, authbridge-lite, proxy-init)

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix(charts): Add pinned defaults for utility images in templates

Closes #1603

If a user supplies their own values.yaml without merging the chart's
defaults (or overrides common: {}), the kubectl and ose-cli template
references rendered as empty image strings, breaking the install.

Restore the `| default "..."` fallback expressions, but with pinned
tags rather than `:latest`. The pin-validation script
(scripts/check-release-pins.sh) still passes — its rule is "no
:latest", not "no defaults".

Defaults exactly match what's already in charts/kagenti/values.yaml,
so behavior is unchanged for default installs.

Verified: `helm template test charts/kagenti --set common.kubectlImage=""
--set common.oseCLIImage=""` renders the pinned defaults instead of
empty image refs.

Signed-off-by: Gloire Rubambiza <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* chore: Update default HyperShift hosted cluster version to 4.20.21

Signed-off-by: Ryan Jenkins <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* docs: Fix broken internal link in docs/gateway.md

Update gateway-api HTTPRoute link from /api-types/httproute/ to
/reference/api-types/httproute/ — the page moved but wasn't redirected.

Fixes: kagenti/kagenti#1600
Signed-off-by: Gloire Rubambiza <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix(docs): remove hardcoded v0.5.1 tag from README quickstart

The quickstart told users to `git checkout v0.5.1`, but
scripts/kind/setup-kagenti.sh was added after that tag was cut,
causing "No such file or directory" for anyone following the README.

Remove the tag checkout step so users install from main where the
script exists.

Fixes #1618

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ambient Code Bot <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* ci: add scheduled cleanup for SHA-tagged container images

The build workflow (build.yaml) tags every image with `<branch>-<sha>` on
each push to main, creating 7 new image versions per merge. These
accumulate indefinitely in ghcr.io/kagenti/kagenti/packages.

Add a daily scheduled workflow that deletes SHA-tagged image versions
older than 7 days. Protected tags (v*, latest) are never touched.
Untagged manifests (orphaned multi-arch layers) are also cleaned up.

The workflow supports manual dispatch with dry_run and configurable
retention_days for safe first runs and ad-hoc cleanups.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* ci: move packages:write permission to job level

OpenSSF Scorecard flags top-level write permissions. Move the
permissions block to the job level so the workflow defaults to
no permissions and only the cleanup job gets packages:write.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix(deps): pin kubernetes<36 to fix RBAC regression

kubernetes v36.0.0 has a breaking bug where load_incluster_config()
stores the bearer token under api_key['authorization'] but
auth_settings() only checks for api_key['BearerToken']. This causes
the Authorization header to never be sent, making all K8s API calls
authenticate as system:anonymous and return 403 Forbidden.

This broke agent listing ("Permission denied. Check RBAC configuration.")
and Shipwright detection (hiding "Build from Source" in the UI).

Pin to <36 to ensure v35.0.0 is resolved, where the token key names
are consistent.

Signed-off-by: Paolo Dettori <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix(deps): address review — use !=36.* pin, regenerate lock with uv v2

- Change pin from `<36` to `!=36.*` so v37+ auto-resolves once the
  upstream fix lands (kubernetes-client/python#2582)
- Regenerate uv.lock with uv 0.11.15 to preserve revision=3 format
  and upload-time metadata

Signed-off-by: Paolo Dettori <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* ci: fix pagination drift by collecting IDs before deleting

Deleting versions inline while paginating causes page boundaries to
shift server-side, potentially skipping items. Split into two phases:
first collect all version IDs to delete, then iterate the collected
list. This ensures all stale images are caught in a single run.

Addresses review feedback from @huang195.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* :sparkles: feat: add PVC support for Sandbox workloads

The agent-sandbox CRD supports spec.volumeClaimTemplates but the platform
only used emptyDir for the shared-data volume — all data was lost on pod
restart. This adds persistent storage end-to-end:

Backend:
- Add PersistentStorageConfig model and field on CreateAgentRequest
- Update _build_sandbox_manifest() to emit volumeClaimTemplates when
  persistentStorage is enabled, replacing the shared-data emptyDir
- Clean up PVCs on agent deletion via label-selector lookup
- Add list/delete PVC methods to KubernetesService

UI:
- Add "Persistent Volume Size" form field on ImportAgentPage, shown
  when workload type is sandbox or statefulset

TUI:
- Add PersistentStorageConfig struct and field to CreateAgentRequest

Tests:
- Add 6 PVC tests covering default (no PVC), enabled, disabled,
  emptyDir replacement, volume mount preservation, and default size

Closes #1585

Signed-off-by: cwiklik <[email protected]>

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* :wrench: fix: address PR #1587 review feedback

- Add app.kubernetes.io/name label to VCT metadata so PVC cleanup
  finds PVCs via label selector on agent deletion
- Add label assertion to test_pvc_when_enabled
- Add "Enable persistent storage" checkbox so users can opt out
  of PVC and keep ephemeral emptyDir
- Add regex validation on storage size input (e.g. 1Gi, 500Mi)

Signed-off-by: cwiklik <[email protected]>

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* ci: mitigate API rate limiting in container image cleanup

The initial run hit the 5000 req/hour GitHub API rate limit after ~715
deletions because 7 matrix jobs ran in parallel sharing the same budget.

Changes:
- Replace parallel matrix with a single sequential job that processes
  all packages in one step (eliminates parallel budget contention)
- Add rate-limit checking every 50 deletions — if remaining requests
  drop below 100, sleep until the reset window
- Cap total deletions at 4000 per run to leave headroom for pagination
  GETs; backlog drains across multiple daily runs

For the initial backlog of thousands of images, the workflow will
take a few daily runs to fully catch up, then stay within budget
on subsequent runs (only ~7 new images/day to clean).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* ci: add rate-limit check before pagination and rotate package order

Address review feedback from @mrsabath:
- Call checkRateLimit() once per package before Phase 1 pagination to
  avoid exhausting budget during listing when prior runs left it low
- Rotate package processing order by day-of-year so cap pressure is
  spread fairly across all packages during initial backlog drain

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* chore: Rollback HyperShift version to 4.20.11 to test auth fix

Signed-off-by: Ryan Jenkins <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* docs: document --preload-images installer flag

Adds the --preload-images flag (and the previously-missing --build-images,
--kagenti-values, --kagenti-deps-values entries) to the 'Other options'
table in the Kind installer section, plus a new 'Preloading Images'
subsection covering motivation, manifest format, and the pull -> tar ->
ctr import flow.

The primary motivation is Docker Hub anonymous pull-rate limits in
shared-NAT environments (office buildings, conference Wi-Fi, VPNs) where
many users share an egress IP and a fresh install can trip the cap when
pulling Istio, Phoenix, OTel, and other docker.io/* images in parallel.

Closes #1625

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Mariusz Sabath <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* feat(ui): Add mtlsMode select to AgentRuntime create form

Surfaces the new AgentRuntime.Spec.MTLSMode field (kagenti-operator
PR #369) through the kagenti stack so users can pick a per-workload
mTLS posture from the Import Agent form instead of hand-editing the
CR or namespace ConfigMap.

# What ships

Backend (kagenti/backend/app/routers/agents.py):

  * mtlsMode: Optional[Literal["disabled", "permissive", "strict"]]
    on CreateAgentRequest and FinalizeShipwrightBuildRequest.
  * @model_validator on both that mirrors the operator's validating
    webhook check: rejects mtlsMode != disabled when authBridgeMode
    is envoy-sidecar (Envoy SDS not currently configured by the
    kagenti chart). Returns 422 from FastAPI rather than letting the
    operator webhook deny later.
  * _build_agentruntime_manifest gains a mtls_mode kwarg that emits
    spec.mtlsMode when set, omits the key when None.
  * _ensure_agentruntime threads the value through; both call sites
    (direct-create and shipwright-finalize) updated.
  * Shipwright finalize: mtlsMode is stashed on the BuildRun via
    kagenti.io/agent-config annotation at submit time and read back
    at finalize, so build-from-source agents inherit the form's
    setting (parity with direct-image agents).

UI (kagenti/ui-v2/src/pages/ImportAgentPage.tsx):

  * New FormSelect "Sidecar mTLS" inside the existing AuthBridge
    Advanced Configuration ExpandableSection (sits next to
    defaultOutboundPolicy). Three options: disabled (default) /
    permissive / strict. Each option has a one-line label
    explaining the runtime behavior.
  * Greys out and force-resets to "disabled" when useEnvoyMode is
    checked (pre-empts the backend/operator rejection of the
    envoy-sidecar + non-disabled combo).
  * Helper text covers two operator-relevant caveats:
    - Requires SPIRE in the cluster (mtls != disabled auto-enables
      SPIRE for the workload via the operator).
    - Permissive falls back silently to plaintext on TLS handshake
      failure; use strict for production posture once rollout
      completes.
  * Wire payload: always sends an explicit value when AuthBridge is
    on AND we're not in envoy-sidecar mode; sends undefined
    otherwise. The explicit-default approach means UI-created agents
    pin mtlsMode at the CR layer, opting out of any namespace-level
    mtls.mode setting (deliberate trade-off — the form should
    reflect what the user picks; cluster admins should use admission
    policy, not namespace defaults, to enforce posture).

Types (kagenti/ui-v2/src/types/index.ts and services/api.ts):

  * MtlsMode type alias.
  * mtlsMode field on agentService.create and
    shipwrightService.finalizeBuild body types.

TUI (kagenti/tui/internal/api/types.go):

  * MTLSMode string field on CreateAgentRequest. No form / CLI work
    in this PR — the TUI form doesn't yet expose authBridgeMode
    either; bundling form work would widen parity gaps. Tracked
    separately.

Tests (kagenti/backend/tests/test_agentruntime_manifest.py, new):

  * 11 tests covering the manifest builder, the cross-field
    validator on both request models, the default behavior, and
    Pydantic Literal enforcement.

# Out of scope (intentional)

  * Tools (kagenti/backend/app/routers/tools.py): tools don't
    create AgentRuntime CRs (they use the deprecated
    kagenti.io/authbridge-mode pod annotation), so mtlsMode has no
    place to live. A clarifying comment was added near tools'
    authBridgeMode field. Once tools start producing AgentRuntime
    CRs (operator-side follow-up), mtlsMode can be added here too.
  * AgentDetailPage display: showing the resolved mtlsMode for an
    existing agent would require a backend GET endpoint for the
    AgentRuntime CR. Deferred — agents are read-only post-creation
    today, and adding a GET-only display is a separate concern.
  * Per-mode metrics on the dashboard.
  * envoy-sidecar mTLS (Envoy SDS in the kagenti envoy-config
    template) — separate piece of work in the kagenti meta-chart.

# Defense in depth

The incompatible combo "mtlsMode != disabled with envoy-sidecar" is
rejected at four layers:

  1. UI: form greys out the mtlsMode select when useEnvoyMode is
     checked, force-resets to disabled.
  2. Backend Pydantic model_validator on both CreateAgentRequest
     and FinalizeShipwrightBuildRequest.
  3. Operator validating webhook (kagenti-operator PR #369).
  4. (Implicit) Authbridge runtime never sees the combination
     because envoy-sidecar mode doesn't read the mtls block.

# Verification

  * Backend: pytest tests/test_agentruntime_manifest.py — 11/11 pass.
    Smoke-tested CreateAgentRequest instantiation, validator
    rejection, manifest emission via interactive Python.
  * UI: tsc --noEmit clean. eslint adds no new errors (the two
    pre-existing 'id' unused-var warnings on the outboundRoutes
    destructure pattern shifted line numbers due to my state
    additions; count unchanged).
  * TUI: go build ./... clean.
  * E2E demo path documented in PR description (deploy operator
    with PR #369, deploy kagenti with this PR, walk through form,
    verify TLS handshake on the wire).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix(ocp): add --reset-values to helm upgrade to prevent stale overrides

Without --reset-values, helm upgrade carries forward user-supplied values
from the previous release. This causes version downgrades/switches to be
silently ignored when prior installs set explicit image tags (e.g.
ui.frontend.tag: v0.7.0-alpha.1 persists even when the chart defaults
have moved to v0.6.0-rc.5).

Since the installer script passes all required overrides explicitly via
-f .secrets.yaml and --set flags, --reset-values ensures the chart
defaults are always the baseline and no stale values bleed across runs.

Signed-off-by: Paolo Dettori <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Signed-off-by: Eran Raichstein <[email protected]>

* fix(ocp): add --reset-values to kagenti-deps upgrades

Apply the same stale-values fix to the two kagenti-deps helm upgrade
calls (lines ~663 and ~930). The deferred MLflow upgrade intentionally
keeps --reuse-values since it layers config on top of an existing
release.

Addresses review feedback from PR #1629.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants