Skip to content

Revert template state model#231

Open
sjmiller609 wants to merge 1 commit into
mainfrom
hypeship/revert-template-state
Open

Revert template state model#231
sjmiller609 wants to merge 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

Edit this comment to update it. It will appear in the SDK's changelogs.

hypeman-go studio · code · diff

Your SDK build had at least one "note" diagnostic, but this did not represent a regression.
generate ✅build ✅lint ✅test ✅

go get github.com/stainless-sdks/hypeman-go@c70bfb748a5c9e3e571eabbd1afabc910e928d86
hypeman-openapi studio · code · diff

Your SDK build had at least one "note" diagnostic, but this did not represent a regression.
generate ✅

hypeman-typescript studio · code · diff

Your SDK build had at least one "note" diagnostic, but this did not represent a regression.
generate ✅build ✅lint ❗test ✅

npm install https://pkg.stainless.com/s/hypeman-typescript/a704b4848fb89b05d8bffa66158e42af631d82d0/dist.tar.gz

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-15 15:13:13 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

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