Skip to content

Commit 0105a68

Browse files
test(cli): keep the two-namespace control's tools distinct so the bare-name rule does not judge it (#31742)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9Ff4UJdxHJzwSQG7VEko8ou)_ Prerequisite for #31661 (it was ejected from the merge queue by this test, queue build 42539489585, Test Core 1/8, triage 6729558102). Test-only; no card of its own, so `skip-changeset`. ## 维护者速读 - 改了什么:只改 `packages/cli/test/validate-namespace-name.test.ts` 的夹具:两个命名空间那条 CONTROL 里,beta 包的 tool 从 `nsn_lookup` 改名为 `nsn_other_lookup`;同命名空间那几条仍共用 `tool/nsn_lookup`。 - 为什么改:#31661 让一期 bare-name 规则在封存后按全环境拒绝同名 tool,于是这个"两个命名空间可以同名"的 CONTROL 在 premise 用例里被 `BareNameConflictError` 422 拒掉。它本意只测 #31717 的命名空间规则,不该被 bare-name 规则判。 - 风险与回滚:只动测试夹具和一个用例标题,不改产品代码。回滚即 revert。 - 先看:`packagesStack` 的 `betaTool` 一行。 - 两分钟验证:`pnpm --filter @objectstack/cli exec vitest run test/validate-namespace-name.test.ts` —— 预期 4 passed。 - 需要你做的:无,席位落地后 #31661 可重新入队。 ## What changes - `packagesStack(betaNs)` gives the beta package's tool its own name when `betaNs` is not `nsn` (`nsn_other_lookup`), so the two-namespace CONTROL shares only the page `nsn_home`. The shared-namespace fixtures still hold `page/nsn_home` and `tool/nsn_lookup` twice, so every refusal assertion is unchanged. The CONTROL's title now says what it holds ("the same page name in two namespaces validates"). A doc comment says why: a tool is also phase 1's bare-name one-holder type, judged environment-wide, so a shared tool across two namespaces is that rule's refusal, not this rule's CONTROL. `os validate` does not run the bare-name rule, so the CLI CONTROL reads the same either way; only the package-door premise is affected. ## Verification Every run under `os-verify-lock`, CLI closure rebuilt each time: - This head `86e164c2` (main `cae8d8fe` + this commit): `test/validate-namespace-name.test.ts` **4 passed**. - This head merged with #31661's head `30b6c84f` (scratch branch): **4 passed**. - `main` merged with #31661 (no fix, scratch branch): **1 failed / 3 passed**, the premise: `expected BareNameConflictError: Bare-name conflict… to be undefined`. That is the queue failure, reproduced, and the fix clears it. - Lint: `eslint packages/cli/test/validate-namespace-name.test.ts --no-inline-config` exit 0. Gates: `dispatch-gates --ran` on `86e164c2`: **49 derived, 49 run, 0 NOT-MEASURED**, all exit 0 (`check:dts-closure` and `check:dual-build-cjs-loads` first read a declaration-less / partial local build and were re-run green after a full closure build). --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmQv69sQL5nfT8xuPWs)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmQv69sQL5nfT8xuPWs Co-authored-by: Claude <noreply@anthropic.com>
1 parent 90cea47 commit 0105a68

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

‎packages/cli/test/validate-namespace-name.test.ts‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,31 @@ function payloadOf(run: Run, label: string): Record<string, any> {
6363
const ALPHA = 'com.example.nsn-alpha';
6464
const BETA = 'com.example.nsn-beta';
6565

66-
/** A two-package artifact; `betaNs` is the second package's namespace. */
66+
/**
67+
* A two-package artifact; `betaNs` is the second package's namespace. Inside
68+
* one namespace both packages hold the page `nsn_home` and the tool
69+
* `nsn_lookup`. Across two namespaces only the page is shared: a tool is also
70+
* phase 1's bare-name one-holder type, which refuses one tool name held by two
71+
* packages environment-wide, so a shared tool there would be that rule's
72+
* refusal, not this one's CONTROL.
73+
*/
6774
function packagesStack(betaNs: string): Record<string, unknown> {
68-
const pkg = (id: string, ns: string, tag: string) => ({
75+
const pkg = (id: string, ns: string, tag: string, tool: string) => ({
6976
id,
7077
name: tag,
7178
version: '1.0.0',
7279
type: 'app',
7380
namespace: ns,
7481
pages: [{ name: 'nsn_home', label: `${tag} home`, type: 'app', regions: [] }],
75-
tools: [{ name: 'nsn_lookup', label: `${tag} lookup`, description: 'Looks a record up', parameters: {} }],
82+
tools: [{ name: tool, label: `${tag} lookup`, description: 'Looks a record up', parameters: {} }],
7683
});
77-
return { packages: [{ manifest: pkg(ALPHA, 'nsn', 'nsn_alpha') }, { manifest: pkg(BETA, betaNs, 'nsn_beta') }] };
84+
const betaTool = betaNs === 'nsn' ? 'nsn_lookup' : `${betaNs}_lookup`;
85+
return {
86+
packages: [
87+
{ manifest: pkg(ALPHA, 'nsn', 'nsn_alpha', 'nsn_lookup') },
88+
{ manifest: pkg(BETA, betaNs, 'nsn_beta', betaTool) },
89+
],
90+
};
7891
}
7992

8093
/** What the package door throws for the same artifact, driven the way the load path drives it. */
@@ -143,7 +156,7 @@ describe('ADR-0150 child N — os validate and os build refuse what the package
143156
expect(existsSync(join(dir, ARTIFACT)), 'os build wrote an artifact the package door refuses').toBe(false);
144157
}, SPAWN_TIMEOUT_MS);
145158

146-
it('CONTROL — the same names in two namespaces validate', async () => {
159+
it('CONTROL — the same page name in two namespaces validates', async () => {
147160
const run = await runCli(['validate', '--json'], dirs['two-namespaces']);
148161
const payload = payloadOf(run, 'two-namespaces --json');
149162
expect(payload.valid, JSON.stringify(payload.errors)).toBe(true);

0 commit comments

Comments
 (0)