T-7: M0.3a — Harden dev Mongo safety: env-safety throws on unsafe data-pipeline QA reads, scheduled jobs default off, read-only bypass tests

This commit is contained in:
Studio 2026-11-27 01:54:00 -05:00
parent abbab4b5a8
commit 0e5ebbd62f
9 changed files with 425 additions and 29 deletions

View file

@ -36,6 +36,7 @@ export class QueueManager {
private redisConnection: ReturnType<typeof getRedisConnection>;
private ioredisConnection?: Redis;
private lifecycle: 'running' | 'draining' | 'closed' = 'running';
private workersStarted = false;
private shutdownPromise: Promise<void> | null = null;
private config: QueueManagerConfig;
private readonly logger: Logger;
@ -154,11 +155,13 @@ export class QueueManager {
const workers = mergedOptions.workers ?? this.config.defaultQueueOptions?.workers ?? 1;
const concurrency =
mergedOptions.concurrency ?? this.config.defaultQueueOptions?.concurrency ?? 1;
const shouldStartWorker =
workers > 0 && (!this.config.delayWorkerStart || this.workersStarted);
const queueConfig: QueueWorkerConfig = {
workers,
concurrency,
startWorker: workers > 0,
startWorker: shouldStartWorker,
handlerRegistry: options.handlerRegistry || this.handlerRegistry,
serviceName: this.config.serviceName,
queueManager: this,
@ -183,7 +186,7 @@ export class QueueManager {
workers: workers,
concurrency: concurrency,
handlerRegistryProvided: !!this.handlerRegistry,
willStartWorkers: workers > 0,
willStartWorkers: shouldStartWorker,
isOwnQueue,
serviceName: this.serviceName,
});
@ -519,8 +522,12 @@ export class QueueManager {
if (this.lifecycle !== 'running') {
throw new Error('QueueManager is shutting down; workers cannot be started');
}
this.workersStarted = true;
let workersStarted = 0;
const queues = this.queues;
const normalizedService = this.serviceName
? normalizeServiceName(this.serviceName)
: undefined;
this.logger.info(
`Starting workers for ${queues.size} queues: ${Array.from(queues.keys()).join(', ')} (service: ${this.serviceName})`
@ -531,7 +538,7 @@ export class QueueManager {
if (this.serviceName) {
const parsed = parseQueueName(queueName);
// Skip if not our service's queue
if (parsed && parsed.service !== this.serviceName) {
if (parsed && parsed.service !== this.serviceName && parsed.service !== normalizedService) {
this.logger.trace('Skipping workers for cross-service queue', {
queueName,
ownerService: parsed.service,