feat: add @constructive-io/infra-secrets — secret resolution bridge#1190
Closed
pyramation wants to merge 1 commit into
Closed
feat: add @constructive-io/infra-secrets — secret resolution bridge#1190pyramation wants to merge 1 commit into
pyramation wants to merge 1 commit into
Conversation
…ith org/global cascade Adds a TypeScript package that resolves function secrets from app_secrets using the infra_public.function_secret_requirements junction table. Resolution cascade: 1. Org-scoped: namespace = database_id 2. Global fallback: namespace = 'default' 3. Strict mode throws SecretResolutionError for missing required secrets Simulates 5 functions from constructive-functions in integration tests: - send_verification_link (SMTP + Mailgun + auth token) - send_email (same profile) - send_email_link (same profile) - simple_email (same profile) - process_file_embedding (OPENAI_API_KEY) 13 integration tests pass covering: - Global-only resolution - Org-scoped override with global fallback - Optional secrets (null when missing) - Strict vs non-strict modes - Database-scoped function definitions
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds
packages/infra-secrets— a TypeScript package that resolves function secrets fromconstructive_store_private.app_secretsusing theinfra_public.function_secret_requirementsjunction table.Resolution cascade:
namespace = database_id(per-tenant override)namespace = 'default'(platform-wide)SecretResolutionErrorif a required (non-optional) secret is missingnullfor unresolved secretsAPI:
resolveSecrets(client, function_id, database_id)→ResolvedSecret[](name, value, source)resolveSecretsMap(client, function_id, database_id)→Record<string, string>(flat map, omits missing)Tests simulate 5 real functions from
constructive-functions/:email:send_verification_link(SMTP_HOST, SMTP_PASSWORD, FROM_EMAIL + optional MAILGUN_*, GRAPHQL_AUTH_TOKEN)email:send_email(same profile)email:send_email_link(same profile)email:simple_email(same profile)embed:process_file_embedding(OPENAI_API_KEY)13 integration tests verify global resolution, org-scoped overrides with fallback, optional secrets, strict/non-strict modes, and database-scoped function definitions.
Review & Testing Checklist for Human
resolveOnecascade logic matches how your app_secrets namespaces are used in production (org = database_id as namespace, global = 'default')app_secrets_getfunction handles decryption transparently (current design relies on the SQL function for decryption)infra_publictable names (function_secret_requirements,secret_definitions) match what's deployed viapackages/infrain constructive-dbNotes
This is the runtime piece for the secret resolution design discussed in constructive-db#1211. The worker (knative-job-worker) would call
resolveSecretsMap()before dispatching to a function, injecting resolved secrets into the HTTP request headers/body.Future work: integrate this into the worker's
doWork()method so secrets flow automatically to Knative functions without env vars.Link to Devin session: https://app.devin.ai/sessions/c0494871633d4beb91f1e16e53c776d1
Requested by: @pyramation