Skip to content

fix(mcp-gateway): honor the first adopted drift check - #6966

Merged
dwu96 merged 1 commit into
mainfrom
codex/fix-adopted-daemon-macos
Aug 30, 2026
Merged

fix(mcp-gateway): honor the first adopted drift check#6966
dwu96 merged 1 commit into
mainfrom
codex/fix-adopted-daemon-macos

Conversation

@bolichen97

Copy link
Copy Markdown
Collaborator

Summary

  • treat _last_drift_check == 0 as the existing "never checked" sentinel
  • keep the five-minute rate limit only after an actual adopted-daemon drift assessment
  • make the regression deterministic by pinning monotonic time below the interval

Root cause

Freshly provisioned macOS runners can have less than five minutes of uptime. The code subtracted the zero sentinel from time.monotonic() and treated that small result as a recent check, so the first drift assessment was skipped. The dependent replacement/watchdog assertions then failed even though no assessment ran.

Determinism evidence

  • with monotonic time fixed at 60 seconds, the pre-fix test fails deterministically at the first call assesses
  • after the fix, all 13 TestAdoptedDriftRecheck tests pass with RuntimeWarning and PytestUnraisable warnings promoted to errors
  • no sleeps, retries, timeout changes, tolerance changes, or warning filters were added

Validation

  • targeted strict drift-recheck class: 13 passed
  • flake8 and isort checks passed
  • repository baseline-aware Black gate passed
  • git diff --check passed

Overlap audit

This is the independent owner fix for the macOS gateway failures first observed on #6962; #6962 remains unchanged.

@bolichen97
bolichen97 requested a review from a team as a code owner August 30, 2026 08:10
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Aug 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 39b20da3c01da3508b83bd2639fc7eb133757930 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Minimal fix with a named root cause (0.0 sentinel misread as a timestamp), a comment documenting the invariant, and a regression test that pins it.

[DESIGN-REVIEWED] 39b20da

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 39b20da3c01da3508b83bd2639fc7eb133757930 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 39b20da

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 39b20da3c01da3508b83bd2639fc7eb133757930: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 39b20da3c01da3508b83bd2639fc7eb133757930 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 39b20da

Verdict parsed from the review's SHA-scoped output markers for commit 39b20da3c01da3508b83bd2639fc7eb133757930.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 39b20da3c01da3508b83bd2639fc7eb133757930: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 39b20da3c01da3508b83bd2639fc7eb133757930 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All evidence gathered. The fix is sound and declared; the notable findings are the repo's existing -inf sentinel idiom and one counted unfixed sibling of the same root cause.

First-Principles-Verdict: CONCERNS

A clean, declared fix — but the repo already spells "never checked" as float("-inf"), which is smaller, and one sibling of the same bug stays unfixed.

What this change ships

Intent: make the adopted-daemon drift repair actually run its first check on freshly booted hosts — a FIX.

  1. First drift assessment now runs even when the host booted under five minutes ago — justified, cause-level.
  2. Drift-recheck regression test runs against a pinned 60-second clock, not real host uptime — justified, declared.

Watch

  • Same root cause, one counted unfixed sibling: grepped now - self._<stamp> < against = 0.0 initializers; pr_watchers.py:427 (_last_reconcile = 0.0, RECONCILE_MIN_INTERVAL_S = 120.0, checked at pr_watchers.py:611) suppresses the first PR-reconcile sweep for up to two minutes on a host booted under two minutes ago. The other 0.0-init throttles (renderers, stt) have seconds-scale intervals, so their harm window is negligible. Accepted-and-deferred, not a demand — though the one-line initializer fix below applies there verbatim.

Subtractions

  • Replace the added four-line self._last_drift_check > 0.0 and … guard (manager.py:898-901) plus its three-line comment with the repo's existing sentinel idiom: initialize _last_drift_check = float("-inf") at manager.py:198 and manager.py:207 and keep the original one-line comparison. Counted 3 existing uses of that idiom: teams/client.py:456, metrics/local_exporter.py:182, acp/session_handle.py:284 (_WORKING_NEVER_LOGGED). The stale "stays 0.0" comment at manager.py:1118 updates with it.

[FIRST-PRINCIPLES-REVIEWED] 39b20da

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Aug 30, 2026
@dwu96
dwu96 enabled auto-merge (squash) August 30, 2026 09:05

@dwu96 dwu96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: fix — the adopted-daemon drift recheck treated the 0.0 "never checked" sentinel as a real time.monotonic() stamp, so on a host whose uptime is below the recheck interval the very first check was suppressed; the guard now requires a non-zero prior stamp, with the test pinning monotonic to make the first assessment uptime-independent.

@dwu96
dwu96 merged commit f4b41e4 into main Aug 30, 2026
67 checks passed
@dwu96
dwu96 deleted the codex/fix-adopted-daemon-macos branch August 30, 2026 09:05
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Aug 30, 2026

@chenmingwei23 chenmingwei23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: fix with clear root cause, honor the first adopted drift check in mcp_gateway manager.

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: treats the zero _last_drift_check sentinel as "never checked" so the first adoption-drift assessment is not suppressed on hosts with less uptime than the 5-minute interval; single-condition change plus the matching test pin.

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.

4 participants