You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pattern: Log directory path construction with conditional proxyLogsDir/workDir logic
Locations: src/config-writer.ts lines 65-96 and src/compose-generator.ts lines 48-68
Impact: ~35 lines of duplicated path resolution logic that must be kept synchronized
Evidence
The exact same conditional logic for resolving log directory paths appears in both files:
compose-generator.ts (lines 48-68):
// Squid logs path: use proxyLogsDir if specified (direct write), otherwise workDir/squid-logsconstsquidLogsPath=config.proxyLogsDir||`${config.workDir}/squid-logs`;// Session state path: use sessionStateDir if specified (timeout-safe, predictable path),// otherwise workDir/agent-session-state (will be moved to /tmp after cleanup)constsessionStatePath=config.sessionStateDir||`${config.workDir}/agent-session-state`;// Agent logs path: always workDir/agent-logs (moved to /tmp after cleanup)constagentLogsPath=`${config.workDir}/agent-logs`;// API proxy logs path: if proxyLogsDir is specified, write inside it as a subdirectory// so that token-usage.jsonl is included in the firewall-audit-logs artifact automatically.// Otherwise, write to workDir/api-proxy-logs (will be moved to /tmp after cleanup)constapiProxyLogsPath=config.proxyLogsDir
? path.join(config.proxyLogsDir,'api-proxy-logs')
: path.join(config.workDir,'api-proxy-logs');// CLI proxy logs path: write to workDir/cli-proxy-logs (will be moved to /tmp after cleanup)constcliProxyLogsPath=config.proxyLogsDir
? path.join(config.proxyLogsDir,'cli-proxy-logs')
: path.join(config.workDir,'cli-proxy-logs');
constlogPaths=resolveLogPaths(config);// Pass to service buildersconstsquidService=buildSquidService(config,networkConfig,sslConfig,squidConfigContent,logPaths.squidLogs);
Why This Matters
Maintenance burden: Changes to log path logic must be synchronized across two files
Duplicate Code Opportunity
Summary
src/config-writer.tslines 65-96 andsrc/compose-generator.tslines 48-68Evidence
The exact same conditional logic for resolving log directory paths appears in both files:
compose-generator.ts(lines 48-68):config-writer.ts(lines 65-96):Both files implement the same conditional path resolution:
squidLogsDir/Path:proxyLogsDir || workDir/squid-logssessionStatePath/Dir:sessionStateDir || workDir/agent-session-stateagentLogsPath/Dir: alwaysworkDir/agent-logsapiProxyLogsPath/Dir: conditional subdirectory underproxyLogsDirorworkDircliProxyLogsPath/Dir: conditional subdirectory underproxyLogsDirorworkDirSuggested Refactoring
Extract log path resolution into a shared module (e.g.,
src/log-paths.ts):Usage in
config-writer.ts:Usage in
compose-generator.ts:Why This Matters
Affected Files
src/compose-generator.ts— lines 48-68src/config-writer.ts— lines 65-96Effort Estimate
Low — Extract to a shared module with 2 call sites
Detected by Duplicate Code Detector workflow. Run date: 2026-05-23
Note
🔒 Integrity filter blocked 1 item
The following item was blocked because it doesn't meet the GitHub integrity level.
search_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: