Skip to content

SCA-5098: decouple held expiry from request paths - #26511

Merged
Git-on-my-level merged 5 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m1-studio-codex-luna/1b98e6927fb6
Nov 27, 2026
Merged

Git-on-my-level merged 5 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m1-studio-codex-luna/1b98e6927fb6

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Summary

The supervised held-expiry loop remains the sole owner of expiry work. Request-triggered reconciliation retains its other maintenance while skipping the expiry tick inline, including /recover-quarantine when the owner-only recovery switch is disabled.

Changes

  • /reconcile, fallback /metrics, and /recover-quarantine explicitly opt out of inline held-expiry work.
  • Regression coverage includes the owner-only-off recovery fallback, the request routes, supervisor behavior, and continued reconciliation after an expiry tick raises.
  • The cadence and per-instance lease/cursor read bounds are documented below.

Cadence and cost

serving_tick_seconds() is clamped to 10–60 seconds; the checked-in production configuration sets 10 seconds. When enabled, the loop attempts one maintenance-lease acquisition per serving instance per tick. At 10 seconds, that is an upper bound of 6 lease transactions per minute (360 per hour) per instance. Only the lease holder performs the expiry cursor read, up to 6 per minute. At 60 seconds, each rate is 1 per minute. These are configuration-derived upper bounds; work time can lower the frequency, and no production measurements were taken.

Verification on current head

Head: 01ea31ea943ab748de3fc221d2a34db3c66c5150.

  • Non-periodic /reconcile and owner-only-off /recover-quarantine maintenance use the separate lease when they skip inline held expiry; the supervisor retains serving_maintenance.
  • The serving loop and fresh-guard supervisor now choose the same lease. A two-instance regression proves the losing guard follower deactivates instead of acquiring a conflicting lease.
  • The held-expiry change note now covers both request paths, skipped inline expiry, and the operational effect.
  • Focused verification passed all six selected backend unit files under Python 3.14.7 via omi-heavy: tests/unit/test_batch_pipeline_serving.py, test_batch_pipeline_quarantine_recovery.py, test_batch_pipeline_recovery_owner_only.py, test_batch_pipeline_fresh_guard.py, test_batch_pipeline_leader.py, and test_revision_drain_harness.py.
  • The bounded M1 pre-push gate passed, including its selected repository checks and Firestore guard.

Earlier verification receipts

Earlier receipt — gates ran on d3db129

  • The new owner-only-off regression failed before the route change because _maintain received run_held_expiry=True; it now asserts False and passes.
  • BACKEND_PYTEST_WORKERS=1 bash test.sh tests/unit/test_batch_pipeline_serving.py tests/unit/test_batch_pipeline_quarantine_recovery.py tests/unit/test_batch_pipeline_recovery_owner_only.py tests/unit/test_revision_drain_harness.py — 261 passed under Python 3.11.15.
  • The bounded local pre-push gate passed against main at 1628d27cbb5484d0aec8ee178074bbf89224bf83, including its selected backend tests and formatting checks.

Earlier receipt — gates ran on 3abfab4

  • 25 selected backend files passed under Python 3.11.15 and preflight passed 39 checks.

Product invariants affected

none

Failure class

Failure-Class: FC-observer-cadence-coupled-to-maintenance

Reviewer focus

Confirm the dedicated loop remains the only held-expiry driver when BATCH_PIPELINE_RECOVERY_OWNER_ONLY_ENABLED is off, while request paths preserve their other reconciliation work.

View guided diff

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T15:02:23.454236Z 9ceacb7 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d3db129e26

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

else:
# Periodic maintenance uses the leader lease; per-unit policy decides follow-ups.
await service.reconcile_async(periodic=True)
await service.reconcile_async(periodic=True, run_held_expiry=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reserve expiry ownership for hosts that run the supervisor

On a same-stage host with serving and projection-pump loops disabled, this fallback still acquires and renews SERVING_MAINTENANCE through Serving.reconcile(periodic=True), but start_serving_from_env() starts no expiry supervisor there. This configuration is supported by the legacy-metrics tests and the non-serving production roles in backend/deploy/runtime_env.yaml. Since the actual supervisor's sweep_held_dead_letters(periodic=True) checks that same lease, repeated metrics requests reaching the non-serving process within the 60-second TTL can retain ownership indefinitely while neither process expires or redrives held rows. Previously, the lease-holding request performed the tick. Give expiry a supervisor-only lease or otherwise prevent non-supervising hosts from monopolizing its ownership.

Useful? React with 👍 / 👎.

@router.post('/reconcile', include_in_schema=False)
async def reconcile(body: WorkerRequest):
await body.service().reconcile_async(recover_quarantine=True)
await body.service().reconcile_async(recover_quarantine=True, run_held_expiry=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the required held-expiry pipeline change note

This changes batch-audio maintenance and recovery by removing request-driven held expiry, but the commit adds no pipeline change note. backend/AGENTS.md requires a note under docs/listen_pusher_pipeline/changes/ in the same PR for audio, transcription, or lifecycle changes. Add one documenting supervisor ownership, the required serving configuration, and rollback/verification behavior so operators can discover that explicit reconciliation and legacy metrics requests no longer drive expiry.

AGENTS.md reference: backend/AGENTS.md:L164-L164

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ceacb71ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@router.post('/reconcile', include_in_schema=False)
async def reconcile(body: WorkerRequest):
await body.service().reconcile_async(recover_quarantine=True)
await body.service().reconcile_async(recover_quarantine=True, run_held_expiry=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep explicit reconciliation off the supervisor lease

On a same-stage host with serving disabled, an authenticated /reconcile now skips expiry but still acquires SERVING_MAINTENANCE through _maintain() -> refresh_fresh_guard(). The new alternate-lease branch only handles periodic=True, whereas this call keeps the default False. Requests repeated within the 60-second TTL can therefore retain ownership indefinitely while the actual supervisor's sweep_held_dead_letters(periodic=True) refuses to tick; unlike before, the request does not expire or redrive those rows either. The owner-only-off recovery path has the same problem. Keep non-supervising request maintenance off the expiry lease, not just legacy metrics requests.

Useful? React with 👍 / 👎.

Comment thread backend/utils/batch_pipeline/serving.py Outdated
Comment on lines +258 to +259
if periodic and not run_held_expiry and self.legacy_metrics_leader is not None:
maintenance_leader = self.legacy_metrics_leader

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep both fresh-guard callers on the same lease

With multiple serving replicas, this branch can give the two fresh-guard callers contradictory ownership decisions: supervise() also passes periodic=True, run_held_expiry=False, so its maintenance now uses the legacy-metrics lease, while _supervise_fresh_guard() still uses SERVING_MAINTENANCE. If different replicas acquire those leases, _maintain() refreshes a sampler that its independent guard loop deactivates, while the other replica's successful guard sample is cleared by its losing reconcile() call. FreshGuard.deactivate() clears the counts without resetting the 60-second refresh deadline, so healthy fresh-delivery counts and ratios disappear between ticks. Distinguish HTTP scrapes explicitly and preserve consistent ownership for both guard callers.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 1bb198d into BasedHardware:main Nov 27, 2026
66 of 67 checks passed
Git-on-my-level added a commit that referenced this pull request Dec 1, 2026
…96b (SCA-5954) (#26835)

Prod Pusher moved from pusher@sha256:fd5fb969… to pusher@sha256:b2e9996b…
in the 11-29 #26511 serving roll (SCA-5204). execute() requires the live
Deployment image to equal BASELINE before any digest or qualification check,
so every preview of a qualified candidate now refuses.

Point BASELINE at the image serving now (read 2026-12-01T00:52Z, ro-prod)
in the writer, the write detector and the runbook evidence example. Same
shape as #26710.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant