Add lifecycle node field#2328
Closed
shangyian wants to merge 7 commits into
Closed
Conversation
Implement pure-logic foundation for node lifecycle states (dev, experimental, stable, deprecated, retired) with bidirectional mapping to legacy NodeMode. Adds resolve_lifecycle() to reconcile (mode, lifecycle) pairs for back-compat and forward deployment paths. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…paths The lifecycle field was silently dropped on the source-create (create_a_source_node), PATCH-update (create_new_revision_from_existing, update_cube_node), and reactivate (create_node_from_inactive) node paths. These now derive (lifecycle, mode) consistently with create_node_revision. - create_a_source_node / create_cube_node_revision: derive via resolve_lifecycle(data.mode, data.lifecycle) and set both mode+lifecycle (source-create previously set neither, always falling back to DB defaults). - Update/copy-forward paths: new resolve_updated_lifecycle helper preserves the prior lifecycle when mode is unchanged and no explicit lifecycle given, derives fresh when mode changes (legacy mode-only input), and lets an explicit lifecycle win. Applied in create_new_revision_from_existing and update_cube_node. - Copy-forward NodeRevision constructions (copy_to_new_node, copy_existing_node_revision, refresh_source) now copy old lifecycle alongside mode. - Lifecycle diffs now register as minor_changes so a lifecycle-only PATCH triggers a new revision. Adds 4 tests covering source-create, PATCH lifecycle->mode derivation, unrelated-field lifecycle preservation, and mode-only back-compat. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add test_create_source_node_mode_only_backfills_lifecycle to TestNodeLifecycle to verify source nodes created with only mode=draft (no lifecycle) correctly persist mode=draft and derive lifecycle=dev (back-compat path). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…e conflict test - Add missing "lifecycle": None to test_deployment_spec's expected model_dump() now that NodeSpec includes the lifecycle field. - Make _LENIENT_LIFECYCLES a frozenset to signal immutability. - Add test pinning that an explicit lifecycle wins over a conflicting explicit mode on PATCH.
✅ Deploy Preview for thriving-cassata-78ae72 canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a first-class lifecycle field (
dev/experimental/stable/deprecated/retired) to nodes and derives the existing mode (draft/published) from it. We'll keepmodeas a stored column, but it is now computed from lifecycle on write, so all existing mode behavior and readers keep working. Clients/specs that send only mode are fully backwards-compatible (lifecycleis derived frommode).LifecycleStateenum +resolve_lifecycle(mode, lifecycle)where an explicitlifecyclesetting wins, but if it's absent, it gets derived frommode.lifecyclecolumn onnoderevision+ Alembic migration backfilling frommode(drafttodev,publishedtostable).modeis derived fromlifecycleon every write path: API create, source-create, update, reactivate, copy-forward, and deployment specs. The validity gate (lenient below stable, strict at/above) reads the derived mode unchanged.This also corrects a latent bug where source-create previously ignored input mode and persisted published with a draft version number; it now honors mode/lifecycle like every other path.
Deferred (follow-up PRs)
Response warnings, discovery filtering, dependency guards, change events, configurable vocabulary, and migrating readers off
mode.Test Plan
Added new unit + API + deployment tests (lifecycle to mode derivation, mode-only back-compat, validity threshold, conflict resolution, lifecycle preservation across revisions).
make checkpassesmake testshows 100% unit test coverageDeployment Plan