Skip to content

Simplify lnk_persist_init after clean cypher snapshot lands #169

@NewGraphEnvironment

Description

@NewGraphEnvironment

Problem

lnk_persist_init is overcomplicated because it defends against a broken cypher snapshot (rtj issue [linked]). Specifically:

  • force_recreate = TRUE flag is misleadingly named — it doesn't actually force-recreate, it only DROPs tables with unexpected GENERATED ALWAYS columns
  • DDL-drift detection only catches ONE specific drift pattern (GENERATED columns from a prior frs_col_generate() run baked into snapshot)
  • No "wipe data" concept — the function only thinks about DDL, not data state
  • Conflates "ensure tables exist with right shape" (setup) with "ensure tables are empty" (clean-slate run)

Most of this complexity exists to compensate for the rtj-side snapshot that ships with stale fresh.streams data. Once that's fixed, this function can be ~20 lines simpler.

Proposed: simplify after rtj snapshot fix

When the clean-snapshot rtj issue lands:

  1. Drop force_recreate flag — no longer needed
  2. Drop DDL-drift detection (the .lnk_validate_persist_table helper + GENERATED-column check)
  3. Function becomes: CREATE SCHEMA IF NOT EXISTS + CREATE TABLE IF NOT EXISTS for each expected table. That's it.
  4. Update tests to reflect simpler contract (drop the DDL-drift test cases — they become obsolete)

Why not now?

The rtj snapshot rebuild isn't done yet. Until it ships, lnk_persist_init's defensive logic IS load-bearing — without it, cypher dispatch fails with "cannot insert non-DEFAULT value into column gradient" (the bug it was added to fix in Phase 7).

So this issue waits for the rtj-side fix to land first, then this becomes a pure simplification PR. Cross-ref blocking.

Acceptance

  • lnk_persist_init has no force_recreate arg
  • No DDL-drift detection logic
  • Tests cover only "creates tables if missing, no-op if present"
  • Function body < 50 lines (currently ~80)

Cross-ref

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions