-
Notifications
You must be signed in to change notification settings - Fork 25
SPIRE-233, OAPE-880: Add agentic documentation for AI-assisted development #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rausingh-rh
wants to merge
3
commits into
openshift:main
Choose a base branch
from
rausingh-rh:agents-md
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # Zero Trust Workload Identity Manager (ZTWIM) - Agentic Documentation | ||
|
|
||
| **Component**: Zero Trust Workload Identity Manager | ||
| **Repository**: openshift/zero-trust-workload-identity-manager | ||
|
|
||
| > **Retrieval-first**: Before generating code, read the relevant `ai-docs/` files. Start with `domain/` for API types, then `architecture/components.md` for patterns, then `ZTWIM_DEVELOPMENT.md` for workflow. | ||
| > | ||
| > **Generic Platform Patterns**: See Platform documentation (openshift/enhancements/ai-docs/) for operator patterns, testing practices, security guidelines, and cross-repo ADRs. | ||
|
|
||
| ## What is ZTWIM? | ||
|
|
||
| A controller-runtime operator (not library-go) that deploys and manages upstream SPIFFE/SPIRE components on OpenShift 4.18+ so workloads get dynamic, rotatable identities (JWT-SVID / X.509-SVID). GA since v1.0.0; published to `stable-v1` channel via `redhat-operators` CatalogSource. | ||
|
|
||
| **Key Principle**: The operator does not embed upstream code — it manages upstream resources as static YAML manifests (bindata) applied imperatively, deploying upstream container images via `RELATED_IMAGE_*` env vars. | ||
|
|
||
| ## Core Components | ||
|
|
||
| | Controller | Purpose | Key Resources | | ||
| |---|---|---| | ||
| | **ZTWIM** | Status aggregator | Watches all operand CRs + OperatorCondition, syncs Upgradeable to OLM | | ||
| | **SpireServer** | SPIRE server lifecycle | StatefulSet, ConfigMaps, Routes, webhooks, federation, SPIFFE CRs | | ||
| | **SpireAgent** | SPIRE agent lifecycle | DaemonSet, custom SCC, ConfigMap, ClusterRole | | ||
| | **SpiffeCSIDriver** | CSI driver lifecycle | DaemonSet, CSIDriver, privileged SCC RoleBinding | | ||
| | **SpireOIDCDiscoveryProvider** | OIDC discovery | Deployment, Route, ClusterSPIFFEID, ConfigMap | | ||
|
|
||
| **Quick Start**: `oc get zerotrustworkloadidentitymanagers cluster -o yaml` | `oc get spireservers,spireagents,spiffecsidrivers,spireoidcdiscoveryproviders` | ||
|
|
||
| ## Critical Patterns | ||
|
|
||
| **1. Never hand-edit generated files** — `zz_generated.deepcopy.go`, `config/crd/bases/*.yaml`, `pkg/operator/assets/bindata.go`. Use `make generate`, `make manifests`, `make update-bindata`. Run `make verify` before pushing. | ||
|
|
||
| **2. All five ZTWIM-owned CRDs are cluster-scoped singletons named `cluster`** — enforced by CEL XValidation. The three upstream `spire.spiffe.io` CRDs (ClusterSPIFFEID, ClusterFederatedTrustDomain, ClusterStaticEntry) are NOT singletons — see [`ai-docs/domain/upstream-spiffe-crds.md`](ai-docs/domain/upstream-spiffe-crds.md). Controller names use the full prefix: `zero-trust-workload-identity-manager-<component>-controller` (constants in `pkg/controller/utils/constants.go`). | ||
|
|
||
| **3. Operand controllers watch the parent ZTWIM CR** — all four operand controllers watch `ZeroTrustWorkloadIdentityManager` with `ZTWIMSpecChangedPredicate`, and managed resources with component-specific label predicates (`ControllerManagedResourcesForComponent`). The ZTWIM controller does NOT create operand CRs — it only aggregates status. | ||
|
|
||
| **4. Vendor is tracked** — after dependency changes, always `make vendor` and commit the vendor directory. The build uses `-mod=vendor`. | ||
|
|
||
| ## Key Build Commands | ||
|
|
||
| | Command | Purpose | | ||
| |---|---| | ||
| | `make build` | Full build (manifests + generate + fmt + vet + binary) | | ||
| | `make test` | Unit tests with envtest | | ||
| | `make verify` | vet + fmt + golangci-lint | | ||
| | `make manifests generate update-bindata` | Regenerate all generated files | | ||
|
|
||
| ## Documentation Structure | ||
|
|
||
| ```text | ||
| ai-docs/ | ||
| ├── domain/ # CRD type docs (ZTWIM, SpireServer, SpireAgent, etc.) | ||
| │ └── upstream-spiffe-crds.md | ||
| ├── architecture/ # Repo layout, controller table, reconciliation flow | ||
| │ └── components.md | ||
| ├── decisions/ # Component ADRs (controller-runtime choice, bindata) | ||
| │ ├── adr-0001-*.md | ||
| │ └── adr-template.md | ||
| ├── exec-plans/ | ||
| │ └── README.md # Pointer to Platform guidance | ||
| ├── references/ | ||
| │ ├── ecosystem.md # Links to Platform | ||
| │ └── enhancements.md # Enhancement proposals & upstream refs | ||
| ├── ZTWIM_DEVELOPMENT.md # Build, workflow, common tasks, env vars | ||
| └── ZTWIM_TESTING.md # Unit (FakeCustomCtrlClient) + E2E (Ginkgo) | ||
| ``` | ||
|
|
||
| **AI Agent Path**: [`ai-docs/README.md`](ai-docs/README.md) → domain/ → architecture/ → decisions/ → ZTWIM_DEVELOPMENT.md | ||
|
|
||
| **Platform Patterns**: [Operator](https://github.com/openshift/enhancements/tree/master/ai-docs) | [Testing](https://github.com/openshift/enhancements/tree/master/ai-docs) | [Security](https://github.com/openshift/enhancements/tree/master/ai-docs) | ||
|
|
||
| ## Upstream Operands | ||
|
|
||
| | Upstream | Integration | | ||
| |---|---| | ||
| | [spire](https://github.com/spiffe/spire) | Server (StatefulSet), agent (DaemonSet), OIDC (Deployment) images | | ||
| | [spire-controller-manager](https://github.com/spiffe/spire-controller-manager) | Go module dep for API types; sidecar with SPIRE server | | ||
| | [spiffe-csi](https://github.com/spiffe/spiffe-csi) | CSI driver DaemonSet image | | ||
|
|
||
| **Release**: Managed via [zero-trust-workload-identity-manager-release](https://github.com/openshift/zero-trust-workload-identity-manager-release) (Konflux, dual-branch model: `release-*` for images, `main` for FBC catalogs). | ||
|
|
||
| ## External References | ||
|
|
||
| - [SPIFFE Specification](https://github.com/spiffe/spiffe) | [SPIRE Docs](https://spiffe.io/docs/latest/spire-about/) | [OpenShift Docs](https://docs.openshift.com/) | ||
|
|
||
| --- | ||
|
|
||
| **Platform Documentation**: openshift/enhancements/ai-docs/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # ZTWIM Agent Documentation | ||
|
|
||
| Retrieval-first documentation for AI agents and contributors working on the Zero Trust Workload Identity Manager operator. | ||
|
|
||
| > **Start here**: Read [`../AGENTS.md`](../AGENTS.md) for critical patterns and build commands before generating code. | ||
|
|
||
| ## Agent Path | ||
|
|
||
| Follow this order when working on a task: | ||
|
|
||
| 1. **`domain/`** — CRD types, validation rules, field relationships | ||
| 2. **`architecture/components.md`** — controller patterns, reconcile flow, shared utilities | ||
| 3. **`decisions/`** — architectural decisions (controller-runtime, bindata) | ||
| 4. **`ZTWIM_DEVELOPMENT.md`** — build workflow, bootstrap, common tasks | ||
| 5. **`ZTWIM_TESTING.md`** — unit and E2E test patterns (when writing tests) | ||
|
|
||
| ## Documentation Map | ||
|
|
||
| | Document | Purpose | | ||
| |----------|---------| | ||
| | [domain/zero-trust-workload-identity-manager.md](domain/zero-trust-workload-identity-manager.md) | Top-level singleton CR — trust domain, status aggregation | | ||
| | [domain/spire-server.md](domain/spire-server.md) | SPIRE Server CR — CA, persistence, federation, JWT issuer | | ||
| | [domain/spire-agent.md](domain/spire-agent.md) | SPIRE Agent CR — node/workload attestation, socket path | | ||
| | [domain/spiffe-csi-driver.md](domain/spiffe-csi-driver.md) | CSI Driver CR — Workload API socket delivery to pods | | ||
| | [domain/spire-oidc-discovery-provider.md](domain/spire-oidc-discovery-provider.md) | OIDC Discovery Provider CR — JWT-SVID validation for external systems | | ||
| | [domain/shared-types.md](domain/shared-types.md) | CommonConfig, conditions, singleton/immutability patterns | | ||
| | [domain/upstream-spiffe-crds.md](domain/upstream-spiffe-crds.md) | Upstream `spire.spiffe.io` CRDs and ZTWIM vs controller-manager ownership | | ||
| | [architecture/components.md](architecture/components.md) | Repository layout, controllers, reconcile flow, anti-patterns | | ||
| | [decisions/adr-0001-controller-runtime-over-library-go.md](decisions/adr-0001-controller-runtime-over-library-go.md) | Why controller-runtime instead of library-go | | ||
| | [decisions/adr-0002-bindata-for-operand-manifests.md](decisions/adr-0002-bindata-for-operand-manifests.md) | Why go-bindata for static operand manifests | | ||
| | [ZTWIM_DEVELOPMENT.md](ZTWIM_DEVELOPMENT.md) | Build, bootstrap, adding operands/bindata/CRD fields | | ||
| | [ZTWIM_TESTING.md](ZTWIM_TESTING.md) | Unit (FakeCustomCtrlClient) and E2E (Ginkgo) patterns | | ||
| | [references/ecosystem.md](references/ecosystem.md) | Links to Platform operator/testing/security docs | | ||
| | [references/enhancements.md](references/enhancements.md) | OpenShift enhancement proposals and upstream refs | | ||
| | [exec-plans/README.md](exec-plans/README.md) | Multi-step feature execution plans | | ||
|
|
||
| ## Cross-Field Consistency | ||
|
|
||
| These fields must agree across CRs — see linked domain docs for details: | ||
|
|
||
| | Field | CRs | | ||
| |-------|-----| | ||
| | Socket path | [SpireAgent](domain/spire-agent.md) ↔ [SpiffeCSIDriver](domain/spiffe-csi-driver.md) | | ||
| | JWT issuer | [SpireServer](domain/spire-server.md) ↔ [SpireOIDCDiscoveryProvider](domain/spire-oidc-discovery-provider.md) | | ||
| | CSI plugin name | [SpiffeCSIDriver](domain/spiffe-csi-driver.md) ↔ [SpireOIDCDiscoveryProvider](domain/spire-oidc-discovery-provider.md) | | ||
|
|
||
| ## Platform Documentation | ||
|
|
||
| Generic OpenShift operator patterns live in [openshift/enhancements/ai-docs/](https://github.com/openshift/enhancements/tree/master/ai-docs). ZTWIM-specific patterns stay in this directory. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use the required documentation order.
The
Agent Pathplacesdecisions/beforeZTWIM_DEVELOPMENT.md. Movedecisions/afterZTWIM_DEVELOPMENT.mdso agents read the required development workflow before generating code.Proposed order
As per coding guidelines,
**/*: Before generating code, read relevant documentation inai-docs/in this order:domain/,architecture/components.md, thenZTWIM_DEVELOPMENT.md.📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines