Skip to content

Padding twins, NUL and lone-surrogate reference keys are refused on every backend (BACKLOG #6613) - #3541

Open
wshallwshall wants to merge 46 commits into
mainfrom
b20053-6613b
Open

wshallwshall wants to merge 46 commits into
mainfrom
b20053-6613b

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

Ledger row: BACKLOG #6613. Source branch b20053-6613b, head 20a74d0. Stacked on PR 3535 (b20053-6573e); merge after PR 3535.

What changed. Every store backend refuses reference keys that some backend cannot hold (padded, NUL and surrogate keys) before the transaction, as ReferenceSnapshotRefused, and refuses such a set name at load and at rename. The preview skips such a set. SQL Server reports the reference tables' collation. The SQL Server state note rides only UnauthenticatedCipherError. Docs: CONFIGURATION.md, ADR 0006 amendment, changelog fragment.

This branch is the original b20053-6613 (a41e2ab) cherry-picked unchanged onto the final #6573 branch, with no conflicts.

Merge danger. It changes a control's behaviour: reference snapshots holding such keys are now refused on every backend, where some backends used to accept them.

Proposed vault banner: SHIPPED. Every backend refuses padded, NUL and surrogate reference keys before the transaction (ReferenceSnapshotRefused), and such a set name at load and at rename; the preview skips such a set; SQL Server reports the reference tables' collation; the state note rides only UnauthenticatedCipherError; items 5 to 9 fixed. Item 3's refusal at open not built.

Checks. The original branch ran its own row checks. The restack ran pytest over 41 store, reference-key, trust-anchor, dr_backup, engine_secrets and vault files: 2474 passed, 732 skipped, 0 failed. Legs to read: every required context.

…er lower-casing (BACKLOG #5116)

_looks_like_url's docstring is the one statement docs/CONFIGURATION.md now
links for the backup and DR path keys. It said "a letter", but _URL_SCHEME
is ASCII only, and the shape is judged after str.lower(), so say both.
Docstring only; no behaviour change.

Verified-by: tests
…s real shape (BACKLOG #5116)

The four rows ([backup] destination; [dr] seed_archive, seed_dir,
restore_token) each said a URL "whose scheme has two or more characters"
is rejected. The check, _looks_like_url, needs a leading ASCII letter, so
a digit-led scheme such as 1s:// is missed and loads as a path.

The destination row now names _looks_like_url as the one statement of the
shape, and says it misses at least a one-letter scheme, a scheme holding
_, and a digit-led one. Each [dr] row links it and says what its own key
does with a missed value: seed_archive and restore_token load it as a
path; seed_dir still refuses it unless it is absolute on the platform
that loads the settings, since _seed_dir_absolute runs too.

Proposed PR title: CONFIGURATION.md states the backup/DR URL check's real shape (BACKLOG #5116)
Proposed vault banner: BUILT on branch b20053-5116 (batch 20053): the four
CONFIGURATION.md rows link _looks_like_url, whose docstring now says ASCII
and lower-cased; each row says what its key does with a missed value.

Verified-by: tests
… each position (BACKLOG #5230)

The fix itself landed with BACKLOG #5229 (PR 3301, 15b74a9): the
read-to-end check, _reads_to_the_end, refuses a file whose cadata= load
stops early without an error. This adds a test for the block with no data
under a CERTIFICATE label (LF and CRLF) and an X509 CRL label, between two
certificates, after both and before both, and asserts cafile= refuses each
file too. The between and after rows fail against anchor_cadata as it
stood before 15b74a9 (DID NOT RAISE); the before rows were already
refused there, by the trial load. The controls: nothing, or a well-formed
CRL, between the two certificates loads both by path and through the
check. Test only; no product code changes.

Proposed PR title: Pin the anchor check's refusal of a PEM block with no data (BACKLOG #5230)
Proposed vault banner: ALREADY MET by BACKLOG #5229 (PR 3301, 15b74a9),
which refuses the shape and corrected the CONFIGURATION.md sentence;
branch b20053-5230 adds the row's regression test with its controls.

Verified-by: tests
…h no link (BACKLOG #6573)

The walk screened each file by lstat, then tar.add opened it by name. A
folder or a file swapped for a symlink or a junction in between was
followed, so the target's bytes reached the archive: a swapped file up
to its own size, a swapped folder its whole listing.

Each screened file is now opened with the file connector's confined read,
_open_confined (POSIX: O_NOFOLLOW per component from a parent descriptor;
Windows: held folders, the file opened as itself, its final path checked),
and its member is described and filled from that handle with
gettarinfo(fileobj=) and addfile. A link refusal is a pass-over. Any other
open failure re-screens the name: gone is gone, a folder or link now is a
pass-over (Windows answers ERROR_ACCESS_DENIED there), and a name that
still reads as a regular file fails the backup, naming the file, as an
unreadable config file did before; Windows codes 1, 50 and 87 pass it
over. The archive file being written is still skipped, as tar.add did.
_tree_size is unchanged and still reads by name.

Tests: a file and a folder swapped for a link after the walk checked
them, with the controls carried; a file swapped for a folder, junction or
directory symlink between its screen and its open; and a file that still
screens as regular but will not open fails the backup. The swap tests for
a file symlink and a folder junction fail on origin/main. The candidate
test now hooks the open the walk makes, since the walk no longer calls
tar.add.

Verified-by: tests
…he config walk (BACKLOG #6573)

The row now states that the walk adds each file from a handle opened
through no link below the config dir, and what a swap still reaches, with
"at least", on POSIX and Windows alike: names listed behind a folder
swapped while the walk lists it, the space estimate read by name, a
second hard link, and on Windows the reopen by name of a file whose
reparse point names no path. It also states when a file the walk accepted
fails the backup and when Windows passes it over.

PARTIAL: the listing and the space estimate still read by name; closing
them needs a descriptor walk on POSIX and a held walk on Windows.

Proposed PR title: The DR config walk adds each file through no link, closing the swap race for content (BACKLOG #6573)
Proposed vault banner: PARTIAL on branch b20053-6573 (batch 20053): content
from behind a link swapped in after the check no longer reaches the
archive; the listing and the space estimate still read by name.

Verified-by: tests
…as before, on three faults (BACKLOG #6573)

A repair round on the confined config open, each fix restoring the
outcome origin/main had:

- A confined open that fails because a share or network path cannot be
  reached (Windows winerror 53 or 67, which Python maps to ENOENT) fails
  the backup, naming the file. It no longer reads as a file gone since
  the listing when the second look meets the same fault. A plain ENOENT
  still means gone. Read with path_reach.is_absent.
- A second look at the name after a failed open that fails for any
  reason but absence (EIO, a stale handle, winerror 64) fails the
  backup, naming the file, rather than passing it over.
- On Windows, a file whose final path alone cannot be read, with an
  error outside ERROR_INVALID_FUNCTION, ERROR_NOT_SUPPORTED and
  ERROR_INVALID_PARAMETER (such as winerror 3 on a volume mounted with
  no drive letter), is added by its name as before, rather than failing
  every backup. _final_path_fails re-opens the file through no link and
  reads its final path, so only that step's error takes this route.

Each has a test that fails on the unrepaired head.

Verified-by: tests
…lk cannot open or read (BACKLOG #6573)

The row said both that such a file fails the backup and, later, that
some are passed over. It now states the rule once: fail, naming the
file, except a name gone by then (left out), one that no longer reads
as a regular file (passed over), the three Windows "volume does not do
that" errors (passed over) and a Windows file whose final path alone
cannot be read (added by its name, which follows a link swapped in).
An unreachable share, a failed second look and a failed read each fail
the backup. The swap sentence names the by-name exception.

Proposed PR title: DR config walk opens each file through no link, and keeps main's outcome on share, screen and final-path faults (BACKLOG #6573)
Proposed vault banner: BUILT on engine branch b20053-6573b: the config walk adds each file from a handle opened through no link; a repair round restored origin/main's outcome for an unreachable share, a failed second screen and a Windows final-path fault.

Verified-by: none
…dded from its handle (BACKLOG #6573)

Round 3 of vault BACKLOG #6573. On 6573b a config file the confined open
had opened and found regular, whose Windows final-path query alone failed
with ERROR_INVALID_FUNCTION, ERROR_NOT_SUPPORTED or ERROR_INVALID_PARAMETER,
was passed over, where origin/main bundled it, and on any other code was
opened again by name.

transports/file.py: _open_confined takes an opt-in `unverified` list. On
it alone, when the final-path query itself fails after the regular-file
check, the open descriptor is returned and the query's error appended; a
final path that is read and names another path is still refused, and on
Windows the root itself is held and tag-checked too
(_win_hold_dirs(hold_root=True)). The default, which the file connector
uses, is unchanged: the read fails and the file stays in place. The
unused _final_path wrapper is gone.

pipeline/dr_backup.py: the config walk uses the opt-in, adds such a file
from the returned handle, closes the descriptor on every path, a tar
failure included, and logs one WARNING per walk counting such files, with
the residual stated: a folder above the config dir swapped after resolve()
is not detected. _final_path_fails and the by-name tar.add branch are
gone. _config_file_error keeps the Windows code and says the file could
not be added to the backup. 6573b's fixes for an unreachable share and a
failed re-screen stay.

tests: the final-path fault on winerror 1, 50, 87 and 3 adds the file from
its handle and closes it, also when tar fails; the default path still
fails the read and leaves the file; a mismatched final path is still a
pass-over on both paths; a root swapped for a junction is refused on the
opt-in path; the early unreachable-share raise and the screen-fault test
gain the arms and controls they lacked.

Verified-by: tests
… WARNING names every code (BACKLOG #6573)

Repair round 1 of the code-review on 5066161.

- _open_config_file returns the descriptor with the final-path error, else
  None, from a list of its own, so the walk keeps no OSError per file and
  the WARNING names every distinct code seen, not only the first.
- _reader_over builds the reader in two steps, so a failure closes the
  descriptor once: the earlier guard around os.fdopen could close it a
  second time after io.open had closed it.
- the comment on an unresolvable share root no longer says its files are
  always passed over.
- tests: the reader closes its descriptor once when either layer fails;
  the WARNING names the code.

Verified-by: tests
…not report is added from its handle (BACKLOG #6573)

The by-name add is gone, so the row drops it. It now says, once:

- on Windows a file whose final-path query fails is added from its handle
  with that check not run, and one WARNING per pass counts and names such
  files and gives the codes; a final path read that names another path
  still passes the file over;
- the residual: a folder above the config dir swapped for a link after the
  backup resolved the dir is not detected, nor on POSIX the config dir
  itself;
- a cloud placeholder is opened by name at least three times, not "a
  second time";
- the failure rule's exceptions are "at least these cases", and an open
  that fails with ERROR_INVALID_FUNCTION, ERROR_NOT_SUPPORTED or
  ERROR_INVALID_PARAMETER passes the file over.

Proposed PR title: DR config walk adds a file whose Windows final path
cannot be read from its handle, and the File connector still refuses it
(BACKLOG #6573)

Proposed vault banner: BUILT on engine branch b20053-6573c, stacked on
b20053-6573b: the config walk adds each file from a handle opened through
no link; a Windows final-path query failure adds the file from that
handle with one WARNING, the root held as itself; the File connector's
default is unchanged. Residual stated in the include_config row: a folder
above the config dir swapped after resolve (and on POSIX the dir itself)
is not detected. Owed: see the PR's open findings.

Verified-by: none
… the file (BACKLOG #6573)

Repair round 2 of the code-review, on 1eebfa0.

- the member's describe and add from the handle are wrapped, so a read
  that fails once the file is open (a byte-range lock, a file truncated
  under tar) or a tar write fault fails the backup naming the file, as
  the include_config row says; _config_file_error falls back to the
  error's text where it has no strerror.
- tests: the tar failure test asks for the file name; the reader test
  tells a closed descriptor from a number another thread reused.

Verified-by: tests
… (BACKLOG #6573)

Repair round 2 of the code-review, on 1eebfa0.

- The ancestor swap leaves the "POSIX and Windows alike" list: on POSIX a
  folder above the config dir, or the dir itself, swapped after resolve is
  not detected; on Windows only for a file whose final path cannot be
  read.
- A cloud placeholder is "opened by name more than once", the last time
  through its filter, with no closed-looking list of the opens.
- The root hold is stated as the backup walk's, not as existing behaviour
  of every confined open.

Proposed PR title: DR config walk adds a file whose Windows final path
cannot be read from its handle, and the File connector still refuses it
(BACKLOG #6573)

Proposed vault banner: BUILT on engine branch b20053-6573c, stacked on
b20053-6573b: the config walk adds each file from a handle opened through
no link; a Windows final-path query failure adds the file from that
handle with one WARNING, the root held as itself; the File connector's
default is unchanged. Residual stated in the include_config row: a folder
above the config dir swapped after resolve (and on POSIX the dir itself)
is not detected. Owed: see the PR's open findings.

Verified-by: none
…KLOG #6573)

On the backup's opted-in confined open, each held folder, the root
included, is checked again by its handle once the file is open and
before release, and the file is refused if one now names another path.
The file connector's default open is unchanged.

A final-path query is trusted only when it fails with WinError 1, 50
or 87; any other code fails the backup, naming the file. An open step
failing with one of those codes opens the file by name only on a volume
that reports no reparse points; otherwise the backup fails, naming the
file, cause and remedy. A config dir held open for delete by another
process is named as the config dir. Tests match readers by path, and a
WinError 3 open-step control is restored; the census grades the new
open, and the followers lock test faults the walk's own open.

Verified-by: tests
…CKLOG #6573)

The row says the held folders are checked again after the open, that
the re-check sees one instant, and names with "at least" what it still
misses: a folder made a link and back in between, and a folder above
the config dir. It says which final-path codes are trusted, what an
unsupported open step does on each kind of volume, the misreporting
redirector residual, and that a config dir held open for delete is
named as the dir.

Proposed PR title: DR backup config walk: re-check held folders after
the open, trust three final-path codes, open by name only where no link
can be (BACKLOG #6573)

Proposed vault banner: BUILT round 4 on engine branch b20053-6573d:
O1, O2, O4, O8 and O13 fixed; O3, O5-O7, O9-O12 and the 6573b finding 1
owed.

Verified-by: none
…ACKLOG #6573)

Review round 1 repairs. A hold of the config dir failing with WinError
1, 50 or 87 is raised as a step of the open, so the walk asks the
volume about reparse points rather than failing on the dir. A hold
reporting no such path while the dir is still there fails naming the
dir instead of leaving every file out. The by-name open goes down from
the resolved config dir whose volume answered. The re-check reads the
tag only where the reparse attribute is set. The refusal texts are
shorter and name a filter-driver remedy where the volume holds links.
The WARNING says the by-name files held nothing.

Verified-by: tests
…KLOG #6573)

The row says a hold of the config dir that the volume does not support
is a step of the open, that a file opened by name goes down from the
resolved config dir and holds nothing, which remedy each refusal names,
and that a config dir that cannot be held while it is still there is
named as the dir.

Proposed PR title: DR backup config walk: re-check held folders after
the open, trust three final-path codes, open by name only where no link
can be (BACKLOG #6573)

Proposed vault banner: BUILT round 4 on engine branch b20053-6573d:
O1, O2, O4, O8 and O13 fixed; O3, O5-O7, O9-O12 and the 6573b finding 1
owed.

Verified-by: none
…sed over (BACKLOG #6573)

Review round 2 repairs. On a volume with no reparse points, an open by
name that fails while the name now reads as no regular file passes the
file over, as the confined open does. The refusal on a volume that can
hold links names the filter or the share. The docstring no longer says
the open by name crosses no link above the config dir. The WARNING
names that residual for files opened by name and puts the codes last.
The unused reason argument of the file error is gone.

Verified-by: tests
…a proof (BACKLOG #6573)

The row says the walk reads the three final-path codes as a volume that
cannot report one, which is not a proof; that a file opened by name
also follows a swap of the config dir itself; the filter-or-share
remedy; and that a name turned into a non-file before the open by name
is passed over.

Proposed PR title: DR backup config walk: re-check held folders after
the open, trust three final-path codes, open by name only where no link
can be (BACKLOG #6573)

Proposed vault banner: BUILT round 4 on engine branch b20053-6573d:
O1, O2, O4, O8 and O13 fixed; O3, O5-O7, O9-O12 and the 6573b finding 1
owed.

Verified-by: none
…older (BACKLOG #6573)

The by-name fallback on a volume that reports no reparse points now checks
what it opened by its descriptor. POSIX opens a name swapped for a folder,
and the reader built over that descriptor raised outside the per-file
handler, so the whole backup failed and the Linux test leg went red. A
descriptor that is not a regular file is closed and passed over; an fstat
that fails closes it and fails the backup naming the file.

The new test fakes the open to reach a folder, so it fails before the fix
on Windows too.

Verified-by: tests
…t least (BACKLOG #6573)

The opt-in's re-check sees one instant. Its docstring listed two residuals
as a closed set, while the WARNING, the sibling docstring and the
include_config row give them with at least. Docstring only.

Verified-by: tests
…es the remedy (BACKLOG #6573)

On a volume reached only by its GUID path, the query of every config
file's final path fails with ERROR_PATH_NOT_FOUND, and every backup failed
with the system's text alone, which says nothing of the query or the fix.
The refusal stays: that code is no proof the volume lacks the check.

The confined open, opted in, now raises the query's failure as
_FinalPathUnread, which keeps its codes; _RootUnheld and it share one
base that copies them. The DR walk names the final-path query for that
code and gives the remedy: assign the volume a drive letter, or set
include_config = false. Any other code keeps the system's text.

Verified-by: tests
… the remedy (BACKLOG #6573)

When the hold of the config dir failed with a code saying the volume does
not do what it asked, and the volume then reported it holds reparse points
or its answer could not be read, the backup failed naming the first file
under the dir, whose fault it was not.

The confined open, opted in, now raises every root-hold failure as
_RootUnheld, keeping its codes. The DR walk sends one of the three
unsupported codes to the volume's answer as before, and a refusal there
names the config dir after the cause and the remedy, so a long path is
what the 200-character cut drops. The holds-links cause is shortened to
leave the dir more of that room.

Verified-by: tests
…, lengths measured (BACKLOG #6573)

The docstring said a file name of up to about 60 characters left the remedy
inside the 200-character cut. It left out the class and code prefixes, so
the real figure was about 53, and an ordinary relative name pushed the
remedy out of the audit row and the alert.

Every refusal of a config file or the config dir on the walk's open steps
now reads "<what>: <cause and remedy>: <name>", the dir's sharing-violation
refusal included, so the cut takes the name, whole, before the remedy. The
final-path cause is shortened. The lengths are measured from the final
text as safe_exc renders it twice, as BackupError and the audit row do:
a name survives whole up to 55 to 68 characters by arm, 30 for the
final-path refusal. A test pins each arm's length through safe_exc at the
200-character cut, one longer, and a 150-character name.

Verified-by: tests
…BACKLOG #6573)

The row now says that a final-path query failing with ERROR_PATH_NOT_FOUND,
which at least a volume with no drive letter gives, names the query and the
remedy; that a refusal after an unsupported root hold names the config dir;
that an open by name reaching no regular file is passed over; and that each
refusal gives the cause and any remedy before the name, so the audit row's
200-character cut drops a long name rather than them. Only the
include_config row changes.

Proposed PR title: DR config walk: refusals lead with cause and remedy, a
refused root hold names the dir, an open by name passes a folder over
(BACKLOG #6573)

Proposed vault banner: PARTIAL, round 5 on engine branch b20053-6573e,
stacked on b20053-6573d: the by-name open checks its descriptor; a refused
root hold names the config dir; a volume with no drive letter gets a
remedy; refusals lead with cause and remedy, with lengths pinned by test.
Round-3 findings F2, F3, F5 and the rest are owed, as is a GUID volume-name
fallback for the final-path check.

Verified-by: none
Review round 1 (code-review xhigh) found, and this fixes:

- A final-path query failing with ERROR_PATH_NOT_FOUND, and a root hold
  the volume does not support, skipped the screen of the file's name that
  every other failed open runs, so a name gone or swapped since the listing
  failed the backup where the base branch left it out or passed it over.
  Both now take that screen first.
- The final-path remedy named a cause the walk never checked. It now reads
  as a condition: if the volume has no drive letter, assign it one, or set
  include_config = false.
- The config dir's refusal kept the period Windows ends its text with, and
  read ".:" before the dir. Its docstring named an alert's cut, which a
  staging leftover can lead.
- The fstat comment claimed a POSIX path production never reaches; the
  _open_confined docstring paragraph is reflowed to 100 columns.
- The length test used Windows' own sharing-violation text, and a long name
  short enough to stay under MAX_PATH; the final-path length is now 41.

Verified-by: tests
…on (BACKLOG #6573)

The ERROR_PATH_NOT_FOUND remedy now reads as the refusal does: if the
volume has no drive letter, assign it one, or set include_config = false.
The row also says that the screen of the name after a failed open covers
that final-path failure and a refused hold of the config dir. Only the
include_config row changes.

Proposed PR title: DR config walk: refusals lead with cause and remedy, a
refused root hold names the dir, an open by name passes a folder over
(BACKLOG #6573)

Proposed vault banner: PARTIAL, round 5 on engine branch b20053-6573e,
stacked on b20053-6573d: the by-name open checks its descriptor; a refused
root hold names the config dir; a final path a volume with no drive letter
cannot give gets a remedy; refusals lead with cause and remedy, lengths
pinned by test. Round-3 findings F2, F3, F5 and the rest are owed, as are
a GUID volume-name fallback for the final-path check and the round-5
review findings left open.

Verified-by: none
Review round 2 (code-review xhigh) found, and this fixes:

- A final-path query that failed because its share could not be reached
  came wrapped in _FinalPathUnread, which the unreachable-share guard did
  not see through, so a screen that then read the name as gone left the
  file out unrecorded. The guard now reads the wrapped error, and the
  backup fails naming the file, as on the base branch.
- The ERROR_PATH_NOT_FOUND constant is file.py's _WIN_PATH_NOT_FOUND,
  imported with the others, not a third copy.
- The config dir's refusal is built in one place, _config_dir_error,
  which now takes the reason the volume arm gives.
- The length test shows a name one character too long is dropped whole,
  not cut part-way.

Verified-by: tests
… as unsupported (BACKLOG #6573)

Review round 2 found the row said a name gone after any refused hold of
the config dir is left out unrecorded. Only a hold refused with one of the
three unsupported-volume codes screens the name; any other refused hold
fails the backup naming the dir, as the row says further on. The sentence
on what comes before the name now says refusals, not failures, since a
file's other failures still name it first. Only the include_config row
changes.

Proposed PR title: DR config walk: refusals lead with cause and remedy, a
refused root hold names the dir, an open by name passes a folder over
(BACKLOG #6573)

Proposed vault banner: PARTIAL, round 5 on engine branch b20053-6573e,
stacked on b20053-6573d: the by-name open checks its descriptor; a refused
root hold names the config dir; a final path a volume with no drive letter
cannot give gets a remedy; refusals lead with cause and remedy, lengths
pinned by test. Round-3 findings F2, F3, F5 and the rest are owed, as are
a GUID volume-name fallback for the final-path check and the round-5
review findings left open.

Verified-by: none
…e platform (BACKLOG #6573)

ctypes.WinError exists only on Windows, so the tests mypy leg, which runs
for linux, refused the call. The test is Windows-only by its skip; a
platform check now narrows it for mypy too. Test only.

Proposed PR title: DR config walk: refusals lead with cause and remedy, a
refused root hold names the dir, an open by name passes a folder over
(BACKLOG #6573)

Proposed vault banner: PARTIAL, round 5 on engine branch b20053-6573e,
stacked on b20053-6573d: the by-name open checks its descriptor; a refused
root hold names the config dir; a final path a volume with no drive letter
cannot give gets a remedy; refusals lead with cause and remedy, lengths
pinned by test. Round-3 findings F2, F3, F5 and the rest are owed, as are
a GUID volume-name fallback for the final-path check and the round-5
review findings left open.

Verified-by: tests
…(BACKLOG #6613)

The trailing-space reference-key refusal moves from SQL Server's width
guard into store/reference_keys.py, which all three backends call before
the snapshot transaction, and gains a U+0000 key refusal for Postgres.
Both raise ReferenceSnapshotRefused (ReferenceKeyCollision is now its
subclass), naming the set and 0-based key ordinals only; reference_sync
logs it whole. Registry.add_reference refuses a set name ending in a
space or holding U+0000, which SQL Server would merge or Postgres refuse.

SQL Server: the open-time collation report (now _report_key_collations)
covers reference and reference_version too, says a failed metadata read
aborts the open, and the state-cache note rides only an
UnauthenticatedCipherError, folded into _load_state_cache. The width
guard uses _utf16_units and named width constants.

SetState names any surrogate code point, not "lone surrogate", since half
a pair is refused too. StateKeyError is exported from messagefoundry;
both reference errors are in store.base.__all__. The reply_dropped test
docstrings cite #3462.

Not built: a refusal at open for a non-binary state key collation. It
would refuse a store whose pre-#1588 state table opens today.

BACKLOG #6613

Verified-by: tests
…ogate wording (BACKLOG #6613)

CONFIGURATION.md's Reference sets section states the key and set-name
refusals every backend now applies, what the ordinals count, and that
SQL Server reports the reference tables' collation. The SetState keys
paragraph names any surrogate code point, and says only a failed metadata
read stops the open. ADR 0006 gains a dated amendment. A changelog
fragment corrects the 0.5.3 entry that said each SetState refusal names
a length.

BACKLOG #6613

Proposed PR title: Reference keys some backend cannot hold are refused on every backend (BACKLOG #6613)
Proposed vault banner: SHIPPED. Every backend refuses padded and NUL reference keys before the transaction (ReferenceSnapshotRefused), a padded or NUL set name at load; SQL Server reports the reference tables' collation; the state note rides only UnauthenticatedCipherError; items 5 to 9 fixed. Item 3's refusal at open not built: it would refuse a pre-#1588 store that opens today.

Verified-by: none
…es (BACKLOG #6613)

The dry-run reference preview runs the shared key guard, so check no
longer passes a Handler against a set every backend refuses. A rename to
a set name ending in a space is refused at plan time. The guard also
refuses a surrogate code point in a key, which surfaced as a bare
UnicodeEncodeError. A non-string set name reaches the registry as before.

SQL Server: the reference collation warning names the tables that fold
and says what that does to names and keys; the state-cache note's
docstring says a key not supplied fails the tag too; the width constant's
comment gives the real byte sum, and a test pins both constants to the
DDL; an ASCII key skips the UTF-16 encode. The vacuous width-guard
control is gone, and the trailing-space twin test expects the name rule's
refusal, which now fires first. Claims now name the rules the guard
applies rather than every backend limit.

BACKLOG #6613

Verified-by: tests
CONFIGURATION.md and the changelog fragment add the surrogate key rule,
the dry-run and check skip, and the rename refusal, and give the
cross-reload reason for the set-name rule rather than the twin case
graph validation already refuses.

BACKLOG #6613

Proposed PR title: Reference keys some backend cannot hold are refused on every backend (BACKLOG #6613)
Proposed vault banner: SHIPPED. Every backend refuses padded, NUL and surrogate reference keys before the transaction (ReferenceSnapshotRefused), and a padded or NUL set name at load and at rename; the preview skips such a set; SQL Server reports the reference tables' collation; the state note rides only UnauthenticatedCipherError; items 5 to 9 fixed. Item 3's refusal at open not built: it would refuse a pre-#1588 store that opens today.

Verified-by: none
A set name holding a surrogate code point is refused at load, as the
rename path already refused it. The reference guard reuses
controlchars.has_lone_surrogate. The dry-run warning for a refused set is
logged once per set per process. The SQL Server collation warning names
each folding table.column, and a comment at the report call records why
it warns rather than refuses. The add_reference comment no longer credits
case_twins with the same-graph case, and a database-lookup test keeps the
twin check's trailing-space fold covered.

BACKLOG #6613

Verified-by: tests
The changelog headline names the three key rules and says SQL Server's
widths stay its own. CONFIGURATION.md says the preview warning names the
same set, rule and ordinals, and that an engine that synced the set keeps
serving its last-good snapshot. ADR 0006's amendment lists every rule
the change adds, and the surrogate set-name refusal.

BACKLOG #6613

Proposed PR title: Reference keys some backend cannot hold are refused on every backend (BACKLOG #6613)
Proposed vault banner: SHIPPED. Every backend refuses padded, NUL and surrogate reference keys before the transaction (ReferenceSnapshotRefused), and such a set name at load and at rename; the preview skips such a set; SQL Server reports the reference tables' collation; the state note rides only UnauthenticatedCipherError; items 5 to 9 fixed. Item 3's refusal at open not built: it would refuse a pre-#1588 store that opens today.

Verified-by: none
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

QA for the restack (covers PRs 3541 and 3542): code-review at xhigh on git diff origin/b20053-6573e...origin/b20053-4800c, run once with no repair round. Fork a8d3fc8ca305961ab round-8488c3b9f4. Tag: "xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings". Rounds: 1. 14 open, 0 repaired.

Original row reviews: #6613 forks a8c3e1f1d44a6efb9 round-91defbd1, a21d50b0ef1a65726 round-87d00059, a394fac99e56464f0 round-b3c64a66. #4800 forks aca84523d26f5edd7 round-9fa1efcc, a9a577396b2bbda6d round-425d243b, then the docstring round's forks a8e6cf0c087e9049f round-52b6527eb7, a980b78b8116b168e round-1dadb41cc5, a951edb558433f801 round-3c8ccff3ae (Rounds 2 + 1 unrepaired).

Disclosure: the original Builder of both rows had a worktree-guard "too complex to verify" refusal and then made the change with Edit on an explicit path inside its own worktree. The owner ruled that a corrected act on 2026-12-01 (decision d20261202T003713356-3565dc).

@wshallwshall wshallwshall added the qa Builder QA record posted; not a merge gate label Dec 2, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander handover. PR 3541, MEFORORG/MessageFoundry, head 20a74d0.
Unread legs: every required context.
Landing order: after PR 3535 (which follows 3534, which follows 3533); PR 3542 stacks on this one.
Known defects (restack review, content unchanged from the original 6613 branch):

  1. Behaviour-changing: the shared rules omit SQL Server's width limits (key 450 units, set name 256), so a set only SQL Server cannot hold passes load, dry-run and check on SQLite or Postgres.
  2. Behaviour-changing, and its text claim is false: _load_state_cache adds the folding-collation note only to UnauthenticatedCipherError, so a plain CipherError under Vault Transit loses it, and the docstring and changelog lines about it are false.
  3. Behaviour-changing: dryrun _refused_reference_sets_logged is never cleared, so a later different refusal of the same set drops it with no warning.
  4. A comment justifies warn-not-refuse on a folding collation by pointing to pre-feat(security): DAST ingress-plane pass over live MLLP, raw-TCP and X12 listeners (BACKLOG #318) #1588 stores.
  5. Performance: the key guard runs a per-key Python pass on the event loop, twice on SQL Server.
  6. The promotion reload decrypts state rows without the collation note.
  7. _report_key_collations turns a NULL into the string "None".
  8. Not behaviour-changing: CONNECTIONS.md ~24 still says a set name is refused only beside a trailing-space twin; the changelog headline says "padded"; the rule is written three times; the guard sits per backend; ordinals are restated.
    Each is queued for filing under ledger ruling R2.

@github-actions github-actions Bot added the ci-red A required check went red. Attribute it before retrying. label Dec 2, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Manager d6318533: windows test shard 2 fails tests/test_reference_sets.py::test_a_nul_key_refusal_is_logged_whole because the #6613 test opens 'nul.db', a reserved device name on Windows. A fix is being pushed to b20053-6613b and merged into b20053-4800c (fast-forward, no force). The red dependency-and-secret-scan (npm-audit, ide glob) is main-wide and clears when PR 3516 merges; docker image smoke is not required and fails on main's own run 46749188753. SQL Server lease-race (3541) will re-run with the new head.

…me (BACKLOG #6613)

test_a_nul_key_refusal_is_logged_whole opened tmp_path / "nul.db". NUL with any
extension is a reserved device name on Windows, so MessageStore.open failed with
"unable to open database file" on the windows-2022 test shard. The file is now
nul_key.db. No other test file this stack added uses a reserved device name.

Verified-by: tests
…#6613)

The comment added with the rename said NUL with any extension is reserved
on Windows. That holds on Windows Server 2022, the windows-2022 runner, and
not on Windows 11, where NUL.<ext> is a regular file. The comment now says
so, matching tests/test_audit_integrity.py. The previous commit's message
carries the same overstatement; this one corrects it.

Proposed PR title: unchanged (this repairs the existing #6613 branch).

Verified-by: tests
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Manager d6318533: head moved to 746bb5c (fast-forward). a95af89 renames the test store from nul.db to nul_key.db (reserved device name on windows-2022); 746bb5c corrects the comment. Test-only, no control change. QA: xhigh, tag xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (forks af004d692f3d84eb0 round-0f66d018, a1c8f6afba952f708 round-fcfde366; review_tag.py), Rounds 1 + 1 unrepaired. Leg to read: test shard 2 (windows-2022). Open (to file): no census guard for reserved tmp_path names; MessageStore.open does not screen reserved names (--db nul.db would fail with only 'unable to open database file'); the test's docstring claims 'last-good kept, retried' it does not assert; the comment names Server 2022 where Windows 10 / Server 2019 behave alike.

…kup; the held-dir refusal names its remedy

The screen before a config file's confined open read any ENOENT as a file
gone, so a share or network path that could not be reached (WinError 53,
67) left the file out unrecorded while docs/CONFIGURATION.md said it fails
the backup. It now fails the backup naming the file; a plain absent file
is still left out.

The refusal for a config dir that cannot be held as itself now gives the
remedy before the dir (close what holds it open, or include_config =
false), and the include_config row states it. The pinned survivor length
for that arm moves from 68 to 15.

Repair of the Lander's hold on PR 3535 (BACKLOG #6573).

Verified-by: tests
…en in short so the dir still survives the cut

Review round 1 of the repair: the remedy to close what holds the config
dir open was given for every failed hold, path-not-found and access
denied included, and its length pushed the dir past the audit row's
200-character cut for any real path. It is now given only for
ERROR_SHARING_VIOLATION, with a short cause in place of Windows' text,
so a dir of up to 68 characters survives as before. The docs row quotes
the text the code emits; the first-screen test pins which screen
faulted.

Repair of the Lander's hold on PR 3535 (BACKLOG #6573).

Verified-by: tests
…er passed over; the held-dir quote is pinned

Review round 2 of the repair: the include_config row still said the walk
passes over any file whose stat fails, and that the skipped list names a
file it could not stat for any reason but absence. Both now except a
share or network path that cannot be reached, which fails the backup. A
test pins that the row quotes the held-dir refusal text the code gives,
and the constant's comment drops a miscounted length.

Repair of the Lander's hold on PR 3535 (BACKLOG #6573).

Verified-by: tests
…corded subfolder

The include_config row of docs/CONFIGURATION.md said a share or network
path that cannot be reached fails the backup. That holds for a file the
walk listed. A subfolder whose listing fails with ERROR_BAD_NETPATH or
ERROR_BAD_NET_NAME is dropped by the walk's onerror with no record, and
the run succeeds. The row now says so, names the two codes where it said
"unreachable", and says a share lost with another code at the first
stat, such as ERROR_NETNAME_DELETED, is passed over. Text only; no code
or test changes.

Repair of the Lander hold on PR 3535 (BACKLOG #6573).

Verified-by: tests
Base automatically changed from b20053-6573e to main December 2, 2026 23:41
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): 3535 merged (3e75f94), so this PR is retargeted to main. Held at 746bb5c for one thing: it was built on an older head of 3535 and now conflicts with main in five files (docs/CONFIGURATION.md, config/settings.py, pipeline/dr_backup.py, tests/test_backup_runner.py, tests/test_trust_anchor_byte_binding.py).

Outcome, and nothing else (a Lander repair Builder makes it now, repair 1 of 2; please do not push until it reports here). Two ordinary merges, no rebase and no force-push: first 3535's final head 3e75f941363152edc378c2983c19eb5173dd5aa0, then origin/main. For 3535's own content main's text wins; this PR's own content is kept word for word. After it, git diff origin/main HEAD holds only this PR's change. If a conflict needs a choice between two deliberate changes, the Builder stops and reports it.

Proof. The touched test files' counts, the diff stat against main, then my full independent review.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): held at 8a2967d for four fixes. My independent review ran (fresh-context subagent; code-review xhigh, round-7b42e0f8d6, tag read; main and head run on SQLite, Postgres and SQL Server read; 291 pass). The code loses no data, and the head accepted nothing main refused. The merges are clean.

Fix, these and nothing else (Lander repair 2 of 2, a Lander Builder makes it now; please do not push until it reports here).

  1. sqlserver.py _load_state_cache: the folding-collation note rides only UnauthenticatedCipherError; on main it rode any CipherError, and a Transit refusal with wrapped, oversize or unreadable text stays a plain CipherError, so the note is lost. Restore except CipherError, and correct the docstring ("cannot come from a merge"), the changelog ("the one error a merged row can cause") and the test docstring. A test with a plain CipherError, failing on this head.
  2. docs/CONFIGURATION.md near 725: "The open goes on after the warning; only a failure of the metadata read itself stops it" is false, because a merged row fails a keyed open at cache warm-up. Say only that the warning itself does not stop the open.
  3. The padding-collision, NUL and surrogate key refusals, and CONFIGURATION.md, name the remedy: strip or remove the named keys at the source. Update the tests that pin the words.
  4. The changelog headline claims only what is refused: padding twins, NUL and lone-surrogate keys on every backend, and set names at load and rename. A lone padded key and an over-long key are still accepted. I change the PR title.

Proof. The touched tests' counts, ruff and mypy, and my review of the delta.

Queued for filing under R2: CONNECTIONS.md 23 still says a trailing-space set name is refused only beside a twin (safe); the add_reference comment on the case_twins fold is false for U+3000 (by reading); "check skips with a warning" without .hl7 fixtures (not checked); a later, different dry-run refusal of the same set is not logged; a comment argues from pre-#1588 stores (section 0); the SQL Server width refusal logs only its class (on main); a per-key surrogate scan runs on the event loop; no note on the promotion reload or reference cache (on main).

@wshallwshall wshallwshall changed the title Reference keys some backend cannot hold are refused on every backend (BACKLOG #6613) Padding twins, NUL and lone-surrogate reference keys are refused on every backend (BACKLOG #6613) Dec 3, 2026
…olding state collation (BACKLOG #6613)

The SQL Server state cache note rides any CipherError again, as on main: the Transit cipher raises a
plain one for a failed tag whose reason it cannot read. The padding, NUL and surrogate refusals name
the remedy at the source. CONFIGURATION.md and the changelog claim only what holds.

Verified-by: tests
…tring hedges (BACKLOG #6613)

Review repair: the collision remedy keeps one unpadded key, the surrogate remedy writes a pair as its
one character, and a merged row may, not must, fail to decrypt.

Verified-by: tests
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): cleared at the pinned head fc69c72, to be enqueued once every required check is green and the Postgres, SQL Server and windows-2022 shard 2 legs are read. Review proof: 8a2967d in full (independent, code-review xhigh, round-7b42e0f8d6, tag read) and the delta (independent, xhigh, round-30e8d5a7cf, tag read; 198 pass). All four fixes are met.

The new refusals: decision d20261203T001834391-baeab8, decided by the Lander under the Owner's instruction of 2026-11-28, empower added class 3. They are loud, name cause and remedy, keep the last good set, change no stored data, and are in docs/CONFIGURATION.md. Undo: revert. Relaxing them later is a follow-up with an open owner line.

Queued for filing under R2: the collision remedy gives no rule for which value to keep and does not tell the author to strip the Handler's lookup; stripping a NUL or surrogate can make two keys equal, so the remedy should lead with fixing the source encoding; the folding note also rides CipherUnavailableError (on main); a docstring's "key not supplied" is wrong for a keyless open; a test comment is too absolute; stale comments omit the remedy; the "keep only one" clause is untested; CONFIGURATION.md omits two open failures; duplicated remedy prose; the items in the hold.

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

ci-red A required check went red. Attribute it before retrying. qa Builder QA record posted; not a merge gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant