ci: apply memory successor repair #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Apply memory successor fixes | |
| on: | |
| push: | |
| branches: | |
| - successor/memory-guard-current-v4 | |
| permissions: | |
| contents: write | |
| jobs: | |
| repair: | |
| if: github.actor == 'twoimo' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: successor/memory-guard-current-v4 | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Apply review fixes and commit | |
| shell: bash | |
| run: | | |
| python3 - <<'PY' | |
| from pathlib import Path | |
| source = Path('packages/coding-agent/src/tools/resource-gc.ts') | |
| text = source.read_text() | |
| old = '''\t\tif (limit !== null && usage !== null) {\n\t\t\tconst zeroLimit = limit.kind === "finite" && limit.bytes === 0;\n\t\t\tdomains.push({\n\t\t\t\thardCapBytes: limit.kind === "unlimited" ? hostBytes : Math.min(hostBytes, Math.max(1, limit.bytes)),\n\t\t\t\ttotalUsageBytes: zeroLimit ? Math.max(1, usage) : usage,\n\t\t\t\tsource,\n\t\t\t});\n\t\t}\n''' | |
| new = '''\t\tif (limit !== null && usage !== null && (limit.kind === "unlimited" || limit.bytes > 0)) {\n\t\t\tdomains.push({\n\t\t\t\thardCapBytes: limit.kind === "unlimited" ? hostBytes : Math.min(hostBytes, limit.bytes),\n\t\t\t\ttotalUsageBytes: usage,\n\t\t\t\tsource,\n\t\t\t});\n\t\t}\n''' | |
| if old in text: | |
| text = text.replace(old, new, 1) | |
| elif new not in text: | |
| raise SystemExit('cgroup zero-limit block not found') | |
| source.write_text(text) | |
| test = Path('packages/coding-agent/test/tools/resource-gc.test.ts') | |
| t = test.read_text() | |
| old_test = '''\t\t\tawait expect(\n\t\t\t\t__sampleLinuxCgroupHierarchyForTest(mountLine(53, "/", zeroMount), "/app", "cgroup2", 5000, 100),\n\t\t\t).resolves.toMatchObject({\n\t\t\t\thardCapBytes: 1,\n\t\t\t\ttotalUsageBytes: 100,\n\t\t\t});\n''' | |
| new_test = '''\t\t\tawait expect(\n\t\t\t\t__sampleLinuxCgroupHierarchyForTest(mountLine(53, "/", zeroMount), "/app", "cgroup2", 5000, 100),\n\t\t\t).resolves.toBeNull();\n''' | |
| if old_test in t: | |
| t = t.replace(old_test, new_test, 1) | |
| elif new_test not in t: | |
| raise SystemExit('zero-limit regression assertion not found') | |
| test.write_text(t) | |
| PY | |
| git restore --source=41d6850cabd16629a14170f8b446090a7fafd117 -- \ | |
| packages/coding-agent/src/prompts/agent-fragments/ralplan-persistence.md \ | |
| packages/coding-agent/src/prompts/agent-fragments/restricted-bash.md \ | |
| packages/coding-agent/src/prompts/system/rlm-research.md \ | |
| packages/coding-agent/src/prompts/system/system-prompt.md \ | |
| packages/coding-agent/src/prompts/tools/bash.md \ | |
| packages/coding-agent/src/prompts/tools/cron.md | |
| git config user.name "twoimo" | |
| git config user.email "32544727+twoimo@users.noreply.github.com" | |
| git rm .github/workflows/self-repair-memory-successor.yml | |
| git add -A | |
| git commit -m "fix(coding-agent): harden cgroup zero limits" | |
| git push origin HEAD:successor/memory-guard-current-v4 |