Harden architecture hot paths

This commit is contained in:
gsxdsm
2026-04-12 15:13:27 -07:00
parent 7b78963a4c
commit a34ba41ad1
38 changed files with 1212 additions and 561 deletions

View File

@@ -2970,7 +2970,7 @@ describe("Attachment routes", () => {
expect(res.status).toBe(200);
expect(res.body).toEqual(fakeLogs);
expect(store.getAgentLogs).toHaveBeenCalledWith("KB-001");
expect(store.getAgentLogs).toHaveBeenCalledWith("KB-001", undefined);
});
it("GET /tasks/:id/logs — returns empty array when no logs", async () => {

View File

@@ -2829,7 +2829,12 @@ export function createApiRoutes(store: TaskStore, options?: ServerOptions): Rout
router.get("/tasks/:id/logs", async (req, res) => {
try {
const scopedStore = await getScopedStore(req);
const logs = await scopedStore.getAgentLogs(req.params.id);
const limit = typeof req.query.limit === "string"
? Number.parseInt(req.query.limit, 10)
: undefined;
const logs = await scopedStore.getAgentLogs(req.params.id, limit !== undefined && Number.isFinite(limit)
? { limit }
: undefined);
res.json(logs);
} catch (err: any) {
if (err instanceof ApiError) {