Skip to content

tests: skip the signer's fsync in the approval state space's workers (#722) - #803

Merged
LoopGlitch26 merged 1 commit into
Cygnux-Labs:mainfrom
khushi-git-7:agent/issue-722-fsync
Nov 13, 2026
Merged

LoopGlitch26 merged 1 commit into
Cygnux-Labs:mainfrom
khushi-git-7:agent/issue-722-fsync

Conversation

@khushi-git-7

@khushi-git-7 khushi-git-7 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Part (2) of #722, as agreed there: tests only.

Why

On windows-latest, ApprovalStateSpace spent most of its time in fsync. One part profiled in-process spent 2.4 s of 4.9 s in nt.fsync, against 0.08 s of 1.0 s on Linux. The syncs come from the signer's file store, its new files, and its state and key files. This class checks the approval state machine; durability has its own tests (test_storage_file.py: test_durability_modes, test_a_failed_background_sync_names_the_records_not_known_durable; storage_contract.py: test_torn_tail_is_set_aside_and_reported).

Change (tests/test_bounded.py)

  • part() runs its sequences inside signer_without_fsync(), a patch held while that part runs, in its own worker process. Inside it, os.fsync and os.fdatasync skip the calls made from the signer's modules (SIGNER_SYNCS: tracekit.storage.file, tracekit.signer.service, tracekit.deploy.files). storage.file._sync is a no-op too, since on macOS it syncs with an fcntl.
  • A sync from any other module still runs, and its module is recorded. explore() asserts there are none, so a sync the signer moves to another module fails the test and names that module, instead of quietly making it slow again.
  • The old body of part() is now _part(), unchanged.

Checked on my fork

ApprovalStateSpace, both tests passing, with the same sequences and outcomes:

as on main with this change
windows-latest 3.13 689 s 46 s
ubuntu-latest 3.13 52 s 63 s*
macos-latest 3.13 54 s
ubuntu-22.04 3.9 42 s

* a slower runner on that run; the experiment on #722, with fsync stubbed the same way, measured 36 s against 52 s on ubuntu-latest.

The guard checked against a mutation, with every sync treated as made outside the signer: both tests fail with ['tracekit.deploy.files', 'tracekit.signer.service', 'tracekit.storage.file'] != [] on all four. The first version of this change only covered storage.file, and the guard caught the other two. pyflakes tests/test_bounded.py is clean.

Next is part (3), the E20 test.

…ygnux-Labs#722)

fsync was most of ApprovalStateSpace's time on windows-latest: 689 s as on
main, 50 s with fsync skipped in the workers (52 s and 36 s on ubuntu-latest),
with the same sequences and outcomes. The class checks the approval state
machine; durability has its own tests, which the comment names.

Each part skips the syncs of the signer's modules (its logs, its new files, and
its state and key files) for its own run only, a patch held while the part runs
in its worker process. A sync from any other module still runs and is counted,
and the test expects none, so a sync the signer moves elsewhere fails it instead
of making it slow again.

Signed-off-by: Khushi Jain <jainkhushibts@gmail.com>
@LoopGlitch26

Copy link
Copy Markdown
Member

Read it. This is what we agreed:

  • the stub only while a part runs;
  • the durability tests named in its docstring;
  • the guard catching a sync made anywhere outside the signer's modules.

It goes on the merge list once CI is green.

@LoopGlitch26
LoopGlitch26 enabled auto-merge (squash) November 13, 2026 09:06
@khushi-git-7

Copy link
Copy Markdown
Contributor Author

Thanks for reading it against the plan. The e20 change for (3) builds on this one: it moves signer_without_fsync to tests/factories.py, as you suggested on #722.

@LoopGlitch26
LoopGlitch26 merged commit 5ece2ad into Cygnux-Labs:main Nov 13, 2026
34 checks passed
@LoopGlitch26

Copy link
Copy Markdown
Member

Merged, thanks. The approval state space now runs about ten minutes faster on each Windows job.

LoopGlitch26 added a commit that referenced this pull request Nov 13, 2026
#803 defined it in test_bounded.py and #806 moved it to factories and imported it; merged together, test_bounded.py
kept both and pyflakes failed (redefinition of unused 'signer_without_fsync'). The bodies were the same.

Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
LoopGlitch26 added a commit that referenced this pull request Nov 13, 2026
…ne signer_without_fsync (lint) (#820)

* tracekit audit: a gptme call its hook can't read is blocked, not an error

gptme's checks of a call's shape raised a plain ValueError. Its hook blocks such a call, but since #779 audit
counts only UnreadableCall as blocked and ends the replay on any other ValueError, so main's audit test failed
for gptme (test_the_guard_line_names_the_calls_files_agent). The two PRs each passed CI before the other merged.

Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>

* tracekit audit: a gptme MCP call whose content isn't JSON is blocked, not an error

The same mismatch as the shape checks: json.loads raised a plain ValueError, which gptme's hook blocks and audit
ended the replay on. Found by the independent review of this PR.

Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>

* tests: one signer_without_fsync, from factories (main's lint)

#803 defined it in test_bounded.py and #806 moved it to factories and imported it; merged together, test_bounded.py
kept both and pyflakes failed (redefinition of unused 'signer_without_fsync'). The bodies were the same.

Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>

---------

Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
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.

2 participants