Repository navigation
rust-cli-template: lock tests count waits instead of timing them; escape record text on stderr - #21
Open
orbit-agent-01 wants to merge 1 commit into
Open
orbit-agent-01 wants to merge 1 commit into
orbit-agent-01 wants to merge 1 commit into
Conversation
rust-cli-template: lock tests count waits instead of timing them; escape record text on stderr Completed all three items: Orbit-Task: ORB-26751 Orchestrated-By: Orchestrated-By: opus
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.
Task
ORB-26751 — rust-cli-template: lock tests count waits instead of timing them; escape record text on stderr
Description
Problem
Two leftovers from the audit's defect fix (landed as c7d24df).
Timing-bound lock tests. Two tests assert a wall-clock window around the 80 ms lock deadline, with
elapsed < deadline * 2(andelapsed >= deadlinein the second). On a loaded runner that leaves about 80 ms of slack:record_audit_succeeds_while_the_store_lock_is_heldincrates/tmpl-cli-core/src/store/tests/store.rs;crates/tmpl-cli/src/commands/tests/note.rs.The same kind of check already failed once on hosted macOS before the review repair (GitHub Actions run 44999038272). The behaviour under test is that the failing command waits on the store lock once, not twice. Measure that by counting contended lock acquisitions (or waits) through a test seam, not with elapsed time. Keep the assertions that the timeout error comes back and that exactly one failure line is audited.
Unescaped text on stderr. Bad-record warnings are written raw (
crates/tmpl-cli/src/output/mod.rs,emit:warning: {warning}).NoteError::InvalidTagdisplays the tag as'{0}'(crates/tmpl-cli-core/src/note.rs). A hand-edited tag or title holding ESC therefore reaches the terminal raw, through a warning or an error message. That goes against the third defect's rule that control characters cannot reach the terminal raw. Escape control characters in any record-derived text written to stderr, with the same sanitiser the body output uses, or{:?}.Nit, same change:
#[allow(dead_code)]ondecode_lineincrates/tmpl-cli-core/src/store/audit.rshas noreason =.Filed by the constellation captain ORB-26697 from the review of the earlier defect fix. No task ids in any file of this public repository.
Acceptance Criteria
Execution Summary
Click to expand
Completed all three items:
LockGuard::acquire_observingincrates/tmpl-cli-core/src/store/fsio.rs(invokingon_contendedonce on the firstWouldBlock, withLockGuard::acquiredelegating to it).Arc<AtomicUsize>counter andStore::contended_lock_waits(&self) -> usizeincrates/tmpl-cli-core/src/store/mod.rs, wired intoStore::lockandStore::audit_lock.Instant::now()/elapsed < deadline * 2wall-clock assertions incrates/tmpl-cli-core/src/store/tests/store.rs#record_audit_succeeds_while_the_store_lock_is_heldandcrates/tmpl-cli/src/commands/tests/note.rs#lock_timeout_audited_command_waits_one_deadline_and_records_one_failure_linewithcontended_lock_waits() == 1assertions, keeping thestore_lockedand single-failure-audit-line checks. Verifiedgrep -rn "deadline \* 2" cratesmatches nothing (exit 1).NoteError::{InvalidId, InvalidTag, InvalidPriority}incrates/tmpl-cli-core/src/note.rsto format values with{0:?}.render::sanitize_for_displaypub(super)incrates/tmpl-cli/src/output/render.rsand applied it incrates/tmpl-cli/src/output/mod.rs(emitwarnings/notices,report_errorhuman errors,finish_parse_errorhuman usage errors).bad_record_control_characters_are_escaped_on_stderrincrates/tmpl-cli/tests/cli.rs(seen failing on unfixed code with raw ESC0x1bon stderr, passing after fix).decode_lineattribute:crates/tmpl-cli-core/src/store/audit.rs#decode_linealready carries#[cfg_attr(not(test), expect(dead_code, reason = "template mechanism for an audit reader"))](landed in b3d2772).Validation:
cargo test -p tmpl-cli --locked --test cli bad_record_control_characters_are_escaped_on_stderr(before fix): failed as expected (left: Some(27)on stderr).cargo fmt --all && make ci: passed (exit 0:fmt-check,structure,standards-check,docs-check,clippy -D warnings,cargo deny check,cargo nextest run --workspace --all-targets --locked --no-tests=fail,cargo test --workspace --doc --locked1 passed,make goldens).grep -rn "deadline \* 2" crates: no matches (exit 1).cargo test --workspace --all-targets --locked: passed (42 tmpl-cli lib tests, 32 cli integration tests, 45 tmpl-cli-core lib tests, 13 store integration tests, plus scripts/goldens/rename_template binaries).crates/tmpl-cli-core/src/note.rs,crates/tmpl-cli-core/src/store/fsio.rs,crates/tmpl-cli-core/src/store/mod.rs,crates/tmpl-cli-core/src/store/tests/store.rs,crates/tmpl-cli/src/commands/tests/note.rs,crates/tmpl-cli/src/output/mod.rs,crates/tmpl-cli/src/output/render.rs,crates/tmpl-cli/tests/cli.rs), all within task scope;git diff --checkclean; no untracked leftovers.Validation
Branch Freshness
refs/remotes/origin/agent-mainorbit/ORB-26751-4b1f5bd1Orchestrated-By: opus