Skip to content

Make the write session public and share the file drivers (GH-1455) - #1627

Open
laughingman7743 wants to merge 8 commits into
masterfrom
refactor/1455-public-write-session
Open

laughingman7743 wants to merge 8 commits into
masterfrom
refactor/1455-public-write-session

Conversation

@laughingman7743

@laughingman7743 laughingman7743 commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

WHAT

Publishes the write session and has S3File and AioS3StreamedFile share their write logic through S3FileTarget, as decided on #1455 (Decided (2026-11-29) and decision 2 of 08:44).

Public API in pyathena.filesystem.s3_writer

  • S3WriteSession, the former _S3WriteSession. Its public methods are state, multipart, upload, completed_parts, commit_attempts, start, iter_parts, iter_copy_parts, ready, wait_ready, check, submit_part, submit_copy, commit, reserve_commit, withdraw_commit, begin_abort, abort, and abort_or_log.
  • S3WriteState, the former _S3WriteState. Its values are now plain names. COMMITTING and COMMITTED replace COMPLETING and COMPLETED. The error messages describe the states separately and read as before.
  • S3WriteStateError. S3MultipartStateError refers to the same class under its former name.

Session changes

  • commit(body=None) is now the only commit entry point. It sends PutObject if the write started no multipart upload, and otherwise completes the upload. It chooses from the session's state, not from body is None. It rejects a non-empty body for a multipart upload with ValueError, after the state checks and after raising a failed part. A repeated commit after a success returns the recorded result.
  • Entering COMMITTING, by reserve_commit() or commit(), now resolves pending ready() futures, which master left until a later change.
  • put() and complete() are now private (_put_object, _complete_parts).
  • begin_complete() and withdraw_complete() are renamed to reserve_commit() and withdraw_commit().
  • settled() is removed. No caller in the source used it, so it went under the condition of the decision.
  • abort_or_log() aborts and logs a failed abort with the upload ID instead of raising it. On an interrupt, it logs the upload ID and re-raises. It replaces the abort-failure log sites of S3File, AioS3StreamedFile, and the sync multipart copy.
  • The prepared parameters of an operation are sent as given and replace the session's request_kwargs for that operation. No current caller passes both.

Shared file drivers

S3FileTarget is now kept on the file in both modes. It builds the session on the file's core (write_session) and holds:

  • the append copy plan (iter_append_copies)
  • the commit dispatch (commit). It takes the file's cleanup for a failed commit, evicts the error's stale entries before and after that cleanup, and invalidates the path last, as both files did on master.
  • the abort with its upload-listing invalidation (abort)

The blocking and awaited waits, the fsspec buffering, the failure handling of each file, and the finalizers stay on each class. There is no base class or mixin. The stop-checked range read and the range splitter were already shared (read_range, read_ranges).

Decided during implementation (consulted with Codex only, because Fable 5.2 was at its weekly limit until 12/5):

  1. Remove settled(). Its one test waits on ready() with max_workers=1 instead.
  2. Publish commit_attempts, so that a custom driver can invalidate a cache after a commit whose response was lost.
  3. Keep the sync file's eviction of stale cache entries on a failed abort. A private _logging_abort_failure() context manager, shared with abort_or_log(), wraps the file's eviction. Aio stays without that eviction.

The final flush stays with the file (#1518). The cache invalidation after a possibly sent commit (#1523, #1536, #1562, #1579), the upload-listing invalidation (#1527), and the final-flush ownership of #1546 (#1593) are unchanged.

Not in this PR: the recheck-interval constant and the executor rename from the earlier comments, which the 14:55 decision does not include.

Closes #1455

WHY

#1340 proposal 6: the session that both files and the sync multipart copy use was private, and its commit was split across put() and complete(). The two files repeated the commit dispatch, the append copy plan, and the abort, and each of them and the copy logged an abort failure itself.

TEST

Tested at c8ca53f2, based on e0ab4875.

  • just lint: passed (ruff, mypy, license headers).
  • just test offline: 4966 passed, 6 skipped, at ba0c127e. The last commit removes one test parameter; that test was rerun.
  • Each new or repaired test was seen to fail with its behavior removed. For example:
    • the prepared-parameter rule;
    • the order of the body check;
    • the interrupt log;
    • the cleanup order around the commit's eviction and invalidation;
    • the eviction of a missing bucket;
    • the withdrawal of an untaken reservation;
    • the whole-copy boundary.
  • just docs lint: passed. sphinx-build docs on the working tree raises no warning for the changed pages. just docs build builds the git refs, not the working tree.
  • New tests in test_s3_writer.py:
    • commit() follows the state (PutObject with None, empty, or data; completion), and a repeat returns the same result.
    • commit() rejects a body for a multipart upload, but only once the state allows the commit: a committed write returns its result, and a discarded one raises its state error.
    • Reserved and withdrawn commits.
    • abort_or_log() with a failure and with an interrupt.
    • Prepared parameters replace request_kwargs, checked with a botocore Stubber. This test fails with the change reverted.
    • The alias refers to the same class.
  • No AWS test was run locally. The AWS jobs run when the PR is marked Ready.

Differential check (offline; not in the repository): a fake S3 answers at botocore's before-call event, and sockets are blocked. Each case has a fresh filesystem, the same seed, and an empty request log. It records the result, the exception, the requests (bodies as size and digest), the pyathena log records, the objects and uploads left, and a cache probe after the write (the requests that exists() and ls() send).

The matrix has 2966 cases:

  • General purpose and directory buckets × sync S3File and aio AioS3StreamedFile.
  • Modes wb, xb, and ab, with no object, a small object rewritten from the buffer, an object copied whole, or an object copied in ranges.
  • Sizes 0, 3, 8, 9, 20, and 33 bytes with a block size of 8, and part sizes from 8 to 16.
  • Commit paths:
    • sync: close, commit while open, flush(force=True) then commit, repeated commit, discard, with exit on an error, and commit after close
    • aio: close, flush(force=True) then close, repeated close, and async with exit on an error
  • Failures:
    • parts 1 or 2, the creation, the completion, and the completion with a failed, missing-bucket (NoSuchBucket), or interrupted abort
    • the PutObject (403 and 412), the completion with 412, and part copies with 412 and NoSuchKey
    • for sync, retried discard/commit after each failure
  • Sync and aio multipart copies: success, a failed part, creation, or completion, and a failed or interrupted abort.

Race-prone cases (an abort while a part may run) use max_workers=1 and wait for ready() first. Failing copies use one worker. Part request runs are compared in part-number order.

Two runs on each base were identical: 4f320bf0, 06d48025, 251a43ff, and e0ab4875. The branch was compared on each base and again after every review repair, last at ba0c127e on e0ab4875. Each comparison gave the same result:

Difference Count Intended
Exception type name S3MultipartStateError → S3WriteStateError (same class, same message) 188 cases yes, the rename
Abort-failure log lines moved from the pyathena.filesystem.s3/s3_async loggers to pyathena.filesystem.s3_writer (same text) 518 lines yes, abort_or_log()
A sync file whose abort is interrupted logs Interrupted the abort of multipart upload <id> to <uri>. 120 cases yes, abort_or_log() logs an interrupt with the upload ID, as the copy did
Any other difference (results, exceptions, requests, final objects and uploads, cache probes) 0 —

🤖 Generated with Claude Code

taken = self._state is S3WriteState.COMMITTING and self._reservation is state
if not taken:
self._refuse_unless(state, operation="commit")
if body and self._multipart:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round one (implementation behavior; /code-review high and /simplify), base 06d48025, reviewed head e0e50e61, repairs in 54c5e715. FINDINGS, repaired: commit(body) raised ValueError for a non-empty body before it read the state. A multipart write that had committed did not return its recorded result, and a failed or discarded one did not raise its state error. The body is now checked once the state allows the commit. test_commit_rejects_a_body_of_a_multipart_upload covers both and fails with the old order.

Comment thread pyathena/filesystem/s3.py
if target.append_data is not None:
self.write(target.append_data)
# Not kept twice while the file is open: the target is.
target.append_data = None

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round one (implementation behavior; /code-review high and /simplify), base 06d48025, reviewed head e0e50e61, repairs in 54c5e715. FINDINGS, repaired: a write-mode file now keeps its S3FileTarget, which held the bytes of a small appended object (up to the minimum part size) after the file had written them into its buffer. The target drops them there, here and in s3_async.py:2671.

handler = UploadIdLogged()
logger = logging.getLogger("pyathena.filesystem.s3")
# The logger of the session, whose abort_or_log() logs the upload ID.
logger = logging.getLogger("pyathena.filesystem.s3_writer")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round one (implementation behavior; /code-review high and /simplify), base 06d48025, reviewed head e0e50e61, repairs in 54c5e715. FINDINGS, repaired: this test listened on pyathena.filesystem.s3, while abort_or_log() logs on pyathena.filesystem.s3_writer. Its finally released the part either way, so it no longer checked that the upload ID is logged. It now listens on the session's logger and asserts the record, and it fails with the interrupt log removed.

Comment thread docs/filesystem.md
max_workers=4,
)
try:
if size >= 5 * 2**20:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round one (implementation behavior; /code-review high and /simplify), base 06d48025, reviewed head e0e50e61, repairs in 54c5e715. FINDINGS, repaired: the example started a multipart upload for any stream, so an empty stream sent a completion without parts. It now writes a short stream with PutObject, as the S3WriteSession docstring example does.

state = S3WriteState.ACTIVE if self._multipart else S3WriteState.IDLE
self._refuse_unless(state, operation="commit")
# Set first, so that a COMPLETING state that this sets always has
# Set first, so that a COMMITTING state that this sets always has

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round one (implementation behavior; /code-review high and /simplify), base 06d48025, reviewed head e0e50e61, repairs in 54c5e715. FINDINGS, repaired: this comment and the one in withdraw_commit() named the removed COMPLETING state.

return dict(self._prepared_params.get(method) or {})

def _request_core(self) -> S3Core:
def _request_core(self, method: str) -> S3Core:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round one (implementation behavior; /code-review high and /simplify), base 06d48025, reviewed head e0e50e61, repairs in 54c5e715. Rejected: a reviewer pass suggested merging prepared parameters with the session's request_kwargs instead of replacing them. Decision 4 on #1455 says a prepared entry replaces the session's defaults for that operation. The core's own request_kwargs are still added, and no caller passes both. The multipart copy passes prepared parameters with its plan's defaults on the core, and the files pass request_kwargs only. test_prepared_params_replace_request_kwargs pins the rule. /simplify also suggested one _send() helper for the request sites; skipped, since the creation and the parts take their parameters when they are submitted, and the rule lives in this method already.

Comment thread pyathena/filesystem/s3.py
if_match_from_lookup: bool = False
# The commit requests of the write session counted when the cache of the
# path was last invalidated after a commit (see commit()).
_invalidated_commit_attempts: int = field(default=0, init=False, repr=False, compare=False)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round one (implementation behavior; /code-review high and /simplify), base 06d48025, reviewed head e0e50e61, repairs in 54c5e715. Rejected: a reviewer pass objected to the per-write counter living on S3FileTarget. A target is resolved for one file and builds that file's one session; write_session() now says so. No second session is built on a target.

Comment thread pyathena/filesystem/s3.py
fs._invalidate(path)
self._invalidated_commit_attempts = session.commit_attempts

def abort(self, fs: S3FileSystem, session: S3WriteSession, abort: Callable[[], None]) -> None:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round one (implementation behavior; /code-review high and /simplify), base 06d48025, reviewed head e0e50e61, repairs in 54c5e715. Rejected, as decided before implementation: the callable form and the private _logging_abort_failure() keep the sync file's eviction on a failed abort (NoSuchBucket) and keep aio without it. The differential check's part1_abort_nobucket rows show the sync eviction unchanged. Adding the eviction to aio would change aio behavior, so it belongs in a separate change.

Covered in round one: the session state machine (commit, reservation, withdrawal, abort, waiters without settled()), the shared target methods, both files' write, commit, discard and finalizer paths, the sync copy, the tests, and the docs. /simplify (reuse, simplification, efficiency, altitude) applied a docstring clarification and matching example names. It skipped getvalue() or None (it keeps the mock-level put_object(path, None) calls), the fs parameter of iter_append_copies (tests override the part limits per core), and the name-valued enum (decided). The differential check was rerun after the repairs: unchanged.

Comment thread docs/filesystem.md Outdated
raise
```

`start()` creates the multipart upload, which needs at least one part before `commit()`; without it, `commit(body)` writes `body` with PutObject, and `None` or empty bytes write an empty object.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round two (claims, compatibility, operations), base 06d48025, head 54c5e715. FINDINGS, repaired: this said the parts must hold at least one byte. A completion needs at least one part, so it now says that.

S3MultipartStateError: If no upload is active, or the write failed
earlier or has been discarded.
raised yet, or the failure of the commit request.
S3WriteStateError: If the multipart upload is being created, the

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round two (claims, compatibility, operations), base 06d48025, head 54c5e715. FINDINGS, repaired: the Raises entry omitted a commit refused while another call commits the write.

Claims checked:

  • the error messages read as before: the differential check compares them (only the type name changes, as an alias)
  • settled() had no source caller
  • no caller passes both prepared parameters and request_kwargs
  • the range read and splitter were already shared
  • the docs' abort() and commit_attempts descriptions

The PR body's WHY said the abort-failure logs were all worded differently; the two file sites used the same text, so the body was corrected.

Compatibility: S3MultipartStateError is the same class, so except and isinstance keep working. _S3WriteSession was private. The S3FileTarget field is init=False and compare=False. Operations: no request changes in any of the 2966 rows. This is a static and offline review; the AWS jobs have not run yet.

@laughingman7743 laughingman7743 added this to the 5.0.0 milestone Nov 30, 2026
laughingman7743 and others added 3 commits December 1, 2026 01:29
Publish S3WriteSession and S3WriteState in s3_writer.py. The states take
plain names (COMMITTING and COMMITTED replace COMPLETING and COMPLETED),
and the error messages describe them separately. One commit(body=None)
sends PutObject or completes the multipart upload, chosen by whether the
write started one, and rejects a non-empty body for a multipart upload;
put() and complete() become private. begin_complete()/withdraw_complete()
become reserve_commit()/withdraw_commit(). settled(), which no caller
uses, is removed. abort_or_log() logs a failed or interrupted abort with
the upload ID and replaces the abort-failure log sites of both files and
of the multipart copy. Prepared parameters of an operation replace the
session's request_kwargs for that operation.

S3MultipartStateError becomes S3WriteStateError; the former name refers
to the same class.

S3File and AioS3StreamedFile keep their S3FileTarget, which builds the
session and holds the shared append copies, commit, and abort; the
blocking and awaited waits, the buffering, and the finalizers stay on
each file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1455)

commit(body) on a multipart write returned ValueError before it looked
at the state, so a commit after a success did not return the recorded
result, and a failed or discarded write did not raise its state error.
The body is now checked once the state allows the commit.

A write-mode file keeps its S3FileTarget, which held the data of a small
appended object after the file had written it into its buffer; the
target drops it there.

The interrupted-copy test listens on the session's logger, which now
logs the upload ID, and checks the record. The documentation example
writes a short stream with PutObject, the commit docstring names the
refusal of a concurrent commit, and stale comments name the
COMMITTING state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…H-1455)

The shared commit of S3FileTarget invalidated the cache of the path
before the file aborted the failed upload, and an interrupt of the
invalidation after a successful commit closed a sync file without its
buffer. The file's cleanup now runs inside the commit, before the
invalidation, as before the drivers were shared.

The session takes a reserved commit before it checks the body, so that a
rejected body fails the write and abort() aborts the upload, and it
resolves the waits of ready() when the write starts to be committed.
write_session() keeps the version of the target, which the session
refuses, and starts the invalidation record over; the append plan
yields no copy for an object that the file rewrites from its buffer.
The docstrings and docs name the fields that S3Core sets itself and when
an interrupted abort is logged; the log tests check the level and the
upload ID instead of the wording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@laughingman7743
laughingman7743 force-pushed the refactor/1455-public-write-session branch from 54c5e71 to 6971bc2 Compare November 30, 2026 16:30
Comment thread pyathena/filesystem/s3.py Outdated
session.commit(body)
except BaseException:
if on_failure is not None:
on_failure()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (Codex), relayed. Reviewer: Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d1a-b868-7f63-8023-c9ed9ddf27f0. Static review of a detached snapshot, base 06d48025, head 54c5e715; no PR text, commit message, or prior findings were given. Result: FINDINGS (10). Repairs in 5b5370de, rebased onto e0ab4875 as 6971bc25.

1. Valid, a regression of this PR; repaired. The shared commit invalidated the cache of the path before the file aborted the failed upload. An entry cached while the abort ran could then survive a completion that took effect despite its failure. An interrupt of the invalidation after a successful flush(force=True) also closed a sync file without its buffer. The file's cleanup (on_failure) now runs inside the commit, before the invalidation, as on master. test_failed_commit_invalidates_after_the_abort (sync) and test_failed_completion_invalidates_after_the_abort (aio) fail with the cleanup moved after the invalidation.

state = S3WriteState.ACTIVE if self._multipart else S3WriteState.IDLE
waiters: list[Future[None]] = []
if self._state is S3WriteState.COMMITTING and self._reservation is state:
# Reserved by reserve_commit(), and taken before the body

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (Codex), relayed. Reviewer: Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d1a-b868-7f63-8023-c9ed9ddf27f0. Static review of a detached snapshot, base 06d48025, head 54c5e715; no PR text, commit message, or prior findings were given. Result: FINDINGS (10). Repairs in 5b5370de, rebased onto e0ab4875 as 6971bc25.

2. Valid; repaired. After reserve_commit(), commit(b"extra") raised ValueError with the reservation still held. The write stayed COMMITTING, so abort() left the upload open. The commit now takes the reservation before it checks the body, so the rejected body fails the write and abort() aborts it (test_rejected_body_of_a_reserved_commit_fails_the_write).

# abort, rather than being committed.
reserved = True
self._state = S3WriteState.COMMITTING
# The waits of ready() end, as no part can be submitted.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (Codex), relayed. Reviewer: Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d1a-b868-7f63-8023-c9ed9ddf27f0. Static review of a detached snapshot, base 06d48025, head 54c5e715; no PR text, commit message, or prior findings were given. Result: FINDINGS (10). Repairs in 5b5370de, rebased onto e0ab4875 as 6971bc25.

3. Valid, pre-existing on master (begin_complete/_commit); fixed here since ready() is now public. Entering COMMITTING did not resolve pending ready() futures until another change published. Both reserve_commit() (line 803) and a direct commit() now publish (test_commit_ends_the_waits_of_ready, both forms fail without it).

Comment thread pyathena/filesystem/s3.py
self._invalidated_commit_attempts = 0
return S3WriteSession(
fs.core,
S3Path(self.bucket, self.key, self.version_id),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (Codex), relayed. Reviewer: Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d1a-b868-7f63-8023-c9ed9ddf27f0. Static review of a detached snapshot, base 06d48025, head 54c5e715; no PR text, commit message, or prior findings were given. Result: FINDINGS (10). Repairs in 5b5370de, rebased onto e0ab4875 as 6971bc25.

4. Valid for the public S3FileTarget; repaired. write_session() dropped the target's version. It now passes it, so the session refuses the write before any request (test_write_session_refuses_a_version). The files only build sessions for write modes, which have no version.

5. Repaired. A second session on one target reused the first one's invalidation record, so its first commit skipped the invalidation (also raised in round one). write_session() now starts the record over (line 5918).

Comment thread pyathena/filesystem/s3.py Outdated
which the file rewrites from its buffer (see ``append_data``).
"""
size = self.appended.get("size", 0) if self.appended is not None else 0
if size < fs.core.MULTIPART_UPLOAD_MIN_PART_SIZE:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (Codex), relayed. Reviewer: Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d1a-b868-7f63-8023-c9ed9ddf27f0. Static review of a detached snapshot, base 06d48025, head 54c5e715; no PR text, commit message, or prior findings were given. Result: FINDINGS (10). Repairs in 5b5370de, rebased onto e0ab4875 as 6971bc25.

6. Valid for the public planner; repaired. iter_append_copies() yielded a whole-object copy for an appended object that the file rewrites from its buffer. It now yields nothing below the minimum part size (test_iter_append_copies). The files call it only for larger objects, so their behavior is unchanged.

Comment thread pyathena/filesystem/s3_writer.py Outdated
``create_multipart_upload``, which are sent as given for that
operation, so that botocore rejects one that the operation
does not accept, under the fields that the core sets itself,
such as the checksum algorithm of the upload. They replace

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (Codex), relayed. Reviewer: Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d1a-b868-7f63-8023-c9ed9ddf27f0. Static review of a detached snapshot, base 06d48025, head 54c5e715; no PR text, commit message, or prior findings were given. Result: FINDINGS (10). Repairs in 5b5370de, rebased onto e0ab4875 as 6971bc25.

7. Valid as documentation; repaired. The docstrings and docs/filesystem.md now say that prepared parameters yield to the fields that S3Core sets itself, such as the upload's checksum algorithm. They also say that None or empty bytes send no body, as S3Core.put_object() does, which writes a Body of request_kwargs in that case (line 704). The session test keeps checking the body that the session passes to the core. S3Core.put_object has its own tests for the request.

failure is logged with the ID of the upload, which is kept so that a
later :meth:`abort` can retry. An interrupt, such as
``KeyboardInterrupt``, is raised, and logged with the ID of the upload
if the interrupted abort keeps it; an interrupt of the wait for the

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (Codex), relayed. Reviewer: Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d1a-b868-7f63-8023-c9ed9ddf27f0. Static review of a detached snapshot, base 06d48025, head 54c5e715; no PR text, commit message, or prior findings were given. Result: FINDINGS (10). Repairs in 5b5370de, rebased onto e0ab4875 as 6971bc25.

8. Valid; repaired. abort_or_log() now says that an interrupt is logged only if the interrupted abort keeps the upload. An interrupt of the wait for the creation is raised once the upload is aborted.

assert session.state is S3WriteState.COMMITTED
assert requests.completed == [[1]]

def test_withdrawal_leaves_a_running_commit(self):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (Codex), relayed. Reviewer: Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d1a-b868-7f63-8023-c9ed9ddf27f0. Static review of a detached snapshot, base 06d48025, head 54c5e715; no PR text, commit message, or prior findings were given. Result: FINDINGS (10). Repairs in 5b5370de, rebased onto e0ab4875 as 6971bc25.

9. Valid; repaired. The reservation test now withdraws while the completion request is held, checks that the state stays COMMITTING, and checks that the commit succeeds after the release. Withdrawing a taken reservation makes it fail.

session.abort_or_log()
level = logging.WARNING if interrupted else logging.ERROR
assert [(r.levelno, "uploadid" in r.getMessage()) for r in caplog.records] == [
(level, True)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (Codex), relayed. Reviewer: Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d1a-b868-7f63-8023-c9ed9ddf27f0. Static review of a detached snapshot, base 06d48025, head 54c5e715; no PR text, commit message, or prior findings were given. Result: FINDINGS (10). Repairs in 5b5370de, rebased onto e0ab4875 as 6971bc25.

10. Valid; repaired. This test and the multipart-copy interrupt test (test_s3.py:9863) check the level and the upload ID instead of the wording. The copy test keeps its record assertion, since its handler-based check passes even without the log (its finally releases the part).

After the repairs:

  • just test offline: 4960 passed, 6 skipped, on 6971bc25.
  • The differential check, rerun on the repaired branch, shows only the three intended differences.
  • Each new test fails with its behavior removed.

The shared commit read the buffer before the block whose failure runs
the file's cleanup, and evicted stale entries before that cleanup. The
body is now read inside that block, and the cleanup runs inside the
eviction, so that an entry cached while the upload is aborted is evicted
too, as the async file did before the drivers were shared. The sync
file passes no buffer to a multipart commit, which would keep it in the
error's traceback.

A reserved commit raises a failed part before it rejects its body. The
docs say which fields prepared parameters must not give and that a Body
of request_kwargs is sent when the commit has no body of its own. The
order tests observe the cache of a filesystem instead of the calls, and
a test covers an interrupt of the invalidation after a successful commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread pyathena/filesystem/s3.py Outdated
body = None
if buffer is not None and not session.multipart:
# None without data, which writes an empty object as well.
body = buffer.getvalue() or None

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d4b-8874-7f71-bcaa-87fac24d0c81. Static review of a detached snapshot of 6971bc25 (merge base e0ab4875). It covered the repair commit, the unchanged range-diff of the earlier commits, and the upstream filesystem commits since 06d48025. Result: FINDINGS (9). Repairs in 3d20335a.

2. Valid; repaired. buffer.getvalue() ran before the block whose failure runs the cleanup, so an interrupt there left a sync file with its buffer and an IDLE session. The body is now read inside that block.

3. Valid; repaired. The eviction of the commit's error ran before the cleanup (the abort), so an entry cached while the abort ran could survive. The cleanup now runs inside _evicting_stale, as the async driver did on master.

The tests test_failed_commit_invalidates_after_the_abort (sync, test_s3.py:13631) and its async counterpart now cache the object during the mocked abort and check the cache afterwards on an offline filesystem (finding 8). Both fail with the cleanup moved after the invalidation.

Comment thread pyathena/filesystem/s3.py
session,
# A multipart upload has its data in its parts; the buffer, which
# the error of a failed commit would keep, is not passed.
None if session.multipart else self.buffer,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d4b-8874-7f71-bcaa-87fac24d0c81. Static review of a detached snapshot of 6971bc25 (merge base e0ab4875). It covered the repair commit, the unchanged range-diff of the earlier commits, and the upstream filesystem commits since 06d48025. Result: FINDINGS (9). Repairs in 3d20335a.

6. Valid; repaired. The sync driver passed its buffer to a multipart commit, whose failure would keep it in the traceback. It now passes None; the data is in the parts.

8 (second part). Valid; repaired. test_interrupted_invalidation_keeps_a_committed_file_open (test_s3.py:13657) interrupts the invalidation after a successful commit of a force-flushed file. It checks that the file stays open and that a retry sends no second PutObject. It fails with the cleanup wrapped around the shared commit.

Comment thread pyathena/filesystem/s3_writer.py Outdated
self._refuse_unless(state, operation="commit")
if body and self._multipart:
if reserved:
# The first failure of a request, if any, before the

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d4b-8874-7f71-bcaa-87fac24d0c81. Static review of a detached snapshot of 6971bc25 (merge base e0ab4875). It covered the repair commit, the unchanged range-diff of the earlier commits, and the upstream filesystem commits since 06d48025. Result: FINDINGS (9). Repairs in 3d20335a.

4. Valid; repaired. A reserved commit that rejected its body hid a part failure recorded after the reservation. It now raises that failure first, as the completion would (test_rejected_body_of_a_reserved_commit_raises_a_failed_part, which fails without the check).

botocore rejects one that the operation does not accept.
``create_multipart_upload``, which are sent as given for that
operation, so that botocore rejects one that the operation
does not accept. They must not give the fields that the core

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d4b-8874-7f71-bcaa-87fac24d0c81. Static review of a detached snapshot of 6971bc25 (merge base e0ab4875). It covered the repair commit, the unchanged range-diff of the earlier commits, and the upstream filesystem commits since 06d48025. Result: FINDINGS (9). Repairs in 3d20335a.

7. Valid as documentation; repaired. This docstring and docs/filesystem.md now say that prepared parameters must not give the fields the core sets from the path, the upload, and the part (Bucket, Key, UploadId, PartNumber). They yield to the upload's checksum algorithm, and a Body of request_kwargs is sent when the commit has no body of its own. Not adopted: checking the request at the botocore boundary in the session test. The session passes the body through, and S3Core.put_object has its own request tests.

# abort, rather than being committed.
reserved = True
self._state = S3WriteState.COMMITTING
# The waits of ready() end, as no part can be submitted.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d4b-8874-7f71-bcaa-87fac24d0c81. Static review of a detached snapshot of 6971bc25 (merge base e0ab4875). It covered the repair commit, the unchanged range-diff of the earlier commits, and the upstream filesystem commits since 06d48025. Result: FINDINGS (9). Repairs in 3d20335a.

5. Rejected. Waiters are taken under the lock and resolved after it is released at every state change of the session. That is how master publishes too: _on_part_done, withdraw_complete, and abort all do it. An interrupt between the two steps can strand a waiter at any of them. This PR adds publishing to the two transitions into COMMITTING, which did not publish at all, so it narrows the case. A sync wait_ready() also rechecks every second. A change to how all transitions resolve waiters is outside this refactor.

Comment thread pyathena/filesystem/s3.py
ValueError: If the target names a version, which a write cannot
replace, or the block size is invalid.
"""
self._invalidated_commit_attempts = 0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d4b-8874-7f71-bcaa-87fac24d0c81. Static review of a detached snapshot of 6971bc25 (merge base e0ab4875). It covered the repair commit, the unchanged range-diff of the earlier commits, and the upstream filesystem commits since 06d48025. Result: FINDINGS (9). Repairs in 3d20335a.

1. Rejected. It needs two sessions created on one target before either commits. A target is resolved for one file and builds that file's session: write_session() says so, and the files build one session each. write_session() restarts the invalidation record for a session built after another.

9. Partly adopted. The log tests filter the session logger's records by upload ID and check the level. The ValueError checks keep a short match, which the repository's lint (ruff PT011) requires for pytest.raises(ValueError).

After the repairs:

  • just test offline: 4962 passed, 6 skipped, on 3d20335a.
  • The new tests were seen to fail with their behavior removed.
  • The differential check on 3d20335a (base e0ab4875, two identical base runs) shows only the three intended differences.

A failed commit evicts the entries that its error shows to be stale
before the cleanup, which an interrupt may end, and again after it, for
an entry cached while the upload was aborted. A commit that fails before
the session takes its reservation, such as on a closed buffer, withdraws
the reservation. A reserved commit consumes finished part requests before
it rejects a body, so that a part failure whose callback has not run is
raised first.

S3FileTarget.write_session() and iter_append_copies() take the core of
the file's filesystem, so that the async file sends through the core of
AioS3FileSystem, as before the drivers were shared. The docs name the
payload parameters that only PutObject inherits and the Body that a
commit without a body sends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread pyathena/filesystem/s3.py
# Evicts again after the cleanup, for an entry cached meanwhile.
with fs._evicting_stale(path):
try:
# Evicts before the cleanup, which an interrupt may end.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), second round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d60-bc63-7a91-8861-a7fffe210bb7. Static review of a detached snapshot of 3d20335a (merge base e0ab4875), covering the repair commit and the full change. Result: FINDINGS (8). Repairs in 8695cc58.

1. Valid, introduced by the previous repair; repaired. Moving the cleanup inside the eviction lost the sync eviction of a missing bucket when an interrupt ends the abort. The commit now evicts the error's stale entries before the cleanup (this block) and again after it (the outer block).

test_missing_bucket_of_a_failed_commit_is_evicted uses a sibling entry and NoSuchBucket:

  • cached before the commit, with the abort interrupted: fails without the inner eviction;
  • cached during the abort: fails without the outer eviction.

Comment thread pyathena/filesystem/s3.py
body = buffer.getvalue() or None
session.commit(body)
except BaseException:
session.withdraw_commit()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), second round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d60-bc63-7a91-8861-a7fffe210bb7. Static review of a detached snapshot of 3d20335a (merge base e0ab4875), covering the repair commit and the full change. Result: FINDINGS (8). Repairs in 8695cc58.

4. Valid; repaired. A commit that failed before the session took its reservation, such as getvalue() on a closed buffer, left a reserved PutObject in COMMITTING, which abort() leaves alone. The failure now withdraws an untaken reservation. A reservation that the commit took makes this a no-op. test_commit_withdraws_a_reservation_that_it_did_not_take fails without it.

max_workers=self.max_workers,
request_kwargs=self.s3_additional_kwargs,
self._session = target.write_session(
fs.core, self._requests, block_size=block_size, max_workers=self.max_workers

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), second round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d60-bc63-7a91-8861-a7fffe210bb7. Static review of a detached snapshot of 3d20335a (merge base e0ab4875), covering the repair commit and the full change. Result: FINDINGS (8). Repairs in 8695cc58.

5. Valid, a difference this PR introduced; repaired. The async file built its session on fs._sync_fs.core instead of fs.core, so a subclass whose core adds parameters would lose them. write_session() and iter_append_copies() now take the core (s3.py:5920), and each file passes fs.core, as on master. No test was added: master already used fs.core, and the change restores it.

Comment thread pyathena/filesystem/s3_writer.py Outdated
# The first failure of a request, if any, also of one
# whose callback has not run yet, before the error of
# the caller.
self._consume_finished()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), second round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d60-bc63-7a91-8861-a7fffe210bb7. Static review of a detached snapshot of 3d20335a (merge base e0ab4875), covering the repair commit and the full change. Result: FINDINGS (8). Repairs in 8695cc58.

3. Valid; repaired. A part failure whose done callback had not run yet lost to the body's ValueError. The reserved commit now consumes finished requests first, as the completion does. test_rejected_body_of_a_reserved_commit_raises_a_failed_part defers the callback and fails without the consumption.

self._reservation = state
self._state = _S3WriteState.COMPLETING
self._state = S3WriteState.COMMITTING
# The waits of ready() end, as no part can be submitted.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), second round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d60-bc63-7a91-8861-a7fffe210bb7. Static review of a detached snapshot of 3d20335a (merge base e0ab4875), covering the repair commit and the full change. Result: FINDINGS (8). Repairs in 8695cc58.

2. Rejected. On master, a reservation left the waiters for a later transition. Every later transition (part completion, withdrawal, abort, completion) takes its waiters under the lock and resolves them after releasing it, with the same window for an interrupt. Publishing at the reservation resolves the waiters at once in the normal case, instead of after the part completes. The window between taking and notifying is the same one that every publishing transition on master has. The file drivers never wait on ready() across a reservation: the async final flush waits for the flush in progress before it reserves, and the sync wait_ready() rechecks every second. A change to how all transitions resolve waiters is outside this refactor.

6. Rejected. Concurrent commit() calls on one file race on the invalidation record as they did on master's file-local counter. One file is not used from several threads at once (threadsafety 2).

Comment thread pyathena/filesystem/s3_writer.py Outdated
(see :meth:`S3Core.with_request_kwargs`). The mapping is read
(see :meth:`S3Core.with_request_kwargs`), except those that
describe the payload of the object, such as ``ContentMD5``,
which it sends with PutObject only (see :meth:`S3Core.call`).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), second round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d60-bc63-7a91-8861-a7fffe210bb7. Static review of a detached snapshot of 3d20335a (merge base e0ab4875), covering the repair commit and the full change. Result: FINDINGS (8). Repairs in 8695cc58.

7. Valid as documentation; repaired. This docstring and docs/filesystem.md now say that payload parameters such as ContentMD5 reach PutObject only. They also say that a commit without a body sends a Body from request_kwargs or from the prepared put_object parameters.

assert isinstance(result, S3CompleteMultipartUpload if multipart else S3PutObject)
assert session.state is S3WriteState.COMMITTED
assert session.commit_attempts == 1
# Empty bytes and None send the same request.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), second round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d60-bc63-7a91-8861-a7fffe210bb7. Static review of a detached snapshot of 3d20335a (merge base e0ab4875), covering the repair commit and the full change. Result: FINDINGS (8). Repairs in 8695cc58.

8. Partly adopted. The commit test no longer distinguishes b"" from None handed to the core. Kept: the matches on the session's state messages (has been discarded, was withdrawn). These are user-facing messages, and the suite matches on them elsewhere too (for example test_s3.py and test_s3_async.py). The ValueError checks keep a short match for ruff PT011.

After the repairs:

  • just test offline: 4965 passed, 6 skipped, on 8695cc58.
  • The new tests were seen to fail with their behavior removed.
  • The differential check on 8695cc58 (base e0ab4875) shows only the three intended differences.

iter_append_copies() decided with the limits of the core it was given
whether an appended object is rewritten from the buffer, which resolve()
had decided with the limits of the filesystem; with different limits, an
appended object could be neither copied nor rewritten. It now plans the
copies of the appended object, for one that resolve() did not read into
append_data, as the files call it.

Any commit, reserved or not, consumes finished part requests and raises
a failed part before it rejects a body. The docs name the checksums that
the completion of a FULL_OBJECT upload inherits and the parameters from
which a PutObject without a body takes its Body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread pyathena/filesystem/s3.py
) -> Iterator[tuple[int, tuple[int, int] | None]]:
"""Plan the part copies of the appended object, which lead the multipart upload.

For an appended object that the file copies, which :meth:`resolve`

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), third round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d77-7211-76e1-bba0-5e12a1dc3a06. Static review of a detached snapshot of 8695cc58 (merge base e0ab4875), limited to that repair and what it affects. Result: FINDINGS (6). Repairs in 91dd6bd9.

1. Valid, introduced by an earlier repair; repaired. The planner skipped an appended object below the minimum part size of the core it was given. resolve() decides copy or rewrite with the filesystem's limits, so with different limits an object could be neither copied nor rewritten. The planner now plans the copies of the appended object, for one that resolve() did not read into append_data, which is how both files call it. The planner test that covered the early return was removed. What remains is covered by the files' append tests.

# The first failure of a request, if any, also of one
# whose callback has not run yet, before the error of the
# caller.
self._consume_finished()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), third round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d77-7211-76e1-bba0-5e12a1dc3a06. Static review of a detached snapshot of 8695cc58 (merge base e0ab4875), limited to that repair and what it affects. Result: FINDINGS (6). Repairs in 91dd6bd9.

4. Valid; repaired. A direct commit without a reservation still let the body's ValueError win over a failed part whose callback had not run. Every commit now consumes finished requests and raises the failure before it rejects a body. test_rejected_body_raises_a_failed_part runs with and without a reservation, and both fail without the consumption.

Comment thread pyathena/filesystem/s3_writer.py Outdated
PutObject request of ``body``; None or empty bytes send no body of
their own, as with :meth:`S3Core.put_object`, which writes an empty
object unless the parameters of the PutObject request give ``Body``:
the prepared parameters of ``put_object``, if any, or else

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), third round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d77-7211-76e1-bba0-5e12a1dc3a06. Static review of a detached snapshot of 8695cc58 (merge base e0ab4875), limited to that repair and what it affects. Result: FINDINGS (6). Repairs in 91dd6bd9.

5, 6. Valid as documentation; repaired. The docs and this docstring now say:

  • the checksums of a FULL_OBJECT upload reach its completion;
  • a PutObject without a body takes Body from its effective parameters: the prepared put_object parameters if any, else the session's request_kwargs, then the core's.

Comment thread pyathena/filesystem/s3.py
"""
path = S3Path(self.bucket, self.key)
try:
# Evicts again after the cleanup, for an entry cached meanwhile.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), third round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d77-7211-76e1-bba0-5e12a1dc3a06. Static review of a detached snapshot of 8695cc58 (merge base e0ab4875), limited to that repair and what it affects. Result: FINDINGS (6). Repairs in 91dd6bd9.

2. Rejected. It needs a lookup that repopulates a sibling during the abort and an interrupt of that abort, two events in one failed commit. The interrupt guarantee covers one interrupt per operation. Without the interrupt, the outer eviction covers the concurrent lookup; without the concurrent lookup, the inner eviction covers the interrupt (test_missing_bucket_of_a_failed_commit_is_evicted).

3. Rejected. It needs an interrupt between the reservation and the handler of target.commit(). Only the async file reserves a commit, and its _complete_upload runs in a thread of the filesystem's pool, which interrupts do not reach (they reach the main thread only).

After the repairs:

  • just test offline: 4963 passed, 6 skipped, on 91dd6bd9.
  • The parametrized test was seen to fail with its behavior removed.
  • The differential check on 91dd6bd9 (base e0ab4875) shows only the three intended differences.

iter_append_copies() took the core whose maximum part size decided
whether the appended object is copied whole, apart from the session
that plans the ranges; with different limits, every range was copied
whole. It now takes only the session, and copies the object whole when
the session plans it as one part. A test covers the boundary at the
maximum part size.

The docs say that prepared parameters of put_object replace the
session's request_kwargs also as an empty mapping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread pyathena/filesystem/s3.py
size = self.appended.get("size", 0) if self.appended is not None else 0
parts = list(session.iter_copy_parts(size))
# An object planned as one part is copied whole.
whole_source = len(parts) == 1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), fourth round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d89-d76a-7ef3-85e0-e09fa499af8f. Static review of a detached snapshot of 91dd6bd9 (merge base e0ab4875), limited to that repair and what it affects. Result: FINDINGS (4). Repairs in ba0c127e.

1. Valid for the public planner; repaired. iter_append_copies() took a core whose maximum part size decided whole copies, apart from the session that plans the ranges. With different limits, every range was copied whole. It now takes only the session and copies the object whole when the session plans one part, which is the master rule (size <= MULTIPART_UPLOAD_MAX_PART_SIZE) for the files' shared core.

3. Valid; repaired. test_iter_append_copies covers the boundary again: at the minimum and at exactly the maximum part size, the object is copied whole; one byte more, it is copied in contiguous ranges that cover it. It fails with the boundary moved.

their own, as with :meth:`S3Core.put_object`, which writes an empty
object unless the parameters of the PutObject request give ``Body``:
the prepared parameters of ``put_object``, which, if the session has
them, also as an empty mapping, replace ``request_kwargs``, and the

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), fourth round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d89-d76a-7ef3-85e0-e09fa499af8f. Static review of a detached snapshot of 91dd6bd9 (merge base e0ab4875), limited to that repair and what it affects. Result: FINDINGS (4). Repairs in ba0c127e.

4. Valid as documentation; repaired. This docstring and the guide say that the session's put_object entry replaces request_kwargs even as an empty mapping, while the core's request_kwargs still apply.

# The first failure of a request, if any, also of one
# whose callback has not run yet, before the error of the
# caller.
self._consume_finished()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), fourth round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d89-d76a-7ef3-85e0-e09fa499af8f. Static review of a detached snapshot of 91dd6bd9 (merge base e0ab4875), limited to that repair and what it affects. Result: FINDINGS (4). Repairs in ba0c127e.

2. Rejected. It needs an interrupted part callback, after which a commit raises the consumed failure without resolving pending ready() waiters. Master's _submit() and check() raise a consumed failure without publishing in the same way, and a later operation that publishes resolves them. The sync wait_ready() also rechecks every second. This is the pre-existing pattern for an interrupted callback, not a change of this PR.

After the repairs: just test offline gave 4966 passed and 6 skipped on ba0c127e. The differential check on ba0c127e (base e0ab4875) shows only the three intended differences.

The async append test already requires a whole copy at the minimum
part size; the target test keeps the boundary at the maximum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
max_workers=1,
)

@pytest.mark.parametrize(("size", "whole"), [(8, True), (9, False)])

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up review (Codex), fifth round, relayed. Codex CLI codex exec -s read-only, model gpt-6.2-astra, session 01a22d9a-98a0-7c00-bf69-71b9cab18754. Static review of a detached snapshot of ba0c127e (merge base e0ab4875), limited to that repair. It found no runtime defect in the repairs; the sync and async append paths, part numbering, and the commit documentation were checked. Result: FINDINGS (1, low).

1. Valid; repaired in c8ca53f2. The (4, True) case duplicated the async append test, which already requires a whole copy at the minimum part size. It is dropped; the cases at exactly the maximum and one byte above it remain. This test-only change applies the reviewer's own suggestion, so it gets no further review round.

@laughingman7743
laughingman7743 marked this pull request as ready for review November 30, 2026 18:08

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the write session public and share the file drivers

1 participant