You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6455104
Browse filesBrowse the repository at this point in the historyBrowse files
fix(service-automation): an install-local package keeps its flows registered after a restart, whatever the plugin order (#33095)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DPZVafoyPJiw5GSH3KRXGJh)_Fixes#33049
Clause-②: no
Metadata-protocol: none
## 维护者速读
1. 问题:通过 install-local 安装的包,重启后对象还在,但它的流程没注册到自动化引擎,触发返回
404,要等下一次随便装个包才恢复。
2. 原因:引擎只在自己的 `kernel:ready` 里做一次开机流程绑定;install-local 在它自己的
`kernel:ready` 里才恢复已装包。谁先跑取决于插件启动顺序。
3. 为什么只有 showcase 中招:连接器插件都声明依赖自动化插件,showcase 又把 install-local
排在连接器之后,于是自动化插件先启动、先绑定,恢复的包就漏了。空白应用和 app-todo 的 install-local 由 CLI
先挂载,所以不受影响。
4. 修复:引擎在 `kernel:bootstrapped`(所有 `kernel:ready`
跑完之后、封存流程归属之前)再读一次流程视图,视图有变化才补绑一次;没变化什么都不做。与 #28591 对连接器的做法一致。
5. 不是 18.3.0 回归:18.3.0 版本提交上四个条件全都已经存在(卡片评论 6850890576),因此按冻结规则本 PR
不进合并队列,除非 triage 改判为阻塞。
6. 验证:真实 `objectstack dev` 在文件库上重启 showcase,修复前触发 404、修复后 200 且
`registered`;新增 dogfood 重启 pin 和单元 pin,把修复拿掉两者都变红。
## What changes
- `packages/services/service-automation/src/plugin.ts`: a
`kernel:bootstrapped` pass (`bindFlowsRegisteredDuringBoot`) on the flow
sync queue. The `kernel:ready` bind (`syncFlowsFromProtocol`) now
records a fingerprint of the flow view it read (`flowViewFingerprint`:
every flow's whole definition, order-free). At `kernel:bootstrapped`,
which fires once every `kernel:ready` handler has settled whatever the
plugin order, the view is read again; when it differs, the same additive
bind runs over it (logged `Bound N flow(s) from the protocol at
kernel:bootstrapped`). An unchanged view binds nothing; a boot whose
`kernel:ready` bind read no view does nothing. The hook is registered
before the plugin's own seal/audit `kernel:bootstrapped` hook, so the
rebound flows are in place before `sealFlowHolders`, the node-type audit
and the trigger-binding audit. The #28591 comment that claimed "Its
flows already bind" is corrected.
- Changeset: `@objectstack/service-automation` patch.
Why there and not in the install-local rehydrate: the defect is the
engine's assumption that every package registered in a `kernel:ready`
handler is registered before its own; any plugin registering flows there
meets it. Announcing `metadata:reloaded` from the rehydrate would run
every reload consumer during the boot, which the install-local plugin
explicitly does not do at `kernel:ready`.
## Mechanism (measured on main c419609)
- Real restart: scratch copy of `examples/app-showcase`, `objectstack
dev --seed-admin --no-compile --no-watch` over a file DB with an
isolated `OS_HOME`, the card's manifest. Before the fix: install 200,
trigger 200, restart, trigger **404** `RESOURCE_NOT_FOUND`,
`registration.state: unregistered`, banner `33 flow(s)`. With the fix:
trigger 200, `registered`, banner `34 flow(s)`.
- Debug log of the failing boot: plugin start order `service-automation`
#17, the four connector plugins #18 to #21, `marketplace-install-local`
#23; `[Automation] Bound 33 flow(s) from the protocol at kernel:ready`
at 10:55:17.997Z, `[MarketplaceInstallLocal] rehydrated
com.qa.solo@1.0.0` at 10:55:18.372Z.
- The kernel's dependency sort starts a plugin's declared dependencies
first; all four connector plugins declare `dependencies =
['com.objectstack.service-automation']`.
## Tests
-
`packages/qa/dogfood/test/install-local-restart-connectors.dogfood.test.ts`:
a second top-level `describe` in the shared harness file. It mounts
`MarketplaceInstallLocalPlugin` inside the showcase's own `plugins`,
after the plugins that depend on the automation plugin, where the
showcase lists it. The existing describe passes it through
`extraPlugins`, which `bootStack` mounts before the app's plugins, so it
never met the CLI's order. Pins: the composition precondition, the
pre-restart install and trigger, the listing after the restart, the
trigger by name after the restart (200), and `registration.state:
registered` after the restart.
-
`packages/services/service-automation/src/flow-cold-boot-bind.test.ts`:
a new top-level `describe` on a `LiteKernel`: a plugin registered after
the automation plugin adds a packaged flow to the protocol's view in its
own `kernel:ready` handler; after `bootstrap()` the flow is registered,
beside the one the `kernel:ready` bind registered.
Ablation (both negative pins, fix reverted to origin/main in the tree
and `service-automation` rebuilt, then restored from HEAD):
- dogfood: `Tests 2 failed | 8 passed (10)`; `after the restart, the
package's flow triggers by name`: `expected 404 to be 200`
(`RESOURCE_NOT_FOUND`); `after the restart, the package's flow reads
registered`: `expected 'unregistered' to be 'registered'`. Restored:
`Tests 10 passed (10)`.
- unit: `Tests 1 failed | 5 passed (6)`, `registered after a later
kernel:ready handler added it: expected null not to be null`. Restored:
`Tests 6 passed (6)`.
## Acceptance notes
- Release check: not a regression vs 18.3.0 (card comment 6850890576).
18.4.0 merge freeze: this PR stays out of the merge queue unless triage
grades the card a blocker.
- Reach beyond the showcase: any host that wires its own
`MarketplaceInstallLocalPlugin` after a plugin that depends on the
automation plugin met the same loss. A host relying on the CLI-mounted
install-local did not.
- The dogfood pins boot in memory, not over a file DB: the loss is
decided by plugin order and the ledger directory (kept across the two
boots), not by the database. The file-DB restart was measured by hand on
the real CLI (above).
## Verification
Head `348024bd50` (origin/main `c4196099` merged before the PR opened;
main had not moved). The gates ran on `3093fdb91f`, whose tree is
byte-identical to the head's (the amend only removed a card trailer from
the commit message). Every exit captured before any pipe.
<details><summary>Package tests, typecheck and pins</summary>
- `pnpm --filter @objectstack/service-automation exec vitest run
--maxWorkers=2`: `Test Files 279 passed (279)`, `Tests 3830 passed
(3830)`.
- `pnpm --filter @objectstack/service-automation typecheck` (`tsc
--noEmit` + `check:test-typecheck`): exit 0, `0 file(s) / 0 error(s)`.
- `pnpm --filter @objectstack/dogfood exec vitest run --maxWorkers=2
test/install-local-restart-connectors.dogfood.test.ts`: `Tests 10 passed
(10)`.
- `src/flow-cold-boot-bind.test.ts`: `Tests 6 passed (6)`.
- Prerequisite: whole-tree `pnpm exec turbo run build --concurrency=2`
under the verify lock, exit 0 (`120 successful`).
</details>
<details><summary>Derived gates (`dispatch-gates.mjs --commands`, 74)
and lint</summary>
`node scripts/pm/dispatch-gates.mjs --ran gates-ran-348024bd50.txt`: `✓
dispatch-gates --ran: 74 derived famil(ies) accounted for — 74 run, 0
NOT-MEASURED (a DERIVED zero — all 74 recorded an exit code and none of
them is 3)`. `check:dual-build-cjs-loads` first answered exit 3 (11
packages without `dist/`) and was re-run after the whole-tree build:
exit 0. `pnpm lint` (`eslint . --no-inline-config`): exit 0, recorded
outside the derivation.
```text
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
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-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-adoption.mjs :: exit 0
node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-issue-citations.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0
node scripts/check-tenant-audit-census.mjs :: exit 0
node scripts/check-tenant-audit-census.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/docs-audit/check-affected-docs.mjs :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm --filter @objectstack/spec run check:empty-state :: exit 0
pnpm --filter @objectstack/spec run check:liveness :: exit 0
pnpm --filter @objectstack/spec run check:strictness-ledger :: exit 0
pnpm --filter @objectstack/spec run check:variant-docs :: exit 0
pnpm check:adr-symbol-anchors :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:cli-command-ids :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 0
pnpm check:durability-log-level :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:error-status-conformance :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:init-service-contract :: exit 0
pnpm check:issue-citations :: exit 0
pnpm check:keyed-text-bounds :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:logger-receiver-detach :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:object-def-param-keys :: exit 0
pnpm check:objectql-double-limit :: exit 0
pnpm check:optional-error-sink :: exit 0
pnpm check:org-identifier :: exit 0
pnpm check:package-naming :: exit 0
pnpm check:page-declaration-shape :: exit 0
pnpm check:platform-object-tenancy-census :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:settings-bind-window :: exit 0
pnpm check:slot-lookup :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:startup-registry-verdict :: exit 0
pnpm check:system-context-census :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:vouch-for-reference-callers :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
pnpm lint :: exit 0
```
</details>
<!-- signed: domain:server#6 · os-elon-musk ·
session_016WV4cwZuSHmXjzxcfEXUGA -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(service-automation): a package installed through install-local keeps its flows registered after a restart, whatever the plugin order
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
The engine bound a cold boot's flows once, in its own `kernel:ready` handler. The install-local rehydrate re-registers every installed package in its own `kernel:ready` handler, so the bind saw those packages only when the install-local plugin started first. A host that lists a plugin depending on the automation plugin (any connector plugin) before `MarketplaceInstallLocalPlugin` starts the automation plugin first: after a restart the package was listed and its objects served, but its flows answered 404 on the trigger door and read `registration.state: unregistered` until some later hot install re-synced the engine. The engine now reads the flow view again at `kernel:bootstrapped`, once every `kernel:ready` handler has settled and before the flow holders seal, and binds again when the view changed since the `kernel:ready` bind. A boot whose view did not change binds nothing more.
0 commit comments