Skip to content

feat: production-readiness parity — metering, dashboard, gRPC, quorum, and embedding parity - #20

Open
devin-ai-integration[bot] wants to merge 28 commits into
mainfrom
feature/m11-production-readiness
Open

devin-ai-integration[bot] wants to merge 28 commits into
mainfrom
feature/m11-production-readiness

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Description

Closes the remaining production-readiness backlog for DASH by adding managed-cloud metering, a web dashboard, a gRPC surface, and synchronous multi-region quorum replication:

  • Managed-cloud usage metering: new pkg/usage crate with UsageCounters/UsageSnapshot. Ingestion and retrieval services record per-tenant request/byte counters on every successful ingest/retrieve and expose GET /v1/usage.
  • Operational dashboard: GET /dashboard on the retrieval service serves an HTML dashboard with live health, per-tenant usage, available models, and a retrieve form.
  • gRPC surface: new services/grpc binary exposes dash.v1.Dash with Embed and ListModels methods on DASH_GRPC_BIND (default 127.0.0.1:50051), backed by the shared embedding provider. Generated prost code is committed so protoc is not required at build time.
  • Real semantic embeddings by default: DASH_EMBEDDING_PROVIDER auto-discovers a reachable Ollama endpoint (DASH_OLLAMA_ENDPOINT / OLLAMA_HOST) and falls back to deterministic hash embeddings with a startup warning. All services share a single env-keyed provider cache to avoid repeated TCP probes.
  • OpenAI-compatible /v1/models: retrieval service exposes a model list so OpenAI SDK clients can discover supported model names before calling /v1/embeddings.
  • GET /v1/tenants on ingestion: admin-style collection listing endpoint returning sorted tenant IDs known to the runtime.
  • Multi-region synchronous quorum hardening: POST /v1/ingest with write_consistency=quorum fan-outs POST /internal/replication/ack to follower endpoints configured via DASH_REPLICA_ACK_ENDPOINTS and waits up to DASH_INGEST_QUORUM_TIMEOUT_MS (default 5000ms), returning the real-time ack_count and commit_status.
  • M11 additions already in the branch: CMEK WAL/snapshot encryption wiring, AWS KMS EncryptionProvider, OIDC/RBAC, SOC 2 controls evidence, OpenAPI spec, Helm control-plane deployment, Prometheus/Grafana observability, and multi-region replication primitives.

Type of change

  • New feature
  • Bug fix
  • Breaking change
  • Documentation
  • Refactor / performance

Verification

  • cargo fmt --all --check
  • cargo clippy --workspace --all-features
  • cargo test --workspace --all-features -- --test-threads=1
  • ./scripts/ci.sh
  • cargo doc --workspace --all-features --no-deps
  • cargo audit
  • Relevant SDK tests pass (Python/Go/TypeScript CI)
  • OpenAPI YAML parses cleanly

Checklist

  • Commits are authored by BHAWESHBHASKAR <bhaskarbhawesh09@gmail.com>.
  • CHANGELOG.md and relevant docs updated.
  • Tests added for /v1/usage, /dashboard, /v1/models, /v1/tenants, gRPC, and synchronous quorum fan-out.
  • No secrets, credentials, or placeholder defaults committed.

Link to Devin session: https://app.devin.ai/sessions/ec131330ea0a4a33ab5e7c5fac35e5a2
Requested by: @BHAWESHBHASKAR


Open in Devin Review

- pkg/encryption now exposes encrypt_storage_line/decrypt_storage_line
  helpers that embed the AAD in the encrypted line.
- FileWal and InMemoryStore use the configured EncryptionProvider to
  encrypt WAL/snapshot lines and decrypt on replay. Claim records use
  tenant_id as AAD.
- Ingestion and retrieval services load the encryption provider from
  env (DASH_ENCRYPTION_PROVIDER) and attach it to WAL and store.
- Add AwsKmsProvider behind the aws-kms feature; uses AWS KMS
  GenerateDataKey/Decrypt to unwrap a 256-bit data key, then AES-256-GCM
  locally.
- Update deploy/container/.env.example with KMS env vars.
- Update M11 completion plan to mark CMEK storage integration done.
- Add FileWal encryption round-trip tests.
- Add docs/api/openapi.yaml with all public ingestion, retrieval,
  embeddings, diagnostics, and control-plane endpoints.
- Add docs/api/README.md with curl examples, auth notes, KMS/CMEK notes,
  and SDK generator commands.
- Update production-readiness remediation plan: mark CMEK, control-plane
  HA, quorum replication, disk-first serving, object-storage backup,
  Helm managed-cloud scaffolding, and OpenAPI docs as done.
- Fix select_embedding_provider_from_env() to use the correct Ollama
  /api/embeddings endpoint when DASH_OLLAMA_ENDPOINT is unset and to honor
  an explicit endpoint.
- Add transport_openai_embeddings_uses_ollama_provider_when_configured to
  verify /v1/embeddings calls an HTTP backend when DASH_EMBEDDING_PROVIDER=ollama.
- Add deploy/container/docker-compose.ollama.yml with an ollama service and
  --profile ollama defaults; update .env.example with Ollama/OpenAI vars.
- Document the Ollama overlay in docs/api/README.md.
- Mark M13 (real HTTP embeddings) as done in the remediation plan.
- Update current state: CMEK, OIDC/RBAC, control-plane HA, quorum
  replication, disk-first segments, S3 backup, Helm, OpenAPI, Ollama overlay.
- Update comparison table: RBAC and CMEK rows.
- Update roadmap done/next lists to reflect M11 and M13 completion.
- Add pkg/encryption and metadata-router to architecture overview.
- Add deploy/container/docker-compose.monitoring.yml with Prometheus and
  Grafana services behind the  compose profile.
- Add monitoring/prometheus.yml scraping ingestion:8081 and retrieval:8080.
- Add Grafana provisioning for Prometheus datasource and DASH Overview
  dashboard with request rate, latency, replication lag, error rate, role,
  disk health, queue depth, and segment cache panels.
- Document the overlay and set GRAFANA_ADMIN_PASSWORD in .env.example.
- Update CHANGELOG and docs/api/README.md.
- M11 completion plan: note all sub-milestones implemented in PR #18 and
  update the 'What was added' summary.
- Production-readiness remediation: mark M11 as Done and update status to
  reflect M1–M13 completion.
@BHAWESHBHASKAR BHAWESHBHASKAR self-assigned this Aug 10, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Devin Review found 6 potential issues.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +45 to +54
} else {
let (plaintext, wrapped) = runtime.block_on(generate_data_key(&client, &key_id))?;
let encoded = base64::engine::general_purpose::STANDARD.encode(&wrapped);
std::fs::write(&wrapped_key_file, encoded).map_err(|e| {
EncryptionError::Config(format!(
"failed to write wrapped key to {wrapped_key_file}: {e}"
))
})?;
(plaintext, wrapped)
};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🔴 Data encrypted with AWS-managed keys becomes permanently unreadable after a restart

A brand-new encryption key is created and saved over the old one on every start (generate_data_key at pkg/encryption/src/aws_kms.rs:46-52) because the saved key is never loaded back, so everything written earlier can no longer be read.
Impact: After the first restart of a deployment using AWS KMS encryption, all previously stored data fails to load and is effectively lost.

Wrapped-key file is written but never read on subsequent startups

AwsKmsProvider::new_from_env (pkg/encryption/src/aws_kms.rs:14-66) only takes an existing data key from the DASH_ENCRYPTION_MASTER_KEY environment variable. If that variable is unset, it calls KMS GenerateDataKey, writes the wrapped key to DASH_ENCRYPTION_WRAPPED_KEY_FILE (default .dash-wrapped-key), and uses the fresh plaintext key. Nothing in the crate ever reads that file back (grep shows the path is only written), so the next process start generates yet another key and overwrites the file, discarding the only copy of the key that can decrypt existing WAL/snapshot lines.

Since FileWal/InMemoryStore decryption failures surface as StoreError::Parse, the service exits at startup replay (services/ingestion/src/main.rs:196-202) with all prior data unrecoverable.

Prompt for agents
In pkg/encryption/src/aws_kms.rs, AwsKmsProvider::new_from_env writes the KMS-wrapped data key to DASH_ENCRYPTION_WRAPPED_KEY_FILE (default .dash-wrapped-key) but never reads it back on later startups. Because only DASH_ENCRYPTION_MASTER_KEY is consulted, a restart without that env var generates a fresh data key via KMS GenerateDataKey and overwrites the stored wrapped key, making all WAL/snapshot lines encrypted with the previous key permanently undecryptable. The startup path should, when DASH_ENCRYPTION_MASTER_KEY is unset, first attempt to load and KMS-Decrypt the wrapped key from the file, and only generate (and persist) a new data key when no such file exists. Consider also making an unreadable/corrupt wrapped key file a hard startup error rather than silently regenerating.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread pkg/store/src/wal.rs
Comment on lines +200 to +209
fn record_to_storage_line(&self, record: &PersistedRecord) -> Result<String, StoreError> {
let plaintext = record_to_line(record);
if let Some(provider) = self.encryption.as_ref() {
let aad = Self::aad_for_record(record);
encrypt_storage_line(provider.as_ref(), &plaintext, aad)
.map_err(|e| StoreError::Io(e.to_string()))
} else {
Ok(plaintext)
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🟡 Storage files are rewritten in an encrypted-looking encoded format even when encryption is turned off

Every stored line is wrapped and base64-encoded with an "enc:" marker (encrypt_storage_line at pkg/store/src/wal.rs:200-209) even when no encryption is configured, so unprotected data looks encrypted and grows by roughly a third.
Impact: Default deployments silently change their on-disk log format, files become unreadable to existing tooling and human inspection, and operators can mistake plain data for encrypted data.

NoOp provider is still attached and still goes through the encrypt wrapper

encryption::provider_from_env() returns Arc<NoOpProvider> when DASH_ENCRYPTION_PROVIDER is unset (pkg/encryption/src/lib.rs:106), and both services attach it unconditionally (services/ingestion/src/main.rs:188, services/retrieval/src/main.rs:60). FileWal::record_to_storage_line only checks whether some provider is present, so with the no-op provider each record is emitted as enc:<base64(aad)>:<base64(plaintext)> — the plaintext is merely base64-encoded, yet the line carries the enc: marker used by the new tests to assert "not plaintext" (pkg/store/src/wal.rs:1161-1173). Consequences for the default (encryption-off) configuration: ~33% larger WAL/snapshot files, loss of the previously human/tool-readable tab-separated format, and replication lines that older nodes cannot parse.

Suggested change
fn record_to_storage_line(&self, record: &PersistedRecord) -> Result<String, StoreError> {
let plaintext = record_to_line(record);
if let Some(provider) = self.encryption.as_ref() {
let aad = Self::aad_for_record(record);
encrypt_storage_line(provider.as_ref(), &plaintext, aad)
.map_err(|e| StoreError::Io(e.to_string()))
} else {
Ok(plaintext)
}
}
fn record_to_storage_line(&self, record: &PersistedRecord) -> Result<String, StoreError> {
let plaintext = record_to_line(record);
match self.encryption.as_ref() {
Some(provider) if provider.name() != "none" => {
let aad = Self::aad_for_record(record);
encrypt_storage_line(provider.as_ref(), &plaintext, aad)
.map_err(|e| StoreError::Io(e.to_string()))
}
_ => Ok(plaintext),
}
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread docs/api/openapi.yaml
Comment on lines +220 to +232
/health:
get:
tags: [Diagnostics]
summary: Health check
operationId: ingestionHealth
responses:
'200':
description: Healthy

/v1/health:
get:
tags: [Diagnostics]
summary: Health check

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🟡 API specification silently drops the ingestion and retrieval health, readiness and metrics endpoints

The same endpoint names are declared several times in the new API document (/health, /ready, /live, /metrics, /debug/placement at docs/api/openapi.yaml:220-311), so only the last definition survives and the earlier services' entries disappear.
Impact: Generated client libraries and published API docs are missing or misattribute the ingestion/retrieval diagnostics endpoints, and strict validators reject the document outright.

Duplicate YAML mapping keys under `paths`

paths contains duplicated keys: /health (ingestion line 220, retrieval line 479, control-plane line 560), /v1/health, /live, /v1/live, /ready, /v1/ready, /metrics (lines 278 and 537) and /debug/placement (lines 291 and 550). YAML mappings must have unique keys — strict parsers error, lenient ones keep the last occurrence, so only the control-plane variants of /health//ready and the retrieval variants of /metrics//debug/placement remain. Because each service is on a different server URL, the spec would need per-server path prefixes or separate documents (or distinct paths) to describe all three services.

Prompt for agents
docs/api/openapi.yaml declares the same path keys multiple times under `paths` (/health, /v1/health, /live, /v1/live, /ready, /v1/ready, /metrics, /debug/placement appear once per service). YAML mappings require unique keys, so strict OpenAPI validators/generators fail and lenient ones keep only the last occurrence, dropping the ingestion and retrieval diagnostics operations. Restructure so each service's endpoints are uniquely addressable — e.g. split into per-service spec files, or keep one document with a single set of diagnostics paths documented as common to all three servers.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread pkg/store/src/wal.rs
Comment on lines +193 to +209
fn aad_for_record(record: &PersistedRecord) -> &str {
match record {
PersistedRecord::Claim(claim) => &claim.tenant_id,
_ => "",
}
}

fn record_to_storage_line(&self, record: &PersistedRecord) -> Result<String, StoreError> {
let plaintext = record_to_line(record);
if let Some(provider) = self.encryption.as_ref() {
let aad = Self::aad_for_record(record);
encrypt_storage_line(provider.as_ref(), &plaintext, aad)
.map_err(|e| StoreError::Io(e.to_string()))
} else {
Ok(plaintext)
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🟨 Encrypted storage lines for evidence, edges, vectors and batch commits carry no tenant binding

FileWal::aad_for_record (pkg/store/src/wal.rs:193-198) only supplies the tenant id as additional authenticated data for Claim records; evidence, edges, claim vectors and batch-commit records are encrypted with an empty AAD. Because the AAD is also stored in cleartext next to the ciphertext (encrypt_storage_line in pkg/encryption/src/lib.rs:40-49), an attacker with write access to the WAL/snapshot file can relocate or replay any non-claim ciphertext line to another tenant's record set without the AEAD tag detecting it, defeating the stated goal of binding ciphertext to identity.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread pkg/store/src/wal.rs
Comment on lines +200 to +209
fn record_to_storage_line(&self, record: &PersistedRecord) -> Result<String, StoreError> {
let plaintext = record_to_line(record);
if let Some(provider) = self.encryption.as_ref() {
let aad = Self::aad_for_record(record);
encrypt_storage_line(provider.as_ref(), &plaintext, aad)
.map_err(|e| StoreError::Io(e.to_string()))
} else {
Ok(plaintext)
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🟨 Storage lines look encrypted when encryption is disabled

With DASH_ENCRYPTION_PROVIDER unset, provider_from_env() returns NoOpProvider (pkg/encryption/src/lib.rs:106) and both services still attach it to the WAL and store (services/ingestion/src/main.rs:188, services/retrieval/src/main.rs:60). FileWal::record_to_storage_line therefore emits enc:<base64-aad>:<base64-plaintext> lines for unencrypted deployments, giving files an encrypted appearance while the contents are trivially base64-decodable. Operators (and the new encrypted_wal_file_is_not_plaintext style check) can mistake obfuscation for at-rest encryption.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +45 to +54
} else {
let (plaintext, wrapped) = runtime.block_on(generate_data_key(&client, &key_id))?;
let encoded = base64::engine::general_purpose::STANDARD.encode(&wrapped);
std::fs::write(&wrapped_key_file, encoded).map_err(|e| {
EncryptionError::Config(format!(
"failed to write wrapped key to {wrapped_key_file}: {e}"
))
})?;
(plaintext, wrapped)
};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🟨 KMS-wrapped data key is written to a world-readable file in the working directory by default

When DASH_ENCRYPTION_MASTER_KEY is unset, AwsKmsProvider::new_from_env writes the KMS-wrapped data key to DASH_ENCRYPTION_WRAPPED_KEY_FILE, defaulting to .dash-wrapped-key in the process working directory (pkg/encryption/src/aws_kms.rs:21-52), using std::fs::write with default permissions (typically 0644, subject to umask). The file is created inside the deployment/source tree by default, making accidental inclusion in backups, container images, or version control likely.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

- AWS KMS: load persisted wrapped key on restart, generate only when missing,
  write with 0600 permissions and prefer DASH_PERSISTENCE_PATH.
- WAL encryption: skip enc: wrapper when provider is the no-op provider.
- WAL AAD: bind Evidence, ClaimEdge, ClaimVector and BatchCommit records to the
  claim tenant instead of empty AAD.
- OpenAPI: remove duplicate /health, /ready, /metrics and /debug/placement keys.
- Cargo: disable default rustls features for aws-config/aws-sdk-kms to remove
  rustls-webpki 0.101.7 and satisfy cargo-audit.
select_embedding_provider_from_env() now auto-discovers a local Ollama
daemon via DASH_OLLAMA_ENDPOINT or OLLAMA_HOST and uses it when no
DASH_EMBEDDING_PROVIDER is set. Falls back to hash with a startup warning
so deployments get real semantic vectors out-of-the-box while tests remain
deterministic. Added unit tests for default, explicit, and OLLAMA_HOST paths.
Add embeddings::shared_embedding_provider() and switch ingestion/
retrieval services to use it. The provider is cached by the current
embedding-related env vars, so production avoids repeated Ollama probes
while tests can still switch providers between env changes.
Exposes GET /v1/models on the retrieval service with a wire-compatible
OpenAI model list. The list advertises the embedding model names that
can be passed to POST /v1/embeddings, making DASH a more complete
drop-in replacement for OpenAI SDK clients. Added handler + transport
test, OpenAPI schema, and docs update.
Adds the first admin-style collection listing API. IngestionRuntime
gains a tenant_ids() helper that returns sorted tenant IDs from the
in-memory store; read_routes exposes them at GET /v1/tenants with a
405 for other methods. Includes tests, OpenAPI path, and README example.
Adds a new `pkg/usage` crate with `UsageCounters` and `UsageSnapshot`,
records per-tenant request/byte counters on every successful ingest,
retrieve, and embedding call, and exposes `GET /v1/usage` on both
ingestion and retrieval. OpenAPI spec, docs, and tests included.
Serves an HTML operational dashboard from the retrieval service with
live health, per-tenant usage, embedding models, and a retrieve form.
Includes OpenAPI path, docs, and tests.
Adds `services/grpc` binary exposing `dash.v1.Dash` with `Embed` and
`ListModels` methods, backed by the shared embedding provider. Generated
prost code is committed so `protoc` is not required at build time.

Also serves an HTML operational dashboard at `GET /dashboard` on the
retrieval service. Includes OpenAPI, docs, and tests.
@devin-ai-integration devin-ai-integration Bot changed the title feat: M11 follow-up — CMEK storage wiring, AWS KMS, OpenAPI, observability feat: M11 follow-up — managed-cloud metering, gRPC, dashboard, and embedding parity Aug 10, 2026
After a leader ingest with write_consistency=quorum/all, the ingestion
service fans out POST /internal/replication/ack to follower endpoints
configured via DASH_REPLICA_ACK_ENDPOINTS and waits up to
DASH_INGEST_QUORUM_TIMEOUT_MS before returning, updating the real-time
ack_count and commit_status. Adds timeout-aware replication HTTP client,
tests, docs, and CHANGELOG.
@devin-ai-integration devin-ai-integration Bot changed the title feat: M11 follow-up — managed-cloud metering, gRPC, dashboard, and embedding parity feat: production-readiness parity — metering, dashboard, gRPC, quorum, and embedding parity Aug 10, 2026
let epoch = ack_epoch.unwrap_or(0);
let (tx, rx) = std::sync::mpsc::channel();
let start = std::time::Instant::now();
for (node_id, base_url) in endpoints {
let epoch = ack_epoch.unwrap_or(0);
let (tx, rx) = std::sync::mpsc::channel();
let start = std::time::Instant::now();
for (node_id, base_url) in endpoints {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants