Repository navigation
Commit ade13d3
fix(cloud-connection, runtime)!: install-local refuses a package with two enabled jobs of one name, as the binder refuses the name at bind (#32889)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuNCRstR4ui2WukRu5DzDKPR)_
Fixes #32572
domain:server#7 · os-sales · session_01L6bhgTHn5TtkSoqxQzSJ34 (card
thread; claim 6836648648)
Clause-②: yes (narrowing) — the narrowing: `POST
/api/v1/marketplace/install-local` refuses a package with two or more
enabled jobs of one name with `422 VALIDATION_ERROR`, where it answered
`200` and none of those jobs ran: with package-authored scheduled work
on, the binder then refused the name at bind and cancelled the job of
that name the installed version ran; with it off
(`OS_AUTOMATION_SCHEDULED_WORK_ENABLED` unset, the default) or with no
job service, the package installed whole with every job withheld, and an
upgrade to it landed. The door judges the package whatever the switch,
as it already judges a job with no `body`. The widening:
`@objectstack/runtime` exports `collectJobNameCollisions(bundle,
appId)`, the binder's own shared-name judgement (`jobNameCollisions`)
the door refuses by — a name added to the package's entry, so the public
surface grows (the claim expected `no (narrowing)`; measured `yes`
because of that export, the one way to share the bind's judgement
without a second copy in the door).
Metadata-protocol: none — no key, value or metadata type an author
writes changes; what moves is one door's answer to a package whose
shared job name no deployment runs a job of (with scheduled work on the
binder refuses it at bind; with it off, the default, no job of the
package is scheduled).
Skills-docs: follow-up #32896 — content/docs/automation/jobs.mdx (its
job-name paragraph and its install callout say the runtime refuses a
shared name at bind; one sentence owed: `os package install` refuses
such a package with `422` before installing, and the installed version
keeps running). `skills/**` does not teach the install door's job
refusals.
## 维护者速读
- 改了什么:通过 install-local(`os package
install`)装一个包,若包里有两个及以上同名且启用的定时任务,以前门口答
200,之后看部署:定时调度默认关(`OS_AUTOMATION_SCHEDULED_WORK_ENABLED` 未设)或没有 job
服务时,包整个装上、登记记账,任务按开关一个都不调度,名字没人判,升级也落到新版本;开了调度时,绑定器拒绝这个名字、一个都不调度,还把旧版本正在跑的同名任务取消了。现在不论开关,门口都直接
422 拒收(与开关关着时照样拒收没有 body 的任务一致),提示里原样引用绑定器的拒绝句(每个任务、每个声明它的包、以及制品顶层
residual),什么都不写入。
-
为什么改:开了调度的部署上,运维看到"安装成功",实际这些任务都不跑、旧任务也停了,毫无提示;默认(调度关)的部署上,这个名字要等开了调度才在绑定时被拒(#32411
契约审查点名的余项,专题 #31527)。
-
风险与回滚:只收窄一种以前就跑不起来的包;同名但禁用的孪生、名字各不相同的任务照旧安装。默认(调度关)的部署上,以前整包装上(任务本就不跑)的这种包或这种升级,现在整包被拒。已装包重启照旧加载(开着调度时绑定器照旧拒绝并记
error,关着时任务照旧不调度)。回滚即 revert。
- 先看:`packages/cloud-connection/src/marketplace-install-local-plugin.ts`
的 `unrunnableCode`(新判定的懒加载与降级告警)和 `describeUnrunnable`
的新首句;`packages/runtime/src/app-artifact-handlers.ts` 的
`collectJobNameCollisions`(只是 `jobNameCollisions` 的出口)。
- 两分钟验证:`pnpm --filter @objectstack/cloud-connection exec vitest run
--maxWorkers=2 src/marketplace-install-local-jobs.test.ts -t 32572`,应见 6
passed(main 源码下 4 个拒收钉子红、2 个 CONTROL 绿)。
- 需要你做的:无,席位落地。
## What changes
**The defect.** Since #32563 the binder (`scheduleAppArtifactJobs`), on
a deployment that runs package-authored scheduled work, refuses a job
name two or more enabled jobs of one artifact share
(`jobNameCollisions`): the job service keys a job by its name and keeps
only the last one scheduled, so none of the name's jobs is scheduled,
the refusal is logged at `error`, and the job of that name the app
scheduled before is cancelled. With scheduled work off
(`OS_AUTOMATION_SCHEDULED_WORK_ENABLED` unset, the default in every
posture) or with no `job` service, the binder returns before it judges
any name: every job is withheld (one `info` or `warn` line) and nothing
is refused. The install-local door pre-judges the jobs it cannot run
(`collectJobsWithoutBody`) whatever the switch, but not a shared name,
so it answered such a package `200` on every deployment: with the switch
on, an upgrade stopped the job the installed version ran; with it off,
the package (or an upgrade to it) installed whole, carrying a name the
binder refuses as soon as scheduled work is turned on.
**The fix.**
1. **`@objectstack/runtime` (`app-artifact-handlers.ts`, `index.ts`).**
New export `collectJobNameCollisions(bundle, appId):
PackageScopedRefusal[]` = `jobNameCollisions(bundle, appId,
collectBundleJobs(bundle))` — the bind's own judgement over the jobs the
binder reads, one refusal per shared name, in the order the binder logs
them. Not a second copy: the binder and the door call the same function.
`scheduleAppArtifactJobs`'s docblock says install-local now refuses the
shape up front.
2. **`@objectstack/cloud-connection`
(`marketplace-install-local-plugin.ts`).** The install route's step 1d
(code this door cannot run) also judges shared names: `unrunnableCode`
resolves `collectJobNameCollisions` lazily from `@objectstack/runtime`,
as it resolves the other two judgements, and calls it with `manifestId`
— the id `bindArtifactHandlers` schedules the package's jobs under. A
runtime that predates the export judges nothing and says so at `warn`,
as for the other two. `describeUnrunnable` gains a first clause (first
because the binder judges the name before any job's run form) that
quotes each refusal's `message` whole, so the jobs and their holders are
the bind's own words: every declaring package body, and — when the
artifact holds more jobs of the name than its bodies declare — `this
artifact's top level outside every package body (its residual, …)`.
**Why a refusal, not a report in the answer.** It is how this door
already answers every job it cannot run: a job with no `body`, a `body`
the declaration refuses, a `pull` that does not bind — one `422
VALIDATION_ERROR` before any write, one clause per kind, so the author
fixes them in one pass. A shared name is the same kind of fact
(installed, the jobs would never be scheduled), and, with scheduled work
on, refusing it before any write is what keeps the installed version's
job running on an upgrade; a 200 with a report would still cancel it.
The answer stays prose-only like the other clauses: the unrunnable
refusal carries no `details`, and adding one would also move
`@objectstack/client`'s `err.details` from the whole body to that object
(a second narrowing face). The holder vocabulary is the bind's by
construction, since its message is quoted.
**Not changed.** The `kernel:ready` rehydrate is not gated (as for the
other 1d judgements): an entry installed before loads, and its jobs are
bound as today (with scheduled work on its shared name is refused at
bind; with it off every job is withheld). The binder's judgement, its
`409` log line and its candidates are untouched. The `unmanaged` mode
passes through the same step 1d, as the other judgements do.
## FROM → TO (every moved answer)
FROM = `origin/main` `c04aa295` (source of the three changed files
restored over the fix, runtime rebuilt), measured by the pins below. The
pins run with scheduled work on (the test harness sets
`OS_AUTOMATION_SCHEDULED_WORK_ENABLED` to `true`), so the rows marked
**on** are pinned; the rows marked **off** and the no-job-service row
are the contract review's probe A readings (6838806726), reproduced by
the epic red-line read (6839378150), and are not pinned here. The
multi-package, one-pass and CONTROL rows are with scheduled work on.
| Install-local request | FROM | TO |
|:--|:--|:--|
| single-package artifact, two enabled body jobs `jobs_app_twin` (plus
one of its own name); scheduled work **on** | `200`, `hotLoaded: true`;
the binder refuses `jobs_app_twin` at `error` and schedules only the
other job | `422 VALIDATION_ERROR`; message names the shared name and
quotes the bind refusal (`declared by package "com.example.jobsapp", the
app itself — one that runs a sandboxed body, and one that runs a
sandboxed body`); nothing registered, persisted or scheduled |
| the same package, scheduled work **off**
(`OS_AUTOMATION_SCHEDULED_WORK_ENABLED` unset, the default) | `200`; the
package registered and recorded in the ledger, no job scheduled (one
`info` line: declarative jobs not scheduled), nothing refused, no
`error` line | `422 VALIDATION_ERROR`, the same message; nothing
registered |
| the same package, scheduled work on but no `job` service | `200`; the
package registered, one `warn` line (job service not registered),
nothing refused | `422 VALIDATION_ERROR`; nothing registered |
| upgrade, scheduled work **on**: v1 with one `jobs_app_twin` installed
and scheduled, then the package declaring it twice | `200`,
`upgradedFrom` set; the bind refuses the name and cancels the running
`jobs_app_twin` (the runtime pin `a refused name cancels the job of that
name an earlier install of the package scheduled`) | `422
VALIDATION_ERROR`; no cancel, `jobs_app_twin` still scheduled, the
ledger keeps v1 |
| upgrade, scheduled work **off**: v1 with one `jobs_app_twin` installed
(its jobs withheld), then the package declaring it twice | `200`, the
ledger at v2 (`0.2.0`); no job scheduled, nothing refused | `422
VALIDATION_ERROR`; the ledger keeps v1 (`0.1.0`) |
| multi-package artifact (`composeStacks`, `manifest: 'preserve'`): body
`com.example.jobsalpha` and the residual both carry `jobs_app_twin` |
`200` | `422`; quotes `declared by package "com.example.jobsalpha"; and
by this artifact's top level outside every package body (its residual,
which runs as package "com.example.jobsapp", the body that carries the
artifact's id)` |
| shared name beside a handler-only job | `422`, the no-`body` clause
only | `422`, the shared-name clause first, then the no-`body` clause |
| CONTROL: two enabled jobs of distinct names | `200`, both scheduled |
unchanged |
| CONTROL: an enabled job and a DISABLED twin of its name | `200`, the
enabled one scheduled | unchanged |
The binder's own answers (log line, `409 RESOURCE_CONFLICT` error,
candidates, `refused` / `cancelled`) do not move;
`collectJobNameCollisions` answers exactly what it logs (runtime pin
below).
## Tests
- `packages/cloud-connection/src/marketplace-install-local-jobs.test.ts`
— new top-level describe `[#32572] install-local refuses a package with
two enabled jobs of one name, as the binder refuses it at bind` (the
file's existing harness: the real `@objectstack/runtime` dist binder):
the refusal (422, code, the quoted bind sentence, nothing registered /
persisted / scheduled / written), the upgrade (no cancel, installed job
keeps running, ledger keeps v1), the multi-package residual holder, one
answer naming the shared name beside a no-`body` job, and two CONTROLs
(distinct names; a disabled twin).
- `packages/runtime/src/app-artifact-handlers.job-pull.test.ts` — new
top-level describe `[#32572] collectJobNameCollisions answers the
refusals the binder refuses a shared job name by`: for three
arrangements (body + residual running as no declaring body; body +
residual running as that body; one package listing two names twice) the
export deep-equals the refusals the binder logs on a real
`CronJobAdapter`; CONTROLs (distinct names, a disabled twin) answer none
and the binder refuses none.
<details><summary>Red / green / ablation</summary>
| Run | Tree | cloud-connection jobs file |
|:--|:--|:--|
| red (FROM) | the three source files at `origin/main` `c04aa295`,
runtime rebuilt (dist has no `collectJobNameCollisions`), pins of this
PR | 4 failed / 19 passed — the four refusal pins (`expected 200 to be
422` ×3; the one-pass pin lacks the shared-name clause); both CONTROLs
green |
| green | `0fbfde90` (the fix; the merge `487a0f5b` brings two commits
touching neither package) | 23 / 23 |
| ablation | `node scripts/ablation-replace.mjs --file
packages/cloud-connection/src/marketplace-install-local-plugin.ts
--anchor 'collectShared(manifest, manifestId).map(({ name, message }) =>
({ name, message }))' --replacement '[] /* ABLATE_32572 */' -- …` |
anchor x1 → x0, marker x0 → x1; 4 failed / 19 passed (the same four),
CONTROLs green; restored: blob f91ccdc == HEAD, `git diff HEAD`
empty |
The cloud-connection file imports the plugin from source and the runtime
through its `exports` (built `dist/`), so the door-side ablation needs
no rebuild; the red leg rebuilt the runtime from `main`'s source, and
the green and ablation legs ran on a runtime dist rebuilt from HEAD
(`grep -c collectJobNameCollisions packages/runtime/dist/index.js` = 2).
</details>
<details><summary>Suites and typecheck</summary>
On `0fbfde90` (the merge to `487a0f5b` adds #32804 and #32824, which
touch `packages/rest` and `ui/` only, so per AGENTS.md §10 these were
not re-run):
- `pnpm --filter @objectstack/runtime test` :: exit 0 — 588 files, 10255
passed / 19 skipped
- `pnpm --filter @objectstack/cloud-connection test` :: exit 0 — 80
files, 1203 passed
- `pnpm --filter @objectstack/runtime typecheck` :: exit 0
(`NODE_OPTIONS=--max-old-space-size=8192`)
- `pnpm --filter @objectstack/cloud-connection typecheck` :: exit 0
- `pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2
src/app-artifact-handlers.job-pull.test.ts` :: exit 0 — 64 passed
</details>
## Verification
On `487a0f5b` (main `5c0f1134` merged once, before this PR; the final
head `ee4577cf` adds one text-only commit to the changeset, see the last
bullet):
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 70 derived; each run, exit code captured
before any pipe: **70 / 70 exit 0**. Three first answered exit 3 (a
prerequisite, not a verdict) and were re-run once it was met:
`check-plugin-teardown-shape.mjs --self-test` (its pinned fixture commit
fetched into the shallow clone; 48 cases pass), `pnpm
check:dual-build-cjs-loads` (the nine dists the dogfood closure does not
build, built; 123 entries / 72 packages load), `pnpm
check:type-check-debt` (re-run under the verify lock after the dogfood
battery released it; 0 entries above their record).
- `node scripts/pm/dispatch-gates.mjs --ran`: 70 derived, 70 run, 0
NOT-MEASURED, 0 UNRUN.
- `pnpm lint` :: exit 0.
- **Dogfood battery** (owed: `!` title and a `(narrowing)` arm): closure
`pnpm exec turbo run build --filter='@objectstack/dogfood^...'` rebuilt
on `487a0f5b`, then `pnpm --filter @objectstack/dogfood test` under
`os-verify-lock.sh`, no shard, no path: VERDICT command-exit 0 — Test
Files 456 passed / 3 skipped (459), Tests 3831 passed / 42 skipped
(3873).
- CI check-runs: cited by the seat at ACCEPT (this body was written at
create; r2 amends the S2 lines only).
- **r2, final head `ee4577cf`** (the changeset's text only, for the
red-line read's S2): per AGENTS.md §10 only the gates that read a
changeset were re-run, base `origin/main` = merge base `5c0f1134`, each
exit code captured before any pipe: `node
scripts/check-adr-0087-registration.mjs --base origin/main` :: exit 0
(read as `[BREAKING+bang+clause-②-narrowing] not-required
(no-migration-prescription)`); `node
scripts/check-adr-0087-registration.mjs --self-test` :: exit 0; `node
scripts/check-changeset-no-major.mjs --base origin/main` :: exit 0;
`node scripts/check-empty-changeset.mjs --base origin/main` :: exit 0;
`node scripts/check-empty-changeset.mjs --self-test` :: exit 0; `pnpm
check:changeset-gate-self-tests` :: exit 0. No main merge; code and pins
unchanged since `487a0f5b`, so the suites, the 70 gates and the dogfood
battery above stand.
## Acceptance notes
- File surface: the claim names `packages/cloud-connection/src/**`,
`packages/runtime/src/app-artifact-handlers.ts`, their tests and the
changeset. This diff also edits `packages/runtime/src/index.ts` (+3
lines: the export and its comment), the one way the door can reach the
shared judgement through `@objectstack/runtime`'s entry; no other file
outside the surface.
- `Clause-②` measured `yes (narrowing)` (claim expected `no
(narrowing)`): the new runtime export is the widening face. A `no` would
need the door to carry its own copy of the judgement, which the card
asks to avoid.
- Docs: `content/docs/automation/jobs.mdx` owes one sentence (see
`Skills-docs:`); left out of this diff because the claim's file surface
does not name it.
- Branch is the platform-assigned `claude/project-thread-5ff19y` (not
`claude/issue-32572-*`), from `origin/main` `c04aa295`; `origin/main`
`5c0f1134` merged once, before this PR (`487a0f5b`); later merges only
on a conflict, a main-caused red or a queue kick.
- r2 (epic red-line read 6839378150, HOLD on the contract review's S2,
text only): the changeset's Before bullet (now one bullet for scheduled
work off, the default, and one for on), its `Clause-②` line, its Now and
Who moves bullets and its ADR-0087 marker's reason, and this body's
matching lines (`Clause-②:`, `Metadata-protocol:`, 维护者速读, The defect,
Why a refusal, Not changed, and the single-package and upgrade rows of
FROM → TO) now state both deployments. `Clause-②` stays `yes
(narrowing)`. Code and pins are unchanged since `487a0f5b`; S1, F1 and
the nits ride #32913.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(spec untouched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [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 by [Claude
Code](https://claude.ai/code/session_01L6bhgTHn5TtkSoqxQzSJ34)_
<!-- signed: domain:server#7 · os-sales ·
session_01L6bhgVSjQBHNkZd6Eqx2XX -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 64b46fe commit ade13d3
6 files changed
Lines changed: 267 additions & 11 deletions
File tree
- .changeset
- packages
- cloud-connection/src
- runtime/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| 55 | + | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
| |||
505 | 510 | | |
506 | 511 | | |
507 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
0 commit comments