Repository navigation
fix(local-send): confirm delivery only after the pre-send tail and gate ax-read - #50
Merged
Merged
Conversation
Characterization tests ahead of the clean-code pass on local_db and forward. local_db: open a production LocalDbReader over a synthetic SQLCipher replica and pin the exact output of every reader query (chat listings, group titles, message reads and search, author identities, memo room, schema, and each poll_after completeness state and error). forward: record what LinkForwarder hands the journal and reports per room for every send outcome (already delivered, fenced, failed, sent, partial with each miss-reason kind, collect failure, deadline). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r and logging modules These files drifted from rustfmt's output, so `cargo fmt --check` failed on them. Formatting only, no code changes, so later commits show only real edits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lay, collector and forwarder Each deletion has no remaining caller in src/, tests/ or desktop/ (grep, plus a probe build with these items made pub(crate) so dead_code would flag them). - local_db: title_from_extra and json_title_from_value were dead outside tests. Their only caller was an assertion that repeated the resolve_group_title assertion right above it. - relay: STEP_TIMEOUT_MS duplicated forward::STEP_TIMEOUT_MS and had no reader. MISS_RETRY_WINDOW_SECS was never read. Settlement::tally() and TelegramRelay::latency() had no callers (RelayTick already carries the latency snapshot). - collector: TempScope::is_deleted and AsideCollector::endpoint had no callers. TempScope's `deleted` flag mirrored `dir.is_none()`. The explicit HealthTimeout arm in try_aside matched the catch-all arm below it. - forward: deliver_to_room took `dropped_images`, which always equalled message.dropped_images. Dropping it also removes the too_many_arguments allow. - improve: both apply_generation callers passed "rolled_back", and promote() cloned `problem` but never used it again. - media: the two existing-directory downloads now share one parent check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The NTChatRoom projection was mapped by three identical closures (list_chats, list_all_chats, poll_after). The eight-column NTChatMessage projection was mapped by three more (read_message_by_log_id, read_messages, poll_after). Each projection now has one mapper: local_chat_from_row and local_message_from_row. read_message_by_log_id and read_messages also drop their hand-built `Vec<Box<dyn ToSql>>` parameter lists for rusqlite::params!. The SQL text is byte-identical. The reader characterization tests pin each query's output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o poll_completeness poll_after read the chat row, read the aggregate, read the page, validated it, classified completeness, and built the envelope, all in 164 lines. The classification depends only on five values, so it is now a pure function. poll_after keeps the snapshot, the validation, and the bounded-size checks. The poll characterization test pins every status (complete, partial, empty, gap, unknown). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
read_cached_user_id and read_cached_user_id_for_uuid resolved the real cache path themselves, so no test could reach them. Each now takes the cache path as a parameter. Its single call site passes local_db_identity_cache_path(), so runtime behavior is unchanged. The new test pins what each reader trusts: machine UUID, account hash, hash/id consistency, positive ids, schema version, malformed JSON, owner-only mode, and symlink rejection. The next commit merges the two readers against it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tform-UUID choice read_cached_user_id and read_cached_user_id_for_uuid repeated the same owner/mode/schema/UUID checks and differed only in the account-hash check. They are now one reader that takes an Option<&str> account hash. Their two call sites were mutually exclusive on that hash (known vs unknown), so they collapse into one, and the safety reasons from both comments are kept. Also: - platform_uuid(mode) replaces the two copies of the NoMutation-vs-Normal UUID branch. - KAKAO_DATABASE_DIR names the container path that find_database_path and check_access each spelled out. The identity-cache test from the previous commit passes unchanged against the merged reader. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
find_database_path resolved the real home directory, so nothing exercised its trust rules. find_database_path_in now takes the container directory. find_database_path passes home/KAKAO_DATABASE_DIR, so callers are unchanged. The test pins what the lookup accepts and rejects: a regular, owner-only- writable file inside the container is accepted. A missing name, a hex-named directory, a group- or world-writable file, a symlinked name, and a symlinked container are rejected, each with its current error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…database path When the by-name lookup failed, find_database_path enumerated the container and accepted only an entry whose name equals db_name. That entry's path is container_dir.join(db_name), the exact path the by-name lookup had just rejected, checked with the same is-file, under-root, owner, and mode predicate. So the scan could never return a different answer. What it did add was a directory enumeration on the database-missing path, the operation the fast-path comment says can stall on an unhealthy sandbox. The single lookup states its trust predicate once instead of once per cfg branch. The database-lookup test from the previous commit passes unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 167-line parser handled two unrelated shapes inside one match: the single-locator photo/emoticon attachment (types 2 and 14) and the parallel-array multi-photo attachment (type 27). Each arm is now its own function, single_image_source and multi_photo_sources, and the parser just dispatches on the Kakao still-image kind. The bodies move unchanged, with every error string kept. In the multi-photo loop, `direct.clone().or(key_url.clone())` cloned both locators for every item. It now records requires_credentials first and moves the locator. The existing strict parser tests cover each shape and every rejection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
deliver_to_room repeated the same seven-argument journal_event call in all five outcome branches. The calls differed only in the stage, status, result code, and delivered count, and those four values follow from the DeliveryResult. deliver_to_room now decides the result, and delivery_journal_record maps result to journal record in one table. The journal is written once. Side effects keep their order: ledger read, send, ledger mark, journal. The link-forward journal characterization test pins every outcome's stage, status, code, and image counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the imports The image ladder's unit tests sat between the ladder and the link forwarder, so readers crossed 265 lines of tests and a second import block to get from one production section to the next. The tests now follow the forwarder's own tests at the end of the file (same module name, same test paths), and the forwarder's imports join the top. A line-sorted diff of the file before and after differs by one blank line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
process_message copied clock, ledger, sender, ladder, and the screen-recording flag into locals and cloned the room list. No borrow needed that: the loop takes only shared borrows of self, and the one mutable use (latency.record) comes after it. The method now reads the fields directly. Also: - The Fenced and Failed send arms had identical bodies, so they are one arm. - The three settlement branches each carried Stage::Commit, so the stage is now stated once at the journal call. - `batch.drain(..).next()` is `batch.into_iter().next()`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oops - AsideCollector::collect maps the secret-store error with map_err(..)? instead of matching into Some and returning early, and passes Some(&session) to the transport. - TempScope::path uses TempDir::path directly. - Knobs::digest hashes to_json() instead of repeating its serialization. - SqliteImproveStore's rolled_back_digests, history, and holdout_ids collect their rows into Result rather than pushing in a loop. The first row error still short-circuits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…false
Comment-only change. A strip-comments-and-whitespace comparison against
the previous commit is identical for all eight files.
Deleted: section banners, task numbers ("task 7.1", "Task 13"), "used
to" / "previously" history, incident dates, docs that only repeat an item
or field name, and test comments that repeat the assertion. Kept, in
English and Korean: comments that carry an external constraint, a measured
quirk, or a safety reason (SQLCipher key order, the macOS consent-gate
stall, the HMAC allocation cost, SEF/AOSP parsing, CHECK-ceiling
upserts, the deadline-before-send order).
Corrected comments that described code that no longer works that way:
- mask_pii said addresses are masked first. Phone and account numbers are.
- mask_addresses and is_area_token mixed up the road and area rules.
- StepAttempt::PermissionMissing also covers an acquirer's PermissionDenied.
- The relay docs said only the missing images are retried. The whole
message is re-acquired and re-sent each tick.
- The improve docs claimed an is_local_only embedder check, a value-level
holdout split, a ">= 5" rollback threshold (the code uses "> 5"), and
manual RollbackOutcomes. None of these is true.
- The logging docs said SQLite cannot add a column with ALTER, and that
contains_url mirrors the context indexer.
- The collector docs said the deletion report reaches the History window
and that HTML extraction is "layered on in task 7.1".
- LocalMediaAttachment said it excludes sender identity. It carries
author_id.
Also adds the missing why on jpeg_dimensions' C4/C8/CC exclusions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- summarize took total.min(SHORT_BODY_THRESHOLD) inside the `total <= SHORT_BODY_THRESHOLD` branch, where it always equals total. - InMemoryKnobStore kept its snapshot in RwLock<Arc<..>> but never cloned the Arc out: current() copies the tuple under the read lock, and the RwLock alone makes the swap atomic for concurrent readers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`read_via_ax` opens a chat that is not already open by selecting its row and posting Return to the KakaoTalk process. That keystroke goes to whichever KakaoTalk window is key, so it can submit a draft in another chat. `ax-read` ran without any opt-in. It now needs the same `allow_ax_send` gate as `local-send` and `local-delete`. No script in the repo calls `ax-read`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…end tail The worker-bound send confirmed delivery from the first 8 rows after the scheduled source. In an active room the source is often more than 20 rows behind the tail by send time, so those 8 rows were backlog and the delivered reply read as accepted_unconfirmed. The same page could also hold a self row the account wrote before the send. When its text matched the reply, that older row was reported as this send's proof. The fence read before AX touches the composer already holds the newest conversational row id. Confirmation now polls strictly after that row with a full LOCAL_POLL_MAX_ROWS page. Pre-send rows can no longer stand in for the reply, and a burst of new room rows no longer hides it. The poll loop takes its page source as a closure, so tests drive it over an in-memory room built with the real poll_completeness. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Worker confirmation returned Rejected as soon as any self row after the pre-send tail did not match the reply, and the poll loop stopped there. If the account wrote something from another device just before the reply reached the database, the delivered reply read as accepted_unconfirmed. A self row with different text says nothing about this send, so it now leaves the result Pending. A second self row with the same text is still a duplicate and still rejects. The 3 s deadline still ends the wait, so a send whose row never appears stays unconfirmed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`live_index_text` joins the message with its type label and attachment fragments, then cut the result at LIVE_CONTEXT_MAX_FIELD_BYTES with `String::truncate`. Validation bounds only the message, so a long Korean message plus a fragment could put the cut inside a three-byte character and panic. The cut now lands on `floor_char_boundary`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
InMemoryKnobStore panicked on every later read or write once any writer had panicked while holding one of its locks. Both locks always hold a complete value. `apply` swaps the generation and knobs in one assignment whose right side is built first, and it only pushes and trims the history Vec. So a poisoned guard is still safe to use. The four `expect`s now recover the guard with `PoisonError::into_inner`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cli tests ran the real binary with the developer's HOME, so `cargo test` opened, and if missing created, ~/.config/openkakao/messages.db through `cache-stats`. `doctor` and `auth-status` also read the real config, credentials, and KakaoTalk container paths. Each invocation now gets its own temp HOME and drops inherited OPENKAKAO_* variables, so OPENKAKAO_CONFIG and the other path overrides cannot point a test at real files either. All 17 cli tests pass under a sandbox-exec profile that denies every read and write in the real HOME except this checkout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Some send-path defects could only be fixed after the module splits in the parent PR. The worst one: a worker send could take a message the owner typed before the send as proof that the reply was delivered.
What changed
local-sendconfirmation polls only rows newer than the pre-send tail, with a full page, and an unrelated self row no longer cancels it.ax-readrequiresallow_ax_send, because it can press Return in KakaoTalk.cli_testruns against an empty tempHOME. The Rust data and ingest modules get a clean-code pass (664 fewer production lines, SQL byte-identical).Scope
Blast Radius
ax-readhas no caller in the repo. The confirmation change can only make a delivered message read as confirmed sooner; it never accepts a row older than the send.Verification
cargo test1,148 passed, clippy clean, all with an emptyHOME; cli tests also pass under a sandbox that blocks the real home folder.🤖 Generated with Claude Code