Skip to content

fix(company-os): a live process keeps its identity when boot time drifts, so a run key is not revoked early (#20466) - #20475

Closed
mrveiss wants to merge 2 commits into
mainfrom
issue-20466-run-key-early
Closed

mrveiss wants to merge 2 commits into
mainfrom
issue-20466-run-key-early

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Refs #20466

Thinking Path

A heartbeat's run key was revoked about 20 seconds into a run that worked for 7 more minutes. The key is only revoked after _await_adapter_completion returns, so the status check must have read a live process as finished. On this host the exact create_time comparison does that.

What Changed

  • llc/adapters/subprocess_support.py: process identity compares _start_stamp, psutil's own identity value, instead of create_time(). On Linux that is monotonic jiffies since boot, which doesn't change. PID-reuse protection stays: a different stamp still reads as ended, and terminate_pid still refuses to signal a mismatch.

Why: psutil's create_time() is jiffies since boot plus boot_time(), re-read from /proc/stat each call. On the WSL2 host btime moved down by a second every 10 to 60 seconds, measured. So one live process's create_time changes between reads, an exact == fails, the status reads COMPLETED, and the key is revoked. Reading the run as finished also meant status and usage were read too soon.

Ruled out: a shared state path (state files are keyed by pid), and another revoker (revoke_run_key has one caller).

Verification

  • test_run_identity_survives_clock_drift_20466.py, with a real detached process: alive across 5 polls while boot time drifts; killed then reads ended; a different stamp reads ended; terminate_pid still works after drift. Without the fix the 2 drift tests fail.
  • llc/tests plus llc/adapters/tests, whole: 2837 passed, 2 skipped.

Not established:

  • The early poll itself wasn't logged, so this cause is the measured mechanism plus the 21-second gap, not an observed poll. The host criterion on the issue is the proof: a scheduled run posts its comment.
  • No scheduler-level test for status and usage being read after exit; it follows from the identity check.
  • _ident is a private psutil attribute, because the public create_time() takes no monotonic argument in 7.2.2. The alternative is parsing /proc/<pid>/stat.
  • A run in flight during the update holds an old stamp, reads as ended once, and isn't signalled.

Model Used

Claude Opus 5.5
🤖 Generated with Claude Code

@mrveiss mrveiss added this to the M2 - Company OS workflow-ready milestone Nov 1, 2026
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0dbb02f and e433eaa.

Files selected for processing: 8
  • autobot-backend/llc/adapters/subprocess_support.py
  • autobot-backend/llc/adapters/tests/test_adapters.py
  • autobot-backend/llc/adapters/tests/test_copilot_local_adapter.py
  • autobot-backend/llc/adapters/tests/test_process_group_kill_13097.py
  • autobot-backend/llc/adapters/tests/test_run_identity_survives_clock_drift_20466.py
  • autobot-backend/llc/adapters/tests/test_stall_watchdog_13099.py
  • autobot-backend/llc/adapters/tests/test_subprocess_base.py
  • autobot-backend/llc/adapters/tests/test_subprocess_support.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

@mrveiss

mrveiss commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Code review on PR #20475 (head 55c9997): approve. Read directly; psutil 7.2.2 _ident[1] is the since-boot start time, so boot-time drift no longer reads a live process as finished, and PID-reuse protection stays. _ident is private and the floor is >=: the tests drive a real process, so a psutil change would show as red. To check on update: a stamp recorded before this change in a run still in flight will not match the new form, so that run reads as finished once.

@mrveiss

mrveiss commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Landed via the merge train (PR #20500), main 64943e3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase:M2.5 Heartbeats fire reliably

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant