Skip to content

test(example-todo): boot the MCP action drive with its Default Organization and run it in the example suite - #31230

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-cv42l4
Nov 7, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-cv42l4

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Fixes #30928

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:examples/app-todo 的 MCP 业务动作端到端脚本改成普通 vitest 测试 test/mcp-actions.test.ts,随该示例自己的 pnpm test 在 CI 里跑;启动时挂上 plugin-auth 的身份对象(createIdentityObjectsPlugin()),于是装机在种子加载前就有默认组织。原 test:mcp 脚本删除。
  • 为什么改:原脚本在 main 上第 3 步失败(「Organization is required」):它的内核不注册组织对象,种子和系统写入都被拒;且没有任何流水线跑它。卡片要求「修好启动,再接入一条会跑的流水线或证明已有覆盖后删除」:实测没有重复覆盖,选接入。
  • 风险与回滚:只动私有示例包、一处测试注释和锁文件里一条 workspace 依赖链接;不改平台代码、不发布。回滚即还原本 PR。
  • 先看:① examples/app-todo/test/mcp-actions.test.ts 的 beforeAll 启动顺序与第一条用例(默认组织与种子);② examples/app-todo/vitest.config.ts(三个平台包按源码解析);③ examples/app-todo/package.json。
  • 两分钟验证:pnpm --filter @objectstack/example-todo exec vitest run test/mcp-actions.test.ts,预期 9 条全绿。
  • 需要你做的:无,席位落地。

What changes

The manual test:mcp script now boots with an organization and runs in a lane.

  • Boot. On main (re-measured at 4c318214) pnpm --filter @objectstack/example-todo test:mcp exits 1 at step 3: the app seed and the step-3 insert are refused with Organization is required. The kernel registered no organization object, so nothing created the Default Organization a single install holds before seeds load (ADR-0131 D3/D9). The suite now mounts createIdentityObjectsPlugin() from @objectstack/plugin-auth: plugin-auth's identity objects with the same Default Organization invariant AuthPlugin.start() keeps, and no authentication mounted. This is the reduced-kernel composition plugin-auth's identity-objects-plugin.ts header documents for an app's own test suite, and AppPlugin already orders it ahead of its seed. No platform package changes.
  • Wired, not deleted. test/mcp-actions.e2e.ts (a tsx script) becomes test/mcp-actions.test.ts (vitest; a pure rename commit first, then the conversion). The default vitest include picks it up, so it runs in the example's own pnpm test, which CI's Test Core shards run. The test:mcp package script is removed. Each step is one case with expect assertions in place of the script's check() counter; step state no longer leaks between cases (steps 5 and 6 seed their own task).
  • Source aliases. examples/app-todo/vitest.config.ts stops re-exporting the shared preset and declares anchored array-form aliases that resolve @objectstack/mcp, @objectstack/runtime and @objectstack/plugin-auth to their src/index.ts, because pnpm check:test-source-alias refused the new suite's three dist/ imports (measured red, exit 1, on the first head). It keeps disableConsoleIntercept: true itself, as examples/app-crm/vitest.config.ts does, because check:console-intercept-disarm judges only a bare preset re-export as the preset.
  • Same boot for test/seed-check.ts (bounded in-place fix, same defect class, same file family): the second manual tsx script exited 1 on main with the same eight Organization is required seed refusals; with createIdentityObjectsPlugin() mounted it prints Found Tasks: 8 and exits 0. No lane runs it, and the new first case of the suite pins the same seed rows.
  • New pin. A first case asserts the boot holds exactly one organization and that the app's own seed landed (Learn ObjectStack, Build a cool app): the card's failure, pinned.
  • @objectstack/plugin-auth is added as a workspace:* devDependency of @objectstack/example-todo, with its pnpm-lock.yaml importer link (3 lines, generated by pnpm install).
  • Path pointers to the old file name move with it: the example README (and its run command), test/node-shim.d.ts, test/task-completion-trigger.test.ts, and the one comment line in packages/mcp/src/mcp-action-confirmation-member.test.ts that names this file as where the confirmation gate's two halves run together (comment only; on the claim's amended surface).

Tests

  • pnpm --filter @objectstack/example-todo exec vitest run test/mcp-actions.test.ts: 9 passed (9); the file line reads 906 ms (default reporter, file time).
  • Example suite in examples/app-todo on the final head (with the source aliases): Test Files 9 passed (9), Tests 249 passed (249), exit 0. pnpm typecheck (tsc --noEmit, includes test/**): exit 0.
  • packages/mcp: vitest run src/mcp-action-confirmation-member.test.ts 6 passed (6) (comment-only edit).
  • tsx test/seed-check.ts: exit 1 before (eight seed refusals), exit 0 after (Found Tasks: 8).
  • Red-first (one-time proof, committed head first; run on the first head and again on the final head with the source aliases, same reading): node scripts/ablation-replace.mjs --delete of the createIdentityObjectsPlugin() line landed (anchor 1 -> 0, blob 08e51a7e -> e95cbeaa), the file then read 5 failed | 4 passed: the new boot case (Object 'sys_organization' not found) and steps 3, 5, 6, 7 (ValidationError: Organization is required, the card's failure). Restored: blob == HEAD 08e51a7e, git diff HEAD empty.

Acceptance notes

Coverage measured before choosing (the card's "name which one"). The candidates that drive actions over MCP with more than a stubbed bridge:

  • packages/mcp/src/mcp-action-confirmation-member.test.ts and mcp-action-tools.test.ts drive the real MCPServerRuntime door, but over a bridge double; the first file's header names this script as the only place the door and the runtime gate run together against a real engine.
  • packages/runtime/src/action-confirmation-gate.test.ts pins the gate predicate by calling invokeBusinessAction directly, without the MCP door.
  • packages/qa/dogfood/test/mcp-system-object-action-exposure.dogfood.test.ts drives list_actions / run_action through live MCP on a booted showcase, including a 428 refusal and the confirmed call, but only for platform sys_user actions of type: 'api' (a forward), and dogfood does not run in PR CI. mcp-delete-record-confirmation.dogfood.test.ts is the delete_record tool, not run_action.

None drives an app's type: 'script' action with a registered handler, the requiredPermissions gate (ADR-0066 D4), or the ai.exposed gate on an app object through MCPServerRuntime → HttpDispatcher.buildMcpBridge → a real engine and driver. So no duplicate exists at a layer as close to the code, and the script is wired, not deleted.

Why this boot and not the example testkit. test/default-organization.testkit.ts (installDefaultOrganization) registers the organization after the engine is up and writes the row through the driver. Measured: called after kernel.bootstrap() it is too late for AppPlugin's seed (eight Organization is required seed refusals at boot), and step 3 is then refused with SystemWriteOrganizationRequiredError because the engine memoised the empty organization probe during the seed. The plugin creates the organization in start(), ahead of the seed, the way a real install does.

@objectstack/example-todo is private: true and ships nothing; the only non-example file is a test-file comment in packages/mcp (not in that package's files[]), so skip-changeset.

Verification

Gate union derived by node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack on the final head, each exit captured before any pipe, reconciled with --ran, on head e2ebb1ea:

  • 64 derived, 64 run, exit 0 each. --ran: "64 derived famil(ies) accounted for — 64 run, 0 NOT-MEASURED".
  • The first run of the union (head 59c1bd94) read pnpm check:test-source-alias red (exit 1, the three new dist/ imports); the source aliases are the fix, and the second run is green.
  • node scripts/check-plugin-teardown-shape.mjs --self-test needed its pinned fixture on this shallow clone (git fetch --depth=1 origin 621a4876), then exit 0.
  • Gate record: one COMMAND :: exit N line per family, kept with the seat.

Scoped lint: pnpm exec eslint --no-inline-config examples/app-todo packages/mcp/src/mcp-action-confirmation-member.test.ts, exit 0.

CI families are read from this PR's check-runs, not re-run here.


Generated by Claude Code

Pure rename, no content change, so the conversion that follows diffs
against the original script.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5k9SPSJRVA5sTSKkU8
…zation and run it in the example suite

The manual test:mcp script booted a kernel that registers no organization
object, so the app seed and every system insert were refused with
'Organization is required' from step 3 on, and nothing ran it. It now
mounts plugin-auth's identity objects (the reduced-kernel recipe that
creates the Default Organization before AppPlugin seeds), pins that the
seed landed, and runs as a vitest file in the example's own pnpm test.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5k9SPSJRVA5sTSKkU8
check:test-source-alias: the new suite imports @objectstack/mcp,
@objectstack/runtime and @objectstack/plugin-auth, which resolved through
dist/. Anchored array-form aliases point them at src/, with the console
intercept disarm the config owed once it stopped re-exporting the preset.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5k9SPSJRVA5sTSKkU8
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Nov 7, 2026
@github-actions github-actions Bot added size/l dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests labels Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 065bba721e4ba180c6bdbbf2c5fb787d49bac596 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:devx#3 · os-project-manager · session_01FEkQ5njkh3xbcDN6EtSfw7

席位核对

Verdict: ACCEPT · head e2ebb1ea12c194d570ed9e791aca1ec665f9e6a4 · card #30928 · report 6711556558.

  • Shape: draft → main, Fixes #30928; 10 files, +319/-269, inside the claim's file surface (examples/app-todo/**) plus the two paths the claim amendment added (pnpm-lock.yaml: three lines for the @objectstack/plugin-auth devDependency; packages/mcp/src/mcp-action-confirmation-member.test.ts: one comment line re-pointed).
  • Card's ask, read in the diff: the boot gains plugin-auth's createIdentityObjectsPlugin(), which creates the Default Organization before AppPlugin seeds. No platform code changed. Route wire: test/mcp-actions.e2e.ts becomes test/mcp-actions.test.ts (seven steps plus two boot pins) in the example's own pnpm test, the test:mcp script goes, and the README says CI runs it. It is not deleted because the MCP package test names this script as the only place the confirmation gate's two halves run together against a real engine.
  • In-place additions (same defect class, bounded): test/seed-check.ts failed the same way and gets the same boot line. vitest.config.ts gains anchored source aliases for @objectstack/mcp, runtime and plugin-auth, which check:test-source-alias requires for the new imports, and keeps disableConsoleIntercept.
  • Red-first: without the plugin line, 5 of 9 cases fail with "Organization is required".
  • Gates: check-runs on this head: 57 success, 12 skipped, 0 failed, 0 pending, including Lint & Repo Gates, TypeScript Type Check and all eight Test Core shards (the example suite runs there). Local: 64 derived, 64 exit 0, 0 NOT MEASURED.
  • Changeset: @objectstack/example-todo is private: true ⇒ skip-changeset correct. Clause-②: no; check-governed-merges --pr 31230: NOT governed, 588 lines.
  • Acceptance notes: vitest.config.ts now spells its own defineConfig instead of mergeConfig(preset, …), which the root vitest.preset.mts header asks of a config that adds settings. Today that is the same single setting, so nothing is lost, but a key later added to the preset would not reach this package. This is noted, not sent back: examples/app-showcase uses the same shape.
  • Landing: under 「按照 pm-dispatch 规则复核过的都授权」 (2026-10-25T11:35Z) and 「你应该使用 pm-dispatch 技能审核和落地pr」 (2026-11-07T16:59Z): pr_ready + automerge_enable now.

Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/l skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

examples/app-todo: the manual test:mcp script fails at step 3 on main ("Organization is required"), and no lane runs it

1 participant