Skip to content

test: lock in the process-tree and identity-file leak fixes with regression contracts - #11935

Merged
iamwhatever merged 1 commit into
mainfrom
test/memory-leak-regression-contracts
Sep 19, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
test/memory-leak-regression-contracts

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

The 0.7.0 memory leak was fixed by several PRs (#11309, #11565, #11456, #11594, #11712, #10985), each with its own unit tests. Nothing tests the fixes together: a session ends, its whole runtime tree is gone, identity files are retired, the browser buffers stay bounded. A refactor could reopen one path and every existing test would still pass.

Why it matters

Users saw 50 GB of orphaned kiro-cli trees and 58k identity files build up over a day. Those fixes are now in v0.7.0-insider.5. Without end-to-end contracts, the same leak class can come back without any test turning red.

What changed (motivation → approach → change)

Goal: make the leak fixes fail loudly if they regress. Approach: drive the real cleanup code with fake processes, then assert on what is left alive, not on log lines. Every new test was checked in reverse: disable the cleanup step it guards and the test fails.

Backend, in test/test_runtime_cleanup_regression.py (new): a session that starts persists its new descendants (new and load paths); a cancelled descendant scan terminates only the failed session; repeated kills keep escaped processes for the periodic sweep instead of losing them.

Backend, in existing files: test/test_acp_spawn_offload.py checks a spawn that fails in finish_suspended_spawn, initialize or cancel unwinds the live tree and its tracking. test/test_session_scope_reap.py checks periodic ticks reclaim successive runtime trees without a gateway restart. test/test_member_binding_reclaim.py checks repeated publication, retirement and maintenance keep live identity records and drop only dead ones.

Frontend, in website/src/test/pierre.diffWorker.test.ts and website/src/test/useWebSocket.chunkBufOverflow.test.ts: the diff cache keeps exact retention through repeated eviction, bypass, abort and recreation; mixed chunk buffers and tool-output copies stay bounded across repeated active and background turns.

No production code changes.

Backwards compatibility

Compatible: test-only change, no runtime behaviour touched.

Tests

  • test_session_start_persists_new_descendants[new|load]: descendants seen at session start are written to the PID ledger.
  • test_cancelled_descendant_scan_terminates_only_failed_session[new|load]: cancel kills the failed tree, not a sibling.
  • test_repeated_kill_retains_escapees_for_periodic_cleanup: an escaped PID stays recorded for the sweep.
  • test_failed_spawn_unwinds_live_tree_and_tracking[3 stages]: no live process or ledger entry survives a failed spawn.
  • test_periodic_ticks_reclaim_successive_runtime_trees_without_gateway_restart: Linux scope reap works on a long-running gateway.
  • test_repeated_publication_retirement_and_maintenance_preserve_live_records: identity file counts converge; live records survive.
  • keeps exact retention through repeated eviction, bypass, abort and recreation: diff worker cache size pinned.
  • bounds mixed buffers and tool copies across repeated active/background turns: chunk buffer and tool output clamps pinned.

All use fake processes; they do not prove native macOS or Windows reaping.

Manual verification

N/A — unit coverage sufficient: the change adds tests only. Related backend set (146 tests) and both frontend files pass locally; each new test fails when its guarded cleanup step is disabled.

Related Issues

no linked issue: regression coverage for already-merged fixes; no open issue tracks the missing tests.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

…ession contracts

Adds end-to-end regression tests that fail if a previously fixed leak path reopens: descendant reclaim after a session ends (including reparented descendants), cancel terminating only the failed session, escaped processes left to the periodic sweep, identity-record retirement counts, and frontend tool-output and chunk-buffer clamps that must not copy unbounded data.
@bolichen97
bolichen97 requested review from a team and cixuuz September 19, 2026 04:06
@bolichen97

Copy link
Copy Markdown
Contributor Author

Intent: Add end-to-end regression contracts so the 0.7.0 process-tree and identity-file leak fixes fail a test if any single cleanup step is removed or weakened again.
Not a goal: Changing production cleanup behaviour, widening kill authority, or proving native macOS/Windows reaping (fake processes only).

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ✅ PASS

UX-level review of e40f70279496e9402cce71ab46cd8684aa70ac5a — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Nothing to check.

[UX-REVIEWED] e40f702

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of e40f70279496e9402cce71ab46cd8684aa70ac5a — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify the reverse-check claim by disabling one guarded cleanup step locally — the "each test fails when disabled" assertion isn't provable from the diff.

[DESIGN-REVIEWED] e40f702

@github-actions

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed e40f70279496e9402cce71ab46cd8684aa70ac5a — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] e40f702

Verdict parsed from the review's SHA-scoped output markers for commit e40f70279496e9402cce71ab46cd8684aa70ac5a.

False positive or not applicable? A repository writer can comment:
/ai-review override fable e40f70279496e9402cce71ab46cd8684aa70ac5a: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of e40f70279496e9402cce71ab46cd8684aa70ac5a and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e40f702

False positive or not applicable? A repository writer can comment:
/ai-review override gpt e40f70279496e9402cce71ab46cd8684aa70ac5a: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 19, 2026
@iamwhatever
iamwhatever enabled auto-merge (squash) September 19, 2026 05:02

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: test (6 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: test/spec files only -- four new pytest regression files (ACP spawn offload, member-binding reclaim, runtime cleanup, session-scope reap) plus two vitest files; zero production files touched, so no runtime behaviour changes. The only annotation on the Semgrep run is GitHub's own level=notice runner-image migration message at .github:1, not a Semgrep finding.

@iamwhatever
iamwhatever merged commit 50ab832 into main Sep 19, 2026
85 checks passed
@iamwhatever
iamwhatever deleted the test/memory-leak-regression-contracts branch September 19, 2026 05:02
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 19, 2026
bolichen97 added a commit that referenced this pull request Sep 20, 2026
Cover real Darwin zombie identity, reaped-root group recovery and escaped descendants. Exercise idle and warm-pool expiry over repeated small process trees, and route these contracts through the existing macOS CI lane.

Complements #11935.
bolichen97 added a commit that referenced this pull request Sep 20, 2026
Cover real Darwin zombie identity, reaped-root group recovery and escaped descendants. Exercise idle and warm-pool expiry over repeated small process trees, and route these contracts through the existing macOS CI lane.

Complements #11935.
bolichen97 added a commit that referenced this pull request Sep 20, 2026
Cover real Darwin zombie identity, reaped-root group recovery and escaped descendants. Exercise idle and warm-pool expiry over repeated small process trees, and route these contracts through the existing macOS CI lane.

Complements #11935.
bolichen97 added a commit that referenced this pull request Sep 20, 2026
Cover real Darwin zombie identity, reaped-root group recovery and escaped descendants. Exercise idle and warm-pool expiry over repeated small process trees, and route these contracts through the existing macOS CI lane.

Complements #11935.
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…ession contracts (kirodotdev#11935)

Adds end-to-end regression tests that fail if a previously fixed leak path reopens: descendant reclaim after a session ends (including reparented descendants), cancel terminating only the failed session, escaped processes left to the periodic sweep, identity-record retirement counts, and frontend tool-output and chunk-buffer clamps that must not copy unbounded data.
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
Cover real Darwin zombie identity, reaped-root group recovery and escaped descendants. Exercise idle and warm-pool expiry over repeated small process trees, and route these contracts through the existing macOS CI lane.

Complements kirodotdev#11935.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants