Commit 5dd395d
fix(agent,cli,publisher,scripts): OT-RFC-38 LU-6 — address Codex PR #610 R2
Three follow-ups from the second Codex pass on commit 730e58a:
1. memory.ts:765 — host-catchup applied counter was conflating
envelope counts with triple counts. One SWM envelope can carry
many quads, so summing the boolean `applied` flag undercounted
recoveries whenever a publisher batched > 1 triple per share.
Threaded `appliedTriples` through SharedMemoryApplyOutcome
(`insertedTriples` from `quads.length` on the success path) →
`catchupSwmFromHost` → `catchupSwmFromConnectedHosts` →
`/api/shared-memory/catchup` + `/api/shared-memory/host-catchup`.
`appliedTotal` now reports triples (the user-facing unit);
`appliedEnvelopes` is exposed alongside for operators who want
the envelope count. `totalInsertedTriples` is rolled up from
the correct unit (verified end-to-end on the late-joiner devnet:
appliedTriples=5 vs appliedEnvelopes=1 for a 5-quad batch).
2. dkg-agent.ts:8497 — reconciler re-entry was returning before
`maybeMarkRegisteredForHostMode()` ran, so a core that
subscribed while a CG was unregistered stayed on the 6h/1MiB
pre-registration limits forever — even after the CG was later
registered on chain — and pruned ciphertext from registered CGs
much earlier than intended. Mirror the same fix R1 applied to
`enableSwmHostModeFor()` on the periodic reconcile path.
3. workspace-handler.ts trustedReplay — the R1 bypass of the two
transport identity checks had no focused coverage (only the
SwmHostModeStore was unit-tested). New test file
`workspace-handler-trusted-replay.test.ts` covers:
a. valid host replay applies (publisher ≠ fromPeerId, allowlist
only includes publisher, signature + CG binding all valid)
b. control: same wire bytes WITHOUT trustedReplay are rejected
(proves the bypass is the only thing letting (a) through)
c. tampered envelope signature still rejects under trustedReplay
(agent-gate verification runs first; bypass MUST NOT defeat
cryptographic identity)
d. encrypted payload bound to a different CG still rejects
(CG binding check runs before decryption)
e. missing decryptor state still rejects as retryable (agent-
gated analogue of "no sender-key state yet")
Bonus: tests assert `insertedTriples` is set on the apply
outcome from (a), locking in the R2-1 contract.
Devnet hardening: scripts/devnet-test-rfc38-late-joiner.sh now
calls `wait_for_peer_link` before SCENARIO B's curator write to
both other members. SCENARIO A→B transition was flaking with
"All multiaddr dials failed" when run from a cold-started devnet
because stale dial cache entries from A weren't expired before
B's 3-way sender-key handshake fan-out.
Verification:
- All 5 new trustedReplay tests pass
- All 21 agent-gate tests still pass
- 9 host-mode-store tests still pass (incl. R1's seqno recovery)
- Pre-existing strict-equality test in workspace.test.ts updated
to include the new `insertedTriples` field
- All 11 RFC-38 scenarios pass on a clean devnet
(lu5-pub, lu5-cur, lu7..lu10, e2e, xcg, mm, scale, lj)
- Late-joiner SCENARIO D explicitly observes the R2-1 fix in
hostCatchup.appliedTotal=5 (triples) vs appliedEnvelopes=1
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 730e58a commit 5dd395d
6 files changed
Lines changed: 425 additions & 7 deletions
File tree
- packages
- agent/src
- cli/src/daemon/routes
- publisher
- src
- test
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8494 | 8494 | | |
8495 | 8495 | | |
8496 | 8496 | | |
8497 | | - | |
| 8497 | + | |
| 8498 | + | |
| 8499 | + | |
| 8500 | + | |
| 8501 | + | |
| 8502 | + | |
| 8503 | + | |
| 8504 | + | |
| 8505 | + | |
| 8506 | + | |
| 8507 | + | |
8498 | 8508 | | |
8499 | 8509 | | |
8500 | 8510 | | |
| |||
8726 | 8736 | | |
8727 | 8737 | | |
8728 | 8738 | | |
| 8739 | + | |
| 8740 | + | |
| 8741 | + | |
| 8742 | + | |
| 8743 | + | |
| 8744 | + | |
| 8745 | + | |
| 8746 | + | |
8729 | 8747 | | |
| 8748 | + | |
| 8749 | + | |
| 8750 | + | |
| 8751 | + | |
| 8752 | + | |
8730 | 8753 | | |
8731 | 8754 | | |
8732 | 8755 | | |
| |||
8738 | 8761 | | |
8739 | 8762 | | |
8740 | 8763 | | |
| 8764 | + | |
8741 | 8765 | | |
8742 | 8766 | | |
8743 | 8767 | | |
| |||
8787 | 8811 | | |
8788 | 8812 | | |
8789 | 8813 | | |
| 8814 | + | |
| 8815 | + | |
| 8816 | + | |
| 8817 | + | |
8790 | 8818 | | |
8791 | 8819 | | |
8792 | 8820 | | |
| |||
8804 | 8832 | | |
8805 | 8833 | | |
8806 | 8834 | | |
8807 | | - | |
| 8835 | + | |
8808 | 8836 | | |
8809 | 8837 | | |
8810 | 8838 | | |
| |||
8823 | 8851 | | |
8824 | 8852 | | |
8825 | 8853 | | |
| 8854 | + | |
8826 | 8855 | | |
8827 | 8856 | | |
8828 | 8857 | | |
| |||
8845 | 8874 | | |
8846 | 8875 | | |
8847 | 8876 | | |
| 8877 | + | |
8848 | 8878 | | |
8849 | 8879 | | |
8850 | 8880 | | |
| |||
8861 | 8891 | | |
8862 | 8892 | | |
8863 | 8893 | | |
8864 | | - | |
| 8894 | + | |
8865 | 8895 | | |
8866 | 8896 | | |
8867 | 8897 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
750 | 750 | | |
751 | 751 | | |
752 | 752 | | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
753 | 756 | | |
754 | 757 | | |
755 | 758 | | |
| |||
762 | 765 | | |
763 | 766 | | |
764 | 767 | | |
765 | | - | |
766 | | - | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
767 | 779 | | |
768 | 780 | | |
769 | 781 | | |
770 | 782 | | |
| 783 | + | |
771 | 784 | | |
772 | 785 | | |
773 | 786 | | |
774 | 787 | | |
775 | 788 | | |
776 | 789 | | |
777 | 790 | | |
| 791 | + | |
778 | 792 | | |
779 | 793 | | |
780 | 794 | | |
| |||
830 | 844 | | |
831 | 845 | | |
832 | 846 | | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
833 | 850 | | |
| 851 | + | |
834 | 852 | | |
835 | | - | |
| 853 | + | |
836 | 854 | | |
837 | 855 | | |
838 | 856 | | |
| |||
868 | 886 | | |
869 | 887 | | |
870 | 888 | | |
871 | | - | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
872 | 895 | | |
873 | 896 | | |
874 | 897 | | |
875 | 898 | | |
876 | 899 | | |
| 900 | + | |
877 | 901 | | |
878 | 902 | | |
879 | 903 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
114 | 130 | | |
115 | 131 | | |
116 | 132 | | |
| |||
1020 | 1036 | | |
1021 | 1037 | | |
1022 | 1038 | | |
| 1039 | + | |
1023 | 1040 | | |
1024 | 1041 | | |
1025 | 1042 | | |
| |||
0 commit comments