Skip to content

fix(sandbox): emit a heartbeat from the GCP Agent Platform template controller - #541

Merged
ItamarZand88 merged 1 commit into
mainfrom
itamar/alien-622-gcp-sandbox-emits-no-heartbeat
Aug 30, 2026
Merged

ItamarZand88 merged 1 commit into
mainfrom
itamar/alien-622-gcp-sandbox-emits-no-heartbeat

Conversation

@ItamarZand88

Copy link
Copy Markdown
Contributor

Summary

A GCP sandbox reconciled healthy and reported no observation at all: neither GCP controller
emitted a heartbeat, and SandboxHeartbeatData had no variant they could emit.

  1. The template controller's Ready handler already reads the template's lifecycle state
    every 30 seconds and returns an error on anything but ACTIVE.
  2. It now reports what it just read — the engine and template id, with a status that can
    only be produced after that ACTIVE check passed.
  3. Ready returns to itself, so the observation refreshes on every reconcile instead of
    freezing at create time.

This turns a controller that measured a template's health and discarded it into one that
reports it.

What I did

Added a GcpAgentPlatform variant to SandboxHeartbeatData and emitted it from the
template controller. The engine controller observes nothing at Ready by design, so the
template controller is the right emitter.

The emission sits after the ACTIVE check, which returns early on anything else, so a
healthy status is only ever reported when ACTIVE was actually read. It carries no session
count: counting sessions needs a list verb no sandbox permission set grants, and inventing
the number would be worse than leaving it out.

This adds no cloud API call and needs no permission the controller does not already
hold.
The read was already there, and the diff touches no permission set.

Files touched

crates/alien-core/src/heartbeat.rs ·
crates/alien-infra/src/sandbox/gcp_agent_platform_template.rs ·
crates/alien-deployment/src/manager_api_transport.rs · regenerated OpenAPI and zod artifacts

How I tested

  • cargo test -p alien-infra --features all-platforms,test-utils --lib sandbox::gcp_agent_platform_template
    — 16 passed. The new test drives three consecutive Ready reconciles and asserts exactly
    one healthy heartbeat each, which is what separates a steady-state emitter from one that
    fires once and goes stale.
  • Mutation-verified both ways: deleting the emission fails the test, and so does changing
    the reported lifecycle away from running.
  • A JSON round-trip asserts the exact wire tag and camelCase field names — a struct
    round-trip passes even when the tag is wrong.
  • The regeneration is load-bearing, so I proved it. Reverting only the generated OpenAPI
    and rebuilding produces data did not match any variant of untagged enum SandboxHeartbeatData — a client-side failure before any HTTP call, which looks nothing
    like a missing schema. A test in manager_api_transport.rs now pins it.
  • Generators run rather than files edited: pnpm run generate:manager-rust-sdk and
    pnpm --filter @alienplatform/core generate.
  • cargo check --workspace --all-targets in the consuming workspace, which enumerates every
    variant of this enum — the new one breaks nothing.

Not validated against a live GCP project, so the above proves the logic, the wire shape and
the regeneration, not that the call succeeds in a real cloud.

…ontroller

A GCP sandbox reconciled healthy and reported no observation at all: neither GCP
controller emitted a heartbeat, and SandboxHeartbeatData carried no variant they
could emit.

The template controller's Ready handler already reads the template's lifecycle
state every 30s and fails fast on anything but ACTIVE, so the emission adds no
cloud API call and needs no permission it does not already hold. It reports the
engine and template it read, and nothing about sessions: counting those needs a
list verb only the management set grants.
@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds recurring health observations for GCP Agent Platform sandbox templates after confirming that the provider reports them as active.

  • Adds a gcpAgentPlatform sandbox heartbeat variant containing status, engine, and template identity.
  • Emits one healthy heartbeat during each successful Ready reconciliation.
  • Updates Manager OpenAPI contracts and verifies core and generated-client wire compatibility.

Confidence Score: 5/5

The PR appears safe to merge, with the heartbeat producer and relevant serialized Manager contracts aligned.

The heartbeat is emitted only after the existing ACTIVE-state check, repeats through the delayed Ready transition, and has consistent core, OpenAPI, and generated-client wire representations.

Important Files Changed

Filename Overview
crates/alien-core/src/heartbeat.rs Adds the serialized GCP Agent Platform sandbox heartbeat contract and an exact wire-format round-trip test.
crates/alien-infra/src/sandbox/gcp_agent_platform_template.rs Emits a healthy heartbeat after each successful ACTIVE template check while retaining the 30-second Ready loop.
crates/alien-deployment/src/manager_api_transport.rs Adds coverage proving the new core heartbeat converts through the generated Manager request type.
client-sdks/manager/openapi.json Extends the Manager client contract with the tagged GCP Agent Platform sandbox heartbeat schema.
crates/alien-manager/openapi.json Keeps the Manager service OpenAPI contract aligned with the new heartbeat variant.

Sequence Diagram

sequenceDiagram
    participant R as Ready reconciler
    participant G as GCP Agent Platform
    participant C as Heartbeat collector
    participant M as Manager transport
    R->>G: Read sandbox template
    G-->>R: Template state and identity
    alt State is ACTIVE
        R->>C: Emit healthy GCP sandbox heartbeat
        C->>M: Include heartbeat in reconciliation
        R-->>R: Schedule Ready after 30 seconds
    else State is not ACTIVE
        R-->>R: Return ResourceDrift error
    end
Loading

Reviews (1): Last reviewed commit: "fix(sandbox): emit a heartbeat from the ..." | Re-trigger Greptile

@ItamarZand88
ItamarZand88 merged commit 813014f into main Aug 30, 2026
25 checks passed
@ItamarZand88
ItamarZand88 deleted the itamar/alien-622-gcp-sandbox-emits-no-heartbeat branch August 30, 2026 23:02
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