Skip to content

Revert template state model#231

Merged
sjmiller609 merged 1 commit into
mainfrom
hypeship/revert-template-state
May 18, 2026
Merged

Revert template state model#231
sjmiller609 merged 1 commit into
mainfrom
hypeship/revert-template-state

Conversation

@sjmiller609
Copy link
Copy Markdown
Collaborator

@sjmiller609 sjmiller609 commented May 15, 2026

Summary

  • revert the template VM state, API endpoints, and metadata fields
  • remove template-specific fork and deletion behavior so snapshot fanout can replace it

Tests

  • go test ./lib/instances/ -run 'Test(StateTransitions|ResolveForkTargetState|ValidateForkRequest|ForkInstanceFromStandbyCancelsCompressionJobAndCopiesRawMemory)'\n- go test ./cmd/api/api ./lib/scopes ./lib/builds (fails locally: bridge setup is not permitted and mkfs.erofs is unavailable)

Note

Medium Risk
Removes the Template lifecycle state and associated API endpoints, which is a breaking change for clients and alters fork/delete/restore behavior for standby instances. Risk is moderate due to lifecycle semantics and generated OpenAPI client/server surface changes.

Overview
Reverts the template instance concept by removing the Template state from instances (state machine, metadata fields, state derivation, and transition tests) and deleting all template-specific logic such as fork-from-template handling and delete/demote fork-count guards.

Removes the POST /instances/{id}/promote-template and POST /instances/{id}/demote-template endpoints end-to-end (API handlers, scopes, OpenAPI schema/enum, generated lib/oapi client/server code, and stainless.yaml), and drops the now-obsolete template-focused unit test suite.

Reviewed by Cursor Bugbot for commit 3787ab3. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

✱ Stainless preview builds for hypeman

This PR will update the hypeman SDKs with the following commit message.

feat: Revert template state model
hypeman-openapi studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅

⚠️ hypeman-typescript studio · code

Your SDK build had a failure in the lint CI job, which is a regression from the base state.
generate ✅build ✅lint ❗test ✅

hypeman-go studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅build ⏭️lint ✅test ✅

go get github.com/stainless-sdks/hypeman-go@537a68947307effc1c8a9efec8a9041fd6319e9d

This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-05-18 14:39:18 UTC

@sjmiller609 sjmiller609 marked this pull request as ready for review May 15, 2026 15:45
@sjmiller609 sjmiller609 requested a review from hiroTamada May 15, 2026 15:45
@firetiger-agent
Copy link
Copy Markdown

Monitoring Plan: Remove Template Instance State

This PR removes the Template VM instance state and its associated PromoteInstanceToTemplate / DemoteInstanceTemplate API endpoints entirely. The change deletes ~1,400 lines across the instance manager, state machine, API handlers, OpenAPI spec, and OAPI client — cleaning up an unused lifecycle concept. After this deploy, instances with IsTemplate=true in stored metadata will be read back as plain Standby (since deriveState no longer checks IsTemplate), and callers hitting the removed endpoints will receive 404s.

Key risks to watch post-deploy: (1) any existing Template-state instances whose metadata is read back and misclassified, triggering unexpected state transitions; (2) a spike in 4xx/5xx errors on /instances/{id}/fork, /instances/{id}/restore, or the removed paths; (3) any panics or invalid_state errors in the API logs from code paths that still referenced StateTemplate but weren't caught by the test suite. Status updates will be posted automatically on this PR as monitoring progresses.

Key risks:

  • Fork/restore 5xx errors rising above baseline (~0.01–0.018%)
  • invalid_state or failed to promote/demote errors appearing in API logs post-deploy
  • 404s on /instances/{id}/promote-template or /instances/{id}/demote-template (expected/benign if callers already migrated, but volume worth confirming is zero)
  • Metadata misread: instances previously in Template state now incorrectly treated as Standby

View agent

@sjmiller609 sjmiller609 merged commit 8eeeeff into main May 18, 2026
11 checks passed
@sjmiller609 sjmiller609 deleted the hypeship/revert-template-state branch May 18, 2026 14:37
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.

2 participants