Skip to content

fix(agent-runtime): bound current workflow-state response - #652

Merged
seonghobae merged 6 commits into
mainfrom
fix/procedural-current-lifecycle-response-bound-20260912
Sep 11, 2026
Merged

fix(agent-runtime): bound current workflow-state response#652
seonghobae merged 6 commits into
mainfrom
fix/procedural-current-lifecycle-response-bound-20260912

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Finding

Fresh protected main@549c1fbe631e4c1e001900419772a2ffd779fe97 lets src/agent-runtime/procedural-current-lifecycle.ts call Response.json() directly on the private Workflow / Task Execution Durable Object response before lifecycle-evidence admission. A corrupt or unexpectedly large internal response can therefore be buffered and parsed without a retained-byte ceiling before the ACL fails closed.

Reality RED

Test-only exact e003f8fdd47453fa3346b0ba7dff1642d9e1594d added the hostile high-fragmentation response stream. Hosted application CI 34644754403 checked out that exact head, passed toolchain/install/typecheck, and failed at release tests, establishing the required source RED without changing production semantics.

Causal repair and follow-up RCA

The production repair replaces Response.json() with a fixed 1 MiB retained buffer, chunk-wise pre-copy ceiling enforcement, cancellation on oversize, reader-lock cleanup, fatal UTF-8 decoding, JSON admission, and the existing exact execution/plan/task validation. It remains a narrow Agent Runtime ↔ Workflow / Task Execution ACL and does not create lifecycle, task, retry, tool, Policy / Approval, provider-routing, quarantine, security, or outbound authority.

Exact 7dd85e831788bd0b2b6f638d31861ff5856a7382 exposed a Worker type-contract failure because Cloudflare's TextDecoderConstructorOptions requires an explicit ignoreBOM; exact c1184a3b25e2b45af1b810a2817a2d12ecaa91c5 fixed that with ignoreBOM:false, preserving ordinary JSON BOM handling. Its application CI 34647774968 then passed typecheck and all 4,710 tests but correctly failed the repository-wide 100% coverage gate on the newly added malformed non-byte chunk branch. Exact 23fabd95f3ef886c6bef0ae9ff6ead50dc0ce342 adds that hostile fixture instead of deleting the fail-closed branch.

Exact-head GREEN

Current exact 23fabd95f3ef886c6bef0ae9ff6ead50dc0ce342 is GREEN on all fresh hosted gates: application CI 34648179930, reviewer-ci 34648179936, required Security Scan 34648179953, and patch-validator-image 34648179940. Application CI also passed the release tests, release security/KPI/license/acquisition checks, and the final live-base drift refusal on this exact. Predecessor evidence is not reused.

Boundary retained

This source integration is not an immutable Noema release, deployed Durable Object latency/recovery evidence, graph publication, or activation authority. ADR-0017 remains Proposed, and external released contract/trust prerequisites remain owned by their canonical repositories.

Summary by CodeRabbit

  • 버그 수정

    • 현재 워크플로 및 작업 실행 응답을 최대 1MiB까지 안전하게 처리합니다.
    • 응답이 크기 제한을 초과하거나 본문이 비어 있는 경우 오류로 처리하고 추가 데이터 읽기를 중단합니다.
    • 잘못된 형식의 데이터, UTF-8 디코딩 실패, JSON 파싱 오류 및 스트림 읽기 실패를 일관된 진단으로 제공합니다.
  • 테스트

    • 대용량 응답, 빈 본문, 잘못된 데이터 청크, 스트림 오류 상황을 검증하는 테스트를 추가했습니다.

@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: cf20845d-a2e4-48f4-9029-124a14aa9511

📥 Commits

Reviewing files that changed from the base of the PR and between 549c1fb and 23fabd9.

📒 Files selected for processing (2)
  • src/agent-runtime/procedural-current-lifecycle.ts
  • test/procedural-current-lifecycle-response-bounds.test.ts

📝 Walkthrough

Walkthrough

현재 워크플로 응답에 1 MiB 크기 제한을 적용한다. 초과, 빈 본문, 비바이트 청크, 읽기, UTF-8, JSON 파싱 실패는 invalid_workflow_state_response로 처리한다. 관련 동작을 테스트한다.

Changes

현재 워크플로 응답 경계 처리

Layer / File(s) Summary
제한된 응답 리더 구현
src/agent-runtime/procedural-current-lifecycle.ts
응답 본문을 최대 1 MiB까지 고정 버퍼에 읽는다. 크기 초과 시 스트림을 취소한다. 본문, 읽기, UTF-8 디코딩, JSON 파싱 실패를 invalid_workflow_state_response로 정규화한다.
응답 경계 검증 테스트
test/procedural-current-lifecycle-response-bounds.test.ts
초과 응답의 조기 취소, 빈 본문, 비바이트 청크, 스트림 읽기 실패가 실패-폐쇄 진단을 반환하는지 검증한다.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant 실행 가이드
  participant 현재 상태 리더
  participant 응답 스트림
  participant JSON 파서
  실행 가이드->>현재 상태 리더: 현재 워크플로 상태 요청
  현재 상태 리더->>응답 스트림: 응답 청크 읽기
  응답 스트림-->>현재 상태 리더: 바이트 청크 반환
  현재 상태 리더->>현재 상태 리더: 1 MiB 한도 확인
  현재 상태 리더->>JSON 파서: UTF-8 텍스트 파싱
  JSON 파서-->>현재 상태 리더: 상태 데이터 또는 파싱 실패
  현재 상태 리더-->>실행 가이드: 상태 데이터 또는 invalid_workflow_state_response
Loading
✨ 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/procedural-current-lifecycle-response-bound-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 complete on 23fabd95f3ef886c6bef0ae9ff6ead50dc0ce342. The hosted RED is preserved, both follow-up CI defects were repaired rather than bypassed, malformed-stream coverage now exercises the added fail-closed branch, and application/reviewer/security/patch-validator gates are all fresh GREEN on this exact. No additional source, ownership-boundary, DDD, test/coverage, or merge-blocking finding remains in the two-file diff. This is COMMENT-only review; no self-approval is asserted.

@seonghobae
seonghobae marked this pull request as ready for review September 11, 2026 21:24
@seonghobae
seonghobae merged commit ac762f1 into main Sep 11, 2026
17 of 18 checks passed
@seonghobae
seonghobae deleted the fix/procedural-current-lifecycle-response-bound-20260912 branch September 11, 2026 21:24
seonghobae added a commit that referenced this pull request Sep 11, 2026
…ent-response-bound-20260912

docs(agent-runtime): classify #652 as protected response-bound authority
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