Skip to content

[code-review] Code-review cleanup: vacuous and host-dependent assertions in crates/orbit-cli/tests/workspace - #8971

Merged
orbit-agent-01 merged 1 commit into
agent-mainfrom
orbit/ORB-23827-7033c354
Nov 10, 2026
Merged

orbit-agent-01 merged 1 commit into
agent-mainfrom
orbit/ORB-23827-7033c354

Conversation

@orbit-agent-01

Copy link
Copy Markdown
Contributor

Task

ORB-23827 — [code-review] Code-review cleanup: vacuous and host-dependent assertions in crates/orbit-cli/tests/workspace

Description

Grouped low/nit findings from the code-review sweep of module dir:crates/orbit-cli/tests/workspace (22,275 lines, 40 files) at agent-main @ ad6324277cd9a7d607bd7c09b0f1a1941d553c81. Every finding was re-verified against the pinned tree. All are test-suite defects (no product behavior is wrong); each lets a real regression pass unnoticed or makes a test depend on ambient host state.

Findings

  1. [low] Replica "never mints auto-tasks" assertion reads a key the CLI never emits — crates/orbit-cli/tests/workspace/replica_routines.rs:508-513 (exercise_routine_settlement). The check reads fired["auto_task_reports"], but orbit sweep --format json has no such key: crates/orbit-cli/src/command/clock/tick.rs:220-284 merges auto-task rows into reports with kind: "auto_task" and exposes a top-level minted. is_none_or(..) is therefore always true, and the enable_auto_task edit at 893-902 is never asserted to have taken effect. Fix: assert on the real shape (no reports row of kind auto_task evaluated/minted, minted empty) and assert the seed edit applied. Culprit: ORB-14173 (85118e8, PR Allow replica-local scheduled worktree GC with honest routine control capabilities #3320; the shape was already reports at that commit) — defect_in_new / no_test.
  2. [low] Clock-unit doctor test passes regardless of the unit's deadline/kill mode on hosts without the timer — crates/orbit-cli/tests/workspace/sweep_root.rs:141-182 (doctor_flags_an_installed_clock_without_deadline_or_descendant_cleanup). It asserts only status warning plus the remediation string. Since ORB-16351 (0edd136) clock_unit_row / apply_clock_manager_readiness (crates/orbit-cmd/src/doctor/report.rs:611-675) fold in the live systemctl --user timer state (crates/orbit-clock/src/status/query.rs:12-58), and the fixture command (sweep_root.rs:219-243) overrides only HOME/USERPROFILE. On a host with no enabled+active orbit-sweep.timer both assertions hold whatever the unit file contains, and the outcome depends on ambient host state. Fix: isolate the manager query in the fixture (e.g. a stub systemctl on PATH reporting a healthy timer) and assert on the deadline/cleanup-specific detail. Culprit: ORB-16351 — broke_existing / no_test (test written by ORB-14592).
  3. [low] Age-floor helpers also zero scratch_older_than_hours — crates/orbit-cli/tests/workspace/worktree_gc_routing.rs:560-606 (zero_worktree_gc_age_floor, replace_seeded_older_than_hours_default) and crates/orbit-cli/tests/workspace/replica_routines.rs:906-923 (zero_worktree_gc_age_floor). The substring match on older_than_hours: also rewrites scratch_older_than_hours: 24 (crates/orbit-core/assets/jobs/worktree_gc_pipeline.yaml:21), contrary to the helper's doc, so fixture sweeps prune .orbit/tmp with a 0-hour floor (crates/orbit-engine/src/executor/automation/mod.rs:126-131). Same area: the comment at worktree_gc_routing.rs:241-243 says the seed defaults to a 24h floor (asset line 16 says 1), and enable_worktree_gc_routine (608-616) replaces enabled: false although the asset ships enabled: true (a no-op) and never asserts its cron replace applied. Fix: match the key at line start/exact key, assert each replace changed the text, correct the comment. Culprit: ORB-14432 (9a3e046 added the scratch key after the helpers existed) — broke_existing / no_test.
  4. [low] Exact-stderr assertions run with inherited RUST_LOG — crates/orbit-cli/tests/workspace/generation_root.rs:412-422 (orbit fixture) does not neutralise RUST_LOG (not in INHERITED_AUTHORITY_ENV, crates/orbit-common/src/test_env/env.rs), while clock_ticks_during_generation_hold_emit_one_dated_summary_on_resume asserts refused.stderr.is_empty() (313-316) and exactly one stderr line (324-325). A developer shell with RUST_LOG=debug fails it. Sibling fixtures set RUST_LOG=off or remove it (deployment_gc.rs:52, doctor_confirm.rs:45, the init_* fixtures). Same gap in host_fleet.rs:144-159 (Fleet::process). Fix: neutralise RUST_LOG in both fixtures. Culprit: ORB-13013 (c2e94f9 added the assertions) — defect_in_new / nondeterministic.
  5. [nit] Ordering assertion compares Options — crates/orbit-cli/tests/workspace/host_registry.rs:133-137 (host_add_reads_identity_from_the_remote_and_refusals_leave_the_file_untouched): written.find(a) < written.find(b) passes when the first needle is absent (None < Some(_)). Fix: require both positions to be Some before comparing. Culprit: ORB-14448 (8023d01) — defect_in_new / no_test.
  6. [nit] Help-prose pin — crates/orbit-cli/tests/workspace/workspace_source_remote.rs:575-602 (source_remote_help_names_inspection_dry_run_and_rebind) pins help wording via contains() ("roll back", "publication bindings", "Credentials", "first source identity"), which the repo guide's test rules disallow (text-matching / wording pins; help text is covered by goldens). Fix: retire the wording asserts or reduce to structural checks (flags exist), naming the surviving golden coverage. Written by ORB-11426 (451c5f8, 2026-09-06). Unattributed: the evidence does not show the no-wording-pin rule predates that commit, so no regression_from link is recorded for it.

Scope

Test-only changes inside crates/orbit-cli/tests/workspace. No product code change is expected. Each corrected assertion must be shown to fail when the guarded behavior is broken (e.g. temporarily perturb the fixture) and pass on the current tree.

Acceptance Criteria

  • replica_routines.rs asserts the replica no-auto-task guarantee against keys orbit sweep --format json actually emits (reports rows of kind auto_task, minted), and asserts the enable_auto_task seed edit applied.
  • The clock-unit doctor test in sweep_root.rs no longer depends on the host's real systemctl --user timer state and fails if the unit's missing deadline/descendant-cleanup stops being reported.
  • The worktree-GC age-floor helpers in worktree_gc_routing.rs and replica_routines.rs change only older_than_hours, leave scratch_older_than_hours untouched, assert their replacements applied, and the stale 24h comment and the no-op enabled replace are corrected.
  • The generation_root.rs and host_fleet.rs process fixtures neutralise RUST_LOG, so the stderr assertions pass with RUST_LOG=debug exported.
  • The host_registry.rs ordering assertion fails when either needle is absent.
  • The help-prose contains() pins in workspace_source_remote.rs are retired or reduced to structural checks, with surviving coverage named in the execution summary.
  • The affected tests pass: cargo nextest run -p orbit-cli --test workspace (or the equivalent cargo test -p orbit-cli --test workspace) for the touched test modules.

Execution Summary

Click to expand

Outcome: test-only repair of six vacuous or host-dependent assertions under crates/orbit-cli/tests/workspace. No product code changed. Perturbations used to show each new assertion fail were restored before handoff; the diff is only the seven test files.

Changes:

  • replica_routines.rs: assert_no_replica_auto_task reads the sweep JSON that orbit sweep --format json actually emits. A replica source on a reports row of kind auto_task fails the test. minted must be a count equal to the number of auto_task rows with action minted, and this fixture must mint zero. enable_auto_task requires a seeded enabled: false line, replaces it with enabled: true, and asserts the text changed and the write stuck. zero_worktree_gc_age_floor rewrites only a line whose trimmed text starts with older_than_hours: and is an integer, asserts that rewrite changed the file and left the scratch_older_than_hours line byte-identical.
  • sweep_root.rs: the Linux clock-unit doctor test prepends a stub systemctl on PATH for that invocation only. The stub reports an enabled, active orbit-sweep.timer and a service that already has TimeoutStartUSec=10min and KillMode=mixed, so a healthy host timer cannot satisfy the check and a live service warning cannot stand in for the unit file. The test requires status warning and a message naming missing finite TimeoutStartSec and missing KillMode=mixed.
  • worktree_gc_routing.rs: the same exact-key age-floor rewrite, with the call-site comment corrected to the seeded one-hour floor (scratch stays seeded). enable_worktree_gc_routine asserts the seed is already enabled: true and that replacing cron: "35 * * * " with cron: " * * * *" changes the file. The old enabled: false replace was a no-op against the shipped asset.
  • generation_root.rs orbit() and host_fleet.rs Fleet::process set RUST_LOG=off after clearing inherited authority.
  • host_registry.rs compares entry order only when both name needles are Some.
  • workspace_source_remote.rs drops help-prose contains() pins. The row checks that source-remote help lists the show and rebind subcommands, that rebind help lists --dry-run and --remote as whitespace tokens, and that workspace init help lists --force.

Criteria:

  1. Met. Replica no-auto-task is asserted on reports kind auto_task and on minted. enable_auto_task asserts the seed edit. The real sweep kept minted at 0, so that assert was not weakened.
  2. Met. The doctor test no longer calls the host systemctl. A temporary safe unit (TimeoutStartSec=10min, KillMode=mixed) made doctor report clock-unit status ok ("runs this binary") and the warning assertion failed at sweep_root.rs:179. Restored.
  3. Met. Both helpers match the key at the start of the trimmed line. A temporary split_once("older_than_hours:") rewrite made the scratch assert fail in both files: the numeric scratch_older_than_hours: 24 line disappeared and the first remaining scratch line was the template. The cron replace assert failed when the replace was a no-op ("worktree_gc cron replace was a no-op"). The passing worktree_gc_contracts run reported scratch retention_hours 24. Restored.
  4. Met. With the fixtures setting RUST_LOG=off, RUST_LOG=debug cargo test of generation_admission_contracts_0 and host_registry_contracts_0 passed (2 passed). Removing the generation_root override failed the empty-stderr assert on a DEBUG orbit::entry::run line. Removing the host_fleet override made host add's refusal JSON parse fail because those DEBUG lines landed on stderr. Restored.
  5. Met. An absent build-box needle failed with alpha=Some(30) build-box=None. An absent alpha needle failed with alpha=None build-box=Some(142); the old Option ordering would have treated None < Some as success. Restored.
  6. Met. Help prose pins (roll back, publication bindings, Credentials, first source identity, verify) are gone. There is no help_goldens case for workspace source-remote or workspace init, so nothing golden was added. Surviving behavioral coverage in this module: owner_can_dry_run_apply_read_back_and_retry_source_remote_rebind, credential_bearing_rebind_is_redacted_and_does_not_mutate, force_init_binds_first_origin_and_preserves_task_partition_and_publication, force_init_recovers_identity_with_an_unchanged_non_portable_origin, force_init_rejects_invalid_origins_before_first_binding_and_on_retry, force_init_cannot_bind_first_origin_from_a_replica_or_foreign_owner. A temporary --not-a-flag check failed while --force was still listed. Restored.
  7. Met. After restore, scripts/build-budget.py -- cargo test -p orbit-cli --test workspace -- sweep_command_contracts_1 source_remote_contracts_1 generation_admission_contracts_0 host_registry_contracts_0 replica_fires_only_its_worktree_gc_routine_and_owner_scheduling_is_unchanged worktree_gc_contracts passed: 6 passed, 0 failed, 114 filtered out, 6.82s. Those runners contain the touched cases. The full unfiltered workspace binary was not run.

Validation:

  • make ci-guards: passed.
  • cargo fmt --all -- --check: passed.
  • rustfmt --check --edition 2024 on the seven test files: passed.
  • scripts/build-budget.py -- cargo clippy -p orbit-cli --bins -- -D warnings -D clippy::disallowed_methods: passed (Finished in 1m 29s).
  • scripts/build-budget.py -- cargo clippy -p orbit-cli --all-targets -- -D warnings -A clippy::disallowed_methods: passed (Finished in 1m 20s).
  • RUSTDOCFLAGS="-D warnings" scripts/build-budget.py -- cargo doc --no-deps -p orbit-cli: passed (Documenting orbit-cli, Finished in 1m 23s).
  • make ci, ci-fast, ci-lint, goldens, ci-test-affected: not run. The workspace guide does not require them as blanket pre-handoff gates, and no golden surface changed.
  • workflow.required_validation_commands is empty and task.final_validation_commands is absent.

Reconciliation: baseline HEAD c233d75 was clean. git status --short is the seven modified test files, all inside the existing selectors' directory. git diff --check is clean. No untracked deliverable paths. context_files were not edited. Scratch and perturbation copies stay under .orbit/tmp (gitignored). No leftovers outside that directory.

Deviations: age-floor helpers stay duplicated in the two test files rather than a new shared module. sweep_workspace.rs already rewrote the YAML key exactly and was left unchanged. Doctor assertions still match the deadline phrases in CLI JSON because the criterion requires that detail; that is separate from the retired help-prose pins. host_fleet RUST_LOG=off also covers host_dashboard and host_routing, which share Fleet::process.

Validation

  • Not reported

Branch Freshness

  • Base ref: origin/agent-main
  • Head ref: orbit/ORB-23827-7033c354
  • Behind base: 0
  • Ahead of base: 1

…se… [ORB-23827]

[code-review] Code-review cleanup: vacuous and host-dependent assertions in crates/orbit-cli/tests/workspace

Fixes: 85118e8 ("Allow replica-local scheduled worktree GC with honest routine control capabilities (#3320)")
Regression-From: ORB-14173
Regression: defect_in_new; escape=no_test; severity=low
Fixes: 0edd136 ("fix: Make doctor's clock-unit check verify the sweep timer is enabled a… [ORB-16351] (#4923)")
Regression-From: ORB-16351
Regression: broke_existing; escape=no_test; severity=low
Fixes: 9a3e046 ("feat: Worktree GC routine prunes the workspace .orbit/tmp scratch direc… [ORB-14432] (#3521)")
Regression-From: ORB-14432
Regression: broke_existing; escape=no_test; severity=low
Fixes: c2e94f9 ("fix: [qa-sweep] Installing a new binary SIGTERMs live drains and record… [ORB-13013] (#2618)")
Regression-From: ORB-13013
Regression: defect_in_new; escape=nondeterministic; severity=low
Fixes: 8023d01 ("feat: Host registry: `orbit host add|list|show|remove` over a CLI-owned… [ORB-14448] (#3556)")
Regression-From: ORB-14448
Regression: defect_in_new; escape=no_test; severity=nit
@orbit-agent-01 orbit-agent-01 added the orbit orbit related label Nov 10, 2026
@orbit-agent-01
orbit-agent-01 merged commit 4500d4b into agent-main Nov 10, 2026
15 checks passed
@orbit-agent-01
orbit-agent-01 deleted the orbit/ORB-23827-7033c354 branch November 10, 2026 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

orbit orbit related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant