test(ci-workflows): add file-size ratchet gate - #4636
Conversation
Fails when a new tracked text file lands at 2000+ lines or an already-oversized file grows past its committed cap. Seeds 51 caps and 12 exact generated exemptions. No file is split here.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ Deterministic PR hygiene checks passed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45fca0ad62
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const baseline = loadBaseline( | ||
| readFileSync(repoPath("tests/fixtures/file-size-baseline.json"), "utf8"), | ||
| ); |
There was a problem hiding this comment.
Validate cap changes against the previous baseline
When a PR grows a grandfathered file and edits file-size-baseline.json to the new line count, this repository test loads only that modified fixture, so evaluate() reports UNCHANGED and CI passes. The restriction in ratchet:update does not enforce the invariant because the JSON can be edited directly; compare fixture changes with a trusted base revision and reject increased or newly grandfathered caps.
Useful? React with 👍 / 👎.
| const current = scanRepo(repoRoot); | ||
| if (process.argv.includes("--update")) { | ||
| const next = updateBaseline(current, baseline, !existed); | ||
| writeFileSync(baselinePath, `${JSON.stringify(next, null, 2)}\n`); |
There was a problem hiding this comment.
Write the baseline using atomic replacement
If ratchet:update is interrupted or the write fails after truncation, this direct overwrite can leave the committed baseline as partial JSON, after which both the test and subsequent update attempts fail in loadBaseline() and require manual recovery. Write a temporary file in the same directory and rename it over the baseline only after the complete write succeeds.
AGENTS.md reference: scripts/AGENTS.md:L16-L16
Useful? React with 👍 / 👎.
리뷰 · 우선순위 55 / 80이 PR은 #4546 비용 가드 스택이 아니라 godfile round2 / 파일 크기 ratchet 레인입니다. base는
판정은 다섯 가지입니다. 기준선에 없고 2,000줄 이상이면 라인 CI enforce-target - 이 PR base가 경로 tests/fixtures/file-size-baseline.json - 51개 캡이 한 번에 들어갑니다. 기준선 생성 시각·커밋 SHA를 픽스처나 스크립트 주석에 남겨 두면, 나중에 「왜 이 숫자인가」 논쟁을 줄입니다. 경로 scripts/file-size-ratchet.ts - 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
Pure move. state.ts 2432 -> 1355 with five leaves under src/responses/state/, shim.ts 2466 -> 1246 with six shim-* leaves. Public export surfaces are byte-identical in name; consumers keep their import paths.
Pure move. inject.ts 2342 -> 987 with five leaves, catalog/sync.ts 2698 -> 52 with seven leaves. INV-TOML-01 moves to inject/config-toml.ts and INV-AGENT-01 to catalog/subagent-roster.ts. Three source oracles that read these files as text are repointed in the same commit.
Pure move. routing.ts 3507 -> 1475 with six leaves, quota.ts 3313 -> 558 with five leaves. Dispatchers that would close a cycle stay on the facade. Retry budget scope is unchanged; no new attempt counter exists in any leaf.
Three identifiers lost their binding when the leaves were cut: the spill write-status types were re-exported from state.ts but never imported for local use, snapshot-codec lost OcxProviderContinuationState, and spill-queue lost existsSync. Caught by the translator-budget typecheck fixture on CI.
The inject and catalog leaves imported six symbols from modules that never exported them. Each one is re-pointed at where it is actually defined: parsing, account-models, subagent-roster, paths, desired-state. Import paths only; no declaration moved.
…ta split Fifteen symbols lost their binding: leaves that defined a symbol never exported it, quota type imports pointed at src/types instead of providers/quota-types, and isModelDetourAffinityScope lost its definition entirely while its call site survived. Imports and exports only; no declaration was moved or rewritten.
The leaf sits one directory deeper than routing.ts, so ../config resolved to src/codex/config, which does not exist. Every test shard that loaded the routing graph failed at import time.
refactor(codex,providers): split routing and quota behind facades
refactor(codex): split inject and catalog sync behind facades
refactor(responses,codex): split state and shim behind facades
Summary
새 파일이 2,000줄 이상으로 태어나거나 기존 초과 파일이 더 길어지는 것을 CI에서 막는다. 지금
dev에는 사람이 유지하는 2,000줄 이상 파일이 51개 있고, 이 PR은 그것들을 현재 길이로 고정하기만 한다. 파일을 쪼개지는 않는다.bun test에 얹는 이유는 base SHA를 git으로 구할 수 없기 때문이다..github/workflows/ci.yml의actions/checkout은 전부 기본fetch-depth: 1이고(:289-293은fetch-depth: 0을 명시적으로 거부한다) PR 체크아웃은refs/pull/N/merge단일 커밋이라origin/dev도 merge-base도 없다. 그래서 기준선을 저장소에 커밋된 숫자로 둔다.판정은 다섯 가지다. 기준선에 없고 2,000줄 이상이면
NEW_OVERSIZED로 실패, 기준선보다 길어지면GREW로 실패, 줄어들면 통과하고bun run ratchet:update가 캡을 내려 되돌아올 수 없게 한다.generated12경로는 면제다.devlog/,assets/,docs-site정적 자산,gui/dist,bun.lock과 화이트리스트 밖 확장자는 애초에 스캔하지 않는다.면제는 정확 경로만 받고 glob은 쓰지 않는다.
src/adapters/cursor/gen/아래에 손으로 쓴 파일이 새로 생기면 그것은 면제 대상이 아니라 새 초과 파일이어야 하기 때문이다.scripts/test-layout/layout.json의ci-workflows시드 정규식에는file-를 넣지 않았다. 넣으면 앞으로 생길 다른file-*.test.ts까지 이 도메인으로 끌어들인다. 대신 explicit 목록 양쪽에 한 줄씩만 추가했고,tests/test-layout-tooling.test.ts가 두 목록의 완전일치를 요구하므로 한쪽만 고치면 적색이 된다.Verification
bun scripts/file-size-ratchet.ts→file-size ratchet passedbun scripts/file-size-ratchet.ts --update→wrote tests/fixtures/file-size-baseline.json (51 caps),generated12경로 /files51항목node_modules가 없고 사용자 환경에서 스위트를 돌리지 않는 제약이 있어, 나머지 검증은 이 PR head의 hosted CI가 증거다.prepush문자열을 고정하는tests/ci-workflows/ci-workflows.test.ts:5294는 건드리지 않았다.ratchet:update는 키 추가만 한다.Checklist