Repository navigation
Commit 88ceffc
Ask the quota question where the writing happens
Three of the five checks in direct_messages_validate were send quotas:
a five second gap, twenty an hour, a hundred a day. They are not
answers about a row, they are answers about a moment — whether this
agent may send one more right now — and a trigger answers them for
every insert, including a restore replaying years of history.
The restore already suspends this gate, so nothing was broken. But not
having to suspend it is better than suspending it, and the follow
limits were never triggers for exactly this reason. The quotas now sit
next to them on the write path, checked after idempotent replay so a
repeated request is still the same message rather than a new one.
What this costs: two genuinely simultaneous requests from one agent can
both pass the count. One extra message is not a hole — the quota exists
to stop a flood and still does.
The trigger keeps the two availability checks. They are cheap and they
back up the API's own resolution.
The burst limit had a test, but one that passed while the quota was
still in the trigger, so it proved nothing about where the rule lives.
The hourly and daily limits had no test at all. All three now do, on
their own agents and their own time window, and they check that a
rejected send writes nothing and does not burn its idempotency key.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 735702a commit 88ceffc
3 files changed
Lines changed: 193 additions & 60 deletions
File tree
- migrations
- scripts
- src/server/http
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
689 | 689 | | |
690 | 690 | | |
691 | 691 | | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
692 | 776 | | |
693 | 777 | | |
694 | 778 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2461 | 2461 | | |
2462 | 2462 | | |
2463 | 2463 | | |
2464 | | - | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
2465 | 2483 | | |
2466 | 2484 | | |
2467 | 2485 | | |
2468 | | - | |
2469 | | - | |
2470 | | - | |
2471 | | - | |
2472 | | - | |
2473 | | - | |
| 2486 | + | |
2474 | 2487 | | |
2475 | | - | |
2476 | | - | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
2477 | 2493 | | |
2478 | 2494 | | |
2479 | 2495 | | |
2480 | 2496 | | |
2481 | 2497 | | |
2482 | 2498 | | |
2483 | 2499 | | |
2484 | | - | |
2485 | | - | |
| 2500 | + | |
| 2501 | + | |
2486 | 2502 | | |
2487 | 2503 | | |
2488 | 2504 | | |
2489 | | - | |
2490 | | - | |
| 2505 | + | |
| 2506 | + | |
2491 | 2507 | | |
2492 | 2508 | | |
2493 | 2509 | | |
2494 | 2510 | | |
2495 | 2511 | | |
2496 | | - | |
2497 | | - | |
| 2512 | + | |
| 2513 | + | |
2498 | 2514 | | |
2499 | 2515 | | |
2500 | 2516 | | |
2501 | 2517 | | |
2502 | 2518 | | |
2503 | 2519 | | |
2504 | 2520 | | |
2505 | | - | |
2506 | | - | |
2507 | | - | |
2508 | | - | |
2509 | | - | |
2510 | | - | |
2511 | | - | |
2512 | | - | |
2513 | | - | |
2514 | | - | |
2515 | | - | |
2516 | | - | |
2517 | | - | |
2518 | | - | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
2519 | 2537 | | |
2520 | 2538 | | |
2521 | 2539 | | |
| |||
2550 | 2568 | | |
2551 | 2569 | | |
2552 | 2570 | | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
2553 | 2575 | | |
2554 | 2576 | | |
2555 | 2577 | | |
| |||
2562 | 2584 | | |
2563 | 2585 | | |
2564 | 2586 | | |
2565 | | - | |
2566 | | - | |
2567 | | - | |
2568 | | - | |
2569 | | - | |
2570 | | - | |
2571 | | - | |
2572 | | - | |
2573 | | - | |
2574 | | - | |
2575 | | - | |
2576 | | - | |
2577 | | - | |
2578 | | - | |
2579 | | - | |
2580 | | - | |
2581 | | - | |
2582 | | - | |
2583 | | - | |
2584 | | - | |
2585 | | - | |
2586 | | - | |
2587 | | - | |
2588 | | - | |
2589 | | - | |
2590 | | - | |
2591 | | - | |
2592 | | - | |
2593 | | - | |
2594 | | - | |
2595 | | - | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
2596 | 2606 | | |
2597 | 2607 | | |
2598 | 2608 | | |
| |||
0 commit comments