Commit 1363084
* feat(spec,objectql): transaction contract gains `opts.require` fail-closed and an `owned` signal (#5696)
`IObjectQLEngine.transaction` declared two degradations as part of its meaning
(ADR-0119 D1): default-driver-only routing, and a silent fallback to "no
transaction, no rollback" on a driver without `beginTransaction`. #4619 made
both audible (PR #5724). This lands the first two of #5696's three tightenings,
each opt-in, with every existing caller's behaviour unchanged:
- `opts.require: true` throws `TransactionUnsupportedError` instead of
degrading — refused BEFORE the callback runs, so nothing is written when the
caller finds out. Generalizes `batchData`'s atomic gate (ADR-0119 D4).
- the callback's second argument carries `owned`: true when this call opened
the transaction, false when it JOINED an outer one (ADR-0067 D2) or ran on
the degrade path where there is no transaction to own.
Both are honoured on `ScopedContext.transaction` (`ctx.api.transaction`) too —
a second implementation of one primitive must not become a second dialect.
The contract TSDoc is corrected on a point measurement disproved: writes routed
off the transaction's datasource were NOT "written outside it", they were handed
the owner's transaction handle and executed on the wrong connection (#5351). The
TSDoc now states that, plus the two decided semantics landing next: business
writes refused across drivers, and system ledgers (`lifecycle.class` of
audit/telemetry/event) carved out to execute outside the transaction.
`@objectstack/core`'s `EngineWithTransaction` is typed FROM the contract rather
than transcribed from it — the hand-copy had already started to drift.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Q7oc7ASjh8yxyS3Yz78We
* chore(spec): regenerate api-surface after merging main (os-regen deferred artifact)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Q7oc7ASjh8yxyS3Yz78We
* fix(metadata-protocol): realign the SysMetadataEngine test doubles' transaction signature with the contract (#5696)
CI's `TypeScript Type Check` went red where a scoped `pnpm --filter …
typecheck` could not: @objectstack/metadata-protocol has no `typecheck`
script, so its errors are only ever seen by the DEBT ledger's `--re-measure`,
which reported 63 -> 70 (+7).
All seven were one shape. Six test doubles stand in for `SysMetadataEngine`,
whose `transaction?` member is typed FROM the contract
(`IObjectQLEngine['transaction']`), and each declared its callback as
`(ctx: any) => Promise<T>` — one parameter, from before the callback gained
its `info` argument. A double may be narrower than the producer; it may not
contradict it.
Each now declares `(ctx: any, info: { owned: boolean })` and passes
`{ owned: true }` at the call — the honest value, since every one of these
doubles OPENS the transaction it stands in for, which is exactly what
`ObjectQL.transaction` reports on its own open branch.
Re-measured: 63 raw errors, the frozen count, with zero transaction-related
errors remaining. `check-type-check-coverage --re-measure` reports no upward
drift. metadata-protocol: 49 files / 502 tests pass.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Q7oc7ASjh8yxyS3Yz78We
* test(objectql): type-clean the new transaction contract test under the TEST_DEBT re-measure (#5696)
objectql's test layer is excluded from its own `tsconfig.json`, so
`pnpm --filter @objectstack/objectql typecheck` never reads these files —
only the ledger's `--re-measure` does, by synthesizing a config with the test
globs unexcluded. The new file arrived with 7 errors nothing local reported.
Two shapes, both fixed rather than absorbed:
- `registry.registerObject(x as any)` — `packageId` is not optional (TS2554).
- `promise.catch((e) => e as E)` types the result `E | <resolved type>`, so
every property read on it is TS2339. Replaced by a `rejection<E>()` helper
that narrows to the rejection AND throws if the call did not reject at all —
which the bare `.catch()` would have let pass silently as a green test.
Re-measured: zero errors in this file.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Q7oc7ASjh8yxyS3Yz78We
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent bd19133 commit 1363084
15 files changed
Lines changed: 588 additions & 37 deletions
File tree
- .changeset
- packages
- core/src
- utils
- metadata-protocol/src
- objectql/src
- spec
- api-surface
- src/contracts
| 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 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
103 | 112 | | |
104 | | - | |
| 113 | + | |
105 | 114 | | |
106 | 115 | | |
107 | 116 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
| 169 | + | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
0 commit comments