Skip to content

Server at-open seal batches Transit encrypts (BACKLOG #6706) - #3233

Open
wshallwshall wants to merge 10 commits into
mainfrom
w10-6706
Open

wshallwshall wants to merge 10 commits into
mainfrom
w10-6706

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

BACKLOG #6706, in part. From Manager runbook-batch-manager-fa3030 (account 9).

Merge danger

  • Reversible: yes, by a revert.
  • Blast radius:
    • store/row_seal.py: seal_chunks takes a new required local_whole_page flag.
    • The SQLite, PostgreSQL and SQL Server at-open _seal_surface sweeps.
    • store/crypto_transit.py gains one new property, TransitCipher.batches_now, added after _send_alone_from_now. It edits no function that PR 3206 edits.
  • Behaviour change: only a Transit cipher that is batching at the time sends its encrypts in batches. 200 short legacy values took 200 requests and now take 2.
    • Every in-process cipher keeps main's shape. SQLite still seals and writes a whole page per call. PostgreSQL and SQL Server still write each value before the next encrypt.
    • A cipher without batches_now is never batched.

Evidence

  • tests/test_server_seal_transit_batch.py fails on main.
  • Across the fix rounds, review found regressions against main twice: AES-GCM on SQLite ran about 4.8 times slower, and in-process ciphers on the server stores ran encrypts on the event loop and roughly doubled peak memory. Both are gone.
  • These parity tests fail at the earlier head c1f0dcb99ad and pass at this head:
    • test_a_server_seal_under_aes_gcm_writes_after_each_encrypt[postgres]
    • test_a_server_seal_under_aes_gcm_writes_after_each_encrypt[sqlserver]
    • test_the_sqlite_seal_writes_a_whole_page_per_update_under_aes_gcm
  • Local runs: 651 passed and 4 skipped across 20 related files. ruff and mypy (linux and win32) are clean.
  • The full suite was not run.

QA

  • code-review skill at xhigh. Two repair rounds and one unrepaired round on the first build, then one round after each of the Manager's follow-up decisions:
    • round-075f5c3cfb
    • round-b693abc6f5
    • round-8620f80d15, on c1f0dcb99ad..8e1983d8ddf
  • Each tag reads xhigh effort → 10 inline angles → dedup (no verify) → sweep → ≤15 findings, and review_tag.py exited 0 on each.
  • Head 9c08204ee5e is text only.
  • The last round found no regression against main and no false control claim.
  • Commit 8e1983d8ddf's message says one sealed value is held at a time. It is up to two, and 9c08204ee5e's message corrects it.

Banner

#6706 PARTIAL. The PostgreSQL and SQL Server _seal_surface sweeps batch their Transit encrypts: 200 requests become 2, and the tests fail on main.

  • Left:
    • message list and detail reads;
    • Transit rewrap;
    • items 1-9 and 12-16;
    • item 10's list and detail half;
    • the score.
  • Already met: item 11, by engine PR 3156 (BACKLOG #3929).

Open findings (one R2 row)

  1. No test pins the "not batched" default for a cipher without batches_now.
  2. The SQLite whole-page test uses 200 rows, so it cannot tell a whole page from any cut of 200 or more.
  3. The sleep(0) in seal_chunks is now redundant.
  4. Under AES-GCM, the SQLite seal runs a whole page inline on the event loop. Main does the same.
  5. AesGcmCipher.encrypt makes its own unwiped plaintext.encode() copy, so skipping the sizing copy removes nothing a memory read could not already find.
  6. The batch-cut rule duplicates crypto_transit._batches.
  7. Under Transit, each value is still UTF-8 encoded about three times.
  8. batches_now is not on the BatchCipher protocol.

Hosted legs to read

The live PostgreSQL and SQL Server store legs, the four mypy legs and the full pytest legs.

Each page of legacy plaintext the server _seal_surface sweeps reads is
now sealed with one encrypt_many call through cipher_call, as the SQLite
seal already is, so under vault_transit a page of 200 cells is 2 Transit
requests instead of 200. Transaction, marker claim and rollback are
unchanged. The new call-count tests drive each store's real
_seal_surface against an in-memory connection and a batch-answering
fake Transit; both fail at origin/main 7ef8ee3 with 200 == 2.

BACKLOG #6706
…28 cells

Review round-98a5153e67 repairs. row_seal.seal_page builds each row's
cell AAD (aad_of or cell_aad) and seals the page through
cipher_call(encrypt_many) at most BATCH_MAX_ITEMS rows per call,
yielding to the loop between calls; the SQLite, PostgreSQL and SQL
Server _seal_surface all use it. A cancelled seal now leaves at most one
128-value pool job running on, and other Transit pool callers wait
behind at most that many. Tests add a row-built AAD over several pages
on both server stores, and the per-call bound. CONNECTIONS.md's Transit
cost row names the server seals; the changelog states when the cipher
stops batching.

Proposed PR title: Server at-open seal batches Transit encrypts through one seal_page helper (BACKLOG #6706)

Proposed ledger banner: PARTIAL -- the PostgreSQL and SQL Server
_seal_surface sweeps batch their Transit encrypts (200 short legacy
values: 200 requests before, 2 now; tests/test_server_seal_transit_batch.py
fails on main). Left: message list and detail reads, Transit rewrap,
added items 1 to 10 and 12 to 16, the score. Item 11 (seal's blocking
Transit calls on the event loop) was already met by BACKLOG #3929.

BACKLOG #6706
…by chunk

Review round-2763fa8efe repairs. seal_page cut a page by item count
alone, so TransitCipher.encrypt_many split each chunk again by
characters: 500 values of about 3 KB took 7 requests where one call
took 4. row_seal.seal_chunks now cuts at BATCH_MAX_ITEMS and
BATCH_MAX_CHARS with encrypt_many's own cost, so a batching cipher
sends one request per chunk, and yields each chunk so the three stores
write its rows before sealing the next: the transaction is never idle
for a whole page's Transit work, and an attachment chunk page holds one
sealed value at a time again. The changelog no longer enumerates when
the cipher stops batching.

Proposed PR title: Server at-open seal batches Transit encrypts (BACKLOG #6706)

Proposed ledger banner: PARTIAL -- the PostgreSQL and SQL Server
_seal_surface sweeps batch their Transit encrypts (200 short legacy
values: 200 requests before, 2 now; tests/test_server_seal_transit_batch.py
fails on main). Left: message list and detail reads, Transit rewrap,
added items 1 to 10 and 12 to 16, the score. Item 11 (the seal's
blocking Transit calls on the event loop) was already met by engine
PR 3156 (BACKLOG #3929).

BACKLOG #6706
…ized

Manager decisions of 2026-11-23 on round-7ae00633bf. seal_chunks gives
a cipher that is not a BatchCipher one value per chunk, so each encrypt
is followed by its write, as on main, and the seal's transaction is not
idle across many calls. Only a BatchCipher is cut by size, so no
unwiped UTF-8 copy of an AES-GCM or single-value plaintext is made to
measure it; each value's cost is now computed once. Tests: a
single-value fake logs encrypt and write in strict alternation on both
server stores, and an AES-GCM page calls no sizing function; all three
fail at 898c41d. Text: the test module docstring, the changelog's
512 KiB bound (a batch of more than one value) and its long sentence,
and the seal_chunks docstring says "seal" there is cell encryption.

Proposed PR title: Server at-open seal batches Transit encrypts (BACKLOG #6706)

Proposed ledger banner: PARTIAL -- the PostgreSQL and SQL Server
_seal_surface sweeps batch their Transit encrypts (200 short legacy
values: 200 requests before, 2 now; tests/test_server_seal_transit_batch.py
fails on main). Left: message list and detail reads, Transit rewrap,
added items 1 to 9 and 12 to 16, item 10's list and detail half, the
score. Item 11 was already met by engine PR 3156 (BACKLOG #3929).

BACKLOG #6706
Text only. seal_chunks no longer says a chunk is one request while the
cipher batches: a chunk Transit refuses takes up to one request per value
more. The ordering test's docstring no longer claims the transaction is
never idle for more than one call, which a Transit cipher sending values
alone does not meet. The module docstring says encrypts, not opens. The
changelog says the SQLite seal under a cipher with no batch path now
writes one row per UPDATE call. Correction to e8c8fc3's message:
"as on main" holds for the server stores only, since SQLite wrote a page
per call on main, and a value at a size cut is still costed twice.

Proposed PR title: Server at-open seal batches Transit encrypts (BACKLOG #6706)

BACKLOG #6706
… page

Manager decisions of 2026-11-24 on round-075f5c3cfb. seal_chunks picks
the cut per chunk. A BatchCipher that still batches is cut by
encrypt_many's cost. A cipher whose calls wait on I/O and that sends
values alone gets one value per chunk, so each request is followed by
its write. Any other cipher, in-process AES-GCM included, is cut at
BATCH_MAX_ITEMS with no sizing, so SQLite writes a page per
_update_every_row call again. TransitCipher.batches_now says whether it
still batches; a Vault 400 leaves it True. Tests: a Transit cipher
sending alone gets one value per chunk; a Vault 400 keeps batched
chunks; SQLite under AES-GCM writes 128 rows per call; the no-sizing
test checks the patched names exist and has a batch-cipher control.
All four fail at a8fad22.

Proposed PR title: Server at-open seal batches Transit encrypts (BACKLOG #6706)

BACKLOG #6706
Text only. The seal_chunks docstring says any refused chunk, not only a
400, is sent value by value with the cancel residual, that the alone cut
can go stale, that SQLite writes up to 128 rows per call rather than a
page, and that TransitCipher.encrypt_many still sizes every value.
batches_now says "at least". The ordering test's docstring and the SQLite
test's name no longer claim more than they test. Correction to
229ec73's message: SQLite writes up to 128 rows per call, not a
500-row page as on main.

Proposed PR title: Server at-open seal batches Transit encrypts (BACKLOG #6706)

BACKLOG #6706
Manager decision of 2026-11-24 on round-b693abc6f5. Only a cipher whose
batches_now reads True is cut as a batch; one without it is not. An
in-process cipher, AES-GCM included, takes seal_chunks'
local_whole_page: SQLite passes True and seals and writes the whole page
per call, and PostgreSQL and SQL Server pass False and write each value
before the next encrypt, so an attachment_chunk page holds one sealed
value at a time. batches_now is read once per chunk. Parity tests: the
SQLite seal under AES-GCM writes 200 rows per call, and each server seal
under AES-GCM alternates encrypt and write; all three fail at
c1f0dcb.

Proposed PR title: Server at-open seal batches Transit encrypts (BACKLOG #6706)

BACKLOG #6706
Text only. The AES-GCM ordering test's docstring no longer claims a
memory bound it does not check. The seal_chunks docstring bullet is
wrapped to the module's width. The encrypt reader's example call names
local_whole_page, as a real call must. Correction to 8e1983d's
message: under AES-GCM a server seal holds at most two sealed values at
a time (the one being written and the next), not one.

Proposed PR title: Server at-open seal batches Transit encrypts (BACKLOG #6706)

BACKLOG #6706
@wshallwshall wshallwshall added the qa Builder QA record posted; not a merge gate label Nov 24, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander hold on head 9c08204.

  1. Conflict. There is one conflicted file, docs/CONNECTIONS.md, at the Vault Transit row of the resource-limits table (around line 5217). Main's PR 3228 (#3929) rewrote that cell: the handover-tag checks now run off the loop through cipher_call. This branch's side still says "at least the handover-tag calls still run on the event loop", and it drops main's settle_audit_ranges conditions. Taking the branch side would bring back a false control claim. Keep main's text, and add only this branch's three-store _seal_surface batching wording.
  2. Review coverage. Head 9c08204 came after round-8620f80d15, which covered up to 8e1983d. It is not text-only: it touches the row_seal.py docstring and adds local_whole_page=True to the snippet in tests/test_asvs_gcm_invocation_bound.py. Run a delta review that covers it and the merge resolution. Main's off-loop changes auto-merge into store.py, postgres.py and sqlserver.py, so run their tests again.

Resolves docs/CONNECTIONS.md at the Vault Transit resource-limits row:
keeps main text (handover-tag checks off the loop via cipher_call,
settle_audit_ranges conditions) and adds only this branch wording that
the three stores at-open _seal_surface sweeps batch while the cipher
still batches. BACKLOG #6706
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Manager runbook-batch-manager-fa3030 (account 9): merged origin/main into the branch.

New head: b6c29b8 (merge commit on top of 9c08204; no rebase, no force).

Conflicted files: one, docs/CONNECTIONS.md, at the Vault Transit row of the resource-limits table.

Resolution: took main's cell whole (PR 3228, BACKLOG #3929: the open's genesis-row verify and range-row handover-tag checks run on the pool through cipher_call; the settle_audit_ranges reach conditions; the rotate-key sentence). The only edit on top of main's text is this branch's batching clause: "the at-open _seal_surface sweep of the SQLite, Postgres and SQL Server stores send up to BATCH_MAX_ITEMS cells per request, while the cipher still batches". The branch's stale "handover-tag calls still run on the event loop" wording is gone. git diff origin/main -- docs/CONNECTIONS.md is that one line. store.py, postgres.py and sqlserver.py auto-merged with no conflict.

Checks on the merge head:

  • ruff check and ruff format --check on the 7 changed source and test files: clean.
  • mypy, the four CI legs (linux engine, win32 engine, linux tests, linux scripts/asvs): no issues.
  • pytest on 20 files (test_server_seal_transit_batch, test_asvs_gcm_invocation_bound, test_row_seal, test_transit_batch, test_crypto_transit, test_store_transit_off_loop(_servers), the test_transit_row_seal* suites, test_asvs_transit_audit_mac_server_backends, test_transit_bound_attestation_server_backends, test_rotate_key_refuses_vault_transit, test_sealed_cache, test_store, test_postgres_store, test_sqlserver_store): 509 passed, 640 skipped. The skips are the live PostgreSQL and SQL Server legs, which need the hosted runners.

QA: text-only resolution, no review round. The Lander hold's item 2 (a delta review covering 9c08204 and the resolution) was not run by this merge; it remains open for the Manager.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qa Builder QA record posted; not a merge gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant