Skip to content

feat(lesson): alembic upgrade failure diagnosis - #1713

Open
zsxh1990 wants to merge 1 commit into
Ikalus1988:mainfrom
zsxh1990:lesson/alembic-v2
Open

zsxh1990 wants to merge 1 commit into
Ikalus1988:mainfrom
zsxh1990:lesson/alembic-v2

Conversation

@zsxh1990

Copy link
Copy Markdown
Contributor

Summary

New lesson documenting alembic migration chain divergence: diagnosis commands, fix-by-scenario playbooks.

Closes #1652

Lesson Content

  • Problem: alembic upgrade head fails after dependency update
  • Root cause: migration chain diverges from alembic_version table
  • Solution: diagnose → stamp/merge/rollback per scenario
  • Prevention: alembic check before upgrade, backup before migrate

@Ikalus1988 Ikalus1988 added area:docs area:lessons lessons-only needs-human-review Content needs maintainer judgment (real experience, root cause quality) shape-safe labels Sep 15, 2026
@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Ikalus1988 Ikalus1988 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lesson itself is the right shape and I want it in the corpus: Problem names three distinct failure modes, Root Cause explains the alembic_version ↔ chain divergence (including the SQLite no-transactional-DDL trap), Solution is a real diagnostic sequence rather than a recipe, and Verification ends on the criterion that actually matters (alembic heads must show one line). All 24 checks are green.

One blocker, and it is the one thing this corpus cannot ship:

The source URL does not exist

source: "https://github.com/modelcontextprotocol/mcp-memory-service/issues/1652"
provenance:
  source: "community"
  issue: 1652

I checked both:

GET /repos/modelcontextprotocol/mcp-memory-service              -> HTTP 404
GET /repos/modelcontextprotocol/mcp-memory-service/issues/1652  -> HTTP 404

The repository does not exist, so the issue cannot either. And issue: 1652 is our own bounty issue number, not an upstream source — the two have been merged into one line, which is how a plausible-looking provenance got invented. The actual origin is the third-party report that opened intake #1553 (source repo s6pa1rta3n-lab/roof4u, error Command '['alembic', 'upgrade', 'head']' returned non-zero exit status 255).

Provenance is the trust anchor here: E-levels, evidence_refs and the whole "verifiable contributions" story mean a reader must be able to follow that link. A lesson with an invented upstream URL is worse than one that admits it has no upstream — which is why #1553's own AC says "先补齐被截断的 stderr——拿不到真实根因就不要写成课程".

Please fix (small, ~4 lines)

  1. provenance.issue: "#1553" — quoted, matching the corpus convention (grep -r 'issue: "' lessons/ for examples). That is the report this task converts.
  2. Keep the external source only if it resolves; otherwise drop the URL and say where it came from in plain words (第三方仓库 s6pa1rta3n-lab/roof4u 报料). If you have the real upstream issue, link that instead.
  3. created: '2026-09-07' / updated: '2026-09-07' predate this PR by eight days and predate the intake by a day — set the real dates, or drop both fields (most of the corpus omits them).
  4. evidence_level: E3 needs to be defensible: either state where you reproduced this (alembic version, DB backend, what you saw before/after alembic merge), or lower it and say plainly that the sequence is derived rather than reproduced. Honest beats decorated — the Verification section already reads like "should", which is fine as long as it is not labelled as reproduced evidence.

Nothing else needs to change; the filename is yours to choose (#1553's AC suggests alembic-upgrade-head-failed.md, but kebab-case is the only hard rule).

One coordination note

There are now two open PRs for #1652: this one and #1656 (@TaherEzzi, a 519-byte skeleton that also edits the generated lessons/index.md). You claimed the task on 2026-09-15, and yours is the one worth finishing — so this PR is the live candidate. Just be aware #1656 exists so we don't merge both.

Signed-off-by: zsxh1990 <445655361@qq.com>
Ikalus1988 added a commit that referenced this pull request Sep 16, 2026
The existing gates each cover one axis and none of them covers truth: `lesson_gate.py`
checks structure, DCO checks signatures, `injection_scan.py` checks injection shapes. So on
2026-09-16 four lesson PRs (#1713#1716) passed **24/24 checks** while every one of them
cited `https://github.com/modelcontextprotocol/mcp-memory-service/issues/1652` — a
repository that returns 404, dressed up with `evidence_level: E3`. In a corpus whose value
is *verifiable* failure memory, an invented source is worse than an absent one: it looks
checkable and is not.

`scripts/check_provenance.py` resolves the URLs a lesson cites in its frontmatter, with two
rule tiers that reuse the strict-new/advisory split the lesson gate already uses (#1506) so
legacy debt cannot block unrelated PRs:

- tier 1 (always fails): a placeholder URL (`<owner>`, `TODO`, `{repo}`, `/xxx/`), or a URL
  confirmed dead (404/410) that is not recorded in the baseline.
- tier 2 (new files only): `evidence_level: E2`/`E3` with no resolvable source at all.

The statuses are deliberately conservative — a timeout, a DNS failure, a rate limit or a 5xx
is `unknown` and never fails the build. A gate that goes red on someone else's outage gets
bypassed within a week, so this one fails on evidence only, never on the absence of it.
Private-IP and example.com URLs are exempt by construction: a lesson about a corporate proxy
has to be able to say `http://172.19.128.1:7890`.

`data/provenance-baseline.json` is the debt register for known-dead links; placeholders are
never accepted there (there is a test for that). The corpus currently passes with an empty
baseline: 439 lessons, 31 citations, 30 ok, 1 unknown (a Google docs URL this network cannot
reach — reported, not failed).

Red-teamed against the real case: the #1713 lesson file now exits 1 with
"source does not resolve — ... (HTTP 404)".

The scheduled weekly sweep is report-only, for link rot.

27 tests, offline. Runs on PRs touching lessons/** and on a schedule.

Signed-off-by: Ikalus1988 <136884451+Ikalus1988@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Ikalus1988 added a commit that referenced this pull request Sep 16, 2026
Records what landed, what is in flight, and — the part that matters for a handoff — the six
things that need a human rather than another agent:

1. the first real `/adopt` run (#1746#1750, and explicitly *not* #1656, whose lesson fails the
   structural gate);
2. the first end-to-end auto-merge once an adopted PR exists, since the channel from #1781 is
   live but has never actually merged anything;
3. what to do about #1713#1716 after their provenance fix;
4. whether to create the PAT that would make `fix-dco.yml` fork-capable (optional — `/adopt` is
   the no-secret path);
5. confirming `GET /api/search-signals/stats` returns 200 and grows after the worker deploys,
   because that endpoint is the denominator the efficiency claim has been missing;
6. the policy call on whether external lesson PRs get `auto-merge-lesson` by default.

Also records the process lessons of this stretch, because they cost real time: parallel agents
editing one file entangle the diff (the edit guard catches it, but integration means splitting by
hunk); a stub-`gh` replay of eleven scenarios passed while the real workflow went red on every PR
because `gh api user` returns 403 for an App installation token — a stub can verify logic, not
authority; and a test that passes locally can fail in CI because its evidence lives in a
gitignored directory on the author's machine.

Signed-off-by: Ikalus1988 <136884451+Ikalus1988@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs area:lessons lessons-only needs-human-review Content needs maintainer judgment (real experience, root cause quality) shape-safe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty][$0][Lessons] 把 intake #1553(alembic upgrade 失败)转成课程

2 participants