Skip to content

fix(codegraph): bound command output retention - #642

Merged
seonghobae merged 4 commits into
mainfrom
fix/codegraph-output-fragment-retention-20260912
Sep 11, 2026
Merged

fix(codegraph): bound command output retention#642
seonghobae merged 4 commits into
mainfrom
fix/codegraph-output-fragment-retention-20260912

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Finding

Noema's CodeGraph sandbox command wrapper caps captured stdout/stderr at 128 KiB, but protected source retained every accepted child-process data chunk as a separate Buffer and concatenated them only after close. Untrusted command output could therefore amplify retained heap/object count with highly fragmented output even while total payload bytes stayed within the byte ceiling. This is an Isolation Integration resource-bound defect inside Noema's CodeGraph reviewer boundary; it does not change quarantine/runtime ownership.

RED

Test-only exact ac1b2404b56fdeacbaa035247e7cf628ba890344 executed the real bounded child-process path and required successful bounded output without a final Buffer.concat over retained chunks. Hosted application CI run 34627520581 checked out that exact head, passed base/toolchain/install/typecheck, and failed at release tests, providing the expected RED.

Repair

Production repair 32e15c10280b4eb9ff04d7719c0be670c429d306 replaces per-event chunk retention with one fixed maxOutputBytes buffer. Each accepted stdout/stderr chunk is copied directly into the remaining bounded region; an oversize chunk is rejected and the child is killed before it is retained. Close decodes only the written subarray, so retained output memory is bounded independently of stream fragmentation while preserving event-order capture, shell-free spawn, wall-clock/output ceilings, child-kill semantics, diagnostic bounds, and environment ownership.

Canonical CodeGraph sandbox design documentation was converged on the same branch to state the fixed-retention invariant and its verification requirement. A trailing-newline source hygiene finding in the touched test file was then repaired without changing test semantics. Final exact is 3427e5a66d7a0ea9379ddc7915ba2b3d1872c492.

GREEN / review

On that unchanged exact, application CI 34628191004, reviewer-ci 34628191052, required Security Scan 34628191053, and patch-validator-image 34628191114 are terminal SUCCESS. Application release tests, security/KPI/license/acquisition gates passed; reviewer-ci retained its 100% line+branch/docstring gates and real no-network CodeGraph sandbox smoke; patch-validator retained exact-source/image/SBOM/vulnerability and isolation evidence. A current-head COMMENT-only review found no additional valid source, DDD/owner-boundary, documentation, or regression finding. Fresh unresolved inline threads are 0. Protected main remained ef24edcea85f49cdf7e81f88cb30ca84d620b80f, matching this PR's base immediately before Ready.

Scope

No LLM routing, quarantine/security product authority, outbound policy, or foreign domain truth moves into Noema. This is source/isolation hardening only; it is not an immutable release, deployment, quarantine-runtime, or production-outcome claim.

Summary by CodeRabbit

  • 성능 및 안정성

    • 명령 출력 수집 방식을 고정 용량 버퍼 기반으로 개선해, 설정된 바이트 한도 내에서 메모리 사용량을 제한합니다.
    • 출력 한도 초과 시 기존과 같이 실행 중인 프로세스를 종료합니다.
  • 테스트

    • 출력 데이터를 불필요하게 재조합하지 않고 처리하는 동작을 검증하는 테스트를 추가했습니다.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 1edae67d-1ed6-4a06-a991-fde0d456df46

📥 Commits

Reviewing files that changed from the base of the PR and between ef24edc and 3427e5a.

📒 Files selected for processing (3)
  • .github/codegraph/sandbox-runner.mjs
  • docs/superpowers/specs/2026-08-03-codegraph-quarantine-sandbox-design.md
  • test/codegraph-sandbox-runner.test.ts

📝 Walkthrough

Walkthrough

runBoundedCommand가 청크 배열 대신 고정 크기 버퍼에 출력을 저장합니다. 출력 한도를 초과하는 청크는 복사하지 않고 프로세스를 종료합니다. 테스트와 설계 문서가 새 동작을 반영합니다.

Changes

명령 출력 수집

Layer / File(s) Summary
고정 버퍼 출력 수집
.github/codegraph/sandbox-runner.mjs, docs/superpowers/specs/...
출력을 고정 크기 버퍼에 직접 복사합니다. 잔여 용량을 초과하는 청크는 거부하고 자식 프로세스를 SIGKILL로 종료합니다. 종료 시 버퍼의 사용 영역만 문자열로 변환합니다.
출력 수집 검증
test/codegraph-sandbox-runner.test.ts, docs/superpowers/specs/...
테스트가 Buffer.concat 미호출과 명령 결과를 확인합니다. 설계 문서가 바이트 한도 기반 메모리 제한 검증을 기록합니다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/codegraph-output-fragment-retention-20260912

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Current-head review on 3427e5a66d7a0ea9379ddc7915ba2b3d1872c492: no additional valid source, DDD/owner-boundary, documentation, or regression finding. The patch keeps CodeGraph command capture shell-free and fail-closed, replaces per-chunk retention/final concatenation with a fixed maxOutputBytes buffer, rejects an unfit chunk before retaining it, preserves timeout/kill/diagnostic semantics, and updates the canonical sandbox design plus executable regression. This is COMMENT-only review, not self-approval. Merge remains contingent on all required exact-head hosted gates reaching terminal success and a fresh pre-merge head/base/thread check.

@seonghobae
seonghobae marked this pull request as ready for review September 11, 2026 17:37
@seonghobae
seonghobae merged commit 36c786a into main Sep 11, 2026
17 of 18 checks passed
@seonghobae
seonghobae deleted the fix/codegraph-output-fragment-retention-20260912 branch September 11, 2026 17:37
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.

1 participant