Skip to content

feat(control-plane): cron-triggered wake/poll orchestration for hosted AMS tenants - #8075

Merged
JSONbored merged 1 commit into
mainfrom
claude/control-plane-ams-cron-wake
Jul 22, 2026
Merged

feat(control-plane): cron-triggered wake/poll orchestration for hosted AMS tenants#8075
JSONbored merged 1 commit into
mainfrom
claude/control-plane-ams-cron-wake

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Control-plane half of #7182 (the miner-side hosted entry point, loopover-miner-hosted, already shipped in #8070). Together they bring #7180's provisioning core to its full intended shape for AMS.

  • ams-wake.ts: a scheduled() handler (Cloudflare Cron Trigger, every 5 minutes) that finds every currently-due AMS tenant and wakes it. There's no per-resource Cron Trigger primitive, so per-tenant cadence lives as data on each tenant's own amsSchedule record, checked by one frequent global tick.
  • Wakes a due tenant's container via an explicit entrypoint override (not HTTP) calling loopover-miner-hosted, then polls getState() for its real exit code (0=success, 2=failure, per docs/unattended-scheduling.md's existing contract) and records it, unmodified.
  • Distinguishes a genuine poll timeout from a container that legitimately stopped without reporting a code — both leave exitCode undefined, but only one is a timeout.
  • Wakes due tenants sequentially, not concurrently, since a single Cron Trigger invocation has a bounded wall-clock budget shared across every due tenant that tick.
  • POST /v1/tenants gains an optional schedule field (command/args/intervalMs, AMS-only) to configure a new tenant's cadence at creation time; GET /v1/tenants surfaces it back for admin visibility.

Test plan

  • npm run build (typecheck) clean
  • npm run cf:typecheck clean
  • npm run test:node — 129/129 passing
  • node ../scripts/control-plane-coverage.mjs — 99.93%/99.38%/98.83%/99.93% (only gap: pre-existing, untouched settlement-backend-driver.ts)
  • npx wrangler deploy --dry-run clean, both container images build, all bindings resolve

Closes #7182

…d AMS tenants (#7182)

Adds ams-wake.ts: a Cloudflare Cron Trigger scheduled() handler (wrangler.jsonc,
every 5 minutes -- there is no per-resource cron primitive, so per-tenant
cadence lives as data on each AMS tenant's own amsSchedule) that finds every
currently-due AMS tenant, wakes its container via the already-shipped
loopover-miner-hosted entry point (an explicit entrypoint override, not
HTTP), polls for its real exit code, and records the result -- 0=success,
2=failure, unmodified, per docs/unattended-scheduling.md's existing contract.
Distinguishes a genuine poll timeout from a container that legitimately
stopped without reporting a code (both leave exitCode undefined, but only
one is actually a timeout).

POST /v1/tenants gains an optional `schedule` field (command/args/intervalMs,
AMS-only) to configure a new tenant's cadence at creation time; GET /v1/tenants
surfaces it back for admin visibility. Sequential (not concurrent) wake
processing, since a single Cron Trigger invocation has a bounded wall-clock
budget shared across every due tenant that tick.

This is the control-plane half of #7182 (the miner-side hosted entry point,
loopover-miner-hosted, already shipped separately) -- brings #7180's
provisioning core's downstream consumers to their full intended shape for
AMS, alongside #7181 (ORB webhook routing, not yet built) for the ORB side.
@JSONbored JSONbored self-assigned this Jul 22, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored
JSONbored merged commit b99a475 into main Jul 22, 2026
12 checks passed
@JSONbored
JSONbored deleted the claude/control-plane-ams-cron-wake branch July 22, 2026 19:31
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 22, 2026
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.50%. Comparing base (e219e1a) to head (e6e89a4).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8075      +/-   ##
==========================================
+ Coverage   91.96%   92.50%   +0.53%     
==========================================
  Files         747      665      -82     
  Lines       76408    55934   -20474     
  Branches    23211    19585    -3626     
==========================================
- Hits        70269    51742   -18527     
+ Misses       5039     3317    -1722     
+ Partials     1100      875     -225     
Flag Coverage Δ
control-plane 99.79% <100.00%> (+0.02%) ⬆️
rees ?
shard-1 52.79% <ø> (-0.70%) ⬇️
shard-2 54.94% <ø> (-0.63%) ⬇️
shard-3 53.92% <ø> (-0.62%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
control-plane/src/ams-wake.ts 100.00% <100.00%> (ø)
control-plane/src/container-driver.ts 100.00% <100.00%> (ø)
control-plane/src/http-app.ts 100.00% <100.00%> (ø)
control-plane/src/index.ts 100.00% <100.00%> (ø)
control-plane/src/tenant-registry.ts 100.00% <100.00%> (ø)

... and 86 files with indirect coverage changes

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

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloudflare Cron Trigger wake scheduling for hosted AMS containers

1 participant