Skip to content

Add lifecycle node field#2328

Closed
shangyian wants to merge 7 commits into
mainfrom
node-lifecycle-mvp
Closed

Add lifecycle node field#2328
shangyian wants to merge 7 commits into
mainfrom
node-lifecycle-mvp

Conversation

@shangyian

@shangyian shangyian commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

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 keep mode as 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 (lifecycle is derived from mode).

  • Added a LifecycleState enum + resolve_lifecycle(mode, lifecycle) where an explicit lifecycle setting wins, but if it's absent, it gets derived from mode.
  • Added lifecycle column on noderevision + Alembic migration backfilling from mode (draft to dev, published to stable).
  • mode is derived from lifecycle on 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).

  • PR has an associated issue: #
  • make check passes
  • make test shows 100% unit test coverage

Deployment Plan

shangyian and others added 7 commits July 12, 2026 08:50
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.
@netlify

netlify Bot commented Jul 12, 2026

Copy link
Copy Markdown

Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit 25b3360
🔍 Latest deploy log https://app.netlify.com/projects/thriving-cassata-78ae72/deploys/6a53f2999a5a8800086356c6

@shangyian shangyian changed the title Node lifecycle mvp Add lifecycle node field Jul 12, 2026
@shangyian shangyian closed this Jul 12, 2026
@shangyian shangyian deleted the node-lifecycle-mvp branch July 12, 2026 22:26
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