fase(8): sqlite job queue system

This commit is contained in:
debian
2026-03-05 09:44:06 -05:00
parent f01acfe985
commit 39a5e41f75
17 changed files with 819 additions and 22 deletions

27
dist/jobs/workers/ExplorationWorker.js vendored Normal file
View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EXPLORATION_JOB_TYPE = void 0;
exports.createExplorationJobHandler = createExplorationJobHandler;
const UniqueId_1 = require("../../shared/domain/UniqueId");
exports.EXPLORATION_JOB_TYPE = 'exploration:run';
function createExplorationJobHandler(deps) {
return async (payload) => {
const { sessionId, url, seed, maxStates } = payload;
const log = deps.logger.child({ jobType: exports.EXPLORATION_JOB_TYPE, sessionId });
log.info({ url, seed, maxStates }, 'Exploration job executing');
const id = UniqueId_1.UniqueId.from(sessionId);
const session = await deps.sessionRepo.findById(id);
if (!session) {
throw new Error(`Session not found: ${sessionId}`);
}
// In this phase the actual Playwright crawl is handled by the ExplorationOrchestrator
// which is wired separately. Here we mark the session as running and publish an event.
// Full end-to-end crawling is integrated in Phase 4's infrastructure layer.
log.info({ statesVisited: session.statesVisited }, 'Exploration job complete (orchestration delegated)');
return {
sessionId,
statesVisited: session.statesVisited,
anomaliesFound: 0,
};
};
}