Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
Use Codex Security for Codex audit agents
Adam Eivyeff6a7e6972c
diff --git a/docs/features/self-improvement-audits.md b/docs/features/self-improvement-audits.mdindex de59080a6a..4689f5074d 100644--- a/docs/features/self-improvement-audits.md+++ b/docs/features/self-improvement-audits.md@@ -19,6 +19,29 @@ Registry: `server/lib/auditCatalog.js` (what each lane is and how it files),`server/services/taskScheduleRegistry.js` (cadence and posture),`server/services/taskPromptDefaults/prompts.js` (the mission bodies).+## Codex security scans++When a `security` task runs through a Codex CLI/TUI provider, dispatch adds a+Codex Security runtime contract, including for customized or previously queued+missions. Selection follows the provider executable (with the shipped provider+id as a fallback), rather than the model name. Other providers and the separate+local-inference-only private assessment keep their existing workflows.++The agent uses an available Codex Security scanner or the official+[`@openai/codex-security` CLI](https://learn.chatgpt.com/docs/security/cli) in+report-only, unattended mode, with private artifacts outside the checkout.+Existing authentication, configured model/effort, quota and spending limits+still apply. This routing does not install a hook, patch code, create a PR,+publish findings, or authorize a different provider account. The audit's+file-issues/remediation contract remains responsible for delivery.++Unavailable access or a refused action must be recorded without interactive+login or repeated attempts through another tool. The agent preserves completed+evidence, continues independently permitted review, delivers supported findings,+and writes the usual quality assessment and completion sentinel. Scanner+coverage and unresolved areas remain evidence to inspect, not a clean bill of+health for the repository.+## The lanes`Mode` is the shipped default. `Isolated` marks lanes whose remediation must rundiff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex 5a594ecc76..43c3f12c8f 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -33,6 +33,7 @@ import { applySlashdoInvocation } from './promptSections/slashdo.js';import { manualForgeCli, resolveManualForgeCli } from './promptSections/forge.js';import { buildOrchestrationDoctrineSection } from './promptSections/orchestrationDoctrine.js';import { buildIssueFilingSection } from './promptSections/plannerAttribution.js';+import { buildSecurityAuditRuntimeSection } from './promptSections/securityAudit.js';import { isPublicReviewNoToolProfile, isPublicReviewRestrictedProfile } from '../lib/agentExecutionProfiles.js';import { COMPLETION_MODES, resolveCompletionMode } from '../lib/agentCompletionMode.js';import {@@ -1051,6 +1052,8 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, { isTui = tcontractSections.push(UNATTENDED_RUN_RULE);if (task.metadata?.prCompletion === PR_COMPLETIONS.DRAFT) contractSections.push(DRAFT_PR_RULE);if (isUiAuditTask(task)) contractSections.push(UI_AUDIT_RUNTIME_RULE);+ const securityAuditRuntime = buildSecurityAuditRuntimeSection(task, { providerId, providerCommand });+ if (securityAuditRuntime) contractSections.push(securityAuditRuntime);// --- Issue filing labels and planner attribution --------------------------// Unconditional filing rules, with planner attribution when resolvable:diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex 457da46658..827e49ee1e 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -676,6 +676,57 @@ describe('claim-flow completion handoff', () => {});describe('buildLightContextPrompt', () => {+ describe('Codex security audit dispatch', () => {+ it.each(['cli', 'tui'])('routes a customized %s audit through Codex Security without changing issue-only completion', async (providerType) => {+ const prompt = await buildAgentPrompt(makeTask({+ metadata: {+ analysisType: 'security',+ noCodeOutput: true,+ prompt: 'Custom security mission: file issues and preserve the live checkout.',+ },+ }), {}, '/repo', null, {+ providerType,+ providerId: 'custom-auditor',+ providerCommand: '/opt/tools/Codex.exe',+ split: true,+ });++ expect(prompt.userPrompt).toContain('Custom security mission');+ expect(prompt.systemPrompt).toContain('## Codex Security Audit Runtime');+ expect(prompt.systemPrompt).toContain('--auth chatgpt --headless --json');+ expect(prompt.systemPrompt).toContain('deliver supported findings even when another probe is blocked');+ expect(prompt.systemPrompt).toContain('## Completion (No Code Output)');+ expect(prompt.systemPrompt).toContain('## Required audit assessment handoff');+ expect(prompt.systemPrompt).toContain('QUALITY_AUDIT_JSON');+ });++ it.each([+ { metadata: { taskAnalysisType: 'security' } },+ { taskType: 'security' },+ ])('routes legacy security task shapes when only the Codex provider id is available: %j', (shape) => {+ const prompt = buildLightContextPrompt(makeTask(shape), '/repo', null, { providerId: 'codex-tui' });+ expect(prompt).toContain('## Codex Security Audit Runtime');+ });++ it.each([+ [{ metadata: { analysisType: 'security' } }, { providerId: 'claude', providerCommand: 'claude' }],+ [{ metadata: { analysisType: 'security' } }, { providerId: 'codex', providerCommand: 'claude' }],+ [{ metadata: { analysisType: 'performance' } }, { providerId: 'codex', providerCommand: 'codex' }],+ [{ metadata: { analysisType: 'private-security-assessment' } }, { providerId: 'codex' }],+ [{ metadata: { selfImprovementType: 'security' } }, { providerId: 'codex' }],+ ])('keeps other runtimes and task contracts unchanged: %j', (shape, options) => {+ const prompt = buildLightContextPrompt(makeTask(shape), '/repo', null, options);+ expect(prompt).not.toContain('## Codex Security Audit Runtime');+ });++ it('does not route an API model through a native Codex scanner', async () => {+ const prompt = await buildAgentPrompt(makeTask({ metadata: { analysisType: 'security' } }), {}, '/repo', null, {+ providerType: 'api', providerId: 'codex', providerModel: 'gpt-6.1-sol',+ });+ expect(prompt).not.toContain('## Codex Security Audit Runtime');+ });+ });+describe('UI audit runtime context', () => {it.each(UI_AUDIT_TASK_TYPES)('adds browser and local-system guidance to %s', (analysisType) => {const prompt = buildLightContextPrompt(diff --git a/server/services/promptSections/securityAudit.js b/server/services/promptSections/securityAudit.jsnew file mode 100644index 0000000000..4d3bb6893b--- /dev/null+++ b/server/services/promptSections/securityAudit.js@@ -0,0 +1,24 @@+import { isCodexProvider } from '../../lib/providerModels.js';+import { resolveTaskHookType } from '../taskTypeHooks.js';++// Resolve at dispatch, rather than changing only the shipped security mission:+// customized prompts and already-queued audits need the same scanner guidance.+export function buildSecurityAuditRuntimeSection(task, { providerId, providerCommand } = {}) {+ // Match the identity used by source evidence, completion and score recording.+ const taskType = resolveTaskHookType(task);+ // An explicit executable wins over a stale provider id. Custom ids still+ // qualify when their command is Codex; model names alone never select it.+ const provider = { id: providerCommand ? null : providerId, command: providerCommand };+ if (taskType !== 'security' || !isCodexProvider(provider)) return '';++ return `## Codex Security Audit Runtime+This security audit is running in a Codex agent. Run the scanner phase through Codex Security after reading the target's threat model and completing the required repository-wide discovery. Use an available Codex Security scan capability, or the official local CLI; opening Codex Security Cloud alone does not run a scan.++- For the CLI, inspect its installed help/version, then run a report-only scan non-interactively: \`npx --yes @openai/codex-security scan "<repo-root>" --auth chatgpt --headless --json --model "<authorized-model>" --effort "<authorized-effort>" --output-dir "<private-dir-outside-repo>"\`. Resolve the placeholders first, close stdin, and keep scan artifacts/state outside the repository with private permissions. Remove unrelated application/provider credentials from the scanner's child environment, including PORTOS_API_TOKEN, while preserving its authorized scanner sign-in and required runtime variables; never print credentials. Use existing authorized credentials; never start login/device-auth, change accounts, purchase access, or wait for a human. Do not silently switch to an environment API key.+- Supply the project's security/architecture documents with \`--knowledge-base\` and a scoped \`--scan-prompt-file\` describing the actual threat model, selected audit area and report-only restrictions. Keep outer issue-filing and completion commands out of that file. Explicitly select an accessible model and effort within this run's configured permissions, quota and budget before starting; do not inherit more expensive CLI defaults or launch extra workers/categories. If that cannot be established, record the limitation and continue permitted source review.+- The scanner supplies evidence, not authority. Preserve the task's file-issues versus remediation mode, independent review, validation and delivery requirements. Never use \`--patch\`, \`--create-pr\`, \`publish\`, or hook installation as part of the scan. Check the checkout's branch/status before and after; report unexpected changes without discarding anyone's work. Read findings and coverage artifacts, challenge reachability against callers/tests/history, redact evidence, and de-duplicate before filing.+- If the module is missing, access is denied, a permission review refuses an action, or a quota/time limit stops the scan, preserve completed evidence and name the concrete failure. Do not repeat a refused action through another tool or treat a dry run as proof of scan access. Continue independent permitted inspection and deliver supported findings even when another probe is blocked; do not strand an unattended run on a setup or approval prompt.+- Finish with the required sentinel and exactly one QUALITY_AUDIT_JSON assessment based on work actually performed. Scanner completion does not certify every file: retain exclusions, deferred areas and uncertainty, and use partial/unavailable coverage when warranted.++CLI contract: https://learn.chatgpt.com/docs/security/cli`;+}