Skip to content

Commit cf78946

Browse files
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

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/docs/openapi-v2-billing.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"schema": {
4848
"description": "Workspace whose payer should be resolved. Workspace API keys are pinned to their own workspace.",
4949
"type": "string",
50-
"minLength": 1
50+
"minLength": 1,
51+
"maxLength": 128
5152
}
5253
}
5354
],
@@ -133,7 +134,8 @@
133134
"schema": {
134135
"description": "Restrict results to one workspace whose payer the caller can inspect.",
135136
"type": "string",
136-
"minLength": 1
137+
"minLength": 1,
138+
"maxLength": 128
137139
}
138140
},
139141
{

apps/docs/openapi-v2-files-audit.json

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"schema": {
5252
"type": "string",
5353
"minLength": 1,
54+
"maxLength": 128,
5455
"description": "Workspace whose files should be listed."
5556
}
5657
},
@@ -343,6 +344,7 @@
343344
"schema": {
344345
"type": "string",
345346
"minLength": 1,
347+
"maxLength": 128,
346348
"description": "Workspace that owns the upload session."
347349
}
348350
},
@@ -433,6 +435,7 @@
433435
"schema": {
434436
"type": "string",
435437
"minLength": 1,
438+
"maxLength": 128,
436439
"description": "Workspace that owns the upload session."
437440
}
438441
},
@@ -537,6 +540,7 @@
537540
"schema": {
538541
"type": "string",
539542
"minLength": 1,
543+
"maxLength": 128,
540544
"description": "Workspace that owns the upload session."
541545
}
542546
},
@@ -629,6 +633,7 @@
629633
"schema": {
630634
"type": "string",
631635
"minLength": 1,
636+
"maxLength": 128,
632637
"description": "Workspace that owns the file."
633638
}
634639
}
@@ -721,6 +726,7 @@
721726
"schema": {
722727
"type": "string",
723728
"minLength": 1,
729+
"maxLength": 128,
724730
"description": "Workspace that owns the file."
725731
}
726732
}
@@ -965,8 +971,21 @@
965971
"schema": {
966972
"type": "string",
967973
"minLength": 1,
974+
"maxLength": 128,
968975
"description": "Workspace that owns the file."
969976
}
977+
},
978+
{
979+
"name": "scope",
980+
"in": "query",
981+
"required": false,
982+
"description": "Which lifecycle set to read from: `active` (default) resolves live files only and returns `404` for a file a `DELETE` soft-deleted; `archived` also resolves soft-deleted files, so metadata stays readable before `POST /files/{fileId}/restore`. Authorization is identical for both.",
983+
"schema": {
984+
"default": "active",
985+
"description": "Which lifecycle set to read from: `active` (default) resolves live files only and returns `404` for a file a `DELETE` soft-deleted; `archived` also resolves soft-deleted files, so metadata stays readable before `POST /files/{fileId}/restore`. Authorization is identical for both.",
986+
"type": "string",
987+
"enum": ["active", "archived"]
988+
}
970989
}
971990
],
972991
"responses": {
@@ -1060,7 +1079,8 @@
10601079
"schema": {
10611080
"description": "Filter to actions in one workspace.",
10621081
"type": "string",
1063-
"minLength": 1
1082+
"minLength": 1,
1083+
"maxLength": 128
10641084
}
10651085
},
10661086
{
@@ -1361,6 +1381,7 @@
13611381
"schema": {
13621382
"type": "string",
13631383
"minLength": 1,
1384+
"maxLength": 128,
13641385
"description": "Workspace that owns the file."
13651386
}
13661387
}
@@ -1655,6 +1676,7 @@
16551676
"schema": {
16561677
"type": "string",
16571678
"minLength": 1,
1679+
"maxLength": 128,
16581680
"description": "Workspace whose folders should be listed."
16591681
}
16601682
},
@@ -1898,6 +1920,7 @@
18981920
"schema": {
18991921
"type": "string",
19001922
"minLength": 1,
1923+
"maxLength": 128,
19011924
"description": "Workspace containing the folder."
19021925
}
19031926
},
@@ -2437,6 +2460,7 @@
24372460
"workspaceId": {
24382461
"type": "string",
24392462
"minLength": 1,
2463+
"maxLength": 128,
24402464
"description": "Workspace in which to create the file."
24412465
},
24422466
"name": {
@@ -2651,6 +2675,7 @@
26512675
"workspaceId": {
26522676
"type": "string",
26532677
"minLength": 1,
2678+
"maxLength": 128,
26542679
"description": "Workspace in which the file will be registered."
26552680
},
26562681
"name": {
@@ -2822,6 +2847,7 @@
28222847
"workspaceId": {
28232848
"type": "string",
28242849
"minLength": 1,
2850+
"maxLength": 128,
28252851
"description": "Workspace that owns the file."
28262852
},
28272853
"name": {
@@ -2877,6 +2903,7 @@
28772903
"workspaceId": {
28782904
"type": "string",
28792905
"minLength": 1,
2906+
"maxLength": 128,
28802907
"description": "Workspace that owns the archived file."
28812908
}
28822909
},
@@ -3352,6 +3379,7 @@
33523379
"workspaceId": {
33533380
"type": "string",
33543381
"minLength": 1,
3382+
"maxLength": 128,
33553383
"description": "Workspace containing the files."
33563384
},
33573385
"fileIds": {
@@ -3446,6 +3474,7 @@
34463474
"workspaceId": {
34473475
"type": "string",
34483476
"minLength": 1,
3477+
"maxLength": 128,
34493478
"description": "Workspace that owns the file."
34503479
},
34513480
"isActive": {
@@ -3496,6 +3525,7 @@
34963525
"workspaceId": {
34973526
"type": "string",
34983527
"minLength": 1,
3528+
"maxLength": 128,
34993529
"description": "Workspace that owns the file."
35003530
},
35013531
"content": {
@@ -3572,6 +3602,7 @@
35723602
"workspaceId": {
35733603
"type": "string",
35743604
"minLength": 1,
3605+
"maxLength": 128,
35753606
"description": "Workspace containing the files."
35763607
},
35773608
"fileIds": {
@@ -3683,6 +3714,7 @@
36833714
"workspaceId": {
36843715
"type": "string",
36853716
"minLength": 1,
3717+
"maxLength": 128,
36863718
"description": "Workspace in which to create the folder."
36873719
},
36883720
"path": {
@@ -3701,6 +3733,7 @@
37013733
"workspaceId": {
37023734
"type": "string",
37033735
"minLength": 1,
3736+
"maxLength": 128,
37043737
"description": "Workspace containing the folder."
37053738
},
37063739
"path": {

apps/docs/openapi-v2-knowledge.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"schema": {
4848
"type": "string",
4949
"minLength": 1,
50+
"maxLength": 128,
5051
"description": "Workspace whose knowledge bases should be listed."
5152
}
5253
},
@@ -885,6 +886,7 @@
885886
"schema": {
886887
"type": "string",
887888
"minLength": 1,
889+
"maxLength": 128,
888890
"description": "Workspace that owns the knowledge base."
889891
}
890892
}
@@ -1077,6 +1079,7 @@
10771079
"schema": {
10781080
"type": "string",
10791081
"minLength": 1,
1082+
"maxLength": 128,
10801083
"description": "Workspace that owns the knowledge base."
10811084
}
10821085
},
@@ -1178,6 +1181,7 @@
11781181
"schema": {
11791182
"type": "string",
11801183
"minLength": 1,
1184+
"maxLength": 128,
11811185
"description": "Workspace that owns the knowledge base."
11821186
}
11831187
},
@@ -1293,6 +1297,7 @@
12931297
"schema": {
12941298
"type": "string",
12951299
"minLength": 1,
1300+
"maxLength": 128,
12961301
"description": "Workspace that owns the knowledge base."
12971302
}
12981303
},
@@ -1635,6 +1640,7 @@
16351640
"schema": {
16361641
"type": "string",
16371642
"minLength": 1,
1643+
"maxLength": 128,
16381644
"description": "Workspace whose folders should be listed."
16391645
}
16401646
},
@@ -1881,6 +1887,7 @@
18811887
"schema": {
18821888
"type": "string",
18831889
"minLength": 1,
1890+
"maxLength": 128,
18841891
"description": "Workspace containing the folder."
18851892
}
18861893
},
@@ -2469,6 +2476,7 @@
24692476
"workspaceId": {
24702477
"type": "string",
24712478
"minLength": 1,
2479+
"maxLength": 128,
24722480
"description": "Workspace in which to create the knowledge base."
24732481
},
24742482
"name": {
@@ -2509,6 +2517,7 @@
25092517
"workspaceId": {
25102518
"type": "string",
25112519
"minLength": 1,
2520+
"maxLength": 128,
25122521
"description": "Workspace that owns the knowledge base."
25132522
},
25142523
"name": {
@@ -2798,6 +2807,7 @@
27982807
"workspaceId": {
27992808
"type": "string",
28002809
"minLength": 1,
2810+
"maxLength": 128,
28012811
"description": "Workspace that owns the knowledge bases."
28022812
},
28032813
"knowledgeBaseIds": {
@@ -3116,6 +3126,7 @@
31163126
"workspaceId": {
31173127
"type": "string",
31183128
"minLength": 1,
3129+
"maxLength": 128,
31193130
"description": "Workspace that owns the knowledge base."
31203131
},
31213132
"operation": {
@@ -3467,6 +3478,7 @@
34673478
"workspaceId": {
34683479
"type": "string",
34693480
"minLength": 1,
3481+
"maxLength": 128,
34703482
"description": "Workspace that owns the knowledge base."
34713483
},
34723484
"name": {
@@ -3918,6 +3930,7 @@
39183930
"workspaceId": {
39193931
"type": "string",
39203932
"minLength": 1,
3933+
"maxLength": 128,
39213934
"description": "Workspace that owns the knowledge base."
39223935
},
39233936
"filename": {
@@ -4113,6 +4126,7 @@
41134126
"workspaceId": {
41144127
"type": "string",
41154128
"minLength": 1,
4129+
"maxLength": 128,
41164130
"description": "Workspace in which to create the folder."
41174131
},
41184132
"path": {
@@ -4131,6 +4145,7 @@
41314145
"workspaceId": {
41324146
"type": "string",
41334147
"minLength": 1,
4148+
"maxLength": 128,
41344149
"description": "Workspace containing the folder."
41354150
},
41364151
"path": {

apps/docs/openapi-v2-logs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"schema": {
4848
"type": "string",
4949
"minLength": 1,
50+
"maxLength": 128,
5051
"description": "Workspace whose execution logs should be returned."
5152
}
5253
},

0 commit comments

Comments
 (0)