tabc 0.2.5__tar.gz → 0.2.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. {tabc-0.2.5 → tabc-0.2.6}/CHANGELOG.md +20 -0
  2. {tabc-0.2.5 → tabc-0.2.6}/GUIDE.md +1 -1
  3. {tabc-0.2.5 → tabc-0.2.6}/MCP.md +2 -1
  4. {tabc-0.2.5/tabc.egg-info → tabc-0.2.6}/PKG-INFO +2 -1
  5. {tabc-0.2.5 → tabc-0.2.6}/PYPI.md +1 -0
  6. {tabc-0.2.5 → tabc-0.2.6}/pyproject.toml +1 -1
  7. {tabc-0.2.5 → tabc-0.2.6/tabc.egg-info}/PKG-INFO +2 -1
  8. {tabc-0.2.5 → tabc-0.2.6}/tabus/bus.py +35 -1
  9. {tabc-0.2.5 → tabc-0.2.6}/tabus/cli.py +13 -8
  10. {tabc-0.2.5 → tabc-0.2.6}/tabus/daemon.py +43 -3
  11. {tabc-0.2.5 → tabc-0.2.6}/LICENSE +0 -0
  12. {tabc-0.2.5 → tabc-0.2.6}/MANIFEST.in +0 -0
  13. {tabc-0.2.5 → tabc-0.2.6}/setup.cfg +0 -0
  14. {tabc-0.2.5 → tabc-0.2.6}/tabc.egg-info/SOURCES.txt +0 -0
  15. {tabc-0.2.5 → tabc-0.2.6}/tabc.egg-info/dependency_links.txt +0 -0
  16. {tabc-0.2.5 → tabc-0.2.6}/tabc.egg-info/entry_points.txt +0 -0
  17. {tabc-0.2.5 → tabc-0.2.6}/tabc.egg-info/requires.txt +0 -0
  18. {tabc-0.2.5 → tabc-0.2.6}/tabc.egg-info/top_level.txt +0 -0
  19. {tabc-0.2.5 → tabc-0.2.6}/tabus/__init__.py +0 -0
  20. {tabc-0.2.5 → tabc-0.2.6}/tabus/admin.py +0 -0
  21. {tabc-0.2.5 → tabc-0.2.6}/tabus/codex_queue.py +0 -0
  22. {tabc-0.2.5 → tabc-0.2.6}/tabus/compat_bcn.py +0 -0
  23. {tabc-0.2.5 → tabc-0.2.6}/tabus/compat_busd.py +0 -0
  24. {tabc-0.2.5 → tabc-0.2.6}/tabus/doorbell.py +0 -0
  25. {tabc-0.2.5 → tabc-0.2.6}/tabus/doorbell_poll.py +0 -0
  26. {tabc-0.2.5 → tabc-0.2.6}/tabus/lang.py +0 -0
  27. {tabc-0.2.5 → tabc-0.2.6}/tabus/locales/en.json +0 -0
  28. {tabc-0.2.5 → tabc-0.2.6}/tabus/mcp_server.py +0 -0
  29. {tabc-0.2.5 → tabc-0.2.6}/tabus/nodekey.py +0 -0
  30. {tabc-0.2.5 → tabc-0.2.6}/tabus/paths.py +0 -0
  31. {tabc-0.2.5 → tabc-0.2.6}/tabus/process_argv.py +0 -0
  32. {tabc-0.2.5 → tabc-0.2.6}/tabus/reply_link.py +0 -0
  33. {tabc-0.2.5 → tabc-0.2.6}/tabus/route_capture.py +0 -0
  34. {tabc-0.2.5 → tabc-0.2.6}/tabus/send_refusal.py +0 -0
  35. {tabc-0.2.5 → tabc-0.2.6}/tabus/sent.py +0 -0
  36. {tabc-0.2.5 → tabc-0.2.6}/tabus/tac_identity.py +0 -0
  37. {tabc-0.2.5 → tabc-0.2.6}/tabus/tac_lookup.py +0 -0
  38. {tabc-0.2.5 → tabc-0.2.6}/tabus/tac_migration.py +0 -0
  39. {tabc-0.2.5 → tabc-0.2.6}/tabus/tac_refusal.py +0 -0
  40. {tabc-0.2.5 → tabc-0.2.6}/tabus/tac_search.py +0 -0
  41. {tabc-0.2.5 → tabc-0.2.6}/tabus/tac_store.py +0 -0
  42. {tabc-0.2.5 → tabc-0.2.6}/tabus/terminal_frontend.py +0 -0
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.6 — 2026-11-22
4
+
5
+ ### Fixed
6
+
7
+ - `tabc open` on a message already marked READ or PROCESSED answered
8
+ `no such delivery`, which reads as a wrong id. It now shows the body again
9
+ and changes nothing (no state move, no row written), and prints
10
+ `(already read — state unchanged)`. A DEAD or QUARANTINED delivery, or a
11
+ body that no longer matches its hash, answers 409 with the state named.
12
+ An id that matches nothing still answers 404.
13
+ - `tabc read` skips a listed message that was marked read elsewhere before it
14
+ was opened, instead of printing it and reporting that the READ mark failed.
15
+ - Opening a message whose body fails its envelope check closed the
16
+ connection with no answer the first time, because the quarantined row was
17
+ read as a body. It now answers 409 with state `QUARANTINED` and the reason,
18
+ the first time and after. `tabc open` prints the reason and exits 1.
19
+ - A message another reader claimed in the same instant answers 409
20
+ `being opened by another reader — try again` instead of naming its state as
21
+ if it could not be opened.
22
+
3
23
  ## 0.2.5 — 2026-11-20
4
24
 
5
25
  ### Added
@@ -383,7 +383,7 @@ tabc send --sender alice --to bob --subject "hello" --body "first"
383
383
 
384
384
  # shell 2
385
385
  tabc dm --node bob # the subject appears, state unchanged
386
- tabc open --node bob --id <full-uuid> # body prints, state becomes INJECTED
386
+ tabc open --node bob --id <full-uuid> # body prints, state becomes INJECTED (an already READ or PROCESSED message prints, unchanged)
387
387
  tabc ack --node bob --id <full-uuid> --state READ
388
388
 
389
389
  # shell 1
@@ -94,7 +94,8 @@ the stored message; it does not confirm that the recipient has read it.
94
94
  On the receiving agent:
95
95
 
96
96
  1. Call `tabc_pull`. It claims new deliveries and returns bodies.
97
- 2. Call `tabc_open` with the full message UUID. It records `INJECTED`.
97
+ 2. Call `tabc_open` with the full message UUID. It records `INJECTED`. A message
98
+ already `READ` or `PROCESSED` is shown again and keeps its state.
98
99
  3. Call `tabc_ack` with state `READ` after reviewing the message.
99
100
  4. Record `PROCESSED` only after processing it. This records an outcome, not its correctness.
100
101
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tabc
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: A shared inbox for AI agents and programs on one machine
5
5
  License: MIT License
6
6
 
@@ -126,6 +126,7 @@ install; see the repository's guide before turning it on.
126
126
  - `tabc send --sender alice --to bob --subject "Hello" --body "Ready to collaborate."`: send a dm.
127
127
  - `tabc dm --node bob`: list unread messages.
128
128
  - `tabc read --node bob`: display messages and record them as read.
129
+ - `tabc open --node bob --id <id>`: open one message; one already read shows again, unchanged (0.2.6).
129
130
  - `tabc sent --node alice`: inspect outgoing delivery states.
130
131
  - `tabc tac search --node alice --query text`: search joined topics without changing read state.
131
132
  - `tabc send --sender bob --to alice --re <id> --subject "re" --body "ok"`: reply to a message (0.2.5).
@@ -80,6 +80,7 @@ install; see the repository's guide before turning it on.
80
80
  - `tabc send --sender alice --to bob --subject "Hello" --body "Ready to collaborate."`: send a dm.
81
81
  - `tabc dm --node bob`: list unread messages.
82
82
  - `tabc read --node bob`: display messages and record them as read.
83
+ - `tabc open --node bob --id <id>`: open one message; one already read shows again, unchanged (0.2.6).
83
84
  - `tabc sent --node alice`: inspect outgoing delivery states.
84
85
  - `tabc tac search --node alice --query text`: search joined topics without changing read state.
85
86
  - `tabc send --sender bob --to alice --re <id> --subject "re" --body "ok"`: reply to a message (0.2.5).
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tabc"
7
- version = "0.2.5"
7
+ version = "0.2.6"
8
8
  description = "A shared inbox for AI agents and programs on one machine"
9
9
  readme = "PYPI.md"
10
10
  requires-python = ">=3.9"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tabc
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: A shared inbox for AI agents and programs on one machine
5
5
  License: MIT License
6
6
 
@@ -126,6 +126,7 @@ install; see the repository's guide before turning it on.
126
126
  - `tabc send --sender alice --to bob --subject "Hello" --body "Ready to collaborate."`: send a dm.
127
127
  - `tabc dm --node bob`: list unread messages.
128
128
  - `tabc read --node bob`: display messages and record them as read.
129
+ - `tabc open --node bob --id <id>`: open one message; one already read shows again, unchanged (0.2.6).
129
130
  - `tabc sent --node alice`: inspect outgoing delivery states.
130
131
  - `tabc tac search --node alice --query text`: search joined topics without changing read state.
131
132
  - `tabc send --sender bob --to alice --re <id> --subject "re" --body "ok"`: reply to a message (0.2.5).
@@ -76,7 +76,7 @@ DB_PATH = os.environ.get(
76
76
  # drifted once already — 0.1.0.post1 shipped while this said 0.1.0. Bump
77
77
  # both together; tests/test_version_agreement.py fails the build otherwise.
78
78
  # Do not copy the number into documentation.
79
- __version__ = "0.2.5"
79
+ __version__ = "0.2.6"
80
80
  PROTOCOL_VERSION = "tabus.v1"
81
81
 
82
82
  # TTLs. Past these, a derived status counts as old.
@@ -1055,6 +1055,40 @@ def claim_new(con, node, limit=10, priority=None, lease_sec=None, claimed_by=Non
1055
1055
  return out, quarantined, lost_claim
1056
1056
 
1057
1057
 
1058
+ SETTLED_STATES = ("READ", "PROCESSED")
1059
+
1060
+
1061
+ def open_settled(con, node, message_id):
1062
+ """Show a message this node already marked READ or PROCESSED. Changes nothing.
1063
+
1064
+ `open` used to answer "no such delivery" for these, because reopen_unread
1065
+ selects unread states only. The id was right; the message was read. People
1066
+ took the answer to mean the id was wrong, and kept the output of `read` in
1067
+ files to see a body again.
1068
+
1069
+ Read only: no state moves, no row is written. The envelope was checked when
1070
+ the message was first opened, so this does not check it again; a body whose
1071
+ hash no longer matches is still refused, because showing a tampered body is
1072
+ worse than showing nothing.
1073
+
1074
+ Returns (row or None, state or None). state is the delivery's state whatever
1075
+ it is, so the caller can say why nothing was shown (DEAD, QUARANTINED).
1076
+ """
1077
+ row = con.execute(
1078
+ """SELECT d.state, m.id, m.sender_id, m.subject, m.body, m.body_hash
1079
+ FROM deliveries d JOIN messages m ON m.id = d.message_id
1080
+ WHERE d.recipient_id=? AND m.id=?""",
1081
+ (node, message_id),
1082
+ ).fetchone()
1083
+ if row is None:
1084
+ return None, None
1085
+ if row["state"] not in SETTLED_STATES:
1086
+ return None, row["state"]
1087
+ if hashlib.sha256(row["body"].encode()).hexdigest() != row["body_hash"]:
1088
+ return None, "TAMPERED"
1089
+ return dict(row), row["state"]
1090
+
1091
+
1058
1092
  def reopen_unread(
1059
1093
  con, node, message_id=None, limit=10, lease_sec=None, claimed_by=None
1060
1094
  ):
@@ -916,11 +916,10 @@ def fn_open(a):
916
916
  node=a.node,
917
917
  )
918
918
  if code != 200:
919
- print("failed:", r)
919
+ # 409 names the state (quarantined, DEAD, opened by another reader);
920
+ # 404 means the id matched nothing in this mailbox.
921
+ print("failed:", r.get("error") or r)
920
922
  sys.exit(1)
921
- if r.get("quarantined"):
922
- print(f"quarantined — the body was not opened ({r['quarantined']})")
923
- return
924
923
  print(
925
924
  f"\n{'='*60}\nid {r['id']}\nfrom {r.get('sender_id') or r.get('from')}"
926
925
  )
@@ -931,6 +930,10 @@ def fn_open(a):
931
930
  print("=" * 60)
932
931
  if r.get("state") == "INJECTED":
933
932
  print("(reopened — not marked read)")
933
+ if r.get("state") in ("READ", "PROCESSED"):
934
+ # Already read: shown again, state unchanged. Nothing to acknowledge.
935
+ print(f"(already {r['state'].lower()} — state unchanged)")
936
+ return
934
937
  # Record arrival: the body was opened, so this advances to INJECTED.
935
938
  # 🔴 Acknowledge with the full id the server resolved, not the prefix that was
936
939
  # typed. If another message sharing that prefix arrives in between, resolving
@@ -999,10 +1002,12 @@ def fn_read(a):
999
1002
  node=a.node,
1000
1003
  )
1001
1004
  if oc != 200:
1002
- print(f" ⚠ {mid[:18]}… could not open — left unread ({orr.get('error') or orr})")
1005
+ # A quarantined message answers 409 with its reason; it is not opened.
1006
+ print(f" ⚠ {mid[:18]}… could not open ({orr.get('error') or orr})")
1003
1007
  continue
1004
- if orr.get("quarantined"):
1005
- print(f" ⚠ {mid[:18]}… quarantined — body not opened, left unread ({orr['quarantined']})")
1008
+ if orr.get("state") in ("READ", "PROCESSED"):
1009
+ # Marked read elsewhere after the listing above. Already read: skip it.
1010
+ print(f" {mid[:18]}… already marked read elsewhere — skipped")
1006
1011
  continue
1007
1012
  opened_id = orr.get("id", mid)
1008
1013
  print(
@@ -1605,7 +1610,7 @@ COMMANDS = {
1605
1610
  ),
1606
1611
  "open": (
1607
1612
  fn_open,
1608
- "open one: shows the body and records arrival. State never moves backwards",
1613
+ "open one: shows the body and records arrival. A message already marked READ or PROCESSED is shown again and left as it is. State never moves backwards",
1609
1614
  [(("--node",), dict(required=True)), (("--id",), dict(required=True))],
1610
1615
  ),
1611
1616
  "ack": (
@@ -880,14 +880,54 @@ class BusHandler(BaseHTTPRequestHandler):
880
880
  # When it grew the third value this caller was not updated, and
881
881
  # dict(rows[0]) blew up here.
882
882
  out, quarantined, _lost = tabus.reopen_unread(con, node, full_id)
883
+ settled_state = None
884
+ if not out:
885
+ # 🔴 Already READ or PROCESSED: show it, change nothing. This used to
886
+ # answer "no such delivery", which reads as a wrong id.
887
+ settled, settled_state = tabus.open_settled(con, node, full_id)
888
+ if settled:
889
+ out = [settled]
883
890
  # The parent shown above a reply: its subject only when this node can
884
891
  # see the parent, its id alone otherwise.
885
892
  parent = reply_link.parent_of(con, node, full_id)
886
893
  con.close()
887
- for q in quarantined:
888
- pass # quarantined rows are not mixed into the response; the first
889
- # valid row is what goes out, keeping the existing contract
894
+ # 🔴 reopen_unread puts a row whose envelope failed into `out` itself,
895
+ # with "quarantined" set and no body (bus.py reopen_unread). Answer
896
+ # it before reading sender_id: reading it first raised KeyError and
897
+ # the connection closed with no answer.
898
+ if out and out[0].get("quarantined"):
899
+ q0 = out[0]
900
+ # An ACCEPTED row was just moved to QUARANTINED; any other keeps its state.
901
+ q_state = "QUARANTINED" if q0["state"] == "ACCEPTED" else q0["state"]
902
+ return self._json(
903
+ 409,
904
+ {
905
+ "error": f"message {full_id[:8]} is quarantined and cannot be opened ({q0['quarantined']})",
906
+ "state": q_state,
907
+ "quarantined": q0["quarantined"],
908
+ },
909
+ )
890
910
  if not out:
911
+ if settled_state in tabus.UNREAD_STATES:
912
+ # Still unread, yet reopen returned nothing: another reader claimed
913
+ # it between the select and the claim. Nothing is wrong with it.
914
+ return self._json(
915
+ 409,
916
+ {
917
+ "error": f"message {full_id[:8]} is being opened by another reader — try again",
918
+ "state": settled_state,
919
+ },
920
+ )
921
+ if settled_state:
922
+ # The id is right; the delivery is in a state that has no body to
923
+ # show (DEAD, QUARANTINED, a body that no longer matches its hash).
924
+ return self._json(
925
+ 409,
926
+ {
927
+ "error": f"message {full_id[:8]} is {settled_state} and cannot be opened",
928
+ "state": settled_state,
929
+ },
930
+ )
891
931
  return self._json(404, {"error": "no such delivery"})
892
932
  r0 = dict(out[0])
893
933
  return self._json(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes