Skip to content

Preserve shared labels and preflight variable lineage dependencies - #20

Merged
TonisOrmisson merged 2 commits into
mainfrom
fix/inplace-metadata-integrity
Sep 8, 2026
Merged

TonisOrmisson merged 2 commits into
mainfrom
fix/inplace-metadata-integrity

Conversation

@TonisOrmisson

@TonisOrmisson TonisOrmisson commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Phase 2 — in-place metadata integrity

Keeps existing canonical-plan and SPSS entry points, dataset/table identity, and ordered execution. No dependencies, new configuration, workflow installation, or persistent rollback/copy layer.

Changes

  • Detach a variable from its old value-label set before pruning it; preserve labels while another variable still references that set.
  • Reject deletion of original variable IDs referenced by published derived lineage with variable_has_dependents, before any plan mutation. Same-name recreation cannot bypass this guard; plan-local create/delete sequences remain supported.
  • Enable and verify native SQLite foreign-key enforcement on apply-owned connections before the existing transaction begins.
  • Changes are confined to one production file and one existing test file.

Validation

  • RED commit 0927d6a: 7 reproduced failures and 1 already-working sequential control.
  • GREEN commit 395cbc0: all 8 scenarios pass; related frontend/workflow/CLI/apply suites: 158 passed.
  • Full local non-service suite: 381 passed, 8 skipped, 49 service cases deselected.
  • git diff --check passes; independent full-diff local subagent review: No findings.
  • Both push and PR CI passed all 14 jobs: Python 3.11–3.14, package build/install, PostgreSQL 17.10/18.4, MySQL 8.4.11/9.7.2, MariaDB 11.4.12/11.8.8/12.3.2, and Dolt 2.2.2/2.2.3 default-write integration. Local evidence uses temporary SQLite databases; live coverage is not inferred from mocks.

Scope and next phase

Phase 1 PHP import-integrity PR OpenStatSpec/php#12 is merged. Phase 2 is ready for handoff at 395cbc0: independent local full-diff review found no issues; latest-head @codex review completed without findings and confirmed 👍; CodeRabbit also reported no actionable comments. All GitHub checks pass. Its optional docstring-percentage suggestion does not justify unrelated boilerplate.

Next: phase 3 — Python export reads values and metadata from one consistent database snapshot without database writes, in a separate PR.

Do not merge automatically. Worktree is clean and both logical commits are pushed. The overall phase plan is not yet complete.

@TonisOrmisson

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-08T06:14:01.229587Z 395cbc0 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 00e6dfad-426c-4b5e-a11a-03cd3fbc58bc

📥 Commits

Reviewing files that changed from the base of the PR and between 214e4a1 and 395cbc0.

📒 Files selected for processing (2)
  • src/openstatspec/sql/inplace_transform.py
  • tests/test_inplace_transform.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Changes

The in-place transformation workflow now preserves shared value-label records, blocks deletion of variables with published lineage, enables SQLite foreign-key enforcement, and validates rollback behavior.

In-place transformation integrity

Layer / File(s) Summary
Shared value-label ownership
src/openstatspec/sql/inplace_transform.py, tests/test_inplace_transform.py
Value-label replacement keeps records used by sibling variables and removes them after the final owner is replaced.
Lineage-aware variable lifecycle
src/openstatspec/sql/inplace_transform.py, tests/test_inplace_transform.py
Variable deletion checks published lineage before mutation. Tests cover local deletion and recreation of unreferenced variables.
Connection integrity and rollback
src/openstatspec/sql/inplace_transform.py, tests/test_inplace_transform.py
SQLite connections enable foreign-key enforcement. Tests verify rollback after trigger-driven constraint failures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 395cb

In-place transformations now preserve shared labels, prevent deletion of published lineage sources, and enforce SQLite foreign keys. The covered behavior is ready to merge with no identified outstanding production risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: preserving shared value labels and preflighting variable lineage dependencies before deletion.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/inplace-metadata-integrity

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 395cbc09f2

ℹ️ 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".

@TonisOrmisson
TonisOrmisson merged commit 790051c into main Sep 8, 2026
29 checks passed
@TonisOrmisson
TonisOrmisson deleted the fix/inplace-metadata-integrity branch September 8, 2026 07:36
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