Skip to content

Studio logs: prove the managed engine log family prunes - #19276

Merged
danielhanchen merged 1 commit into
mainfrom
ci/log-bounds-managed-engine-families
Nov 24, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci/log-bounds-managed-engine-families

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

studio/backend/tests/test_log_bounds.py fails on main in the backend (Python 3.13, g-l) shard. It also shows on staging runs, for example for #19113:

TestFamiliesAreBounded::test_every_python_written_family_prunes
  these log families are written but never pruned: sglang (sglang-*.log)
TestFamiliesAreBounded::test_a_new_family_cannot_be_added_unnoticed
  new log families: sglang

Cause

#19166 (per-attempt logs for managed SGLang) added the sglang family, and its logs are pruned: ManagedEngineLog.open calls prune_log_dir(directory, f"{engine}-*.log", protect = path) after opening each attempt's file. The guard could not see that, for two reasons:

  • it only reads run.py, log_retention.py, llama_cpp.py and lemonade_server.py;
  • it looks for the literal glob sglang-*.log, which an f-string never contains.

The reviewed list also did not name the new family. So this is a guard gap, not unbounded logs.

Fix

  • managed_engine_log.py: prune with the pattern it already reads from MANAGED_ENGINE_LOG_FAMILIES. It is the same value, but now the family table is the one place the glob is defined.
  • test_log_bounds.py:
    • managed engine families are proved by running the code. test_a_managed_engine_log_prunes_its_family_on_open is parametrised over MANAGED_ENGINE_LOG_FAMILIES. It fills a temp studio home with DEFAULT_KEEP + 5 old logs and opens a new one, then checks:
      • exactly DEFAULT_KEEP remain;
      • the new handle is kept;
      • the oldest is gone.
    • the source scan skips these families instead of grepping for their glob;
    • sglang joins the reviewed list. A future managed engine still fails test_a_new_family_cannot_be_added_unnoticed until someone adds it there, and the behavioral test covers it automatically.

Verification

  • test_log_bounds.py and test_managed_engine_logs.py: 17 passed. On main, 2 fail.
  • Sabotage:
    • replacing the prune_log_dir call with pass fails test_a_managed_engine_log_prunes_its_family_on_open[sglang];
    • adding a vllm entry to MANAGED_ENGINE_LOG_FAMILIES fails test_a_new_family_cannot_be_added_unnoticed.

#19166 added an sglang log family. ManagedEngineLog.open prunes it, but
with a glob built as f"{engine}-*.log" in a file test_log_bounds.py does
not read, so the source scan reported sglang-*.log as unbounded and the
reviewed list as missing it: two failures on main.

Prune with the family table's own pattern (same value), and check managed
engine families by running ManagedEngineLog.open against a log directory
already past DEFAULT_KEEP instead of grepping for the glob. sglang joins
the reviewed list; a new managed engine still has to be added there.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T14:17:16.615805Z 50c0409 Manual request
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 50c0409adf

ℹ️ 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".

@danielhanchen
danielhanchen merged commit c5a77cf into main Nov 24, 2026
2 of 38 checks passed
@danielhanchen
danielhanchen deleted the ci/log-bounds-managed-engine-families branch November 24, 2026 14:19
danielhanchen added a commit that referenced this pull request Nov 24, 2026
…9278)

## Problem


`studio/backend/tests/test_log_bounds.py::TestFamiliesAreBounded::test_a_new_family_cannot_be_added_unnoticed`
fails on main in the backend `(Python 3.13, g-l)` shard:

```
AssertionError: new log families:
    vllm
```

## Cause

#19167 (per-attempt logs for managed vLLM) added `"vllm": ("logs/vllm",
"vllm-*.log")` to `MANAGED_ENGINE_LOG_FAMILIES` while #19276 was adding
the review gate for those families. Both merged, so the gate reports the
new family as unreviewed. That is what the gate is for: a new log family
is a decision about disk growth.

## Review

The family is bounded. #19167 writes vLLM attempt logs through
`ManagedEngineLog.open`, which prunes the family's glob after opening
each file. `test_a_managed_engine_log_prunes_its_family_on_open[vllm]`
(added in #19276, parametrised over `MANAGED_ENGINE_LOG_FAMILIES`) runs
that path:

- it fills a temp studio home with `DEFAULT_KEEP + 5` old `vllm-*.log`
files and opens a new one;
- it checks that exactly `DEFAULT_KEEP` remain, that the new one is
kept, and that the oldest is gone.

It passes.

## Fix

Add `vllm` to the reviewed list in
`test_a_new_family_cannot_be_added_unnoticed`.

## Verification

- `test_log_bounds.py`: 7 passed. The cases include
`test_a_managed_engine_log_prunes_its_family_on_open[sglang]` and
`[vllm]`.
- On main, `test_a_new_family_cannot_be_added_unnoticed` fails with the
error above.
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