Multiplayer agent harness for work.
Mark deployment credentials on lookup so decision providers and skill-pack auth refuse them, and warn about shadowed stored rows
Josh Franceb6e7dc6a6f02
diff --git a/src/core/orchestrator.ts b/src/core/orchestrator.tsindex fe1ca7790..228bdcee0 100644--- a/src/core/orchestrator.ts+++ b/src/core/orchestrator.ts@@ -1548,10 +1548,8 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {perf.credsMs += Date.now() - credsStart;// Service credentials: one read of the org's credential list and one grant scan feed both// the env-delivery gate (below) and the broker token mint (further down). Same grants gate both.- // Deployment-supplied credentials carry an implicit org-wide grant: every participant must- // be entitled to the org, exactly as an org grantee row would require.- const grantedServiceCredSlugs = async (records: readonly PublicServiceCredential[]): Promise<Set<string>> => {- const granted = new Set(+ const aclGrantedServiceCredSlugs = async (): Promise<Set<string>> =>+ new Set((await deps.acl.grantsOfKind("service-cred",@@ -1562,12 +1560,14 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {)).map((g) => parseRef(g.ref).id),);- const orgWide =- conversation.audience.length > 0 &&- conversation.audience.every((p) =>- principalEntitledToScope(p, resolution.orgScopeId, scopeId, resolution.orgScopeId),- );- if (orgWide) for (const record of records) if (record.source === "deployment") granted.add(record.slug);+ const orgWideAudience =+ conversation.audience.length > 0 &&+ conversation.audience.every((p) =>+ principalEntitledToScope(p, resolution.orgScopeId, scopeId, resolution.orgScopeId),+ );+ const grantedServiceCredSlugs = async (records: readonly PublicServiceCredential[]): Promise<Set<string>> => {+ const granted = await aclGrantedServiceCredSlugs();+ if (orgWideAudience) for (const record of records) if (record.source === "deployment") granted.add(record.slug);return granted;};let serviceCredRecords: PublicServiceCredential[] = [];@@ -1580,8 +1580,13 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {}const authorizeServiceCredential = async (slug: string): Promise<void> => {if (!serviceAllowed(slug)) throw new Error("Service is not approved for external Slack.");- const records = (await deps.serviceCreds?.listServiceCredentials(resolution.orgScopeId)) ?? [];- if (!(await grantedServiceCredSlugs(records)).has(slug)) {+ if ((await aclGrantedServiceCredSlugs()).has(slug)) return;+ const supplied =+ orgWideAudience &&+ ((await deps.serviceCreds?.listServiceCredentials(resolution.orgScopeId)) ?? []).some(+ (record) => record.slug === slug && record.source === "deployment",+ );+ if (!supplied) {throw new Error(`Service credential is no longer authorized: ${slug}`);}};diff --git a/src/wiring.ts b/src/wiring.tsindex bcb1d911f..e0d50b77b 100644--- a/src/wiring.ts+++ b/src/wiring.ts@@ -1312,12 +1312,23 @@ export function buildApp(// every other personal credential.const userModelCredentials = createUserModelCredentialStore({ keychain: credentialStore });const keychain: Keychain | undefined = keychainKeyMaterial ? credentialStore : undefined;- const deploymentBrokerSlugs = new Set((config.brokerCredentials ?? []).map((c) => c.slug));const serviceCreds = withDeploymentCredentials(credentialStore,scopeId("org", config.orgId),config.brokerCredentials ?? [],);+ if (config.brokerCredentials?.length) {+ const reserved = new Set(config.brokerCredentials.map((c) => c.slug));+ void credentialStore.listServiceCredentials(scopeId("org", config.orgId)).then(+ (stored) => {+ const shadowed = stored.filter((c) => reserved.has(c.slug)).map((c) => c.slug);+ if (shadowed.length)+ console.warn(`[broker-credentials] BROKER_CREDENTIALS overrides stored credentials: ${shadowed.join(", ")}`);+ },+ (error) =>+ console.warn(`[broker-credentials] could not check for overridden stored credentials: ${errMessage(error)}`),+ );+ }const mcpToolService = createMcpToolService({servers: mcpServers,audit: auditLog,@@ -1507,9 +1518,12 @@ export function buildApp(}: {}),credential: async (slug) => {- if (deploymentBrokerSlugs.has(slug)) return null;- const rec = await keychain?.getServiceCredentialSecret(scopeId("org", config.orgId), slug);- return rec ? { host: rec.host, enabled: rec.enabled, header: brokerCredentialAuthHeader(rec) } : null;+ const rec = keychain+ ? await serviceCreds.getServiceCredentialSecret(scopeId("org", config.orgId), slug)+ : null;+ return rec && rec.source !== "deployment"+ ? { host: rec.host, enabled: rec.enabled, header: brokerCredentialAuthHeader(rec) }+ : null;},}),auditLog,@@ -2155,7 +2169,7 @@ export function buildApp({serviceCredential: async (slug) => {const record = await serviceCreds.getServiceCredentialSecret(scopeId("org", config.orgId), slug);- return record && record.delivery !== "env" ? record : undefined;+ return record && record.delivery !== "env" && record.source !== "deployment" ? record : undefined;},connectorToken: async (host, principalId) =>(await keychain.connectorAccessToken(host, principalId)) ?? undefined,