Repository navigation
Batch 673: security notifier close is bounded and records every cut notice (BACKLOG #6832) - #3260
Open
wshallwshall wants to merge 9 commits into
Open
wshallwshall wants to merge 9 commits into
wshallwshall wants to merge 9 commits into
Conversation
When the shutdown's bounded step cut SecurityEventNotifier.aclose while a send waited on a slow relay, the notices still queued got no audit row, and on a full queue the close was cut while putting its stop sentinel, so the drain ran on past the close into the closed store. aclose now cancels a drain the cut left running, records the cut send with reason "interrupted" (its thread may still deliver it) and each notice still queued with reason "closing", before it returns. A WARNING line counts the queued notices, lock notices left out (BACKLOG #1131). SECURITY.md's residual bullet and the alert sink's aclose docstring are corrected to match. BACKLOG #6832 Proposed vault banner: FIXED (batch 673, branch b673/notify-aclose). Adjudicated by failing tests: a cut close left queued notices unrecorded, and a cut on a full queue left the drain running. aclose now cancels the drain and records the cut send (reason interrupted) and each queued notice (reason closing) while the store is open. Residual: those writes run in the teardown's 0.1 s cut grace, so one still running then can meet the closed store.
The precondition of the BACKLOG #3120 restart test read the sentinel a cut close left behind. The close now empties the queue, recording each notice it took, so the precondition reads an empty queue; the property assertions are unchanged. BACKLOG #6832
The send is shielded and held on the notifier, so a cut close reads
how it ended rather than guessing: a send already finished counts as
delivered or failed, and only one still running is "interrupted". A
failed send's record is a held, shielded task, so a cut during that
write no longer cancels it. Queued notices are taken and counted in the
log before any await, so a second cancel cannot leave them untold, and
they are recorded as "abandoned", apart from a notice refused once the
close began ("closing"). Failed records at close are summed into one
WARNING line; no sink means no record claim. SECURITY.md, the changelog
fragment, __main__'s counting-sink comments and the BACKLOG #3120 test
docstring are corrected to match.
BACKLOG #6832
aclose takes a timeout, and the API teardown hands it _INNER_SHARE of its step's bound, so the close cuts its own drain and starts recording before the step is cut. A send cancelled with the loop no longer raises out of the record pass; a cut send logs that its delivery is unknown, with or without a sink; a drain that died is logged rather than swallowed; the failed-record count is logged in a finally; _task is reset whatever state the drain is in. SECURITY.md now states the residual as it is: the writes are unbounded and run on beside engine.stop() until the store closes. Comments on start(), the recording set and _MAX_RECORDING are corrected. BACKLOG #6832 Proposed vault banner: FIXED (batch 673, branch b673/notify-aclose). Adjudicated by failing tests: a cut close left queued notices unrecorded, and a cut on a full queue left the drain running. aclose now stops waiting at part of the teardown step's bound, cancels the drain, and records the cut send (reason interrupted) and each queued notice (reason abandoned), with a WARNING count first. Residual, in SECURITY.md: the writes are unbounded, so under a full queue many can still meet the store's close.
The record pass of a cut close is a held, shielded task, so the teardown's cut stops only the close's wait and the rows go on being written until the store closes; SECURITY.md said so and the code did not. The close's own "did not drain" WARNING is gone: with only a lock notice in flight it would tell a logs:view reader a lock landed (BACKLOG #1131). A TimeoutError not from the close's own deadline is re-raised, and a drain failure is logged only on a cut, where nothing else raises it. SECURITY.md no longer says an interrupted provision-admin run always leaves no row. BACKLOG #6832 Proposed vault banner: FIXED (batch 673, branch b673/notify-aclose). Adjudicated by failing tests: a cut close left queued notices unrecorded, and a cut on a full queue left the drain running. aclose now stops waiting at part of the teardown step's bound, cancels the drain, and records the cut send (reason interrupted) and each queued notice (reason abandoned) in a shielded pass, with a WARNING count first. Residual, in SECURITY.md: the writes are unbounded, so under a full queue many can still meet the store's close.
The final unrepaired review found the "send still running" WARNING, skipped for a lock notice, let its absence tell a logs:view reader a lock landed, since a cut with notices queued nearly always has a send in flight (BACKLOG #1131). The line is gone; the row remains. The close's docstring and the alert sink's no longer say every record is written before the close returns, the _MAX_RECORDING comment says "at least", and a drain failure is logged only on a real cut. BACKLOG #6832
The paragraph said the engine writes the row for a cut close; the residual below it says those writes can fail. It now says the engine tries to write it, and points at the residual. BACKLOG #6832
(a) A second aclose() waits for the first to finish or be cut, and closes nothing itself, so it no longer awaits the drain the first set to None. (b) Each send passes a gate its thread must take before it mails; a cut close skips a send still waiting for a worker thread, so it never mails after the close, and records it as abandoned. (c) A close cut by its own timeout logs a WARNING on every such cut naming the queued count (lock notices left out), standing in for the teardown's cut line. __main__ says "at least an interrupt". BACKLOG #6832
The close's timeout-cut line logs at ERROR, the level of the teardown line it stands in for. The failed-send line passes the username through scrub_log_argument and the kind through notice_kind_log_label, like the closing line (the raw username predates this branch). SECURITY.md and the changelog name the abandoned reason for an unstarted send, and the start() comment no longer rests on a sentinel a close cannot leave. BACKLOG #6832
Collaborator
Author
|
QA: level xhigh. Rounds: 2 + 4 unrepaired. Tag: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch 673 (pipeline). This is its own PR because it changes a security control: how the security-event notifier closes and what it records. It merges clean with current main (
git merge-treeexit 0).BACKLOG #6832 -- the security notifier's close is bounded and leaves no notice unrecorded
b673/notify-aclose, headbc3562fea4435927dde2048e43489a4f46ab7b8e.SecurityEventNotifier.aclose(timeout):interrupted, and each queued notice, including a send that had not started on a worker thread, asabandoned. A send that finished before the cut is read as it ended.aclose()waits for the first, then returns.api/app.pypassesb * _INNER_SHAREto the close._log_send_failednow scrubs the username and the event type throughscrub_log_argument. On main, both were logged raw.__main__counting-sink comments, thealert_sinksdocstring, andchangelog.d/6832.fixed.md. The precondition of one Re-race the coord race test when the only invalid reason is start lateness #3120 test now expects an empty queue.aclosenow stops waiting at part of the teardown step's bound, cancels the drain, and records the cut send (reasoninterrupted) and each queued or unstarted notice (reasonabandoned) in a shielded pass, with an ERROR count first. Residual: those records are unbounded serial writes.Checks (Builder): ruff, both mypy package legs. pytest on test_security_notice_undelivered, test_lock_notice_off_request_path, test_lifespan_teardown, test_provision_first_administrator, test_engine_stop_budget, test_mfa, test_alert_*, test_security_doc_rate_limits and test_initial_credential_reminder: all pass. Full suite and the tests mypy leg not run. Read the pytest, mypy and changelog legs.
QA: xhigh. Rounds: 2 + 4 unrepaired. Tag:
xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings(round-8a5ebb8d4f, round-5946a3f037, round-db7e0eed1f, round-908381f651, round-67477f48ec, round-95c38613cc). Each unrepaired round led to a Manager-directed repair of a regression or a false text claim, and the last round reviewed53f5acf3. The head,bc3562fe, fixes the log level, the log scrub and the doc wording, and no review round ran on it.Open findings, to file under R2:
aclose(timeout)ignores its own timeout while it waits for the first.interrupted, so the feed shows "undelivered" for a mail that probably went out. The Manager decided to keep this: when delivery is unknown, telling the recipient it may not have arrived is the safe side._consume_outcomeswallows a late send failure, and a late success leaves itsinterruptedrow in place.abandoned.engine.stop(); under a full queue, most can be lost._record_cutreads_sendinglazily.