Repository navigation
test: make the slowest tests fast without losing what they assert - #525
Merged
Merged
Conversation
With an active goal the scheduler queues a goal-origin run as soon as the goal is set. Under load it was claimed before the fixture's prompt, so the report counted the prompt's tool events (zero) while the goal run did the work. The fixture now follows the queued goal run, with a per-run turn cap that fits the scripted workload.
One checked goal now covers the real kills, waits, outages, interleaved prompts, achievement through the check, and then a replacement goal that runs out its deadline, which the unchecked soak used to prove.
The perf run keeps its 560 paced 1 KiB chunks. The test streams 8 KiB chunks with no pause, which still commits over 512 events, the gate it checks. The captured-output timeout test waits 100 ms instead of 1 s.
The in-run compaction scripts spawned about 640 shells only to produce 6 KB results. A test tool now returns the same stored bytes (the bounded 2,051-byte shell result), so every test compacts exactly as many times as before. The verbatim-goal test runs 30 turns instead of 72, which still compacts five times per row.
A 5 s limit made each case wait 5 s. On one loaded core the run needs about 520 ms to reach the hung summarizer (22 ms unloaded), so 500 ms failed under stress while 2 s passed 40 of 40.
Each run reads three 90 KiB notes instead of one, so the window-less session crosses the point where stale reads must be shed after about 40 runs instead of 140. The assertions are unchanged.
The first page is already covered by ab3_scan_cap_continuation_does_not_claim_an_exact_remainder; starting at line 40,000 still pages seven times into the terminal marker instead of 140 quadratic rescans.
The yield and timeout tests waited a real second per command. They now wait for the command's first output (or its pid report), then pause and advance the clock, as running_build_survives_clock_advance does. The timeout message test and the process-group timeout test ran the same 1 s timeout; they are one test now.
Store::open keeps the 1.5 s ownership wait; the two busy-store tests open through an internal variant with a 50 ms wait and still assert the refusal waited at least that long.
The test ran 64 shell turns to show a cd-prefixed read never triggers a stall report. That follows from the call counting as progress, so it now runs the command once and checks the receipt is work and is_progress is true. The stall counter's reset is unit-tested in runtime/progress.rs, and ab1_verified_exec_reads_report_on_request_sixty_five keeps the end-to-end 64-call run.
The final-slot rules depend on the last and next-to-last runs, not on there being ten. The test passes at both RUNS = 10 and RUNS = 3.
…e permission matrix The close drain is guarded by the draining flag under the lifecycle lock, so one pass covers it; 30 stress iterations pass. The permission selection matrix creates a fresh stored session per row in one store instead of opening 16 stores.
Each request built a reqwest client with platform TLS roots. The client is built once per test thread now, so command_routes_match_the_protocol_table runs in 27 ms instead of 0.77 s here (2.9 s on CI).
with_endpoint is test-only and built a rustls client with platform roots per call; the header-rejection tests only reject headers. The effort matrix compiled 21 providers with a new compiler each; it reuses one per thread now.
…window The test filled nearly 4 MiB of history to reach the storage backstop. A 128 Ki-token window compacts at about 0.5 MiB and still leaves the 16,384-token cap uncapped by the summarizer's window/8 rule.
…atrix The 15-row matrix opened a store per row. The policy authority is the only per-runtime input, so one runtime with each authority serves every row, each in its own workspace and session.
child_budget and exceeded now carry every limit family as unit rows. The end-to-end delegation tests keep one known-spend and one unknown-spend row each, and the nested receipt test corrupts and restores one store instead of building three.
A test-only tool_calls_per_slice on Runtime (carried through the agent profile into the compiled plan) replaces MAX_TOOL_CALLS_PER_SLICE in the checkpoint test; production builds keep the constant. The full 256-call continuation stays end to end, and the empty-checkpoint billing test now checks the exact cost instead of a lower bound.
Collaborator
Author
|
@codex review |
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. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #524.
Change
The slowest tests now run fast, and each one still checks what it checked before. This covers findings D1–D19, except D10 and D20, which earlier PRs already did. Production behavior is unchanged: the only new knobs are test-only (
#[cfg(test)]) or an internal parameter whose production default is unchanged.It also fixes the follow-up from #523: the
qq-core::soak goal_enabled_soak_measures_real_notices_across_compactionflake.Flake cause. The brief recorded the failing field as
work_requests_with_goal, but the failing assertion is soak.rs:44,durable_calls == 72, which read 0. When the fixture sets an active goal, the scheduler queues a goal-origin run at once. On a loaded core that run is claimed before the fixture's own prompt. It does all 72 work turns, while the report countsToolCallFinishedfor the prompt run, which did none. Per-runRunStartedlogging showed the goal-origin run starting first in every failure. Fix: the goal-mode fixture now measures the goal run that the scheduler queues (Fixture::goal_run), with a per-run turn cap that fits the 72-turn script. The goal-modeturn_overheadbench uses the same fixture and still passes its asserts (QQ_BENCH_GOAL=1 QQ_BENCH_ITERATIONS=1 cargo bench -p qq-core --bench turn_overhead).docs/runbooks/perf-recording.mdnow says the goal mode measures the goal run.What changed, by item:
multi_day_driver_survives_real_process_kills_waits_and_outages. It runs 22 steps with two real process kills, three waits, two interleaved prompts, two outages, and achievement through the real check. It then replaces the goal and runs the deadline to exhaustion, which the old unchecked variant used to prove. The reopen and no-recharge assertions are unchanged. It stays in thesoakgroup (themulti_day_filter still matches).busy_workspacefixture's pacing is now a parameter. The perf run keeps 560 × 1 KiB chunks with 10 ms pauses. The test streams 505 × 8 KiB chunks with no pause and still commits over 512 events, the same gate. The captured-output timeout test waits 100 ms instead of 1 s.timeout_seconds: 3still runs.sh640 times to make 6 KB output. A test tool now returns the same stored 2,051-byte bounded shell result. Each test sees exactly as many compactions as before, which I checked by logging the counts on both trees.maximum_goal_is_verbatim…runs 30 turns instead of 72 and still compacts five times per row (the test asserts at least three).ab3_scan_cap_continuation_does_not_claim_an_exact_remainder.a_shell_timeout_names_its_limit_and_how_to_raise_itandshell_timeout_kills_the_whole_process_groupran the same 1 s timeout and are now one test,shell_timeout_kills_the_whole_process_group_and_names_its_limit, with both sets of assertions.Store::openkeeps its 1.5 s ownership wait. The two busy-store tests open through an internalopen_waitingwith a 50 ms wait and still assert that the refusal waited at least that long. I did not add the other D9 limits (see Known impact).tool_calls_per_sliceonRuntimereaches the run loop through the agent profile. Production builds still useMAX_TOOL_CALLS_PER_SLICE. The slice-report tests run with a 32-call slice.one_durable_run_continues_across_the_internal_tool_budget(and the text-only slice-report audit test) keep the full 256-call continuation. The empty-checkpoint billing test now checks the exact cost instead of> 61_700.is_progressis true.ab1_verified_exec_reads_report_on_request_sixty_fivekeeps the 64-call end-to-end run.RUNSand uses 3; it also passes at 10. It is renamed fromgoal_tenth_run_…togoal_final_run_…because the old name would now be false, and.config/nextest.tomlis updated to match.drainingflag is checked under the lifecycle lock, so the drain is deterministic, and 30 stress iterations passed. The permission-selection matrix now uses one store, with a fresh session per row.with_endpointis test-only, and it now reuses one rustls client per thread. The effort matrix reuses one compiler per thread.window/8rule leaves 16,384 uncapped.BudgetMeter:child_budgetaftercharge_child, andexceededafter an audit's spend, one row per limit family. A mutation that dropped the output-token check failed the new table. End to end, each delegation test keeps one known-spend row and one unknown-spend row, and the nested-receipt test corrupts and restores one store instead of building three.Verification
Timings are local, from
cargo nextest run --workspace --profile ci --all-featureson 32 cores,junit.xmltimeper test.Full workspace, total test-seconds: 235.9 s → 170.5 s (172.0 and 178.8 on two re-runs under load 5–6 from a preceding check). Wall time 12.7 s → 5.7 s.
multi_day_*(two tests → one)busy_workspace_fixture_seeds_a_long_historycaptured_output_timeout_kills_and_reaps_the_process_groupcancel_and_timeout_kill_descendants_that_left_the_groupmaximum_goal_is_verbatim_immediately_after_three_in_run_summariesan_in_run_summary_cut_at_the_output_limit_is_continued_and_joined_verbatiman_in_run_marker_survives_restart_and_folds_into_a_later_between_run_compactionan_in_run_summarizer_keeps_the_session_context_before_its_promptone_run_spanning_several_windows_compacts_its_own_turns_and_completesan_empty_faulted_attempt_inside_the_replaced_span_keeps_replay_equal_to_livea_dense_tokenizer_compacts_in_run_instead_of_failing_at_the_guardcancelling_during_in_run_compaction_settles_both_runs_oncea_rejected_in_run_summary_fails_the_run_closed_without_resending_the_overflowan_in_run_compaction_that_cannot_start_fails_the_prompt_run_as_a_server_failurea_provider_window_rejection_compacts_the_run_and_continuesstopping_a_pending_summarizer_preserves_measured_turns_and_unknown_totalsoriginal_deadline_stops_a_summarizer_backoff_without_retryinga_session_without_a_window_still_sheds_stale_reads_before_the_storage_backstopab3_scan_cap_offsets_remain_readable_until_a_terminal_markera_run_follows_a_yielded_command_and_stops_the_rest_when_it_endsyielded_commands_stop_on_cancel_and_on_teardowna_yielded_escaped_tree_dies_when_the_run_endssaturated_live_output_never_masks_the_shell_timeouta_long_command_yields_and_completes_through_command_statusshell_timeout_kills_the_whole_process_group_and_names_its_limit(two tests → one)a_store_has_one_owner_and_a_busy_store_is_refused_without_mutationa_busy_store_is_refused_before_the_database_is_createdab1_cd_prefixed_reads_without_context_verification_count_as_workgoal_final_run_reserves_a_durable_tool_free_handoff_after_early_completionclosing_goal_host_drains_accepted_work_without_admitting_successorssession_resume_permission_selection_is_shared_by_prompt_and_goalcommand_routes_match_the_protocol_tableevery_effort_reaches_responses_standard_codex_and_chat_transportrejects_*headerstestscompaction_sends_and_persists_the_effective_output_capauto_goal_checks_derive_contained_authority_without_human_consentbudgeted_read_children_refuse_exhausted_or_unknown_remaindersaudit_overspend_and_unknown_spend_exhaust_the_parentnested_spend_receipt_rejects_incomplete_or_overflowing_descendantsStress (taskset recipe: three busy loops pinned to core 0,
--retries 0):goal_enabled_soak_measures_real_notices_across_compaction, before: 1/40, 3/60, 8/30 and 12/60 failed, all ondurable_calls0 ≠ 72. After the fix: 60/60 passed.cancel_and_timeout_kill_descendants_that_left_the_group40/40 passed. The six D7 tests together: 40/40 passed.captured_output_timeout…at 100 ms: 200/200 passed. The D5 pair at 2 s: 40/40 passed; at 500 ms, 10 of 40 failed on "the second summary request must really hang", which is why I kept 2 s.closing_goal_host_drains…, unloaded: 30/30 passed.Commands:
cargo xtask check --full: passed on the head commit (fmt, lint, clippy, workspace tests with soak, minimal provider profile).cargo clippy -p qq-core --all-targets --no-default-features -D warnings: passed.goal_final_run_…is updated in.config/nextest.toml. The merged and deleted tests (multi_day_checked_goal_achieves_after_forty_runs_and_real_process_kills,a_shell_timeout_names_its_limit_and_how_to_raise_it,shell_timeout_kills_the_whole_process_group) were not named in.config/nextest.toml,.config/platform-tests/*.txt,.config/quarantine.toml,.githubordocs(checked with grep). The real-process regex still matches the merged timeout test.goal_driver_soakis now#[cfg(unix)]as a module, because its only test needs a realshcheck. It was never in a Windows platform list.Deleted or merged tests:
multi_day_checked_goal_achieves_after_forty_runs_and_real_process_kills: merged intomulti_day_driver_survives_real_process_kills_waits_and_outages, which now covers the checked-goal achievement and then the deadline exhaustion of a replacement goal.a_shell_timeout_names_its_limit_and_how_to_raise_itandshell_timeout_kills_the_whole_process_group: merged intoshell_timeout_kills_the_whole_process_group_and_names_its_limit. Both ran the same 1 s timeout, and the merged test has both sets of assertions.input_tokens,output_tokens,costandtokens_unknownrows inbudgeted_read_children_…, and theInputTokens,OutputTokens,CostandTokensUnknownrows inaudit_overspend_…. They are now unit rows inruntime::budget::tests::{a_settled_child_spends_each_bound_or_makes_it_unknown, an_overspending_or_unmeasured_child_exceeds_its_parent}.Known impact
FEED_CAPACITY,EVENT_JOURNAL_ROWS,MAX_SESSION_SPILL_BYTES,MAX_SESSION_FILESand history-scan-budget tests run 0.4–1.2 s each locally. Making them injectable means threading a store-wide option throughappend_eventand the tool-call writers, which every write calls. That is more production surface than about 3 s of local test time justifies, so I left them.goal_check_process_timeout_and_binary_output_stay_bounded(2 s, a real 2 s check deadline, A6) anddeadlines::duration_waits_for_blocking_attachment_guidance_and_skill_cleanup(2.4 s). I listed them as follow-ups.Runtimegains atool_calls_per_slicefield that equalsMAX_TOOL_CALLS_PER_SLICEoutside tests.Store::openkeeps its 1.5 s wait.