Repository navigation
docs: user-facing documentation under docs/ #18
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
Merged
colinjlacy
merged 2 commits into
runtimeconditions:main
from
lasomethingsomething:docs/user-facing-documentation
Nov 27, 2026
Merged
Changes from all commits
Commits
Show all changes
2 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
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,8 @@ | ||
| # Documentation | ||
|
|
||
| - [Usage: critical-path workflows](./usage.md): publish a profile, correlate it to a Component, report and read fulfillments | ||
| - [Architecture and API reference](./architecture.md): data flow, internals, `POST`/`GET /api/runtime-conditions/fulfillments` | ||
| - [Fulfillment API for adapters](./fulfillment-api.md): backend install, POST/GET contract, validation rules, storage caveat | ||
| - [Releases](./releases.md): how versions and npm publishing work | ||
|
|
||
| Install and ecosystem links live in the [README](../README.md). |
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,91 @@ | ||
| # Architecture and API reference | ||
|
|
||
| ## Data flow | ||
|
|
||
| The adapter only writes. The browser only reads. The store is not a separate actor; it is just the backend plugin's memory. | ||
|
|
||
| ``` | ||
| Adapter ──POST /fulfillments──▶ backend plugin ──▶ in-memory store (append-only) | ||
| ▲ | ||
| Browser ──▶ frontend plugin ────┘── GET /fulfillments?profileName=... | ||
| │ | ||
| └──▶ Kubernetes plugin proxy ──GET /apis/runtimeconditions.io/v1alpha1/runtimeconditionsprofiles | ||
| │ (once per configured cluster) | ||
| ▼ | ||
| profiles matched to the current entity (workload.uri == source-location) | ||
| │ | ||
| ▼ | ||
| one card per cluster; conditions table joined with fulfillments by condition name | ||
| ``` | ||
|
|
||
| ## How the pieces work | ||
|
|
||
| ### Profile fetch | ||
|
|
||
| - File: `src/profiles.ts`, function `fetchAllProfiles` | ||
| - Calls `kubernetesApi.getClusters()` to list configured clusters. | ||
| - Per cluster, calls `kubernetesApi.proxy()` with path `/apis/runtimeconditions.io/v1alpha1/runtimeconditionsprofiles` (the `PROFILES_PATH` constant). | ||
| - Non-OK responses are skipped, so clusters without the CRD installed simply contribute nothing. | ||
| - Returns one `ProfileDeployment` per profile: `{ cluster, profile }`. | ||
|
|
||
| ### Correlation | ||
|
|
||
| - File: `src/profiles.ts`, functions `entitySourceLocationUrl` and `deploymentsForEntity` | ||
| - The Component's `backstage.io/source-location` annotation is parsed with `parseLocationRef`, which strips the `url:` prefix. The result is compared to `profile.workload.uri`. | ||
| - Entities without the annotation match nothing. The tab is hidden for them via `isRuntimeConditionsAvailable`. | ||
| - Matching is by identity (repo URL), not by Kubernetes labels. | ||
|
|
||
| ### Fulfillment store | ||
|
|
||
| - File: `backend/src/router.ts` | ||
| - A plain in-memory array. `POST /fulfillments` validates and appends (returns `201`). `GET /fulfillments` filters by optional `profileName` and `condition` query params. | ||
| - Ephemeral: a backend restart loses all fulfillments. Adapters should treat POST as "report current state" and re-post after a restart. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this is why. We need a durable |
||
| - File: `backend/src/plugin.ts` registers an auth policy with `allow: 'unauthenticated'` for path `/fulfillments`, so adapters can call without a Backstage session. | ||
|
|
||
| ### Rendering | ||
|
|
||
| - File: `src/components/RuntimeConditionsContent.tsx` | ||
| - Extension links: URLs matching `https://runtimeconditions.io/extensions/<ns>/<name>/runtimeconditions.extension.yaml` are rewritten to `https://github.com/runtimeconditions/extensions/blob/main/catalog/rc/<ns>/<ns>-<name>.yaml`. Other URLs are shown as-is. | ||
| - Kubernetes deep links: fulfillments with `provider: "kubernetes"` and a `componentRef` render the reference as a link to `/catalog/<namespace>/<kind>/<name>/kubernetes`. | ||
| - Conditions table columns: Name, Kind, Interface, Optional, "Fulfilled in". The count is the number of distinct environments that reported a fulfillment for the condition; `none` when zero. | ||
| - Expanding a condition row shows a table of every fulfillment resource: Environment, Kind, Provider, Reference (linked as above), Automation. | ||
|
|
||
| ## API reference | ||
|
|
||
| Base path: `/api/runtime-conditions` (backend plugin id `runtime-conditions`). | ||
|
|
||
| ### `POST /fulfillments` | ||
|
|
||
| Registers a fulfillment. Body: | ||
|
|
||
| ```ts | ||
| interface FulfillmentRecord { | ||
| profileName: string; // required | ||
| profileNamespace?: string; // optional | ||
| condition: string; // required; matches profile.conditions[].name | ||
| environment: string; // required, e.g. "dev", "prod", "federal" | ||
| resources: FulfillingResource[]; // required, non-empty | ||
| } | ||
| interface FulfillingResource { | ||
| kind: string; // required, e.g. "CiliumNetworkPolicy" | ||
| provider: string; // required, free-form, e.g. "kubernetes" | ||
| reference: string; // required; unique id in its environment | ||
| componentRef?: string; // optional, e.g. "component:default/inventory-service" | ||
| automation?: { tool: string; reference?: string }; // optional provenance | ||
| } | ||
| ``` | ||
|
|
||
| Responses: | ||
|
|
||
| - `201` with the stored record | ||
| - `400` with an error message if validation fails | ||
|
|
||
| ### `GET /fulfillments?profileName=...&condition=...` | ||
|
|
||
| Returns the array of stored records matching the filters (both optional). Always `200`. | ||
|
|
||
| ## Frontend exports (`src/index.ts`) | ||
|
|
||
| - `runtimeConditionsPlugin`: the plugin object created with `createPlugin`. Id: `runtime-conditions`. It registers one route, `entityContent`, which is the mount point for the entity tab. | ||
| - `EntityRuntimeConditionsContent`: the routable extension rendered inside the tab. Fetches profiles via the Kubernetes API, correlates them to the current entity, and renders one card per matching cluster. | ||
| - `isRuntimeConditionsAvailable(entity)`: route guard for `EntityLayout.Route`. Returns true when the entity has a `backstage.io/source-location` annotation. | ||
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,64 @@ | ||
| # Fulfillment API (for adapters) | ||
|
|
||
| `backend/` ships as `@runtimeconditions/plugin-runtime-conditions-backend`, a companion backend plugin that adapters report fulfillment to. Install it in `packages/backend`: | ||
|
|
||
| ``` | ||
| yarn --cwd packages/backend add @runtimeconditions/plugin-runtime-conditions-backend | ||
| ``` | ||
|
|
||
| ```ts | ||
| backend.add(import('@runtimeconditions/plugin-runtime-conditions-backend')); | ||
| ``` | ||
|
|
||
| The plugin registers an auth policy allowing **unauthenticated** access to `/fulfillments`, because adapters call it without a Backstage user session. Restrict this at your ingress or API gateway if the endpoint should not be public. | ||
|
|
||
| ## Register a fulfillment | ||
|
|
||
| ``` | ||
| POST /api/runtime-conditions/fulfillments | ||
| { | ||
| "profileName": "request-coordinator", | ||
| "condition": "available-stock-capability", | ||
| "environment": "dev", | ||
| "resources": [ | ||
| { | ||
| "kind": "CiliumNetworkPolicy", | ||
| "provider": "kubernetes", | ||
| "reference": "rc-cilium/applications/request-coordinator-egress", | ||
| "componentRef": "component:default/inventory-service", | ||
| "automation": { "tool": "kratix", "reference": "cnp-promise" } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
lasomethingsomething marked this conversation as resolved.
Resolved
|
||
|
|
||
| Validation rules (the backend returns `400` otherwise): | ||
|
|
||
| - Required fields: `profileName`, `condition`, `environment`, and a non-empty `resources` array. | ||
| - Each resource requires `kind`, `provider`, and `reference`. | ||
| - `resources` is always an array, never a single object. One condition is often fulfilled by several resources, e.g. a `CiliumNetworkPolicy` plus a cert-manager `Certificate` for an API condition, or a database plus a `CiliumNetworkPolicy` plus a `Secret` for a datastore condition. | ||
| - `reference` is whatever uniquely identifies the resource in its environment: `cluster/namespace/kind/name` for Kubernetes, an ARN for a cloud resource. | ||
| - `provider` and `automation.tool` are free-form strings, not an enum. The set of platforms and automation tools isn't fixed. | ||
| - `componentRef` and `automation` are optional. When a resource's `provider` is `"kubernetes"` and it carries a `componentRef`, the frontend links its reference to that component's Kubernetes tab in the Kubernetes Backstage plugin. | ||
| - `automation` lives on each resource, not on the fulfillment as a whole. A platform composed of several independent adapters (separate Kratix Promises for network policy, certificates, and secrets) can each POST their own resources for the same condition and environment. Each resource keeps its own automation provenance. | ||
|
|
||
| POSTs are purely additive. Nothing is ever looked up by key and overwritten. Multiple adapters can post to the same profile, condition, and even the same environment concurrently without racing or clobbering each other. Each POST's resources show up alongside whatever else has been reported for that condition. | ||
|
|
||
| ## Read fulfillments | ||
|
|
||
| ``` | ||
| GET /api/runtime-conditions/fulfillments?profileName=request-coordinator | ||
| GET /api/runtime-conditions/fulfillments?profileName=request-coordinator&condition=datastore | ||
| ``` | ||
|
|
||
| Both query params are optional filters. The frontend uses the `profileName` form. | ||
|
|
||
| The conditions table shows how many distinct environments have reported a fulfillment for a condition, even if multiple adapters posted to the same one. Expanding a row shows every environment, resource, and automation tool involved. A condition with no reported fulfillment shows none. It is never inferred. | ||
|
|
||
| ## Example adapter | ||
|
|
||
| See `runtimeconditions/rc-demos`, path `cilium-policy/adapter`, for a working adapter that reports CiliumNetworkPolicy fulfillments. | ||
|
|
||
| ## Storage caveat | ||
|
|
||
| The store is in-memory and ephemeral. A backend restart loses all fulfillments. Treat POST as "report current state" and re-post after a restart. | ||
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,5 @@ | ||
| # Releases | ||
|
|
||
| Merging a `feat`, `fix`, `perf`, `revert`, or breaking change to `main` publishes both packages to npm at the same version, tags the merge commit `vX.Y.Z`, and creates a GitHub release. Other changes, such as docs or CI, do not release. | ||
|
|
||
| Versions follow semantic versioning and come from the PR titles described in [CONTRIBUTING.md](../CONTRIBUTING.md). Publishing uses npm trusted publishing, so no token is stored. `CONTRIBUTING.md` lists the one-time setup. |
Oops, something went wrong.
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.
A plain in-memory array-> This makes me a sad panda. We'll have to address this in the future.