Skip to content

Refactor: reading a thread returns a Transcript with its note - #23

Merged
Skeyelab merged 1 commit into
refactor/contacts-filefrom
refactor/transcript
Nov 13, 2026
Merged

Skeyelab merged 1 commit into
refactor/contacts-filefrom
refactor/transcript

Conversation

@Skeyelab

Copy link
Copy Markdown
Member

Stacked on #22.

Summary

-store.read_thread(chat, ...) -> list[Message]
-main: staleness_note(messages, store.updated()); reverse; json.dump / print
+store.read(chat, ..., now=None) -> Transcript(messages, note)
+Transcript.render(text=False, oldest_first=False) -> str
+main: print note to stderr; print transcript.render(...)

The staleness note now comes with the read, so a caller can't print a thread without saying it may be incomplete.

Evidence

  • test_a_transcript_carries_its_own_staleness_note: chat.db mtime is backdated, and .note reports it (red → green).
  • test_a_transcript_renders_as_json_or_text_newest_or_oldest_first (red → green). --text and --oldest-first had no tests before.
  • README library section updated. 133 passed.

Merge Danger

Door: two-way

Blast Radius: library callers. ChatStore.read_thread is gone; use .read(...).messages. CLI output is unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VCgWWsJbTMzsnA2WJkmsjC

ChatStore.read(chat, ...) -> Transcript(messages, note) replaces read_thread.
The staleness note is computed with the read, so no caller can print a thread
and forget to say it may be incomplete. Transcript.render(text, oldest_first)
owns JSON/text output; --text and --oldest-first were untested before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgWWsJbTMzsnA2WJkmsjC
@claude

claude Bot commented Nov 13, 2026

Copy link
Copy Markdown

Review summary (all four priority invariants checked):

  • Marker (blocker): see the inline comment on _resolve_marker_choice. A standing marker = false is honored from any contacts file, including one a program supplies via --contacts-file or $IMSG_AGENT_CONTACTS. That allows a silent unmarked send with no human involved. This contradicts the stated invariant.
  • Scoping: OK. Every query binds a chat identifier, and find_groups is scoped to one participant. --message-file can send any readable file to the target; this is worth a note in SKILL.md.
  • Read-only: OK. mode=ro is used, and updated() only uses file stat.
  • Privacy: no real numbers or emails found in tracked files, apart from the "Eric" nit (inline).
  • Typedstream: the length encoding (<0x81 literal, 0x81 uint16, 0x82 uint32) is correct, and bounds are checked.
  • Contacts lookup: the order is flag, then env, then XDG, then bundled, and matches the README. A missing --contacts-file silently yields no contacts while a missing env file errors. This is inconsistent but safe.
  • README install: the steps are consistent with pyproject.toml, and the editable install makes the 'beside the module' lookup work. I did not run them on macOS.

🤖 Generated with Claude Code

@claude

claude Bot commented Nov 13, 2026

Copy link
Copy Markdown

Correction: the inline comments I referenced did not post, because those lines are not in the diff. Details:

Blocker: imsgread.py _resolve_marker_choice (~line 1204). A configured marker = false answers for a program that passed no flag. The only guard is that --config refuses without a tty. Nothing stops a program from supplying its own config:

  • imsg-agent --send --contacts-file /tmp/x.toml --contact a --message-file m.txt, where the agent wrote /tmp/x.toml with a = { id = "...", marker = false }, sends unmarked with no flag and no human.
  • Setting $IMSG_AGENT_CONTACTS does the same.
  • Editing ~/.config/imsg-agent/contacts.toml directly does the same.

The README and SKILL.md say this is 'not editable by a program', but that is only a prose rule for everything except the --config command. Options:

  • Honor only a configured marker = true non-interactively, and require an explicit --no-robot for a non-interactive unmarked send.
  • Or honor never only from the default search path, not via --contacts-file or the env var.

Either way, add a test for non-interactive plus --contacts-file with marker=false, which should be refused.

Nit: README.md:149, SKILL.md:17 and the skill description. "text Eric" reads like a real contact nickname. Use the placeholder friend.

🤖 Generated with Claude Code

@Skeyelab
Skeyelab added this pull request to stack #25 November 13, 2026 17:08
@Skeyelab
Skeyelab merged commit 4d7d948 into main Nov 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant