Skip to content

Commit 8b23ee5

Browse files
test(dogfood): build the commit revert cases' publish fixtures in hooks, so each case's clock times the revert it pins (#34323)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbNTugWasvhTMrtCZiFGrZYK)_ Fixes #34271 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:只改一个 dogfood 测试文件。两个用例在用例体内现场发布对象来造夹具,现把这些发布移到嵌套 describe 的 beforeAll 里,断言一字未改。 - 为什么改:合并队列里该文件的「可写包的编辑提交原位恢复」用例三次超时(5.0–5.1 秒,默认 5 秒上限),把三条 PR 踢出队列。测量证明是慢 runner 上的计时悬崖,不是产品变慢。 - 风险与回滚:只动测试,产品代码与已发布包零改动;回滚就是 revert 这一个提交。用例的 5 秒上限没有放宽。 - 先看:`packages/qa/dogfood/test/package-commit-revert-path-package.dogfood.test.ts` 末尾的嵌套 describe(编辑提交夹具),以及第四个用例外层的嵌套 describe(已卸载包夹具)。 - 两分钟验证:`pnpm --filter @objectstack/dogfood exec vitest run --project isolated --reporter=verbose test/package-commit-revert-path-package.dogfood.test.ts`,预期 12/12 通过,末尾用例约 0.7 秒(原约 2.6–3.0 秒)。 - 需要你做的:无,席位落地。 ## What changes `packages/qa/dogfood/test/package-commit-revert-path-package.dogfood.test.ts` only (a private package; nothing publishes, hence `skip-changeset`). - `[#29414] control: a writable package's edit commit restores its own row in place`: its two object publishes (the create, then the edit that records the edit commit) move into the `beforeAll` of a nested `describe`, with a 60 s hook budget. The case now times the revert it pins and the label read after it. - `an uninstalled package's commit is refused 404 …`: the package create and its object publish move the same way. The uninstall, both refusals and every read stay in the case. - Every assertion is unchanged, and so is the order the suite writes state in: each nested suite runs at the position its case had. No per-case timeout is raised, and nothing is skipped or quarantined. ## Diagnosis: (a) a load/timing cliff, not a product regression and not a conflict between the roots <details><summary>Failing queue builds: the reason line is a timeout, in the same case each time</summary> Every one fails in `Dogfood Regression Gate (3/3)` with `Error: Test timed out in 5000ms.` at line 370, the last case of the file: | queue build | edit-commit control | uninstalled case | B-rollback control (1 publish) | file | |---|---|---|---|---| | 43795201091 (root) | **5098 ms ×** | 3845 ms | 1725 ms | 35.1 s | | 43792843358 (independent) | **5013 ms ×** | 4020 ms | 1853 ms | 36.9 s | | 43797161496 (inherited) | **5068 ms ×** | 4251 ms | 2041 ms | 37.4 s | None of the roots touches the file, and the cases with no publish in them stay at 40–190 ms in the same runs. </details> <details><summary>Green history: the case's cost follows the runner's speed, and its ratio to a one-publish control does not move</summary> The edit-commit control on green runs (scheduled `main` and queue builds, shard that ran the file): - 11-04 to 11-13 (8 scheduled runs): 2261 to 3155 ms. - 11-14 to 11-16 (12 runs): 2244 to 4493 ms. Fast runners on the newest trees read 2244 ms (`7be32d39fa`) and 2488 ms (`9efb58f1ca`, a later tree than the failing builds), the same as 11-06's 2350 ms. - Its ratio to the one-publish `B rolls back` control stays 2.2 to 2.6 on every run read, so the product did not get slower on this path. What changed is runner load: the file's total runs from 18 s to 37 s across runners. </details> <details><summary>Local measurement (shared 4-core box, under the verify lock; absolutes are shared-box seconds, ratios carry)</summary> Per-call wall of the edit-commit control on `origin/main` (instrumented copy, three runs): - `publish-drafts` (create): 974 / 1221 / 1476 ms - `publish-drafts` (edit): 1034 / 1152 / 1478 ms - the revert under test: 526 / 582 / 700 ms - all reads: 11 to 17 ms each So about 80 % of the case's clock went to the two fixture publishes. The uninstalled case is similar: the package create took 517 to 597 ms and the object publish 1081 to 1236 ms, against 521 to 596 ms for the uninstall. | case | origin/main alone ×2 | this PR alone ×2 | loaded (4 workers, both files plus 2 neighbours) | |---|---|---|---| | edit-commit control | 2611 / 3046 ms | 678 / 655 ms | 3750 → 761 ms | | uninstalled case | 2226 / 2537 ms | 658 / 612 ms | 2567 → 651 ms | | B-rollback control (untouched) | 1178 / 1195 ms | 1211 / 1286 ms | 1421 / 1446 ms | At the failing builds' runner factor (about 1.7 to 1.9 times local alone), the edit-commit control comes out at about 1.2 to 1.4 s against its 5 s clock, which was 5.0 to 5.1 s before. The hook does the two publishes: 2.0 to 3.0 s locally, so about 5 s at that factor, inside its 60 s budget. The file's top-level hook keeps its own 180 s. </details> ## Tests <details><summary>Ablation: the moved fixture still feeds a pin that bites</summary> The forbidden behaviour is the one that `[#29414]` closed: a revert restoring a row other than the committing package's own row. It was put back in the built `@objectstack/metadata-protocol` `dist/index.js`, which is the file the dogfood isolated project resolves for that package. That file is untracked build output, so no source file was touched. The `restoreVersion` call's `packageId: commitPackageId,` became `packageId: null`. On disk, the marker count went to 1 and the anchor count went from 2 to 1. - Run: `vitest run --project isolated -t 'restores its own row in place'` (the top-level hook and the new nested hook both ran). - Result, red: ```text AssertionError: expected 'A edited 2' to be 'A edited 1' // Object.is equality Tests 1 failed | 11 skipped (12) ``` - Restored from the saved copy. The sha256 equals the pre-mutation copy (`829c9eb0…`), and the marker count is 0. - Observation: under that mutation the case's status, `success` and `action: 'restored'` pins still pass. The label read is the pin that catches it, and it is kept as it was. </details> ## Verification <details><summary>Local gate subset</summary> - `eslint --no-inline-config` on the file: exit 0. - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` on HEAD `e863d61b84` derived 53 commands, and each one was run with its exit code captured before any pipe. Results are in the report on the card. - `check:dual-build-cjs-loads` answers PREREQUISITE NOT MET (exit 3, unbuilt packages outside this diff), so it is NOT MEASURED locally and left to CI. - `test:repo`, the full dogfood battery and every CI family are left to CI. Their check-runs are cited in the report. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01QsR2jTkZnXtRhuEiiyidvJ)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 66f6638 commit 8b23ee5

1 file changed

Lines changed: 56 additions & 36 deletions

File tree

‎packages/qa/dogfood/test/package-commit-revert-path-package.dogfood.test.ts‎

Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -154,33 +154,44 @@ describe('dogfood: package commit revert and rollback act only on a commit of th
154154
expect(JSON.stringify(rollback.json)).toContain("Package 'app.cmtprobe-nosuch' not found");
155155
});
156156

157-
it('an uninstalled package\'s commit is refused 404 through its own revert and rollback path, and writes nothing', async () => {
158-
const created = await call('POST', '/packages', {
159-
manifest: { id: GONE, name: 'Commit probe gone', version: '0.1.0', type: 'app', namespace: 'cmtpg' },
157+
// The uninstalled package and its commit are this case's fixture, built in
158+
// the hook so the case's 5 s clock times the uninstall and the two refusals
159+
// it pins, never the package create and object publish before them (a cold
160+
// object publish is the costliest call this file makes).
161+
describe('an uninstalled package', () => {
162+
let before: Commit[];
163+
let target: Commit;
164+
beforeAll(async () => {
165+
const created = await call('POST', '/packages', {
166+
manifest: { id: GONE, name: 'Commit probe gone', version: '0.1.0', type: 'app', namespace: 'cmtpg' },
167+
});
168+
expect(created.status, JSON.stringify(created.json)).toBe(201);
169+
await publishObject(GONE, 'cmtpg_first', 'Gone first');
170+
before = await commitsOf(GONE);
171+
target = before.find((c) => c.operation === 'apply')!;
172+
}, 60_000);
173+
174+
it('an uninstalled package\'s commit is refused 404 through its own revert and rollback path, and writes nothing', async () => {
175+
expect(target).toBeDefined();
176+
177+
const uninstalled = await call('DELETE', `/packages/${GONE}`);
178+
expect(uninstalled.status, JSON.stringify(uninstalled.json)).toBe(200);
179+
expect(await isServed('cmtpg_first')).toBe(false);
180+
// The trail outlives the package's registry entry.
181+
expect(await commitsOf(GONE)).toEqual(before);
182+
183+
const revert = await call('POST', `/packages/${GONE}/commits/${target.id}/revert`, {});
184+
expect(revert.status, JSON.stringify(revert.json)).toBe(404);
185+
expect(revert.json?.error?.code, JSON.stringify(revert.json)).toBe('RESOURCE_NOT_FOUND');
186+
expect(revert.json?.error?.message).toBe(`Package '${GONE}' not found`);
187+
const rollback = await call('POST', `/packages/${GONE}/rollback`, { commitId: target.id });
188+
expect(rollback.status, JSON.stringify(rollback.json)).toBe(404);
189+
expect(rollback.json?.error?.code, JSON.stringify(rollback.json)).toBe('RESOURCE_NOT_FOUND');
190+
expect(rollback.json?.error?.message).toBe(`Package '${GONE}' not found`);
191+
192+
expect(await commitsOf(GONE)).toEqual(before);
193+
expect(await isServed('cmtpg_first')).toBe(false);
160194
});
161-
expect(created.status, JSON.stringify(created.json)).toBe(201);
162-
await publishObject(GONE, 'cmtpg_first', 'Gone first');
163-
const before = await commitsOf(GONE);
164-
const target = before.find((c) => c.operation === 'apply')!;
165-
expect(target).toBeDefined();
166-
167-
const uninstalled = await call('DELETE', `/packages/${GONE}`);
168-
expect(uninstalled.status, JSON.stringify(uninstalled.json)).toBe(200);
169-
expect(await isServed('cmtpg_first')).toBe(false);
170-
// The trail outlives the package's registry entry.
171-
expect(await commitsOf(GONE)).toEqual(before);
172-
173-
const revert = await call('POST', `/packages/${GONE}/commits/${target.id}/revert`, {});
174-
expect(revert.status, JSON.stringify(revert.json)).toBe(404);
175-
expect(revert.json?.error?.code, JSON.stringify(revert.json)).toBe('RESOURCE_NOT_FOUND');
176-
expect(revert.json?.error?.message).toBe(`Package '${GONE}' not found`);
177-
const rollback = await call('POST', `/packages/${GONE}/rollback`, { commitId: target.id });
178-
expect(rollback.status, JSON.stringify(rollback.json)).toBe(404);
179-
expect(rollback.json?.error?.code, JSON.stringify(rollback.json)).toBe('RESOURCE_NOT_FOUND');
180-
expect(rollback.json?.error?.message).toBe(`Package '${GONE}' not found`);
181-
182-
expect(await commitsOf(GONE)).toEqual(before);
183-
expect(await isServed('cmtpg_first')).toBe(false);
184195
});
185196

186197
it('control: a member without manage_metadata is refused 403 first', async () => {
@@ -367,16 +378,25 @@ describe('dogfood: package commit revert and rollback act only on a commit of th
367378
expect(await servedLabel()).toBe(shipped);
368379
});
369380

370-
it('[#29414] control: a writable package\'s edit commit restores its own row in place', async () => {
371-
await publishObject(A, 'cmtpa_edited', 'A edited 1');
372-
await publishObject(A, 'cmtpa_edited', 'A edited 2');
373-
const edit = (await commitsOf(A))[0] as any;
374-
expect(edit.items).toEqual([expect.objectContaining({ type: 'object', name: 'cmtpa_edited', existedBefore: true })]);
375-
const res = await call('POST', `/packages/${A}/commits/${edit.id}/revert`, {});
376-
expect(res.status, JSON.stringify(res.json)).toBe(200);
377-
expect(res.json?.data).toMatchObject({
378-
success: true, revertedCount: 1, reverted: [{ type: 'object', name: 'cmtpa_edited', action: 'restored' }],
381+
// The edit commit is this case's fixture: its two object publishes (a create,
382+
// then the edit) run in the hook, so the case's 5 s clock times the revert it
383+
// pins, never the publishes that build the commit.
384+
describe('[#29414] a writable package\'s edit commit', () => {
385+
let edit: any;
386+
beforeAll(async () => {
387+
await publishObject(A, 'cmtpa_edited', 'A edited 1');
388+
await publishObject(A, 'cmtpa_edited', 'A edited 2');
389+
edit = (await commitsOf(A))[0];
390+
}, 60_000);
391+
392+
it('[#29414] control: a writable package\'s edit commit restores its own row in place', async () => {
393+
expect(edit.items).toEqual([expect.objectContaining({ type: 'object', name: 'cmtpa_edited', existedBefore: true })]);
394+
const res = await call('POST', `/packages/${A}/commits/${edit.id}/revert`, {});
395+
expect(res.status, JSON.stringify(res.json)).toBe(200);
396+
expect(res.json?.data).toMatchObject({
397+
success: true, revertedCount: 1, reverted: [{ type: 'object', name: 'cmtpa_edited', action: 'restored' }],
398+
});
399+
expect((await call('GET', '/meta/object/cmtpa_edited')).json?.item?.label).toBe('A edited 1');
379400
});
380-
expect((await call('GET', '/meta/object/cmtpa_edited')).json?.item?.label).toBe('A edited 1');
381401
});
382402
});

0 commit comments

Comments
 (0)