Files
shannon/apps/worker/src/services/agent-git-paths.ts
T
ezl-keygraph ed5659e2e2 fix(report): emit SARIF by default for exploit runs (#431)
* fix(report): emit SARIF by default for exploit runs, opt out with report.sarif: false

* docs: describe SARIF as on-by-default for exploit runs
2026-08-26 19:25:16 +05:30

40 lines
1.6 KiB
TypeScript

// Copyright (C) 2025 Keygraph, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License version 3
// as published by the Free Software Foundation.
/**
* Per-agent git path scoping.
*
* Under parallel agent execution the deliverables git is shared, so each agent's
* checkpoint/commit/rollback must be limited to the files that agent actually
* writes. This resolves those paths from the agent's deliverable filename plus
* its structured exploitation queue (vuln agents only).
*/
import { getQueueFilename } from '../ai/queue-schemas.js';
import { REPORT_JSON_FILENAME, SARIF_FILENAME } from '../paths.js';
import { AGENTS } from '../session-manager.js';
import type { AgentName } from '../types/agents.js';
/**
* Deliverable files an agent writes into the deliverables directory. Used to
* scope git operations so one agent never touches a sibling agent's output.
*/
export function getAgentGitPaths(agentName: AgentName): string[] {
const paths = [AGENTS[agentName].deliverableFilename];
const queueFilename = getQueueFilename(agentName);
if (queueFilename) {
paths.push(queueFilename);
}
// The report agent also emits the structured findings the markdown is rendered from, and the
// SARIF log when produced. Listing the log unconditionally is harmless when it was not written,
// and keeps a stale one from surviving the rollback of a failed attempt.
if (agentName === 'report') {
paths.push(REPORT_JSON_FILENAME);
paths.push(SARIF_FILENAME);
}
return [...new Set(paths)];
}