Skip to content

Keep Inbox GitHub lock file owner-only - #2256

Merged
JacobStephens2 merged 4 commits into
mainfrom
issue-2254
Nov 17, 2026
Merged

JacobStephens2 merged 4 commits into
mainfrom
issue-2254

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Open .github-inbox-lock owner-only (0o600) in src/logs/github.rs::refresh, matching the owner-only exclusive lock setup already used by GitHub quota and plan-usage records so another local user cannot open the lock file read-only, take an flock, and stall Inbox refreshes:

  • src/github/quota/store.rs (open_owner_only_lock, try_lock_exclusive) + src/github/quota.rs: extract shared owner-only lock opening (OpenOptions with create(true).truncate(false).write(true).mode(0o600) followed by set_permissions(0o600)) alongside lock_exclusive, and add non-blocking try_lock_exclusive returning Ok(None) on TryLockError::WouldBlock.
  • src/logs/github.rs (refresh): replace File::create with crate::github::quota::try_lock_exclusive(&config.logs_dir.join(".github-inbox-lock"))?, keeping _lock held for the scope of refresh and returning Ok(kept) on WouldBlock.
  • src/logs/github.rs (tests): add unit tests verifying new lock creation at 0o600, tightening a pre-existing 0o644 lock to 0o600, and returning kept while still tightening a 0o644 lock held by another descriptor.
refresh (src/logs/github.rs)
  ├── calls crate::github::quota::try_lock_exclusive(.github-inbox-lock)
  │     ├── open_owner_only_lock: OpenOptions(create=true, truncate=false, write=true, mode=0o600)
  │     ├── set_permissions(0o600)
  │     └── try_lock() -> WouldBlock => Ok(None) => return Ok(kept)
  └── holds _lock across GitHub refresh

Evidence

Execution evidence

Seams under test: src/logs/github.rs::refresh

Before (Red)

  • Slice 1 (refresh_creates_inbox_lock_with_owner_only_permissions against File::create under umask 0002):
thread 'logs::github::tests::refresh_creates_inbox_lock_with_owner_only_permissions' (742634) panicked at src/logs/github.rs:661:9:
assertion `left == right` failed: unexpected .github-inbox-lock mode 664
  left: 436
 right: 384
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1967 filtered out; finished in 0.01s
  • Slice 2 (refresh_tightens_existing_inbox_lock_to_owner_only_permissions against OpenOptions without set_permissions, pre-existing 0o644 lock):
thread 'logs::github::tests::refresh_tightens_existing_inbox_lock_to_owner_only_permissions' (758026) panicked at src/logs/github.rs:682:9:
assertion `left == right` failed: unexpected .github-inbox-lock mode 644
  left: 420
 right: 384
test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 1967 filtered out; finished in 0.02s

After (Green on e26e9f68)

  • cargo fmt --check: exited 0
  • cargo clippy --all-targets -- -D warnings: exited 0 (0.87s)
  • cargo test --bin thirdshift logs::github::tests: 3 passed; 0 failed; 0 ignored; 1967 filtered out; finished in 0.21s
  • cargo test --bin thirdshift github::quota: 6 passed; 0 failed; 0 ignored; 1964 filtered out; finished in 0.09s
  • cargo test --test console github: 19 passed; 0 failed; 0 ignored; 335 filtered out; finished in 17.68s
  • cargo nextest run --test console: exited 0 (3m10s)
  • cargo test --test dismiss: 25 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out; finished in 11.86s
  • PATH="/home/jacob/.cargo/bin:/usr/local/bin:/usr/bin:/bin" cargo test --test plan_usage: 7 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out; finished in 13.33s
  • python3 -m unittest discover -s scripts -p 'test_*.py': Ran 72 tests in 44.394s (OK)
  • PATH="/home/jacob/.cargo/bin:/usr/local/bin:/usr/bin:/bin" NEXTEST_TEST_THREADS=3 python3 scripts/affected-tests main: exited 0 (Summary [4937.741s] 4771 tests run: 4771 passed (32 slow), 209 skipped; wrapper PASS cargo nextest run (4939.83s)). Note on environment overrides: earlier default-env runs of scripts/affected-tests main failed on three host-environment issues outside this change — 4-core CPU saturation flakes in tests/dismiss.rs (dismiss_live_silent_row_moves_it_to_working_and_keeps_it_running) and tests/console/api.rs (api::release_url_keeps_api_openapi_and_cli_parity), and host /home/jacob/.local/bin/agy remaining on PATH during tests/plan_usage.rs (plan_usage_shows_configured_routes_in_order_and_omits_api_key_and_unused_harnesses) — so ~/.local/bin was omitted from PATH and concurrency was capped with NEXTEST_TEST_THREADS=3; all three suites also passed standalone as recorded above.

Merge Danger

  • Door: two-way
  • Blast Radius: Inbox (src/logs/github.rs::refresh) and shared local lock helper (src/github/quota/store.rs::open_owner_only_lock, try_lock_exclusive; existing lock_exclusive callers github::quota and plan_usage::store preserve identical owner-only 0o600 creation and permission tightening).

Unaddressed findings

  • Skipped findings: None. Standards initial review raised 1 judgement-call finding (duplicated owner-only lock setup between src/logs/github.rs and src/github/quota/store.rs), which was addressed in e26e9f68 and confirmed resolved on follow-up review. Spec review raised 0 findings.
  • Changed files left unread by review: None. Both Standards and Spec reviewers read all 3 changed files (src/github/quota.rs, src/github/quota/store.rs, src/logs/github.rs).

CI notes

The failure in run 44082567872 comes from an unrelated test this branch does not touch:

  • rust-x86 / run (3) (job 134036909818), thirdshift::show_logs a_tickets_issue_names_its_run_inside_the_spec_command (tests/show_logs.rs:396, assertion failed: logs.stdout.contains("session_id")): intermittent async pipe-flush race. Fake claude prints init (session_id) to stdout just before launching the ticket script (touch started in tests/fakes/claude.rs), and the test polls only for started before running a one-shot thirdshift logs widgets#21 --session implement (stream_log(..., false) in src/logs/status/inspect.rs), which exits 0 with empty stdout if the child Ticket run's stream reader (follow in src/session/recording.rs) has not yet written the first OTLP line to the pre-created .logs.jsonl file under concurrent CI load. This branch (4fb1bdb1, merging 7373a1f4 Release 0.35.1 into e26e9f68) modifies only src/github/quota.rs, src/github/quota/store.rs, src/logs/github.rs, Cargo.toml, and Cargo.lock, and logs/show/Spec runs never invoke src/logs/github.rs::refresh or try_lock_exclusive; locally on 4fb1bdb1, a_tickets_issue_names_its_run_inside_the_spec_command passed 49 of 49 standalone/parallel runs and cargo test --test show_logs passed (17 passed; 0 failed; 2 ignored), alongside cargo fmt --check, cargo clippy --all-targets -- -D warnings, python3 -m unittest discover -s scripts -p 'test_*.py' (72 tests), python3 scripts/generate-release.py --check, cargo test --bin thirdshift logs::github::tests (3 passed), github::quota (6 passed), plan_usage (37 passed), logs::reading::tests (51 passed), cargo test --test console github (19 passed), cargo test --test dismiss (25 passed; 2 ignored), PATH="/home/jacob/.cargo/bin:/usr/local/bin:/usr/bin:/bin" cargo test --test plan_usage (7 passed; 2 ignored), and cargo test --test status (80 passed; 2 ignored). rust-x86 / complete (job 134041756329) and test (job 134041858511) failed only as aggregates of rust-x86 / run (3).

Closes #2254

Built with agy 1.5.9 · gemini-4-hydrogen-xhigh · default effort

Security review outcome

No unaddressed introduced findings.

@JacobStephens2
JacobStephens2 merged commit c58b4bf into main Nov 17, 2026
25 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-2254 branch November 17, 2026 13:01
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.

Keep Inbox GitHub lock file owner-only

1 participant