Skip to content

cleanup(phase7): regenerate migrations to post-phase-7 initial#1666

Merged
earayu merged 2 commits into
mainfrom
bryce/phase7-migration-regen
Apr 24, 2026
Merged

cleanup(phase7): regenerate migrations to post-phase-7 initial#1666
earayu merged 2 commits into
mainfrom
bryce/phase7-migration-regen

Conversation

@earayu
Copy link
Copy Markdown
Collaborator

@earayu earayu commented Apr 24, 2026

Phase 7 收尾:全量数据库 migration 重生 — task #33

Per 主架构师 @符炫炜 canonical 边界(task #33 thread msg=4d8a6c49) + PM msg=caffbd22 执行口径。

Baseline

  • origin/main @ 613514c4 (Phase 7 post-cleanup code terminal state)
  • 旧 chain length: 32 revisions(base db9c88848f52 → head e1f2a3b4c5d6
  • 新 chain length: 1 revision6a8fc31427d9 post_phase_7_initialdown_revision = None

Scope (minimal canonical work only — per symofons gate)

仅重生 aperag/migration/versions/*.py 反映 post-Phase-7 ORM state;做 schema 变更 / domain absorption / ORM drift 修补。

Execution summary

  1. Dropped all 32 legacy migration files (including Phase 1-6 lineage)
  2. Autogenerated 20260425041904-6a8fc31427d9_post_phase_7_initial.py (865 lines)
  3. Inspected: 40 op.create_table() calls — all expected, no drift

Inspect results

29 domain ORM tables(all 12 domains covered):

  • identity: user / oauth_account
  • governance: api_key / audit_log
  • model_platform: llm_provider / llm_provider_models
  • marketplace: collection_marketplace / user_collection_subscription
  • knowledge_base: collection / document / collection_summary
  • indexing: document_index
  • retrieval: searchhistory
  • knowledge_graph: graphindex_nodes / graphindex_edges / graphindex_chunks / graph_curation_runs / graph_curation_suggestions
  • conversation: bot / chat / turn_feedback
  • agent_runtime: agent_turn / agent_timeline_event / agent_artifact
  • evaluation: evaluation_datasets / evaluation_dataset_items / evaluation_runs / evaluation_run_items / evaluation_run_item_attempts

11 legacy local ORMs (still in aperag/db/models.py per inventory v1 §1 Layer C + Phase 7 end-state legacy compatibility layer): config / user_quota / invitation / prompt_template / setting / export_task / evaluations / evaluation_items / questions / question_sets / model_service_provider

§1 PERMANENT verification

  • Layer C invitation.role column → sa.String(length=50) (via EnumColumn helper producing String(max_enum_value_length) per aperag/db/models.py:55-59) — identity-domain Role enum binding preserved, class-body load-time import intact ✅
  • Layer A/B PERMANENT services (quota / prompt_template / search_pipeline) — non-ORM, unaffected ✅
  • Layer D G17/G18-alt CRITICAL_WIRINGS — migration layer does not touch DI ✅
  • aperag/db/base.py Base.metadata — unchanged ✅
  • aperag/migration/env.py per-domain model imports — unchanged ✅

pgvector observation (informational, not drift)

No Vector() columns in the new initial migration. Post-Phase-7 Base.metadata has zero ORM tables declaring a Vector column (LightRAG tables were dropped earlier in Phase 7 chain). The pgvector extension creation was removed with them. This matches current ORM state — not drift. If the pgvector module (outside Base.metadata) provisions its own schema at runtime, it would create its own extension. Flagged for task #34 smoke verification.

Round-trip + stability gates

  • Local Postgres 16 + pgvector 0.7.2 (127.0.0.1:55432/aperag)
  • alembic downgrade base → success (no-op on empty DB, chain traversable)
  • alembic upgrade head → success exit 0, 41 relations created (40 tables + alembic_version)
  • Second alembic revision --autogenerate -m "_tmp_verify_no_diff"upgrade() pass / downgrade() pass emptyzero drift ✅(终态稳定)

G-gate results

  • pytest tests/unit_test/test_modularization_boundaries.py -x -q20 passed / 0 failed (G1-G19 all green) ✅
  • pytest tests/unit_test/ -x --ignore=tests/unit_test/objectstore -q577 passed / 29 skipped / 1 failed — the single failure (test_web_typed_api_contract.py::test_phase1_fe_complete_identity_auth_admin_audit_adapter_boundary missing listUserQuotas) is pre-existing on baseline 613514c4(verified by stash+rerun); unrelated to migration regen. This is a FE contract drift on main, flagged separately.

Ghost-check

Ghost-check: none — §1 Layer A/B/C/D/E untouched; scope strictly bounded to aperag/migration/versions/*.py replacement; 32 old migrations deleted, 1 post_phase_7_initial created; round-trip + no-diff verified on real local Postgres + pgvector.

Follow-up

per docs/modularization/cleanup-inventory.md v1 §Phase7-postmerge + 符炫炜 task-thread canonical gate.

🤖 Generated with Claude Code

earayu and others added 2 commits April 25, 2026 04:23
Replace the 32-revision Alembic chain with a single post-Phase-7
initial migration. Fresh empty DB → `alembic upgrade head` now yields
the exact same schema as the current ORM state, with no intermediate
LightRAG / legacy steps.

Ghost-check:
- docs/modularization/cleanup-inventory.md §Phase7-postmerge: chain
  collapsed, zero schema change
- §1 Layer A / B / C untouched: aperag/db/base.py Base.metadata
  unchanged; aperag/db/models.py Invitation class-body `Role` binding
  via `from aperag.domains.identity.db.models import ... Role ...`
  preserved; env.py per-domain model imports preserved
- G17 / G18-alt CRITICAL_WIRINGS unchanged (migration layer doesn't
  touch DI); 20/20 G1-G19 boundary tests pass

Verification:
- Old chain: 32 revisions (base db9c88848f52 → head e1f2a3b4c5d6)
- New chain: 1 revision (base → head 6a8fc31427d9 `post_phase_7_initial`)
- Round-trip: `alembic downgrade base` + `alembic upgrade head`
  succeed against fresh local Postgres 16 + pgvector 0.7.2 DB;
  41 relations created (40 ORM tables + alembic_version)
- Stability: second `alembic revision --autogenerate` produces an
  empty upgrade() / downgrade() (no drift)
- Tables: all 13 domain surfaces present (identity / governance /
  model_platform / marketplace / knowledge_base / indexing /
  retrieval / knowledge_graph / conversation / agent_runtime /
  evaluation) plus 11 legacy local ORMs (ConfigModel / UserQuota /
  Invitation / PromptTemplate / Setting / ExportTask / Evaluation /
  EvaluationItem / Question / QuestionSet / ModelServiceProvider)
- No pgvector extension / Vector column DDL in the initial: no ORM
  declares Vector type post-Phase-7 (LightRAG tables already dropped)
- No re-export shim leakage; invitation.role renders as String(50)
  (EnumColumn helper is a varchar, matching identity domain Role)

Tests:
- tests/unit_test/test_modularization_boundaries.py: 20 passed
- tests/unit_test/ broad regression (minus pre-existing unrelated
  failure `test_phase1_fe_complete_identity_auth_admin_audit_adapter_boundary`):
  577 passed, 29 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Weston blocker-level CR (msg=fa0b6b4e) found 1 mechanical `git diff --check`
blocker: `aperag/migration/versions/20260425041904-6a8fc31427d9.py:4` had
trailing whitespace on the `Revises: ` line (template artifact from alembic
autogenerate). Normalized via `rstrip()` on all lines.

Whitespace-only change; no logic or schema diff.

Ghost-check: none — §1 Layer A/B/C/D/E untouched; whitespace-only trailing-space strip.
@earayu earayu merged commit 98b0f39 into main Apr 24, 2026
0 of 2 checks passed
@earayu earayu deleted the bryce/phase7-migration-regen branch April 24, 2026 20: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.

1 participant