Commit cf78946
authored
fix(v2): close seven correctness and honesty gaps found sweeping the API (#6702)
* fix(v2): close seven correctness and honesty gaps found sweeping the API
A ten-slice sweep of the live v2 surface turned up no regression from the
recent cancellation work, but did surface a set of pre-existing defects where
an endpoint either lost data, hid a failure, or reported something that was not
true. Each is fixed at the layer that owns the behavior.
Terminal execution logs. The two force-fail boundaries wrote `status: 'failed'`
without `ended_at` or `total_duration_ms`, so a force-failed run dropped out of
every duration-filtered log query — the same defect class already closed for
cancellation, still open on its sibling. The cancellation payload factory is
generalized to take the status; the cancellation call sites are untouched and
still emit a byte-identical row.
Custom tools. One malformed row failed the whole page, and because the list is
keyset-paginated that row made every page containing it permanently
unreachable. The projection now validates against the same contract schema the
route builder applies, repairing only what can be repaired without inventing
information — a stringified schema, and a missing `type` whose contract admits
exactly one value — and omitting with a warning what cannot. Both rows observed
in production are recovered rather than discarded.
Table filters. `eq`/`ne`/`in`/`nin` compiled a wrongly-typed operand into a
containment test that silently matched nothing, so a filter written against the
value the write path had stored returned an empty page instead of its rows. The
operand is now read through the same column-type registry the write used, and
rejected only where that registry refuses it. Range operators already behaved
this way; `null` and the cleared-cell sentinel still pass through untouched.
Error messages. A custom `error` on a string schema also replaced the wrong-type
wording, so supplying a number for a name reported that the name was missing.
Messages now distinguish an omitted field from a mistyped one, `topK` names its
own bounds, the knowledge search refine reports against a field rather than the
whole body, and a workspace id is bounded before it reaches a lookup.
Archived file metadata. A soft-deleted file was listed but unreadable, leaving
no way to check share state before restoring it. The read takes the same `scope`
selector the list already exposes; the default is unchanged, and the parameter
relaxes only the `deleted_at` predicate, never the authorization.
Cancellation reporting. Cancelling an already-terminal run reported a durable
write that never happened. The service now distinguishes the no-op and names the
state it observed, and both surfaces present one vocabulary instead of the
internal route deriving its own. No claim predicate or write changed.
Protocol. A 401 carries a challenge naming the header the API actually reads,
and a body that failed to parse is reported as an unsupported media type only
when the caller positively declared a non-JSON one — after the read has already
failed, so nothing that succeeds today can begin to fail.
* fix(v2): correct three regressions this branch introduced, and harden its tests
Adversarial review of the previous commit found that three of its "behavior
preserving" claims were wrong. Each is corrected here at the layer that owns it.
Table filters no longer coerce a `date` operand, and no longer throw. `date` is
the one column type whose registry `coerce` is not idempotent — it drops
sub-second precision — and the leaf that compiles a filter also builds the
unique-constraint and upsert-conflict probes, so re-reading an already-coerced
operand could stop it matching the row it was written from and admit a duplicate
inside the write transaction with no error. Throwing was the second mistake: the
v2 predicate grammar type-checks structure but not operand values, so a rejected
operand no longer failed at submission but inside the delete, update, dispatch
and cancel runners, where a filter that cannot compile means the cells it started
can no longer be cancelled. Coercion is now total — it rewrites what the registry
accepts and passes everything else through unchanged, exactly as before.
Reviving a force-failed run no longer inherits its terminal duration. Writing
`ended_at` and `total_duration_ms` on the force-fail boundary was correct in
isolation, but a partial resume flips that row back to `pending` and those
columns survived. The preserved value is meant to be the pause checkpoint — the
run's active time — and it had become wall clock measured at the failed resume,
which the checkpoint rule then faithfully carried into the next terminal write.
The revival clears them only for a row that was terminal, so an ordinary paused
row keeps the checkpoint it is supposed to keep.
Cancelling reports the terminal state it actually observed. Reclassification now
requires that nothing else went wrong, so a genuine paused-reconciliation failure
survives instead of being rewritten as an already-terminal no-op, and the claim's
own row count — not a snapshot read before it — decides whether this cancel
terminalized the run or lost a race to something else. The status the snapshot
needed rides along on the ownership query that already reads the row, rather than
the second read that query's own contract warns against.
A custom tool that cannot be projected now answers the same way everywhere: the
list omits it, and reading or patching it by id reports it as absent rather than
as a server fault. Analytics stops reporting a cancellation for a request that
cancelled nothing.
The tests around all of this were audited by mutating each fix and checking the
suite noticed. Where it did not, the assertion is stronger now: the absent
content-type branch is genuinely exercised rather than relying on a header the
client library supplies, the duration encoder is pinned to the column it must
measure from, execution ownership is pinned to both ids it must match, and the
archived-file concealment test proves it conceals the archived read specifically.
Two tests that asserted a paused branch they could not observe are gone; the
rendered-SQL test that can decide it already covers them.
* fix(execution): report a workflow-group cancellation as the write it performed
Cancelling a workflow-group run whose log had already been cancelled, but whose
cell sidecar still needed reconciliation, durably cancelled that sidecar and
then reported `already_cancelled` with `durablyRecorded: false` — because the
terminal-status shortcut answered from the entry snapshot alone and never asked
what this request had written. The analytics event, which now gates on that
field, stopped firing for a cancellation that really happened.
The outcome a cancel reports is the same question whichever path answers it, so
there is now one vocabulary for it rather than one the direct claim tracked and
one the group transition did not. Every group result maps to that outcome
through a total map, so a new group result cannot compile without deciding what
it wrote, and the reclassification leads with whether this request wrote at all.
A group transition that reports itself already cancelled is deliberately mapped
as unknown rather than as a no-op: it leaves the sidecar alone but still
terminalizes a log that was active, and the result does not say which happened.
That costs nothing today, because the only snapshot that would reclassify proves
the log was already terminal.
* fix(execution): have a workflow-group cancellation report the writes it made
Three review findings landed on the same reporting logic, each a different face
of one cause: the caller could not see what the group transaction had written, so
it inferred. It inferred from an entry snapshot, then from the returned kind, and
the remaining blind spot was the kind that covers two different transactions —
a repair that terminalizes an active log, and a genuine no-op — which left a
cancel that wrote nothing still claiming a durable write when it lost a race.
The transaction now reports both writes it can make, each read from that
statement's own returning row and recorded immediately before the throw that
already depended on it, so the report cannot drift from the write. The caller
derives its outcome from those rather than from the kind, and the kind is back to
naming the situation instead of standing in for the work.
The group path can now always answer whether it wrote. The only remaining
unknown is the direct claim when its update throws or is never attempted, which
genuinely has no row count to report.1 parent 237f973 commit cf78946
47 files changed
Lines changed: 2918 additions & 154 deletions
File tree
- apps
- docs
- sim
- app/api
- v2
- custom-tools
- [id]
- files/[fileId]/metadata
- lib
- workflows/[id]/runs/[runId]/cancel
- workflows/[id]/executions/[executionId]/cancel
- lib
- api
- contracts
- v2
- server/routes
- execution
- logs/execution
- table
- __tests__
- workflows/executor
- workspace-files/application
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
136 | | - | |
| 137 | + | |
| 138 | + | |
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
343 | 344 | | |
344 | 345 | | |
345 | 346 | | |
| 347 | + | |
346 | 348 | | |
347 | 349 | | |
348 | 350 | | |
| |||
433 | 435 | | |
434 | 436 | | |
435 | 437 | | |
| 438 | + | |
436 | 439 | | |
437 | 440 | | |
438 | 441 | | |
| |||
537 | 540 | | |
538 | 541 | | |
539 | 542 | | |
| 543 | + | |
540 | 544 | | |
541 | 545 | | |
542 | 546 | | |
| |||
629 | 633 | | |
630 | 634 | | |
631 | 635 | | |
| 636 | + | |
632 | 637 | | |
633 | 638 | | |
634 | 639 | | |
| |||
721 | 726 | | |
722 | 727 | | |
723 | 728 | | |
| 729 | + | |
724 | 730 | | |
725 | 731 | | |
726 | 732 | | |
| |||
965 | 971 | | |
966 | 972 | | |
967 | 973 | | |
| 974 | + | |
968 | 975 | | |
969 | 976 | | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
970 | 989 | | |
971 | 990 | | |
972 | 991 | | |
| |||
1060 | 1079 | | |
1061 | 1080 | | |
1062 | 1081 | | |
1063 | | - | |
| 1082 | + | |
| 1083 | + | |
1064 | 1084 | | |
1065 | 1085 | | |
1066 | 1086 | | |
| |||
1361 | 1381 | | |
1362 | 1382 | | |
1363 | 1383 | | |
| 1384 | + | |
1364 | 1385 | | |
1365 | 1386 | | |
1366 | 1387 | | |
| |||
1655 | 1676 | | |
1656 | 1677 | | |
1657 | 1678 | | |
| 1679 | + | |
1658 | 1680 | | |
1659 | 1681 | | |
1660 | 1682 | | |
| |||
1898 | 1920 | | |
1899 | 1921 | | |
1900 | 1922 | | |
| 1923 | + | |
1901 | 1924 | | |
1902 | 1925 | | |
1903 | 1926 | | |
| |||
2437 | 2460 | | |
2438 | 2461 | | |
2439 | 2462 | | |
| 2463 | + | |
2440 | 2464 | | |
2441 | 2465 | | |
2442 | 2466 | | |
| |||
2651 | 2675 | | |
2652 | 2676 | | |
2653 | 2677 | | |
| 2678 | + | |
2654 | 2679 | | |
2655 | 2680 | | |
2656 | 2681 | | |
| |||
2822 | 2847 | | |
2823 | 2848 | | |
2824 | 2849 | | |
| 2850 | + | |
2825 | 2851 | | |
2826 | 2852 | | |
2827 | 2853 | | |
| |||
2877 | 2903 | | |
2878 | 2904 | | |
2879 | 2905 | | |
| 2906 | + | |
2880 | 2907 | | |
2881 | 2908 | | |
2882 | 2909 | | |
| |||
3352 | 3379 | | |
3353 | 3380 | | |
3354 | 3381 | | |
| 3382 | + | |
3355 | 3383 | | |
3356 | 3384 | | |
3357 | 3385 | | |
| |||
3446 | 3474 | | |
3447 | 3475 | | |
3448 | 3476 | | |
| 3477 | + | |
3449 | 3478 | | |
3450 | 3479 | | |
3451 | 3480 | | |
| |||
3496 | 3525 | | |
3497 | 3526 | | |
3498 | 3527 | | |
| 3528 | + | |
3499 | 3529 | | |
3500 | 3530 | | |
3501 | 3531 | | |
| |||
3572 | 3602 | | |
3573 | 3603 | | |
3574 | 3604 | | |
| 3605 | + | |
3575 | 3606 | | |
3576 | 3607 | | |
3577 | 3608 | | |
| |||
3683 | 3714 | | |
3684 | 3715 | | |
3685 | 3716 | | |
| 3717 | + | |
3686 | 3718 | | |
3687 | 3719 | | |
3688 | 3720 | | |
| |||
3701 | 3733 | | |
3702 | 3734 | | |
3703 | 3735 | | |
| 3736 | + | |
3704 | 3737 | | |
3705 | 3738 | | |
3706 | 3739 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
885 | 886 | | |
886 | 887 | | |
887 | 888 | | |
| 889 | + | |
888 | 890 | | |
889 | 891 | | |
890 | 892 | | |
| |||
1077 | 1079 | | |
1078 | 1080 | | |
1079 | 1081 | | |
| 1082 | + | |
1080 | 1083 | | |
1081 | 1084 | | |
1082 | 1085 | | |
| |||
1178 | 1181 | | |
1179 | 1182 | | |
1180 | 1183 | | |
| 1184 | + | |
1181 | 1185 | | |
1182 | 1186 | | |
1183 | 1187 | | |
| |||
1293 | 1297 | | |
1294 | 1298 | | |
1295 | 1299 | | |
| 1300 | + | |
1296 | 1301 | | |
1297 | 1302 | | |
1298 | 1303 | | |
| |||
1635 | 1640 | | |
1636 | 1641 | | |
1637 | 1642 | | |
| 1643 | + | |
1638 | 1644 | | |
1639 | 1645 | | |
1640 | 1646 | | |
| |||
1881 | 1887 | | |
1882 | 1888 | | |
1883 | 1889 | | |
| 1890 | + | |
1884 | 1891 | | |
1885 | 1892 | | |
1886 | 1893 | | |
| |||
2469 | 2476 | | |
2470 | 2477 | | |
2471 | 2478 | | |
| 2479 | + | |
2472 | 2480 | | |
2473 | 2481 | | |
2474 | 2482 | | |
| |||
2509 | 2517 | | |
2510 | 2518 | | |
2511 | 2519 | | |
| 2520 | + | |
2512 | 2521 | | |
2513 | 2522 | | |
2514 | 2523 | | |
| |||
2798 | 2807 | | |
2799 | 2808 | | |
2800 | 2809 | | |
| 2810 | + | |
2801 | 2811 | | |
2802 | 2812 | | |
2803 | 2813 | | |
| |||
3116 | 3126 | | |
3117 | 3127 | | |
3118 | 3128 | | |
| 3129 | + | |
3119 | 3130 | | |
3120 | 3131 | | |
3121 | 3132 | | |
| |||
3467 | 3478 | | |
3468 | 3479 | | |
3469 | 3480 | | |
| 3481 | + | |
3470 | 3482 | | |
3471 | 3483 | | |
3472 | 3484 | | |
| |||
3918 | 3930 | | |
3919 | 3931 | | |
3920 | 3932 | | |
| 3933 | + | |
3921 | 3934 | | |
3922 | 3935 | | |
3923 | 3936 | | |
| |||
4113 | 4126 | | |
4114 | 4127 | | |
4115 | 4128 | | |
| 4129 | + | |
4116 | 4130 | | |
4117 | 4131 | | |
4118 | 4132 | | |
| |||
4131 | 4145 | | |
4132 | 4146 | | |
4133 | 4147 | | |
| 4148 | + | |
4134 | 4149 | | |
4135 | 4150 | | |
4136 | 4151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
0 commit comments