Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8a5751c
feat(coding-agent): add memory pressure observability
Jul 23, 2026
dc66505
fix(coding-agent): wire memory guard policy
Jul 23, 2026
969f2d8
fix(coding-agent): honor memory domains
Jul 23, 2026
6f964cc
fix(natives): enable Windows Job Object bindings
Jul 23, 2026
6d1b624
fix(natives): query current Job Object memory
Jul 23, 2026
c735c53
test(ci): align native push plan fixture
Jul 23, 2026
884f387
merge dev into memory guard observability
Jul 23, 2026
c8ac807
fix(coding-agent): harden memory pressure sampling
Jul 23, 2026
9c8dfb1
fix(natives): use Windows Job limit constants
Jul 23, 2026
08b3f84
fix(coding-agent): refresh live memory guard cadence
Jul 23, 2026
a438d56
fix(coding-agent): preserve memory pressure domains
Jul 23, 2026
c975770
fix(coding-agent): harden pressure timing and mounts
Jul 23, 2026
717907c
style(memory-guard): apply repository formatting
Jul 23, 2026
7512f70
fix(coding-agent): fail over cgroup mount candidates
Jul 24, 2026
a80a879
fix(coding-agent): select binding cgroup pressure
Jul 24, 2026
d753fa2
fix(coding-agent): preserve cgroup pressure domains
Jul 24, 2026
de04bb0
fix(coding-agent): retain all pressure candidates
Jul 24, 2026
426ca8d
fix(coding-agent): resolve five owner blockers
Jul 25, 2026
ecff73d
Merge remote-tracking branch 'upstream/dev' into feat/memory-guard-ob…
Jul 25, 2026
75af20c
fix(coding-agent): resolve all 8 owner review requirements for memory…
Jul 25, 2026
76a2559
test: close the teardown-ordering witness gap and fix a soak-caught d…
Yeachan-Heo Jul 25, 2026
c412dd6
test(runtime): deflake concurrent-dispose TERM trap race
Jul 25, 2026
2a7f33d
fix(sdk): join completed-start controller teardown before shutdown re…
Yeachan-Heo Jul 25, 2026
fcec26a
chore: sync memory successor with current upstream dev
twoimo Jul 25, 2026
683414a
chore: trigger memory final review repair
twoimo Jul 25, 2026
b9e5dcc
ci: run memory final review repair on branch
twoimo Jul 25, 2026
78b6cb1
ci: rerun final memory repair
twoimo Jul 25, 2026
20db19c
ci: fix generated declaration repair
twoimo Jul 25, 2026
24b1b73
ci: preserve executable memory repair test source
twoimo Jul 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/trigger/memory-final-review
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
one-shot-retry-2026-07-25
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,31 @@ jobs:
pattern: pi-natives-${{ matrix.platform }}-${{ matrix.arch }}*
path: packages/natives/native
merge-multiple: true
- name: Verify memory-guard native loader export
run: bun test packages/natives/test/memory-guard-native.test.ts

- name: Build release binary
env:
RELEASE_TARGETS: ${{ matrix.target_id }}
run: bun run ci:release:build-binaries
- name: Smoke memory-guard native route (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$json = & "${{ matrix.binary_path }}" internal memory-guard-native-smoke --json
$data = $json | ConvertFrom-Json
if ($data.api -ne "memory_guard_windows_job_probe_v1") {
throw "unexpected api: $($data.api)"
}
if ($data.source -ne "pi_natives") {
throw "unexpected source: $($data.source)"
}
if ($data.result.platform -ne "win32") {
throw "unexpected platform: $($data.result.platform)"
}
if (@("job_snapshot", "not_in_job", "api_error") -notcontains $data.result.kind) {
throw "unexpected result kind: $($data.result.kind)"
}
- name: Smoke release binary
if: runner.os != 'Windows'
run: |
Expand Down
159 changes: 159 additions & 0 deletions .github/workflows/memory-final-self-repair.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Memory final self repair

on:
push:
branches:
- feat/memory-guard-observability-dev

permissions:
contents: write

jobs:
repair:
if: github.actor == 'twoimo'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: feat/memory-guard-observability-dev
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- uses: oven-sh/setup-bun@v2
with:
bun-version: '1.3'

- name: Add direct Windows accounting regressions
shell: bash
run: |
python3 - <<'PY'
from pathlib import Path

path = Path('packages/coding-agent/test/tools/resource-gc-redteam.test.ts')
text = path.read_text()

settings_import = 'import { Settings } from "../../src/config/settings";\n'
limit_import = 'import { resolveEffectiveMemoryLimit } from "../../src/runtime/memory-limit";\n'
if limit_import not in text:
if settings_import not in text:
raise SystemExit('settings import anchor missing')
text = text.replace(settings_import, settings_import + limit_import, 1)

import_anchor = '\t__resetResourceGcForTest,\n'
seam = '\t__sampleWindowsJobMemoryForTest,\n\t__selectMemoryPressureDomainForTest,\n'
if '__sampleWindowsJobMemoryForTest' not in text:
if import_anchor not in text:
raise SystemExit('resource-gc import anchor missing')
text = text.replace(import_anchor, import_anchor + seam, 1)

marker = '\tit("never evicts ownerless tabs under RSS pressure and warns once", async () => {'
tests = r''' it("keeps uncapped Windows Job commit charge separate from physical RAM", () => {
const gib = 1024 ** 3;
const hostBytes = 16 * gib;
const parentBytes = 2 * gib;
const snapshot = __sampleWindowsJobMemoryForTest(hostBytes, parentBytes, {
kind: "job_snapshot",
platform: "win32",
isInJob: true,
jobMemoryUsedBytes: String(20 * gib),
peakJobMemoryUsedBytes: String(21 * gib),
processPrivateUsageBytes: String(20 * gib),
processWorkingSetBytes: String(parentBytes),
peakProcessWorkingSetBytes: String(3 * gib),
});

expect(snapshot).not.toBeNull();
expect(snapshot?.parentBytes).toBe(parentBytes);
expect(snapshot?.domains).toContainEqual({
hardCapBytes: Number.MAX_SAFE_INTEGER,
totalUsageBytes: 20 * gib,
source: "windows_job",
});
expect(snapshot?.domains).toContainEqual({
hardCapBytes: hostBytes,
totalUsageBytes: parentBytes,
source: "windows_process_job_limit",
});
});

it("does not clamp a Windows commit-domain policy cap to physical RAM", () => {
const gib = 1024 ** 3;
const hostBytes = 16 * gib;
const policyLimitBytes = 24 * gib;
const snapshot = __sampleWindowsJobMemoryForTest(hostBytes, 2 * gib, {
kind: "job_snapshot",
platform: "win32",
isInJob: true,
jobMemoryUsedBytes: String(20 * gib),
peakJobMemoryUsedBytes: String(21 * gib),
processPrivateUsageBytes: String(20 * gib),
processWorkingSetBytes: String(2 * gib),
peakProcessWorkingSetBytes: String(3 * gib),
});
expect(snapshot).not.toBeNull();
const pressure = __selectMemoryPressureDomainForTest(snapshot!, policyLimitBytes);
const limit = resolveEffectiveMemoryLimit({
hardCapBytes: pressure.hardCapBytes,
policyLimitBytes,
});

expect(pressure.source).toBe("windows_job");
expect(limit.effectiveBytes).toBe(policyLimitBytes);
expect(limit.effectiveBytes).toBeGreaterThan(hostBytes);
const usageRatio = pressure.totalUsageBytes / limit.effectiveBytes!;
expect(usageRatio).toBeCloseTo(20 / 24, 8);
expect(usageRatio).toBeLessThan(1);
});

'''
if 'keeps uncapped Windows Job commit charge separate from physical RAM' not in text:
if text.count(marker) != 1:
raise SystemExit('test insertion anchor missing')
text = text.replace(marker, tests + marker, 1)
path.write_text(text)
PY

- name: Restore generated declarations
run: |
python3 -c 'from pathlib import Path; p=Path("packages/natives/native/index.d.ts"); s=p.read_text(); a="/* eslint-disable */\nexport declare class ComputerController"; c="/**\n * macOS computer-use controller.\n *\n * This declaration and the named JS export are available on every platform so\n * consumers can import them portably; the native controller itself is built\n * only on macOS.\n */\n"; p.write_text(s if "macOS computer-use controller." in s else s.replace(a, "/* eslint-disable */\n"+c+"export declare class ComputerController", 1))'
bun packages/natives/scripts/gen-enums.ts
cp packages/natives/native/index.d.ts /tmp/index.generated.d.ts
cp packages/natives/native/index.js /tmp/index.generated.js
bun packages/natives/scripts/gen-enums.ts
cmp /tmp/index.generated.d.ts packages/natives/native/index.d.ts
cmp /tmp/index.generated.js packages/natives/native/index.js
grep -F "macOS computer-use controller." packages/natives/native/index.d.ts

- name: Install and format
run: |
bun install --frozen-lockfile
bunx biome check --write packages/coding-agent/test/tools/resource-gc-redteam.test.ts

- name: Verify focused memory boundary
run: |
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 --cwd=packages/coding-agent run check
bun --cwd=packages/natives run check

- name: Commit verified repair and remove automation
shell: bash
run: |
git config user.name "twoimo"
git config user.email "32544727+twoimo@users.noreply.github.com"
git rm .github/workflows/memory-final-self-repair.yml
git rm -f .github/trigger/memory-final-review
git add \
packages/coding-agent/test/tools/resource-gc-redteam.test.ts \
packages/natives/native/index.d.ts \
packages/natives/native/index.js
git commit -m "test(coding-agent): cover Windows memory accounting"
git push origin HEAD:feat/memory-guard-observability-dev
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,10 @@ windows-sys = { version = "0.61", features = [
"Win32_Storage_ProjectedFileSystem",
"Win32_System_Com",
"Win32_System_IO",
"Win32_System_JobObjects",
"Win32_System_Ioctl",
"Win32_System_LibraryLoader",
"Win32_System_ProcessStatus",
"Win32_System_Threading",
] }
winreg = "0.56"
Expand Down
1 change: 1 addition & 0 deletions crates/pi-natives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub mod highlight;
pub mod html;
pub mod keys;
pub mod linediff;
pub mod memory;
pub mod sdk;
pub mod sixel;
pub use pi_ast::language;
Expand Down
Loading
Loading