Repository navigation
Conversation
|
Thanks @johoja12, and thanks for coming back with a much smaller cut after #793. This PR claims each allowed Discord reply by its message ID before any attachment is downloaded or anything is typed, so a replayed message cannot type the same reply twice. The IDs go in a small 0600 store, with an in-memory fallback when the store fails. It meets the rule from the #793 review. I ran it with a corrupt file, a failed read ( There are two small things to fix and two nits.
None of these affects whether a reply is typed, so they don't need another round trip. You can push them here, or they can go in on top at merge time. The CI test job still has to finish green before this merges. |
|
Thanks @johoja12 for the quick follow-up. This PR claims each allowed Discord reply by its message ID in a small private store before anything is downloaded or typed, so a replayed gateway message can't type the same reply twice. The second commit covers the earlier review. Content that was read but is invalid now heals on the next write, a file that could not be read is still left alone, recovered rows go first so eviction drops the oldest IDs, and the new file has its There are two things to fix and two nits.
These are small, so they don't need another round trip. You can push them here, or they can go in on top at merge time. The merge waits for the CI test job, which was still running when I looked. |
|
Addressed the latest code and formatting feedback in
Validation: 138 tests passed across bridge, replay store, and Discord routes. Typecheck, lint, format, lockfile and all 49 frontend JS syntax checks passed. The remaining
These rules are already present in |
|
Added both requested |
|
Thanks @johoja12 for working through both rounds. This PR claims each allowed Discord reply by its message ID in a small private store before the rate-limit and exited-agent checks, any download or any typing. A replayed gateway message can no longer type the same reply twice, and when the store fails, the bridge falls back to memory and still types the reply. Both earlier reviews are covered. Invalid and oversized content heals, errno failures leave the file alone, recovered rows go first, and the claim now sits before the rate limit, with a test for a refused reply that gets replayed. There are three small things left:
it('never replaces a symlink or a folder at the metadata path, and still accepts replies', async () => {
const path = join(dir, 'discord-reply-dedupe.json');
const target = join(dir, 'target');
await writeFile(target, 'keep');
await symlink(target, path);
const warn = vi.fn(),
store = new DiscordReplyDedupe(dir, Date.now, warn);
expect(await store.claim(guild, channel, message)).toBe(true);
expect(await store.claim(guild, channel, message)).toBe(false);
expect(await store.claim(guild, channel, '444444444444444444')).toBe(true);
expect((await lstat(path)).isSymbolicLink()).toBe(true);
expect(await readFile(target, 'utf8')).toBe('keep');
expect(warn).toHaveBeenCalledTimes(1);
await rm(path);
await mkdir(path);
expect(await new DiscordReplyDedupe(dir, Date.now, warn).claim(guild, channel, message)).toBe(true);
expect((await lstat(path)).isDirectory()).toBe(true);
});
None of these change what the code does. You can push them here, or they can go in on top at merge time. |
Gateway message replays can type an allowed reply into its session more than once, including after a server restart. Claim the Discord message ID before downloading attachments or typing, using a bounded private ID/timestamp store and an in-memory fallback.
This replaces the journal approach reviewed in #793 with a much smaller change (199 added lines including tests/docs). Outbound notification behavior is unchanged: no payload fingerprints, uncertain-notice lockouts, nonce retries, or journal dependency for alerts. A metadata read/write error logs one content-free warning and accepts the reply through in-memory deduplication; later replies retry storage. Capacity evicts old records instead of refusing new input. No terminal input is automatically replayed. This is best-effort replay protection, not an exactly-once guarantee during a storage outage/restart.
Validation on current master e99b42c:
First independent slice of the split requested in #769. Full-mode channels, streaming, controls, activity, and files will follow separately after their prerequisites. Fork tracking: johoja12#258 and johoja12#218.
Maintainer review follow-up (2026-11-18): readable invalid/over-cap ID metadata now heals automatically; errno/unsafe-file failures remain memory-only and never overwrite the unread file. Recovery merges older disk entries before newer outage claims, and dirty outage claims are persisted when IO recovers. Warnings name the metadata file; the source now has its fileoverview tag, and architecture/store-list rules are updated. Added invalid JSON/shape, over-cap, EMFILE non-overwrite, restart and eviction-order regressions. The three targeted files pass 135 tests; typecheck and lint pass.
For the agent-guide additions that may be applied on top at merge time, the exact wording is:
discord-reply-dedupe.json(private 0600, bounded reply IDs and timestamps only).