Skip to content

fix: align OB source constraint comparison - #69

Merged
Minorli merged 3 commits into
mainfrom
fix/ob-source-constraint-alignment
May 9, 2026
Merged

Minorli merged 3 commits into
mainfrom
fix/ob-source-constraint-alignment

Conversation

@Minorli

@Minorli Minorli commented May 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • preserve enabled NOT NULL CHECK group metadata through OB source adaptation so OB->OB duplicate NOT NULL cleanup candidates are visible
  • treat OB automatic NOT NULL checks as column semantics for compare/status paths and prefer OB automatic names when source semantics are automatic
  • guard FK comparison when source OB reference metadata is incomplete instead of matching by column list alone
  • keep OpenSpec notes local-only; no openspec files are included in this PR

Audit triage

  • Valid and fixed: source NOT NULL group loss after OB metadata pruning/adaptation; OB automatic name preference; OB automatic NOT NULL skip semantics; FK source incomplete reference metadata false-match risk
  • Verified already aligned: CHECK BETWEEN/range normalization and source unique-index-derived target UK suppression
  • Deferred intentionally: removing OB automatic NOT NULL physical pruning from dump output; this PR keeps the lower-risk phase-1 shape and uses pre-prune metadata groups for cleanup correctness

Verification

  • .venv/bin/ruff format schema_diff_reconciler.py
  • git diff --check
  • .venv/bin/python -m py_compile schema_diff_reconciler.py run_fixup.py diagnostic_bundle.py comparator_reliability.py
  • .venv/bin/python -m py_compile comparator_reliability.py
    diagnostic_bundle.py
    init_users_roles.py
    run_fixup.py
    schema_diff_reconciler.py
    tools/build_release_package.py
  • .venv/bin/python -m unittest test_schema_diff_reconciler.TestSchemaDiffReconcilerPureFunctions -k compare_constraints -v (30 tests)
  • .venv/bin/python -m unittest test_schema_diff_reconciler.TestSchemaDiffReconcilerPureFunctions -v (825 tests)
  • OB real DB probe: created temporary OB tables in OMS_USER, loaded metadata via dump_ob_metadata -> adapt_ob_metadata_to_source_oracle_metadata -> compare_constraints_for_table, verified duplicate_notnull_extra_constraints contains the extra target CHECK, then dropped temp tables
  • openspec validate update-ob-source-constraint-alignment --strict (valid; telemetry flush failed due network DNS only)
  • pre-commit during git commit: ruff check, ruff format, detect-secrets passed
  • pre-push hook: pytest passed

@Minorli

Minorli commented May 9, 2026

Copy link
Copy Markdown
Owner Author

PK coverage follow-up completed.

Added a tracked focused regression file: tests/test_ob_source_constraint_pk.py

  • verifies OB source partition PK whose columns do not include the partition key is matched by a target UNIQUE constraint
  • verifies the same downgraded PK is reported as missing and marked in downgraded_pk_constraints when no target PK/UK exists

Also excluded tests/ from customer release packaging so tracked regression files do not enter the toolkit zip.

Additional verification after this follow-up:

  • .venv/bin/python -m unittest tests.test_ob_source_constraint_pk -v
  • .venv/bin/python -m pytest -q tests/test_ob_source_constraint_pk.py
  • .venv/bin/python -m py_compile comparator_reliability.py
    diagnostic_bundle.py
    init_users_roles.py
    run_fixup.py
    schema_diff_reconciler.py
    tests/test_ob_source_constraint_pk.py
    tools/build_release_package.py tests/test_ob_source_constraint_pk.py
  • .venv/bin/python tools/build_release_package.py --version 0.0.0-ci --output-dir dist_pk_test
  • package zip inspection confirmed tests/ is not included
  • .venv/bin/python -m pytest -q => 1194 passed, 2 skipped, 6 subtests passed
  • git diff --check
  • pre-commit: ruff check, ruff format, detect-secrets passed
  • pre-push: pytest passed

@Minorli

Minorli commented May 9, 2026

Copy link
Copy Markdown
Owner Author

Customer clarification addressed: OB->OB constraint detection completeness, not only cleanup.

Newly fixed detection gaps:

  • OB source strict constraint compare now reports target PK/UK/FK extras only when the source has the same constraint family on that column set. It no longer suppresses a target PK just because source has a UK/FK/CHECK on the same columns.
  • Source FK rows with incomplete reference metadata now disable the cache-signature fast path, so FK unknown-reference cases cannot be incorrectly marked OK when source/target signatures both contain NULL ref metadata.
  • The strict behavior is scoped to source_db_mode=oceanbase; Oracle->OB keeps the older permissive column-noise behavior.

Added regression coverage:

  • source UK vs target PK same columns => missing UK + extra PK
  • source PK vs target FK same columns => missing PK + extra FK
  • source/target FK both missing ref metadata with equal signatures => mismatch, not OK
  • previous PK partition downgrade tests remain covered

Verification added after this commit:

  • .venv/bin/python -m pytest -q tests/test_ob_source_constraint_pk.py => 5 passed
  • .venv/bin/python -m pytest -q selected threadpool compatibility + strict constraint tests => 7 passed
  • .venv/bin/python -m unittest test_schema_diff_reconciler.TestSchemaDiffReconcilerPureFunctions -k compare_constraints -v => 30 passed
  • .venv/bin/python -m pytest -q => 1197 passed, 2 skipped, 6 subtests passed
  • .venv/bin/python -m py_compile comparator_reliability.py
    diagnostic_bundle.py
    init_users_roles.py
    run_fixup.py
    schema_diff_reconciler.py
    tests/test_ob_source_constraint_pk.py
    tools/build_release_package.py
  • git diff --check
  • release package smoke, and zip inspection confirmed tests/ is excluded
  • OB real DB strict detection probe: created temporary OB source UK table and target PK table, loaded real metadata, ran check_extra_objects(source_db_mode=oceanbase), verified missing source UK + extra target PK, then cleaned up temp tables
  • pre-commit: ruff check, ruff format, detect-secrets passed
  • pre-push: pytest passed

@Minorli
Minorli merged commit 9dfa34b into main May 9, 2026
4 checks passed
@Minorli
Minorli deleted the fix/ob-source-constraint-alignment branch May 9, 2026 06:14
@Minorli

Minorli commented May 9, 2026

Copy link
Copy Markdown
Owner Author

Merge note: GitHub rejected formal approval from the current account because it is the PR author (self-approval is not allowed). After all required checks were green and the repository owner requested merge, PR #69 was squash-merged with administrator privileges. Local main is fast-forwarded to merge commit 9dfa34b.

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