Skip to content

fix(integrations): bound managed config reads and writes - #7029

Merged
lidge-jun merged 2 commits into
devfrom
fix/integration-config-bounds
Oct 13, 2026
Merged

lidge-jun merged 2 commits into
devfrom
fix/integration-config-bounds

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Based on #7017 by @luvs01.

Managed integration configs (Cline, Kilo, Aside and other client files OpenCodex edits) were read with an unbounded readFileSync, so an oversized or special file could be loaded whole before parsing. Reads now go through a bounded regular-file descriptor that refuses final symlinks, FIFOs/devices and files over 4 MiB. Writes refuse merged configs and Cline recovery markers past the same bound before any mutation, and the unused pre-write snapshot is discarded through the state store when that refusal happens.

This carries the two in-scope commits from #7017 unchanged (authorship preserved). The two unrelated test-hardening commits (generation-child diagnostics, Windows tray probe readiness) are left out to keep this PR on one topic.

Verification

  • bun run typecheck
  • bun test tests/lib/bounded-file-read.test.ts tests/clients/{aside-profiles,cline-writer,integrations-journal,integrations-state,integrations-writer}.test.ts tests/test-layout*.test.ts: all new and changed cases pass. One pre-existing TOML-date failure in integrations-state.test.ts reproduces identically on origin/dev with local Bun 1.3.14 (CI pins 1.4.x).
  • Full CI on this PR.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Co-authored-by: Epinephrine [email protected]

Summary by CodeRabbit

  • Bug Fixes

    • Managed configuration files are now limited to 4 MiB. Oversized files are rejected without changing the original file.
    • Failed writes avoid leaving unnecessary recovery snapshots; recovery information is retained when cleanup cannot be confirmed.
    • Oversized configuration files are reported as unreadable rather than treated as missing.
  • Documentation

    • Updated the integrations guide with the file-size limit and steps for reducing configurations or managing larger files manually.

luvs01 and others added 2 commits October 13, 2026 16:01
Refuse oversized and non-regular managed configuration inputs, apply the same 4 MiB write bound before target mutation, and retain committed or uncertain snapshots.

Read small files into initialized size-proportional buffers while preserving growth and overflow probes. Preserve store-owned cleanup for unused snapshots and all current upstream test registrations.

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Separate oversized-file rejection from final-symlink rejection. Probe file-symlink creation on Windows and mark only that test skipped for EPERM/EACCES; preserve other errors and execute the rejection check when creation succeeds.

The oversized assertion already preceded link creation, but an unavailable link privilege failed the combined test. Keep byte-boundary coverage unconditional and record actual symlink skips.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 13, 2026 07:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T07:06:48.650838Z c75a987 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 942bd5ec-c813-40fd-8f4e-44044a0bb244
📥 Commits

Reviewing files that changed from the base of the PR and between e6d7e56 and c75a987.

📒 Files selected for processing (16)
  • docs-site/src/content/docs/guides/integrations.md
  • scripts/test-layout/layout.json
  • scripts/test-layout/seeds.json
  • src/integrations/config-io.ts
  • src/integrations/journal.ts
  • src/integrations/store.ts
  • src/integrations/writer.ts
  • src/lib/bounded-file-read.ts
  • structure/clients/integrations.md
  • tests/clients/aside-profiles.test.ts
  • tests/clients/cline-writer.test.ts
  • tests/clients/integrations-journal.test.ts
  • tests/clients/integrations-state.test.ts
  • tests/clients/integrations-writer.test.ts
  • tests/fixtures/test-layout-expected.json
  • tests/lib/bounded-file-read.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

Managed integration configuration reads and writes now enforce a 4 MiB limit. A bounded file reader rejects oversized or non-regular files. When a size refusal occurs after snapshot creation, the writer attempts guarded snapshot cleanup.

Changes: Managed configuration size limits

Layer / File(s) Summary
Bounded reads and configuration size enforcement
src/lib/bounded-file-read.ts, src/integrations/config-io.ts, tests/lib/bounded-file-read.test.ts, tests/clients/integrations-state.test.ts, docs-site/src/content/docs/guides/integrations.md, structure/clients/integrations.md, scripts/test-layout/*, tests/fixtures/test-layout-expected.json
Managed configuration reads use a bounded regular-file reader, and writes reject UTF-8 content above 4 MiB. Tests cover file type, size boundaries, and file changes during reads. Documentation describes the limit and refusal outcomes.
Snapshot cleanup after write refusal
src/integrations/journal.ts, src/integrations/store.ts, src/integrations/writer.ts, tests/clients/integrations-journal.test.ts, tests/clients/integrations-writer.test.ts, tests/clients/aside-profiles.test.ts, tests/clients/cline-writer.test.ts, structure/clients/integrations.md
The journal and store expose guarded deletion of uncommitted snapshots. After a size refusal, the writer attempts cleanup when a snapshot exists. Tests cover preserved snapshot evidence, cleanup failures, and repeated write refusals.

Priority: ⬇️ Low

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant IntegrationWriter
  participant ConfigIO
  participant IntegrationStateStore
  participant Journal
  IntegrationWriter->>ConfigIO: writeText with serialized configuration
  ConfigIO-->>IntegrationWriter: throw IntegrationWriteSizeError
  IntegrationWriter->>IntegrationStateStore: discardUncommittedSnapshot
  IntegrationStateStore->>Journal: check journal and ownership records
  Journal-->>IntegrationStateStore: remove snapshot only if no evidence references it
  IntegrationStateStore-->>IntegrationWriter: return cleanup result
Loading
Merge Risk: ⚪ Minimal · up to c75a9

The bounded reads and writes have no identified merge-blocking issue. The snapshot-cleanup path does not discard recovery evidence after a target mutation.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 11 files. (5 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: applying size bounds to managed integration configuration reads and writes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 11 files. (5 skipped: 5 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions github-actions Bot added the bug Something isn't working label Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration into dev under MAINTAINERS.md (admin dev-only PR bypass). Exact-head CI evidence: all 35 checks green on c75a9878a8f70cf49b3dd0e3de111bf2c6852a22 (test 1–4/4, windows 1–9/9, enforce-target, privacy/structure gates). Replaces #7017 by @luvs01 with its two in-scope commits; authorship preserved.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants