Commit 76ac582
feat(objectql): accept execution context via trailing options arg on read methods (#1941)
The engine's read methods (find/findOne/count/aggregate) took execution context
INSIDE the query (`query.context`), while the write methods (insert/update) took
it in a trailing `options.context`. That split is a footgun: the same `{ context }`
object is correct as the 3rd arg to `insert` but was SILENTLY DROPPED as the 3rd
arg to `find` — a recurring class of bugs where an intended `isSystem` bypass just
vanished (e.g. control-plane reads coming back empty once org-scoping hooks were
added; same shape as the staging "all environments invisible" incident).
This is the AI-error root cause: the read API fought the universal convention
(and AI's instinct) of "context/options goes in the trailing argument", so people
and agents kept passing it there and losing it.
Fix: read methods now ALSO accept `options.context` (3rd arg), merged into the
effective context (options wins when both given). `query.context` stays fully
supported. One rule now spans reads and writes: execution context goes in the
trailing options argument. This additively fixes the existing dropped-context
call sites (plugin-security/auth/org-scoping, objectos auth-proxy, cloud
environment-crud, and several tests) with zero call-site edits.
Tests: +5 engine cases (options.context honored on find/findOne/count, legacy
query.context still works, options wins on conflict). objectql 621, plugin-security
87, plugin-auth 118, plugin-org-scoping 15 — all green.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 40a7f1e commit 76ac582
3 files changed
Lines changed: 99 additions & 8 deletions
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
248 | 295 | | |
249 | 296 | | |
250 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
138 | 166 | | |
139 | 167 | | |
140 | 168 | | |
| |||
1766 | 1794 | | |
1767 | 1795 | | |
1768 | 1796 | | |
1769 | | - | |
| 1797 | + | |
1770 | 1798 | | |
1771 | 1799 | | |
1772 | 1800 | | |
| |||
1818 | 1846 | | |
1819 | 1847 | | |
1820 | 1848 | | |
1821 | | - | |
| 1849 | + | |
1822 | 1850 | | |
1823 | 1851 | | |
1824 | 1852 | | |
| |||
1864 | 1892 | | |
1865 | 1893 | | |
1866 | 1894 | | |
1867 | | - | |
| 1895 | + | |
1868 | 1896 | | |
1869 | 1897 | | |
1870 | 1898 | | |
| |||
1896 | 1924 | | |
1897 | 1925 | | |
1898 | 1926 | | |
1899 | | - | |
| 1927 | + | |
1900 | 1928 | | |
1901 | 1929 | | |
1902 | 1930 | | |
| |||
2341 | 2369 | | |
2342 | 2370 | | |
2343 | 2371 | | |
2344 | | - | |
| 2372 | + | |
2345 | 2373 | | |
2346 | 2374 | | |
2347 | 2375 | | |
2348 | 2376 | | |
2349 | 2377 | | |
2350 | 2378 | | |
2351 | 2379 | | |
2352 | | - | |
| 2380 | + | |
2353 | 2381 | | |
2354 | 2382 | | |
2355 | 2383 | | |
| |||
2366 | 2394 | | |
2367 | 2395 | | |
2368 | 2396 | | |
2369 | | - | |
| 2397 | + | |
2370 | 2398 | | |
2371 | 2399 | | |
2372 | 2400 | | |
| |||
2375 | 2403 | | |
2376 | 2404 | | |
2377 | 2405 | | |
2378 | | - | |
| 2406 | + | |
2379 | 2407 | | |
2380 | 2408 | | |
2381 | 2409 | | |
| |||
0 commit comments