Skip to content

ci: self-repair memory successor #1

ci: self-repair memory successor

ci: self-repair memory successor #1

name: Self-repair memory successor
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 }}
- uses: oven-sh/setup-bun@v2
with:
bun-version: '1.3'
- name: Apply review fixes
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
- name: Verify
run: |
bun install --frozen-lockfile
bunx biome check --write \
packages/coding-agent/src/tools/resource-gc.ts \
packages/coding-agent/test/tools/resource-gc.test.ts
bun test --timeout 30000 \
packages/coding-agent/test/runtime/memory-limit.test.ts \
packages/coding-agent/test/runtime/memory-domain.test.ts \
packages/coding-agent/test/runtime/memory-guard.test.ts \
packages/coding-agent/test/tools/resource-gc.test.ts \
packages/coding-agent/test/tools/resource-gc-redteam.test.ts \
packages/coding-agent/test/gjc-runtime/linux-proc.test.ts \
packages/coding-agent/test/cli-memory-guard-native-smoke.test.ts \
packages/natives/test/memory-guard-native.test.ts \
packages/natives/test/memory-guard-build-wiring.test.ts
bun packages/natives/scripts/gen-enums.ts
git diff --exit-code -- packages/natives/native/index.d.ts packages/natives/native/index.js
bun --cwd=packages/coding-agent run check
bun --cwd=packages/natives run check
cargo fmt --all -- --check
- name: Commit verified fix
shell: bash
run: |
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