Skip to content

feat(scenarios): gallery-publish publishes each gallery app to the marketplace as a template; the export carries the readmePath README - #39314

Draft
objectstack-fleet[bot] wants to merge 9 commits into
mainfrom
claude/issue-35134-gallery-publish
Draft

objectstack-fleet[bot] wants to merge 9 commits into
mainfrom
claude/issue-35134-gallery-publish

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Part of #35134

Clause-②: yes (widening: a new gallery-publish command on the published @objectstack/scenarios bin)
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:发布团队可以用一条命令,把画廊里每个通过验证的应用,以“模板”形式提交到应用市场审核;已经发布过的版本会被跳过并写明原因。客户暂时还看不到变化,要等画廊那边的自动发布接上。
  • 为什么做:这是“客户可以从应用市场中下载安装试用”这个目标的发布那一步(场景画廊专题);同时修好导出缺少说明文件、导致发布命令直接失败的问题。
  • 出错会怎样:最坏是某个应用这次没有发布成功,命令会写明原因并以失败退出;已发布的版本不会被删除或修改,可以直接撤回本改动。
  • 要你做什么:定下用哪个云端组织作为官方发布方,并提供它的 API 密钥(存为画廊仓库的密钥),以及该组织的软件包标识前缀;再决定画廊版本走正常审核还是自动通过、在市场里公开还是仅限链接。

What changes

  • gallery-publish (packages/qa/scenarios/src/export/publish.ts, CLI publish-cli.ts; the bin reaches it as npx @objectstack/scenarios gallery-publish). For each app in a gallery checkout's index.json:
    • The version is framework.version. The package id is PREFIX.APP_ID, with _ spelled -. It is checked against the spec's PackageSchema.shape.manifestId before anything runs. --id-prefix is required and has no default, because a package id is permanent and the publisher is the maintainer's decision.
    • The publishing CLI comes first, apart from the gallery's code. Before any gallery code runs, @objectstack/cli@VERSION is installed once per version with npm install --ignore-scripts --no-save --prefix DIR into a temp directory of its own, apart from the work directory. Its tree is fingerprinted (treeDigest).
    • The command copies apps/ID/source into a work directory, so the gallery checkout is never written. It builds that copy with the project's own installed CLI, run by path: npm install --include=dev, then node node_modules/@objectstack/cli/bin/run.js build. If the install leaves no @objectstack/cli, the app fails. Nothing is ever fetched and run through npx.
    • The publish runs the CLI from the first step, by path, from the work directory: node DIR/node_modules/@objectstack/cli/bin/run.js package publish --visibility marketplace --submit --readme-file … --license … --icon-url … --description … --homepage-url … --note …. Its tree must still match the fingerprint, or the app fails and nothing runs with the key.
    • Listing metadata. The description is summary.en. The README is written from index.json, the screenshots (linked from the gallery), the 问数 transcript summary and the app's gallery README.md. The summary gives the counts, then how many askers of each question passed in the last half, with a link to the full transcript. The display name, the Chinese pair and the business functions come from the source's objectstack.manifest.json, which the export wrote.
    • Free-plan note. If the build declares a scheduled flow, the description and the README say that scheduled flows do not run on a Free-plan trial. The command counts these with the spec's resolveFlowTriggerKind (schedule and time_relative), which is how the control plane counts them in declaredScheduledFlowCount.
    • Icon. --icon-url is preferred. With --icon-file, an upload the control plane refuses fails the app with the cause named: no icon store on a 503. The message then points to --icon-url.
    • Idempotency, read from the code.
      • The command first reads the public catalog (GET /api/v1/marketplace/packages/:id, approved versions of a listed package). If the catalog already serves the version, the app is skipped and nothing is built or sent.
      • Otherwise the control plane's version door decides. Cloud packages/service-cloud/src/routes/package-publish.ts looks up (package_id, version) before any write and answers 409 with Version 'V' already exists for package 'ID'. Bump the version and retry. os package publish prints that as Publish version failed (409): … in its !verRes.ok branch. The command treats that sentence as a skip only when V is this version and ID is this package. The lookup reads no review status, so the skip reason says the version is held "in review, approved but unlisted, or rejected".
      • Any other 409 is a failure. The hosted schema-upgrade stop is also a 409, but only with --install, which this command never passes. feat(cli): os deploy and os package publish --install stop on the hosted schema upgrade refusal and take --confirm-upgrade (#30887) #39286 left the printed line unchanged.
    • Credentials.
      • The key comes from OS_CLOUD_API_KEY only. If it is missing, the command refuses before any network call or child process. A key flag on the command line is refused.
      • The key is never on an argv. The CLI install, the gallery's npm install and its build get an allowlist of the caller's environment (TOOL_ENV): never the key, NODE_ENV, NODE_OPTIONS or any other secret.
      • The publish child's whole environment is PATH, a fresh empty HOME, the key, OS_CLOUD_URL and, when set, OS_ORG_ID. Pinning OS_CLOUD_URL stops the CLI falling back to a cloud.json URL.
      • Each child leads a process group of its own, which is killed when the child exits.
      • Every kept line of child output has the key replaced.
      • This is not a sandbox. The gallery's install scripts and its objectstack.config.ts run as the same user, on the same file system. The fingerprint catches a rewrite of the publishing CLI. It does not stop code that escapes its process group or reads what the user can read. The README says to run the command where the key is the only secret, on a throwaway runner.
    • --dry-run prints, per app, would publish or would skip with the reason, and the exact commands with the key shown as [redacted]. It builds, writes and publishes nothing, and creates no directory, not even --work DIR.
    • The publishing module is not exported. The @objectstack/scenarios/export subpath gains only mainPublish (through the export-check re-exports) and manifestReadmePath, both named in the changeset.
  • Exporter fix (source.ts). The exported source/ now carries the README that objectstack.manifest.json names as readmePath, so os package publish run there can read it. The app is refused, with its reason, when the readmePath:
    • is missing;
    • is absolute;
    • climbs out with ..;
    • enters node_modules or dist;
    • passes through a symbolically linked directory.
  • README. A new section, Publishing the gallery to the marketplace — gallery-publish, covers the command, the env var, idempotency, and the rule that an app later removed from the gallery is not unpublished: its last good version stays installable. The refresh section now notes the README copy. The gallery-publish pnpm script is added for use from a checkout.

Why Part of. Items 2 and 3 of the card live on objectstack-ai/gallery: the workflow on push to main and the gallery README's install path. They wait for this CLI's release and for the maintainer's two preconditions: the publisher identity, its key and its id prefix, and the review policy and listing visibility.

Read first (riskiest first):

  1. publish.ts galleryPublish, the CLI-install phase and the keyed spawn: cliInstallArgv, treeDigest, publishEnv. Check that the key reaches only the CLI this command installed.
  2. publish-cli.ts spawnChild: the process-group kill.
  3. publish.ts classifyPublish: the skip rule, which must never turn a real failure into a skip.

Two-minute check: pnpm --filter @objectstack/scenarios exec vitest run --maxWorkers=2 test/export/publish.test.ts. Expect 22 green:

  • the missing key, with zero spawns and reads;
  • both skips;
  • the metadata mapping;
  • the dry-run lines;
  • the icon cause;
  • the key redaction;
  • the separate, fingerprinted publishing CLI and its allowlisted environment;
  • no npx;
  • the process-group kill.

Acceptance notes

  • The published bin's lazy entry. gallery-publish reaches the bin through the export-check build entry (check-cli.ts re-exports mainPublish), because tsup.config.ts was outside this claim's file surface. dist/bin.js still imports only fs, path and url, as measured after the build. A separate export-publish entry is a one-line follow-up in tsup.config.ts if the seat wants one.
  • Dry run and the Free-plan note. A dry run does not build, so it cannot know whether the description gains the Free-plan sentence, and it prints a line saying so. The Chinese listing description (translations.zh.description, read from the manifest by the CLI) does not carry the note. The Chinese sentence is in the README only.
  • The 409 skip comes after a package upsert. os package publish runs a step-1 package upsert before the version POST that answers 409.
    • For a version not yet approved, that upsert rewrites the package's listing (README, description, icon, licence, homepage, visibility) from this run's values, even though the version is skipped. The README says so.
    • The catalog pre-check avoids the upsert for approved versions.
    • A rejected version is skipped on every run until the framework version moves.
  • Fix round, the review's points and what was chosen:
    • readmePath containment. The review proposed a realpath check (N5). The code instead refuses a symbolic link on any directory of the path; the file itself was already refused by take's lstat. That is stricter than realpath containment: it also refuses a link that stays inside the project, which the module's rule ("a symbolic link anywhere refuses the export") requires. With it in place, a realpath check could never fire, so none was added.
    • OS_ORG_ID. It is in the publish allowlist beyond the four names the review listed, because the README promises it reaches --org.
    • Fresh HOME. The publish child's HOME is a fresh directory rather than the caller's, so nothing the build wrote under the user's home (an oclif data directory, cloud.json) is read with the key.
  • The publishing CLI tree. @objectstack/cli@18.5.0, installed with --ignore-scripts, is 703 MB and 23,939 files.
    • Its fingerprint took about 1.1 s with the page cache warm; this is a shared-box reading.
    • The fingerprint is unchanged by a publish run, so several apps on one version share one install.
  • License. The --license default Apache-2.0 follows the publish command line in the card's 2026-11-18 readings. It matches the gallery's own LICENSE (Apache License 2.0, read from a clone of objectstack-ai/gallery).

Tests

Targeted tests and typecheck at the final head

Readings at head c0a9ba2b74 (objectstack-ai/objectstack).

  • pnpm --filter @objectstack/scenarios exec vitest run --maxWorkers=2 (the whole package): exit 0, Test Files 47 passed (47), Tests 1479 passed (1479).
  • pnpm --filter @objectstack/scenarios typecheck: exit 0. The tsc --listFiles run includes test/export/publish.test.ts.
  • Root eslint --no-inline-config on the changed source and test files: exit 0.
  • The built dist/export.cjs exports mainPublish and manifestReadmePath as functions; galleryPublish is undefined, so it is not exported.
  • pnpm --filter @objectstack/scenarios build: exit 0. The built dist/bin.js imports only fs, path and url, which packed-tarball.test.ts pins.
Red at base, then ablations (each restored to the HEAD blob)

Red at base (git restore --source=f80864150e -- packages/qa/scenarios/src, then restored to HEAD): publish.test.ts fails to load (Cannot find module '../../src/export/publish-cli.js'). In exporter.test.ts, 3 of the new README tests fail (Tests 3 failed | 74 passed (77)).

Each mutation went through scripts/ablation-replace.mjs: the anchor hit once, the blob changed, and the file was restored to blob == HEAD with an empty git diff HEAD. The tests import src, so there is no build leg. Run: vitest run test/export/publish.test.ts test/export/exporter.test.ts, 92 tests.

  • A1, the catalog skip answers holds: false: 2 red (the catalog skip, and the dry-run skip line).
  • A2, the 409 skip rule is disabled: 1 red (the duplicate-version skip).
  • A3, the missing-key refusal is disabled: 4 red (unset, blank, dry run, and the bin door).
  • A4, the description no longer comes from listingDescription: 3 red (the metadata mapping, the scheduled-flow note, and the dry-run line).
  • A5, the dry-run line prints the key: 1 red (the dry run).
  • A6, the exporter's take(readme) is removed: 2 red (the README is exported, and the subdirectory case). The refusal case stays green, as expected, because its refusal comes before the copy.
  • A7, the key also reaches install and build: 1 red (the key travels only to publish).
  • A8, the icon-cause branch is disabled: 1 red (the icon upload refused).
Fix round (L2 contract review, B1, B2, N1 to N5): red first, then ablations

Red first, at 6991287c7d's parent with only the new tests applied (red-fix-round.out, then red3.out once the dependency closure was built):

  • publish.test.ts: Tests 13 failed | 9 passed (22). Every B1, B2, N2, N3, N4 and dry-run test was red. The process-group test timed out at 15 s, because the child's sleep 30 held the pipes open.
  • exporter.test.ts: Tests 1 failed | 77 passed (78). The symlinked docs/ README was exported.

Each mutation went through scripts/ablation-replace.mjs against the committed 65ca516dc0. Each file was restored to blob == HEAD with an empty git diff HEAD. Run: vitest run test/export/publish.test.ts test/export/exporter.test.ts, 100 tests.

Ablation Mutation Red
A9 (B1) the publish runs the work copy's CLI 1: the CLI outside the work copy
A10 (B1) the fingerprint check is off 1: the CLI tree changed
A11 (B1) the publish env is the caller's whole env plus the allowlist 2: the key's travel, the allowlist
A12 (B1) the CLI install without --ignore-scripts 3: the metadata argv, the dry-run line, the CLI install
A13 (B1) no process group (detached: false) 1: the leftover process; it timed out at 15 s
A14 (B2) npm install without --include=dev 3: the metadata argv, the dry-run line, no npx
A15 (B2) the missing-local-CLI check is off 1: the install that leaves no CLI
A16 (B2) the build goes back to npx objectstack build 2: the metadata argv, no npx
A17 (nit) install and build get the caller's whole env minus the key 1: no NODE_ENV, NODE_OPTIONS or runner secret
A18 (N2) the 409 package-id match is dropped 1: a 409 for another package id
A19 (N5) the symlinked-directory check is off 1: the symlinked docs/
A20 (nit) a dry run creates --work DIR 1: the dry run
A21 (B1) the CLI-directory-apart refusal is off 1: the CLI directory inside the work directory

The N3 and N4 wording is pinned by the existing skip-line and icon-line tests, which went red at base as listed above. The wording was not ablated separately.

Verification

Readings against the real gallery (a read-only clone of objectstack-ai/gallery, one app: asset_lifecycle @ 18.5.0)
  • Built bin, real end to end at 6991287c7d's code (unchanged at the head), with nothing sent. The run used OS_CLOUD_API_KEY=dummy-not-a-key NODE_ENV=production and --server http://127.0.0.1:9 --work DIR, taking 73 s.
    • @objectstack/cli@18.5.0 was installed with --ignore-scripts into the separate CLI directory.
    • The gallery copy's npm install --include=dev left node_modules/@objectstack/cli/bin/run.js in place despite NODE_ENV=production, and its build wrote dist/objectstack.json.
    • The fingerprint matched.
    • The separately installed CLI ran with the allowlisted environment and stopped at Register package failed (0): fetch failed, giving 0 published, 0 skipped, 1 failed, exit 1.
    • The CLI temp directory was removed after the run.
  • Built bin, dry run at the head. Exit 0, with would publish: asset_lifecycle as ai.objectos.gallery.asset-lifecycle@18.5.0.
    • The lines printed: the npm install --ignore-scripts … --prefix /tmp/gallery-publish-cli/18.5.0 @objectstack/cli@18.5.0 line, npm install --include=dev …, node …/node_modules/@objectstack/cli/bin/run.js build, and env -i PATH="$PATH" HOME=… OS_CLOUD_API_KEY=[redacted] OS_CLOUD_URL=… node /tmp/gallery-publish-cli/18.5.0/node_modules/@objectstack/cli/bin/run.js package publish ….
    • Neither --work DIR nor the CLI directory exists afterwards.
  • Earlier reading, first round, built bin dry run. The catalog read reached cloud.objectos.ai and answered 404.
  • The real build of that app's source/. A scratch copy ran npm install and npx objectstack build with CLI 18.5.0, both exit 0. scheduledFlowCount on its dist/objectstack.json answered 1: post_monthly_depreciation, the monthly depreciation flow the 2026-11-18 reading saw not armed on a Free plan. So the listing for this app carries the Free-plan sentence.
  • The real 18.5.0 os package publish. It was given the exact flag set this command sends, against an unreachable OS_CLOUD_URL (127.0.0.1:9), so nothing was sent anywhere. It accepted every flag, loaded the artifact and the manifest, and stopped at Register package failed (0): fetch failed, exit 1.
  • Built bin, no key. env -u OS_CLOUD_API_KEY … gallery-publish … printed refused — OS_CLOUD_API_KEY is not set …, exit 1. dist/bin.js imports only from "fs", from "path" and from "url". require('dist/export.cjs').galleryPublish and require('dist/export-check.cjs').mainPublish both load as functions.
Gates: dispatch-gates --commands and --ran, at the final head c0a9ba2
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 83 families at c0a9ba2b74, the same list as at 6991287c7d.
  • Each gate ran with a 280 s bound and its exit code was captured before any pipe. 82 exited 0.
  • check:query-options-erasure outran 280 s twice (124). It exited 0 in 372 s on a 585 s bound, and the record carries that re-run code.
  • check:dual-build-cjs-loads was measured this time and exited 0: 128 published require entry point(s) across 75 package(s) load. It was exit 3, NOT MEASURED, in the first round.
  • node scripts/pm/dispatch-gates.mjs --ran ran3.list: exit 0, 83 derived famil(ies) accounted for — 83 run, 0 NOT-MEASURED.
  • The same 83 also ran at 6991287c7d and reconciled to 82 run, 1 NOT-MEASURED, where dual-build-cjs-loads gave exit 3 before the closure was built.
  • CI-owned families are read from this PR's check-runs, not re-run locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TsNV8Bsjqmw7aXCo2QuLU1

@github-actions github-actions Bot added size/xl dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/scenarios, touching 89 documentable anchor(s). ⚠️ 2 changed file(s) yielded no anchor (packages/qa/scenarios/README.md, packages/qa/scenarios/src/export/check-cli.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

47 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 6b2e596027c7d4f9b01efab0766e3cfd4f2ba7df.

⛔ 14 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 2 changed file(s) yielded no anchor (packages/qa/scenarios/README.md, packages/qa/scenarios/src/export/check-cli.ts) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: objectstack.config.ts (literal, 42 pages)
  • 18 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 256 client-bound route-ledger rows — the other 185 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 185: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 125 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 2 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 6b2e596027c7d4f9b01efab0766e3cfd4f2ba7df → packageMentionDocs.

Which tree this was computed on

This run read content/docs from f21159b17fd5b21315a4e557faadefca991c4da2 — the merge of head c0a9ba2b74bf8b44237476fcf9038b206dbb8afe into base 6b2e596027c7d4f9b01efab0766e3cfd4f2ba7df, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin f21159b17fd5b21315a4e557faadefca991c4da2 && git checkout f21159b17fd5b21315a4e557faadefca991c4da2
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 6b2e596027c7d4f9b01efab0766e3cfd4f2ba7df c0a9ba2b74bf8b44237476fcf9038b206dbb8afe && git checkout -B drift-repro 6b2e596027c7d4f9b01efab0766e3cfd4f2ba7df && git merge --no-ff c0a9ba2b74bf8b44237476fcf9038b206dbb8afe

node scripts/docs-audit/affected-docs.mjs --json 6b2e596027c7d4f9b01efab0766e3cfd4f2ba7df

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 6b2e596027c7d4f9b01efab0766e3cfd4f2ba7df → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud@zhuangjianguo · zhuangjianguo · session_01TsNV8Bsjqmw7aXCo2QuLU1

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 5e8604200ec652c4398d168faa66830bd891cd6f
Local-runs: none
Scope: the PR diff against merge base 14680d009b (11 files): .changeset/35134-gallery-publish.md, packages/qa/scenarios/{README.md,package.json}, src/bin.ts, src/export/{check-cli.ts,index.ts,publish-cli.ts,publish.ts,source.ts}, test/export/{exporter.test.ts,publish.test.ts}. Read-only citations: packages/cli/src/commands/package/publish.ts and src/utils/cloud-config.ts at the head; packages/cli/src/commands/compile.ts; packages/create-objectstack/src/templates/blank/package.json; src/export/manifest.ts; cloud origin/main ce4997f17 packages/service-cloud/src/routes/package-publish.ts; npm 10.9.9's docs/content/commands/npm-exec.md and npm-install.md; the npm registry (objectstack answers 404; the bins of @objectstack/cli are os and objectstack); AGENTS.md § Post-Task Checklist step 3; the PR body (updated 11:37:20Z); card #35134 with comments 6973238785, 7375179236 (claim) and 7376939705 (dev report); check-runs on the head, read at 11:43:30Z.
Security-touching: yes
Rule-change-verified: none

Judgments

1. Widening declaration and changeset level: correct, but the declaration is incomplete (N1).

  • AGENTS.md:1030-1032: "The level follows the kind alone … none takes patch; a non-protocol change, widening or breaking, ships patch". The PR declares Metadata-protocol: none and Clause-②: yes (widening …), so '@objectstack/scenarios': patch is right. Both declaration lines are line-initial in the PR body and the changeset (.changeset/35134-gallery-publish.md:7-8).
  • The bin wiring matches the docs. bin.ts:74 routes gallery-publish to check-cli.js's mainPublish, and the usage text sits at bin.ts:45-48. The README section README.md:913-969 matches the code: flags, the version and id rules, the listing mapping, the icon behaviour, exit codes 0/1/2 (publish-cli.ts:154,159,130), and "never unpublished". OS_ORG_ID → --org is true through env inheritance (CLI publish.ts:589-591).
  • The widening is wider than declared (N1). src/export/index.ts:18 adds export * from './publish.js', which puts 25 new public symbols on the published @objectstack/scenarios/export subpath. These include galleryPublish, classifyPublish, redactKey, publishArgv, PublishRefusal, API_KEY_ENV and DEFAULT_CLOUD_URL. mainPublish (through check-cli.js) and manifestReadmePath (through source.js) become public too. Neither the changeset nor the PR body names any of them.

2. Credential safety: FAIL (B1, B2).

  • What holds:
    • The key is read only from env, at publish.ts:359.
    • It is refused when missing or blank as the first statement of galleryPublish (:358-362), before the index read, any fetch or any spawn.
    • A --token, --api-key or -t flag is a usage error (publish-cli.ts:76).
    • The key never appears on an argv (publishArgv, :262-275). It reaches only the publish spawn's env (:421, :480).
    • childEnv strips OS_CLOUD_API_KEY and OS_TOKEN from the install and build children (:322-326, :460, :465). So the key is not in the env of npm install or objectstack build.
    • Dry-run output prints [redacted] (:444). Failure tails are redactKey'd (:452). Refusal and error messages carry no key.
    • Nothing writes the key into the work directory. The copied source, dist/ and the <id>.listing.md README are its only contents.
    • Gallery-controlled index.json cannot traverse: id is a MachineName and path must be apps/<id> (manifest.ts:39-44,84-86).
  • OS_CLOUD_URL is pinned for the genuine CLI. The publish child gets OS_CLOUD_URL=server, and oclif binds --server to it (CLI publish.ts:541-544). resolveCloudCredential falls back to cloud.json only when OS_CLOUD_URL is unset (cloud-config.ts:227-231). server comes only from --server, the caller's OS_CLOUD_URL, or the default (publish.ts:381), never from gallery content.
  • What does not hold (B1): the pin only matters if the keyed child is the genuine CLI, and the keyed child's code is gallery-controlled.
    • The publish child is npx objectstack … with cwd set to the work copy (:480). That resolves <work>/node_modules/.bin/objectstack, a tree produced by steps that run gallery-controlled code:
      • npm install runs the copied package.json's own preinstall, install, postinstall and prepare scripts, plus every dependency's install scripts. No lockfile is exported (source.ts SOURCE_ROOT_FILES), so ranges float.
      • objectstack build runs compile, which loadConfigs and executes the gallery's objectstack.config.ts and src/ (CLI compile.ts:335).
    • Either step can rewrite node_modules/@objectstack/cli/** or node_modules/.bin/objectstack, or drop a project .npmrc with node-options=--require … (the gallery check has no source/ allowlist that would refuse one). The next spawn then runs that code with OS_CLOUD_API_KEY in process.env and can send it to any host.
    • The key is absent from the install and build env only while those steps run. Code they leave behind receives it.
    • The claim "npm install and the build run without it, so dependency install scripts never see it" is therefore not a protection. It appears in the PR body, publish.ts:52-53, README.md:956-957 and .changeset/35134-gallery-publish.md:20-21.
  • Also not holding (B2): there is no install guard on npx.
    • The scaffold declares @objectstack/cli as a devDependency (create-objectstack/src/templates/blank/package.json:25).
    • npm install omits dev dependencies when the inherited env has NODE_ENV=production (npm-install docs, omit). childEnv passes the caller's env through.
    • With no local bin, npx objectstack installs the unscoped objectstack package from the registry and runs it. npm-exec docs: "When standard input is not a TTY or a CI environment is detected, --yes is assumed", and spawnChild sets stdin to 'ignore' (publish-cli.ts:88).
    • objectstack does not exist on npm today (registry 404), so anyone can register it. It would run in the build and then in the keyed publish child.

3. Idempotency: correct, with two precision gaps (N2, N3).

  • The catalog pre-check (publish.ts:343-354, :423-428) skips only when data.versions[].version === version. A 404 means "not held". Any other status, or a body with no version list, is unread and falls through to the publish, which is safe.
  • The 409 skip (:287, :301-302) is the exact sentence cloud prints (package-publish.ts:1674-1676), as relayed by the CLI's Publish version failed (${status}): ${error} (CLI publish.ts:1045). It requires dup[1] === plan.version. Any other 409 falls through to failed:
    • the module-id collision 409 (package-publish.ts:1622);
    • a 409 for another version;
    • the reserved-namespace 409, which is tested at publish.test.ts:198-207.
  • N2: the package id captured in dup[2] is never compared with plan.manifestId.
  • N3: cloud's duplicate lookup has no status filter (package-publish.ts:1668-1670). A version that was rejected in review is therefore reported as "the control plane already holds … skipped" on every run, with exit 0.
  • The step-1 upsert is described honestly in the PR body ("For an unchanged app these are the same values") and in publish.ts:38-40. README.md:951 ("re-sends the same listing fields") is vaguer: the README, description and icon are recomputed on each run (N3).

4. The exporter's README copy: correct (N5).

  • manifestReadmePath (source.ts:89-104) refuses:
    • an absolute path (isAbsolute, posix.isAbsolute);
    • .. and ../… after posix.normalize, and .;
    • any segment in NEVER (node_modules, dist, .objectstack, .git).
  • readAuthoredSource (:61-69) refuses a path that is missing or is not a file. It refuses a symlinked final component through take's lstat.
  • Tests cover missing, .., absolute and node_modules (exporter.test.ts new block, third case). There is no dist case (nit).
  • N5: an intermediate directory symlink is not caught. lstat checks only the last component, and walk checks symlinks only under src/.

5. Tests and ablations: they correspond.

  • The missing-key cases assert calls and reads both []:

    • unset and blank through main (publish.test.ts:135-148);
    • dry run through galleryPublish (:150-155);
    • the bin with a nonexistent gallery, which proves the key check precedes the index check (:157-168).
  • I checked each ablation against the assertions it should turn red:

    Ablation Reported red Assertions
    A1 2 :179, :302
    A2 1 :187
    A3 4 :139 ×2, :150, :157
    A4 3 :226, :254, :300
    A5 1 :295
    A6 2 the two exporter export cases; the refusal case stays green, as the report says
    A7 1 :258-271
    A8 1 :309
  • The counts agree with the test bodies. I did not re-run them.

  • No test covers B1 or B2: which binary the keyed spawn runs, and whether npx may install.

6. CI on the head, at 11:43:30Z.

  • 52 check-runs: 28 success, 18 skipped, 6 in progress, 0 failure.
  • Concluded success: TypeScript Type Check, all four Type Check · * jobs, Build Core, Check Changeset, Lint · ESLint, Lint · repo & tooling gates, Lint · CI, release & engine gates, Lint · docs & code guards, Test Core 5/12 through 8/12, Test UI, Dogfood Regression Gate, Governed Surface Queue Guard, PR-body guards, and Validate Package Dependencies.
  • check:dual-build-cjs-loads is CI-owned. Locally it was NOT MEASURED (exit 3). It runs in Build Core (ci.yml:3686-3687), whose step "Every published require entry point actually loads" concluded success.
  • Still running: Test Core 1/12 through 4/12, Lint · PM dispatch-gates, and Lint · scoped · query-options erasure.
  • The PR is a draft (mergeable_state: blocked).

Blocking

  • B1: the publish child, which holds the key, runs a CLI tree that gallery-controlled code writes.
    • Where: packages/qa/scenarios/src/export/publish.ts:480, which spawns npx objectstack package publish in work after :460 (npm install) and :465 (objectstack build) ran gallery code there. The overstated claim is at publish.ts:50-54, README.md:956-957, .changeset/35134-gallery-publish.md:20-21 and the PR body's Credentials bullet.
    • Fix, part 1: publish from a CLI tree the gallery does not write. Once per distinct framework.version (already STABLE_VERSION-checked), run npm install --ignore-scripts --no-save --prefix <workDir>/.cli/<version> @objectstack/cli@<version> with childEnv(deps.env).
    • Fix, part 2: spawn process.execPath with [<that>/node_modules/@objectstack/cli/bin/run.js, 'package', 'publish', ...publishArgv(p)] and cwd: work. Publish only reads dist/objectstack.json, objectstack.manifest.json and the README there.
    • Fix, part 3: give that spawn a minimal env: PATH, HOME, the key, OS_CLOUD_URL, and nothing NODE_OPTIONS or npm_config_*.
    • Fix, part 4: update the dry-run line (:444).
    • Fix, part 5: pin it with a test asserting that the publish spawn's cmd and script path lie outside work.
    • Fix, part 6: until this lands, correct the four claims to say what holds ("the key is not in the env of install or build").
  • B2: npx objectstack can install and run the unscoped, unregistered objectstack package from npm.
    • Where: publish.ts:279 (BUILD_ARGV) and :480. Non-TTY stdin comes from publish-cli.ts:88. The CLI is a devDependency (create-objectstack/src/templates/blank/package.json:25), and NODE_ENV=production passes through childEnv (:322-326).
    • Fix, part 1: spawn npx --no-install objectstack … (or npm exec --no -- objectstack …) for the build, and for the publish if B1 keeps npx.
    • Fix, part 2: install with npm install --include=dev --no-audit --no-fund (:278).
    • Fix, part 3: fail the app when <work>/node_modules/.bin/objectstack is absent after install.
    • Fix, part 4: pin the argv in the metadata test (publish.test.ts:217) and the dry-run expectation (:298).

Non-blocking

  • N1: the undeclared public API. Add a changeset bullet naming the @objectstack/scenarios/export additions (galleryPublish and its helpers, mainPublish, manifestReadmePath). Alternatively, if they are not meant to be public, drop export * from './publish.js' (src/export/index.ts:18).
  • N2: classifyPublish (publish.ts:302) also needs && dup[2] === plan.manifestId, plus one case for a sentence carrying a different id.
  • N3: two wording fixes.
    • The skip why at publish.ts:302 should say "holds it (in review, rejected or unlisted)", so a rejected version is not reported as a plain hold.
    • README.md:951 should say that, for a version not yet approved, the step-1 upsert rewrites the package's listing (readme, description, icon, licence, homepage, visibility) from this run's values even though the version is skipped.
  • N4: the icon failure says "Nothing was published" (publish.ts:309). The CLI's step-1 upsert (CLI publish.ts:955) has already created or updated the package row before the icon upload (:978). Suggested wording: "No version was published; the package row was registered".
  • N5: to catch an intermediate symlink in readmePath (source.ts:61-69), check realpathSync(join(projectDir, readme)) against realpathSync(projectDir) + sep. A dist/… case would make the refusal list complete.
  • Nit: --dry-run --work DIR creates DIR (publish-cli.ts:133), but README.md:962 says a dry run writes nothing.
  • Nit: childEnv passes the caller's whole env (minus the two key names) to the gallery's install and build code. An allowlist (PATH, HOME, npm cache and proxy variables) would also keep other runner secrets out.

Verdict

FAIL at 5e8604200ec652c4398d168faa66830bd891cd6f. Two blocking items:

  • B1: the key goes to a publish child whose CLI tree the gallery's install scripts and objectstack.config.ts can rewrite. The "install and build never see it" claim does not protect it.
  • B2: npx with no install guard can fetch and run the unregistered unscoped objectstack package.

What is correct:

  • the changeset level and the widening arm;
  • the idempotency rule;
  • the missing-key refusal (0 spawns, 0 fetches);
  • the redaction;
  • the readmePath refusals;
  • the eight ablations.

CI has 0 failures so far. 6 runs are still in progress, and the CI-owned dual-build-cjs-loads step has concluded success.

… gallery never wrote, and never fetches through npx

- The publishing CLI is installed once per framework version with --ignore-scripts into a directory apart from
  the work copy, before any gallery code runs, fingerprinted, and checked before each keyed publish. It runs by
  path with an allowlisted environment: PATH, a fresh HOME, the key, OS_CLOUD_URL and OS_ORG_ID when set.
- The gallery install keeps dev dependencies (--include=dev) and the build runs the project's installed CLI by
  path; an install that leaves none fails the app. Install and build get an allowlisted environment.
- Each child leads its own process group, killed when it exits.
- The 409 skip also matches the package id; skip and icon wording state what holds.
- A readmePath through a symbolically linked directory is refused.
- A dry run creates no directory; the publish module leaves the export subpath.

Claude-Session: https://claude.ai/code/session_01TsNV8Bsjqmw7aXCo2QuLU1
Co-authored-by: Claude <noreply@anthropic.com>
…credential handling holds

Claude-Session: https://claude.ai/code/session_01TsNV8Bsjqmw7aXCo2QuLU1
Co-authored-by: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
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/xl tests 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.

2 participants