refactor(#6312): promote OIDC audience to shared const - #6315
Conversation
Introduce internal/mintcore/mintconsts package exporting OIDCAudience = "fullsend-mint" as a compile-time constant. This removes the OIDC_AUDIENCE environment variable from the mint server configuration surface. Changes: - Add mintconsts sub-package with OIDCAudience constant and test - Make VerifierFactory niladic (remove audience string param) since verifiers now default to mintconsts.OIDCAudience - Remove OIDC_AUDIENCE reading from NewHandler; handler no longer requires this env var - Update NewJWKSVerifier and NewSTSVerifier to default empty Audience to mintconsts.OIDCAudience - Update all entrypoints (GCF, standalone, WASM) to use niladic verifier factories - mintclient uses mintconsts.OIDCAudience as default audience - CLI --audience flag defaults to mintconsts.OIDCAudience - GCF provisioner uses mintconsts.OIDCAudience for WIF allowedAudiences; stops writing OIDC_AUDIENCE env var - CF provisioner stops defaulting OIDC_AUDIENCE in env vars - Remove OIDC_AUDIENCE from Worker Env TypeScript interface, vitest bindings, and wrangler docs - Create embed copy of mintconsts for GCF bundle; register in embeddedMintFiles - Sync all changed mintcore embed files - Update standalone-mint guide and infrastructure reference to remove OIDC_AUDIENCE documentation - Update tests: remove OIDC_AUDIENCE env setup, replace empty-audience-fails tests with defaults-to-const tests Closes #6312
|
🤖 Finished Review · ✅ Success · Started 11:30 AM UTC · Completed 11:45 AM UTC Commit: |
Site previewPreview: https://7dabe759-site.fullsend-ai.workers.dev Commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Looks good to me Previous runReviewFindingsMedium
Previous run (2)Looks good to me Previous run (3)ReviewFindingsLow
Previous run (4)ReviewFindingsLow
Labels: PR modifies mint subsystem (mintcore, mintclient, mint dispatch, CLI mint commands) and is primarily Go code |
|
/fs-fix #6315 introduced a WASM regression (~1.9 → ~3.0 MB gzip) by replacing the old empty-audience error check with a conditional default: if opts.Audience == "" {
opts.Audience = mintconsts.OIDCAudience
}in NewJWKSVerifier and NewSTSVerifier. Entrypoints (especially cmd/mint-wasm/main.go) then stopped passing Audience, expecting the default to fill it. That if is a soft-migration leftover — it does not match #6312’s intent (“verifiers use mintconsts.OIDCAudience directly”). Root cause: not const vs env. When WASM calls NewJWKSVerifier with compile-time-empty Audience and the constructor takes the default-success path, the generic init graph bloats. Const folding only helps when the compiler sees a non-empty audience at the call site, or when the const is used unconditionally / in Verify() (not via if opts.Audience == ""). Fix (spirit of #6312):
Do not “fix” by only adding Audience: mintconsts.OIDCAudience at the WASM call site while keeping the conditional default — remove the if entirely. |
|
🤖 Finished Fix · ✅ Success · Started 12:26 PM UTC · Completed 12:46 PM UTC Commit: |
Remove Audience field from JWKSVerifierConfig and STSVerifierConfig. Use mintconsts.OIDCAudience unconditionally in constructors instead of a conditional default branch (if opts.Audience == ""). The conditional default prevented the Go compiler from const-folding the audience value at WASM call sites, bloating the binary from ~1.9 MB to ~3.0 MB gzip. - Drop Audience from JWKSVerifierConfig and STSVerifierConfig structs - Set audience/oidcAudience directly to mintconsts.OIDCAudience in NewJWKSVerifier and NewSTSVerifier constructors - Remove all Audience: from config literals in tests - Replace EmptyAudience_DefaultsToConst tests with AudienceIsConst - Sync embed copies for GCF deployment - WASM gzip size verified at ~1.93 MB (within 3 MB Free tier) Addresses review feedback on #6315
🔧 Fix agent — iteration 1 (human-triggered)Addressed all 7 findings from the human instruction. Removed Audience field from JWKSVerifierConfig and STSVerifierConfig, eliminated conditional default branches, used mintconsts.OIDCAudience unconditionally in constructors. Updated all tests and synced GCF embed copies. WASM gzip size verified at ~1.93 MB (was ~3.0 MB with the conditional default). Fixed (7):
Tests: passed Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 12:47 PM UTC · Completed 12:58 PM UTC Commit: |
|
/fs-fix the review comment - make the const a const! |
|
🤖 Finished Fix · ✅ Success · Started 1:05 PM UTC · Completed 1:11 PM UTC Commit: |
Change defaultAudience from var to const since mintconsts.OIDCAudience is an untyped string constant. This preserves compile-time immutability and is safe because no code mutates defaultAudience. Addresses review feedback on #6315
🔧 Fix agent — iteration 2 (human-triggered)Addressed 1 review finding: changed var defaultAudience to const defaultAudience in mintclient.go, preserving compile-time immutability. Fixed (1):
Tests: passedNext steps:
|
|
🤖 Finished Review · ✅ Success · Started 1:12 PM UTC · Completed 1:22 PM UTC Commit: |
|
/fs-fix VerifierFactory is leftover from when NewHandler needed a delayed constructor so it could inject OIDC audience (env / getEnv) into JWKS/STS verifiers. Audience is now mintconsts.OIDCAudience inside the constructors — the factory is a niladic
|
|
🤖 Finished Fix · ✅ Success · Started 1:54 PM UTC · Completed 2:12 PM UTC Commit: |
Remove the VerifierFactory type and change NewHandler to accept an already-constructed OIDCVerifier instead of a factory function. The factory was a leftover from when audience was injected via env/getEnv; now that audience is the compile-time const mintconsts.OIDCAudience inside the verifier constructors, the niladic factory adds indirection without benefit. All load sites (cmd/mint, cmd/mint-wasm, internal/mint GCF) now call NewJWKSVerifier / NewSTSVerifier directly and pass the verifier in. NewHandler rejects a nil verifier the same way it rejects nil getEnv. Embed sync updated. WASM gzip stays ~1.9 MB (under 3 MB). Addresses human review feedback on #6315
🔧 Fix agent — iteration 3 (human-triggered)Addressed all 9 findings from the human instruction: removed VerifierFactory type, changed NewHandler to accept OIDCVerifier directly, updated all 4 load sites and their tests, synced embed files, and verified tests and WASM build pass. docs/contributing/go-code.md still references VerifierFactory pattern (not in scope). Fixed (9):
Tests: passed Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 2:14 PM UTC · Completed 2:24 PM UTC Commit: |
|
/fs-fix Review finding (medium): stale
Grep for other |
|
🤖 Finished Fix · ✅ Success · Started 2:48 PM UTC · Completed 2:53 PM UTC Commit: |
The VerifierFactory type was removed in this PR. Update the WASM binary-size guidance to describe the current pattern: load sites construct a concrete OIDCVerifier (NewJWKSVerifier / NewSTSVerifier) and pass it directly into NewHandler. Audience comes from the mintconsts.OIDCAudience constant inside the constructors. Addresses review feedback on #6315
🔧 Fix agent — iteration 4 (human-triggered)Updated stale VerifierFactory documentation in docs/contributing/go-code.md to reflect the current pattern where load sites construct concrete OIDCVerifier instances and pass them directly to NewHandler. No other VerifierFactory mentions found under docs/. Fixed (1):
Tests: passedNext steps:
|
|
🤖 Finished Review · ✅ Success · Started 2:55 PM UTC · Completed 3:09 PM UTC Commit: |
|
🤖 Finished Retro · ❌ Failure · Started 4:23 PM UTC · Completed 4:23 PM UTC Commit: |
Summary
Introduces
internal/mintcore/mintconstspackage withOIDCAudience = "fullsend-mint"as a compile-time constant, replacingOIDC_AUDIENCEenvironment variable throughout the mint codebase.internal/mintcore/mintconsts/— dependency-free constants package shared by client and serverNewHandlerno longer readsOIDC_AUDIENCE;VerifierFactoryis niladic;NewJWKSVerifier/NewSTSVerifierdefault emptyAudienceto the constantmintclientand CLI--audienceflag both usemintconsts.OIDCAudienceOIDC_AUDIENCEenv var; WIFallowedAudiencesuses the constantOIDC_AUDIENCETesting
internal/mintcore/mintconsts/— unit test verifies constant valueinternal/mintcore/— all tests pass; empty-audience tests converted to default-to-const testsinternal/mint/— GCF wiring test passes withoutOIDC_AUDIENCEenvcmd/mint/— standalone mint tests pass withoutOIDC_AUDIENCEenvinternal/dispatch/gcf/— provisioner tests pass; embed sync test updated for new file countinternal/dispatch/cf/— provisioner tests pass;OIDC_AUDIENCEenv assertion updatedinternal/mintclient/— tests pass with constant-backed defaultCloses #6312
Post-script verification
agent/6312-oidc-audience-const)05416e9141e64a5a46437ea19b8227884c1d2039..HEAD)