Skip to content

Autoscale CPU record seal workers with fenced claims - #24491

Merged
Git-on-my-level merged 7 commits into
mainfrom
lane/ic-sealfold-a
Nov 3, 2026
Merged

Git-on-my-level merged 7 commits into
mainfrom
lane/ic-sealfold-a

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Replace the fixed record-seal-repair throughput buffer with CPU seal workers that
claim completed unsealed record_pending obligations and scale from one to sixteen
slots on fresh seal backlog. Discovery pages pending jobs oldest-first instead of
rescanning 10,000 conversations. Keep canonical plan/apply, proof rules and the
270-second child unchanged; GPU worker scheduling and its HPA are unchanged.

Claims use expiring tokens on the existing obligation, stale-token release checks
and one-hour retry backoff. Add backlog/oldest age, seals/minute counter and seal-age
histogram through the existing Prometheus Adapter route. Retain the repair CronJob
with suspend: true and move the sweeper to hourly, matching its alert alignment
and absence window to that cadence. The worker switch ships on.

Validation: hermetic seal suites and the seven Firestore query/index guards passed
via omi-heavy run -- nice -n 19 env BACKEND_UNIT_TEST_FILE_LIST=... bash test.sh,
one pytest process per file (1,098 passed, one deselected; five later worker guards
also passed, 19 total worker cases). Includes concurrent apply (one seal), claim expiry,
reclaim, interrupted cleanup, budget/backoff, oldest-first keyset, kill switch and
complete/fresh backlog samples. Concurrent hermetic tests serialize the strict
fixture at its transaction boundary; real SDK contention is a staging gate.
make preflight passed all 43 selected checks. The updated hourly-sweeper alert
contract also passed (4 tests). Receipts are in /Volumes/scratch/ic-sealfold-a/.
Additional review guards cover malformed-row progress, startup-error privacy,
real dev/staging values, the monitoring target inventory and exact adapter drift
acceptance. The 22 flag-budget cases pass; GPU chart contracts still verify the
same scheduling and HPA settings alongside the new CPU Deployment/HPA.
Process metadata is read at entrypoint bootstrap and passed into the worker;
the stage-env and logging-entrypoint ratchets pass with no baseline exception.
After integrating current main (including the independently landed #24493), the
12-file seal/monitoring/chart integration set passed, including both existing GPU
HPA replays. No GPU HPA or scheduler changes are in this PR's diff.

Deployment/ramp (lead + infracost):

  1. Verify composite indexes READY, deploy Prometheus scrape/adapter wiring, and
    qualify CPU placement, long-row memory and forced-death reclaim in staging.
  2. Deploy workers ON with an explicit recordSealRepair.suspend=false override for
    one evening peak. Shared canonical apply rechecks make cron overlap safe.
  3. Set suspend=true, then run one bounded catch-up sweep over chronic classes,
    preserving privacy/upload/proof refusals. No redrive is included in this PR.
  4. Gate: seal-age p95 <30 minutes across one evening peak, no manual worker
    changes. Also check oldest unfinished debt so refusals cannot disappear from
    the success histogram. Lead owns the peak gate; remove the retained cron in
    a later PR after a recorded passing peak.

Rollback: recordSealWorker.runtimeEnabled=false and
recordSealRepair.suspend=false in one Helm values update. Worker slots idle;
repair resumes. Current policy maps must be supplied to both worker and repair
during overlap; invalid/absent maps refuse cloud IO.

The 16-slot maximum preserves repair's 4CPU/8Gi aggregate limit, split into
250m/512Mi per slot. Throughput and memory at that split are unqualified until
staging. No production/GCP credential use, deploy, live flag change or Luna run
was performed on m1. Runbook: backend/docs/runbooks/record-seal-workers.md.

Failure-Class: none
Workers reuse RECORD_SEAL_REPAIR_ENABLED in their own pods and children;
recordSealWorker.runtimeEnabled controls that independently of the retained
cron's runtime flag. No additional runtime flag or flag-budget exception.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-03T09:52:45.700617Z
We couldn’t complete this review. Comment @codex review to try again.
bd5a73b PR opened
ℹ️ 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 25 files

Confidence score: 4/5

  • test_record_seal_sweeper_deploy.py does not check that the new worker resources are disabled with all repair paths off, so the kill-switch test could miss them remaining deployed. Assert the record-seal-worker Deployment, HPA, and PodMonitoring are absent.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/tests/unit/test_record_seal_sweeper_deploy.py">

<violation number="1" location="backend/tests/unit/test_record_seal_sweeper_deploy.py:74">
P2: The new worker flag is not covered by this kill-switch assertion. Also assert that the `record-seal-worker` Deployment, HPA, and PodMonitoring are absent when all repair paths are disabled.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread backend/database/record_seal_worker.py Resolved
Comment thread config/feature-flags.yaml Resolved
def test_chart_kill_switch_removes_job_and_rbac_and_plan_mode_is_explicit():
result = render('--set', 'recordSealSweeper.enabled=false,recordSealRepair.enabled=false')
result = render(
'--set', 'recordSealSweeper.enabled=false,recordSealRepair.enabled=false,recordSealWorker.enabled=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.

P2: The new worker flag is not covered by this kill-switch assertion. Also assert that the record-seal-worker Deployment, HPA, and PodMonitoring are absent when all repair paths are disabled.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/unit/test_record_seal_sweeper_deploy.py, line 74:

<comment>The new worker flag is not covered by this kill-switch assertion. Also assert that the `record-seal-worker` Deployment, HPA, and PodMonitoring are absent when all repair paths are disabled.</comment>

<file context>
@@ -70,7 +70,9 @@ def test_ship_on_cpu_cron_reuses_worker_identity_and_image():
 def test_chart_kill_switch_removes_job_and_rbac_and_plan_mode_is_explicit():
-    result = render('--set', 'recordSealSweeper.enabled=false,recordSealRepair.enabled=false')
+    result = render(
+        '--set', 'recordSealSweeper.enabled=false,recordSealRepair.enabled=false,recordSealWorker.enabled=false'
+    )
     assert result.returncode == 0
</file context>

Git-on-my-level and others added 5 commits November 3, 2026 05:05
@Git-on-my-level
Git-on-my-level merged commit 1517820 into main Nov 3, 2026
68 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/ic-sealfold-a branch November 3, 2026 11:58
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