Skip to content

feat(auth): 身份导入默认不设密码(passwordPolicy: 'none') - #2820

Merged
os-zhuang merged 1 commit into
mainfrom
claude/sys-user-bulk-import-passwords-iv68s9
Jul 11, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
claude/sys-user-bulk-import-passwords-iv68s9

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

设计讨论结论(#2766 后续):导入的职责是身份,不是凭据。验证码/魔法链接登录 + Console 已有的无密码检测(hasLocalPassword() → /set-password 引导,SSO 入职同款流程)意味着导入根本不需要生成密码。

变更

  • 新增 passwordPolicy: 'none' 并设为默认:建号时不传 password(better-auth 可选密码 → 无 credential 记录),零密码材料生成/返回/分发。用户经手机 OTP / 魔法链接 / 重置链接首登,Console 检测到无密码后引导 set-initial-password。
  • invite 不再生成丢弃式密码:改为同样无凭据建号 + 发送邀请。依据:better-auth 1.6.23 的 reset-password 对无凭据账号会自动创建 credential 记录(api/routes/password.mjs 已核实),语义完全等价且更干净。
  • temporary 不变:保留为"无邮件/短信基建部署"的显式兜底。
  • 行为变化说明:passwordPolicy 原为必填(缺失 400),现在缺失 = none。
  • 文档(authentication.mdx)与 changeset 同步更新。

测试

  • plugin-auth 全套 372 测试通过(新增 4 个 none 策略用例:createUser 请求体断言无 password 键、无强制改密打戳、无邀请发送、不依赖邮件/短信服务;原"缺失策略 400"用例改为"未知策略 400 + 缺省即 none")。
  • tsc --noEmit 干净;check-role-word 通过。

三种策略的最终定位

策略 定位 密码
none(默认) 有 OTP/魔法链接渠道的常规入职 无——用户首登后自设(Console 引导已存在)
invite 需要主动推送入职通知 无——邀请链接/短信 OTP 首登自设
temporary 无邮件/短信基建的兜底 服务端生成,一次性返回 + 强制改密

Ref #2766, #2782(向导适配器将把 none 作为默认选项)。

🤖 Generated with Claude Code

https://claude.ai/code/session_016r6eiJzivw1CkwTDSGho1o


Generated by Claude Code

…edentials at import time

Import provisions identity, not credentials. The new default 'none'
policy creates credential-less accounts (better-auth optional-password
create): no password material is generated, returned, or distributed.
Users first sign in through a channel (phone OTP / magic link / reset
link) and the Console's existing hasLocalPassword() → set-initial-password
flow nudges them to set one afterwards.

'invite' also stops minting a throwaway password — better-auth's
reset-password creates the credential record on first set (verified in
1.6.23 dist), so it is now 'none' + the invitation send. 'temporary' is
unchanged as the no-infrastructure fallback.

passwordPolicy was previously required (400 when omitted); omitted now
means 'none'.

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

vercel Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 11, 2026 2:55am

Request Review

@github-actions github-actions Bot added 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 size/m labels Jul 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-auth.

9 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/deployment/production-readiness.mdx (via @objectstack/plugin-auth)
  • content/docs/getting-started/cli.mdx (via @objectstack/plugin-auth)
  • content/docs/kernel/services-checklist.mdx (via @objectstack/plugin-auth)
  • content/docs/permissions/authentication.mdx (via @objectstack/plugin-auth)
  • content/docs/permissions/sso.mdx (via @objectstack/plugin-auth)
  • content/docs/plugins/index.mdx (via @objectstack/plugin-auth)
  • content/docs/plugins/packages.mdx (via @objectstack/plugin-auth)
  • content/docs/releases/implementation-status.mdx (via @objectstack/plugin-auth)
  • content/docs/releases/v9.mdx (via @objectstack/plugin-auth)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang
os-zhuang marked this pull request as ready for review July 11, 2026 03:01
@os-zhuang
os-zhuang merged commit 5bced2f into main Jul 11, 2026
15 checks passed
@os-zhuang
os-zhuang deleted the claude/sys-user-bulk-import-passwords-iv68s9 branch July 11, 2026 03:01
os-zhuang pushed a commit that referenced this pull request Jul 11, 2026
…Console wizard entry

The detailed Bulk Import section already documents the none/invite/temporary
policies, but the API-reference one-liner still said "invite or temporary"
(the pre-#2820 default) and nothing pointed at the Console import wizard
shipped in objectui (framework#2782). Adds none as the default to the
endpoint reference and a short paragraph on the Users-list Import flow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016r6eiJzivw1CkwTDSGho1o
os-zhuang added a commit that referenced this pull request Jul 11, 2026
The detailed Bulk Import section already documents the none/invite/temporary
policies, but the API-reference one-liner still said "invite or temporary"
(the pre-#2820 default) and nothing pointed at the Console import wizard
shipped in objectui (framework#2782). Adds none as the default to the
endpoint reference and a short paragraph on the Users-list Import flow.


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

Co-authored-by: Claude <noreply@anthropic.com>
os-zhuang pushed a commit that referenced this pull request Jul 27, 2026
… and correct download filename (#3504)

The approval inbox timeline showed a nameless "附件" chip that did nothing on
click, and even the downloaded file was named after the opaque URL token. Two
root causes, both in the framework:

approvals — `sys_approval_action.attachments` (a `Field.file`) stores rich
descriptors `{ id, name, url, mimeType, size }`, but `rowFromAction` mapped them
with `.map(String)`, collapsing each to "[object Object]". `ApprovalActionRow.
attachments` is now `ApprovalActionAttachment[]`; the descriptor carries name +
url, so consumers label/open attachments without reading the system `sys_file`.

storage — presigned downloads served `application/octet-stream` with no
`Content-Disposition`. `getSignedUrl`/`getPresignedDownload` now take
`PresignedDownloadOptions { filename, contentType, disposition }`; the REST
download routes pass the `sys_file` name+mime; the local adapter carries them in
the token and `_local/raw` emits an RFC 5987 Content-Disposition; S3 bakes the
same into the signed URL. Default `inline` preserves in-browser preview.

Verified end-to-end in app-showcase. Refs objectui #2820.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
os-zhuang pushed a commit that referenced this pull request Jul 27, 2026
…wnload filename (#3504) (#3505)

* fix(approvals+storage): surface decision attachments with name, open, and correct download filename (#3504)

The approval inbox timeline showed a nameless "附件" chip that did nothing on
click, and even the downloaded file was named after the opaque URL token. Two
root causes, both in the framework:

approvals — `sys_approval_action.attachments` (a `Field.file`) stores rich
descriptors `{ id, name, url, mimeType, size }`, but `rowFromAction` mapped them
with `.map(String)`, collapsing each to "[object Object]". `ApprovalActionRow.
attachments` is now `ApprovalActionAttachment[]`; the descriptor carries name +
url, so consumers label/open attachments without reading the system `sys_file`.

storage — presigned downloads served `application/octet-stream` with no
`Content-Disposition`. `getSignedUrl`/`getPresignedDownload` now take
`PresignedDownloadOptions { filename, contentType, disposition }`; the REST
download routes pass the `sys_file` name+mime; the local adapter carries them in
the token and `_local/raw` emits an RFC 5987 Content-Disposition; S3 bakes the
same into the signed URL. Default `inline` preserves in-browser preview.

Verified end-to-end in app-showcase. Refs objectui #2820.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore(spec): regenerate API surface snapshot for the two added interfaces

Additive only (0 breaking): ApprovalActionAttachment + PresignedDownloadOptions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(approvals): correct the attachment read-shape rationale and share the id rule

Follow-up on this PR's own change, after ADR-0104 D3 wave 2 landed on main.

The fix in this PR is right; its stated cause was inverted. It says the
`sys_approval_action.attachments` column "stores rich descriptors — a fileId is
resolved to a full descriptor on write". The code says otherwise:
approval-service.ts writes `input.attachments` verbatim (a fileId string[]),
and there is no write-side descriptor resolution anywhere in the repo. What
actually happens is that the column stores an opaque sys_file id — the stored
form of every media field — and the ObjectQL read path expands it into
`{ id, name, size, mimeType, url }` on the way out. That resolver was already
in this PR's base commit, so the descriptors observed in listActions came from
the read path, not from storage.

Left as written, that inverted account would have been a false statement about
storage sitting in the protocol contract, in the changeset, and in a regression
test comment — and PR-5a has since made the stored form explicitly an id, so it
would also have been contradicted by the schema. Corrected in all three places.

Also names the three read forms the normalizer actually handles, rather than
one: the expanded value (normal), a bare id (nothing to expand it into), and a
legacy inline blob written before the cutover, whose keys are snake_case
(`file_id`, `mime_type`). The last of those had no test; it has one now. The
id-token test reuses `isFileIdToken` from @objectstack/spec/data — the
platform's single arbiter of "opaque id or URL?" — so this normalizer and the
engine's read resolver cannot drift apart on that question, and a non-id string
is now surfaced as a url rather than mislabelled an id.

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

* docs(storage): record the presigned-download options in the hand-written contract docs

The drift check flagged these: both storage-service pages transcribe
IStorageService by hand, and this PR adds an optional PresignedDownloadOptions
argument to getSignedUrl / getPresignedDownload. Left alone they would describe
a signature the code no longer has — the same declared-vs-actual gap the rest of
this PR is about, one level up in the docs.

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

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…deliveries land when the triggering write runs in a unit of work (objectstack-ai#37742)

<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuT6upE7mQVRYxkhAeA5UjwM)_
Fixes objectstack-ai#37705

Clause-②: yes (widening) — `ObjectQL` is exported from the
`@objectstack/objectql` entry, and it gains two public methods,
`runOutsideOpenUnits(body)` and `runAfterOpenUnitsCommit(body)`;
`@objectstack/core` gains the root export
`wakeAfterOpenUnitsCommit(engine, wake)`; the
`@objectstack/service-automation` interface `SuspendedRunStoreEngine`
gains the matching optional member `runOutsideOpenUnits`, so an engine
that does not supply it still satisfies the interface. No existing
signature or accepted input narrows. `DispatchLoop`'s change is to the
async context its ticks run in, and the dispatchers' change is to when a
wake is sent, not to any API. The level stays `patch` because nothing a
metadata author can write changes (`Metadata-protocol: none`).
Metadata-protocol: none

## 维护者速读
- 用户能看到什么变化:记录变更触发的流程(例如 hotcrm
的线索分配)跑完后,运行历史和通知投递、活动记录不再丢失;运行历史会在保存返回后片刻落库,而不是和那次保存同时落库。
- 为什么做:hotcrm 移植到框架 19 被这个问题挡住,6 个线索分配测试失败;任何在保存时带钩子的对象上跑流程的应用都会丢运行历史。
- 出错会怎样:最坏是运行历史晚一点出现或重新丢失,业务数据本身不受影响;改动可直接回滚。
- 要你做什么:无。

## What changes

On 19.0.0-next.0 (and on `main` at `0f8e13b0`), a record-change flow
fired by a write whose object carries a metadata `before*` hook, or a
blocking `after*` hook that can abort, runs inside the unit of work the
write door opens for that write (`inAfterAbortUnit`). Two pieces of work
the run starts and does not await then took that unit's transaction
handle while it was still open, and ran their statements after it had
committed, so knex answered "Transaction query already complete":

1. **The terminal run-history write**
(`ObjectStoreSuspendedRunStore.recordTerminal`, fired and forgotten from
`run-history.ts`). Its first `find` on `sys_automation_run` failed, so
the run's history row never landed.
2. **The notification dispatcher's tick**, started by the `notify`
node's outbox wake (`DispatchLoop.wake()`) in the same async context.
Its delivery updates failed, and so did the `sys_activity` audit rows
they fire; the timer each tick sets inherited the same context, so later
ticks did too.

The fix, one mechanism per producer:

- `packages/objectql/src/engine.ts`: new public
`ObjectQL.runOutsideOpenUnits(body)`. It runs work its caller starts and
does not await outside every unit open at the call, through the same
`runOutsideOpenUnits` exit an `async: true` hook's run already takes
(`unit-detach.ts`): out of the ambient entry, with that entry's handle
recorded as detached.
- `packages/services/service-automation/src/suspended-run-store.ts`:
`recordTerminal` runs its whole write (the read, the insert or update,
the retention prune) through the engine's `runOutsideOpenUnits`.
`SuspendedRunStoreEngine` gains it as an optional member, so a double
without units keeps running the write where it is.
- `packages/core/src/dispatch-loop.ts`: `DispatchLoop` (the
notification, HTTP-delivery, database-queue and audit-seal loops) runs
every tick, its due-time read and the timer for the next tick in the
async context it was constructed in, never the context of the caller of
`start()`, `wake()` or `wakeAt()`. Its docblock now states that a loop
is constructed at boot, and names `DbQueueAdapter.start()` reached from
`subscribe()` under `autoStart` (review F-5).
- **The wake waits for the commit (review F-2, option a).** A tick woken
inside a unit now runs outside it, and on a pooled driver (Postgres,
MySQL) it cannot see the outbox or queue row the unit has not committed
yet, so that row would wait for a backed-off tick (up to
`maxIdleIntervalMs`, 30 s, under `soleWriter`). New public
`ObjectQL.runAfterOpenUnitsCommit(body)` (`unit-detach.ts`) runs `body`
outside the units once the ambient unit commits, never when it rolls
back, at once when no unit is open, on the same `UnitCommitQueue` the
write events' `async` runs wait on (objectstack-ai#33760).
`wakeAfterOpenUnitsCommit(engine, wake)` (new, `@objectstack/core`)
sends a wake through it, or at once on an engine without it. Wired at
the notification and HTTP outboxes' `onEnqueued`
(`messaging-service-plugin.ts`) and at the DB queue's due `publish` and
`replay` (`db-queue-adapter.ts`). A deferred `publish` keeps `wakeAt` (a
timer hint, no read now). A `ScopedContext` `beginTransaction` trio unit
holds the wake back while an engine call carrying its handle runs
(`publishTrioHandleFor` publishes the handle with the trio's queue); a
wake made outside such a call, by code that holds the trio handle only
explicitly, goes at once and on a pooled driver waits one backed-off
tick (review F-6, accepted). `engine.ts` stays within its line ceiling
(6856 of 6857): the `[DETACHED_HOOK_RUN]` docblock lost one line,
wording only.

Behaviour a reader can see: a run's history row is written beside the
run, not inside the triggering write's unit. It is not rolled back with
that write, and it can land a moment after the write has returned, as it
already could for any run outside a unit (the run-history write was
never awaited). A test that reads a run's history once, straight after
the write that fired it, has to wait for it to land instead.

Branch: `claude/project-thread-a7kaf6`, the name the harness assigned
this card thread, not `claude/issue-37705-*`.

## Tests

- `packages/objectql/src/engine-scoped-transaction-late-write.test.ts`,
new top-level describe `objectstack-ai#37705`: a driver that refuses a finished handle
as knex does, and holds a read until after the commit. CONTROL: a read
started bare inside `engine.transaction()` took the unit's handle and
fails with "Transaction query already complete". The same read through
`runOutsideOpenUnits` reaches the driver with no handle and answers. A
unit the detached body opens is its own.
-
`packages/services/service-automation/src/suspended-run-store.test.ts`,
new describe `objectstack-ai#37705`: every statement of the terminal write (find,
insert, update, the prune's delete) runs inside `runOutsideOpenUnits`;
an engine without it still gets the row.
- `packages/core/src/dispatch-loop.test.ts`, new describe `objectstack-ai#37705`: a
tick, its due-time read and the next timer tick see none of an
`AsyncLocalStorage` store the caller of `wake()`, `start()` or
`wakeAt()` was in. A second describe: `wakeAfterOpenUnitsCommit` hands
the wake to the engine's `runAfterOpenUnitsCommit`, and wakes at once
without it.
- `packages/objectql/src/engine-scoped-transaction-late-write.test.ts`,
second `objectstack-ai#37705` describe: inside a unit the signal runs after the commit
(`body done`, `commit`, `signal`); a read it starts reaches the driver
with no handle; a rolled-back unit sends none; with no unit it runs
before the call returns.
- `packages/services/service-queue/src/db-queue-idle-backoff.test.ts`,
new describe `objectstack-ai#37705`: under an engine that holds the signal as an open
unit does, a due `publish` runs no tick until the commit and then
delivers within the base interval; a `replay` hands its wake over too.
-
`packages/services/service-messaging/src/plugin-enqueue-wakes-dispatcher.test.ts`,
new describe `objectstack-ai#37705` on the composed plugin and a real engine: an
`emit()` inside `objectql.transaction()` hands its wake to
`runAfterOpenUnitsCommit` once, nothing is sent while the unit is open,
and the delivery goes out after the commit.

Reverse verification (fix committed first, then each source file put
back to its `main` body, `engine.ts` by making the method `return
body()`): the two `objectstack-ai#37705` cases in each of the three files go red (6 of
6), the control stays green, and restoring HEAD gives `git diff HEAD`
empty. Round 2 at 92c84c3, the same way: `runAfterOpenUnitsCommit`
running at once (2 red: commit order, rollback),
`wakeAfterOpenUnitsCommit` never deferring (1 red), the queue's two
wakes back to `this.wake()` (2 red), the notification outbox's
`onEnqueued` back to a bare wake (1 red); 6 of 6, `git diff HEAD` empty
after each.

<details><summary>Local runs (tree: objectstack-ai/objectstack, head
f94bcab; 62064b5 below)</summary>

- `pnpm --filter @objectstack/core test`: Tests 3797 passed (3797);
`typecheck` exit 0.
- `pnpm --filter @objectstack/objectql test`: Tests 14435 passed
(14435); `typecheck` exit 0.
- `pnpm --filter @objectstack/service-messaging test`: Tests 1108 passed
(1108); `typecheck` exit 0.
- `pnpm --filter @objectstack/service-queue test`: Tests 93 passed (93);
`typecheck` exit 0.
- `pnpm --filter @objectstack/service-automation test`: Tests 4322
passed (4322); `typecheck` exit 0.
- All under `os-verify-lock.sh` (VERDICT command-exit 0), after a `turbo
run build` of the five packages with declarations.
- `dispatch-gates.mjs --commands` at f94bcab derived 79 families;
`--ran` reconciles 79: 78 run, all exit 0
(`check:facade-delegation-only`, `check:query-options-erasure`,
`check:dts-closure` and `check:dual-build-cjs-loads` included), 1 NOT
MEASURED (exit 3, prerequisite not met in this shallow tree:
`check-plugin-teardown-shape --self-test`).
- `check-adr-0087-registration`, `check-changeset-no-major`,
`check-empty-changeset` green.
- At 62064b5 (docs and comment wording only: `webhooks.mdx`, the
`unit-detach.ts` docblock, the changeset): `dispatch-gates --commands`
derives 110 families, the 31 the docs page adds all run and exit 0,
`check:facade-delegation-only` and `check:query-options-erasure` re-ran
green, and `engine-scoped-transaction-late-write.test.ts` re-ran green.
- Full dogfood battery: not owed (no `!` in the title, no `(narrowing)`
arm). Round 1's sweep files were run at aed7894 (table above); round 2
changes when a wake is sent, not what the swept tests read.

</details>

## Read-after-write sweep (seat ask)

What moved: only a run's terminal history row in `sys_automation_run`,
and only for a run fired inside a unit. `listRuns`, `listRunsPage` and
`getRun` answer from the in-memory run log first (`run-history.ts`), so
an in-process read through them sees the run as soon as it finishes, as
before. Delivery rows (and the `sys_activity` rows their updates fire)
for a wake made inside a unit go out once the unit commits, through the
commit-time wake above, on every driver, except a wake made outside an
engine call that carries a trio handle (review F-6); before review F-2
this sentence held only on a single-connection pool. What can now miss
is a test that reads the durable row itself
(`ql.find('sys_automation_run')`, `/data/sys_automation_run`,
`loadTerminal`) once, straight after the write.

Checked against this branch's build (every file green, no edit needed):

| File | Reads | Verdict |
|---|---|---|
|
`packages/qa/dogfood/test/install-local-uninstall-flows-withdrawn.dogfood.test.ts`
| durable rows | already a bounded wait (`settledRunCounts`, 10 s) |
|
`packages/plugins/plugin-approvals/src/save-notice-approval-round-trip.integration.test.ts`
| durable terminal row | already a bounded wait (100 × 20 ms) |
|
`packages/qa/dogfood/test/flow-shipped-name-stored-row-boot.dogfood.test.ts`
| `listRuns` | already a bounded wait (50 × 100 ms) |
|
`packages/qa/dogfood/test/flow-trigger-record-credential-mask.dogfood.test.ts`,
`flow-durable-suspend.dogfood.test.ts` | durable `paused` rows | the
pause write is awaited, unchanged |
| `packages/qa/dogfood/test/flow-name-per-namespace.dogfood.test.ts`,
`automation-stored-reference-package-column.dogfood.test.ts` | rows the
test seeds itself; `getRun` | not a run's terminal write |
| `packages/qa/dogfood/test/flow-condition-scope-keys`,
`flow-door-elevated-start`, `seed-ownership-claim-dispatch`
(`.dogfood.test.ts`) | `listRuns` / resume door | in-memory log |
| `packages/verify/src/action-flow-elevated-door`,
`automation-trigger-elevated-door`, `handle.flows-system-start`,
`handle.public-form-door`, `handle.system-insert-delete`,
`handle.update-doors` (`.test.ts`) | `listRuns` | in-memory log |
|
`packages/plugins/plugin-approvals/src/batch-item-recall-resumes-batch.test.ts`
| `getRun` | in-memory log |
| `packages/runtime/src/domains/automation-run-detail-passthrough`,
`automation-screen-read-gate`, `automation-resume-caller-gate`,
`automation-run-read-permission-gate`,
`automation-write-capability-gate` (`.test.ts`) | stubbed engine | no
store |
|
`packages/plugins/organizations/src/elevated-organization-wall.postures.wall.test.ts`
| flow side effects | green |
| `examples/app-todo/test/task-completion-trigger.test.ts`,
`task-recurrence.test.ts`;
`examples/app-showcase/test/approver-bindings-specimen-unarmed.test.ts`
| `listRuns` | in-memory log |
| `packages/services/service-automation/**` | all | full package suite
green (4322) |

Runs: dogfood 51 + 26, verify 70, runtime 25, organizations 10,
plugin-approvals 3 + 10, example-todo 27, example-showcase 4, all
passed. Found by grepping `packages/` and `examples/` test files for
`sys_automation_run`, `listRuns`, `getRun`, `loadTerminal`, `/runs` and
`sys_activity` next to a record-change trigger.

**hotcrm** (not in this PR): in PR objectstack-ai#2820's
`test/flow-record-change.test.ts`, the three `case_escalation` cases at
lines 205, 263 and 787 read the durable row once and must switch to the
file's own `landedRuns` wait (details under Acceptance notes).

## Acceptance notes

- **hotcrm.** hotcrm PR objectstack-ai#2820's head `03a2647`, with every
`@objectstack/*` package except `console` swapped for this branch's
build: `test/flow-record-change.test.ts` answers 6 failed / 50 passed on
`main` (`0f8e13b0`, the same 6 as on `19.0.0-next.0`) and 0 "Transaction
query already complete" lines with the fix. Three `case_escalation`
cases (lines 205, 263 and 787 there) then read the run's history once,
straight after the write, and find nothing yet: on `main` the row was
written inside the triggering write's unit and was visible when the
write returned. With those three reads switched to the file's own
`landedRuns` (wait for the row), the file is 56 / 56. That three-line
change belongs to the hotcrm port, not to this PR.
- A framework end-to-end twin of the hotcrm run was not kept: a booted
fixture (record-after-create flow, `update_record`, a metadata `before*`
and blocking `after*` hook, `AuditPlugin`) did not reproduce the race on
SQLite, because nothing there held the history read between its handle
and its statement. The engine-level pin holds that step by construction
instead.
- Accepted deviations from review: F-1, the terminal history row
outlives a rolled-back triggering write. F-7, an outbox or queue table
on a datasource the open unit does not cover commits its row on its own
connection while the wake rides the unit's queue, so a rollback drops
that wake and the row goes out on the next backed-off tick (at most
`maxIdleIntervalMs`); no in-tree composition was measured that way.
- Docs: `content/docs/automation/webhooks.mdx` now says a delivery
`enqueueHttp()` or `redeliverHttp()` writes inside a transaction goes
out at its commit, and not at all on a rollback (review F-9).
- Same class elsewhere: any other work a run or a hook starts inside a
unit and does not await can take the unit's handle the same way. This PR
fixes the two producers the hotcrm run measured;
`ObjectQL.runOutsideOpenUnits` is the exit for the next one.

## Verification

Two-minute check: `pnpm --filter @objectstack/objectql exec vitest run
src/engine-scoped-transaction-late-write.test.ts -t 37705`, which shows
the control failing with "Transaction query already complete" and the
detached read answering.

Read first:
1. `packages/services/service-automation/src/suspended-run-store.ts`
`recordTerminal`: the write leaves the caller's units; it no longer
commits or rolls back with the triggering write.
2. `packages/core/src/dispatch-loop.ts` `loopTickAtHome` / `wakeAt`:
every loop's ticks now run in the context the loop was constructed in;
`wakeAfterOpenUnitsCommit` and the `unit-detach.ts`
`runAfterOpenUnitsCommit` it reaches: a wake made in a unit goes at its
commit.
3. `packages/objectql/src/engine.ts` `runOutsideOpenUnits`: the new
public engine member.

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

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

https://claude.ai/code/session_01L6bhgX3p4cHBBQ11Sjokrq

<!-- signed: repo:objectstack#2 · os-sales ·
session_01L6bhgX3p4cHBBQ11Sjokrq -->

---------

Co-authored-by: Claude <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — a94b1fd6 Deployed Jul 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m 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