Skip to content

Commit 5ddd5d3

Browse files
baozhoutaoclaude
andauthored
fix(cli): migrate-meta's semver-label assertion targets the Chain: line, not the whole stdout (#17654)
`os migrate meta --from N` (no `--to`) defaults toMajor to CHAIN_TERMINUS_MAJOR (18), one major ahead of PROTOCOL_MAJOR (17), because protocol-18 semantic migration entries are already pre-registered in packages/spec/src/migrations/registry.ts. Their `why:` prose legitimately CITES the 17.0.0 GA release ("Measured on 17.0.0 GA end to end: …") and is printed verbatim by the human-output path — a real historical citation, not the mislabelled-runtime-version defect this test guards (docblock :468-480). The blunt whole-stdout `expect(stdout).not.toContain(PROTOCOL_VERSION)` cannot tell the two apart and fires on the citation. Narrows that assertion to the version-label surface the docblock names (the `Chain:` line), keeping both halves the docblock requires: no bare semver in the Chain: line's version position, and no semver after the word "runtime" anywhere (unchanged, already green). Also pins `--to PROTOCOL_MAJOR` explicitly on the sibling "names this build's protocol major, in majors" case, which silently rode the same drifting default into a hop it was never meant to exercise. No production code touched; packages/spec/src/migrations/** (the data under test) is untouched, per the card's own instruction not to damage a real historical record to silence an instrument. Claude-Session: https://claude.ai/code/session_012GKcPZbMoGq7WPzKLfRBTU Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9e3c485 commit 5ddd5d3

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

packages/cli/test/migrate-meta.e2e.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,32 @@ export default {
510510
});
511511

512512
it("names this build's protocol major, in majors", async () => {
513-
const stdout = await runMeta(['--from', String(PROTOCOL_MAJOR)], labelDir);
513+
// `--to` is pinned to PROTOCOL_MAJOR deliberately: the unqualified default
514+
// is CHAIN_TERMINUS_MAJOR (the highest major ANY migration step is
515+
// registered for), which legitimately runs ahead of PROTOCOL_MAJOR once a
516+
// future major's steps are pre-authored (see migrate/meta.ts). This case
517+
// is specifically the "already at this runtime's own major" no-op chain,
518+
// so it names both ends explicitly rather than riding a default that is
519+
// designed to drift.
520+
const stdout = await runMeta(['--from', String(PROTOCOL_MAJOR), '--to', String(PROTOCOL_MAJOR)], labelDir);
514521
expect(stdout).toContain(
515522
`Chain: protocol ${PROTOCOL_MAJOR}${PROTOCOL_MAJOR} (this runtime implements protocol ${PROTOCOL_MAJOR})`,
516523
);
517524
}, 120_000);
518525

519526
it('prints no padded protocol semver in the human output, under any label', async () => {
527+
// Deliberately NOT pinning `--to` here: the default climbs to
528+
// CHAIN_TERMINUS_MAJOR, which is exactly what exercises the real risk
529+
// surface this test guards — a hop's semantic `why:` prose (which may
530+
// legitimately CITE a past release's bare semver, e.g. "measured on
531+
// 17.0.0 GA …") printed verbatim into stdout. The instrument must not
532+
// confuse that citation with the mislabelled-runtime defect the docblock
533+
// above describes, so it targets the version-label surface (the `Chain:`
534+
// line / the word "runtime") instead of the whole transcript.
520535
const stdout = await runMeta(['--from', String(PROTOCOL_MAJOR)], labelDir);
521-
expect(stdout).not.toContain(PROTOCOL_VERSION);
536+
const chainLine = stdout.split('\n').find((line) => line.includes('Chain:'));
537+
expect(chainLine, 'the Chain: line must be present to assert against').toBeTruthy();
538+
expect(chainLine).not.toContain(PROTOCOL_VERSION);
522539
expect(stdout).not.toMatch(/runtime \d+\.\d+\.\d+/);
523540
}, 120_000);
524541

0 commit comments

Comments
 (0)