Repository navigation
fix(core): make atomic staging private before writing - #1925
Conversation
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e59a28992
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
6e59a28 to
d74bce5
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
## Why The terminal `#bm:links_to` regex retries a leading whitespace run at every position when no directive follows. A 150,000-space token exceeds a five-second subprocess deadline. Fixes #1900. ## What Changed Use a single-character whitespace boundary before the literal directive instead of a repeated leading whitespace group. Existing callers trim the prefix, preserving directive-removal behavior. ## Implementation Details Only the fixed literal can initiate a trailing-whitespace match, so failed whitespace suffixes cannot overlap quadratically. Both observation parsing and code-aware relation directive handling share the corrected pattern. A subprocess bounds regression runtime without mocking the parser. Stacked on #1925; only the shared directive pattern and its tests are new here. ## Testing - Before the fix: the whitespace-heavy regression timed out after five seconds. - `uv run pytest tests/markdown/test_directive_work.py tests/markdown/test_markdown_plugins.py -q --no-cov`: passed. - Semantics tests cover Unicode whitespace, terminal newlines, missing separators, and nonterminal directives. - `just fast-check`: passed, including repository type checking. - `just doctor`: passed sandboxed write/index/search self-test. ## Risks / Follow-ups The shared pattern's match start now points at the directive instead of its leading whitespace; both consumers already trim the prefix, so returned content remains identical. Broader Markdown parser work remains outside this PR. --------- Signed-off-by: phernandez <[email protected]>
Why
Atomic writes stage content in a file created with ordinary permissions, then restore the target's mode only after writing. Under umask 000, rewriting a private 0600 note stages its bytes in a 0666 file. Fixes #1906.
What Changed
Create the content-bearing staging inode with mode 0600 from the outset for both text and binary writers. Preserve the target's final permissions; newly created targets retain their normal umask-derived final mode.
Implementation Details
Capture the existing target mode, or determine the umask-derived mode using an empty probe in a private temporary directory for a new target. This avoids mutating the process-wide umask and prevents an observer from opening the content inode before permissions tighten. Existing publication-time chmod remains in place, preserving read-only and shared target behavior. No content reaches the staging file until reservation returns.
Stacked on #1924; only atomic staging permissions and their regression tests are new here.
Testing
uv run pytest tests/utils/test_atomic_staging_permissions.py tests/utils/test_file_utils.py -q --no-cov: 60 passed.just fast-check: passed, including repository type checking.just doctor: passed sandboxed write/index/search self-test.Risks / Follow-ups
This closes the staging-content permission window without changing final file modes or the atomic rename protocol. POSIX permission regressions skip Windows, which uses native ACL semantics.