Skip to content

fix(docs-audit): derive package roots from the filesystem, not a special-cased regex - #4206

Merged
os-zhuang merged 1 commit into
mainfrom
claude/docs-drift-mapper-nesting-bug-v56kpb
Jul 30, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
claude/docs-drift-mapper-nesting-bug-v56kpb

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Fixes #4162.

Problem

affected-docs.mjs derived changed-package roots with a regex that special-cased only packages/plugins/*. The 30 packages nested under the other six container directories (services/, connectors/, apps/, qa/, triggers/, adapters/) collapsed into their container, whose missing package.json left name = null — so the npm-name matching arm never fired for them. Any doc that names @objectstack/service-automation but never the repo path was a guaranteed miss (content/docs/automation/flows.mdx is one), the exact direction the tool promises to avoid ("over-inclusion is preferred over misses").

Fix

  • Package root = deepest ancestor directory with a package.json, resolved from the filesystem. No hardcoded container list replaces the special case — a list would silently fail again on container dir number eight (排查「手抄 spec 清单 + "keep in sync" 注释」模式:一天内确认三例,全部曾静默漂移 #3786's pattern). A deleted package falls back to the coarse packages/<x> token so path matching still works.
  • Second arm, from the issue thread: <packageRoot>/scripts/** is build/verification tooling and no longer counts as an implementation change (feat(spec): check:generated — report every stale artifact in one run #4183 flagged 106 docs for a diff whose only code change was a new check script). Kept deliberately narrow: package.json and src/scripts/** stay counted. Publication check done — no package's files allowlist ships scripts/; three plugins ship a lone i18n-extract.config.ts only for lack of a files field (tooling, not runtime).
  • --self-test now pins the derivation and both classifiers (32 hermetic cases via an injected fake tree), closing the guard-of-the-guard hole — the original self-test pinned only isTestFile. Includes the issue's two invariants: a container directory must never come out as a package root; packages/x/package.json is implementation while packages/x/scripts/y.ts is not.
  • Exclusions stay non-silent: summary line notes + scriptFilesSkipped alongside testFilesSkipped in --json.

Verified against real history

scenario old new
#4161's commit (service-automation + spec) attributed to the directory name packages/services attributed to @objectstack/service-automation; flows.mdx now hits via the right package
synthetic service-automation-only change 6 docs, all about other services (via the packages/services path token), flows.mdx absent the 4 right docs, flows.mdx included
#4183's commit (check script + package.json registration) 106 docs 106 docs (the package.json change keeps packages/spec counted, by design) + explicit "1 tooling script(s) excluded" note
scripts-only change 106 docs 0 docs, exclusion reported

node scripts/docs-audit/affected-docs.mjs --self-test → 32 cases pass; the drift workflow already runs it before computing the mapping.

🤖 Generated with Claude Code

https://claude.ai/code/session_01J2x8Tie9WT1VgWFifqMKrR


Generated by Claude Code

…ial-cased regex (#4162)

The drift mapper special-cased only `packages/plugins/*`, so the 30
packages nested under the other six container dirs collapsed into their
container — whose missing package.json killed the npm-name matching arm.
A doc naming `@objectstack/service-automation` but never the repo path
was a guaranteed miss (`automation/flows.mdx` on a service-automation-
only change). The root is now the deepest ancestor with a package.json,
with no hardcoded container list to drift out of sync.

Also from the issue thread: `<packageRoot>/scripts/**` is build tooling,
not documented behaviour, and no longer counts as an implementation
change (#4183); `package.json` and `src/scripts/**` stay counted. Both
the derivation and the classifiers are now pinned by `--self-test`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J2x8Tie9WT1VgWFifqMKrR
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Jul 30, 2026 3:17pm

Request Review

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation ci/cd tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

No hand-written docs reference the 0 changed package(s). ✅

@os-zhuang
os-zhuang marked this pull request as ready for review July 30, 2026 15:22
@os-zhuang
os-zhuang merged commit 64489f8 into main Jul 30, 2026
15 checks passed
@os-zhuang
os-zhuang deleted the claude/docs-drift-mapper-nesting-bug-v56kpb branch July 30, 2026 15:22
os-zhuang added a commit that referenced this pull request Jul 31, 2026
…never got (#4219)

The drift comment on #4161 was computed by the mapper bug #4206 fixed: the
service-automation change collapsed to `packages/services`, so these four
docs were attributed to the wrong package — and a service-automation-only
diff would have reported none of them. Re-derived with the fixed mapper and
audited against the implementation.

flows.mdx carries the #4161 axis itself: a `runAs:'user'` run that resolved
no trigger user has its data operations refused. Also documents `node.type`
as an open string checked against the live registry (ADR-0018), the script
executor as naming a callable with logger-backed `email`/`slack` markers,
the `.strict()` shells, and six previously undocumented node keys.

implementation-status.mdx gains the real `/api/v1` route prefixes, the
memory driver's actual `InMemoryDriver.supports` matrix, and the ADR-0090 D3
`Role` -> `Position` rename — which ratchets the role-word baseline down by
one, so that gate-mandated update ships here too.

Gates: docs build, check:doc-authoring, check:role-word, check:nul-bytes,
check:release-notes, check:skill-examples (198 prose examples).


Claude-Session: https://claude.ai/code/session_01J2x8Tie9WT1VgWFifqMKrR

Co-authored-by: Claude <noreply@anthropic.com>
os-zhuang added a commit that referenced this pull request Jul 31, 2026
#4248) (#4262)

20 of the 49 publishable packages declared no `files` field, so npm fell back
to packing the whole package directory. `npm pack --dry-run` on
@objectstack/plugin-webhooks listed 21 files -- 15 under src/, three of them
unit tests, plus the build-time scripts/i18n-extract.config.ts. dist/ lands on
top of that at publish time rather than instead of it.

Each now declares ["dist", "README.md"], matching the 29 packages that already
did. Nothing a consumer imports moves: every main / types / exports target in
all 20 already resolved inside dist/.

The other half is the gate. check:published-files (wired into the
always-required lint job) holds every non-private workspace package to four
invariants: DECLARED, SUFFICIENT (covers every entry point, so tightening a
whitelist cannot ship a package that fails to resolve), MINIMAL (admits no
test, test-harness config or build script), and REGISTERED (anything beyond
dist + README.md carries a reason, reconciled in both directions).

MINIMAL also closes an assumption #4206 rested on: that no package publishes
scripts/ as runtime code held, but it held by hand-checking three packages.
It is now checked on every PR.
rajeev-kumar-se pushed a commit to rajeev-kumar-se/objectstack that referenced this pull request Nov 10, 2026
…mespace the control plane's grant names, and target_namespace beside a managed install is refused (objectstack-ai#32038)

<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9Q7Q2hTCwEn1JV6MbUK9Wwz)_

Fixes objectstack-ai#31482

Clause-②: yes (narrowing) — `POST /api/v1/cloud-connection/install`
gains an optional `target_namespace` (or `targetNamespace`) beside an
unmanaged install (forwarded to the control plane, and to the copy as
the grant echoes it); the same key beside a managed install (or no
`install_mode`), which the route ignored on main, is refused 400, as are
the two spellings naming different values.
Metadata-protocol: none

Measured on base (8031f49) and head with the head tests: 11 of the 15
new pins fail on base, among them the managed refusal (base installs and
ignores the key), the forward (base sends no `target_namespace`), the
two-spellings conflict and the audit row's namespaces. The 4 that pass
on base are the two CONTROLs and the two door pins (the door already
kept 409 / 400 on the grant path). First-party senders of
`target_namespace` or `targetNamespace`: 0 (Console, CLI,
`@objectstack/client`, examples; `git grep` at 8a9db61). Seat rulings:
step 0 accepted, rulings 1 to 6 on the seat thread (grant governs the
namespace; managed refusal kept; the narrowing arm); contract review
PASS (6756998867) with S1, N1 and N2 folded here, and the open questions
ruled A on the card (6757010844).

Claim by `domain:server#1` (6755209332), card-thread
session_01ADHkmRBVrEGiPWKs12b6A3. Consumer: objectstack-ai/cloud#3648
item 4 (control-plane half in cloud PR objectstack-ai#4206).

## 维护者速读

- 改了什么:托管环境的市场安装入口 `POST /api/v1/cloud-connection/install` 现在读取可选的
`target_namespace`(也接受 `targetNamespace` 写法,两者不一致则
400,值会去首尾空格):非托管安装时转发给控制面,副本按控制面授权回显的 `data.target_namespace`
改名落地;托管安装(或没写安装模式)带它会被 400 拒绝,用的是 install-local 门自己的那句话。
- 为什么改:之前托管环境的非托管副本永远沿用源包命名空间(如 `democrm_*`),cloud#3648
要按组织的客户代码落地。授权决定命名空间:调用方要了但授权没回显或回显不同,就 502
不复制并记审计(审计行记下请求的和授权回显的命名空间),不会悄悄落到源命名空间。
- 风险与回滚:收窄只有两处:「托管安装 + 任一写法的命名空间」和「两种写法值不一致」从忽略变成 400,第一方调用方为 0。在 cloud
objectstack-ai#4206 上线前,带命名空间的非托管安装会一直 502(失败即关闭,不写数据)。回滚即 revert。
-
先看:`packages/cloud-connection/src/cloud-connection-plugin.ts`(`targetNamespaceOf`、`/install`
路由里的托管拒绝、`copyOnUnmanagedGrant` 的
`namespaceUnread`),`packages/cloud-connection/src/install-local-door-service.ts`(共享的拒绝句常量)。
- 两分钟验证:`pnpm --filter @objectstack/cloud-connection exec vitest run
--maxWorkers=2 src/cloud-connection-plugin.test.ts -t 31482`,预期 12
条全过;审计行:`pnpm --filter @objectstack/plugin-audit exec vitest run
src/package-lifecycle-audit.test.ts -t 31482`,预期 1 条通过。
- 需要你做的:无,席位落地。

## What changes

- **`POST /api/v1/cloud-connection/install`**
(`cloud-connection-plugin.ts`):
- Reads an optional `target_namespace`, or `targetNamespace` as a second
spelling, the same way it reads `install_mode` / `installMode` (review
S1). Absent or `null`: nothing changes and the control plane is sent no
key. Both spellings naming different values: `400 INVALID_REQUEST`
naming both, before the mode is judged and before the control plane is
asked.
- Beside a managed install, or with no `install_mode`, a non-null
`target_namespace` or `targetNamespace` is refused `400 INVALID_REQUEST`
with the install-local door's own sentence, before the value is judged
and before the control plane is asked. The sentence is one exported
constant, `TARGET_NAMESPACE_ON_MANAGED_INSTALL_MESSAGE` in
`install-local-door-service.ts`, which the door's step 0″ now reads too
(byte-identical to the literal it replaces, checked with a node
comparison against 8031f49).
- Beside an unmanaged install, the value is trimmed (review N2, as
`version` is) and parsed by `ManifestSchema.shape.namespace` by
reference. A value it refuses is `400 INVALID_REQUEST` with
`details.targetNamespace` (the door's own details key for its namespace
refusals), before the control plane is asked. Otherwise it is sent as
`params.target_namespace`.
- **`copyOnUnmanagedGrant`**: the grant governs the namespace, as it
governs the manifest (objectstack-ai#31963).
- The grant's `data.target_namespace` (a string) is handed to the door
as `targetNamespace`. A namespace in the caller's body never reaches the
door on its own.
  - No ask, but an echo: the echo passes (a control-plane default).
- Asked, but no echo or a different one: `502 PLUGIN_INSTALL_FAILED`,
nothing copied, audited through the environment's `audit` slot like the
other unreadable grants. The message says the environment "cannot tell
which namespace it granted". The audit event carries
`requestedNamespace` and, when the grant named one, `grantedNamespace`
(review N1).
  - An echo that is not a string (asked or not): the same 502.
- No ask and no echo: today's behaviour, the copy keeps the source
namespace.
- **The door** (`marketplace-install-local-plugin.ts`): only the
sentence moves to the shared constant. Its namespace refusals already
pass through unchanged on the grant path: a namespace another package
owns is `409 RESOURCE_CONFLICT` with `details { namespace, owners }`; a
malformed, reserved or unrenamable name is `400 INVALID_REQUEST` with
`details.targetNamespace`. objectstack-ai#31995's 502 split covers only the manifest,
mode and withheld-map refusals.
- **The audit row**
(`packages/plugins/plugin-audit/src/package-lifecycle-audit.ts`):
`package_unmanaged_import` gains two optional event fields, written to
the row's closed metadata as `requested_namespace` and
`granted_namespace` (null when absent) only when either is present, so
every other row is unchanged. `install-local-door-service.ts`'s
`UnmanagedImportAuditEvent` declares the same two fields.
- **Prose** that said a hosted kernel has no install-local door:
`install-local-door-service.ts` (the NOT MEASURED paragraph, now the
cloud#3845 ruling A / cloud#4175 fact), `index.ts` and
`marketplace-install-rename-planner.ts` (now "a kernel that does not
mount `MarketplaceInstallLocalPlugin`"), and a comment in
`ui/packages/app-shell/src/console/marketplace/MarketplacePackagePage.tsx`
(no install-local ROUTE; the door is reached in process). The pending
changesets 30963 / 30964 are left as written (seat ruling 5).

Cross-repo, NOT MEASURED: the control plane's spelling,
`params.target_namespace` in and `data.target_namespace` echoed, is
cloud PR objectstack-ai#4206's (seat ruling 1; cloud asked to confirm on mailbox
6755291490). Until the control plane echoes it, an unmanaged install
that names a namespace answers the fail-closed 502 after the control
plane has recorded its grant, and nothing is copied.

## Tests

`packages/cloud-connection/src/cloud-connection-plugin.test.ts`, 12 new
tests (`-t 31482`):
- Route: unmanaged + `target_namespace` → sent as
`params.target_namespace`; `targetNamespace` read as a second spelling,
either trimmed, two that agree are one → sent `'acme'`; the two
disagreeing → 400 naming both, no control-plane call (beside managed
too); CONTROL absent / `null` → the params unchanged; managed or no mode
→ 400 with the shared sentence, no control-plane call (either spelling,
and a malformed value beside managed); malformed values (`Acme`,
`acme-corp`, `1acme`, `''`, `' '`, a number, a boolean, an object, an
array) → 400 `details.targetNamespace`, no control-plane call.
- Grant copy: asked + echoed → door body `targetNamespace` and the
control plane was sent it; no ask + echo → passed; CONTROL no ask + no
echo (absent / `null`) → no `targetNamespace`; asked + no echo / `null`
/ another → 502, door never called, one audit event carrying both
namespaces; a camelCase ask the grant does not echo → 502, door never
called; a non-string echo → 502, asked or not.


`packages/cloud-connection/src/marketplace-install-local-grant-refusal-audit.test.ts`,
one new top-level `describe` (the grant-path harness, with the REAL
`ObjectStackProtocolImplementation#importUnmanagedPackage`), 2 tests: a
namespace another package owns → 409 `RESOURCE_CONFLICT` `details {
namespace, owners }`, audited once; a reserved namespace → 400
`INVALID_REQUEST` `details.targetNamespace`, audited once.

`packages/plugins/plugin-audit/src/package-lifecycle-audit.test.ts`, 1
new test: a grant refused over its namespace writes
`requested_namespace` and `granted_namespace` (null when the grant named
none) on the real `audit` slot.

No test that exists on main was edited, so there are no forced test
edits. This round changed two of this PR's own tests: the 502 pin now
also expects both namespaces on the audit event, and the earlier pin "a
camelCase `targetNamespace` in the caller's body never reaches the door"
is replaced, because S1 makes that spelling an ask; its successor pins
that the grant still governs it.

## Acceptance notes

- A second unmanaged copy of the same package is refused `409
RESOURCE_CONFLICT` with `details.targetPackageId` whatever namespace is
asked: the door never sends `targetPackageId`, so the base is always
`SOURCE-copy`. The follow-up dialog card states it as a known limit.
- The environment's unmanaged install dialog (item 3, carried from
objectstack-ai#31994) is split to the follow-up `domain:ui` card objectstack-ai#32040, Blocked-by
this PR and cloud PR objectstack-ai#4206 (seat ruling 4). It needs a same-origin proxy
for the control plane's default-namespace answer, because a tenant
console cannot call it cross-origin and does not know its environment
id.
- The door-only mount Ruling A described was built on cloud's side
(cloud#4175); nothing is owed here (seat ruling 3).

## Verification

All readings at head `88c0a71ca` (this branch merged with main
`09bf7de71`; the 8 incoming commits touch none of this PR's files),
unless named otherwise.

<details><summary>Package suite, typecheck, lint</summary>

- `pnpm --filter @objectstack/cloud-connection typecheck && pnpm
--filter @objectstack/cloud-connection test` under the lock: VERDICT
command-exit 0; Test Files 80 passed (80), Tests 1178 passed (1178).
- `pnpm --filter @objectstack/plugin-audit typecheck && pnpm --filter
@objectstack/plugin-audit test` under the lock: VERDICT command-exit 0;
Test Files 81 passed (81), Tests 1260 passed (1260).
- `eslint packages/cloud-connection packages/plugins/plugin-audit
--no-inline-config`: exit 0. `pnpm --filter @object-ui/app-shell lint`
(at c48adec; its file is unchanged since): exit 0 (0 errors, warnings
are main's).
- `@object-ui/app-shell` tests and type check: not run locally; its diff
is one comment. Declared to CI.

</details>

<details><summary>Ablations (each restored, `git diff HEAD` empty; A1 to
A4 at 8a9db61, A5 to A9 at da14ba0)</summary>

Through `scripts/ablation-replace.mjs` (anchor hit 1, mutation landed by
blob, restore blob == HEAD). The tests import the plugin from `src`, so
no rebuild or dist leg.
- A1 drop the route's managed refusal: "install refuses
`target_namespace` beside a managed install or no mode" red.
- A2 drop the route's shape check: "install refuses a `target_namespace`
the manifest namespace declaration refuses" red.
- A3 drop `namespaceUnread` from the grant check: "asked … not echo, or
echoes another, fails closed" and "a grant whose `target_namespace` is
not a string fails closed" red.
- A4 make the door answer 502 for any grant-path import refusal: both
new door pins (409 conflict, 400 reserved) red.
- A5 drop the two-spellings conflict check: "install refuses
`target_namespace` and `targetNamespace` that disagree" red.
- A6 stop reading `targetNamespace`: the second-spelling pin, the
conflict pin, the managed refusal pin (its camel cases) and "the grant
governs either spelling" red.
- A7 drop the trim: the second-spelling pin (its padded values) red.
- A8 drop `requestedNamespace` from the 502 audit event: "a namespace
asked for that the grant does not echo … audited" red.
- A9 drop `requested_namespace` from the audit row: the plugin-audit pin
red.

</details>

<details><summary>Widening and narrowing, measured on base</summary>

At 88c0a71, `git restore --source=8031f49d` of the four source files
(`cloud-connection-plugin.ts`, `install-local-door-service.ts`,
`marketplace-install-local-plugin.ts`, `package-lifecycle-audit.ts`),
head tests, `-t 31482` across the three test files: 11 failed, 4 passed
(the two CONTROLs and the two door pins). The failures include the
managed refusal (base installs and ignores the key), the forward, the
two-spellings conflict and the audit row's namespaces. Restored with
`git checkout HEAD --`, `git diff HEAD` empty.

</details>

<details><summary>Derived gates</summary>

`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at 88c0a71: 79 commands (the plugin-audit
file adds the tenant-audit census and the i18n pair), each run (stdin
from /dev/null), all exit 0. `--ran` reconciliation: "79 derived
famil(ies) accounted for — 79 run, 0 NOT-MEASURED". The two
prerequisites (teardown fixture fetch of 621a487, full `turbo run build
--filter='./packages/**'`) were met first.

</details>

<details><summary>Full dogfood (the narrowing arm)</summary>

`pnpm --filter @objectstack/dogfood test` under the lock at 88c0a71,
after the full packages build: VERDICT command-exit 0, held 30m14s on a
shared box; Test Files 445 passed, 3 skipped (448); Tests 3690 passed,
42 skipped (3732).

</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmRBVrEGiPWKs12b6A3)_

<!-- signed: domain:server#1 · os-steve ·
session_01ADHkmPF1skfu2kx89BEXZi -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
rajeev-kumar-se pushed a commit to rajeev-kumar-se/objectstack that referenced this pull request Nov 10, 2026
…ault install namespace (objectstack-ai#32182)

<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwB1tBW79GqioDEpaUFQASeqM)_

Fixes objectstack-ai#32083

Clause-②: yes (widening)
Metadata-protocol: none

## 维护者速读

- 改了什么:`@objectstack/cloud-connection` 新增一条同源只读路由 `GET
/api/v1/cloud-connection/install-namespace?package_id=PACKAGE_ID`,按主机名解析环境,用服务凭证向控制面读取非托管副本的默认命名空间,原样带回。
- 为什么改:托管环境的安装对话框(objectstack-ai#32040)要把默认命名空间填进可编辑输入框,但控制面接口跨域、租户控制台也不知道自己的环境
id,读不到。
- 风险与回滚:只新增一条读路由,不改任何已有路由的行为;门禁与 `POST /install`
相同(本环境的登录会话,被策略挂起的会话拒绝)。回滚即撤销本 PR。
-
先看:`packages/cloud-connection/src/cloud-connection-plugin.ts`(新路由的处理函数,紧挨
`/installation`)、`cloud-connection-route-ledger.ts`(新台账行)、`cloud-connection-plugin.test.ts`(末尾的拒绝与保真
pins)。
- 两分钟验证:`pnpm --filter @objectstack/cloud-connection exec vitest run
src/cloud-connection-plugin.test.ts`,预期全部通过,其中 `[objectstack-ai#32083]` 一组 9 个用例。
- 需要你做的:无,席位落地。

## What changes

One read-only route beside `/installation`, named as the card suggested
so objectstack-ai#32040 follows it unchanged:

`GET /api/v1/cloud-connection/install-namespace?package_id=PACKAGE_ID`

- **Closed query set (AGENTS.md route rule 5).**
`INSTALL_NAMESPACE_QUERY_PARAMS = ['package_id']`, measured from the
handler's one read point. Recognition runs first, then arity, both the
nested ADR-0112 `400 VALIDATION_ERROR` through `@objectstack/rest`'s
`unknownQueryParamRefusalMessage` / `repeatedQueryParamMessage`, before
anything else is read. The `packageId` alias `/installation` honours is
deliberately not taken (a new door takes one spelling), and an
`environment_id` the caller names is refused: the environment is the
request's host, never caller input.
- **Gate, the same as `POST /install`.** `resolveEnvironmentId`
(hostname via `env-registry`, or the single-environment config) → `404
ENVIRONMENT_NOT_FOUND`; `resolveSession` → a held session refused by
`refuseHeldSession` (`403`, the gate's own code), no session `401
UNAUTHENTICATED`. Nothing reaches the control plane before these pass.
- **The control plane's answer, unchanged.** `GET
{cloudUrl}/api/v1/cloud/packages/:id/install-namespace?environment_id=ENV`
with the env→cloud credential (`authHeaders()`, the one `/install`
presents); its status and JSON body are relayed as they came. Not
connected → `503 CLOUD_UNCONFIGURED`; unreachable or a non-JSON answer →
`502 EXTERNAL_SERVICE_ERROR`. Neither carries a namespace, so the dialog
reads "no default" and leaves the field empty; the route never answers a
value it made up.
- **Ledger.** A `server-only` row in `cloud-connection-route-ledger.ts`
(the conformance guard's exact accounting picks it up from the mount
call); the scope paragraph and the `unbind` row's header-count note are
brought up to the new totals.
- **Census pins.** `cloud-connection-plugin.test.ts` (mounting: 9
routes) and `cloud-connection-auth-gate.pin.test.ts` (the new door joins
`CC_SESSION_DOORS`, so it is held to HELD `403` under both modes,
UN-HELD `200` in both credential shapes, and anonymous `401`).

## Why

objectstack-ai#32040's hosted install dialog must show the default namespace the
control plane will use for an unmanaged copy. The control plane answers
it (cloud PR objectstack-ai#4206), but cross-origin, and a tenant console has no
environment id to ask with. This package already resolves the
environment per request and proxies credentialed control-plane reads for
the marketplace, so the read belongs here.

## Tests

New top-level `describe` in the shared harness
`cloud-connection-plugin.test.ts`:

| Pin | Kind | Asserts |
|:--|:--|:--|
| unknown parameter (`packageId`, `environment_id`, a typo) | refusal |
`400` + `VALIDATION_ERROR`, fetch never called |
| `package_id` twice | refusal | `400` + `VALIDATION_ERROR`, fetch never
called |
| no session | refusal | `401` + `UNAUTHENTICATED`, fetch never called |
| host resolves to no environment | refusal | `404` +
`ENVIRONMENT_NOT_FOUND`, fetch never called |
| missing / blank `package_id` | refusal | `400` + `INVALID_REQUEST`,
fetch never called |
| unbound runtime | refusal | `503` + `CLOUD_UNCONFIGURED`, no `data`,
fetch never called |
| control plane unreachable | refusal | `502` +
`EXTERNAL_SERVICE_ERROR`, no `data` |
| happy path | preservation | the URL the control plane received
(encoded package id, this host's environment), `Authorization: Bearer
SERVICE_KEY`, body deep-equal to the control plane's |
| control-plane refusal | preservation | its `404` status and body
relayed unchanged |

Held sessions are pinned through
`cloud-connection-auth-gate.pin.test.ts` (both postures × both modes).
`error-envelope.conformance.test.ts` adds three cases holding the door's
own `400` / `503` / `502` bodies to `BaseResponseSchema`,
`envelopeViolations` and `ApiErrorSchema` (closed code vocabulary); its
`driveCloudConnection` helper gains an optional `query`.

## Acceptance notes

- **Cloud fact not read here.** This lane does not read cloud code, so
the shape of the control plane's `install-namespace` answer (the key
that carries the namespace inside `data`) is not measured from this
repo. The route relays the body unchanged, so objectstack-ai#32040 reads the key the
control plane sends; the preservation pin's body is an illustrative
fixture, not a claim about that shape.
- A control-plane refusal (any non-2xx with a JSON body) is relayed with
its own status, the way `POST /install` relays one.

## Verification

All readings on `dea8eae6` (the final head; `b942df61` merged
`origin/main` `0f7389cc`, and `dea8eae6` changes only the changeset's
placeholder spelling).

- **Package suite.** `pnpm --filter @objectstack/cloud-connection
typecheck && pnpm --filter @objectstack/cloud-connection test` after the
merge and the closure rebuild: exit 0, `Test Files 80 passed (80)`,
`Tests 1190 passed (1190)`.
- **Lint.** Root eslint over the touched package, `node
--stack-size=4000 node_modules/eslint/bin/eslint.js
packages/cloud-connection --no-inline-config`: exit 0.
- **Derived gates.** `node scripts/pm/dispatch-gates.mjs --commands`
printed 69 commands; each ran under `scripts/pm/os-verify-lock.sh`, exit
code recorded before any pipe. `dispatch-gates --ran`: `69 derived
famil(ies) accounted for — 69 run, 0 NOT-MEASURED`. The first round (on
`82e79459`) found one red, `check:test-source-alias` on the edited
envelope suite (a lazy `@objectstack/runtime` import reached inside a
clocked case); fixed with a module-top side-effect import, the way the
package's other suites do it.
- **Ablations.** Ten one-shot mutations of `cloud-connection-plugin.ts`
through `scripts/ablation-replace.mjs` (anchor must hit once,
disk-verified write, restore to the `HEAD` blob), each running the three
suites under the lock. Every leg went red, and `git diff HEAD` was empty
after each restore. The suites import the plugin from `src/`, so no
`dist/` sits between mutation and reading.

<details><summary>Ablation legs (mutation → tests that went
red)</summary>

| Leg | Mutation | Red |
|:--|:--|:--|
| A1 | unknown-parameter refusal deleted | closed-set pin; envelope
`400` case |
| A2 | arity refusal disabled | `package_id` twice pin |
| A3 | environment refusal deleted | unresolved-host `404` pin |
| A4 | held-session refusal deleted | auth-gate HELD × 4 (both postures
× both modes) |
| A5 | no-session refusal deleted | no-session `401` pin; auth-gate
anonymous |
| A6 | blank `package_id` refusal deleted | missing/blank `400` pin |
| A7 | unbound refusal disabled | unbound `503` pin; envelope `503` case
|
| A8 | unreachable answers a guessed namespace | unreachable `502` pin;
envelope `502` case |
| A9 | relay sends `200` instead of the control plane's status |
refusal-relay preservation pin |
| A10 | `environment_id` not sent upstream | happy-path preservation pin
|

</details>

- **Size.** 6 files, under the 3,000 changed-line threshold
(`dispatch-gates` change-set line).

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(`packages/spec` not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (root eslint over
`packages/cloud-connection`: exit 0)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01WGufzgXtKPmGqL9ZXA4ApQ

---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzgXtKPmGqL9ZXA4ApQ)_

<!-- signed: domain:server#4 · os-support-ai ·
session_01WGufzgXtKPmGqL9ZXA4ApQ -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
rajeev-kumar-se pushed a commit to rajeev-kumar-se/objectstack that referenced this pull request Nov 10, 2026
…get namespace (objectstack-ai#32263)

<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBGU8m9WENyvoKLyxe2kUbYo)_

Fixes objectstack-ai#32040

Clause-②: yes (widening)
Metadata-protocol: none

## 维护者速读

- 改了什么:托管环境里以「非托管副本」安装应用时,安装对话框多了一个「目标命名空间」输入框,预填控制面给的默认值(经 objectstack-ai#32182 的同源路由
`GET /api/v1/cloud-connection/install-namespace` 读取),可以修改,安装时作为
`target_namespace` 发出;托管安装不画输入框、不发这个键。
- 为什么改:objectstack-ai#31482 之后服务端已能按命名空间复制,只差界面;之前对话框既不显示也不能改命名空间,冲突时也不能换名重试。
- 风险与回滚:只动界面和 11 种语言的 `marketplace` 懒加载文案,不动服务端和
`packages/spec`;读不到默认值(`503`/`502`)时输入框留空,手填仍可安装,空着则不发键、沿用控制面默认。回滚即
revert 本 PR。
- 先看:`MarketplacePackagePage.tsx` 的 `namespaceFieldShown` / `doInstall`
的 catch 分支,`marketplaceApi.ts` 的 `getInstallNamespace`,新文件
`targetNamespaceRefusal.ts`(三种拒绝怎么分)。
- 两分钟验证:`cd ui && pnpm exec vitest run
packages/app-shell/src/console/marketplace/__tests__/MarketplacePackagePage.installMode-12288.test.tsx`,预期
46 条全绿;截图在项目文件夹 `ui-orders/32040-shots/`。
- 需要你做的:无,席位落地。⚠️ 默认值读的是 `data.namespace`,这个键名取自路由测试的转发样例,云端 PR objectstack-ai#4206
本会话读不到,请席位核一下。

## What changes

- **The namespace read.**
`marketplaceApi.getInstallNamespace(packageId)` calls `GET
/api/v1/cloud-connection/install-namespace?package_id=…` with the same
`withEnvAuth` + `credentials: 'include'` that `installPackage` uses, and
returns the trimmed string at `data.namespace`, else `null`. `null`
covers `503 CLOUD_UNCONFIGURED`, `502 EXTERNAL_SERVICE_ERROR`, any other
refusal, a network failure and a non-string value: the field is empty,
never a guessed name.
- **The install body.** `installPackage` takes an optional
`targetNamespace` and sends it as `target_namespace` on the hosted
same-origin route only, only beside `installMode: 'unmanaged'`, trimmed,
never blank. A managed install never carries the key, since the route
refuses it there.
- **The dialog.** For an unmanaged hosted install (never an update), the
dialog draws a "Target namespace" field: a skeleton while the read is in
flight (Install waits), then an editable input pre-filled with the
default, or empty with a "no default could be read" hint. `data-state`
on `install-target-namespace` is `loading`, `ready` or `refused`.
- **Refusals**, sorted by `targetNamespaceRefusal.ts` from the error's
`code` (read with `errorCodeIs`) and `details` (which `installPackage`
already carries on its thrown error):
- `409 RESOURCE_CONFLICT` with `details.namespace`: the dialog stays
open, the field says the name is taken (localized, naming it), focus
returns to the field, and Install is enabled for another name.
- `400 INVALID_REQUEST` with `details.targetNamespace`: the server's
sentence is shown beside the field.
- `409 RESOURCE_CONFLICT` with `details.targetPackageId` (a second
unmanaged copy): shown as a plain refusal in the dialog's result box,
with no re-ask, since no namespace clears it (card item 3, stated not
fixed).
- **Strings.** Five keys under `marketplace.install.targetNamespace.*`
in all 11 files of the `marketplace` lazy namespace (`zh-Hant` generated
by `gen:zh-hant`). ⛔ Nothing in `src/locales/en.ts`. The German `taken`
string adds one „…“ pair, so `de-quote-pairing-3876.test.ts` moves its
two pins by one, with a dated line in each comment as earlier additions
did.
- **Changeset** `.changeset/32040-hosted-install-target-namespace.md`:
`@object-ui/i18n` patch. `@object-ui/app-shell` is private and gets no
row.

`Clause-②: yes (widening)`: `@object-ui/i18n` gains five strings.
`marketplaceApi`'s exported surface does widen (the new
`getInstallNamespace` export and the optional `targetNamespace` input),
but it lives in the private `@object-ui/app-shell`, so nothing it adds
publishes.

## Why

objectstack-ai#31482 lets the control plane copy a package under a chosen namespace,
and objectstack-ai#32182 (objectstack-ai#32083) added the same-origin read of its default. The
dialog was the missing piece: it sent no namespace and drew no field.

## Verification

- `MarketplacePackagePage.installMode-12288.test.tsx`: 46 / 46, 12 of
them new (two new describes in the existing harness; `marketplaceApi` is
not mocked, one stubbed `fetch` answers by path): default shown and
sent, edited value sent, `503` / `502` empty field still installs a
typed name, empty field sends no key, ownership `409` re-asks and
installs a new name, `400` sentence beside the field, `targetPackageId`
`409` gives no re-ask, managed install shows no field, reads no default
and sends no key, plus `installPackage` / `getInstallNamespace` unit
pins.
- **Ablation** (`scripts/ablation-replace.mjs`, delete
`...withNamespace,` from the hosted body): 6 tests go red (default sent,
edited sent, both `503`/`502` typed-name cases, the re-ask case, the
unit pin). Restored; `git diff HEAD` empty.
- `vitest run packages/app-shell/src/console/marketplace
packages/app-shell/src/__tests__ packages/i18n`: 183 files, all green
after the German pin move (that suite holds the ADR-0060
`product-neutral-renderer.ratchet` test).
- `type-check` of `@object-ui/app-shell` and `@object-ui/i18n`: clean.
ESLint on the changed files: 0 errors. `node
scripts/check-i18n-call-site-keys.mjs` (ui): clean.
- Full `turbo run build --filter='!@objectstack/docs'`: 119 / 119.
- Derived gates: every line of `dispatch-gates.mjs --commands`, plus
`pnpm --dir ui run check:eager-closure`, `node
scripts/check-sdui-manifest.mjs` and `pnpm --dir ui run
check:spec-symbols`; results in the `--ran` reading below.
- **Browser.** A hosted environment is not bootable in this container
(no control plane). Shot against a real CRM dev boot and the console on
Vite, with Playwright mocking the hosted routes (`runtime/config`
patched to a cloud base with `installLocal: false`, the catalog,
manifest, `install-namespace` and `install` answers). Seven dialog
states in the project folder `ui-orders/32040-shots/`: loading, default
shown, no default (`503`), name taken (`409`), malformed (`400`), second
copy (`409 targetPackageId`), managed (no field).

<details><summary><code>dispatch-gates --ran</code>: 39 derived, 39 run,
0 NOT-MEASURED; every exit 0</summary>

`check:eager-closure` and `check:spec-symbols` (ui) ran beside the 39
and exited 0; `check-sdui-manifest` is one of the 39. Gate scripts ran
on a shared box.

</details>

## Known limits

- The namespace key inside `data` is read as `namespace`, taken from the
relay pin in `cloud-connection-plugin.test.ts`, which objectstack-ai#32182's own body
calls an illustrative fixture. Cloud PR objectstack-ai#4206 is not readable from this
session. If the control plane sends another key, the field is simply
empty (a typed name still installs); it never sends a wrong value.
- A second unmanaged copy of the same package is still refused, as the
card says (item 3).

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(no spec change)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; lint passes on the changed files.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title and body are in English, except the maintainer brief.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01WGufzgQpfw8pDeXcPo2zvJ
<!-- signed: domain:ui#2 · os-support-ai ·
session_01WGufzgQpfw8pDeXcPo2zvJ -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs-drift mapper 把 30 个嵌套包全部塌成父目录:只特判了 plugins,导致真实漏报(automation/flows.mdx 就是其中一个)

2 participants