Skip to content

shell: writable's probe is never named twice in a process (#760) - #835

Open
kitokey-marc[bot] wants to merge 4 commits into
mainfrom
shell-760-writable-probe-never-named-twice
Open

kitokey-marc[bot] wants to merge 4 commits into
mainfrom
shell-760-writable-probe-never-named-twice

Conversation

@kitokey-marc

@kitokey-marc kitokey-marc Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

shell: writable's probe is never named twice in a process

Closes #760.


Module

modules/shell — exactly one.

  • This pull request touches a single module
  • ⚠️ Cross-module — the cross-module label is required, justification below

Deliverable

Out of cycle: #760, found by the independent verifier of #759 and taken from ines's backlog triage (2026-11-14). It bears on D93 criterion 4 on Windows: the meeting's folder said not writable.

What it changes

  • The problem: sessions::writable wrote and then removed .kitokey-writable-<pid>, the same name on every call. On Windows, a name whose removal is still pending answers « Access is denied » when it is made again (shell: on Windows, starts at once can fail the trial's day with « Access is denied » #705). A second call in the same process could therefore find a writable folder not writable. This has not been observed yet.
  • The fix: probe makes a new file named .kitokey-writable-<pid>-<count>, where the count is kept for the process (AtomicU64). A file that an earlier Kitokey left under the same number is passed over (AlreadyExists).
    • This is the module's own convention for the same risk: the trial's file beside the day, shell: a name beside the trial's day is never given twice (#705) #759 (trial.rs, beside).
    • tempfile::NamedTempFile was the other way, and it is the field's convention. In the shell, though, tempfile is a dev-dependency only, so using it in src would add a runtime dependency (the security playbook). The counter adds none.
  • writable's behaviour is otherwise as before: it makes the folder, writes the probe, removes it, and returns the first error.

Oracle

  • The success criterion was written before the implementation: sessions::tests::a_second_probe_does_not_wait_on_the_first_ones_deletion (cdca9f5).
    • It probes twice in a row in one process.
    • Between the two probes, the first one's name stays taken: a folder stands in its place, which refuses a file as Windows does while a deletion is pending.
    • The second probe must still be made, under another name, and writable must then pass.
  • It was seen failing, for the right reason: at cdca9f5, with one name per process, the second probe panicked at src/sessions.rs:333 (probe(…).unwrap()) on the name the first one had taken.
  • It passes now: cargo test --lib sessions:: passes 2 of 2, and tests/sessions.rs passes 12 of 12.
  • Then a second test, a_probe_left_in_the_folder_is_passed_over, as shell: a name beside the trial's day is never given twice (#705) #759's: fifty names under this process's number taken, the probe made under another. Without the AlreadyExists branch, it fails.

Kind of oracle: a unit test, in the module, as #759's.


Review budget

  • Lines changed (excluding generated): 60 (57 added, 3 removed)
  • Files touched: 1
  • Within budget

Contracts

  • No contract affected

Definition of Done

  • Oracle green
  • Lint, format, types: cargo fmt --check, cargo clippy --all-targets -D warnings
  • Unit tests: as above. Two mutants are killed:
    • freezing the count (fetch_add → load) fails the first test at the second probe;
    • removing the AlreadyExists branch fails the second test.
  • The shell's whole suite passes except tests/migrate.rs::a_model_written_from_home_is_named_where_it_went. That test writes in $HOME, which this sandbox refuses; it fails the same way on main, and shell: the test of a model written from the home uses a home of its own #819 fixes it.
  • Affected documentation updated: probe's comment says why its name changes
  • Diff self-reviewed line by line

Test sheet

Verifier: session bfdb23f1-1199-4cda-ab11-22e178326643

# Given · when · then Kind Result Evidence Commit Confirmed
S1 Given a folder probed once, its probe's name still taken — a folder in its place, as a deletion pending on Windows —, when it is probed again in the same process, then the second probe is made under another name and writable passes automated passed cargo test --locked --lib sessions:: at 467e94f, run by me on Linux: a_second_probe_does_not_wait_on_the_first_ones_deletion ok, 2 passed; --test sessions 12 passed. Windows: run 43619901365, head 467e94f, job Windows — shell cargo test success. Hand mutant fetch_add → load (the count fixed): both tests failed, killed. 467e94f —
S2 Given a probe's next name already taken by a file an earlier Kitokey left, when the folder is probed, then that name is passed over, never an error automated passed a_probe_left_in_the_folder_is_passed_over ok at 467e94f, run by me. Windows: run 43619901365, head 467e94f, job Windows — shell cargo test success. Hand mutant AlreadyExists => continue → return Err(error): that test failed, killed. Hand mutant, the probe no longer removed: the unit tests pass, tests/sessions.rs a_folder_of_sessions_is_writable_or_said_not_to_be_and_nothing_is_left_in_it fails, killed. 467e94f —

Verifier's remarks: S1's pending deletion is played on Linux by a folder in the name's place, which answers AlreadyExists; Windows answers a name whose deletion is pending with « Access is denied » (PermissionDenied), which probe returns as an error, not passed over. Within one process the count never meets it; a probe of an earlier Kitokey under the same process number and count, its deletion still pending, would make writable fail — rare, not exercised. A probe left by a Kitokey stopped between its making and its removal now stays in the meeting's folder under its own name, where the old one was written over by the next call.


Summary

DONE

  • sessions::probe: a name never given twice in a process, the file made new, one left under the same number passed over.

VERIFIED

  • The test red at cdca9f5 for the right reason, then green.
  • Two mutants are killed: the count frozen, and the left name not passed over.
  • fmt and clippy are clean.
  • The shell's suite passes, apart from one failure that only this sandbox causes and that happens on main too.

ASSUMED

NOT VERIFIED

  • A run on Windows: windows.yml runs the test there on this pull request.

RISKS

  • Files a crashed Kitokey left beside the meetings (.kitokey-writable-<pid>-<n>) are not cleaned. The same was true of the old name.

Signals to report

  • I had to look at another module's implementation
  • A kernel or playbook rule got in my way for no good reason
  • A quality gate blocked without improving quality
  • A rule applied by hand would be worth automating

🤖 Generated with Claude Code

kitokey-marc Bot and others added 3 commits November 14, 2026 18:09
…the last one's deletion (#760, red)

`probe` taken out of `writable`, as it was. Its name kept taken after removal — a folder in
its place, as Windows keeps a name whose deletion is pending (#705) —, the second probe must
still be made, under another name. Red: one name per process.

Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As the trial's file beside the day (#759): a count for the process in its name, the file made
new, one left under the same number passed over. On Windows a name whose deletion is pending
refuses to be made again (#705); a second probe no longer meets the first one's name.

Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#760)

As #759's for its file beside the day: fifty names under this process's number taken, the
probe made under another. Without the AlreadyExists branch, it fails.

Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kitokey-marc kitokey-marc Bot added the out-of-cycle Work outside the current cycle: an incident, a production defect; justified in the PR label Nov 14, 2026
…-named-twice

The e2e finds a start's tray item in a second: this branch's attest saves about 20 minutes.

Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

out-of-cycle Work outside the current cycle: an incident, a production defect; justified in the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shell: sessions::writable reuses one file name, the Windows delete-pending risk of #705

0 participants