Conversation
…fixtures - adr/implementation/inbox-thread-state.md: the sections, the two list views, the events, a transition table, the invariants, what is window-only, and three known violations. - store.test.ts: the existing fast-check op harness gains seen, Mark read, Undo, the agent's read, the set-aside note and the Send that skips; an independent ThreadStateModel predicts every outcome, thread, question state and row, and the invariants are checked after every step in both list views, with a replay from disk. Hand-written edges, and test.failing cases for the three violations it found. - fixtures/thread-state/v1: 15 hand-written and 24 generated traces (seeds 1001 to 1024) for the phone apps, regenerated and verified by the same test. No product code changes.
- The doc's Archived column: an archived thread refuses pick, Send, Mark read and Undo only while no agent wrote after the archive line; one that came back and returned takes them (Undo brings it back as it was). The cells are proved by new "Archived column" tests on a real store. - Seventh place, not eleventh; routing joins only the newest unnamed thread the session started, while it is open; invariant 7 called circular except decisions_waiting. - The model's look rule is now the intended one, written independently: the Inbox's notes are neither the person's reply nor a look. Where the store differs (violation A) the check allows it only on a thread with a note, only in the look fields, and only in one of six pinned shapes, each with its own test.failing case (the new question variant and the late Undo included). - Shared clock ticks in the generated runs exercise the sort tie-break; the run fails if no tie was met. - Fixtures: generated traces start with a root and keep their events as data (replayed, never resampled unless asked), so a fast-check upgrade changes nothing; every trace lists its known_violations, detected per step (hand traces declare theirs and are compared).
- The model derives every row under two look rules: today's (the store's: the Inbox's notes count as the person's reply and as a look) and the intended one. The store must match today's rule on every field after every step; the difference between the rules is violation A, recorded and classified, never allowed for in the store check. Forcing unseen to 0 on every thread with a note now turns the generated runs red. - Section and archived-list ties are counted apart; a new property archives every open thread in one clock tick so resolved_at ties, and reversing the archived tie-break turns it red. - asks>asks unseen- noted as covering two A cases.
1 task
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.
Documents the Inbox thread-state model, checks it against the real store with a model-based test, and adds trace fixtures the phone apps replay. No product code changes.
What is in it
adr/implementation/inbox-thread-state.md: the six sections and Archived, the two list views (the default list with archived threads in Quiet; the window's?archived=excludeview withGET /threads/archived), the events, a transition table (event by state), the invariants, the counts, what is window-only and never stored (folding, held order, the current visit's look boundary), and three known violations. Linked from CLAUDE.md's Inbox section in one line.packages/shared/inbox/store.test.ts: the existing fast-check op harness is extended (not a second harness).Opgains seen, Mark read, Undo, the agent's read, the set-aside note and the Send that skips;runreports each outcome and records decisions as the Send route does. A newThreadStateModelis an independent account of the rules: it predicts every op's outcome (written, nothing to do, a replayed key, or the refusal code), which thread each message lands in, every question's state, and each row's section, unseen count, read and came-back flags. After every step the store and the model must agree and every invariant must hold.packages/shared/inbox/fixtures/thread-state/v1/: 15 hand-written and 24 generated traces,index.jsonand a README (format, events, generator, seeds, how to regenerate).Invariants checked after every step
waitingCount(the sidebar) equals the rows in Stopped, Holding and Waiting, in both views and per project; the folders'unreadequals the rows in Stopped, Holding, Waiting and New; an archived row never counts;waitingDecisionCount(the Decisions count) matches the model.last_at, ties on the thread id; archived newest archived first.Note on 7: the sidebar's count is Stopped, Holding and Waiting only (
waitingCountinpackages/inbox/held.ts); New is bold (unread) but not in that count. The test pins the code as it is.Run time and seeds
bun test packages/shared/inbox/store.test.tsruns in about 4 to 9 s locally (the whole file, the existing properties included). Fixed seeds: 20261012 (300 generated sequences of 15 to 45 ops; about one step in four shares the previous step's clock time, solast_atties in the sections, and the run fails if none was met); 20261015 (every open thread archived in one clock tick, soresolved_atties in the archived list, 60 runs; reversing that tie-break turns it red), 20261013 (Mark read then Undo on every thread, 100 runs), 20261014 (Archive then Unarchive on every thread, 100 runs).How the phones consume the fixtures
Each trace is the event sequence and, after each step, the expected sections in both views, the archived list, the counts, and each thread's row and question states, plus
known_violations(the steps where the Inbox breaks a rule today, with what the rule wants). A phone kit feeds the events in order to its own list handling and compares after each step;index.jsonlists the files. The generated traces (seeds 1001 to 1024, each starting with a root) keep their events as data: the test replays them from the files and never resamples unlessPLANNOTATOR_INBOX_TRACES=resample, so a fast-check upgrade changes nothing.PLANNOTATOR_INBOX_TRACES=writeregenerates the expectations. A format change makesv2.Violations found (kept as
test.failing, product code untouched)test.failingcase and a plain test proving the case shows its shape today. Forcingunseento 0 on every thread with a note (the reviewer's mutation) turns the generated runs red. Includes: Mark read, news inside the Undo window, the note: Sent with nothing unseen instead of New (tracehand-04, step 4); Mark read, a new question, the note: Waiting but unseen 0; the late Undo: unseen 0 (tracehand-03, step 7).back_from_archive; the rule (and the toast) says it goes back to Archived. Tracehand-09, step 5.hand-14, step 5.The Archived column of the transition table is proved on a real store by the "Archived column" tests: an archived thread refuses pick, Send, Mark read and Undo only while no agent wrote after the archive line.
Checks run
bun run typecheck: pass. The test file also type-checks under a throwaway config with bun types (the package config excludes tests).bun test:store.test.ts(29 pass, about 4 s) andstore-mark-read,store-supersede,store-archived,list.test.ts,tests/never-touch-the-real-inbox.test.ts,tests/package-bunfig.test.ts(85 pass).gitleaks git . --config .gitleaks.toml --log-opts="<merge-base>..HEAD": no leaks. Semgrep was not run locally (not installed); the change has no request input, exec or digest for its rules to match.