Skip to content

Add snapshot lifecycle hooks - #1

Merged
Mattie merged 11 commits into
mainfrom
codex/snapshot-lifecycle-hooks
Jun 24, 2026
Merged

Add snapshot lifecycle hooks#1
Mattie merged 11 commits into
mainfrom
codex/snapshot-lifecycle-hooks

Conversation

@Mattie

@Mattie Mattie commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

Adds opt-in snapshot lifecycle hooks for migration paths that need transient object setup around attachment and load boundaries.

  • calls __snapclass_ready__(self, *, snapshot) after snapshot attachment, mutable wrapping, and sidecar constructor values are settled
  • calls __snapclass_loaded__(self, *, snapshot, path) after Snapshot.load() applies file data, wraps mutables, and records loaded state
  • suppresses automatic snapclass save/reload hooks while lifecycle hooks run
  • wraps hook failures in SnapclassError with hook name and path context when available

Why

Downstream migrations need a reliable place to initialize transient fields before normal object use, plus a separate hook once file data has been applied. The previous lifecycle had attachment and load behavior, but no explicit extension points for those phases.

Validation

  • python.exe -m pytest via ErrorHelp: 317 passed
  • git diff --check: clean, aside from existing CRLF normalization warnings

@Mattie
Mattie marked this pull request as ready for review June 24, 2026 05:09
@Mattie
Mattie requested a review from Copilot June 24, 2026 05:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds opt-in snapclass lifecycle hooks to provide explicit extension points after snapshot attachment (__snapclass_ready__) and after file data has been loaded/applied (__snapclass_loaded__), primarily to support migration/transient initialization flows.

Changes:

  • Introduces internal lifecycle hook helpers in schemas.py and triggers them after snapshot attachment and after Snapshot.load() completes.
  • Updates snapshot creation/collection APIs to call the new “ready” hook after attachment.
  • Adds tests covering hook ordering, sidecar visibility, suppression of autosave loops during hooks, and error wrapping.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_sidecar.py Adds regression test ensuring sidecar constructor values are visible when __snapclass_ready__ runs.
tests/test_behavior_contracts.py Adds contract tests for ready/loaded hook ordering, autosave suppression during hooks, and error message context.
src/snapclass/snapshots.py Calls ready hook after attaching a snapshot via create_snapshot().
src/snapclass/schemas.py Implements lifecycle hook invocation, hook suppression context, and calls ready/loaded hooks from init/sync/load paths.
src/snapclass/collections.py Ensures collection instantiation paths call the ready hook before initial load.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/snapclass/schemas.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c10f6286ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/snapclass/schemas.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4fc4688f1d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/snapclass/schemas.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread src/snapclass/schemas.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 67f22d37b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/snapclass/schemas.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8fb3705c4b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/snapclass/schemas.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1bcbfc1c28

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/snapclass/schemas.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b51f26d40e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/snapclass/collections.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread src/snapclass/sidecar.py Outdated
Mattie and others added 2 commits June 24, 2026 11:37
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ffc7a4458

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/snapclass/schemas.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 463af9d62a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/snapclass/schemas.py
Comment thread src/snapclass/collections.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread src/snapclass/schemas.py
@Mattie
Mattie merged commit b974a26 into main Jun 24, 2026
4 checks passed
@Mattie
Mattie deleted the codex/snapshot-lifecycle-hooks branch June 24, 2026 18:30
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