Phase 3 Work Package: Deterministic Constraints and Canonical Graph Contract Alignment
Status: PASS (checkpoint 2 complete) Date: 2026-03-29
Objective
Advance from Phase 2 cutover verification into a bounded Phase 3 implementation slice that hardens deterministic DB contracts and removes remaining legacy graph namespace assumptions in high-signal integration tests.
Bounded Scope
- Canonical graph contract alignment in integration tests.
- Update graph contract assertions and fixtures to prefer canonical fields/semantics (
kind,path,predicate_path) over legacy namespace assumptions where those assumptions are now obsolete.
- Deterministic constraint enforcement signal preservation.
- Preserve and verify deterministic behavior for IDs and audit patch helpers.
- Preserve RLS/predicate-policy semantic guarantees while moving assertions to canonical contract language.
- Forward migration only if required.
- Add a single forward migration only when implementation reveals a real contract mismatch that cannot be addressed at test/contract-call level.
- No destructive or compatibility-window rollback behavior.
In-Scope Files
- integration-tests/graph-access-control.db-contract.test.ts
- integration-tests/graph-db-functions.db-contract.test.ts
- docs/reference/modules/phase-2-cutover-handoff-2026-03-29.md
- Optional forward migration in db/migrations if test-driven gap requires it.
Out of Scope
- Rewriting baseline historical schema files under db/migrations/20251207_001_initial_schema.
- Non-graph unrelated workflow suites.
- Backward-compat alias restoration.
Acceptance Checks
Run these before and after edits:
pnpm vitest run --project integration-tests-node-pglite-memory integration-tests/db-ids.db-contract.test.ts integration-tests/db-audit.db-contract.test.ts integration-tests/graph-access-control.db-contract.test.ts --reporter=dotpnpm vitest run --project integration-tests-node-pglite-memory integration-tests/graph-db-functions.db-contract.test.ts integration-tests/graph.router.test.ts --reporter=dotpnpm vitest run --project integration-tests-node-pglite-memory integration-tests/db-bootstrap.db-contract.test.ts integration-tests/db-migrations.db-contract.test.ts --reporter=dot
Baseline Snapshot (Pre-Implementation)
- Command (1) current baseline:
- Test Files 3 passed (3)
- Tests 15 passed (15)
- Duration 10.43s
Progress Checkpoint 1 (Post-Edit)
Implemented change:
- Updated graph access-control contract tests to use canonical graph columns in direct SQL assertions (
kind,path,predicate_path) instead of legacytype_namespace/predicateassumptions.
Post-edit acceptance results:
- Command (1): Test Files 3 passed (3), Tests 15 passed (15), Duration 11.44s.
- Command (2): Test Files 2 passed (2), Tests 19 passed (19), Duration 34.86s.
- Command (3): Test Files 2 passed (2), Tests 10 passed (10), Duration 7.39s.
Objective alignment status:
- Canonical graph contract alignment: on track.
- Deterministic constraint enforcement signal preservation: on track.
- No Phase 1/2 gate regression: on track (acceptance suite remains green).
Progress Checkpoint 2 (Hard-Rename Stabilization)
Implemented changes:
- Completed full hard rename of graph function parameter contracts to canonical
p_kind/*_kindnaming in migration sources and regenerated contract bindings. - Added forward-only migrations for already-migrated environments to force signature/body convergence:
db/migrations/20260329_013_function_param_kind_hard_rename.sqldb/migrations/20260329_014_create_resource_kind_collision_recovery.sqldb/migrations/20260329_015_create_resource_kind_collision_recovery_v2.sqldb/migrations/20260329_016_collection_helpers_kind_arg_forward_fix.sql
- Resolved remaining
42883 undefined_functionfailures caused by stale function-body named-argument metadata in persistent migration state.
Post-stabilization acceptance results:
- Command (1): Test Files 3 passed (3), Tests 15 passed (15), Duration 10.48s.
- Command (2): Test Files 2 passed (2), Tests 19 passed (19), Duration 30.93s.
- Command (3): Test Files 2 passed (2), Tests 10 passed (10), Duration 7.83s.
Objective alignment status:
- Canonical graph contract alignment: complete for this bounded slice.
- Deterministic constraint enforcement signal preservation: complete for this bounded slice.
- Forward migration policy: satisfied (forward-only migrations used for replay-safe convergence).
- Phase 1/2 gate compatibility: preserved (acceptance triplet remains green).
Broader integration slice revalidation:
- Command:
pnpm vitest run --project integration-tests-node-pglite-memory integration-tests/db-bootstrap.db-contract.test.ts integration-tests/db-migrations.db-contract.test.ts integration-tests/db-error-handling.workflow.test.ts integration-tests/graph-db-functions.db-contract.test.ts integration-tests/graph-access-control.db-contract.test.ts integration-tests/graph.router.test.ts integration-tests/entities-crud.profile.workflow.test.ts --reporter=dot
- Result:
- Test Files 7 passed (7)
- Tests 70 passed (70)
- Duration 45.32s
- Interpretation:
- Hard-rename and forward convergence changes remain stable on the broader verification slice, not only the minimal acceptance triplet.
Exit Criteria
- Acceptance checks pass post-implementation.
- No regression in Phase 1 and Phase 2 gate docs/evidence.
- Any migration added is forward-only and justified by failing contract evidence.