Refactor container cleanup to deduplicate log/session preservation paths#3361
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors cleanup() in src/container-cleanup.ts to remove four near-identical chmod-or-rename log/session-state preservation blocks by introducing a single preserveDirectory() helper with per-call options.
Changes:
- Adds
PreserveDirectoryOptionstype andpreserveDirectory()helper covering both the runtime-directory chmod path and the workDir→/tmp rename path. - Replaces four inline preservation blocks (agent session state, api-proxy logs, cli-proxy logs, squid logs) with helper calls.
- Preserves squid-specific post-rename chmod via
chmodPreservedDir, and squid's no-existsSync runtime chmod viaruntimeDirMustExist: false.
Show a summary per file
| File | Description |
|---|---|
| src/container-cleanup.ts | Introduce preserveDirectory helper and replace four duplicated preservation blocks in cleanup(). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
🧪 Smoke Test Results
Overall: PARTIAL — MCP test passed; connectivity and file tests could not be verified due to unexpanded template variables. PR: Refactor container cleanup to deduplicate log/session preservation paths — author
|
🔥 Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( PR: "Refactor container cleanup to deduplicate log/session preservation paths" — author: Overall: PARTIAL (BYOK path ✅, pre-step outputs not available)
|
Smoke Test Results✅ GitHub API: Confirmed 2 PR entries in recent-prs.json Result: PASS — All smoke tests passed.
|
Smoke Test: FAILMerged PRs: ✅ chore: recompile all workflow lock files; refactor: split token-tracker.js into four focused modules Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
|
Smoke test FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
Chroot Smoke Test Results
Overall: ❌ FAILED — Python and Node.js versions differ between host and chroot.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test: GitHub Actions Services Connectivity
Overall: FAIL —
|
|
@copilot address review feedback |
I checked this PR and don’t see any actionable review comments or unresolved review threads to address right now. Please share the specific feedback/thread you want me to apply, and I’ll update it right away. |
cleanup()insrc/container-cleanup.tsrepeated the same chmod-or-rename preservation flow across four directories (session-state,api-proxy-logs,cli-proxy-logs,squid-logs). This made behavior changes error-prone and required editing multiple near-identical blocks.What changed
preserveDirectory(...), to encapsulate:chmod -R a+rX+"... available at"log)renameto timestamped/tmp+"... preserved at"log)Where duplication was removed
cleanup()with helper calls for:agent-session-state)api-proxy-logs)cli-proxy-logs)squid-logs)Behavior preserved
chmodPreservedDir).