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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Superposition ships two integration surfaces:
| Rust | [![Crates.io Version](https://img.shields.io/crates/v/superposition_sdk?color=green&label=superposition_sdk)](https://crates.io/crates/superposition_sdk) | [![Crates.io Version](https://img.shields.io/crates/v/superposition_provider?color=green&label=superposition_provider)](https://crates.io/crates/superposition_provider) |
| JavaScript | [![NPM Version](https://img.shields.io/npm/v/superposition-sdk?color=green&label=superposition-sdk)](https://www.npmjs.com/package/superposition-sdk) | [![NPM Version](https://img.shields.io/npm/v/superposition-provider?color=green&label=superposition-provider)](https://www.npmjs.com/package/superposition-provider) |
| Python | [![PyPI - Version](https://img.shields.io/pypi/v/superposition_sdk?color=green&label=superposition_sdk)](https://pypi.org/project/superposition-sdk/) | [![PyPI - Version](https://img.shields.io/pypi/v/superposition_provider?color=green&label=superposition_provider)](https://pypi.org/project/superposition-provider/) |
| Java | [![Maven Central Version](https://img.shields.io/maven-central/v/io.juspay.superposition/sdk?label=io.juspay.superposition.sdk&color=green)](https://central.sonatype.com/artifact/io.juspay.superposition/sdk) | [![Maven Central Version](https://img.shields.io/maven-central/v/io.juspay.superposition/openfeature-provider?label=io.juspay.superposition.openfeature-provider&color=green)](https://central.sonatype.com/artifact/io.juspay.superposition/openfeature-provider) |
| Java | [![Maven Central Version](https://img.shields.io/maven-central/v/io.juspay.superposition/sdk?label=io.juspay.superposition.sdk&color=green)](https://central.sonatype.com/artifact/io.juspay.superposition/sdk) | [`io.juspay.superposition.openfeature:superposition-provider`](https://juspay.io/superposition/docs/providers/openfeature/java) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I didn't understand the reason for this change

| Haskell | [![Haskell SDK](https://img.shields.io/badge/source-SuperpositionSDK-green)](https://github.com/juspay/superposition/tree/main/clients/haskell/sdk) | [![Haskell Provider](https://img.shields.io/badge/source-superposition--open--feature--provider-green)](https://github.com/juspay/superposition/tree/main/clients/haskell/open-feature-provider) |
| Go | TBD | TBD |

Expand Down
19 changes: 10 additions & 9 deletions docs/docs/applications/cac-redis-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ The `cac_redis_module` extends Redis with custom commands that allow clients to

## Features

- **Context-Aware Configuration**: Resolve configurations based on dynamic context conditions using JSONLogic
- **Context-Aware Configuration**: Resolve configurations based on dynamic context conditions using Superposition's JSONLogic-compatible evaluator
- **Redis Integration**: Access configuration resolution through Redis commands
- **Real-time Configuration**: Load and evaluate configurations from local JSON files
- **Multiple Merge Strategies**: Support for MERGE and REPLACE strategies when applying overrides
- **MERGE Resolution**: `CAC.EVAL` applies selected overrides with the `MERGE` strategy. `REPLACE` exists in the internal evaluator, but is not exposed by the Redis command.
- **Error Handling**: Comprehensive error reporting with timestamps and detailed messages

## Architecture
Expand All @@ -38,12 +38,14 @@ git clone https://github.com/juspay/superposition.git
cd superposition/examples/cac_redis_module
```

2. Build the Redis module:
2. As checked in today, this example is under the repository workspace but is not listed in the root `workspace.members`. Before running Cargo commands from this directory, either add `examples/cac_redis_module` to the root workspace members or make the example an independent workspace by adding an empty `[workspace]` table to `examples/cac_redis_module/Cargo.toml`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lets drop the As checked in today


3. Build the Redis module:
```bash
cargo build --release
```

3. The compiled module will be available at `target/release/libredis_module_cac.so` (Linux) or `target/release/libredis_module_cac.dylib` (macOS).
4. The compiled module is emitted to Cargo's target directory. In a root workspace build, that is typically `<repo>/target/release/libredis_module_cac.so` on Linux or `<repo>/target/release/libredis_module_cac.dylib` on macOS. In a standalone example workspace, the same files are under `target/release/` in the example directory.

### Loading the Module

Expand Down Expand Up @@ -223,7 +225,7 @@ The module provides detailed error messages for various scenarios:
## Performance Considerations

- **File I/O**: Configuration is loaded from disk on each evaluation. For production use, consider caching mechanisms
- **JSON Parsing**: JSONLogic evaluation is performed for each context condition
- **Condition Evaluation**: The Superposition logic helper evaluates each context condition
- **Memory Usage**: Module keeps minimal state; most data is processed per request

## Development
Expand All @@ -234,8 +236,7 @@ The module uses these key dependencies:

- `redis-module`: Redis module SDK for Rust
- `serde_json`: JSON serialization/deserialization
- `jsonlogic`: JSONLogic rule evaluation engine
- `superposition_types`: Superposition's type definitions
- `superposition_types`: Superposition's shared types and condition evaluation helpers

### Extending the Module

Expand Down Expand Up @@ -304,8 +305,8 @@ redis-cli> CAC.EVAL '{"test": "value"}'

- The module reads configuration files from the local filesystem
- No authentication is performed on Redis commands (use Redis AUTH if needed)
- JSONLogic evaluation should be considered when exposing user-controllable context data
- Condition evaluation should be considered when exposing user-controllable context data

## Source Code

The complete source code for this example is available in the [Superposition repository](https://github.com/juspay/superposition/tree/main/examples/cac_redis_module).
The complete source code for this example is available in the [Superposition repository](https://github.com/juspay/superposition/tree/main/examples/cac_redis_module).
37 changes: 19 additions & 18 deletions docs/docs/applications/k8s-staggered-releaser.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Kubernetes Staggered Releaser (Mayday)

A Kubernetes deployment automation tool that leverages Superposition's experimentation features to perform safe, gradual rollouts with automatic traffic management and rollback capabilities.
A Kubernetes deployment automation example that leverages Superposition's experimentation events to perform gradual rollouts with NGINX Ingress traffic management.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we keep the older description? I don't think we use nginx here


## Overview

Expand All @@ -13,7 +13,7 @@ The `k8s-staggered-releaser` (internally named "Mayday") is a webhook-driven dep
- **Automatic Resource Management**: Creates and manages Kubernetes Deployments, Services, and Ingresses
- **Multi-Namespace Support**: Deploy to different Kubernetes namespaces based on context
- **Traffic Management**: Uses NGINX Ingress Controller for weighted traffic distribution
- **Rollback Capability**: Automatic cleanup and rollback when experiments conclude
- **Conclusion Cleanup**: Updates the main Service for the chosen variant and deletes experimental Services and Ingresses when experiments conclude. Deployment deletion is not implemented in the checked-in example.
- **Configuration Integration**: Fetches deployment configurations from Superposition

## Architecture
Expand All @@ -31,7 +31,7 @@ The `k8s-staggered-releaser` (internally named "Mayday") is a webhook-driven dep

1. **Experiment Started**: Creates new Deployment, Service, and Ingress resources
2. **Experiment In Progress**: Updates traffic weights for gradual rollout
3. **Experiment Concluded**: Promotes winning variant and cleans up resources
3. **Experiment Concluded**: Promotes the winning variant by updating the main Service, then deletes experimental Services and Ingresses

## Installation

Expand All @@ -56,12 +56,14 @@ pub const K8S_API_SERVER: &str = "https://your-k8s-api-server:6443";
pub const TOKEN: &str = "your-k8s-api-token";
```

3. Build the application:
3. As checked in today, this example is under the repository workspace but is not listed in the root `workspace.members`. Before running Cargo commands from this directory, either add `examples/k8s-staggered-releaser` to the root workspace members or make the example an independent workspace by adding an empty `[workspace]` table to `examples/k8s-staggered-releaser/Cargo.toml`.

4. Build the application:
```bash
cargo build --release
```

4. Run the webhook server:
5. Run the webhook server:
```bash
cargo run
```
Expand All @@ -70,13 +72,13 @@ The server will start on `127.0.0.1:8090` and listen for webhook events at `/hi`

## Configuration

### Environment Variables
### Source Constants

You can configure the following constants in `src/utils.rs`:
The checked-in example reads these values as constants in `src/utils.rs`, not as environment variables:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not really useful as documentation, the section can just be removed


- `K8S_API_SERVER`: Kubernetes API server URL
- `TOKEN`: Kubernetes API authentication token
- `NAMESPACE`: Default namespace for deployments
- `NAMESPACE`: Declared as `"default"`, but the webhook handlers derive the active namespace from `payload.context` through `get_namespace`

### Superposition Integration

Expand Down Expand Up @@ -186,17 +188,17 @@ Triggered when an experiment ends with a chosen variant:
**Actions Performed:**
- Updates main service to point to winning variant deployment
- Removes experimental Ingress resources
- Cleans up unused Services and Deployments
- Deletes experimental Ingresses and Services. Deployment cleanup is not implemented.

### Configuration Resolution

The system fetches deployment configurations from Superposition using the `/config/resolve` endpoint:

```
GET /config/resolve?namespace={namespace}&variantIds={variant_id}
GET http://localhost:8080/config/resolve?dimension[namespace]={namespace}&dimension[variantIds]={variant_id}
Headers:
x-org-id: localorg
x-tenant: {service_name}
x-tenant: {workspace_id}
```
Comment on lines 197 to 202

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add language specifier to fenced code block.

The code block for the Configuration Resolution request example is missing a language specifier, which violates markdown linting rules (MD040). The content is a plaintext HTTP request, so it should use a language identifier like ```bash or ```text.

🔧 Proposed fix
-```
+```bash
 GET http://localhost:8080/config/resolve?dimension[namespace]={namespace}&dimension[variantIds]={variant_id}
 Headers:
   x-org-id: localorg
   x-tenant: {workspace_id}
-```
+```
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 197-197: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/docs/applications/k8s-staggered-releaser.md` around lines 197 - 202, The
fenced code block containing the Configuration Resolution request example
starting with GET http://localhost:8080/config/resolve is missing a language
specifier, which violates markdown linting rule MD040. Add a language identifier
to the opening triple backticks of this code block by changing the opening fence
from ``` to ```bash or ```text to properly indicate the content type of the HTTP
request example.

Source: Linters/SAST tools


Expected configuration format:
Expand Down Expand Up @@ -235,11 +237,13 @@ metadata:
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-weight: "25"
spec:
ingressClassName: nginx
rules:
- host: nginxservice.mumbai
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginxservice-service-variant-123
Expand Down Expand Up @@ -344,12 +348,7 @@ Common error scenarios and troubleshooting:

### Health Checks

Monitor the webhook endpoint:

```bash
# Basic health check
curl http://127.0.0.1:8090/hi
```
There is no separate health endpoint. The `/hi` route is a GET webhook receiver that expects a JSON request body matching the Superposition event shape.

## Advanced Configuration

Expand All @@ -364,6 +363,8 @@ let app_state = Data::new(AppState {
});
```

The checked-in handler stores this `AppState`, but does not currently validate webhook namespaces or tenants against those lists.

### Custom Resource Templates

Modify resource generation in respective modules:
Expand Down Expand Up @@ -451,4 +452,4 @@ When contributing to this example:

## Source Code

The complete source code for this example is available in the [Superposition repository](https://github.com/juspay/superposition/tree/main/examples/k8s-staggered-releaser).
The complete source code for this example is available in the [Superposition repository](https://github.com/juspay/superposition/tree/main/examples/k8s-staggered-releaser).
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ Two functions that can be linked with default configs to ensure correctness:
- Value Validation
- Value Compute

To learn more about these, check out [functions](./basic-concepts/safety/functions.mdx)
To learn more about these, check out [functions](../safety/functions.mdx)
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Two functions that can be linked with dimensions to ensure correctness:
- Value Validation
- Value Compute

To learn more about these, check out [functions](./basic-concepts/safety/functions.mdx)
To learn more about these, check out [functions](../safety/functions.mdx)

## Cohort Dimensions

Expand Down Expand Up @@ -209,4 +209,4 @@ Use a **Local Cohort** when:
Use a **Remote Cohort** when:
- The grouping logic requires **database lookups** or **external API calls**.
- The logic is too complex for JSONLogic expressions.
- You need the cohort value to be computed fresh on each server-side resolution.
- You need the cohort value to be computed fresh on each server-side resolution.
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ _context_ = { city = "Bangalore" }
per_km_rate = 22.0
```

Interested in writing better config files? Check out [SuperTOML](./docs/superposition-config-file/intro.md)
Interested in writing better config files? Check out [SuperTOML](../../superposition-config-file/intro.md)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: Group experiments to prevent overlap and ensure isolated traffic al

## Introduction

When running multiple experiments, they can overlap with each other due to the cascading nature of [Context-Aware Configs](/docs/basic-concepts/how-all-this-works.mdx). This overlap makes it difficult to predict the final configuration a user receives, as multiple experiments may simultaneously modify the same config keys.
When running multiple experiments, they can overlap with each other due to the cascading nature of [Context-Aware Configs](../context-aware-config/how-all-this-works.mdx). This overlap makes it difficult to predict the final configuration a user receives, as multiple experiments may simultaneously modify the same config keys.

**Experiment Groups** solve this by ensuring experiments within a group never overlap with each other. Each user is assigned to exactly one experiment (or none) within the group, providing predictable and isolated traffic allocation.

Expand Down Expand Up @@ -124,4 +124,4 @@ Group B: context = [environment IS "production"]
## Related Concepts

- [Experiments](/docs/basic-concepts/experimentation/experiments) - Understanding individual experiments
- [Context-Aware Configs](/docs/basic-concepts/context-aware-configs) - The foundation for experimentation
- [Context-Aware Configs](../context-aware-config/how-all-this-works.mdx) - The foundation for experimentation
18 changes: 14 additions & 4 deletions docs/docs/basic-concepts/safety/type-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,19 @@ Type templates are used when defining:

**Example Usage in Default Config:**
```toml
[default-config]
per_km_rate = { "value" = 20.0, "schema" = { "$ref": "#/types/Decimal" } }
user_location = { "value" = {"lat": 0.0, "lng": 0.0}, "schema" = { "$ref": "#/types/GeographicCoordinate" } }
[default-configs]
per_km_rate = { value = 20.0, schema = { type = "number" } }
user_location = {
value = { lat = 0.0, lng = 0.0 },
schema = {
type = "object",
properties = {
lat = { type = "number" },
lng = { type = "number" }
},
required = ["lat", "lng"]
}
}
```

#### Type Template Management
Expand All @@ -103,4 +113,4 @@ Type templates support full lifecycle management:
- **Versioning**: Track changes with audit trail (created_by, last_modified_by, change_reason)
- **Updates**: Modify existing templates with automatic validation
- **Dependencies**: Templates can reference other templates for composition
- **Deletion**: Remove unused templates with dependency checking
- **Deletion**: Remove unused templates with dependency checking
3 changes: 1 addition & 2 deletions docs/docs/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ The following matrix contains the languages in which the above client libraries
| Rust | [![Crates.io Version](https://img.shields.io/crates/v/superposition_sdk?color=green&label=superposition_sdk)](https://crates.io/crates/superposition_sdk) | [![Crates.io Version](https://img.shields.io/crates/v/superposition_provider?color=green&label=superposition_provider)](https://crates.io/crates/superposition_provider) |
| Javascript | [![NPM Version](https://img.shields.io/npm/v/superposition-sdk?color=green&label=superposition-sdk)](https://www.npmjs.com/package/superposition-sdk) | [![NPM Version](https://img.shields.io/npm/v/superposition-provider?color=green&label=superposition-provider)](https://www.npmjs.com/package/superposition-provider) |
| Python | [![PyPI - Version](https://img.shields.io/pypi/v/superposition_sdk?color=green&label=superposition_sdk)](https://pypi.org/project/superposition-sdk/) | [![PyPI - Version](https://img.shields.io/pypi/v/superposition_provider?color=green&label=superposition_provider)](https://pypi.org/project/superposition-provider/) |
| Java | [![Maven Central Version](https://img.shields.io/maven-central/v/io.juspay.superposition/sdk?label=io.juspay.superposition.sdk&color=green)](https://central.sonatype.com/artifact/io.juspay.superposition/sdk) | [![Maven Central Version](https://img.shields.io/maven-central/v/io.juspay.superposition/openfeature-provider?label=io.juspay.superposition.openfeature-provider&color=green)](https://central.sonatype.com/artifact/io.juspay.superposition/openfeature-provider)|
| Java | [![Maven Central Version](https://img.shields.io/maven-central/v/io.juspay.superposition/sdk?label=io.juspay.superposition.sdk&color=green)](https://central.sonatype.com/artifact/io.juspay.superposition/sdk) | [`io.juspay.superposition.openfeature:superposition-provider`](./providers/openfeature/java.md) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we revert this?

| Haskell | ![Static Badge](https://img.shields.io/badge/SDK-Github-8A2BE2?style=flat&logoColor=purple&label=SDK&color=8A2BE2&cacheSeconds=30&link=https%3A%2F%2Fgithub.com%2Fjuspay%2Fsuperposition%2Ftree%2Fmain%2Fclients%2Fhaskell%2Fsdk) | ![Static Badge](https://img.shields.io/badge/SDK-Github-8A2BE2?style=flat&logoColor=purple&label=Provider&color=8A2BE2&cacheSeconds=30&link=https%3A%2F%2Fgithub.com%2Fjuspay%2Fsuperposition%2Ftree%2Fmain%2Fclients%2Fhaskell%2Fopen-feature-provider) |
| Go | TBD | TBD |

Expand Down Expand Up @@ -160,4 +160,3 @@ Superposition comes as a shot in the arm for any application that needs safe and

## Email us
* [superposition@juspay.in](mailto:superposition@juspay.in)

Loading
Loading