Change feed follow-ups from the #54 reviews: lock-wait docs, ack test gaps and notes #68

Open
opened 2026-11-15 04:41:18 +00:00 by svc-agent-writer · 2 comments

The correctness review and the security review of PR #67 (head 2efd6b6) found no blocker. Every mutation named in the spec table fails its test in under 8 s. The findings below are in the code at the edges of the new checks, in two documents and in the tests. They land here so that #54 closes with slice A.

Should fix first

  1. Moved to #69 (the salt and every secret pair compared in normalised form; split out at triage).
  2. README.md:24 and SECURITY.md:89 say a lock wait on the store "ends after 5 seconds". The ack's positions transaction now gives up after 1 s (POSITIONS_BUSY_TIMEOUT). Only the docstrings changed. An ack also runs two transactions now, and each has its own 10 s CALL_SECONDS deadline, so the "a tool call that reads for more than 10 seconds stops" sentence needs a qualifier for the ack.

Test gaps (mutations that survived)

  1. No test pins the re-check inside the write transaction (views.ack, views.py:413-416). With last_seq=10**18, or with parse_cursor in place of decode_cursor, every test passes, because the reader pre-check hides both. This re-check is the guard against a Rebuild or a prune between the reader check and acking. Fix: a test that makes views.ack_reply return None and asserts that cursor-ahead and cursor-expired are still refused and that no position is written.
  2. Each half of the ROLLBACK guard in store.transaction survives on its own. The test covers the case where in_transaction is false; the except sqlcipher.Error: pass branch never runs. Add a case where ROLLBACK itself fails while a transaction is open, and assert the first error is the one raised.
  3. The bound in test_an_ack_waits_at_most_a_short_time_for_the_lock is 3 s, so a busy timeout up to about 2.5 s passes. Tighten the bound, or assert the pragma value on the positions connection.

Notes

  • The Tokens backstop wrapper in startup.start cannot be reached (startup.py:141-149). first_equal already refuses every pair that Tokens.__post_init__ checks, and a mutation of its location list survived. Delete it, or keep it and say why.
  • A failed ROLLBACK is now silent. If one fails while a transaction is still open, the long-lived sync writer stays inside it, and the nested-join rule absorbs later writes without a commit. The old code left the connection in the same state; the swallow now hides it. Consider closing the connection in that case.
  • "The api … compares tokens with the store key only" (README.md:401, SECURITY.md:66) can read as if the api did not compare tokens with each other. It does. Reword.
  • The api does not compare a Consumer token with the Feeder token, because it never reads the Feeder token. Only check catches that pair. The documents say so.
  • An ack can take about 2 × CALL_SECONDS plus 1 s in the worst case (two connections, each with its own deadline).
  • make check on macOS runs test_real_time_machine_exclusion (tests/test_host.py:357). It adds a real Time Machine exclusion to a throwaway directory under $HOME. The ACL tests run chmod +a, and one test makes a directory under $HOME. A review lane that must not change host settings has to deselect these 11 tests. Consider an opt-in variable for the tests that change host state.

Human act

ruling: the operator rules on the ROLLBACK and Tokens backstop notes and approves dispatch with svd:go (CONV-40)

Blocked by

  • #65 (writes startup.py and store.py, as the ROLLBACK and backstop notes do)

Filed under: operator word "I grant authority to merge T4 through 21:00 aedt" sha256:cec4dd4fecbd

The correctness review and the security review of PR #67 (head `2efd6b6`) found no blocker. Every mutation named in the spec table fails its test in under 8 s. The findings below are in the code at the edges of the new checks, in two documents and in the tests. They land here so that #54 closes with slice A. ## Should fix first 1. **Moved to #69** (the salt and every secret pair compared in normalised form; split out at triage). 2. **`README.md:24` and `SECURITY.md:89` say a lock wait on the store "ends after 5 seconds".** The ack's positions transaction now gives up after 1 s (`POSITIONS_BUSY_TIMEOUT`). Only the docstrings changed. An ack also runs two transactions now, and each has its own 10 s `CALL_SECONDS` deadline, so the "a tool call that reads for more than 10 seconds stops" sentence needs a qualifier for the ack. ## Test gaps (mutations that survived) 3. **No test pins the re-check inside the write transaction** (`views.ack`, `views.py:413-416`). With `last_seq=10**18`, or with `parse_cursor` in place of `decode_cursor`, every test passes, because the reader pre-check hides both. This re-check is the guard against a Rebuild or a prune between the reader check and `acking`. Fix: a test that makes `views.ack_reply` return `None` and asserts that `cursor-ahead` and `cursor-expired` are still refused and that no position is written. 4. **Each half of the ROLLBACK guard in `store.transaction` survives on its own.** The test covers the case where `in_transaction` is false; the `except sqlcipher.Error: pass` branch never runs. Add a case where `ROLLBACK` itself fails while a transaction is open, and assert the first error is the one raised. 5. **The bound in `test_an_ack_waits_at_most_a_short_time_for_the_lock` is 3 s**, so a busy timeout up to about 2.5 s passes. Tighten the bound, or assert the pragma value on the positions connection. ## Notes - **The `Tokens` backstop wrapper in `startup.start` cannot be reached** (`startup.py:141-149`). `first_equal` already refuses every pair that `Tokens.__post_init__` checks, and a mutation of its location list survived. Delete it, or keep it and say why. - **A failed ROLLBACK is now silent.** If one fails while a transaction is still open, the long-lived `sync` writer stays inside it, and the nested-join rule absorbs later writes without a commit. The old code left the connection in the same state; the swallow now hides it. Consider closing the connection in that case. - **"The api … compares tokens with the store key only"** (`README.md:401`, `SECURITY.md:66`) can read as if the api did not compare tokens with each other. It does. Reword. - **The api does not compare a Consumer token with the Feeder token**, because it never reads the Feeder token. Only `check` catches that pair. The documents say so. - **An ack can take about 2 × `CALL_SECONDS` plus 1 s** in the worst case (two connections, each with its own deadline). - **`make check` on macOS runs `test_real_time_machine_exclusion`** (`tests/test_host.py:357`). It adds a real Time Machine exclusion to a throwaway directory under `$HOME`. The ACL tests run `chmod +a`, and one test makes a directory under `$HOME`. A review lane that must not change host settings has to deselect these 11 tests. Consider an opt-in variable for the tests that change host state. ## Human act ruling: the operator rules on the ROLLBACK and `Tokens` backstop notes and approves dispatch with `svd:go` (CONV-40) ## Blocked by - #65 (writes `startup.py` and `store.py`, as the ROLLBACK and backstop notes do) --- Filed under: operator word "I grant authority to merge T4 through 21:00 aedt" sha256:cec4dd4fecbd
Author
Member

This was generated by AI during triage.

Triage Notes

Checked against main at 99a849c.

Item 1 (salt vs normalised key): confirmed.

  • read_key_file (src/messages_mind_mcp/store.py:136-143) strips whitespace and folds hex to lowercase. read_secret_file (src/messages_mind_mcp/kit/secrets.py:18-42) returns raw bytes and removes one trailing newline only.

  • startup.py:127-136 appends the salt in raw form. The strip().lower() loop covers the held tokens only.

  • A reproduction with synthetic files and the shipped read_key_file, read_secret_file and first_equal:

    Salt file content Refused
    the key, exact yes
    the key in upper case no
    the key with a leading space no
    the key and two newlines no
  • The intended behaviour is already decided. The #54 ruling Q3 says: compare every pair, "the store key (and its strip().lower() form) and the tombstone salt, including the salt against the key". The shipped check does not meet that text for the salt.

  • SECURITY.md:66 and README.md:401 say that tokens-equal compares "the value of every secret". The comparison is on raw values only, except tokens against the key. The documents overstate the check.

  • Exposure: a salt that is a variant of the key can be derived from the key file. ADR 0007 keeps the salt apart from the Tombstone export, and the key and the salt sit in the same secrets directory, so a party with the key usually has the salt too. The defect is a missed configuration guard and a document claim that is wider than the code.

  • The salt reaches HMAC as raw bytes (tombstones.py:44-50). A fix must normalise for the comparison only. A change to the HMAC input changes every existing Tombstone hash and the salt check.

Item 2 (lock-wait docs): confirmed. README.md:24 and SECURITY.md:89 say a lock wait "ends after 5 seconds". The positions connection uses PRAGMA busy_timeout=1000 (store.py:94, store.py:313).

Items 3 to 5 (test gaps): each is a mutation that the #67 reviewers ran and that left the suite green. Not run again here.

File overlap.

  • Item 1 writes startup.py and tests/test_config_cli.py. #56 (at its gate, spec base 99a849c) writes tests/test_config_cli.py, README.md and SECURITY.md. A merge that changes those files before #56 dispatches makes the #56 source hashes stale.
  • #65 (slice B) writes startup.py, store.py and views.py. The ROLLBACK note and the Tokens backstop note write the same files.
> *This was generated by AI during triage.* ## Triage Notes **Checked against `main` at `99a849c`.** **Item 1 (salt vs normalised key): confirmed.** - `read_key_file` (`src/messages_mind_mcp/store.py:136-143`) strips whitespace and folds hex to lowercase. `read_secret_file` (`src/messages_mind_mcp/kit/secrets.py:18-42`) returns raw bytes and removes one trailing newline only. - `startup.py:127-136` appends the salt in raw form. The `strip().lower()` loop covers the held tokens only. - A reproduction with synthetic files and the shipped `read_key_file`, `read_secret_file` and `first_equal`: | Salt file content | Refused | |---|---| | the key, exact | yes | | the key in upper case | no | | the key with a leading space | no | | the key and two newlines | no | - The intended behaviour is already decided. The #54 ruling Q3 says: compare every pair, "the store key (and its `strip().lower()` form) and the tombstone salt, including the salt against the key". The shipped check does not meet that text for the salt. - `SECURITY.md:66` and `README.md:401` say that `tokens-equal` compares "the value of every secret". The comparison is on raw values only, except tokens against the key. The documents overstate the check. - Exposure: a salt that is a variant of the key can be derived from the key file. ADR 0007 keeps the salt apart from the Tombstone export, and the key and the salt sit in the same secrets directory, so a party with the key usually has the salt too. The defect is a missed configuration guard and a document claim that is wider than the code. - The salt reaches HMAC as raw bytes (`tombstones.py:44-50`). A fix must normalise for the comparison only. A change to the HMAC input changes every existing Tombstone hash and the salt check. **Item 2 (lock-wait docs): confirmed.** `README.md:24` and `SECURITY.md:89` say a lock wait "ends after 5 seconds". The positions connection uses `PRAGMA busy_timeout=1000` (`store.py:94`, `store.py:313`). **Items 3 to 5 (test gaps):** each is a mutation that the #67 reviewers ran and that left the suite green. Not run again here. **File overlap.** - Item 1 writes `startup.py` and `tests/test_config_cli.py`. #56 (at its gate, spec base `99a849c`) writes `tests/test_config_cli.py`, `README.md` and `SECURITY.md`. A merge that changes those files before #56 dispatches makes the #56 source hashes stale. - #65 (slice B) writes `startup.py`, `store.py` and `views.py`. The ROLLBACK note and the `Tokens` backstop note write the same files.
svc-agent-writer changed title from Change feed follow-ups from the #54 reviews: salt vs normalised key, lock-wait docs and ack test gaps to Change feed follow-ups from the #54 reviews: lock-wait docs, ack test gaps and notes 2026-11-15 10:11:07 +00:00
Author
Member

This was generated by AI during triage.

Triage outcome

The operator accepted each lean (operator word "accept").

  • Item 1 is now #69 (bug, ready-for-human), with the normalisation scope widened to every secret pair. It dispatches after #56 and before #65.
  • The rest of this issue stays enhancement, now ready-for-human: CONV-40 rule 3 fires, because the Tokens backstop note touches the startup secret check. It is blocked by #65, which writes startup.py and store.py.
> *This was generated by AI during triage.* ## Triage outcome The operator accepted each lean (operator word "accept"). - Item 1 is now #69 (`bug`, `ready-for-human`), with the normalisation scope widened to every secret pair. It dispatches after #56 and before #65. - The rest of this issue stays `enhancement`, now `ready-for-human`: CONV-40 rule 3 fires, because the `Tokens` backstop note touches the startup secret check. It is blocked by #65, which writes `startup.py` and `store.py`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dev/messages-mind-mcp#68
No description provided.